akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;


namespace C
{
    class Program
    {
        static void Main(string[] args)
        {
            var nk = Console.ReadLine().Split().Select(int.Parse).ToArray();

            var h = Console.ReadLine().Split().Select(double.Parse).ToList();

            if (nk[0] >= nk[1])
            {
                var count = h.OrderBy(x => x).ToList().GetRange(0, nk[0] - nk[1]).Sum();
                Console.WriteLine(count);
            }
            else
            {
                Console.WriteLine(0);
            }




        }
    }
}


Measured memory_bytes: 41104
from _collections import deque

n,m=map(int,input().split())
f=[[] for i in range(n+1)]
for i in range(m):
    a,b=map(int,input().split())
    f[a].append(b)
    f[b].append(a)
g=[0]*(n+1)
p=[0]*(n+1)
for i in range(1,n+1):
    if p[i]==0:
        p[i]=i
        data=[i]
        data=deque(data)
        while len(data)>0:
            pos=data.popleft()
            p[pos]=i
            for j in f[pos]:
                if p[j]==0:
                    data.append(j)
for i in range(n):
    g[p[i+1]]+=1
print(max(g))


Measured memory_bytes: 125308
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define maxn 100005
int main(){__
	int n;
	int k;
	cin >> n >> k;
	vi a(n);
	for(int i=0; i < n; i++) cin >> a[i];
	int ans =0;
	sort(all(a));
	for(int i=0; i < n && k; i++){
		ans+=a[i];
		k--;
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
int main()
{
	int max,b,c,s=0;	
	while(scanf("%d%d%d",&max,&b,&c)!=EOF)
	{
		int t,d,i=0;		
		if(max<b)
		{
			t=max;
			max=b;
			b=t;
		}
		if(max<c)
		{
			t=max;
			max=c;
			c=t;
		}
		if(b<c)
		{
			t=b;
			b=c;
			c=t;
		}
		d=max-b;
		b=b+d;
		c=c+d;
		i=i+d;
		while(b!=c)
		{
		  if((b-c)%2==0)
			{
				c+=2;
				i++;
			}
			else 
			{
				max+=1;
				b+=1;
				i++;
			}
		}
		printf("%d\n",i);		
	}		
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <bits/stdc++.h>
#include <string>

using namespace std;


typedef long long int ll;
typedef unsigned long long  ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef deque <int> di;
typedef deque <char> dc;
typedef vector<long long int> vll;

#define f(i, a, b) for (int i = a; i < b; i++)
#define f2(i, a, b) for (int i = a; i <=b; i++)
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front;
int main() {
int x;
int y;
cin >> x >> y;
if (y%2 == 0 && 4*x >= y && 2*x <= y) {
    cout << "Yes";
}
else {
    cout << "No";
}
return 0;
}


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

int main()
{
	ll N, A, B;
	cin >> N >> A >> B;
	if (B >= A && N >= 2) {
		cout << (B - A) * (N - 2) + 1 << endl;
	}
	else if (A == B && N >= 1) {
		cout << 1 << endl;
	}
	else {
		cout << 0 << endl;
	}
	return 0;
}


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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	ll n, d, a;
	cin >> n >> d >> a;
	vector<P> p(n);
	rep(i,n){
		cin >> p[i].first >> p[i].second;
		p[i].second = (p[i].second + a - 1) / a; // 何回殴れば倒せるかに変換する
	}
	sort(p.begin(),p.end());
	d = d*2;
	ll tot = 0;
	queue<pair<ll,ll>> q;
	ll ans = 0;
	rep(i,n) {
		ll x = p[i].first;
		ll h = p[i].second;
		while (q.size() && q.front().first < x){
			tot -= q.front().second;
			q.pop();
		}
		h -= tot;
		if (h > 0) {
			ll num = h;
			ans += h;
			ll damage = num;
			tot += damage;
			q.emplace(x+d, damage);
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3456
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

int ans[110];
int N;

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


	cin >> N;
	int k = N;
	VI A(N);
	REP(i, N) {
		cin >> A[i];
	}
	bool F[110] = { false };
	REP(i, N) {
		int cnt = 0;
		REP(i, N)if (!F[i])cnt++;
		for (int i = N - 1; i >= 0; i--) {
			if (!F[i] && A[i] == cnt) {
				F[i] = true;
				ans[k] = cnt;
				k--;
				break;
			}
			else if (!F[i])cnt--;
		}
	}
	if (ans[1] == 0) {
		cout << -1 << endl;
		return 0;
	}
	FOR(i, 1, N + 1)cout << ans[i] << endl;
	return 0;
}



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

int main() {
  char s;
  cin >> s;
  if(s-'a' <= 26 && s-'a' >= 0) cout << "a" << endl;
  else cout << "A" << endl;
}

Measured memory_bytes: 3632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
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;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll high_order_bit(ll n){
    ll tmp=1,i=-1;
    while(tmp<=n){
        tmp*=2;
        i++;
    }
    if(n==0) return 0;
    else return i;
}
vector<ll> binary_expansion(ll n){
    vector<ll> B(high_order_bit(n)+1);
    ll tmp=n;
    for(ll i=high_order_bit(n);i>=0;i--){
        B[i]=tmp/pw2[i];
        tmp%=pw2[i];
    }
    return B;
}

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N,K; cin>>N>>K;
    ll ans=0;
    vector<ll> A(N+1,0);
    rep1(i,N) cin>>A[i];
    
    //doubling[i][j]:iから2^j回でどこにいるか
    ll D_MAX=65; //2^D_MAXで辿り着ける
    vector<vector<ll> > doubling(N+1,vector<ll>(D_MAX+1,0));
    
    //[i][0]は入力から作る
    rep1(i,N) doubling[i][0]=A[i];
    
    //前処理
    rep1(j,D_MAX)rep1(i,N){
        doubling[i][j] = doubling[doubling[i][j-1]][j-1];
    }
    
    //solve
    //1からK回
    vector<ll> v=binary_expansion(K);
    ll now=1;
    rep(i,sz(v)){
        if(v[i]==1) now=doubling[now][i];
    }
    cout<<now<<endl;
    
    return 0;
    
    //逆辿り
    now=1;
    rrep(i,sz(v)){if(v[i]==1) now=doubling[now][i];
    }
    cout<<now<<endl;
}



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

using namespace std;

#define DUMP(x) std::cerr << (#x) << " = " << (x) << "\n"
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP(i, k, n) for (int i = (k); i < (int)(n); ++i)
#define ALL(r) r.begin(), r.end()
#define YES puts("YES")
#define Yes puts("Yes")
#define NO puts("NO")
#define No puts("No")
#define IMP puts("IMPOSSIBLE")
#define Imp puts("Impossible")
#define imp puts("impossible")
#define M1 puts("-1")
#define pb push_back

template <typename T>
ostream &operator<<(ostream &os, vector<T> &v)
{
    os << "{";
    rep(i, v.size()) os << v[i] << (i == (int)v.size() - 1 ? "" : ", ");
    os << "}";
    return os;
}
template <typename T>
T dup(T x, T y)
{
    return (x + y - 1) / y;
};
template <typename A, size_t N, typename T>
inline void arrayFill(A (&array)[N], const T &val) { std::fill((T *)array, (T *)(array + N), val); }
struct in
{
    const size_t n = 0;
    in() = default;
    in(size_t n) : n(n){};
    template <typename T>
    operator T()
    {
        T ret;
        cin >> ret;
        return ret;
    }
    template <typename T>
    operator vector<T>()
    {
        assert(n != 0);
        vector<T> ret(n);
        for (auto &x : ret)
            cin >> x;
        return ret;
    }
};

using ll = int64_t;
using vint = vector<int32_t>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pint = pair<int32_t, int32_t>;
using pll = pair<ll, ll>;
using setint = set<int32_t>;
using setstr = set<string>;
using qint = queue<int32_t>;
using qpint = queue<pint>;

constexpr std::int32_t INF = 1001001001;
constexpr std::int64_t LINF = 1001001001001001001;

int table[35][100005];

void Main()
{
    arrayFill(table, 0);
    int n = in(), c = in();
    rep(i, n)
    {
        int s = in(), t = in(), c = in();
        ++table[c][s - 1];
        --table[c][t];
    }

    rep(i, 31)
    {
        rep(j, 100002)
        {
            table[i][j + 1] += table[i][j];
        }
    }
    /*
    rep(i, 5)
    {
        rep(j, 90)
        {
            if (table[i][j] >= 2)
                table[i][j] = 1;
            cout << table[i][j] << (j == 89 ? "\n" : " ");
        }
    }
    */

    int ans = 0;
    rep(i, 100002)
    {
        int cnt = 0;
        rep(j, 31)
        {
            if (table[j][i])
                ++cnt;
        }
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

int main()
{
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 13952
#include<iostream>
#include<string>
#include<map>
#include<algorithm>
using namespace std;
typedef long long ll;
const int Max = 1e5 + 7;
int lst[Max];

int main()
{
	int n;
	cin >> n;
	ll res = 0;
	for (int i = 1; i <= n; i++)
	{
		int a, b;
		cin >> a >> b;
		res += (b - a+1);
	}
	cout << res;
}

Measured memory_bytes: 3112
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cstring>
#include <queue>
#include <vector>
#include <functional>
#include <map>
#include <set>
#include <cmath>
#include <string>
#define SIZE 200005
#define INF 1000000005LL

using namespace std;
typedef long long int ll;
typedef pair <int,int> P;

int N;
int A[SIZE];
ll K;
vector<int> S; //素因数

//素因数分解
map<int,int> prime_factor(int n){
	map<int,int> res;
	for(int i=2;i*i<=n;i++){
		while(n%i == 0){
			++res[i];
			n /= i;
			S.push_back(i);
		}
	}
	if(n != 1){
		res[n] = 1;
		S.push_back(n);
	}
	S.erase(unique(S.begin(),S.end()),S.end());
	return res;
}

const int MAX = 300000;
const int MOD = 1000000007;

ll fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
// O(n)
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
// O(1)
ll COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

int main()
{
	int N,M;
	scanf("%d%d",&N,&M);
	COMinit();
	map<int,int> mp = prime_factor(M);
	ll ans = 1;
	for(int i=0;i<S.size();i++){
		ans *= COM(N+mp[S[i]]-1,mp[S[i]]);
		ans %= MOD;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 7296
#include<cstdio>
#include<iostream>
#include<cstring>
using namespace std;
int main(void)
{
	int a[101][101],c,h,w,i,j,k;
	char b[101][101];
	cin>>h>>w;
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			a[i][j]=-1;
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			cin>>b[i][j];
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(b[i][j]=='c'){
				a[i][j]=0;
				for(k=1;k<w;k++){
					c=j+k;
					if(c==w){
						c=0;
						break;
					}
					a[i][c]=k;
				}
			}
		}
	}
	for(i=0;i<h;i++){
		for(j=0;j<w;j++){
			if(j==w-1){
				cout<<a[i][j];
			}
			else{
				cout<<a[i][j]<<' ';
			}
		}
		cout<<endl;
	}
	return 0;
}


Measured memory_bytes: 3144
import java.util.*;
class Main{
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = sc.nextInt();
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(Math.abs(x-a)<Math.abs(x-b)){
			System.out.println("A");
		}else{
			System.out.println("B");
		}
	}
}

Measured memory_bytes: 21716
#include <stdio.h>

int main(){
	int N; int even = 0;
	int M; int odd = 0;
	scanf ("%d %d", &N, &M);
	
	for (int i=1; i <= N; i++){
		even = even +i-1; 
	}
	for(int i=1; i <= M; i++){
		odd = odd +i-1;
	}
	printf ("%d", odd+even);
	
	return 0;
}

Measured memory_bytes: 1732
n, m = map(int,input().split())
a = list(map(int,input().split()))
b = []
c = []
for i in range(m):
    bb, cc = map(int,input().split())
    b.append(bb)
    c.append(cc)

pairs = []
for i in range(n):
    pairs.append( (a[i], 1) )
for i in range(m):
    pairs.append( (c[i], b[i]) )

pairs.sort(reverse = True)

idx = 0
res = 0
for i in range(n):
    if pairs[idx][1]== 0:
        idx += 1
    p = list(pairs[idx])        
    res += p[0]
    p[1] -= 1
    pairs[idx] = tuple(p)
    
print(res)
    
    


Measured memory_bytes: 36428
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String result = "No";
		if(a + b >= c) result = "Yes";
		System.out.println(result);
	}

}


Measured memory_bytes: 35744
#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>;
const ll mod = 1000000007;

int main(){
    string s,a,b;
    cin >> s;
    int x = s.size();
    if (s[x-1] == 's'){
        s = s + "es";
    }
    else{
        s = s + "s";
    }
    cout << s << endl;
}

Measured memory_bytes: 3636
#include <iostream>

using namespace std;

int cmmdc(int a, int b){
  //for(int i = 1;i <= n;i++){
  while(b != 0){
    int rest = a % b;
    a = b;
    b = rest;
  }
  return a;
}

int main()
{
  int a, b;
  cin >> a >> b;
  cout << (1LL * a * b) / cmmdc(a, b);
  return 0;
}


Measured memory_bytes: 256
/* be name khoda */

// #define stream_enable
#define long_enable

#include <iostream>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <queue>

// #include <bits/stdc++.h>
// #include <numeric>
// #include <iomanip>
// #include <cmath>
// #include <bitset>
// #include <fstream>

using namespace std;

#ifdef stream_enable
#define cin sss
#endif

#ifdef long_enable
typedef long long int ll;
#else
typedef int ll;
#endif

typedef pair<ll, ll> pii;
typedef pair<pii, ll> ppi;
typedef pair<ll, pii> pip;
typedef vector<ll> vi;
typedef vector<vi> vii;
typedef vector<pii> vpii;

const ll MOD = 1000000007;

const long long BIG = 1446803456761533460LL;
const int Big = 336860180;

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

#define debug(x) cout << #x << " -> " << (x) << endl;
#define debug2(x, y) cout << #x << ' ' << #y << " -> " << (x) << ' ' << (y) << endl;
#define debug3(x, y, z) cout << #x << ' ' << #y << ' ' << #z << " -> " << (x) << ' ' << (y) << ' ' << (z) << endl;
#define debug4(x, y, z, t) cout << #x << ' ' << #y << ' ' << #z << ' ' << #t << " -> " << (x) << ' ' << (y) << ' ' << (z) << ' ' << (t) << endl;
#define debugp(x) cout << #x << " -> " << "(" << (x).ff << ", " << (x).ss << ")" << endl;
#define debuga(x, n) cout << #x << " -> "; fori (i1_da, n) { cout << (x)[i1_da] << ' '; } cout << endl
#define debugap(x, n) cout << #x << " ->\n"; fori (i1_dap, n) { cout << "(" << (x)[i1_dap].ff << ", " << (x)[i1_dap].ss << ")" << endl; } cout << endl
#define debugaa(x, n, m) cout << #x << " ->\n"; fori (i1_daa, n) { fori (i2_daa, m) { cout << (x)[i1_daa][i2_daa] << ' '; } cout << '\n'; } cout << endl
#define debugav(x, n) cout << #x << " ->\n"; fori (i1_dav, n) { fori (i2_dav, (x)[i1_da].size()) { cout << (x)[i1_dav][i2_dav] << ' '; } cout << '\n'; } cout << endl
#define debugia(x, n) cout << #x << " ->\n"; fori (i1_dia, n) { cout << i1_dia << " : " << (x)[i1_dia] << '\n'; } cout << endl

#define forifrom(i, s, n) for(ll i = (s); i < (n); ++i)
#define forirto(i, n, e) for(ll i = (n) - 1; i >= (e); --i)
#define fori(i, n) forifrom (i, 0, n)
#define forir(i, n) forirto (i, n, 0)

#define smin(a, b) a = min(a, (b))
#define smax(a, b) a = max(a, (b))

#define Add(a, b) a = (a + (b)) % MOD
#define Mul(a, b) a = (a * (b)) % MOD

stringstream sss;

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

const ll maxn = 100010;

void MAIN() {

    ll x;
    cin >> x;
    fori (i, 1000001) {
        if (i * 100 <= x && x <= i * 105) {
            cout << "1\n";
            return;
        }
    }
    cout << "0\n";

}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    // cout << fixed << setprecision(10);
    sss << R"(

    )";
    MAIN();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const ll MOD = 1e9+7;

const ll N = 1e6;



//a^(p-2)=a^(-1) (mod p)

//(x^n)%mod

ll mod_pow(ll x,ll n,ll mod){

  if(n==0)return 1;

  ll res=mod_pow( x*x%mod , n/2 , mod );

  if( n & 1 )res = res*x%mod;

  return res;

}



ll fact[N];

ll infact[N];



void make_factorial(void){

  fact[0] = 1;

  for( ll i = 1 ; i < N ; i++ ){

    fact[i] = fact[i-1] * i;

    fact[i] %= MOD;

  }

  for( ll i = 0 ; i < N ; i++ ){

    infact[i] = mod_pow( fact[i] , MOD-2 , MOD );

  }

}



ll comb(ll a,ll b){

  if(a == 0 && b == 0)return 1;

  if(a < b || a < 0)return 0;

  ll tmp = infact[a-b]* infact[b] % MOD;

  return tmp * fact[a] % MOD; 

}

int main(){
  ll n,k;
  cin>>n>>k;
  if(n<k){
	cout<<0<<endl;
	return 0;
  }
  n-=k;
  make_factorial();
  cout<<comb(n+k-1,n)<<endl;
  return 0;
}



Measured memory_bytes: 18760
#include <stdio.h>
int main(){
  int S,h,m,s;
  scanf("%d",&S);
  h=S/3600;      
  m=(S%3600)/60;
    s=(S%3600)%60;
    printf("%d:%d:%d\n",h,m,s);
  return 0;
}
   
  

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

#define rep(i, a, b) for(int i = (a); i < int(b); ++i)
#define rrep(i, a, b) for(int i = (a) - 1; i >= int(b); --i)
#define trav(it, v) for(auto &it : (v))
#define all(v) (v).begin(), (v).end()
#define what_is(x) cerr << #x << " is " << x << endl;
#define sz(x) (int)(x).size()

typedef double fl;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;

int main(){
	ios::sync_with_stdio(0);
	ll N, A, B, C, D;
	cin >> N >> A >> B >> C >> D;
	if(A > B)
		swap(A, B);
	B-=A;
	A=0;
	ll lo = 0, hi = 0;
	rep(i,0,N){
		ll cs = N-1-i;
		if(lo-cs*C <= B && hi-cs*C >= B){
			cout << "YES" << endl;
			return 0;
		}
		ll ds = N-1-i;
		if(lo-ds*D <= B && hi-ds*D >= B){
			cout << "YES" << endl;
			return 0;
		}
		lo += C;
		hi += D;
	}
	cout << "NO" << endl;
}

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

int main() {
    string S;
    int K;
    cin >> S >> K;

    char ans;
    for(int i=0; i<S.size(); i++){
        if(S[i] != '1' || K==i+1){
            ans = S[i];
            break;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int ln,s=0,i;
    char a[1009];
    while(1)
    {
        cin>>a;
        ln=strlen(a);
        if(ln==1&&a[0]=='0')
            break;
        for(i=0;i<ln;i++)
            s+= a[i]-'0';
        cout<<s<<endl;
        s=0;
    }
}



Measured memory_bytes: 3040
#include <bits/stdc++.h>
#define endl '\n'

using namespace std;
template<class T, class T2> inline void chkmax(T &x, const T2 &y) { if(x < y) x = y; }
template<class T, class T2> inline void chkmin(T &x, const T2 &y) { if(x > y) x = y; }
const int MAXN = (1 << 20);

int n;
string s;

void read()
{
	cin >> s;
	n = s.size();
}

int psum[MAXN];

void solve()
{
	for(char let = 'a'; let <= 'z'; let++)
	{
		for(int i = 1; i <= n; i++)
			psum[i] = psum[i - 1] + ((s[i - 1] == let) ? 1 : -1);

		pair<int, int> mx = {0, 0};
		for(int i = 2; i <= n; i++)
		{
			chkmin(mx, make_pair(psum[i - 2], i - 2));
			if(psum[i] - mx.first >= 1) 
			{
				cout << mx.second + 1 << " " << i << endl;
				return;
			}
		}
	}

	cout << "-1 -1" << endl;
}

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

	read();
	solve();
	return 0;
}



Measured memory_bytes: 848
S = input()
mod = 10 ** 9 + 7
dp = [0] * 13
dp[0] = 1
for s in S:
    d = [0] * 13
    if s == '?':
        for i in range(13):
            for j in range(10):
                d[(10*i + j) % 13] += dp[i]
    else:
        for i in range(13):
            d[(10*i + int(s)) % 13] += dp[i]
    dp = [x % mod for x in d]
print(d[5] % mod)


Measured memory_bytes: 44948
#include <stdio.h>

int main(void)
{
	int i,j;
	int xjiku,yjiku,count[101][101];
	int tile[101][101];
	char moji[101];
	
	while(scanf("%d %d",&yjiku,&xjiku),xjiku)	//タイル枚数入力
	{	
		for(i=0;i<yjiku;i++)
		{
			scanf("%s",moji);	//タイル配置
			for(j=0;j<xjiku;j++)
			{
				if(moji[j]=='^')		//方向を数字に変換
					tile[i][j]=1;		//  1
				else if(moji[j]=='>')	// 4 2
					tile[i][j]=2;		//  3
				else if(moji[j]=='v')	//0は何も書かれていないタイル
					tile[i][j]=3;
				else if(moji[j]=='<')
					tile[i][j]=4;
				else if(moji[j]=='.')
					tile[i][j]=0;
				count[i][j]=0;
			}
		}
	//出力
		xjiku=0;
		yjiku=0;
		
		while(count[yjiku][xjiku]<2)	//2度通ったとこがあればループする
		{
			if(tile[yjiku][xjiku]==1)
				yjiku--;
			else if(tile[yjiku][xjiku]==2)
				xjiku++;
			else if(tile[yjiku][xjiku]==3)
				yjiku++;
			else if(tile[yjiku][xjiku]==4)
				xjiku--;
			else if(tile[yjiku][xjiku]==0)
				break;
			count[yjiku][xjiku]++;
		}
		if(count[yjiku][xjiku]<2)
			printf("%d %d\n",xjiku,yjiku);
		else
			printf("LOOP\n");
	}
	return 0;
}

Measured memory_bytes: 696
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<math.h>
using namespace std;
int main() {
  int N,K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i=0; i<N; i++) cin >> x[i];
  
  vector<int> ndis(N);
  vector<int> kdis(N);
  for (int i=0; i<N; i++) {
    ndis[i] = abs(x[i]);
    kdis[i] = abs(x[i]-K);
  }
  int sum = 0;
  for (int i=0; i<N; i++) {
    if (ndis[i] < kdis[i]) {
      sum += ndis[i]*2;
    }
    else {
      sum += kdis[i]*2;
    }
  }
  cout << sum << endl;
} 
  

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
A_sum = [0]
for i in range(N):
    A_sum.append(A[i] + A_sum[i])
B_sum = [0]
for i in range(M):
    B_sum.append(B[i] + B_sum[i])   
    
b_idx = 0
for i in range(1, M+1):
    if B_sum[i] <= K:
        b_idx = i
ans = 0
for i in range(N+1):
    if b_idx > 0:
        while A_sum[i] + B_sum[b_idx] > K:
            b_idx -= 1
            if b_idx < 0:
                b_idx = 0
                break
    if A_sum[i] + B_sum[b_idx] <= K:
        ans = max(ans, i+b_idx)
    else:
        break
print(ans)

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

using namespace std;
using ll = long long;

int main() {
	int r, c,k;
	cin >> r >> c>>k;
	ll** field = new ll * [r];
	for (int i = 0;i < r;i++) {
		field[i] = new ll[c];
		for (int j = 0;j < c;j++) {
			field[i][j] = 0;
		}
	}
	for (int i = 0;i < k;i++) {
		int tr, tc, v;
		cin >> tr >> tc >> v;
		field[tr - 1][tc - 1] = v;
	}
	ll*** dp = new ll ** [r + 1];
	for (int i = 0;i <= r;i++) {
		dp[i] = new ll*[c + 1];
		for (int j = 0;j <= c;j++) {
			dp[i][j] = new ll[4];
		}
	}
	for (int i = 0;i <= c;i++) {
		for (int j = 0;j < 4;j++) {
			dp[0][i][j] = -1e9;
		}
	}
	for (int i = 0;i <= r;i++) {
		for (int k = 0;k < 4;k++) {
			dp[i][0][k] = -1e9;
		}
	}
	dp[1][1][0] = 0;
	dp[1][1][1] = dp[1][1][2] = dp[1][1][3] = field[0][0];
	for (int i = 1;i <= r;i++) {
		for (int j = 1;j <= c;j++) {
			if (i == 1 && j == 1)continue;
			dp[i][j][0] = max(dp[i - 1][j][3], dp[i][j - 1][0]);
			for (int k = 1;k < 4;k++) {
				dp[i][j][k] = max(dp[i - 1][j][3] + field[i-1][j-1], max(dp[i][j - 1][k], dp[i][j - 1][k - 1] + field[i-1][j-1]));
			}
			
		}
	}

	cout << dp[r][c][3] << endl;
}

Measured memory_bytes: 565960
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
#include <bitset>
#include <functional>

#define all(x) (x).begin(),(x).end()
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------
int main(void){
    int a, b, m;
    cin >> a >> b >> m;
    vector<int> aa(a), bb(b);


    rep(i, a) cin >> aa[i];
    rep(i, b) cin >> bb[i];

    vector<int> aa2 = aa;
    vector<int> bb2 = bb;
    sort(all(aa2));
    sort(all(bb2));

    int ans = aa2[0] + bb2[0];

    rep(i, m){
        int x, y, c;
        cin >> x >> y >> c;
        x--;
        y--;
        ans = min(ans, aa[x] + bb[y] - c);
    }
    cout << ans << endl;
}   

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

const int maxn=200005;

int n,q;
int a[maxn];

struct node{
    node* c[2];
    int mx1,mx2;
}pool[maxn<<2];int ps;


node* nwnode(){
    node* rt=pool+ps++;
    rt->mx1=rt->mx2=-(1<<20);
    return rt;
}

void pu(node* rt){
    if(rt&&rt->c[0])rt->mx1=max(rt->c[0]->mx1,rt->c[1]->mx1),rt->mx2=max(rt->c[0]->mx2,rt->c[1]->mx2);
}

node* bt(int l,int r){
    int m=(l+r)>>1;
    node* u=nwnode();
    if(l!=r){
        u->c[0]=bt(l,m);
        u->c[1]=bt(m+1,r);
    }
    return u;
}

void chg(node* rt,int cl,int cr,int i,int v){
    int cm=(cl+cr)>>1;
    if(cl==cr){rt->mx1=max(rt->mx1,v);rt->mx2=max(rt->mx2,v-a[cl]);return;}
    else if(i<=cm)chg(rt->c[0],cl,cm,i,v);
    else chg(rt->c[1],cm+1,cr,i,v);
    pu(rt);
}

int qry(node* rt,int cl,int cr,int l,int r,bool x){
    int cm=(cl+cr)>>1;
    if(cl==l&&cr==r)return x?rt->mx1:rt->mx2;
    else if(r<=cm)return qry(rt->c[0],cl,cm,l,r,x);
    else if(l>cm)return qry(rt->c[1],cm+1,cr,l,r,x);
    else return max(qry(rt->c[0],cl,cm,l,cm,x),qry(rt->c[1],cm+1,cr,cm+1,r,x));
}

pair<int,int> p[maxn];

int main(){
    ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    cin>>n;
    int ans=0;
    for(int i=1;i<=n;i++){
        cin>>a[i];
        if(a[i]==0)a[i]=-1;
        else ans++;
        a[i]+=a[i-1];
        //cerr<<a[i]<<endl;
    }
    cin>>q;
    node* rt=bt(0,n);
    chg(rt,0,n,0,0);
    for(int i=1;i<=q;i++)cin>>p[i].first>>p[i].second;
    sort(p+1,p+1+q);
    for(int i=1;i<=q;i++){
        int el=p[i].first,er=p[i].second;
        int h=qry(rt,0,n,0,el-1,1)+a[er]-a[el-1];
        int g=qry(rt,0,n,el-1,er,0)+a[er];
        chg(rt,0,n,er,max(h,g));
    }
    ans-=qry(rt,0,n,0,n,1);
    cout<<ans;
    return 0;
}

Measured memory_bytes: 15360
#include <bits/stdc++.h>
using namespace std;
const int N=1e5+5;
int A[N],n;
multiset<int> last;
int main(){
    scanf("%d",&n);
    for(int i=0;i<n;++i){
        scanf("%d",A+i);
        auto it = last.lower_bound(A[i]);
        if(it == last.begin()){
            last.insert(A[i]);continue;
        }
        last.erase(--it);
        last.insert(A[i]);

    }
    printf("%d\n",last.size());
    return 0;
}


Measured memory_bytes: 5376
#include <bits/stdc++.h>
using namespace std;
#define ii pair<int,int>
#define ll long long

int n;
int arr[200005];
int brr[200005];
priority_queue<ii> pq;

void rage(){
	printf("-1\n");
	exit(0);
}

int main(){
	cin>>n;
	for (int x=0;x<n;x++) cin>>arr[x];
	for (int x=0;x<n;x++) cin>>brr[x];
	
	for (int x=0;x<n;x++){
		if (arr[x]>brr[x]) rage();
		else if (arr[x]<brr[x]) pq.push(ii(brr[x],x));
	}
	
	int pos,temp,diff;
	ll ans=0;
	while (!pq.empty()){
		//printf("%d %d\n",pq.top().first,pq.top().second);
		pos=pq.top().second,pq.pop();
		
		temp=brr[(pos+1)%n]+brr[(pos-1+n)%n];
		diff=brr[pos]-arr[pos];
		
		if (diff<temp) rage();
		ans+=diff/temp;
		brr[pos]=arr[pos]+diff%temp;
		
		if (arr[pos]<brr[pos]){
			pq.push(ii(brr[pos],pos));
		}
	}
	
	printf("%lld\n",ans);
}

Measured memory_bytes: 3956
import java.io.PrintWriter;
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    PrintWriter pw = new PrintWriter(System.out);

    while (true) {
      int h = sc.nextInt();
      int w = sc.nextInt();

      if (h == 0 && w == 0) break;

      IntStream.range(0, h).forEach(i -> {
        IntStream.range(0, w).forEach(j -> {
          pw.print((i + j) % 2 == 0 ? "#" : ".");
        });
        pw.println();
      });
      pw.println();
    }
    pw.flush();
  }
}


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

