akhauriyash/Code-Regression huggingface dataset:
H, W, K = map(int, input().split())
s = [input() for _ in range(H)]
            
ret = [[0] * W for _ in range(H)]
n = 0

ex = []
for y in range(H) :
    if '#' in s[y] :
        ex.append(y)
        n += 1
        first = True
        for x in range(W) :
            if s[y][x] == '#' :
                if first :
                    first = False
                else :
                    n += 1
                    
            ret[y][x] = n

for y in range(H) :
    if sum(ret[y]) != 0 :
        ny = y - 1
        while ny >= 0 and sum(ret[ny]) == 0 :
            ret[ny] = ret[y]
            ny -= 1
        ny = y + 1
        while ny < H and sum(ret[ny]) == 0 :
            ret[ny] = ret[y]
            ny += 1
        
        
for r in ret :
    print(*r)
print()

Measured memory_bytes: 45788
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, sum;
  sum = 0;
  cin >> a;
  if (a >= 100) {
    sum++;
    a -= 100;
  }
  if (a >= 10) {
    sum++;
    a -= 10;
  }
  if (a >= 1) {
    sum++;
  }
  cout << sum << endl;
}


Measured memory_bytes: 256
import bisect
a, b, q = map(int, input().split())
s = [int(input()) for _i in range(a)]
t = [int(input()) for _i in range(b)]
s.append(float('inf'))
s.insert(0, -float('inf'))
t.append(float('inf'))
t.insert(0, -float('inf'))
x = [int(input()) for _i in range(q)]

for i in x:
    n = bisect.bisect_right(s, i)
    m = bisect.bisect_right(t, i)
    e = abs(max([s[n], t[m]])-i)
    f = abs(i-min(s[n-1], t[m-1]))
    g = min([abs(i-s[n]), abs(i-t[m-1])])+abs(s[n]-t[m-1])
    h = min([abs(i-s[n-1]), abs(i-t[m])])+abs(s[n-1]-t[m])
    print(min([e, f, g, h]))

Measured memory_bytes: 16156
#include "bits/stdc++.h"
using namespace std;
typedef long long int lli;
#define pb push_back
#define mp make_pair
#define mod 998244353
#define ff first
#define ss second
#define pi pair<lli,lli>
#define pii pair<lli,pi>
#define endl "\n"
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
const int N = 2e5 + 5;
int main() {
	IOS
	int T = 1;
	// cin >> T;
	while(T--) 
	{
		int n, k;
		cin  >> n >> k;
		set<int> s;
		for(int i=1;i<=n;i++) s.insert(i);
		for(int i=1;i<=k;i++)
		{
			int x,y;
			cin  >> x;
			while(x--)
			{
				cin >> y;
				s.erase(y);
			}
		}
		cout << s.size();
		
	}
	return 0;
}

Measured memory_bytes: 3668
package main

import (
	"fmt"
)

func main() {
	var s, t string
	strArray := scanStr(2)
	s = strArray[0]
	t = strArray[1]

	fmt.Println(t + s)
}

