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

string s1,s2;

int main()
{
	cin>>s1>>s2;
	
	int len=s1.size();
	
	for(int i=0;i<len;i++)
	 if(s1[i]!=s2[i])
	 {
	 	cout<<"No";
	 	return 0;
	 }
	
	cout<<"Yes";
	return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
 
 
char x[105][105];
 
 
int main() {
	int a, b;
	cin >> a >> b;
	a--,b--;
	for(int i = 1;i <= 50; i++)
		for(int j = 1; j <= 100; j++)
			x[i][j] = '.';
	for(int i = 51; i <= 100; i++)
		for(int j = 1; j <= 100; j++)
			x[i][j] = '#';
	for(int i = 1;i <= 50 && b; i += 2)
		for(int j = 1; j <=100 && b; j += 2)
			x[i][j] = '#', b--;
	for(int i = 100; i > 50 && a; i-=2)
		for(int j = 1; j <= 100 && a;j += 2)
			x[i][j] = '.', a--;
	puts("100 100");
	for(int i = 1; i <= 100; i++, puts(""))
		for(int j = 1;j <= 100; j++)
			cout << x[i][j];
	return 0;
}


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

int main(){
    int n;
    cin>>n;
    string s;
    cin>>s;
    int ans=0;
    rep(i,n-2){
        if(s[i]=='A' &&s[i+1]=='B' && s[i+2]=='C')ans++;
    }
    cout<<ans<<endl;
    return 0;
}

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

using namespace std;

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))
#define OUT(P) cout << (P) << endl
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)
typedef long long ll;

int sum_digits(int num);
template <class T>
vector<T> copy_vector(vector<T> vec);
int gcd(int a, int b);

int main() {
    int n;
    cin >> n;
    vector<int> l(n);
    for(int i=0; i<n; i++) cin >> l[i];
    sort(l.rbegin(), l.rend());
    int max_elem = l[0];
    int sum = 0;
    for(int i=1; i<n; i++) {
        sum += l[i];
    }
    cout << ((max_elem < sum)? "Yes" : "No") << endl; 

    return 0;
}

/******************************/
/***** DECRARED FUNCTIONS *****/
/******************************/

int sum_digits(int num) {
    int rtn = 0;
    while(num != 0) {
        int tmp = num % 10; 
        rtn += tmp;
        num /= 10; 
    }   
    return rtn;
}

// vectorのコピー
template <class T>
vector<T> copy_vector(vector<T> vec) {
    vector<T> rtn;
    rtn.reserve(vec.size());
    copy(vec.begin(), vec.end(), back_inserter(rtn));
    return rtn;
}

// ユークリウッドの互除法
int gcd(int a, int b) {
    if(b==0) return a;
    else return gcd(b, a % b);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define REVETSE(c) reverse((c).begin(),(c).end())
#define SUM(c) accumulate((c).begin(),(c).end(),0)
#define ALL(a)  (a).begin(),(a).end()
// int gcd(int a,int b){return b?gcd(b,a%b):a;}
long long gcd(long long a,long long b){return b?gcd(b,a%b):a;}

using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class T> T maxt(T x,T y) {
    if (x>y) return x;
    else return y;
}
template<class T> T mint(T x,T y) {
    if (x>y) return y;
    else return x;
}
//sort(v.rbegin(), v.rend(), [](auto& x, auto& y){return x[1] < y[1];});
//cout << fixed << setprecision(10) << ans << defaultfloat << endl;
typedef long long ll;
typedef vector<int> Vi;
typedef vector<ll> Vl;
typedef vector<double> Vd;
typedef vector<string> Vs;

//小数出力
double print_double(double d){printf("%.10f", d);}

long long m = 1e9+7, mod = 1e9+7;
//逆元　a/b の modをとるとき -> a*modinv(b)%mod
long long modinv(long long a, long long m = 1e9+7) {
    long long b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m; 
    if (u < 0) u += m;
    return u;
}

//約数列挙
vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}








int main() {
  int N,K;
  cin >> N >> K;
  Vi v(N),dp(2*K+1,0);
  rep(i,N) {
    cin >> v[i];
    }

  rep(i,K) {
    if (dp[i]==0) {
      rep(j,N) {
        dp[i+v[j]] = 1;
      }
    }
  }
  
  if (dp[K]) cout << "First";
  else  cout << "Second";
}

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

using namespace std;


using int64 = long long;
const int mod = 1e9 + 7;

const int64 infll = (1LL << 62) - 1;
const int inf = (1 << 30) - 1;

struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    cerr << fixed << setprecision(10);
  }
} iosetup;


template< typename T1, typename T2 >
ostream &operator<<(ostream &os, const pair< T1, T2 > &p) {
  os << p.first << " " << p.second;
  return os;
}

template< typename T1, typename T2 >
istream &operator>>(istream &is, pair< T1, T2 > &p) {
  is >> p.first >> p.second;
  return is;
}

template< typename T >
ostream &operator<<(ostream &os, const vector< T > &v) {
  for(int i = 0; i < (int) v.size(); i++) {
    os << v[i] << (i + 1 != v.size() ? " " : "");
  }
  return os;
}

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

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 = int64 >
vector< T > make_v(size_t a) {
  return vector< T >(a);
}

