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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second

#define DUMP(x) cout<<#x<<":"<<(x)<<endl
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class T>
istream& operator>>(istream& is, vector<T>& xs){
  for(auto& x: xs)
	is >> x;
  return is;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
ostream& operator<<(ostream& os, const vector<T>& xs){
  for(unsigned int i=0;i<xs.size();++i)
	os << (i?" ":"") << xs[i];
  return os;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;


class BIT{
private:
  int n;
  VI bit;
public:
  BIT(int n_){
	n = n_;
	bit.assign(n+1, 0);
  }

  // return bit[1] + ... + bit[i]
  int sum(int i){
	int s = 0;
	while(i > 0){
	  s += bit[i];
	  i -= i & -i;
	}
	return s;
  }

  // bit[i] += x
  void add(int i, int x){
	while(i <= n){
	  bit[i] += x;
	  i += i & -i;
	}
  }

  int lower_bound(int x){
	if(x <= 0) return 0;
	int i = 1;
	for(;i<=n;i<<=1);
	i >>= 1;
	int res = 0;
	for(;i>0;i>>=1){
	  if(res+i <= n && bit[res+i] < x){
		x -= bit[res+i];
		res += i;
	  }
	}
	return res+1;
  }
};

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

  int N, Q;
  cin >> N >> Q;
  BIT bit(N+1);
  while(Q--){
	int c, x, y;
	cin >> c >> x >> y;
	if(c == 0){
	  bit.add(x, y);
	}
	else{
	  cout << bit.sum(y) - bit.sum(x-1) << endl;
	}
  }

  return 0;
}



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

int main(){
    int n ,k;
    cin >> n ;
    vector<int> t ;
    vector<int> cost ;
    for(int i = 0 ; i<n ; i++){
        scanf("%d",&k) ;
        t.push_back(k) ;
    }
    cost.push_back(0) ;
    cost.push_back(abs(t[n-1] - t[n-2])) ;
    for(int i=n-3 ;i>=0 ; i--){
        if(abs(t[i] - t[i+1])+cost[n-i-2] > abs(t[i] - t[i+2])+cost[n-i-3] ){
            cost.push_back(abs(t[i] - t[i+2])+cost[n-i-3]) ;
        }else{
            cost.push_back(abs(t[i] - t[i+1])+cost[n-i-2]) ;
        }

    }
    cout << cost[n-1] ;
    return 0 ;
}





Measured memory_bytes: 1400
import sys
input = sys.stdin.readline

def main():
    N = int(input())
    T,A = map(int,input().split())
    H = list(map(int,input().split()))
    temp = 10**10
    ans = -1
    for i in range(N):
        if temp > abs(T-H[i]*0.006-A):
            ans = i
            temp = abs(T-H[i]*0.006-A)
            
    print(ans+1)
    
if __name__ == "__main__":
    main()


Measured memory_bytes: 3060
#方針: 753数を全列挙
n = gets.to_i

list = ["7","5","3"]
ary = []

def is_753?(s)
  f7=f5=f3 = false
  s.chars do |c|
    case c
    when "7"
      f7=true
    when "5"
      f5=true
    when "3"
      f3=true
    end
  end
  return f7&&f5&&f3
end

ary = (3..9).inject([]){|memo, digit| memo + ["7","5","3"].repeated_permutation(digit).select{|a| is_753?(a.join)}.map(&:join)}

ans = 0
ary.each_with_index do |a, i|
  if a.to_i <= n
    ans+=1
  end
end
 
p ans

Measured memory_bytes: 12284
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define _GLIBCXX_DEBUG // check []
#define DIVISOR 1000000007

using namespace std;
typedef pair<int,int> pii;
typedef pair<int64_t, int64_t> pII;

template<typename T>
void cins(vector<T>& arr) { for(T& e: arr) cin >> e; }

#ifdef DEBUG
#define debug(fmt, ...) \
    printf("[debug: %s] " fmt, __func__, __VA_ARGS__)
#define ps(arr) \
    debug("size %ld: ", arr.size()); \
    for(auto e: arr) cout << e << " "; \
    cout << endl;
#else
#define debug(fmt, ...)
#define ps(arr)
#endif

int sign(int a) {
    if(a > 0) return 1;
    if(a < 0) return -1;
    return 0;
}

int main(void) {
    int num;
    cin >> num;
    vector<int> arr(num);
    cins(arr);
    int prev = arr[0];
    int dir = 0;
    int cnt = 1;
    for(int i = 0; i < num; i++) {
        int cur = arr[i];
        int sgn = sign(cur-prev);
        if(dir == 0) {
            dir = sgn;
        } else {
            if(dir*sgn == -1) {
                // cut and reset
                dir = 0;
                cnt++;
            }
        }
        debug("cnt: %d(sgn: %d)\n", cnt, sgn);
        prev = cur;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3684
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

#ifdef NJUDGE 
#include "C:/Users/Mateus/Documents/CP/Programas/Templates/kowski.h"
#endif

using namespace __gnu_pbds;
using namespace std; 

using T_ = int;
typedef tree<T_, less<T_>, null_type, rb_tree_tag, tree_order_statistics_node_update> ordered_set; 

typedef long long ll;
typedef long double ld;
typedef pair <int, int> pii;
typedef pair <ll, ll> pll;
typedef pair <ld, ld> pld;
#define pb push_back
#define ss second
#define ff first

const int N = 2e5 + 10, L = 22;
int n, a[N], l[N], r[N], st[N][L];

void build(){
  for(int i = 0; i < n; i++)
    st[i][0] = a[i];

  for(int k = 1; (1<<k) <= n; k++)
    for(int i = 0; i+(1<<k) <= n; i++)
      st[i][k] = min(st[i][k-1], st[i+(1<<(k-1))][k-1]);
}

int get(int a, int b){
  int k = log2(b-a+1);
  return min(st[a][k], st[b-(1<<k)+1][k]);
}

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

  for(int i = 0; i < n; i++)
    scanf("%d", a+i);

  build();
  ll ans = 0LL;

  for(int i = 0; i < n; i++){
    int lo = i, hi = n-1, mid;
    while(lo <= hi){
      mid = ((lo+hi)>>1) + (hi-lo==1);
      if (get(i, mid) < a[i]) hi = mid-1;
      else lo = mid;
      if (lo == hi){
        r[i] = lo;
        break;
      }
    }

    lo = 0, hi = i;
    while(lo <= hi){
      mid = ((lo+hi)>>1);
      if (get(mid, i) < a[i]) lo = mid+1;
      else hi = mid;
      if (lo == hi){
        l[i] = lo;
        break;
      }
    }
  }

  for(int i = 0; i < n; i++)
    ans += a[i] * 1LL* (r[i]-i+1) * (i-l[i]+1);

  printf("%lld\n", ans);
}

Measured memory_bytes: 19840
#include <iostream>
#include <fstream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
using namespace std;
#define mod 1000000007

int main()
{
	//freopen("test", "r", stdin);
	string s; cin >> s;
	int ret = 0;
	for (int i = 1; i < s.size(); ++i) {
		if (s[i] != s[i - 1]) {
			++ret;
		}
	}
	cout << ret << '\n';
	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;

int main( void ){
	ll A, B, K;
	cin >> A >> B >> K;
	if (A <= K){
		cout << 0 << " ";
		if (B+A-K <0)
			cout << 0 << endl;
		else
			cout << B+A-K << endl;
	}
	else
		cout << A-K << " " << B << endl;
}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N,K;cin >> N >> K;
    map<int,int> L;
    rep(i,N){
        int c;cin >> c;
        L[c]++;
    }
    int ans = 0;
    vector<int> tmp;
    int mapsize = L.size();
    if(mapsize > K){
        int lim = mapsize - K;
        for(auto itr = L.begin();itr != L.end();itr++){
            int value = (itr -> second);
            if(value)tmp.push_back(value);
        }
        sort(all(tmp));
        rep(i,lim){
            ans += tmp[i];
        }
        cout << ans << endl;
    }
    else {
        cout << 0 << endl;
    }

}


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

int main() {
	int N, K, X, Y;
	cin >> N >> K >> X >> Y;

	int sum = 0;
	for (int i = 0; i < N; i++) {
		if (i < K) {
			sum += X;
		}
		else {
			sum += Y;
		}
	}
	cout << sum << endl;
}


Measured memory_bytes: 256
package main

import (
	"fmt"
	"math"
)

func main() {
	S, T := scanStr(), scanStr()
	n := len(S)
	for i := 0; i < n; i++ {
		flag := true
		for j := 0; j < n; j++ {
			if S[j] != T[(i+j)%n] {
				flag = false
				break
			}
		}
		if flag {
			fmt.Println("Yes")
			return
		}
	}
	fmt.Println("No")
}

/*
	Snippets
*/
func scanInt() (n int) {
	fmt.Scan(&n)
	return
}
func scanInts(n int) []int {
	N := make([]int, n)
	for i := 0; i < n; i++ {
		N[i] = scanInt()
	}
	return N
}
func scanInts2(n int) ([]int, []int) {
	N1, N2 := make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		N1[i] = scanInt()
		N2[i] = scanInt()
	}
	return N1, N2
}
func scanInts3(n int) ([]int, []int, []int) {
	N1, N2, N3 := make([]int, n), make([]int, n), make([]int, n)
	for i := 0; i < n; i++ {
		N1[i] = scanInt()
		N2[i] = scanInt()
		N3[i] = scanInt()
	}
	return N1, N2, N3
}
func scanMatrix(n, m int) [][]int {
	M := make([][]int, n)
	for i := 0; i < n; i++ {
		M[i] = scanInts(m)
	}
	return M
}
func scanStr() (s string) {
	fmt.Scan(&s)
	return
}
func scanStrs(n int) []string {
	S := make([]string, n)
	for i := 0; i < n; i++ {
		S[i] = scanStr()
	}
	return S
}
func getAbs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func getPow(p, q int) int {
	return int(math.Pow(float64(p), float64(q)))
}
func getMin(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMin() requires at least one argument.")
	}
	min := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if min > nums[i] {
			min = nums[i]
			pos = i
		}
	}
	return min, pos
}
func getMax(nums ...int) (int, int) {
	if len(nums) == 0 {
		panic("funciton getMax() requires at least one argument.")
	}
	max := nums[0]
	pos := 0
	for i := 1; i < len(nums); i++ {
		if max < nums[i] {
			max = nums[i]
			pos = i
		}
	}
	return max, pos
}

