akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int n;
char s[100010];
char g[100010];
int top=0;

int main(){
	scanf("%s",s+1);
	n=strlen(s+1);
	g[++top]=s[1];
	for(int i=2;i<=n;i++){
		if(top==0) g[++top]=s[i];
		else if(s[i]==g[top]) g[++top]=s[i];
		else top--;
	}
	printf("%d\n",n-top);
	
	return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <cstdio>
#include <vector>
#include <array>
#include <algorithm>

using namespace std;

int main() {
	while (true) {
		int n;
		cin >> n;

		if (n == 0) break;

		int head = 1;
		int tail = 1;
		long long sum = 1;
		long long count = 0;

		while (tail!=n) {
			if (sum <= n) {
				if (sum == n) ++count;
				++head;
				sum += head;
			} else {
				sum -= tail;
				++tail;
			}
		}

		cout << count << endl;
	}
}

Measured memory_bytes: 1156
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0, i##_len = (n); i < i##_len; i++)
#define reps(i, s, n) for(ll i = (s), i##_len = (n); i < i##_len; i++)
#define rrep(i, n) for(ll i = (n) - 1; i >= 0; i--)
#define rreps(i, e, n) for(ll i = (n) - 1; i >= (e); i--)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
#define len(x) ((ll)(x).length())

ll gcd(ll a, ll b) {
    return b ? gcd(b, a % b) : a;
}

ll lcm(ll a, ll b) {
    return a / gcd(a, b) * b;
}

ll divcnt(ll a) {
    ll ans = 0;
    while((a > 0) && (a % 2 == 0)) {
        a /= 2;
        ans++;
    }
    return ans;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    // std::ifstream in("input.txt");
    // std::cin.rdbuf(in.rdbuf());
    ll n, m;
    cin >> n >> m;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n) a[i] /= 2;
    ll dc = divcnt(a[0]);
    ll dv = 1LL << dc;
    rep(i, n) {
        if (dc != divcnt(a[i])) {
            cout << 0 << endl;
            return 0;
        }
        a[i] /= dv;
    }
    m /= dv;
    ll lv = a[0];
    rep(i, n) {
        lv = lcm(lv, a[i]);
        if (lv > m) {
            cout << 0 << endl;
            return 0;
        }
    }
    cout << ((m / lv + 1) / 2) << endl;
    return 0;
}


Measured memory_bytes: 1152
import sys
import socket
from math import sin, cos, sqrt, pi


hostname = socket.gethostname()

if hostname == 'F451C':
    sys.stdin = open('c1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()


def main():
    A, B, H, M = read_int_list()
    phi1 = 30 * H + 0.5 * M
    phi1 *= pi / 180
    x1 = A * sin(phi1)
    y1 = A * cos(phi1)

    phi2 = 6 * M
    phi2 *= pi / 180
    x2 = B * sin(phi2)
    y2 = B * cos(phi2)
    
    d2 = (x1 - x2)**2 + (y1 - y2)**2
    res = sqrt(d2)
    print(res)


main()


Measured memory_bytes: 10140
import java.util.*;

public class Main {
	
//	public static String rev(int s) {
//		 String rev = new StringBuffer(s).reverse().toString();
//		 return rev;
//	}
	

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String st1 = sc.next();
		String st2 = sc.next();
		int l1 = st1.length();
		char[] arr1 = st1.toCharArray();
		char[] arr2 = st2.toCharArray();
		int cnt = 0;
		for(int i = 0; i < l1; i++) {
			if(arr1[i] != arr2[i]) {
				cnt++;
			}
				
		}
       
        	
        	
        	System.out.println(cnt);
        }
         
        
        
        
	
}

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

// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
	ll x; // typedef long long ll;
	mint(ll x = 0) :x((x%mod + mod) % mod) {}
	mint operator-() const { return mint(-x); }
	mint& operator+=(const mint a) {
		if ((x += a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator-=(const mint a) {
		if ((x += mod - a.x) >= mod) x -= mod;
		return *this;
	}
	mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this; }
	mint operator+(const mint a) const { return mint(*this) += a; }
	mint operator-(const mint a) const { return mint(*this) -= a; }
	mint operator*(const mint a) const { return mint(*this) *= a; }
	mint pow(ll t) const {
		if (!t) return 1;
		mint a = pow(t >> 1);
		a *= a;
		if (t & 1) a *= *this;
		return a;
	}

	// for prime mod
	mint inv() const { return pow(mod - 2); }
	mint& operator/=(const mint a) { return *this *= a.inv(); }
	mint operator/(const mint a) const { return mint(*this) /= a; }
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x; }
ostream& operator<<(ostream& os, const mint& a) { return os << a.x; }

int main() {
	string S;
	cin >> S;
	vector<vector<mint>> dp(S.size() + 1, vector<mint>(4));
	dp[0][0] = 1;
	for (int i = 0; i < S.size(); ++i) {
		if ('A' == S[i]) {
			dp[i + 1][0] = dp[i][0]; 
			dp[i + 1][1] = dp[i][1] + dp[i][0];			
			dp[i + 1][2] = dp[i][2]; 
			dp[i + 1][3] = dp[i][3];
		}
		else if ('B' == S[i]) {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][1];
			dp[i + 1][2] = dp[i][2] + dp[i][1];
			dp[i + 1][3] = dp[i][3];
		}
		else if ('C' == S[i]) {
			dp[i + 1][0] = dp[i][0];
			dp[i + 1][1] = dp[i][1];
			dp[i + 1][2] = dp[i][2];
			dp[i + 1][3] = dp[i][3] + dp[i][2];
		}
		else {
			dp[i + 1][0] = (mint)3 * dp[i][0];
			dp[i + 1][1] = (mint)3 * dp[i][1] + dp[i][0];
			dp[i + 1][2] = (mint)3 * dp[i][2] + dp[i][1];
			dp[i + 1][3] = (mint)3 * dp[i][3] + dp[i][2];
		}
	}
	cout << dp[S.size()][3] << endl;
	return 0;
}

Measured memory_bytes: 10376
#include <iostream>

using namespace std;

