akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <stack>
#include <deque>
#include <cmath>
#include <map>
using ll = long long;
using namespace std;

int main() {
    int N, D, X;
    int A[110];
    cin >> N >> D >> X;
    for (int i=0; i<N; i++) cin >> A[i];

    ll res=X;
    for (int i=0; i<N; i++){
        res += (D - 1) / A[i] + 1;
    }
    cout << res << endl;
}


Measured memory_bytes: 256
fun main(args: Array<String>) {
    abc142b()
}

fun abc142b() {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }
    val hList = readLine()!!.split(" ").map { it.toInt() }

    val answer = hList.filter { it >= k }

    println(answer.size)
}


Measured memory_bytes: 48128
row = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
K = int(input())
print(row[K-1])

Measured memory_bytes: 2940
#include<cstdio>
#include<cstring>
#include<algorithm>
#define ll long long
using namespace std;
const int N=1000100;
inline int read(){
	int x=0,f=0,c=getchar();
	for(;c>'9'||c<'0';f=c=='-',c=getchar());
	for(;c>='0'&&c<='9';c=getchar())
	x=(x<<1)+(x<<3)+c-'0';return f?-x:x;
}
inline void write(ll x){
	if(x<0)putchar('-'),x=-x;
	if(x>9)write(x/10);putchar(x%10+'0');
}
int n,x,a[N],v[N],i,m;
int main(){
	//freopen("1.out","w",stdout);
	n=read();x=read();
	m=n+n-1;
	if(m==3){
		if(x!=2)puts("No");
		else puts("Yes\n1\n2\n3\n");
		return 0;
	}
	if(x<2||x>m-1)puts("No");
	else{
		a[n]=x;v[x]=1;
		a[n-1]=x-1,v[x-1]=1;
		a[n+1]=x+1,v[x+1]=1;
		if(x+2<=m)a[n-2]=x+2,v[x+2]=1;
		if(x-2>=1)a[n+2]=x-2,v[x-2]=1;
		for(i=x=1;i<=m;i++)
		if(!a[i]){
			while(v[x])x++;
			v[x]=1;a[i]=x;
		}
		puts("Yes");
		for(i=1;i<=m;i++)printf("%d\n",a[i]);
	}
	return 0;
}

Measured memory_bytes: 6272
//****** @mdazmat9 **********
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define UB upper_bound
#define LB lower_bound
#define BS binary_search
#define EB emplace_back
#define PB push_back
#define endl "\n"
#define MOD 1000000007
#define MOD2 998244353
#define F first
#define S second
#define ALL(a) (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
int fast_pow(int x, int y, int p);

