akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;

public class Hello{
    public static void Main(){
        double x = double.Parse(System.Console.ReadLine());
        var price = new int[6]{100,101,102,103,104,105};
        var oneDig = new int[6]{0,1,2,3,4,5};
        var maxN = (int)Math.Floor(x / price.Min());
        var minN = (int)Math.Ceiling(x / price.Max());
        bool isOk = false;
        for(int i=minN;i<=maxN;i++){
            int y = (int)x - 100*i;
            for(int j=i;j>0;j--){
                y = y - oneDig.Where(p => p <= y).Max();
                if(y==0){
                    isOk = true;
                    break;
                }
            }
            if(isOk){
                break;
            }
        }
        if(isOk){
            System.Console.WriteLine(1);
        }else{
            System.Console.WriteLine(0);
        }
    }
}

Measured memory_bytes: 13396
#include <bits/stdc++.h>
using namespace std;
#define fori(i,n) for(int i =0;i<n;i++)
#define pb push_back
#define ll long long
#define int long long
#define F first
#define S second
#define mp make_pair
#define rev(a) reverse(a.begin(),a.end())
#define srt(a) sort(a.begin(),a.end())
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);cout.precision(15);
 
 
int mod = 1e9+7;
 
int pow(int a, int b) {
    int ans = 1;
    a %= mod;
    while(b) {
        if(b%2) {
            ans *= a;
            ans %= mod;
        }
        b /= 2;
        a *= a;
        a %= mod;
    }
    return ans;
}

int inv(int a) {
    return pow(a,mod-2);
}

int mul (int a,int b) {
    return ((a%mod)*(b%mod))% mod;
}

struct cmp {
    bool operator() (pair<int,int> a, pair<int,int> b) const {
        int x = a.F;
        int y = b.F;
        return x>=y;
    }
};


int32_t main() {
    FAST;
    int t;
    // cin>>t;
    t = 1;
    while(t--) {
        int a,b;
        cin>>a>>b;
        cout<<a*b;

    }
    
    return 0;
}

Measured memory_bytes: 3640
sum = 0

while n = gets
  a = n.to_i
  while sides = gets
    str_side = sides.split
    int_side = str_side.map(&:to_i)
    int_side.sort!
    if int_side[-1] ** 2 == (int_side[-2] ** 2) + (int_side[-3] ** 2)
      puts "YES"
      sum += 1
      if sum == a
        break
      end
    else
      puts "NO"
      sum += 1
      if sum == a
        break
      end
    end
  end
  break
end

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

// マクロ //
#define rep(v,times) for(int v = 0; v < (int)(times); v++)
#define req(v,first,endplus1) for(int v = first; v < (int)(endplus1); v++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vpii = vector<pii>;
using plili = pair<lint, lint>;
using vplili = vector<plili>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvli = vector<vli>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vvs = vector<vs>;
using mii = map<int, int>;
using mili = map<int, lint>;
using mci = map<char, int>;
using mcli = map<char, lint>;
using msi = map<string, int>;
using msli = map<string, lint>;


