akhauriyash/Code-Regression huggingface dataset:
#include <iostream>  
using namespace std;  
  
// Important header files   
#include <ext/pb_ds/assoc_container.hpp> // Common file  
#include <ext/pb_ds/tree_policy.hpp>  
#include <functional> // for less  
#include <iostream>  
using namespace __gnu_pbds;  
using namespace std;  
  
// Declaring ordered_set 
typedef tree<int, null_type, less<int>, rb_tree_tag,  
            tree_order_statistics_node_update>  
    ordered_set; 
#define rep(i,n) for(li i=0;i<n;i++)
#define li long long int
#define ll long long int
#define pb push_back
#define all(v) sort(v.begin(),v.end())
const int N = 40043;
const ll mod = 1e9 + 7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define f first
#define s2 second
const ll INF=(1LL<<60)-1;
int dx[]={0,0,1,-1};
int dy[]={1,-1,0,0};

int gcd(int a,int b)
{
    if(b==0) return a;
    return gcd(b,a%b);
}
int lcm(int a,int b)
{
    return (a*b)/gcd(a,b);
}
 
ll power(ll a,ll b,ll mo)
{
    ll ans=1;
	while(b)
	{
		if(b&1) ans=ans*a%mo;
		a=a*a%mo;
		b>>=1;
	}
	return ans;
}
 
li xx,yy,dd;
void equation(li a,li b)
{
    if(b==0)
    {
        xx=1;
        yy=0;
        dd=a;
    }
    else
    {
        equation(b,a%b);
        li temp=xx;
        xx=yy;
        yy=temp-(a/b)*yy;
    }
}
li inverse(li a,li m)
{
    equation(a,m);
    return(xx%m+m)%m;
}
bool compare(const pair<li,li> &i, pair<li,li> &j)
{
    if(i.f==j.f)
    return i.s2 > j.s2;
    else
    return i.f<j.f;
    
}
void solve()
{
    int l,r,d;
    cin>>l>>r>>d;
    int ans=(r)/d;
    ans-=(l)/d;
    if(l%d==0)
    ans++;
    
    cout<<ans;
    
}
signed main()
{
    FAST_IO;
    li t;
    t=1;
  
    while(t--)
    {
        solve();
        cout<<endl;
        
    }
    
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string s,t;
  cin>> s;
  t=s;
  
  
  int n=s.size();
  
  int c1=0;  
  for(int i=0;i<n-1;i++){
    if (s.at(i)==s.at(i+1)){
      c1++;
      if (s.at(i)=='0'){
        s.at(i+1)='1';
      }else {
        s.at(i+1)='0';
      }
    }
  }
  
  int c2=0;
  for(int i=0;i<n-1;i++){
    if (t.at(n-1-i)==t.at(n-1-i-1)){
      c2++;
      if (t.at(n-1-i)=='0'){
        t.at(n-1-i-1)='1';
      }else {
        t.at(n-1-i-1)='0';
      }
    }
  }
  cout << min(c1,c2)<<endl;
}
  
    

Measured memory_bytes: 512
#include <vector>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <algorithm>
typedef long long ll ;
#define rep(i, a, b) for (int i = a; i <= b; ++ i)
const int N = 3e5 + 5 ;
using namespace std ;
int n, m, top = 1, f[N], bit[N] ; vector <int> v[N] ; 
struct poi { int l, r ; } a[N] ;
bool cmp(poi a, poi b) { return a.r > b.r ; }
void put(int x) { for ( ; x <= m; x += x & (- x)) ++ bit[x] ; }
int get(int x) { int ret = 0 ; for ( ; x; x -= x & (- x)) ret += bit[x] ; return ret ; }
int main() {
	scanf("%d%d", &n, &m) ;
	rep(i, 1, n) scanf("%d%d", &a[i].l, &a[i].r) ;
	sort(a + 1, a + n + 1, cmp) ;
	rep(i, 1, m) rep(j, 1, m / i) v[i * j].push_back(i) ;
	for (int i = m; i; -- i) {
		for ( ; top <= n && a[top].r == i ; ++ top) put(a[top].l) ;
		rep(j, 0, (int) v[i].size() - 1) {
			int u = v[i][j] ;
			f[u] += get(i) - get(i - u) ;
		}
	}
	rep(i, 1, m) printf("%d\n", f[i]) ;
	return 0 ;
}

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

int main(){
    
    while(1){
        int H,W;
        cin >> H >> W;
        if(H == 0 && W == 0) break;
        
        for(int i = 0; i < H; i++){
            for(int j = 0; j < W; j++){
                if((i+j)%2) cout << '.';
                else cout << '#';
                
                if(j == W-1) cout << endl;
            }
        }
        cout << endl;
    }
}


Measured memory_bytes: 3104
#include<iostream>
#include<vector>
#include<cmath>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define rep(i,n) for(ll i=0;i<n;++i)
#define ocut cout
#define ouct cout
#define itn int

struct Union{
  vector<ll> par;
  Union(ll a){
  par=vector<ll>(a,-1);
  }
  ll find(ll a){
    if(par[a]<0){
      return a;
    }
    else{
      return par[a]=find(par[a]);
    }
  }
  bool same(ll a,ll b){
    return (find(a)==find(b));
  }
  ll size(ll a){
    return -par[find(a)];
  }
  void unite(ll a,ll b){
    ll c=find(a),d=find(b);
    if(c==d)
      return;
    if(size(c)<size(d)){
      swap(c,d);
    }
    par[c]+=par[d];
    par[d]=c;
  }
};
ll Nagaemon1;
void swap(ll i,ll j){
  Nagaemon1=i;
  i=j;
  j=Nagaemon1;
}
int main(){
  int a,b,c,d;
  cin >> a >> b >> c >> d;
  cout << c-(d-b) <<" "<< d+(c-a) <<" "<< a-(d-b) <<" "<< b+(c-a);
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

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)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define FIND(s, e) ((s).find(e) != (s).end())
#define EB emplace_back
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int N, H, W;
    cin >> N >> H >> W;
    cout << max((N - H + 1) * (N - W + 1), 0) << endl;
}


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

int main() {
        int N, K, P=0;
        cin >> N >> K;
        vector<int> v(N);

        for (int i = 0; i < N; i++) {
                cin >> v.at(i);
        }

        // Simple Sort
        sort(v.begin(), v.end());

        for (int i = 0; i < K; i++) {
                P += v.at(i);
        }
        cout << P <<endl;

}

Measured memory_bytes: 3584
package main