void solve() {
    int n;cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        for(int j=1;j<=n;j++){
            for(int k=1;k<=n;k++){
                int gc=__gcd(i,j);
                gc=__gcd(gc,k);
                ans+=gc;
            }
        }
    }
    cout<<ans<<endl;
}
int32_t main() {
    IOS;
    int test = 1;
//    cin >> test;
    for (int i = 1; i <= test; i++) {
        solve();
    }
    return 0;
}
int fast_pow(int x, int y, int p) {
    int res = 1;
    x = x % p;
    while (y > 0) {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}

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

using namespace std;

int main(){
    int n,m;
    while(cin>>n>>m,n){
        vector<int>v(11,0);
        for(int i=0;i<n;++i){
            int d,p;
            cin>>d>>p;
            v[p]+=d;
        }
        int ans=0;
        for(int i=10;i>0;--i){
            if(m>v[i]){
                m-=v[i];
                v[i]=0;
            }else{
                v[i]-=m;
                m=0;
            }
            ans+=v[i]*i;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 2964
#include <bits/stdc++.h>
using namespace std;
using T = tuple<int, int, int>;

struct SegTree {
  int N;
  vector<int> dat;
  SegTree(int k) {
    N = 1;
    while (N < k) N *= 2;
    dat.assign(2 * N - 1, INT_MAX);
  }
  void update(int k, int a) {
    k += N - 1;
    dat[k] = a;
    while (k > 0) {
      k = (k - 1) / 2;
      dat[k] = min(dat[k * 2 + 1], dat[k * 2 + 2]);
    }
  }
  int query(int a, int b) { return query(a, b, 0, 0, N); }
  int query(int a, int b, int k, int l, int r) {
    if (r <= a || b <= l) return INT_MAX;
    if (a <= l && r <= b) return dat[k];
    int m = (l + r) / 2;
    int vl = query(a, b, k * 2 + 1, l, m);
    int vr = query(a, b, k * 2 + 2, m, r);
    return min(vl, vr);
  }
};

main() {
  int N; cin >> N;
  vector<int> p(N), pos(N + 1, N);
  SegTree even(N), odd(N);
  for (int i = 0; i < N; i++) {
    cin >> p[i];
    ( (i % 2 == 0) ? even : odd ).update(i, p[i]);
    pos[p[i]] = i;
  }
  vector<int> ans;
  priority_queue<T, vector<T>, greater<T> > que;
  que.push(make_tuple(even.query(0, N), 0, N));
  while (!que.empty()) {
    T min_interval = que.top(); que.pop();
    int& eval = get<0>(min_interval);
    int& l = get<1>(min_interval);
    int& r = get<2>(min_interval);
    if (l % 2 == 0) {
      int oval = odd.query(pos[eval], r);
      if (l < pos[eval] - 1) que.push(make_tuple(even.query(l, pos[eval]), l, pos[eval]));
      if (pos[eval] < pos[oval] - 1) que.push(make_tuple(odd.query(pos[eval] + 1, pos[oval]), pos[eval] + 1, pos[oval]));
      if (pos[oval] < r - 1) que.push(make_tuple(even.query(pos[oval] + 1, r), pos[oval] + 1, r));
      ans.push_back(eval); ans.push_back(oval);
    } else {
      int oval = even.query(pos[eval], r);
      if (l < pos[eval] - 1) que.push(make_tuple(odd.query(l, pos[eval]), l, pos[eval]));
      if (pos[eval] < pos[oval] - 1) que.push(make_tuple(even.query(pos[eval] + 1, pos[oval]), pos[eval] + 1, pos[oval]));
      if (pos[oval] < r - 1) que.push(make_tuple(odd.query(pos[oval] + 1, r), pos[oval] + 1, r));
      ans.push_back(eval); ans.push_back(oval);
    }
  }
  for (int i = 0; i < N; i++) cout << ans[i] << ( (i == N - 1) ? '\n' : ' ' );
}

Measured memory_bytes: 8616
#include<iostream>
#include<string>
#include<queue>

using namespace std;
 
#define NMAX 50

struct St{
	double P;
	string L;
};

bool operator<(St a,St b){
	return (a.P<b.P||(a.P==b.P&&a.L>b.L));
}

int main(void){
	
	int N;
	string L;
	int P,A,B,C,D,E,F,S,M;
	priority_queue<St> q;
	St tm;

	while(1){

		cin>>N;
		if(N==0) break;

		for(int i=0;i<N;i++){
			cin>>L>>P>>A>>B>>C>>D>>E>>F>>S>>M;
			tm.P=(double)((M*S*F)-P)/((A+B+C+D+E)*1+(D+E)*(M-1));
			tm.L=L;
			q.push(tm);
		}
		while(!q.empty()){
			cout<<q.top().L<<endl;
			q.pop();
		}
		cout<<"#"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1220
// C - 4-adjacent
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define rep(i, m, n) for (lli i = m; i < (n); i++)
#define repe(i, m, n) for (lli i = m; i <= (n); i++)
#define ALL(x) (x).begin(), (x).end()
#define SIZE(x) ((lli)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define _GLIBCXX_DEBUG
const lli INF = 2147483647;
const lli MINF = -2147483648;
const lli LINF = 9223372036854775807;
const lli MOD = 1000000007; //10^9+7
const double PI = acos(-1);
#define SORT(n) sort(n.begin(), n.end())
#define SORTR(n) sort(n.begin(), n.end(), greater<int>())
#define REV(n) reverse(n.begin(), n.end())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#pragma GCC optimize("Ofast")
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vlli = vector<lli>;
using vvli = vector<vlli>;
using vs = vector<string>;
using vvs = vector<vs>;
using vb = vector<bool>;
using vvb = vector<vb>;
using ll = long long;
// vector入力
template <typename T>
istream &operator>>(istream &is, vector<T> &vec)
{
  for (T &x : vec)
    is >> x;
  return is;
}
// vector出力
template <typename T>
ostream &operator<<(ostream &os, vector<T> &vec)
{
  // os << '{';
  for (int i = 0; i < vec.size(); i++)
  {
    os << vec[i] << (i + 1 == vec.size() ? "" : "");
  }
  // os << '}';
  return os;
}
// aよりもbが大きいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmax(T &a, const T &b)
{
  if (a < b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}
// aよりもbが小さいならばaをbで更新する(更新されたならばtrueを返す)
template <typename T>
bool chmin(T &a, const T &b)
{
  if (a > b)
  {
    a = b; // aをbで更新
    return true;
  }
  return false;
}

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  lli a, b, c, h, n, w, ans = 0, count = 0;
  string s, t;
  vector<pair<string, pair<lli, lli>>> pr;
  cin >> n;
  vlli d(n), e(n, 0), f(n, 0);
  rep(i, 0, n)
  {
    cin >> d[i];
    if (d[i] % 4 == 0)
    {
      e[i] = 4;
      count++;
    }
    else if (d[i] % 2 == 0)
    {
      e[i] = 2;
      ans++;
    }
    else
    {
      e[i] = 1;
    }
  }
  // cout << e << endl;
  // cout << "count: " << count << endl;
  // cout << "ans: " << ans << endl;
  if (count >= n / 2)
  {
    cout << "Yes" << endl;
    return 0;
  }
  if (ans >= 2)
  {
    count += (ans / 2);
    // cout << "count: " << count << endl;
  }
  if (count >= n / 2)
  {
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 5500
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO Auto-generated method stub
		Scanner sc = new Scanner(System.in);

		String input = sc.next();
		input = input.replaceAll("BC", "D");
//		System.out.println(input);

		String array[] = input.split("[BC]");
		long result = 0;
		for(int i = 0; i < array.length; i++){
//			System.out.println(array[i]);

			int countA = 0;
//			int trans = 0;
			for(int j = 0; j < array[i].length(); j++){
				int c = array[i].charAt(j);

				if(c == 'A'){
					countA++;
				}
				else {
					result += countA;
				}
			}
		}
		System.out.println(result);
	}
}

Measured memory_bytes: 40176
#include <algorithm>
#include <array>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <stack>
#include <vector>

using namespace std;
using ll = long long;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

#define MOD ((ll)1000000007)


int main(int argc, char const *argv[])
{
	cin.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);

	string S;
	cin >> S;
	string s[4] = {"dream", "dreamer", "erase", "eraser"};

	string sub1, sub2, sub3;
	int i = S.size() - 1;
	while (i > 3)
	{
		if (i - 4 >= 0)
		{
			sub1 = S.substr(i - 4, 5);
			if (sub1 == s[0] || sub1 == s[2]) {
				i -= 5;
				continue;
			}
		}

		if (i - 6 >= 0)
		{
			sub2 = S.substr(i - 6, 7);
			if (sub2 == s[1]) {
				i -= 7;
				continue;
			}
		}

		if (i - 5 >= 0)
		{
			sub3 = S.substr(i - 5, 6);
			if (sub3 == s[3]) {
				i -= 6;
				continue;
			}
		}

		break;
	}

	if (i == -1)
	{
		cout << "YES" << endl;
	} else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define se second
#define fi first
#define pb push_back
const int N=1e5 + 5;
int v[N];
int n;

ll check(ll am){

	for(int i=0;i < n;i++){
		am-=am % v[i];
	}
	return am;
}

int main(){

//	freopen("in.txt","r",stdin);

	scanf("%d",&n);
	for(int i=0;i < n;i++){
		scanf("%d",v + i);
	}
	if(v[n - 1] != 2) return puts("-1"), 0;
	ll l=1,r=2e18 + 5,mn=2e18 + 10,mx=0;
	bool f=0;
	while(l <= r){
		ll mid=(l + r) / 2;
		ll temp=check(mid);
		if(temp >= 2){
			if(temp == 2) mn=min(mn,mid), f=1;
			r=mid - 1;
		}
		else l=mid + 1;
	}
	if(!f) return puts("-1"), 0;
	mx=mn;
	l=1, r=2e18 + 5;
	while(l <= r){
		ll mid=(l + r) / 2;
		ll temp=check(mid);
		if(temp <= 2){
			if(temp == 2) mx=max(mx,mid);
			l=mid + 1;
		}
		else r=mid - 1;
	}
	cout << mn << " " << mx << endl;

}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define dum(x) cout<<#x<<'='<<x<<endl
#define ll long long
using namespace std;
 
int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a.at(i);
  }
  sort(a.begin(), a.end());
  bool flag = true;
  if (n % 2 == 0) {
    for (int i = 0; i < n; i += 2) {
      if (a.at(i) == a.at(i + 1) && a.at(i) == i + 1) continue;
      else flag = false;
    }
  } else {
    if (a.at(0) != 0) flag = false;
    for (int i = 1; i < n; i += 2) {
      if (a.at(i) == a.at(i + 1) && a.at(i) == i + 1) continue;
      else flag = false;
    }
  }
  ll ans = 1;
  if (flag) {
    for (int i = 0; i < n / 2; i++) {
      ans = ans * 2 % 1000000007;
    }
  } else {
    ans = 0;
  }
  cout << ans << endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;
 
#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)
 
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; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }
typedef long long ll; 
ll func(ll num){
    while(num>=10){
    num/=10;
    }
    return num; 
}
ll func2(ll num){
    int cnt=0;
    while(num>0){
        cnt++;
        num/=10;
    }
    return cnt;
}
int main(){
    ll n;
    cin>>n;
    int num=func(n+1);
    int cnt=func2(n+1);
    cout<<9*(cnt-1)+num-1<<endl;

    return 0;
}


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


int main(){
    ll n;
    cin >> n;
    ll sqrtn = sqrt(n);
    cout << sqrtn * sqrtn << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
long long int dp[1001][1001];
int main(void)
{
	int i,j,n,m,d[1000],c[1000],dc;
	long long int min;
	min=9223372036854775807;
	scanf("%d %d",&n,&m);
	for(i=0;i<=m;i++){
		for(j=0;j<=n;j++) dp[i][j]=min;
	}
	for(i=0;i<n;i++) scanf("%d",&d[i]);
	for(i=0;i<m;i++) scanf("%d",&c[i]);
	dp[0][0]=0;
	for(i=0;i<m;i++){
		for(j=0;j<=n;j++){
			if(dp[i][j]!=min){
				if(dp[i][j]<dp[i+1][j]) dp[i+1][j]=dp[i][j];
				dc=d[j]*c[i];
				if(dp[i][j]+dc<dp[i+1][j+1]) dp[i+1][j+1]=dp[i][j]+dc;
			}
		}
	}
	for(i=1;i<=m;i++){
		if(min>dp[i][n]) min=dp[i][n];
	}
	printf("%d\n",min);
	return 0;
}

Measured memory_bytes: 8428
N=int(input())
xyh=[list(map(int,input().split())) for _ in range(N)]
xyh.sort(key=lambda x: x[2],reverse=True)

for x in range(101):
    for y in range(101):
        ans=True
        H=xyh[0][2]+abs(x-xyh[0][0])+abs(y-xyh[0][1])
        for n in range(1,N):
            if H!=xyh[n][2]+abs(x-xyh[n][0])+abs(y-xyh[n][1]) and xyh[n][2]!=0:
                ans=False
                break
        if ans:
            for n in range(1,N):
                if max(H-abs(x-xyh[n][0])-abs(y-xyh[n][1]),0)!=xyh[n][2]:
                    ans=False
                    break
            if ans:
                print(x,y,H)
                exit()

Measured memory_bytes: 3192
#include<iostream>
#include<sstream>
#include<fstream>
#include<algorithm>
#include<utility>
#include<set>
#include<vector>
#include<map>
#include<queue>
#include<deque>
#include<stack>
#include<list>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<functional>
using namespace std; 
bool f1[200005],f2[200005];
int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=0;i<m;i++)
	{
		int x,y;
		scanf("%d %d",&x,&y);
		if(x==1) f1[y]=1;
		if(y==n) f2[x]=1;
//		cout<<x<<" "<<y<<" "<<f1[y]<<" "<<f2[x];
		if((x==1&&f2[y]==1)||(y==n&&f1[x]==1))
		{
			cout<<"POSSIBLE";
			return 0;
		}
	}
	cout<<"IMPOSSIBLE";
	return 0;
}

Measured memory_bytes: 640
def z_algorithm(s)
    c = 0
    ret = Array.new(N, 0)
    (1...N).each do |i|
        if i + ret[i-c] < c + ret[c]
            ret[i] = ret[i-c]
        else
            j = c + ret[c] - i
            j = 0 if j < 0
            j += 1 while i+j < N && s[j] == s[i+j]
            ret[i] = j
            c = i
        end
    end
    ret[0] = N
    ret
end

S = gets.chomp
N = S.length
len = [z_algorithm(S)]
S.reverse!
len[1] = z_algorithm(S)
bad = Array.new(2){Array.new(N+1)}

min_period = N
2.times do |k|
    (1...N).each do |period|
        next if bad[k][period]
        0.step(N-1, period) do |s|
            if len[k][s] >= period
                bad[k][s+period] = true if s > 0
            else
                break
            end
        end
        min_period = period if min_period == N && bad[k][N]
    end
end

if min_period == N
    opt = 1
    num = 1
elsif min_period == 1
    opt = N
    num = 1
else
    opt = 2
    num = (1...N).count{|i| !bad[0][i] && !bad[1][N-i]}
end
puts opt, num

Measured memory_bytes: 20620
SP = input()
T = input()
S = ""

for i in range(len(SP)-len(T),-1,-1):
  cnt = 0
  for j in range(len(T)):
    if SP[i+j] == T[j] or SP[i+j] == "?":
      cnt = cnt +1
  if cnt == len(T):
    S = (SP[:i] + T + SP[i+len(T):]).replace("?","a")
    break
###    
if S == "":
  print("UNRESTORABLE")
else:
  print(S)

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

#define fi first
#define se second
#define ll long long
#define pb push_back
#define mp make_pair
#define mt make_tuple

using namespace std;

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

    ll a, b;
    cin >> a >> b;
    double res = a/0.08;
    ll r = (ll)res;
    if(abs(res - r) > 0.0001) r++;
    res = b/0.1;
    ll r2 = (ll)res;
    if(abs(res - r2) > 0.0001) r2++;
    ll k = max(r, r2);
    if((ll)(k*0.08) != a || (ll)(k*0.1) != b) cout << -1;
    else cout << k;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
int a,b,c;
  cin>>a>>b>>c;
 int m = max(a,max(b,c));
int g = 1;
  if(a!=m)
    g*=a;
  if(b!=m)
    g*=b;
  if(c!=m)
    g*=c;
  cout<<g/2;
  
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define pi pair<int ,int >
#define pl pair<ll ,ll >
#define pb push_back
#define vl vector <long long int >
#define vi vector <int >
#define vp vector <pi>
#define mod 1000000007
#define eps 1e-9
#define fi first
#define se second
#define _ <<" "<<
#define forn(x,	n) for(int x = 0; x < n ;++ x) 
#define forn1(x,n) for(int x = 1; x <= n ;++ x)
#define IOS ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#pragma GCC optimize ("Ofast")
void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F &f, R&... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

template<class A, class B> ostream& operator<<(ostream& out, const pair<A, B> &a){
    return out<<"("<<a.first<<","<<a.second<<")";}
template<class A> ostream& operator<<(ostream& out, const vector<A> &a){
	out<<"";for(auto it=a.begin();it!=a.end();it++){if(it!=a.begin())out<<" ";out<<*it;}out<<"";
	return out;}
template<class A, class B> istream& operator>>(istream& in, pair<A,B> &a){in>>a.first>>a.second;return in;}
template<class A> istream& operator>>(istream& in, vector<A> &a){for(A &i:a)in>>i;return in;}

pi getInvCount(vi arr,int n) 
{ 
    // Create an empty set and insert first element in it 
    multiset<int> set1; 
    set1.insert(arr[0]); 
  
    int invcount = 0;
    int noninv=0; // Initialize result 
  
    //multiset<int>::iterator itset1; // Iterator for the set 
  
    // Traverse all elements starting from second 
    for (int i=1; i<n; i++) 
    { 
        // Insert arr[i] in set (Note that set maintains 
        // sorted order) 
        set1.insert(arr[i]); 
  
        // Set the iterator to first greater element than arr[i] 
        // in set (Note that set stores arr[0],.., arr[i-1] 
        auto itset1 = set1.upper_bound(arr[i]);
        auto it2 = set1.lower_bound(arr[i]);

        //debug(i,*it2, *itset1,invcount);
  
        // Get distance of first greater element from end 
        // and this distance is count of greater elements 
        // on left side of arr[i] 
        invcount += distance(itset1,set1.end());
        noninv += distance(set1.begin(),it2);
    }
    return {invcount,noninv}; 
} 

int main(){
	IOS

	ll n,k;
	cin>>n>>k;
	vi v(n);
	cin>>v;
	pi p=getInvCount(v,v.size());

	ll inv = (((((k*(k+1))/2)%mod)*(p.fi%mod))%mod + (((k*(k-1)/2))%mod*(p.se%mod))%mod)%mod;
	assert(inv<mod);
	cout<<inv; 

	
 
	return 0;	
}

Measured memory_bytes: 384
p = [True] * (105000)
p[0] = p[1] = False
for i in range(2, len(p)):
    if p[i]:
        for j in range(i * 2, len(p), i):
            p[j] = False
p = [i for i in range(len(p)) if p[i]]

while True:
    n = int(raw_input())
    if n == 0:
        break
    print sum(p[:n])

Measured memory_bytes: 10016
#include <iostream>
#include <algorithm>
using namespace std;
typedef unsigned long long ull;
ull m;
ull gcd(ull a,ull b)
{
    while(b^=a^=b^=a%=b);
    return a;
}
ull lcm(ull a,ull b)
{
    return a/gcd(a,b)*b;
}
int main()
{
    int n;
    ull k;
    cin >> n;
    for (int i = 0; i < n; i++) {
        if (i == 0) {
            cin >> m;
            k = m;
        }
        else {
            cin >> m;
            k = lcm(k, m);
        }
    }
    cout << k << endl;
    return 0;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
def main():
    N = int(input())
    L = list(map(int, input().split()))
    CNT = 0
    for i in range(N):
        for j in range(i+1,N):
            if L[i] != L[j]:
                for k in range(j+1,N):
                    if L[i] != L[k] and L[j] != L[k]:
                        S = L[i] + L[j] + L[k]
                        M = max(max(L[i], L[j]), L[k])
                        if S - M > M:
                            CNT += 1
    print(CNT)

if __name__ == '__main__':
    main()

Measured memory_bytes: 9212
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline bool Get(){
	static char c; c = getchar();
	while ((c!='#')&&(c!='.')) c=getchar();
	return c=='#';
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }
const int N = 105,M = 105,V = N*M*100;
int n,m,d[N][M]; bool mp[N][M];
int Qx[V*4],Qy[V*4],ql,qr;
int t[] = {0,1,0};
int main(){
	int i,j,x,y,nx,ny,nv;
	read(n),read(m);
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) d[i][j] = 1000000,mp[i][j] = Get();
	ql = V + 1,qr = V;
	++qr,Qx[qr] = 1,Qy[qr] = 1,d[1][1] = (mp[1][1])?(1):(0);
	while (ql <= qr){
		x = Qx[ql],y = Qy[ql],++ql;
		for (int k = 0; k < 2; ++k){
			nx = x + t[k],ny = y + t[k+1];
			if (nx>n||ny>m||nx<1||ny<1) continue;
			nv = d[x][y] + (((mp[x][y]^mp[nx][ny]) && mp[nx][ny])?(1):(0));
			if (d[nx][ny] > nv) d[nx][ny] = nv,++qr,Qx[qr] = nx,Qy[qr] = ny;
		}
	}
	int ans1 = d[n][m];
	
	ql = V + 1,qr = V;
	for (i = 1; i <= n; ++i) for (j = 1; j <= m; ++j) d[i][j] = 1000000;
	++qr,Qx[qr] = 1,Qy[qr] = 1,d[1][1] = (mp[1][1])?(1):(0);
	while (ql <= qr){
		x = Qx[ql],y = Qy[ql],++ql;
		for (int k = 0; k < 2; ++k){
			nx = x + t[k],ny = y + t[k+1];
			if (nx>n||ny>m||nx<1||ny<1) continue;
			nv = d[x][y] + ((mp[nx][ny])?(1):(0));
			if (d[nx][ny] > nv) d[nx][ny] = nv,++qr,Qx[qr] = nx,Qy[qr] = ny;
		}
	}
	int ans2 = d[n][m];
	int ans = min(ans1,ans2);
	cout << ans << endl; 
	return 0;
}

Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<cmath>
#include<deque>
#include<map>

using namespace std;
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000
const int MOD = 1000000007;
int main(void) {
	int N, M, p, y, c;
	map<pair<int, int>, ll> num;
	vector<pair<int, int> > data, data2;
	scanf("%d%d", &N, &M);
	rep(i, 0, M) {
		scanf("%d%d", &p, &y);
		data.push_back(make_pair(p, y));
		data2.push_back(make_pair(p, y));
	}
	sort(all(data2));
	p = 0;
	for (auto v : data2) {
		if (v.first != p)c = 1;
		num[v] = c + v.first * 1000000LL;
		p = v.first;
        c++;
	}
	for (auto v : data) {
		printf("%012lld\n", num[v]);
	}
	return 0;
}


Measured memory_bytes: 9324
#include <iostream>
#include <chrono>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <set>

using namespace std;

int main() {
	int h, w;
	cin >> h >> w;
	vector<string> v(h);
	string str(w + 2, '#');
	for (int i = 0; i < h; i++)
		cin >> v[i];
	for (int i = 0; i < h + 2; i++) {
		if (i == 0 || i == h + 1) {
			cout << str << endl;
		}
		else {
			cout << '#' << v[i - 1] << '#' << endl;
		}
	}

}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
#define fore(i,a) for(auto &i:a)
#define all(x) (x).begin(),(x).end()
//#pragma GCC optimize ("-O3")
using namespace std; void _main(); int main() { cin.tie(0); ios::sync_with_stdio(false); _main(); }
typedef long long ll; const int inf = INT_MAX / 2; const ll infl = 1LL << 60;
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; }
//---------------------------------------------------------------------------------------------------
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/









int N, Q; string S;
char T[201010], D[201010];
//---------------------------------------------------------------------------------------------------
int check(int x) {
	rep(i, 0, Q) {
		if (T[i] == S[x]) {
			if (D[i] == 'L') x--;
			else x++;
		}

		if (x < 0 or N <= x) return 1;
	}
	return 0;
}
//---------------------------------------------------------------------------------------------------
void _main() {
	cin >> N >> Q >> S;
	rep(q, 0, Q) cin >> T[q] >> D[q];

	int ans = N;

	if (check(0)) {
		int ok = 0, ng = N;
		while (ok + 1 != ng) {
			int md = (ok + ng) / 2;
			if (check(md)) ok = md;
			else ng = md;
		}
		ans -= ok + 1;
	}

	if (check(N - 1)) {
		int ng = 0, ok = N - 1;
		while (ng + 1 != ok) {
			int md = (ok + ng) / 2;
			if (check(md)) ok = md;
			else ng = md;
		}
		ans -= N - ok;
	}

	chmax(ans, 0);
	cout << ans << endl;
}

Measured memory_bytes: 976
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v) sort(v.begin(), v.end(), greater<ll>())
#define prvsort(v) sort(v.begin(), v.end(), greater<pair<ll, ll>>())
#define ll long long
#define ld long double
#define fixset(val) fixed << setprecision(10) << val 
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define mod 1000000007
#define vfind(v, target) find(v.begin(), v.end(), target)
#define notFound(v, target) (vfind(v, target) == v.end())

using namespace std;

int main()
{
  string S; cin >> S;
  ll N = S.size(), a, b = 1, ans = 0;
  vector<ll> amari(N + 1), count(2020, 0);
  amari[N] = 0;
  count[0] = 1;
  for (ll i = N - 1; i >= 0; i--) {
  	a = S[i] - '0';
    amari[i] = (amari[i + 1] + (a * b) % 2019) % 2019;
    count[amari[i]]++;
    b = (b * 10) % 2019;
  }
  rep(i, 0, 2020) {
  	ans += count[i] * (count[i] - 1) / 2;
  }
  cout << ans << endl;
}

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

int main() {
    int N, P;
    cin >> N >> P;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }

    int cnt0 = 0;
    int cnt1 = 0;
    for (int i = 0; i < N; i++) {
        if (A[i] % 2 == 0) {
            cnt0++;
        }
        else {
            cnt1++;
        }
    }

    if (P == 1 && cnt1 == 0) {
        cout << 0 << endl;
    }
    else if (cnt0 == N && P == 0) {
        long long ans = pow(2, N);
        cout << ans << endl;
    }
    else {
        long long ans = pow(2, N - 1);
        cout << ans << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
  int n,m,i,sam=0,a[10000];
  scanf("%d%d",&n,&m);
  for(i=0;i<m;i++){
    scanf("%d",&a[i]);
    sam+=a[i];
  }
  if(n>=sam)
    printf("%d",n-sam);
  else
    printf("%d",-1);
  return 0;
}

Measured memory_bytes: 1772
#include<iostream>

using namespace std;

int main()
{
	int N;
    cin >> N;
    N = N%10;
    if(N==2 || N==4||N==5||N==7||N==9)
    	cout << "hon";
    else if(N==3)
    	cout << "bon";
    else
    	cout << "pon";
    return 0;

}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
#define rep(i,j,k) for(int i = (int)j;i <= (int)k;i ++)
#define debug(x) cerr<<#x<<":"<<x<<endl
const int maxn=(int)1e6+5;
const int inf=(long long)1e9+5;
int a[maxn],dp[maxn],tmp[maxn];
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
    int n;
    cin>>n;
    rep(i,1,n)cin>>a[i];
    fill(tmp,tmp+n+2,inf),tmp[0]=-1;
    int ans=0;
    rep(i,1,n){
        int p=lower_bound(tmp,tmp+ans+1,a[i])-tmp;
        ans=max(ans,p);
        tmp[p]=min(a[i],tmp[p]);
    }
    cout<<ans<<endl;
}
/* 
5
5
1
3
2
4

1 0
 */