int main()
{
    string u,s,t;
    cin>>s>>t;
    int a,b;
    cin>>a>>b;
    cin>>u;
    if(u==s){
        a--;
    }
    if(u==t){
        b--;
    }
    cout<<a<<" "<<b<<endl;
}


Measured memory_bytes: 256
#include<cstdio>
using namespace std;
int main(){
	int n;
	scanf("%d",&n);
	for (int i=0;i*4<=n;i++)
	if ((n-i*4)%7==0) {
		printf("Yes");	
		return 0;
	}
	printf("No");
	return 0;	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int (i)=0;(i)<(n);i++)
#define INF 1001001001
#define LLINF 1001001001001001001
#define MOD 1000000007
#define FOUT(n, dist) cout<<fixed<<setprecision(n)<<(dist);
#define BR cout<<endl;
#define LEN(s) s.length();
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; }
#define ALL(v) v.begin(), v.end()
typedef long long ll;
const ll mod=1000000007;

ll powmod(ll x,ll y){
    ll res=1;
    for(ll i=0;i<y;i++){
        res=res*x%mod;
    }
    return res;
}

int main(){
    int a, b, c, x, y, ans = 0;
    cin >> a >> b >> c >> x >> y;

    if(a + b > 2 * c){
        int num = min(x, y);
        x = x - num;
        y = y - num;
        ans = num * 2 * c;
    }
    else{
        cout << a * x + b * y << endl;
        return 0;
    }
    
    if(a * x + b * y > 2 * c * (x + y))cout << ans + 2 * c * (x + y) << endl;
    else cout << ans + a * x + b * y << endl;

    return 0;
}



Measured memory_bytes: 3592
from collections import Counter

N=int(input())
s=[0]*N
t=[0]*N
d=dict()
cnt=0

for i in range(N):
  s[i]=input()
  t[i]=str(sorted(s[i]))
  if t[i] not in d:
    d[t[i]] =1
    #print(i,d)
  else:
    cnt += d[t[i]]
    d[t[i]] +=1
    #print(i,d)

print(cnt)

Measured memory_bytes: 29664
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <stack>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef vector<int> vi;
typedef pair<int, int> P;

const int INF = 1<<27;

