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

int main()
{
    int H, W;
    cin >> H >> W;

    char c;

    for (int i = 0; i < W + 2; i++)
        cout << '#';
    cout << endl;

    for (int i = 0; i < H; i++)
    {
        cout << '#';
        for (int j = 0; j < W; j++)
        {
            cin >> c;
            cout << c;
        }
        cout << '#' << endl;
    }

    for (int i = 0; i < W + 2; i++)
        cout << '#';
    cout << endl;
}


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

typedef long long ll;

int main()
{
	int n, w;
	cin >> n >> w;
	vector<vector<ll>> arr(n,vector<ll>(2,0));
	for(int i = 0; i < n; i++)
	{
		for(int j = 0; j < 2; j++)
		{
			cin >> arr[i][j];
		}
	}
	vector<vector<ll>> dp_arr(n+1,vector<ll>(w+1,0));
	ll max_ = 0;
	for(int i = 1; i <= n; i++)
	{
		for(int j = 1; j <= w; j++)
		{
			dp_arr[i][j] = max(dp_arr[i-1][j], (j - arr[i-1][0] >=0 ? arr[i-1][1] + dp_arr[i-1][j-arr[i-1][0]] : 0));
			if(j <= w)
				max_ = max(max_,dp_arr[i][j]);
		}
	}
	cout << max_ << endl;
}


Measured memory_bytes: 80256
// std::setを用いた解
#include <bits/stdc++.h>
using namespace std;
const string R = "abcdefghijklmnopqrstuvwxyz";

int main() {
    string S;
    cin >> S;
    set<char> alph;

    for (int i = 0; i < S.size(); i++) {
        alph.insert(S.at(i));
    }

    for (int i = 0; i < 26; i++) {
        bool noMatch = true;
        for (char a : alph) {
            if (a == R.at(i)) noMatch = false;
        }
        if (noMatch) {
            cout << R.at(i) << endl;
            return 0;
        }
    }

    cout << "None" << endl;
    return 0;
}

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


int itorab(char x){
    switch(x){
        case 'I':
            return 1;
        case 'V':
            return 5;
        case 'X':
            return 10;
        case 'L':
            return 50;
        case 'C':
            return 100;
        case 'D':
            return 500;
        case 'M':
            return 1000;
        default:
            break;
    }
}

int main(){
    string str;
    while(cin>>str){
        int n=str.length();
        int ans=0;
        ans += itorab(str[n-1]);
        for(int i=n-1;i>0;i--){
            if(itorab(str[i-1])>=itorab(str[i])){
                ans+=itorab(str[i-1]);
            }else{
                ans-=itorab(str[i-1]);
            }
        }
        cout << ans << endl;
    }
    return 0;
}

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

// i桁目まで見て j枚多く払う時(0 or 1)
ll dp[1000100][2];

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

  s = '0' + s;
  int n = (int)s.size();
  memset(dp, 0, sizeof(dp));
  dp[0][1] = 1;

  for (int i = 1; i < n; i++) {
    int current = s[i] - '0';
    dp[i][0] = min(dp[i - 1][0] + current, dp[i - 1][1] + (10 - current));
    dp[i][1] = min(dp[i - 1][0] + current + 1, dp[i - 1][1] + (9 - current));
  }
  cout << dp[n - 1][0] << '\n';
}

Measured memory_bytes: 20072
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
sys.setrecursionlimit(10 ** 7)

from collections import defaultdict
from itertools import accumulate

n, m, *a = map(int, read().split())
dict = defaultdict(int)
ans = 0
for v in [0] + list(map(lambda x: int(x) % m, list(accumulate(a)))):
    ans += dict[v]
    dict[v] += 1
print(ans)


Measured memory_bytes: 17716
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n, k = sc.nextInt
  val s = sc.next
//  val xss = List.fill(rows, cols)(sc.nextInt)

  val ans = s.zipWithIndex.map(c => if (c._2 == k - 1) c._1.toLower else c._1).mkString

  println(ans)
}

Measured memory_bytes: 25508
#include<bits/stdc++.h>
using namespace std;
int main(){
  string a;
  int c=0;
  cin >> a;
  map<char,int>ma;
  for(int i=0;i<a.size();i++){
    ma[a[i]]++;
    if(ma[a[i]]%2==1)c++;
    else c--;
  }
  cout << c/2 << endl;
  return 0;
}

  

Measured memory_bytes: 3140
#include <bits/stdc++.h>
 
using namespace std;
typedef long long ll;
typedef vector<int> VI;
ll mm=1000000000;ll MM=mm+7;
#define rep(i, n) for(int i=0;i<n;i++)
#define PI 3.141592653589793