import (
       "bufio"
       "fmt"
       "os"
       "strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func nextInt() int {
     sc.Scan()
     i, e := strconv.Atoi(sc.Text())
     if e != nil {
     	panic(e)
     }
     return i
}

func main() {
     sc.Split(bufio.ScanWords)
     n := nextInt()
     m := nextInt()
     all := 0
     a := make([]int,n)
     for i:=0; i<n; i++ {
     	 a[i] = nextInt()
	 all = all + a[i]
     }
     cut := float64(all) / (float64(4 * m))

     buf := 0
     for i:=0; i<n; i++ {
     	 if float64(a[i]) >= cut {
	    buf++
	 }
     }
     if buf >= m {
     	fmt.Println("Yes")
     } else {
        fmt.Println("No")
     }
}     

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, A, B;
  cin >> N >> A >> B;
  int x, y, z;
  x = y = z = 0;
  for (int i = 0; i < N; i++) {
    int p;
    cin >> p;
    if (p <= A) {
        x++;
    } else if (p <= B) {
        y++;
    } else {
        z++;
    }
  }
  int ans;
  ans = min(x, min(y, z));
  cout << ans << '\n';
  return 0;
}

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

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

#define INF 1000000000
#define MOD 1000000007
#define EPS 1e-12

#define REP(i, a, b) for(int i = (a); i < (b); ++i)
#define ALL(x) x.begin(), x.end()
#define UNIQUE(c) (c).resize(unique(ALL(c)) - (c).begin())

// bitmask operations
#define SETBIT(S, j) S |= (1 << j)
#define CLEARBIT(S, j) S &= ~(1 << j)
#define ISSET(S, j) S & (1 << j)
#define FLIPBIT(S, j) S ^= (1 << j)
#define LSBIT(S) (S & (-S))

// debug
#define DEBUGSTR(S) cout << "(" << S << ")\n";