int main(){
	int n;
	while(cin >> n, n){
		vector<P> stone;
		for(int i = 1; i <= n; i++){
			int c;
			cin >> c;
			if(i%2){
				if(stone.empty() || (stone.back().first != c)){
					stone.push_back(MP(c, 1));
				}else{
					stone.rbegin()->second++;
				}
			}else{
				if(c == stone.rbegin()->first){
						stone.rbegin()->second++;
				}else{
					int s = stone.rbegin()->second+1;
					stone.pop_back();
					if(stone.empty()){
						stone.push_back(MP(c, s));
					}else{
						stone.rbegin()->second+=s;
					}
				}
			}
		}
		int ans = 0;
		rep(i, stone.size()){
			if(stone[i].first == 0) ans += stone[i].second;
		}
		cout << ans << endl;
	}
 
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,i,j,a[100],b[100],c[100],d[100],mini,in;
    scanf("%d %d",&n,&m);
    for(i=0;i<n;i++)
    scanf("%d %d",&a[i],&b[i]);
    for(i=0;i<m;i++)
    scanf("%d %d",&c[i],&d[i]);
    for(i=0;i<n;i++)
    {
        in=0,mini=2e9;;
        for(j=0;j<m;j++)
        {
            if((abs(a[i]-c[j])+abs(b[i]-d[j]))<mini)
            mini=(abs(a[i]-c[j])+abs(b[i]-d[j])),in=j;
        }
        printf("%d\n",in+1);

    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
int main(){
  int N, M;
  cin >> N >> M;
  vector<string> id(N);
  rep(i, N) cin >> id[i];
  set<string> st;
  for(int i = N-1; i >= 0; i--) {
    if(!st.count(id[i])) {
      cout << id[i] << endl;
      st.insert(id[i]);
      M--;
    }
    if(M <= 0) break;
  }
  return 0;
}

Measured memory_bytes: 10756
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define agewari(a, b) ((ll)a + ((ll)b - 1)) / b
const int MOD = 1000000007;
const long long INF = 1LL << 60;

int main()
{
    ll n;
    cin >> n;
    vector<ll> L(n);
    rep(i, n) cin >> L[i];
    sort(L.begin(), L.end());

    ll ans = 0;
    for (ll i = 0; i < n; i++)
    {
        for (ll j = i + 1; j < n; j++)
        {
            for (ll k = j + 1; k < n; k++)
            {
                if (L[i] + L[j] > L[k]&&L[i]!=L[j]&&L[i]!=L[k]&&L[j]!=L[k])
                    ans++;
            }
        }
    }

    cout << ans << endl;
}

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

int dp[300001];
int ar[300001];
int j,k,l,m,n;


int solve(int x)
{

    if(x == 0)return 0;

    if(dp[x] != -1)return dp[x];

    int ans = 0;
    for(int i=0;i<n;i++)
    {
        if(ar[i] > x)continue;

        if(solve(x-ar[i]) == 0)
        {
            ans = 1;
            break;

        }
    }
    return dp[x] = ans;
}

int main()
{
    cin >> n >> k;
memset(dp,-1,sizeof dp);

    for(int i=0;i<n;i++)cin >> ar[i];

    if(solve(k))cout<<"First"<<endl;
    else cout << "Second" << endl;
}


Measured memory_bytes: 4480
#include<stdio.h>
#include<algorithm>
#include<cstdio>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
struct str {
	int a, b, cost;
	bool operator < (const str&A)const {
		return cost < A.cost;
	}
};
int X[4] = { 0,0,1,-1 };
int Y[4] = { 1,-1,0,0 };
int n, m, k, arr[300010];
priority_queue<str> que;
int main() {
	scanf("%d %d", &n, &m);
	int r, w;
	scanf("%d %d", &r, &w);
	int ans = n * m;
	ans -= (r * m);
	ans -= ((n - r)*w);
	printf("%d", ans);
	return 0;
}

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

int main(void) {
  int k, n;
  cin >> k >> n;
  
  int p1;
  cin >> p1;
  
  int p = p1, q, d = 0;
  for(int i = 1; i < n; i++){
    cin >> q;
    if(q - p > d) d = q - p;
    p = q;
  }
  
  if(k - p + p1 > d) d = k - p + p1;
  
  cout << k - d;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <queue>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef pair<string,int> P;
const ll MOD=1e9+7;
class Edge
{
	public:
	int to,cost;
	Edge(int t,int c)
	{
		to=t;
		cost=c;
	}
};

vector<Edge> g[100000];
ll color[100000];
void dfs(int now,ll c,ll k)
{
	color[now]=c;
	ll p=max(c-1,k-2);
	for(int i=0;i<g[now].size();i++)
	{
		Edge e=g[now][i];
		if(color[e.to]==-1e8+1)
		{
			dfs(e.to,p,k);
			p--;
		}
	}
	return;
}
int main()
{
	int n;
	ll k;
	cin>>n>>k;
	fill(color,color+100000,-1e8+1);
	for(int i=0;i<n-1;i++)
	{
		int a,b;
		cin>>a>>b;
		a--;b--;
		g[a].push_back(Edge(b,1));
		g[b].push_back(Edge(a,1));
	}
	dfs(0,k,k);
	ll ans=1;
	for(int i=0;i<n;i++)
	{
		//cerr<<color[i]<<endl;
		ans*=color[i];
		ans%=MOD;
	}
	if(ans<0)
		ans+=MOD;
	cout<<ans<<endl;
	return 0;
}

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

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

int main(void){
	int n;

	while(cin >> n, n){
		vector< pair<int, int> > p;
		int xmax, xmin, ymax, ymin;

		xmin = ymin = xmax = ymax = 0;
		p.push_back(pair<int, int>(0, 0));

		for(int i=0; i<n-1; i++){
			int index, d;
			cin >> index >> d;
			int nx = p[index].first + dx[d];
			int ny = p[index].second + dy[d];

			xmax = max(xmax, nx);
			xmin = min(xmin, nx);
			ymax = max(ymax, ny);
			ymin = min(ymin, ny);

			p.push_back(pair<int, int>(nx, ny));
		}

		printf("%d %d\n", xmax+1-xmin, ymax+1-ymin);

	}


	return 0;
}

Measured memory_bytes: 1180
#include <stdio.h>
#include <string.h>
int main(void){
    char a[1000000], b[1000000];
    scanf("%s %s", a, b);
    int i, l, count = 0;
    l = strlen(a);
    for(i = 0; i < l; i++){
        if(a[i] != b[i]){
            count++;
        }
    }
    printf("%d\n", count);
    return 0;
}

Measured memory_bytes: 2132
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ

		Scanner sc=new Scanner(System.in);
		int k=sc.nextInt();
		String moji=sc.next();
		String s=moji.toLowerCase();

    if(k>=1&&k<=100) {
	      if(s.length()>=1&&s.length()<=100) {
	    		if(k>=s.length()) {
	    			System.out.println(s);
	    		}else if(s.length()>=k) {
	    			String result=s.substring(0,k);
	    			System.out.println(result+"...");
	    		}
	    }

      }
  }
}

Measured memory_bytes: 38540
class uf_tree():

    def __init__(self,n):
        self.n = n
        self.par = [i for i in range(n)]
        self.rank = [0 for i in range(n)]
        self.e_num = [1 for i in range(n)]

    def indep(self):
        dep =0
        for i in range(self.n):
            if i == self.par[i]:
                dep += 1

        return dep

    def unite(self,x,y):
        if self.root(x) == self.root(y):
            return
        else:
            rootx = self.root(x)
            rooty = self.root(y)

            e_sum = self.e_num[rootx] + self.e_num[rooty]

            if self.rank[rootx] < self.rank[rooty]:
                self.par[rootx] = rooty
                self.e_num[rooty] = e_sum
            else:
                self.par[rooty] = rootx
                self.e_num[rootx] = e_sum

                if self.rank[rootx] == self.rank[rooty]:
                    self.rank[rootx] += 1

    def root(self,i):
        if self.par[i] == i:
            return i
        else:
            self.par[i] = self.root(self.par[i])
            return self.par[i]

    def same(self,x,y):
        return self.root(x) == self.root(y)


n,m,k = map(int,input().split())
num_rels = [0 for i in range(n)]
tree =uf_tree(n)

for i in range(m):
    a,b = map(int,input().split())
    a-=1
    b-=1
    tree.unite(a,b)
    # print(tree.e_num)
    num_rels[a] += 1
    num_rels[b] += 1

for i in range(k):
    c,d = map(int,input().split())
    c-=1
    d-=1
    if tree.same(c,d):
        num_rels[c] += 1
        num_rels[d] += 1

# print(num_rels)
#
# for i in range(n):
#     print(tree.e_num[tree.root(i)],end=" ")
# print()

for i in range(n):
    temp = tree.e_num[tree.root(i)]-1-num_rels[i]
    if temp >= 0:
        print(temp,end=" ")
    else:
        print(0,end=" ")
print()

Measured memory_bytes: 10204
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <set>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())

using namespace std;
typedef long long ll;

int main(int argc, const char * argv[]) {
    
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n;
    cin >> n;
    
    vector<int> p(n);
    rep(i, n)
    {
        cin >> p[i];
        --p[i];
    }
    
    vector<int> idx(n);
    rep(i, n) idx[p[i]] = i;
    ll cnt = 0;
    set<int> s;
    
    for (int x = n-1; x >= 0; --x)
    {
        
        int i = idx[x];
        s.insert(i);
        
        ll c = 0;
        vector<int> l(2, -1);
        vector<int> r(2, n);
        {// calc c
            {
                // left
                auto it = s.find(i);
                rep(j, 2)
                {
                    if (it == s.begin()) break;
                    --it;
                    l[j] = *it;
                }
            }
            {
                //right
                auto it = s.find(i);
                rep(j, 2)
                {
                    ++it;
                    if (it == s.end()) break;
                    r[j] = *it;
                }
            }
        }
        c = (ll)(r[1] - r[0]) * (i - l[0])
            + (ll)(l[0] - l[1]) * (r[0] - i);
        cnt += c * (x + 1);
    }
    
    cout << cnt << endl;
    
    return 0;
}

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

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

