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

const double PI = 3.14159265358979323846;
using namespace std;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<ll, ll> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

std::istream &operator>>(std::istream &in, set<int> &o) {
    ll a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ifstream myfile("C:\\Users\\riku\\Downloads\\0_00.txt");
//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
const int mod = 1000000007;
//const ll mod = 1e10;
typedef priority_queue<string, vector<string>, greater<string> > PQ_ASK;

int main() {
    int n, k, gu, choki, par;
    cin >> n >> k >> gu >> choki >> par;

    string t;
    cin >> t;
    vector<bool> is_win(t.size(), false);

    auto was_win = [&](int i, char c) {
        if (i < 0) return false;
        if (t[i] != c) return false;
        bool b = is_win[i];
        return b;
    };

    rep(i, n) {
        if (was_win(i - k, t[i])) {
            is_win[i] = false;
        } else {
            is_win[i] = true;
        }
    }


    ll ans = 0;
    rep(i, n) {
        if (!is_win[i]) continue;
        if (t[i] == 'r') {
            ans += par;
        } else if (t[i] == 's') {
            ans += gu;
        } else {
            ans += choki;
        }
    }
    cout << ans << endl;


}

Measured memory_bytes: 512
#include <sys/time.h>

#include <iostream>
#include <iomanip>
#include <algorithm>
#include <utility>
#include <cmath>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <utility>
#include <cctype>

using namespace std;

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mkp(a, b) make_pair(a, b)

const double time_limit = 1.9;
double start;

unsigned rando() {
	static unsigned y = 2463534242;
    y ^= y << 13;y ^= y >> 17;y ^= y << 5;
    return y;
}


double sec() {
	struct timeval tv;
    gettimeofday(&tv, NULL);
    return tv.tv_sec + tv.tv_usec * 1e-6;
}

double pastTime() {
	return sec() - start;
}

int d;

int c[26];
int s[365][26];

int score(vector<int>& t) {
	int score = 0;
	vector<int> last(26,0);
	rep(i, d) {
		score += s[i][t[i]];
		last[t[i]] = (i + 1);

		rep(j,26) {
			score -= ((i + 1) - last[j]) * c[j];
		}
		//cout  << score << endl;

	} 


	return score;

}

void output(vector<int>& t) {
	rep(i, d) {
		cout << t[i] + 1 << endl;
	}
}


int main() {
	


	cin >> d;
	rep(i, 26) {
		cin >> c[i];
	} 
	rep(i, d) {
		rep(j,26) {
			cin >> s[i][j];
		}
	}
	start = sec();
	vector<int> t(d);

	rep(i, d) {
		t[i] = rando() % 26;
	}

	int cur = score(t);


	while(true) {
		double cur_time = pastTime();
		if (cur_time > time_limit) {
			break;
		}
		//vector<int> nt = t;
		int size = (int) ((time_limit - cur_time) / time_limit * 3.0) + 1;
		
		for (int loop = 0; loop < 100; loop++) {
			stack<P> cd;
			rep(i ,size) {
				int cur_d = rando() % d;
				int cur_c = rando() % 26;
				cd.push(mkp(cur_d, t[cur_d]));
 
				t[cur_d] = cur_c;
			}
			int next = score(t);
			if (cur < next) {
				cur = next;
			} else {
				while(!cd.empty()) {
					auto cur = cd.top();
					t[cur.first] = cur.second;
					cd.pop();
				}
 
			}
	
		}
	}

	output(t);

	//cout << "score:" <<  << endl;

	return 0;
}


Measured memory_bytes: 3232
#include<stdio.h>
#include<string>
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<list>
using namespace std;

int main(){
	int N;
	cin >> N;
	if (N % 10 == 9) {
		cout << "Yes" << endl;
		return 0;
	}
	N = (N - N % 10)/10;
	if (N == 9) cout << "Yes" << endl;
	else  cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0
for a in range(A+1):
  for b in range(B+1):
    for c in range(C+1):
      value = 500*a + 100*b + 50*c 
      if value == X:
      	ans += 1
print(ans)


Measured memory_bytes: 2940
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <bits/stdc++.h>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int H,W;
int a[510][510];
struct ST{
  int x,y,z,w;
};
vector<ST> ans;
int main() {
  cout << fixed << setprecision(15);
  cin >> H >> W;
  REP(i,H)
    REP(j,W)
      cin >> a[i][j];
  REP(i,H)
    REP(j,W)
      if (a[i][j]%2==1) {
        if (j==W-1) {
          if (i!=H-1) {
            ans.pb({i,j,i+1,j});
            a[i+1][j]++;
          }
        } else {
          ans.pb({i,j,i,j+1});
          a[i][j+1]++;
        }
      }
  cout << ans.size()<< endl;
  REP(i,ans.size())
    cout << ans[i].x+1 << " " << ans[i].y+1 << " " << ans[i].z+1 << " " << ans[i].w+1 << endl;
  return 0;
}


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

int main (){
  string S;
  cin >> S;
  
  int siz = S.size();
  if(S.at(siz-1) == 's')
    S.append("es");
  else
    S.append("s");
    
  cout << S << endl;
}

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

int main(){
	int n;
    int A[100100];
	vector<long long> v;
	
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> A[i];
	}
	sort(A,A+n);
	reverse(A,A+n);
	
	for(int i=1;i<n;i++){
		if(A[i-1]==A[i]){
			v.push_back(A[i]);
			i++;
		}
		if(v.size()==2){
			cout << v[0]*v[1] << endl;
			return 0;
		}
	}
	
	cout << 0 << endl;
	return 0;
}


Measured memory_bytes: 640
#define D(x) cout << #x " = " << x << endl
#define DD(x, y) cout << "(" #x ", " #y ") = (" << x << ", " << y << ")" << endl
#define DDD(x, y, z) cout << "(" #x ", " #y ", " #z ") = (" << x << ", " << y << ", " << z << ")" << endl
#define DV(v) for (auto __macro_vi : v){ cout << __macro_vi << " ";} cout << endl;
#define DA(a, n) for (int __macro_i = 0; __macro_i < n; ++__macro_i) { cout << a[__macro_i] << " "; } cout << endl;
#define REP(i, n) for (int i = 0; i < n; ++i)
#define ALL(v) (v).begin(), (v).end()
#include<iostream>
#include<vector>
#include<cassert>
#include<cmath>
template<class T, class U> std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p){ os << "(" << p.first << ", " <<  p.second << ")"; return os; }

