akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i <(n); ++i)
#define REP2(i,x,n) for (int i = x; i <(n); ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
static const double PI = acos(-1);
static const int INF = 1e9+7;
#define REP(i,n) for (int i = 0; i <(n); ++i)
//debug 
#ifdef _DEBUG
#define debug(var)  do{cout << #var << " :";view(var);}while(0)
#else
#define debug(...)
#endif
template<typename T> void view(T e){cout << e << endl;}
template<typename T> void view(const vector<T>& v){for(const auto& e : v){ cout << e << " "; } cout << endl;}
template<typename T> void view(const vector<vector<T> >& vv){ for(const auto& v : vv){ view(v); } }


int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  REP(i,n) cin >> a[i];

  sort(RALL(a));

  int cnt = 0;

  ll ans = 1;
  REP(i,n-1){
    if(a[i] == a[i+1]){
      ans *= a[i];
      cnt++;
      i++;
      if(cnt == 2){
        cout << ans << endl;
        return 0;
      }
    }   
  }


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

Measured memory_bytes: 3796
#define _USE_MATH_DEFINES
#define INF 0x3f3f3f3f
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <queue>
#include <stack>
#include <limits>
#include <map>
#include <string>
#include <cstring>
#include <set>
#include <deque>
#include <bitset>
#include <list>

using namespace std;

typedef long long ll;
typedef pair<int,string> P;

static const double EPS = 1e-8;

class State {
public:
  int x;
  int cost;
  State(int x,int cost)
    : x(x), cost(cost) {}
  bool operator<(const State& s) const {
    return cost < s.cost;
  }
  bool operator>(const State& s) const {
    return cost > s.cost;
  }
};

int main(){
  int max_roulette_num;
  while(~scanf("%d",&max_roulette_num)){
    if(max_roulette_num == 0) break;

    int stage[320] = {};
    int total_cells;
    scanf("%d",&total_cells);
    for(int i = 0; i < total_cells; i++){
      int cell;
      scanf("%d",&cell);
      stage[i+1] = cell;
    }
    stage[0] = 0;
    stage[total_cells + 1] = 0;
    
    priority_queue<State,vector<State>,greater<State> > que;
    que.push(State(0,0));
    int dp[320];
    memset(dp,0x3f,sizeof(dp));
    dp[0] = 0;
    while(!que.empty()){
      State s = que.top();
      que.pop();
      for(int i = 1; i <= max_roulette_num; i++){
        int next = s.x + i;
        if(next > total_cells + 1) continue;
        next += stage[next];
        if(dp[next] <= s.cost + 1) continue;
        dp[next] = s.cost + 1;
        que.push(State(next,s.cost + 1));
      }
    }
    vector<int> starts;
    for(int i = 0; i <= total_cells + 1; i++){
      if(dp[i] < INF) starts.push_back(i);
    }

    bool has_unable = false;
    for(int start_i = 0; start_i < starts.size(); start_i++){
      int start = starts[start_i];
      memset(dp,0x3f,sizeof(dp));

      que.push(State(start,0));
      dp[start] = 0;
      while(!que.empty()){
        State s = que.top();
        que.pop();
        for(int i = 1; i <= max_roulette_num; i++){
          int next = s.x + i;
          if(next > total_cells + 1) continue;
          next += stage[next];
          if(dp[next] <= s.cost + 1) continue;
          dp[next] = s.cost + 1;
          que.push(State(next,s.cost + 1));
        }
      }

      if(dp[total_cells + 1] >= INF){
        has_unable = true;
        break;
      }
    }
    
    printf("%s\n", has_unable ? "NG" : "OK");
  }
}

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

signed main() {
    int N;
    cin >> N;
    int ac = 0;
    int wa = 0;
    int tle= 0;
    int re = 0;

    rep (i, N) {
        string S;
        cin >> S;
        if (S[0] == 'A') ac++;
        if (S[0] == 'W') wa++;
        if (S[0] == 'T') tle++;
        if (S[0] == 'R') re++;
    }
    cout << "AC x "  << ac  << endl;
    cout << "WA x "  << wa  << endl;
    cout << "TLE x " << tle << endl;
    cout << "RE x "  << re  << endl;
}


Measured memory_bytes: 3624
#include <stdio.h>
#include <algorithm>
#include <stdlib.h>
#include <cstring>
#include <iostream>
#include <math.h>
using namespace std;
int main ()
{
	int r=700;
	char s[4];
	scanf("%s",&s);
	for(int i=0;i<3;i++)
	{
		if(s[i]=='o')
		{
			r+=100;
		}
	}
	printf("%i",r);
	return 0;
}


Measured memory_bytes: 256
from collections import deque

s = input()
q = int(input())

dt = deque()
de = deque()

f1 = 1
f2 = 2

for _ in range(q):
    q = input().split()
    if int(q[0]) == 1:
        f1,f2 = f2,f1
    elif int(q[0]) == 2:
            if int(q[1]) == f1:
                dt.appendleft(q[2])
            elif int(q[1]) == f2:
                de.append(q[2])
                
st = "".join(dt)
se = "".join(de)
ans = st + s + se

if f1 == 1:
    print(ans)
else:
    ans = list(ans)
    ans.reverse()
    ans = "".join(ans)
    print(ans)

Measured memory_bytes: 13892
// C - Half and Half
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vs = vector<string>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, k, n, x, y, w, ans = 0, count = INF;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> a >> b >> c >> x >> y;
  repe(i, 0, 100000)
  {
    ans = i * 2 * c + max(0LL, (x - i)) * a + max(0LL, (y - i)) * b;
    count = min(count, ans);
    // cout << count << endl;
  }
  cout << count << endl;
}

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