// 関数 //
template<class T, class Q> lint gcd_(T a, Q b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

template<class T, class Q> lint lcm_(T a, Q b) {
    return a * b / gcd_(a, b);
}

template<class T, class Q> double distance(T a, Q b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint combination(int n, int m) {
    long double c = 1;
    for (int i = n, k = 1; i > m; i--, k++) {
        c *= i;
        c /= k;
    }
    return (lint)c;
}

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

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

// 定数 //
const double pi = acos(-1);
const int mod = 1000000007;
const int inf = 1045141919;
const lint linf = ((1LL << 62) - 1);
const int dx4[4] = { 1,0,-1,0 };
const int dy4[4] = { 0,1,0,-1 };
const int dx8[8] = { 1,1,0,-1,-1,-1,0,1 };
const int dy8[8] = { 0,1,1,1,0,-1,-1,-1 };

// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
        
    int N;
    cin >> N;
    cout << (10000 - N) % 1000 << endl;

}

Measured memory_bytes: 3624
#include <iostream>
#include <algorithm>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
#define rep(i,a,b) for(int i=a;i<(b);++i)
typedef long long ll;
const ll INF = 1LL << 60;

ll dp[410][410];
ll a[410],b[410];

ll rec(int l,int r){
    if(l==r) return 0;
    if(dp[l][r]!=INF) return dp[l][r];
    ll ret = INF;
    for(int i=l;i<r;++i) ret = min(ret,rec(l,i) + rec(i+1,r) + b[r+1]-b[l] );
    return dp[l][r] = ret;
}

int main() {
    cin.tie(0); ios_base::sync_with_stdio(false);
    int N; cin >> N;
    REP(i,N){
        cin >> a[i];
        b[i+1] = b[i] + a[i];
    }
    REP(i,N+1) REP(j,N+1) dp[i][j] = INF;
    cout << rec(0,N-1) << endl;
    return 0;
}

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

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    N = I()
    t = S()
    if N % 2 > 0:
        print('No')
        return
    if t[:N//2] == t[N//2:]:
        print('Yes')
    else:
        print('No')

main()



Measured memory_bytes: 6480
#include <limits.h>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <queue>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REPS(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(10)

using namespace std;

typedef pair<int, int> P;

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T& t, const V& v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T& t, const V& v) {
    for (auto& e:t) fill_v(e, v);
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

    int N;
    cin >> N;
    vector<int> A(N);
    REP(i, N) cin >> A[i];

    auto dp = make_v<int>(N + 1, 2);
    dp[0][0] = 0;
    dp[0][1] = -INF;

    REP(i, N) {
        dp[i + 1][0] = max(A[i] + dp[i][0], -A[i] + dp[i][1]);
        dp[i + 1][1] = max(-A[i] + dp[i][0], A[i] + dp[i][1]);
    }
    cout << dp[N][0] << endl;

    return 0;
}


Measured memory_bytes: 6528
n = int(input())
s = input()

e_list = [0] * n
for i in range(n - 2, -1, -1):
    e_list[i] = (1 if s[i + 1] == "E" else 0) + e_list[i + 1]

w_list = [0] * n
for i in range(1, n):
    w_list[i] = (1 if s[i - 1] == "W" else 0) + w_list[i - 1]

print(min([e + w for e, w in zip(e_list, w_list)]))

Measured memory_bytes: 39200
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
using ll = long long;
using ldb = long double;
using pa = pair < ll, ll >;
using vec = vector < ll >;
 
template < typename T > using index_set = tree < T, null_type, less < T >, rb_tree_tag, tree_order_statistics_node_update >;
template < typename T > using MinPriorityQueue = priority_queue < T, vector < T >, greater < T > >;

#define pb push_back
#define po pop_back
#define mp make_pair
#define mt make_tuple
#define F  first
#define S  second
#define f(i,x,n) for(ll i=x;i<n;i++) 
#define all(c) c.begin(),c.end()
#define str string
#define edl "\n"
#define add insert
#define cot continue
#define fast() ios_base::sync_with_stdio(false);cin.tie(NULL)


const int MOD = 1e9 + 7, INF = INT_MAX, N = 1e5 + 10;
const double PI = acos(-1);
const ll LINF = LLONG_MAX;
int main() 
{

  fast();
  
    // #ifndef ONLINE_JUDGE
    //   freopen("input.txt", "r", stdin);
    //   freopen("output.txt","w",stdout);
    // #endif
    
    ll n;
    cin>>n;
    vec q(n+1),q1(n);
  
    f(i,0,n+1)
    {
      cin>>q[i];

    }
   
    

    f(i,0,n)
    {
      cin>>q1[i];
    }
    ll c=0,c1=0,c2=0;
    f(i,0,n)
    {
      c1=0;
      c2=0;
      c2=min(q[i],q1[i]);
      c+=c2;
      // cout<<c<<" ";
      q1[i]-=c2;
      // cout<<q1[i]<<" ";
      c1=min(q1[i],q[i+1]);
      // cout<<c1<<" ";

      q[i+1]-=c1;
   
      c+=c1;
     
    }
    cout<<c;












  


    
    cerr << "Time taken: " << int((clock() * 1000.) / CLOCKS_PER_SEC) << "ms\n";
    return 0;
}
 

Measured memory_bytes: 1792
#include<stdio.h>

int main(void){
    int N=0;
    int L[101];
    int max=0,sum=0;
    scanf("%d",&N);
    for (int i=0;i<N;i++){
        scanf("%d",&L[i]);
        if(max<L[i]) max=L[i];
        sum+=L[i];
    }
    if(max<sum-max){
        printf("Yes\n");
    }
    else printf("No\n");
    return 0;
}

Measured memory_bytes: 128
/********************/
/* K B G D E L T A */
/*     DA-IICT      */
/********************/
 
#include<bits/stdc++.h>
using namespace std;
using   ll=long long;
using   ld=long double;
#define fast           ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define endl           "\n"
#define F(i,n)         for(ll i=0;i<n;i++)
#define rep(i,a,b,c)   for(ll i=a;i<b;i+=c)
#define repp(i,a,b)    for(ll i=a;i>=b;i--)
#define pb             push_back
#define mp             make_pair
#define vll            vector<ll>
#define f              first
#define s              second
#define pll            pair<ll,ll>
#define ALL(v)         v.begin(),v.end()
#define ALLR(v)        v.rbegin(),v.rend()
#define pii            3.14159265358979323
 
void solve()
{
	ll n;
	
	cin>>n;
	
	vector<ll> a(n);
	
	F(i,n)	cin>>a[i];
	
	ll cnt=0;
	
	vector<ll> tt(n+1,n+1);
	
	for(ll i=0;i<n;i++)
	{
		if(a[i]==1)
		{
			tt[a[i]]=min(tt[a[i]],i+1);
		}
		else
		{
			if(i+1>tt[a[i]-1])
			{
				tt[a[i]]=min(tt[a[i]],i+1);
			}
		}
	}
	
	for(ll i=1;i<=n;i++)
	{
		if(tt[i]==n+1)	break;
		
		else	cnt++;
	}
	
	if(cnt>0)
	{
		cout<<n-cnt;
	}
	else
	{
		cout<<-1;
	}
}

 
signed main(){
 
    fast;
 
    ll t;
    
    t=1;
    
    while(t--)
    {
        solve();
    }
 
    return 0;
}

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

#define int long long
#define fi first
#define se second
#define pb push_back
#define ins insert
#define er erase

typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef pair<ii, ii> iiii;

const int oo = 1e18 + 7, mod = 1e9 + 7;

int n, x[100005], L, q;
int sparse[100005][17];

signed main(){
	ios_base::sync_with_stdio(0);
	cin >> n;
	for(int i = 1; i <= n; i++) cin >> x[i];
	cin >> L;
	x[n + 1] = oo;
	for(int i = 1; i < n; i++){
	    int l = i + 2, r = n + 1;
	    while(l != r){
	        int mid = (l + r) >> 1;
	        if((x[mid] - x[i]) <= L) l = mid + 1;
	        else r = mid;
	    }
	    l--;
	    sparse[i][0] = l;
	    //cout << i << " " << 0 << " " << sparse[i][0] << "\n";
	}
	for(int i = 1; i <= 16; i++){
	    for(int j = 1; j <= n; j++){
	        sparse[j][i] = sparse[sparse[j][i - 1]][i - 1];
	        if(!sparse[j][i]) sparse[j][i] = n;
	        //cout << i << " " << j << " " << sparse[j][i] << "\n";
	    }
	}
	cin >> q;
	while(q--){
	    int a, b, ans = 0;
	    cin >> a >> b;
	    if(a > b) swap(a, b);
	    for(int i = 16; i >= 0; i--){
	        if(sparse[a][i] < b){
	            ans += (1 << i);
	            a = sparse[a][i];
	        }
	    }
	    ans++;
	    cout << ans << "\n";
	}
}



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

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();}

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

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

