akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
using namespace std;
const int N = 2010;
int sticks[N], n;

int bin_search(int value, int l, int r){
    int flag = l;
    while (l < r){
        int mid = (l + r + 1) >> 1;
        if(sticks[mid] >= value){
            r = mid - 1;
        } else {
            l = mid;
        }
    }
    return r;
}

int main(){
    cin >> n;
    for (int i = 0; i < n; i ++){
        cin >> sticks[i];
    }
    sort(sticks, sticks + n);
    int sum = 0;
    for (int i = 0; i < n; i ++){
        for (int j = i+1; j < n; j ++){
            sum += bin_search(sticks[i] + sticks[j], j, n-1)-j;
        }
    }
    
    cout << sum << endl;
    return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
const ull mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template < typename T >
void vprint(T &v){
	REP(i, v.size()){
		cout << v[i] << " ";
	}
	cout << endl;
}

map< pair<string, string>, ll> L, R;

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

	ll MA = 1<<N;
	REP(i, MA){
		string pre, post;
		REP(j, N){
			if(i>>j & 1){
				pre += S[j];
			}else{
				post += S[j];
			}
		}
		L[{pre, post}]++;
	}


	ll res = 0;
	REP(i, MA){
		string pre, post;
		REP(j, N){
			if(i>>j & 1){
				pre += S[2*N-1-j];
			}else{
				post += S[2*N-1-j];
			}
		}
		res += L[{pre, post}];
	}

	cout << res << endl;

    return 0;
}

Measured memory_bytes: 91904
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, L, sum = 0, abs_min = 100000000;
    cin >> N >> L;
    REP(i, N) {
        sum += L + i;
        abs_min = min(abs_min, abs(L + i));
    }
    if (sum < 0) cout << sum + abs_min << endl;
    else cout << sum - abs_min << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

class Main {
	public static void main(String args[]) {
		StringBuilder sb = new StringBuilder();
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		List<rank> l = new ArrayList<>(n);
		for (int i = 1; i <= n; i++) {
			l.add(new rank(i, sc.next(), sc.nextInt()));
		}
		Collections.sort(l);
		for (int i = 0; i < n; i++) {
			System.out.println(l.get(i));
		}
	}
}

class rank implements Comparable<rank> {
	int num;
	String city;
	int point;

	rank(int n, String s, int p) {
		num = n;
		city = s;
		point = p;
	}

	@Override
	public int compareTo(rank o) {
		if (city.compareTo(o.city) != 0) {
			return city.compareTo(o.city);
		}
		return o.point - point;
	}

	public String toString() {
		return String.valueOf(num);
	}
}


Measured memory_bytes: 21844
function Main(input){
var KP = input.split(" ")[0];
var XP = input.split(" ")[1];
var K = new Number(KP);
var X = new Number(XP);
var a = [];
for(i=0;i<=2*(K-1);i++){
  a[i] = X - (K-1-i);
}
var answer = a.join(" ");
console.log(answer);
}
  Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 7500
#include<bits/stdc++.h>
using namespace std;
// 多倍長テンプレ
/* ---------------------- ここから ---------------------- */
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部が1024ビットの浮動小数点数型(TLEしたら小さくする)
using Real = mp::number<mp::cpp_dec_float<1024>>;
/* ---------------------- ここまで ---------------------- */
int main() {
  Real a, b;
  cin >> a >> b;
  cout << (Bint)(a*b) << endl;
}

Measured memory_bytes: 4020
/**
 * ??????

????????????????????????????????????????????°????????????????????????????????°??????????????????????????¨??§??????

????????°??????????????°?????????????????????????????°????????????????????????

?????????????????°????????????????¨?????????° m?????????????¨?????????° f??????????¨?????????° r
??§?§?????????????????????????

??????????¨???¨??????????¨???? 50 ????????????m, f ??? 50?????????????¨???? 100 ????????? ???r ???
100?????§??????

????¨????????????????????????´???????????°??? -1 ??¨????????????

??\??????????????§??????????????????????????????

??????????¨??????????????¨????????????????????¬????????????´???????????? F???
??????????¨???¨??????????¨????????¨??????°??? 80 ??\???????????°????????? A ???
??????????¨???¨??????????¨????????¨??????°??? 65 ??\??? 80 ??????????????°????????? B???
??????????¨???¨??????????¨????????¨??????°??? 50 ??\??? 65 ??????????????°????????? C???
??????????¨???¨??????????¨????????¨??????°??? 30 ??\??? 50 ??????????????°????????? D???
???????????????????¨?????????°??? 50 ??\???????????°????????? C??? ??????????¨???¨??????????¨????????¨??????°??? 30
??????????????°????????? F???

Input
?????°??????????????????????????\?????¨??????????????????????????????????????????????????§??????????????§???????????????
m???f???r ??? 1 ???????????????????????????

m???f???r ???????????? -1 ?????¨?????\?????????????????¨????????????

Output
?????????????????????????????????????????????A???B???C???D???????????? F???????????????????????????????????????

Sample Input
40 42 -1
20 30 -1
0 2 -1
-1 -1 -1
Sample Output
A
C
F
 */

#include <iostream>
#include <sstream>

