akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define YES() printf("YES\n")
#define NO() printf("NO\n")
#define Yes() printf("Yes\n")
#define No() printf("No\n")
#define in(x,y,h,w) x >= 0 && x < h && y >= 0 && y < w

#define int long long
//typedef    long long          ll;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      P;

template <typename T> T &chmin(T &a, const T &b) { return a = min(a, b); }
template <typename T> T &chmax(T &a, const T &b) { return a = max(a, b); }
 
const int INF=1e+18;
const double EPS=1e-9;
const int MOD=1000000007;

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

template<class T>
struct Edge{
	int from,to;
	T cost;
	Edge(int to,T cost) : to(to),cost(cost){}
	Edge(int from,int to,T cost) : from(from),to(to),cost(cost){}
};

template<class T>
using WeightedGraph = vector<vector<Edge<T>>>;
using Graph = vector<vector<int>>;
template<class T>
using Matrix = vector<vector<T>>;

vector<int> topologicalSort(const Graph &G){
	int n = G.size();
	vector<int> inDegree(n),ret;
	queue<int> que;
	for(int i = 0;i < n;i++){
		for(int to : G[i]) inDegree[to]++;
	}
	for(int i = 0;i < n;i++){
		if(!inDegree[i]) que.push(i);
	}
	while(!que.empty()){
		int v = que.front(); que.pop();
		ret.push_back(v);
		for(int to : G[v]){
			inDegree[to]--;
			if(!inDegree[to]) que.push(to);
		}
	}
	return ret;
}

signed main(){
	int n,m;
	cin >> n >> m;
	Graph G(n),rev(n);
	for(int i = 0;i < n - 1 + m;i++){
		int a,b;
		cin >> a >> b; a--;b--;
		G[a].push_back(b);
		rev[b].push_back(a);
	}
	auto topo = topologicalSort(G);
	int topoInd[100010];
	for(int i = 0;i < n;i++) topoInd[topo[i]] = i;
	for(int i = 0;i < n;i++){
		int ma = -1;
		for(int to : rev[i]) chmax(ma,topoInd[to]);
		if(ma == -1) cout << 0 << endl;
		else cout << topo[ma] + 1 << endl;
	}
}

Measured memory_bytes: 13416
H, W = map(int, input().split())
ResMin = H*W