func scanNums(len int64) (nums []int64) {
	var num int64
	var i int64
	for i = 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func scanStr(len int64) (strs []string) {
	var str string
	var i int64
	for i = 0; i < len; i++ {
		fmt.Scan(&str)
		strs = append(strs, str)
	}
	return
}


Measured memory_bytes: 512
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cstdlib>
#include<cmath>
#include<cstring>
#include<set>
#include<map>
#include<queue>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);++i)
#define rrep(i,n) for(int (i)=(n)-1;(i)>=0;--i)
#define rep1(i,n) for(int (i)=1;(i)<=(n);++i)
#define rrep1(i,n) for(int (i)=(n);(i)>=1;--i)
#define pb push_back
#define fr first
#define sc second
typedef long long ll;
typedef pair<int,int> P;
typedef pair<long long,long long> LP;
typedef double db;
using namespace std;

ll N;
ll D[52];
bool used[25];
ll cnt;

int main()
{
  cin>>N;
  rep(i,N){
    cin>>D[i];
    if(D[i]==0 ){
      puts("0");
      return 0;
    }
  }
  if(N==1LL){
    cout<<min(24-D[0],D[0])<<endl;
    return 0;
  }
  if(N>=24){
    puts("0");
    return 0;
  }
  ll ans = 0LL;
  rep(s,1<<(N-1)){//0~午前 1~午後
    rep(i,24) used[i]=0;
    used[0]=used[D[N-1]]=1;
    rep(i,N-1){
      if((s>>i)&1LL){
        if(used[D[i]]){
          goto en;
        }
        used[D[i]]=1;
      }
      else{
        if(used[24-D[i]]){
          goto en;
        }
        used[24-D[i]]=1;
      }
    }
    cnt = 12LL;
    ll pos,pas;
    pas = 0LL;
    rep1(i,23LL){
      while(i<24LL && !used[i]){
        i++;
      }
      if(i == 24LL) break;
      pos = i;
      cnt = min(cnt,pos-pas);
      pas = pos;
    }
    cnt = min(24LL-pas,cnt);
    ans = max(ans,cnt);
    en: ;
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using vec = vector<int>;
using vec2 = vector<vector<int>>;

int main(){
   int n, k;
   cin >> n >> k;
   vec a(n,0);
   rep(i, n){
       cin >> a[i];
   }
   rep(i, k){
       vec b(n+1, 0);
       rep(j, n){
           int f = max(0, j-a[j]);
           int m = min(n, j + a[j] + 1);
           b[f]++;
           b[m]--;
       }
       rep(j, n){
           b[j+1] = b[j] + b[j+1];
       }
       b.pop_back();
       if(a == b){
           break;
       }
       a = b;
   }
   rep(i, n){
       cout << a[i] << " " ;
   }
}


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

int main(){
	int N,K; cin>>N>>K;
	vector<int> X(N); rep(i, N) cin>>X[i];
	int ans = INT_MAX;
	rep(il, N-(K-1)){
		int ir = il + (K-1), l = X[il], r = X[ir];
		ans = min({ans, abs(l) + r-l, abs(r) + r-l});
	}
	cout<< ans <<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <set>
#include <queue>
#include <map>
#include <stack>
using namespace std;

#define mod 1000000007
#define ten5 100005
#define ten52 200005
#define ten6 1000005
#define PI 3.1415926

typedef long long int ll;

//ll chk[55];
ll num[55];
//ll num2[55];
//ll num[ten5];
//ll num2[ten5];
//char cmap[10][10];
//priority_queue<long long int> pq;   //big at front
//stack<int> stk;
//vector<pair<ll,ll>> vint;
//vector<ll> vtime;
//deque<ll> deq[55];
//list<int> li;
//set<int> sint;
//set<ll> sll;
//map<ll,ll> mp;


int main()
{
    //double ans=0.0,half;
    //float f,g,h;
    long long int sum,sum2,n1,n2,n3;
    long long int m,n,o,i,j,k=1;
    long long int a,a1,a2,a3,a4,a5,a6;
    sum=sum2=n1=n2=n3=0;
    a=a1=a2=a3=a4=a5=a6=0;
    //string s,s1;
    //char now,pre,c;
    cin>>n;
    for(i=1;i<=n;i++)
    {
        cin>>a;
        if(a!=i) sum++;
        if(sum>2)
        {
            cout<<"NO";
            return 0;
        }
    }
    cout<<"YES";
    return 0;
}


Measured memory_bytes: 256
//package hiougyf;
import java.io.*;
import java.util.*;
import java.util.Map.Entry;
public class Main{	
		public static void main(String[] args){  
		Scanner sc =new Scanner(System.in);
		int hh=1000000007,t=sc.nextInt();
		int ans=0,k=0;
		while(t-->0) {
		int a=sc.nextInt();
		int b=sc.nextInt();
		if(a==b) ans++;
		else if(a!=b) ans=0;
		if(ans>=3) {
			System.out.println("Yes");
			k=9;
			break;
		}
		
	}
		if(k!=9) System.out.println("No");
		
   }
		static double distance(long a,long b,long a1,long b1) {
			//System.out.println(((a-a1)*(a-a1))+((b-b1)*(b-b1)));
			double d1=Math.sqrt(((a-a1)*(a-a1))+((b-b1)*(b-b1)));
			return d1;
		}
	
	  public static int floorSqrt(int x) 
	    { 
	        // Base Cases 
	        if (x == 0 || x == 1) 
	            return x; 
	  
	        // Do Binary Search for floor(sqrt(x)) 
	        int start = 1, end = x, ans=0; 
	        while (start <= end) 
	        { 
	            int mid = (start + end) / 2; 
	  
	            // If x is a perfect square 
	            if (mid*mid == x) 
	                return mid; 
	  
	            // Since we need floor, we update answer when mid*mid is 
	            // smaller than x, and move closer to sqrt(x) 
	            if (mid*mid < x) 
	            { 
	                start = mid + 1; 
	                ans = mid; 
	            } 
	            else   // If mid*mid is greater than x 
	                end = mid-1; 
	        } 
	        return ans; 
	    } 
		static int div(int n,int b) {
			int g=-1;
			for(int i=2;i<=Math.sqrt(n);i++) {
				if(n%i==0&&i!=b) {
					g=i;
					break;
				}
			}
			return g;
		}
	 
	  
	  public static int gcd(int a, int b) 
	    { 
	        if (a == 0) 
	            return b; 
	          
	        return gcd(b%a, a); 
	    } 
	   public static int lcm(int a, int b)  
	  {  
	     return (a*b)/gcd(a, b);  
	  }  
	   public static boolean isPrime1(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           for (int i = 2; i <= Math.sqrt(n) + 1; i++) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
       public static boolean isPrime(int n) {
           if (n <= 1) {
               return false;
           }
           if (n == 2) {
               return true;
           }
           if (n % 2 == 0) {
               return false;
           }
           for (int i = 3; i <= Math.sqrt(n) + 1; i = i + 2) {
               if (n % i == 0) {
                   return false;
               }
           }
           return true;
       }
	      
	
}

Measured memory_bytes: 35896
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n, m;
    cin >> n >> m;
    vector<int>v(m + 3), v2, stick(12), val(12, -1), vis(12, 0);
    stick[1] = 2, stick[2] = 5, stick[3] = 5, stick[4] = 4, stick[5] = 5, stick[6] = 6, stick[7] = 3, stick[8] = 7, stick[9] = 6;
    for(int i = 0; i < m; i++){
        cin >> v[i];
        if(vis[stick[v[i]]] == 0){
            vis[stick[v[i]]] = 1;
            v2.push_back(stick[v[i]]);
        }
        val[stick[v[i]]] = max(val[stick[v[i]]], v[i]);
    }
    int dp[n + 3];
    for(int i = 0; i <= n; i++){
        dp[i] = -1;
    }
    dp[0] = 0;
    for(int i = 0; i < v2.size(); i++){
        for(int j = v2[i]; j <= n; j++){
            if(dp[j - v2[i]] != -1){
                dp[j] = max(dp[j], dp[j - v2[i]] + 1);
            }
        }
    }
    vector<pair<int, int> >vec;
    for(int i = 0; i < v2.size(); i++){
        vec.push_back(make_pair(val[v2[i]], v2[i]));
    }
    sort(vec.rbegin(), vec.rend());
    string s;
    int cnt = 0;
    while(n > 0){
        cnt++;
        for(int j = 0; j < vec.size(); j++){
            if(n - vec[j].second >= 0 && dp[n] == dp[n - vec[j].second] + 1){
                s.push_back('0' + vec[j].first);
                n = n - vec[j].second;
                break;
            }
        }
    }
    cout << s;
    return 0;
}

Measured memory_bytes: 3668
#include<stdio.h>
int main(){
  int w,h,n,i,j,k;
  int x,y,a,s=0;
  scanf("%d %d %d",&w,&h,&n);
  int b[h][w];
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      b[i][j]=1;
    }
  }
    for(k=0;k<n;k++){
    scanf("%d %d %d",&x,&y,&a);
    if(a==1){
      for(i=0;i<h;i++){
	for(j=0;j<x;j++)
	  b[i][j]=0;
      }
    }
    if(a==2){
      for(i=0;i<h;i++){
	for(j=x;j<w;j++){
	  b[i][j]=0;
	}
      }
    }
    if(a==3){
      for(i=h-y;i<h;i++){
	for(j=0;j<w;j++){
	  b[i][j]=0;
	}
      }
    }
    if(a==4){
      for(i=0;i<h-y;i++){
	for(j=0;j<w;j++){
	  b[i][j]=0;
	}
      }
    }
  }
  for(i=0;i<h;i++){
    for(j=0;j<w;j++){
      s=s+b[i][j];
    }
  }
  printf("%d",s);
  return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include  <iostream>
#include  <algorithm>
#include  <climits>
#include  <vector>
#include  <string>
#include  <cstring>
#include  <stack>
#include  <queue>
#include  <cmath>
#include  <iomanip>
#include  <set>
#include  <map>
#include  <new>

using namespace std;

#define rep(i,n)  for(int i = 0; i < n; i++)
#define lrep(i,n,m)  for(int i = n; i < m; i++)

typedef long long ll;
const int Mod = static_cast<int>(1e9 + 7);

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

	vector<int> A(n + 1);
	rep(i, n + 1)  A[i] = i;

	bool ans = false;
	int i, j;
	for (i = 0; i <= n; i++) {
		for (j = 0; j <= n; j++) {
			if (binary_search(A.begin(), A.end(), i + j)) {
				if (10 * i + 5 * j + n - i - j == y / 1000) {
					ans = true;
					break;
				}
			}
		}
		if (ans)  break;
	}
	if (ans) {
		cout << i << " " << j << " " << n - i - j << endl;
	}
	else {
		cout << -1 << " " << -1 << " " << -1 << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF = 1000000007;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
int main(){
  int a,b;
  string s;
  cin>>a>>s>>b;
  if(s == "-")cout<<a-b<<endl;
  else cout<<a+b<<endl;
  return 0;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
const int M = 1000000007;

int main() {
    double d;
    cin >> d;
    int di = (int)d;
    printf("%.12lf\n", max(max(sqrt(d * d - di * di), 1.0) + di, d * sqrt(2.0)));
    return 0;
}

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

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

  long long r = 0;
  long long g = 0;
  long long b = 0;
  for ( int i = 0; i < n; i++ ) {
    if ( s[i] == 'R' ) { r++; }
    if ( s[i] == 'G' ) { g++; }
    if ( s[i] == 'B' ) { b++; }
  }

  long long ans = r * g * b;
  for ( int i = 0; i < n-2; i++ ) {
    for ( int j = i+1; j < n-1; j++ ) {
      int k = 2*j - i;
      if ( k >= n ) { continue; }
      if ( s[i] != s[j] && s[j] != s[k] && s[k] != s[i] ) { ans--; }
    }
  }
  ans = ( ans < 0 ) ? 0 : ans;

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


Measured memory_bytes: 3628
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int H, W; cin >> H >> W;
  using Row = vector<int>;
  vector<Row> S(H, Row(W));
  int A, B; cin >> A >> B;

  int res{};
  for (int row = 0; row < H; ++row){
    res ^= 1;
    if(row == B) res ^= 1;
    for (int column = 0; column < W; ++column){
      if(column == A) res ^= 1;
      cout << res;
    }
    cout << CRLF;
  }

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

using namespace std;

typedef long long ll;

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

    
    int n; cin >> n;
    int ans = 0;
    for(int i = 1; i<= 1000000; i++){
        for(int j = 1; j<= 1000000;j++){
            if(i * j >= n)break;
            ans += 1;
        }
    }

    cout << ans << '\n';

}


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

struct data{
  ll a,b;
  bool operator < (const data &d) const {
    return a+b < d.a+d.b;
  }
};

ll N;

data t[100005];

int main(){
  cin>>N;
  for(int i=0;i<N;i++){
    cin>>t[i].a>>t[i].b;
  }
  sort(t,t+N);
  reverse(t,t+N);
  ll ans=0;
  for(int i=0;i<N;i++){
    if(i%2==0)ans+=t[i].a;
    else ans-=t[i].b;
  }
  cout<<ans<<endl;
  return 0;
}


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

long long MOD = 1e9 + 7;

vector<long long> fact, inv_fact;

long long POW(long long a, long long b) {
    long long result = 1;
    while (b > 0) {
        if (b & 1) {
            result *= a;
            result %= MOD;
        }

        a *= a;
        a %= MOD;
        b /= 2;
    }
    return result;
}

long long combination(long long n, long long m) {
    if (n <= m) {
        return 1;
    }

    return fact[n] * inv_fact[n - m] % MOD * inv_fact[m] % MOD;
}

int main() {
    long long H, W, A, B;
    cin >> H >> W >> A >> B;

    fact.resize(H + W + 1);
    inv_fact.resize(H + W + 1);
    fact[0] = fact[1] = 1;
    inv_fact[0] = inv_fact[1] = 1;
    for (int i = 2; i <= H + W; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        inv_fact[i] = POW(fact[i], MOD - 2);
    }

    long long ans = 0;
    for (int j = B + 1; j <= W; j++) {
        //(1, 1) ~ (j, H - A)　と (j, H - A + 1) ~ (H, W)に分けて考える
        long long r1 = combination(j - 1 + H - A - 1, j - 1);
        long long r2 = combination(A - 1 + W - j, A - 1);
        ans += r1 * r2 % MOD;
        ans %= MOD;
    }

    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <climits>
#include <iomanip>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;


int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, a, b;
    cin >> n >> a >> b;
    if(b < a) {
        cout << 0 << endl;
        return 0;
    }
    cout << max((n - 2) * (b - a) + 1, 0LL) << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);
		
		int a = sc.nextInt();
		int b = sc.nextInt();
		
		if((a+b)%3==0 || a%3==0 || b%3==0) {
			System.out.println("Possible");			
		}else {
			System.out.println("Impossible");
		}
		
		
	}

}


Measured memory_bytes: 23764
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <random>

using ll = long long;

//vector
template <class T>
using vec = std::vector<T>;

void solve()
{
    using namespace std;
    
    int N, M;
    cin >> N >> M;

    vec<int> roadNum(N);
    
    for (int i = 0; i < M; ++i)
    {
        int a, b;
        cin >> a >> b;
        ++roadNum[a - 1];
        ++roadNum[b - 1];
    }

    for (auto r : roadNum)
        cout << r << endl;
}

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

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


int main()	
{
	string s,ans="";
	cin>>s;
	for(int i=0;i<s.length();i++)
	{
		if(i%2==0)ans+=s[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;



/*
int bs(int l,int r)
{
    int mid,res=inf;

    while(l<=r)
    {
        mid=l+(r-l)/2;

        if(check(mid,0)|| check(mid,1))
        {
            res=min(res,mid);
            r=mid-1;
        }
        else
            l=mid+1;

    }


    return res;
}*/


int main()
{

    S s1,s2;
    cin>>s1>>s2;
    int count=0;
    for(int i=0;i<s1.size();i++)
    {
        if(s1[i]!=s2[i])
            count++;
    }

    cout<<count;




    return 0;

}
/*

*/


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

using namespace std;
using ll = long long;

#define rep(i, a) for (int i = 0; (i) < (int) (a); (i)++)
#define reps(i, a, b) for (int i = (int) (a); (i) < (int) (b); (i)++)
#define rrep(i, a) for (int i = (int) a-1; (i) >= 0; (i)--)
#define rreps(i, a, b) for (int i = (int) (a)-1; (i) >= (int) (b); (i)--)
#define MP(a, b) make_pair((a), (b))
#define PB(a) push_back((a))
#define all(v) (v).begin(), (v).end()
#define PERM(v) next_permutation(all(v))
#define UNIQUE(v) sort(all(v));(v).erase(unique(all(v)), v.end())
#define CIN(type, x) type x;cin >> x
#define TRUE__  "Yes"
#define FALSE__ "No"
#define PRINT(f) if((f)){cout << (TRUE__) << endl;}else{cout << FALSE__ << endl;}
#define RS(N) resize(N)
#define CINV(v, N) do {\
	v.RS(N);\
	rep(i, N) cin >> v[i];\
} while (0);
#define RCINV(v, N) do {\
	v.RS(N);\
	rrep(i, N) cin >> v[i];\
} while (0);

#define MOD 1000000007

void init();
void solve();

signed main()
{
	init();
	solve();
}

void init()
{
	int n;
	cin >> n;
	n -= 25;
	n = -n;
	cout << "Christmas";
	rep(i, n) cout << " Eve";
	cout << endl;
}

void solve()
{
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf int(1e6)
using namespace std;
int main(){
    int n,k;cin>>n>>k;
    int a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    int t[n];
    memset(t,inf,sizeof(t));
    t[0] = 0;
    for(int i=0;i<n;i++){
        for(int j=i+1;j<=i+k;j++){
            if(j<n)
                t[j] = min(t[j],t[i]+abs(a[i]-a[j]));
        }
    }
    cout<<t[n-1]<<endl;
    return 0;
}


Measured memory_bytes: 4412
n,k=map(int, input().split())
P = list(map(int, input().split()))
P=[i-1 for i in P]
C = list(map(int, input().split()))
visited=[-1]*n
group=[]

for i in range(n):
    if visited[i]!=-1:
        continue
    visited[i]=0
    group.append([i])
    now=P[i]
    while now!=i:
        group[-1].append(now)
        visited[now]=0
        now=P[now]
dp=[[0] for i in range(n)]

from collections import defaultdict
d=defaultdict(list)
for g in group:
    for i in g:
        now=i
        point=0
        for j in range(len(g)):
            now=P[now]
            point+=C[now]
            d[i].append(point)
ans=-float('inf')

for i in range(n):
    dic=d[i]
    leng=len(dic)
    if k<=leng:
        ans=max(ans, max(dic[:k]))
    else:
        if dic[-1]<=0:
            ans=max(ans, max(dic))
        else:
            if k%leng!=0:
                ans=max(ans,(k//leng)*dic[-1]+max(dic[:k%leng]))
            ans=max(ans,(k//leng-1)*dic[-1]+max(dic))
print(ans)


Measured memory_bytes: 281148
#include <iostream>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;

int main(){
    string str;
    int page;
    map<string, vector<int> > dict;
    while(cin>>str>>page){
        dict[str].push_back(page);
    }
    for(map<string, vector<int> >::iterator it=dict.begin(); it!=dict.end(); it++){
        sort(it->second.begin(), it->second.end());
        cout << it->first << endl;
        for(int i=0; i<(int)it->second.size(); i++){
            cout << it->second[i] ;
            cout << ((i<(int)it->second.size()-1)?' ':'\n');
         }
    }
    return 0;
}      

Measured memory_bytes: 0
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <algorithm>
#define mem(i,a) memset(i,a,sizeof(i))
#define PI acos(-1.0)
#define DMAX 100005
#define MOD 20190823
#define eps 1e-8
#define bl bool
#define INF 1e+9
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef double db;
template<class T> inline void read(T &f){
	f=0;
    T x=1;
    char ch=getchar();
    while(ch<48 || ch>57) {
        if(ch=='-') {
            x=-1;
        }
        ch=getchar();
    }
    while(ch<=57 && ch>=48) {
        f=f*10+ch-'0';
        ch=getchar();
    }
    f*=x;
}
int main(){
	ll a,b;
	read(a),read(b);
	ll maxn=max(a+b,a-b);
	maxn=max(maxn,a*b);
	cout<<maxn<<endl;
	return 0;
}

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

int main(int argc, char const *argv[])
{
    int n; cin >> n;
    if (n==1) {
        cout << "Hello World" << endl;
    } else if (n==2) {
        int a, b; cin >> a >> b;
        cout << a+b << endl;
    }
    return 0;
}


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

#define LL long long

const int MAX_N = (4 * 1e3) + 5;

int N;
string S;
int prefix_r[MAX_N];
int prefix_g[MAX_N];
int prefix_b[MAX_N];
LL answer = 0;

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

  cin >> N >> S;

  if(S[0] == 'R') prefix_r[0] = 1;
  if(S[0] == 'G') prefix_g[0] = 1;
  if(S[0] == 'B') prefix_b[0] = 1;
  for(int i = 1; i < N; i++) {
    if(S[i] == 'R') {
      prefix_r[i] = prefix_r[i - 1] + 1;
      prefix_g[i] = prefix_g[i - 1];
      prefix_b[i] = prefix_b[i - 1];
    }
    if(S[i] == 'G') {
      prefix_r[i] = prefix_r[i - 1];
      prefix_g[i] = prefix_g[i - 1] + 1;
      prefix_b[i] = prefix_b[i - 1];
    }
    if(S[i] == 'B') {
      prefix_r[i] = prefix_r[i - 1];
      prefix_g[i] = prefix_g[i - 1];
      prefix_b[i] = prefix_b[i - 1] + 1;
    }
  }

  for(int i = 0; i < N - 2; i++) {
    for(int j = i + 1; j < N - 1; j++) {
      if(S[i] == S[j]) continue;
      if(S[i] != 'R' && S[j] != 'R') {
        answer += prefix_r[N - 1] - prefix_r[j];
        if(j + (j - i) < N && S[j + (j - i)] == 'R') answer--;
      }
      if(S[i] != 'G' && S[j] != 'G') {
        answer += prefix_g[N - 1] - prefix_g[j];
        if(j + (j - i) < N && S[j + (j - i)] == 'G') answer--;
      }
      if(S[i] != 'B' && S[j] != 'B') {
        answer += prefix_b[N - 1] - prefix_b[j];
        if(j + (j - i) < N && S[j + (j - i)] == 'B') answer--;
      }
    }
  }

  cout << answer << "\n";

  return 0;
}

Measured memory_bytes: 3680
import java.util.*;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int m = sc.nextInt();
        int c = sc.nextInt();
        sc.nextLine();
        int b[] = new int[m];

        for(int i = 0;i<m;i++){
            b[i] = sc.nextInt();
        }
        sc.nextLine();

        int ans = 0;
        int tmp = 0;
        for(int i = 0;i<n;i++){
            for(int j = 0;j<m;j++){
                tmp += sc.nextInt()*b[j];
            }
            sc.nextLine();
            if(tmp + c > 0){
                ans++;
            }
            tmp = 0;
        }

        System.out.println(ans);
    }
}

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

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

    int k;
    int f[n];
    fill(f, f+n, 0);
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 10; j++) {
            cin >> k;
            if (k == 1) f[i] |= (1<<j);
        }
    }

    int p[n][11];
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 11; j++) {
            cin >> p[i][j];
        }
    }

    int ans;
    int tmp_ans;
    ans = -(1<<30);

    for (int i = 1; i < 1<<10; i++) {
        tmp_ans = 0;

        for (int j = 0; j < n; j++) {
            tmp_ans += p[j][__builtin_popcount(i&f[j])];
        }

        ans = max(ans, tmp_ans);
    }

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

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

#define MAX 200002

int n;
int k;

deque<int> d;

char buf[MAX];

string ans;


int main(){
	cin >> n >> k;
	scanf("%s", buf);
	for (int i = 0; i < n; i++){
		if (buf[i] - 'A' == 0){
			d.push_back((i & 1) ^ 1);
		}
		else{
			d.push_back((i & 1));
		}
	}
	if (n == 1){
		k %= 2;
		d.front() ^= k;
		return 1;
	}
	else{
		int C = 0;
		while (k&&C <= 3 * n){
			k--;
			C++;
			if (d.front() == 1){
				d.front() = 0;
				continue;
			}
			d.pop_front();
			d.push_back(((n - 1) & 1) ^ 1);
		}
		if (k == 0){

		}
		else{
			if (d.front() == 0&&d[1]==0){  //B
			}
			else{
				k %= 2;
				if (k){
					d.front() ^= 1;
				}
			}
		}
	}
	for (int i = 0; i < d.size(); i++){
		int go = ((i % 2) == d[i]);
		ans.push_back('A' + go);
	}
	printf("%s\n", ans.c_str());
	return 0;
}

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

namespace Contest
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] input = Console.ReadLine().Split(' ').Select(int.Parse).ToArray();
            int N = input[0];
            int K = input[1];
            string S = Console.ReadLine();
            int cnt = 0;
            for(int i = 0; i < N; i++)
            {
                if(S[i] == 'R')
                {
                    if(i != N - 1 && S[i + 1] == 'R')
                    {
                        cnt++;
                    }
                }
                else
                {
                    if(i != 0 && S[i - 1] == 'L')
                    {
                        cnt++;
                    }
                }
            }
            //出力
            Console.WriteLine(Math.Min(N -1, cnt + 2 * K));
            Console.ReadLine();
        }
    }
}