using namespace std;
using ll = long long;
int n;
ll k;
vector<int> a;
vector<int> b;

bool f(ll v) {
    if (v == -1) return false;
    ll kt = k;
    REP(i, n) {
        ll train = max(a[i] - v / b[i], 0LL);
        kt -= train;
        if (kt < 0) return false;
    }
    return true;
}

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n >> k;
    a = vector<int>(n);
    b = vector<int>(n);
    REP(i, n) cin >> a[i];
    REP(i, n) cin >> b[i];
    sort(ALL(a));
    sort(ALL(b));
    reverse(ALL(b));
    ll mx = 0;
    ll mn = 0;
    REP(i, n) mx = max(mx, (ll)a[i] * b[i]);
    while(mx > mn) {
        ll mid = (mn + mx) / 2;
        // DDD(mn, mx, mid);
        // D(f(mid));
        if (f(mid)) mx = mid;
        else mn = mid + 1;
    }
    cout << mx << endl;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <string.h>

#define MAX_N 100000
#define REMOVED '2'

int main() {
  char S[MAX_N];

  char stack[MAX_N];
  int stack_top;
  int N;
  int has_changed;
  int i;
  int result;

  scanf("%s", S);
  N = strlen(S);
  stack[0] = S[0];
  stack_top = 0;
  result = 0;
  for (i = 1; i < N; i++) {
    if (stack_top >= 0 && S[i] != stack[stack_top]) {
      result += 2;
      stack_top--;
    } else {
      stack_top++;
      stack[stack_top] = S[i];
    }
  }

  printf("%d\n", result);

  return 0;
}


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

int main(){

    int d;
    cin>> d;

    if(d==22){
        cout << "Christmas Eve Eve Eve" << endl;
    }else if(d==23){
        cout << "Christmas Eve Eve" << endl;
    }else if(d==24){
        cout << "Christmas Eve" << endl;
    }else if(d==25){
        cout << "Christmas" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mod 1000000007
#define ff first
#define ss second
using namespace std;
//ll arr[1000002];
/*ll power(ll x,ll y)
{
    ll res=1;
    while(y>0)
    {
        if(y%2==1)
            res=(res*x)%mod;
        x=(x*x)%mod;
        y=y/2;
    }
    return res;
}*/

int main()
{
ll a,b;
cin>>a>>b;
if(a>=6 && a<=12)
    cout<<b/2<<endl;
else if(a<=5)
    cout<<0<<endl;
else
    cout<<b<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
typedef pair<int, int> P;

int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<string> st;
  FOR(i,0,N) {
    string s;
    cin >> s;
    st.insert(s);
  }
  cout << st.size() << endl;
}


Measured memory_bytes: 19232
#include<stdio.h>
#include<string.h>
int main()
{
	char s[55];
	char t[55];
	char ans[55];
	char ans1[55];
	int i=0,j=0,n,min=100,cishu=0;
	scanf("%s",&s);
	scanf("%s",&t);
	strcpy(ans,s);
	if(strlen(s)<strlen(t))
	{
		printf("UNRESTORABLE\n");
		return 0;
	}
	for(i=0;i<=strlen(s)-strlen(t);i++)
	{
		cishu=0;
		strcpy(ans,s);
		for(j=0;i+j<strlen(s),j<strlen(t);j++)
		{
			if((ans[i+j]==t[j])||(ans[i+j]=='?'))
			{
				if((ans[i+j]=='?')&&(t[j]!='a'))
					cishu++;
				ans[i+j]=t[j];
			}
			else
				break;
		}
		if(j==strlen(t))
		{
			for(n=0;n<strlen(s);n++)
			{
				if(ans[n]=='?')
					ans[n]='a';
			}
			if(cishu<=min)
			{
				min=cishu;
				strcpy(ans1,ans);
			}
		}
	}
	if(min!=100)
		printf("%s\n",ans1);
	else
		printf("UNRESTORABLE\n");
	return 0;
}

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

int main() {
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    // dp[i][j]:末端がi-1,j-1なる連続部分文字列で最長のやつの長さ
    vector<vector<int>> dp(n + 1, vector<int>(n + 1, 0));
    for (int i = 1; i <= n; i++) {
        for (int j = 1; j <= n; j++) {
            if (s[i - 1] == s[j - 1]) {
                dp[i][j] = min(dp[i - 1][j - 1] + 1, abs(i - j));
                ans = max(ans, dp[i][j]);
            } else {
                dp[i][j] = 0;
            }
        }
    }
    cout << ans << endl;
}

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

int main(){
  int n,array[100],array2[100],array3[100]={},array4[100]={},anskouho[201]={},i,j;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>array[i];
  }
  for(i=0;i<n;i++){
    cin>>array2[i];
  }
  for(i=0;i<n;i++){
    for(j=0;j<=i;j++){
      array3[i]+=array[j];
    }
  }
  for(i=0;i<n;i++){
    for(j=i;j<n;j++){
      array4[i]+=array2[j];
    }
  }
  for(i=0;i<n;i++){
    anskouho[i]=array3[i]+array4[i];
  }
  sort(anskouho,anskouho+n);
  cout<<anskouho[n-1]<<endl;
}

Measured memory_bytes: 256
k, n = gets.chomp.split(' ').map(&:to_i)
arr = gets.chomp.split(' ').map(&:to_i).sort
pre = arr[0]
max = 0
(1...n).each do |i|
  cur = arr[i]
  max = [max, arr[i] - pre].max
  pre = cur
end
max = [max, arr.first + (k - arr.last)].max
puts k - max

Measured memory_bytes: 22256
#include<cmath>
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long int ll;
const int MAXN=1e5+1;
ll n,N,arr[MAXN];
ll chafen[MAXN],sum[MAXN];
inline ll read(){
	ll x=0,f=1;char c=getchar();
	for(;c<'0'||c>'9';c=getchar()) if(c=='-') f=-1;
	for(;c>='0'&&c<='9';c=getchar()) x=x*10+c-'0';
	return x*f;
}
inline ll getsum(int Start,int End){
	return abs(arr[Start]-arr[End]);
}
int main(){
	n=read();
	for(int i=1;i<=n;++i) arr[i]=read();
	for(int i=1;i<=n;++i) chafen[i]=abs(arr[i]-arr[i-1]);
	for(int i=1;i<=n;++i) sum[i]=sum[i-1]+chafen[i];
	printf("%lld\n",sum[n]-sum[2]+getsum(0,2)+getsum(n,0));
	for(int i=2;i<n;++i) printf("%lld\n",sum[i-1]+sum[n]-sum[i+1]+getsum(i-1,i+1)+getsum(n,0));
	printf("%lld\n",sum[n-1]+getsum(n-1,0));
	return 0;
}

Measured memory_bytes: 3584
#include<stdio.h>
#include<stdlib.h>

int cmp1(const void *a, const void *b){
	return *((char *)a) - *((char *)b);
}
int cmp2(const void *a, const void *b){
	return *((char *)b) - *((char *)a);
}

int ff(int a,int b){
	int m,mm;
	int i;
	char s[13]={0};
	/*
	for(i = 5;i >= 0;i--){
		s[i] = a%10 + '0';
		a /= 10;
		if(a==0)break;
	}
	for(;i >= 0;i--)s[i] = '0';
	*/
	sprintf(s,"%d000000",a);
	s[b] = '\0';

	qsort(s,b,sizeof(char),cmp1);
	m = atoi(s);
	qsort(s,b,sizeof(char),cmp2);
	mm = atoi(s);

	return mm-m;
}

int main(){
	int i,j,a[100],l,ii,jj;
	int q,w,e,r,t,y;

	while(scanf("%d%d",&a[0],&l),l){
		for(i = 1;1;i++){
			a[i] = ff(a[i-1],l);
			q = 0;
			for(j = 0;j < i;j++){
				if(a[i] == a[j]){
					ii = i;
					jj = j;
					q = 1;
					break;
				}
			}
			if(q)break;
		}
		printf("%d %d %d\n",jj,a[jj],ii-jj);
	}
	return 0;
}

/*
959000 6
95900 6
9590 6
959 6
950900 6
920097 6
920079 6
919600 6
91960 6
9196 6
919060 6
862632 6
750843 6
55555 5
2 1
782464 6
782457 6
782446 6
779944 6
23 2
23 3
23 4
23 5
23 6
631764 6
6174 4
549945 6
495 3
105 3
104642 6
707813 6
191985 6
27605 5
171941 6
859443 6
188265 6
682092 6
94354 6
9983 6
90499 6
904909 6
904099 6
903980 6
90398 6
903908 6
903890 6
90389 6
903809 6
903098 6
903089 6
831701 6
831699 6
831600 6
83160 6
8316 6
831592 6
831570 6
99989 5
99964 5
999794 6
383342 6
383336 6
887 3
960 3
96 3
96 2
50005 6
500005 6
500 3
50 3
5 3
5 1
499994 6
0 0
*/





			

Measured memory_bytes: 620
use proconio::{fastout, input};

pub fn floor_sum(n: i64, m: i64, a: i64, b: i64) -> i64 {
    let mut ret = 0;
    let (mut a, mut b) = (a, b);

    if a >= m {
        ret += (n - 1) * n * (a / m) / 2;
        a %= m;
    }
    if b >= m {
        ret += n * (b / m);
        b %= m;
    }

    let y_max = (a * n + b) / m;
    let x_max = y_max * m - b;
    if y_max == 0 {
        ret
    } else {
        ret += (n - (x_max + a - 1) / a) * y_max;
        ret += floor_sum(y_max, a, m, (a - x_max % a) % a);
        ret
    }
}

#[fastout]
fn main() {
    input! {
        t: usize,
        nmab: [(usize, usize, usize, usize); t],
    }
    for (n, m, a, b) in nmab {
        let ans = floor_sum(n as i64, m as i64, a as i64, b as i64);
        println!("{}", ans);
    }
}


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

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

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

	int count = 0;

	for( int i = 1; i < n-1; ++i ) {
		int a = p.at( i-1 );
		int b = p.at( i );
		int c = p.at( i+1 );

		if( min( { a, b, c } ) != b && max( { a, b, c } ) != b ) {
			count += 1;
		}
	}

	cout << count << endl;
}


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