Measured memory_bytes: 3960
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        int b = scan.nextInt();

        if (b % a == 0) {
            System.out.println(a + b);
        } else {
            System.out.println(b - a);
        }
    }
}

Measured memory_bytes: 23636
data = input().split()
W = int(data[0])
a = int(data[1])
b = int(data[2])

if(a < b):
	if(b <= a+W):
		print("0")
	else:
		print(b-(a+W))
else:
	if(a <= b+W):
		print("0")
	else:
		print(a-(b+W))



Measured memory_bytes: 3060
#include <stdio.h>

int main(){
    int W, H, x, y, r;
    scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);
    
    if(x-r<0||x+r>W||y-r<0||y+r>H){
        printf("No\n");
    }else{
        printf("Yes\n");
    }
    
    return 0;
}


Measured memory_bytes: 2100
#include <stdio.h>
int main(void){
    int i,j,a,z;
    char s[200000];
    scanf("%s",s);
    for(i=0;s[i]!='\0';i++){
        if(s[i]=='A') {a=i;break;}
    }
    for(j=i+1;s[j]!='\0';j++){
        if(s[j]=='Z') z=j;
    }
    printf("%d",z-a+1);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const ll INF = 1LL << 60; //MAX 9223372036854775807

//子から親を求める演算
auto calc_parent = [](ll x, ll y) { return x+y; };
//親遅延配列を子に伝播する演算
auto calc_lazychild = [](ll &x,ll y) { x=y/2; };
//遅延配列をノードに反映する演算
auto lazy_to_node = [](ll &x,ll y) { x=y; };
//遅延配列に値を入れる演算 y-値 l,r-区間index
auto intolazy = [](ll &x,ll y,ll r,ll l) { x=(r-l)*y; };
//単位元
const ll unit = 0;

struct LazySegTree
{
private:
  ll n;
  vector<ll> node,lazy;
  vector<bool> islazy;

public:
  LazySegTree(vector<ll> v)
  {
    node.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); 
    lazy.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, unit); 
    islazy.resize((1LL << 64 - __builtin_clzll(v.size())) * 2 - 1, 0); 

    n = 1LL << 64 - __builtin_clzll(v.size());
    for (ll i = 0; i < v.size(); i++)
      node[i + n - 1] = v[i]; //最下段から構築
    for (ll i = n - 2; i >= 0; i--)
      node[i] = calc_parent(node[2 * i + 1], node[2 * i + 2]);
  }
  
  // k 番目のノードについて遅延評価を行う
  void eval(int k, int l, int r){ 
    // 遅延配列が空でない場合、自ノード及び子ノードへの
    // 値の伝播が起こる
    if (islazy[k]){
      lazy_to_node(node[k],lazy[k]);
      // 最下段かどうかのチェック
      if (r - l > 1){
        calc_lazychild(lazy[2 * k + 1],lazy[k]);
        calc_lazychild(lazy[2 * k + 2],lazy[k]);
        islazy[2 * k + 1] = 1;
        islazy[2 * k + 2] = 1;
      }
      // 伝播が終わったので、自ノードの遅延配列を空にする
      islazy[k] = 0;
      lazy[k] = unit;
    }
  }

  void update(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
    if (r < 0)
      r = n;
    // k 番目のノードに対して遅延評価を行う
    eval(k, l, r);
    // 範囲外なら何もしない
    if (b <= l || r <= a)
      return;
    // 完全に被覆しているならば、遅延配列に値を入れた後に評価
    if (a <= l && r <= b){
      intolazy(lazy[k],x,r,l);
      islazy[k] = 1;
      eval(k, l, r);
    }
    // そうでないならば、子ノードの値を再帰的に計算して、
    // 計算済みの値をもらってくる
    else{
      update(a, b, x, 2 * k + 1, l, (l + r) / 2);
      update(a, b, x, 2 * k + 2, (l + r) / 2, r);
      node[k] = calc_parent(node[2 * k + 1] , node[2 * k + 2]);
    }
  }

  // 要求区間 [a, b) 中の要素の最小値を答える k := 自分がいるノードのインデックス 対象区間は [l, r) にあたる
  ll get(ll a, ll b, ll k = 0, ll l = 0, ll r = -1)
  {
    // 最初に呼び出されたときの対象区間は [0, n)
    if (r < 0)
      r = n;
    // 要求区間と対象区間が交わらない -> 適当に返す
    if (r <= a || b <= l)
      return unit;
    // 要求区間が対象区間を完全に被覆 -> 対象区間を答えの計算に使う
    // 関数が呼び出されたら評価！
    eval(k, l, r);
    if (a <= l && r <= b)
      return node[k];
    // 要求区間が対象区間の一部を被覆 -> 子について探索を行う
    // 左側の子を vl ・ 右側の子を vr としている
    // 新しい対象区間は、現在の対象区間を半分に割ったもの
    ll vl = get(a, b, 2 * k + 1, l, (l + r) / 2);
    ll vr = get(a, b, 2 * k + 2, (l + r) / 2, r);
    return calc_parent(vl, vr);
  }
};

