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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}
#define MOD 998244353

std::vector<int> suffix_array(int len, const std::string &s) {
	int n = s.size();
	int m = n + 1 - len;
	if (len == 1) {
		int cnt[10] = { 0 };
		for (int i = 0; i < m; i++) cnt[s[i] + 1]++;
		for (int i = 0; i < 9; i++) cnt[i + 1] += cnt[i];
		std::vector<int> res(m);
		for (int i = 0; i < m; i++) res[i] = cnt[s[i]];
		return res;
	}
	int half = len / 2;
	auto sub = suffix_array(half, s);
	int cnt[n];
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < m; i++) cnt[sub[i + half]]++;
	for (int i = 0; i + 1 < n; i++) cnt[i + 1] += cnt[i];
	int tmp0[m];
	for (int i = m; i--; ) tmp0[--cnt[sub[i + half]]] = i;
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < m; i++) cnt[sub[tmp0[i]]]++;
	for (int i = 0; i + 1 < n; i++) cnt[i + 1] += cnt[i];
	int tmp1[m];
	for (int i = m; i--; ) tmp1[--cnt[sub[tmp0[i]]]] = tmp0[i];
	
	std::vector<int> res(m);
	int start = 0;
	int cnter = 0;
	for (int i = 1; i <= m; i++) {
		if (i == m || sub[tmp1[i]] != sub[tmp1[i - 1]] || sub[tmp1[i] + half] != sub[tmp1[i - 1] + half]) {
			if (len & 1) {
				int cnt[10] = { 0 };
				for (int j = start; j < i; j++) cnt[s[tmp1[j] + half + half] + 1]++;
				for (int j = 0; j < 9; j++) cnt[j + 1] += cnt[j];
				for (int j = start; j < i; j++) res[tmp1[j]] = cnter + cnt[s[tmp1[j] + half + half]];
			} else for (int j = start; j < i; j++) res[tmp1[j]] = cnter;
			cnter += i - start;
			start = i;
		}
	}
	return res;
}
std::vector<int> convert(const std::vector<int> &array) {
	std::vector<int> res(array.size());
	int cnt[array.size()];
	memset(cnt, 0, sizeof(cnt));
	for (int i = 0; i < (int) array.size(); i++) res[array[i] + cnt[array[i]]++] = i;
	return res;
}

int main() {
	int k = ri() + 1;
	std::string s;
	std::cin >> s;
	for (auto &i : s) i -= '1';
	int n = s.size();
	
	int one = n / k;
	int big_num = n - k * one; // n = (one + 1) * big_num + one * (k - big_num)
	
	if (!big_num) {
		auto sarray = suffix_array(one, s);
		for (auto &i : s) i += '1';
		int index = -1;
		int max = -1;
		for (int i = 0; i <= n - one; i += one) if (max < sarray[i]) max = sarray[i], index = i;
		printf("%s\n", s.substr(index, one).c_str());
		return 0;
	}
	
	auto slist = convert(suffix_array(one + 1, s));
	
	// std::cerr << one << std::endl;
	// std::cerr << big_num << std::endl;
	
	int l = big_num - 1, r = slist.size();
	while (r - l > 1) {
		int m = l + ((r - l) >> 1);
		// std::cerr << "mid:" << m << std::endl;
		std::vector<int> all;
		for (int i = 0; i < m; i++) all.push_back(slist[i]);
		std::sort(all.begin(), all.end());
		// for (auto i : all) std::cerr << i << " ";
		// std::cerr << std::endl;
		int last = 0;
		int got = 0;
		for (auto i : all)
			if (i >= last && (i - last) % one == 0) got++, last = i + one + 1;
		if (got >= big_num) r = m;
		else l = m;
	}
	// std::cerr << r << std::endl;
	// std::cerr << slist[l] << std::endl;
	for (auto &i : s) i += '1';
	std::cout << s.substr(slist[l], one + 1) << std::endl;
	return 0;
}
 

Measured memory_bytes: 3120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N,x;
  cin >>N>>x;
  vector<int> a(N);
  for (int i=0;i<N;i++){
    cin >> a.at(i);
  }
  sort(a.begin(),a.end());
  int c=0;
  for (int i=0;i<N-1;i++){
    if (x>=a.at(i)){
      x-=a.at(i);
      c++;
    }
    else break;
  }
  if(x==a.at(N-1))c++;
  
  cout << c <<endl;
  
}

Measured memory_bytes: 256
#!coding:utf-8

n = input()
a = [int(i) for i in raw_input().split()]
a.sort()

ok = True

if(n%2==0):
    for i in range(n):
        if(a[i]!=(i/2*2+1)):
            ok = False

if(n%2==1):
    for i in range(n):
        if(a[i]!=((i+1)/2*2)):
            ok = False


if(ok):
    print 2**(n/2)%1000000007
        
else:
    print '0'

Measured memory_bytes: 11584
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(x, name)in(x)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(x,v) for(auto &x:(v))
#define all(x) (x).begin(),(x).end()
#define print(x) cout<<(x)<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);
  VEC(ll, A, N);
  vl Ad(N);
  rep(i, 0, N) {
    Ad[i] = A[i] - i - 1;
  }

  sort(all(Ad));

  ll m = N % 2 ? Ad[N / 2] : round((double)(Ad[N / 2 - 1] + Ad[N / 2]) / 2);
  ll ans = 0;
  rep(i, 0, N) {
    ans += abs(Ad[i] - m);
  }

  print(ans);
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
 
// in-short-use macros
 
#define all(c) (c).begin(),(c).end()
#define ll long long int
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define mod 1000000007
#define PI 3.14159265
#define sizes 1000010
 
//main function here
 
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	
	int n;
	cin>>n;
	bool flag = false;
	int x =0 ;
	for(int i=0,a,b;i<n;i++)
	{	
		cin>>a>>b;
		if(a==b)
			x++;
		else
			x=0;
		if(x==3)
			flag=true;
	}
	if(flag)
		cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}

