akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#define X first
#define Y second
#define FOR(i, l, r) for(int i = int(l); i <= int(r); ++i)
#define FORD(i, l, r) for(int i = int(l); i >= int(r); --i)
#define REP(i, r) for(int i = 0; i < int(r); ++i)
#define REPD(i, l) for(int i = int(l)-1; i >= 0; --i)
#define mk make_pair
#define sz size
#define DEBUG(x) {cerr << #x << " = " << x << '\n';}
#define PR(A, n) {cerr << #A << " = "; FOR(i, 1, n) cerr << A[i] << ' '; cerr << '\n';}
#define PR0(A, n) {cerr << #A << " = "; REP(i, n) cerr << A[i] << ' '; cerr << '\n';}

using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
const int Nmax = 3*1e5 + 100;
const ll inf = 1e18 + 100;
template<class T> int getbit(T x, int pos) {return (x >> (pos-1)) & 1;}
template<class T> void turn_on(T &x, int pos) {x = x | ((T)1 << (pos-1));}
template<class T> void turn_off(T &x, int pos) {x = x & ~((T)1 << (pos-1));}
template<class T> T sqr(T a) {return a*a;}

ll n, a[Nmax], Mx[Nmax], Mn[Nmax], sum, ans = -inf;
priority_queue<ll, vi, greater<ll> > pmin;
priority_queue<ll> pmax;

int main() {
    //freopen("in.txt", "r", stdin);
    //freopen(".out", "w", stdout);
    scanf("%I64d", &n);
    FOR(i, 1, 3*n) scanf("%I64d", &a[i]);
    FOR(i, 1, 3*n) {
        if (pmin.size() < n) {
            pmin.push(a[i]);
            sum += a[i];
        } else if (pmin.size() == n && pmin.top() < a[i]) {
            sum = sum - pmin.top() + a[i];
            pmin.pop();
            pmin.push(a[i]);
        }
        Mx[i] = sum;
    }
    sum = 0;
    FORD(i, 3*n, 1) {
        if (pmax.size() < n) {
            pmax.push(a[i]);
            sum += a[i];
        } else if (pmax.size() == n && pmax.top() > a[i]) {
            sum = sum - pmax.top() + a[i];
            pmax.pop();
            pmax.push(a[i]);
        }
        Mn[i] = sum;
    }
    //FOR(i, 2*n, 3*n) cout << Mn[i] << ' ';
    FOR(i, n, 2*n) {
        ans = max(Mx[i] - Mn[i+1], ans);
    }
    cout << ans;
}


Measured memory_bytes: 8948
import sys

