akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <iomanip>
#include <stdlib.h>
#include <string.h>
#include <cstring>
#include <cmath>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <stdio.h>
#include <tuple>
#include <bitset>
#include <cfloat>
#include <fstream>
#include <limits.h>
#include <list>
#include <math.h>
#include <random>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <numeric>
#include <utility>
// *テンプレート*
#define int long long
#define rep(i, n) for (int i = 0; i < (n); i++)
#define P pair<int, int>
// aよりbの方が小さかったら、aの値をbの値に置き換える。(swapではない！)
template<class T> inline bool chmin(T& a, T b) {
	if (a > b) {
		a = b;
		return true;
	}
	return false;
}
// aよりbの方が大きかったら、aの値をbの値に置き換える。
template<class T> inline bool chmax(T& a, T b) {
	if (a < b) {
		a = b;
		return true;
	}
	return false;
}
const long long MOD = 1000000007;
const long long INF = 1LL << 60;
using namespace std;
typedef long long ll;
map<int, int> mp;
using Graph = vector<vector<int>>; 
//最大公約数
ll gcd(ll a, ll b) {
	if (a < b)swap(a, b);
	if (b == 0) return a;
	return gcd(b, a % b);
}
//最小公倍数
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

// *テンプレートここまで*

// pair -> vector<pair<int,int>> 
//		   AandB.push_back(make_pair(a[i],b[i]))

int dp[100100];
int h[100010];
signed main() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, k; cin >> n >> k;
	rep(i, n) {
		cin >> h[i];
	}
	rep(i, 100100) {
		dp[i] = INF;
	}
	dp[0] = 0;
	for (int i = 0; i < n; i++) {
		for (int j = 1; j <= k; j++) {
			chmin(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

template<typename T>
istream& operator>> (istream& is, vector<T> &vec){
    for(T& x: vec) is >> x;
    return is;
}

int main(){
    ll n, m, k; cin >> n >> m >> k;
    map<ll, ll> list;
    ll first = 0, end = n*m;
    rep(i, n+1){
        ll step = (end - first) / m;
        rep(j, m+1){
            ll tmp = first + step * j;
            list[tmp] = tmp;
        }
        first += m;
        end -= m;
    }
    if(list.count(k) == 0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 17408
#include<cstdio>
#include<cstring>
char a[10010];
bool c, f;
int main() {
    scanf("%s", a);
    for(int i=0; i<strlen(a); i++) {
        if(a[i]=='C') c=true;
        if(a[i]=='F'&&c==true) f=true;
    }
    if(f==true) printf("Yes\n"); 
    else printf("No\n");
    return 0;
}

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

int main(){
  int n; cin>>n;
  vector<int>A(n+1);
  A[0] = 0;
  A[1] = 0;
  for (int i=1; i<n; i++) cin>>A[i];
  vector<int>Count(n+1);
  for (int i=1; i<=n; i++){
    int a = A[i];
    Count[a]++;
  }
  for (int i=1; i<=n; i++) cout << Count[i] << endl;
}

Measured memory_bytes: 4832
#include <bits/stdc++.h>
#include <cassert>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
struct Edge
{
  int to;
  int weight;
  Edge(int t, int w) : to(t), weight(w) {}
};
// using Graph = vector<vector<Edge>>;
using Graph = vector<vector<int>>;

const long long INF = 1LL << 60;
const int INT_INF = 1000000000;

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

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int N;
  cin >> N;
  Graph G(N);
  for (int i = 0; i < N - 1; i++)
  {
    int a, b;
    cin >> a >> b;
    a--, b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }
  vector<int> c(N);
  for (auto &it : c)
    cin >> it;
  sort(c.begin(), c.end(), greater<int>());
  ll ans = 0;
  for (int i = 1; i < N; i++)
    ans += c[i];
  vector<int> num(N, -1);
  queue<int> que;
  que.push(0);
  int cnow = 0;
  while (!que.empty())
  {
    int v = que.front();
    if (num[v] == -1)
    {
      num[v] = c[cnow];
      cnow++;
    }
    que.pop();
    for (auto nv : G[v])
    {
      if (num[nv] == -1)
      {
        num[nv] = c[cnow];
        cnow++;
        que.push(nv);
      }
    }
  }
  cout << ans << endl;
  for (auto &it : num)
    cout << it << " ";
  cout << endl;
  return 0;
}

// 与えられた数字のうち最大のものはscoreとして現れない．2番目以降の数字をscoreとして出したいときにその頂点と繋がっている頂点の中に自分より大きい数字がないといけない．（三番目以降も同様）このようにすることでmaximum score は整数のリストから最大の数字を除いて残りの数字の和となる．数字は大きい順に当てはめる．scoreはsum - 最大の整数．木の葉のうちどれか一つからスタートしてbfsで訪問していき訪問順に大きい数字から当てはめていく．BFSを使えば子は必ず親より小さくなるから子の値は必ず採用される．すなわちスタートから大きい順に割り振っていけばスタートの頂点以外は必ず採用される．（そのためsum - (最大の値)となる）


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

struct UnionFind {
    int n, cnt;
    vector<int> par, rank, sz;

    UnionFind(int n) : n(n), cnt(n), par(n), rank(n), sz(n, 1) {
        iota(par.begin(), par.end(), 0);
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }

    int size(int x) {
        return sz[find(x)];
    }

    void unite(int x, int y) {
        x = find(x), y = find(y);
        if (x == y) return;
        if (rank[x] < rank[y]) {
            par[x] = y;
            sz[y] += sz[x];
        } else {
            par[y] = x;
            sz[x] += sz[y];
            if (rank[x] == rank[y]) {
                rank[x]++;
            }
        }
        cnt--;
    }
};

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

    int n, m;
    cin >> n >> m;
    UnionFind uf(n);
    for (int i = 0; i < m; i++) {
        int a, b, c;
        cin >> a >> b >> c;
        a--, b--;
        uf.unite(a, b);
    }

    cout << uf.cnt << endl;
}

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

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

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

	int N, A, B; cin >> N >> A >> B;

	int ans = 0;

	for (int i = 1;i <= N;i++){
		int sum = 0;
		int num = i;
		while(num != 0){
			sum += num%10;
			num /= 10;
		}
		if(A <= sum && sum <= B) ans += i;
	}

	cout << ans << endl;

	return 0;

}


Measured memory_bytes: 256
use warnings;
    use Data::Dumper;
    use List::Util qw(max min);
    # use Statistics::Lite qw(max min sum);
    
    sub GetInputData{
    
        my @array_data;
    
        my $line = <STDIN>;
    
        chomp($line);
    
        while($line ne ""){
    
           push(@array_data,$line);
    
           $line = <STDIN>;
    
           chomp($line);
    
    }
    
        return @array_data;
    
    }
    
    sub GetSpaceInputData{
    
        my @array_temp=GetInputData();
    
        my @array_buf;
    
        foreach(@array_temp){
    
            #戻りは配列スペース区切りを分解
            # myを先頭につける必要あり
            my @array_work=split(" ",$_);

            # print "@array_work";
    
            # リファレンスを配列に代入
            push(@array_buf,\@array_work);
        }
    
        return @array_buf;
    
    }
    
    my @arr_result = GetSpaceInputData();

    my $arr = $arr_result[0];

    # print "@$arr";

    my $chkflg=1;
    unless (grep {$_ == 1} @$arr) {
        $chkflg=0;
    }
    unless (grep {$_ == 9} @$arr) {
        $chkflg=0;
    }
    unless (grep {$_ == 7} @$arr) {
        $chkflg=0;
    }
    unless (grep {$_ == 4} @$arr) {
        $chkflg=0;
    }


    print $chkflg ? "YES" : "NO";

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

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

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)(n);++i)
#define DEBUG(x) cerr << #x << " = " << x << endl
const int INF = (int)1e9;
struct UnionFind {
  vector<int> data;
  UnionFind(int v) : data(v, -1) { }
  int root(int x) {
    return data[x] < 0 ? x : (data[x] = root(data[x]));
  }
  bool same(int x, int y) {
    return root(x) == root(y);
  }
  int size(int x) {
    return -data[root(x)];
  }
  void merge(int x, int y) {
    x = root(x), y = root(y);
    if(x != y) {
      if(size(y) > size(x)) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
  }
};
char M[1000][1001];
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, -1, 0, 1 };
int main() {
  ios::sync_with_stdio(false);
  int W, H; cin >> W >> H;
  REP(i,H) cin >> M[i];
  int N; cin >> N;
  UnionFind U(1000*1000);
  int ty, tx;
  REP(i,H) REP(j,W) REP(k,4) {
    if(M[i][j] == 't') {
      ty = i;
      tx = j;
      M[ty][tx] = '.';
    }
    int ny = i + dy[k];
    int nx = j + dx[k];
    if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
    if(M[i][j] == '.' && M[ny][nx] == '.') {
      // cerr << "merge " << i << ", " << j << " <=> " << ny << ", " << nx << endl;
      U.merge(i*1000+j, ny*1000+nx);
    }
  }
  int ans = INF;
  if(U.same(0, ty*1000+tx)) ans = 0;
  REP(n, N) {
    int j, i; cin >> j >> i;
    M[i][j] = '.';
    REP(k,4) {
      int ny = i + dy[k];
      int nx = j + dx[k];
      if(ny < 0 || ny >= H || nx < 0 || nx >= W) continue;
      if(M[i][j] == '.' && M[ny][nx] == '.') {
        // cerr << "merge " << i << ", " << j << " <=> " << ny << ", " << nx << endl;
        U.merge(i*1000+j, ny*1000+nx);
      }
    }
    if(U.same(0, ty*1000+tx)) {
      ans = min(ans, n + 1);
    }
  }
  if(ans == INF) cout << -1 << endl;
  else cout << ans << endl;
}