Measured memory_bytes: 3648
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
using namespace std;
 
typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
 
int DX[4] = {-1, 0, 1, 0};
int DY[4] = {0, -1, 0, 1};
 
int H, W, K;
int SX, SY;
char A[800][800];
int D[800][800];
 
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> H >> W >> K;
  rep(y, H) {
    rep(x, W) {
      cin >> A[x][y];
      if (A[x][y] == 'S') SX = x, SY = y;
    }
  }
  rep(y, H) {
    rep(x, W) {
      D[x][y] = INF;
    }
  }
  queue<P> q;
  q.push(P(SX, SY));
  D[SX][SY] = 0;
  while (!q.empty()) {
    int x = q.front()._1, y = q.front()._2;
    q.pop();
 
    int d = D[x][y];
    if (d == K) continue;
 
    rep(k, 4) {
      int nx = x+DX[k], ny = y+DY[k];
      if (nx<0||nx>=W||ny<0||ny>=H) continue;
      if (A[nx][ny] == '#') continue;
      if (D[nx][ny] > d+1) {
        D[nx][ny] = d+1;
        q.push(P(nx, ny));
      }
    }
  }
  int m = INF;
  rep(y, H) {
    rep(x, W) {
      if (D[x][y] < INF) {
        m = min(m, x);
        m = min(m, y);
        m = min(m, W-1-x);
        m = min(m, H-1-y);
      }
    }
  }
  int steps = 1 + (m+(K-1))/K;
  cout << steps << endl;
  return 0;
}

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

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

	vector<int> a( n );
	for( int& v: a ) { cin >> v; }

	for( int i = 0; i < a.size()/2; ++i ) {
		int r = a.size() - 1 - i;

		int t = a.at( i );
		a.at( i ) = a.at( r );
		a.at( r ) = t;
	}

	for( int i = 0; i < a.size(); ++i ) {
		cout << a.at( i );

		if( i != a.size()-1 ) {
			cout << " ";
		}
	}

	cout << endl;
}



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

using namespace std;

const int maxn = 1e5 + 50;


int n , fa[maxn] , seq[maxn] , len , a[maxn] ,sz[maxn];
vector < int > G[maxn];

void Dfs( int u ){
	sz[u] = 1;
	for(auto v : G[u]){
		if( v == fa[u] )
			continue;
		fa[v] = u;
		Dfs( v );
		sz[u] += sz[v];
	}
}

int main( int argc , char * argv[] ){
	scanf( "%d" , & n );
	for(int i = 2 ; i <= n ; ++ i){
		int u , v;
		scanf( "%d%d" , & u , & v );
		G[u].emplace_back( v );
		G[v].emplace_back( u );
	}
	Dfs( 1 );
	for(int i = n ; i >= 1 ; i = fa[i])
		seq[len ++] = i;
	reverse( seq , seq + len );
	for(int i = 0 ; i + 1 < len ; ++ i)
		a[i] = sz[seq[i]] - sz[seq[i + 1]];
	a[len - 1] = sz[seq[len - 1]];
	int mid = ( len + 1 ) >> 1;
	int fst = 0 , scd = 0;
	for(int i = 0 ; i < mid ; ++ i) fst += a[i] + 1;
	for(int i = mid ; i < len ; ++ i) scd += a[i] + 1;
	if( fst > scd )
		puts( "Fennec" );
	else
		puts( "Snuke" );
	return 0;
}

Measured memory_bytes: 11904
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define int long long
#define mod 1000000007
#define INF 1145141919364364
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}

int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1)*x%mod;
}

int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1)res = res * x%mood;
		x = x * x%mood;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

int n, m, l, r, d;
int par[100010], ran[100010], wei[100010];

void init(int n) {
	for (int i = 1; i <= n; i++) {
		par[i] = i;
		ran[i] = 0;
		wei[i] = 0;
	}
}

int find(int x) {
	if (par[x] == x)return x;
	int r = find(par[x]);
	wei[x] += wei[par[x]];
	return par[x] = r;
}

int weight(int x) {
	find(x);
	return wei[x];
}

void unite(int x, int y, int b) {
	b += weight(x);
	b -= weight(y);
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (ran[x] < ran[y]) {
		par[x] = y;
		wei[x] = -b;
	}
	else {
		par[y] = x;
		wei[y] = b;
		if (ran[x] == ran[y])ran[x]++;
	}
}

bool same(int x, int y) {
	return find(x) == find(y);
}

int diff(int x, int y) {
	return weight(y) - weight(x);
}