int main(){
   int n,m;
   cin >> n >> m;
   VI a(m);
   VI b(m);
   rep(i,m){
      cin >> a[i] >> b[i];
   }
   map<int,int> cnt;
   rep(i,m){
      if(cnt.count(a[i])){
         cnt.at(a[i])++;
      }
      else{
         cnt[a[i]]=1;
      }
      if(cnt.count(b[i])){
         cnt.at(b[i])++;
      }
      else{
         cnt[b[i]]=1;
      }
   }
   for(int i=1;i<=n;i++){
      if(cnt.count(i)){
      cout << cnt.at(i) << endl;
      }
      else cout << 0 << endl;
   }
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n;

int main() {
    cin >> n;
    int ans = 12341234;
    for (int a = 1; a < n; ++a) {
        int b = n - a;
        int sum = 0;
        for (int x = a; x > 0; x /= 10) {
            sum += x % 10;
        }
        for (int x = b; x > 0; x /= 10) {
            sum += x % 10;
        }
        ans = min(ans, sum);
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
	int N;
	cin >> N;
	vector<int> vec (N);
	for(int i = 0;i < N;i++){
		cin >> vec.at(i);
	}
	sort(vec.begin(),vec.end());
	cout << vec.at(N-1) - vec.at(0) << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define pr(num) cout << num << endl
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define mp make_pair
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 150005
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;





int main(void) {
    string s;
    cin >> s;
    ll i;
    
    if(s.size()==1) {
        puts("0");
        return 0;
    }
    
    
    vector<ll> vec;
    for(i=0; i<s.size(); i++) {
        if(s[i]=='W') {
            vec.push_back(i);
        }
    }
    
    ll ans=0;
    
    for(i=0; i<vec.size(); i++) {
        ans+=vec[i]-i;
    }
    
    pr(ans);
    
}



Measured memory_bytes: 2680
/*  -*- coding: utf-8 -*-
 *
 * c.cc: C - Tax Increase
 */

#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<stack>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 100;

const int INF = 1 << 30;
const long long LINF = 1LL << 60;

/* typedef */

typedef long long ll;
typedef vector<int> vi;
typedef queue<int> qi;
typedef pair<int,int> pii;

/* global variables */

/* subroutines */

/* main */

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

  // |x*0.08|=a, |x*0.1|=b
  // -> a<=x*0.08<a+1, b<=x*0.1<b+1
  // -> a/0.08<=x<(a+1)/0.08
  int x0 = (a * 100 + 7) / 8, x1 = (a + 1) * 100 / 8;
  int y0 = b * 10, y1 = (b + 1) * 10;

  if (y0 < x1 && x0 < y1) printf("%d\n", max(x0, y0));
  else puts("-1");
  return 0;
}


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

vector <int> v[200000];
int ans[200000];
int n, q;

void ch(int now, int prev){
  for(int i = 0;i < v[now].size();i++){
    if(v[now][i] == prev)continue;
    ans[v[now][i]] += ans[now];
    ch(v[now][i], now);
  }
  return;
}

int main(void){
  cin >> n >> q;
  for(int i = 0;i < n-1;i++){
    int a, b; cin >> a >> b;
    a--; b--;
    v[a].push_back(b);
    v[b].push_back(a);
  }
  for(int i = 0;i < n;i++)ans[i] = 0;
  for(int i = 0;i < q;i++){
    int p, x; cin >> p >> x;
    p--; ans[p] += x;
  }
  ch(0, -1);
  for(int i = 0;i < n;i++)printf("%d ", ans[i]);
}

Measured memory_bytes: 26624
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
//#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1LL<<31)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)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 dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

string s;
stack<char> v;

int main(){
	cin>>s;
	for(int i=0;i<s.size();i++){
		if(s[i]=='T'){
			if(v.size()&&v.top()=='S'){
				v.pop();
			}else{
				v.push('T');
			}
		}else{
			v.push('S');
		}
	}
	cout<<v.size()<<endl;
	return 0;
}
	

Measured memory_bytes: 644
#include <bits/stdc++.h>
using namespace std;
using pii=pair<int,int>;
using ll=long long;

#define fi first
#define se second
#define pb push_back
#define rep(i,n) for(int i=0; i<(int)(n); i++)

int main() {

	ll h,w;
	cin >> h >> w;
	ll ans=0;
	if (h == 1) ans = 1;
	else if (w == 1) ans = 1;
	else 
	{
		if (h % 2 == 1)
		{
			ans = w * ((h - 1) / 2);
			ans += w % 2 == 0 ? w / 2 : w / 2 + 1;
		}
		else
		{
			ans = w * (h / 2);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n = int(input())
csf = [list(map(int, input().split())) for _ in range(n - 1)]

for i, (c, s, f) in enumerate(csf):
    t = s + c
    for j in range(i + 1, n - 1):
        C, S, F = csf[j][0], csf[j][1], csf[j][2]
        if t < S:
            t = S + C
        else:
            if (t - S) % F == 0:
                t += C
            else:
                t += F - (t-S) % F + C
    print(t)
print(0)

Measured memory_bytes: 3188
#include<stdio.h>
#include<cmath>
#include<math.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<complex>
#include<queue>
#include<set>
#include<utility>
#include<iomanip>
#include<limits>
#include<thread>
#include<map>
#include<stack>
#include<numeric>
#include<cassert>
#include<random>
#include<chrono>
#include<unordered_set>
#include<unordered_map>
#include<fstream>
#include<list>
#include<functional>
#include<bitset>
#include<tuple>

using namespace std;

template <class... A>
void prints() { cout << "\n"; }
template <class... A>
void prints_rest() { cout << "\n"; }
template <class T, class... A>
void prints_rest(const T &first, const A &... rest) { cout << " " << first; prints_rest(rest...); }
template <class T, class... A>
void prints(const T &first, const A &... rest) { cout << first; prints_rest(rest...); }

#define rep(i,n) for(int i=0; i<n; i++)
#define rep1(i,n) for(int i=1; i<n+1; i++)
#define repr(i,n) for(int i=n-1; i>=0; i--)
#define repr1(i,n) for(int i=n; i>0; i--)
#define souatari rep1(i,n-1)rep(j,i)
#define souatari1 for(int i=2; i<n+1; i++)rep1(j,i-1)
#define mp make_pair
#define F first
#define S second
#define elif else if

typedef long long ll;
typedef vector<int>  vi;
typedef vector<vi>  vvi;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef long double D;

const ll llinf =  numeric_limits<ll>::max();
const ll _llinf = numeric_limits<ll>::lowest();
const int inf = numeric_limits<int>::max();
const int _inf = numeric_limits<int>::lowest();
const double dinf = numeric_limits<double>::infinity();
const ll MOD = 1000000007;




ll a[100005];
ll b[100005];

int main(){ 

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

  priority_queue<int> pq;

  ll need = 0;
  int cnt = 0;
  rep(i,n){
    if(a[i] > b[i]){ pq.push(a[i]-b[i]);}
    elif(a[i] < b[i]){
      need += b[i] - a[i];
      cnt++;
    }
  }

  while(!pq.empty() && need > 0){
    int tmp = pq.top();
    pq.pop();
    need -= tmp;
    cnt++;
  }

  if(need > 0){prints(-1);}
  else{
    prints(cnt);
  }

  return 0;
}


Measured memory_bytes: 2176
// 5/9 過去問ガリガリ
#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;
    cin >> N;

    map<string, int> mp;

    int max = 0;

    rep(i, N) {
        string s;
        cin >> s;

        mp[s] += 1;

        // max = (max, mp[s]);
    }

    for(const auto& x : mp) {
        int v = x.second;
        if (v > max) max = v;
    }

    // vector<string> ans;

    // for (auto& [key, value] : mp) {
    //     if (value == max) {
    //         ans.push_back(key);
    //     }
    // }
    // for (const auto& x : mp) {
    //     if (x.second == max) {
    //         ans.push_back(x.first);
    //     }
    // }

    // sort(ans.begin(), ans.end());

    // for (auto an : ans) cout << an << endl;

    for (auto it = mp.begin(); it != mp.end(); it++) {
        if (it->second == max) {
            cout << it->first << endl;
        }
    }
}


Measured memory_bytes: 25216
#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" << "\n";
    }
    else{
        cout << "consonant" << "\n";
    }

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using  namespace std;

typedef long long ll;
typedef long long int lli;

int main()
{
  ll n; cin >> n;
  vector<lli> iv;

  for (int i = 0; i < n; i++) {
    lli x; cin >> x;
    iv.push_back(x - i);
  }

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

  // ivの中央値を計算する
  lli size = iv.size();
  lli b = iv[size / 2];

  lli sad = 0;

  for (lli x : iv) sad += abs(x - b);

  cout << sad << endl;

  return 0;
}


Measured memory_bytes: 2420
N, L = map(int, input().split()) 

a = [L + i - 1for i in range(1, N+1)]

a = sorted(a)

if 0 in a:
    print(sum(a))
    
elif a[-1] < 0:
    print(sum(a[:-1]))
    
else:
    print(sum(a[1:]))

Measured memory_bytes: 3060
#include<bits/stdc++.h>
// Begin Header {{{
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i,n) for(ll i=0; i<n; i++)
#define loop(i, j, n) for(ll i=j; i<n; i++)
#define all(x) (x).begin(), (x).end()
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
constexpr int INF  = 0x3f3f3f3f;
const long long mod=1e9+7;
const long double PI = acos(-1);
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }
// }}} End Header


int main() {
	ll n, ans = 0;
	cin >> n;
	vector<ll> a(n+1);
	loop(i, 1, n){
		for(ll j=i; j<n; j+=i){
			a[j]++;
		}
	}
	ans = accumulate(all(a), 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11060
from collections import defaultdict
from collections import deque
import itertools
import math

def readInt():
	return int(input())
def readInts():
	return list(map(int, input().split()))
def readChar():
	return input()
def readChars():
	return input().split()

n,k = readInts()

x = 0

for i in range(1,n+1):
	t=min(1/(2**math.ceil(math.log2(k)-math.log2(i))),1)
	x+=t
	#print(t)

print(x/n)

Measured memory_bytes: 68752
#include <iostream>
#include <vector>
#include <array>
#include <set>
#include <cmath>
#include <string>
#include <queue>
#include <list>
#include <unordered_map>
#include <algorithm>
#include <functional>
#include <iomanip> // std::std::setprecision(X)
#include <limits>  //std::numeric_limits<int>::max(), min()

int main (void) {

  int A, B, C; std::cin >> A >> B >> C;
  std::cout << ((A*B*C)/std::max({A,B,C}))/2 << std::endl;
  return 0;
}

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

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

  vector<long long> a(n);
  vector<long long> b(n);
  vector<long long> c(n);
  for (int i = 0; i < n; i++) {
    int tmp;
    cin >> tmp;
    a[i]=-tmp;
  }
  for (int i = 0; i < n; i++) cin >> b[i];
  for (int i = 0; i < n; i++) cin >> c[i];
  sort(a.begin(),a.end());
  sort(b.begin(),b.end());
  sort(c.begin(),c.end());

  long long ans=0;
  for (int i = 0; i < n; i++)
  {
    auto ita = upper_bound(a.begin(),a.end(),-b[i]);
    auto itc = upper_bound(c.begin(),c.end(),b[i]);
    long long cnta=a.end()-ita;
    long long cntc=c.end()-itc;
    ans+=cnta*cntc;
  }

  cout << ans << endl;
}

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

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  int c[n], a[n][m];
  int ans = -1;
  for ( int i = 0; i < n; i++ ) {
    cin >> c[i];
    for ( int j = 0; j < m; j++ ) {
      cin >> a[i][j];
    }
  }

  for (int bit = 0; bit < (1<<n); ++bit) {
    int now_cost = 0;
    int now_und[m];
    for ( int j = 0; j < m; j++ ) { now_und[j] = 0; }
    for ( int i = 0; i < n; i++ ) {
      if (bit & (1 << i)) {
        now_cost += c[i];
        for ( int j = 0; j < m; j++ ) {
          now_und[j] += a[i][j];
        }
      }
    }
    if ( ans != -1 && now_cost >= ans ) { continue; }
    bool cong = true;
    for ( int j = 0; j < m; j++ ) {
      if ( now_und[j] < x ) { cong = false; break; }
    }
    if ( cong ) { ans = now_cost; }
  }

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


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>
#include <stack>
#include <cstdint>



#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define rrep(i, n) for(ll i = (ll)(n-1); i >= 0; i--)
#define repi(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define rrepi(i,a,b) for(ll i=(ll)(b);i>=(ll)(a);i--)

#define all(x) (x).begin(),(x).end()

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

typedef long long ll;

using namespace std;


template <std::uint_fast64_t Modulus> class modint {
  using u64 = std::uint_fast64_t;

public:
  u64 a;

  modint(const u64 x = 0) noexcept : a(x % Modulus) {}
  u64 &value() noexcept { return a; }
  u64 &value() const noexcept { return a; }
  modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  modint &operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if (a >= Modulus) {
      a -= Modulus;
    }
    return *this;
  }
  modint &operator-=(const modint rhs) noexcept {
    if (a < rhs.a) {
      a += Modulus;
    }
    a -= rhs.a;
    return *this;
  }
  modint &operator*=(const modint rhs) noexcept {
    a = a * rhs.a % Modulus;
    return *this;
  }
  modint &operator/=(modint rhs) noexcept {
    u64 exp = Modulus - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
  modint pow(u64 exp){
    modint res=1,rhs=*this;
    while (exp) {
      if (exp % 2) {
        res *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return res;
  }

  friend ostream& operator<<(ostream& os,modint& rhs){
    os << rhs.value();
    return os;
  }

  friend istream& operator>>(istream &is,modint &rhs){
      is>>rhs.value();
      rhs.value()%=Modulus;
      return is;
  }

};
using mint=modint<(ll)1e9+7>;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,k;cin>>n>>k;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<mint>cnt(n,0),l(n,0);
  rep(i,n){
    rep(j,n){
      if(a[i]<a[j])cnt[i]+=1;
    }
  }
  rep(i,n){
    rep(j,i){
      if(a[i]<a[j])l[i]+=1;
    }
  }
  mint res=0;
  rep(i,n){
    res+=l[i]*k;
  }
  rep(i,n){
    res+=cnt[i]*(k*(k-1)/2);
  }
  cout<<res<<endl;



  return 0;

}


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

using namespace std;

const int MAXN = 1e3 + 5, MOD = 1e9 + 7;
int H, W;
char grid[MAXN][MAXN];
int dp[MAXN][MAXN];

int calcDp(int r, int c) {
    if (r < 0 || c < 0 || grid[r][c] == '#')
        return 0;
    if (dp[r][c] != -1)
        return dp[r][c];
    if (r == 0 && c == 0)
        dp[r][c] = 1;
    else
        dp[r][c] = (calcDp(r - 1, c) + calcDp(r, c - 1)) % MOD;
    return dp[r][c];
}

signed main() {
    cin >> H >> W;
    for (int i = 0; i < H; i++)
        for (int j = 0; j < W; j++) {
            cin >> grid[i][j];
            dp[i][j] = -1;
        }

    cout << calcDp(H - 1, W - 1) << endl;

    // dp[0][0] = 1;
    // for (int r = 0; r < MAXN; r++)
    //     for (int c = 0; c < MAXN; c++) {
    //         if (grid[r][c] == '#')
    //             continue;
    //         if (r > 0)
    //             dp[r][c] += dp[r - 1][c];
    //         if (c > 0)
    //             dp[r][c] += dp[r][c - 1];
    //     }
    // cout << dp[H - 1][W - 1] << endl;
}

Measured memory_bytes: 5248
#include<bits/stdc++.h>
using namespace std;
const int N=3e3;

int n;
double p[N],ans;
double dp[N][N];

int main()
{
	
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%lf",p+i);
	dp[1][1]=p[1];
	dp[1][0]=1-p[1];
	for(int i=1;i<n;i++)
	for(int j=0;j<=i;j++)
	{
		dp[i+1][j+1]+=dp[i][j]*p[i+1];
		dp[i+1][j]+=dp[i][j]*(1-p[i+1]);
	}
	for(int i=n/2+1;i<=n;i++)
		ans+=dp[n][i];
	printf("%.15f\n",ans);
	
	return 0;
}

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

int main()
{
	int N;
	string S;
	cin >> N >> S;
	for (int i = 0; i < S.size(); ++i)
		cout << (char)(((S[i] - 'A') + N) % 26 + 'A');
	cout << '\n';
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#define REP(i,n) for(int i=0;i<(n);++i)
#define INT_MAX 0x7FFFFFFF
#define MIN(a,b) ((a)<(b)?(a):(b))
#define ABS(a) ((a)<0?(-(a)):(a))
using namespace std;
typedef long long int LL;

int main(){
  int N, K = 2;
  int h[100000], c[100000];
  cin >> N;
  REP(i, N) {
    cin >> h[i];
    c[i] = INT_MAX;
  }
  c[0] = 0;
  REP(i, N) {
    for(int j=1; j<=K; ++j) {
      if(i+j < N) {
        c[i+j] = MIN(c[i+j],c[i]+ABS(h[i+j]-h[i]));
      }
    }
  }
  cout << c[N-1] << endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main()
{
	cin.tie(0);
	cin.sync_with_stdio(0);
	
	int n, k;
	cin >> n >> k;
	
	vector<int> a(n), dp(n);
	for(auto& x : a)
	  cin >> x;
	
	int const inf = ~0u >> 1;
	for(int i = 1; i < n; ++i) {
	  auto& v = dp[i];
	  v = inf;
	  for(int j = i - 1; i - j <= k && j >= 0; --j) {
	    v = min(v, dp[j] + abs(a[i] - a[j]));
	  }
	}
	cout << dp.back();
}

Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author Yulian
 */

#include <iostream>
#include <iostream>
#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


#include <iostream>

#include <fstream>
#include <vector>
#include <set>
#include <cmath>
#include <queue>
#include <deque>
#include <string>
#include <algorithm>
#include <map>


using namespace std;
class A {
public:
	void solve(std::istream& in, std::ostream& out) {
    ios::sync_with_stdio(false);
    int n, c, k, res, curr_dep, cur_num;
    res = cur_num = curr_dep = 0;
    in >> n >> c >> k;
    vector<int> t (n);
    for(int i = 0; i < n; ++i){
      in >> t[i];
    }
    sort(t.begin(), t.end());
    cur_num = 1;
    curr_dep = t[0] + k;
    for(auto i = 1; i < n; ++i){
      if(t[i] > curr_dep || cur_num >= c){
        ++res;
        cur_num = 1;
        curr_dep = t[i] + k;
      }else{
        ++cur_num;
      }
    }
    res++;
    out << res << endl;
	}
};


int main() {
	A solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<bitset>
#include<queue>
#include<set>
#include<map>
using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);++i)
#define ROF(i,b,a) for (int i=(b);i>(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,n-1,-1)

typedef int i32;
typedef long long int i64;
typedef unsigned long long int ui64;
typedef float f32;
typedef double f64;
typedef long double f128;
typedef pair<int,int> Pi;

constexpr int INF = 1e9 + 7;
constexpr int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

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

int main() {
    int N; cin>>N;
    i64 A[N],T[N];
    REP(i,N) {
        cin>>A[i]>>T[i];
    }
    REP(i,N-1) {
        i64 rate = max((A[i]+A[i+1]-1)/A[i+1],(T[i]+T[i+1]-1)/T[i+1]);
        A[i+1] *= rate;
        T[i+1] *= rate;
    }
    cout<<A[N-1]+T[N-1]<<endl;
}


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

double dp[301][301][301];
int main()
{
	int n;
	cin>>n;
	int a;
	int a1=0,a2=0,a3=0;
	for (int i = 0; i < n; ++i)
	{
	 	/* code */ cin>>a;
	 	if(a==1) a1++;
	 	if(a==2) a2++;
	 	if(a==3) a3++;
 	} 
 	for (int i = 0; i < 301; ++i)
 	{
 		for(int j = 0 ; j < 301 ; j++)
 		{
 			for(int k = 0 ; k < 301 ; k++)
 			{

 				dp[i][j][k] = 0;
 			}
 		}
 	}
 	// cout<<a1<<a2<<a3<<endl;
	for(int i=0;i<=a3;i++)
	{
		for(int j=0;j<=a3+a2;j++)
		{
			for(int k=0;k<n+1;k++)
			{

				if(i + j + k > n||i+j+k==0) continue;
				dp[i][j][k] = 0;
				if(i>0)dp[i][j][k] += (dp[i-1][j+1][k] + (double)n/(i+j+k))*(double)i/(i+j+k);
				if(j>0)dp[i][j][k] += (dp[i][j-1][k+1] +(double)n/(i+j+k))*(double)j/(i+j+k);
				if(k>0)dp[i][j][k] += (dp[i][j][k-1] +(double)n/(i+j+k))*(double)k/(i+j+k);
			}
		}
	}
	printf("%0.10lf\n",dp[a3][a2][a1]);
	return 0;
}

Measured memory_bytes: 213248
use std::io::*;
use std::str::FromStr;

#[allow(dead_code)]
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s = read::<String>();
    println!(
        "{}",
        match s.as_str() {
            "SUN" => 7,
            "MON" => 6,
            "TUE" => 5,
            "WED" => 4,
            "THU" => 3,
            "FRI" => 2,
            "SAT" => 1,
            _ => unreachable!(),
        }
    );
}


Measured memory_bytes: 2048
use std::io::BufRead;

fn main() {
    let stdin = std::io::stdin();
    let (n, _len): (usize, usize) = stdin.lock().gets().split(' ').values();
    let mut s = stdin.lock().lines().take(n).map(|x| x.unwrap())
        .collect::<Vec<_>>();
    s.sort();
    for x in s {
        print!("{}", x);
    }
    println!("");
}

trait Gets { fn gets(&mut self) -> String; }
impl<T: std::io::BufRead> Gets for T {
    fn gets(&mut self) -> String { self.lines().next().unwrap().unwrap() } }

trait Values<T> { fn values(&mut self) -> T; }
impl<'a, I, T1, T2> Values<(T1, T2)> for I
    where I: Iterator<Item=&'a str>,
          T1: std::str::FromStr, T1::Err: std::fmt::Debug,
          T2: std::str::FromStr, T2::Err: std::fmt::Debug {
    fn values(&mut self) -> (T1, T2) {
        (self.next().unwrap().parse().unwrap(),
         self.next().unwrap().parse().unwrap())
    }
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef pair<ll,ll> p2;
void solve(){
	ll n,res=0;
	cin>>n;
	for(ll i=1;i<=n;i++)
	if(i%3!=0&&i%5!=0)
	res+=i;
	cout<<res;
}
int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	ll qc=1;
	for(ll i=1;i<=qc;i++)
	solve();
}


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

int main(){
  int  n;
  cin>>n;
  int res=0;
  int num[3];
  while(n>1){
    if(n<=3) n=3;
    num[0]=n/3;
    num[1]=(n-num[0])/2;
    num[2]=n-num[1]-num[0];
    n=max(num[0],num[2]);
    res++;
    
  }
  cout << res<<endl;
  return 0;
}

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

int N;
vector<pair<long long int, long long int>> robots;

int main() {
    cin >> N;
    robots.resize(N);
    for (int i = 0; i < N; i++) {
        long long int x, l;
        cin >> x >> l;
        robots.at(i) = make_pair(x, l);
    }

    sort(robots.begin(), robots.end(), [](auto const &lhs, auto const &rhs) {
        return lhs.first + lhs.second < rhs.first + rhs.second; 
    });

// 1番右のロボットの右腕はどこまで伸びるか
    long long int right_arm = -1000000001;
    int res = 0;
    for (auto &e: robots) {
        if (e.first - e.second >= right_arm) {
            res++;
            right_arm = e.first + e.second;
        }
    }

    cout << res << endl;
}

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

int f(int x){
  if (x % 2 == 0){
    return x/2;
  }
  else{
    return 3*x +1;
  }
}

int main(){
  int s;
  cin >> s;
  if (s == 1 || s == 2 || s==4){
    cout << 4 << endl;
  }
  else{
    int count = 1;
  	int flag = 0;
  	while (flag == 0){
      s = f(s);
      count ++;
      if (s == 4){
        cout << count + 3 << endl;
        flag = 1;
      }
    }
  }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    cout << (a + b >= 24 ? a + b - 24 : a + b);
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
    int N,M;
    cin >> N >> M;
    int food[M+2] = {};

    int A = 0;
    int k = 0;
    for(int i = 0; i < N; i++)
    {
        cin >> k;

        /* code */
        for(int j = 0; j < k; j++)
        {
            /* code */
            cin >> A;
            food[A+1]++;
        }
    }

    int ans = 0;
    for(int i = 0; i <= M; i++)
    {
        /* code */
        //cout << "aa:"  << food[i+1] << endl;
        if(food[i+1] == N){
            ans++;
        }
    }
    cout << ans << endl;
    


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
#define rep(i,a,b) for (int i = (a); i < (b); i++ )
typedef pair<int,int> P;
typedef long long ll;
const int INF = 100000000;


int main (){
    int a,b,c,x,y;
    cin >> a >> b >> c >> x >> y;

    int ans;

    ans = a*x+b*y;

    ans = min(ans,(max(x,y)*2*c));

    int tmp;

    if (x>y) {
        ans = min(ans,(x-y)*a+y*2*c);

    }
    if (x<y) {
        ans = min(ans,(y-x)*b+x*2*c);

    }

    cout << ans << endl;



}




Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	int A[n];
	for(int i=0; i<n; i++)
		cin>>A[i];
	int m;
	cin>>m;
	int B[m];
	for(int i=0; i<m; i++)
		cin>>B[i];
	int flag=0;
	int i;
	for(i=0; i<min(n,m); i++){
		if(B[i]>A[i]){
			flag=1;
			break;
		}
		else if(A[i]>B[i]) break;
	}
	if(i==n && i<m)
		flag=1;
	cout<<flag<<endl;
	return 0;
}


Measured memory_bytes: 3116
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace AtCoder
{

    class Program
    {
        static void Main()
        {
            Solve();

            Console.ReadKey();
        }

        static void Solve()
        {
            var s = GetIntArray();
            var ans = s[0] * s[1] % 2 != 0 ? "Odd" : "Even";

            Console.Write(ans);
        }



        static public string GetStr() { return Console.ReadLine(); }
        static public int GetInt() { return int.Parse(Console.ReadLine()); }
        static public long GetLong() { return long.Parse(Console.ReadLine()); }
        static public string[] GetStrArray() { return Console.ReadLine().Split(' '); }
        static public int[] GetIntArray() { return Console.ReadLine().Split(' ').Select(int.Parse).ToArray(); }
        static public long[] GetLongArray() { return Console.ReadLine().Split(' ').Select(long.Parse).ToArray(); }
        static public List<double> GetDoubleList() { return Console.ReadLine().Split(' ').Select(double.Parse).ToList(); }
        static public void WriteObjects<T>(IEnumerable<T> values) { foreach (var o in values) { Console.Write(o + " "); } }

        static bool eq<T, U>() => typeof(T).Equals(typeof(U));
        static T ct<T, U>(U a) => (T)Convert.ChangeType(a, typeof(T));
        static T cv<T>(string s) => eq<T, int>() ? ct<T, int>(int.Parse(s))
                           : eq<T, long>() ? ct<T, long>(long.Parse(s))
                           : eq<T, double>() ? ct<T, double>(double.Parse(s))
                           : eq<T, char>() ? ct<T, char>(s[0])
                                             : ct<T, string>(s);
        static void Multi<T>(out T a) => a = cv<T>(GetStr());
        static void Multi<T, U>(out T a, out U b)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]);
        }
        static void Multi<T, U, V>(out T a, out U b, out V c)
        {
            var ar = GetStrArray(); a = cv<T>(ar[0]); b = cv<U>(ar[1]); c = cv<V>(ar[2]);
        }
    }
}

