akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <functional>
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <stack>
#include <string>
#include <vector>
#include <iomanip>
 
using namespace std;
typedef long long ll;
using gra = vector<vector<ll>>;
using gram = vector<unordered_map<ll,ll>>;
 
typedef unsigned long long ull;
 
template <class T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
 
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
template <class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
template <class T> T dup(T a, T b) { return (a + b - 1) / b; }
template <class T> T modpow(T x, T p, T m) { T a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
// template <class T> void prim(T a) { for(ll i=0;i<a.size();++i) { cout << a[i]; } cout << "\n"; }
//template< typename T >
//T mod_pow(T x, T n, const T &p) {
//  T ret = 1;
//  while(n > 0) {
//    if(n & 1) (ret *= x) %= p;
//    (x *= x) %= p;
//    n >>= 1;
//  }
//  return ret;
//}
/////////////////// 
//

#define mod 1000000007LL
#define INF 10000000000000000LL
 
#define rep(i, n) for (ll i = 0; i < n; ++i)
#define rep1(i, n) for (ll i = 1; i <= n; ++i)
#define rrep(i, n) for (int i = (n - 1); i >= 0; --i)
#define rrep1(i, n) for (int i = n; i > 0; --i)
 
#define pri(x) cout << (x) << "\n"
#define pri2(x, y) cout << (x) << " " << (y) << "\n"
#define pri3(x, y, z) cout << (x) << " " << (y) << " " << (z) << "\n"
//#define modpow(x, p, m) { ll a=1; while(p){ if(p%2)a =a*x%m; x = x+x%m; p/=2; } return a; }
 
#define m0(h) memset(h, 0, sizeof(h))
#define m1(h) memset(h, 1, sizeof(h))
#define m(h, n) memset(h, (n), sizeof(h))
#define all(n) (n).begin(),(n).end()
#define bit(n) (1LL << (n))
#define pb push_back
#define mp make_pair
 
//#ifdef LOCAL
//
//#define dpri(...) fprintf(stderr, __VA_ARGS__)
//#define pria(g) rep(i,g.size()){ cout << i << "{"; rep(j,g[i].size()) cout << g[i][j] << " "; cout << "}" << "\n"; }
//#else
//#define dpri(...) 42
//#define pria(g) 42
//#endif
//
//
//

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  // ---------------------
  // コーディング開始
  // ---------------------
  char s;int count = 0;
  while(cin >> s){
    if ((count==0 && s == 'C')||(count==1 && s == 'F')) count += 1;
  }
  cout << ((count == 2) ? "Yes":"No") << endl;
  return 0;
}







Measured memory_bytes: 256
class NilClass
  def preorder
    nil
  end

  def inorder
    nil
  end

  def postorder
    nil
  end

  def parent=(_)
    nil
  end
end

class Node
  attr_reader :id
  attr_accessor :left_child, :right_child, :parent

  def initialize(id)
    @id = id
    @left_child = nil
    @right_child = nil
    @parent = nil
  end

  def preorder
    [@id, @left_child.preorder, @right_child.preorder].flatten.compact
  end

  def inorder
    [@left_child.inorder, @id, @right_child.inorder].flatten.compact
  end

  def postorder
    [@left_child.postorder, @right_child.postorder, @id].flatten.compact
  end

  def print_preorder
    puts "Preorder"
    puts " #{preorder.join(" ")}"
  end

  def print_inorder
    puts "Inorder"
    puts " #{inorder.join(" ")}"
  end

  def print_postorder
    puts "Postorder"
    puts " #{postorder.join(" ")}"
  end
end

n = gets.to_i
node_ids = []
n.times do
  node_ids << gets.chomp.split(' ').map(&:to_i)
end
nodes = node_ids.map { |id_list| Node.new(id_list.first) }

node_ids.each do |id, left_child_id, right_child_id|
  node = nodes.find{|node| node.id == id }
  node.left_child = nodes.find{|node| node.id == left_child_id}
  node.right_child = nodes.find{|node| node.id == right_child_id}
  node.left_child.parent = node
  node.right_child.parent = node
end

root = nodes.find { |node| !node.parent }
root.print_preorder
root.print_inorder
root.print_postorder


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

using namespace std;

int main () {
  int Q, N;
  string S;
  int dp[100005];

  cin >> N >> Q;
  cin >> S;

  dp[0] = 0;
  for (int i=1; i<N; i++) {
    dp[i] = dp[i-1];
    if (S[i-1] == 'A' && S[i] == 'C') {
      dp[i]++;
    }
  }

  for (int i=0; i<Q; i++) {
    int l,r;
    cin >> l >> r;
    cout << dp[r-1] - dp[l-1] << endl;
  }

  return 0;
}



Measured memory_bytes: 1408
import java.util.*;
import java.io.*;
public class Main
{
    public static void main(String []args) throws IOException {
    	FastScanner in  = new FastScanner(System.in);
    	PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)), false);
    	solve(in, out);
    	in.close();
    	out.close();
    }
    static long gcd(long a, long b){ return (b==0) ? a : gcd(b, a%b); }
    static int gcd(int a, int b){ return (b==0) ? a : gcd(b, a%b); }
    private static int fact(int n) { int ans=1; for(int i=2;i<=n;i++) ans*=i; return ans; }
    static class FastScanner{
	BufferedReader reader;
	StringTokenizer st;
	FastScanner(InputStream stream){reader=new BufferedReader(new InputStreamReader(stream));st=null;}
	String next(){while(st == null || !st.hasMoreTokens()){try{String line = reader.readLine();if(line == null){return null;}
	     st = new StringTokenizer(line);}catch (Exception e){throw new RuntimeException();}}return st.nextToken();}
	String nextLine()  {String s=null;try{s=reader.readLine();}catch(IOException e){e.printStackTrace();}return s;}
	int    nextInt()   {return Integer.parseInt(next());}
	long   nextLong()  {return Long.parseLong(next());}
	double nextDouble(){return Double.parseDouble(next());}
	char   nextChar()  {return next().charAt(0);}
	int[]  nextIntArray(int n)         {int[] arr= new int[n];   int i=0;while(i<n){arr[i++]=nextInt();}  return arr;}
	long[] nextLongArray(int n)        {long[]arr= new long[n];  int i=0;while(i<n){arr[i++]=nextLong();} return arr;}
	int[]  nextIntArrayOneBased(int n) {int[] arr= new int[n+1]; int i=1;while(i<=n){arr[i++]=nextInt();} return arr;}
	long[] nextLongArrayOneBased(int n){long[]arr= new long[n+1];int i=1;while(i<=n){arr[i++]=nextLong();}return arr;}
	void   close(){try{reader.close();}catch(IOException e){e.printStackTrace();}}
    }
    
    /********* SOLUTION STARTS HERE ************/
    
    private static void solve(FastScanner in, PrintWriter out){
        int n = in.nextInt();
        int m = in.nextInt();
        int ans = ((n*(n-1))/2)+((m*(m-1))/2);
        out.println(ans);
    }
    
    /************* SOLUTION ENDS HERE **********/
}

