akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0);
  int n,d;
  cin >> n >> d;
  two_sat ts(n);
  vector<int> x(n),y(n);
  for(int i = 0; i < n; ++i) cin >> x[i] >> y[i];
  for(int i = 0; i < n; ++i){
    for(int j = i+1; j < n; ++j){
      if(abs(x[i]-x[j]) < d) ts.add_clause(i,false,j,false);
      if(abs(x[i]-y[j]) < d) ts.add_clause(i,false,j,true);
      if(abs(y[i]-x[j]) < d) ts.add_clause(i,true,j,false);
      if(abs(y[i]-y[j]) < d) ts.add_clause(i,true,j,true);
    }
  }
  if(ts.satisfiable()){
    cout << "Yes\n";
    vector<bool> ans = ts.answer();
    for(int i = 0; i < n; ++i){
      if(ans[i]) cout << x[i] << '\n';
      else cout << y[i] << '\n';
    }
  }
  else cout << "No";
  return 0;
}

Measured memory_bytes: 3692
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
vector<ll> luca(100, 0);


int main(){
    ll N;
    cin >> N;
    luca[0] = 2;
    luca[1] = 1;
    for(int i = 2; i < 90; i++) {
        luca[i] = luca[i - 1] + luca[i - 2];
    }

    cout << luca[N] << endl;


}


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

#define ll long long
using namespace std;

const int N = 1e5 + 5;
int n, k, h[N];
ll dp[N];

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    dp[1] = 0;
    for(int i = 1; i <= n; i++) {
        cin >> h[i];
    }
    for(int i = 2; i <= n; i++) {
        dp[i] = abs(h[i] - h[i - 1]) + dp[i - 1];
        for(int j = 2; j <= k && i - j >= 1; j++) {
            dp[i] = min(dp[i], abs(h[i] - h[i - j]) + dp[i - j]);
        }
    }
    cout << dp[n] << endl;
}

Measured memory_bytes: 1408
//$g++ -std=c++11 Template.cpp 

//#include <bits/stdc++.h>
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
#include <climits>
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define ROF(i, j, k) for(int i = (int)(j); i >= (int)(k); --i)
#define FORLL(i, n, m) for(long long i = n; i < (long long)(m); i++)
#define SORT(v, n) sort(v, v+n)
#define REVERSE(v) reverse((v).begin(), (v).end())

using namespace std;
using ll = long long;
const ll MOD=1000000007LL;
typedef pair<int, int> P;

ll ADD(ll x, ll y) { return (x+y) % MOD; }
ll SUB(ll x, ll y) { return (x-y+MOD) % MOD; }
ll MUL(ll x, ll y) { return x*y % MOD; }
ll POW(ll x, ll e) { ll v=1; for(; e; x=MUL(x,x), e>>=1) if (e&1) v = MUL(v,x); return v; }
ll DIV(ll x, ll y) { /*assert(y%MOD!=0);*/ return MUL(x, POW(y, MOD-2)); }

priority_queue<int> q_descending;
priority_queue<int, vector<int>, greater<int> > q_ascending;

ll array[100];

ll digits(ll n){
  int ans=0;
  while(n){
    ans += n%10;
    n /= 10;
  }
  return ans;
}

bool compare(ll x, ll y){
  return digits(y)*x <= y*digits(x);
}

int
main(void){  
  ios_base::sync_with_stdio(false);

  ll k;
  cin >> k;  
  
  ll d = 1, cur = 0;

  REP(i, k){
    ll x = cur + d, y = cur + d * 10;
    if(compare(x, y)){
      cur = x;
    }
    else{
      cur = y;
      d *= 10;      
    }
    cout << cur << endl;
  }
  
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define rep(i, n) for (ll i = 0; i < n; i++)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define is(a, b) a == b
#define len(v) ll(v.size())

class UnionFind {
public:
	vector<int> par;//親の番号
    vector<int> rank;//木の深さ
 
	UnionFind(int n){//全ての要素に対して自身が根となるように初期化, 木の深さは0になる
		rep(i,n){
            par.push_back(i);
            rank.push_back(0);
        }
	}
 
	int find(int x) {//木の根を求める
		if(par[x]==x){
            return x;
        }else{
            return par[x]=find(par[x]);
        }
	}
 
	void unite(int x,int y){//xとyの属する集合を併合
        x=find(x);
        y=find(y);
        if(x==y) return;
        if(rank[x]<rank[y]){//木の深さが小さい方を大きい方へ繋げる
            par[x]=y;
        }else{
            par[y]=x;
            if(rank[x]==rank[y]) rank[x]++;
        }
    }

    bool same(int x,int y){//xとyが同じ集合に属するか否か
        return find(x)==find(y);
    }
};
//x以下の要素への最小index, ソートしてから使ってね
template <class T> 
int former(const vector<T> &v, T x){
  return upper_bound(v.begin(), v.end(), x) - v.begin() - 1;
}
//x以上の要素への最小index
template <class T> 
int latter(const vector<T> &v, T x){
  return lower_bound(v.begin(), v.end(), x) - v.begin();
}
//vector書き出し
template <class T>
void cout_vec(const vector<T> &vec1){
  rep(i,len(vec1)){
    cout<<vec1[i]<<' ';
  }
  cout<<'\n';
}
//nCk
template <class T>
T comb(T n,T k){
    T ans=1;
    FOR(i,n-k+1,n+1){
        ans*=i;
    }
    FOR(i,1,k+1){
        ans/=i;
    }
    return ans;
}
//a,bの最大公約数
template <class T>
T gcd(T a,T b) {
	if (b == 0) return a;
	else return gcd(b, a % b);
}
//素因数分解
template <class T>
map<T,T> prime_factor(T x){
    map<T,T> ans;
    for(T i=2;i*i<=x;i++){
        while(x%i==0){
            x/=i;
            ans[i]++;
        }
    }
    if (x!=1){
        ans[x]=1;
    }
    return ans;
}
//約数列挙
template <class T>
vector<T> divisor(T x){
    vector<T> res;
    for(T i=1;i*i<=x;i++){
        if(x%i==0){
            res.push_back(i);
            if(i!=x/i){
                res.push_back(x/i);
            }
        }
    }
    return res;
}
//素数判定
template <class T>
bool is_prime(T x){
    for(T i=2;i*i<=x;i++){
        if(x%i==0){
            return false;
        }
    }
    return x!=1;
}

const ll inf=1e9+7;

ll mult(ll n,ll m){//n^m%infを求める
    if(m==1){
        return n%inf;
    }else if(m%2==0){//オーバーフロー防止のためにn^(m/2)*n^(m/2)を考える
        ll t=mult(n,m/2);
        return (t*t)%inf;
    }else{//奇数の時はn^(m-1)*nを考える
        ll t=mult(n,m-1);
        return (t*n)%inf;
    }
}

typedef pair<ll,ll> P;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin>>n;
    vector<int> a(n+1);
    int ans=1;
    FOR(i,1,n+1){
        cin>>a[i];
    }
    int next=a[1];
    bool flag=false;
    while(true){
        if(next==2){
            flag=true;
            break;
        }
        ans++;
        next=a[next];
        if(ans>1e7){
            break;
        }
    }
    if(flag){
        cout<<ans<<endl;
    }else{
        cout<<-1<<endl;
    }
}

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

