akhauriyash/Code-Regression huggingface dataset:
/*
 * Shubham Jain
 */
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define mem(x,val) memset((x),(val),sizeof(x));
#define rite(x) freopen(x,"w",stdout);
#define read(x) freopen(x,"r",stdin);
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define sqr(x) ((x)*(x))
#define clr clear()
#define ll long long int
#define inf (1<<30)
#define ins insert
#define endl '\n'
#define xx first
#define yy second
#define eps 1e-9
#define FAST_IO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define INF 1000000000000000000
#define mx 0
inline ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
inline ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }


int main() {
    FAST_IO
    ll x,y,a,c=0;
    cin>>x>>y;
    while(x<=y){
        x=x*2;
        c++;
    }
    cout<<c<<endl;
return 0;
}


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

//何でも良い型に変換
template<class T> inline bool chmin(T&a,T b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}  
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

const long long INF = 1LL << 60;

// 入力
int N;
long long h[100010];

// DP テーブル
long long dp[100010];

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

    // 初期化 (最小化問題なので INF に初期化)
    for (int i = 0; i < 100010; ++i) dp[i] = INF;

    // 初期条件
    dp[0] = 0;

    // ループ
    for (int i = 1; i < N; ++i) {
        chmin(dp[i], dp[i - 1] + abs(h[i] - h[i - 1]));
        if (i > 1) chmin(dp[i], dp[i - 2] + abs(h[i] - h[i - 2]));
    }

    // 答え
    cout << dp[N-1] << endl;
}


Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>
#include <limits>
#include <math.h>
using namespace std;

int N;

int countEmpty(int h[]){
  int num = 0;
  for(int i = 0; i < N; i++ ) {
    if(h[i] == 0 ){
      num++;
    }
  }
  return num;
}
int countEmptyGroup(int h[]) {
  int num = 0;
  bool flag = false;
  for(int i = 0; i< N; i++) {
    if(i == N -1 && (flag || h[i] == 0) ) {
      num++;
    }else if(!flag && h[i] == 0) {
      flag = true;
    }else if (flag && h[i] != 0){
      num++;
      flag = false;
    }
  }
  return num;
}
void decrement(int h[]) {
  for(int i = 0; i< N; i++){
    if(h[i] != 0) {
      h[i] = h[i] -1;
    }   
  }
}

int side(int h[]) {
  int count = 0;
  if(h[N-1] == 0){
    count++;
  }
  if(h[0] == 0){
    count++;
  }
  return count;
}

int main(){ 
  cin >> N;
  int h[N];
  for(int i = 0; i < N; i++) {
    cin >> h[i];
  }
  int count = 0;
  while(countEmpty(h) < N){
    count += countEmptyGroup(h) - side(h) + 1;
    decrement(h);
  }
  cout << count << endl;
  return 0;
}

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

int main()
{
        string str, left, right;
        int h, t, size;

        while(1){
                cin >> str;
                if(str=="-"){break;}
                cin >> h;
                for(int i=0; i<h; i++){
                        cin >> t;
                        size = str.length();
                        left = str.substr(0,t);
                        right = str.substr(t,size-t);
                        str = right + left;
                }
                cout << str << endl;
        }

        return 0;
}

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