Measured memory_bytes: 23252
///******* In the name of Allah *******///

#include <bits/stdc++.h>
using namespace std;

long int ar[10013];
//long int gcd(long int a, long int b)
//{
//    if(b==0)
//        return a;
//    return gcd(b,a%b);
//}
//void sieve()
//{
//    long long int i,j,k = 0;
//    memset(ar,0,sizeof(ar));+
//    ar[1] = 1;
//    for(i=2; i<=713; i++)
//    {
//        if(ar[i]==0)
//        {
//            for(j=i+i; j<=713; j+=i)
//            {
//                ar[j] = 1;
//            }
//        }
//    }
//}

long int a[10000013];
void Ok()
{
    long int b,c,d,e,f,g,h,t,i,j,k,l,m,n,Min,Max;
    long int ans_1,ans_2,ans_3,cnt_1,cnt_2,cnt_3,flag_1,flag_2,flag_3,temp,sum;
    double aa,bb,cc,dd,ee,ff,gg;
    char aaa[113],bbb[113],ccc[113],ddd;
    string spc,in,store;

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin>>aaa;
    cnt_1 = 0;
    Max = 0;
    for(i=0;i<3;i++)
    {
        if(aaa[i]=='R')
            cnt_1++, Max = max(cnt_1,Max);
        else
            cnt_1 = 0;

    }
    cout<<Max<<endl;


    return;
}

int main()
{
//    freopen("input.txt","r",stdin);
//    freopen("output.txt","w",stdout);
    Ok();

    return 0;
}


Measured memory_bytes: 3612
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
count=0
save=0
for i in range(N):
  count+=min(A[i],B[i]+save)
  save=max(0,B[i]-max(0,A[i]-save))
count+=min(A[N],save)
print(count)

Measured memory_bytes: 18476
N, X = map(int, input().split())
L = list(map(int, input().split())) 

import numpy as np

arr = [0]

for i in range(1, N+1):
    arr.append(arr[i-1]+L[i-1])


arr = np.array(arr)

ans = len(arr[arr<=X])

print(ans)

Measured memory_bytes: 12500
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <vector>
#include <cctype>
#include <algorithm>
#include <functional>
#include <cmath>
#include <string>
#include <cstring>
#include <vector>
#include <numeric>
#include <iomanip>
#include <limits>
#include <sstream>
#include <bitset>

#define roop(i, n) for(int i=0;i<n;i++)
#define DIV 1000000007
#define MOD ((int)1e9+7)
//static const long double pi = 3.1415926535897932;

using namespace std;
using ll = long long int;
using ull = unsigned long long;

char toSmall(char c) { // 大文字を小文字へ
	return (c + 0x20);
}

char toLarge(char c) { // 小文字を大文字へ
	return (c - 0x20);
}

float myPower(int a, int n) { // aのn乗の計算
	float x = 1;
	while (n > 0) { // 全てのbitが捨てられるまで
		if ( n & 1) { // 一番右のbitが１のとき
			x *= a;
		}
		a *= a;
		n >>= 1; // bit全体を右に1つシフトして一番右を捨てる
	}
	return x;
}

struct Combination {
	const int num=51e4;			//要素数
	const int mod=1e9+7;
	vector<ll> fact,inv,finv; //階乗,逆元,逆元の階乗.
	
	Combination():fact(num),inv(num),finv(num){
		fact[0]=fact[1]=1;
		inv[1]=1;
		finv[0]=finv[1]=1;
		for(int i=2;i<num;++i){
			fact[i]=fact[i-1]*i%mod;
			inv[i]=mod-inv[mod%i]*(mod/i)%mod;
			finv[i]=finv[i-1]*inv[i]%mod;
		}
	}
	
	int nCk(int n,int k){
		if(n<k) return 0;
		if(n<0 or k<0) return 0;
		return fact[n]*(finv[k]*finv[n-k]%mod)%mod;
	}
	int big_nCk(int n,int k){ //nが大きいとき
		ll res=1LL;
		for (int i = 0; i < k; i++) {
			res=res*(n-i)%mod;
		}
		res = res*finv[k]%mod;
		return res;
	}
	int nHk(int n,int k){return nCk(n+k-1,n-1);}//重複組み合わせ.
};

vector<string> split(const string& src, const char* delim = ",") { //カンマ区切り
	vector<string> vec;
	string::size_type len = src.length();

	for (string::size_type i = 0, n; i < len; i = n + 1) {
		n = src.find_first_of(delim, i);
		if (n == string::npos) {
			n = len;
		}
		vec.push_back(src.substr(i, n - i));
	}

	return vec;
}

bool check_int(string str)
{
	if (all_of(str.cbegin(), str.cend(), [](char ch) { return isdigit(ch);}))
	{
		return true;
	}
	return false;
}

struct rest {
	string s;
	int p;
	int num;

	/* -------------------------------------
	sort関数を使用したときのソートの定義をする。
	まずは文字列sでソートする。
	文字列sが同じだった場合、pでソートする。
	この条件を参考演算子で表現(ifでもOK)
	-------------------------------------*/
	bool operator<(const rest& right) const {
		return s == right.s ? p > right.p : s < right.s;
	}
};

ll pow_mod(ll n, ll k, ll p) { // n^k(mod p)
	if (k == 0) {
		return 1;
	}
	ll res = pow_mod(n * n % p, k / 2, p);
	if (k & 1) {
		res = res * n % p;
	}
	return res;
}