int main() {
  int X;
  cin >> X;
  vector<int> beki(0);
  beki.push_back(1);

  for(int i=2;;i++) {
    if(pow(i, 2) > 1500) {
      break;
    }
    for(int j=2;;j++) {
      if(pow(i, j) <= 1500) {
        beki.push_back(pow(i, j));
      } else {
        break;
      }
    }
  }

  sort(beki.begin(), beki.end());

  int ans = 0;

  for(int i=0;i<beki.size();i++) {
    if(beki[i] > X) {
      ans = beki[i-1];
      break;
    }
  }

  cout << ans << endl;
}

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

const int N = 4005;
int n, a[N], par[N];
int pos[N];
int dep[N];
bool vis[N];
bool del[N];
set<int> G[N];
vector<int> queries;

void query(int u) {
	if (!u) return;
	queries.push_back(u);
	int cur = a[u];
	a[u] = a[0];
	while(true) {
		u = par[u];
		if (u == -1) break;
		int new_cur = a[u];
		a[u] = cur;
		cur = new_cur;
	}
}

int main() {
	ios_base::sync_with_stdio(false); cin.tie(0);
	cin >> n;
	par[0] = -1;
	for (int i = 1; i < n; ++i) {
		cin >> par[i], G[par[i]].insert(i), dep[i] = dep[par[i]] + 1;
	}
	for (int i = 0; i < n; ++i) cin >> a[i];
	for (int i = 0; i < n; ++i) pos[i] = -1;

	vector< vector<int> > useless;
	while(true) {
		useless.clear();
		// find useless chains
		queue <int> q;
		for (int i = 0; i < n; ++i) if (!del[i] && G[i].size() == 0) {
			pos[i] = useless.size();
			useless.push_back(vector<int>(1, i));
			q.push(i);
		}
		if (useless.empty()) break;

		while(!q.empty()) {
			int u = q.front(); q.pop();
			if (u == 0) break;
			int p = par[u];
			if (G[p].size() == 1) { // p has only one child u
				pos[p] = pos[u]; useless[pos[p]].push_back(p); q.push(p);
			}
		}

		// for (auto &vec : useless) {
		// 	for (auto &u : vec) cerr << u << ' '; cerr << endl;
		// }

		// solve
		int nleave = 0;
		for (auto &vec : useless) nleave += vec.size(); // vec: from bottom to top

		int ndone = 0;
		while(ndone < nleave) {
			if (pos[a[0]] != -1) { // in useless chain
				int curpos = pos[a[0]];
				int where = 0;
				for (int i = 0; i < useless[curpos].size(); ++i) {
					int u = useless[curpos][i];
					if (!vis[a[u]]) continue;
					if (a[u] > a[0]) ++where; else break; // a[u] < a[0]
				}
				vis[a[0]] = true;
				query(useless[curpos][where]);
				//for (int i = 0; i < n; ++i) cerr << a[i] << ' '; cerr << endl;
				++ndone;
			} else {
				int u = 0;
				for (int i = 0; i < n; ++i) if (!del[i] && !vis[a[i]] && pos[a[i]] != -1 && dep[i] > dep[u]) u = i;
				query(u);
			}
		}

		// erase
		for (auto &vec : useless) {
			for (auto &u : vec) {
				if (u != 0) G[par[u]].erase(u);
				del[u] = true;
			}
		}
	}

	cout << queries.size() << endl;
	for (int u : queries) cout << u << endl;
}

Measured memory_bytes: 768
import sys
import math
import itertools
import bisect
from copy import copy
from collections import deque,Counter
from decimal import Decimal
def s(): return input()
def i(): return int(input())
def S(): return input().split()
def X(): return list(input())
def I(): return map(int,input().split())
def L(): return list(input().split())
def l(): return list(map(int,input().split()))
def lcm(a,b): return a*b//math.gcd(a,b)
sys.setrecursionlimit(10 ** 9)
mod = 10**9+7

S = X()
S[3] = "8"
print("".join(S))


Measured memory_bytes: 9856
#include <cstdio>
#include <iostream>
#include <vector>
#include <queue>
#include <map>
#include <algorithm>
#include <cmath>
#include <string>
#include <cctype>
#include <cstdlib>
#include <typeinfo>

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

using namespace std;

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

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

void trace(int A[], int N) {
    for (int i = 0; i < N; ++i) {
        if (i > 0) cout << " ";
        cout << A[i];
    }
    cout << endl;
}

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

const unsigned long long INF = 1LL << 60;

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

string s, p;

