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

#define ll long long
#define pb push_back
#define eb emplace_back
//#define st first
#define sc second

using namespace std;

const ll mod = 1e9 + 7;
const int e = 1e5 + 69;
const int base = 311;

// dung inverse module de tinh nCk
// beginer 78
// mbeginer
// cach tao hoan vi tu n so : n*(n+1)/2;

//vector<pair<ll,ll>>adj[e];
vector<ll>adj[e];

/*ll Pow(ll n, ll dem)
{
    if(dem == 0) return 1;
    if(dem == 1) return n ;
    ll t = Pow(n, dem/2);
    if(dem % 2 == 0) return (t*t);
    else return ((t * t) * n);
}*/

/*ll C(ll k, ll n)
{
    if(k == 0) return 1;
    if(n < k) return 0;
    return (gt[n]%mod * (igt[k]%mod * igt[n-k]%mod)%mod)%mod;
}*/

int n, m, k;
ll h[e];

int main()
{
    cin >> n >> m;
    for(int i=1; i<=n; i++)
    {
        cin >> h[i];
    }
    map<ll,ll>kt;
    for(int i=1; i<=m; i++)
    {
        ll u, v;
        cin >> u >> v;
        //adj[u].pb(v);
        //adj[v].pb(u);
        if(h[u] >= h[v]) kt[v] ++;
        if(h[v] >= h[u]) kt[u] ++;
    }
    ll dem = 0;
    for(int i=1; i<=n; i++)
    {
        if(kt[i] == 0) dem ++;
    }
    cout << dem;
}
/*

*/


Measured memory_bytes: 13020
#include <iostream>
#include <string.h>
#include <algorithm>
typedef long long ll;
using namespace std;

int main()
{
  int n,a,i,count=1,ans=0;
  cin >> n;

  for(i=0;i<n;i++){
      cin >> a;
      if(a==count){
        count++;
      }else{
        ans++;
      }
  }
  if(count > 1){
    cout << ans;
  }else{
    cout << -1;
  }
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
ans = 0
mod = 998244353

fact = [0] * 200001
invfact = [0] * 200001
fact[0] = 1
invfact[0] = 1

for i in range(1, 200001):
    fact[i] = fact[i-1] * i % mod
    
invfact[-1] = pow(fact[-1], mod-2, mod)

for i in reversed(range(1, 200000)):
    invfact[i] = invfact[i+1] * (i+1) % mod

for k in range(K+1):
    ans += invfact[N-1-k] * invfact[k] *pow((M-1),N-1-k, mod) % mod
    ans %= mod

ans = ans * M * fact[N-1] % mod

print(ans)




Measured memory_bytes: 24656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(int i = a; i < b; i++)
#define endl "\n"
const int mod = 1e9+7;
#define sync ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int power(int a,int b){ int res=1; a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
int gcd(int a,int b) { return b?gcd(b,a%b):a;}

int main()
{	
	sync
	int n, k;
	cin >> n >> k;
	ll a[n], dp[n];
	for(int i = 0; i < n; i++)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1]-a[0]);
	for(int i = 2; i < n; i++)
	{	
		dp[i] = abs(a[i] - a[i-1]) + dp[i-1];
		for(int j = 2; j <= k; j++)
		{	
			if(i-j >= 0)
				dp[i] = min(abs(a[i]-a[i-j]) + dp[i-j], dp[i]);
		}	
	}
	cout << dp[n-1];
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>
#include<map>

using namespace std;

typedef long long ll;

typedef std::pair<int, int> ipair;
bool lessPair(const ipair& l, const ipair& r){return l.second < r.second;}
bool morePair(const ipair& l, const ipair& r){return l.second > r.second;}

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

const ll MOD = 1e9 + 7;
void add(long long &a, long long b) { a += b; if (a >= MOD) a -= MOD; }

