akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define MAX (1<<17)
#define INF (1LL<<55)
typedef long long ll;
typedef pair<ll, ll> P;

struct SegmentTree {
    int n;
    P dat[2*MAX-1];    
    
    SegmentTree(int n_)
    {
        n = 1;
        while (n < n_) {
            n *= 2;
        }
        for (int i = 0; i < 2 * n - 1; i++) {
            dat[i] = P(0, 1);
        }
    }

    ll get_nearest_marked_node(int k)
    {
        k += n - 1;
        P p = dat[k];
        while (k > 0) {
            k = (k - 1) / 2;
            p = max(p, dat[k]);
        }
        return p.second;
    }
        
    void mark(int a, int b, int k, int l, int r, P x)
    {
        if (r <= a || b <= l) return;

        if (a <= l && r <= b) {
            dat[k] = max(dat[k], x);
        } else {
            mark(a, b, k * 2 + 1, l, (l + r) / 2, x);
            mark(a, b, k * 2 + 2, (l + r) / 2, r, x);
        }
    }    
};

ll L[MAX], R[MAX], D[MAX], p;
vector<int> G[MAX];

void init(int N)
{
    p = 0;
    for (int i = 0; i < N; i++) {
        G[i].clear();        
    }
}

void dfs(int v, int depth)
{
    L[v] = p++;
    D[v] = depth;
    for (int i = 0; i < (int)G[v].size(); i++) {
        dfs(G[v][i], depth + 1);
    }
    R[v] = p;
}

int main()
{
    int N, Q, x;
    while (scanf("%d %d", &N, &Q), N) {
        init(N);
        for (int i = 1; i < N; i++) {
            scanf("%d", &x); x--;
            G[x].push_back(i);
        }

        dfs(0, 0);

        SegmentTree st(N);
        
        char m;
        ll v, res = 0;
        while (Q--) {
            cin >> m >> v; v--;
            if (m == 'M') {
                st.mark(L[v], R[v], 0, 0, st.n, P(D[v], v+1));
            } else {
                res += st.get_nearest_marked_node(L[v]);
            }
        }
        printf("%lld\n", res);
    }
    return 0;
}

Measured memory_bytes: 22620
#include <iostream>
#include <cstdio>
#include <deque>
#include <string>
using namespace std;

int main(){
	int n,num;
	string s;
	deque<int> de;
	cin >> n;
	for(int i = 0;i < n;i++){
		cin >> s;
		if(s == "deleteFirst"){
			de.pop_front();
			continue;
		}
		else if(s == "deleteLast"){
			de.pop_back();
			continue;
		}
		scanf("%d",&num);
		if(s == "insert"){
		de.push_front(num);
		}
		else if(s == "delete"){
			for(deque<int>::iterator ite = de.begin();ite < de.end();ite++){
				if(*ite == num){
					de.erase(ite);
					break;
				}
			}
		}
	}
	for(int i = 0;i < de.size();i++){
	if(i == de.size() - 1)cout << de[i] <<endl;
	else printf("%d ",de[i]);
	}
	return 0;
}

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

public class Main {

    public static void main(String[] args) {
        
        Scanner sc = new Scanner(System.in);
        
        int h = Integer.parseInt(sc.next());
        int n = Integer.parseInt(sc.next());
        int[] a = new int[n+1];
        int[] b = new int[n+1];
        for(int i = 1; i <= n; i++){
            a[i] = Integer.parseInt(sc.next());
            b[i] = Integer.parseInt(sc.next());
        }
    
        int[][] dp = new int[n+1][h+1];
        for(int i = 0; i <= n; i++){
            Arrays.fill(dp[i], Integer.MAX_VALUE/2);
            dp[i][0] = 0;
        }
        for(int i = 1; i <= n; i++){
            for(int j = 1; j <= h; j++){
                dp[i][j] = Math.min(dp[i][Math.max(j-a[i], 0)] + b[i], dp[i-1][j]);
            }
        }
    
        System.out.println(dp[n][h]);
    }
}

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

using namespace std;

const int MAX_N = 100000, INDEX = 1;

struct Pile {
    int ind, val;

    Pile() {
        this->ind = 0;
        this->val = 0;
    }

    Pile(int ind, int val) {
        this->ind = ind;
        this->val = val;
    }

    friend bool operator < (const Pile& a, const Pile& b) {
        if (a.val == b.val) {
            return a.ind < b.ind;
        }

        return a.val > b.val;
    }
};

int n, a[MAX_N + INDEX];
long long ans[MAX_N + INDEX];

Pile aSort[MAX_N + 1 + 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];
    }

    for (int i = 1; i <= n; i++) {
        aSort[i] = Pile(i, a[i]);
    }

    aSort[n + 1] = Pile(0, 0);

    sort(aSort + INDEX, aSort + n + 1 + INDEX, less<Pile>());

//    for (int i = 1; i <= n + 1; i++) {
//        cout << aSort[i].ind << ' ' << aSort[i].val << '\n';
//    }

    int r = 1;
    for (int l = 1; l <= n; ) {
        while (aSort[r].ind >= aSort[l].ind) {
            r++;
        }

        int x = aSort[l].ind;

//        cout << l << ' ' << r << ' ' << x << ' ' << aSort[l].val << ' ' << aSort[r].val << '\n';

        ans[x] += (long long)(l - 1) * (long long)(aSort[l].val - aSort[r].val);

        for (; l < r; l++) {
            ans[x] += aSort[l].val - aSort[r].val;
        }
    }

    for (int i = 1; i <= n; i++) {
        cout << ans[i] << '\n';
    }

    return 0;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
  using namespace std;
const int N=100000;
int cnt[N+1],n,m,sum;
bool b[N+1]={0};
inline void into(){
  int x,y;
  scanf("%d%d",&n,&m);
  b[1]=1;
  for (int i=1;i<=n;i++)
    cnt[i]=1;
  for (int i=1;i<=m;i++){
    scanf("%d%d",&x,&y);
    if (b[x]) b[y]=1;
    if (cnt[x]>0) cnt[x]--,cnt[y]++;
    if (!cnt[x]) b[x]=0;
  }
}
inline void work(){
}
inline void outo(){
  for (int i=1;i<=n;i++)
    if (b[i]) sum++;
  printf("%d\n",sum);
}
int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 768
#include "stdio.h"

