akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using vi=vector<int>;
using LL=long long;
int main() {
    int N; cin>>N;
    vi P(N+1),pos(N+1);//1-indexed
    for (int i = 1; i < N+1; i++){
        cin>>P[i]; 
        pos[P[i]]=i;
    }

    set<int> higher_pos;
    higher_pos.insert(0);
    higher_pos.insert(N+1);
    long long ans=0;
    for (int i = N; i >=1 ; i--){
        higher_pos.insert(pos[i]);
        int l=*prev(higher_pos.find(pos[i]));
        int r=*next(higher_pos.find(pos[i]));
        if(l!=0){
            int ll=*prev(higher_pos.find(l));
            ans+=(LL)i*(l-ll)*(r-pos[i]);
        }
        if(r!=N+1){
            int rr=*next(higher_pos.find(r));
            ans+=(LL)i*(pos[i]-l)*(rr-r);
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 8700
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
       double tate = scan.nextDouble();
       double yoko = scan.nextDouble();
       double S;
       double tubo;
       
       S = tate*yoko;
       tubo = S / 3.305785 ;
       System.out.printf("%.6f",tubo);

    }

}



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

/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y) {
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}
int main() {
	int n;
	int a;
	cin >> n >> a;
	n = n % 500;
	if (a >= n) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <numeric>
#include <ctime>
#include <complex>
#include <bitset>
#include <random>
#include <climits>
#include <stack>

using namespace std;

typedef long long ll;
typedef long double ld;

#define int ll
#define double ld
#define loop(i, n) for(int i = 0; i < (int)n; ++i)
#define loop1(i, n) for(int i = 1; i <= (int)n; ++i)
#define F first
#define S second
#define pb push_back
#define pi pair <int, int>
#define all(x) begin(x), end(x)
#define ti tuple <int, int, int>
#define Point Vect
#define no {cout << -1; return;}
#define yes {cout << "Yes"; return;}
#define mkp make_pair
#define mkt make_tuple
#define cerr if(0) cerr

const int N = 607;

vector <int> g[N];
double sum[N], from[N];

void solve() {
    int n, m;
    cin >> n >> m;
    loop(i, m) {
        int u, v;
        cin >> u >> v;
        g[u].pb(v);
    }
    loop1(cv, n) {
        loop(i, N)
            sum[i] = 0;
        sum[cv] = 1;
        for (int v = cv; v <= n; ++v) {
            for (int u : g[v]) {
                double pls = sum[v] / g[v].size();
                from[cv] += pls; sum[u] += pls;
            }
        }
    }
    double ans = from[1];
    loop1(i, n) {
        if (g[i].size() < 2)
            continue;
        loop(j, N)
            sum[j] = 0;
        sum[1] = 1;
        double cur = 0;
        loop1(v, n) {
            int bad = 0;
            if (v == i)
                for (int u : g[v])
                    if (from[u] > from[bad])
                        bad = u;
            for (int u : g[v]) {
                if (bad == u)
                    continue;
                double pls = sum[v] / (g[v].size() - (v == i));
                cur += pls; sum[u] += pls;
            }
        }
        ans = min(ans, cur);
    }
    cout << fixed << setprecision(7) << ans;
}

signed main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}


Measured memory_bytes: 5972
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<string>
#include<vector>
#include<set>
#include<map>
#include<queue>
using namespace std;

int main() {
	int h, w;
	cin>>h>>w;
	int n;
	cin>>n;
	vector<int> a(n);
	for(int i = 0; i < n; ++i) cin>>a[i];
	vector<vector<int> > g(h, vector<int>(w));
	pair<int, int> np = pair<int, int>(0, 0);
	for(int i = 0; i < n; ++i) {
		while(a[i] > 0) {
			g[np.first][np.second] = i + 1;
			--a[i];
			if(np.first % 2 == 0) {
				if(np.second != w - 1) ++np.second;
				else ++np.first;
			} else {
				if(np.second != 0) --np.second;
				else ++np.first;
			}
		}
	}
	for(int i = 0; i < h; ++i) {
		for(int j = 0; j < w; ++j) {
			cout<<g[i][j];
			if(j != w - 1) cout<<" ";
			else cout<<endl;
		}
	}
}


Measured memory_bytes: 384
using System;
using System.Collections.Generic;
using System.Linq;

class Program{

  static int n = 0;
  static int q = 0;
  static int l = 0;
  static int r = 0;
  static char[] s;

  static int Main() {

    string[] nyu = Console.ReadLine().Split(' ');
    n = int.Parse(nyu[0]);
    q = int.Parse(nyu[1]);
    int[] ans = new int[q];

    string nya = Console.ReadLine();
    s = nya.ToCharArray();

    int[] ac = new int[n];
    if (s[0] == 'A' && s[1] == 'C') {
      ac[0] = 1;
    } else {
      ac[0] = 0;
    }

    for (int i = 1; i < n-1; i++) {
      if (s[i] == 'A' && s[i+1] == 'C') {
        ac[i] = ac[i-1]+1;
      } else {
        ac[i] = ac[i-1];
      }
    }
    ac[ac.Length-1] = ac[ac.Length-2];

    // foreach (int i in ac){
    //   System.Console.Write("{0}", i);
    // }
    // System.Console.Write("\n");

    for (int i = 0; i < q; i++) {
      string[] nyo = Console.ReadLine().Split(' ');
      l = int.Parse(nyo[0]);
      r = int.Parse(nyo[1]);

      if (l == 1 && ac[0] == 0) {
        ans[i] = ac[r-1];
      } else if (l == 1 && ac[0] == 1) {
        ans[i] = ac[r-1];
      } else {
        ans[i] = ac[r-1] - ac[l-2];
      }

      if (ac[r-1] > ac[r-2]) {
        ans[i] -= 1;
      }

      Console.WriteLine("{0}", ans[i]);
    }

    return 0;
  }


}


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

