akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>

using namespace std;

typedef long long ll;
// constexpr ll MOD = 998244353;
constexpr ll MOD = 1000000007;

// struct UnionFind {
//     vector<int> par;
    
//     UnionFind(int N): par(N) {
//         for (int i=0;i<N;i++) par[i] = i;
//     }

//     int root(int x) {
//         if (par[x] == x) return x;
//         else return par[x] = root(par[x]);
//     }

//     void unite(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         if (rx == ry) return;
//         par[rx] = ry;
//     }

//     bool same(int x, int y) {
//         int rx = root(x);
//         int ry = root(y);
//         return rx == ry;
//     }
// };

int main(void) {
    int N, Q;
    vector<ll> q(100010,0);
    cin >> N >> Q;
    for (int i=0;i<Q;i++) cin >> q[i];

    if (!Q) {
        vector<ll> a(N+1,1LL);
        for (int i=1;i<=N;i++) {
            cout << a[i] << endl; 
        }
        return 0;
    }
    stack<ll> S;
    S.push(q[0]);
    for (int i=1;i<Q;i++) {
        while (!S.empty() && q[i] <= S.top()) S.pop();
        S.push(q[i]);
    }
    
    int L = S.size();
    vector<ll> a(N+1,0), t(L+1,0), B(L,0);
    for (int i=0;i<L;i++) {
        B[i] = S.top();
// #ifdef DEBUG
//         cout << i << ": " << B[i] << endl;
// #endif
        S.pop();
    }
    if (N < B[L-1]) {
        B.push_back(N);
        L++;
// #ifdef DEBUG
//     cout << L << ": " << B[L] << endl;
// #endif
    }
    t[0] = 1;
    for (int i=0;i<L;i++) {
        ll k = B[i];
#ifdef DEBUG
        cout << "B[" << i << "]: " << k << endl;
#endif
        auto itr = lower_bound(B.begin()+i+1,B.end(),k,greater<ll>());
        while (itr != B.end()) {
            // itr = partition_point(itr+1, B.end(), [&](int x){ return k >= x; });
            int j = itr - B.begin();
#ifdef DEBUG
            cout << "B[" << j << "]: " << B[j] << endl;
#endif
            t[j] += t[i] * (k/B[j]);
            k %= B[j];
#ifdef DEBUG
            cout << "k: " << k << endl;
#endif
            itr = lower_bound(itr+1,B.end(),k,greater<ll>());
        }
//         for (int j=i+1;j<=L;j++) {
//             if (k >= B[j]) {
//                 t[j] += t[i] * (k/B[j]);
//                 k %= B[j];
// //                cout << k << endl;
//             }
//         }
        // for (int m=1;m<=k;m++) a[m] += t[i];
#ifdef DEBUG
        cout << "t[" << i << "]: " << t[i] << endl;
#endif
        a[k] += t[i];
#ifdef DEBUG
        cout << "a[" << k << "]: " << a[k] << endl;
#endif
    }
    for (int i=N-1;i>0;i--) {
        a[i] += a[i+1];
    }
	for (int i=1;i<=N;i++) {
        cout << a[i] << endl; 
    }

    return 0;
}


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

using namespace std;

#define rep(i, n) for(int i = 0; i < (int)n; ++i)
#define FOR(i, a, b) for(int i = a; i < (int)b; ++i)
#define rrep(i, n) for(int i = ((int)n - 1); i >= 0; --i)

typedef long long ll;
typedef long double ld;

const ll INF = 1e18;
const int Inf = 1e9;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(0);
    string s;
    int q;
    cin >> s >> q;
    int r = 0;
    deque<char> dq;
    rep (i, s.size()) dq.push_back(s[i]);
    rep (_, q) {
        int t;
        cin >> t;
        if (t == 1) {
            r++;
        } else {
            int f;
            char c;
            cin >> f >> c;
            if (f == 1) {
                if (r % 2) dq.push_back(c);
                else dq.push_front(c);
            } else {
                if (r % 2) dq.push_front(c);
                else dq.push_back(c);
            }
        }
    }
    string res = "";
    while (!dq.empty()) {
        res += dq.front();
        dq.pop_front();
    }
    if (r % 2) reverse(res.begin(), res.end());
    cout << res << endl;
    
    return 0;
}



Measured memory_bytes: 1368
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;

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