int main() {

	int i,sum;
	char num[1001];

	while(1) {
		scanf("%s", &num);
		if (num[0] == '0') {
			break;
		}
		sum = 0;
		for (i = 0; num[i] != '\0'; i++) {
			sum += num[i] - '0';
		}
		printf("%d\n", sum);
	} 
	return 0;
}


Measured memory_bytes: 2132
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#include <list>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
//#define cerr if(false) cerr
#ifdef DEBUG
#define show(...) cerr << #__VA_ARGS__ << " = ", debug(__VA_ARGS__);
#else
#define show(...) 42
#endif
using namespace std;
using ll = long long;
using pii = pair<int, int>;
template <typename T, typename S>
ostream& operator<<(ostream& os, pair<T, S> a) {
    os << '(' << a.first << ',' << a.second << ')';
    return os;
}
template <typename T>
ostream& operator<<(ostream& os, vector<T> v) {
    for (auto x : v) os << x << ' ';
    return os;
}
void debug() {
    cerr << '\n';
}
template <typename H, typename... T>
void debug(H a, T... b) {
    cerr << a;
    if (sizeof...(b)) cerr << ", ";
    debug(b...);
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int X, Y, a, b, c;
    cin >> X >> Y >> a >> b >> c;
    multiset<int> st;
    multiset<int> st2;
    rep(i,a){
        int x;
        cin >> x;
        st.insert(x);
    }
    while(st.size()>X)st.erase(st.begin());
    rep(i,b){
        int x;
        cin >> x;
        st2.insert(x);
    }
    while(st2.size()>Y)st2.erase(st2.begin());
    vector<int>d(c);
    rep(i,c){
        cin >> d[i];
    }
    sort(d.rbegin(), d.rend());
    for(auto x: d){
        if(*st.begin()>x and *st2.begin()>x)break;
        if(*st.begin()<*st2.begin()){
            st.erase(st.begin());
            st.insert(x);
        }else{
            st2.erase(st2.begin());
            st2.insert(x);
        }
    }
    ll ans = 0;
    for(auto x : st)ans += x;
    for(auto x : st2)ans += x;
    cout << ans << endl;
}


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

using int32 = int_fast32_t;
using int64 = int_fast64_t;

const int32 INF = 1e9;
const int32 MOD = 1e9+7;
const int64 LLINF = 1e18;

#define YES(n) cout << ((n) ? "YES\n" : "NO\n"  )
#define Yes(n) cout << ((n) ? "Yes\n" : "No\n"  )
#define POSSIBLE cout << ((n) ? "POSSIBLE\n" : "IMPOSSIBLE\n"  )
#define ANS(n) cout << (n) << "\n"
#define REP(i,n) for(int64 i=0;i<(n);++i)
#define FOR(i,a,b) for(int64 i=(a);i<(b);i++)
#define FORR(i,a,b) for(int64 i=(a);i>=(b);i--)
#define ALL(obj) (obj).begin(),(obj).end()
#define pii pair<int32,int32>
#define pll pair<int64,int64>
#define pb(a) push_back(a)

//Monoid, 1点更新(書き換え)区間取得
//要素数, 2項演算, 単位元 (, 初期データ)
//todo:1点取得も関数化する？
template<typename T>
struct SegmentTree{
    typedef function<T(T,T)> F;
    int n;    //要素数
    F f;    //2項演算
    T e;    //単位元
    vector<T> dat;
    SegmentTree(int n_,F f,T e):f(f),e(e){
        init(n_);
        build();
    }
    SegmentTree(int n_,F f,T e,vector<T>& v):f(f),e(e){
        init(n_);
        build(n_,v);
    }
    void init(int n_){
        n=1;
        while(n<n_)n<<=1;
        dat.clear();
        dat.resize(n<<1, e);
    }
    void build(int n_,const vector<T>& v){
        for(int i=0;i<n_;++i)dat[n+i]=v[i];
        build();
    }
    void build(){
        for(int i=n-1;i>=1;--i){
            dat[i] = f(dat[i<<1],dat[i<<1|1]);
        }
    }
    void update(int k,const T& x){
        dat[k+=n]=x;
        while(k>>=1){
            dat[k] = f(dat[k<<1],dat[k<<1|1]);
        }
    }
    int query(int a,int b){
        T l=e,r=e;
        for(a+=n,b+=n;a<b;a>>=1,b>>=1){
            if(a&1)l=f(l,dat[a++]);
            if(b&1)r=f(dat[--b],r);
        }
        return f(l,r);
    }
};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int32 n,x;
  cin >> n >> x;
  vector<int32> a(n);
  REP(i,n)cin >> a[i];
  SegmentTree<int32> rmq(n,[](int32 a, int32 b){return min(a,b);},INF,a);
  int64 ans = LLINF;
  REP(magic,n){
    int64 cur = (int64)x * magic;
    REP(i,n){
      if(i-magic < 0){
        cur += min(rmq.query(0,i+1), rmq.query(i-magic+n,n));
        // cout << 0 << " " << i + 1 << " " << i-magic+n << " " << n << endl;
      }else{
        cur += rmq.query(i-magic,i+1);
        // cout << i-magic << " " << i+1 << endl;
      }
    }
    // ANS(cur);
    ans = min(ans, cur);
  }
  ANS(ans);
  return 0;
}

Measured memory_bytes: 256
"use strict";

// read lines from stdin
const input = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");

const firstLine = input[0].split(" ").map((val) => parseInt(val, 10));
const N = firstLine[0];
const K = firstLine[1];

const sunukeList = Array(N).fill(false);

for (let i = 1; i <= K; i++) {
  const d = parseInt(input[2 * i - 1], 10);
  const targetLine = input[2 * i].split(" ");

  for (let j = 0; j < d; j++) {
    sunukeList[targetLine[j] - 1] = true;
  }
}

console.log(sunukeList.filter((hasSnack) => hasSnack === false).length);


