akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <cmath>
#include <complex>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <vector>

const int MOD = 1e9 + 7;
const int iINF = 2147483647 / 2;
const long long int llINF = 9223372036854775807 / 2;

using namespace std;
using ll = long long int;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;

typedef pair<ll, ll> pll;
bool paircomp(const pll &a, const pll &b) {
  if (a.first == b.first)
    return a.second < b.second;
  return a.first < b.first;
}

#define REP(i, n) for (ll i = 0; i < (n); i++)
#define RREP(i, n) for (ll i = (n)-1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i < (b); i++)
#define AUTO(i, m) for (auto &i : m)
#define ALL(a) (a).begin(), (a).end()
#define MAX(vec) *std::max_element(vec.begin(), vec.end())
#define MIN(vec) *std::min_element(vec.begin(), vec.end())
#define ARGMAX(vec)                                                            \
  std::distance(vec.begin(), std::max_element(vec.begin(), vec.end()))
#define ARGMIN(vec)                                                            \
  std::distance(vec.begin(), std::min_element(vec.begin(), vec.end()))
#define REV(T) greater<T>()
#define PQ(T) priority_queue<T, vector<T>, greater<T>>
#define VVL(a, b, c) vector<vector<ll>>(a, vector<ll>(b, c))
#define VVVL(a, b, c, d)                                                       \
  vector<vector<vector<ll>>>(a, vector<vector<ll>>(b, vector<ll>(c, d)))
#define SP(a) setprecision(a)
#define SQRT(a) sqrt((long double)(a))
#define DPOW(a, b) pow((long double)(a), (long double)(b))
#define UNIQUE(vec)                                                            \
  do {                                                                         \
    sort(ALL((vec)));                                                          \
    (vec).erase(std::unique(ALL((vec))), (vec).end());                         \
  } while (0)

ll POW(ll n, ll m) {
  if (m == 0) {
    return 1;
  } else if (m % 2 == 0) {
    ll tmp = POW(n, m / 2);
    return (tmp * tmp);
  } else {
    return (n * POW(n, m - 1));
  }
}

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

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  ll N, Q;
  string S;
  cin >> N;
  cin >> S;
  cin >> Q;
  vl K(Q);
  REP(i, Q) cin >> K[i];
  REP(q, Q) {
    ll k = K[q];
    ll nowa = 0;
    ll nowb = 0;
    ll mcount = 0;
    ll ans = 0;
    REP(i, k) {
      if (S[i] == 'D')
        nowa++;
      else if (S[i] == 'M') {
        nowb += nowa;
        mcount++;
      } else if (S[i] == 'C')
        ans += nowb;
    }
    FOR(i, k, N) {
      if (S[i - k] == 'D') {
        nowa--;
        nowb -= mcount;
      } else if (S[i - k] == 'M') {
        mcount--;
      }
      if (S[i] == 'D')
        nowa++;
      else if (S[i] == 'M') {
        nowb += nowa;
        mcount++;
      } else if (S[i] == 'C')
        ans += nowb;
    }
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 1948
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using namespace std;
using ll = long long;
//const ll MOD = (ll)1e9+7;
const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}

#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
	ll res = 1;
	while(b){
		if(b&1)res = res * x % MOD;
		x = x * x % MOD;
		b>>=1;
	}
	return res;
}

ll modinv(ll x){
	return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
	if(was_output)cout << " ";
	cout << a;
	was_output = true;
}
void outendl(){
	was_output = false;
	cout << endl;
}

