akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iomanip>
using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=(b-1);i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007

ll da[100100];
ll dd[330][330];

int main() {
	clr(da,0);
	ll h,w,d;
	cin>>h>>w>>d;
	vector<pair<ll,pair<ll,ll> > > v;
	v.pb(mp(0,mp(0,0)));
	rep(y,0,h){
		rep(x,0,w){
			ll a;
			cin>>a;
			v.pb(mp(a,mp(y,x)));
		}
	}
	sort(all(v));
	rep(i,d+1,h*w+1){
		ll y1 = v[i].se.fi;
		ll x1 = v[i].se.se;
		ll y2 = v[i-d].se.fi;
		ll x2 = v[i-d].se.se;
		da[i] += da[i-d] + abs(y1-y2) + abs(x1-x2);
	}
	ll q;
	cin>>q;
	rep(i,0,q){
		ll l,r;
		cin>>l>>r;
		cout << da[r]-da[l] << endl;
	}
	return 0;
}

Measured memory_bytes: 5620
#include <iostream>
#include <cstring>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
string a,b;
int main()
{
	cin >> a >> b;
	int len = a.size();
	int lne1 = b.size();
	int i=0;
	int ans ,minx = 999999;
	while(i < len - lne1 + 1)
	{
		ans = 0;
		int j=i;
		int x=0;
		while(x < lne1)
		{
			if(a[j] != b[x]) ans++;
			x++,j++;
		}		
		if(ans < minx) minx = ans;
		i++;
	}
	cout << minx << endl;
}

Measured memory_bytes: 3632
N = int(input())
H = list(map(int, input().split()))

ans='Yes'
pre=-000
if N > 1:
    for i in range(0, len(H)):
        if (pre <= H[i] - 1):
            pre = H[i] - 1
            continue
        elif (pre <= H[i]):
            pre = H[i]
            continue
        else:
            ans = 'No'
            break

print(ans)

Measured memory_bytes: 14396
#include<iostream>
#include<stdio.h>
using namespace std;

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

Measured memory_bytes: 1152
tiles=list(map(int,input()))
def create(x,y):
    sample=[]
    for i in range(0,len(tiles)):
        if i%2==0:
            sample.append(x)
        else:
            sample.append(y)
    return sample

sample1=create(1,0)
sample2=create(0,1)

def dif_count(list):
    count=0
    for i in range(0,len(list)):
        if list[i]!=tiles[i]:
            count+=1
    return count
print(min(dif_count(sample1),dif_count(sample2)))


Measured memory_bytes: 5536
#include <bits/stdc++.h>
using namespace std;
 
double SUM(double p){
	double a=0;
    for(int i=1;i<=p;i++) a+=i;
    return a/p;
}
int main(){
	int n,k;
    double ans=0;
    cin>>n>>k;
    double p[n];
    for(int i=0;i<n;i++){
        double q;
        cin>>q;
        p[i]=SUM(q);
    }
    for(int i=0;i<k;i++) ans+=p[i];
    double sum=ans;
    for(int i=0;i<=n-k;i++){
        sum=sum+p[i+k]-p[i];
    	ans=max(sum,ans);
    }
    cout<<setprecision(16)<<ans;
}


Measured memory_bytes: 5336
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int n;
	cin>>n;
	n = n%10;
	//cout<<n<<endl;
	if(n==2||n==4||n==5||n==7||n==9)
	cout<<"hon\n";
	else if(n==0||n==1||n==6||n==8)
	cout<<"pon\n";
	else
	cout<<"bon\n";
	return 0;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod=1e9+7;
const int maxn=1e5+5;
const int maxm=5e2+5;
const int maxq=55;
const int INF=0x3f3f3f3f;
int main()
{
    ll n,k;
    while(~scanf("%lld%lld",&n,&k))
    {
        ll num=n/k;
        ll ans=num*num*num;
        if(k%2==0)
        {
            num=(n+k/2)/k;
            ans+=num*num*num;
        }
        printf("%lld\n",ans);
    }
}


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

