akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;
int main() {
	int n;
	cin >> n;

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

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

	int alice = 0;
	int bob = 0;

	for (int i = 0; i < n;i++) {
		if (i % 2 == 0) {
			alice += a[i];
		}
		else bob += a[i];
	}

	cout << abs(alice - bob )<< endl;


	return 0;
}

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

int main()
{
	int n;
	cin >> n;
	if (n % 10 == 9||(n-(n%10))/10==9) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
n, m, X, Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
if X+1 <= Y:
    for Z in range(X+1, Y+1):
        if max(x) < Z and Z <= min(y):
            print('No War')
            exit()
print('War')

Measured memory_bytes: 3060
#include<iostream>
#include<cmath>
using namespace std;
long long N,T,A,ans,a_ans=1,b_ans=1,ratio;
int main(){
	cin>>N;
	for(int i=1;i<=N;++i){
		cin>>T>>A;
		ratio=max(a_ans/T,b_ans/A);
		while(ratio*T<a_ans || ratio*A<b_ans)
			ratio++;
		a_ans=ratio*T;
		b_ans=ratio*A;
		/*
		if(ratio<T*1.0/A){
			while(ratio!=T*1.0/A) {
				++T;
				ans=
			}
		}
		else if(ratio>T*1.0/A){
			while(ratio!=T*1.0/A) {
				++T;
				ans=T+A;
			}
		}
		ratio=T*1.0/A;
		*/
	}
	cout<<a_ans+b_ans<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector< vector<int> > VVI;
typedef pair<int,int> P;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()

int main() {
  ll A,B;
  cin>>A>>B;
  while(B){
    A%=B;
    swap(A,B);
  }
  set<ll> X;
  X.insert(1);
  rep(i,100){
    rep(i,sqrt(A)+10){
      if(i>=2&&A%i==0){
        A/=i;
        X.insert(i);
        break;
      }
    }
  }
  X.insert(A);
  cout<<X.size()<<endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <unordered_set>
#include <vector>
#include <utility>
#include <algorithm>
#include <queue>
#include <cstdint>
#include <cstdlib>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

constexpr ll inf = INT64_MAX / 4;
constexpr double pi = asin(1) * 2;
constexpr ll mod = 1000000007;

template<class T>
class set2 : public set<T> {
private:
    typename set<T>::iterator back_itr() {
        auto e = this->end();
        e--;
        return e;
    }

public:
    T front() {
        if (this->empty()) throw;
        return *this->begin();
    }

    T back() {
        if (this->empty()) throw;
        return *this->back_itr();
    }

    void erase_front() {
        if (!this->empty()) this->erase(this->begin());
    }

    void erase_back() {
        if (!this->empty()) this->erase(this->back_itr());
    }
};

int h, w, a[80][80], b[80][80];
char d[80][80][80 * 160 * 2];

int main() {
    cin >> h >> w;
    for (int y = 0; y < h; y++)for (int x = 0; x < w; x++)cin >> a[x][y];
    for (int y = 0; y < h; y++)for (int x = 0; x < w; x++)cin >> b[x][y];
    for (int y = 0; y < h; y++)for (int x = 0; x < w; x++)a[x][y] -= b[x][y];
    d[0][0][80 * 160 + a[0][0]]++;
    d[0][0][80 * 160 - a[0][0]]++;
    for (int i = 0; i < h + w; i++) {
        for (int j = 0; j <= i; j++) {
            if (j < w && i - j < h) {
                if (i - j + 1 < h) {
                    for (int k = 0; k < 80 * 160 * 2; k++) {
                        if (d[j][i - j][k]) {
                            d[j][i - j + 1][k + a[j][i - j + 1]]++;
                            d[j][i - j + 1][k - a[j][i - j + 1]]++;
                        }
                    }
                }
                if (j + 1 < w) {
                    for (int k = 0; k < 80 * 160 * 2; k++) {
                        if (d[j][i - j][k]) {
                            d[j + 1][i - j][k + a[j + 1][i - j]]++;
                            d[j + 1][i - j][k - a[j + 1][i - j]]++;
                        }
                    }
                }
            }
        }
    }
    int r = 400000;
    for (int i = 0; i < 80 * 160 * 2; i++) {
        if (d[w - 1][h - 1][i]) r = min(r, abs(i - 80 * 160));
    }
    cout << r << endl;
}


Measured memory_bytes: 159104
#include<bits/stdc++.h>
#define LL long long
#define P 1000000007
#define M 100005
using namespace std;
int rx[]={1,-1,0,0};
int ry[]={0,0,1,-1};
//RLUD
struct node{
	int x,y,d;
}s[M];
int n;
double calc(double t){
	double x1=1e18,x2=-1e18;
	double y1=x1,y2=x2;
	for(int i=1;i<=n;i++){
		double x=s[i].x+t*rx[s[i].d];
		double y=s[i].y+t*ry[s[i].d];
		x1=min(x1,x);x2=max(x2,x);
		y1=min(y1,y);y2=max(y2,y);
	}
	return (x2-x1)*(y2-y1);
}
int main() { 
	char str[10];
	cin>>n;
	for(int i=1;i<=n;i++){
		scanf("%d %d %s",&s[i].x,&s[i].y,str);
		if(str[0]=='R')s[i].d=0;
		if(str[0]=='L')s[i].d=1;
		if(str[0]=='U')s[i].d=2;
		if(str[0]=='D')s[i].d=3;
	}
	double l=0,r=1e8,res;
	for(int i=0;i<100;i++){
		double l1=l+(r-l)/3;
		double r1=l+(r-l)*2/3;
		double c1=calc(l1);
		double c2=calc(r1);
		if(c1<=c2){
			res=c1;r=r1;
		}else{
			res=c2;l=l1;
		}
	}
	printf("%.15f\n",res);
	return 0;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, m;
  cin >> n >> m;
  vector<ll> a(m);
  ll sum = 0;
  REP(i, m) cin >> a[i], sum += a[i];
  if(sum > n) cout << -1 << endl;
  else cout << n-sum << endl;
  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
typedef vector<int> VI;
const ll MOD = 1000000007;
#define REP(i, n) for(int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()

ll tas(ll x, ll y) { return (x + y) % MOD; }
ll hik(ll x, ll y) { return (x + MOD - (y % MOD)) % MOD; }
ll kak(ll x, ll y) { return ((x % MOD) * (y % MOD)) % MOD; }
ll power(ll x, ll y) {
	if (y == 0) {
		return 1;
	}
	else if (y == 1) {
		return x % MOD;
	}
	else if (y % 2 == 0) {
		ll pow = power(x, y / 2);
		return (pow * pow) % MOD;
	}
	else {
		ll pow = power(x, y / 2);
		return (((pow * pow) % MOD) * x) % MOD;
	}
}
ll war(ll x, ll y) { return kak(x, power(y, MOD - 2)); }

int main() {
	ll n, k;
	cin >> n >> k;
	VI a(n);
	REP(i, n)
		cin >> a[i];
	ll c = 0;
	REP(i, n) {
		for(int j = n - 1;j > i;j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				c++;
			}
		}
	}
	ll nn = 0, m = 0;
	REP(i, n - 1) {
		if (a[i] != a[i + 1])
			m = i + 1;
		nn = tas(m, nn);
	}
	cout << tas(kak(c, k), kak(war(kak(k - 1, k), 2), nn));
}

Measured memory_bytes: 256
N,X,M = list(map(int,input().split()))

D = [X]

E = set([X])

F = [0,X]

for i in range(M+1):
    X = X**2
    X%=M
    if X in E:
        break
    D.append(X)
    E.add(X)
    F.append(F[-1]+X)
if N<=len(D):
    print(F[N])
else:
    for i in range(len(D)):
        if D[i]==X:
            break
    #print(D)
    num = (N-i-1)//(len(D)-i)
    res = (N-i-1)%(len(D)-i)
    print(F[res+i+1] + num*(F[-1]-F[i]))

Measured memory_bytes: 80100
#include <bits/stdc++.h>
#define FOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i++)
#define RFOR(i, a, b) for(int i=(int)(a); i!=(int)(b); i--)
#define REP(i, n) FOR(i, 0, n)
using namespace std;
using ll = long long;

bool check(string s, string t){
vector<bool> ch(s.size(), false);

  vector<vector<int>> cnt(26);
  REP(i, s.size()){
    cnt[s[i]-'a'].push_back(i);
  }

  REP(i, s.size()){
    if(!ch[i]){
      ch[i] = true;
      char c = t[i];
      REP(j, cnt[s[i]-'a'].size()){
        int nt = cnt[s[i]-'a'][j];
        ch[nt] = true;
        if(c != t[nt]){
          return false;
        }
      }
    }
  }

  return true;
}

int main(){
  string s, t; cin >> s >> t;

  if(!check(s, t)){
    cout << "No" << endl;
    return 0;
  }

  swap(s, t);

  if(!check(s, t)){
    cout << "No" << endl;
    return 0;
  }

  cout << "Yes" << endl;

  return 0;
}


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

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

  if ((N - N % 10) / 10 % 111 == 0) {
    cout << "Yes" << endl;
  }
  else if (N % 1000 % 111 == 0) 
    cout << "Yes" <<endl;
  else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3628
# AGC031A - Colorful Subsequence
from functools import reduce


def main():
    _ = int(input())
    S = input().rstrip()
    MOD = 10 ** 9 + 7
    C = [S.count(i) + 1 for i in set(S)]
    ans = reduce(lambda x, y: (x * y) % MOD, C)
    print(ans - 1)


if __name__ == "__main__":
    main()

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

using namespace std;

long long d[87] = { 0 };

long long f(int n) {
    d[0] = 2;
    d[1] = 1;
    if (n == 0) return 2;
    if (n == 1) return 1;
    if (d[n - 1] != 0) {
        if (d[n - 2] != 0) {
            return d[n - 1] + d[n - 2];
        } else {
            d[n] = d[n - 1] + f(n - 2);
            return d[n - 1] + f(n - 2);
        }
    } else {
        if (d[n - 2] != 0) {
            return f(n - 1) + d[n - 2];
        } else {
            d[n] = f(n - 1) + f(n - 2);
            return d[n];
        }
    }
}

int main() {
    int n;
    cin >> n;
    cout << f(n);
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FSP(x) fixed << setprecision(x)
using namespace std;
using ll = long long;
constexpr ll INF = LLONG_MAX;
constexpr ll P = 1e9 + 7;
//constexpr ll P = 998244353;
constexpr long double PI = acosl(-1);
void Yes() {cout << "Yes\n";}
void No() {cout << "No\n";}
void YES() {cout << "YES\n";}
void NO() {cout << "NO\n";}

#include <vector>

/*	verified : 2020/07/18
		AOJ, Disjoint Set: Union Find Tree
		http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_A
*/

struct union_find {
	long long N;					// the number of nodes
	long long M;					// the number of trees
	std::vector<long long> parent;	// parent[i] := the direct parent of i
	std::vector<long long> size;	// size[i] := the number of nodes in the tree containing i

	union_find(long long n) : N(n), M(n) {
		parent.resize(n, -1);
		size.resize(n, 1);
	}

	long long root(long long i) {
		if (parent[i] == -1) return i;
		else return parent[i] = root(parent[i]);
	}

	bool is_united(long long i, long long j) {
		return (root(i) == root(j));
	}

	// true : unite succeeded
	bool unite(long long i, long long j) {
		i = root(i); j = root(j);
		if (i == j) return false;
		if (size[i] < size[j]) std::swap(i, j);
		parent[j] = i;
		size[i] += size[j];
		M--;
		return true;
	}
};

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

	ll n, q;
	cin >> n >> q;
	union_find uf(n);
	while (q--) {
		ll t, u, v;
		cin >> t >> u >> v;
		if (t == 0) uf.unite(u, v);
		else cout << uf.is_united(u, v) << '\n';
	}
}

Measured memory_bytes: 6216
#include <iostream>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <iomanip> // cout<<setprecision(n)
#include <functional> // std::function<void(ll)>
using namespace std;
#define All(v) (v).begin(),(v).end()
typedef long long ll;
const ll mod = 1000000007;
const ll inf = mod*mod;
const ll d5 = 114514;
const double EPS = 1e-10;
const double INF = 1e+10;
const double PI = acos(-1.0);
int main(){
    int n;
    string s;
    cin>>n>>s;
    if(n>=3200)cout<<s<<endl;
    else cout<<"red"<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<list>
using namespace std;
int main(){
	int n,i;
	cin>>n;
	string coms;
	list<int> nums;
	int key;
	for(i=0; i<n; i++){
		cin>>coms;
		if(coms=="insert"){
			cin>>key;
			nums.push_front(key);
		}else if(coms=="delete"){
			cin>>key;
			for(auto itr=nums.begin(); itr!=nums.end();){
				if(*itr==key){
					itr=nums.erase(itr);
					break;
				}else{
					itr++;
				}
			}
		}else if(coms=="deleteFirst"){
			nums.pop_front();
		}else if(coms=="deleteLast"){
			nums.pop_back();
		}
	}
	
	
	for(auto itr=nums.begin(); itr!=nums.end(); itr++){
		if(itr!=nums.begin()) cout<<" ";
		cout<<*itr;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 34352
from math import gcd
K = int(input())
tot_sum = 0

for i in range(1, K + 1):
    for j in range(1, K + 1):
        temp = gcd(i, j)
        for k in range(1, K + 1):
            tot_sum += gcd(temp, k)

print(tot_sum)

Measured memory_bytes: 9072
#include <bits/stdc++.h>
#define MOD 1000000007
#define INF 1001001001
#define LINF 1001001001001001001
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define bit(n) (1LL<<(n))
using namespace std;

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

// ll dp[3000][3000][4];
// ll V[3000][3000];

int main() {
  
  int R, C, K;
  cin >> R >> C >> K;
  vector dp(R, vector(C, vector<ll>(4, 0)));
  vector V(R, vector(C, 0));
  rep(i,K) {
    ll r, c, v;
    cin >> r >> c >> v;
    V[r - 1][c - 1] = v;
  }
  rep(i,R) {
    if (i > 0) {
      rep(j,C) rep(k,4) dp[i][j][0] = max(dp[i][j][0], dp[i - 1][j][k]);
    }
    if (V[i][0] > 0) dp[i][0][1] = dp[i][0][0] + V[i][0];
    for (int j = 1; j < C; j++) {
      for (int k = 1; k <= 3; k++) {
        if (V[i][j] == 0) {
          dp[i][j][k] = dp[i][j - 1][k];
          continue;
        }
        dp[i][j][k] = max(dp[i][j - 1][k], dp[i][j - 1][k - 1] + V[i][j]);
        if (k == 1) {
          dp[i][j][k] = max(dp[i][j][k], dp[i][j][0] + V[i][j]);
        }
      }
    }
  }

  ll ans = 0;
  rep(i,4) ans = max(ans, dp[R - 1][C - 1][i]);
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 671244
def prepare(n, MOD):
    # n! の計算
    f = 1
    for m in range(1, n + 1):
        f *= m
        f %= MOD
    fn = f

    # n!^-1 の計算
    inv = pow(f, MOD - 2, MOD)
    # n!^-1 - 1!^-1 の計算
    invs = [1] * (n + 1)
    invs[n] = inv
    for m in range(n, 1, -1):
        inv *= m
        inv %= MOD
        invs[m - 1] = inv

    return fn, invs


def ncr(n, r, invs, MOD):
    ret = invs[r]
    for i in range(n, n - r, -1):
        ret = ret * i % MOD
    return ret


n, a, b = list(map(int, input().split()))
MOD = 10 ** 9 + 7
fn, invs = prepare(max(a, b), MOD)
ans = pow(2, n, MOD)
ans = (ans - ncr(n, a, invs, MOD) - ncr(n, b, invs, MOD) - 1) % MOD
print(ans)


Measured memory_bytes: 10868
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
int main() {
  ll a;
  cin>>a;
  vector<ll>vec(a);
  vector<ll>sum(a);
  ll b=0;
  for(ll i=0;i<a;i++){
    cin>>vec.at(i);
    b+=vec.at(i);
  }
  sum.at(0)=b-vec.at(0);
  for(ll i=1;i<a;i++){
    sum.at(i)=sum.at(i-1)-vec.at(i);
  }
  ll c=0;
  for(ll i=0;i<a;i++){
    c+=sum.at(i)*vec.at(i);
  }
  cout<<c<<endl;
  return 0;
  
      
                        
                        
}


Measured memory_bytes: 3536
import qualified Data.Vector.Unboxed as U
import qualified Data.Vector as V
import qualified Data.ByteString.Char8 as C
import Debug.Trace
import Data.List
import Control.Monad
import Data.Ord


r :: Int -> IO (U.Vector Int)
r n = U.unfoldrN n (C.readInt . C.dropWhile (==' ')) <$> C.getLine

r' :: IO [Int]
r'  =   unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

rp :: IO (Int,Int)
rp  = toTup . unfoldr    (C.readInt . C.dropWhile (==' ')) <$> C.getLine

toTup [a,b] = (a,b)



main :: IO ()
main = do
    n <- readLn
    ds <- r n
    print $ solve ds

solve :: U.Vector Int -> Int
solve xs
    | U.null xs = 0
    | otherwise = U.sum ( U.map (U.head xs *) (U.tail xs) )
                    + (solve (U.tail xs))

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

int main() {
  int n,k;
  cin >> n >> k;
  vector<int> p(n);
  rep(i,n) cin >> p[i];
  sort(p.begin(), p.end());
  ll ans=0;
  rep(i,k){
    ans += p[i];
  }
  cout << ans << endl;

}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
#define lli long long int
using namespace std;


int main()
{
	lli n, m, val, b, c;
	
	cin >> n >> m;
	
	map<lli, lli> mp;
	
	for(int i = 0; i < n; i++){
		cin >> val;
		mp[val]++;
	}
	
	while(m--){
		cin >> b >> c;
		mp[c] += b;
	}
	
	lli sum = 0, sz;
	
	for(auto it = mp.rbegin(); it != mp.rend(); it++){
		if(n == 0) break;
		
		val = it->first; sz = it->second;
		
		if(n >= sz){
			n -= sz;
			sum += (val * sz);
		}
		else{
			sum += (val * n);
			n = 0;
		}
	}
	
	
	cout << sum << "\n";
	
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
#define int long long
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int N;
    cin>>N;
    int a[N-1],b[N-1],c[N-1];
    vector<vector<pair<int,int>>> G(N);
    rep(i,N-1) {
        cin>>a[i]>>b[i]>>c[i];
        a[i]--;
        b[i]--;

        G[a[i]].push_back(make_pair(b[i],c[i]));
        G[b[i]].push_back(make_pair(a[i],c[i]));
    }

    int Q,K;
    cin>>Q>>K;
    K--;
    int x[Q],y[Q];
    rep(i,Q) {
        cin>>x[i]>>y[i];
        x[i]--;
        y[i]--;
    }

    vector<int> dist(N,INF);
    queue<int> q;
    dist[K]=0;
    q.push(K);
    while(!q.empty()){
        int v=q.front();
        q.pop();
        for(auto nv:G[v]){
            int na=nv.first;
            int nx=nv.second;
            if(dist[na]<dist[v]+nx) continue;
            dist[na]=dist[v]+nx;
            q.push(na);
        }
    }
    rep(i,Q){
        cout << dist[x[i]]+dist[y[i]] << endl;
    }





}


Measured memory_bytes: 13952
from itertools import groupby, accumulate

N, K = map(int, input().split())
S = input()

l = [len(list(g)) for k, g in groupby(S)]
# print(l)
m = min(len(l)//2, K)
# print(m)
a = [0]*(N+1)
x = 0
for l_i in l[:m]:
    x += l_i
    a[x] += 1
x = N
for l_i in l[-m:][::-1]:
    x -= l_i
    if a[x] == 0:
        a[x] -= 1

# print(list(accumulate(a))[:-1])

s_list = list(S)
for i, b in enumerate(list(accumulate(a))[:-1]):
    if b%2:
        s_list[i] = "R" if S[i] == "L" else "L"

# print(s_list)

count = 0
for i, s_i in enumerate(s_list):
    if s_i == "L":
        if i == 0:
            continue
        count += s_list[i-1] == "L"
    else:
        if i == N-1:
            continue
        count += s_list[i+1] == "R"

print(count)


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

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


Measured memory_bytes: 256
use strict;
use warnings;

sub main {
    my ($N,$M) = split(/ /,<STDIN>);
    chomp($M);
    my @xyz;
    for (1..$N) {
        chomp(my $l=<STDIN>);
        push(@xyz, [split(/ /, $l)]);
    }
    print solve($N,$M,\@xyz);
}

main() unless caller;

sub solve {
    my ($N,$M,$xyz) = @_;
    my $max = 0;

    $max = _cal( 1,  1,  1, $xyz, $max, $M);
    $max = _cal(-1,  1,  1, $xyz, $max, $M);
    $max = _cal( 1, -1,  1, $xyz, $max, $M);
    $max = _cal( 1,  1, -1, $xyz, $max, $M);
    $max = _cal(-1, -1,  1, $xyz, $max, $M);
    $max = _cal(-1,  1, -1, $xyz, $max, $M);
    $max = _cal( 1, -1, -1, $xyz, $max, $M);
    $max = _cal(-1, -1, -1, $xyz, $max, $M);

    return $max;
}

sub _max {
    my ($arr, $M, $max) = @_;
    my $x = 0;
    my $y = 0;
    my $z = 0;
    for my $i(0..$M-1){
         $x += $arr->[$i]->[1]->[0];
         $y += $arr->[$i]->[1]->[1];
         $z += $arr->[$i]->[1]->[2];
    }
    my $tmp = abs($x) + abs($y) + abs($z);
    $max = $max > $tmp ? $max : $tmp;
    return $max;
}

sub _cal {
    my($malX,$malY,$malZ,$xyz,$max,$M)=@_;

    my @arr = ();
    for my $l(@$xyz){
        my $tmp = 0;
        $tmp += $malX * $l->[0];
        $tmp += $malY * $l->[1];
        $tmp += $malZ * $l->[2];
        push(@arr, [$tmp,[@$l]]);
    }
    @arr = sort {$b->[0] <=> $a->[0]} @arr;
    $max = _max(\@arr, $M, $max);
    return $max;
}

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

long n;
int main() {
  cin >> n;
  int sum = 0;
  for (long i = 2; i * i <= n; ++i) {
    int cnt = 0;
    while (n % i == 0) {
      n /= i;
      ++cnt;
    }
    int p = 1;
    while (p <= cnt) {
      ++sum;
      cnt -= p;
      ++p;
    }
  }
  if (n > 1) ++sum;
  cout << sum << endl;
}

Measured memory_bytes: 3592
A1 = list(map(int,input().split()))
A2 = list(map(int,input().split()))
A3 = list(map(int,input().split()))

N = int(input())
A10,A11,A12,A20,A21,A22,A30,A31,A32 = 0,0,0,0,0,0,0,0,0
for n in range(N):
  b = int(input())
  
  if A1[0] == b:
    A10 += 1
  elif A1[1] == b:
    A11 += 1
  elif A1[2] == b:
    A12 += 1
  elif A2[0] == b:
    A20 += 1
  elif A2[1] == b:
    A21 += 1
  elif A2[2] == b:
    A22 += 1
  elif A3[0] == b:
    A30 += 1
  elif A3[1] == b:
    A31 += 1
  elif A3[2] == b:
    A32 += 1

if A10+A11+A12 == 3:
  print("Yes")
elif A20+A21+A22 == 3:
  print("Yes")
elif A30+A31+A32 == 3:
  print("Yes")
elif A10+A20+A30 == 3:
  print("Yes")
elif A11+A21+A31 == 3:
  print("Yes")
elif A12+A22+A32 == 3:
  print("Yes")
elif A10+A21+A32 == 3:
  print("Yes")
elif A12+A21+A30 == 3:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 9296
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cstdio>
#include <cstring>

using namespace std;

int main(int argc, char* argv[])
{
    int a, b, d, r;
    double f;

    cin >> a >> b;

    d = a / b;
    r = a % b;
    f = (double)a / (double)b;

    //cout << d << " " << r << " " << f << endl;
    printf("%d %d %f\n", d, r, f);
}


Measured memory_bytes: 3216
# -*- coding: utf-8 -*-

#############
# Libraries #
#############

import sys
input = sys.stdin.readline

import math
from collections import deque
from fractions import gcd
from functools import lru_cache


#############
# Constants #
#############

MOD = 10**9+7
INF = float('inf')

#############
# Functions #
#############

######INPUT######
def inputI(): return int(input().strip())
def inputS(): return input().strip()
def inputIL(): return list(map(int,input().split()))
def inputSL(): return list(map(str,input().split()))
def inputILs(n): return list(int(input()) for _ in range(n))
def inputSLs(n): return list(input().strip() for _ in range(n))
def inputILL(n): return [list(map(int, input().split())) for _ in range(n)]
def inputSLL(n): return [list(map(str, input().split())) for _ in range(n)]

#####Inverse#####
def inv(n): return pow(n, MOD-2, MOD)

######Combination######
kaijo_memo = []
def kaijo(n):
  if(len(kaijo_memo) > n):
    return kaijo_memo[n]
  if(len(kaijo_memo) == 0):
    kaijo_memo.append(1)
  while(len(kaijo_memo) <= n):
    kaijo_memo.append(kaijo_memo[-1] * len(kaijo_memo) % MOD)
  return kaijo_memo[n]

gyaku_kaijo_memo = []
def gyaku_kaijo(n):
  if(len(gyaku_kaijo_memo) > n):
    return gyaku_kaijo_memo[n]
  if(len(gyaku_kaijo_memo) == 0):
    gyaku_kaijo_memo.append(1)
  while(len(gyaku_kaijo_memo) <= n):
    gyaku_kaijo_memo.append(gyaku_kaijo_memo[-1] * pow(len(gyaku_kaijo_memo),MOD-2,MOD) % MOD)
  return gyaku_kaijo_memo[n]

def nCr(n,r):
  if(n == r):
    return 1
  if(n < r or r < 0):
    return 0
  ret = 1
  ret = ret * kaijo(n) % MOD
  ret = ret * gyaku_kaijo(r) % MOD
  ret = ret * gyaku_kaijo(n-r) % MOD
  return ret

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

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

#####LCM#####
def lcm(a, b):
    return a * b // gcd (a, b)

#############
# Main Code #
#############

a,b,c,d = inputIL()

if abs(c-a)<=d or (abs(c-b)<=d and abs(b-a)<=d):
  print("Yes")
else:
  print("No")


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

int H,W,K,Sx,Sy,dis[810][810],dep[810][810],Ans=1e9;
bool g[810][810],vis[810][810];
queue<pair<int,int> > q;

void BFS()
{
	while (!q.empty()) q.pop();
	vis[Sx][Sy]=1;
	q.push(make_pair(Sx,Sy));
	while (!q.empty())
	{
		int x=q.front().first;
		int y=q.front().second;
		q.pop();
		Ans=min(Ans,dis[x][y]+1);
		if (dep[x][y]==K) continue;
		if (g[x-1][y]&&!vis[x-1][y]) dep[x-1][y]=dep[x][y]+1,vis[x-1][y]=1,q.push(make_pair(x-1,y));
		if (g[x+1][y]&&!vis[x+1][y]) dep[x+1][y]=dep[x][y]+1,vis[x+1][y]=1,q.push(make_pair(x+1,y));
		if (g[x][y-1]&&!vis[x][y-1]) dep[x][y-1]=dep[x][y]+1,vis[x][y-1]=1,q.push(make_pair(x,y-1));
		if (g[x][y+1]&&!vis[x][y+1]) dep[x][y+1]=dep[x][y]+1,vis[x][y+1]=1,q.push(make_pair(x,y+1));
	}
}

int main()
{
#ifdef h10
	freopen("C.in","r",stdin);
	freopen("C.out","w",stdout);
#endif
	int i,j;
	char c;
	scanf("%d%d%d",&H,&W,&K);
	for (i=1;i<=H;i++)
	for (j=1;j<=W;j++)
	{
		c=getchar();
		while (c!='.'&&c!='#'&&c!='S') c=getchar();
		if (c=='#') continue;
		g[i][j]=1;
		dis[i][j]=min(min((i-1+K-1)/K,(j-1+K-1)/K),min((H-i+K-1)/K,(W-j+K-1)/K));
		if (c=='S') Sx=i,Sy=j;
	}
	BFS();
	printf("%d\n",Ans);
}


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

using namespace std;
#define all(a)a.begin(),a.end()
using ll=long long;
const int INF = 1<<30;
const ll INFll =1LL<<62;
const int mod= int(1e9)+7;
using P = pair<ll,ll>;
using ld=long double;

int main(){
    string s;cin >>s;
    unordered_map<char,int>mp;
    for (int i = 0; i < s.size(); ++i) {
        mp[s[i]]++;
    }
    bool flg=true;
    for(auto p:mp){
        if(p.second%2)flg=false;
    }
    if(flg)puts("Yes");
    else puts("No");
    return 0;
}


Measured memory_bytes: 3532
#include <bits/stdc++.h>
#include <string>
#include <cstring>
#include <algorithm>
#include <math.h>
#include <map>
#include <bitset>
#include <cmath>
#include <set>

#define INF 1000000000000
#define MOD 1000000007 //10^9+7:合同式の法

using namespace std;
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)

int main(){
    string o,e;
    cin >> o >> e;
    string ans;
    
    if(o.size() > e.size()){
        int i=0;
        while(i < e.size()){
            ans += o.at(i);
            ans += e.at(i);
            i++;
        }
        ans += o.at(i);
    }else{
        int i = 0;
        while(i < o.size()){
            ans += o.at(i);
            ans += e.at(i);
            i++;
        }
    }
    
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define str string
#define fi first
#define se second
#define pb push_back
#define SET(a, b) memset(a, b, sizeof(a))
#define eps 1e-6
#define pi atan(1) * 4
#define mod 1000000007
#define inf 1000000000
#define llinf 1000000000000000000
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
#define FORl(i, a, b) for (ll i = (a); i <= (b); i++)
#define FORDl(i, a, b) for (ll i = (a); i >= (b); i--)
using namespace std;
int main () {
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  string S;
  cin >> n >> S;
  if (n >= 3200) printf("%s\n", S.c_str());
  else printf("red\n");
  return 0;
}

Measured memory_bytes: 256
fn main() {
    let a = read::<u32>();
    let b = read::<u32>();
    let c = read::<u32>();
    let d = read::<u32>();
    println!("{}", std::cmp::min(a, b) + std::cmp::min(c, d));
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}
#[allow(dead_code)]
fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}
#[allow(dead_code)]
fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
#[allow(dead_code)]
fn yn(result: bool) {
    if result {
        println!("Yes");
    } else {
        println!("No");
    }
}


Measured memory_bytes: 4352
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();
		int r = sc.nextInt();
		int d = sc.nextInt();
		int count = 0;
		for(int i=l; i<=r; i++) {
			if(i%d==0) {
				count++;
			}
		}
		System.out.println(count);
		

	}

}


Measured memory_bytes: 26980
# row = [int(x) for x in input().rstrip().split(" ")]
# n = int(input().rstrip())
# s = input().rstrip()

def resolve():
    import sys
    input = sys.stdin.readline

    num_list = [int(x) for x in input().rstrip()]

    ans = sum(num_list)

    for i in range(1, len(num_list)+1):
        tmp = sum([x for x in num_list[:i]]) - 1 + 9 * (len(num_list) - i)
        if tmp > ans:
            ans = tmp

    print(ans)


if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61184
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let (n, k) = readl!(usize, usize);
    let mut x = Vec::with_capacity(n);
    let mut y = Vec::with_capacity(n);
    for _ in 0..n {
        let (a, b) = readl!(i64, i64);
        x.push(a);
        y.push(b);
    }
    let x = x;
    let y = y;
    
    let mut ans = std::i64::MAX;
    for lx in &x {
        for rx in &x {
            if rx <= lx {
                continue;
            }
            for ly in &y {
                for ry in &y {
                    if ry <= ly {
                        continue;
                    }
                    let mut cnt = 0;
                    for i in 0..n {
                        if *lx <= x[i] && x[i] <= *rx
                        && *ly <= y[i] && y[i] <= *ry {
                            cnt += 1;
                        }
                    }
                    if cnt >= k {
                        ans = std::cmp::min((rx-lx)*(ry-ly), ans);
                    }
                }
            }
        }
    }
    println!("{}", ans);
}



Measured memory_bytes: 4352
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
 
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<stdlib.h>
#include<stdarg.h>
#include<malloc.h>

int main()
{
	char s[128] = {0};
	int i, ans=0;

	while(scanf("%s", s) != EOF){

		for(i=0; i<128; i++){
			if((s[i] >= '0' && s[i] <= '9') && (s[i+1] >= '0' && s[i+1] <= '9') && (s[i+2] >= '0' && s[i+2] <= '9') && (s[i+3] >= '0' && s[i+3] <= '9')){
				ans += (s[i] - '0') * 1000 + (s[i+1] - '0') * 100 + (s[i+2] - '0') * 10 + (s[i+3] - '0');
				i += 3;
			} else if((s[i] >= '0' && s[i] <= '9') && (s[i+1] >= '0' && s[i+1] <= '9') && (s[i+2] >= '0' && s[i+2] <= '9')){
				ans += (s[i] - '0') * 100 + (s[i+1] - '0') * 10 + (s[i+2] - '0');
				i += 2;
			} else if((s[i] >= '0' && s[i] <= '9') && (s[i+1] >= '0' && s[i+1] <= '9')){
				ans += (s[i] - '0') * 10 + (s[i+1] - '0');
				i++;
			} else if(s[i] >= '0' && s[i] <= '9') {
				ans += s[i] - '0';
			}
		}
		for(i=0; i<128; i++)
			s[i] = 0;

	}
	printf("%d\n", ans);

	return 0;
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
using namespace std;
#define sd(x) scanf("%d", &x)
#define sz(v) (int) v.size()
#define pr(v) For(i, 0, sz(v)) {cout<<v[i]<<" ";} cout<<endl;
#define slld(x) scanf("%lld", &x)
#define all(x) x.begin(), x.end()
#define For(i, st, en) for(ll i=st; i<en; i++)
#define tr(x) for(auto it=x.begin(); it!=x.end(); it++)
#define fast std::ios::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define ll long long
#define ld long double
#define int long long
#define double long double
#define mp make_pair
#define F first
#define S second
typedef pair<int, int> pii;
typedef vector<int> vi;
#define pi 3.141592653589793238
const int MOD = 1e9+7;
const int INF = 1LL<<60;


const int N = 2e5+5;

// it's swapnil07 ;)
 
#ifdef SWAPNIL07
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cout << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int begtime = clock();
#define end_routine() cout << "\n\nTime elapsed: " << (clock() - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n";
#else
#define endl '\n'
#define trace(...)
#define end_routine()
#endif

int compute(int x){
    int c1 = sqrt(x);
    int ct = 0;
    For(i, 1, c1+1){
        int c2 = sqrt(x - i*i);
        For(j, 1, c2+1){
            int c33 = x - i*i - j*j - i*j;
            if(c33 <= 0)
                break;
            int c3 = sqrt(c33);
            For(k, 1, c3+1){
                int v = i*i + j*j + k*k + i*j + j*k + k*i;
                if(v == x){
                    ct++;
                }
                else if(v > x)
                    break;
            }
        }
    } 
    return ct;   
}


void solve(){
    int n; cin>>n;
    For(i, 1, n+1){
        cout<<compute(i)<<"\n";
    }
}


signed main()
{
    fast
    #ifdef SWAPNIL07
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    int t=1; 
    // cin>>t;
    while(t--){
        solve();
        // cout<<"\n";
    }
    return 0;
}



Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//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; }

/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(void){
    int N, M; cin >> N >> M;
    vector<int> p(M), y(M);
    vector<int> rank[N+1];
    for(int i=0; i<M; i++){
        cin >> p[i] >> y[i];
        rank[p[i]].push_back(y[i]);
    }

    for(int i=1; i<=N; i++) sort(rank[i].begin(), rank[i].end());

    for(int i=0; i<M; i++){
        auto itr = lower_bound(rank[p[i]].begin(), rank[p[i]].end(), y[i]);
        int r = itr - rank[p[i]].begin() + 1;
        printf("%06d%06d\n", p[i], r);
    }

    
}

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

signed main () {
	int n;
	cin >> n;
	vector < int > a(n);
	map < int, int > cnt;
	int64_t ans = 0;
	for (int i = 1; i <= n; ++i) {
		cin >> a[i - 1];
		ans += cnt[i - a[i - 1]];
		++cnt[a[i - 1] + i];
	}
	cout << ans << '\n';
}


Measured memory_bytes: 21044
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <numeric>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) ((int)x.size())
#define fi first
#define se second
const int INF = 1e15;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

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

const int MOD = 1000000007;
const int MX = 777777 + 5;
int fac[MX+5],inv[MX+5];
 
int power(int x,int y,int p){
	int res=1;
	x=x%p;
	while(y){
		if(y&1)res=(res*x)%p;
		y=y>>1;
		x=(x*x)%p;
	}
	return res;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    int a=(power(9,N,MOD)-power(8,N,MOD));
    if(a<0) a+=MOD;
    int ans=power(10,N,MOD)-power(8,N,MOD);
    if(ans<0)  ans+=MOD;
    ans-=(a*2)%MOD;
    if(ans<0) ans+=MOD;
    cout << ans << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include<string>
#include<math.h>
#include<algorithm>
using namespace std;

int main() {
    int N;
    cin >> N;
    int a[N];
    int maxa = - pow(10, 9);
    int mina = pow(10, 9);
    for (int i = 0; i < N; i++){
        cin >> a[i];
        maxa = max(maxa, a[i]);
        mina = min(mina, a[i]);
    }
    cout << maxa - mina << endl;

	return 0;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
void p(vector<char> A){rep(i,A.size()){cout << A[i];}cout << endl;}

int main(){
    int n;
    cin >> n;
    vector<int> h(n);
    rep(i,n) cin >> h[i];
    int now = h[0];
    for(int i = 1;i < n;i++){
        if (h[i] >= now){
            now = h[i];
        }
        else if (now - h[i] == 1){
            now = h[i] + 1;
        }
        else{
            cout << "No";
            exit(0);
        }
        //cout << now << endl;
    }
    cout << "Yes";
}

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

using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
const int MOD = 1000000009;
const long long INF = 1LL << 60;

int main() {
    int N, X, T;
    cin >> N >> X >> T;
    int t = N % X;
    if (t) cout << (N / X + 1) * T << endl;
    else cout << (N / X) * T << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.util.*;
import java.io.*;
import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;

public class Main implements Runnable
{
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};
    static long mod=1000000007;
    
    public static void main(String[] args) {        
        new Thread(null, new Main(), "", 200 * 1024 * 1024).start();        
    }

    public void run() {
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int a=sc.nextInt();
        int b=sc.nextInt();
        int c=sc.nextInt();
        int d=sc.nextInt();
        
        for(int i=0;0<=i;) {
        	c-=b;
        	if(c<=0)ret("Yes");
        	a-=d;
        	if(a<=0)ret("No");
        }
        
        out.println();
     	out.flush();
    }

    static void ret(String ans) {
    	System.out.println(ans);
    	System.exit(0);
    }

    static void ret(long ans) {
    	System.out.println(ans);
    	System.exit(0);
    }
    
    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

//class P {
//	int x,y; double d;
//	P(int  x, int y, double d) {
//	  this.x=x;
//	  this.y=y;
//	  this.d=d;
//	}
//}


//class P implements Comparable<P>{
//    int i,x,r,f;
//    P(int i,int x,int r,int f) {
//    	this.i=i;
//    	this.x=x;
//    	this.r=r;
//    	this.f=f;
//    }
//
//    public int compareTo(P p){
//    	if(-this.r+p.r==0) {
//    		return -this.x+p.x;
//    	}
//        return -this.r+p.r;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString()
    {
        while( st==null || !st.hasMoreTokens() )
			try {
				st = new StringTokenizer(x.readLine());
			} catch (IOException e) {
				// TODO Auto-generated catch block
				e.printStackTrace();
			}
        return st.nextToken();
    }
    public int nextInt()
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) {
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) {
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public char[] getCharSet() {
        return this.nextString().toCharArray();
    }    
    public long nextLong()
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 33132
#include<stdio.h>
 
int main(){
  int x,y,z;
  int t;
  scanf("%d %d %d",&x,&y,&z);
  //xとyを入れ替える
  t=x;
  x=y;
  y=t;
  //xとzを入れ替える
  t=x;
  x=z;
  z=t;
  
  printf("%d %d %d",x,y,z);
  return 0;
}

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

int main(){
    string s;
    cin >> s;
    int n = s.size();
    int ans = 0;
    for(int i = 0; i < (n+1)/2;i++){
        if(s.at(i) != s.at(n-1-i))ans++;
    }
    cout << ans << endl;

}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); i++)
#define all(x) (x).begin(), (x).end()
#define bit(x) (1L << (x))
using ll = long long;
using namespace std;

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

int main() {
        ll a, b, n;
        cin >> a >> b >> n;

        if (n >= b - 1) {
                cout << a * (b - 1) / b << endl;
        } else {
                cout << a * n / b << endl;
        }

        return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <cmath>
#include <cstdlib>
#include <tuple>
#include <iterator>
#include <sstream>
#include <bits/stdc++.h>

using ll = long long;
using namespace std;
#define modmod 1000000007

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

int waru(int N){
    int count = 0;
    while(1){
        if(N/10 == 0){
            count += N;
            break;
        }else{
            count += N%10;
            N = N/10;
        }
    }
    return count;
}

int main(){
    int N;
    cin >> N;
    int result = 100003;
    for(int a = 1 ; a <= N/2; a++){
        int b = N-a;
        int num = waru(a) + waru(b);
        if(result > num){
            result = num;
        }
    }
    cout << result << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair
#define F first
#define S second

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;


const int MOD = 1000000007;
const int nax = 200009;
int fact[nax];
ll int  powermod(ll int base, ll int exp, ll int mod) {
ll int result = 1;
while (exp != 0) {
    if ((exp % 2) == 1) {
        result = (result * base) % mod;
    }
    base = (base * base) % mod;
    exp /= 2;
}
return result;
}
ll int c(ll int n,ll int r){
    ll int va = 1;
    if(r > n-r){
        r = n - r;
    }
    ll int res = 1;
    for (size_t i = 0; i < r; i++) {
        va = (va*(n-i)%MOD);
        res = (res*(r - i)%MOD);
    }
    //dump(va);dump(res);
    va = ((va % MOD)*(powermod(res , MOD - 2 , MOD) % MOD)) % MOD;
    ///dump(va);
    return va;
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll int n,a,b;cin>>n>>a>>b;
    ll int ans = 0;
    ans = powermod(2,n,MOD);
    /*fact[0] = 1;

    for (size_t i = 1; i < n; i++) {
        fact[i] = (fact[i-1]*i)%MOD;
    }
    */
    ans = (ans - c(n,a) - c(n,b) - 1)%MOD;
    ans = (ans + MOD) % MOD;
    cout<<ans;

	//cout<<"Time Used : "<<clock()<<endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod=1000000007;
int main(){
  ll n;cin>>n;
  ll a[n][n];
  for(ll i=0;i<n;i++)for(ll j=0;j<n;j++)cin>>a[i][j];
  ll dp[1<<n];
  ll t=1<<n;
  fill(dp,dp+t,0);
  dp[0]=1;
  for(ll i=1;i<1<<n;i++){
    ll j=__builtin_popcount(i)-1;
    for(ll k=0;k<n;k++){
      if(i&(1<<k)&&a[j][k]){
        dp[i]+=dp[i^(1<<k)];
      }
      dp[i]%=mod;
    }
  }
  cout<<dp[(1<<n)-1]<<endl;
  
}

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

int main() {
  int n, x, t;
  cin >> n >> x >> t;
  int ans = n / x;
  if (n % x == 0) {
    cout << ans * t << endl;
  } else {
    cout << (ans + 1) * t << endl;
  }
  return 0;
}

Measured memory_bytes: 3632