akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int main() {
	LL n; cin >> n;
	LL mini = LLBIG;
	LL ans = 4;
	for (int i = 0; i < 5; i++) {
		LL x; cin >> x;
		mini = min(mini, x);
	}
	ans += n / mini + (n%mini ? 1 : 0);
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
n,k=map(int,input().split())
a=list(map(int,input().split()))
s=set(a)
l=[0]*(n+1)
for i in range(n):
    l[a[i]]+=1
l=[i for i in l if i>0]
l.sort()
le=len(s)
c=0
for i in range(len(l)):
    if le<=k:
        break
    else:
        c+=l[i]
        le-=1
print(c)


Measured memory_bytes: 26148
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < (b); i++)
#define iter(it,c) for(__typeof((c).begin()) it = (c).begin(); it != (c).end();++it)
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef long long ll;
const int INF = ~(1<<31);
const double pi = acos(-1);

int main() {
	cin.sync_with_stdio(false);
	int n,k;
	cin >> n >> k;
	vi arr(n);
	rep(i,0,n) cin >> arr[i];
	sort(arr.rbegin(), arr.rend());
	int sum = 0;
	rep(i,0,k) sum += arr[i];
	cout << sum << endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
using namespace std;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return w*s;}
int dp[1<<16][20],Cost[1<<16];
int mp[20][20],n,M; 
int main()
{
	n=read(),M=read();
	for(rint i=1;i<=M;++i){
		int u=read(),v=read(),c=read();
		mp[u][v]=c;mp[v][u]=c; 
	}
	int Max=1<<n;
	for(rint i=0;i<Max;++i){
		for(rint j=1;j<=n;++j)
		{
			if((i&(1<<j-1))==0) continue;
			for(rint k=j+1;k<=n;++k)
			{
				if((i&(1<<k-1))==0) continue;
				Cost[i]+=mp[j][k];
			}
		}
	}memset(dp,-1,sizeof(dp));
	dp[1][1]=0;
	for(rint i=1;i<Max;i+=2)
	{
		for(rint j=1;j<=n;++j)
		{
			if(dp[i][j]==-1) continue;
			if(!(i&(1<<j-1))) continue;
			for(rint k=1;k<=n;++k)
			{
				if((i&(1<<k-1))) continue;
				if(mp[j][k])
				dp[i|(1<<(k-1))][k]=max(dp[i|(1<<(k-1))][k],dp[i][j]+mp[j][k]);
			}
			int set=((Max-1)^i)|(1<<j-1);
			for(rint S=set;;S=(S-1)&set)
			{
				dp[i|S][j]=max(dp[i|S][j],dp[i][j]+Cost[S]);
				if(S==0) break;
			}
		}
	}
	int mx=0;
	for(rint i=((Max-1)>>1)+2;i<Max;i+=2) mx=max(mx,dp[i][n]);
	cout<<Cost[Max-1]-mx<<"\n";
	return 0;
}




