akhauriyash/Code-Regression huggingface dataset:
import sys

sys.setrecursionlimit(10**7)
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int,sys.stdin.readline().rstrip().split())
def LI(): return list(map(int,sys.stdin.readline().rstrip().split()))  #空白あり
def LI2(): return list(map(int,sys.stdin.readline().rstrip()))  #空白なし
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())  #空白あり
def LS2(): return list(sys.stdin.readline().rstrip())  #空白なし

N,D = MI()
ans = 0
for i in range(N):
    x,y = MI()
    if x**2+y**2 <= D**2:
        ans += 1
print(ans)

Measured memory_bytes: 68620
import sys
sys.setrecursionlimit(10000000)
import math
import bisect
from collections import deque
def input():
    return sys.stdin.readline()[:-1]

n,m,k = map(int,input().split())
a = list(map(int,input().split()))
b = list(map(int,input().split()))
sa = [0]
sb = [0]
for i in range(n):
    sa.append(sa[-1]+a[i])
for i in range(m):
    sb.append(sb[-1]+b[i])
anst = 0
ans = 0
#print(sa)
#print(sb)
for i in range(n+1):
    tmp = k
    tmp-=sa[i]
    if tmp<0:
        continue
    iti = bisect.bisect_right(sb,tmp)
    #print(tmp,i,iti)
    anst = i+iti-1
    ans = max(ans,anst)

print(ans)


Measured memory_bytes: 131312
x, y, a, b, c = map(int, input().split())
p = list(map(int, input().split()))
q = list(map(int, input().split()))
r = list(map(int, input().split()))
p.sort()
q.sort()
r.sort()
p = p[::-1]
q = q[::-1]
r = r[::-1]

ir = 0
ig = 0

red = 0
for i in range(x):
    red += p[i]
    ir = i
green = 0
for i in range(y):
    green += q[i]
    ig = i

ino = 0
while (0 <= ir or 0 <= ig) and ino < c:
    iir = ir
    iig = ig
    iino = ino

    if ig < 0:
        if p[ir] < r[ino]:
            red -= p[ir]
            red += r[ino]
            ino += 1
            ir -= 1
    elif ir < 0:
        if q[ig] < r[ino]:
            green -= q[ig]
            green += r[ino]
            ino += 1
            ig -= 1
    elif p[ir] < q[ig]:
        if p[ir] < r[ino]:
            red -= p[ir]
            red += r[ino]
            ino += 1
            ir -= 1
    else:
        if q[ig] < r[ino]:
            green -= q[ig]
            green += r[ino]
            ino += 1
            ig -= 1

    if iir == ir and iig == ig and iino == ino:
        break

print(green + red)


Measured memory_bytes: 106980
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

typedef pair<long,long> P;

void bfs(queue<P>& q, vector<vector<int>>&to, vector<vector<int>>& ans) {
  while( !q.empty()) {
    P p = q.front();
    int u = p.first;
    int c = p.second;
    q.pop();

    for (auto v : to[u]) {
      if(ans[c%3][v]!=-1) continue;
      // cout << u << "->" << v << endl;
      ans[c%3][v] = c;
      q.push(P(v,c+1));
    }
  }
}

int main() {
  long n,m;
  long s,t;
  cin >> n >> m;
  vector<vector<int>> to(n+1);
  vector<vector<int>> ans(3, vector<int>(n+1, -1));

  for (long i=0; i<m; i++) {
    int u,v;
    cin >> u >> v;
    to[u].push_back(v);
  }

  cin >> s >> t;

  queue<P> q;
  q.push(P(s,1));

  bfs(q,to,ans);

  if(ans[0][t] >= 0) ans[0][t]/=3;

  cout << ans[0][t] << endl;
}


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

using namespace std;
typedef long long ll;
typedef long  double lb;
int mod=1e9+7;
const int N=1e5+5;

int main()
{
    int a,b,c;
    cin>>a>>b>>c;
    swap(a,b);
    swap(a,c);
    cout<<a<<" "<<b<<" "<<c;
    return 0;
}