int main(){
    
    int s;
    cin >> s;
    vector<int> a(1000000);
    a.at(0) = s;
    int i = 1;
    while(1){
        if(s%2 == 0){
            s = s/2;
            auto result = find(a.begin(),a.end(),s);
            if (result != a.end()) {
                cout << i+1 << endl;
                return 0;
            }
            a.at(i) = s;
            i += 1;
        }
        else{
            s = 3 * s + 1;
            auto result = find(a.begin(),a.end(),s);
            if (result != a.end()) {
                cout << i+1 << endl;
                return 0;
            }
            a.at(i) = s;
            i += 1;
        }   
    }
}

Measured memory_bytes: 7172
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"Yes":"No");
}
int main() {
  int n,m;cin>>n>>m;
  for(int i=0;i<m;i++){
    int a;cin>>a;
    n-=a;
  }
  if(n<0){
    n=-1;
  }
  cout<<n<<endl;
  return 0;
}

Measured memory_bytes: 3632
r, c = map(int, input().split())
a = [0]*(c+1)
for _ in range(r):
    v = list(map(int, input().split()))
    s = 0
    for i, e in enumerate(v):
        s+=e
        a[i]+=e
    v.append(s)
    print(*v)
    a[-1]+=s
print(*a)

Measured memory_bytes: 7624
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n,f=0;
    cin>>n;
    while(n)
    {
        if(n%10==7)
            f=1;
        n/=10;
    }
    if(f)
        printf("Yes\n");
    else
        printf("No\n");
    return 0;
}

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

