akhauriyash/Code-Regression huggingface dataset:
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        n: i32
    }
    println!("{}", (1000 - n % 1000) % 1000);
}


Measured memory_bytes: 2108
#include <iostream>
#include <algorithm>
#include <fstream>
#include <set>
#include <string>
#include <time.h>
#include <map>
#include <bitset>
#include <queue>
#include <deque>
#include <iomanip>
#include <vector>
#include <cstring>
#include <cassert>
#include <stack>
#include <functional>
#include <cmath>
#include <climits>

using namespace std;

#define _ ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define endl "\n"

const int MAXN = 1000010;
const int mod = 1000000009;

typedef long long ll;

int n;
int ar[MAXN];

int main() {
	cin >> n;
	n *= 2;
	for (int i = 0; i < n; i++) {
		cin >> ar[i];
	}
	sort(ar, ar + n);
	reverse(ar, ar + n);
	int ans = 0;
	for (int i = 1; i < n; i += 2) ans += ar[i];
	cout << ans << endl;
}

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

int main()
{
  int n, a[200000];
  int m = 0, r = 0;

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

  for(int i = 0; i < n; i++){
    if(abs(m/2-r) > abs(m/2-a[i])){
      r = a[i];
    }
  }

  cout << m << ' ' << r << endl;

  return 0;
}


Measured memory_bytes: 640
using System;
using System.Collections.Generic;
class Program{
  
  static void Main()
  {
    string[] Sh=Console.ReadLine().Split(' ');
    int S=int.Parse(Sh[0]);
    int W=int.Parse(Sh[1]);
    
    if(S>W)
    {
      Console.WriteLine("safe");
    }
    else
    {
      Console.WriteLine("unsafe");
    }
  }
  
}

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

int main()
{
  int n;
  cin >> n;
  long long int min = 10000000;
  long long int max = -10000000;
  long long int x, sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> x;
    if (min > x) {
      min = x;
    }
    if (max < x) {
      max = x;
    }
    sum = sum + x;
  }
  cout << min << " ";
  cout << max << " ";
  cout << sum << endl;
}


Measured memory_bytes: 3100
#include <cstdio>
#include <cstring>
#include <cmath>
#include <queue>
#include <algorithm>
#include <iostream>
using namespace std;


int main()
{
  long long int k;
  cin >> k;
  long long int n = 50;
  long long int a[50]={};

  long long int m,l;
  m = k/n;
  l = k%n;

  for(int i=0;i<n;i++){
    a[i] = m + n -1;
  }

  for(int i=0;i<n-l;i++)
    a[i] -= l;

  for(int i= n-l;i<n;i++)
    a[i] += n + 1 - l;

  cout << n << endl;
  for(int i=0;i<n;i++)
    cout << a[i] << " ";
  cout << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a < b) {
      System.out.println("a < b");
    } else if (a > b) {
      System.out.println("a > b");
    } else {
      System.out.println("a == b");
    }
  }
}


Measured memory_bytes: 26176
#include<bits/stdc++.h>
using namespace std;
vector<int>adj[100005];
#define pb push_back
int vis[100005];
int lvl[100005];
int par[100005];
string bfs(int n)
{
    queue<int>f;
    f.push(1);
    lvl[1]=1;
    par[1]=-1;
    string ans;
    while(1)
    {
        int top=f.front();
        f.pop();
        if(top==n)break;
        for(int i=0;i<adj[top].size();i++)
        {
            int chi=adj[top][i];
            if(lvl[chi]==0)
            {
                par[chi]=top;
                lvl[chi]=lvl[top]+1;
                f.push(chi);
            }
        }
    }
    int a=(lvl[n]+1)/2+1;
    int x=n;
    while(par[x]!=-1)
    {
        if(lvl[x]==a)
        {
            vis[x]=2;
            break;
        }
        x=par[x];
    }
    queue<int>q;
    q.push(1);
    vis[1]=1;
    while(!q.empty())
    {
        int top=q.front();
        q.pop();
        for(int i=0;i<adj[top].size();i++)
        {
            int chi=adj[top][i];
            if(vis[chi]==0)
            {
                vis[chi]=1;
                q.push(chi);
            }
        }
    }
    int cnt=0;
    for(int i=1;i<=n;i++)
        if(vis[i]==1)cnt++;
    if(cnt>n-cnt)ans="Fennec";
    else ans="Snuke";
//    cout<<"cnt = "<<cnt<<endl;
    return ans;
}

int main()
{
    int n;cin>>n;
    for(int i=0;i<n-1;i++)
    {
        int u,v;cin>>u>>v;
        adj[u].pb(v);
        adj[v].pb(u);
    }
    string ans=bfs(n);
    cout<<ans<<endl;
}
/*
9
1 2
1 4
1 3
1 8
5 8
5 6
6 7
5 9
*/


Measured memory_bytes: 7040
price, num = map(int,input().split())
dislike = list(input().split())
ans = price
p = 0
for i in range(10*price+1):
    s = str(ans)
    for j in range(len(str(s))):
        if s[j] in dislike:
            break
    else:
        break
    ans += 1
print(ans)


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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);

int main() {
    ios_base::sync_with_stdio(false);
    int k,a,b; cin >> k >> a >> b;
    int x = (a/k + (a%k?1:0))*k;
    cout << (x >= a and x <= b?"OK":"NG") << endl;
    return 0;
}



Measured memory_bytes: 3696
// clang-format off
#include <bits/stdc++.h>
#define int long long
#define main signed main()
#define loop(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) loop(i, 0, n)
#define forever for (;;)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define prec(n) fixed << setprecision(n)
template<typename A> using V = std::vector<A>;
template<typename A> using F = std::function<A>;
template<typename A, typename B> using P = std::pair<A, B>;
using pii = P<int, int>;
using vi = V<int>;
using vd = V<double>;
using vs = V<std::string>;
using vpii = V<pii>;
using vvi = V<vi>;
using vvpii = V<vpii>;
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; }
template<typename T> std::istream &operator>>(std::istream &is, std::vector<T> &v) { for (T &x : v) is >> x; return is; }
template<typename A, typename B> std::istream &operator>>(std::istream &is, std::pair<A, B> &p) { is >> p.first; is >> p.second; return is; }
using namespace std;
// clang-format on