Measured memory_bytes: 29680
N = int(input())
f, s = [0, 0], [0, 0]
for i in range(N):
    a = int(input())
    if f[1] < a:
        s = f
        f = [i, a]
    elif s[1] < a:
        s = [i, a]
for i in range(N):
    if f[0] == i:
        print(s[1])
    else:
        print(f[1])


Measured memory_bytes: 4668
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int N,M;
	cin >> N >> M;
	vector<int> vec(2*M);
	vector<int> ans(N);
	for(int i=0;i<2*M;i++){
		cin >> vec.at(i);
	}
	for(int i=1;i<N+1;i++){
		for(int k=0;k<2*M;k++){
			if(vec.at(k)==i){
				ans.at(i-1)++;
			}
		}
	}
	for(int i=0;i<N;i++){
		cout << ans.at(i) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int a, b;
    cin >> a >> b;
    if (a < b) swap(a, b);
    int ans = max(2*a-1, a+b);

    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
### constant

MAX_W = 10000

### subroutines

def root(i)
  while i != $uft[i]
    i = $uft[i]
  end
  i
end

def spanning?()
  r0 = root(0)
  for i in (1...$n)
    return false if root(i) != r0
  end
  true
end

def check_rec(k)
  return (MAX_W + 1) if k >= $m

  ak, bk, wk = $edges[k]
  ra = root(ak)
  rb = root(bk)

  uw = MAX_W + 1;

  if ra == rb
    uw = check_rec(k + 1)
  else
    $uft[rb] = ra

    if spanning?()
      uw = wk;
    else
      uw = check_rec(k + 1)
    end
    
    $uft[rb] = rb
  end

  uw
end

def check()
  min_dw = MAX_W + 1
  $uft = (0...$n).to_a

  for i in (0...$m)
    ai, bi, wi = $edges[i];
    lw = wi;
    uw = MAX_W + 1
    
    $uft[bi] = ai

    if spanning?()
      uw = wi
    else
      uw = check_rec(i + 1)
    end
    
    $uft[bi] = bi

    if uw <= MAX_W
      dw = uw - lw
      min_dw = dw if min_dw > dw
    end
  end
  
  min_dw
end

### main

loop do
  $n, $m = gets.split.map(&:to_i)
  break if ($n | $m) == 0

  $edges = []
  $m.times do
    ai, bi, wi = gets.split.map(&:to_i)
    $edges << [ai - 1, bi - 1, wi]
  end
  $edges.sort!{|a, b| a[2] <=> b[2]}
  #p $edges

  min_dw = check()

  puts (min_dw >= MAX_W ? -1 : min_dw)
end

Measured memory_bytes: 6248
#include <iostream>
#include <cstdio>
#include <complex>
using namespace std;

int main()
{
  complex<double> a[4];
  double x, y;
  while (scanf("%lf %lf ", &x, &y) == 2) {
    a[0] = complex<double>(x, y); 
    for (int i = 1; i < 4; i++) {
      scanf("%lf %lf ", &x, &y);
      a[i] = complex<double>(x, y);
    }
    
    if ((a[1].real() - a[0].real()) * (a[3].real() - a[2].real()) + (a[1].imag() - a[0].imag()) * (a[3].imag() - a[2].imag()) == 0) {
      cout << "YES" << endl;
    } else {
      cout << "NO" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <numeric>
#include <vector>
#include <math.h>
#include <map>
#include <algorithm>
#include <stdio.h>
#include <set>
#include <string>
#define mod 1000000007
using namespace std; 

int main(){
	string a; cin >> a;
	string s; cin >> s;
	for (int i=0;i<a.size();i++){
		if (a[i]!=s[i]){
			cout << "No" << "\n";
			return 0;
		}
	}
	cout << "Yes" << "\n";
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define SORT(v) sort((v).begin(), (v).end())
#define ALL(v) (v).begin(), (v).end()

int main() {
    int n, m;
    vector<P> dat;
    vector<vector<int> > ls;
    cin >> n >> m;
    ls.resize(n);
    REP(i,m){
        int p, y;
        cin >> p >> y;
        p--;
        ls[p].push_back(y);
        dat.push_back(make_pair(p,y));
    }
    REP(i,n)SORT(ls[i]);
    REP(i,m){
        int p, y, x;
        p = dat[i].first;
        y = dat[i].second;
        x = lower_bound(ALL(ls[p]),y)-ls[p].begin()+1;
        printf("%06d%06d\n",p+1,x);
    }
    return 0;
}


Measured memory_bytes: 7796
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        FastReader sc = new FastReader(System.in);
        int N = sc.nextInt();
        int[] A = new int[N], B = new int[N], C = new int[N];
        for (int i=0; i<N; i++) {
            A[i] = sc.nextInt();
        }
        for (int i=0; i<N; i++) {
            B[i] = sc.nextInt();
        }
        for (int i=0; i<N-1; i++) {
            C[i] = sc.nextInt();
        }
        int sum = 0;
        for (int i=0; i<N; i++) {
            sum += B[A[i]-1];
            if (i>0 && A[i-1] == (A[i]-1)) {
                sum += C[A[i-1]-1];
            }
        }
        System.out.println(sum);
    }
    static class FastReader
    {
        BufferedReader br;
        StringTokenizer st;
        public FastReader(InputStream x) {
            br = new BufferedReader(new
                    InputStreamReader(x));

        }

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

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

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

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

        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 22484
#include<stdio.h>
 
int pnCheck(int);
 
int main() {
    int i,j;
    int data;
 
    scanf("%d", &data);
    printf("%d:", data);

    if(pnCheck(data)){
        printf(" %d\n",data);
        return 0;
    }


    i = 2;
    while (data%i==0) {
        data /= 2;
        printf(" 2");
    }
 
    for (i = 3; i <= data; i+=2) {
        if (pnCheck(i)) {
            while (data%i==0) {
                data /= i;
                printf(" %d", i);
            }
        }
    }
    printf("\n");
    return 0;
}
 
int pnCheck(int x) {
    if(x%2==0)return 0;
    int i;
    int fl = 0;
 
    for (i = 3; i*i <= x; i += 2) {
        if (pnCheck(i)) {
            if (fl = (x % i == 0)) break;
        }
    }
    return !fl;
}

Measured memory_bytes: 2756
n,k=map(int,input().split())

a=0
b=0
for i in range(1,n+1):
    if i%k==0:
        a+=1
    elif i%k==(k//2):
        b+=1
print(a*a*a if k%2==1 else a*a*a+b*b*b)


Measured memory_bytes: 2940
import sys
sys.setrecursionlimit(1000000)

N = int(input())

adj = [[] for i in range(N)]
for i in range(N - 1):
    a, b, c = map(int, input().split())
    adj[-a].append((b, c))
    adj[-b].append((a, c))

Q, K = map(int, input().split())
query = [tuple(map(int, input().split())) for i in range(Q)]

# dist[-i]:頂点Kから頂点iまでの距離
dist = [-1 for i in range(N)]
dist[-K] = 0

# 深さ優先探索（再帰）
def dfs(v):
    for nxt, c in adj[-v]:
        if dist[-nxt] == -1:
            dist[-nxt] = dist[-v] + c
            dfs(nxt)

dfs(K)

for x, y in query:
    print(dist[-x] + dist[-y])


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

using namespace std;

int n;

void solve(){
    int i,j;
    string str;
    cin >> n;
    cin >> i >> j;
    long long ans = 0;
    cout << min(i,j) << ' ' << max(0,i+j-n) << endl;
}

int main(){
    solve();
}


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

if 0 in line:
    a = 0
else:
    a = 1
    for ele in line:
        if ele >= 10**18:
            a = -1
            break
        a = a * ele
        if a > 10**18:
            a = -1
            break

print(a)

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
ll MOD = 1000000007;
const long long INF = 1LL << 60;
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}

signed main()
{   
    gearup;
    int n; cin >> n;
    string s; cin >> s;
    map<char,int> mp;
    rep(i,s.size()) mp[s[i]]++;
    ll res = 1;
    for(auto m:mp){
        res *= m.second+1;
        res %= MOD;
    }
    cout << res -1 << endl;
}


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

int main() {
  int N;
  cin >> N;
  
  int mindata = 1000000;
  for (int i = 1; i <= (N + 1) / 2; ++i) {
    int a = i;
    int b = N - i;
    
    int sum_a, sum_b;
    sum_a = sum_b = 0;
    
    while (a > 0) {
      sum_a += (a % 10);
      a /= 10;
    }
    while (b > 0) {
      sum_b += (b % 10);
      b /= 10;
    }
    int sum = sum_a + sum_b;
    
    mindata = min(mindata, sum);
    
  }
  cout << mindata << endl;
}

Measured memory_bytes: 3636
#include <cstdio>
#include <vector>
#include <set>
using namespace std;
 
struct NODE {
    int id;
    int degree;
    int parent;
    int depth;
    vector<int> child;
};
 
 
int main() {
    vector<NODE> node;
    int n;
    int i,j;
    int id,k;
    scanf("%d",&n);
    node.resize(n);
    for(i=0; i<n; ++i) {
        scanf("%d%d",&id,&k);
        node[id].parent=-1; // default
        node[id].depth=0;   // default
        if(0==(node[id].degree=k)) {
            continue;
        }
        node[id].child.resize(k);
        for(j=0; j<k; ++j) {
            scanf("%d",&node[id].child[j]);
        }
    }
    for(i=0; i<n; ++i) {
        if((k=node[i].degree)==0) continue;
        for(j=0; j<k; ++j) {
            node[node[i].child[j]].parent=i;
        }
    }
    for(i=0; i<n; ++i) {
        j=i;
        while(node[j].parent!=-1){
            j=node[j].parent;
            ++node[i].depth;
        }
    }
    for(i=0; i<n; ++i) {
        if(node[i].parent==-1) {
            printf("node %d: parent = %d, depth = %d, root, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        } else if(node[i].degree==0) {
            printf("node %d: parent = %d, depth = %d, leaf, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        } else {
            printf("node %d: parent = %d, depth = %d, internal node, [",i,node[i].parent,node[i].depth);
            for(j=0; j<node[i].degree-1; ++j) {
                printf("%d, ",node[i].child[j]);
            }
            if(node[i].degree!=0) {
                printf("%d",node[i].child[j]);
            }
            printf("]\n");
        }
    }
    return 0;
}

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

string s[110], t[110];

int main(){
    int N, M, i, j;
    int ans = 0;

    cin >> N;
    for (i = 0; i < N; i++)cin >> s[i];
    cin >> M;
    for (i = 0; i < M; i++)cin >> t[i];
 
    for (i = 0; i < N; i++){
      int score = 0;
      for (j = 0; j < N; j++) if(s[j]==s[i])score++;
      for (j = 0; j < M; j++) if(t[j]==s[i])score--;
      ans = max(ans, score);
    }
    cout << ans << endl;
}  

Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
        int a = sc.nextInt();
     	int b = sc.nextInt();
      
        if(a == b ){
          System.out.println("Draw");
        }else if(a > b && b != 1){
          System.out.println("Alice");
        }else if(a < b && a != 1){
          System.out.println("Bob");
        }else if(a == 1){
          System.out.println("Alice");
        }else{
          System.out.println("Bob");
        }
    }
}

Measured memory_bytes: 35844
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) throws NumberFormatException, IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

		int n = Integer.parseInt(br.readLine());
		String[] aline = br.readLine().split(" ");

		long ans = 0;

		for (int i = 0; i < n; i++) {
			ans += Long.parseLong(aline[i]) - 1;
		}

		System.out.println(ans);

	}

}


Measured memory_bytes: 23764
#include <bits/stdc++.h>
using namespace std;
#define int64_t long long
constexpr int64_t MOD=1e9+7;

int main() {
    ios_base::sync_with_stdio(0);
    int n;
    cin>>n;
    int cur;
    cin>>cur;
    for(int i=1;i<n;++i){
        int x;
        cin>>x;
        if(cur<x)--x;
        if(cur>x){
            cout<<"No\n";
            return 0;
        }
        cur=x;
    }
    cout<<"Yes\n";
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <sstream>
#include <iomanip>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <list>
#include <utility>
#include <numeric>

using namespace std;
typedef long long llong;
typedef unsigned long long ullong;

const ullong MOD = 1000000000 + 7;

int main()
{
	string s;
	vector<pair<string, int>> r = {make_pair("M", 1000), make_pair("D", 500), make_pair("C", 100), make_pair("L", 50), make_pair("X", 10), make_pair("V", 5), make_pair("I", 1)};
	for (; cin >> s;)
	{
		int sum = 0;
		int add = 0;
		int old = 0;
		for (int i = 0; i < s.length(); i++)
		{
			for (int j = 0; j < r.size(); j++)
			{
				if (s.substr(i, 1) == r.at(j).first)
				{
					int n0 = r.at(j).second;
					if (old > 0 && old < n0)
					{
						sum -= 2 * old;
						old = 0;
					}
					sum += n0;
					old = n0;
					break;
				}
			}
		}

		// sum += add + old;

		cout << sum << endl;
	}
}



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

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define FOR(i,n,m) for(int i=(int)(n); i<=(int)(m); i++)
#define RFOR(i,n,m) for(int i=(int)(n); i>=(int)(m); i--)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define RITR(x,c) for(__typeof(c.rbegin()) x=c.rbegin();x!=c.rend();x++)
#define setp(n) fixed << setprecision(n)

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 (a>b) { a=b; return 1; } return 0; }

#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pll pair<ll,ll>
#define pi pair<int,int>

#define all(a) (a.begin()),(a.end())
#define rall(a) (a.rbegin()),(a.rend())
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define ins insert

using namespace std;

/* Some Libraries */

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

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n; cin>>n;
    string s = to_string(n);
    int m = s.size();
    int sum=0;
    rep(i,m){
        sum+=s[i]-'0';
    }
    if (n%sum==0){
        cout<<"Yes\n";
    }else{
        cout<<"No\n";
    }
    return 0;
}


Measured memory_bytes: 256
//Decrementing
#include <cstdio>
typedef long long lint;
int const N=1e5+10;
int n,a[N];
int gcd(int x,int y)
{
	if(x==-1 || y==-1) return -x*y;
	if(x==0) return y;
	else return gcd(y%x,x);
}
int g1[N],g2[N];
int main()
{
	scanf("%d",&n);
	lint sum=0;
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),sum+=a[i];
	if(n%2==0)
	{
		if(sum%2==1) printf("First");
		else printf("Second");
		return 0;
	}
	if(sum%2==0) {printf("First"); return 0;}
	int cur=0;
	while(true)
	{
		bool flag=false;
		sum=0;
		for(int i=1;i<=n;i++) sum+=a[i];
		g1[0]=-1; g2[n+1]=-1;
		for(int i=2;i<=n;i++) g1[i]=gcd(g1[i-1],a[i]);
		for(int i=n-1;i>=1;i--) g2[i]=gcd(g2[i+1],a[i]);
		int g;
		for(int i=1;i<=n&&!flag;i++)
		{
			if(a[i]==1) continue;
			g=gcd(gcd(g1[i-1],g2[i+1]),a[i]-1);
			if(((sum-1)/g)%2==1) flag=true;
		}
		if(flag)
			for(int i=1;i<=n;i++) a[i]/=g;
		else
		{ 
			if(cur==0) printf("Second");
			else printf("First");
			return 0; 
		} 
		cur^=1;
	}
	return 0;
}

