akhauriyash/Code-Regression huggingface dataset:
#include <iostream>

int main(){
    int a, b;

    std::cin >> a >> b;
    
    if(a > b){
        std::cout << "a > b" << std::endl;
    }else if(a < b){
        std::cout << "a < b" << std::endl;
    }else{
        std::cout << "a == b" << std::endl;
    }

    return 0;
}

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

int main() {
  int a,b,c;
  cin >> a >> b >> c;
  if(a == 5 && b == 5 && c == 7) {
    cout << "YES" << endl;
  } else {
    if(a == 5 && b == 7 && c == 5) {
      cout <<"YES" << endl;
    } else {
      if(a == 7 && b == 5 && c == 5) {
        cout << "YES" << endl;
      } else {
        cout << "NO" << endl;
      }
    }
  }
}
  


Measured memory_bytes: 3612
#include<bits/stdc++.h>
#include<math.h>
#include<string>
#include<vector>
using namespace std;
int main(void){
	int i,j,k,M,N,H,W,K;
	cin >> N >> K;
	if(N<K){
		cout << 1;
	}else if(K==1){
		cout << 0;
	}else{
		cout<<(N-K);
	}
	return 0;
}

Measured memory_bytes: 256
n, m, c = map(int, input().split())
b = list(map(int, input().split()))
ans = 0
for i in range(n):
  a = list(map(int, input().split()))
  point = c
  for i in range(m):
    point += a[i]*b[i]
  if point > 0:
    ans += 1
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto e : a) cout << e << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);
using namespace std;
int INF = 1e9 + 7;

int main()
{
    ll a, b; cin >> a >> b;
    ll lca = (a * b) / (__gcd(a, b));
    cout << lca;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

int main() {

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

	Int N, A;
	cin >> N >> A;

	vector<Int> x(N);
	for (Int i = 0; i < N; i++) {
		cin>>x[i];
	}

	vector<vector<vector<Int>>> dp(N + 1, vector<vector<Int>>(N + 1, vector<Int>(5000)));
	dp[0][0][0] = 1;

	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < N; j++) {
			for (Int k = 0; k < 5000; k++) {
				//選ばない
				dp[i + 1][j][k] += dp[i][j][k];
				//選ぶ
				if (k - x[i] >= 0) {
					dp[i + 1][j + 1][k] += dp[i][j][k - x[i]];
				}
			}
		}
	}

	Int ans = 0;
	for (Int j = 1; j <= N; j++) {
		ans += dp[N][j][A * j];
	}
	cout << ans << "\n";
}

Measured memory_bytes: 104064
import sys
sys.setrecursionlimit(10 ** 7)

def dfs(y, x):
    if not (0 <= y < h) or not (0 <= x < w) or not L[y][x]:
        return
    else:
        L[y][x] = 0
        dy = [1, 1, 1, 0, 0, -1, -1, -1]
        dx = [-1, 0, 1, -1, 1, -1, 0, 1]
    for i in range(8):
        ny = y + dy[i]
        nx = x + dx[i]
        dfs(ny, nx)
while True:
    w, h = map(int, input().split())
    if w == h == 0:
        break
    L = [list(map(int, input().split())) for _ in range(h)]
    cnt = 0
    for i in range(h):
        for j in range(w):
            if L[i][j]:
                cnt += 1
                dfs(i, j)
    print(cnt)



Measured memory_bytes: 8624
#define _DEBUG
#include "bits/stdc++.h"
#define CHOOSE(a) CHOOSE2 a
#define CHOOSE2(a0,a1,a2,a3,a4,x,...) x
#define debug_1(x1) cout<<#x1<<": "<<x1<<endl
#define debug_2(x1,x2) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<endl
#define debug_3(x1,x2,x3) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<endl
#define debug_4(x1,x2,x3,x4) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<endl
#define debug_5(x1,x2,x3,x4,x5) cout<<#x1<<": "<<x1<<", "#x2<<": "<<x2<<", "#x3<<": "<<x3<<", "#x4<<": "<<x4<<", "#x5<<": "<<x5<<endl
#ifdef _DEBUG
#define debug(...) CHOOSE((__VA_ARGS__,debug_5,debug_4,debug_3,debug_2,debug_1,~))(__VA_ARGS__)
#else
#define debug(...)
#endif
#define rep(index,num) for(int index=0;index<(int)num;index++)
#define rep1(index,num) for(int index=1;index<=(int)num;index++)
#define brep(index,num) for(int index=(int)num-1;index>=0;index--)
#define brep1(index,num) for(int index=(int)num;index>0;index--)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-7
#define mp(a1,a2) make_pair(a1,a2)
#define ALL(a) (a).begin(),(a).end()
#define rALL(a) (a).rbegin(),(a).rend()
typedef long long ll;
typedef long double ld;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=(ll)1e+18+1;
int INF=1e+9+1;
int main(){
	ll N;
	scan(N);
	vll keta(14);
	keta[0]=0;
	ll now=26;
	rep1(i,13){
		keta[i]=now+keta[i-1];
		now*=26;
	}
	int k;
	rep(i,13){
		if(N<=keta[i]){
			k=i;
			break;
		}
	}
	N-=keta[k-1];
	N--;
	vector<char> s(k);
	rep(i,k){
		s[k-i-1]='a'+N%26;
		N/=26;
	}
	rep(i,s.size()){
		printf("%c",s[i]);
	}
	kaigyo;
	return 0;
}


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

int main() {
  int n;
  cin >> n;
  int sum;

  for (int i=0;i < n;i++) {
    int l, r;
    cin >> l >> r;
    sum += r - l + 1;
  }

  cout << sum << endl;

  return 0;
}

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

using namespace std;