int main(){
  int h,w,k,ans=0;
  cin>>h>>w>>k;
  vector<string> s(h);
  for(int i=0; i<h; i++){
    cin>>s[i];
  }
  for(int is=0; is<(1<<h); is++){
    for(int js=0; js<(1<<w); js++){
      int cnt=0;
      for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
          if(is&(1<<i))continue;
          if(js&(1<<j))continue;
          if(s[i][j]=='#') cnt++;
        }
      }
      if(cnt==k)ans++;
    }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 3624
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    long long N, ans = 0;
    cin >> N;
    for(int i = 1; i < N + 1; ++i)
    {
        if(i % 5 != 0 && i % 3 != 0) ans += i;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3632
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val (N, M) = readInts().map { it.toLong() }

    print(when {
        M > 1  && N > 1  -> (M - 2) * (N - 2)
        M == 1L && N > 1  -> N - 2
        M > 1  && N == 1L -> M - 2
        M == 1L && N == 1L -> 1
        else -> throw Error()
    })
}

Measured memory_bytes: 37876
n = int(input())
inf = 10 ** 9
dp = [inf] * (n+1)
dp[0] = 0
for i in range(n):
    dp[i+1] = min(dp[i]+1, dp[i+1])
    j, k = 1, 1
    while (i + 6**j) <= n:
        dp[i + 6**j] = min(dp[i]+1, dp[i + 6**j])
        j += 1
    while (i + 9**k) <= n:
        dp[i + 9**k] = min(dp[i]+1, dp[i + 9**k])
        k += 1
print(dp[-1])

