akhauriyash/Code-Regression huggingface dataset:
//https://vjudge.net/contest/313071#problem/B

#include<bits/stdc++.h>
const int N = 305;
const int mod = 1e9 + 7;
using namespace std;

int n, dp[N][N*2][N], f[N*2], g[N*2], a[N], ans;

void add(int&a, int b){
    a += b; if (a >= mod) a -= mod; if (a < 0) a += mod;
}

int C(int k, int n){
    if (k < 0 || k > n) return 0;
    return 1LL * f[n] * g[k] % mod * g[n-k] % mod;
}

int main(){
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    f[0] = 1; for (int i = 1; i < N*2; i++) f[i] = 1LL * f[i-1] * i % mod;
    g[0] = g[1] = 1; for (int i = 2; i < N*2; i++) g[i] = 1LL * (mod-1) * (mod / i) % mod * g[mod % i] % mod;
    for (int i = 1; i < N*2; i++) g[i] = 1LL * g[i-1] * g[i] % mod;

    cin >> n;
    for (int i = 1; i <= n; i++) cin >> a[i];
    if (n == 3) return cout << 1, 0;
    dp[0][0][0] = 1;
    for (int i = 1; i <= n; i++) for (int k = 0; k <= 2*n; k++) for (int h = 0; h <= n; h++){
        add(dp[i][k][h], 1LL * dp[i-1][k][h] * g[a[i]-1] % mod);
        if (a[i] >= 2) add(dp[i][k+a[i]-2][h+1], 1LL * dp[i-1][k][h] * C(a[i]-2, k+a[i]-2) % mod);
    }
    for (int k = 0; k <= 2*n; k++) for (int h = 3; h <= n; h++){
        if (k != 0 && h != n) add(ans, 1LL * dp[n][k][h] * f[h-1] % mod * (mod+1) / 2 % mod * g[k-1] % mod * f[n-h-1] % mod);
        if (k == 0 && h == n) add(ans, 1LL * dp[n][k][h] * f[h-1] % mod * (mod+1) / 2 % mod);
    }
    cout << ans;
}


Measured memory_bytes: 218624
#!/usr/bin/env python3
#ABC133 B

import sys
input = sys.stdin.readline
sys.setrecursionlimit(1000000)
def LI(): return list(map(int,sys.stdin.readline().split()))
def LIR(n): return [LI() for _ in range(n)]

n,d = LI()
x = LIR(n)
ans = 0
for i in range(1,n):
    for j in range(i):
        sum = 0
        for k in range(d):
            sum +=(x[i][k] - x[j][k])**2
        if sum**(1/2) % 1 == 0:
            ans += 1
print(ans)


Measured memory_bytes: 38384
#include <iostream>
#include <cmath>
#include <algorithm>
using namespace std;
int main(void){
  long N,M;
  cin >> N >> M;

  if(abs(N - M) > 1)
    cout << 0 << endl;
  else{
    long n = 1;
    long m = 1;
    for(int i=1;i<=N;i++){
      n *= i;
      n %= 1000000007;
    }
    for(int i=1;i<=M;i++){
      m *= i;
      m %= 1000000007;
    }

    if(n == m)
      cout << n * m * 2 % 1000000007 << endl;
    else
      cout << n * m % 1000000007 << endl;
    }

    return 0;
  }

    
    

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

/**
 *
 * @author k15115kk
 */
public class Main {

    
    /**
     * @param args the command line arguments
     * @throws java.io.IOException
     */
    public static void main(String[] args) throws IOException {
        // TODO code application logic here
        InputStreamReader is = new InputStreamReader(System.in);       
        BufferedReader br = new BufferedReader(is);
        String s=br.readLine();
       StringTokenizer st=new StringTokenizer(s," ");
         
        int a=Integer.parseInt(st.nextToken());
        int b=Integer.parseInt(st.nextToken());
        
       if(-1000 <= a && 1000 >= b){
           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: 24184
#include <bits/stdc++.h>

using namespace std;
using ll = long long;
#define int ll
using PII = pair<int, int>;
template <typename T> using V = vector<T>;
template <typename T> using VV = vector<V<T>>;
template <typename T> using VVV = vector<VV<T>>;

#define FOR(i, a, n) for (ll i = (ll)a; i < (ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define PB push_back

const ll INF = (1LL<<60);
const int MOD = 1000000007;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template <typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }
template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a){
  out<<'('<<a.first<<','<<a.second<<')';
  return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
  out<<'[';
  REP(i, a.size()) {out<<a[i];if(i!=a.size()-1)out<<',';}
  out<<']';
  return out;
}

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

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

  int n;
  cin >> n;
  V<int> a(n);
  V<char> op(n);
  op[0] = '+'; cin >> a[0];
  FOR(i, 1, n) cin >> op[i] >> a[i];

  V<int> b(n); b[0] = a[0];
  FOR(i, 1, n) b[i] = b[i-1] + a[i];

  V<int> v;
  REP(i, n) if(op[i] == '-') v.PB(i);
  v.PB(n);
  V<int> nxt(n);
  REP(i, (int)v.size()-1) nxt[v[i]] = v[i+1];