#define en "\n"

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int INT_INF = 2147483647;
const long long LL_INF = 1LL<<60;
const long long MOD = 1000000007; // 998244353

#define CLR(a) memset((a), 0, sizeof(a))

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

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; }

vector<int> compress(vector<int> &v){
    int N = v.size(), mn = 1000000000;
    vector<int> res(N);
    vector<pair<int,int>> a(N);
    for(int i=0; i<N; ++i){
        a[i].first = v[i];
        a[i].second = i;
        mn = min(mn, v[i]);
    }
    sort(a.begin(), a.end());
    
    int prev = mn-1, n = -1;
    for(int i=0; i<N; ++i){
        if(a[i].first == prev) res[a[i].second] = n;
        else{
            n++;
            prev = a[i].first;
            res[a[i].second] = n;
        }
    }
    
    return res;
}

int main(void){
    int N; cin >> N;
    VI A(N); REP(i,N) cin >> A[i];
    A = compress(A);
    int ans = 0;
    REP(i,N/2) if(A[2*i+1]%2 == 0) ans++;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1920
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <cassert>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>
#include <random>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int h, w; cin >> h >> w;
  vector<int> mat(h*1000+w, INT_MAX/2);

  priority_queue<P, vector<P>, greater<>> que;

  rep(i, h) {
    rep(j, w) {
      char c; cin >> c;
      if (c == '#') {
        mat[i*1000+j] = 0;
        que.emplace(0, i*1000+j);
      }
    }
  }

  while(!que.empty()) {
    P p = que.top(); que.pop();
    int i = p.second/1000;
    int j = p.second%1000;
    int cost = p.first;
    if (i>0) {
      int pos = (i-1)*1000+j;
      if (mat[pos] > cost+1) {
        mat[pos] = cost+1;
        que.emplace(cost+1, pos);
      }
    }
    if (j>0) {
      int pos = i*1000+j-1;
      if (mat[pos] > cost+1) {
        mat[pos] = cost+1;
        que.emplace(cost+1, pos);
      }
    }
    if (i<h-1) {
      int pos = (i+1)*1000+j;
      if (mat[pos] > cost+1) {
        mat[pos] = cost+1;
        que.emplace(cost+1, pos);
      }
    }
    if (j<w-1) {
      int pos = i*1000+j+1;
      if (mat[pos] > cost+1) {
        mat[pos] = cost+1;
        que.emplace(cost+1, pos);
      }
    }
  }
  
  int ma = 0;
  rep(i, h) {
    rep(j, w) {
      chmax(ma, mat[i*1000+j]);
    }
  }
  cout << ma << endl;
}

Measured memory_bytes: 21864
N = int(input())
l = list(map(int, input().split()))
ans = 0

for i in range(N-1):
    if l[i] == i+1:
        l[i], l[i+1] = l[i+1], l[i]
        ans += 1
if l[-1]==N:
    ans += 1

print(ans)

Measured memory_bytes: 14008
def pow_k(x, n):
    """
    O(log n)
    """
    if n == 0:
        return 1

    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2

    return K * x

x = int(input())

for i in range(-1000,1000):
  for j in range(-1000,1000):
    if pow_k(i,5) - pow_k(j,5) == x:
      print(i,j)
      exit()

Measured memory_bytes: 9140
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
typedef long long ll;
using namespace std;
const ll INF = 1e9;
const ll MOD = 1e9 + 7;
#define repi(i, n, init) for (ll i = init; i < (n); i++)

