akhauriyash/Code-Regression huggingface dataset:
//DEEPANSHU RAWAT
    //BTECH/10530/18
     
    #include<bits/stdc++.h>
    #define ull unsigned long long
    #define lld long long int
    #define infi LLONG_MAX
    #define ninfi LLONG_MIN
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define e endl
    #define mod 998244353
    using namespace std;
    lld s(lld a,lld b)
    {
        return (a-b)*(a-b);
    }
     
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        cout.tie(NULL);
        /*#ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif*/
        lld n,ans=0,ans1=0,ans2=0;
        cin>>n;
        vector<lld> v(n);
        lld i,sum=0;
        for(i=0;i<n;i++)
        {
            cin>>v[i];
            sum+=v[i];
        }
        //cout<<sum/n<<e;
        for(i=0;i<n;i++)
        {
            ans+=s(v[i],sum/n);
            ans1+=s(v[i],(sum/n)+1);
            ans2+=s(v[i],(sum/n)-1);
        }
        cout<<min(ans,min(ans1,ans2));

    }

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

using namespace std;

int main(void) {
    int n;

    vector<vector<int>> mat(3, vector<int>(3, 0));

    for (int i = 0; i < 3; i++) {
        for (int j = 0; j < 3; j++) {
            cin >> mat[i][j];
        }
    }

    cin >> n;
    for (int i = 0, a; i < n; i++) {
        cin >> a;
        for (int i = 0; i < 3; i++) {
            for (int j = 0; j < 3; j++) {
                if (mat[i][j] == a) {
                    mat[i][j] = -1;
                }
            }
        }
    }

    bool flag = false;
    for (int i = 0; i < 3; i++) {
        int cnt = 0;
        for (int j = 0; j < 3; j++) {
            if (mat[i][j] == -1) cnt++;
        }
        if (cnt == 3) {
            flag = true;
            break;
        }
    }

    for (int i = 0; i < 3; i++) {
        int cnt = 0;
        for (int j = 0; j < 3; j++) {
            if (mat[j][i] == -1) cnt++;
        }
        if (cnt == 3) {
            flag = true;
            break;
        }
    }

    int cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (mat[i][i] == -1) cnt++;
    }
    if (cnt == 3) flag = true;

    cnt = 0;
    for (int i = 0; i < 3; i++) {
        if (mat[i][2 - i] == -1) cnt++;
    }
    if (cnt == 3) flag = true;

    cout << (flag ? "Yes":"No") << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
#define print(n) std::cout << n << std::endl
#define _print(n) std::cout << n
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
using Graph = vector<vector<int>>;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/

int main(){
    ll n; cin >> n;
    vector<ll> a(n + 5);
    rep(i, n) cin >> a[i];

    sort(a.begin(), a.end(), greater<>());

    ll nagaihen = 0;
    rep(i, n){
        if(a[i] == a[i + 1]){
            if(a[i + 1] == a[i + 3] && nagaihen == 0){
                cout << a[i] * a[i] << endl;
                return 0;
            }else if(a[i + 1] == a[i + 3]){
                cout << nagaihen * a[i] << endl;
                return 0;
            }else{
                if(nagaihen == 0){
                nagaihen = a[i];
                i++;
                }else{
                    cout << nagaihen * a[i] << endl;
                    return 0;
                }
            }
        }
    }
    cout << 0 << endl;
}

Measured memory_bytes: 1024
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>


using namespace std;
bool used[401][401];
int H,W;