Measured memory_bytes: 5504
#include <bits/stdc++.h>
using namespace std;
char s[27];
int cnt[37];
int main()
{
	scanf("%s",s+1);
	int len=strlen(s+1);
	for (int i=1;i<=len;i++)
		++cnt[s[i]-'a'+1];
	bool check=true;
	for (int i=1;i<=26;i++)
		if (cnt[i]>1) check=false;
	if (!check) printf("%d\n",-1);
	else
	{
		if (len<26)
		{
			for (int i=1;i<=len;i++)
				printf("%c",s[i]);
			int ans=26;
			for (int j=1;j<=26;j++)
				if (cnt[j]==0&&j<ans) ans=j;
			printf("%c",ans+'a'-1);
			printf("\n");
		} else
		{
			bool flag=true;
			for (int i=1;i<=26;i++)
				if (s[i]-'a'+1!=27-i) flag=false;
			if (flag) printf("%d\n",-1); else
			{
				int now=len;
				int t=0;
				memset(cnt,0,sizeof(cnt));
				for (int i=len;i;i--)
				{
					if (s[i]>t) t=s[i];
					++cnt[s[i]-'a'+1];
					if (s[i]!=t)
					{
						now=i;
						break;
					}
				}
				for (int i=1;i<now;i++)
					printf("%c",s[i]);
				for (int i=s[now]-'a'+2;i<=26;i++)
					if (cnt[i]>0)
					{
						printf("%c\n",i+'a'-1);
						return 0;
					}
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
S=input()
n=len(S)
ans=0

no=False
for i in range(n):
    for j in range(i,n):
        for k in range(i,j+1):
            if not S[k] in ("A","C","G","T"):
                no=True
                break
        if no:
            no=False
            break
        ans=max(ans,j-i+1)
print(ans)

Measured memory_bytes: 3060
#![allow(unused_imports)]
#![allow(unused_variables)]
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(deprecated)]

use std::cell::{Cell, Ref, RefCell, RefMut};
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;
use std::usize;

const MOD_10_9_7: u64 = 1_000_000_007;
const INF: i64 = 1_000_000_000_000;
const MIN_INF: i64 = -1_000_000_000_000;

/// FYI: https://github.com/vain0x/scan-bench
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($t:ty) =>
        (rl().parse::<$t>().unwrap());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();
    buf.trim_right().to_owned()
}

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),*) => {
        eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

fn main() {
    let c1 = read!(String);
    let c2 = read!(String);
    let c3 = read!(String);

    let c1 = c1.chars().collect::<Vec<_>>();
    let c2 = c2.chars().collect::<Vec<_>>();
    let c3 = c3.chars().collect::<Vec<_>>();
    println!("{}{}{}", c1[0], c2[1], c3[2]);
}


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

#define ld long double
#define MAXN 3005

using namespace std;

ld dp[MAXN][MAXN];

int main() {

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

    int n;
    cin >> n;

    ld p[n];
    for(int i = 0; i < n; i++)
        cin >> p[i];
    

    dp[0][0] = 1.0;
    for(int i = 1; i <= n; i++) {
        for(int j = 0; j <= i; j++) {
            if(j == 0) {
                dp[i][j] = dp[i - 1][j] * (1.0 - p[i - 1]);
                continue;
            }
            dp[i][j] = dp[i - 1][j] * (1.0 - p[i - 1]) + dp[i - 1][j - 1] * p[i - 1];
        }
    }

    ld prob = 0.0;
    for(int i = n / 2 + 1; i <= n; i++)
        prob += dp[n][i];
    cout << fixed << setprecision(10) << prob << endl;
    return 0;
}


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

typedef long long ll;
const double EPS = 1e-8;
typedef pair<ll,ll> P;
const ll INF = (1000000000000000LL);
const ll MAX_V = 1000;
 
 
//テヲツ慊?・ツ、ツァテヲツオツ?Ford-Fulkerson O(F|E|)
  
struct edge{ll to,cap,rev;};
  
vector<edge> G[MAX_V];
bool used[MAX_V];
  
void add_edge(ll from, ll to, ll cap){
  G[from].push_back((edge){to, cap, G[to].size()});
  G[to].push_back((edge){from, 0, G[from].size()-1});
}
  
ll dfs(ll v, ll t, ll f){
  if(v == t)return f;
  used[v] = true;
  for(ll i = 0 ; i < (ll)G[v].size() ; i++){
    edge &e = G[v][i];
    if(!used[e.to] && e.cap > 0){
      ll d = dfs(e.to,t,min(f,e.cap));
      if(d > 0){
        e.cap -= d;
        G[e.to][e.rev].cap += d;
        return d;
      }
    }
  }
  return 0;
}
  
ll maxflow(ll s,ll t){
  ll flow = 0;
  for(;;){
    memset(used,0,sizeof(used));
    ll f = dfs(s,t,INF);  
    //  cout << f<< endl;  
    if(f == 0)return flow;
    flow += f;
  }
}

string weeks[]={"Sunday", "Monday", "Tuesday", "Wednesday", "Thursday", "Friday", "Saturday"};

ll getday(string s){
  for(ll i=0;i<7;i++) if( s == weeks[i] ) return i;
  assert(false);
}
 

ll N,W;
int main(){
  while( cin >> N >> W && (N|W) ){    
    ll sum = 0;
    int s = N+7, t = N+8;
    for(ll i=0;i<N;i++){
      ll t,c;
      cin >> t >> c;
      sum += t;
      for(ll j=0;j<c;j++){
        string m; 
        cin >> m;
        int d = getday(m);
        add_edge( i, N+d, INF );
      }
      add_edge(s,i,t);      
    }
    for(int i=0;i<7;i++)
      add_edge( N+i, t, W );
    if( maxflow( s,t ) == sum ) cout << "Yes" << endl;
    else cout << "No" << endl;

    for(int i=0;i<=t;i++) G[i].clear();
  }
}

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

int main() {
  int N;
  cin >> N;
  int k = 1;
  int l = 0;
  for (int i = 0; i < 10; i++){
    l +=  N % k * 10 / k;
    k = k * 10;
  }
  if (N % l == 0){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl; 
  }
}

Measured memory_bytes: 256
N = int(input())
S = input()
rn = [0 for _ in range(N)]
gn = [0 for _ in range(N)]
bn = [0 for _ in range(N)]
rgn = [0 for _ in range(N)]
gbn = [0 for _ in range(N)]
brn = [0 for _ in range(N)]
for i, s in enumerate(S):
    if i == 0:
        if s == "R":
            rn[i] = 1
            rgn[i] = 1
            brn[i] = 1
        if s == "G":
            gn[i] = 1
            rgn[i] = 1
            gbn[i] = 1
        if s == "B":
            bn[i] = 1
            gbn[i] = 1
            brn[i] = 1
    else:
        if s == "R":
            rn[i] = rn[i-1] + 1
            gn[i] = gn[i-1]
            bn[i] = bn[i-1]
            rgn[i] = rgn[i-1] + 1
            gbn[i] = gbn[i-1]
            brn[i] = brn[i-1] + 1
        if s == "G":
            rn[i] = rn[i-1]
            gn[i] = gn[i-1] + 1
            bn[i] = bn[i-1]
            rgn[i] = rgn[i-1] + 1
            gbn[i] = gbn[i-1] + 1    
            brn[i] = brn[i-1]       
        if s == "B":
            rn[i] = rn[i-1]
            gn[i] = gn[i-1]
            bn[i] = bn[i-1] + 1
            rgn[i] = rgn[i-1]
            gbn[i] = gbn[i-1] + 1
            brn[i] = brn[i-1] + 1
ans = 0
for i, s in enumerate(S):
    if i == 0 or i == N-1:
        continue
    if s == "R":
        ans += gn[i-1] * (bn[-1] - bn[i])
        ans += bn[i-1] * (gn[-1] - gn[i])
    if s == "G":
        ans += rn[i-1] * (bn[-1] - bn[i])
        ans += bn[i-1] * (rn[-1] - rn[i])
    if s == "B":
        ans += rn[i-1] * (gn[-1] - gn[i])
        ans += gn[i-1] * (rn[-1] - rn[i])
    for j in range(min(i, N - i - 1)):
        if S[i-j-1] != S[i+j+1] and S[i-j-1] != s and S[i+j+1] != s:
            ans -= 1
print(ans)


Measured memory_bytes: 68816
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000000000000


long long get_min(vector<vector<int>> &dis,int y,int x){
	if(y==0||x==0||y+1==dis.size()||x+1==dis.size())return -1;
	return min({dis[y+1][x],dis[y-1][x],dis[y][x+1],dis[y][x-1]});
}

int main(){
	
	int N;
	cin>>N;
	
	vector<int> P(N*N);
	
	for(int i=0;i<N*N;i++){
		scanf("%d",&P[i]);
		P[i]--;
	}
	
	vector<vector<int>> dis(N,vector<int>(N));
	
	for(int i=0;i<N;i++){
		for(int j=0;j<N;j++){
			dis[i][j] = min({i,N-1-i,j,N-1-j});
		}
	}
	
	long long ans = 0;
	
	vector<vector<bool>> B(N,vector<bool>(N,true));
	
	for(int i=0;i<N*N;i++){
		int y = P[i]/N;
		int x = P[i]%N;
		
		ans += (long long)dis[y][x];
		B[y][x] = false;
		dis[y][x] = get_min(dis,y,x);
		
		deque<pair<int,int>> D;
		D.emplace_back(y,x);
		
		while(D.size()!=0){			
			
			int yy = D.back().first;
			int xx = D.back().second;
			D.pop_back();
			
			for(int j=0;j<4;j++){
				int ny = yy;
				int nx = xx;
				if(j==0)ny++;
				if(j==1)ny--;
				if(j==2)nx++;
				if(j==3)nx--;
			
				if(nx<0||nx>=N||ny<0||ny>=N)continue;
				int ND = dis[yy][xx];
				if(B[ny][nx]){
					ND++;
					if(ND<dis[ny][nx]){
						dis[ny][nx] = ND;
						D.emplace_front(ny,nx);
					}
				}
				else{
					if(ND<dis[ny][nx]){
						dis[ny][nx] = ND;
						D.emplace_back(ny,nx);
					}
				}
			}
		}
	}
		
	cout<<ans<<endl;
				
	
	return 0;
}

Measured memory_bytes: 6368
import java.util.*;

public class Main{
    public static void main(String[] args){
        System.out.println(Main.isIn());
    }

    public static String isIn(){
        int[] array = new int[5];
        Scanner scan = new Scanner(System.in);
        for(int i=0; i < 5; i++){
            array[i] = scan.nextInt();
        }
        boolean boolX = array[4] <= array[2] && array[2] + array[4] <= array[0];
        boolean boolY = array[4] <= array[3] && array[4] + array[3] <= array[1];
        if (boolX && boolY){
            return "Yes";
        }
        else{
            return "No";
        }
    }
} 



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

template<typename T, typename U> void cmax(T &a, U b) { if (a < b) a = b; }
template<typename T, typename U> void cmin(T &a, U b) { if (a > b) a = b; }

signed main() {
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  long A, B, C, D;
  cin >> A >> B >> C >> D;
  cout << max({A * C, A * D, B * C, B * D}) << "\n";
}

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

#define int long long
#define double long double

#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define ALL(v) (v).begin(), (v).end()

#define fi first
#define se second
#define pb push_back
#define mp make_pair

using namespace std;

using pi = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vs = vector<string>;
using vb = vector<bool>;
using vpi = vector<pi>;
using vvi = vector<vi>;
using vvb = vector<vb>;

const int INF = 1e16;
const int MOD = 1e9+7;

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


signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int n; cin >> n;
    vi a(n); REP(i, n) cin >> a[i];
    int s = a[0];
    int ans = -INF;
    REP(i, n)
    {
        chmin(s, a[i]);
        if(i < n-1) chmax(ans, a[i+1]-s);
    }
    cout << ans << endl;
}


