akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
using namespace std;
using i64 = int64_t;
#define rep(i, j, n) for(int i = (j); i < (n); ++i)
#define rrep(i, j, n) for(int i = (n) - 1; (j) <= i; --i)
constexpr i64 MOD = 1000000007;
constexpr i64 INF = 1LL << 60;

int main() {
	i64 n, a, b; cin >> n >> a >> b;
	double* v = new double[n];
	rep(i, 0, n) cin >> v[i];

	sort(v, v + n);

	i64 maxcnt = 0;
	i64 maxcnt_all = 0;
	double maxave = 0.0;
	rep(i, 0, a) {
		maxave += v[n - 1 - i];
		if (v[n - 1 - i] == v[n - a]) ++maxcnt;
	}
	maxave /= a;

	rep(i, 0, n) if (v[i] == v[n - a]) {
		++maxcnt_all;
	}

	vector<vector<i64>> dp(99, vector<i64>(99, 0));
	dp[0][0] = 1;
	rep(i, 0, 60) 
		rep(j, 0, i + 1) {
		dp[i + 1][j] += dp[i][j];
		dp[i + 1][j + 1] += dp[i][j];
	}

	i64 ans = 0;
	if (maxcnt == a) {
		rep(i, a, min(b, maxcnt_all) + 1) ans += dp[maxcnt_all][i];
	}
	else {
		ans = dp[maxcnt_all][maxcnt];
	}

	cout << fixed << setprecision(10) << maxave << endl;
	cout << ans;

	delete[] v;
	return 0;
}

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

using namespace std;
typedef long long ll;