  int ret = -INF, now = 0;
  REP(i, n) {
    if(op[i]=='+') {
      now += a[i];
    } else {
      chmax(ret, now - (b[nxt[i]-1]-b[i-1]) + (b[n-1]-b[nxt[i]-1]));
      now -= a[i];
    }
  }
  chmax(ret, now);

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
using namespace std;
#define loop(i,N) for(ll (i)=0; (i)<(N);++(i))
struct _OMAZINAI_ { _OMAZINAI_() { std::ios::sync_with_stdio(false); std::cin.tie(0); } } __omazinai_instance__;
#define INF (1LL<<61 + 1<<29)
#define YesNo(x) {std::cout << ((x)?"Yes":"No") << std::endl;}
#define YESNO(x) {std::cout << ((x)?"YES":"NO") << std::endl;}
#define OddEven(x) {std::cout << ((x)%2?"Odd":"Even") << std::endl;}
#define ODDEVEN(x) {std::cout << ((x)%2?"ODD":"EVEN") << std::endl;}
typedef long long int ll;
void _INPUT_IMPL_() {};
template <class T, class... Args> void _INPUT_IMPL_(T& dest, Args&... args) { cin >> dest; _INPUT_IMPL_(args...); }
void _OUTPUT_IMPL_() {};
template <class T, class... Args> void _OUTPUT_IMPL_(T dest, Args... args) { cout<< dest << (sizeof...(Args)?" ":""); _OUTPUT_IMPL_(args...); }
#define in(type, ...) type __VA_ARGS__; _INPUT_IMPL_(__VA_ARGS__)
#define in_v(type, name, cnt) vector<type> name(cnt); loop(i, cnt) cin >> name[i];
#define out(...) _OUTPUT_IMPL_(__VA_ARGS__)

int main() {
	string s;
	cin >> s;
	YesNo(s[0] == '9' || s[1] == '9');
}

Measured memory_bytes: 256
function main(s) {
	var s = s.split("\n")[0];
	var x = Number(s);
	var y = 0;
	for (var i = 0; i < s.length; i++) {
		y += Number(s[i]);
	}
	console.log(x%y===0?"Yes":"No");
}
main(require("fs").readFileSync("/dev/stdin", "utf8"));



Measured memory_bytes: 7496
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<ll> VI;
typedef vector<VI> VVI;
const ll MOD = 1000000007;
const ll INF = 4611686018427387903;
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

vector<vector<P>> edge(114514, vector<P>(0));

int main(){
	int n, m; cin >> n >> m;
	int l, r, d;
	REP(i,m){
		cin >> l >> r >> d;
		l--; r--;
		edge[l].push_back({r,d});
		edge[r].push_back({l,-d});
	}
	bool no=0;
	VI ds(n,INF);
	REP(i,n){
		if(ds[i]==INF){
			ds[i]=0;
			queue<int> q; q.push(i);
			while(!q.empty()){
				int v=q.front(); q.pop();
				for(auto u:edge[v]){
					if(ds[u.first]==INF){
						ds[u.first]=ds[v]+u.second;
						q.push(u.first);
					}
					else{
						if(ds[u.first]!=ds[v]+u.second){
							no=1;
							break;
						}
					}
				}
			}
		}
		if(no)
			break;
	}
	if(no)
		cout << "No" << endl;
	else
		cout << "Yes" << endl;
	return 0;
}

Measured memory_bytes: 14208
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>
#include <utility>
#include <queue>
#include <cmath>

using namespace std;

typedef long long ll;

int main(){
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  int N; cin >> N;
  int t[N+1], x[N+1], y[N+1];
  t[0] = 0, x[0] = 0, y[0] = 0;
  for(int i=1;i<=N;i++)
    cin >> t[i] >> x[i] >> y[i];
  for(int i=1;i<=N;i++){
    int dt = t[i] - t[i-1];
    int dx = abs(x[i] - x[i-1]);
    int dy = abs(y[i] - y[i-1]);
    if(dx > dt || dy > dt){
      cout << "No" << endl;
      return 0;
    }
    if((x[i] + y[i]) %2 != t[i] %2){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 1408
#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <array>
#include <unordered_set>
#include <unordered_map>
#include <map>
#include <math.h>
#include <queue>
#include <stdio.h>
using namespace std;
using i64 = int64_t;
#define rep(i, n) for(int i=0;i<n;++i)
#define rep2(i, x, n) for(int i=x;i<n;++i)
#define INF 1<<29;

int main()
{
    string s;
    i64 k;
    cin >> s >> k;

    int n = s.size();
    i64 pos = 0;
    int ret = 1;
    rep(i,n)
    {
        if(s.substr(i,1) != "1")
        {
            ret = stoi(s.substr(i,1));
            break;
        }

        pos++;
        if(pos >= k) break;
    }

    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }eni(!=) cerr  << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
} sim dor(rge<c> d) { *this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it; ris << "]";}
#else
sim dor(const c&) { ris; }
#endif
};
#define err(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

using ll=long long;
using vi=vector<int>;



int main() {
    ios::sync_with_stdio(false) , cin.tie(0);
    int n;
    cin >> n ;
    vi a(n) , b(n) , c(n);
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i] >> c[i];
    }
    vector < vi > dp(n + 1, vi(3));
    dp[0][0] = a[0];
    dp[0][1] = b[0];
    dp[0][2] = c[0];
    for(int i = 1; i < n; i++){
        dp[i][0] =  a[i] +  max( dp[i - 1][1]  , dp[i - 1][2]  );
        dp[i][1] = b[i] + max( dp[i - 1][0] , dp[i - 1][2] );
        dp[i][2] = c[i] + max( dp[i- 1][0] , dp[i - 1][1] );
    }
    cout << max( { dp[n - 1][0] , dp[n - 1][1] , dp[n - 1][2] } ) << '\n';





    return 0;
}



Measured memory_bytes: 6912
N, W = map(int, input().split())
vs = [[] for _ in range(4)]
w1, v1 = map(int, input().split())
vs[0].append(v1)
for i in range(N - 1):
    w, v = map(int, input().split())
    vs[w - w1].append(v)
#print(vs)
s = [[0] for _ in range(4)]
for i in range(4):
    vs[i].sort()
    for j in range(len(vs[i])):
        s[i].append(s[i][-1] + vs[i][-j-1])
#print(vs)
ans = 0
for i in range(N + 1):
    if i > len(vs[0]):
        break
    if i * w1 > W:
        break
    si = s[0][i]
    for j in range(N + 1 - i):
        if j > len(vs[1]):
            break
        if i * w1 + j * (w1 + 1) > W:
            break
        sj = si
        sj += s[1][j]
        for k in range(N + 1 - i - j):
            if k > len(vs[2]):
                break
            if i * w1 + j * (w1 + 1) + k * (w1 + 2) > W:
                break
            sk = sj
            sk += s[2][k]
            for l in range(N + 1 - i - j - k):
                if l > len(vs[3]):
                    break
                if i * w1 + j * (w1 + 1) + k * (w1 + 2) + l * (w1 + 3) > W:
                    break
                sl = sk
                sl += s[3][l]
                ans = max(ans, sl)
print(ans)

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

using namespace std;

int main(void) {

	int a, b, c, d;
	cin >> a >> b >> c >> d;

	string result = "No";
	int ca  = abs(c - a);
	if (ca <= d) {
		result = "Yes";
	} else {
		int ab = abs(b - a);
		int cb = abs(c - b);
		if (ab <= d && cb <= d) {
			result = "Yes";
		}
	}

	cout << result << endl;

	return 0;
}



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

using namespace std;

long double average;
vector<int> a;
vector<pair<int, int>> points;
int n, num_of_perm, dist[8][8];