main {
  int n, r;
  while (cin >> n >> r) {
    vi c(r);
    cin >> c;
    deque<int> C;
    rep(i, n) C.push_back(i);
    for (auto &x : c) {
      deque<int> A, B;
      rep(i, n / 2) B.push_back(C.front()), C.pop_front();
      loop(i, n / 2, n) A.push_back(C.front()), C.pop_front();
      while (A.size() || B.size()) {
        rep(i, x) if (A.size()) C.push_back(A.front()), A.pop_front();
        rep(i, x) if (B.size()) C.push_back(B.front()), B.pop_front();
      }
    }
    cout << C.back() << endl;
  }
}

Measured memory_bytes: 3124
#include <algorithm>
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <vector>
#include <queue>
#include <math.h>
#include <string> 
#include <bits/stdc++.h>
using namespace std;

int main(){
    string S,T,U;
    int A,B;
    cin >> S >> T;
    cin >> A >> B;
    cin >> U;
    if(S==U){
        A=A-1;
    }else{
        B=B-1;
    }
    cout << A << " " << B << endl;
}

Measured memory_bytes: 256
// 2116
#include<bits/stdc++.h>
#define fast ios::sync_with_stdio(false);cin.tie(NULL)
using namespace std;
#define int long long
#define MOD 1000000007
typedef vector<int> vi;
typedef pair<int,int> pi;
#define inf 1e18
#define For(i,a,b) for (int i = a; i < b; i++)
#define Rep(i,a,b) for (int i = a; i <= b; i++)
#define ps(x,y) fixed << setprecision(y) << x 
#define pb push_back 
#define mp make_pair 
 
int32_t main()
{
    fast;
    int n, m, ans; cin >> n >> m;
    if(m >= 2*n) {
        ans = n;
        m -= 2*n;
        ans += m / 4; 
        cout << ans << "\n";
    }
    else {
        cout << m / 2 << "\n";
    }
    
    
    
    
    
    return 0;
}

Measured memory_bytes: 3612
from operator import add
import statistics
n,*a=map(int,open(0).read().split())
b=range(-1,-(n+1),-1)
combined=[a[i]+b[i] for i in range(n)]
x=round(statistics.median(combined))
ans=sum([abs(combined[i]-x) for i in range(n)])
print(ans)


Measured memory_bytes: 29688
#!/usr/bin/env ruby

(n, p) = gets.chomp.split(/ /).map(&:to_i)
array = []
if (n == 1)
  puts p
  exit
end

if (p == 1)
  puts 1
  exit
end

i = 2
ans = 1
while (i * i <= p)
  if (p % i == 0)
    if ((p % (i ** n)) == 0)
      ans *= i
      p /= i ** n
    else
      p /= i
    end
  else
    i += 1
  end
end
puts ans


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


long long int power(long long int x, int y){
	long long int ans = 1;
	while(y--) ans *= x;
	return ans;
}


int main(){
	long long int x;


	cin >> x;

	for(long long int a=-1000; a <= 1000; a++){
		for(long long int b=-1000; b <= 1000; b++){
			if(power(a, 5) - power(b, 5) == x){
				cout << a << " " << b << endl;
				return 0;
			}
		}
	}
}


Measured memory_bytes: 3600
from collections import deque

n, m = map(int, input().split())
edges = [[] for _ in range(n)]
prev = [-1] * n
for _ in range(m):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    edges[a].append(b)
    edges[b].append(a)

def bfs(v):
    q = deque()
    prev[v] = -99999
    q.append(v)
    while q:
        v = q.popleft()
        for u in edges[v]:
            if prev[u] == -1:
                prev[u] = v
                q.append(u)

bfs(0)
print("Yes")
for i in range(1, n):
    print(prev[i] + 1)


Measured memory_bytes: 34164
N = int(input())
A = [int(T) for T in input().split()]
L = [0]*(N+1)
R = [sum(A)]*(N+1)
for T in range(0,N):
    L[T+1] = L[T]+A[T]
    R[T+1] = R[T]-A[T]
MIN = 10**10
for T in range(1,N):
    if abs(L[T]-R[T])<MIN:
        MIN = abs(L[T]-R[T])
print(MIN)

Measured memory_bytes: 36824
#include<bits/stdc++.h>
using namespace std;
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
using ll=long long;
using ld=long double;
#define INF 1000000009
const ll INFll=1ll*INF*INF;
#define MOD 998244353
#define MODE 1000000007
const long double PI=3.141592653589793238462643383279502884197169399375105820974944;
#define pb push_back
#define mp make_pair
#define rep(i,n) for (ll i = 0; i < n; i++)
#define rev(i,n) for (ll i = n-1; i >= 0; i--)
#define REP(i,a,b) for (ll i = a; i < b; i++)
#define REV(i,a,b) for (ll i = a; i >= b; i--)
#define all(v) v.begin(),v.end()
#define F first
#define S second
#define vl vector<ll>
#define pll pair<ll,ll>
#define sz(a) (ll)a.size()
#define print(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << *it << ' '; cout << endl;
#define printii(arr) for (auto it = arr.begin(); it != arr.end(); ++it) cout << it->f<<' '<<it->s << endl; cout << endl;
#define MID(i,j) ((i)+(j))/2
#define nl '\n' 
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
#define int ll
ll gcd(ll a,ll b)  {return (b==0)? a:gcd(b,a%b);}

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