/*
	Sort template
*/
type sortType struct {
	a int
	b int
}
type byA []sortType

func (s byA) Len() int {
	return len(s)
}
func (s byA) Swap(i, j int) {
	s[i], s[j] = s[j], s[i]
}
func (s byA) Less(i, j int) bool {
	return s[i].a < s[j].a
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
using namespace std;
int main()
{
ll l,r;
cin>>l>>r;
if(r-l>=2019)
{
cout<<0<<endl;
}
else
{
ll ans=2020;
for(ll i=l;i<=r;i++)
{
for(ll o=i+1;o<=r;o++)
{
ans=min(ans,((i%2019)*(o%2019))%2019);
}
}
cout<<ans<<endl;
}
}

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

const double s[5] = { 165.0, 170.0, 175.0, 180.0, 185.0 };

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

	vector <int> list(6,0);
	for ( int i = 0; i < n; i++ )
	{
		double h;
		cin >> h;

		int j;
		for ( j = 0; j < 5; j++ )
		{
			if ( h < s[j] )
				break;
		}

		list[j]++;
	}

	for ( int i = 0; i < 6; i++ )
	{
		cout << i+1 << ":";
		for ( int j = 0; j < list[i]; j++ )
			cout << '*';
		cout << endl;
	}

	return 0;
}