int main(){
  int n;
  cin >> n;
  int a[n];
  rep(i,n){
    cin >> a[i];
  }
  sort(a,a+n);
  //rep(i,n)cout << a[i] << endl;
  double ans;
  double tmp=a[0];
  rep(i,n-1){
    tmp= (double)((double)tmp+a[i+1])/2;
    //cout << tmp << endl;
  }
  ans = tmp;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	@SuppressWarnings("resource")
	public static void main(String args[]) {
		Scanner scanner = new Scanner(System.in);
		String s = scanner.next();
		String answer="";

		for(int i=0; i<s.length();i++) {
			char target = s.charAt(i);
			if(target=='0') {
				answer+='0';
			}
			if(target=='1') {
				answer+='1';
			}
			if(target=='B') {
				if(answer != null && answer.length() > 0){
					answer = answer.substring(0, answer.length()-1);
				}
			}
		}
		
		System.out.println(answer);

	}
}

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

int main(){
    string s;
    cin >> s;
    if(s == "Sunny"){
        cout << "Cloudy" << endl;
    }else if(s == "Cloudy"){
        cout << "Rainy" << endl;
    }else{
        cout << "Sunny" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
use proconio::input;

fn main() {
    input! {
        n: u64,
        mut x: usize,
        m: usize,
    }

    let mut dp = vec![0u64; m];
    let mut i = (0..).peekable();
    while i.next().unwrap() < n {
        dp[x] += 1;
        x = x * x % m;
        if dp[x] == 2 {
            break;
        }
    }

    if i.peek().unwrap() < &(n - 1) {
        let per = dp.iter().filter(|&x| x == &2).count() as u64;
        let rem = n - i.peek().unwrap();
        let add = rem / per;
        for j in 0..m {
            if dp[j] == 2 {
                dp[j] += add;
            }
        }
        let ci = *i.peek().unwrap() + add * per;
        i = (ci..).peekable();

        while i.next().unwrap() < n {
            dp[x] += 1;
            x = x * x % m;
        }
    }

    let res = dp
        .into_iter()
        .enumerate()
        .map(|(i, x)| i as u64 * x)
        .sum::<u64>();
    println!("{}", res);
}


Measured memory_bytes: 2844
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void solution(int [] arr) {
		int store1[] = new int[2];
		int k=0;
		int temp [] = new int[arr.length];
		for(int i=0;i<arr.length;i++) {
			temp[i] = arr[i];
		}
		Arrays.sort(temp);
		if(Arrays.equals(temp, arr)) {
			System.out.println("YES");
			return;
		}
		for(int i=0;i<arr.length-1;i++) {
			if(arr[i]>arr[i+1]) {
				store1[k]=i;
				k++;
				if(k==2) {
					break;
				}
			}
		}
		store1[1]++;
		int temp1 = arr[store1[0]];
		arr[store1[0]] = arr[store1[1]];
		arr[store1[1]] = temp1;
		if(Arrays.equals(arr, temp)) {
			System.out.println("YES");
			
		}
		else {
			System.out.println("NO");
		}
	}
	
	
	public static void main(String args []) {
		Scanner obj = new Scanner(System.in);
		int n = obj.nextInt();
		int a [] = new int [n];
		for(int i=0;i<a.length;i++) {
			a[i]= obj.nextInt();
		}
		solution(a);
		
	}
}


Measured memory_bytes: 21844
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e18
#define flush fflush(stdout);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>
ll modpower(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b>>=1;
	}
	return res;
}
//-------------------------------Template--Above------------------------------------------------