template< typename T, typename... Ts >
auto make_v(size_t a, Ts... ts) {
  return vector< decltype(make_v< T >(ts...)) >(a, make_v< T >(ts...));
}

template< typename T, typename V >
typename enable_if< is_class< T >::value == 0 >::type fill_v(T &t, const V &v) {
  t = v;
}

template< typename T, typename V >
typename enable_if< is_class< T >::value != 0 >::type fill_v(T &t, const V &v) {
  for(auto &e : t) fill_v(e, v);
}

template< typename F >
struct FixPoint : F {
  FixPoint(F &&f) : F(forward< F >(f)) {}

  template< typename... Args >
  decltype(auto) operator()(Args &&... args) const {
    return F::operator()(*this, forward< Args >(args)...);
  }
};

template< typename F >
inline decltype(auto) MFP(F &&f) {
  return FixPoint< F >{forward< F >(f)};
}

int main() {
  int N;
  cin >> N;
  vector< int > X(N), Y(N);
  vector< int > ord(N);
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> Y[i];
    ord[i] = i;
  }
  int add = 0;
  double ret = 0.0;
  do {
    for(int j = 1; j < N; j++) {
      ret += hypot(X[ord[j]] - X[ord[j - 1]], Y[ord[j]] - Y[ord[j - 1]]);
    }
    ++add;
  } while(next_permutation(begin(ord), end(ord)));
  cout << ret / add << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll update(ll t)
{
    ll s[15],cnt=0;
    while(t)
    {
        s[cnt++]=t%10;
        t/=10;
    }
    int i=0;
    for(;i<cnt;i++)
    {
        if(s[i]==7) s[i]=3;
        else
        {
            if(s[i]==3) s[i]=5;
            else if(s[i]==5) s[i]=7;
            break;
        }
    }
    if(i>=cnt) s[cnt]=3,cnt++;
    ll ans=0;
    for(i=cnt-1;i>=0;i--)
        ans=ans*10+s[i];
    return ans;
}
bool check(ll t)
{
    bool f1=false,f2=false,f3=false;
    while(t)
    {
        ll p=t%10;
        if(p==3) f1=true;
        else if(p==5) f2=true;
        else if(p==7) f3=true;
        t/=10;
    }
    return f1&&f2&&f3;
}
int main()
{
    ll n;
    scanf("%lld",&n);
    ll ans=0,tmp=333;
    while(tmp<=n)
    {
        if(check(tmp)) ans++;
        tmp=update(tmp);
    }
    printf("%lld\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#ifdef _DEBUG
#define debug(x) cout << "[debug] " << #x << ": " << x << endl
#else
#define debug(x)
#endif
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr double PI = 3.141592653589793238462643383279;
ll getDigit(ll x) {
  return x == 0 ? 1 : log10(x) + 1;
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

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

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

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

const int mod = 1000000007;
struct mint {
  ll x;
  // コンストラクタ。引数のxが負でもxは正になるようにしている
  mint(ll x = 0) : x((x % mod + mod) % mod) {
  }
  mint operator-() const {
    return mint(-x);
  }
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod - a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    return mint(*this) += a;
  }
  mint operator-(const mint a) const {
    return mint(*this) -= a;
  }
  mint operator*(const mint a) const {
    return mint(*this) *= a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod - 2);
  }
  mint& operator/=(const mint a) {
    return *this *= a.inv();
  }
  mint operator/(const mint a) const {
    return mint(*this) /= a;
  }
};
istream& operator>>(istream& is, const mint& a) {
  return is >> a.x;
}
ostream& operator<<(ostream& os, const mint& a) {
  return os << a.x;
}

mint f(int n) {
  if (n == 0) {
    return 1;
  }
  mint x = f(n / 2);
  x *= x;
  if (n % 2 == 1) {
    x *= 2;
  }
  return x;
}

mint choose(ll n, ll a) {
  mint x = 1, y = 1;
  rep(i, a) {
    x *= n - i;
    y *= i + 1;
  }
  return x / y;
}

signed main() {
  ll n, a, b;
  cin >> n >> a >> b;

  mint ans = f(n);
  ans -= 1;
  ans -= choose(n, a);
  ans -= choose(n, b);
  COUT(ans);
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(){
 int n, i;
 int array[100];

 scanf("%d", &n);

 for(i = 0; i<n; i++){
  scanf("%d", &array[i]);
 }

 for(i = 0; i<n-1; i++){
  printf("%d ", array[n-i-1]);
 }

 printf("%d\n", array[0]);

 return 0;
}

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

#define rep(i,n) for(int i=0; i<n; i++)
#define rept(i,a,b) for(int i=a; i<b; i++)
#define all(x) (x).begin(),(x).end()

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

const int MOD = 1e9 + 7;


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


    int a,b;
    cin >> a >> b;
    cout << 6 - a - b << endl;


    return 0;
}



Measured memory_bytes: 256
MOD = 10 ** 9 + 7
s = int(input())

if s == 0 or s == 1:
    print(0)
else:
    ans = [1, 0, 0]
    for i in range(3, s + 1):
        ans.append(ans[i - 1] + ans[i - 3])
    print(ans[-1] % MOD)


Measured memory_bytes: 63720
#include <stdio.h>
#include <cstdio>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue> 
 
using namespace std;
 
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);

	string S;

	cin >> S;

	for(int i = 0; i < S.length(); i++) {
		cout << "x";
	}

	cout << endl;
}