int main() {

    int n;
    cin >> n;

    vector<int> p(n);
    rep(i, n) {
       cin >> p[i];
    }
    auto v=p;
    sort(v.begin(),v.end());

    int cnt=0;
    rep(i,n) {
        if(v[i]!=p[i])cnt++;
    }

    if(cnt==2||cnt==0){
        cout << "YES" << endl;
    }else{
        cout << "NO" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
N = int(input())
Ls = list(map(int,input().split()))
ans = 0

for i in range(N-2):
    for j in range(i+1,N-1):
        for k in range(j+1,N):
            m = max(Ls[i],Ls[j],Ls[k])
            if Ls[i] + Ls[j] + Ls[k] - 2*m > 0 and Ls[i] != Ls[j] and Ls[i] != Ls[k] and Ls[j] != Ls[k]:
                ans += 1

print(ans)


Measured memory_bytes: 9128
#include <bits/stdc++.h>
using namespace std;
#define int long long
const int mod = 1000000007;
signed main()
{
    int N;
    string S[2];
    int i = 1;
    cin >> N;
    cin >> S[0] >> S[1];
    int ans = 3;
    if(S[0][0] != S[1][0]) i++, ans = 6;
    while(i < N) {
        if(S[0][i] != S[1][i]) {
            if(S[0][i - 1] != S[1][i - 1]) (ans *= 3) %= mod;
            else (ans *= 2) %= mod;
            i++;
        } else {
            if(S[0][i - 1] == S[1][i - 1]) (ans *= 2) %= mod;
        }
        i++;
    }
    cout << ans << endl;
    return (0);
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

const double PI=acos(-1);
const double EPS=1e-9; //うまくいかなかったらゆるめる

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;
typedef vector<pii> vp;
typedef vector<vi> vvi;

int gcd(int a, int b){if(b==0) return a;return gcd(b,a%b);}
int lcm(int a, int b){return a/gcd(a,b)*b;}


signed main(void) {
    int n;
    cin >> n;
    vi ans(4,-1);
    if(n == 1){
        int m;
        cin >> m;
        rep(i,m){
            int ind, num;
            cin >> ind >> num;

            if(ans[ind] != -1 && num != ans[ind]){
                cout << -1 << endl;
                return 0;
            }
            ans[ind] = num;
        }
        if(ans[1] == -1)ans[1] = 0;
        cout << ans[1] << endl;
        return 0;
    }
    if(n == 2){
        int m;
        cin >> m;
        rep(i,m){
            int ind, num;
            cin >> ind >> num;
            if(ind == 1 && num == 0){
                cout << -1 << endl;
                return 0;
            }

            if(ans[ind] != -1 && num != ans[ind]){
                cout << -1 << endl;
                return 0;
            }
            ans[ind] = num;
        }
        if(ans[1] == -1)ans[1] = 1;
        if(ans[2] == -1)ans[2] = 0;
        cout << ans[1] << ans[2] << endl;
        return 0;
    }
    if(n == 3){
        int m;
        cin >> m;
        rep(i,m){
            int ind, num;
            cin >> ind >> num;
            if(ind == 1 && num == 0){
                cout << -1 << endl;
                return 0;
            }

            if(ans[ind] != -1 && num != ans[ind]){
                cout << -1 << endl;
                return 0;
            }
            ans[ind] = num;
        }
        if(ans[1] == -1)ans[1] = 1;
        if(ans[2] == -1)ans[2] = 0;
        if(ans[3] == -1)ans[3] = 0;
        cout << ans[1] << ans[2] << ans[3] << endl;
        return 0;
    }
}


Measured memory_bytes: 256
from collections import Counter
import sys
input = sys.stdin.buffer.readline

def main():
    n = int(input())
    lis = list(map(int,input().split()))
    d = Counter(lis)
    su = 0
    for e in d:
        su += (d[e] - 1) * d[e] // 2

    for e in lis:
        if d[e] <= 1:
            print(su)
        else:
            k = d[e]
            res = su - k*(k-1)//2 + (k-1)*(k-2)//2
            print(res)

if __name__ == '__main__':
    main()


Measured memory_bytes: 71024
#include<bits/stdc++.h>
#include<algorithm>
 
using namespace std;
int main()
{
 
int a,b,flag=0;
int ans;
cin>>a>>b;
for (int i=0; i<=998244353; ++i)
{
  if(abs(a-i)==abs(b-i))
  {
    ans=i;
    flag=1;
    break;
  }
  
  
}
 
if(flag==1){
cout<<ans;  
}
else
{
  cout<<"IMPOSSIBLE";
}
 
 
}

Measured memory_bytes: 256
#[test]
fn test_solve() {
    assert_eq!(solve("3 4\naabb\naabb\naacc\n"), "Yes\n");
    assert_eq!(solve("2 2\naa\nbb\n"), "No\n");
    assert_eq!(solve("5 1\nt\nw\ne\ne\nt\n"), "Yes\n");
    assert_eq!(solve("2 5\nabxba\nabyba\n"), "No\n");
    assert_eq!(solve("1 1\nz\n"), "Yes\n");
}

fn solve(src: &str) -> String {
    let mut sc = Scanner::from_str(src);

    let h: usize = sc.read();
    let w: usize = sc.read();
    let crd = |c: char| c as usize - 'a' as usize;
    let mut cnt = vec![0; crd('z') + 1];
    for _ in 0..h {
        let s = sc.get().chars();
        for c in s {
            cnt[crd(c)] += 1;
        }
    }
    let mut c1 = 0;
    let mut c2 = 0;
    for mut c in cnt {
        if c & 1 == 1 {
            c1 += 1;
        }
        c >>= 1;
        if c & 1 == 1 {
            c2 += 1;
        }
    }
    let (a1, a2) = match (h & 1, w & 1) {
        (0, 0) => (0, 0),
        (1, 1) => (1, (h + w) / 2 - 1),
        (1, 0) => (0, w / 2),
        (0, 1) => (0, h / 2),
        (_, _) => unreachable!(),
    };
    if c1 == a1 && c2 <= a2 && (a2-c2) & 1 == 0 {
        "Yes\n".to_string()
    } else {
        "No\n".to_string()
    }
}

fn main() {
    let mut buf = String::new();
    use std::io;
    use std::io::{Read, Write};
    io::stdin().read_to_string(&mut buf).unwrap();
    io::stdout().write_all(solve(&buf).as_bytes()).unwrap();
}

struct Scanner<'a>(std::str::SplitWhitespace<'a>);
impl<'a> Scanner<'a> {
    fn from_str(src: &str) -> Scanner {
        Scanner(src.split_whitespace())
    }
    fn get(&mut self) -> &str {
        self.0.next().unwrap()
    }
    fn read<T: std::str::FromStr>(&mut self) -> T {
        self.get().parse().ok().unwrap()
    }
}


Measured memory_bytes: 4352
#include<iostream>
#include<string>

using namespace std;

class dice {

public:

	int TOP, S, E, W, N, BOTTOM, tmp;

	void rotN () {
		tmp = N;
		N = TOP; TOP = S; S = BOTTOM, BOTTOM = tmp;
	}
	void rotE () {
		tmp = E;
		E = TOP; TOP = W; W = BOTTOM; BOTTOM = tmp;
	}
	void rotW () {
		tmp = W;
		W = TOP; TOP = E; E = BOTTOM; BOTTOM = tmp;
	}
	void rotS () {
		tmp = S;
		S = TOP; TOP = N; N = BOTTOM; BOTTOM = tmp;
	}
	void clockwise () {
		tmp = W;
		W = S; S = E; E = N; N = tmp;
	}
	void antiClockwise () {
		tmp = W;
		W = N; N = E; E = S; S = tmp;
	}
};


int main(){

    int num, i, dice_num[6];
    string rot_map;

    for(i=0;i<6;i++){
        cin >> num;
        dice_num[i] = num;
    }

    dice dice = {dice_num[0], dice_num[1], dice_num[2], dice_num[3], dice_num[4], dice_num[5]};

    cin >> rot_map;

    for(i=0;i<rot_map.length();i++){
        switch(rot_map[i]){
            case 'N':
                dice.rotN();
                break;
            case 'E':
                dice.rotE();
                break;
            case 'W':
                dice.rotW();
                break;
            case 'S':
                dice.rotS();
                break;
        }
    }

    cout << dice.TOP << endl;

    return 0;

}


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

int main() {
  string s;
  cin >> s;
  vector<int> v(s.size() - 2);
  
  for (int i = 0; i < s.size() - 2; i++)
    v[i] = (s[i] - '0') * 100 + (s[i + 1] - '0') * 10 + (s[i + 2] - '0');

  for (int i = 0; i < v.size(); i++) v[i] = abs(v[i] - 753);

  sort(v.begin(), v.end());
  cout << v[0] << endl;
}


Measured memory_bytes: 256
#include<iostream>
using std::cin;
using std::cout;
using std::endl ;
int main()
{
	int b[10];
	int i=0,j;
	for(;i<10;i++)
		cin>>b[i];
	int t;
	for(i=0;i<3;i++)
	{
		for(j=0;j+i<9;j++)
			while(b[j]>b[j+1])
			{	t=b[j];b[j]=b[j+1];b[j+1]=t;}
		cout<<b[j]<<endl;
	}
	return 0;
}

Measured memory_bytes: 1160
#include <iostream>
#include <string>
using namespace std;
 
int main()
{
  int h, w;
  cin >> h >> w;
  string s[100];
  for(int i = 0; i < h; i++){
    cin >> s[i];
    cout << s[i] << endl;
    cout << s[i] << endl;
  }
}

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

int main() {
  int x, y;
  cin >> x >> y;
  int turu, kame;
  bool ok = false;
  for (int i = 0; i <= x; i++) {
    turu = i;
    kame = x - i;
    if (turu * 2 + kame * 4 == y) {
      ok = true;
      break;
    }
  }

  if (ok) {
    puts("Yes");
  } else {
    puts("No");
  }

  return 0;
}


Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()
{
    int K, i;
    int S = 0;

    cin >> K;

    for (int i = 0; i <= K; i++)
    {
        S = (S * 10 + 7) % K;
        if (S == 0)
        {
            cout << i + 1 << endl;
            return 0;
        }
    }

    cout << -1 << endl;
    return 0;
}

Measured memory_bytes: 3592
INF = int(1e9 + 7)


def factorial(x):
    FCT = 1
    for i in range(2, x + 1):
        FCT = i * FCT % INF
    return FCT


def main():
    N, M = map(int, input().split())
    MIN_NM = factorial(min(N, M))
    if N == M:
        print(2 * MIN_NM * MIN_NM % INF)
    elif abs(N - M) <= 1:
        print(MIN_NM * MIN_NM * max(N, M) % INF)
    else:
        print(0)

    return


main()


Measured memory_bytes: 3060
s=input()
table=[1]+[0 for _ in range(3)] 
abc='ABC'
mod=10**9+7
for i in range(len(s)):
    if s[i]=='?':
        for j in range(3,0,-1):
            table[j]=(3*table[j]+table[j-1])%mod
        table[0]=3*table[0]%mod
    else:
        for j in range(3):
            if s[i]==abc[j]:
                table[j+1]+=table[j]
#print(table)
print(table[3]%mod)


Measured memory_bytes: 3188
#include<iostream>

using namespace std;

int main(){
  int A, B;
  
  cin >> A >> B;
  
  if(A >= 13){
    cout << B << endl;
  }else if(6 <= A && A <= 12){
    cout << B/2 << endl;
  }else{
    cout << 0 << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
const int size=1e5+5;
const int level = 60;
typedef long long int ll;
ll basis[level];
void add(ll mask)
{
    for(int i=level-1;i>=0;i--)
    {
        if(((mask>>i)&1) == 0)
            continue;
        if(!basis[i])
        {
            basis[i] = mask;
            return;
        }
        mask ^= basis[i];
    }
}
int main()
{
    int n;
    cin>>n;
    ll arr[n];
    ll total = 0;
    for(int i=0;i<n;i++)
        cin>>arr[i],total ^= arr[i];
    ll ans = 0;
    for(int i=0;i<level;i++)
    {
        if((total>>i)&1)
        {
            for(int j=0;j<n;j++)
                if((arr[j]>>i)&1)
                arr[j] -= (1LL<<i);
        }
    }
    for(int i=0;i<n;i++)
        add(arr[i]);
    for(int i=level-1;i>=0;i--)
    {
        if(!basis[i])
            continue;
        if((ans>>i)&1) continue;
        ans ^= basis[i];
    }
    cout<<(ans+(ans^total))<<"\n";
    return 0;
}


Measured memory_bytes: 1024
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define For(i,a,b) for(int i=a;i<=b;i++)
#define F first
#define S second
#define all(x) x.begin(),x.end()
#define sz(x) ((int)x.size())
#define MOD (ll)(1e9+7)
#define INF 1e17
#define int ll
#define EPS (1e-6)
using namespace std;
using ll=long long;
using pii=pair<int,int>;

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

int fpow(int b,int p)
{
	if(p==0) return 1;
	int h=fpow(b,p/2);
	if(p%2) return h*b%MOD*h%MOD;
	return h*h%MOD;
}

int32_t main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	int x; cin>>x;
	int ans=x/11*2;
	x=x%11;
	if(x>=1) ans++;
	if(x>=7) ans++;
	cout<<ans<<"\n";
	return 0;
}





























Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<iomanip>

using namespace std;

int main() {
	
	double a, b, c;
	
	while( cin >> a >> b >> c  ) {
		
	double area = a * b * sin(c * M_PI / 180) / 2;
	double d = sqrt(a * a + b * b - 2 * a * b * cos(c * M_PI / 180 ));
	double premeter = a + b + d;
	double h = area * 2 / a;
		
	cout << fixed << setprecision(6)
		 << area << "\n"
		 << premeter << "\n"
		 << h << "\n";
		
	}
	
	return 0;
}


Measured memory_bytes: 3500
# E - Payment

N = input().strip()

s = 0
carry = 0
prev = None
for c in reversed(N):
    x = int(c) + carry
    if x > 5 or x == prev == 5:
        if prev == 5:
            x += 1
        s += 10 - x
        carry = 1
    else:
        s += x
        carry = 0
    prev = x
s += carry

print(s)


Measured memory_bytes: 52844
#include<cstdio>
#include<cmath>
int n,m,q;
int a[55],b[55],c[55],d[55];
int A[15],num,maxn=-1e9;
int max(int a,int b) {
	return a>b?a:b;
}
void dfs(int pre){
	if(num==n) {
		int sum=0;
		for(int i=1;i<=q;i++) {
			if(A[b[i]]-A[a[i]]==c[i]) {
				sum+=d[i];
			}
		}
		maxn=max(maxn,sum);
		return;
	}
	for(int i=pre;i<=m;i++) {
		A[++num]=i;
		dfs(i);
		A[num--]=0;
	}
}
int main() {
  scanf("%d%d%d",&n,&m,&q);
  for(int i=1;i<=q;i++) {
  	scanf("%d%d%d%d",&a[i],&b[i],&c[i],&d[i]);
  }
  dfs(1);
  // for(int i=)
  return printf("%d\n",maxn),0;
}

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  ll n;
  cin >> n;
  ll a = sqrt(n);
  for (; a >= 1; --a) {
    if (n % a == 0) break;
  }
  ll b = n/a;
  ll ans = max(log10(a), log10(b)) + 1;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 512
#include <stdio.h>

int main(int argc, char** argv)
{
  int a, b;
  int i;
  scanf("%d%d",&a,&b);
  for(i=b*10; i<b*10+10; ++i){
    if(i*8/100 == a){
      printf("%d\n", i);
      return 0;
    }
  }
  printf("-1\n");
  return 0;
}



Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
using namespace std;

#ifdef LOCAL
	#define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
	#define eprintf(...) 42
#endif

typedef long long ll;
typedef pair<int, int> pii;
#define mp make_pair

const int N = (1 << 18) + 7;
int n;
int a[N][2];
int b[N];

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

	scanf("%d", &n);
	for (int i = 0; i < (1 << n); i++) {
		scanf("%d", &a[i][0]);
		a[i][1] = -1;
	}
	for (int k = 0; k < n; k++)
		for (int mask = 0; mask < (1 << n); mask++) {
			if (((mask >> k) & 1) == 0) continue;
			for (int i = 0; i < 2; i++) {
				int t = a[mask ^ (1 << k)][i];
				for (int j = 0; j < 2; j++)
					if (a[mask][j] < t)
						swap(a[mask][j], t);
			}
		}
	for (int i = 1; i < (1 << n); i++)
		b[i] = a[i][0] + a[i][1];
	for (int i = 2; i < (1 << n); i++)
		b[i] = max(b[i], b[i - 1]);
	for (int i = 1; i < (1 << n); i++)
		printf("%d\n", b[i]);

	return 0;
}


Measured memory_bytes: 6144
N = int(input())
A = list(map(int,input().split()))
k = 0
l = 0
for i in range(N):
  if (A[i] % 4 == 0):
    k += 1
  elif (A[i] % 2 ==0):
    l += 1
if (k >= N//2):
  print('Yes')
elif (l == N):
  print('Yes')
else:
  if (N-k-l > k or k <= 1):
    print('No')
  else:
    print('Yes')


Measured memory_bytes: 15020
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll> 
#define rep(i,n) for(ll (i)=0; i<(n); ++(i))
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll n;cin>>n;
  lvector a(n,0),ans(n,0);rep(i,n) cin>>a[i];
  for(ll i=0;i<n;++i) {
    if(i%2==0) ans[i/2]=a[n-1-i];
    else ans[n-(i+1)/2]=a[n-1-i];
  }
  rep(i,n) cout<<ans[i]<<' ';cout<<endl;
  return 0;
}

Measured memory_bytes: 5376
import java.util.*;
import java.math.*;

class Main {
  public static void main (String[] args) {
    Scanner scan_ = new Scanner(System.in);
    int howMany_ = scan_.nextInt();
    long total = 0;
    int[] ints = new int[howMany_];
    for(int i = 0; i < howMany_ ; i++) {
      ints[i] = scan_.nextInt();
     }
     Arrays.sort(ints);
    for(int i = 0; i < howMany_ ; i++) {
     total += ints[i];
     }
     System.out.println(ints[0] + " " + ints[howMany_ - 1] + " "  + total);
  }
}


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

using namespace std;

const int MAX_N = 100, INDEX = 1;

int n, a[MAX_N + INDEX];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie();
    cout.tie();

    cin >> n;

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

    cout << *max_element(a + INDEX, a + INDEX + n, less<int>()) - *min_element(a + INDEX, a + INDEX + n, less<int>()) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define intt long long
#define mk make_pair
#define pb push_back
#define fr first
#define sc second
#define ii pair<intt,intt>
using namespace std;

int main()
{
    intt a,b,c;
    cin>>a>>b>>c;
    intt have=a-b;
    c=max(0ll,c-have);
    cout<<c<<endl;
    return 0;
}


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

int main() {
    int n;cin>>n;
    int a[n];
    for (int i=0;i<n;i++) {
        int b;cin>>b;
        a[b-1]=i+1;
    }
    for (int i=0;i<n;i++)
        cout<<a[i]<<endl;
    return 0;
}

Measured memory_bytes: 1152
import java.util.*;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    
    int n = sc.nextInt();
    int k = sc.nextInt();
    
    int sum = 0;
    for(int i = 0; i < n ; i++){
      int height = sc.nextInt();
      if(k <= height){
        sum++;
      }
    }
    System.out.println(sum);
  }
}

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