int main()
{
ll n , q ;
cin >> n >> q ;

vector<ll> t(n,0);
LazySegTree s(t);
vector<ll> ans;
rep(i,q){
  ll a  ;
  cin >> a  ;
  if(!a){
    ll b , c , d ;
    cin >> b >> c >> d ;
    s.update(b, c+1, d);
  }
  else {
    ll b ,c;
    cin >> b >>c;
    ans.push_back(s.get(b, c+1));
  }
}

rep(i,ans.size())cout<<ans[i]<<"\n";

return 0;
}



Measured memory_bytes: 9512
import java.util.Arrays;
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String s=scan.nextLine();
		char[] y=s.toCharArray();
		Arrays.sort(y);
		if(y[0]=='a' && y[1]=='b' && y[2]=='c') System.out.println("Yes");
		else System.out.println("No");
	}

}


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

int main() {
 int a,b,c;
 cin >> a >> b >> c;
 if (a==b&&b==c&&c==a){
  cout << '1' << endl;
 }
 else if (a==b||b==c||c==a){
  cout << "2" << endl;
 }
 else
  cout << "3" << endl;
}


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

int main() {

  string S; cin >> S;
  if (S == "abc" || S == "acb" || S == "bac" || S == "bca" || S == "cab" || S == "cba") {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
    
}


Measured memory_bytes: 256
h,w,k=map(int,input().split())
c=[list(input())for i in range(h)]
d=0
for i in range(2**h):
    for j in range(2**w):
        x=bin(i)[2:]
        y=bin(j)[2:]
        x="0"*(h-len(x))+x
        y="0"*(w-len(y))+y
        p=0
        for s in range(h):
            for t in range(w):
                if x[s]==y[t]=="0" and c[s][t]=="#":
                    p+=1
        if p==k:
           d+=1
print(d)

Measured memory_bytes: 9064
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>
#define repl(i, l, r) for (ll i = l; i < r; i++)
#define rep(i, n) repl(i, 0, n)

using namespace std;
using ll = long long;

int main() {

    string S;
    ll K, N;

    cin >> S >> K;
    
    N = S.size();

    vector<ll> c;
    ll tmp = 1;

    repl(i, 1, N) {
        if (S[i - 1] == S[i]) {
            tmp++;
            if (i == N - 1) {
                c.push_back(tmp);
            }
        }
        else{
            c.push_back(tmp);
            tmp = 1;
        }
    }

    if (N == 1) {
        c.push_back(1);
    }

    ll ans = 0;
    ll n = c.size();
    
    rep(i, n) {
        ans += c[i] / 2;
    }

    ans = ans * K;

    if (S.front() == S.back()) {
        ans = ans - (c.front() / 2 + c.back() / 2 - (c.front() + c.back()) / 2) * (K - 1);
    }


    if (n == 1) {
        ans = c.front() * K / 2;
    }

    cout << ans;

    return 0;
}

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

using namespace std;

void change(string & s)
{
    char c = 'A';
    char e;
    for (auto& i: s)
    {
        if (i >= 'a')
        {    
            e = i;
            for (auto& j: s)
            {
                if (j == e) j = c;
            }
            c++;
            if (c > 'Z') break;
        }
    }
}

int main(void)
{
    string S, T;
    cin >> S >> T;
    change(S);
    change(T);
    cout << ( (S == T) ? "Yes" : "No") << endl;
    return 0;
}

Measured memory_bytes: 776
<?php
$N = intval(fgets(STDIN));
for($i = 0; $i < $N; $i++)$map[] = array_map("boolval", str_split(trim(fgets(STDIN))));

$max = -1;
for($i = 0; $i < $N; $i++){
    $distance = array_fill(0, $N, 300);
    $current = [$i];
    $d = 0;
    $distance[$i] = $d;
    while($current){
        $d++;
        $next = [];
        foreach($current as $c){
            for($j = 0; $j < $N; $j++){
                if($map[$c][$j]){
                    if($distance[$j]==300){
                        $distance[$j] = $d;
                        $next[] = $j;
                    }elseif($distance[$j] == $d-2 || $distance[$j] == $d){
                    }else{
                        continue 4;
                    }
                }
            }
        }
        $current = $next;
    }
    if($d > $max){
        $max = $d;
    }
}
echo $max,"\n";



Measured memory_bytes: 7544
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;
typedef string::const_iterator State;
#define Ma_PI 3.141592653589793
#define eps 1e-5
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL
#define MOD 998244353LL
#define seg_size 262144
#define REP(a,b) for(long long a = 0;a < b;++a)
int ans[400][400];
int main() {
	int h, w, k;
	cin >> h >> w >> k;
	vector<string> inputs;
	REP(i, h) {
		string s;
		cin >> s;
		inputs.push_back(s);
	}
	int itr = 0;
	int now_cnt = 1;
	for (int i = 0; i < h; ++i) {
		int starting = -1;
		for (int q = 0; q < w; ++q) {
			if (inputs[i][q] == '#') {
				for (int j = starting + 1; j <= q; ++j) {
					for (int t = itr; t <= i; ++t) {
						ans[t][j] = now_cnt;
					}
				}
				now_cnt++;
				starting = q;
			}
		}
		if (starting != -1) {
			for (int j = starting + 1; j < w; ++j) {
				for (int t = itr; t <= i; ++t) {
					ans[t][j] = now_cnt-1;
				}
			}
			itr = i + 1;
		}
	}
	for (int i = 1; i < h; ++i) {
		for (int q = 0; q < w; ++q) {
			if (ans[i][q] == 0) {
				ans[i][q] = ans[i - 1][q];
			}
		}
	}
	REP(i, h) {
		REP(q, w) {
			cout << ans[i][q] << " ";
		}
		cout << endl;
	}
}

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

int main()
{
    int i,j,k,l,m,n;
    scanf("%d",&n);
    vector<int>v(n,0);
    for(i=0;i<n-1;i++)
    {
        scanf("%d",&k);
        v[k-1]++;
    }
    for(i=0;i<v.size();i++)
    {
        printf("%d\n",v[i]);
    }
}


Measured memory_bytes: 4068
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
#include <chrono>
#include <random>

using namespace std;

#define int long long
#define ll long long
//#define double long double
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()

const int INF = 2e9;
const int MB = 32;
const int MOD = 998244353;

void solve() {
    int n, m;
    cin >> n >> m;
    vector<int> a(n);
    int sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }

    int x = (sum + 4 * m - 1) / (4 * m);
    sort(rall(a));
    for (int i = 0; i < m; i++) {
        if (a[i] < x) {
            cout << "No";
            return;
        }
    }
    cout << "Yes";
}

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
   // freopen("C:\\Users\\Иван\\Desktop\\output.txt", "w", stdout);
    //int t;
    // cin >> t;
    int t = 1;
    while (t--) solve();
}

