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

using namespace std;

#define DEBUG(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define fst first
#define snd second
#define SZ(u) ((int) (u).size())
#define ALL(u) (u).begin(), (u).end()

inline void proc_status()
{
    ifstream t("/proc/self/status");
    cerr << string(istreambuf_iterator<char>(t), istreambuf_iterator<char>()) << endl;
}

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }
template<typename T> inline T read()
{
	register T sum = 0, fg = 1;
	register char ch(getchar());
	for(; !isdigit(ch); ch = getchar()) if(ch == '-') fg = -1;
	for(;  isdigit(ch); ch = getchar()) sum = (sum << 3) + (sum << 1) - '0' + ch;
	return sum * fg;
}

typedef long long LL;
typedef pair<int, int> pii;

const int MAXN = (int) 1e5;

int n, m;

LL b[MAXN + 5];

inline void input()
{
	n = read<int>(), m = read<int>();
	b[0] = 0;
	for(int i = 1; i <= m; ++i) b[i] = read<LL>();
}

namespace SEGT
{
	const int MAX_NODE = MAXN << 2;

	LL mn[MAX_NODE + 5];

	inline void push_up(int u) { mn[u] = min(mn[u << 1], mn[u << 1 | 1]); }

	inline void build(int u, int l, int r)
	{
		if(l == r)
		{
			mn[u] = b[l];
			return;
		}

		int mid = (l + r) >> 1;
		build(u << 1, l, mid);
		build(u << 1 | 1, mid + 1, r);
		push_up(u);
	}

	inline pair<LL, int> query(int u, int l, int r, int rlim, LL val)
	{
		if(l == r) return mp(mn[u], l);

		int mid = (l + r) >> 1;
		if(rlim >= mid + 1 && mn[u << 1 | 1] <= val)
		{
			pair<LL, int> res = query(u << 1 | 1, mid + 1, r, rlim, val);
			if(res.fst < val) return res;
		}
		return query(u << 1, l, mid, rlim, val);
	}
}

LL cnt[MAXN + 5], cnt_pre[MAXN + 5];

inline void calc_cnt(int p)
{
	LL len = b[p], cnt0 = cnt[p];
	while(len && cnt0)
	{
		int q = SEGT::query(1, 0, m, p - 1, len).snd;
		if(q == 0)
		{
			cnt[0] += cnt0 * (len / n), cnt_pre[len % n] += cnt0;
			return;
		}
		cnt[q] += cnt0 * (len / b[q]), len %= b[q];
		p = q;
	}
}

inline void solve()
{
	SEGT::build(1, 0, m);
	cnt[m] = 1;
	for(int i = m; i >= 1; --i) calc_cnt(i);

	for(int i = n - 1; i >= 1; --i) cnt_pre[i] += cnt_pre[i + 1];
	for(int i = 1; i <= n; ++i) printf("%lld\n", cnt_pre[i] + cnt[0]);
}

int main()
{
	input();
	solve();

	return 0;
}



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

//template
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(a);i>(b);i--)
#define ALL(v) (v).begin(),(v).end()
typedef long long int ll; typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename A,size_t N,typename T>void Fill(A(&array)[N],const T &val){fill((T*)array, (T*)(array+N), val);}
const int inf = INT_MAX / 2; const ll INF = LLONG_MAX / 2;
//template end