int main(void) {
  ll x, y;
  cin >> x >> y;

  int ans = 1;
  while (x * 2 <= y) {
    x <<= 1;
    ans++;
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
from operator import itemgetter

n = int(input())

sp = [list(input().split()) for i in range(n)]

for i in range(n):
    sp[i].append(i+1)
    sp[i][1] = int(sp[i][1])

sp.sort(key=itemgetter(1))
sp.reverse()
sp.sort(key=itemgetter(0))

for i in range(n):
    print(sp[i][2])

Measured memory_bytes: 38384
n,m = map(int,input().split())
l = list(map(int,input().split()))
d = {}
each = []
for i in range(m):
	sou,des = map(int,input().split())
	each.append(sou)
	each.append(des)
	if sou not in d:
		d[sou] = [des]
	else:
		d[sou].append(des)
	if des not in d:
		d[des] = [sou]
	else:
		d[des].append(sou)
#print(d)
#print(dic)
count = 0
for i in d:
	flag = True
	for j in d[i]:
		if l[i-1] <= l[j-1]:
			flag = False
			break
	if flag:
		count += 1
count += (n - len(set(each)))
print(count)

Measured memory_bytes: 122244
s=input()
a=list(set(s))
if s.islower()!=True:
  print("No")
else:
  d=dict()
  for i in range(len(a)):
    if a[i].islower:
      d[a[i]]=s.count(a[i])
  b=[i for i in d.values()if i%2==0]
  print("Yes" if len(b)==len(a) else "No")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
#include <string.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919810364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first

int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}

int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int ka[300010];

int c(int x, int y) {
	if (y > x)return 0;
	return ka[x] * mod_pow(ka[x - y], mod - 2, mod) % mod*mod_pow(ka[y], mod - 2, mod) % mod;
}

int n;
vector<int> vec[200010];
int cntdown[200010], ansdown[200010];
int ansup[200010];
int ans[200010];

void dfs(int x, int p) {
	for (int i = 0; i < (int)vec[x].size(); i++) {
		if (vec[x][i] != p) {
			dfs(vec[x][i], x);
			cntdown[x] += cntdown[vec[x][i]];
		}
	}
	int cnt = cntdown[x];
	cntdown[x]++;
	ansdown[x] = 1;
	for (int i = 0; i < (int)vec[x].size(); i++) {
		if (vec[x][i] != p) {
			ansdown[x] *= c(cnt, cntdown[vec[x][i]]);
			ansdown[x] %= mod;
			ansdown[x] *= ansdown[vec[x][i]];
			ansdown[x] %= mod;
			cnt -= cntdown[vec[x][i]];
		}
	}
}

void dfs2(int x, int p) {
	ans[x] = ansup[x] * c(n - 1, n - cntdown[x]) % mod;
	ans[x] *= ansdown[x];
	ans[x] %= mod;
	for (int i = 0; i < (int)vec[x].size(); i++) {
		if (vec[x][i] != p) {
			ansup[vec[x][i]] = ans[x] * mod_pow(c(n - 1, cntdown[vec[x][i]]), mod - 2, mod) % mod*mod_pow(ansdown[vec[x][i]], mod - 2, mod) % mod;
			dfs2(vec[x][i], x);
		}
	}
}

signed main() {
	cin >> n;
	ka[0] = 1;
	for (int i = 1; i <= 300000; i++)ka[i] = ka[i - 1] * i%mod;
	for (int i = 0; i < n - 1; i++) {
		int a, b;
		cin >> a >> b;
		vec[a].push_back(b);
		vec[b].push_back(a);
	}
	ansup[1] = 1;
	dfs(1, 0);
	dfs2(1, 0);
	for (int i = 1; i <= n; i++)cout << ans[i] << endl;
}


Measured memory_bytes: 23280
#include <iostream>
#include <algorithm>

using namespace std;

int main() {
  while(1) {
    int n;
    cin >> n;
    if(n == 0) break;
    int c[26];
    for(int i = 0; i < 26; i++) {
      c[i] = 0;
    }
    bool end = false;
    for(int i = 0; i < n; i++) {
      char in;
      cin >> in;
      c[in - 'A']++;
      bool sam = false;
      int Max = 0;
      int Mid = 0;
      int ind = 0;
      for(int i = 0; i < 26; i++) {
        if(c[i] == Max) sam = true;
        if(c[i] > Max) {
          sam = false;
          Mid = Max;
          Max = c[i];
          ind = i;
        }
        if(c[i] < Max && c[i] > Mid) {
          Mid = c[i];
        }
      }
      if(!end && !sam && (n - i - 1) + Mid < Max) {
        cout << (char)('A' + ind) << " " << (i+1) << endl;
        end = true;
      }
    }
    if(!end) cout << "TIE" << endl;

  }


}

Measured memory_bytes: 3096
N = int(input())
a_list = list(map(int, input().split()))
max_num = max(a_list)
min_num = min(a_list)
result = []
if abs(max_num) >= abs(min_num):
    max_index = a_list.index(max_num)
    for i, a in enumerate(a_list):
        if a < 0:
            a_list[i] += max_num
            result.append((max_index + 1, i + 1))

    for i in range(N - 1):
        if a_list[i] > a_list[i + 1]:
            result.append((i + 1, i + 2))
            a_list[i + 1] += a_list[i]
    print(len(result))
    for v1, v2 in result:
        print(v1, v2)

else:
    min_index = a_list.index(min_num)
    for i, a in enumerate(a_list):
        if a > 0:
            a_list[i] += min_num
            result.append((min_index + 1, i + 1))

    for i in reversed(range(N - 1)):
        if a_list[i] > a_list[i + 1]:
            result.append((i + 2, i + 1))
            a_list[i] += a_list[i + 1]
    print(len(result))
    for v1, v2 in result:
        print(v1, v2)
    exit()


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
int main()
{
	
	double d;int  a,b,c;
	cin>>a>>b;
	c=2*b+1;
	d=1.0*a/c;
	c=a/c;
	if(d-c==0)
	cout<<c;
	else
	cout<<c+1;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <string>
using namespace std;
typedef long long ll;

int main(){
string a,b;
ll c;
cin>>a>>b;
c = a.size();
if(b.substr(0,c)==a){
  cout << "Yes" << endl;
}else{
  cout << "No" << endl;
  }
}

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

int k;

void bfs(){
    int cnt = 0;
    queue<string> q;
    for(int i = 1; i <= 9; i++){
        q.push(string(1, '0' + i));
        //cout << "pushed: " << string(1, '0' + i) << endl;
    }
    while(!q.empty()){
        string seq = q.front();
        //cout << "seq = " << seq << endl;
        q.pop();
        cnt++;
        if(cnt == k){
            cout << seq << endl;
            return;
        }
        int last = seq.back() - '0';
        //cout << "last = " << seq << endl;
        for(int i = max(0, last-1); i <= min(9, last+1); i++){
            string next = seq;
            //cout << "i = " << i  << "next = " << next << endl;
            next += '0' + i;
            q.push(next);
            //cout << "added: " << next << endl;
        }
    }
}

int main(){
    cin >> k;
    bfs();
    return 0;
}

Measured memory_bytes: 13696
abc = list(map(int, input().split()))

abc.sort()
def calc(a, b):
    if (a + b) % 2 == 0:
        return (b - a) // 2
    else:
        return -(-(b - a) // 2) + 1


print(calc(abc[0], abc[1]) + (abc[2] - abc[1]))

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

int main(void){
    int d;
    cin >> d;
    vector<int> c(26);
    for (int i = 0; i < 26; i++) cin >> c.at(i);
    
    vector<vector<int>> s (d, vector<int> (26));
    for(int j = 0; j < d; j++) for(int i = 0; i < 26; i++) cin >> s.at(j).at(i);
    
    int score = 0;
    vector<int> last(26,-1);
    
    for(int i = 0; i < d; i++) {
        int mx = 0;
        for(int j = 0; j < 26; j++) {
         mx = max(mx,s.at(i).at(j));
        }
        score += mx;
        
        int select;
        for(int j = 0; j < 26; j++) {
         if (mx == s.at(i).at(j)) select = j;
        }  
        last.at(select) = i;
        for(int j = 0; j < 26; j++) {
         score -= c.at(j) * (i - last.at(j));
        }
        cout << select + 1 << endl;
    }
}


Measured memory_bytes: 3676
#include <iostream>
#include <iomanip>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
using namespace std;

int main(){
    long long N, Q;
    cin >> N >> Q;
    vector<long long> A(N), X(Q);
    for(int i=0; i<N; i++) cin >> A[i];
    for(int i=0; i<Q; i++) cin >> X[i];

    vector<long long> B(N+1);
    for(int i=0; i<N; i++)
        B[i+1] = B[i] + A[i];

    vector<long long> C(N+1);
    if(N%2==1){
        for(int i=0; i<N; i++){
            C[i+1] = C[i];
            if(i%2==0) C[i+1] += A[i];
        }
    }else{
        for(int i=0; i<N; i++){
            C[i+1] = C[i];
            if(i%2==1) C[i+1] += A[i];
        }
    }

    for(auto x : X){
        double lb = 0;
        double ub = 1e9;
        for(int i=0; i<100; i++){
            double mid = (lb+ub)/2;
            auto a = lower_bound(A.begin(), A.end(), x-mid);
            auto b = lower_bound(A.begin(), A.end(), x+mid);
            long long aok = b-a;
            long long tak = A.end()-b;
            if(aok > tak) ub = mid;
            else lb = mid;
        }
        long long idx = lower_bound(A.begin(), A.end(), x+lb) - A.begin();

        long long ans = B[N] - B[idx];

        if(2*idx-N>=0)
            ans += C[2*idx-N];

        cout << ans << endl;
    }


    return 0;
}

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

typedef pair<vector<int>, int> P;

priority_queue<P> pq[20];

int f[50010][4];

map<vector<int>, int> mp;
vector<vector<int>> zyun;
int n, k;
void load(int x){
	for(int i = 0;i < zyun.size();i++){
		vector<int> tmp;
		for(int j = 0;j < k;j++){
			tmp.push_back(f[x][zyun[i][j]]);
		}
		pq[i].push({tmp, x});
	}
}

vector<int> graph[50010];
int ydk[50010];

vector<int> e[50010];
int m[50010];

int used[50010];


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


	{
		vector<int> vec(k);
		for(int i = 0;i < k;i++){
			vec[i] = i;
		}
		
		int cnt = 0;
		do{
			zyun.push_back(vec);
			mp[vec] = cnt;
			cnt++;
		}while(next_permutation(vec.begin(), vec.end()));
	}

	for(int x = 0;x < n;x++){
		for(int j = 0;j < k;j++){
			cin >> f[x][j];
		}
	}

	int d;
	cin >> d;

	for(int i = 0;i < d;i++){
		int a, b; cin >> a >> b;
		a--; b--;
		graph[a].push_back(b);
		ydk[b]++;
	}

	int r;
	for(int i = 0;i < k;i++){
		int t; cin >> t;
		e[0].push_back(t-1);
	}

	cin >> r;
	for(int j = 0;j < r;j++){
		cin >> m[j+1];
		for(int i = 0;i < k;i++){
			int t; cin >> t;
			e[j+1].push_back(t-1);
		}
	}
	r++;
	m[r] = n;

	for(int i = 0;i < n;i++){
		if(ydk[i] == 0) load(i);
	}

	int now = mp[e[0]];

	vector<int> ans;
	int fi = 0;
	int p = 0;
	for(int x = 0;x < n;x++){
		int idx;
		while(1){
			idx = pq[now].top().second;
			pq[now].pop();
			if(used[idx] == 0){
				break;
			}
		}

		ans.push_back(idx+1);
		used[idx] = 1;

		for(auto p : graph[idx]){
			ydk[p]--;
			if(ydk[p] == 0){
				load(p);
			}
		}

		fi++;
		if(m[p+1] == fi){
			p++;
			now = mp[e[p]];
		}
	}

	for(auto p : ans){
		cout << p << endl;
	}

		
	return 0;
}
	

		


Measured memory_bytes: 83732
#include <iostream>
#include <string>
 
using namespace std;
 
int main(){
     int N,r=0,b=0;
     cin >> N;
     char s[N];
     cin >> s;
    
    
     for(int i=0;i<N;i++){
          if(s[i] == 'R')
            r++;
          else
            b++;
          }
 
     if(r>b)
       cout << "Yes"<< endl;
     else
       cout << "No" << endl;
     
 
     return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<cstdio>
using namespace std;
int main()
{
    long long int i,j,k,n,m,x,y,t=0,gc;
//    string s;
  vector<long long int>v,u;

    cin>>n>>k;
    v.push_back(k);
    for(i=0;i<n;i++)
    {
        cin>>x;
        v.push_back(x);
    }
    sort(v.begin(),v.end());
    for(i=1;i<=n;i++)
    {
        u.push_back(abs(v[i]-v[i-1]));
    }
    gc=u[0];
    for(i=1;i<n;i++)
    {
        gc=__gcd(gc,u[i]);

    }
    cout<<gc<<endl;

    return 0;
}


Measured memory_bytes: 2548
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var arr= input.trim().split("\n");
while(true){
   var gymd = arr.shift();
   if(gymd=="#")break;
   var [g, y, m, d]=gymd.split(" ");
   [y,m,d]=[y-0,m-0,d-0];
   if(y<=30 || y==31 && m<=4)console.log(gymd);
   else {
      y=y-30;
      console.log("? "+y+" "+m+" "+d);
   }
}


Measured memory_bytes: 18212
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	public static void main(String[] args)
	{
		Scanner stdIn = new Scanner(System.in);
		
		int n = stdIn.nextInt();
		
		boolean[] hantei = new boolean[52];
		Arrays.fill(hantei,false);
		
		String pattern;
		int number;
		
		for(int i=0;i<n;i++)
		{
			pattern = stdIn.next();
			number = stdIn.nextInt();
			
			if(pattern.equals("S"))
			{
				hantei[number-1] = true;
			}
			else if(pattern.equals("H"))
			{
				hantei[13+number-1] = true;
			}
			else if(pattern.equals("C"))
			{
				hantei[26+number-1] = true;
			}
			else
			{
				hantei[39+number-1] = true;
			}
			
		}
		
		for(int i=0;i<52;i++)
		{
			if(!hantei[i])
			{
				if(i<13)
				{
					System.out.println("S "+(i+1));
				}
				else if(i<26)
				{
					System.out.println("H "+(i-12));
				}
				else if(i<39)
				{
					System.out.println("C "+(i-25));
				}
				else
				{
					System.out.println("D "+(i-38));
				}
			}
		}
	}
}

Measured memory_bytes: 18048
// clang-format off
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rep1(i,n) for(ll i=1, i##_len=(n); i<=i##_len; ++i)
#define rrep(i,n) for(ll i=n-1; i>=0; --i)
#define rrep1(i,n) for(ll i=n; i>0; --i)
#define all(x) (x).begin(),(x).end()
#define SORT(x) sort(all(x))
#define SORT_DESC(x) sort(all(x), greater<>())
#define pb push_back
#define mp make_pair
#define coutl cout<<fixed<<setprecision(10)
#define ANS(ans) cout<<ans<<endl;
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;}
const int INF = 1e9;
const ll LINF = 1e18;
// clang-format on

void solve(std::string S, std::string T) {
  ANS(T << S);
}

int main() {
  std::string S;
  std::cin >> S;
  std::string T;
  std::cin >> T;
  solve(S, T);
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <map>
#include <functional>
#include <cassert>
#include <utility>
#include <stack>
#include <queue>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
typedef pair<int,int> Pi;
typedef long long int ll;
const int INF=(ll)(1<<30)-1;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a, b)*b;}


int n,k;
int a[100100];

int main(){
	cin>>n>>k;
	int max=0;
	REP(i,n){
		cin>>a[i];
		max=max(max,a[i]);
	}
	int t=a[0];
	for(int i=1;i<n;i++)
		t=gcd(t,a[i]);
	if(k%t==0&&max>=k){
		cout<<"POSSIBLE"<<endl;
	}else{
		cout<<"IMPOSSIBLE"<<endl;
	}
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <vector>
using namespace std;
using ll = long long;

const ll LLINF = 1e16;

int main() {
    int N, W;
    cin >> N >> W;
    vector<ll> w(N), v(N);
    for(int i = 0; i < N; i++) cin >> w[i] >> v[i];

    vector<vector<ll>> dp(N+1, vector<ll>(1e5+1, LLINF));
    dp[0][0] = 0;
    for(int i = 0; i < N; i++) {
        for(int j = 0; j < 1e5+1; j++) {
            dp[i+1][j] = min(dp[i+1][j], dp[i][j]);
            if(j + v[i] < 1e5+1) dp[i+1][j+v[i]] = min(dp[i+1][j+v[i]], dp[i][j] + w[i]);
        }
    }

    ll ans = -LLINF;
    for(int i = 0; i < 1e5+1; i++) {
        if(dp[N][i] <= W) ans = max(ans, (ll)i);
    }

    cout << ans << endl;

    return 0;
}

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

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

    for(int i = 0; i < H + 2; i++){
        for(int j = 0; j < W + 2; j++){
            if(i == 0 || i == H + 1 || j == 0 || j == W + 1){
                cout << "#";
            }else if(i != 0 && i != H + 1 && j == 1){
                cin >> a.at(i-1);
                cout << a.at(i-1);
            }
        }
        cout << endl;
    }
}


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

#define ll long long 
#define inf 0x3f3f3f3f
#define infll 0x3f3f3f3f3f3f3f3f
#define all(x) (x).begin(),(x).end()
#define f(i, a, b) for (int i=a; i<(signed)(b); ++i)
#define pc __builtin_popcount // counts number of 1's in bin(num)
#define pb push_back
#define mp make_pair

const double pi = 2*acos(0.0);
//__gcd(n1, n2);
//cout << fixed;
//cout << setprecision(6); //fixes # of dp
//tgamma(i+1) is 1!
void solve(){
    int n, m;
    cin >> n >> m;
    int items[n];
    int summ = 0;
    f(i,0,n){
        cin >> items[i];
        summ += items[i];
    }
    sort(items,items+n,greater<int>());
    int index = m-1;
    cout << (items[index]*4*m>=summ ? "Yes" : "No");
}

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








Measured memory_bytes: 256
n = gets.to_i
a = gets.split.map &:to_i
b = gets.split.map &:to_i
c = gets.split.map &:to_i
d = -1
s = 0
(0...n).each do |i|
  s += b[a[i]-1]
  s += c[d-1] if d+1 == a[i]
  d = a[i]
end
p s

Measured memory_bytes: 1788
S = input()
A = int(S[:2])
B = int(S[2:])
if 0<A<=12 and 0<B<=12:
    print("AMBIGUOUS")
elif 0< A <= 12:
    print("MMYY")
elif 0 < B <= 12:
    print('YYMM')
else:
    print("NA")

Measured memory_bytes: 3060
#include <iostream>

int main(){
  int n, a, ma = -1000001, mi = 1000001;
  long long int sum = 0;
  std::cin >> n;

  for(int i = 0; i < n; i++){
    std::cin >> a;
    mi = std::min(mi, a);
    ma = std::max(ma, a);
    sum += a;
  }
  std::cout << mi << " " << ma << " " << sum << std::endl;

  return 0;
}



Measured memory_bytes: 3088
import sys

alnum = ord('z') - ord('a') + 1
res = [0] * alnum

for line in sys.stdin:
    instr = line.lower()

    for s in instr:
        if s.isalpha():
            relc = ord(s) - ord('a')
            res[relc] += 1

for i in range(alnum):
    print("{0} : {1}".format(chr(i + ord('a')), res[i]))



Measured memory_bytes: 5568
/*
   PALLAV TOTAWAT
   IIT(BHU) VARANASI
   ELECTRONICS ENGG.
*/

#include<bits/stdc++.h>

#define pii pair<int,int>
#define pll pair<long long,long long>
#define pli pair<long long,int>
#define pil pair<int,long long>
#define ll long long 
#define fl(n) for(int i{0};i!=n;++i)
#define vi vector<int>
#define vll vector<long long>
#define mll map<long long,long long>
#define mii map<int,int>
#define mli map<long long,int>
#define mil map<int,long long>
#define mp make_pair
#define pb push_back
#define pf push_front

using namespace std;

int main()
{
   ios_base::sync_with_stdio(false);
   cin.tie(0);
   int n;
   cin>>n;
   priority_queue<ll,vll,greater<int> > pu;
   priority_queue<ll> pd;
   vll v(3*n);
   fl(3*n)
       cin>>v[i];
   ll topu,topd,sumu=0,sumd=0;
   vll maxim(n+1),minim(n+1);
   fl(n)
   {
       sumu+=v[i];
       sumd+=v[3*n-1-i];
       pu.push(v[i]);
       pd.push(v[3*n-1-i]);
   }
   maxim[0]=sumu;
   minim[0]=sumd;
   fl(n)
   {
       sumu+=v[n+i];
       pu.push(v[n+i]);
       topu=pu.top();
       pu.pop();
       sumu-=topu;
       maxim[i+1]=sumu;
       
       sumd+=v[2*n-i-1];
       pd.push(v[2*n-i-1]);
       topd=pd.top();
       pd.pop();
       sumd-=topd;
       minim[i+1]=sumd;
   }
   fl(n+1)
   maxim[i]-=minim[n-i];
   cout<<*max_element(maxim.begin(),maxim.end());
}


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

int main(){
  string S,T;
  cin >> S >> T;
  
  int num = S.size();
  
  bool flag = true;
  
  for(int i=0; i < num ; i++){
    if(S.at(i) != T.at(i)){
      flag = false;
    }
  }
  
  if(flag){
    cout << "Yes" << endl;
  }
  else{
    cout << "No" << endl;
  }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
int main() {
    long long k,a,b;
    scanf("%lld%lld%lld",&k,&a,&b);
    long long ans=1;
    if(b-a<=2||(k+1)<a) {
        printf("%lld\n",k+1);
    }
    else {
        if(a>1) {
            k-=(a-1);
        }
        ans=a;
        if(k%2==0) {
            ans+=(k/2)*(b-a);
        }
        else {
            ans+=(k/2)*(b-a)+1;
        }
        printf("%lld\n",ans);
    }
}


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

const int INF=0x7fffffff;
const int maxn=2005;
int n,a[maxn<<1],t,dp[maxn][maxn],f[maxn<<1][maxn<<1];
char ch[10];

int cal(int x,int b,int w) 
{
	return f[x][b]-f[x-1][b]+f[x][w]-f[x][n]-f[x-1][w]+f[x-1][n];
}

int main() 
{
	
	scanf("%d",&n);
	for(int i=1; i<=n<<1; i++) 
	{
		scanf("%s",&ch);
		scanf("%d",&a[i]);
		if (ch[0]=='W') a[i]+=n;
		for (int j=1; j<i; j++)
			f[a[j]][a[i]]=1;
	}
	
	for (int i=1; i<=n<<1; i++)
		for (int j=1; j<=n<<1; j++)
			f[i][j]+=f[i-1][j]+f[i][j-1]-f[i-1][j-1];
			
	memset(dp,0x7f,sizeof(dp));
	dp[0][0]=0;
	for (int i=0; i<=n; i++) 
	{
		for (int j=0; j<=n; j++) 
		{
			if(i==0 && j==0) continue;
			dp[i][j]=min(i?dp[i-1][j]+cal(i, i, j+n):INF,j?dp[i][j-1]+cal(j+n, i, j+n):INF);
		}
	}
	printf("%d\n", dp[n][n]);
	return 0;
}

Measured memory_bytes: 78720
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	const double eps=1e-11;
	static void Main(){
		Sc sc=new Sc();
		var s=sc.Ia;
		var t=sc.S;
		int p=0;
		var h=new int[s[0]];
		StringBuilder sb=new StringBuilder();
		for(int i = s[0]-1;i>=0&&p<s[1];i--) {
			if(t[i]=='o'){
				p++;
				h[i]=s[1]-p+1;
				i-=s[2];
			}
		}
		p=0;
		for(int i = 0;i<s[0]&&p<s[1];i++) {
			if(t[i]=='o'){
				p++;
				if(h[i]==p){sb.Append((i+1)+"\n");}
				i+=s[2];
			}
		}
		Console.Write(sb);
	}
}
public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public double[] Da2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),double.Parse);}}
	public double[] Da3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),double.Parse);}
	public double[] Da3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),double.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 22992