const int maxn = 1e5 + 10;

int n;
int a[maxn];
map<int,int>q;

int main()
{
    scanf("%d", &n);
    for(int i = 1; i <= n; i++)
    {
        scanf("%d", &a[i]);
       // q[a[i]]++;
    }
    int cnt = 0;
    for(int i = 1; i <= n; i++)
    {
        if(a[i] == i)
        {
            if(a[i+1] == i + 1)
            {
                i++;
            }
            cnt++;
        }
    }
    printf("%d\n", cnt);
    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
constexpr Int MOD = 1e9+7;
int N, M;
vector<vector<tuple<Int, int, int>>> graph;
void dijkstra(int start, vector<Int>& dist)
{
    using P = pair<Int, int>;
    priority_queue<P, vector<P>, greater<P>> Q;
    vector<bool> visited(N);
    Q.emplace(0, start);
    while (!Q.empty()) {
        Int d, n; tie(d, n) = Q.top();
        Q.pop();
        if (visited[n]) continue;
        visited[n] = true;
        dist[n] = d;
        for (auto& tup : graph[n]) {
            int dd, nn, edge; tie(dd, nn, edge) = tup;
            Q.emplace(d + dd, nn);
        }
    }
}
void counting(int start, vector<Int>& distOpp, vector<Int>& countV)
{
    using P = pair<Int, int>;
    priority_queue<P, vector<P>, greater<P>> Q;
    vector<bool> visited(N);
    Q.emplace(0, start);
    countV[start] = 1;
    while (!Q.empty()) {
        Int d, n; tie(d, n) = Q.top();
        Q.pop();
        if (visited[n]) continue;
        visited[n] = true;
        for (auto& tup : graph[n]) {
            int dd, nn, id; tie(dd, nn, id) = tup;
            if (distOpp[n] - distOpp[nn] == dd) {
                (countV[nn] += countV[n]) %= MOD;
                Q.emplace(d + dd, nn);
            }
        }
    }
}
int main()
{
    cin >> N >> M;
    int S, T; cin >> S >> T; S--, T--;
    graph.resize(N);
    vector<Int> distS(N), distT(N), countS(N), countT(N);
    vector<tuple<int, int, int>> edges;
    for (int i = 0; i < M; i++) {
        int u, v, d; cin >> u >> v >> d; u--, v--;
        edges.emplace_back(u, v, d);
        graph[u].emplace_back(d, v, i);
        graph[v].emplace_back(d, u, i);
    }
    dijkstra(S, distS);
    dijkstra(T, distT);
    counting(S, distT, countS);
    counting(T, distS, countT);
    Int all = 0, collision = 0;
    for (int i = 0; i < N; i++) {
        if (distS[i] * 2 == distS[T]) {
            Int pat = countS[i] * countT[i] % MOD;
            (all += pat) %= MOD;
            (collision += pat * pat) %= MOD;
        }
    }
    for (int i = 0; i < M; i++) {
        int u, v, d; tie(u, v, d) = edges[i];
        if (distS[u] > distS[v]) swap(u, v);
        bool shortest = distS[u] + d + distT[v] == distS[T];
        bool half = distS[u] * 2 < distS[T] && distT[v] * 2 < distS[T];
        if (shortest && half) {
            Int pat = countS[u] * countT[v] % MOD;
            (all += pat) %= MOD;
            (collision += pat * pat) %= MOD;   
        }
    }
    cout << (all * all % MOD - collision + MOD) % MOD << endl;
    return 0;
}


Measured memory_bytes: 25452
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--) 
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define downque(que) priority_queue<ll> que;
#define upque(que) priority_queue<ll, vector<int>, greater<int>> que;
typedef long long ll;
typedef vector<vector<int>> Matrix;
const int MOD = 1e9 + 7;
const int MAX = 1e7;
const int INF = numeric_limits<int>::max();

int main(){
 int n,d,res=0; cin>>n>>d;
 cout<<(n-1)/(2*d+1)+1<<endl;

}

Measured memory_bytes: 256
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
using namespace std;
#include <vector>
#define rep(i,n) for (int i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

/*
#include <math.h>
int standerd = int(pow(10.0,9.0)) + 7;
*/
string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

ll A;
ll B;
ll C;
ll N;

int main(){


    
    cin >> A;
    cin >> B;

    ll A_max;
    ll A_min;
    ll B_max;
    ll B_min;

    double tmp;
    double tmpd;
    ll tmpi;
    double tax;
    tax = 0.08;
    tmp = A;
    tmpi = (tmp+1)/tax;
    tmpd =  (tmp+1)/tax;
    if(tmpi==tmpd) A_max = tmpi -1;
    else A_max = tmpi;
    tmpi = (tmp)/tax;
    tmpd =  (tmp)/tax;
    if(tmpi==tmpd) A_min = tmpi ;
    else A_min = tmpi+1;
    
    tax = 0.1;
    tmp = B;
    tmpi = (tmp+1)/tax;
    tmpd =  (tmp+1)/tax;
    if(tmpi==tmpd) B_max = tmpi -1;
    else B_max = tmpi;
    tmpi = (tmp)/tax;
    tmpd =  (tmp)/tax;
    if(tmpi==tmpd) B_min = tmpi ;
    else B_min = tmpi+1;

    if(B_min>A_max || A_min > B_max){
        cout << -1 << endl;
    }else{
        cout << max(A_min,B_min) << endl;
    }

}

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

using namespace std ; 

const int N = 1e5 + 7 ; 