int main(int argc, char const *argv[]) {
  short m, f, r;
  std::string Result;

  while (true) {
    while (true) {
      std::string Param;

      getline(std::cin, Param);
      std::istringstream iss(Param);
      iss >> m >> f >> r;

      if (m < -1 || m > 50 || f < -1 || f > 50 || r < -1 || r > 100) {
        std::cout << "Error: m, f <= 50, r <= 100" << std::endl;
      } else {
        break;
      }
    }
    if (m == -1 && f == -1 && r == -1) {
      break;
    } else {
      short Sum = m + f;
      if (m == -1 || f == -1) {
        Result = "F";
      } else if (Sum >= 80) {
        Result = "A";
      } else if (Sum >= 65) {
        Result = "B";
      } else if (Sum >= 50 || Sum + r >= 80) {
        Result = "C";
      } else if (Sum >= 30) {
        Result = "D";
      } else if (Sum < 30) {
        Result = "F";
      }
      std::cout << Result << std::endl;
    }
  }
  return 0;
}

Measured memory_bytes: 3168
n = int(input())
la = list(map(int,input().split()))
lb = list(map(int,input().split()))
lc = list(map(int,input().split()))

con = 0

for i in range(n-1):
    if la[i+1]==la[i]+1:
        con += lc[la[i]-1]

print(sum(lb)+con)

Measured memory_bytes: 9196
from copy import deepcopy

d=int(input())
c=list(map(int,input().split()))
s=[]
for i in range(d):
    a=list(map(int,input().split()))
    s.append(a)

def score_calculator(l):
    score=0
    last=[0]*26
    for i in range(d):
        for j in range(26):
            last[j]+=1
        last[l[i]]=0
        for j in range(26):
            score-=last[j]*c[j]
        score+=s[i][l[i]]
    return score

for i in range(1,26):
    highest_sum_score=-1000000000000
    last=[0]*26
    temp_ans_lst=[]
    for j in range(d):
        daily_highest_score=-10000000000000
        for k in range(26):
            temp_score=s[j][k]
            temp_last=deepcopy(last)
            for p in range(26):
                temp_last[p]+=1
            temp_last[k]=0
            for p in range(26):
                down=temp_last[p]
                for q in range(i):
                    qdown=down+i+1
                    down+=qdown
                temp_score-=down*c[p]
            if temp_score>daily_highest_score:
                daily_highest_score=temp_score
                daily_choice=k
        temp_ans_lst.append(daily_choice)
    if score_calculator(temp_ans_lst)>highest_sum_score:
        ans_lst=temp_ans_lst
        
for i in ans_lst:
    print(i+1)

Measured memory_bytes: 84960
using System;

class Program
{
    static void Main(string[] args)
    {
        var s = Console.ReadLine();

        var d = new int[26];
        for (int i = 0; i < s.Length; i++)
        {
            d[s[i] - 'a']++;
        }

        for (int i = 0; i < d.Length; i++)
        {
            if (d[i] % 2 != 0)
            {
                Console.WriteLine("No");
                return;
            }
        }

        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 13140
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        Scanner input = new Scanner(System.in);
        String word = input.nextLine();
        int n = word.length();
        int maximumLength = 0;
        boolean end = false;
        for (int i = 0; i < n; i++) {
            if(word.charAt(i) == 'A')
            {
                for (int j = i+1; j < n; j++) {
                    if(word.charAt(j) == 'Z')
                    {

                        if(j-i+1 > maximumLength)
                        {
                            maximumLength = j - i + 1;
                        }
                    }

                    if(j == n-1)
                        end = true;

                }
            }
            if(end)
                break;
        }
        System.out.println(maximumLength);
        }
}

Measured memory_bytes: 26540
// 1_2_D
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

long cnt = 0;

void InsertionSort(long A[], long n, long g){
    long i, j, v;
    for(i = g; i < n; i++){
        v = A[i];
        j = i - g;
        while(j >= 0 && A[j] > v){
            A[j+g] = A[j];
            j -= g;
            cnt++;
        }
        A[j+g] = v;
    }
    return;
}

void ShellSort(long A[], long n){
    int m, i;
    m = ((pow(n, 1.25) > 100)? 100: pow(n, 1.25));
    long G[m];
    G[0] = 1;
    for(i = 1; i < m; i++){
        if((G[i] = 3 * G[i-1] + 1) > n) break;
    }
    m = i;

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

    for(i = m - 1; i > 0; i--){
        printf("%ld ", G[i]);
    }
    printf("%ld\n", G[i]);

    for(i = m - 1; i >= 0; i--){
        InsertionSort(A, n, G[i]);
    }
    return;
}

int main(){
    int i;
    long n, *A;
    scanf("%ld", &n);

    A = malloc(sizeof(long) * n);
    for(i = 0; i < n; i++){
        scanf("%ld", &A[i]);
    }

    ShellSort(A, n);
    printf("%ld\n", cnt);
    for(i = 0; i < n; i++){
        printf("%ld\n", A[i]);
    }

    free(A);
    return 0;
}

Measured memory_bytes: 8340
#include "bits/stdc++.h"
using namespace std;
#ifndef LOCAL
#define endl '\n'
#endif

#define fr(i, a, b) for(int i = a; i <= b; i++)
#define rf(i, a, b) for(int i = a; i >= b; i--)
#define pf push_front
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define lb lower_bound
#define ub upper_bound

typedef long long ll;
typedef long double f80;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

int pct(int x) { return __builtin_popcount(x); }
int pct(ll x) { return __builtin_popcountll(x); }
int bt(int x) { return 31 - __builtin_clz(x); } // floor(log2(x))
int bt(ll x) { return 63 - __builtin_clzll(x); } // floor(log2(x))
int cdiv(int a, int b) { return a / b + !(a < 0 || a % b == 0); }
ll cdiv(ll a, ll b) { return a / b + !(a < 0 || a % b == 0); }
int nxt_C(int x) { int c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }
ll nxt_C(ll x) { ll c = x & -x, r = x + c; return (((r ^ x) >> 2) / c) | r; }