Measured memory_bytes: 4412
#include<bits/stdc++.h>
#define fi first
#define se second
using namespace std;
typedef long long ll;
const int MAXN = 10 + 1e6;
const ll oo = 1 + 1e18;
const ll mod = 7 + 1e9;

int x, n, a[MAXN], d[MAXN];

int main()
{
    #define TASK "ABC"
    #ifndef ONLINE_JUDGE
    freopen(TASK".inp","r",stdin);
    freopen(TASK".out","w",stdout);
    #endif ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    cin >> x >> n;

    if (n == 0)
    {
        cout << x;
        return 0;
    }

    for (int i = 1; i <= n; i++)
    {
        cin >> a[i];
        d[a[i]] = 1;
    }

    int mi, ans;

    for (int i = x; i >= 0; i--)
    {
        if (!d[i])
        {
            ans = i, mi = x - i + 1;
            break;
        }
    }

    for (int i = x + 1; i <= 1000; i++)
    {
        if (!d[i])
        {
            if (mi > i - x + 1)
            {
                cout << i;
                return 0;
            }
            cout << ans;
            return 0;
        }
    }


    return 0;
}




















































































Measured memory_bytes: 3644
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define fi first
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define fit(x) for(auto it=x.begin();it!=x.end();++it)
#define se second
#define mp make_pair
#define ALP "abcdefghijklmnopqrstuvwxyz"
#define nline cout<<"\n"
#define rep(i,x) for(i=0;i<x;++i)
#define repr(i,a,b) for(i=a;i<=b;++i)
#define mi2 500000004
#define mi3 333333336
#define MOD 1000000007
#define N 1000005
#define pll pair<ll,ll>
#define Vll vector<ll>
#define W(t) while(t--)
#define modsum(a,b,M) (a%M + b%M)%M
#define modsub(a,b,M) (a%M - b%M + M)%M
#define modmul(a,b,M) (a%M * b%M)%M
#define moddiv(a,b,M) (a%M * modinv(b,M)%M)%M
using namespace std;
ll powermod(ll x,ll n,ll M)
{
	ll result=1;
	while(n>0)
	{
	  if(n % 2 ==1)
	    result=(result * x)%M;
	  x=(x*x)%M;
	  n=n/2;
	}
	return result;
}
vector<ll> readll() {
	cin>>ws;
	vector<ll> v;
	string input;
	getline(cin, input);
	cout<<input;
	istringstream is(input);
	ll num;
	while(is>>num) v.pb(num);
	return v;
}
ll modinv(ll n,ll p) {
	return powermod(n,p-2,p);
}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
ll fact[1000005],invf[1000005];
void facmod(ll n,ll M) {
	ll i;
	fact[0]=fact[1]=1;
	for(i=2;i<=n;++i) {
		fact[i]=((fact[i-1])%M * (i%M))%M;
	}
	invf[n]=modinv(fact[n],M);
	for (i=n-1;i>=0;--i){
		invf[i]=invf[i+1]*(i+1);
		invf[i]%=M;
	}
}
/*****
ll T=0;
ll p[200005], d[200005];
ll tin[200005], tout[200005];
vector<ll> g[200005];

void dfs(ll v, ll par = 1, ll dep = 0) {
	p[v] = par;
	d[v] = dep;
	tin[v] = T++;
	for (auto to : g[v]) {
		if (to == par) continue;
		dfs(to, v, dep + 1);
	}
	tout[v] = T++;
}
****/
void solve() {
	ll n,m,k,sm=0;
	cin>>n>>k;
	if(n>=k) {
		n=n%k;
	}
	cout<<min(n,k-n);
}
int main() {
  	fastio;
	ll t=1;
	//cin>>t;
	W(t) {
		solve();
	}
	
  	return 0;
}

Measured memory_bytes: 256
//*****Jai Mata di*****//

#include<bits/stdc++.h>
using namespace std;
#define Nitroboost  ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define ll long long int 
const int mod=1e9+7;
const int N=2e5+15;
#define debug cout<<"Good uptill here"<<endl<<flush;
#define deb(x) cout<<#x<<":"<<x<<endl<<flush;

vector<int>adj[N];
int h[N];
ll ans=0;
priority_queue<int,vector<int>,greater<int> >q;
vector<pair<int,int> >L,R;
int rsum[100],dsum[100];
int dp[100];