signed main() {
	cin >> n >> m;
	init(100000);
	for (int i = 0; i < m; i++) {
		cin >> l >> r >> d;
		if (same(l, r)) {
			if (diff(l, r) != d) {
				cout << "No" << endl;
				return 0;
			}
		}
		else {
			unite(l, r, d);
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 2560
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 

#define print(stuff) cout << stuff << endl
#define printc(stuff) for(auto x: stuff) cout << x << " "; cout << endl;
#define printPrec(stuff) cout << fixed << setprecision(15) << stuff << endl;
#define debug(stuff) cout << #stuff << ": " << stuff <<endl
#define debugc(stuff) cout << #stuff << ": "; for(auto x: stuff) cout << x << " "; cout << endl;
#define len length
#define ret0 return 0
#define ret return 

#define ll long long
#define ld long double
#define fi first
#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound
#define fill(ar, x) memset(ar, x, sizeof ar)

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

// typedef tree<ll,null_type,less<ll>,rb_tree_tag,
// tree_order_statistics_node_update> indexed_set;

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100005

vl adj[MAXN];
ll coeff[MAXN];
ll par[MAXN];
ll n, k;

void aux(ll s, ll e){
    par[s]=e;
    for(auto x: adj[s]){
        if(x!=e) aux(x, s);
    }
}
void dfs(ll s, ll e, ll cnt){
    // debug(s<<" "<<e<<" "<<cnt);
    if(s!=1){
        coeff[s]=k;
        if(par[s]) coeff[s]--;
        if(par[par[s]]) coeff[s]--;
        coeff[s]-=cnt;
    }
    // debug(coeff[s]);
    ll c=0;
    for(ll i=0; i<adj[s].size(); i++){
        if(adj[s][i]!=e){
            dfs(adj[s][i], s, c);
            c++;
        }
    }
}

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

    cin>>n>>k;
    loop(i,0,n-1){
        ll a, b;
        cin>>a>>b;
        adj[a].pb(b), adj[b].pb(a);
    }
    loop(i,1,n) par[i]=0;
    coeff[1]=k;
    aux(1, 0);
    dfs(1, 0, 0);
    // printc(coeff);
    ll ans = 1;
    for(ll i=1; i<=n; i++){
        ans = (ans%mod * coeff[i]%mod)%mod;
    }
    print(ans);
        
    
}



Measured memory_bytes: 10496
N,K = map(int, input().split())
A = [[int(a) for a in input().split()] for _ in range(N)]

mod = 10**9+7

import numpy as np

a = np.array(A, dtype=object)
Mat = np.eye(N, dtype=object)

while K:
    if K%2:
        Mat = np.dot(Mat, a)%mod
    a = np.dot(a, a)%mod
    K //= 2
    
ans = 0
for i in range(N):
    for j in range(N):
        ans += Mat[i, j]
        ans %= mod
        
print(ans)

Measured memory_bytes: 14476
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
using P = pair<lint, lint>;
#define FOR(i, begin, end) for(int i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(int i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
constexpr int MOD = 1000000007;
constexpr int INF = 2147483647;
void yes(bool expr) {
  cout << (expr ? "Yes" : "No") << "\n";
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  int N, Z, W;
  cin >> N >> Z >> W;
  vector<lint> a(N);
  REP(i, N) cin >> a[i];
  lint ans = abs(a[N-1]-W);
  if(N > 1) ans = max(ans, abs(a[N-2]-a[N-1]));
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;
uint64_t gcd(uint64_t a, uint64_t b);
uint64_t lcm(uint64_t a, uint64_t b);

template <typename T>
static inline void ArrayInput(vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cin >> *itr;
}

template <typename T>
static inline void ArrayPut(const vector<T>& A) {
  for (auto itr = A.begin(); itr < A.end(); ++itr) cout << *itr << " ";
  cout << endl;
}

bool Sec_compare(pair<uint64_t, uint64_t> a, pair<uint64_t, uint64_t> b) {
  if (a.second != b.second) {
    return a.second < b.second;
  } else {
    return a.first < b.first;
  }
}

int main() {
  uint32_t N, M;
  cin >> N >> M;
  vector<bool> Res;
  Res.assign(N, false);
  vector<uint32_t> P_Cnt;
  P_Cnt.assign(N, 0);

  for (uint32_t i = 0; i < M; ++i) {
    uint32_t p;
    string S;
    cin >> p >> S;
    if (Res[p - 1]) {
      continue;
    }
    if (S != "AC") {
      ++P_Cnt[p - 1];
    } else {
      Res[p - 1] = true;
    }
  }
  uint64_t P_Res = 0;
  uint32_t C_Res = 0;
  for (uint32_t i = 0; i < N; ++i) {
    if (Res[i]) {
      C_Res++;
      P_Res += P_Cnt[i];
    }
  }
  cout << C_Res << " " << P_Res << endl;
  return 0;
}

uint64_t gcd(uint64_t a, uint64_t b) {
  if (a < b) {
    a ^= b;
    b ^= a;
    a ^= b;
  }

  return b ? gcd(b, a % b) : a;
}

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

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

using namespace std;

#define INF 210000000
#define int long long

bool cmp(int a,int b){
		return a > b;
}

signed main() {
		int n;
		cin >> n;
		map<int,int> cnt;
		int min = INF;
		int max = 0;
		for(int i=0;i<n;i++){
				int tmp;
				cin >> tmp;
				cnt[tmp]++;
				if(tmp < min) min = tmp;
				if(tmp > max) max = tmp;
		}
		int ans = 0;
		for(int i=min;i<=max;i++){
				if(ans < (cnt[i-1]+cnt[i]+cnt[i+1])) ans = cnt[i-1]+cnt[i]+cnt[i+1];
		}
		cout << ans << endl;
}


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

using namespace std;

inline int ctoi(char c) { if(c < '0' || '9' < c) throw invalid_argument("ctoi error"); return c - '0'; }
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define REP(i, k, n) for(int i = (int)(k); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()

template <typename T>
inline T gcd(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("gcd error: x <= 0 or y <= 0");
	
	if(x < y) swap(x, y);
	T r = x % y;

	while(r != 0){
		x = y;
		y = r;
		r = x % y;
	}

	return y;
}
template <typename T>
inline T lcm(T x, T y){
	if (x <= 0 || y <= 0) throw invalid_argument("lcm error: x <= 0 or y <= 0");

	return x * y / gcd(x, y);
}

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

	vector<unsigned long long int> input;

	rep(i, n){
		unsigned long long int a;
		cin >> a;

		if(a == 0){
			cout << 0;
			return 0;
		}

		input.push_back(a);
	}

	unsigned long long ans = input[0];

	REP(i, 1, input.size()){
		if(18 <= log10(ans) + log10(input[i])){
			if(1000000000000000000 / ans == input[i]){
				ans = 1000000000000000000;
			}
			else{
				cout << -1;
				return 0;
			}
		}
		else{
			ans *= input[i];
		}
	}

	cout << ans;

	return 0;
}

Measured memory_bytes: 4380
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define For(i,n,k) for(int i=(n);i<(k);i++)
#define ALL(a)  (a).begin(),(a).end()
ll ans=0;
void Main(){
    int N;
    cin >> N;
    For(n,1,N+1){
        ll cnt=0;
        for(int a=1;a*a<n;a++){
            for(int b=1;a*a+a*b+b*b<n;b++){
                for(int c=1;a*a+a*b+b*b+a*c+b*c+c*c<=n;c++){
                    if(a*a+a*b+b*b+a*c+b*c+c*c==n){
                        cnt++;
                        //cout << n << " " << a << " " << b << " " << c;
                        break;
                    }
                }
            }
        }
        cout << cnt << endl;
    }
}
int main(){
    Main();
    /*
    東方風神録は神が出てくるので当然神ゲー
    */
    return 0;
}


Measured memory_bytes: 3552
#include <bits/stdc++.h>
#define rep(i,n)  for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define deb(x) cerr << #x <<": " << x << '\n';
#define ios ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using namespace std;
typedef long double ld;
typedef long long ll;

int main(){
    ios;
    ll a, b;
    cin >> a >> b;
    cout << a * b;

    
    return 0;
}



Measured memory_bytes: 3652
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF= 1LL << 60;
#define REP(i,n) for(ll i=0; i<n; i++)
#define FOR(i,a,n) for(ll i=a; i<n; i++)
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, k;
    cin >> h >> w >> k;
    int num= 1;
    vector<vector<char>>A(h,vector<char>(w,0));
    vector<vector<int>>mmap(h,vector<int>(w,0));
    map<int,int>empty;
    int flag= 0;
    REP(i,h){
        REP(j,w){
            cin >> A[i][j];

            if(A[i][j]=='.'){
                mmap[i][j]= 0;
            }else if(A[i][j]=='#'){
                mmap[i][j]= num;
                num++;
                flag= 1;
            }
        }
        if(!flag){
            empty[i]++;
            
        }flag= 0;
    }
    num= 0;
    int t;
    REP(i,h){
        if(empty[i]==0){
            num++;
        }
        REP(j,w){
            if(empty[i]==0){
                if(num==1)t= i;
                if(mmap[i][j]!=0){
                    num= mmap[i][j];
                }else{
                    mmap[i][j]= num;
                }
            }
        }
    }
    
    REP(i,h){
        REP(j,w){
            if(empty[i]==1){
                mmap[i][j]= mmap[t][j];
            }else{
                t= i;
                break;
            }
        } 
    }

    REP(i,h){
        REP(j,w){
            cout << mmap[i][j] << ((j!=w-1)?" ":"");
        }cout << endl;
    }
    // cout << s;
    
}

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

namespace 競プロ_Csharp {
    class Program {
        static void Main(string[] args) {

            int n = int.Parse(Console.ReadLine());
            Console.WriteLine(n * n * n);

        }
    }
}



Measured memory_bytes: 15976
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int a[3001][3001];
int main()
{
	ios_base::sync_with_stdio(0); 
    cin.tie(0);   
	int n,m;
	string s1,s2,ans="";
	cin>>s1>>s2;
	n=s1.size();
	m=s2.size();
	for(int i=0;i<=n;i++)
		for(int j=0;i<=m;i++)
			a[i][j]=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=1;j<=m;j++)
		{
			if(s1[i-1]==s2[j-1])
			{
				a[i][j]=a[i-1][j-1]+1;
			}
			else
				a[i][j]=max(a[i-1][j],a[i][j-1]);
			// cout<<a[i][j]<<" ";
		}
		// cout<<endl;
	}
	ll i=n,j=m;
	while(i>0 && j>0)
	{
		if(s1[i-1]==s2[j-1])
		{
			ans+=s1[i-1];
			i--;
			j--;
		}
		else if(a[i-1][j]>a[i][j-1])
			i--;
		else
			j--;
	}
	for(int i=ans.size()-1;i>=0;i--)
		cout<<ans[i];
	cout<<endl;
	return 0;
}