#include <stdio.h>
int main(){
	long long int a, min;
	scanf("%lld", &a);
	min = a-1;
	for(int i = 1; i < 1123456; ++i){
		if(a%i == 0){
			long long temp = (a/i + i - 2);
			min = min > temp ? temp: min;
		}
	}
	printf("%lld\n", min);
}

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

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, a, b) for (int (i) = (a); (i) <= (b); (i)++)
#define ROF(i, a, b) for (int (i) = (a); (i) >= (b); (i)--)
#define REP(i, n) FOR(i, 0, (n)-1)
#define sqr(x) ((x) * (x))
#define all(x) (x).begin(), (x).end()
#define reset(x, y) memset(x, y, sizeof(x))
#define uni(x) (x).erase(unique(all(x)), (x).end());
#define BUG(x) cerr << #x << " = " << (x) << endl
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define _1 first
#define _2 second

const int maxn = 112345;

int n;
pair<ll, pair<ll, ll>> val[maxn];

int main() {
    scanf("%d", &n);
    FOR(i, 1, n) {
        ll a, b;
        scanf("%lld%lld", &a, &b);
        val[i] = mp(a + b, mp(a, b));
    }
    sort(val + 1, val + n + 1, greater<pair<ll, pair<ll, ll>>>());
    ll ans = 0;
    FOR(i, 1, n) {
        if (i & 1) ans += val[i]._2._1;
        else ans -= val[i]._2._2;
    }
    printf("%lld", ans);
}