bool in_range(char a, char l, char r) {
	return l <= a and a <= r;
}

int main () {
	int a, b; string s;
	cin >> a >> b >> s;
	bool ok = 1;
	for (int i = 0; i < a+b+1; i++) {
		if (i != a and not in_range(s[i],'0','9')) ok = 0;
		else if (i == a and s[i] != '-') ok = 0;
	}
	cout << (ok ? "Yes" : "No") << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (T &x : vec) is >> x;
  return is;
}

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &pa) {
  return os << "(" << pa.first << ", " << pa.second << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }
#define dump(...) cout<<#__VA_ARGS__<<": [L_"<<__LINE__<<"]"<<'\n'; print(__VA_ARGS__);cout<<'\n';

template<class T, class U>inline bool chmax(T &a, const U &b) { if(a<b){ a=b; return 1; } return 0; }
template<class T, class U>inline bool chmin(T &a, const U &b) { if(b<a){ a=b; return 1; } return 0; }

struct RuntimeModComb {
private:
  unsigned int N;
  long long MOD;

public:
  vector<long long> fac;
  vector<long long> inv;
  vector<long long> ifac;

  RuntimeModComb(unsigned int N, long long MOD) : N(N), MOD(MOD), fac(), inv(), ifac() {
    fac.resize(N), inv.resize(N), ifac.resize(N);
    fac[0] = fac[1] = inv[1] = ifac[0] = ifac[1] = 1;
    for (size_t i = 2; i <= N; ++i) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
      ifac[i] = ifac[i-1] * inv[i] % MOD;
    }
  }
  long long comb(unsigned int n, unsigned int k) const {
    if (n < 0 || k < 0 || k > n) return 0;
    return (fac[n] * ifac[k] % MOD) * ifac[n-k] % MOD;
  }
};

int main() {
  int x, y; cin>>x>>y;
  int d = x+y;
  if (d%3 != 0) {
    print(0);
    return 0;
  }
  int n = (x+y)/3;
  RuntimeModComb mc(1000010, MOD);
  int basex = 2*n, basey = n;
  int m = -1;
  rep(i, n+1) {
    if (basex==x and basey == y) {
      m = i;
      break;
    }
    basex -= 1;
    basey += 1;
  }
  if (m == -1) {
    print(0);
    return 0;
  }
  long long ans = mc.comb(n, m);
  print(ans);

  return 0;
}

Measured memory_bytes: 23680
N = list(map(int,input()))
hon_list = [2, 4, 5, 7, 9]
pon_list = [0, 1, 6, 8]
bon_list = [3]
 

if N[-1] in hon_list:
    print('hon')
elif N[-1] in pon_list:
    print('pon')
else:
    print('bon')

Measured memory_bytes: 9088
#include <iostream>
#include <string>
#include <cmath>
#include<algorithm>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<iomanip>
#define _USE_MATH_DEFINES
#include <math.h>
#include <functional>
using namespace std;

#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)

typedef long long ll;
const ll INF = 1e17;
const ll MOD = 1000000007;
const ll MAX = 1000001;

ll max(ll a, ll b) {
	if (a > b) { return a; }
	return b;
}

ll min(ll a, ll b) {
	if (a > b) { return b; }
	return a;
}

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

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

struct edge {
	ll ind;
	ll to;
	ll d;
};


///////////////////////////



int main() {

	string s;
	cin >> s;

	ll ans = 0;

	rep(i, 3) { if (s[i] == '1') { ans++; } }
	cout << ans;

	system("PAUSE");

	

}


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

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;

    if((A+B) > (C+D)) cout << "Left" << endl;
    else if((A+B) == (C+D)) cout << "Balanced" << endl;
    else if((A+B) < (C+D)) cout << "Right" << endl;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.Set;
import java.util.StringTokenizer;
import java.util.TreeMap;
import java.util.TreeSet;

public class Main {
	
	public static class Plane {
		int height;
		int pos;
		
		public Plane(int height, int pos) {
			super();
			this.height = height;
			this.pos = pos;
		}
	}
	
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner(System.in);
		
		final char[] inputs = sc.next().toCharArray();
		
		int[] map = new int[inputs.length + 1];
		int[] max = new int[inputs.length + 1];
		map[0] = 0;
		
		int cnt = 1;
		for(char c: inputs){
			map[cnt] += map[cnt - 1] + (c == '/' ? 1 : c == '_' ? 0 : -1);
			cnt++;
		}
		
		max[map.length - 1] = map[map.length - 1];
		for(int i = map.length - 2; i >= 0; i--){
			max[i] = Math.max(max[i + 1], map[i]);
		}
		
		LinkedList<Plane> stack = new LinkedList<Plane>();
		LinkedList<Integer> area_list = new LinkedList<Integer>();
		
		int total_area = 0, cur_area = 0;
		for(int i = 1; i < map.length; i++){
			final int prev_diff = map[i] - map[i - 1];
			
			if(prev_diff > 0 && !stack.isEmpty()){
				Plane before = stack.removeFirst();
				total_area += (i - before.pos);
				cur_area += (i - before.pos);
				
				if(stack.isEmpty() || max[i] <= map[i]){
					area_list.add(cur_area);
					cur_area = 0;
				}
				
			}else if(prev_diff < 0){
				stack.addFirst(new Plane(map[i], i));
			}
		}
		
		if(cur_area != 0){
			area_list.add(cur_area);
		}
		
