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


// vector
#define MAX_ELE(vec) *max_element(vec.begin(), vec.end())

// ---------------------------------------

// string
#define TO_UP(str) transform(str.cbegin(), str.cend(), str.begin(), ::toupper)

// ---------------------------------------



using namespace std;
int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
//  --------------------------------------

    int N, A, B;

    cin >> N >> A >> B;

    if(N*A < B){
        cout << N*A << "\n";
    }else{
        cout << B << "\n";
    }

}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L x,L i){for(x=G(x)-M(i+1)+M(i++);i<1<<17;B[i]+=x,i+=i&-i);}
L W(){for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
main(){for(cin>>n>>k;++p<n;path[a][b]=path[b][a]=c)cin>>a>>b>>c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;S(a=H[a],O[a]=c++))X[a]=p;
       for(cin>>a;cin>>s>>a>>b;*s&2?W():A[a]+=b,S(H[a],O[a]),a?S(a,O[a]-1):0);}
       

Measured memory_bytes: 33416
#include<vector>
#include<list>
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
string f(string s){
  int i;
  int ln=s.length();
  string t;
  t=s;
  for(i=0;i<ln;i++)
    t[i]=s[ln-i-1];
  return t;
}
int main(){
  int i,j;
  int n;
  int ln;
  int *a;
  string s;
  list<string> l;
  cin>>n;
  a=new int[n];
  for(i=0;i<n;i++){
    cin>>s;
    ln=s.length();
    l.clear();
    for(j=1;j<ln;j++){
      l.push_back(s.substr(0,j)+s.substr(j));
      l.push_back(f(s.substr(0,j))+s.substr(j));
      l.push_back(s.substr(0,j)+f(s.substr(j)));
      l.push_back(f(s.substr(0,j))+f(s.substr(j)));
      l.push_back(s.substr(j)+s.substr(0,j));
      l.push_back(f(s.substr(j))+s.substr(0,j));
      l.push_back(s.substr(j)+f(s.substr(0,j)));
      l.push_back(f(s.substr(j))+f(s.substr(0,j)));
    }
    l.sort();
    l.unique();
    a[i]=l.size();
  }
  for(i=0;i<n;i++)
    cout<<a[i]<<endl;
  delete[]a;
  return 0;
}

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