Measured memory_bytes: 3828
/*---Author:HenryHuang---*/
#include<bits/stdc++.h>
using namespace std;
const int maxn=3e3+5;
int n,p;
int ksm(int a,int b,int p){
	int ans=1;
	while(b){
		if(b&1) ans=ans*a%p;
		b>>=1,a=a*a%p;
	}
	return ans;
}
int C[maxn][maxn],S[maxn][maxn];
void init(){
	C[0][0]=S[0][0]=1;
	for(int i=1;i<=n+1;++i){
		C[i][0]=1;
		for(int j=1;j<=i;++j){
			S[i][j]=(S[i-1][j-1]+1ll*j*S[i-1][j]%p)%p;
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%p;
		}
	}
}
int a[32769],b[32769];
int c[32769],d[32769];
int p1(int x){
	return 1ll*a[x&0x00007fff]*b[x>>15]%p;
}
int p2(int x){
	return 1ll*c[x&0x00007fff]*d[x>>15]%(p-1);
}
int main(){
	ios::sync_with_stdio(0);
	cin.tie(0),cout.tie(0);
	cin>>n>>p;init();
	a[0]=1;
	for(int i=1;i<=32768;++i){
		a[i]=1ll*a[i-1]*2%p;
	}
	b[0]=1,b[1]=a[32768];
	for(int i=2;i<=32768;++i){
		b[i]=1ll*b[i-1]*b[1]%p;
	}
	c[0]=1;
	for(int i=1;i<=32768;++i){
		c[i]=1ll*c[i-1]*2%(p-1);
	}
	d[0]=1,d[1]=c[32768];
	for(int i=2;i<=32768;++i){
		d[i]=1ll*d[i-1]*d[1]%(p-1);
	}
	int ans=0;
	for(int i=0;i<=n;++i){
		int tmp=1ll*p1(p2(n-i))*C[n][i]%p,owo=0;
		if(i&1) tmp=p-tmp;
		for(int j=0;j<=i;++j){
			owo=(owo+1ll*S[i+1][j+1]*p1(1ll*(n-i)*j%(p-1))%p)%p;
		}
		(ans+=1ll*tmp*owo%p)%=p;
	}
	cout<<ans<<'\n';
	return 0;
}


Measured memory_bytes: 59276
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define dunk(a) cout << (a) << endl
#define rall(a) (a).rbegin(),(a).rend()
const int INF = 2e9;
using namespace std;
using Graph = vector<vector<int>>;
typedef pair<int,int> P;
typedef long long ll;

int main(){
    int h, w; cin >> h >> w;
    vector<vector<char>> g(h+2,vector<char> (w+2,'#'));

    rep(i,h){
        rep(j,w){
            cin >> g[i+1][j+1];
        }
    }

    rep(i,h+2){
        rep(j,w+2){
            cout << g[i][j];
        }
        cout << endl;
    }

}

Measured memory_bytes: 256
#include<cmath>    
#include<queue>    
#include<vector>    
#include<cstdio>    
#include<ctime>   
#include<cstring>    
#include<iostream>    
#include<algorithm>    
#define INF 0x3f3f3f3f
#define MAXN 100
using namespace std;
int read()
{
    int f=1,x=0;char s=getchar();   
    while(s<'0'||s>'9'){if(s=='-')f=-1;s=getchar();}  
    while(s>='0'&&s<='9'){x=x*10+s-'0';s=getchar();}
    return x*f;
}
int n,candy[5][MAXN+5],dir[2][2]={{1,0},{0,1}},ans;
void DFS(int x,int y,int sum){
	if(x<=0||y<=0||x>2||y>n) return ;
	sum+=candy[x][y];
	if(x==2&&y==n)
	{
		if(sum>ans)
			ans=sum;
		return ;
	}
	for(int i=0;i<=1;i++)
		DFS(x+dir[i][0],y+dir[i][1],sum);
	return ;
}
int main() 
{
	n=read();
	for(int j=1;j<=2;j++)
		for(int i=1;i<=n;i++)
			candy[j][i]=read();
	DFS(1,1,0);
	printf("%d\n",ans);
    return 0; 
} 


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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
// #define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

int dx[4] = { 0,1,0,-1 };
int dy[4] = { 1,0,-1,0 };




void solve() {
    int r; cin >> r;
    cout << 3*r*r << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


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

// int/long:		-2,147,483,648 - 2,147,483,647 (-2^31 <= int < 2^31)
// long/long long:	-9,223,372,036,854,775,808 - 9,223,372,036,854,775,807 (-2^63 <= long < 2^63)

// lower_bound(A.begin(), A.end(), N)
// upper_bound(...

// A.erase(unique(A.begin(), A.end()), A.end())

// bit: &/and, |/or, ^/xor, ~/not

// getline(cin, String)
// while (getline(cin, S)) {}

// cout <<fixed <<setprecision(10)

// priority_queue<int> q;
// priority_queue<int, vector<int>, less<int>> q; // Default: vector, less
// priority_queue<vector<int>, vector<vector<int>>, greater<vector<int>>> q;

// Graph
// Warshall-Floyd: Distance between each node, N^3
// Dijkstra: Distance from the start node, N^2
// DFS(Depth-First Search)

//
// Notes
//
// When specified less than N, try full scan.
// RE: empty vector
// Check Qs
// long/int
// xor -> count each bit
// Check values
// 	1,000,000 -> Loop
// 	100,000	-> vector(int:400KB, long:800KB) 

#define	INF (1<<30)
//1,073,741,824
//= 536,870,912 *2

#define	MOD 1000000007

#define	Rep0(i, n)	for (int i=0; i<n; i++)
#define	Rep1(i, n)	for (int i=1; i<=n; i++)
#define Sort(P)	sort(P.begin(), P.end())
#define Rev(P)	reverse(P.begin(), P.end())

int	main() {
	int N, M;
	cin >>N >>M;
	vector<int> A(N, -1);
	Rep0(i, M) {
		int s, c;
		cin >>s >>c;
		s--;
		if (c==A.at(s))
			continue;
		if (A.at(s)==-1)
			A.at(s)=c;
		else {
			cout <<-1 <<endl;
			return 0;
		}
	}
	if (1==N)
		if (-1==A.at(0)) {
			cout <<0 <<endl;
			return 0;
		}
	if (1!=N)
		if (0==A.at(0)) {
			cout <<-1 <<endl;
			return 0;
		}
	if (-1==A.at(0))
		A.at(0)=1;
	for (int i=1; i<N; i++)
		if (-1==A.at(i))
			A.at(i)=0;
	Rep0(i, N)
		cout <<A.at(i);
	cout <<endl;
	return 0;
}



Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    char s[4];
    scanf("%s",s);
    int ans = 0;
    for(int i = 0;i < 4;i++)
    {
        if(s[i] == '2')
            ans++;
    }
    printf("%d\n",ans);
    return 0;
}


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