bool vector_finder(std::vector<int> vec, int number) { // vector 内にnumberがあるかどうか
	auto itr = std::find(vec.begin(), vec.end(), number);
	size_t index = std::distance( vec.begin(), itr );
	if (index != vec.size()) { // 発見できたとき
		return true;
	}
	else { // 発見できなかったとき
		return false;
	}
}

int main() {
	double n, d;
	cin >> n >> d;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		double x, y;
		cin >> x >> y;
		if (sqrt(x*x + y*y) <= d) {
			ans++;
		}
	}
	cout << ans << endl;
	return 0;
}

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

namespace ABC080A
{
    class Program
    {
        static void Main(string[] args)
        {
            int n, a, b, x;
            var word = Console.ReadLine().Split(' ');

            n = int.Parse(word[0]);
            a = int.Parse(word[1]);
            b = int.Parse(word[2]);

            if (n * a > b)
                Console.WriteLine(b);

            else if (n * a < b)
                Console.WriteLine(n * a);

            else
                Console.WriteLine(b);

            Console.ReadKey();


        }
    }
}


Measured memory_bytes: 13140
// clang-format off
#include <bits/stdc++.h>

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs
#define ctz __builtin_ctz
#define clz __builtin_clz
#define all(a) (a).begin(), (a).end()
 
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pli = pair<ll,int>;
using pil = pair<int,ll>;
using pll = pair<ll,ll>;
template <typename T> using vec = vector<T>;
using vi = vec<int>;
using vl = vec<ll>;
template <typename T> using que = queue<T>;
template <typename T> using deq = deque<T>;

template <typename T> T id(T b) {return b;};
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
template <typename S, typename K> bool contains(S &s, K k) { return s.find(k) != s.end(); }
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }
// clang-format on

const int MAX_N = 200000;
int n, m;
set<int> s[MAX_N];

int main() {
    fastio();

    cin >> n >> m;
    forn(i, m) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        s[a].insert(b);
        s[b].insert(a);
    }

    forn(i, n) {
        if (contains(s[i], 0) && contains(s[i], n - 1)) {
            cout << "POSSIBLE\n";
            return 0;
        }
    }

    cout << "IMPOSSIBLE\n";

    return 0;
}

Measured memory_bytes: 28416
import sys
input = sys.stdin.readline
N, K = map(int, input().split())
a = list(map(int, input().split()))
mod = 10 ** 9 + 7
res = 0
a.sort()
cs = [0] * (N + 1)
for i in range(N): cs[i + 1] = cs[i] + a[i]
#print(cs)

class Factorial:
  def __init__(self, n, mod):
    self.f = [1]
    for i in range(1, n + 1):
      self.f.append(self.f[-1] * i % mod)
    self.i = [pow(self.f[-1], mod - 2, mod)]
    for i in range(1, n + 1)[: : -1]:
      self.i.append(self.i[-1] * i % mod)
    self.i.reverse()
  def factorial(self, i):
    return self.f[i]
  def ifactorial(self, i):
    return self.i[i]
  def combi(self, n, k):
    return self.f[n] * self.i[n - k] % mod * self.i[k] % mod

f = Factorial(N, mod)
t = [0] * (N + 1)
for i in range(1, N + 1):
  if i - 1 < K - 2: continue
  x = f.combi(i - 1, max(K - 2, 0))
  y = -cs[i] + cs[-1] - cs[-1 - i]
  t[i] = x * y % mod
  res += t[i]
  res %= mod
#print(t)
print(res)

Measured memory_bytes: 63144
#include <cstdio>
#include <vector>
#include <algorithm>

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

  std::vector<std::vector<int>> F(N, std::vector<int>(10));
  for (int i=0; i<N; ++i)
    for (int j=0; j<10; ++j)
      scanf("%d", &F[i][j]);

  std::vector<std::vector<int>> P(N, std::vector<int>(11));
  for (int i=0; i<N; ++i)
    for (int j=0; j<=10; ++j)
      scanf("%d", &P[i][j]);
  
  int res=-2e9;
  for (int i=1; i<(1<<10); ++i) {
    int cur=0;
    for (int j=0; j<N; ++j) {
      int c=0;
      for (int k=0; k<10; ++k)
	if (i>>k & 1 && F[j][k]) ++c;
      
      cur += P[j][c];
    }
    res = std::max(res, cur);
  }

  printf("%d\n", res);
}


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

using namespace std;

typedef long long ll;

const int V = 100005;
vector<int> to[V * 2];
vector<int> cnt;
bool visited[V * 2];

void dfs(int v)
{
	if (visited[v]) {
		return;
	}
	visited[v] = true;
	cnt[v / V]++;
	for (int u : to[v]) {
		dfs(u);
	}
}

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

	cin >> N;

	for (int i = 0; i < N; i++) {
		int x, y;
		cin >> x >> y;
		y += V;
		to[x].push_back(y);
		to[y].push_back(x);
	}

	ll ans = 0;
	for (int i = 0; i < V * 2; i++) {
		if (visited[i]) {
			continue;
		}
		cnt = vector<int>(2);
		dfs(i);
		ans += (ll) cnt[0] * cnt[1];
	}
	ans -= N;
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10240
#include <bits/stdc++.h>
#define vsort(v) sort(v.begin(), v.end())
#define ll long long
#define rep(i, s, g) for (ll i = (s); i < (g); i++)
#define MOD 1000000007
using namespace std;
int main()
{
  ll N, K, step = 0, pos = 1, loop, mordred, r; 
  cin >> N >> K;
  vector<ll> A(N + 1), visited(N + 1, -1); A[0] = 0;
  for (int i = 1; i <= N; i++) {
  	cin >> A[i];
  }
  while (visited[pos] == -1) {
  	visited[pos] = step;
    step++;
    pos = A[pos];
    if (step == K) {
    	cout << pos << endl;
      return 0;
    }
  }
  mordred = visited[pos];
  loop = step - mordred;
  r = (K - mordred) % loop;
  for (ll i = 0; i < r; i++) {
  	pos = A[pos];
  }
  cout << pos << endl;
}

Measured memory_bytes: 6424
#include <iostream>
#include <fstream>

#include <deque>

using namespace std;

typedef deque<int> deqi;

void push(deqi *d,int op, int x){
    switch(op){
    case 0:
        d->push_front(x);
        break;
    case 1:
        d->push_back(x);
        break;
    default:break;
    }
}

int randomAccess(deqi *d, int p){
    return d->at(p);
}

