akhauriyash/Code-Regression huggingface dataset:
#ifdef LOCAL
#define _GLIBCXX_DEBUG
#endif
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define reps(i,a,b) for(int i=a;i<b;++i)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int a, b, c;
    cin >> a >> b >> c;
    int ans = 0;
    for (int i = a; i <= b; ++i) {
        if (c % i == 0) ans++;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3216
#include <stdio.h>
#include <stdbool.h>
#include <string.h>
#include <math.h>
#define INF 1001001001
#define ll long long
#define rep(i,n)  for(i=0; i<n;  i++)
#define rep2(i,n) for(i=1; i<=n; i++)

int  get_min(int a, int b){ if(a<b) return a; else return b; }
int  get_max(int a, int b){ if(a>b) return a; else return b; }

int main(){
    ll h,w;
    scanf("%lld %lld",&h,&w);
    ll all_cell = h * w;
    if(get_min(h,w) == 1){
        printf("1\n");
        return 0;
    }
    ll answer = (all_cell+1) / 2;
    printf("%lld",answer);
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;
typedef long long ll;

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()

int main()
{
	vector<int> V;

	REP(i, 3){
		int x;
		cin >> x;
		V.push_back(x);
	}
	
	sort(ALL(V));

	REP(i, 3){
		cout << V[i];
		if(i < 3-1)
			cout << " ";
	}
	cout << endl;
	

	return 0;
}




Measured memory_bytes: 3128
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <cassert>

using namespace std;
typedef long long LL;
template <typename F, typename S> std::ostream& operator<<(ostream& os, const pair<F,S>& p) {
    os << "(" << p.first << "," << p.second << ")"; return os; }
template <typename T> ostream& operator<<(ostream& os, const vector<T>& v) {
    os << "["; for(const T& a: v){ os << a << ", "; } os << "]"; return os; }
template <typename K, typename V> ostream& operator<<(ostream& os, const map<K,V>& m) {
    os << "{"; for(const auto& p: m){ os << p.first <<":"<< p.second << ", "; } os << "}"; return os; }

vector<LL> solve(LL n, LL m, string s){
    vector<LL> ans;
    LL cur = n;
    while(cur > 0){
        LL v = 0;
        for(LL i = 1; i <= m; ++i){
            if(cur - i < 0) break;
            if(s[cur-i] == '0'){
                v = i;
            }
        }
        if(v == 0) return vector<LL>{-1};
        ans.push_back(v);
        cur -= v;
    }
    reverse(ans.begin(), ans.end());
    return ans;
}


int main(){
    LL n, m;
    cin >> n >> m;
    string s;
    cin >> s;
    vector<LL> ans = solve(n, m, s);
    for(LL i = 0; i < ans.size(); ++i){
        if(i+1 == ans.size()){
            cout << ans[i] << endl;
        }else{
            cout << ans[i] << " ";
        }
    }
    return 0;
}



Measured memory_bytes: 1592
<?php
list($A,$B)=sscanf(trim(fgets(STDIN)),"%d %d");
$max=-10000;
$calc=$A+$B;
if($calc>$max) $max = $calc;
$calc=$A-$B;
if($calc>$max) $max = $calc;
$calc=$A*$B;
if($calc>$max) $max = $calc;
printf($max);

Measured memory_bytes: 4604
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <sstream>
#include <unordered_map>
#include <vector>


#define INF 4000000000000000000LL
#define MOD 1000000007
#define ALL(x) std::begin(x), std::end(x)


int main(int argc, char** argv)
{
  std::cin.tie(0);
  std::ios_base::sync_with_stdio(0);

  std::cout << std::fixed << std::setprecision(6);
  std::cerr << std::fixed << std::setprecision(6);

  int N, n = 0, a[200000][2], b[2];

  std::string X;

  std::cin >> N >> X;

  for (const auto& c : X)
    if (c == '1')
      n ++;

  a[0][0] = a[0][1] = b[0] = b[1] = 0;

  for (int i = 0, u = 1, v = 1; i < N; i ++) {
    int y = X[N - 1 - i] - '0';

    if (n - 1) {
      (b[0] += y * (a[i][0] = u)) %= (n - 1);
      
      u = u * 2 % (n - 1);
    }
    
    (b[1] += y * (a[i][1] = v)) %= (n + 1);

    v = v * 2 % (n + 1);
  }

  for (int i = 0; i < N; i ++) {
    int j = N - 1 - i;

    if (n == 1 && X[i] == '1') {
      std::cout << 0 << std::endl;
    }
    else {
      int x = X[i] == '1' ? (b[0] - a[j][0] + (n - 1)) % (n - 1) : (b[1] + a[j][1]) % (n + 1), c = 1;

      for ( ; x; c ++) {
        int y = __builtin_popcount(x);

        x %= y;
      }

      std::cout << c << std::endl;
    }
  }

  return 0;
}


Measured memory_bytes: 5264
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin >> n;
    long long int a[n];
    for(int i=0; i<n;i++){
        cin >> a[i];
    }
    int x=sizeof(a)/sizeof(a[0]);
    sort(a,a+x);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cout << "NO"<< endl;
            return 0;
        }
    }
    cout << "YES" <<endl;
    return 0;
}

