akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.util.*;
import java.text.*;
import java.math.*;
import java.util.regex.*;

public class Main {

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int N = in.nextInt();
        int[] d = new int[N];
        for(int i =0; i< N; i++){
            d[i] = in.nextInt();
        }
        Arrays.sort(d);
        int ans = 1;
        int current = d[0];
        for(int i = 0; i < N; i++){
            if(d[i] > current){
                ans++;
                current = d[i];
            }
        }
        System.out.println(ans);
        in.close();
    }
}


Measured memory_bytes: 21844
#include <stdio.h>

int main(){
    int K, S, i, j, k, cnt=0;

    scanf("%d %d", &K, &S);

    for(i=0; i<=K; i++){
        for(j=0; j<=K; j++){
            k = S-i-j;
            if(0<=k && k <= K)
                cnt++;
        }
    }

    printf("%d\n", cnt);
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define dprint(Exp,...) if(Exp){fprintf(stderr, __VA_ARGS__);}
#define printe(...) fprintf(stderr, __VA_ARGS__);
#define PrtExp(_Exp)  cerr<< #_Exp <<" = "<< (_Exp)
#define PrtExpN(_Exp)  cerr<< #_Exp <<" = "<< (_Exp) <<"\n"

#define SINT(n) scanf("%d",&n)
#define SINT2(n,m) scanf("%d %d",&n,&m)
#define SINT3(n,m,o) scanf("%d %d %d",&n,&m,&o)
#define SINT4(n,m,o,p) scanf("%d %d %d %d",&n,&m,&o,&p)
#define SINT5(n,m,o,p,q) scanf("%d %d %d %d %d",&n,&m,&o,&p,&q)
#define SLL(n) scanf("%lld",&n)
#define SLL2(n,m) scanf("%lld %lld",&n,&m)
#define SLL3(n,m,o) scanf("%lld %lld %lld",&n,&m,&o)
#define SST(s) scanf("%s",s)
#define SCH(c) scanf("%c",&c)

#define GC() getchar()

#define PINT(n) printf("%d",(int)(n))
#define PINT2(n,m) printf("%d %d",(int)(n),(int)(m))
#define PINT3(n,m,l) printf("%d %d %d",(int)(n),(int)(m),(int)(l))
#define PLL(n) printf("%lld",(long long)(n))
#define PST(s) printf("%s",(s))
#define PCH(s) printf("%c",(s))

#define PINTN(n) printf("%d\n",(int)(n))
#define PINT2N(n,m) printf("%d %d\n",(int)(n),(int)(m))
#define PINT3N(n,m,l) printf("%d %d %d\n",(int)(n),(int)(m),(int)(l))
#define PLLN(n) printf("%lld\n",(long long)(n))
#define PSTN(s) printf("%s\n",(s))
#define PCHN(s) printf("%c\n",(s))

#define PSP() printf(" ")
#define PN() printf("\n")

#define PC(c) putchar(c)
#define CSP (' ')
#define SN ("\n")

#define rep(i,a) for(int i=0;i<a;i++)
#define reP(i,a) for(int i=0;i<=a;i++)
#define Rep(i,a) for(int i=a-1;i>=0;i--)
#define ReP(i,a) for(int i=a;i>=0;i--)

#define rEp(i,a) for(i=0;i<a;i++)
#define rEP(i,a) for(i=0;i<=a;i++)
#define REp(i,a) for(i=a-1;i>=0;i--)
#define REP(i,a) for(i=a;i>=0;i--)

#define repft(i,a,b) for(int i=a;i<b;i++)
#define repfT(i,a,b) for(int i=a;i<=b;i++)
#define Repft(i,a,b) for(int i=a-1;i>=b;i--)
#define RepfT(i,a,b) for(int i=a;i>=b;i--)

#define foreach(a,it) for(auto it = a.begin(); it != a.end(); ++it)

#define FILL(a,v) fill(begin(a),end(a), v)
#define FILL0(a) memset(a,0,sizeof(a))
#define FILL1(a) memset(a,-1,sizeof(a))

typedef long long ll;

typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll>   Pll;


const int INF = 0x2aaaaaaa; // 715,827,882
const ll INFLL = 0x1f1f1f1f1f1f1f1fLL;//2,242,545,357,980,376,863

template <class A, class B> inline ostream& operator<<(ostream& st, const pair<A, B>& P) { return st << "(" << P.first << "," << P.second << ")"; };
template <class A, class B> inline pair<A, B> operator+(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first + Q.first, P.second + Q.second); };
template <class A, class B> inline pair<A, B> operator-(const pair<A, B>& P, const pair<A, B>& Q) { return pair<A, B>(P.first - Q.first, P.second - Q.second); };

#define fs  first
#define sc  second

/*
int main() {
	int a, b, c, d, e, d;
	string s, t, u;

	cin >> a >> b >>s;
	bool f = true;

	if (s[a + 1] != '-')f = false;



	//for (;;) getchar();

	return 0;
}

*/
int main() {
	int a, b, c, d, e;
	string s, t, u;

	cin >> a;
	cout << 48 - a << endl;


	//for (;;) getchar();

	return 0;
}

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

#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define bg begin()
#define ed end()
#define all(x) x.bg, x.ed
#ifdef LOCAL
#define dmp(x) cerr << __LINE__ << " " << #x << " " << x << endl
#else
#define dmp(x) void(0)
#endif

template <class t, class u>
void chmax(t &a, u b)
{
  if (a < b)
    a = b;
}
template <class t, class u>
void chmin(t &a, u b)
{
  if (b < a)
    a = b;
}
const int mod = 1000000007;
struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
      fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
      ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
      return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vc<vc<t>>;

using vi = vc<int>;
int gcd(int a, int b)
{
  if (b == 0)
    return a;
  return gcd(b, a % b);
}
int lcm(int a, int b)
{
  return (a * b) / gcd(a, b);
}
int fact(int n)
{
  if (n == 0)
    return 1;
  return n * fact(n - 1);
}