int main() {
    cin >> s >> p;
    string ss = s + s;
    if (ss.find(p) == string::npos) {
        cout << "No" << endl;
    } else {
        cout << "Yes" << endl;
    }
}



Measured memory_bytes: 3212
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(ll i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int mod = 1e9+7;
const int MAX = 510000;
const int V = 100005;
ll dy[8] = {1,0,-1,0,1,-1,1,-1};
ll dx[8] = {0,1,0,-1,1,-1,-1,1};
const double pi = acos(-1);
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << endl;}
#define INT_MAX 1e9+7

int main(){
    ll n; cin >> n;
    rep(i,50001){
        if(i*108/100==n){
            cout << i << endl;
            return 0;
        }
    }
    puts(":(");
}


Measured memory_bytes: 256
n = int(input())
dp = [0] * (1 << n)
dp[0] = 1
curr = {0}
MOD = 10 ** 9 + 7
for i in range(n):
    compatibilities = [1 << i for i, v in enumerate(input().split()) if v == '1']
    nxt = set()
    for k in curr:
        p = dp[k] % MOD
        for c in compatibilities:
            if k & c:
                continue
            dp[k | c] += p
            nxt.add(k | c)
    curr = nxt
print(dp[(1 << n) - 1] % MOD)


Measured memory_bytes: 137188
/*************************************************************************
    > File Name: test.cpp
    > Author: Akira 
    > Mail: qaq.febr2.qaq@gmail.com 
 ************************************************************************/

#include<bits/stdc++.h>
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
#define MST(a,b) memset(a,b,sizeof(a))
#define CLR(a) MST(a,0)
#define Sqr(a) ((a)*(a))
using namespace std;

#define MaxN 100001
#define MaxM MaxN*10
#define INF 0x3f3f3f3f
#define PI 3.1415926535897932384626
const int mod = 1E9+7;
const double eps = 1e-6;
#define bug cout<<88888888<<endl;
#define debug(x) cout << #x" = " << x << endl;

int a,b,c;

int main()
{
    //std::ios::sync_with_stdio(false);
    while(~scanf("%d%d%d", &a, &b, &c))
    {
        if(b-a == c-b) puts("YES");
        else puts("NO");
    }
    //system("pause");
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        MyScanner in = new MyScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        A solver = new A();
        solver.solve(1, in, out);
        out.close();
    }

    static class A {
        public void solve(int testNumber, MyScanner in, PrintWriter out) {
            char c = in.next().charAt(0);
            out.println((char) (c + 1));
        }

    }

    static class MyScanner {
        private BufferedReader in;
        private StringTokenizer st;

        public MyScanner(InputStream stream) {
            in = new BufferedReader(new InputStreamReader(stream));
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String rl = in.readLine();
                    if (rl == null) {
                        return null;
                    }
                    st = new StringTokenizer(rl);
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }

    }
}



Measured memory_bytes: 21460
#include <stdio.h>
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <vector>
#include <string>
#include <algorithm>
#include <cstdlib>
#include <limits>
#include <numeric>

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;

int main()
{
	int a, b,ans;
	cin >> a >> b;
	ans = a-1;
	if (b >= a)cout << ans + 1 << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
  n = int(input())
  l = []
  a,b = 0,1
  for x in range(n+1):
    if x%15==0:
      pass
     # l.append('FizzBuzz')
    elif x%5==0:
      pass
     # l.append('Buzz')
    elif x%3==0:
      pass
     # l.append('Fizz')
    else:
      l.append(x)
      
  print(sum(l))    


if __name__ == '__main__':
  main()

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

using namespace std;

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

  int n, k;
  cin >> n >> k;
  set<char> hsh;
  char c;
  for (int i = 0; i < k; ++i) {
    cin >> c;
    hsh.insert(c);
  }
  string res;
  for (int i = n; i <= 999999; ++i) {
    ostringstream oss;
    oss << i;
    string num = oss.str();
    bool ok = true;
    for (auto &x : num) {
      if (hsh.find(x) != hsh.end()) {
        ok = false;
        break;
      }
    }
    if (ok) {
      res = num;
      break;
    }
  }
  cout << res << endl;

  return 0;
}



Measured memory_bytes: 256
N = int(input())
P = list(map(int, input().split()))
Q = list(map(int, input().split()))
assert len(P) == N
assert len(Q) == N

import itertools
a = 0
b = 0
for i,nums in enumerate(itertools.permutations(range(1,N+1))):
  if list(nums) == P:
    a = i
  if list(nums) == Q:
    b = i
print(abs(b - a))

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

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

    int ans = 0;
    long long x = N;
    for (long long i = 2; i * i <= N; i++) {
        if (x % i != 0) continue;
        int cnt = 0;
        while (x % i == 0) {
            x /= i;
            cnt++;
        }
        int j = 1;
        while (cnt >= j) {
            cnt -= j;
            j++;
            ans++;
        }
    }

    if (x != 1) ans++;

    cout << ans << endl;
}

Measured memory_bytes: 3648
import java.util.*;

public class Main {

    void run() {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        HashMap<String, Integer> map = new HashMap<>();
        for (int i = 0; i < n; i++) {
            String s = sc.next();
            map.put(s, map.getOrDefault(s, 0) + 1);
        }
        int ans = 0;
        for (Map.Entry<String, Integer> entry: map.entrySet()) {
            ans = Math.max(ans, entry.getValue());
        }

        ArrayList<String> o = new ArrayList<>();
        for (Map.Entry<String, Integer> entry: map.entrySet()) {
            if (ans == entry.getValue()) {
                o.add(entry.getKey());
            }
        }
        Collections.sort(o);

        for (String s: o) {
            System.out.println(s);
        }
    }

    void debug(Object... os) {
        System.err.println(Arrays.deepToString(os));
    }

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

}


Measured memory_bytes: 87552
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LS()
    return l
sys.setrecursionlimit(1000000)
mod = 1000000007