		System.out.println(total_area);
		System.out.print(area_list.size());
		for(int i : area_list){
			System.out.print(" " + i);
		}
		System.out.println();
		
	}
	
	public static class Scanner {
	    private BufferedReader br;
	    private StringTokenizer tok;

	    public Scanner(InputStream is) throws IOException {
	        br = new BufferedReader(new InputStreamReader(is));
	    }

	    private void getLine() throws IOException {
	        while (!hasNext()) { tok = new StringTokenizer(br.readLine()); }
	    }

	    private boolean hasNext() {
	        return tok != null && tok.hasMoreTokens();
	    }

	    public String next() throws IOException {
	        getLine(); return tok.nextToken();
	    }

	    public int nextInt() throws IOException {
	        return Integer.parseInt(next());
	    }
	    
	    public long nextLong() throws IOException {
	    	return Long.parseLong(next());
	    }
	    
	    public void close() throws IOException {
	        br.close();
	    }
	}

}

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

typedef long long ll;
typedef long double ld;
const ll mod = 1e9 + 7;
#define eps 1e-9
using namespace std;

int n;
ll arr[(int)2e5 + 5];

ll calc(ll b) {
    ll res = 0;
    for (int i = 0; i < n; i++) {
        res += abs(arr[i] - (b + i + 1));
    }
    return res;
}

int main() {
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >>arr[i];
    }
    ll l = -1e9, r = 1e9;
    while (r - l >= 3) {
        ll mid1 = l + (r - l) / 3;
        ll mid2 = r - (r - l) / 3;
        ll res1 = calc(mid1);
        ll res2 = calc(mid2);
        if (res1 >= res2) {
            l = mid1;
        }
        else
            r = mid2;
    }
    ll res = 1e18;
    for (int i = l; i <= r; i++) {
        res = min(res, calc(i));
    }
    cout << res;
    return 0;
}


Measured memory_bytes: 1792
#include <cstring>
#include <iostream>

using namespace std;

int n;
char pattern[104][104];

void rec(int d, bool c, int y, int x) {
  pattern[y][x] = '#';
  switch (d) {
  case 0:
    if (pattern[y-2][x] == '#')
      if (c && pattern[y+1][x+1] != '#') rec(1, false, y, x);
      else return;
    else
      rec(0, true, y-1, x);
    break;
  case 1:
    if (pattern[y][x+2] == '#')
      if (c && pattern[y+1][x-1] != '#') rec(2, false, y, x);
      else return;
    else
      rec(1, true, y, x+1);
    break;
  case 2:
    if (pattern[y+2][x] == '#')
      if (c && pattern[y-1][x-1] != '#') rec(3, false, y, x);
      else return;
    else
      rec(2, true, y+1, x);
    break;
  case 3:
    if (pattern[y][x-2] == '#')
      if (c && pattern[y-1][x+1] != '#') rec(0, false, y, x);
      else return;
    else
      rec(3, true, y, x-1);
    break;
  default:
    break;
  }
}

int main() {
  int d;
  cin >> d;
  for (int i = 0; i < d; i++) {
    memset(pattern, ' ', sizeof pattern);
    cin >> n;
    for (int j = 0; j < n+4; j++)
      pattern[0][j] = pattern[n+3][j] = pattern[j][0] = pattern[j][n+3] = '#';
    rec(0, true, n+1, 2);
    for (int y = 2; y < n+2; y++) {
      for (int x = 2; x < n+2; x++)
        cout << pattern[y][x];
      cout << endl;
    }
    if (i != d-1) cout << endl;
  }
}

Measured memory_bytes: 0
import sys
#from collections import defaultdict, deque, Counter
#import bisect
#import heapq
#import math
#from itertools import accumulate
#from itertools import permutations as perm
#from itertools import combinations as comb
#from itertools import combinations_with_replacement as combr
#from fractions import gcd
#import numpy as np

stdin = sys.stdin
sys.setrecursionlimit(10 ** 7)
MIN = -10 ** 9
MOD = 10 ** 9 + 7
INF = float("inf")
IINF = 10 ** 18