int main()
{
  int n, m;
  cin >> n >> m;
  if(n+m<24){
  cout<<n+m<<endl;
  }else{
  cout<<n+m-24<<endl;
  }
  
}

Measured memory_bytes: 256
//NEVER LOSE HOPE 
#pragma GCC optimize("Ofast")
#pragma GCC target("avx,avx2,fma")
#pragma GCC optimization ("unroll-loops")
#define fastio ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#include <bits/stdc++.h>
#define int long long int
#define vi vector<int>
#define pi pair<int,int>
#define si set<int>
#define mi map<int,int>
#define ff first
#define ss second
#define pb push_back
#define all(v) v.begin(),v.end()
#define gi greater<int>()
#define mp make_pair
#define endl "\n"

//to count no of digits //floor(log10(n) + 1)

#define lb lower_bound //a,a+n,4 -a==index of 4  // returns pointer to the "first position of num" if number is present in the container. Returns pointer to the "position of next higher number greater than num" if num is not present.   
#define ub upper_bound // returns pointer to the "first position of the next higher number than last occurence of num" if num is present in the container. Returns pointer to the position of next higher number than num if container does not contain occurence of num.
#define REP(i,n) for(int i=0;i<n;i++)
#define REPE(i,n) for(int i=n-1;i>=0;i--)
#define REPA(i,a,n) for(int i=a;i<=n;i++)
 
//next_permutation(s.begin(),s.end())
//*max_element(a,a+n)
#define mod 1000000007
int N=INT_MAX;
using namespace std;

bool isPrime(int n)
{if(n==1)return false;
for(int i=2;i*i<=n;i++)
{if(n%i==0)return false;}
return true;
} 

int gcd(int a,int b)
{
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return a/gcd(a,b)*b;
 
}

  
 //JAI SHREE RAM  //JAI SHREE RAM //JAI SHREE RAM  //JAI SHREE RAM
///////////////// MAIN FUNCTION ////////////////////////

 void CSK()
 {
  int n;
  cin>>n;
  int a[n];
  REP(i,n){
    cin>>a[i];
  }
  int c=0;
  REP(i,n-1){
    if(a[i]>a[i+1]){
      int x=a[i]-a[i+1];
      a[i+1]=a[i+1]+x;
      c+=x;
    }

  }
  cout<<c<<endl;
 
    

  





   



    




  




    

















}
///////////////////////// END //////////////////////////////////////  
  
 

 
 
 
int32_t main()
{
    #ifndef ONLINE_JUDGE
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    #endif 
    fastio;
    cout<<fixed;
    cout.precision(10);
    int __TESTCASES=1;
    //cin>>__TESTCASES;
    while(__TESTCASES--){
    CSK();  
}
 
}

Measured memory_bytes: 5148
#include <iostream>
#include <bits/stdc++.h>
#include <set>
#define fastio cin.tie(NULL); cout.tie(NULL); ios::sync_with_stdio(false)
#define vi vector<int>
#define vll vector<long long>
#define pii pair<int, int>
#define vii vector<pair<int, int> >
#define si stack<int>
#define pb push_back
#define mp make_pair
#define ALL(T) (T).begin(), (T).end()
#define MODU 1000000007
#define ABS(x) (x<0)?(-x):(x)
typedef long long ll;
using namespace std;

ll intmax = (1LL<<32)-1;
ll llmax = (1LL<<60)-1;


void solve(){
	
}

void DFSVisit(int u, vector<int> g[], vector<bool> &visited){ 
    visited[u] = true;
    for(int i=0; i<g[u].size(); i++){
        if(!visited[g[u][i]]){
            DFSVisit(g[u][i], g, visited); 
        }
    }
} 
  
void DFS(vector<int> adj[], int V){
    vector<bool> visited(V, false); 
    for(int u=0; u<V; u++) 
        if(!visited[u]) 
            DFSVisit(u, adj, visited);
}

bool chkdiv(ll val1, ll val){
    if(val == 0)
        return false;
    if(val1 % val)
        return false;
    else
        return true;

}

int main(){
	fastio;
    int n,x;
    cin >> n >> x;
    vi l(n);
    vi d;
    d.pb(0);
    int ans = 1;
    for(int i=0; i<n; i++){
        cin >> l[i];
        d.pb(d[i]+l[i]);
        if(d[i+1]<=x) ans++;
    }
    cout << ans;
}

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

