akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <vector>

using namespace std;
 
#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

typedef int64_t ll; typedef vector<int> VI; typedef pair<int,int> pii;
const ll mod = 1e9+7;

void dbg(){ cerr << "\n"; }  
template <typename T,typename ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }


int main()
{
 
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int ai;
	cin >>ai;
	VI a(4);
	
	rep(i, 4){
		a[3-i] = ai%10;
		ai /=10;
	}
	string s="1+2+3+4=7";
	rep(i, 4) s[i*2]=char(a[i]+'0');
	rep(i, 1<<3){
		int sm = a[0];
		rep(j, 3){
		 sm += (i>>j &1)? a[j+1]: -a[j+1];
		}
		if(sm ==7){
			rep(j,3) s[j*2+1] = (i>>j &1)? '+':'-';
			cout << s <<endl;
			return 0;
		}
	}
	
	return 0;
}


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

#define ll long long

int main()
{

           ll n,x;
           cin>>n;

           ll a[n];

          ll c[n+5]={0};

           for(int i=0;i<n;i++){
               cin>>x;
               x--;

               a[i]=x;

               c[x]++;
           }


           ll ans=0;

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

                ans+=((c[i]-1)*(c[i]-2))/2;

                //cout<<ans<<" ";
           }


           ll res=0;

           for(int i=0;i<n;i++){
                ll y=a[i];

                res = ans;
                res-= ((c[y])*(c[y]-1))/2;

                res+= ((c[y]-2)*(c[y]-1))/2;

                cout<<res<<endl;

           }




    return 0;
}


Measured memory_bytes: 5760
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
using namespace std;

int main(){
  long long N; cin >> N;
  vector<string>s(N);
  for(int i=0;i<N;i++){
    cin >> s.at(i);
    sort(s.at(i).begin(),s.at(i).end());
  }
  long long ans = 0;
  map<string,long long>count;
  for(int i=0;i<N;i++){
    count[s.at(i)]++;
  }
  for(auto itr = count.begin();itr != count.end();itr++){
    ans += itr->second*(itr->second-1)/2;
  }
  cout << ans << endl;
}


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

int main() {
  	int a, b, c, d, e;
	int ans;
 	cin >> a >> b >> c >> d >> e;
  
  if(a==0){ans = 1;}
  if(b==0){ans = 2;}
  if(c==0){ans = 3;}
  if(d==0){ans = 4;}
  if(e==0){ans = 5;}
	cout << ans << endl;
}



Measured memory_bytes: 3520
#include<cstdio>
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;
int main(){
    int N;
    int a[100010]={0};
    int b[100010]={0};
    int ansk=0;
    int ansg=0;
    cin>>N;
    for(int i=0;i<N;i++){
        cin>>a[i];
        b[i]=a[i];
    }
    sort(b,b+N);
    for(int i=0;i<N;i++){
        int l=0,r=N,p=a[i];
        for(int j=0;j<20;j++){
            if(p<b[(l+r)/2])r=(l+r)/2;
            else if(p>b[(l+r)/2])l=(l+r)/2;
            else break;
        }
        if(i%2==0&&((l+r)/2)%2==1)ansg++;
        if(i%2==1&&((l+r)/2)%2==0)ansk++;
    }
    cout<<max(ansk,ansg)<<endl;
    return 0;
}




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

const int mod = 1e9+7;
const int INF = 2000000;
const double PI = acos(-1.0);

int main() {
    int N;
    cin >> N;
    ll ans=1,a[N];
    bool f=false;
    for (int i = 0; i < N; i++)
    {
        cin >> a[i];
    }
    ll M = 1e18;
    sort(a,a+N);
    if(a[0] == 0) ans = 0;
    else {
        for(ll n:a){
            M /= n;
        }
        if(M < 1) ans = -1;
        else {
            for(ll n:a){
                ans *= n;
            }
        }
    }
    cout << ans << endl;
    
}


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

int main(){    
    string S, T;
    cin >> S;
    cin >> T;

    int ans = 0;

    for (int i = 0; i < S.size(); i++)
    {
        if (S[i] != T[i])
        {
            ans += 1;
        }
        
    }

    cout << ans << endl;
    
}

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

int main(){

    int n;
    cin >> n;
    string s;
    cin >> s;

    if(n%2){
        cout << "No" << endl;
    }else{
        for(int i = 0; i < n/2; ++i){
            if(s[i] != s[i+n/2]){
                cout << "No" << endl;
                return 0;
           }
        }
        cout << "Yes" << endl;
    }

}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Runtime.CompilerServices;
using System.Text;
using static System.Console;
using static System.Math;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            try
            {
                Solve.Answer();
            }
            catch (Exception ex)
            {
                WriteLine(ex.ToString());
            }
        }
    }

    public class Solve
    {
        public static void Answer()
        {
            var nk = IO.ReadSplitInt;
            var l = IO.ReadSplitInt;
            l.Sort((x, y) => y - x);
            int sum = 0;
            for (int i = 0; i < nk[1]; i++)
            {
                sum += l[i];
            }
            WriteLine(sum);
        }

        public class IO
        {
            #region Input
            public static string ReadString => ReadLine();
            public static int ReadInt => int.Parse(ReadLine());
            public static long ReadLong => long.Parse(ReadLine());
            public static double ReadDouble => double.Parse(ReadLine());

            public static List<string> ReadSplitString => ReadLine().Split().ToList();
            public static List<int> ReadSplitInt => ReadLine().Split().Select(s => int.Parse(s)).ToList();
            public static List<long> ReadSplitLong => ReadLine().Split().Select(s => long.Parse(s)).ToList();
            public static List<double> ReadSplitdouble => ReadLine().Split().Select(s => double.Parse(s)).ToList();
            #endregion

            #region Output
            public static void OutJoinSpace<T>(IEnumerable<T> list) => WriteLine(string.Join(" ", list));
            public static void WriteLineYes_or_No(bool flag) => WriteLine(flag ? "Yes" : "No");

            #endregion
        }

        public class Mod
        {
            #region
            private readonly static long M = 1000000007;

            public static long Add(long a, long b) => (a * b) % M;
            public static long Sub(long a, long b) => (a - b) % M >= 0 ? (a - b) % M : (a - b) % M + M;
            public static long Multi(long a, long b) => (a * b) % M;
            #endregion
        }

        public static long GCD(long x, long y)
        {
            #region
            if (x < y)
            {
                var tmp = x;
                x = y;
                y = tmp;
            }
            while (true)

            {
                if (x % y == 0)
                {
                    return y;
                }
                else
                {
                    var tmp = x;
                    x = y;
                    y = tmp % y;
                }
            }
            #endregion
        }

        public static long Choice2(long n)
        {
            #region
            if (n <= 1)
                return 0;
            if (n == 2)
                return 1;
            else
                return n * (n - 1) / 2;
            #endregion
        }
    }
}