int main(){
    int a, b; cin >> a >> b;
    if(a == b){
        rep(i, a) cout << a;
    }
    else{
        rep(i,max(a,b)) cout << min(a,b);
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

bool exist(const string &s, char tgt) {
  for (auto ch: s) {
    if (ch == tgt) return true;
  }
  return false;
}

int main () {

  string s;
  cin >> s;

  int64_t a = 0;
  for (auto ch: s) {
    a = a * 10 + (ch - '0');
  }

  vector<int> v;
  rep(i, s.size()) v.push_back(1);
  while(v.size() < 10) {
    v.push_back(0);
  }
  reverse(v.begin(), v.end());
  int64_t pow10n = 1;
  rep(i, s.size()) pow10n *= 10;
  int64_t mx = 0;
  string arg_mx = to_string(pow10n - 1);
  do {
    vector<int> w;
    rep(i, 10) {
      if (v[i]) w.push_back(i);
    }
    do {
      int64_t b = 0;
      for (auto d: w) {
        b = b * 10 + d;
      }
      auto tmp = min(abs(a - b), pow10n - abs(a - b));
      if (tmp >= mx) {
        string str_b = "";
        for (auto d: w) {
          str_b += (char)(d + '0');
        }
        if (tmp > mx) {
          mx = tmp;
          arg_mx = str_b;
        } else if(str_b < arg_mx) {
          arg_mx = str_b;
        }
      }
    } while(next_permutation(w.begin(), w.end()));
  } while(next_permutation(v.begin(), v.end()));

  cout << arg_mx << endl;
  return 0;
}


Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <map>
#include <cmath>
#include <bitset>

using namespace std;

#define int long long

signed main() {
    int k, n;
    cin >> k >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];
    

    int max_dist = 0;
    for(int i = 0; i < n; i++) {
        if(i < n - 1) {
            int dist = abs(a[i] - a[i + 1]);
            max_dist = max(max_dist, dist);
        } else {
            int dist = abs((k - a[i]) + a[0]);
            max_dist = max(max_dist, dist);
        }
    } 

    cout << k - max_dist << endl;
    return 0;
}

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

using namespace std;
using ll = long long;

int main() {
    string s;
    cin >> s;
    int cnt = 0;
    int ans = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'R') cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T> void assign(V<T>& v, int n, const T& a = T()) { v.assign(n, a); }
template<class T, class... U> void assign(V<T>& v, int n, const U&... u) { v.resize(n); for (auto&& i : v) assign(i, u...); }

struct M {
  using T = lint;
  static T op(const T a, const T b) { return max(a, b); }
  static constexpr T e() { return numeric_limits<T>::min(); }
};

template<class M> struct ST {
  using T = typename M::T;
  int n;
  V<T> t;

  ST(int n) : n(n) {
    t.assign(2 * n, M::e());
  }

  void build() {
    for (int i = n - 1; i; i--) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }

  T get(int l, int r) {
    T resl = M::e(), resr = M::e();
    for (l += n, r += n; l < r; l >>= 1, r >>= 1) { 
      if (l & 1) resl = M::op(resl, t[l++]); 
      if (r & 1) resr = M::op(t[--r], resr);
    }
    return M::op(resl, resr);
  }

  void set(int i, const T a) {
    for (t[i += n] = a; i >>= 1;) t[i] = M::op(t[2 * i], t[2 * i + 1]);
  }
};

int main() {
  cin.tie(NULL); ios::sync_with_stdio(false);
  int n, m, k; cin >> n >> m >> k;
  V<lint> a(n); for (int i = 0; i < n; i++) cin >> a[i];
  lint dp[2][n + 1];
  memset(dp, 0, sizeof(dp));
  for (int i = 1; i < k + 1; i++) {
    ST<M> st(n + 1);
    for (int j = 0; j < n + 1; j++) st.t[j + n + 1] = dp[i - 1 & 1][j];
    st.build();
    for (int j = i; j < n + 1; j++) {
      dp[i & 1][j] = i * a[j - 1] + st.get(max(j - m, 0), j);
    }
  }
  cout << *max_element(dp[k & 1], dp[k & 1] + n + 1) << '\n';
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define itn int

int main(void){
    int n;
    cin >> n;
    int a[n];
    map<long long,long long>mp;
    for(int i = 0;i < n;i++)cin >> a[i];
    
    long long sum = 0;
    
    for(int i = 0;i < n;i++){
        //mp[a[i]-(i+1)]++;
        mp[(-a[i]+(i+1))]++;
    }
    
    for(int i = 0;i < n;i++){
        mp[(-a[i]+(i+1))]--;
        //mp[a[i]-(i+1)]--;
        
        if(mp[abs(a[i]+(i+1))] > 0){
            sum += mp[abs(a[i]+(i+1))];
            
        }
    }
    cout << sum << endl;
}

Measured memory_bytes: 26996
#include <iostream>
#include <vector>
#include <numeric>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <cmath>
#include <utility>
#define FOR(i, a, b) for (ll i = (a); i < (b); ++i)
#define REP(i, n) for (ll i = 0, i##_len = (n); i < i##_len; ++i)
#define INF 1e9
typedef long long int ll;
using namespace std;

int main()
{
    int N;
    cin >> N;
    vector<int> L(2*N);
    REP(i,2*N){
        cin >> L[i];
    }

    sort(L.begin(), L.end());

    ll ans=0;
    REP(i,2*N){
        if(i%2==0)  ans+=L[i];
    }

    cout << ans << endl;
    return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long //pi        3.14159265358979323846
int main() {

ll n,s=0;
cin>>n;
vector<ll> v(n);
for(int i=0;i<n;i++)
{
    cin>>v[i];
    s=s+v[i];
}
bitset<10000000> dp;
dp[0]=1;
for(int i=0;i<n;i++)
{
    dp=dp|(dp<<v[i]);
}
ll i=(s+1)/2;
while(dp[i]==0)
{
    i++;
}
cout<<i<<endl;

	return 0;
} 

Measured memory_bytes: 5120
#include<stdio.h>

int main()
{
	char s[100];
	scanf("%s", s);
	if ((s[0] == s[1] || s[0] == s[2] || s[0] == s[3])&& (s[1] == s[2] || s[1] == s[3] || s[2] == s[3])
		&&(s[0] != s[1] || s[0] != s[2] || s[0] != s[3]))
		printf("Yes");
	else
		printf("No");
	return 0;
}

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

int main() {
	int a, b, c;
	int bel[3];

	for (int i = 0; i < 3; i++)
	{
		cin >> bel[i];
	}

	int max;
	if (bel[0] < bel[1])
	{
		max = 1;
	} else {
		max = 0;
	}
	if (bel[max] < bel[2])
	{
		max = 2;
	} else {
		
	}

	int ans;
	if (max == 0) {
		ans = bel[1] + bel[2];
	}
	if (max == 1) {
		ans = bel[0] + bel[2];
	}
	if (max == 2) {
		ans = bel[1] + bel[0];
	}

	cout << ans << endl;


	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define pi acos(-1.0)
const int MOD=1e9+7;
#define pb push_back
#define cy cout<<"Yes\n"
#define cn cout<<"No\n"
#define ci cout<<"impossible\n"
typedef unsigned long long int ull;
typedef long long int ll;
const int MAX=500005;
ll ar[MAX],br[MAX];
const int M=1e4;
ll cnt[M];
int main()
{
    int n;
    cin>>n;
    for(int i=0;i<n;i++)cin>>ar[i];
    for(int i=0;i<n;i++)cin>>br[i];
    reverse(br,br+n);
    int l=0,r=n-1;
    for(int i=0;i<n;i++)
    {
        if(ar[i]==br[i])
        {
            if(br[l]!=br[i] and ar[l]!=br[i])
            {
                swap(br[l],br[i]);
                l++;
            }
            else if(br[r]!=br[i] and ar[r]!=br[i])
            {
                swap(br[r],br[i]);r--;
            }
            else
            {
                cn;
                return 0;
            }
        }
    }
    bool ok=1;
    for(int i=0;i<n;i++)
    {
        if(ar[i]==br[i])
        {
            cn;
            return 0;
        }
    }
    cy;
    for(int i=0;i<n;i++)
        cout<<br[i]<<" ";

}





Measured memory_bytes: 6808
x,n = map(int,input().split())
a = []
if n != 0 : a = list(map(int,input().split()))
tmp = 114514
ret = -114514
for i in range(-10,110):
  if not i in a and abs(x-i) < tmp:
    ret = i
    tmp = abs(x-i)
print(ret)


Measured memory_bytes: 9176
#include <bits/stdc++.h>
#define ll long long
#define all(a) (a).begin(),(a).end()

ll gcd(ll,ll);

using namespace std;

int main(int argc, char const *argv[]) {
  ll N,K;
  scanf("%lld%lld",&N,&K);
  std::vector<ll> A(N);
  for (size_t i = 0; i < N; i++) {
    scanf("%lld",&A[i]);
  }
  bool flag=true;
  if(K%2==1){
    for (size_t i = 0; i < N; i++) {
      if(A[i]%2==1){
        flag=false;
        break;
      }
    }
    if(flag){
      printf("IMPOSSIBLE\n");
      return 0;
    }
  }

  ll temp=A[0];
  for (size_t i = 1; i < N; i++) {
    temp=gcd(A[i],temp);
  }

  if(K%temp==0 && K<=*max_element(all(A))){
    printf("POSSIBLE\n");
  }else{
    printf("IMPOSSIBLE\n");
  }
  return 0;
}

ll gcd(ll a,ll b){
  if(a<b){
    ll tmp=a;
    a=b;
    b=tmp;
  }

  ll r=a%b;
  while(r!=0){
    a=b;
    b=r;
    r=a%b;
  }
  return b;
}


Measured memory_bytes: 1024
from collections import defaultdict

N = int(input())

def factorize(N):
    factors = defaultdict(int)
    i = 2
    while i * i <= N:
        factor = 0
        while N % i == 0:
            N //= i
            factor += 1
        if factor > 0:
            factors[i] = factor
        i += 1
    if N > 1:
        factors[N] = 1
    return factors

def to_cnt(n):
    i = 0
    while n >= i+1:
        n-=(i+1)
        i += 1
    return i

ans = 0
for _, n in factorize(N).items():
    ans += to_cnt(n)
print(ans)

Measured memory_bytes: 9440
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <chrono>
#include <stack>
#include <string>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <cstdio>
#include <limits>
#include <vector>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <numeric>
#include <sstream>
#include <cassert>
#include <tuple>
#include <iomanip>
#include <random>
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <fstream>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef vector<bool> vb;

#define pb push_back
#define fi first
#define se second
#define in insert
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

const int mod = 1e9 + 7;
const int inf = 1e9;

template <class T>
istream& operator>>(istream& ss, vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss >> v[i];
    return ss;
}

template <class T> 
ostream& operator<<(ostream& ss, const vector<T>& v) {
    for (int i = 0; i < v.size(); i++) ss << v[i] << ' ';
    return ss;
}
int n, m, x;
int p[12];
int a[12][12];
int lvl[12];
int ans = inf;
void rec(int idx, int sum) {
    if (idx == n) {
        bool q = true;
        for (int i = 0; i < m; ++i) {
            if (lvl[i] < x) {
                q = false;
                break;
            }
        }
        if (q) ans = min(ans, sum);
        return;
    }
    rec(idx + 1, sum);
    for (int i = 0; i < m; ++i) lvl[i] += a[idx][i];
    rec(idx + 1, sum + p[idx]);
    for (int i = 0; i < m; ++i) lvl[i] -= a[idx][i];
}
void solve(){
    cin >> n >> m >> x;
    for (int i = 0; i < n; ++i) {
        cin >> p[i];
        for (int j = 0; j < m; ++j) cin >> a[i][j];
    }
    rec(0, 0);
    if (ans == inf) cout << -1;
    else cout << ans;
}

int main(){
    int t = 1;
    //cin >> t;
    for(int i = 1; i <= t; i++){
        solve();
    }
}

Measured memory_bytes: 3520
import java.util.*;
import java.io.*;
import java.awt.geom.*;
import java.math.*;

public class Main {

	static final Scanner in = new Scanner(System.in);
	static final PrintWriter out = new PrintWriter(System.out,false);

	static void solve() {
		Integer[] a = new Integer[5];
		for (int i=0; i<5; i++) {
			a[i] = in.nextInt();
		}

		Arrays.sort(a, new Comparator<Integer>(){
			public int compare(Integer a, Integer b) {
				return b - a;
			}
		});

		for (int i=0; i<4; i++) {
			out.print(a[i]+" ");
		}
		out.println(a[4]);
	}

	public static void main(String[] args) {
		long start = System.currentTimeMillis();

		solve();
		out.flush();

		long end = System.currentTimeMillis();
		//trace(end-start + "ms");
		in.close();
		out.close();
	}

	static void trace(Object... o) { System.out.println(Arrays.deepToString(o));}
}

Measured memory_bytes: 26196
#include<stdio.h>

 


int main(void){
    int n,max=0;
    scanf("%d",&n);
    int a[n];
    for(int i=0;i<n;i++){
        scanf("%d",&a[i]);   
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<n-1;j++){
            if(a[j]<a[j+1]){
                int y;
                y=a[j+1];
                a[j+1]=a[j];
                a[j]=y;
            }
        }
    }

    for(int i=0;i<n-1;i++){
        if(a[i]>a[i+1]){
            max++;
        }
    }

    printf("%d",max+1);
    
    return 0;
}

Measured memory_bytes: 128
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int A[] = new int[N];
        int B[] = new int[N];
        int C[] = new int[N];
        for(int i = 0; i < N; i++){
            A[i] = sc.nextInt();
        }
        for(int i = 0; i < N; i++){
            B[i] = sc.nextInt();
        }
        for(int i = 0; i < N - 1; i++){
            C[i] = sc.nextInt();
        }
        int result = 0;
        int prev = N + 1;
        for(int i = 0; i < N; i++){
            result += B[A[i] - 1];
            if(prev + 1 ==  A[i]){
                result += C[A[i - 1] - 1];
            }
            prev = A[i];
        }
        System.out.println(result);
    }
}


Measured memory_bytes: 21332
process.stdin.resume();
process.stdin.setEncoding('utf8');

process.stdin.on('data', function (chunk) {
    var lines = chunk.toString().split(' ');
    var first = Number(lines[0]);
    var second = Number(lines[1]);

    var time = second + first;
    
    if(
        time<24)
        {
            console.log(time)
        }else{
            console.log(time-24)
        }
        
//    console.log(lines);
});

Measured memory_bytes: 7500
#include <algorithm>
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <string>
#include <map>
#include <cmath>
#include <cstring>

#define fi first
#define se second
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define rrep(i,n) for (int i = 1; i < (n); ++i)
#define drep(i,n) for (int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define all(x) (x).begin(), (x).end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define pb push_back
#define sz(x) (int)(x).size()
#define PQ(T) priority_queue<T, v(T), greater<T> >

using namespace std;
using ll = long long;
using uint = unsigned;
using ull = unsigned long long;
using P = pair<int,int>;

const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;

const int mod = 1000000007;

int dp[100100];

int main() {
    int n, k; cin >> n >> k;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    rep(i,n) dp[i] = INF;
    dp[0] = 0;
    rep(i,n) {
        for (int j = 1; j<=k; ++j) dp[i+j] = min(dp[i+j],dp[i]+abs(h[i]-h[i+j]));
    }
    cout << dp[n-1] << endl;
    return 0;
}






Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
const int MAX=1e5+5;
const int N=403;
int x[MAX];
int y[MAX];
int arr[N][N];
int fl[N];

int main()
{
	int n,m;
	scanf("%d %d",&n,&m);
	for(int i=1;i<=m;i++)
	{
		scanf("%d %d",&x[i],&y[i]);
	}
	for(int i=1;i<=n;i++)
	{
		arr[i][i]=1;
	}
	for(int i=1;i<=n;i++)
	{
		for(int j=m;j>=1;j--)
		{
			int a=x[j];
			int b=y[j];
			if(arr[i][a]&&arr[i][b])
			{	
				fl[i]=1;
			}
			else if(arr[i][a])
			{
				arr[i][b]=1;
			}
			else if(arr[i][b])
			{
				arr[i][a]=1;
			}
		}
	}
	int ans=0;
	for(int i=1;i<=n;i++)
	{
		for(int j=i+1;j<=n;j++)
		{
			if(fl[i]||fl[j])
			{
				continue;
			}
			int ok=1;
			for(int k=1;k<=n;k++)
			{
				if(arr[i][k]&&arr[j][k])
				{
					ok=0;
				}
			}
			ans+=ok;
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 1664
i = input()
data = i.split(" ")
if int(data[0])*int(data[1]) == int(data[0]) or int(data[0])*int(data[1]) == int(data[1]):
    print(1)
elif (int(data[0])*int(data[1]))%2 == 0:
    print(int(data[0])*int(data[1])//2)
else:
    print(int(data[0])*int(data[1])//2+1)

Measured memory_bytes: 3064
def mapt(fn, *args):
    return tuple(map(fn, *args))


def aa(W, H, x, y, r):
    if 0 <=x-r and 0 <= y-r and x+r <= W and y+r <= H:
        print("Yes")
    else: print("No")


n = mapt(int, input().split(" "))

aa(*n)


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

    #define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
    #define uint unsigned int
    #define lli long long int
    #define pb push_back
    #define mp make_pair
    #define fi first
    #define se second
    #define pii pair<int,int>
    #define all(x) (x).begin(), (x).end()
    #define forn(i, n)  for(int i=0;i<n;++i)
    #define rforn(i,start) for(int i = start; i >= 0;--i)
    #define forsn(i,start,end) for(int i=start;i<end;++i)
    #define rforsn(i,start,end) for(int i=start;i>=end;--i)
    #define debug(x) cout<<#x<<" = "<<x<<"\n";
    const int CONST = 1e9 + 7;
    const double pi = 3.14159265358979323846;

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

        #ifndef ONLINE_JUDGE
        //    freopen("input.txt", "r", stdin);
        //  freopen("output.txt","w",stdout);
        #endif
        
        int arr[5];
        int sum=0;
        forn(i, 5){
            cin>>arr[i];
            sum+= arr[i];
        }
        cout<<(15-sum)<<endl;
        return 0;
    }


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

int main() {
  int A,B,C,K;
  cin >> A >> B >> C >> K;
  
  if(K<=A){
    cout << K << endl;
  }
  
  else if(K<=A+B){
     cout << A << endl;
  }
  
  else{
    int x=K-A-B;
    cout << A-x << endl;
  }
    
}


Measured memory_bytes: 3632
n,h=map(int,input().split())
A=[]
B=[]
C=[]
for i in range(n):
    a,b=map(int,input().split())
    A.append(a)
    B.append(b)
amax=max(A)
for i in range(n):
    if amax<=B[i]:
        C.append(B[i])
A.sort(reverse=True)
B.sort(reverse=True)
C.sort(reverse=True)
cnt=0
ans=0
for i in range(len(C)):
    if ans<h:
        ans+=C[i]
    else:
        break
    cnt+=1
if ans<h:
    if ((h-ans)//amax)*amax<h-ans:
        cnt+=(h-ans)//amax+1
    else:
        cnt+=(h-ans)//amax
        
print(cnt)


Measured memory_bytes: 67928
#include<iostream>
using namespace std;
int main() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; i++) {
		if (i % 3 == 0) {
			cout << " " << i;
		}
		else {
			int x = i;
			while (x) {
				if (x % 10 == 3) {
					cout << " " << i;
					break;
				}
				x /= 10;
			}
		}
		

	}
	cout << endl;
	
}


Measured memory_bytes: 3108
#include<iostream>
#include<set>
using namespace std;

int n;
string str;
set<string> ise;

int main()
{
	ios::sync_with_stdio(false);
	cin>>str>>n;
	for(int k=0;k<26;++k)
	{
		char c=char(k+'a');
		for(int i=0;i<str.size();++i)
			if(str[i]==c){
				string s="";
				for(int j=0;j<5&&i+j<str.size();++j)
				{
					s+=str[i+j];
					ise.insert(s);
				}
			}
		if(ise.size()>=5)	break;
	}
	string ss[10];
	int k=1;
	for(auto c:ise)
	{
		ss[k++]=c;
		if(k==6)	break;
	}
	cout<<ss[n]<<endl;
	return 0;
}

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

#[fastout]
fn main() {
    input! {
        n: usize,
        m: usize,
    }

    if n % 2 == 1 {
        for i in 1..=m {
            println!("{} {}", i, n + 1 - i);
        }
    } else {
        for i in 1..=(m + 1) / 2 {
            println!("{} {}", i, n + 1 - i);
        }
        for i in (m + 1) / 2 + 1..=m {
            println!("{} {}", i, n - i);
        }
    }
}


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

int main() {
  int x;
  cin >> x;
  int a, b;
  for (int i = 0; i < 3000; i++) {
    for (int j = 0; j < 3000; j++) {
      if (pow(i - 1500, 5) - pow(j - 1500, 5) == x) {
        a = i - 1500;
        b = j - 1500;
      }
    }
  }
  cout << a << " " << b << endl;
}

Measured memory_bytes: 4092
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()

int main(){
  string s,t;
  ll a=0;
  cin >> s >> t;
  for(ll i=0;i<3;i++){
    if(s.at(i) == t.at(i)){
      a++;
    }
  }
  cout << a << endl;
}


Measured memory_bytes: 256
import java.util.Scanner;

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

		double ans = 0.0;
		for (int i = 1; i <= N; i++) {
			int cnt = 0;
			double p = i;
			while (p < K) {
				cnt++;
				p *= 2.0;
			}
			ans += 1.0 / N * Math.pow(0.5, cnt);
		}
		System.out.println(ans);
	}
}

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

using namespace std;

typedef long long int ll;
typedef long double ld;

ll dp[102][100010];
ll weight[100010], cost[100010];
ll cap, n;

ll ZeroOneKnapsack(int i, ll w){
	if(i == n) return 0;
	
	if(dp[i][w] != -1) return dp[i][w];
	
	ll profit1 = 0, profit2 = 0;
	
	if(w + weight[i] <= cap){
		profit1 = cost[i] + ZeroOneKnapsack(i + 1, w + weight[i]);
	}
	else profit1 = 0;
	
	profit2 = ZeroOneKnapsack(i + 1, w);
	
	return dp[i][w] = max(profit1, profit2);
}

int main(){
	ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
	
	cin >> n >> cap;
	
	memset(dp, -1, sizeof(dp));
	
	for(int i = 0; i < n; i++){
		ll x, y;
		cin >> x >> y;
		weight[i] = x, cost[i] = y;
	}

	ll ans = ZeroOneKnapsack(0, 0);
	
	cout << ans << endl;
	
	return 0;
}




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

ll n;
string s;

int main(){
    cin >> n;
    cin >> s;
    ll count=0;
    ll left=0;
    for(ll i=0;i<n;i++){
        if(s[i]=='(') count++;
        else if(s[i]==')'&&count==0) left++;
        else if(s[i]==')'&&count>0) count--;
    }
    string res="";
    for(ll i=0;i<left;i++) res+="(";
    res+=s;
    for(ll i=0;i<count;i++) res+=")";
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 3564
import java.util.Arrays;
import java.util.Comparator;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args) {
        Scanner stdin = new Scanner(System.in);
        int n = Integer.parseInt(stdin.nextLine());
        int[] a = new int[n];
        for (int i = 0; i < n; i++) a[i] = Integer.parseInt(stdin.nextLine());
        
        List<Integer> b = Arrays.stream(a).boxed().sorted(Comparator.reverseOrder()).collect(Collectors.toList());
        for (int i = 0; i < n; i++) {
            if (a[i] == b.get(0)) {
                System.out.println(b.get(1));
            } else {
                System.out.println(b.get(0));
            }
        }
    }

}

Measured memory_bytes: 169192
#include<stdio.h>
#define M 100001
typedef struct tree{
  int p,l,r;
}t;
t T[M];
 
int main(void){
  int n,i,j,k,id,c,tmp,tmp2;
  scanf("%d",&n);
  for(i=0;i<n;i++)
    T[i].p=T[i].l=T[i].r=-1;
  for(i=0;i<n;i++){
    scanf("%d %d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      T[c].p=id;
      if(j==0)
    T[id].l=c;
      else
    T[tmp].r=c;
      tmp=c;
    }
  }
  for(i=0;i<n;i++){
    id=0;
    k=0;
    tmp=T[i].p;
    tmp2=T[i].l;
    while(tmp!=-1){
      k++,tmp=T[tmp].p;
    }
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,k);
    if(T[i].p==-1)
      printf("root, [");
    else if(T[i].l!=-1)
      printf("internal node, [");
    else
      printf("leaf, [");
    while(tmp2!=-1){
      if(id==0){
    printf("%d",T[i].l);
    id=1;
      }
      else
    printf(", %d",tmp2);
      tmp2=T[tmp2].r;
    }
    printf("]\n");
  }
  return 0;
}