int main(){
    ios_base::sync_with_stdio(0) ; 
    cin.tie(0) ; 
    //freopen("in.in" , "r" ,stdin) ; 
    int a , b, c ,  k ; 
    cin>>a>>b>>c>>k ; 
    int ans = 0 ; 
    vector<pair<int , int > > V = { {a , 1} , {b , 0} , {c , -1}} ; 
    for(auto u : V){
        if( k ){
            int mn = min(k , u.first ) ; 
            ans += mn * u.second ; 
            k-=mn ; 
        }
    }
    cout<< ans ; 
    return 0 ; 
}

Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}


int main() {
  int n; cin >> n;
  vector<int> d(13);
  d[0]++;
  rep(i,n) {
    int x; cin >> x;
    ++d[x];
  }
  int ans = 0;

  rep(i,13) if(d[i]>2) { puts("0"); return 0;}

  for (int bit = 0; bit < (1<<13); ++bit) {
    vector<int> v1;
    for (int i = 0; i < 13; ++i) {
      if(d[i] == 0) continue;
      if(d[i] > 1) {
        v1.push_back(i);
        v1.push_back(24 - i);
        continue;
      }
      if (bit & (1<<i)) v1.push_back(i);
      else v1.push_back(24 - i);
    }
    int nn = v1.size();
    int s = 100;
    rep(i, nn) rep(j, i+1, nn) {
      int x = abs(v1[i] - v1[j]);
      umin(s, min(x, 24-x));
    }
    umax(ans, s);
  }

  cout << ans << endl;
}


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

#define ALL(v) v.begin(), v.end()
#define V vector
#define P pair
using ll = long long;
using ld = long double;
const int MOD = 1e9+7;
const ll INF = 1LL << 60;


int main() {
    int A, B, m; cin >> A >> B >> m;
    V<int> a(A), b(B);
    int amin = 1e9, bmin = 1e9;
    for(int i = 0; i < A; i++){
        cin >> a[i];
        amin = min(a[i], amin);
    }
    for(int i = 0; i < B; i++){
        cin >> b[i];
        bmin = min(b[i], bmin);
    }

    V<int> x(m), y(m), c(m);
    for(int i = 0; i < m; i++){
        int xx, yy, cc; cin >> xx >> yy >> cc;
        xx--, yy--;
        x[i] = xx;
        y[i] = yy;
        c[i] = cc;
    }

    int ans = 1e9;
    for(int i = 0; i < m; i++){
        ans = min(a[x[i]] + b[y[i]] - c[i], ans);
    }

    cout << min(ans, amin + bmin) << endl;

    return 0;
}


Measured memory_bytes: 5028
/*
・反省点
大まかな実装の方針(BFSを用いる)はできていた
BFS, DFS を用いたやり方をマスターする
*/
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;

int main() {
    int K;
    cin >> K;
    vector<long long> nums;
    //BFSして、K個目を出力?
    for (int i = 1; i <= 9; i++){
        nums.push_back(i);
    }
    while(true){
        if(K <= nums.size()){
            cout << nums[K - 1] << endl;
            return 0;
        }
        K -= nums.size();
        vector<long long> old_nums;
        swap(old_nums, nums);
        for(long long x : old_nums){
            for (int i = -1; i <= 1; i++){//もとの数-1, もとの数と等しい, もとの数+1
                int d = x % 10 + i;
                if (d < 0 || d > 9) continue;
                long long nx = x * 10 + d;
                nums.push_back(nx);
            }
        }
    }
}

Measured memory_bytes: 1712
#include<bits/stdc++.h>
using namespace std;
 
#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         cout<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
#define endl            "\n"
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());


void __print(int32_t x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long 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");}

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
 
char myHeap[200 * 1024 * 1024];
int sz = 0;
void assert_tle(bool q) { while (!q); }
void* operator new  ( std::size_t count ) {
    sz += count;
    assert_tle(sz <= 200 * 1024 * 1024);
    return myHeap + sz - count;
}
 
void operator delete (void *ptr) { }
 
 
void fastIO()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}

bool condition(int a,int b,int c)
{
    int k=c-a-b;
    debug(k);
    if(k<0)
        return false;
    //k/=2;
    k*=k;
    //debug(k);
    int k2=a*b*4;
    //k2*=k2;
    debug(k2);
    return k2<k;

}

void solve()
{
    int a,b,c;
    cin>>a>>b>>c;

    if(condition(a,b,c))
    {
        cout<<"Yes";
    }
    else
    {
        cout<<"No";
    }
}
 