vector<int> get_bits(int mask) {
	vector<int> bb;
	while(mask) { int b = bt(mask); bb.pb(b); mask ^= (1 << b); }
	reverse(all(bb));
	return bb;
}

int get_mask(vector<int> v) {
	int mask = 0;
	for(int x : v) { mask ^= (1 << x); }
	return mask;
}

template<typename T>
void uniq(vector<T> &v) { sort(all(v)); v.resize(unique(all(v)) - v.begin()); }

mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

ll rand(ll l, ll r){
	uniform_int_distribution<ll> uid(l, r);
	return uid(rng);
}

void sc() {}

template <typename Head, typename... Tail>
void sc(Head &H, Tail &... T) { cin >> H; sc(T...); }

#ifdef LOCAL
#define debug(...) cerr << "[L:" << __LINE__ << "][" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// #ifndef LOCAL
// string to_string(__int128 x) {
// 	string s = "";
// 	bool neg = 0;
// 	if(x < 0) { s += "-"; neg = 1; x = -x; }
// 	if(!x) s += '0';
// 	while(x) {
// 		int rem = x % 10;
// 		s += to_string(rem);
// 		x /= 10;
// 	}
// 	reverse(s.begin() + neg, s.end());
// 	return s;
// }
// #endif

const int mod = 1e9 + 7; // 998244353;

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

/*
	Lookout for overflows!!
	Check array sizes!!
	Clear before test cases!!
	Use the correct modulo!!
	Check for corner cases!!
	Are you forgetting something?!
	Read problem statement carefully!!!
*/

const int N = 1e5 + 5;
int a[N];

void solve() {
	int n, L;
    sc(n, L);
    fr(i, 1, n) {
        sc(a[i]);
    }
    int pos = 0;
    fr(i, 1, n - 1) {
        if(a[i] + a[i + 1] >= L) {
            pos = i;
        }
    }
    if(!pos) {
        cout << "Impossible";
        return;
    }
    cout << "Possible" << endl;
    fr(i, 1, pos - 1) {
        cout << i << endl;
    }
    rf(i, n - 1, pos + 1) {
        cout << i << endl;
    }
    cout << pos << endl;
}

int main() {
	ios :: sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int t = 1;
	// cin >> t;
	for(int tt = 1; tt <= t; tt++) {
		solve();
	}
	return 0;
}

Measured memory_bytes: 4056
s = input()
ans = ''
if s == 'keyence':
  ans = 'YES'
else:
  for i in range(len(s) - 7):
    for j in range(len(s) - i):
      if s[:j] + s[j + i + 1:] == 'keyence':
        ans = 'YES'
        break
if ans == '':
  ans = 'NO'
print(ans)

Measured memory_bytes: 9056
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <set>
#include <map>
#include <vector>

using namespace std;

#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) repi(i,0,n)

typedef unsigned long long hash;

string line;

#define repit(it,u) for(__typeof(u.begin()) it=u.begin();it!=u.end();++it)
#define mp make_pair

const hash p = 1e9 + 7;
int strnum;
int idnum;
map<pair<int, int>, int> par;
map<pair<int, int> ,bool> comp;
struct node
{
  set<hash> s;
  node *l, *r;
  int num, den;
  int id;
  node() : s(), l(NULL), r(NULL), num(0), den(1) { id = idnum++;}
  node(node *l, node *r) : s(), l(l), r(r), num(0), den(1) { id = idnum++;}
  void calc() {
    if (l == NULL) {
      s.insert(1ULL);
    } else {
      l->calc();
      r->calc();
      repit(itl, l->s) repit(itr, r->s) {
	pair<int, int> key = mp(min(*itl, *itr), max(*itl, *itr));
	if(par.find(key) == par.end()) par[key]= strnum++;
	s.insert(par[key]);
      }
    }
  }
  void calc1() {
    if (l == NULL) return;

    l->calc1();
    r->calc1();

    repit(it, l->s) s.insert(*it);
    repit(it, r->s) s.insert(*it);

    set<hash> u;
    repit(it, l->s) u.insert(*it);
    repit(it, r->s) u.insert(*it);

    num = 0;
    repit(it, l->s) if (r->s.find(*it) != r->s.end()) {
      ++num;
    }
    den = u.size();
  }
  void rearrange(bool flip) {
    if (l == NULL) return;
    if (*l < *r ^ flip) {
      swap(l, r);
    }
    l->rearrange(false);
    r->rearrange(true);
  }
  void dump() {
    //cout << (double)num << ',' << den;
    if (l == NULL) {
      cout << 'x';
      return;
    }
    cout << '(';
    l->dump();
    cout << ' ';
    r->dump();
    cout << ')';
  }
  bool operator !=(const node& t) const {
    return *this < t or t < *this;
  }
  bool operator <(const node& t) const {
    bool ret;
    if(comp.find(mp(id, t.id)) != comp.end()) return comp[mp(id, t.id)];
    if (num * t.den != den * t.num) ret = num * t.den > den * t.num;
    else if (l == NULL or t.l == NULL) ret = false;
    else if (max(*l, *r) != max(*(t.l), *(t.r))) ret = max(*l, *r) < max(*(t.l), *(t.r));
    else if (min(*l, *r) != min(*(t.l), *(t.r))) ret = min(*l, *r) < min(*(t.l), *(t.r));
    else ret = false;
    return comp[mp(id, t.id)] = ret;
  }
};

node *get(int i, int& next)
{
  if (line[i] == '(') {
    node *l = get(i + 1, next);
    node *r = get(next + 1, next);
    next += 1;
    return new node(l, r);
  }

  next = i + 1;
  return new node();
}