Measured memory_bytes: 256
def read_int():
    return int(input().strip())


def read_ints():
    return list(map(int, input().strip().split(' ')))


def solve():
    N, K = read_ints()
    p = read_ints()
    p.sort()
    return sum(p[:K])


if __name__ == '__main__':
    print(solve())


Measured memory_bytes: 62204
#include <iostream>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <math.h>
using namespace std;

int main(){
	
	char p[1000000];
	for(int i=2;i<1000000;i++)p[i]=1;
	for(int i=2;i<1000;i++){
		if(p[i]==0)continue;
		for(int j=i+1;j<1000000;j++){
			if(p[j]==0)continue;
			if(j%i==0)p[j]=0;
		}
	}
	
	int n,c;
	while(scanf("%d",&n)!=EOF){
		c=0;
		for(int i=0;i<=n;i++)if(p[i]==1)c++;
		cout<<c<<endl;
	}
}

Measured memory_bytes: 1864
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  ll x[5];
  int i;

  for (i=0; i<5; i++) {
    cin >> x[i];
  }
  for (i=0; i<5; i++) {
    if (x[i] == 0) {
      printf("%d\n", i+1);
      return 0;
    }
  }

  return 0;
}


Measured memory_bytes: 3760
#include <iostream>
#include <algorithm>
#include <cstring>

using namespace std;

int path[101];
int main(void)
{
	int a, b;
	while (cin >> a >> b)
	{
		if(a == 0 && b == 0)
		{
			bool ans = all_of(path + 3, path + 100, [=](int n){return n % 2 == 0;}) && path[1] % 2 == 1 && path[2] % 2 == 1;
			cout << (ans ? "OK" : "NG") << endl;
			memset(path, 0, sizeof(path));
		}
		path[a]++;
		path[b]++;
	}
	return 0;
}

Measured memory_bytes: 1152
program AGC026A
    implicit none
    integer(8)::N,i,ans,scount
    integer(8),allocatable,dimension(:)::A
    read*,N
    allocate(A(N))
    read*,A
    ans=0
    scount=1

    do i=2,N
        if(A(i)==A(i-1))then
            scount=scount+1
        else
            ans=ans+scount/2
            scount=1
        end if
    end do
    ans=ans+scount/2
    
    print'(i0)',ans
end program AGC026A

Measured memory_bytes: 256
#include<iostream>

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1c(i, n) for (int i = 1; i <= (int)(n); i++)
#define repc1(i, n) for (int i = (int)(n); i >= 1; i--)
typedef long long ll;

using namespace std;

int H, W, K, dpw[15][2][2], mod = 1000000007;
ll dph[110][15];

void all_amida(int a) {
  int res=1;
  rep(i, W-2) if(((a>>i)&3)==3) res=0;
  if(res) rep1c(i, W) {
    int b = ((a<<1)>>(i-1))&3;
    if (b==0) dpw[i][0][0]++;
    else if (b==1) dpw[i][1][0]++;
    else if (b==2) dpw[i][0][1]++;
  }
  return;
}

int main() {
  cin >> H >> W >> K;
  rep(i, 1<<(W-1)) all_amida(i);
  rep1c(i, W) if(i==K) dph[H+1][i]=1; else dph[H+1][i]=0;
  dph[H+1][0]=dph[H+1][W+1]=0;
  repc1(i, H) rep1c(j, W) {
    dph[i][j] = (
      dph[i+1][j-1] * dpw[j][1][0] +
      dph[i+1][j]   * dpw[j][0][0] +
      dph[i+1][j+1] * dpw[j][0][1]
    ) % mod;
  }
  cout << dph[1][1] << endl;

  return 0;
}


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

#define min3(a,b,c)   min(a,min(b,c))
#define max3(a,b,c)   max(a,max(b,c))
#define min4(a,b,c,d) min(min(a,b),min(c,d))
#define max4(a,b,c,d) max(max(a,b),max(c,d))

#define count_one(a) __builtin_popcount(a)  // Returns the number of set bits(1) in a number(a). In long long use __builtin_popcountll(a)
#define parity(i)    __builtin_parity(i)  //even parity 0 and odd parity 1
#define blz(a)       __builtin_clz(a) //Returns the number of leading zeroes in a number(a)
#define btz(a)       __builtin_ctz(a) //Returns the number of trailing zeroes in a number(a)
#define gcd(a,b)     __gcd(a,b)
#define lcm(a,b)     (a*(b/gcd(a,b)))

#define pb   push_back
#define PI   M_PI
#define endl "\n"
#define sc   scanf
#define pf   printf

#define ll  long long
#define ull unsigned long long

#define W(t)            while(t--)
#define rep1(i,n)       for(int i = 0; i < n; i++)
#define rep2(a,b)       for(int i = a; i <= b; i++)
#define rep3(a,b,c)     for(int i = a; i <= b; i+=c)
#define irep(a,b,c)     for(int i = b; i >=a; i-=c)
#define repit(it,type)  for(it = type.begin(); it != type.end(); it++)
#define IOS ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
using namespace std;
using namespace __gnu_cxx;