int main() {
  //ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
  int N;
  scanf(" %d", &N);

  vi v(N);

  REP(i, 0, N)
    scanf(" %d", &v[i]);

  sort(ALL(v));

  reverse(ALL(v));

  int pontos_a = 0, pontos_b = 0;

  for(int i = 0; i < N; i += 2) {
    pontos_a += v[i];
  }

  for(int i = 1; i < N; i += 2) {
    pontos_b += v[i];
  }

  printf("%d\n", pontos_a-pontos_b);
  
  return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
b=[0]*(10**5+5)
for i in range(n):
	b[a[i]]+=1
	b[a[i]+1]+=1
	b[a[i]+2]+=1
print(max(b))
   
    
        
        
    
        


Measured memory_bytes: 13964
#include <iostream>
#include <vector>

using namespace std;

int main() {
	int n;
	cin >> n; 
	vector<int> v(n);

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

	for (int i = n - 1; i > 0; i--) {
		if(v[i] >= v[i - 1]) continue;
        else if(v[i - 1] - 1 == v[i]) v[i - 1] -= 1; 
        else {
          cout << "No";
          return 0;
        }
	}

	cout << "Yes";
}


Measured memory_bytes: 768
#include <string.h>
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <istream>
#define INF 2147483647
#define LLINF 9223372036854775807
typedef long long ll;
using namespace std;
long double a[200010];
long double num[200010];
int main(){
	int n,k;
	cin>>n>>k;
	for(int i=0;i<n;i++){
		cin>>a[i];
		num[i]=(a[i]+1.00)/2.00;
	}
	long double ans=0.00;
	long double mx=0.00;
	for(int i=0;i<k;i++){
		ans+=num[i];
	}
	mx=max(mx,ans);
//	cout<<ans<<endl;
	for(int i=0;i<n-k;i++){
		ans-=num[i];
		ans+=num[i+k];
//		cout<<ans<<" "<<i+k-1<<" "<<endl;
		mx=max(mx,ans);
	}
	cout<<fixed<<setprecision(12)<<mx<<endl;
	return 0;
}

Measured memory_bytes: 6528
#include <iostream>
#include <string>
using namespace std;
int main() {
	int t[10] = { 0 };
	string s;

	cin >> s;

	for (int i = 0; i < 3; i++)
	{
		t[s[i]-'a']++;
	}

	if (t[0] == 1 && t[1] == 1 && t[2] == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}

Measured memory_bytes: 256
N, Y= list(map(int, input().split()))
ans = []
for i in range(N+1):
    for j in range (N-i+1):
        k = N-i-j 
        if 0<= k <= 2000 and 10000*i + 5000*j + 1000*k ==Y:
            print(i,j,k)
            exit()
print(-1,-1,-1)

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

typedef long long LL;

const int N=99;

int n;

void into(){
  scanf("%d",&n);
}

int ans[N*2+9];

int Query(int p){
  cout<<"? ";
  for (int i=0;i<n;++i) cout<<p+i<<' ';
  cout<<endl;
  fflush(stdout);
  string s;
  cin>>s;
  return s[0]=='R';
}

int Query(int l,int r,int p0){
  cout<<"? ";
  if (l<p0&&p0<r){
	for (int i=l;i<p0;++i) cout<<i<<' ';
	for (int i=p0+1;i<=r;++i) cout<<i<<' ';
	cout<<endl;
  }else{
	for (int i=l+1;i<r;++i) cout<<i<<' ';
	cout<<p0<<endl;
  }
  fflush(stdout);
  string s;
  cin>>s;
  return s[0]=='R'^(l<p0&&p0<r);
}

void Two_divide_ans(){
  int l=1,r=n+1,tl=Query(l),tr=Query(r);
  for (int mid,tm;r-l>1;mid=l+r>>1,(tm=Query(mid))==tl?l=mid:r=mid);
  ans[l]=tl;ans[l+n]=tr;
  for (int i=1;i<=n<<1;++i)
	if (i^l&&i^l+n) ans[i]=Query(l,l+n,i);
}

void work(){
  Two_divide_ans();
}

void outo(){
  cout<<"! ";
  for (int i=1;i<=n<<1;++i)
	cout<<(ans[i]?'R':'B');
  cout<<endl;
}

int main(){
  into();
  work();
  outo();
  return 0;
}

Measured memory_bytes: 3856
#include<iostream>
#include<vector>
#include<string>
#include<iomanip>
#include<algorithm>

using namespace std;

int main(){
int N,M; cin >> N >> M;
  vector<int> P(M); vector<int> Y(M); 
  for(int i = 0 ; i < M; i++){ cin >> P[i] >> Y[i]; P[i]--;}
  
  vector<vector<int>> val(N);
  for(int i = 0; i < M; i++){
    val[P[i]].push_back(Y[i]);}
  for(int j = 0; j < N; j++){
    sort(val[j].begin(),val[j].end());}
  
  for(int i = 0; i < M; i++){
    int v = P[i];
    cout << setw(6) << setfill('0') << v + 1 ;
    
    int id = lower_bound(val[v].begin(),val[v].end(),Y[i]) - val[v].begin();
    cout << setw(6) << setfill('0') << id + 1 << endl;}
  
  return 0; }
  

Measured memory_bytes: 7808
n=int(input())
hoge=list(map(int,input().split()))
ans1=0
ans2=0
for i in range(n):
  ans1+=hoge[i]*hoge[i]
  for j in range(n):
    ans2+=hoge[i]*hoge[j]
    
print((ans2-ans1)//2)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#include <math.h>
#include <iomanip>
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF=1e9;
const int mod = 1000000007;

int main(){
  int N;
  cin>>N;
  int64_t ans=1;
  for(int i=0;i<N;i++){
    int64_t x;
    cin>>x;
    ans=ans/__gcd(ans,x)*x;
  }
  cout<<ans<<endl;
  return 0;                       
}

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

using namespace std;

int main()
{
  string s; cin >> s;
  set<int> st;
  st.insert(s[0]);
  st.insert(s[1]);
  st.insert(s[2]);

  if (st.size() == 3) cout << "Yes" << endl;
  else cout << "No" << endl;
}


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

using namespace std;
/*
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds; 

typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
*/
#define pfi(a) printf("%d",a);
#define pfl(a) printf("%lld",a);
#define pfin(a) printf("%d\n",a);
#define pfln(a) printf("%lld\n",a);
#define sfi(a) scanf("%d",&a);
#define sfl(a) scanf("%lld",&a);
#define pb push_back
#define f(i,a,b) for(int i=a;i<b;i++)
#define ll long long
#define inf INT_MAX
#define llinf LONG_LONG_MAX

const int N=50+3;
const int M=998244353;


int main(){

	long double a,b;
	cin>>a>>b;

	a*=b;

	ll num=a;

	cout<<num;

	return 0;
}

Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
uint64_t n,lim,tmp,ans=0;
std::vector<int> high;

void solve(){
  for(int i=0;i<n;i++){
    if(high.at(i)>=lim){
      ans++;
    }
  }

  cout<<ans<<endl;
}


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

  for(int i=0;i<n;i++){
    cin>>tmp;
    high.push_back(tmp);
  }

  solve();
  return 0;
}


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

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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define ALL(v) (v.begin(),v.end())
#define COUT(x) cout<<(x)<<"\n"



int main(){
    int k,a,b;
    cin >> k >> a >> b;
    for(int i=1;i<1001;i++){
        if(a<=k*i&&k*i<=b){
            COUT("OK");
            return 0;
        }
    }
    COUT("NG");
    return 0;
}

Measured memory_bytes: 3624
#include <iostream>

using namespace std;

int main()	{
  int n;
  cin >> n;
  long long total = 0;
  int a, b;
  for (int i = 0; i < n; i++)	{
    cin >> a >> b;
    total += b - a + 1;
  }
  cout << total << endl;
  return 0;
}

Measured memory_bytes: 3620
#include <iostream>

using namespace std;

int ganswer(int x, int y, int n, int *table[])
{

  if ((x == (n-1)) && (y == 1))
    return table[1][n-1];

  if (x == (n-1)) {
    return table[0][n-1] + ganswer(n-1,1,n, table);
  }

  int right = table[y][x] + ganswer(x+1,y, n, table);
 
  if (y == 1) {
    return right;
  }

  int down = table[y][x] + ganswer(x, y+1, n, table);

  return (down > right ? down : right);

}

int main()
{
  int n;
  cin >> n;
  int *a[2];
  int i;
  for (i = 0; i < 2; i++) {
    a[i] = new int[n];
  }
  for (i = 0; i < n; i++) {
    cin >> a[0][i];
  }  
  for (i = 0; i < n; i++) {
    cin >> a[1][i];
  }  

  cout << ganswer(0,0,n,a) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using ull = long long unsigned;
using P = pair<int,int>;
const int INF=1001001;
const int NMAX=8;

//head

struct pcake{

	ll a;
	ll b;
	ll c;
	pcake(ll a1,ll b1,ll c1){
		a=a1;b=b1;c=c1;
	}

	bool operator<(const pcake& other) const {
		return a < other.a;
	}
};

int main()
{
	int x,y,z,k;
	cin>>x>>y>>z>>k;
	vector<ll> A(x);
	vector<ll>B(y);
	vector<ll> C(z);
	rep(i,x)cin>>A[i];
	rep(i,y)cin>>B[i];
	rep(i,z)cin>>C[i];
	sort(A.begin(),A.end());
	sort(B.begin(),B.end());
	sort(C.begin(),C.end());


	ll now=A[x-1]+B[y-1]+C[z-1];

	priority_queue <pair<ll,pcake>> q;
	pcake p1(x-1,y-1,z-1);
	q.push(make_pair(now,pcake(x-1,y-1,z-1)));
	set<ll>s;

	rep(i,k){
		auto qnow=q.top();
		q.pop();
		cout<<qnow.first<<endl;



	 ll a1=qnow.second.a;
	 ll b1=qnow.second.b;
	 ll c1=qnow.second.c;

	 ll hash=a1*100000000+b1*10000+c1;
	 s.insert(hash);

		if (a1>0){

			//cout<<p.a<<endl;

			ll s1=A[a1-1]+B[b1]+C[c1];
		//	cout<<s1<<endl;
			pcake pnow1(a1-1,b1,c1);
			if (s.find((a1-1)*100000000+b1*10000+c1)==s.end())
			//cout<<pnow1.a<<endl;
			q.push(make_pair(s1,pnow1));
			s.insert((a1-1)*100000000+b1*10000+c1);
		}


		if (b1>0){
			ll s2=A[a1]+B[b1-1]+C[c1];
			pcake pnow2(a1,b1-1,c1);
					if (s.find(a1*100000000+(b1-1)*10000+c1)==s.end())
				q.push(make_pair(s2,pnow2));
					s.insert(a1*100000000+(b1-1)*10000+c1);
			}


		if (c1>0){
			ll s3=A[a1]+B[b1]+C[c1-1];
		//	cout<<s3<<'s'<<endl;
			pcake pnow3={a1,b1,c1-1};
				if (s.find(a1*100000000+b1*10000+c1-1)==s.end())
				q.push(make_pair(s3,pnow3));}
					s.insert(a1*100000000+b1*10000+c1-1);

	}



}


Measured memory_bytes: 768
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
using namespace std;

int main()
{
	long long n, t, a;
	cin >> n >> t >> a;
	vector<int>h(n);
	vector<double>tmpH;
	for (int& x : h)cin >> x;
	for (int i = 0; i < n; i++) {
		tmpH.push_back(abs(a -(t- h[i] * 0.006)));
	}
	vector<double>::iterator itr = min_element(tmpH.begin(),tmpH.end());
	size_t index = distance(tmpH.begin(),itr);
	cout << index+1 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define PI 3.14159265359
#define NIL (-1)
#define LL long long
using namespace std;
const int64_t MOD = 1e9 + 7;
const int INF = INT_MAX;

int main() {
	int64_t r, D, x;
	cin >> r >> D >> x;

	for (int i = 0; i < 10; i++) {
		x = x * r - D;
		cout << x << endl;
	}
}

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

using namespace std;

using int64 = long long;

int64 N, S, X[100000], P[100000];
int64 ret, last;

void rec(int l, int r) {
  if(X[r] < S) {
    ret += S - X[l];
    last = X[l];
  } else if(X[l] > S) {
    ret += X[r] - S;
    last = X[r];
  } else if(P[l] >= P[r]) {
    P[l] += P[r];
    rec(l, r - 1);
    ret += abs(last - X[r]);
    last = X[r];
  } else {
    P[r] += P[l];
    rec(l + 1, r);
    ret += abs(last - X[l]);
    last = X[l];
  }

}

int main() {

  cin >> N >> S;
  for(int i = 0; i < N; i++) {
    cin >> X[i] >> P[i];
  }
  rec(0, N - 1);
  cout << ret << endl;
}

Measured memory_bytes: 4352
#define rep(i,n) for(ll i=0, i##_len=(n); i<i##_len; ++i)
#define rrep(i,a,b) for(ll i=(b)-1; i>=a; --i)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define ALL(obj) (obj).begin(), (obj).end()
#define scanv(n,v) v.resize(n); rep(i,n){ cin>>v[i];}
#define MOD 1000000007ll
#define Yes(flag) cout<<((flag)? "Yes":"No");
#define YES(flag) cout<<((flag)? "YES":"NO");
#define be begin
#define pb push_back
#define fi first
#define se second
#define square(x) x*x
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
template<class T>T 
chmin(T& a,T b){if(a>b){a=b;return true;}return false;}
template<class T>T 
chmax(T& a,T b){if(a<b){a=b;return true;}return false;}
//------------------------------------------------------
ll n,k;
map<char,int> mp;
vector<ll> a;
void input(){
    cin>>n;
    rep(i,n){
        char c;
        cin>>c;
        mp[c]++;
    }
}
void src(){
    Yes(mp['R']>mp['B']);
}    
int main(int argc,char* argv[]){
    ios::sync_with_stdio(false);
 //   ifstream in( argv[1] ); cin.rdbuf(in.rdbuf());
    input();
    src();    
}

Measured memory_bytes: 256
def main():
    # 下、右、上、左
    dy = [1, 0, -1, 0]
    dx = [0, 1, 0, -1]
    H, W = map(int, input().split())
    s = [["."] * (W + 2)]
    s += [["."] + list(input()) + ["."] for i in range(H)]
    s.append(["."] * (W + 2))
    for y in range(1, H + 1):
        for x in range(1, W + 1):
            if s[y][x] == "#" and s[y + dy[0]][x + dx[0]] == "."\
                    and s[y + dy[1]][x + dx[1]] == "."\
                    and s[y + dy[2]][x + dx[2]] == "."\
                    and s[y + dy[3]][x + dx[3]] == ".":
                print("No")
                return
    print("Yes")
    return


main()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef tuple<ll, ll, ll> T;

ll N, x;
vector<ll> a(100000, 0);

int main(void){
	
	scanf("%lld %lld", &N, &x);
	for(int i = 0; i < N; ++i) scanf("%lld", &a[i]);
	
	ll ans = 0;
	for(int i = 0; i < N - 1; ++i){
	    ll sum = a[i] + a[i + 1];
	    ans += max(sum - x, (ll)0);
	    if(sum > x){
	        a[i + 1] -= (sum - x);
	        if(a[i + 1] < 0) a[i] += a[i + 1], a[i + 1] = 0;
	    }
	}
	printf("%lld\n", ans);
	
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <vector>
#include <map>
#include <string>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <cmath>
using namespace std;

typedef unsigned long long ull;
const int MAX_N = 300001;
// B := 基数
const int B = 1000000007;
// B_inv := mod 2^64 における B の逆元 (Rubyで求めた)
const ull B_inv = 13499267949257065399ull;

// base[i] := B^i を返す. (Bは基数) 
ull base[MAX_N] = {1};

int main(){
	int N, M, k=0, m=1;
	string s;
	cin >> N >> M >> s;
	
	// h(k,m) := s[k] から m 文字のハッシュ値 (mod 2^64)
	// h(k,m) := s[0] * B^(m-1) + s[1] * B^(m-2) + ... + s[m-1] * B^0 (mod 2^64)
	// h(k,m) は 1つの変数 hash に保持して文字を1文字進める,戻すたびに前のハッシュからO(1)で計算していく
	// k=0, m=1 のときは hash := s[0] * B^0
	ull hash = s[0];
	// i = 0..n-1 について B^i を計算しておく
	for(int i=1 ; i <= N ; i++ ){
		base[i] = base[i-1] * B;
	};
	
	// 解
	set<ull> ans;
	for(int i=0 ; i < M ; i++ ){
		string q;
		cin >> q;
		
		if( q == "L++" ){
			// h(k+1,m-1) := h(k,m) - s[k] * B^(m-1)
			hash = hash - s[k] * base[m-1];
			k++;
			m--;
		}else if( q == "L--" ){
			// h(k-1,m+1) := h(k,m) + s[k-1] * B^m
			hash = hash + s[k-1] * base[m];
			k--;
			m++;
		}else if( q == "R++" ){
			// h(k,m+1) := h(k,h) * B + s[k+m] * B^0
			hash = hash * B + s[k+m];
			m++;
		}else if( q == "R--" ){
			// h(k,m-1) := (h(k,m) - s[k+m-1]) / B
			// 合同式の割り算は普通に割り算するとだめなので
			// 基数Bについて B の mod逆元 B^(-1) を求めてそれを掛ける.
			// h(k,m-1) := (h(k,m) - s[k+m-1]) * B_inv
			hash = (hash - s[k+m-1]) * B_inv;
			m--;
		}
		ans.insert( hash );
		// cout << hash << endl;
	}
	cout << ans.size() << endl;
}

Measured memory_bytes: 17652
import           Control.Monad
import qualified Data.Array.IO               as IO
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

main = do
  [l, r] <- getIntList
  let r'= min (l + 2020) r
      ans = V.minimum $ V.fromList [x * y `mod` 2019 | x <- [l..(r'-1)], y <- [(x+1)..r']]
  print ans


Measured memory_bytes: 892
import sys
sys.setrecursionlimit(1 << 25)
read = sys.stdin.readline
ra = range
enu = enumerate


def exit(*argv, **kwarg):
    print(*argv, **kwarg)
    sys.exit()


def mina(*argv, sub=1): return list(map(lambda x: x - sub, argv))
# 受け渡されたすべての要素からsubだけ引く.リストを*をつけて展開しておくこと


def ints(): return list(map(int, read().split()))


def read_col(H):
    '''H is number of rows
    A列、B列が与えられるようなとき
    ex1)A,B=read_col(H)    ex2) A,=read_col(H) #一列の場合'''
    ret = []
    for _ in range(H):
        ret.append(list(map(int, read().split())))
    return tuple(map(list, zip(*ret)))


import numpy as np
# from numba import njit

N, W_max = ints()
W, V = read_col(N)
W = np.array(W, dtype=np.int64)
V = np.array(V, dtype=np.int64)

'''
dp[i,j] ... 重さの最小 (:iまで考慮したとき、価値がちょうどjのとき)
答えはW以下の数字が入ってるマスの一番左側

更新則
chmin(dp[i+1,j+V[i]] , dp[i, j]+W[i]) #ナップサックに入れた場合
chmin(dp[i+1,j] , dp[i, j]) # ナップサックに入れなかった場合
'''


# @njit('(i8, i8, i8[:], i8[:])', cache=True)
def solve(N, W_max, W, V):
    V_max = np.sum(V) + 1
    dp = np.full((N + 1, V_max), 10**12, dtype=np.int64)
    # 初期化
    dp[0][0] = 0  # 一個も選ばず価値が0なら必ず重さも0

    # 更新
    for i in range(N):
        dp[i + 1, :] = np.minimum(dp[i + 1, :], dp[i, :])
        dp[i + 1, V[i]:] = np.minimum(dp[i + 1, V[i]:], dp[i, :-V[i]] + W[i])
        # for j in range(V_max):
        #     jv = j + V[i]
        #     if jv < V_max:
        #         dp[i + 1, jv] = min(dp[i + 1, jv], dp[i, j] + W[i])
        #     dp[i + 1, j] = min(dp[i + 1, j], dp[i, j])

    # 左から見てく
    for j in range(V_max - 1, -1, -1):
        if np.any(dp[:, j] <= W_max):
            print(j)
            return


solve(N, W_max, W, V)


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

int main(){
	cin.tie(0),ios::sync_with_stdio(false);
	int n; cin>>n;
	vector<int>a(n);
	for(auto&i:a)cin>>i;
	sort(a.begin(),a.end());
	int ans;
	for(int i=n-2;i>=0;--i){
		if(a.at(i)==a.at(i+1)){
			ans=a.at(i);
			for(int j=i-2;j>=0;--j){
				if(a.at(j)==a.at(j+1)){
					cout<<(int64_t)ans*a.at(j)<<"\n"s;
					return 0;
				}
			}
			cout<<0<<"\n"s;
			return 0;
		}
	}
	cout<<0<<"\n"s;
	return 0;
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>
#include <iomanip>
#include <set>
#include <map>

using namespace std;

#define PI (3.14159265358979323846)
#define INF (2147483647)
#define INF_LL (9223372036854775807)
#define DIV_NUM (1000000007)
typedef long long ll;

// 配列初期化テンプレ
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T& val) {
	std::fill((T*)array, (T*)(array + N), val);
}


int main() {

	int X;
	cin >> X;

	if (X >= 30) cout << "Yes" << endl;
	else cout << "No" << endl;

	return 0;
}


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

int main(){
    string S,T;
    cin>>S>>T;
    string K=S+S;
    bool flg=false;
    for(int i=0;i<S.size();i++){
        string V=K.substr(i,S.size());
        if(V==T){
            flg=true;
            break;
        }
    }
    if(flg){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;
template<typename T>
void print(T x) {
    cout << x << endl;
}
int main(void) {
    string s; cin >> s;
    if(s[0] == 'A') print("T");
    if(s[0] == 'T') print("A");
    if(s[0] == 'G') print("C");
    if(s[0] == 'C') print("G");
}


Measured memory_bytes: 256
import sys
n = int(input())
d = list(map(int, input().split()))
if d[0] != 0:
    print(0)
    sys.exit()
d.sort()
d.append(-1)
if d[1] == 0:
    print(0)
    sys.exit()
i = 1
distance = 1
count = 0
while d[i] == distance:
    count += 1
    i += 1
branch = count
ans = 1
while True:
    count = 0
    distance += 1
    while d[i] == distance:
        count += 1
        i += 1
    ans *= (branch**count)%998244353
    branch = count
    if i >= n:
        break
print(ans%998244353)

Measured memory_bytes: 52952
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long y = sc.nextLong();
    int ans1 = -1;
    int ans2 = -1;
    int ans3 = -1;
    for(int i = 0; i <= n; i++) {
      for(int j = 0; j <= (n - i); j++) {
        int k = n - (i + j);
        long t = (long)10000 * (long)i + (long)5000 * (long)j + (long)1000 * (long)k;
        if(t == y) {
          ans1 = i;
          ans2 = j;
          ans3 = k;
        }
      }
    }
    System.out.println(ans1 + " " + ans2 + " " + ans3);
  }
}

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

bool isOK(int index, int key, const vector<int> &v) {
    if (v.at(index) >= key) return true;
    else return false;
}

int binary_search(int key, const vector<int> &v) {
    int ng = -1;
    int ok = (int)v.size();

    while (abs(ok - ng) > 1) {
        int mid = (ok + ng) / 2;

        if (isOK(mid, key, v)) ok = mid;
        else ng = mid;
    }
    return ok;
}

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for(int i = 0; i < n; i++)
    {
        cin >> a.at(i);
    }
    for(int i = 0; i < n; i++)
    {
        cin >> b.at(i);
    }

    long long ans = 0;
    long long k = 1;
    vector<int> amodk(n), bmodk(n);
    for(int i = 0; i < 30; i++)
    {
        for(int j = 0; j < n; j++)
        {
            amodk.at(j) = a.at(j) % (k * 2);
            bmodk.at(j) = b.at(j) % (k * 2);
        }
        sort(bmodk.begin(), bmodk.end());
        
        long long cnt = 0;
        for (int ai = 0; ai < n; ai++) { 
            int index_k_or_more = binary_search(k - amodk.at(ai), bmodk);
            int index_2k_or_more = binary_search(k * 2 - amodk.at(ai), bmodk);
            int index_3k_or_more = binary_search(k * 3 - amodk.at(ai), bmodk);
            
            cnt += index_2k_or_more - index_k_or_more + n - index_3k_or_more;
        }
        
        if (cnt % 2 == 1) ans += k;
        
        k *= 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3328
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <deque>
#include <set>
#include <iomanip>
#include <utility>
#define ll long long
#define ld long double
using namespace std;

int main() {
	int N;
	cin >> N;
	int p=(N+1)/2;
	cout << setprecision(10) << (ld) p/N << endl;
	return 0;
}


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

//{ START
using namespace std;
#define int int64_t
#define rep(i, a, n) for (int i = (a); i < (n); ++i)
#define reps(i, a, n) for (int i = (a); i > (n); --i)
#define arep(i, x) for (auto &&i : (x))
#define irep(i, x) for (auto i = (x).begin(); i != (x).end(); ++i)
//降順はgreater<T>()
#define all(x) (x).begin(), (x).end()
#define rv(s) reverse((s).begin(), (s).end())
//gcd lcmはそのままok
#define gcd(a, b) __gcd(a, b)
#define bits(n) (1 << (n))
#define pcnt(x) __builtin_popcountll(x)
//配列内等要素削除
#define unique(x) (x).erase(unique(x).begin(),(x).end()),(x).end())
#define Fixed(n) fixed << setprecision(n)
//総和
#define sowa(n) ((n) * ((n) + 1)) / 2
#define pb(x, a) (x).push_back(a)
#define fb(x, a) (x).push_front(a)
#define eb(x, a) (x).emplace_back(a)
#define F first
#define S second
#define cauto const auto &
using P = pair<int, int>;
using Graph = vector<vector<P>>;
template <class T> //昇順
using min_heap = priority_queue<T, vector<T>, greater<T>>;
template <class T> //降順
using max_heap = priority_queue<T>;
template <class A, class B>
using umap = unordered_map<A, B>;
template <class A>
using uset = unordered_set<A>;
template <class T>
bool chmax(T &a, const T &b) //最大値更新 返り値はbool
{
    if (a < b)
    {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) //最小値更新 返り値はbool
{
    if (b < a)
    {
        a = b;
        return 1;
    }
    return 0;
}
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
constexpr int INF = 0x3f3f3f3f;
constexpr int LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int mod1 = 1e9 + 7;
constexpr int mod2 = 998244353;
//} END

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

    int n, x, cnt = 0;
    cin >> n;
    map<int, int> mp;

    rep(i, 1, n + 1)
    {
        int x;
        cin >> x;
        int ans = i - x;
        cnt += mp[ans];
        ++mp[i + x];
    }

    cout << cnt << '\n';
    return 0;
}

Measured memory_bytes: 26296
using namespace std;

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

void solve(){

}
long long getDigitSum(long long num){
    long long sum = 0;
    while(num > 0){ 
        sum += num % 10; 
        num /= 10;
    }
    return sum;
}
int main(){
    ll n;
    cin >> n;
    if (n % getDigitSum(n) == 0){
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }


    return 0;
}


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

int main()
{
	int h, w, k;
	cin >> h >> w >> k;
	auto c = vector<string>(h);
	int all = 0;
	for(int i = 0; i < h; ++i){
		cin >> c[i];
	}
	int ans = 0;
	for(int y = 0; y < (1 << h); ++y){
		for(int x = 0; x < (1 << w); ++x){
			int cnt = 0;
			for(int i = 0; i < h; ++i){
				if(y & (1 << i)) continue;
				for(int j = 0; j < w; ++j){
					if(x & (1 << j)) continue;
					if(c[i][j] == '#') ++cnt;
				}
			}
			if(cnt == k) ++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 3632
n = int(input())
tmp = [i for i in map(int, input().split())]
v_list = []
cnt = 1
for i in tmp:
    if i < 0:
       cnt *= -1
    v_list.append(abs(i))
v_list.sort()
if cnt ==1:
    print(sum(v_list))
else:
    print(sum(v_list[1:]) - v_list[0])


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

const int Nmax = 100001;
int Q;
bool isPrime[Nmax];
int cnt[Nmax];

int main() {
	fill(isPrime, isPrime + Nmax, 1);
	isPrime[1] = false;
	for (int i = 2; i*i < Nmax; i++) {
		for (int j = 2; j*i < Nmax; j++) {
			isPrime[i*j] = false;
		}
	}

	int buf = 0;
	for (int i = 0; i < Nmax; i++) {
		if (isPrime[i]) {
			if (isPrime[(i + 1) / 2]) {
				buf++;
			}
		}
		cnt[i] = buf;
	}

	cin >> Q;
	for (int i = 0; i < Q; i++) {
		int l, r;
		cin >> l >> r;
		cout << cnt[r] - cnt[l - 1] << endl;
	}

	return 0;
}

Measured memory_bytes: 1152
/*

*/
#include<bits/stdc++.h>

using namespace std;
using ll=long long;
#define rep2(i, a, n) for(int i = (a); i < (n); i++)
#define rep(i, n) rep2(i,0,n)
template<class T,class U>void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>void chmax(T &t,U f){if(t<f)t=f;}

int main(){
  cin.tie(nullptr);ios_base::sync_with_stdio(false);
  string n;cin>>n;
  int hoge=n[n.size()-1]-'0';
  //cout<<hoge<<endl;
  if(hoge==2 || hoge==4 || hoge==5 || hoge==7 || hoge==9)cout<<"hon"<<endl;
  if(hoge==0 || hoge==1 || hoge==6 || hoge==8)cout<<"pon"<<endl;
  if(hoge==3)cout<<"bon"<<endl;
}


Measured memory_bytes: 3636
import java.util.HashMap;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		String anser = "YES";

		HashMap<Integer, Integer> map = new HashMap<Integer, Integer>();

		int A = 0;
		for (int i = 0; i < N; i++) {
			A = scan.nextInt();

			if (map.containsKey(A)) {
				anser = "NO";
				break;
			} else {
				map.put(A, A);
			}
		}

		System.out.println(anser);
	}

}


Measured memory_bytes: 104080
{-# OPTIONS_GHC -O2 #-}
{-# LANGUAGE BangPatterns      #-}
{-# LANGUAGE CPP               #-}
{-# LANGUAGE OverloadedStrings #-}
{-# LANGUAGE TupleSections     #-}

import           Control.Applicative
import           Control.Monad
import           Control.Monad.Primitive
import           Control.Monad.ST
import           Control.Monad.State.Strict
import           Data.Bool
import qualified Data.ByteString.Char8       as B
import qualified Data.ByteString.Unsafe      as B
import           Data.Char
import           Data.Function
import qualified Data.IntMap.Strict          as IM
import qualified Data.IntSet                 as IS
import           Data.List
import           Data.Monoid
import           Data.Ord
import           Data.Primitive.MutVar
import qualified Data.Set                    as S
import           Data.Tuple
import qualified Data.Vector                 as V
import qualified Data.Vector.Generic         as G
import qualified Data.Vector.Generic.Mutable as GM
import qualified Data.Vector.Unboxed         as U
import qualified Data.Vector.Unboxed.Mutable as UM
import           Debug.Trace
import           Foreign                     hiding (void)
import           Unsafe.Coerce

main :: IO ()
main = do
    [n, k] <- map read.words <$> getLine
    tds <- U.unfoldrN n parseInt2 <$> B.getContents
    print $ solve n k tds

solve :: Int -> Int -> U.Vector (Int, Int) -> Int
solve n k tds = go res0 s0 size0 used0 (reverse $ buildQ xs) ys
  where
    (xs, ys) = splitAt k
        . sortBy (flip compare)
        . map swap
        $ U.toList tds
    !s0 = sum $ map fst xs
    !size0 = IS.size used0
    !used0 = IS.fromList $ map snd xs
    !res0 = s0 + size0 * size0

    go !res !s !size !used fs ((d, t):rest)
        | IS.member t used = go res s size used fs rest
        | otherwise = case fs of
            (z:zs)
                | size' <- size + 1
                , s' <- s - z + d
                , res' <- max res $ s' + size' * size'
                , used' <- IS.insert t used
                -> go res' s' size' used' zs rest
            [] -> res
    go res _ _ _ _ [] = res

buildQ :: [(Int, Int)] -> [Int]
buildQ dts = go IS.empty dts
  where
    go !used ((d, t):rest)
      | IS.member t used = d : go used rest
      | otherwise = go (IS.insert t used) rest
    go _ [] = []

type Parser a = B.ByteString -> Maybe (a, B.ByteString)

parseInt :: Parser Int
parseInt = B.readInt . B.dropWhile isSpace

parseInt2 :: Parser (Int, Int)
parseInt2 = runStateT $
    (,) <$> StateT (B.readInt . B.dropWhile isSpace)
        <*> StateT (B.readInt . B.unsafeTail)

Measured memory_bytes: 30076
#include<stdio.h>
#include<stdlib.h>
#define INF 10000000
#define M 10001
#define NIL -1
#define W 0
#define G 1
#define B 2
struct node{
  int k,c;
  struct node *next;
};

typedef struct node * nodepointer;

nodepointer sssp[M];
nodepointer mknd(int,int,nodepointer);
void insert(int,int,int);

int main(){
  int i,j,k,n,u,v,c,clr[M],dt[M],t[M],min,x;
  nodepointer a;

  scanf("%d",&n);
  for(i=0;i<n;i++) sssp[i] = mknd(0,0,NULL);
  for(i=0;i<n;i++){
    scanf("%d",&u);
    scanf("%d",&k);
    for(j=0;j<k;j++){
      scanf("%d",&v);
      scanf("%d",&c);
      insert(i,v,c);
      }
  }
  for(i=0;i<n;i++){
    clr[i]=W;
    t[i]=NIL;
    dt[i] = INF;

  }
  dt[0]=0;
  while(1){
    min=INF;
    for(i=0;i<n;i++){
      if(clr[i] != B && dt[i]<min){
	min =dt[i];
	x=i;
      }

    }
    if(min==INF) break;
    clr[x]=B;

    for(a=sssp[x];a!=NULL;a=a->next){
      if(clr[a->k]!=B && (a->c + dt[x])<dt[a->k]){
	t[a->k]=x;

	dt[a->k]=a->c + dt[x];
	clr[a->k] = G;
      }
    }
  }

  for(i=0;i<n;i++) printf("%d %d\n",i,dt[i]);
  

  return 0;
}
nodepointer mknd(int k,int c,nodepointer node){
  nodepointer b;
  b=malloc(sizeof(struct node));
  b->k=k;
  b->c=c;
  b->next = node;

  
  return b;
}


void insert(int i,int x,int y){
  nodepointer mn;
  mn=mknd(x,y,sssp[i]->next);
  sssp[i]->next = mn;

}



Measured memory_bytes: 17388
#include <bits/stdc++.h>
using namespace std;
const int MAX_H = 1000000000;
int main(){
    int n,k; cin >> n >> k;
    vector<int> h(n);
    for(int i=0;i<n;++i) cin >> h[i];
    sort(h.begin(),h.end());
    int ans = MAX_H;
    for(int i=0;i<n;++i){
        int j=i+k-1;
        if(j>=n) continue;
        ans = min(ans,h[j]-h[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <vector>
#include <set>

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR (i, 0, n)
#define _ << " _ " <<
#define TRACE(x) cerr << #x << " = " << x << endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
//#define debug
//#define TRACE(x)

using namespace std;

typedef long long llint;

const int MAXN = 15;

int h, w, cnt;
int ok[MAXN][MAXN];
char s[MAXN][MAXN];

int main(void) {
  scanf("%d %d",&h,&w);
  REP(i, h) scanf("%s",s[i]);
  REP(i, h) REP(j, w) cnt += s[i][j] == '#' ? 1 : 0;

  if (cnt != h + w - 1) {
    printf("Impossible\n");
    return 0;
  }
  
  for (int i = h - 1; i >= 0; --i)
    for (int j = w - 1; j >= 0; --j) {
      if (s[i][j] != '#') continue;
      if (i == h - 1 && j == w - 1) ok[i][j] = 1;
      if (i < h - 1) ok[i][j] |= ok[i+1][j];
      if (j < w - 1) ok[i][j] |= ok[i][j+1];
    }

  printf(ok[0][0] ? "Possible\n" : "Impossible\n");

  return 0;
}


Measured memory_bytes: 256
def lcs(s1, s2):
    dp = []
    for s2_k in s2:
        bgn_idx = 0
        for i, cur_idx in enumerate(dp):
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if not chr_idx:
                break
            dp[i] = min(cur_idx, chr_idx)
            bgn_idx = cur_idx
        else:
            chr_idx = s1.find(s2_k, bgn_idx) + 1
            if chr_idx:
                dp.append(chr_idx)
    return len(dp)

def solve():
    N = int(input())
    for _ in range(N):
        x = input()
        y = input()
        print(lcs(x, y))

if __name__ == '__main__':
    solve()

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

int main(void){
    int n, ans = 0;
    vector<int> a;
    cin >> n;
    for(int i = 0; i < n; i++){
        int temp;
        cin >> temp;
        a.push_back(temp);
    }
    sort(a.begin(), a.end(), greater<int>());
    for(int i = 0; i < n; i++){
        if(i % 2 == 0){
            ans += a[i];
        } else {
            ans -= a[i];
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3576
//最大値が分かる
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#define rep(i, n) for(i = 0; i < n; i++)
using namespace std;

int n;
int a[200001];

signed main() {
	int i, j;
	
	cin >> n;
	rep(i, n) cin >> a[i + 1];
	
	vector<int> ans;
	for (i = n; i >= 1; i--) {
		if (a[i] == 0) continue;
		ans.push_back(i);
		
		for (j = 1; j * j <= i; j++) {
			if (i % j == 0) {
				a[j] = !a[j];
				if (i / j != j) a[i / j] = !a[i / j];
			}
		}
	}
	
	for (i = 1; i <= n; i++) {
		if (a[i] != 0) {
			cout << -1 << endl;
			return 0;
		}
	}
	
	cout << ans.size() << endl;
	if (ans.size() == 0) return 0;
	for (i = 0; i < ans.size(); i++) {
		cout << ans[i];
		if (i + 1 < ans.size()) cout << " ";
	}
	cout << endl;
	return 0;
}

Measured memory_bytes: 2424
#include<iostream>
using namespace std;
int b, s, nS, nB;
int z[101], r[101];
int main(){
    cin >> nS >> nB;
    for(s=1; s<=nS; s++){cin>>z[s];}
    for(b=1; b<=nB; b++){
        for(s=1; s<=nS; s++){
            r[s] = z[s]%b;
        }
        for(s=1; s<=nS-1;  s++){
            if(r[s] > r[s+1]){
                swap(z[s], z[s+1]);
                swap(r[s], r[s+1]);
            }
        }
    }
    for(s=1; s<=nS; s++){
        cout << z[s] << endl;
    }
}

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

Measured memory_bytes: 3100
#include <iostream>
#include <bits/stdc++.h>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <tuple>
#include <time.h>
#include <random>

using namespace std;

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

long long int INF = 1e18;
double Pi = 3.1415926535897932384626;

vector<ll> G[500005];
//vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "DRUL";
//ll bit[500005];
//↓,→,↑,←


#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<(x)<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<(x);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define line cout << "----------" << endl;


ll mod = 1000000007;
ll rui(ll number1,ll number2){

    if(number2 == 0){
        return 1;
    }else{
        ll number3 = rui(number1,number2 / 2);
        number3 *= number3;
        number3 %= mod;
        if(number2%2==1){
            number3 *= number1;
            number3 %= mod;
        }
        return number3;
    }
}
ll gcd(ll number1,ll number2){

    if(number1 > number2){
        swap(number1,number2);
    }
    if(number1 == 0 || number1 == number2){
        return number2;
    }else{
        return gcd(number2 % number1,number1);
    }
}
void YES(bool condition){

    if(condition){
        p("YES");
    }else{
        p("NO");
    }
    return;
}
void Yes(bool condition){

    if(condition){
        p("Yes");
    }else{
        p("No");
    }
    return;
}


//ll fact[800005],rfact[800005];
/*
void c3_init(){
    fact[0] = rfact[0] = 1;
    for(ll i=1; i<=800000; i++){
        fact[i] = (fact[i-1]*i) % mod;
    }
	rfact[800000] = rui(fact[800000],mod - 2);
	for(ll i=800000; i>=1; i--){
	   rfact[i-1] = rfact[i] * i;
	   rfact[i-1] %= mod;
	}
	return;}
ll c3(ll n,ll r){
    return (((fact[n] * rfact[r]) % mod) * rfact[n-r]) % mod;}
*/

ll n,m,num,ans,a,b,c,d,e,g,h,w,i,j,k,q;
ll x[300005],y[300005],z[100005];
char s[2005][2005];
ll dp[5000];

void add_edge(ll a,ll b){
	x[num] = a;
	y[num] = b;
	num++;
	return;
}


int main(){
	cin >> n;
	m = n;
	while(m % 2 == 0){
		m /= 2;
	}
	if(m == 1){
		p("No");
	}else{
		p("Yes");
		a = 2;
		b = 3;
		add_edge(b+n,1+n);
		while(b <= n){
			add_edge(a+n,b);
			add_edge(b,1);
			add_edge(1,a);
			add_edge(a,b+n);
			a += 2;
			b += 2;
		}
		c = 1;
		while(c * 2 <= n){
			c *= 2;
		}
		if(n % 2 == 0){
			add_edge(n,c);
			d = n ^ c;
			d = d ^ 1;
			add_edge(2*n,d);
		}
		for(i=0;i<num;i++){
			pe(x[i]);p(y[i]);
		}
	}
	return 0;
}


Measured memory_bytes: 19328
#include <iostream>
#include <stdio.h>
#include <vector>
#include <utility>
#include <string>
#include <algorithm>
#include <cmath>
#include <queue>
 
typedef long long ll;

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

using namespace std;
 
const ll INF = ll(1e18)+1;
const double PI=3.14159265358979323846;

int main(){
  string s, ans="hi";
  cin >> s;
  bool ok;
  while(true){
    if(s == ans){
      ok = true;
      break;
    }
    if(s.size() < ans.size()){
      ok = false;
      break;
    }
    ans += "hi";
  }
  ok ? cout << "Yes" << endl : cout << "No" << endl;
}


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

int main(){
    int N;cin >> N;
    cout << N*N*N << endl;
    return 0;
}

Measured memory_bytes: 256