bool dfs(int v, int t, vector<vector<int>> &mat, vector<bool> &used) {
	if(v == t) return true;

	used[v] = true;
	const int n = mat.size();
	for(int i = 0; i < n; ++i) {
		if(mat[v][i] > 0 && !used[i] && dfs(i, t, mat, used)) {
			--mat[v][i];
			++mat[i][v];
			return true;
		}
	}

	return false;
}

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


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

	vector<vector<int>> mat(n, vector<int>(n, 0));
	while(m--) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		mat[a][b] = mat[b][a] = 1;
	}

	const int s = 0;
	const int t = n - 1;

	int flow = 0;
	vector<bool> used(n, false);
	while(dfs(s, t, mat, used)) {
		++flow;
		fill(used.begin(), used.end(), false);
	}

	while(q--) {
		int m, a, b;
		cin >> m >> a >> b;
		--a; --b;

		if(m == 1) { // connect
			mat[a][b] = mat[b][a] = 1;
			fill(used.begin(), used.end(), false);
			flow += dfs(s, t, mat, used);
		}
		else { // cut
			if(mat[a][b] != 1) {
				if(mat[b][a] == 0) swap(a, b);

				if(flow) {
					--flow;
					fill(used.begin(), used.end(), false);
					dfs(t, s, mat, used);
				}

				if(mat[a][b] == 0) {
					fill(used.begin(), used.end(), false);
					dfs(a, b, mat, used);
				}

				mat[a][b] = mat[b][a] = 0;
				fill(used.begin(), used.end(), false);
				flow += dfs(s, t, mat, used);
			}
			else {
				mat[a][b] = mat[b][a] = 0;
			}
		}

		cout << flow << "\n";
	}

	return EXIT_SUCCESS;
}

Measured memory_bytes: 2052
#!/usr/bin/env python3

def main():
    K,X = map(int, input().split())
    may_kuro_ishi = []
    for i in range(1,K+1):
        may_kuro_ishi.append(X - (K - i))
    for i in range(1,K):
        may_kuro_ishi.append(X+i)

    print(' '.join(map(str,may_kuro_ishi)))

if __name__ == "__main__":
    main()