int main()
{
     IOS
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int x,y;

    cin>>x>>y;

    if(x*4 >= y)
    {
         if(x*2 <= y)
         {
             if(y&1)
               cout<<"No\n";
             else
               cout<<"Yes\n";
         }
         else
          cout<<"No\n";
    }
    else
     cout<<"No\n";

     return 0;
}



Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int K; cin>>K;
  vector<set<string>> S(11);
  rep(i,1,10) S[0].insert(to_string(i));
  REP(i,1,10){
    for(auto p:S[i-1]){
      char X=p[p.size()-1];
      X++;
      if(X<='9')
      S[i].insert(p+(X));
      X--;
      S[i].insert(p+(X));
      X--;
      if(X>='0')
      S[i].insert(p+X);
    }
  }
  int cnt=0;
  rep(i,0,11){
    if(cnt+S[i].size()>=K){
      for(auto p:S[i]){
        cnt++;
        if(cnt==K) cout<<p<<endl;
      }
      break;
    }
    cnt+=S[i].size();
  }
  }



Measured memory_bytes: 63360
package main

import (
	"fmt"
	"math"
)

func main() {
	var x int64
	fmt.Scan(&x)

	for {
		if IsPrime(x) {
			break
		}
		x++
	}

	fmt.Println(x)
}

func scanNums(len int64) (nums []int64) {
	var num int64
	var i int64
	for i = 0; i < len; i++ {
		fmt.Scan(&num)
		nums = append(nums, num)
	}
	return
}

func IsPrime(value int64) bool {
	var i int64
	for i = 2; i <= int64(math.Floor(float64(value)/2)); i++ {
		if value%i == 0 {
			return false
		}
	}
	return value > 1
}


Measured memory_bytes: 512
//inlclude before define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
#include<assert.h>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef pair<int, int> P1;
typedef long long int ll;

//define
#define INF 1e9
#define NUM 1000000007
#define all(x) begin(x),end(x)
#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 REP(i,a,b) for(int i=int(a);i<int(b);i++)
#define chmin(a,b) a=min((a),(b))
#define chmax(a,b) a=max((a),(b))


int main() {
	ll n, a, b;
	cin >> n >> a >> b;

	ll ans = 1;
	//ll min = a * n - 1 + b;

	ans += (n - 2)*(b - a);

	if (n == 1 && a == b) {
		ans = 1;
	} else if (n == 1 && a != b) {
		ans = 0;
	} else if (a > b) {
		ans = 0;
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define INF 100000000
#define EPS 1e-10
#define MOD 1000000007
using namespace std;
typedef pair<double,double> P;
typedef pair<int,P> PP;

int n;
int ans;
vector<double> x, y;
vector<PP> v1, v2;

void solve(){
	x.clear(); y.clear(); v1.clear(); v2.clear();
	x.resize(n); y.resize(n);
	ans = 1;
	rep(i,n) cin >> x[i] >> y[i];
	for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
		double I = i/10.0, J = j/10.0;
		int cnt = 0;
		rep(k,n){
			if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
		}
		v1.push_back(PP(cnt,P(I,J)));
	}
	sort(v1.begin(),v1.end(), greater<PP>());
	rep(u,10){
		P p = v1[u].second;
		for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
			double I = p.first-0.05+i/1000.0, J = p.second-0.05+j/1000.0;
			int cnt = 0;
			rep(k,n){
				if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
			}
			v2.push_back(PP(cnt,P(I,J)));
		}
	}
	sort(v2.begin(),v2.end(), greater<PP>());
	
	rep(u,10){
		P p = v2[u].second;
		for(int i = 0; i <= 100; i++) for(int j = 0; j <= 100; j++){
			double I = p.first-0.005+i/10000.0, J = p.second-0.005+j/10000.0;
			int cnt = 0;
			rep(k,n){
				if((x[k]-I)*(x[k]-I)+(y[k]-J)*(y[k]-J) < 1) cnt++;
			}
			ans = max(ans,cnt);
		}
	}
	cout << ans << endl;
}

int main(){
	while(cin >> n){
		if(n == 0) break;
		solve();
	}
}

Measured memory_bytes: 4432
#include <bits/stdc++.h>
#define fi first
#define se second
#define ll long long
using namespace std;

int n,t,mx,low;
map<int,int> cnt;

int main() {
	#ifdef kvutxdy
	freopen("C:/Users/khanh/OneDrive/RoadtoPurple/Code/Codeforces/input.in", "r", stdin);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);
	cin>>n>>t;
	cin>>low;
	for(int i=1;i<n;++i){
		int x; cin>>x;
		if(low>=x){
			low=x;
			continue;
		}
		if(x-low>=mx){
			mx=max(mx,x-low);
			++cnt[mx];
		}
		low=min(low,x);
	}
	cout<<cnt[mx];
}