void solve() {
    int n, m;
    cin >> n >> m;
    char a[n][m];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            cin >> a[i][j];
        }
    }
    int paths[n][m] = {0};
    for(int i = 0; i < n; i++){
        for(int j = 0; j < m; j++){
            if(a[i][j] == '#')paths[i][j] = 0;
            else{
                if(i == 0 && j == 0){
                    paths[i][j] = 1;
                }
                else if(i == 0){
                    paths[i][j] = paths[i][j-1];
                }
                else if(j == 0){
                    paths[i][j] = paths[i-1][j];
                }
                else{
                    paths[i][j] = (paths[i][j-1]+paths[i-1][j])%MODE;
                }
            }
        }
    }
    cout << paths[n-1][m-1] << endl;

}

// DONT GET TLE FOR NOT USING FASTIO (--__--)

signed main(){
	fastio;
    ll t = 1;
    // cin >> t;
    rep(i, t){
        solve();
    }
    return 0;
}


Measured memory_bytes: 12320
#include <bits/stdc++.h>
#define N 1000005
#define ll long long int 	
#define MP make_pair
#define pb push_back
#define ppb pop_back
#define sp " "
#define endl "\n"
#define fi first
#define se second
#define ii pair<int,int>
#define lli pair<ll,ll>
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
#define fast2 freopen ("badhair.gir","r",stdin);freopen ("badhair.cik","w",stdout);
#define mod 1000000007
#define fs(x,y) for(ll i=1;i<=y;i++) cin>>x[i]
#define fo(i,x,y) for(ll i=x;i<=y;i++)
#define INF 1000000000005
using namespace std;

ll n,m,ar[N],sum,t;



int main()
{
	fast;
	cin>>n;
	fs(ar,n);
	sort(ar+1,ar+n+1,greater<int>());
	int l=0;
	for(int i=1;i<=n;i++)
	{
		l=i;
		if(ar[i+1]<=i)
		{
			l=i;
			break;
		}
	}
	ll t1=0,t2=0;
	t1=ar[l]-l;
	for(int i=l+1;i<=n;i++)
	{
		if(ar[i]<l)
			break;
		t2++;
	}
	// cout<<l<<endl;
	// cout<<t1<<sp<<t2<<endl;
	if(t2%2==0 && t1%2==0)
		cout<<"Second";
	else
		cout<<"First";

}



/*     cd onedrive\desktop\kod
cls

Sinav:21-22 aralik
Aciklama: Muhtemelen 25 aralik
*/

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define pb push_back
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1e9 + 7;
const ll inf = 9223372036854775807;
const ll mininf = -9223372036854775807;
const ll nax = 0;
 
ll len, n, bl;
string s; 
char ch[105];

int main(){
	cin >> s;
	len = s.length();
	for (ll i = 0; i < s.length(); i++){
		ch[i+1] = s[i];
	}
	for (ll i = 1; i <= len / 2; i++){
		// cout << i << " " << len-i+1 << '\n';
		if (ch[i] != ch[len-i+1]){
			bl = 1;
		}
	}
	// cout << 99 << '\n';
	n = (len - 1) / 2;
	for (ll i = 1; i <= n / 2; i++){
		// cout << i << " " << n - i + 1 << '\n';
		if (ch[i] != ch[n-i+1]){
			bl = 1;
		}
	}
	// cout << 99 << '\n';
	n = (len + 3) / 2;
	for (ll i = n; i < (n + len) / 2; i++){
		// cout << i << " " << len - i + n << '\n';
		if (ch[i] != ch[len-i+n]){
			bl = 1;
		}
	}
	if (bl){
		cout << "No" << '\n';
	}
	else{
		cout << "Yes" << '\n';
	}
}


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

