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

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<vector<pii> > vvpii;

#define pb push_back
#define endl '\n'
#define INF (int)1e9
#define EPS 1e-9
#define gcd __gcd
#define rs resize
#define FOR(i,a,b) for(int i = a; i < b; i++)
#define by(T, x) [](const T& a, const T& b) { return a.x < b.x; } //for struct sorting

void printV(vector<int> v){
	for(int i = 0; i < v.size(); i++){
		cout << v[i] << " " ;
	}
	cout << endl;
}

void print2V(vvi v){
	FOR(i, 0, v.size()){
		FOR(j, 0, v[i].size()){
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
}

double dp[305][305][305];
int n;

double f(int a, int b, int c){
//	cout << "inside with: " << a << " " << b << " " << c << endl;
	if(a < 0 || b < 0 || c < 0){
//		cout << "negative, returning 0" << endl;
		return 0;
	}
	if(a == 0 && b == 0 && c == 0){
//		cout << "finished all, returning 1" << endl;
		return 1;
	}
	
	if(dp[a][b][c] != -1){
		return dp[a][b][c];
	}
	dp[a][b][c] = ( f(a-1, b, c)*a + f(a+1, b-1, c)*b + f(a, b+1, c-1)*c + n*1.0 )/(a+b+c);
//	cout << "returning: " << dp[a][b][c] << " for " << a << " " << b << " " << c << endl;
	return dp[a][b][c];
}

int main(){
	for(int i = 0; i < 305; i++){
		for(int j = 0; j < 305; j++){
			for(int k = 0; k < 305; k++){
				dp[i][j][k] = -1;
			}
		}
	}
	cin >> n;
	int temp, a= 0, b = 0, c = 0;
	for(int i = 0; i < n; i++){
		cin >> temp;
		if(temp == 1){
			a++;
		}
		else if(temp == 2){
			b++;
		}
		else{
			c++;
		}
	}
	cout << setprecision(15) << f(a, b, c)-1;
}

Measured memory_bytes: 221952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define ll long long
#define db long double
#define ii pair<int,int>
#define vi vector<int>
#define fi first
#define se second
#define sz(a) (int)(a).size()
#define all(a) (a).begin(),(a).end()
#define pb push_back
#define mp make_pair
#define FN(i, n) for (int i = 0; i < (int)(n); ++i)
#define FEN(i,n) for (int i = 1;i <= (int)(n); ++i)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define repv(i,a,b) for(int i=b-1;i>=a;i--)
#define SET(A, val) memset(A, val, sizeof(A))
typedef tree<int ,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>ordered_set ;
// order_of_key (val): returns the no. of values less than val
// find_by_order (k): returns the kth largest element.(0-based)
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ','); cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif
const int N=100005,mod=1e9+7;
int a[N],pre[N],pre2[N];
int add(int x,int y)
{
  x+=y;
  if(x>=mod) x-=mod;
  if(x<0) x+=mod;
  return x;
}
int mult(int x,int y)
{
  ll tmp=(ll)x*y;
  if(tmp>=mod) tmp%=mod;
  return tmp;
}
int pow1(int x,int y)
{
  int ans=1;
  while(y)
    {
      if(y&1) ans=mult(ans,x);
      x=mult(x,x);
      y>>=1;
    }
  return ans;
}
int inv(int x)
{
  return pow1(x,mod-2);
}
int main()
{
  std::ios::sync_with_stdio(false);
  cin.tie(NULL) ; cout.tie(NULL) ;
  int n,ans=0;
  cin>>n;
  int fact=1;
  rep(i,1,n+1)
    {
      cin>>a[i];
      fact=mult(fact,i);
      pre[i]=add(pre[i-1],a[i]);
    }
  rep(i,1,n+1) pre2[i]=add(pre2[i-1],pre[i]);
  rep(len,1,n-1)
    {
      int tmp=mult(inv(len+1),inv(len+2)),tmp2=0;
      int l1=2+len-1,r1=n-1;
      int l2=1,r2=n-len-1;
      if(l1<=r1 && l2<=r2)
	{
	  tmp2=add(tmp2,add(pre2[r1],-pre2[l1-1]));
	  tmp2=add(tmp2,-add(pre2[r2],-pre2[l2-1]));
	}
      ans=add(ans,mult(tmp,tmp2));
    }
  ans=mult(ans,2);
  /*rep(i,1,n)
    {
      rep(j,2,i+1)
	{
	  int len=i-j+1;
	  int tmp=add(pre[i],-pre[j-1]);
	  int tmp2=mult(inv(len+1),inv(len+2));
	  ans=add(ans,mult(tmp,tmp2));
	}
	}*/
  //start with 1
  rep(i,1,n)
    ans=add(ans,mult(pre[i],inv(i+1)));
  //end with n
  rep(i,2,n+1)
    {
      int len=n-i+1;
      ans=add(ans,mult(add(pre[n],-pre[i-1]),inv(len+1)));
    }
  //complete array
  ans=add(ans,pre[n]);
  ans=mult(ans,fact);
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define REP(i, n) for (int 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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  int h,w;
  cin >> h >> w;
  vector<string> field(h);
  REP(i,h) cin >> field[i];

  int dx[8] = {-1, 0, 1, -1, 1, -1, 0, 1};
  int dy[8] = {-1, -1, -1, 0, 0, 1, 1, 1};
  vector<vector<char>> ans(h, vector<char>(w));
  REP(i,h) REP(j,w){
    if(field[i][j]=='#'){
      ans[i][j] = '#';
      continue;
    }
    int cnt = 0;
    REP(k,8){
      int x = j + dx[k];
      int y = i + dy[k];
      if(x<0 || x>=w || y<0 || y>=h) continue;
      if(field[y][x]=='#') cnt++;
    }
    ans[i][j] = '0' + cnt;
  }
  REP(i,h){
    REP(j,w) cout << ans[i][j];
    cout << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Text.RegularExpressions;

namespace AtCoder
{
	public class ABC
	{
		static readonly int mod = 1000000007;  // 10^9+7

		static void Main(string[] args)
		{
			Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });


			//int n = int.Parse(Console.ReadLine());
			//string s = Console.ReadLine();
			int[] vs = Console.ReadLine().Split().Select(int.Parse).ToArray();
			//long[] a = Console.ReadLine().Split().Select(long.Parse).ToArray();
			int n = vs[0];
			int m = vs[1];

			long[] primes = PrimeFactorization(m);
			//System.Diagnostics.Debug.WriteLine($"{string.Join(" ", primes)}");
			long ans = 1;
			int c = 1;
			for (int i = 0; i < primes.Length; i++) {
				if (i + 1 < primes.Length && primes[i] == primes[i + 1]) {
					c++;
				} else {
					long tmp = CombinationDP(c + n - 1, c, mod);
					//System.Diagnostics.Debug.WriteLine($"{primes[i]}:{c + n - 1} C {c} = {tmp}");
					ans *= tmp;
					ans %= mod;
					c = 1;
				}
			}
			Console.WriteLine(ans);


			Console.Out.Flush();
		}

		#region 場合の数（DP計算版） long CombinationDP(int n, int r, int mod)
		static long CombinationDP(int n, int r, int mod)
		{
			r = Math.Min(r, n - r);
			long[,] dp = new long[n + 1, r + 1];
			dp[0, 0] = 1;
			for (int i = 1; i <= n; i++) {
				dp[i, 0] = 1;
				for (int j = 1; j <= i && j <= r; j++) {
					dp[i, j] = (dp[i - 1, j - 1] + dp[i - 1, j]) % mod;
				}
			}
			return dp[n, r];
		}
		#endregion

		#region 素因数分解 long[] PrimeFactorization(long a)
		public static long[] PrimeFactorization(long a)
		{
			if (a < 2) { return new long[] { }; }

			List<long> ans = new List<long>();
			while (a % 2 == 0) {
				ans.Add(2);
				a /= 2;
			}
			for (int i = 3; i <= Math.Sqrt(a); i += 2) {
				while (a % i == 0) {
					ans.Add(i);
					a /= i;
				}
			}
			if (a > 1) {
				ans.Add(a);
			}
			return ans.ToArray();
		}
		#endregion

	}
}


Measured memory_bytes: 32480
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
const int MD = 998244353;
const int MX = 200005;
int n;
long long m[MX], ans, sm, f[MX], mp[MX];
string x;
int gcd(int x, int y){
	if(x < y) swap(x, y);
	while(y){
		x %= y;
		swap(x,y);
	}
	return x;
}
void setmap(int t){
	int u = t;
	for(; u < n && x[u-t] != x[u]; u++);
	mp[t] = f[t] + (u == n || x[u] == '1');
}
int main(){
	cin >> n >> x;
	rep(i,n) f[i+1] = (f[i]*2 + x[i] - '0') % MD;
	for(int i = 1; i*i <= n; i++) if(!(n%i)){
		setmap(i);
		if(i*i != n) setmap(n/i);
	}
	for(int i = 1; i < n; i++){
		int t = gcd(i,n);
		if(i/t % 2 == 0){
			m[i] = (m[i] + mp[t]) % MD;
			sm = (sm + m[i]) % MD;
			ans = (ans + m[i] * i) % MD;
			for(int j = i*2; j < n; j += i) m[j] = (m[j] - m[i] + MD) % MD;
		}
	}
	printf("%lld\n", (ans + (f[n]+1 - sm + MD) * 2*n) % MD);
}

Measured memory_bytes: 3716
#include <bits/stdc++.h>
#define REP(i, s, n) for (int i = s; i < n; i++)
#define ALL(a) a.begin(), a.end()
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main() {
    int N, M, X; cin >> N >> M >> X;
    vector<int> C(N); vector<vector<int>> A(N, vector<int>(M));
    REP(i, 0, N) {
        cin >> C[i];
        REP(j, 0, M) cin >> A[i][j];
    }

    int ans = 1 << 30;
    for (int bit = 0; bit < (1 << N); bit++) {
        vector<int> tmp(M, 0); int cost = 0;
        REP(j, 0, N) {
            if (bit & (1 << j)) {
                cost += C[j];
                REP(k, 0, M) tmp[k] += A[j][k];
            }
        }

        bool ok = true;
        REP(j, 0, M) if (tmp[j] < X) ok = false;

        if (ok) ans = min(ans, cost);
    }
    if (ans < (1 << 30)) cout << ans << endl;
    else cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3640
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

def main():
    N,D,A = map(int,readline().split())
    m = map(int,read().split())
    X,H = zip(*sorted(zip(m,m)))
    
    over = [-1]*N
    tmp=0
    for i in range(N):
      while(tmp<N and X[i]+D*2>=X[tmp]):
        tmp += 1
      over[i] = tmp
    reset = [0]*N
    
    ans = 0
    dam = 0
    for i in range(N):
      if i>0:
        reset[i] += reset[i-1]
      hp = H[i]-dam+reset[i]
      if hp > 0:
        bomb = (hp+A-1)//A
        ans += bomb
        dam += bomb * A
        if(over[i]<N):
          reset[over[i]] += bomb * A

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 52936
#include<bits/stdc++.h>
using namespace std;
int n,a,b; 
int main()
{
	cin>>n;
	if(n==1){
		cout<<"Hello World"<<endl;
		return 0; 
	}else{
		cin>>a>>b;
		cout<<a+b<<endl;
	} 
	return 0;
}


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


int main(void)
{
    int L, R, d;
    cin>>L>>R>>d;

    int cnt=0;
    REP(i, L, R+1){
        if(i%d==0) cnt++;
    }

    cout<<cnt<<endl;
    return 0;
}

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

int main() {
	int A, B;
	cin >> A >> B;
	int c = A + B;
	int d = A - B;
	int e = A * B;

	int f = max(c, d);
	f = max(f, e);

	cout << f << endl;

}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MAXN = 100*1000+10;
int n;
int c[MAXN][3];
int dp[MAXN][3];

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=1; i<=n;i++) {
        cin>>c[i][0]>>c[i][1]>>c[i][2];
    }
    for(int i=1; i<=n;i++) {
        for(int j=0; j<3;j++) {
            dp[i][j] = -1000*1000*1000;
            for(int k=0; k<3;k++) {
                if(j==k) continue;
                dp[i][j]=max(dp[i][j],dp[i-1][k]);
            }
            dp[i][j]+=c[i][j];
        }
    }
    cout<<max({dp[n][0],dp[n][1],dp[n][2]});
}


Measured memory_bytes: 2560
#include <iostream>
#include <fstream>
#include <string> 
#include <cmath>  
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
//#include <boost/multiprecision/cpp_int.hpp>

#define BIT(a) (1 << (a))
#define EPS (1e-10)

using namespace std;
//using namespace boost::multiprecision;

const long long MOD = 1000000007;
const int COUNTER_CLOCKWISE = 1;
const int CLOCKWISE = -1;
const int ONLINE_BACK = 2;
const int ONLINE_FRONT = -2;
const int ON_SEGMENT = 0;

class Point{
    public:
    double x, y;

    Point(double x = 0, double y = 0): x(x), y(y) {}
    
    Point operator+(Point p){return Point(x + p.x, y + p.y);}
    Point operator-(Point p){return Point(x - p.x, y - p.y);}
    Point operator*(double a){return Point(a * x, a * y);}
    Point operator/(double a){return Point(x / a, y / a);}

    bool operator < (const Point &p) const {
        return y != p.y ? y < p.y : x < p.x;
    }

    double norm(){return x * x + y * y;}
};
typedef Point Vector;
typedef vector<Vector> Polygon;

double cross(Vector a, Vector b){
    return a.x*b.y - a.y*b.x;
}

double dot(Vector a, Vector b){
    return a.x * b.x + a.y * b.y;
}

int ccw(Point p0, Point p1, Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if (cross(a, b) > EPS)return COUNTER_CLOCKWISE;
    if (cross(a, b) > -EPS)return CLOCKWISE;
    if (dot(a, b) < -EPS)return ONLINE_BACK;
    if (a.norm() < b.norm())return ONLINE_FRONT;

    return ON_SEGMENT;
}

Polygon andrewScan(Polygon s){
    Polygon u, l;
    if (s.size() < 3) return s;
    sort(s.begin(), s.end());
    u.push_back(s[0]);
    u.push_back(s[1]);
    l.push_back(s[s.size()-1]);
    l.push_back(s[s.size()-2]);
    
    for (size_t i = 2; i < s.size(); i++){
        for (size_t n = u.size(); n >= 2 && ccw(u[n-2], u[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            u.pop_back();
        }
        u.push_back(s[i]);
    }

    for (int i = (int)s.size() - 3; i >= 0; i--){
        for (size_t n = l.size(); n >= 2 && ccw(l[n-2], l[n-1], s[i]) == COUNTER_CLOCKWISE; n--){
            l.pop_back();
        }
        l.push_back(s[i]);
    }

    reverse(l.begin(), l.end());
    for (size_t i = u.size() - 2; i >= 1; i--) l.push_back(u[i]);

    return l;
}

long long mod_pow(long long x, long long n){
    long long res = 1;
    for(int i = 0;i < 60; i++){
        if(n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}


int main(void){
    int N;
    Polygon po;
    cin >> N;
    for (int i = 0; i < N; i++){
        int x, y;
        cin >> x >> y;
        po.push_back(Vector(x, y));
    }
    Polygon ans = andrewScan(po);
    cout << ans.size() << endl;
    for (auto itr = ans.begin(); itr != ans.end(); itr++){
        cout << itr->x << " " << itr->y << endl;
    }
    return 0;
}   



Measured memory_bytes: 9308
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1e18
#define PI 3.14159265358979

using namespace std;

int main(void){
  string s;
  cin >> s;
  ll n = s.size();
  
  int ok = 0;
  if (n == 2){
    if (s[0] == s[1]){
      ok = 1;
      cout << 1 << " " << 2 << endl;
    }
  }
  else {
    for (int i = 0; i < n - 2; i++){
      if (s[i] == s[i + 1] || s[i] == s[i + 2] || s[i + 1] == s[i + 2]){
        cout << i + 1 << " " << i + 3 << endl;
        ok = 1;
        break;
      }
    }
  }

  if (!ok){
    cout << -1 << " " << -1 << endl;
  }

  return 0;
}


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

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

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<string> str = {"Sunny", "Cloudy", "Rainy"};
  string s;
  cin >> s;
  rep(i,3) if(s == str[i]) cout << str[(i+1)%3] << endl;

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <random>
#include <chrono>
#include <queue>
using namespace std;
typedef long long ll;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;
#define INF 1000000000
#define mod 1000000007


int main() {
    string S; cin >> S;
    int ans = 0;
    for(int i=0; i<S.size()-1; i++){
        if(S[i+1]!=S[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
#ifdef DBP
#define deb(...) fprintf(stderr,__VA_ARGS__)
#else
#define deb(...) 0
#endif
#define fst first
#define snd second
#define fore(x,a,b) for(int x=(a), qwerty=(b); x<qwerty; x++)
#define pb push_back
#define mset(a,v) memset((a),(v),sizeof(a))
#define ALL(a) (a).begin(), (a).end()
#define SZ(a) int((a).size())
#define FIN ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
typedef long long ll;

const ll MOD=1e9+7;
const int N=1e3+5;
int h,w;
string s[N];
ll dp[N][N];

ll f(int i, int j){
	if(i==h-1 && j == w-1)return 1;
	ll &r=dp[i][j];
	if(r!=-1)return r;
	r=0;
	if(i<h-1&&s[i+1][j]=='.'){r+=f(i+1,j);if(r>=MOD)r-=MOD;}
	if(j<w-1&&s[i][j+1]=='.'){r+=f(i,j+1);if(r>=MOD)r-=MOD;}
	return r;
}

int main(){FIN;mset(dp,-1);
	cin>>h>>w;
	fore(x,0,h)cin>>s[x];
	cout << f(0,0) << "\n";
}

Measured memory_bytes: 9344
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include <limits>
#include <iomanip>

using namespace std;


int main(){
	string s,t,u;
	int a,b;
	
	cin >> s >> t >> a >> b >> u;
	
	if(s == u)cout << a-1 << ' ' << b << endl;
	else cout << a << ' ' << b-1 << endl;
	return 0;
}

Measured memory_bytes: 256
/*
  Motto - try hard to become an expert
*/
#include <bits/stdc++.h>
#include <map>
#include <algorithm>
#include <vector>
#include <string.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <chrono>
#include <thread>
#include <iomanip>
 
//define
#define rep(i,n)    for(int i=0;i<n;i++)
#define repu(i,k,n) for(int i=k;i<=n;i++)
#define repd(i,k,n) for(int i=k;i>=n;i--)
#define se second
#define fi first
#define pb push_back
#define mp make_pair
#define INF (int)INT_MAX
#define all(v)  v.begin(), v.end()
#define endl "\n"
 
//typedef
typedef long long int ll;
typedef long double ld;
typedef std::pair<int, int> pii;
typedef std::vector<int> vi;
typedef std::vector< pii > vii;
typedef std::vector< ll > vll;
typedef std::vector< std::pair < pii, int > > vpp;
 
const int N = 3*1e5 +5 ;
const long long MOD = 998244353;
const long long inf = 1e18;
 
using namespace std;
 
ll MAXN=100001;
ll spf[100001]; 
 
ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1) res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}
 
ll modFact(ll n, ll p) 
{ 
    if (n >= p) 
        return 0; 
  
    ll result = 1; 
    for (ll i = 1; i <= n; i++) 
        result = (result * i) % p; 
  
    return result;  
} 
 
bool isPrime(int x)
{
    if(x%2==0)
        return 0;
    for(int i=3;i<=sqrt(x);i+=2)
    {
        if(x%i==0)
            return 0;
    }
    return 1;
}
 

 
void solve()
{
    ll  a  ,v ;
    cin>>a>>v ;
    ll  b  ,w ;
    cin>>b>>w ;
    ll  t  ;
    cin>>t ;
    if(a==b){
    	cout<<"YES";
    }
    else{
    	if(w>=v){
    		cout<<"NO";
    	}
    	else{
    		ll  dis = abs(a-b);
    		ll  vel = abs(w-v) ;
    		if(t*vel>=dis){
    			cout<<"YES";
    		}
    		else{
    			cout<<"NO";
    		}
    	}
    }
}
 
int main() {
    #ifndef ONLINE_JUDGE
        // for getting input from input.txt
        freopen("input.txt", "r", stdin);
        // for writing output to output.txt
        freopen("output.txt", "w", stdout);
    #endif
    
    ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    int t = 1;
    //cin>>t;
    while(t--)
    {
        solve();
    } 
    cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
}

Measured memory_bytes: 3868
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define ll long long

int main(){

    string s; cin >> s;
    bool flag = false;

    if(s[0] == 'A'){
        for(int i=2;i<s.size()-1;i++){
            if(s[i] == 'C'){
                bool komoji = false;
                for(int j=1;j<s.size();j++){
                    if(j == i) continue;
                    else{
                        if(s[j] >= 'A' && s[j] <= 'Z'){
                            komoji = true;
                            break;
                        }
                    }
                }
                if(!komoji) flag = true;
                break;
            }
        }
    }

    if(flag) cout << "AC" << endl;
    else cout << "WA" << endl;

    return 0;
}

Measured memory_bytes: 256
var c,n,i,j,m:Longint;
begin
	read(n);
	for i:=1 to n do begin
		m:=0;
		for j:=1 to i do begin
			if i mod j=0 then inc(m);
		end;
		if(i mod 2=1)and(m=8)then inc(c);
	end;
	write(c);
end.


Measured memory_bytes: 128
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;


void main()
{
  readln;
  auto l = sort(readln.chomp.split.map!(to!int).array);
  int sum;
  foreach (i; iota(0,l.length,2)) {
    sum += l[i];
  }
  sum.writeln;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <map>
#include <utility>
#include <algorithm>
#include <cmath>
using namespace std;

typedef long long ll;
const ll mod=1000000007;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n) for(int i=1;i<n+1;i++)

int _num(int s){
    if(s<1) return 1;
    return _num(s-2)+_num(s-1);
}

int main(){
    int H,W,K;
    cin>>H>>W>>K;

    if(W==1) {
        cout<<1<<endl;
        return 0;
    }
    ll dp[9][102];
    Rep(i,W){
        if(i==K) dp[i][H+1]=1;
        else dp[i][H+1]=0;
    }
    rep(i,H){
        Rep(j,W){
            if(j==1){
                dp[j][H-i]=(dp[j][H-i+1]*_num(W-2)+dp[j+1][H-i+1]*_num(W-3))%mod;
            }else if(j==W){
                dp[j][H-i]=(dp[j][H-i+1]*_num(W-2)+dp[j-1][H-i+1]*_num(W-3))%mod;
            }else{
                dp[j][H-i]=(dp[j][H-i+1]*_num(j-2)*_num(W-j-1)+dp[j-1][H-i+1]*_num(W-j-1)*_num(j-3)+dp[j+1][H-i+1]*_num(W-j-2)*_num(j-2))%mod;
            }
        }
    }
    cout<<dp[1][1]<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int ns,nl,cnt;
int vec[12][12];
bool used[12][12];

vector<int> dis;

const int INF = 1<<30;


void permutation(int s,int cost,vector<int> P){
  
  bool fin = true;
  
  for(int i=1;i<=ns;i++){
    if(!used[s][i] && vec[s][i] != INF && i!=s){
      fin = false;
      P.push_back(i);
      used[s][i] = used[i][s] = true;
      permutation(i,cost+vec[s][i],P);
      used[s][i] = used[i][s] = false;
      P.pop_back();
    }
  }

  if(fin){
    if(cnt <= cost){
      // cout << cnt << endl;
      if(cnt == cost){
	bool AorB = false;//true -> dis, false -> P
	
	for(int i=0;i<min(dis.size(),P.size());i++){
	  if(dis[i] > P[i]){
	    AorB = false;
	    break;
	  }
	  else if(dis[i] < P[i]){
	    AorB = true;
	    break;
	  }
	}
	//cout << "---------------" << endl;
	//cout << "P = ";
	//for(int i=0;i<P.size();i++){
	//cout << P[i] << " ";
	//}
	//cout << endl;
	//cout << "dis  = ";
	//for(int i=0;i<dis.size();i++)cout<< dis[i] << " ";
	//cout<< endl;


	if(!AorB){
	  dis.clear();
	  copy(P.begin(),P.end(),back_inserter(dis));
	}
      }
      else if(cnt < cost){
 dis.clear();
	  copy(P.begin(),P.end(),back_inserter(dis));
      }   
      cnt = cost;
    }
  }

}

int main(){
  int s1,s2,d;
 
  while(true){
    cin >> ns >> nl;
    if(ns+nl == 0)break;
    dis.clear();
    dis.push_back(9999999);
    for(int j=0;j<12;j++)for(int i=0;i<12;i++){
	vec[i][j]=INF;    
	used[j][i] = false;
      }
    cnt = 0;

    for(int i=0;i<nl;i++){
      cin >> s1 >> s2 >> d;
      vec[s1][s2] = vec[s2][s1] = d;
    }

    vector<int> pos;
    for(int i=1;i<=ns;i++){
      pos.push_back(i);
      
      permutation(i,0,pos);
      for(int k=0;k<12;k++)for(int j=0;j<12;j++)used[k][j] = false;
      pos.pop_back();
    }
    cout << cnt << endl;
    for(int i=0;i<dis.size();i++){
      cout << dis[i];
      if(i == dis.size()-1)cout<< endl;
      else cout << " ";
    }
  }
  return 0;
}

Measured memory_bytes: 1216
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int N,M;
  cin>>N>>M;
  if(N==M){
  cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}
  

Measured memory_bytes: 256
# 入力
A, B = map(int, input().split())


# f(0, a)を返す
def g(a):
    m = a % 4
    return (
        a if m == 0 else
        1 if m == 1 else
        a + 1 if m == 2 else
        0
    )


# b >= a >= 1 ならば f(a, b) = f(0, b) ^ f(0, a - 1) を用いる
ans = g(B) ^ g(A - 1) if A > 0 else g(B)

# 出力
print(ans)


Measured memory_bytes: 2940
import std.stdio, std.conv, std.functional, std.string;
import std.algorithm, std.array, std.container, std.range, std.typecons;
import std.numeric, std.math, std.random;
import core.bitop;

string FMT_F = "%.10f";

static string[] s_rd;
T RD(T = long)() { while(!s_rd.length) s_rd = readln.chomp.split; string res = s_rd[0]; s_rd.popFront; return res.to!T; }
string RDR()() { return readln.chomp; }
T[] ARR(T = long)(in string str, T fix = 0) { auto r = str.split.to!(T[]); r[] += fix; return r; }
size_t[] MAKE_IDX(alias less = "a < b", Range)(Range range) { auto idx = new size_t[](range.length); makeIndex!(less)(range, idx); return idx;}
size_t MIN_POS(alias less = "a < b", Range)(Range range) { auto r = minPos!(less)(range); return range.length - r.length; }

bool inside(T)(T x, T b, T e) { return x >= b && x < e; }
long lcm(long x, long y) { return x * y / gcd(x, y); }

long mod = 10^^9 + 7;
//long mod = 998244353;
//long mod = 1_000_003;
void moda(ref long x, long y) { x = (x + y) % mod; }
void mods(ref long x, long y) { x = ((x + mod) - (y % mod)) % mod; }
void modm(ref long x, long y) { x = (x * y) % mod; }

void main()
{
	auto N = RD;
	auto s = RD!string;
	auto t = RD!string;

	long ans;
	foreach (i; 0..N)
	{
		bool ok = true;
		foreach (j; 0..N-i)
		{
			if (s[i+j] != t[j])
			{
				ok = false;
			}
		}
		if (ok)
		{
			ans = N - i;
			break;
		}
	}

	writeln(N * 2 - ans);
	stdout.flush();
	debug readln();
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int,input().split()))
c = 0
if n==1:
  print(*l)
  exit()
while l.count(0)!=n:
  for i in range(n-1):
    if l[i]==0 and i!=n-2:
      continue
    elif l[i]==0 and i==n-2:
      c += 1
      l[n-1] -=1
    elif l[i]<=l[i+1] and i!=n-2:
      l[i] -= 1
    elif l[i]<=l[i+1] and i==n-2:
      l[i] -= 1
      l[i+1] -=1
      c += 1
    else:
      c += 1
      l[i] -= 1
      break
print(c)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main(){
  int h,w;
  char c;
  int a[101][101];
  cin >> h >> w;
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      cin >> c;
      if(c =='c') a[i][j] = 0;
      else a[i][j] = -1;
    }
  }
  for(int i=0; i<h; i++){
    int count=0,x=1;
    for(int j=0; j<w; j++){
      if(a[i][j]==0){
        while(1){
          if(a[i][j+x]==0 || j+x > w-1){
            x=1;
            count = 0;
            break;
          }
          count++;
          a[i][j+x]=count;
          x++;
        }
      }
    }
  }
  for(int i=0; i<h; i++){
    for(int j=0; j<w; j++){
      if(j>0) cout << " " << a[i][j];
      else cout << a[i][j];
    }
    cout << endl;
  }
  return 0;
}



Measured memory_bytes: 3124
n,k=map(int,input().split())
h=list(map(int,input().split()))
dp=[10**10]*n
for i in range(n):
  if i==0:
    dp[i]=0
  elif i==1:
    dp[i]=abs(h[1]-h[0])
  else:
    for j in range(1,min(i,k)+1):
      dp[i]=min(dp[i],dp[i-j]+abs(h[i]-h[i-j]))
print(dp[-1])

Measured memory_bytes: 84688
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, a, b) for (int i = a; i < b; i++)
using namespace std;

#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <tuple>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <stack>
#include <bitset>

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

	vector<int> a(N + 1);

	rep(i, N) {
		cin >> a.at(i + 1);	
	}

	int c = 1, result = 0;

	rep(i, N) {
		if (c == 2) {
			cout << result;
			return 0;		
		}
		c = a.at(c);
		result++;	
	}
	cout << -1;
	return 0;
}

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

template <typename TYPE>
void print_vec(const vector<TYPE>& v){
	for(int i=0; i<v.size(); i++){
		cout << v[i] << " ";
	}
	cout << endl;
}

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

int main(){
	int N, M;
	cin >> N >> M;

	if(N % 2 == 1){
		for(int i=1; i<=M; i++){
			cout << i << " " << N-i+1 << endl;
		}
		return 0;
	}

	//以下Nが偶数の場合 
	//b-a==N/2にならないように途中で1ずらして表示　例(N, M) = (6,2)で影響
	//あるいは 前回のa,bの差と 今回のa,bの差の合計がNにならないように途中で1ずらして表示 例(N, M) = (8, 3)で影響
	int tmp = 0;
	for(int i=1; i<=M; i++){
		if(tmp==0 &&  (N-i+1)-(i) == N/2) tmp++;
		if(tmp==0 && (N-i+2)-(i-1) + (N-i+1)-i == N) tmp++;
		cout << i << " " << N-i+1-tmp << endl;
	}
	return 0;
}


Measured memory_bytes: 3464
n, m = map(int, input().split())
height = list(map(int, input().split()))

heigher = [0] * n
for i in range(m):
    a, b = map(int, input().split())
    heigher[a - 1] = max(heigher[a - 1], height[b - 1])
    heigher[b - 1] = max(heigher[b - 1], height[a - 1])

count = 0
for i in range(n):
    if height[i] > heigher[i]:
        count += 1

print(count)

Measured memory_bytes: 20068
import java.awt.geom.*;
import java.util.*;

public class Main {
	int [][] data;
	private void dfs(int x, int y ){
		data[y][x] = 0;
		for(int ydis = -1; ydis <= 1; ydis++){
			for(int xdis = -1; xdis <= 1; xdis++){
				//System.out.println((x + xdis) + " " + (y + ydis));
				if(data[y + ydis][x + xdis] == 1)
					dfs(x + xdis, y + ydis);
			}
		}
	}
	
	private void doit(){
		Scanner sc = new Scanner(System.in);
		while(true){
			int w = sc.nextInt();
			int h = sc.nextInt();
			if(w ==0 && h == 0) break;
			data = new int[h+2][w+2];
			for(int i =1; i <= h; i++){
				for(int j = 1; j <= w;j++){
					data[i][j] = sc.nextInt();
				}
			}
			int count = 0;
			for(int i =1; i <= h; i++){
				for(int j = 1; j <= w;j++){
					if(data[i][j] == 1){
						dfs(j,i);
						count++;
					}
				}
			}
			System.out.println(count);
		}
		
	}

	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();
	}
}

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

// sum(ai) < xのとき、あげすぎて幸福になれない子供が一人生じ、最大N-1人幸せになる
// sum(ai) == xのとき、全員幸せにできて、最大N人幸せになる
// sum(ai) > xのとき、少ないお菓子で幸福になる子から配っていく

int main() {
    int N; long long x;
    cin >> N >> x;
    long long sm = 0LL;
    vector<long long> a(N);
    for(int i = 0; i < N; ++i) {
        cin >> a[i];
        sm += a[i];
    }

    if(sm < x) { cout << N-1 << endl; return 0;}

    if(sm == x) { cout << N << endl; return 0;}

    int res = 0;
    long long tmp = 0LL;
    sort(a.begin(),a.end());
    for(auto &p: a) {
        tmp += p;
        if(tmp <= x) ++res;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int>X(N),Y(N),H(N);
  for(int i=0;i<N;i++)cin>>X[i]>>Y[i]>>H[i];
  
  for(int cx=0;cx<=100;cx++)for(int cy=0;cy<=100;cy++){
    int hh;
    for(int i=0;i<N;i++)if(H[i]>0){hh=H[i]+abs(X[i]-cx)+abs(Y[i]-cy);break;}
    
    bool ok=true;
    for(int i=0;i<N;i++){
      if(max(hh-abs(X[i]-cx)-abs(Y[i]-cy),0)!=H[i])ok=false;
    }
    if(ok){cout<<cx<<" "<<cy<<" "<<hh<<endl;}
    assert(hh>0);
  }
  
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

const int maxn = 605;
bool a[2][maxn][maxn];

vector<int> dx, dy;
bool used[maxn][maxn];

void go(int x, int y, int n, bool to[maxn][maxn], int c = 0) {
  if (used[x][y]) {
    assert(c == to[x][y]);
    return;
  }
  used[x][y] = true;
  to[x][y] = c;
  for (int dir = 0; dir < (int) dx.size(); ++dir) {
    int nx = x + dx[dir];
    int ny = y + dy[dir];
    if (nx < 0 || nx >= n || ny < 0 || ny >= n) {
      continue;
    }
    go(nx, ny, n, to, c ^ 1);
  }
}

void solve(int n, int d, bool to[maxn][maxn]) {
  dx.clear();
  dy.clear();
  for (int x = -n; x <= n; ++x) {
    if (x * x > d) {
      continue;
    }
    int y = roundl(sqrtl(d - x * x));
    if (y * y + x * x != d) {
      continue;
    }
    dx.push_back(x);
    dy.push_back(y);

    dx.push_back(x);
    dy.push_back(-y);
  }
  memset(used, 0, sizeof(used));
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < n; ++j) {
      if (!used[i][j]) {
        go(i, j, n, to);
      }
      sum += to[i][j];
    }
  }
  if (sum < n * n / 2) {
    for (int i = 0; i < n; ++i) {
      for (int j = 0; j < n; ++j) {
        to[i][j] ^= 1;
      }
    }
  }
}

signed main() {
#ifdef LOCAL
  assert(freopen("d.in", "r", stdin));
#endif
  //solve(5, 5, a[0]);
  mt19937 rr(1337);
  //for (int iter = 0; iter < 100000; ++iter) {
    //int n = rr() % 300 + 1;
    //int d = rr() % 100000 + 1;
    //memset(a, 0, sizeof(a));
    //cerr << n << ' ' << d << '\n';
    //solve(n, d, a[0]);
  //}

  while (true) {
    int n, d1, d2;
    cin >> n >> d1 >> d2;
    //n = rr() % 300 + 1;
    //d1 = rr() % 2000 + 1;
    //d2 = rr() % 2000 + 1;
    //cerr << n << ' ' << d1 << ' ' << d2 << '\n';
    memset(a, 0, sizeof(a));
    solve(2 * n, d1, a[0]);
    solve(2 * n, d2, a[1]);

    int sum = 0;
    for (int i = 0; i < 2 * n; ++i) {
      for (int j = 0; j < 2 * n; ++j) {
        if (a[0][i][j] && a[1][i][j]) {
          ++sum;
        }
      }
    }
    if (sum < n * n) {
      for (int i = 0; i < 2 * n; ++i) {
        for (int j = 0; j < 2 * n; ++j) {
          a[1][i][j] ^= 1;
        }
      }
    }

    int rem = n * n;
    int sum1 = 0, sum2 = 0;
    for (int i = 0; i < 2 * n; ++i) {
      for (int j = 0; j < 2 * n; ++j) {
        sum1 += a[0][i][j];
        sum2 += a[1][i][j];
        if (a[0][i][j] && a[1][i][j] && rem > 0) {
          --rem;
          cout << i << ' ' << j << '\n';
        }
      }
    }
    //cerr << "rem: " << rem << '\n';
    assert(rem == 0);
    break;
  }
}


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

// マクロ //
#define rep(i,N) for(int i = 0; i < N; i++)
#define all(x) x.begin(), x.end()
#define sort(x) sort(all(x))
#define uniq(x) x.erase(unique(all(x)), x.end())
#define vsum(x) accumulate(all(x), 0)
#define cou(x) cout << x << endl
#define y() cout << "Yes" << endl
#define n() cout << "No" << endl
#define Y() cout << "YES" << endl
#define N() cout << "NO" << endl
#define x2(x) (x) * (x)

// 型エイリアス //
using lint = long long;
using pii = pair<int, int>;
using vi = vector<int>;
using vli = vector<lint>;
using vc = vector<char>;
using vs = vector<string>;
using vb = vector<bool>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvc = vector<vc>;
using vpii = vector<pii>;
using msi = map<string, int>;

// 関数 //
int gcd(int a, int b) {
    int t;
    while (b != 0) {
        t = a % b;
        a = b;
        b = t;
    }
    return a;
}

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

double distance(pii a, pii b) {
    double dist;
    dist = sqrt(x2(a.first - b.first) + x2(a.second - b.second));
    return dist;
}

lint perm(int a) {
    lint perm = 1;
    for (int i = a; i >= 1; i--) {
        perm *= i;
    }
    return perm;
}

lint comb(int n, int m) {
    return perm(n) / (perm(n - m) * perm(m));
}

// 定数 //
#define pi acos(-1)
// End of Template //



int main() {

    cin.tie(0);
    ios::sync_with_stdio(false);

    string s;
    cin >> s;

    bool flag = false;
    rep(i, (s.size() - 1) / 2) {
        if (s[i] != s[s.size() - 1 - i]) {
            flag = true;
            break;
        }
    }

    rep(i, (s.size() - 1) / 2 / 2) {
        if (s[i] != s[(s.size() - 1) / 2 - 1 - i]) {
            flag = true;
            break;
        }
    }

    for (int i = (s.size() + 3) / 2 - 1; i < s.size(); i++) {
        if (s[i] != s[s.size() - i - 1]) {
            flag = true; 
            break;
        }
    }
    flag ? n() : y();
}

Measured memory_bytes: 256
from collections import *
import sys
try: inp = raw_input
except: inp = input
def err(s):
    sys.stderr.write('{}\n'.format(s))

def ni():
    return int(inp())

def nl():
    return [int(_) for _ in inp().split()]
N, M = nl()
A = nl()

print(max(-1, N - sum(A)))


Measured memory_bytes: 68316
#include <iostream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cstdio>
using namespace std;

map<string, int> mp;
set<string> st;

#define ALL(c) ((c).begin,(c).end())
#define MP make_pair

int solve() {
  string s;
  for(int i=0; i<8; i++) {
    int x; if(scanf("%d", &x) == EOF) return -1;
    s += (char)(x+'0');
  }
  
  return mp[s];
}

int main() {
  
  int const dir[] = {-1,-4,1,4};
  
  typedef pair<int, string> State;
  
  queue<State> q;
  q.push(MP(0, "01234567"));
  st.insert("01234567");
  while(!q.empty()) {
    const int cost = q.front().first;
    const string s = q.front().second; q.pop();
    
    int pos = s.find('0');
    
    for(int i=0; i<4; i++) {
      int npos = pos + dir[i];
      if(dir[i] == 1 && npos == 4) continue;
      if(dir[i] == -1 && npos == 3) continue;
      if(npos < 0 || npos > 7) continue;
      
      string ns = s;
      swap(ns[pos], ns[npos]);
      int ncost = cost+1;
      if(st.count(ns) && mp[ns] < ncost) continue;
      mp[ns] = ncost; st.insert(ns);
      q.push(MP(ncost, ns));
    }
  }
  
  while(1) {
    int ret = solve();
    if(ret == -1) break;
    else {
      cout << ret << endl;
    }
  }
  
  return 0;
}

Measured memory_bytes: 5416
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int a,b,c,d,e,f;
	int maxs=0,maxsl=0,svf=0;
	double bass=0;
	cin>>a>>b>>c>>d>>e>>f;
	for(int i=0;i<=f/(100*a)+1;i++)
	{
		for(int j=0;j<=f/(100*b)+1;j++)
		{
			for(int k=0;k<=f/c+1;k++)
			{
				for(int l=0;l<=f/d+1;l++)
				{

					double sol = k*c + l*d;
					double sv = 100*(a*i+b*j);

					if(sol+sv<=(double)f && !(i+j==0) && sol<=((a*i+b*j)*e))
					{
						if(bass<=sol/sv)
						{
							bass=sol/sv;
							maxs=100*(a*i+b*j)+k*c+l*d;
							maxsl=k*c+l*d;
						}
					}
				}
			}
		}
	}
	cout<<(long long)maxs<<" "<<(long long)maxsl<<"\n";
}

Measured memory_bytes: 3576
W, H, x, y = map(float,input().split())
judge = 0
ans = 0

if x == W/2 and y == H/2:
    judge = 1
elif y == (-H*x)/W + H or y == H*x / W:
    judge = 0
elif x == W/2 or y == H/2:
    judge = 0
else:
    judge = 0

ans = W*H / 2

print("{0:.6f}".format(ans), judge)


Measured memory_bytes: 3060
N = int(input())
if N == 1:
    print('Yes')
    print(2)
    print(1,1)
    print(1,1)
    exit()

k = 3
while k*(k-1) < N*2:
    k += 1

if k*(k-1) != N*2:
    print('No')
    exit()

print('Yes')
print(k)

ans = [[] for i in range(k)]
n = 1
for i in range(k-1):
    for j in range(i+1,k):
        ans[i].append(n)
        ans[j].append(n)
        n += 1

for row in ans:
    print(len(row), ' '.join(list(map(str,row))))

Measured memory_bytes: 9076
import math
import sys 
a, b = map(int,input().split())
# ans1 = math.ceil(a/0.08)
# ans2 = math.ceil(b/0.1)
# if ans1 == ans2:
#     print(ans1)
# elif ans1 > ans2:

for i in range(1001):
    ans1 = math.floor(i*0.08)
    ans2 = math.floor(i*0.1)
    if (ans1 == a) & (ans2 == b):
        print(i)
        sys.exit()
print(-1)


Measured memory_bytes: 3064
#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
//#ifndef rd
#define endl '\n'
//#endif
#ifdef rd
#define trace(...) cout<<"Line:"<<__LINE__<<" "; __f(#__VA_ARGS__, __VA_ARGS__)
template<typename Arg1>
void __f(const char* name, Arg1&& arg1) {
	cout<<name<<" : "<<arg1<<endl;
}
template<typename Arg1, typename ... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args) {
	const char* comma=strchr(names+1,',');
	cout.write(names,comma-names)<<" : "<<arg1<<" | ";
	__f(comma+1,args...);
}
#else
#define trace(...)
#endif
#define pb push_back
#define fi first
#define se second
#define mkp make_pair
//#define int long long
typedef long long ll;
typedef long double f80;
//#define double long double
#define pii pair<int,int>
#define pll pair<ll,ll>
#define sz(x) ((long long)x.size())
#define fr(a,b,c) for(int a=b; a<=c; a++)
#define frdec(a,b,c) for(int a=b; a>=c; a--)
#define rep(a,b,c) for(int a=b; a<c; a++)
#define trav(a,x) for(auto &a:x)
#define all(con) con.begin(),con.end()
const ll infl=2e18;
const int infi=2e9;
const int mod=1e9+7;
typedef vector<int> vi;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
mt19937 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
auto clk=clock();
int rng(int lim) {
	uniform_int_distribution<int> uid(0,lim-1);
	return uid(rang);
}
template<class t1, class t2, class t3>
t1 fast_expo(t2 x, t3 p) {
	if(p == 0) return 1;
	t1 r = fast_expo(x,p/2);
	if(p%2 != 0) return r * r * x;
	return r * r;
}
// Code from here...