int main() {
  string S;
  cin >> S;
  
  if(S.at(2) == S.at(3) && S.at(4) == S.at(5)){
    cout << "Yes" << endl;
   
  }
  
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define rep(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define debug(x) cout << #x << " = " << (x) << endl;
#define SORT(x) sort(rng(x))
#define RSORT(x) sort(rrng(x))
#define SUM(x) accumulate(rng(x),0)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

int main () {
  int n;
  cin >> n;
  vvi to(n), cost(n);
  rep(i,n-1) {
    int a, b ,w;
    cin >> a >> b >> w;
    a--, b--;
    to[a].pb(b); cost[a].pb(w);
    to[b].pb(a); cost[b].pb(w);
  }
  vi ans(n,-1);
  queue<int> q;
  ans[0] = 0;
  q.push(0);
  while (!q.empty()) {
    int v = q.front(); q.pop();
    rep(i,to[v].size()) {
      int u = to[v][i];
      int w = cost[v][i];
      if (ans[u] != -1) continue;
      ans[u] = (ans[v]+w)%2;
      q.push(u);
    }
  }
  rep(i,ans.size()) printf("%d\n", ans[i]);
  return 0;
}

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

int main() {
  ll N, i,j,A,B,C, count=0;
  
  cin >> N;
  
  for(A=1;A<=N;A++){
    for(B=1;B<=N/A;B++){
      C = N-A*B;
      if(C>0)count+=1;
    }
  }
  
  cout << count;
}

Measured memory_bytes: 3636
#include<stdio.h>

int main() {
	int n,m;
	scanf("%d%d",&n,&m);
	int a[n][m],b[m];
	int c[n];

	for(int i = 0;i < n;i++) {
		for(int j = 0;j < m;j++) {
			scanf("%d",&a[i][j]);
		}
	}
	for(int i = 0;i < m;i++) {
		scanf("%d",b + i);
	}
	for(int i = 0;i < n;i++) {
		c[i] = 0;
		for(int j = 0;j < m;j++) {
			c[i] += a[i][j] * b[j];
		}
	}

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



Measured memory_bytes: 2752
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

#define BEGIN(x) x.begin()
#define END(x) x.end()
#define ALL(x) BEGIN(x), END(x)
#define PAIR make_pair
#define VEC(type) vector<type >

#define FOR(i, A, B) for(auto i = (A);i != (B); i++)
#define FORD(i, A, B) for(auto i = (A);i != (B); i--)

#define READRANGE(begin, end) FOR(it, begin, end) cin >> *it
#define READVEC(V) READRANGE(BEGIN(V), END(V))

using namespace std;

typedef long long lint;

void io_init()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
};

int main(int argc, char **argv)
{
    io_init();

    // Actual program code starts here.
    int N;
    cin >> N;
    VEC(lint) A(N);
    READVEC(A);
    lint ret = 0;
    const lint MOD = 1000000007;
    FOR(_bit, 0, 60) {
        lint fac = 1LL << _bit;
        fac = fac % MOD;
        int ones = 0, zeros = 0;
        FOR(i, 0, N)
            if (A[i] & (1LL << _bit))
                ones++;
            else
                zeros++;

        lint fac2 = ones * 1LL * zeros % MOD;
        ret = (ret + (fac2 * fac) % MOD) % MOD;
    }

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


Measured memory_bytes: 2560
"use strict";
main(
  require("fs")
    .readFileSync("/dev/stdin", "UTF-8")
    .trim()
    .split("\n")
    .map(i => i.split(" "))
);

function main(input) {
  let state = {};
  for (let i = 0; i < input[0].length; i++) {
    state[input[0][i]] = parseInt(input[1][i]);
  }
  state[input[2]] -= 1;

  let result = "";
  Object.keys(state).map(k => (result += String(state[k]) + " "));

  console.log(result);
}


Measured memory_bytes: 7372
package main

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

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func Min(x ...int) int {
	min := x[0]
	for _, v := range x {
		if v < min {
			min = v
		}
	}
	return min
}

func main() {
	h := nextInt()
	n := nextInt()
	a := make([]int, n)
	b := make([]int, n)

	for i := 0; i < n; i++ {
		a[i] = nextInt()
		b[i] = nextInt()
	}

	dp := make([][]int, n)
	for i := 0; i < n; i++ {
		dp[i] = make([]int, h + 1)
	}

	for i := 0; i < n; i++ {
		for j := 1; j <= h; j++ {
			var x, y int
			if i == 0 {
				x = math.MaxInt64
			} else {
				x = dp[i - 1][j]
			}
			if j - a[i] >= 0 {
				y = dp[i][j - a[i]] + b[i]
			} else {
				y = b[i]
			}
			dp[i][j] = Min(x, y)
		}
	}

	fmt.Printf("%d", dp[n - 1][h])
}


Measured memory_bytes: 83456
import java.util.*;

public class Main {
    private static final int GAME = 3;
    private static final int MAX  = 200 + 1;

    public static void main(String[] args) {
        int[][] count = new int[MAX][GAME];

        try(Scanner scn = new Scanner(System.in)) {
            int n = scn.nextInt();

            int[][] nums = new int[n][GAME];
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < GAME; j++) {
                    int num = scn.nextInt();
                    nums[i][j] = num;
                    count[num][j]++;
                }
            }

            int[] scores = new int[n];
            for(int i = 0; i < n; i++) {
                for(int j = 0; j < GAME; j++) {
                    int num = nums[i][j];
                    if(count[num][j] < 2) {
                        scores[i] += num;
                    }
                }
            }

            for(int score : scores) {
                System.out.println(score);
            }
        }
    }
}

Measured memory_bytes: 28412
//include
//------------------------------------------
#include <bits/stdc++.h>
using namespace std;
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef long long ll;
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
// chmax chmin
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int main(void){

    int N;
    cin >> N;
    int A[N], x[N][N-1], y[N][N-1];
    REP(i,N){
        cin >> A[i];
        REP(j,A[i]){
            cin >> x[i][j] >> y[i][j];
            x[i][j]--;
        }
    }

    int max = 0;
    for(int i=0; i<(1<<N); i++){
        int n = 0;
        bool flag = true;
        vector<int> S(N,0);
        for (int j = 0; j < N; ++j) {
            if (i & (1<<j)) { // i が bit に入るかどうか
                S[j] = 1;
                n++;
            }
        }
        REP(k,N){
            if(S[k] == 0) continue;
            bool f = false;
            REP(j,A[k]){
                if(S[x[k][j]] != y[k][j]){f = true; flag = false; break;}
            }
            if(f) break;
        }
        if(flag) chmax(max, n);
    }

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

Measured memory_bytes: 256
a, b, c, d, e, f = map(int, input().split())
con, w, s = 0, 0, 0

for i in range(100*a, f+1, 100):
    b_max = i // (100*b)
    for j in range(0, b_max+1):
        if (i-j*b*100) % (100*a) == 0:
            break
    else:
        continue

    sugar = 0
    for k in range(0, i//100*e+1):
        d_max = k // d
        for l in range(0, d_max+1):
            if (k-d*l) % c == 0:
                if k > sugar and i + k <= f:
                    sugar = k

    if sugar / (i+sugar) * 100 >= con:
        con = sugar / (i+sugar) * 100
        w, s = i, sugar

print("{} {}".format(w+s, s))


Measured memory_bytes: 3064
#include <stdio.h>
#include <string>
#include <vector>
#include <algorithm>
#include <iostream>
#include <cmath>
using namespace std;

int a, b, ans;

int main() {
    scanf("%d %d", &a, &b);
    
    if ( b % a == 0 ) {
        ans = a + b;
    } else {
        ans = b - a;
    }
    
    printf("%d", ans);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    int n = 0;
    int x = 0;
    int ans = 0;
    string id;
    cin >> n;
    cin >> id;
    for (int i = 0; i < n; ++i) {
        if (id[i] == 'I'){
            x++;
        } else if (id[i] == 'D'){
            x--;
        }
        ans = max(x,ans);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#define ll long long
#define INF 1e+18
#define MOD 998244353
using namespace std;


int main(){
    int N;
    ll x;
    cin >> N >> x;
    ll a[N];
    for(int i=0; i<N; i++){
        cin >> a[i];
    }
    sort(a,a+N);
    int ans=0;
    
    for(int i=0; i<N; i++){
        if(i<N-1){
     
            if(x>=a[i]){
            ans++;
            x-=a[i];
     
            }else{
                break;
            }
        }else{
            if(x==a[i]){
                ans++;
            }
        }
        
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
import sys
 
def make_connected_group(G):
    C = [None]*len(G)
    group = 0
    for i,p in enumerate(C):
        if p != None: continue
        friends = [i]
        while len(friends) > 0:
            f = friends.pop()
            if C[f] == None:
                C[f] = group
                friends += G[f]
        group += 1
    return C
 
 
if __name__=='__main__':
    n,m = list(map(int,sys.stdin.readline().split()))
    G = [[] for _ in range(n)]
    for _ in range(m):
        s,t = list(map(int,input().split()))
        G[s].append(t)
        G[t].append(s)
    C = make_connected_group(G)
    q = int(input())
    for j,line in enumerate(sys.stdin):
        if not j < q: break
        s,t = list(map(int,line.split()))
        print('yes' if C[s] == C[t] else 'no')

Measured memory_bytes: 33476
s = input()
search="keyence"
idx=0
flg = False
ans="NO"
n = len(s)
if s[0:7] == search:
    print("YES")
elif (s[-7:] == search):
    print("YES")
else:
    for i in range(7):
        if s[0:i+1] == search[0:i+1]:
            #print(s[(-7+i+1):])
            #print(search[i+1:])
            if (s[(-7+i+1):] == search[i+1:]):
                ans = "YES"
                break
    print(ans)

Measured memory_bytes: 3064
N, A, B, C = list(map(int, input().split()))
l = [int(input().strip()) for i in range(N)]
INF = 10 ** 9


def dfs(pointer, a, b, c):
    if pointer == N:
        return abs(a - A) + abs(b - B) + abs(c - C) - 30 if min(min(a, b), c) > 0 else INF
    ret_0 = dfs(pointer + 1, a, b, c)
    ret_1 = dfs(pointer + 1, a + l[pointer], b, c) + 10
    ret_2 = dfs(pointer + 1, a, b + l[pointer], c) + 10
    ret_3 = dfs(pointer + 1, a, b, c + l[pointer]) + 10
    return min(ret_0, ret_1, ret_2, ret_3)


print(dfs(0, 0, 0, 0))


Measured memory_bytes: 44124
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <functional>
#include <queue>
#include <string>
#include <cstring>
#include <numeric>
#include <cstdlib>
#include <cmath>
#include <map>
#include <unordered_map>
#include <set>
using namespace std;

typedef long long ll;

#define INF 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define END cout << endl
#define MOD 1000000007
#define pb push_back
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { debug(itr); }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  int t = a - b;
  cout << max(0, c - t) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define SZ(x) ((int)(x).size())
#define ALL(x) (x).begin(),(x).end()
#ifdef _DEBUG_
  #define debug(...) printf(__VA_ARGS__)
#else
  #define debug(...) (void)0
#endif
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;

void go(int x, int N, char bound, string &res) {
  if (x == N) {
    puts(res.c_str());
    return;
  }
  res.push_back('_');
  for (char c = 'a'; c <= bound; c++) {
    res.back() = c;
    go(x + 1, N, max(bound, (char)(c + 1)), res);
  }
  res.pop_back();
}

int main() {
  int N;
  cin >> N;
  string res;
  go(0, N, 'a', res);
  return 0;
}


Measured memory_bytes: 1536
x = list(map(int, input().split()))
y = list(map(int, input().split()))
z = [[0, 1, 2, 3], [0, 2, 1, 1], [1, 0, 2, 1], [2, 0, 1, 0], [1, 2, 0, 0], [2, 1, 0, 1]]
for i in range(6):
    order = [0, 0, 0]
    for j in range(3):
        if x[j] == y[z[i][j]] and x[-j-1] == y[-z[i][j]-1]:
            if x[j] == x[-j-1]:
                order[j] = 2
        elif x[j] == y[-z[i][j]-1] and x[-j-1] == y[z[i][j]]:
            order[j] = 1
        else:
            break
    else:
        if 2 in order:
            print('Yes')
            break
        if z[i][3] in [0, 3] and not sum(order) % 2:
            print('Yes')
            break
        if z[i][3] == 1 and sum(order) % 2:
            print('Yes')
            break
else:
    print('No')

Measured memory_bytes: 7708
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
//const ll MOD = 924844033;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
const double EPS = 1e-5;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), outendl())
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	char c;
	cin >> c;
	cout << (char)(c+1) << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

	public void execute() {
		Scanner sc = new Scanner(System.in);
		final int N = sc.nextInt();
		sc.nextLine();
		int A[] = new int[N];
		int B[] = new int[N];
		int[] diff = new int[N];
		long totalJunbi = 0;
		long totalScore = 0;

		String[] a = sc.nextLine().split(" ");
		String[] b = sc.nextLine().split(" ");
		for (int i = 0; i < N; i++) {
			A[i] = Integer.parseInt(a[i]);
			B[i] = Integer.parseInt(b[i]);
			totalJunbi += A[i];
			totalScore += B[i];
			diff[i] =  A[i] - B[i];
		}

		if (totalJunbi < totalScore) {
			System.out.println(-1);
			sc.close();
			return;
		}

		Arrays.sort(diff);
		int m = -1;
		int p = diff.length;
		int cnt = 0;
		int minus = 0;
		int plus = 0;
		while (true) {
			if (minus == 0) {
				m++;
				if (diff[m] >= 0) {
					break;
				}
				minus = diff[m];
				cnt++;
			}
			if (plus == 0) {
				p--;
				plus = diff[p];
				cnt++;
			}
			if (minus + plus >= 0) {
				plus += minus;
				minus = 0;
			} else {
				minus += plus;
				plus = 0;
			}
		}
		System.out.println(cnt);

		sc.close();

	}

}


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

string S;

bool is_Palindrome(int left, int right) // [left, right]の間が回文か調べる 
{
    while(left < right) {
        if(S[left] != S[right]) return false;
        ++left, --right;
    }
    return true;
}

int main()
{
    cin >> S;
    int N = S.size();
    if(is_Palindrome(0,N-1) && is_Palindrome(0,(N-1)/2 - 1) && is_Palindrome((N+3)/2 - 1, N-1)) {
        cout << "Yes" << endl;
    }
    else cout << "No" << endl;
    return 0;
}

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

int main(){
  int n;
  string s;
  cin >> n >> s;
  int l=0, r=n-1;
  int ans = 0;
  while(1){
    while(l<n-1 && s[l] == 'R') ++l;
    while(r>=0 && s[r] == 'W') --r;
    if(l>=r) break;
    ++ans;
    s[l] = 'R';
    s[r] = 'W';
  }
  cout << ans << endl;
}

Measured memory_bytes: 3736
/*
    LIFE WOULD BE SO BEAUTIFUL IF BRUTE WORKED EVERYTIME
    */
    #include <bits/stdc++.h>
    #include <string.h>
    #define int long long
    #define MAX (int)1e5
    #define itn int
    #define inf 1e9
    #define mod 1000000007
    #define pb push_back
    #define all(x) x.begin(),x.end()
    #define mk make_pair
    #define sitr set<int> :: iterator
    #define mitr map<int,int> :: iterator
    #define pii pair<int,int>
    #define vii vector<pii>
    #define vi vector<int>
    #define sortall(x) sort(x.begin(),x.end());
    #define fori(i,n) for(int i=0;i<n;i++)
    #define test int t;cin>>t;while(t--)
    #define fast ios_base :: sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
    using namespace std;
    const int N = 5000007;
    int spf[N];
    void SPF()
    {
        spf[0] = 1;
        spf[1] = 1;
        for(int i=2;i<=(int)5e6;i++)
        {
            if(spf[i] == 0)
            {
                for(int j=i;j<=(int)5e6;j+=i)
                {
                    if(spf[j] == 0)
                        spf[j] = i;
                }
            }
        }
    }
    int n;
    vii a(MAX);
    bool alreadychanged(int n)
    {
        if(a[n].second != 0)
            return true;
        return false;
    }

    int toint(const string &s) {stringstream ss; ss << s; int x; ss >> x; return x;}

    int32_t main(){
        //fast;
        int n;
        cin>>n;

        vi v(n);
        for(itn i=0;i<n;i++)
            cin>>v[i];

        vi dp(n);
        dp[0] = 0;
        dp[1] = abs(v[0]-v[1]);
        for(int i=2;i<n;i++)
            dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]),dp[i-2]+abs(v[i]-v[i-2]));


        cout<<dp[n-1];

        return 0;
    }


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

using namespace std;

#define REP(i,n)	for(int i=0, i##_len=(n); i<i##_len; ++i)
#define REPS(i,s,n)	for(int i=(s), i##_len=(n); i<i##_len; ++i)

#define ALL(obj)	(obj).begin(),(obj).end()

typedef unsigned int 			uint;
typedef unsigned long long int	ull;
typedef long long int 			ll;

typedef pair<int,int>			P;
typedef vector<int>				V;
typedef vector<V>				VV;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define MAX 		100050

const ll LINF = (ll)1e18+7;		//
const int INF = 1e9+7;			//2,147,483,647 (Max int)
const int MOD = 1e9+7;
// テンプレ終了
//====================================================================//




//
int main(){
	int A,B;
	cin >>A>>B;
	if((ceil((double)abs(A-B)/2) == floor((double)abs(A-B)/2)))
		printf("%d\n",(abs(A-B)/2)+min(A,B));
	else
		cout << "IMPOSSIBLE" << endl;


	return 0;
}




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

int main() {
	int N,judge = 0,M=0;cin >> N;
	for(int i = 0 ; i < N ; i++){
		int x; cin >> x;
		judge += x;
		M = max(M,x);
	}
	if(judge > M*2){
		cout << "Yes" << endl;
	}else{
		cout << "No" << endl;
	}
}

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

using namespace std;

typedef long long       ll;

#define all(x)            (x).begin(),(x).end()
#define Sort(x)            sort(all(x))
#define A               first
#define B               second
#define sep             ' '
#define fast_io         ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define set_random     mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count())

const int MAX1 = 1e6+10,
         Md = 1e9+7,
		 Base = 257;

ll a, b;
string s;

int main(){
    fast_io;
    cin >> a >> b;
    cout << ceil(1.0*(b-1)/(a-1));
    return 0;
}
/*               now or never                 */


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <strings.h>
int main()
{
    char temp;
    int i,j,l;
    char str_s[101],str_t[101];
    scanf("%s",str_s);
    scanf("%s",str_t);
    for(i=0; str_s[i]!='\0'; i++);
    l=i;
    //printf("%d",l);
    for(i=0; i<l; i++)
    {
        if(strcmp(str_s,str_t)==0)
            break;
        else
        {
            temp=str_t[0];
            for(j=0; j<l-1; j++)
            {
                str_t[j]=str_t[j+1];
            }
            str_t[l-1]=temp;
        }
    }
    if(strcmp(str_s,str_t)==0)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}


Measured memory_bytes: 128
//minamoto
#include<bits/stdc++.h>
#define R register
#define fp(i,a,b) for(R int i=(a),I=(b)+1;i<I;++i)
#define fd(i,a,b) for(R int i=(a),I=(b)-1;i>I;--i)
#define go(u) for(int i=head[u],v=e[i].v;i;i=e[i].nx,v=e[i].v)
template<class T>inline bool cmax(T&a,const T&b){return a<b?a=b,1:0;}
template<class T>inline bool cmin(T&a,const T&b){return a>b?a=b,1:0;}
using namespace std;
const int N=45,inf=0x3f3f3f3f;
char a[N][N];int f[N][N][N][N],s[N][N];
int px,py,n,m,res;
inline int qs(R int x,R int y,R int xx,R int yy){
	return s[xx][yy]+s[x-1][y-1]-s[xx][y-1]-s[x-1][yy];
}
inline int min(R int x,R int y){return x<y?x:y;}
inline int get(R int lx,R int ly,R int rx,R int ry){
	return min(min(qs(lx,ly,px,py),qs(px,py,rx,ry)),
			min(qs(lx,py,px,ry),qs(px,ly,rx,py)));
}
int main(){
//	freopen("testdata.in","r",stdin);
	scanf("%d%d",&n,&m);
	fp(i,1,n)scanf("%s",a[i]+1);
	fp(i,1,n)fp(j,1,m){
		if(a[i][j]=='P')px=i,py=j;
		s[i][j]=s[i-1][j]+s[i][j-1]+(a[i][j]=='#')-s[i-1][j-1];
	}
	memset(f,0x3f,sizeof(f));
	f[1][1][n][m]=0,res=inf;
	fp(lx,1,n)fp(ly,1,m)fd(rx,n,lx)fd(ry,m,ly)
		if(f[lx][ly][rx][ry]!=inf){
			R int ret=f[lx][ly][rx][ry];
			if(px>=lx&&px<=rx&&py>=ly&&py<=ry)cmin(res,ret+get(lx,ly,rx,ry));
				else cmin(res,ret);
			ret+=qs(lx,ly,rx,ry);
			fp(x,lx,rx+1)fp(y,ly,ry+1)
				if(!((x==lx||x==rx+1)&&(y==ly&&y==ry+1))){
					R int val=qs(lx,ly,x-1,y-1)+qs(x,y,rx,ry);
					if(x>lx&&y>ly&&!(px>=x&&px<=rx&&py>=y&&py<=ry))
						cmin(f[lx][ly][x-1][y-1],ret-val);
					if(x<=rx&&y<=ry&&!(px<x&&px>=lx&&py<y&&py>=ly))
						cmin(f[x][y][rx][ry],ret-val);
					val=qs(lx,y,x-1,ry)+qs(x,ly,rx,y-1);
					if(x>lx&&y<=ry&&!(px>=x&&px<=rx&&py<y&&py>=ly))
						cmin(f[lx][y][x-1][ry],ret-val);
					if(x<=rx&&y>ly&&!(px<x&&px>=lx&&py>=y&&py<=ry))
						cmin(f[x][ly][rx][y-1],ret-val);
				}
		}
	printf("%d\n",res);
	return 0;
}

Measured memory_bytes: 16384
N,K=map(int,input().split())
A=list(map(int, input().split()))
dp=[[0,0]for _ in range(42)]
#2の41乗が10**12とちょっと

for i in range(1,42):
  if dp[i-1][1]==1:
    dp[i][1]=1
  
  cnt=0
  #リストA内のiケタ目の1の数をカウント
  for j in range(N):
    if (A[j]>>(41-i))&1==1:
      cnt+=1
      
  #1の方が多いときは、0を当てはめる
  if cnt>=N-cnt:
    dp[i][0]=dp[i-1][0]+(2**(41-i))*cnt
    if (K>>(41-i))&1==1:
      dp[i][1]=1
  else:
    if dp[i][1]==1:
      dp[i][0]=dp[i-1][0]+(2**(41-i))*(N-cnt)
    else:
      if (K>>(41-i))&1==1:
        #そのケタが1ならば問題なし
        dp[i][0]=dp[i-1][0]+(2**(41-i))*(N-cnt)
      else:
        #桁が0ならば0にするしかない
        dp[i][0]=dp[i-1][0]+(2**(41-i))*cnt
print(dp[41][0])
  

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

int n;
int p[30], l[30], r[30];

void preParse(int i){
  if(i == -1) return ;

  cout << " " << i;
  if(l[i] != -1) preParse(l[i]);
  if(r[i] != -1) preParse(r[i]);
}

void inParse(int i){
  if(i == -1) return ;

  if(l[i] != -1) inParse(l[i]);
  cout << " " << i;
  if(r[i] != -1) inParse(r[i]);
}

void postParse(int i){
  if(i == -1) return ;

  if(l[i] != -1) postParse(l[i]);
  if(r[i] != -1) postParse(r[i]);
  cout << " " << i;
}

int main(){

  //input
  cin >> n;
  for(int i = 0;i < n;i++) p[i] = l[i] = r[i] = -1;
  for(int i = 0;i < n;i++){
    int id, left, right;

    cin >> id >> left >> right;
    l[id] = left;
    r[id] = right;
    p[left] = p[right] = id;
  }

  //output
  for(int i = 0;i < n;i++){
    if(p[i] == -1){ //the node i is root, output
      cout << "Preorder" << endl;
      preParse(i);
      cout << endl;

      cout << "Inorder" << endl;
      inParse(i);
      cout << endl;

      cout << "Postorder" << endl;
      postParse(i);
      cout << endl;
    }
  }

  return 0;
}




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

void add_children(int root, vector<pair<vector<int>, int>>& tree) {
    for (int child: tree[root].first) {
        tree[child].second += tree[root].second;
        add_children(child, tree);
    }
}

signed main() {
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    string s, t, u;
    int A, B;
    cin >> s >> t >> A >> B >> u;
    if (u == s) {
        A--;
    } else {
        B--;
    }
    cout << A << " " << B << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <random>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll, ll> P;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

template<class T> class rollinghash {
	const ull mask30 = (1LL << 30) - 1;
	const ull mask31 = (1LL << 31) - 1;
	const ull mod61 = (1LL << 61) - 1;
	vector<ull> base;
	vector<vector<ull>> hashvalue, basepower;
	int length;
	ull multiply(ull a, ull b) {
		ull au = a >> 31; ull ad = a & mask31;
		ull bu = b >> 31; ull bd = b & mask31;
		ull mid = ad * bu + au * bd;
		ull midu = mid >> 30; ull midd = mid & mask30;
		return au * bu * 2 + midu + (midd << 31) + ad * bd;
	}
	ull modulo(ull a) {
		ull au = a >> 61; ull ad = a & mod61;
		ull res = au + ad; if (res >= mod61) res -= mod61;
		return res;
	}
public:
	rollinghash(T s) {
		length = s.size();
		base = { 200001 };
		hashvalue = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			for (int i = 0; i < length; i++) {
				hashvalue[i + 1][j] = modulo(multiply(hashvalue[i][j], base[j]) + s[i]);
			}
		}
		basepower = vector<vector<ull>>(length + 1, vector<ull>(1));
		for (int j = 0; j < 1; j++) {
			basepower[0][j] = 1;
			for (int i = 1; i <= length; i++) {
				basepower[i][j] = modulo(multiply(basepower[i - 1][j], base[j]));
			}
		}
	}
	ull hash(ll l, ll r, ll i) {
		assert(l < r && 0 <= l && l < length && 0 < r && r <= length);
		return modulo(hashvalue[r][i] + mod61 * 3 - multiply(hashvalue[l][i], basepower[r - l][i]));
	}
};

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(20);

	int n;
	cin >> n;
	string s;
	cin >> s;
	rollinghash<string> rol(s);
	int ans = 0;
	rep(i, n) {
		for (int j = i + 1; j < n; j++) {
			int ok = 0, ng = j - i + 1;
			while (ng - ok > 1) {
				int mid = (ok + ng) / 2;
				bool flag = true;
				rep(k, 1) {
					if (j + mid > n || rol.hash(i, i + mid, k) != rol.hash(j, j + mid, k)) flag = false;
				}
				if (flag) ok = mid;
				else ng = mid;
			}
			chmax(ans, ok);
		}
	}
	cout << ans << '\n';
}