Measured memory_bytes: 2560
#include <stdio.h>
int main(void){
    
    int i,n,tmp;
    scanf("%d",&n);
    int a[n];
    
    for (i=0; i<n; i++){
        scanf("%d",&a[i]);
    }
    
    for(i=0; i<n/2; i++){
        tmp =a[i];
        a[i] =a[n-1-i];
        a[n-1-i] =tmp;
    }
    
    for(i=0; i<n; i++){
    if(i)printf(" ");
    printf("%d",a[i]);
    }
    printf("\n");
    

    return 0;
}



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

// #define int long long
#define rep(i, n) for (long long i = (long long)(0); i < (long long)(n); ++i)
#define reps(i, n) for (long long i = (long long)(1); i <= (long long)(n); ++i)
#define rrep(i, n) for (long long i = ((long long)(n)-1); i >= 0; i--)
#define rreps(i, n) for (long long i = ((long long)(n)); i > 0; i--)
#define irep(i, m, n) for (long long i = (long long)(m); i < (long long)(n); ++i)
#define ireps(i, m, n) for (long long i = (long long)(m); i <= (long long)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) long long(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;
using vtp = vector<tuple<ll,ll,ll>>;
using vb = vector<bool>;

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

const ll INF = 1e9;
const ll MOD = 1e9+7;
const ll LINF = 1e18;



signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  map<ll,ll> m;
  vll a(n);
  rep(i,n){
    cin>>a[i];
    m[a[i]]++;
  }
  ll sum=0;
  for(auto e: m){
    if(e.second<2) continue;
    sum+=e.second*(e.second-1)/2;
  }
  rep(i,n){
    if(m[a[i]]<2) cout<<sum<<endl;
    else{
      ll cnt=m[a[i]];
      cout<<sum-cnt*(cnt-1)/2+(cnt-1)*(cnt-2)/2<<endl;
    }
  }
  
}

Measured memory_bytes: 11136
using namespace std;

using uint = unsigned int;
using ll = long long;
using ull = unsigned long long;
#include <iostream>
#include <string>
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <climits>
#include <bitset>
#include <array>
#include <deque>
#include <queue>
#define all(x) (x).begin(),(x).end()

void solve(){

}
int getQuot(int n, int d){
    int ret = 0;
    int i = 0;
    while(ret > n){
        i++;
        ret = d * i;
    }
    return i;
}

int main(){
    ll N;
    cin >> N; 
    vector<int> ans;
    int q = N;
    if (q == 0) {
        cout << 0 << endl;
        exit(0);
    }
    while(q != 1){
        int r = 0;
        if (q > 0){
            r = q % (-2);
            q = q / (-2);
        }else {
            r = abs(q % 2);
            //q = -1 * ((abs(q) + 2 - 1) / 2);
            q = getQuot(q,-2);
        }
        ans.push_back(r);
    }

    ans.push_back(1);
    for (int i = (int)ans.size()-1; i >= 0; --i){
        cout << ans[i];
    }
    cout << endl;
        //商を求める
        //余りを求める

    return 0;
}


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

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

