akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <map>
#include <math.h>
#include <vector>
#include <algorithm>
#include <cstdio>
#include <set>
#include <queue>
#include <sstream>
#include <stack>
#include <deque>
#include <memory.h>
#include <cassert>
#include <ctime>
#include <climits>
#include <list>
#include <time.h>
#include <unordered_map>
#include <bitset>
#include <exception>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long long ull;
#define pb push_back
#define mp make_pair
#define FILE "file"
#define lc v << 1
#define rc (v << 1) + 1
#define inf 1e+9
#define linf ll(1e+18)
#define dinf 1e+14

typedef long long ll;
#define pb push_back
#define mp make_pair

vector<int> v;

void solve()
{
    int n, q;
    cin >> n >> q;
    string s;
    cin >> s;
    
    v.resize(n);
    for(int i = 0; i < n - 1; i++)
    {
        v[i] = 0;
        if(s[i] == 'A' && s[i + 1] == 'C')
        {
            v[i] = 1;
        }
        
        if(i)
        {
            v[i] += v[i - 1];
        }
    }
    
    for(int i = 0; i < q; i++)
    {
        int l, r;
        cin >> l >> r;
        l--;
        r -= 2;
        
        int ans = 0;
        ans = v[r];
        if(l)
        {
            ans -= v[l - 1];
        }
        cout << ans << "\n";
    }
}

int main()
{
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    //freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.in", "r", stdin);freopen("/Users/bekhzodsoliev/Desktop/C++/cp/cp/file.out", "w", stdout);
    
    int t = 1;
    //cin >> t;
    
    while(t--)
    {
        solve();
    }
    
    return 0;
}