void solve()
{
  int dummy;
  node *root = get(0, dummy);
  root->calc();
  root->calc1();
  root->rearrange(false);
  root->dump();
  cout << endl;
}

int main()
{
  int cnt = 0;
  while (getline(cin, line) and line[0] != '0') {
    //cerr << ++cnt << endl;
    comp.clear();
    par.clear();
    solve();
  }

  return 0;
}

Measured memory_bytes: 5464
using System;
//using System.Text;
//using System.Linq;
class Program
{
    public static int gcd(int a, int b)
    {
        if (b == 0) return a;
        return gcd(b, a % b);
    }
    static void Main()
    {
        while (true)
        {
            string r = Console.ReadLine();
            if (r == null) break;
            string[] c = r.Split();
            int a = int.Parse(c[0]),
                b = int.Parse(c[1]);
            int d = gcd(a, b);
            Console.WriteLine(d+" "+a/d*b);
        }
    }
}

Measured memory_bytes: 9012
import java.util.Scanner;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long sum = 0;
    int[] array = new int[100001];
    for(int i = 0; i < n; i++){
      int a = sc.nextInt();
      array[a]++;
      sum += (long)a;
    }
    int q = sc.nextInt();
    for(int i = 0; i < q; i++){
      int b = sc.nextInt();
      int c = sc.nextInt();
      long diff = (long)(c - b) * (long)array[b];
      array[c] += array[b];
      array[b] = 0;
      sum += diff;
      System.out.println(sum);
    }
  }
}

Measured memory_bytes: 60972
n, y =map(int, input().split())
for i in range(n+1):
    for j in range(n-i+1):
        if y-10000*i-5000*j==1000*(n-i-j):
            print(i, j, n-i-j)
            break
    else:
        continue
    break
else:
    print('-1 -1 -1')

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

#define int long long 

using namespace std;

void solve()
{
	int mx=0,n=0;
	string s;
	cin>>s;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='R'){
				n++;
		}
		else{
			mx=max(mx,n);
			n=0;
		}
	}
	mx=max(mx,n);
	cout<< mx << endl;
}

int32_t main() {

#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
#endif
	
	//int t;cin >> t;while(t--)
		solve();

	return 0;
}

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

int main(){
  int a,b;
  cin>>a>>b;

  if( a < b ) cout<<"a < b"<<endl;
  if( a > b ) cout<<"a > b"<<endl;
  if( a == b ) cout<<"a == b"<<endl;

  return 0;
}


Measured memory_bytes: 3040
#include<stdio.h>

int main(void){
    int a,n,y;
    while(scanf("%d",&a) != EOF){
        n = 1;
        y = 0;
        while(n < 1024){
            if (a % 2){
                if(y == 1){
                    printf(" ");
                }
                printf("%d",n);
                a--;
                y = 1;
            }
            n*=2;
            a/=2;
        }
        printf("\n");
    }
    return 0;
}

Measured memory_bytes: 596
def main():
    n = int(input())
    s = input()
    # Positions for each character.
    r = set()
    g = set()
    r_add = r.add
    g_add = g.add
    for ind, c in enumerate(s):
        if c == 'R':
            r_add(ind)
        elif c == 'G':
            g_add(ind)
    b = set(range(n)) - r - g

    ans = 0
    for i in r:
        for j in g:
            p, q = min(i, j), max(i, j)
            if (q - p) % 2 == 0 and (p + q) // 2 in b:
                ans -= 1
            if (q + (q - p)) in b:
                ans -= 1
            if (p - (q - p)) in b:
                ans -= 1
            ans += len(b)
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 74204
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
typedef long long ll;
#include <cmath>

int main(int argc, char *argv[])
{
	int a,b;

	cin>>a>>b;


	int sb=10*b,lb=10*b+9;
	int sa=(25*a+1)/2,la=(25*a+24)/2;

	int ret=max(sa,sb);
	if (ret>lb || ret>la) ret=-1;

	cout<<ret<<endl;

	return 0;
}


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