Measured memory_bytes: 38748
#include <bits/stdc++.h>
using namespace std;
const long long MAXI=pow(10,18);

int main(){
  int N;cin>>N;
  vector<long long> A(N),S(N+1,1);
  for(int i=0;i<N;i++){
    cin>>A.at(i);
    if(A.at(i)==0){
      cout<<0<<endl;
      return 0;
    }
    else {
      S.at(i+1)=S.at(i)*A.at(i);
      if(S.at(i+1)>MAXI||S.at(i+1)<S.at(i)||A.at(i)>MAXI){
        S.at(i+1)=-1;
      }
    }
  }
  cout<<S.at(N)<<endl;
}

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

int main() {
    ll a, v, b, w, t;
    cin >> a >> v >> b >> w >> t;

    ll d = abs(a-b);

    if((v-w)*t >= d) {
        cout << "YES" << endl;
    }
    else cout << "NO" << endl;


    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
//using namespace atcoder;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define Sort(v) sort(v.begin(), v.end())
#define Reverse(v) reverse(v.begin(), v.end())
#define all(v) v.begin(),v.end()
#define SZ(v) ((int)v.size())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define bit(n) (1LL<<(n))
#define debug(x) cout << #x << "=" << x << endl;
#define vdebug(v) { cout << #v << "=" << endl; REP(i_debug, v.size()){ cout << v[i_debug] << ","; } cout << endl; }
#define mdebug(m) { cout << #m << "=" << endl; REP(i_debug, m.size()){ REP(j_debug, m[i_debug].size()){ cout << m[i_debug][j_debug] << ","; } cout << endl;} }
#define pb push_back
#define fi first
#define se second
#define int long long
#define INF 1000000000000000000
template<typename T> istream &operator>>(istream &is, vector<T> &v){ for (auto &x : v) is >> x; return is; }
template<typename T> ostream &operator<<(ostream &os, vector<T> &v){ for(int i = 0; i < v.size(); i++) { cout << v[i]; if(i != v.size() - 1) cout << endl; }; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p){ cout << '(' << p.first << ',' << p.second << ')'; return os; }
template<typename T> void Out(T x) { cout << x << endl; }
template<typename T1, typename T2> void chOut(bool f, T1 y, T2 n) { if(f) Out(y); else Out(n); }

using vec = vector<int>;
using mat = vector<vec>;
using Pii = pair<int, int>;
using v_bool = vector<bool>;
using v_Pii = vector<Pii>;

//int dx[4] = {1,0,-1,0};
//int dy[4] = {0,1,0,-1};
//char d[4] = {'D','R','U','L'};

const int mod = 1000000007;
//const int mod = 998244353;

vector<int> KMP(vector<int> A){
    int N = A.size();
    vector<int> K(N + 1), next(N);
    K[0] = -1; next[0] = -1;
    int j = -1;
    for(int i = 0; i < N; i++){
        while(j >= 0 && A[i] != A[j]) j = next[j];
        j++;
        K[i + 1] = j;
        if(i + 1 < N){
            if(A[i + 1] == A[j]) next[i + 1] = next[j];
            else next[i + 1] = j;
        }
    }
    return K;
}

vector<int> KMP(string S){
    int N = S.size();
    vector<int> A(N);
    for(int i = 0; i < N; i++) A[i] = (int)S[i];
    return KMP(A);
}

signed main(){

    string S; cin >> S;
    int N = SZ(S);

    vec k0 = KMP(S);
    Reverse(S);
    vec k1 = KMP(S);

    int d = N - k0[N];
    if(d == 1){
        Out(N);
        Out(1);
    }else if(d == N || N % d){
        Out(1);
        Out(1);
    }else{
        int ans = 0;
        FOR(i, 1, N){
            int d0 = i - k0[i], d1 = N - i - k1[N - i];
            if((d0 == i || i % d0) && (d1 == N - i || (N - i) % d1)) ans++;
        }
        Out(2);
        Out(ans);
    }

    return 0;
}


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

typedef long long ll;
typedef pair<int, int> ii;

int a, b;
char op;

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

  cin >> a >> op >> b;
  if (op == '+') {
    cout << a + b << endl;
  } else {
    cout << a - b << endl;
  }

  return 0;
}