int main(){
	int n, c; cin >> n >> c;
	vector<vector<int> > a(c, vector<int>(w));
	for(int i = 0; i < n; ++i){
		  int s,t,ci; cin >> s >> t >> ci;
		  --s; --ci;
		  ++a[ci][s];
		  --a[ci][t];
    }
    
    for(int i = 0; i < c; ++i){
    	for(int j = 0; j < w-1; ++j){
    	    a[i][j+1] += a[i][j];    	    
        }
for(int j = 0; j < w; ++j){
    	    a[i][j] = min(1, a[i][j]);    	    
        }
    }
    int ans = 0;
    for(int i = 0; i < w; ++i){
    	int tmp = 0;
    	for(int j = 0; j < c; ++j){
    	    tmp  += a[j][i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14072
import java.io.BufferedReader;
import java.io.InputStreamReader;

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

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int r = scanner.nextInt();
        System.out.println(3*r*r);



    }

    private static long gcd(long m, long n) {
        if(m < n) return gcd(n, m);
        if(n == 0) return m;
        return gcd(n, m % n);
    }

    private static long lcm(long m, long n) {
        return m * n / gcd(m, n);
    }

    private class MyScanner {
        String[] s;
        int i;
        BufferedReader br;
        String reg = " ";
        MyScanner () {
            s = new String[0];
            i = 0;
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}

Measured memory_bytes: 21204
#define _CRT_SECURE_NO_WARNINGS

#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>
#include <vector>
#include <cassert>
#include <cstring>
#include <numeric>
#include <set>
#include <queue>
#include <deque>
#include <array>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <map>
#include <functional>
#include <bitset>
#include <complex>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back

using namespace std;
using ll = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using ld = long double;

int main() {
	ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n, D, A;
	cin >> n >> D >> A;
	vector<pii> a(n);
	for (int i = 0; i < n; i++) {
		cin >> a[i].first >> a[i].second;
	}
	sort(all(a));
	vi add(n, 0);
	int cur_dam = 0;
	int pt = -1;
	ll ans = 0;
	for (int i = 0; i < n; i++) {
		cur_dam += add[i];
		int need_bombs = (a[i].second <= cur_dam ? 0 : (a[i].second - cur_dam + A - 1) / A);
		while (pt < n - 1 && a[pt + 1].first - a[i].first <= 2 * D) {
			pt++;
		}
		cur_dam += A * need_bombs;
		if (pt < n - 1) {
			add[pt + 1] -= A * need_bombs;
		}
		ans += need_bombs;
	}
	cout << ans;
}


Measured memory_bytes: 2560
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) printf("Case #%d: ",i);
using namespace std;
typedef long long int ll;
typedef complex<double> com;
typedef pair<int, int> P;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int n; cin >> n;
	vector<vector<int>> e(n);
	rep(i, 0, n - 1) {
		int p1, p2; cin >> p1 >> p2;
		p1--; p2--;
		e[p1].push_back(p2);
		e[p2].push_back(p1);
	}
	vector<int> a(n, -1), b(n, -1);
	a[0] = 0, b[n - 1] = 0;
	queue<int> q; q.push(0);
	while (!q.empty())
	{
		int u = q.front(); q.pop();
		rep(i, 0, e[u].size()) {
			int v = e[u][i];
			if (a[v] < 0) {
				a[v] = a[u] + 1;
				q.push(v);
			}
		}
	}
	q.push(n-1);
	while (!q.empty())
	{
		int u = q.front(); q.pop();
		rep(i, 0, e[u].size()) {
			int v = e[u][i];
			if (b[v] < 0) {
				b[v] = b[u] + 1;
				q.push(v);
			}
		}
	}
	int cnt1 = 0, cnt2 = 0;
	rep(i, 0, n) {
		if (a[i] <= b[i]) cnt1++;
		else cnt2++;
	}
	if (cnt1 > cnt2) printf("Fennec");
	else printf("Snuke");
	return 0;
}

Measured memory_bytes: 6528
import java.io.*;
public class Main {

	public static void main(String[] args) throws IOException{
		InputStreamReader is = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(is);
		
		String str = br.readLine();
		int n = Integer.parseInt(str);
		double debt = 100.0; 
		for(int i = 0; i < n; i++){
			debt = debt * 1.05;
			int deb = (int)debt;
			double pre = debt;
			pre  = pre - (double)deb;
			if(pre != 0.0)
				deb++;
			debt = (double)deb;
		}
		
		
		int deb = (int)debt;
		deb *= 1000;
		System.out.println(deb);		
		
	}

}

Measured memory_bytes: 9332
#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 1000000000
#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 n, a[55];

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++) {
		for (int j = i; j < n; j++) {
			swap(a[i], a[j]);
			bool bl = true;
			for (int k = 1; k < n; k++)if (a[k - 1] > a[k])bl = false;
			if (bl) {
				cout << "YES" << endl;
				return 0;
			}
			swap(a[i], a[j]);
		}
	}
	cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <map>
#include <set>
#include <queue>
using namespace std;

const int MAX_N = 100005;
typedef pair<int, int> pii;

queue<pii> q;
map<pii, int> cnt;
multiset<int> go[MAX_N];
multiset<int>::iterator iter;

int deg[MAX_N];

void add(int x, int y) {
  if (x > y) swap(x, y);
  cnt[make_pair(x, y)]++;
  if (cnt[make_pair(x, y)] == 2) q.push(make_pair(x, y));
  go[x].insert(y), go[y].insert(x);
  deg[x]++, deg[y]++;
}

bool vis[MAX_N];

int N;

int main() {
  scanf("%d", &N);
  for (int i = 1, u, v; i < N * 2 - 1; ++i) {
    scanf("%d%d", &u, &v);
    add(u, v);
  }

  while (!q.empty()) {
    int u = q.front().first, v = q.front().second;
    q.pop();

    if (vis[u] || vis[v]) continue;

    if (deg[u] < deg[v]) swap(u, v);
    vis[v] = 1;

    for (iter = go[v].begin(); iter != go[v].end(); ++iter) {
      if (*iter != u) {
	add(u, *iter);
	go[*iter].erase(go[*iter].find(v));
      }
    }

    go[u].erase(go[u].find(v)), go[u].erase(go[u].find(v));
    go[v].erase(go[v].find(u)), go[v].erase(go[v].find(u));
  }

  int num = 0;
  for (int i = 1; i <= N; ++i)
    if (!vis[i]) num++;

  if (num == 1) puts("YES");
  else puts("NO");
  
  return 0;
}


Measured memory_bytes: 45184
#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 <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <vector>
#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(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin  >> n;
    vector<int>a(n),b(n);
    rep(i,n)cin >> a[i] >> b[i];
    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    if(n&1){
        cout << b[n/2] - a[n/2] + 1 << endl;
    }else{
        cout << b[n/2]+b[n/2-1]-a[n/2]-a[n/2-1] + 1 << endl;
    }
}