#define rep(i,cc,n) for(int i=cc;i<n;++i)
#define lrep(i,cc,n) for(long long i=cc;i<n;++i)
#define sqrep(i,cc,n) for(long long i=cc;i*i<=n;++i)
#define rrep(i,cc,n) for(long i=cc;i>n;--i)
#define pii pair<int, int>
#define pll pair<long long, long long>
 
using ll = long long;

const vector<int> dx = {1, 0, -1, 0};
const vector<int> dy = {0, 1, 0, -1};
const double PI = 3.1415926535;
const ll inf = 1001001001;
const ll e9  = 1000000000;
const ll mod = 1000000007;

ll solve(int n, ll x){
    if(n==0)return 1;
    ll len = (1LL<<(n+1))-3;
    ll bnum = (1LL<<n)-1;
    if(x==1)return 0;
    else if(x<=len+1)return solve(n-1, x-1);
    else if(x==len+2)return bnum+1;
    else if(x<=len*2+2)return bnum+1+solve(n-1, x-len-2);
    else return bnum*2+1;
}
int main(){
    int n;
    ll x;
    cin >> n >> x;
    cout << solve(n, x);
    return 0;
}

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

public class Main {
    private void solve() {
        int x = sc.nextInt();

        int ans = x / 500 * 1000 + (x % 500) / 5 * 5;
        out.println(ans);
    }

    private static PrintWriter out;
    private static MyScanner sc;

    private static class MyScanner {
        BufferedReader br;
        StringTokenizer st;

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

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

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

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

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

    public static void main(String[] args) {
        out = new PrintWriter(new BufferedOutputStream(System.out));
        sc = new MyScanner();
        new Main().solve();
        out.close();
    }
}


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

int main()
{
  int64_t a,b,c ;
  cin>>a>>b>>c ;
  
  if(c-a-b<0) cout<<"No"<<endl ;
  else if(4*a*b<(c-a-b)*(c-a-b)) cout<<"Yes"<<endl ;
  else cout<<"No"<<endl ;
  
  return 0 ;
}


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

typedef long long ll;
typedef long double ld;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

#define f first
#define s second
#define sz(x) (int)x.size()
#define all(x) begin(x), end(x)
#define rall(x) rbegin(x), rend(x)
#define pb push_back

#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (int i = (b); i >= (a); i--)
#define R0F(i, a) ROF(i, 0, a-1)
#define trav(x, a) for (auto& x: a)

const int MX  = 2e5+5;
const int MOD = 1e9+7;
const ll  INF = 1061109567; // 4557430888798830399LL
const ld  EPS = 1e-9;
const ld  PI  = acos(-1);

int main() {

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

    char op;
    ll a, b; cin >> a >> op >> b;

    if (op == '+') {
        cout << a+b << "\n";
    } else {
        cout << a-b << "\n";
    }

}


Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <algorithm>

using namespace std;

long long n, s, k;
long long a[200200];

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


Measured memory_bytes: 1920
#include <stdio.h>

int main(){
  int i,j,minj,cp,ct=0,n,A[100];
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%d",&A[i]);
  }
  for(i=0; i<n; i++){
    minj = i;
    for(j=i; j<n; j++){
      if(A[j] < A[minj]) minj = j;
    }
    if(minj != i){
      cp = A[i];
      A[i] = A[minj];
      A[minj] = cp;
      ct++;
    }
  }
  for(i=0; i<n-1; i++){
    printf("%d ",A[i]);
  }
  printf("%d\n%d\n",A[i],ct);


  return 0;
}


Measured memory_bytes: 2056
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>

#define FOR0(i,n) for (int i = 0; i < n; i++)
#define FOR(i,j, n) for (int i = j; i < n; i++)
// bool isEven(ll n) {return (n%2!=0)?false:true;};
#define INF 1000000000 // 1 billion, safer than 2B for Floyd Warshall’s

#define f(i,a,b) for(i=a;i<b;i++)
#define rep(i,n) f(i,0,n)
#define fd(i,a,b) for(i=a;i>=b;i--)
#define pb push_back
#define mp make_pair
#define vi vector< int >
#define vl vector< ll >
#define ss second
#define ff first
#define ll mp::cpp_int
#define pii pair< int,int >
#define pll pair< ll,ll >
#define sz(a) a.size()
#define inf (1000*1000*1000+5)
#define all(a) a.begin(),a.end()
#define tri pair<int,pii>
#define vii vector<pii>
#define vll vector<pll>
#define viii vector<tri>
#define mod (1000*1000*1000+7)
#define pqueue priority_queue< int >
#define pdqueue priority_queue< int,vi ,greater< int > >
// #define int ll

using namespace std;
typedef pair<int, pair<int, int> > ppp;

int main()
{
    long long int n,k;
    cin>>n>>k;

    cout<<floor(log(n)/log(k)) + 1<<endl;
}

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

vector<int> divisor(int n)
{
    vector<int> res;
    for (int i = 1; i * i <= n; ++i)
    {
        if (n % i == 0)
        {
            res.push_back(i);
            if (n % (n / i) == 0)
                res.push_back(n / i);
        }
    }
    return res;
}
void solve(void)
{
    ll n, m;
    cin >> n >> m;
    int ans = 0;
    for (auto i : divisor(m))
    {
        if (n * i <= m)
            ans = max(ans, i);
    }
    cout << ans << endl;
}
int main(void) { solve(); }


Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define rep(i,n)    for(long long i = 0; i < (n) ; ++i)
#define orep(i,n)   for(long long i = 1; i <= (n); ++i)   // one rep
#define drep(i,n)   for(long long i = (n)-1; i >= 0; --i) // down rep
#define srep(i,s,t) for(long long i = (s); i < (t); ++i)  // set rep
#define rng(x)  (x).begin(),(x).end()
 
  // range