Measured memory_bytes: 1280
N = int(input())
A = list(map(int, input().split()))
m = 10**9
while m >0:
    for i in A:
        if i != 0 and i <= m:
            m = i
    A = [k%m for k in A]
    if max(A) == 0:
        break
    A += [m]
print(m)



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

int main(){
    int N,M,X,money=0,ans=10000000,flag=1;
    cin >> N >> M >> X;
    vector<int> vec(M,0);
    vector<vector<int>> book(N,vector<int>(M+1,0));
    for(int i=0;i<N;i++){
        for(int j=0;j<M+1;j++){
            cin >> book[i][j];
        }
    }
    for(int i=0;i<pow(2,N);i++){
        for(int j=0;j<N;j++){
            if(i&(1<<j)){
                money+=book[j][0];
                for(int k=0;k<M;k++){
                    vec[k]+=book[j][k+1];
                }
            }
        }
        for(int l=0;l<M;l++){
            if(vec[l]<X){
                flag=0;
            }
        }
        if(flag){
            ans=min(ans,money);
        }
        flag=1;
        money=0;
        for(int m=0;m<M;m++){
            vec[m]=0;
        }
    }
    if(ans!=10000000) cout << ans << endl;
    else cout << -1 << endl;
}

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

int main()
{
  int K,N;
  string S;
  cin >> K;
  cin >> S;
  N=S.size();
  if(K>=N)
  {
    cout << S << endl;
    return 0;
  }
  if(K<N)
  {
    for(int i=0; i<K; i++)
    {
      cout << S.at(i);
      if(i==K-1)
      {
        cout <<"..."<< endl;
      }
    }
  }
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
const ld eps = 1e-9;

//// < "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\a.txt" > "d:\d_download\visual studio 2015\projects\programing_contest_c++\debug\b.txt"


int main() {
	int acase = 0;
	while (1) {
		acase++;
		int N; cin >> N;
		if (!N)break;
		vector<vector<int>>field(N, vector<int>(N));
		int num = 1;
		for (int t = 0; t <  N; ++t) {
			const int len = t + 1;
			for (int n = 0; n < len; ++n) {
				if (t % 2) {
					field[n][t - n] = num++;
				}
				else {
					field[t - n][n] = num++;
				}
			}
		}
		for (int i = 0; i < N; ++i) {
			for (int j = N - i - 1; j < N; ++j) {
				field[i][j] = N*N + 1 - field[N - 1 - i][N - 1 - j];
			}
		}
		cout << "Case " << acase << ":" << endl;
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				printf("%3d", field[i][j]);
			}
			printf("\n");
		}

	}
	return 0;
}