Measured memory_bytes: 256
use std::io::*;

fn main() {
    let mut s: String = String::new();
    std::io::stdin().read_to_string(&mut s).ok();
    let mut itr = s.trim().split_whitespace();
    let x: usize = itr.next().unwrap().parse().unwrap();
    let y: usize = itr.next().unwrap().parse().unwrap();
    let a: usize = itr.next().unwrap().parse().unwrap();
    let b: usize = itr.next().unwrap().parse().unwrap();
    let c: usize = itr.next().unwrap().parse().unwrap();
    let mut p: Vec<usize> = (0..a)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut q: Vec<usize> = (0..b)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();
    let mut r: Vec<usize> = (0..c)
        .map(|_| itr.next().unwrap().parse().unwrap())
        .collect();

    p.sort_by(|a, b| b.cmp(&a));
    q.sort_by(|a, b| b.cmp(&a));
    r.sort_by(|a, b| b.cmp(&a));
    let mut ans = Vec::new();
    for i in 0..x {
        ans.push(p[i]);
    }
    for i in 0..y {
        ans.push(q[i]);
    }
    for i in 0..c {
        ans.push(r[i]);
    }
    ans.sort_by(|a, b| b.cmp(&a));
    let mut sum = 0;
    for i in 0..x + y {
        sum += ans[i];
    }
    println!("{}", sum);
}


Measured memory_bytes: 17708
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define ll long long
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ rep(i, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

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

    ll sum = 0;
    rep(i, n){
        sum ^= a[i];
    }

    bool flg = true;
    rep(i, n){
        if(sum^=a[i] != a[i]){
            flg = false;
            break;
        }
    }

    ans(flg);

    return 0;
}