int main() {
    int X,Y;
    cin >> X >> Y;
    for(int i=0;i<X+1;i++) {
        if(2*i+4*(X-i)==Y) {
            cout << "Yes" << endl;
            exit(0);
        }
    }
    cout << "No" << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
#define int long long
using namespace std;
const int INF = 1e9 + 7, MOD = 1e9 + 7;
const long long LINF = 1e18;
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

int Check(int n) {
	int Tmp = n, Cnt = 0;
	while (Tmp >= 2 && Tmp % 2 == 0) {
		Cnt++;
		Tmp /= 2;
	}
	return Cnt;
}

signed main() {
	int n;
	cin >> n;
	int a[n];
	vector<int> vec;
	for (int i = 0; i < n; i++) {
		cin >> a[i];
		if (a[i] % 2 == 0) vec.push_back(a[i]);
	}
	int Ans = 0;
	for (auto e : vec) {
		Ans += Check(e);
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 512
#include<stdio.h>
#define MOD 1000000009+7

int main(){
	int A[3];
	scanf("%d %d %d",&A[0],&A[1],&A[2]);
	int max=A[0];
	int min=A[0];
	for(int i=1;i<3;i++){
		if(max<A[i])max=A[i];
		if(min>A[i])min=A[i];
	}
	printf("%d\n",max-min);
	
	return 0;
}

Measured memory_bytes: 128
//--- pB ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	PrintWriter out;
	public Solution() {
		reader = new Reader();
		out = new PrintWriter(System.out);
		while (reader.hasNext()) {
			run_case();
		}
		out.flush();
	}

	private void run_case() {
		char[] arr = reader.ns().toCharArray();
		int n = arr.length;
		for (int i=0; i<n; i++) {
			if (arr[i] == '?') arr[i] = 'D';
		}
		out.println(String.valueOf(arr));
		return;
	}
}


class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public long nl() {return Long.parseLong(this.next());}
	public String ns() {return this.next();}
}


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

using namespace std;

typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi; 
typedef vector<ll> vl;
typedef vector<ld> vd;
typedef pair<int,int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef priority_queue<int> pqi;
typedef priority_queue<int, vi, greater<int>> mpqi;

#define IOS std::ios::sync_with_stdio(false); cin.tie(0);
#define F0R(i,a) for(int i = 0; i < a; i++)
#define R0F(i,a) for(int i = a - 1; i >= 0; i--)
#define pb push_back
#define mp make_pair
#define ins insert
#define ft front()
#define bk back()
#define f first
#define s second
#define trav(a,x) for(auto& a : x)
#define ALL(x) (x).begin(), (x).end()

const int MOD = 1000000007;
const int MX = 2e5+2;
const ll INF = 1000000000000000000;
const ld PI = 4*atan((ld)1);
const int dx[4] = {1,0,-1,0}, dy[4] = {0,1,0,-1};

bool tkmin(int a, int b){
    return b < a ? a = b, true : false;
}
bool tkmax(int a, int b){
    return b > a ? a = b, true : false;
}
int rudiv(int a, int b){
    return a/b + !(a % b == 0);
}
ll exp(ll a1, ll b1, ll m1) { // a1^b1 mod m1
    a1 %= m1; ll res = 1;
    while (b1 > 0) {
        if (b1 & 1) res = res * a1 % m1;
        a1 = a1 * a1 % m1;
        b1 >>= 1;
    }
    return res;
}

// Output
void op(int ok){ cout << ok << endl; }
void op(string ok){ cout << ok << endl; }
void op(ll ok){ cout << ok << endl; }
void op(char ok){ cout << ok << endl; }
void op(db ok){ cout << fixed << setprecision(7) << ok << endl; }
void op(ld ok){ cout << fixed << setprecision(7) << ok << endl; }
void op(pi ok){ cout << ok.f << " " << ok.s << endl; }
void op(pl ok){ cout << ok.f << " " << ok.s << endl; }
void op(pd ok){ cout << ok.f << " " << ok.s << endl; }

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

int a, b, c;

int main(){
    IOS;
    cin >> a >> b >> c; cout << c << " " << a << " " << b;
    return 0;
    // You should actually read the notes to self.
}

/* NOTES TO SELF:
    Int overflow? Array bounds?
    Edge cases? (n = 1, n = 0)
    Don't be dumbosity please pace yourself.
*/

Measured memory_bytes: 256
N = int(input())
X = list(map(int,input().split()))
if sum(X)//N <= sum(X)/N <= sum(X)//N+0.5:
  A = sum(X)//N
else:
  A = sum(X)//N+1
B = []
for i in range(N):
  B.append((X[i]-A)**2)
print(sum(B))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  ll n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  reverse(s.begin(),s.end());
  vl S(n+1,0);
  map<ll,ll> nums;
  ll ten = 1;
  rep(i,n){
    S[i+1] = (S[i] +(s[i]-'0')*ten)%p;
    ten = (ten*10)%p; 
  }
  ll ans = 0;
  if(p == 2 || p == 5){
    rep(i,n){
      if((s[i]-'0')%p==0)ans+=n-i;
    }
    cout<<ans<<endl;
    return 0;
  }
  rep(i,n+1){
    ll q = S[i]%p;
    nums[q]++;
  }
  for(auto it: nums){
    ll a = it.se;
    ans+=a*(a-1)/2;
  }
  cout<<ans<<endl;
  return 0;
}

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

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

  int A, B, C, D;
  cin >> A >> B >> C >> D;
  const int MOD = 998244353;
  vector<vector<int>> dp(C + 2, vector<int>(D + 2, 0));
  dp[C][D] = 1;
  for (int i = C; i >= A; i--) {
    for (int j = D; j >= B; j--) {
      dp[i][j - 1] += 1ll * i * dp[i][j] % MOD;
      dp[i][j - 1] %= MOD;
      dp[i - 1][j] += 1ll * j * dp[i][j] % MOD;
      dp[i - 1][j] %= MOD;
      dp[i - 1][j - 1] -= 1ll * (i - 1) * (j - 1) * dp[i][j] % MOD;
    }
  }
  cout << (dp[A][B] + MOD) % MOD << "\n";
  return 0;
}


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

using namespace std;

const int  N = 1e5 + 5;

int n, ar[N];

int calc (int player = 1)
{
    int cn = 0, in, gcd;
    for (int i = 1; i <= n; i++)
    {
        if (ar[i] % 2 == 0) cn++;
        else in = i;
    }
    if (cn & 1)
        return player;

    else if (cn != n - 1 || ar[in] == 1)
        return (player ^ 1);

    ar[in]--;
    gcd = ar[1];
    for (int i = 2; i <= n; i++)
        gcd = __gcd(gcd, ar[i]);

    for (int i = 1; i <= n; i++)
        ar[i] /= gcd;
    calc(player ^ 1);
}

int main()
{
    cin >> n;
    for (int i = 1; i <= n; i++) scanf("%d", &ar[i]);
    if (calc())
        puts("First");
    else
        puts("Second");
}


Measured memory_bytes: 640
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

	public Main() {
		// TODO Auto-generated constructor stub
	}

	public static void main(String[] args) {
		Scanner sc  = new Scanner(System.in);
		int N = sc.nextInt();
		Long[] a = new Long[3*N];
		for(int i = 0; i < 3*N; i++)
			a[i] = sc.nextLong();
		sc.close();
		List<Long> aList = Arrays.asList(a);
		Collections.sort(aList);
		BigInteger sum = BigInteger.ZERO;
		for(int i = aList.size() - 2; i >= N; i -= 2) {
			sum = sum.add(BigInteger.valueOf(aList.get(i)));
		}	
		System.out.println(sum);
	}

}


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

int main(){
    vector<bool> prime(250000, true);
    prime[0] = false;
    prime[1] = false;
    for (int i = 2; i < 250000; i++){
        if (prime[i] == false) continue;
        for (int j = i * 2; j < 250000; j += i) prime[j] = false;
    }
    while (1){
        int n;
        cin >> n;
        if (n == 0) break;
        int ans = 0;
        for (int i = n + 1; i <= n * 2; i++) if (prime[i]) ans++;
        cout << ans << endl;
    }
}


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

#define int long long
#define pii pair<int, int>
#define pb push_back
 
signed main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    int k, n;
    cin >> k >> n;
    int a[n];
    int mn = k;
    for(int i = 0; i < n ; i++){
        cin >> a[i];
        
        if(i > 0)
            mn = min(mn, k - a[i] + a[i-1]);
    }
    mn = min(mn, a[n-1] - a[0]);
    cout << mn << endl;
    return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<queue>