void pop(deqi *d, int op){
    switch(op){
    case 0:
        d->pop_front();
        break;
    case 1:
        d->pop_back();
        break;
    default:break;
    }
    return;
}

int main(){

    deqi d;
    deqi *pd = &d;
    int q;
    cin >> q;
    for(int i=0; i< q;i++){
        int op;
        cin >> op;
        switch(op){
        case 0:{
            int dd, x;
            cin >> dd >> x;
            push(pd, dd, x);
            break;
        }
        case 1:{
            int p;
            cin >> p;
            cout << randomAccess(pd,p) << endl;
            break;
        }
        case 2:{
            int dd;
            cin >> dd;
            pop(pd, dd);
            break;
        }
        default:break;
        }
    }
}


Measured memory_bytes: 4540
import kotlin.math.max

fun main() {
    abc129d()
}

fun abc129d() {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    val vertical = List<IntArray>(h) { IntArray(w + 1) { 0 } }
    val horizontal = List<IntArray>(h) { IntArray(w + 1) { 0 } }
    val vCount = IntArray(w + 1) { 0 }
    repeat(h) { height ->
        val s = readLine()!! + "#"
        // 番兵を用意すれば右端が.であってもカウントを正しく記録できるようにする
        var i = 0
        while (i <= w) {
            var t = 0
            var start = i
            while (s[i] == '.') {
                i++
                t++
            }
            for (j in start until i) {
                vertical[height][j] = t
                vCount[j]++
            }
            vertical[height][i] = 0
            for (k in (height - vCount[i]) until height) {
                horizontal[k][i] = vCount[i]
            }
            vCount[i] = 0
            horizontal[height][i] = 0
            i++
        }
    }
    for (i in 0 until w) {
        if (vCount[i] == 0) continue
        for (k in (h - vCount[i]) until h) {
            horizontal[k][i] = vCount[i]
        }
    }
    var max_size = 0
    for (i in 0 until h) {
        for (j in 0 until w) {
            max_size = max(vertical[i][j] + horizontal[i][j] - 1, max_size)
        }
    }
    println(max_size)
}

Measured memory_bytes: 94152
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <algorithm>
#include <random>
#include <chrono>
#include <iomanip>
#define lint long long int
#define FOR(x, to) for(int x=0; x<(int)(to); x++) // for簡略表記
#define DUMP(ar) for(int loop=0; loop<(int)ar.size(); loop++) cout << "[" << loop << "]:" << ar[loop] << endl // 配列一覧表示
#define DUMPL(ar) for(int loop=0; loop<(int)ar.size(); loop++) { cout << ar[loop]; if(loop<(int)ar.size()-1) cout << ' '; } cout << endl; // 配列一行一覧表示
#define COUT(x) cout << x << endl // 単要素出力
#define ALL(ar) ar.begin(), ar.end() // コンテナの全要素
#define LOOPD(i) cout << "ループ[" << i << "]回目---------------" << endl // ループ回数デバグ
using namespace std;
// cout << fixed << setprecision(4) で小数点以下4桁の桁そろえ
// cout << setw(5) << ... で表示形式を5桁に設定 5桁未満なら頭に空白がつく 5桁越なら先頭から5桁まで
// cout << setw(5) << setfill('0') << ... で空白部分の埋め文字に5を使う
// getline(cin, [変数]); で空白などを含む入力の受け取り(行ごとの受け取り)
// cin >> ws; でそこまでにストリームに残されたホワイトスペースを取り除く(=以降のgetlineの有効化)

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

    string n;
    cin >> n;
    int count = 0;
    // cout << n.size()-1 << endl;
    for(int i=0; i<(int)n.size()-1; i++){
        if(n[i] == n[i+1]){
            count++;
            // cout << count << endl;
            if(count == 2){
                COUT("Yes");
                return 0;
            }
        }else{
            count = 0;
        }
    }

    COUT("No");
    return 0;
}

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

int main(){
	int n; ll k; cin >> n >> k;
	vector<ll> a(n),f(n);
	for(int i=0;i<n;i++){
		cin >> a[i];
	}
	for(int i=0;i<n;i++){
		cin >> f[i];
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	sort(f.begin(),f.end());
	vector<pair<ll,ll> > v(n);
	for(int i=0;i<n;i++){
		v[i]=make_pair(a[i]*f[i],f[i]);
	}
	sort(v.begin(),v.end());
	reverse(v.begin(),v.end());
	ll left=-1; ll right=1e12;
	while(right-left>1){
		ll mid=(left+right)/2;
		ll sum=0;
		for(int i=0;i<n;i++){
			if(v[i].first>mid){
				sum+=v[i].first/v[i].second-mid/v[i].second;
			}
			else{
				break;
			}
		}
		if(sum<=k){
			right=mid;
		}
		else{
			left=mid;
		}
	}
	cout << right << endl;
}


Measured memory_bytes: 6528
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <iostream>
#include <utility>
#include <set>
#include <cctype>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

int main(){

  int N, K, l, max;
  vector<int> length;
  cin >> N >> K;
  for(int i=0; i<N; i++){
    cin >> l;
    length.push_back(l);
  }
  sort(length.begin(), length.end(), greater<int>());
  max =0;
  for(int i=0; i<K; i++){
    max += length[i];
  }
  cout << max << endl;
}


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

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

    vector<int> data(n);
    for (int i = 0; i < n; i++){
        cin >> data.at(i);
    }

    int max = 0, tmax = 0;
    for (int i = 0; i < n - 1; i++){
        if (data.at(i) < data.at(i + 1)){
            if (max < tmax){
                max = tmax;
            }

            tmax = 0;
        }
        else{
            tmax++;
        }
    }
  if (max < tmax){
    max = tmax;
  }

    cout << max << endl;
}


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

using namespace std;

bool isPalindrome(string s, int begin, int end) {
  bool result = true;
  
  for (int i = begin; i < end; i++) {
    if (s[i] != s[end - i - 1]) {
      result = false;
      break;
    }
  }
  
  return result;
}

int main() {
  string s;
  
  cin >> s;
  
  int N = s.length();
  bool ans = isPalindrome(s, 0, (N - 1) / 2) && isPalindrome(s, (N + 1) / 2, N);
  
  cout << (ans ? "Yes" : "No") << endl;
  return 0;
}

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