#define rep(i, n) for (ll i = 0; i < n; i++)
#define Rep(i, r, n) for (ll i = r; i < n; i++)
#define pb push_back
#define MOD 1000000007

typedef long long ll;
int main() {
  int n, in;
  int students[100005];
  cin >> n;
  for(int i = 1; i <= n; i++) {
    scanf("%d", &in);
    students[in] = i;
  }
  printf("%d", students[1]);
  for(int i = 2; i <= n; i++) {
    printf(" %d", students[i]);
  }
  printf("\n");
  return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
long long p = 1000000007;
long long x, y, z;
long long rui(long long a,long long b) {
	if (b == 0)return 1;
	if (b == 1)return a;
	if (b == 2)return a * a % p;
	if (b % 2)return rui(rui(a, b / 2), 2) * a % p;
	else return rui(rui(a, b / 2), 2);
}
int main() {
	scanf("%lld%lld", &x, &y);
	if ((x + y) % 3) {
		printf("0\n");
		return 0;
	}
	if (x > 2 * y || y > x * 2) {
		printf("0\n");
		return 0;
	}
	z = (x + y) / 3;
	x -= z;
	y -= z;
	z = 1;
	for (long long i = 1; i <= x + y; i++) {
		z *= i; z %= p;
	}
	for (long long i = 1; i <= x; i++) {
		z *= rui(i, p - 2);
		z %= p;
	}
	for (long long i = 1; i <= y; i++) {
		z *= rui(i, p - 2);
		z %= p;
	}
	printf("%lld\n", z);
}


Measured memory_bytes: 1732
K, A, B = map(int, input().split())

bisc = 1
yen = 0

ans = K + 1

if A >= B:
    print(ans)
    exit()

now = A
K -= (A - 1)
now += (K // 2) * (B - A)
K = K % 2
now += K
print(max(now, ans))

Measured memory_bytes: 9024
#include<stdio.h>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
 
 
using namespace std;
 
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}
 
//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
 
//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
 
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
 
//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
 
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))
 
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//pair sort
bool compare_by_b(pair<LL, LL> a, pair<LL, LL> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

const long long MOD = 1000000007;

void solve(long long N, long long M){
    if(abs(N-M)>1)cout<<0<<endl;
    // else cout<<1<<endl;
    else{
        LL ans=1;
        for(int i=1; i <=N; i++){
            ans = (ans*i)%MOD;
        }

        for(int i=1; i <=M; i++){
            ans = (ans*i)%MOD;
        }
        // cout<<ans*2%MOD<<endl;
        if(N==M)cout<<ans*2%MOD<<endl;
        else cout<<ans<<endl;
    }
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long M;
    scanf("%lld",&M);
    solve(N, M);
    return 0;
}


Measured memory_bytes: 256
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($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, [graph1; $len:expr]) => {{
        let mut g = vec![vec![]; $len];
        let ab = read_value!($next, [(usize1, usize1)]);
        for (a, b) in ab {
            g[a].push(b);
            g[b].push(a);
        }
        g
    }};
    ($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:tt ]) => {{
        let len = read_value!($next, usize);
        read_value!($next, [$t; len])
    }};
    ($next:expr, $t:ty) => ($next().parse::<$t>().expect("Parse error"));
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (let _ = write!(out,$($format)*););
    }
    input! {
        n: usize,
        ab: [(usize1, usize1); n - 1],
    }
    let mut tot: i64 = 0;
    for i in 0..n {
        tot += (i + 1) as i64 * (n - i) as i64;
    }
    for &(a, b) in &ab {
        let (a, b) = if a > b {
            (b, a)
        } else {
            (a, b)
        };
        tot -= (a + 1) as i64 * (n - b) as i64;
    }
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


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