Measured memory_bytes: 1784
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
using namespace std;
typedef long long ll;

#define rep(i, n) for(ll i = 0; i < n; i++)
#define REP(i, n) for(ll i = 1; i < n + 1; i++)
#define PI 3.14159265359
#define EPS 0.0000000001
#define MOD 1000000007
//cout << std::fixed << std::setprecision(15) << y << endl;


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

    ll d[N];
    rep(i, N){
        cin >> d[i];
    }
    sort(d, d + N);

    ll ans = d[N / 2] - d[N / 2 - 1];
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4368
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
int main()
{
long long a,b,k,x;
cin>>a;
cin>>b;
cin>>k;
x=a-k;
if(x<0&&k>a)
{
b=b+x;
x=0;
}
if(b<0)
{
b=0;
}
cout<<x<<" "<<b;
}



Measured memory_bytes: 3612
N = int(input())
A = list(map(int, input().split()))
count = 0
judge = True

while(True):
    for i in range(N):
        if A[i] % 2 == 0:
            A[i] /= 2
        else:
            judge = False
            break
    if judge == False:
        break
    count += 1
            
print(count)

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

typedef std::pair<int, int> ipair;
#define pb push_back
#define ff first
#define ss second
#define fr(i, j, k) for (int i = j; i < k; i++)
#define rf(i, j, k) for (int i = j; i >= k;i--)
#define int long long
#define ld long double
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(),x.rend()
#define mp make_pair