int main() {
  ll N, A, B, cntA, cntB, minF = 114514;
  cin >> N;
  for(ll i = 1; i < sqrt(N) + 1; i++) {
    if(N % i == 0) {
      A = i;
      B = N / i;
      cntA = 0;
      cntB = 0;
      while(A != 0) {
        A /= 10;
        cntA++;
      }
      while(B != 0) {
        B /= 10;
        cntB++;
      }
    }
    if(minF > max(cntA, cntB)) minF = max(cntA, cntB);
  }
  cout << minF << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
    using namespace std;
     
    int main() {
      
    int x1, x2, x3, x4, x5;
      cin >> x1 >> x2 >> x3 >> x4 >> x5;
        
      if (x1 == 0){
        cout << 1 << endl;
      }
      else if (x2 == 0){
        cout << 2 << endl;
      }
      else if (x3 == 0){
        cout << 3 << endl;
      }
      else if (x4 == 0){
        cout << 4 << endl;
      }
      else if (x5 == 0){
        cout << 5 << endl;
      }
    }

Measured memory_bytes: 3572
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<climits>
#include<cmath>
#include<sstream>
#include<iomanip>

const int64_t cc = pow( 10, 9 ) + 7;

bool sort_pair( std::pair< char, int64_t > origin, std::pair< char, int64_t > another )
{
    return origin.second > another.second;
}

int main()
{
    int64_t a,b,c,d;
    std::cin>> a;

    std::vector< int64_t > list( a );

    for( int i = 0; i < a; i++ )
    {
        std::cin>> list[i];
    }

    c = 1;
    int64_t result = 0;
    bool out = true;
    
    for( int i = 0; i < list.size(); i++ )
    {
        if( list[i] == c )
        {
            c += 1;
            out = false;
        }
        else
        {
            result += 1;
        }
    }

    if( out )
    {
        result = -1;
    }

    std::cout<< result;
}


Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace ProCon
{
    class Program
    {
        static void Main(string[] args)
        {
            int num = int.Parse(Console.ReadLine());
            string input = Console.ReadLine();
            int leftStock = 0;
            int tooManyRight = 0;
            for(int i = 0; i < num; ++i)
            {
                if(input[i] == '(')
                {
                    leftStock++;
                }
                else
                {
                    if(leftStock > 0)
                    {
                        leftStock--;
                    }
                    else
                    {
                        tooManyRight++;
                    }
                }
            }
            string result = "";
            for(int i = 0; i < tooManyRight; ++i)
            {
                result += "(";
            }
            result += input;
            for (int i = 0; i < leftStock; ++i)
            {
                result += ")";
            }
            Console.WriteLine(result);
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0;}

int main() {
    ll n,m;
    cin >> n >> m;
    if(n==1 && m==1) {
        cout << 1 << endl;
        return 0;
    }
    if(n==1) {
        cout << m-2 << endl;
        return 0;
    }
    if(m==1) {
        cout << (n-2) << endl;
        return 0;
    }
    cout << (n-2)*(m-2) << endl;
}

Measured memory_bytes: 3564
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define vi vector<int>
#define vs vector<string>
#define vll vector<ll>
#define ii pair<int, int>
#define pll pair<ll, ll>
#define vpll vector<pll>
#define vii vector<ii>
#define vvi vector<vi>
#define vvii vector<vii>
#define ld long double
#define iii tuple<int, int, int>
#define sc scanf
#define pb push_back
#define FOR(i, x, n) for(int i=x; i<=n; ++i)
#define ROF(i, x, n) for(int i=x; i>=n; --i)
#define MOD 1000000007
#define F first
#define S second

int a[105][2];

int main() {

    int n;
    sc("%d", &n);

    FOR(i, 1, n) {
        sc("%d %d", &a[i][0], &a[i][1]);
    }

    FOR(i, 1, n-2) {
        if(a[i][0] == a[i][1] && a[i+1][0] == a[i+1][1] && a[i+2][0] == a[i+2][1]) {
            printf("Yes\n");
            return 0;
        }
    }

    printf("No\n");
}



Measured memory_bytes: 3756
#include<iostream>
#include<vector>
#include <stdio.h>
#include <queue>
#include <algorithm>
#include <math.h>
using namespace std;
 
vector<int> p,rank,cost;
 
 
int find(int x) {
    int prep = p[x];
    if(x != p[x]) {
        p[x] = find(p[x]);
    }
    cost[x] += cost[prep];
    return p[x];
}
 
void connect(int x, int y, int z) {
    int rootx = find(x), rooty = find(y);
    if(rootx == rooty) return;
    z = z + cost[x] - cost[y];
    if(rank[rooty] < rank[rootx]) {
        p[rooty] = rootx;
        cost[rooty] = z;
    }
    else {
        p[rootx] = rooty;
        cost[rootx] = -z;
        if(rank[rootx] == rank[rooty]) rank[rooty]+=1;
    }
}

void Set(int x) {
    p.push_back(x);
    rank.push_back(0);
    cost.push_back(0);
}
 
int main() {
    int n,q,com,x,y,z;
    scanf("%d %d", &n, &q);
    for(int i=0; i<n; i++) Set(i);
    for(int i=0; i<q; i++) {
        scanf("%d %d %d", &com, &x, &y);
        if(com == 1) {
            if(find(x) == find(y)) 
            {
                cout << cost[y]-cost[x] << endl;
            }
            else {
                cout << '?' << endl;
            }
        }
        else {
            
        scanf("%d", &z);
            connect(x,y,z);
    }
    }
    return 0;
}


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

using namespace std;
int main(){
    int n, k;
    string s;
    cin >> n;
    cin >> s;
    cin >> k;

    char target = s[k - 1];

    for (int i = 0; i < n; i++){
        if(s[i] != target)
            s[i] = '*';
    }

    cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define INFTY 1<<20
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
const int MOD=1000000007;
int n;
int x[102],cnt=0;
//最大公約数
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
int main(){
    int n;cin>>n;
    vector<ll> a(n);
    rep(i,n)cin>>a[i];
    ll ans = a[0];
    rep(i,n){
        ans = gcd(ans,a[i]);
    }

    cout<<ans<<endl;

return 0;
}

Measured memory_bytes: 1024
H, W, K = map(int, input().split())
cake = [input() for _ in range(H)]
ans = [[0]*W for _ in range(H)]

pn = 1
for i, r in enumerate(cake):
    for j, p in enumerate(r):
        if p == '#':
            ans[i][j] = pn
            n = j-1
            while n < W and n >= 0 and ans[i][n] == 0 and cake[i][n] != '#':
                ans[i][n] = pn
                n -= 1
            n = j+1
            while n < W and n >= 0 and ans[i][n] == 0 and cake[i][n] != '#':
                ans[i][n] = pn
                n += 1
            pn += 1
    if pn > K:
        break

for i, a in enumerate(ans):
    if 0 in a:
        if i != 0:
            ans[i] = ans[i-1]
        else:
            for ary in ans[i:]:
                if not 0 in ary:
                    ans[i] = ary
                    break

for ary in ans:
    print(*ary)


Measured memory_bytes: 47324
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto hwk = readln.split.to!(int[]);
    auto H = hwk[0];
    auto W = hwk[1];
    auto K = hwk[2];
    char[][] CK;
    CK.length = H;
    auto HK = new int[](H);
    foreach (i; 0..H) {
        CK[i] = readln.chomp.to!(char[]);
        int k;
        foreach (c; CK[i]) if (c == '#') ++k;
        HK[i] = k;
    }
    auto RR = new int[][](H, W);
    int start = -1;
    int n;
    foreach (i; 0..H) {
        if (start == -1) {
            if (HK[i] == 0) continue;
            start = i;
        }
        if (HK[i] == 0) {
            foreach (j; 0..W) {
                RR[i][j] = RR[i-1][j];
            }
        } else if (HK[i] == 1) {
            ++n;
            foreach (j; 0..W) RR[i][j] = n;
        } else {
            ++n;
            bool skip;
            foreach (j; 0..W) {
                if (CK[i][j] == '#') {
                    if (skip) ++n;
                    skip = true;
                }
                RR[i][j] = n;
            }
        }
    }
    foreach_reverse (i; 0..start) foreach (j; 0..W) RR[i][j] = RR[i+1][j];

    foreach (r; RR) writeln(r.to!(string[]).join(" "));
}

Measured memory_bytes: 9084
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <bitset>
#include <climits>
#define REP(i,n) for (int i=0;i<(n);i++)
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define RFOR(i,a,b) for (int i=(a)-1;i>=(b);i--)
#define ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int INF = 1e9;
const ll LL_INF = 1e18;
const int MOD = 1e9 + 7;

using namespace std;

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  ull A[100005];
  REP(i,N){
    cin >> A[i + 1];
  }
  N++;
  A[0] = 0;
  map<int, int> mp;
  REP(i,N){
    if(i) A[i] += A[i - 1];
    mp[A[i] % M]++;
  }
  ull ans = 0;
  for(auto m : mp){
    ull a = m.second;
    ans += a*(a-1)/2;
  }
  cout << ans << endl;
  return 0;
}


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

int main()
{
  int N, K;
  int cnt = 0;
  cin >> N >> K;

  int h;
  for (int i=0;i<N;i++){
    cin >> h;
    if (h>=K){
      cnt++;
    }
  }

  cout << cnt << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
#include <string>
#include <vector>
#include <algorithm>
#include <map>
typedef long long ll;
#include <cmath>


int main(int argc, char *argv[])
{
	int n,m;
	cin >> n>>m;
	

	cout<< ((m>=n)?"Yes":"No")<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //JuniorMonster a.k.a Sho10
#define ll long long
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#define all(a) (a).begin(), (a).end()
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define sz size
#define f first
#define s second
#define pb push_back
#define er erase
#define in insert
#define mp make_pair
#define pi pair
#define rc(s) return cout<<s,0
#define mod 1000000007
#define PI 3.14159265359
#define CODE_START  ios_base::sync_with_stdio();cin.tie();cout.tie();
using namespace std;
ll n;
char a;
int32_t main(){
CODE_START;
cin >> a;
if(a=='a'||a=='e'||a=='i'||a=='o'||a=='u'){
    rc("vowel");
}
cout << "consonant";
}


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

int main(){

    int q;
    cin >> q;

    list<int> List;
    list<int>::iterator cursor = List.end();
    for(int i = 0; i < q; ++i){
        int com;
        cin >> com;
        if(com == 0){
            int x;
            cin >> x;
            cursor = List.insert(cursor, x);
        }
        else if(com == 1){
            int d;
            cin >> d;
            if(d >= 0){
                cursor = next(cursor, d);
            }
            else{
                cursor = prev(cursor, -d);
            }
        }
        else if(com == 2){
            cursor = List.erase(cursor);
        }
    }

    for(auto x : List){
        cout << x << endl;
    }

    return 0;
}


Measured memory_bytes: 18612
//g++ -std=gnu++14 a.cpp

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <iostream>
#include <istream>
#include <iterator>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <tuple>
#include <iomanip>
#include <random>
#include <math.h>

using namespace std;

#define ll long long
#define rep(i, n) for(ll i = 0; i < (n); i++)
ll MOD = 1e9 + 7;
int INF = 1 << 30;
ll INFL = 1LL << 60;

int main(){
  ll N;
  cin >> N;
  vector<ll> A(100010);
  vector<ll> B(100010);
  vector<ll> C(100010);
  rep(i,N){
    cin >> A[i] >> B[i] >> C[i];
  }
  vector<vector<ll>> dp(3,vector<ll>(100010,0));
  dp[0][0] = A[0];
  dp[1][0] = B[0];
  dp[2][0] = C[0];
  rep(i,N){
    dp[0][i+1] = max(dp[1][i]+A[i+1],dp[2][i]+A[i+1]);
    dp[1][i+1] = max(dp[0][i]+B[i+1],dp[2][i]+B[i+1]);
    dp[2][i+1] = max(dp[0][i]+C[i+1],dp[1][i]+C[i+1]);
  }
  ll ans = 0;
  ans = max(dp[0][N-1],max(dp[1][N-1],dp[2][N-1]));
  cout << ans << endl;
}


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

using namespace std;

typedef long long int ll;
#define f first
#define s second
#define Mp make_pair
#define pb push_back
#define Lb lower_bound
#define Ub upper_bound
#define all(x) x.begin(), x.end()
#define fast_io ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);

const ll Maxn = 300 + 5, N = 50 + 5, Mod = 1000 * 1000 * 1000 + 7, Inf = (ll) 1e15;
int n, m, l, t, ans[Maxn][Maxn];
ll dp[Maxn][Maxn];


int main() {
    fast_io
    cin >> n >> m >> l;
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            dp[i][j] = Inf;
        }
    }
    while (m--) {
        int ai, bi, ci;
        cin >> ai >> bi >> ci;
        if (ci <= l) {
            dp[ai][bi] = min(dp[ai][bi], (ll) ci);
            dp[bi][ai] = min(dp[bi][ai], (ll) ci);
        }
    }
    for (int k = 1; k <= n; k++) {
        for (int j = 1; j <= n; j++) {
            for (int i = 1; i <= n; i++) {
                dp[i][j] = min(dp[i][j], dp[i][k] + dp[k][j]);
            }
        }
    }
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (i == j || l < dp[i][j]) {
                ans[i][j] = Maxn;
            }
        }
    }
    for (int k = 1; k <= n; k++) {
        for (int j = 1; j <= n; j++) {
            for (int i = 1; i <= n; i++) {
                ans[i][j] = min(ans[i][j], ans[i][k] + ans[k][j] + 1);
            }
        }
    }
    int t;
    cin >> t;
    while (t--) {
        int si, fi;
        cin >> si >> fi;
        if (ans[si][fi] == Maxn) ans[si][fi] = -1;
        cout << ans[si][fi] << '\n';
    }
    return 0;
}

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