#include<cmath>
#include<cstdio>
#include<tuple>
#include<bitset>
#include<map>

using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define ALL(x) x.begin(),x.end()
#define ll long long
using lint=long long;
typedef pair<int,int> P;
const int inf=1000000007;
const int MOD=1000000007;
signed main(){
  int x[2],y[2];
  cin>>x[0]>>y[0]>>x[1]>>y[1];
  int v[2]={y[0]-y[1],x[1]-x[0]};
  int dy=-1;int dx=1;
  int rx[2],ry[2];
  rx[0]=x[1]+v[0];
  ry[0]=y[1]+v[1];
  v[0]=x[0]-x[1];v[1]=y[0]-y[1];
  rx[1]=rx[0]+v[0];
  ry[1]=ry[0]+v[1];
  cout<<rx[0]<<" "<<ry[0]<<" "<<rx[1]<<" "<<ry[1]<<"\n";
  return 0;
}

Measured memory_bytes: 3540
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <vector>
#include <map>
#include <stack>
#include <string>
#include <list>
#include <set>
#include <queue>
#include <deque>
#include <math.h>
#include <string.h>
using namespace std;

typedef pair<int, int> P;
#define ll long long
//#define int ll
#define INF (1LL<<60)
#define mod 1000000007


int N;

signed main(){

	cin >> N;
	cout << N*(N + 1) / 2 << endl;
	return 0;
}


Measured memory_bytes: 256
N=int(input())
X=list(map(int,input().split()))
Y=[0]*N
S=sum(X)

Y[0]=S-2*sum([X[i] for i in range(N) if i%2==1])

for i in range(N-1):
	Y[i+1]=2*X[i]-Y[i]

print(*Y)

Measured memory_bytes: 14092
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>
#include <iostream>
#include <sstream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <utility>
#include <numeric>
#include <algorithm>
#include <bitset>
#include <complex>
#include <array>
#include <list>
#include <stack>
#include <valarray>

using namespace std;

typedef unsigned uint;
typedef long long Int;
typedef unsigned long long UInt;

const int INF = 1001001001;
const Int INFLL = 1001001001001001001LL;

template<typename T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<typename T> void chmin(T& a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T& a, T b) { if (a < b) a = b; }
int in() { int x; scanf("%d", &x); return x; }
double fin() { double x; scanf("%lf", &x); return x; }
Int lin() { Int x; scanf("%lld", &x); return x; }

string f(const string& s) {
  const int n = s.size();
  vector<int> Z(n);

  Z[0] = n;
  for (int i = 1, j = 0; i < n; ) {
    while (i + j < n && s[j] == s[i + j]) {
      ++j;
    }
    Z[i] = j;
    if (j == 0) {
      ++i;
      continue;
    }
    int k = 1;
    while (i + k < n && k + Z[k] < j) {
      Z[i + k] = Z[k];
      ++k;
    }
    i += k;
    j -= k;
  }

  int r = 0;
  for (int i = 1; i * 2 < n; ++i) {
    if (Z[n - i] == i) {
      r = i;
    }
  }

  return s.substr(0, n - r) + s.substr(0, n - r);
}

Int len[1024], res[26], cnt[1024][26];
string A0, A1;

void solve(int k, Int L, Int R) {
  // cerr<<k<<' '<<L<<' '<<R<<endl;
  if (len[k] == R - L) {
    for (int i = 0; i < 26; ++i) {
      res[i] += cnt[k][i];
    }
    return;
  }
  if (k <= 1) {
    const string& s = (k == 0 ? A0 : A1);
    for (int i = L; i < R; ++i) {
      res[s[i] - 'a']++;
    }
    return;
  }
  if (L < len[k - 1]) solve(k - 1, L, min(R, len[k - 1]));
  if (R > len[k - 1]) solve(k - 2, max(L, len[k - 1]) - len[k - 1], R - len[k - 1]);
}

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

  Int L, R;
  cin >> L >> R;
  --L;

  const string S1 = f(S);
  const string S2 = f(S1);

  A0 = S1.substr(S.size() / 2, S1.size() / 2 - S.size() / 2);
  A1 = S2.substr(S1.size() / 2, S2.size() / 2 - S1.size() / 2);

  for (const char c : A0) cnt[0][c - 'a']++;
  for (const char c : A1) cnt[1][c - 'a']++;

  int k = 1;
  len[0] = A0.size();
  len[1] = A1.size();
  for (int i = 2; ; ++i) {
    len[i] = len[i - 1] + len[i - 2];
    for (int j = 0; j < 26; ++j) {
      cnt[i][j] = cnt[i - 1][j] + cnt[i - 2][j];
    }
    if (len[i] > INFLL) {
      k = i;
      break;
    }
  }

  S = S.substr(S.size() / 2);
 
  fill(res, res + 26, 0);
  if (L < S.size()) {
    while (L < S.size() && L < R) {
      res[S[L] - 'a']++;
      ++L;
    }
  }
  L -= S.size();
  R -= S.size();

  if (R - L > 0) {
    for (int i = 0; i <= k; ++i) {
      if (L < len[i]) solve(i, L, min(R, len[i]));
      L -= len[i];
      R -= len[i];
      if (R <= 0) break;
      if (L < 0) L = 0;
    }
  }

  for (int i = 0; i < 26; ++i) {
    printf("%lld%c", res[i], i+1 == 26 ? '\n' : ' ');
  }

  return 0;
}