for i in range(1, H+1):
    S1 = i * W
    S2_1 = (H-i) * (W//2)
    S2_2 = ((H-i)//2) * W
    S3_1 = H*W - (S1+S2_1)
    S3_2 = H*W - (S1+S2_2)
    tmp = min(max(S1, S2_1, S3_1) - min(S1, S2_1, S3_1), max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2))
    if tmp < ResMin:
        ResMin = tmp

for i in range(1, W+1):
    S1 = i * H
    S2_1 = (W-i) * (H//2)
    S2_2 = ((W-i)//2) * H
    S3_1 = H*W - (S1+S2_1)
    S3_2 = H*W - (S1+S2_2)
    tmp = min(max(S1, S2_1, S3_1) - min(S1, S2_1, S3_1), max(S1, S2_2, S3_2) - min(S1, S2_2, S3_2))
    if tmp < ResMin:
        ResMin = tmp

print(ResMin)

Measured memory_bytes: 3064
#include <iostream>

using namespace std;

int main() {
    int n,k; cin >> n >> k;
    if(n<k){
        cout << "1" << endl;
    }else if(n%k == 0){
        cout << "0" << endl;
    }else{
        cout << "1" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
n,k = (int(x) for x in input().split())
ln = list(map(float, input().split()))
ln_mean=[1+0.5*(x-1) for x in ln]
#print(ln_mean)

if n == k:
  print(sum(ln_mean))
else:
  lnk = [0]*(n-k+1)
  m_in = 0
  for i in range(k):
    m_in += ln_mean[i]
  m_max = m_in
  tmp_max = m_in
  for i in range(n-k):
    tmp_max = tmp_max - ln_mean[i] + ln_mean[i+k]
    if m_max < tmp_max:
      m_max = tmp_max
  print(m_max)

Measured memory_bytes: 24068
from collections import deque
from itertools import product


def bfs(S):
    x, y = S
    dist = [[10 ** 9] * w for _ in range(h)]
    dist[y][x] = 0
    que = deque([S])

    while len(que) > 0:
        x, y = que.popleft()
        near_a = [(x + 1, y), (x - 1, y), (x, y + 1), (x, y - 1)]
        num = product([-2, -1, 0, 1, 2], repeat=2)
        near_b = [(x + dx, y + dy) for dx, dy in num]

        for i, j in near_a:
            if (0 <= i < w and 0 <= j < h and
                    dist[j][i] > dist[y][x] and s[j][i] == '.'):
                dist[j][i] = dist[y][x]
                que.appendleft((i, j))
        for i, j in near_b:
            if (0 <= i < w and 0 <= j < h and
                    dist[j][i] > dist[y][x] + 1 and s[j][i] == '.'):
                dist[j][i] = dist[y][x] + 1
                que.append((i, j))
    return dist


h, w = map(int, input().split())
Ch, Cw = map(int, input().split())
Dh, Dw = map(int, input().split())
s = [input() for _ in range(h)]

ans = bfs((Cw - 1, Ch - 1))[Dh - 1][Dw - 1]
print(-1 if ans == 10 ** 9 else ans)


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

int main() {
  int h, w;
  cin >> h >> w;
  char s[h + 2][w + 2];
  int i, j;
  for (i = 0; i < h + 2; i++) {
    for (j = 0; j < w + 2; j++) {
      if (i == 0 || i == h + 1 || j == 0 || j == w + 1) {
        s[i][j] = '.';
      } else {
        cin >> s[i][j];
      }
    }
  }
  for (i = 0; i < h + 2; i++) {
    for (j = 0; j < w + 2; j++) {
      if (s[i][j] == '#') {
        if (!(s[i - 1][j] == '#' || s[i + 1][j] == '#' || s[i][j - 1] == '#' || s[i][j + 1] == '#')) {
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }
  cout << "Yes" << endl;
  return 0;
}


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

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

    return 0;
}

Measured memory_bytes: 3832
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i<(int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;  // vi <=> vl
using vb = vector<bool>;
using boolGraph = vector<vb>;
using P = pair<int, int>;  // int <=> ll
const int MOD = 1e9+7;
const double EPS = 1e-9;

int main() {
  int N; cin >> N;
  vi arr(N);
  rep(i,N) cin >> arr[i];

  cout << 2 * (N-1) << endl;

  int MAX = 0, MIN = 0;
  rep(i,N) {
    if (arr[i] > arr[MAX]) MAX = i;
    if (arr[i] < arr[MIN]) MIN = i;
  }

  if (abs(arr[MAX]) > abs(arr[MIN])) {
    rep(i,2) cout << MAX+1 << ' ' << 2 << endl;
    for (int i=2; i<N; ++i) {
      rep(j,2) cout << i << ' ' << i+1 << endl;
    }
  }
  else {
    rep(i,2) cout << MIN+1 << ' ' << N-1 << endl;
    for (int i=N-1; i>1; --i) {
      rep(j,2) cout << i << ' ' << i-1 << endl;
    }
  }
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#define rep(i,n) for(int i = 0; i < n; i++)
using namespace std;

int m, e, w;

int main(){
	string str, tmp;
	cin >> str;
	if(str[0] != 'm'){
		cout << "Rabbit" << endl;
		return 0;
	}
	m++;
	for(int i = 1; i < str.size(); i++){
		if(str[i] == 'm') m++;
		else if(str[i] == 'e'){
			e++;
			if(i == str.size()-1 || str[i+1] == 'e'){
				cout << "Rabbit" << endl;
				return 0;
			}
		}
		else{
			w++;
			if(i != str.size()-1){
				if(m == w){
					cout << "Rabbit" << endl;
					return 0;
				}
			}
		}
		if(m < e || e < w || m < w){
			cout << "Rabbit" << endl;
			return 0;
		}
	}
	cout << "Cat" << endl;
}

Measured memory_bytes: 1180
/**

author:	©LoneWolfDON
Git: MahinHossainMunna

**/
/*

*/

#include <stdio.h>
#include <string.h>

int main()
{
    int N;

    scanf("%d", &N);

    int temp = N % 10;

    if(temp == 2 || temp == 4 || temp == 5 || temp == 7 || temp == 9 )
        printf("hon\n");

    else if(temp == 0 || temp == 1 || temp == 6 || temp == 8)
        printf("pon\n");

    else
        printf("bon\n");

    return 0;
}


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

int main(){
  int x,n,a;
  cin >> x >> n;
  int line[110] = {};
  for(int i = 0; i < n ; i++){
    cin >> a;
    line[a] = 1;
  }
  int Min = 110,ans = 0,pre;
  for(int i = 0;i<=101;i++){
    if(line[i]==0){
      pre = i-x;
      if(pre < 0) pre  *=-1;
      if(min(Min,pre)<Min){
        ans = i;
        Min = min(Min,pre);
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    try (Scanner sc = new Scanner(System.in)) {
      int N = Integer.parseInt(sc.next());
      long result = 0;
      for (int i = 0; i <= N; i++) {
        if (!(i % 3 == 0 || i % 5 == 0)) {
          result += i;
        }
      }

      System.out.println(result);
    }
  }
}


Measured memory_bytes: 27164
#include<bits/stdc++.h>
using namespace std;
#define ALL(x) x.begin(),x.end()
#define rep(i,n) for(int i=0;i<n;i++)
#define debug(v) cout<<#v<<":";for(auto x:v){cout<<x<<' ';}cout<<endl; 
#define INF 1000000000
#define mod 1000000007
typedef long long ll;
const ll LINF = 1001002003004005006ll;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
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; }

using Real=long double;
using Point=complex<Real>;
const Real EPS=1e-10;
const Real pi=acosl(-1);

inline bool eq(Real a,Real b){
    return fabs(a-b)<EPS;
}

Point operator*(const Point &p,const Real &d){
    return Point(real(p)*d,imag(p)*d);
}

// 点 p を反時計回りに theta 回転
Point rotate(Real theta, const Point &p) {
  return Point(cos(theta)*p.real()-sin(theta)*p.imag(),sin(theta)*p.real()+cos(theta)*p.imag());
}

Real dis(Point a,Point b){
    return abs(a-b);
}

Real radian_to_degree(Real r){
    return r*180.0/pi;
}

Real degree_to_radian(Real d){
    return d*pi/180.0;
}
 
//三角形の面積，サラスの公式
Real area_triangle(Point a,Point b,Point c){
    Point x=b-a,y=c-a;
    return fabs(x.real()*y.imag()-x.imag()*y.real())/2;
}
 
struct Circle{
    Point center;
    Real r;
    Circle(Point center,Real r):center(center),r(r){}
};

Circle MinimumBoundingCircle(vector<Point> v){
    int n=v.size();
    
    //ランダムシャッフル．いぢわるされたくないもんだ
    mt19937 mt(time(0));
    shuffle(v.begin(),v.end(),mt);

    Circle ret(0,0);
 
    //2点で円を作る
    auto make_circle2=[&](Point a,Point b){
        return Circle((a+b)*0.5,dis(a,b)/2);
    };
 
    //3点で円を作る
    auto make_circle3=[&](Point A,Point B,Point C){
        //wikiの公式
        Real S=area_triangle(A,B,C);
        Real a=dis(B,C),b=dis(A,C),c=dis(A,B);
        Point cent=A*(a*a*(b*b+c*c-a*a)/(16*S*S))+B*(b*b*(c*c+a*a-b*b)/(16*S*S))+C*(c*c*(a*a+b*b-c*c)/(16*S*S));
        return Circle(cent,dis(cent,A));
    };
 
    auto isIn=[&](Point a){
        return dis(ret.center,a)<ret.r+EPS;
    };

    ret=make_circle2(v[0],v[1]);
    for(int i=2;i<n;i++){
        //v[i]が円に入っていないなら
        if(!isIn(v[i])){
            //円内にないなら点v[i]は必ず円周上に来る
            ret=make_circle2(v[0],v[i]);
            for(int j=1;j<i;j++){
                if(!isIn(v[j])){
                    //この時iとjが円周上を考える
                    ret=make_circle2(v[i],v[j]);
                    //最後の1点の決定
                    for(int k=0;k<j;k++){
                        if(!isIn(v[k])){
                            ret=make_circle3(v[i],v[j],v[k]);
                        }
                    }
                }
            }
        }
    }
    return ret;
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(12);

    int n;cin>>n;
    vector<Point> v(n);
    rep(i,n){
        Real x,y;cin>>x>>y;
        v[i]=Point(x,y);
    }
    auto ans=MinimumBoundingCircle(v);
    cout<<ans.r<<endl;
    return 0;
}



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


int main(){
  int N,K,Q;
  cin >> N >> K >> Q;
  vector<int> p(N,K-Q);
  rep(i,Q){
   int a;
   cin >> a;
   a--;
   p[a]++;
  }
  
  rep(i,N){
    if(p[i]> 0)puts("Yes");
    else puts("No");
  }
  return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
 
int main() {
  int n, a, b;
  scanf("%d %d %d", &n, &a, &b);
  int count = 0;
  
  for(int i= 0; i <= n; i++) {
  	int sum = 0;
  	
    for(int j = i; j != 0; j /= 10) {
      sum += j % 10;
    }
  
    if(sum >= a && sum <= b) {
      count += i;
    }
  }
  
   printf("%d", count);
   
  return 0;
}

Measured memory_bytes: 1712
#include <stdio.h>
//#include <stdlib.h>
//#include <string.h>
//#include <stdbool.h>
//#include <limits.h>
//#include <math.h>

int main() {
  int n;
  scanf("%d", &n);
  printf("%d\n", n/3);
  return 0;
}


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


int getMobility(vector <int> &a){
	int v=-1,n=0;
	for(int i=0;i<a.size();i++){
		if(n==0)v=a[i];
		if(v==a[i])n++;
		else n--;
	}
	return v;
}

int main(){
	int n,v;
	while(cin>>n&&n){
		vector<int> a(n);
		for(int i=0;i<n;i++)cin>>a[i];
		v=getMobility(a);
		if(n/2<count(a.begin(),a.end(),v))cout<<v<<endl;
		else cout<<"NO COLOR\n";
	}
	return 0;
}

Measured memory_bytes: 6436
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define bg begin()
#define ed end()
#define all(x) x.bg,x.ed
#define pb push_back
#define eb emplace_back
using namespace std;
typedef long long ll;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
template<class t> using vc=vector<t>;
template<class t> using vvc=vc<vc<t>>;
using pi=pair<int,int>;
using vi=vc<int>;
void yes(){ cout << "Yes" << endl; }
void no(){ cout << "No" << endl; }
int SIZE(string s){ return (int)s.size(); }

int main(){
    cout << fixed << setprecision(20);
    ll ans = 0;
    string s; cin >> s;
    int si = SIZE(s);
    int cnt = 0;
    rep(i,si){
        if(s[i] == 'B') cnt++;
        else ans += cnt;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <algorithm>
using namespace std;
int p[21000]={};
int a[21000]={},b[21000]={};
int main(){
 int n,x=0;
 scanf("%d",&n);
 for(int i=1;i<=n;i++){
   scanf("%d",&x);
   p[x]=i;
 }
 for(int i=1;i<=n;i++){
   if(i==1){
     a[i]=p[i];
     b[i]=0;
   }
   else if(p[i]>p[i-1]){
     a[i]=a[i-1]-1;
     b[i]=b[i-1]+(p[i]-p[i-1])+1;
   }
   else if(p[i]<p[i-1]){
     b[i]=b[i-1]+1;
     a[i]=a[i-1]-(p[i-1]-p[i])-1;
   }
 }
 x=*min_element(a+1,a+n+1);
 for(int i=1;i<=n;i++){
   a[i]+=-x;
 }
 for(int i=1;i<=n;i++){
   printf("%d ",b[i]+1);
 }
 printf("\n");
 for(int i=1;i<=n;i++){
   printf("%d ",a[i]+1);
 }
}


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

#define REP(i, n) for (int i = 0; i < (n); i++)
#define FOR(i, init, n) for(int i = init; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = INT_MAX;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

template <typename T>
struct RMQ
{
  private:
    ll N = 1;
    vector<T> node;

  public:
    RMQ(vector<T> vec)
    {
        ll size = vec.size();

        while (N < size)
        {
            N *= 2;
        }

        node.resize(2 * N - 1, iINF);

        REP(i, size)
        {
            node[i + N - 1] = vec[i];
        }

        for (int i = N - 2; 0 <= i; i--)
        {
            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    void update(int i, T value)
    {
        i += (N - 1);

        node[i] = value;

        while (i > 0)
        {
            i = (i - 1) / 2;

            node[i] = min(node[2 * i + 1], node[2 * i + 2]);
        }
    }

    T getMin(int a, int b, int i = 0, int l = 0, int r = -1)
    {
        if (r < 0)
        {
            r = N;
        }

        if (r <= a || b <= l)
        {
            return iINF;
        }

        if (a <= l && r <= b)
        {
            return node[i];
        }

        T vl = getMin(a, b, 2 * i + 1, l, (l + r) / 2);

        T vr = getMin(a, b, 2 * i + 2, (l + r) / 2, r);

        return min(vl, vr);
    }
};


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

    ll N, Q;
    cin >> N >> Q;

    RMQ<ll> rmq(vector<ll> (N, iINF));

    REP(i, Q)
    {
        int com, x, y;
        cin >> com >> x >> y;

        if(com == 0)
        {
            rmq.update(x, y);
        }
        else
        {
            cout << rmq.getMin(x, y + 1) << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5672
#include "bits/stdc++.h"
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define rep2(i, l, r) for (int i = (l); i < (r); i++)
#define ALL(x) (x).begin(), (x).end()     //昇順
#define RALL(x) (x).rbegin(), (x).rend()  // 降順
const long long mod = 1e9 + 7;
typedef long long ll;  // ll とdoubleは違う
typedef priority_queue<int> PQ;
typedef vector<long long> VL;
typedef vector<bool> VB;
typedef vector<int> VI;  // VI a(n);
typedef vector<double> VD;
typedef vector<string> VS;
typedef vector<char> VC;
typedef vector<VS> VSS;
typedef vector<VC> VCC;
typedef vector<VI> VII;  // VII a(n,vector<int>(m)) n * m
typedef vector<VL> VLL;
typedef pair<int, int> PII;
typedef map<int, int> MP;  // MP a;
typedef vector<pair<ll, ll>> PS;

template <class T, class U>  // chmax(max, a);
bool chmax(T &a, U b) {
  if (a <= b) {
    a = b;
    return 1;
  }
  return 0;
}
template <class T, class U>  // chmin(min,a)
bool chmin(T &a, U b) {
  if (a > b) {
    a = b;
    return 1;
  }
  return 0;
}
template <typename T>  // operator << (cout,a);
ostream &operator<<(ostream &os, vector<T> &v) {
  os << "{";
  rep(i, (int)v.size()) { os << v[i] << (i < v.size() - 1 ? ", " : ""); }
  os << "}";
  return os;
}

// g++ -std=c++11 prac.cpp
     
template<typename T>
T gcd(T a, T b){
	return b != 0 ? gcd(b, a % b) : a;
}    

int main() {
  ll x=0,y=0,z=0,k,n,m,h,w,ans=0,sum=0,Max=-1,Min=1e9+1;
  bool ok = true;
  string s,t,r;
  cin >> n >> k;
  if(n <= k)
    cout << "unsafe" << endl;
  else
  cout << "safe" << endl;

  return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
typedef long long int ll;
typedef long double ld;
using namespace std;
const long long int INF = 1e18;
const long long int mod = 1e9+7;

typedef pair<ll, ll> pairs;
typedef vector<pairs> p;

struct Edge{
    ll to, weight;
    Edge(ll t, ll w) : to(t), weight(w){}
};
using graph = vector<vector<ll>>;
using Graph = vector<vector<Edge>>;


ll gcd(ll a,ll b){
    if(b == 0){
        return a;
    }else{
        return gcd(b, a%b);
    }
}

ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}

ll keta(ll N){
    int tmp{};
    while( N > 0 ){
        tmp += ( N % 10 );
        N /= 10;
    }
    N = tmp;
    return N;
}

// 回文
bool kai(string S){
    bool flag = true;
    for(ll i=0;i<S.size()/2;++i){
        if(S[i] != S[S.size()-i-1]){
            flag = false;
            break;
        }
    }
    return flag;
}
// ---------------------------------------------

int main(){
    ll n;
    cin>>n;
    ll m=0, a=0, r=0, c=0, h=0; 
    for(ll i=0;i<n;++i){
        string s;
        cin>>s;
        if(s[0] == 'M'){
            m++;
        }else if(s[0] == 'A'){
            a++;
        }else if(s[0] == 'R'){
            r++;
        }else if(s[0] == 'C'){
            c++;
        }else if(s[0] == 'H'){
            h++;
        }
    }
    ll ans = 0;
    ans += m * a * r;
    ans += m * a * c;
    ans += m * a * h;
    ans += m * r * c;
    ans += m * r * h;
    ans += m * c * h;
    ans += a * r * c;
    ans += a * r * h;
    ans += a * c * h;
    ans += r * c * h;
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<algorithm>
using namespace std;
const int mod=1000000007;
int mi[101010],ma[101010];
int a[101010],b[101010];
int main()
{
	int n;
	scanf("%d",&n);
	a[0]=b[n+1]=0;
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=1;i<=n;i++)
		scanf("%d",&b[i]);
	for(int i=1;i<=n;i++)
	{
		mi[i]=1;
		ma[i]=1000000000;
	}
	for(int i=1;i<=n;i++)
	{
		if(a[i]>a[i-1])
		{
			mi[i]=max(mi[i],a[i]);
			ma[i]=min(ma[i],a[i]);
		}
		else
			ma[i]=min(ma[i],a[i]);
	}
	for(int i=n;i>=1;i--)
	{
		if(b[i]>b[i+1])
		{
			mi[i]=max(mi[i],b[i]);
			ma[i]=min(ma[i],b[i]);
		}
		else
			ma[i]=min(ma[i],b[i]);
	}
	long long ans=1;
	for(int i=1;i<=n;i++)
		(ans*=max(ma[i]-mi[i]+1,0))%=mod;
	printf("%lld",ans);
	return 0;
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

#define fi first
#define se second
#define pb push_back
#define int long long
#define all(x) (x).begin(), (x).end()

using LL = long long;
using LD = long double;
using pii = pair<int, int>;
using vii = vector<pii>;

const int INF = 1e18;
const int MOD = 1e9 + 7;
const int N = 1e5 + 5;

int p[N], q[N], r[N];

int32_t main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);

    int x, y, a, b, c;
    cin >> x >> y >> a >> b >> c;
    
    for (int i = 0; i < a; i++) cin >> p[i];
    for (int i = 0; i < b; i++) cin >> q[i];
    for (int i = 0; i < c; i++) cin >> r[i];

    sort(p, p + a, greater<int>());
    sort(q, q + b, greater<int>());

    vector<int> v;
    for (int i = 0; i < x; i++) v.pb(p[i]);
    for (int i = 0; i < y; i++) v.pb(q[i]);
    for (int i = 0; i < c; i++) v.pb(r[i]);

    sort(all(v), greater<int>());

    int ans = 0;
    for (int i = 0; i < x + y; i++) ans += v[i];
    cout << ans;
}

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

using namespace std;
using ll = long long;

int main(int argc, char const* argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    cout << 2;
    --N;
    for (int i=3;; i+=10) {
        bool flg = true;
        for (int j=3; j<i; j+=2) {
            if (i % j == 0) {
                flg = false;
                break;
            }
        }
        if (flg) {
            cout << " " << i;
            --N;
            if (N <= 0) {
                cout << endl;
                return 0;
            }
        }
    }
    return 0;
}


Measured memory_bytes: 256
#### import ####
import sys
import math
from collections import defaultdict

#### 設定 ####
sys.setrecursionlimit(10**7)
def input():
    return sys.stdin.readline()[:-1]

#### 定数 ####
mod = 10**9 + 7

#### 読み込み ####
def I(): return int(input())
def II(): return map(int, input().split())
def III(): return list(map(int, input().split()))
def Line(N):
    read_all = [tuple(map(int, input().split())) for _ in range(N)]
    return map(list,zip(*read_all))

#################


S = str(input())

if 1<=int(S[0:2])<=12:
    if 1<=int(S[2:4])<=12:
        print('AMBIGUOUS')
    else:
        print('MMYY')
else:
    if 1<=int(S[2:4])<=12:
        print('YYMM')
        exit()
    else:
        print('NA')
        exit()

Measured memory_bytes: 38640
from collections import deque


def bfs(si, sj, gi, gj):
    visited = set()
    q = deque([(si, sj, {(si, sj)})])
    while q:
        i, j, path = q.popleft()
        for di, dj in (1, 0), (-1, 0), (0, 1), (0, -1):
            ni, nj = i + di, j + dj
            if 0 <= ni < H and 0 <= nj < W and field[ni][nj] == '.' and (ni, nj) not in visited:
                if (ni, nj) == (gi, gj):
                    return path | {(gi, gj)}
                visited.add((ni, nj))
                q.append((ni, nj, path | {(ni, nj)}))
    return set()


H, W = map(int, input().split())
field = [input() for _ in range(H)]
path = bfs(0, 0, H - 1, W - 1)
if path:
    print(sum(field[i][j] == '.' for i in range(H) for j in range(W)) - len(path))
else:
    print(-1)


Measured memory_bytes: 3820
import std;

alias sread = () => readln.chomp();
alias lread = () => readln.chomp.to!long();
alias aryread(T = long) = () => readln.split.to!(T[]);
//aryread!string();
//auto PS = new Tuple!(long,string)[](M);
void main()
{
    auto n = lread();
    auto sp = new Tuple!(string, long, long)[](n);
    // writeln(sp);
    foreach (i; 0 .. n)
    {
        string s;
        long p;
        scan(s, p);
        sp[i][0] = s;
        sp[i][1] = -p;
        sp[i][2] = (i + 1);
    }
    sp.sort();
    foreach (i; 0 .. n)
    {
        writeln(sp[i][2]);
    }

}

void scan(L...)(ref L A)
{
    auto l = readln.split;
    foreach (i, T; L)
    {
        A[i] = l[i].to!T;
    }
}

void arywrite(T)(T a)
{
    a.map!text.join(' ').writeln;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define test() int t;cin>>t;for(int test=1;test<=t;test++)
#define pb push_back
#define nl cout<<"\n"
#define F first
#define S second
#define all(x) x.begin(),x.end()

template<class C> void min_self( C &a, C b ){ a = min(a,b); }
template<class C> void max_self( C &a, C b ){ a = max(a,b); }

const ll MOD = 1000000007;
ll mod( ll n, ll m=MOD ){ n%=m,n+=m,n%=m;return n; }

const int MAXN = 1e5+5;
const int LOGN = 21;
const ll INF = 1e14;
int dx[] = {1,0,-1,0};
int dy[] = {0,1,0,-1};

template<class T1, class T2> void add( T1 &x, T2 y, ll m = MOD )
{
	x += y;
	if( x >= m )
		x -= m;
}

template<class T1, class T2> void sub( T1 &x, T2 y, ll m = MOD )
{
	x -= y;
	if( x < 0 )
		x += m;
}

vector<vector<int>>divisors;

int main() 
{
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
	fastio();

	int n;
	cin>>n;

	divisors.resize(n+1);
	for(int i=1;i<=n;i++)
	{
		for(int j=i;j<=n;j+=i)
			divisors[j].pb(i);
	}

	ll ans = 0;
	for(int c=1;c<=n;c++)
	{
		ans += (int)divisors[n-c].size();
	}
	cout<<ans,nl;

	cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
	return 0;
}


Measured memory_bytes: 117572
//--- pC ---//
import java.util.*;
import java.lang.*;
import java.io.*;
public class Main {
	public static void main (String[] args) throws java.lang.Exception {
		new Solution();
	}
}
class Solution {
	Reader reader;
	public Solution () {
		reader = new Reader();
		while (reader.hasNext()) {
			run_case();
		}
	}
	private void run_case() {
		int a = reader.ni(), b = reader.ni();
		int l = 1, r = (int)1e4;
		for (int i=l; i<=r; i++) {
			if (((int)Math.floor(i * 0.08) == a) && ((int)Math.floor(i * 0.1) == b)) {
				System.out.println(i);
				return;
			}
		}
		System.out.println(-1);
		return;
	}


}

class Reader {
	BufferedReader br;
	StringTokenizer st;
	public Reader(){
		try {
			br = new BufferedReader(new InputStreamReader(System.in));
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
	}
	public String next() {
		if (st.hasMoreTokens()) return st.nextToken();
		try {
			st = new StringTokenizer(br.readLine());
		} catch (Exception e) {
			e.printStackTrace();
		}
		return st.nextToken();
	}
	public boolean hasNext() {
		try {
			if (!st.hasMoreTokens() && !br.ready()) return false;
			else return true;
		} catch (Exception e) {
			e.printStackTrace();
		}
		return false;
	}
	public int ni() {return Integer.parseInt(this.next());}
	public String ns() {return this.next();}
}


Measured memory_bytes: 23484
#include<iostream>
#include<sstream>
#include<fstream>
#include<vector>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>
#include<algorithm>
#include<functional>
#include<climits>
#include<utility>
#include <iomanip>
#include<map>

using namespace std;

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;

#define max(a,b) (a>b?a:b)
#define min(a,b) (a<b?a:b)
#define FOR(i,s,e) for (int i = int(s); i < int(e); i++)
#define REP(i,x) FOR(i,0,x)
#define CLR(a) memset((a), 0 ,sizeof(a))


const int MOD = 1e+9+7;
const double PI  = acos(-1.0);

int eind[50][50];
vi edge[50];
bool memo[50];
int n,m;

bool check(){
  bool ret=true;
  REP(i,n) ret=ret&memo[i];
  return ret;
}

void dfs(int tg,int ind){
  memo[tg]=true;
  REP(i, edge[tg].size()){
    int next=edge[tg][i];
    if(!memo[next] && eind[tg][next]!=ind){
      dfs(next,ind);
    }
  }
}

int main(){
  int a,b;
  cin>>n>>m;
  CLR(eind);
  REP(i,m){
    cin>>a>>b;
    eind[--a][--b]=i+1;
    eind[b][a]=i+1;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  int ret=m;
  REP(i,m){
    CLR(memo);
    dfs(0,i+1);
    if(check()) ret-=1;
  }
  cout<<ret<<"\n";
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
inline long long read()
{
	long long ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}
long long T,A,B,C,D,g;
int main()
{
	T=read();
	while(T--) {
		A=read(); B=read(); C=read(); D=read();
		if(B > A || B>D){
			puts("No");
			continue;
		}
		if(B<=C+1){
			puts("Yes");
			continue;
		}
		A-=B;
		if(A>C){
			A=A-(A-C-1)/B*B;
			A-=B;
		}
		
		//
		g=__gcd(B,D);
		A=A+(C+1-A+g-1)/g*g;
		if(A<B)puts("No");else puts("Yes");
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
typedef long long ll;
// C 72
int main(){
    int n; cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    map<ll, ll> m;
    for (int i = 0; i < n; ++i) {
        m[a[i]]++;
        m[a[i]-1]++;
        m[a[i]+1]++;
    }
    ll max = 0;
    for(pair<int,int> e : m){
        if(e.second > max) max = e.second;
    }
    cout << max << endl;
    return 0;
}


Measured memory_bytes: 6528
<?php
//$n = 3;
fscanf(STDIN, "%d", $n);
$input = explode(' ', fgets(STDIN));

$a_n = [];
for ($i = 0; $i < $n; $i++) {
	$a_n[$i] = (int)$input[$i];
	//$a_n[$i] = $i % 3 - 1;
}
//var_dump($a_n);
$memo = [];
$memo2 = 0;
$count = 0;
for($i = 0; $i < $n; $i++) {
	if (isset($memo[-($a_n[$i]+$memo2)])) {
		$count += $memo[-($a_n[$i]+$memo2)];
	}
	if ($a_n[$i] === 0) {
		$count ++;
	}
	$memo[-$memo2] += 1;
	$memo2 += $a_n[$i];
	//var_dump($memo, $memo2, "count".$count);
}
//var_dump($memo);
echo $count,"\n";

Measured memory_bytes: 41960
def gcd(a, b):
    if a < b:
        a, b = b, a
    while a % b != 0:
        a, b = b, a % b
    return b


def lcm(a, b):
    x = a * b // gcd(a, b)
    return x


a, b, c, d = map(int, input().split())
lcm_cd = lcm(c, d)
a -= 1

x = b - ((b // c + b // d) - (b // lcm_cd))
y = a - ((a // c + a // d) - (a // lcm_cd))
print(x - y)


Measured memory_bytes: 3064
import math
N, M = map(int,input().split())
mod = 10**9+7
if abs(N-M)>1:
    print(0)
    exit()
elif abs(N-M)==1:
    print(math.factorial(N)*math.factorial(M)%mod)
else:
    print(2*math.factorial(N)*math.factorial(M)%mod)


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

int main()
{
	int p = 0 <=  10000;
	int m = 0 <=  10000;
	int c = 0 <=  10000;
	cin >> p;
	cin >> m;
	cin >> c;
	int ans = p + m + c;
	cout << ans << endl;
}



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

int main(){
	unsigned w, h;
	std::cin >> w >> h;
	std::vector<unsigned> a(w), b(h);
	for(unsigned &i : a) std::cin >> i;
	for(unsigned &i : b) std::cin >> i;

	std::sort(std::begin(a), std::end(a), std::greater<unsigned>());

	for(unsigned i : a){
		std::sort(std::begin(b), std::end(b), std::greater<unsigned>());
		for(unsigned j = 0; j < i; ++j){
			if(b[j]) --b[j];
			else{
				std::cout << '0' << std::endl;
				return 0;
			}
		}
	}
	for(unsigned i : b){
		if(i){
			std::cout << '0' << std::endl;
			return 0;
		}
	}
	std::cout << '1' << std::endl;
}



Measured memory_bytes: 3144
#include "bits/stdc++.h"
using namespace std;
#define REP(i, n) for(ll i = 0;i < n;i++)
#define ll long long
#define MOD 1000000007
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
 
int n,t;
 
int main(){
  int ans=0;
  cin >> n >> t;
  vi a(n,0),b(n,0);
  REP(i,n) cin>>a[i]>>b[i];
  int st=sqrt(n);
  if (st==0)st=1;
  int nt=n/st+1;
  //cout<<st<<endl;
  //cout<<nt<<endl;
 
  vector<int> data(t,0);//ダミー
  vector<int> dp(t,0);
 
  for(int i=0;i<nt;i++){//stきざみ
    for(int j=1;j<t;j++){
      dp[j]=-1;
    }
    dp[0]=0;
    
    for(int k=0;k<n;k++){//全食品
      if ((k>=i*st)&(k<i*st+st)){
        continue;
      }

        for(int j=t-a[k]-1;j>=0;j--){
          if (dp[j]!=-1){
            dp[j+a[k]]=max(dp[j+a[k]],dp[j]+b[k]);
          }
        }
    }
    
    //コピー
    //for(int k=0;k<st;k++){
    //}
    
    //残りの食品
    
    for(int dk=0;dk<st;dk++){
      int idx=dk+i*st;//skipしたやつ
      if (idx>=n){
        break;
      }
      for(int j=0;j<t;j++){
        data[j]=dp[j];
      }
      for(int k=0;k<st;k++){
        if (dk==k){
          continue;
        }
        int kk=i*st+k;
        if (kk>=n)break;
        for(int j=t-a[kk]-1;j>=0;j--){
          if (data[j]!=-1){
            data[j+a[kk]]=max(data[j+a[kk]],data[j]+b[kk]);
            //cout<<data[j+a[kk]]<<" "<<kk<<endl;
          }
        }
      }
      //この時点での最大を検出
      
      for(int j=0;j<t;j++){
        ans=max(data[j]+b[idx],ans);
      }
    }
    
  }
 
 
 
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;

int main() {
   int N;
   cin >> N;
   int x = 0, y = 0, t = 0;
   int tmpx, tmpy, tmpt;
   bool flg = true;
   for (int i = 0; i < N; i++) {
      cin >> tmpt >> tmpx >> tmpy; 
      int d = abs(tmpx - x) + abs(tmpy - y);
      if ((tmpt - t) % 2 == 0) {
         if (d % 2 == 0 && d <= tmpt - t);
         else flg = false;
      } else {
         if (d % 2 == 1 && d <= tmpt - t);
         else flg = false;
      }
      x = tmpx;
      y = tmpy;
      t = tmpt;
   }
   if (flg) cout << "Yes" << endl;
   else cout << "No" << endl;
   return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<deque>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int MOD = 1e9 + 7;
const int INF = 1e10;
const long double PI = (acos(-1));


signed main() {
	string S;
	cin >> S;
	deque<char>q;
	for (auto i : S)q.push_back(i);
	bool flip = false;
	int Q;
	cin >> Q;
	rep(i, Q) {
		int T;
		cin >> T;
		if (T == 1)flip = !flip;
		else {
			int F;
			char C;
			cin >> F >> C;
			if (flip)F = 3 - F;
			if (F == 1)q.push_front(C);
			else q.push_back(C);
		}
	}
	if (flip)reverse(q.begin(), q.end());
	for (auto i : q)cout << i;
}

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

using namespace std;

int main(){
    string s;
    cin >> s;
    int cnt = 0, cnt1 = 0, cnt2 = 0, cnt3 = 0;
    for(int i = 0; i < s.length(); ++i){
        if(i % 2 == 0){
            if(s[i] == '0')cnt++;
            else cnt1++;
        }else{
            if(s[i] == '0')cnt2++;
            else cnt3++;
        }
    }
    cout << s.length() - max(cnt + cnt3, cnt1 + cnt2);
    return 0;

}


Measured memory_bytes: 512
import sys
lr = list(map(int, input().split()))
l = lr[0]
r = lr[1]
lmod = l%2019

def minfunc(x, y):
    if x > y:
        return y
    else:
        return x

if r - l >= 2019:
    print(0)
elif 2019 <= r - l + lmod:
    print(0)
else:
    min = 9999999
    modlist = list(map(lambda x: x%2019,range(l,r+1)))
    for i in range(r-l):
        for j in range(i+1, r-l+1):
            min = minfunc((modlist[i]*modlist[j])%2019,min)
    print(min)


Measured memory_bytes: 3064
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        
        while(true){
            int x = sc.nextInt();
            int y = sc.nextInt();
            
            if(x == 0 && y == 0){
                break;
            }
            
            if(x < y){
                System.out.println(x + " " + y);
            }else{
                System.out.println(y + " " + x);
            }
        }
    }
}


Measured memory_bytes: 35584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    string s; cin >> s;
    int ans = 0;

    int begin = 0, end = s.size()-1;
    while(end - begin > 0){
        if(s[begin] == s[end]){
            begin++;
            end--;
        }
        else if(s[begin] == 'x'){
            ans++;
            begin++;
        }
        else if(s[end] == 'x'){
            ans++;
            end--;
        }
        else{
            cout << -1 << endl;
            return 0;
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 512
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <cstring>

#define MOD 1000000007
#define ll long long

using namespace std;

ll H,W;
ll N;
vector <ll>a;

int main(){
  ll inp;
  ll c[101][101];
  ll count = 0;
  
  cin.tie(0);
  ios::sync_with_stdio(false);

  cin >> H >> W >> N;
  for(ll i =0;i<N;i++){
    cin >> inp;
    a.push_back(inp);
  }
  
  
  for(ll i = 0;i<H;i++){
    for(ll j = 0;j<W;j++){
      c[i][j]=(count+1);
      a[count]--;
      if(a[count]==0) count++;
    }
  }

  for(ll i = 0;i<H;i++){
    if(i%2==0){
      for(ll j = 0;j<W;j++){
	cout << c[i][j] << " ";
      }
    }
    else{
      for(ll j =W-1;j>=0;j--)cout << c[i][j] << " "; 
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 640
// Problem : E - O(rand)
// Contest : AtCoder - Tokio Marine & Nichido Fire Insurance Programming Contest 2020
// URL : https://atcoder.jp/contests/tokiomarine2020/tasks/tokiomarine2020_e
// Memory Limit : 1024 MB
// Time Limit : 3000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
typedef unsigned int ui;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef complex<double> cd;
typedef pair<int,int> pii;
typedef pair<int,ll > pil;
typedef pair<ll ,int> pli;
typedef pair<ll ,ll > pll;
typedef vector<int> vi;
typedef vector<ll > vl;
#define pque priority_queue
#define rep(i,l,r) for(i=(l);i<=(r);++i)
#define per(i,l,r) for(i=(l);i>=(r);--i)
#define REP(i,l,r) for(i=(l);i< (r);++i)
#define PER(i,l,r) for(i=(l);i> (r);--i)
#define mp make_pair
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define fi first
#define se second
#define bugf(...) fprintf(stderr,__VA_ARGS__);
#define bugs(x) cerr<<"    "<<(x);
#define bugx(x) cerr<<"    "<<(#x)<<" = "<<(x);
#define bugl cerr<<"\n";
#define bugL cerr<<"\n================================================\n";
#define bugt bugx(clock());bugl;
template<class IT>inline void cmax(IT &a,IT b){if(a<b)a=b;}
template<class IT>inline void cmin(IT &a,IT b){if(b<a)a=b;}
template<class IT>inline bool bmax(IT &a,IT b){if(a<b){a=b;return true;}else return false;}
template<class IT>inline bool bmin(IT &a,IT b){if(a>b){a=b;return true;}else return false;}
const int N=55,M=1<<18,T=387420489;
unsigned char X[T];
ull C[N][N],C0[N];
int s,t;
ull dfs(int l,int tmp){
	if(~l){
		tmp*=3;
		if((s>>l&1)==(t>>l&1))return dfs(l-1,tmp+(s>>l&1));
		else return dfs(l-1,tmp+2)-(dfs(l-1,tmp+1)+dfs(l-1,tmp));
	}else return C0[X[tmp]];
}
inline void ac(){
	int n,k,i,j,a,tmp,b;
	ull x;
	scanf("%d%d%d%d",&n,&k,&s,&t);
	if((t&s)!=s){printf("0");return;}
	rep(i,0,n)C[i][0]=1ull;
	rep(i,1,n)rep(j,1,i)C[i][j]=C[i-1][j]+C[i-1][j-1];
	rep(i,1,n){
		x=0ull;
		rep(j,1,k)x+=C[i][j];
		C0[i]=x;
	}
	rep(i,1,n){
		scanf("%d",&a);
		REP(j,0,M){
			tmp=0;
			per(b,17,0){
				tmp*=3;
				if(j>>b&1)tmp+=2;
				else if(a>>b&1)++tmp;
			}
			++X[tmp];
		}
	}
	printf("%llu",dfs(17,0));
}
int main(){
	//freopen("a.in","r",stdin);
	//freopen("a.out","w",stdout);
	
	ac();
	return 0;
}
#undef pque
#undef rep
#undef per
#undef REP
#undef PER
#undef mp
#undef pb
#undef pf
#undef pob
#undef pof
#undef fi
#undef se
#undef bugs
#undef bugx
#undef bugl

Measured memory_bytes: 190616
import java.util.Arrays;
import java.util.Scanner;
import java.util.stream.LongStream;

public class Main {
    public static void main(String[]args){
        Scanner sc=new Scanner(System.in);
        int N=sc.nextInt();
        int K=sc.nextInt();
        long [] healths=new long[N];
        int sum_of_moves=0;
        for(int i=0;i<N;i++)
           healths[i]=sc.nextLong();
        Arrays.sort(healths);
      //  String output=(sum_of_moves>=H)?"Yes":"No";
        System.out.print((N>K)? LongStream.of(Arrays.copyOfRange(healths,0,healths.length-K)).sum():0);
    }
}

Measured memory_bytes: 94848
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<iterator>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>
#include<chrono>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,x,n) for(int i=x; i<(n); i++)
#define vint(a,n) vint a(n); rep(i, n) cin >> a[i];
#define vll(a,n) vll a(n); rep(i, n) cin >> a[i];
#define ALL(n) begin(n),end(n)
#define RALL(n) rbegin(n),rend(n)
#define MOD (1000000007)
#define INF (2e9)
#define INFL (2e18)

typedef long long ll;
typedef unsigned int ui;
typedef unsigned long long ull;
using vint=vector<int>;
using vll=vector<ll>;
using vbool=vector<bool>;
template<class T>using arr=vector<vector<T>>;
template<class T>int popcount(T &a){int c=0; rep(i, 8*(int)sizeof(a)){if((a>>i)&1) c++;} return c;}
template<class T>void pr(T x){cout << x << endl;}
template<class T>void prvec(vector<T>& a){rep(i, a.size()-1){cout << a[i] << " ";} pr(a[a.size()-1]);}
template<class T>void prarr(arr<T>& a){rep(i, a.size()) if(a[i].empty()) pr(""); else prvec(a[i]);}
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; }

ll f(ll a, ll m){
    ll t = a*a;
    return (t%m);
}

int main()
{
    ll n;
    ll x, m; cin >> n >> x >> m;

    vll val(m, -1);
    vll a;
    ll ans = 0;

    ll loop=0;
    ll intt = 0;
    ll sum = 0;
    val[x] = 0;
    for(ll i=0; i<n; i++){
        // pr(x);
        ans += x;
        if(i==n-1) break;
        a.push_back(x);
        x = f(x, m);
        
        if(val[x]!=-1){
            intt = val[x];
            loop = i+1 - val[x];
            FOR(j, val[x], i+1) sum += a[j];
            break;
        }
        val[x] = i+1;
    }

    if(loop!=0) {
        ans += sum* (((n-intt)/loop) - 1);
        ll k = (n-intt)%loop;
        FOR(i, intt, intt+k) ans += a[i];
    }
    pr(ans);


    return 0;}

Measured memory_bytes: 4684
def solve(N, Ps):
    ans = 0
    target = Ps[0]
    for p in Ps:
        if p <= target:
            ans += 1
            target = p
    print(ans)


if __name__ == '__main__':
    N = int(input())
    Ps = [int(i) for i in input().split()]
    solve(N, Ps)


Measured memory_bytes: 25768
while True:
	try:
		a,b,c,d,e,f = map(float,raw_input().split())
		x = (e*c-b*f) / (e*a-b*d)
		y = (c*d-a*f) / (b*d-e*a)
		if x == -0.0:
			x = 0
		if y == -0.0:
			y = 0
		print '%.3f %.3f' % (x,y)
	except EOFError:
		break

Measured memory_bytes: 4236
import java.util.*;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int X = sc.nextInt();
		int max = 0;
		for(int t=1; t<100000; t++) {
			max += t;
			if(X<=max) {
				System.out.println(t);
				break;
			}
		}
		
		sc.close();
	}
}


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

//C++14 (GCC 5.4.1)

#define LLINF (1LL<<60)
typedef long long ll;
#define mod 1000000007

#define repd(i,a,b) for (int i=(a);i<(b);i++)
#define rep(i,n) repd(i,0,n)
#define rrepd(i,a,b) for(int i=(a);i>=(b);i--)

template<typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

template < typename T > inline string toString( const T &a ) { ostringstream oss; oss << a; return oss.str(); }

#define dbg_v1(i,V) do{cout<<"-v1----\n";rep(i,V.size())cout<<" "<<i<<"\t:"<<V[i]<<endl;cout<<endl;}while(0)
#define dbg_v2(i,k,V) do{cout<<"-v2----\n";rep(i,V.size()){rep(k,V[0].size())cout<<" "<<V[i][k];cout<<endl;}}while(0)
#define lower_bound_idx(V,c) distance(V.begin(),lower_bound(V.begin(),V.end(),c))

int main() {
    ios::sync_with_stdio(false);//stdoutとcoutの同期解除
    cin.tie(nullptr);//cinとcoutの同期解除
    
    int H,W,K;
    cin >>H>>W>>K;

    vector<string> A(H);
    vector<vector<int>> ans(H,vector<int>(W,-1));
    rep(i,H) cin >> A[i];
    
    //-----------------------------------
    bool head=true;
    int cntbf=0,cnt=1;
    rep(i,H){
        bool iss=false;
        rep(j,W)if(A[i][j]=='#')iss=true;
        if(!iss){
            if(head)cntbf++;
            else rep(j,W)ans[i][j]=ans[i-1][j];
            continue;
        }
        int ss=0;
        rep(j,W){
            if(A[i][j]=='#'){
                ss++;
                if(2<=ss) cnt++;
            }
            ans[i][j]=cnt;
        }
        cnt++;
        if(head){
            rep(t,cntbf){
                rep(j,W)ans[t][j]=ans[i][j];
            }
            head=false;
        }
    }

    rep(i,H){
        rep(j,W) cout << ((j==0)?"":" ") <<ans[i][j]; 
        cout<<endl;
    }
    return (0);
}

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

int main()
{
  int n;
  cin >> n;
  vector<int> order(n);
  vector<int> score(n);
  vector<int> bonus(n-1);
  for (int i = 0; i < n; i++) {
    cin >> order.at(i);
  }
  for (int i = 0; i < n; i++) {
    cin >> score.at(i);
  }
  for (int i = 0; i < n-1; i++) {
    cin >> bonus.at(i);
  }
  int res = 0;
  int pre = -2;
  for (int i = 0; i < n; i++) {
    int idx = order.at(i) - 1;
    res += score.at(idx);
    if (pre + 1 == idx) {
      res += bonus.at(pre);
    }
    pre = idx;
  }
  cout << res << '\n';
  return 0;
}


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

int main() {
    char s[11];
    char t[12];
    int a = 0, bb = 0;
    
    scanf("%s", s);
    scanf("%s", t);
    
    if (strlen(s) + 1 == strlen(t))
        a += 1;
    for (int i = 0; i < strlen(s); ++i){
        if (s[i] == t[i])
            bb += 1;
    }
    if (bb == strlen(s))
        a+= 1;
        
    if (a == 2)
        printf("Yes\n");
    else 
        printf("No\n");
    return 0;
}


Measured memory_bytes: 1660
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
    enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
// #ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
    ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
    *this << "[";
    for (auto it = d.b; it != d.e; ++it)
       *this << ", " + 2 * (it == d.b) << *it;
    ris << "]";
}
// #else
// sim dor(const c&) { ris; }
// #endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "

void solve(){
    int n;
    cin>>n;
    cout<<(n^1)<<'\n';
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 3700
#include<vector>
#include<iostream>
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<algorithm>
#define INF 10**9+7
using namespace std;
using Graph = vector<vector<int> >;//Graph graph(ノードの数)で生成できる

bool check(long long a,long long b,long long c){
    return true;
}

int main(){
    string S;
    cin >> S;
    if(S.at(0)=='a' || S.at(0)=='i' || S.at(0)=='u' || S.at(0)=='e' || S.at(0)=='o'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }
    return 0;
}

Measured memory_bytes: 256