akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k,x;
	scanf("%d%d",&k,&x);
	int be=x-k+1;
	int ed=x+k-1;
	for(int i=be;i<=ed;i++){
		if(i!=be){
			printf(" ");
		}
		printf("%d",i);
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <functional>
#include <cassert>
 
using namespace std;
 
typedef long long ll;
 
const int N = 2e5 + 7;
 
int f[N];
 
void modify(int i) {
  for (; i < N; i |= i + 1) {
    ++f[i];
  }
}
 
int get(int r) {
  int res = 0;
  for (; r >= 0; r &= r + 1, --r) {
    res += f[r];
  }
  return res;
}
 
int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  string s;
  cin >> s;
  int n = s.size();
  vector <int> cnt(26);
  for (int i = 0; i < n; ++i) ++cnt[s[i] - 'a'];
  int bad = 0;
  for (int i = 0; i < 26; ++i) bad += (cnt[i] % 2);
  if (bad > 1) {
    cout << "-1\n";
    return 0;
  }
  vector <vector <int>> where(26);
  for (int i = 0; i < n; ++i) where[s[i] - 'a'].push_back(i);
  vector <int> go(n, -1);
  vector <int> rofl(26);
  int sz = (n + 1) / 2;
  int uk = 0;
  for (int i = 0; i < n; ++i) {
    int c = s[i] - 'a';
    if (cnt[c] >= 2) {
      go[uk] = where[c][rofl[c]];
      go[n - uk - 1] = where[c][(int)where[c].size() - rofl[c] - 1];
      ++uk;
      ++rofl[c];
      cnt[c] -= 2;
    }
  }
 
  vector <int> used(n);
  for (int x : go) if (x != -1) used[x] = 1;
  for (int i = 0; i < n; ++i) if (!used[i]) go[n / 2] = i;
  ll ans = 0;
  for (int i = n - 1; i >= 0; --i) {
    ans += get(go[i]);
    modify(go[i]);
  }
  cout << ans << '\n';
}


Measured memory_bytes: 3980
s = list(input())
l = len(s)
a = (l-1)//2
b = (l+3)//2
if s == s[::-1] and s[:a][::-1] == s[:a] and  s[b-1:][::-1] == s[b-1:][::-1]:
	print("Yes")
else:
	print("No")

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

template <typename T> vector<T> make_vector(size_t a, T b) { return vector<T>(a, b); }
template <typename... Ts> auto make_vector(size_t a, Ts... ts) { return vector<decltype(make_vector(ts...))>(a, make_vector(ts...)); }

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    auto calc = [&](string s) {
        char idx = 'a';
        map< char, char > mp;
        
        range(i, 0, s.size()) {
            if (mp.count(s[i]) == 0) {
                mp[s[i]] = idx++;
            }
            
            s[i] = mp[s[i]];
        }
        
        return s;
    };
            
    cout << (calc(input< string >()) == calc(input< string >()) ? "Yes" : "No") << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 916
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <deque>
#include <map>
#include <set>
#include <cassert>
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(x) ((int)(x).size())
#define It iterator
typedef vector<int> VI;
typedef long long ll;
typedef pair<int,int> PII;

int n;
ll a=6;



int main() {
    //freopen("test.in","r",stdin);
    cin>>n;
    rep(i,2,n+1) a=a*2+2;
    cout<<a;

    return 0;
}