Measured memory_bytes: 1792
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main 
{
	public static void main(String[] args) {
		new Thread(null, new Runnable() {
			public void run() {
                solve();
            }
        }, "1", 1 << 26).start();
	}
	static void solve () {
		FastReader fr =new FastReader();	PrintWriter op =new PrintWriter(System.out);
 
 		int k =fr.nextInt() ;	String s =fr.next() ;
 		if (s.length()<=k)	op.println(s) ;
 		else 	op.println(s.substring(0,k)+"...") ;
		op.flush();	op.close();
	}
	static class FastReader {
		BufferedReader br;
		StringTokenizer st;

		public FastReader() {
			br =new BufferedReader(new InputStreamReader(System.in));
		}

		String next() {
			while (st==null || (!st.hasMoreElements())) 
			{
				try
				{
					st =new StringTokenizer(br.readLine());
				}
				catch(IOException e)
				{
					e.printStackTrace();
				}
				
			}
			return st.nextToken();
		}

		String nextLine() {
			String str ="";

			try
			{
				str =br.readLine();
			}
			catch(IOException e)
			{
				e.printStackTrace();
			}

			return str;
		}

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

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

Measured memory_bytes: 36660
#include <iostream>
#define INF LLONG_MAX
#define ll  long long
#define ull unsigned long long
#define rep(i,n) for(int i=0; i<n; ++i)
#define MOD 1000000007
using namespace std;
template<class T> inline bool chmin(T& a, T b) { if(a>b) {a=b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if(a<b) {a=b; return true;} return false;}

int main() {
  int N; cin >> N;
  int odd = 0;
  rep(i, N) {
    int A; cin >> A;
    if(A%2) ++odd;
  }
  printf("%s\n", odd%2?"NO":"YES");
}

Measured memory_bytes: 256
S = input()
while True:
    if S[-6:] == "eraser":
        S = S[:-6]
        if len(S) == 0:
            print("YES")
            exit(0)
    elif S[-7:] == "dreamer":
        S = S[:-7]
        if len(S) == 0:
            print("YES")
            exit(0)
    elif S[-5:] == "dream" or S[-5:] == "erase":
        S = S[:-5]
        if len(S) == 0:
            print("YES")
            exit(0)
    else:
        print("NO")
        exit(0)


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

int main()
{
    int x,y;
    cin >> x;
    cin >> y;
    multiset<int>v;
    int in;
    for (int i = 0; i <x ; ++i)
    {
        cin >> in;
        v.insert(in);
    }
    int res = 0; int c = 0;
    for (auto i = v.begin(); i != v.end() and c != y; i++)
    {
        res += *i;
        c++;
    }
    cout << res << endl;
}
//C:\Users\dell\Desktop\untitled\cmake-build-debug\untitled.exe
//5 3
//50 100 80 120 80


Measured memory_bytes: 3628
x,n = gets.split(' ').map(&:to_i)
p = gets.split(' ').map(&:to_i)
count = 0
plus = x
minus = x
minus_found = p.include?(x)
plus_found = p.include?(x)
if p.length == 0
    puts x
else
    if !minus_found
        puts x
    else
        while (minus_found && plus_found)
            plus +=1
            minus -= 1
            plus_found = p.include?(plus)
            minus_found = p.include?(minus)
            if plus_found == false || minus_found == false
                break
            end
        end
        if !plus_found && minus_found
            puts plus
        elsif plus_found  && !minus_found
            puts minus
        else
            puts (x- plus).abs < (x - minus).abs ? plus : minus
        end
    end
end

Measured memory_bytes: 14312
#include <iostream>
#include <vector>
#include <cmath>
using namespace std;
const int MOD = 1e9 + 7;
int cnt;
int mod(long long x){return (x % MOD + MOD ) % MOD;}
void dfs(int , vector<int>[] , bool[]);
int main(){
    int N , M;
    cin >> N >> M;

    bool visited[N + 1] = {0};
    vector<int> adjlist[N + 1];
    for (int i = 0 , a , b ; i < M ; i++){
        cin >> a >> b;
        adjlist[a].push_back(b);
        adjlist[b].push_back(a);
    }

    int ans = 0;
    for (int i = 1 ; i <= N ; i++){
        if (!visited[i])
            cnt = 0 , dfs(i , adjlist , visited) , ans = max(ans , cnt);
    }
    cout << ans << endl;
}
void dfs(int n , vector<int> adjlist[] , bool visited[]){
    //cout << "mengunjungi " << n << endl;
    ++cnt;
    visited[n] = 1;
    for (int it : adjlist[n]){
        if (!visited[it])
            dfs(it , adjlist , visited);
    }
}


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

typedef int i ;
typedef double d ;
typedef string s ;

int main ()
{
   i yold , cost ;

   cin >> yold >> cost ;

   if (yold >= 13)
    cout << cost << endl ;
   else if (yold >= 6 && yold <= 12)
    cout << cost / 2 << endl ;
   else if (yold <= 5 )
    cout << 0 << endl ;
    //its_Rashid
    return 0 ;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
  public static void main(String[] args){

    Scanner sc = new Scanner(System.in);

   int N = sc.nextInt();
   String S = sc.next();
   int sum = 1;

   for(int i = 1; i < N; i++){

    if(S.charAt(i) != S.charAt(i - 1)){
     sum = sum + 1;
    }
   }
   System.out.println(sum);
  }
}

Measured memory_bytes: 25260
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
const ll inf=1e18;
const int N=1e5+3;
const int p=1e9+7;
int n,m;
ll f[N];
void init(){
	f[0]=1;
	for(int i=1;i<N;i++) f[i]=f[i-1]*i%p;
}
int main(){
	init();
    cin>>n>>m;
    if(abs(n-m)>1){
    	cout<<0<<endl;
    	return 0;
    }
    if(n==m){
    	cout<<2*f[n]*f[m]%p<<endl;
    }
    else cout<<f[n]*f[m]%p<<endl;
    return 0;
}

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

int main(){
    int n;
    cin>>n;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int b[n];
    for(int i=0;i<n;i++){
        b[i]=i+1;
    }
    int c=0;
    for(int i=0;i<n;i++){
        if(a[i]%2!=0&&b[i]%2!=0){
            c++;
        }
    }
    cout<<c;


}


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

int main() {
    int t; cin >> t; int arr[4]; memset(arr, 0, sizeof(arr));
    while(t--) {
        string s; cin >> s; if (s == "AC") arr[0]++;
        if (s == "WA") arr[1]++; if (s == "TLE") arr[2]++; if (s == "RE") arr[3]++;
    }   cout << "AC x " << arr[0] << endl;
        cout << "WA x " << arr[1] << endl;
        cout << "TLE x " << arr[2] << endl;
        cout << "RE x " << arr[3] << endl;
}

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

long long layer_num[51], patty_num[51];

long long getPatty(long long n, long long x) {
    if (n == 0) {
        return (x == 1 ? 1 : 0);
    } else if (x <= 1 + layer_num[n - 1]) {
        return getPatty(n - 1, x - 1);
    } else if (x == layer_num[n - 1] + 1) {
        return patty_num[n - 1];
    } else if (x == layer_num[n - 1] + 2) {
        return patty_num[n - 1] + 1;
    } else if (x == 2 * layer_num[n - 1] + 2 || x == 2 * layer_num[n - 1] + 3) {
        return 2 * patty_num[n - 1] + 1;
    } else {
        return patty_num[n - 1] + 1 + getPatty(n - 1, x - (layer_num[n - 1] + 2));
    }
}

int main() {
    long long N, X;
    cin >> N >> X;

    layer_num[0] = 1;
    patty_num[0] = 1;
    for (int i = 1; i <= 50; i++) {
        layer_num[i] = 2 * layer_num[i - 1] + 3;
        patty_num[i] = 2 * patty_num[i - 1] + 1;
    }

    cout << getPatty(N, X) << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  vi a(3);
  cin >> a[0] >> a[1] >> a[2];
  sort(all(a));
  int ans = 0;
  while(a[1] < a[2]) {
    ans++;
    a[0]++;
    a[1]++;
  }
  ans += (a[1] - a[0] + 1) / 2;
  if(a[1] % 2 != a[0] % 2) ans++;
  cout << ans << endl;
}

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

void printVec(std::vector<int> &vec)
{
  std::cout << "";
  for (auto it = vec.begin(); it != vec.end(); ++it)
  {
    std::cout << *it << " ";
  }
  std::cout << std::endl;
}
int main() {
  // string S, T;
  // cin >> S >> T;
  // int A, B;
  // cin >> A >> B;
  // string U;
  // cin >> U;
  // if (U == S) {
  //   A -= 1;
  // } else {
  //   B -= 1;
  // }
  // cout << A << " " << B;

  // string S;
  // cin >> S;
  // int len;
  // len = S.length();
  // string ans;
  // for (int i = 0; i < len; i++) {
  //   ans += "x";
  // }
  // cout << ans << endl;

  int N;
  cin >> N;
  vector<int> A(N, 0);
  for (int i = 0; i < N; i++)
  {
    int val;
    cin >> val;
    A.at(i) = val;
  }
  int org_len = A.size();
  sort(A.begin(), A.end());
  A.erase(unique(A.begin(), A.end()), A.end());
  if (org_len == A.size())
  {
    cout << "YES" << endl;
  } else {
    cout << "NO" << endl;
  }
}

Measured memory_bytes: 1024
#include <stdio.h>
#define MAX_A 100010

int cnt[MAX_A];

int main(void)
{
    int n;
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        int a;
        scanf("%d", &a);
        cnt[++a]++;
    }
    int ans = 0;
    for (int i = 0; i < MAX_A; i++) {
        int cur = cnt[i - 1] + cnt[i] + cnt[i + 1];
        if (cur > ans) ans = cur;
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define    ll          unsigned long long int
#define    sz          200010
#define    md          1000000007
#define    py          printf("Yes\n")
#define    pn          printf("No\n")
#define    sc1(a)      scanf("%lld",&a)
#define    sc2(a,b)    scanf("%lld %lld",&a,&b)
#define    pv(a)      printf("%lld\n",a)

using namespace std;

map<string,string>mp;

int main()
{


       string s;

       ll i,j,k,p,d,m,n;

       cin>>s;

       for(i=0;i<s.length();i++)
       {
           if(i%2==0)
           {
               if(s[i]=='L')
               {
                   pn;
                   return 0;
               }
           }
           else
           {
               if(s[i]=='R')
               {
                   pn;
                   return 0;
               }
           }
       }
       py;


    return 0;
}


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

//# include <x86intrin.h>
# include <bits/stdc++.h>

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

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

#define _USE_MATH_DEFINES_
#define ll long long
#define ld long double
#define Accepted 0
#define pb push_back
#define mp make_pair
#define sz(x) (int)(x.size())
#define every(x) x.begin(),x.end()
#define F first
#define S second
#define lb lower_bound
#define ub upper_bound
#define For(i,x,y)  for (ll i = x; i <= y; i ++) 
#define FOr(i,x,y)  for (ll i = x; i >= y; i --)
#define SpeedForce ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0)
// ROAD to...                                                                                                                                                                                                                Red

inline void Input_Output () {
	//freopen(".in", "r", stdin);
   //freopen(".out", "w", stdout);
}

const double eps = 0.000001;
const ld pi = acos(-1);
const int maxn = 1e7 + 9;
const int mod = 1e9 + 7;
const ll MOD = 1e18 + 9;
const ll INF = 1e18 + 123;
const int inf = 2e9 + 11;
const int mxn = 1e6 + 9;
const int N = 6e5 + 123;                                          
const int M = 22;
const int pri = 997;
const int Magic = 2101;

const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, -1, 0, 1};
 
int n, m, k;
int a[N];
int b[N];
//	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
//	shuffle(permutation.begin(), permutation.end(), rng);



bool check (int x) {
	ordered_set < pair < int, int > > q;
	ll ans = 0;
	q.insert({0, 0});
	for (int i = 1; i <= n; ++i) {
		b[i] = b[i-1];
		if (a[i] >= x) b[i]++;
		else b[i]--;
		ans += q.order_of_key({b[i], n+1});
  		q.insert({b[i], i});
	}
	ll overall = n * (ll)(n+1) / 2;

	return ans * 2 >= overall;
}

int main () {
	scanf("%d", &n);
	for (int i = 1; i <= n; ++i) {
		scanf("%d", a + i);
	}

	int l = 1, r = 1e9 + 1;
	while (r - l > 1) {
		int md = (l + r) >> 1;
		if (check(md)) {
			l = md;
		} else {
			r = md;
		} 
	}

	printf("%d\n", l);

	return Accepted;
}

// B...a

Measured memory_bytes: 8960
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define MOD 1000000007

int prime[1005];

int main(){
  int N;
  cin>>N;
  for(int i=1;i<=N;i++){
    int m = i;
    for(int j=2;j<=sqrt(m);j++){
      while(m%j == 0){
        prime[j]++;
        m /= j;
      }
    }
    if(m != 1)
      prime[m]++;
  }
  long long ans = 1;
  for(int i=2;i<=N;i++)
    if(prime[i])
      ans = ans * (prime[i] + 1) % MOD;
  cout<<ans<<endl;
  return 0;
}


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

int main()
{
    int n,k;

    cin >> n >> k;
    vector<int> d(100);
    int a[100][100];
    int bucket[100] = {0};
    for (size_t i = 0; i < k; i++)
    {
        cin >> d[i];
        for (size_t j = 0; j < d[i]; j++)
        {
            cin >> a[i][j];
            bucket[a[i][j] - 1]++;
        }
    }

    int ans = 0;
    for (int i = 0; i < n; i++)
    {
        if(bucket[i] == 0)ans++;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 3664
#include <stdio.h>
#define N 105

int main(){
  int M[N][N],A[N],n,u,k,i,j;

  scanf("%d",&n);

  for(i=1;i<=n;i++){
    for(j=1;j<=n;j++){
      M[i][j]=0;
    }
  }

  for(i=1;i<=n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=1;j<=k;j++){
      scanf("%d",&A[j]);
      M[i][A[j]] = 1;
    }
  }
  
  for(i=1;i<=n;i++){
    for(j=1;j<n;j++){
      //
      printf("%d ",M[i][j]);
      
    }
     printf("%d",M[i][j]);

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

  




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

using namespace std;

typedef long long ll;

const int mod = 1e9+7;

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	stack<char> stack;
	for(int i=0;i<n;i++){
		char c = s[i];
		if(stack.empty()){
			stack.push(c);
			continue;
		}
		if(stack.top()!=c){
			stack.push(c);
		}
	}
	cout << stack.size() << "\n";
	
	return 0;
}

Measured memory_bytes: 512
#include <stdio.h>

int main()
{
	int D[6];
	int i, t, f, q, e, tp, fp, t1, t2, f1, f2;

	for (i = 0; i < 6; i++) scanf("%d", &D[i]);

	scanf("%d", &q);

	for (i = 0; i < q; i++)
	{
		scanf("%d", &t);
		tp = 0;
		while (D[tp] != t) tp++;

		scanf("%d", &f);
		fp = 0;
		while (D[fp] != f) fp++;

		t1 = tp / 3;
		t2 = t1 > 0 ? 3 - (t1 + tp % 3) : tp % 3;
		f1 = fp / 3;
		f2 = f1 > 0 ? 3 - (f1 + fp % 3) : fp % 3;

		e = t1 ^ f1;
		e = f2 - (t2 + 1) % 3 != 0 ? !e * 3 : e * 3;
		e += e > 0 ? (t2 + f2) - 1 : 3 - (t2 + f2);

		printf("%d\n", D[e]);
	}
	
	return 0;
}

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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;
typedef vector < vector<ll> > Mat;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, M;
priority_queue <ll> que;
ll A[int(1e5+5)];
Pll P[int(1e5+5)];

int main(){
  cin >> N >> M;
  for (int i = 0; i < N; i++){
    cin >> A[i]; que.push(A[i]);
  }
  for (int i = 0; i < M; i++){
    ll B, C; cin >> B >> C;
    P[i] = {C, B};
  }
  sort(P, P + M, greater<Pll>());

  ll cnt = 0;
  for (int i = 0; i < M; i++){
    for (int j = 0; j < P[i].se; j++) que.push(P[i].fi);
    cnt += P[i].se;
    if (cnt >= N) break;
  }

  ll ans = 0;
  for (int i = 0; i < N; i++){
    ans += que.top(); que.pop();
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 7628
import java.io.BufferedInputStream;
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
        Scanner sc=new Scanner(new BufferedInputStream(System.in));
        long a=sc.nextLong();
        long b=sc.nextLong();
        long c=a*b+1;
        c/=2;
        if(a==1||b==1)
            System.out.println("1");
        else
            System.out.println(c);

    }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#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 equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int main() {
  int n;
  string s;
  cin >> n >> s;

  rep(i, 4) {
    vector<char> c(n, 'a');
    if (i <= 1) c[0] = 'S';
    else c[0] = 'W';
    if (i & 1) c[1] = 'W';
    else c[1] = 'S';

    bool flag = true;

    rep(j, n) {
      char res;
      if (c[(j + 1) % n] == 'S' && s[(j + 1) % n] == 'o') res = c[j];
      else if (c[(j + 1) % n] == 'W' && s[(j + 1) % n] == 'x') res = c[j];
      else if (c[(j + 1) % n] == 'S' && s[(j + 1) % n] == 'x') {
        if (c[j] == 'S') res = 'W';
        else if (c[j] == 'W') res = 'S';
      }
      else if (c[(j + 1) % n] == 'W' && s[(j + 1) % n] == 'o') {
        if (c[j] == 'S') res = 'W';
        else if (c[j] == 'W') res = 'S';
      }

      if (c[(j + 2) % n] == 'a') c[(j + 2) % n] = res;
      else if (c[(j + 2) % n] != res) {
        flag = false;
        break;
      }
    }

    if (flag) {
      rep(i, n) cout << c[i];
      cout << endl;
      return 0;
    }
  }
  cout << -1 << endl;


  
  return 0;
}

Measured memory_bytes: 512
#define _USE_MATH_DEFINES // M_PIなどの定義を使用するのに必要
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int H1, M1, H2, M2, K;

  cin >> H1 >> M1 >> H2 >> M2 >> K;

  int time_1 = H1 * 60 + M1;
  int time_2 = H2 * 60 + M2;

  cout << time_2 - time_1 - K << endl;

  return 0;
}


Measured memory_bytes: 3636
def lb(k, a):
    n = len(a)
    l, u = 0, n
    while l < u:
        m = (l + u) // 2
        if k < a[m]:
            u = m
        else:
            l = m + 1
    return l

def ub(k, a):
    n = len(a)
    l, u = -1, n - 1
    while l < u:
        m = (l + u + 1) // 2
        if a[m] < k:
            l = m
        else:
            u = m - 1
    return l

N = int(input())
A = sorted([int(x) for x in input().split()])
B = sorted([int(x) for x in input().split()])
C = sorted([int(x) for x in input().split()])

res = 0
for i in range(N):
    j = ub(B[i], A)
    k = lb(B[i], C)
    res += (j + 1)*(N - k)

print(res)

Measured memory_bytes: 29036
import java.util.Scanner;
import java.util.stream.IntStream;

/**
 * 解説どおりに作成したソースコード
 */
public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt();
			int[] a = new int[n];
			IntStream.range(0, n).forEach(i -> a[i] = scanner.nextInt());
			if (isIncreasing(a)) {
				System.out.println(0);
				return;
			}
			int maxValue = 0, maxIndex = 0;
			int minValue = Integer.MAX_VALUE, minIndex = 0;
			for (int i = 0; i < a.length; i++) {
				if (a[i] > maxValue) {
					maxValue = a[i];
					maxIndex = i + 1;
				}
				if (a[i] < minValue) {
					minValue = a[i];
					minIndex = i + 1;
				}
			}
			System.err.println("maxValue=" + maxValue + ",maxIndex=" + maxIndex);
			System.err.println("minValue=" + minValue + ",minIndex=" + minIndex);
			if ((maxValue <= 0) || (minValue >= 0)) {
				System.out.println(n - 1);
				// すべてが負の数か正の数の場合
				printSteps(n, (maxValue <= 0));
			} else {
				int fromIndex = (Math.abs(maxValue) > Math.abs(minValue)) ? maxIndex : minIndex;
				System.out.println(2 * n - 1);
				printAddSteps(n, fromIndex);
				printSteps(n, (fromIndex == minIndex));
			}
		}
	}

	/**
	 * @param a 入力配列
	 * @return 入力配列は単調増加かどうか
	 */
	static boolean isIncreasing(int[] a) {
		for (int i = 1; i < a.length; i++) {
			if (a[i] < a[i - 1]) {
				return false;
			}
		}
		return true;
	}

	/**
	 * 長さnの数列の計算ステップを出力する
	 * 
	 * @param n       数列の長さ
	 * @param reverse 逆順かどうか
	 */
	private static void printSteps(int n, boolean reverse) {
		if (reverse) {
			IntStream.range(1, n).map(i -> n - i).forEach(i -> System.out.println((i + 1) + " " + i));
		} else {
			IntStream.range(1, n).forEach(i -> System.out.println(i + " " + (i + 1)));
		}
	}

	/**
	 * 数列のすべてにindexの数字を足す計算ステップを出力する
	 * 
	 * @param n     数列の長さ
	 * @param index 加算もととなるindex
	 */
	private static void printAddSteps(int n, int index) {
		IntStream.rangeClosed(1, n).forEach(i -> System.out.println(index + " " + i));
	}
}


Measured memory_bytes: 29652
#!/bin/bash

name=()
time=()
read total
for ((i=0; i < ${total}; i++)); do
        read n t
        name=("${name[@]}" $n)
        time=("${time[@]}" $t)
done

read target

for ((i=0; i < ${total}; i++)); do
        if [ ${target} = ${name[$i]} ]; then 
                break   
        fi      
done
let i++
slp=0
for ((; i < ${total}; i++)); do
        slp=$((${slp}+${time[$i]}))
done
echo $slp

exit

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

using namespace std;

#define REP1(i,n) for(int i=1, i##_len=(n); i<i##_len; ++i)
#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define pow(x) x*x
#define ll long long
static const ll MAX = 1000000;
static const ll INFTY = 1e12;
static const ll MOD = 1000000007;

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); };