Measured memory_bytes: 11348
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int n = in.nextInt();
		StringBuilder ans = new StringBuilder();
		while (n != 0) {
			if (n % 2 != 0) {
				n--;
				ans.append(1);
			} else {
				ans.append(0);
			}
			n /= -2;
		}
		System.out.println(ans.length() > 0 ? ans.reverse().toString() : 0);
		in.close();
	}
}

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <

// Output, Common Containers
template <typename T> ostream& operator << (ostream &os, const vector<T> &v) { for (T i : v) os << i << ' '; return os; }
template <typename T> ostream& operator << (ostream &os, const set<T> &v)    { for (T i : v) os << i << ' '; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const pair<T,S> &v) { os << "(" << v.F << "=>" << v.S << ") "; return os; }
template <typename T, typename S> ostream& operator << (ostream &os, const map<T,S> &v)  { for (auto i : v) os << i << ' '; return os; }

// Debugging
#ifdef SANYAM1101
	#define trace(args...) do{ cerr << "TRACE ON! (Line: " << __LINE__ << ")\n"; auto _stream = istringstream{string{#args}}; d_f(_stream, args); } while(0)
	void d_f(__attribute__((unused)) istringstream& _stream) {}
	template<typename Head, typename... Tails> void d_f(istringstream& _stream, Head H, Tails... T) { string _name; _stream >> _name; if(_name.back() == ',') _name.pop_back(); cerr << "\t" << _name << " <=> [" << H << "]\n"; d_f(_stream, T...); }
#else
	#define trace(args...)
#endif


// CODE STARTS HERE

void solve(){
	int a, b;
	cin >> a >> b;
	int add = a + b;
	if(add >= 10) cout << "error";
	else cout << add;	
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3660
#include "bits/stdc++.h"

using namespace std;

const long long MAX = 2000000010;

void Main() {
    long long N;
    cin >> N;
    vector<long long> x(N, 0LL), y(N, 0LL);
    long long maxYpX = 0LL;
    long long minYpX = MAX;
    long long maxYmX = -MAX;
    long long minYmX = MAX;
    for (long long i = 0; i < N; ++i) {
        cin >> x[i] >> y[i];
        maxYpX = max(maxYpX, y[i] + x[i]);
        minYpX = min(minYpX, y[i] + x[i]);
        maxYmX = max(maxYmX, y[i] - x[i]);
        minYmX = min(minYmX, y[i] - x[i]);
    }

    long long ans = max(maxYpX - minYpX, maxYmX - minYmX);
    cout << ans << endl;
}

int main() {
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6420
#include<bits/stdc++.h>
#define D(x) cout<<"D: "<<#x<<'='<<x<<endl;
#define R(x, l) cout<<"R: Array "<<#x<<endl; for(int i = 0; i < l; i++) cout<<' '<<i<<':'<<*(x+i)<<endl;
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
template<typename tn> inline tn next(void)
{
	tn k;
	cin>>k;
	return k;
}
template<typename tn> inline ostream& operator << (ostream& os, const vector<tn>& v)
{
	for(unsigned i = 0; i < v.size(); i++) os<<v[i]<<' ';
	return os;
}
vector<int> v;
int main(void)
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int a, b, cnt = 0;
	cin>>a>>b;
	for(int i = 0; i < a; i++) v.pb(2);
	for(int i = 0; i < b; i++) v.pb(1);
	for(int i = 0; i < v.size(); i++)
		for(int j = i+1; j < v.size(); j++)
			if (!((v[i]+v[j])%2)) cnt++;
	cout<<cnt<<endl;
	return ~~(0-0);
}


Measured memory_bytes: 256
from collections import Counter
import string
alpha = list(string.ascii_lowercase)
n = int(input())
s = []
words = []
for i in range(n):
    s.append(Counter(input()))
for i in alpha:
    now = float("inf")
    for j in range(n):
        now = min(now, s[j].get(i, 0))
    if now:
        words.append([i, now])
ans = []
for i in words:
    ans.append(i[0] * i[1])

print("".join(ans))

Measured memory_bytes: 3768
N = int(input())
V = [int(i) for i in input().split()]

V.sort()
#print(V)

ans = 0

for i in range(N):
	if i == 0 or i == 1:
		ans += V[i] / (2**(N-1))
	else:
		ans += V[i] / (2**(N-i))

print(ans)

Measured memory_bytes: 3060
def main(n: int, s: str):
    i = 0
    ans = [0]

    for s in s:
        if s == 'I':
            i += 1
        else:
            i -= 1

        ans.append(i)

    print(max(ans))


if __name__ == '__main__':
    n = int(input())
    s = input()

    main(n, s)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
/* テンプレートここまで */
void yes(){
  cout << "YES" << endl;
  exit(0);
}

void no(){
  cout << "NO" << endl;
  exit(0);
}
int main() {
  ll n; cin >> n;
  vector<ll> p(n);
  ll cnt = 0;
  REP(i, n){
    cin >> p[i];
    if(p[i] != i+1) cnt++;
  }
  if(cnt==2 || cnt == 0) yes();
  else no();
}


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

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


Measured memory_bytes: 3096
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Washoum
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        inputClass in = new inputClass(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BYYMMOrMMYY solver = new BYYMMOrMMYY();
        solver.solve(1, in, out);
        out.close();
    }

    static class BYYMMOrMMYY {
        public void solve(int testNumber, inputClass sc, PrintWriter out) {
            String s = sc.nextLine();
            int first = Integer.parseInt(s.substring(0, 2));
            int second = Integer.parseInt(s.substring(2));
            if (first > 0 && first <= 12) {
                if (second > 12 || second == 0) {
                    out.println("MMYY");
                } else {
                    out.println("AMBIGUOUS");
                }
            } else if (second > 0 && second <= 12) {
                if (first > 12 || first == 0) {
                    out.println("YYMM");
                } else {
                    out.println("AMBIGUOUS");
                }
            } else {
                out.println("NA");
            }
        }

    }

    static class inputClass {
        BufferedReader br;

        public inputClass(InputStream in) {

            br = new BufferedReader(new InputStreamReader(in));
        }

        public String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }

    }
}



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

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

