akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

macro_rules! read_value {
    ($next:expr, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
    ($next:expr, usize1) => (read_value!($next, usize) - 1);
    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize, d: i64,
        xy: [(i64, i64); n],
    }
    puts!("{}\n", xy.into_iter().filter(|(x, y)| {
        x * x + y * y <= d * d
    }).count());
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 3996
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int> >;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define fi first
#define se second
#define mp make_pair
#define sum accumulate
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 1000000000000000ll;
const ll MOD = 1000000007LL;
typedef unsigned int uint;

int main(){
    int n,k,s;
    std::cin >>n>>k>>s ;
    if(s==1000000000){
        rep(i,k)std::cout << s << ' ';
        rep(i,n-k)std::cout << 999999999 << ' ';
        std::cout << std::endl;
    }else{
        rep(i,k)std::cout << s << ' ';
        rep(i,n-k)std::cout << 1000000000 << ' ';
        std::cout << std::endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
const long long INF = (1LL << 32);
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;
template <class T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <class T> T &chmax(T &a, const T &b) { return a = max(a, b); }

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/


int main() {
    string a, b, c;
    cin >> a >> b >> c;
    cout << a[0] << b[1] << c[2] << Endl;
}

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

int main(void)
{
  std::string o, e, ans;
  getline(std::cin, o);
  getline(std::cin, e);
  int counter = 0;
  for (int i = 1; i < o.size() + e.size()+1; i++) {
    if (i%2==0) {
      ans.push_back(e[counter]);
      counter++;
    }else if(i%2==1){
      ans.push_back(o[counter]);
    }
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <set>
#include <map>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <functional>
#include <algorithm>
#include <climits>
#include <cmath>
#include <iomanip>
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string S, T;
    cin >> S >> T;
    string A = "NOTHING";
    rep(i, S.length()) {
        string R = "";
        bool ok = true;
        int cnt = 0;
        rep(j, S.length()) {
            if(j < i || cnt == T.length()) {
                if(S[j] == '?') R += 'a';
                else R += S[j];
            } else if (S[j] != '?' && S[j] != T[cnt]) {
                ok = false;
                break;
            } else {
                R += T[cnt++];
            }
        }
        //cout << i << " " << R << " " << ok << " " << cnt << endl;
        if(ok && cnt == T.length()){
            if(A == "NOTHING" || A > R) A = R;
        }
    }
    if(A == "NOTHING") {
        cout << "UNRESTORABLE" << endl;
    } else {
        cout << A << endl;
    }

    return 0;
}


Measured memory_bytes: 3588
#include <iostream>
using namespace std;
 
int main() {
	int a,b,c;
	cin>>a>>b>>c;
	if(a==b){
		cout<<c<<endl;
	}
	if(b==c){
		cout<<a<<endl;
	}
	if(a==c){
		cout<<b<<endl;
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <iomanip>
#include <cmath>
#include <algorithm>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
template<class T> inline void chmin(T& a, T b) {if (a>b) a=b; }
template<class T> inline void chmax(T& a, T b) {if (a<b) a=b; }
inline void print() { cout << endl; }
template <class Head, class... Tail> inline void print(Head&& head, Tail&&... tail) {cout << head; if (sizeof...(tail) != 0) cout << " "; print(forward<Tail>(tail)...);}
template <class T> inline void print(vector<T>& vec) { for (auto& a : vec) {cout << a; if (&a != &vec.back()) cout << " "; } cout << endl;}
template <class T> inline void print(vector<vector<T>>& df) { for (auto& vec : df) { print(vec); }}
typedef long long ll;
const ll LINF = 1e18;
const int INF = 1e9;


int main() { 
    int H, W; cin >> H >> W;
    vector<vector<char>> m;
    m.resize(H);
    REP(i, H) {
        m[i].resize(W);
        REP(j, W) {
            cin >> m[i][j];
        }
    }
    vector<int> mh;
    vector<int> mw;
    REP(w, W) {
        bool allWhite = true;
        REP(h, H) {
            if(m[h][w] != '.') {
                allWhite = false;
            }
        }
        if (allWhite) {
            mw.push_back(w);
        }
    }
    REP(h, H) {
        bool allWhite = true;
        REP(w, W) {
            if(m[h][w] != '.') {
                allWhite = false;
            }
        }
        if (allWhite) {
            mh.push_back(h);
        }
    }
    // print(mw);
    // print(mh);
    vector<vector<char>> comp;
    // print(comp.size());
    REP(h, H) {
        comp.resize(comp.size()+1);
        REP(w, W) {
            if(find(mh.begin(), mh.end(), h) == mh.end()) {
                if(find(mw.begin(), mw.end(), w) == mw.end()) {
                    int hh = comp.size()-1;
                    int ww = comp[hh].size();
                    // print(hh, ww);
                    // print(h, w, m[h][w]);
                    comp[hh].resize(comp[hh].size()+1);
                    comp[hh][ww] = m[h][w];
                }
            }
        }
    }
    REP(h, comp.size()) {
        REP(w, comp[h].size()) {
            cout << comp[h][w];
        }
        if(comp[h].size() > 0) cout << endl;
    }

    
    return 0;
}

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

#ifdef LOCAL
#define debug(var) cerr << #var << " = " << var << endl;
#else
#define debug(var)
#endif

void init() {
	ios_base::sync_with_stdio(0);
	cin.tie(0);
}

int c[10][10];

void solve() {
	int h, w; scanf("%d%d", &h, &w);
	for (int i = 0; i < 10; ++i) {
		for (int j = 0; j < 10; ++j) {
			scanf("%d", c[i]+j);
		}
	}
	for (int k = 0; k < 10; ++k) {
		for (int i = 0; i < 10; ++i) {
			for (int j = 0; j < 10; ++j) {
				c[i][j] = min(c[i][j], c[i][k]+c[k][j]);
			}
		}
	}
	long long ans = 0;
	for (int i = 0; i < h*w; ++i) {
		int a; scanf("%d", &a);
		if (a == -1) continue;
		ans += c[a][1];
	}
	printf("%lld", ans);
}

int main() {
	init();
	int t = 1; //scanf("%d", &t);
	while (t--) {
		solve();
	}
	return 0;
}


Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <math.h>
#include <algorithm>
#include <functional>
#include <string>
#include <array>
#include <vector>
#include <list>
#include <stack>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <queue>
#include <complex>
#include <bitset>
#define full(c) c.begin(), c.end()
#define vector2d(name,type,h,w,init) vector<vector<type>> name(h,vector<type>(w,init)) 
const int PRIME = 1000000007;
//const int INT_INF = 2147483647;
//const long long int LL_INF = 9223372036854775807;
const double PI = acos(-1);
const double EPS = 0.0001;
typedef unsigned long long int ull;
typedef long long int ll;
using namespace std;

struct unit {
	int id, p, y, n;
};
unit c[100000];
int i, n, m, s, t;
int main() {
	//cin.tie(0);
	//ios::sync_with_stdio(false);
	cin >> n >> m;
	for (i = 0; i < m; i++) {
		c[i].id = i + 1;
		cin >> c[i].p >> c[i].y;
	}
	sort(c, c + m, [](const unit &l, const unit &r) {
		if (l.p != r.p) return l.p < r.p;
		return l.y < r.y;
	});
	s = c[0].p;
	t = 0;
	c[0].n = 1;
	for (i = 1; i < m; i++) {
		if (c[i].p != s) {
			s = c[i].p;
			t = i;
			c[i].n = 1;
		}
		else {
			c[i].n = i + 1 - t;
		}
	}
	sort(c, c + m, [](const unit &l, const unit &r) {
		return l.id < r.id;
	});
	for (i = 0; i < m; i++) {
		printf("%06d%06d\n", c[i].p, c[i].n);
	}
	return 0;
}


Measured memory_bytes: 3072
using System;
using System.Linq;
 
class Program {
   static void Main(){
     
     string[] input = Console.ReadLine().Split().ToArray();
     int A = int.Parse(input[0]);
     int B = int.Parse(input[1]);
     
     int count = 0;
     for(int i = A; i <= B; i++){
       string I = i.ToString();
       if(I[0] == I[4]&&I[1] == I[3]) count++;
     }
     
     Console.WriteLine(count);
     
   }
}


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

int main(int argc, char const *argv[])
{
	int n;
	string s;
	cin>>n>>s;
	int w[n+5]={},e[n+5]={};
	for (int i = 0; i < n; ++i)
	{
		w[i+1]=w[i]+(s[i]=='W');
	}
	for (int i = n-1; i >= 0; --i)
	{
		e[i]=e[i+1]+(s[i]=='E');
	}
	int ans=n;
	for (int i = 0; i < n; ++i)
	{
		ans=min(ans,w[i]+e[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
#define P pair<int,int>
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define re(i,k,n) for(int i=k;i<n;i++)
#define mod 1000000007;
int n;
//最大公約数
int gcd(int s,int b){
    if(b==0)return s;
    return gcd(b,s%b);
}
signed main(){
    int n;
    cin>>n;
    int a[n];
    int sub=0,kai=0;
    rep(i,n){
        cin>>a[i];
    }
    rep(i,n-1){
        if(a[i]>=a[i+1]){
            sub++;
        }
        else{
            kai=max(kai,sub);
            sub=0;
        }
    }
    kai=max(kai,sub);
    cout<<kai<<endl;
}

Measured memory_bytes: 1024
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
f = int(input())

e = max(e,f)
t = min(a,b)
t = min(c,t)
t = min(d,t)

print(a+b+c+d-t+e)

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

int main(){
	int a[3];
	cin >> a[0] >> a[1] >> a[2];
	sort(a, a + 3);
	for(int i = 0; i < 3; i++){
		cout << a[i];
		if(i != 2) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 1176
import sys
N = int(input())

ans = ""

alp = "abcdefghijklmnopqrstuvwxyz"
#print (len(alp))

ns = 0
k = 0
ans = ""
for keta in range(1,100):

    os = ns
    ns += 26**keta

    if ns >= N:

        N -= (os + 1)
        #print (N)
        

        for i in range(keta-1,-1,-1):

            ans += alp[N // (26**i)]
            N %= 26**i

        print (ans)
        sys.exit()



Measured memory_bytes: 61824
#include<bits/stdc++.h>
using namespace std;
long long int func(long long int x)
{
	return log2(x);
}
int main()
{
	long long int x;
	cin>>x;
	long long int n=func(x);
	//cout<<n<<endl;
	long long int ans=pow(2,n+1)-1;
	cout<<ans<<endl;
}

Measured memory_bytes: 512
#include<stdio.h>
#include<math.h>

int main(void){
    int a, b, c;
    int dif1, dif2, dif3;
    int min, min2;
    scanf("%d %d %d", &a, &b, &c);
    dif1 = abs(a-b);
    dif2 = abs(a-c);
    dif3 = abs(b-c);
    min = dif1;
    if ( min >= dif2 ) {
        min2 = min;
        min = dif2;
    } else {
        min2 = dif2;
    }
    if ( min >= dif3 ) {
        min2 = min;
        min = dif3;
    } else if ( min2 >= dif3 ) {
        min2 = dif3;
    }
    printf("%d\n", min+min2);
    return 0;

}


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



using namespace std;

typedef vector<int> VI;
typedef vector<string> VS;


//container util
#define SORT(c) sort((c).begin(),(c).end())

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



int main(void){

	int N; cin >> N;

	set<int> st;
	int d;
	REP(i,N){
		cin >> d;
		st.insert(d);
	}

	cout << st.size() << endl;


	return 0;

}


Measured memory_bytes: 256
def divisors(n)
  res = []
  1.upto(n) do |i|
    break unless i * i <= n
    next unless n.modulo(i).zero?
    res << i
    res << n.div(i) unless i * i == n
  end
  res
end

t = gets.to_i.times.map{gets.to_i}.sort
d = divisors(t.last)
p t.map{|i|
  d.map{|j|
    i<=j ? j-i : 1e9
  }.min
}.inject :+

Measured memory_bytes: 12868
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rrep(i,n) for (int i = n-1; i >= 0; i--)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define tmax(a,b,c) max(a,max(b,c))
#define tmin(a,b,c) min(a,min(b,c))
#define pb push_back
#define eb emplace_back
#define vi vector<int>
#define vvi vector<vector<int>>
#define vl vector<ll>
#define vs vector<string>
#define vc vector<char>
#define vb vector<bool>
#define vp vector<P>
using namespace std;
using ll = long long;
using P = pair<int,int>;
using LP = pair<ll,ll>;
template<class T> istream& operator>>(istream& is,vector<T>& v) { for(T& t:v){is>>t;} return is; }
template<class T> ostream& operator<<(ostream& os,const vector<T>& v) { for(T t:v){os<<t<<" ";} os<<"\n"; return os; }
void Yes(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YES(bool b) { cout << (b ? "YES" : "NO") << endl; }
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;}
const int inf = 1001001001;
const ll linf = 1001001001001001001;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr); cout.tie(nullptr);
    string s;
    cin >> s;
    int n = s.size();
    vi a(n);
    rep(i,n) a[i] = (s[i] == 'W');
    int num = 1;
    int now = a[0];
    rep2(i,1,n) {
        if(a[i] == now) continue;
        num++;
        now = 1-now;
    }
    cout << num-1 << endl;
}


Measured memory_bytes: 848
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define f first
#define s second
#define mp make_pair
#define pb push_back
#define vll vector<ll>
#define endl "\n"
#define pll pair<ll,ll>
#define all(x) (x).begin() , (x).end()
#define in insert
#define REP(i,n) for (int i = 1; i <= n; i++)
#define matrix vector<vector<ll> > 
using namespace std;
 
const ll N = 1e5+2;
const ll MOD = 1e9+7;
const ll INF = 1e16;
const ll LOG = 25;
 
long long binpow(long long a, long long b, long long m) {
    a %= m;
    long long res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll func(ll b,ll n){
	if(b < 2) return 0;
	ll sum = 0;
	while(n){
		sum += (n%b);
		n/=b;
	}
	return sum;
}

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	// ifstream fin ("sound.in");
	// ofstream fout("sound.out");
	string s;
	cin >> s;
	ll n = 1ll *s.size();
	for(int i =0;i<n;i++){
		if(s[i] == 'g') s[i]='r';
	}

	ll P = 0,R = 0;
	ll ans = 0;
	// P <= R
	R++;
	if(s[0] == 'p'){
		ans--;
	}

	for(int i =1;i<n;i++){
		if(s[i] == 'p'){
			if((P+1) <= R){
				P++;
			}
			else {
				ans--;
				R++;
			}
		}
		else{
			if((P+1) <= R){
				ans++;
				P++;
			}
			else{
				R++;
			}
		}
	}	
	cout<<ans<<endl;
	
	return 0;
}

Measured memory_bytes: 512
# encoding: utf-8

n, q = map(int, raw_input().split())
queue = []
for i in xrange(n):
    name, time = raw_input().split()
    queue.append((name, int(time)))

time = 0
while queue:
    name, t = queue.pop(0)
    if q < t:
        time += q
        queue.append((name, t - q))
    else:
        time += t
        print name, time

Measured memory_bytes: 12484
#include <numeric>
#include<iostream>
#include<set>
#include<queue>
#include<vector>
#include<map>
#include<stack>
#include<algorithm>
#include <sstream>
#include<string.h>
#include <cmath>
#include <iomanip>
using namespace std;
#define inf 1000000007
#define int long long
#define rep(i,j,n) for(int i=j;i<n;++i)
typedef pair<int,int>  P;
string alph("abcdefghijklmnopqrstuvwxyz");
struct edge{int from,to,cost;};
vector<edge> G;
double pi = 3.141592653589793;
P sg[10];
int a[55],b[55];
int n,m;
int d[16][16];
int dp[55][55]={};//i番目までの数でj個選んだ状態のsum
signed main(){
    int n;cin>>n;
    cout<<n/3<<endl;
    return 0;
}


Measured memory_bytes: 768
import sys
from heapq import heappush, heappop, heapify
import math
from math import gcd
import itertools as it
import collections
from collections import deque 

input = sys.stdin.readline

def inp():
    return int(input())
def inpl():
    return list(map(int, input().split()))
def _debug(obj):
    print(obj, file=sys.stderr)

# ---------------------------------------

N, W = inpl()
dp = [[0] * (W+1) for i in range(N+1)]
for i in range(1, N+1):
    w, v = inpl()
    for j in range(1, W+1):
        if j - w < 0:
            dp[i][j] = dp[i-1][j]
        else:
            dp[i][j] = max(dp[i-1][j], dp[i-1][j-w] + v)
print(dp[N][W])

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

string s;

void solve() {
  int n = s.size();
  ll cnt = 0;
  for (int i = 0; i < n; i++) {
    if (s[i] == 'x') {
      cnt++;
    }
  }
  if (cnt >= 8) {
    cout << "NO\n";
  } else {
    cout << "YES\n";
  }
  return;
}

int main() {
  cin >> s;
  solve();
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
	"strconv"
)

var N, A, B int

func main() {
	fmt.Scanf("%d %d %d", &N, &A, &B)

	ans := 0
	for i := 1; i <= N; i++ {
		str := strconv.Itoa(i)
		sum := 0
		for _, c := range str {
			sum += int(c) - '0'
		}
		if A <= sum && sum <= B {
			ans += i
		}
	}

	fmt.Println(ans)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFLL = LLONG_MAX / 3;
const double eps = (1e-9);

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

  int n;
  cin >> n;

  vector<pair<int, int>> vp;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    vp.emplace_back(b, a);
  }

  sort(ALL(vp));

  int now = 0;
  for (auto& p : vp) {
    if (now + p.second > p.first) {
      puts("No");
      return 0;
    }
    now += p.second;
  }

  puts("Yes");

  return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repeat(i, a, b) for (int i = (a); i < (b); i++)
#define INF 2e8
#define all(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  cout << (n + 110) / 111 * 111 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main()
{
    int n, q, i, j, save, temp;
    int countn = 0, countq = 0;
    int s[10001];
    int t[501];
    
    scanf("%d", &n);
    for (i = 0;i < n; i++){
        save = 1;
        scanf("%d", &temp);
        for(j = 0; j < countn; j++) {
            if (temp == s[j]) {
                save = 0;
                break;
            }
        }
        if (save){
            s[countn] = temp;
            countn++;
        }
    }
    
    scanf("%d", &q);
    for (i = 0; i < q; i++) {
        save = 1;
        scanf("%d", &temp);
        for(j = 0; j < countq; j++) {
            if (temp == t[j]) {
                save = 0;
                break;
            }
        }
        if (save){
            t[countq] = temp;
            countq++;
        }
    }
    
    int count = 0;
    for (i = 0; i < countn; i++){
        for (j = 0; j < countq; j++){
            if (s[i] == t[j]) {
                count++;
            }
        }
    }
    printf("%d\n", count);
    return 0;
}


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

int main(){
  int N,D,X,cnt=0;
  cin >> N >> D >> X;
  vector<int> A(N);
  rep(i,N){
    cin >> A.at(i);
  }
  rep(i,N){
    cnt += (D-1)/A.at(i)+1;
  }
  cout << cnt + X << endl;
}


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

#define REP(i, n) for(ll i = 0; i <= n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 1e9
#define ALL(v) v.begin(), v.end()

using namespace std;
typedef unsigned long long ll;

int main(){
    // read in integers
    ll n, y;
    cin >> n >> y;

    REP(i, n){
        REP(j, n){
            if (i+j > n) continue;
            if ((i*10000) + (j*5000) + ((n-i-j)*1000) == y){
                cout << i << ' ' << j << ' ' << n-i-j << endl;
                return 0;
            }
        }
    }
    cout << "-1 -1 -1" << endl;
    return 0;

}

Measured memory_bytes: 3644
// Indrajeet Mishra

/*#pragma warning(disable:4996)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")*/

#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define test(s) if (!(s)) { cout << __LINE__ << " " << #s << endl; exit(-1); }
#define debug(x) do { std::cerr << x; } while (0)
#define endl "\n"
#define pb push_back
#define pf push_front
#define vll vector<ll>
#define dll deque<ll>
#define sll set<ll, greater <ll>>
#define mll map<ll, ll>
#define vii vector<int>
#define dii deque<int>
#define sii set <int, greater <int>>
#define mii map<int, int>
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define inv2 500000004
#define inv6 166666668
#define N 1000005
#define inf 200000000
#define eps 1e-10
#define PI 3.14159265359
#define all(v) (v).begin(),(v).end()
#define min(a,b) (((a)<(b))?(a):(b))
#define max(a,b) (((a)>(b))?(a):(b))
#define gcd(a,b) __gcd(a,b)

ll dp[101][100001];
void Indrajeet(){
    memset(dp,-1,sizeof(dp));
}

ll knapsack(ll w[], ll v[], ll n, ll W){
    if(n==0 || W==0)return 0;
    if(dp[n][W]!=-1)return dp[n][W]; 
    if(w[n-1]<=W) 
    return dp[n][W]=max((v[n-1]+knapsack(w,v,n-1,W-w[n-1])),(knapsack(w,v,n-1,W)));
    else return dp[n][W]=knapsack(w,v,n-1,W);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    Indrajeet();
    ll n=0,W=0;cin>>n>>W;
    ll w[101]={0},v[101]={0};
    rep(i,0,n){
        cin>>w[i]>>v[i];
    }
    cout<<knapsack(w,v,n,W);
    return 0;
}

Measured memory_bytes: 82464
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<long long> vll;
typedef vector<pair<int, int>> vpi;
typedef vector<pair<long long, long long>> vpl;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
#define INF (int)(1e9)
#define MAXX 1.1529215e+18
#define inf 999999
#define EPS (1e-7)
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define FOR(i, k, n) for (int i = (k); i < (int)(n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.begin(), a.end(), greater<int>()
#define ROT(a) a.begin(), a.begin() + 1, a.end()
#define RROT(a) a.begin(), a.end() - 1, a.end()
#define PB push_back
#define MP make_pair
#define PI acos(-1.0)
#define sz(a) a.size()
const ll MOD = 1e9 + 7;
const int MAX = 10000000;
template <typename T1, typename T2>
inline bool chmin(T1& a, T2 b)
{
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T1, typename T2>
inline bool chmax(T1& a, T2 b)
{
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
T gcd(T a, T b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}
//cout << 'H' << endl;
/*--------------------------------------------*/

ll func(ll a)
{
    if (a % 2) {
        return (a % 4 == 1 ? 1 : 0);
    } else {
        return (a % 4 == 0 ? (0 ^ a) : (1 ^ a));
    }
}


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

    ll A, B;
    cin >> A >> B;

    ll x = func(A - 1);
    ll y = func(B);

    cout << (x ^ y) << endl;
}


Measured memory_bytes: 256
/**
 *      author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *      created : 2019-11-28:15:25:43
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <functional>
#include <iomanip>
#include <random>
#include <utility>

using namespace std;

using int64 = long long;
#define debug(_) cerr << #_ << ": " << (_) << '\n'
template<typename T> inline void chmin(T &a, T b) { if (a > b) a = b; return; }
template<typename T> inline void chmax(T &a, T b) { if (a < b) a = b; return; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& vec) { os << '{'; for (size_t i = 0; i < vec.size(); ++i) { os << vec[i]; if (i != vec.size() - 1) os << ','; } os << '}'; return os; }
template<typename T, typename U> ostream& operator<<(ostream& os, const pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

struct edge {
  int from, to;
  int64 cost;
};

constexpr int64 INF = 2e18;

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

  int n, m; cin >> n >> m;
  vector<edge> es(m);
  for (int i = 0; i < m; ++i) {
    int a, b; int64 c; cin >> a >> b >> c;
    --a; --b;
    es[i] = (edge){a, b, -c};
  }

  vector<int64> dis(n, INF);

  dis[0] = 0;

  for (int i = 0; i < n - 1; ++i) {
    for (const edge& e : es) {
      if (dis[e.from] == INF) continue;
      if (dis[e.to] > dis[e.from] + e.cost) {
        dis[e.to] = dis[e.from] + e.cost;
      }
    }
  }

  int64 ans = -dis[n - 1];

  bool include_negativecycle[n] = {};

  for (int i = 0; i < n - 1; ++i) {
    for (const edge& e : es) {
      if (dis[e.from] == INF) continue;
      if (dis[e.to] > dis[e.from] + e.cost) {
        dis[e.to] = dis[e.from] + e.cost;
        include_negativecycle[e.to] = true;
      }
      if (include_negativecycle[e.from]) {
        include_negativecycle[e.to] = true;
      }
    }
  }

  if (include_negativecycle[n - 1]) {
    cout << "inf" << endl;
  } else {
    cout << ans << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

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

const int MAX = 2e5 + 10;
const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

// 素集合データ構造
struct UnionFind {
  vector<int> par, sizes; // par:あるデータの親, sizes:あるデータが属する木のサイズ

  // コンストラクタ
  // データ一つ一つを木とし、親は自分自身に初期化する
  UnionFind(int n) : par(n), sizes(n, 1) {
    for (int i = 0; i < n; i++) par[i] = i;
  }

  // データxが属する木の根ノードを取得
  // 再帰的に根を調べる際に、調べた辺を根に直接繋ぎ直すことで効率化している（経路圧縮）
  int find(int x) {
    return (x == par[x] ? x : par[x] = find(par[x]));
  }

  // 2つのデータx, yが属する木をマージする
  void unite(int x, int y) {
    // それぞれのデータの根ノードを取得
    x = find(x);
    y = find(y);

    // x, yが同じ木に属するならマージしない
    if (x == y) return;

    // xの木がyの木より大きくなるようにする
    if (sizes[x] < sizes[y]) swap(x, y);

    // xがyの親になるようにマージする
    par[y] = x;
    sizes[x] += sizes[y];
  }

  // 2つのデータx, yが同じ木に属するかどうか
  bool same(int x, int y) {
    return (find(x) == find(y));
  }

  // データxの属する木のサイズを返す
  int size(int x) {
    return sizes[find(x)];
  }
};

int main() {
  // 入力
  int N, K, L;
  cin >> N >> K >> L;
  int p[K], q[K];
  for (int i = 0; i < K; i++) cin >> p[i] >> q[i];
  int r[L], s[L];
  for (int i = 0; i < L; i++) cin >> r[i] >> s[i];

  UnionFind uf_k(N);
  UnionFind uf_l(N);
  for (int i = 0; i < K; i++) {
    p[i]--, q[i]--;
    uf_k.unite(p[i], q[i]);
  }
  for (int i = 0; i < L; i++) {
    r[i]--, s[i]--;
    uf_l.unite(r[i], s[i]);
  }

  int ar[MAX];
  int br[MAX];
  for (int i = 0; i < N; i++) {
    ar[i] = uf_k.find(i);
    br[i] = uf_l.find(i);
  }

  map<P, int> mp;
  for (int i = 0; i < N; i++) {
    mp[P(ar[i], br[i])]++;
  }

  // 解答
  cout << mp[P(ar[0], br[0])];
  for (int i = 1; i < N; i++) {
    cout << " " << mp[P(ar[i], br[i])];
  }
  cout << endl;

  return 0;
}


Measured memory_bytes: 18048
/******************************************************************************

            EYENINE,THE ELDER_WAND!!!
            THE ROOT OVER MINUS EIGHTY ONE!!

*******************************************************************************/

#include<bits/stdc++.h>
#define ALL_UP_WITH return 0
#define vi vector<int>
using namespace std;
int count1=0,n;
int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    set<string>st;
    int t;
    cin>>t;
    while(t--){
        string s;
        cin>>s;
        st.emplace(s);
    }
    cout<<st.size()<<endl;


    ALL_UP_WITH;
}



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

using namespace std;
typedef long long ll;
priority_queue <ll> q2;
priority_queue<ll,vector<ll>, greater<ll> > q1;
ll dp[300005][2];
ll a[300005];
int main()
{

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

    for(int i=0;i<3*N;i++)
        scanf("%lld",&a[i]);
    ll sum=0;
    for(int i=0;i<3*N;i++)
    {
        sum+=a[i];
        q1.push(a[i]);
        if(q1.size()>N)
        {
            sum-=q1.top();
            q1.pop();
        }
        dp[i][0]=sum;
    }
    sum=0;
    for(int i=3*N-1;i>=0;i--)
    {
        sum+=a[i];
        q2.push(a[i]);
        if(q2.size()>N)
        {
            sum-=q2.top();
            q2.pop();
        }
        dp[i][1]=sum;
    }
    ll ans=-1e18;
    for(int i=N-1;i<2*N;i++)
    {
        ans=max(ans,dp[i][0]-dp[i+1][1]);
    }
    printf("%lld",ans);

}


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

int main() {
	int n, l;
	cin >> n >> l;
	vector<string> s(n);
	rep(i, n) cin >> s[i];
	sort(s.begin(), s.end());
	string ans = "";
	rep(i, n) ans += s[i];
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
s=input()
a=0
b=0
c=0
for i in s:
    if i=='a':
        a+=1
    elif i=='b':
        b+=1
    else:
        c+=1

if max(a,b,c)-min(a,b,c)>=2:
    print("NO")
else:
    print("YES")

Measured memory_bytes: 3188
x1, y1, x2, y2 = list(map(int, input().split()))

x3 = y1 + x2 - y2
y3 = x2 - x1 + y2
x4 = x1 + y1 - y2
y4 = y1 + x2 - x1

print(x3, y3, x4, y4)

Measured memory_bytes: 2940
#include <string.h>
int main(void){
    int N;
    scanf("%d", &N);
    char w[N][11];
    int ans = 1;
    char w1 = '\0';
    char wl = '\0';
    for(int i = 0; i < N; i++){
        scanf("%s", w[i]);
        w1 = w[i][0];
        if(i > 0){
            if(w1 != wl){
                ans = 0;
            }
            for(int j = 0; j < i; j++){
                if(strcmp(w[j], w[i]) == 0){
                    ans = 0;
                    break;
                }
            }
        }
        wl = w[i][strlen(w[i]) - 1]; 
    }
    printf("%s\n", ans ? "Yes": "No");
    return 0; 
}

Measured memory_bytes: 128
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	static final PrintStream out = System.out;
	static Scanner sc = new Scanner(System.in);
	static final long Mod = 1000_000_007L;
	public static void main(String[] args) {
		Main main = new Main();
		main.solve();
		System.exit(0);
	}

	void solve() {
		String S = next();

		boolean f = false;
		for(int i=1;i<S.length();i++) {
			if(S.substring(i-1,i).equals(S.substring(i,i+1))) {
				f = true;
				break;
			}
		}
		if(f)out.println("Bad");
		else out.println("Good");


	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)a[i] = nextInt();
		return a;
	}
	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)a[i] = nextLong();
		return a;
	}
	public int nextInt() {
		return Integer.parseInt(next());
	}
	public long nextLong() {
		return Long.parseLong(next());
	}
	public String next() {
		return sc.next();
	}


}

Measured memory_bytes: 22612
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Text;

class Program
{
    static void Main(string[] args)
    {
        var N = int.Parse(Console.ReadLine());
        var A = new List<long>();
        var line = Console.ReadLine().Split(" ");
        for (int i = 0; i < N; i++)
        {
            A.Add(long.Parse(line[i]));
        };

        A.Sort((a, b) => (int)(b - a));

        long sum = A[0];
        var index = 1;
        var isTwice = false;
        for (int i = 0; i < N - 2; i++)
        {
            if (isTwice)
            {
                sum += A[index++];
                isTwice = false;
            }
            else
            {
                sum += A[index];
                isTwice = true;
            }
        }
        Console.WriteLine(sum);
    }
}

Measured memory_bytes: 49356
N, M, X = map(int, input().split())
A = [list(map(int, input().split())) for _ in range(N)]
ans = float("inf")

for i in range(2**N):
    now = bin(i)[2:].zfill(N)  # now[i]: 参考書iを買う
    res = 0
    An = [0] * M
    for n in range(N):
        if now[n] == "1":
            res += A[n][0]
            An = [An[j] + A[n][j+1] for j in range(M)]
    if min(An) >= X:
        ans = min(ans, res)

if ans == float("inf"):
    print(-1)
else:
    print(ans)


Measured memory_bytes: 9220
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define Would
#define you
#define please

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


	int N;
	cin >> N;
	int A[200001];
	rep(i, N) cin >> A[i];
	sort(A, A + N);
	int tukatta[200001] = {};
	
	int kotae = 0;
	for (int beki = 30; beki >= 1; beki--) {
		int i1 = lower_bound(A, A + N, 1 << beki) - A;
		int i2 = lower_bound(A, A + N, 1 << (beki - 1)) - A;

		int kazu = 0;
		for (int j = i1 - 1; j >= i2; j--) {
			while (kazu < N && A[kazu] + A[j] <= 1 << beki) {
				if (A[kazu] + A[j] == 1 << beki && kazu != j && tukatta[kazu] == 0 && tukatta[j] == 0) {
					kotae++;
					tukatta[kazu] = 1;
					tukatta[j] = 1;
					break;
				}
				kazu++;
			}
		}

	}
	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 1792
//四則演算 #pragma GCC target("avx")
//並列計算 #pragma GCC optimize("O3")
//条件分岐を減らす #pragma GCC optimize("unroll-loops")
//浮動小数点演算 #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int i=(a);i<(n);++i)
#define eFOR(i,a,n) for(int i=(a);i<=(n);++i)
#define rFOR(i,a,n) for(int i=(n)-1;i>=(a);--i)
#define erFOR(i,a,n) for(int i=(n);i>=(a);--i)
#define each(i, a) for(auto &i : a)
#define SORT(a) sort(a.begin(),a.end())
#define rSORT(a) sort(a.rbegin(),a.rend())
#define fSORT(a,f) sort(a.begin(),a.end(),f)
#define all(a) a.begin(),a.end()
#define out(y,x) ((y)<0||h<=(y)||(x)<0||w<=(x))
#define tp(a,i) get<i>(a)
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, const T& b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, const T& b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& a : v)is >> a; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }
template<class T>inline void print(const T& a) { cout << a << "\n"; }
template<class T, class... Ts>inline void print(const T& a, const Ts&... ts) { cout << a << " "; print(ts...); }
template<class T>inline void print(const vector<T>& v) { for (int i = 0; i < v.size(); ++i)cout << v[i] << (i == v.size() - 1 ? "\n" : " "); }
template<class T>inline void print(const vector<vector<T>>& v) { for (auto& a : v)print(a); }
inline string reversed(const string& s) { string t = s; reverse(all(t)); return t; }

int main() {
    init();

    ll a, b, n; cin >> a >> b >> n;
    print(min(b - 1, n) % b * a / b);

    return 0;
}

Measured memory_bytes: 3604
class Prime():
    def __init__(self, n):
        self.p = []
        self.d = [0] * n

        for i in range(2, n):
            if self.d[i] == 0:
                self.p.append(i)
                for j in range(i, n, i):
                    if self.d[j] == 0:
                        self.d[j] = i

        self.ind = [-1] * n
        for i in range(len(self.p)):
            self.ind[self.p[i]] = i

    def prime_factorization_index(self, x):
        l = []
        while x != 1:
            if l == [] or l[-1] != self.ind[self.d[x]]:
                l.append(self.ind[self.d[x]])
            x //= self.d[x]
        return l

    def num_prime(self):
        return len(self.p)

def main():

    from math import gcd
 
    n = int(input())
    a = list(map(int, input().split()))
 
    g = a[0]
    for i in range(1, n):
        g = gcd(g, a[i])
        if g == 1:
            break
    else:
        print('not coprime')
        exit()

    p = Prime(10**6 + 1)

    tf = [False] * p.num_prime()

    for i in range(1, n):
        l = p.prime_factorization_index(a[i])
        for i in l:
            if tf[i]:
                print('setwise coprime')
                exit()
            else:
                tf[i] = True

    print('pairwise coprime')

main()

Measured memory_bytes: 189052
# include <bits/stdc++.h>
#pragma GCC optimize("Ofast")

# define pb push_back
# define fr first
# define sc second
# define mk make_pair

using namespace std;

const long long linf = 1e18 + 7;
const int inf = 1e9 + 7;
const int N = 1e5 + 5;

typedef long long ll;

int n, x;
set <int> st;

int main(){
      cin >> n;

      while(n --){
            cin >> x;
            st.insert(x);
      }

      cout << st.size() << endl;
}


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

int main()
{
	std::string str;
	while(true)
	{
		std::cin >> str;
		if ("0" == str)
		{
			return 0;
		}

		int sum = 0;
		for (char c : str)
		{
			sum += static_cast<int>(c - '0');
		}
		std::cout << sum << std::endl;
	}
}


Measured memory_bytes: 3160
#include<iostream>
int main() {
	int x;
	std::cin >> x;
	int s = x % 60;
	int a = (x - s)/60;
	int m = a % 60;
	int h = (x - m * 60 - s) / 3600;
	std::cout << h << ":" << m << ":" << s << std::endl;
}

Measured memory_bytes: 1168
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define MOD 1000000007
#define ff first
#define ss second
#define pb push_back
#define N 100010

ll inv[N], fac[N], finv[N];

void make()
{
	fac[0] = fac[1] = 1;
	inv[1] = 1;
	finv[1] = finv[0] = 1;
	for(int i = 2; i < N; ++i)
	{
		fac[i] = i * fac[i - 1] % MOD;
		inv[i] = MOD - MOD/i * inv[MOD % i] % MOD;
		finv[i] = inv[i] * finv[i - 1] % MOD;
	}
}

ll C(ll n, ll k)
{
	if(n < k || n < 0) return 0;
	return fac[n] * finv[n - k] % MOD* finv[k] % MOD;
}

ll gcd(ll a, ll b)
{
	if(b == 0)
		return a;
	return gcd(b, a % b);
}
int n, m;
vector<int> g[N];
ll dp[N];
ll dpf(int i)
{
	if(dp[i] >= 0)
		return dp[i];
	for(auto e : g[i])
		dp[i] = max(dp[i], 1 + dpf(e));
	if(dp[i] == -1)
		dp[i] = 0;
	return dp[i];
}

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

	memset(dp, -1, sizeof(dp));
	cin >> n >> m;
	int x, y;
	for (int i = 0; i < m; ++i)
	{
		cin >> x >> y;
		g[x].pb(y);
	}
	ll ans = 0;
	for (int i = 1; i <= n; ++i)
	{
		ans = max(ans, dpf(i));
	}
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 8832
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

using namespace std;

typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
    os << "[ ";
    REP(i, vec.size()) {
        os << vec[i] << " ";
    }
    os << "]";

    return os;
}

ll pow_mod(ll a, ll p) {
    ll res = 1;
    while(p) {
        if (p & 1) res = (res * a) % MOD;
        a = (a * a) % MOD;
        p >>= 1;
    }

    return res;
}


ll mod_inv(ll a, ll m) {
    ll b = m, u = 0, v = 1;
    while(a) {
        ll t = b / a;
        swap(b -= t * a, a);
        swap(u -= t * v, v);
    }

    return (u % m + m) % m;
}

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


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

    unordered_map<ll, int> m;
    ll a;
    bool f=true;
    REP(i, N) {
        cin >> a;
        if(m[a]) f = false;
        m[a]++;
    }

    if (f) cout << "YES" << endl;
    else cout << "NO" << endl;
}


Measured memory_bytes: 8520
N, K = map(int, input().split())
P = list(map(lambda x: int(x)-1, input().split()))
C = list(map(int, input().split()))
# print(C)
ans = -float("inf")
hoge = K
for i in range(N):
    K = hoge
    start_point = i
    visited = set()
    ruisekiwa = [0]
    tmp = 0
    for j in range(min(K, N)):
        # とりあえず回数の許す限り次のマスへ行く
        # ループしているならブレイク, 目的値に到着したことがある
        if P[start_point] in visited:
            break
        visited.add(P[start_point])
        ruisekiwa.append(ruisekiwa[-1]+C[P[start_point]])
        start_point = P[start_point]
    if ruisekiwa[-1] < 0:
        ans = max(ans, max(ruisekiwa[1:]))
        continue
    # ループが可能な場合
    if K > len(visited):
        # 可能な限りループする（最後の1回はループしない）
        tmp += ruisekiwa[-1]*(K//len(visited)-1)
        K %= len(visited)  # 余ったループ回数
        # 左側はもう1ループして，余力のループを行った場合．
        # 右側は最後の1ループを理想的なところで止めた場合
        # print("K %= N のあとの : ", K)
        if K != 0:
            tmp += max(ruisekiwa[-1]+max(ruisekiwa[1:K+1]), max(ruisekiwa[1:]))
        else:
            tmp += max(ruisekiwa)
        ans = max(ans, tmp)
    else:
        ans = max(ans, max(ruisekiwa[1:]))
print(ans)


Measured memory_bytes: 168792
program Typical_Strairs
    implicit none
    integer(8):: n,m,i,a
    integer(8),allocatable::dp(:)
    integer(8),parameter:: md=1000000007
    logical,allocatable:: safe(:)

    read*, n,m
    allocate(dp(0:n),safe(n))
    safe(:) = .true.
    do i=1,m
        read*, a
        safe(a) = .false.
    end do

    dp(0) = 1
    dp(1:) = 0    

    do i=0,n-1
        if (safe(i+1)) dp(i+1) = mod(dp(i+1) + dp(i),md)
        if (safe(i+2) .and. i+2 <= n) dp(i+2) = mod(dp(i+2) + dp(i),md) 
    end do

    print*, dp(n)

end program Typical_Strairs

Measured memory_bytes: 1408
INTMAX = (1<<31) - 1

def ans():
    for i in range(k):
        x = i + OFS
        A[x] = arr[i]
        while True:
            if(x <= 0):
                break
            x = (x - 1)//2
            l = A[x*2+1]
            r = A[x*2+2]
            A[x] = l if l < r else r#min(tree[left],tree[right])
    res = []
    c = 0
    for i in range(_N-k):
        res.append(A[0])
        x = c + OFS
        A[x] = arr[i+k]
        while True:
            if(x <= 0):
                break
            x = (x - 1)//2
            l = A[x*2+1]
            r = A[x*2+2]
            A[x] = l if l < r else r
        c += 1
        if(c == k):
            c = 0
    res.append(A[0])
    print(*res)

_N,k = map(int, input().split())
*arr, = map(int,input().split())
if(k==1):
    print(*arr)
else:
    N = 2**(_N-1).bit_length()
    A = [INTMAX]*(2*N)
    OFS = N - 1
    ans()



Measured memory_bytes: 120576