#define rrng(a) (a).rbegin(),(a).rend() // reverse range
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define ru(x,y) (((x)+(y)-1)/(y)) // round up
#define fi first
#define se second
#define eb emplace_back
#define fcout cout << fixed << setprecision(15)
 
 
using namespace std;
using ll  = long long;
using P   = pair<int,int>;
using vi  = vector<int>;
using vvi = vector<vi>;
using vp  = vector<P>;
using vl  = vector<ll>;
 
template<typename T> void Yes(T flag) {
  cout << (flag ? "Yes" : "No") << endl;
}
 
template<typename T> void pv(vector<T> vec) {
  cout << "[";
  for(auto& v : vec) { cout << v << ","; }
  cout << "]" << endl;
}
 
template<>
void pv(vector<P> vec) {
  cout << "[";
  for(auto& v : vec) {
    cout << "<" << v.fi << ","<< v.se << ">" << ",";
  }
  cout << "]" << endl;
}
 
template<typename T> void pv2(vector<vector<T>> vec) {
  for(auto& v : vec) pv(v);
}
 
vi dx={1,0,-1,0},dy={0,1,0,-1};
const int INF = 100100101;
int main() {
  int h,w;
  cin >> h >> w;
 
  vvi maze(h,vi(w,0));
  rep(i,h) rep(j,w) {
    char a;
    cin >> a;
    if(a=='.') maze.at(i).at(j)=1;
    else maze.at(i).at(j)=0;
  }
 
  vvi defa(h,vi(w,INF));
 
  int ans=0;
  int cnt=0;
  rep(i,h) rep(j,w) {
    if(!maze.at(i).at(j)) continue;
    queue<P>  que;
    que.push(P(i,j));
    int tmp=0;
    vvi d=defa;
    vvi mazemaze=maze;
    d.at(i).at(j)=0;
    mazemaze.at(i).at(j)=0;
    while(que.size()) {
      P q=que.front();que.pop();
      int x=q.fi,y=q.se;
      rep(k,4) {
        int nx=x+dx[k];int ny = y+dy[k];
        if(isin(nx,0,h) and isin(ny,0,w) and mazemaze.at(nx).at(ny)==1) {
          que.push(P(nx,ny));
          d[nx][ny]=d[x][y]+1;
          mazemaze.at(nx).at(ny)=0;
          tmp=max(tmp,d[x][y]+1);
          cnt++;
        }
      }
    }
    ans=max(ans,tmp);
  }
 
  cout << ans << endl;
 
  return 0;
}

Measured memory_bytes: 256
A = {1, 3, 5, 7, 8, 10, 12}
B = {4, 6, 9, 11}
C = {2}
X, Y = map(int, input().split())

print('Yes' if {X, Y} <= A or {X, Y} <= B or {X, Y} <= C else 'No')

Measured memory_bytes: 3060
using System;
using System.IO;
using System.Linq;
using System.Collections.Generic;
using static System.Math;
using static System.Console;
using static System.Linq.Enumerable;
using static System.Numerics.BitOperations;

namespace abc176
{
    class SolverA
    {
        static void Main()
        {
            checked
            {
                SetOut(new StreamWriter(Console.OpenStandardOutput()){AutoFlush = false});
                new SolverA().Solve();
                Out.Flush();
            }
        }

        public void Solve()
        {
            checked
            {
                (long N, long X, long T) = Get.Tuple<long,long,long>();
                if(N%X == 0){
                    WriteLine(N/X*T);
                }else{
                    WriteLine((N/X+1)*T);
                }
            }
        }




        static class Get
        {
            public static string Str() => ReadLine().Trim();
            public static int Int() => int.Parse(Str());
            public static long Long() => long.Parse(Str());
            public static double Double() => double.Parse(Str());
            public static string[] Strs() => Str().Split(' ', StringSplitOptions.RemoveEmptyEntries);
            public static int[] Ints() => Strs().Select(int.Parse).ToArray();
            public static long[] Longs() => Strs().Select(long.Parse).ToArray();
            public static double[] Doubles() => Strs().Select(double.Parse).ToArray();
            static bool TypeEq<T,U>() => typeof(T).Equals(typeof(U));
            static T TypeConv<T,U>(U u) => (T)Convert.ChangeType(u, typeof(T));
            static T TypeConv<T>(string s) => TypeEq<T, int>() ?   TypeConv<T, int>(int.Parse(s))
                                        : TypeEq<T, long>() ?       TypeConv<T, long>(long.Parse(s))
                                        : TypeEq<T, double>() ?     TypeConv<T, double>(long.Parse(s))
                                        : TypeConv<T, string>(s);
            public static (T,U) Tuple<T,U>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); return(t,u);}
            public static (T,U,V) Tuple<T,U,V>() {string[] strs = Strs(); T t = TypeConv<T>(strs[0]); U u = TypeConv<U>(strs[1]); V v = TypeConv<V>(strs[2]); return(t,u,v);}
        }

       
    }

    
}


Measured memory_bytes: 27536
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  vector<int> A;
  for (int i = 0; i < N; i++) {
    int Ai;
    cin >> Ai;
    A.push_back(Ai);
  }
  sort(A.begin(), A.end());
  for (int i = 1; i < N; i++) {
    if (A[i] == A[i-1]) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}

Measured memory_bytes: 1400
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <sstream>
#include <cstring>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <functional>
#include <array>
#include <cmath>

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int mod = (int)1e9+7;


int main()
{
	
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n;
	string s, mt="CODEFESTIVAL";
	cin >>s;
	int ck=0;
	rep(i,sz(s)){
		if(s[i]=='C') ck=1;
		if(ck==1 && s[i]=='F'){
			puts("Yes");
			return 0;
		}
	}
	puts("No");
	return 0;
}


Measured memory_bytes: 256
li = input().split()
num = int(li[0])
foot = int(li[1])
a = 0
for i in range(num+1):
  j = num-i
  n = 2*i + 4*j
  if n == foot:
    a += 1
    if a == 1:
      print("Yes")

if a == 0:
  print("No")

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
struct EDGE { int from, to, cost; };
bool operator < (const EDGE& a, const EDGE& b) {
    return a.cost < b.cost;
}
 
