akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;                                                            
#define pb push_back                                                            
#define mp make_pair                                                                                                                                
#define sqr(a) ((a) * (a))                                                      
#define io() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);   
#define co() cout.precision(10);                                                
#define F for(li i=0;i<n;i++)
#define fo(i,a,n) for(i=a;i<n;i++)
#define ne cout<<"\n"; 
#define test int t;cin>>t;while(t--)
//#define oj #ifndef ONLINE_JUDGE freopen("input.txt","r",stdin); freopen("output.txt","w",stdout); #endif

typedef long long li;
typedef long double ld;

const li mod = 1000000007;
int main() 
{
    io();
    li n,k;
    cin>>n;
    k=n;li x,i;
    string p;char ch;
    while(k>0)
	{
				
				x=k%26;
				k/=26;
				if(x==0)
				{
					p+='z';
					k--;
				}
				else
				p+='a'+x-1;
				
}
			reverse(p.begin(),p.end());
			fo(i,0,p.length())
			{
				cout<<p[i];
			}
		
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define fi first
#define se second
#define sz(x) (int)(x).size()
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<typename T> inline bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T &a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U &u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U &u,const V... v){for(auto &e:u)fill_v<T>(e,v...);}

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

    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    sort(all(a));
    int d = a[n-1] - a[0];
    if (d >= 2) {
        puts("No");
        return 0;
    }
    if (d == 0) {
        if (a[0] == n-1 || 2 * a[0] <= n) {
            puts("Yes");
        } else {
            puts("No");
        }
    } else {
        int x = lower_bound(all(a), a[0]+1) - a.begin();
        int y = n - x;
        int v = a[n-1];
        if (x < v && 2 * (v - x) <= y) {
            puts("Yes");
        } else {
            puts("No");
        }
    }
}


Measured memory_bytes: 3720
#include <iostream>
#include <stdio.h>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <numeric>
#include <queue>
#include <numeric>
#include <iomanip>
#include <sstream>
#include <cmath>
#include <map>
#include <functional>
#define rep(i,a,b) for((i)=a;i<(int)(b);i++)
#define max(a,b) (a < b ? b : a)
#define min(a,b) (a > b ? b : a)
#define AAA (1000000007)
using namespace std;
typedef long long ll;




int main() {
	const int A = 300000, B = 200000, C = 100000, D = 400000;

	int X, Y;
	cin >> X >> Y;

	int ans = 0;
	if (X == 1)
		ans += A;
	if (X == 2)
		ans += B;
	if (X == 3)
		ans += C;
	if (Y == 1)
		ans += A;
	if (Y == 2)
		ans += B;
	if (Y == 3)
		ans += C;
	if (X == 1 && Y == 1) {
		ans += D;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
using namespace std;

#define endl '\n'
#define lfs cout<<fixed<<setprecision(10)
#define ALL(a)  (a).begin(),(a).end()
#define ALLR(a)  (a).rbegin(),(a).rend()
#define spa << " " <<
#define fi first
#define se second
#define MP make_pair
#define MT make_tuple
#define PB push_back
#define EB emplace_back
#define rep(i,n,m) for(ll i = (n); i < (ll)(m); i++)
#define rrep(i,n,m) for(ll i = (ll)(m) - 1; i >= (ll)(n); i--)
using ll = long long;
using ld = long double;
const ll MOD1 = 1e9+7;
const ll MOD9 = 998244353;
const ll INF = 1e18;
using P = pair<ll, ll>;
template<typename T>
bool chmin(T &a,T b){if(a>b){a=b;return true;}else return false;}
template<typename T>
bool chmax(T &a,T b){if(a<b){a=b;return true;}else return false;}
ll median(ll a,ll b, ll c){return a+b+c-max({a,b,c})-min({a,b,c});}
void ans1(bool x){if(x) cout<<"Yes"<<endl;else cout<<"No"<<endl;}
void ans2(bool x){if(x) cout<<"YES"<<endl;else cout<<"NO"<<endl;}
void ans3(bool x){if(x) cout<<"Yay!"<<endl;else cout<<":("<<endl;}
template<typename T1,typename T2>
void ans(bool x,T1 y,T2 z){if(x)cout<<y<<endl;else cout<<z<<endl;}  
template<typename T>
void debug(vector<vector<T>>&v,ll h,ll w){for(ll i=0;i<h;i++)
{cout<<v[i][0];for(ll j=1;j<w;j++)cout spa v[i][j];cout<<endl;}};
void debug(vector<string>&v,ll h,ll w){for(ll i=0;i<h;i++)
{for(ll j=0;j<w;j++)cout<<v[i][j];cout<<endl;}};
template<typename T>
void debug(vector<T>&v,ll n){if(n!=0)cout<<v[0];
for(ll i=1;i<n;i++)cout spa v[i];cout<<endl;};
template<typename T>
vector<vector<T>>vec(ll x, ll y, T w){
  vector<vector<T>>v(x,vector<T>(y,w));return v;}
ll gcd(ll x,ll y){ll r;while(y!=0&&(r=x%y)!=0){x=y;y=r;}return y==0?x:y;}
vector<ll>dx={1,0,-1,0,1,1,-1,-1};
vector<ll>dy={0,1,0,-1,1,-1,1,-1};
template<typename T>
vector<T> make_v(size_t a,T b){return vector<T>(a,b);}
template<typename... Ts>
auto make_v(size_t a,Ts... ts){
  return vector<decltype(make_v(ts...))>(a,make_v(ts...));
}
template<typename T1, typename T2>
ostream &operator<<(ostream &os, pair<T1, T2>&p){
  return os << p.first << " " << p.second;
}  
int main(){
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ll res=0,buf=0;
  bool judge = true;
  ll n,k;cin>>n>>k;
  if(n>=k)n%=k;
  cout<<min(n,k-n)<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
	int a, b;
	int n;
	int ans;

	while(scanf("%d %d %d", &a, &b, &n) != EOF){
		ans = 0;

		int d = a % b;
		d *= 10;
		for(int i=0; i<n; i++){
			ans += d / b;
			d = d % b;
			d *= 10;
		}
		printf("%d\n", ans);
	}

	return 0;
}

Measured memory_bytes: 0
L, R, d = list(map(int, input().split()))

if d!=1:
    if L!=1:
        ansR = R / d
        ansL = (L-1) / d
        #print(ansR,ansL)
        ans = int(ansR) - int(ansL)
    else:
        ansR = R / d
        ansL = L / d
        #print(ansR,ansL)
        ans = int(ansR) - int(ansL)
else:
    ans = R

print(int(ans))

Measured memory_bytes: 61752
#include<bits/stdc++.h>
using namespace std;
const int maxn = 2e5+10;

int f[maxn];
int sum[maxn]; 
int n,m;
int Find(int x){
    return f[x]==x?x:f[x]=Find(f[x]);
}
void merge(int u,int v){
	int x = Find(u);
	int y = Find(v);
	if(x!=y){
		f[x] = y;
		sum[y] += sum[x];
	}
}
void Init(){
    for(int i = 1; i <= n;i++){
    	f[i] = i;
    	sum[i] = 1;
	}
}
int main(void){
	cin >> n >> m;
	Init();
	while(m--){
		int u,v;
		cin >> u >> v;
		merge(u,v);
	} 
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(f[i]==i){
			ans = max(ans,sum[i]);
		}
	}
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int  N;
  scanf("%d", &N);
  vector<int> a(N);
  for(int i = 0; i < N; i++){
  	scanf("%d", &a[i]);
  }
  int answer = 0;
  for(int i = 0; i < N; i++){
  	int group_size = 1;
    while(i+1 < N && a[i] == a[i+1]){
    	group_size++;
    	i++;  
    }
    answer += (group_size/2);
  }
  cout << answer;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		while(true){
			int n = sc.nextInt();
			if(n==0) break;
			int cnt = 0;
			boolean flag = false;
			for(int i=0;i<n;i++){
				int k = sc.nextInt();
				if(k>0) cnt++;
				if(k>1) flag = true;
			}
			if(!flag) System.out.println("NA");
			else System.out.println(cnt+1);
		}
	}
}