Measured memory_bytes: 13268
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

var sc = bufio.NewScanner(os.Stdin)

func readString() string {
	sc.Scan()
	return sc.Text()
}

func readStrings() []string {
	return strings.Split(readString(), " ")
}

func readInts() []int {
	line := readStrings()
	ints := make([]int, 0)
	for _, s := range line {
		val, err := strconv.Atoi(s)
		if err != nil {
			panic(err)
		}
		ints = append(ints, val)
	}
	return ints
}

func main() {
	xy := readInts()

	fmt.Println(xy[0] + xy[1]/2)
}

Measured memory_bytes: 640
#include<iostream>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<set>
#include<stdio.h>
#include<ctype.h>
using namespace std;
int main()
{
	int n;
	cin >> n;
	if (n % 2 == 0)
	{
		cout << n / 2 - 1 << endl;
	}
	else
	{
		cout << n / 2 << endl;
	}
}

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

int main(){
  int N,K;
  cin >> N >> K;
  int high[N];
  int count=0;
  for(int i=0;i<N;i++){
    cin >> high[i];
    if(high[i]>=K){
      count++;
    }
  }
  cout << count << endl;

  return 0;
} 


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dup(x,y) (((x)+(y)-1)/(y))
#define ALL(x) (x).begin(), (x).end()
typedef long long ll;
typedef pair<int, int> pii;
const double EPS = 1e-10;
const int INF = 1e9;
const ll LINF = 1e18;
const int MOD = 1000000007;
const double PI = acos(-1);
int dx[4] = {0,1,0,-1};
int dy[4] = {1,0,-1,0};