Measured memory_bytes: 3264
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <vector>
#include <numeric>
#include <string.h>
using namespace std;
typedef long long int lli;
#define urept(soeji, start, n) for (int soeji = start; soeji < n; soeji++)
#define drept(soeji, start, n) for (int soeji = start; soeji > n; soeji--)
struct sqe
{
    lli A;
    lli B;
};
int main(void)
{
    lli N, H, W;
    cin >> N >> H >> W;
    sqe *ita;
    ita = new sqe [N];
    for (int i = 0; i < N; i++)
    {
        cin >> ita[i].A >> ita[i].B;
    }
    int count = 0;
    for (int i = 0; i < N; i++)
    {
        if (ita[i].A >= H && ita[i].B >= W)
        {
            count++;
        }
    }
  	cout << count <<endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <stdlib.h>
#define NOT_ZERO 1
#define MAX(a,b) (a>b?a:b)
#define MIN(a,b) (a<b?a:b)

int main()
{
    int i, n, h[100000];
    int cost[100000];

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

    cost[0] = 0;
    cost[1] = abs(h[1]-h[0]);
    for(i=2; i<n; i++) {
         cost[i] = MIN(cost[i-1] + abs(h[i]-h[i-1]), cost[i-2] + abs(h[i]-h[i-2]));
    }
    printf("%d",cost[n-1]);
    return 0;
}

Measured memory_bytes: 896
n = int(input())
d = [list(map(int, input().split())) for i in range(n)]

for i in range(0,n-2):
    if d[i][0] == d[i][1] and d[i+1][0] == d[i+1][1] and d[i+2][0] == d[i+2][1]:
        print("Yes")
        exit()
print("No")

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

const int H_MAX = 10001,N_MAX = 1001;

int dp[N_MAX][H_MAX];
//dp[i][j] iまでの魔法でjの体力を０にするために最小の魔力
int main()
{
	memset(dp,INF,N_MAX*H_MAX*sizeof(int));
	dp[0][0] = 0;
	int h,n;
	cin >> h >> n;
	vector<P> ab(n);
	rep(i,n)
	{
		int a,b;
		cin >> a >> b;
		ab[i] = make_pair(a,b);
	}
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<=h;j++)
		{
			if(j-ab[i].first<0)
			{
				dp[i+1][j] = min(dp[i][j],ab[i].second);
			}
			else
			{
				dp[i+1][j] = min(dp[i][j],dp[i+1][j-ab[i].first]+ab[i].second);	
			}
		}
	}
	cout<<dp[n][h]<<endl;
	return 0;
}