int main()
{
	boost
	ll n,m;
	cin>>n>>m;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	sort(a,a+n);
	pair<ll,ll> p[m];
	for(ll i=0;i<m;i++)
	{
		ll b,c;
		cin>>b>>c;
		p[i]=mp(c,b);
	}
	sort(p,p+m,greater<pair<ll,ll> >());
	for(ll i=0,j=0;i<m&&j<n;i++)
	{
		ll k,flag=0;
		for(k=j;k<n&&k<j+p[i].se;k++)
		{
			if(a[k]<p[i].fi)
			{
				//debug1(a[k]);
				a[k]=p[i].fi;
			}
			else
			{
				flag=1;
				break;
			}
		}
		if(flag==1)
			break;
		j=k;
	}
	ll sum=0;
	for(ll i=0;i<n;i++)
		sum+=a[i];
	cout<<sum<<endl;
	return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;
ll mod = pow(10,9) + 7;
int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}
char upper(char c){
	return c-0x20;
}
char lower(char c){
	return c+0x20;
}
int main() {
	ll n; cin >> n;
	ll p = 1;
	rep(i,n){
		p = (p*(i+1))%mod;
	}
	cout << p << endl;
}

Measured memory_bytes: 256
n, h, w = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
count = 0

for i in range(n):
    hight = ab[i][0] // h
    width = ab[i][1] // w
    if hight >= 1 and width >= 1:
        count += min(hight, width)