int main() {
	int a, b;
	cin >> a >> b;
	vector<vector<char>> g(100, vector<char>(100, '.'));
	rep(i,50) {
		rep(j,100) g[i][j] = '#';
	}
	int cnt1 = 1;
	rep(i,50) {
		if (cnt1 == a) break;
		if (i % 2 == 1) continue;
		rep(j,100) {
			if (cnt1 == a) break;
			if (j % 2 == 1) continue;
			g[i][j] = '.';
			cnt1++;
		}
	}
	int cnt2 = 1;
	for (int i = 99; i >= 0; i--) {
		if (cnt2 == b) break;
		if (i % 2 == 0) continue;
		rep(j,100) {
			if (cnt2 == b) break;
			if (j % 2 == 0) continue;
			g[i][j] = '#';
			cnt2++;
		}
	}

	cout << 100 << " " << 100 << endl;
	rep(i,100) {
		rep(j,100) cout << g[i][j];
		cout << endl;
	}
}

Measured memory_bytes: 3648
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>

using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;


// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// -------------------------------------------------------------------------------------

int main() {
  string a, b, c;
  cin >> a >> b >> c;
  if(a[a.length()-1] == b[0] && b[b.length()-1] == c[0]) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
const ll mod=1000000007;
const int MAX_N = 1000;         // n の最大値
 
// nCk を取得
double nCk(int n, int k) {
double res=1.0;
for(int i=0; i<n; i++){
res*=0.5;}
for(int i=0; i<k; i++){
res*=(double)(n-i);
res/=(double)(k-i);
}
return res;}
 
int main() {
ll h,w,k;
cin>>h>>w;
ll c=-500;
c =max(h+w,c);
c = max(h-w,c);
c = max(h*w , c);
cout << c << endl;
}


Measured memory_bytes: 3632
import bisect, copy, heapq, math, sys
from collections import *
from functools import lru_cache
from itertools import accumulate, combinations, permutations, product
def input():
    return sys.stdin.readline()[:-1]
def ruiseki(lst):
    return [0]+list(accumulate(lst))
def celi(a,b):
    return -(-a//b)
sys.setrecursionlimit(5000000)
mod=pow(10,9)+7
al=[chr(ord('a') + i) for i in range(26)]
direction=[[1,0],[0,1],[-1,0],[0,-1]]

n=int(input())
if n<1:
    print(0)
    exit()

zero=pow(10,n,mod)-pow(9,n,mod)
nine=pow(10,n,mod)-pow(9,n,mod)
ans=zero+nine-(pow(10,n,mod)-pow(8,n,mod))
print(ans%mod)

Measured memory_bytes: 68192
#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>

#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>
#include <regex>
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,j,n) for(int i = j; i < n; i++)
#define rrep(i,j,n) for(int i = j-1; i >= n; i--)
#define prec(n) fixed << setprecision(n)
#define print_array(v) rep(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define MOD 1e+7
#define inf 1e9
#define fi first
#define se second
using namespace std;

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

  int n;
  string s;
  cin >> n >> s;
  vector<int> w(n+1, 0);
  vector<int> e(n+1, 0);
  rep(i,n) {
    int W = 0, E = 0;
    if(s[i] == 'W') W++;
    if(s[i] == 'E') E++;
    w[i+1] = w[i] + W;
    e[i+1] = e[i] + E;
  }

  int res = inf;
  rep(i,n+1) {
    int cur = 0;
    cur += e[n] - e[i];
    cur += w[i];
    res = min(res, cur);
  }
  cout << res << endl;
  return 0;
}
//templete by private_yusuke

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