struct edge {
    ll to, cost;
};

using Graph = vector<vector<int>>;
using _Graph = vector<vector<edge>>;


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

// 深さ優先探索
vector<bool> seen;
vector<int> colors;

int H, W, N;
int sx, sy, gx, gy; 
vector<vector<char>> field;
vector<vector<int>> dist;
//vector<pair<int, int>> gx, gy;
deque<pair<int, int>> que;

typedef vector<vector<int> > Matrix;

const ll INF = 1e18;

int main() {


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

    sort(L.begin(), L.end());
    int sum = 0;
    REP(i, N-1){
        sum += L[i];
    }
    if(L[N-1] < sum)cout << "Yes" << endl;
    else cout << "No" << endl;



}
/*
みんな、くるくるぱーにな〜れ
　∧＿∧　
（｡･ω･｡)つ━☆・*。
⊂　　 ノ 　　　・゜+.
　しーＪ　　　°。+ *´¨)
　　　　　　　　　.· ´¸.·*´¨) ¸.·*¨)
　　　　　　　　　　(¸.·´ (¸.·'* ☆
*/



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

#define Int int_fast64_t
#define pll pair<Int,Int>
template<class T> using pql = priority_queue<T,vector<T>>;
template<class T> using pq = priority_queue<T,vector<T>,greater<T>>;
#define LL(n) Int n; cin >> n;
#define RP(n) for (Int i = 0; i < n; i++)
#define REP(n,i) for (Int i = 0; i < n; i++)