Measured memory_bytes: 13536
//
//  main.cpp
//  201910
//
//  Created by Hajime Sakamoto on 2019/10/09.
//  Copyright © 2019 Hajime Sakamoto. All rights reserved.
//

#include <iostream>
#include <stdio.h>

using namespace std;

int N, K, X, Y;

int fee=0;

void count_fee(int n,int k,int x,int y){
    if (n<=K){
        fee=n*x;
    }
    else{
        fee=k*x+(n-k)*y;
    }
}


int main(){
    cin >> N >> K>> X >> Y;
    
    count_fee(N, K, X, Y);
    
    cout << fee;
}


Measured memory_bytes: 256
// -----------------------------------
// author   : MatsuTaku
// country  : Japan
// created  : 06/14/20 20:53:44
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  int ans;
  for (int i = 0; i < 5; i++) {
    int x; cin>>x;
    if (x == 0)
      ans = i+1;
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define nl "\n"
#define rep(i,n) for(ll i=0; i<(n); i++)
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll,ll> pl;
typedef vector<pl> vp;
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define sortup(V) sort(V.begin(), V.end())
#define sortdown(V) sort(V.rbegin(), V.rend())
#define MOD 998244353 //1000000007


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

    // solution comes here

    ll N, S=0, n;
    cin >> N;
    n=N;
    while(n) {
        S += n%10;
        n /= 10;
    }

    cout << ((N%S) ? "No":"Yes") << nl;
}

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

