akhauriyash/Code-Regression huggingface dataset:
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.NoSuchElementException;

public class Main {
	static int INF = (int)1e9 + 7;
	int N;
	int[] A,dp;
	public void solve() {
		N = nextInt();
		A = new int[N];
		dp = new int[N];

		for(int i = 0;i < N;i++){
			A[i] = nextInt();
		}

		Arrays.fill(dp, INF);

		for(int i = 0;i < N;i++){
			int left = -1;
			int right = N;
			while(right - left > 1){
				int mid = (right + left) / 2;
				if(dp[mid] < A[i]){
					left = mid;
				}else{
					right = mid;
				}
			}
			dp[right] = Math.min(dp[right],A[i]);
		}

		int l = -1;
		int r = N;
		while(r - l > 1){
			int m = (r + l) / 2;

			if(dp[m] < INF){
				l = m;
			}else{
				r = m;
			}
		}

		out.println(r);
	}

	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

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

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

Measured memory_bytes: 42136
#include<stdio.h>
int main(void){
  int a,b,c;
  scanf("%d %d %d",&a,&b,&c);
  int max=a;
  if(b>max){
    max=b;
  }
  if(c>max){
    max=c;
  }
  printf("%d\n",a+b+c-max);
  return 0;
}

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

pub 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")
}

use std::cmp::{max, min};

fn main() {
  let n = read::<i64>();
  let k = read::<i64>();
  let mut sum_s = vec![];
  let s = read::<String>();

  // 連続数で配列
  let mut now = '1';
  let mut cnt = 0;
  for i in s.chars() {
    if i != now {
      sum_s.push(cnt);
      cnt = 1;
      now = if now == '1' { '0' } else { '1' }
    } else {
      cnt += 1;
    }
  }
  sum_s.push(cnt);
  if sum_s.len() % 2 == 0 {
    sum_s.push(0);
  }

  let length = (k * 2 + 1) as usize;
  let sum_len = sum_s.len() as i64;
  let mut ans = 0;
  let mut block = 0;
  for i in 0..min(length as i64, sum_len) {
    block += sum_s[i as usize];
  }

  ans = block;

  for i in 0..sum_len - length as i64 {
    if i % 2 == 1 {
      continue;
    }
    let i_size = i as usize;
    let block_f = sum_s[i_size];
    let block_s = sum_s[i_size + 1];

    let block_n = sum_s[i_size + length];
    let block_n2 = sum_s[i_size + 1 + length];

    // println!(
    //   "first: {}, second: {}, last1: {}, last2: {}",
    //   block_f, block_s, block_n, block_n2
    // );
    block += block_n + block_n2 - block_s - block_f;
    // println!("block: {}", block);
    ans = max(ans, block)
  }
  println!("{}", ans);

}



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

int main()
{
    int n, x, sum = 0;
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        cin >> x;
        sum += x;
    }
    cout << sum-n << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <list>
#include <cmath>
#include <stack>
#include <string>
#include <cstring>
#include <numeric>
#include <iomanip>
#include <fstream>
#include <array>
using namespace std;
int n;
int a[200000];
int pa[200000];
vector<int> ch[200000];
int ans[200000];
int dp[200000];
void dfs(int now,int mem){
	int md;
	int id=lower_bound(dp,dp+n,a[now])-dp;
	if(dp[id]==1e9+7){
		md=dp[id];
		dp[id]=a[now];
		ans[now]=mem+1;
	}else{
		md=dp[id];
		dp[id]=a[now];
		ans[now]=mem;
	}
	for(int i=0;i<ch[now].size();i++){
		if(ch[now][i]==pa[now]){
			continue;
		}else{
			pa[ch[now][i]]=now;
			dfs(ch[now][i],ans[now]);
		}
	}
	dp[id]=md;
}
int main(){
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	for(int i=0;i<n-1;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		ch[u].push_back(v);
		ch[v].push_back(u);
	}
	pa[0]=-1;
	for(int i=0;i<n;i++){
		dp[i]=1e9+7;
	}
	dfs(0,0);
	for(int i=0;i<n;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}


Measured memory_bytes: 32012
#include <cmath>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <queue>
#include <map>
#include <bitset>
#include <set>
#include <vector>
const int inf=2147483647;
const int mo=1e9+7;
const int N=300005;
const int M=100005;
using namespace std;
struct Rec{
    int l,r;
    friend bool operator < (Rec x,Rec y)
    {return (x.r-x.l+1)<(y.r-y.l+1);}
}a[N];
int n,m,ans;
namespace BIT{
    int c[M];
    int mx;
    void init(int _n){mx=_n; memset(c,0,sizeof(c));}
    void insert(int x,int delta){for (;x<=mx;x+=x&-x) c[x]+=delta;}
    void update(int l,int r){insert(l,1); insert(r+1,-1);}
    int query(int x){
        int ret=0;
        for (;x;x-=x&-x) ret+=c[x];
        return ret;
    }
}
void solve(){
    int now=1;
    for (int i=1;i<=m;++i){
        while (a[now].r-a[now].l+1<=i&&now<=n){
            BIT::update(a[now].l,a[now].r);
            ++now;
        }
        ans=n-now+1;
        for (int j=i;j<=m;j+=i){
            ans+=BIT::query(j);
        }
        printf("%d\n",ans);
    }
}

int main(){
	//freopen("arc068e.in","r",stdin);
	//freopen("arc068e.out","w",stdout);
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;++i)
        scanf("%d%d",&a[i].l,&a[i].r);
    sort(a+1,a+1+n);
    BIT::init(m+1);
    solve();
}

Measured memory_bytes: 3712
// abc078_a
#include <bits/stdc++.h>
#ifdef LOCAL
#include "../cxx-prettyprint/prettyprint.hpp"
#endif
using namespace std;

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