const int d = 60;
const int Mn = 200005;
int to[d][Mn];

vector<ll>visited;
int main(){
  int N; ll K;
  cin >> N >> K;
  rep(i,N){
    cin >> to[0][i];
    to[0][i]--;
  }
  rep(i,d-1){
    rep(j,N){
      to[i+1][j] = to[i][to[i][j]];
    }
  }

  int v = 0;
  for(int i = d-1; i >= 0; i--){
    ll l = 1LL<<i;
    if(K & l){
      v = to[i][v];
    }
  }
  cout << v+1 << endl;
}


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

// definition {{{ 1

// scaning {{{ 2
#define Scd(x) scanf("%d", &x)
#define Scd2(x,y) scanf("%d%d", &x, &y)
#define Scd3(x,y,z) scanf("%d%d%d", &x, &y, &z)

#define Scll(x) scanf("%llu", &x)
#define Scll2(x,y) scanf("%llu%llu", &x, &y)
#define Scll3(x,y,z) scanf("%llu%llu%llu", &x, &y, &z)

#define Scc(c) scanf("%c", &c);
#define Scs(s) scanf("%s", s);
#define Scstr(s) scanf("%s", &s);
// }}} 2

// constants {{{ 2
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
// }}} 2

// systems {{{ 2
#define Rep(x,y) for(int x = 0; x < y; x++)
#define Repe(x,y,z) for(int x = z; x < y; x++)
// }}} 2