Measured memory_bytes: 0
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int a = scanner.nextInt(), b = scanner.nextInt(), k = scanner.nextInt();
			for (int i = Math.min(a, b); i >= 1; i--) {
				if ((0 == (a % i)) && (0 == (b % i))) {
					if (0 == --k) {
						System.out.println(i);
						break;
					}
				}
			}
		}
	}
}


Measured memory_bytes: 35652
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

template <typename T>
void print_vec(const vector<T>& v, bool is_reverse=false, int num=0){
  if(num == 0) num = (int)v.size();
  if(is_reverse) for(int i=num-1; i>=0; i--){ cout<<v[i]; if(i!=0) cout<<" ";}
  else for(int i=0; i<num; i++){ cout<<v[i]; if(i!=num-1) cout<<" ";}
  cout << endl;
}

template <typename T>
void print_pairvec(const vector<T> &v, int num=0){
  if(num == 0) num = (int)v.size();
  cout << endl;
  for(int i=0; i<num; i++){ cout << v[i].first << " " << v[i].second << endl;}
}


template <typename TYPE>
void print_vec2(const vector<vector<TYPE>>& v){
  cout << endl; cout << "       ";
  for(int i=0; i<v[0].size(); i++) cout << i << "   "; 
  cout << endl;
	for(int i=0; i<v.size(); i++){
		cout << "i=" << i << ":   ";
		for(int j=0; j<v[i].size(); j++){
			if(v[i][j] == 0) cout << "\x1B[0m" << v[i][j] << "   ";
      else cout << "\x1B[31m" << v[i][j] << "   ";//https://stackoverrun.com/ja/q/12618775
		}
		cout << "\x1B[0m" << endl;
	}
}


// int chmin(int &a, int b){ return a = min(a, b);}
int chmin(int &a, int b){ return a = min(a, b); }

int main(){
	int N;
	cin >> N;
	
	//解法1 6の倍数をi円  9の倍数をN-i円で分けて考えて
	// iを 6進数で　　　N-iを9進数で考える方法(解説見ました)
	int ans = N;
	for(int i=0; i<=N; i++){
		// cout << " ---------------------- i: " << i << endl;
		int num6 = i;

		int cnt = 0;
		int pow6 = pow(6, 6);// 6^7 = 20万を超える		
		while(num6 > 0){
			int num = num6 / pow6;
			num6 -= num* pow6;
			pow6 /= 6;
			cnt += num;
			// cout << "  pow6: " << pow6 << "  num6: " << num6 << "   num: " << num <<  "   cnt: " << cnt  << "   ans: " << ans  << endl;
		}

		int num9 = N-i;
		int pow9 = pow(9, 5); // 9^6 = 50万を超える
		while(pow9 > 0 ){
			int num = num9 / pow9;
			num9 -= num* pow9;
			pow9 /= 9;
			cnt += num;
			// cout << "  pow9: " << pow9 << "  num9: " << num9 << "   num: " << num <<  "   cnt: " << cnt << "   ans: " << ans  << endl;
		}
		ans = min(ans, cnt);
	}
	cout << ans << endl;


	//解法2 dp解法
	// vector<int> yen;
	// yen.push_back(1);
	// for(int i=1; i<=5; i++) yen.push_back(pow(9, i));
	// for(int i=1; i<=6; i++) yen.push_back(pow(6, i));
	// sort(yen.rbegin(), yen.rend());
	// 
	// // dp[i][j]: i-1番目のお札まで考慮した時に j円を作ることができる最小手数
	// const int INF = N;
	// vector<vector<int>> dp((int)yen.size()+2, vector<int>(N+1, INF+1));
	// dp[0][0] = 0;

	// for(int i=0; i<=(int)yen.size(); i++){
	// 	for(int j=0; j<=N; j++){
	// 		chmin(dp[i+1][j], dp[i][j]);// //yen[i]を使わない
	// 		if(j+yen[i] <= INF) chmin(dp[i+1][j+yen[i]], dp[i][j] + 1);// yen[i]を1回目使う
	// 		if(j+yen[i] <= INF) chmin(dp[i+1][j+yen[i]],dp[i+1][j] + 1);// yen[i]を2回目以上使う
	// 	}
	// }

	// // print_vec2(dp);
	// cout << dp[(int)yen.size()][N] << endl;

	
	return 0;
}



Measured memory_bytes: 3604
#include <iostream>
using namespace std;
#define MAX 1000000
typedef long long llong;
int n, k;
llong T[MAX];

int check(llong P) {
	int i = 0;
	for (int j = 0;j < k;j++) {
		llong s = 0;
		while (s + T[i] <= P) {
			s += T[i];
			i++;
			if (i == n)return n;
		}
	}
	return i;
}
int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n)right = mid;
		else left = mid;
	}
	return right;
}
int main()
{
	cin >> n >> k;
	for (int i = 0;i < n;i++)cin >> T[i];
	llong ans = solve();
	cout << ans << endl;
	return 0;
}



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

using namespace std;

void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

#define rep(i,n) for(int i=0; i<(int)(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

using ll = long long;
using P = pair<ll, ll>;

//constexpr ll mod = 998244353;
constexpr ll mod = 1e9+7;
const double PI = acos(-1.0);
mt19937_64 engine(chrono::steady_clock::now().time_since_epoch().count());