void solve() {
	int n, a, b;
    cin >> n >> a >> b;
    cout << min(n*a, b);
}

signed main() {
	ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
	srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	cout<<fixed<<setprecision(10);
	int t=1;
	// cin>>t;
	while(t--)
		solve();
#ifdef rd
	cout<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
#endif
	return 0;
}

Measured memory_bytes: 256
//{{{
#include<algorithm>
#include<cmath>
#include<deque>
#include<fstream>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<random>
#include<set>
#include<sstream>
#include<sys/time.h>
#include<unordered_map>
#include<unordered_set>
#include<vector>
using ll = long long;
enum : int { M = (int)1e9 + 7 };
enum : ll { MLL = (ll)1e18L + 9 };
using namespace std;
#ifdef LOCAL
#include"rprint2.hpp"
#else
#define FUNC(name) template <ostream& out = cout, class... T> void name(T&&...){ }
FUNC(printde) FUNC(printdbe) FUNC(printdwe) FUNC(printdu);
#endif
template <template <class T, class = std::allocator<T>> class V, class E>
istream& operator >> (istream& in, V<E>& v){ for(auto& e : v){ in >> e; } return in; }
//}}}

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b)) << '\n';
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    public static final int F = 0, A = 1, B = 2, C = 3, D = 4;

    public int grade(int m, int f, int r) {
        int sum = m + f;
        if (m == -1 || f == -1) {
            return Main.F;
        } else if (sum >= 80) {
            return Main.A;
        } else if (sum >= 65) {
            return Main.B;
        } else if (sum >= 50) {
            return Main.C;
        } else if (sum >= 30) {
            if (r >= 50) {
                return Main.C;
            } else {
                return Main.D;
            }
        } else {
            return Main.F;
        }
    }

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

        while (true) {
            int inM, inF, inR;
            int result;
            inM = Integer.parseInt(scan.next());
            inF = Integer.parseInt(scan.next());
            inR = Integer.parseInt(scan.next());

            if (inM == -1 && inF == -1 && inR == -1) {
                break;
            }

            result = app.grade(inM, inF, inR);
            switch (result) {
                case Main.F:
                    System.out.println("F");
                    break;
                case Main.A:
                    System.out.println("A");
                    break;
                case Main.B:
                    System.out.println("B");
                    break;
                case Main.C:
                    System.out.println("C");
                    break;
                case Main.D:
                    System.out.println("D");
                    break;
            }
        }

    }
}