Measured memory_bytes: 2940
//#pragma GCC optimize(3, "Ofast", "inline")
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const int mod = 1e9 + 7;
const ll infll = 1e18 + 9;
const int infint = 1e9 + 7;
const int MAXN = 3e5 + 7;
const double eps = 1e-9;
const long double pi = 3.1415926535897932384626433832795;
const long double e = 2.71828182845904523536028747135266;
inline ll read()
{
    ll kr = 1, xs = 0;char ls;ls = getchar();
    while (!isdigit(ls)){
        if (!(ls ^ 45)) kr = -1;
        ls = getchar();
    }
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs * kr;
}
// inline __int128 read128()
// {
//     __int128 kr=1,xs=0;char ls;ls=getchar();
//     while(!isdigit(ls)){
//         if(!(ls^45)) kr=-1;ls=getchar();
//     }
//     while(isdigit(ls)){
//         xs=(xs<<1)+(xs<<3)+(ls^48);ls=getchar();
//     }
//     return xs*kr;
// }
inline ull readull()
{
    ull xs = 0;char ls;ls = getchar();
    while (!isdigit(ls))ls = getchar();
    while (isdigit(ls)){
        xs = (xs << 1) + (xs << 3) + (ls ^ 48);ls = getchar();
    }return xs;
}
inline void writeull(ull x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) writeull(x / 10);
    putchar('0' + x % 10);
}
inline void write(ll x)
{
    if (x < 0){
        x *= -1;putchar('-');
    }
    if (x >= 10) write(x / 10);
    putchar('0' + x % 10);
}
// inline void write(__int128 x){
//     if(x<0){x*=-1;putchar('-');}
//     if(x>=10) write(x/10);
//     putchar('0'+x%10);
// }
///////////////////////////////////////////////////////////////////////////////////////
map<ll,ll> q;
int main()
{
    // ios_base::sync_with_stdio(0);
    // cin.tie(0),cout.tie(0);
    int t = 1;
    // t = read();
    while (t--)
    {
        ll a=read(),b=read(),c=read(),d=read();
        ll ans=max(a*c,a*d);
        ans=max(ans,b*c);
        ans=max(ans,b*d);
        cout << ans << endl;
    }
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define repr(i, n) for (int i = (n)-1; i >= 0; i--)
using namespace std;
typedef long long ll;

const int INF = 1e9;

int main() {
  int n;
  cin >> n;
  ll ans = 0;
  vector<string> s(n);
  unordered_map<string, int> mp;
  rep(i, n) {
    cin >> s[i];
    sort(s[i].begin(), s[i].end());
    if (mp.find(s[i]) == mp.end())
      mp[s[i]] = 1;
    else {
      ans += mp[s[i]];
      mp[s[i]] = ++mp[s[i]];
    }
  }

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


Measured memory_bytes: 17700
#include <bits/stdc++.h>
#define ll long long int
using namespace std;
double a[10000000];
int main(){
	int n,k;
	cin>>n>>k;double x,sum=0;double mx=-1;
	int c=0;int l=0;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<n;i++){
       // cin>>x;
        sum+=a[i];c++;
         if(c==k)c--,mx=max(mx,sum),sum-=a[l],l++;
       // cout<<sum<<" ";
	}if(c==k)mx=max(mx,sum);

//cout<<mx<<" ";
cout<<fixed<<setprecision(7)<<(mx+k)/2<<endl;
	return 0;
}


Measured memory_bytes: 1792
# B - Boxes

def main():
    N = int(input())
    A = list(map(int,input().split()))
    get = N*(N+1)//2
    if sum(A)%get!=0:
        print('NO')
        return
    k = sum(A)//get
    for i in range(N):
        d = A[(i+1)%N]-A[i]-k
        if d>0 or d%N!=0:
            print('NO')
            return
    print('YES')

main()

Measured memory_bytes: 14244
#include <stdio.h>

int main() {
    int s = 0;
    scanf("%d", &s);
    int count[1000000];
    for (int i=0; i<1000000; i++) {
        count[i] = 0;
    }
    int buf = s;
    int ans = 0;
    while (1) {
        count[buf]++;
        ans++;
        if (count[buf] > 1) break;
        if (buf%2 == 0) buf = buf/2;
        else buf = 3*buf+1;
    }
    printf("%d\n", ans);
    return 0;
}


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

constexpr int MAX_N = 8;

int N, A[3];
int l[MAX_N];

int dfs(int n, int a, int b, int c) {
  if (n == N) {
    if (a == 0 || b == 0 || c == 0) {
      return 10000;
    }
    return abs(A[0] - a) + abs(A[1] - b) + abs(A[2] - c) - 30;
  }

  int ret[4];
  ret[0] = dfs(n + 1, a + l[n], b, c) + 10;
  ret[1] = dfs(n + 1, a, b + l[n], c) + 10;
  ret[2] = dfs(n + 1, a, b, c + l[n]) + 10;
  ret[3] = dfs(n + 1, a, b, c);
  sort(ret, ret + 4);

  return ret[0];
}

int main() {
  cin >> N;
  for (int i{}; i < 3; ++i)
    cin >> A[i];
  for (int i{}; i < N; ++i)
    cin >> l[i];

  array<int, 3> a{};
  cout << dfs(0, 0, 0, 0) << endl;
  return 0;
}


Measured memory_bytes: 256
_, k, *ab = `dd`.split.map{|t|t.to_i}

sz = 0

m = [0] * (10**5+1)

ab.each_slice(2){|(a,b)| m[a] += b }

m.each_with_index do |b,i|
  
  sz += b
  if k <= sz
    puts i
    exit
  end
end

Measured memory_bytes: 21768
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>

using namespace std;
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(),(x).end()

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class X> void DEBUG(X d, T e){if(DEBUG_OUT == false)return;std::cout <<d<<" ";DEBUG(e);};
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template< typename T > using matrix = vector< vector< T > >;

//FUNCTION  


void solve(void)
{
  int N;
  cin>>N;
  vector<int> T(N+1,0),X(N+1,0),Y(N+1,0);
  bool ok = 1;
  for (int i = 1; i <= N; i++)
  {
    cin>>T[i]>>X[i]>>Y[i];
  }
  for (int i = 0; i < N; i++)
  {
    int t = T[i+1] - T[i];
    int x = X[i+1] - X[i];
    int y = Y[i+1] - Y[i];
    if(t < abs(x) + abs(y) ||t%2 != (abs(x) + abs(y))%2) ok = 0;
  }
  cout<<(ok?"Yes":"No")<<endl;
  
  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <cstring>
#include <algorithm> // sort
#include <map>
#include <string>
#include <bits/stdc++.h>

#define REP(i, n) for (long long i = 0; i < (n); i++) 
typedef long long ll;

static const ll MOD = 1000000007;
static const ll INF = 1000000000000000000LL;
using namespace std;
using pint = pair<int,int>;

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

  ll L[90];
  L[0] = 2;
  L[1] = 1;
  
  for(int i = 2; i <= 87; ++i)
  {
    L[i] = L[i-1] + L[i-2];
  }

  cout << L[n] <<  endl;
  return 0;
}



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

int main() {
  
  int N, A;
  cin >> N >> A;
  int X = N % 500;
  if (X <= A) {
    cout << "Yes" << endl;
  }
  
  else {
    cout << "No" << endl;
  }
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;

const int MOD = 1e9+7;

ll n, a, b, c, d;
map<ll, ll> m;

ll solve(ll aux){
	if(aux <= 1)
		return max(aux*d, 0LL);
	if(m.count(aux))
		return m[aux];


	ll ret=1e18;
	ret = a+(aux%2)*d + solve(aux/2);
	if(aux%2)
		ret = min(ret, a+d+solve((aux+2)/2));
	ret = min(ret, b+(aux%3)*d+solve(aux/3));
	if(aux%3)
		ret = min(ret, b+(3-aux%3)*d+solve((aux+3)/3));
	ret = min(ret, c+(aux%5)*d+solve(aux/5));
	if(aux%5)
		ret = min(ret, c+(5-aux%5)*d+solve((aux+5)/5));
	
	if(aux*d > 0)
		return m[aux] = min(ret, aux*d);
	else
		return m[aux] = ret;
}

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

	int t; cin >> t;
	while(t--){
		m.clear();
		cin >> n >> a >> b >> c >> d;
		ll ret = 1e18;
		ret = min(ret, solve(n));
		cout << ret << '\n';
	}

 	return 0;
}

Measured memory_bytes: 4412
from collections import defaultdict

n, k = map(int, input().split())

seq = list(map(int, input().split()))

count = defaultdict(int)
count[0] = 1

prefix = [0]*(n+1)
ans = 0

for i in range(n):
  pre = prefix[i+1] = (prefix[i] + seq[i] - 1)%k
  
  if i >= k - 1:
    count[prefix[i - k + 1]] -= 1
  ans += count[pre]
  count[pre] += 1
print(ans)

Measured memory_bytes: 110668
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
typedef long long ll;
namespace mp = boost::multiprecision;
using Mint = mp::cpp_int;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i,a,b) for(int i = int(a); i < int(b); i++)
#define all(v) v.begin(), v.end()
#define uni(v) v.erase(unique(all(v)), v.end())
#define sort_g(v) sort(all(v), greater<int>())
#define dump(x) cerr << #x << ' ' << '=' << ' ' << x << endl

int sum_digit(int n) {
    int sum = 0;
    while(n > 0) {
        sum += n % 10;
        n /= 10;
    }
    return sum;
}

int main() {
    int N;
    cin >> N;
    int X = sum_digit(N);
    cout << (N % X == 0 ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace         std;
#define                 int long long
#define                 pb push_back
#define                 mp make_pair
#define st(arr,a)       memset(arr,a,sizeof arr)
#define                 nl cout<<endl
#define                 real signed
#define                 endl '\n'              
#define bitcount(x)     __builtin_popcountll(x)
const int MOD = 1000000007ll;
#define forn(i,a,b)     for(int i=a;i<=b;i++)
#define rfor(i,a,b)     for(int i=a;i>=b;i--)
#define all(x)          x.begin() , x.end()
#define pi pair<int,int>
#define X first
#define Y second
#define N 314159
#define  vi vector<int>
#define  v  vector

signed main() 
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL); 
    int n;
    cin>>n;
    vi arr;
    forn(i,1,n)
    {
        int a;
        cin>>a;
        if(a==i)arr.pb(i);
    }
    
    int x=arr.size();
    int ans=0;
    //for(auto i : arr)cout<<i<<" ";nl;
    forn(i,0,x-1)
    {
        if(i!=x-1 and arr[i+1]==arr[i]+1)
        {
            ans++;
            i++;
        }
        else ans++;
    }
    cout<<ans;




     return 0;

}

