akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <algorithm>
int n, k, x, kk, t;
long long ans;
long long v[52];
long long f[502];
int main() {
	scanf("%d%d", &n, &k);
	for (int i = 0; i < n; i++) {
		scanf("%lld", v + i);
	}
	for (int i = 0; i <= n; i++) {
		for (int j = i; j <= n; j++) {
			for (int l = 0; l < 502; l++) {
				f[l] = 0;
			}
			kk = k - (n - j + i);
			t = 0;
			x = 0;
			if (kk < 0)x = 0;
			else {
				for (int l = 0; l < i; l++) {
					x += v[l];
					f[t] = v[l];
					t++;
				}
				for (int l = j; l < n; l++) {
					x += v[l];
					f[t] = v[l];
					t++;
				}
				std::sort(f, f + 500);
				t = 0;
				while (kk) {
					if (f[t] < 0)x -= f[t];
					t++; kk--;
				}
				if (x > ans) {
					ans = x;
				}
			}
		}
	}
	printf("%lld\n", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define Inf 0x3f3f3f3f
#define rg register
#define pii pair<int, int>
#define mp(x, y) make_pair(x, y)
using namespace std;
typedef long long ll;
const int Maxn = 1e5 + 5;
typedef int arr[Maxn];
//ll Add(ll x, ll y) { return (x += y) >= Mod ? x - Mod : (x < 0 ? x + Mod : x); }
ll min(ll x, ll y) { return x < y ? x : y; }
ll max(ll x, ll y) { return x > y ? x : y; }
inline ll read()
{
	rg ll res = 0, sign = 1;
	rg char ch = getchar();
	while (!isdigit(ch))
	{
		if (ch == '-')
			sign = -1;
		ch = getchar();
	}
	do
	{
		res = (res << 3) + (res << 1) + (ch ^ 48);
		ch = getchar();
	} while (isdigit(ch));
	return res * sign;
}
ll n;
deque<int> ans;
int main()
{
	rg ll cnt = 1;
	cin >> n;
	if (n == 1)
	{
		printf("2\n1 1\n");
		return 0;
	}
	while (cnt <= n)
		cnt <<= 1;
	cnt >>= 1;
	rg int i;
	ans.push_front(i = 1);
	n ^= cnt;
	cnt >>= 1;
	while (cnt)
	{
		if (n & cnt)
			ans.push_back(++i);
		if (cnt != 1)
			ans.push_front(++i);
		cnt >>= 1;
	}
	ans.push_back(++i);
	cout << 2 * i << '\n';
	for (int j = 1; j <= i; j++)
		cout << j << ' ';
	while (!ans.empty())
	{
		cout << i - ans.front() + 1 << ' ';
		ans.pop_front();
	}
	putchar('\n');
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  long long n, a, b;
  cin >> n >> a >> b;
  
  if((b - a) % 2 == 0){
    cout << (b - a) / 2 << '\n';
    return 0;
  }
  
  cout << min(a + (b - a - 1) / 2, (n - b + 1) + (b - a - 1) / 2) << '\n';
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define hell  1000000007
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define pb   push_back


int main()
{
	ios;
	char c;
	cin>>c;
	if(int(c)>=65 && int(c)<97)cout<<'A';
	else cout<<'a';
}

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

using namespace std;
using ll = long long;
// #define int ll
using PII = pair<ll, ll>;

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

template<typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template<typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
template<typename T> bool IN(T a, T b, T x) { return a<=x&&x<b; }
template<typename T> T ceil(T a, T b) { return a/b + !!(a%b); }

template<typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T,typename... Ts>
auto make_v(size_t a,Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...));
}
template<typename T,typename V> typename enable_if<is_class<T>::value==0>::type
fill_v(T &t, const V &v) { t=v; }
template<typename T,typename V> typename enable_if<is_class<T>::value!=0>::type
fill_v(T &t, const V &v ) { for(auto &e:t) fill_v(e,v); }

template<class S,class T>
ostream &operator <<(ostream& out,const pair<S,T>& a) {
    out<<'('<<a.first<<','<<a.second<<')'; return out;
}
template<class T>
ostream &operator <<(ostream& out,const vector<T>& a){
    out<<'[';
    for(const T &i: a) out<<i<<',';
    out<<']';
    return out;
}
template<class T>
ostream &operator <<(ostream& out, const set<T>& a) {
    out<<'{';
    for(const T &i: a) out<<i<<',';
    out<<'}';
    return out;
}
template<class T, class S>
ostream &operator <<(ostream& out, const map<T,S>& a) {
    out<<'{';
    for(auto &i: a) out<<i<<',';
    out<<'}';
    return out;
}

int dx[] = {0, 1, 0, -1}, dy[] = {1, 0, -1, 0}; // DRUL
const int INF = 1<<30;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;

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

    ll n;
    cin >> n;
    vector<ll> x(n), y(n);
    REP(i, n) cin >> x[i] >> y[i];

    map<PII,set<ll>> mp;
    REP(i, n) REP(j, n) {
        if(i == j) continue;
        mp[{x[i]-x[j], y[i]-y[j]}].insert(i);
    }

    ll ret = n;
    for(auto p: mp) chmin(ret, n-(ll)p.second.size());
    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 640
def factorization(n):
  arr = []
  temp = n
  for i in range(2, int(-(-n**0.5//1))+1):
    if temp%i==0:
      cnt=0
      while temp%i==0:
        cnt+=1
        temp //= i
      arr.append([i, cnt])

  if temp!=1:
    arr.append([temp, 1])

  if arr==[]:
    arr.append([n, 1])

  return arr

n = int(input())
e = factorization(n)
cnt = 0
if n != 1:
  for i in range(len(e)):
    curr_num = e[i][1]
    curr_val = 1
    while curr_val * (curr_val + 1) / 2 < curr_num:
      curr_val += 1
    if curr_val * (curr_val + 1) / 2 > curr_num:
      curr_val -= 1
    cnt += curr_val

print(cnt)

Measured memory_bytes: 9500
N = int(input())
A = map(int, input().split())
MOD = 1000000007
ans = 1
cnt = [3 if i == 0 else 0 for i in range(N+1)] #分布を作る

for a in A:
  ans = ans * cnt[a] % MOD
  if ans == 0:
    break
  cnt[a] -= 1 #分布状態の変化
  cnt[a+1] += 1
  
print(ans)

Measured memory_bytes: 10764
my $N = <>;
my @A = split(/ /, <>);
my @AA;
foreach (@A) {
        chomp($_);
        push(@AA, int($_));
}
@AA = sort {$b <=> $a} @AA;
my $i = 0;
my $alice = 0;
my $bob = 0;
foreach (@AA) {
        if ($i%2 == 0) {
                $alice += $_;
        } else {
                $bob += $_;
        }
        $i++;
}
print $alice - $bob;

Measured memory_bytes: 512
#!/usr/bin/env python3

from itertools import permutations
import numpy as np

HUGE = 10 ** 18

def main():
    n, m, r = map(int, input().split())
    togo = list(map(int, input().split()))
    adj_mat = [[HUGE for j in range(n)] for i in range(n)]
    for i in range(n):
        adj_mat[i][i] = HUGE
    for i in range(m):
        a, b, c = map(int, input().split())
        a0 = a - 1
        b0 = b - 1
        adj_mat[a0][b0] = c
        adj_mat[b0][a0] = c
    adj_mat = np.array(adj_mat)

    wf(adj_mat, n)

    res = HUGE
    for way in permutations(togo):
        assert len(way) > 1
        x = 0
        for i in range(len(way) - 1):
            x += adj_mat[way[i] - 1][way[i + 1] - 1]
        res = min(res, x)

    print(res)

def wf(adj_mat, n):
    for k in range(n):
        for i in range(n):
            adj_mat[i, :] = np.minimum(adj_mat[i, :], adj_mat[i][k] + adj_mat[k, :])

if __name__ == "__main__":
    main()


Measured memory_bytes: 13248
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <tuple>
#include <stack>
#include <bitset>
using namespace std;



typedef unsigned long ul;
typedef unsigned long long ull;
typedef long long ll;
typedef vector<ll> vint;
typedef vector<vector<ll>> vvint;
typedef pair<ll,ll> pint;
typedef vector<pint> vpint;

#define rep(i,n) for(ll i=0;i<n;i++)
#define repf(i,f,n) for(ll i=f;i<n;i++)
#define repr(i,n) for(ll i=n-1;i>=0;i--)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define pf push_front
#define fi first
#define se second
#define INT_MAX 2147483647
#define vmax(vec) *max_element(vec.begin(), vec.end())
#define vmin(vec) *min_element(vec.begin(), vec.end())
#define vsort(vec) sort(vec.begin(), vec.end())



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



// int binary_search(int key){
//  //isOKを満たす要素のうち最小のインデックスを返す。（要ソート）
//   int left = -1;
//   int right = N;
//
//   while(right - left > 1){
//     int mid = left + (right - left)/2;
//
//     if(isOK(mid, key)) right=mid;
//     else left=mid;
//   }
//
//   return right;
// }




int main() {

  ll N;
  cin >> N;

  vint a(5);
  rep(i,5){
    cin >> a[i];
  }

  ll mn = vmin(a);


  cout << (N-1)/mn + 5 << endl;

}

















//


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

int main()
{
	int n, m;
	cin >> n >> m;
	int l1, r1,l2,r2;
	cin >> l1 >> r1;
	m--;
	while (m--)
	{
		cin >> l2 >> r2;
		if (l2 > l1) l1 = l2;
		if (r2 < r1) r1 = r2;
	}
	if (r1 < l1) cout << 0<<endl;
	else {
		cout << r1 - l1 + 1 << endl;
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
const ll md = 1000000007;
vector<ll> fact(1e6 + 7), invfact(1e6 + 7);

ll fn(ll a, ll r, ll n, ll mod = md) {
    ll res = 1, x = r%mod;
    ll ans = 0;
    while(n) {
        if(n&1) ans = (x*ans + res)%mod;
        res = ((res*x)%mod + res%mod)%mod;
        x = (x*x)%mod;
        n = n/2;
    }
    ans = (ans*a)%mod;
    return ans;
}

ll nCr(ll n, ll r) {
    if(r == 0) return 1;
    ll num = fact[n];
    ll den = (invfact[r] % md *invfact[n-r] % md)%md;
    return (num*den)%md;
}

ll mul(ll a, ll b, ll mod = md) {
    ll res = (a%mod * b%mod)%mod;
    return res;
}

ll mulm(ll a, ll b, ll mod = md) {
    ll r = 0;
    a %= mod;
    while (b) {
        if (b & 1) r = (r+a)%mod;
        a = (a+a)%mod;
        b = b/2;
    }
    r %= mod;
    return r;
}

ll power(ll x, ll n, ll mod = md) {
    ll res = 1;
    x %= mod;
    while (n) {
        if (n & 1)  res = (res*x)%mod;
        n = n/2;
        x = (x*x)%mod;
    }
    return res;
}

ll power2(ll x, ll n) {
    ll res = 1;
    while (n)  
    {  
        if (n & 1)  res = (res*x);  
        n = n/2; 
        x = (x*x);  
    }  
    return res;
}

bool is_prime(ll x) {
    if(x == 1 || x == 0) return false;
    for(int i=2; i*i <= x; i++) {
        if(x%i == 0) return false;
    }
    return true;
}

ll compgcd(ll n, vector<ll> const &primes) { 
    ll res = n; 
    for (ll i=0; primes[i]*primes[i] <= n; i++) {
        if (n % primes[i]== 0) { 
            res -= (res / primes[i]); 
            while (n%primes[i]== 0) {
               n/=primes[i]; 
            }
        } 
    } 
    if (n > 1) {
       res -= (res / n); 
    }
    return res; 
} 

void sieve(vector<bool> &prime, vector<ll> &primes, ll lim) {
    for(int i = 2; i*i <= lim; i++) {
        if(prime[i]) {
            for(int j = 2; j*i <= lim; j++) {
                prime[j*i] = false;
            }
        }
    }
    for(int i = 2; i <= lim; i++) {
        if(prime[i]) {
            primes.push_back(i);
        }
    }
}

void sieveGCD(ll lim, vector<ll> &tab, vector<ll> const &primes) {
    for(int  i = 1; i <= lim; i++) {
        tab[i] = i;
    }
    for(int i = 0; i<primes.size() && primes[i] <= lim; i++) {
        tab[primes[i]] = primes[i]-1;
        for(int j = 2; primes[i]*j <= lim; j++) {
            tab[primes[i]*j] = (tab[primes[i]*j]/primes[i])*(primes[i]-1);
        }
    }
}

int main() 
{ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n;
    bool good = true;
    cin >> n;
    vector<ll> a(n);
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for(int i = n-2; i >= 0; i--) {
        if(a[i] > a[i+1]) {
            a[i]--;
        }
    }
    for(int i = 0; i < n-1; i++) {
        if(a[i] > a[i+1]) {
            good = false;
            break;
        }
    }
    if(good) {
        cout << "Yes\n";
    } else {
        cout << "No\n";
    }
    return 0; 
}

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

struct Benri { Benri() { std::cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(12);}} benri;

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using vll = vector<long long>;
using pll = pair<ll, ll>;
template <typename T> using PQ = priority_queue<T>;
template <typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define mp make_pair
#define F first
#define S second

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

constexpr long long MOD = 1000000007;
constexpr long long MOD2 = 998244353;
constexpr double EPS = 1e-10;
constexpr int INF = 1001001001;
constexpr ll LINF = 1001001001001001001ll;


vector< int > z_algorithm(const string &s) {
    vector< int > prefix(s.size());
    for (int i = 1, j = 0; i < s.size(); i++) {
        if (i + prefix[i - j] < j + prefix[j]) {
            prefix[i] = prefix[i - j];
        } else {
            int k = max(0, j + prefix[j] - i);
            while (i + k < s.size() && s[k] == s[i + k]) ++k;
            prefix[i] = k;
            j = i;
        }
    }
    prefix[0] = (int) s.size();
    return prefix;
}


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

    rep(i,N) {
        vi z = z_algorithm(S.substr(i));
        for (int j = i + 1; j < N; j++) {
            if (i + z[j - i] <= j) chmax(ans, z[j - i]);
        }
    }

    cout << ans << endl;

}




Measured memory_bytes: 384
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
    int n,x;
    cin>>n;
    double sum=0.0;
    for(int i=0;i<n;i++)
    {
        cin>>x;
        sum+=(1.0/x);
    }
    sum=1.0/sum;
    cout<<setprecision(16)<<sum<<"\n";
    
}

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

int main() {
  int n;
  cin >> n;
  int odd = 0;
  for (int i = 0; i < n; i++) {
    int a;
    cin >> a;
    if (a % 2 == 1) odd++;
  }
  string ans = "YES";
  if (odd % 2 != 0) ans = "NO";
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <unordered_map>
#include <map>
#include <unordered_set>
#include <set>
#include <vector>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <stack>
#include <list>
#include <array>
#include <deque>
#include <bitset>
typedef long long ll;
using namespace std;
#define trace(x) cerr << #x << " is " << x << endl;

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n;
    cin >> n;
    vector<int> a(n);
    unordered_map<ll, ll> s;
    unordered_map<ll, ll> diff;
    for (int i = 0; i < n; i++) {
        cin >> a[i];
        s[a[i] + i]++;
        diff[i - a[i]]++;
    }
    ll res = 0;
    for (auto it : diff) {
        if (s.count(it.first)) res += s[it.first] * it.second;
    }
    cout << res <<endl;
    return 0;
}

Measured memory_bytes: 19392
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define int long long
#define ll long long
using namespace std;
signed main(){
    int a;
    cin>>a;
    cout<<a+a*a+a*a*a<<endl;
    return 0;
}

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

long long dp[55][2505], ans;
int n, a, m;
int main() {
	scanf("%d%d", &n, &a); 
	dp[0][0] = 1; 
	m = a * n;
	for (int t, i = 1; i <= n; i++) {
		scanf("%d", &t);
		for (int j = i; j; --j)
			for (int k = m; k >= t; --k)
				dp[j][k] += dp[j-1][k-t];
	} 
	for (int i = 1; i <= n; ++i) ans += dp[i][i*a];
	printf("%lld\n", ans);
	return 0;
}

Measured memory_bytes: 1280
#include<iostream>
#include<cstdio> 
//#include<vector>
//#include<string>
//#include<cstring>
//#include<algorithm> 
#define max(a,b) (a>b?a:b)
#define min(a,b) (a>b?b:a)
#define  endl '\n'
#define all(s) s.begin(),s.end()
#define lowbit(x) (x&-x)
#define fi first
#define se second 
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int inf=0x3f3f3f3f; 
const int N=2e5+10;
int main()
{
	ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
	int n,m,q,k;
	cin>>n;
	ll ans=0;
	int f=n/500;
	ans+=f*1000;
	n=n%500;
	f=n/5;
	ans+=5*f;
	cout<<ans;

}

Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.*;
import java.util.stream.Collectors;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    BigInteger result = BigInteger.ZERO;
    BigInteger max = BigInteger.ZERO;
    for (int i = 0; i < n; i++) {
      BigInteger a = new BigInteger(sc.next());
      if (max.compareTo(a) < 0) {
        max = a;
      } else {
        result = result.add(max.subtract(a));
      }
    }
    System.out.println(result);
  }
}


Measured memory_bytes: 49788
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.OutputStreamWriter;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
    static PrintWriter out;
    static CF_Reader in;

    public static void main(String[] args) throws IOException {
        out = new PrintWriter(new OutputStreamWriter(System.out));
        in = new CF_Reader();

        int n = in.intNext();
        int m = in.intNext();
        int[] nums = new int[n];
        Arrays.fill(nums, -1);
        if (solve(m, nums) == -1) out.println(-1);
        out.close();
    }

    static int solve(int m, int[] nums) throws IOException {
        for (int i = 0; i < m; i++) {
            int x = in.intNext()-1;
            int y = in.intNext();
            if (nums[x] != -1 && nums[x] != y) return -1;
            nums[x] = y;
        }
        if (nums.length > 1 && nums[0] == 0) return -1;
        if (nums.length > 1 && nums[0] == -1) nums[0] = 1;
        for (int num: nums) out.print((num == -1) ? 0 : num);
        return 0;
    }

    static class CF_Reader {
        BufferedReader br;
        StringTokenizer st;

        public CF_Reader() throws IOException {
            br = new BufferedReader(new InputStreamReader(System.in));
        }

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

        long longNext() throws IOException {
            return Long.parseLong(next());
        }

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

        double doubleNext() throws IOException {
            return Double.parseDouble(next());
        }

        char charNext() throws IOException {
            return next().charAt(0);
        }

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


Measured memory_bytes: 21332
/*
BY: SAFWAAN SHAIKH
PROBLEM:
KEY IDEAS: 
TIME COMPLEXITY: 
*/

#define r(x) do{while((x=getchar())<'0'); for(x-='0'; '0'<=(_=getchar()); x=(x<<3)+(x<<1)+_-'0');}while(0)
#include <bits/stdc++.h>
#include <cmath>
#include <fstream>
#define f first
#define endl "\n"
#define s second
#define pb push_back
#define ms(a,b) memset(a,b,sizeof(a))
#define fori(a,b) for(int i=a;i<b;i++)
#define forj(a,b) for(int j=a;j<b;j++)
typedef long long ll;
using namespace std;
typedef vector<int> vi;
typedef pair<int,int> pii;
char _;
int ans=0;
int n;
int nums[102];
int main(){
//	freopen("problemname.in", "r", stdin);
//  freopen("problemname.out", "w", stdout);
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>n;
	for(int i=0;i<n;i++)cin>>nums[i];
	    for (int i = 0; i < n - 2; i++) { 
        for (int j = i + 1; j < n - 1; j++) { 
            for (int k = j + 1; k < n; k++) {
				int maxi = max({nums[i],nums[j],nums[k]});	
				if(nums[i]==nums[j] || nums[j]==nums[k] || nums[k]==nums[i]) continue;
				if(nums[i]==maxi){
					if(nums[j]+nums[k] > nums[i])ans++;
					continue;
				}
				else if(nums[j]==maxi){
					if(nums[i]+nums[k] > nums[j])ans++;
					continue;
				}
				if(nums[i]+nums[j] > nums[k]) ans++;
            } 
        } 
    }
	   cout << ans << endl;	
	return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <vector>
#include <list>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <tuple>
using namespace std;
typedef long long ll;

int main(){

    int n, m; cin >> n >> m;

    int p[m], y[m];
    for(int i=0; i<m; i++){
        cin >> p[i] >> y[i];
    }

    vector<vector<pair<int, int>>> vec_y;
    vec_y.resize(n);


    for(int i=0; i<m; i++){
        vec_y[p[i]-1].push_back(make_pair(y[i], i));
    } 
    for(int i=0; i<n; i++){
        if(vec_y[i].size() != 0){
            sort(vec_y[i].begin(), vec_y[i].end());
        }
    }

    vector<tuple<int, int, int>> vec_ans;

    for(int i=0; i<n; i++){
        for(int j=0; j<vec_y[i].size(); j++){
            // cout << vec_y[i][j].first << " " << vec_y[i][j].second << endl;
            vec_ans.push_back(make_tuple(vec_y[i][j].second, i+1, j+1));
        }
    }

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

    for(int i=0; i<m; i++){
        cout << setfill('0') << setw(6) << get<1>(vec_ans[i]);
        cout << setfill('0') << setw(6) << get<2>(vec_ans[i]) << endl;
    }



    return 0;
}

Measured memory_bytes: 9076
#![allow(non_snake_case)]

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

fn main() {
    let N: usize = read();
    let mut vec: Vec<(i32, i32)> = vec![];
    for _ in 0..N {
        let x: i32 = read();
        let l: i32 = read();
        vec.push((x, l));
    }
    vec.sort_by_key(|x| x.0 + x.1);
    let (x1, l1) = vec[0];
    let mut minus: usize = 0;
    let mut right = x1 + l1;
    for &(x, l) in &vec[1..] {
        if x - l >= right {
            right = x + l;
        } else {
            minus += 1;
        }
    }
    println!("{}", N - minus);
}


Measured memory_bytes: 3260
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <string>
using namespace std;
int main() {
	string str1, str2;
	cin >> str1 >> str2;
	bool flag = true;
	vector<vector<int> > c1,c2;
	for (char a = 'a'; a <= 'z'; ++a) {
		vector<int> tmp1, tmp2;
		std::string::iterator itr=str1.begin();
		while (true)
		{
			itr = find(itr+1, str1.end(), a);
			if (itr == str1.end())break;
			tmp1.push_back(distance(str1.begin(), itr));
		}
		itr = str2.begin();
		while (true)
		{
			itr = find(itr+1, str2.end(), a);
			if (itr == str2.end())break;
			tmp2.push_back(distance(str2.begin(), itr));
		}
			c1.push_back(tmp1);
			c2.push_back(tmp2);
	}
	for (int i = 0; i < c1.size(); ++i) {
		if (find(c1.begin(),c1.end(),c2[i])==c1.end()) {
			flag = false;
		}
	}
	if (flag) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 3568
N=int(input())
b=list(map(int,input().split()))
flg=True

ans = [0 for i in range(N)]
for i in range(N):
    for j in range(N-i):
        if b[N-i-j-1]==N-i-j:
            del b[N-i-j-1]
            #print(b)
            ans[N-i-1]=N-i-j
            break

for a in ans:
    if a==0:
        flg=False
        break
#print(ans)
if flg:
    for a in ans:
        print(a)
else:
    print(-1)

Measured memory_bytes: 3064
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define dump(x) cout << x << endl
typedef int64_t Int;

using namespace std;
using Graph = vector<vector<Int>>;

const double pi = M_PI;
const Int MOD = 1000000007;

int main() {
    int n, ans = 1;
    cin >> n;
    int h[n];
    for (int i = 0; i < n; i++) {
        cin >> h[i];
    }

    for (int i = 1; i < n; i++) {
        bool flag = true;
        for (int k = i - 1; k >= 0; k--) {
            if (h[i] < h[k]) {
                flag = false;
                break;
            }
        }

        if (flag) {
            ans++;
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define uint unsigned long long
#define double long double
#define rep(i, n) for (int i = 0; i < (n); i++)
#define reps(i, n) for (int i = 1; i <= (n); i++)
int gcd(int a, int b) {
    while (b) { swap(a %= b, b); }
    return a;
}
int lcm(int a, int b) {
    return a / gcd(a, b) * b;
}
int sigma(int n){
    int sum=0;
    for (int i=1; i<=(n); i++){
        sum+=i;
    }
    return sum;
}
int distance(int yo,int xo,int yi,int xi){
    return (yo-yi)*(yo-yi)+(xo-xi)*(xo-xi);
}
signed main(){
    int A,B,K;
    cin >> A >> B >> K;
    if((A-K)>0){
        cout << A - K << ' ' << B << endl;
    }
    else if((B- (K - A))>0){
        cout << 0 << ' ' << B - (K-A) << endl;
    }
    else{cout << 0 << ' ' << 0 << endl;}
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<unordered_set>
#include<cmath>
#include<tuple>
#include<numeric>
#include<iterator>
#include<set>
#include<unordered_map>
#include<map>
#include<queue>
#include<cstring>
#include<stdio.h>
#include<fstream>


#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define foru(i , a , b) for(ll i = a ; i < b ; i++)
#define ford(i , a , b) for(ll i = a ; i >= b ; i--)
#define dbg(a) cerr << #a << ": " << a << "\n";
#define ain(a , n) for(ll i = 0 ; i < n ; i++) cin >> a[i]
#define aout(a , n) for(ll i = 0 ; i < n ; i++) cout << a[i] << " "
#define M 1000000007
#define mp make_pair
#define mt make_tuple
#define cend cout << "\n"
#define all(x) x.begin() , x.end()
#define aout2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cout << a[i][j] << " ";} cout << endl;}
#define ain2(a , n , m) for(ll i = 0 ; i < n ; i++){for(ll j = 0 ; j < m ; j++){cin >> a[i][j];}}
#define ff first
#define ss second

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector <int> vi;
typedef vector <ll> vll;
typedef vector <char> vch;
typedef vector <string> vs;

/*----------------------------- # --- MATH ALGORITHMS --- # -----------------------------*/

template <class T> T gcd(T a , T b){ while(a != 0){T temp = a; a = b % a; b = temp;}return b;}
template <class T> T egcd(T a , T b , T &x , T &y){T gcd , xt , yt;if(a == 0){gcd = b;x = 0 , y = 1;}else {gcd = egcd(b % a , a , xt , yt);x = yt - (b/a)*xt; y = xt;}return gcd;}
template <class T> T expo(T base , T exp , T mod){T res = 1;base = base % mod;while (exp > 0){if (exp & 1)res = (res*base) % mod;exp = exp>>1;base = (base*base) % mod;}return res;}
template <class T> T modinv(T a , T mod){T x , y; egcd<T>(a , mod , x , y);while(x < 0) x += mod; while(x >= mod) x -= mod; return x;}
template <class T> T modinvfermat(T a , T mod){return expo<T>(a , mod - 2 , mod);}
template <class T> bool rev(T a , T b){return a > b;}
template <class T> ll maxpower(T a , T b){ll ans = 0;while(a > 0 && a % b == 0){ans++;a /= b;}return ans;}


/*----------------------------- # --- MAIN CODE --- # -----------------------------*/

int main(){
    fastio;
#ifndef ONLINE_JUDGE
    freopen("testcase.txt" , "r" , stdin);
    freopen("error.txt" , "w" , stderr);
    freopen("output.txt" , "w" , stdout);
#endif
//    double r;cin>>r;
//    cout << 2* 3.14159265*r;
    ll n , m; cin >> n >> m;
    ll a[m]; ain(a , m);
    ll ans = 0;
    foru(i , 0 , m){
        ans += a[i];
    }
    if(ans > n) cout << -1;
    else cout << n - ans;
}
























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

#define fast_io ios_base::sync_with_stdio(false) ; cin.tie(0); cout.tie(0);

int main() {
    fast_io;
    int a;
    cin>>a;

    int ans = a+a*a+a*a*a;
    cout<<ans<<endl;
}




Measured memory_bytes: 3564
n = int(input())

sums = 0
answer = False
for _ in range(n):
    d1, d2 = map(int, input().split())
    if d1 == d2:
        sums += 1
    else:
        sums = 0

    if sums == 3:
        answer = True

print("Yes" if answer else "No")

Measured memory_bytes: 62272
use std::io::{stdin, Read, StdinLock};
use std::str::FromStr;

fn main() {
    let cin = stdin();
    let mut scan = Scanner::new(cin.lock());
    let a = scan.read::<i64>();
    let b = scan.read::<i64>();
    println!("{}", ceil_div(b-1, a-1));
}

#[allow(dead_code)]
fn ceil_div(x: i64, y: i64) -> i64 {
    (x + y - 1) / y
}

// region template
#[allow(dead_code)]
fn iu(i: isize) -> usize { i as usize }

#[allow(dead_code)]
fn ui(i: usize) -> isize { i as isize }

#[allow(dead_code, deprecated)]
fn join<T: std::fmt::Display>(slice: &[T], sep: &str) -> String {
    let strings = slice.iter().map(|t| format!("{}", t)).collect::<Vec<_>>();
    strings.connect(sep)
}

#[allow(dead_code)]
fn arr<'a, S, T>(n: usize, mut f: S) -> Vec<T> where S: FnMut(usize) -> T + 'a {
    (0..n).map(|i| f(i)).collect::<Vec<T>>()
}

struct Scanner<'a> {
    cin: StdinLock<'a>,
}

#[allow(dead_code)]
impl<'a> Scanner<'a> {
    fn new(cin: StdinLock<'a>) -> Scanner<'a> {
        Scanner { cin: cin }
    }

    fn read1<T: FromStr>(&mut self) -> Option<T> {
        let token = self.cin.by_ref().bytes().map(|c| c.unwrap() as char)
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        token.parse::<T>().ok()
    }

    fn read<T: FromStr>(&mut self) -> T {
        self.read1().unwrap()
    }

    fn readn<T: FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read::<T>()).collect()
    }

    fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}
// endregion

Measured memory_bytes: 4352
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
int main(){
	int n,a[100],ans=0,bns=0;
	cin>>n;
	for(int i=0;i<n;i++){
		cin>>a[i];
	}
	
	sort(a,a+n);
	
	for(int i=0;i<n;i++){
		if(i%2!=0){
			ans+=a[i];
		}
		else if(i%2==0){
			bns+=a[i];
		}
	}
	
	if(ans<=bns){
		cout<<bns-ans<<endl;
	}
	
	else if(ans>=bns){
		cout<<ans-bns<<endl;
	}
	
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <algorithm>
#include <iostream>
using namespace std;
#define ll long long
#define repi(a,b) for (ll i=a;i<=b;i++)
#define repj(a,b) for (ll j=a;j<=b;j++)


ll n,a,b,c,d;
//bool t[1000000005];

int main()
{
	cin>>n>>a>>b>>c>>d;
	
	repi(0,(int)n-1)
	{
		ll low = a + c*i - d*(n-i-1);
		ll up  = a + d*i - c*(n-i-1);
		
		//cout<<'*'<<low<<' '<<up<<' '<<endl;
		
		if ( b >= low && b <= up) {
			cout<<"YES"<<endl;
			return 0;
		}
	}
	
	cout<<"NO"<<endl;
	return 0;
	
}
/*
4 7 6 4 5
*/

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
	int N,M;
	cin>>N;
	int i,j,k,count=0;
	int A[N+1];
	for(i=1;i<=N;i++)
	{
		cin>>A[i];
		if((A[i]%2!=0)&&(i%2!=0))
		count++;
	}
	cout<<count<<"\n";
	return 0;
	
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
#define f(i, n) for(int i = 0; i < n; ++i)
#define pb push_back
typedef long long ll;
typedef long double lld;
const ll mx = 1e14 + 5;
const ll mod = 1e9 + 7;

void input(){
    string s;
    cin >> s;
    int n= s.size();
    int cnt = 0;
    f(i, s.size() / 2)if(s[i] != s[n - 1 - i])++cnt;
    cout <<cnt << endl;

}
int main(){
    input();
    return 0;
}



Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
using namespace std;
#define taskname "123"
typedef long long lli;
typedef pair<int, int> pii;
int n;

void ReadInput()
{
    cin >> n;
}

void Solve()
{
    cout << 180 * (n - 2) << '\n';
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    ReadInput();
    Solve();
}


Measured memory_bytes: 256
import fractions
import functools

N,X = map(int,input().split())
x_list = list(map(int,input().split()))

x_list.append(X)
x_list.sort()

x_len = list()
for i in range(1,N+1):
    x_len.append(x_list[i]-x_list[i-1])

x_len.sort(reverse = True)

result = functools.reduce(fractions.gcd,x_len)

print(result)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int H,W;
string S[202];
ll ret;
int even[202][202];
ll mo=1000000007;
template<int um> class UF {
	public:
	vector<int> par,rank;
	UF() {rank=vector<int>(um,0); for(int i=0;i<um;i++) par.push_back(i);}
	int operator[](int x) {return (par[x]==x)?(x):(par[x] = operator[](par[x]));}
	int operator()(int x,int y) {
		if((x=operator[](x))==(y=operator[](y))) return x;
		if(rank[x]>rank[y]) return par[x]=y;
		rank[x]+=rank[x]==rank[y]; return par[y]=x;
	}
};
UF<500000> uf;


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>H>>W;
	FOR(y,H) cin>>S[y];
	ret=1;
	if(H%2) {
		FOR(x,W) if(S[H/2][x]!=S[H/2][W-1-x]) {
			ret=2;
			break;
		}
		for(y=H/2;y<H-1;y++) swap(S[y],S[y+1]);
		H--;
	}
	if(W%2) {
		FOR(y,H) if(S[y][W/2]!=S[H-1-y][W/2]) {
			ret*=2;
			break;
		}
		FOR(y,H) S[y]=S[y].substr(0,W/2)+S[y].substr(W/2+1,W/2);
		W--;
	}
	
	if(H&&W) {
		FOR(y,H/2) FOR(x,W/2) {
			map<char,int> M;
			M[S[y][x]]++;
			M[S[H-1-y][x]]++;
			M[S[y][W-1-x]]++;
			M[S[H-1-y][W-1-x]]++;
			
			if(M.size()==4) {
				uf(y,200+x);
				even[y][x]=1;
				ret=ret*12%mo;
			}
			else if(M.size()==3) {
				ret=ret*12%mo;
			}
			else if(M.size()==2) {
				if(M.begin()->second==2) ret=ret*6%mo;
				else ret=ret*4%mo;
			}
		}
		
		j=H/2+W/2;
		FOR(y,H/2)  if(uf[y]==y) j--;
		FOR(x,W/2)  if(uf[x+200]==x+200) j--;
		FOR(i,j) ret=ret*2%mo;
	}
	cout<<ret<<endl;
	
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 4340
#include <iostream>
#include <queue>
#include <map>
#include <algorithm>

using namespace std; using ll=long long; const int INF=1e2; using P=pair<int,int>;

int main() {
  ll n,t; cin>>n>>t;
  ll an=0, nw=0;
  for(int i=0;i<n;i++) {
    ll a; cin>>a;
    an += a + t - max(a, nw);
    nw = a + t;
  }
  cout<<an<<endl;
}


Measured memory_bytes: 256
#include <stdio.h>
                                                                                                
  
int main(void){
                                                                                                
   
    int a, b, c, d;
   
    char s[100];
   
      
    scanf("%d %d %d %d", &a, &b, &c, &d );
   

    if( a + b > c + d ){

        printf("Left\n");

        return 0;

        }

    else if( a + b < c + d ){

        printf("Right\n");

        return 0;

        }

    else printf("Balanced\n");

    return 0;
                                                          
}

Measured memory_bytes: 128
#include <stdio.h>

int main(int argc, char const *argv[]) {
  int quant;
  int sum = 0;
  scanf("%d\n", &quant);

  int score[quant];
  int is10n[quant];

  for (int i = 0; i < quant; i++) {
    (void)scanf("%d", &score[i]);
    if (score[i] % 10 == 0) { // true-> 0, false -> 1;
      is10n[i] = 0;
    }else{
      is10n[i] = 1;
    }
    sum += score[i];
  }

  if (sum % 10 != 0) {
    printf("%d\n", sum);
    return 0;
  }

  int min = 101;
  for (int i = 0; i < quant; i++) {
    if (score[i] * is10n[i] != 0 && min > score[i]) {
      min = score[i];
    }
  }

  if (min == 101) {
    printf("0\n");
  }else{
    printf("%d\n", sum - min);
  }
  return 0;
}


Measured memory_bytes: 128
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val n = sc.nextInt
  var list = List.fill(n)(sc.nextInt)

  var count = 0
  while (list.forall(_ % 2 == 0)){
    count += 1
    list = list.map(_ / 2)
  }
  println(count)
}

Measured memory_bytes: 26056
from  itertools import combinations 

N=int(input())
arr=list(map(int,input().split()))
arr.sort()

count=0
for i in combinations(arr,3):
    a,b,c=i[0],i[1],i[2]
    #print(a,b,c)
    if a!=b and b!=c and a+b>c:
        count+=1
        
print(count)

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

int main() {
    int N, M, L[30 + 1], K[30 + 1], A[30 + 1][30 + 1];
    cin >> N >> M;
    for (int i = 0; i < M + 1; ++i){
    	L[i] = 0;
    }
    for (int i = 0; i < N; ++i){
    	cin >> K[i];
    	for (int j = 0; j < K[i]; ++j){
    		cin >> A[i][j];
    		++L[A[i][j]];
    	}
    }

    int ans = 0;
    for (int i = 0; i < M + 1; ++i){
    	if (L[i] == N) ++ans;
    }

	cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S;
  cin >> S;
  int zer=0,m;
  for (int i=0;i<S.size();i++) {
    if (S.at(i)=='0'){
      zer++;
    }
  }
  m=S.size()-zer;
  cout << 2*min(m,zer) << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <set>
using namespace std;

#define rep(i,s,e) for(int i = (s);i <= (e);i++)

typedef long long ll;

int n;
ll max_w;

ll w[101];

ll v[101];

vector<ll> value[4];

ll weight[4];


int main()
{
	cin >> n >> max_w;

	for(int i = 0;i < n;i++)
	{
		cin >> w[i] >> v[i];
		value[w[i] - w[0]].push_back(v[i]);
	}

	for(int i = 0;i < 4;i++)
	{
		weight[i] = w[0] + i;
	}

	for(vector<ll>& vec : value)
	{
		sort(vec.rbegin(),vec.rend());
		vec.insert(vec.begin(),0);
	}

	ll result = 0;

	rep(i,0,value[0].size() - 1)
	{
		rep(j,0,value[1].size() - 1)
		{
			rep(k,0,value[2].size()- 1)
			{
				rep(l,0,value[3].size() - 1)
				{
					ll now_w = i * weight[0] + j * weight[1] + k * weight[2] + l * weight[3];
					if(max_w >= now_w)
					{
						ll val = 0;
						vector<int> cou;
						cou.push_back(i);
						cou.push_back(j);
						cou.push_back(k);
						cou.push_back(l);
						rep(c,0,3)
						{
							rep(m,0,cou[c])
							{
								val += value[c][m];
							}
						}
						result = max(result , val);
					}
				}
			}
		}
	}

	cout << result << endl;
	return 0;
}


Measured memory_bytes: 256
from heapq import heapify, heappushpop

N, *A = map(int, open(0).read().split())

L, C, R = A[:N], A[N:2 * N], A[2 * N:]

heapify(L)
red = [sum(L)]
for c in C:
    red.append(red[-1] + c - heappushpop(L, c))

R = [-r for r in R]
heapify(R)
blue = [sum(R)]
for c in reversed(C):
    blue.append(blue[-1] - c - heappushpop(R, -c))

print(max(r + b for r, b in zip(red, reversed(blue))))


Measured memory_bytes: 36308
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  int A, B, K;
  cin >> A >> B >> K;
  for (int i = A; i <= B; ++i) {
    if ((i - A) < K || (B - i) < K) cout << i << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
template <class T>
inline bool chmax(T &a, T b) {
  if (a < b) {
    a = b;
    return 1;
  }
  return 0;
}

typedef long long ll;
ll MOD = 1000000007;

// a^p
// 2^3 = 2 * 2^2
// 2^2 = 2 * (2^1)
// 2^1 = 2
ll modpow(ll a, ll p, ll mod) {
  if (p == 0)
    return 1;

  if (p % 2 == 0) {
    ll half = modpow(a, p / 2, mod) % mod;
    return half * half % mod;
  } else {
    return a * modpow(a, p - 1, mod) % mod;
  }
}

// nCa を求める
ll modCombination(ll n, ll a, ll mod) {
  if (n - a < a) {
    return modCombination(n, n - a, mod);
  }

  ll denominator = 1; // 分母
  ll numerator = 1;   // 分子

  for (ll i = 0; i < a; i++) {
    denominator *= a - i;
    numerator *= n - i;
    denominator %= mod;
    numerator %= mod;
  }

  return numerator * modpow(denominator, mod - 2, mod) % mod;
}

int main() {
  ll N;
  cin >> N;
  vector<vector<ll>> pairs(10, vector<ll>(10, 0));
  for (ll i = 1; i < N + 1; i++) {
    string str = to_string(i);
    ll first = str[str.length() - 1] - '0';
    ll last = str[0] - '0';

    pairs[first][last]++;
  }

  ll ans = 0;
  for (ll i = 1; i < 10; i++) {
    for (ll j = 1; j < 10; j++) {
      // cout << "(" << i << "," << j << ") " << pairs[i][j] << " ( " << j << "," << i << ") " << pairs[j][i] << endl;
      ans += pairs[i][j] * pairs[j][i];
    }
  }

  cout << ans << endl;
  return 0;
}


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

using namespace std;

int N;
const int MOD = 1000000007;

int main()
{
    cin >> N;
    long long cnt = 1;
    for (int i = 1; i < N + 1; i++) {
        if (cnt > MOD) cnt %= MOD;
        cnt *= i;
    }
    cnt %= MOD;
    cout << cnt << endl;
}

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



using namespace std;



static const int INF = 99999;



int main(){



	int n,array[100][100];



	cin>>n;



	for(int i=0; i<n; i++){

		fill(array[i],array[i]+n,INF);

	}



	for(int i=0; i<n; i++){

		for(int j=0; j<n; j++){

			int tmp;

			cin>>tmp;

			if(tmp!=-1) array[i][j]=tmp;

		}

	}



	int ans=INF;

	

	for(int k=0; k<n; k++){

		bool flag[100];

		fill(flag,flag+n,false);

		flag[k]=true;



		int tmp=0;

		while(1){

			int u=-1,minv=INF;

			for(int i=0; i<n; i++){

				if(!flag[i]) continue;

				for(int j=0; j<n; j++){

					if(!flag[j] && array[i][j]<=minv){

						minv = array[i][j];

						u = j;

					}	

				}

			}

			if(minv==INF){

				break;

			}else{

				tmp += minv;

				flag[u]=true;

			}

		}

		ans = min(ans,tmp);

	}



	cout<<ans<<endl;



	return 0;

}

Measured memory_bytes: 1200
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
using namespace std;

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

	auto result = 0;
	for (auto i = 1; i <= N; i += 2)
	{
		auto count = 0;
		for (auto j = 1; j <= i; ++j)
		{
			if (i % j == 0)
			{
				++count;
			}
		}

		if (count == 8)
		{
			++result;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 384
s = input()
ans = 0
while s:
  if s[0] == s[-1]:
    s = s[1:-1]
  else:
    if s[0] == "x":
      ans += 1
      s = s[1:]
    elif s[-1] == "x":
      ans += 1
      s = s[:-1]
    else:
      print(-1)
      exit()
print(ans)

Measured memory_bytes: 3316
/*
    Author: Aryan Yadav
*/
#include <bits/stdc++.h>
using namespace std;

#define ll long long
#define mod 1000000007
#define f(i, a, b) for (long long i = a; i < b; i++)
#define rep(i, a, b) for (long long i = a; i <= b; i++)
#define fm(i, a, b) for (long long i = a; i > b; i--)
#define repm(i, a, b) for (long long i = a; i >= b; i--)
#define vi vector<int>
#define vl vector<long long>
#define vs vector<string>
#define pqmaxi priority_queue<int>
#define pqmaxl priority_queue<ll>
#define pqmini priority_queue<int, vi, greater<int>>
#define pqminl priority_queue<ll, vl, greater<ll>>
#define all(x) x.begin(), x.end()
#define test     \
    ll test;     \
    cin >> test; \
    while (test--)
#define pb(i) push_back(i)
#define mp(i, j) make_pair(i, j)
#define fast                     \
    ios::sync_with_stdio(false); \
    cin.tie(NULL)

int main()
{
    fast;
    ll n;
    ll a[3][3];
    bool tick[3][3];

    f(i, 0, 3)
    {
        f(j, 0, 3)
        {
            cin >> a[i][j];
            tick[i][j] = false;
        }
    }
    cin >> n;
    vl b(n);
    f(i, 0, n)
    {
        cin >> b[i];
    }
    f(i, 0, n)
    {
        f(a1, 0, 3)
        {
            f(b1, 0, 3)
            {
                if (b[i] == a[a1][b1])
                    tick[a1][b1] = true;
            }
        }
    }

    ll k = 0;
    f(i, 0, 3)
    {
        if (tick[i][0] && tick[i][1] && tick[i][2])
            k = 1;
    }
    f(i, 0, 3)
    {
        if (tick[0][i] && tick[1][i] && tick[2][i])
            k = 1;
    }
    if (tick[0][0] && tick[1][1] && tick[2][2])
        k = 1;
    if (tick[0][2] && tick[1][1] && tick[2][0])
        k = 1;

    if (k == 0)
    {
        cout << "No";
    }
    else
    {
        cout << "Yes";
    }
}

Measured memory_bytes: 3652
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <sstream>
#include <cassert>
#include <list>
#include <ctime>
#include <numeric>
#include <fstream>
using namespace std;
static const double EPS = 1e-6;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> PI;
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define SZ(a) (int(a.size()))
#define F first
#define S second
const long double pi=acos(-1.0);
int dx[]={0,1,0,-1,1,1,-1,-1,0},dy[]={1,0,-1,0,1,-1,1,-1,0};


int n,m,d;


void solve(){
  int mat[n*m][n*m+1];
  memset(mat,0,sizeof(mat));

  rep(i,m*n)mat[i][i]=1;
  queue<PI> q;
  q.push(mp(0,0));
  set<PI> app;
  vector<PI> man;
  while(!q.empty()){
    int cx=q.front().F;
    int cy=q.front().S;
    q.pop();
    if(app.count(mp(cx,cy)))continue;
    app.insert(mp(cx,cy));
    if(abs(cx)+abs(cy)==d){
      man.pb(mp(cx,cy));
      continue;
    }

    rep(i,4){
      int nx=cx+dx[i],ny=cy+dy[i];
      if(app.count(mp(nx,ny)))continue;
      q.push(mp(nx,ny));
    }
  }

  rep(i,m*n)
    FOR(it,man){
    int x=i/m+it->F,y=i%m+it->S;
    if(min(x,y)<0 || x>=n || y>=m)continue;
    mat[i][x*m+y]=1;
  }

  rep(i,n)rep(j,m)
    cin>>mat[i*m+j][m*n];


  int ofs=0;
  for(int i=0;i+ofs<m*n;++i){
    /*
    rep(j,m*n){
      rep(k,m*n+1)cout<<mat[j][k]<<' ';
      cout<<endl;
    }
    cout<<endl;
    */
    if(!mat[i][i+ofs])
      for(int j=m*n-1;j>i;--j)
        if(mat[j][i+ofs]){
          for(int k=0;k<m*n+1;++k)
            swap(mat[i][k],mat[j][k]);
          break;
        }
    
    if(mat[i][i+ofs]){
      for(int j=i+1;j<m*n;++j)
        if(mat[j][i+ofs])
          rep(k,m*n+1)
            mat[j][k]^=mat[i][k];
    }else ++ofs,--i;
  }

  for(int i=m*n-1;i>m*n-1-ofs;--i)
    if(mat[i][m*n]){
      cout<<0<<endl;
      return;
    }

  cout<<1<<endl;
}

main(){
  while(cin>>m>>n>>d,n|m|d)
    solve();
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
#define rep(i,a,n) for(int i=a;i<n;i++)
#define rrep(i,n,a) for(int i=n;i>=a;i--)
#define FOR(i,n) for(int i=0;i<n;i++)
#define all(s) s.begin(),s.end()
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pcnt(n) __builtin_popcount(n)
const int MOD = 1e9 + 7;
//const int MOD = 998244353;
const int INF = 1e18;
const double PI = acos(-1);

map<int,int> pf(int N){
    map<int,int> ret;
    for(int i=2;i*i<=N;i++){
        while(N%i==0){
            ret[i]++;
            N/=i;
        }
    }
    if(N!=1){ret[N]++;}
    return ret;
}

signed main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    map<int,int>m = pf(n);
    int ans = 0;
    for(auto x:m){
        ans += (-1 + sqrt(1+8*x.second))/2;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 3676
import heapq
N = int(input())
A = [int(i) for i in input().split()]
heap = []
for i in range(N):
    heapq.heappush(heap,(A[i],i))
heapq.heappush(heap,(10**9,10**9))
ans = []
for i in range(N):
    p,q = heapq.heappop(heap)
    ans.append(q+1)
print(*ans)


Measured memory_bytes: 19864
n=int(input())
l=[int(i) for i in input().split()]
v=sum(l)
e=0
for i in range(max(l)):
  ef=0
  for j in l:
    if j>i:
      ef+=1
    else:
      if ef>0:
        e+=ef-1
      ef=0
  if ef>1:
    e+=ef-1
print(v-e)


Measured memory_bytes: 3060