int inputnumbers(int *raw,int *column){
	cin >> *raw >> *column;
	if(0<*raw && *raw<=100 && 0<*column && *column<=100)
		return 1;
	else
		return 0;
}

int inputsheet(int r,int c,int (*x)[101]){
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			cin >> x[i][j];
		}
	}
	return 0;
}

int printsheet(int r, int c, int (*x)[101]){
	for(int i=0;i<r;i++){
		for(int j=0;j<c;j++){
			if(j<c-1)
				cout << x[i][j] << ' ';
			else
				cout << x[i][j];
		}
		cout << endl;
	}
	return 0;
}

int calculation(int r, int c, int (*x)[101]){

	for(int i=0;i<r+1;i++){
		x[i][c]=0;
		for(int j=0;j<c;j++){
			x[i][c] += x[i][j];
		}
	}
	for(int j=0;j<c+1;j++){
		x[r][j]=0;
		for(int i=0;i<r;i++){
			x[r][j] += x[i][j];
		}
	}



	return 0;
}


int main() {
	int raw,column;
	int x[101][101];

	inputnumbers(&raw, &column);
	inputsheet(raw, column, x);
	calculation(raw, column,x);
	printsheet(raw+1, column+1,x);

	return 0;
}



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

int main() {
    string stra;
    int x;
    bool r=true;
    cin >> stra;
    x= stra.length();
    for(int i=0;i<x;i++){
        for(int j=i+1;j<x;j++){
            if(stra[i]==stra[j]){
                r=false;
                break;
            }
        }
    }
    if(r==false){
        cout << "no" << endl;
    }else if(r==true){
        cout << "yes" << endl;
    }
}

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <array>