signed main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n; cin >> n;
  for(int i=1; i<10; i++) {
    for(int j=1; j<10; j++) {
      if (i*j==n) {
        cout << "Yes" << endl;
        return 0;
      }
    }
  }
  cout << "No" << endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String[] s = sc.next().split("");
		int[] n = new int[s.length];
		for(int i =0;i <s.length;i++) {
			n[i] = Integer.parseInt(s[i]);
		}
		boolean kurisageFlag = false;
		for(int i =0;i <n.length;i++) {
			if(i ==0) {
				continue;
			}
			if(kurisageFlag) {
				n[i] =9;
				continue;
			}

			if(n[i] <=7) {
				n[i-1]--;
				n[i] =9;
				kurisageFlag = true;
			}
		}
		long answer = 0;
		for(int ne:n) {
			answer+= ne;
		}
		System.out.println(answer);
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
#define maxs(x,y) x = max(x, y)
#define mins(x,y) x = min(x, y)
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int H, W, K;
    cin >> H >> W >> K;

    vector<vector<int>> ans(H, vector<int> (W));
    vector<string> cake(H);
    vector<int> nai(H);

    for(int i = 0; i < H; i++) {
        cin >> cake[i];
        for(int j = 0; j < W; j++) {
            ans[i][j] = -1;
            if (cake[i][j] == '#') {
                nai[i] ++;
            }
        }
    }

    int ind = 0;
    int fi = 1;

    for(int i = 0; i < H; i++) {
        if (fi && nai[i] == 0) continue;
        
        fi = 0;
        int st = 0;

        for(int j = 0; j < W; j++) {
            if (cake[i][j] == '#') {                
                for(int k = i; k < H; k++) {
                    if (k > i && nai[k]) break;
                    for (int l = st; l <= j; l++) {
                        ans[k][l] = ind;
                    }
                }
                ind ++;
                st = j+1;
            }
        }
        if (st) {
            for(int j = st; j < W; j++) {
                for(int k = i; k < H; k++) {
                    if (k > i && nai[k]) break;
                    ans[k][j] = ind-1;
                }
            }
        }
    }

    for(int i = H-1; i >= 0; i--) {
        for(int j = 0; j < W; j++) {
            if (ans[i][j] == -1) ans[i][j] = ans[i+1][j];
        }
    }

    for(int i = 0; i < H; i++) {
        for(int j = 0; j < W; j++) {
            if (j) cout << " ";
            cout << ans[i][j]+1;
        }
        cout << endl;
    }

    return 0;
}

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

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

#define sq(x)   (x)*(x)
#define PI      acos(-1.0)
#define all(x) x.begin(),x.end()
#define nl      '\n'

typedef long long int ll;
typedef unsigned long long int  llu;

int main()
{
    int a,b,c,k,x,y;
    cin>>a>>b>>c;
    cin>>k;
    while(k--)
    {
        if(b>a)
            break;
        else b=b*2;
    }
    x=k+1;
    //cout<<x<<nl;
    while(x--)
    {
        c*=2;
    }
    if(a<b && b<c)
        cout<<"Yes"<<nl;
    else cout<<"No"<<nl;
    return 0;
}



Measured memory_bytes: 3592
#pragma GCC target ("avx2")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize ("O3")
#include "bits/stdc++.h"
#include <unordered_set>
#include <unordered_map>
#include <random>
using namespace std;
typedef long long ll;
const ll MOD = 1'000'000'007LL; /*998'244'353LL;*/
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int (i)=0; (i)<(n); (i)++)
const int dx[4]={ 1,0,-1,0 };
const int dy[4]={ 0,1,0,-1 };

int N, K;
int A[100000]; ll B[100000];

ll solve(int k){
    ll ret = 0;
    rep(i, N){
        if((k|A[i]) == k) ret += B[i];
    }
    return ret;
}