Measured memory_bytes: 5944
#include <bits/stdc++.h>
using namespace std;
int n;
int main() {
    cin>>n;
    for(int i=0; i<=n/4; i++) {
        for(int j=0; j<=n/7; j++) {
            if(i*4+j*7==n) {
                cout<<"Yes"<<endl;
                return 0;
            }
        }
    }
    cout<<"No"<<endl;
    return 0;
}

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

int main(){
	// sengen
	long long n;
	// nyuryoku
	cin >> n;
	// keisan
	long long sai = n-1;
	for(long long i=2;i<=sqrt(n);i++){
		if(n%i == 0){
			long long ksai = i + n/i -2;
			sai = min(sai,ksai);
		}
	}
	// syutsuryoku
	cout << sai;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <cmath>
#include <map>
#include <queue>
#include <iomanip>
#include <set>
#include <tuple>
#define mkp make_pair
#define mkt make_tuple
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define all(v) v.begin(),v.end()
using namespace std;
typedef long long ll;
const ll MOD=1e9+7;
template<class T> void chmin(T &a,const T &b){if(a>b) a=b;}
template<class T> void chmax(T &a,const T &b){if(a<b) a=b;}

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

  int L,R,D;
  cin>>L>>R>>D;

  int ans=R/D-(L-1)/D;
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 3688
def main():
    num = int(input())
    T = [[0] * num for i in range(num)]
    for n in range(num):
        a = list(map(int,input().split()))
        u = a[0] - 1
        if a[1] > 0:
            for i in a[2:]:
                T[u][i-1] = 1

    for i in range(num):
        print(" ".join(map(str,T[i])))

if __name__ == '__main__':
    main()

Measured memory_bytes: 7792
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
#define _GLIBCXX_DEBUG
     
int main() {
  ll a, b, c, k, ans=0;
  cin >> a >> b >> c >> k;

/*
  if (a >= k) cout << a << endl;
  else if (a+b >= k) cout << a << endl;
  else cout << a - (k - a - b) << endl;
  */

  if (a < k) {
    k -= a;
    ans += a;
    if (b < k) {
      k -= b;
      ans -= k;
    }
  }
  else ans = k;
  
  cout << ans << endl;
}

Measured memory_bytes: 3556
n=int(input())
A=list(map(int,input().split()))

ans=0

for i in range(1,n):
    
    
    if A[i]<A[i-1]:

        
        dai=A[i-1]-A[i]

#        print(i, A,ans,dai)
        ans+=dai

        A[i] += dai

    

print(ans)

Measured memory_bytes: 94088
import sys
from math import ceil, floor, sqrt, sin, cos, pi
from itertools import accumulate, permutations, combinations
from fractions import gcd # 最大公約数
from collections import deque, Counter
from operator import itemgetter
from heapq import heappop,heappush
sys.setrecursionlimit(10**7)
def lcm(x, y): return ((x * y) // gcd(x, y)) # 最小公倍数
# list(map(int, input().split()))

n, m = map(int, input().split())
root = {i:[] for i in range(n)}
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    root[a].append(b)
    root[b].append(a)

if len(root) != n:
    print('No')
    sys.exit()

r = sorted(root.items())
mae = [ -1 for _ in range(n)]
mae[0] = n
q = [0]
while True:
    l = len(q)
    if l == 0: break
    for i in range(l):
        ima = q[i]
        for tugi in r[ima][1]:
            if tugi == mae[ima]: continue
            if mae[tugi] != -1:
                if mae[tugi] != ima: continue
            mae[tugi] = ima
            q.append(tugi)
    q = q[l:]
if min(mae) == -1:
    print('No')
    sys.exit()
print('Yes')
for x in mae[1:]:
    print(x + 1)


Measured memory_bytes: 50772
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<cassert>
using namespace std;

int A[1000000], n;

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

  int q, k, sum = 0;
  cin >> q;
  for ( int i = 0; i < q; i++ ){
    scanf("%d", &k);
    if ( *lower_bound(A, A + n, k) == k) sum++;
  }

  cout << sum << endl;

  return 0;
}




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

int main(){
    int A;
    cin >> A;

    if(A < 1200){
        cout << "ABC" << endl;
    }
    else if(A < 2800){
        cout << "ARC" << endl;
    }
    else{
        cout << "AGC" << endl;
    }
}

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

const int M = 1000005;

int main(){
    //要素数
    int n;
    cin >> n;

    //要素数分の配列を初期化
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector<int> cnt(M);
    
    //インプットしたデータを一つのデータに格納していく
    for (int x : a){
        if (cnt[x] != 0){
            cnt[x] = 2;
            continue;
        }
        for (int i = x; i < M; i += x){
            cnt[i]++;
        }
    }

    //正解データが自分自身しかない条件の時
    int ans = 0;
    for(int x:a){
        if(cnt[x]==1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 8008
#include<cmath>
#include<cstdio>
#include<cstring>
#include<set>
#include<vector>
#include<assert.h>
#include<iostream>
#include<algorithm>
using namespace std;
#define pb push_back
#define mp make_pair
#define sz(x) ((int)(x).size())
#define rep(i,l,r) for(int i=(l);i<(r);++i)
#define setIO(x) freopen(x".in","r", stdin);freopen(x".out","w",stdout);
typedef long long ll;
typedef pair<int, int> pii;
const ll LINF = 1e10 + 7;
const int N = 4e2 + 7;
const int MOD = 1e9 + 7;
int n, c, a[N], b[N], f[N][N];
int g[N][N], s[N][N];
ll kpow(ll a, ll b) {
	ll ret = 1;
	while (b > 0) {
		if (b & 1)
			ret = ret * a % MOD;
		b >>= 1, a = a * a % MOD;
	}
	return ret;
}
void inc(int &x, int y) {
	x += y;
	if (x >= MOD)
		x -= MOD;
}

void init() {
	rep(i, 1, N)
	{
		s[i][0] = 1;
		rep(j, 1, N)
			s[i][j] = 1ll * s[i][j - 1] * i % MOD;
	}
	rep(i, 1, n + 1)
	{
		rep(x, 0, c + 1)
		{
			g[i][x] = 0;
			rep(j, a[i], b[i] + 1)
				inc(g[i][x], s[j][x]);
		}
	}
}
void solve() {
	memset(f, 0, sizeof(f));
	f[0][0] = 1;
	rep(i, 1, n + 1)
	{
		rep(j, 0, c + 1)
		{
			rep(x, 0, j + 1)
			{
				inc(f[i][j], 1ll * f[i - 1][j - x] * g[i][x] % MOD);
			}
		}
	}
	printf("%d\n", f[n][c]);
}
int main() {
	scanf("%d%d", &n, &c);
	rep(i, 1, n + 1)
		scanf("%d", &a[i]);
	rep(i, 1, n + 1)
		scanf("%d", &b[i]);
	init();
	solve();
	return 0;
}


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


int main()
{
    long long int i,j,n,root,a,b;
    cin>>n;
    root=sqrt(n);
     for(i=1;i<=root;i++)
        {
            if(n%i==0)
            {
                a=n/i;
                b=i;
            }
        }

            cout<<a+b-2;

    return 0;
}
















Measured memory_bytes: 256
#https://note.nkmk.me/python-union-find/
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

def main():
    N,M = list(map(int,input().split()))
    ab = [list(map(int,input().split())) for i in range(M)]
    
    uf = UnionFind(N+1)
    for i in range(M):
        uf.union(ab[i][0],ab[i][1])
    base = uf.group_count()
    
    ans = 0
    for skip in range(M):
        uf = UnionFind(N+1)
        for i in range(M):
            if skip == i:
                continue
            else:
                uf.union(ab[i][0],ab[i][1])
        if uf.group_count()-base == 1:
            ans += 1
    print(ans)
    
if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
#include <iostream>

using namespace std;

int main(){
	int cl[8];
	int n;
	int x;
	int malti;
	int min,max;

	for(int i = 0;i < 8;i++){
		cl[i] = 0;
	}

	malti = 0;
	min = 0;
	max = 0;

	cin >> n;

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

		if(x >= 3200){
			malti++;
		}
		else{
			int k = x / 400;
			cl[k] = 1;
		}
	}

	for(int i = 0;i < 8;i++){
		if(cl[i] == 1){
			min++;
			max++;
		}
	}
	
	if(min == 0){
		min = 1;
	}

	cout << min << " " << max+malti << endl;

	return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <string>
#include <vector>

using namespace std;

map<long long, int> factorization(long long N) {
	map<long long, int> re;
	while (true) {
		if (N % 2 == 0) {
			N /= 2;
			re[2]++;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	for (int loop = 3; (long long)loop * (long long)loop <= N; loop += 2) {
		if (N % loop == 0) {
			N /= loop;
			re[loop]++;
			loop -= 2;
			if (N == 1) break;
		}
	}
	if (N > 1) re[N]++;
	return re;
}

struct Memo {
	long long fact = 0;
	long long fact_inv = 0;
	long long inv = 0;
};
class Combination1 {
private:
	int m_module = 1000000007;
	vector<struct Memo> memo;
public:
	int calculate(int, int);
	Combination1(int, int);
};
int Combination1::calculate(int n, int k) {
	return ((memo[n].fact * memo[k].fact_inv) % m_module * memo[n - k].fact_inv) % m_module;
}
Combination1::Combination1(int memo_max, int module = 1000000007) {
	m_module = module;
	memo.push_back({ 1,1,0 });
	memo.push_back({ 1,1,1 });
	for (int loop = 2; loop <= memo_max; loop++) {
		struct Memo temp;
		temp.fact = (memo[loop - 1].fact * loop) % m_module;
		temp.inv = m_module - (memo[m_module % loop].inv * int(m_module / loop)) % m_module;
		temp.fact_inv = (memo[loop - 1].fact_inv * temp.inv) % m_module;
		memo.push_back(temp);
	}
}

class Combination2 {
private:
	int size = 0;
	bool add(int);
public:
	vector<int> sequence;
	bool next_combination(void);
	Combination2(int, int);
};
bool Combination2::add(int index) {
	if (index == (int)sequence.size() - 1 && sequence[index] == size - 1
		|| index < (int)sequence.size() - 1 && sequence[index] == sequence[index + 1] - 1) {
		if (index == 0) {
			return false;
		}
		else {
			bool re = add(index - 1);
			sequence[index] = sequence[index - 1] + 1;
			return re;
		}
	}
	else {
		sequence[index]++;
		return true;
	}
}
bool Combination2::next_combination(void) {
	return (sequence.size() == 0) ? false : add(sequence.size() - 1);
}
Combination2::Combination2(int n, int r) {
	size = n;
	for (int loop = 0; loop < r; loop++) sequence.push_back(loop);
	return;
}

void A_The_Number_of_Even_Pairs(void) {

	int N, M; cin >> N >> M;
	cout << (N * (N - 1) + M * (M - 1)) * 0.5 << flush;
	return;
}

void B_String_Palindrome(void) {

	string S; cin >> S;
	int N = S.size();

	for (int loop = 0; loop < N; loop++) {
		if (S[loop] != S[N - loop - 1]) {
			cout << "No" << flush;
			return;
		}
	}
	for (int loop = 0; loop * 2 <= N - 3; loop++) {
		if (S[loop] != S[(N - 3) / 2 - loop]) {
			cout << "No" << flush;
			return;
		}
	}
	for (int loop = (N + 1) / 2; loop < N; loop++) {
		if (S[loop] != S[N - 1 + (N + 1) / 2 - loop]) {
			cout << "No" << flush;
			return;
		}
	}
	cout << "Yes" << flush;
	return;
}

void C_Maximum_Volume(void) {

	int L; cin >> L;
	cout << setprecision(20) << double(L * L * L) / 27.0 << flush;
	return;
}

int main(void) {

	//A_The_Number_of_Even_Pairs();
	//B_String_Palindrome();
	C_Maximum_Volume();
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

typedef struct {
  char suit;
  int value;
}AAA;

void BubbleSort(AAA *, int);
void SelectionSort(AAA *, int);
void output(AAA *, int);

int main(){
  int N, i;
  AAA *C, *C_B, *C_S;
  
  scanf("%d",&N);
  C = malloc(sizeof(AAA) * N);
  C_B = malloc(sizeof(AAA) * N);
  C_S = malloc(sizeof(AAA) * N);
  for(i = 0; i < N; i++){
    scanf(" %c%d", &C[i].suit, &C[i].value);
  }
  for(i = 0; i < N; i++){
    C_B[i] = C[i];
    C_S[i] = C[i];
  }

  
  
  BubbleSort(C_B, N);
  output(C_B, N);
  printf("Stable\n");
  
  SelectionSort(C_S, N);
  output(C_S, N);
  
  for(i = 0; i < N; i++){
    if(C_B[i].suit != C_S[i].suit){
      break;
    }
  }
  if(i == N){
    printf("Stable\n");
  }
  else{
    printf("Not stable\n");
  }

  return 0;
}

void BubbleSort(AAA * C, int N){
  int i, j;
  AAA temp;
  for(i = 0; i < N - 1; i++){
    for(j = N - 1; j > i; j--){
      if(C[j - 1].value > C[j].value){
	temp = C[j];
	C[j] = C[j - 1];
	C[j - 1] = temp;
      }
    }
  }
}

void SelectionSort(AAA * C, int N){
  int i, j, minj, flag;
  AAA temp;

  for(i = 0; i < N - 1; i++){
    minj = i;
    for(j = i + 1; j < N; j++){
      if(C[minj].value > C[j].value){
	minj = j;
      }
    }
    temp = C[i];
    C[i] = C[minj];
    C[minj] = temp;
  }
}

void output(AAA * C, int N){
  int i;
  
  for(i = 0; i < N - 1; i++){
    printf("%c%d ", C[i].suit, C[i].value);
  }
  printf("%c%d\n", C[N - 1].suit, C[N - 1].value);
}


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

#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;

int main(){
    string L,T;cin >> T >> L;
    int res = L.size();
    rep(i,T.size()-L.size()+1){
        int r = 0;
        rep(j, L.size()){
            if (T[i+j]!=L[j]) r++;
        }
        if (r < res) res = r;
    }
    cout << res << endl;
}

Measured memory_bytes: 3632
s = input()

first = (len(s)-1)//2
sec = (len(s)+3)//2

if s[:first] == s[:first][::-1] and s == s[::-1]:
    if s[sec-1:] == s[sec-1:][::-1]:
        print("Yes")
    else:
        print("No")
else:
    print("No")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define rep(i, s, n) for (int i = s; i < n; i++)
#define rp(i,n) for (int i=0;i<n;i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define all_acc(x) (x).begin(), (x).end(), 0LL
#define int long long
#define absSort(v) sort(a.begin(), a.end(), [](int i, int j) -> bool { return abs(i) < abs(j); });
using namespace std;
using P = pair<int, int>;
using Graph = vector<vector<int>>;
using ll = long long;
double pi=3.14159265359;

template <class T, class U>
void chmin(T& t, const U& u) {
    if (t > u) t = u;
}
template <class T, class U>
void chmax(T& t, const U& u) {
    if (t < u) t = u;
}

//出力するよ
void output_tate(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        //if (i != 0)
        //    cout << " ";
        cout << s[i]<<endl;
    }
    //cout << endl;
}

void output_yoko(vector<int> s){
    int n = s.size();
    for (int i = 0; i < n; i++){
        if (i != 0)
            cout << " ";
        cout << s[i];//<<endl;
    }
    cout << endl;
}

int dp[3010][3010][4];
int v[3010][3010]={};

signed main() {
    int N,K; cin>>N>>K;
    vector<int> p(N),c(N);
    rp(i,N) cin>>p[i],p[i]--;
    rp(i,N) cin>>c[i];

    int ans= -1e18;

    //各マスからスタートした場合を考える。
    rp(i,N){
        int v=i;
        int cycle_sum=0;
        int cycle_cnt=0;

        //そのマスからスタートして、サイクルの和とサイクルの要素数を求める。
        while(1){
            cycle_cnt++;
            cycle_sum+=c[v];
            v=p[v];
            if(v==i) break;
        }

        int path=0;
        int cnt=0;

        while(true){
            cnt++;
            path+=c[v];

            if(cnt>K) break;

            int num = (K-cnt) / cycle_cnt;
            int score = path + max(0LL,cycle_sum)*num;
            chmax(ans,score);

            v=p[v];
            if(v==i) break;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3680
#include <iostream>
#include <string>
#include <map>

using namespace std;

const int MAX_N = 55;

int arr [MAX_N];

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

  map<string, int> idx;
  for (int i = 0; i < n; i++) {
    string s;
    cin >> s >> arr[i];

    idx[s] = i;
  }

  string x;
  cin >> x;

  int ans = 0;
  int st = idx[x] + 1;
  for (int i = st; i < n; i++) {
    ans += arr[i];
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
a = list(map(int, input().split()))
Q = deque(a)
b = deque()
i = 1
while Q:
    q = Q.popleft()
    if i == 0:
        b.appendleft(q)
        i = 1
    else:
        b.append(q)
        i = 0
if n % 2 == 0:
    for bi in b:
        print(bi, end=' ')
    print('')
else:
    for bi in reversed(b):
        print(bi, end=' ')
    print('')

Measured memory_bytes: 32372
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
 
int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++)
    {
        cin >> A[i];
    }
 
    long long ans = 0;
    int MaxNum = 0;
    for (int i = 0; i < N; i++)
    {
        //Use common MaxNum to reduce the compuation time
        MaxNum = max(MaxNum, A[i]);
        int Bi = MaxNum;
        ans += Bi - A[i];
    }
 
    cout << ans << endl;
}

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

using namespace std;

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int H, W, K;
  cin >> H >> W >> K;
  vector<vector<int>> G(H, vector<int>(W, 0));
  for (int i = 0; i < K; i++) {
    int y, x, v;
    cin >> y >> x >> v;
    y--, x--;
    G[y][x] = v;
  }
  vector dp(H, vector(W, vector(4, INT64_C(0))));
  dp[0][0][1] = G[0][0];
  for (int i = 0; i < H; i++) {
    for (int j = 0; j < W; j++) {
      for (int k = 0; k < 4; k++) {
        if (i + 1 < H) {
          chmax(dp[i + 1][j][0], dp[i][j][k]);
          chmax(dp[i + 1][j][1], dp[i][j][k] + G[i + 1][j]);
        }
        if (j + 1 < W) {
          chmax(dp[i][j + 1][k], dp[i][j][k]);
          if (k < 3) chmax(dp[i][j + 1][k + 1], dp[i][j][k] + G[i][j + 1]);
        }
      }
    }
  }
  cout << *max_element(dp[H - 1][W - 1].begin(), dp[H - 1][W - 1].end()) << '\n';
  return 0;
}


Measured memory_bytes: 670880
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    vl A(N);
    in(N,A);
    
    ll ans = 0;
    ll min_p = 1;
    
    rep(i,N){
        
        ll a = A[i]/min_p;
        ll b = A[i] - a*min_p;
        
        if(a == 0) chmax(min_p,A[i]+1);
        else if(b == 0){
            if(a > 1) ans += a-1,chmax(min_p,(ll)2);
            else chmax(min_p,A[i]+1);
        }else ans += a,chmax(min_p,b+1);
        
        
        //cout << i csp A[i] csp ans csp min_p csp a<< endl;
    }
    
    
    cout << ans << endl;
    
    

    return 0;
}


Measured memory_bytes: 3976
#include <iostream>
#include <iomanip>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <functional>
#include <limits.h>
#include <set>
#include <map>
#include <tuple>
using namespace std;



#define ll long long
#define ull unsigned long long
#define rep(i,N) for (ll i=0;i<N;i++)
#define loop(i,N,M) for(ll i=N;i<M;i++)
#define MAX(v) *max_element(v.begin(),v.end())
#define MIN(v) *min_element(v.begin(),v.end())
#define SORTL2S(type,v) sort(v.begin(),v.end(),greater<type>())
#define SORTS2L(type,v) sort(v.begin(),v.end())
#define SORTMF(v,func) sort(v.begin(),v.end(),func)

ll debugFlag = false;
template<typename T> void debug(T&);
template<typename T> void debug(T&, bool);
template<typename T> void debug(vector<T>&);
template<typename T> void debug(vector<T>&, bool);
template<typename T, typename U> void debug(pair<T, U>&);
template<typename T, typename U> void debug(pair<T, U>&, bool);

template<typename T>
void debug(T& obj) {
	debug(obj, true);
}

template<typename T>
void debug(T& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << obj;
	if (lnFlag) cout << endl;
}

template<typename T>
void debug(vector<T>& obj) {
	debug(obj, true);
}

template<typename T>
void debug(vector<T>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "[";
	rep(i, obj.size()) {
		if (i != 0) cout << ",";
		debug(obj[i], false);
	}
	cout << "]";
	if (lnFlag) cout << endl;
}

template<typename T, typename U>
void debug(pair<T, U>& obj) {
	debug(obj, true);
}

template<typename T, typename U>
void debug(pair<T, U>& obj, bool lnFlag) {
	if (!debugFlag) return;
	cout << "(";
	debug(obj.first, false);
	cout << ",";
	debug(obj.second, false);
	cout << ")";
	if (lnFlag) cout << endl;
}

void solve() {
	ll R, G;
	cin >> R >> G;

	cout << G + (G - R);



}


int main(int argc, char* argv[]) {
	if (argc == 2 && string(argv[1]) == "debug") debugFlag = true;
	solve();
	cout << endl;
	return 0;
}


Measured memory_bytes: 256
//M(int*a){return*1[&a]-*a;}
M(int*a,int*b){return*b-*a;}
main(){
	int a[10],i,j;
	for(i=0;i<2;i++){
		for(j=0;j<10;j++)
			scanf("%d",a+j);
		qsort(a,10,4,M);
		printf("%d%c",a[0]+a[1]+a[2],i?'\n':' ');
	}
	exit(0);
}

Measured memory_bytes: 0
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class ABC106_2 {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int N = in.nextInt();
            int count = 0;
            int anscount = 0;
            for (int j = N; j >= 0; j--) {
                for (int i = 1; i <= j; i++) {
                    if ((j % i) == 0) {
                        if ((i % 2) == 1) {
                            count++;
                        }
                    }
                }
                if (count == 8) {
                    anscount++;
                }
                count = 0;
            }
            out.println(anscount);

        }

    }
}



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

int main(){
    int n, t;
    scanf("%d %d", &n, &t);
    vector<pair<int, int>> dish(n);
    for (int i = 0; i < n; i++) scanf("%d %d", &dish[i].first, &dish[i].second);
    sort(dish.begin(), dish.end());
    vector<vector<int>> dp(n + 1, vector<int>(t, 0));
    vector<int> max_b(n, 0);
    for (int i = n - 1; i >= 0; i--){
        max_b[i] = max(max_b[i], dish[i].second);
        if (i != 0) max_b[i - 1] = max_b[i];
    }
    int ans = 0;
    for (int i = 0; i < n; i++){
        if (dish[i].first < t) dp[i + 1][dish[i].first] = max(dp[i + 1][dish[i].first], dish[i].second);
        for (int j = 0; j < t; j++){
            dp[i + 1][j] = max(dp[i + 1][j], dp[i][j]);
            if (j + dish[i].first < t) dp[i + 1][j + dish[i].first] = max(dp[i + 1][j + dish[i].first], dp[i][j] + dish[i].second);
            if (j != t - 1) dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i + 1][j + 1]);
        }
        if (i != n - 1) ans = max(ans, dp[i + 1][t - 1] + max_b[i + 1]);
        else ans = max(ans, dp[i + 1][t - 1]);
    }
    printf("%d", ans);
}



Measured memory_bytes: 35584
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>

using namespace std;
using ll = long long;
const int N = 200005;
ll a[N];
int main() 
{
	int n, k;
	scanf("%d%d", &n, &k);

	for (int i = 1; i <= n; ++i) scanf("%lld", &a[i]);

	int p1 = 1, p2 = k + 1;

	while (p2 <= n)
	{
		if (a[p1] < a[p2])
		{
			puts("Yes");
		}
		else
		{
			puts("No");
		}
		++p1, ++p2;
	}

	return 0;
}

Measured memory_bytes: 5316
#include <algorithm>  
#include <iostream>  
#include <sstream>  
#include <string>  
#include <vector>  
#include <queue>  
#include <set>  
#include <map>  
#include <cstdio>  
#include <cstdlib>  
#include <cctype>  
#include <cmath>  
#include <cstring>
#include <list>  
#include <cassert>
#include <climits>
#include <bitset>
#include <chrono>
#include <random>
using namespace std;

#define PB push_back  
#define MP make_pair  
#define SZ(v) ((int)(v).size())  
#define FOR(i,a,b) for(int i=(a);i<(b);++i)  
#define REP(i,n) FOR(i,0,n)  
#define FORE(i,a,b) for(int i=(a);i<=(b);++i)  
#define REPE(i,n) FORE(i,0,n)  
#define FORSZ(i,a,v) FOR(i,a,SZ(v))  
#define REPSZ(i,v) REP(i,SZ(v))  
std::mt19937 rnd((int)std::chrono::steady_clock::now().time_since_epoch().count());
typedef long long ll;
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }

const int MAXN = 12;
const int MAXLEN = 200000;

int n;
char s[MAXLEN + 1]; int slen;
vector<int> ans;

int swapcnt[MAXLEN];
int nmove, nswap;

vector<int> calc(int n) {
	if (n == 0) {
		vector<int> ret(nmove + 1);
		REP(i, nmove) ret[i] = i + 1; ret[nmove] = 0;
		return ret;
	} else {
		vector<int> sub = calc(n - 1);
		int partsize = SZ(sub) - nmove;
		vector<int> nxt(3 * (nmove + partsize));
		REP(atpart, 3) REPSZ(atpos, sub) {
			int topos = sub[atpos], topart;
			if (topos >= nmove) topart = atpart; else if (swapcnt[topos] % 2 == 0) topart = atpart + 1; else topart = atpart == 0 ? 2 : atpart == 1 ? 3 : 1;
			nxt[atpart * (nmove + partsize) + atpos] = topart * (nmove + partsize) + topos;
		}
		//printf("nxt:"); REPSZ(i, nxt) printf(" %d", nxt[i]); puts("");
		vector<int> ret(nmove + 3 * partsize);
		REP(i, nmove + 3 * partsize) {
			int atpart = i < nmove ? 0 : (i - nmove) / partsize, atpos = i < nmove ? i : nmove + (i - nmove) % partsize;
			while (true) {
				int to = nxt[atpart * (nmove + partsize) + atpos], topart = to / (nmove + partsize), topos = to % (nmove + partsize);
				//printf("%d: (%d,%d) -> (%d,%d)\n", i, atpart, atpos, topart, topos);
				if (topos >= nmove) {
					assert(topart == atpart);
					ret[i] = nmove + (topart == 0 || nswap % 2 == 0 ? atpart : 3 - atpart) * partsize + topos - nmove;
					break;
				} else if (topart >= 3) {
					ret[i] = topos;
					break;
				} else {
					atpart = topart, atpos = topos;
				}
			}
		}
		return ret;
	}
}

void solve() {
	nmove = nswap = 0; REP(i, slen) if (s[i] == 'S') ++nswap; else swapcnt[nmove] = nswap, ++nmove;
	vector<int> trans = calc(n);
	//printf("trans:"); REPSZ(i, trans) printf(" %d", trans[i]); puts("");
	int totsize = SZ(trans) - nmove;
	ans=vector<int>(totsize);
	REP(i, totsize) {
		int atpos = nmove + i;
		while (true) {
			int topos = trans[atpos];
			if (topos >= nmove) {
				ans[i] = topos - nmove;
				break;
			} else {
				atpos = topos;
			}
		}
	}
	//printf("ans:"); REPSZ(i, ans) printf(" %d", ans[i]); puts("");
}

void run() {
	scanf("%d", &n);
	scanf("%s", s); slen = strlen(s);
	solve();
	REPSZ(i, ans) { if (i != 0) printf(" "); printf("%d", ans[i]); } puts("");
}

int main() {
	run();
	return 0;
}


Measured memory_bytes: 13436
#include <cstdlib>
#include <iostream>
#include <typeinfo>
#include <bits/stdc++.h>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int h, w;
  cin >> h >> w;
  char c[h][w];
  int m[h][w];
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> c[i][j];
      if (c[i][j] == '#')
      {
        m[i][j] = 9;
      }
      else
      {
        m[i][j] = 0;
      }
    }
  }
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (c[i][j] == '#')
      {
        for (int k = i - 1; k <= i + 1; k++)
        {
          for (int l = j - 1; l <= j + 1; l++)
          {
            if (!(k == i && l == j) && k != -1 && k != h && l != -1 && l != w)
            {
              if (c[k][l] != '#')
              {
                m[k][l] += 1;
              }
            }
          }
        }
      }
    }
  }

  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      if (m[i][j] == 9)
      {
        cout << '#';
      }
      else
      {
        cout << m[i][j];
      }
    }
    cout << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