Measured memory_bytes: 4768
#include<stdio.h>
#define max 100005
#define NIL -1

typedef struct{
  int p;
  int l;
  int r;
}Node;

Node T[max];
int n,H,D[max];

int Depth(int u){
  int d=0;
  for(;T[u].p!=NIL;d++) u=T[u].p;
  return d;
}

int main(){
  int i,j,k,id,c,l;

  scanf("%d",&n);

  for(i=0;i<n;i++) T[i].p=T[i].l=T[i].r=NIL;

  for(i=0;i<n;i++){
    scanf("%d%d",&id,&k);
    for(j=0;j<k;j++){
      scanf("%d",&c);
      if(j==0) T[id].l=c;
      else T[l].r=c;
      l=c;
      T[c].p=id;
    }
  }

  H=0;
  for(i=0;i<n;i++){
    D[i]=Depth(i);
    if(D[i]>H) H=D[i];
  }

  for(i=0;i<n;i++){
    printf("node %d: parent = %d, depth = %d, ",i,T[i].p,D[i]);

    if(T[i].p==NIL) printf("root, ");
    else if(T[i].l==NIL) printf("leaf, ");
    else printf("internal node, ");
    
    printf("[");
    for(j=0,c=T[i].l;c!=NIL;j++,c=T[c].r){
      if(j) printf(", ");
      printf("%d",c);
    }
    printf("]\n");
  }
  
  return 0;
}



Measured memory_bytes: 3292
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String t = sc.next();
        System.out.println(s.equals(t.substring(0, t.length()-1)) ? "Yes" : "No");
        sc.close();

    }

}


Measured memory_bytes: 35684
#include <bits/stdc++.h>
#define rep3(i, s, n, a) for (int i = (s); i < (int)(n); i += a)
#define rep2(i, s, n) rep3(i, s, n, 1)
#define rep(i, n) rep2(i, 0, n)

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

int main(){
    int R, C, k;
    cin >> R >> C >> k;
    vector<ll> tmp(C+1, 0);
    vector<vector<ll>> v(R+1, tmp), tmp2(R+1, tmp), ans(R+1, tmp);
    vector<vector<vector<ll>>> dp(4, tmp2);
    rep(i, k){
        ll x, y, z;
        cin >> x >> y >> z;
        v[x][y] = z;
    }

    rep2(i, 1, R+1){
        rep2(j, 1, C+1){
            dp[0][i][j] = max(dp[0][i][j-1], ans[i-1][j]);
            rep2(k, 1, 4) {
                dp[k][i][j] = max(dp[k][i][j - 1], max(dp[k - 1][i][j - 1], ans[i - 1][j]) + v[i][j]);
            }
            rep(k, 4) { ans[i][j] = max(ans[i][j], dp[k][i][j]); }
        }
    }

    cout << ans[R][C] << endl;
    return 0;
}

Measured memory_bytes: 496644
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
using pii = pair<int, int>;
using piii = pair<pii, int>;
using pll = pair<ll, ll>;
using pli = pair<ll, int>;
using pil = pair<int, ll>;
using uint = unsigned int;
template <typename T>
using Graph = vector<vector<T>>;
const int MOD = 1e9 + 7;
const ld PI = acosl(-1);

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

    int N, Q;
    cin >> N >> Q;

    fenwick_tree<ll> fw(N);
    for (int i = 0; i < N; ++i) {
        int a;
        cin >> a;
        fw.add(i, a);
    }

    for (int i = 0; i < Q; ++i) {
        int com, a, b;
        cin >> com >> a >> b;
        if (com == 0)
            fw.add(a, b);
        else
            cout << fw.sum(a, b) << '\n';
    }

    return 0;
}


Measured memory_bytes: 8252
MOD = 10 ** 9 + 7

def mult(a, b):
  return ((a % MOD) * (b % MOD)) % MOD

def count_inversion(sequence):
    return sum(sum(m<n for m in sequence[i+1:]) for i,n in enumerate(sequence))