const int mod = 1000000007;
const ld pi = acos(-1);
const int maxn = 200006;

template<class T> ostream& operator <<(ostream &out,vector<T> &A){for(auto x:A) out<<x<<" ";return out;}
template <class T1,class T2>T1 powr(T1 a,T2 b){T1 res = 1;fr(i,1,b+1)res = res*a;return res;}
#define IOS  std::ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int32_t main(){
  int n,cnt=0;  cin>>n;
  vector<int>A(n);
  fr(i,0,n){
     cin>>A[i];
     if(A[i] != i+1)  cnt++;
   }
  puts(cnt>2?"NO":"YES");
}


Measured memory_bytes: 256
from collections import Counter

n, m = map(int, input().split())
a = list(map(int, input().split()))
SUM = [0]

for i in a:
    SUM.append((SUM[-1]+i)%m)

c = Counter(SUM)
C = c.most_common()
C_srt = sorted(C)
ans = 0

for i in C:
    if i[1] > 1:
        ans += i[1]*(i[1]-1)//2
    else:
        break
print(ans)

Measured memory_bytes: 19624
#include <iostream>
#include <string>
#include <cmath>
#include <vector>
#include <set>
#include <utility>
#include <algorithm>
using namespace std;


int main()
{
    ios::sync_with_stdio(0);

    int n,m;
    cin>>n>>m;
    char arr[100][100];
    for(int i=0;i<n;i++)
      {
        for(int j =0;j<m;j++)
         cin >> arr[i][j];
      }
    int c[100] = {0};
    for(int i=0;i<n;i++)
    {
        bool bo = false;
        for(int j=0;j<m;j++)
        {
            if(arr[i][j] == '#') bo =  true;
        }
        if(bo) c[i]++;
    }
    int b[100] = {0};
    for(int i=0;i<m;i++)
    {
        bool bo = false;
        for(int j=0;j<n;j++)
        {
            if(arr[j][i] == '#') bo =  true;
        }
        if(bo) b[i]++;
    }
    for(int i=0; i<n;i++)
    {
        for(int j=0;j<m; j++)
         {
            if(c[i]&&b[j])
            cout << arr[i][j];
        }
        if(c[i])
        cout << endl;
    }
}