Measured memory_bytes: 768
n, y = map(int, input().split())
ans = False
for i in range(n + 1):
    if ans:
        break
    for j in range(n + 1 - i):
        if y - i*10000 - j*5000 == (n - i - j)*1000:
            print(i, j, n - i - j)
            ans = True
            break
if not ans:
    print(-1, -1, -1)

Measured memory_bytes: 9120
import copy
n, m = map(int, input().split())
h = list(map(int, input().split()))

roads = []
for i in range(n): roads.append([])

for i in range(m):
    a, b = map(int, input().split())
    a, b = a-1, b-1
    roads[a].append(b)
    roads[b].append(a)

ans = 0
for i in range(n):
    flg = True
    for j in roads[i]:
        if h[i] <= h[j]:
            flg = False
            break
    if flg: ans += 1

print(ans)

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

int main(void) {
	char S[254];
	char T[254];

	fgets(S, 256, stdin);
	fgets(T, 256, stdin);

	int lenS = strlen(S);
	int i;

	for(i=0; i<lenS-1; i++) {
		//printf("%d,%c\n",i,S[i]);

		
		if(S[i]!=T[i]) {

			printf("No");
			return 0;
		}
		
	}

	if((strlen(S)+1 == strlen(T))) {
		printf("Yes");
	}

	return 0;
}

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