vector<EDGE> g;
int par[10000];
 
int find(int x)
{
    if (par[x] == x) return x;
    return par[x] = find(par[x]);
}
 
bool _union(int x, int y)
{
    x = find(x);
    y = find(y);
    if (x == y) return false;
    par[x] = y;
    return true;
}
 
int main()
{
    int V, E;
    scanf("%d %d", &V, &E);
     
    for (int i = 0; i < V; i++) par[i] = i;
     
	for (int j = 0; j < E; j++) {
		int s, t, w;
		cin>>s>>t>>w;
		g.push_back(EDGE{ s, t, w });
	}
     
    sort(g.begin(), g.end());
     
    int res = 0;
    for (int i = 0; i < g.size(); i++){
        EDGE &e = g[i];
        if (_union(e.from, e.to)) res += e.cost;
    }
     
    printf("%d\n", res);
     
    return 0;
}

Measured memory_bytes: 4652
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;

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

  int A = stoi(S.substr(0, 2));
  int B = stoi(S.substr(2, 2));

  if (A > 0 && A <= 12 && B > 0 && B <= 12)
    cout << "AMBIGUOUS" << endl;
  else if (A > 0 && A <= 12)
    cout << "MMYY" << endl;
  else if (B > 0 && B <= 12)
    cout << "YYMM" << endl;
  else
    cout << "NA" << endl;
}

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

using namespace std;

int main() {
    int a;
    int temp = 0;
    for (int i = 0; i < 3; i++) {
        cin >> a;
        temp += a;
    }

    if (temp <= 21)cout << "win" << endl;
    else cout << "bust" << endl;
}


Measured memory_bytes: 256
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: i32 = read();
    let b: i32 = read();
    let product = a * b;
    let ans = {
        let ans;
        if product % 2 == 0 {
            ans = String::from("Even");
        } else {
            ans = String::from("Odd");
        };
        ans
    };
    let out = stdout();
    let mut out = out.lock();
    writeln!(out, "{}\n", ans).unwrap();
}


Measured memory_bytes: 4352
#include<bits/stdc++.h>
 
#define lli long long int
#define endl "\n"
 
using namespace std;
 
typedef long long int LLI;
typedef double DB;
 
void fastio()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
}
 
 
bool comparator(pair<lli,lli> a,pair<lli,lli> b)
{
    if(a.first>b.first)
        return true;
    else if (a.first==b.second)
    {
        if(a.second>=b.second)
            return false;
        return true;
    }
    return false;
}
 
int mods(int x)
{
    if(x>0)
        return x;
    return -x;
}
 
lli gcd(lli a,lli b)
{
    return __gcd(a,b);
}
 
lli lcm(lli x,lli y,lli z)
{
    lli j=gcd(x,y);
    lli k=gcd(y*x/j,z);
    return (((x*y)/j)*z)/k;
} 

int arr[3][3];
bool vis[3][3]={0};

int main()
{
    fastio();
    int n; cin>>n; int arr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    sort(arr,arr+n);
    cout<<mods(arr[n/2]-arr[n/2-1]);
    return 0;
}

Measured memory_bytes: 640
/*Made by Shivam Solanki*/
#include<bits/stdc++.h>
#pragma GCC optimize ("Ofast")
using namespace std;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define ll long long int
#define endl '\n'
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vll> vvl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<pii> vp;
typedef vector<pll> vpll;
typedef map<int,int> mii;
typedef map<ll,ll> mll;
typedef set<int> sii;
typedef set<ll> sll;
typedef queue<int> qii;
typedef priority_queue<int> pq;
typedef unordered_map<int,int> umii;
typedef unordered_map<ll,ll> umll;
#define all(x) x.begin(),x.end()
#define rep(i,k,n) for (int i = k; i < n; ++i) 
#define repr(i,k,n) for (int i = n; i>=k; --i)
#define repll(i,k,n) for (ll i = k; i < n; ++i) 
#define pb push_back
#define mp make_pair
#define gcd __gcd
#define F first
#define S second
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
const int INF = 1e9+5;
const int MOD = 1e9+7;
double pi = 2 * acos(0.0); 
const int N=2e5+5;
vi adj[N];
vi d(N,INF);
vi p(N,-1);

void bfs(int s){
    qii q;
    q.push(s);
    d[s]=0;
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(int u:adj[v]){
            if(d[u]>d[v]+1){
                d[u]=d[v]+1;
                p[u]=v;
                q.push(u);
            }
        }
    }
}