Measured memory_bytes: 256
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def IS(): return sys.stdin.readline()[:-1]
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LI1(): return list(map(int1, sys.stdin.readline().split()))
def LII(rows_number): return [II() for _ in range(rows_number)]
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def LLI1(rows_number): return [LI1() for _ in range(rows_number)]

def main():
	N,K,Q = MI()
	cnt = [0]*N
	for i in range(Q):
		A = II()
		cnt[A-1]+=1
	ans = 0
	for i in range(N):
		if(K-Q+cnt[i] > 0):
			print("Yes")
		else:
			print("No")


main()

Measured memory_bytes: 47068
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	A := nextInt()
	B := nextInt()

	fmt.Println(calc(A-1) ^ calc(B))
}

func calc(n int) int {
	if n%2 == 0 {
		a := n / 2
		return n ^ a%2
	}

	a := (n + 1) / 2
	return a % 2
}

// Input. ----------

var sc = bufio.NewScanner(os.Stdin)

func init() {
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Split(bufio.ScanWords)
}

func nextInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}

	return i
}

func nextFloat() float64 {
	sc.Scan()
	f64, err := strconv.ParseFloat(sc.Text(), 64)
	if err != nil {
		panic(err)
	}

	return f64
}

func nextString() string {
	sc.Scan()
	if err := sc.Err(); err != nil {
		panic(err)
	}

	return sc.Text()
}