Measured memory_bytes: 256
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)  
using namespace std;
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
int main() {
  int N, H;
  cin >> N >> H;
  priority_queue<pair<int,int>> q;
  for(int i = 0; i < N; i++) {
    int a, b;
    cin >> a >> b;
    q.push(mp(a, H));
    q.push(mp(b, 1));
  } 
  int ans = 0;
  while(H > 0) {
    pair<int,int> p = q.top(); q.pop();
    int c = min(p.second, (H - 1) / p.first + 1);
    H -= p.first * c;
    ans += c;
  } 
  cout << ans << endl;
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define pb(x) push_back(x)
#define SORT(ls) sort(ls.begin(), ls.end())
#define DESC(ls) sort(ls.rbegin(), ls.rend()) 
#define mp(x, y) make_pair(x, y)
#define INF 1000000000
#define MOD 1000000007
#define F(i, a, n) for(i=a;i<n;i++)


int main(void)
{
    int i, j, n, k;
    scanf("%d %d", &n, &k);
    int heights[n];
    F(i, 0, n)
        scanf("%d", heights + i);
    int dp[n];
    dp[0] = 0;
    F(i, 1, n)
        dp[i] = INF;
    F(i, 1, n)
        for(j = i - 1; j >= max(0, i - k); --j)
            dp[i] = min(dp[j] + abs(heights[j] - heights[i]), dp[i]);
    printf("%d\n", dp[n - 1]);
}

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

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



Measured memory_bytes: 2996
import java.util.Scanner;
import java.util.ArrayList;

class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		// 青いカードの文字列
		ArrayList<String> blue = new ArrayList<String>();
		int n = sc.nextInt();
		for (int i = 0; i < n; i++) {
			String tmp = sc.next();
			blue.add(tmp);
		}
		// 赤いカードの文字列
		ArrayList<String> red = new ArrayList<String>();
		int m = sc.nextInt();
		for (int i = 0; i < m; i++) {
			String tmp = sc.next();
			red.add(tmp);
		}
		// すべての文字列
		ArrayList<String> all = new ArrayList<String>();
		for (String tmp : blue) {
			all.add(tmp);
		}
		for (String tmp : red) {
			all.add(tmp);
		}
		// 各文字列についてポイントを計算
		int point = 0;
		for (String target : all) {
			int pointT = 0;
			for (String tmpB : blue) {
				if (tmpB.equals(target)) {
					pointT++;
				}
			}
			for (String tmpR : red) {
				if (tmpR.equals(target)) {
					pointT = pointT - 1;
				}
			}
			if (point < pointT) {
				point = pointT;
			}
		}
		System.out.println(point);
	}
}