def solve():
  N, K = map(int, input().split())
  A = [int(i) for i in input().split()]
  n = count_inversion(A)
  m = count_inversion(A * 2) - 2 * n

  return (mult(n, K) + mult(m, (K * (K - 1)) // 2)) % MOD

print(solve())

Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

vector<int> a;

int bubbleSort(){
    int cnt = 0;
    bool flag;
    do{
        flag = false;
        for(int i = a.size() - 1; i > 0; i--){
            if(a[i] < a[i - 1]){
                swap(a[i], a[i - 1]);
                flag = true;
                cnt++;
            }
        }
    }while(flag);
    return cnt;
}

int main(){
    int n;
    cin >> n;
    a.resize(n);
    for(auto&& i : a){
        cin >> i;
    }
    int ans = bubbleSort();
    for(int i = 0; i < n - 1; i++){
        cout << a[i] << " ";
    }
    cout << a[n - 1] << "\n";
    cout << ans << "\n";
}


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


int main() {
  int a, b;
  cin >> a >> b;
  string ans = "Alice";
  if(a == b) ans = "Draw";
  else if(b == 1 || a > 1 && b > a) ans = "Bob";
  
  
  cout << ans << endl;
  return 0;
  
}

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


int main()
{
    string S, T;
    //vector<char> S, T;
    cin >> S;
    cin >> T;
    
    T.pop_back();
    if(S == T)
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    



    return 0;
}


Measured memory_bytes: 3624
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int f[3][110];
	memset(f,0,sizeof(f));
	int n;
	cin>>n;
	int a[3][110];
	for(int i=1;i<=2;i++) for(int j=1;j<=n;j++)
	{
		cin>>a[i][j];
		if(i==1)f[i][j]=f[i][j-1]+a[i][j];
	}
	for(int i=1;i<=n;i++) f[2][i]=max(f[1][i],f[2][i-1])+a[2][i];
	cout<<f[2][n];
	return 0;
}

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

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

    string result = "No";
    for (int i = 1; i <= 9; i++) {
        if (n % i == 0) {
            int div = n / i;
            if (div >= 1 && div <= 9) {
                result = "Yes";
            }
        }
    }

    cout << result << endl;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<vector>
#include<queue>
#include<map>
#include<stack>
#include<fstream>
#include<stdlib.h>
#include<set>
#include<climits>
#include<cmath>  
#include<memory.h> 
#include<sstream>
#include<time.h>
#include<iomanip>
using namespace std;
const unsigned long long BIGEST=1000000000000000000+1000000000000000000;
const long long BIGER=1000000000000000000;
const int BIG=1000000000;
const long long MOD=998244353;
//const long long LMOD=154590409516822759;
const long long LMOD=1000000007;
#define Fi first
#define Se second
#define P2 pair
#define Pii pair<int,int>
#define Pll pair<long long,long long>
#define Pil pair<int,long long>
#define Pli pair<long long,int>
#define Cb make_pair
#define ll long long
#define Ull unsigned long long
#define Sf scanf
#define Pf printf
#define Pb push_back
#define Psh push
#define Stc stack
#define Vct vector
#define Ret return
#define Re0 return 0
#define Sz size
#define Is insert
#define Que queue
#define Emp empty
#define Fro front
#define Rv reverse
#define Er erase
#define Bg begin
#define Srt sort
#define Pq priority_queue
#define Ins insert
#define Ite iterator
#define Cou count
#define Cot continue
#define Swp swap
#define Bre break
#define Beg begin
#define Upb upper_bound
#define Lwb lower_bound
#define Str string
int a[1000001];
int main()
{
	int n;
	Sf("%d",&n);
	int g=0;
	for(int i=1;i<=n;i++)
	{
		Sf("%d",&a[i]);
		for(int j=1;j<i;j++)
		{
			if(a[i]==a[j])Cot;
			for(int k=1;k<j;k++)
			{
				if(a[i]==a[k])Cot;
				if(a[j]==a[k])Cot;
				g+=((a[i]+a[j]+a[k]-2*max(a[i],max(a[j],a[k]))>0)?1:0);
			}
		}
	}
	cout<<g;
	return 0;
}

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

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    int n,k;
    cin>>n>>k;

    pair<int,int>p[n];
    for (int i = 0; i < n; ++i) {
        cin>>p[i].second>>p[i].first;
    }

    sort(p,p+n,greater<>());
    map<int,int> mm;
    int ans=0;
    int mx=0,cnt=0;
    for (int i = 0; i < k; ++i) {
        mm[p[i].second]++;
        if(mm[p[i].second]==1)
            cnt++;
        ans+=p[i].first;
    }

    mx=max(mx,cnt*cnt+ans);

    int x=k-1;
    priority_queue<int>s;
    map<int,int>ind;
    for (int i = k; i < n; ++i) {
        if(mm[p[i].second]==0&&ind[p[i].second]==0)
        {
            ind[p[i].second]++;
            s.push(p[i].first);
        }
    }

    while (x>=0)
    {
        if(mm[p[x].second]>1)
        {
            mm[p[x].second]--;
            if(s.empty())
                break;
            ans-=p[x].first;
            ans+=s.top();
            s.pop();
            cnt++;
            mx=max(mx,ans+cnt*cnt);
        }
        x--;
    }

    cout<<mx;
}

Measured memory_bytes: 11640
def main():
    sa = input()
    sb = input()
    sc = input()
    turn = 'a'
    while True:
        if turn == 'a':
            if len(sa) == 0:
                print('A')
                break
            turn = sa[0]
            sa = sa[1:]
        elif turn == 'b':
            if len(sb) == 0:
                print('B')
                break
            turn = sb[0]
            sb = sb[1:]
        else:
            if len(sc) == 0:
                print('C')
                break
            turn = sc[0]
            sc = sc[1:]