Measured memory_bytes: 256
/**
 *    author:  tourist
 *    created: 02.06.2019 15:52:21       
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin >> s;
  char last = 'A';
  int cc = 0;
  long long ans = 0;
  for (char c : string(s.rbegin(), s.rend())) {
    if (c == 'A') {
      int mv = 0;
      if (last == 'B') {
        mv = cc / 2;
      }
      ans += mv;
      cc = 2 * mv;
    } else {
      if (c != last) {
        last = c;
        ++cc;
      } else {
        cc = 1;
      }
    }
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 788
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 30;
const int MOD = 1e9 + 7;

int main() {
  int n, k;
  cin >> n >> k;
  int64 cur = 1;
  while (n--) {
    cur = min(cur + k, cur * 2);
  }
  cout << cur << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main() {
    long long x;
    cin>>x;
    if(x%2!=0)
        cout<<0;
    else{
        long long n=10,l=0;
        while(n<=x){
            l+=x/n;
            n*=5;
        }
        cout<<l;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
double l;
int main() {
    DAU
    cin >> l;
    l /= 3.0;
    l = l * l * l;
    cout << fixed << setprecision(10) << l;
    PLEC
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define rep(i,n) for(int i=0;i<n;i++)

int main() {
	int N;
  	cin>>N;
  	cout<<N*(N+1)/2<<endl;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#define debug(x) cout << #x " => " << (x) << endl
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
#endif
using lint = long long;
constexpr int MOD = (int)1e9 + 7;
constexpr double EPS = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

vector<int> eratosthenes(int minimum, int maximum) {
  vector<bool> is_prime(maximum + 1, true);
  vector<int>  prime_num;
  is_prime[0] = is_prime[1] = false;
  for (int i = 2; i <= maximum; ++i) {
    if (is_prime[i]) {
      prime_num.push_back(i);
      for (int check = i * 2; check <= maximum; check += i) is_prime[check] = false;
    }
  }
  prime_num.erase(prime_num.begin(), lower_bound(prime_num.begin(), prime_num.end(), minimum));
  return prime_num;
}

int main(void) {
  int x;
  cin >> x;
  auto primes = eratosthenes(x, 100010);
  cout << primes[0] << endl;
  return 0;
}

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

using int64 = long long;

using vint = vector<int>;

constexpr int INF = (1 << 30) - 1;
constexpr int64 INF64 = (1ll << 60) - 1;

#define rep(i, N) for(int i=0;i<(int)(N);++i)
#define fs first
#define sc second
#define e_b emplace_back
#define m_p make_pair
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()

template <typename T, typename U>
ostream& operator<<(ostream& os, const pair<T, U>& p) {
	return os << "P(" << p.first << ", " << p.second << ")";
}
template <typename T>
ostream& operator<<(ostream& os, const vector<T>& v) {
	os << "[";
	for (auto& e : v) os << e << ", ";
	return os << "]";
}
template <typename T, typename U>
ostream& operator<<(ostream& os, const map<T, U>& m) {
	os << "{" << endl;
	for (auto& e : m) os << "(" << e.first << ", " << e.second << ")" << endl;
	return os << "}";
}
template <typename T>
ostream& operator<<(ostream& os, const set<T>& s) {
	os << "{" << endl;
	for (auto& e : s) os << ", " << e << endl;
	return os << "}";
}

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

int64 gcd(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	int64 r;
	while ((r = y % x) != 0) {
		y = x;
		x = r;
	}
	return x;
}
int64 lcm(int64 x, int64 y) {
	if (x == 0 || y == 0) return 0;
	return x / gcd(x, y) * y;
}

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

void Main();
signed main() {
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	Main();
}


/*----------------------------Insert from here!----------------------------*/



/*----------------------------Insert above here----------------------------*/

void Main() {
	int n; cin >> n;
	bitset<2000 * 20 + 1> dp;
	dp[0] = 1;
	rep(i, n) {
		int a; cin >> a;
		dp |= dp << a;
	}

	int q; cin >> q;
	rep(i, q) {
		int m; cin >> m;
		if (dp[m]) cout << "yes" << endl;
		else cout << "no" << endl;
	}
}


Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)  for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define pb emplace_back
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
#define dame(a) {out(a);return 0;}
#define decimal cout<<fixed<<setprecision(15);
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef tuple<ll,ll,ll,ll> PPP;
typedef multiset<ll> S;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
using vp=vector<P>;
using vvp=vector<vp>;
using vb=vector<bool>;
using vvb=vector<vb>;
const ll inf=1001001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outvvp(T v){rep(i,v.size())outvp(v[i]);}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void yesno(T b){if(b)out("yes");else out("no");}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
template<class T> void YESNO(T b){if(b)out("YES");else out("NO");}
template<class T> void noyes(T b){if(b)out("no");else out("yes");}
template<class T> void NoYes(T b){if(b)out("No");else out("Yes");}
template<class T> void NOYES(T b){if(b)out("NO");else out("YES");}
void outs(ll a,ll b){if(a>=inf-100)out(b);else out(a);}
ll gcd(ll a,ll b){if(b==0)return a;return gcd(b,a%b);}
ll modpow(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*modpow(a,b-1)%mod;ll k=modpow(a,b/2);return k*k%mod;}
vvi g;
vi x;
P dfs(int i){
    vb dp(x[i]+1,false);
    dp[0]=true;
    ll sum=0;
    for(ll t:g[i]){
        auto p=dfs(t);
        if(p.fi==-1)return P(-1,-1);
        vb ndp(x[i]+1,false);
        rep(j,x[i]+1)if(dp[j]){
            if(j+p.fi<=x[i])ndp[j+p.fi]=true;
            if(j+p.se<=x[i])ndp[j+p.se]=true;
        }
        dp=ndp;
        sum+=p.fi+p.se;
    }
    ll w=x[i];
    while(w>=0){
        if(dp[w])break;
        else w--;
    }
    if(w==-1)return P(-1,-1);
    return P(x[i],sum-w);
}
int main(){
    ll n;cin>>n;
    vi p(n-1);
    x=vi(n);
    g=vvi(n);
    rep(i,n-1)cin>>p[i];
    rep(i,n-1)p[i]--;
    rep(i,n)cin>>x[i];
    rep(i,n-1)g[p[i]].pb(i+1);
    if(dfs(0).fi==-1)out("IMPOSSIBLE");
    else out("POSSIBLE");
}