#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dump() fprintf(stderr, "#%s.%d\n", __func__, __LINE__);
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumplll(x1, x2, x3) fprintf(stderr, "#%s.%d (%s, %s, %s) = (%ld, %ld, %ld)\n", __func__, __LINE__, #x1, #x2, #x3, x1, x2, x3);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
typedef int64_t Int;
typedef std::vector<Int> LI;
const double pi = 3.14159265358979323846264338;
const Int mod = 1000000007;

template<typename T> void scan1(T& x) { fprintf(stderr, "unknown type\n"); }
template<> void scan1(Int& x) { if( scanf("%" PRId64, &x) < 0 ) exit(0); }
template<> void scan1(std::string& x) { if( not ( std::cin >> x ) ) exit(0); }
template<> void scan1(LI& xs) { for(Int &x : xs) scan1(x); }
void scan() {}
template<typename Head, typename... Tail>
void scan(Head& x, Tail&... xs) {
  scan1(x); scan(xs...);
}

template<typename T>
struct Maybe {
   T x;
   bool valid;
   Maybe() : valid(false) {}
   Maybe(T x_) : x(x_), valid(true) {}
   operator T() const {
      assert( valid );
      return x;
   }
};

struct Solver {
   Solver() { fprintf(stderr, "--------Solver begin--------\n"); }
   ~Solver() { fprintf(stderr, "--------Solver end--------\n"); }
   void solve() {
      Int h, w; scan(h, w);
      std::string field[64];
      for(Int i = 0; i < h; ++i) scan(field[i]);
      Int dx[] = {1, 1, 1, 0, 0, -1, -1, -1};
      Int dy[] = {1, 0, -1, 1, -1, 1, 0, -1};
      for(Int y = 0; y < h; ++y) {
         for(Int x = 0; x < w; ++x) {
            if( field[y][x] != '.' ) continue;
            Int z = 0;
            for(Int k = 0; k < 8; ++k) {
               Int nx = x + dx[k], ny = y + dy[k];
               if( not ( 0 <= nx and nx < w and 0 <= ny and ny < h ) ) continue;
               if( field[ny][nx] == '#' ) z += 1;
            }
            field[y][x] = '0' + z;
         }
      }
      for(Int i = 0; i < h; ++i) {
         printf("%s\n", field[i].c_str());
      }
   }
};

int main() {
   loop std::unique_ptr<Solver>(new Solver())->solve();
}




Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cmath>

using namespace std;

int main() {
    char c;
    cin >> c;
    if ('a' <= c && c <= 'z') cout << "a" << endl;
    else cout << "A" << endl;
}

Measured memory_bytes: 3628
#define REP(i,n) for(int i=0; i<(int)(n); i++)

#include <queue>
#include <iostream>
#include <cstdio>
inline int getInt(){ int s; scanf("%d", &s); return s; }

#include <set>

using namespace std;

int dp[1024][8];

int main(){
  const int n = getInt();
  string s; cin >> s;
  vector<int> v(n);
  REP(i,n) v[i] = s[i] == 'J' ? 0 : s[i] == 'O' ? 1 : 2;

  int ans = 0;
  dp[0][1] = 1;
  REP(i,n) REP(j,1<<3){
    REP(k,1<<3){
      if((k & (1 << v[i])) == 0 || (k & j) == 0) continue;
      (dp[i + 1][k] += dp[i][j]) %= 10007;
    }
  }

  REP(i,1<<3) (ans += dp[n][i]) %= 10007;
  printf("%d\n", ans);

  return 0;
}

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

using namespace std;

typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;
typedef long double LD;
typedef pair<LD, int> PLDI;
typedef pair<LD, LD> PLDLD;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define CLR(a) memset((a), 0 ,sizeof(a))
#define ALL(a) a.begin(),a.end()
const int INF = (1e9);
const LL MOD = 1e9+7;
const double PI=atan2(0,-1);

    int bac[100001];
int main()
{
    int n,m;
    cin>>n>>m;
    int ans=0;
    vector<int> x(n);
    REP(i,n)
    {
        cin>>x[i];
        bac[x[i]%m]++;
    }
    sort(ALL(x));
    REP(i,m)
    {
        int cou;
        if(i!=0 && i!=m-i)
        {
            cou = min(bac[i], bac[m-i]);
            bac[i]-=cou;
            bac[m-i]-=cou;
        }
        else if(i==m-i)
        {
            cou=bac[i]/2;
            bac[i]-=cou*2;
        }
        else
        {
            cou=bac[i]/2;
            bac[i]-=cou*2;
        }
        
        ans+=cou;
    }
    
    REP(i,n-1)
    {
        if(x[i]==x[i+1])
        {
            if(bac[x[i]%m]>=2)
            {
                bac[x[i]%m]-=2;
                ans++;
                i++;
            }
        }
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cmath>
using namespace std;
int main(){
    int a, k;
    cin>>a>>k;
    int arr[a], dp[a];
    for (int i=0; i<a; i++) cin>>arr[i], dp[i]=1e9;
    dp[0]=0;
    for (int i=0; i<a-1; i++){
        for (int j=1; j<=k; j++){
            if (i+j>=a) break;
            dp[i+j]=min(dp[i+j], dp[i]+abs(arr[i]-arr[i+j]));
        }
    }
    cout<<dp[a-1]<<endl;
}

Measured memory_bytes: 1024
n = int(input())
a = list(map(int, input().split()))

p = []
q = []
r = []

for i in range(n):
    if a[i] % 4 == 0:
        p.append(a[i])
    elif a[i] % 2 == 0:
        q.append(a[i])
    else:
        r.append(a[i])

s = len(p)
t = len(q)
u = len(r)

if t == 0:
    if u <= s + 1:
        print("Yes")
    else:
        print("No")
else:
    if u <= s:
        print("Yes")
    else:
        print("No")



Measured memory_bytes: 14252
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    ll n, k;    cin >> n >> k;
    vector<int>a(n);
    rep(i, n){
        int A;  cin >> A;
        a[i] = --A;
    }
    int ptr = 0;
    vector<int>visited(n, -1);
    for(ll i = 1; i <= k; i++){
        if(visited[ptr] == -1){
            visited[ptr] = i-1;
        }else{
            k = i + (k-i)%(i-1-visited[ptr]);
        }
        ptr = a[ptr];
    }
    cout << ptr+1 << endl;
}


Measured memory_bytes: 4820
#include <iostream>
#include <string.h>
using namespace std;

const int INF = 1<<28;
int dp1[1000001];
int dp2[1000001];

int search(int n, int k){
	if(k == 0){
		if(dp1[n] != -1)
			return dp1[n];
	}
	else{
		if(k == 1){
			if(dp2[n] != -1)
				return dp2[n];
		}
	}
	
	if(n <= 0)
		return 0;
		
	int res = INF;
	for(int i = 1; i <= 1000000; ++i){
		int a = i * (i + 1) * (i + 2) / 6;
		if(a > n)
			break;
		if(k == 1 && a % 2 == 0)
			continue;
			
		if(k == 0)
			res = min(res, search(n - a, k) + 1);
		else
			res = min(res, search(n - a, k) + 1);
	}
	if(k == 0)
		return dp1[n] = res;
	else
		return dp2[n] = res;
}

int main() {
	memset(dp1, -1, sizeof(dp1));
	memset(dp2, -1, sizeof(dp2));
	
	for(int i = 1; i <= 1000000; ++i){
		search(i, 0);
		search(i, 1);
	}
	int n;
	while(cin >> n && n){
		cout << dp1[n] << " " << dp2[n] << endl;
	}
	return 0;
}

Measured memory_bytes: 8980
#include<bits/stdc++.h>
#define rep(i,n) for(i=0; i<n; ++i)
using namespace std;
int main(void){
  int b=0,i,N; cin >> N;
  vector<int> a(N);
  rep(i,N){ cin >> a[i]; b^=a[i];}
  rep(i,N) cout << (a[i]^b) << ' ';
  return 0;
}

Measured memory_bytes: 4052
def examA():
    x, y = LI()
    ans = 0
    if x<0 and y<0:
        if x<=y:
            ans = y-x
        else:
            ans = x-y+2
    elif x<0 and 0<=y:
        if -x<=y:
            ans = y+x+1
        else:
            ans = min(-(x+y)+1,y-x)
    elif y<=0:
        ans = abs(y+x)+1
    else:
        if x<=y:
            ans = y-x
        else:
            ans = x-y+2
    print(ans)
    return

def examB():
    B, K = LI()
    A = LI()
    cumA = [0]*(B+1); negA = [0]*(B+1)
    for i,a in enumerate(A):
        cumA[i+1] = cumA[i]
        negA[i+1] = negA[i]
        if a>0:
            cumA[i+1] +=a
        else:
            negA[i+1] +=a
    ans = 0
    for i in range(B-K+1):
        curC = cumA[K+i]-cumA[i]; curN = negA[K+i]-negA[i]
        now1 = cumA[B] + curN
        now2 = cumA[B] - curC
#        print(now1,now2)
        ans = max(ans,now1,now2)
    print(ans)
    return

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18

if __name__ == '__main__':
    examB()


Measured memory_bytes: 63264
#include<bits/stdc++.h>
using namespace std;
#define NitroBoost \
        ios_base::sync_with_stdio(false); \
        cin.tie(NULL);
#define ll long long
#define fori(i,l,n) for(int i=l;i<n;i++)
#define ford(i,n,l) for(int i=n;i>l;i--)
#define All(i,x) for(auto i=x.begin();i!=x.end();++i)
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) (((a)*(b))/gcd((a),(b)))
#define test int t;cin>>t;while(t--)
#define pb(i) push_back(i)
#define watch(x) cout<<(#x)<<"="<<(x)<<"\n"
#define str(n) to_string(n)
#define fi first
#define sec second
#define prec(n) fixed<<setprecision(n)
#define mp make_pair
const double pi=3.141592653589793;
const int MOD=1e9+7;
ll power(ll x, ll y, ll m) 
{
     ll res = 1;x %= m;
    while (y > 0) {
        if (y & 1)
        res = (res*x) % m;
        y>>=1;
        x = (x*x) % m;
    }
    return res%m;
}
int look[100001],k;
int dp(int a[],int n){
    if(n<=0)
    return 0;
    if(look[n]==-1){
        int minc=INT_MAX;        
        if(n==1)
        look[n]=abs(a[1]-a[0]);
        else 
        {
            fori(i,1,k+1){
                if(n>=i){
                    minc=min(minc,dp(a,n-i)+abs(a[n]-a[n-i]));
                }
                else break;
            }
            look[n]=minc;
        }
    }
    return look[n];
}
void solve(){
    fori(i,0,100001)
    look[i]=-1;
    int n;
    cin>>n>>k;
    int a[n];    
    fori(i,0,n)
    cin>>a[i];
    cout<<dp(a,n-1);
}
int main(){  
    NitroBoost
    //freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
    //test
    {
        solve();
    }
    return 0;
}

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

int m=1000000007;

long long p(long long a) {
    int aa=a;
    queue<int> q;
    while (aa!=0) {
        if (aa%2==1) q.push(1);
        else q.push(0);
        aa/=2;
        //cout << aa << endl;
    }
    long long count=1;
    long long b=2;
    while(!q.empty()) {
        if (q.front()==1) {
            count*=b;
            count%=m;
            //cout << count << endl;
        }
        b*=b;
        b%=m;
        q.pop();
    }
    return count;
};
int main() {
   int N;
   cin >> N;
   long long A[N];
   for (int i=0; i<N; i++) cin >> A[i];
   long long total=0;
   for (int i=0; i<N; i++) {
       total+=A[i];
       total%=m;
   }
   total*=total;
   //cout << total << endl;
   total%=m;
   for (int i=0; i<N; i++) {
       total-=(A[i]*A[i]);
       //cout << total << endl;
       //cout << A[i] << endl;
       total%=m;
   }
   if (total<0) total+=m;
   //cout << total << endl;
   total*=p(m-2);
   total%=m;
   cout << total << endl;
}

Measured memory_bytes: 5140
#include <stdio.h>
  
int main(int argc, char *argv[]) {
    int a, b, c;
    int k;

    scanf("%d%d%d%d", &a, &b, &c, &k);
    int f = 1;
    for (int i = 0; i < k; i++) {
        f *= 2;
    }

    int max = (a >= b && a >= c) ? (a * f + b + c) :
              (b >= a && b >= c) ? (b * f + a + c) :
                                   (c * f + a + b) ;

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

    return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <iostream>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <tuple>

using namespace std;
#define ll long long
#define pb push_back

int main() {
  int X,Y;
  cin >> X >> Y;
  
  cout << X + Y/2 << endl;

}


Measured memory_bytes: 256
#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;
#define MV 200001
#define LMV 21
#define ff first
#define ss second
#define pb push_back
#define eb emplace_back
#define emp emplace
#define mp make_pair
#define ins insert
#define sz(x) (int)x.size()
#define whoami(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); whi(_it, args); }

void whi(istream_iterator<string> it) { cerr<<"\n"; }

template<typename T, typename... Args>
void whi(istream_iterator<string> it, T a, Args... args) { cerr<<*it<<" "<<a<<" "; whi(++it, args...); }

void FLASH() {ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);}
void SETF() {cout.ios_base::setf(ios_base::fixed); cerr.ios_base::setf(ios_base::fixed);}
void UNSETF() {cout.ios_base::unsetf(ios_base::fixed); cerr.ios_base::unsetf(ios_base::fixed);}

typedef long long ll;
typedef long double ld;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
typedef pair<PII, int> PPII;
typedef pair<PLL, ll> PPLL;
typedef map<int, int> MII;

const int MOD = 1000000007;
const ll INF = 4e18;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
template <typename T>
using ordered_multiset = tree<T, null_type, less_equal<T>, rb_tree_tag, tree_order_statistics_node_update>;

struct h_llint {
  static uint64_t splitmix64(uint64_t x) {    // http://xorshift.di.unimi.it/splitmix64.c
    x += 0x9e3779b97f4a7c15;
    x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
    x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
    return x ^ (x >> 31);
  }
  size_t operator()(uint64_t x) const {
    static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
    return splitmix64(x + FIXED_RANDOM);
  }
};

struct h_pair{
  size_t operator()(const PLL&x)const{
    return hash<ll>()(((ll)x.ff)^(((ll)x.ss)<<32));
  }
};

typedef map<ll, ll> MLL;
typedef map<PII, int> MPII;
typedef map<PLL, ll> MPLL;
typedef set<int> SI;
typedef set<ll> SL;
//ordered_set = order_of_key(.)
//ordered_set = find_by_order(.)
typedef ordered_set<int> OSI;
typedef ordered_set<ll> OSL;
typedef ordered_multiset<int> MOSI;
typedef ordered_multiset<ll> MOSL;
typedef unordered_map<ll, int, h_llint> UMLI;
typedef unordered_map<ll, ll, h_llint> UMLL;
typedef unordered_map<PLL, int, h_pair> UMPI;
typedef unordered_map<PLL, ll, h_pair> UMPL;

int ar[MV];
ll arr[MV];

void solve(int T)
{
	int n;
	cin>>n;
	int yy = 0;
	for(int i=0;i<n;i++)
	{
		int t;
		cin>>t;
		if(!(i & 1) && (t & 1))
		yy++;	
	}	
	cout<<yy<<"\n";
	return;
}

int main(void)
{
	FLASH();
	//freopen("cowjog.in", "r", stdin);
	//freopen("cowjog.out", "w", stdout);
	int T;
	T = 1;

#ifndef ONLINE_JUDGE
	time_t time_t1, time_t2;
	time_t1 = clock();
#endif

	//cin>>T;
	while(T--)
	solve(T);

#ifndef ONLINE_JUDGE
	time_t2 = clock();
	SETF();
	cerr<<"Time taken: "<<setprecision(7)<<(time_t2 - time_t1)/(double)CLOCKS_PER_SEC<<"\n";
	UNSETF();
#endif

	return 0;
}

Measured memory_bytes: 3648
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    private static Scanner sc;

    public static void main(String[] args) {
        Main instance = new Main();
        sc = instance.new Scanner();
        instance.solve();
    }

    private void solve() {
        try {
        	String s = sc.next();
            if(s.contains("a") && s.contains("b") && s.contains("c")) {
            	System.out.println("Yes");
            }else {
            	System.out.println("No");
            }
        } catch (Exception e) {
            e.printStackTrace();
        }
    }

    private class Scanner {
        String[] s;
        int i;
        BufferedReader br;
        String regex = " ";

        public Scanner() {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }

        @Override
        protected void finalize() throws Throwable {
            try {
                super.finalize();
            } finally {
                destruction();
            }
        }

        private void destruction() throws IOException {
            if (br != null) br.close();
        }

        public String next() throws IOException {
            if (i < s.length) return s[i++];
            String st = br.readLine();
            while (st == "") st = br.readLine();
            s = st.split(regex, 0);
            i = 0;
            return s[i++];
        }

        public int nextInt() throws NumberFormatException, IOException {
            return Integer.parseInt(next());
        }

        public Long nextLong() throws NumberFormatException, IOException {
            return Long.parseLong(next());
        }

        public Double nextDouble() throws NumberFormatException, IOException {
            return Double.parseDouble(next());
        }
    }
}