struct node{
    int to;
    int length;
};

vector<vector<node>> to;
vector<int> flag;
vector<int> c;

void dfs(int from){
    for (auto z : to.at(from)){
        int next = z.to;
        int length = z.length;
        if (flag.at(next) == 0) {
            flag.at(next) = 1;
            if (length % 2 == 0) {
                c.at(next) = c.at(from);
            }else{
                c.at(next) = 1 - c.at(from);
            }
            dfs(next);
        }
    }
}

int main(void){
    LL(n);
    to.resize(n);
    flag.resize(n);
    c.resize(n);

    for (int i = 0; i < n - 1 ;i ++){
        int a, b , length;
        cin >> a >> b >> length;
        a--;
        b--;
        to.at(a).push_back({b,length});
        to.at(b).push_back({a,length});
    }
    dfs(0);
    for (auto z: c){
        cout << z << endl;
    }

}

Measured memory_bytes: 8576
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
using namespace std;

const int inf=2147483647;

int main()
{
	int n,m;
	cin>>n>>m;
	
	cout<<(n-1)*(m-1)<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdint.h>
typedef int64_t i64;

int main(void){
    i64 n, s = 26;
    int count = 1, i, p;
    char alpha[27] = "abcdefghijklmnopqrstuvwxyz";
    scanf("%ld", &n);
    while(n > 26*(s-1)/25){
        s *= 26;
        count++;
    }s /= 26;
    n -= 26*(s-1)/25+1;
    for(i = 0; i < count; i++){
        putchar(alpha[n/s]);
        n %= s;
        s /= 26;
    }
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		int k = in.nextInt();
		in.close();
		long num = 1;
		//べき乗について
		for (int i = 0; i < n - 1; i++) {
			num *= (k - 1);
		}

		long ans = num * k;
		System.out.println(ans);

	}
}