int main() {
   int N;
   cin >> N;
   int l = N % 2;

   int M = 0;
   if (l == 0) {
      M = N * (N - 2) / 2;
      cout << M << endl;
      for (int i = 1; i <= N; i++) {
         for (int j = i + 1; j <= N; j++) {
            if (i + j == N + 1) continue;
            cout << i << " " << j << endl;
         }
      }
   } else {
      M =  (N - 1) * (N - 1) / 2;
      cout << M << endl;
      for (int i = 1; i <= N; i++) {
         for (int j = i + 1; j <= N; j++) {
            if (i + j == N) continue;
            cout << i << " " << j << endl;
         }
      }
   }
   return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdint>

int main() {
    int64_t N;
    scanf("%lld", &N);

    int64_t res=1;
    int64_t mod=1e9+7;
    for (int64_t i=1; i<=N; ++i)
        (res *= i) %= mod;

    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define endl "\n"
#define se second
#define ll long long
//priority_queue<int, vector<int>, greater<int> > pq;
#define _CRT_SECURE_NO_DEPRECATE
const int N = 300030;
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
const ll mod =  1e9+7;
ll n,k;
ll dp[N],arr[N];
int main()
{
    ios::  sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin>>n>>k;
	rep(i,1,n+1)
	cin>>arr[i];
	rep(i,0,n+2)
	dp[i]=1e16;
	dp[1]=0;

	rep(i,2,n+1)
	{
		ll x=max(1ll,i-k);
		rep(j,x,i+1)
		{
			dp[i]=min(dp[i],dp[j]+abs(arr[j]-arr[i]));
		}
	}

	cout<<dp[n];
}






Measured memory_bytes: 3072
N = int(input())
H = list(map(int, input().split()))
rel = []
count = [0]
for i in range(N-1):
  if H[i] >= H[i+1]:
    rel.append(1)
    if rel[i-1] == 0:
      count.append(1)
    else:
      count[-1] += 1
  else:
    rel.append(0)
    
print(max(count))

Measured memory_bytes: 15020
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
V<ll> a;
  ll n,k;
bool C(ll m){
   ll cnt=0, ok,ng,mid;
   for(int i=0;i<n;i++){
      if(a[i]>=0){
         //積がm以下の最大indexの値
         ok=i;ng=n;
         while(ng-ok>1){
            mid=(ok+ng)/2;
            if(a[i]*a[mid]>m)ng=mid;
            else ok=mid;
         }
         cnt+=ok-i;
      }
      else{
         // 積がm以下の最小のindex
         ok=n,ng=i;
         while(ok-ng>1){
            mid=(ok+ng)/2;
            if(a[i]*a[mid]>m)ng=mid;
            else ok=mid; 
         }
         cnt+=n-ok;
      }
   }
   return cnt>=k;
}
int main(){
   cin>>n>>k;
   a.resize(n);
   for(int i=0;i<n;i++)cin>>a[i];
   sort(all(a));
   ll ok=inf,ng=-inf-5,mid;
  while(ok-ng>1){
     mid=(ok+ng)/2;
     if(C(mid))ok=mid;
     else ng=mid;
  }
  cout<<ok<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cctype>
#define len length()
#define sz size()
#define rng(i, a, b) for(int i = a; i < b; i++)
#define rep(i, n) rng(i, 0, n)
#define srt(v) sort(v.begin(), v.end())
#define rev(s) reverse(s.begin(), s.end())
#define vi(a, n) vector<int> a(n)
#define vs(a, n) vector<string> a(n)
#define vc(a, n) vector<char> a(n)
#define psb(a) push_back(a)
#define ppb pop_back()
#define erc(S, i) S.erase(S.begin() + i)
#define ers(S, i, j) S.erase(S.begin() + i, S.begin() + j)
#define sp(n) cout << setprecision(n) << fixed
#define fst(s) s.at(0)
#define lst(s) s.at(s.len - 1)
using namespace std;

int main(){
    int N;
    cin >> N;
    vi(a,N);
    rep(i,N) cin >> a[i];
    int ans=0;
    rep(i,N) if(i+1 == a[a[i]-1]) ans++;
    cout << ans / 2 << endl;
    return 0;
}

Measured memory_bytes: 640
#include <algorithm>
#include <iostream>

using namespace std;

int main() {
  string S;
  int N, ans = 0;
  cin >> N >> S;

  for (auto i = 0; i < 1000; i++) {
    int c[3] = {i/100, (i/10) % 10, i % 10};
    int f = 0;
    for (int j = 0; j < N; j++) {
      if (S[j] == ('0' + c[f])) f++;
      if (f == 3)
        break;
    }
    if (f == 3)
      ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,s,n) for(int i = s;i<n;i++)
#define repe(i,s,n) for(int i = s;i<=n;i++)
#define pb push_back
#define fi first
#define se second
typedef long long ll;
typedef pair<int,int>pint;
typedef vector<int>vint;
typedef vector<pint>vpint;
static const ll maxLL = (ll)1 << 62;
const ll MOD=1000000007,INF=1e18;
int dy[]={-1,0,1,0};
int dx[]={0,1,0,-1};

#define int ll
int n,X;
int x[100010],y[100010];
int gcd( int m, int n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	// ユークリッドの方法
	while( m != n )
	{
		if ( m > n ) m = m - n;
		else         n = n - m;
	}
	return m;
}//gcd
signed main(){
    cin>>n>>X;
    rep(i,0,n){
        cin>>x[i];
    }
    x[n]=X;
    sort(x,x+(n+1));
    rep(i,0,n){
        y[i]=x[i+1]-x[i];
        if(i!=0)y[i]=gcd(y[i],y[i-1]);
    }
    cout<<y[n-1]<<endl;
    return 0;
}

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

using ll = long long;

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

    ll n,a,b;cin>>n>>a>>b;

    ll ans=(n/(a+b))*a;
    n%=a+b;

    ans+=min(n,a);

    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3632
tri, acute, right, dull = 0, 0, 0, 0
while True:
    a,b,c = map(int, input().split())
    if a+b<=c or abs(a-b)>=c:
        print(tri, right, acute, dull)
        exit()
    else:
        tri += 1
        M = max(a,b,c)
        if M**2 < (a**2+b**2+c**2 -M**2):
            acute += 1
        if M**2 == (a**2+b**2+c**2 -M**2):
            right += 1
        if M**2 > (a**2+b**2+c**2 -M**2):
            dull += 1

        



Measured memory_bytes: 5604
def zeroTrim(s):
    while s[0] == '0':
        if len(s) == 1:
            break
        s = s[1:]
    return s

N = input()
K = int(input())

def calc(N, K):
    digit = len(N)
    res = 0

    if K == 1:
        if digit > 1:
            res += (digit - 1) * 9
        res += int(N[0])
    elif K == 2:
        if digit <= 1:
            return 0
        if digit > 2:
            res += 9 * 9 * (digit - 1) * (digit - 2) // 2
        for i in range(int(N[0])-1):
            res += calc('9'*(digit-1), 1)
        res += calc(zeroTrim(N[1:]), 1)
    else:
        if digit <= 2:
            return 0
        if digit > 3:
            res += 9 * 9 * 9 * (digit - 1) * (digit - 2) * (digit - 3) // 6
        
        for i in range(int(N[0])-1):
            res += calc('9'*(digit-1), 2)
        res += calc(zeroTrim(N[1:]), 2)
    return res

print(calc(N, K))

Measured memory_bytes: 9224
#include"bits/stdc++.h"
using namespace std;

#define REP(i,N) for(int i=0;i<(N);i++)
#define FOR(i,M,N) for(int i=M;i<(N);i++)
#define unko int

const int INF = 1 << 17;

int A[11][11];
int getmin(int x,int y,int X,int Y) {
	int mn = INF;
	FOR(i, x, X + 1) {
		mn = min(mn, A[i][y]);
		mn = min(mn, A[i][Y]);
	}
	FOR(j, y, Y + 1) {
		mn = min(mn, A[x][j]);
		mn = min(mn, A[X][j]);
	}
	return mn;
}
int getmax(int x, int y, int X, int Y) {
	int mx = -INF;
	FOR(i, x + 1, X) {
		FOR(j, y + 1, Y) {
			mx = max(mx, A[i][j]);
		}
	}
	return mx;
}
int calc(int x, int y, int X, int Y, int mn) {
	int res = 0;
	FOR(i, x + 1, X) {
		FOR(j, y + 1, Y) {
			if (A[i][j] >= mn)return 0;
			res += mn - A[i][j];
		}
	}
	return res;
}
int H, W;

void solve() {
	int ans = 0;
	REP(i, H - 2) {
		REP(j, W - 2) {
			FOR(k, i + 2, H) {
				FOR(l,j + 2, W) {
					int mn = getmin(i, j, k, l);
					int mx = getmax(i, j, k, l);
					if (mn > mx) {
						int res = calc(i, j, k, l, mn);
						ans = max(ans, res);
					}
				}
			}
		}
	}
	cout << ans << endl;
}

unko main() {
	while (true) {
		 cin >> H >> W;
		if (H == 0 && W == 0) {
			return 0;
		}
		REP(i, 10) {
			REP(j, 10)A[i][j] = 0;
		}
		REP(i, H) {
			REP(j, W) {
				cin >> A[i][j];
			}
		}
		solve();
	}
}


Measured memory_bytes: 3072
list=[]

try:
    while True:
        list.append(input())
except EOFError:
    pass

for i in range(len(list)):
    list[i]=list[i].lower()
w=''.join(list)

for c in 'abcdefghijklmnopqrstuvwxyz':
    print(c,':',w.count(c))
    




Measured memory_bytes: 5564
N = int(input())
 
tmp = int(input())
rlt = tmp//2
tmp -= 2*(tmp//2)

for i in range(1,N):
  a = int(input())
  if a == 0:
    tmp = 0
  elif tmp == 1:
    rlt += 1
    a -= 1
  tmp = a
  rlt += tmp//2
  tmp -= 2*(tmp//2)
  
print(rlt)

Measured memory_bytes: 74672
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<tuple>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define Per(i,sta,n) for(int i=n-1;i>=sta;i--)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

string n;
int m;
ll dp[1000010][2][2];

ll rec(int i,int flagX,int flagY){
    if(i==-1) return 0;
    if(dp[i][flagX][flagY]!=-1) return dp[i][flagX][flagY];
    
    ll res=INF;
    int s=n[m-i-1]-'0';
    if(flagY){
        res=min(rec(i-1,flagX,1)+s,rec(i-1,1,0)+s+2);
    }
    else{
        if(9-s<=s){
            res=rec(i-1,1,0)+9-s;
        }
        else{
            res=min(rec(i-1,flagX,1)+s,rec(i-1,1,0)+min(s+2,9-s));
        }
    }
    dp[i][flagX][flagY]=res;
    return res;
}

void solve(){
    cin >> n;
    n="0"+n;
    m=n.length();
    rep(i,m+1){
        rep(flagX,2){
            rep(flagY,2){
                dp[i][flagX][flagY]=-1;
            }
        }
    }
    cout << rec(m-1,0,1) << endl;
    rep(i,m+1){
        rep(flagX,2){
            rep(flagY,2){
                //cout << i << " " << flagX << " " << flagY << " " <<dp[i][flagX][flagY] << endl;
            }
        }
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << fixed << setprecision(50);
    solve();
}

Measured memory_bytes: 110792
#include<iostream>
using namespace std;
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
	int n, p=1, x;
	cin >> n;
	while(p<n)
	    p*=2;
	int tree[2*p+1];
	for(int i = 0; i < p; i++)
	{
	    if(i < n)
	        cin >> tree[i+p];
	    else
	        tree[i+p]={0};
	}
	for(int i = p-1; i > 0; i--)
	    tree[i]=max(tree[i*2], tree[i*2+1]);
	for(int i = 0; i < n; i++)
	{
	    x = tree[i+p];
	    tree[i+p]=0;
	    int b=(i+p)/2;
	    while(b > 0)
	    {
	        tree[b]=max(tree[b*2], tree[b*2+1]);
	        b/=2;
	    }
	    cout << tree[1] << '\n';
	    tree[i+p]=x;
	    b=(i+p)/2;
	    while(b > 0)
	    {
	        tree[b]=max(tree[b*2], tree[b*2+1]);
	        b/=2;
	    }
	}
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
using namespace std;
#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++)
typedef long long ll;

int main() {
    int N; cin >> N;
    vector<int> cnt(9);
    int a;

    for (int i = 0; i < N; i++){
        cin >> a;
        if (a >= 3200){
            cnt[8] = cnt[8] + 1;
        }
        else {
            for (int j = 0; j < 9; j++){
                if (400 * (j+1) > a){
                    cnt[j] = cnt[j] + 1;
                    break;
                }
            }
        }
    }
    int c = 0;
    for (int i = 0; i < 8; i++) {
        if (cnt[i]) {
            c++;
        }
    }

    cout << max(1, c) << " " << c + cnt[8] << endl;
    
}


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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef double dd;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<pair<int, int>> vpii;
typedef pair<int, int> pii;
typedef vector<pair<ll, ll>> vpll;
typedef pair<ll, ll> pll;

#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define all(c) (c).begin(), (c).end()
#define MOD 1000000007

int n;
vvi g;
vi d;
vi used;
vi path;
vi col;

void dfs(){
    int s = 0;
    d[s] = 0;
    stack<int> st;
    st.push(s);
    while(!st.empty()){
        int v = st.top();
        used[v] = 1;
        st.pop();
        int sz = g[v].size();
        for(int i = 0; i < sz; i++){
            if(d[g[v][i]] > d[v] + 1)
                d[g[v][i]] = d[v] + 1;
            if(!used[g[v][i]])
                st.push(g[v][i]);
        }
    }
}

void findpath(){
    int v = n - 1;
    int go, sz, ans = INT_MAX;
    path.pb(n);
    while(v != 0){
        sz = g[v].size();
        ans = INT_MAX;
        for(int i = 0; i < sz; i++)
            if(d[g[v][i]] < ans){
                ans = d[g[v][i]];
                go = g[v][i];
            }
        path.pb(go + 1);
        v = go;
    }
    return;
}

int dfs2(int v, int cnt){
    stack<int> s;
    s.push(v);
    while(!s.empty()){
        v = s.top();
        col[v] = 1;
        cnt++;
        s.pop();
        int sz = g[v].size();
        for(int i = 0; i < sz; i++)
            if(col[g[v][i]] != 1)
                s.push(g[v][i]);
    }
    return cnt;
}

int main(){
#ifdef HOME
    freopen("kek.in", "r", stdin);
    freopen("kek.out", "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n;
    int f, s;
    g.resize(n);
    d.resize(n, INT_MAX);
    used.resize(n, false);
    col.resize(n, 0);
    for(int i = 1; i < n; i++){
        cin >> f >> s;
        g[f - 1].pb(s - 1);
        g[s - 1].pb(f - 1);
    }
    dfs();
    findpath();
    reverse(all(path));
    int b, w;
    if(path.size() % 2 == 0){
        b = path[path.size()/2 - 1] - 1;
        w = path[path.size()/2] - 1;
    }
    else{
        b = path[path.size()/2] - 1;
        w = path[path.size()/2 + 1] - 1;
    }
    col[b] = 1;
    col[w] = 1;
    int cnt = 0, ansb, answ;
   /* for(auto a : path)
        cout << a << " ";
    cout << endl;
    cout << b << " " << w << endl;*/
    ansb = dfs2(b, cnt);
    cnt = 0;
    answ = dfs2(w, cnt);
  //  cout << ansb <<  " " << answ;
    if(ansb > answ)
        cout << "Fennec";
    else
        cout << "Snuke";
    return 0;
}

Measured memory_bytes: 7548
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
using namespace std;
#define ll  long long
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define pii pair<ll,ll>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define rep(i,t,n) for(int i=t;i<n;i++)
#define nd "\n"
using namespace __gnu_pbds;

#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>




/*ll power(ll x,ll t){
if(t<=0){
    return 1;
}
ll y=(power(x,t/2));
y=(y*y)%ma;
if(t%2)
    y=(y*x)%ma;
return y;

}*/
/*ll ph[100001];
void E_phi(int n){

ph[0]=0;
ph[1]=1;
for(int i=2;i<=n;i++){
    ph[i]=i;
}
for(int i=2;i<=n;i++){
    if(ph[i]==i){
        for(int j=i;j<=n;j+=){
            ph[j]-=ph[j]/i;
        }
    }
}


}*/
/*string s,t;
vector<int>  z_fun(string s){

int n = (int) s.length();
    vector<int> z(n);
    for (int i = 1, l = 0, r = 0; i < n; ++i) {
        if (i <= r)
            z[i] = min (r - i + 1, z[i - l]);
        while (i + z[i] < n && s[z[i]] == s[i + z[i]])
            ++z[i];
        if (i + z[i] - 1 > r)
            l = i, r = i + z[i] - 1;
    }
    return z;
}*/

/*struct st{
ll sum,pre,suf,ans;
st(){}
st(ll k){
ans=k,pre=k,suf=k,sum=0;
}

};
ll t[4*200001+4];
ll a[200001];
ll lazy[4*200001+4];
ll mx=1e14;



void push(int ind){
int l=2*ind+1,r=2*ind+2;
t[l]+=lazy[ind];
t[r]+=lazy[ind];
lazy[l]+=lazy[ind];
lazy[r]+=lazy[ind];
lazy[ind]=0;

}

void build(int ind,int l,int r){
if(l==r){
    t[ind]=a[l];
return;
}
int mid=(l+r)/2;
build(2*ind+1,l,mid);
build(2*ind+2,mid+1,r);

  t[ind] =min(t[ind*2+1] , t[ind*2+2]);



}
ll query(int ind,int l,int r,int p,int q){

if(l>q || r<p )
    return mx;
    int mid=(l+r)/2;

if(l>=p && r<=q )
    {
      return t[ind];
    }
    push(ind);
ll x=query(2*ind+1,l,mid,p,q);
ll y=query(2*ind+2,mid+1,r,p,q);


return min(x,y);
}

void update(int ind,int l,int r,int p,int q,int val){
if(l>q || r<p )
    return;

if(l>=p && r<=q )
    {
      t[ind]+=val;
      lazy[ind]+=val;
      return;
    }
push(ind);
int mid=(l+r)/2;
    update(2*ind+1,l,mid,p,q,val);
     update(2*ind+2,mid+1,r,p,q,val);
    t[ind]=min(t[2*ind+1],t[2*ind+2]);



}


ll mod(ll a){
if(a>=0)
    return a;
else return -a;
}
*/
vector<set<int> > g;
vector<int> v;
int dfs(int n){
v[n]=1;
int x=1;
for(auto i:g[n])
{
    if(!v[i]){
        x+=dfs(i);
    }

}
return x;
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
int n,m;
cin>>n>>m;
g.resize(n+1);
v.resize(n+1);
rep(i,0,m){
int x,y;
cin>>x>>y;
g[x].insert(y);
g[y].insert(x);

}
int ans=0;

for(int i=1;i<=n;i++){
    if(!v[i]){
        ans=max(ans,dfs(i));
    }

}
cout<<ans<<endl;



    }



Measured memory_bytes: 38268
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	string s;
	cin>>s;
	unsigned int n,i,j,length=0; //HAGATAYA
	n = strlen(s.c_str());
    
    for(i=0;i<n;i++)
    {
    	if(s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')
    	{
    	  j=1;
          i++;

          while((s[i]=='A'||s[i]=='T'||s[i]=='G'||s[i]=='C')&&i<n)
          {
          	
          	i++;
          	j++;
          }

          length = max(length,j); 
    	}
    	
    }
    cout<<'\n'<<length;


}

Measured memory_bytes: 3596
<?php
error_reporting(0);
$stdin = file_get_contents('php://stdin');
$line = explode("\n",$stdin);
$fi = 0;
$cnt = 0;
$list = array();
$key = new stdclass();
foreach($line as $l) {
  if (strlen($l)==0) continue;
  if ($fi == 0) {
    $a = explode(" ",$l);
    $key->A = $a;
    $fi++;
    continue;
  }
  if ($fi > 0) {
    $a = explode(" ",$l);
    $key->X[] = $a;
  }
}
$s = 1;
for($i=0;$i<$key->A[0]-1;$i++) {
  $s += $s*($i+1);
  $s = $s % 1000000007;
}
printf("%ld\n",$s);


Measured memory_bytes: 3828
#include <cstdio>
#include <cstring>
#include <vector>
using namespace std;
#define pb push_back
vector<int> primes;
bool prime[10010];
void eratos()
{
	memset(prime,true,sizeof(prime));
	prime[0]=false;
	prime[1]=false;
	for(int i=2;i<=100;i++)
	{
		if(prime[i])
		{
			for(int j=i*2;j<=10000;j+=i)
			{
				prime[j]=false;
			}
		}
	}
	for(int i=2;i<=10000;i++)if(prime[i])primes.pb(i);
	return;
}
int cnt(int x)
{
	int s=0,t=0,sum=0;
	int ret=0;
	while(s<primes.size())
	{
		while(sum<x&&t<primes.size())
		{
			sum+=primes[t];
			t++;
		}
		if(sum==x)ret++;
		sum-=primes[s];
		s++;
	}
	return ret;
}
int main()
{
	eratos();
	while(1)
	{
		int n;
		scanf("%d",&n);
		if(n==0)break;
		printf("%d\n",cnt(n));
	}
	return 0;
}

Measured memory_bytes: 1080
import java.util.Scanner;

public class Main {

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

		 int a = s.nextInt();

		 int result = 1000 - a % 1000;

		 if(result == 1000) {
			 result = 0;
		 }

		 System.out.println(result);
	}

}

Measured memory_bytes: 27060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: String = read();
    let str_taishou :Vec<char>  = s.chars().collect();
    let r = delete(str_taishou);
    println!("{}", r);
}

fn delete(mut s: Vec<char>) -> usize{
    let mut i :usize = 0;
    let mut n: usize = 1;
    let start_length = s.len();
    while n < s.len() {
        if s[i] != s[n] {
            s.remove(i);
            s.remove(i);
            i = 0;
            n = 1;
        } else {
            i = i + 1;
            n = n + 1;
        }
    }
    start_length - s.len()
}



Measured memory_bytes: 4352
A,B,C,D=map(int,input().split())
def gcd(a, b):
    while b:
        a, b = b, a % b
    return a
def lcm(x, y):
    return (x * y) // gcd(x, y)
  
d=B//D-(A-1)//D
c=B//C-(A-1)//C
tmp=lcm(C,D)
cd=B//(tmp)-(A-1)//(tmp)
print(B-A+1-c-d+cd)

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

#define infi            5e9
#define infl            5e18
#define MX              100005
#define pi              2*acos(0.0)
#define ll              long long int
#define rr              read()
#define ff              first
#define ss              second
#define pb              push_back
#define pii             pair<int,int>
#define ms(a,b)         memset(a, b, sizeof(a))
#define loop(i,n)       for(register int i=0;i<n;i++)
#define pool(i,n)       for(register int i=n-1;i>=0;i--)
#define loop1(i,n)      for(register int i=1;i<=n;i++)
#define pool1(i,n)      for(register int i=n;i>0;i--)

using namespace std;

inline ll read(){char c=getchar();ll num,sign=1;for(;c<'0'||c>'9';c=getchar())if(c=='-')sign=-1;for(num=0;c>='0'&&c<='9';){c-='0';num=num*10+c;c=getchar();}return num*sign;}
inline ll pw(ll b, ll p){ll ans=1;while(p>0){if(p&1)ans*=b;p>>=1;b*=b;}return ans;}
// inline bool isPrime(ll n){if(n==1)return false;if(n==2)return true;if(!(n%2))return false;for(ll i=3;i<=sqrt(n);i+=2)if(!(n%i))return false;return true;}
// inline ll gcd(ll a, ll b){if(a==0)return b;return gcd(b%a,a);}

// //*************************************  Bitmask Opereations  **********************************//
// int Set(int N,int pos){return N=N | (1<<pos);}
// int reset(int N,int pos){return N= N & ~(1<<pos);}
// bool check(int N,int pos){return (bool)(N & (1<<pos));}
// //********************************************************************************************//


int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    //#ifdef rid.dle
    //freopen("in.txt", "r", stdin);//#endif
    
    int n=rr,x;
    set<int>S;

    loop(i,n){
        x=rr;
        S.insert(x);
    }

    int dif = n-S.size();

    if(dif%2)cout << S.size()-1 << endl;
    else cout << S.size() << endl;

    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>
#include <map>

using namespace std;

typedef long long ll;
const ll MOD = 1000000007;

template <typename T>
struct matrix{
    int n, m;
    vector<vector<T>> dat;
    matrix(int n_, int m_){
        n = n_; m = m_;
        for(int i = 0; i < n; i++){
            dat.push_back(vector<T>(m));
        }
    }
};

template <typename T>
bool prod(matrix<T> a, matrix<T> b, matrix<T> &ans){
    if(a.m != b.n) return false;
    for(int i = 0; i < a.n; i++){
        for(int j = 0; j < a.m; j++){
            ans.dat[i][j] = 0;
            for(int k = 0; k < b.m; k++){
                ans.dat[i][j] += a.dat[i][k]*b.dat[k][j];
                ans.dat[i][j] %= MOD;
            }
        }
    }
    return true;
}

template <typename T>
void copy_mat(matrix<T> a, matrix<T> &b){
    for(int i = 0; i < a.n; i++){
        for(int j = 0; j < a.m; j++){
            b.dat[i][j] = a.dat[i][j];
        }
    }
}

template <typename T>
void pow(matrix<T> a, ll n, matrix<T> &ans){
    matrix<T> buf(a.n, a.n);
    matrix<T> tmp(a.n, a.n);
    copy_mat(a, tmp);

    for(int i = 0; i < a.n; i++) {
        for(int j = 0; j < a.n; j++){
            ans.dat[i][j] = 0;
        }
        ans.dat[i][i] = 1;
    }
    
    for(int i = 0; i <= 60; i++){
        ll m = (ll)1 << i;
        if(m&n){
            prod(tmp, ans, buf);
            copy_mat(buf, ans);
        }
        prod(tmp, tmp, buf);
        copy_mat(buf, tmp);
    }
}

template <typename T>
void print_mat(matrix<T> a){
    for(int i = 0; i < a.n; i++){
        for(int j = 0; j < a.m; j++){
            cout << a.dat[i][j] << ' ';
        }
        cout << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int N;
    ll K;
    cin >> N >> K;
    matrix<ll> mat(N, N);
    matrix<ll> buf(N, N);
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            int a;
            cin >> a;
            mat.dat[i][j] = a;
        }
    }
    pow(mat, K, buf);
    //print_mat<ll>(buf);
    ll ans = 0;
    for(int i = 0; i < N; i++){
        for(int j = 0; j < N; j++){
            ans += buf.dat[i][j];
            ans %= MOD;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 384
#include <stdio.h>
signed main(){
 
long long kyori,hayasa,a,v,b,w,t;
 
scanf("%lld %lld",&a,&v);
scanf("%lld %lld",&b,&w);
scanf("%lld",&t);
 
if(a>=b){
    kyori=a-b;
    
}else{
    kyori=b-a;
}
 
hayasa=v-w;
  
  if(hayasa<=0){
  hayasa=0;
  }
 
if(kyori>hayasa*t){    
    printf("NO\n");   
}else{
    printf("YES\n");   
}
 
 return 0 ;
    
}

Measured memory_bytes: 1644
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>

// 内部変数 - テスト用
#ifdef D_TEST
	static int siRes;
	static FILE *szpFpT, *szpFpA;
#endif

// 実行メイン
int
fMain(
	int piTNo					// <I> テスト番号 1～
)
{
	int i;
	char lc1Buf[1024], lc1Out[1024];

	// テストファイルオープン
#ifdef D_TEST
	sprintf(lc1Buf, ".\\Test\\T%d.txt", piTNo);
	szpFpT = fopen(lc1Buf, "r");
	sprintf(lc1Buf, ".\\Test\\A%d.txt", piTNo);
	szpFpA = fopen(lc1Buf, "r");
	siRes = 0;
#endif

	// 回数取得
	int liCnt;
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
	fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
	sscanf(lc1Buf, "%d", &liCnt);

	// 現在票数
	long long llTCnt = 1;
	long long llACnt = 1;

	// 比を取得
	for (i = 0; i < liCnt; i++) {
		long long llTRate, llARate;
#ifdef D_TEST
		fgets(lc1Buf, sizeof(lc1Buf), szpFpT);
#else
		fgets(lc1Buf, sizeof(lc1Buf), stdin);
#endif
		sscanf(lc1Buf, "%lld%lld", &llTRate, &llARate);

		// 倍数
		long long llTRCnt = (llTCnt + llTRate - 1) / llTRate;
		long long llARCnt = (llACnt + llARate - 1) / llARate;
		long long llRCnt = 0;
		if (llTRCnt > llARCnt) {
			llRCnt = llTRCnt;
		}
		else {
			llRCnt = llARCnt;
		}

		// 票数更新
		llTCnt = llTRate * llRCnt;
		llACnt = llARate * llRCnt;
	}

	// 結果セット
	sprintf(lc1Out, "%lld\n", llTCnt + llACnt);

	// 結果表示
#ifdef D_TEST
	fgets(lc1Buf, sizeof(lc1Buf), szpFpA);
	if (strcmp(lc1Buf, lc1Out)) {
		siRes = -1;
	}
#else
	printf("%s", lc1Out);
#endif

	// テストファイルクローズ
#ifdef D_TEST
	fclose(szpFpT);
	fclose(szpFpA);
#endif

	// テスト結果
#ifdef D_TEST
	if (siRes == 0) {
		printf("OK %d\n", piTNo);
	}
	else {
		printf("NG %d\n", piTNo);
	}
#endif

	return 0;
}

int
main()
{

#ifdef D_TEST
	int i;
	for (i = D_TEST_SNO; i <= D_TEST_ENO; i++) {
		fMain(i);
	}
#else
	fMain(0);
#endif

	return 0;
}



Measured memory_bytes: 128
from math import gcd
k = int(input())
gcd_sum=[0]*201
ans = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        gcd_sum[i] += gcd(i,j)
for i in range(1,k+1):
    for j in range(1,k+1):
        g = gcd(i,j)
        ans += gcd_sum[g]
print(ans)

Measured memory_bytes: 64912
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i) 
const int N = 200005 ;
using namespace std ;

int n, L, T, a[N], b[N] ;
struct poi {
	int x, y ;
} c[N] ;


bool cmp(poi a, poi b) {
	return a.x < b.x ;
}

inline int hit(int x, int y) {
	if (b[x] > b[y]) swap(x, y) ;
	int tot = 0 ; double res = T - 0.1 ;
	if ((double) ((a[y] - a[x] + L) % L) <= 2.0 * res) ++ tot, res -= 0.5 * ((a[y] - a[x] + L) % L) ;
	tot += (int) (res / (0.5 * L)) ;
	return tot ;
}

void solve() {
	int u = 1, times = 0, pos = 0, x = b[u] == 1 ? (a[u] + T) % L : ((a[u] - T) % L + L) % L, posx, posy ; 
	if (b[u] & 1) {
		rep(i, 1, n) if (c[i].x == x) {
			pos = i ;
			break ;
		}
	} else {
		rep(i, 1, n) if (c[i].x == x) pos = i ;
	}
	rep(i, 1, n) if (b[i] != b[u]) times += hit(i, u), times %= n ;
	if (b[u] & 1) pos -= times, pos = (pos % n + n) % n ; else
		pos = (pos + times) % n ;
	if (!pos) pos = n ; posx = pos ;
//	printf("x_val: %d\n", x) ;
	u = 2, times = 0, pos = 0, x = b[u] == 1 ? (a[u] + T) % L : ((a[u] - T) % L + L) % L ;
	if (b[u] & 1) {
		rep(i, 1, n) if (c[i].x == x) {
			pos = i ;
			break ;
		}
	} else {
		rep(i, 1, n) if (c[i].x == x) pos = i ;
	}
	rep(i, 1, n) if (b[i] != b[u]) times += hit(i, u), times %= n ;
	if (b[u] & 1) pos -= times, pos = (pos % n + n) % n ; else
		pos = (pos + times) % n ;
	if (!pos) pos = n ; posy = pos ;  
	if (c[posx].x != c[posy].x) {
		rep(i, 1, n) if (c[i].x == c[posx].x) pos = i ;
	} else {
		rep(i, 1, n) if (c[i].x == c[posx].x) {
			pos = i ;
			break ;
		}
	}
	rep(i, pos, n) printf("%d\n", c[i].x) ;
	rep(i, 1, pos - 1) printf("%d\n", c[i].x) ;
}

int main() {
	scanf("%d%d%d", &n, &L, &T) ;
	rep(i, 1, n) {
		scanf("%d%d", &a[i], &b[i]) ;
		c[i].x = b[i] == 1 ? (a[i] + T) % L : ((a[i] - T) % L + L) % L ;
		c[i].y = i ;
	}
	sort(c + 1, c + n + 1, cmp) ;
	if (c[1].x == c[n].x) {
		rep(i, 1, n) printf("%d\n", c[i].x) ;
		return 0 ; 
	}
	solve() ;
	return 0 ; 
}

Measured memory_bytes: 2816
#include "bits/stdc++.h"
using namespace std;
#define MOD 1000000007
#define Nmax 200010
#define FOR(i,a,b) for(long long i=(a);i<(b);i++)
#define RFOR(i,a,b) for(long long i = (b-1);i>=a;i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ITR(itr,mp) for(auto itr = (mp).begin(); itr != (mp).end(); ++itr)
#define RITR(itr,mp) for(auto itr = (mp).rbegin(); itr != (mp).rend(); ++itr)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
typedef pair<ll,ll> P;
typedef vector<P> Graph;
 
int main() {
	int A,B;
	cin >> A >> B;
	cout << (A+B)%24 << endl;
	return 0;
}

Measured memory_bytes: 256
open Batteries
open Enum

let the_mod = 998244353
let ( *@ ) a b = a * b mod the_mod
let ( +@ ) a b = (a + b) mod the_mod
let rec mod_pow a n =
  if n <= 0 then 1
  else if n mod 2 = 1 then a *@ mod_pow a (n-1)
  else let h = mod_pow a (n/2) in h *@ h
let mod_inv a = mod_pow a (the_mod-2)

let n, a, b, k = Scanf.scanf "%d %d %d %d" (fun w x y z -> w, x, y, z)

let combs =
  let res = Array.make (n+1) 0 in
  res.(0) <- 1;
  for i = 1 to n do
    res.(i) <- res.(i-1) *@ (n+1-i) *@ mod_inv i
  done;
  res

let () =
  (0--n) |> Enum.fold (fun sum r ->
    let rest = k - a * r in
    if rest >= 0 && rest mod b = 0 && rest / b <= n then
      let c = combs.(r) *@ combs.(rest / b) in
      sum +@ c
    else
      sum) 0
  |> Printf.printf "%d\n"


Measured memory_bytes: 4736
N, M = gets.split.map(&:to_i)

e = Hash.new { |h, k| h[k] = [] }
while line = gets
  a, b = line.split.map(&:to_i)
  e[a] << b
  e[b] << a
end

q = [[1]]
times = 0
while c = q.pop
  (e[c[-1]] - c).each do |i|
    q << (c + [i])
  end
  times += 1 if c.sort == (1..N).to_a
end
p times

Measured memory_bytes: 1916
//============================================================================
//Everyone has a different way of thinking, so God Created us
//   Hope You Respect My Way..,Thank You ):
// Author      : Murad
// Name        : Codeforces.cpp & Atcoder.cpp
// Description : Problem name
//============================================================================
#include<bits/stdc++.h>
#include<unordered_map>
#include<unordered_set>
using namespace std;
#define pi 3.1415926536
#define forn(i,a,b)for(int i=a;i<b;i++)
#define LL long long
#define ULL unsigned long long
#define MP make_pair
#define ff first
#define ss second
#define endl '\n'
#define INF 1e9 + 1
#define _INF INT32_MIN
#define pq priority_queue
#define MM multimap
#define PB push_back
#define vii vector<int>
#define ipair pair<int,int>
#define lpair pair<LL,LL>
#define El3zba ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define modd 1000000007
#define sfll1(v) scanf("%I64d",&v);
#define sfll2(v1,v2) scanf("%I64d %I64d",&v1,&v2)
#define sfll3(v1,v2,v3) scanf("%I64d %I64d %I64d",&v1,&v2,&v3)
//std::transform(s1.begin(), s1.end(), s1.begin(),::tolower);
char alphz[27] = { 'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z' };
float Euclidean(LL x1, LL x2, LL y1, LL y2) {
	return sqrt(pow(x1 - x2, 2) + pow(y1 - y2, 2));
}
LL gcd(LL a,LL b) {
	return !b ? a : gcd(b, a % b);
}
LL LCM(LL a, LL b) {
	return (a*b) / gcd(a, b);
}
void PrimeFactor(LL n)
{
	while (n % 2 == 0) {
		//printf("%d ", 2);
//		aa.insert(2);
		n /= 2;
	}
	for (int i = 3; i <= sqrt(n); i += 2)
	{
		if (n%i == 0) {
			//printf("%d ", i);
			//aa.insert(i);
			n /= i;
		}
	}
	if (n > 2){
		//printf("%d ", n);
	//	aa.insert(n);
	};
}
bool is_square(LL x) {
	LL l = 0, r = x;
	while (l <= r) {
		LL mid = l + (r - l) / 2;
		if (mid*mid == x)return true;
		if (mid*mid > x)r = mid - 1;
		else l = mid + 1;
	}
	return false;
}
LL power(LL x, LL y)
{
	LL temp;
	if (y == 0)return 1;
	temp = power(x, y / 2);
	if (y % 2 == 0)
		return temp*temp;
	else return x*temp*temp;
}
bool is_Prime(int x) {
	if (x == 2)return 1;
	else if (x % 2 == 0 || x < 2)return 0;
	for (int i = 3; i*i <= x; i += 2)
		if (x%i == 0)return 0;
	return 1;
}
const int N = 105;
int main()
{
	El3zba;
	/***  بسم الله الرحمن الرحيم   ***/
	string s;
	LL k;
	cin >> s >> k;
	for (int i = 0; i < min(k, (LL)s.size()); i++)
	{
		if (s[i] != '1')
			return cout << s[i] << endl, 0;
	}
	cout << 1 << endl;
	return 0;
}

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

using namespace std;

const int64_t MOD = 1000000007;

int main() {
  int N;
  cin >> N;
  int64_t answer = 1;
  for (int i = 1; i <= N; i++) {
    answer *= i;
    answer %= MOD;
  }
  cout << answer << "\n";

  return 0;
}


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

using namespace std;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
    string s;
    cin >> s;
    if(s == "ABC")
        cout << "ARC";
    else
        cout <<"ABC";

}

Measured memory_bytes: 3636
N,M = map(int,input().split())
S = [input() for i in range(N)]

P = N*M+2
src, dst = N*M, N*M+1
es = [[] for i in range(P)] # [[to1,cap1,rev1], ...]
pos = []

def add_edge(fr,to,cap):
    pos.append((fr, len(es[fr])))
    es[fr].append([to,cap,len(es[to])])
    es[to].append([fr,0,len(es[fr])-1])

for i,row in enumerate(S):
    for j,c in enumerate(row):
        if c=='#': continue
        if (i+j)%2==0:
            add_edge(src, i*M+j, 1) #src -> even
        else:
            add_edge(i*M+j, dst, 1) #odd -> dst
#even -> odd
for i,row in enumerate(S):
    for j,c in enumerate(row):
        if c=='#' or (i+j)%2: continue
        v = i*M+j
        if i and S[i-1][j]=='.':
            add_edge(v, (i-1)*M+j, 1)
        if j and S[i][j-1]=='.':
            add_edge(v, i*M+j-1, 1)
        if i+1 < N and S[i+1][j]=='.':
            add_edge(v, (i+1)*M+j, 1)
        if j+1 < M and S[i][j+1]=='.':
            add_edge(v, i*M+j+1, 1)

INF = float('inf')
level = [0] * P
iters = [0] * P
from collections import deque
def dinic_max_flow(s,t):
    global iters

    def _bfs(s):
        global level
        level = [-1] * P
        level[s] = 0
        q = deque([s])
        while q:
            v = q.popleft()
            for to,cap,rev in es[v]:
                if cap > 0 and level[to] < 0:
                    level[to] = level[v] + 1
                    q.append(to)

    def _dfs(v,t,f):
        if v == t: return f
        for i in range(iters[v],len(es[v])):
            iters[v] += 1
            to,cap,rev = es[v][i]
            if es[v][i][1] > 0 and level[v] < level[to]:
                d = _dfs(to,t,min(f,es[v][i][1]))
                if d > 0:
                    es[v][i][1] -= d #cap
                    es[to][rev][1] += d
                    return d
        return 0

    flow = 0
    while True:
        _bfs(s)
        if level[t] < 0: return flow
        iters = [0] * P
        f = 0
        while True:
            f = _dfs(s,t,INF)
            if f <= 0: break
            flow += f

print(dinic_max_flow(src, dst))

ans = [list(row) for row in S]
for fr,i in pos:
    if fr==src: continue
    to,cap,rev = es[fr][i]
    if to==dst: continue
    flow = es[to][rev][1]
    if flow==0: continue
    i0,j0 = divmod(fr,M)
    i1,j1 = divmod(to,M)
    if i0 == i1+1:
        ans[i1][j1] = 'v'
        ans[i0][j0] = '^'
    elif j0 == j1+1:
        ans[i1][j1] = '>'
        ans[i0][j0] = '<'
    elif i0 == i1-1:
        ans[i0][j0] = 'v'
        ans[i1][j1] = '^'
    else:
        ans[i0][j0] = '>'
        ans[i1][j1] = '<'
for row in ans:
    print(''.join(row))

Measured memory_bytes: 20104
use std::cmp::Ordering;
use std::cmp::Ordering::*;
use std::cmp::PartialOrd;
use std::collections::BinaryHeap;
use std::io::{stdin, Read};

#[derive(PartialEq, Eq, Debug)]
struct Rev<T>(T);

impl<T: Ord> PartialOrd for Rev<T> {
    fn partial_cmp(&self, other: &Self) -> Option<Ordering> {
        Some(match self.0.cmp(&other.0) {
            Less => Greater,
            Equal => Equal,
            Greater => Less,
        })
    }
}

impl<T: Ord> Ord for Rev<T> {
    fn cmp(&self, other: &Self) -> Ordering {
        self.partial_cmp(other).unwrap()
    }
}

macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
}

macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, q: usize);
    let mut left = BinaryHeap::<i64>::new();
    let mut right = BinaryHeap::<Rev<i64>>::new();
    let mut c = 0;
    let mut ls = 0;
    let mut s = 0;
    let mut n = 0;
    for _ in 0..q {
        parse!(it, t: usize);
        if t == 1 {
            n += 1;
            parse!(it, a: i64, b: i64);
            c += b;
            s += a;
            match (left.peek(), right.peek()) {
                (None, None) => {
                    left.push(a);
                    ls += a
                }
                (_, Some(&Rev(r))) if a > r => right.push(Rev(a)),
                (_, Some(_)) => {
                    left.push(a);
                    ls += a
                }
                (Some(&l), _) if a <= l => {
                    left.push(a);
                    ls += a
                }
                (Some(_), _) => right.push(Rev(a)),
            }
            // balance
            while left.len() > right.len() + 1 {
                let l = left.pop().unwrap();
                ls -= l;
                right.push(Rev(l));
            }
            while left.len() < right.len() {
                let Rev(r) = right.pop().unwrap();
                ls += r;
                left.push(r);
            }
        } else {
            let &l = left.peek().unwrap();
            let ret = -(n - 2 * ((n + 1) / 2)) * l + s - 2 * ls + c;
            println!("{} {}", l, ret);
        }
    }
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 13560
#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,unsafe-math-optimizations")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,sse4.1,sse4.2,popcnt,abm,mmx,avx,tune=native")
#include "bits/stdc++.h"
#include <assert.h>
#include <immintrin.h>
#include <emmintrin.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define PB push_back
#define MP make_pair
const int MOD=1000000007;
#define endl "\n"
#define fst first
#define snd second
const int UNDEF = -1;
const int INF=1<<30;
template<typename T> inline bool chkmax(T &aa, T bb) { return aa < bb ? aa = bb, true : false; }
template<typename T> inline bool chkmin(T &aa, T bb) { return aa > bb ? aa = bb, true : false; }
typedef pair<ll,ll> pll;typedef vector<ll> vll;typedef pair<int,int> pii;typedef vector<int> vi;typedef vector<vi> vvi;
#ifdef ONLINE_JUDGE
#define assert(...) /* nothing */
#endif
#define DEBUG_CAT
#ifdef DEBUG_CAT
#define dbg(...)   printf( __VA_ARGS__ )
#else 
#define dbg(...)   /****nothing****/
#endif
//int rint();char rch();long long rlong();
const int mn=2002;
const int W=0,B=1;
int pre[2][2*mn][mn];
int f[mn][mn];
int id2pos[2][mn];
int n;

int main()
{
  ios_base::sync_with_stdio(false); cin.tie(0);
  scanf("%d\n",&n);
  for (int pos=0;pos<2*n;pos++) {
    char c; int id;
    scanf("%c %d\n",&c,&id); --id;
    //printf("%c %d\n",c,id);
    int t=(c=='B')?B:W;
    id2pos[t][id]=pos;
    for (int x=0;x<=pos;x++) {
      pre[t][x][id]=1;
    }
  }
  for (int t=0;t<2;t++) for (int x=0;x<=2*n;x++) {
    for (int id=1;id<=n;id++) {
      pre[t][x][id]+=pre[t][x][id-1];
    }
  }

  for (int w=0;w<=n;w++) for (int b=0;b<=n;b++) f[w][b]=INF;
  f[0][0]=0;
  for (int s=0;s<2*n;s++) {
    for (int w=0;w<=min(s,n);w++) {
      int b=s-w;
      if (0<=b&&b<=n) {
        int now=f[w][b];
        if (now==INF) continue;
        //printf("w:%d b:%d now:%d\n",w,b,now);
        if (b<n) {
          int pos=id2pos[B][b];
          int cand=now+pre[B][pos+1][b-1]+pre[W][pos+1][w-1];
          //int cand=now+tree[B]->GTE(0,b-1,pos+1)+tree[W]->GTE(0,w-1,pos+1);
          chkmin(f[w][b+1],cand);
        }
        if (w<n) {
          int pos=id2pos[W][w];
          int cand=now+pre[B][pos+1][b-1]+pre[W][pos+1][w-1];
          //int cand=now+tree[B]->GTE(0,b-1,pos+1)+tree[W]->GTE(0,w-1,pos+1);
          chkmin(f[w+1][b],cand);
        }
      }
    }
  }
  printf("%d\n",f[n][n]);
}



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

using namespace std;

long long eval(vector<pair<int,int> > &V){
    long long ans = 0;
    int poz = 0;
    for(auto it:V){
        if(it.first <= poz && it.second >= poz){
            continue;
        }
        if(it.first > poz){
            ans += it.first - poz;
            poz = it.first;
        }
        else{
            ans += poz - it.second;
            poz = it.second;
        }
    }
    ans += (poz < 0 ? -poz:poz);
    return ans;
}

int N;
pair<int,int> V[100005];

class Cmp1{
    public:
    bool operator () (int a,int b){
        return V[a].second > V[b].second;
    }
};

class Cmp2{
    public:
    bool operator () (int a,int b){
        return V[a].first < V[b].first;
    }
};

priority_queue<int,vector<int>,Cmp1> minRight;
priority_queue<int,vector<int>,Cmp2> maxLeft;

bool U[100005];

int main(){
    cin >> N;
    for(int i = 1;i <= N;i++){
        cin >> V[i].first >> V[i].second;
    }


    vector<pair<int,int> > ord;

    for(int i = 1;i <= N;i++){
        minRight.push(i);
        maxLeft.push(i);
        U[i] = 0;
    }

    for(int i = 1;i <= N;i++){
        if(i & 1){
            while(U[minRight.top()]){
                minRight.pop();
            }
            ord.push_back(V[minRight.top()]);
            U[minRight.top()] = 1;
        }
        else{
            while(U[maxLeft.top()]){
                maxLeft.pop();
            }
            ord.push_back(V[maxLeft.top()]);
            U[maxLeft.top()] = 1;
        }
    }

    long long rez = eval(ord);

    ord.clear();

    for(int i = 1;i <= N;i++){
        minRight.push(i);
        maxLeft.push(i);
        U[i] = 0;
    }

    for(int i = 1;i <= N;i++){
        if(!(i & 1)){
            while(U[minRight.top()]){
                minRight.pop();
            }
            ord.push_back(V[minRight.top()]);
            U[minRight.top()] = 1;
        }
        else{
            while(U[maxLeft.top()]){
                maxLeft.pop();
            }
            ord.push_back(V[maxLeft.top()]);
            U[maxLeft.top()] = 1;
        }
    }

    rez = max(rez,eval(ord));

    cout << rez;

    return 0;
}


Measured memory_bytes: 3692