using namespace std;

int main() {

    ll n,m; cin >> n >> m;
    ll ans = 0;
    pair<ll,ll> p[100001];
    rep(i,n) {
        cin >> p[i].first >> p[i].second;
    }
    sort(p,p+n);

    rep(i,n){
        while(p[i].second != 0 && m != 0){
            ans += p[i].first;
            p[i].second --;
            m --;
        }
    }

    cout << ans;

    return 0;
}











Measured memory_bytes: 5148
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll ans = 1, tmp = k;
    while(n > tmp-1){
    	tmp *= k;
    	ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {	
	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
		int N = fs.nextInt();
		int M = fs.nextInt();
		
		System.out.println(N*(N-1)/2+M*(M-1)/2);
		

	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");

		public String next() {
			while (!st.hasMoreElements())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}

		public int nextInt() {
			return Integer.parseInt(next());
		}

		public long nextLong() {
			return Long.parseLong(next());
		}

		public int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) {
				a[i]=nextInt();
			}
			return a;
		}

		public double nextDouble() {
			return Double.parseDouble(next());
		}

	}
	
}


Measured memory_bytes: 21076
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

    long int ans = 0;
    for (int i = 1; i < N; i++)
    {
        ans += i;
    }

    cout << ans << endl;
    
    /*
    vector<int> vec(N);

    vec.at(0) = N;
    for (int i = 1; i < N; i++)
    {
        vec.at(i) = i;
    }

    long int ans = 0;

    for (int i = 0; i < N; i++)
    {
        ans += vec.at(i) % (i+1);
    }

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

    for (int i = 0; i < N; i++)
    {
        cout << i+1 << " ";
    }
    
    //cout << ans << endl;
    */

}


Measured memory_bytes: 256
<?php

fscanf(STDIN, '%d', $n);

for ($i = 0; $i < $n; $i++) {
    fscanf(STDIN, '%f %f %f %f %f %f %f %f', $x1, $y1, $x2, $y2, $x3, $y3, $x4, $y4);
    $ab = INF;
    if ($x2 - $x1 !== 0.0) {
        $ab = ($y2 - $y1) / ($x2 - $x1);
    }
    $cd = INF;
    if ($x4 - $x3 !== 0.0) {
        $cd = ($y4 - $y3) / ($x4 - $x3);
    }

    echo $ab === $cd ? 'YES' : 'NO';
    echo PHP_EOL;
}

Measured memory_bytes: 6560
#include<stdio.h>
#include<math.h>
int main()
{
  long long int n,i,j;
  scanf("%lld",&n);
  for ( i= -200; i <= 200; i++) {
        for ( j = -200; j <= 200; j++) {
            if(pow(i, 5) - pow(j, 5) == n){
                printf("%lld %lld\n",i,j);
                return 0;}
        }
  }
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
//#define fisier 1
using namespace std;
typedef long long ll;
const double dancila = 3.14159265359;

int main(){
	#ifdef fisier
        ifstream cin("input.in");
        ofstream cout("output.out");
    #endif	
		
	ios_base::sync_with_stdio();
	cin.tie(0);
		
	int N;
	cin >> N;
	for(int i=1;i<=N;++i)
	{
		int a;
		cin >> a;
		if (a % 2 == 0)
		{
			if (a % 3 != 0 && a % 5 != 0)
			{
				cout << "DENIED" << endl;
				return 0;
			}
		}
	}
	cout << "APPROVED" << endl;
}



Measured memory_bytes: 256
import math

N, K = map(int, input().split())
h = list(map(int, input().split()))
dp = [float('INF')] * (10**5 + 10)

def chmin(a, b):
    if a >= b:
        return b
    else:
        return a

dp[0] = 0 #初期値 = 0
for i in range(N-1):
    for j in range(K+1):
        if i+j < N:
            dp[i+j] = chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]))