const string alpha = "abcdefghijklmnopqrstuvwxyz";

int main(){
  string s;
  cin >> s;
  vector<int> v(26,0);
  for(int i = 0; i < s.size();i++){
    for(int j = 0; j < 26;j++){
      if(s.at(i) == alpha.at(j)){
        v.at(j)++;
      	break;
      }
    }
  }
  int index = 27;
  for(int i = 0; i < 26;i++){
    if(v.at(i) == 0) {
      index = i;
      break;
    }
  }
  if(index == 27) cout << "None" << endl;
  else cout << alpha.at(index) << endl;
}

Measured memory_bytes: 512
n,w0=map(int,input().split())
v=[]
w=[]
for _ in range(n):
	V,W=map(int,input().split())
	v.append(V)
	w.append(W)

#knapsack with no restriction
dp=[[0]*(w0+1) for _ in range(n+1)]
#print(dp)
for i in range(n):
	for j in range(w0+1): #iが小さいほうから埋まっていくので昇順
		if j-w[i]<0:
			dp[i+1][j]=dp[i][j]
		else:
			dp[i+1][j]=max(dp[i][j],dp[i+1][j-w[i]]+v[i])
print(dp[n][w0])
#dp[0][j]は0番目まで選んだとする。何も選んでないと言うこと。
#通常のナップサックの場合、何も選んでいないのはdp[n][j]。n番目以降から選ぶが、番号は[0:n-1]でふられている。


