akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

void no() {
    cout<<"NO"<<endl;
    exit(0);
}

const int N = 1e5+7;

vector<int> adj[N];
int a[N];
long long up[N];
long long leafsum = 0;

void dfs(int u, int p) {
    if (adj[u].size() == 1) {
        up[u] = a[u];
        return ;
    }

    long long mx = 0;
    up[u] = 2*a[u];
    for (int v: adj[u]) {
        if (v == p) continue;
        dfs(v, u);
        up[u] -= up[v];
        mx = max(mx, up[v]);
    }

    if (up[u] < 0)  no();
    mx = max(mx, up[u]);
    if (mx > a[u])  no();
}

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

    int n;
    cin>>n;

    for (int i=1; i<=n; i++)    cin>>a[i];

    for (int i=1; i<n; i++) {
        int u, v;
        cin>>u>>v;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }

    if (n == 2) {
        if (a[1] == a[2])   cout<<"YES\n";
        else                cout<<"NO\n";
        return 0;
    }

    int root = 0;
    for (int i=1; i<=n; i++)
        if (adj[i].size() > 1) {
            if (!root)  root = i;
        }

    dfs(root, 0);
    if (up[root])   no();
    cout<<"YES\n";
}


Measured memory_bytes: 16772
#include <bits/stdc++.h>
#define pb push_back
#define LL long long
#define x first
#define y second
#define pii pair<int,int>
#define mp make_pair
#define MEM(x) memset(x,0,sizeof(x))
#define pi acos(-1)
using namespace std;	
int main(){
	int n;
	scanf("%d",&n);
	char c[15];
	int ea=0,sb=0;
	int ans=0;
	int ok=0;
	for(int i = 0;i<n;i++){
		scanf("%s",c);
		for(int j =0;c[j]!=0;j++){
			if(c[j]=='A'&&c[j+1]=='B')
				ans++;
		}
		if(c[0]=='B'){
			ea++;
		}
		if(c[strlen(c)-1]=='A'){
			sb++;
		}
		int x=c[0]=='B',y=c[strlen(c)-1]=='A';
		if(x^y){
			ok=1;
		}
	}
	ans+=min(ea,sb);
	if(!ok){
		if(ea!=0&&sb!=0)
			ans--;
	}
	printf("%d\n",ans);
	return 0;
}
/*




*/

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int T[105][105];
int main()
{
    int t;
    cin>>t;
    int m=t;
    while(t--)
    {
        int ori;
        cin>>ori;
        int n;
        cin>>n;
        while(n--)
        {
            int x;
            cin>>x;
            T[ori][x]=1;
        }
    }
    for(int i=1;i<=m;i++)
    {
        cout<<T[i][1];
        for(int j=2;j<=m;j++)
            cout<<" "<<T[i][j];
        cout<<endl;
    }
    return 0;
}



Measured memory_bytes: 3124
#include <iostream>
#include <iomanip>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <cstdio>
#include <utility>
#include <string>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <numeric>

using namespace std;

typedef uint64_t u64;
typedef int64_t s64;
typedef uint32_t u32;
typedef int32_t s32;
typedef vector<s32> vs32;
typedef vector<u32> vu32;
typedef vector<s64> vs64;
typedef vector<u64> vu64;

const double PI=3.14159265358979323846;

#define MAX(x, y) ((x) < (y) ? (y) : (x))
#define MIN(x, y) ((x) > (y) ? (y) : (x))

#define rep(i, N) for(int i = 0; i < N; ++i)

#define CEIL(x, y) (((x) + (y) - 1) / (y))
#define MOD 1000000007ULL

#define IN(l, r, x) ((l) <= (x) && (x) < (r))

string s;

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

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

    s64 r, g, b;
    r = g = b = 0;
    rep (i, n)
    {
        if (s[i] == 'R') ++r;
        else if (s[i] == 'G') ++g;
        else if (s[i] == 'B') ++b;
    }

    s64 ans = r * g * b;
    rep (i, n)
    {
        for (int k = i + 1; k < n; ++k)
        {
            int j = (k + i) / 2;
            if (!(s[i] == s[j] || s[j] == s[k] || s[k] == s[i]) && 2 * j == i + k)
            {
                --ans;
            }
        }
    }

    cout << ans << "\n";
    return 0;
}



Measured memory_bytes: 3640
W, H, x, y, r = map(int, input().split())

if x - r < 0:   # 左
    print('No')
elif x + r > W: # 右
    print('No')
elif y - r < 0: # 下
    print('No')
elif y + r > H: # 上
    print('No')
else:
    print('Yes')



Measured memory_bytes: 5596
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <utility>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <queue>
#include <map>
using namespace std;
typedef long long ll;
const int INF = 1<<30; 
const int MOD = 1e9 + 7;
const int dy[] = {1, 0, -1, 0};
const int dx[] = {0, 1, 0, -1};
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, h, w;
    cin >> n >> h >> w;
    int x[n + 1];
    for(int i = 0; i < n; i++) cin >> x[i];
    int e = 0;
    for(int i = 0; i < n; i += 2)
    {
        int tmp = x[i] + x[i + 1];
        if(tmp > w) tmp = 2 * w - tmp;
        e += tmp;
    }
    cout << e * h << endl;
    return 0;
}




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

int main(){
    long long a;
    cin>>a;
    vector<int>v(a);
    vector<int>v1(a+1,1e9);
    for(int i=0;i<a;i++){
        cin>>v[i];
    }
    v1[0]=0;
    v.push_back(1e9);
    for(int i=0;i<a-1;i++){
        v1[i+1]=min(v1[i+1],v1[i]+abs(v[i+1]-v[i]));
        v1[i+2]=min(v1[i+2],v1[i]+abs(v[i+2]-v[i]));
    }
    cout<<v1[a-1];
}

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