Measured memory_bytes: 1488
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
#include<string>
#include<iostream>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using bl = bool;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
using vbl = V<bl>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(ll)(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(ll)(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(ll)(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n,k;
  	ci(n>>k);
  vpll A(n);
  FOR(i,0,n){
    ci(A[i].fi>>A[i].se)
  }
  SORT(A);
  FOR(i,0,n){
    k-=A[i].se;
    if(k<=0){
      co(A[i].fi)
        break;
    }
  }
}
      


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <vector>
#include <cstring>
#include <map>
#include<cmath>
#include <algorithm>
#include <stack>
#include <queue>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(int argc, const char * argv[])
{
    ios_base::sync_with_stdio(false);
    int n;
    cin >> n;
    map<int, bool> visited;
    int ret = 0;
    int a;
    for(int i = 0; i < n; i ++){
        cin >> a;
        if(!visited[a]){
            visited[a] = true;
            ret ++;
        }
        else{
            ret --;
            visited[a] = false;
        }
    }
    cout << ret << endl;
    return 0;
}
//1234567894848
//1234567891011


Measured memory_bytes: 4992
#include <stdio.h>

int main(){
  int N,M;
  int a[51];
  int b[51];
  int A;
  scanf("%d %d",&N,&M);
  for(int i=0;i<M;i++){
    scanf("%d %d",&a[i],&b[i]);
  }
  for(int i=1;i<=N;i++){
    A=0;
    for(int j=0;j<M;j++){
      if(a[j]==i){
        A++;
      }
      if(b[j]==i){
        A++;
      }
    }
    printf("%d\n",A);
  }
  return 0;
  
}

Measured memory_bytes: 128
S = input()

len_S = len(S)
first = ("01" * (len_S//2+1))[:len_S]
second = ("10" * (len_S//2+1))[:len_S]

ans = min(bin(int(S,2) ^ int(first,2)).count('1'), bin(int(S,2) ^ int(second,2)).count('1'))
print(ans)


Measured memory_bytes: 3444
#include<bits/stdc++.h>
using namespace std;
int n;
int a[200010],ans[200010]={};
int main()
{
	cin>>n;
	for(int i=1;i<n;i++) cin>>a[i];
	for(int i=1;i<n;i++) ans[a[i]]++;
	for(int i=1;i<n;i++) cout<<ans[i]<<endl;
	cout<<'0';
	return 0;
}


Measured memory_bytes: 5148
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
/*逆元計算*/
long long int  modinv(long long a, long long m) {
	long long int b = m, u = 1, v = 0;
	while (b) {
		long long int t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
// index が条件を満たすかどうか
vector<long long int >meguru;
bool isOK(int index, int key) {
	if (meguru[index] >= key) return true;
	else return false;
}
// 汎用的な二分探索のテンプレ
int binary_search(int key) {
	int left = -1; //「index = 0」が条件を満たすこともあるので、初期値は -1
	int right = (int)meguru.size(); // 「index = a.size()-1」が条件を満たさないこともあるので、初期値は a.size()
	/* どんな二分探索でもここの書き方を変えずにできる！ */
	while (right - left > 1) {
		int mid = left + (right - left) / 2;

		if (isOK(mid, key)) right = mid;
		else left = mid;
	}
	/* left は条件を満たさない最大の値、right は条件を満たす最小の値になっている */
	return right;
}
int main() {
	int h;
	int a;
	cin >> h >> a;
	cout << (h + a - 1) / a;
}


Measured memory_bytes: 256
#pragma GCC optimize ("O3")
#include<bits/stdc++.h>


#include <cstdio>
#include <queue>
#include <set>
#include <string>
#include <stdbool.h>
#include<ctime>

#include <cstring>

#define pb push_back
#define p push

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

#define getI(a) scanf("%d",&a)
#define getII(a, b) scanf("%d%d",&a,&b)
#define getIII(a, b, c) scanf("%d%d%d",&a,&b,&c)
#define getL(a) scanf("%lld",&a)
#define getLL(a, b) scanf("%lld%lld",&a,&b)
#define getLLL(a, b, c) scanf("%lld%lld%lld",&a,&b,&c)
#define BEND(c) (c).begin(),(c).end()
#define BEND2(c) (c).rbegin(),(c).rend()
#define fi first
#define se second
#define pi 3.1415926535897932384626
#define getS(a) scanf("%s",a)
#define pfb(a) printf("%.10lf\n",a);
#define pfi(a) printf("%d",a);
#define pfii(a, b) printf("%d%d",a,b);
#define pfl(a) printf("%lld",a);
#define pfll(a, b) printf("%lld%lld",a,b);
#define pfd(a) printf("%.12lf ",a);
#define IOS ios_base::sync_with_stdio(false);cin.tie(0);
#define endl "\n"

#define MOD  ( int)(1e9 + 7)
#define MAXN (ll) ((1e6+5))
#define K 25
#define  ALPHABET_SIZE  26
//#define N (int)(1e5+10)
#define sag (sol|1)
#define sol (root<<1)
#define ort (bas+son)/2
#define INF (ll )1e18
#define int ll
using namespace std;
typedef vector<int> vi;
typedef vector<bool> vb;
typedef vector<vector<int>> vvi;
typedef vector<vector<pair<int, int>>> vvpi;
typedef vector<long long> vl;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair <ll, ll> pll;
typedef vector<vi> graph;


signed main(){
	IOS

		ll n, m; 
	cin >> n >> m;
	if (n > m)cout << "safe";
	else cout << "unsafe";
	
	return 0;
}

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

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

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

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe"<<"\n";
    }
    else
    {
        cout<<"safe"<<"\n";
    }


    return 0;
}


Measured memory_bytes: 3608
class Tree:
    def __init__(self, orders):
        self.root = None
        for order in orders:
            if len(order) == 1:
                self.inorder_print()
                self.preorder_print()
            else:
                fchr = order[0][0]
                key = int(order[1])
                if fchr == 'f':
                    self.find(key)
                elif fchr == 'i':
                    self.insert(key)
                else:
                    self.delete(key)

    def insert(self, key):
        z = Node(key)
        y = None
        x = self.root
        while x:
            y = x
            if z.key < x.key:
                x = x.left
            else:
                x = x.right
        z.parent = y
        if not y:
            self.root = z
        elif z.key < y.key:
            y.left = z
        else:
            y.right = z

    def find(self, key):
        x = self.root
        while True:
            if key == x.key:
                print('yes')
                break
            elif key < x.key:
                if x.left:
                    x = x.left
                else:
                    print('no')
                    break
            else:
                if x.right:
                    x = x.right
                else:
                    print('no')
                    break

    def delete(self, key):
        z = self.root
        while z.key != key:
            if key < z.key:
                z = z.left
            else:
                z = z.right

        if not z.left or not z.right:
            y = z
        else:
            y = self.get_successor(z)

        if y.left:
            x = y.left
        else:
            x = y.right

        if x:
            x.parent = y.parent

        if not y.parent:
            self.root = x
        elif y == y.parent.left:
            y.parent.left = x
        else:
            y.parent.right = x

        if y != z:
            z.key = y.key

        del (y)

    def get_successor(self, x):
        if x.right:
            return self.get_minimum(x.right)

        y = x.parent
        while y and x == y.right:
            x = y
            y = y.parent
        return y

    def get_minimum(self, x):
        while x.left:
            x = x.left
        return x

    def inorder_print(self):
        self.root.inorder_print()
        print()

    def preorder_print(self):
        self.root.preorder_print()
        print()


class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None

    def inorder_print(self):
        if self.left:
            self.left.inorder_print()
        print(' {}'.format(self.key), end='')
        if self.right:
            self.right.inorder_print()

    def preorder_print(self):
        print(' {}'.format(self.key), end='')
        if self.left:
            self.left.preorder_print()
        if self.right:
            self.right.preorder_print()


if __name__ == '__main__':
    import sys
    m = int(input())
    orders = [line.strip().split() for line in sys.stdin]
    Tree(orders)



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

int main() {
  int n;
  cin >> n;
  long int x=2;
  long int y=1;
  for(int i=0;i<(n-n%2)/2;i++){
    x += y;
    y += x;
  }
  
  if (n%2==0){
    cout << x << endl;
  }
  else{
    cout << y << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n;
  int64_t k;
  cin >> n >> k;
  vector<vector<int>> A(n,vector<int>(2));
  vector<vector<int>> hantei(n,vector<int>(2));
  for(int i = 0; i < n; i++) {
    int a;
    cin >> a;
    a--;
    A.at(i).at(0) = i;
    A.at(i).at(1) = a;
    hantei.at(i).at(0) = i;
  }
  
  int site = 0;
  bool fin = true;
  vector<int> mitinori(n+1, -1);
  int count = 0;
  mitinori.at(0) = 0;
  hantei.at(0).at(1)++;
  while(fin) {
    count++;
    int to = A.at(site).at(1);
    mitinori.at(count) = to;
    site = to;
    hantei.at(site).at(1)++;
    if(hantei.at(site).at(1) > 1) {
      fin = false;
    }
  }
  
  int iriguti = 0;
  for(int i = 0; i <= count; i++) {
    if(mitinori.at(i) == site) {
      iriguti = i;
      break;
    } 
  }
  int ans = 0;
  if(k < count) {
    ans = mitinori.at(k)+1;
  } else {
  	int loop = count - iriguti;
  	k -= iriguti;
  	k %= loop;
  	ans = mitinori.at(k+ iriguti)+1;
  }
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 25940
//F5で実行 Shift+F5で停止
//F9でブレークポイント
#include<cmath>
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
//Ctrl+PageUpで上部の大半を選択できる
// 1e18 = 10の18乗

void _main() {
	ll n;
	cin >> n;
	ll ans = 1e18; //10の18乗

	//範囲はi <= √n と同義
	//longlongにしないと i*i がオーバーフローする
	for (ll i = 1; i*i <= n; i++) {
		if (n%i != 0) continue; //整数でなければ i+1へ
		ll j = n / i;
		ans = min(ans, i + j - 2);
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <stack>
#include <vector>

#define FOR(i,k,n) for(int (i) = (k); (i) < (n); ++(i))
#define rep(i,n) FOR(i,0,n)
#define pb push_back
#define all(v) begin(v), end(v)
#define debug(x) cerr << #x << ": " << x << endl
#define debug2(x,y) cerr << #x << ": " << x << ", " << #y << ": " << y << endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
template<class T> using vv=vector<vector<T>>;
typedef deque<int> di;
typedef deque<deque<int>> ddi;


int main() {
    int n,x;
    while(true) {
        cin >> n >> x;
        if(n == 0 && x == 0) {
            return 0;
        }
        int c;   
        c = x%3 == 0 ? x/3: x/3 +1;
        int sum  =0;
        FOR(i,c,n+1){
            int upb,unb;
            upb = (x-i-1 < i-1) ? x-i-1: i-1;
            unb = ((x-i) %2 ==0) ? (x-i)/2 + 1 : (x-i+1)/2;
            if(unb > upb) {
                continue;
            }
            sum += upb - unb + 1;
        }
        cout << sum << endl;
    }
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  if (N == 25) cout << "Christmas" << endl;
  else if (N == 24) cout << "Christmas Eve" << endl;
  else if (N == 23) cout << "Christmas Eve Eve" << endl;
  else if (N == 22) cout << "Christmas Eve Eve Eve" << endl;
}

Measured memory_bytes: 764
#include <iostream>
#include <algorithm>
using namespace std;
int const INF = 1<<18;
int main() {
  int N, M; cin >> N >> M;
  int G[420][420]; fill(G[0], G[0]+410*410, -INF);
  for(int i=0; i<M; i++) {
    int a, b; cin >> a >> b; cin >> G[a][b];
  }
  for(int i=0; i<N; i++) G[i][i] = 0;
  for(int k=0; k<N; k++)
    for(int i=0; i<N; i++)
      for(int j=0; j<N; j++)
        G[i][j] = max(G[i][j], G[i][k]+G[k][j]);
  cout << G[0][N-1] << endl;
  return 0;
}

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

int main(){
  string S;
  cin >> S;
  int count1=0;
  for(int i=0;i<S.size();i++){
    if (i%2==0 && S.at(i)!='1')
      count1++;
    if (i%2==1 && S.at(i)!='0')
      count1++;
  }
  int count2=0;
  for(int i=0;i<S.size();i++){
    if (i%2==0 && S.at(i)!='0')
      count2++;
    if (i%2==1 && S.at(i)!='1')
      count2++;
  }
  cout << min(count1,count2) << endl;
  
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using ll=long long;
using namespace std;
int main(){
   int k;
   cin>>k;
   rep(i,k){
       cout<<"ACL";
   }
}


Measured memory_bytes: 3540
#include <stdio.h>
#include <stack>
#include <math.h>

using namespace std;

int main(){

	int n,table[200];
	int* dp = new int[1000000];
	int* odd_dp = new int[1000000];

	for(int i=0; i < 200; i++)table[i] = i*(i+1)*(i+2)/6;

	for(int i=0; i < 1000000; i++){
		odd_dp[i] = 20000000;
		dp[i] = 20000000;
	}

	dp[0] = 0;
	dp[1] = 1;

	for(int i = 2; i < 1000000; i++){
		for(int k = 1; table[k] <= i; k++){
			dp[i] = (dp[i] <= dp[i-table[k]]+1)?dp[i]:dp[i-table[k]]+1;
		}
	}

	odd_dp[0] = 0;
	odd_dp[1] = 1;

	for(int i = 2; i < 1000000; i++){
		for(int k = 1; table[k] <= i; k += 2){
			if(table[k]%2 == 1){
				odd_dp[i] = (odd_dp[i] <= odd_dp[i-table[k]]+1)?odd_dp[i]:odd_dp[i-table[k]]+1;
			}
		}
	}

	while(true){
		scanf("%d",&n);
		if(n == 0)break;

		printf("%d %d\n",dp[n],odd_dp[n]);
	}

    return 0;
}

Measured memory_bytes: 10392
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;
using P = pair<int, int>;

#define FOR(i, a, n) for(int i = (int)(a); i < (int)(n); ++i)
#define REP(i, n) FOR(i, 0, n)

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e15;
const int MOD = 1e9 + 7;

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

/*************** using variables **************/
int n, x;
vector<int> a;
int dp[2005];
/**********************************************/

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

    cin >> n >> x;
    a.resize(n);
    REP(i, n) cin >> a[i];
    
    REP(i, n) dp[i] = a[i];
    
    int ans = INFL;
    REP(k, n){
        int cost = 0;
        FOR(i, n, n*2){
            int scost = a[i%n];
            scost = min(dp[i%n], a[(i-k)%n]);
            cost += scost;
            dp[i%n] = scost;
        }
        ans = min(ans, cost + x*k);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <atcoder/all>
#include <bits/stdc++.h>
#define FOR(i, a, n) for(ll i = (ll)a; i < (ll)n; i++)
#define FORR(i, n) for(ll i = (ll)n - 1LL; i >= 0LL; i--)
#define rep(i, n) FOR(i, 0, n)
#define ALL(x) begin(x), end(x)
using namespace std;
using ll = long long;
constexpr ll Mod = 998244353;
constexpr ll mod = 1e9 + 7;
constexpr ll inf = 1LL << 60;
const double PI = acos(-1);
template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) {
    return a < b && (a = b, true);
}
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) {
    return a > b && (a = b, true);
}
/*-------------------------------------------*/

using mint = atcoder::modint998244353;

struct S {
    mint x, sz;
};

S op(S a, S b) { return S{a.x * b.sz + b.x, a.sz * b.sz}; }
S e() { return S{0, 1}; }

struct F {
    mint x;
    int t;
};

F id() { return {0, -1}; }

S mapping(F f, S s) {
    if(f.t == -1) return s;
    return {(s.sz - 1) / 9 * f.x, s.sz};
}
F composition(F f, F g) { return (f.t < g.t ? g : f); }

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

    int n, q;
    cin >> n >> q;
    atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(
        vector<S>(n, S{1, 10}));

    rep(_, q) {
        int l, r, d;
        cin >> l >> r >> d;
        seg.apply(l - 1, r, {d, _});
        cout << seg.all_prod().x.val() << "\n";
    }

    return 0;
}

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

using namespace std;

int main(){

  
  int t1;
  int t2;

  while(cin>>t1,t1){

	int t=0;
	
	for(int i=0;i<9;++i){

	  cin>>t2;
	  
	  t+=t2;
	  
	}

	cout<<t1-t<<endl;
	
  }

  return 0;
  
}



Measured memory_bytes: 2976
#include <iostream>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <limits>
#include <string>
#include <algorithm>
#include <bitset>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include "math.h"
#include "assert.h"

using namespace std;

#define ll long long

#define BUFF ios::sync_with_stdio(false)
#define epsilon 1e-07
#define pi 2 * acos(0.0);
#define mod 1000000007   // 1e9+7
#define cerr if(false)cerr
#define watch(x) cerr << #x << " = " << x << endl;

#define inf std::numeric_limits<int>().max()

int main() {
	int n;
	cin >> n;
	vector<int> h(n+1, 0); 
	for(int i=1; i<=n; i++) {
		cin >> h[i];
	}

	vector<int> opt(n+1, 0);
	opt[1] = 0;
	opt[2] = abs(h[1] - h[2]);
	for(int i=3; i<=n; i++) {
		opt[i] = min ( abs(h[i-1]-h[i]) + opt[i-1], abs( h[i-2] - h[i]) + opt[i-2]); 
	}

	cout << opt[n] << endl;

}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll inf = 100100100100100;
const ll mod = 1000000007;
typedef pair<ll,ll> P;
#define fi first
#define se second
int n,m;
ll dp[90001000];
int main(){
    ll d=0;
    string ans;
    cin >> n >> m;
    vector<int> v,u;//vは可能なコスト、uは使える数
    map<int,int> c;
    c.insert({1,2});
    c.insert({2,5});
    c.insert({3,5});
    c.insert({4,4});
    c.insert({5,5});
    c.insert({6,6});
    c.insert({7,3});
    c.insert({8,7});
    c.insert({9,6});
    for(int i=1;i<n+1;i++){
        dp[i]=-1;
    }

    for(int i=0;i<m;i++){
        int x;
         cin >> x;
         v.push_back(c[x]);
         u.push_back(x);
    }
    sort(v.begin(),v.end());
    sort(u.begin(),u.end(),greater<int>());
    v.erase(unique(v.begin(),v.end()),v.end());

    for(int i=2;i<=n;i++) {
        for(int j=0;j < v.size();j++)
        {   
            if(i-v.at(j)>=0){
                dp[i]=max(dp[i-v.at(j)]+1,dp[i]);
            }
        }
    }//dp[n]桁がつくれる最大桁数
    ll cost=n,cnt=0;
    for(int i=0;i<u.size() && cnt<=dp[cost] ;i++) {
        if(n-c[u.at(i)]>=0 && dp[n-c[u.at(i)]]==dp[n]-1){
            ans.push_back((char)u.at(i)+48);
            n-=c.at(u.at(i));
            i--;
            cnt++;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <numeric>
#include <algorithm>
using namespace std;

int gcd(int a, int b){
  if(a < b) swap(a, b);
  int r;
  while((r = a % b) != 0){
    a = b;
    b = r;
  }
  return b;
}

int main(void){
  int n;
  cin >> n;
  int x[n + 1];
  int sub[n];
  cin >> x[0];
  for(int i = 1; i <= n; i++) cin >> x[i];
  sort(x, x + n + 1);
  for(int i = 0; i < n; i++) sub[i] = x[i + 1] - x[i];
  int ans = sub[0];
  for(int i = 1; i < n; i++)
    ans = gcd(ans, sub[i]);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
#define vl vector
#define pb push_back
#define ff first
#define ss second
using namespace std;
int main()
{
    ll a,b,i,j,n,m;
    cin>>n;
    ll arr[n];
    for(i=0;i<n;i++) cin>>arr[i];
    ll count=0;
    for(i=0;i<n;i++)
    {
        if((i+1)%2 && arr[i]%2) count++;
    }
    cout<<count;
    
}

Measured memory_bytes: 3632
n = int(input())
a_list1 = [int(a) for a in input().split()]
a_list2 = list()
for i in range(1, n+1):
    a_list2.append(a_list1[i-1]-i)
a_list3 = sorted(a_list2)

def sunuke_func(m):
    b = a_list3[m-1]
    sumv = 0
    for i in range(n):
        sumv += abs(a_list3[i]-b)
    return sumv

if n%2 == 0:
    m1 = n//2
    m2 = n//2 + 1
    sumv1 = sunuke_func(m1)
    sumv2 = sunuke_func(m2)
    if sumv1 < sumv2:
        print(sumv1)
    else:
        print(sumv2)
else:
    m = n//2 + 1
    sumv = sunuke_func(m)
    print(sumv)

Measured memory_bytes: 25836
#include <stdio.h>

int main()
{
    int A = 0;
    int B = 0;
    scanf("%d %d", &A, &B);
    if (A <= 8 && B <= 8){
        printf("%s", "Yay!");
    }
    else{
        printf("%s", ":(");
    }
    return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>

#define rep(i,n) for(int i = 0;i < n;i++)
#define Rep(i,m,M) for(int i = m;i < M;i++)
#define print(var) cout<<#var" = "<<var<<endl;

typedef long long ll;

using namespace std;

typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;

int main()
{
	string A[4] = { "dream","dreamer","erase","eraser" };
	string S;

	bool flag = true;
	cin >> S;
	if (S.size() <= 3)
	{
		flag = false;
	}
	while ((S.size()>=5) and flag)
	{
		int len = S.size();
		flag = false;
		string s;
		if(len >= 7)
		s = S.substr(len - 7);
		
		string str;
		if (len >= 5)
		{
			str = S.substr(len - 5);
		}
		string Str;
		
		if (len >= 6)
		{
			Str = S.substr(len - 6);
		}
		rep(i, 4)
		{
			if (str == A[i] or Str == A[i] or s == A[i])
			{
				S.erase(S.end() - A[i].size(), S.end());
			//	cout << S << endl;
				flag = true;
			}
		}
		if (S.size() <= 3 and S.size() > 0)
		{
			flag = false;
		}
	}
		if (flag)
		{
			cout << "YES";
		}
		else cout << "NO";

	
}

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

typedef long long ll;

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl

const int maxn = 1e6 + 5;
int n,k,a[maxn];
int best = -1e9 - 10;

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

  cin>>n>>k;
  for (int i=0; i<n; i++) {
    cin>>a[i];
  }
  
  multiset<int> left;
  for (int l=0; l<=min(n,k); l++) {
    if (l>0) {
      left.insert(a[l-1]);
    }
    multiset<int> right = left;
    for (int r=0; r+l<=min(n,k); r++) {
      if (r>0) {
	right.insert(a[n-r]);
      }

      int rm = k-l-r;
      multiset<int> cur = right;
      while (rm > 0 && !cur.empty()) {
	if (*cur.begin() < 0) {
	  rm--; cur.erase(cur.begin());
	} else {
	  break;
	}
      }
      int sum = 0;
      for (int x: cur) sum += x;
      best = max(best, sum);
    }
  }

  cout<<best<<endl;
  

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	static Scanner sc = new Scanner(System.in);
	static int x = 0, y = 0; 
	static String second;
	static int second_ = 0;
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		// TODO ツ篠ゥツ督ョツ青カツ青ャツつウツづェツつスツδソツッツドツ・ツスツタツブ
		read();	
		slove();
		
	}
	static boolean read(){
		for(int i = 0; i < 4; i++){
			second = sc.next();
			second_ = second_ + Integer.parseInt(second);
		}
		//System.out.println(second_);
		return true;
	}
	static void slove(){
		x = second_/60;
		y = second_ % 60;
		System.out.println(x);
		System.out.println(y);
	}
}

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

int main(){
    int N;
    cin >> N;
    vector<ll> A(3*N);
    for (int i = 0; i < 3*N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    ll ans = 0;
    for (int i = 0; i < N; i++) ans += A[2*i+N];
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2560
import scala.io.StdIn._
object Main extends App {
  @scala.annotation.tailrec
  def possible(t: Int, x: Int, y: Int, i: Int): Boolean = {
    if (i == 0) true
    else {
      val Array(ti, xi, yi) = readLine.split(" ").map{_.toInt}
      val manhattan = Math.abs(x - xi) + Math.abs(y - yi)
      if (manhattan <= ti - t && ((ti - t - manhattan) & 1) == 0) possible(ti, xi, yi, i - 1) else false
    }
  }
  println(if (possible(0, 0, 0, readInt)) "Yes" else "No")
}

Measured memory_bytes: 53128
/**************************************************************************
Coded by: Saba Karimi(_VINTAGE)
Institution: AIT PUNE
***************************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define int long long int 
#define F first 
#define S second
/**************************************************************************/
const int N = 1e5+2;
const int mod = 1e9+7;
int add(int a,int b)
{
    return ((a%mod)+(b%mod))%mod;
}
int mul(int a,int b)
{
    return ((a%mod)*(b%mod))%mod;
}
int dp[N][2];//0 for black // 1 for white
int n;
vector<int> adj[N];
int solve(int src,int color,int parent)
{
    if(dp[src][color]!=-1)
        return dp[src][color];
    int ans = 1;
    for(auto it:adj[src])
    {
        if(it == parent)
            continue;
        if(color == 1)
            ans = mul(ans,add(solve(it,!color,src),solve(it,color,src)));
        else ans = mul(ans,solve(it,!color,src));
    }
    dp[src][color] = ans;
    return ans;
}
signed main()
{
    fast;
    cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    memset(dp,-1,sizeof(dp));
    cout<<add(solve(1,0,-1),solve(1,1,-1));
}


Measured memory_bytes: 15616
#include <bits/stdc++.h>
#define rep(i,a,b) for (int i=(a); i<(b); i++)
#define per(i,a,b) for (int i=(b)-1; i>=(a); i--)
#define debug(x) cout << #x << " => " << x << endl
using namespace std;
typedef long long ll;

#define fi first
#define se second
#define mp make_pair
typedef pair<int,int> pii;

#define pb push_back
typedef vector<int> vi;

const int INF = 1e9 + 7;
const int MAX_N = 7 + 100000;
///----------------------------------------------
char str[MAX_N];
int main() {

    ///freopen ( "xx.in" , "r" , stdin );

    ///read
    scanf(" %s",str); int len=strlen(str);

    ///work
    int can=0;
    int sco=0;
    rep(i,0,len) {
        if (str[i]=='p') if (!can) can++,sco--; else can--;
            else if (can) can--,sco++; else can++;
    }

    ///print
    cout << sco;



}




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

template<class T> void vin(vector<T>& v, int n) {
    v.resize(n);
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
    }
}

char board[101][101];

int main() {
    int A, B;
    cin >> A >> B;
    for (int r=0; r<50; ++r) {
        for (int c=0; c<100; ++c) board[r][c] = '.';
    }
    for (int r=50; r<100; ++r) {
        for (int c=0; c<100; ++c) board[r][c] = '#';
    }
    A--;
    B--;
    if (B > 0) {
        for (int r = 0; r < 49; r += 2) {
            for (int c = 0; c < 100; ++c) {
                if (B <= 0) {
                    r=1000; c=1000;
                    break;
                }
                if (c%2 == 0) {
                    board[r][c] = '#';
                    B--;
                }
            }
        }
    }
    if (A > 0) {
        for (int r = 51; r < 100; r += 2) {
            for (int c = 0; c < 100; ++c) {
                if (A <= 0) {
                    r=1000; c=1000;
                    break;
                }
                if (c%2 ==0) {
                    board[r][c] = '.';
                    A--;
                }
            }
        }
    }
    cout << "100 100" << endl;
    rep(r, 100) {
        rep(c, 100) {
            cout << board[r][c];
        }
        cout << endl;
    }
}


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

I1 = sum(A)//N
I0 = I1 - 1
I2 = I1 + 1

cost0 = 0
cost1 = 0
cost2 = 0
for a in A:
  cost0 = cost0 + (a-I0)*(a-I0)
  cost1 = cost1 + (a-I1)*(a-I1)
  cost2 = cost2 + (a-I2)*(a-I2)
print(min(min(cost1, cost2), cost0))

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <functional>

using namespace std;

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}
constexpr ll TEN(ll n){return n==0?1:10ll*TEN(n-1);}

constexpr ll inf = TEN(9)+5;
constexpr ll linf = 3*TEN(18);

signed main()
{
    int N, M; cin >> N >> M;
    vi imos(N + 1);
    rep(i, M) {
        int l, r; cin >> l >> r;
        --l, --r;
        imos[l]++;
        imos[r+1]--;
    }

    rep(i, N) imos[i + 1] += imos[i];

    int ans = 0;

    rep(i, N + 1) if (imos[i] == M) ans++;

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


Measured memory_bytes: 3772
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int n;
	cin>>n;
	string s;
	cin>>s;
	int cmp=0;
	int jsq=0;
	for(int i=0;i<s.size();i++)
	{
		if(s[i]=='I')
		{
			jsq++;
			if(jsq>cmp)cmp=jsq;
		}
		if(s[i]=='D')jsq--;
	}
	cout<<cmp<<endl;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
use std::collections::BinaryHeap;

fn main() {
    input! {
        n: usize,
        mut a: [i64; n],
    }

    let mut q = BinaryHeap::new();
    a.sort();
    a.reverse();
    q.push((a[0], a[0]));
    let mut ans = 0;
    for i in 1..n {
        let (mx, other) = q.pop().unwrap();
        ans += mx;
        let next = std::cmp::min(a[i], other);
        let next_other = std::cmp::max(a[i], other);
        q.push((a[i], mx));
        q.push((next, next_other));

        // dbg!(ans);
    }

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


Measured memory_bytes: 9448
import sys

N_MAX = 100010

sys.setrecursionlimit(500000)

dp = [-1]*N_MAX
vec = [0]*N_MAX

def frog(n):
  if dp[n] != -1:
    return dp[n]
  else:
    dp[n] = min(frog(n-1) + abs(vec[n] - vec[n-1]) , frog(n-2) + abs(vec[n] - vec[n-2]))
    return dp[n]
  
N = int(input())
ln = list(map(int, input().split()))

for i in range(N):
  vec[i] = ln[i]

dp[0] = 0
dp[1] = abs(vec[0] - vec[1])

print(frog(N-1))


  


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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int INF = 1<<30;
const ll mod = 1000000007LL;

ll pow(ll a, ll n, ll m) {
	ll ret = 1LL;
	for (; n > 0LL; n >>= 1LL, a = a * a % m) {
		if (n % 2LL == 1LL) {
			ret = ret * a % m;
		}
	}
	return ret;
}

ll cmb(ll x, ll y){
    if(y>x||y<0) return 0LL;
    ll c = 1;
    for(ll i = 0LL; i < y; i++) {
        c *= (x-i)%mod;
        c %= mod;
        c *= pow(i+1,mod-2,mod);
        c%= mod;
    }
    return c;
}

int main() {
  ll N,K;
  cin>>N>>K;
  ll ans = 0LL;
  ll T = 1LL;
  for(ll i = 0LL; i <= min(K,N-1LL); i++) {
    ans= (ans+(pow(T,2LL,mod)*pow(N-i,mod-2LL,mod)))%mod;
    T=(((T*(N-1-i))%mod)*pow(i+1LL,mod-2LL,mod))%mod;
  }
  ans=(ans*N)%mod;
  if(ans<0LL) ans+=mod;
  cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define reps(i,s,n) for(int i = s; i < n; i++)
#define rep(i,n) reps(i,0,n)
#define Rreps(i,n,e) for(int i = n - 1; i >= e; --i)
#define Rrep(i,n) Rreps(i,n,0)
#define ALL(a) a.begin(), a.end()
#define fi first
#define se second
#define mp make_pair
typedef long long ll;
typedef vector<ll> vec;
typedef vector<vec> mat;

ll N,M,H,W,K,Q,A,B,L,R;
string S, T;
const ll MOD = (1e+9) + 7;
const ll INF = 1LL << 60;
typedef pair<ll,ll> P;

vec a(0), f(0);
bool simu(ll n){
    ll judge = 0;
    rep(i,N){
        ll temp = n / f[i];
        judge += max(0LL, a[i] - temp);
    }
    return judge <= K;
}

int main() {
    cin>>N>>K;
    rep(i,N) cin>>A, a.push_back(A);
    rep(i,N) cin>>A, f.push_back(A);
    sort(ALL(a));
    sort(ALL(f));
    reverse(ALL(f));
    ll lb = -1, ub = 2e+12;
    while(ub - lb > 1){
        ll cen = (ub + lb) / 2;
        (simu(cen) ? ub : lb) = cen;
    }
    cout<<ub<<endl;
}

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

int main() {
    int S;
    int hour, min, sec;
    cin >> S;
    hour = S / 3600;
    min = (S % 3600) / 60;
    sec = (S % 3600) % 60;
    cout << hour << ":" << min << ":" << sec << endl;
    return 0;
}


Measured memory_bytes: 3112
#include <bits/stdc++.h>
using namespace std;
int n;
int m;
int k;
int a[300005],b[300005];
int p[300005];
int l[300005];
int totp[300005];
int totl[300005];
int maxp=0;
int maxl=0;
int cntl;
int cntp;
int ans=0;
int main()
{
	scanf("%d %d %d",&n,&m,&k);
	for(int i=1;i<=k;i++)
	{
		scanf("%d %d",&a[i],&b[i]);
		p[a[i]]++;
		l[b[i]]++;
	}
	for(int i=1;i<=n;i++)
	{
		if(p[i]>maxp)
		{
			maxp=p[i];
			cntp=i;
		}
	}
	for(int i=1;i<=k;i++)
	{
		if(a[i]==cntp)
		{
			totl[b[i]]=1;
		}
	}
	for(int i=1;i<=m;i++)
	{
		if(l[i]-totl[i]>maxl)
		{
			maxl=l[i]-totl[i];
		}
	}
	ans=max(ans,maxl+maxp);
	maxl=0;
	maxp=0;
	for(int i=1;i<=m;i++)
	{
		if(l[i]>maxl)
		{
			maxl=l[i];
			cntl=i;
		}
	}
	for(int i=1;i<=k;i++)
	{
		if(b[i]==cntl)
		{
			totp[a[i]]=1;
		}
	}
	for(int i=1;i<=n;i++)
	{
		if(p[i]-totp[i]>maxp)
		{
			maxp=p[i]-totp[i];
		}
	}
	ans=max(ans,maxl+maxp);
	printf("%d",ans);
}

Measured memory_bytes: 10056
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string x , y;
	cin>>x>>y;
	int n=x.length() , count=0;
	for(int i=0;i<n;i++)
		if(x[i]!=y[i])
			count++;
	cout<<count<<endl;
}

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

int main() {
	int a, b, c, k;
	cin >> a >> b >> c >> k;
	
	int m = min(a, k);
	int s = m;
	k -= m;

	m = min(b, k);
	k -= m;

	m = min(c, k);
	s -= m;
	k -= m;

	cout << s;

	return 0;
}
	

Measured memory_bytes: 3652
#include<iostream>
#include<cstdlib>
#include<algorithm>
#include<vector>
using namespace std;

 
int main()
{   
    long long N, M;
    cin >> N >> M;
    
    long long H[N];
    for(int i=0; i<N; i++){
        cin >> H[i];
    }
    
    bool top[N];
    for(int i=0; i<N; i++){
        top[i] = true;
    }
    
    long long A, B;
    for(int i=0; i<M; i++){
        cin >> A >> B;
        
        if(H[A-1] < H[B-1]){
            top[A-1] = false;
        }else if(H[A-1] > H[B-1]){
            top[B-1] = false;
        }else{
            top[A-1] = false;
            top[B-1] = false;
        }
    }
    
    // sum
    long long sum = 0;
    for(int i=0; i<N; i++){
        sum += top[i];
    }
    cout << sum << endl;
  
}


Measured memory_bytes: 4512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,n) for(long long i=0;i<n;++i)
#define REPP(i,m,n) for(long long i=m;i<n;++i)
#define rep(i,n) for(long long i = n-1;i>=0;--i)
#define repp(i,n,m) for(long long i = n-1; i >= m; --i)
#define ALL(N) (N.begin(),N.end())
#define de cout << "line : " << __LINE__ << " debug" << endl;
#define pb push_back
#define pq priority_queue
#define Dcout(N) cout << setprecision(20) << N << endl
constexpr ll INF = 2147483647;
constexpr long long INFF = 9223372036854775807;

signed main() {
    cin.tie(0);
	ios::sync_with_stdio(false);
    ll N;cin >> N;
    string S,T;cin >> S >> T;
    ll ans = 0;
    if(S[0] == T[0]) ans = 3;
    else ans = 6;
    REPP(i,1,N){
		ans %= 1000000007;
        if(S[i-1] == S[i] && T[i] == T[i-1]) continue;
        else if(S[i-1] == T[i-1]){
            if(S[i] != T[i]){
                ans *= 2;
            }
            else ans *= 2;
        }
        else{
            if(S[i] == T[i]){
                ans *= 1;
            }
            else ans *= 3;
        }
        ans %= 1000000007;
    }
    cout << ans << endl;
}

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

ll N,M;

struct edge {
    ll to;
    ll cost;
};

unordered_map<ll,vector<edge> > edges;

// 会社+駅
ll pl(ll c, ll p){
    return c*1e6 + p;
}

int main() {
    std::cin >> N>>M;
    for (int i = 0; i < M; i++) {
        ll a,b,c;
        std::cin >>a>>b>>c;
        a--;
        b--;
        // 同じ会社の駅同士にコスト0
        edges[pl(c,a)].push_back({pl(c,b),0});
        edges[pl(c,b)].push_back({pl(c,a),0});
        // 駅から改札外にコスト0
        edges[pl(c,a)].push_back({pl(0,b),0});
        edges[pl(c,b)].push_back({pl(0,a),0});
        // 改札外から入るのにコスト1
        edges[pl(0,b)].push_back({pl(c,a),1});
        edges[pl(0,a)].push_back({pl(c,b),1});
    }
    
    
    unordered_map<ll,int> d;    
    const ll INF = 400000;
    
    // コストが低い順、nodeの番号
    priority_queue< pair<int,ll>, vector< pair<int,ll> >, greater<  pair<int,ll> > > que;

    
    d[pl(0,0)] = 0;
    que.push({0,pl(0,0)});
    while(!que.empty()){
        pair<int, ll> p2 = que.top(); que.pop();
        int p = p2.first;
        ll v = p2.second;
        if(d[v]==0 && v != pl(0,0)){
            d[v]=INF;
        }
        if(d[v] < p){
            continue;
        }
        
        for (auto e : edges[v]) {
            if(d[e.to]==0 && e.to != pl(0,0)){
                d[e.to]=INF;
            }
            if(d[e.to] > p + e.cost ){
                d[e.to] = p + e.cost;
                que.push({d[e.to],e.to});
            }
        }
    }
    
    if(d[pl(0,N-1)] == INF || d[pl(0,N-1)] == 0){
        std::cout << -1 << std::endl;
    }else{
        std::cout << d[pl(0,N-1)] << std::endl;
    }
}


Measured memory_bytes: 77920
#include<iostream>

using namespace std;

int main() {
	int N, M;
	int A[1000 + 10];
	cin >> N >> M;
	int s = 0;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		s += A[i];
	}

	int cnt = 0;
	for (int i = 0; i < N; i++) {
		if (A[i] * (4 * M) >= s)cnt++;
	}
	if (cnt >= M)cout << "Yes" << endl;
	else cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <bitset>
#include <cmath>
#include <string>
#include <fstream>
#define FI first
#define SE second
#define VE vector<int>
#define PB push_back
#define PA pair<int,int>
#define MA make_pair
#define LL long long
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define ROF(i,a,b) for(int i=b-1;i>=a;i--)
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define POS(i) cout<<(i?"POSSIBLE":"IMPOSSIBLE")<<endl
using namespace std;
//
const int INF=1e9+7;
const int MOD=1e9+7;
//
int h,w;
int b1[50][50]={0};
int d[50][50]={0};
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int bfs();

int main(){
    cin>>h>>w;
    int whitenum=0;
    FOR(i,0,h){
        string s;
        cin>>s;
        FOR(j,0,w){
            if(s[j]=='.'){
                b1[i][j]=0;
                whitenum++;
            }else{
                b1[i][j]=1;
            }
        }
    }
    if(bfs()==INF){
        cout<<-1<<endl;
    }else{
        cout<<whitenum-bfs()-1<<endl;
    }
    return 0;
}

int bfs(){
    queue<PA> que;
    FOR(i,0,h){
        FOR(j,0,w){
            d[i][j]=INF;
        }
    }
    que.push(PA(0,0));
    d[0][0]=0;

    while(que.size()){
        PA p=que.front(); que.pop();
        if(p.first==h-1&&p.second==w-1) break;
        FOR(i,0,4){
            int nx=p.first+dx[i],ny=p.second+dy[i];
            if(0<=nx&&nx<h&&0<=ny&&ny<w&&b1[nx][ny]!=1&&d[nx][ny]==INF){
                que.push(PA(nx,ny));
                d[nx][ny]=d[p.first][p.second]+1;                
            }
        }
    }
    return d[h-1][w-1];
}

Measured memory_bytes: 256
from math import sin,cos,radians

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

s=a*b*sin(c)*0.5
l=a+b+(a*a+b*b-2*a*b*cos(c))**0.5
h=s/a*2

for i in[s,l,h]:print('%5f'%i)


Measured memory_bytes: 5724
#include <iostream>
/*
int main(void){
    int large_n;
    int buf[100];
    std::cin >> large_n;
    if(large_n<1 || large_n>100){
        std::cout << "Invalid error!" << std::endl;
        return 1;
        }
    for(int i=0; i<(large_n); i++){
        std::cin >> buf[i];
    }
    for(int i=0; i<(large_n); i++){
        if(buf[i]<0 || buf[i]>1000){
            std::cout << "Invalid value!" << std::endl;
            return 1;
        }
    }
    int max_zahyo = -1;
    int min_zahyo = 1001;
    for(int i=0; i<(large_n); i++){
        if(buf[i]<=min_zahyo){
            min_zahyo = buf[i];
        }else if(buf[i]>=max_zahyo){
            max_zahyo = buf[i];
        }
    } 
    std::cout << (max_zahyo-min_zahyo) << std::endl;
    return 0;
} */

int N, A, min = 1001, max = 01;
int main(){
    std::cin >> N;
    for(int i = 1; i <= N; i++){
        std::cin >> A;
        if(min > A) min = A;
        if(max < A) max = A;
    }
    std::cout << max -min <<  std::endl;
    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 A = sc.nextInt();
		int B = sc.nextInt();
		if((A + B) % 2 == 0) {
			System.out.println((A + B) / 2);
		}else {
			System.out.println("IMPOSSIBLE");
		}
		sc.close();
	}
}

Measured memory_bytes: 21844
#include <bits/stdc++.h>
using namespace std;
using lli = int_fast64_t;
using ulli = uint_fast64_t;
#define debug(x) cerr << #x << " : " << x << endl
#define debugv(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x << ", ";}cerr << endl
#define debugst(x) auto xt = x;cerr << #x << " : {";for(int i=0;i<x.size();i++){ cerr << xt.top() << ", ";xt.pop();}cerr << endl
#define debugvp(x) cerr << #x << " : {";for(auto value_of_x:x){ cerr << value_of_x.first << " : " << value_of_x.second << ", ";}cerr << endl

const lli MOD = 1000000007;
const lli LIMIT = 1000000000000000000 * 5;
const int tenfive = 100000;


int main() {
	lli N, M;
	cin >> N >> M;
	priority_queue<lli, vector<lli>, greater<>> a;
	for (int i = 0; i < N; i++) {
		lli t;
		cin >> t;
		a.push(t);
	}
	vector<pair<lli,lli>> b(M);

	for (int i = 0; i < M; i++) {
		cin >> b[i].first >> b[i].second;
	}

	sort(b.begin(), b.end(), [](const pair<lli, lli> & l, const pair<lli, lli> & r) {
		return l.second != r.second ? l.second > r.second:l.first > l.first;
		});
	bool c = false;
	for (int i = 0; i < M; i++) {
		while (b[i].first != 0) {
			if (a.top() < b[i].second) {
				a.pop(); a.push(b[i].second);
				b[i].first--;
			}
			else {
				c = true;
				break;
			}
		}
		if (c)break;
	}
	lli ans = 0;
	for (int i = 0; i < N; i++) {
		ans += a.top(); a.pop();
	}
	cout << ans << endl;
	return 0;
}



Measured memory_bytes: 2804
#include <iostream>
#include <map>
#include <vector>
using namespace std;

int main(){
    int n;cin>>n;
    vector<pair<string, int>> playlists(n);
    for (int i=0;i<n;i++){
        string s;
        int t;
        cin>>s>>t;
        playlists[i] = make_pair(s, t);
    }

    string x;cin>>x;

    bool started = false;
    int acc = 0;
    for (auto item : playlists){
        if (started){
            acc += item.second;
        }
        if (item.first == x){
            started = true;
        }
    }
    cout << acc <<endl;
    return 0;
}

Measured memory_bytes: 256