int main() {
	cin >> n;
	points.resize(n);
	for(pair<int,int>& p: points) 
		cin >> p.first >> p.second;

	for(int i = 0; i < n; i++) {
		for(int j = i + 1; j < n; j++) {
			int ans = (points[i].first - points[j].first) * (points[i].first - points[j].first);
			ans += (points[i].second - points[j].second) * (points[i].second - points[j].second);
			dist[i][j] = dist[j][i] = ans;
		}
	}
	
	a.resize(n);
	iota(a.begin(), a.end(), 0);
	
	do {
		for(int i = 1; i < n; i++)
			average += sqrt(dist[a[i]][a[i-1]]);
	
		num_of_perm++;
	} while(next_permutation(a.begin(), a.end()));
	
	cout << fixed << setprecision(10) << average / num_of_perm << endl;
	
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
using ll=long long;
using vi=vector<int>;
using pii=pair<int,int>;
#define ALL(c) begin(c),end(c)
#define RALL(c) rbegin(c),rend(c)
#define ITR(i,b,e) for(auto i=(b);i!=(e);++i)
#define FORE(x,c) for(auto &x:c)
#define REPF(i,a,n) for(int i=a,i##len=(int)(n);i<i##len;++i)
#define REP(i,n) REPF(i,0,n)
#define REPR(i,n) for(int i=(int)(n);i>=0;--i)
#define SZ(c) ((int)c.size())
#define CONTAIN(c,x) (c.find(x)!=end(c))
#define OUTOFRANGE(y,x,h,w) (y<0||x<0||y>=h||x>=w)
#define dump(...)
const int DX[9]={0,1,0,-1,1,1,-1,-1,0},DY[9]={-1,0,1,0,-1,1,1,-1,0};
#define INF (1001001001)
#define INFLL (1001001001001001001ll)
template<class T> ostream& operator << (ostream &os,const vector<T> &v) {
    ITR(i,begin(v),end(v)) os<<*i<<(i==end(v)-1?"":" "); return os; }
template<class T> istream& operator >> (istream &is,vector<T> &v) {
    ITR(i,begin(v),end(v)) is>>*i; return is; }
template<class T> istream& operator >> (istream &is, pair<T,T> &p) {
    is>>p.first>>p.second; return is; }
template <class T> bool chmax(T &a,const T &b) {if(a<b) {a=b;return 1;} return 0;}
template <class T> bool chmin(T &a,const T &b) {if(b<a) {a=b;return 1;} return 0;}
template <class T> using heap = priority_queue<T,vector<T>,greater<T>>;
struct before_main_function {
    before_main_function() {
        #ifdef int
            #undef INF
            #define INF INFLL
            #define stoi stoll
        #endif
        cin.tie(0);ios::sync_with_stdio(false);
        cout<<setprecision(15)<<fixed;
        #define endl "\n"
    }
} before_main_function;
//------------------8<------------------------------------8<--------------------

signed main() {
    int n,a,b;
    cin>>n>>a>>b;
    int ans=0;
    REPF(i,1,n+1) {
        string s=to_string(i);
        int t=0;
        FORE(x,s) {
            t+=x-'0';
        }
        if(a<=t && t<=b) {
            ans+=i;
        }
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
var
	n,i,a,s:Longint;
	t:array[0..31]of Longint=(31,0,27,1,28,13,23,2,29,21,19,14,24,16,3,7,30,26,12,22,20,18,15,6,25,11,17,5,10,4,9,8);
begin
	read(n);
	for i:=1 to n do begin
		read(a);
		inc(s,t[((a and-a)*251226722 shr 27)and 31]);
	end;
	writeln(s);
end.

Measured memory_bytes: 128
#include <iostream>

using namespace std;

typedef long long ll;

struct object{
  ll weight, value;
};

ll const nmax = 100;
ll const capMax = 1e5;
object v[1 + nmax];
ll maxValue[1 + nmax][1 + capMax];

int main() {

  ll n, cap;
  cin >> n >> cap;
  for(ll i = 1;i <= n;i++){
    cin >> v[i].weight >> v[i].value;
  }
  for(ll i = 1;i <= n;i++){
    for(ll j = 1;j <= cap;j++){
      if(v[i].weight <= j){
        //cerr << maxValue[i-1][j-v[i].weight] + v[i].value << ' ' << i << ' '<< j << '\n';
        maxValue[i][j] = max(maxValue[i-1][j-v[i].weight] + v[i].value, max(maxValue[(i-1)][j], maxValue[i][j-1]));
      }else{
        maxValue[i][j] = maxValue[i-1][j];
      }
    }
  }
  cout << maxValue[n][cap];
  return 0;
}


Measured memory_bytes: 78336
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define pb push_back
template<class T>void chmax(T &a,T b){if(a<b)a=b;}
template<class T>void chmin(T &a,T b){if(a>b)a=b;}
constexpr int INF=1000000000000000000;
constexpr int mod=1000000007;
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[2000010];
int gcd(int a,int b){
    if(b==0)return a;
    return gcd(b,a%b);
}
int lcm(int a,int b){
    return a/gcd(a,b)*b;
}
bool prime(int a){
    if(a==1)return false;
    for(int i=2;i*i<=a;i++){
        if(a%i==0)return false;
    }
    return true;
}
void init_fact(){
    kaijo[0]=1;
    for(int i=1;i<=2000000;i++){
        kaijo[i]=kaijo[i-1]*i;
        kaijo[i]%=mod;
    }
}
int modpow(int a,int b){
    if(b==0)return 1;
    if(b%2)return modpow(a,b-1)*a%mod;
    int memo=modpow(a,b/2);
    return memo*memo%mod;
}
int comb(int a,int b){
    if(!kaijo[0])init_fact();
    return kaijo[a]*modpow(kaijo[a-b],mod-2)%mod*modpow(kaijo[b],mod-2)%mod;
}
int inv(int x){
    x=modpow(x,mod-2);
    return x;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){
    double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
    double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
    double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
    double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
    return tc*td<0&&ta*tb<0;
}
int n;
double p[3010];
double dp[3010][3010];
signed main(){
    cin>>n;
    rep(i,n)cin>>p[i];
    dp[0][0]=1.0;
    rep(i,n){
        rep(j,n){
            if(i+j<n){
                dp[i+1][j]+=dp[i][j]*p[i+j];
                dp[i][j+1]+=dp[i][j]*(1.0-p[i+j]);
            }
        }
    }
    double sum=0.0;
    rep(i,n+1){
        if(i>n-i)sum+=dp[i][n-i];
    }
    printf("%.12lf\n",sum);
    return 0;
}

Measured memory_bytes: 71936
#include<iostream>
#include<cstdio>
#include<algorithm>
using namespace std;
int n;

struct node
{
    int key;
    node *parent,*left,*right;
    node():key(-1),parent(NULL),left(NULL),right(NULL) {}
};
node *root,*nil;

node* newnode()
{
    return new node();
}

void insert(int num)
{
    node* x=root;
    node* y=nil;
    node* z=newnode();
    z->key=num;
    while(x!=nil)
    {
        y=x;
        if(num>=x->key)
            x=x->right;
        else
            x=x->left;
    }
    if(y==nil) root=z;
    else
    {
    	z->parent=y;
    	if(num<y->key)
    	  y->left=z;
    	else
    	  y->right=z;
	}
}

bool find(node* u,int num)
{
	if(u->key==num) return true;
	else if(u->key<num&&u->right!=nil) return find(u->right,num);
	else if(u->key>num&&u->left!=nil) return find(u->left,num); 
	return false;
}

void inorder(node* u)
{
	if(u->left!=nil) inorder(u->left);
	printf(" %d",u->key);
	if(u->right!=nil) inorder(u->right);
	return; 
}

void preorder(node* u)
{
	printf(" %d",u->key);
	if(u->left!=nil) preorder(u->left);
	if(u->right!=nil) preorder(u->right);
	return;
}

int main()
{
    scanf("%d",&n);
    for(int i=1; i<=n; ++i)
    {
        char s[11];
        scanf("%s",s);
        if(s[0]=='i')
        {
            int x;
            scanf("%d",&x);
            insert(x);
        }
        else if(s[0]=='f')
        {
            int x;
            scanf("%d",&x);
            if(find(root,x))
              printf("yes\n");
            else
              printf("no\n");
        }
        else if(s[0]=='p')
        {
            inorder(root);
            printf("\n");
            preorder(root);
            printf("\n");
        }
    }
    return 0;
}

Measured memory_bytes: 21836
{-# LANGUAGE OverloadedStrings #-}
module Main where

import           Data.List
import           Control.Monad
import           Debug.Trace
import qualified Data.ByteString.Char8         as BC
import           Data.Maybe                     ( fromJust )
import qualified Data.Set                      as S
import qualified Data.IntMap.Strict            as IM
import qualified Data.Map.Strict               as M
import           Data.Char


readTuple2 :: IO (Int, Int)
readTuple2 = do
    [a, b] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b)

readTuple3 :: IO (Int, Int, Int)
readTuple3 = do
    [a, b, c] <- map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine
    return (a, b, c)

readInt :: IO Int
readInt = fst . fromJust . BC.readInt <$> BC.getLine

readInts :: IO [Int]
readInts = map (fst . fromJust . BC.readInt) . BC.words <$> BC.getLine

split :: (a -> Bool) -> [a] -> [[a]]
split f [] = []
split f as =
    let (fo, la) = span f as
        las      = case la of
            [] -> []
            xs -> split f $ tail xs
    in  case fo of
            [] -> las
            xs -> xs : las

main = do
    s <- getLine
    if any (== '7') s then putStrLn "Yes" else putStrLn "No"





Measured memory_bytes: 3792
N = int(input())
for i in range(N):
  a,t = map(int,input().split())
  if i == 0:
    x,y = a,t
  else:
    xa = x//a if x%a==0 else x//a+1
    yt = y//t if y%t==0 else y//t+1
    c = max(xa,yt)
    x,y = a*c,t*c
print(x+y)


Measured memory_bytes: 3060
#include <iostream>
#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 <numeric>
using namespace std;
typedef long long int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

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


int main() {
  ll N, M;
  cin >> N >> M;
  vector<ll> s(M), e(M);
  map<ll, set<ll>> G, G1;
  REP(i, M) {
    cin >> s[i] >> e[i];
    G[s[i]].insert(e[i]);
    G1[s[i] * 3].insert(e[i] * 3 + 1);
    G1[s[i] * 3 + 1].insert(e[i] * 3 + 2);
    G1[s[i] * 3 + 2].insert(e[i] * 3);
  }
  ll S, T;
  cin >> S >> T;

  std::vector<ll> val(3 * N + 4, 4 * N);
  queue<ll> que;
  que.push(S * 3);
  ll tmp = S * 3;
  val[tmp] = 0;
  while(!que.empty()){
    tmp = que.front();
    que.pop();
    for(auto x : G1[tmp]){
      if (val[tmp] + 1 < val[x]){
        que.push(x);
        val[x] = val[tmp] + 1;
      }
    }

  }

  if (val[T * 3] == 4 * N) val[T * 3] = -3;
  cout << (val[T * 3] / 3) << endl;

  return 0;
}


Measured memory_bytes: 60416
#include <stdio.h>

int main(void) 
{
  int i, j, temp, height[10];

  for (i = 0; i < 10; i++) 
    scanf("%d", &height[i]);

  for (i = 0; i < 10; i++) {
    for (j = 0; j < 9 - i; j++) {
      if (height[j] < height[j + 1]) {
	temp          = height[j];
	height[j]     = height[j + 1];
	height[j + 1] = temp;
      }
    }
  }

  for (i = 0; i < 3; i++) 
    printf("%d\n", height[i]);

  return 0;
}

Measured memory_bytes: 600
#define DEBUG 0

#include <bits/stdc++.h>
using namespace std;

#if DEBUG
// basic debugging macros
int __i__,__j__;
#define printLine(l) for(__i__=0;__i__<l;__i__++){cout<<"-";}cout<<endl
#define printLine2(l,c) for(__i__=0;__i__<l;__i__++){cout<<c;}cout<<endl
#define printVar(n) cout<<#n<<": "<<n<<endl
#define printArr(a,l) cout<<#a<<": ";for(__i__=0;__i__<l;__i__++){cout<<a[__i__]<<" ";}cout<<endl
#define print2dArr(a,r,c) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<a[__i__][__j__]<<" ";}cout<<endl;}
#define print2dArr2(a,r,c,l) cout<<#a<<":\n";for(__i__=0;__i__<r;__i__++){for(__j__=0;__j__<c;__j__++){cout<<setw(l)<<setfill(' ')<<a[__i__][__j__]<<" ";}cout<<endl;}

// advanced debugging class
// debug 1,2,'A',"test";
class _Debug {
    public:
        template<typename T>
        _Debug& operator,(T val) {
            cout << val << endl;
            return *this;
        }
};
#define debug _Debug(),
#else
#define printLine(l)
#define printLine2(l,c)
#define printVar(n)
#define printArr(a,l)
#define print2dArr(a,r,c)
#define print2dArr2(a,r,c,l)
#define debug
#endif

// define
#define MAX_VAL 999999999
#define MAX_VAL_2 999999999999999999LL
#define EPS 1e-6
#define mp make_pair
#define pb push_back

// typedef
typedef unsigned int UI;
typedef long long int LLI;
typedef unsigned long long int ULLI;
typedef unsigned short int US;
typedef pair<int,int> pii;
typedef pair<LLI,LLI> plli;
typedef vector<int> vi;
typedef vector<LLI> vlli;
typedef vector<pii> vpii;
typedef vector<plli> vplli;

// ---------- END OF TEMPLATE ----------

int balls[100000],red[100000];
int main() {
    int i;
    int N,M;
    int x,y;
    scanf("%d %d",&N,&M);
    fill(balls,balls+N,1),red[0] = 1;
    for (i = 0; i < M; i++) {
        scanf("%d %d",&x,&y);
        x--,y--;
        balls[x]--,balls[y]++;
        if (red[x]) red[y] = 1;
        if (balls[x] == 0) red[x] = 0;
    }
    int c = 0;
    for (i = 0; i < N; i++) {
        if (red[i]) c++;
    }
    printf("%d\n",c);

    return 0;
}



Measured memory_bytes: 1024
#include<iostream>
#include<cstring>
using namespace std;

int card[4][13] = {};

int main()
{
	int n;
	char mark;
	int number;
	cin >> n;
	for (int i = 0; i < n; i++)
	{
		cin >> mark >> number;
		switch (mark)
		{
			case 'S':
				card[0][number-1] = 1;
				break;
			case 'H':
				card[1][number-1] = 1;
				break;
			case 'C':
				card[2][number-1] = 1;
				break;
			case 'D':
				card[3][number-1] = 1;
				break;
		}

	}
	//
	for (int i = 0; i < 13; i++)
	{
		if (card[0][i] != 1)
		{
			cout << "S " << i+1 << endl;
		}
	}
	for (int i = 0; i < 13; i++)
	{
		if (card[1][i] != 1)
		{
			cout << "H " << i+1 << endl;
		}
	}
	for (int i = 0; i < 13; i++)
	{
		if (card[2][i] != 1)
		{
			cout << "C " << i+1 << endl;
		}
	}
	for (int i = 0; i < 13; i++)
	{
		if (card[3][i] != 1)
		{
			cout << "D " << i+1 << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<pair<int,int>> vp;
#define pb push_back
#define ll long long int 

void solve()
{
string s;
ll sum=0;
cin>>s;
for(int i=0;i<s.size();i++)
{
	sum+=s[i]-'0';
}
	if(sum%9==0)
	cout<<"Yes";
	else
	cout<<"No";
}
int main()
{ 
    

   solve();
    
	return 0;
}



Measured memory_bytes: 3728
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <queue>
#include <functional>
#include <cmath>
#include <iomanip>
using namespace std;

int DP[100][100];

int main() {
	long long X, Y; cin >> X >> Y;

	/*
	for (int i = 0; i < 100; i++)for (int j = 0; j < 100; j++)DP[i][j] = -1;

	vector<int>pos(100);
	while (1) {
		for (int j = 0; j < 100; j++) {
			for (int i = pos[j]; i < 100; i++) {
				int flag = 0;
				for (int k = 1; flag != -1 && k <= i / 2; k++) {
					if (DP[i - 2 * k][j + k] == -1)flag = -1;
					else if (!DP[i - 2 * k][j + k])flag = 1;
				}
				for (int k = 1; flag != -1 && k <= j / 2; k++) {
					if (DP[i + k][j - 2 * k] == -1)flag = -1;
					else if (!DP[i + k][j - 2 * k])flag = 1;
				}

				if (flag == -1) break;
				else DP[i][j] = DP[j][i] = flag;
				pos[j] = i + 1;
			}
		}
		if (pos[99] == 100)break;
	}

	for (int i = 0; i < 100; i++) {
		for (int j = 0; j <= i; j++) {
			cout << i << " " << j << " " << DP[i][j] << endl;
		}
	}
	*/

	if (abs(X - Y) <= 1)cout << "Brown" << endl;
	else cout << "Alice" << endl;

	return 0;
}

Measured memory_bytes: 256
/// Kazuki Hoshino


#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define int long long
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
#define inf 1000000000
#define mod 1000000007
#define rep(i,a,b) for (int i = a; i <= b; i++)
#define rep1(i, a, b) for(int i =a; i >=b; i--)
#define dmp(x) cerr<<"line "<<__LINE__<<" "<<#x<<":"<<x<<endl
#define fs first
#define sc second
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define mt make_tuple
//#define endl '\n'
typedef tree<
int,
null_type,less<int>,
rb_tree_tag,tree_order_statistics_node_update>
ordered_set;
int n,k,vis[2005],dist[2005],ans=1e9,cnt,smax;
vi adj[2005];
set<int> st;
void dfs(int s, int p){
	if(dist[s]>(k+1)/2)return ;
	if(k%2 && dist[s]==(k+1)/2){
		st.insert(s);
	}
	else
	cnt++;
	for(auto t:adj[s]){
		if(t!=p){
			dist[t]=dist[s]+1;
			dfs(t,s);
		}
	}
}
signed main(){
ios::sync_with_stdio(0);
cin.tie(0);
//freopen("input.txt", "r", stdin);
//freopen("output.txt", "w", stdout);
cin >> n >> k;
for(int i=1;i<n;i++){
	int x,y;
	cin >> x >> y;
	adj[x].pb(y);
	adj[y].pb(x);
}
for(int i=1;i<=n;i++){
	cnt = 1;
	smax = 0;		
	for(int j=1;j<=n;j++){
		dist[i]=1e18;
	}
	for(auto t:adj[i]){

		dist[t]=1;
		dfs(t,i);
		smax = max(smax, (int)st.size());
		st.clear();

	}
	ans = min(ans, n-cnt-smax );
}
cout << ans << endl;
return 0;}
///....


Measured memory_bytes: 384
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Scanner;

//Bicycle Diet
public class Main{

	class E{
		int s, t, c;
		public E(int s, int t, int c) {
			this.s = s;
			this.t = t;
			this.c = c;
		}
	}
	
	int m, n, k, d;
	
	int get(String s){
		if(s.charAt(0)=='H')return n+m;
		if(s.charAt(0)=='D')return n+m+1;
		int x = Integer.parseInt(s.substring(1))-1;
		return s.charAt(0)=='C'?x:x+m;
	}
	
	@SuppressWarnings("unchecked")
	void run(){
		Scanner sc = new Scanner(System.in);
		while(true){
			m = sc.nextInt();
			n = sc.nextInt();
			k = sc.nextInt();
			d = sc.nextInt();
			if((m|n|k|d)==0)break;
			int[] cake = new int[m];
			for(int i=0;i<m;i++)cake[i]=sc.nextInt();
			int N = m+n+2;
			List<E> l[] = new ArrayList[N];
			for(int i=0;i<N;i++)l[i]=new ArrayList<E>();
			while(d--!=0){
				int s = get(sc.next());
				int t = get(sc.next());
				int cost = sc.nextInt()*k;
				l[s].add(new E(s,t,cost));
				l[t].add(new E(t,s,cost));
			}
			int[][] dist = new int[N][1<<m];
			for(int[]a:dist)Arrays.fill(a, 1<<28);
			boolean[][] u = new boolean[N][1<<m];
			dist[n+m][0] = 0;
			u[n+m][0] = true;
			boolean update = true;
			while(update){
				update = false;
				boolean[][] next = new boolean[N][1<<m];
				for(int i=0;i<N;i++){
					for(int j=0;j<1<<m;j++){
						if(!u[i][j])continue;
						for(E e:l[i]){
							if(m<=e.t){
								int v = dist[i][j]+e.c;
								if(v<dist[e.t][j]){
									dist[e.t][j] = v;
									update = true;
									next[e.t][j] = true;
								}
							}
							else {
								if((j&(1<<e.t))>0)continue;
								int v = dist[i][j]+e.c-cake[e.t];
								if(v<dist[e.t][j+(1<<e.t)]){
									dist[e.t][j+(1<<e.t)] = v;
									update = true;
									next[e.t][j+(1<<e.t)] = true;
								}
							}
						}
					}
				}
				u = next;
			}
			int min = 1<<28;
			for(int j=0;j<1<<m;j++)min = Math.min(min, dist[n+m+1][j]);
			System.out.println(min);
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<set>
#include<unordered_map>
using namespace std;
typedef long long ll;
#define chmax(a,b) a=max(a,b)
#define chmin(a,b) a=min(a,b)
#define mod 1000000007
#define mad(a,b) a=(a+b)%mod
#define N 1000000

int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a[200010];
    cin>>n;
    vector<ll> val;
    for(int i=0;i<n;i++){
	cin>>a[i];
	val.push_back(a[i]);
    }
    sort(val.begin(),val.end(),greater<ll>());
    for(int i=0;i<n;i++){
	if(a[i]==val[0])cout<<val[1]<<endl;
	else cout<<val[0]<<endl;
    }
}




Measured memory_bytes: 4848
while True:
    num = int(input())

    if num == 0: 
        break
    
    list = []
    for i in range(num):
        list.append(int(input()))

    for i in range(1, num):
        list[i] = max(list[i - 1] + list[i], list[i])

    print(max(list))

Measured memory_bytes: 7576
#include<vector>
#include<iostream>
#include<algorithm>

using namespace std;
using ll = long long;

const int INF = 1e9;
const ll MOD = 1e9 + 7;

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define debug(x) cout << #x << ": " << x << endl;
#define popcnt __builtin_popcount


int main() {
	int N, C, K;
	cin >> N >> C >> K;
	vector<int> T(N);
	for (int i = 0; i < N; i++) cin >> T[i];
	sort(all(T));

	int i=0, bus = 0;
	while(i<N){
		int fp = T[i];
		i++;
		for (int j = 0; j < C-1; j++) {
			if (i >= N)break;
			if (T[i] > fp + K)break;
			i++;
		}
		bus++;
	}
	cout << bus << endl;

	return 0;
}

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

x = 0
max_x = 0

N = int(input())
S = list(str(input()))

for i in range(N):
    if S[i] == 'I':
        x += 1
        max_x = max(max_x, x)
    else:   # elseの処理は必ずいれること
        x -= 1
        max_x = max(max_x, x)

print(max_x)

Measured memory_bytes: 9104
N = int(input())
ans = []
for i in range(1,N+1):
  for j in range(i+1,N+1):
    ans.append(sorted([i,j]))

if N%2==1:
  for i in range(1, N//2+1):
    del ans[ans.index(sorted([i, N-i]))]
else:
  for i in range(1, N//2+1):
    del ans[ans.index(sorted([i, N-i+1]))]

print(len(ans))
[print(*a) for a in ans]

Measured memory_bytes: 43760
#include<bits/stdc++.h>
using namespace std;
const int N = 2e5+1;

int main()
{
	int n;
	cin >> n;
	double a[n], ans = 0;
	for(int i=0; i<n; i++) cin >> a[i];
	sort(a, a+n);
	ans = a[0];
	for(int i=1; i<n; i++) ans += a[i], ans /= 2;
	cout << fixed << setprecision(5) << ans << endl;
}
	


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <iomanip>
using namespace std;

typedef long long ll;

int main()
{
    int N;
    cin >> N;
    int cnt=0, num=1;
    vector<int> ans;
    bool none=false;
    while(cnt<N){
        bool flag=true;
        while(flag){
            flag=false;
            num+=10;
            for(int i=2; i*i<=num; i++){
                if(num%i==0){
                    flag=true;
                    break;
                }
            }
            if(num>55555){
                none=true;
                break;
            }
        }
        if(none) break;
        ans.push_back(num);
        cnt++;
    }
    for(auto v: ans){
        if(v==ans[N-1]) cout << v << endl;
        else cout << v << ' ';
    }


    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;;
#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 FORR(i, m, n) for(int i = m;i >= n;i--)
#define INF 1<<30
#define LINF 1LL<<62
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
const int MOD = 1000000007;
 
typedef long long ll;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
typedef pair<ll, P> PP;

vector<ll> e[100005];
ll u,v;
vector<ll> disu(100005), disv(100005);
void caldis(ll x, ll from, ll dis, bool isu){
  if(isu)disu[x] = dis;
  else disv[x] = dis;

  rep(i,e[x].size()){
    ll to = e[x][i];
    if(to==from)continue;
    caldis(to,x,dis+1,isu);
  }
}

bool can[100005];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n;cin >> n;
  cin >> u >> v;
  u--;v--;
  rep(i,n-1){
    ll a,b;cin >> a >> b;a--;b--;
    e[a].push_back(b);
    e[b].push_back(a);
  }
  caldis(u,-1,0,true);
  caldis(v,-1,0,false);
  ll ans = 0;
  rep(i,n){
    if(disu[i]<=disv[i]){
      ans = max(ans,max(disu[i],disv[i]));
    }
  }
  
  cout<<ans-1 << endl;
}

Measured memory_bytes: 13952
n, m = map(int, input().split())
p = list(map(int, input().split()))
xy = [list(map(int, input().split())) for _ in range(m)]

par = [i for i in range(n)]
rank = [0 for _ in range(n)]


def root(x):
    if x == par[x]:
        return x
    par[x] = root(par[x])  # 経路圧縮
    return par[x]


def is_same(x, y):
    return root(x) == root(y)


def unite(x, y):
    x = root(x)
    y = root(y)
    if x == y:
        return
    if rank[x] < rank[y]:
        par[x] = y
    else:
        par[y] = x
        if rank[x] == rank[y]:
            rank[x] += 1


for x, y in xy:
    unite(x - 1, y - 1)


count = 0
for i, p_i in enumerate(p):
    count += 1 if is_same(i, p_i - 1) else 0
print(count)


Measured memory_bytes: 36124
#include<iostream>
#include<string>
using namespace std;
int main(){
string s,t;
  cin>>s;
  cin>>t;
  int ans=0;
  for(int i=0;i<s.size();i++){
if(s[i]!=t[i]) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


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

#include <iostream>
//#include <algorithm>
// #include <iomanip>
#define ll long long
#define map unordered_map
#define set unordered_set

using namespace std;

const ll MOD = 1000000007;
const ll INF = (1LL << 62);

ll N;

ll dp[3005][3005];

// 0  0  0  0  0  0  0
// 0  0  0  0  0  0  0
// 0  0  0  0  0  0  0
// 0  0  0  0  0  0  0
// 0  0  0  0  0  0  0
// 0  0  0  0  0  0  0

// 0 -4  0  0  0  0  0
// 0  0 -2  0  0  0  0
// 0  0  0 -9  0  0  0
// 0  0  0  0 -7  0  0
// 0  0  0  0  0 -1  0
// 0  0  0  0  0  0 -5

// 0 -4  2  0  0  0  0
// 0  0 -2  7  0  0  0
// 0  0  0 -9  2  0  0
// 0  0  0  0 -7  6  0
// 0  0  0  0  0 -1  4
// 0  0  0  0  0  0 -5
// 0  0  0  0  0  0  0

// 0 -4  2 -7  0  0  0
// 0  0 -2  7  0  0  0
// 0  0  0 -9  2 -3  0
// 0  0  0  0 -7  6 -3
// 0  0  0  0  0 -1  4
// 0  0  0  0  0  0 -5

// 0 -4  2 -7  4  0  0
// 0  0 -2  7  0  1  0
// 0  0  0 -9  2 -3  6
// 0  0  0  0 -7  6 -3
// 0  0  0  0  0 -1  4
// 0  0  0  0  0  0 -5

// 0 -4  2 -7  4 -3  0
// 0  0 -2  7  0  1 -4
// 0  0  0 -9  2 -3  6
// 0  0  0  0 -7  6 -3
// 0  0  0  0  0 -1  4
// 0  0  0  0  0  0 -5

// 0 -4  2 -7  4 -3  2
// 0  0 -2  7  0  1 -4
// 0  0  0 -9  2 -3  6
// 0  0  0  0 -7  6 -3
// 0  0  0  0  0 -1  4
// 0  0  0  0  0  0 -5

void show_table() {
  for (ll i = 0; i <= N; i++) {
    for (ll j = 0; j <= N; j++) {
      cout << dp[i][j] << " ";
    }
    cout << "" << endl;
  }
  cout << "" << endl;
}

int main() {
  fill(dp[0], dp[3005], 0);
  // std::cout << std::fixed << std::setprecision(10);
  scanf("%lld", &N);

  vector<ll> list(N);
  for (ll i = 0; i < N; i++) {
    ll v;
    scanf("%lld", &v);
    list[i] = v;
  }

  for (ll i = 0; i < N; i++) {
    dp[i][i] = 0;
  }

  for (ll rest = 0; rest < N; rest++) {
    // show_table();
    for (ll i = 0; i < (N - rest); ++i) {
      ll j = i + (rest + 1);
      bool first_turn = (N - rest) % 2 == 1;  // 注意
      if (first_turn) {
        ll val1 = dp[i + 1][j] + list[i];      // 左をとる
        ll val2 = dp[i][j - 1] + list[j - 1];  // 右をとる
        dp[i][j] = max(val1, val2);
      } else {
        ll val1 = dp[i + 1][j] - list[i];      // 左をとる
        ll val2 = dp[i][j - 1] - list[j - 1];  // 右をとる
        dp[i][j] = min(val1, val2);
      }
    }
  }

  // show_table();

  cout << dp[0][N] << endl;
}


Measured memory_bytes: 70784
#include<bits/stdc++.h>				//Written by ThiDaiLoc
using namespace std;				//Team Three Wolves
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<ll,pll> trp;
typedef vector<ll> vi;
typedef vector<pll> vp;

#define fu(i,a,b)   for(ll i=a;i<=b;i++)
#define f1(i,n)     for(ll i=1;i<=n;i++)
#define fs(i,s)     for(ll i=0;i+1<=s.length();i++)
#define fd(i,b,a)   for(ll i=b;i>=a;i--)
#define fuv(i,a)    for(ll i=0;i<a.size();i++)
#define fdv(i,a)    for(ll i=(ll)a.size()-1;i>=0;i--)
#define ms(a,x)     memset(a, x, sizeof a)
#define prec(n)     fixed<<setprecision(n)
#define uni(a)      (a).erase(unique(all(a)), (a).end())
#define pb(i)       push_back(i)
#define pob         pop_back()
#define sc(a)       cin>>a
#define sc2(a,b)    cin>>a>>b
#define sc3(a,b,c)  cin>>a>>b>>c
#define pr(a)       cout<<a<<endl
#define pr2(a,b)    cout<<a<<" "<<b<<endl
#define rpr(a)      return cout<<a<<endl,0
#define prY         cout<<"Yes"<<endl
#define prN         cout<<"No"<<endl
#define bit(n,i)    (((n)>>(i))&1)
#define lowb(a,n,x) lower_bound(a,a+n,x) -a
#define lowb2(a,x)  lower_bound(all(a),x) -a.begin()
#define all(x)      (x).begin(), (x).end()
#define sz(a)       (ll)a.size()
#define le(s)       (ll)s.length()		
#define re          return 	
#define	mp(a,b)     make_pair(a,b)
#define	mp3(a,b,c)  make_pair(a,make_pair(b,c))
#define se          second
#define fi          first 
#define sse         second.second
#define sfi         second.first
#define soA         sort(A+1,A+1+n)
#define so(A,n)     sort(A+1,A+1+n)
#define sov(v)      sort(all(v))
#define sovr(v)     sort(all(v),greater<ll>())
#define debug(x)    cerr << #x << " = " << x << endl
#define INPUT       freopen("locin.txt", "r", stdin)
#define OUTPUT      freopen("locout.txt", "w", stdout)
inline ll isqrt(ll k) {ll r = sqrt(k) + 1; while (r * r > k) r--; return r;}
inline ll icbrt(ll k) {ll r = cbrt(k) + 1; while (r * r * r > k) r--; return r;}
inline ll mnz(ll& a,ll b){return a=(a>b?b:a);}
inline ll mxz(ll& a,ll b){return a=(a<b?b:a);}
inline string toString(ll n) {stringstream ss; ss << n;return ss.str();}
double const eps = 1e-6;
ll const Base=1e9+7,oo=1e17,MAXN=1e6;


ll A[MAXN+5];

ll Solves(){
	
	ll n,m,k,cnt=0,ans=0,x,y,q,c,sum=0,v,t;
	// PROCESS IN HERE
	sc(n);
	pr(n/500*1000+n%500/5*5);
	
	
	
	
	re 0;
	// Hack it if you can :)
}

int main(){
	//INPUT;
	if(fopen("locin.txt", "r"))INPUT;
	ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	ll test=1;
//	sc(test);
	fu(T,1,test){
//		cout<<"Case #"<<T<<": ";
		Solves();
	} 		
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int N;
	int modnum=0;
	int ans = 0;
	scanf("%d",&N);
	for(int i = 1;i<=N;i+=2){
		modnum=0;
		for(int j=1;j<=N;j++){
			if( i%j == 0){
				modnum++;
			}
		}
		if( modnum ==8){
			ans++;
		}
	}
	printf("%d",ans);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <math.h>
#include <stdio.h>
#include <string>
using namespace std;

int main(void){
    int N;
  	scanf("%d", &N);
    int l, i=0, a[N-1];
    while(cin>>l){
        a[i] = l;
        i++;
    }
	for(i=0;i<N-1;i++){
      int ans=0;
      for(int j=i;j<N-1;j++){
        if(a[j]==i+1){
          ans++;
        }
      }
      printf("%d\n",ans);
	}
	printf("0");
}

Measured memory_bytes: 4000
#include <cstdio>
#include <queue>

using namespace std;

int a;
long long sum;
priority_queue<int> q;

int main(){
	int n, m;	
	scanf("%d%d", &n, &m);
	for(int i = 0; i < n; ++i){
		scanf("%d", &a);
		q.push(a);
	}
	for(int i = 0; i < m; ++i){
		a = q.top();
		q.pop();
		a /= 2;
		q.push(a);
	}
	while(!q.empty()){
		sum += q.top();
		q.pop();
	}
	printf("%lld", sum);
	return 0;
} 

Measured memory_bytes: 892
N, T = map(int, input().split())

ct = []

for i in range(N):
    ct.append([int(i) for i in input().split()])

ct.sort(key=lambda x: x[0])

ans = 1001

for i in range(N):
    if ct[i][1] <= T:
        ans = ct[i][0]
        break

print("TLE" if ans == 1001 else ans)


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

int main(){
	string s;
	cin>>s;
	string a="CODEFESTIVAL2016";
	int ans=0;
	for(int i=0;i<16;i++){
		if(a[i]!=s[i])ans++;
		}
		cout<<ans<<endl;
	}


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

#define ll long long
#define pii pair<int, int>
#define pll pair<long, long>
#define pdd pair<double, double>
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mod 1000000007
#define umap unordered_map
#define uset unordered_set

using namespace std;

vector<bool> prime;

ll modex(ll x,ll n)
{
	if(!n) return 1;
    if(n&1) return (x*modex((x*x)%mod,(n-1)/2))%mod;
    else return modex((x*x)%mod,n/2);
}
ll modinv(ll n) 
{ 
	return modex(n,mod-2); 
}
void sieve(ll n) {
	prime.resize(n+1, true);
	for(ll p=2;p<=n;p++) {
		if(prime[p]) {
			for(int i=p;i*i<=n;i+=p) prime[i] = false;
		}
	}
}

void solve() {
	// type code here
	int n,m; int t,d;
	cin>>n>>m>>t>>d;
	if(n<t) cout << 1 <<endl;
	else cout << 0 << endl;
}

int main(void) {
	fastio;
	solve();
	// int t; cin>>t;
	// while(t--)
	// 	solve();
	return 0;
}


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

using namespace std;

#define PI          3.1415926535897932384626433832795l

#define pb push_back
#define mp make_pair
#define lb lower_bound // First element which is not less than val
#define ub upper_bound // First element greater than val
#define f first
#define s second

#define sz(x) int((x).size())
#define all(x) (x).begin(), (x).end()

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vb = vector<bool>;
using vd = vector<double>;
using vs = vector<string>;
using vpii = vector<pair<int,int>>;
using vpll = vector<pair<ll,ll>>;

using pii = pair<int,int>;
using pll = pair<ll,ll>;

#define endl '\n'
#define re return

#define rep(i,a,b) for (ll i = (a); i < (b); i++)
#define repz(i, a) for (ll i = 0; i < (a); i++)
#define repd(i,a,b) for (ll i = (a); i >= b; i--)
#define repdz(i,a) for (ll i = a; i >=0; i--)
#define trav(a, x) for (auto& a : x)

#define vecin(n,v) for(ll i = 0; i < n; i++) cin>>v[i];
#define llin(a) ll a; cin>>a;
#define llin2(a,b) ll a,b; cin >>a>>b;
#define llin3(a,b,c) ll a,b,c; cin>>a>>b>>c;
#define full(v) v.begin(),v.end()

void solve()
{
    int n,m;
    cin >> n >> m;
    vi a(n);
    int sum = 0;
    repz(i,n)
    {
        cin >> a[i];
        sum += a[i];
    }
    double prop = 0.25*(1/(double)m)*sum;
    int cnt = 0;
    repz(i,n)
    {
        if (a[i]>=prop)
            cnt++;
    }
    if (cnt >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}
int main()
{
    //ios_base::sync_with_stdio(false);
    //llin(t);
    //while (t--)
    //{
        solve();
    //}
}


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

public class Main {

	static int gcd(int a,int b) {
		return b==0?a:gcd(b,a%b);
	}
	public static void main(String[] args) throws IOException {
		Scanner sc = new Scanner();
		PrintWriter out = new PrintWriter(System.out);
		int n=sc.nextInt();
		int N=(int)1e6+5;
		int[]cnt=new int[N];
		int gcd=0;
		for(int i=0;i<n;i++) {
			int x=sc.nextInt();
			gcd=gcd(gcd,x);
			cnt[x]++;
		}
		boolean all=true;
		boolean[] isPrime=new boolean[N];
		Arrays.fill(isPrime, true);
		for(int i=2;i<N;i++)
			if(isPrime[i]) {
				int curr=0;
				for(int j=i;j<N;j+=i) {
					curr+=cnt[j];
					isPrime[j]=false;
				}
				all&=curr<2;
				
			}
		out.println(all?"pairwise coprime":gcd==1?"setwise coprime":"not coprime");
		out.close();

	}

	static class DSU {
		int[] p, r;

		DSU(int n) {
			p = new int[n];
			r = new int[n];
			for (int i = 0; i < n; i++)
				p[i] = i;
		}

		boolean union(int x, int y) {
			x = findSet(x);
			y = findSet(y);
			if (x == y)
				return false;
			if (r[x] > r[y]) {
				p[y] = x;
			} else {
				p[x] = y;
				if (r[x] == r[y])
					r[y]++;
			}
			return true;

		}

		int findSet(int x) {
			if (p[x] == x)
				return x;
			else
				return p[x] = findSet(p[x]);
		}
	}

	static class Scanner {
		BufferedReader br;
		StringTokenizer st;

		Scanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}

		Scanner(String fileName) throws FileNotFoundException {
			br = new BufferedReader(new FileReader(fileName));
		}

		String next() throws IOException {
			while (st == null || !st.hasMoreTokens())
				st = new StringTokenizer(br.readLine());
			return st.nextToken();
		}

		String nextLine() throws IOException {
			return br.readLine();
		}

		int nextInt() throws IOException {
			return Integer.parseInt(next());
		}

		long nextLong() throws NumberFormatException, IOException {
			return Long.parseLong(next());
		}

		double nextDouble() throws NumberFormatException, IOException {
			return Double.parseDouble(next());
		}

		boolean ready() throws IOException {
			return br.ready() || st.hasMoreTokens();
		}

		int[] nxtArr(int n) throws IOException {
			int[] ans = new int[n];
			for (int i = 0; i < n; i++)
				ans[i] = nextInt();
			return ans;
		}

	}

	static void sort(int[] a) {
		shuffle(a);
		Arrays.sort(a);
	}

	static void shuffle(int[] a) {
		int n = a.length;
		Random rand = new Random();
		for (int i = 0; i < n; i++) {
			int tmpIdx = rand.nextInt(n);
			int tmp = a[i];
			a[i] = a[tmpIdx];
			a[tmpIdx] = tmp;
		}
	}

}

Measured memory_bytes: 76004