void solve(){
    int n,m;
    cin>>n>>m;
    rep(i,0,m){
        int u,v;
        cin>>u>>v;
        u--,v--;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    bfs(0);
    bool f=1;
    rep(i,1,n){
        if(p[i]==-1){
            f=0;
            break;
        }
    }
    if(f){
        cout<<"Yes\n";
        rep(i,1,n) cout<<p[i]+1<<'\n';
    }
    else{
        cout<<"No\n";
    }
}

int main(){ 
    // #ifndef ONLINE_JUDGE  
        // freopen("input.txt", "r", stdin); 
        // freopen("output.txt", "w", stdout); 
    // #endif 
    fastio;
    int t=1;
    // cin>>t;
    while(t--)
        solve();
    return 0;
}


Measured memory_bytes: 13828
#include<iostream>
using namespace std;
int main(){
  int x,y;
  cin >> x >> y;
  if (y % 2)
  {
    cout << "No";
    return 0;
  }
  if (y <= 4 * x && y >= 2 * x)
  {
    cout << "Yes";
    return 0;
  }
  cout << "No";
  return 0;
}
  
  


Measured memory_bytes: 3640
def main():
    a, b = map(int, input().split())
    if b == 1:
        print(0)
    else:
        cnt = 0
        target = a
        while True:
            cnt += 1
            if target >= b:
                break
            target += a -1
        print(cnt)

if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
import sys
from bisect import bisect_left

def solve():
    A = map(int, sys.stdin)
    n = next(A)
    L = [next(A)]
    for a_i in A:
        if a_i > L[-1]:
            L.append(a_i)
        else:
            j = bisect_left(L, a_i)
            L[j] = a_i
    print(len(L))

solve()



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

using namespace std;

typedef long long int ll;
#define f first
#define s second 

const int MAXN = 1000 * 1000 + 10;

vector<int> adj[MAXN];
bool mark[MAXN];
int h[MAXN];
pair<int, int> e[MAXN];


ll mod = 1000*1000*1000+7;

void addEdge(int x, int y)
{
	adj[x].push_back(y);
	adj[y].push_back(x);
}

void dfs(int u, int v = 0)
{
	mark[u] = true;
	for(int i = 0; i < adj[u].size(); i++)
	{
		int x = adj[u][i];
		if(!mark[x])
		{
			h[x] = h[u]+1;
			dfs(x);
		}
	}
	return;
	
}

void cl(int n)
{
	for(int i = 1; i <= n; i++)
	{
		mark[i] = false;
		h[i] = 0;
	}
	return;
}

int main()
{
	ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	
	int n, k;
	cin >> n >> k;
	for(int i = 0; i < n-1; i++)
	{
		int x, y;
		cin >> x >> y;
		addEdge(x, y);
		e[i] = {x, y};
	}
	int ans = n;
	if(k%2 == 0)
	{
		for(int i = 1; i <= n; i++)
		{
			cl(n);
			dfs(i);
			int cnt = 0;
			for(int j = 1; j <= n; j++)
			{	
				if(h[j] > k/2)
					cnt++;
			}
			ans = min(ans, cnt);
		}
	}
	else
	{
		for(int i = 0; i < n-1; i++)
		{
			cl(n);
			int x = e[i].f;
			int y = e[i].s;
			mark[x] = true;
			mark[y] = true;
			dfs(x);
			dfs(y);
			int cnt = 0;
			for(int j = 1; j <= n; j++)
			{	
				if(h[j] > k/2)
					cnt++;
			}
			ans = min(ans, cnt);
			
		}	
	}
	cout << ans << endl;
		
	


	return 0;
}


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

using namespace std;

#define pii pair<int,int>
#define ll long long
#define s second
#define f first


int n,d;
bool is_perfect_square(int n) {
    if (n < 0)
        return false;
    int root(round(sqrt(n)));
    return n == root * root;
}

int main(){
  cin >> n >> d;
  vector<vector<int>> a(n,vector<int>(d));
  int x;
  for(int i=0;i<n;++i){
    for(int j=0;j<d;++j){
        cin >> a[i][j];
    }
  }
 // cout << "A";
  ll cnt=0;
  for(int i=0;i<n;++i){
    for(int j=i+1;j<n;++j){
        ll x=0;
        for(int z=0;z<d;++z){
           x+=(a[i][z]-a[j][z])*(a[i][z]-a[j][z]);
        }
        if(is_perfect_square(x)){
            ++cnt;
        }
    }
  }
  cout << cnt;
  return 0;
}


Measured memory_bytes: 384
S = str(input())
# print(S)
S_size = len(S)


def calc(s, plist):
    nlist = [0]*S_size
    nlistcount = 0
    start = 0
    end = 1
    plist = list(map(int, list(plist)))

    if plist == []:
        nlist[0] = int(s)

    for i in range(S_size-1):
        if plist[i] == 1:
            nlist[nlistcount] = int(S[start:end])
            start = end
            end += 1
            nlistcount += 1
        else:
            end += 1
        if end == S_size:
            nlist[nlistcount] = int(S[start:end])
            nlistcount += 1
    return sum(nlist)



# pi: +を入れるか判定した回数，
# plist: +を入れるかどうかの01str
def dfs(pi, plist):
    # print(pi, plist,type(plist))
    if pi == S_size - 1:
        # print(plist, calc(S, plist))
        return calc(S, plist)
    return dfs(pi + 1, plist+"0") + dfs(pi + 1, plist+"1")


print(dfs(0,""))

Measured memory_bytes: 3064
#include<cstdio>
#include<algorithm>
using namespace std;
#define MAXN 55
#define MAXM 2510
#define LL long long
#define MO 998244353
#define PII pair<int,int>
int n,x[MAXN],y[MAXN],tot,ans;
PII dis[MAXM];
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d%d",&x[i],&y[i]);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
		{
			if(x[i]>x[j]) dis[++tot]=PII(x[i]-x[j],y[i]-y[j]);
			else if(x[i]<x[j]) dis[++tot]=PII(x[j]-x[i],y[j]-y[i]);
			else dis[++tot]=PII(0,abs(y[i]-y[j]));
		}
	sort(dis+1,dis+tot+1);
	ans=n;
	for(int i=1,cnt=0;i<=tot+1;i++)
		if(dis[i-1]!=dis[i]||i==tot+1) ans=min(ans,n-cnt),cnt=1;
		else cnt++;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <unordered_map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

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

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;
	string s;
	cin >> s;

	auto check = [&](int len) {

		unordered_map<string, int> mp;
		for (int j = 0; j <= N - len; j++) {
			string tmp = s.substr(j, len);
			if (mp.find(tmp) == mp.end()) mp.emplace(tmp, j);
			else if (j - mp[tmp] >= len) return true;
		}
		
		return false;
	};

	vector<int> len(N);
	iota(len.begin(), len.end(), 0);
	cout << *partition_point(len.begin(), len.end(), check) - 1 << endl;

	return 0;
}


Measured memory_bytes: 6696
//  SMOKE SHISHA PLAY FIFA  // 
#include<bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef long double ld;

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pll pair<ll,ll>
#define MP make_pair
#define ff first
#define ss second
#define PB push_back
#define mod 1000000007
#define lp(i,start,end) for(ll i=start;i<=end;i++) 
#define deb1(a) cout<<#a<<" = "<<(a)<<endl;
#define deb2(a,b) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<endl;
#define deb3(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;


ll modu(ll a, ll b)
{
	ll ans =1;
	while(b>0)
	{
		if(b&1)
		ans = (ans*a)%mod;
		b/=2;
		a = (a*a)%mod;
	}
	return ans;
}