Measured memory_bytes: 26344
#include <bits/stdc++.h>
#define int long long
using namespace std;
int32_t main() {
int n;
cin>>n;
vector<int> v(n);
for(int i=0;i<n;i++){
cin>>v[i];
}
int heights = 0;
int max_ = v[0];
for(int i=1;i<v.size();i++){
if(v[i]<max_)heights+=max_-v[i];
max_ = max(max_,v[i]);
}
cout<<heights;
}  


Measured memory_bytes: 4836
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

def calc(x):
    lim=a*b
    mx=ceil(x, 2)*(x//2+1)
    return mx<lim

Q=INT()
for _ in range(Q):
    a,b=MAP()

    # 例外処理
    if a==b:
        print(a*2-2)
        continue

    # 二分探索
    low=1
    hi=10**18
    while low+1<hi:
        mid=(hi+low)//2
        if calc(mid):
            low=mid
        else:
            hi=mid
    print(low-1)


Measured memory_bytes: 3064
import java.io.*;
 
class Main {
  public static void main(String[] args)throws IOException{
    BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
    String str = br.readLine();
     
    String[] strAry = str.split(" ");
     
    int a = Integer.parseInt(strAry[0]);
    int b = Integer.parseInt(strAry[1]);
     
    if(a < b){
    	System.out.println("a < b");
    }else if(a > b){
    	System.out.println("a > b");
    }else if(a == b){
    	System.out.println("a == b");
    }
    
  }
}

Measured memory_bytes: 24276
#define _CRT_SECURE_NO_WARNINGS

#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>

/* define */
#define Yes(X) puts ( X ? "Yes" : "No")
#define YES(X) puts ( X ? "YES" : "NO")
#define FOR(i, a, b) for ( int i = a; i < b ; i++)
#define REP(i, n) for ( int i = 0; i < n ; i++)
#define max(a, b) (((a) > (b)) ? (a) : (b))
#define min(a, b) (((a) < (b)) ? (a) : (b))
#define max3(a, b, c) ((max((a), (b)) > (c)) ? max((a), (b)) : (c))
#define min3(a, b, c) ((min((a), (b)) < (c)) ? min((a), (b)) : (c))

/* const */
const int MOD = (int)1e9 + 7;

/* alias */
typedef long long ll;
typedef unsigned  u;

/* function */
int cmp(const void *a, const void *b) {
	return *(int*)a - *(int*)b;
}
int cmp2(const void *a, const void *b) {
	return *(int*)b - *(int*)a;
}

/* main */

int main() {
	ll n, k, a, b, c[100001] = { 0 };
	scanf("%lld%lld", &n, &k);
	REP(i, n) {
		scanf("%lld%lld", &a, &b);
		c[a] += b;
	}
	REP(i, 100001) {
		if (k > c[i]) k -= c[i];
		else {
			printf("%d", i);
			return 0;
		}
	}
}

Measured memory_bytes: 896