//       g++ -g c.cpp ; ./a.exe

Measured memory_bytes: 1400
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
int main(){
    long long int A,B,N;
    cin>>A>>B>>N;
    long long int x=min(B-1,N);
    cout<<A*x/B<<endl;
    return 0;
}


Measured memory_bytes: 3624
n = int(input())
hs = list(map(int, input().split()))
dp = [0]*n

# cost1 = dp[i-1] + abs(dp[i-1]-dp[i])
# cost2 = dp[i-2] + abs(dp[i-2]-dp[i])
# dp[i] = min(cost1, cost2)

#for i in reversed(range(n)):
for i in range(n):
    if i == 0:
        dp[0] = 0
    elif i == 1:
        dp[1] = abs(hs[0]-hs[1])
    else:
        cost1 = dp[i-1] + abs(hs[i-1]-hs[i])
        cost2 = dp[i-2] + abs(hs[i-2]-hs[i])
        dp[i] = min(cost1, cost2)

print(dp[n-1])

Measured memory_bytes: 13980
N, M = map(int, input().split())
AB = [list(map(int, input().split())) for i in range(N)]
AB.sort(key=lambda x:x[0])
#print(AB)

money = 0
for i in range(N):
  if M >= AB[i][1]:
    money += AB[i][0] * AB[i][1]
    M -= AB[i][1]
  else:
    money += AB[i][0] * M
    M = 0
  if M == 0:
    print(money)
    break


Measured memory_bytes: 29020
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll mod=1e9+7;
    ll n,m;
    cin>>n>>m;
    int a[n],b[m];
    for(int i=1;i<=n;i++)
    cin>>a[i];
    for(int j=1;j<=m;j++)
    cin>>b[j];
    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<=n;i++)
    dp[i][0]=1;
    for(int i=0;i<=m;i++)
    dp[0][i]=1;
    for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(a[i]==b[j])
			dp[i][j]=(dp[i-1][j]+dp[i][j-1])%mod;
			else
			dp[i][j]=(dp[i-1][j]+dp[i][j-1]-dp[i-1][j-1]+mod)%mod;
		}
	}
	 cout<<dp[n][m]<<endl;
 }   


Measured memory_bytes: 15872
#include <bits/stdc++.h>
using namespace std;
const int maxn = 3001;
int n, m, a, b;
char buf[maxn][maxn];
int main() {
	scanf("%d%d%d%d", &n, &m, &a, &b);
	int row = n & 1 ? m >> 1 : 0, col = m & 1 ? n >> 1 : 0, sp = n & 1 && m & 1;
	int aa = max(a - row, 0), bb = max(b - col, 0);
	int com = (aa >> 1) + (bb >> 1), spa = aa & 1, spb = bb & 1;
	int upp = (n >> 1) * (m >> 1);
	if(com + spa + spb <= upp) {
		for(int i = 0; i < a && i < row; ++i) {
			buf[0][i << 1] = '<';
			buf[0][i << 1 | 1] = '>';
		}
		for(int i = 0; i < b && i < col; ++i) {
			buf[(n & 1) + (i << 1)][0] = '^';
			buf[(n & 1) + (i << 1 | 1)][0] = 'v';
		}
	} else if(sp && com + 1 <= upp) {
		if(spa) {
			for(int i = 0; i < b && i < col; ++i) {
				buf[(i << 1)][0] = '^';
				buf[(i << 1 | 1)][0] = 'v';
			}
			for(int i = 0; i < a && i < row; ++i) {
				buf[0][(m & 1) + (i << 1)] = '<';
				buf[0][(m & 1) + (i << 1 | 1)] = '>';
			}
			buf[n - 1][0] = '<';
			buf[n - 1][1] = '>';
			--aa;
			if(spb) {
				buf[n - 2][2] = '^';
				buf[n - 1][2] = 'v';
				--bb;
			}
		} else {
			for(int i = 0; i < a && i < row; ++i) {
				buf[0][i << 1] = '<';
				buf[0][i << 1 | 1] = '>';
			}
			for(int i = 0; i < b && i < col; ++i) {
				buf[(n & 1) + (i << 1)][0] = '^';
				buf[(n & 1) + (i << 1 | 1)][0] = 'v';
			}
			buf[0][m - 1] = '^';
			buf[1][m - 1] = 'v';
			--bb;
		}
	} else {
		puts("NO");
		return 0;
	}
	for(int i = 0; i < n >> 1 && aa + bb; ++i)
		for(int j = 0; j < m >> 1 && aa + bb; ++j) {
			if(aa && !buf[(n & 1) + (i << 1)][(m & 1) + (j << 1)] && !buf[(n & 1) + (i << 1)][(m & 1) + (j << 1 | 1)]) {
				buf[(n & 1) + (i << 1)][(m & 1) + (j << 1)] = '<';
				buf[(n & 1) + (i << 1)][(m & 1) + (j << 1 | 1)] = '>';
				--aa;
			}
			if(aa && !buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1)] && !buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1 | 1)]) {
				buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1)] = '<';
				buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1 | 1)] = '>';
				--aa;
			}
			if(bb && !buf[(n & 1) + (i << 1)][(m & 1) + (j << 1)] && !buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1)]) {
				buf[(n & 1) + (i << 1)][(m & 1) + (j << 1)] = '^';
				buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1)] = 'v';
				--bb;
			}
			if(bb && !buf[(n & 1) + (i << 1)][(m & 1) + (j << 1 | 1)] && !buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1 | 1)]) {
				buf[(n & 1) + (i << 1)][(m & 1) + (j << 1 | 1)] = '^';
				buf[(n & 1) + (i << 1 | 1)][(m & 1) + (j << 1 | 1)] = 'v';
				--bb;
			}
		}
	assert(!aa && !bb);
	puts("YES");
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j)
			if(!buf[i][j])
				buf[i][j] = '.';
		buf[i][m] = '\0';
		puts(buf[i]);
	}
	return 0;
}