Measured memory_bytes: 4992
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    ll A, B, C;
    cin >> A >> B >> C;
    set<ll> s;
    ll amari = A % B;
    ll tmp = amari;
    while(true) {
        if (tmp == C) {
            YES;
            return 0;
        }
        if (s.find(tmp) == s.end()) {
            s.insert(tmp);
            tmp = tmp + amari;
            tmp %= B;
        } else {
            NO;
            return 0;
        }
    }

    return 0;
}


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

#define rep(i,n) for(long long int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(long long int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(long long int i=(a);i>(b);i--)
#define all(v) (v).begin(), (v).end()
#define pb(q) push_back(q)
#define P pair<int,int>
#define Abs(a,b) max(a,b)-min(a,b)
#define YES(condition) if(condition){cout << "YES" << endl;}else{cout << "NO" << endl;}
#define Yes(condition) if(condition){cout << "Yes" << endl;}else{cout << "No" << endl;}
#define Cout(x) cout<<(x)<<endl

typedef long long ll;

using namespace std;

const int INF = 1e9,MOD = 1e9 + 7;
const ll LINF = 1e18;

//while(x!=0){
            //sum+=x%10;
           // x/=10;
        //}
        //各桁の和

//pair<int,int> p[100000];
//P r[100000];
//cin >> tmp;
//p[i]=make_pair(tmp,i);
//cout << p[i].second+1 << endl;//ペアの右側つまりiを出力

//s.find(w[i])==string::npos
//findの使い方

//for(int i=0;i<n;i++){
   // b[i]=x%2;
    //x/=2;
  //}二進数

long long int n=1,cnt=0,ans=0,a,b,c,cmp,cmpa,cmpb,cmpc,data,m,h,x,y,xcmp=0,ycmp=0,sum=0;

string s,w;

vector<int> z;

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

       cin >> a >> b >> c;
       if(a%2!=0 || b%2!=0 || c%2!=0){
           Cout(0);
           return 0;
       }
       if(a==b && b==c){
           if(a%2==0 && b%2==0 && c%2==0){
               Cout(-1);
               return 0;
           }
       }
       else{
           while(1){
          cmpa=a;
          cmpb=b;
          cmpc=c;
          a=(cmpb+cmpc)/2;
          b=(cmpa+cmpc)/2;
          c=(cmpa+cmpb)/2;
          ans++;
          if(a%2!=0 || b%2!=0 || c%2!=0){
           Cout(ans);
           return 0;
       }
       }
       }
return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << "\n"; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " <<to_string(H);
  debug_out(T...);
}
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

int n,m,a,b,c;
string s,t;

void solve(){
  cin>>a>>b;
  s=to_string(a);
  t=to_string(b);
  string p="",q="";
  rep(i,b)q+=s;
  rep(i,a)p+=t;
  if(q<=p)cout<<q<<endl;
  else cout<<p<<endl;
}
 
int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
	solve();
	return 0;
}


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

typedef long long ll;
using namespace std;

// gcd(a,b) および ax+by=gcd(a,b) となる x, y の導出
ll Extgcd(ll a, ll b, ll& x, ll& y)
{
    ll g = a;
    if (b != 0) {
        Extgcd(b, a % b, y, x);
        y -= (a / b) * x;
    } else {
        x = 1, y = 0;
    }
    return g;
}

// ax = gcd(a, m)となるxの導出
// a,m が互いにその時、x は mod m での a のモジュラ逆数となる
ll ModInverse(ll a, ll m)
{
    ll x, y;
    Extgcd(a, m, x, y);
    return (x % m + m) % m;
}

// mod MOD での i! のモジュラ逆数テーブルの生成
// i は 0 ~ MAX_NUM-1
constexpr ll MOD = 1000000007;
constexpr ll MAX_NUM = 100000 + 3;

vector<ll> fact(MAX_NUM);
vector<ll> rfact(MAX_NUM);

void FactInit()
{
    fact[0] = rfact[0] = 1;
    for(int i = 1; i < MAX_NUM; i++) {
        fact[i] = fact[i - 1] * i % MOD;
        rfact[i] = rfact[i - 1] * ModInverse(i, MOD) % MOD;
    }
}

// C(n,k) (mod MOD)の導出
inline ll Combination(ll n, ll k)
{
    return (fact[n] * rfact[k] % MOD) * rfact[n - k] % MOD;
}

int main() {
    FactInit();
    int n, m;
    cin >> n >> m;
    ll ans = 1;
    if (abs(n - m) == 0) {
        ans = 2;
    } else if (abs(n - m) == 1) {
        ;
    } else {
        cout << "0" << endl;
        return 0;
    }

    cout << (((ans * fact[n]) % MOD) * fact[m]) % MOD << endl;
    return 0;
}


Measured memory_bytes: 1920
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.TreeMap;
import java.util.ArrayDeque;
import java.awt.Point;

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

        System.out.println(A * B);
    }
}

Measured memory_bytes: 35760
n=int(input())
h=list(map(int,input().split()))[::-1]
 
flg=True
for i in range(1,n):
    if h[i-1]<h[i]:
        h[i]-=1
        if h[i-1]<h[i]:
            flg=False
            break
print('Yes' if flg else 'No')

Measured memory_bytes: 14396
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
#define test        int t;cin>>t;while(t--)
#define REP(i,a,b)  for(int i=a,i<=b;i++)
#define MAXN        200001