int main(){
  int A,B;
  cin >> A >>B;
  
  if(A!=1 && B!=1){
    cout << 1 <<endl;
  }
  if(A!=2 && B!=2){
    cout << 2 <<endl;
  }
  if(A!=3 && B!=3){
    cout << 3 <<endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define speed ios_base::sync_with_stdio(false) , cin.tie(NULL) , cout.tie(NULL);

int main()
{
    speed;

    int n;
    cin>>n;

    vector<int>v(n);
    int ans=INT_MAX;

    for(int i=0;i<n;i++) cin>>v[i];

    for(int i=-100;i<=100;i++)
    {
        int cal=0;

        for(int j=0;j<n;j++)
        {
            cal+=((v[j]-i)*(v[j]-i));
        }

        ans=min(ans,cal);
    }

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

Measured memory_bytes: 3628
s = str(input())

def is_kaibun(kaibun):
    for i in range(len(kaibun)//2):
        if kaibun[i] != kaibun[-i-1]:
            return False
    return True

n = len(s)
sub1 = s[0:(n - 1)//2]
sub2 = s[(n + 3)//2 - 1:n + 1]

if is_kaibun(s) and is_kaibun(sub1) and is_kaibun(sub2):
    print('Yes')
else:
    print('No')

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

int main(){
    int N,R;cin>>N>>R;
    if(N<10){
        cout<<R+100*(10-N)<<endl;
        return 0;
    }else{
        cout<<R<<endl;
    }
    return 0;
}

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

int k ; 
int main(){
    int N ;
    cin >> N ;
    vector<int> A(N,0) ; 
    vector<int> keep(1000000+5, 0); 
    for(int i = 0; i < N ; i++){
        cin >> k ; 
        A[i] = k ; 
        keep[k]++ ; 
    }
    if(keep[1] > 1 ){
        cout << 0 << endl ; 
        return 0 ; 
    }
    if(keep[1] == 1){
        cout << 1 << endl ;
        return 0 ;
    }
    int ans = 0 ; 
    for(int i = 0 ; i < N ; i++){
        int m = 2 ; 
        int now = A[i] ; 
        bool flag = 1  ; 
        while(1){
            if(m * m >  now) break ; 
            if(now % m == 0 && (keep[m] >= 1 || keep[now / m] >= 1)){
                flag = 0 ; 
                break ; 
            }
            m++ ; 
        }
        if(flag && keep[now] == 1 ) ans++ ; 
    }
    cout << ans << endl ; 
    
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = (1 << 30) - 1;
const long long LLINF = 1LL << 61;
const long long MOD = 1000000007LL;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n;
    cin >> n;

    vector<lint> a(n);
    rep(i, n){
        cin >> a[i];
        a[i] -= i + 1;
    }
    SORT(a);

    lint b = a[n / 2];

    lint ans = 0;
    rep(i, n){
        ans += abs(a[i] - b);
    }

    cout << ans << endl;

    return 0;
}

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

int main() {
  int N;
  cin >> N;
  int Alice = 0;
  int Bob = 0;
  
  vector<int> A(N);
  for(int i=0; i<N; i++)
    cin >> A.at(i);
    
  sort(A.begin(),A.end());
  reverse(A.begin(),A.end());
  
  for(int i=0; i<N; i++){
    if (i%2 == 0) {
      Alice += A.at(i);
    } else {
	  Bob += A.at(i);
	}
  }
  
  cout << Alice - Bob << endl;
  
}



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

using namespace std;
#define rep(i,i0,n) for(int i=(i0);i<(int)(n);++i)
typedef vector<int> vi; typedef pair<int,int> pii; typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vii;
typedef long long ll;


int main(){
    int a,b;
    cin>>a>>b;
    int tab[1001]={};
    rep(i,1,1000){
        tab[i]=i+tab[i-1];
    }
    cout<<tab[b-a]-b<<endl;
	return 0;
}



Measured memory_bytes: 256
from itertools import accumulate
from bisect import bisect

n, m, k = map(int, input().split())
a = [*map(int, input().split())]
b = [*map(int, input().split())]
ca = [*accumulate(a, initial=0)]
cb = [*accumulate(b, initial=0)]
print(max(i - 1 + bisect(cb, k - x) for i, x in enumerate(ca) if x <= k))


Measured memory_bytes: 49408
#include <iostream>
#include <string>
#include <vector>
#include <numeric>
#include <queue>
#include <unordered_map>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <sstream>
#include <stack>
#include <map>
#include <set>

#define REP(i,a) for(int i = 0;i < (a);++i)
#define FOR(i,a,b) for(int i = (a);i < (b); ++i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SIZE(obj) (int)(obj).size()
#define MAX(list) std::max(list)
#define MIN(list) std::min(list)

template<typename T>
T round_up(const T& a, const T& b) {
    return (a + (b - 1)) / b;
}

using ll = long long;
using namespace std;
ll mod = 1e9 + 7;

const ll INF = 10500000000000;

int main() {
    int A, B, Q;
    cin >> A >> B >> Q;
    vector<ll> s(A + 2), t(B + 2), x(Q);
    s[0] = -INF;
    s[A + 1] = INF;
    t[0] = -INF;
    t[B + 1] = INF;
    REP(i, A)cin >> s[i + 1];
    REP(i, B)cin >> t[i + 1];
    REP(i, Q)cin >> x[i];

    REP(i, Q) {
        ll len = x[i];

        auto aIt = lower_bound(ALL(s), len);
        ll sa = *aIt - len;
        ll sb = -(*(aIt - 1) - len);
        auto bIt = lower_bound(ALL(t), len);
        ll ta = *bIt - len;
        ll tb = -(*(bIt - 1) - len);
        ll ans = std::min({ max(sa, ta), max(sb, tb), sa * 2 + tb, sb * 2 + ta, ta * 2 + sb, tb * 2 + sa });
        cout << ans << endl;
    }
    return 0;
}

Measured memory_bytes: 3712
//#include<bits/stdc++.h>
 
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
 
#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
 
using namespace std;
 
int main()
{
	int n; cin >> n;
	vector < pair < long long , long long > > a;
	for (int i = 1; i <= n; i++) 
	{
		long long x, y; cin >> x >> y;
		a.push_back({x, y});
	}
	sort(a.begin(), a.end());
 	
	if (n == 1) 
	{
		cout << 1;
		return 0;
	}

	int answer = 1293132;
	for (int i = 0; i < (int)a.size(); i++)
	{
		for (int j = i + 1; j < (int)a.size(); j++)
		{
			long long d1 = a[j].first - a[i].first, d2 = a[j].second - a[i].second;
 
			set < pair < long long , long long > > s;
			int ans = 0;
			for (int g = 0; g < (int)a.size(); g++)
			{
				if (s.find({a[g].first - d1, a[g].second - d2}) == s.end()) ans++;
				s.insert(a[g]);
			}
 
			answer = min(answer, ans);
		}
	}
 
	cout << answer;
	return 0;
}

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

#define ll long long 


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

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


int main(){
	ll a,b;
	cin >> a >> b;
	cout << lcm(a,b) << endl;
}

Measured memory_bytes: 256
n = gets
slimes = gets.chomp.split(' ').map(&:to_i)
len = slimes.length
spells = 0
before = -1
len.times do |i|
  if before == slimes[i]
    before = -1
    spells += 1
  else
    before = slimes[i]
  end
end
puts spells


Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define pw(x) (1LL << (x))
#define db(x) cerr << #x << " = " << x << endl
#define db2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl

using namespace std;
typedef long long ll;
typedef double dbl;
const int INF = 1.01e9;



int main() {
#ifdef HOME
    assert(freopen("in", "r", stdin));
#endif

    int n;
    string s;
    while (cin >> n >> s) {
        ll ans = 0;
        for (int mask = 0; mask < (1 << n); mask++) {
            string t(n, '#');
            int c1 = 0, c2 = 0;
            for (int i = 0; i < n; i++) {
                if (mask & (1 << i)) {
                    t[c1++] = s[i];
                } else {
                    t[n - 1 - c2++] = s[i];
                }
            }
            vector<vector<ll>> dp(n + 1, vector<ll>(n + 1));
            dp[0][c1] = 1;
            for (int i = 0; i < n; i++) {
                char c = s[n + i];
                for (int j = 0; j <= n; j++) {
                    if (j < n && c == t[j]) {
                        dp[i + 1][j + 1] += dp[i][j];
                    }
                    int jj = n + i - j;
                    if (jj != n && c == t[n - 1 - jj]) {
                        dp[i + 1][j] += dp[i][j];
                    }
                }
            }
            ans += dp[n][n];
        }
        cout << ans << endl;
    }

#ifdef HOME
    cerr << "time = " << (clock() * 1. / CLOCKS_PER_SEC) << "\n";
#endif
    return 0;
}

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

#define INF 10E+09
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

int main() {
  long long int x, ans, tmp;
  cin >> x;
  tmp = 100;
  ans = 0;
  while(x > tmp) {
    tmp *= 1.01;
    ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3624
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
 
int main() {
    string S, T;
    cin >> S >> T;
 
    
    int ans = T.size();

    for (int start = 0; start <= S.size() - T.size(); start++)
    {
        int diff = 0;
        for (int i = 0; i < T.size(); i++)
        {
            if (T[i] != S[start + i]) {
                diff++;
            }
        }
        ans = min(ans, diff);
    }
 
    cout << ans << endl;
}

Measured memory_bytes: 3564
#include<cstdio>
#include<iostream>
using namespace std;
int main(){
	int n;
	cin>>n;
	if(n==1){
		cout<<"Yes";
		return 0;
	}
	int a,b;
	cin>>a;
	for(int i=2;i<=n;i++){
		cin>>b;
		if(a-b==1){
			b++;
		}
		if(a-b>1){
			cout<<"No";
			return 0;
		}
		a=b;
	}
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
a = list(map(int,input().split()))
lis_now = set(a[1:])
like = lis_now
for i in range(n-1):
    a = list(map(int,input().split()))
    lis_new = set(a[1:])
    like = like & lis_new
    lis_now = set(lis_new)
print(len(like))

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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
   ll n,m;cin >>n>>m;
   m--;
   vector<int>a(n);
   ll sum=0;
    for (int i = 0; i < n; ++i) {
        cin >>a[i];
        sum+=a[i];
    }
    sort(all(a));
    reverse(all(a));
    if(a[m]*4*(m+1)>=sum)puts("Yes");
    else puts("No");
}


Measured memory_bytes: 3612
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;



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

	int a, b;
	cin >> a >> b;

	int ma = max(a, b);

	int mi = min(a, b);



	REP(i, ma)cout << mi;
	cout << endl;
	return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <functional>
#include <bitset>

using namespace std;
#define int long long int
const int INF = 1001001001001001LL;
const int MOD = 1000000007;

int di[] = {-1, 0, 1, 0, -1, 1, 1, -1};
int dj[] = {0, 1, 0, -1, 1, 1, -1, -1};

signed main(){
  
  int n, m; cin >> n >> m;
  vector<pair<int, int>> p(n);
  for(int i = 0; i < n; i++){
    int a, b; cin >> a >> b;
    p[i] = {a, b};
  }

  sort(p.begin(), p.end());
  int idx = 0;
  priority_queue<int> pq;

  int ans = 0;
  for(int i = 1; i <= m; i++){
    // a <= i は全て突っ込む
    while(idx < n and p[idx].first <= i){
      pq.push(p[idx].second);
      idx++;
    }
    
    // 一番いいやつをスコアに入れる
    if(!pq.empty()){
      ans += pq.top();
      pq.pop();
    }
  }

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


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

// @@ !! LIM()

int main(/* int argc, char *argv[] */) {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  cout << setprecision(20);

  ll X, K, D; cin >> X >> K >> D;
  if (X < 0) X = -X;
  ll t = X / D;
  if (t > K) {
    cout << X - D * K << endl;
    return 0;
  }
  ll y = X - D * t;
  K -= t;
  if (K % 2 == 0) {
    cout << y << endl;
  }else {
    cout << D - y << endl;
  }

  return 0;
}



Measured memory_bytes: 3632
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.math.BigInteger;

public class Main {

	public static void main(String[] args) {
		try{
			BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
			BigInteger first = new BigInteger(br.readLine());
			BigInteger second = new BigInteger(br.readLine());
			switch(first.compareTo(second)){
			case 1:
				System.out.println("GREATER");
				break;
			case 0:
				System.out.println("EQUAL");
				break;
			case -1:
				System.out.println("LESS");
			}
			
		}catch(Exception e){
			e.printStackTrace();
		}
	}

}


Measured memory_bytes: 23124
//package AtCoder;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		int k=sc.nextInt();
		int[] a=new int[n];
		for(int i=0;i<n;i++)
			a[i]=sc.nextInt();
		//int[] pre=new int[n];
		
		for(int i=1;i<n;i++)
		{
			a[i]+=a[i-1];
		}
		int max=a[k-1];
		int start=0;
		for(int i=k;i<n;i++)
		{
			int maybe=a[i]-a[start];
			if(maybe>max)
				max=maybe;
			start++;
		}
		double ans=(double)(max+k)/2;
		System.out.printf("%.12f",ans);

	}

}


Measured memory_bytes: 71772
/*
     DoS
 */

#include <cstdio>
#include <vector>
#include <algorithm>
using namespace std;

#define INF 0xffffffff

int r;
int c;
int q;
long long int sizex;
long long int sizey;
long long int const2d;
unsigned int grid[10000000];

void update(long long int x, long long int y, unsigned int t) {
    x += sizex-1;
    y += sizey-1;

    grid[const2d*y+x] = t;
    while (y >= 0) {
        long long int x_ = x;

        while (x_ > 0) {
            x_ = (x_-1)/2;
            grid[const2d*y+x_] = min(grid[const2d*y+x_*2+1], grid[const2d*y+x_*2+2]);
        }
        if (y == 0) break;

        y = (y-1)/2;
        grid[const2d*y+x] = min(grid[const2d*(y*2+1)+x], grid[const2d*(y*2+2)+x]);
    }
}

unsigned int _get_min(unsigned int *vec, int wishl, int wishr, long long int k, int watchl, int watchr) {
    int mid;
    unsigned int lval, rval;

    if (wishr <= watchl || watchr <= wishl) return INF;
    if (wishl <= watchl && watchr <= wishr) {
        return vec[k];
    }

    mid = (watchl+watchr)/2;
    lval = _get_min(vec, wishl, wishr, k*2+1, watchl, mid);
    rval = _get_min(vec, wishl, wishr, k*2+2, mid, watchr);
    return min(lval, rval);
}

unsigned int get_min(int wishl, int wishr, int wishu, int wishd, long long int k, int watchu, int watchd) {
    int mid;
    unsigned int uval, dval;

    if (wishd <= watchu || watchd <= wishu) return INF;
    if (wishu <= watchu && watchd <= wishd) {
        return _get_min(&grid[const2d*k], wishl, wishr, 0, 0, sizex);
    }

    mid = (watchu+watchd)/2;
    uval = get_min(wishl, wishr, wishu, wishd, k*2+1, watchu, mid);
    dval = get_min(wishl, wishr, wishu, wishd, k*2+2, mid, watchd);
    return min(uval, dval);
}
    
int main() {
    while (1) {
        scanf("%d %d %d", &r, &c, &q);
        if (r == 0 && c == 0 && q == 0) return 0;

        sizex = 1;
        while (sizex < c) sizex *= 2;
        sizey = 1;
        while (sizey < r) sizey *= 2;
        const2d = sizex*2-1;

        for (int i=0; i<r; i++) {
            for (int j=0; j<c; j++) {
                unsigned int g;
    
                scanf("%u", &g);
                update(j, i, g);
            }
        }
 
        for (int i=0; i<q; i++) {
            int r1, r2;
            int c1, c2;
    
            scanf("%d %d %d %d", &r1, &c1, &r2, &c2);
            printf("%u\n", get_min(c1, c2+1, r1, r2+1, 0, 0, sizey));
        }
    }
}

Measured memory_bytes: 31088
int main(int argc, const char * argv[]) {
    int N,K,X,Y;
    scanf("%d",&N);
    scanf("%d",&K);
    scanf("%d",&X);
    scanf("%d",&Y);
    
    int ans=0;
    
    if(N>K){
        ans = (X*K) + (Y*(N-K));
    }
    
    else if(N<=K){
        ans = X*N;
    }
    
    
    printf("%d\n",ans);
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#define MN 100000
#define ll long long
using namespace std;
inline int read()
{
    int x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9')x=x*10+ch-'0',ch=getchar();
    return x*f;
}
vector<int> v[MN+5];
int n,K,a[MN+5],ans,d[MN+5];
void dfs(int x)
{
    d[x]=0;
    for(int i=0;i<v[x].size();++i)
    {
        dfs(v[x][i]);
        if(d[v[x][i]]+1+(x!=1)>K) ++ans;
        else d[x]=max(d[x],d[v[x][i]]+1);
    }
}
int main()
{
    n=read();K=read();
    for(int i=1;i<=n;++i) a[i]=read();
    ans=(a[1]!=1);
    for(int i=2;i<=n;++i) v[a[i]].push_back(i);
    dfs(1);
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11136
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <bitset>
#include <cctype>
#include <functional>
#include <ctime>
#include <cmath>
#include <limits>
#include <numeric>
#include <type_traits>
using namespace std;
using ll = long long;

unsigned euclidean_gcd(unsigned a, unsigned b) {
    if (a < b) return euclidean_gcd(b, a);
    unsigned r;
    while ((r = a % b)) {
        a = b;
        b = r;
    }
    return b;
}

class UnionFind {
public:
    vector <ll> par;
    vector <ll> siz;
    UnionFind(ll sz_) : par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    void init(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i;
    }
    ll root(ll x) {
        while (par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool merge(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool issame(ll x, ll y) {
        return root(x) == root(y);
    }

    ll size(ll x) {
        return siz[root(x)];
    }
};

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    if (n < 0)return 0;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main() {
    ll n,m;
    cin >> n >> m;
    vector<ll> fib(n+2);
    fib.at(1) = 1;
    for (int i = 1; i < n+1; i++) {
        fib.at(i + 1) = fib.at(i) + fib.at(i - 1);
        fib.at(i + 1) %= 1000000007;
}
    if (m != 0) {
        vector<ll> z(m);
        for (int i = 0; i < m; i++) {
            cin >> z.at(i);
        }
        ll ans = fib.at(z.at(0));
        for (int i = 1; i < m; i++) {
            ans *= fib.at(z.at(i) - z.at(i - 1) - 1);
            ans %= 1000000007;
        }
        ans *= fib.at(n - z.at(m - 1));
        ans %= 1000000007;
        cout << ans << endl;
    }
    else { cout << fib.at(n + 1) << endl; }
}

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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int n, k;
const int N = 2e5 + 100;
int aa[N], bb[N], all[N], alll = 0, aaa = 0, bbb = 0;
ll factor[10500010];

int main() {
    int n;
    scanf("%d", &n);
    for (int i = 1; i <= n; i++)
        for (int j = 1; j <= n / i; j++)
            factor[i * j]++;
    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        ans += 1ll * i * factor[i];
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 81868
#include <bits/stdc++.h>
using namespace std;
const int INF = 1e9 + 5;
int main(){
    int n, k;
    cin >> n >> k;
    int cnt = 0;
    while(n != 0){
        cnt++;
        if(n % k == 0){
            n /= k;
        }
        else{
            n /= k;
        }
    }
    cout << cnt  << endl;
    return 0;
}   

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

int main() {
  int N, M; cin >>N >>M;
  vector<int> A(N);
  int Sum = 0;
  rep( i, 0, N ) {
    cin >>A.at(i);
    Sum += A.at(i);
  }

  int Count = 0;
  float Temp = float(Sum)/float(4.0*M);
  rep( i, 0, N ) {
    if ( Temp<=A.at(i) ) Count++;
  }
  cout << ( M <= Count ? "Yes" : "No" ) << endl;
}


Measured memory_bytes: 3604
import heapq


def submit():
    n, m = map(int, input().split())
    q = []
    for a in map(int, input().split()):
        heapq.heappush(q, -a)

    for _ in range(m):
        t = -heapq.heappop(q)
        heapq.heappush(q, -(t // 2))

    print(-sum(q))        


if __name__ == "__main__":
    submit()
    

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

typedef long long ll;
typedef long double ld;
typedef vector<vector<int>> Graph;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
#define pi 3.14159265359
#define inf 2147483647
#define INF 9223372036854775807
#define mod 1000000007
#define mod2 998244353

int main() {
	int A, B; cin >> A >> B;
    if(A + B < 24) cout << A + B << endl;
    else cout << A + B - 24 << endl;
	return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
using namespace std;
typedef long long ll;

int INF = 1 << 30;

int N,A,B,C;
int l[1010];

void chmin(int &a, int b){
  if (a > b){
    a = b;
  }
}

int rec(int i, int a, int b, int c){
  
  //ベースケース
  if (i == N){
    if (a == 0 || b == 0 || c == 0) return INF; //どれかが何も使われてなかったらINFを返す。
    return abs(a - A) + abs(b - B) + abs(c - C); //絶対値の引き算を返す
  }
  
  int res = INF;
  
  //再帰ステップ
  chmin(res, rec(i+1,a,b,c)); //何も選択しない
  chmin(res, rec(i+1,a + l[i],b,c) + (a ? 10 : 0)); //Aを選択。変数aに長さを足して再帰。もしすでにaが1以上になっていれば合体として10を足す。
  chmin(res, rec(i+1,a,b + l[i],c) + (b ? 10 : 0)); //同上
  chmin(res, rec(i+1,a,b,c + l[i]) + (c ? 10 : 0)); //同上
  
  return res;
}

int main(){
  
  cin >> N >> A >> B >> C;
  
  for (int i = 0; i < N; i++){
    cin >> l[i];
  }
  
  cout << rec(0,0,0,0);
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
 
#define rep(i,n) for(ll i = 0;i < n;++i)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
typedef pair<int,int> P;
 
const int INF = 1001001001;
const long double PI = (acos(-1));


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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n){
        int x;
        cin >> x;
        int b = i+1;
        a[--x] = b;

    }
    rep(i,n) cout << a[i] << " ";
    
    cout << endl;
    return 0;
}


Measured memory_bytes: 1280
#include<cstdio>
#include<iostream>
#include<cstring>
#include<algorithm>
using namespace std;
#define maxn 20
#define maxm maxn*(maxn-1)/2
#define p 1000000007
template <typename T>inline T read()
{
	register T sum=0;
	char cc=getchar();
	int sym=1;
	while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
	if(cc=='-')sym=-1,cc=getchar();
	sum=sum*10+cc-'0';
	cc=getchar();
	while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
	return sym*sum;
}
template <typename T>inline T read(T &a)
{
	a=read<T>();
	return a;
}
long long n,m,a[maxm],b[maxm],c[(1<<maxn)],d[(1<<maxn)],fc[maxm],f[2][(1<<maxn)],ans;
int main()
{
	n=read<int>(),m=read<int>();
	fc[0]=1;
	for(int i=1;i<=maxm;i++)
		fc[i]=(fc[i-1]*2)%p;
	for(int i=1;i<=m;i++)
		a[i]=read<int>()-1,b[i]=read<int>()-1;
	for(int i=0;i<(1<<n);i++)
		for(int j=1;j<=m;j++)
		{
			if((i&(1<<a[j]))&&(i&(1<<b[j])))c[i]++;
			if((i&(1<<a[j]))||(i&(1<<b[j])))d[i]++;
		}
	for(int k=0;k<2;k++)
		for(int i=0;i<(1<<n);i++)
		{
			if(!(i&(1<<k)))continue;
			f[k][i]=fc[c[i]];
			for(int j=(i-1)&i;j>0;j=(j-1)&i)
				if(j&(1<<k))f[k][i]=(f[k][i]-1ll*fc[c[i-j]]*f[k][j]%p+p)%p;
		}
	for(int i=0;i<(1<<n);i++)
		for(int j=0;j<(1<<n);j++)
			if(!(i&j)&&c[i]+c[j]==c[i|j])
				ans=(ans+(fc[m-d[i|j]]*(f[0][i]*f[1][j])%p)%p)%p;
	printf("%lld\n",(fc[m]-ans+p)%p);
	return 0;
}

Measured memory_bytes: 6784
#include <stdio.h>

int main(void)
{
  char s[11];
  scanf("%s", s);
  
  int i = 0;
  int j;
  int ans = 0;
  while (s[i] != '\0')
  {
    if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T')
    {
      j = 0;
      while ((s[i + j] == 'A' || s[i + j] == 'C' || s[i + j] == 'G' || s[i + j] == 'T') && s[i + j] != '\0')
      {
        j++;
      }
      if (ans < j)
      {
        ans = j;
      }
    }
    i++;
  }
  printf("%d", ans);
  return 0;
}

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    ll a , b , c ; cin >> a >> b >> c ;
    if (a == b && b != c || a != b && b == c || a != b && b != c && c == a)
        Yes ;
    else
        No ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/



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

int main(){
  int x,n;
  cin >> x>>n;
  vector<int> d(102);
  rep(i,n){
    int p;
    cin >> p;
    d[p]=1;
  }
  P ans(99999,-1);
  rep(i,102){
    if(d[i]==1) continue;
    int dif =abs(x-i);
    ans = min(ans,P(dif,i));
  }
  cout << ans.second << endl;
  return 0;
}

Measured memory_bytes: 3636
// ------------------------------------
// Date:2018/ 3/21
// Problem:Shik and Stone a.cpp
//
// ------------------------------------

#include <bits/stdc++.h>

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Possible" : "Impossible") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

static const int MOD = 1e9 + 7;
static const int MAX_N = 1;

int H, W;
string a[8];

bool check()
{
  REP(hi, H) {
    REP(wi, W) {
      // 左下
      if (0 < hi and wi < W - 1) {
	if (a[hi][wi] == '#') {
	  if (a[hi - 1][wi + 1] == '#') return false;
	}
      }
      // 右下
      if (0 < wi and hi < H - 1) {
	if (a[hi][wi] == '#') {
	  if (a[hi + 1][wi - 1] == '#') return false;
	}
      }
    }
  }
  return true;
}

int main()
{
  scanf("%d %d", &H, &W);
  REP(hi, H) {
    cin >> a[hi];
  }

  bool ok = check();
  OK(ok);
  
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <stdlib.h>

using namespace std;


int main(){

	double a,b,c,d,e,f;
	double x, y;

	while(cin >> a){
		cin >> b >> c >> d >> e >> f;

		if(c/b == f/e){
			x = 0;
			y = c/b;
			printf("%.3lf %.3lf\n",x, y);
		}else if(c/a == f/d){
			y = 0;
			x = c/a;
			printf("%.3lf %.3lf\n",x, y);
		}else{
			y = (c*d - a*f)/(d*b - a*e);
			x = (c - b*y)/a;
			printf("%.3lf %.3lf\n",x, y);
		}
	}
	return 0;
}

Measured memory_bytes: 1236
#include<stdio.h>
#define N 100
 
int main(){
  
 int M[N][N];
 int a,b,c,d;
 int i,j;
  
 scanf("%d",&a);
  
 for( i = 0 ; i < a ; i++){
  for( j = 0 ; j < a ; j++){
    M[i][j]=0;
  }
 }
  
 for( i = 0 ; i < a ; i++ ){
   scanf("%d%d",&b,&c);
   b--;
   for( j = 0 ; j < c ; j++){
     scanf("%d",&d);
     d--;
     M[b][d] = 1;
   }
 }
 
 for( i = 0 ; i < a ; i++){
  for( j = 0 ; j < a ; j++ ){
   if(j == a-1)printf("%d\n",M[i][j]);
   else printf("%d ",M[i][j]);
  }
 }
 return 0 ;
}

Measured memory_bytes: 636
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
int main(){
  int n,m,q;
  cin >> n >> m >> q;
  vector<vector<int>> p(q,vector<int>(4));
  for(int i = 0;i < q;i++){
    for(int j = 0;j < 4;j++){
      cin >> p[i][j];
      if(j == 0 || j == 1)p[i][j]--;
    }
  }
  vector<int> num(n);
  for(int i = 0;i < n;i++)num[i] = 1;
  int now = 0;
  now = n - 1;
  int res = 0;
  bool finish = true;
  while(finish){
    /*for(auto& item:num)cout << item << " ";
    cout << endl;*/
    int count = 0;
    for(int i = 0;i < q;i++){
      if(num[p[i][1]] - num[p[i][0]] == p[i][2])count += p[i][3]/*,cout << "!" << endl*/;
    }
    res = max(res,count);
    now = n - 1;
    while(1){
      if(num[now] < m){
        num[now]++;
        for(int i = n - 1;i >= now + 1;i--){
          num[i] = num[now];
        }
        break;
      }
      else if(now > 0){
        num[now] = 1;
      }
      else{
        finish = false;
        break;
      }
      now--;
    }
  }
  cout << res << endl;
  return 0;
}

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

using namespace std;

typedef long long int lli;

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

    int h, w;
    lli mod = 1000000007;
    cin >> h >> w;
    vector<vector<lli>> dp(h+1, vector<lli>(w+1, 0));
    vector<string> grid(h);

    for (int i=0; i<h; i++) cin >> grid[i];

    dp[1][0] = 1;
    for (int i=0; i<h; i++) {
        for (int j=0; j<w; j++) {
            dp[i+1][j+1] = (grid[i][j]=='.') ? (dp[i][j+1]+dp[i+1][j])%mod : 0;
        }
    }

    cout << dp[h][w] << endl;

    return 0;
}


Measured memory_bytes: 9216
#include <iostream>
#include <string>
using namespace std;
int main(int argc, char const *argv[]) {
  string s;
  cin>>s;
  string ans;
  for(int i=0;i<s.size();i++){
    if(s[i]=='0') ans.push_back(s[i]);
    if(s[i]=='1') ans.push_back(s[i]);
    if(s[i]=='B'&&ans.size()!=0)  ans.pop_back();
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
import sys

readline = sys.stdin.readline
readall = sys.stdin.read
ns = lambda: readline().rstrip()
ni = lambda: int(readline().rstrip())
nm = lambda: map(int, readline().split())
nl = lambda: list(map(int, readline().split()))
prn = lambda x: print(*x, sep='\n')

def solve():
    m = 26
    D = ni()
    c = nl()
    s = [nl() for _ in range(D)]
    sche = [ni() - 1 for _ in range(D)]
    last = [-1] * m
    ans = 0
    for i in range(D):
        t = sche[i]
        ans += s[i][t]
        last[t] = i
        for j in range(m):
            ans -= c[j] * (i - last[j])
        print(ans)

    return

solve()


Measured memory_bytes: 9500
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <cstring>
#include <cmath>
#include <climits>
#include <ctime>
#include <fstream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#define MAGIC cin.tie(NULL); ios_base::sync_with_stdio(false)
#define endl '\n'
//#define ll long long
#define mod 1000000007
#define NCONS 100001
//#define NCONS 100001
//#define NCONS 1001
//#define NCONS 101
#define MCONS 2001
#define LIMIT 1000000000
#define TRUE 1
#define FALSE 0
#define toRadian(degree) ((degree) * (M_PI / 180.))
#define toDegree(radian) ((radian) * (180. / M_PI))
#define int long long
//#define double long double
using namespace std;
struct Point{int x; int y;};
struct PPoint{Point x; Point y;};
typedef long long ll;

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

#define YYYY cout << "YES" << endl
#define NNNN cout << "NO" << endl
#define yyyy cout << "Yes" << endl
#define nnnn cout << "No" << endl

int32_t main()
{
    MAGIC;
    int N, K; cin >> N >> K;
    string str; cin >> str;
    vector<int> vec;
    char prev = str[0]; int acc = 1;
    for(int i = 1; i < str.size(); i++)
    {
        auto ch = str[i];
        if(prev == ch)
        {
            acc += 1;
        }
        else
        {
            prev = ch;
            vec.push_back(acc);
            acc = 1;
        }
    }
    vec.push_back(acc);
    
    int ret = 0;
    for(auto v : vec)
        ret += (v-1);
    
    while(K > 0 && vec.size() > 1)
    {
        if(vec.size() >= 3)
        {
            ret += 2;
            vec.pop_back();
        }
        else if(vec.size() == 2)
        {
            ret += 1;
        }
        vec.pop_back();
        K -= 1;
    }
    
    
    cout << ret << endl;
    return 0;
}


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

typedef pair<int,int> P;
const int INF = 500000000;

int main(){
    int h,w;
    cin >> h >> w;
    char maze[h][w];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            cin >> maze[i][j];
        }
    }
    
    queue<tuple<int,int,int>> que;
    int ans;
    if (maze[0][0] == '.') ans = 0;
    else ans = 1;
    int dis[h][w];
    for (int i = 0; i < h; i++){
        for (int j = 0; j < w; j++){
            dis[i][j] = INF;
        }
    }
    dis[0][0] = ans;
    int nexth[2] = {0,1}; int nextw[2] = {1,0};
    que.push(make_tuple(0,0,ans));
    tuple<int,int,int> next;

    for (int a = 0; a < h; a++){
        for (int b = 0; b < w; b++){
            while(que.size()){
                tuple<int,int,int> now = que.front(); que.pop();

                for (int i = 0; i < 2; i++){
                    next = make_tuple(get<0>(now) + nexth[i], get<1>(now) + nextw[i], get<2>(now));
                    if (get<0>(next) >= 0 && get<1>(next) >= 0 && get<0>(next) < h && get<1>(next) < w ){
                        if(maze[get<0>(next)][get<1>(next)] == '#' && maze[get<0>(next)][get<1>(next)] != maze[get<0>(now)][get<1>(now)]) get<2>(next) += 1;
                        if (dis[get<0>(next)][get<1>(next)] > get<2>(next)){
                            que.push(next);
                            dis[get<0>(next)][get<1>(next)] = get<2>(next);
                        }
                    }
                }
            }

        }
    }
    cout << dis[h-1][w-1] << "\n";
}


Measured memory_bytes: 384
#include <stdio.h>

int main(){
    int n, m, i, j;
    char c[128], ch[128], a;
    
    while(1){
        scanf("%d",&n);
        if(n == 0) break;
        for(i = 0 ; i < n ; i++){
            scanf(" %c %c ",&c[i],&ch[i]);
        }
        scanf("%d",&m);
        for(i = 0 ; i < m; i++){
            scanf(" %c ",&a);
            for(j = 0 ; j < n ; j++){
                if(a == c[j]){
                    a = ch[j];
                    break;
                }
            }
            printf("%c", a);
        }
        printf("\n");
    }
    return 0;
    
}

Measured memory_bytes: 576
#include <iostream>
#include <cassert>
int main(void){
    using namespace std;
    static const int AbnormalValueMin = 1;
    static const int AbnormalValueMax = 100;
    int length =0;
    int breadth =0;
    cin >> length;
    cin >> breadth;
    /* Calculation  Area, perimeter */
    if(AbnormalValueMin <= length && breadth <= AbnormalValueMax){
        cout << length*breadth << " " << (length+breadth)*2 << endl;
    }
    return 0;
}

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

int main(int argc, char *argv[])
{
	int i, j;

	for (i = 1; i < 10; i++)
		for (j = 1; j < 10; j++)
			printf("%dx%d=%d\n", i, j, i*j);

	return 0;
}

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

using namespace std;

vector<int >vp;
int dp[100010][2];
bool visit[3010][3010];
int n;
int  dpp(int p ,int x)
{

  if(dp[p][x]!=-1)
  return dp[p][x];


  int ans;
  ans=(x==0);
  if(x==0)
  {
   for(int i=0;i<n;i++)
   {
   if(p>=vp[i])
   ans=min(ans,dpp(p-vp[i],1));
   }
   return dp[p][x]=ans;

  }
  else
  {
  for(int i=0;i<n;i++)
   {
   if(p>=vp[i])
   ans=max(ans,dpp(p-vp[i],0));
   }
   return dp[p][x]=ans;

  }

}

int main()
{

memset(dp,-1,sizeof dp);
 int k;
 cin>>n>>k;
    for(int i=1;i<=n;i++)
    {

        double x;
        cin>>x;
        vp.push_back(x);
    }
    int ans=dpp(k,0);

    if(ans==0)
    cout <<"First";
    else
    cout <<"Second";


}


Measured memory_bytes: 5760
n=int(input())
a=list(map(int,input().split()))

height=a[0]
fumidai=0

for i in range(1,n):
    if(a[i]<height):
        fumidai+=(height-a[i])
        #print(0,fumidai)
    else:
        height=a[i]
#print(height)
print(fumidai)

Measured memory_bytes: 32176
#include <algorithm>
#include <iostream>
#include <vector>
#include <math.h>
#include <set>
#include <map>
#define _USE_MATH_DEFINES
using namespace std;
typedef long long ll;
double pi = 3.141592653589793;
ll mod = 1000000007;

bool ch[100010][30];

int main() {
    int N, C;
    cin >> N >> C;
    for(int i = 0; i < N; i++) {
        int s, t, cc;
        cin >> s >> t >> cc;
        for(int j = s - 1; j < t; j++) {
            ch[j][cc - 1] = true;
        }
    }
    int ans = 0;
    for(int i = 0; i < 100010; i++) {
        int count = 0;
        for(int j = 0; j < 30; j++) {
            if(ch[i][j]) {
                count++;
            }
        }
        ans = max(ans, count);
    }
    cout << ans << endl;
}


Measured memory_bytes: 3328
# -*- coding: utf-8 -*-
import sys
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    N=int(input())
    S=list(input())
    ans=0
    for i in range(100):
        ans=max(ans,len(set(S[:i])&set(S[i:])))
    print(ans)

if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;


int main(){

    int a, b, c;
    cin >> a >> b >> c;

    if((a <= c) && (c <= b)) cout << "Yes" << endl;
    else cout << "No" << endl;
    
    return 0;
}

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

bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}

int main(){
    char s[3];

    rep(i,3){
        cin >> s[i];
    }
    if(s[0]==s[1]&&s[1]==s[2])
        cout << "No" << endl;
    else
    {
        cout << "Yes" << endl;
    }
    
}

Measured memory_bytes: 256