int main(){
    int n,m; scanf("%d%d",&n,&m);
    vector<int> g[1010];
    rep(i,0,m){
        int a,b; scanf("%d%d",&a,&b); a--; b--;
        g[a].push_back(b);
    }
    int mi=inf; vector<int> ans;
    rep(i,0,n){
        int used[1010]={};
        queue<int> q;
        for(int nxt:g[i]){
            used[nxt]=i; q.push(nxt);
        }
        bool f=0;
        while(q.size()){
            int v=q.front(); q.pop();
            if(v==i){
                f=1; break;
            }
            for(int nxt:g[v]){
                if(used[nxt])continue;
                used[nxt]=v; q.push(nxt);
            }
        }
        if(f){
            vector<int> sub;
            sub.push_back(i);
            int nxt=used[i];
            while(nxt!=i&&sub.size()<=n){
                sub.push_back(nxt); nxt=used[nxt];
            }
            if(chmin(mi,(int)sub.size()))ans=sub;
        }
    }
    if(ans.size()==0)printf("-1\n");
    else{
        printf("%d\n",ans.size());
        rep(i,0,ans.size())printf("%d\n",ans[i]+1);
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>

#define DIV 1000000007
using namespace std;
using ll = long long;

int main() {
	ll N, K;
	cin >> N >> K;

	ll ans = 0;
	if (K == 0) ans = N * N;
	else {
		for (ll b = K + 1; b <= N; b++) {
			ll q = (N - (b - 1)) / b;

			ans += (q + 1) * (b - 1 - (K - 1));
			if (N - (q + 1) * b - (K - 1) > 0)
				ans += N - (q + 1) * b - (K - 1);
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int a,b,t,r,s,y;
    scanf("%d %d",&a,&b);
    t=a-1;
    r=b-1;
    s=a+t;
    y=b+r;
    if(s>y){
        printf("%d",s);
    }
    else if(a==b)
        printf("%d",a+b);

else
    printf("%d",y);
    return 0;
}


Measured memory_bytes: 128
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n = ni()
f = [int("".join(ls()), 2) for _ in range(n)]      
p = [list(li()) for _ in range(n)]

def dfs(cur:int, depth:int):
    if depth == 10:
        if cur == 0:
            return -float("inf")
        else:
            profit = 0
            for i,fi in enumerate(f):
                both = 0
                
                for mask in range(10):
                    if cur&(1<<mask) and fi&(1<<mask):
                        both += 1
                
                profit += p[i][both]
                
            return profit
    
    else:
        return max(dfs(cur+(1<<depth), depth+1),
                   dfs(cur, depth+1))
        
print(dfs(0,0))

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

using namespace std;

int main() {
	int K, N;
	cin >> K >> N;
	int a[200000];
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}
	int ans = K;
	for (int i = 0; i < N; i++) {
		int tmp = i == 0 ? a[N - 1] - a[0] : K + a[i - 1] - a[i];
		if (ans > tmp)ans = tmp;
	}
	cout << ans << endl;
	return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const ll INF = 1e18;
const double PI = acos(-1.0);
const int T = 3e5 + 3;
int v[T];
ll b[T],s[T];

multiset<int> bag;

int main() {
    ios_base::sync_with_stdio(false);
    int n; cin >> n;
    ll tmp = 0;
    for(int i = 0; i < 3*n; i++) {
        cin >> v[i];
        tmp += v[i];
        bag.insert(v[i]);
        if(bag.size() > n) {
            ll at = *bag.begin();
            tmp -= at;
            bag.erase(bag.find(at));
        }
        b[i] = tmp;
    }

    tmp = 0;
    bag.clear();

    for(int i = 3*n-1; i >= 0; i--) {
        tmp += v[i];
        bag.insert(v[i]);
        if(bag.size() > n) {
            ll at = *bag.rbegin();
            tmp -= at;
            bag.erase(bag.find(at));
        }
        s[i] = tmp;
    }

    ll ans = -1e18;

    for(int i = n-1; i < 2*n; i++)
        ans = max(ans, b[i] - s[i+1]);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 10752
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    ll q, h, s, d;
    cin >> q >> h >> s >> d;
    ll n;
    cin >> n;
    ll ans = (n / 2) * min({8 * q, 4 * h, 2 * s, d});
    ans += (n % 2) * min({4 * q, 2 * h, s});
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios::sync_with_stdio(false);
    long long n,a=1,b,p,i,r=0,w=0,ans;
      cin>>n;
    char s[n];
    for(i=0;i<n;i++)
    {
        cin>>s[i];
        if(s[i]=='W')
            w++;
    }
    ans=w;

    for(i=n-1;i>=n-w;i--)
    {
        if(s[i]=='W')

        ans--;
    }
    cout<<ans<<'\n';
}


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

using namespace std;

int main(void) {
  int N; cin >> N;
  vector<int> A(N), B(N);

  for (int i = 0; i < N; i++) {
    cin >> A[i] >> B[i];
  }

  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  int min, max;

  if (N%2 != 0) {
    min = A[N/2];
    max = B[N/2];
  } else {
    min = A[N/2-1] + A[N/2];
    max = B[N/2-1] + B[N/2];
  }

  cout << max - min + 1 << endl;

  return 0;
}

Measured memory_bytes: 4836
def power_set(A, s):
	if len(A) == 0:
		return {s}
	else:
		return power_set(A[1:], s) | power_set(A[1:], s+A[0])

def main():
	n = int(input())
	A = input()
	#print(n)
	A = list(map(int, A.split()))
	q = int(input())
	m = input()
	ms = list(map(int, m.split()))
	powerset = power_set(A, 0)
	
	for m in ms:
		if m in powerset:
			print('yes')
		else:
			print('no')

if __name__ == '__main__':
	main()

Measured memory_bytes: 8120
#include <bits/stdc++.h>
using namespace std;
int main(void){
    int n,a,b,c;
    cin>>n;
    std::deque<int> A;
    std::deque<int> B;
    std::deque<int> C;
    for (int i=0;i<n;i++) {
        cin>>a;
        A.emplace_back(a);
    }
    for (int j=0;j<n;j++) {
        cin>>b;
        B.emplace_back(b);
    }
    for (int k=0;k<n-1;k++) {
        cin>>c;
        C.emplace_back(c);
    }
    int score=0;
    int last=1000;
    for (int l=0;l<n;l++) {
        score+=B[A[l]-1];
        //cout<<score<<endl;
        if (A[l]-1==last) {
            score+=C[last-1];
            //cout<<score<<endl;
        }
        last=A[l];
    }
    cout<<score<<endl;
}

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

using int64 = long long;
using uint64 = unsigned long long;

using namespace std;

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

    int n;
    cin >> n;

    vector<int64> as(n + 1);
    for (int i = 0; i < n + 1; i++) {
        cin >> as[i];
    }

    constexpr int64 INF = (1LL << 60);

    vector<int64> lb(n + 1, -INF), ub(n + 1, INF);
    lb[n] = max(lb[n], as[n]);
    ub[n] = min(ub[n], as[n]);
    for (int i = n - 1; i >= 0; i--) {
        lb[i] = as[i] + (lb[i + 1] + 1) / 2;
        ub[i] = min(ub[i], (ub[i + 1] + as[i]));
    }

    ub[0] = min(ub[0], 1LL);
    for (int i = 1; i < n + 1; i++) {
        ub[i] = min(ub[i], max(-1LL, 2 * (ub[i - 1] - as[i - 1])));
        if (lb[i] > ub[i]) {
            cout << -1 << endl;
            return 0;
        }
        // cerr << "i: " << i << " " << ub[i] << endl;
    }

    int64 ans = 0;
    for (int i = 0; i < n + 1; i++) {
        if (lb[i] > ub[i]) {
            cout << -1 << endl;
            return 0;
        }
        ans += ub[i];
    }
    cout << ans << endl;

    /*
    for (int i = 0; i < n + 1; i++) {
        cerr << "ub[" << i << "] " << ub[i] << endl;
    }
    for (int i = 0; i < n + 1; i++) {
        cerr << "lb[" << i << "] " << lb[i] << endl;
    }
    */

    return 0;
}



Measured memory_bytes: 5576
n=gets.to_i
s=gets.chomp
ew=[0]*n
n.times do |i|
  if s[i]=="W"
    ew[i+1]+=1 if i<n-1
  else
    if i>0
      ew[0]+=1
      ew[i]-=1
    end
  end
end
1.upto(n-1) do |i|
  ew[i]+=ew[i-1]
end
puts ew.min


Measured memory_bytes: 4868
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
#include<cmath>
#include<vector>
#include<list>
#include<memory>

using namespace std;

class UnionFind{
private:
  UnionFind *parent;
  int rank;
  //UnionFind *t_root;
public:
  UnionFind(){
    parent=this;
    rank=0;
  }
  UnionFind *root(UnionFind *x){
    if(x->parent == x){
      return x;
    }
    else{
      //return root(x->parent);
      x->parent=root(x->parent);
      return x->parent;
    }

    return 0;
  }
  int _union(UnionFind *x){
    UnionFind *rx=root(x);
    UnionFind *rt=root(this);

    if(rx->rank > rt->rank) rt->parent = rx;
    else if(rx->rank < rt->rank) rx->parent = rt;
    else if(rx != rt){
      rt->parent = rx;
      rx->rank+=1;
    }

    //rx->parent=rt;
    return 0;
  }
  int find(UnionFind *x){
    if(root(x) == root(this)){
      return 1;
    }
    else{
      return 0;
    }
  }
  void show_root(){
    cout << this->root(this) << endl;
  }
};

void show_v(vector< vector<int> > &v,int n);

int par[100001];
int rnk[100001];

void init(int);
int rt(int);
bool same(int,int);
void unite(int,int);

int main(void){

  int n,m;
  cin>>n;
  cin>>m;

  vector<int> p(n+1);
  vector<int> x(m);
  vector<int> y(m);
  /*
  vector< vector<int> > v(n,vector<int>(n,0));
  */
  int cnt=0;

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

  for(int i=0;i<m;i++){
    cin >> x[i];
    cin >> y[i];
  }

  //show_v(v,n);
  /*
  for(int i=0;i<m;i++){
    v[y[i]-1][x[i]-1] = 1;
  }
  */
  /*
  init(n);

  for(int i=0;i<m;i++){
    unite(x[i],y[i]);
    //unite(y[i]-1,x[i]-1);
  }

  for(int i=1;i<n+1;i++){
    if(i == p[i]){
      cnt++;
      continue;
    }
    else{
    }
  }
  cout << cnt << endl;
  */
  //show_v(v,n);
  ///*
  vector< UnionFind > graph(n+1);

  for(int i=0;i<m;i++){
    graph[y[i]]._union(&graph[x[i]]);
  }

  for(int i=1;i<n+1;i++){
    //graph[i].show_root();
  }

  for(int i=1;i<n+1;i++){
    cnt+=graph[i].find(&graph[p[i]]);
  }

  cout << cnt << endl;
  //*/
  //cout << "debug" << endl;

  //for(int i=1;i<n+1;i++) cout << par[i] << endl;

  return 0;
}

void show_v(vector< vector<int> > &v,int n){
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      cout << v[i][j] << " ";
    }
    cout << endl;
  }
  cout << endl;
}

void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rnk[i]=0;
  }
}
int rt(int x){

  return par[x]==x ? x : par[x]=rt(par[x]);
}
bool same(int x,int y){
  return rt(x) == rt(y);
}
void unite(int x,int y){
  int temp_x;
  int temp_y;
  temp_x=rt(x);
  temp_y=rt(y);

  if(temp_x==temp_y) return ;
  if(rnk[temp_x] < rnk[temp_y]){
    par[temp_x]=temp_y;
  }
  else{
    par[temp_y]=temp_x;
    if(rnk[temp_x] == rnk[temp_y]) rnk[temp_x]++;
  }
}