#define rep(i,n) for(ll i = 0; i < n; i++)
#define per(i,n) for(ll i = n-1; i >= 0; i--)
#define REP(i,n) for(ll i = 1; i < n; i++)
#define PER(i,n) for(ll i = n; i >= 1; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
using vP = vector<P>;
using vPP = vector<vP>;
using vPl = vector<Pl>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



int main(){
  int n;
  cin >> n;
  int ans = 1000 - n % 1000;
  if(ans == 1000) ans = 0;
  cout << ans << endl;
}

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

#ifdef LOCAL
#include "../dump.hpp"
#else
#define dump(...)
#endif

#define rep(i,n) for(ll i=0,i##_cond=(n);i<i##_cond;++i)
#define FOR(i,a,b) for(ll i=(a),i##_cond=(b);i<i##_cond;++i)
#define ROF(i,a,b) for(ll i=(a)-1,i##_cond=(b);i>=i##_cond;--i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumulate(all(a),0)
#define sz(x) ((ll)(x).size())
#define pb push_back
#define fst first
#define snd second
#define mp make_pair

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<ll,ll> pii;

const ll inf = 1ll<<62;
const ll mod = 1e9+7;

#define int ll

main(){
  string s;
  while(1){
    string t;
    getline(cin, t);
    if(t == ".") break;
    rep(i,sz(t)){
      if(t[i] == '(') s += "(";
      else if(t[i] == ')') s += ")";
      else if(t[i] == '[') s += "[";
      else if(t[i] == ']') s += "]";
    }

    // 内側から消す
    while(1){
      string tmp = s;
      rep(i,sz(s)-1){
	if(s[i] == '(' and s[i+1] == ')'){
	  s.erase(i,2);
	  break;
	}else if(s[i] == '[' and s[i+1] == ']'){
	  s.erase(i,2);
	  break;
	}
      }  
      if(tmp == s) break;
    }
    if(s == "") cout << "yes" << endl;
    else cout << "no" << endl;
    s.clear();
  }
}