const Int MOD = 998244353;
struct SegTree {
    int N;
    vector<Int> A, B, C;
    SegTree(int n) {
        N = 1; while (N < n) N *= 2;
        A.resize(2 * N);
        B.resize(2 * N, 1);
        C.resize(2 * N);
    }
    Int sum_0(int L, int R, int node, int nodeL, int nodeR) {
        if (R <= nodeL || nodeR <= L) return 0;
        if (L <= nodeL && nodeR <= R) return A[node];
        A[2*node+0] = (B[node] * A[2*node+0] + C[node] * (nodeR - nodeL) / 2) % MOD;
        A[2*node+1] = (B[node] * A[2*node+1] + C[node] * (nodeR - nodeL) / 2) % MOD;
        B[2*node+0] = B[node] * B[2*node+0] % MOD;
        B[2*node+1] = B[node] * B[2*node+1] % MOD;
        C[2*node+0] = (B[node] * C[2*node+0] + C[node]) % MOD;
        C[2*node+1] = (B[node] * C[2*node+1] + C[node]) % MOD;
        B[node] = 1, C[node] = 0;
        Int ans = 0;
        ans += sum_0(L, R, 2*node+0, nodeL, (nodeL + nodeR) / 2);
        ans += sum_0(L, R, 2*node+1, (nodeL + nodeR) / 2, nodeR);
        return ans % MOD;
    }
    Int sum(int L, int R) {
        return sum_0(L, R, 1, 0, N);
    }
    void modify_0(int L, int R, int b, int c, int node, int nodeL, int nodeR) {
        if (R <= nodeL || nodeR <= L) return;
        if (L <= nodeL && nodeR <= R) {
            A[node] = (b * A[node] + (Int)c * (nodeR - nodeL)) % MOD;
            B[node] = b * B[node] % MOD;
            C[node] = (b * C[node] + c) % MOD;
            return;
        }
        A[2*node+0] = (B[node] * A[2*node+0] + C[node] * (nodeR - nodeL) / 2) % MOD;
        A[2*node+1] = (B[node] * A[2*node+1] + C[node] * (nodeR - nodeL) / 2) % MOD;
        B[2*node+0] = B[node] * B[2*node+0] % MOD;
        B[2*node+1] = B[node] * B[2*node+1] % MOD;
        C[2*node+0] = (B[node] * C[2*node+0] + C[node]) % MOD;
        C[2*node+1] = (B[node] * C[2*node+1] + C[node]) % MOD;
        B[node] = 1, C[node] = 0;
        modify_0(L, R, b, c, 2*node+0, nodeL, (nodeL + nodeR) / 2);
        modify_0(L, R, b, c, 2*node+1, (nodeL + nodeR) / 2, nodeR);
        A[node] = (A[2*node+0] + A[2*node+1]) % MOD;
    }
    void modify(int L, int R, int b, int c) {
        modify_0(L, R, b, c, 1, 0, N);
    }
};
int main() {
    int N, Q; cin >> N >> Q;
    SegTree st(N);
    for (int i = 0; i < N; i++) {
        int a; cin >> a; st.modify(i, i + 1, 0, a);
    }
    for (int i = 0; i < Q; i++) {
        int type; cin >> type;
        if (type == 0) {
            int l, r, b, c; cin >> l >> r >> b >> c;
            st.modify(l, r, b, c);
        } else {
            int l, r; cin >> l >> r;
            cout << st.sum(l, r) << '\n';
        }
    }
    return 0;
}


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