template <typename T>
using Vec = std::vector<T>;

using Pair = std::array<int, 2>;

int main() {
	int n, t;
	std::cin >> n >> t;

	Vec<Pair> dish(n);
	for (auto&& p : dish)
		std::cin >> p[0] >> p[1];

	std::sort(dish.begin(), dish.end());

	// dish[i, n) の中で一番大きい美味しさ
	Vec<int> revMax(n + 1);
	revMax[n] = 0;
	for (int i = n - 1; i >= 0; --i)
		revMax[i] = std::max(revMax[i + 1], dish[i][1]);

	Vec<Vec<int>> dp(n + 1, Vec<int>(t + 1));
	for (int i = 1; i < n; ++i) {
		for (int j = 1; j <= t; ++j) {
			const int w = dish[i - 1][0];
			const int d = dish[i - 1][1];

			if (j < w)
				dp[i][j] = dp[i - 1][j];
			else
				dp[i][j] = std::max(dp[i - 1][j - w] + d, dp[i - 1][j]);
		}
	}

	int ans = dp[n][t];

	ans = std::max(ans, revMax[0]);
	for (int i = 0; i <= n; ++i)
		ans = std::max(ans, dp[i][t - 1] + revMax[i]);

	std::cout << ans << std::endl;
}

Measured memory_bytes: 35584
#include<iostream>
#include<cctype>
#include<cstdio>
#include<cstring>
using namespace std;
int n;
int a,b,c,d;
int ok[4];
int tot[4];
int main(){
#ifdef LOCAL
	freopen("a.txt","r",stdin);
#endif
	while(~scanf("%d",&n)&&n){
		memset(tot,0,sizeof(tot));
		memset(ok,0,sizeof(ok));
		while(n--){
			scanf("%d%*c%d%d",&a,&b,&c);
			//cout<<"a b c"<<a<<" "<<b<<" "<<c<<endl;
			int t;
			if(a>=11 && a<=14){
				t=0;
			}
			else
				if(a>=18 && a<=20){
					t=1;
				}
				else
					if(a>=21 || a<=1){
						t=2;
					}
					else
						t=3;
			//cout<<"t "<<t<<endl;
			tot[t]++;
			if((c+60-b)%60 <=8)
				ok[t]++;
		}
		//cout<<tot[0]<<" "<<tot[1]<<" "<<tot[2]<<endl;
		if(tot[0]){
			printf("lunch %d\n",ok[0]*100/tot[0]);
		}
		else
			printf("lunch no guest\n");
		if(tot[1]){
			printf("dinner %d\n",ok[1]*100/tot[1]);
		}
		else
			printf("dinner no guest\n");
		if(tot[2]){
			printf("midnight %d\n",ok[2]*100/tot[2]);
		}
		else
			printf("midnight no guest\n");
	}
}

Measured memory_bytes: 1196
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstring>
#include <string>
#include <cctype>
#include <sstream>
#include <cmath>
#include <climits>
#include <set>
#include <iostream>
#include <map>
#include <functional>
#include <cstdlib>
#include <numeric>
#include <queue>
#include <complex>
#include <sstream>
#include <stack>

using namespace std;

#define reep(i,f,n) for(int i=f; i<int(n); ++i)
#define rep(i,n) reep(i,0,n)

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef complex<double> Point;