Measured memory_bytes: 39296
#line 1 "test/aoj/DSL1B.test.cpp"
#define PROBLEM "http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=DSL_1_B"

// header file section
#include <iostream>
#include <cstdio>
#include <cfloat>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <functional>
#include <numeric>
#include <algorithm>
#line 1 "disjoint_set/weighted_union_find.hpp"


#line 4 "disjoint_set/weighted_union_find.hpp"

//===
template<class Abel>
struct WeightedUnionFind {
    using T = typename Abel::value_type;

    std::vector<int> parent; // [i] = i-th node's parent. if [i] < 0, i-th node is root.
    std::vector<T> diff_weight; // distance from parent
    
    WeightedUnionFind() = default;
    WeightedUnionFind(int nmemb) {
        init(nmemb);
    };

    void init(int nmemb) {
        parent.resize(nmemb, -1);
        diff_weight.resize(nmemb, Abel::identity());
    };

    int root(int x) {
        if (parent[x] < 0) return x;
        
        int p = root(parent[x]);
        diff_weight[x] = Abel::operation(diff_weight[x], diff_weight[parent[x]]);
        parent[x] = p;

        return p;
    };

    // unite x, y; weight(y) - weight(x) = w
    bool unite(int x, int y, T w) {
        T wx = weight(x);
        T wy = weight(y);
        x = root(x);
        y = root(y);

        if (x == y) return false;
        w = Abel::operation(w, wx);
        w = Abel::operation(w, Abel::inverse(wy));
        if (size(x) < size(y)) std::swap(x, y), w = Abel::inverse(w);

        parent[x] += parent[y];
        parent[y] = x;
        diff_weight[y] = w;
        
        return true;
    };
    
    bool same(int x, int y) {
        return root(x) == root(y);
    };

    T weight(int x) {
        root(x);
        return diff_weight[x];
    };

    T diff(int x, int y) {
        return Abel::operation(weight(y),
                Abel::inverse(weight(x)));
    };

    int size(int x) {
        return -parent[root(x)];
    };
};
//===


#line 17 "test/aoj/DSL1B.test.cpp"

using namespace std;
using llong = long long;

struct A {
    using T = llong;
    using value_type = T;

    static inline T identity() {
        return 0;
    };

    static inline T operation(T x, T y) {
        return x + y;
    };

    static inline T inverse(T x) {
        return -x;
    };
};

llong n, q;
llong com, x, y, w;

int main() {
    cin >> n >> q;
    WeightedUnionFind<A> uf(n);

    while (q--) {
        cin >> com;

        if (com == 0) {
            cin >> x >> y >> w;
            uf.unite(x, y, w);
        }
        else {
            cin >> x >> y;

            if (uf.same(x, y)) {
                cout << uf.diff(x, y) << '\n';
            }
            else {
                cout << "?\n";
            }
        }
    }

    return 0;
};




Measured memory_bytes: 3844
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	void run() {
		Scanner sc = new Scanner(System.in);
		long n = sc.nextLong();
		sc.close();
		
		if(n%f(n) == 0) System.out.println("Yes");
		else System.out.println("No");
	}
	
	int f(long n) {
		String s = n+"";
		String ss[] = s.split("");
		int m = 0;
		for(int i=0; i<ss.length; i++) {
			m += Integer.parseInt(ss[i]);
		}
		return m;
	}
}