Measured memory_bytes: 384
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] dp = new int[N + 1];
		long res = 0;
		for (int i = 1; i <= N; i++) {
			long pos = i;
			dp[(int) pos] += 1;
			while (pos + i <= N) {
				pos += i;
				dp[(int) pos] += 1;
			}
			if (dp[i] < 0) {
				System.out.println(dp[i]);
			}
			res += i * (long) dp[i];
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 74828
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
  int n;
  cin>>n;
  vector<int> a(n);
  for(int i=0;i<n;i++) a[i]=i+1;

  do{
    for(int i=0;i<n;i++){
      if(i) cout<<" ";
      cout<<a[i];
    }
    cout<<endl;
  } while(next_permutation(a.begin(),a.end()));

  return 0;

}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (int i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (int i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,v) for (int i = 0; i < v.size(); i++)
#define RREPALL(i,v) for (int i = v.size()-1; i >= 0; i--)
#define SORT(v) sort(v.begin(), v.end())
#define MIN_ELEMENT(v) min_element(v.begin(), v.end())
#define MAX_ELEMENT(v) max_element(v.begin(), v.end())
#define COUNT(v,n) count(v.begin(), v.end(), n);
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
typedef long long ll;
typedef unsigned long long ull;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

string s;
int a, b, c, d;
vector<vector<char>> cells;
vector<string> ans;

bool solve()
{
    cin>>a>>b>>c>>d;
    int idx = 0;
    string r;
    cells.push_back({});
    REPALL(i,s) {
        if (s[i] == 'b') {
            cells[idx].push_back('b');
        } else if (s[i] == '/') {
            cells.push_back({});
            idx++;
        } else {
            int cnt = (int)(s[i] - '0');
            REP(j,cnt) cells[idx].push_back('.');
        }
    }
    /*REPALL(i,cells) {
        REPALL(j,cells[i]) {
            cout<<s[i];
        }
        cout<<endl;
    }*/
    cells[a-1][b-1] = '.';
    cells[c-1][d-1] = 'b';

    REPALL(i,cells) {
        int cnt = 0;
        REPALL(j,cells[i]) {
            if (cells[i][j] == 'b') {
                if (cnt != 0) {
                    r += to_string(cnt);
                }
                cnt = 0;
                r += 'b';
            } else {
                cnt++;
            }
        }
        if (cnt != 0) {
            r += to_string(cnt);
        }
        if (i != cells.size() -1)
            r += '/';
    }
    ans.push_back(r);
    cells.clear();
}

int main()
{
    while (cin>>s, s != "#") {
        solve();
    }
    REPALL(i,ans) cout<<ans[i]<<endl;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, n) for (int i = 1; i <= (int)(n); i++)
using ll = long long;
using P = pair<ll,ll>;
#define pb push_back
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

/*
 string -> int : stoi(S);
 int -> string : to_string(N);
 Sのn文字以降をm文字取り出す : S.substr(n,m)
cout << fixed << setprecision(2) << 3.14 << endl; //3.1

 int: -2,147,483,648 ～ 2,147,483,647 (2×10^9)
 ll: -9,223,372,036,854,775,808 ~ 9,223,372,036,854,775,807 (9×10^18)

*/

int main() {

  ll n, m, k,count=0, ans=0;
  string s;
 
  cin >> n >> k;
  vector<bool> flag(n,false);
  vector<int> root;
  vector<int> a(n);

  rep(i,n){
    cin >> a[i];
    a[i]--;
  }
  bool f=true;
  ll from=0;
  ll length2;
  ll roop=1;
  root.pb(0);
  flag[0]=true;
  while(f){
    int to= a[from];
    if(flag[to]){
      f=false;
      ll length = root.size();
      length2= length;
      length--;
      while(root[length]!=to){
        roop++;
        length--;
      }
      break;
    }
    root.pb(to);
    flag[to]=true;
    from=to;
  }

  ll left = length2-roop;
  if(k<=left-1) ans=root[k];
  else{
    k=k-left;
    k = k%roop;
    ans=root[left+k];
  }


  cout << ans+1 << endl;
}

Measured memory_bytes: 5028
#include"bits/stdc++.h"

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

#define FOR(k,m,n) for(ll (k)=(m);(k)<(n);(k)++)
#define REP(i,n) FOR((i),0,(n))
#define WAITING(str) int str;std::cin>>str;
#define DEBUGING(str) cout<< #str << " " str<<endl

constexpr int INF = (1 << 30);
constexpr ll INFL = (1ll << 60);
constexpr ll MOD = 1000000007;// 10^9+7



int main()
{
	int N, K;
	cin >> N >> K;
	ld res = 0;
	FOR(i, 1, N + 1) {
		int now = i;
		ld tmp = 1;
		while (now < K) {
			tmp /= 2;
			now *= 2;
		}
		res += tmp;
	}
	res /= N;
	cout << fixed << setprecision(12) << res << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>

int main(){

	int a;
	int b;
	int c;
	int x=0;

	std::cin >> a >> b >> c;

	for (int i = a; i <= b; i++){
		if (c%i == 0){
			x++;
		}
	}
	std::cout << x << '\n';
}


Measured memory_bytes: 3100
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define MAXORDER 1046527
#define TRUE 1
#define FALSE 0

long dictionary[MAXORDER];

short GetNum(char c){
    if(c == 'A') return 1;
    else if(c == 'C') return 2;
    else if(c == 'G') return 3;
    else if(c == 'T') return 4;
    else return 0;
}

long GetKey(char *word){
    int i,len,p=1;
    long key=0;

    len = strlen(word);
    for(i=0; i<len; i++){
        key += p*GetNum(word[i]);
        p*=5;
    }
    return key;
}

int h1(long key){return key % MAXORDER;}
int h2(long key){return 1 + (key % (MAXORDER - 1));}

void Insert(long key){
    int i,hash;

    for(i=0;;i++){
        hash = (h1(key) + i*h2(key)) % MAXORDER;
        if(dictionary[hash] == 0){
            dictionary[hash] = key;
            return;
        }else if(dictionary[hash] == key){
            return;
        }
    }
    return;
}

int Find(long key){
    int i,hash;

    for(i=0;;i++){
        hash = (h1(key) + i*h2(key)) % MAXORDER;
        if(dictionary[hash] == key){
            return TRUE;
        }else if(dictionary[hash] == 0){
            return FALSE;
        }
    }
    return FALSE;
}

int main(){
    int i,n,j=0;
    long key;
    char order[7],word[13];
    short isFound[MAXORDER];

    for(i=0; i<MAXORDER; i++){
        dictionary[i] = 0;
    }

    scanf("%d",&n);
    for(i=1; i<=n; i++){
        scanf("%s %s",order,word);
        key = GetKey(word);

        if(order[0]=='i'){
            Insert(key);
        }else if(order[0]=='f'){
            isFound[j++] = Find(key);
        }else{
            printf("Invalid Order!!\n");
            exit(1);
        }
    }

    for(i=0; i<j; i++){
        if(isFound[i]) printf("yes\n");
        else printf("no\n");
    }
    return 0;
}


Measured memory_bytes: 10748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int MOD = 1e9+7;

int main(int argc, char const *argv[]) {
    int a, b, t;
    cin >> a >> b >> t;

    int count = 0;
    for (int i = a; i <= t; i+=a) {
        count += b;
    }

    cout << count << endl;
    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=1000000007;
const double PI=3.14159265358979;
const ll INF= pow(10,18);
typedef pair<ll,ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) FOR(i,0,n)
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main() {
  ll n,m,v,p;
  cin >> n >> m >> v >> p;
  vl a(n);
  rep(i,n){
    cin >> a[i];
  }
  sort(a.begin(),a.end());
  ll A=0,B=n-1;
  ll M;
  while(A!=B){
    M=(A+B)/2;
    bool ok=false;
    bool sub=true;
    ll s=0;
    //a[M]で条件満たすの?
    FOR(i,M+1,n-p+1){
      if(a[M]+m-a[i]>=0){
        s +=(a[M]+m-a[i]);
      }
      else
        sub=false;
    }
    if((M+1)*m+s>=m*(v-p+1)){
      ok=true;
    }
    //にぶたん
    if(ok&&sub){
      A=min(A,B);
      B=M;
    }
    else{
      B=max(A,B);
      A=M+1;
    }
  }
  cout << n-A << endl;
}

Measured memory_bytes: 1152
def main():
    import sys
    #input = sys.stdin.readline
    sys.setrecursionlimit(10000000)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations
    #from itertools import accumulate, product
    from bisect import bisect_left,bisect_right
    from math import floor, ceil
    #from operator import itemgetter

    #mod = 1000000007

    n = int(input())
    A = list(map(int, input().split()))
    B = list(map(int, input().split()))
    C = list(map(int, input().split()))
    A.sort()
    C.sort()

    res = 0
    for j in B:
        res += bisect_left(A, j) * (n-bisect_right(C, j))
    print(res)

if __name__ == '__main__':
    main()

Measured memory_bytes: 23520
#include <iostream>
#include <sstream>
#include <cstdlib>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <numeric>
#include <bitset>
#include <stack>
#include <cstring>
using namespace std;

const int INF = 1 << 30;
const double EPS = 1e-10;
const int dx[7] = {0, 1, 1, 0, -1, -1, 0};
const int dy[2][7] = { {1, 0, -1, -1, -1, 0, 0}, {1, 1, 0, -1, 0, 1, 0} };
const int REV = 100;

class State
{
public:
  int x, y, t, c;
  State(int _x, int _y, int _t, int _c)
    :x(_x), y(_y), t(_t), c(_c) {}
  bool operator < (const State& st) const
  {
    return this->c > st.c;
  }
};

int main()
{
  int sx, sy, gx, gy;
  while (cin >> sx >> sy >> gx >> gy) {
    int n;
    cin >> n;
    deque<deque<bool> > h(200+1, deque<bool>(200+1, false));
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      h[y+REV][x+REV] = true;
    }

    int lx, ly;
    cin >> lx >> ly;

    int ans = -1;
    priority_queue<State> que;
    que.push(State(sx, sy, 0, 0));
    vector<vector<vector<int> > > dp(6, vector<vector<int> >(200+1, vector<int>(200+1, INF)));
    while (!que.empty()) {
      const State st = que.top();
      que.pop();

      if (st.x == gx && st.y == gy) {
        ans = st.c;
        break;
      }

      if (dp[st.t][st.y+REV][st.x+REV] < st.c)
        continue;
      dp[st.t][st.y+REV][st.x+REV] = st.c;

      int ind = abs(st.x*st.y*st.t) % 6;
      for (int d = 0; d < 7; ++d) {
        int x = st.x + dx[d];
        int y = st.y + dy[abs(st.x)%2][d];
        int c = st.c;
        if (ind != d)
          ++c;

        if (abs(x) > lx || abs(y) > ly ||
            h[y+REV][x+REV] || dp[(st.t+1)%6][y+REV][x+REV] <= c)
          continue;
        que.push(State(x, y, (st.t+1)%6, c));
      }

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

Measured memory_bytes: 2964
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int r = sc.nextInt();
        int d = sc.nextInt();
        int x = sc.nextInt();
        int temp = r * x - d;
        int ans = temp;
        System.out.println(temp);
        for (int i = 0; i < 9; i++) {
            ans = r * temp - d;
            System.out.println(ans);
            temp = ans;
        }
    }
}

Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
#define FastRead ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define ll long long int
#define endl '\n'
#define ld long double
#define FOR(i,a,n) for (ll i=(a);i<=(n);++i)
#define RFOR(i,a,n) for (ll i=(n);i>=(a);--i)
#define FI(i,n) for (ll i=0; i<(n); ++i)
#define ZERO(a) memset((a),0,sizeof((a)))
#define MINUS(a) memset((a),-1,sizeof((a)))
#define f first
#define s second
#define pb push_back
#define mk make_pair
#define all(g) g.begin(),g.end()
int fastMax(int x, int y) { return (((y-x)>>(32-1))&(x^y))^y; }
int fastMin(int x, int y) { return (((y-x)>>(32-1))&(x^y))^x; }
 
/*
░░░░░░░░░░░░░░░░░░░░░░░░░
░░█▀▀▄░░░░░░░░░░░▄▀▀█░░░░
░░█░░░▀▄░▄▄▄▄▄░▄▀░░░█░░░░
░░░▀▄░░░▀░░░░░▀░░░▄▀░░░░░
░░░░░▌░▄▄░░░▄▄░▐▀▀░░░░░░░
░░░░▐░░█▄░░░▄█░░▌▄▄▀▀▀▀█░
░░░░▌▄▄▀▀░▄░▀▀▄▄▐░░░░░░█░
░▄▀▀▐▀▀░▄▄▄▄▄░▀▀▌▄▄▄░░░█░
░█░░░▀▄░█░░░█░▄▀░░░░█▀▀▀░
░░▀▄░░▀░░▀▀▀░░▀░░░▄█▀░░░░
░░░░█░░░░░░░░░░░▄▀▄░▀▄░░░
░░░░█░░░░░░░░░▄▀█░░█░░█░░
░░░░█░░░░░░░░░░░█▄█░░▄▀░░
░░░░█░░░░░░░░░░░████▀░░░░
░░░░▀▄▄▀▀▄▄▀▀▄▄▄█▀░░░░░░░
░░░░░░░░░░░░░░░░░░░░░░░░░
*/
 
// I want to be the very best, like no one ever was, I will battle everyday to claim my rightful place
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp>     // Including tree_order_statistics_node_updat
// using namespace __gnu_pbds;
// typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
 
// I am questioning life and universe and 
// everything else after looking at this

void solve(){
    ll n; cin>>n;
    ll total_n = (1<<n);

    multiset<ll> m;
    FOR(i,1,total_n){
        ll x; cin>>x; m.insert(-x);
    }

    vector<ll> v;
    v.push_back(*m.begin());
    m.erase(*m.begin());

    FOR(i,1,n){
        ll siz = v.size();
        FOR(j,0,siz-1){
            if(m.upper_bound(v[j]) == m.end()){
                cout<<"No\n";
                return;
            }
            auto val = m.upper_bound(v[j]);
            v.push_back(*val);
            m.erase(val);
        }
    }

    cout<<"Yes\n";
}

signed main(){
 
   FastRead;    
 
    
    ll t;
    t = 1; 
    // cin>>t;
    FOR(i,1,t){
        // cout<<"Case #"<<i<<": ";
        solve();
    }
}

Measured memory_bytes: 14708
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, const pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, const vector<vector<T>> &v)
{
	for (const vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, const vector<T> &v)
{
	for (const T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define per(i,b,a) for (int i = (b); i > (a); i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	int n, k;
	cin >> n >> k;
	set<int> s;
	rep(i,1,n+1)
		s.insert(i);
	rep(i,0,k)
	{
		int d;
		cin >>d;
		vi v(d);
		cin >> v;
		for(int x : v)
			s.erase(x);
	}	
	cout << s.size();
}


Measured memory_bytes: 3656
import java.util.Arrays;
import java.util.Scanner;
 
public class Main {
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		long[] dp = new long[100010];
		long[] h = new long[100010];
		
		Arrays.fill(dp, Long.MAX_VALUE);
		
		dp[0] = 0;
		
		int n = sc.nextInt();
		
		for(int i = 0; i < n; i++) h[i] = sc.nextInt();
		
		for(int i = 0; i < n; i++) {
			dp[i+1] = Math.min(dp[i]+Math.abs(h[i]-h[i+1]), dp[i+1]);
			dp[i+2] = Math.min(dp[i]+Math.abs(h[i]-h[i+2]), dp[i+2]);
		}
		
		System.out.println(dp[n-1]);
	}
}

Measured memory_bytes: 59268
#!/usr/bin/python3

from collections import defaultdict, Counter
from itertools import product, groupby, count, permutations, combinations
from math import pi, sqrt
from collections import deque
from bisect import bisect, bisect_left, bisect_right
from string import ascii_lowercase
from functools import lru_cache
import sys
sys.setrecursionlimit(10000)
INF = float("inf")
YES, Yes, yes, NO, No, no = "YES", "Yes", "yes", "NO", "No", "no"
dy4, dx4 = [0, 1, 0, -1], [1, 0, -1, 0]


def inside(y, x, H, W):
    return 0 <= y < H and 0 <= x < W


def main():
    A = int(input())
    B = int(input())
    C = int(input())
    D = int(input())

    print(min(A, B) + min(C, D))


if __name__ == '__main__':
    main()


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

int main()
{
  string s, t;
  cin >> s >> t;
  int len = s.length();
  int ans = 0;
  for (int i = 0; i < len; i++) {
    if (s[i] != t[i]) ans++;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3824
S = input().strip()
T = input().strip()
F = {}
flag = 0
for i in range(len(S)):
    a = S[i]
    b = T[i]
    if a not in F:
        F[a] = b
    if F[a] != b:
        flag = 1
        break
    for c in F:
        if c!=a and F[c]==b:
            flag = 1
            break
if flag==1:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vc = vector<char>;
using vb = vector<bool>;
using vs = vector<string>;
using vll = vector<long long>;
using vp = vector<pair<int, int>>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using vvll = vector<vector<long long>>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    
    int n; ll k;
    cin >> n >> k;
    vi a(n), f(n);
    rep(i, n) cin >> a[i];
    rep(i, n) cin >> f[i];
    sort(all(a));
    sort(rall(f));
    
    auto ok = [&](ll x) {
        ll cnt = 0;
        rep(i, n) {
            cnt += max(a[i] - x/f[i], 0LL);
        }
        return cnt <= k;
    };
    ll l = -1, r = 1e12 + 1;
    while (r - l > 1) {
        ll m = (l+r) >> 1;
        if (ok(m)) r = m;
        else l = m;
    }
    cout << r << endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <queue>
#include <cstdio>
#include <string>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define fi first
#define se second
static const int INF = 1e9;
int dx[4] = {1, 0, 0, -1};
int dy[4] = {0, 1, -1, 0};
string board[1001];
int d[1001][1001];
int h, w, n;
pair<int, int> point[10];//fi=y se=x
int ans = 0;
bool flag;
//???????????¢?´¢
void bfs(void){
	rep(i, n){//??????????????¨??´?????????
		int starty = point[i].fi, startx = point[i].se;//start
		int endy = point[i + 1].fi, endx = point[i + 1].se;//end
		queue<pair<int, int> > q;
		q.push(make_pair(starty, startx));
		rep(i, h) rep(j, w) d[i][j] = INF;
		d[starty][startx] = 0;
		flag = false;
		while(!q.empty()){
			pair<int, int> now;
			now = q.front(); q.pop();
			rep(j, 4){
				int y = now.fi + dy[j];
				int x = now.se + dx[j];
				if(y < 0 || h <= y || x < 0 || w <= x) continue;
				if(d[y][x] == INF && board[y][x] != 'X'){
					d[y][x] = d[now.fi][now.se] + 1;
					q.push(make_pair(y, x));
				}
				if(y == endy && x == endx){
					flag = true;
					ans += d[y][x];
					break;
				}
			}
			if(flag == true) break;
		}
	}
	return;
}

int main(void){
	cin >> h >> w >> n;
	rep(i, h){
		cin >> board[i];
	}

	rep(i, h) rep(j, w){
		if(board[i][j] == 'S'){
			point[0].fi = i; point[0].se = j;
		}else if ('1' <= board[i][j] && board[i][j] <= '9'){
			int tmp = board[i][j] - '0';
			point[tmp].fi = i; point[tmp].se = j;
		}
	}
	bfs();
	cout << ans << endl;
	return 0;
}

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

int main() {
	int arr[]={1,3,5,7,8,10,12};
	int arr2[]={4,6,9,11};
	int a, b;
	cin >> a >> b;
	int cnt=0;
	for (int i=0; i<7; i++){
		if (arr[i]==a) cnt ++;
		else if (arr[i]==b) cnt++;
	}
	if (cnt==2){ 
		cout << "Yes" << endl;
		return 0;
	}
	else cnt = 0;
	for (int i=0; i<4; i++){
		if (arr2[i]==a) cnt ++;
		else if (arr2[i]==b) cnt++;
	}
	if (cnt==2){
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define pb push_back
#define mp make_pair
using namespace std;
ll k;

bool found;
int generated;
void generate(int st_digit, int d, int balance, int cd = 1, string curr = "") {
	if(generated == k) return;
	if(balance < 0) return;
	if(balance > 9) return;



	if(cd == d) {
		generated++;
		if(generated == k) {
			found = true;

			string result = "";
			result += char(st_digit+'0');


			int lst = st_digit;
			for(int i=0;i<curr.length();i++) {
				if(curr[i] == '+') lst++;
				else if(curr[i] == '-') lst--;

				result += char(lst + '0');
			}
			cout<<result<<"\n";
			return;
		}
	}
	else {
		generate(st_digit, d, balance-1, cd+1, curr+"-");
		generate(st_digit, d, balance, cd+1, curr+"0");
		generate(st_digit, d, balance+1, cd+1, curr+"+");
	}
}

int main() {
	cin>>k;

	int br = 1;
	while(!found) {
		for(int i=1;i<=9;i++) {
			generate(i, br, i);

			if(found) break;
		}
		if(found) break;

		br++;
	}
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif
        ll a;
        string b;
        cin >> a >> b;
        ll ind ;
        for(ll i=0 ; i<b.size() ; ++i) {
        	if(b[i] == '.') {
        		ind = i;
        		break;
        	}
        }
        
        ll res = 0;
        int ep = b.size() - ind - 1;
        ll t = 1;
        while(ep--)
        	t*=10;
        
        string s1 = b.substr(0 , ind);
        string s2 = b.substr(ind+1 , b.size() - ind - 1);

        ll x=0 , y=0;
        stringstream t1(s1);
        t1 >> x;
        stringstream t2(s2);
        t2 >> y;
        res = x*t + y;
        res  *= a;
        res = res / t;
        cout << res << endl;
    return 0;
}

Measured memory_bytes: 3640
import java.util.ArrayList;
import java.util.Comparator;
import java.util.List;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

        String line;
        List<String> list = new ArrayList<>();
        while ((line = br.readLine()) != null && !line.isEmpty()) {
            list.add(line);
        }
        list.stream().map(Integer::parseInt).sorted(Comparator.reverseOrder()).limit(3).forEach(System.out::println);
    }
}


Measured memory_bytes: 30820
#include <bits/stdc++.h>
using namespace std;
int a,b,c,x;
void solve()
{
    int ans=0;
    for (int i=0;i<=min(x/500,a);i++)
    {
        for (int j=0;j<=min(x/100,b);j++)
        {
            for (int k=0;k<=min(x/50,c);k++)
                if (i*500+j*100+k*50==x) ans++;
        }
    }
    cout<<ans<<endl;
}
int main()
{
    while(cin>>a>>b>>c>>x)
        solve();
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;

#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define fbo find_by_order
#define ook order_of_key
#define INF (ll)1e18
#define PI (ld)3.14159265358979323846
#define print(a); for(auto x:a)cout<<x<<" "; cout<<"\n";
#define mset(a); memset(a,0,sizeof(a));

int main(){
	ios_base::sync_with_stdio(0);cin.tie(0);
    ll a,b;cin>>a>>b;
    if((a+b)&1)cout<<"IMPOSSIBLE\n";
    else cout<<(a+b)/2<<"\n";
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

int main() {
    int n,m; cin >> n >> m;
    if (n == m) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 100

int main(void){
  int n,a[N],i,j,min,ch=0,sw;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n;i++){
    min=i;
    for(j=i;j<n;j++)if(a[j]<a[min])min=j;
    if(min!=i){
      sw=a[min];
      a[min]=a[i];
      a[i]=sw;
      ch++;
    }
  }
  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i!=n-1){
      printf(" ");
    }
  }
  printf("\n");
  printf("%d\n",ch);
  
  return 0;
  
}

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

#define ll long long
#define vvi vector<vector<int>>
#define vec vector
#define pq priority_queue
#define all(v) (v).begin(), (v).end()
#define rep(i, n) for (int (i) = (0); (i) < (n); ++(i))
#define repp(i, m, n) for (int (i) = (m); (i) < (n); ++(i))
#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;
#define debugB(x, y) cerr<<#x<<": "<<bitset<y>(x) << endl;
#define line() cerr << "---------------" << endl;

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

template<typename T>
   void printA(vector<T> &printArray, char between = ' ') {
   int paSize = printArray.size();
   for (int i = 0; i < paSize; i++) { cerr << printArray[i] << between;}
   if (between != '\n') {cerr << endl;}
}

// ------------------------------------------------------------------------------------------
const int INF = 1e9+1000;

int main() {
   int n, a, b;
   cin >> n >> a >> b;
   a -= b;
   vec<int> d(n);
   rep (i, n) cin >> d[i];

   int l = 0, r = INF;
   while (l+1<r) {
      ll mid = (l+r)/2;
      ll tmp = 0;
      rep (i, n) {
         ll x = max(d[i]-mid*b, 0LL);
         ll s = (x+a-1)/a;
         tmp += s;
      }
      if (tmp <= mid) r = mid;
      else l = mid;
   }
   cout << r << endl;

   return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
const int N=2e5+10;
int a[N];
bool ok=1;
int main()
{
	int n;
	scanf("%d",&n);
	for(int i=1;i<=n;++i)
	scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=2;i<=n;++i)
	if(a[i]==a[i-1])ok=0;
	puts(ok?"YES":"NO");
	return 0;
}

Measured memory_bytes: 1152
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_map>
#include <unordered_set>
#include <list>
#include <bitset>

using namespace std;
typedef pair<int, int> Pi;
typedef long long ll;
#define pii Pi
#define pll PL
#define Fi first
#define Se second
#define pb(x) push_back(x)
//#define sz(x) ((int)(x).size())
#define rep(i, n) for(int i=0;i<n;i++)
#define all(x) (x).begin(), (x).end()
typedef tuple<int, int, int> t3;
typedef pair<ll, ll> pll;
typedef long double ldouble;
typedef pair<double, double> pdd;

const double PI = acos(-1);
const double EPS = 1e-9;

const int MX = 100005;
const int MM = 1000000007;

pii D[MX];
int chk[MX];
int N, X, Y, Z;

int main()
{
	ll ans = 0;
	scanf("%d%d%d", &X, &Y, &Z);
	N = X+Y+Z;
	for(int i = 1; i <= N; i++){
		int a, b, c;
		scanf("%d%d%d", &a, &b, &c);
		ans += a;
		D[i] = pii(b-a, c-a);
	}
	sort(D+1, D+N+1, [](pii l, pii r){
		return l > r;
	});

	priority_queue<pii> Q, R, S;
	for(int i = 1; i <= Y; i++){
		ans += D[i].first;
		Q.emplace(D[i].second - D[i].first, i);
		chk[i] = 1;
	}
	for(int i = Y+1; i <= N; i++){
		R.emplace(D[i].second, i);
		S.emplace(D[i].first, i);
	}
	for(int t = 1; t <= Z; t++){
		if( R.top().first >= Q.top().first + S.top().first){
			chk[R.top().second] = 1;
			ans += R.top().first;
		}
		else{
			chk[S.top().second] = 1;
			ans += S.top().first + Q.top().first;
			Q.pop();

			int v = S.top().second;
			Q.emplace(D[v].second - D[v].first, v);
		}
		while(R.size() && chk[R.top().second] ) R.pop();
		while(S.size() && chk[S.top().second] ) S.pop();
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#include <stdio.h>
 
using namespace std;
 
#define int long long
#define rep(i, a, b) for (int i = (a); i < (b); ++i)
#define trav(i, a) for (auto &i: (a))
#define sz(x) (int)(x).size()
#define all(v) (v).begin(), (v).end()
#define fr(i, a, b) for (int i = (a); i <= (b); ++i)

void solve();
signed main () {
    clock_t beg = clock();
    cout << fixed << setprecision(15);
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    #ifdef LOCAL
    freopen("input.txt", "r", stdin);
    #endif 
    int t=1; 
    // cin >> t;    
    int tt = t;
    while (t--) {
        // cout << "Case #" << tt - t << ": "; 
        solve();
    }
    // cerr << "\nExecution time: " << (clock() - beg) / 1000 << '\n';
    return 0;
}
// int arr[(int)1e5+2];
void solve(){
    int a,b,c,d;
    cin>>a>>b>>c>>d;
    cout<<max(a*c,max(b*d,max(a*d, b*c)));
    cout<<endl;
}
    

Measured memory_bytes: 3648
import sys
s = list(input())
 
if s[0] != 'A':
    print('WA')
    sys.exit(0)

for i in range(2, len(s) - 1):
    if s[i] == 'C':
        s.pop(i)
        break
else:
    print('WA')
    sys.exit(0)
 
if ''.join(s[1:]) == ''.join(s[1:]).lower():
    print('AC')
else:
    print('WA')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i,n) for (ll i = 0; i < (n); ++i)
#define vcout(v) rep(i,v.size()) cout << v[i] << " "; cout << endl
#define mcout(m) rep(j,m.size()){vcout(m[j]);}
const ll MOD = 1e9 + 7;

void mainsolve(){

	ll n,m;
	cin >> n >> m;
	vector<vector<ll>> a(n,vector<ll>(m));
	rep(i,n) rep(j,m){
		cin >> a[i][j];
		a[i][j]--;
	}

	vector<ll> kouho(m);

	set<ll> sports;
	rep(i,m) sports.insert(i);

	rep(i,m){
		
		ll nowm = a[0].size();
		assert(nowm > 0);

		vector<ll> cnt(nowm);
		rep(j,n){
			ll p = 0;
			while(true){
				assert(p < nowm);
				if(sports.find(a[j][p]) != sports.end()){
					cnt[a[j][p]]++;
					break;
				}
				else{
					p++;
				}
			}	
		}

		ll maxsport;
		rep(k,nowm){
			ll tmp = kouho[i];
			kouho[i] = max(kouho[i], cnt[k]);
			if(kouho[i] > tmp) maxsport = k;
		}

		sports.erase(maxsport);
	}


	ll res = MOD;
	rep(i,m) res = min(res,kouho[i]);
	cout << res << endl;
	return;
}

int main(){
	
	//ll TC;cin>>TC;rep(I,TC){cout<<"case:"<<I+1<<"---"<<endl; // comment out!
		mainsolve();
	//} // comment out!
	return 0;
}

Measured memory_bytes: 1024
S = input()
l1 = list(S)
l2 = sorted(l1,reverse=True)
m1 = [i for i, x in enumerate(l1) if x == 'W']
m2 = [i for i, x in enumerate(l2) if x == 'W']
count = 0
for i in range(len(m1)):
    count += m1[i] - m2[i]
print(count)

Measured memory_bytes: 22504
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
using P = pair<int,int>;
/* ちゃんと考えてわかって実装 */

# define MAX_N 1000010 // 10^6 + 10

// UnionFindTree
// 使い方(インスタンス名 : tree)
// インスタンス生成 : UnionFind tree;
// tree.init(要素数)
// uniteしたりsameかどうか判定したり

class UnionFind{
    private:
        int par_[MAX_N];
        int rank_[MAX_N];
        int size[MAX_N];
        int groups_;
    
    public:
        void init(int n){ // initializes the tree 
            for(int i=0; i<n; i++){
                par_[i] = i;
                rank_[i] = 0;
                size[i] = 1;
            }
            groups_ = n;
        } 
        int rootOf(int x){ // returns the root of x 
            if(par_[x] == x){
                return x;
            }
            else{
                return par_[x] = rootOf(par_[x]);
            }
        } 
        void unite(int x, int y){ // unites x and y 
            x = rootOf(x);
            y = rootOf(y);
            if(x == y) return;
            if(rank_[x] < rank_[y]){
                par_[x] = y;
                groups_--;
                size[y] += size[x];
            }
            else{
                par_[y] = x;
                groups_--;
                size[x] += size[y];
                if(rank_[x] == rank_[y]) rank_[x]++;
            }
        }
        bool isSameGroupe(int x, int y){ // whether x and y are united
            return rootOf(x) == rootOf(y);
        }
        int countGroups(){ // returns the number of groups
            return groups_;
        }
        // 6 / 19 Updated!! (連結成分のサイズを返す)
        int sizeOf(int x){
            return size[rootOf(x)];
        }
};


int main(void){
    int n, m, k;
    cin >> n >> m >> k;
    UnionFind tree;
    tree.init(n);
    vector<int> frnd(n);
    for(int i=0; i<n; i++) frnd[i] = 0;

    for(int i=0; i<m; i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        frnd[a]++;
        frnd[b]++;
        tree.unite(a, b);
    }

    vector<int> blck(n);
    // 同じ連結成分にいるblock相手を数える
    for(int i=0; i<k; i++){
        int c, d;
        cin >> c >> d;
        c--; d--;
        if(tree.isSameGroupe(c, d)){
            blck[c]++;
            blck[d]++;
        }
    }

    for(int i=0; i<n; i++){
        int ans_i = 0;
        ans_i += tree.sizeOf(i);
        ans_i -= frnd[i];
        ans_i -= blck[i];
        // 自分自身を引く
        ans_i -= 1;
        cout << ans_i << " "; 
    }
    return 0;
}

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

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

	int q;cin>>q;
	while(q--){
		int com,l,u;cin>>com>>l>>u;
		if(com==0){
			cout<<(*minmax_element(next(a.begin(),l),next(a.begin(),u)).first)<<endl;
		}else{
			cout<<(*minmax_element(next(a.begin(),l),next(a.begin(),u)).second)<<endl;
		}
	}
  return 0;
}



Measured memory_bytes: 3072
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;
//a%kで決め打ち
int main() {
    int n, k;
    cin >> n >> k;
    vector<ll> num(k,0);
    for(int i = 1; i <= n; ++i) num[i%k]++;
    ll ans = 0;
    for(int a = 0; a < k; ++a) {
        int b = (k-a)%k;
        int c = (k-a)%k;
        if((b+c)%k!=0) continue;
        ans += num[a]*num[b]*num[c]; 
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4768
#include<iostream>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
#include<vector>
#include<cmath>
#include<cstring>
#include<cstdio>
#include<time.h>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
const double PI=acos(-1);
const double EPS=1e-10;
const int inf=1e8;
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
int main(){
	int n;
	while(cin>>n){
		int d=(n-1)%39+1;
		cout<<"3C";
		cout<<(d/10==0?"0":"")<<d<<endl;
	}
}

Measured memory_bytes: 1160
#include <cstdio>
#include <cstring>
#include <ctime>
#include <cstdlib>
#include <cmath>
#include <iostream>
#include <string>
#include <queue>
#include <map>
#include <stack>
#include <vector>
#include <algorithm>
#include <set>
#include <deque>
#include <utility>
#include <chrono>
#include <sstream>
#include <iomanip>

#define INF 1 << 30
#define MOD 1000000007
#define PI 3.14159265358979
#define rep(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define rer(i, l, r) for (int (i) = (int)(l); (i) <= (int)(r); (i)++)
#define reu(i, l, r) for (int (i) = (int)(l); (i) < (int)(r); (i)++)
#define D(x) cout << x << endl
#define d(x) cout << x
#define all(x) (x).begin(), (x).end()
#define pub(x) push_back(x)
#define pob() pop_back()
#define puf(x) push_front(x)
#define pof() pop_front()
#define mp(x, y) make_pair((x), (y))
#define fi first
#define se second
#define setp(x) setprecision(x)

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long long> vll;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
template<typename T, typename U> inline void amin(T &x, U y) { if (y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if (x < y) x = y; }

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

int main() { 
        int n;
        cin >> n;
        vi a(n);
        int sum = 0;
        rep(i, n) {
                cin >> a[i];
                sum += a[i];
        }
        int ave = sum / n;

        int ans = INF;
        int res;
        for (int j = -1; j <= 1; j++) {
                res = 0;
                rep(i, n) {
                        res += ((ave + j) - a[i]) * ((ave + j) - a[i]);
                }
                amin(ans, res);
        }
       
        D(ans);

        return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define int long long
#define ljc 998244353
using namespace std;
#define gc getchar
inline ll read(){
    register ll x=0,f=1;char ch=gc();
    while (!isdigit(ch)){if (ch=='-') f=-1;ch=gc();}
    while (isdigit(ch)){x=(x<<3)+(x<<1)+ch-'0';ch=gc();}
    return (f==1)?x:-x;
}
int n;
struct node{
	ll x;
	int id;
}x[1010101];
inline bool cmp(node a,node b){
	return a.x>b.x;
}
int sz[1010101],ans[1010101];
map<ll,int> mp;
vector<pair<int,int> > as;
signed main(){
	n=read();
	for (int i=1;i<=n;i++) x[i].x=read(),x[i].id=i,sz[i]=1,mp[x[i].x]=i;
	sort(x+1,x+1+n,cmp);
	if (n==1){
		puts(x[1].x==0?"":"-1");
		return 0;
	}
	if (n==2){
		puts("-1");
		return 0;
	}
	for (int i=1;i<n;i++){
		if (!mp.count(x[i].x-n+sz[x[i].id]+sz[x[i].id])){
			puts("-1");
			return 0;
		}
		int faa=mp[x[i].x-n+sz[x[i].id]+sz[x[i].id]];
		as.push_back(make_pair(faa,x[i].id));
		sz[faa]+=sz[x[i].id];
		ans[faa]+=ans[x[i].id]+sz[x[i].id];
	}
	if (ans[x[n].id]!=x[n].x){
		puts("-1");return 0;
	}
	for (auto i:as) printf("%d %d\n",i.first,i.second);
    return 0;
}


Measured memory_bytes: 14648
#include <cstddef>
#include <complex>
#include <iostream>
#include <iomanip>
#include <string>
#include <sstream>
#include <vector>
#include <array>
#include <list>
#include <unordered_map>
#include <unordered_set>
#include <algorithm>
#include <numeric>
#include <limits>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <bitset>
#include <valarray>
#include <utility>
#include <tuple>
#include <cmath>
#include <memory>
#include <random>
#include <fstream>
#include <locale>

using ll = long long;
using ull = unsigned long long;

//vector
template <class T>
using vec = std::vector<T>;

template <class T>
using vvec = vec<vec<T>>;

constexpr std::size_t operator""_sz(ull n) { return std::size_t(n); }

int main()
{
    using namespace std;

    int n, m;
    cin >> n >> m;

    vec<ll> A(n);

    for (auto& e : A)
        cin >> e;

    auto sum = accumulate(A.cbegin(), A.cend(), 0ll);

    auto c = count_if(A.cbegin(), A.cend(), 
        [m, sum](ll x) 
    {
        return x * 4 * m >= sum;
    });

    if (c >= m)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,b,e) for(int i=(b);i<(e);++i)
#define RREP(i,b,e) for(int i=(b)-1;i>=e;--i)
#define rep(i,e) for(int i=0;i<(e);++i)

constexpr int MOD = 1000000007;
constexpr int INF = 1LL << 30;
constexpr long long LLINF = 1LL << 62;
constexpr double EPS = 1e-9;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15) << boolalpha;
  }
} initializer;

template<typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  os << "[";
  for (auto it = vec.begin(); it != vec.end(); ++it) {
    if (it != vec.begin()) os << ", ";
    os << *it;
  }
  return os << "]";
}

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

template<typename Tuple, size_t N>
struct TuplePrinter {
  static void print(const Tuple &t) {
    TuplePrinter<Tuple, N-1>::print(t);
    cout << ", " << get<N-1>(t);
  }
};

template<typename Tuple>
struct TuplePrinter<Tuple, 1> {
  static void print(const Tuple &t) {
    cout << get<0>(t);
  }
};

template<typename... T>
ostream &operator<<(ostream &os, const tuple<T...> &tup) {
  os << "(";
  TuplePrinter<decltype(tup), sizeof...(T)>::print(tup);
  return os << ")";
}

template<typename T>
ostream &operator<<(ostream &os, const set<T> &se) {
  os << "{";
  for (auto it = se.begin(); it != se.end(); ++it) {
    if (it != se.begin()) os << ", ";
    os << *it;
  }
  return os << "}";
}

template<typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &ma) {
  os << "{";
  for (auto it = ma.begin(); it != ma.end(); ++it) {
    if (it != ma.begin()) os << ", ";
    os << it->first << ": " << it->second;
  }
  return os << "}";
}

inline void print(void) { cout<<'\n'; }
template<class T> inline void print(const T &x) { cout<<x<<'\n'; }
template<class T, class... U> inline void print(const T &x, const U&... y) { cout<<x<<" "; print(y...); }


int main() {
  int n, k; cin>>n>>k;
  vector<long long> a(n);
  rep(i, n) cin>>a[i];

  REP(i, k, n) {
    if (a[i] > a[i-k]) print("Yes");
    else print("No");
  }

  return 0;
}

Measured memory_bytes: 4732
n=int(input())
l=input().split()
r=0
if n<3:
  print(0)
else:
  for x in range(n):
    l[x]=int(l[x])

  for i in range(n):
    a=l[i]
    for j in range(n-i-1):
      y=i+j+1
      b=l[y]
    
      for k in range(n-y-1):
        if a<b:
          d=a
          a=b
          b=d
        c=l[k+y+1]
        if a<c:
          f=a
          a=c
          c=b
          b=f
        elif b<c:
          f=b
          b=c
          c=f
        if b+c>a and a-b<c and a!=b and b!=c:
          r=r+1
          
        a=l[i]
        b=l[y]
        c=l[k+1]
  print(r)

Measured memory_bytes: 9248