int32_t main()
{
    fastIO();
    //w(t)
    {
        solve();
        cout<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <string>
#include <algorithm>
#include <queue>
#include <iomanip>
#include <stack>

#define pb push_back
#define ins insert
#define pob pop_back
#define er erase
#define emp empty
#define f first
#define s second
#define ff f.f
#define fs f.s
#define sf s.f
#define ss s.s
#define var auto

using namespace std;
template<typename  T>
using s = set<T>;
template<typename T>
using  v = vector<T>;
template<typename T1, typename  T2>
using p = pair < T1, T2>;
typedef long long ll;
typedef p<int, int> pii;
typedef v<int> vi;
typedef v<pii> vpii;
typedef s<int> si;
typedef s<pii> spii;


const int Max = 4e3 + 100;
const int MOD = 1e9 + 7;
const ll INF = 1e18;
int n;

ll dp[Max][Max];
ll sz[Max][Max];
ll A[Max];

ll CALC(int i, int j)
{
	if (dp[i][j] == INF)
	{
		for (int k = i; k < j; k++)
		{
			//k + 1 : [i + 1 -> j]
			ll trg = CALC(i, k) + CALC(k + 1, j) + sz[i][k] + sz[k + 1][j];
			dp[i][j] = min(dp[i][j], trg);
			if (dp[i][j] == trg)
				sz[i][j] = sz[i][k] + sz[k + 1][j];
		}
	}

	return dp[i][j];
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	for (int i = 0; i < n; i++)
	{
		for (int j = i; j < n; j++)
		{
			dp[i][j] = INF;
		}
		dp[i][i] = 0;
		sz[i][i] = A[i];
	}

	cout << CALC(0, n - 1);
}

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

int main()
{
  int N,K ;
  cin>>N>>K ;
  int h[N] ;
  for(int i=0;i<N;i++) cin>>h[i] ;
  
  int tmp=N ;
  for(int i=0;i<tmp;i++) if(h[i]<K) N-- ;
  cout<<N ;
  
  return 0 ;
}

Measured memory_bytes: 640
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline

n=int(input())
ps=list(map(int,input().split()))
cnt=0
for i,p in enumerate(ps):
    if i+1!=p:
        cnt+=1
    if cnt>2:
        print("NO")
        break
else:
    print("YES")

Measured memory_bytes: 3060
#include<stdio.h>
int n;
char x[60][60];
int nums[1000];
int new_n[1000];
int main(void){
    int i,j,k;
    char a;
    for(i=0;i<60;i++){
        for(j=0;j<60;j++){
            x[i][j]=0;
        }
    }
    for(i=0;i<1000;i++){
        nums[i]=0;
        new_n[i]=0;
    }
    scanf("%d",&n);
    scanf("%c",&a);
    i=0;
    j=0;
    while(1){
        scanf("%c",&a);
        if(a=='\n'){
            j=0;
            i++;
            if(i!=1){
                for(k='a';k<='z';k++){
                    if(new_n[k]<nums[k]){
                        nums[k]=new_n[k];
                    }
                }
            }
            for(k='a';k<='z';k++){
                new_n[k]=0;
            }
        }else{
            x[i][j]=a;
            if(i==0){
                nums[a]++;
            }else{
                new_n[a]++;
            }
            j++;
        }
        if(i==n){
            break;
        }
    }
    for(k='a';k<='z';k++){
        while(1){
            if(nums[k]==0){
                break;
            }else{
                printf("%c",k);
                nums[k]--;
            }
        }
    }
    printf("\n");
    return 0;
}


Measured memory_bytes: 128
def main():
    N, L = map(int, input().split())
    sum_val = int(N * (L - 1) + N * (N + 1) / 2)
    if L >= 0:
        print(sum_val - L)
    elif 1 - N < L < 0:
        print(sum_val - 0)
    else:
        print(sum_val - (N+L-1))
    return


if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time
sys.setrecursionlimit(10**7)
inf = 10**20

def oddDigit(x):
    s = str(x)
    return(len(s)%2 == 1)

N = int(input())
ans=0
for i in range(1,N+1):
    if oddDigit(i):
        ans+=1
print(ans)


Measured memory_bytes: 5412
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,m,a;
    cin>>n>>m;
    for(int i=0; i<m; i++)
    {
        cin>>a;
        n=n-a;
    }
    if(0>n)
    {
        cout<<"-1"<<endl;
        return 0;
    }
    else
    {
        cout<<n<<endl;
        return 0;
    }
}


Measured memory_bytes: 3492
#include <iostream>

using namespace std;

int main()
{

int a,b,x;cin>>a>>b>>x;
if(a>x){
        cout<<"NO";
}

      else  if (a+b<x){
    cout<<"NO";
        }


else {
        (a+b>=x);
        cout<<"YES";
    }
return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int N, K;
    cin >> N >> K;

    int c = 0;

    if (N < K) {
        cout << 1 << endl;
    } else {
        while (true) {
            N /= K;
            c++;
            if (N < K) break;
        }

        cout << c + 1 << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <iomanip>


using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef long double ld;

typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;

typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;

#define rep(i, a, b) for (int i=a; i<(b); i++)
#define rp(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define rpd(i,a) for (int i = (a)-1; i >= 0; i--)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define shandom_ruffle random_shuffle

const int MOD = 1000000007;
const ll INF = 1e18;
const int MX = 100001; //check the limits, dummy


int main() {
    ios_base::sync_with_stdio(0); cin.tie(0);
    cout << std::setprecision(9);
    cout << std::fixed;

    ll n;
    cin >> n;
    ll a[3][n];
    rp(i,3) rp(j,n) cin >> a[i][j];
    sort(a[0],a[0]+n);
    sort(a[1],a[1]+n);
    sort(a[2],a[2]+n);
    ll d[3][n];
    rp(i,3){
      ll curCursor = 0;
      rp(j,n){
        if(i == 0) d[i][j] = 1;
        else {
          ll sum;
          if(j == 0) sum = 0;
          else sum = d[i][j-1];
          while(curCursor < n && a[i-1][curCursor] < a[i][j]){
            sum += d[i-1][curCursor];
            curCursor++;
          }
          d[i][j] = sum;
        }
    }

    }
    ll ans = 0;
    rp(i,n) {
      ans+=d[2][i];
      // cout << d[1][i]<<endl;
    }
    cout << ans << endl;

    return 0;
}

// read the question correctly (ll vs int)
// template by super1 derived from bqi343


Measured memory_bytes: 4992
#include<stdio.h>

int main()
{
  
  int i,j,k,l,v,N;
  int A[100];

  scanf("%d",&N);
  
  for(i=0;i<N;i++) scanf("%d",&A[i]);
  
  for(i=0;i<N;i++){
    printf("%d",A[i]);
    if(i != N-1)printf(" ");  
  }
  
  
  printf("\n");
  
  for(i=1;i<N;i++){
    v = A[i];
    j = i-1;
    
    while(j >=0 && A[j] > v){
      A[j+1] = A[j];
      j--;
      A[j+1] = v;
    }   

    for(k=0;k<N;k++){
      printf("%d",A[k]);
    if(k != N-1) printf(" ");   
    }  
    
    
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 604
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using std::cin;
using std::cout;
using std::endl;

using std::string;
using std::pair;

using std::vector;
using std::sort;

int main(){
    string s;
    cin >> s;
    int ans=s.size();
    int len=s.size();
    for(int i=0;i<s.size()-1;i++){
        if(s[i]==s[i+1]){
            continue;
        }
        ans=std::min(ans,std::max(i+1,len-i-1));
    }
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 512
d=int(input())
c=list(map(int, input().split()))
s=[list(map(int, input().split())) for _ in range(d)]
t=[0]*26
ans=0
for i in range(1,d+1):
  tmp=int(input())
  t[tmp-1]=i
  ans+=s[i-1][tmp-1]
  for j in range(26):
    ans-=c[j]*(i-t[j])
  print(ans)

Measured memory_bytes: 69916
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <unordered_map>

int main()
{
  int N;
  std::cin >> N;

  auto result = true;
  std::unordered_map<int, int> um;
  for (auto i=0; i<N; ++i)
  {
    int a;
    std::cin >> a;
    auto p1 = um.emplace(a, a);
    if(!p1.second)
    {
      result = false;
      break;
    }
  }


  if (result)
    std::cout << "YES";
  else
    std::cout << "NO";
}


Measured memory_bytes: 8520
import javax.print.DocFlavor;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigDecimal;
import java.math.BigInteger;
import java.nio.charset.StandardCharsets;
import java.util.*;
import java.util.function.BiConsumer;

public class Main {

    //グローバル変数を定義

    public static void main(String[] args) throws IOException {
        new Main().run();
    }

    void run() {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int x = c-a;
        int y = d-b;

        System.out.println(String.format("%s %s %s %s", c-y, d+x, a-y, b+x));
    }
}


Measured memory_bytes: 21716
#include<string>
#include<iostream>
using namespace std;
void print(string& str, int a,int b){
    for(int i=a;i<=b;i++){
        cout<<str[i];
    }
    cout<<endl;
}

void replace(string& str,int a,int b,string& p){
    int count=0;
    for(int i=a;i<=b;i++){
        str[i]=p[count];
        count++;
    }
}

void reverse(string& str,int a,int b){
    string tmp;
    for(int i=a;i<=b;i++){
        tmp+=str[i];
    }
    int count=b-a;
    for(int i=a;i<=b;i++){
        str[i]=tmp[count];
        count--;
    }
    
}

int main(){
    string str,p,order;
    int q,a,b;
    cin>>str;
    cin>>q;
    for(int i=0;i<q;i++){
        cin>>order>>a>>b;
        if(order=="print"){
            print(str,a,b);
        }else if(order=="replace"){
            cin>>p;
            replace(str,a,b,p);
        }else if(order=="reverse"){
            reverse(str,a,b);
        }
    }
}


Measured memory_bytes: 3156
N = int(input())
a = [int(i) for i in input().split()]
count = 0

while([i % 2 for i in a].count(0) == N and [i / 2 for i in a].count(0) == 0):
    a = [i / 2 for i in a]
    count += 1

print(count)

Measured memory_bytes: 3060
mod reader {
    use std::fmt::Debug;
    use std::str::FromStr;
    use std::collections::VecDeque;
    use std::io::{self, Read};

    fn _read_line() -> String {
        let mut buf = String::new();
        io::stdin().read_to_string(&mut buf);
        buf
    }

    fn _read_vec_deque_string() -> VecDeque<String> {
        _read_line().split_whitespace().map(|s| s.to_string()).collect()
    }

    pub struct Reader {
        buf : VecDeque<String>
    }

    impl Reader {
        pub fn new() -> Reader {
            Reader {buf : VecDeque::new()}
        }

        fn update_buf(&mut self) {
            if self.buf.is_empty() {
                self.buf = _read_vec_deque_string();
            }
        }

        pub fn next<T>(&mut self) -> T where T: FromStr, T::Err: Debug {
            self.update_buf();
            self.buf.pop_front().unwrap().parse::<T>().unwrap()
        }
    }
}


fn main() {
    let mut reader = reader::Reader::new();

    let x : i32 = reader.next();
    let a : i32 = reader.next();
    let b : i32 = reader.next();
    // println!("{} {} {}", x, a, b);
    println!("{}", if a >= b {
        "delicious"
    } else if a + x >= b {
        "safe"
    } else {
        "dangerous"
    });
}


Measured memory_bytes: 4352
#include <iostream>
 
using namespace std;
 
int main(){
    int a;
    int b;
    int c;
    int k;
    cin >> a >> b >> c >> k;
    int result = 0;
    if(k < a){
        result = k;
    }
    else if(a <= k && b >= k){
        result = a;
    }
    else{
        result = a - (k - a - b);
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 3652
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    String s = null;
    if(a < b) {
      s = String.valueOf(a);
      for(int i= 1; i<b;i++){
        s += String.valueOf(a);
      }
    }
    else {
      s = String.valueOf(b);
      for(int i= 1; i<a;i++){
        s += String.valueOf(b);
      }
    }
    System.out.println(s);
  }
}


Measured memory_bytes: 21844
#include<iostream>
#include<algorithm>
#include<vector>
#include<stack>
#include<map>
#include<set>
#include<queue>
#include<cstdio>
#include<climits>
#include<cmath>
#include<cstring>
#include<string>
#include<sstream>
#include<numeric>
#include<cassert>

#define f first
#define s second
#define mp make_pair

#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define rep(i,s,n) for(int i=(s); i<(int)(n); i++)
#define FOR(i,c) for(__typeof((c).begin()) i=(c).begin(); i!=(c).end(); i++)
#define ALL(c) (c).begin(), (c).end()
#define IN(x,s,g) ((x) >= (s) && (x) < (g))
#define ISIN(x,y,w,h) (IN((x),0,(w)) && IN((y),0,(h)))
#define print(x) printf("%d\n",x)

using namespace std;

typedef unsigned int uint;
typedef long long ll;

const int _dx[] = {0,1,0,-1};
const int _dy[] = {-1,0,1,0};

int getInt(){
  int ret = 0,c;
  c = getchar();
  while(!isdigit(c)) c = getchar();
  while(isdigit(c)){
    ret *= 10;
    ret += c - '0';
    c = getchar();
  }
  return ret;
}

int Time[100];// = {  0,  5, 10, 15, 20, 25, 30, 35, 40, 45};
int peop[100];// = {  2,  5,  2,  2,  2,  2,  5,  2,  2,  2};
int eats[100];// = { 19, 39, 25, 36, 22, 42, 19, 39, 25, 36};
int star[100];
int tabl[17];
int ans[100];

int main(){
  int next = 0;
  REP(i,100){
    Time[i] = 5 * i;
    peop[i] = (i%5 == 1 ? 5 : 2);
    eats[i] = 17*(i%2) + 3*(i%3) + 19;
  }

  REP(i,17) tabl[i] = -1;
  for(int i=0; ; i++){
    REP(j,17) if(tabl[j] != -1){
      int t = tabl[j];
      if(star[t] + eats[t] == i){
        tabl[j] = -1;
      }
    }

  loop:
    if(next == 100) goto end;
    if(Time[next] <= i){
      int cnt = 0;
      int st  = -1;
      REP(j,17){
        if(tabl[j] == -1){
          if(cnt == 0) st = j;
          cnt++;
          if(cnt == peop[next])
            break;
        }else cnt = 0;
      }
      if(cnt == peop[next]){
        ans[next] = i - Time[next];
        star[next] = i;
        REP(j,peop[next])
          tabl[st + j] = next;
        next++;
        goto loop;
      }
    }

    /*
    printf("%d: ",i);
    REP(j,17){printf("%3d ",tabl[j]);} puts("");
    getchar();
    */
  }

 end:
  int n;
  while(~scanf("%d",&n))
    print(ans[n]);

  return 0;
}

Measured memory_bytes: 0
import java.awt.geom.Point2D;
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n;
		Point2D.Double a, b, c, d;
		double s1, s2;

		n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			a = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			b = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			c = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			d = new Point2D.Double(sc.nextDouble(), sc.nextDouble());
			if (a.x == b.x) {
				s1 = Double.POSITIVE_INFINITY;
			} else {
				s1 = (b.y - a.y) / (b.x - a.x);
			}
			if (c.x == d.x) {
				s2 = Double.POSITIVE_INFINITY;
			} else {
				s2 = (c.y - d.y) / (c.x - d.x);
			}
			if (s1 == s2) {
				System.out.println("YES");
			} else {
				System.out.println("NO");
			}
		}
	}
}

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

using namespace std;

typedef long long ll;

const ll MOD = 924844033;
ll fac[2100];
ll res;
int n, k;

vector<ll> prod(vector<ll> a, vector<ll> b) {
    int i,j;
    vector<ll> c(n+1,0);
    for (i=0;i<=n;i++) {
        for (j=0;j<=i;j++) c[i] += (a[j]*b[i-j])%MOD;
        c[i] %= MOD;
    }
    return c;
}

vector<ll> base;
vector<ll> power(vector<ll> a, int p) {
    if (p==0) return base;
    vector<ll> tmp = power(a,p/2);
    if (p&1) return prod(prod(tmp,tmp),a);
    return prod(tmp,tmp);
}

ll dyn[4200][2100];

vector<ll> calc(int p) {
    int i, j;
    if (p==0) return base;
    memset(dyn,0,sizeof(dyn));
    dyn[0][0] = dyn[0][1] = dyn[1][0] = 1;
    dyn[1][1] = 2;
    for (i=2;i<p;i++) {
        dyn[i][0] = 1;
        for (j=1;j<=i/2+1;j++) {
            dyn[i][j] = (dyn[i-1][j]+dyn[i-2][j-1])%MOD;
        }
    }
    vector<ll> ad(n+1,0);
    for (i=0;i<=n;i++) ad[i] = dyn[p-1][i];
    return ad;
}

int main() {
    int i;

    fac[0] = 1;
    for (i=1;i<=2010;i++) fac[i] = (fac[i-1]*i)%MOD;
    scanf("%d%d",&n,&k);
    base.assign(n+1,0);
    base[0] = 1;
    int s = 1, p, q, a, b;
    p = 2*(n-(n-1)/k*k); q = 2*min(k,n-k)-p;
    a = (n-1)/k; b = a-1;
    vector<ll> fd = prod(power(calc(a),p),power(calc(b),q));
    for (i=0;i<=n;i++) {
        res += (((s*fac[n-i])%MOD)*fd[i])%MOD;
        s = -s;
        res %= MOD;
    }
    res += MOD;
    res %= MOD;
    printf("%lld\n",res);


    return 0;
}


Measured memory_bytes: 69448
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }
/*考察
状態遷移を考えろクソ悔しい。解けませんでした
Aliceの立場として
自分の手番がきて今の状態から必勝の盤面に遷移できるなら
今の状態もAlice必勝。だから小さい状態から決まる

今回の問題だと(x,y)の状態から(x-2*i,y+i)or(x+i,y-2*i)の状態へ遷移
このときに勝てるマスから負けるマスに遷移できるなら勝てる
相手に手番渡してその状態で相手が負けるなら自分は勝てる

なんか日本語自身なくなってきたな
 */

int main(){
    ll x,y;cin>>x>>y;
    if(abs(x-y)<=1) cout<<"Brown"<<endl;
    else cout<<"Alice"<<endl;
    
    return 0;   
}

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

int main() {
 string s,t,u;
 cin>>s>>t>>u;
 if(s.at(s.size()-1)==t.at(0)&&t.at(t.size()-1)==u.at(0)){
   cout<<"YES"<<endl;
 }
 else{
   cout<<"NO"<<endl;
 }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define pb push_back
#define mp make_pair
#define sz(a) ll(a.size())
#define trace(c,x) for(auto &x:c)
#define F first
#define S second		
ll mod = 1e9 + 7;   //change acc to question

ll fastexpo(ll x,ll y)
{
	ll a=1;
	while(y>0)
	{
		if(y&1)a = (a*x)%mod;
		y/=2;
		x=(x*x)%mod;
	}	
	return a;
}

long double memo[3003][3003];
long double p[3003];

long double dp(int i,int rem)
{
	if(rem<0)
		return 0;
	if(rem>(i+1))
		return 0.0;
	if(i==0)
	{
		if(rem==0)
			return 1.0-p[0];
		else
			return p[0];
	}	
	
	if(memo[i][rem]!=-1.0)
		return memo[i][rem];

	memo[i][rem] = p[i]*dp(i-1,rem-1) + (1.0 - p[i])*dp(i-1,rem);
	return memo[i][rem];
}


int main(){

ios::sync_with_stdio(false);

int n;
cin>>n;

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

for(int i=0;i<3003;i++)
	for(int j=0;j<3003;j++)
		memo[i][j] = -1.0;

long double ans = 0.0;
for(int i=n/2+1;i<=n;i++)
{
	memo[n-1][i] = dp(n-1,i);
	// cout<<i<<" "<<memo[n-1][i]<<endl;`
	ans += memo[n-1][i];
}	
cout<<fixed<<setprecision(10)<<ans<<endl;
// printf("%0.9lf\n",ans);
return 0;

}	

Measured memory_bytes: 141440
N,K = map(int,input().split())
H = []
[H.append(int(input())) for _ in range(N)]
H.sort()
ans = 10000000000
for i in range(N-K+1):
    if(ans>(H[i+K-1]-H[i])):
        ans = H[i+K-1]-H[i]
print(ans)


Measured memory_bytes: 7840
#include <bits/stdc++.h>
using namespace std;
void debug() {cout<<endl;}
template<typename T,typename... Args>
void debug(T x,Args... args) {cout<<x<<" ";debug(args...);}
#define forn(i,a,b) for(int i=a;i<b;++i)
#define SZ(x) int(x.size())
#define pb push_back
#define F first
#define S second
#define endl "\n"
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    ios::sync_with_stdio(0); cin.tie(0);
    int a, b;
    string s;
    cin >> a >> b >> s;
    
    bool ok = true;
    
    if (SZ(s) != a+b+1) {
        cout << "No\n";
        return 0;
    }
    
    forn(i, 0, a) {
        ok &= isdigit(s[i]);
    }
    ok &= s[a] == '-';
    forn(i, a+1, SZ(s)) {
        ok &= isdigit(s[i]);
    }
    
    if (ok) cout << "Yes\n";
    else cout << "No\n";
}


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

#define ll long long
#define rep(A,B,C) for(A=B;A<C;++A)
#define pii pair<int,int>
#define pll pair<ll,ll>

#define fi first
#define se second
#define all(A) A.begin(),A.end()

using namespace std;

/////////////////////////////////////////////////////

ll N;
char S[40];

ll i, j, k;

int main(){
    scanf("%s", S);
    rep(i,0,3){
        if(S[i]=='S'){
            j = 0;
        }else{
            ++j;
            k = max(k, j);
        }
    }
    printf("%lld\n", k);

    return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
#define int long long
 int $(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }

signed main(){
  int a,d,c,e;
  cin>>a;
  vector<int> b(a);
  for(int i=0;i<a;i++)
    cin>>b.at(i);
  sort(b.begin(),b.end());
  for(int i=0;i<a-1;i++){
    c=b.at(i);
    d=b.at(i+1);
    e=d%c;
    if(e==0)
      b.at(i+1)=c;
    else{
      b.at(i+1)=c;
      b.at(i)=e;
      i--;
    }
  }
  cout<<c<<endl;
}


Measured memory_bytes: 1024
/*The woods are lovely, dark and deep,
But I have promises to keep,
And miles to go before I sleep,
And miles to go before I sleep.*/

//PRABHJOT SINGH A.K.A. PRABHI
//~~~~~conquizztador~~~~~


#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define fi first
#define se second
#define MOD 1000000007
const int maxn= 100010;
vector<int> Z(string &s)
{
	int n=(int)s.length();
	vector<int> z(n);
	for(int i=1,l=0,r=0;i<n;++i)
	{
		if(i<=r)
			z[i]=min(r-i+1,z[i-l]);
		while(i+z[i]<n&&s[z[i]]==s[i+z[i]])
			++z[i];
		if(i+z[i]-1>r)
			l=i,r=i+z[i]-1;
	}
	return z;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n=0,res=0;string s;
    cin>>n;
    cin>>s;
    for(int i=0;i<n;++i)
    {
    	string str=s.substr(i);
    	vector<int> aux=Z(str);
    	for(int j=0;j<(int)aux.size();++j)
    	{
    		int len=min(aux[j],j);
    		res=max(res,len);
    	}
    }
    cout<<res<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int n, i, j;
  scanf("%d", &n);
  int adj[n+1][n+1];
  for(i=0;i<n+1;i++){
    for(j=0;j<n+1;j++){
      adj[i][j]=0;
    }
  }
  int m, l;
  for(i=1;i<n+1;i++){
    scanf("%d%d", &m, &l);
    int x[l];
    for(j=0;j<l;j++){
      scanf("%d", &x[j]);
      adj[m][x[j]]=1;
    }
  }

  for(i=1;i<n+1;i++){
    for(j=1;j<n;j++){
      printf("%d ", adj[i][j]);
    }
    printf("%d\n", adj[i][n]);
  }
  return 0;
}


Measured memory_bytes: 2060
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll gcd(ll a, ll b){if(!b)return a;return gcd(b, a % b);}
ll power(ll x,ll y,ll p){ll res=1;x%=p;while(y>0){if(y&1)res=(res*x)%p;y=y>>1;x=(x*x)%p;}return res;}
int main() {
/*    #ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
//ll  t;cin>>t;while(t--)
{
  ll a,b,c,x=0;
  cin>>a>>b;
  if(a%3==0||b%3==0||(a+b)%3==0)
  {
    cout<<"Possible"<<endl;
  }
  else
  {
    cout<<"Impossible"<<endl;
  }
  

}
return 0;
}


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

int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<int> B(M);
  for (int i = 0; i < M; ++i) {
    cin >> B.at(i);
  }
  vector<vector<int>> A(N, vector<int>(M));
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < M; ++j) {
      cin >> A.at(i).at(j);
    }
  }

  int ans = 0;
  for (int i = 0; i < N; ++i) {
    int sum = C;
    for (int j = 0; j < M; ++j) {
      sum += A.at(i).at(j) * B.at(j);
    }
    if (sum > 0) ans++;
  }

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


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    int h,w;
    int i,j;
    while(1){
        scanf("%d %d", &h,&w);
        
        if (h == 0 && w == 0){
            break;
        }
        
        
        for (i=0;i<h;i++){
            for (j=0;j<w;j++){
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    
    return 0;
}
        
    
    

Measured memory_bytes: 572
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
typedef long long ll;
#define MODSIZE 1000000007
priority_queue<int, vector<int>, greater<int> > PQ; // 昇順PQ
// priority_queue<int> PQ;

int main(){
  int a,b,c;

  scanf("%d %d %d", &a, &b, &c);

  if(a <= c && c <= b) printf("Yes\n");

  else printf("No\n");
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
	int n,r;
	int s = 0;
	scanf("%d",&n);
	int  z = n;
	while (n > 0){
		r = n % 10;
		n = n / 10;
		s = s + r;	
	}

	if(z % s == 0)
		printf("Yes");
	else
		printf("No");
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <inttypes.h>

//int compare_int(const void *a, const void *b){//qsort 整数比較<
//	return *(int*)a - *(int*)b;
//}
//int compare_int2(const void *a, const void *b){//qsort 整数比較>
//	return *(int*)b - *(int*)a;
//}
//
int main(void){
	int n;
	int l[101]={0};
	int i;
	int j,k;
	int ans=0;

	scanf("%d",&n);
	for(i=0;i<n;i++){
		scanf("%d",&l[i]);
	}
	for(i=0;i<n;i++){
		for(j=i+1;j<n;j++){
			for(k=j+1;k<n;k++){
				if(l[i]!=l[j]&&l[j]!=l[k]&&l[k]!=l[i]){
					if(l[i]+l[j]>l[k]){
						if(l[k]+l[j]>l[i]){
							if(l[i]+l[k]>l[j]){
								ans++;
							}
						}
					}
				}
			}
		}
	}

	printf("%d",ans);

	return 0;
}


Measured memory_bytes: 1736
x, y = map(int, input().split())
ans = abs(abs(x)-abs(y))
if x*y > 0:
    if x <= y:
        print(ans)
    else:
        print(ans+2)
elif x*y < 0:
    print(ans+1)
else:
    if x <= y:
        print(ans)
    else:
        print(ans+1)
        

Measured memory_bytes: 9164
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include<limits>
#include<iomanip>
#include<cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;

const long double pi = 3.141592653589793;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repi(i, j, n) for(int i = j;i < n;i++)
#define pb push_back
#define mp make_pair
#define mod 998244353
#define F first
#define S second

string s;int k, n;

/*
  --- 0 111111  ----------
      i'     i     (j)

      i(3) j(3) k(5)

      O(N ** 5) solution: accepted (confused now)
*/

unordered_map<ll, int> dp;
ll state_to_num(int i, int j, int k) {
  return 1LL*i*1E10 + 1LL*j*1E6 + k;
}

int combinations(int i, int j, int k) {
  if(i < 0) return 1;
  if(dp.count(state_to_num(i, j, k)) == 1) {
    return dp[state_to_num(i, j, k)];
  }

  int id = i;
  while(id >= 0 && s[id] == '1') id--;
  if(id == -1) return 1;
  int ans = 0;
  for(int ps = 0;ps <= (i-id+j);ps++) {
    if(ps <= j) {
      ans += combinations(id-1, ps, k);
    } else if(ps-j <= k) {
      ans += combinations(id-1, ps, k-ps+j);
    }
    ans %= mod;
  }
  return dp[state_to_num(i, j, k)] = ans;
}

int main() {

// freopen("input.in","r",stdin);
// freopen("output.out","w",stdout);

 cin>>s>>k;
 n = s.size();
 k = min(k, n*n);

 cout << combinations(n-1, 0, k) << endl;
 if(dp.size() > 1000000) {
   assert(false);
 }

 return 0;
}


Measured memory_bytes: 31752