#A
def A():
    p,q,r = LI()
    print(p+q+r-max(p,q,r))
    return

#B
def B():
    n = I()
    w = LI()
    ans = float("inf")
    for i in range(n):
        m = sum(w[:i])
        l = sum(w[i:])
        ans = min(ans,abs(m-l))
    print(ans)
    return

#C
def C():
    n,m = LI()
    f = [1 for i in range(n+1)]
    for i in range(m):
        a = I()
        f[a] = 0
    dp = [0 for i in range(n+1)]
    dp[0] = 1
    for i in range(1,n+1):
        if f[i]:
            dp[i] = dp[i-1]+dp[i-2]
            dp[i] %= mod
    print(dp[n])
    return

#D
def D():
    h,w = LI()
    s = SR(h)
    vi = [[0 for j in range(w)] for i in range(h)]
    ho = [[0 for j in range(w)] for i in range(h)]
    q = deque()
    for y in range(h):
        for x in range(w):
            if s[y][x] == "#":
                l = len(q)
                while q:
                    i,j = q.pop()
                    vi[i][j] = l
            else:
                q.append((y,x))
        l = len(q)
        while q:
            i,j = q.pop()
            vi[i][j] = l
    for x in range(w):
        for y in range(h):
            if s[y][x] == "#":
                l = len(q)
                while q:
                    i,j = q.pop()
                    ho[i][j] = l
            else:
                q.append((y,x))
        l = len(q)
        while q:
            i,j = q.pop()
            ho[i][j] = l
    ans = 0
    for y in range(h):
        for x in range(w):
            ans = max(ans,vi[y][x]+ho[y][x]-1)
    print(ans)
    return

#E
def E():
    n = I()

    return

#F
def F():
    n = I()

    return

#Solve
if __name__ == "__main__":
    D()