s = str(stdin.readline().rstrip())
t= str(stdin.readline().rstrip())
#l = list(map(int, stdin.readline().rstrip().split()))
#A, B, C = map(int, stdin.readline().rstrip().split())
#numbers = [[int(c) for c in l.strip().split()] for l in sys.stdin]
#word = [stdin.readline().rstrip() for _ in range(n)]
#number = [[int(c) for c in stdin.readline().rstrip()] for _ in range(n)]
#zeros = [[0] * w for i in range(h)]
t = t[:len(t)-1]
if s == t:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 9108
#include<stdio.h>

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

    if(n<=k){
        printf("%d\n",n*x);
    }
    else{
        printf("%d\n",k*x+(n-k)*y);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define all(x) (x).begin(), (x).end()
using ll = long long;
using namespace std;
template <typename T> using vec = std::vector<T>;

int main() {
    int D, T;
    int S;
    cin >> D >> T >> S;
    bool c = (D + S - 1) / S <= T;
    cout << (c ? "Yes" : "No") << '\n';
}


Measured memory_bytes: 3632
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>
#include <unordered_map>
#include <set>
#include <functional>
#include <iomanip>
using namespace std;

typedef long long ll;


int main() {
	int n, m, x, y; cin >> n >> m >> x >> y;
	vector<int> a(n + 1), b(m + 1);
	for (int i = 0; i < n; i++) cin >> a[i];
	for (int i = 0; i < m; i++) cin >> b[i];
	a[n] = x; b[m] = y;
	sort(a.begin(), a.end());
	sort(b.begin(), b.end());
	if (a[n] < b[0]) cout << "No War" << endl;
	else cout << "War" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <string>
#include <sstream>
#include <stack>
#include <algorithm>
#include <cmath>
#include <queue>
#include <map>
#include <set>
#include <cstdlib>
#include <bitset>
#include <tuple>
#include <assert.h>
#include <fstream>
#include <bitset>
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; }

const long long INF = 1LL << 60;
const long long MOD = 1000000007LL;
const long long MAX = 500000LL;
using namespace std;
typedef unsigned long long ull;
typedef  long long ll;
int N;
string S;
bool is_ok(int l){
    for(int i=0;i < N-l+1; i++){
        string sub = S.substr(i,l);
        string sub2 = S.substr(i+l,N);
        if (sub2.find(sub) != string::npos){

            return true;
        }
    }
    return false    ;
}
int bis (int ok,int ng){
    while(abs(ok-ng) > 1){
        int mid = (ok+ng)/2;
        if (is_ok(mid)){
            ok = mid;
        }else{
            ng = mid;
        }
    }
    return ok;
}
int main()
{
	cin >> N;
    cin >> S;
    int ans = bis(0,N);
    cout << ans << endl;


}


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

int x[105][5], y[105][5], n;

vector<int> match, vis;
vector<int> adj[205];

int Aug(int l){
    if(vis[l]) return 0;
    vis[l] = 1;
    for(int r : adj[l])
        if(match[r] == -1 || Aug(match[r])){
            match[r] = l;
            return 1;
        }
    return 0;
}

int main(){
    cin >> n;
    for(int j = 0; j < 2; j++)
        for(int i = 0; i < n; i++)
            cin >> x[i][j] >> y[i][j];
    
    for(int i = 0; i < n; i++)
        for(int j = 0; j < n; j++)
            if(x[i][0] < x[j][1] and y[i][0] < y[j][1]){
                adj[i].push_back(n+j);
                adj[n+j].push_back(i);
                //cout << i << " " << n+j << endl;
            }

    int res = 0;
    match.assign(2*n+5, -1);
    for(int l = 0; l < n; l++){
        vis.assign(2*n+5, 0);
        res += Aug(l);
    }
    cout << res << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		long a = sc.nextLong();
		long b = sc.nextLong();
		long n = sc.nextLong();

		long ans = 0;
		long s = 0;

		if (n < b) {
			ans = (a * n) / b - a * (n / b);
		} else {
			long nb = n / b;

			if (n % b == b - 1) {
				s = (nb * b - 1);
				ans = (a * s) / b - a * (s / b);
			} else {
				s = ((nb - 1) * b - 1);
				ans = (a * s) / b - a * (s / b);
			}

			ans = Math.max(ans, a * (b - 1) / b);
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 27016
#include <bits/stdc++.h>
#define int long
#define ll long long
#define rep(i, n) for(int i = 0; i < n; i++)
#define IOS cin.tie(0); ios::sync_with_stdio(false)
const int INF = 1e9;
using namespace std;

main() {
    string S; cin >> S;
    bool A[30]; rep(i,26) A[i]=false;
    if(S.size()<26){
        rep(i,S.size()){
            A[S[i]-'a']=true;
        }
        rep(i,26){
            if(!A[i]) {S+=(char)('a'+i); break;}
        }
    }
    else {
        vector<char> v; int pos=0;
        for(int i=S.size()-1;i>=1;i--){
            v.push_back(S[i]);
            if(S[i]>S[i-1]){
                pos=i; break;
            }
        }
        if(pos==0){cout << -1 << endl; return 0;} 
        sort(v.begin(),v.end());
        S=S.substr(0,pos-1)+*(upper_bound(v.begin(),v.end(),S[pos-1]));
    }
    cout << S << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
#include<queue>
#include<set>
#include<map>
using namespace std;
typedef long long int ll;
typedef vector<pair<ll,ll> > Q;
typedef pair<int,int> P;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
const ll inf=1e9+7;
ll gcd(ll a, ll b) { return (b ? gcd(b, a % b) : a); }
ll lcm(ll a, ll b) { return a / (gcd(a, b)) * b; }

int main(){
  int n,k,q;
  cin>>n>>k>>q;
  int a[100000];
  rep(i,0,q) cin>>a[i];

  int cnt[100000];
  rep(i,0,n) cnt[i]=0;

  rep(i,0,q) cnt[a[i]-1]++;

  rep(i,0,n){
    if(q-cnt[i]<k) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
  }


}

Measured memory_bytes: 1408
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>
#include <cstring>

using namespace std;

#define REP(i,n) for(int i = 0; i < n; i++)
#define RREP(i,n) for(int i = n - 1; i >= 0; i--)

#define ALL(v) v.begin(),v.end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

#define UNIQUE(v) do{sort(v.begin(), v.end()); v.erase( unique(v.begin(), v.end()), v.end() );} while(0)


#define y0 y3487465
#define y1 y8687969

#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,63,sizeof(x))

typedef long long ll;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;
typedef vector<ll> vll;
typedef vector<vll> vvll;

double EPS = 1e-9;
int INFi = 1000000005;
long long INFll = 1000000000000000005ll;
double PI = acos(-1);
int dirx[8] = {-1,0,0,1,-1,-1,1,1};
int diry[8] = {0,1,-1,0,-1,1,-1,1};
ll MOD = 1000000007;

ll N, ga, sa, ba, gb, sb, bb;

ll solve3(ll N, ll a1, ll a2, ll a3, ll b1, ll b2, ll b3) {
  ll res = N;
  REP(g, N / a1 + 1) {
    REP(s, N / a2 + 1) {
      ll rem = N - g * a1 - s * a2;
      if(rem >= 0) {
        ll b = rem / a3;
        rem = rem - b * a3;
        res = max(res, g * b1 + s * b2 + b * b3 + rem);
      }
    }
  }
  return res;
}

ll solve2(ll N, ll a1, ll a2, ll b1, ll b2) {
  ll res = N;
  REP(s, N / a1 + 1) {
    ll rem = N - s * a1;
    ll b = rem / a2;
    rem = rem - b * a2;
    res = max(res, s * b1 + b * b2 + rem);
  }
  return res; 
}

ll solve1(ll N, ll a1, ll b1) {
  ll res = N;
  ll g = N / a1;
  ll rem = N - g * a1;
  return g * b1 + rem;
}

int main(){
  cin >> N >> ga >> sa >> ba >> gb >> sb >> bb;

  vll goa, gob, backa, backb;
  if(ga < gb) {
    goa.pb(ga); gob.pb(gb);
  } else if (ga > gb) {
    backa.pb(gb); backb.pb(ga);
  }

  if(sa < sb) {
    goa.pb(sa); gob.pb(sb);
  } else if (sa > sb) {
    backa.pb(sb); backb.pb(sa);
  }

  if(ba < bb) {
    goa.pb(ba); gob.pb(bb);
  } else if(ba > bb) {
    backa.pb(bb); backb.pb(ba);
  }

  ll N2;

  if(goa.size() == 3) {
    N2 = solve3(N, goa[0], goa[1], goa[2], gob[0], gob[1], gob[2]);
  } else if (goa.size() == 2) {
    N2 = solve2(N, goa[0], goa[1], gob[0], gob[1]);
  } else if (goa.size() == 1) {
    N2 = solve1(N, goa[0], gob[0]);
  } else {
    N2 = N;
  }

  ll ans;

  if(backa.size() == 3) {
    ans = solve3(N2, backa[0], backa[1], backa[2], backb[0], backb[1], backb[2]);
  } else if (backa.size() == 2) {
    ans = solve2(N2, backa[0], backa[1], backb[0], backb[1]);
  } else if (backa.size() == 1) {
    ans = solve1(N2, backa[0], backb[0]);
  } else {
    ans = N2;
  }
  
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
using namespace std;
 
#define REP(i,n) for(int i=0; i<n; ++i)
#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 ALL(c) c.begin(), c.end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int mi[53][53][53], ma[53][53][53];

int main() {
    int n;
    cin >> n;
    VI a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    cout << a[n-1] - a[0] << endl;
    return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <numeric>

using namespace std;
typedef long long ll;

int main(){

  int a, b, c;
  cin >> a >> b >> c;
  int d;
  d = b / a;
  if (d > c){
    cout << c << endl;
  }
  else {
    cout << d << endl;
  }

  return 0;
}


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

using namespace std;

//typedef pair<int,int> P;

int main(){
	long long X,t;
	scanf("%lld %lld", &X, &t);

	if(X-t<0){
		printf("0\n");
	}else{
		printf("%d\n",X-t);
	}
	

	return 0;
}


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

int main(){
  long long N;
  long long c=0;
  cin>>N;
int d[100][2];
  bool a=true;
  for(int i=0;i<N;i++){
  cin>>d[i][0]>>d[i][1];
  }
  for(int i=0;i<N;i++){
   
  if(d[i][0]==d[i][1]){
  c++;
  }
   
    else{
    c=0;
    }
     if(c==3){
      a=false;
    break;
    }
   //cout<<c;
  }
  if(a){
  cout<<"No"<<endl;
  }
  else{
  cout<<"Yes"<<endl;
  }
}


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

int main(){
  
  int x1,y1,x2,y2;
  cin>>x1>>y1>>x2>>y2;

  int X=abs(x2-x1),Y=abs(y2-y1);
  
  if(!X||!Y){
    cout<<0<<endl;
    return 0;
  }

  int ans=X+Y-1;
  
  ans-=(X/(X/__gcd(X,Y))-1);
  
  cout<<ans<<endl;
  
  return 0;
}


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

#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define All(obj) (obj).begin(),(obj).end()
#define REP(n) for(int i=0;i<(n);++i)
#define REPR(n) for(int i=(n-1); i>=0;--i)
#define FOR(i,b,n) for(int i=(b);i<(n);++i)

typedef long long ll;

const int M=2e5+5;
const int INF=2e9;
const int MOD=1e9+7; //prime number
/*
vector<string> split(const string &str, char sep)
{
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
vector<int> split_into_num(const string &str, char sep)
{
    vector<int> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(stoi(buffer));
    }
    return v;
}
*/
int gcd(int a, int b)
{
    if(b==0)
    {
        return a;
    }
    return gcd(b,a%b);
}
bool isPrime(int a)
{
    if(a==2)
        return true;
    else if(a<=1 or a%2 == 0)
        return false;

    for(int i = 3; i <= sqrt(a); i+=2)
    {
        if(a%i==0)
            return false;
    }
    return true;
}
void BubbleSort(vector<string> &v, int n)
{
    int a,b;
    for(int i = 0; i < n-1; ++i)
    {
        bool swapped = false;
        for(int j = 0; j < n-i-1; ++j)
        {
            a = v[j][1] - '0';
            b = v[j+1][1] - '0';
            if(a > b)
            {
                swap(v[j],v[j+1]);
                swapped = true;
            }
        }
        if(swapped == false)
            break;
    }
}
void SelectionSort(vector<string> &v, int n)
{
    bool swapped;
    int index,a,b;
    for(int i = 0; i < n-1; ++i)
    {
        swapped = false;
        index = i;
        for(int j = i+1; j < n; ++j)
        {
            a = v[index][1] - '0';
            b = v[j][1] - '0';
            if(a>b)
            {
                index = j;
                swapped = true;
            }
        }
        if(swapped)
        {
            swap(v[i],v[index]);
        }
    }
}
void Solve()
{
    int x;
    cin >> x;
    if(x==1)
        cout << 0;
    else
        cout << 1;

}
int main()
{
    fastio;
    Solve();

    return 0;
}



Measured memory_bytes: 3692
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};
    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! { 
        a: usize, 
        b: usize, 
    }
    println!("{}", if (a * b) % 2 == 0 { "Even" } else { "Odd" });
}


Measured memory_bytes: 4352
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
const int N=1e9+7;
int dp[101][100001];
int wt[101];
int val[101];
int knapsack(int n,int w)
{
    if(n==0||w==0)
        return dp[n][w]=0;
    if(dp[n][w]!=-1)
        return dp[n][w];
    if(wt[n]<=w)
    {
        return dp[n][w]=max((val[n]+knapsack(n-1,w-wt[n])),knapsack(n-1,w));
    }
    else
        return dp[n][w]=knapsack(n-1,w);
}
int32_t main()
{
	IOS;
	int n,w;
    cin>>n>>w;
	for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=w;j++)
            dp[i][j]=-1;
    }


    for(int i=1;i<=n;i++)
        cin>>wt[i]>>val[i];
    int ans = knapsack(n,w);
    cout<<ans;
}


Measured memory_bytes: 82552
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <stack>
#include <string>
#include <utility>
#include <vector>

#define repd(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, n) repd(i, 0, n)
typedef long long ll;

using namespace std;

int inputValue();
void inputArray(int *, int);
void inputVector(vector<int> *, int);
template <typename T> void output(T, int);

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

    int ans = 0;
    repd(i, 1, n + 1) {
        int counter = 0;
        repd(j, 1, i + 1) {
            if (i % j == 0) {
                counter++;
            }
        }

        if (counter == 8 && i % 2 == 1) {
            ans++;
        }
    }

    cout << ans << endl;
    return 0;
}

int inputValue() {
    int a;
    cin >> a;
    return a;
}

void inputArray(int *p, int a) {
    rep(i, a) { cin >> p[i]; }
}

void inputVector(vector<int> *p, int a) {
    rep(i, a) {
        int input;
        cin >> input;
        p->push_back(input);
    }
}

template <typename T> void output(T a, int precision) {
    if (precision > 0) {
        cout << setprecision(precision) << a << "\n";
    } else {
        cout << a << "\n";
    }
}


Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#include <iomanip>
#include <stack>
#include <bitset>

#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())
#define fore(i,a) for(auto &i:a)

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

template<class T> bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T> bool chmin(T &a,const T &b){if(a>b){a=b;return 1;}return 0;}

ll N;
vector<ll> E[1010100];
ll ans;
ll K;
void dfs(ll current, ll parent, ll sum) {
  cerr << current << " " << parent << " " << sum << endl;
  for(auto &to: E[current]){
    if(to != parent) {
      if(sum == 0) {
	ans = 0;
	return ;
      }
      ans = (1LL * ans * sum) % MOD;
      dfs(to,current,K-2);
      sum--;
    }
  }
}

int
main(void){  
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  
  cin >> N >> K;
  REP(i, N-1) {
    ll a, b; cin >> a >> b;
    E[a].push_back(b);
    E[b].push_back(a);
  }
  //kかけた状態から始める
  ans = K;
  dfs(1,0,K-1);  

  cout << ans%MOD << endl;
  
  return 0;
}


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < n; i++)
#define Rep(i, n) for(int i = 1; i < n; i++)