inline int findstr(const char* s, const int& begin, const int& end, const char* t, const int& tl) {
  for (int i = begin; i <= end - tl;) {
    for (int j = 0; j < tl; ++j) {
      if (s[i + j] != t[j]) goto cont;
    }
    return i;
  cont:
    ++i;
  }
  return -1;
}
int main() {
  char s[5001] = {};
  int k;
  scanf("%s", s);
  scanf("%d", &k);
  const int n = strlen(s);
  char t[6] = {};
  for (char c = 'a'; c <= 'z'; ++c) {
    t[0] = c;
    int l0 = findstr(s, 0, n, t, 1);
    if (l0 < 0) continue;
    if (k == 1) {
      printf("%s\n", t);
      return 0;
    }
    --k;
    for (char c = 'a'; c <= 'z'; ++c) {
      t[1] = c;
      int l1 = findstr(s, l0, n, t, 2);
      if (l1 < 0) continue;
      if (k == 1) {
        printf("%s\n", t);
        return 0;
      }
      --k;
      for (char c = 'a'; c <= 'z'; ++c) {
        t[2] = c;
        int l2 = findstr(s, l1, n, t, 3);
        if (l2 < 0) continue;
        if (k == 1) {
          printf("%s\n", t);
          return 0;
        }
        --k;
        for (char c = 'a'; c <= 'z'; ++c) {
          t[3] = c;
          int l3 = findstr(s, l2, n, t, 4);
          if (l3 < 0) continue;
          if (k == 1) {
            printf("%s\n", t);
            return 0;
          }
          --k;
          for (char c = 'a'; c <= 'z'; ++c) {
            t[4] = c;
            int l4 = findstr(s, l3, n, t, 5);
            if (l4 < 0) continue;
            if (k == 1) {
              printf("%s\n", t);
              return 0;
            }
            --k;
          }
          t[4] = 0;
        }
        t[3] = 0;
      }
      t[2] = 0;
    }
    t[1] = 0;
  }
}