Measured memory_bytes: 5248
import java.util.*; 
import java.io.*;

public class Main {
	
	public static void solve(InputReader in) {
		int n = in.readInt(); 
		long a[] = new long[n+1]; 
		for(int i = 1; i<=n; i++ ) 
			for(int j = i; j<=n; j+=i) 
				 if(j % i == 0)a[j]++; 
			
		long ans = 0; 
		for(int i = 1; i<=n; i++) {
			ans += i * a[i]; 
		}
		System.out.println(ans); 
	}
	public static void main(String[] args) {
		InputReader in = new InputReader(System.in); 
		int t = 1; 
		while(t-- > 0) {
			solve(in); 
		}
	}
}

class InputReader{
	private InputStream stream;
	private byte[] buf = new byte[1024];
	private int curChar;
	private int numChars;
	private SpaceCharFilter filter;

	 public InputReader(InputStream stream) {
		this.stream = stream;
	}

     public int read() {
		if (numChars == -1)
			throw new InputMismatchException();
		if (curChar >= numChars) {
			curChar = 0;
			try {
				numChars = stream.read(buf);
			} catch (IOException e) {
				throw new InputMismatchException();
			}
			if (numChars <= 0)
				return -1;
		}
		return buf[curChar++];
	}

     public int readInt() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		int res = 0;
		do {
			if (c < '0' || c > '9')
				throw new InputMismatchException();
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}

     public String readString() {
		int c = read();
		while (isSpaceChar(c))
			c = read();
		StringBuilder res = new StringBuilder();
		do {
			res.appendCodePoint(c);
			c = read();
		} while (!isSpaceChar(c));
		return res.toString();
	}

     public long readLong() {
		int c = read();
		while (isSpaceChar(c)) {
			c = read();
		}
		int sgn = 1;
		if (c == '-') {
			sgn = -1;
			c = read();
		}
		long res = 0;
		do {
			if (c < '0' || c > '9') {
				throw new InputMismatchException();
			}
			res *= 10;
			res += c - '0';
			c = read();
		} while (!isSpaceChar(c));
		return res * sgn;
	}
	
     public boolean isSpaceChar(int c) {
		if (filter != null)
			return filter.isSpaceChar(c);
		return c == ' ' || c == '\n' || c == '\r' || c == '\t' || c == -1;
	}
     
     public String next() {
		return readString();
	}
    
     public interface SpaceCharFilter {
		public boolean isSpaceChar(int ch);
	}
}


Measured memory_bytes: 112216
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,a) for(int i=0;i<(a);i++)
const ll MOD=1000000007;
//const ll MOD=998244353;

int dp[5050][5050];

int main(){
  int N; cin>>N;
  string S; cin>>S;
  int ans=0;
  for(int i=N-1;i>=0;i--){
    for(int j=N-1;j>=0;j--){
      if(S[i]==S[j]){
        dp[i][j]=max(dp[i][j],dp[i+1][j+1]+1);
      }
      ans=max(ans,min(dp[i][j],j-i));
    }
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 98944
#include <bits/stdc++.h>
using namespace std;
using Graph = vector<vector<int>>;
const int INF = 1e9;
const int EPS = 1e-9; 

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i) cin >> A.at(i), --A.at(i);
  vector<int> B(N);
  for (int i = 0; i < N; ++i) {
     B.at(A.at(i)) = i+1;
  }
  for (int i = 0; i < N; ++i) cout << B.at(i) << ' ';
}

Measured memory_bytes: 1536
#include <iostream>
#include <vector>
#include <cstdlib>
#include <bits/stdc++.h>
using namespace std;

int main() {
    int n;
    cin >> n;
    vector<int> h(n);
    for(int i = 0; i < n; i++){
        cin >> h.at(i);
    }
    vector<int> dp(100010);
    for(int i = 0; i < n; i++){
        dp[i] = 1000000000;
    }
    dp[0] = 0;
    for(int i = 1; i < n; i++){ //1行目で1マス進んでたどり着いた場合のコストとINFの比較,2行目で2マス進んでたどり着いた場合の1行目コストと2行目コストの比較
        dp[i] = min(dp[i], dp[i-1]+abs(h[i]-h[i-1]));
        if(i > 1){
            dp[i] = min(dp[i], dp[i-2] + abs(h[i] - h[i-2]));
        }
    }
    cout << dp[n-1] << endl;
}

Measured memory_bytes: 1024
d[1<<22],i,N,p;w[99];main(j){for(*d=1;~scanf("%d",w+i++););for(N=*w;p<N<<N;d[i]%=j=1e9+7)d[i]+=d[j=p/N]*w[p%N*N+__builtin_popcount(i=j|1<<p++%N)]*(j<i);printf("%d",d[i]);}

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

int main() {
  for (int i=0; i<3000; i++) {
    int a, b;
    cin >> a >> b;
    if (a == 0 && b == 0) break;
    else {
      if (a > b) cout << b << " " << a << endl;
      else cout << a << " " << b << endl;
    }
  }
  return 0;
}


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

int main() {

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

	vector<vector<char>> a(n + 2, vector<char>(n + 2, '-1'));
	vector<vector<char>> b(m + 2, vector<char>(m + 2, '-1'));
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= n; j++) {
			cin >> a[i][j];
		}
	}
	for (int i = 1; i <= m; i++) {
		for (int j = 1; j <= m; j++) {
			cin >> b[i][j];
		}
	}
	for (int h = 1; h <= n - m + 1; h++) {
		for (int w = 1; w <= n - m + 1; w++) {

			bool can = true;
			for (int i = h; i <= h + m - 1; i++) {
				for (int j = w; j <= w + m - 1; j++) {
					if (a[i][j] != b[i - h + 1][j - w + 1]) {
						can = false;
					}
				}
			}

			if (can) {
				cout << "Yes" << endl;
				return 0;
			}

		}
	}

	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
import itertools
N,M,Q=map(int,input().split())
L=[list(map(int, input().split())) for _ in range(Q)]
m=[x for x in range(1, M+1)]
A=list(itertools.combinations_with_replacement(m ,N))
ans=0
for a in A:
    d=0
    for i in range(Q):
        if a[L[i][1]-1]-a[L[i][0]-1]==L[i][2]:
            d+=L[i][3]    
    ans=max(ans,d)
print(ans)

Measured memory_bytes: 21516