#define REP(i, n) for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n) for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define REP_REV(i, n) for (int (i) = (int)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (int (i) = (int)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

#define INF ((1 << 29)-1)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
#define print_line(vec, n) {for(int i=0;i<(n-1);i++) cout << (vec)[i] << " "; cout << (vec)[(n)-1] << endl;}
template<class T> void print(const T& x){cout << x << endl;}
template<class T, class... A> void print(const T& first, const A&... rest) { cout << first << " "; print(rest...); }
struct PreMain {PreMain(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(20);}} premain;

int main() {
#ifdef LOCAL
    ifstream in("../arg.txt"); cin.rdbuf(in.rdbuf());
#endif

    string X, Y;
    cin >> X >> Y;

    if (X[0] < Y[0]){
        print("<");
    } else if (X[0] == Y[0]){
        print("=");
    }else{
        print(">");
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define err(args...) {}
#ifdef DEBUG
#include "_debug.cpp"
#endif
using namespace std;
using ll = long long;
using ld = long double;
template <typename T> using lim = numeric_limits<T>;
template <typename T> istream& operator>>(istream& is, vector<T>& a) { for(T& x : a) { is >> x; } return is; }
template <typename X, typename Y> istream& operator>>(istream& is, pair<X, Y>& p) { return is >> p.first >> p.second; }
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<string> s(n);
    vector<int> p(n);
    for(int i = 0; i < n; i++) {
        cin >> s[i] >> p[i];
    }
    vector<int> I(n);
    iota(I.begin(), I.end(), 0);
    sort(I.begin(), I.end(), [&](int i, int j) {
        return pair{s[i], -p[i]} < pair{s[j], -p[j]};
    });
    for(int i : I) {
        cout << i + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 3608
import heapq

N, M = map(int, input().split())
a = list(map(int, input().split()))
bc = [list(map(int, input().split())) for _ in range(M)]

bc.sort(key=lambda x:-x[1])
cnt = True

heapq.heapify(a)

for b, c in bc:
    if not cnt: break
    for i in range(b):
        hq = heapq.heappop(a)
        if hq < c:heapq.heappush(a, c)
        else:
            heapq.heappush(a, hq)
            cnt = False
            break
print(sum(a))
        
        

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

int main(){
    int S;
    cin >> S;
    int h,m,s;
    h = S/3600;
    m = (S - h*3600)/60;
    s = S - h*3600 - m*60;
    cout << h << ":" << m << ":" << s << endl;
    return 0;
}


Measured memory_bytes: 3104
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int[][] a = new int[n][m];
        int[] b = new int[m];

        for(int i = 0; i < n; i++) {
        	for(int j = 0; j < m; j++) {
        		a[i][j] = sc.nextInt();
        	}
        }

        for(int i = 0; i < m; i++) {
        	b[i] = sc.nextInt();
        }

        for(int i = 0; i < n; i++) {
        	int sum = 0;
        	for(int j = 0; j < m; j++) {
        		sum += a[i][j] * b[j];
        	}
        	System.out.println(sum);
        }
	}
}



Measured memory_bytes: 40412
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,copy,functools
import time,random

sys.setrecursionlimit(10**7)
inf = 10**20
eps = 1.0 / 10**10
mod = 10**9+7
dd = [(-1,0),(0,1),(1,0),(0,-1)]
ddn = [(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(): return [list(map(int, l.split())) for l in sys.stdin.readlines()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
def pf(s): return print(s, flush=True)
def pe(s): return print(str(s), file=sys.stderr)
def JA(a, sep): return sep.join(map(str, a))
def JAA(a, s, t): return s.join(t.join(map(str, b)) for b in a)


def main():
    n = I()
    a = LI()
    s = sum(a)
    t = 0
    r = inf
    for c in a:
        t += c
        k = abs(s-t*2)
        if r > k:
            r = k

    return r


print(main())





Measured memory_bytes: 28468
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
	int n;
	cin >> n;
	vector<int> ja(4);
	rep(i, n) {
		string x;
		cin >> x;
		if (x == "AC") {
			ja[0]++;
		}
		if (x == "WA") {
			ja[1]++;
		}
		if (x == "TLE") {
			ja[2]++;
		}
		if (x == "RE") {
			ja[3]++;
		}
	}
	rep(i, 4) {
		if (i == 0) {
			cout << "AC x " << ja[i] << endl;
		}
		if (i == 1) {
			cout << "WA x " << ja[i] << endl;
		}
		if (i == 2) {
			cout << "TLE x " << ja[i] << endl;
		}
		if (i == 3) {
			cout << "RE x " << ja[i] << endl;
		}
	}
}
	

Measured memory_bytes: 3620
n = int(input())
data = list(map(int, input().split()))
mx = max(data)
marked = [0]*(mx + 1)
for a in data:
    for x in range(a, mx+1, a):
        marked[x] += 1
ans = 0
for a in data:
    if marked[a] == 1:
        ans += 1
print(ans)

Measured memory_bytes: 32200
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll h, w, dp[1005][1005], mod = 1000000007;
string s[1005];
queue< pair< ll, ll> > q;
bool vis[1005][1005];

int main(){
	cin >> h >> w;
	for( ll i = 0 ; i < h ; i++ )
		cin >> s[i];
	dp[h-1][w-1] = 1;
	if( s[h-1][w-2] == '.'){
    	vis[h-1][w-2] = true;
		q.push( make_pair( h-1, w-2));
        }
	if( s[h-2][w-1] == '.'){
    	vis[h-2][w-1] = true;
		q.push( make_pair( h-2, w-1));
        }
	while( !q.empty() ){
		pair< ll, ll> a = q.front();
		q.pop();
		if( a.first > 0 and s[a.first - 1][a.second] == '.' and !vis[a.first - 1][a.second] ){
			q.push( make_pair( a.first - 1, a.second));
            vis[a.first - 1][a.second] = true;
        }
		if( a.second > 0 and s[a.first][ a.second - 1] == '.' and !vis[a.first][a.second - 1] ){
			q.push( make_pair( a.first, a.second - 1));
            vis[a.first][a.second - 1] = true;
        }
		if( a.second < w-1 and a.first < h-1 ){
			if( s[a.first+1][a.second] == '.' and s[a.first][a.second+1] == '.' )
				dp[a.first][a.second] = ( dp[a.first+1][a.second] + dp[a.first][a.second+1]) % mod;
			else if( s[a.first+1][a.second] == '#' )
				dp[a.first][a.second] = dp[a.first][a.second + 1];
			else
				dp[a.first][a.second] = dp[a.first + 1][a.second];
		}
		else if( a.second < w-1 )
			dp[a.first][a.second] = dp[a.first][a.second+1];
		else
			dp[a.first][a.second] = dp[a.first+1][a.second];
	}
	cout << dp[0][0] << endl;
	return(0);
}


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

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout.precision(12);
    cout.setf(ios_base::fixed, ios_base::floatfield);
    
    int64_t r;
    int64_t d;
    int64_t x;
    cin >> r >> d >> x;
    for(int i=2001;i<=2010;i++){
        x = r*x - d;
        cout << x << endl;
    }
    
    return 0;
}

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

use proconio::{input, fastout};
use proconio::marker::*;

#[fastout]
fn main() {
    input! {
    n: usize,
    x: usize
    }
    let ans = dfs(n, x);
    println!("{}", ans);
}

fn dfs(k: usize, x:usize) -> usize{
    if x <= k {
        return 0
    }
    let d = 2usize.pow(k as u32 + 2) - 3;
    if x == d {
        return 2usize.pow(k as u32 + 1) - 1
    }
    let mut res = 0;
    if d / 2 < x {
        res += 2usize.pow(k as u32);
        res += dfs(k - 1, x - d / 2 - 1);
    } else {
        res += dfs(k - 1, x - 1)
    }
    res
}


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

int main() {
  int n, x = 0, y = 0;
  cin >> n;
  vector<int> v(n), c(n);
  for (int i = 0; i < n; i++) {
    cin >> v.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> c.at(i);
  }

  for (int i = 0; i < n; i++) {
    if (v.at(i) > c.at(i)) {
      x += v.at(i);
      y += c.at(i);
    }
  }
  if(x-y<0) cout << "0" << endl;
  else cout << x-y << endl;
}


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

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

using ll = long long;
using pll = pair<ll, ll>;

const ll MAXN = 1000001;
bool P[MAXN];

map<ll, ll> makePrimeFactorMap(ll n)
{
    map<ll, ll> res;

    for (ll i=2;i*i<=n;++i)
    {
        while ((n % i) == 0) { n /= i; ++res[i]; }
    }

    if (n != 1) { ++res[n]; }

    return res;
}

template<typename T> T gcdraw(T a, T b) { return a ? gcdraw(b%a, a) : b; }
template<typename T> T gcd(T a, T b)
{
    const auto aa = abs(a), bb = abs(b);
    return aa > bb ? gcdraw(aa, bb) : gcdraw(bb, aa);
}

int main()
{
    ll N;
    cin >> N;

    vector<ll> A(N);
    for (auto& a: A) { cin >> a; }

    bool isPairwise = true;
    ll setwise = A[0];

    for (ll i=0;i<N;++i)
    {
        for (const auto& kv : makePrimeFactorMap(A[i]))
        {
            isPairwise &= !P[kv.first];
            P[kv.first] = true;
        }

        setwise = gcd(setwise, A[i]);
    }

    if (isPairwise)        { cout << "pairwise coprime" << endl; }
    else if (setwise == 1) { cout << "setwise coprime" << endl; }
    else                   { cout << "not coprime" << endl; }

    return 0;
}


Measured memory_bytes: 11896
import java.io.BufferedReader
import java.io.InputStreamReader

fun main() {
    val jin = BufferedReader(InputStreamReader(System.`in`))
    val line = jin.readLine().split(" ")
    val n = line[0].toInt()
    val m = line[1].toInt()
    val hs = listOf(0) + jin.readLine().split(" ").map { it.toInt() }
    val isGood = BooleanArray(n + 1) { true }
    isGood[0] = false
    for (j in 1..m) {
        val line = jin.readLine().split(" ")
        val a = line[0].toInt()
        val b = line[1].toInt()
        if (hs[a] <= hs[b]) {
            isGood[a] = false
        }
        if (hs[b] <= hs[a]) {
            isGood[b] = false
        }
    }
    println(isGood.count { it })
}

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

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> PII;
typedef long long LL;
typedef vector<LL> VLL;
typedef vector<VLL> VVLL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SQ(a) ((a)*(a))
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
#define LB lower_bound
#define UB upper_bound

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL INF = 1e9;
const LL MOD = 1e9+7;

//other
//-------------------------------------------
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define FI first
#define SE second

//memo
// setprecision()

int main() {
  
  int A,B,C;
  cin >> A >> B >> C;
  
  if(C >=A && C <= B) cout << "Yes" << endl;
  else cout << "No" << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
	ll k,x;
  cin>>k>>x;
  ll left=x-k+1;
  ll right=x+k-1;
  if(left<-1000000)
    left=-1000000;
  if(right>1000000)
    right=1000000;
  for(ll i=left;i<=right;i++)
    cout<<i<<" ";
  cout<<endl;
}

Measured memory_bytes: 256
def cmb(n, r, p):
    if (r < 0) or (n < r):
        return 0
    r = min(r, n - r)
    return fact[n] * factinv[r] * factinv[n-r] % p

N, A, B, K = map(int, input().split())

p = 998244353
fact = [1, 1]  # fact[n] = (n! mod p)
factinv = [1, 1]  # factinv[n] = ((n!)^(-1) mod p)
inv = [0, 1]  # factinv 計算用
for i in range(2, N + 1):
    fact.append((fact[-1] * i) % p)
    inv.append((-inv[p % i] * (p // i)) % p)
    factinv.append((factinv[-1] * inv[-1]) % p)

ans = 0

for a in range(N+1):
    if (K - A*a) % B == 0 and A*a <= K:
        b = (K- A*a) // B
        ans += cmb(N, a, p)*cmb(N, b, p)%p

print(ans%p)



Measured memory_bytes: 100208
// https://atcoder.jp/contests/abc141/tasks/abc141_e
#include <bits/stdc++.h>
using namespace std;
using P = pair<int, int>;
using ll = long long;
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, s, n) for (int i = (s), i##_len = (n); i < i##_len; ++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define ALLR(obj) (obj).rbegin(), (obj).rend()

vector<int> z_algorithm(const string &s) {
    vector<int> prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k])
                ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int)s.size();
    return prefix;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    string S;
    cin >> N >> S;
    int len = S.length(), maxv = 0;
    REP(i, len) {
        auto lcp = z_algorithm(S.substr(i));
        REP(j, lcp.size()) maxv = max(maxv, min(lcp[j], j));
    }
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 256
/*宣言*/
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<string.h>
#include<string>
#include<vector>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
int main()
{
	int n, a, b, c, d, ans = 0,x,y;
	cin >> n >> a >> b >> c >> d;
	x = n / a;
	y = n / c;
	if (n%a != 0)
		x++;
	if (n%c != 0)
		y++;
	ans = min(b*x, d*y);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3080
n, l = map(int,input().split())
ai = [[int(input()),i] for i in range(n)]

ai.sort(key = lambda x: x[0])
time = [0]*(n+2)
for i in ai:
    idx = i[1]
    time[idx+1] = max(time[idx],time[idx+2]) + l - i[0]

print(max(time))

Measured memory_bytes: 28172
#include <iostream>
#include <cmath>

using namespace std;

typedef long int lint;
typedef long long int llint;

#define INF 1073741824
#define LINF 4611686018000000000
#define MOD 1000000007

int main() {
    int n, d;
    cin >> n >> d;
    double x, y;
    int ans = 0;
    for (int i = 0; i < n; i++) {
        cin >> x >> y;
        if (d - sqrt(x * x + y * y) > -0.000001)
            ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3188
let () =
  let open Hashtbl in
  let n = read_int () in
  let tbl = create ~random:true n in
  let rec doit i =
    if i < n then begin
      match Scanf.scanf "%s %s\n" (fun x y -> (x, y)) with
      | ("insert", x) -> (add tbl x true; doit (i + 1))
      | ("find", x) -> (print_endline (if mem tbl x then "yes" else "no"); doit (i + 1))
      | _ -> exit 1
    end
  in
  doit 0

Measured memory_bytes: 44016
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.bigint, std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static File _f;
void file_io(string fn) { _f = File(fn, "r"); }
static string[] s_rd;
T _RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T _RD(T = long)(File f) { while(!s_rd.length) s_rd = f.readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
T[] _RDA(T = long)(T fix = 0) { auto r = readln.chomp.split.to!(T[]); r[] += fix; return r; }
T[] _RDA(T = long)(File f, T fix = 0) { auto r = f.readln.chomp.split.to!(T[]); r[] += fix; return r; }
T RD(T = long)() { if (_f.isOpen) return _RD!T(_f); else return _RD!T; }
T[] RDA(T = long)(T fix = 0) { if (_f.isOpen)  return _RDA!T(_f, fix); else return _RDA!T(fix); }

size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

void chmin(T)(ref T x, T y) { x = min(x, y); } void chmax(T)(ref T x, T y) { x = max(x, y); }
bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
T lcm(T)(T x, T y) { return x * (y / gcd(x, y)); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(T)(ref T x, T y) { x = (x + y) % mod; }
void mods(T)(ref T x, T y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(T)(ref T x, T y) { x = (x * y) % mod; }
void modpow(T)(ref T x, T y) { if (!y) { x = 1; return; } auto t = x; x.modpow(y>>1); x.modm(x); if (y&1) x.modm(t); }

void main()
{
	auto N = RD;
	auto R = RD;

	writeln(N >= 10 ? R : R + 100 * (10 - N));
	stdout.flush;
	debug readln;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<string>
#include <vector>
#include <map>
#include<cstdio>
#include<cstdlib>

using namespace std;

void Solution()
{
    int N = 105000; // to judge if the number is prime number
    int n;
    bool data[N];
    
    for(int i = 0;i < N; i++)
    {
        if(i % 2 == 0) // remove the numbers which can be devide by 2
        {
            data[i] = false;
        }
        else
        {
            data[i] = true;
        }
    }
    
    data[1] = false; //remove 1
    data[2] = true; // casue 2 is prime number
    
    for(int i = 3; i < N; i += 2) // remove 3, 5, 7's multiples
    {
        if(data[i])
        {
            for(int j = i + i; j < N; j += i) //remove 3, 5, 7's multiples
            {
                data[j] = false;
            }
        }
    }
   
    while(cin>>n)
    {
        
                
        for(int i = n - 1; i > 1; i--)
        {
            if(data[i])
            {
                cout<<i;
                break;
            }
        }
        
        for(int i = n + 1; i < N; i++)
        {
            if(data[i])
            {
                cout<<" "<<i<<endl;
                break;
            }
        }
        
    }
}

int main()
{
    Solution();
    return 0;
}

Measured memory_bytes: 1260
#include <iostream>
using namespace std;
int main() {
    int n, ans = 0;
    cin >> n;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        while (a % 2 == 0) {
            ans++;
            a /= 2;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>


int main(){
int pa1,pa2,pa3,j1,j2;
int a[6];
int i,sais;

scanf("%d",&pa1);
scanf("%d",&pa2);
scanf("%d",&pa3);
scanf("%d",&j1);
scanf("%d",&j2);
a[0]=pa1+j1-50;
a[1]=pa1+j2-50;
a[2]=pa2+j1-50;
a[3]=pa2+j2-50;
a[4]=pa3+j1-50;
a[5]=pa3+j2-50;
sais=a[0];
for(i=1;i<6;i++){
if(sais>a[i]){
sais=a[i];
}
}

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

return 0;
}

Measured memory_bytes: 592
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
#define ote(x) cout<<(x)<<endl
#define all(x) (x).begin(),(x).end()
#define rp(i,s,e) for(int i=(s);i<(e);++i)
#define irp(i,s,e) for(int i=(s);i>(e);--i)
template<class T>bool chmax(T &a, const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a, const T &b){if(b<a){a=b;return 1;}return 0;}

int N,M;
int a,b,c;
string s, t;
vi v,u;

int main(){
	cin>>N>>M;
	// cout<<N<<" "<<M<<"\n";//
	auto ans = 0;

	ans = (N*(N-1))/2 + (M*(M-1))/2;

	cout<< ans <<endl;
	// printf("%f\n",ans);
}


Measured memory_bytes: 256
N = int(input())
G = [[] for _ in range(N)]
for _ in range(N-1):
    u, v, w = map(int, input().split())
    G[u-1].append((v-1, w))
    G[v-1].append((u-1, w))

color = [-1]*N
color[0] = 0

import queue
q = queue.Queue()
q.put(0)
while not q.empty():
    v = q.get()
    for c, w in G[v]:
        if color[c] >= 0: continue
        color[c] = (color[v] + w)%2
        q.put(c)

print('\n'.join(map(str, color)))

Measured memory_bytes: 102892
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define RREP(i, n) for (int i = (int)n - 1; i >= 0; --i)
#define FOR(i, s, n) for (int i = s; i < (int)n; ++i)
#define RFOR(i, s, n) for (int i = (int)n - 1; i >= s; --i)
#define ALL(a) a.begin(), a.end()
#define IN(a, x, b) (a <= x && x < b)
template<class T>inline void out(T t){cout << t << "\n";}
template<class T,class... Ts>inline void out(T t,Ts... ts){cout << t << " ";out(ts...);}
template<class T>inline bool CHMIN(T&a,T b){if(a > b){a = b;return true;}return false;}
template<class T>inline bool CHMAX(T&a,T b){if(a < b){a = b;return true;}return false;}
constexpr int INF = 1e18;

signed main(){
	int N,K;
	cin >> N >> K;
	int t = N % K;
	int tt = K - N % K;
	out(min(t,tt));
}

Measured memory_bytes: 256
import java.util.*;
class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int k = sc.nextInt();
    int n = sc.nextInt();
    int[] arr = new int[n];
    for(int i=0;i<n;i++){
      arr[i]=sc.nextInt();
    }
    int[] dist = new int[n];
    for(int i=0;i<n-1;i++){
      dist[i]=arr[i+1]-arr[i];
    }
    dist[n-1]=k-arr[n-1]+arr[0];
    Arrays.sort(dist);
    int ans=0;
    for(int i=0;i<n-1;i++){
      ans = ans +dist[i];
    }
    System.out.println(ans);
  }
}

Measured memory_bytes: 81272
#include <bits/stdc++.h>
#define fi first
#define se second
#define pii pair<int,int>
#define space putchar(' ')
#define enter putchar('\n')
#define MAXN 100005
//#define ivorysi
using namespace std;
typedef long long int64;
template<class T>
void read(T &res) {
    res = 0;T f = 1;char c = getchar();
    while(c < '0' || c > '9') {
	if(c == '-') f = -1;
	c = getchar();
    }
    while(c >= '0' && c <= '9') {
	res = res * 10 + c - '0';
	c = getchar();
    }
    res *= f;
}
template<class T>
void out(T x) {
    if(x < 0) {x = -x;putchar('-');}
    if(x >= 10) out(x / 10);
    putchar('0' + x % 10);
}
int N,K;
int a[MAXN],pos[MAXN];
int C(int x) {
    return x % (K - 1) == 0 ? x / (K - 1) : x / (K - 1) + 1;
}
void Solve() {
    read(N);read(K);
    for(int i = 1 ; i <= N ; ++i) {read(a[i]);pos[a[i]] = i;}
    int ans = N;
    for(int i = 1 ; i <= N ; ++i) {
	if(i + K - 1 >= pos[1]) {
	    ans = min(ans,C(i - 1) + C(N - min((i + K - 1),N)) + 1);
	}
    }
    out(ans);enter;
}
int main() {
#ifdef ivorysi
    freopen("f1.in","r",stdin);
#endif
    Solve();
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
	int N;
	scanf("%d",&N);
	int a[N];
	int c[100000];
	int ans=0;
	for(int i=0;i<100000;i++)c[i]=0;
	for(int i=0;i<N;i++){
		scanf("%d",&a[i]);
		c[a[i]]++;
	}
	for(int i=0;i<99998;i++){
		int tmp=c[i]+c[i+1]+c[i+2];
		if(tmp>ans)ans=tmp;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline bool chmin(A &a,const B &b){if(a>b){a=b;return true;}else{return false;}}
template<typename A,typename B>inline bool chmax(A &a,const B &b){if(a<b){a=b;return true;}else{return false;}}

int main()
{
    int K;
    cin >> K;
    REP(i,K){
        cout << "ACL";
    }
    cout << endl;
}

Measured memory_bytes: 3632
#include"bits/stdc++.h"
using namespace std;

//define
#define ALL(a) a.begin(),a.end()
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define debug(x) if(1)cout<<#x<<":"<<x<<endl;
#define DEBUG(x) if(1)cout<<#x<<":"<<x<<endl;
#define ll long long

//typedef
typedef vector<int> vi;
typedef vector<vector<int>> vvi;

class UnionFind {
private:
	std::vector<int> data_array;
	const int root(int id) {
		if (data_array[id] >= 0)
			return data_array[id] = root(data_array[id]);
		else
			return id;
	}
public:
	UnionFind(size_t size) : data_array(size, -1) {}
	// unionは予約語
	bool union_(int lhs, int rhs) {
		lhs = root(lhs);
		rhs = root(rhs);
		bool is_union = (lhs != rhs);
		if (is_union) {
			if (data_array[lhs] > data_array[rhs]) { std::swap(lhs, rhs); }
			data_array[lhs] += data_array[rhs];
			data_array[rhs] = lhs;
		}
		return is_union;
	}
	bool find(int lhs, int rhs) {
		return (root(lhs) == root(rhs));
	}
};


int main() {
	int n, m;
	cin >> n >> m;
	vector<int> k(n);
	vector<vector<int>> l(n);
	for (int i = 0; i < n; i++) {
		cin >> k[i];
		for (int j = 0; j < k[i]; j++) {
			int x;
			cin >> x;
			x--;
			l[i].push_back(x);
		}
	}

	UnionFind u(n + m);
	
	for (int i = 0; i < n; i++) {
		for (int j = 0; j <k[i]; j++) {
			u.union_(i, n + l[i][j]);
		}
	}

	bool isok = true;
	for (int i = 0; i < n; i++) {
		isok &= u.find(i, 0);
	}
	if (isok) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}



Measured memory_bytes: 6912
#include <string>
#include <algorithm>
#include <cassert>
#include <functional>
#include <iostream>
using namespace std;
int main()
{
	string x;
	int n,m;
	cin >> n>> m>> x;
	int ans = 0;
	
	for (int i = 1; i < n; i++) {
		if (x[i - 1] == x[i]) {
			ans++;
		}
	}
	cout << ans + min(n-1-ans,m*2)<<endl;
}

Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using static Assistant.Input;
using static Assistant.Debug;
using System.Linq;
using Assistant;

namespace ABC124B
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = ReadInt;
            var H = ReadInts;

            int ans = 0;
            for (int i = 0; i < N; i++)
            {
                bool ok = true;
                for (int j = 0; j < i; j++)
                {
                    if (H[j] > H[i]) ok = false;
                }
                if (ok) ans++;
            }

            Console.WriteLine(ans);
        }


    }


}

namespace Assistant
{
    static class Input
    {
        static List<string> line = new List<string>();
        static int index = 0;
        static String ReadNext()
        {
            if (line.Count <= index) line.AddRange(Console.ReadLine().Split());
            return line[index++];
        }
        public static int ReadInt => int.Parse(ReadNext());
        public static long ReadLong => long.Parse(ReadNext());
        public static int[] ReadInts => Console.ReadLine().Split().Select(int.Parse).ToArray();
        public static long[] NextLongs => Console.ReadLine().Split().Select(long.Parse).ToArray();
    }

    static class Debug
    {
        static public void Draw2D(int[,] map, int mode = 1)
        {
#if DEBUG
            int W = map.GetLength(0);
            int H = map.GetLength(1);

            int[,] map2 = new int[W + 1, H + 1];
            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (i == 0 && j == 0) map2[i, j] = 0;
                    else if (i == 0) map2[i, j] = j - 1;
                    else if (j == 0) map2[i, j] = i - 1;
                    else map2[i, j] = map[i - 1, j - 1];
                }
            }

            for (int i = 0; i < W + 1; i++)
            {
                for (int j = 0; j < H + 1; j++)
                {
                    if (mode == 0) Console.Write(map2[i, j] % 10);
                    if (mode == 1) Console.Write(map2[i, j] + " ");
                }
                Console.WriteLine();
            }
            Console.WriteLine();
#endif
        }

        static void Draw1D(int[] array, int mode = 0)
        {
#if DEBUG
            Console.WriteLine(string.Join(" ", array));
#endif
        }
    }
}


Measured memory_bytes: 13268
using System;
    using System.Linq;
    using System.Collections.Generic;
    using static System.Console;
    using System.Text;
     
     
    namespace AtCoder_Beginner_Contest_132
    {
        class Program
        {
            static public long[] Sarray() { return ReadLine().Split().Select(long.Parse).ToArray(); }
            static public List<long> Slist() { return ReadLine().Split().Select(long.Parse).ToList(); }
            static void Main(string[] args)
            {
                var NAB=Sarray();
                WriteLine(Math.Min(NAB[0] * NAB[1], NAB[2]));
            }
        }
    }

Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
template<class T> using V = vector<T>;
template<class T> using VV = vector<vector<T> >;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define repb(i, n) for(ll i = (n)-1; i >= 0; i--)
#define repr(i, a, b) for(ll i = (a); i < (b); i++)
#define reprb(i, a, b) for(ll i = (a)-1; i >= (b); i--)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((ll)(x).size())
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
inline ll GCD(ll a, ll b){ return b?GCD(b, a % b):a; }
inline ll LCM(ll a, ll b){ return a/GCD(a, b)*b; }
inline ll powint(unsigned long long x, ll y){ ll r=1; while(y){ if(y&1) r*=x; x*=x; y>>=1; } return r; }
inline ll powmod(ll x, ll y, ll m = MOD){ ll r=1; while(y){ if(y&1) r*=x; x*=x; r%=m; x%=m; y>>=1; } return r; }
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; }
#ifdef OJ_LOCAL
#include "dump.hpp"
#else
#define dump(...) ((void)0)
#endif

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    ll n;
    cin >> n;
    vll a(n), acc(n);
    rep(i, n){
        cin >> a[i];
    }
    sort(ALL(a));
    acc[0] = a[0];
    repr(i, 1, n){
        acc[i] = acc[i-1]+a[i];
    }
    dump(acc);
    ll ans = 1;
    repb(i, n-1){
        if(acc[i]*2 >= a[i+1]){
            ans++;
        }else{
            break;
        }
    }
    cout << ans << endl;
    return 0;
}

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

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

struct ABCD{
    int a, b, c, d;
    ABCD(int a, int b, int c, int d) : a(a), b(b), c(c), d(d) {}
    ABCD()
    {
        a = 0;
        b = 0;
        c = 0;
        d = 0;
    }
};

void dfs(vector<vector<int>> &all, int n, int m, vector<int> v)
{
    if(v.empty())
    {
        for(int i=1; i<=m; i++)
        {
            v.push_back(i);
            dfs(all, n, m, v);
            v.pop_back();
        }
    }
    else if(v.size() == n)
    {
        all.push_back(v);
    }
    else
    {
        int bn = v.back();
        for(int i=bn; i<=m; i++)
        {
            v.push_back(i);
            dfs(all, n, m, v);
            v.pop_back();
        }
    }
    
    return;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n, m, q;
    cin >> n >> m >> q;
    vector<ABCD> kumis;
    for(int i=0; i<q; i++)
    {
        int a, b, c, d;
        cin >> a >> b >> c >> d;
        kumis.emplace_back(a-1, b-1, c, d);
    }

    vector<vector<int>> all;
    dfs(all, n, m, vector<int>());

    int ans = 0;
    for(auto &vec : all)
    {
        int sun = 0;
        for(auto kumi : kumis)
        {
            if(vec.at(kumi.b) - vec.at(kumi.a) == kumi.c) sun += kumi.d;
        }
        chmax(ans, sun);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9812
parseInt(x) = parse(Int,x)
parseMap(x::Array{SubString{String}, 1}) = map(parseInt, x)
function main()
    N,M = map(parseInt, split(readline()))
  a = zeros(N)
  b = zeros(N)
  	for i in 1:N
    	a[i],b[i] = readline() |> split |> parseMap
	end
  hon = 0;
  yen = 0;
  	bs = b[sortperm(a)]
  	sort!(a)	
  	for i = 1:N
    	if M - hon > bs[i]
      		yen += a[i] * bs[i]
      		hon += bs[i]
      else 
      	 yen +=  a[i]*(M- hon)
      	break
    end
  end
  println(Int64(yen))
end
main()

Measured memory_bytes: 163452
#include <iostream>
#include <vector>
#include <algorithm>
int INF = 1e9;
int main(){
    int N;
    std::cin >> N;
    std::vector<int> a(N);
    for(int i = 0; i < N; i++) std::cin >> a[i];
    std::vector<int> dp(N, INF);
    for(int i  = 0; i < N; i++){
        int t = std::lower_bound(dp.begin(), dp.end(), a[i]) - dp.begin();
        dp[t] = a[i];
    }
    int ans = 0;
    for(int i = 0; i < N; i++){
        if(dp[i] != INF) ans = i + 1;
        else break;
    }
    std::cout << ans << std::endl;
}


Measured memory_bytes: 3632
n, a = map(int, raw_input().split())
values = sorted(map(lambda s: int(s) - a, raw_input().split()))
counts = {}
for x in values:
    items = counts.items()
    for a, count in items:
        y = x + a
        counts[y] = counts.setdefault(y, 0) + count
    counts[x] = counts.setdefault(x, 0) + 1
print(counts[0] if 0 in counts else 0)


Measured memory_bytes: 10864
N,Q = list(map(int,input().split()))
S = input()
L = [list(map(int,input().split())) for _ in range(Q)]

B= [0]
for i in range(N-1):
    if S[i] == 'A' and S[i+1] == "C":
        B.append(1)
    else:
        B.append(0)

from itertools import accumulate 
B = list(accumulate(B))

for i in range(Q):
    print(B[L[i][1]-1] - B[L[i][0]-1 ])

Measured memory_bytes: 32300
#include <stdio.h>
int main(){
char a[101];
int l,k;
scanf ("%d %d %s",&l,&k,a);
a[k-1]=a[k-1]+'a'-'A';
for (int i=0;i<l;i++){
	printf ("%c",a[i]);
	}
	return 0;
	}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;


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

	string s;
	long long n, i, j, k, ans, p, x;
	cin >> n >> s;
	p = 0;
	ans = 0;
	vector<long long> ct(26, 0);
	for (i = 0; i < n; i++) {
		x = s[i] - 'a';
		ct[x]++;
	}

	ans = 1;
	for (i = 0; i < 26; i++) {
		ans = (ans * (ct[i] + 1)) % 1000000007;
	}
	ans = (ans + 1000000006) % 1000000007;

	cout << ans << "\n";



	return 0;
}


Measured memory_bytes: 512
/*input 
cupofcoffee
cupofhottea
*/ 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
#pragma GCC optimize("unroll-loops,no-stack-protector")
//order_of_key #of elements less than x
// find_by_order kth element
#define ld double
#define pii pair<ll,ll>
#define f first
#define s second
#define pb push_back
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define FILL(n,x) memset(n,x,sizeof(n))
#define ALL(_a) _a.begin(),_a.end()
#define sz(x) (int)x.size()
const ll maxn=3e6+5;
const ll maxlg=__lg(maxn)+2;
const ll INF64=4e18;
const int INF=0x3f3f3f3f;
const ll MOD=998244353;
const ld PI=acos(-1);
const ld eps=1e-9;
#define lowb(x) x&(-x)
#define MNTO(x,y) x=min(x,(__typeof__(x))y)
#define MXTO(x,y) x=max(x,(__typeof__(x))y)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
ll mult(ll a,ll b){
    return ((a%MOD)*(b%MOD))%MOD;
}
ll mypow(ll a,ll b){
    if(b<=0) return 1;
    ll res=1LL;
    while(b){
        if(b&1) res=mult(res,a);
        a=mult(a,a);
        b>>=1;
    }
    return res;
}
int main(){
    string a,b;
    cin>>a>>b;
    int cnt=0;
    REP(i,sz(a)){
        if(a[i]!=b[i]) ++cnt;
    }
    cout<<cnt;
} 


Measured memory_bytes: 3860
#include<iostream>
#include<string>
using namespace std;
int main(){
	string S;
	cin >> S;

	int count = 0;
	int ans=0;
	for (int i = 0; i < S.size(); i++){
		if (S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T')count = 1;
		else continue;
		for (int j = i+1; j < S.size(); j++){
			if (S[j] == 'A' || S[j] == 'C' || S[j] == 'G' || S[j] == 'T')count++;
			else break;
		}
		if (ans < count)ans = count;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
using namespace std;

#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define int long long int

template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}

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

int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
constexpr ll INF = 1001001001001001LL;
constexpr ll MOD = 1000000007LL;

int N, M, board[110][10010];

signed main() {
    cin >> N >> M;
    rep(i,0,M) rep(j,0,N) {
        char c; cin >> c;
        if(c == 'W') board[i+1][j+1] = -1;
        else board[i+1][j+1] = 1;
    }

    rep(i,0,M) rep(j,0,N) board[i+1][j+1] += board[i+1][j];
    rep(j,0,N) rep(i,0,M) board[i+1][j+1] += board[i][j+1];


    int sum = board[M][N], val = -INF, ans;
    repq(i,0,N) {
        int va = board[M][i], vb = sum - va;
        if(val < vb - va) {
            val = vb - va;
            ans = i;
        }
    }
    printf("%lld %lld\n", ans, ans+1);
    return 0;
}

Measured memory_bytes: 11060
import sys
import bisect

# ???????????¨?????????DP?
# 

def main():
    n,t = map(int, sys.stdin.readline().split())
    levels = []
    for i in range(n):
        d = int(sys.stdin.readline())
        levels.append(d)
    levels.sort()

    ans = 1
    for i in range(n):
        cnt = i - bisect.bisect_left(levels, levels[i] - t) + 1
        ans *= cnt
        ans %= 1000000007

    print(ans)

if __name__ == '__main__':
    main()

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

typedef long long ll;
const int maxn=1e3+10;
int n;
ll a[maxn][maxn];
set<ll> s;
vector<int> v;

inline ll gcd(ll a,ll b){
	return b?gcd(b,a%b):a;
}
inline ll lcm(ll a,ll b){
	return a/gcd(a,b)*b;
}
const int xx=1e6;
int pcnt,p[xx];
bool prm[xx];
map<int,int> mp1,mp2;

int main(){
	for(int i=2;i<xx;++i){
		if(!prm[i])
			p[++pcnt]=i;
		for(int j=1;j<=pcnt&&(ll)i*p[j]<xx;++j){
			prm[i*p[j]]=1;
			if(i%p[j]==0)
				break;
		}
	}
	cin>>n;
	for(int i=0;i<=n+1;++i)
		for(int j=0;j<=n+1;++j)
			a[i][j]=1;
	{
		int cnt=0;
		for(int i=2;i<=2*n;++i)
			if(i&1)
				mp1[i]=p[++cnt];
		for(int i=1-n;i<=n-1;++i)
			if(i&1)
				mp2[i]=p[++cnt];
	}
	for(int i=1;i<=n;++i)
		for(int j=1,cnt=1;j<=n;++j)
			if(i+j&1){
				ll now=mp1[i+j]*mp2[i-j];
				a[i][j]=now;
				s.insert(now);
			}
	for(int i=1;i<=n;++i)
		for(int j=1;j<=n;++j)
			if(i+j&1^1){
				ll tmp=lcm(a[i-1][j],a[i][j-1]);
				tmp=lcm(tmp,a[i][j+1]);
				tmp=lcm(tmp,a[i+1][j]);
				ll now=tmp+1;
				while(s.count(now))
					now+=tmp;
				a[i][j]=now;
				s.insert(now);
			}
	for(int i=1;i<=n;++i,puts(""))
		for(int j=1;j<=n;++j){
			cout<<a[i][j]<<' ';
	//		if(a[i][j]>1e15)
	//			cerr<<"#";
		}
	return 0;
}

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

using namespace std;

int main() {
    int R;
    cin >> R;
    if(R < 1200) {
        cout << "ABC" << endl;
    } else if(R < 2800) {
        cout << "ARC" << endl;
    } else {
        cout << "AGC" << endl;
    }
    return 0;
}



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

int bd(string s)
{
   int tmp=0;
   for(int i=0;i<s.size();i++)
   { 
     tmp=tmp*10+(s[i]-'0');
   }
   return tmp;
}

int main()
{
  
  string a,b,s;
  cin>>a>>b;
  s=a+b;
  int x;
  x=bd(s);
  if(int(sqrt(x))==sqrt(x))  cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256