Measured memory_bytes: 1668
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner s = new Scanner(System.in);
    
    int min = s.nextInt();
    s.nextInt();
    s.nextInt();
    s.nextInt();
    int max = s.nextInt();
    int k = s.nextInt();
    System.out.println(max - min <= k ? "Yay!" : ":(");
  }
}


Measured memory_bytes: 21460
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf = 1e9 + 7;

int main() {
	int n, cnt;
	bool a = true;
	vector<string> s;
	string ss;
	cin >> n;
	cnt = n;
	rep(i, n) {
		cin >> ss;
		s.push_back(ss);
	}
	sort(s.begin(), s.end());
	rep(i, n-1) {
		if (s[i] == s[i + 1])cnt--;
	}
	cout << cnt << endl;;

}

Measured memory_bytes: 11652
require "set"

n,m = gets.split.map(&:to_i)

g = Array.new(n+1){ [] }
m.times do |i|
  a, b = gets.split.map(&:to_i)
  g[a] << b
  g[b] << a
end

ans = 0
(2..n).to_a.permutation do |per|
  
  per.unshift(1)
  flag = true
  (n-1).times do |i|
    
    a, b = per[i], per[i+1]
    # a, b = b, a if a > b
    
    if !g[a].include?(b)
      flag = false
      break
    end
  end
  ans += 1 if flag