Measured memory_bytes: 1024
class Combination:
    """階乗とその逆元のテーブルをO(N)で事前作成し、組み合わせの計算をO(1)で行う"""
    def __init__(self, n, mod):
        self.fact = [1]
        for i in range(1, n + 1):
            self.fact.append(self.fact[-1] * i % mod)
        self.inv_fact = [0] * (n + 1)
        self.inv_fact[n] = pow(self.fact[n], mod - 2, mod)
        for i in reversed(range(n)):
            self.inv_fact[i] = self.inv_fact[i + 1] * (i + 1) % mod
        self.mod = mod

    def factorial(self, k):
        """k!を求める O(1)"""
        return self.fact[k]

    def inverse_factorial(self, k):
        """k!の逆元を求める O(1)"""
        return self.inv_fact[k]

    def permutation(self, k, r):
        """kPrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r]) % self.mod

    def combination(self, k, r):
        """kCrを求める O(1)"""
        if k < r:
            return 0
        return (self.fact[k] * self.inv_fact[k - r] * self.inv_fact[r]) % self.mod

    def combination_large(self, k, r):
        """kCrを求める O(r) kが大きいが、r <= nを満たしているときに使用"""
        if k < r:
            return 0
        res = 1
        for l in range(r):
            res *= (k - l)
            res %= self.mod
        return (res * self.inv_fact[r]) % self.mod



x, y = map(int, input().split())
mod = 10**9 + 7
comb = Combination(10**6,mod)

if (x+y)%3 != 0:
    print(0)
    exit(0)
i = (2*x-y)//3
j = (2*y-x)//3
n = i+j
r = i
if not 0 <= r <= n:
    print(0)
    exit(0)
print(comb.combination(n, r))


Measured memory_bytes: 156928
#include<stdio.h>
#include<stdlib.h>
int compare(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main(void) {
    int n,k;
    scanf("%d%d",&n,&k);
    int s[n];
    int i;
    int ans=0;
    for (i=0; i<n; i++) {
        scanf("%d",&s[i]);
    }
    qsort(s,n,sizeof(int),compare);
    for (i=0; i<k; i++) {
        ans += s[i];
    }
    printf("%d\n",ans);
    return 0;
}


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

#define fst first
#define scd second
#define PB push_back
#define MP make_pair
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define omajinai ios::sync_with_stdio(false);cin.tie(0)
#define rep(i,x) for(int i=0;i<(int)(x);++i)
#define rep1(i,x) for(int i=1;i<=(int)(x);++i)
#define rrep(i,x) for(int i=(int)x-1;i>=0;--i)
#define rrep1(i,x) for(int i=(int)x;i>=1;--i)

using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int, int>;
using vpii=vector<pii>;

template<class T,class U>ostream&operator<<(ostream&os,const pair<T,U>p){os<<"("<<p.fst<<", "<<p.scd<<")";return os;}
template<class T>ostream&operator<<(ostream&os,const vector<T>v){rep(i,v.size()){if(i)os<<", ";os<<v[i];}return os;}
template<typename T>T&max(T&a,T&b){if(a>=b)return a;return b;}
template<typename T>T&min(T&a,T&b){if(a < b)return a;return b;}
template<typename T>bool chmax(T&a,T b){if(a < b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a > b){a=b;return true;}return false;}

constexpr int inf = 1e9;
constexpr ll linf = 3e18;
constexpr double eps = 1e-9;

int N, K;

signed main()
{
    cin >> N >> K;
    vector<int> H(N);
    rep(i, N) cin >> H[i];

    sort(all(H));

    long long ans = 0;
    rep(i, N-K) ans += H[i];

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 1024
import math

def prime_check(n):
    if n == 1:
        return False

    for i in range(2, int(math.sqrt(n)) + 1):
        if n % i == 0:
            return False

    return True

x = int(input())

for i in range(x, 1000000):
    if prime_check(i):
        print(i)
        break

Measured memory_bytes: 3060
#include<stdio.h>
#define N_MAX 40

typedef struct data
{
	int value;
	char mark;
}Data;

Data C[N_MAX], C1[N_MAX], C2[N_MAX];

void BubbleSort(Data C[N_MAX], int N);
void SelectionSort(Data C[N_MAX], int N);
 
void BubbleSort(Data C1[N_MAX], int N)
{	
	int i, j, flag=0;
	Data work;

	for(i=0; i<N; i++){
		for(j=N-1; j>i; j--){
			if(C1[j].value < C1[j-1].value){
				work=C1[j];
				C1[j]=C1[j-1];
				C1[j-1]=work;
			}
		}
	}
	for(i=0; i<N; i++){
		printf("%c%d", C1[i].mark, C1[i].value);
		if(i!=N-1) printf(" ");
	}
	printf("\nStable\n");
}



void SelectionSort(Data C2[N_MAX], int N)
{
	int i, j, flag=0;
	Data work;
	int minj;

	for(i=0; i<N; i++){
		minj=i;
		for(j=i; j<N; j++){
			if(C2[j].value < C2[minj].value){
				minj = j;
				}
		}
			work = C2[i];
			C2[i] = C2[minj];
			C2[minj] = work;
	}

	for(i=0; i<N; i++){
		printf("%c%d", C2[i].mark, C2[i].value);
		if(i!=N-1)printf(" ");
	}
		
	printf("\n");

	for(i=0; i<N; i++){
		if(C2[i].mark != C1[i].mark)
			flag = 1;
	}

	if(flag == 1)
		printf("Not stable\n");
	else
		printf("Stable\n");
}

int main()
{
	int N;
	int i;

	scanf("%d", &N);

	for(i=0; i<N; i++){
		scanf(" %c%d", &C[i].mark, &C[i].value);
	}	

	for(i=0; i<N; i++){
		C1[i] = C[i];
		C2[i] = C[i];
	}


	BubbleSort(C1, N);
	SelectionSort(C2, N);

	return 0;

}

Measured memory_bytes: 612
#include <iostream>

using namespace std;

int main(){
    int sum = 0;
    for(int i = 0; i < 3; i++){
        int a;
        cin >> a;
        sum += a;
    }
    if(22 <= sum){
        cout << "bust\n";
    }else{
        cout << "win\n";
    }
}

Measured memory_bytes: 256
import itertools
n = int(input())

counter = {}
for i in range(n):
  head = input()[0]
  if head not in counter:
    counter[head] = 1
  else:
    counter[head] += 1

char_num = 0
char_count = []
for c in "MARCH":
  if c in counter:
    char_num += 1
    char_count.append(counter[c])

ans = 0
if char_num < 3:
  print(0)
else:
  for a, b, c in itertools.combinations(char_count, 3):
    ans += a * b * c
  print(ans)

Measured memory_bytes: 3064
n, k = map(int, input().split())
d = []
a = []
for _ in range(k):
    d.append(int(input()))
    a.append(list(map(int, input().split())))

sunuke = [0] * n

for candy in a:
    for i in candy:
        i -= 1
        sunuke[i] += 1

print(len([i for i in sunuke if i == 0]))

Measured memory_bytes: 9168
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count = Integer.parseInt(sc.nextLine());
		float sum = 0;

		for(int i = 0; i < count; i++) {
			String[] data = sc.nextLine().split(" ");
			float money = Float.parseFloat(data[0]);
			String tuuka = data[1];

			if(tuuka.equals("BTC")) {
				sum += money * 380000;
			}else {
				sum += money;
			}
		}
		System.out.println(sum);
	}
}


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

namespace ABC094D
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Split().Select(int.Parse).ToArray();

            int n = ai.Max();
            int r = -1;
            for(int i = 0; i < N; i++)
            {
                if (ai[i] == n) continue;
                double d = Math.Abs(n / 2.0 - ai[i]);
                double d2 = Math.Abs(n / 2.0 - r);
                if (d < d2) r = ai[i];
            }
            Console.WriteLine(n + " " + r);
            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 20960
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector <long long int, long long int> 
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int MAX = 1e5 + 5;
bool done[MAX];
int main()
{
	boost;
	int n, m, i, x, y;
	string s;
	cin >> n >> m;
	memset(done, false, sizeof done);
	int w[MAX];
	memset(w, 0, sizeof w);
	int ac = 0, wa = 0;
	fo(i, 0, m){
		cin >> x >> s;
		if(s == "AC"){
			if(done[x])
			continue;
			else
			ac++;
			done[x] = true;
		}
		else{
			if(done[x])
			continue;
			else
			w[x]++;
		}
	}
	foe(i, 1, n){
		if(done[i])
		wa += w[i];
	}
	cout << ac << ' ' << wa;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int a[105];
int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int i,n,m,s=0;
    cin>>n;
    for(i=0; i<n; i++)
    {
        cin>>a[i];
        s+=a[i];
    }
    sort(a,a+n);
    if((s%10)==0)
    {
        for(i=0;i<n;i++)
        {
            if((a[i]%10)!=0)
            {
                cout<<(s-a[i])<<"\n";
                return 0;
            }
        }
        cout<<"0\n";
    }
    else
    {
        cout<<s<<"\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>

using namespace std;

#define int long long
#define endl "\n"
#define all(v)  v.begin(),v.end()
#define fir first
#define sec second
#define m_p make_pair
#define m_t make_tuple
#define rep(i,n)  for(int i=0; i<(int) (n); i++)


const double pai = 3.1415926535897;
const int mod = 1000000007;
const int INF = 1000000021;
const int MAX = 510000;
const int MOD = 1000000007;
long long fac[MAX], finv[MAX], inv[MAX];


int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
//x未満の要素数を返す二分探索関数
int b_s(vector<int>& vec, int xx) {
	return lower_bound(all(vec), xx) - vec.begin();
}
template<typename T>
void vecout(vector<T>& vec) { for (T t : vec) cout << t << " "; cout << endl; }
template<typename TT>
void vecin(vector<TT>& vec) {
	for (int i = 0; i < vec.size(); i++) {
		cin >> vec[i];
	}
}


// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}
//n個を1個以上のx組のグループに分ける重複組み合わせはcom(n-1,x-1)
//グループが0個でもいいときはnにxを足す
// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
long long modinv(long long a, long long m) {
	long long b = m, u = 1, v = 0;
	while (b) {
		long long t = a / b;
		a -= t * b; swap(a, b);
		u -= t * v; swap(u, v);
	}
	u %= m;
	if (u < 0) u += m;
	return u;
}
int modpow(int a, int n) {
	int res = 1;
	while (n > 0) {
		if (n & 1) res = res * a % mod;
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

int gcd(int xx, int yy) {
	int p = xx;
	int q = yy;
	if (q > p)swap(p, q);
	while (p % q != 0) {
		p %= q;
		swap(p, q);
	}
	return q;
}
int lcm(int xx, int yy) {
	return xx * yy / gcd(xx, yy);
}
bool prime(int xx) {
	if (xx <= 1) {
		return 0;
	}
	for (int i = 2; i * i <= xx; i++) {
		if (xx % i == 0) {
			return 0;
		}
	}
	return 1;
}



signed main() {
	int n;
	cin >> n;
	vector<int>vec(n,INF),vec2(n);
	vecin(vec2);
	vec[0] = 0;
	vec[1] = abs(vec2[1] - vec2[0]);
	for (int i = 2; i < n; i++) {
		vec[i] = min(vec[i - 1] + abs(vec2[i] - vec2[i - 1]), vec[i - 2] + abs(vec2[i] - vec2[i - 2]));
	}
	cout << vec.back() << endl;
}


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

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

	for (int i = a; i >= 1; i--) {
		if (a%i == 0 && b % i == 0) {
			k--;
		}
		if (k == 0) {
			cout << i << endl;
			return 0;
		}
	}

	return 0;
}

Measured memory_bytes: 256
N, K, Q = map(int,input().split())
A = []
for i in range(Q):
    A.append(int(input())-1)
count = [0 for i in range(N)]
for i in A:
    count[i] += 1
for i in range(N):
    if count[i] >= Q - K + 1:
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 8624
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
//#include <math.h>
#include <string>
#include <numeric>
#include <queue>
#include <cstdio>
#include <cstring>
#include <cmath>
#define ll long long
#define rep(i,n) for(ll i=0;i<n;++i)
#define rep1(i,n) for(ll i=1;i<n;++i)
#define mrep(i,n) for(ll i=n;i>=0;--i)
#define all(a) (a).begin(),(a).end()
#define vl vector<ll>
#define vvl vector<vector<ll> >
#define vb vector<bool>
#define vvb vector<vector<bool> >
#define pl pair<ll,ll>
#define inf 1001001001001001000
//#define mod 1000000007
#define mod 998244353
#define pi 3.1415926535
using namespace std;
struct __INIT{
    __INIT(){
        cin.tie(0);
        ios::sync_with_stdio(false);
        cout<<fixed<<setprecision(15);
    }
}__init;



int main(void){
    string s;
    cin>>s;
    ll n = s.size()-1;
    if(s[n] == '2' || s[n] == '4' || s[n] == '7' || s[n] == '9' || s[n] == '5'){
        cout<<"hon"<<endl;
    }
    else if(s[n] == '0' || s[n] == '1' || s[n] == '6' || s[n] == '8'){
        cout<<"pon"<<endl;
    }
    else{
        cout<<"bon"<<endl;
    }
}

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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)
#define REPS(i, n) for(i64 i = 1; i <= n; ++i)
#define RREP(i, n) for(i64 i = n - 1; i >= 0 ; --i)
#define RREPS(i, n) for(i64 i = n; i >= 1; --i)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

#define pb push_back
#define mp make_pair
#define F first
#define S second

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

template<typename C>
i64 SIZE(const C& c) { return static_cast<i64>(c.size()); }

template<typename T, size_t N>
i64 SIZE(const T (&)[N]) { return static_cast<i64>(N); }


struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define MAX_N 3000
#define MAX_T 3000
#define MAX_A 3000

using P = pair<i64, i64>;
i64 dp[MAX_N + 5][MAX_T + 5];

int main() {
    i64 N, T; cin >> N >> T;
    vector<P> AB(N);
    REP(i, N) cin >> AB[i].first >> AB[i].second;
    sort(AB.begin(), AB.end(), [&](const P &p1, const P &p2) { return p1.first < p2.first; });

    REP(i, N) {
        REP(t, T) {
            chmax(dp[i + 1][t], dp[i][t]);
            chmax(dp[i + 1][min(T, t + AB[i].first)], dp[i][t] + AB[i].second);
        }
        chmax(dp[i + 1][T], dp[i][T]);
    }

    i64 maxv = 0;
    REP(t, T + 1) chmax(maxv, dp[N][t]);
    cout << maxv << endl;

    return 0;
}

Measured memory_bytes: 70784
#include <iostream>
#include <queue>
#include <utility>

using namespace std;

int main(){
	int n,q;
	cin >> n >> q;
	queue < pair<string,int> > t;
	int ntime=0;

	for (int i=0;i<n;i++){
		string temps;
		int tempi;
		cin >> temps;
		cin >> tempi;
		pair<string,int> tempp(temps,tempi);
		t.push(tempp);
	}

	while(!t.empty()){
		pair<string,int> tempp(t.front());
		t.pop();
		if(tempp.second > q){
			tempp.second-=q;
			ntime+=q;
			t.push(tempp);
		}else{
			ntime+=tempp.second;
			cout << tempp.first << " " << ntime <<endl;
		}
	}
}


Measured memory_bytes: 4404
#include <bits/stdc++.h>
using namespace std; 
int n,m;
int a[200010];
int main() {
    //freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	sort(a,a+n);
	long long ans=0;
	for(int i=0;i<n-m;i++){
		ans+=a[i];
	}
	cout<<ans<<endl;
    return 0; 
}/*
*/

Measured memory_bytes: 1152
#include <iostream>
#include <string>

using namespace std;


int main(){
        int A,B,C;
        cin >> A >> B >> C;
        //全部食べれる
        if(B+1 >= C)cout << B+C;
        //Bだけでは足りないのでAも食べる
        //Aも使えば足りつる？
        else if(A+B+1 >= C )cout << B + C;
        //Aを使っても足りない
        else cout << (A+B)+1+B;    
}


Measured memory_bytes: 256
//2706 石井夏鈴 問5
import java.util.Scanner;
public class Main{
	int n,t;
	int a=0;
	int ti[]={0,6000,4000,3000,2000};
	
    public void solve(){
		Scanner sc = new Scanner(System.in);
		for(int i=1;i<=4;i++){
			t=sc.nextInt();
			n=sc.nextInt();
			a=ti[t]*n;
    System.out.println(a);
		}
	}
   public static void main(String[] args){
   	Main obj=new Main();
	obj.solve();
   }
}

Measured memory_bytes: 17312
s = input()
if s == 'SUN':
    print(7)
elif s == 'MON':
    print(6)
elif s == 'TUE':
    print(5)
elif s == 'WED':
    print(4)
elif s =='THU':
    print(3)
elif s == 'FRI':
    print(2)
else:
    print(1)


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

int main() {
    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    int h = h2-h1;
    h *= 60;
    int m;
    int a1 = h1*60+m1;
    int a2 = h2*60+m2;
    int diff = a2-a1;
    if(diff-k > 0) {
        cout << diff-k << endl;
    }
    else {
        cout << 0 << endl;
    }
    return 0;
}

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

#define REP(i,num) for(int i=0;i<(num);++i)
#define LOOP(i) while(i--)
#define ALL(c) c.begin(),c.end()
#define PRINTALL(c) for(auto pitr=c.begin();pitr!=c.end();++pitr){cout<<*pitr;if(next(pitr,1)!=c.end())cout<<' ';}cout<<endl;
#define PAIRCOMP(c,comp) [](const pair<ll,ll>& lhs,const pair<ll,ll>& rhs){return lhs.c comp rhs.c;}

using namespace std;
using ll = long long;

constexpr ll atcoder_mod = 1e9+7;

template<typename T=int>
T in(){T x; cin >> x; return (x);}
template<typename T=int,typename C=vector<T>>
C vecin(int N){C x(N);REP(i,N){x[i]=in<T>();}return move(x);}

void vout(){cout << endl;}
template<typename Head,typename... Tail>
void vout(Head&& h,Tail&&... t){cout << ' ' << h;vout(forward<Tail>(t)...);}
void out(){cout << endl;}
template<typename Head,typename... Tail>
void out(Head&& h,Tail&&... t){cout << h;vout(forward<Tail>(t)...);}

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);

	string S;
	multimap<string,set<int>> M;
	while(cin>>S){
		int V=in();
		auto itr=M.find(S);
		if(itr!=M.end()){
			itr->second.emplace(V);
		}
		else{
			M.emplace(S,set<int>{V});
		}
	}
	
	for(auto& x:M){
		out(x.first);
		PRINTALL(x.second);
	}
	return 0;
}



Measured memory_bytes: 3192
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int r;
	cin >> r;
	int ans = 3*r*r;
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256