// output {{{ 2
#define YesNo(a) (a)?printf("Yes\n"):printf("No\n");
// }}} 2

// }}} 1

int main() {

    int a,b;
    Scd2(a,b);

    bool ans = !(a%3 && b%3 && (a+b)%3);

    printf ("%s\n", ans ? "Possible" : "Impossible");

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    ll i,j,k,m,n;
    cin>>m>>n;
    long double a,b,c,ans=0,cnt=0;
    a=1;
    cnt=(m-n)*100+n*1900;
    for(i=1;i<=n;i++)
        a/=2;
    b=1;
    c=a;
    for(i=1;i<=5000;i++)
    {
        ans+=i*cnt*c*b;
        b*=(1-a);
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//vector<vector<int>> a(5, vector<int>(5, 0)) 5*5-0
int main(){
    bool flag = false;
    int n;
    cin >> n;
    int tmp = 0;
    int a, b;
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if(a == b){
            tmp++;
        }else{
            tmp = 0;
        }
        if(tmp >= 3){
            flag = true;
        }
    }

    if(flag){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3592
#include <stdio.h>

int main(void){
	double a,b,c,d,e,f;
	double x,y;
	
	while(scanf("%lf %lf %lf %lf %lf %lf",&a,&b,&c,&d,&e,&f) != EOF){
		
		x = (c*e - b*f) / (a*e - b*d);
		y = (c*d - a*f) / (b*d - a*e);
		
		//printf("%d %d\n",((int)x*10000)%10,((int)y*10000)%10);
		if(((int)x*10000)%10 > 4) x += 0.001;
		if(((int)y*10000)%10 > 4) y += 0.001;
		
		if(x < 0.0004 && x > -0.0005) x = 0.00001;
		
		printf("%.3f %.3f\n",x,y);
	}
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int MAX_N = 100010;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;
/*------------------------------------------------------------------*/
int main(){
    int n, k; cin >> n >> k;
    vector<int> p(n);
    rep(i, n) cin >> p[i];
    sort(p.begin(), p.end());
    int sum = 0;
    rep(i, k) sum += p[i];
    cout << sum << endl;
}

Measured memory_bytes: 3596
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld  = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5 + 77;

ll a[MAXN];
int n;

int check(int pos) {
	ll cur = 0;

	for(int i = pos; i < n; ++i) {
		cur += a[i];
	}

	for(int i = pos - 1; i >= 0; --i) {
		if(a[i] <= 2 * cur) {
			cur += a[i];
		} else {
			return 0;
		}
	}

	return 1;
}

void solve() {
	cin >> n;

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

	sort(a, a + n);
	reverse(a, a + n);

	if(check(n - 1)) {
		cout << n << '\n';
	} else if(!check(0)) {
		cout << 0 << '\n';
	} else {
		int low = 0, high = n - 1;

		while(high - low > 1) {
			int mid = (low + high) / 2;

			if(check(mid)) {
				low = mid;
			} else {
				high = mid;
			}
		}

		cout << low + 1 << '\n';
	}
}

int main() {
	fast_io();
	solve();

	return 0;
}


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

#define repi(i, a, b) for(int i = (int)(a); i < (int)(b); ++i)
#define rep(i, n) repi(i, 0, n)
#define all(x) (x).begin(), (x).end()

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

using ll = long long;
using P = pair<int, int>;

const int MAX_N = 100 + 10;
const int MAX_V = 1e5 + 10;
const ll  INF   = 1LL << 60;

ll N, W;
ll weight[MAX_N], value[MAX_N];
ll DP[MAX_N][MAX_V];

inline void input() {
  cin >> N >> W;
  rep(i, N) cin >> weight[i] >> value[i];
  rep(i, MAX_N) rep(j, MAX_V) DP[i][j] = INF;
  DP[0][0] = 0;
}

inline void solve() {
  rep(i, N) {
    rep(j, MAX_V) {
      if(j-value[i] >= 0)
        chmin(
          DP[i+1][j],
          DP[i][j-value[i]]+weight[i]
        );

      chmin(
        DP[i+1][j],
        DP[i][j]
      );
    }
  }
}

inline void Main() {
  // code
  input();
  solve();

  ll R = 0;
  rep(i, MAX_V) 
    if(DP[N][i] <= W) R = i;
  cout << R << endl;
}

int main() {
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(20);
  Main();
  return 0;
}


Measured memory_bytes: 86272
n,d = map(int,input().split())
L= []
for i in range(n):
    L.append(tuple(map(int,input().split())))
cnt = 0
for i in range(n-1):
    for j in range(i+1,n):
        dis = 0
        for k in range(d):
            dis += (L[i][k] - L[j][k])**2
        dis = dis**0.5
        if dis%1 == 0:
            cnt +=1
print(cnt)

Measured memory_bytes: 3444
#include<bits/stdc++.h>
#define rep(i,n) for (long long i = 0; i < (n); ++i)
//g++ -std=c++11 

using namespace std;

long long N;
vector<long long> L;

int main(){
	cin >> N;
	rep(i, N) {
		long long tmp;
		cin >> tmp;
		L.push_back(tmp);
	}
	sort(L.begin(), L.end());

	//cout << "item " << endl;
	//for(auto item: L) {
	//	cout << item << endl;
	//}

	long long ans = 0;

	for(long long i = 0; i < N; i++) {
		for(long long j = i + 1; j < N; j++) {
			long long a = L[i];
			long long b = L[j];


			long long start = j;
			long long end = N;

			//minicを探す
			while(start + 1 < end) {
				long long mid = (start + end)/2;
				if(max(a-b, b-a) >= L[mid]) {
					start = mid;
				} else {
					end = mid;
				}
			}
			long long c_minidx = end;


			start = j;
			end = N;

			//maxcを探す
			while(start + 1 < end) {
				long long mid = (start + end)/2;
				if(a+b <= L[mid]) {
					end = mid;
				} else {
					start = mid;
				}
			}
			long long c_maxidx = start;

			//cout << "i = " << i << " j = " << j << " minidx " << c_minidx << " maxidx " << c_maxidx << endl;

			ans += (c_maxidx - c_minidx + 1);


		}
	}
	cout << ans << endl;






}


Measured memory_bytes: 3632
#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))
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
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;
typedef vector<double> vd;
typedef pair<double,double> PD;
typedef pair<int,P> ed;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
const double eps = 1e-10;
  
int main() {
  int N;
  cin >> N;
  auto isfst = [&](int l,int r) {
    return (l+N-r)&1;
  };
  vl A(N);
  rep(i,N) {
    cin >> A[i];
  }
  vv(ll) dp(N,vl(N,0));
  drep(l,N) {
    rep(r,N) {
      if(l>r) continue;
      if(l==r) {
        if(isfst(l,r)) {
          dp[l][r] = A[l];
        } else {
          dp[l][r] = -A[l];
        }
        continue;
      }
      if(isfst(l,r)) {
        dp[l][r] = max(dp[l+1][r]+A[l],dp[l][r-1]+A[r]);
      } else {
        dp[l][r] = min(dp[l+1][r]-A[l],dp[l][r-1]-A[r]);
      }
    }
  }
  cout << dp[0][N-1] << endl;
  return 0;
}

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

int main() {
   int a,b,x,y,z;
   cin>>a>>b;
   x=a+b;
   y=a-b;
   z=a*b;
   if(x>=y and x>=z){
       cout<<x;
   }
   else if(y>=x and y>=z){
       cout<<y;
   }
   else{
       cout<<z;
   }
   return 0;
}



Measured memory_bytes: 256
import java.util.*;

public class Main {

    public static void main(String[] args) {
        // write your code here
        Scanner sc=new Scanner(System.in);
        char c[] = sc.next().toCharArray();
        if(c[2]==c[3]&&c[4]==c[5]){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }




    }
}


Measured memory_bytes: 23892
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
int n;
int main(){
    cin>>n;
    vector<int> p(n,0);
    vector<int> q(n,0);
    vector<int> v(n,0);
    for(int i = 0;i < n; i++){
        v[i]=i+1;
    }
    for(int i=0;i<n;i++){
        cin>>p[i];
    }
    for(int i = 0;i < n; i++){
        cin>>q[i];
    }
    ll a,b;
    int now=0;
    do{
        now++;
        int cnt1=0,cnt2=0;
        for(int i = 0;i < n; i++){
            if(v[i]==p[i]) cnt1++;
            if(v[i]==q[i]) cnt2++;        
        }
        if(cnt1==n) a=now;
        if(cnt2==n) b=now;
    }while(next_permutation(v.begin(),v.end()));
    cout<<abs(a-b)<<endl;
    //N!の順列の全探索
    return 0;
}

Measured memory_bytes: 256
n = int(input())
a,b = map(int,input().split())
l = list(map(int,input().split()))
c = [0]*3
for i in l:
    if i <= a:
        c[0] += 1
    elif i > b:
        c[2] += 1
    else:
        c[1] += 1
print(min(c))

Measured memory_bytes: 9136
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <climits>
#define mk make_pair
#define pb push_back
#define scanf scanf_s
#define printf printf_s
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<ll, ll> pos;
const ll N = 310, MOD = 1000000007;

ll mn(ll a, ll b) {
	if (a == -1)return b;
	if (b == -1)return a;
	return min(a, b);
}

int bb(int v1) {
	if (v1 % 2 == 0)return v1 / 2 - 1;
	else return v1 / 2;
}

ll pw(ll a, ll b) {
	ll v = 1;
	for (; b > 0; b = (b >> 1), a = (a * a) % MOD) {
		if ((b & 1) > 0)v = (v * a) % MOD;
	}
	return v;
}

ll h[N],dp[N][N][N],n,k;

int main() {
	memset(dp, -1, sizeof(dp));
	dp[0][0][0] = 0;
	cin >> n >> k;
	for (int i = 1; i <= n; i++)cin >> h[i];
	for (int i = 0; i < n; i++) {
		for (ll j = 0; j <= k; j++) {
			for (int l = 0; l <= i; l++) {
				if (dp[i][j][l] == -1)continue;
				ll v1 = h[l];
				if (j + 1 <= k && v1!=h[i+1]) {
					dp[i + 1][j + 1][l] = mn(dp[i + 1][j + 1][l], dp[i][j][l]);
				}
				if (v1 != h[i + 1])
					dp[i + 1][j][i + 1] = mn(dp[i + 1][j][i + 1], dp[i][j][l] + max((ll)0, h[i + 1] - v1));
				else
					dp[i + 1][j][i + 1] = mn(dp[i + 1][j][i + 1], dp[i][j][l]);
			}
		}
	}
	ll ans = -1;
	for (int i = 0; i <= k; i++) {
		for (int j = 0; j <= n; j++) {
			ans = mn(ans, dp[n][i][j]);
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 232960
#include <stdio.h>

int main() {
  char s[4];
  int i,price;

  scanf("%s", s);

  price = 700;

  for(i = 0; i < 4; i++){
    if(s[i] == 'o'){
      price += 100;
    }
  }

  printf("%d\n", price);

  return 0;
}


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

using namespace std;

int INF=1e9;

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

    int n,k;
    cin>>n>>k;
    long long ans=0;
    for(int i=k+1;i<=n;i++){
        ans+=(i-k)*(n/i);
        int m=n%i;
        if(k!=0)ans+=max(0,m-k+1);
        else ans+=max(0,m-k);
    }

    cout<<ans<<endl;
}

Measured memory_bytes: 256
# 2020/07/01
# AtCoder Beginner Contest 149 - C

# Input
x = int(input())
slist = [0] * 100005

for i in range(2, 100000):
    if slist[i] == 0:
        j = i + i
        while(j < 100004):
            slist[j] = 1
            j = j + i

sidx = x
while(x < 100004):
    if slist[x] == 0:
        ans = x
        break
    x = x + 1

# Output
print(ans)


Measured memory_bytes: 9656
// #pragma GCC target("avx2")  // CPU 処理並列化
// #pragma GCC optimize("O3")  // CPU 処理並列化
// #pragma GCC optimize("unroll-loops")  // 条件処理の呼び出しを減らす
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<queue>
#include<deque>
#include<stack>
#include<string>
#include<string.h>
#include<vector>
#include<set>
#include<map>
#include<bitset>
#include<stdlib.h>
#include<cassert>
#include<time.h>
#include<bitset>
#include<numeric>
using namespace std;
const long long mod=998244353;
const long long inf=mod*mod;
const long long d2=(mod+1)/2;
const double EPS=1e-10;
const double INF=1e+10;
const double PI=acos(-1.0);
const int C_SIZE = 3121000;
long long fact[C_SIZE];
long long finv[C_SIZE];
long long inv[C_SIZE];
long long Comb(int a,int b){
 	if(a<b||b<0)return 0;
 	return fact[a]*finv[b]%mod*finv[a-b]%mod;
}
void init_C(int n){
	fact[0]=finv[0]=inv[1]=1;
	for(int i=2;i<n;i++){
		inv[i]=(mod-(mod/i)*inv[mod%i]%mod)%mod;
	}
	for(int i=1;i<n;i++){
		fact[i]=fact[i-1]*i%mod;
		finv[i]=finv[i-1]*inv[i]%mod;
	}
}
long long pw(long long a,long long b){
	if(a<0LL)return 0;
	if(b<0LL)return 0;
	long long ret=1;
	while(b){
		if(b%2)ret=ret*a%mod;
		a=a*a%mod;
		b/=2;
	}
	return ret;
}
int ABS(int a){return max(a,-a);}
long long ABS(long long a){return max(a,-a);}
double ABS(double a){return max(a,-a);}
int sig(double r) { return (r < -EPS) ? -1 : (r > +EPS) ? +1 : 0; }
// ここから編集しろ
char in[12];
string str[110000];
int main(){
	int a;scanf("%d",&a);
	for(int i=0;i<a;i++){
		scanf("%s",in);
		std::sort(in,in+10);
		str[i]=in;
	}
	std::sort(str,str+a);
	long long ret=0;
	int cnt=0;
	for(int i=0;i<a;i++){
		if(i==0||str[i]!=str[i-1])cnt=0;
		ret+=cnt;
		cnt++;
	}
	printf("%lld\n",ret);
}

Measured memory_bytes: 5760
#include <iostream>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <cstdio>
#include <utility>
#include <algorithm>
#include <iomanip>
using std::cin;
using std::cout;
using std::endl;

const int MAX_N = 100000;

struct War
{
    int west, east;
    /*bool operator>(const War &another)
    {
        return east > another.east;
    };
    bool operator<(const War &another)
    {
        return east < another.east;
    };*/
};

bool comp(War a, War b)
{
    return a.east < b.east;
}

int main(void)
{
    cout << std::fixed << std::setprecision(10);
    int n, m;
    cin >> n >> m;
    std::vector<War> war;

    int m1, m2;
    War pushed_war;
    for (int i = 0; i < m; i++)
    {
        scanf("%d %d", &m1, &m2);
        pushed_war.west = m1;
        pushed_war.east = m2;
        war.push_back(pushed_war);
    };

    std::sort(war.begin(), war.end(), comp);

    int answer = 0;
    int break_bridge = 0;
    for (int i = 0; i < m; i++)
    {
        War query = war[i];
        if (query.west >= break_bridge)
        {
            break_bridge = query.east;
            answer++;
        }
    }

    cout << answer << endl;

    return 0;
}


Measured memory_bytes: 1400
#include<cstdio>
#include<cstring>
#include<algorithm>

using namespace std;
int main(){
  
  int n,a;
  int s1[201],s2[201];
  
  scanf("%d",&n);
  
  while(n != 0){
    fill(s1,s1+201,0);
    fill(s2,s2+201,1);
    s2[0] = 0;
    int len1 = n;
    int len2 = n;
    int ans1 = 0,ans2 = 0;
    
    for(int i=0;i<n;i++){
      scanf("%d",&a);
      s1[a] = 1;
      s2[a] = 0;
    }
    
    int max = 0;
    
    while(1){
      
      for(int i=max;i<=(2*n);i++){
	if(s1[i] == 1){
	  s1[i] = 0;
	  len1--;
	  max = i;
	  break;
	}
	if(i == 2*n){
	  max = 0;
	  break;
	}
      }
      
      if(len1 == 0){
	break;
      }
      
      for(int i=max;i<=(2*n);i++){
	if(s2[i] == 1){
	  s2[i] = 0;
	  len2--;
	  max = i;
	  break;
	}
	if(i == 2*n){
	  max = 0;
	  break;
	}
      }
      
      if(len2 == 0){
	break;
      }
      
    }
    
    printf("%d\n%d\n",len2,len1);
    scanf("%d",&n);
  }

  return (0);
}

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

int main(){
  long long int w,h;
  cin >> w >> h;
  if(w == 1 || h == 1){
    cout << 1 << '\n';
    return 0;
  }
  if(w * h % 2 == 0){
    cout << w * h / 2 << '\n';
  }else{
    cout << w * h / 2 + 1 << '\n';
  }
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
long a[1<<17], b[1<<17];
int main(){
	long ans=0, N, X, M, t, cnt = 0;
	scanf("%ld%ld%ld", &N, &X, &M);
	t = X;
	while(N){
		if(a[t] > 0)break;
		a[t] = cnt++;
		b[t] = ans;
		ans += t;
		t = t * t % M;
		N--;
	}
	if(N){
		ans += (ans - b[t]) * (N / (cnt - a[t]));
		N %= cnt - a[t];
	}
	while(N--){
		ans += t;
		t = t * t % M;
	}
	printf("%ld\n", ans);
	return 0;
}

Measured memory_bytes: 3188