Measured memory_bytes: 23508
import java.io.*;
public class Main 
{
	public static void main(String[] args) throws IOException 
	{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String a = br.readLine();
		int n = Integer.parseInt(a);
		while(n != 0)
		{
			String str = br.readLine();
			char[] s = str.toCharArray();
			for(int i = 0; i < s.length; ++i)
			{
				if(s[i] == 'H' && i + 6 < s.length && s[i + 1] == 'o' && s[i + 2] == 's'
						 && s[i + 3] == 'h' && s[i + 4] == 'i' && s[i + 5] == 'n'
						 && s[i + 6] == 'o')
				{
					s[i + 6] = 'a';
				}
			}
			System.out.println(s);
			--n;
		}
	}
}

Measured memory_bytes: 9340
inpl = lambda: list(map(int,input().split()))
N, K, Q = inpl()
A = [ int(input()) for _ in range(Q)]
points = [K-Q]*N
for i in range(Q):
    points[A[i]-1] += 1
for n in range(N):
    if points[n] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 10464
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

class Main{
    public static void main(String[] a){
    	String[] sl = new String[10];
    	InputStreamReader in = new InputStreamReader(System.in);
    	BufferedReader br = new BufferedReader(in);
    	//ArrayList<Integer> al = new ArrayList<Integer>();
    	//System.out.println(in.getEncoding());
    	for(int i =0; i<10;i++){
    		try{sl[i]= br.readLine();
    		if(i==9){
    			br.close();
    		}
    		}catch(Exception e){
    		}
    		}
    	int[] height = new int[10];
    	for(int i = 0; i<10; i++){
    		height[i]=Integer.parseInt(sl[i]);
    	}
    	Arrays.sort(height);
    	for(int i =9;i>=7;i--){
    	System.out.println(height[i]);
    	}
    	}
    }

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

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define foreach( gg,itit )  for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define mp make_pair
#define pb push_back
#define all(s) s.begin(),s.end()
#define present(c,x) ((c).find(x) != (c).end())
const double EPS = 1e-8;
const int mod = 1e9+7;
const int N = 1e6+10;
const ll INF = 1e18;