if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<cstdio>
using namespace std;
int main()
{
	int n,i,k,q,x,a[100000],cnt[100000];
	scanf("%d %d %d",&n,&k,&q);
	for(i=1;i<=n;i++){
		cnt[i]=0;
	}
	for(i=0;i<q;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	for(i=1;i<=n;i++){
		x=k-q+cnt[i];
		// printf("cnt=%d x=%d\n",cnt[i],x);
		if(x<=0)	printf("No\n");
		else	printf("Yes\n");
	}
	return 0;
}
	

Measured memory_bytes: 1280
#include <algorithm>
#include <array>
#include <bitset>
#include <chrono>
#include <cmath>
#include <iostream>
#include <numeric>
#include <random>
#include <set>
#include <unordered_set>
#include <vector>
#include <list>
#include <functional>

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

using namespace std;

#define LOCAL 1

#if LOCAL
#define pv(val) cerr << #val << " = " << (val) << endl
#define pvn(name, val) cerr << name << " = " << (val) << endl
#define pl cerr << '@' << __LINE__ << endl
#else
#define pv(val)
#define pvn(name, val)
#define pl
#endif

template <class T>
ostream& operator<<(ostream& os, vector<T> const& vec) {
    if (vec.empty()) {
        os << "{}";
    }
    else {
        os << '{';
        for (size_t i = 0; i < vec.size() - 1; i++) os << vec[i] << ", ";
        os << vec.back() << '}';
    }
    return os;
}

template <class T, size_t S>
ostream& operator<<(ostream& os, array<T, S> const& arr) {
    if (arr.empty()) {
        os << "{}";
    }
    else {
        os << '{';
        for (size_t i = 0; i < arr.size() - 1; i++) os << arr[i] << ", ";
        os << arr.back() << '}';
    }
    return os;
}

template <class T, class U>
ostream& operator<<(ostream& os, pair<T, U> const& p) {
    os << '(' << p.first << ", " << p.second << ')';
    return os;
}

template<class T, class U>
pair<T, U> operator+(pair<T, U> const& lhs, pair<T, U> const& rhs) {
    return { lhs.first + rhs.first, lhs.second + rhs.second };
}

template<class T, class U>
pair<T, U> operator-(pair<T, U> const& lhs, pair<T, U> const& rhs) {
    return { lhs.first - rhs.first, lhs.second - rhs.second };
}

template<class T, class U>
U lowerBound(function<T(U)> f, T const& val, U l, U r) {
    while (l < r) {
        auto m = l + (r - l) / 2;
        auto fm = f(m);
        if (fm < val) {
            l = m;
        }
        else {
            r = m;
        }

    }
}

struct UnionFind {
    vector<int> data;
    UnionFind(int size) : data(size, -1) { }
    bool unionSet(int x, int y) {
        x = root(x); y = root(y);
        if (x != y) {
            if (data[y] < data[x]) swap(x, y);
            data[x] += data[y]; data[y] = x;
        }
        return x != y;
    }
    bool findSet(int x, int y) {
        return root(x) == root(y);
    }
    int root(int x) {
        return data[x] < 0 ? x : data[x] = root(data[x]);
    }
    int size(int x) {
        return -data[root(x)];
    }
};

long long int eval(vector<long long int> const& A, long long int b) {
    long long int ans = 0;
    for (int i = 0; i < A.size(); i++) {
        ans += abs(A[i] - b);
    }

    return ans;
}

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

    vector<long long int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
        A[i] -= (i + 1);
    }
    pv(A);
    sort(A.begin(), A.end());

    if(N > 1) cout << min(eval(A, A[N / 2]), eval(A, A[N / 2 - 1])) << endl;
    else cout << 0 << endl;

    return 0;
}


Measured memory_bytes: 1792
N, M = list(map(int, input().split()))
P, Y = [], []
for _ in range(M):
  p, y = list(map(int, input().split()))
  P.append(p)
  Y.append(y)
  
num = ['']*M

pref_dict={i:[] for i in range(1,N+1)}

for i, c in enumerate(zip(P,Y)):
  pref_dict[c[0]].append([i+1, c[1]]) #市i+1, 年Y
  
for p, l in pref_dict.items():
  for i, c in enumerate(sorted(l, key=lambda x:x[1])):
    num[c[0]-1] = '{:06}{:06}'.format(p,i+1)
        
for n in num:
  print(n)
  



Measured memory_bytes: 52380
#pragma region RegionDefs
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include "boost/multi_array.hpp"
#define rep(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define reps(i,j,n) for(int i=(j),i##_len=(n);i<i##_len;++i)
#define repr(i,n) for(int i=(n);i>=0;--i)
#define all(x) begin(x),end(x)
using namespace std;
const int INF = 1e9;
template<class T=int> using P  = pair<T, T>;
template<class T=int> using V  = vector<T>;
template<class T=int> using PQ = priority_queue<T>;
template<class T=int> using PQG = priority_queue<T, V<T>, greater<T>>;
typedef long long ll;
const ll MOD = 1000000007LL;
void in() {}
template<class Head, class... Tail>
void in(Head&& head, Tail&&... tail)
{
    cin >> head;
    in(move(tail)...);
}
#define IN(...) ll __VA_ARGS__; in(__VA_ARGS__)

//時間が厳しいとき使う
#define INI(...) int __VA_ARGS__; in(__VA_ARGS__)
#define INS(T, ...) T __VA_ARGS__; in(__VA_ARGS__)
#define VIN(T, v, n) V<T> v(n); for(auto& _elem:v)cin>>_elem
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 y0 y__0
#define y1 y__1
#define j0 j__0
#define j1 j__1
#pragma endregion RegionDefs

void solve()
{
    string s; cin >> s;
    if (s.size() % 2 == 1)
    {
        cout << "No" << endl;
        return;
    }
    for(int i = 0; i < s.size(); i += 2)
    {
        if (s[i] != 'h' || s[i+1] != 'i')
        {
            cout << "No" << endl;
           return;
        }
    }
    cout << "Yes" << endl;
}