Measured memory_bytes: 3068
#include <iostream>
#include <cstring>
#include <cmath>
#include <cstdio>
#include <algorithm>
#include <queue>
#include <vector>
#include <map>

#define inf 0x3f3f3f3f

#define lc k << 1
#define rc k << 1 | 1

using namespace std;

typedef long long ll;

char ch[200005];
int n;

int f[1 << 26];
int g[200005];
int main(){
	scanf("%s", ch + 1);
	n = strlen(ch + 1);
	memset(f, 0x3f, sizeof(f));
	memset(g, 0x3f, sizeof(g));
	
	f[0] = 0; int ff = 0;
	for(int i = 1; i <= n; i ++){
		int t = ch[i] - 'a';
		ff = ff ^ (1 << t);
		if(ff == 0) g[i] = 1;
		for(int j = 0; j < 26; j ++){
			int r = ff ^ (1 << j);
			g[i] = min(g[i], f[r] + 1);
		}
		f[ff] = min(f[ff], g[i]); 
	}
	printf("%d\n", g[n]);
    return 0;
}

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

int main()
{
    int64_t n;
    std::cin >> n;
    std::unordered_map<int, int> m;
    for (int i = 0; i < n; ++i)
    {
        int a;
        std::cin >> a;
        m[a]++;
    }
    int q;
    std::cin >> q;

    int64_t sum = 0;
    for (auto& itr: m)
    {
        sum += itr.first * itr.second;
    }
    
    for (int i = 0; i < q; ++i)
    {
        int b, c;
        std::cin >> b >> c;
        sum += (c - b) * m[b];
        m[c] += m[b];
        m.erase(b);
        std::cout << sum << std::endl;
    }

    return 0;
}