Measured memory_bytes: 249992
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
#define all(n) begin(n),end(n)
struct cww{cww(){ios::sync_with_stdio(false);cin.tie(0);}}star;
const long long inf = numeric_limits<long long>::max();
int main()
{
  int n;
  cin >> n;
  int ans = 0;
  rep(i, 3) {
    int p = pow(10, i);
    int v = n % 10;
    if (v == 9) {
      ans += 1*p;
    } else if (v == 1) {
      ans += 9*p;
    } else {
      ans += v * p;
    }
    n /= 10;
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 512
#バスの定員C人　Ti <= Ti + kのバスに乗りたい
n,c,k = map(int, input().split())
t = list(int(input()) for _ in range(n))
t.sort()

T = 0
x = 0
ans = 0
for i in range(n):
    if x == 0: #誰も待ってない状態
        T = t[i] + k
        x += 1
    elif t[i] <= T: #バス待ってる人
        x += 1
    elif t[i] > T: #time over
        ans += 1
        x = 1
        T = t[i] + k
    if x == c: #定員に達していたらバス出発
        ans += 1
        T = 0
        x = 0
if x != 0: ans += 1
print(ans)

Measured memory_bytes: 7392
s=input()
b=0
for i in range(len(s)):
  if s[i] != s[-i-1]:
    b=1
    break
for j in range(int((len(s)-1)/2)):
  if s[j] != s[int((len(s)-1)/2)-j-1]:
    b=1
    break
if b==1:
  print("No")
else:
  print("Yes")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0;i<n;i++)
#define erep(i,n) for(int i = 0;i<=n;i++)
#define rep1(i,n) for(int i = 1;i<n;i++)
#define erep1(i,n) for(int i = 1;i<=n;i++)
typedef long long ll;
#define vint vector<int>
#define vvint vector<vector<int>>
#define vstring vector<string>
#define vdouble vector<double>
#define vll vector<ll>:
#define vbool vector<bool>
#define INF 1101010101010101010
#define MOD 1000000007
#define int long long
using P = pair<int,int>;

signed main(){
  int n,k;
  cin >> n >> k;
  string s;
  cin >> s;
  vector<int> num;
  if(s[0] == '0') num.push_back(0);
  for(int i = 0;i < s.size();){
    int j = i;
    while(j < s.size() && s[j] == s[i]) j++;
    num.push_back(j-i);
    i = j;
  }
  vector<int> sums(num.size()+1,0);
  rep(i,num.size()) sums[i+1] = sums[i] + num[i];
  int ans = 0;
  for(int left = 0;left < sums.size();left+=2){
    int right = left + 2*k + 1;
    if(right > sums.size()-1) right = sums.size()-1; 
    ans = max(ans,sums[right] - sums[left]);
  }
  cout << ans << endl;
}

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

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

  int ans = 0;

  for(int i=0;i<1000;i++) {
    stringstream ss;
    ss << setw(3) << setfill('0') << i;
    string str = ss.str();

    bool first = false;
    bool second = false;
    bool third = false;

    for(int j=0;j<n;j++) {
      if(s[j] == str[0] && !first) first = true;
      else if (s[j] == str[1] && first && !second) second = true;
      else if (s[j] == str[2] && first && second) {
        third = true;
        break;
      }
    }

    if(first && second && third) ans++;
  }

  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main()
{
    string s, t;
    int ans = 0;
    cin >> s >> t;
    for(size_t i = 0; i < s.size(); i++) {
        if(s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3788
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {

	int n; cin >> n;
	vector<int> a(n);

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

	vector<int> ans;

	for (int i = 0; i < n; i++) {
		for (int j = n-i-1; j >=0; j--) {
			if (a[j] == (j+1)) {
				ans.push_back(j + 1);
				a.erase(a.begin() + j);
				break;
			}
		}
	}

	if (ans.size() == n) {
		reverse(ans.begin(), ans.end());

		for (int i = 0; i < n; i++) {
			cout << ans[i] << endl;
		}
	}
	else {
		cout << "-1" << endl;
	}

	return 0;
}

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

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define For(i,a,b) for(int (i)=(a); (i)<(b); (i)++)

int main() {
    char c[1200];
    cin.getline(c, sizeof(c));
    int i = 0;
    while(c[i] != '\0') {
        if (islower(c[i])) {
            cout << (char)toupper(c[i]);
        }else if (isupper(c[i])) {
            cout << (char)tolower(c[i]);
        }else {
            cout << (char)c[i];
        }
        i++;
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 1124
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
#define rep(i,n) for(long long int (i)=0;(i)<(n);++(i))
#define ref(i,a,b) for (long long int (i)=(a); (i)<=(b); ++(i))
#define INF 0xFFFFFF
#define endl '\n'
#define pb push_back
#define mp make_pair
const unsigned int mod = 1e9+7;
const int mx=1000005;

int main(){
	/*freopen("input.in", "r", stdin);
	freopen("output.out", "w", stdout);*/  
	ios_base::sync_with_stdio(false);cin.tie(NULL);
	long long a,b,c;cin >> a >> b >> c;
	if(c-a-b<2)cout << b+c << endl;
	else cout << (a+b+1+b) << endl;

}
	

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> mp;
ll inf =  1e9;

template<typename T,T MOD = 1000000007>
struct Mint{
    T v;
    vector<Mint> fact;
    vector<Mint> fact_inv;
    Mint():v(0){}
    Mint(signed v):v(v){}
    Mint(long long t){v=t%MOD;if(v<0) v+=MOD;}

    Mint pow(long long k){
        Mint res(1),tmp(v);
        while(k){
            if(k&1) res*=tmp;
            tmp*=tmp;
            k>>=1;
        }
        return res;
    }

    static Mint add_identity(){return Mint(0);}
    static Mint mul_identity(){return Mint(1);}

    Mint inv(){return pow(MOD-2);}

    Mint& operator+=(Mint a){v+=a.v;if(v>=MOD)v-=MOD;return *this;}
    Mint& operator-=(Mint a){v+=MOD-a.v;if(v>=MOD)v-=MOD;return *this;}
    Mint& operator*=(Mint a){v=1LL*v*a.v%MOD;return *this;}
    Mint& operator/=(Mint a){return (*this)*=a.inv();}

    Mint operator+(Mint a) const{return Mint(v)+=a;};
    Mint operator-(Mint a) const{return Mint(v)-=a;};
    Mint operator*(Mint a) const{return Mint(v)*=a;};
    Mint operator/(Mint a) const{return Mint(v)/=a;};

    Mint operator-() const{return v?Mint(MOD-v):Mint(v);}

    bool operator==(const Mint a)const{return v==a.v;}
    bool operator!=(const Mint a)const{return v!=a.v;}
    bool operator <(const Mint a)const{return v <a.v;}
    
    Mint comb(long long n,int k){
        Mint res(1);
        for(int i=0;i<k;i++){
            res*=Mint(n-i);
            res/=Mint(i+1);
        }
        return res;
    }
};

Mint<ll> P[400010];
void make(){
    P[0] = P[1] = 1;
    for(ll i=2;i<=400009;i++){
	P[i] = P[i-1]*Mint<ll>(i);
    }
}
Mint<ll> C(ll n , ll k ){
    return (P[n]/P[k])/P[n-k];
}
Mint<ll> func(ll r, ll c ){
 	return C(r+c,r);
}
Mint<ll> H(ll n , ll k ){//n種類からkこ
 return C( n+k-1 , k );
}


int main(){
 ll n,k;
 cin>>n>>k;
 make();

 /*if( k == 1 ){
  cout<<n*(n-1)<<endl;
  return 0;
 }*/
 if( n-1 <= k ){
  cout<<H(n,n).v<<endl;
  return 0;
 }

 	Mint<ll> ans(1);
 for(ll i=1;i<=k;i++){
	Mint<ll> cnt = C( n , i ) * H( n- i , i ) ;
	ans += cnt;
 }

cout<<ans.v<<endl;


    return 0;
}


Measured memory_bytes: 22144
s=input()

le=0

i=0
while(i<len(s)):
    l=0
    while(i<len(s) and (s[i]=='A' or s[i]=='C' or s[i]=='G' or s[i]=='T')):
        l+=1
        i+=1

    if(l>le):
        le=l
    l=0
    i+=1
print(le)

Measured memory_bytes: 3064
#!/usr/bin/env python
# -*- coding: utf-8 -*-

"""
input:
6 9
0 1 1
0 2 3
1 2 1
1 3 7
2 4 1
1 4 3
3 4 1
3 5 1
4 5 6

output:
5
"""

import sys
import heapq as hp

WHITE, GRAY, BLACK = 0, 1, 2


def generate_adj_table(v_table):
    for each in v_table:
        v_from, v_to, edge_weight = map(int, each)
        init_adj_table[v_from][v_to] = edge_weight
        init_adj_table[v_to][v_from] = edge_weight

    return init_adj_table


def prim_span_tree():
    distance[init_v] = 0
    parent[init_v] = -1
    distance_heap = []
    hp.heappush(distance_heap, (0, init_v))

    while distance_heap:
        current_vertex = hp.heappop(distance_heap)[1]

        color[current_vertex] = BLACK

        for adj_vertex, adj_weight in adj_table[current_vertex].items():
            if color[adj_vertex] is not BLACK:
                if adj_weight < distance[adj_vertex]:
                    distance[adj_vertex] = adj_weight
                    parent[adj_vertex] = current_vertex
                    color[adj_vertex] = GRAY
                    hp.heappush(distance_heap, (adj_weight, adj_vertex))

    return distance


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:])

    parent = [-1] * vertices
    distance = [float('inf')] * vertices
    color = [WHITE] * vertices
    init_v = 0

    init_adj_table = tuple(dict() for _ in range(vertices))
    adj_table = generate_adj_table(v_info)
    print(sum(prim_span_tree()))

Measured memory_bytes: 38864
abc_list = ['a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z']

if __name__ == '__main__':
	w = input()
	w = [s.split()[0] for s in w]

	check = 0
	
	for i in abc_list:
		if w.count(i) % 2 != 0:
			check = 1
			break

	if check == 0:
		print('Yes')
	else:
		print('No')

Measured memory_bytes: 3064
while True:
  m, f, r = map(int, input().split())
  if m == -1 and f == -1 and r == -1:break

  if m == -1 or f == -1:
    print('F')
  elif m + f >= 80:
    print('A')
  elif (m + f < 80) and (m + f >= 65):
    print('B')
  elif ((m + f < 65) and (m + f >= 50)) or (r >= 50):
    print('C')
  elif (m + f < 50) and (m + f >= 30):
    print('D')
  elif m + f < 30:
    print('F')


Measured memory_bytes: 5592
#include<cstdio>
#include<algorithm>

using namespace std;

int w[110];
int w_cum[110];
int main() {
  int n;
  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%d", &w[i]);
    if (i == 0) w_cum[i] = w[i];
    else w_cum[i] = w_cum[i-1] + w[i];
  }

  int ans = w_cum[n-1];
  for (int i = 0; i < n; i++) {
    int s2 = w_cum[n-1] - w_cum[i];
    ans = min(ans, abs(s2 - w_cum[i]));
  }
  printf("%d\n", ans);

  return 0;
}


Measured memory_bytes: 128
fun main(args: Array<String>){
    val(k,n) = readLine()!!.split(" ").map{it.toInt()}
    val distance = readLine()!!.split(" ").map{it.toInt()}

    var max = 0
    for(i in 0 until distance.size - 1){
        var between = distance.elementAt(i+1) - distance.elementAt(i)
        if(max < between){
            max = between
        }
    }
    val lastBetween = k + distance.first() - distance.last()
    if(max < lastBetween){
        max = lastBetween
    }
    println(k - max)
}

Measured memory_bytes: 82696
#include<stdio.h>
#define N 1000
#define Z 200000
int a, b, c, d, z = -1000000001, topNext, top, buf, compF, compB, larg;
int push(void);
int print(void);
int pop(void);
int A[N][Z];
int size[N];
////////////////////////////////////////////////////////////
int main(void){
    scanf("%d%d", &b, &a);
    while (a-- != 0){
        scanf("%d", &b);
        if (b == 0) push();
        if (b == 1) print();
        if (b == 2) pop();
    }
    return 0;
}
int push(void){
    scanf("%d%d", &c, &d);
    A[c][size[c]] = d;
    size[c]++;
    topNext = size[c] - 1;
    top = (topNext - 1)/2;
    if (size[c] <= 1) return 0;
    while (top >= 0 && A[c][top] < A[c][topNext]) {
        buf = A[c][top];
        A[c][top] = A[c][topNext];
        A[c][topNext] = buf;
        topNext = top;
        top = (topNext-1)/2; 
    }
    return 0;
}
int print(void){
    scanf("%d", &c);
    if (size[c] == 0) return 0;
    printf("%d\n", A[c][0]);
    return 0;
}
int pop(void){
    scanf("%d", &c);
    if (size[c] == 0) return 0; 
    A[c][0] = A[c][size[c]-1];
    d = 0;
    while (z < 0){
        compF = (d+1)*2-1;
        compB = (d+1)*2;
        if (compF < size[c] && A[c][compF] > A[c][d]) larg = compF;
        else larg = d;
        if (compB < size[c] && A[c][compB] > A[c][larg]) larg = compB;
        if (larg == d) break;
        buf = A[c][d];
        A[c][d] = A[c][larg];
        A[c][larg] = buf;
        d = larg;
    }
    size[c]--;
    return 0;
}



Measured memory_bytes: 6204
def f(s, cost, route, ans):
    route.append(s)
    ans += cost[s]
    del cost[s]
    for k, c in data.items():
        if s in k:
            a, b = k
            b = b if s == a else a
            if not b in route:
                if not b in cost or c < cost[b]:
                    cost[b] = c
    if cost:
        s = sorted(cost.items(), key=lambda x: x[1])[0][0]
        return f(s, cost, route, ans)
    return ans

while 1:
    n, m = map(int, raw_input().split())
    if n == m == 0: break
    data = {}
    for i in range(m):
        a, b, c = map(int, raw_input().split())
        data[(a, b)] = c
    print f(0, {0:0}, [], 0)

Measured memory_bytes: 4316
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int T;
  int N;
  cin >> A >> T >> N;
  if (A * T > N) {
    cout << N << endl;
  }
  else if (A * T == N) {
    cout << N << endl;
  }
  else {
    cout << A * T << endl;
  }
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		int c = scanner.nextInt();
		if (a < b && b < c)
			System.out.println("Yes");
		else
			System.out.println("No");
		scanner.close();
	}
}


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

int main()
{
    long long N, W;
    cin >> N >> W;

    long long w[N+1], v[N+1];
    for(long long i = 1; i <= N; i++) cin >> w[i] >> v[i];

    long long DP[W+1];
    for(long long j = 0; j <= W; j++) DP[j] = 0;

    for(long long i = 1; i <= N; i++)
    {
        for(long long j = W; j >= w[i]; j--) DP[j] = max(DP[j], DP[j - w[i]] + v[i]);
        for(long long j = 1; j <= W; j++) DP[j] = max(DP[j], DP[j-1]);
    }
    cout << DP[W] << '\n';
    return 0;
}

Measured memory_bytes: 1024
const int isDebugMode = 1;
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<long long, long long> P;
struct edge{long long to,cost;};
const int inf = 1 << 27;
const long long INF = 1LL << 60;
const int COMBMAX = 1001001;
const long long MOD = 1000000007;
const long long dy[] = {-1, 0, 0, 1};
const long long dx[] = {0, -1, 1, 0};
string abc = "abcdefghijklmnopqrstuvwxyz";
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define eachdo(v, e) for (const auto &e : (v))
#define all(v) (v).begin(), (v).end()
#define lower_index(v, e) (long long)distance((v).begin(), lower_bound((v).begin(), (v).end(), e))
#define upper_index(v, e) (long long)distance((v).begin(), upper_bound((v).begin(), (v).end(), e))
long long mpow(long long a, long long n, long long mod = MOD){long long res = 1; while(n > 0){if(n & 1)res = res * a % mod; a = a * a % mod; n >>= 1;} return res;}
void pt(){cout << endl; return;}
template<class Head> void pt(Head&& head){cout << head; pt(); return;}
template<class Head, class... Tail> void pt(Head&& head, Tail&&... tail){cout << head << " "; pt(forward<Tail>(tail)...);}
void dpt(){if(!isDebugMode) return; cout << endl; return;}
template<class Head> void dpt(Head&& head){if(!isDebugMode) return; cout << head; pt(); return;}
template<class Head, class... Tail> void dpt(Head&& head, Tail&&... tail){if(!isDebugMode) return; cout << head << " "; pt(forward<Tail>(tail)...);}
template<class T> void debug(T v){if(!isDebugMode) return; rep(i, v.size()) cout << v[i] << " " ; cout << endl;}
template<class T> void debug2(T v){if(!isDebugMode) return; rep(i, v.size()){rep(j, v[i].size()) cout << v[i][j] << " " ; cout << endl;}}
template<class T1, class T2> inline bool chmin(T1 &a, T2 b){if(a > b){a = b; return true;} return false;}
template<class T1, class T2> inline bool chmax(T1 &a, T2 b){if(a < b){a = b; return true;} return false;}
template<class T1, class T2> long long gcd(T1 a, T2 b){return a % b ? gcd(b , a % b) : b;}
template<class T1, class T2> void reduce(T1 &a, T2 &b){ll g = gcd(a, b); a /= g; b /= g; return;}
bool valid(long long H, long long W, long long h, long long w) { return 0 <= h && h < H && 0 <= w && w < W; }

int main(){
    char a; cin >> a;
    pt(find(all(abc), a) == abc.end() ? "A" : "a");
    return 0;
}

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

using namespace std;

int main()
{
	int k,a,b;
	cin >> k >> a >> b;
	int i=0;
	for(i=a; i<=b; ++i){
		if(i%k==0){
			cout << "OK" << endl;
			break;
		}
	}
	if(i==b+1){
		cout << "NG" << endl;
	}
}

Measured memory_bytes: 3624
n=int(input())
s = [ str(input()) for _ in range(n)]
s = sorted([sorted(x) for x in s])
pairs = 0
from operator import mul
from functools import reduce

def combinations_count(n, r):
    r = min(r, n - r)
    numer = reduce(mul, range(n, n - r, -1), 1)
    denom = reduce(mul, range(1, r + 1), 1)
    return numer // denom

i=0
while i < n-1:
    sames = 0
    for j in range(i+1, n):
        if s[i] == s[j]:
            sames += 1
            continue
        else:
            break
    i += sames + 1
    if sames != 0:
        pairs += combinations_count(sames + 1, 2)


print(int(pairs))

Measured memory_bytes: 32600
#include<bits/stdc++.h>
using namespace std;
typedef		long long       ll;
typedef         long double      dl;
#define		pb              push_back
#define		PB              pop_back
#define		nn              "\n"
#define     O_O             ios_base::sync_with_stdio(false); cin.tie(NULL)
#define		all(p)          p.begin(),p.end()
#define		zz(v)           (ll)v.size()
#define		ss              ' '
#define         arrsize(a)      (sizeof(a)/sizeof(a[0]))
//#define       arrsize(a)      (sizeof(a)/sizeof(*a))
#define 	S(a)            scanf("%lld",&a)
#define 	SS(a,b)         scanf("%lld %lld",&a,&b)
#define 	SSS(a,b,c)      scanf("%lld %lld %lld",&a,&b,&c)
#define		gcd(a,b)        __gcd(a,b)
#define		lcm(a,b)        (a*b)/gcd(a,b)
#define		pi              acos(-1.0)
typedef        pair <int, int>   pii;
typedef       pair <ll, ll>      pll;
typedef      vector< pair <ll, ll> >      vpll;
typedef		vector<ll>      vll;
typedef		map<string,ll>      msl;
typedef		map<ll,ll>      mll;
#define MAX 1000005


int main()
{
 //O_O ;
   ll n,a=0;
   cin>>n;
   string s;
   cin>>s;
   ll l=s.length();
   for(ll i=0;i<l;i++)
   {
       a=s[i]+n;
    //   cout<<a<<nn;
      if(a>90){
        a=a-26;
      }
     // cout<<a<<nn;
      s[i]=a;
   }
   cout<<s<<nn;



    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <queue>
#include <stack>
#include <cmath>
#include <bitset>
#include <random>
#include <cassert>
#include <cstdio>
#include <cstring>
#include <complex>
#include <functional>
using namespace std;
#define rep(i,a,b) for(int i = (a); i < int(b); ++i)
#define rrep(i,a,b) for(int i = (b); i --> int(a);)
#define all(v) v.begin(),v.end()
#define trav(x, v) for(auto &x : v)
#define sz(v) int((v).size())
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long double ld;

const int lg = 20;

int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	
	int n;
	cin >> n;
	vector<vi> dp(lg, vi(n));
	trav(a, dp[0]) cin >> a;
	rep(h,1,lg) rep(i,0,n){
		int ii = i + (1<<(h-1));
		dp[h][i] = dp[h-1][i];
		if(ii < n)
			dp[h][i] = min(dp[h][i], dp[h-1][ii]);
	}
	auto rmq = [&](int from, int to){
		int t = 31 - __builtin_clz(to - from);
		return min(dp[t][from], dp[t][to - (1<<t)]);
	};
	ll ans = 0;
	rep(i,0,n){
		int lo = -1, hi = i;
		while(lo + 1 < hi){
			int mi = (lo + hi)/2;
			if(rmq(mi, i) < dp[0][i])
				lo = mi;
			else
				hi = mi;
		}
		int le = lo;
		lo = i, hi = n;
		while(lo + 1 < hi){
			int mi = (lo + hi)/2;
			if(rmq(i+1, mi+1) < dp[0][i])
				hi = mi;
			else
				lo = mi;
		}
		int rr = hi;
		ll cnt = (ll)(i - le)*(rr - i);
		ans += cnt * dp[0][i];
	}
	cout << ans << endl;
}

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






int main(){
  

  int n;
  cin>>n;
  
  vector<int> rawdata(n);
  
  for (int i=0;i<n;i++){
    int tmp;
    cin>>tmp;
    rawdata.at(i)=tmp;
  }
  
  auto sortdata=rawdata;
  
  sort(sortdata.begin(),sortdata.end());
  
  for (int i=0;i<n;i++){
    if (rawdata.at(i)<=sortdata.at((n/2)-1)){
      cout<<sortdata.at(n/2)<<endl;
    }
    
    else {
      cout<<sortdata.at((n/2)-1)<<endl;
    }
    
  }
  
  
  

  
    
  


    
  
  
  
}

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repit(it, li) for(auto it=li.begin(); it!=li.end(); it++)
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main(){
	int n, m;
	cin>>n>>m;
	vector<int> e[600];
	rep(i, m){
		int s, t;
		cin>>s>>t; s--; t--;
		e[s].push_back(t);
	}

	double dp[600][600];
	// rep(i, n) rep(j, n) dp[i][j]=0;
	rep(j, n) dp[n-1][j]=0;
	for(int i=n-2; i>=0; i--){
		int ne=e[i].size();
		rep(j, n){
			if(i==j && ne>=2){
				double mx=0, sm=0;
				for(int u : e[i]){
					double b=(double)1/(ne-1)*dp[u][j];
					mx=max(mx, b);
					sm+=b;
				}
				dp[i][j]=sm-mx;
			}
			else for(int u : e[i]) dp[i][j]+=(double)1/ne*dp[u][j];
			dp[i][j]+=1;
		}
	}

	double mn=601;
	rep(j, n) mn=min(mn, dp[0][j]);

	cout<<std::setprecision(15)<<mn<<endl;
	return 0;
}


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

#include <math.h>
#include <stdlib.h>


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

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_MAX	2,147,483,647 = 2*1.0e9

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    
    int N; cin >> N;

    map<string, int> mp;

    for(int i = 0; i < N; i++){
        string s; cin >> s;
        mp[s] += 1;
    }

    int M; cin >> M;
    for(int i = 0; i < M; i++){
        string s; cin >> s;
        mp[s] -= 1;
    }

    int ans = 0;
    for(auto itr = mp.begin(); itr != mp.end(); ++itr) {
        int val = itr->second;
        ans = max(ans, val);
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
signed main(){  
  cin.tie(0);
  ios::sync_with_stdio(0);
  Int T;
  cin>>T;
  map<string,Int> ms;
  vector<string> vs({"C", "C#", "D", "D#", "E", "F", "F#", "G", "G#", "A", "A#", "B" });
  for(Int i=0;i<12;i++) ms[vs[i]]=i;
  while(T--){
    Int n,m;
    cin>>n>>m;
    vector<Int> t(n+1,0),s(m);
    for(Int i=0;i<n;i++){
      string x;
      cin>>x;
      t[i+1]=ms[x];
    }
    for(Int i=0;i<m;i++){
      string x;
      cin>>x;
      s[i]=ms[x];
    }

    vector<Int> dp(1,n+1);
    for(Int i=m;i>=0;i--){
      vector<Int> nx;
      for(Int x: dp){
	if(x-1>=0&&(i==m||t[x]==s[i])) nx.emplace_back(x-1);
	if(x-2>=0&&(i==m||t[x]==(s[i]+11)%12)) nx.emplace_back(x-2);
	if(x+1<=n&&(i==m||t[x]==(s[i]+1)%12)) nx.emplace_back(x+1);
      }
      sort(nx.begin(),nx.end());
      nx.erase(unique(nx.begin(),nx.end()),nx.end());
      swap(dp,nx);
      if(dp.empty()) break;
    }
    
    cout<<(!dp.empty()&&dp.front()==0?"Yes":"No")<<endl;
  }
  return 0;
}



Measured memory_bytes: 3644
a,b,x = map(int,input().split())
import math
m_cm3 = a*b*a
if(x >= (m_cm3/2)):
    s = 2*b - (2*x)/(a**2)
    s /= a
    ans = math.degrees(math.atan(s))
else:
    s = (a*b*b)/(2*x)
    ans = math.degrees(math.atan(s))

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#define ULL unsigned long long

int cmp(const void *a, const void *b) {
    int *p = *(int**)a; int *q = *(int**)b;
    if( p[0] > q[0] )       { return 1; }
    else if( p[0] < q[0] )  { return -1; }
    else                    { return 0; }
}

int main()
{
    int i, n, m, temp;
    ULL mny;
    scanf("%d %d", &n, &m);
    int **a = (int **)malloc(n * sizeof(int *));
    a[0] = (int *)malloc(n*2*sizeof(int));
    for(i = 1; i < n; ++i) { a[i] = a[0] + i*2; }
    for(i = 0; i < n; ++i) { scanf("%d %d", &a[i][0], &a[i][1]); }
    qsort(a, n, sizeof(int*), cmp);
    //for(i = 0; i < n; ++i) { printf("%d %d\n", a[i][0], a[i][1]); }

    //printf("---------\n");
    i = 0; mny = (ULL)0;
    for(i = 0; (i < n && m > 0); ++i) {
        temp = ( a[i][1] <= m) ? a[i][1] : m;
        mny += (ULL)a[i][0] * (ULL)temp;
        m -= temp;
    }
    printf("%llu\n", mny);
    return 0;
}

Measured memory_bytes: 2556