end

puts ans

Measured memory_bytes: 4092
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e6+5;

//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 //谭雪大法好 
//谭雪大法好 
//谭雪大法好 


//谭雪大法好\
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 
//谭雪大法好 

char s[maxn];long long kk,tt;
long long sa[maxn],t[maxn],t2[maxn],c[maxn],n,m;
long long height[maxn],rk[maxn];
void build_sa(long long m){
    long long *x=t,*y=t2;
    for(int i=0;i<=m;i++)c[i]=0;
    for(int i=1;i<=n;i++)c[x[i]=s[i]]++;
    for(int i=1;i<=m;i++)c[i]+=c[i-1];
    for(int i=n;i>0;i--)sa[c[x[i]]--]=i;
    for(int k=1;k<=n;k*=2){
        long long p=0;for(long long i=n-k+1;i<=n;i++)y[++p]=i;
        for(long long i=1;i<=n;i++)if(sa[i]>k)y[++p]=sa[i]-k;
        for(int i=0;i<=m;i++)c[i]=0;
        for(int i=1;i<=n;i++)c[x[y[i]]]++;
        for(int i=1;i<=m;i++)c[i]+=c[i-1];
        for(int i=n;i>=1;i--)sa[c[x[y[i]]]--]=y[i];
        swap(x,y);p=1;x[sa[1]]=1;
        for(int i=2;i<=n;i++)x[sa[i]]=y[sa[i-1]]==y[sa[i]]&&y[sa[i-1]+k]==y[sa[i]+k]?p:++p;
        if(p==n)break;m=p;
    }
}void getHeight(){
    int i,j,k=0;
    for(i=1;i<=n;i++)rk[sa[i]]=i;
    for(i=1;i<=n;i++){
    	if(k>0)k--;
    	j=sa[rk[i]-1];
    	while((i+k<=n)&&(j+k<=n)&&(s[i+k]==s[j+k]))k++;
    	height[rk[i]]=k;
	}
}int main(){
	scanf("%s",s+1);n=strlen(s+1);
	build_sa(127);getHeight();
	tt=1;
	while(tt--){
		long long ss=0,tt=0,tp=0;
		scanf("%d",&kk);
		for(int i=1;i<=n;i++){
			if(tp+n-sa[i]+1-height[i]<kk)tp+=n-sa[i]+1-height[i];
			else{
				tp=kk-tp;ss=sa[i];
				tt=sa[i]+height[i]+tp-1;
				break;
			}
		}if(ss!=0){
			for(int i=ss;i<=tt;i++)printf("%c",s[i]);
			printf("\n"); 
		}else printf("-1\n");
	}
}