Measured memory_bytes: 21204
def input_from_console():
    n, k = map(int, input().split())
    a_list = []
    for i in range(k):
        d = input().rstrip()
        a = map(int, input().rstrip().split())
        for ii in a:
            if not ii in a_list:
                a_list.append(ii)
    return n, a_list


def solve(n, a_list):
    # print("n, a_list", n, a_list)
    return n - len(a_list)


def main():
    n, a_list = input_from_console()
    print(solve(n, a_list))

if __name__ == "__main__":
    import sys

    if sys.gettrace():  # Check if the python interpreter is in debug mode or not.
        check_cases()
    else:
        main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
#define FAST_IO ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef long long ll;
int main() {
    FAST_IO;
    
    int n;
    cin >> n;

    for (int i = 1; i <= 9; ++i) {
        for (int j = 1; j <= 9; ++j) {
            if (i*j == n) {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>
#include <complex>

using namespace std;

#define mod 1000000007
double result[(1 << 16)][17] = {};

int main()
{
	int m, n;
	cin >> m >> n;
	double winper[17][17] = {};
	for(int i = 0; i < m; i++){
		for(int j = 0; j < n; j++){
			cin >> winper[i][j];
		}
	}
	for(int i = 0; i < (1 << m); i++){
		result[i][n] = 1.0;
	}
	// 今j番目の部屋にいる(今からj番目の敵を倒す)
	for(int j = n - 1; j >= 0; j--){
		// 残っている猫の組み合わせ : i
		for(int i = 0; i < (1 << m); i++){
			// 次に戦う猫を決める
			double tmpres = 0.0;
			for(int k = 0; k < m; k++){
				if((i & (1 << k)) == 0) continue;
				// どこまで戦い抜くか？
				double tmp = 1.0;
				double tmpres = (1.0 - winper[k][j]) * result[i ^ (1 << k)][j];
				for(int l = j; l < n; l++){
					tmp *= winper[k][l];
					tmpres += tmp * (1.0 - winper[k][l + 1]) * result[i ^ (1 << k)][l + 1];
				}
				result[i][j] = max(result[i][j], tmpres);
			}
			// cout << i << " " << j << " " << result[i][j] << endl;
		}
	}
	printf("%.10f\n", result[(1 << m) - 1][0]);
	return 0;
}


Measured memory_bytes: 11992
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

int n, dp[5001][5001];
string s;

int main() {
	cin >> n >> s;
	
	dec(i, n) {
	dec(j, n) {
		if(s[i] == s[j]) { dp[i][j] = dp[i + 1][j + 1] + 1; }
	}
	}
	
	int ans = 0;
	inc(i, n) {
	inc(j, i) {
		setmax(ans, min(dp[i][j], SC<int>(i - j)));
	}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 97920
import sys
array = []
for i in sys.stdin:
  array.append(int(i))
m=max(array)
prime = [1]*(m+1)
prime[0] = prime[1] = 0
for i in range(2,int(m**0.5)+1):
  if prime[i] == 1:
    for j in range(i*i, m+1, i):
      prime [j] = 0
for i in range(len(array)):
  print(sum(prime[:array[i] + 1]))


Measured memory_bytes: 21980
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define vi vector<int>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pi 3.141592653589793238
#define eb emplace_back
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define zip(i,a,b) for(int i=a;i<b;i++)
#define rzip(i,a,b) for(int i=a;i>=b;i--)
#define ll unsigned int
#define test int t;cin>>t; while(t--)
#define um unordered_map
#define en '\n'
#define us unordered_set
typedef pair<int, int>     pii;
typedef pair<char, int>    pci;
typedef pair<char, char>   pcc;
typedef vector<pii>       vii;
typedef long double ld;
#define all(v) v.begin(), v.end()
#define sz(x) (int)x.size()
#define INF (1e18+5)
#define inf (1e9+5)
#define mod 1000000007


void __print(int x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}
// You should only debug a pair of simple data types. For example,
// the debug won't work if one of pair's elements is collection type
// (std::vector, std::map, std::set...).
template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i : x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif


// bool check_prime(int n)  return whether a number is prime or not O(sqrt(N));
// int BE(int x,int n,int m)  return x^n%m; O(logN);
// void sieve()  from number 1-1000001 saare prime store kar lega  in bool is_prime[1000001] array
// vector<int> z_array(string s)  return vector which is Z-array of string s;
// vector<int> lps(string s)      return vector which is lps array of string s;



int32_t main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(0);
#ifndef ONLINE_JUDGE
	if (fopen("input.txt", "r"))
	{
		freopen ("input.txt" , "r" , stdin);
		freopen ("output.txt" , "w" , stdout);
	}
#endif
	//_______________________________-code starts-_______________________________________________

	int n;
	cin >> n;
	string s;
	cin >> s;
	string t = s;
	sort(all(t));
	int cnt = 0;
	int r = 0, w = 0;
	zip(i, 0, n)
	{
		if (s[i] == 'R')
			r++;
		else if (s[i] == 'W')
			w++;

		if (s[i] != t[i])
			cnt++;
	}
	int ans = cnt / 2;
	cout << ans << en;


	return 0;
}



Measured memory_bytes: 3852
#include <cstdio>
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)

typedef long long ll;

ll vs[100000+10];
ll ts[100000+10];
int main(void) {
  int n;
  scanf("%d", &n);
  REP(i, n) {
    scanf("%lld", &vs[i]);
  }
  sort(vs, vs + n);
  ll res = 0;
  if(n % 2 == 0) {
    ll cur = 0;
    REP(i, n/2) {
      cur += vs[n-1-i];
      if(i != n/2-1) {
        cur += vs[n-1-i];
      }
    }
    REP(i, n/2) {
      cur -= vs[i];
      if(i != n/2-1) {
        cur -= vs[i];
      }
    }
    res = max(res, cur);
  } else {
    { // 上から
      ll cur = 0;
      REP(i, (n+1)/2) {
        cur += vs[n-1-i];
        if(i < (n+1)/2-2) {
          cur += vs[n-1-i];
        }
      }
      REP(i, n/2) {
        cur -= vs[i]*2;
      }
      res = max(res, cur);
    }
    { // 下から
      ll cur = 0;
      REP(i, (n+1)/2) {
        cur -= vs[i];
        if(i < (n+1)/2-2) {
          cur -= vs[i];
        }
      }
      REP(i, n/2) {
        cur += vs[n-1-i]*2;
      }
      res = max(res, cur);
    }
  }
  
  cout  << res << endl;
  return 0;
}


Measured memory_bytes: 1024