print(count)

Measured memory_bytes: 3188
from collections import Counter


def main():
    N = int(input())
    A = [input() for _ in range(N)]

    C = Counter(A)
    most_c = C.most_common()
    max_num = most_c[0][1]
    ANS = []
    for c in most_c:
        if c[1] < max_num:
            break
        ANS.append(c[0])
    ANS.sort()
    for ans in ANS:
        print(ans)


if __name__ == '__main__':
    main()


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

const int mod = 1000000007;

struct mint {
    ll x;

    mint(ll x = 0) : x((x % mod + mod) % mod) {}

    mint operator-() const { return mint(-x); }

    mint &operator+=(const mint a) {
      if ((x += a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator-=(const mint a) {
      if ((x += mod - a.x) >= mod) x -= mod;
      return *this;
    }

    mint &operator*=(const mint a) {
      (x *= a.x) %= mod;
      return *this;
    }

    mint operator+(const mint a) const {
      mint res(*this);
      return res += a;
    }

    mint operator-(const mint a) const {
      mint res(*this);
      return res -= a;
    }

    mint operator*(const mint a) const {
      mint res(*this);
      return res *= a;
    }

    mint pow(ll t) const {
      if (!t) return 1;
      mint a = pow(t >> 1);
      a *= a;
      if (t & 1) a *= *this;
      return a;
    }

    mint inv() const {
      return pow(mod - 2);
    }

    mint &operator/=(const mint a) {
      return (*this) *= a.inv();
    }

    mint operator/(const mint a) const {
      mint res(*this);
      return res /= a;
    }
};

const int N = 2000020;
mint table[N];

void init() {
  table[0] = table[1] = 1;
  for (ll i = 2; i < N; i++) {
    table[i] = table[i - 1] * i;
  }
}

mint nCr(int n, int r) {
  return table[n] / table[r] / table[n - r];
}

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

  init();
  int n = (int)s.size();

  mint ans = 0;
  for (int i = 0; i <= k; i++) {
    mint tmp = mint(26).pow(k - i);
    tmp *= mint(25).pow(i) * nCr(i + n - 1, n - 1);
    ans += tmp;
  }
  cout << ans.x << '\n';
}


Measured memory_bytes: 20964
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll ans=1;
  ll tmp=1;
  while(n!=1){
    
    
    n/=2;
    tmp*=2;
    ans+=tmp;
    
  }
  
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = x; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<25
#define pb push_back

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int,int> pii;
typedef pair<long,long> pll;
typedef long long ll;

double dist(pii a, pii b){
    return sqrt((a.first-b.first)*(a.first-b.first)+(a.second-b.second)*(a.second-b.second));
}

class UnionFind{
private:
    vi par;
    vi rank;
    int find(int x){
        if (par[x] == -1) {
            return x;
        } else {
            return par[x] = find(par[x]);
        }
    }
public:
    UnionFind(int size)
        :par(size, -1)
        ,rank(size, 0)
    {
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if (x==y) return;

        if (rank[x] < rank[y]) {
            par[x] = y;
        } else {
            par[y] = x;
            if (rank[x] == rank[y]) rank[x]++;
        }
    }

    bool same (int x, int y) {
        return find(x) == find(y);
    }
};

struct edge {
    int from, to;
    double length;
    bool operator <(const edge& e) const {
        return length < e.length;
    }
};

int main()
{
    int n, m;
    cin >> n >> m;
    vector<pii> pile(n+1);
    REP(i, 1, n+1){
        int x, y;
        cin >> x >> y;
        pile[i] = {x, y};
    }
    priority_queue<edge> que;
    rep(i, m){
        int p, q;
        cin >> p >> q;
        que.push({p, q, dist(pile[p], pile[q])});
    }
    UnionFind u(n+1);
    double cost = 0;
    while(!que.empty()){
        edge e = que.top(); que.pop();
        if (!u.same(e.from, e.to))
            u.unite(e.from, e.to);
        else
            cost += e.length;
    }
    printf("%.3f\n", cost);
    return 0;
}

Measured memory_bytes: 1880
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<set>
#include<tuple>
#include<cmath>
#include<iomanip>


using namespace std;
typedef long long ll;
typedef vector<ll> v;
typedef vector<vector<ll>> vv;


#define MOD 1000000007
#define INF 1001001001
#define MIN -1001001001
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back
#define PF push_front
#define all(x) (x).begin(),(x).end()


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

ll calc(ll x, ll n){
    if (x == 0)return n;

    ll c = x;
    ll ones = 0;
    rep(i,0,20){
        if(((c>>i) % 2) == 1){
            ones++;
        }
    }
    return calc(x%ones,n+1);
}

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

    reverse(all(X));
    ll ones = 0;

    rep(i,0,N){
        if(X[i] == '1')ones++;
    }
    ll sum_a = 0,sum_b = 0;
    ll a,b;
    
    if(ones == 1){
        a = 2; b= INF;
    }
    else{
        a = ones + 1;b = ones - 1;
    }
    ll now_a=1,now_b=1;
    rep(i,0,N){
        if(X[i] == '1'){
            sum_a += now_a;
            sum_a %= a;
            sum_b += now_b;
            sum_b %= b;
        }
        now_a *= 2;
        now_a %= a;
        now_b *= 2;
        now_b %= b;
    }

    now_a=1,now_b=1;
    v ans;
    rep(i,0,N){
        if(X[i] == '1'){
            if(b==INF)ans.push_back(0);
            else ans.push_back(calc((sum_b - now_b + b)%b, 1));
        }
        else{
            ans.push_back(calc((sum_a + now_a + a)%a, 1));
        }
        now_a *= 2;
        now_a %= a;
        now_b *= 2;
        now_b %= b;
    }
    
    rep(i,0,N)cout<<ans[N-1-i]<<endl;
    return 0;
}

Measured memory_bytes: 5524
//
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios::sync_with_stdio(false)
using namespace std;

string gs(char x){
    string s(1,x);
    return s;
}

int main()
{
	speed;
	
	ll n,k;
	cin>>n>>k;
	ll arr[n+1];
	ll mmin=INT_MAX;
	for(ll i=1;i<=n;i++)
	{
		cin>>arr[i];
		mmin=min(mmin,arr[i]);
	}

	ll ind;
	for(ll i=1;i<=n;i++)
	{
		if(arr[i]==mmin)
		{
			ind=i;
			break;
		}
	}

	ll last=-1;
	ll ans=0;
	float fm=ceil((float)(ind-1)/(k-1));
	ll m=(ll)fm;
	ans+=m;
	last=(k-1)*m+1;
	for(ll i=last+1;i<=n;i++)
	{
		if(arr[i]==mmin)
		{
			last=i;

		}
		else if(i>last)
		{
			ans++;
			last+=(k-1);
		}
		
	}

	cout<<ans;






	
	return 0;
}

Measured memory_bytes: 1024