Measured memory_bytes: 512
import sys
sys.setrecursionlimit(100100)
from collections import deque
def factorials(M):#M!までのリストｘと其の逆元のリストyを返すmod INF
    INF=int(1e9+7)
    fac=[0]*(M+1)
    finv=[0]*(M+1)
    inv=[0]*(M+1)
    fac[0]=fac[1]=1
    finv[0]=finv[1]=1
    inv[1]=1
    for i in range(2,M+1):
        fac[i]=(fac[i-1]*i)%INF
        inv[i]=INF-(inv[INF%i]*(INF//i))%INF
        finv[i]=finv[i-1]*inv[i]%INF
    return fac,finv

N,K=map(int,input().split())
fac,finv=factorials(max(N,K))
def nCr(n,r):
    INF=int(1e9+7)
    if n<r or r<0 or n<0 :
        return 0
    return fac[n]*(finv[r]*finv[n-r]%INF)%INF
A=[0]*N
G=[[] for i in range(N)]
MOD=10**9+7
for i in range(N-1):
    a,b=map(int,input().split())
    a,b=a-1,b-1
    A[a]+=1
    A[b]+=1
    G[a].append(b)
    G[b].append(a)
ans=K
can=K
grand=0
gpare=-1
stack=deque([[0,gpare]])
while(stack):
    pare,gpare=stack.pop()
    childs=G[pare]
    ans*=nCr(K-1-grand,len(childs)-grand)*fac[len(childs)-grand]
    ans%=MOD
    grand=1
    for i in childs:
        if i==gpare:
            continue
        if A[i]-1==0:
            continue
        stack.append([i,pare])
print(ans)


Measured memory_bytes: 67616
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
using namespace std;
vector<string> split(string &input, char delimiter)
{
	istringstream stream(input);
	string field;
	vector<string> result;
	while (getline(stream, field, delimiter)) {
		result.push_back(field);
	}
	return result;
}
int main()
{
	string s = "1,1,1,2,1,2,1,5,2,2,1,5,1,2,1,14,1,5,1,5,2,2,1,15,2,2,5,4,1,4,1,51";
	vector<string> t = split(s, ',');
	int n;
	cin >> n;
	n--;
	cout << t[n] << endl;
	return 0;
}

Measured memory_bytes: 256
import collections
import sys

input = sys.stdin.readline

ri = lambda: int(input())
rs = lambda: input().rstrip()
ril = lambda: list(map(int, input().split()))
rsl = lambda: input().rstrip().split()
ris = lambda n: [ri() for _ in range(n)]
rss = lambda n: [rs() for _ in range(n)]
rils = lambda n: [ril() for _ in range(n)]
rsls = lambda n: [rsl() for _ in range(n)]


def eratosthenes(n):
    sieve = [True for _ in range(n + 1)]
    sieve[0] = False
    sieve[1] = False

    def _update(p):
        if sieve[p]:
            for i in range(p * 2, n + 1, p):
                sieve[i] = False

    if n > 1:
        _update(2)
    p = 3
    while p * p <= n:
        _update(p)
        p += 2
    return sieve


def factorize(n, primes):
    import collections
    if n < 2:
        return dict()
    counter = collections.Counter()
    for p in primes:
        while n % p == 0:
            counter[p] += 1
            n //= p
        if n == 1:
            break
    if n > 1:
        counter[n] += 1
    return counter


MOD = 10**9 + 7

n = ri()
ls = ril()
if n == 1:
    print(1)
    exit()

sieve = eratosthenes(10**3)
primes = [x for x, b in enumerate(sieve) if b]

lcm_counter = collections.Counter()
for x in ls:
    counter = factorize(x, primes)
    for p, k in counter.items():
        lcm_counter[p] = max(lcm_counter[p], k)
lcm = 1
for p, k in lcm_counter.items():
    lcm *= pow(p, k, MOD)
    lcm %= MOD

res = 0
for x in ls:
    res += lcm * pow(x, MOD - 2, MOD)
    res %= MOD
print(res)

Measured memory_bytes: 4852
#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>>;

const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
const ll INF = 1e16;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
#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--)

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; }

void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}
//--------------------------------------------------------------------------------//

int main() {
    init();
    while(1){
        ll N;
        cin >> N;
        if (N == 0) break;
        vc<ld> A(N);
        rep(i, N) cin >> A[i];

        ld av = accumulate(all(A), 0.0L) / (ld)N;
        ld sum = 0;
        rep(i, N) sum += (A[i] - av) * (A[i] - av);
        cout << sqrtl(sum / (ld)N) << endl;
    }
}


Measured memory_bytes: 3276
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using static System.Math;
using System.Text;
using System.Threading;
using System.Globalization;
using System.Runtime.CompilerServices;
using Library;