print(dp[N-1])

Measured memory_bytes: 55520
#include <bits/stdc++.h>
using namespace std;
int n; long long a[10009];
int main() {
	cin >> n;
	for(int i = 0; i < n; i++) cin >> a[i];
	sort(a, a + n);
	if(a[0] >= 2) {
		cout << 1 << endl;
	}
	else {
		long long sum = 1; bool flag = false;
		for(int i = 1; i < n; i++) {
			if(sum + 1 < a[i]) {
				cout << sum + 1 << endl;
				flag = true; break;
			}
			sum += a[i];
		}
		if(!flag) cout << sum + 1 << endl;
	}
}

Measured memory_bytes: 3220
#include <iostream>
#include <string>
using namespace std;
int main(){
    string S[3]; cin >> S[0] >> S[1] >> S[2];
    int p = 0;
    while(!S[p].empty()) {
        char t = S[p].front();
        S[p].erase(0, 1);
        p = t-'a';
    }
    cout << (p==0?"A":p==1?"B":"C");
}

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

int main() {
    int K, S;
    cin >> K >> S;

    int res = 0;
    for (int x = 0; x <= K; x++) {
        for (int y = 0; y <= K; y++) {
            int z = S - (x + y);
            if (z <= K && z >= 0) {
                res++;
            }
        }
    }

    print(res);

    return 0;
}

Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<cstdio>
#include<type_traits>
#include<numeric>
#include<limits>
#include<iomanip>
#include<set>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

//define
#define INF 100000000
#define NUM 1000000007


int main() {
	int a, b, c;
	cin >> a >> b >> c;

	if ((b - a) == (c - b)) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cstdio>
#include <string>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long int ll;
#define all(x) x.begin(),x.end()
int main()
{
  int N;
  cin >> N;
  int H[N][3];
  int dp[N][3];
  for (int i = 0; i < N; ++i) {
    cin >> H[i][0] >> H[i][1] >> H[i][2];
    }
  dp[0][0] = H[0][0];
  dp[0][1] = H[0][1];
  dp[0][2] = H[0][2];
  for (int i = 1; i < N; ++i) {
    int a = H[i][0];
    int b = H[i][1];
    int c = H[i][2];
    dp[i][0] = max( dp[i-1][1]+a, dp[i-1][2]+a);
    dp[i][1] = max( dp[i-1][0]+b, dp[i-1][2]+b);
    dp[i][2] = max( dp[i-1][0]+c, dp[i-1][1]+c);
  }
  cout << max({dp[N-1][0], dp[N-1][1], dp[N-1][2]}) << "\n";

  return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <limits>
#include <bitset>
#include <map>

using namespace std;

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

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
    IoSetup() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(20);
    }
} iosetup;

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

signed main() {
    int N; cin >> N;
    
    map<string, ll> m;

    rep(i, N) {
        string S;
        cin >> S;
        sort(all(S));
        m[S]++;
    }
    ll ans = 0;

    for (auto a : m) {
        int count = a.second;
        ans += (a.second) * (a.second - 1) / 2;
    }

    cout << ans << endl;

}
 

Measured memory_bytes: 11264
#include <iostream>
#include <cstdio>
using namespace std;
int main(){
	long long N,ans = 0;
	scanf("%lld",&N);
	ans += (N/11)*2;
	if(N%11 > 6){
		ans += 2;
	}else if(N%11 > 0){
		ans++;
	}
	printf("%lld\n",ans);
	return 0;
}


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

int p[70000], j[70000];
signed main() {
	int n;
	while (scanf("%lld", &n), n) {
		rep(i, n)scanf("%lld", &p[i]);
		rep(i, n - 1)scanf("%lld", &j[i]);
		sort(j, j + n - 1, greater<>());
		int s = accumulate(p, p + n, 0), Max = 0;
		rep(i, n) {
			Max = max(Max, s*(n - i));
			if (i < n - 1)s += j[i];
		}
		printf("%lld\n", Max);
	}
}

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

int main()
{
    while (1)
    {
        int x, y;
        cin >> x >> y;
        if (x == 0 && y == 0)
            break;
        if (x > y)
        {
            swap(x, y);
        }
        cout << x << " " << y << endl;
    }
}


Measured memory_bytes: 3068
n, q = map(int,input().split())
s = input()


a = [0] * (n + 1)

# n文字目までにACが出た回数を累積和で求める
for i in range(n):
  a[i + 1] = a[i] + (1 if s[i:i + 2] == 'AC' else 0)

for i in range(q):
  l, r = map(int, input().split())
  print(a[r - 1] - a[l - 1])



Measured memory_bytes: 9540
n = int(input())
L = list(map(int,input().split()))
L.sort()

ans = 0
for i in range(1,n-1):
  for j in range(i):
    if L[n-1] - L[i]-L[j] < 0:
      ans += (n-1) - (i+1) + 1
      continue
    elif L[i+1] - L[i]-L[j] >= 0:
      continue
    l = i+1
    r = n-1
    while abs(r-l) > 1:
      mid = (l+r)//2
      if L[i]+L[j] - L[mid]> 0:
        l = mid
      else:
        r= mid
    ans += l-(i+1)+ 1
print(ans)


Measured memory_bytes: 42844
N = int(input())

ans = ['a']
for i in range(N-1):
    tmp = []
    for s in ans:
        m = max(s)
        j = ord(m) - ord('a') + 1
        for k in range(j+1):
            tmp.append(s + chr(ord('a') + k))
    ans = tmp
print(*ans, sep='\n')

Measured memory_bytes: 14788
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int x;
  cin >> x;
  int sum = 0;
  for (int i = 1; i <= x; i++) {
	sum += i;
	if (sum >= x) {
	  cout << i << endl;
	  return 0;
	}
	
  }
  return 0;
}