int main()
{
	int n;
	scanf("%d", &n);
	rep(i, n){
		int field[9][9];
		rep(j, 9) rep(k, 9)
			scanf("%d", &field[j][k]);
		
		vector<vector<bool> > collect(9, vector<bool>(9, true));
		rep(j, 3){
			rep(k, 9){
				pii base;
				if(j == 0) base = pii(k, 0);
				if(j == 1) base = pii(0, k);
				if(j == 2) base = pii(k/3*3, k%3*3);
				
				int hist[9] = {0};
				rep(l, 2){
					rep(m, 9){
						pii diff;
						if(j == 0) diff = pii(0, m);
						if(j == 1) diff = pii(m, 0);
						if(j == 2) diff = pii(m/3, m%3);
						
						pii now(base.first + diff.first, base.second + diff.second);
						int a = field[now.first][now.second] - 1;
						if(!l)
							hist[a]++;
						else
							collect[now.first][now.second] = collect[now.first][now.second] & (hist[a] == 1);
					}
				}
			}
		}
		
		if(i)
			puts("");
		rep(j, 9){
			rep(k, 9)
				printf("%c%d", collect[j][k] ? ' ' : '*', field[j][k]);
			puts("");
		}
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

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

		int b = n % 500;

		if (a >= b) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}


Measured memory_bytes: 21716
n,m=map(int,input().split())
ab=[list(map(int,input().split())) for i in range(n)]
ab.sort()

count=0

for i in range(n):
    if ab[i][1]>m:
        count+=ab[i][0]*m
        break
    else:
        count+=ab[i][0]*ab[i][1]
        m-=ab[i][1]

print(count)

Measured memory_bytes: 27884
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<map>
#include<utility>
#define mod 1000000007
#define ll long long
#define mp make_pair
#define pb push_back
using namespace std;
int main(){
	ll n;
	cin>>n;
	vector< pair<ll,ll> > eds;
	if(n%2==0){
		for(int i=1;i<=n;i++){
			for(int j=i+1;j<=n;j++){
				if( i+j != n+1 ){
					eds.pb( mp(i,j) );
				}
			}
		}
	}
	else{
		for(int i=1;i<=n-1;i++){
			for(int j=i+1;j<=n;j++){
				if( i+j != n){
					eds.pb( mp(i,j) );
				}
			}
		}
	}
	cout<<eds.size()<<endl;
	for(int i=0;i<eds.size();i++){
		cout<<eds[i].first<<" "<<eds[i].second<<endl;
	}
	return 0;
}

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

int main() {
	long long K, N;
	cin >> K >> N;
	if (K % 2 == 0) {
		cout << K / 2;
		for (int i = 1; i < N; i++) {
			cout << " " << K;
		}
		cout << endl;
		return 0;
	}
	stack<long long> ANS;
	long long Size = N;
	for (int i = 0; i < N; i++) ANS.push((K + 1) / 2);
	for (int i = 0; i < N / 2; i++) {
		if (ANS.top() == 1) ANS.pop(), Size--;
		else {
			ANS.top()--;
			for (int j = Size; j < N; j++) ANS.push(K);
			Size = N;
		}
	}
	vector<long long> ANS2;
	while (!ANS.empty()) ANS2.push_back(ANS.top()), ANS.pop();
	reverse(ANS2.begin(), ANS2.end());
	for (int i = 0; i < ANS2.size(); i++) {
		cout << ANS2[i];
		if (i == ANS2.size() - 1) cout << endl;
		else cout << " ";
	}
}

Measured memory_bytes: 7756
/// @file
/// @copyright 2018 thousand
/// @version Accepted.
#include <bits/stdc++.h>
using std::cin;
using std::cout;
using std::endl;
using std::max_element;
using std::string;
using std::stringstream;
using std::vector;

namespace {
class Ints : public vector<int> {
 public:
  string str();
};
class Intss : public vector<Ints> {
 public:
  string str(string delimiter);
};
class Intsss : public vector<Intss> {
 public:
  string str();
};
string Ints::str() {
  stringstream ss;
  for (auto it = this->begin(); it != this->end(); ++it) {
    ss << *it;
    if (it != this->end() - 1) ss << " ";
  }
  return ss.str();
}
string Intss::str(string delimiter = "\n") {
  stringstream ss;
  for (auto it = this->begin(); it != this->end(); ++it) {
    ss << it->str();
    if (it != this->end() - 1) ss << delimiter;
  }
  return ss.str();
}
string Intsss::str() {
  stringstream ss;
  for (auto it = this->begin(); it != this->end(); ++it) {
    ss << it->str(" ");
    if (it != this->end() - 1) ss << endl;
  }
  return ss.str();
}
void GetInput(int* N, Intsss* F, Intss* P) {
  cin >> *N;
  for (int i = 1; i <= *N; ++i) {
    Intss intss;
    for (int j = 1; j <= 5; ++j) {
      Ints ints;
      for (int k = 1; k <= 2; ++k) {
        ints.push_back(-1);
        cin >> *--ints.end();
      }
      intss.push_back(ints);
    }
    F->push_back(intss);
  }
//  cout << F->str() << endl;
  for (int i = 1; i <= *N; ++i) {
    Ints ints;
    for (int j = 0; j <= 10; ++j) {
      ints.push_back(-1);
      cin >> *--ints.end();
    }
    P->push_back(ints);
  }
//  cout << P->str() << endl;
}
void Solve(int N, const Intsss& F, const Intss& P) {
  Ints profits;
  for (int b = 1; b <= 1023; ++b) {  // for each case.
    int P_sum = 0;
    for (int i = 0; i < N; ++i) {
      // "Let c_i be the number of periods during which both Shop i"
      // "and Joisino's shop are open."
      int c_i = 0;
      for (int j = 0; j < 5; ++j) {
        for (int k = 0; k < 2; ++k) {
          bool open_shop_i = F[i][j][k];
          bool open_Joisino = (b >> (2 * j + k) & 1);
          if (open_shop_i && open_Joisino) ++c_i;
        }
      }
      P_sum += P[i][c_i];
    }
    profits.push_back(P_sum);
  }
  cout << *max_element(profits.begin(), profits.end()) << endl;
}
}  // namespace

int main() {
  int N;
  Intsss F;
  Intss P;
  GetInput(&N, &F, &P);
  Solve(N, F, P);
}


Measured memory_bytes: 256