int main()
{
    #ifdef LOCAL_EXEC
    #else
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    #endif // LOCAL_EXEC
    long long int i,j,k,n,m,y,sum=0,x;
    long long int mt[10000001]={0};
    cin>>n;
    for(i=1;i<=n;i++){
        for(j=i;j<=n;j+=i){
            mt[j]+=1;
        }
    }
    for(i=1;i<=n;i++){
        sum+=i*mt[i];
    }
    cout<<sum;
    return 0;
}


Measured memory_bytes: 81748
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1e9;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
typedef long long ll;
//typedef pair<int, int> P;
struct P {
	int x, y, n;
	P(int n, int x, int y):n(n), x(x), y(y){}
	P(){}
};

/** Problem1141 : Dirichlet's Theorem on Arithmetic Progressions **/
const int MAX = 1e6;

int main()
{
	bool isPrime[MAX];
	memset(isPrime, 1, sizeof(isPrime));
	isPrime[0]=false, isPrime[1]=false;

	
	for (int i=2; i<MAX; i++) {
		if (isPrime[i]) {
			for (int j=2; i*j<MAX; j++) {
				isPrime[i*j]=false;
			}
		}
	}

	
	int a, d, n;
	while (cin>>a>>d>>n, a||d||n) {
		int count = 0;
		for (int i=0; ; i++) {
			int b = a + i*d;
			
			if (isPrime[b])
				count++;
			
			if (count == n) {
				cout << b << endl;
				break;
			}
		}
	}
}

Measured memory_bytes: 2144
#!/usr/bin/env ruby
# coding: utf-8
h, _, k = ARGF.gets.split.map(&:to_i)
s = Array.new(h).map { ARGF.gets.chomp }