// int par[MAXN],sz[MAXN];
// void makeset(int i){
//     par[i]=i;
//     sz[i]=1;
// }

// int find(int i){

//     while(par[i]==i)
//         return i;
//     return par[i]=find(par[i]);
// }

// void combine(int u,int v){

//     u=find(u);
//     v=find(v);
//     if(u==v) 
//         return;
//     else
//     {   
//         // cout<<sz[pu]<<"  "<<sz[pv]<<endl;
//         if(sz[u] < sz[v])
//             swap(u,v);
//         par[v]=u;
//         sz[u]+=sz[v];
//     }
// }

vi adj[MAXN];
bool vis[MAXN];

void dfs(int src,int &cnt){
    vis[src]=true;
    cnt++;
    for(auto x:adj[src]){
        if(!vis[x])
            dfs(x,cnt);
    }
}
int32_t main()
{
    
    int n,m;
    cin>>n>>m;

    // for(int i=1;i<=n;i++){
    //     makeset(i);
    // }
    memset(vis,false,sizeof(vis));
    int u,v;
    for(int i=0;i<m;i++){
        cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }

    int mx=INT_MIN;
    for(int i=1;i<=n;i++){
        if(!vis[i]){
            int cnt=0;
            dfs(i,cnt);
            mx=max(mx,cnt);
        }
    }

    // cout<<endl;
    cout<<mx<<endl;
    return 0;
}


Measured memory_bytes: 24032
#include <iostream>
#include<utility>
#include<algorithm>
using namespace std;
int main(void){
    int N;
    cin>>N;
    pair<long long, long long> C[N];
    long long A,B,E,F;
    
    for(int i=0;i<N;i++){
        cin>>A>>B;
        C[i]=make_pair(B,A);
        
    }
    sort(C,C+N);
   
    E=0;
    for(int i=0;i<N;i++){
        E=E+C[i].second;
        F=C[i].first;
        
        if(F<E){
            cout<<"No"<<endl;
            return 0;
        }
        
    }
    
    
    cout<<"Yes"<<endl;
    
    return 0;
    
}

Measured memory_bytes: 3328
#pragma GCC optimize("Ofast")
#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 print
#define print(...)
#define trace(...)
#define endl '\n'
#endif
#define pb push_back
#define fi first
#define se second
#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 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 = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;
//const int mod=998244353;
const int mod = 1000000007;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk = clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) { uniform_int_distribution<int> uid(0, lim - 1); return uid(rang); }
int powm(int a, int b) { int res = 1; while (b) { if (b & 1) res = (res * a) % mod; a = (a * a) % mod; b >>= 1; } return res; }

int32_t main() {
	ios::sync_with_stdio(false); cin.tie(NULL); cout.precision(10); srand(chrono::high_resolution_clock::now().time_since_epoch().count());
	int n; cin >> n;
	string s; cin >> s;
	std::map<char, int> mp;
	for (auto ch : s) mp[ch]++;
	int ans = 1;
	for (auto p : mp)
		ans = ans * (p.se + 1) % mod;
	ans += mod - 1;
	ans %= mod;
	cout << ans << '\n';
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int INF = 1e9 + 5;

int main()
{
    int n;
    scanf("%d",&n);
    int dp[n + 1][3] = {},in[3];
    for(int i = 1; i <= n; i++)
    {
        cin >> in[0] >> in[1] >> in[2];
        for(int j = 0; j < 3; j++)
        {
            for(int k = 0; k < 3; k++)
                if(j != k)
                    dp[i][k] = max(dp[i][k], dp[i - 1][j] + in[j]);
        }
    }
    int ans = max(max(dp[n][0],dp[n][1]),dp[n][2]);
    cout << ans ;
}


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

const long long MOD = 1000000007LL;
const long long INF = 1e18;

int GCD(int a, int b){return b == 0 ? a : GCD(b, a % b);}
long long fast_exp(long long base, long long exp, long long mod = MOD) {
    long long tot = 1;
    for(;exp > 0;exp >>= 1) {
       if((exp & 1) == 1) tot = tot * base % mod;
       base = base * base % mod;
    }
    return tot;
}
long long slow_mult(long long base, long long exp, long long mod = MOD) {
    long long tot = 0;
    for(;exp > 0;exp >>= 1){
       if((exp & 1) == 1) tot = (tot + base) % mod;
       base = base * 2 % mod;
    }
    return tot;
}

struct chash {
    static uint64_t splitmix64(uint64_t x) {x += 0x8e3779b97f4a7c15; x = (x ^ (x >> 30)) * 0xbf54876d1ce4e5b9; x = (x ^ (x >> 27)) * 0x94d049bb133111eb; return x ^ (x >> 31);}
    size_t operator()(uint64_t x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x + FIXED_RANDOM);}
    size_t operator()(pair<uint64_t,uint64_t> x) const { static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count(); return splitmix64(x.first + FIXED_RANDOM)^(splitmix64(x.second + FIXED_RANDOM) >> 1);}
};

int main(){

    cin.sync_with_stdio(0); cin.tie(0); cout.tie(0);

    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);

    long long n; cin >> n;

    cout << n * (n - 1) / 2;

    return 0;
}


Measured memory_bytes: 256
public class Main {