Measured memory_bytes: 6532
/*
    ~A_Pessimist~:)
*/
 
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
 
const int sz=50000;
ll ans=-5e18;
vector<ll>vec;
ll p[sz],c[sz];
bool vis[sz];
 
void dfs(ll node, ll presum)
{
    if(vis[node]) return;
 
    vis[node]=true;
 
    presum+=c[node];
 
    vec.push_back(presum);
 
    dfs(p[node], presum);
}
 
void solve()
{
    ll n,k,i,j,rem,temp,mx=0,cycle;
    cin>>n>>k;
    for(i=0;i<n;i++)
    {
        cin>>p[i];
        p[i]--;
    }
    for(i=0;i<n;i++)
    {
        cin>>c[i];
    }
    for(i=0;i<n;i++)
    {
        memset(vis, false, sizeof vis);
        dfs(p[i],0);
        mx=-5e18;
 
        if(k>=vec.size() && vec.size() && vec.back()>0)
        {
            cycle=k/vec.size();
            rem=k%vec.size();
 
            temp=(cycle-1LL)*vec.back();
 
            for(j=0;j<vec.size();j++)
            {
                mx=max(mx, vec[j]);
            }
            ans=max(ans, temp+mx);
 
            mx=-5e18;
 
            for(j=0;j<rem;j++)
            {
                mx=max(mx, vec[j]);
            }
 
            temp=cycle*vec.back();
 
            ans=max(ans, temp+mx);
        }
        else
        {
            ll z=vec.size();
            for(j=0;j<min(z,k);j++)
            {
                ans=max(ans, vec[j]);
            }
        }
        vec.clear();
        temp=0;
    }
    cout<<ans<<endl;
}
 