//#define DEBUG
ll power(ll x,ll y){
  ll t=1;
  while(y>0){
    if(y%2) y-=1,t=t*x%mod;
    else y/=2,x=x*x%mod;
  }
  return t;
}
#ifdef DEBUG
#define dprintf(fmt,...) fprintf(stderr,fmt,__VA_ARGS__)
#else
#define dprintf(fmt,...)
#endif

int n,k;
vector<int> fac; 
ll ans[N],pali[N];
int main(){
  scanf("%d%d",&n,&k);
  
  int x=1;
  while(x*x<=n){
    if((n)%x==0){
      fac.pb(x); fac.pb(n/x);
    }
    x++;
  }
  sort(all(fac)); fac.resize(unique(all(fac))-fac.begin());
  ll sum=0,z=power(2,mod-2);
  REP(i,fac.size()){

    pali[i]=power(k,(fac[i]+1)/2);
    REP(j,i) if(fac[i]%fac[j]==0){
      int x=fac[i]/fac[j];
      if(x%2==0) pali[i]-=pali[j];
      else pali[i]-=pali[j];
    }
    pali[i]%=mod;
   // printf("%d %lld %lld\n",fac[i],ans[i],pali[i]);
    if(fac[i]%2==0){
      sum+=fac[i]*pali[i]%mod*z%mod;
    }else sum+=fac[i]*pali[i]%mod;
  }
  printf("%lld\n",(sum%mod+mod)%mod);
  return 0;
}

Measured memory_bytes: 256