int main(){
  int n,x,y,z;
  cin >> n;
  int A[n+1],B[n+1],C[n];
  for(int i = 1;i <= n;i++)cin >> A[i];
  for(int i = 1;i <= n;i++)cin >> B[i];
  for(int i = 1;i < n;i++)cin >> C[i];
  for(int i = 1;i <= n;i++){
    y = A[i];
    x += B[y];
    if(A[i-1]+1 == A[i]){
      x += C[y-1];
    }
  }
  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
void ABC161(void);
void ABC162(void);
void ABC163(void);
void ABC164(void);

int main(void){
    ABC162();
}

void ABC162(){
    int n,a,b,c;
    cin>>n;
    a=n/100;
    b=(n/10)%10;
    c=n%10;
    if(a==7||b==7||c==7)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define pi M_PI
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1000000007,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<ll,ll> P;

void Main() {
  ll n;
  R n;
  map<int,int> m;
  ll a[n];
  rep(i,n) {
    R a[i];
    m[a[i]]++;
  }
  vector<P> v;
  tr(it,m) v.pb(P(it->F,it->S));
  ll cnt=0,sum=0;
  rep(i,v.size()) {
    sum+=v[i].F*v[i].S;
    cnt+=v[i].S;
    if(i<v.size()-1&&sum*2<v[i+1].F) cnt=0;
  }
  pr(cnt);
}

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


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

#define ST_ARR_LEN(array) (sizeof(array)/sizeof(*array))
#define MOD 1000000007

using namespace std;

using ll = long long;
const ll MAX = LLONG_MAX;
const ll MIN = LLONG_MIN;

typedef stack<ll> llStack;
typedef queue<ll> llQueue;
typedef vector<ll> llVector;
typedef list<ll> llList;

typedef struct S{
  int a;
  int b;
} Object;

int main(){
  ll X;
  cin >> X;
  
  ll n, m;
  for(ll i=-1000;i<=1000;i++){
    n = i*i*i*i*i;
    for(ll j=-1000;j<=1000;j++){
      m = j*j*j*j*j;
      if(n-m == X){
        cout << i << " " << j << endl;
        return 0;
      }
    }
  }
  
  
  
  
  
  //cout << ans << endl;
  
}

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

int main() {
  int H,M;
  while(1) {
    cin >> H >> M;
    for ( int i = 0; i < H; i++ ){
    for ( int j = 0; j < M; j++ ){
        if((i+j)%2==1){
           cout<<".";
        }
        else {
          cout<<"#";
        }
}
    cout<<endl;
    if(H==0&&M==0) {
      break;
    }
}
    if(H==0&&M==0) {
      break;
    }
    cout<<endl;
}
           }



Measured memory_bytes: 3080
#include <bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template <class T>
inline bool chmin(T &a, T b) {
  if (a > b) {
    a = b;
    return true;
  }
  return false;
}
const long long INF = 1LL << 60;
using pll = pair<long long, long long>;

int main() {
  // 標準入力が早くなる。Cスタイルの入出力とC++スタイルの入出力を混合させてはならない。
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  int N;
  cin >> N;

  cout << N / 2 + N % 2 << endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#define lol(i,n) for(int i=0;i<n;i++)
#define mod 1000000007
typedef long long ll;
using namespace std;
ll n,a[100010];
int main(){
    cin>>n;
    lol(i,n)cin>>a[i];
    ll s=2,ans=a[0]-1;
    for(int i=1;i<n;i++){
	if(s==a[i])s++;
	else{
	    ans+=(a[i]-1)/s;
	}
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 1024
N,M=map(int,input().split())
H=list(map(int,input().split()))
AB = [map(int, input().split()) for _ in range(M)]
A, B = [list(i) for i in zip(*AB)]
road= [ [] for i in range(N)]
cnt=0
for i in range(0,M):
    road[A[i]-1].append(B[i])
    road[B[i] - 1].append(A[i])

for i in range(1,N+1):
    flag=True
    for j in road[i-1]:
        if H[i-1]<=H[j-1]:
            flag=False
            break
    if flag:
        cnt+=1

print(cnt)


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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back
#define pii pair<int, int>
#define pll pair<ll, ll>

using namespace std;

typedef long long ll;

/* --- INFの値が適切か確認する --- */
// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
// const int MOD = 1000000007;

int main() {
  int a, b;
  cin >> a >> b;
  cout << max({a - b, a + b, a * b}) << endl;
}


Measured memory_bytes: 256