Measured memory_bytes: 2944
#include <iostream>
using namespace std;
int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if (A == B)
	{
		cout << C;
	}
	else if (A == C)
	{
		cout << B;
	}
	else if (B == C)
	{
		cout << A;
	}
	return 0;
}

Measured memory_bytes: 256
def main():
    N, K, *xn = map(int, open(0).read().split())
    ans = int(1e9 + 7)
    for xl, xr in zip(xn[:], xn[K - 1:]):
        t = min(ans, xr - xl + min(abs(xr), abs(xl)))
        ans = t if t < ans else ans
    print(ans)
    return


main()


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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> a(n),b(n,-1);
    for (int i = 1; i <= n; ++i) {
        cin>>a[i-1];
        if(i*2>n)b[i-1]=a[i-1];
    }
    for (int i = n; i >= 1; --i) {
        if(b[i-1]!=-1)continue;
        int cnt=a[i-1],bcnt=0;
        for (int j = i*2; j <= n; j+=i) {
            assert(b[j-1]!=-1);
            bcnt+=b[j-1];
        }
        if(abs(cnt-bcnt)%2==0)b[i-1]=0;
        else b[i-1]=1;
    }
    vector<int> ans;
    for (int i = 0; i < n; ++i) {
        if(b[i]==1)ans.emplace_back(i+1);
    }
    cout<<ans.size()<<endl;
    int c=0;
    for(auto i:ans){
        ++c;
        cout<<i;
        if(c<ans.size())cout<<" ";
    }
    cout<<endl;
    return 0;
}

Measured memory_bytes: 3064
#include <iostream>
#include <vector>
#include <cstdint>

using namespace std;
using ll = long long;

#define ALL(x) begin(x), end(x)
#define REP(i, n) for (size_t i = 0, i##_len = (n); i < i##_len; ++i)

template <std::uint_fast64_t Mod>
class ModInt {
  using u64 = std::uint_fast64_t;

 public:
  u64 val;

  constexpr ModInt(const u64 x = 0) noexcept : val(x % Mod) {}
  constexpr ModInt operator+(const ModInt rhs) const noexcept {
    return ModInt(*this) += rhs;
  }
  constexpr ModInt operator-(const ModInt rhs) const noexcept {
    return ModInt(*this) -= rhs;
  }
  constexpr ModInt operator*(const ModInt rhs) const noexcept {
    return ModInt(*this) *= rhs;
  }
  constexpr ModInt operator/(const ModInt rhs) const noexcept {
    return ModInt(*this) /= rhs;
  }
  constexpr ModInt &operator+=(const ModInt rhs) noexcept {
    val += rhs.val;
    if (val >= Mod) {
      val -= Mod;
    }
    return *this;
  }
  constexpr ModInt &operator-=(const ModInt rhs) noexcept {
    if (val < rhs.val) {
      val += Mod;
    }
    val -= rhs.val;
    return *this;
  }
  constexpr ModInt &operator*=(const ModInt rhs) noexcept {
    val = val * rhs.val % Mod;
    return *this;
  }
  constexpr ModInt &operator/=(ModInt rhs) noexcept {
    u64 exp = Mod - 2;
    while (exp) {
      if (exp % 2) {
        *this *= rhs;
      }
      rhs *= rhs;
      exp /= 2;
    }
    return *this;
  }
};