template<typename T>
void chmin(T &x, T y) { x = min(x, y); }

template<typename T>
void chmax(T &x, T y) { x = max(x, y); }

typedef long long int lli;
typedef long double ld;
typedef tuple<int,int> P;

const int INF = INT_MAX/2 - 1;
const double EPS = 1e-14;
const int dx[4] = {0, 1, 0, -1}; // {-1,  0,  1, -1, 1, -1, 0, 1};
const int dy[4] = {1, 0, -1, 0}; // {-1, -1, -1,  0, 0,  1, 1, 1};

int main() {
  cout << fixed << setprecision(10);
  int N, W;
  while (cin >> N >> W and N) {
    map<int,int> m;
    REP(i, N) {
      int v;
      cin >> v;
      m[v / W] ++;
    }
    int max_interval = 0, max_height = 0;
    for (auto p : m) {
      chmax(max_interval, p.first);
      chmax(max_height, p.second);
    }
    double ink = 0.01;
    for (auto p : m) {
      int interval = p.first, height = p.second;
      double gray = double(max_interval - interval) / max_interval;
      ink += gray * height / max_height;
    }
    cout << ink << endl;
  }
  return 0;
}

Measured memory_bytes: 3204
import java.util.Scanner;

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

    public void run() {
        Scanner sc = new Scanner(System.in);
        int X = sc.nextInt();
        System.out.println(getNextPrimeNumber(X));

    }

    public int getNextPrimeNumber(int num) {
        int i = num;
        while (true) {
            boolean isPrime = true;
            for (int j = 2; j < i; j++) {
                if (i % j == 0) {
                    isPrime = false;
                    break;
                }
            }
            if (isPrime) {
                return i;
            }
            i++;
        }
    }
}

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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