signed main(){
    cin >> N >> K;
    rep(i, N) cin >> A[i] >> B[i];

    ll ans = solve(K);
    for(int i=29; i>=0; i--){
        if((K>>i)&1){
            ans = max(ans, solve( (K-(1<<i)) | ((1<<i)-1) ));
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4776
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using System.Text.RegularExpressions;
using System.Diagnostics;
//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{
    class Solve
    {
        const int mod = 1000000007;
        static void Main(string[] args)
        {
            //var watch = new Stopwatch();
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);

            int N = int.Parse(Console.ReadLine());
            var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
            long suma = 0;
            long sumb = 0;
            for (var i = 0; i < N; i++)
            {
                a[i] -= i + 1;
            }
            if (N == 1)
            {
                Console.WriteLine(0);
                Console.Out.Flush();
                return;
            }
            Array.Sort(a);
            int m = a[N / 2];
            int mm = a[N / 2 + 1];
            for (var i = 0; i < N; i++)
            {
                suma += Math.Abs(a[i] - m);
                sumb += Math.Abs(a[i] - mm);
            }

            Console.WriteLine(Math.Min(suma, sumb));



            //watch.Start();



            Console.Out.Flush();
            /*watch.Stop();

            Console.WriteLine($"time:{watch.ElapsedMilliseconds} ms"); //Debug Only.
            Console.Out.Flush();*/
        }
    }



    public class Calculation
    {

    }

    public class Graph
    {

    }
}



Measured memory_bytes: 32988
h, w = map(int,input().split())
if h == 1 or w == 1:
    print(1)
else: 
    m, a = divmod(h, 4)
    n, b = divmod(w, 4)
    print(8*m*n + 2*a*n + 2*m*b + int((a*b+1)/2))

Measured memory_bytes: 2940
#include <iostream>
#include <vector>
#include <cstdio>
#include <algorithm>
using namespace std;

using ll = long long;

int main() {
  int N;
  cin >> N;
  int a[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      scanf("%d", a[i] + j);
    }
  }

  ll dist[N][N];
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      dist[i][j] = a[i][j];
    }
  }

  // ワーシャルフロイド
  for (int k = 0; k < N; k++) {
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
      }
    }
  }

  // 題意の道路の形状が存在するかどうか判定
  bool flag = true;
  for (int i = 0; i < N; i++) {
    for (int j = 0; j < N; j++) {
      if (dist[i][j] != a[i][j]) flag = false;
    }
  }

  // グラフ内の三角形全てにおいて、辺を消しても最短距離が変わらない箇所があればグラフから消す
  ll ans = -1;
  if (flag) {
    bool need[N][N];
    fill(need[0], need[N-1], true);
    for (int i = 0; i < N; i++) {
      for (int j = 0; j < N; j++) {
        for (int k = 0; k < N; k++) {
          if (k == i || k == j || i == j) continue;
          if (dist[i][j] == dist[i][k] + dist[k][j]) {
            need[i][j] = false;
          }
        }
      }
    }

    ans = 0;
    for (int i = 0; i < N; i++) {
      for (int j = i; j < N; j++) {
        if (!need[i][j]) continue;
        ans += dist[i][j];
      }
    }
  }

  // 解答
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define pb push_back
#define F first
#define S second
#define all(x) x.begin(), x.end()
using namespace std;
const int maxn = 1000005;
const int mod = 998244353;
vector<int>tar;
int cnt[40][2];
ll dp[40][2];
ll dfs(int pos, int lim) {
    if (pos == -1) return 0;
    if (~dp[pos][lim]) return dp[pos][lim];
    int ub = lim ? tar[pos] : 1;
    ll mx = 0;
    for (int i = 0 ; i <= ub ; i++) {
        mx = max(mx, cnt[pos][i^1] * (1LL<<pos) + dfs(pos-1,lim && (i==ub)));
    }
    return dp[pos][lim] = mx;
}
int main(){
    //cout << (1LL<<40) << endl;
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    ll n, k;
    cin >> n >> k;
    vector<ll>v;
    f (n) {
        ll x;
        cin >> x;
        v.pb(x);
    }
    tar.resize(40);
    for (int i = 0 ; i < 40 ; i++) {
        tar[i] = k % 2;
        k /= 2;
    }
    for (int i = 39 ; i >= 0 ; i--) {
        for (auto &j : v) {
            if (j & (1LL<<i)) {
                cnt[i][1]++;
            }
            else {
                cnt[i][0]++;
            }
        }
    }
    memset(dp, -1, sizeof(dp));
    cout << dfs(39,1) << '\n';
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
using namespace std;
/* typedef */
typedef long long ll;
typedef pair<int, int> pii;
/* constant */
const int INF = 1 << 30;
const ll LINF = 1LL << 50;
const int NIL = -1;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */
/* function */
/* main */
int main(){
    int N, M, X;
    cin >> N >> M >> X;
    vector<int> book(20);
    vector<vector<int> > algo(20, vector<int>(20));
    int a, b;
    for (int i = 0; i < N; i++) {
        cin >> book[i];
        for (int j = 0; j < M; j++)
            cin >> algo[i][j];
    }

    int upper = 1 << N;
    int ans = INF;
    for (int b = 1; b < upper; b++) {
        vector<int> cnt(20);
        int tmp = 0;
        for (int i = 0; i < N; i++) {
            if (b >> i & 1) {
                tmp += book[i];
                for (int j = 0; j < M; j++) { cnt[j] += algo[i][j]; }
            }
        }
        bool can = true;
        for (int i = 0; i < M; i++) {
            if (cnt[i] < X) can = false;
        }
        if (can) ans = min(ans, tmp);
    }
    if (ans == INF) cout << -1 << '\n';
    else cout << ans << '\n';
}


Measured memory_bytes: 3632
n = int(input())
cnt = 0
ans = []
for i in range(n):
    a,b = map(int,input().split())
    if a == b:
        cnt += 1
    else:
        cnt = 0
    ans.append(cnt)

if max(ans) >= 3:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9168
<?php
$n = (int)fgets(STDIN);
dfs("", 0, $n);

function dfs($str, $mx) {
    global $n;
    if (strlen($str) == $n) {
        print $str . "\n";
        return;
    }

    for ($i = 0; $i <= $mx; $i++) {
        dfs($str . chr(97 + $i), ($i == $mx) ? $mx + 1 : $mx);
    }
}

Measured memory_bytes: 4852
#include <bits/stdc++.h> 
 
#define INF (1<<31)//INT_MAX/2
#define MOD 1000000007
 
using ll  = long long;
using ull = unsigned long long;
 
int main(int argc, char *argv[])
{
    std::string s;
    std::cin >> s;

    std::string a, b, c, d;
    a = s[0];
    b = s[1];
    c = s[2];
    d = s[3];

    int A = std::stoi(a);
    int B = std::stoi(b);
    int C = std::stoi(c);
    int D = std::stoi(d);
    
    if (A+B+C+D == 7) {
        std::cout << A << "+" << B << "+" << C << "+" << D << "=7" << std::endl;
    } else if (A+B+C-D == 7) {
        std::cout << A << "+" << B << "+" << C << "-" << D << "=7" << std::endl;
    } else if (A+B-C+D == 7) {
        std::cout << A << "+" << B << "-" << C << "+" << D << "=7" << std::endl;
    } else if (A+B-C-D == 7) {
        std::cout << A << "+" << B << "-" << C << "-" << D << "=7" << std::endl;
    } else if (A-B+C+D == 7) {
        std::cout << A << "-" << B << "+" << C << "+" << D << "=7" << std::endl;
    } else if (A-B+C-D == 7) {
        std::cout << A << "-" << B << "+" << C << "-" << D << "=7" << std::endl;
    } else if (A-B-C+D == 7) {
        std::cout << A << "-" << B << "-" << C << "+" << D << "=7" << std::endl;
    } else if (A-B-C-D == 7) {
        std::cout << A << "-" << B << "-" << C << "-" << D << "=7" << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
n = int(input())
a = [int(item) for item in input().split()]

suma = 0 
for item in a:
    suma += abs(item)

min_id = -1; min_val = 10**5
max_id = -1; max_val = -10**5
plus_id = -1
minus_id = -1
zero_id = -1

for i, item in enumerate(a):
    if min_val > item:
        min_val = item
        min_id = i
    if max_val < item:
        max_val = item
        max_id = i
    if item == 0:
        zero_id = i
    elif item > 0:
        plus_id = i
    elif item < 0:
        minus_id = i
# All plus
if minus_id == -1:
    print(suma - 2 * min_val)
    val = min_val
    not_initialized = True
    for i, item in enumerate(a):
        if item == min_val and not_initialized:
            not_initialized = False
            continue
        if i == len(a) - 1 - not_initialized:
            print(item, val)
            continue
        print(val, item)
        val -= item
# All minus
elif plus_id == -1:
    print(suma - 2 * abs(max_val))
    val = max_val
    not_initialized = True
    for i, item in enumerate(a):
        if item == max_val and not_initialized:
            not_initialized = False
            continue
        print(val, item)
        val -= item
# both of tem
elif plus_id != -1 and minus_id != -1:
    print(suma)
    not_initialized_min = True
    not_initialized_max = True
    minv = min_val
    maxv = max_val
    for i, item in enumerate(a):
        if item == min_val and not_initialized_min:
            not_initialized_min = False
            continue
        if item == max_val and not_initialized_max:
            not_initialized_max = False
            continue
        if item <= 0:
            print(maxv, item)
            maxv -= item
        elif item > 0:
            print(minv, item)
            minv -= item
    print(maxv, minv)
else:
    print(0)
    for i in range(n-1):
        print(0, 0)

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

using namespace std;
using ll = long long;


int main()
{
    ll n;
    cin >> n;
    vector<vector<ll>> cnt(10, vector<ll>(10)); //先頭がiで末尾がjの整数の個数

    for(ll i = 1; i <= n; i++){
        string s = to_string(i);
        cnt[s.front() - '0'][s.back() - '0']++;
    }


    ll ans = 0;
    for(ll i = 1; i < 10; i++){
        for(ll j = 1; j < 10; j++){

            ans += cnt[i][j] * cnt[j][i];


        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var mod=998244353;

console.log(main());
function main(){
  var n = o.a();
  var s = o.a(1);
  var ans = 1;
  var n3 = n*3;
  var r = 0, g = 0, b = 0, rg = 0, rb = 0, gb = 0;
  for(var i = 0; i < n3; i++){
    if(s[i] === "R"){
      if(gb)ans = ans * gb-- % mod;
      else if(g)ans = ans * g-- % mod, rg++;
      else if(b)ans = ans * b-- % mod, rb++;
      else r++;
    }else if(s[i] === "G"){
      if(rb)ans = ans * rb-- % mod;
      else if(r)ans = ans * r-- % mod, rg++;
      else if(b)ans = ans * b-- % mod, gb++;
      else g++;
    }else{
      if(rg)ans = ans * rg-- % mod;
      else if(g)ans = ans * g-- % mod, gb++;
      else if(r)ans = ans * r-- % mod, rb++;
      else b++;
    }
  }
  for(i = 2; i <= n; i++)ans = ans * i % mod;
  return ans;
}

Measured memory_bytes: 10316
#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;

ll gcd(ll a, ll b);
ll lcm(ll a, ll b);

int main() {

    ll N, M, tmp;
    string S, T, tmpS;

    cin >> N >> M >> S >> T;

    if (M > N) {
        tmpS = T;
        T = S;
        S = tmpS;
    }

    tmp = min(N, M);
    N = max(N, M);
    M = tmp;

    ll x, y;
    x = gcd(N, M);
    y = lcm(N, M);

    for (int i = 0; i < x; i++) {
        if (S[i * N / x] != T[i * M / x]) {
            cout << -1 << endl;
            return 0;
        }
    }

    cout << y;

    return 0;
}

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

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

Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define cans cout << ans << endl;
#define cyes cout << "Yes" << endl; 
#define cno cout << "No" << endl; 
typedef long long ll;


int main(){
    int n;
    cin >> n;
    vector<int> a(n+1);
    a[0] = 1e9;
    int ans = 0;
    for(int i=1; i<n; i++){
        cin >> a[i];
        ans += min(a[i-1],a[i]);
    }
    ans += a[n-1];
    cans;
    return 0;
}

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

int main(){
	string s;
	int ans = 0;
	while(cin >> s){
		//if(s == "fuck")break;
		int i = 0, size = s.size()/2;
		for(i;i < size && s[i] == s[s.size()-i-1];i++);
		if(i == size)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3032
#include<stdio.h>

int main(void)
{

	//3つの文節の長さABC
	int A, B, C;
	int count5 = 0;
	int count7 = 0;

	//長さを入力
	scanf("%d %d %d", &A, &B, &C);

	//並べ替えて575になるか検証
	if (A == 5) {
		count5++;
	}
	else if (A == 7) {
		count7++;
	}

	if (B == 5) {
		count5++;
	}
	else if (B == 7) {
		count7++;
	}

	if (C == 5) {
		count5++;
	}
	else if (C == 7) {
		count7++;
	}

	//結果を表示
	if (count5 == 2 && count7 == 1) {
		printf("YES \n");
	}
	else {
		printf("NO \n");
	}

	return 0;

}

Measured memory_bytes: 128
#include<stdio.h>
#define N 100
#define W 0
#define G 1
#define B 2

int n,M[N][N];
int color[N],d[N],f[N],t;

void dfs_visit(int u){
    int v;
    color[u] = G;
    d[u] = ++t;
    for(v = 0;v < n;v++){
        if(M[u][v]==0) continue;
        if(color[v] == W){
            dfs_visit(v);
        }
    }
    color[u] = B;
    f[u] = ++t;
}

int main(){
    int u,v,k;
    int i,j;

    scanf("%d",&n);
    for(i=0;i<n;i++){
        for(j=0;j<n;j++) M[i][j]=0;
    }

    for(i=0;i<n;i++){
        scanf("%d %d",&u,&k);
        u--;
        for(j=0;j<k;j++){
            scanf("%d",&v);
            v--;
            M[u][v] = 1;

        }
    }
    for(u=0;u<n;u++){
        color[u] = W;
    }
     t = 0;
     for(u=0;u<n;u++){
         if(color[u] == W) dfs_visit(u);
     }   
     for(u=0;u<n;u++){
        printf("%d %d %d\n",u+1,d[u],f[u]);
     }
    return 0;
}


Measured memory_bytes: 2048
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        for(int i = 0; i <= n; i++){
            if((int)Math.floor(i * 1.08) == n){
                System.out.println(i);
                return;
            }
        }
        System.out.println(":(");
    }
}


Measured memory_bytes: 23252
from collections import deque



H,W = map(int, input().split())
S = [input() for _ in range(H)]

ans = 0
dyx = [(1,0), (0,1),(-1,0), (0,-1)]
for i in range(H):
    for j in range(W):
        if S[i][j] == '#': continue
        dist = [[0 for _ in range(W)] for _ in range(H)] 
        visited = [[False for _ in range(W)] for _ in range(H)]
        visited[i][j] = True
        q = deque()
        q.append((i,j))
        while q:
            y,x = q.popleft()
            for dy,dx in dyx:
                ny, nx = y+dy, x+dx
                if not 0 <= nx < W: continue
                if not 0 <= ny < H: continue
                if visited[ny][nx]: continue
                if S[ny][nx] == '#': continue
                visited[ny][nx] = True
                dist[ny][nx] = dist[y][x] + 1
                q.append((ny, nx))
                #dist[ny][nx] = dist[y][x] + 1
                #visited[ny][nx] = True

        
        for p in range(H):
            ans = max(ans, max(dist[p]))
        
        #ans = max(ans, max(max(row) for row in dist))

            

print(ans)

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

using namespace std;

#define endl '\n'

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

  string s, t;
  cin >> s >> t;
  int n = s.length(), m = t.length();
  int dp[n + 1][m + 1];
  for (int i = 0; i <= n; i++)
    dp[i][0] = 0;
  for (int i = 1; i <= m; i++)
    dp[0][i] = 0;
  for (int i = 1; i <= n; i++) {
    for (int j = 1; j <= m; j++) {
      if (s[i - 1] == t[j - 1]) dp[i][j] = dp[i - 1][j - 1] + 1;
      else dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  vector<char> lcs(dp[n][m]);
  int i = n, j = m, idx = dp[n][m];
  while (i > 0 && j > 0) {
    if (s[i - 1] == t[j - 1]) {
      lcs[idx - 1] = s[i - 1];
      i--; j--; idx--;
    } else if (dp[i - 1][j] > dp[i][j - 1]) i--;
    else j--;
  }
  for (int i = 0; i < dp[n][m]; i++)
    cout << lcs[i];
  cout << endl;

	return 0;
}


Measured memory_bytes: 38708
#include<stdio.h>

int main(void)
{
  int n,d,x;
  scanf("%d%d%d",&n,&d,&x);

  int count = 0;
  int a=0;
  int b=0;
  for(int i=0; i<n; i++){
    scanf("%d",&a);
    for(int j=1; j<=d; j = 1+b*a){
      count ++;
      b++;
    }
   //   printf("%d\n",count);
    b=0;
  }

  printf("%d",count+x);

    return 0;

}



Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using P = pair<int, int>;
using ll = long long;
 
int main(){
	int n, k, q;
  	cin >> n >> k >> q;
  	vector<int> a(n);
  	rep(i, q){
      	int res;
      	cin >> res;
      	res--;
 		a[res]++;
    }
  	
  	rep(i, n){
      	if(k-q+a[i] > 0) puts("Yes");
  		else puts("No");
   	}
}

Measured memory_bytes: 3708
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
#define era(t) t.erase(unique(be(t)),t.end())
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;
typedef long long ll;
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    cin>>a>>b>>c;
    if(a*c>b){
        cout <<b/a<<endl;
    }
    else{
        cout <<c<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <cassert>
#include <cmath>
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <functional>
#include <tuple>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <set>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
#define FOR(x,xs) for(auto &x: xs)

using namespace std;
typedef long long ll;
typedef pair<int,int> PI;
typedef pair<ll,ll> PL;
typedef vector<int> VI;
typedef vector<ll> VL;

int main() {
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  vector<bool> s(N+1, false);
  vector<bool> e(N+1, false);
  REP(i,0,M) {
    int a, b;
    cin >> a >> b;
    if(a == 1) {
      s[b] = true;
    } else if(a == N) {
      e[b] = true;
    }
    if(b == 1) {
      s[a] = true;
    } else if(b == N) {
      e[a] = true;
    }
  }
  bool ans = false;
  REP(i,2,N) {
    if(s[i] && e[i]) {
      ans = true;
      break;
    }
  }
  cout << (ans ? "POSSIBLE" : "IMPOSSIBLE") << endl;
  return 0;
}


Measured memory_bytes: 256
program main
implicit none
integer :: n
integer , allocatable :: l(:)

read(*,*) n
allocate(l(n))
read(*,*) l
call bubble(n,l)
if(l(n) < sum(l(1:n-1)) )then
   write(*,'(a3)') 'Yes'
else
   write(*,'(a2)') 'No'
end if

stop
contains
  subroutine bubble(n,array)
    implicit none
    integer , intent(in) :: n
    integer , intent(inout) :: array(n)
    integer :: i, j
    integer :: t

    do i = 1, n-1
       do j = i+1 , n
          if(array(i).gt.array(j))then
             t = array(i)
             array(i) = array(j)
             array(j) = t
          end if
       end do
    end do
  end subroutine bubble



end program main


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"log"
	"os"
	"strconv"
)

func main() {
	log.SetFlags(log.Lshortfile)
	n := nextInt()
	m := nextInt()
	ans := 1
	for i := 1; i*i <= m; i++ {
		if m%i == 0 {
			if m/i >= n {
				ans = max(ans, i)
			}
			if i >= n {
				ans = max(ans, m/i)
			}
		}
	}
	fmt.Println(ans)
}

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}
func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}
func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}
func sum(a []int) (r int) {
	for i := range a {
		r += a[i]
	}
	return r
}
func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}
func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

type Pair struct {
	a, b int
}

type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	return p[i].b < p[j].b
}

var nextReader func() string

func init() {
	nextReader = NewScanner()
}

func NewScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}


Measured memory_bytes: 640
#include<math.h>
#include<iostream>
#include <algorithm>
#include <string>
#include<vector>
#include <array>
#include<tuple>
#include<queue>
#include<stack>
#include<iomanip>
#include<bitset>
//AtCoderC++.cpp

using namespace std;


int main() {
	int N, K; cin >> N >> K;
	long long answer = K;
	cout << answer * (long long)pow(K - 1, N - 1) << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void) {
	int m, f, r, n = 0;
	char grade;
	while (1) {
		scanf("%d %d %d", &m, &f, &r);
		n++;

		if (m == -1 && f == -1 && r == -1) break;

		if (m == -1 || f == -1)grade = 'F';

		else if (m + f >= 80) grade = 'A';

		else if(m+f>=65)grade = 'B';

		else if (m + f >= 50)grade = 'C';

		else if (m + f >= 30) {
			if(r>=50)grade = 'C';
			else grade = 'D';
		}

		else if (m + f < 30)grade = 'F';

		if (m + f >= 30 && r >= 50)grade = 'C';

		printf("%c\n", grade);
	}

	

	return 0;
}


Measured memory_bytes: 2752
#include <bits/stdc++.h>
using namespace std;
                     
#define int             long long
#define ld              long double
#define mp              make_pair
#define ff              first
#define ss              second
#define pb              push_back
#define fo(i,n)         for(i=0;i<n;i++)
#define fo1(i,n)        for(i=1;i<=n;i++)
#define FO(i,a,b)       for(i=a;i<=b;i++)
#define FOR(i,a,b)      for(i=a;i>=b;i--)
#define all(c)          c.begin(),c.end()
#define rall(c)         c.rbegin(),c.rend()
#define si              set<int>
#define vi              vector<int>
#define mii             map<int,int>
#define pii             pair<int,int>
#define vpii            vector<pii>
#define vvi             vector<vi>
#define usi             unordered_set<int>
#define umii            unordered_map<int,int>
#define pqmx            priority_queue<int>
#define pqmn            priority_queue<int,vi,greater<int> >
#define sp(x)           cout<<setprecision(x)<<fixed;
#define setbits(x)      __builtin_popcountll(x)
#define zerobits(x)     __builtin_ctzll(x)
#define in(a,n)         vi a(n);fo(i,n)cin>>a[i];
#define in1(a,n)        vi a(n+1);fo1(i,n)cin>>a[i];
#define w(t)            int t;cin>>t;while(t--)
#define sz(v)           (int)v.size()
#define gcd             __gcd
#define lcm(x,y)        x*(y/gcd(x,y))
#define endl            '\n'
#define PI              3.14159265358979323846
const int inf =         1e18;
const int mod =         1e9+7;
void __p(int x) {cout<<x;}
void __p(int32_t x){cout<<x;}
void __p(float x){cout<<x;}
void __p(double x){cout<<x;}
void __p(ld x) {cout<<x;}
void __p(char x){cout <<'\''<<x<<'\'';}
void __p(const char *x){cout <<'\"' <<x<<'\"';}
void __p(const string &x) {cout<<'\"'<<x<<'\"';}
void __p(bool x) {cout<<(x?"true":"false");}
void _p() {cout << "]\n";}
template<typename T,typename V>     void __p(const pair<T,V> &x) {cout<<'{';__p(x.first);cout<<',';__p(x.second);cout<<'}';}
template<typename T>                void __p(const T &x) {int f = 0; cout << '{'; for (auto &i: x) cout << (f++ ? "," : ""), __p(i); cout << "}";}
template <typename T,typename... V> void _p(T t, V... v) {__p(t);if(sizeof...(v))cout<<", ";_p(v...);}
int po(int x,int p) {int ans=1;x%=mod;while(p>0){if(p&1)ans=(ans*x)%mod;p=p>>1;x=(x*x)%mod;}return ans;}
int inv(int x){return po(x,mod-2)%mod;}
#ifndef ONLINE_JUDGE
#define dbg(x...) cout<<"["<<#x<<"]=[";_p(x)
#else 
#define dbg(x...)
#endif
//=================================================================================




int n,m,k,x,y,z,a,b,c,d,i,j,l,r,f,q;








void sol()
{   
    cin>>n;
    in(a,n);
    int i = 0, buy, sell, profit = 0,N=n-1;
    int value=1000,c=0;
        while (i < N) {
            while (i < N && a[i + 1] <= a[i]) i++;
            buy = a[i];
            c=value/a[i];
            value-=c*a[i];
            while (i < N && a[i + 1] > a[i]) i++;
            sell = a[i];

            value += c*sell;
        }
        
        cout<<value<<endl;
    
}





int32_t main()
{   
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    //pre();
    //sp(10);
    // w(t)
    sol();
    return 0;
}

Measured memory_bytes: 3652
def main():
    while True:
        H, W = tuple(map(int, input().split()))

        if (H, W) == (0, 0):
            break
        elif H == 0 or W == 0:
            pass
        else:
            for i in range(H):
                print("#"*W)
        print()

if __name__ == '__main__':
    main()



Measured memory_bytes: 5616