Measured memory_bytes: 15684
n=int(input())
comments=[]
for i in range(n):
    num=int(input())
    comment=[]
    for j in range(num):
        comment.append(list(map(int,input().split(" "))))
    comments.append(comment)
#print(comments)

ans=0
for i in range(2**n):
    judges=[[] for i in range(n)]
    condition=list(str(format(i,'b').zfill(n)))
    conflict=False
    #print(condition)
    for idx,j in enumerate(condition):
        person_num=idx
        if j=='1':
            for comment in comments[person_num]:
                judges[comment[0]-1].append(comment[1])
    for jdx,judge in enumerate(judges):
        if len(judge)==0:
            pass
        if judge.count(int(condition[jdx])) != len(judge):
            conflict=True
            break
    if not conflict:
        ans=condition.count('1')
    #print(judges)
print(ans)

Measured memory_bytes: 49244
import java.util.*;

public class Main {
	static int N=26;
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		N = sc.nextInt();
		int data[] =new int[N];

		ArrayList<Double> ar =new ArrayList<Double>();
	
		for(int i=0;i<data.length;i++) {
			double a=sc.nextInt();
			ar.add(a);
		}
		Collections.sort(ar);
		double tt=ar.get(0);
		ar.remove(0);
		while(true) {
			double t1 =tt+ar.get(0);
			tt= (double)t1 / 2.0;
			ar.remove(0);
			
			if(ar.size()==0)break;
		}
		System.out.println(tt);
		
		
		

	}

}


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