int main(){
  cin >> H >> W;
  string S[H];
  for(int i=0;i<H;i++) cin >> S[i];
  memset(used, false, sizeof(used));
  int dx[] = {0,1,0,-1};
  int dy[] = {1,0,-1,0};
  long long ans = 0;
  for(int i=0; i < H; i++){
     for(int j=0; j<W; j++){
        if(used[i][j]==false){
           long long cnt[]={0,0};
           int num=0;
           stack<pair<int,int>> st;
           st.push(make_pair(i,j));
           if(S[i][j]=='.')cnt[0]++;
           else cnt[1]++;
           used[i][j]=true;
           while(st.size()!=0){
              pair<int,int> p = st.top();
              st.pop();
              num++;
              for(int k=0; k<4; k++){
                 int x = p.first;
                 int y = p.second;
                 int x2 = dx[k]+p.first;
                 int y2 = dy[k]+p.second;
                 if(x2>=0&&x2<H &&y2>=0&&y2<W&&used[x2][y2]==false&&S[x][y]!=S[x2][y2]){
                    if(S[x2][y2]=='.')cnt[0]++;
                    else cnt[1]++;
                    used[x2][y2]=true;
                    st.push(make_pair(x2,y2));
                 }
              }
           }
           ans += cnt[0]*cnt[1];
        }
     }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<set>
#include<map>
#include<queue>
#include<vector>
typedef long long int ll;
#define REP(i, n) for(int i = 0; i < (n); i++)
#define FOR_IN(i, a, b) for(int i = (a); i < (b); i++)
#define BETWEEN(x, a, b) ((x) >= (a) && (x) <= (b))
#define BIT(b, i) (((b) >> (i)) & 1)
#define LOG_F 1
#define LOG(...) if(LOG_F) fprintf(stderr, __VA_ARGS__)

using namespace std;

ll pow(int x, int n){
  return n == 0 ? 1 : x * pow(x, n - 1);
}
/*

 */
char b;

int main()
{
  cin >> b;
  char a;
  switch (b){
  case 'A':
    a = 'T';
    break;
  case 'T':
    a = 'A';
    break;
  case 'C':
    a = 'G';
    break;
  case 'G':
    a = 'C';
    break;
  }

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


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

int main(){
    int n,m,x;
    cin >> n >> m >> x;
    int a[100];
    int s=0,t=0;
    for(int i=0;i<m;i++){
        cin >> a[i];
        if(a[i]<x)s++;
        if(a[i]>x)t++;
    }
    cout << min(s,t) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int t, n, k;
int x;
int a[100000], b[100000];
int s;
int main()
{
	cin >> t;
	for(int m=0; m<t; m++)
	{
		cin >> n >> k;
		for(int i=0; i<n; i++)
		{
			cin >> a[i];
		}
		for(int i=0; i<n-1; i++)
		{
			b[i]=a[i+1]-a[i];
		}
		sort(b, b+(n-1));
		s=0;
		if(k<n)
		{
			for(int i=0; i<n-k; i++)
			{
				s+=b[i];
			}
		}
		cout << s << endl;
	}
	return 0;
}

Measured memory_bytes: 1956
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1LL << 60;
ll MOD = 1e9 + 7;

int main() {
    int n, x, y;
    cin >> n >> x >> y;
    --x, --y;
    vector<int> cnt(n, 0);
    for (int i = 0; i < n - 1; i++) {
        for (int j = i + 1; j < n; j++) {
            cnt[min(abs(j - i), min(abs(i - x) + abs(y - j) + 1,
                                    abs(i - y) + abs(j - x) + 1))]++;
        }
    }
    for (int i = 1; i < n; i++) {
        cout << cnt[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 3648
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ii pair<int, int>
#define iii tuple<int, int, int>
#define iiii tuple<int, int, int, int>
#define vi vector<int>
#define vvi vector<vector<int>>
#define fi first
#define se second
#define eb emplace_back
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define uni(v) v.erase(unique(v.begin(), v.end()), v.end())
#define gcd(a, b) __gcd(a, b)
#define lcm(a, b) (ll) a / __gcd(a, b) * b
#define rep(i, a, b) for (auto i = a; i != b; i += 1 - 2 * (a > b))

using namespace std;

void solve() {
    int n;
    cin >> n;
    vi a(n);
    for (auto& i : a) cin >> i;
    if (any_of(all(a),
               [](int x) { return (x % 2 == 0 && x % 3 != 0 && x % 5 != 0); }))
        cout << "DENIED\n";

    else
        cout << "APPROVED";
}

int main() {
    ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr);
    // freopen("in", "r", stdin);

    int t = 1;
    // cin >> t;

    while (t--) solve();
    return 0;
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> score(N);
  for(int i = 0; i < N; i++){
    cin >> score.at(i);
  }
  
  double sum = 0;
  for(int i = 0; i < N; i++){
    sum += (double)1/score.at(i);
  }
  
  double answer;
  answer = 1/sum;
  
  cout << answer << endl;
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> //required
#include <ext/pb_ds/tree_policy.hpp> //required

using namespace __gnu_pbds; 
using namespace std;

template <typename T> using ordered_set =  tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>; 
// find_by_order(k)  returns iterator to kth element starting from 0;
// order_of_key(k) returns count of elements strictly smaller than k;
typedef long long  ll;
typedef vector<ll> VL;
typedef vector<int> VI;
typedef pair<ll,ll> PLL;
typedef pair<int,int> PII;
#define pb push_back

#define F first
#define S second
#define SZ(a) int((a).size())
#define ALL(a) a.begin(),a.end()
#define fr(i,x,y) for(int i=x;i<y;i++)
#define frr(i,x,y) for(int i=x-1;i>=y;i--)
#define inf 1e18+1
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
const int mod=1000000007;
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll power(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;}a=a*a;b>>=1;}return ans;}
ll powerm(ll a,ll b){ll ans=1;while(b!=0){if(b&1){ans*=a;ans%=mod;}a=a*a;a%=mod;b>>=1;}return ans%mod;}
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();

void solve()
{
    ll n;
    cin>>n;
    map<ll,ll> mp;
    fr(i,0,n)
    {
        ll x;
        cin>>x;
        mp[x]+=1;

    }
    ll ct=0;
    for(auto &i:mp)
    {
        i.S=i.S%2;
        if(i.S==0)
        {
            i.S=2;
        }
        if(i.S==2)
        {
            ct++;
        }
    }
    if(ct%2==0)
    {
        cout<<SZ(mp)<<endl;
    }
    else
    {
        cout<<SZ(mp)-1<<endl;
    }
    return;
}
int main()
{
    IOS;
    ll t=1;
    //cin>>t;
    while(t--)
    {
        //cout<<"Case #"<<pp-t<<":\n";
        solve();
    }
    return 0;
}
/* stuff you should look for
        * int overflow, array bounds
        * special cases (n=1?)
        * do smth instead of nothing and stay organized
        * WRITE STUFF DOWN
*/
/*
recursion - matrix exponential

*/
// BITMASK:
// 1)When some constrall is of the order of 15-20, think of bitmask DP.
// 2)When some constrall is around 40, try out meet in the middle
// 3) See Strings,palindromes,prefix,suffix etc -> KMP,Z algorithm

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

int  main()
{
	int x, a ; cin >> x >> a;
	if (x < a)
		cout << 0 << endl;
	else 
		cout << 10 << endl;
	return (0);
}


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

using namespace std;
typedef long long ll;
typedef pair<int, int> P;

P p[200000];

int N;
string T[200000];
string S[200000];

struct node{
    char val;
    vector<int> v;
    int depth;
    vector<node> next;
};

node& getNode(node &cur, char c){
    for(int i = 0; i < cur.next.size(); i++){
        if(cur.next[i].val == c) return (cur.next[i]);
    }
}

bool hasChar(node &cur, char c){
    for(int i = 0; i < cur.next.size(); i++){
        if(cur.next[i].val == c) return true;
    }
    return false;
}

void addNode(node &cur, char c){
    node n;
    n.depth = cur.depth+1;
    n.val = c;
    cur.next.push_back(n);
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    cin >> N;
    for(int i = 0; i < N; i++){
        cin >> T[i];
        p[i] = P(T[i].size(), i);
    }
    sort(p, p+N);
    for(int i = 0; i < N; i++){
        int idx = p[i].second; 
        S[i] = T[idx];
        reverse(S[i].begin(), S[i].end());
    }
    node root = (node){'a', vector<int>(), 0, vector<node>()};
    ll ans = 0;
    for(int i = 0; i < N; i++){
        // cout << S[i] << endl;
        vector<int> cnt(26);
        auto cur = &root;
        int sz = S[i].size();
        for(int j = 0; j < cur->v.size(); j++){
            cnt[j] += cur->v[j];
        }
        for(int j = 0; j+1 < sz; j++){
            char c = S[i][j];
            ans += cnt[c-'a'];
            cnt[c-'a'] = 0;
            if(hasChar(*cur, c)){
                // cout << "has:" << c << endl;
                cur = &getNode(*cur, c);
            }else{
                addNode(*cur, c);
                cur = &getNode(*cur, c);
            }
            for(int j = 0; j < cur->v.size(); j++){
                cnt[j] += cur->v[j];
            }
        }
        if(cur->v.size() == 0){
            cur->v = vector<int>(26);
        }
        char c = S[i][sz-1];
        ans += cnt[c-'a'];
        cur->v[c-'a']++;
        // cout << ans << endl;
    }
    cout << ans << endl;
}

Measured memory_bytes: 125176
#include <stdio.h>
int main(void){
	int H,N,A,i,sum=0;
	
	scanf("%d %d",&H,&N);
	
	for(i=0;i<N;i++){
		scanf("%d",&A);
		sum = sum + A;
	}

	if(H<=sum){
		printf("Yes");
	}else{
		printf("No");
	}
	
	return 0;
}

Measured memory_bytes: 128
fun main(args: Array<String>) {
    val arr = readLine()!!.split(' ').map{it.toInt()}
    if (arr[0] == arr[1]) {
        println(arr[2])
    }
    else if (arr[0] == arr[2]) {
        println(arr[1])
    }
    else {
        println(arr[0])
    }
}

Measured memory_bytes: 38008
#include <bits/stdc++.h>
using namespace std;
long long A,B;
long long ans=1e12;
void f(){
    if(A%3)ans=min(ans,B);
    else ans=0;
    ans=min(ans,max(abs(A/3*B-B/2*(A-A/3)),abs(A/3*B-(A-A/3)*(B-B/2))));
    ans=min(ans,max(abs((A/3+1)*B-B/2*(A-A/3-1)),abs((A/3+1)*B-(A-A/3-1)*(B-B/2))));
}
int main(){
    cin>>A>>B;
    f();
    swap(A,B);
    f();
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#define rep(i, n) for(i = 0; i < n; i++)
#define int long long
using namespace std;

int a, b, n;
int f(int x) {
	return (a * x) / b - a * (x / b);
}

signed main() {
	cin >> a >> b >> n;
	
	if (n < b) {
		cout << f(n) << endl;
	}
	else {
		cout << f(b - 1) << endl;
	}
	
	return 0;
}


Measured memory_bytes: 3604
N = int(input())
A = list(map(int,input().split()))

min_m = 10**10
while len(A)*min_m != sum(A):
    min_m = min(A)
    n_min_m = min_m
    for i,a in enumerate(A):
        if min_m != a:
            A[i] = min_m if a%min_m == 0 else a%min_m
            n_min_m = min(a,n_min_m)
    min_m = n_min_m

print(min_m)

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

using ll = long long;
#define REP(i,n) for(int i = 0;i < n;i++)


#define debug(arr) cout << #arr << " = " << arr << '\n'
#define debug2(a,b) cout << "[" << #a << "," << #b << "] = " << "[" << a << "," << b << "]" << '\n'
template<class T> ostream &operator << (ostream& out, const vector<T>& arr) {
	cout << "{";
	for (int i = 0; i < arr.size(); i++)cout << (!i ? "" : ", ") << arr[i];
	cout << "}";
	return out;
}
template<class T> ostream &operator << (ostream& out, const vector<vector<T> >& arr) {
	cout << "{\n";
	for (auto& vec : arr)cout << "  " << vec << ",\n";
	cout << "}";
	return out;
}
template<class T> istream &operator >> (istream& in, vector<T>& arr) {
	for (auto& i : arr)cin >> i; return in;
}
template<class T> struct Cumurative{ // 一次元累積和
    int N;
    vector<T> c;
    vector<T> a;
    Cumurative(vector<T> a):a(a){
        N = a.size() + 1;
        c = vector<T>(N,0);
        build();
    }
    void build(){
        for(int i = 1;i <= N;i++){
            c[i] = c[i-1] + a[i];
        }
    }
    T query(int i,int j){//[i,j)を返す
        return c[j] - c[i];
    }
};

template<class T> struct Cumurative2D { // 二次元累積和
    int N,M;
    vector<vector<T> > Dat; 

    Cumurative2D(int N,int M):N(N),M(M){//aの配列size
        Dat = vector<vector<T> >(N+1,vector<T>(M+1,0));
    }
    void add(int i,int j,T x){ //a[i][j] = xをDat[i+1][j+1]に加算する
        Dat[i+1][j+1] += x;
    }
    void build(){//累積和テーブルを作成する
        for(int j = 1;j <= M;j++){ Dat[0][j] += Dat[0][j-1]; }
        for(int i = 1;i <= N;i++){ Dat[i][0] += Dat[i-1][0]; }
        for(int i = 1;i <= N;i++){
            for(int j = 1;j <= M;j++){
                Dat[i][j] += (Dat[i-1][j] + Dat[i][j-1] - Dat[i-1][j-1]);
            }
        }
    }
    T query(int i,int j,int k,int l){ //[(i,j) , (k,l))
        return Dat[k][l] - Dat[k][j] - Dat[i][l] + Dat[i][j];
    }
};

vector<pair<ll,ll> > b;
Cumurative2D<ll> C(100,100);

void _count(ll x){
  //cout << x << ' ';
  ll two = 0;
  while(x && x % 2 == 0){
    x /= 2;
    two++;
//    debug(x);
  }
  ll five = 0;
  while(x && x % 5 == 0){
    x /= 5;
    five++;
//    debug(x);
  }
  //cout << two << ' ' << five << '\n';
  C.add(two,five,1);
  b.push_back(make_pair(two,five));
}

int main(void){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int N;cin >> N;
  vector<ll> a(N);  
  const ll base = 1000000000;
  REP(i,N){
    double x;cin >> x;
    x *= (double)base;
    a[i] = round(x);
    _count(a[i]);
  }

  C.build();
  ll ans = 0;
  REP(i,N){
    ll two = max(0LL,18 - b[i].first);
    ll five = max(0LL,18 - b[i].second);
    ans += C.query(two,five,100,100);
    if(two <= b[i].first && five <= b[i].second) ans--;
//    cout << ans << '\n';
  }
  cout << ans / 2 << '\n';
}


Measured memory_bytes: 9044
d,g = map(int, input().split())
p = []
c = []
for i in range(d):
    a,b = map(int, input().split())
    p.append(a)
    c.append(b)
    
dp = [0 for i in range(sum(p) + 2)] 
for i in range(1,d+1):
    count_max = p[i-1]
    bonus = c[i-1]
    for j in range(sum(p)+1,0,-1):
        for k in range(1,count_max+1):
            if k < count_max:
                cc = 100 * i * k
            if k == count_max:
                cc = 100 * i * k + bonus
                
            if j - k >= 0:
                dp[j] = max(dp[j],dp[j-k] + cc)
                
for i,j in enumerate(dp):
    if g <= j:
        print(i)
        break

Measured memory_bytes: 3064
/*  -*- coding: utf-8 -*-
 *
 * b.cc: B: 
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>

using namespace std;

/* constant */

const int MAX_N = 30000;

/* typedef */

/* global variables */

int as[26], cs[2][MAX_N + 1];

/* subroutines */

/* main */

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

  for (int i = 0; i < n; i++) {
    string s;
    cin >> s;
    as[s[0] - 'A']++;
  }
  int maxc = 0;
  for (int i = 0; i < 26; i++) {
    cs[0][as[i]]++;
    if (maxc < as[i]) maxc = as[i];
  }
  //for (int i = 1; i <= maxc; i++) printf("%d ", cs[0][i]); putchar('\n');

  int cnt = 0, cur = 0, nxt = 1;
  for (;;) {
    memcpy(cs[nxt], cs[cur], sizeof(cs[cur]));
    int m = k;

    for (int i = maxc; m > 0 && i > 0; i--)
      if (cs[cur][i] > 0) {
	int d = min(m, cs[cur][i]);
	m -= d;
	cs[nxt][i] -= d;
	cs[nxt][i - 1] += d;
      }
    if (m > 0) break;

    cnt++;
    while (maxc > 0 && cs[nxt][maxc] == 0) maxc--;
    cur ^= 1, nxt ^= 1;
  }

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


Measured memory_bytes: 512
#include<stdio.h>
#include<stdlib.h>
int main(void){
	int n;
	char *s;
	long x = 0;
	long r = 0;
	long g = 0;
	long b = 0;
	scanf("%d", &n);
	s = (char *)malloc(sizeof(char) * (n+1));
	scanf("%s", s);
	for(int i=0; i<n; i++){
		if(s[i] == 'R'){
			r++;
		}
		else if(s[i] == 'G'){
			g++;
		}
		else if(s[i] == 'B'){
			b++;
		}
	}
	x += r*g*b;
	for(int j=0; j<n-2; j++){
		for(int k=1; k<n; k++){
			if(j+k+k < n){
				if(s[j] != s[j+k] && s[j] != s[j+k+k] && s[j+k] != s[j+k+k]){
					x--;
				}
			}
		}
	}
	printf("%ld\n", x);
	return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

#define MAX_V 200010

int V; 
vector<int> G[MAX_V], rG[MAX_V];
vector<int> vs; 

bool vis[MAX_V];
int cmp[MAX_V]; 

void add_edge(int from, int to)
{
	G[from].pb(to);
	rG[to].pb(from);
}

void dfs(int v)
{
	vis[v] = true;

	for (int to : G[v]) {
		if (!vis[to]) dfs(to);
	}

	vs.push_back(v);
}

void rdfs(int v, int k)
{
	vis[v] = true;
	cmp[v] = k;

	for (int to : rG[v]) {
		if (!vis[to]) rdfs(to, k);
	}
}

int scc()
{
	memset(vis, 0, sizeof(vis));
	vs.clear();

	rep(v, V) if (!vis[v]) dfs(v);

	memset(vis, 0, sizeof(vis));

	int k = 0;
	reverse(ALL(vs));

	for (int v : vs) if (!vis[v]) rdfs(v, k++);

		return k;
}

int N;
int x[10010], y[10010];
vector<pii> vec;
int u[10010][2], pp[10010];
int B, sz;

void build(int a, int b, int k, int l, int r, int p) {
	if (b <= l || r <= a) {
		return ;
	}

	if (a <= l && r <= b) {
		add_edge(p, k + B);
		add_edge(k, p + B);
		return ;
	}

	build(a, b, k * 2 + 1, l, (l + r) / 2, p);
	build(a, b, k * 2 + 2, (l + r) / 2, r, p);
}

bool ok(int d)
{
	sz = 1;
	while (sz < N * 2) sz *= 2;

	B = sz * 2;
	V = B * 2;

	rep(i, V) {
		G[i].clear();
		rG[i].clear();
	}

	rep(i, N) {
		int a = u[i][0] + sz - 1, b = u[i][1] + sz - 1;
		add_edge(a, b + B);
		add_edge(b, a + B);
		add_edge(a + B, b);
		add_edge(b + B, a);
	}

	for (int i = 1; i < sz * 2 - 1; ++i) {
		add_edge(i, (i-1) / 2);
		add_edge((i-1) / 2 + B, i + B);
	}

	rep(i, vec.size()) {
		int l = upper_bound(ALL(vec), mp(vec[i].fi - d + 1, -1)) - vec.begin();
		int r = lower_bound(ALL(vec), mp(vec[i].fi + d, -1)) - vec.begin();
		//[l, i), [i + 1, r)
		build(l, i, 0, 0, sz, i + sz - 1);
		build(i + 1, r, 0, 0, sz, i + sz - 1);
	}

	scc();

	rep(i, B) {
		if (cmp[i] == cmp[i + B]) {
			return false;
		}
	}
	return true;
}

int main() {
	cin >> N;

	rep(i, N) {
		cin >> x[i] >> y[i];
		vec.eb(x[i], i * 2);
		vec.eb(y[i], i * 2 + 1);
	}

	sort(ALL(vec));

	rep(i, vec.size()) {
		int id = vec[i].se / 2;
		u[id][pp[id]++] = i;
	}

	int lo = 0, hi = 1000000010;

	while (hi - lo > 1) {
		int mid = (lo + hi) / 2;
		if (ok(mid)) {
			lo = mid;
		} else {
			hi = mid;
		}
	}

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

Measured memory_bytes: 43640
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(12), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-12, PI = acos(-1);
const int N = 4e5 + 9, M = 5e3 + 9, OO = 1e9 + 7, MOD = 1e9 + 7;
const ll inf = 1e18;

ll freq[N][2];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif
  string str;
  int n;
  cin >> n >> str;
  for (int i = 1; i <= n; ++i) {
    freq[i][0] += freq[i-1][0];
    freq[i][1] += freq[i-1][1];
    if(str[i - 1] == 'E') {
      freq[i][0] += 1;
    } else {
      freq[i][1] += 1;
    }
  }
  int ans = OO;
  for (int i = 1; i <= n; ++i) {
    int cntW = freq[i-1][1];
    int cntE = freq[n][0] - freq[i][0];
    ans = min(ans, cntW + cntE);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 6804
import java.util.Scanner;
import java.util.Stack;

public class Main {

	public static void main(String[] args) {
	Scanner input = new Scanner(System.in);
	String[] equation;
	equation = input.nextLine().split(" ");
	Stack<Integer> numbers = new Stack<Integer>();
	input.close();
	int solution = 0;
	for(int i = 0; i < equation.length; i++) {
		String operator;
		
		if(equation[i].equals("*") || equation[i].equals("+") || equation[i].equals("-")) {
			operator = equation[i];
			if(operator.equals("*")) {
				solution = (numbers.pop() * numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("+")) {
				solution = (numbers.pop() + numbers.pop());
				numbers.push(solution);
			}
			else if(operator.equals("-")) {
				int first = numbers.pop();
				int second = numbers.pop();
				solution = ( second - first );
				numbers.push(solution);
			}
			
			
		}
		else {
			numbers.push(Integer.parseInt(equation[i]));
		}
		
		
	}
	System.out.println(solution);

		
	}
	
	

}


Measured memory_bytes: 26084
#include<iostream>
#include<vector>
#include <queue>
#include<cmath>
#include<algorithm>
using namespace std;
#define pb push_back
#define ll long long

ll a[100100];
vector <int > v;
int main(){
	ll n,cnt=0;
	cin >> n;
	for(ll i = 0,x;i < n;i++){
		cin >> x;
		if(x%2==1){
			cnt++;
		}
	}
	if(cnt%2==1){
		cout << "NO" << endl;
	}
	else{
		cout << "YES" << endl;
	}

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <cmath>

#define rep(x,to) for(int x=0;x<to;x++)
#define rep2(x,from,to) for(x=from;x<to;x++)

using namespace std;


int main(void){

double v,wn;
int n;

	while(cin >> v ){
		double h = 4.9 * (v / 9.8) * (v / 9.8);
		n = ceil(( h + 5 ) / 5);
//		n = (int)wn;
//		n = n + (wn==n? 0: 1);
		cout << n << endl;
	}
	
	return 0;
}

Measured memory_bytes: 1228
using System;
using System.Linq;
using static System.Math;
class Program {
    static void Main (string[] args) 
    {
        var ary =  Console.ReadLine().Split(' ').Select(x=>int.Parse(x)).ToArray();

        var ans = (ary[2] / ary[0]) * ary[1];
        
        Console.WriteLine (ans);
    }
}

Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
string a;
int ans;
int main(){
    cin>>a;
    if(a[0] != 'C') ans++;
    if(a[1] != 'O') ans++;
    if(a[2] != 'D') ans++;
    if(a[3] != 'E') ans++;
    if(a[4] != 'F') ans++;
    if(a[5] != 'E') ans++;
    if(a[6] != 'S') ans++;
    if(a[7] != 'T') ans++;
    if(a[8] != 'I') ans++;
    if(a[9] != 'V') ans++;
    if(a[10] != 'A') ans++;
    if(a[11] != 'L') ans++;
    if(a[12] != '2') ans++;
    if(a[13] != '0') ans++;
    if(a[14] != '1') ans++;
    if(a[15] != '6') ans++;
    cout<<ans<<endl;
return 0;
}

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

int main() {
  int a,s1,s2,s3;
  cin >> a;
  s3 = a%10;
  s2 = ((a-s3)/10)%10;
  s1 = (a-(s2*10+s1))/100;
  cout << s1+s2+s3 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;
  cin>>s;
  int N=s.size();
  if(N%2==0){
  if(s.at(0)==s.at(N-1)){
     cout<<"First"<<endl;
  }else{
  cout<<"Second"<<endl;
  }
  }else{
  if(s.at(0)==s.at(N-1)){
    cout<<"Second"<<endl;
  }else
    cout<<"First"<<endl;
  }
    return 0;
}

Measured memory_bytes: 512
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use permutohedron::*;
use proconio::*;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

fn main() {
    let n: usize = read!();
    let m: usize = read!();

    let mut v = vec![vec![]; n];

    for _ in 0..m {
        let xi: usize = read!();
        let yi: usize = read!();

        v[xi - 1].push(yi - 1);
        v[yi - 1].push(xi - 1);
    }

    let p = (1..n).permutations(n - 1).collect_vec();

    let mut ans = 0;

    let p = p
        .into_iter()
        .map(|mut vi| {
            let mut tmp = vec![0];
            tmp.append(&mut vi);
            tmp
        })
        .collect_vec();

    'par: for pi in p {
        if pi[0] != 0 {
            continue;
        }

        let mut now = pi[0];
        for &pii in &pi[1..] {
            if v[now].contains(&pii) {
                now = pii;
            } else {
                continue 'par;
            }
        }

        ans += 1;
    }

    println!("{}", ans);
}


Measured memory_bytes: 2780
import Data.List
import Data.Maybe

main :: IO ()
main = do
    _ <- getLine
    s <- sort . map read . lines <$> getContents :: IO [Int]
    let s' = sum s
        m  = fromMaybe 0 $ find (\x -> rem10 x /= 0) s
    print $ if rem10 s' == 0
               then if rem10 (s'-m) == 0 then 0 else s'-m
               else s'
  where
    rem10 = (`rem` 10)

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

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

  int n;
  cin >> n;

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

  ll ans = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = i+1; j < n; ++j) {
      ans += d[i] * d[j];
    }
  }

  cout << ans << endl;

  return (0);
}


Measured memory_bytes: 3624
fun main(args: Array<String>) = yorukatsu11c()

fun yorukatsu11c() {
    val dirR = readLine()!!.map { it == 'R' }.toBooleanArray()

    val counts = IntArray(dirR.size)

    for (i in dirR.indices) {
        if (i + 1 !in dirR.indices || !dirR[i] || dirR[i + 1]) continue

        var left = i
        while (left in dirR.indices && dirR[left]) {
            if ((i - left--) % 2 == 0) counts[i]++ else counts[i + 1]++
        }

        var right = i + 1
        while (right in dirR.indices && !dirR[right]) {
            if ((i - right++) % 2 == 0) counts[i]++ else counts[i + 1]++
        }
    }

    val answer = counts.joinToString(" ")

    println(answer)
}


Measured memory_bytes: 46848
#include<stdio.h>

int insertionSort(int *A,int n,int g){

  int i,cnt=0,v,j;


  for(i=g;i<n;i++){

    v=A[i];
    j=i-g;

    while(j>=0&&A[j]>v){
      A[j+g]=A[j];
      j=j-g;
      cnt++;
    }
    A[j+g]=v;

  }

  return cnt;
}


void shellSort(int *A,int n){

  int cnt=0,m=0,G[n],i,cnt1;

  //printf("wa-i\n");
  
  for(i=1;i<=n;i=3*i+1){

    G[m]=i;
    m++;

  }
  
  // for(i=0;i<m;i++){
  //    printf("%d",G[i]);
  // }
  
  for(i=0;i<m;i++){
    cnt1=insertionSort(A,n,G[m-i-1]);
    cnt+=cnt1;
    // printf("%d\n",cnt);
  }
  
  printf("%d\n",m);

  for(i=0;i<m;i++){
    
    printf("%d ",G[m-i-1]);
    
  }
  printf("\n");
  printf("%d\n",cnt);

}


int main( ){

  int i,n,A[1000000];

  scanf("%d",&n);

  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
  }

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

  return 0;


}

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

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).begin(),(x).rend()

typedef vector<int> vi;
typedef long long ll;
typedef pair<int,int> PII;
typedef pair<long long,long long> PLL;


int main(){
	int n;
	cin>>n;
	int a[n];
	int sum=0;

	for (int i = 0; i < n; ++i){
		cin>>a[i];
		sum+=a[i];
	}

	sort(a,a+n);

	
	if(sum%10==0){
		for (int i = 0; i < n; ++i){
			if(a[i]%10==0)continue;
			sum-=a[i];
			break;
		}
	}

	if(sum%10==0){
		cout<<0<<endl;
	}else{
		cout<<sum<<endl;
	}
	


	return 0;
}

Measured memory_bytes: 256
import sys
x = int(input())
if x == 2:
    print(2)
    sys.exit(0)
prime = []
prime_dec = True
#x_sqrt = x ** 0.5
prime.append(2)
# 素数リストの作成
for n in range(3, 1000, 2):
    prime_dec = True
    for primes in prime:
        if primes > n ** 0.5:
            break
        if n % primes == 0:
            prime_dec = False
            break
        else:
            continue
    if prime_dec:
        prime.append(n)
# 素数の探査
x -= 2
if x % 2 == 0:
    x += 1
prime_disc = True
while prime_disc:
    prime_dec = True
    x += 2
    for primes in prime:
        if primes > x ** 0.5:
            break
        if x % primes == 0:
            prime_dec = False
            break
        else:
            continue
    if prime_dec:
        print(x)
        prime_disc = False


Measured memory_bytes: 39024
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define REP(NAME, NUM) for (int NAME = 0; NAME < (NUM); ++NAME)
#define BREP(NAME, NUM) for (int NAME = (NUM)-1; NAME >= 0; --NAME)
#define ALL(NAME) (NAME).begin(), (NAME).end()
 
#define cMOD 1000000007ULL
#define cINF ((1ull<<62)-1)
#define cINFINT ((1<<30)-1)
 
 
int main()
{
	ll n,x; cin >> n >> x;
	vector<ll> b(n),l(n),u(n);
	REP(i,n) cin>>b[i]>>l[i]>>u[i];
	vector<pair<ll,pair<ll,ll>>> k(n);
	ll sum = 0;
	REP(i,n)
	{
		k[i].first = l[i]*b[i]+u[i]*(x-b[i]);
		k[i].second.first = -l[i];
		k[i].second.second = i;
		sum += l[i]*b[i];
	}
	sort( ALL(k), greater<pair<ll,pair<ll,ll>>>() );
 
	ll time = 0, score = 0;
	vector<bool> perfect(n,false);
	ll now = 0;
	REP(i,k.size())
	{
		ll idx = k[i].second.second;
		if( score + k[i].first > sum )
		{
			now = i;
			break;
		}
		time += x;
		score += k[i].first;
		perfect[idx] = true;
	}
	const ll leftScore = sum - score;
	ll min_time = 100000000;
	if(leftScore == 0)
	{
		min_time = 0;
	}
	else
	{
		REP(i,n)
		{
			auto div = [](ll a, ll b)
			{
				return a%b==0 ? a/b : a/b+1;
			};
			if( !perfect[i] )
			{
				ll t=0;
				if( l[i] * b[i] >= leftScore )
				{
					t = div( leftScore, l[i] );
				}
				else
				{
					t = b[i];
					ll ss = leftScore - l[i]*b[i];
					t += div( ss, u[i] );
				}
				min_time = min( min_time, t );
			}
			else
			{
				ll ss = leftScore;
				ss -= k[now].first;
				ss += l[i]*b[i]+u[i]*(x-b[i]);
				ll t=0;
				if( l[i] * b[i] >= ss )
				{
					t = div( ss, l[i] );
				}
				else
				{
					t = b[i];
					ss -= l[i]*b[i];
					t += div( ss, u[i] );
				}
				min_time = min( min_time, t );
			}
		}
	}
	cout << time+min_time << endl;
	return 0;
}

Measured memory_bytes: 4992
kakko=[0]*(int(input())+1)
S=input()
kakkoSum=0
for n,s in enumerate(S):
    if s=="(":
        kakkoSum +=1
    else:
        kakkoSum -=1
    kakko[n+1] = kakkoSum
D=min(kakko)
if D<0:
    d=kakko[-1]
    kakkoleft=-D
    kakkoright=-D+d
    print("(" * kakkoleft + S + ")" * kakkoright)
elif kakko[-1] ==0:print(S)
else:
    d=kakko[-1]
    print(S + ")"* d)

Measured memory_bytes: 3064
from collections import defaultdict
import sys
n=int(input())

d=defaultdict(int)
for i in range(n):
    s=input()
    d[s[0]]+=1

march=[d["M"],d["A"],d["R"],d["C"],d["H"]]
zero=march.count(0)
if zero>=3:
    ans=0
    print(ans)
    sys.exit()

m=[]
for i in march:
    if i>0:
        m.append(i)

ans=0
for i in range(len(m)-2):
    for j in range(i+1,len(m)-1):
        for k in range(j+1,len(m)):
            ans+=m[i]*m[j]*m[k]

print(ans)

Measured memory_bytes: 9424
#include <iostream>

using namespace std;

int n, m, u, v, f[5000], res = 0, c;

void Process()
{
    for (int i=0; i<=(1<<n)-1; i++)
        {
            f[i|c] = min(f[i|c], f[i] + u);
            //cout << i << endl;
        }

    //if (f[1] == 2156) cout << c << endl;
}

void Input()
{
    ios_base::sync_with_stdio(0);       cin.tie(0);

    cin >> n >> m;
    for (int i=0; i<=(1<<n)-1; i++)
        f[i] = 1e9;
    f[0] = 0;

    for (int i=1; i<=m; i++)
    {
        cin >> u >> v;      c = 0;

        for (int j=1; j<=v; j++)
        {
            int x;      cin >> x;
            c += (1 << (x-1));
        }

        Process();
    }

//    for (int i=0; i<=(1<<n)-1; i++)
//        cout << f[i] << " ";

    if (f[(1<<n)-1] > 1e8) cout << -1;
        else cout << f[(1<<n)-1];
}

int main()
{
    Input();
    //cout << "Hello world!" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define sort(s) sort(s.begin(),s.end())
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind
#define rt (a); return (a); 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 1000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
llint gcd(llint a, llint b) {
	if (b > a)swap(a, b);
	if (a % b == 0)return b;
	return gcd(b, a % b);
}


int main() {
	int n;
	cin >> n;
	hei(int) p(n);
	string s;
	rep(i, 0, n) {
		cin >> p[i];
		if (p[i] == i + 1)s += "x";
		else s += "o";
	}
	s += "a";
	int ans = 0;
	rep(i, 0, n) {
		if (s[i] == 'x') {
			s[i + 1] = 'o';
			ans++;
		}
	}
	cout << ans << endl;
	return 0;

}

Measured memory_bytes: 896
import java.awt.Point;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.PriorityQueue;
import java.util.Scanner;

public class Main {

	private void solve() {
		Scanner in = new Scanner(System.in);
		int x1 = in.nextInt();
		int y1 = in.nextInt();
		int x2 = in.nextInt();
		int y2 = in.nextInt();
		
		if(y2<y1){
			int sp = y2;
			y2 = y1;
			y1 =sp;
			sp = x2;
			x2 = x1;
			x1 = sp;
		} // y1 < y2
		
		int N = in.nextInt();
		
		if(x1==x2){
			boolean exist = false;
			for (int i = 0; i < N; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				if(x==x1 && y1<y && y<y2) exist = true;
			}
			System.out.println(100L*(y2-y1)+((!exist)?0:10*Math.PI-20));
			
		}else if(y1==y2){
			boolean exist = false;
			if(x1>x2){
				int sp = x2; x2 = x1; x1 = sp;
			}
			for (int i = 0; i < N; i++) {
				int x = in.nextInt();
				int y = in.nextInt();
				if(y==y1 && x1<x && x<x2) exist = true;
			}
			System.out.println(100L*(x2-x1)+((!exist)?0:10*Math.PI-20));
			
		}else if(x1<x2){
			PriorityQueue<Point> queue = new PriorityQueue<>(
					(a,b)->((Point)a).x-((Point)b).x
			);
			for (int i = 0; i < N; i++) {
				queue.add(new Point(in.nextInt(),in.nextInt()));
			}
			//BinaryPoints tree = new BinaryPoints();
			ArrayList<Integer> tree = new ArrayList<>();
			while(!queue.isEmpty()){
				Point p = queue.poll(); 
				if(x1<=p.x && p.x<=x2 && y1<=p.y && p.y<=y2) tree.add(p.y);
			}
			int[] list = new int[tree.size()];
			for (int i=0;i<tree.size();i++) {
				list[i] = tree.get(i);
			}
			int max = lis(list);
			
			double ans = 100L*((x2-x1)+(y2-y1));
			if(max==Math.min(x2-x1, y2-y1)+1){
				ans += (5*Math.PI-20)*(max-1) + 10*Math.PI-20;
			}else{
				ans += (5*Math.PI-20)*max;
			}
			System.out.println(ans);
			
		}else if(x1>x2){
			PriorityQueue<Point> queue = new PriorityQueue<>(
					(a,b)->((Point)b).x-((Point)a).x
			);
			for (int i = 0; i < N; i++) {
				queue.add(new Point(in.nextInt(),in.nextInt()));
			}
			//BinaryPoints tree = new BinaryPoints();
			ArrayList<Integer> tree = new ArrayList<>();
			while(!queue.isEmpty()){
				Point p = queue.poll(); 
				if(x2<=p.x && p.x<=x1 && y1<=p.y && p.y<=y2) tree.add(p.y);
			}
			int[] list = new int[tree.size()];
			for (int i=0;i<tree.size();i++) {
				list[i] = tree.get(i);
			}
			int max = lis(list);
			
			double ans = 100L*((x1-x2)+(y2-y1));
			if(max==Math.min(x1-x2, y2-y1)+1){
				ans += (5*Math.PI-20)*(max-1) + 10*Math.PI-20;
			}else{
				ans += (5*Math.PI-20)*max;
			}
			System.out.println(ans);
		}
	}
	
	public static void main(String[] args) {
		new Main().solve();
	}
	
	public int lis(int[] list){
		int[] dp = new int[list.length];
		Arrays.fill(dp, Integer.MAX_VALUE);
		for (int h : list) {
			int index = -Arrays.binarySearch(dp, h)-1;
			dp[index] = h;
		}
		return -Arrays.binarySearch(dp,Integer.MAX_VALUE-1)-1;
	}
}

Measured memory_bytes: 114920
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

//-------------------------------------------------------------------
struct segtree{
  ll M=1, INIT;
  vector<ll> dat;
  segtree(ll N, ll num){
    INIT = num;
    while(M<N) M*=2;
    for(int i=0;i<M*2-1;i++)  dat.push_back(num);
  }
  void update(ll x, ll k, ll l=0, int r=-1){
    if(r==-1) r = M;
    k+=M-1;
    dat[k] += x;
    while(k>0) k = (k-1)/2, dat[k] = dat[k*2+1] + dat[k*2+2];
  }
  ll query(ll a, ll b=-1, ll k=0, ll l=0, ll r=-1){
    if(r==-1) r = M;
    if(b==-1) b = M;
    if(r<=a || b<=l) return INIT;
    if(a<=l && r<=b) return dat[k];
    ll A = query(a, b, k*2+1, l, (l+r)/2);
    ll B = query(a, b, k*2+2, (l+r)/2, r);
    return A + B;
  }
};
//-------------------------------------------------------------------
int main(int argc, char const *argv[]) {
  ll a, b, c, t, n, q;std::cin >> n >> q;
  segtree seg(n, 0);
  re(i, n) scanf("%lld", &t), seg.update(t, i);
  re(i, q){
    scanf("%lld %lld %lld", &a, &b, &c);
    if(a==0) seg.update(c, b);
    else std::cout << seg.query(b, c) << '\n';
  }

  return 0;
}


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

const ll p = 998244353;

map<ll, ll> m[105];
ll dp[105][105], t[105][105], n, p2[105];
string s;

ll ans(ll a, ll q) {
	assert(a <= 50);
	if (a == 1) {
		m[a][q] = (q==1)+1;
		return m[a][q];
	}

	if (m[a].count(q) > 0)
		return m[a][q];
	int t[a];
	ll v[a+1];

	ll q1 = q;
	for (int i = 0; i < a; ++i) {
		t[i] = q1%2;
		q1 /= 2;
	}

	v[a] = 0;
	for (int i = a-1; i >= 0; --i)
		v[i] = 2*v[i+1]+t[i];

	if (t[0] == 0)
		m[a][q] = ans(a-1, q/2);
	else
		m[a][q] = 2*ans(a-1, q/2)%p;

	for (int i = 1; i <= a/2; ++i) {
		bool x[i];
		for (int k = 0; k < i; ++k)
			x[k] = 1;
		ll tot = (1LL<<i)-1;
		for (int j = 0; j+i-1 < a; j += i) {
			for (int k = j; k < j+i; ++k) {
				if (t[k] == 1)
					continue;
				else {
					if (x[k-j] == 1) {
						tot -= (1LL<<(k-j));
						x[k-j] = 0;
					}
				}
			}

			if (j == 0)
				continue;
			ll u = ans(i, tot);
			if (j+i-1 == a-1) {
				m[a][q] = (m[a][q] + u)%p;
			} else {
				m[a][q] = (m[a][q] + u*ans(a-i-j, v[j+i]))%p;
			}
		}
	}

	// cout << a << ' ' << q << ' ' << m[a][q] << endl;
	return m[a][q];
}

void comp(int a, int b) {
	if (a == b) {
		dp[a][b] = (s[a]=='1')+1;
		return;
	}

	if (s[a] == '1')
		dp[a][b] = 2*dp[a+1][b]%p;
	else
		dp[a][b] = dp[a+1][b]%p;

	for (int i = 1; i <= (b-a+5)/2; ++i) {
		bool x[i];
		for (int k = 0; k < i; ++k)
			x[k] = 1;
		ll tot = (1LL<<i)-1;
		for (int j = a; j+i-1 <= b; j += i) {
			for (int k = j; k < j+i; ++k) {
				if (s[k] == '1')
					continue;
				else {
					if (x[k-j] == 1) {
						tot -= (1LL<<(k-j));
						x[k-j] = 0;
					}
				}
			}

			if (j == a)
				continue;
			ll u = ans(i, tot);
			if (j+i-1 == b) {
				dp[a][b] = (dp[a][b] + u)%p;
			} else {
				dp[a][b] = (dp[a][b] + u*dp[j+i][b])%p;
			}
		}
	}
}


int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

	cin >> s;
	n = s.length();

	p2[0] = 1;
	for (int i = 1; i < 105; ++i)
		p2[i] = 2*p2[i-1]%p;

	for (int l = 0; l < n; ++l)
		for (int i = 0; i+l < n; ++i)
			comp(i, i+l);
	cout << dp[0][n-1] << endl;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define pb push_back
#define endl "\n"
#define inf 1000000007
#define for(i, a, b) for(int i=a; i<b; i++)
int dp[1000001] = {0}; 	

bool check(int *arr, int n){
	for(i, 1, n){
		if(*(arr+i) <= *(arr+i-1)){
			return false;
		}
	}
	return true;
}
void solve(){
	int n, curr=0, m=INT_MIN;
	cin>>n;
	int arr[n];
	for(i, 0, n) cin>>arr[i];
		if(check(arr, n)){
			cout<<'0';
			return;
		}
	for(i, 1, n){
		if(arr[i]>arr[i-1]){
			//cout<<i<<" "<<curr<<endl;
			m = max(curr, m);
			curr=0;
		}
		else curr++;
	}
	cout<<max(curr, m);
}
signed main(){	
	#ifdef _DEBUG
		freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
	#endif
	
	ios::sync_with_stdio(false);
	cin.tie(0);
	int t=1;
	//cin>>t;
	while(t--){
		solve();
	}
	return 0;
 
}

Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
import sys
import math
import os
import itertools
import string
import heapq
import _collections
from collections import Counter
from collections import defaultdict
from functools import lru_cache
import bisect
import re
import queue
from decimal import *


class Scanner():
    @staticmethod
    def int():
        return int(sys.stdin.readline().rstrip())

    @staticmethod
    def string():
        return sys.stdin.readline().rstrip()

    @staticmethod
    def map_int():
        return [int(x) for x in Scanner.string().split()]

    @staticmethod
    def string_list(n):
        return [input() for i in range(n)]

    @staticmethod
    def int_list_list(n):
        return [Scanner.map_int() for i in range(n)]

    @staticmethod
    def int_cols_list(n):
        return [int(input()) for i in range(n)]


class Math():
    @staticmethod
    def gcd(a, b):
        if b == 0:
            return a
        return Math.gcd(b, a % b)

    @staticmethod
    def lcm(a, b):
        return (a * b) // Math.gcd(a, b)

    @staticmethod
    def divisor(n):
        res = []
        i = 1
        for i in range(1, int(n ** 0.5) + 1):
            if n % i == 0:
                res.append(i)
                if i != n // i:
                    res.append(n // i)
        return res

    @staticmethod
    def round_up(a, b):
        return -(-a // b)

    @staticmethod
    def is_prime(n):
        if n < 2:
            return False
        if n == 2:
            return True
        if n % 2 == 0:
            return False
        d = int(n ** 0.5) + 1
        for i in range(3, d + 1, 2):
            if n % i == 0:
                return False
        return True


def pop_count(x):
    x = x - ((x >> 1) & 0x5555555555555555)
    x = (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x = (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f
    x = x + (x >> 8)
    x = x + (x >> 16)
    x = x + (x >> 32)
    return x & 0x0000007f


MOD = int(1e09) + 7
INF = int(1e15)


def main():
    # sys.stdin = open("sample.txt")
    N = Scanner.int()
    A = Scanner.map_int()
    S = sum(A)
    x0 = S
    for i in range(1, N, 2):
        x0 -= 2 * A[i]
    ans = []
    ans.append(x0)
    for i in range(N - 1):
        x = 2 * A[i] - ans[-1]
        ans.append(x)
    print(*ans)


if __name__ == "__main__":
    main()


Measured memory_bytes: 87444