  private static void solve() {
    int n = ni();
    int k = ni();
    
    for (int a = 1; a <= n; a ++) {
      
    }
    // (n/k-1)^3 + 
    
    long ret = (long)(n/k) * (n/k) * (n/k);
    
    if (k % 2 == 0) {
      int cnt = 0;
      for (int i = 1; i <= n; i ++) {
        if (i % (k / 2) == 0 && i % k != 0) cnt ++;
      }
      ret += (long)cnt * cnt * cnt;
    }
    System.out.println(ret);
  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}


Measured memory_bytes: 22740
n = int(input())
l = list(map(int,input().split()))

nums = set([])
for i in range(n):
    for j in range(n):
        for k in range(n):
            if l[i] == l[j] or l[i] == l[k] or l[j] == l[k]:
                continue
            else:
                ver = [l[i],l[j],l[k]]
                num = [i,j,k]
                ver.sort()
                num.sort()
                if ver[0] + ver[1] > ver[2]:
                    nums.add(tuple(num))

print(len(nums))

Measured memory_bytes: 30864
import sys
import numpy as np

# 実行環境(0:vscode, 1:atcoder)
MODE = 1

# 入力の次元
DIMENSION = 1

# int型に変換
INT_TYPE = 1

if not (MODE):
    with open("input.txt", "r") as f:
        s = f.read()
else:
    s = sys.stdin.read()

if DIMENSION == 0:
    if INT_TYPE == 1:
        s = int(s)
elif DIMENSION == 1:
    if INT_TYPE == 0:
        s = s.split()
    elif INT_TYPE == 1:
        s = [int(x) for x in s.split()]
elif DIMENSION == 2:
    if INT_TYPE == 0:
        s = [x.split() for x in s.splitlines()]
    elif INT_TYPE == 1:
        s = [[int(y) for y in x.split()] for x in s.splitlines()]

x, y = s
a = y - 2 * x
b = 4 * x - y
if a % 2 == 0 and b % 2 == 0 and a >= 0 and b >= 0:
    print("Yes")
else:
    print("No")


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

using namespace std;
using int64 = long long;

constexpr int DEBUG = 0;

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

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

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

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

  vector<int64> dp(n);
  dp[0] = 1000;
  for (int i = 0; i < n - 1; i++) {
    for (int j = i + 1; j < n; j++) {
      if (xs[i] < xs[j]) {
        int64 u = dp[i] / xs[i];
        int64 r = dp[i] % xs[i];
        int64 v = u * xs[j] + r;
        UpdateMax(dp[j], v);
      }
    }
    if (i + 1 < n) {
      UpdateMax(dp[i + 1], dp[i]);
    }
  }

  int64 ans = 0;
  for (int i = 0; i < n; i++) {
    UpdateMax(ans, dp[i]);
  }
  cout << ans << endl;
}

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

const int INF = 1001001001;
vector<vector<int>> dist(100005, vector<int>(3, INF));

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

	// 有向グラフG
	vector<vector<int>> to(n);
	for (int i = 0; i < m; i++)
	{
		int a, b;
		cin >> a >> b;
		a--; b--;
		to[a].push_back(b);
	}

	int sv, tv;
	cin >> sv >> tv;
	sv--; tv--;

	// BFS（幅優先探索）
	queue<pair<int, int>> q;
	q.push(pair<int, int>(sv, 0));
	dist[sv][0] = 0;
	while (!q.empty()) {
		int v = q.front().first;
		int l = q.front().second;
		q.pop();
		for (int u : to[v]) {
			int nl = (l + 1) % 3;
			if (dist[u][nl] != INF) continue;
			dist[u][nl] = dist[v][l] + 1;
			q.push(pair<int, int>(u, nl));
		}
	}
	int ans = dist[tv][0];
	if (ans == INF) ans = -1;
	else ans /= 3;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 11136
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<bitset>
#include<cstdio>
#include<cmath>
#include<deque>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<string>
#include<tuple>
#include<utility>
#include<vector>
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
typedef vector<vector<int>> vvi;

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define REP(i, n)  for(int i=0; i<(int)(n); i++)
#define REPS(i, n)  for(int i=1; i<=(int)(n); i++)
#define PER(i, n) for(int i=(int)(n)-1; i>= 0; i--)
#define PERS(i, n)  for(int i=(int)(n); i>0; i--)
#define FOR(i, c) for(__typeof((c).begin()) i = (c).begin(); i!=(c).end(); i++)
#define RFOR(i, c)  for(__typeof((c).rbegin()) i=(c).rbegin(); i!=(c).end(); i++)
#define ALL(container)  (container).begin(), (container).end()
#define RALL(container) (container).rbegin(), (container).rend()
#define SZ(container) (container).size()
#define FILL0(n)  setfill('0') << right << setw(n)
#define mp(a, b)  make_pair(a, b)
#define toLower(c)  c+0x20
#define toUpper(c)  c-0x20
#define pb  push_back
#define eb  emplace_back

const int INF = 1e9;
const long long LLINF = 1e18;
const ll MOD = 1000000007;
const int MSIZE = 100007;
const double Pi = 3.14159265358979323146;