int main(){
	int n;
	cin >> n;
	string str;
	cin >> str;
	set<string> s;
	set<string> ans;
	s.emplace("");
	foreach(i, str){
		set<string> add;
		foreach(j, s){
			string e=" ";
			e[0]=i;
			string d = j + e;
			if(d.size()==3)ans.emplace(d);
			else add.emplace(d);
		}
		foreach(j, add)s.emplace(j);
	}
	cout << ans.size() << endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define fore(i,x,y) for(long long i=x;i<y;i++)
typedef long long ll;
using namespace std;
int main()
{
	int n,m;
	cin >> n >> m;
	vector<int>vec(n,0);
	fore(i,0,m){
		int t,u;
		cin >> t >> u;
		vec[t-1]++;
		vec[u-1]++;
	}
	fore(i,0,n){
		cout << vec[i] << endl;
	}

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<utility>
#include<cmath>
#include<climits>
#include<queue>
#include<stack>
#include<numeric>
#include<set>
#include<iomanip>
#include<map>
using namespace std;


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


int main(){
  int n;
  cin >> n;
  vector<int> a(n);

  rep(i, n) cin >> a[i];

  int as = 0, bs = 0;

  sort(a.begin(), a.end());
  reverse(a.begin(), a.end());

  for(int i = 0; i < n; ++i){
    if(i % 2 == 0){
      as += a[i];
    } else {
      bs += a[i];
    }
  }

  cout << as - bs << endl;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>    
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define ld long double
#define pii pair <int, int>
#define sz(a) (int)(a.size()) 
#define resize(v) v.resize(unique(all(v)) - v.begin()); 
#define all(a) a.begin(), a.end()
#define forit(it, s) for(__typeof(s.begin()) it = s.begin(); it != s.end(); it ++)

// random_device rd; mt19937 g(rd());    
                                            
using namespace std;
using namespace __gnu_pbds;
 
void Fast_Read_Out()
{
    ios_base::sync_with_stdio(0);
    cin.tie(), cout.tie();
}
 
void Random()
{
    unsigned int seed;                                                                        
    asm("rdtsc" : "=A" (seed));
    srand(seed);        
}
 
unsigned int Time()
{
     unsigned int time = clock() / 1000.00;                           
     return time;
}

template <typename T> using ordered_set = tree <T, null_type, less <T>, rb_tree_tag, tree_order_statistics_node_update>; 
 
const int mod = (int)1e9 + 7;
const int N = (int)2e5 + 123;

int n;
int a[N];
long long l[N];
long long r[N];
long long ans;     
stack <int> st;

int main ()
{
    #ifdef JUDGE
        freopen("input.txt", "r", stdin);
    #endif        
    Fast_Read_Out();
    Random();
    cin >> n;
    for(int i = 1; i <= n; i++) cin >> a[i];
    for(int i = 1; i <= n; i++)
    {
    	while(!st.empty() && a[st.top()] > a[i]) st.pop();
    	if(st.empty()) l[i] = 0;
    	else l[i] = st.top();
    	st.push(i);
    }
    while(!st.empty()) st.pop();
    for(int i = n; i >= 1; i--)
    {
    	while(!st.empty() && a[st.top()] > a[i]) st.pop();
    	if(st.empty()) r[i] = n + 1;
    	else r[i] = st.top();
    	st.push(i);
    }
    for(int i = 1; i <= n; i++) ans += (i - l[i]) * (r[i] - i) * a[i];
    cout << ans;
}      


Measured memory_bytes: 4992
#[allow(unused_macros)]
macro_rules ! input { ( source = $ s : expr , $ ( $ r : tt ) * ) => { let mut iter = $ s . split_whitespace ( ) ; let mut next = || { iter . next ( ) . unwrap ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; ( $ ( $ r : tt ) * ) => { let stdin = std :: io :: stdin ( ) ; let mut bytes = std :: io :: Read :: bytes ( std :: io :: BufReader :: new ( stdin . lock ( ) ) ) ; let mut next = move || -> String { bytes . by_ref ( ) . map ( | r | r . unwrap ( ) as char ) . skip_while ( | c | c . is_whitespace ( ) ) . take_while ( | c |! c . is_whitespace ( ) ) . collect ( ) } ; input_inner ! { next , $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! input_inner { ( $ next : expr ) => { } ; ( $ next : expr , ) => { } ; ( $ next : expr , $ var : ident : $ t : tt $ ( $ r : tt ) * ) => { let $ var = read_value ! ( $ next , $ t ) ; input_inner ! { $ next $ ( $ r ) * } } ; }
#[allow(unused_macros)]
macro_rules ! read_value { ( $ next : expr , ( $ ( $ t : tt ) ,* ) ) => { ( $ ( read_value ! ( $ next , $ t ) ) ,* ) } ; ( $ next : expr , [ $ t : tt ; $ len : expr ] ) => { ( 0 ..$ len ) . map ( | _ | read_value ! ( $ next , $ t ) ) . collect ::< Vec < _ >> ( ) } ; ( $ next : expr , chars ) => { read_value ! ( $ next , String ) . chars ( ) . collect ::< Vec < char >> ( ) } ; ( $ next : expr , usize1 ) => { read_value ! ( $ next , usize ) - 1 } ; ( $ next : expr , $ t : ty ) => { $ next ( ) . parse ::<$ t > ( ) . expect ( "Parse error" ) } ; }

fn main() {
    input! {
        s: [chars;2]
    }
    let mut t = s.clone();
    let mut t0 = t[0].clone();
    let mut t1 = t[1].clone();
    t0.reverse();
    t1.reverse();
    t[0] = t1;
    t[1] = t0;
    let mut is_ok = true;
    for y in 0..2 {
        for x in 0..3 {
            if s[y][x] != t[y][x] {
                is_ok = false;
            }
        }
    }
    println!("{}", if is_ok {"YES"} else {"NO"});
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
#define io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define ll long long
int main()
{
    io
    int a,b;
	cin >> a >> b;
	int x,y;
	x = (a/0.08);
	y = (b/0.10);
	int ans = max(x,y),f=-1;
  	while(ans <= 1250)
    {
		if((floor(ans*0.08)==a) && (floor)(ans*0.1)==b)
        {
          f = ans;
          break;
        }
		else ans++;
    }
  cout << f << "\n";
    return 0;
}

Measured memory_bytes: 256
N = gets.chomp.to_i
H = gets.chomp.split.map(&:to_i)

ans = 1
1.upto(N - 1).each do |i|
  f = true
  0.upto(i - 1).each do |j|
    f = false if H[j] > H[i]
  end
  ans += 1 if f
end

puts ans


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e5 + 5;
#define INF 1000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;

int cnt = 0;

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	//ifstream cin (".in");
	//ofstream cout (".out");
	int n;
	cin >> n;
	int a[n];
	for(int i=0; i<n; i++)cin >> a[i];
	sort(a,a+n);	
	int cnt = 0 ;
	for(int i=0; i<n; i++){
		for(int j=i+1; j<n; j++){
			for(int k=j+1; k<n; k++){
				if(a[i]<a[j] && a[j]<a[k]){
					if(a[k]<a[i]+a[j])cnt++;
				}
			}
		}
	}
	cout << cnt << endl;
	return 0;	
}	


// ab=ob

Measured memory_bytes: 3620
#define Nil 100
  
int G[Nil][Nil],way[Nil],chi[Nil],n,weigh[Nil][Nil];
  
void Fsearch(int x, int y){
  int i;
  way[x] = y;
  for(i=0;i<chi[x];i++)
    if(y+weigh[x][i]<way[G[x][i]]) Fsearch(G[x][i], y+weigh[x][i]);
}
  
int main(){
  int i,j,m;
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    way[i]=10000000;
    scanf("%d",&m);
    scanf("%d",&chi[m]);
     
    for(j=0;j<chi[m];j++){
     scanf("%d",&G[m][j]);
     scanf("%d",&weigh[m][j]);
    }
  }
  
  Fsearch(0,0);
  
  for(i=0;i<n;i++)
    if(way[i]==10000000)way[i]=-1;
  
  for(i=0;i<n;i++) printf("%d %d\n",i,way[i]);
  
  return 0;
}


Measured memory_bytes: 2052
#include "bits/stdc++.h"
using namespace std;

#define ub upper_bound
#define sum(a) accumulate(all(a),0ll)
#define lb lower_bound
#define all(v) begin(v),end(v)
#define allr(v) rbegin(v),rend(v)
#define sort_dec(v) sort(all(v),[](auto e1,auto e2){return e1>e2;})
#define For(n) for(ll i=0;i<n;i++)
#define Forj(n) for(ll j=0;j<n;j++)
typedef long long int ll;
typedef unsigned long long int ull;
#define fi first
#define se second
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define Mp 1e9+7
#define vpll vector< pair<ll,ll> >
#define bug(n) {cout<<n;return;}
#define cont(n) {cout<<n<<endl;continue;}
#define pb push_back

ll n;
ll w[101],v[101];

// ll dpArray[101][100001];

// ll dp(ll i,ll W){
// 	if(i==n)return 0;
// 	if(w[i]>W)return dp(i+1,W);
// 	if(dpArray[i][W]!=-1)return dpArray[i][W];
// 	return dpArray[i][W]=max(dp(i+1,W-w[i])+v[i],dp(i+1,W));
// }
 
void solve()
{
	// ll n;
	// memset(dpArray,-1,sizeof(dpArray));
	ll W;
	cin>>n>>W;
	For(n)cin>>w[i]>>v[i];
	ll V[100001],VV[100001];
	For(100001)V[i]=1e9+7;
	V[0]=0;
	For(n)
	{
		Forj(100001)VV[j]=V[j];
		Forj(100001)
		{
			if(j>=v[i])V[j]=min(V[j],VV[j-v[i]]+w[i]);
			// if(j+v[i]==100)cout<<i<<":"<<V[100]<<endl;
		}
	}
	ll ans=0;
	// For(1000)if(V[i]!=1e9+7)cout<<i<<":"<<V[i]<<endl;
	For(100001)if(V[i]<=W)ans=i;
	// cout<<V[100]<<endl;
	cout<<ans;
	// ll dp[n+1][W+1];
	// memset(dp,0,sizeof(dp));
	// For(n){
	// 	Forj(W+1)
	// 	{
	// 		dp[i+1][j]=dp[i][j];
	// 		if(w[i]<=j)dp[i+1][j]=max(dp[i][j],dp[i][j-w[i]]+v[i]);
	// 	}
	// }
	// cout<<dp[n][W];
	// cout<<dp(0,W);
}
 
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	 
	// freopen("error.txt", "w", stderr);
	 
	int t=1;
	 
	while(t--)
	{
		solve();
	}

	cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
	 
	return 0;
}

Measured memory_bytes: 5352
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif
// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<pii,int> ppii;
typedef pair<int,pii> pipi;
typedef pair<ll,ll> pll;
typedef pair<pll,ll> ppll;
typedef pair<ll,pll> plpl;
#define rep(i,n) for(int i=0; i<((int)n); i++)
#define REP(i,n) for(int i=0; i<=((int)n); i++)
#define srep(i,a,n) for(int i=a; i<((int)n); i++)
#define SREP(i,a,n) for(int i=a; i<=((int)n); i++)
#define rrep(i,n) for(int i=n-1; i>=0; i--)
#define RREP(i,n) for(int i=n; i>=0; i--)
#define INF 1000000000
const int mod = INF+7;

int main(){
  int H,W;
  cin >> H >> W;
  char **a=(char **)malloc(sizeof(char *)*H);
  rep(i,H){
    a[i]=(char *)malloc(sizeof(char)*W);
  }
  rep(i,H){
    rep(j,W){
      cin >> a[i][j];
    }
  }

  int **dp=(int **)malloc(sizeof(int *)*H);
  rep(i,H){
    dp[i]=(int *)calloc(W,sizeof(int));
  }

  dp[0][0]=1;
  rep(i,H){
    rep(j,W){
      if(a[i][j]=='#'){
        dp[i][j]=0;
      }
      else{
        if(i>=1){
          dp[i][j]=((long)dp[i][j]+dp[i-1][j])%mod;
        }
        if(j>=1){
          dp[i][j]=((long)dp[i][j]+dp[i][j-1])%mod;
        }
      }
    }
  }

  printf("%d\n", dp[H-1][W-1]);
}


Measured memory_bytes: 5120
#include"bits/stdc++.h"
using namespace std;

int CEIL(int a, int b) {return (a - 1) / b + 1;}

int main(){

	int A, B, C;
	cin >> A >> B >> C;
	int weekly = 7 * A + B;
	int answer = 0;

	int week = C / weekly;
	answer = week * 7;
	C -= week * weekly;

	for(int day = 0; day < 7 && C > 0; day++){
		C -= A;
		answer++;
	}

	cout << answer << endl;

	return 0;
}


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

#pragma region Macro
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define SORT(v) sort(v.begin(), v.end())
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define vvi vector<vector<int>>
#define chmax(x,y) (x = max(x,y))
#define chmin(x,y) (x = min(x,y))

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

void solve(){
	#define int ll
	// ここに処理を記述
	// コンパイル時はエイリアス「gpp」--> c++17でコンパイル
	
	int n;
	cin >> n;

	vvi d(n,vi(2,0));
	rep(i,n){
		cin >> d[i][0] >> d[i][1];
	}

	bool zoro = false;
	FOR(i,2,n){
		if(zoro) continue;
		if(d[i-2][0] != d[i-2][1]){
			continue;
		}
		if(d[i-1][0] != d[i-1][1]){
			continue;
		}
		if(d[i][0] != d[i][1]){
			continue;
		}
		zoro = true;
	}

	if(zoro) cout << "Yes" << endl;
	else cout << "No" << endl;

}

signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	
	solve();
	return 0;
}

Measured memory_bytes: 3676
n,m,x = list(map(int, input().split()))

import sys
sys.setrecursionlimit(10**6)
readline = sys.stdin.readline
ca = [[int(i) for i in readline().split()] for _ in range(n)]

from itertools import combinations
import numpy as np

lc = [i for i in range(n)]

ans = 1001001001

for nc in range(1,n+1):
    lc_sub = list(combinations(lc,nc))
    for lc_sub2 in lc_sub:
        tmp_price = 0
        tmp_und = np.array([0]*m)
        for c in lc_sub2:
            tmp_price += ca[c][0]
            tmp_und += np.array(ca[c][1:])
        if all([und >= x for und in tmp_und]):
            ans = min(ans, tmp_price)

if ans == 1001001001:
    print(-1)
else:
    print(ans)

Measured memory_bytes: 27828
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,o,n) for(long long i = o;i<n;i++)
#define oneforall ios::sync_with_stdio(false);cin.tie(0);
#define all(v) (v).begin(),(v).end()
#define ini(...) int __VA_ARGS__; in(__VA_ARGS__)
#define inl(...) long long __VA_ARGS__; in(__VA_ARGS__)
#define ins(...) string __VA_ARGS__; in(__VA_ARGS__)
#define int long long 
const long long INF=1e18;
void in(){} template <typename T,class... U> void in(T &t,U &...u){ cin >> t; in(u...);}
void out(){cout << "\n";} template <typename T,class... U> void out(const T &t,const U &...u){ cout << t; if(sizeof...(u)) cout << " "; out(u...);}
typedef vector<int> vi;
typedef vector<long long> vl;
typedef long long ll;
typedef vector<pair<long, long > > vpll;
typedef vector<pair<int, int > > vpii;
#define FORR(x,arr) for(auto& x:arr)

int32_t main() {
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall
	oneforall 
	oneforall

	ini(n);
	ini(n1);
	int tmp = 0;
	FOR(i,1,n+1){
		int x = n/i;
		int x1 = n%i;
		//out(max(0LL,i-n1));
		tmp+=x*(max(0LL,i-n1));
		tmp+=max(0LL,x1-n1+1LL);
	}
	if(n1 == 0)tmp-=n;
	out(tmp);














	return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <stdlib.h>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <climits>
#include <iomanip>
#include <deque>
#include <limits>
#include <map>
#include <set>
#include <functional>

using namespace std;

int main()
{
  int64_t X;
  int64_t N;
  vector<int64_t> p;

  cin >> X >> N;
  p.resize(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
  }

  sort(p.begin(), p.end());

  int64_t ans = 0;

  for (int i = 0; i <= 101; i++) {
    bool exist_flag = false;
    for (auto &&p_i : p) {
      if (p_i == i) {
        exist_flag = true;
        break;
      }
    }
    if (exist_flag == false) {
      if (abs(X - i) < abs(X - ans)) {
        ans = i;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

int main(){
    int n,c,k;
    cin>>n>>c>>k;
    vector<int> a(n);
    rep(i,n) cin>>a[i];
    sort(a.begin(),a.end());
    
    int cnt = 1, s = 0;
    for(int i=1;i<n;i++){
        if(a[i]>a[s]+k || i==s+c){
            cnt++;
            s=i;
        }
    }
    cout << cnt << endl;
    return 0;
}


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

#define int long long
#define rep(i, a, n) for (int i = a; i < n; i++)
#define pb push_back
#define eb emplace_back
#define dump(x) cout << #x << " = " << (x) << endl
#define chk() cout << "now" << endl;
#define ALL(x) (x).begin(), (x).end()
#define SORT(c) sort((c).begin(), (c).end())
#define SORTG(c) sort(ALL(c), greater<int>());
#define fi first
#define se second
int INF = 1e9 + 7;

typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vector<int>> mat;

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

string s;

void solve() {
  cin >> s;

  int n = s.size();
  int ans = 0, l = 1;
  rep(i, 1, n) {
    if (s[i] == s[i - 1]) {
      l++;
    } else {
      if (l == 1) {
        ans++;
      } else {
        int a = l / 3;
        int b = l - a * 3;
        if (b == 0) {
          ans += a * 2;
        } else if (b == 1) {
          int c = a * 2 + 1;
          ans += c;
        } else {
          int d = a * 2 + 1;
          ans += d;
          s[i] = '1';
        }
        l = 1;
      }
    }
  }
  if (l > 1) {
    int a = l / 3;
    int b = l - a * 3;
    if (b == 0) {
      ans += a * 2;
    } else if (b == 1) {
      int c = a * 2 + 1;
      ans += c;
    } else {
      int d = a * 2 + 1;
      ans += d;
    }
  } else {
    ans++;
  }

  cout << ans << endl;
}

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

  // cout << fixed << setprecision(10);

  solve();

  return 0;
}


Measured memory_bytes: 720
#![allow(dead_code, unused_imports, deprecated)]
use std::cmp::{max, min, Reverse};
use std::collections::*;
use maplit::*;
use num::Integer;
use proconio::input;
use proconio::marker::*;
use proconio::fastout;
const INF: usize = 1_000_000_007;

#[fastout]
fn main() {
  input! {
    d : usize,
    c : [isize; 26],
  };
  input! {
    s : [[isize; 26]; d],
  };

  let mut res = vec![];
  for i in (0..d).rev() {
    let mut v = vec![];

    let mut gd = 0;
    for j in 0..26 {
      v.push(s[i][j] + i as isize * (d as isize - i as isize) * c[j]);
      if v[j] > v[gd] {
        gd = j;
      }
    }
    res.push(gd);
  }
  
  for i in (0..d).rev() {
    println!("{}", res[i] + 1);
  }
}

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

#define M1 1000000007
#define M2 1000000009
#define ll long long 
#define ull unsigned long long
#define ui unsigned int
#define us unsigned short
#define INF 1001001001
#define PI 3.1415926535897932384626
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define f0(i, n) for (int i = 0; i < (int)(n); ++i)
#define f1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define fc0(i,l,r) for(int i = (int)(l); i<(int)(r); ++i)
#define fc1(i, l, r) for (int i = (int)(l); i <= (int)(r); ++i)
#define fr0(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define all(x) (x).begin(), (x).end()
#define sz(a) int((a).size())
#define tr(c,i) for(typeof((c)).begin() i = (c).begin(); i != (c).end(); i++)
typedef vector<int> vi; 
typedef vector<vi> vvi; 
typedef pair<int,int> ii; 
 
void init()
{
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
      freopen("error.txt", "w", stderr);
    #endif

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;
}
 
signed main()
{
    init();

    int a,b,d;
    cin>>a>>b>>d;
    if(a%d==0){cout<<(b/d)-(a/d)+1;}
    else{cout<<(b/d)-(a/d);}
    cerr<<"time taken : "<<(float)clock()/CLOCKS_PER_SEC<<" secs"<<endl;
    return 0;
}

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

# define rep(i, n) for(int(i)=0;(i)<(n);(i)++)
# define reps(i, n) for(int(i)=1;(i)<=(n);(i)++)
# define rrep(i, n) for(int i=((int)(n)); i>0; --i)
# define rreps(i, n) for(int i=((int)(n)); i>=0; --i)
# define ALL(v) v.begin(), v.end()
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return true; } return false; }
template<typename T> void dump(T e){std::cout << e << std::endl;}
template<typename T> void dump(const std::vector<T>& v){for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void dump(const std::vector<std::vector<T> >& vv){ for(const auto& v : vv){ dump(v); } }
typedef long long ll;

int gcd(int a, int b) {
  if (a%b==0) return(b);
  else return(gcd(b,a%b));
}

int lcm(int a, int b){
    return a * b / gcd(a, b);
}


int main() {
  int N,A,B; cin >> N >> A >> B;
  int between = B-A-1;
  if(between%2==0) dump("Borys");
  else dump("Alice");
}

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

int main() {
	int h, w, i, j;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0) {
			break;
		}
		else {
			for (i = 1; i <= h; i++) {
				for (j = 1; j <= w; j++) {
					if (i == 1 || i==h) {
						cout << "#";
					}
					else {
						if (j == 1 || j == w) {
							cout << "#";
						}
						else{
							cout << ".";
						}

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


Measured memory_bytes: 3112
#include <iostream>
using namespace std;
int main(){
        int a,b;
        cin >> a >> b;
        if(a>b)
                cout << "a > b" << endl;
        else if(a<b)
                cout << "a < b" << endl;
        else
                cout << "a == b" << endl;
        return 0;
}

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

using namespace std;

int main() {
  string s, t;
  cin >> s >> t;
  int ans = 0;
  for (int i = 0; i < 3; ++i) {
    if (s[i] == t[i]) ans++;
  }
  cout << ans << endl;
  return 0;
}



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

int N, a[100100], dp[100100];

int f(int n) {
	if (n==1) return 0;
	if (n==2) return abs(a[2] - a[1]);
	if (dp[n] != -1) return dp[n];
	dp[n] = min(
				f(n-1) + abs(a[n] - a[n-1]),
				f(n-2) + abs(a[n] - a[n-2])
				);
	return dp[n];
}

int main() {
	cin >> N;
	for(int i=1; i<=N; i++)
		cin >> a[i];
	memset(dp, -1, sizeof(dp));
	cout << f(N) << endl;
	return 0;
}

Measured memory_bytes: 2560
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int s, g;
		int sh, sm;
		int gh, gm;
		int sTime, gTime;
		int money;
		int map[][] = {{0, 300, 500, 600, 700, 1350, 1650},
				{6, 0, 350, 450, 600, 1150, 1500},
				{13, 7, 0, 250, 400, 1000, 1350},
				{18, 12, 5, 0, 250, 850, 1300},
				{23, 17, 10, 5, 0, 600, 1150},
				{43, 37, 30, 25, 20, 0, 500},
				{58, 52, 45, 40, 35, 15, 0}};

		while (true) {
			s = sc.nextInt();
			if (s == 0) {
				break;
			}
			sh = sc.nextInt();
			sm = sc.nextInt();
			g = sc.nextInt();
			gh = sc.nextInt();
			gm = sc.nextInt();
			int swap = s + g;
			s = Math.min(s, g);
			g = swap - s;
			sTime = sh * 60 + sm;
			gTime = gh * 60 + gm;
			money = map[s - 1][g - 1];
			if (map[g - 1][s - 1] <= 40 && ((17 * 60 + 30 <= sTime && sTime <= 19 * 60 + 30) || (17 * 60 + 30 <= gTime && gTime <= 19 * 60 + 30))) {
				money /= 2;
				if (money % 50 != 0) {
					money = money - (money % 50) + 50;
				}
			}
			System.out.println(money);
		}
	}
}

Measured memory_bytes: 12000
/*********************************************JMD**********************************************/
//                                  |\  |     | |   |   /\                                   //
    //                              | \ |     | |---|  /--\                              //
        //                          |  \| |___| |   | /    \1999                     //
/*******************************************************************************************/
#include <bits/stdc++.h>
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define mem(x,val) memset(x,val,sizeof(x))
#define forr(i,a,b) for(ll i=a;i<b;i++)
#define f(i,n) forr(i,0,n)
#define sz(x) ll((x).size())
#define all(x) ((x).begin(),(x).end())
#define asc(x) ((int)(x))
#define precision(x) cout<<fixed<<setprecision((x));

const ll mod=1e9 + 7;

/*******************************************************************************************/
vector<unordered_set<ll> > g;
vector<ll> vis;
ll sz;

void dfs(ll x)
{
    vis[x]=1;
    sz++;
    for(auto y:g[x])
    {
        if(!vis[y]) dfs(y);
    }
}

void solve()
{
    ll n,m;
    cin>>n>>m;

    g.resize(n);
    vis.resize(n);

    while(m--)
    {
        ll x,y;
        cin>>x>>y;
        x--,y--;
        g[x].insert(y);
        g[y].insert(x);
    }

    ll ans=1;

    f(i,n)
    {
        if(!vis[i])
        {
            sz=0;
            dfs(i);
            ans=max(sz,ans);
        }
    }
    cout<<ans<<"\n";

    return;
}

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

    ll t=1;
    clock_t launch=clock();

    while(t--)
    {
        solve();
    }

    clog<<((long double)(clock()-launch)/CLOCKS_PER_SEC)<<"\n";
}


Measured memory_bytes: 37480
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
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;}

int main() {
    int a,b,c;
    cin >> a >> b >> c;
    int m = max(max(a,b),c);
    if(3*m%2==(a+b+c)%2) cout << (3*m-(a+b+c))/2 << endl;
    else cout << (3*(m+1)-(a+b+c))/2 << endl;
}

Measured memory_bytes: 256
from sys import stdin
import bisect
def main():
    #入力
    readline=stdin.readline
    n=int(readline())
    a=[int(readline()) for _ in range(n)]

    li=[]
    for i in range(n):
        if i==0:
            li.append(a[i])
        else:
            l=-1
            r=len(li)
            while l<r-1:
                m=(l+r)//2
                if li[m]>=a[i]:
                    l=m
                else:
                    r=m
            if r==len(li):
                li.append(a[i])
            else:
                li[r]=a[i]

    print(len(li))
    
if __name__=="__main__":
    main()

Measured memory_bytes: 7836
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
using namespace std;
typedef long long LL;

char a[200005];
int f[200005][30];
LL ans;
int main()
{
	ans = 0;
	scanf("%s", a + 1);
	int len = strlen(a + 1);
	for(int i = 1; i <= len; i++)
	{
		int p = a[i] - 'a';
		for(int j = 0; j <= 26; j++) f[i][j] = f[i - 1][j];
		f[i][p] = f[i - 1][p] + 1;
	}
	for(int i = 1; i <= len; i++)
	{
		int p = a[i] - 'a';
		ans = ans + i - f[i][p];
	}
	if(ans < 0) ans = 0;
	ans++;
	printf("%lld\n", ans);
	return 0;
}

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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

int f(int x)
{
    int res = 0;
    while (x % 2 == 0)
    {
        x /= 2;
        ++res;
    }
    return res;
}

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

void Main()
{
    int n = in(), m = in();
    vint a = in(n);

    rep(i, n)
    {
        a[i] /= 2;
    }

    int t = f(a[0]);
    rep(i, n)
    {
        if (f(a[i]) != t)
        {
            cout << 0 << endl;
            return;
        }
        // a[i] /= 2 ** t
        a[i] >>= t;
    }
    m >>= t;

    ll l = 1;
    rep(i, n)
    {
        l = lcm(l, a[i]);
        if (l > m)
        {
            cout << 0 << endl;
            return;
        }
    }

    m /= l;
    int ans = (m + 1) / 2;
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

char s[100][11];
int p[100], num[100];

int compare(const void *a, const void *b)
{
    int n = strcmp(s[*(int *)a], s[*(int *)b]);
    if (n != 0)
        return n;
    else
        return p[*(int *)b] - p[*(int *)a];
}

int main(void)
{
    int ans = 0;

    int n;
    scanf("%d", &n);

    rep(i, n)
    {
        scanf("%s%d", s[i], &p[i]);
        num[i] = i;
    }

    qsort(num, n, sizeof(int), compare);

    rep(i, n)
        printf("%d\n", (num[i] + 1));

    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<string>
#include<sstream>
#include<cmath>
#include<numeric>
#include<map>
#include<stack>
#include<queue>
#include<list>
#include<set>
using namespace std;
int mod = 1e9 + 7;
template <class T>
void inputV(vector<T> &x, int n){
  for(int i=0; i<n; i++) cin >> x[i];
}

int main() {

  int x, a, b;
  cin >> x >> a >> b;
  x -= a;
  cout << x % b << endl;

  return 0;
}




//


Measured memory_bytes: 256
N, K = gets.chop.split(" ").map(&:to_i)
ary = gets.chop.split(" ")
n = N
loop do
  flg = true
  n.to_s.split("").each do |i|
    if ary.include?(i)
      flg = false
      break
    end
  end
  if flg
    puts n
    exit
  else
    n += 1
  end
end

Measured memory_bytes: 2044
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#define GYOU_MAX 256


int  isInt(double a) {

	if ((int)a == a) {
		return 1;
	}
	else {
		return 0;
	}
}



int main(void) {
	int N, Y;
	scanf("%d%d", &N, &Y);

	int count = 0;
	int flag = 0;
	double z;
	for (int i = 0;;i++) {
		if (10000 * i > Y) {
			break;
		}
		for (int j = 0;; j++) {
			if (10000 * i + 5000 * j > Y) {
				break;
			}
			z = (double)(Y - 10000 * i - 5000 * j) / 1000;
			if (isInt(z) == 1 && z >= 0) {
				count=i+j+(int)z;
				if (count == N) {
					flag = 1;
					printf("%d %d %d\n", i, j, (int)z);
					return 0;
				}
				count = 0;
			}
		}
	}
	if (flag == 0) {
		printf("%d %d %d\n", -1, -1, -1);
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
ll factorial(int i) {       //階乗
    if (i == 0) return 1;
    return (factorial(i - 1)) * i;
}

int main() {
    int n, a, b;
    cin >> n >> a >> b;
    string s;
    cin >> s;
    int b_count = 0;
    // int c_count = 0;
    int join = 0;
    rep(i, s.size()) {
        if(s[i] == 'c') {
            cout << "No" << endl;
            // c_count++;
        }
        else if(s[i] == 'a' && join < a + b) {
            cout << "Yes" << endl;
            join++;
        }
        else if(s[i] == 'b' && join < a + b && b_count < b) {
            cout << "Yes" << endl;
            b_count++;
            join++;
        }
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 3696
def resolve():
    def is_rotatable(S):
        for i in range(len(S)//2):
            if S[i] != S[-1-i]:
                return False
        return True
    S = input()
    N = len(S)
    if is_rotatable(S) and is_rotatable(S[:N//2]) and is_rotatable(S[(N//2)+1:]):
        print("Yes")
    else:
        print("No")


if '__main__' == __name__:
    resolve()

Measured memory_bytes: 61704
from collections import deque
s=deque(list(input()))
n=int(input())
count=0


for i in range(n) :
    x=input()
    if x[0]=="1" :
        count+=1
        count%=2

    elif x[2]=="1" :
        if count%2==0 :
            s.appendleft(x[4])
        else :
            s.append(x[4])
    else :
        if count%2==0 :
            s.append(x[4])
        else :
            s.appendleft(x[4])


if count%2==1 :
    s.reverse()

print("".join(s))

Measured memory_bytes: 14368
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, n) for(int i=0; i<n; i++)
#define REPR(i, n) for(int i=n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=m; i<n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ll(x.size()) 
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 2e9;
const ll LINF = (1LL<<60);

const int mod = 1000000007;
//const int mod = 998244353;
struct mint {
  ll x;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, const mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n; cin >> n;
  vector<int> a(n);
  REP(i,n){ 
    cin >> a[i];
  }

  mint ans = 0;
  mint tmp = a.back();
  REPR(i,n-1){
    ans += tmp * mint(a[i]);
    tmp += mint(a[i]); 
  }
  cout << ans << '\n';

  return 0;
}


Measured memory_bytes: 3976
#include <bits/stdc++.h>
using namespace std;
constexpr int IINF = INT_MAX;

int main() {
    int n, r=0, ans = IINF;
    bool ok = false;
    cin >> n;
    vector<string> s(n);
    for(int i=0;i<n;i++) cin >> s[i];
    for(int j=0;j<n;j++){
        int cnt = 0;
        for(int i=0;i<n;i++){
            if(s[i][j] == '#') cnt++;
        }
        if(cnt == n) r++;
        ok |= cnt > 0;
    }
    if(!ok){
        cout << -1 << endl;
        return 0;
    }
    for(int j=0;j<n;j++){
        int f = 1;
        for(int i=0;i<n;i++){
            if(s[i][j] == '#') f = 0;
        }
        int cnt = 0;
        for(int i=0;i<n;i++){
            if(s[j][i] == '.') cnt++;
        }
        ans = min(ans, cnt+n-r+f);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    
    int result_min = 1000000000;
    
    for(int i = 0; i < N; i++)
    {
        int count = 0;
        int buf;
        cin >> buf;
        
        while(buf % 2 == 0)
        {
            buf /= 2;
            count++;
        }
        result_min = min(result_min,count);
    }
    
    cout << result_min << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;

typedef pair<int, int> P;
typedef pair<long long, long long> LLP;

int main() {
    int N;
    string S;
    cin >> N >> S;
    if (N % 2 == 1) {
        cout << "No" << endl;
        return 0;
    }

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

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

int main() {
  char c;
  cin >> c;
  if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') cout << "vowel" << endl;
  else cout << "consonant" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <unordered_map>
#include <cmath>
#include <algorithm>

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  string s;
  cin >> s;
  cout << (s[2] == s[3] && s[4] == s[5] ? "Yes" : "No") << endl;
  return 0;
}


Measured memory_bytes: 256
# Begin Header {{{
from math import gcd
from collections import Counter, deque, defaultdict
from heapq import heappush, heappop, heappushpop, heapify, heapreplace, merge
from bisect import bisect_left, bisect_right, bisect, insort_left, insort_right, insort
from itertools import accumulate, product, permutations, combinations, combinations_with_replacement
# }}} End Header
# _________コーディングはここから！！___________
# ... 最小側の制約も確認した？
# ... オーバーフローしない？
s = input()
t = input()
ans = 0
for i in range(len(s)):
    if s[i] != t[i]: ans+=1
print(ans)


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

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

    ll minv = 10000000;
    ll maxv = -10000000;
    ll sum = 0;
    
    rep(i,n) {
        minv = min(minv, a[i]);
        maxv = max(maxv, a[i]);
        sum += a[i];
    }

    cout << minv << ' ' << maxv << ' ' << sum << endl;
}


Measured memory_bytes: 3180
#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>;
 
 
int main() {
    int n,d;
    cin >> n >> d;
    vector<vector<int>> x(n,vector<int>(d));
    rep(i,n)rep(j,d) cin >> x.at(i).at(j);
    int count=0;
    rep(i,n-1){
        for(int j=i+1;j<n;j++){
            int dis_2=0;
            rep(k,d){
                dis_2+=(x.at(i).at(k)-x.at(j).at(k))*(x.at(i).at(k)-x.at(j).at(k));
            }
            double dis=sqrt(dis_2);
            int intdis=dis;
            if(intdis==dis) count++;

        }
    }
    cout << count << endl;

}

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

using namespace std;
long long sume[100005];
int n,sum,i;
long long val,j;
struct wow
{
    int x,y;
}v[105];
int main()
{
    cin>>n>>val;
    for (i=1;i<=n;i++)
    {
        cin>>v[i].x>>v[i].y;
        sum+=v[i].y;
    }
    for (i=1;i<=sum;i++)
    {
        sume[i]=1e18;
    }
    for (i=1;i<=n;i++)
    {
        for (j=sum;j>=v[i].y;j--)
        {
            if (sume[j-v[i].y]!=1e18)
            {
                sume[j]=min(sume[j],sume[j-v[i].y]+v[i].x);
            }
        }
    }
    for (i=sum;i>=1;i--)
    {
        if (sume[i]<=val)
        {
            cout<<i;
            return 0;
        }
    }
    return 0;
}


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

int n,A,B,ok1,ok2;

int main()
{
	scanf("%d",&n);
	A=n/100,B=n%100;
	if(1<=B&&B<=12) ok1=1;
	if(1<=A&&A<=12) ok2=1;
	if(ok1&&ok2) printf("AMBIGUOUS\n");
	else if(ok1&&!ok2) printf("YYMM\n");
	else if(!ok1&&ok2) printf("MMYY\n");
	else printf("NA\n");
	return 0;
}

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

#define DEBUG

#ifndef LOCAL
#undef DEBUG
#endif

#ifdef DEBUG
#define debug(...) fprintf(stderr,__VA_ARGS__)
#else
#define debug(...) ;
#endif

#define maxn 55
typedef long long ll;
const ll mod=1000000007;
string s1,s2;
int n;

int main()
{
	cin>>n>>s1>>s2;
	ll ans=1;
	int p=0;
	for(int i=0;i<n;i++)
	{
		if (i+1<n && s1[i]==s1[i+1])
		{
			if (p==0)
			{
				ans=ans*6%mod;
			}
			else if (p==1)
			{
				ans=ans*3%mod;
			}
			else if (p==2)
			{
				ans=ans*2%mod;
			}
			p=1;
			i++;
		}
		else
		{
			if (p==0)
			{
				ans=ans*3%mod;
			}
			else if (p==1)
			{
				ans=ans*1%mod;
			}
			else if (p==2)
			{
				ans=ans*2%mod;
			}
			p=2;
		}
	}
	ans=(ans%mod+mod)%mod;
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
  
int main(void)
{
   int a, b, c;
   scanf("%d %d %d", &a, &b, &c);
   if(a < b){
     if(b < c){
       printf("Yes\n");
     }else{
       printf("No\n");
     }
   }else{
     printf("No\n");
   }return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <map>
#include <stack>
#include <numeric> //lcm


#define ERROR() cout << "ERROR!!" << endl; return 0;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = n-1; i >= 0; --i)
#define rep1(i,n) for(int i = 1; i <= (n); ++i)

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1000000000; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

inline bool maxch(int& a, int b) { if (a < b) { a = b; return true; } else return false; }
inline bool minch(int& a, int b) { if (a > b) { a = b; return true; } else return false; }

int main() {
  ll n,m;
	cin >> n >> m;

	if (n == 1 || m == 1) {
		cout << 1 << endl;
	}
	else
	cout << (n*m+1) / 2 << endl;
}


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

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

  vector<int> mochi(N);
  for(int i = 0; i < N; i++){
    cin >> mochi.at(i);
  }
  
  sort(mochi.begin(), mochi.end());

  int sum = 1;
  for(int i = 0; i < N - 1; i++){
    if(mochi.at(i) < mochi.at(i + 1)){
      sum++;
    }
  }
  
  cout << sum << endl;
}

Measured memory_bytes: 3600