Measured memory_bytes: 3564
import Control.Monad (replicateM)
import Data.List (foldl')

shuffle :: [a] -> Int -> [a]
shuffle li a = let (pre,post) = splitAt a li in post ++ pre

main = do
    source <- getLine
    case source of
        "-" -> return ()
        s -> do
            n <- readLn
            replicateM n readLn >>= putStrLn . foldl' shuffle s
            main

Measured memory_bytes: 4152
from collections import Counter
 
M = 998244353
n = int(input())
a = map(int, input().split())
x, c = next(a), Counter(a)
r = 0
if x == c[0] == 0:
  r = p = i = 1
  x = c[i]
  while x:
    r = r * pow(p, x, M) % M
    i += 1; n -= x; p = x; x = c[i]
print((r, 0)[n > 1])


Measured memory_bytes: 22636
/**
    AUTHOR:JUNSH
    TIME:19/5/19
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int a,b;
    cin>>a>>b;
    cout<<(3*a+b)/2<<endl;
}


Measured memory_bytes: 256
n,k,c=map(int,input().split())
s=input()
def greedy_work(days,rest,plan):
  day_count=0
  go=[0]*n
  while day_count < days:
    if plan[day_count]=='o':
      go[day_count]=1
      day_count += rest+1
    else:
      day_count += 1
  return(go)
front = greedy_work(n,c,s)
back = greedy_work(n,c,s[::-1])
back = back[::-1]
if front.count(1)==k:
  for i in range(n):
    if front[i]==1 and back[i]==1:
      print(i+1)

Measured memory_bytes: 8040
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
#include<deque>
using namespace std;



int main() {
	int s;
	cin >> s;
	deque<long int>a;
	a.push_back(s);
	int i = 0;
	int ans = 0;
	while (i <= 1000000) {
		i++;
		if (s % 2 == 0) {
			s = s / 2;
			a.push_back(s);
	
		}
		else {
			s = 3 * s + 1;
			a.push_back(s);
		}
		for (int i = 0; i < a.size()-1; i++) {
			if (s== a[i]) {
				ans = a.size() ;
				break;
			}
		}
		if (ans > 0) {
			break;
		}
	}
	cout << ans << endl;

}


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

int main(){
  string s;
  cin >> s;
  
  reverse(s.begin(),s.end());
  
  int k=0;
  long long ans=0;
  
  for(int i=0;i<s.size();i++){
    if(s.at(i)=='B'){
      ans+=i-k;
      k++;
    }
  }
  
  cout << ans << endl;
  
}

Measured memory_bytes: 640
#include<iomanip>
#include<limits>
#include<thread>
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
#include<deque>
using namespace std;
typedef unsigned long long int ull;
typedef long long int ll;
const int E=1e9+7;
#define F first
#define S second
#define MK make_pair




int main(){
    cout<<fixed<<setprecision(12);
    int n,m,d;
    cin>>n>>m>>d;
    double p=m-1;
    if(d==0){p*=1.0/(double)n;}
    else{p*=(double)n-d; p*=(double)2; p/=(double)n*n;}
    cout<<p<<endl;
    
    return 0;
}


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

int main()
{
    int l,r; cin >> l >> r;
    int ans = 2018;

    if (r-l <= 2019)
    {
        for (int i = l; i <= r; ++i)
        {
            for (int j = i+1; j <= r; ++j)
                ans = min(ans, ((i%2019)*(j%2019))%2019);
        }
        cout << ans;
        return 0;
    }

    cout << 0;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int a,b,c,sum,cnt;
	cnt=1;
	sum=0;
	scanf("%d %d %d",&a,&b,&c);
	while(1){
		sum=sum+a;
		if(cnt%7==0){
			sum=sum+b;
		}
		if(sum>=c){
			printf("%d\n",cnt);
			break;
		}
		cnt++;
	}
	return 0;
}


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

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

const ll INF64 = 1LL << 60;
const int INF32 = 1 << 29;
const int MOD = 1000000007;

const int CASES = 4;

vector<bool> isprime;
vector<int> Era(int n) {
    isprime.resize(n, true);
    vector<int> res;
    isprime[0] = false; isprime[1] = false;
    for (int i = 2; i < n; ++i) isprime[i] = true;
    for (int i = 2; i < n; ++i) {
        if (isprime[i]) {
            res.push_back(i);
            for (int j = i*2; j < n; j += i) isprime[j] = false;
        }
    }
    return res;
}


bool check(int N, int mb){
    return false;
}

void solve() {
    ll N, M;
    cin >> N >> M;

    if(M % N == 0){
        cout << M/N << endl;
        return;
    }
    
    ll ans = 1;
    for(ll i = 1; i < M / N + 1; ++i){
        if((M - i * N) % i == 0){
            ans = max(ans, i);
        }
    }
    cout << ans << endl;
    return ;
}

int main() {
    #ifdef MYLOCAL
    vector<string> filenames {"input1.txt", "input2.txt", "input3.txt", "input4.txt"};
    cout << "------------\n";
    for(int i = 0; i < CASES; ++i){
        ifstream in(filenames[i]);
        cin.rdbuf(in.rdbuf());
        solve();
        cout << "------------\n";
    }
    #else

    solve();

    #endif
    return 0;
}



Measured memory_bytes: 256
#pragma region ヘッダー
#define _CRT_SECURE_NO_WARNINGS

#ifdef _____MY_DEBUG_____
#define VS_ENDPAUSE()	(system("pause"))
#else
#define VS_ENDPAUSE()
#endif

#include <stdio.h>
#include <string.h>
#include <iostream>
#include <math.h>
#include <cmath>
#include <vector>
#include <algorithm>

using namespace std;
typedef signed char int8;
typedef signed short int16;
typedef signed int int32;
typedef signed long long int64;
typedef unsigned char uint8;
typedef unsigned short uint16;
typedef unsigned int uint32;
typedef unsigned long long uint64;
#define int int64

#ifndef INT8_MIN
#define INT8_MIN	(-127)
#endif
#ifndef INT8_MAX
#define INT8_MAX	( 128)
#endif
#ifndef UINT8_MAX
#define UINT8_MAX	( 255)
#endif
#ifndef INT16_MIN
#define INT16_MIN	(-32768)
#endif
#ifndef INT16_MAX
#define INT16_MAX	( 32767)
#endif
#ifndef UINT16_MAX
#define UINT16_MAX	( 65535)
#endif
#ifndef INT32_MIN
#define INT32_MIN	(-2147483648)	// -2 * 10^9
#endif
#ifndef INT32_MAX
#define INT32_MAX	( 2147483647)	//  2 * 10^9
#endif
#ifndef UINT32_MAX
#define UINT32_MAX	( 4294967295)	//  4 * 10^9
#endif
#ifndef INT64_MIN
#define INT64_MIN	(-9223372036854775808)	// -9 * 10^18
#endif
#ifndef INT64_MAX
#define INT64_MAX	( 9223372036854775807)	//  9 * 10^18
#endif
#ifndef UINT64_MAX
#define UINT64_MAX	( 18446744073709551615)	// 18 * 10^18
#endif

void func(void);
#pragma endregion

int32 main(void)
{
	func();
	VS_ENDPAUSE();
	return 0;
}


void func(void)
{
	int n;
	cin >> n;
	vector< int > a(n);
	for(int i=0; i<n; i++){
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	int l = a[n-1] - a[0];
	cout << l << endl;

	return;
}




Measured memory_bytes: 256
using System;
using System.Linq;

class F2
{
	static void Main()
	{
		var n = int.Parse(Console.ReadLine());
		var n2 = n / 2;
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

		if (n % 2 == 0)
		{
			long M = a.Where((x, i) => i % 2 == 1).Sum(x => (long)x), t = M;
			for (int i = 0; i < n2; i++)
				M = Math.Max(M, t += a[2 * i] - a[2 * i + 1]);
			Console.WriteLine(M);
		}
		else
		{
			var dp = CreateArray(n2 + 1, 3, -1L << 60);
			dp[0][0] = dp[0][1] = dp[0][2] = 0;

			for (int i = 0; i < n2; i++)
				for (int j = 0; j < 3; j++)
					for (int k = j; k < 3; k++)
						dp[i + 1][k] = Math.Max(dp[i + 1][k], dp[i][j] + a[2 * i + k]);
			Console.WriteLine(Enumerable.Range(0, 3).Max(j => dp[n2][j]));
		}
	}

	static T[][] CreateArray<T>(int l1, int l2, T v = default)
	{
		var a = new T[l1][];
		for (int i = 0; i < l1; i++)
		{
			a[i] = new T[l2];
			Array.Fill(a[i], v);
		}
		return a;
	}
}


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

template<typename T>
T gcd(T a,T b)
{
	if(a<b) swap(a,b);
	T r = a % b;
	while(r!=0)
	{
		a = b;
		b = r;
		r = a % b;
	}
	return b;
}

int main()
{
	int T;
	cin >> T;
	bool is_ok[T];
	unsigned long int A,B,C,D;
	for(int i=0;i<T;i++)
	{
		is_ok[i] = false;
//		cin >> A >> B >> C >> D;
		scanf("%ld%ld%ld%ld",&A,&B,&C,&D);
		if(A<B) 	continue;
		if(D<B)		continue;
		if(C<A%B)	continue;
		if(C<B-gcd(B,D))	continue;
		is_ok[i] = true;
	}
	for(int i=0;i<T;i++)
		if(is_ok[i]) 	cout << "Yes" << std::endl;
		else			cout << "No" << std::endl;
	return 0;
}

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

int main()
{
    double x1, y1, x2, y2, d;
    cin >> x1 >> y1 >> x2 >> y2;
    d = sqrt((x2-x1)*(x2-x1) + (y2-y1)*(y2-y1));
    cout << fixed << setprecision(8) << d << endl;
    return 0;
}


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

#define mod 1000000007

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

using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
 
int main(void){
  
	int N, M = 100001;
	cin >> N;

	vector<int> A(M);
	vector<int> B(M);
	for(int i = 0; i < N / 2; i++) {
		int a, b;
		cin >> a >> b;
		A.at(a)++;
		B.at(b)++;
	}

	int a, b, X = 0, Y = 0;
	for(int i = 0; i < M; i++){
		if (A.at(i) > X){
			X = A.at(i);
			a = i;
		}
		if(B.at(i) > Y){
			Y = B.at(i);
			b = i;
		}
	}

	sort(A.rbegin(), A.rend());
	sort(B.rbegin(), B.rend());

	if (a == b) 
		cout << min(N - A.at(0) - B.at(1), N - A.at(1) - B.at(0)) << endl;
	else 
		cout << N - A.at(0) - B.at(0) << endl;
}


Measured memory_bytes: 1152
import java.util.*;
public class Main {
	public static void main(String[] arg) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for(int i=0; i<n; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		int cnt=1;
		for(int i=1; i<n;i++) {
			if(a[i]>a[i-1]) {
				cnt++;
			}
		}
		System.out.println(cnt);
		
	}

}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
#define x first
#define y second
using namespace std;

using f80 = long double;
using i64 = long long;
using pii = pair<i64, i64>;

const f80 PI = 3.141592653589793238462643383279502884197169399375105820974L;

vector<pii> v;
vector<i64> lis;

int main() {
#ifdef HOME
	freopen("agc09c.in", "r", stdin);
	freopen("agc09c.out", "w", stdout);
#endif
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	f80 res;
	i64 x0, y0, x1, y1, tx, ty, n;
	int ant;

	cin >> x0 >> y0 >> x1 >> y1;

	tx = x0 > x1 ? -1 : 1;
	ty = y0 > y1 ? -1 : 1;

	x0*= tx, y0*= ty;
	x1*= tx, y1*= ty;

	cin >> n, v.resize(n);
	for (auto &i: v) {
		cin >> i.x >> i.y;
		i.x*= tx, i.y*= ty; }

	for (int i = 0; i < v.size(); ++i) {
		if (!(min(x0, x1) <= v[i].x && v[i].x <= max(x0, x1)) || !(min(y0, y1) <= v[i].y && v[i].y <= max(y0, y1))) {
			swap(v[i], v.back());
			v.pop_back();
			--i; } }

	sort(begin(v), end(v));
	for (int i = 0; i < v.size(); ++i) {
		auto it = lower_bound(begin(lis), end(lis), v[i].y);
		if (it == end(lis))
			lis.push_back(v[i].y);
		else
			*it = v[i].y; }
	ant = lis.size();

	if (ant == 1 + min(abs(x0 - x1), abs(y0 - y1)))
		res = 100 * (abs(x1 - x0) + abs(y1 - y0)) + (ant - 1) * (10 * PI / 2.0 - 20) + (10 * PI - 20);
	else
		res = 100 * (abs(x1 - x0) + abs(y1 - y0)) + ant * (10 * PI / 2.0 - 20);

	cout << setprecision(20) << fixed;
	cout << res << endl;

	return 0; }


Measured memory_bytes: 5620
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define sz(x) (int)(x).size()
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
  
int main() {
  int N;
  cin >> N;
  v(string) s(N);
  rep(i,N) {
    cin >> s[i];
  }
  map<string,int> mp;
  rep(i,N) {
    mp[s[i]]++;
  }
  int maxn = 0;
  for(auto x: mp) {
    maxn = max(maxn,x.second);
  }
  for(auto x: mp) {
    if(x.second == maxn) {
      cout << x.first << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 26752
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first 
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30; const ll LINF=1LL<<60 ; const ll MOD=1e9+7 ;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
//-------------------


int main(){
	int n,a,b;
	cin >> n >> a >> b;
	cout << min(a*n,b);
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int number_a, number_b, number_c;
  scanf("%d %d %d", &number_a, &number_b, &number_c);
  if((number_a > number_c && number_c > number_b) || (number_a < number_c && number_c < number_b)) {
    printf("Yes\n");
  } else {
    printf("No\n");
  }

  return 0;
}


Measured memory_bytes: 128
def get_input():
    while True:
        try:
            yield int(raw_input())
        except EOFError:
            break

num_lis = list(get_input())

for num in num_lis:
    all_count = 600/num
    S = 0
    for i in range(all_count-1):
        count = i+1
        yoko = num
        tate = (count*num)**2
        S += (yoko*tate)
    print(S)

Measured memory_bytes: 4208
use proconio::input;

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

    let coeff = (n - m) * 100 + 1900 * m;

    let mut previous = -1.0f64;
    let mut current = 0.0f64;
    let mut k = 1.0;
    let pos = 1.0 / 2.0f64.powf(m as f64);
    while (previous - current).abs() > 1e-9 {
        previous = current;
        current += k * pos * (1.0 - pos).powf(k - 1.0);
        k += 1.0;
    }
    let sum = current.round() as usize;

    println!("{}", coeff * sum);
}


Measured memory_bytes: 3028
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))

const ll INF = 1LL << 60;
ll h[100010];
ll dp[100010];

int main() {
  int n;
  cin >> n;
  vector<int>h(n);
  rep(i,n) cin >> h[i];
  rep(i,n) dp[i] = INF;
  dp[0]=0;
  rep(i,n) {
    mins(dp[i+1], dp[i]+abs(h[i]-h[i+1]));
    mins(dp[i+2], dp[i]+abs(h[i]-h[i+2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}


Measured memory_bytes: 1408
import itertools

N, A, B, C = map(int,input().split())
L = [int(input()) for _ in range(N)]

A, B, C = sorted([A,B,C], reverse=True)

ans = 100000000 ## =Inf
for state in itertools.product(range(4), repeat=N): ## 4**N 通りの全探索, 3:not used
    bamboo = [0]*4
    for i in range(len(state)): ## stateに応じてbambooをグループ化する, 同グループは合成
      if state[i] < 3:
        bamboo[state[i]] += L[i]
    if 0 in bamboo[0:3]: ## 竹が3種類あることを確認
      continue
    cost_0 = max(state.count(0) - 1, 0) * 10
    cost_1 = max(state.count(1) - 1, 0) * 10
    cost_2 = max(state.count(2) - 1, 0) * 10
    cost = cost_0 + cost_1 + cost_2
    bamboo.sort(reverse=True)
    cost += abs(bamboo[0]-A) + abs(bamboo[1]-B) + abs(bamboo[2]-C)
    ans = min(ans, cost)
    
print(ans)
  

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define rrep(i,n) for(int i=n-1;i>=0;--i)
#define yesno(flg) if(flg){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define MAX_N 1002
#define i197 1000000007

using namespace std;

typedef long long ll;
typedef pair<ll,ll> P1;
typedef pair<int,int> Pi;
typedef pair<double,Pi> Pdi;
typedef pair<ll,int>Pli;
typedef pair<P1,ll> P2;
const ll INF=1000000000000000001;
struct edge{int to,cost;};
int dy[]={0, 0, 1, -1};
int dx[]={1, -1, 0, 0};
struct Road{double cost;int a,b;};


int main() {

	string s,t;
	int n;
	cin>>n;
	cin>>s;
	cin>>t;
	rep(i,n){
		if(s[i]!=t[0])continue;
		int k=0,f=0;
		for(int j=i+1; j<n; j++){
			k++;
			if(s[j]!=t[k]){
				f=1;
				break;
			}
		}
		if(f==0){
			cout<<n+i<<endl;
			return 0;
		}
	}
	cout<<n*2<<endl;
	return 0;

}


Measured memory_bytes: 256
var
	f:array[0..100010] of int64;
	a,b,n,m,i,j:longint;
begin
	readln(n,m);
	fillchar(f,sizeof(f),$7f);
	f[0]:=0;
	for i:=1 to n do 
	begin
		read(a,b);
		for j:=100000 downto b do
			if f[j-b]+a<f[j] then f[j]:=f[j-b]+a;
	end;
	for i:=100000 downto 0 do
		if f[i]<=m then
		begin
			writeln(i);
			break;
		end;
end.

Measured memory_bytes: 896
#include<bits/stdc++.h>
using namespace std;
int main() {
  int N,K;
  cin>>N>>K;
  vector<int>l(N);
  for(int i=0;i<N;i++)cin>>l.at(i);
  sort(l.begin(),l.end(),greater<int>());
  int sum=0;
  for(int i=0;i<K;i++)sum+=l.at(i);
  cout<<sum<<endl;
}

Measured memory_bytes: 256