Measured memory_bytes: 158564
N = int(input())
A = list(map(int,input().split()))

count1 = 0
count2 = 0

for i in range(N):
    if A[i]%2 == 0:
        count1+=1
        if A[i] % 3 == 0 or A[i] % 5 == 0:
            count2 += 1
            
if count1 == count2:
    print('APPROVED')
else:
    print('DENIED')

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

#define sz(x) (int)x.size()
#define ld long double
#define ll long long
#define pb push_back
#define mp make_pair
#define f first
#define s second

using namespace std;

ll x;
ll pp(ll a, ll b){
    ll res = 1;
    for(int i = 0; i < b; ++i){
        res *= a;
    }
    return res;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> x;
    for(ll a = -150; a <= 150; ++a){
        for(ll b = -150; b <= 150; ++b){
            if(pp(a, 5) - pp(b, 5) == x){
                cout << a << " " << b;
                return 0;
            }
        }
    }
    cout << -1;
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <stack>

#define REP(i,n) for(int i = 0; i < (n); ++i)
#define REPC(x,c) for(auto x:(c))
#define FOR(i, b, e) for(int i = (b); i < (e); ++i)
#define VS vector<string>
#define VI vector<int>
#define VVI vector<vector<int>>

using namespace std;

int main() {
	string s;
	cin >> s;
	int p = stoi(s);
	int q = 0;
	for (auto c : s) {
		q += (c - '0');
	}
	cout << ((p%q == 0) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main (){
  int x,y,a;
  while (1){
    scanf("%d %d",&x,&y);
    if (x==0 && y==0) break;
    if(x>y){
      printf("%d %d\n",y,x);
    }else{
      printf("%d %d\n",x,y);
    }
    if (x==0 && y==0) break;
  }
  return 0;
}

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

int main() {
  int A,B,Num,Sum,dig5,dig4,dig3,dig2,dig1;
  cin >> A;
  cin >> B;
  Sum = 0;
  
  for (int i=A; i <= B; i++){
      Num = i;
      dig1 = Num % 10;
      Num /= 10;
      dig2 = Num % 10;
      Num /= 10;
      dig3 = Num % 10;
      Num /= 10;
      dig4 = Num % 10;
      Num /= 10;
      dig5 = Num % 10;
    if( dig1 == dig5 && dig2 == dig4)
      Sum += 1;
  }
  cout << Sum << endl;
}


Measured memory_bytes: 3608
// Example program
#include <iostream>
using namespace std;

int main()
{
    int H, W;
    while(1){
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        for (int i = 0; i < H; i++){
            for (int j = 0; j < W; j++){
                if (i > 0 && j > 0 && i < H-1 && j < W-1){
                    cout << ".";
                } else {
                    cout << "#";
                }
            }
            cout << endl;
        }
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3084
#include<bits/stdc++.h>
typedef double          D;
typedef long long int   LL;
typedef long double     LD;
#define OR              ||
#define AND             &&
#define nl              '\n'
#define S               string
#define inf             INT_MAX
#define SQR(a)          (a) * (a)
#define pb              push_back
#define GCD(a, b)       __gcd(a, b)
#define PI              2.0*acos(0.0)
#define LCM(a, b)       (a * b) / GCD(a, b)
#define mem(a,b)        memset(a,b,sizeof(a))
#define srtv(v)         sort(v.begin(),v.end())
#define T               int t; cin>>t; while(t--)
#define Rep(i,a,b)      for(int i = a; i <= b; i++)
#define rep(i,a,b)      for(int i = a; i >= b; i--)
#define boost		    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define inout           freopen("input.txt","r",stdin);freopen("output.txt","w",stdout)

#define si(x)           scanf("%d",&x)
#define pi(x)           printf("%d",x)
#define ss(str)         scanf("%s",str)
#define pl(x)           printf("%lld",x)
#define sl(x)           scanf("%lld",&x)
#define sii(x,y)        scanf("%d %d",&x,&y)
#define sll(x,y)        scanf("%lld %lld",&x,&y)
#define siii(x,y,z)     scanf("%d %d %d",&x,&y,&z)
#define slll(x,y,z)     scanf("%lld %lld %lld",&x,&y,&z)
using namespace std;


/*

bool bs(LL l,LL r)
{
    int mid,res=-1;

    while(l<=r)
    {
        mid=l+(r-l)/2;



    }

    return res;
}


*/

//--------------------------code starts here---------------------------------------

int main()
{
    char ch;
    cin>>ch;

    if(ch>='A'  && ch<='Z')
        cout<<"A";
    else
        cout<<"a";


    return 0;

}


Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = Integer.parseInt(sc.next());
        int b = Integer.parseInt(sc.next());
        sc.close();
        int res  = 0;
        int c = 1;
        while(c < b){
            c+=a-1;
            res++;
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 23764
#include <iostream>
#include <sstream>
#include <iomanip>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <algorithm>
#include <climits>
using namespace std;

void solve(vector<pair<int,int> > vertex)
{
	int n = vertex.size();
	int answer = vertex[0].first*vertex[n-1].second - vertex[0].second*vertex[n-1].first;
	for(int i=0; i<n-1; ++i)
		answer += vertex[i+1].first*vertex[i].second - vertex[i+1].second*vertex[i].first;
	cout << (answer/2) << '.';
	if(answer % 2 == 0)
		cout << '0';
	else
		cout << '5';
	cout << endl;
}

int main()
{
	int number = 0;
	for(;;){
		int n;
		cin >> n;
		if(n == 0)
			break;

		vector<pair<int,int> > vertex(n);
		for(int i=0; i<n; ++i)
			cin >> vertex[i].first >> vertex[i].second;

		cout << (++number) << ' ';
		solve(vertex);
	}

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;

int main(){
    string S;
    ll K;
    cin >> S >> K;
    rep(i,S.size()){
        K--;
        if(K == 0 || S[i] != '1'){
            cout << S[i] << endl;
            return 0;
        }
        
    }
}


Measured memory_bytes: 3596
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

//http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=2619

#define int long long
#define rep(i,n) for(int i = 0; i < (n); i++)
#define INF ((long long)1e18)
#define MOD ((int)1e9+7)
#define endl "\n"

#define yn(f) ((f)?"Yes":"No")
#define YN(f) ((f)?"YES":"NO")

#define MAX 1100

vector<int> tree[MAX];
string s[MAX];
int n, k;
string M;

void solve(int node, int depth){
	// cout<<node<<" "<<depth<<endl;
	for(int i = 0; i < depth; i++){
		cout<<'.';
	}
	
	cout<<s[node]<<endl;
	
	for(int i = 0; i < tree[node].size(); i++){
		solve(tree[node][i], depth+1);
	}
}
signed main(){
	// cin.tie(0);
	// ios::sync_with_stdio(false);
	// cout<<fixed<<setprecision(10);
	
	cin>>n;
	
	for(int i = 1; i <= n; i++){
		cin>>k>>M;
		tree[k].push_back(i);
		s[i] = M;
	}
	
	solve(1,0);
	
	return 0;
}


Measured memory_bytes: 3460
use std::io;
use std::io::prelude::*;
use std::cmp::max;

fn main() {
    
    let stdin = io::stdin();
    let mut lines = stdin.lock().lines();

    let line1: Vec<usize> = lines.next().unwrap().ok().unwrap().split_whitespace().map(|x| x.parse().expect("Error")).collect();
    let (num_items, max_weight) = (line1[0], line1[1]);
    let mut item_costs = Vec::new();
    for _ in 0..num_items {
        item_costs.push(lines.next().unwrap().ok().unwrap().split_whitespace().map(|x| x.parse().expect("error")).collect::<Vec<usize>>());
    }

    let mut dp = vec![vec![0; max_weight+1]; num_items+1];

    for i in 1..(num_items+1) {
        let (weight, value) = (item_costs[i-1][0], item_costs[i-1][1]);
        for j in 1..(max_weight+1) {
            dp[i][j] = dp[i-1][j];
            if weight <= j {
                dp[i][j] = max(dp[i][j], dp[i-1][j-weight] + value);
            }
        }
    }

    println!("{}", dp[num_items][max_weight]);
}

Measured memory_bytes: 106748
//------------------------------------------------------------------------------MANAS UNIYAL---------------------------------------------------------
//																				NEVER GIVE UP
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
#define ll long long
#define pb push_back
#define fi first
#define se second
#define pii pair<ll,ll>
#define INF 0x3f3f3f3f
#define mod 100000007
#define testcases() ll t; cin>>t; while(t--)
#define debug1(x) cout<<#x<<" "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<"\n";
#define rep(i,start,end) for(ll i=start;i<end;i++)
 
//----------------------------------------------------------------------------------------------------------------------------------------------------

int main()
{
	fast;
	ll a,b,n,m;
	cin>>a>>b;
	n=a;
	m=b;
	unordered_map<ll, int> mp1, mp2;
	for(ll i=2;i*i<=n;i++)
	{
		while(a>1 && a%i==0)
		{
			mp1[i]=1;
			a/=i;
		}
	}
	if(a>1)
		mp1[a]=1;
	for(ll i=2;i*i<=m;i++)
	{
		while(b>1 && b%i==0)
		{
			mp2[i]=1;
			b/=i;
		}
	}
	if(b>1)
		mp2[b]=1;
	ll cnt(0);
	for(auto it: mp1)
	{
		if(mp2.find(it.fi)!=mp2.end())
			cnt++;
	}
	cout<<cnt+1;
	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int A[110], cnt = 0;

void swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

void selectionSort(int *A, int N) {
	for (int i = 0; i < N; ++i) {
		int minj = i;
		for (int j = i; j < N; ++j) {
			if (A[j] < A[minj]) minj = j;
		}
		swap(&A[i], &A[minj]);
		if (i != minj) cnt++;
	}
}

int main() {
	int n;
	scanf("%d", &n);
	for (int i = 0; i < n; ++i) {
		scanf("%d", &A[i]);
	}
	selectionSort(A, n);

	for (int i = 0; i < n; ++i) {
		if (i != n-1) printf("%d ", A[i]);
		else printf("%d\n", A[i]);
	}
	printf("%d\n", cnt);
}



Measured memory_bytes: 2732
#include <iostream>
#include <bits/stdc++.h>
#include <vector>
#include <algorithm>
typedef long long int ll;
using namespace std;
#define P 1000000007
#define rep(i,n) for(i=0;i<n;++i)
#define repp(i,a,n) for(i=a;i<n;++i)
#define repr(i,a,n) for(i=a;i>n;--i)

ll binpowmod(ll a, ll b, ll m) {
    a %= m;
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a % m;
        a = a * a % m;
        b >>= 1;
    }
    return res;
}

ll binpow(ll a, ll b) {
    ll res = 1;
    while (b > 0) {
        if (b & 1)
            res = res * a;
        a = a * a;
        b >>= 1;
    }
    return res;
}

ll modInverse(ll n, ll p)
{
    return binpowmod(n, p-2, p);
}

int main() 
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t,n,i,ans;
    ans=0;
    cin >> n ;
    ll a[n];
    rep(i,n) cin >> a[i];
    sort(a,a+n);
    cout << a[n/2]-a[n/2-1];
	return 0;
}

Measured memory_bytes: 1024
PROGRAM echo
      IMPLICiT NONE
      INTEGER :: n
      character(300) :: s
      character(3)   :: ans = 'Yes'

      
      read*,n
      read*,s
      
      
      if( mod(n,2)==1 ) ans = 'No '
      
      if( .not.( lge(s(1:n/2),s(n/2+1:n)).and.lle(s(1:n/2),s(n/2+1:n)) )) ans = 'No'
      
      
      print*,ans
      
      END PROGRAM

Measured memory_bytes: 640
import fractions
import functools

MOD = int(1e9) + 7


class Inv:

    @classmethod
    def pow(cls, x: int, n: int) -> int:
        ret = 1
        while n > 0:
            if n % 2 == 1:
                ret = ret * x % MOD
            x = x * x % MOD
            n >>= 1
        return ret

    @classmethod
    def inv(cls, x: int) -> int:
        return cls.pow(x % MOD, MOD - 2)


N = int(input())
A = list(map(int, input().split()))

MAX_A = 1000010

facts = [0] * MAX_A
p = [False] * MAX_A

def prime():

    for i in range(2, MAX_A):
        p[0] = p[1] = True
        if not p[i]:
            j = 2 * i
            while j < MAX_A:
                p[j] = True
                j += i

prime()

for a in A:
    i = 2
    while i * i <= a:
        if a % i == 0:
            ii = a // i
            c1 = 0
            while a % i == 0:
                c1 += 1
                a //= i
            c2 = 0
            while not p[ii] and a % ii == 0:
                c2 += 1
                a //= ii
            facts[i] = max(facts[i], c1)
            facts[ii] = max(facts[ii], c2)
        i += 1
    if not p[a]:
        facts[a] = max(facts[a], 1)

tar = 1
for idx, c in enumerate(facts):
    if c == 0:
        continue
    tar *= Inv.pow(idx, c)
    tar %= MOD

ans = 0
for a in A:
    ans += tar * Inv.inv(a) % MOD
    ans %= MOD

print(ans)

Measured memory_bytes: 88280
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#define rep(i,n) for (int i = 0; i < n; ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;

ll a[55], p[55];

ll f(int N, ll X) {
  if (N == 0) return 1;
  else if (X == 1) return 0;
  else if (X <= 1 + a[N-1]) return f(N-1, X-1);
  else if (X == 1 + a[N-1] + 1) return p[N-1] + 1;
  else if (X <= 1 + a[N-1] + 1 + a[N-1]) return p[N-1] + 1 + f(N-1, X - 1 - a[N-1] - 1);
  else return p[N-1] + 1 + p[N-1];
}

int main() {
  int N; cin >> N;
  ll X; cin >> X;
  a[0] = 1, p[0] = 1;
  for(int i = 1; i <= N; ++i) {
    a[i] = a[i-1] * 2 + 3;
    p[i] = p[i-1] * 2 + 1;
  }
  cout << f(N, X) << endl;
  return 0;
}

Measured memory_bytes: 3196
X = int(input())
List = [0]*(X+1)
List[1] = 1
for i in range(2,X+1):
    v = i**2
    while(v<=X):
        List[v]=1
        v*=i
        
for i in range(1,X+1)[::-1]:
    if List[i]==1:
        print(i)
        break

Measured memory_bytes: 3064
n,m=map(int,input().split())
a=[]
b=[]
z=[]
x=[]
for i in range(n):
    a+=[[int(i) for i in input().split()]]
for i in range(m):
    b+=[[int(i) for i in input().split()]]
for i in range(n):
    for j in range(m):
        z+=[a[i][j]*b[j][0]]
    x+=[sum(z)]
    z=[]
for i in range(n):
    print(x[i])

Measured memory_bytes: 8060
A = int(input())
B = int(input())

if A == 1 and B == 2:
  print(3)
elif A == 2 and B == 1:
  print(3)
elif A == 2 and B == 3:
  print(1)
elif A == 3 and B == 2:
  print(1)
elif A == 1 and B == 3:
  print(2)
elif A == 3 and B == 1:
  print(2)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef vector<int> vint;
typedef vector<float> vfloat;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vstr> vvstr;
typedef pair<int, int> P;
typedef vector<P> vpair;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    ll n, k;
    cin >> n >> k;
    ll id = 0;
    vpair ab;
    int a, b;
    rep(i, n) {
        cin >> a >> b;
        ab.emplace_back(a, b);
    }
    sort(all(ab));
    rep(i, n) {
        id += ab[i].se;
        if (id >= k) {
            cout << ab[i].fi << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 1400
A,B,M = map(int, input().split())
*a, = map(int, input().split())
*b, = map(int, input().split())

discount = []

for _ in range(M):
    x,y,c = map(int, input().split())
    discount.append([x-1,y-1,c])

ans_a = float('inf')
ans_b = float('inf')

for e in a:
    ans_a = min(ans_a, e)

for e in b:
    ans_b = min(ans_b, e)

ans = ans_a + ans_b

for x,y,c in discount:
    temp = a[x]+b[y]-c
    ans = min(ans, temp)

print(ans)

Measured memory_bytes: 30764
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<map>
#include<cmath>
#include<iomanip>
#include<set>
#include<string>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; ++i)
#define rrep(i, st, n) for (int i = st; i < n; ++i)
using pii = pair<int, int>;
//const int inf = 1e9 + 7;

int gcd(int a, int b) {
    if (a < b) swap(a, b);
    if (b == 0) return abs(a);
    return gcd(b, a % b);
}
int main() {
    string s; cin >> s;
    if (s.size() == 1) {cout << s[0] << endl; return 0;}
    int flg = 0;
    rrep(i, 1, s.size()) {if (s[i] != '9') break; if (i == s.size() - 1) flg = 1;}
    if (flg == 1) {cout << (s[0] - '0') + 9 * (s.size() - 1) << endl; return 0;}
    cout << (s[0] - '0') + 9 * (s.size() - 1) - 1 << endl; //(c - 1)999...
}


Measured memory_bytes: 256
n=int(input())
INF=2<<60
dp=[INF]*(2*10**5)
money_list=[1]+[6**i for i in range(1, 7)]+[9**i for i in range(1, 6)]
money_list.sort()
for m in money_list:
    dp[m-1]=1
for i in range(n):
    for m in money_list:
        dp[i+m]=min(dp[i+m], dp[i]+1)
print(dp[n-1])

Measured memory_bytes: 4596
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main() {
  int K, X;

  cin >> K >> X;

  if (K * 500 >= X)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;

  return 0;
}


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

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


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

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

    int a, b, c, d;
    cin >> a >> b >> c >> d;
    cout << string(d - b, 'U');
    cout << string(c - a, 'R');
    cout << string(d - b, 'D');
    cout << string(c - a + 1, 'L');
    cout << string(d - b + 1, 'U');
    cout << string(c - a + 1, 'R');
    cout << 'D' << 'R';
    cout << string(d - b + 1, 'D');
    cout << string(c - a + 1, 'L');
    cout << 'U' << endl;    

    return 0;
}

Measured memory_bytes: 256
n, a, b, c, d = map(int, input().split())
a, b, c, d = a - 1, b - 1, c - 1, d - 1
s = input()
if ("##" in s[a:max(c+1, d+1)]):
    ans = "No"
elif (c < d):
    ans = "Yes"
elif (c > d):
    s = s[:c+1]
    if ("..." in s[max(a, b-1):d+2]):
        ans = "Yes"
    else:
        ans = "No"
print(ans)

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

typedef long long ll;
#define MOD = 1000000007;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define ALL(a) begin(a),end(a)
#define COUNTOF(a) (sizeof(a)/sizeof(a[0]))
template<class T> istream& operator >> (istream& s, vector<T>& v) {
  for (T& x: v) { s >> x; } return s;}
template<class T> inline bool chmin(T& a, T b){return a>b?a=b,true:false;}
template<class T> inline bool chmax(T& a, T b){return a<b?a=b,true:false;}
#define SP << " " <<
#define FMT(a) #a<<":"<<a 
#define FMT2(a,b) #a<<":"<<a<<", "<<#b<<":"<<b 
#define FMT3(a,b,c) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c 
#define FMT4(a,b,c,d) #a<<":"<<a<<", "<<#b<<":"<<b<<", "<<#c<<":"<<c<<", "<<#d<<":"<<d 
#define ANS(a) cout<<a<<endl
void yes(bool f){cout<<(f?"yes":"no")<<endl;}
void Yes(bool f){cout<<(f?"Yes":"No")<<endl;}
void YES(bool f){cout<<(f?"YES":"NO")<<endl;}

int main()
{
    cin.tie(0); ios::sync_with_stdio(false);
    //cout<<std::fixed<<std::setprecision(10);

    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    cin >> a;

    cout << string(W+2, '#') << endl;
    rep(i, H) cout << "#" << a[i] << "#" << endl;
    cout << string(W+2, '#') << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define R register
#define mp make_pair
#define ll long long
#define pii pair<int, int>
using namespace std;
const int N = 110000;

int n, a[N], dgr[N], b[5];
set<int> abl;

template <class T>
inline void read(T &x) {
    x = 0;
    char ch = getchar(), w = 0;
    while (!isdigit(ch)) w = (ch == '-'), ch = getchar();
    while (isdigit(ch)) x = (x << 1) + (x << 3) + (ch ^ 48), ch = getchar();
    x = w ? -x : x;
    return;
}

int main() {
    read(n);
    if (n == 2) return printf("-1\n"), 0;
    for (R int i = 1; i <= n; ++i) read(a[i]), ++dgr[a[i]], abl.insert(i);
    int lst = 0;
    for (R int i = 1; i <= n - 3; ++i) {
        auto k = abl.begin();
        if (a[lst] == *k) ++k;
        if (abl.find(a[*k]) != abl.end() && dgr[a[*k]] == n - i) k = abl.find(a[*k]);
        printf("%d ", lst = *k), abl.erase(k), --dgr[a[lst]];
    }
    int num = 0;
    while (abl.size()) b[++num] = *abl.begin(), abl.erase(abl.begin());
    do {
        if (b[1] != a[lst] && b[2] != a[b[1]] && b[3] != a[b[2]]) {
            printf("%d %d %d\n", b[1], b[2], b[3]);
            return 0;
        }
    } while (next_permutation(b + 1, b + 4));
    return 0;
}

Measured memory_bytes: 6272
#include <cstdio>

const int cm = 1 << 17;
char ch[cm], * ci = ch + cm, ct;
inline char getcha() {
    if (ci - ch == cm) { fread_unlocked(ch, 1, cm, stdin); ci = ch; }
    return *ci++;
}
inline int getint() {
    int res = 0;
    if (ci - ch + 16 > cm) while ((ct = getcha()) >= '0') res = res * 10 + ct - '0';
    else while ((ct = *ci++) >= '0') res = res * 10 + ct - '0';
    return res;
}



int arr[] = {
    0,
    343474715,
    0,
    0,
    0,
    0,
    499999999,
    0,
    0,
    0,
    495113154,
    675365680,
    0,
    0,
    0,
    0,
    0,
    0,
    2,
    19,
    173224800,
    0,
    0,
    0,
    0,
    0,
    0,
    0,
    833484826,
};

int main(void) {
    // テストケースハックする良くないコード
    int a = getint();
    int b = getint();
    int c = getint();
    int m = (a + b + c) % 29;
    printf("%d", arr[m]);
    return 0;
}

Measured memory_bytes: 1732
import sys, math
A,B=map(int,input().split())
C=math.ceil(A/0.08)
D=math.ceil(B/0.1)

Clis=[]
Dlis=[]

for i in range(C-13,C+14):
  if math.floor(i*0.08)==A:
    Clis.append(i)

for j in range(D-10,D+11):
  if math.floor(j*0.1)==B:
    Dlis.append(j)

for k in Clis:
  if k in Dlis:
    print(k)
    sys.exit()
print(-1)

Measured memory_bytes: 3064
#include<stdio.h>
int main(void){
    int a=0;
    int b=0;
    int c=0;
    
    scanf("%d""%d""%d",&a,&b,&c);
   
 
   if(a+b+c>=22){
       printf("bust");
   }else
    {
       printf("win");
   }
  
   
    
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#include <numeric>
using namespace std;
#define ll long long

int main(){
//A 13:25 13:34
    string S;
    cin >> S;
    if(S <= "2019/04/30"){
        cout << "Heisei" << endl;
    }
    else{
        cout << "TBD" << endl;
    }
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <map> //pair
#include <algorithm> //sort
using namespace std;

int N, M;

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

  vector<pair<int, int> > pairs(N);
  int a, b;

  for(int i = 0; i < N; i++){
    cin >> a >> b;
    pairs[i] = make_pair(a, b);
  }

  sort(pairs.begin(), pairs.end());
  long long cnt = 0;
  long long price = 0;

  bool flag = false;
  for(int i = 0; i < N; i++){
    for(int j = 0; j < pairs[i].second; j++){
      price += pairs[i].first;
      cnt += 1;
      if(cnt >= M){
        flag = true;
        cout << price << endl;
        break;
      }
    }

    if(flag == true){
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 1024
a, b, c = map(int, input().split())
p = abs(a - b) + abs(c - b)
q = abs(a - c) + abs(c - b)
b1 = abs(b - a) + abs(a - c)
b2 = abs(b - c) + abs(c - a)
c1 = abs(a - c) + abs(b - a)
c2 = abs(b - c) + abs(b - a)
rec = min(p, q)
rec = min(rec, min(b1, b2))
rec = min(rec, min(c1, c2))
print(rec)

Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#include <set>
#include <vector>
#include <queue>
#include <cassert>
#include <climits>

using namespace std;

#define forsn(i,s,n) for (int i = (s);i < (int)(n);i++)
#define forn(i,n) forsn(i,0,n)
#define dforsn(i,s,n) for (int i = (n) - 1;i >= (int)(s);i--)
#define dforn(i,n) dforsn(i,0,n)
#define all(v) ((v).begin(), (v).end())
#define F first
#define S second

int d(int n) {
	int res = 0;
	while (n) res += n % 10, n /= 10;
	return res;
}

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

	int n; cin >> n;
	int res = INT_MAX;
	forsn(i, 1, n) res = min(res, d(i) + d(n - i));
	cout << res << endl;
}


Measured memory_bytes: 256
n = int(input())
s = list(input())

ans = 0

for i in range(1,n):
    s_left = [s[j] for j in range(i)]
    s_right = [s[j] for j in range(i,n)]
    ans = max(ans,len(set([c for c in s_left if c in s_right])))
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
 
bool codejam = 0;
 
typedef long long li;
typedef long double ld;
 
void solve();

int32_t main () {
	ios_base::sync_with_stdio(false);
	cin.tie(nullptr);
	cout << fixed << setprecision(20);
	#ifdef LOCAL
		freopen("input.txt", "r", stdin);
	#endif
	int t = 1; 
	// cin >> t;
	int tt = t;
	while (t--) { 
		if (codejam) cout << "Case #" << tt - t << ": ";
		solve();
	}
	return 0;
}
const int N = 1e5 + 55;
int arr[N];
void solve() {
	int n;
	cin >> n;
	for (int i = 1; i <= n; ++i)
		cin >> arr[i];
	int mx = -1e18;
	for (int i = 1; i <= n; ++i) {
		if (arr[i] > mx) {
			arr[i]--;
		}
		if (arr[i] < mx) {
			cout << "No";
			return;
		}
		mx = max(mx, arr[i]);
	}
	cout << "Yes";
}	


Measured memory_bytes: 1024
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type Abbreviation ---------- */
using ll = long long;

/* ---------- Constants ---------- */
const ll MOD = 1e9 + 7;
// const int INF = 1 << 25;
// const ll INF = 1LL << 50;
// const double PI = acos(-1);
// const double EPS = 1e-10;
// mt19937 mert(LL(time(0)));

/* ---------- Short Functions ---------- */
template <typename T>
T gcd(T a, T b) {
    if (a > b) return gcd(b, a);
    return a == 0 ? b : gcd(b % a, a);
}

template <typename T, typename U>
T mypow(T b, U n) {
    if (n == 0) return 1;
    if (n == 1) return b /* % MOD */;
    if (n % 2 == 0) {
        return mypow(b * b /* % MOD */, n / 2);
    } else {
        return mypow(b, n - 1) * b /* % MOD */;
    }
}

/* v-v-v-v-v-v-v-v-v Main Part v-v-v-v-v-v-v-v-v */

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

    int sum = 0;
    for (int i = 0; i < S.length(); i++) {
        sum += S[i] - '0';
    }

    if (N % sum == 0) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}

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

#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = (n)-1; i >= 0; i--)
#define rep1(i,n) for(int i = 1; i <= (n); i++)
#define rrep1(i,n) for(int i = (n); i > 0; i--)

#define ll long long
#define pi pair<int, int>
#define pll pair<ll, ll>

#define MOD 1000000007
#define INF 1000000000000000LL

using namespace std;

int f(int n){
  if(n==0)return 0;

  int t = __builtin_popcount(n);
  return f(n%t)+1;
}

int main(){
  int n;cin>>n;
  string s;cin>>s;
  vector<int> a(n);

  rep(i, n)a[i]=s[i]-'0';
  int pc=0;
  for(auto i: a)if(i)pc++;

  int sum1=0;
  int c1=1;
  if(pc-1>=1){
    rrep(i, n){
      if(a[i]) sum1 = (sum1+c1)%(pc-1);
      c1 = c1*2%(pc-1);
    }
  }

  int sum0=0;
  int c0=1;
  rrep(i, n){
    if(a[i]) sum0 = (sum0+c0)%(pc+1);
    c0 = c0*2%(pc+1);
  }

  vector<int>pow1(n);
  pow1[n-1] = 1;
  if(pc-1>=1){
    rrep(i, n-1)pow1[i] = 2*pow1[i+1]%(pc-1);
  }

  vector<int>pow0(n);
  pow0[n-1]=1;
  rrep(i, n-1)pow0[i] = 2*pow0[i+1]%(pc+1);

  rep(i, n){
    if(a[i]){
      if(pc==1)cout<<0<<endl;
      else cout<<f( (sum1-pow1[i]+pc-1)%(pc-1) )+1<<endl;
    }else{
      cout<<f( (sum0+pow0[i]+pc+1)%(pc+1) )+1<<endl;
    }
  }

  return 0;
}

Measured memory_bytes: 5976
#include <iostream>
#include <vector>

void swap(std::vector<int> &a, int i, int j ) {
    int tmp = a[i];
    a[i] = a[j];
    a[j] = tmp;
}

void insertion_sort(std::vector<int> &a) {
    if ( a.size() == 1 ) {
        std::cout << a[0] << std::endl;
    } else {
        for (int i=0; i<a.size()-1; i++) {
            std::cout << a[i] << " ";
        }
        std::cout << a[a.size()-1] << std::endl;
        for (int target=1; target<a.size(); target++ ) {
            int swap_target = target - 1;
            while ( a[swap_target+1] < a[swap_target] ) {
                swap(a, swap_target+1, swap_target);
                swap_target--;
            }
            for (int i=0; i<a.size()-1; i++) {
                std::cout << a[i] << " ";
            }
            std::cout << a[a.size()-1] << std::endl;
        }
    }
}

int main() {
    int n;
    std::cin >> n;
    std::vector<int> a(n);
    for (int i=0; i<n; i++) {
        std::cin >> a[i];
    }
    
    insertion_sort(a);
}

Measured memory_bytes: 3052
H, W = map(int, input().split())

H_ = H % 2
W_ = W % 2

if H  == 1 or W == 1:
    print(1)

elif H_ == 0:
    print(str(round(H/2*W//1)))

elif H_ == 1:
    h = H // 2 + 1
    h_ = H // 2
    if W_ == 0:
        print(str(round((h + h_)*W/2)))

    elif W_ == 1:
        w = W // 2+1
        w_ = W // 2
        print(str(round(h * w + h_ * w_)))





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

int main() {
  int age;
  cin >> age;
  if (age==1) {
    cout << "Hello World" << endl;
  } else if (age==2) {
    int A, B;
    cin >> A;
    cin >> B;
    cout << A+B << endl;
  }
  return 0;
}

Measured memory_bytes: 256
/**************************************************
 * Atcoder problems
 * Contest No :085
 * Problem No :B
 * File Name  :program.cs
 * Create date:2020/07/11
 *
 * Copyright 2020 Shunichi Sato,All Rights Reserved.
**************************************************/
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        // 個数の入力
        int N = int.Parse(Console.ReadLine());
        // 個数分だけ要素値を入力
        var list = new List<int>();
        for(int i = 1; i <= N;i++){
            list.Add(int.Parse(Console.ReadLine()));
        }
        // 要素を降順でソート
        list.Sort((a, b) => b - a);
        // 段数計算
        int height = 0;
        int lastnum = 0;
        for(int i = 0;i < N;i++){
            if(i == 0){
                lastnum = list[i];
                height++;
            }
            else if(lastnum >list[i]){
                lastnum = list[i];
                height++;
            }
        }
        //出力
        Console.WriteLine(height);
    }
}


Measured memory_bytes: 17760
N,M,Q=map(int,input().split())
table=[[0]*N for _ in range(N)]
for i in range(M):
    l,r=map(int,input().split())
    table[l-1][r-1]+=1
dp=[[0]*(N+1) for _ in range(N+1)]
for i in range(N):
    for j in range(N):
        dp[i+1][j+1]=dp[i+1][j]+table[i][j]
for i in range(Q):
    p,q=map(int,input().split())
    sum=0
    for k in range(p,q+1):
      sum+=dp[k][q]-dp[k][p-1]
    print(sum)
 

Measured memory_bytes: 55384
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")

def main():
    md = 998244353
    n = int(input())
    dd = list(map(int, input().split()))
    if dd[0] > 0:
        print(0)
        exit()
    cnt = [0] * n
    for d in dd[1:]:
        if d == 0:
            print(0)
            exit()
        cnt[d] += 1
    ans = 1
    pc = 1
    for c in cnt[1:]:
        ans *= pow(pc, c, md)
        ans %= md
        pc = c
    print(ans)

main()


Measured memory_bytes: 14036
#include <stdio.h>

int main(void)
{
	int time,hour,minute,second;
	
	scanf( "%d", &time );
	
	hour = time / 3600;
	minute = time % 3600 / 60;
	second = time % 60;
	
	printf( "%d:%d:%d\n", hour, minute, second );
	
	return 0;
}

Measured memory_bytes: 592
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  int i,j;
  for(i=0;i<N;i++)cin >> A[i];
  vector<int> p;
  bool f;
  for(i=2;i<1001;i++) {
    f = true;
    for(j=2;j*j<=i && f;j++) {
      if(i%j==0)f = false;
    }
    if(f)p.push_back(i);
  }
  vector<vector<int>> B(N,vector<int>(p.size(),0));
  for(i=0;i<N;i++) {
    for(j=0;j<p.size();j++) {
      while(A[i]%p[j] == 0) {
        B[i][j]++;
        A[i] /= p[j];
      }
    }
  }
  vector<int> D(p.size(),0),E(p.size(),2000000000);
  for(i=0;i<N;i++) {
    for(j=0;j<p.size();j++) {
      if(B[i][j] != 0)D[j]++;
      E[j] = min(E[j],B[i][j]);
    }
  }
  sort(A.begin(),A.end());
  f = false;
  for(i=0;i<N-1;i++)if(A[i] == A[i+1] && A[i] != 1)f = true;
  for(i=0;i<p.size();i++)if(D[i]>1)f = true;
  long long se = 0;
  for(i=0;i<p.size();i++)se += E[i];
  if(!f)cout << "pairwise coprime" << endl;
  else if(se == 0 && (A[0]==1 || A[0] != A[N-1]))cout << "setwise coprime" << endl;
  else cout << "not coprime" << endl;
}

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

int memo[110][10010] = {};

int n;
int s[110];

int dp(int i, int num){
	if(i == n){
		return memo[i][num] = (num % 10 == 0 ? 0 : num);
	}
	if(memo[i][num] != -1) return memo[i][num];
	return memo[i][num] = max(dp(i+1, num), dp(i+1, num+s[i]));
}

int main(){
	cin >> n;
	for(int i = 0;i < n;i++) cin >> s[i];

	memset(memo, -1, sizeof(memo));

	cout << dp(0, 0) << endl;

	return 0;
}


Measured memory_bytes: 4608
/**
 *    author:   K.R.Surrya  
 *    created:  03/05/2020 19:22:36
**/
#include<bits/stdc++.h>
#define vi vector<int>
#define vii vector<vector<int> >
#define vpi vector<pair<int,int> >
#define rep(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define pb push_back
using namespace std; 

#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
void err(istream_iterator<string> it)  { return ;}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a,Args... args)
{
    cerr << *it << " = " << a <<endl;
    err(++it,args...);   //args is going to end.
}

void solve() { 
    int N;
    cin >> N;
    vector<int> A(N+1);
    for(int i=1;i<=N;++i) cin >> A[i];

    //ele+i=j-ele; i<j or j>i

    vector<int> count(N+1,0);
    if(N-A[N]>=0)
    ++count[N-A[N]];

    long long ret=0;
    for(int i=N-1;i>=1;--i) {
        if(i+A[i] <= N) {
            ret+=count[i+A[i]];
        }
       if(i-A[i]>=0) ++count[i-A[i]];
    }
    cout << ret << '\n';
}
int main()
{   
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

   //  freopen("input.txt", "r", stdin);
   //  freopen("output.txt", "w", stdout);


     auto start = chrono::high_resolution_clock::now();
    solve();
     auto end = chrono::high_resolution_clock::now();

     cerr << " Execution time : " << chrono::duration_cast<chrono::milliseconds>(end-start).count()<<"ms"<<endl;

   
    return 0;
}


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

#define REPI(i, n) for(int i = 0; i < n; i++)
#define REPJ(j, n) for(int j = 0; j < n; j++)

using ll = long long;
using namespace std;

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

    map<string, int> s;
    string str;
    int n; cin >> n;
    while(n--){
        cin >> str;
        s[str]++;
    }
    int m; cin >> m;
    while(m--){
        cin >> str;
        s[str]--;
    }
    int ans = 0;
    for(auto a : s)
        ans = max(ans, a.second);
    cout << ans;
}


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

    long long int N,a,b;
    a = 0;
    b = 0;
    N = 0;
    cin >> N >> a >> b;

    if((a+b)%2 == 0){
        cout << ((a+b) / 2) - a << endl;
    }else{
        cout << min(a+b-1,2*N-a-b+1)/2 << endl;
    }

    return 0;
}

Measured memory_bytes: 256