#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
#define pb push_back
#define fst first
#define snd second
typedef long long ll;
typedef pair<int,int> pii;

const int maxn=3005;
int n,mod,ans;
int fac[maxn],ifac[maxn],f[maxn][maxn];

int C(int a,int b){
	if(a<0||b<0||a<b)return 0;
	return 1LL*fac[a]*ifac[b]%mod*ifac[a-b]%mod;
}
int power(int x,int pow,int mod){
	int res=1;
	for(;pow;pow>>=1){
		if(pow&1)res=1LL*res*x%mod;
		x=1LL*x*x%mod;
	}
	return res;
}

int main(){
	scanf("%d%d",&n,&mod);
	fac[0]=fac[1]=ifac[0]=ifac[1]=1;
	for(int i=2;i<=n;i++){
		fac[i]=1LL*fac[i-1]*i%mod;
		ifac[i]=1LL*ifac[mod%i]*(mod-mod/i)%mod;
	}
	REP(i,n)ifac[i]=1LL*ifac[i-1]*ifac[i]%mod;
	f[0][0]=1;
	REP(i,n)rep(j,n+1){
		f[i][j]=f[i-1][j];
		if(j){
			f[i][j]+=f[i-1][j-1];
			if(f[i][j]>=mod)f[i][j]-=mod;
		}
		f[i][j]+=1LL*f[i-1][j]*j%mod;
		if(f[i][j]>=mod)f[i][j]-=mod;
	}
	rep(i,n+1){
		int cur=power(2,n-i,mod),coef=1LL*C(n,i)*power(2,power(2,n-i,mod-1),mod)%mod,now=1;
		if(i&1)coef=(mod-coef)%mod;
		rep(j,i+1){
			ans+=1LL*f[i][j]*now%mod*coef%mod;
			if(ans>=mod)ans-=mod;
			now=1LL*now*cur%mod;
		}
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 35456
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
#include<queue>
#include<map>
#include<set>
using namespace std;
#define ll long long
const int maxn=2e5+5;
int n,k,a[maxn];
int sum[maxn];
void add(int pos,int val)
{
    while(pos<=n)
    {
        sum[pos]+=val;
        pos+=pos&(-pos);
    }
    return;
}
int query(int pos)
{
    int res=0;
    while(pos)
    {
        res+=sum[pos];
        pos-=pos&(-pos);
    }
    return res;
}
int main()
{
    scanf("%d%d",&n,&k);
    for(int i=1;i<=n;i++)
        scanf("%d",&a[i]);
    while(k--)
    {
        memset(sum,0,sizeof(sum));
        for(int i=1;i<=n;i++)
        {
            int l=max(1,i-a[i]),r=min(n,i+a[i]);
            add(l,1); add(r+1,-1);
        }
        ll tot=0;
        for(int i=1;i<=n;i++)
        {
            a[i]=query(i);
            tot+=(ll)a[i];
        }
        if(tot==(ll)n*n) break;
    }
    for(int i=1;i<=n;i++)
        printf("%d%c",a[i],(i==n?'\n':' '));
    return 0;
}


Measured memory_bytes: 5372
import math

def mapt(fn, *args):
    return tuple(map(fn, *args))

n, d = mapt(int, input().split(" "))
list1 = [mapt(int, input().split(" "))  for i in range(n)]


def calc(args):
    x, y = args
    return math.sqrt((x**2) + (y**2))

print(sum(calc(i)<=d for i in list1))

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

#define ll long long
#define endl "\n"
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

//const int MOD = 1e9 + 7;
//typedef unsigned long long u64;
//const double pi = 3.141592653589793238460;

const int MAX = 1e5 + 5;
int arr[MAX];

int main()
{
	IOS
	int t = 1;
	//cin >> t;
	while(t--)
	{
		int x, y;
		cin >> x >> y;
		if((y & 1) == 1) cout << "No\n";
		else if(y < 2 * x || y > 4 * x) cout << "No\n";
		else if(y >= 2 * x && y <= 4 * x && y % 2 == 0) cout << "Yes\n";
	}
	return 0;
}


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

int main() {
  int n, m, c, ans = 0;
  cin >> n >> m >> c;
  vector<int> b(m);
  for (int i = 0; i < m; i++)
  {
    cin >> b[i];
  }
  vector<vector<int>> a(n, vector<int>(m));
  for (int i = 0; i < n; i++)
  {
    for (int j = 0; j < m; j++)
    {
      cin >> a[i][j];
    }
    
  }

  for (int i = 0; i < n; i++)
  {
    int T = c;
    for (int j = 0; j < m; j++)
    {
      T += a[i][j]*b[j];
    }
    if (T > 0)
    {
      ans++;
    }
    
  }
  cout << ans << endl;
  
  return 0;

}


Measured memory_bytes: 3604
#include <iostream>

using namespace std;

int main() {
  int n[4], sum;
  char a, b, c, d;
  char operands[3];
  scanf("%c%c%c%c", &a, &b, &c, &d);
  n[0] = a - '0';
  n[1] = b - '0';
  n[2] = c - '0';
  n[3] = d - '0';

  for(int flag = 0; flag < 8; flag++){
    sum = n[0];
    for(int i = 1; i < 4; i++){
      if((flag >> (i-1)) & 1){
        sum += n[i];
        operands[i-1] = '+';
      } else {
        sum -= n[i];
        operands[i-1] = '-';
      }
    }
    if(sum == 7){
      printf("%d%c%d%c%d%c%d=7\n", n[0], operands[0], n[1], operands[1], n[2], operands[2], n[3]);
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 256
//
//  alds1_1_d_maximum_profit.cpp
//  aoj
//
//  Created by Sei Kataoka on 2/5/16.
//  Copyright ?? 2016 Sei Kataoka. All rights reserved.
//

#include <iostream>

using namespace std;

static const int MAX = 200000;

int main() {
    int n;
    int r[MAX];
    cin >> n;
    for (int i = 0; i < n; ++i) cin >> r[i];

    int maxv = -1000000000;
    int minv = r[0];

    for (int i = 0; i < n - 1; ++i) {
        if (minv > r[i]) minv = r[i];
        if (r[i + 1] - minv > maxv) maxv = r[i + 1] - minv;
    }

    cout << maxv << endl;

    return 0;
}

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

int main()
{
    int N;
    cin >> N;
    
    int A[N];
    for (int i = 0; i < sizeof(A)/sizeof(*A); i++)
    {
        cin >> A[i];
    }
    sort(A, A + N, greater<int>());
    
    cout << A[0] - A[N-1] << endl;
    
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int a,b,c,d;
int main(){
	cin>>a>>b>>c>>d;
	if(abs(a-c)<=d||(abs(a-b)<=d&&abs(b-c)<=d)) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}

Measured memory_bytes: 764