id = 0
t1 = s.map do |line|
  sp = line.split(/(#)/)
  if sp.size == 1
    []
  else
    id += 1
    sp[1] = 'x' # 誤魔化す
    sp.map do |i|
      if i == '#'
        id += 1
        [id]
      else
        Array.new(i.size, id)
      end
    end
  end.flat_map {|o|o}
end

ok1 = nil
ok2 = nil
t2 = t1.map do |tx|
  if tx == []
    ok2
  else
    ok1 = ok1 || tx
    ok2 = tx
    tx
  end
end.map do |tx|
  if tx == nil
    ok1
  else
    tx
  end
end

t2.each do |tx|
  puts tx.map {|ty| sprintf("%3d", ty)}.join(' ')
end


Measured memory_bytes: 4092
n=int(input())
s = input()
ans = 0

if n%2 != 0:
    print('No')
if n%2 == 0:
    for i in range(n//2):
        if s[i] == s[i+n//2]:
            ans += 1
    if ans == n//2:
        print('Yes')
    if ans != n//2:
        print('No')

Measured memory_bytes: 9120
#include<bits/stdc++.h>
#define rep(i,k,n) for(ll i= (ll) k;i< (ll) n;i++)
#define all(v) (v).begin(), (v).end()
#define SZ(v) (int)((v).size())
#define pb push_back
#define ft first
#define sd second
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const long long INF = 4e18L + 1;
const int IINF = 2e9 + 1;

using namespace std;

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

#ifdef LOCAL
#define DBG(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define DBG(...) ;
#define cerr if(0)cout
#endif

const int N = 2e5;

int nums[N + 1], cnt[N + 1], cov[N + 1], st[N + 1], fn[N + 1];

int n, m;

int main()
{
#ifndef LOCAL
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif
    cin >> n >> m;
    rep(i, 1, n + 1){
        cin >> nums[i];
        cnt[nums[i]]++;
    }
    rep(i, 1, n + 1){
        DBG(i, cnt[i]);
    }
    rep(i, 1, n + 1){
        if(cnt[i]){
            st[max(1ll, i + 1 - cnt[i])]++;
            fn[i]++;
        }
    }
    rep(i, 1, n + 1){
        DBG(i, st[i], fn[i]);
    }
    int res = 0;
    rep(i, 1, n + 1){
        cov[i] = cov[i - 1] + st[i] - fn[i - 1];
        res += (cov[i] == 0);
    }
    rep(i, 1, n + 1){
        DBG(i, cov[i]);
    }
    DBG(res);
    rep(_, 0, m){
        int i, v; cin >> i >> v;
        DBG(i, v, nums[i]); 
        int j1 = nums[i] + 1 - cnt[nums[i]];
        if(j1 >= 1){
            res += (cov[j1] == 1);
            cov[j1]--;
        }
        cnt[nums[i]]--;
        int j2 = v - cnt[v];
        if(j2 >= 1){
            res -= (cov[j2] == 0);
            cov[j2]++;
        }
        cnt[v]++;
        nums[i] = v;
        cout << res << "\n";
    }
    return 0;
}

Measured memory_bytes: 5376
using System;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace contest_Csharp
{
    class Program
    {
        public static (long m,long s)[,] dp;

        static void Main(string[] args)
        {
            checked
            {
                var sw = new System.IO.StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
                Console.SetOut(sw);

                var vals = Console.ReadLine().Split(' ').
                    Select(x => int.Parse(x)).ToList();

                var N = vals[0];
                var S = Console.ReadLine();
                var redseeker = N-1;
                var rcnt = S.Count(x=>x=='R');
                var ans = 0;
                for (int i = 0; i < N; i++)
                {
                    if (S[i] == 'W')
                    {
                        while (redseeker >= 0 && S[redseeker] != 'R')
                            redseeker--;
                        redseeker--;                   
                        rcnt--;
                        if ( redseeker+1 <= i)
                            break;
                        ans++;
                        
                    }   
                    if ( redseeker +1<= i)
                            break;        
                }

                if (0 == S.Count(x => x == 'R'))
                    ans = 0;
                
                
                
                Console.WriteLine(ans);

                Console.Out.Flush();
            }




        }
    }
}




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

int main() {
    int n;
    string s;
    cin >> n >> s;
    rep(i, s.size()){
        if(s[i]-'0'+n > 42){
            s[i] = s[i]-(26-n);
        }else s[i] = s[i]+n;
    }
    cout << s << endl;
    // cout << 'Z'-'0' << endl; 
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int ans(int arr[],int dp[],int n){
    if(n==1){
        return 0;
    }
  
  if(n==2)
  {if(dp[n-1]!=-1){
  return dp[n-1];
  }
  else{
      dp[1]=abs(arr[n-1]-arr[0]);
    return dp[n-1];
  }
 }
  else if(n>2){
      if(dp[n-1]!=-1){
  return dp[n-1];
  }
  else{
      dp[n-1]=min(ans(arr,dp,n-1)+abs(arr[n-2]-arr[n-1]),ans(arr,dp,n-2)+abs(arr[n-1]-arr[n-3]));
    return dp[n-1];
  }
  }

}
int main(){
  int n;
  int a;
  scanf("%d",&n);
  int arr[n];
  int dp[100001];
  memset(dp,-1,sizeof(dp));
  for(int i=0;i<n;i++){
    scanf("%d",&arr[i]);}
  a=ans(arr,dp,n);
  printf("%d",dp[n-1]);
return 0;
}

Measured memory_bytes: 4992
s = input()
t = input()
n = len(s)
m = len(t)

dp = [[0]*(m+1) for _ in range((n+1))]

for i in range(n):
  for j in range(m):
    if s[i]==t[j]:
      dp[i+1][j+1] = dp[i][j] + 1
    else:
      dp[i+1][j+1] = max(dp[i][j+1], dp[i+1][j])
      
ans = ''
i = len(s)
j = len(t)
while i>0 and j>0:
  if dp[i][j] == dp[i-1][j]:
    i-=1    
  elif dp[i][j] == dp[i][j-1]:
    j-=1
  else:
    i-=1
    j-=1
    ans = s[i]+ans
    
print(ans)    

Measured memory_bytes: 112220
/* � Ashiq Uddin Pranto
   Department of Computer Science and Engineering
   BATCH 27
   University Of Rajshahi,Bangladesh
*/
#include<bits/stdc++.h>

#define ll long long
#define ld long double
#define FOR(x,y) for(ll i=x;i<=y;i++)
#define pb(x) push_back(x)
#define mp make_pair
#define pii pair<int,int>
#define pll pair<ll,ll>
#define vii vector<int>
#define vll vector<ll>
#define matrix(x) vector<vector<x>>
#define vss vector<string>
#define PI (2*acos(0.0))
#define sqr(x) ((x)*(x))
#define sf(a)   scanf("%d",&a)
#define sfl(a)  scanf("%lld",&a)
#define sff(a,b)    scanf("%d %d",&a,&b)
#define sffl(a,b)   scanf("%lld %lld",&a,&b)
#define sfff(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)    scanf("%lld %lld %lld",&a,&b,&c)
#define ms(a,b) memset(a, b, sizeof(a))
#define ff  first
#define ss  second
#define lcm(a, b)   ((a)*((b)/__gcd(a,b)))
#define all(a)  a.begin(),a.end()
#define readfile freopen("input.txt","r",stdin);
#define writefile freopen("output.txt","w",stdout);
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define gap " "
#define mx 104
#define inf (ll)1e9
#define WHITE 1
#define GRAY 2
#define BLACK 3
#define EMPTY_VALUE -1
#define mod 1000000007
#define MOD(a,b) (a%b + b)%b

using namespace std;

void __print(int 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

int main()
{
    //fastio
    ll n;
    sfl(n);
    ll d[n][2];
    ll cnt = 0,ans = 0;
    for(ll i=0;i<n;i++)
    {
        sffl(d[i][0],d[i][1]);
        if(d[i][0] == d[i][1])
        {
            cnt++;
        }
        else cnt = 0;
        if(cnt>=3) ans = 1;
    }
    if(ans==1) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 3764
n = int(input())
p = list(map(int,input().split()))
ans = 0
for i in range(n):
    if (i == 0):
        ans = ans + 1
        x = p[0]
    else:
        if (x < p[i]):
            pass
        else:
            ans = ans + 1
            x = p[i]

print(ans)


Measured memory_bytes: 32352
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cassert>
#include <cstring>
using namespace std;

#define GET_ARG(a,b,c,F,...) F
#define REP3(i,s,e) for (i = s; i <= e; i++)
#define REP2(i,n) REP3 (i,0,(int)(n)-1)
#define REP(...) GET_ARG (__VA_ARGS__,REP3,REP2) (__VA_ARGS__)
#define RREP3(i,s,e) for (i = s; i >= e; i--)
#define RREP2(i,n) RREP3 (i,(int)(n)-1,0)
#define RREP(...) GET_ARG (__VA_ARGS__,RREP3,RREP2) (__VA_ARGS__)
#define DEBUG(x) cerr << #x ": " << x << endl

int main(void) {
    int i, j, n, m, k;
    cin >> n >> m >> k;
    
    REP (i,0,n/2) {
        int sum = i * m;
        REP (j,m) {
            if (sum == k) {
                puts("Yes");
                return 0;
            }
            sum += n - 2 * i;
        }
        if (sum == k) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;

typedef pair <int, int> pii;

const int MAXN = 205;
const int INF = 0x3f3f3f3f;

int N, M;
char mat[MAXN][MAXN];
int edge[MAXN][MAXN];
bool bio[MAXN];
int source, sink;
int flow;

void load() {
  scanf("%d%d", &N, &M);
  for (int i = 0; i < N; i++)
    scanf("%s", mat[i]);
}

pii find(char c) {
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      if (mat[i][j] == c)
        return pii(i, j);
  return pii(-1, -1);
}

int dfs(int x, int cap) {
  if (cap <= 0)
    return 0;
  if (x == sink) {
    flow += cap;
    return cap;
  }
  bio[x] = true;
  for (int i = 0; i < N + M; i++) {
    if (bio[i])
      continue;
    int tmp = dfs(i, min(cap, edge[x][i]));
    if (tmp > 0) {
      edge[x][i] -= tmp;
      edge[i][x] += tmp;
      return tmp;
    }
  }
  return 0; 
}

void add(int a, int b) {
  edge[a][b]++;
  edge[b][a]++;
  //printf("a b %d %d\n", a, b);
}

int solve() {
  pii S = find('S');
  pii T = find('T');
  
  if (S.first == T.first || S.second == T.second)
    return -1;
  
  source = S.first;
  sink = T.first;
  
  //printf("source sink %d %d\n", source, sink);
  
  for (int i = 0; i < N; i++)
    for (int j = 0; j < M; j++)
      if (mat[i][j] == 'o') {
        if (i == S.first)
          add(source, j == T.second ? sink : N + j);
        else if (j == S.second)
          add(source, i == T.first ? sink : i);
        else if (i == T.first)
          add(j == S.second ? source : N + j, sink);
        else if (j == T.second)
          add(i == S.first ? source : i, sink);
        else
          add(i, N + j);
      }
      
  while (1) {
    memset(bio, false, sizeof bio);
    if (!dfs(source, INF))
      break;
  }
  
  return flow;
}

int main() {
  load();
  printf("%d\n", solve());
  return 0;
}

Measured memory_bytes: 384
#include<iostream>
using namespace std;
int main(){
    
    int p[3];
    int res = 300;
    
    for(int i = 0;i < 3;i++){
        cin>>p[i];
    }
    for(int i = 0;i < 3;i++){
        for(int j = i+1;j < 3;j++){
        res = min(res,p[i] + p[j] );
        
    }
        
    }
    
    
    
    cout<<res;
    
    return 0;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Joy
 */

#include <bits/stdc++.h>
#define REP(i, N) for (ll i = 0; i < (N); ++i)
#define ALL(x) (x).begin(), (x).end()
#define MOD 1000000007
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

class BDigitalGifts {
public:
	void solve(std::istream& in, std::ostream& out) {
        int N;
        in >> N;
        double sum = 0.0;
        REP(i, N) {
            double x;
            string u;
            in >> x >> u;
            if (u == "JPY") sum += x;
            else sum += x * 380000.0;
        }
        out << setprecision(14) << sum << '\n';
	}
};


int main() {
	BDigitalGifts solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int pre[50], in[50], post[50];
int k = 0, j = 0;

void rec(int left, int right)
{
	if (left >= right)
		return;
	int root, p;
	root = pre[j++];
	for (int i = left; i < right; i++)
		if (in[i] == root)
			p = i;

	rec(left, p);
	rec(p + 1, right);
	post[k++] = root;
}

int main()
{
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; i++)
		scanf("%d", &pre[i]);
	for (int i = 0; i < n; i++)
		scanf("%d", &in[i]);
	rec(0, n);
	for (int i = 0; i < n; i++)
	{
		if (i)
			printf(" ");
		printf("%d", post[i]);
	}
	printf("\n");
}



Measured memory_bytes: 2092
import sys
stdin = sys.stdin
sys.setrecursionlimit(10**6)
 
ni = lambda: int(ns())
na = lambda: list(map(int, stdin.readline().split()))
nn = lambda: list(stdin.readline().split())
ns = lambda: stdin.readline().rstrip()
 
a,b = na()
 
if a >= 13:
    print(b)
elif a >= 6:
    print(b//2)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long LL;
const int N = 200000 + 10;
const LL MOD = 1e9+7;
int n;
int x[N],v[N],pre[N],suf[N];
pair<int,int> p[N];
vector<int> vec;
int id(int x) {
    return lower_bound(vec.begin(),vec.end(),x) - vec.begin() + 1;
}

int nod[N<<2];
LL query(int l,int r,int rt,int L,int R) {
    if(L<=l&&r<=R)return nod[rt];
    int mid=(l+r)>>1; LL ans=0;
    if(L<=mid) ans+=query(l,mid,rt<<1,L,R);
    if(R >mid) ans+=query(mid+1,r,rt<<1|1,L,R);
    return ans%MOD;
}
void modify(int l,int r,int rt,int pos,int x){
    if(l==r){
        (nod[rt]=x)%=MOD; return;
    }
    int mid=(l+r)>>1;
    if(pos<=mid) modify(l,mid,rt<<1,pos,x);
    else modify(mid+1,r,rt<<1|1,pos,x);
    nod[rt]=(nod[rt<<1]+nod[rt<<1|1])%MOD;
}
int main() {
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d%d",&p[i].first,&p[i].second);
        vec.push_back(p[i].second);
    }
    sort(p+1, p+1+n);
    sort(vec.begin(), vec.end());
    vec.erase(unique(vec.begin(), vec.end()), vec.end());

    pre[0]=0,suf[n+1]=N;
    for(int i=1;i<=n;i++){
        pre[i]=max(pre[i-1],id(p[i].second));
    }
    for(int i=n;i>=1;i--){
        suf[i]=min(suf[i+1],id(p[i].second));
    }
    vector< pair<int,int> > items; 
    for(int i=1;i<=n;i++){
        //printf("<%d, %d>\n", suf[i],pre[i]);
        items.push_back(make_pair(suf[i],pre[i]));
    }
    sort(items.begin(), items.end());
    LL dp[N]={0};
    modify(0,vec.size(),1,0,1);
    for (auto item: items) {
        (dp[item.second] += query(0,vec.size(),1,item.first-1, item.second)) %= MOD;
        //printf("$ %d %d\n", item.second, dp[item.second]);
        modify(0,vec.size(),1,item.second,dp[item.second]);
    }
    cout<<dp[items.size()]<<endl;
}









Measured memory_bytes: 10480
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner sc=new Scanner(System.in);
    int m1=sc.nextInt()*60+sc.nextInt();
    int m2=sc.nextInt()*60+sc.nextInt();
    System.out.println((m2-m1-sc.nextInt()));
  }
}

Measured memory_bytes: 35544
str_input = input()
num_list = list(str_input)
next_stage = 0

num1 = int(num_list[0])
num2 = int(num_list[1])
num3 = int(num_list[2])

def change_nums( num ):
    return num*100+num*10+num


if num1 > num2:
    next_stage = change_nums( num1 )
elif num1==num2==num3:
    next_stage = change_nums( num1 )
elif num1==num2 and num1 > num3:
    next_stage = change_nums( num1 )
else:
    next_stage = change_nums( num1+1 )

print(next_stage)

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

public class Main
{
  static long t[];
  static long l[];
  static long h[];

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);

    String s;
    String sl[];

    s = r.readLine();
    sl = s.split(" ");
    int n = Integer.parseInt(sl[0]);

    int a[] = new int[n];
    s = r.readLine();
    sl = s.split(" ");
    for(int i = 0; i < n; i++)
    {
      a[i] = Integer.parseInt(sl[i]);
    }

    for(int i = 0; i < n - 1; i++)
    {
      int x = a[i];
      int y = a[i + 1];
      while(y > 0)
      {
        int t = y;
        y = x % y;
        x = t;
      }
      a[i + 1] = x;
    }

    System.out.println(a[n - 1]);
  }

}

Measured memory_bytes: 50932
N = int(input())
S = [input() for _ in range(N)]

import collections
t = [collections.Counter(s) for s in S]

def com(x, y):
    result = {}
    for k,v in x.items():
        if k in y:
            result[k] = min(y[k], v)
    return result

c = t[0]
for x in t[1:]:
    c = com(c, x)

ans = ""
for k in sorted(c.keys()):
    ans += k * c[k]
print(ans)

Measured memory_bytes: 3444
#include<iostream>
#include<vector>
using namespace std;
long long n,m,a[100100];
vector<int> v,ans;
string s;
int main()
{
	cin>>n>>m;
	cin>>s;
	for(int i=0;i<s.size();i++)
		if(s[i]=='0')
			v.push_back(i);
	if(v.size()==0)
		cout<<-1<<endl;
	else
	{
		int x=0;
		bool no=false;
		while(x!=n)
		{
			long long l=0,r=v.size(),w=0;
			while(r-l!=1)
			{
				w=(l+r)/2;
				if(v[w]<=x+m)
					l=w;
				else
					r=w;	
			}
			w=(l+r)/2;
			if((v[w]<x && w==v.size()-1)||(x==v[w] && v[w+1]>x+m))
			{
				no=true;
				break;
			} 
			if(w!=v.size()-1 && v[w+1]<x+m && x==v[w])
				x=v[w+1];
			else	
				x=v[w];
		}
		if(no==false)
		{
			int x=n;
			while(x!=0)
			{
				long long l=0,r=v.size(),w=0;
				while(r-l!=1)
				{
					w=(l+r)/2;
					if(v[w]<=x-m)
						l=w;
					else
						r=w;	
				}
				w=(l+r)/2;
				if(v[w]<x-m)
					w++;		
				ans.push_back(x-v[w]);
				x=v[w];
			}	
			for(int i=ans.size()-1;i>=0;i--)
				cout<<ans[i]<<" ";
			cout<<endl;	
		}			
		else
			cout<<-1<<endl;	
	}	
} 

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


void __print(int 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...);}

#define fo(i, n) for(int i=0; i<n; i++)
#define Fo(i, k, n) for(int i=k; i<n; i++)
#define w(x)  int x; cin>>x; while(x--)
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define watch2(x,y) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<"\n"
#define watch3(x,y,z) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<"\n"
#define watch4(x,y,z,q) cout <<(#x)<<" is "<<(x)<<" and "<<(#y)<<" is "<<(y)<<" and "<<(#z)<<" is "<<(z)<<" and "<<(#q)<<" is "<<(q)<<"\n"
#define MOD 1000000007
#define INF 1000000007;
#define F first
#define S second
#define pb(x) push_back(x);


#define ll  long long
#define all(c) (c).begin(),(c).end()
#define endl "\n"

typedef vector<int> vl;
typedef vector< vl > vvl;
typedef pair< int, int> pll;
typedef map< int, int> mll;


#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif





void c_p_c()
{
#ifndef ONLINE_JUDGE
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}
void parray(int a[],int n){
    for(int i=0;i<n;i++){
    cout<<a[i]<<" ";
    }
    cout<<endl;
}

int main() {
    int i,n,m,k,sum=0;
    c_p_c();
   string s;
   cin>>s;
   map<char,int> ma;
   for(char ch:s)
   	ma[ch]++;
   if(ma.size()==26)
   	cout<<"None"<<endl;
   else{
   		int j=0;
   		int p=0;
   		// cout<<char(j+'a')<<endl;
   		if(s=="a")
   			cout<<'b'<<endl;
   		else{
   		for(auto i : ma){
   			// watch2(i.F,char(j+'a'));
   			if(i.F!=char(j+'a')){
   				cout<<char(j+'a');
   				p=1;
   				break;
   			}
   			j++;
   		}

   		if(!p){
   			auto it= ma.rbegin();
   			cout<<char(it->first+1)<<endl;


   		}
   	}




   }
 	return 0;

   }

Measured memory_bytes: 3752
<?php

ini_set('error_reporting', E_ALL & ~E_NOTICE & ~E_WARNING);
ini_set('display_errors', 'Off');

// define('DEBUG', true);
define('DEBUG', false);

fscanf(STDIN, "%d %d", $N, $P);
$a = explode(" ", trim(fgets(STDIN)));
$odd = 0;
$even = 0;

// echo calcP(10,2);

$ans = 0;

foreach ($a as $k => $v) {
    $a[$k] = $v % 2;
    if ($a[$k] == 1) {
        $odd++;
    } else {
        $even++;
    }
}

// echo "\$P = $P \n";
// echo "\$odd = $odd\n";
// echo "\$even = $even\n";

if ($P == 0) {
    // for ($i = 1; $i <= $even; $i++) {
    //     $ans += calcP($even, $i);
    //     if (DEBUG) echo "E{$i}: " . $ans . PHP_EOL;
    // }
    for ($i = 0; $i <= $even; $i++) {
        for ($j = 0; $j <= $odd; $j += 2) {
            $ans += calcP($even, $i) * calcP($odd, $j);
            if (DEBUG) echo "Even:{$i} Odd:{$j} " . $ans . PHP_EOL;
        }
    }
} else {
    for ($i = 1; $i <= $odd; $i += 2) {
        for ($j = 0; $j <= $even; $j++) {
            $ans += calcP($even, $j) * calcP($odd, $i);
            if (DEBUG) echo "Odd:{$i} Even:{$j} " . $ans . PHP_EOL;
        }
    }
}

echo $ans . PHP_EOL;

function calcP($a, $b) {
    $ret = 1;
    for ($i = 0; $i < $b; $i++) {
        $ret *= $a - $i;
        $ret /= $i + 1;
    }
    // echo "calc:{$ret}\n";
    return $ret;
}

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

#define rep(i,n) for (int i = 0; i< (n); ++i)
#define vvec(m,n) vector<vector<int>> (int(m), vector<int>(n))
#define ALL(a) (a).begin(), (a).end()

using ll = long long;

int main(){
    string s;
    cin >> s;
    bool res = false;
    if(s.at(0)==s.at(1)&&s.at(1)==s.at(2)) res = true;
    if(s.at(1)==s.at(2)&&s.at(2)==s.at(3)) res = true;
    if(res) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 256
#from statistics import median
#import collections
#aa = collections.Counter(a) # list to list || .most_common(2)で最大の2個とりだせるお a[0][0]
from fractions import gcd
from itertools import combinations,permutations,accumulate, product # (string,3) 3回
#from collections import deque
from collections import deque,defaultdict,Counter
import decimal
import re
#import bisect
#
#    d = m - k[i] - k[j]
#    if kk[bisect.bisect_right(kk,d) - 1] == d:
#
#
#
# pythonで無理なときは、pypyでやると正解するかも！！
#
#
# my_round_int = lambda x:np.round((x*2 + 1)//2)
# 四捨五入
import sys
sys.setrecursionlimit(10000000)
mod = 10**9 + 7
#mod = 9982443453
def readInts():
  return list(map(int,input().split()))
def I():
  return int(input())
a,b = input().split()
ab = a+b
rab = int(ab)**.5
print("Yes" if int(ab) == int(rab)**2 else 'No')


Measured memory_bytes: 10664
N = int(input())
A = [int(input()) for i in range(N)]

def push(i):
    return A[i] - 1

index = 0
cnt = 0
for _ in range(N):
    index = push(index)
    cnt += 1
    if index == 1:
       print(cnt)
       exit()
print(-1)


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

int main(int argc, char const *argv[])
{
	string s; cin >> s;
	bool f = true;
	rep(i, 3) if (s[i] == s[i + 1]) f = false;
	printf("%s\n", f ? "Good" : "Bad");
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
  int a[1000];
  int i, v, j, k, N;

  scanf("%d", &N);
 
  for(i = 0; i < N; i++)
    scanf("%d", &a[i]);
  
  for(k = 0; k < N; k++) {
      if(k > 0)
        printf(" ");
      printf("%d", a[k]);
  }
  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++) {
      if(k > 0)
        printf(" ");
      printf("%d", a[k]);
    }
    printf("\n");
  }

  return 0;
}

Measured memory_bytes: 1796
n = int(input())
p = (n+1)*[0]

for i in range(2, n+1):
    now = i
    for j in range(2, i+1):
        while now % j == 0:
            p[j] += 1
            now //= j


def cnt(m):
    return len(list(filter(lambda x: x >= m, p)))


ans = 0
ans += cnt(74)
ans += cnt(24)*(cnt(2)-1)
ans += cnt(14)*(cnt(4)-1)
ans += cnt(4)*(cnt(4)-1)*(cnt(2)-2)//2
print(ans)


Measured memory_bytes: 3064
#include <iostream>
using namespace std;
#define ll long long

ll gcd (ll a, ll b) {
  while(1) {
    if(a < b) swap(a, b);
    if(!b) break;
    a %= b;
  }
  return a;
}

int main () {
    ll a, b;
    cin >> a >> b;
    ll GCD = gcd(a, b);
    cout << a * b / GCD << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.NoSuchElementException;

public class Main {

	int N,M,Q;
	int[] a,b,v,d,c;

	public void solve() {
		N = nextInt();
		M = nextInt();

		a = new int[M+N];
		b = new int[M+N];
		for(int i = 0;i < M;i++){
			a[i] = nextInt()-1;
			b[i] = nextInt()-1;
		}

		for(int i = 0;i < N;i++){
			a[M+i] = i;
			b[M+i] = i;
		}

		Q = nextInt();
		v = new int[Q];
		d = new int[Q];
		c = new int[Q+1];
		int[][] dp = new int[10+1][N];
		for(int i = 0;i < Q;i++){
			v[i] = nextInt()-1;
			d[i] = nextInt();
			c[i+1] = nextInt();

			dp[d[i]][v[i]] = i + 1;
		}

		for(int i = 10;i >= 1;i--){
			for(int j = 0;j < M+N;j++){
				dp[i-1][b[j]] = Math.max(dp[i-1][b[j]], dp[i][a[j]]);
				dp[i-1][a[j]] = Math.max(dp[i-1][a[j]], dp[i][b[j]]);
			}
		}

		for(int i = 0;i < N;i++){
			out.println(c[dp[0][i]]);
		}
	}

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

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

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

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

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

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

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

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

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

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

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

int main(){
  int N, K;
  cin >> N >> K;
  bool T[N];
  fill(T, T + N, true);
  for(int i = 0; i < K; i++){
      int d;
      cin >> d;
      for (int j = 0; j < d; j++){
          int a;
          cin >> a;
          T[a - 1] = false;
      }
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
      if(T[i]) ans++;
  }
  cout << ans;
  return 0;
}
  

Measured memory_bytes: 3632
n=int(input())
l=list(map(int,input().split()))
a=l[0]
l.remove(a)
f='flat'
f2='first'
c=1
for i in l:
  if f2=='first':
    if a==i:
      pass
    elif a<i:
      f='up'
      f2='not first'
      a=i
    else:
      f='down'
      f2='not first'
      a=i
  else:
    if a==i:
      pass
    elif a<i:
      if f=='up':
        pass
        a=i
      else:
        f=='flat'
        f2='first'
        c+=1
        a=i
    else:
      if f=='down':
        pass
        a=i
      else:
        f=='flat'
        f2='first'
        c+=1
        a=i
print(c)

Measured memory_bytes: 14436
n=int(input())
a=[int(i) for i in input().split()]

s=[0 for i in range(n+1)]
count=0

for i in range(n):
  if a[i]<=n:
    s[a[i]]+=1
  else:
    count+=1

for i in range(n+1):
  if s[i]>=i:
    count+=s[i]-i
  else:
    count+=s[i]
   
print(count)

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

const long long MAX_N = 1e5 + 5e4 + 5, inf = 1e9 + 7;
long long n;
long long Arr[MAX_N];
long long P[MAX_N];
long long psum[MAX_N];
long long cnt[MAX_N];
long long dp[MAX_N];

void process(long long d) {
	memset(cnt, 0, sizeof cnt);
	memset(dp, 0, sizeof dp);
	for (long long i = 1; i <= n; i++) {
		P[i] = (d <= Arr[i]? +1: -1);
		psum[i] = P[i] + psum[i - 1];
	}
}

long long calc(long long d) {
	long long res = 0;
	cnt[50000] = 1;
	
	for (long long i = 1; i <= n; i++) {
		dp[i] = dp[i - 1];
		if (P[i] == +1)
			dp[i] += cnt[50000 + psum[i - 1]];
		else
			dp[i] -= cnt[50000 + psum[i]];
			
		res += dp[i] + cnt[50000+ psum[i]];
		cnt[50000+ psum[i]]++;
	}
	
	return res;
}

int main() {
	scanf("%d", &n);
	for (long long i = 1; i <= n; i++)
		scanf("%d", &Arr[i]);
	
	long long s = 1, e = inf;
	while (e - s > 1) {
		long long mid = e + s >> 1;
		
		process(mid);
		if (calc(mid) < ((((n * (n + 1)) >> 1) + 1) >> 1))
			e = mid;
		else
			s = mid;
	}
	
	printf("%d\n", s);
	return 0;
}
// 

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)

int main(void) {
    int n;
    long long l[100];

    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    l[0] = 2;
    l[1] = 1;
    FOR(i, 2, n + 1) {
        l[i] = l[i - 2] + l[i - 1];
    }

    cout << l[n] << "\n";
    return 0;
}

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

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define REP(i,n) for (int i=0;i<(n);++i)
#define RREP(i,n) for (int i=(n)-1;i>=0;--i)
#define all(a) (a).begin(),(a).end()

using namespace std;

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

    int N, L, Q;
    cin >> N;
    vector<int> x(N);
    REP(i, N) cin >> x[i];
    cin >> L >> Q;

    int K = 31 - __builtin_clz(N - 1); // floor(log(max(b - a)))
    vector<vector<int>> dp(N, vector<int>(K + 1));
    REP(i, N) {
        dp[i][0] = distance(x.begin(), upper_bound(all(x), x[i] + L)) - 1;
        //printf("dp[%d][0] = %d\n", i, dp[i][0]);
    }
    FOR(j, 1, K + 1) REP(i, N) {
        dp[i][j] = dp[dp[i][j - 1]][j - 1];
    }

    REP(_, Q) {
        int a, b;
        cin >> a >> b;
        --a; --b;
        if (a > b) {
            swap(a, b);
        }
        int result = 0;
        RREP(i, K + 1) {
            if (dp[a][i] < b) {
                //printf("from x[%d] to x[%d] in %d days\n", a, dp[a][i], 1 << i);
                a = dp[a][i];
                result += 1 << i;
            }
        }
        ++result;
        cout << result << '\n';
    }
    cout << flush;

    return 0;
}

Measured memory_bytes: 11392
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    REP(i,s.length()-1){
        if(s[i] == s[i+1]){
            cout << "no" << endl;
            return 0;
        }
    }
    cout << "yes" << endl;
    return 0;
}

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

int main() {
    string s; cin >> s;
    bool ans = true;
    if (s[0] != 'A') {
        //ans = false;
        cout << "WA" << endl;
        return 0;
    }
    int count = 0;
    int count2 = 0;
    for (int i=0; i<s.size(); i++) {
        if (2<=i && i<=s.size()-2) {
            if (s[i] == 'C') count++;
        }
        if (s[i] > 'Z') count2++;
    }

    if (count == 1 && count2 == s.size()-2) {
        cout << "AC" << endl;
    }

    else cout << "WA" << endl;

    return 0;
}


Measured memory_bytes: 256
url = "https://atcoder.jp//contests/abc149/tasks/abc149_d"

def main():
    n,k = list(map(int, input().split()))
    rsp = list(map(int, input().split()))
    j_machine = list(input())
    j_human = []
    score = 0
    for i, v in enumerate(j_machine):
        hand = ''
        points = 0
        hand, points = ret_win_hand_point(v, rsp)

        if i - k >= 0 and hand == j_human[i - k]:
            f_hand = [hand]
            if i + k < len(j_machine):
                h = ret_win_hand_point(j_machine[i + k], rsp)
                f_hand.append(h[0])
            for v in ['r','s','p']:
                if v not in f_hand:
                    hand = v
                    break
            points = 0
        score += points
        j_human.append(hand)
    print(score)


def ret_win_hand_point(machine, rsp):
    if machine == 'r':
        hand = 'p'
        points = rsp[2]
    elif machine == 'p':
        points = rsp[1]
        hand = 's'
    else:
        points = rsp[0]
        hand = 'r'
    return hand, points

if __name__ == '__main__':
    main()


Measured memory_bytes: 4804
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner scan = new Scanner(System.in);
		int K = scan.nextInt();
		int N = scan.nextInt();
		int A[] = new int[N];
		for (int i = 0; i < N; i++) {
			A[i] = scan.nextInt();
		}
		int Max = 0;
		for (int i = 1; i < N; i++) {
			Max = Math.max(A[i] - A[i-1], Max);
		}
		Max = Math.max( K - A[N-1] + A[0], Max);

		System.out.println(K - Max);
	}
}

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, k, n) for(auto i = k; i != n; i++)
#define rrep(i, n) RREP(i, n, 0)
#define RREP(i, n, k) for(auto i = n; i != k; i--)
#define all(x, r) (x), (x)+(r)
#define ALL(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << " " << x << endl
#define exst(x, data) (data).find(x) != (data).end()
#define mp make_pair
#define mt make_tuple