// ---------- Input.

// Util. ----------

func abs(x int) int {
	return int(math.Abs(float64(x)))
}

func min(x, y int) int {
	return int(math.Min(float64(x), float64(y)))
}

func max(x, y int) int {
	return int(math.Max(float64(x), float64(y)))
}

// ---------- Util.


Measured memory_bytes: 640
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define repo(i,N) for(int i = 1; i < (N); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)


int main() {
  int n;
  cin >> n;
  int ans = 0;

  if(105<=n && n<=134) ans=1;
  if(135<=n && n<=164) ans=2;
  if(165<=n && n<=188) ans=3;
  if(189<=n && n<=194) ans=4;
  if(195<=n) ans=5;
  
  cout << ans << endl;

}

Measured memory_bytes: 256
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)
        a := make([]int, n)
        for i := range a {
                fmt.Scan(&a[i])
        }

        fmax := 0
        for i := range a {
                fmax += a[i] - 1
        }
        fmt.Println(fmax)
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define ALL(A) (A).begin(),(A).end()
#define ll long long
#define rep(i,n) for(int i=0;i<(n);i++)

const ll mod = 1e9+7;
const ll INF = -1*((1LL<<63)+1);
const int inf = -1*((1<<31)+1);

using namespace std;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(20);
    int N; cin >> N;
    string S; cin >> S;
    int ans = 0;
    for(int i=0;i<N;i++){
        if(S[i]=='A'&&S[i+1]=='B'&&S[i+2]=='C'&&i+2<N)ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import product
import numpy as np

H, W, K = map(int, input().split())
C = [list(input()) for _ in range(H)]

C = np.array(C)
C = np.where(C == '.', 0, C)
C = np.where(C == '#', 1, C)
C = C.astype(np.int)

ans = 0

for h_bits in product(*[range(2) for _ in range(H)]):
    ch = C.copy()
    for i,h in enumerate(h_bits):
        if h == 1:
            ch[i] = 0
    for w_bits in product(*[range(2) for _ in range(W)]):
        cw = ch.copy()
        for j,w in enumerate(w_bits):
            if w == 1:
                cw[:,j] = 0
        if cw.sum() == K:
            ans += 1

print(ans)

Measured memory_bytes: 27248
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) {if (a<b) { a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, const T &b) {if (b<a) { a=b; return 1;} return 0;}
struct init{init(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}}init_;

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cerr << a[i] << " "; cerr << "\n" << flush; }
ll dbgt = 1; void err() { cerr << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cerr<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 4e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//

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

    map<ll, ll> mp;
    multiset<ll> ms;
    rep(i, W) mp[i] = 0, ms.emplace(0);
    mp[W] = 0;

    repe(h, 1, H + 1){
        ll a, b;
        cin >> a >> b, a--, b--;
        if(mp.size() == 1){
            cout << -1 << '\n';
            continue;
        }

        auto it = mp.upper_bound(b + 1);
        if(it != mp.begin()){
            it--;
            auto rr = mp.lower_bound(a);
            auto [id, v] = *it;

            while(rr->first < id){
                ms.erase(ms.lower_bound(rr->second));
                mp.erase(rr->first);
                rr = mp.lower_bound(a);
            }

            if(id >= a and id < W){
                ms.erase(ms.lower_bound(v));
                ll nid = b + 1, nv = v + b + 1 - id;

                mp.erase(id);
                mp[nid] = nv;

                ms.emplace(nv);
            }
        }

        // repa(t, mp) cout << t.first << " ";
        // cout << '\n';
        // repa(t, ms) cout << t << " ";
        // cout << '\n';

        cout << (ms.size() == 0 ? -1 : h + *ms.begin()) << '\n';
    }
}

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