int main()
{
	fastio
	ll t=1;
	//cin >> t;
	while(t--)
	{
		ll a,v,b,w,T,ans;
		cin>>a>>v>>b>>w>>T;
		if(v<=w)
			ans=0;
		else{
			ld time;
			time=abs(b-a)/(ld)(v-w);
			if(time<=T)
				ans=1;
			else
				ans=0;
		}
		if(ans==0)
			cout<<"NO"<<endl;
		else
			cout<<"YES"<<endl;
	return 0;	
	}
}


Measured memory_bytes: 3612
#include <iostream>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll MOD2=(ll)998244353;
const ll INF=(ll)1e18+10;

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

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

void solve(int ca){
    ll K; cin>>K;
    ll ans = 0ll;
    for (int i = 1; i <= K; ++i) {
        for (int j = 1; j <= K; ++j) {
            for (int k = 1; k <= K; ++k) {
                ll tmp = gcd(i,j);
                ans+=gcd(tmp,k);
            }
        }
    }
    cout<<ans<<"\n";
}

//#define MULTI
int main() {
#ifdef MULTI
    int N; cin>>N;
    for (int i = 0; i < N; ++i) {
        solve(i+1);
    }
#else
    solve(1);
#endif
    return 0;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int l,i,j,k,c=0,flag=0;
    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 <set>
#include <map>
#include <list>
#include <queue>
#include <stack>
#include <cmath>
#include <ctime>
#include <cstdio>
#include <vector>
#include <string>
#include <bitset>
#include <cctype>
#include <cstdlib>
#include <cstring>
#include <utility>
#include <numeric>
#include <complex>
#include <sstream>
#include <regex>
#include <fstream>
#include <iomanip>
#include <cassert>
#include <iostream>
#include <iterator>
#include <algorithm>
using namespace std;
using ll = long long;
using VL=vector<ll>;

#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
const long long INF =  999999999;

ll N,M;
vector<ll> a;
vector<ll> s;

bool nibu(ll x){
  ll count=0;
  REP(i,N){
    count+=a.end()-lower_bound(a.begin(),a.end(),x-a[i]);
  }
  if(count>=M)return true;
  else return false;
}

ll sum(ll x){
  ll count=0;
  ll res=0;
  REP(i,N){
    count+=a.end()-lower_bound(a.begin(),a.end(),x-a[i]);
    ll j=lower_bound(a.begin(),a.end(),x-a[i])-a.begin();
    res+=s[N]-s[j]+(N-j)*a[i];
  }
  if(count>M)res-=x*(count-M);
  return res;
}


int main(){
  cin>>N>>M;
  a=vector<ll>(N);
  s=vector<ll>(N+1);
  REP(i,N)cin>>a[i];
  sort(a.begin(),a.end());
  REP(i,N)s[i+1]=s[i]+a[i];
  ll l=0,r=200010;
  while(r-l>1){
    ll m=(l+r)/2;
    if(nibu(m))l=m;
    else r=m;
  }

  cout<<sum(l)<<endl;

}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
    int n,h[100000],k,i,s=0;
    scanf("%d%d",&n,&k);
    for(i=0;i<n;i++)
        scanf("%d",&h[i]);
    for(i=0;i<n;i++)
        if(h[i]>=k)
            s++;
    printf("%d\n",s);
    return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n;
    cin >> n;
    if (n / 100 == n / 10 % 10 && n / 10 % 10 == n % 10) {
        cout << n << endl;
    } else {
        int m = n / 111 + 1;
        cout << m * 100 + m * 10 + m << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <math.h>

using namespace std;

void b()
{
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;
    int length = sqrt((x2 - x1) * (x2 - x1) + (y2 - y1) * (y2 - y1));
}

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> ns(n + 1, 0);
    /*for (int i = 1; i < n + 1; ++i) {
        for (int j = 1; j < n + 1; ++j) {
            for (int l = 1; l < n + 1; ++l) {
                cout << i << " " << j << " " << l;
                if((i + j) % k == 0 && (j + l) % k == 0 && (l + i) % k == 0)
                {
                    cout << " ok";
                }
                cout << endl;
            }
        }
    }*/
    long long int result = 0;
    if(k % 2 == 0)
    {
        ///k / 2に合同な数の集合を作る
        vector<int> half;
        for (int i = 1; i < n + 1; ++i) {
            if(i % (k / 2) == 0 && i % k != 0)
            {
                half.push_back(i);
            }
        }
        /*for(auto e : half)
        {
            cout << e << endl;
        }*/
        result += half.size() * half.size() * half.size();
    }
    long long int count = n / k;
    result += count * count * count;
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 1660
using System;

namespace Problem_B
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            var y500 = int.Parse(Console.ReadLine());
            var y100 = int.Parse(Console.ReadLine());
            var y50 = int.Parse(Console.ReadLine());
            var x = int.Parse(Console.ReadLine());

            var count = 0;
            for (var i = 0; i <= y500; i++)
            {
                for (var j = 0; j <= y100; j++)
                {
                    for (var k = 0; k <= y50; k++)
                    {
                        if (500 * i + 100 * j + 50 * k == x) count++;
                    }
                }
            }
            Console.WriteLine($"{count}");
        }
    }
}


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

const int mod = 1e9 + 7;

// binary exponentiation O(log n)
ll mod_pow(int x, int y) {
  ll res = 1;
  while (y > 0) {
    if (y & 1) res = res * x % mod;  // if right-most bit is 1
    x = x * x % mod;
    y >>= 1;  // right shift y by 1 bit
  }
  return res;
}

int main() {
  int n;
  cin >> n;
  map<int, int> diffs;
  rep(i, n) {
    int pos;
    cin >> pos;
    diffs[pos]++;
  }

  for (int i = (n%2==0); i < n; i++) {
    if (i == 0) {
      if (diffs[i] != 1) {
        cout << 0 << endl;
        return 0;
      }
    }
    else if (diffs[i] > 2) {
      cout << 0 << endl;
      return 0;
    }
  }

  ll ans = 1;
  rep(i, n/2) {
    ans = (ans * 2) % mod;
  }
  cout << ans << endl;
}

Measured memory_bytes: 8160