int main(){
    int a, b, k;
    cin >> a >> b >> k;

    for (int tsumugi = a; tsumugi <= b; tsumugi++){
        if (tsumugi < a + k)
            cout << tsumugi << endl;
        else if (tsumugi > b - k)
            cout << tsumugi << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define ld          double
#define pb          push_back
#define mp          make_pair
#define ff          first
#define se          second
#define endl        '\n'
#define fd(n)       fixed<<setprecision(n)
#define MAX         1000000000000000000
#define MAXN        200005
#define LOG         20
#define mod         1000000007
using namespace std;
 
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n,w,i,j;
    cin>>n>>w;
    ll weight[n],value[n];
    for(i=0;i<n;i++){
        cin>>weight[i]>>value[i];
    }
    ll dp[w+1];
    memset(dp,0,sizeof(dp));
    for(i=0;i<n;i++){
        for(j=w;j>=weight[i];j--){
            dp[j]=max(dp[j],dp[j-weight[i]]+value[i]);
        }
    }
    cout<<dp[w];
}

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


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


void no()
{
  std::cout << "No" << std::endl;

  exit(0);
}


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

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

  int N;

  std::cin >> N;

  std::vector<std::string> a(N);

  std::set<std::string> set;

  for (int i = 0; i < N; i ++) {
    std::cin >> a[i];

    if (set.count(a[i]))
      no();

    set.insert(a[i]);
  }

  for (int i = 0; i < N - 1; i ++)
    if (a[i].back() != a[i + 1].front())
      no();

  std::cout << "Yes" << std::endl;

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
#include<complex>
using namespace std;

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
typedef pair<int, int>P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef pair<ll, ll> LP;
typedef double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef vector<vector<ll>> mat;
typedef vector<int> vec;

void solve() {
	int n; cin >> n;
	int ans = 1;
	for (int i = 1; i <= 40; i++) {
		for (int j = 2; j <= 9; j++) {
			ll s = i;
			rep(k, j - 1)s *= i;
			if (s <= n)ans = max(ans,(int)s);
		}
	}
	cout << ans << endl;
}

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


Measured memory_bytes: 256
#![allow(dead_code)]
#![allow(unused_must_use)]

fn solve(src: &str) -> String {
    use std::fmt::Write;
    let mut buf = String::new();
    let mut sc = Scanner::from_str(&src);

    let n : usize = sc.read();
    let a : Vec<usize> = sc.vec(n);

    let mut a: Vec<_> = a.iter().enumerate().collect();
    a.sort_by(|&(_, a),&(_,b)| a.cmp(b));
    for &(i, _) in a.iter() {
        write!(&mut buf, "{} ", i+1);
    }

    buf
}

#[test]
fn test() {
    assert_eq!(solve(r"3
2 3 1"),r"3 1 2 ");
assert_eq!(solve(r"5
1 2 3 4 5"),r"1 2 3 4 5 ");
assert_eq!(solve(r"8
8 2 7 3 4 5 6 1"),r"8 2 4 5 6 7 3 1 ");
}

fn main() {
    let mut buf = String::new();
    use std::io::Read;
    std::io::stdin().read_to_string(&mut buf);
    use std::io::Write;
    std::io::stdout().write_all(solve(&buf).as_bytes());
}

struct Scanner<I>{
    src: I
}

impl<'a> Scanner<std::str::SplitWhitespace<'a>> {
    fn from_str(src: &'a str) -> Self {
        Scanner { src: src.split_whitespace() }
    }
}

impl<'a, I> Scanner<I> where I: std::iter::Iterator<Item = &'a str>{
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.src.next().unwrap().parse().ok().expect("Parse error")
    }
    fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    fn chars(&mut self) -> Vec<char> {
        self.src.next().unwrap().chars().collect()
    }
}

Measured memory_bytes: 8664
#include <iostream>
#include <algorithm>
#include <vector>
#include <complex>
using namespace std;

int main(){
  int n;
  complex<int> c;
  vector< complex<int> > v;
  vector<int> srt;

  while( cin>>n ){
    if( v.size()==0 ){
      c.real() = n;
      c.imag() = 1;
      v.push_back( c );
      //      cout << "push_back : "<< n << endl;
    }else{
      for( unsigned int i=0;i<v.size();i++ ){
	if( v[i].real()==n ){
	  //	  cout << "coindance : "<<n << endl;
	  v[i].imag()++;
	  break;
	}
	if( i==v.size()-1 ){
	  c.real() = n; c.imag()=1;
	  v.push_back( c );
	  //	  cout << "push_back : "<< n << endl;
	  break;
	}
      }
    }
  }

  int mx = -1;
  for( unsigned int i=0;i<v.size();i++ ){
    //    cout << v[i].real()<<" "<<v[i].imag() << endl;
    mx = max( v[i].imag(), mx );
  }

  srt.clear();
  for( unsigned int i=0;i<v.size();i++ ){
    if( v[i].imag()==mx )
      srt.push_back( v[i].real() );
  }

  sort( srt.begin(), srt.end() );
  for( unsigned int i=0;i<srt.size();i++ )
    cout << srt[i] << endl;

  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <sstream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <list>
#include <numeric>
#include <stack>
#include <iomanip>
#include <random>
#include <complex>
#include <functional>
#include <tuple>
#include <new>

using namespace std;

#define EPS (1e-9)
#define INF (1e9)
#define MOD (ll)(1e9 + 7)
#define PI (acos(-1))
#define REP(i,a,n) for(int i=a;i<n;i++)
#define rep(i, n) REP(i,0,n)
#define allof(a) (a).begin(), (a).end()

#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" ; "IMPOSSIBLE")

using ll = long long int;

ll gcd(ll a, ll b) {
    if (a < b) swap(a, b);
    if (b == 0) return a;
    return gcd(b, a % b);
}

ll beki(ll a, ll b) {
    ll tmp = 1;
    rep(i, b) tmp *= a;
    return tmp;
}

ll modPow(ll x, ll a) {
    if (a == 1) return x;
    if (a % 2) return (x * modPow(x, a - 1)) % MOD;
    ll t = modPow(x, a / 2);
    return ((t % MOD) * (t % MOD)) % MOD;
}

ll modInv(ll x) {
    return modPow(x, MOD - 2);
}

int N;
vector<int> L(110);
vector<int> M(110);
int ans;

int main() {
    cin >> N;
    rep(i, N) cin >> L[i];

    //sort(L.begin(), L.end());
    //L.erase(unique(L.begin(), L.end()), L.end());

    for (auto i = L.begin(); i != L.end(); i++) {
        for (auto j = i + 1; j != L.end(); j++) {
            for (auto k = j + 1; k != L.end(); k++) {
                if (*i + *j > *k && *i + *k > *j && *j + *k > *i && *i != *j && *j != *k && *k != *i) {
                    ans++;
                    //cout << i - L.begin() + 1 << " " << j - L.begin() + 1 << " " << k - L.begin() + 1 << endl;
                    //cout << *i << " " << *j << " " << *k << endl;
                }
            }
        }
    }
    cout << ans << endl;
}

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

using namespace std;

const int maxN = 1000;

int N;
int a[maxN];

struct Answer {
	long long s;
	vector<int> u;

	Answer() : s(0) {

	}

	bool operator < (const Answer & rhs) const {
		return s < rhs.s;
	}
};

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

	cin >> N;
	for (int i = 0; i < N; i++)
		cin >> a[i];

	vector<Answer> vtr;

	int x = max_element(a, a + N) - a;
	vtr.emplace_back();
	vtr.back().s = a[x];
	vtr.back().u.push_back(x);
	for (int z = 0; z < 2; z++) {
		Answer ans;
		for (int i = z; i < N; i += 2) {
			if (a[i] > 0) {
				ans.s += a[i];
				ans.u.push_back(i);
			}
		}
		if (!ans.u.empty())
			vtr.push_back(ans);
	}

	Answer ans = *max_element(vtr.begin(), vtr.end());

	cout << ans.s << '\n';
	vector<int> idx;
	for (int i = N - 1; i > ans.u.back(); i--)
		idx.push_back(i);
	for (int k = ans.u.size() - 1; k > 0; k--) {
		for (int i = ans.u[k] - 2; i > ans.u[k - 1]; i -= 2)
			idx.push_back(i);
		idx.push_back(ans.u[k - 1] + 1);
	}
	for (int i = 0; i < ans.u[0]; i++)
		idx.push_back(0);

	cout << idx.size() << '\n';
	for (const auto & x : idx)
		cout << x + 1 << '\n';

	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<queue>
#include<algorithm>
typedef long long ll;
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;

int main() {
	string s;
	cin >> s;
	if (s == "AAA" || s == "BBB") cout << "No" << endl;
	else cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

int main()
{

    int X, A;
    std::cin >> X >> A;

    if(X<A)
        std::cout << 0 << std::endl;
    else if(X>=A)
        std::cout << 10 << std::endl;



    return 0;
}

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

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

    deque<int> dq;
    bool flip = false;

    for (int i = 0; i < n; i++)
    {
        int x;
        scanf("%d", &x);
        if (flip)
        {
            dq.push_front(x);
            flip = false;
        }
        else
        {
            dq.push_back(x);
            flip = true;
        }
    }

    if (flip) reverse(dq.begin(), dq.end());
    for (int t : dq) printf("%d ", t);
    printf("\n");
}


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

int main()
{
	int q;
	cin >> q;
	int c, a, n;
	for (int i = 0; i < q; i++) {
		cin >> c >> a >> n;

		if (n >= c && n >= a) {
			if (c > a) {
				c -= a;
				c /= 3;
				cout << a + c << endl;
			}
			else
				cout << c << endl;
			continue;
		}

		if (a >= n && a >= c) {
			if (c > n) {
				a -= n;
				c -= n;
				c /= 2;
				cout << c + n << endl;
			}
			else
				cout << c << endl;
			continue;
		}

		if (c >= a&&c >= n) {
			if (a > n) {
				c -= n;
	 			a -= n;
				if ((c / 2) < a)
					cout << c / 2 + n << endl;
				else
					cout << a + (c - 2 * a) / 3 + n << endl;
			}
			else {
				c -= a;
				c /= 3;
				cout << a + c << endl;
			}
			continue;
		}
	}
    return 0;
}


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

int main() {
    int x, a, b;
    cin >> x >> a >> b;
    x -= a;

    while (true) {
        if(x >= b) {
            x -= b;
        }
        else {
            cout << x << endl;
            break;
        }
    }
   
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define P pair<ll,ll>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()




int main(){
    int n; cin>>n;
    vector<ll> p(n+1);
    rep(i,n+1) cin>>p[i];
    vector<P> q(n+1);
    q[n]={p[n],p[n]};
    rep(i,n){
        q[n-1-i].first=(q[n-i].first+1)/2+p[n-1-i];
        q[n-1-i].second=q[n-i].second+p[n-1-i];
    }
    if(q[0].first!=1){
        cout<<-1<<endl;
        return 0;
    }
    ll ans=1;
    ll che=1;
    rep(i,n){
        che=min(2*(che-p[i]),q[i+1].second);
        ans+=che;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5592
eList = [chr(i) for i in range(97, 97+26)]
N = int(input())

n = N
mod = N
numList = []

while n > 0:
    n, mod = divmod(n, 26)
    if mod != 0:
        # 末尾ではなく先頭に追加する
        # 1のくらいから判定して行っているため
        numList.insert(0, mod - 1)
    else:
        numList.insert(0, 25)
        # 26進数のようで26まで数字があるため調整する
        n -= 1

ans = ''
for num in numList:
    ans += eList[num]
print(ans)

Measured memory_bytes: 9096
N = int(input())
flg = False
for i in range(1, 10):
  a  = N % i
  b = N / i
  if (a == 0) and (b > 0 and b < 10):
    flg = True
    break
  
if flg:
  print("Yes")
else:
  print("No")
  


Measured memory_bytes: 2940
local function str2tbl(s)
    -- limit of #s is approximately 999959
    local t = {string.byte(s, 1, #s)}
    local char = string.char
    for i=1, #t do
        t[i] = char(t[i])
    end
    return t
end
--
local read = setmetatable({}, {__index = function(t, k) local a = {} for i=1,#k do table.insert(a, string.sub(k, i, i)) end local r = io.read local u = table.unpack return function() return r(u(a)) end end})
local S = str2tbl(read.l())
local easy = true
for i=1,#S do
    if i%2 == 0 then
        if S[i] == 'R' then
            easy=false
            break
        end
    else
        if S[i] == 'L' then
            easy=false
            break
        end
    end
end
print(easy and "Yes" or "No")


Measured memory_bytes: 1008
#include <iostream>
#include <cstdlib>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>

using namespace std;

int main(){
  int a,b,c,d,ac,bd;
  
  cin >> a >> b >> c >> d;

  ac = a-c;
  bd = b-d;
   cout << ac*bd;

  return 0;
  }

Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cstdio>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <climits>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>

using namespace std;
#define fast ios::sync_with_stdio(false);cin.tie(0);
#define pb push_back
#define sz(s) (int)s.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define PI 3.14159265

typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vi;
const ll mod=(ll)1e9+7;
//const ll inf = (ll)1e16 + 7;
//const int N=1e5+7;

ll a[1001];
vector<ll> v;

void sieve(){
    a[0]=a[1]=1;
    for(int i=2;i<1001;i++){
        for(int j=i+i;j<1001;j+=i){
            a[j]=1;
        }
    }
    forn(i,1001){
        if(!a[i]) v.pb(i);
    }
}

int main(){
    fast;
    sieve();
    ll n,ans=1;
    cin>>n;
    for(ll x : v){
        ll c=0,y=x;
        while(y<=n){
            c+=n/y;
            y*=x;
        }
        ans=(ans*(c+1))%mod;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fin ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ii pair<int,int>
#define F first
#define S second
#define pb push_back
#define pf push_front
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fore(i,a,b) for(int i = a;i < b; i+= 1)
#define forr(i,a) for(int i = a; i >= 0; i--)
#define fori(i,m) for(auto i = m.begin(); i != m.end(); i++) 
#define w(t) while(t--)
#define sz(s) int(s.size())
#define cls(a,car) memset(a,car,sizeof (a))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ii> vii;
const int N = 2 * 1e5 + 5;
const ll mod = 998244353;
const int INF = INT_MAX;
const ll INFCAD  = ll(INT_MAX) * 2 + 1;
const double E = 1e-9;
// fflush(stdout)
// cout << flush
// a + b = a ^ b + 2 * (a & b)
int main(){
    //freopen("in","r",stdin);
    //freopen("out","w",stdout);
    int n, m;
    cin >> n >> m;
    int v[n + 1];
    ll sum = 0;
    fore(i, 0, m){
        cin >> v[i];
        sum += v[i];
    } 
    ll ans = n - sum;
    if(ans < 0)
        ans = -1;
    cout << ans << '\n';
    return 0;
}   

Measured memory_bytes: 3676
# -*- coding: utf-8 -*-

#-------
# Initialize
n = int(input())
a = list(input().split())


itr = n
while(itr > 0):
    print(a[itr-1] + ' ', end="")
    itr -= 2
itr = n % 2
while(itr < n):
    print(a[itr] + ' ', end="")
    itr += 2
print()


Measured memory_bytes: 21668
#include<bits/stdc++.h>
using namespace std;
int main(){
  int c[8]={},n,idx=-1;
  char z[8]={'A','I','D','U','N','Y','A','N'};
  char z1[8]={'A','I','Z','U','N','Y','A','N'};
  string d;
  cin>>d;
 
  for(int i=0;i<d.size();i++){
 
    n=0;
    for(int j=0;j<8;j++)c[j]=0;
 
    for(int j=0;j<8;j++){
      if(i+j>=d.size())break;
      for(int k=0;k<8;k++)
    if(d[i+j]==z[k]&&c[k]==0){
      c[k]=1,n++;
      break;
    }
    }
    if(n==8){
      for(int j=0;j<8;j++)d[i+j]=z1[j];
      i+=7;
    } 
  }
  cout<<d<<endl;  
   
 return 0;
}

Measured memory_bytes: 1184
def submit():
    n, w = map(int, input().split())
    dp = [[0] * (w + 1) for _ in range(n + 1)]

    # dp[i][j] = item iまでで重さjの時に実現する最大価値
    for i in range(1, n + 1):
        wi, vi = map(int, input().split())
        for j in range(1, w + 1):
            if 0 <= j - wi <= w:
                dp[i][j] = max(dp[i - 1][j], dp[i - 1][j - wi] + vi)
            else:
                dp[i][j] = dp[i - 1][j]    
    print(max(dp[n]))

submit()    
        

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

using namespace std;

int a[50];

int main() {
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
	}
	int ans = 0;
	for (int i = 0; i < n; i++) {
		for (int j = i + 1; j < n; j++) {
			ans += a[i] * a[j];
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 256
l = list(map(int,input().split()))
a = l[0]
b = l[1]
if b == 1:
    print(0)
else:
    if (b-1)%(a-1) == 0:
        print((b-1)//(a-1))
    else:
        print((b-1)//(a-1)+1)

Measured memory_bytes: 3060
import queue

N = int(input())
to_list = [ [] for i in range(N) ]
cost_list = [ [] for i in range(N) ]
ans = [ -1 for i in range(N) ]

for n in range(N - 1):
    a, b, w = map(int, input().split())
    a -= 1
    b -= 1
    to_list[a].append(b)
    to_list[b].append(a)
    cost_list[a].append(w)
    cost_list[b].append(w)

# FIFOキューの作成
q = queue.Queue()
q.put(0)

while(not q.empty()):
    v = q.get()
    for i in range(len(to_list[v])):
        u = to_list[v][i]
        w = cost_list[v][i]
        if ans[u] != -1:
            continue
        ans[u] = (ans[v] + w) % 2
        q.put(u)

for a in ans:
    print(a)

Measured memory_bytes: 38952
#include <iostream>
#include <iomanip>
using namespace std;
 
int main() {
	// your code goes here
	int r;
	cin >> r;
   
    long double res = 2 * r ;
	
	cout << fixed << setprecision(20) 
	     << res*3.14159265358979323846 << endl;
	
	return 0;
}

Measured memory_bytes: 3260
if __name__ == '__main__':
    n = int(input())
    a = list(map(int, input().split()))
    cumsum_a = [0] * len(a)
    cumsum_a[0] = a[0]
    for i in range(1, len(a)):
        cumsum_a[i] += cumsum_a[i-1] + a[i]

    sum_val = 0
    num = 10 ** 9 + 7
    for i in range(0, n - 1):
        sum_val += a[i] * (cumsum_a[-1] - cumsum_a[i])
        if sum_val > num:
            sum_val %= num
    print(sum_val)



Measured memory_bytes: 93952
#include<bits/stdc++.h>
#define ll long long
#define int long long int
#define MOD 1000000007
#define mkp make_pair
#define maxn 100005
#define pb push_back
#define ff first
#define ss second
#define debug1(a) cout<<a<<endl;
#define debug2(a,b) cout<<a<<' '<<b<<endl;
#define debug3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define rep(i,n) for(int i=0;i<n;i++)
#define repl(i,a,b) for(int i=a;i<b;i++)
#define pi pair<int,int>
#define pii pair<int,pi>
#define mp map<int,int>
#define ump unordered_map<int,int>
#define  vi vector<int>
#define st set<int>
#define mst multiset<int>
#define pq priority_queue
#define mpq priority_queue<int,vector<int>,greater<int> >
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define in cin>>
#define out cout<<
using namespace std;
const int infi=1e15+7;
void printVector(vector<int> v){
    for(int i=0;i<(int)v.size();i++)
        cout<<v[i]<<" ";
    out endl;
}

void printArray(int arr[],int n)
{
   for(int i=0;i<n;i++)cout<<arr[i]<<' ';
cout<<endl;
}
 set<pair<int,int>> primeset;
 vi prime_number;
void SieveOfEratosthenes(int n)
{
    bool prime[n+1];
    memset(prime, true, sizeof(prime));

    for (int p=2; p*p<=n; p++)
    {
        if (prime[p] == true)
        {
        for (int i=p*p; i<=n; i += p)
                prime[i] = false;
        }
    }
    for (int p=2; p<=n; p++)
       if (prime[p])
           primeset.insert(mkp(p,1));
}
ll modExp(ll base, ll power) {
    if (power == 0) {
        return 1;
    } else {
        ll cur = modExp(base, power / 2); cur = cur * cur; cur = cur % MOD;
        if (power % 2 == 1) cur = cur * base;
        cur = cur % MOD;
        return cur;
    }
}
//for making unordered_map with pair
struct hash_pair {
    template <class T1, class T2>
    size_t operator()(const pair<T1, T2>& p) const
    {
        auto hash1 = hash<T1>{}(p.first);
        auto hash2 = hash<T2>{}(p.second);
        return hash1 ^ hash2;
    }
};
int32_t main()
{
fastio;

int t=1;
//in t;
int tt=0;
while(t--){
int n;in n;
int ans=0;
for(int i=1;i<=n;i++){
    for(int j=1;j<=n;j++){
        for(int k=1;k<=n;k++){
            ans+=__gcd(i,__gcd(j,k));
        }
    }
}
out ans;
}
return 0;
}

/*
google kick start
  cout << "Case #" << tt << ": "<<ans<<endl;
*/


Measured memory_bytes: 3652
import sys
input = sys.stdin.readline

inf = float('inf')

N,Ma,Mb = map(int,input().split())

# dp[i][j][k]: i番目までみてj(g), k(g)となるような最小予算
dp = [[[inf]*401 for _ in range(401)] for _ in range(N+1)]
dp[0][0][0] = 0

for i in range(N):
    a,b,c = map(int,input().split())
    for j in range(401):
        for k in range(401):
            dp[i+1][j][k] = dp[i][j][k]
            if j - a >= 0 and k - b >= 0 and dp[i+1][j][k] > dp[i][j-a][k-b] + c:
                dp[i+1][j][k] = dp[i][j-a][k-b] + c

ans = inf

for j in range(1,401):
    for k in range(1,401):
        if j * Mb == Ma * k and ans > dp[N][j][k]:
            ans = dp[N][j][k]

if ans == inf:
    ans = -1
print(ans)

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

#define rep(X,N) for(ll X = 0LL; X < (N); X++)
#define PI (acos(-1.0))
#define MODN 1000000007
#define MODN2 998244353
#define ALL(V) (V).begin(),(V).end()
#define INT_MAX_HALF (INT_MAX / 2)
#define EPS (1e-10)

using namespace std;
typedef long long ll;

int main(){

    int n;
    cin >> n;

    vector<int> a(n);

    rep(i, n){
        int tmp;
        cin >> tmp;
        tmp--;

        a[i] = tmp;
    }

    int ans = 0;

    rep(i, n){
        if(a[a[i]] == i) ans++;
    }

    cout << ans / 2 << endl;
    return 0;
}


Measured memory_bytes: 640
import sys
import heapq, math
from itertools import zip_longest, permutations, combinations, combinations_with_replacement
from itertools import accumulate, dropwhile, takewhile, groupby
from functools import lru_cache
from copy import deepcopy

N = int(input())
ans = 0
for i in range(N):
    a, b = map(int, input().split())
    ans += b - a + 1

print(ans)

Measured memory_bytes: 3572
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int a[100];
int main()
{
    int n;
    cin>>n;
    int max1=-1e8;
    int t1,t2;
    for(int i=1; i<=n; i++)
    {
        cin>>a[i];
        if(max1<abs(a[i]))
        {
            max1=abs(a[i]);
            t1=i;
        }
    }
    cout<<2*n-1<<endl;
    for(int i=1;i<=n;i++)
        cout<<t1<<" "<<i<<endl;
    if(a[t1]>=0)
    {
        for(int i=2;i<=n;i++)
            cout<<i-1<<" "<<i<<endl;
    }
    else
    {
        for(int i=n-1;i>=1;i--)
            cout<<i+1<<" "<<i<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
import core.bitop;
import std.algorithm;
import std.ascii;
import std.bigint;
import std.conv;
import std.functional;
import std.math;
import std.numeric;
import std.range;
import std.stdio;
import std.string;
import std.random;
import std.typecons;

alias sread = () => readln.chomp();
alias Point2 = Tuple!(long, "y", long, "x");

T lread(T = long)()
{
    return readln.chomp.to!T();
}

T[] aryread(T = long)()
{
    return readln.split.to!(T[])();
}

void scan(TList...)(ref TList Args)
{
    auto line = readln.split();
    foreach (i, T; TList)
    {
        T val = line[i].to!(T);
        Args[i] = val;
    }
}

void minAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) min(dst, src);
}

void maxAssign(T, U = T)(ref T dst, U src)
{
    dst = cast(T) max(dst, src);
}

void main()
{
    auto s = sread();
    bool b = s[0] == '9' || s[1] == '9';
    writeln(b ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <map>
#define ll long long
using namespace std;
int main()
{
#ifndef ONLINE_JUDGE
    //freopen("in.txt","r",stdin);
    //freopen("out.txt", "w",stdout);
#endif
    int n;
    while(cin>>n)cout<<(1+n)*n/2<<endl;
    return 0;
}


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


int main() {
	int N;
	cin >> N;
	int p;
	int count = 0;
	for (int i=0; i < N; i++) {
		cin >> p;
		if (i+1 != p) count += 1;
	}
	string ret;
	if (count == 0 || count == 2) ret = "YES";
	else ret = "NO";
	cout << ret << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define pb push_back
typedef pair<int,int> pr;
template <typename T>
T FindMax(T a,T b){
	return a>b?a:b;
}
int main() {
	int x;cin>>x;
	if(x==0)puts("1");
	else puts("0");
	return 0;
}

Measured memory_bytes: 3664
#include <stdio.h>

int main()
{
	int tate,yoko;
	int menseki,shuu;
	scanf("%d %d", &tate, &yoko);
	menseki=tate*yoko;
	shuu=tate+tate+yoko+yoko;
	printf("%d %d\n", menseki, shuu);
	return 0;
}

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

using namespace std;
typedef long long ll;

int main() {
        cin.sync_with_stdio(0);
       
        ll a, b, n;
        cin >> a >> b >> n;

        n = min(n, b - 1);

        cout << (a * n) / b - a * (n / b);

        //ll res = 0;

        //for (ll x = 0; x <= min(n, (ll)1e8); ++x) {
        //        ll cur = (a * x) / b - a * (x / b);
        //        cout << x << " " << cur << "\n";
        //}
        //cout << res;

        return 0;
}

Measured memory_bytes: 3596
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		
		if (a == b && b == c) {
				System.out.println("1");
		}else if (a == b || b == c || c == a) {
			System.out.println("2");
		}else {
			System.out.println("3");
		}
	}
}

Measured memory_bytes: 35644
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int H, W, K;
bool field[10][1000 + 10];//trueがK個しか含まれないようにする
int csum[10 + 2][1000 + 10];

int main() {
	cin >> H >> W >> K;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			char c;
			cin >> c;
			if (c == '1')field[i][j] = true;
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 0; j < W; j++)csum[i][j + 1] = csum[i][j] + field[i - 1][j];
	}

	for (int j = 1; j <= W; j++) {
		for (int i = 0; i < H; i++)csum[i + 1][j] += csum[i][j];
	}

	int ans = 1145141919;
	for (int bit = 0; bit < (1 << (H - 1)); bit++) {
		vector<int> sep;//切れる場所
		sep.push_back(0);
		for (int i = 0; i < H - 1; i++) {
			if ((bit >> i) & 1)sep.push_back(i + 1);
		}
		sep.push_back(H);

		int tmp = sep.size() - 2;
		int bef = 0;

		for (int i = 0; i < W; i++) {
			for (int j = 0; j < sep.size() - 1; j++) {
				int ue = sep[j], sita = sep[j + 1];
				
				if (csum[sita][i + 1] - csum[ue][i + 1] - csum[sita][i] + csum[ue][i] > K) {
					goto nxtroop;
				}

				if (csum[sita][i + 1] - csum[ue][i + 1] - csum[sita][bef] + csum[ue][bef] > K) {
					tmp++;
					bef = i;
					break;
				}
			}
		}
		
		ans = min(ans, tmp);
	nxtroop:;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mk make_pair
#define mod 1000000007
#define ll long long
#define lb lower_bound
#define ub upper_bound
#define endl "\n"
#define ff first
#define ss second
#define prec(y,x) fixed<<setprecision(y)<<x
#define inf 1e18
#define pi 3.1415926535
 
int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
 
	ll n, k;
	cin >> n >> k;
	ll arr[n];
	for (int i = 0; i < n; i++)
		cin >> arr[i];
	ll food[n];
	for (int i = 0; i < n; i++)
		cin >> food[i];
	sort(arr, arr + n);
	sort(food, food + n);
	ll l = 0 ; ll r = 1e13; ll mid; mid = l + r; mid /= 2;
	int f = 1; ll ans = -1; int u = 0;
	while (f == 1)
	{
		u++;
		if (u > 100)
			break;
		if (l == r)
		{
 
			mid = l + r;
			mid /= 2;
			ll cnt = 0; int flag1 = 1;
			for (int i = 0; i < n; i++)
			{
				ll a = mid / food[n - 1 - i];
				if (arr[i] > a)
					cnt += arr[i] - a;
				if (cnt > k)
				{flag1 = 0; break;}
			}
			cnt = 0; mid++; int flag2 = 1;
			for (int i = 0; i < n; i++)
			{
				ll a = mid / food[n - 1 - i];
				if (arr[i] > a)
					cnt += arr[i] - a;
				if (cnt > k)
				{flag2 = 0; break;}
			} mid--;
			//cout << l << " " << mid << " " << r << " " << flag1 << " " << flag2 << endl;
			if (flag1 == 0 && flag2 == 0)
			{
				ans = mid;
			}
			else if (flag1 == 0 && flag2 == 1)
			{
				ans = mid + 1; break;
			}
			else
			{
				ans = mid;
			}
			break;
		}
		else
		{
			mid = l + r;
			mid /= 2;
			ll cnt = 0; int flag1 = 1;
			for (int i = 0; i < n; i++)
			{
				ll a = mid / food[n - 1 - i];
				if (arr[i] > a)
					cnt += arr[i] - a;
				if (cnt > k)
				{flag1 = 0; break;}
			}
			cnt = 0; mid++; int flag2 = 1;
			for (int i = 0; i < n; i++)
			{
				ll a = mid / food[n - 1 - i];
				if (arr[i] > a)
					cnt += arr[i] - a;
				if (cnt > k)
				{flag2 = 0; break;}
			} mid--;
			//cout << l << " " << mid << " " << r << " " << flag1 << " " << flag2 << endl;
			if (flag1 == 0 && flag2 == 0)
			{
				l = mid + 1;
			}
			else if (flag1 == 0 && flag2 == 1)
			{
				ans = mid + 1; break;
			}
			else
			{
				r = mid - 1;
			}
			//cout << l << " " << mid << " " << r << " " << flag1 << " " << flag2 << endl;
		}
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 6768
K=int(input())

a=7%K
i=1
dp=[0 for n in range(K)]
dp[a]=1

while a!=0:
   a=(10*a+7%K)%K
   if dp[a]==0:
       dp[a]+=1
       i+=1
   else:
       print(-1)
       break
else:
    print(i)

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

using namespace std;

int main()
{
  int64_t n;
  cin >> n;
  vector<std::string> s(n);
  for(int64_t i = 0;
      i < n;
      ++i)
    {
      cin >> s[i];
      sort(s[i].begin(), s[i].end());
    }

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

  int64_t ans = 0;
  int64_t cnt = 0;
  for(int64_t i = 0;
      i < n - 1;
      ++i)
    {
      if(s[i] != s[i + 1])
        {
          for(int64_t j = cnt;
              j != 0;
              --j)
            {
              ans += j;
            }
          cnt = 0;
        }
      else
        {
          ++cnt;
        }
    }
  if(cnt > 0)
    {
      for(int64_t j = cnt;
          j != 0;
          --j)
        {
          ans += j;
        }
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 7296
#include <stdio.h>
#include <string.h>
void shuffle(char card[], int h)
{
    char tmp[201];
    int len = strlen(card);

    strncpy(tmp, card + h, len - h);   //先頭になるべき部分をコピー
    strncpy(tmp + (len - h), card, h); //シャッフルで移動したものをコピー
    strncpy(card, tmp, len);
}
int main(void)
{
    char card[201];
    int n;

    while (1)
    {
        scanf("%[^\n]%*c", card);
        if (card[0] == '-')
        {
            break;
        }
        scanf("%d", &n);
        for (int i = 0; i < n; i++)
        {
            int h;
            scanf("%d%*c", &h);

            shuffle(card, h);
        }
        printf("%s\n", card);
    }

    return 0;
}



Measured memory_bytes: 2688
#ABC143-D
n=int(input())
l=list(map(int,input().split()))
l=sorted(l,reverse=True)
ans=0
#print(l)
for i in range(n-2):
    for j in range(i+1,n-1):
        b=l[i]
        c=l[j]

        #二分探索
        ok=j
        ng=n
        while ng-ok>1:
            mid=(ok+ng)//2
            if l[mid]>b-c:
                #b>=cはわかってる
                ok=mid

            else:
                ng=mid

        ans+=ok-j
print(ans)

Measured memory_bytes: 42732
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long mod = 1e9 + 7;

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

int main() {
	int a;
	string s;
	cin >> a >> s;
	
	if (a >= 3200) {
		cout << s << endl;
	} else {
		cout << "red" << endl;
	}

	
}


Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#define FOR(x,a,b) for(int x=a;x<b;x++)
#define REP(x,b) for(int x=0;x<b;x++)
#define FORSIZE(x,A) for(int x=0;x<A.size();x++)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define SORT(x) sort(x.begin(),x.end())
#define RSORT(x) sort(x.rbegin(),x.rend())
#define rsort(x,n) sort(x, x+n, greater<int>())
#define REV(x) reverse(x.begin(),x.end())
using namespace std;
typedef long long ll;
inline int toInt(std::string s) {int v; std::istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {std::ostringstream sout;sout<<x;return sout.str();}

int main( int argc, const char* argv[] )
{
    string s;
    cin >> s;
    for (int i=s.size()-1; i>=0; i--) {
        cout << s[i];
    }
    cout << endl;
    return 0;
}

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

int main(void) {
	long long int n, m, d;
	cin >> n >> m >> d;
	double res = 0;
	if (d >= n) {
		cout << res << endl;
	} else {
		double coef = 2;
		if (d == 0) {
			coef = 1;
		}
		res = double(n - d) * coef * double(m - 1) / (double(n) * double(n));
		cout << fixed << setprecision(9) << res << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) throws Exception {
    Scanner sc = new Scanner(System.in);
    String[] top = sc.next().split("");
    int count = 0;
    
    for(int i = 0 ; i < top.length ; i++){
      if(top[i].equals("o")){
        count++;
      }
    }
    System.out.println(700 + (count * 100));
  }
}


Measured memory_bytes: 21588
#include<bits/stdc++.h>
#include<iomanip>
#define mins(a,b) a=min(a,b)
#define maxs(a,b) a=max(a,b)
template < typename T > std::string to_string( const T& n )
  {
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
  }
using namespace std;

const long long INF=9000000000000000;
int main(){
long long int n,m;
cin>>n>>m;
long long int ans=0;
int x[100010]={};
int y[m*2]={};
pair<long long int,long long int> a[500000];
for(int i=0;i<500000;i++){
  a[i].first=0;
  a[i].second=0;
}
for(int i=0;i<n;i++){
  cin>>x[i];
  a[i].first=x[i];
  a[i].second=1;
}
for(int i=0;i<m*2;i++){
  cin>>y[i];
}
for(int i=0;i<m;i++){
  a[i+n].first=y[i*2+1];
  a[i+n].second=y[i*2];
}
sort(a,a+500000);reverse(a,a+500000);
for(int i=0;i<1000000;i++){
  if(n>0){
    ans+=(a[i].first*min(a[i].second,n));
    n-=a[i].second;
  }
  else
  break;
}
cout<<ans<<endl;
}


Measured memory_bytes: 9216
#include <iostream>

using namespace std;
using ll = long long;

int main() {
  auto const M = (int)1e9 + 7;
  ll N, K, R=0;
  cin >> N >> K;
  
  for(ll k = K; k<=(N+1); ++k) {
    auto const t = k * (N - k + 1) + 1;
    R = (R + t) % M;
  }
  
  cout << R << endl;
  return 0;
}


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

int main(void){
    int N,T;
    cin>>N>>T;
    vector<int> t(N);
    for(int i=0;i<N;i++) cin>>t[i];
    long long ans = T;
    for(int i=1;i<N;i++){
        ans += min(T,t[i] - t[i-1]);
    }
    cout<<ans<<endl;
    
}


Measured memory_bytes: 1024
#include <stdio.h>
int main()
{
  int a,b,n,s;
  while((scanf("%d%d%d",&a,&b,&n))!=EOF){
    s = 0;
    a %= b;
    while(n--){
      s += a * 10 / b;
      a = (a * 10) % b;
    }
    printf("%d\n",s);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#define MAX 20000  // スタックの最大値

typedef struct{
  int top;         // スタックポインタ(一番上の位置)
  int S[MAX];
}Stack;


// スタック st の初期化
void initialize(Stack *st)
{
  st->top = 0;
  st->S[st->top] = 0;
}

// スタック st が空かどうかを確認
int isEmpty(Stack *st)
{
  return st->top == 0;
}

// スタック st が一杯かどうかを確認
int isFull(Stack *st)
{
  return st->top >= MAX - 1;
}

// スタック st に要素 x をプッシュ(一番上に要素を追加)
void push(int x, Stack *st)
{
  if (isFull(st))
    exit(1);

  st->top++;
  st->S[st->top] = x;
}

// スタック st から要素をポップ(一番上の要素を取り出す)
int pop(Stack *st) {
  if (isEmpty(st))
    exit(1);

  st->top--;
  return st->S[st->top+1];
}


int main(void)
{
  Stack st1;     // '\' の開始位置を格納するスタック
  Stack st2_j;   // 各水たまりの最も左の'\' の位置を格納するスタック
  Stack st2_a;   // 各水たまりの水量を格納するスタック

  // スタック初期化
  initialize(&st1);
  initialize(&st2_j);
  initialize(&st2_a);

  char c;
  int sum = 0;  // 水たまりの総水量

  // 地形を読み込み，各水たまりの水量を計算
  for (int i = 0; (c = getchar()) != EOF; i++) {
    if (c == '\\') {                                 // '\' が出た時の処理
      // 位置 i を st1 にプッシュ(write your code)
      push(i, &st1);
    }else if (!isEmpty(&st1) && c == '/') {          // '/' が出た時の処理
      // 水たまりの総水量 sum を更新(write your code)
      int j = pop(&st1);
      sum += i - j;
      // st2_j と st2_a を用いて水たまりの水量を更新
      int a = i - j;   // 更新する水たまりの水量を a に格納していく
      while (!isEmpty(&st2_j) && st2_j.S[st2_j.top] > j) {  // 最も左の '\' の位置が j よりも大きい場合，以下を繰り返す
        // 水たまりの水量を求めていく (write your code)
        a += pop(&st2_a);
        pop(&st2_j);
      }
      // 更新した水たまりの「最も左の'\' の位置」および「水量」を更新 (write your code)
      push(j, &st2_j);
      push(a, &st2_a);
    }
  }

  printf("%d\n", sum);       // 水たまりの総水量を出力
  printf("%d", st2_a.top);   // 水たまりの個数を出力

  // 各水たまりの水量を断面図の左から出力(スタックの底から出力)
  for (int i = 1; i <= st2_a.top; i++){
    printf(" %d", st2_a.S[i]);
  }
  printf("\n");

  return 0;
}



Measured memory_bytes: 2144
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <string.h>
#include <map>
#include <set>
#include <functional>
#include <complex>
#include <stack>
#include <tuple>
#include <array>
using namespace std;
#define rep(i,n) for (int i=0; i < (n); i++)


typedef long long int ll;
typedef double D;      // ??§?¨?????????????double???long double?????????
typedef complex<D> P;  // Point
typedef pair<P, P> L;  // Line
typedef vector<P> VP;


const int INF = (1<<30) - 1;
const D EPS = 1e-9;
const int MOD = 1000000007;

#define X real()
#define Y imag()
#define LE(n,m) ((n) < (m) + EPS)
#define GE(n,m) ((n) + EPS > (m))
#define EQ(n,m) (abs((n)-(m)) < EPS)

string S;

void solve(){
    int N = S.length();
    vector<vector<int>> s(N, vector<int>(11));
    
    rep(i, N){
        int d = S[i]-'0';
        s[i][d] = d > 0;
        if(i > 0){
            rep(j, 11){
                s[i][(j*10 + d)%11] += s[i-1][j];
            }
        }
    }
    int ans = 0;
    rep(i, N){
        ans += s[i][0];
    }
    cout << ans << endl;
}

//g++ -std=c++0x -msse4.2 -O3
//#include <bits/stdc++.h>
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    //cout.precision(16);
    //cout.setf(ios::fixed);
    
    while(cin>>S, S!="0")
        solve();
    
    return 0;
}

Measured memory_bytes: 8132
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG 
#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() // sort(all(array))
#define INF 1000000000
#define mod 1000000007
using namespace std;
using ll = long long;
using vi = vector<int>; //vi array(要素数, 初期値)
using pll = pair<ll, ll>;
using pii = pair<int, int>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>; //vvi table(行数, vi(列数, 初期値))
using vvc = vector<vc>;
using vvs = vector<vs>;
using vvb = vector<vb>;

int main() {
    int n; cin >> n;
    vi A(n); rep(i, n) cin >> A[i];

    ll step = 0;
    reps(i, 1, n) {
        if (A[i - 1] > A[i]) {
            step += A[i - 1] - A[i];
            A[i] = A[i - 1]; 
        }
    }

    cout << step << endl;
}

Measured memory_bytes: 3984