Measured memory_bytes: 21204
#include <iostream>
using namespace std;
 
int main()
{
	int n,a[25],ans=0;
	cin >> n;
	for (int i = 1; i <=n; i++) {
		int k;
		cin >> k;
		a[k] = i;
	}
	for (int i = 1; i <= n; i++) {
		int b;
		cin >> b;
		ans += b;
	}
	for (int i = 1; i < n; i++) {
		int c;
		cin >> c;
		if (a[i + 1] == a[i] + 1)
			ans += c;
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
    string s;
    cin >> s;

    int tuikaryoukin = 0;

    for(int i=0; i<3; i++) {

        if(s.at(i) == 'o')
        tuikaryoukin++;

    }

    tuikaryoukin *= 100;

    cout << 700 + tuikaryoukin << endl;

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s1,s2;
    cin>>s1>>s2;
    int len1=s1.length();
    int len2=s2.length();
    int dp[len1+1][len2+1];
    for(int i=0;i<=len1;i++)
    {
        for(int j=0;j<=len2;j++)
        {
            if(i==0 || j==0)
            {
                dp[i][j]=0;
            }
            else if(s1[i-1]==s2[j-1])
            {
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else
            {
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);
            }
           // cout<<dp[i][j]<<" ";
        }//cout<<"\n";
    }
   // cout<<dp[len1][len2]<<"\n";
    string res="";
    int r=len1;int c=len2;
    while(r>=0 && c>=0)
    {
            if(dp[r][c]>dp[r-1][c] && dp[r][c]>dp[r][c-1])
            {
                res+=s1[r-1];
                r--;
                c--;
            }
            else if(dp[r-1][c]>dp[r][c-1])
            {
                r--;
            }
            else
            {
                c--;
            }
    }
    reverse(res.begin(),res.end());
    cout<<res<<"\n";
}

Measured memory_bytes: 35456
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     is(a)               to_string(a)
#define     ci(a,c)             a-c
#define     debug(i)            cout<<"point :"<<i<<'\n';
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'

void solve(){
    int n,m,lim,val,sum = 0; cin>>n>>m;
    lim = ceil((n/double(4*m)));
    vi a(n);
    for(int i = 0; i < n; ++i){
    	cin>>a[i];
    	sum+=a[i];
    }
    lim = ceil((sum/double(4*m)));
    for(int i = 0; i < n; ++i){
    	if(a[i]>=lim) m--;
    }
    if(m>0) cout<<"No\n";
    else cout<<"Yes\n";
}

signed main() { 
    IO();
    
    int t=1;
    // cin>>t;
    while(t--) solve();
    return 0; 
}

Measured memory_bytes: 256
N, M = map(int, input().split())

ball_numbers = [2 * i for i in range(N)]
ball_numbers.extend([2 * i + 1 for i in range(M)])

count = 0
for i, num1 in enumerate(ball_numbers):
    for j, num2 in enumerate(ball_numbers):
        if i == j:
            continue
        if (num1 + num2) % 2 == 0:
            count += 1
print(count // 2)

Measured memory_bytes: 3060
#include<iostream>

using namespace std;

int main(){
    int N; 
    cin >> N;
    long A[N];
    long sum =0;
    for(int i =0; i<N; i++){
        cin >> A[i];
        if(i%2 == 1 )sum -=A[i];
        else sum +=A[i]; 
    }
    long pre = sum;
    cout << pre <<" ";
    for(int i=1; i<N; i++){
        cout << A[i-1]*2 - pre << " "; 
        pre = A[i-1]*2 -pre;
    }
    cout << endl;

    return 0;
}

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

int main(void){
	int a, b, c=0;
	cin >> a >> b;
	for(int i=a; i<=b; i++){
		if(i/10000==i%10 && (i/1000)%10==(i/10)%10) c++;
	}
	cout << c << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());

		LinkedList<Integer> ans = new LinkedList<Integer>();
		for (int i=0; i<n; i++){
			if (i%2 == 1){
				ans.add(Integer.parseInt(sc.next()));
			}else {
				ans.add(0, Integer.parseInt(sc.next()));
			}
		}

		if (n%2 == 0){
			Collections.reverse(ans);
		}
//		System.out.println(ans);

		for(int elem : ans.subList(0, ans.size()-1)){
			System.out.print(elem + " ");
		}
		System.out.println(ans.get(ans.size()-1));
	}
}