int main(){
  int n, h; cin >> n >> h;
  int ans = h;
  int ma=0;
  vector<ll> b(n);
  REP(i, n){
    int a;  cin >> a >> b[i];
    ma = max(ma, a);
  }
  sort(RALL(b));
  int cnt=0;
  for(int k=0; k<=n; k++){
    if(k>0) h-=b[k-1];
    int cnt = 0;
    if(h>0) cnt =((h+ma-1)/ma);
    ans = min(ans, k+cnt);
  }
  cout << ans << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
	int n;
	cin >> n;
	ll a[n];
	REP(i,n){
		cin >> a[i];
		a[i] -= i + 1;
	}
	sort(a, a + n);
	ll med = a[n / 2];
	ll ans = 0;
	REP(i,n){
		a[i] -= med;
		ans += abs(a[i]);
	}
	cout << ans << endl;
}

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

long m[100000];
long t[100000];

int main(){
  long N;
  long a;
  long max=0;
  for(long i=0;i<100000;i++){
    m[i]=0;
    t[i]=0;
  }
  cin >> N;
  for(long i=0;i<N;i++){
    cin >> a;
    m[a]++;
  }
  t[1]= m[0]+m[1]+m[2];
  max = t[1];

  for(long i=2;i<100000;i++){
    t[i]=t[i-1]+m[i+1]-m[i-2];
    if(max<t[i]){
      max=t[i];
    }
  }
  cout << max << endl;
  return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;
const int MOD = 1e9 + 7;
typedef long long lint;
const int INF = 1e7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repi(i, k, n) for (int i = (k); i < (int)(n); ++i)
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define all(x) (x).begin(), (x).end()
#define pb push_back
int main()
{
    map<int, int> m;
    int n, k;
    cin >> n >> k;
    vi v(200001,0);
    rep(i, n)
    {
        int a;
        cin >> a;
        v[a]++;
    }
    sort(v.rbegin(), v.rend());
    rep(i,k){
        v[i] = 0;
    }
    lint ans = 0;
    sort(v.rbegin(), v.rend());
    int i=0;
    while (v[i] != 0)
    {
        ans += v[i];
        i++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <cmath>
#include <deque>
#include <iostream>
#include <map>
#include <set>
#include <tuple>
#include <vector>
using namespace std;
typedef long long ll;

bool chmax(ll &a, ll b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> happiness(N, vector<ll>(3));
  ll a, b, c;
  for (int i = 0; i < N; i++) {
    cin >> a >> b >> c;
    happiness[i][0] = a;
    happiness[i][1] = b;
    happiness[i][2] = c;
  }
  ll dp[N][3];
  const ll INF = 1LL << 60;
  for (int i = 0; i < N; i++) {
    dp[i][0] = -INF;
    dp[i][1] = -INF;
    dp[i][2] = -INF;
  }
  dp[0][0] = happiness[0][0];
  dp[0][1] = happiness[0][1];
  dp[0][2] = happiness[0][2];
  vector<pair<int, int>> ref_index = {{1, 2}, {0, 2}, {0, 1}};
  for (int i = 1; i < N; i++) {
    for (int j = 0; j < 3; j++) {
      dp[i][j] = max(dp[i - 1][ref_index[j].first] + happiness[i][j],
                     dp[i - 1][ref_index[j].second] + happiness[i][j]);
    }
  }
  ll ans = max(dp[N - 1][0], dp[N - 1][1]);
  ans = max(ans, dp[N - 1][2]);
  cout << ans << endl;
  return 0;
}

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

using namespace std;
using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline void dump(vector<T> v) { for (auto& x : v) cerr << x << " "; cerr << endl; }
template<class T> inline void dump(vector<pair<T, T>> v) { for (auto& p : v) cerr << p.first << " " << p.second << endl; }
template<class T> inline void dump(vector<vector<T>> vv) { for (auto& v : vv) {for (auto& x : v) cerr << x << " "; cerr << endl;} }

constexpr int INF = 1e9 + 5;
constexpr long long INFLL = 1LL << 62;
constexpr double eps = (1e-9);

ll solve(const int& n, const int& l, const int& r, const vector<ll>& a, vector<vector<ll>>& dp) {
  if (dp[l][r] != -1) return dp[l][r];
  if (l == r) {
    dp[l][r] = a[l];
  } else {
    dp[l][r] = max(a[l] - solve(n, l + 1, r, a, dp), a[r] - solve(n, l, r - 1, a, dp));
  }
  return dp[l][r];
}

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

  int n;
  cin >> n;

  vector<ll> a(n);
  rep(i, n) cin >> a[i];

  vector<vector<ll>> dp(n+1, vector<ll>(n+1, -1));

  ll ans = solve(n, 0, n-1, a, dp);

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 73920
#include <stdio.h>

int main(void){

  int i,j,k,l,much,num;

  while(  scanf("%d",&num) != -1 ){

    much=0;
    
    for(i=0;i<10;i++){
      for(j=0;j<10;j++){
	for(k=0;k<10;k++){
	  for(l=0;l<10;l++){
	    if(i+j+k+l==num){much+=1;}
	  }
	}
      }
    }
    
    printf("%d\n",much);
    
  }
  return 0;
}

Measured memory_bytes: 596