Measured memory_bytes: 23892
#include <iostream>
#include <algorithm>
int array[200000];
int main()
{
	using namespace std;
	int n,maxv,i,minv;
	cin >> n;
	for(i=0;i<n;i++)
		cin >> array[i];
		
	maxv=array[1]-array[0];
	minv=array[0];
	
	for(i=1;i<n;i++)
	{
		maxv=max(maxv,array[i]-minv);
		minv=min(minv,array[i]); 
	}
	cout << maxv <<endl;
	return 0;
}


Measured memory_bytes: 3904
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;

long long n,ans;

int main(){
	scanf("%lld",&n);
	for(int i=sqrt(n);i;i--){
		if(!(n%i)){
			printf("%lld",i+(n/i)-2); 
			return 0;
		}
	}
} 

Measured memory_bytes: 128
#include <bits/stdc++.h>
// atoi : atoi(変数名.c_str())
// to_string(数値)
// %0桁数d とすると表示桁数が「桁数」に満たない場合に0埋めされる
// find(): int i = 変数名.find(“文字列”) 何番目にあるかを得る
// cout << (条件 ? "Yes" : "No") << endl;
// printf("%02d:%02d:%02d",hour,minute,second);
// 降順 sort(a.begin(),a.end(),greater<int>());
// bitset<ビット数> 変数名;  // すべてのビットが0の状態で初期化される
// bitset<ビット数> 変数名("ビット列");  // 指定したビット列で初期化される
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(20);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  int n,k;
  cin >> n >> k;
  int count = 0;
  rep(i,n){
    int h;
    cin >> h;
    if(h >= k) count++;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading.Tasks;
using static System.Console;
using static System.Math;
class Z { static void Main() => new K(); }
class K
{
	int F => int.Parse(Str);
	long FL => long.Parse(Str);
	int[] G => Strs.Select(int.Parse).ToArray();
	long[] GL => Strs.Select(long.Parse).ToArray();
	double[] GR => Strs.Select(double.Parse).ToArray();
	string Str => ReadLine();
	string[] Strs => Str.Split(new char[] { ' ', '\t' }, StringSplitOptions.RemoveEmptyEntries);
	public const int MOD = 1000000007;
	public const long INFL = 4011686018427387913L;
	public K()
	{
		SetOut(new StreamWriter(OpenStandardOutput()) { AutoFlush = false });
		Solve();
		Out.Flush();
	}
	void Solve()
	{
		var I = GL;
		var N = (int)I[0];
		var K = I[1];
		var m = new Matrix(N);
		for (var i = 0; i < N; i++)
		{
			var I2 = G;
			for (var j = 0; j < N; j++) m.a[i, j] = I2[j];
		}
		m = m.Pow((ulong)K);
		var ans = 0L;
		for (var i = 0; i < N; i++) for (var j = 0; j < N; j++) ans += m.a[i, j];
		WriteLine(ans % MOD);
	}
}
class Matrix
{
	const int MOD = K.MOD;
	public int Size { get; protected set; }
	public long[,] a;
	public Matrix(int r) { Size = r; a = new long[r, r]; }
	public Matrix(long[,] c) : this(c.GetLength(0), (i, j) => c[i, j]) { }
	public Matrix(int r, Func<int, int, long> f) : this(r) { for (var i = 0; i < r; i++) for (var j = 0; j < r; j++) a[i, j] = f(i, j) % MOD; }
	public static Matrix operator *(Matrix p, Matrix q)
		=> new Matrix(p.Size, (i, j) => { var sum = 0L; for (var k = 0; k < p.Size; k++) sum = (sum + p.a[i, k] * q.a[k, j] % MOD) % MOD; return sum; });
	public static Matrix One(int size) => new Matrix(size, (i, j) => i == j ? 1 : 0);
	public Matrix Pow(ulong n)
	{
		var p = One(Size);
		var x = this;
		while (n > 0)
		{
			if ((n & 1) == 1) p = p * x;
			n >>= 1;
			x = x * x;
		}
		return p;
	}
}

Measured memory_bytes: 15072
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
using vll=vector<ll>;
using vvll=vector<vll>;


int main(void)
{
	int n;
	while(scanf("%d", &n)==1)
	{
		vi d(n);
		for(int i=0;i<n;i++)
		{
			scanf("%d", &d[i]);
		}
		int ans=0;
		for(int i=0;i<n;i++)
		{
			for(int j=i+1;j<n;j++)
			{
				ans+=d[i]*d[j];
			}
		}
		printf("%d\n", ans);
	}
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int gcd(int,int);
void swap(int,int);
int main(){
  int x,y,d;
  scanf("%d%d",&x,&y);
  d=gcd(x,y);
  printf("%d\n",d);
  return 0;
}

int gcd(int x,int y){
  int r;
  if(x < y)
  swap(x, y);
  while(y > 0){
    r = x % y;
    x = y;
    y = r;
  }
  return x;
}

void swap(int x,int y){
  int temp=0;
  temp=x;
  x=y;
  y=temp;
}



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

int main(){
  int a[100],i,n,ans=1;
  cin>>n;
  for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]%2==0){
      if(a[i]%3==0||a[i]%5==0){
      }else{
        cout<<"DENIED"<<endl;
        ans=-1;
        break;
      }
    }
  }
  if(ans==1) cout<<"APPROVED"<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n)     for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = m; i < (int)(n); i++)
#define MOD 1000000007
#define Graph vector<vector<int>>
#define lint int64_t