using namespace std;
using ll = long long;

int main(void){
    ll X ,Y;
    cin >> X >> Y;
    int ans = 0;
    do{
        ans++;
        X = X * 2;
    }while(X <= Y);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
use std::io::Read;
use std::collections::HashMap;

fn main() {
    let mut buf = String::new();
    let _ = std::io::stdin().read_to_string(&mut buf);
    let mut it = buf.split_whitespace();
    let n: usize = it.next().unwrap().parse().unwrap();
    let s: Vec<String> = (0..n).map(|_| {
        it.next().unwrap().parse().unwrap()
    }).collect();
    let m: usize = it.next().unwrap().parse().unwrap();
    let t: Vec<String> = (0..m).map(|_| {
        it.next().unwrap().parse().unwrap()
    }).collect();
    
    let mut map: HashMap<String, i32> = HashMap::new();
    for i in 0..n {
        let e = map.entry(s[i].to_string()).or_insert(0);
        *e += 1;
    }
    for i in 0..m {
        let e = map.entry(t[i].to_string()).or_insert(0);
        *e -= 1;
    }
    let mut ans: i32 = 0;
    for (_, v) in &map {
        ans = std::cmp::max(ans, *v);
    }
    println!("{}", ans);
}


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

public class Main{
    public static void main(String args[]){
        Scanner in = new Scanner(System.in);
        
        double a = in.nextDouble(), b = in.nextDouble(), C = Math.toRadians(in.nextDouble());


        double h = b * Math.sin(C);
        double S = a * h / 2;
        double c = Math.sqrt(Math.pow(a, 2) + Math.pow(b, 2) - 2 * a * b * Math.cos(C));
        double L = a + b + c;

        System.out.printf("%f\n%f\n%f\n", S, L, h);
    }
}


Measured memory_bytes: 28156
/**
*    created: 09.07.2020 22:21:27
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
// #include <boost/multiprecision/cpp_int.hpp>
// using bint = boost::multiprecision::cpp_int;
using namespace std;
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define pcnt(bit) __builtin_popcountll(bit)
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;}
const long double pi = acos(-1.0);
const int MAX = 1000010;
const int INF = 1LL << 60;
const int MOD = 1000000007;
// const int MOD = 998244353;

// Template for ModInt
template <typename T> T pow(T a, long long n, T e = 1) {
    T ret = e;
    while (n) {if (n & 1) ret *= a; a *= a; n >>= 1;}
    return ret;
}

template <int mod> struct ModInt {
    int x;
    ModInt() : x(0) {}
    ModInt(long long x_) {if ((x = x_ % mod + mod) >= mod) x -= mod;}
    ModInt& operator+=(ModInt rhs) {if ((x += rhs.x) >= mod) x -= mod; return *this;}
    ModInt& operator-=(ModInt rhs) {if ((x -= rhs.x) < 0) x += mod; return *this;}
    ModInt& operator*=(ModInt rhs) {x = (unsigned long long)x * rhs.x % mod; return *this;}
    ModInt& operator/=(ModInt rhs) {x = (unsigned long long)x * rhs.inv().x % mod; return *this;}
    ModInt operator-() const {return -x < 0 ? mod - x : -x;}
    ModInt operator+(ModInt rhs) const {return ModInt(*this) += rhs;}
    ModInt operator-(ModInt rhs) const {return ModInt(*this) -= rhs;}
    ModInt operator*(ModInt rhs) const {return ModInt(*this) *= rhs;}
    ModInt operator/(ModInt rhs) const {return ModInt(*this) /= rhs;}
    bool operator==(ModInt rhs) const {return x == rhs.x;}
    bool operator!=(ModInt rhs) const {return x != rhs.x;}
    ModInt inv() const {return pow(*this, mod - 2);}
    friend ostream& operator<<(ostream& s, ModInt<mod> a) {s << a.x; return s;}
    friend istream& operator>>(istream& s, ModInt<mod>& a) {s >> a.x; return s;}
};

using mint = ModInt<MOD>;

signed main() {

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

    mint ans = 1;
    int n; cin >> n;
    rep(i,n) ans *= i + 1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void debug(String str){
        boolean debug = false;
        if(debug != true){
            return;
        }
        System.out.println(str);
    }
    public static void main(String[] args) {

        int W;
        int H;
        int x;
        int y;

        try (Scanner sc = new Scanner(System.in)) {
            W = sc.nextInt();
            H = sc.nextInt();
            x = sc.nextInt();
            y = sc.nextInt();

        }
        BigDecimal bw =new BigDecimal(W);
        BigDecimal bh =new BigDecimal(H);
        BigDecimal bm = bw.multiply(bh).divide(new BigDecimal(2));
        long a = W * H;
        debug(a + ":");
        double f = bm.doubleValue();
        int j = 0;
        if(x*2 == W && y *2 == H){
            j = 1;
        }
        System.out.println(String.format("%.6f", f) + " "+j);
    }


}


Measured memory_bytes: 22484
#pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math")
#include <bits/stdc++.h>
using namespace std;
template<class t> inline t read(t &x){
	char c=getchar();bool f=0;x=0;
	while(!isdigit(c)) f|=c=='-',c=getchar();
	while(isdigit(c)) x=(x<<1)+(x<<3)+(c^48),c=getchar();
	if(f) x=-x;return x;
}
template<class t,class ...A> inline void read(t &x,A &...a){
	read(x);read(a...);
}
template<class t> inline void write(t x){
	if(x<0) putchar('-'),write(-x);
	else{if(x>9) write(x/10);putchar('0'+x%10);}
}

const int mod=1e9+7,N=1e5+5;
int ans,a[N],n,f[N],inv[N];

signed main(){
	read(n);n--;
	for(int i=1;i<=n+1;i++) read(a[i]),a[i-1]=a[i]-a[i-1];
	inv[1]=1;for(int i=2;i<=n;i++) inv[i]=1ll*(mod-mod/i)*inv[mod%i]%mod;
	for(int i=1;i<=n;i++) f[i]=(f[i-1]+inv[i])%mod;
	for(int i=1;i<=n;i++) ans=(1ll*f[i]*a[i]+ans)%mod;
	for(int i=1;i<=n;i++) ans=1ll*ans*i%mod;
	write(ans);
}

Measured memory_bytes: 4732
#template
from collections import Counter
def inputlist(): return [int(k) for k in input().split()]
#template
N,K = inputlist()
if K == 0:
    print(N**2)
    exit()
ans = 0
for i in range(K+1,N+1):
    indexa = i-K
    sub = N-i+1
    ans += indexa
    if sub // i != 0:
        ans += (sub//i)*indexa

    mod = sub % i
    ans += max(0,mod-K)

print(ans)

Measured memory_bytes: 3316
// #pragma GCC target ("avx2")
// #pragma GCC optimization ("O3")
// #pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long int
#define ll int
#define bits_count __builtin_popcountll
#define endl '\n'
#define double long double
#define ld double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
#define sz(x) (ll)x.size()
#define pr pair<int,int>
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }

// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const int MAXN = 55;
int X[MAXN],Y[MAXN];

double dist(double x1,double y1,double x2,double y2){
    return sqrt((x1-x2)*(x1-x2) + (y1-y2)*(y1-y2));
}

double max_dist(double x,double y,int n){
    double ans = 0;
    FOR(i,1,n) ans = max(ans,dist(x,y,X[i],Y[i]));
    return ans;
}

double func(double x,int n){
    double s = 0,e = 1000,ans;

    FOR(i,1,1000){
        double mid1 = s + (e-s)/3;
        double mid2 = e - (e-s)/3;

        double f1 = max_dist(x,mid1,n);
        double f2 = max_dist(x,mid2,n);

        if(f1 < f2) e = mid2,ans = f1;
        else s = mid1,ans = f2;
    }

    return ans;
}

void solve(){

    int n; cin>>n;
    FOR(i,1,n) cin>>X[i]>>Y[i];

    double s = 0,e = 1000,ans;

    FOR(i,1,1000){
        double mid1 = s + (e-s)/3;
        double mid2 = e - (e-s)/3;

        double f1 = func(mid1,n);
        double f2 = func(mid2,n);

        if(f1 < f2) e = mid2,ans = f1;
        else s = mid1,ans = f2;
    }

    cout<<fixed<<setprecision(10)<<ans<<endl;

}

signed main(){

   FastRead;    

    int t = 1; 
    // cin>>t; 
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

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

using namespace std;

typedef long long ll;

#define faster ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0)
#define read freopen("in.txt","r",stdin)
#define write freopen("out.txt","w",stdout)
#define mem(x,n) memset(x,n,sizeof(x))
#define all(x) x.begin(), x.end()
#define endl "\n"

int main()
{
	faster;
	
	string s;
	cin >> s;

	int cnt = 0,currCnt= 0;

	for(int i= 0; i < s.size(); i++){
		if(s[i] == 'S' || i == s.size()-1){
			if(s[i] == 'R') currCnt++;
			cnt = max(currCnt,cnt);
			currCnt = 0;
		}else {
			currCnt++;
		}
	}

	cout << cnt << endl;

	return 0;
}

Measured memory_bytes: 3636
#define debug_interval ','
#define dump_interval ' '
#define debug_toggle 1

//{
#pragma GCC optimize ("O3","unroll-loops")
#pragma GCC target ("avx")
#include<bits/stdc++.h>
using namespace std;
#define hi cerr<<"hi"<<endl;
#define int long long
#define INT_MAX LLONG_MAX
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define fi first
#define se second
#define mp make_pair
#define rev reverse
#define dans dump(ans)
#define MOD 1000000007
#define amp(v,n) (v).count(n)?v[n]++:v[n]=1
#define sysp system("pause")
#define PI acos(-1)
#define ins insert
#define aer(v) (v).erase((v).begin(),(v).end()) 

//{
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...A> inline void dump(){cout<<endl;}
template<class...A> inline void dump_rest() {cout<<endl;}
template<class T, class...A> inline void dump_rest(const T& first, const A&... rest){cout<<dump_interval<<first;dump_rest(rest...);}
template<class T,class...A> inline void dump(const T&first,const A&...rest){cout<<first;dump_rest(rest...);}
template<class...A> inline void debug(){cerr<<endl;}
template<class...A> inline void debug_rest() {cerr<<endl;}
template<class T, class...A> inline void debug_rest(const T& first, const A&... rest){cerr<<debug_interval<<first;debug_rest(rest...);}
template<class T,class...A> inline void debug(const T&first,const A&...rest){if(debug_toggle)cerr<<first,debug_rest(rest...);}
//}

typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}
template<int m>class mint{private:int i;public:mint() : i(0){}mint(int i): i((i%m+m)%m){}mint operator+(const mint& o){return o.i+i;}mint operator*(const mint& o){return o.i*i;}mint operator-(){return -i;}operator int() {return i;}};

//}

int n,m,k;
string s;
vector<pint> v;

main(){
	int ans=0;
	cin>>n;
	int h[n];
	rep(i,n)cin>>h[i];
	while(true){
		aer(v);
		//hi;
		rep(i,n){
			int ite=i+1;
			if(h[i]<=0)continue;
			else if(v.empty()==1||v.back().se+1!=ite)v.pb({i,ite});
			else v.back().se++;
		}
		if(v.empty()==1)break;
		for(auto x:v){
			for(int i=x.fi;i<x.se;i++){
				h[i]--;
			}
			ans++;
		}
	}
	dans;
}


Measured memory_bytes: 256