Measured memory_bytes: 256
using static System.Math;
using System.Linq;
using System.Collections.Generic;
using System;

public class P
{
    public int x { get; set; }
    public int y { get; set; }
}

public class hello
{
    public static void Main()
    {
        string[] line = Console.ReadLine().Trim().Split(' ');
        var h = int.Parse(line[0]);
        var w = int.Parse(line[1]);
        var ps = new List<P>();
        for (int i = 0; i < h; i++)
        {
            var s = Console.ReadLine().Trim();
            for (int j = 0; j < w; j++)
                if (s[j] == 'B') ps.Add(new P { x = i, y = j });
        }
        getAns(ps);
    }
    static void getAns(List<P> ps)
    {
        var res = 0;
        var psc = ps.Count();
        for (int i = 0; i < psc - 1; i++)
            for (int j = i + 1; j < psc; j++)
                res = Max(res, Abs(ps[i].x - ps[j].x) + Abs(ps[i].y - ps[j].y));
        Console.WriteLine(res);
    }
}



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

public class Main {
    public static void main(String[] args) {
        Scanner itr = new Scanner(System.in);
        int N = itr.nextInt();
        int[][] ac = new int[N][3];

        for (int i = 0; i < N; i++) {
            for (int j = 0; j < 3; j++) {
                ac[i][j] = itr.nextInt();
            }
        }

        int[][] dp = new int[N][3];
        dp[0][0] = ac[0][0];
        dp[0][1] = ac[0][1];
        dp[0][2] = ac[0][2];

        for (int i = 1; i < N; i++) {
            dp[i][0] = Math.max(dp[i - 1][1] + ac[i][0], dp[i - 1][2] + ac[i][0]);
            dp[i][1] = Math.max(dp[i - 1][0] + ac[i][1], dp[i - 1][2] + ac[i][1]);
            dp[i][2] = Math.max(dp[i - 1][0] + ac[i][2], dp[i - 1][1] + ac[i][2]);
        }

        int res = dp[N - 1][0];
        for (int i = 1; i <= 2; i++) {
            res = Math.max(res, dp[N - 1][i]);
        }

        System.out.println(res);
    }
}

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

int main(void)
{
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    
    while (a>=0 && c>=0){
        c = c-b; //高橋くんの攻撃
        if(c<=0 && a>0){//青　負け
            cout << "Yes" << endl;
            break;
        }
        a = a-d; //青木くんの攻撃
        if(a<=0 && c>0){//高橋負け
            cout << "No" << endl;
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 3636
import sys
input = sys.stdin.readline

import numpy as np

INF = 10 ** 18

N, W = map(int, input().split())
lst = np.array([0] + [INF] * (10 ** 5 + 9), dtype = np.int64)
for _ in range(N):
    w, v = map(int, input().split())
    lst[v:] = np.minimum(lst[v:], lst[:10 ** 5 + 10 -v] + w)
    lst[1:v] = np.minimum(lst[1:v], w)

# print (lst[:10])
for i in range(10 ** 5 + 9, -1, -1):
    if lst[i] <= W:
        print (i)
        exit()



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

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

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

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

    string S; cin >> S;
    int N=SZ(S);
    int cnt=0;
    rep(i,N){
        if(S[i]=='p') cnt++;
    }
    cout << N/2-cnt << endl;
}

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

using namespace std;
#define int long long
#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()
using P=pair<int,int>;
using lint=long long;
using ll=long long;
const lint inf=1e18+7;
const int MOD=1000000007;
long long myPow(int x,int n,int rest){
    int res=1;
    int cur=x;
    while(n>0){
        if(n&1){
            res*=cur;
            res%=rest;
        }
        n/=2;cur*=cur;
        cur%=rest;
    }
    return res;
}
signed main(){
  int n;cin>>n;
  lint res=myPow(10,n,MOD);
  res+=MOD*2-myPow(9,n,MOD)*2;
  res+=myPow(8,n,MOD);
  res%=MOD;
  cout<<res<<"\n";
  return 0;
}


Measured memory_bytes: 3632
import java.io.*;

class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br =
			new BufferedReader(new InputStreamReader(System.in));

			String line = br.readLine();
			int a = Integer.parseInt(line);

			int hour = a / 3600;
			int minute = (a - 3600 * hour) / 60;
			int s = a - 3600 * hour - 60 * minute;

			System.out.println(hour + ":" + minute + ":" + s);
	}
}

Measured memory_bytes: 24276
#include <cstdio>
const int Mod = 1e6 + 3;

inline int fsp(int x, int p = Mod - 2) {
    int res = 1;
    while (p) {
        if (p & 1) res = 1LL * res * x % Mod;
        x = 1LL * x * x % Mod;
        p >>= 1;
    }
    return res;
}

int fac[Mod + 1], ifac[Mod + 1];

int main() {
#ifdef whyqx
    freopen("work.in", "r", stdin);
    freopen("work.out", "w", stdout);
#endif
    int Q;
    scanf("%d", &Q);
    fac[0] = 1;
    for (int i = 1; i < Mod; ++i)
        fac[i] = 1LL * fac[i - 1] * i % Mod,
        ifac[i] = fsp(fac[i]);
    while (Q--) {
        int x, d, n;
        scanf("%d%d%d", &x, &d, &n);
        if (!d) {
            printf("%d\n", fsp(x, n));
            continue;
        }
        int tmp = 1LL * x * fsp(d) % Mod;
        if (tmp + n - 1 >= Mod || tmp == 0) {
            puts("0");
            continue;
        }
        printf("%lld\n", 1LL * fac[tmp + n - 1] * ifac[tmp - 1] % Mod * fsp(d, n) % Mod);
    }
    return 0;
}


Measured memory_bytes: 8576