const int mod = 1000000007;
const int inf = (int)1e9 + 7;
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }

ll GCD(ll a, ll b) { return b ? GCD(b, a % b) : a; }
ll LCM(ll a, ll b) { return (a * b) / GCD(a, b); }
int round_int(int a, int b) { return (a + (b - 1)) / b; }

// 素因数分解; 返り値は(素数, 乗数)のvector配列
vector<pair<ll, int>> factorize(ll n) {
	vector<pair<ll, int>> res;
	for (ll i = 2; i * i <= n; ++i) {
		if (n % i) continue;
		res.emplace_back(i, 0);
		while (n % i == 0) {
			n /= i;
			res.back().second++;
		}
	}
	if (n != 1) res.emplace_back(n, 1);
	return res;
}

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };
constexpr auto MAX = 100010;

// ──────────────────────────────────────────────────────────────────────────────

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(3);
    rep(i, 3) cin >> a[i];
    string s;
    cin >> s;
    vector<int> ctoi(256);
    ctoi['r'] = 2;
    ctoi['c'] = 0;
    ctoi['p'] = 1;
    int ans = 0;
    rep(i, k) {
        vector<int> x;
        for (int j = i; j < n; j += k) {
            x.push_back(ctoi[s[j]]);
        }
        vector<int> dp(2);
        int pre = -1;
        for (int nx : x) {
            vector<int> p(2);
            swap(dp, p);
            dp[0] = max(p[0], p[1]);
            if (pre == nx) {
                dp[1] = p[0] + a[nx];
            }
            else {
                dp[1] = p[1] + a[nx];
            }
            pre = nx;
        }
        ans += max(dp[0], dp[1]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
long long a[10001], n, m, tong;

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


Measured memory_bytes: 3688
from itertools import permutations


def check(queen):
    for r1, c1 in queen:
        if not all((r1 == r2 and c1 == c2) or (r1 + c1 != r2 + c2 and r1 - c1 != r2 - c2) for r2, c2 in queen):
            return False
    return True


N = int(input())

# 0～7のリストを作成する
R = list(range(8))
C = list(range(8))

# R,Cから既にクイーンが置いてあるマス目を削除する
queen = []
for _ in range(N):
    r, c = map(int, input().split())
    queen.append((r, c))
    R.remove(r)
    C.remove(c)

# Rの全ての順列を作成する
for columns in permutations(C):
    # tmp_queenに8個のクイーンの位置を格納する
    tmp_queen = queen[:]
    for r, c in zip(R, columns):
        tmp_queen.append((r, c))
    for r1, c1 in tmp_queen:
        for r2, c2 in tmp_queen:
            if r1 == r2 and c1 == c2:
                continue
            else:
                if r1 == r2 or c1 == c2:
                    break
                if r1 + c1 == r2 + c2 or r1 - c1 == r2 - c2:
                    break
        else:
            continue
        break
    else:
        board = [''.join('Q' if (r, c) in tmp_queen else '.' for c in range(8))
                 for r in range(8)]
        print(*board, sep='\n')
        exit(0)



Measured memory_bytes: 5668
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("03")
#pragma GCC optimization ("unroll-loops")
using namespace std;

const int maxn = 100002;
const int maxe = 20;
int n,m,c=0,k=0,d=0,pa[maxn];
string s;
bool a[maxn];
int st[maxn][maxe];

void build(int n){
    for(int j=1;(1<<j)<=n;j++){
        for(int i=1;i+(1<<j)-1<=n;i++){
            st[i][j] = min(st[i][j-1], st[i+(1<<(j-1))][j-1]);
        }
    }
}

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

int find(int i)
{
    if(pa[i]==i)return i;
    return pa[i]=find(pa[i]);
}

int bs(int l,int r,int x)
{
    while(l!=r)
    {
        int mi=(l+r)/2;
        if(a[mi]>x)r=mi;
        else l=mi+1;
    }
}

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

    cin>>n>>m;
    cout<<max(0,n-2*m);
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <string.h>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <stdio.h>
#include <vector>
#include <time.h>

//     MLE,TLE魔
//↓↓↓↓↓↓↓↓↓↓↓↓
#define int long long
//↑↑↑↑↑↑↑↑↑↑↑↑
//     MLE,TLE魔
#define endre getchar();getchar();return 0
#define moder 1000000007
#define inf 5000000000000000000
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define all(v) v.begin(),v.end()
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int n) {
	for (int i = 2; i <= sqrt(n); i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x * y / gcd(x, y);
}
int mod_pow(int x, int y, int mod) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x%mod;
		}
		x = x * x%mod;
		y >>= 1;
	}
	return res;
}
int kai(int x) {
	if (x == 0)return 1;
	return (kai(x - 1)*x) % moder;
}
int comb(int x, int y) {
	return kai(x)*mod_pow(kai(x - y), moder - 2, moder) % moder*mod_pow(kai(y), moder - 2, moder) % moder;
}
struct edge { int to, cost; };
int dx[5] = { 0,1,0,-1 }, dy[5] = { 1,0,-1,0 };
map<int, int>factor(int x) {
	map<int, int>res;
	for (int i = 2; i*i <= x; i++) {
		while (x%i == 0) {
			x /= i;
			res[i]++;
		}
	}
	if (x != 1)res[x]++;
	return res;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << min(c, b / a) << endl;
	endre;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=4000+10;
const int MOD=998244353;
int n,r[N],b[N];
char s[N];
int f[N][N];  //前i个球中有 j个蓝球 i-j个红球 

int main()
{
	scanf("%s",s+1);
	n=strlen(s+1);
	for (int i=1;i<=n;i++) {
		if (s[i]=='0') r[i]=2;
		if (s[i]=='1') { r[i]=1; b[i]=1; }
		if (s[i]=='2') b[i]=2;
		r[i]+=r[i-1]; b[i]+=b[i-1];
	}
	
	memset(f,0,sizeof(f)); f[0][0]=1; 
	for (int i=0;i<2*n;i++)
		for (int j=0;j<=i;j++) {
			if (!f[i][j]) continue;
			if (j+1<=b[min(i+1,n)]) f[i+1][j+1]=(f[i+1][j+1]+f[i][j])%MOD;
			if (i-j+1<=r[min(i+1,n)]) f[i+1][j]=(f[i+1][j]+f[i][j])%MOD;
		}
	cout<<f[2*n][b[n]];	
	return 0;
}

Measured memory_bytes: 63104
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repr(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<int>())
#define rn return
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#include <time.h>
typedef std::pair<int,int> P;
using namespace std;
using ll = long long;






ll f(ll a, ll b, ll x){
    ll e1 =  (a*x);
    e1/=b;
    ll e2 = (x/b);
    e2 *= a;
    return e1 - e2;
}
int main(){
    
    ll a,b,n;
    cin >> a >> b >> n;
    
    if (n < b){
        cout << f(a,b,n);
    }
    else{
        cout << f(a,b,b-1);
    }
    
}

//
//
//int main(){
//    int n,m,q;
//    cin >> n >> m >> q;
//
//    vector<tuple<int,int,int,int>> x(q);
//    rep(i,q){
//        int a,b,c,d;
//        cin >> a >> b >> c >> d;
//        x[i] = {-d,a-1,b-1,c};
//    }
//
//    SORT(x);
//    vector<int> A(n,-1);
//
//    ll ans = 0;
//    rep(i,q){
//        cout << get<0>(x[i]) << endl;
//
//    }
//
//}


Measured memory_bytes: 3596
#include<bits/stdc++.h>
 // #include <ext/pb_ds/tree_policy.hpp>
 // #include <ext/pb_ds/assoc_container.hpp>
 #include<chrono>
  using namespace std;
   using namespace std::chrono;      
  // using namespace __gnu_pbds; 
 #define fastio     ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
 #define fi         first
 #define se         second
 #define int         long long 
 #define pb         push_back
 #define emp        emplace_back
 #define vv(x)      vector<x>
 #define mp(x,y)    map<x,y>
 #define dq(x)      deque<x>
 #define pql(x)     priority_queue<x>
 #define pqs(x)     priority_queue<x,vv(x),greater<x> >
 //#define M          1000000007
 #define forf(i,a,b) for(int i=a;i<b;i++)
 #define it(x)      x::iterator
 #define ll         long long 
 #define debug(...) fprintf(stderr, __VA_ARGS__), fflush(stderr)
 #define time__(d)  for(long blockTime = 0; (blockTime == 0 ? (blockTime=clock()) != 0 : false); debug("%s time : %.4fs", d, (double)(clock() - blockTime) / CLOCKS_PER_SEC))
 #define vii        vector<int>
 #define big        1e12
 #define sm         -2e18
 #define mkr        make_pair
 #define vpi        vector<pair<int,int> >
 #define pii        pair<int,int>
 #define rng        500005
 #define sz(x)      (int)x.size()
 #define rv(x)      reverse(x.begin(),x.end())
 #define out(x)     cout<<x.fi<<" "<<x.se<<endl;
#define MEM(x,val) memset(x,val,sizeof(x))

 // typedef tree<pii, null_type, less<pii>, rb_tree_tag,  
 //            tree_order_statistics_node_update>  odst; 


void pr_init()
{
   
    #ifndef ONLINE_JUDGE
    freopen("gin.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);
   
    #endif
}


const int Mxn = 3e5+1;
int cols[Mxn] , seg[4*Mxn+4];
map<int,vii> row;  
void build(int s,int e,int i)
{
  if(s==e)
  {
    seg[i] = cols[s];
    return ;
  }
  int md = (s+e)/2;
  build(s,md,2*i+1);
  build(md+1,e,2*i+2);
  seg[i] = max(seg[2*i+1],seg[2*i+2]);
}

int qr(int qs,int qe,int s,int e,int i)
{
   if(s<=qs && e>=qe)
   {
    return seg[i];
   }
   if(s>qe || e<qs)
   {
     return 0;
   }

   int md = (qe+qs)/2;
   return max(qr(qs,md,s,e,2*i+1),qr(md+1,qe,s,e,2*i+2));
}

map<int,map<int,int> > mn;
void solve()
{
  int h,w,m;
  cin >> h >> w >> m; 
  

  forf(i,0,m)
  {
    int x,y;
    cin >> x >> y;
    mn[x][y] -- ;
    cols[y]++;
    row[x].pb(y);
  }
 
   build(0,Mxn,0);
   int an = 0;
   for(auto x:row)
   {
    vii cur = x.se;
    int num = sz(cur);
    cur.pb(w);
    cur.pb(0);
    sort(cur.begin(),cur.end());
    
    for(int i=1;i<(int)cur.size();i++)
    {
       an = max(an , num + cols[cur[i]] + mn[x.fi][cur[i]]);
       if(cur[i-1]+2<=cur[i])
       {
         an = max(an,qr(0,Mxn,cur[i-1]+1,cur[i]-1,0)+num);
       }
    }

   }

   cout<<an;
}

int32_t main()
{
  pr_init();
  fastio;
  auto start = high_resolution_clock::now(); 
  solve(); 
  auto stop = high_resolution_clock::now();
  auto duration = duration_cast<microseconds>(stop - start); 
  
    // cout << "Time taken by function: "
    //      << duration.count() << " microseconds" << endl; 

  return 0;
}

Measured memory_bytes: 112616
/****************************************************************
*	Author: huhao
*	Email: 826538400@qq.com
*	Create time: 2020-02-03 16:33:26
****************************************************************/
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#define fr(i,a,b) for(int i=(a),end_##i=(b);i<=end_##i;i++)
#define fd(i,a,b) for(int i=(a),end_##i=(b);i>=end_##i;i--)
int read()
{
	int r=0,t=1,c=getchar();
	while(c<'0'||c>'9')
	{
		t=c=='-'?-1:1;
		c=getchar();
	}
	while(c>='0'&&c<='9')
	{
		r=(r<<3)+(r<<1)+(c^48);
		c=getchar();
	}
	return r*t;
}
const int N=190,L=16;
int n,m,s[N][N],f[N][N][N][L+2];
char c[N][N];
int S(int x,int y,int X,int Y){ return s[X][Y]-s[x-1][Y]-s[X][y-1]+s[x-1][y-1]; }
int main()
{
	n=read(); m=read();
	fr(i,1,n) scanf("%s",c[i]+1);
	fr(i,1,n) fr(j,1,m) s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+(c[i][j]=='#');
//	fr(i,1,n) fr(j,1,m) printf("%d%c",s[i][j],j==m?'\n':' ');
	fr(st,0,n-1) fr(i,1,n-st)
	{
		int j=i+st;
		fd(k,m,1)
			if(S(i,k,j,k)==0||S(i,k,j,k)==st+1)
			{
				if(c[i][k]==c[i][k+1]) f[i][j][k][0]=f[i][j][k+1][0];
				else f[i][j][k][0]=k;
			}
			else f[i][j][k][0]=k-1;
		fr(l,0,L) f[i][j][m+1][l]=m;
		fr(l,1,L) fr(k,1,m)
		{
			f[i][j][k][l]=f[i][j][f[i][j][k][l-1]+1][l-1];
			int _l=i,_r=j-1;
			while(_l<_r)
			{
				int mid=(_l+_r)>>1;
				if(f[i][mid][k][l-1]>f[mid+1][j][k][l-1]) _l=mid+1;
				else _r=mid;
			}
			fr(o,std::max(_l-2,i),std::min(j-1,_l+2)) f[i][j][k][l]=std::max(f[i][j][k][l],std::min(f[i][o][k][l-1],f[o+1][j][k][l-1]));
		}
//		fr(k,1,m) fr(l,0,L) printf("%d %d %d %d %d\n",i,j,k,l,f[i][j][k][l]);
	}
	int ans=0;
	while(f[1][n][1][ans]<m) ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 461184