int32_t main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
 
    int t=1;
   // cin>>t;
 
    while(t--)
    {
        solve();
    }
}

Measured memory_bytes: 4040
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <set>
#include <string>
#include <cstring>
#include <map>
using namespace std;
const int maxn = 2e5 + 100;
int dp[maxn];
int main()
{
    int n;
    scanf("%d",&n);
    for (int i = 1; i <= n; i++){
           int x;
           scanf("%d",&x);
           dp[x] = dp[x - 1] + 1;
    }
    int ans = 0;
    for (int i = 1; i <= n; i++){
        ans = max(dp[i],ans);
    }
    cout << n - ans << endl;
}

Measured memory_bytes: 1024
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7;// ;//1000000000 + 7 998244353 924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max()/100;
constexpr long long DINF = 1000000000000;
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<LL>>g;
vector<edge>ed;
vector<Pll>pv;
map<LL, LL>ma;
set<LL>st;
vector<LL>rest;
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
LL n, m, k, p, q, w, h, s, t, ans, cnt, sum, a[100][100], b[310000];
string str;
bool f;
char c[1100][1100];
int main() {
	cin >> n >> m >> k;
	cout << min(k, n*m) << endl;
	return 0;
}

Measured memory_bytes: 256
D = int(input())
c = list(map(int,input().split()))
s = [ [0 for j in range(26)] for i in range(D)]
for i in range(D):
    tmp = list(map(int,input().split()))
    for j in range(26):
        s[i][j] = tmp[j]
t = []
for i in range(D):
    t.append(int(input()))


v = [0] * D
last = [0] * 26
sat = 0
for d in range(D):
    j = t[d] - 1
    sat += s[d][j]
    last[j] = d+1
    for j in range(26):
        sat -= c[j] * ( d + 1 - last[j] )
    v[d] = sat

for i in range(D):
    print(v[i])

Measured memory_bytes: 9436
N, K = map(int, input().split())
TD = []
for _ in range(N):
    t, d = map(int, input().split())
    TD.append((t-1, d))

TD.sort(key=lambda x:-x[1])

import heapq

Tcount = [0]*N
chosen = []
heapq.heapify(chosen)

tot = 0
num_kinds = 0
ans = [0]*(N+1)

for i in range(K):
    t, d = TD[i]
    tot += d
    Tcount[t] += 1
    if Tcount[t] == 1: 
        num_kinds += 1
    if Tcount[t] > 1:
        heapq.heappush(chosen, d)

ans[num_kinds] = tot + num_kinds**2

for i in range(K, N):
    if len(chosen) == 0: break
    t, d = TD[i]
    if Tcount[t] > 0: continue
    Tcount[t] += 1
    num_kinds += 1
    tot = tot - heapq.heappop(chosen) + d
    ans[num_kinds] = tot + num_kinds**2
    
print(max(ans))

Measured memory_bytes: 89820
using System;

namespace Problem_A
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            const int N = 3;
            var str = "";
            for (var i = 0; i < N; i++)
            {
                var row = Console.ReadLine();
                for (var j = 0; j < N; j++)
                {
                    if (i == j) str += row[j];   
                }
            }
            Console.WriteLine(str);
        }
    }
}


Measured memory_bytes: 13140
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <stack>
#include <queue>
#include <bitset>     //UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>        //do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)

#define ST first
#define ND second
#define PB push_back
#define PF push_front
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double
#define pii pair<int,int>
#define pll pair<LL,LL>
#define vi vector<int>
#define vii vector<vi>

const double pi = 3.14159265358979323846264;
const int mod=1000000007;


//mod演算ライブラリ
//mod=1000000007

LL add(LL a,LL b){
  return (a+b)%mod;
}

LL sub(LL a,LL b){
  return (a+mod-b)%mod;
}

LL mul(LL a,LL b){
  return ((a % mod) * (b % mod)) % mod;
}