int main(){
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    rep(i, 1000) {
        string t;
        int x = i;
        rep(j, 3) {
            t += '0' + x % 10;
            x /= 10;
        }
        int ti = 0;
        rep(j, n) {
            if (s[j] == t[ti]) ++ti;
            if (ti == 3) {
                ++ans;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

int main() {
    string s, t;
    cin >> s >> t;
    int n = s.size(), m = t.size();
    sort(s.begin(), s.end());
    sort(t.begin(), t.end());
    reverse(t.begin(), t.end());
    bool solved = false;
    for (int i = 0; i < min(n, m); i++) {
        if (s[i] != t[i]) {
            solved = true;
            if (s[i] < t[i]) {
                cout << "Yes";
            } else {
                cout << "No";
            }
            break;
        }
    }
    if (!solved) {
        if (n < m) {
            cout << "Yes";
        } else {
            cout << "No";
        }
    }
    return 0;
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
int sum (int n){
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int N;
  cin >> N;
  int minimum = 100000;
  for (int A = 1; A < N; A++) {
    if (sum(A) + sum(N - A) < minimum) {
      minimum = sum(A) + sum(N - A);
    }
  }
  cout << minimum << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define F first
#define S second
#define vec vector
#define ms multiset
#define pb push_back
#define pll pair<ll,ll>
#define pdd pair<ld, ld>
#define pq priority_queue
#define umap unordered_map
#define uset unordered_set
#define pii pair<int, int>
#define pnn pair<Node*, Node*>
#define uid uniform_int_distribution
#define FILE ifstream in("board.in");ofstream out("board.out");
#define fast cin.tie(0);cout.tie(0);cin.sync_with_stdio(0);cout.sync_with_stdio(0);
using namespace std;
typedef string str;
typedef long long ll;
typedef long double ld;
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count()); //uid u1(5, 10); u1(rnd);
 
int main() {
    fast;
    ll a,k; cin>>a>>k;
    vec<pair<int, pii>> m(a);
    for(int q=0; q<a; q++){
        int a1,a2,x; cin>>a1>>a2>>x;
        m[q] = {x, {a1-x,a2-x-1}};
    }
    sort(m.begin(), m.end(), [](pair<int, pii> p1, pair<int, pii> p2){return p1.F<p2.F;});
    vec<int> ans(k);
    set<pii> s;
    for(int q=0; q<k; q++){
        int n; cin>>n;
        s.insert({n,q});
    }
    for(int q=0; q<a; q++){
        int l = m[q].S.F, r = m[q].S.S, x = m[q].F;
        for(; s.size()>0;){
            auto it = s.lower_bound({l,-1});
            if(it == s.end()) break;
            pii p = *it;
            if(p.F>r) break;
            ans[p.S] = x;
            s.erase(p);
        }
    }
    for(pii p : s) ans[p.S] = -1;
    for(int i : ans) cout<<i<<endl;
    
}

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

int main() {
  int n,white=0;
  cin>>n;
  char a[n];
  for(int i=0;i<n;i++){
    char c;
    cin>>c;
    a[i]=c;
    if(c=='.')white++;
  }
  int b[n+1];
  b[0]=white;
  for(int i=0;i<n;i++){
    if(a[i]=='.')b[i+1]=b[i]-1;
    else b[i+1]=b[i]+1;
  }
  sort(b,b+n+1);
  cout<<b[0]<<endl;
}


Measured memory_bytes: 1280
#include <functional>
#include <iostream>

int main() {
  int n, m;
  std::cin >> n >> m;

  bool graph[n][n];
  bool visited[n];
  for (int i = 0; i < n; i++) {
    visited[i] = false;
    for (int j = 0; j < n; j++) { graph[i][j] = false; }
  }

  for (int i = 0; i < m; i++) {
    int a, b;
    std::cin >> a >> b;
    graph[a - 1][b - 1] = true;
    graph[b - 1][a - 1] = true;
  }

  int cnt = 0;
  std::function<void(const int, const int)> dfs = [&](const int i, const int dpt) {
    if (visited[i]) return;
    if (dpt == n) {
      cnt++;
      return;
    }
    visited[i] = true;
    for (int j = 0; j < n; j++) {
      if (i == j) continue;
      if (graph[i][j]) dfs(j, dpt + 1);
    }
    visited[i] = false;
  };

  dfs(0, 1);
  std::cout << cnt << std::endl;
  return 0;
}



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

int main ()
{
    int a, b;
    cin >> a >> b;
    if (a > 9 || b > 9 || a < 1 || b < 1)
        cout << "-1" << endl;
    else cout << a * b << endl;
    return 0;
}


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

using namespace std;

typedef long long LL;

struct Disjoint_set {
    #define MAX_N 200001
    int pa[MAX_N], Rank[MAX_N];
    int sz[MAX_N];
    void init_union_find(int V) {
        for(int i=0; i<V; i++) {
            pa[i] = i;
            Rank[i] = 0;
            sz[i] = 1;
        }
    }
    int find(int x) {
        return x == pa[x] ? x : pa[x] = find(pa[x]);
    }
    
    int unite(int x, int y) {
        x = find(x), y = find(y);
        int S = sz[x]+sz[y];
        if(x != y){
            if(Rank[x] < Rank[y]) {
                pa[x] = y; 
                sz[y] = S;
                return y;
            }
            else{
                pa[y] = x;
                sz[x] = S;
                if(Rank[x] == Rank[y]) Rank[x] ++;
                return x;
            }
        }
        return x;
    }
    bool same(int x, int y) {
        return find(x) == find(y);
    }
};

Disjoint_set s1, s2;
map< pair<int, int>, int> ans;
//int ans[200001];

int main() {
    int N, K, L; cin >> N >> K >> L;
    s1.init_union_find(N);
    s2.init_union_find(N);
    for(int i = 0; i<K; ++i) {
        int p, q; cin >> p >> q; --p, --q;
        s1.unite(p, q);
    }
    for(int i = 0; i<L; ++i) {
        int p, q; cin >> p >> q; --p, --q;
        //if( s1.same(p, q) ) s2.unite(p, q);
        s2.unite(p, q);
    }
    for(int i = 0; i<N; ++i) ++ans[ make_pair(s1.find(i), s2.find(i)) ];
    for(int i = 0; i<N; ++i)
        printf("%d%c", ans[ make_pair(s1.find(i), s2.find(i)) ], " \n"[i==N-1]);
}


Measured memory_bytes: 16640
#include<iostream>
#include<algorithm>
#include<cmath>
#include<string>
using namespace std;

int main(){

  int K,S;
  cin >> K >> S;

  int count = 0;
  for(int i = 0; i <= K; i++){
    for(int j = 0; j <= K; j++){
      if( (S-i-j) < 0) break;
      if( (S-i-j) <= K) count++;

    }

  }

  cout << count << endl;
  return 0;
}


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

using namespace std;
int w[105];
int main(){
	int n;
	cin>>n;
	int ans=0;
	int a=1e9;
	for(int i=0;i<n;i++)cin>>w[i],ans+=w[i];
	for(int i=1;i<n;i++)w[i]=w[i-1]+w[i];
	for(int i=0;i<n;i++){
		a=min(a,abs(ans-w[i]-w[i]));
	}
	cout<<a<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define log(x) cout<<x<<endl
#define pb push_back
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;

int gcd(lint x, lint y){
  return y==0 ? x:gcd(y,x % y);
}

int digsum(int n) {
  int res = 0;
  while(n > 0) {
    res += n%10;
    n /= 10;
  }
  return res;
}

int dignum(int n) {
  int res = 0;
  while(n > 0) {
    res++;
    n /= 10;
  }
  return res;
}

int stringcount(string s, char c) {
  return count(s.cbegin(), s.cend(), c);
}

int lcm(lint x, lint y){
  return x/ gcd(x, y) * y;
}

int combi(int n, int r){
  int num = 1;
  for(int i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

int main(){
  int k;
  string s;
  cin>>k>>s;
  if(s.size()<=k){
    cout<<s;
  }
  else{
    string t;
    t=s.substr(0,k);
    cout<<t<<"...";
  }
}

Measured memory_bytes: 3628
n = int(input())
s = input()
ans = 0
for i in range(1,n-1):
    cnt = 0
    seen = []
    for char in s[:i]:
        if char in s[i:] and char not in seen:
            seen.append(char)
            cnt += 1
    ans = max(ans,cnt)
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define Int int64_t

using namespace std;

bool check(string s) {
	bool ret = true;
	for (int i = 0; i < s.size(); ++i) {
		if (s[i] != s[s.size() - 1 - i]) { ret = false; }
	}
	return ret;
}

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

	int n = s.size();
	bool ok = check(s);
	ok = ok && check(s.substr(0, (n - 1) / 2));
	ok = ok && check(s.substr((n + 3) / 2 - 1, n));

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

	return 0;
}


Measured memory_bytes: 256
// prc.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。
//

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


using namespace std;
int main()
{
    
    char at[4];
    int cnt = 0,n;
    for (int i = 0; i <= 3; i++) {
        cin >> at[i];

    }

  //  for (int i = 0; i <= 3; i++) {
    //
      //  cout << at[i];
    //}

    n = 3;

    for (int a = 3; a >= 1; a--) {
      //  cout << a << endl;
      //  cout << n << endl;
        for (int i = n; i > 0; i--) {
            //cout << i << endl;
            if (at[a] == at[i - 1]) {
                cnt = cnt + 1;
            }
        }
        n--;
    }


    if (cnt == 2) {
        // 出力
        cout << "Yes" << endl;

    }
    else {
        cout << "No" << endl;
    }
  //  cout << cnt << endl;
    return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
#define ld double 
#define rep(i,a,b) for(ll i=a; i<b; ++i)
#define BOOST std::ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb push_back
#define all(v) v.begin(),v.end()
#define sl(a) a.size()
#define mod 1000000007 
#define lcm(a,b) (a*b)/__gcd(a,b)
#define MAX1 100006
#define f first
#define s second
#define pi 2*acos(0.0)
void solve()
{
    ll x,k,d;  cin>>x>>k>>d;
    cin >> x >> k >> d;
    x = abs(x);
    if(x / d >= k) {
        cout << x - k * d << endl;
    }
    else {
        k -= x / d;
        if(k % 2 == 1) {
            cout << abs(d - x % d) << endl;
        }
        else {
            cout << x % d << endl;
        }
    }
}
int main()
{
    #ifndef ONLINE_JUDGE
    // for getting input from input.txt
    freopen("input.txt","r",stdin);
    // for writing output to output.txt
    freopen("output.txt","w",stdout);
    #endif
    BOOST
    int T=1;  //cin>>T;
    while(T--) solve();
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  int N,x;
  cin>>N>>x;
  vector<int> v1(N);
  for(int i=0;i<N;++i){
    cin>>v1[i];
  }
  ll y=0;
  for(int i=0;i<N-1;++i){
    if(v1[i]+v1[i+1]>x){
      if(v1[i]>=x){
        y+=v1[i+1];
        v1[i+1]=0;
        y+=(v1[i]-x);
        v1[i]=x;
      } else {
        y+=(v1[i+1]-(x-v1[i]));
        v1[i+1]=(x-v1[i]);
      }
    }
  }
  cout<<y<<endl;
  return 0;
}


Measured memory_bytes: 640
#include<cstring>
#include<cstdlib>
#include<cstdio>
#include<cmath>
#include<iostream>
using namespace std;
int query(long long x)
{
	cout<<"? "<<x<<endl;
	fflush(stdout);
	char c=getchar();
	while(c!='Y' && c!='N') c=getchar();
	if(c=='Y') return 1;
	return 0;
}
void solve(int l,int r)
{
	int k;
	while(l<=r)
	{
		int mid=(l+r)>>1;
		if(query(10ll*mid)) k=mid,r=mid-1;
		else l=mid+1;
	}
	cout<<"! "<<k;
}
int main()
{
	if(query(1e9))
	{
		int now=2e8;
		while(now)
		{
			if(query(now)==0) {cout<<"! "<<5*now;return 0;}
			now/=10;
		}
		cout<<"! 1";
	}
	else
	{
		int now=1;
		while(1)
		{
			if(query(now)==0) {solve(now/10,now-1);return 0;}
			now*=10;
		}
	}
	return 0;
}

Measured memory_bytes: 596
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <x86intrin.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define V vector
template <typename T> bool chmin(T &a, const T &b) {if(a > b){a = b; return true;} return false;}
template <typename T> bool chmax(T &a, const T &b) {if(a < b){a = b; return true;} return false;}
template<typename A, size_t N, typename T> void Fill (A (&array)[N], const T & val) {fill ((T*)array, (T*)(array+N), val);}
V<int> dx = {-1, 1,  0, 0, -1, -1,  1, 1};
V<int> dy = { 0, 0, -1, 1, -1,  1, -1, 1};

int main () {
    ll n, x, m; cin >> n >> x >> m;
    V<ll> a(1, x);
    map<ll, int> mp;
    ll y = x;
    mp[x] = 0;
    int cnt = 0;
    int loop_s, loop;
    while (true) {
        cnt++;
        ll ny = (y * y) % m;
        if (mp.count(ny)) {
            loop_s = ny;
            loop = cnt - mp[ny];
            break;
        }
        a.emplace_back(ny);
        mp[ny] = cnt;
        y = ny;
    }
    int s = mp[loop_s];
    ll ans = 0;
    rep(i, s) ans += a[i];
    ll loop_sum = 0;
    V<ll> loopp(loop);
    for (int i = s; i < a.size(); i++) {
        loopp[i-s] = a[i];
        loop_sum += a[i];
    }
    n -= s;
    ll loop_num = n / loop;
    ans += loop_sum * loop_num;
    n -= loop * loop_num;
    rep(i, n) ans += loopp[i];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 7128
<?php
$N = (int)trim(fgets(STDIN));
//$S = trim(fgets(STDIN));
//list($a,$b,$c,$d) = array_map('intval',explode(" ",trim(fgets(STDIN))));
//$A = array_map('intval',explode(" ",trim(fgets(STDIN))));

$s = 0;
for($i=1;$i<$N;$i++) {
  $s+=intdiv(($N-1),$i);
}
printf("%d\n",$s);


Measured memory_bytes: 16260
#include<iostream>

using namespace std;

int main() {
	int n, a, b, ans = 0;
	cin >> n >> a >> b;
	for (int i = 0; i < n; i++) {
		int t; cin >> t;
		if (t < a || b <= t)ans++;
	}
	cout << ans << 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 = sc.nextInt();
    int[][] task = new int[N][2];
    for (int i = 0; i < N; i++) {
      task[i][0] = sc.nextInt();
      task[i][1] = sc.nextInt();
    }
    int time = 0;
    Arrays.sort(task, (a,b) -> a[1]-b[1]);
    for (int i = 0; i < N; i++) {
      if (time + task[i][0] <= task[i][1]) {
        time += task[i][0];
      } else {
        System.out.println("No");
        return;
      }
    }

    System.out.println("Yes");
  }
}


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

using namespace std;

int main(){
    int n;
    while(true){
        cin>>n;
        if(n==0)break;
        int ans=-1;
        double t=1000000.0;
        for (int i = 0; i < n; ++i) {
            int p;
            double h,w;
            cin>>p>>h>>w;
            h=h/100.0;
            double tbmi=w/(h*h);
            if(t>abs(22.0-tbmi)){
                t=abs(22.0-tbmi);
                ans=p;
            }
        }
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3168
#include <bits/stdc++.h>
#define int long long
#define inf 0x3f3f3f3f
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
const int maxn=1e5+5;
int a[maxn], vis[maxn];

void slove(int l, int r)
{
    for(int i=l; i<=r; i++)
        vis[i] = 1;
}

signed main()
{
    int cnt=0, n, h, w;
    cin >> n>> h>> w;
    for(int i=1; i<=n; i++)
        cin >> a[i];
    for(int i=1; i<=n; i++)
    {
        int l, r;
        l = (i-1)*w;
        r = i*w;
        l += a[i]*(i&1==1?1:-1);
        r += a[i]*(i&1==1?1:-1);

        //printf("%lld %lld\n", l, r);
        vis[l] ++;
        vis[r] --;
    }
    for(int i=0; i<n*w; i++)
    {
        vis[i] += vis[i-1];
        if(!vis[i])
            cnt ++;
    }
    cout<<cnt*h<<endl;
    return 0;
}



Measured memory_bytes: 3176
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll N=1e5+5;
ll a[N],red[N];
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    ll n,m;cin>>n>>m;
    for(ll i=1;i<=n;i++)red[i]=0,a[i]=1;
    red[1]=1;
    for(ll i=0;i<m;i++){
        ll x,y;cin>>x>>y;
        if(red[x])red[y]=1;

        a[x]-=1;
        a[y]+=1;

        if(a[x]==0)red[x]=0;
    }

    ll ans = 0;
    for(ll i=1;i<=n;i++)ans+=red[i];

    cout<<ans;
}



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

a,b = map(int, input().split())

bt = 0
if b % 2:
    bt = ((b + 1) // 2) % 2
else:
    bt = (b // 2) % 2
    bt ^= b

at = 0
if (a - 1) % 2:
    at = (a // 2) % 2
else:
    at = ((a - 1) // 2) % 2
    at ^= (a - 1)

print(bt ^ at)


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

using namespace std;


int main() {
    int n;
    cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    int ans = 0;
    for(int i = 0; i < n; i++) {
        if(a[a[i]-1] == i + 1) {
            ans++;
        }
    }
    cout << ans / 2 << "\n";
    return 0;
}

Measured memory_bytes: 3672
//region Template
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "../debug_prettyprint.hpp"
#else
#define debug(...) 42
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#endif
#define FASTIO ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); cout<<fixed<<setprecision(12);
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
#define EXIT(answer) { cerr<<"EXIT #"<<__LINE__<<endl; cout<<answer<<endl; exit(0); }
#define sz(v) int(v.size())
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> istream& operator>>(istream& in, pair<T,U> &p) { in>>p.first>>p.second; return in; }
template<typename T> inline vector<T> READ(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> using min_heap = priority_queue<T, vector<T>, greater<T> >;
typedef signed long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
//endregion

const int MOD = 1e9+7;
const int MAXN=5e5+5;
ll fac[MAXN+1];
ll invfac[MAXN+1];

ll inverseModulo(ll a, ll b){
    return 1<a ? b - inverseModulo(b % a, a) * b / a : 1;
}
ll binomial(int n, int k) {
    assert(k>=0 && k<=n);
    if(k==0 || n-k==0) return 1;
    return fac[n] * invfac[k] % MOD * invfac[n-k] % MOD;
}

ll f(int m, int n, int id) {
    if(id==n)
        return 1;

    ll fp = binomial(n, id) % MOD;
    ll other = binomial(m-id, n-id) * fac[n-id] % MOD;

    return (fp*other - f(m, n, id+1)) % MOD;
}

int main() {
    FASTIO

    fac[0]=1;
    invfac[0]=1;
    RNG(i,1,MAXN) {
        fac[i] = 1LL*i*fac[i-1] % MOD;
        invfac[i] = inverseModulo(fac[i], MOD);
    }

    int n,m; cin>>n>>m;

    ll a = binomial(m,n) * fac[n] % MOD;
    ll b = a - f(m,n,1) + MOD;

    cout<<a*b%MOD<<endl;
}

Measured memory_bytes: 27012
#include <iostream>

using namespace std;

long long A[200001];

int main(){
  int i,N,x=0;
  long long S=0;
  cin >> N;
  cin >> A[0];
  for (i=1;i<N;++i) {
    cin >> A[i];
    if (A[i]-A[i-1]==1) {
      S+=1;
    } else if (A[i]-A[i-1]>1) {
      x=-1;
    } else {
      S+=A[i];
    }
  }
  if (A[0]!=0||x==-1) {
    cout << -1 << endl;
    return 0;
  }
  cout << S << endl;
  return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<int,int>;

int main(){
    ll n;
    cin>>n;
    vector<ll>v(n);
    rep(i,n){
     cin>>v[i];
     if(0<i&&v[i-1]<v[i]){
         v[i]--;
     }
    }
   ll now=v[0];
   rep(i,n-1){
       if(v[i]<=v[i+1])continue;
       cout<<"No"<<endl;
       return 0;
   }
   cout<<"Yes"<<endl;
}


Measured memory_bytes: 4056
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>

int main()
{
    int N, W;
    std::cin >> N >> W;
    std::vector<int> v(N), w(N);
    for (int i = 0; i < N; i++)
        std::cin >> v[i] >> w[i];

    int dp[110][10010];

    for (int i = 0; i < N; i++)
    {
        dp[i][0] = 0;
        for (int j = 0; j <= W; j++)
        {
            if (w[i] > j)
                dp[i + 1][j] = dp[i][j];
            else
                dp[i + 1][j] = std::max(dp[i][j], dp[i][j - w[i]] + v[i]);
        }
    }

    std::cout << dp[N][W] << std::endl;

    return 0;
}


Measured memory_bytes: 6960
import sys; input = sys.stdin.buffer.readline
mod = 998244353; INF = float("inf")
sec = pow(2, mod - 2, mod)

def getlist():
	return list(map(int, input().split()))

class lazySegTree(object):
	# N:処理する区間の長さ
	def __init__(self, N):
		self.N = N
		self.LV = (N - 1).bit_length()
		self.N0 = 2 ** self.LV
		self.data = [0] * (2 * self.N0)
		self.lazybeta = [1] * (2 * self.N0)
		self.lazy = [0] * (2 * self.N0)

	def initialize(self, A):
		for i in range(self.N):
			self.data[self.N0 - 1 + i] = A[i]
		for i in range(self.N0 - 2, -1, -1):
			self.data[i] =( self.data[2 * i + 1] + self.data[2 * i + 2]) % mod

	def gindex(self, l, r):
		L = (l + self.N0) >> 1; R = (r + self.N0) >> 1
		lc = 0 if l & 1 else (L & -L).bit_length()
		rc = 0 if r & 1 else (R & -R).bit_length()
		for i in range(self.LV):
			if rc <= i:
				yield R
			if L < R and lc <= i:
				yield L
			L >>= 1; R >>= 1

	def propagates(self, *ids):
		for i in reversed(ids):
			w = self.lazybeta[i - 1]
			v = self.lazy[i - 1]
			if w == 1 and (not v):
				continue
			val = (v * sec) % mod
			self.lazybeta[2 * i - 1] = (self.lazybeta[2 * i - 1] * w) % mod
			self.lazybeta[2 * i] = (self.lazybeta[2 * i] * w) % mod
			self.lazy[2 * i - 1] = (self.lazy[2 * i - 1] * w + val) % mod
			self.lazy[2 * i] = (self.lazy[2 * i] * w + val) % mod
			self.data[2 * i - 1] = (self.data[2 * i - 1] * w + val) % mod
			self.data[2 * i] = (self.data[2 * i] * w + val) % mod
			self.lazybeta[i - 1] = 1; self.lazy[i - 1] = 0

	def update(self, l, r, b, c):
		*ids, = self.gindex(l, r + 1)
		self.propagates(*ids)
		L = self.N0 + l; R = self.N0 + r + 1
		v = c; w = b
		while L < R:
			if R & 1:
				R -= 1
				self.lazybeta[R - 1] = (self.lazybeta[R - 1] * w) % mod
				self.lazy[R - 1] = (w * self.lazy[R - 1] + v) % mod
				self.data[R - 1] = (self.data[R - 1] * w + v) % mod
			if L & 1:
				self.lazybeta[L - 1] = (self.lazybeta[L - 1] * w) % mod
				self.lazy[L - 1] = (w * self.lazy[L - 1] + v) % mod
				self.data[L - 1] = (self.data[L - 1] * w + v) % mod
				L += 1
			L >>= 1; R >>= 1; v <<= 1
		for i in ids:
			self.data[i - 1] = (self.data[2 * i - 1] + self.data[2 * i]) % mod

	def query(self, l, r):
		self.propagates(*self.gindex(l, r + 1))
		L = self.N0 + l; R = self.N0 + r + 1

		s = 0
		while L < R:
			if R & 1:
				R -= 1
				s += self.data[R - 1]
			if L & 1:
				s += self.data[L - 1]
				L += 1
			L >>= 1; R >>= 1
			s %= mod
		return s

def main():
	N, Q = getlist()
	A = getlist()
	lSeg = lazySegTree(N)
	lSeg.initialize(A)
	for _ in range(Q):
		q = getlist()
		if q[0] == 0:
			null, l, r, b, c = q
			lSeg.update(l, r - 1, b, c)
		else:
			null, l, r = q
			res = lSeg.query(l, r - 1)
			print(res)

if __name__ == '__main__':
	main()


# 5 3
# 1 1 1 1 1
# 0 0 4 10 3
# 0 1 5 20 3
# 1 2 3

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

using namespace std;

typedef long long int li;
typedef vector<li> vi;
typedef pair<li,li> pi;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define B begin()
#define E end()
#define f(i,l,r) for(li i=l;i<=r;++i)
#define fr(i,l,r) for(li i=l;i>=r;--i)
#define u_map unordered_map
#define endl "\n"

li fastpow(li base,li exp,li M) 
{
    li res=1;
    while(exp>0) {
        if(exp&1)
            res=(res*base)%M;

        base=(base*base)%M;
        exp>>=1;
    }
    return res;
}

vi par,sz,vis;
vector<vi> graph;

void init(li n)
{
    par.resize(n);
    sz.resize(n);
    vis.resize(n);
    graph.resize(n);

    f(i,0,n-1)
    {
        par[i]=i;
        sz[i]=1;
    }
}

li root(li a)
{
    while(a!=par[a])
    {
        par[a]=par[par[a]];
        a=par[a];
    }

    return a;
}

void unio(li a,li b)
{
    li r_a=root(a);
    li r_b=root(b);

    if(par[r_a]!=r_b)
    { 
        if(sz[r_a]<sz[r_b])
        {
            par[r_a]=par[r_b];
            sz[r_b]+=sz[r_a];
            sz[r_a]=0;
        }
        else
        {
            par[r_b]=par[r_a];
            sz[r_a]+=sz[r_b];
            sz[r_b]=0;
        }
    }
}

int main()
{    
    

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);

    li a,b;

    cin>>a>>b;

    if(a<b)
    {
        li sum=0;

        while(b--)
        {
            cout<<a;
        }
    }
    else if(a==b)
    {
        while(b--)
            cout<<a;
    }
    else
    {
        while(a--)
        cout<<b;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<cstdio>
#include<map>
using namespace std;

const int N=500005;

struct node{
	int x,y;
}p[N];
int h,w,n,lx,ly,ans;
map<int,int> mp[N];

bool cmp(node a,node b){
	return a.y<b.y||(a.y==b.y&&a.x<b.x);
}

int main(){
//	freopen("a.in","r",stdin);
//	freopen("a.out","w",stdout);
	int i,j,k;
	scanf("%d%d%d",&h,&w,&n);
	for (i=1;i<=n;i++) scanf("%d%d",&p[i].x,&p[i].y),mp[p[i].x][p[i].y]=1;
	sort(p+1,p+1+n,cmp); lx=2; ly=1; ans=h;
	for (i=1;i<=n;i++) if (p[i].y==1) ans=min(ans,p[i].x-1);
	for (i=1;i<=n;i=j+1){
		j=i;
		for (k=i;k<n&&p[k+1].y==p[i].y;k++);
		j=k;
		while (p[i].x<p[i].y&&i<=j) i++;
		if (i>j) continue;
		if (p[i].y==1) continue;
		if (lx+p[i].y-ly-1>=h) break;
		if (!mp[lx+p[i].y-ly-1][p[i].y]){
			lx+=p[i].y-ly-1;
			ly=p[i].y;
		}
		else{
			for (k=i;k<=j;k++) if (p[k].x+1<=h){
				if (p[k].x+2-lx>=p[k].y-ly&&!mp[p[k].x+1][p[k].y]){
					lx=p[k].x+1; ly=p[k].y;
					break;
				}
			}
		}
		if (ly<p[i].y) break;
		for (k=i;k<=j;k++) if (p[k].x>lx) ans=min(ans,p[k].x-1);
		if (lx>=h) break;
		if (mp[lx+1][ly]) break;
		lx++;
	}
	printf("%d\n",ans);
	return 0;
}

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

typedef long long ll;

int main(){
    //freopen("in.txt","r",stdin);
    ll a, b, c, d;
    cin>>a>>b>>c>>d;
    ll x1 = a * c, x2 = a * d, x3 = b * c, x4 = b * d;
    ll y1 = max(x1, x2), y2 = max(x3, x4);
    cout<<max(y1, y2);
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#include<algorithm>
using namespace std;
long long int __lcm(long long int a,long long int b){
  long long int n;
  n=a*b/__gcd(a,b);
  return n;
}
 //__gcd 最大公約数
 //__lcm 最小公倍数
 //double 少数（変数）
//sqrt ルート
//ceil 天井関数
//floor 床関数

int main() {
  int n,a,b,c,d;
  cin>>n>>a>>b>>c>>d;
  vector<char> e(n);
  for(int i=0;i<n;i++)
    cin>>e[i];
  int a1=0;
  string anc="Yes";
  for(int i=a;i<c;i++){
    if(i==d)
      for(int j=b-1;j<d;j++){
        if(e[j-1]=='.'&&e[j]=='.'&&e[j+1]=='.'){
          a1=0;
          break;
        }
        else if(j==d-1)
          anc="No";
      }
    else if(e[i]=='#')
      a1++;
    else
      a1=0;
    if(a1==2)
      anc="No";
  }
  a1=0;
  for(int i=b;i<d;i++){
    if(e[i]=='#')
      a1++;
    else
      a1=0;
    if(a1==2)
      anc="No";
  }
  cout<<anc;
}

Measured memory_bytes: 384
from collections import deque
import bisect

N = int(input())
table = deque()
for n in range(N):
    a = int(input())
    if n == 0:
        table.append(a)
    else:
        if a <= table[0]:
            table.appendleft(a)
        else:
            table[bisect.bisect_left(table, a)-1] = a
            
print(len(table))

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

using namespace std;

bool comp(pair<int,int> a, pair<int,int> b){
	return a.first < b.first;
}

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

	int n;
	cin >> n;
	vector<pair<int,int>> v(n);
	for(int i=0; i<n; i++){
		int a;
		cin >> a;
		v.push_back(make_pair(a,i));
	}
	sort(v.begin(), v.end(), comp);
	int mx = v.back().first;
	for(int i=0; i<n; i++){
		if(i!=v.back().second){
			cout << mx;
		}
		else{
			cout << v[v.size()-2].first;
		}
		cout << endl;
	}
	return 0;
}

Measured memory_bytes: 6312
// n using Sieve of Eratosthenes 
#include <bits/stdc++.h> 
#include <iostream>
#include <cmath>
using namespace std;
# define M_PI 3.14159265358979323846 

 
int main(){
double r;cin>>r;
r=2*r;
cout<<M_PI*r;
	
return 0;	
}

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

#define ALL(v) v.begin(), v.end()
typedef pair<int, int> P;
int main() {
	int N;
	cin >> N;
	vector<P> v;
	for (int i = 0; i < N; i++) {
		int a;
		cin >> a;
		v.emplace_back(a, 0);
	}
	for (int i = 0; i < N; i++) {
		int b;
		cin >> b;
		v.emplace_back(b, 1);
	}
	sort(ALL(v));
	int x = 0, y = 0;
	ll ans = 1;
	for (P p : v) {
		if (p.second == 0) {
			if (y == 0) {
				x++;
			}
			else {
				(ans *= y) %= MOD;
				y--;
			}
		}
		else {
			if (x == 0) {
				y++;
			}
			else {
				(ans *= x) %= MOD;
				x--;
			}
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 2420