int main(){
    lint A,B,C;
    cin >> A >> B >> C;

    lint ans = min(C,B/A);    

    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
/* 

	 - If you fail to prepare, you are prepared to fail.	

	(C) Mark Spitz

*/

#include <bits/stdc++.h>

#define pb push_back
#define mp make_pair
#define sz(x) (int)(x).size()
#define S second
#define F first
#define all(x) (x).begin(), (x).end()

using namespace std;

using ll = long long;

const bool dbg_flg = 1;
#define NAME(x) #x
#define debug if (dbg_flg) cerr

const int inf = 1e9 + 7;
const int MAXN = 1e6 + 5;

int n;
int ct[26];

void solve() {	
	cin >> n;
	
	for (int i = 1; i <= n; i++) {
		char x;
		
		cin >> x;
		
		ct[x - 'a']++;
	}
	
	ll res = 1;
	
	for (int i = 0; i < 26; i++) {
		if (ct[i] == 0) continue;
		ct[i]++;
		
		res *= ct[i];
		res %= inf;
	}
	
	cout << (res - 1 + inf) % inf;
}

int main() {
	
	//~ freopen(".in", "r", stdin);
	//~ freopen(".out", "w", stdout);
	                                                         
	ios_base::sync_with_stdio(NULL);
	cin.tie(NULL);
	cout.tie(NULL);

	int tt = 1;
	//~ cin >> tt;
	while (tt--) {
		solve();
	}

	return 0;
}


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

#define repr(i, n) for(int i = n; i >= 0; i--)
#define reprl(i, n) for(ll i = n; i >= 0; i--)
#define all(v) v.begin(), v.end()
ll gcd(ll a,ll b) {
  return b? gcd(b,a%b): a;  
}
ll lcm(ll a,ll b) {
  return a*b/gcd(a,b);
}
bool isLowerCase(char c){
  return (c>='a'&&c<='z');
}
const string outputYesNo(bool ans){
  return (ans?"YES":"NO");
}
const ll mod=1000000007;

int countBits(int in){
  int res=0;
  for(int i=0;i<10;i++){
    int msk=1<<i;
    if((in&msk)!=0){
      res++;
    }
  }
  return res;
}

template<typename T>
void show2dVector(vector<vector<T>>& v){
  for(int i=0;i<v.size();i++){
    int m=v[i].size();
    cout<<i<<" : ";
    for(int j=0;i<m;i++){
      cout<<v[i][j]<<" ";
    }
    cout<<endl;
  }
}

void bfs(const vector<vector<int>>&g, int v, vector<bool>& seen){
  seen[v]=true;
  cout<<v<<" ";
  for(auto next: g[v]){
    if(seen[next]){
      continue;
    }
    bfs(g,next,seen);
  }
}

bool dfs(vector<vector<int>> &g,int start,int goal,vector<bool>&seen){
  bool res=false;
  seen[start]=true;
  if(start==goal){
    return true;
  }
  for(auto next: g[start]){
    if(seen[next]){
      continue;
    }
    res=dfs(g,next,goal,seen);
    if(res){
      break;
    }
  }
  return res;
}

int main() {
  string a,b,c;cin>>a>>b>>c;
  cout<<outputYesNo((*--a.end()==*b.begin())&&(*--b.end()==*c.begin()))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//#define int long long
#define fo(a,b) for(int a=0;a<b;a++)
#define Sort(a) sort(a.begin(),a.end())
#define rev(a) reverse(a.begin(),a.end())
#define fi first
#define se second
#define co(a) cout<<a<<endl
#define sz size()
#define bgn begin()
#define en end()
#define pb(a) push_back(a)
#define pop pop_back
#define V vector
#define P pair
#define V2(a,b,c) V<V<int>> a(b,V<int>(c))
#define V2a(a,b,c,d) V<V<int>> a(b,V<int>(c,d))
#define incin(a) int a; cin>>a
#define yuko(a) setprecision(a)
//#define min min<int>
//#define max max<int>
template<class T>
 void cou(vector<vector<T>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}
/*template<>
 void cou(vector<vector<char>> a){
  int b=a.size();
  int c=a[0].size();
  fo(i,b){
    fo(j,c){
      cout<<a[i][j];
      if(j==c-1)
        cout<<endl;
      else
        cout<<' ';
    }
  }
}*/
 int wari(int a,int b) {
   if(a%b==0)
     return a/b;
   else
     return a/b+1;
 }
 int keta(int a){
  double b=a;
  b=log10(b);
  int c=b;
  return c+1;
 }
 int souwa(int a){
  return a*(a+1)/2;
 }
 int lcm(int a,int b){
  int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return d*e/f;
    }
  int gcm(int a,int b){
      int d=a,e=b,f;
  if(a<b)
    swap(a,b);
  int c,m=1;
  while(m){
    c=a%b;
    if(c==0){
       f=b;
      m--;
    }
    else{
      a=b;
      b=c;
 }
  }
  return f;
  }
 bool prime(int a){
   if(a<2)
     return false;
   else if(a==2)
     return true;
   else if(a%2==0)
     return false;
   double b=sqrt(a);
    for(int i=3;i<=b;i+=2){
      if(a%i==0){
        return false;
      }
    }
   return true;
 }
struct Union{
  vector<int> par;
  Union(int n){
	par= vector<int>(n, -1);
  }
  int find(int x){
    if(par[x]<0)
      return x;
    else
      return par[x]=find(par[x]);
  }
  bool same(int a,int b){
    return find(a)==find(b);
  }
  int Size(int a){
    return -par[find(a)];
  }
  void unite(int a,int b){
    a=find(a);
    b=find(b);
    if(a==b)
      return;
    if(Size(b)>Size(a))
      swap<int>(a,b);
    par[a]+=par[b];
    par[b]=a;
  }
};
int ketas(int a){
  string b=to_string(a);
  int c=0;
  fo(i,keta(a)){
    c+=b[i]-'0';
  }
  return c;
}
/*struct aa{
	vector<int> gt;
  aa(int n){
	gt= vector<int>(n, 1);
  }
	void c(V<int> d,int b){
	if(d[b]==0){
		gt[d[b]-1]++;
		gt[gt.sz-1]++;
	}
	else{
		gt[d[b]-1]++;
		c(d,d[d[b]]-1);
	}
}
void cok(int a){
	cout<<gt[a-1]<<endl;
	fo(i,a-1)
	cout<<gt[i]<<endl;
}
};
*/
signed main(){
	int a,b,c;
	cin>>a>>b>>c;
	cout<<min(b,c)<<' '<<max(0,b+c-a)<<endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using vi=vector<int>;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string a;
    cin >> a;
    if(a[0] >= 'a' && a[0] <= 'z'){
        cout << "a" << "\n";
        return 0;
    }else if(a[0] >= 'A' && a[0] <= 'Z'){
        cout << "A" << "\n";
        return 0;
    }
}

Measured memory_bytes: 3644