int main()
{
    cin.tie(0); cout.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(numeric_limits<double>::max_digits10);

    solve();

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define MM 1000000000
#define MOD MM+7
#define MAX 101000
#define MAP 110
#define initial_value -1
#define Pair pair<int,int>
#define chmax(a,b) (a<b ? a=b:0)
#define chmin(a,b) (a>b ? a=b:0)
ll INF = 1e18;
int dx[4] = {-1,0,1,0};
int dy[4] = {0,-1,0,1};

int main(){
    int N,K; cin >> N >> K;
    int H[100100];
    for(int i = 0; i < N; i++) cin >> H[i];
    int dp[100100];
    for(int i = 0; i <= 100000; i++) dp[i] = MM;
    dp[0] = 0; dp[1] = abs(H[0] - H[1]);
    for(int i = 0; i < N; i++){
        for(int j = 1; j <= K; j++){
            if(i+j < N) dp[i+j] = min(dp[i] + abs(H[i]-H[i+j]), dp[i+j]);
        }
    }
    cout << dp[N-1] << endl;
}



Measured memory_bytes: 1024
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define PN cout << endl
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (n-1); i >= (int)(m); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - (a)) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - (a)) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

/*
ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
*/

/*
vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}
*/

/*
ll ncr[100][100];
ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

ll npr[100][100]={};
ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

ll nHr(int n,int r){ret nCr(n+r-1,r);}
*/

///////////////////////////////////////////////////////////////////////////



int main(){

    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a != c)P(1);
    else P(0);
    return  0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n, ans;
char s[100001], tmp;
int main() {
	cin >> n;
	cin >> s + 1;
	int cur = 1;
	while (cur <= n) {
		tmp = s[cur];
		while (s[cur] == tmp) {
			cur++;
		}
		ans++;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Collections;

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

	    String line = br.readLine();
	    int a = Integer.parseInt(line.split(" ")[0]);
	    int b = Integer.parseInt(line.split(" ")[1]);
	    int c = Integer.parseInt(line.split(" ")[2]);

	    ArrayList<Integer> list = new ArrayList<>();
	    list.add(a);
	    list.add(b);
	    list.add(c);

	    Collections.sort(list);

	    String[] strArray = new String[list.size()];

	    for (int i = 0; i < list.size(); i++) {
	    	strArray[i] = Integer.toString(list.get(i));
	    }

	    System.out.println(String.join(" ", strArray));

	}
}

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

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

typedef long long LL;
const LL mod=1000000007;
#define MAX 10000
const double PI  = acos(-1.0);

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

const int N = 123456;

int a[N], b[N], c[N];

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

    int N,cnta=0,cntc=0;
    LL ans;
    cin >> N;

    REP(i, N){ cin >> a[i];}
    REP(i, N){ cin >> b[i];}
    REP(i, N){ cin >> c[i];}
    sort(a, a+N);
    sort(b, b+N);
    sort(c, c+N);


    REP(i, N){
        LL numa = lower_bound(a, a + N, b[i]) - a ;
        LL numc = N - (upper_bound(c, c + N,b[i] ) - c) ;
        ans += numa * numc;
    }

    cout << ans;


    return 0;
}


Measured memory_bytes: 1408
import os
import sys
import math
import heapq
from decimal import *
from io import BytesIO, IOBase
from collections import defaultdict, deque

def r():
    return int(input())
def rm():
    return map(int,input().split())
def rl():
    return list(map(int,input().split()))

n,k = rm()
p = rl()
p = [0]+p
c = rl()
c = [0]+c
b = [-1]*(n+1)
give=0
ans=-math.inf