Measured memory_bytes: 12544
#include<stdio.h>
int main(void)
{
    int n,m,i,j,c[100],a[100][100],b[100];
	scanf("%d %d",&n,&m);
	for(i=0;i<m;i++){
	    scanf("%d",&c[i]);
	}
	for(i=0;i<m;i++){
	    for(j=0;j<n;j++){
		    scanf("%d",&a[i][j]);
		}
	}
	for(i=0;i<n;i++) b[i]=0;
	for(i=0;i<m;i++){
	    for(j=0;j<n;j++){
		    if(c[i]==a[i][j]){
			    b[j]++;
			}
			else if(c[i]!=a[i][j]){
			    b[c[i]-1]++;
			}
		}
	}
	for(i=0;i<n;i++){
	    printf("%d\n",b[i]);
	}
	return 0;
}

Measured memory_bytes: 2748
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <regex>
using namespace std;

int N, M;
int A[101010], B[101010];
int parent[101010];

int find_root_parent(int a)
{
    if (parent[a] == 0) return a;

    if (parent[a] == a) {
        return a;
    } else {
        return find_root_parent(parent[a]);
    }
}

int main() {
    cin >> N >> M;
    for (int i=0; i<M; i++) {
        cin >> A[i] >> B[i];

        int min_parent = min(
            find_root_parent(A[i]), 
            find_root_parent(B[i])
        );
        // cout << "a = " << A[i] << " : b = " << B[i] << " : min = " << min_parent << endl;
        parent[find_root_parent(A[i])] = min_parent;
        parent[find_root_parent(B[i])] = min_parent;
    }

    int ans = 0;
    for (int i=1; i<=N; i++) {
        if (find_root_parent(i) != 1) ans++;
        parent[find_root_parent(i)] = 1;
    }

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

Measured memory_bytes: 4772
// B - Choose Integers
#include <bits/stdc++.h>
using namespace std;

int main(){
	int a,b,c; cin>>a>>b>>c;
	bool can = false;
	for(int i=0; i<b; ++i) if(a*i%b==c){ can=true; break; }
	cout<< (can? "YES":"NO")  <<endl;
}

Measured memory_bytes: 256