template <typename T>
T power(T x, int n) {
  T ans{1};
  while (n) {
    if (n % 2) ans *= x;
    x *= x;
    n >>= 1;
  }
  return ans;
}

const ll MOD = 998244353;

using mint = ModInt<MOD>;

void solve(ll N, ll M, ll K) {
  mint ans = 0;
  mint nck = 1;
  for (auto i = 0; i <= K; ++i) {
    ans += nck * power<mint>(M-1,N-i-1);
    nck *= N-1-i;
    nck /= i+1;
  }
  ans *= M;

  cout << ans.val << endl;
}

int main() {
  ll N;
  cin >> N;
  ll M;
  cin >> M;
  ll K;
  cin >> K;
  solve(N, M, K);
  return 0;
}


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

using namespace std;

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


  int n, q;
  cin >> n >> q;
  vector<vector<int> > vv(n);
  while(q--) {
    int op;
    cin >> op;
    if (op == 0) {
      int t, x;
      cin >> t >> x;
      vv[t].push_back(x);
    }
    else if (op == 1) {
      int t;
      cin >> t;
      for(auto it = vv[t].begin(); it != vv[t].end(); it++) {
        if (it != vv[t].begin()) {
          cout << " ";
        }
        cout << *it;
      }
      cout << endl;
    }
    else if (op == 2) {
      int t;
      cin >> t;
      vv[t].clear();
    }
  }
  return 0;
}



Measured memory_bytes: 5840
#include <iostream>

using namespace std;

int main() {
    int x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2;
    if (x1 == x2 && y2 - y1 > 0) cout << x1 - y2 + y1 << " " << y2 << " " << x1 - y2 + y1 << " " << y1;
    else if (x1 == x2 && y2 - y1 < 0) cout <<  x1 + y1 - y2 << " " << y2 << " " << x1 + y1 - y2 << " " << y1;
    else if (y1 == y2 && x1 - x2 > 0) cout << x2 << " " << y2 - x1 + x2 << " " << x1 << " " << y2 - x1 + x2;
    else if (y1 == y2 && x2 - x1 > 0) cout << x2 << " " << y1 + x2 - x1 << " " << x1 << " " << y1 + x2 - x1;
    else if (x2 > x1 && y2 > y1) cout << x2 - y2 + y1 << " " << y2 + x2 - x1 << " " << x1 - y2 + y1 << " " << y1 + x2 - x1;
    else if (x2 > x1 && y1 > y2) cout << x2 + y1 - y2 << " " << y2 + x2 - x1 << " " << x1 + y1 - y2 << " " << y1 + x2 - x1;
    else if (x2 < x1 && y2 > y1) cout << x2 - y2 + y1 << " " << y2 - x1 + x2 << " " << x1 - y2 + y1 << " " << y1 - x1 + x2;
    else cout << x2 + y1 - y2 << " " << y2 - x1 + x2 << " " << x1 + y1 - y2 << " " << y1 - x1 + x2;
    return 0;
}


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

const int INF = 500;
char maze[20][20];
int d[20][20];
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

typedef pair<int, int> P;

int bfs(int sx, int sy, int h, int w) {
  queue<P> que;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      d[i][j] = INF;
    }
  }
  que.push(P(sx, sy));
  d[sy][sx] = 0;
  while (que.size()) {
    P p = que.front(); que.pop();
    for (int i = 0; i < 4; i++) {
      int nx = p.first + dx[i], ny = p.second + dy[i];

      if (0 <= nx && nx < w && 0 <= ny && ny < h && maze[ny][nx] != '#' && d[ny][nx] == INF) {
        que.push(P(nx, ny));
        d[ny][nx] = d[p.second][p.first] + 1;
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      //cout << d[i][j] << " ";
      if (d[i][j] != INF) ans = max(ans, d[i][j]);
    }
    //cout << endl;
  }
  return ans;
}

void Main() {
  int h, w;
  cin >> h >> w;

  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> maze[i][j];
    }
  }
  int ans = 0;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (maze[i][j] != '#') ans = max(ans, bfs(j, i, h, w));
    }
  }
  cout << ans << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