sys.setrecursionlimit(10 ** 6)
int1 = lambda x: int(x) - 1
p2D = lambda x: print(*x, sep="\n")
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
def LI(): return list(map(int, sys.stdin.readline().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SI(): return sys.stdin.readline()[:-1]

def main():
    s=SI()
    t=SI()
    ans=0
    for c1,c2 in zip(s,t):
        if c1!=c2:ans+=1
    print(ans)

main()

Measured memory_bytes: 9316
#include <algorithm>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using namespace std;

typedef unsigned long long ul;
typedef long long ll;
typedef pair<ul, ul> P;
map<int, int> dp;
#define REP(i, n) for (ul i = 0; i < n; i++)
void divisor(const ul target, vector<ul>& div, ul num) {
  for (ul i = 1; i <= num; ++i) {
    if (target % i == 0) {
      // div.emplace_back(i);
      if (target / i != i) div.emplace_back(target / i);
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ul N;
  cin >> N;
  vector<ul> div;
  ul div_size = ul(sqrt(N));
  div.reserve(div_size);
  divisor(N, div, div_size);

  sort(div.begin(), div.end());
  ul ans = 0;
  for (auto& tmp : div) {
    if (N % (tmp - 1) != 0) ans += tmp - 1;
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
[N,K,Q] = list(map(int,input().split()))
A = [0]*Q
for i in range(Q):
    A[i] = int(input())

count = [0] * N
for j in range(Q):
    count[A[j]-1] +=1

#make
for k in range(N):
    make = Q-count[k]
    if make < K:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 50904
input()
arr = [int(s) for s in input().split(" ")]
cnt = 0
while (1):
    all_even = all([i % 2 == 0 for i in arr])
    if all_even:
        arr = [i // 2 for i in arr]
        cnt += 1
    else:
        break
print(cnt)


Measured memory_bytes: 2940
#include <stdio.h>
#include <string.h>
char s[20],t[20];
int main(){
	int i,len;
	scanf("%s%s",s,t);
	len=strlen(s);
	for(i=0;i<len;i++)
		if(s[i]!=t[i])return 0*printf("No\n");
	return 0*printf("Yes\n");
}

Measured memory_bytes: 1660
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	int n,sum=0,maxn=0,a,b;
	cin>>n;
	cin>>a;
	for(int i=1;i<n;i++){
		cin>>b;
		if(b<=a) {
			sum++;
			a=b;
		}
		else {
			maxn=max(maxn,sum);
			sum=0;
			a=b;
		}
	}
	maxn=max(maxn,sum);
	cout<<maxn<<endl;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define per(i, n) for(int i = (n)-1; i >= 0; --i)
#define eee(a) (cerr << (#a) << ": " << (a) << endl);
#define ppp(a) (cout << (a) << endl); 
#define cop(a) for(auto x:(a)){cout << x << endl;}

using ll = long long;

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

constexpr char sp = ' ';
constexpr ll MOD = 1e9+7;
constexpr ll Mod = 998244353;
constexpr int INF = 1e9;
constexpr ll LINF = 1e18;
constexpr double phi = (1+sqrt(5))/2;
constexpr double pi = 3.14159265358979323846264338327950288;
inline ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
inline ll lcm(ll a, ll b){return a/gcd(a,b)*b;}
inline ll inv(ll n, ll m=MOD){ll a=n,b=m,x=1,y=0;while(b){ll t=a/b;a-=t*b;swap(a,b);x-=t*y;swap(x,y);}return (a%m+m)%m;}
inline void Yes(){puts("Yes");}
inline void No(){puts("No");}
inline void Judge(bool b){b?Yes():No();}
inline void YES(){puts("YES");}
inline void NO(){puts("NO");}
inline void JUDGE(bool b){b?YES():NO();}
inline ll powmod(ll b, ll e, ll m=MOD){ll r=1;while(e>0){if(e&1)r=(r%m)*(b%m)%m;b=(b%m)*(b%m)%m;e>>=1;}return r;}
inline double distance(ll x1, ll y1, ll x2, ll y2){return sqrt((x1-x2)*(x1-x2)+(y1-y2)*(y1-y2));}
inline double d2r(double d){return d*pi/180;}
inline double r2d(double r){return r*180/pi;}

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; }
template<typename T1, typename T2> ostream& operator<<(ostream& s, const pair<T1, T2>& p) {return s << "(" << p.first << ", " << p.second << ")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& v) {
    s<<'[';for(size_t i=0;i<v.size();++i){s << v[i];if(i < v.size()-1) s << ", ";}s<<']';return s;
}
struct __{ __(){ /* cin.tie(0); ios::sync_with_stdio(0); */ cout<<fixed<<setprecision(15); } };

vector<pair<string, int>> p;
int main(){

    int n;
    scanf("%d", &n);    
    p.resize(n);
    rep(i, n){
        cin >> p[i].first >> p[i].second;
    }

    string s;
    cin >> s;
    int start = 0;
    rep(i, n){
        if(p[i].first == s) {
            start = i+1;
            break;
        }
    }
    
    ll ans = 0;
    for(int i = start; i < n; ++i){
        ans += p[i].second;
    }
    ppp(ans);


    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using LL=long long;
int main(){
  vector<vector<pair<LL,int>>>y(100005);
  LL N,M;
  cin>>N>>M;
  for(int i=1;i<=M;i++){
    LL P,Y;
    cin>>P>>Y;
    y[P].push_back({Y,i});
  }
  for(int i=1;i<=N;i++){
    sort(y[i].begin(),y[i].end());
  }
  vector<pair<int,pair<int,int>>>v;
  for(int i=1;i<=N;i++){
    for(int j=0;j<y[i].size();j++){
      v.push_back({y[i][j].second,{i,j+1}});
    }
  }
  sort(v.begin(),v.end());
  
  for(int j=0;j<v.size();j++){
    printf("%06d%06d\n",v[j].second.first,v[j].second.second);
  }
}

Measured memory_bytes: 8308
N = int(input())
A = []
for i in range(N):
    a = int(input())
    A.append(a)

A = sorted(A)

P1 = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        P1[0] = 1
    elif i%2 == 1:
        if i == N-1:
            P1[i] = -1
        else:
            P1[i] = -2
    else:
        if i == N - 1:
            P1[i] = 1
        else:
            P1[i] = 2

P1 = sorted(P1)

P2 = [0 for _ in range(N)]
for i in range(N):
    if i == 0:
        P2[0] = -1
    elif i%2 == 1:
        if i == N-1:
            P2[i] = 1
        else:
            P2[i] = 2
    else:
        if i == N - 1:
            P2[i] = -1
        else:
            P2[i] = -2

P2 = sorted(P2)

ans1 = 0
ans2 = 0
for i in range(N):
    ans1 += P1[i]*A[i]
    ans2 += P2[i]*A[i]

ans = max(ans1,ans2)

print(ans)


Measured memory_bytes: 9556
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  vector<int> data(6);
    
  for (int r = 0; r < 3; r++) {
    cin >> data.at(r);
  }
  
  
 if((data.at(0) < data.at(2)) && (data.at(1) > data.at(2))){
   cout << "Yes" << endl;
 }
 else if((data.at(1) < data.at(2)) && (data.at(0) > data.at(2))){
   cout << "Yes" << endl;
 }
 else{
   cout << "No" << endl;
 }
  
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, N) for (int i = 0; i < (int)N; ++i)
#define all(a) (a).begin(), (a).end()

ll N, M, V, P;

int main() {
  cin >> N >> M >> V >> P;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  sort(all(A));

  vector<ll> S(N + 1, 0);
  rep(i, N) S[i + 1] = S[i] + A[i];

  int l = 0, m = 0, r = 0;
  rep(i, N) {
    ll s = A[i] + M;
    ll rest = M * V;
    while (r < N - P + 1 && A[r] <= s) ++r;
    if (N - r > P - 1) continue;
    while (A[l] + M < s) ++l;
    while (m < r && A[m] < s) ++m;

    rest -= (N - r) * M;
    rest -= l * M;
    rest -= (m - l) * s - (S[m] - S[l]);
    if (rest <= 0) {
      cout << N - i << endl;
      return 0;
    }
  }

  return 0;
}


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

int main(){
	ll a;
	double b;
	cin >> a >> b;
	ll e = b*100 + 0.5;
	ll c = a*e;
	ll d = c/100;
	cout << d << endl;
}

Measured memory_bytes: 3728
#基数ソート
def BinarySort(N, d, index):
  if index > 0:
    d = BinarySort(N, d, index-1)

  count = [0]*10

  num = []

  for di in d:
    num.append( di // (10**index) % 10)
    count[num[-1]] +=1

  for i in range(9):
    count[i+1] += count[i]
  d_ = [None]*N

  for i in range(N-1, -1, -1):
    count[num[i]] -= 1
    d_[ count[num[i]] ] = d[i]
  #print(d_)
  return d_

N=int(input())
d=list( map(int,input().split() ) )
d = BinarySort(N, d, 5)

print( d[N//2] - d[N//2-1] )

Measured memory_bytes: 14396
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
queue<int> q;
int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
long long a[55],tot;
int cmp(long long x,long long y)
{
	return x>y;
}
int n;long long ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	scanf("%lld",&a[i]);
	sort(a+1,a+n+1,cmp);
	while(a[1]>=n)
	{
		for(int i=1;i<=n;i++)
		{
			long long x=a[i]/n;
			ans+=x;
			a[i]%=n;
			for(int j=1;j<=n;j++)
			{
				if(j!=i)
				a[j]+=x;
			}
		}
		sort(a+1,a+n+1,cmp);
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<stdio.h>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <cstdlib>
#include <cstring>
#include <string>
#include <cstdio>
#include <vector>
#include <cmath>
#include <queue>
#include <deque>
#include <stack>
#include <list>
#include <map>
#include <set>
using namespace std;
int main()
{

    string s;
    char c;
    cin>>c;
    if(c>='a' && c<='z')
        cout<<"a"<<endl;
    else if(c>='A' && c<='Z')
        cout<<"A"<<endl;
    return 0;
}



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

int main()
{
    string S,T;
    cin>>S>>T;

    int _length = S.length();

    for(int i = 0;i < _length; i++)
    {
        if(S[i] != T[i])
        {
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3624
#include <stdio.h>

int main() {
  int r, g, b, result;
  scanf("%d%d%d", &r, &g, &b);

  result = (r*100 + g*10 + b)%4;
    	
  if (result == 0) {
    printf("YES\n");
  }else {
    printf("NO\n");
  }
  return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <bits/stdc++.h>
#include <cstdint>
#include <iostream>
#include <iterator>
#include <vector>

// lib/util.hpp
#ifndef UTIL_HPP
#define UTIL_HPP


typedef ::std::int_fast64_t i64;
typedef ::std::uint_fast64_t u64;
typedef ::std::int_fast32_t i32;
typedef ::std::uint_fast32_t u32;

namespace tools {
  template <typename T>
  void read(::std::istream& is, ::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    vector.reserve(size);
    ::std::copy_n(::std::istream_iterator<T>(is), size, ::std::back_inserter(vector));
  }
  template <typename T>
  void read(::std::vector<T>& vector, const typename ::std::vector<T>::size_type size) {
    ::tools::read(::std::cin, vector, size);
  }

  template <typename T, ::std::size_t N>
  void read(::std::istream& is, ::std::array<T, N>& array) {
    ::std::copy_n(std::istream_iterator<T>(is), N, array.begin());
  }
  template <typename T, ::std::size_t N>
  void read(::std::array<T, N>& array) {
    ::tools::read(::std::cin, array);
  }
}

#endif

// main.cpp

int main() {
  i64 X;
  std::cin >> X;

  i64 answer = 0;
  i64 deposit = 100;
  while (deposit < X) {
    ++answer;
    deposit += deposit / 100;
  }

  std::cout << answer << std::endl;
  return 0;
}

Measured memory_bytes: 3592
#include<stdio.h>
 
 
int Arr[51];
int Select[51];
int n;
int count = 0;
void test()
{
	int a = 1;
    for (int i = 0; i < n; i++)
    {
        if (Select[i]){
            a *= Arr[i];
        }
    }
    count += a;
}
 
void DFS(int Idx, int Cnt)
{
    if (Cnt == 2)
    {
        test();
        return;
    }
 
    for (int i = Idx; i < n; i++)
    {
        if (Select[i] == 1) continue;
        Select[i] = 1;
        DFS(i, Cnt + 1);
        Select[i] = 0;
    }
}
 
int main(void)
{
	scanf("%d",&n);
	for(int i = 0; i< n; i++){
		scanf("%d", &Arr[i]);
	}
    DFS(0, 0);
    printf("%d",count);
}


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

int main() {
  int n, k;
  cin >> n >> k;
  vector<int> l(n);
  int sum = 0;
  for(int i = 0; i < n; i++) {
    cin >> l.at(i);
  }
  
  sort(l.begin(), l.end(), greater<int>());
  
  for(int i = 0; i < k; i++) {
    sum += l.at(i);
  }

  cout << sum << endl;
}

Measured memory_bytes: 256
while True:
    S = input()
    if S == '-':
        break
    list1 = list()
    for s in S:
        list1.append(s)
    M = int(input())
    for m in range(M):
        num = int(input())
        list1 = list1[num:] + list1[:num]
    print(''.join(list1))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
#define FOR(i, n) for(int i=0; i<int(n); i++)
#define RNG(i, f, t) for(int i=int(f); i<=int(t); i++)
#define REV(i, f, t) for(int i=int(f); i>=int(t); --i)
#define ALL(v) (v).begin(), (v).end()
bool RELAXED = false;
template<int,typename T> struct MINMAX{ T val; MINMAX(T val) : val(val) {} };
template<typename T> MINMAX<1,T> MAX(T val) { return MINMAX<1,T>(val); };
template<typename T> MINMAX<2,T> MIN(T val) { return MINMAX<2,T>(val); };
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<1,U> rhs) { return lhs = (rhs.val > lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T, typename U> inline T& operator|=(T &lhs, MINMAX<2,U> rhs) { return lhs = (rhs.val < lhs ? (RELAXED=true,rhs.val) : (RELAXED=false,lhs)); }
template<typename T> inline vector<T> readVector(int n) { vector<T> vec(n); FOR(i,n) cin>>vec[i]; return vec; }
template<typename T> void EXIT(T answer) { cout<<answer<<endl; exit(0); }
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<pii> vpii;
typedef signed long long int ll;

bool cmp(const pii a, const pii b) {
    return 1LL*a.second/a.first > 1LL*b.second/b.first;
}

int dp[3005][2];
int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

    int n, T; cin>>n>>T;
    vpii dish(n);
    FOR(i,n)
    cin>>dish[i].first>>dish[i].second;

    sort(ALL(dish), cmp);

    memset(dp, 0, sizeof dp);

    ll ans=0;
    FOR(i, n) {
        REV(t, T-1, 0) {
            int nt = t + dish[i].first;
            if(nt<T) {
                dp[nt][0] |= MAX( dp[t][0]+dish[i].second );
                dp[nt][1] |= MAX( dp[t][1]+dish[i].second );
                ans |= MAX(dp[nt][0]);
                ans |= MAX(dp[nt][1]);
            }
            dp[t][1] |= MAX( dp[t][0]+dish[i].second );
            ans |= MAX(dp[t][0]);
            ans |= MAX(dp[t][1]);
        }
    }
    cout<<ans<<endl;

    return 0;
}



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

int main(){
  int h, n;
  cin >> h >> n;
  int asum=0;
  for(int i=0; i<n; i++){
    int a;
    cin >> a;
    asum += a;
  }
  if(asum>=h)cout << "Yes";
  else cout << "No";
  return 0;
}

Measured memory_bytes: 888
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>

using namespace std;

int main()
{
  int N;
  string S;
  cin >> N >> S;
  int res = 0;
  for (int i = 1; i < N; i++)
  {
    int temp = 0;
    for (int j = 0; j < 26; j++)
    {
      char c = 'a' + j;
      if (S.substr(0, i).find(c) != string::npos && S.substr(i).find(c) != string::npos)
      {
        temp++;
      }
    }
    res = max(res, temp);
  }
  cout << res << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
 

int main(){
	ll N;
    cin>>N;
    cout<<(N+1)*N/2<<endl;
    return 0;
}

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

int main() {
    int n; cin >> n;
    string s; cin >> s;
    int firstRight = n, lastLeft = -1;
    for (int i = 0; i < n; i++) {
        if (s[i] == '>') firstRight = min(firstRight, i);
        else lastLeft = max(lastLeft, i);
    }
    int ans = 0;
    if (firstRight != n) ans = max(ans, n - firstRight);
    if (lastLeft != -1) ans = max(ans, lastLeft + 1);
    cout << ans << endl;
    return 0;
}



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

int main() {
	int n,k=1,count=1;
	std::cin >> n;

	std::vector<int> v(n);
	for (int& x : v) {
		std::cin >> x;
	}

	for (int i = 1; i < n ; i++) {
		k = 0;
		for (int j = 0; j < i;j++) {
			if (v[j] > v[i]) {
				continue;
			}
			else {
				k++;

				if (i == k) {
					count++;
				}
			}
		}

	}

	std::cout << count << std::endl;
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        long l0 = 2;
        long l1 = 1;
        for (int i = 2; i <= n; i++) {
            long temp = l1;
            l1 += l0;
            l0 = temp;
        }
        System.out.println(l1);
    }
}


Measured memory_bytes: 25044
#include <bits/stdc++.h>
#include <stdlib.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll,ll> llP;

int main() {
  string s;
  cin>>s;
  if(s[2]==s[3] and s[4]==s[5]) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}


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

int main() {
  int N, A, B;
  cin >> N >> A >> B;

  int x = 0;
  int a,b,c,d,e,t;
  for (int i=1; i<=N; i++) {
    a = i/10000;
    b = i%10000/1000;
    c = i%1000/100;
    d = i%100/10;
    e = i%10;
    t = a+b+c+d+e;
    if (t >= A && t <= B){
      x += i;
    }
  }

  cout << x << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <map>

using namespace std;

int main() {
	int N, T;
	cin >> N >> T;
	
	int ans = 10000;
	for (int i = 0; i < N; i++) {
		int c, t;
		cin >> c >> t;
		if (t <= T) ans = min(ans, c);
	}
	if (ans == 10000) cout << "TLE" << endl;
	else cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3644
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int n,L; R(n,L);
    int an=0;
    REP(i,n)an+=L+i;
    if(L<=0&&L+n-1>=0)W(an);
    else if(L<0)W(an-(L+n-1));
    else W(an-L);
    return 0;
}


Measured memory_bytes: 256
const Main = (input) => {
    a = input.split('\n')
    b = a[0].split('')
    c = a[1].split('')
    n = 0
    for (index = 0; index < b.length; index++) {
        if (b[index] == c[index]) {n += 1} 
    }
    console.log(n);
}
   
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
import sys
import itertools
input = sys.stdin.readline
sys.setrecursionlimit(10**6)


def main():
    n, m, q = map(int, input().split())
    ans = 0
    table = itertools.combinations_with_replacement(range(1, m+1), n)
    abcd = [[] for _ in range(q)]
    for i in range(q):
        abcd[i] = list(map(int, input().split()))
    for t in table:
        score = 0
        for i in range(q):
            if(t[abcd[i][1]-1] - t[abcd[i][0]-1] == abcd[i][2]):
                score += abcd[i][3]
        ans = max(score, ans)
    print(ans)


main()


Measured memory_bytes: 68324
require 'set'
n = gets.chomp.to_i
list  = Set.new
n.times do 
  order = gets.split{" "}
  case order[0]
    when "insert"
    list.add order[1]
    when "find"
    puts list.include?(order[1]) ? "yes": "no"
  end
end

Measured memory_bytes: 169064
#include<stdio.h>
int main(void){
	int r,D,x2000,i;
  scanf("%d %d %d",&r,&D,&x2000);
  for(i=0;i<10;i++){
  x2000=r*x2000-D;
  printf("%d\n",x2000);
  }
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(n) for(int I = 0; (I) < (n); ++(I) )
#define repeat(i, n) for( int i = 0; (i) < (n); ++(i) )
#define repeat_to(i, n) for( int i = 0; (i) <= (n); ++(i) )
#define repeat_from(i, m, n) for( int i = (m); (i) < (n); ++(i) )
#define repeat_from_to(i, m, n) for( int i = (m); (i) <= (n); ++(i) )
#define dump(x) cout << " " << #x << "=" << x
#define vdump(v) for(size_t T=0; T<v.size(); ++T){cout << " " << #v << "[" << T << "]=" << v[T];} cout << endl
using namespace std;
using lint = long long;
using ld = long double;

int main(void) {
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    repeat(i, h) cin >> s[i];
    cout << string(w+2, '#') << endl;
    repeat(i, h) cout << '#' << s[i] << '#' << endl;
    cout << string(w+2, '#') << endl;
    return 0;
}


Measured memory_bytes: 256
/*
 * Author : Sadi
 * Sat 18/07/2020
 * 17:42:25.64
 */
#include <bits/stdc++.h>

using namespace std;

#define    watch(x); cout << "\n" <<  #x << " is: " << x << "\n";
#define    all(a) (a).begin(), (a).end()
#define    fi first
#define    se second

template<class A, class B>
ostream& operator << (ostream& output, const pair<A, B>& p) {
    output << "(" << p.first << ", " << p.second << ")";
    return output;
}

template<class A>
ostream& operator << (ostream& output, const vector<A>& a) {
    output << "[";
    for(auto it = a.begin(); it != a.end(); ++it) {
        if(it != a.begin()) {
            output << ", ";
        }
        output << *it;
    }
    output << "]";
    return output;
}

using lld = long long;
using pii = pair<int, int>;
using pll = pair<lld, lld>;

//const int inf = 1e9;
//const int mod = 1e9 + 7;
//const double PI = acos(-1.0);
//const int mx = 1e5 + 5;



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
#ifndef ONLINE_JUDGE
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
#endif // ONLINE_JUDGE

    int n, m;
    cin >> n >> m;
    unordered_map<int, pair<bool, int>> umap;
    int solved = 0;
    int penalty = 0;
    for(int i = 0; i < m; ++i) {
        int p;
        string v;
        cin >> p >> v;
        if(umap[p].fi == false) {
            if(v == "WA") {
                umap[p].se++;    
            }
            else if(v == "AC") {
                solved++;
                penalty += umap[p].se;
                umap[p].fi = true;
            }
            
        }
    }
    cout << solved << " " << penalty << "\n";
    return 0;
}


Measured memory_bytes: 7320
n = int(input())
a = list(map(int,input().split()))

money = 1000
kabu = 0
tmp = a[0]
ans = 0
for i in a:
    if i > tmp:#上がったとき一番安かった日に買っていたことにする
        kabu += money//tmp
        money -= (money//tmp)*tmp
    elif i < tmp:#下がったとき一番高かった日に売っていたことにする
        money += kabu*tmp
        kabu = 0
        ans = max(money,ans)
    tmp = i

if kabu > 0:
    money += kabu*a[-1]

print(max(money,ans))



Measured memory_bytes: 9196
N = int(input())
A = set(map(int, raw_input().split()))

while len(A) != 1:
    minA = min(A)

    nextA = set()
    for Ai in A:
        if Ai == minA:
            nextA.add(Ai)
            continue
        if Ai % minA != 0:
            nextA.add(Ai%minA)

    A = nextA

A = list(A)
print '{}'.format(A[0])


Measured memory_bytes: 12624
#include <stdio.h>
#include <math.h>
#include <string.h>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <queue>
#pragma warning( disable:4996 )
using namespace std;

#define SWAP(a,b) (a += b,b = a - b,a -= b)
#define MIN(a, b) ((a) < (b) ? (a) : (b))


int main(void) {
	/*int r;
	scanf("%d", &r);
	printf("%d\n", 3 * r*r);*/

	int n, d;
	scanf("%d %d", &n, &d);
	int one = 1 + 2 * d;
	if (n%one) {
		printf("%d\n", n / one + 1);
	}
	else {
		printf("%d\n", n / one);
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef tuple<ll,ll,ll> T;
const long long INF = 1LL<<60;
const long long MOD = 1000000000+7;
#define rev(s) (string((s).rbegin(), (s).rend()))
// cout << fixed << setprecision(10) << ans << endl; 有効桁数指定
// *min_element(c + l, c + r) *max_element(c + l, c + r) 配列の中のmin-max
// int dx[8]={1,1,0,-1,-1,-1,0,1};
// int dy[8]={0,1,1,1,0,-1,-1,-1};
// int dx[4]={1,0,-1,0};
// int dy[4]={0,1,0,-1};
// ~ は、-1の時だけfalse

int main () {

    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

    int k;cin>>k;

    cout<<a[k-1]<<endl;

}

Measured memory_bytes: 256
#include <iostream>

#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define ACC(c) (accumulate(ALL(c), 0LL))
#define PRINT(x) cout << (x) << "\n"

using namespace std;
using ll = long long;
using pint = pair<int, int>;
using pll = pair<ll, ll>;

inline int std_in(int& a) {return scanf("%d", &a);}
auto pint_compare = [](pint x, pint y) -> bool{return (x.first < y.first);};
const int MOD = 1000000007;

signed main(){
    ll N, ans = 0;
    cin >> N;
    for(ll i = 1; i <= N; i++){
        if(i % 3 != 0 && i % 5 != 0) ans += i;
    }
    PRINT(ans);
    return 0;
}

Measured memory_bytes: 3636
using System;
using System.Linq;

class Program
{
  static void Main()
  {
var A = int.Parse(Console.ReadLine());
var B= int.Parse(Console.ReadLine());
var C = int.Parse(Console.ReadLine());
var X = int.Parse(Console.ReadLine());
var ans = 0;
            for (int i = 0; i <= A; i++)
                for (int j = 0; j <= B; j++)
                    for (int k = 0; k <= C; k++)
                        if (500 * i + 100 * j + 50 * k == X)
                            ans++;
            Console.WriteLine(ans);
  }
}


Measured memory_bytes: 11092
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

string s;

/*
int dfs(string c, int a){
  for(int i = 0 ; i < c.length(); i++){
    string t = c;
    dfs(string)
  }
}
*/
int main(){
  cin >> s;
  long long a = 0;
  long long b = 0;
  for(long long i = 0; i < s.length(); i++){
    if(s[i] == '0') a++;
    else b++;
  }
  if(a <= b) cout << a*2 << endl;
  else cout << b*2 << endl;
}


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

int main (){
    string S;
    cin >> S;
    string ans="Yes";
    for(int i=0;i<(int)(S.length());i+=2){
        if(S[i]=='L'){
            ans="No";
            break;
        }
        if(S[i+1]=='R'){
            ans="No";
            break;
        }
        
        
    }
    //if((int)(S.length())%2==1&&S[(int)(S.length())-1]=='L')ans="No";
    cout << ans<<endl;        
    return 0;
}

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

typedef long long ll;

ll n;
ll dp[1000010];
ll a[1000010];

int main()
{
    cin>>n;
    for(int i = 1; i <= n; i++)
    {
        cin>>a[i];
    }
    dp[1]=0;
    dp[0]=0;
    dp[2]=abs(a[2]-a[1]);
    for(int i = 3; i <= n; i++)
    {
        dp[i]=min(dp[i-2]+abs(a[i]-a[i-2]),dp[i-1]+abs(a[i]-a[i-1]));

    }
    cout<<dp[n];
    return 0;
}


Measured memory_bytes: 5120
import sys

len = int(input())
input_str_arr = input().split(" ")
input = [int(n) for n in input_str_arr]

# 基準値
base = 1
count = 0

if 1 not in input:
    print("-1")
    sys.exit()

for i in range(len):
    if(base == input[i]):
        base+=1
        continue
    count+=1

print(count)

Measured memory_bytes: 25768
#!/usr/bin/env python

x = int(input())
t = x-11*(x//11)
if t <= 6:
    if x%11 != 0:
        ans = 2*(x//11)+1
    else:
        ans = 2*(x//11)
else:
    if x%11 != 0:
        ans = 2*(x//11)+2
    else:
        ans = 2*(x//11)+1
print(ans)


Measured memory_bytes: 9120
#include <iostream>
#include <cmath>
#define int long long
using namespace std;
int n, d, x, y;
signed main() {
    cin >> n >> d;
    int res = 0;
    for (int i = 0; i < n && cin >> x >> y; i++) {
        double t = sqrt(x * x + y * y);
        if (t <= d) res++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3684
#include<iostream>
#define N 111111
#define M 222222
#define P 10001000
using namespace std;
int n,i,p[N];
long long a[N],b[N];
int main(){
	for(scanf("%d",&n),i=1;i<=n;i++)scanf("%d",&p[i]);
	for(i=1;i<=n;i++)a[i]=1ll*i*20003,b[i]=1ll*(n-i+1)*20003;
	for(i=1;i<=n;i++)a[p[i]]+=i,b[p[i]]+=i;
	for(i=1;i<=n;i++)printf("%lld%c",a[i],i==n?'\n':' ');
	for(i=1;i<=n;i++)printf("%lld%c",b[i],i==n?'\n':' ');
}


Measured memory_bytes: 1024
val = input().split(" ")
N = int(val[0])
K = int(val[1])

initial = set([i for i in range(1, N + 1)])

nhave = set([i for i in range(1, N + 1)])

for i in range(0, K):
    num_of_holder = int(input())
    holder_set = set([int(i) for i in input().split(" ")])

    not_have = initial - holder_set

    nhave = nhave & not_have

print(len(nhave))



Measured memory_bytes: 9148
import math
# N = int( input())

MOD = (10 ** 9) + 7
S = input()
dp = [ [ 0 for _ in range(4)]  for _ in range(len(S) + 1)]
dp[0][0] = 1
for i in range(len(S) ):
    if S[i] == "A":
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][1] += (dp[i][0] + dp[i][1])
        dp[i + 1][2] += (dp[i][2])
        dp[i + 1][3] += dp[i][3]
    if S[i] == "B":
        dp[i + 1][0] += dp[i][0]
        dp[i + 1][1] +=dp[i][1]
        dp[i + 1][2] +=  (dp[i][1] + dp[i][2])
        dp[i + 1][3] +=dp[i][3]

    if S[i] == "C":
        dp[i + 1][0] += (dp[i][0])
        dp[i + 1][1] += dp[i][1]
        dp[i + 1][2] += dp[i][2]
        dp[i + 1][3] += (dp[i][2] + dp[i][3])

    if S[i] == "?":
        dp[i + 1][0] +=  (dp[i][0] * 3)
        dp[i + 1][1] += (dp[i][0] + (dp[i][1]) * 3)
        dp[i + 1][2] += (dp[i][1]+ (dp[i][2]) * 3)
        dp[i + 1][3] += (dp[i][2]+ (dp[i][3]) * 3)
    for j in range(0,4):
        dp[i + 1][j] %= MOD




print(dp[-1][3] % MOD)

Measured memory_bytes: 56156
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define MP make_pair
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define PLI pair<ll, int>
#define PIL pair<int, ll>
#define STR string
#define Fst first
#define Snd second
#define SHN 1e9
#define LSHN 1e18
using namespace std;
double d[3010][3010];
int n;
double a[3010];
double res=0;
int main()
{
	cin >>n;
	for (int i=0;i<n;i++) cin >>a[i];
	d[0][1]=a[0],d[0][0]=1.00-a[0];
	for (int i=1;i<n;i++)
	{
		for (int j=0;j<=n;j++)
		{
			d[i][j]=d[i-1][j]*(1.00-a[i]);
			if (j) d[i][j]+=d[i-1][j-1]*a[i];
		}
	}
	for (int i=n/2+1;i<=n;i++) res+=d[n-1][i];
	cout <<setprecision(9);
	cout <<res;
	return 0;
} 

Measured memory_bytes: 70784
#!/usr/bin/env python
import sys
f = sys.stdin
n = int(f.readline())
a = list(map(int, f.readline().split(' ')))

prefix = [0] * (n+1)
for i in range(1, n+1):
    prefix[i] = prefix[i-1] + a[i-1]

def sum_fragment(p, q, prefix):
    return prefix[q+1] - prefix[p]

l = prefix[n]
diff = l
k = 0
for i in range(1, n):
    l1 = prefix[i]
    if l == 2*l1:
        k = i
        diff = 0
        break
    if l < 2*l1:
        if diff > (2*l1 - l):
            k = i
            diff = 2*l1 - l
        break
    diff = l - 2*l1
    k = i

print(diff)

Measured memory_bytes: 26056
x,n=map(int,input().split())
sett=list(map(int,input().split()))
arr=[i for i in range(-1,102) if i not in sett]
min_=100000
ans=0
for i in arr:
    if abs(x-i)<min_:
        min_=abs(x-i)
        ans=i
print(ans)

Measured memory_bytes: 9196
import math
def comb(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))

N, P = map(int, input().split())
A = list(map(int, input().split()))

n = [0] * 2

for a in A:
    n[a % 2] += 1


if P == 1:
    ans = 0
    for i in range(1, n[1]+1, 2):
        ans += comb(n[1], i)
    ans *= 2 ** n[0]
else:
    ans = 0
    for i in range(0, n[1]+1, 2):
        if i == 0:
            ans += 1
        else:
            ans += comb(n[1], i)
    ans *= 2 ** n[0]
    #ans += 1

print(ans)

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <vector>
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define show(x) cout << #x << " = " << (x) << endl;
using namespace std;
using ll = long long;
using pii = pair<int,int>;
int main(){
    int n;
    cin >> n;
    cout << n/3 << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,ini,n) for(int i=ini;i<n;i++)
#define _rep(i,ini,n) for(int i=ini;i>=n;i--)
#define ToEnd(a) a.begin(),a.end()
uint64_t MOD=1000000007;

int main(){
    int N;
    cin>>N;
    vector<int> X(N);
    rep(n,0,N) cin>>X.at(n);
    sort(ToEnd(X));

    uint64_t minSum=UINT64_MAX;
    for(int i=X.at(0);i<=X.at(X.size()-1);i++){
        uint64_t sum=0;
        for(auto x:X){
            sum+=pow(i-x,2);
        }
        minSum=min(minSum,sum);
    }

    cout<<minSum<<endl;
}

Measured memory_bytes: 256
N, M, X, Y = list(map(int, input().split()))
x = list(map(int, input().split()))
y = list(map(int, input().split()))
accept = False

x_max = max(x)
y_min = min(y)
if X < Y:
    z = [i for i in range(X+1, Y+1)]
    
    for i in z:
        if x_max < i and i <= y_min:
            accept = True
            break
if accept:
    print("No War")
else:
    print("War")

Measured memory_bytes: 3064
a, b, c = map(int, input().split())
d = b-a+1
if d < c*2+1:
  for i in range(d):
    print(a)
    a = a+1
else:
  b = b-c+1
  for i in range(c):
    print(a)
    a = a+1
  for i in range(c):
    print(b)
    b = b+1

Measured memory_bytes: 9140
N = int(input())
sn = str(N)

ans = 0
dp = [[[0] * 2 for i in range(10)] for j in range(10)]
dp[0][0][0] = 1
for nketa in range(len(str(N))):

    ndp = [[[0] * 2 for i in range(10)] for j in range(10)]

    for top in range(10):

        for app in range(10):

            for fl in range(2):

                for nadd in range(10):

                    if top == 0 and  fl == 0 and int(sn[nketa]) == nadd:
                        ndp[nadd][nadd][0] += dp[top][app][fl]
                    if top == 0 and fl == 0 and  int(sn[nketa]) > nadd:
                        ndp[nadd][nadd][1] += dp[top][app][fl]
                    if top == 0 and fl == 1:
                        ndp[nadd][nadd][1] += dp[top][app][fl]

                    if top != 0 and fl == 0 and int(sn[nketa]) == nadd:
                        ndp[top][nadd][0] += dp[top][app][fl]
                        
                    if top != 0 and fl == 0 and int(sn[nketa]) > nadd:
                        ndp[top][nadd][1] += dp[top][app][fl]

                    if top != 0 and fl == 1:
                        ndp[top][nadd][fl] += dp[top][app][fl]
                        
    dp = ndp

    #print (dp[0][0][1])
    #print (dp[9][9][1])

ans = 0
for i in range(9):
    i += 1
    for j in range(9):
        j += 1
        ans += sum(dp[i][j]) * sum(dp[j][i])

print (ans)
                


Measured memory_bytes: 43504
#include <bits/stdc++.h>
using namespace std;
#define rep(i, c) for (int i = 0; i < (int)c; i++)
using ll = long long;
int main() {
    int n;
    scanf("%d", &n);

    vector<int> a(n), b(n), c(n);
    rep(i, n) scanf("%d", &a[i]);
    rep(i, n) scanf("%d", &b[i]);
    rep(i, n) scanf("%d", &c[i]);

    sort(a.begin(), a.end());
    sort(b.begin(), b.end());
    sort(c.begin(), c.end());

    ll ans = 0;
    rep(i, n) {
        // bをiで固定して、bより小さくなるaの数とbより大きくなるcの数を掛け合わせる
        //そのまま全探索すると10^9*10^9とかでオーバーフローしちゃう
        // lower_boundは、ソートされた配列内で、key以上の要素の内の一番左側のイテレータを返す
        ll first = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        // upper_boundは、ソートされた配列内で、keyより大きい要素の内の一番左側のイテレータを返す
        ll third = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        ans += first * third;
    }

    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 4568
#!/usr/bin/env python3
import sys
from collections import deque, Counter
from heapq import heappop, heappush
from bisect import bisect_right
from itertools import accumulate

sys.setrecursionlimit(10**6)
INF = 10**12


def main():
    N = int(input())

    p = 10**9+7
    a = [None] * (N+1)
    inva = [None] * (N+1)
    a[0] = 1

    for i in range(1, N+1):
        a[i] = i * a[i-1] % p

    inva[N] = pow(a[N], p-2, p)
    for i in range(N):
        inva[N - i - 1] = inva[N - i] * (N - i) % p

    ans = 0
    S = N
    cnt = 0
    while S >= 3:
        S -= 3
        cnt += 1
        tmp = a[cnt + S - 1] * inva[S] % p
        tmp = tmp * inva[cnt - 1] % p
        ans += tmp
        ans %= p
    print(ans)


if __name__ == "__main__":
    main()


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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	string s[3] = {"Sunny", "Cloudy", "Rainy"};
	string t;
	cin>>t;
	for (int i = 0; i < 3; i++)
		if (s[i] == t) {
			cout<<s[(i + 1) % 3];
			return 0;
		}	
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int h, w, c;
int p[10][10];
bool used[10][10];
int dx[] = {1, 0, -1, 0}, dy[] = {0, -1, 0, 1};

int dfs2(int x, int y, int c, int nc, int p[10][10])
{
	used[x][y] = true;
	p[x][y] = nc;
	int nx, ny, ret = 1;
	for(int i = 0; i < 4; i++){
		nx = x + dx[i], ny = y + dy[i];
		if(nx <= 0 || nx > w || ny <= 0 || ny > h) continue;
		if(used[nx][ny]) continue;
		if(p[nx][ny] != c) continue;
		ret += dfs2(nx, ny, c, nc, p);
	}
	return ret;
}

int dfs(int t, int p[10][10])
{
	if(t == 5){
		for(int x = 1; x <= w; x++){
			for(int y = 1; y <= h; y++){
				used[x][y] = false;
			}
		}
		return dfs2(1, 1, c, 0, p);
	}
	
	int np[10][10], ret = 0;
	for(int i = 1; i <= 6; i++){
		if(t == 4 && i != c) continue;
		for(int x = 1; x <= w; x++){
			for(int y = 1; y <= h; y++){
				np[x][y] = p[x][y];
				used[x][y] = false;
			}
		}
		dfs2(1, 1, p[1][1], i, np);
		ret = max(ret, dfs(t+1, np));
	}
	return ret;
}

int main(void)
{
	while(1){
		cin >> h >> w >> c;
		if(h == 0 && w == 0 && c == 0) break;
		for(int y = 1; y <= h; y++){
			for(int x = 1; x <= w; x++){
				cin >> p[x][y];
			}
		}
		cout << dfs(0, p) << endl;
	}
	return 0;
}


Measured memory_bytes: 3108
import sys
import collections
from collections import Counter

n = int(input())
s = [input() for _ in range(n)]

cur = Counter(s)
mx = 0
for v in cur.values():
    mx = max(mx, v)

ans = []
for k, v in cur.items():
    if v == mx:
        ans.append(k)
ans.sort()
for i in ans:
    print(i)

Measured memory_bytes: 35572
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <utility>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <cmath>

#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define itrep(i,x) for(auto i=(x).begin(); i!=(x).end();i++)
#define Sort(x) sort((x).begin(),(x).end())
#define all(x) (x).begin(),(x).end()
#define fi first
#define se second
#define vec vector
#define INF (int)1e9
#define INFL 1e18
#define MOD 1000000007
#define pb push_back
#define MP make_pair
#define PI 3.1415926535
typedef long long int ll;
typedef std::pair<int,int> P;
int D=1;
int dx[4]={0,1,0,-1},dy[4]={-1,0,1,0};

using namespace std;

int main(){
    int n;
    cin>>n;
    ll ans=0;
    rep(i,0,n){
        int x;cin>>x;
        while(x%2==0){
            ans++;
            x/=2;
        }
    }
    cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9) + 7;
const double PI = acos(-1);
const double EPS = 1e-9;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N, K; cin >> N >> K;
	vector<int> a(N + 1); rep(i, 1, N + 1) { cin >> a[i]; }
	int m(0);
	rep(i, 1, N + 1)if (a[i] > 0)m += a[i];

	int l = 0, over0 = 0, sum = 0;
	rep(i, 0, K) {
		if (a[i] > 0)
			over0 += a[i];

		sum += a[i];

	}
	dump(m, l, over0, sum);
	int ans(0);
	rep(i, K, N + 1) {
		if (a[i] > 0)over0 += a[i];
		if (a[l] > 0)over0 -= a[l];
		sum = sum + a[i] - a[l++];

		int x = m - over0;

		chmax(ans, max(x, x + sum));
	}

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

Measured memory_bytes: 1024
import java.util.*;

public class Main
{
  public static int getDist(int n, int d, int[] y, int[]z){
      int dist = 0;
      for(int i = 0; i<d; i++){
          dist += (y[i]-z[i])*(y[i]-z[i]);
      }
      return dist;
  }
  public static void main(String[] args)
  {
    Scanner sc = new Scanner(System.in);
    int n, d;
	int cnt = 0;
    n = sc.nextInt();
    d = sc.nextInt();
    int[][] x = new int[n][d];
    for(int i=0;i<n;i++){
      for(int j=0; j<d; j++){
        x[i][j] = sc.nextInt();
      }
    }
    
    int s_dist = 0;
    double sqrt_dist = 0;
	for(int i=0;i<n;i++){
      for(int j=i+1; j<n; j++){
        s_dist = getDist(n, d, x[i], x[j]);
        sqrt_dist = Math.sqrt(s_dist);
        if(sqrt_dist == (int)sqrt_dist)
        {
            cnt++;
        }
      }
    }
    System.out.println(cnt);
  }
}

Measured memory_bytes: 22612
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <cmath>

 
using namespace std;
 

int main()
{
    string s;
    cin >> s;
    for (int i = 0; i < s.length()-1; i++)
    {
        if(s[i] == s[i+1])
        {
            cout << "Bad" << endl;
            return 0;
        }
    }
    cout << "Good" << endl;
    return 0;
}

Measured memory_bytes: 256
require 'prime'
h = Hash.new(0)
max = 1
prev = 0
ret = 0
while gets do
    n = $_.to_i
    b = false
    h.each_key do |k|
        if n < k
            puts h[k]-1
            b = true
            break
        end
    end
    next if b
    Prime.each do |p|
        next if p <= max
        h[p] = h[prev] + 1
        ret = h[prev]
        prev = p
        max = p
        break if p > n
    end
    puts ret
end

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

int N;
int D, X;
int A[127];
int choco(int day, int n){
    int res = 1;
    int cnt = 1;
    while(day + res<= n){
        res += day;
        cnt++;
    }
    return cnt;
}

int main(){
    scanf("%d", &N);
    scanf("%d%d", &D, &X);
    for(int i=0; i<N; i++){
        scanf("%d", &A[i]);
    }
    int sum = 0;
    for(int i=0; i<N; i++){
        sum+= choco(A[i], D);
    }
    sum += X;
    printf("%d", sum);

    return 0;
}


Measured memory_bytes: 256
N = int(input())
H = list(map(int, input().split()))
assert len(H) == N
for i in range(N - 2, -1, -1):
    if H[i] > H[i + 1]:
        H[i] -= 1
yes = all(a <= b for a, b in zip(H, H[1:]))
print('Yes' if yes else 'No')

Measured memory_bytes: 14224
n=int(input())
#n,m=map(int,input().split())
pl=list(map(int,input().split()))
ql=list(map(int,input().split()))
#l=[list(map(int,input().split())) for i in range(n)]

import itertools

seq=[i for i in range(1,n+1)]

l=list(itertools.permutations(seq))
l.sort()

p=tuple(pl)
q=tuple(ql)

a=l.index(p)
b=l.index(q)
print(abs(a-b))

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

typedef long long ll;

int main(){
	int n;
	scanf("%d", &n);
	vector<int> dp(n + 1);
	vector<int> hs(n + 1);
	for(int i = 1; i <= n; i++){
		scanf("%d", &hs[i]);
	}
	
	dp[1] = 0;
	dp[2] = abs(hs[2] - hs[1]);
	for(int j = 3; j <= n; j++){
		 dp[j] = min(dp[j-1] + abs(hs[j] - hs[j-1]), dp[j-2] + abs(hs[j] - hs[j-2]));
	}
	
	printf("%d\n", dp[n]); 
}

Measured memory_bytes: 1024