namespace Program
{
    public static class ABC149B
    {
        static public int numberOfRandomCases = 0;
        static public void MakeTestCase(List<string> _input, List<string> _output, ref Func<string[], bool> _outputChecker)
        {
        }
        static public void Solve()
        {
            var A = NN;
            var B = NN;
            var K = NN;
            if (K <= A)
            {
                Console.WriteLine($"{A - K} {B}");
            }
            else if (K - A <= B)
            {
                Console.WriteLine($"{0} {B - (K - A)}");
            }
            else
            {
                Console.WriteLine("0 0");
            }
        }
        static class Console_
        {
            static Queue<string> param = new Queue<string>();
            public static string NextString() { if (param.Count == 0) foreach (var item in Console.ReadLine().Split(' ')) param.Enqueue(item); return param.Dequeue(); }
        }
        class Printer : StreamWriter
        {
            public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
            public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { base.AutoFlush = false; }
            public Printer(Stream stream, Encoding encoding) : base(stream, encoding) { base.AutoFlush = false; }
        }
        static public void Main(string[] args) { if (args.Length == 0) { Console.SetOut(new Printer(Console.OpenStandardOutput())); } var t = new Thread(Solve, 134217728); t.Start(); t.Join(); Console.Out.Flush(); }
        static long NN => long.Parse(Console_.NextString());
        static double ND => double.Parse(Console_.NextString());
        static string NS => Console_.NextString();
        static long[] NNList(long N) => Repeat(0, N).Select(_ => NN).ToArray();
        static double[] NDList(long N) => Repeat(0, N).Select(_ => ND).ToArray();
        static string[] NSList(long N) => Repeat(0, N).Select(_ => NS).ToArray();
        static IEnumerable<T> OrderByRand<T>(this IEnumerable<T> x) => x.OrderBy(_ => xorshift);
        static long Count<T>(this IEnumerable<T> x, Func<T, bool> pred) => Enumerable.Count(x, pred);
        static IEnumerable<T> Repeat<T>(T v, long n) => Enumerable.Repeat<T>(v, (int)n);
        static IEnumerable<int> Range(long s, long c) => Enumerable.Range((int)s, (int)c);
        static uint xorshift { get { _xsi.MoveNext(); return _xsi.Current; } }
        static IEnumerator<uint> _xsi = _xsc();
        static IEnumerator<uint> _xsc() { uint x = 123456789, y = 362436069, z = 521288629, w = (uint)(DateTime.Now.Ticks & 0xffffffff); while (true) { var t = x ^ (x << 11); x = y; y = z; z = w; w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)); yield return w; } }
    }
}
namespace Library {
}


Measured memory_bytes: 14688
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
 
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
 
using namespace std;
 
#define int long long
//typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;
 
const int INF=1e+9;
const double EPS=1e-9;
const int MOD=1000000007;
 
const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
 