long long a,b,c,d,s1,s2;
int main(){
	cin>>a>>b>>c>>d;
	a--;
	long long p=c*d/__gcd(c,d);
	s1=a-(a/c+a/d-a/p);
	s2=b-(b/c+b/d-b/p);
	cout<<s2-s1;
	return 0;
}

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

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    a[0] = 0; b[0] = 0;
    rep(i, n){
        int x; cin >> x;
        a[i+1] = a[i] + x;
    }
    rep(i, m){
        int x; cin >> x;
        b[i+1] = b[i] + x;
    }

    ll ans = 0;
    ll best = m;
    rep(i, n+1){
        if(a[i] > k) break;
        while(b[best] > k - a[i]) best--;
        ans = max(ans, i+best);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 6408
using System;
using System.Linq;
namespace AGC017A
{
    class Program
    {
        static void Main()
        {
            long[] a;
            long n, p;
            a = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            n = a[0];
            p = a[1];
            a = Console.ReadLine().Split(' ').Select(s => long.Parse(s)).ToArray();
            for (long i = 0; i < n; i++)
                a[i] %= 2;
            long even = a.Count(s => s == 0);
            long odd = n - even;
            Comb c = new Comb(odd);
            long ans = 0;
            for (int i = 0; i <= odd / 2; i++)
                ans += c.CalcComb(odd, 2 * i);
            ans *= (long)Math.Pow(2, even);
            if (p == 0)
                Console.WriteLine(ans);
            else
                Console.WriteLine((long)Math.Pow(2, n) - ans);
        }
    }
    class Comb
    {
        long[,] c;
        public Comb(long n)
        {
            c = new long[n + 1, n + 1];
            c[0, 0] = 1;
            for (int i = 1; i <= n; i++)
            {
                for (int j = 0; j <= n; j++)
                {
                    try { c[i, j] += c[i - 1, j - 1]; } catch { }
                    try { c[i, j] += c[i - 1, j]; } catch { }
                }
            }
        }
        public long CalcComb(long a, long b)
        {
            return c[a, b];
        }
    }
}

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

using namespace std;

#define int long long
#define x first
#define y second
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define forn(i,n) for(int i=0;i<(int)n;i++)
#define pb push_back
#define sz(a) (int)(a.size())

typedef long long ll;typedef vector<int> vi;
typedef pair<int,int> ii;typedef vector<ii> vii;
typedef vector<vi> vvi;

signed main(){
	IOS
	int n,a,b;cin>>n>>a>>b;
	vi v(n);forn(i,n) cin>>v[i];
	int l=1,r=INT_MAX;int ans=0;
	while(l<=r){
		int m=(l+r)/2;
		int req=0;
		for(int i:v){
			i-=m*b;
			if(i>0)
				req+=(i+(a-b-1))/(a-b);
		}
		if(req<=m){
			ans=m;
			r=m-1;
		}
		else
			l=m+1;
	}
	cout<<ans;
}

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

using namespace std;

using ll = long long;

int main() {

	int N;
	cin>>N;
	set<ll> A;
	ll x;
	for (int i = 0;i < N;++i) {
		cin>>x;
		A.insert(x);
	}

	if (A.size() < N) {
		cout<<"NO"<<endl;
	}
	else {
		cout<<"YES"<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 9600
//vec[i]の範囲外エラー表示
#define _GLIBCXX_DEBUG
//includeとusing
#include <bits/stdc++.h>
using namespace std;
//型名省略
template <class T>
using V = vector<T>;
template <class T>
using VV = V<V<T>>;
using ll = long long;
using st = string;
using vl = vector<long long>;
using vvl = vector<vector<long long>>;
using vc = vector<char>;
using vvc = vector<vector<char>>;
using vs = vector<string>;
using vb = vector<bool>;
using vvb = vector<vector<bool>>;
using pll = pair<ll, ll>;
using pcc = pair<char, char>;
//定数
const ll INF = 1e9;
const ll MOD = 1e9+7;
const vl dx = {1,0,-1,0,1,0,-1,0};
const vl dy = {0,1,0,-1,0,1,0,-1};
//マクロ
#define rep(i,n) for(ll i = 0; i < (ll) n; i++)
#define rrep(i,n) for(ll i = (ll) n - 1; i >= 0;i--)
#define REP(i,x,n) for(ll i = (ll) x; i < (ll) n; i++)
#define RREP(i,x,n) for(ll i = (ll) n - 1; i >= x; i--)
#define each(i,A) for(ll i: (vl) A)
#define all(A) A.begin(), A.end()
#define Size(A) ll(A.size())
//入力
template<typename T> T input() {T x; cin >> x; return x;}
//正誤判定
void Yes(bool ans){cout << (ans? "Yes" : "No") << endl;}
void YES(bool ans){cout << (ans? "YES" : "NO") << endl;}
//余り切り上げ
ll ceil(ll a,ll b) {return (a + b - 1) / b;}
//最大値・最小値
template <typename T> bool chmax(T &a, const T& b) {if(a < b) {a = b; return true;} return false;}
template <typename T> bool chmin(T &a, const T& b) {if(a > b) {a = b; return true;} return false;}
//最大公約数
ll gcd(ll a,ll b){if(a<b)swap(a,b); if(a%b==0)return b; return gcd(b,a%b);}
//最小公倍数
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}
//n乗の余り
ll modpow(ll x,ll n,ll mod){ll res=1;for(ll i=0;i<n;i++){res=res*x%mod;}return res;}
ll MODpow(ll x,ll n){ll res=1;for(ll i=0;i<n;i++){res=res*x%MOD;}return res;}


/*--------------------------------------------------------------------------*/

//main関数
int main() {
    ll k,x; cin >> k >> x;
    Yes(500 * k >= x);
}



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

int main() {
    int A, B, K;
    cin >> A >> B >> K;

    for (int i = 1; i <= K; i++) {
        if (i & 1) {
            if (A & 1) A--;
            B += A / 2;
            A /= 2;
        } else {
            if (B & 1) B--;
            A += B / 2;
            B /= 2;
        }
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 888
def resolve():
    N = int(input())
    A_list = [int(i) for i in input().split()]
    if 0 in A_list:
        print(0)
        return
    prod = 1
    for A in A_list:
        prod = prod * A
        if prod > (10**18):
            print(-1)
            return
    print(prod)

resolve()

Measured memory_bytes: 21532
#include <iostream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <numeric>

using namespace std;

#define ll long long
#define rep(cnt,a,n) for(ll cnt=a;cnt<n+a;cnt++) //aから始めてn回ループ
#define vector2(type,name,a,b) vector<vector<type>> name(a, vector<type>(b))
#define PI 3.141592653589793


int main()
{
    int a;
    int b;
    cin >> a;
    cin >> b;

    cout << a*b << endl;


    return 0;
}

Measured memory_bytes: 3592
import sys
input = sys.stdin.readline
N = int(input())
s = [0] * N
for i in range(N) :
    s[i] = int(input())
sum = 0
s.sort()
for i in range(N) :
    sum += s[i]
if sum % 10 != 0 :
    print(sum)
else :
    li = []
    for i in range(N) :
        if s[i] % 10 != 0 :
            li.append(s[i])
    li.sort()
    if len(li) == 0 :
        print(0)
    else :
        print(sum - li[0])

Measured memory_bytes: 3064
#include<stdio.h>
int main()
{
    int a,b,c,count=0;
    scanf("%d %d",&a,&b);
    for(c=1;c<=3;c++){
        if((a*b*c)%2==0)count++;
    }
    if(count==3){
        printf("No\n");
    }
    else{
        printf("Yes\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
int a[114514];
signed main(){
	int n,memo=0,cnt=0;
	cin>>n;
	rep(i,n)cin>>a[i];
	rep(i,n-1){
		if(a[i]>=a[i+1])cnt++;
		else {
			memo =max(memo,cnt);
			cnt=0;
		}
	}
	cout<<max(cnt,memo)<<endl;
}


Measured memory_bytes: 1024
N, X, Y = map(int, input().split())
ans_list = [0]*(N-1)

for i in range(1, N) : 
  for j in range(i+1, N+1) :
    ans = min(abs(j-i), abs(X-i)+abs(Y-j)+1)
    ans_list[ans-1] += 1

for ans_total in ans_list :
  print(ans_total)

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

#define PI 3.14159265359	

using namespace std;

int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = n - 1; i >= 0; i--) {
		cout << a[i];
		if (i != 0) cout << " ";
	}
	cout << endl;
}

Measured memory_bytes: 3092
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <queue>
#include <set>
#include <vector>
#include <cstring>

int main(){
  
  long long int A, B;
  scanf("%lld%lld", &A, &B);
  
  std::cout << (A+B-3)/(A-1) << std::endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(int argc, const char * argv[]) {
    
    int a;
    int b;
    
    scanf("%d %d", &a, &b);

    if (a>b) {
        printf("a > b\n");
    }
    if (a<b) {
        printf("a < b\n");
    }
    if (a==b) {
        printf("a == b\n");
    }
    return 0;
}


Measured memory_bytes: 2040
// Problem : A - Air Conditioner
// Contest : AtCoder - AtCoder Beginner Contest 174
// URL : https://atcoder.jp/contests/abc174/tasks/abc174_a
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define INF (int)1e9
#define EPS 1e-9
#define PI 3.1415926535897932384626433832795
#define all(a) a.begin(),a.end()
#define x first
#define y second
#define MOD 1000000007
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef double ld;

int main() {
    // your code goes here
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int x;
    cin >> x;
    if(x>=30)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}


Measured memory_bytes: 3616
#include<bits/stdc++.h>
#define fo(i,a,b)for(int i=a,_e=b;i<=_e;++i)
#define ll long long
using namespace std;
const int N=105,mo=998244353;
unordered_map<string,int>f;
string s;
string sub(string s,int l,int r){
	string t;fo(i,l,r)t=t+s[i];
	return t;
}
int get(string s){
	if(f.count(s))return f[s];
	int n=s.size(),su=(ll)get(sub(s,1,n-1))*(s[0]-'0'+1)%mo;
	fo(i,1,n/2){
		string a=sub(s,0,i-1);
		fo(j,2,n/i){
			fo(k,0,i-1)a[k]&=s[(j-1)*i+k];
			su=((ll)get(a)*get(sub(s,i*j,n-1))+su)%mo;
		}
	}
	return f[s]=su;
}
int main(){
	f[s]=1;f["1"]=2;f["0"]=1;
	cin>>s;
	cout<<get(s);
}

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

int main(){
  string s; cin>>s;
  int len = s.size();
  ll sum = 0;
  rep(bit, 1<<len-1){
    ll tmp = 0;
    rep(i, len-1){
      tmp *= 10;
      tmp += s[i]-'0';
      if (bit & (1<<i)){
        sum += tmp;
        tmp = 0;
      }
    }
    tmp *= 10;
    tmp += s[len-1] - '0';
    sum += tmp;
  }
  cout << sum << endl;
}

Measured memory_bytes: 3512
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rrep(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define ALL(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define INF9 1000000000 //10^9
#define MOD 1000000007 //10^9+7
#define fi first
#define sc second
using ll=long long;
using pii=pair<ll,ll>;
using vi=vector<int>;

int main() {
    int N;
    cin >> N;
    vector<pair<string,pii>> vec;
    rep(i,N) {
        string s; int p;
        cin >> s >> p;
        vec.pb(mp(s, mp(-p, i+1)));
    }
    sort(ALL(vec));
    rep(i,N) cout << vec.at(i).sc.sc << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <queue>
#include <vector>
#include <map>
#include <set>
#define MAXN 55
#define INF 0x3f3f3f3f
#define p 1000000007
#define rint register int
#define LL long long
#define LD long double
using namespace std;

int n, ans, f[MAXN][MAXN], mp[MAXN][MAXN], temp[MAXN][MAXN];
LL k;

void mul(int x[MAXN][MAXN], int y[MAXN][MAXN])
{
	memset(temp, 0, sizeof(temp));
	for(rint i=1; i<=n; ++i)
	{
		for(rint j=1; j<=n; ++j)
		{
			for(rint k=1; k<=n; ++k)
			{
				temp[i][j]=(temp[i][j]+1LL*x[i][k]*y[k][j]%p)%p;
			}
		}
	}
	memcpy(x, temp, sizeof(temp));
}

int main()
{
	scanf("%d%lld", &n, &k);
	for(rint i=1; i<=n; ++i)
		for(rint j=1; j<=n; ++j) scanf("%d", &mp[i][j]);
	for(rint i=1; i<=n; ++i) f[i][i]=1;
	while(k)
	{
		if(k&1) mul(f, mp);
		k>>=1; mul(mp, mp);
	}
	for(rint i=1; i<=n; ++i)
		for(rint j=1; j<=n; ++j)
			ans=(ans+f[i][j])%p;
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <vector>
#include <queue>
#include <stack>
#include <algorithm>
#include <sstream>
#include <istream>

using namespace std;

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

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

	double ans = 0.0;

	for(int i=1;i<=n;i++){
		double tmp = 1.0/n;
		int l = i;
		while(l<k){
			tmp /= 2;
			l *= 2; 
		}
		//cout << tmp << endl;
		ans += tmp;
	}

	printf("%.10f\n",ans);

	return 0;
}

Measured memory_bytes: 256
#169A
# A × B を整数として出力せよ。

#1. 入力を受け取ること
a, b = map(int, input().split())
#print(a, b)


#2. 受け取った入力値を使って、適切に計算すること
answer= a * b


#3.　計算した結果を出力すること
print(answer)


Measured memory_bytes: 9028
c = [list(map(int, input().split())) for i in range(3)]

for i in range(2):
    for j in range(2):
        if c[i][j] - c[i + 1][j] != c[i][j + 1] - c[i + 1][j + 1]:
            print("No")
            exit()
print("Yes")


Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define all(v) (v).begin(), (v).end()
typedef long long int lint;
using namespace std;

// 累積和
struct cumulative_sum {
    using lint = long long int;
    int sz;
    // data[i]:元の数列
    vector<lint> data;
    // cum[i]:[0,i)の和
    vector<lint> sum;
    // 要素数を指定して初期化
    cumulative_sum(const int _sz) : sz(_sz) {
        data.assign(sz, 0);
        sum.assign(sz + 1, 0);
    }
    lint& operator[](const int k) {
        return data[k];
    }
    // dataに基づいてsumを構築
    void build() {
        for (int i = 0; i < sz; i++) sum[i + 1] = sum[i] + data[i];
    }
    // [a,b)の和を求める
    lint query(const int a, const int b) {
        return sum[b] - sum[a];
    }
};

int main() {
    int n, k;
    cin >> n >> k;
    cumulative_sum a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        a[i]--;
    }
    a.build();
    for (int i = 0; i < a.sum.size(); i++) {
        a.sum[i] %= k;
    }
    auto s = a.sum;
    lint ans = 0;
    unordered_map<int, lint> count;
    //区間を[l,r)で管理
    int l = 0, r = 0;
    while (r + 1 <= n + 1) {
        r++;
        if (r - l > k) {
            count[s[l]]--;
            l++;
        }
        ans += count[s[r - 1]];
        count[s[r - 1]]++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 13256
n = int(input())
arr = list(map(int, input().split()))
def a(b):
    for i in b:
        if i % 2 == 0:
            if i % 3 != 0 and i % 5 != 0:
                return 'DENIED'
                
if a(arr)!='DENIED':
    print('APPROVED')
else:
    print('DENIED')



Measured memory_bytes: 2940
awk 'NR==1 {
  n = $1
}
NR==2 {
  for (i=1;i<=n;++i) a[i] = $i
}
NR==3 {
  for (i=1;i<=n;++i) ans += $i
}
NR==4 {
  for (i=1;i<n;++i) c[i] = $i
}
END {
  for (i=1;i<n;++i) if (a[i] + 1 == a[i + 1]) ans += c[a[i]];
  print ans
}'


Measured memory_bytes: 552
# include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
typedef long long ll;
int n,arr[100005],h;
ll ans;
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin>>h>>n;;
    for(int i=1;i<=n;i++){
        cin>>arr[i];
        ans+=arr[i];
    }
    if(ans>=h){
        cout<<"Yes"<<endl;
    }
    else cout<<"No"<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e10;
const int MOD = 1e9 + 7;
#define dump(x) cout << #x << " = " << (x) << endl;
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i <= (b); ++i)
#define pb push_back
#define all(v) (v).begin(), (v).end()
#define P pair<int, int>
#define V vector<int>
#define M map<int, int>
#define S set<int>
#define itn int
#define tin int
#define tni int
bool dbg = false;
int N, a[100010];
V v, c;
bool ans;
void solve()
{
    FOR(i, 0, N)
    {
        bool flag = true;
        FOR(j, 0, (int)v.size())
        {
            if (a[i] == v[j]) {
                c[j]++;
                flag = false;
                break;
            }
        }
        if (flag) {
            v.pb(a[i]);
            c.pb(1);
            if ((int)v.size() > 3) {
                ans = false;
                return;
            }
        }
    }
    int n = (int)v.size();
    /*
    dump(n);
    dump(c[0]);
    dump(v[0]);
    dump(c[1]);
    dump(v[1]);
    dump(c[2]);
    dump(v[2]);
    */
    if (n == 1) {
        if (v[0] == 0) {
            ans = true;
        } else {
            ans = false;
        }
    } else if (n == 2) {
        if ((v[0] == 0 && c[0] * 2 == c[1]) || (v[1] == 0 && c[1] * 2 == c[0])) {
            ans = true;
        } else {
            ans = false;
        }
    } else if (n == 3) {
        if (c[0] == c[1] && c[1] == c[2] && v[0] == (v[1] ^ v[2])) {
            ans = true;
        } else {
            ans = false;
        }
    } /*else if (n == 4 || n == 5) {
        ans = false;
    } else {
        int C = c[0];
        ans = false;
        if (C == c[1] && C == c[2] && C == c[3] && C == c[4] && C == c[5]) {
            FOR(i1, 1, 6)
            {

                FOR(i2, 1, 6)
                {

                    FOR(i3, 1, 6)
                    {

                        FOR(i4, 1, 6)
                        {
                            FOR(i5, 1, 6)
                            {
                                V x;
                                x.pb(i1);
                                x.pb(i2);
                                x.pb(i3);
                                x.pb(i4);
                                x.pb(i5);
                                sort(all(x));
                                bool flag = true;
                                FOR(i, 0, 5)
                                {
                                    if (x[i] != i + 1) {
                                        flag = false;
                                    }
                                }
                                if (flag) {
                                }
                            }
                        }
                    }
                }
            }
        }
    }*/
    return;
}

signed main()
{
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cin >> N;
    FOR(i, 0, N)
    {
        cin >> a[i];
    }
    solve();
    if (ans) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
using Int = long long;

int main() {
    int N, K;
    string S;
    cin >> N >> S >>K;
    char target = S[K-1];
    string answer = "";

    for(int i=0; i<S.size(); i++){
        if(S[i] != target){
            cout << '*';
        }else{
            cout << S[i];
        }
    }

    cout << endl;
    return 0;
}

Measured memory_bytes: 256
/*
        karmany evadhikaras te
        ma phalesu kadacana 
        ma karma-phala-hetur bhur
        ma re sango'stv akarmani (B.G.-2.47)
 
Translation:
        Lord Krsna to Arjuna.
You have a right to perform your prescribed duty, 
but you are not entitled to the fruits of action. 
Never consider yourself the cause of the results of your activities, 
and never be attached to not doing your duty.    
*/
#include <bits/stdc++.h>

using namespace std;
#define ll long long
#define int long long
const int N = 200005;
const ll mod = 2000000011;
#define ld long double
#define PI 3.14159265358979323846
const int INF = 10000000;

void flash()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout.setf(ios::fixed);
    cout.setf(ios::showpoint);
    cout.precision(2);
}

//3. Structure or classes
struct Value{
    int val = 1e9+7;
};
//3. Ends here

//1. Data structures declaration here
//1. Ends here

//2. Extra Functions here
//2. Ends here


void solve();
int32_t main()
{
    flash();
    int t;
    t = 1;
    //cin>>t;
    while(t--){
        solve();
        //cout<<"\n";
    }
    return 0;
}

void solve()
{
    int a,b,n;
    cin>>a>>b>>n;

    int maxh;

    if(n<b){
        maxh=n;
    }
    else maxh=b-1;

    cout<<((a*maxh)/b) - a *(maxh/b);

    return;

}
// how r u bro

Measured memory_bytes: 3624
#include<iostream>
#include<algorithm>
using namespace std;
int a[1100];
int main ()
{   int n,k;
   cin>>n>>k;
   for(int i=1;i<=n;i++)
     cin>>a[i];
    sort(a+1,a+n+1);
    int sum=0;
    for(int i=1;i<=k;i++)
     sum+=a[i];
     cout<<sum;
}

Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define dump(x) cout << #x << " = " << (x) << endl;
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define int long long

signed main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int H, W;
  cin >> H >> W;
  int ans = 1e9;
  // Aの縦幅
  FOR(h, 1, H) {
    vector<int> S1;
    vector<int> S2;
    S1.push_back(h * W);
    S2.push_back(h * W);
    int h1 = (H - h) / 2;
    int w1 = W / 2;
    S1.push_back(h1 * W);
    S1.push_back(((H - h) - h1) * W);
    S2.push_back((H - h) * w1);
    S2.push_back((H - h) * (W - w1));
    sort(all(S1));
    sort(all(S2));
    ans = min(ans, min(S1[2] - S1[0], S2[2] - S2[0]));
  }
  swap(H, W);
  FOR(h, 1, H) {
    vector<int> S1;
    vector<int> S2;
    S1.push_back(h * W);
    S2.push_back(h * W);
    int h1 = (H - h) / 2;
    int w1 = W / 2;
    S1.push_back(h1 * W);
    S1.push_back(((H - h) - h1) * W);
    S2.push_back((H - h) * w1);
    S2.push_back((H - h) * (W - w1));
    sort(all(S1));
    sort(all(S2));
    ans = min(ans, min(S1[2] - S1[0], S2[2] - S2[0]));
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
while True:
    box = [box for box in input().split()]
    box[0] = int(box[0])
    box[2] = int(box[2])
    if box[1] == '?':
        break
    elif box[1] == '+':
        print(box[0] + box[2])
    elif box[1] == '-':
        print(box[0] - box[2])
    elif box[1] == '*':
        print(box[0] * box[2])
    else:
        print(box[0] // box[2])


Measured memory_bytes: 5600
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include<math.h>
#define int long long
using namespace std;
const int INF = 10000000000000;//5000000000000000

signed main() {
	int N;
	cin >> N;
	int small, big = 0;
	for (int i = 1; i * i <= N; i++) {
		if (N % i == 0) {
			small = max(small, i);
			big = N / small;
		}
	}
	cout << big + small - 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <iterator>
#include <climits>
#include <unordered_map>
#include <queue>


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

using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;

inline int ctoi(char c) {
    return (int)(c -'0');
}

// ----------------------------------------------------------

int main() {
    ll n,m,x,y;
    cin >> n >> m >> x >> y;
    vector<ll> xx(n);
    vector<ll> yy(m);
    rep(i, n) {
        cin >> xx[i];
    }
    rep(i,m) {
        cin >> yy[i];
    }

    if (x >= y) {
        cout << "War" << endl;
        return 0;
    }

    sort(xx.begin(), xx.end());
    sort(yy.begin(), yy.end());
    for(int i=x+1; i<=y; ++i) {
        for (int j=xx[n-1]+1; j<=yy[0]; ++j) {
            if (i==j) {
                cout << "No War" << endl;
                return 0;
            }
        }
    }
    
    cout << "War" << endl;
    return 0;
}

Measured memory_bytes: 256
# coding: utf_8
""" abc085d """

import math

n, h = map(int, input().split())
katanaA = []
katanaB = []
for i in range(n):
    a, b = map(int, input().split())
    katanaA.append(a)
    katanaB.append(b)

maxA = max(katanaA)
throwKatanaB = [k for k in katanaB if k > maxA]
throwKatanaB.sort(reverse=True)
count = 0
for t in throwKatanaB:
    h -= t
    count += 1
    if h <= 0:
        break
if h <= 0:
    print(count)
else:
    count += int(math.ceil(h / maxA))
    print(count)


Measured memory_bytes: 12168
/**
 * @brief ユーザ定義リテラル
 * @author えびちゃん
 */

#ifndef H_int_literals
#define H_int_literals

#include <cstddef>
#include <cstdint>

constexpr intmax_t  operator ""_jd(unsigned long long n) { return n; }
constexpr uintmax_t operator ""_ju(unsigned long long n) { return n; }
constexpr size_t    operator ""_zu(unsigned long long n) { return n; }
constexpr ptrdiff_t operator ""_td(unsigned long long n) { return n; }

#endif  /* !defined(H_int_literals) */

#include <cstdio>
#include <string>

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

  std::string s;
  for (int i = n; i; i /= k) {
    s += '0' + i % k;
  }
  printf("%zu\n", s.length());
}


Measured memory_bytes: 256