int main()
{
    int n;
    cin >> n;
    string s;
    cin >> s;
    vector<int> whsum(n + 1, 0), blsum(n + 1, 0);
    repi(i, n, 0)
    {
        whsum[i + 1] = whsum[i] + (s[i] == '.' ? 1 : 0);
        blsum[i + 1] = blsum[i] + (s[i] == '#' ? 1 : 0);
    }
    int ans = INF;
    repi(left, n + 1, 0)
    {
        int tmp = 0;
        tmp += blsum[left];
        tmp += whsum[n] - whsum[left];
        ans = min(tmp, ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2180
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<algorithm>
#include<vector>

int main() {
   
   int N;
   int A, B;
   std::cin >> N;
   if (N == 1) std::cout << "Hello World" << std::endl;
   else {
      std::cin >> A >> B;
      std::cout << A + B << std::endl;
   }
   return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main()
{
	int a,b;
	cin>>a>>b;
	if(a > 0)
	{
		cout<<"Positive\n";
	}
	else if(a == 0)
	{
		cout<<"Zero\n";
	}
	else
	{
		if(b < 0)
		{
			b-=a;
			if(b%2)
				cout<<"Positive\n";
			else
				cout<<"Negative\n";
		}
		else
		{
			cout<<"Zero\n";
		}
	}
	return 0;
}

Measured memory_bytes: 256
//
// Created by rajshah9914 on 29/03/20.
//

//
// Created by rajshah9914 on 29/03/20.
//

#include <bits/stdc++.h>
using namespace std;
const int INF=1e9+5;
int main() {
    int n;
    cin>>n;
    int a[100005][3],dp[100005][3];
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=2;j++)
            cin>>a[i][j];
    }
    dp[0][0]=a[0][0];
    dp[0][1]=a[0][1];
    dp[0][2]=a[0][2];
    for(int i=1;i<n;i++)
    {
        dp[i][0]=max(dp[i-1][1],dp[i-1][2])+a[i][0];
        dp[i][1]=max(dp[i-1][0],dp[i-1][2])+a[i][1];
        dp[i][2]=max(dp[i-1][1],dp[i-1][0])+a[i][2];
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2])<<endl;
}


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

#if MYDEBUG
#include "lib/cp_debug.hpp"
#else
#define DBG(...) ;
#endif
#if __cplusplus <= 201402L
template <typename T>
T gcd(T a, T b) { return ((a % b == 0) ? b : gcd(b, a % b)); }
template <typename T>
T lcm(T a, T b) { return a / gcd(a, b) * b; }
#endif
using LL = long long;
constexpr LL LINF = 334ll << 53;
constexpr int INF = 15 << 26;
constexpr LL MOD = 1E9 + 7;

namespace Problem {
using namespace std;

class Solver2 {
 public:
  int n, u, v;
  vector<vector<int>> t;
  vector<int> dep, dep2, istakahashi, tkhs;
  int mt;
  Solver2(LL n, LL u, LL v) : n(n), u(u), v(v), t(n), dep(n), dep2(n), istakahashi(n), tkhs(n), mt(0){};

  void solve() {
    for (int i = 0; i < n - 1; ++i) {
      int a, b;
      cin >> a >> b;
      --a;
      --b;
      t[a].push_back(b);
      t[b].push_back(a);
    }
    --u, --v;
    dfs(v);
    dfs2(u);
    int ans = 0;
    for (int i = 0; i < n; ++i) {
      if (dep2[i] < dep[i]) {
        ans = max(ans, dep[i] - 1);
      }
    }
    cout << ans << endl;
  }

  void dfs(int c, int p = -1, int d = 0, int takahashi = 0) {
    if (c == u) {
      takahashi++;
    }
    dep[c] = d;
    if (takahashi) {
      mt = max(mt, d);
    }
    for (auto v : t[c]) {
      if (v != p) {
        dfs(v, c, d + 1, takahashi);
      }
    }
  }
  void dfs2(int c, int p = -1, int d = 0) {
    dep2[c] = d;
    for (auto v : t[c]) {
      if (v != p) {
        dfs2(v, c, d + 1);
      }
    }
  }
};
}  // namespace Problem

int main() {
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(false);
  // std::cout << std::fixed << std::setprecision(12);
  long long n = 0, u, v;
  std::cin >> n >> u >> v;

  Problem::Solver2 sol(n, u, v);
  sol.solve();
  return 0;
}


Measured memory_bytes: 9984
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = int64_t;
using P = pair<ll, ll>;
template <class T>
using V = vector<T>;

const ll mod = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  string s1, s2;
  cin >> s1 >> s2;

  V<int> d;
  rep(i, n) {
    if (s1[i] == s2[i]) {
      d.push_back(1);
    } else {
      i++;
      d.push_back(2);
    }
  }
  int l = d.size();
  ll ans = (d[0] == 1) ? 3 : 6;
  for (int i = 1; i < l; i++) {
    if (d[i] == 1) {
      if (d[i - 1] == 1) ans = ans * 2 % mod;
    } else {
      if (d[i - 1] == 1) ans = ans * 2 % mod;
      if (d[i - 1] == 2) ans = ans * 3 % mod;
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 3516
def main():
	A, B, K = map(int,input().split())
	head = min(A+K-1, B)
	tail = max(B-K, A)
	if tail < head:
		tail = head

	for i in range(A, head+1):
		print(i)

	for i in range(tail+1, B+1):
		print(i)


if __name__ == '__main__':
	main()

Measured memory_bytes: 3060
import java.io.*;

public class Main {
  public static void main(String[] args) throws IOException {
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    
    String[] data = br.readLine().split(" ");
    
    int[] n = new int[4];
    
    for (int i=0; i<4; i++){
      n[i] = Integer.parseInt(data[i]);
    }
    
    int result = 0;
    if (n[0] < n[2]){
      if (n[1] < n[3]){
        result = Math.max(n[1] - n[2], 0);
      } else {
        result = n[3]-n[2];
      }
    } else {
      if (n[3] < n[1]){
        result = Math.max(n[3] -n[0], 0);
      } else {
        result = n[1]-n[0];
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 22612
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <iostream>
#include <stack>
#include <queue>
#include <math.h>
#include <set>
#include <map>
#include <string>
#include <list>
#include <string.h>
using namespace std;
typedef long long int ll; typedef pair <double, double> P;
const int INF = 1000000000; const double EPS = 10e-9;
const double g = 9.8;
int n, v, X, Y;
struct block {
	int l, b, r, t;
	block(int L, int B, int R, int T)
	{
		l = L; b = B; r = R; t = T;
	}
	block() {};
};
block bl[50];
double calc(double vy, double t)
{
	return vy * t - g * t * t / 2;
}
int comp(double lb, double rb, double a)
{
	return lb + EPS > a ? -1 : rb - EPS < a ? 1 : 0;
}
bool check(int x, int y)
{
	double a = g * g / 4, b = g * y - v * v, c = x * x + y * y;
	double D = b * b - 4 * a * c;
	if (D > -EPS && D < 0) D = 0;
	if (D < 0) return false;
	for (int d = -1; d <= 1; d += 2)
	{
		double t2 = (-b + d * sqrt(D)) / (2 * a);
		if (t2 <= 0) continue;
		double t = sqrt(t2);
		double vx = x / t;
		double vy = sqrt(v * v - vx * vx);
		double loc = calc(vy, X / vx);
		if (loc < Y - EPS) continue;
		bool res = true;
		for (int i = 0; i < n; i++)
		{
			if (bl[i].l > X) continue;
			if (X == bl[i].r && loc >= bl[i].b - EPS && bl[i].t + EPS >= Y) res = false;
			int lh = comp(bl[i].b, bl[i].t, calc(vy, bl[i].l / vx));
			int rh = comp(bl[i].b, bl[i].t, calc(vy, bl[i].r / vx));
			int mw = comp(bl[i].l, bl[i].r, vx* vy / g);
			int mh = comp(bl[i].b, bl[i].t, calc(vy, vy / g));
			if (lh * rh <= 0) res = false;
			if (mw == 0 && lh < 0 && mh >= 0) res = false;
		}
		if (res) return res;
	}
	return false;
}
int main() 
{
	cin >> n >> v >> X >> Y;
	for (int i = 0; i < n; i++)
	{
		int l, b, r, t; cin >> l >> b >> r >> t;
		r = min(r, X);
		bl[i] = block(l, b, r, t);
	}
	bool res = check(X, Y);
	for (int i = 0; i < n; i++)
	{
		res |= check(bl[i].l, bl[i].t);
		res |= check(bl[i].r, bl[i].t);
	}
	puts(res ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3088
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()
// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


void solve(void)
{
  int N;
  cin>>N;
  vector<int> S(N);
  for (int i = 0; i < N; i++)
  {
    cin>>S[i];
  }
  int ANS = 0;
  for (int C = 0; C < N; C++)
  {
    int SCORE = 0;
    set<int> st;
    for (int X = 0; X < N; X++)
    {
      if(X*C > N)break;
      int A = (N-1) - X*C;
      if(A <= C)break;
      int P1 = X*C;
      if(st.insert(P1).second == false) break;
      SCORE += S[P1];
      int P2 = N-1 - X*C;
      if(st.insert(P2).second == false) break;
      SCORE += S[P2];
      // DEBUG(SCORE);
      chmax(ANS,SCORE);
    }
    
  }
  
  cout<<ANS<<endl;
  
  
  
  return;
}


int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();
  

 
  return 0;
}


Measured memory_bytes: 7552
import java.util.*;

public class Main {
	public static void main (String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int count = 0;
		for (int i = 0; i < n; i++) {
		    if (i % 2 == 0 & sc.nextInt() % 2 == 1) {
		        count++;
		    }
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 35692
import java.util.Scanner;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int H = scanner.nextInt();
        int W = scanner.nextInt();

        int[][] map = new int[H + 2][W + 2];

        for (int i = 0; i < H; i++) {
            String str = scanner.next();
            for (int j = 0; j < W; j++) {
                String word = str.substring(j, j + 1);
                if (word.equals("#")) {
                    map[i + 1][j + 1] = -100;
                    for (int k = 0; k < 3; k++) {
                        for (int l = 0; l < 3; l++) {
                            map[i + k][j + l]++;
                        }
                    }
                }
            }
        }

//        for (int i = 0; i < H + 2; i++) {
//            for (int j = 0; j < W + 2; j++) {
//                System.out.print(map[i][j]);
//            }
//            System.out.println();
//        }

        for (int i = 0; i < H; i++) {
            for (int j = 0; j < W; j++) {
                if (map[i + 1][j + 1] < 0) {
                    System.out.print("#");
                } else {
                    System.out.print(map[i + 1][j + 1]);
                }
            }
            System.out.println();
        }
    }
}

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

using int64 = int64_t;
#define int int64

constexpr int MAX_N = 3e5+1;
constexpr int MOD = 1e9+7;

int fact[MAX_N];
int ifact[MAX_N];

int power(int x, int n) {
	int res = 1LL;
	while (n > 0) {
		if (n & 1) (res *= x) %= MOD;
		(x *= x) %= MOD;
		n >>= 1;
	}
	return res % MOD;
}

int inv(int x) {
	return power(x, MOD - 2);
}

int nCr(int n, int r) {
	if (n < 0 || r < 0 || r > n) return 0;
	if (r > n / 2) r = n - r;
	return fact[n] * ifact[r] % MOD * ifact[n - r] % MOD;
}

void init_fact() {
  fact[0] = ifact[0] = 1;
	for (int i=1; i<MAX_N; ++i) {
		(fact[i] = fact[i - 1] * i) %= MOD;
		ifact[i] = inv(fact[i]);
	}
}

signed main() {
  int n,k; cin>>n>>k;
  init_fact();

  for(int i=1;i<=k;++i){
    int ans = nCr(n-k+1,i)*nCr(k-1,i-1)%MOD;
    cout << ans << endl;
  }
}


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

typedef long long ll;
const ll InF = 1e15;


int main() {
  int N,M;
  cin>>N>>M;
  vector<pair<int, vector<int>>> pairs(M);
  vector<int> p(M);
  for (int i = 0; i < M; i++) {
    int c; cin>>c;
    pairs[i].first = c;
    for (int j = 0; j < c; j++) {
      int t;
      cin>>t;
      t--;
      pairs[i].second.push_back(t);
    }
  }
  for (int i = 0; i < M; i++) cin>>p[i];
  int ans = 0;
  for (int i = 0; i < 1 << N; i++) {
    bool ok = true;
    for (int j = 0; j < M; j++) {
      int c = pairs[j].first;
      int res = 0;
      vector<int> v = pairs[j].second;
      for (int k = 0; k < c; k++) {
        if ((i >> v[k]) & 1) res++;
      }
      if (res % 2 != p[j]) {
        ok = false;
        break;
      }
    }
    if (ok) ans++;
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;
const int MAX = 200020;

int dx[4] = { 0,0,1,-1 };
int dy[4] = { 1,-1,0,0 };


bool f(int K,int A){ 
	int x = (K + 1) / 2;
	ll res = 0;
	if (x > 0) {
		res = max(res, x * (K - x + 1));
	}
	if (K % 2 == 0) {
		x++;
		res = max(res, x * (K - x + 1));
	}
	return res < A;
}

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

	int Q; cin >> Q;
	REP(i, Q) {
		int A, B;
		cin >> A >> B;
		int ok = 0; int ng = 2e9;
		int mid = (ok + ng) / 2;
		int K = A * B;
		while (abs(ok - ng) > 1) {
			mid = (ok + ng) / 2;
			//printf("ok:%lld ng:%lld mid:%lld\n", ok, ng, mid);
			if (f(mid, K)) {
				ok = mid;
			}
			else ng = mid;
		}
		if (A == (ok + 2) / 2 && B == (ok + 2) / 2) {

		}
		else {
			ok--;
		}
		print(ok);
	}
}


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

int bubble_sort(int A[], int n) {
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++) {
        flag = 0;
        for (int j = n - 1; j >= i + 1; j--) {
            if (A[j] < A[j - 1]) {
                swap(A[j], A[j - 1]);
                flag = 1;
                ++sw;
            }
        }
    }
    return sw;
}

void Main() {
    int n;
    cin >> n;
    int A[100];
    rep(i, n) cin >> A[i];
    int ans;
    ans = bubble_sort(A, n);
    rep(i, n) {
        if (i) cout << " ";
        cout << A[i];
    }
    cout << "\n" << ans << "\n";
}
int main() {
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}


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


#define ALL(a) 		(a.begin() , a.end())
#define ll 			long long int
#define ff          first
#define ss          second
#define pb          push_back
#define ar 			array
#define mp 			make_pair
#define f(i,a,b)   	for(ll i =a;i<=b;i++)
#define inf 		INT_MAX
#define pll 		pair<ll,ll>
#define mat 		vector<vector<ll>>

#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifndef ONLINE_JUDGE
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
	*this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define deb(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
 //debug & operator << (debug & dd, P p) { dd << "(" << p.x << ", " << p.y << ")"; return dd; }
 

const ll INF = 1e18;
void init(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE 
		freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);
#endif
}
 
bool checkp2(ll n){
	return n && !(n & (n-1));
}

ll numsetbit(ll n){
	ll count = 0;
	for(;n;count++){
		n = n & (n-1);
	}
	return count;
}
 
ll power(ll x , ll n , ll mod){
    x = x % mod;
	ll po = 1;
	while(n){
		if(n & 1){
			po = (po*x) % mod;
		}
		n = n>>1;
		x = ((x % mod) * (x % mod)) % mod;
	}
	return po;
}
 
bool isPrime(ll x){
	if(x < 2)
		return 0;
	for(ll y = 2; y * y <= x; y++){
		if(x % y == 0){
			return 0;
		}
	}
	return true;
}







void solve(){

		string s , t;
		cin>>s>>t;
		ll sl = s.length();
		ll tl = t.length();

		ll answer = tl;

		for(ll i = 0;i<=sl - tl;i++){

			ll cnt = 0;
			for(ll j = 0;j<tl;j++){
				if(s[i + j] != t[j]){
					cnt++;
				}
			}
			answer = min(answer , cnt);

		}

		cout<<answer<<endl;

}

int main(){
	
	init();
	ll t = 1;
	//cin>>t;
	for(ll i=1;i<=t;i++){
		//cout<<"Case #"<<i<<": ";
		solve();
	}
}

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

int main(){
 int w,h,x,y,r;
cin >>w>>h>>x>>y>>r;
if((x+r)<=w && (x-r)>=0 && (y+r)<=h && (y-r)>=0){
cout << "Yes"<<endl;
}else{
cout <<"No"<<endl;
}
    return 0;
}

Measured memory_bytes: 1160
/*
20/7/27
*/
#include <bits/stdc++.h>
using namespace std;

typedef vector< vector<int> > vvi;
typedef vector< vector<bool> > vvb;
typedef vector< vector<char> > vvc;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef long long ll;

int main(){
    long long x;
    cin >> x;
    for(int i=0;i<1000;i++){
        bool flag=0;
        for(int j=-1000;j<1000;j++){
            if(x==i*i*i*i*i-j*j*j*j*j){
                cout << i << " " << j << endl;
                flag=1;
                break;
            }
        }
        if(flag) break;
    }
}

Measured memory_bytes: 3596
#! -*- coding: utf-8-unix -*-
import math

if __name__=='__main__':
  n = int(raw_input())
  for i in xrange(n):
    x1, y1, x2, y2, x3, y3, x4, y4 = map(float, raw_input().strip().split(' '))
    if math.fabs((y2 - y1) * (x4 - x3) - (y4 - y3) * (x2 - x1)) < 1e-10:
      print 'YES'
    else:
      print 'NO'

Measured memory_bytes: 4372
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
int comp(const void *p,const void *q){
	return *(int *)p - *(int *)q;
}
int m[105];
int main(){
	int i,n,p,b;
	char s[105];
	while(1){
		scanf("%d",&n);
		if(n==0)break;
		memset(m,0,sizeof(m));
		scanf("%s",s);
		p=0;
		b=0;
		for(i=0;i<100;i++){
			if(s[i]=='M')m[p]++;
			else if(s[i]=='S'){
				b+=m[p]+1;
				m[p]=0;
			}
			else{
				m[p]+=b+1;
				b=0;
			}
			p++;
			p%=n;
		}
		//for(i=0;i<n;i++)printf("%d ",m[i]);
		//printf("%d\n",b);
		qsort(m,n,sizeof(int),comp);
		for(i=0;i<n;i++)printf("%d ",m[i]);
		printf("%d\n",b);
	}
	return 0;
}

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

int main(){
	int n,x,a[100];
	int sum,cnt,p;
	for(;;){
		sum=0;
		cnt=0;
		cin>>n>>x;
		if(n==0&&x==0) break;
		for(int i=0;i<n;i++){
			a[i]=i+1;
		}
		for(int i=0;i<n-2;i++){
			for(int j=i+1;j<n-1;j++){
				for(int k=j+1;k<n;k++){
					p=k;
					sum=a[i]+a[j]+a[k];
					if(sum==x)
						cnt++;
				}
			}
		}
		cout<<cnt<<endl;
	}
	return 0;
}

Measured memory_bytes: 1164
#include <iostream> // cin, cout, cerr
#include <algorithm> // minmax, sort, swap
#include <numeric> // iota
#include <cstdio> // printf, scanf
#include <string> // string, stoi, to_string
#include <vector> // vector
#include <queue> // queue, priority_queue
#include <deque> // deque
#include <map> // key-value pairs sorted by keys
#include <set> // set
#include <iomanip> // cout<<setprecision(n)
#include <functional> // function<void(int)>

#ifdef DEBUG
#include "debug.hpp"
#else
#define debug(...)
#endif

#define int long long // at least int64 > 9*10^18
#define ENDL '\n'
#define rep(i,n) for(int i = 0; i < (n); i++)
#define print(i) std::cout << (i) << '\n'
#define all(v) (v).begin(), (v).end()
/* libraries */

signed main() {
	int n,k;
	std::cin >> n >> k;
	std::vector<int> a(n);
	rep(i,n) {
		std::cin >> a[i];
		a[i]-=1;
		a[i]%=k;
	}
	std::vector<int> ac(n+1,0);
	rep(i,n) ac[i+1] = (ac[i] + a[i])%k;
	debug(ac);
	int count = 0;
	// from the back count the numbers
	std::map<int,std::vector<int> > map;
	for(int i=n;i>=0;i--) {
		int x=std::lower_bound(map[ac[i]].rbegin(),map[ac[i]].rend(),i+k)-map[ac[i]].rbegin();
		debug(i,x,ac[i],map[ac[i]]);
		count+=x;
		map[ac[i]].emplace_back(i);
	}
	print(count);
	return 0;
}


Measured memory_bytes: 25216
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10 ** 7)

n = int(input())
a = list(map(int, input().split()))

LIMIT = 10 ** 18

ans = 1
if 0 in a:
    print(0)
    sys.exit(0)
for i in a:
    ans *= i
    if ans > LIMIT:
        print(-1)
        sys.exit(0)
print(ans)


Measured memory_bytes: 83224
#include<cstdio>
#include<algorithm>
#include<cstring>
#define ll long long
using namespace std;
const ll MOD=998244353;
int n,k;
ll fact[500005],inv[500005];
ll quick_pow(ll x,ll a)
{
	ll ans=1;
	while(a)
	{
		if(a&1)ans=ans*x%MOD;
		x=x*x%MOD;
		a>>=1;
	}
	return ans;
}
int main()
{
	scanf("%d%d",&n,&k);
	fact[0]=1;
	for(int i=1;i<=500000;i++)fact[i]=fact[i-1]*i%MOD;
	inv[500000]=quick_pow(fact[500000],MOD-2);
	for(int i=500000;i>=1;i--)inv[i-1]=inv[i]*i%MOD;
	ll ans=0;
	for(int r=k;r*2>=k;r--)
	{
		int b=k-r;
		if(b==r)b--;
		if(r-n<0)break;
		ans+=fact[r+b]*inv[r]%MOD*inv[b]%MOD;
		if(r-n+1<=b)ans-=fact[r+b]*inv[b-(r-n+1)]%MOD*inv[r+(r-n+1)]%MOD;
	}
	ans%=MOD;
	if(ans<0)ans+=MOD;
	printf("%lld\n",ans);
	return 0;
}

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

int main() {
	int w,n;
	scanf("%d %d",&w,&n);
	int a[n];
	int b[n];
	for(int i=0;i<n;i++){
		scanf("%d,%d",&a[i],&b[i]);
	}
	int ans[w+1];
	for(int i=1;i<=w;i++)ans[i]=i;
	int temp;
	for(int i=0;i<n;i++){
		temp=ans[a[i]];
		ans[a[i]]=ans[b[i]];
		ans[b[i]]=temp;
	}
	for(int i=1;i<=w;i++){
		cout<<ans[i]<<endl;
	}
	return 0;
}

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


int main(){
    long n,m;
    cin>>n>>m;
    vector<string> a(n),b(n);
    for(int i = 0; i < n; i++)
        cin>>a[i];
    for(int i = 0; i < m; i++)
        cin>>b[i];
    for(int i = 0; i <=n-m; i++){
        for(int j = 0; j <=n-m; j++){
            bool jud=true;
            for(int k = 0; k < m; k++){
                if(b[k]!=a[j+k].substr(i,m)){
                    jud=false;
                    break;
                }
            }
            if(jud){
                cout<<"Yes";
                return 0;
            }
        }
    }
    cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>
#include<map>
#include<algorithm>
using namespace std;
//1-indexed
#include<vector>
template<typename T>
struct BIT{
	int n;
	vector<T>bit;
	BIT(int n_=0,T a=0):n(n_),bit(n_+1,a){}
	T sum(int i)
	{
		T ans=0;
		for(;i>0;i-=i&-i)ans+=bit[i];
		return ans;
	}
	void add(int i,T a)
	{
		if(i==0)return;
		for(;i<=n;i+=i&-i)bit[i]+=a;
	}
};
int n;
long K,a[2<<17];
long sum[2<<17];
main()
{
	cin>>n>>K;
	for(int i=0;i<n;i++)
	{
		cin>>a[i];
		a[i]-=K;
	}
	for(int i=0;i<n;i++)sum[i+1]=sum[i]+a[i];
	map<long,int>M;
	vector<long>S;
	for(int i=0;i<=n;i++)S.push_back(sum[i]);
	sort(S.begin(),S.end());
	S.erase(unique(S.begin(),S.end()),S.end());
	for(int i=0;i<S.size();i++)M[S[i]]=i+1;
	BIT<int> P(S.size());
	long ans=0;
	for(int i=0;i<=n;i++)
	{
		ans+=P.sum(M[sum[i]]);
		P.add(M[sum[i]],1);
	}
	cout<<ans<<endl;
}


Measured memory_bytes: 18672
#include<cstdio>
#include<algorithm>
using namespace std;
const int N=1001000;
int ii,i,j,k,l,n,m,ch,Last,ans;
char s[N],t[N],f[N];
struct cc { int x,l,r;} A[N];
int main() {
	scanf("%d",&n);
	scanf("%s",s+1);
	scanf("%s",t+1);
	for (i=1;i<=n;i++) if (s[i]!=t[i]) break;
	if (i>n) return puts("0"),0;
	Last=n;
	for (i=n;i;i--) {
		j=i;
		while (j && t[j-1]==t[i]) j--;
		k=min(j,Last);
		while (k && s[k]!=t[j]) k--;
		if (!k) return puts("-1"),0;
		A[k].x=k;
		A[k].l=j;A[k].r=i;
		Last=k-1;
		i=j;
	}
	for (i=1;i<=n;i++) if (A[i].x) A[++m]=A[i];
	ans=1;f[m]=1;j=m+1;
	for (i=m-1;i;i--) {
		while (j>i && A[j-1].x-(j-1-i)>=A[i].r) j--;
		if (j-i>ans) ans=j-i;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 14848
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main()
{
    int n;
    cin >> n;
    int a[n];
    rep(i, 0, n) cin >> a[i];
    rep(i, 0, n) {
        int tmp = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > tmp) {
            a[j + 1] = a[j];
            j --;
        }
        a[j + 1] = tmp;
        rep(i, 0, n) {
            if (i == n - 1) {
                cout << a[i] << endl;
            } else {
                cout << a[i] << " ";
            }
        }
    }
    return 0;
}



Measured memory_bytes: 3124
/*#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

#include <boost/rational.hpp>
*/
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
using ll = long long;
using ld = long double;
#define rep2(i, s, n) for (ll i = (s); i < (ll)(n); i++)
#define rep3(i, n) for (ll i = 1; i < (ll)(n+1); i++)
#define rep4(i, s, n) for (ll i = (s); i < (ll)(n+1); i++)
#define repr(i,n) for (ll i = (n-1); i>=0;i--)
#define repr3(i,n) for(ll i = (n);i>0;i--)
#define stlen(s) ll s.size()-1
#define all(v) v.begin(), v.end()
#define cout(n) cout<<std::fixed<<std::setprecision(n)
using Graph = vector<vector<int>>;
#define INF1  INT_MAX;
#define INF2  LLONG_MAX;
#define PI  3.14159265358979323846;
#define MOD 1000000007;
/*
namespace mp = boost::multiprecision;
// 任意長整数型
using Bint = mp::cpp_int;
// 仮数部長が32の浮動小数点数型
using Real32 = mp::number<mp::cpp_dec_float<32>>;
// 仮数部長が1024の浮動小数点数型
using Real1024 = mp::number<mp::cpp_dec_float<1024>>;
// 有理数型
using Rat = boost::rational<Bint>;
*/

long long GCD(long long a, long long b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}

long long LCM(long long a, long long b) {
    return a / GCD(a, b) * b;
}

int main() {
  int N;
  cin>>N;
  int A[N];
  rep(i,N){
    cin>>A[i];
  }
  ll l[N];
  ll r[N];
  l[0]=A[0];
  r[N-1]=A[N-1];
  rep2(i,1,N){
    l[i]=GCD(l[i-1],A[i]);
  }
  repr(i,N-1){
    r[i]=GCD(r[i+1],A[i]);
  }
  ll ans =1;
  rep(i,N){
    if(i==0){
      ans=max(ans,r[1]);
    }
    else if(i==N-1){
      ans=max(ans,l[N-2]);
    }
    else{
      ans=max(ans,GCD(l[i-1],r[i+1]));
    }
  }
  cout<<ans<<endl;


return 0;
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,i,e,f,g,n,m,k,l;
string s,s1,s2,s3;
int main() {
           cin>>s;
           for(long long i=0;i<s.size();i++)
           cout<<'x';
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;
const int INF = 1e9;


int main(void){
    int a,b;
    cin>>a>>b;
    cout<<(a-1)*(b-1)<<endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>
#include<cstdio>
#include<string>
#include<cstring>
#include<algorithm>
#include<stack>
#include<queue>
#include<deque>
#include<cmath>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#define IN
using namespace std;
template<typename T>void scan(T &x)
{
    char ch;
    bool f=0;
    x=0;
    ch=getchar();
    while(!isdigit(ch)&&ch!='-')
        ch=getchar();
    if(ch=='-') f=1,ch=getchar();
    while(isdigit(ch))
        x=x*10+ch-'0',ch=getchar();
    if(f==1) x=-x;
}
int m,n,s;
int main()
{
    scan(m),scan(n);
    s=n/m;
    for(register int i=s;i>=1;i--)
        if(n%i==0) 
        {
            printf("%d\n",i);
            exit(0);
        }
    return 0;
}

Measured memory_bytes: 256