using ll = long long;
using Pii = pair<int,int>;
using Tiii = tuple<int, int, int>;
template<class T>using V = vector<T>;

struct Node {
    int dist, number;
    Node(int d, int n) {
        dist = d, number = n;
    }
};
bool operator < (const Node &l, const Node &r) {
    return l.dist < r.dist
    || (!(r.dist < l.dist) && l.number < r.number);
};
bool operator > (const Node &l, const Node &r) {
    return r < l;
};
struct Edge {
    int to, cost;
    Edge(int t, int c) {
        to = t, cost = c;
    }
};

int node_n;
V<int> d;
V<V<Edge>> edges;
void edge_initializer(int n) {
    edges = vector<vector<Edge>>(n, vector<Edge>());
}
void dijkstra(int start_p) {
    d = V<int>(node_n, INT_MAX); d[start_p] = 0;

    priority_queue<Node,vector<Node>,greater<Node>> Q;

    for(int i=0; i<node_n; i++) {
        Q.push(Node(d[i],i));
    }

    while(!Q.empty()) {
        Node u = Q.top(); Q.pop();
        if(u.dist > d[u.number]) continue;

        for(Edge edge:edges[u.number]) {
            if(edge.cost == INT_MAX) continue;
            int alt = d[u.number] + edge.cost;
            int v = edge.to;
            if(d[v] > alt) {
                d[v] = alt;
                Q.emplace(Node(d[v],v));
            }
        }
    }
}

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

    int N, M, R; scanf("%d%d%d", &N, &M, &R);
    node_n = N+1;
    V<int> r = V<int>(R); rep(i,R) scanf("%d", &r[i]);
    edge_initializer(node_n);
    rep(i,M) {
        int a, b, c; scanf("%d%d%d", &a, &b, &c);
        edges[a].emplace_back(Edge(b, c));
        edges[b].emplace_back(Edge(a, c));
    }

    int r_d[201][201];
    sort(ALL(r));
    rep(i,R) {
        dijkstra(r[i]);
        rep(j,R) {
            r_d[r[i]][r[j]] = d[r[j]];
            r_d[r[j]][r[i]] = d[r[j]];
        }
    }

    int ans = INT_MAX;
    do {
        int t_ans = 0;
        rep(i,R-1) {
            t_ans += r_d[r[i]][r[i+1]];
        }
        ans = min(ans, t_ans);
    } while(next_permutation(ALL(r)));

    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 768
N = int(input())
H_list = input().split()
H_list_i = [int(h) for h in H_list]

count = 1
for k in range(1, N):
    if H_list_i[k - 1] <= H_list_i[k]:
        s = 0
        for l in range(k):
            if H_list_i[k] >= H_list_i[l]:
                s = s + 1
            else:
                break

        if s == k:
            count = count + 1
        s = 0
print(count)


Measured memory_bytes: 3060
#include<stdio.h>
int main(){
	int a, b, c, d;
	double e;
	scanf("%d%d", &a, &b);
	c=a/b;
	d=a%b;
	e=1.0*a/b;
	printf("%d ",c);
	printf("%d ",d);
	printf("%.5f\n",e);
	return 0;
}


Measured memory_bytes: 2108