int main()
{
    Nitroboost;
    int n,m,k;
    cin>>n>>m>>k;
    char a[n+1][m+1];
    int p=0;
    for(int i=0;i<n;i++)
        for(int j=0;j<m;j++){
            cin>>a[i][j];
            if(a[i][j]=='#')
                p++;}
    int cnt=0;
    for(int i=0;i<(1<<n);i++)
        for(int j=0;j<(1<<m);j++)
        {
            int black=0;
            for(int r=0;r<n;r++)
                for(int c=0;c<m;c++)
                {
                    if((1<<r&i) && (1<<c &j) && a[r][c]=='#')
                     black++;
                }
                if(black==k)
                    cnt++;
                }
        
    cout<<cnt;
    }

Measured memory_bytes: 8352
h,w=map(int,input().split())
s=[]
for i in range(h):
    s_i=input()
    s.append(s_i)
for i in range(h):
    s_list=list(s[i])
    for j in range(w):
        if s[i][j]==".":
            ans=0
            for k in range(-1,2):
                if i+k<0 or i+k>h-1:
                    continue
                for l in range(-1,2):
                    if j+l<0 or j+l>w-1:
                        continue
                    if s[i+k][j+l]=="#":
                        ans+=1
            s_list[j]=str(ans)
    s_ans = "".join(s_list)
    print(s_ans)

Measured memory_bytes: 3064
N = gets.to_i
dic = Hash.new(0)
N.times do
  dic[gets.chomp] += 1
end

M = gets.to_i
M.times do
  dic[gets.chomp] -= 1
end

v = dic.sort_by {|_, v| -v }
p v[0][1] > 0 ? v[0][1] : 0

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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

typedef pair<ll, ll> P;