for i in range(1,n+1):
    a=i
    lenn=1
    add=c[i]
    while p[a]!=i:
        add+=c[p[a]]
        lenn+=1
        a=p[a]
    if add<0:
        add=0
    addAgain=0
    a=i
    for j in range(lenn):
        if j>k:
            break
        addAgain+=c[a]
        ans = max(ans, addAgain+add*((k-j-1)//lenn))
        a = p[a]

print(ans)

Measured memory_bytes: 78900
n, m = map(int, input().split())

x = [0 for _ in range(n)]
y = [0 for _ in range(n)]
z = [0 for _ in range(n)]
temp = [0 for _ in range(n)]

for i in range(n):
  a, b, c = map(int, input().split())
  x[i] = a
  y[i] = b
  z[i] = c

result = 0

for i in range(n):
  temp[i] = x[i] + y[i] + z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = x[i] + y[i] - z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = x[i] - y[i] + z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = 0 - x[i] + y[i] + z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = x[i] - y[i] - z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = 0 - x[i] + y[i] - z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = 0 - x[i] - y[i] + z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

for i in range(n):
  temp[i] = 0 - x[i] - y[i] - z[i]
temp.sort()
sum_temp = sum(temp[n - m:])
if sum_temp > result:
  result = sum_temp

print(result)

Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <array>

#define ALPHA 26

#define INPUT_LEN 12
#define INPUT_SIZE 2
#define DATA_SIZE (1 << (INPUT_LEN * INPUT_SIZE))

bool memo[INPUT_LEN][DATA_SIZE];

int encode(const std::string& dna, const std::array<int, ALPHA>& dna_map){
	const int length = dna.length();
	
	int code = 0;
	for(int i = length - 1; i >= 0; i--){
		code <<= INPUT_SIZE;
		code |= dna_map[dna[i] - 'A'];
	}
	
	return code;
}

int main(int argc, char* argv[]){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);	
	
	std::array<int, ALPHA> dna_map;
	dna_map.fill(-1);
	dna_map['A' - 'A'] = 0;
	dna_map['C' - 'A'] = 1;
	dna_map['G' - 'A'] = 2;
	dna_map['T' - 'A'] = 3;

	int n;
	std::cin >> n;

	for(int i = 0; i < n; i++){
		std::string ops, dna;
		std::cin >> ops >> dna;

		const int code = encode(dna, dna_map);
		const int length = dna.length() - 1;

		if(ops == "insert"){ memo[length][code] = true; }
		else{ std::cout << (memo[length][code] ? "yes" : "no") << std::endl; }
	}
	
	return 0;
}

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

// input
int T, X;


void input() {
    cin >> T >> X;
}


int main() {
    input();
    double ans = double(T) / X;
    cout << ans << endl;
}


Measured memory_bytes: 3788
#include<bits/stdc++.h>
using namespace std;
int n, m;
vector<vector<int>> adj(200005);
bool vis[200005];
int sz;

void dfs(int u) {
    vis[u] = 1;
    sz++;
    for (int v: adj[u]) {
        if (!vis[v]) dfs(v);
    }
}

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

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

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

    int ans = 0;
    for (int i = 1; i <= n; i++) {
        if (!vis[i]) {
            sz = 0;
            dfs(i);
            ans = max(ans, sz);
        }
    }

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 20620
A, B, C, D, E, F = map(int, input().split())
W = []
for i in range(F // (A * 100) + 1):
  for j in range(F // (B * 100) + 1):
    if (A * i + B * j) and (A * i + B * j) * 100 <= F:
      W.append(A * i + B * j)
c = [0 for w in W]
for k, w in enumerate(W):
  s_upper = min(w * E, F - w * 100)
  s_max = 0
  for i in range(s_upper // C + 1):
    for j in range(s_upper // D + 1):
      if C * i + D * j <= s_upper:
        s_max = max(C * i + D * j, s_max)
  c[k] = [s_max / (s_max + w * 100), s_max, w]
ans = sorted(c, key=lambda x: x[0], reverse=True)[0]
print(ans[1] + ans[2] * 100, ans[1])
  

Measured memory_bytes: 3064
def main():    
    N = int(input())
    a = list(map(int,input().split()))
    res = 1
    if 0 in a:
        print(0)
        return
    for i in a:
        res *= i
        if res > 10**18:
            print(-1)
            return
    print(res)
if __name__ == "__main__":
    main()

Measured memory_bytes: 21784
#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 < (int)(n); ++i)
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;}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string str; cin>>str;
    ll k; cin>>k;
    char ans='1';
    bool isok = true;
    rep(i, str.size()){
        if(str[i] != '1' && i<k){
            ans =str[i];
            break;
        }
    }
    cout<<ans<<endl;
}

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

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int,int> pii;
typedef pair<double, double> pdd;
typedef pair<ll, ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;
typedef vector<pdd> vdd;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define mem(a,b) memset(a, b, sizeof(a) )
#define all(x) (x).begin(),(x).end()
#define INF 1000000000000
#define MOD 1000000007
#define PB push_back
#define MP make_pair
#define F first
#define S second

inline void normal(ll &a) { a %= MOD; (a < 0) && (a += MOD); }
inline ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline ll modPow(ll b, ll p) { ll r = 1; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline ll modInverse(ll a) { return modPow(a, MOD-2); }
inline ll modDiv(ll a, ll b) { return modMul(a, modInverse(b)); }

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

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main(){
	int n,m;cin>>n>>m;
	vi a(m),b(m),c(n,0);
	rep(i,m){
		cin>>a[i]>>b[i];
		a[i]--;b[i]--;
		c[a[i]]++;
		c[b[i]]++;
	}
	rep(i,n)cout<<c[i]<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,arr[100005],ans,DP[100005],k;

int dp(int id){
//	printf("%d\n",id);
	if(id>=n-1)return 0;
	if(DP[id]!=-1) return DP[id];
	int ret = 1000000000;
	for (int i = 1;i<=k;i++){
		if(id+i<=n-1)ret = min(ret, dp(id+i)+abs(arr[id]-arr[id+i]));
	}
	return DP[id] = ret;
}

int main(){
	memset(DP,-1,sizeof(DP));
	scanf("%d%d",&n,&k);
	for (int i =0;i<n;i++){
		scanf("%d",&arr[i]);
	}
	ans = dp(0);
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <algorithm>
#define N 52
using namespace std;
typedef long long ll;
ll n, s;
int main() {
  cin>>n>>s;
  ll ans=-1;
  for (ll b = 2; b *b <= n; ++b) {
   // cout<<"b="<<b<<endl;
    ll sum=0;
    ll x = n;
    while(x) {
      sum += x % b;
      x /= b;
    }
    if (sum == s) {
      ans = b;
      break;
    }
  }
 // cout<<"ans="<<ans<<endl;
  // if (s == 1) {
  //   ans = (ans < 0 ? n : min(n, ans));
  // }
  // if (s == 2) {
  //   ans = (ans < 0 ? n-1 : min(n-1, ans));
  // }
  for (ll x = 1; x * x <= n-s; ++x) {
    if ((n-s) % x == 0) {
      ll a = (n-s)/x;
      if (n/(x+1) == a && a < (x+1) && n % (x+1) + n / (x+1) == s) {
        ans = (ans < 0 ? x+1 : min(x+1, ans));
      }
      if (n/(a+1) == x && x < (a+1) && n % (a+1) + n / (a+1) == s) {
        ans = (ans < 0 ? a+1 : min(a+1, ans));
      }
    }
  }
  if (s == n) {
    ans = (ans < 0 ? n+1 : min(ans, n+1));
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void)
{
	double x1,y1,x2,y2;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	printf("%.6lf\n",sqrt(pow(x2-x1,2)+pow(y2-y1,2)));
	return 0;
}

Measured memory_bytes: 656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
using P = pair<int, int>;

/*
一番高い商品に一枚使うをM回繰り返せばいい
しかし愚直に実装するとO(NlogN * M)となってしまう
今N=10^5なので、O(NlogN)くらいにしないといけない
解説を読むと、優先度付きキューを使うと出てくる。
*/

/*
priority_queueを使うと
勝手に大きい順にソートしてくれるので
結構早くできる
*/

int main()
{
  ll N,M;cin>>N>>M;
  vector<int> A(N);
  priority_queue<int> pq;
  for (int i=0;i<N;i++)
  {
    cin>>A[i];
    pq.push(A[i]);
  }
  
  for (int i=0;i<M;i++)
  {
    int top=pq.top();
    pq.pop();
    pq.push(top/2);
  }
  
  ll sum=0;
  for (int i=0;i<N;i++)
  {
     sum += pq.top();
     pq.pop();
  }
  cout<<sum<<endl;
}

Measured memory_bytes: 1276
#include "bits/stdc++.h"
#define lp(i, n) for(int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using l = long;
using vi = vector<int>;
using vl = vector<l>;
using vll = vector<ll>;
using vvl = vector<vector<l>>;
using vvll = vector<vector<ll>>;
using pll = pair<ll, ll>;
using un = unsigned;

int n, res = 0, ccc = 0;
string s;

int main()
{
	int n, k, d, a; cin >> n >> k;
	vi v(n, 0);
	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> a;
			v[a - 1] += 1;
		}
	}
	int cnt = 0;
	for (int i = 0; i < n; i++) {
		if (v[i] == 0) cnt++;
	}

	cout << cnt;
}



Measured memory_bytes: 3604
using System;
namespace AtCoder
{
    class Program
    {

        static void Main(string[] args)
        {
            string a = "\n", b = Console.ReadLine();
            int i = GetFunc(() => 1)();
            var mask = new []{ 1, 2, +3 };
            foreach (var item in b)
            {
                mask[
                GetFunc(() =>
                {
                    if (0 <= (i % 2 - 1)) Console.Write("{0}", item, i);
                    return (i += 1) % 2;
                })()
                ] = 1;
            }
        }
        
        static Func<T> GetFunc<T>(Func<T> func) => func; 

    }
}


Measured memory_bytes: 15452
#include <iostream>
#include <map>
#include <set>

#define HW 160
using namespace std;

/*struct rect
{
	int h;
	int w;
	int tai;
};*/

int main(int argc, char const *argv[])
{
	int h,w;

	map<int,set<pair<int,int> > > mp;

	for(int i1=1;i1<HW;i1++){
		for(int i2=i1+1;i2<HW;i2++){
			mp[i1*i1+i2*i2].insert(make_pair(i1,i2));
		}
	}

	while(1){
		cin>>h>>w;
		if(h+w==0) break;

		map<int,set<pair<int,int> > >::iterator it=mp.lower_bound(h*h+w*w);
		if(it!=mp.end()) {
			//cout<<(*it).first<<"a";
			set<pair<int,int> >::iterator is=(*it).second.upper_bound(make_pair(h,w));

			if(is!=(*it).second.end()) {
				cout<<(*is).first<<" "<<(*is).second<<endl;
				//cout<<(*is).second<<"b";
				/*if((is++)==(*it).second.end()){
					//cout<<"c";
					it++;
					is=(*it).second.begin();
					cout<<(*is).first<<" "<<(*is).second<<endl;
				}
				else */
			}
			else {
				it++;
				is=(*it).second.begin();
				cout<<(*is).first<<" "<<(*is).second<<endl;	
			}
		}


	}
	return 0;
}

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

int main() {
	
	  long long int n,mx=0;
	  cin>>n;
	   vector <string>v;
	   string s;
	   for(int i=0;i<n;i++)
	   {
	   cin>>s;
	   v.push_back(s);
	   }
	   sort(v.begin(),v.end());
	   map<string,long long int>m;
	   for(int i=0;i<n;i++)
	   {
	       m[v[i]]++;
	   }
	   for(auto i=m.begin();i!=m.end();i++)
	   {
	       mx=max(i->second,mx);
	   }
	   for(auto i=m.begin();i!=m.end();i++)
	   {
	       if(i->second==mx)
	       cout<<i->first<<"\n";
	   }
	   
	   
	return 0;
}

Measured memory_bytes: 26736
#include<stdio.h>
int main(void)
{
	int a, b, c;

	scanf("%d %d %d", &a, &b, &c);
	int sa;
	sa = a - b;
	c -= sa;
	if (c < 0) {
		printf("0\n");
	}
	else {
		printf("%d\n", c);
	}
	return 0;
}

Measured memory_bytes: 128