LL power(LL x,LL y){//繰り返し二乗法 単品利用可
  if(y==0)return 1;
  else if(y==1)return x%mod;
  else if(y%2==0){
    LL tmp=power(x, y/2) % mod;
    return tmp*tmp%mod;
  }else {
    LL tmp=power(x, y/2) % mod;
    return ((tmp*tmp)%mod)*x%mod;
  }
}

LL dvs(LL a,LL b){
  return mul(a,power(b,mod-2));
}

const int SIZE_mod=2000005;
int invfact[SIZE_mod];
int fact[SIZE_mod];

LL factset(int a){//aまでの階乗%mod表を作成
  fact[0]=1;
  FORQ(i,1,a){
    fact[i]=mul(fact[i-1],i);
  }
}

LL cmbset(int a){//1~aまでの階乗と階乗数の逆元のmod(mod)を用意 O(a)
  factset(a);
  invfact[a]=power(fact[a],mod-2);
  invfact[0]=1;
  FORD(i,a,1){
    invfact[i]=mul(invfact[i+1],i+1);
  }

}

LL cmb(int n,int r){//nCr%mod  (cmbset後に使用)
  if(n<r||r<0||n<0)return 0;
  return mul(fact[n],mul(invfact[r],invfact[n-r]));
}

LL prm(int n,int r){//nPr%mod
    return mul(cmb(n,r),fact[n]);
}

LL homo(int n,int r){//nHr%mod
  return cmb(n+r-1,r);
}


int main(){
    int x,y;
    cin>>x>>y;
    int time=(x+y)/3;
    if(time*3!=x+y){
        cout<<0;
        return 0;
    }
    x-=time;
    y-=time;
    cerr<<x<<" "<<y<<endl;
    if(x<0||y<0){
        cout<<0<<endl;
        return 0;
    }
    cmbset(2000000);
    cout<<cmb(x+y,x)<<endl;

	
}


Measured memory_bytes: 15872
from numpy import*;B=searchsorted;a,b=loadtxt(open(0),'i',skiprows=1);c=0;l=2**29
while l:h=l;l//=2;y=sort(hstack((b%h-h,b%h)));c+=sum(B(y,h-a%h)-B(y,l-a%h))%2*l
print(c)

Measured memory_bytes: 64164
#include<iostream>
using namespace std;
int x[3000], y[3000], a;
int main(){
	for (int i = 0; i < 3000; i++){


		cin >> x[i] >> y[i];
		if (x[i] == 0 && y[i] == 0){
			break;
		}
		else if (x[i] > y[i]){
			a = x[i];
			x[i] = y[i];
			y[i] = a;
		}
		cout << x[i] << ' ' << y[i] << endl;
	}
}


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

typedef long long ll;
typedef long double ld;

using namespace std;
int main()
{
  ll n, m, p[100010], ac = 0, wa = 0;
  string s[100010];
  unordered_map<ll, int> score;

  cin >> n >> m;
  for (ll i = 0; i < m; ++i)
  {
    cin >> p[i] >> s[i];
  }

  for (ll i = 0; i < m; ++i)
  {
    if (score[p[i]] != -1)
    {
      if (s[i] == "WA") ++score[p[i]];
      else
      {
        wa += score[p[i]];
        ++ac;
        score[p[i]] = -1;
      }

    }
  }

  cout << ac << " " << wa;
}


Measured memory_bytes: 10660
#include <bits/stdc++.h>
        #define s(a) cin >> a;
        #define s2(a,b) cin >> a>> b;
        #define s3(a,b,c) cin >> a>> b>> c;
        #define s4(a,b,c,d) cin >> a>> b >> c >> d;
        #define sp(b) cout << b << "\n";
        #define sp2(b,c) cout << b << " "<<c <<endl; 
        #define sp3(a,b,c) cout <<a <<" "<< b << " "<<c <<endl; 
        #define p(a) //////printf("%lld\n",a);
        #define p2(a,b) //////printf("%lld %lld",a,b);
        #define pm(a) //////printf("a\n");
        #define test(t) while(t>0)
        #define sl(a) a.length()
        #define f(a,b,c) for(a=b;a<c;a++)
        #define fr(a,b,c) for(a=c-1;a>=0;a--)
        #define v(a,b) vector<a> b;
        #define pb(a,b) a.push_back(b);
        #define ll long long
        #define mem(a,b) memset(a,b,sizeof(a));
        #define fillar(ar,n) f(i,0,n) s(ar[i]);
        #define diff(a,b) abs(a-b);
        using namespace std;
        #define MOD 1000000007
        #define flush fflush(stdout);
bool chekc(ll mid,ll n,ll m){
    ll remn=n-mid;
    ll remm=m-mid*2;
    // printf("remm=%lld,remn=%lld\n", remn,remm);
    if(remm>=0&&remn>=0){
        return true;
    }
    ll midd=min(n,m/2);
    // printf("midd=%lld\n",midd );
    n -=midd;
    m -=midd*2;
    midd=mid-midd;
    // printf("midd=%lld,n=%lld,m=%lld\n",midd,n,m );
    if(m==0){
        return false;
    }
    if(midd<=m/4){

        return true;
    }
    else{
        return false;
    }

}
int main(){
        ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
        int i,j,k;
        ll n,m;
        s2(n,m);
        ll ans=0;
        ll low=0;
        ll high=100000000000001;
        while(low<=high){
            ll mid=low+(high-low)/2;
            // printf("low=%lld,mid=%lld,n=%lld,m=%lld\n",low,mid,n,m);
            if(chekc(mid,n,m)){
                // printf("here\n");
                ans=mid;
                low=mid+1;

            }
            else{
                high=mid-1;
            }
        }
        printf("%lld\n",ans );
}

          

Measured memory_bytes: 256