signed main(){
	vector<P> vec;
	int n,k;
	cin >> n >> k;
	for(int i = 0;i < n;i++){
		int a,b;
		cin >> a >> b;
		vec.pb(P(a,b));
	}
	sort(vec.begin(),vec.end());
	int cnt = 0;
	for(int i = 0;i < n;i++){
		cnt += vec[i].second;
		if(cnt >= k){
			cout << vec[i].first << endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 2420
#include <iostream>

using namespace std;

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int arr[5];
	for (int i = 0; i < 5; i++) {
		cin >> arr[i];
	}
	int num;
	cin >> num;
	for (int i = 0; i < 5; i++) {
		for (int j = i + 1; j < 5; j++) {
			int tmp = arr[j] - arr[i];
			if (tmp > num) {
				cout << ":(\n";
                return 0;
			}
		}
	}
    cout << "Yay!\n";
	return 0;
}

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

int point[10][10];

int main(void)
{
	int N, D;
	cin >> N >> D;
	int cnt = 0;
	for (int i = 0; i < N; i++)
	{
		for (int j = 0; j < D; j++) cin >> point[i][j];
		for (int j = 0; j < i; j++)
		{
			int dist = 0;
			for (int k = 0; k < D; k++)
			{
				int delta = point[i][k] - point[j][k];
				dist += delta * delta;
			}
			for (int k = 0; k < 1000; k++)
			{
				if (dist == k * k) cnt++;
			}
		}
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define pii pair<int,int>
#define piii pair<int,pii>
#define mp make_pair
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-14;
const double PI = M_PI;  
#define DEB cout<<"!"<<endl
#define SHOW(a,b) cout<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cout<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
  
#define DIV 1000000007

ll t[300][300] ={};
bool cancel[300] = {}; //0:carry out 1:canceled
ll num[300] ={};

int main(){
  ll n,m;cin >> n >> m;
  rep(i,n)
    rep(j,m)
      cin >> t[i][j],t[i][j]--;
  
  ll ans = LLINF;
  
  ll index=-1;
  rep(aaaa,m){
  fill_n(num,300,0);
  if(index >= 0)
    cancel[index] = 1;
  rep(i,n)
    rep(j,m)
      if(cancel[t[i][j]] == 0){
        num[t[i][j]]++;
        break;
      }
  ll a = -LLINF;
  rep(j,m){
    if(num[j] > a)
      index = j;
    a=max(a,num[j]);
  }
  ans = min(a,ans);
  }
  
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(int i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

const int MAX_V = 2e3;
vector<int> es[MAX_V];
int d[MAX_V][MAX_V];

void dfs(int root, int now, int pre){
    if(now == root) d[root][now] = 0;
    else d[root][now] = d[root][pre]+1;
    for(auto &e: es[now]){
        if(e != pre) dfs(root, e, now);
    }
}

int main(){
    int N, K;
    cin >> N >> K;
    rep(i, N-1){
        int u, v; cin >> u >> v; u--, v--;
        es[u].pb(v), es[v].pb(u);
    }
    rep(i, N) dfs(i, i, -1);
    int ans = N;
    if(K%2 == 0){
        rep(i, N){
            int tmp = 0;
            rep(j, N){
                if(d[i][j] > K/2) tmp++;
            }
            chmin(ans, tmp);
        }
    }
    else{
        rep(i, N){
            for(auto &e: es[i]){
                int tmp = 0;
                rep(j, N){
                    if(d[i][j] > K/2 && d[e][j] > K/2) tmp++;
                }
                chmin(ans, tmp);
            }
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 19360
#include <iostream>

using namespace std;

int main() {
    int L, R;
    cin >> L >> R;
    int m = 2019;
    int LP = L % 2019, RP = R % 2019;
    if (L / 2019 != R / 2019) {
        cout << 0 << endl;
        return 0;
    }
    for (int i = LP; i <= RP; ++i) {
        for (int j = i + 1; j <= RP; ++j) {
            m = min(m, i * j % 2019);
        }
    }
    cout << m << endl;
}


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

int main(){
string s,t,u;
bool x=false;
cin >> s >> t;
u=t;
for(int j=0;j<s.size();j++){
    for(int i=0;i<s.size();i++){
    u.at((i+j)%s.size())=s.at(i);
}
if(u==t) x=true;
}
if(x) cout << "Yes" << endl;
else cout << "No" << endl;
}

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

int main(){
    int lastdayOfManth[12] = {31, 28, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};

    int m1, d1, m2, d2;

    cin >> m1 >> d1;
    cin >> m2 >> d2;

    if( lastdayOfManth[m1-1] == d1 ){
        cout << 1 << endl;
    }else{
        cout << 0 << endl;
    }
}

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

int main() {
	int N, M;
	cin >> N >> M;
	vector<int> L(M);
	vector<int> R(M);
	rep(i, M) {
		cin >> L[i];
		cin >> R[i];
	}
	cout << max(*min_element(R.begin(), R.end()) - *max_element(L.begin(), L.end()) + 1, 0) << endl;
	return 0;
}

Measured memory_bytes: 1024
N = gets.to_i
S, P = [], []
(0..N-1).each do |i|
  S[i], P[i] = gets.split.map(&:to_s)
end
hash = []
(0..N-1).each do |i|
  hash.push([i+1, S[i], P[i]])
end
hash.sort{|a, b|
  (a[1] <=> b[1]).nonzero? || (b[2].to_i <=> a[2].to_i)
}.each do|key, valS, valP|
  puts key.to_i
end

Measured memory_bytes: 1788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace D
{
    public class Node:IComparable
    {
        public int Cost = int.MaxValue;
        public bool IsSet = false;
        public int Index;
        public Node(int index)
        {
            Index = index;
        }

        public int CompareTo(object obj)
        {
            return Cost.CompareTo((obj as Node).Cost);
        }
    }
    class Program
    {
        static void Main(string[] args)
        {
            var param = Console.ReadLine().Split(' ');
            int H = int.Parse(param[0]);
            int W = int.Parse(param[1]);
            var c = Enumerable.Repeat(0, 10).Select(x => Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray()).ToArray();
            var A = Enumerable.Repeat(0, H).Select(x => Console.ReadLine().Split(' ').Select(y => int.Parse(y)).ToArray()).ToArray();



            int ans = 0;
            Node[] nodes = Enumerable.Range(0, 10).Select(x => new Node(x)).ToArray();
            nodes[1].IsSet = true;
            nodes[1].Cost = 0;
            int current = 1;
            for (int j = 0; j < 9; j++)
            {
                for (int i = 0; i < 10; i++)
                {
                    var cost = nodes[current].Cost + c[i][current];
                    nodes[i].Cost = nodes[i].Cost < cost ? nodes[i].Cost : cost;
                }
                var update = nodes.Where(x => !x.IsSet).Min(x => x);
                update.IsSet = true;
                current = update.Index;
            }

            var result = A.SelectMany(x => x).Where(x => x != -1).Select(x => nodes[x].Cost).Sum();

            Console.WriteLine(result);
        }
    }
}


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

#define M 1000000
#define NIL (-1)
#define L 14

char H[M][L];

int get(char ch){
	if(ch == 'A') return 1;
	else if(ch == 'B') return 2;
	else if(ch == 'C') return 3;
	else if(ch == 'D') return 4;
	else return 0;
}

long long getK(char str[]){
	long long sum = 0,p = 1;
	for(int i = 0;i<strlen(str);i++){
		sum += p*(get(str[i]) );
		p*=5;
	}
	return sum;
}

int h1(int key){
	return key % M;
}

int h2(int key){
	return 1 + (key % (M-1) );
}

int find(char str[]){
	long long key,h;
	key = getK(str);
	for(int i = 0;;i++){
		h = (h1(key) + i * h2(key)) % M;
		if(strcmp(H[h],str) == 0) return 1;
		else if(strlen(H[h]) == 0) return 0;
	}
	return 0;
}

int insert(char str[]){
	long long key,i,h;
	key = getK(str);
	for(int i = 0;;i++){
		int h = (h1(key)+i*h2(key) ) % M;
		if(strcmp(H[h],str) == 0){
			return 1;
		}else if(strlen(H[h]) == 0){
			strcpy(H[h],str);
			return 0;
		}
	}
	return 0;
}

int main(){
	int n,h;
	char str[L],com[9];
	for(int i = 0;i < M; i++){
		H[i][0] = '\0';
	}
	cin >> n;
	for(int i = 0;i<n;i++){
		cin >> com >>str;
		if(com[0] == 'i'){
			insert(str);
		}else{
			if(find(str) ){
				cout << "yes" << endl;
			}else{
				cout << "no" << endl;
			}
		}
	}
	return 0;
}


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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;


int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll n, d; cin >> n >> d;
	int ans = 0;
	for(int i = 0; i < n; i++){
		ll x, y; cin >> x >> y;
		if(x * x + y * y <= d*d) ans++;
	}
	cout << ans << endl;
} 

Measured memory_bytes: 3664
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string>
#include <tuple>
#include <vector>

using namespace std;
typedef long long int ll;
typedef vector<int> vi;
typedef vector<vi> vvi;

#define INF (1e9)

string s;

int main() {
    cin >> s;

    ll ans = 0;
    int N = s.length();

    int countA = 0;
    for (int i = 0; i < N; i++) {
        if (s[i] == 'A')
            countA++;
        else if (s[i] == 'B' && s[i + 1] == 'C') {
            ans += countA;
            i++;
        } else
            countA = 0;
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
 
int main() {
    ll a,b,c,d;
    cin >> a >> b >> c >> d;
    ll p,q,r,s;
    p = a*c;
    q = a*d;
    r = b*c;
    s = b*d;

    ll ans = max(max(p,q),max(r,s));
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3632
//#include "pch.h"
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <time.h>

#include <vector>
#include <set>
#include <map>
#include <iostream>
#include <utility>
#include <queue>
#include <algorithm>
#include <functional>
#include <string>
#include <bitset>

#define ll long long
#define fri(n) for(i=0;i<(n);i++)
#define frj(n) for(j=0;j<(n);i++)
#define min(p,q) ((p)<(q)?(p):(q))
#define max(p,q) ((p)>(q)?(p):(q))
#define INF 1000000000000000000//10^18
#define INFINT 2000000001//2*10^9+1
#define MOD 1000000007
#define MODANOTHER 998244353
#define PI acos(-1)

#define int ll

using namespace std;



signed main(void)
{
	//変数の宣言
	int n,m;
	int h,w;
	static int a[200010];
	static int b[200010];
	char s[110];
	double Ld;

	//よく使う変数
	int i,j,k,l;
	int flag=0;
	int ans=0;
	int count=0;
	int temp=0;
	int temp1=0;
	int temp2=0;
	int temp3=0;
	static int vec[100010];
	int max=0;
	int min=INFINT;
	int len=0;
	int sum=0;
	int ok=0;
	int ng=0;
	char dummy;
	static char stemp[100010];
	
	//データの読み込み


	scanf("%lld",&n);
//	scanf_s("%lld",&n);


//	scanf("%s",&s);
//	scanf_s("%s",&s,110);




/*	//scanf("%c",&dummy);
	scanf_s("%c",&dummy);
	for(i=0;i<n;i++){
//		scanf("%c",&s[i]);
		scanf_s("%c",&s[i]);
	}*/


	for(i=0;i<n;i++){
		scanf("%lld",&a[i]);
//		scanf_s("%lld",&a[i]);
	}


	//	printf("nは%dです\n", n);
	//	printf("データの読み込み終了\n");
	//実際の処理

//	clock_t start=clock();

	for(i=0;i<=n;i++){
		b[i]=0;
	}

	for(i=0;i<n;i++){
		b[a[i]]++;
	}

	ans=0;
	for(i=1;i<=n;i++){
		ans=ans+b[i]*(b[i]-1)/2;
	}

	for(i=0;i<n;i++){
		temp=ans-b[a[i]]+1;
		if(b[a[i]]==0)temp--;
		printf("%lld\n",temp);
	}

//	clock_t end=clock();

	//	printf("計算部分終了\n");

	//出力
	
	//printf("%d",(d[i-1][j-1]+1)/2);

//	printf("time=%lf",(double)(end-start)/CLOCKS_PER_SEC);
	//	printf("結果の出力終了\n");

	return 0;
}



Measured memory_bytes: 5760
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int K = Integer.parseInt(sc.next());
        long[] A = new long[K];
        for (int i=0;i<K;i++) {
            A[i] = Integer.parseInt(sc.next());
        }

        long L = 2;
        long R = 2;
        for (int i=K-1;i>=0;i--) {
            if ((L-1)/A[i]>=R/A[i]) {
                System.out.println(-1);
                return;
            }
            L = (L+A[i]-1)/A[i]*A[i];
            R = R/A[i]*A[i]+A[i]-1;
        }
        System.out.println(L+" "+R);
    }
}

Measured memory_bytes: 47760
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i, s, n) for(int i = s, i##_len=(n); i < i##_len; ++i)
#define REP(i, n) FOR(i, 0, n)
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort(ALL(v))
#define PB push_back
#define MP make_pair
using ll = long long;
using Pii = pair<int, int>;
const int MOD = 1000000007;
const int INF = 1000000000;

int main(){
    vector<int> a(3);
    REP(i, 3) cin >> a[i];
    sort(ALL(a));
    int ans;
    if(a[0] != a[1]) ans = a[0];
    else ans = a[2];
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
// Library
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

// TYPEDEFS
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef pair<int,int> pi;

// CONSTANTS
#define SZA 0
#define SZB 0

// MACRO
#define MAX(X, Y) (((X) > (Y))? (X) : (Y))
#define MIN(X, Y) (((X) < (Y))? (X) : (Y))
#define ABS(X) (((X) > 0)? (X) : -(X))
#define YN(X) ((X)? "YES" : "NO")
#define SWAP(T, X, Y) {T t; t = X; X = Y; Y = t;}

#define F first
#define S second
#define PB push_back
#define MP make_pair


// Global Tables

//ull gPreProcess[SZA][SZB];

// Functions

void Print2DVector(vector<vector<int>>& v)
{
    ull i, j; 
    for(i = 0; i < v.size(); i++)
    {
        for(j = 0; j < v[i].size(); j++)
        {
            cout << v[i][j];
            if(j == v[i].size()-1)
            {
                cout << endl;
            }
            else
            {
                cout << " ";
            }
        }
    }
}

void PrintVector(vi& v)
{
    ull i;
    for(i = 0; i < v.size(); i++)
    {
        cout << v[i];
        if(i == v.size()-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PrintArr(int* a, ull N)
{
    ull i;
    for(i = 0; i < N; i++)
    {
        cout << a[i];
        if(i == N-1)
        {
            cout << endl;
        }
        else
        {
            cout << " ";
        }
    }
}

void PreProcessTables()
{
    ull i, j;
    for(i = 0; i < SZA; i++)
    {
        for(j = 0; j < SZB; j++)
        {
            break;
        }
        break;
    }
}

void TC(int t)
{
    ull i = 0;
    long double N, X = 100;
    cin >> N;
    while(X < N)
    {
        X = (ull)(X*1.01);
        i++;
    }
    cout << i << endl;
}

// Main

int main(void)
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 
    PreProcessTables();

    int T = 1, t;
    for(t = 1; t <= T; t++)
    {
        TC(t);
    }
    return 0;
}


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

int main(){
    int n,k;
    cin >> n >> k;
    vector <ll> v(n),rm(n+1),ru(n+1);
    rm[0]=0;
    rep(i,n){
        cin >> v[i];
        
        rm[i+1]=rm[i]+v[i];
        
        
    }
    ru[0]=0;
    rep(i,n){
        ru[i+1]=ru[i]+v[n-i-1];
    }
    vector <ll> a,b,c;
    ll ans,ma=0;


//cout << "u"  << endl;
    rep(l,k+1){
        //cout << l << endl;
        rep(r,k-l+1){
            
            if(r+l>n or r+l==0){
                    continue;
                }
                else{
                    
                    a=c;
                    rep(j,l){
                        //cout << j << endl;
                        a.push_back(v[j]);
                    }
                    for (int j=n-r; j<(n); ++j){
                        a.push_back(v[j]);
                    }
                 //a=v(0::l)+v(n-1-r::n-1);
                 sort(a.begin(),a.end());
                 ans=rm[l]+ru[r];  
                 if(ans>ma){
                    ma=ans;
                }
                  //cout << l << " " << r << " " << ans << endl;
                
            rep(m,k-l-r){
                if(m+1>r+l){
                    break;
                }
                

                if(a[m]>=0){
                    break;
                }
                else{
                    
                    ans-=a[m];
                    
                }
                if(ans>ma){
                    ma=ans;
                }
            }
        }
        }
    }

    cout << ma << endl;
    

    return 0;
}

Measured memory_bytes: 256
'use strict';
let execute = input => {
  let inputs = input.split(' ').map(str => +str);
  let ans = 0;
  for (let i = 1; i <= inputs[0]; i++) {
    const sum = String(i).split('').reduce((sum, el) => sum += +el, 0);
    if (sum >= inputs[1] && sum <= inputs[2]) ans += i;
  }
  return ans;
};

function Main(input) {
  console.log(execute(input));
}
Main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 9240
#include <bits/stdc++.h>
using namespace std;
#define __ <<' '<<
#define ___ <<' '
#define bash push_back
#define ALL(x) x.begin(),x.end()
//#define int long long

struct IoSetup {IoSetup() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout <<fixed<<setprecision(12);
    cerr <<fixed<<setprecision(12);
}}IoSetup;

using ll = long long;
using pii = pair<int, int>;
constexpr int INF = 0x3f3f3f3f;
constexpr long long LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int SMOD = 1000000007;
constexpr int NMOD = 998244353;
constexpr int dx[]={1,0,-1,0,1,1,-1,-1};
constexpr int dy[]={0,1,0,-1,-1,1,-1,1};

inline bool inside(int x,int y,int w,int h){return (x>=0 && y>=0 && x<w && y<h);}
template<class T>bool chmax(T &a, const T &b){return(a<b?a=b,true:false);}
template<class T>bool chmin(T &a, const T &b){return(a>b?a=b,true:false);}
inline int qp(int a,ll b,int mo){ll ans=1;do{if(b&1)ans=1ll*ans*a%mo;a=1ll*a*a%mo;}while(b>>=1);return ans;}



signed main() {

    int n;
    cin >> n;
    vector<int> d(n);
    for(auto&&i:d) cin >> i;

    sort(ALL(d));

    cout << d[n/2] - d[n/2-1]  << endl;


  
    return 0;
}



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

int main() {
  double L;
  cin >> L;
  
  printf("%.12f", (L*L*L) / 27);
  return 0;
}




Measured memory_bytes: 3772
A, B = map(int, input().split())

from fractions import gcd
from collections import defaultdict
import math
def factorize(n):
    d = defaultdict(int)

    for i in range(2, int(math.sqrt(n) + 1)):
        while n % i == 0:
            d[i] += 1
            n //= i
    if n > 1:
        d[n] += 1
    return d

ab = gcd(A, B)
d = factorize(ab)
print(len(d) + 1)

Measured memory_bytes: 64748
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <cstdlib>
#include <algorithm>

//コメントアウトするとdebug()を実行しない
#define DEBUG

using namespace std;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

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

ll N,ans = 1,inf = (ll)1e9 + 7;

void solve(){

}

void debug(){

}

void answer(){
	cout << ans << "\n";
}

int main(){
	ios::sync_with_stdio(false);
	cin >> N;
	// cout << "INF " << INF  << "\n";
	for (long long i = 2; i < N+1; ++i)
	{
		ans = ans*i;
		// cout << i << ":" << ans << "\n";
		ans = ans % inf;
	}
	solve();
	#ifdef DEBUG
	debug();
	#endif
	answer();

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ADD(a, b) a = (a + ll(b)) % mod
#define MUL(a, b) a = (a * ll(b)) % mod
#define MAX(a, b) a = max(a, b)
#define MIN(a, b) a = min(a, b)
#define rep(i, a, b) for(int i = int(a); i < int(b); i++)
#define rer(i, a, b) for(int i = int(a) - 1; i >= int(b); i--)
#define all(a) (a).begin(), (a).end()
#define sz(v) (int)(v).size()
#define pb push_back
#define sec second
#define fst first
#define debug(fmt, ...) Debug(__LINE__, ":", fmt, ##__VA_ARGS__)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pi;
typedef pair<ll, ll> pl;
typedef pair<int, pi> ppi;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> mat;
typedef complex<double> comp;
void Debug() {cout << '\n'; }
template<class FIRST, class... REST>void Debug(FIRST arg, REST... rest){
	cout<<arg<<" ";Debug(rest...);}
template<class T>ostream& operator<<(ostream& out,const vector<T>& v) {
	out<<"[";if(!v.empty()){rep(i,0,sz(v)-1)out<<v[i]<<", ";out<<v.back();}out<<"]";return out;}
template<class S, class T>ostream& operator<<(ostream& out,const pair<S, T>& v){
	out<<"("<<v.first<<", "<<v.second<<")";return out;}
const int MAX_N = 200010;
const int MAX_V = 100010;
const double eps = 1e-6;
const ll mod = 1000000007;
const int inf = 1 << 29;
const ll linf = 1LL << 60;
const double PI = 3.14159265358979323846;
///////////////////////////////////////////////////////////////////////////////////////////////////

int N, M;
vi G[MAX_N];
bool used[MAX_N];
vector<int> vec;
vector<int> ans;

void loop(int v) {
	vec.pb(v);
	used[v] = true;
	rep(i, 0, sz(G[v])) {
		int n = G[v][i];
		if(!used[n]) {
			loop(n);
			return;
		}
	}
	return;
}

void solve() {
	cin >> N >> M;
	int s, t;
	rep(i, 0, M) {
		int a, b; cin >> a >> b; a--; b--;
		G[a].pb(b);
		G[b].pb(a);
		if(i == 0) {
			used[a] = true; used[b] = true;
			s = a; t = b;
		}
	}
	vec.clear();
	loop(s);
	reverse(all(vec));
	ans.insert(ans.end(), all(vec));
	vec.clear();
	loop(t);
	ans.insert(ans.end(), all(vec));
	cout << sz(ans) << "\n";
	rep(i, 0, sz(ans)) {
		cout << ans[i] + 1 << " ";
	}
	cout << "\n";
}

int main() {
#ifndef LOCAL
	ios::sync_with_stdio(false);
    cin.tie(0);
#endif
    cout << fixed;
	cout.precision(20);
	srand((unsigned int)time(NULL));
#ifdef LOCAL
	//freopen("in.txt", "wt", stdout); //for tester
    freopen("in.txt", "rt", stdin);
#endif	
	solve();
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
	return 0;
}



Measured memory_bytes: 12212
def main():
    N,T = map(int, input().split())
    min_c = 1001
    find_flg = False
    for i in range(N):
        cn,tn = map(int, input().split())
        if(tn<=T and cn < min_c):
            find_flg = True
            min_c = cn
    if(find_flg):
        print(min_c)
    else:
        print('TLE')

if __name__ == "__main__":
    main()

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define size_of(a) (int)(a).size()

class Alphabet {
public:
	static const int N = 4;
	
	inline int toInt(char c) {
		if (c == 'A') return 0;
		if (c == 'C') return 1;
		if (c == 'G') return 2;
		if (c == 'T') return 3;
		return -1;
	}
};

class Trie {
private:
	struct Node {
		vector< int > link;
		bool end;
		Node(int n) : link(n, -1),  end(false) {}
	};
	
	Alphabet& alph;
	vector< Node > node;
	
public:
	Trie(Alphabet& alph_) : alph(alph_) {
		node.push_back(Node(alph.N));
	}
	
	void insert(string& str) {
		insert(str, 0, 0);
	}
	
	void insert(string& str, int i, int vi) {
		if (i == size_of(str)) {
			node[vi].end = true;
			return;
		}
		
		int ci = alph.toInt(str[i]);
		
		if (node[vi].link[ci] != -1) {
			insert(str, i + 1, node[vi].link[ci]);
		} else {
			node.push_back(Node(alph.N));
			node[vi].link[ci] = size_of(node) - 1;
			insert(str, i + 1, node[vi].link[ci]);
		}
	}
	
	bool find(string& str) {
		return find(str, 0, 0);
	}
	
	bool find(string& str, int i, int vi) {
		if (i == size_of(str)) return node[vi].end;
		
		int ci = alph.toInt(str[i]);
		
		if (node[vi].link[ci] != -1) return find(str, i + 1, node[vi].link[ci]);
		return false;
	}
};

int main() {
	Alphabet alph;
	Trie trie(alph);
	
	int n;
	cin >> n;
	
	for_(i,0,n) {
		string op, str;
		cin >> op >> str;
		
		if (op == "insert") {
			trie.insert(str);
		} else {
			if (trie.find(str)) cout << "yes" << endl;
			else cout << "no" << endl;
		}
	}
}

Measured memory_bytes: 35276
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int a,b;
  cin>>a>>b;
  int sum=max(a,b);
  if(sum==a){
    a-=1;
    sum+=max(a,b);
  }
  else{
    b-=1;
    sum+=max(a,b);
  }
cout<<sum<<endl;

}


Measured memory_bytes: 256