int main() {
    int N;
    cin >> N;
    vector<P> p(N);
    rep(i, N) {
        ll x, l;
        cin >> x >> l;
        p[i].first = x + l;
        p[i].second = x - l;
    }

    sort(p.begin(), p.end());
    int ans = 0;
    ll t = p[0].second - 1;
    rep(i, N) {
        if (t <= p[i].second) {
            t = p[i].first;
            ans++;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 1920
#include <stdio.h>
 
int main()
{
    int H1, M1, H2, M2, K;
    scanf("%d %d %d %d %d", &H1, &M1, &H2, &M2, &K);
    int totalHours = (H2-H1)*60;
    int totalMinutes = M2-M1;
    printf("%d\n", totalHours+totalMinutes-K);
    return 0;
}

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

class UnionFind
{
public:
    UnionFind(int n) : parent(n), rank(n){
        for(int i = 0; i < n; ++i){
            parent[i] = i;
            rank[i] = 0;
        }
    }
    
    int find(int i){
        if(parent[i] == i){
            return i;
        } else {
            return parent[i] = find(parent[i]);
        }
    }
    
    bool same(int i, int j){
        return find(i) == find(j);
    }
    
    void unite(int i, int j){
        i = find(i);
        j = find(j);
        if(i == j) return;
        else if(rank[i] < rank[j]){
            parent[i] = j;
        } else {
            parent[j] = i;
            if(rank[i] == rank[j]) ++rank[i];
        }
    }
    
private:
    vector<int> parent;
    vector<int> rank;
};

struct Edge{
    int u,v,cost;
};

vector<Edge> E;

int main()
{
    int n,cost,ans = 0;
    cin >> n;
    for(int i = 0; i < n; ++i){
        for(int j = 0; j < n; ++j){
            cin >> cost;
            if(cost != -1){
                Edge e;
                e.u = i; e.v = j; e.cost = cost;
                E.push_back(e);
            }
        }
    }
    
    sort(E.begin(), E.end(), [](const Edge& x, const Edge& y){return x.cost < y.cost;});
    
    UnionFind U(n);
    
    for(int i = 0; i < E.size(); ++i){
        if(!U.same(E[i].u, E[i].v)){
            U.unite(E[i].u, E[i].v);
            ans += E[i].cost;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 1344
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;
int main(){
  int a,b,c,n,e,f,g,h;
  vector<int> vec[3];
  int memo[301];
  while(1){
    scanf("%d %d %d",&a,&b,&c);
    if(a==0 && b==0 && c==0) break;
    fill(memo,memo+301,2);
    scanf("%d",&n);
    for(int i=0;i<n;i++){
      scanf("%d %d %d %d",&e,&f,&g,&h);
      if(h==1){
	memo[e] = 1;
	memo[f] = 1;
	memo[g] = 1;
      } else if(h==0){
	vec[0].push_back(e);
	vec[1].push_back(f);
	vec[2].push_back(g);
      }
    }
    for(int i=0;i<vec[0].size();i++){
      if(memo[vec[1][i]] == 1 && memo[vec[2][i]] == 1) memo[vec[0][i]] = 0;
      else if(memo[vec[0][i]] == 1 && memo[vec[2][i]] == 1) memo[vec[1][i]] = 0;
      else if(memo[vec[0][i]] == 1 && memo[vec[1][i]] == 1) memo[vec[2][i]] = 0;
    }
    for(int i=1;i<=a+b+c;i++)
      printf("%d\n",memo[i]);
    vec[0].clear();
    vec[1].clear();
    vec[2].clear();
  }
  return (0);
}

Measured memory_bytes: 2684
#include<bits/stdc++.h> 
//#define <- プログラムの文字列を置換する
//typedef <- 新しい型に名前を付けるためのキーワード

using namespace std;

#define MAX_N 1

typedef long long ll;

const double pi = 3.141592653589793;
const long long MOD = 1e9 + 7;
const long long INF = 1e15;

int main(){
    string n;
    cin >> n;
    for(int i = 0; i < n.length(); i++){
        if(n[i] == '1') n[i] = '9';
        else n[i] = '1' ;
    }
    cout << stoi(n) << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define N 100005
#define MOD 1000000007
#define dd double
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;



int main() {
ios_base::sync_with_stdio(false);
cin.tie(NULL);
//ios_base& scientific (ios_base& str);
ll a, b, c;
cin >> a >> b >> c;
ll ans = (c-(a-b));
if(ans<0)
	cout << 0;
else cout << ans;
return 0;
}



Measured memory_bytes: 256
def examC():
    N = I(); A = LI()
    ans = sum(A)-N
    print(ans)

import sys,copy,bisect,itertools,heapq,math
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
mod = 10**9 + 7
inf = float('inf')

examC()


Measured memory_bytes: 3828
#include <iostream>
#include <algorithm>
#include <string>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;
typedef long int li;
typedef long long int lli;
typedef pair<lli, int> P;
const lli INF = 0xfffffffffff;
int main(){
	int x1, x2, x3, x4, y1, y2, y3, y4;
	cin >> x1 >> y1 >> x2 >> y2;
	x3 = x2 + y1 - y2;
	y3 = y2 - x1 + x2;
	x4 = x3 + y2 - y3;
	y4 = y3 - x2 + x3;
	cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	priority_queue<pair<long long, long long> >q;
	long long n, k, x, y, a = 0;
	scanf("%lld%lld", &n, &k);
	for(int i = 1; i <= n; i++){
		scanf("%lld%lld", &x, &y);
		q.push(make_pair(-x, -y));
	}
	while(true){
		x = -q.top().first;
		y = -q.top().second;
		q.pop();
		a = a + y;
		if(a >= k){
			cout << x;
			break;
		}
	}
}

Measured memory_bytes: 2420
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <queue>
#include <sstream>
#include <unordered_map>
#include <cstring>
#include <iomanip>

using namespace std;

typedef long long ll;

const ll INF=1e9+7;

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

#define rep(i,n) for(int i=0;i<(n);i++)

int main(){
    ll N,min=INF*10000;
    cin>>N;
    for(ll i=1;i<=sqrt(N);i++){
        if(N%i==0){
            ll a=N/i;
            ll b=i;
            if(min>a+b-2){
                min=a+b-2;
            }
        }
    }
    cout<<min<<endl;
    return 0;
}

//a=97,z=122

//6,15の時

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.nio.charset.StandardCharsets;

public class Main {

	static int count = 0;
	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		int n = Integer.parseInt(in.readLine());

		String[] tmp = in.readLine().split(" ");
		int[] a = new int[n];
		for(int i = 0; i < n; i++) {
			a[i] = Integer.parseInt(tmp[i]);
		}
		mergeSort(a, 0, n);
		for(int i = 0; i < n-1; i++) {
			System.out.print(a[i] + " ");
		}
		System.out.println(a[n-1]);

		System.out.println(count);

	}
	static void mergeSort(int[] a, int left, int right) {
		if(left + 1 < right) {
			int mid = (left + right) / 2;
			mergeSort(a, left, mid);
			mergeSort(a, mid, right);
			merge(a, left, mid, right);
		}
	}
	static void merge(int[] a, int left, int mid, int right) {
		int n1 = mid-left;
		int n2 = right-mid;
		
		int[] b = new int[n1+1];
		for(int i = 0; i <n1; i++) {
			b[i] = a[left + i];
		}		
		b[n1] = Integer.MAX_VALUE;
		int[] c = new int[n2+1];
		for(int i = 0; i <n2; i++) {
			c[i] = a[mid + i];
		}
		c[n2] = Integer.MAX_VALUE;
		
		int i = 0, j = 0;
		for (int k = left; k < right; k++) {
			if(b[i] <= c[j]) {
				a[k] = b[i];
				i++;
			} else {
				a[k] = c[j];
				j++;
			}
			
			count++;
		}
	}
	
}


Measured memory_bytes: 163304
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <vector>
#include <map>
#include <sstream>
#include <iostream>
#include <queue>
#include <algorithm>
#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)
using namespace std;
typedef long long ll;

ll gcd(ll a, ll b) {
  return b == 0 ? a : gcd(b, a%b);
}
ll lcm(ll a, ll b) {
  ll g = gcd(a, b);
  return a / g * b;
}

char buf1[100000+10];
char buf2[100000+10];

int main(void) {
  int n, m;
  scanf("%d%d", &n, &m);
  // if(n <= m) {
  //   scanf("%s%s", buf1, buf2);
  // } else {
  //   swap(n, m);
  //   scanf("%s%s", buf2, buf1);
  // }
  // if(m % n == 0) {
  //   int d = m / n;
  //   bool ok = true;
  //   REP(i, n) {
  //     if(buf1[i] != buf2[i*d]) {
  //       ok = false;
  //       break;
  //     }
  //   }
  //   printf("%d\n", ok ? m : -1);
  //   return 0;
  // }


  scanf("%s%s", buf1, buf2);

  ll g = gcd(n, m);
  bool ok = true;
  int d1 = n/g;
  int d2 = m/g;
  REP(i, g) {
    if(buf1[i*d1] != buf2[i*d2]) {
      ok = false;
      break;
    }
  }

  printf("%lld\n", ok ? lcm(n, m) : -1);
  
  return 0;
}


Measured memory_bytes: 384
import Foundation

func readInts() -> [Int] {
    return readLine()!.split(separator: " ").map { Int($0)! }
}

func main() {
    let a = readInts()
    let N = a[0]
    let X = a[1]
    let T = a[2]
    let d = Int(ceil(Double(N) / Double(X)))
    print("\(T * d)")
}

main()


Measured memory_bytes: 13564
import math

N = int(input())
coordinate_list = [input().split() for i in range(N)] 

distance_list = []

for i, one_coordinate in enumerate(coordinate_list[:len(coordinate_list)]):
    mini_distance_list = []
    for another_cordinate in coordinate_list[i+1:]:
        distance = math.sqrt((int(one_coordinate[0]) - int(another_cordinate[0])) ** 2 + (int(one_coordinate[1]) - int(another_cordinate[1])) ** 2)
        distance_list.append(distance)
        #mini_distance_list.append(distance)
    #distance_list.append(mini_distance_list)

distance_list = [n*math.factorial(N-1) for n in distance_list]

print(2*sum(distance_list)/math.factorial(N))

Measured memory_bytes: 3064
M, D = map(int, input().split())

if M < 4 or D < 22:
    print(0)

else:
    cnt = 0
    for m in range(4, M+1):
        for d in range(22, D+1):
            d1 = d // 10
            d10 = d % 10
            if d1 >= 2 and d10 >= 2 and d1 * d10 == m:
                cnt += 1

    print(cnt)

Measured memory_bytes: 3060
loop = int(input())
ans = [0, 0]
for _ in range(loop):
    
    arr = input().split()
    
    if arr[0] > arr[1]:
        ans[0] += 3
    elif arr[0] < arr[1]:
        ans[1] += 3
    else:
        ans[0] += 1
        ans[1] += 1

print(ans[0], ans[1])



Measured memory_bytes: 5596
x,a,b = map(int,input().split())
l = -1
r = 10**18+1
while r - l > 1 :
	c = (r + l) // 2
	sum = (a - b) * c + a
	if sum >= x : r = c
	else : l = c
if x <= a : print(1)
elif r != 10**18+1 : print(2 * r + 1)
else : print(-1)

Measured memory_bytes: 3064
N=int(input())
P=[None]*N
for i in range(N):
  x,l=map(int,input().split())
  P[i]=[x,x-l,x+l]
  
P=sorted(P,key=lambda x:x[2])

ans=N
curL=P[0][1]
curR=P[0][2]
for i in range(1,N):
  l=P[i][1]
  r=P[i][2]
  if l<curR:
    ans-=1
  else:
    curR=r

print(ans)

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

int main(){
	
	int m;
	int h;
	int S;
	cin >> S;

	h = S / 3600;
	S -= h * 3600;

	m = S / 60;
	S -= m * 60;

	cout << h << ":" << m << ":" << S << endl;

	return 0;
}


Measured memory_bytes: 3096
#include<iostream>
#include<cmath>
#include<algorithm>
using namespace std;

int main(){
    int total_num;
    cin >> total_num;
    int a,b,c;
    for (int i = 0; i< total_num;i++){
        cin >> a >> b >> c;
        int array[3] = {a,b,c};
        std::sort(array, array+3);
        if (pow(array[2], 2) == pow(array[0],2) + pow(array[1],2))
            cout << "YES" << endl;
        else
            cout << "NO" << endl;
    }

}



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

using namespace std;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	string s;
	cin >> s;
	for (int i = 0; i < s.size(); i += 2)
		cout << s[i];
	cout << endl;
	return 0;
}


Measured memory_bytes: 592
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
// #define main int main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
#define stlice(from, to) substr(from, (to) - (from) + 1)
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
using namespace std;
using pii = pair<int, int>;
using vi = vector<int>;
using vd = vector<double>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vpii = vector<pii>;
using vvi = vector<vi>;
using vvb = vector<vb>;
using vvpii = vector<vpii>;
template<typename A> using fn = function<A>;
constexpr int INF = sizeof(int) == sizeof(long long) ? 1000000000000000000LL : 1000000000;
constexpr int MOD = 1000000007;
constexpr double PI = acos(-1);
template<typename A, typename B> bool cmin(A &a, const B &b) { return a > b ? (a = b, true) : false; }
template<typename A, typename B> bool cmax(A &a, const B &b) { return a < b ? (a = b, true) : false; }
constexpr bool odd(const int &n) { return n & 1; }
constexpr bool even(const int &n) { return !odd(n); }
template<typename V> constexpr typename V::value_type sum(const V &v) { return accumulate(all(v), 0); }
void solve();
main { solve(); return 0; }
// clang-format on

void solve() {
  int n;
  cin >> n;
  rep(i, n) {
    float x1, y1, x2, y2, x3, y3, x4, y4;
    cin >> x1 >> y1 >> x2 >> y2 >> x3 >> y3 >> x4 >> y4;
    cout << ((y2 - y1) / (x2 - x1) == (y4 - y3) / (x4 - x3) ? "YES" : "NO") << endl;
  }
}

Measured memory_bytes: 3048
#include<iostream>
#include<cstdio>
#include<vector>
#include<algorithm>
using namespace std;

int main(){
    int A,B,cA[5000],cB[5000],ans=0;
    cin>>A>>B;
    for(int i=0;i<A;i++) cin>>cA[i];
    for(int i=0;i<B;i++) cin>>cB[i];
    for(int i=0;i<B;i++){
        int latte=i;
        for(int j=0;j<A;j++){
            if(cA[j]==cB[latte]){
                latte++;
                ans = max(ans,latte-i);
            }
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 1184
#pragma target("avx")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef unordered_map<ll, ll> U_MAP;
typedef priority_queue<ll> pq;
typedef priority_queue<ll, vector<ll>, greater<ll>> rpq;
constexpr ll INF = 1e9, MOD = 1e9 + 7, ohara = 1e6 + 10;
constexpr ll LINF = 1e18;

#define rep(i, n) for (ll(i) = 0; (i) < (int)(n); (i)++)
#define rrep(i, a, b) for (ll i = (a); i < (b); i++)
#define rrrep(i, a, b) for (ll i = (a); i >= (b); i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout << (x) << endl
#define doublecout(a) cout << fixed << setprecision(15) << a << endl;
#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
string to_string(string s) { return '"' + s + '"'; }
string to_string(const char* s) { return to_string((string)s); }
string to_string(bool b) { return (b ? "true" : "false"); }
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto& x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
void debug_out() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

//------ Believe yourself as a genius!!!!!! ------

int dy[] = {1, 0, -1, 0};
int dx[] = {0, 1, 0, -1};
// int dy[]={-1,0,1,-1,1,-1,0,1};int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"), s;
ll n, cnt, ans, a, b, c, d, tmp, m, h, w, x, y, sum, k, q;

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

  cin >> a >> b >> c >> d;
  while (1) {
    c -= b;
    if (c <= 0) {
      ans = 1;
      break;
    }
    a -= d;
    if (a <= 0) {
      ans = 2;
      break;
    }
  }
  if (ans == 1)
    Cout("Yes");
  else
    Cout("No");
  return 0;
}

Measured memory_bytes: 3660
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a,flag=0;
    cin >> a;
    for(int i=1;i<=9;i++){
        for(int j=1;j<=9;j++){
            if(i*j==a){
                flag=1;
                break;
            }
        }
    }
    if(flag==1)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
}

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

int main()
{
	int n, S[10000], q, T[500], i, j, count=0;

	scanf("%d", &n);
	for (i = 0; i < n; i++) scanf("%d", &S[i]);

	scanf("%d", &q);
	for (i = 0; i < q; i++) scanf("%d", &T[i]);

	for (i = 0; i < q; i++) {
		for (j = 0; j < n; j++) {
			if (T[i] == S[j]) {
				count++;
				//cout << S[j] << " " << T[i];
				j = n;
			}
		}
	}
	cout << count << endl;
}


Measured memory_bytes: 3228
n = int(input())
t,a = map(int, input().split())
h = list(map(int, input().split()))
best = float("inf")
ind = 0
for i in range(n):
    temp = abs(a-(t- h[i]*0.006))
    if temp < best:
        ind = i
        best = temp
print(ind+1)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};

signed main () {
    int n,m;scanf("%d %d",&n,&m);
    while(n!=0 && m!=0){
        vector<int> cb(m);
        REP(i,m){
            int tmp;scanf("%d",&tmp);
            cb[i]=tmp;
        }
        vector<int> list(n);
        REP(i,n){
            int tmp;scanf("%d",&tmp);
            list[i] = tmp;
        }
        vector<vector<ll>> dp(n+1,vector<ll>(256,INF));
        dp[0][128]=0;
        REP(i,n){
            REP(j,256){
                if(dp[i][j]==INF)continue;
                REP(l,m){
                    int y = j+cb[l];
                    if(y<0)y = 0;
                    if(y>255)y = 255;
                    int sum = (list[i]-y)*(list[i]-y);
                    dp[i+1][y]=min(dp[i+1][y], dp[i][j] + sum );
                }
            }
        }
        cout << *min_element(dp[n].begin(),dp[n].end()) << endl;
        scanf("%d %d",&n,&m);
    }

}


Measured memory_bytes: 43956
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL) ; cout.tie(NULL);
#define INF 0x3f3f3f3f3f

int main() {

    fastio;

    ll h,w;
    vector<vector<char>> grid(1005 , vector<char>(1005));
    vector<vector<ll>> dp(1005 , vector<ll>(1005));

    cin >> h >> w;
    ll h1 = h,w1 = w;
    for(ll i = 0; i < h; i++){
        for(ll j = 0; j < w; j++){
            cin >> grid[i][j];
            if(grid[i][j] == '#') dp[i][j] = 0;
            else dp[i][j] = INF;
        }
    }

    //OPTIMAL SUBPROBLEM :

    //dp[i][j] = number of ways one can reach the grid[i][j]

    // BASE CASE :

    for(ll i = 0; i < w; i++) {
        if(dp[0][i] == 0){
            w1 = i;
            break;
        }
        else dp[0][i] = 1;
    }
    for(ll i = w1; i < w; i++) dp[0][i] = 0;

    for(ll i = 0; i < h; i++) {
        if (dp[i][0] == 0) {
            h1 = i;
            break;
        } else dp[i][0] = 1;
    }
    for(ll i = h1; i < h; i++) dp[i][0] = 0;

    // RECURSIVE RELATION :

    for(ll i = 1; i < h; i++){
        for(ll j = 1; j < w; j++){
            if(dp[i][j]  != 0 ) dp[i][j] = (dp[i-1][j] + dp[i][j-1])%(1000000007);
        }
    }

    //OPTIMAL SOLUTION :

    cout << dp[h-1][w-1];
    return 0;
}

Measured memory_bytes: 9216
/////////////////////////////////////////////////
//                                             //
//                 _ooOoo_                     //
//                o8888888o                    //
//                88" . "88                    //
//                (| -_- |)                    //
//             ____/`---'\\____                //
//           .'  \|     |//  `.                //
//           /  \|||  :  |||// \               //
//          /  _||||| -:- |||||- \             //
//          |   | \\  -  /// |   |             //
//          | \_|  ''\---/''  |  |             //
//          \  .-\__  `-`  ___/-. /            //
//         ___`. .'  /--.--\  `. . __          //
//      ."" '<  `.___\_<|>_/___.'  >'"".       //
//     | | :  `- \`.;`\ _ /`;.`/ - ` : | |     //
//     \  \ `-.   \_ __\ /__ _/   .-` /  /     //
//=====`-.____`-.___\_____/___.-`____.-'=======//
//^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^//
//.............................................//
/////////////////////////////////////////////////

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll modn=998244353;
ll sum[1001000];
int arr[1001000];
int main(){
    int n;
    cin>>n;
    ll ans = 1;
    sum[0]=1;
    for(int i=0;i<n;i++)scanf("%d",&arr[i]);
    sort(arr+1,arr+n);
    for(int i=0;i<n;i++){
        if(i==0){
            if(arr[i]!=0)ans=0;
            continue;
        }
        if(arr[i]==0){
            ans=0;
            break;
        }
        ans*=sum[arr[i]-1];
        ans%=modn;
        sum[arr[i]]++;
    }
    cout<<ans<<endl;
    return 0;
}



Measured memory_bytes: 4736
#include<bits/stdc++.h>
using namespace std;
#define int long long
//BEGIN CUT HERE
struct RUP{
  int n;
  vector<int> dat,laz;
  const int def=INT_MAX;
  RUP(){}
  RUP(int n_){init(n_);}
  void init(int n_){
    n=1;
    while(n<n_) n*=2;
    dat.clear();
    dat.resize(2*n-1,def);
    laz.clear();
    laz.resize(2*n-1,-1);
  }
  inline void eval(int len,int k){
    if(laz[k]<0) return;
    if(k*2+1<n*2-1){
      laz[k*2+1]=laz[k];
      laz[k*2+2]=laz[k];
    }
    dat[k]=laz[k];
    laz[k]=-1;
  }
  int update(int a,int b,int x,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return dat[k];
    if(a<=l&&r<=b) return laz[k]=x;
    eval(r-l,k);
    dat[k]=min(update(a,b,x,k*2+1,l,(l+r)/2),
           update(a,b,x,k*2+2,(l+r)/2,r));
    return dat[k];
  }
  int query(int a,int b,int k,int l,int r){
    eval(r-l,k);
    if(r<=a||b<=l) return def;
    if(a<=l&&r<=b) return dat[k];
    int vl=query(a,b,k*2+1,l,(l+r)/2);
    int vr=query(a,b,k*2+2,(l+r)/2,r);
    return min(vl,vr);
  }
  void update(int a,int b,int x){
    update(a,b,x,0,0,n);
  }
  int query(int a,int b){
    return query(a,b,0,0,n);
  }
};
//END CUT HERE
signed main(){
  int N, Q;
  cin >> N >> Q;

  vector<int> S(N), T(N), X(N);
  using P = pair<int, int>;
  using P3 = pair<int, P>;
  vector<P> xst(N);
  map<int, int> zip;
  vector<int> D(Q);  
  {
    map<int, int> tmp;
    tmp[0] = 1;
    for ( int i = 0; i < N; i++ ) {
      cin >> S[i] >> T[i] >> X[i];
      // tmp[S[i]] = tmp[T[i]] = 1;
      if ( S[i]-X[i] > 0 ) tmp[S[i]-X[i]] = 1;
      if ( T[i]-X[i] > 0 ) tmp[T[i]-X[i]] = 1;    
      xst[i].first = X[i];
      xst[i].second = i;    
    }
    
    sort(xst.begin(), xst.end(), greater<P>());  
        
    for ( int i = 0; i < Q; i++ ) {
      cin >> D[i];
      tmp[D[i]] = 1;    
    }
    tmp[INT_MAX] = 1;  
        
    int cnt = 0;
    for ( auto i : tmp ) {
      zip[i.first] = cnt++;    
    }
  }

  RUP dat(zip.size());  
  for ( int i = 0; i < N; i++ ) {
    int j = xst[i].second;    
    int s = S[j], t = T[j], x = X[j];    
    s = max(0LL, s-x);
    t = max(0LL, t-x);
    if ( s == t ) continue;
    dat.update(zip[s], zip[t], x);    
  }
  
  for ( int i = 0; i < Q; i++ ) {
    int res = dat.query(zip[D[i]], zip[D[i]]+1);    
    if ( res == INT_MAX ) cout << -1 << endl;
    else cout << res << endl;
  }  
}


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

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

    vector<string> data(N);

    for(int i = 0; i < N; i++){
            cin >> data.at(i);
    }

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

    for(int i = 0; i < N; i++){
        cout << data.at(i);
    }

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
using namespace std;
typedef long long LL;
const LL mod=1e9+7;
int main() {
	LL n,m,c,ans;
	cin>>n>>m;
	c=max(m,n)-min(m,n);
	if(c>1) {
		printf("0\n");
		return 0;
	}
	if(c==0) ans=2ll;
	else ans=1ll;
	for(LL i=2;i<=n;i++) ans=(ans*i)%mod;
	for(LL i=2;i<=m;i++) ans=(ans*i)%mod;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using System;
//using System.Collections.Generic;
using System.IO;
using System.Linq;
//using System.Text;
using static System.Console;
using static LibraryForAtCoder.Lib;

namespace LibraryForAtCoder
{
  static class Lib
  {
    static char[] cs = new[] { ' ' };
    public static int Sum(this int[] vector)
    {
      int sum = 0;
      foreach (var fraction in vector) sum += fraction;
      return sum;
    }

    public static int ReadI => int.Parse(ReadS);
    public static long ReadL => long.Parse(ReadS);
    public static double ReadD => double.Parse(ReadS);
    public static string ReadS => ReadLine().Trim();

    public static int[] ReadIs => ReadSs.Select(int.Parse).ToArray();
    public static long[] ReadLs => ReadSs.Select(long.Parse).ToArray();
    public static double[] ReadDs => ReadSs.Select(double.Parse).ToArray();
    public static string[] ReadSs => ReadS.Split(cs, StringSplitOptions.RemoveEmptyEntries);
  }

  class Program
  {
    static StreamWriter sw = new StreamWriter(OpenStandardOutput()) { AutoFlush = false };
    static void Print(string a) => sw.WriteLine(a);
    //static void Print<T>(IEnumerable<T> a) => Print(string.Join(" ", a));
    //static void Print<T>(params T[] a) => Print(string.Join(" ", a));
    //static void Print(params object[] a) => Print(string.Join(" ", a));

    static void Main()
    {
      Body();
      sw.Flush();
    }

    static void Body()
    {
      var a = ReadIs;
      var n = a.Sum();
      if (22 <= n) Print("bust");
      else Print("win");
    }
  }
}


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

int main() {
    int64_t N; cin >> N;
    vector<int64_t> A(N);
    int64_t MOD = 1e9 + 7;
    for (int i = 0; i < N; i++) cin >> A.at(i);

    int64_t sum = 0;
    /* O(N^2)
    for (int i = 0; i < N - 1; i++) {
        for (int j = i + 1; j < N; j++) {
            if (i < j && j <= N) sum += (A.at(i) * A.at(j)) % MOD;
        }
    }
    */
  
    vector<int64_t> B(N + 1);
    for (int i = 0; i < N; i++) B.at(i + 1) = (B.at(i) + A.at(i)) % MOD;

    int64_t ans = 0;
    for (int i = 0; i < N - 1; i++) {
        ans += A.at(i) * (B.at(N) - B.at(i + 1) + MOD);
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6352
module a
  integer(8), allocatable :: anr(:), ang(:), anb(:)
end module a

program main
  use a
  
  implicit none
  integer :: n, i, j
  integer(8) :: ans ,nr, ng, nb
  character(4000) :: s
  
  read(*,*) n
  allocate( anr(n) )
  allocate( ang(n) )
  allocate( anb(n) )
  read(*,*) s
  
  nr = 0
  ng = 0
  nb = 0
  do i = 1, n
    if( s(i:i) == "R" ) then
      nr = nr + 1
    else if( s(i:i) == "G" ) then
      ng = ng + 1
    else
      nb = nb + 1
    end if
  end do
  do i = 1, n
    if( s(i:i) == "R" ) then
      nr = nr - 1
    else if( s(i:i) == "G" ) then
      ng = ng - 1
    else
      nb = nb - 1
    end if
    anr(i) = nr
    ang(i) = ng
    anb(i) = nb
  end do
  ans = 0
  do i = 1, n-2
    do j = i+1, n-1
    if( s(i:i) == "R" ) then
      if( s(j:j) == "G" ) then
        ans = ans + anb(j) 
        if( 2*j-i > n ) cycle
        if( s(2*j-i:2*j-i) == "B") ans = ans - 1
      end if
    end if
    if( s(i:i) == "R" ) then
      if( s(j:j) == "B" ) then
        ans = ans + ang(j) 
        if( 2*j-i > n ) cycle
        if( s(2*j-i:2*j-i) == "G") ans = ans - 1
      end if
    end if
    if( s(i:i) == "G" ) then
      if( s(j:j) == "R" ) then
        ans = ans + anb(j) 
        if( 2*j-i > n ) cycle
        if( s(2*j-i:2*j-i) == "B") ans = ans - 1
      end if
    end if
    if( s(i:i) == "G" ) then
      if( s(j:j) == "B" ) then
        ans = ans + anr(j) 
        if( 2*j-i > n ) cycle
        if( s(2*j-i:2*j-i) == "R") ans = ans - 1
      end if
    end if
    if( s(i:i) == "B" ) then
      if( s(j:j) == "R" ) then
        ans = ans + ang(j) 
        if( 2*j-i > n ) cycle
        if( s(2*j-i:2*j-i) == "G") ans = ans - 1
      end if
    end if
    if( s(i:i) == "B" ) then
      if( s(j:j) == "G" ) then
        ans = ans + anr(j) 
        if( 2*j-i > n ) cycle
        if( s(2*j-i:2*j-i) == "R") ans = ans - 1
      end if
    end if
    end do
  end do

  print*, ans 

end program main



Measured memory_bytes: 2836
N,M = map(int,input().split())
X = list(sorted(map(int,input().split())))
if N >= M:
    print(0)
    exit()
L = [X[i+1] - X[i] for i in range(M-1)]
if N == 1:
    print(sum(L))
    exit()
L = list(sorted(L))


print(sum(L[:1-N]))

Measured memory_bytes: 13968