Measured memory_bytes: 73900
#include <stdio.h>

int main(void)
{
	int a, b;
	
	scanf("%d %d", &a, &b);
	
	if (a < b){
		printf("a < b\n");
	}
	else if (a > b){
		printf("a > b\n");
	}
	else {
	 printf("a == b\n");
	}
	
	return (0);
}

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

int main(){
  string S;
  cin >> S;
  
  int ans = 0;
  char now = S[0];
  for(int i = 1; i < S.size(); i++){
    if(S[i] == now){
      ans++;
    }
    if(now == '0'){
      now = '1';
    }else{
      now = '0';
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
// ITP1_11_A
#include <bits/stdc++.h>
#define endl "\n"
#define rep(i,n) for(int i=0;i<int(n);i++)
#define SZ(x) ((int)(x).size())
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}
namespace you {
    std::string to_string(char val) {
        return std::string(1, val);
        // return std::string{val};
        // you::to_string(char)
    }
}
vector<int> di(6);
tuple<int,int,int,int> c_sn(){
    return forward_as_tuple(di[0],di[1],di[4],di[5]);
}
tuple<int,int,int,int> c_we(){
    return forward_as_tuple(di[0],di[2],di[3],di[5]);
}

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

    string order="EEEENEEEENEEEENEEEEENEEEENNEEEE";
    for(int i=0;i<6;i++){
        int s;
        cin>>s;
        di[i]=s;
    }
    int num;
    cin>>num;
    for(int j=0;j<num;j++){
        int mae,top;
        cin>>top>>mae;
        for(int i=0;i<order.size();i++){
            int a,b,c,d;
            if(order[i]=='N'){
                tie(a,b,c,d)=c_sn();
                di[0]=b;
                di[1]=d;
                di[4]=a;
                di[5]=c;
            }else{
                tie(a,b,c,d)=c_we();
                di[0]=c;
                di[2]=a;
                di[3]=d;
                di[5]=b;
            } 
            //cout<<di<<endl;
            if(di[1]==mae and di[0]==top){
                cout<<di[2]<<endl;
                break;
            }     
        }
    }
    return 0;
}


Measured memory_bytes: 3228
import java.util.Scanner

object Main {
  def main(args: Array[String]): Unit = {
    val sc: Scanner = new Scanner(System.in)
    val Array(a, b) = sc.nextLine.split(" ").map(_.toInt)
    if (a + b >= 10) println("error")
    else println(a + b)
  }
}


Measured memory_bytes: 25420
#include <iostream>
 
int main()
{
  int N, K, result = 1;
  std::cin >> N >> K;

  for(int i = 0; i < N; i++)
  {
    if(result < K)
    {
      result *= 2;
    }
    else
    {
      result += K;
    }
  }

  std::cout << result;
  return 0;
}

Measured memory_bytes: 3188
#include <atcoder/segtree>
#include <cstdio>
#include <vector>

using namespace std;
using namespace atcoder;

int target;

int main() {

    auto op = [](int a, int b){ return max(a, b); };

    auto e = []{ return -1; };

    auto f = [](int v){ return v < target; };

    int n, q;
    scanf("%d %d", &n, &q);
    vector<int> a(n);
    for (int i = 0; i < n; i++) {
        scanf("%d", &(a[i]));
    }

    segtree<int, op, e> seg(a);

    for (int i = 0; i < q; i++) {
        int t;
        scanf("%d", &t);
        if (t == 1) {
            int x, v;
            scanf("%d %d", &x, &v);
            x--;
            seg.set(x, v);
        } else if (t == 2) {
            int l, r;
            scanf("%d %d", &l, &r);
            l--;
            printf("%d\n", seg.prod(l, r));
        } else if (t == 3) {
            int p;
            scanf("%d %d", &p, &target);
            p--;
            printf("%d\n", seg.max_right<f>(p) + 1);
        }
    }
}


Measured memory_bytes: 5748
#include<bits/stdc++.h>
#define N 605
using namespace std;
unsigned long long hashl[N][N],hashh[N][N],bin[N];char a[N][N],s[N];int n,base=233;
unsigned long long gethash1(int x,int y,int z){//第z列x,y之间的 
	return hashl[y][z]-hashl[x-1][z]*bin[y-x+1];
}
unsigned long long gethash2(int x,int y,int z){//第z行x,y之间的 
	return hashh[z][y]-hashh[z][x-1]*bin[y-x+1];
}
inline int solve(int A,int B){
	for (int i=1;i<=n;i++){
		unsigned long long tmp1=gethash1(B+i+1,B+n,i+A);
		unsigned long long tmp2=gethash2(A+i+1,A+n,i+B);
		if (tmp1!=tmp2) return 0;
	}
	return 1;
}
int main(){
	scanf("%d",&n);bin[0]=1;
	for (int i=1;i<=n*2;i++) bin[i]=(unsigned long long)bin[i-1]*base;
	for (int i=1;i<=n;i++){
		scanf("%s",s+1);
		for (int j=1;j<=n;j++) a[i][j]=s[j];
	}
	for (int i=1;i<=n;i++)
		for (int j=n+1;j<=2*n;j++) a[i][j]=a[i][j-n];
	for (int i=n+1;i<=2*n;i++)
		for (int j=1;j<=n;j++) a[i][j]=a[i-n][j];
	for (int i=n+1;i<=2*n;i++)
		for (int j=n+1;j<=2*n;j++) a[i][j]=a[i-n][j-n];
	for (int i=1;i<=2*n;i++)
		for (int j=1;j<=2*n;j++)
			hashh[i][j]=(unsigned long long)hashh[i][j-1]*base+(a[i][j]-'a'+1);//第i行的前缀 
	for (int j=1;j<=2*n;j++)
		for (int i=1;i<=2*n;i++)
			hashl[i][j]=(unsigned long long)hashl[i-1][j]*base+(a[i][j]-'a'+1);
	//printf("%d\n",hashh[1][2]);
	//printf("%d\n",hahsh[1][1]);
	//sscerr<<gethash2(2,2,1)<<endl;
	int ans=0;for (int A=0;A<n;A++)
		for (int B=0;B<n;B++)//(A+1,B+1),(n+A,B+n)范围 
			ans+=solve(A,B);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 6272
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define REPR(i,n) for (int i=(int)(n)-1;i>=0;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define valid(y,x,h,w) (0<=y&&y<h&&0<=x&&x<w)
#define tpl(...) make_tuple(__VA_ARGS__)
const int INF = 0x3f3f3f3f;
const double EPS = 1e-8;
const double PI = acos(-1);
const int dy[] = {-1,0,1,0};
const int dx[] = {0,1,0,-1};
typedef long long ll;
typedef pair<int,int> pii;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
template<typename Ch,typename Tr,typename C,typename=decltype(begin(C()))>basic_ostream<Ch,Tr>& operator<<(basic_ostream<Ch,Tr>&os,
const C& c){os<<'[';for(auto i=begin(c);i!=end(c);++i)os<<(i==begin(c)?"":" ")<<*i;return os<<']';}
template<class S,class T>ostream&operator<<(ostream &o,const pair<S,T>&t){return o<<'('<<t.first<<','<<t.second<<')';}
template<int N,class Tp>void output(ostream&,const Tp&){}
template<int N,class Tp,class,class ...Ts>void output(ostream &o,const Tp&t){if(N)o<<',';o<<get<N>(t);output<N+1,Tp,Ts...>(o,t);}
template<class ...Ts>ostream&operator<<(ostream&o,const tuple<Ts...>&t){o<<'(';output<0,tuple<Ts...>,Ts...>(o,t);return o<<')';}
template<class T>void output(T t,char z=10){if(t<0)t=-t,putchar(45);int c[20];
int k=0;while(t)c[k++]=t%10,t/=10;for(k||(c[k++]=0);k;)putchar(c[--k]^48);putchar(z);}
template<class T>void outputs(T t){output(t);}
template<class S,class ...T>void outputs(S a,T...t){output(a,32);outputs(t...);}
template<class T>void output(T *a,int n){REP(i,n)cout<<a[i]<<(i!=n-1?',':'\n');}
template<class T>void output(T *a,int n,int m){REP(i,n)output(a[i],m);}
template<class T>bool input(T &t){int n=1,c;for(t=0;!isdigit(c=getchar())&&~c&&c-45;);
if(!~c)return 0;for(c-45&&(n=0,t=c^48);isdigit(c=getchar());)t=10*t+c-48;t=n?-t:t;return 1;}
template<class S,class ...T>bool input(S&a,T&...t){input(a);return input(t...);}
template<class T>bool inputs(T *a, int n) { REP(i,n) if(!input(a[i])) return 0; return 1;}

ll func(ll x, ll n)
{
  return (n + x - 1) / x;
}
int main() {
  ll n,a,b,c,d,e;
  while(input(n,a,b,c,d,e)) {
    ll t = min({a,b,c,d,e});
    // cout << t << " " << func(t, n) << endl;
    cout << 4 + func(t, n) << endl;
  }
}


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

int main(void)
{
    long long X, K, D;
    cin >> X >> K >> D;

    X = abs(X);
    long long ans;

    if (X/D > K)
    {
        ans = X - (D * K);
    }
    else
    {
        if((K-(X/D)) % 2 == 0)
        {
            ans = X - ((X/D) * D);
        }
        else
        {
            ans = abs(X - (((X/D)+1)) * D);
        }
    }
    cout << ans << endl;
}

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

 
int main() {
    int n;
    cin >> n;
    vi a(26);
    rep(i, n) {
        string S;
        cin >> S;
        vi a_(26);
        rep(j, S.size()) {
            if(!i) a[S[j]-'a']++;
            a_[S[j]-'a']++;
        }
        rep(j, 26) {
            a[j] = min(a[j], a_[j]);
        }
        
    }

    string ans;
    rep(i, 26) {
        rep(j, a[i]) {
            ans += i + 'a';
        }
    }

    cout << ans << endl;
}

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

int main() {
	
	int n, k;
	cin >> n >> k;
	rep(i, n){
		int a;
		cin >> a;
	}
	int ans = 1;
	if(n > k){
		ans += ((n - k) + (k - 2)) / (k - 1);
	}
	cout << ans << endl;
	return 0;
}

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

int main(){
  int N=1;
  int A=0;
  int s;
  
  cin >> N >> A;
  s = N % 500;
  
  if(s <= A)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h> 
#define FOR(i,a,b) for(int i=(a);i<=(b);++i) 
#define RFOR(i,a,b) for(int i=(a);i>=(b);--i) 
#define REP(i,n) for(int i=0;i<(n);++i)
#define RREP(i,n) for(int i=(n);i>0;--i)
#define CI cin>> 
#define CO cout<<
#define EN <<endl 
#define all(x) (x).begin(),(x).end() 
#define asn ans
using namespace std;
template <typename T> istream& operator >> (istream& is, vector<T>& vec) { for (T& x : vec) is >> x; 	return is; }
using ll = long long;

int main() {
	int n, k; CI n >> k;
	int memo;
	int ans = 1;
	vector<int> a(n);
	REP(i, n) {
		CI a[i];
		if (a[i] == 1)memo = i;
	}

	for (int i = k; i < n; i+=(k-1)) {
		ans++;
	}

	CO ans EN;

	return 0;
}

Measured memory_bytes: 640