akhauriyash/Code-Regression huggingface dataset:
#D
N=int(input())
X=str(input())
   
CNT=0
for i in range(N):
    if X[i]=="1":
        CNT+=1
NUM=int(X,2)

to0_cnt=[0 for i in range(N)]
for i in range(1,N):
    ans=0
    num=i
    while True:
        cnt=0
        for j in bin(num)[2:]:
            if j=="1":
                cnt+=1
        if cnt==0:
            break
        r=num%cnt
        ans+=1
        if r==0:
            break
        num=r
    to0_cnt[i]=ans
                
R=[NUM%(CNT+1),NUM%(CNT-1) if CNT!=1 else 0]
for i in range(N):
    if X[i]=="0":
        cnt=CNT+1
        r=(R[0]+pow(2,N-i-1,cnt))%cnt
    else:
        cnt=CNT-1
        if NUM-pow(2,N-i-1)==0:
            print(0)
            continue
        r=(R[1]-pow(2,N-i-1,cnt))%cnt
    
    ans=1+to0_cnt[r]
    print(ans)

Measured memory_bytes: 95380
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef vector<LL> VI;
typedef vector<VI> VVI;
typedef pair<LL, LL> PII;
typedef vector<string> VS;
inline LL toInt(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(x,c) for(auto x: (c))
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define REVERSE(c) reverse((c).begin(), (c).end())
#define SORT(c) sort((c).begin(),(c).end())
#define RSORT(c) sort((c).rbegin(),(c).rend())
#define STABLE_SORT(c) stable_sort((c).begin(),(c).end())
#define STABLE_RSORT(c) stable_sort((c).rbegin(),(c).rend())
#define UNIQUE(c) SORT(c); (c).erase(unique((c).begin(), (c).end()), (c).end());
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
const double INF = 1e7;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
#define dump(x)  cerr << #x << " = " << (x) << endl;


int main() {
	LL A, B, C;
	cin >> A >> B >> C;

	cout << (int)(A * B / 2) << endl;
	
    return 0;
}


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

void dfs(int i, string s, string f, int sum) {
    if(i == 4) {
        if(sum == 7) {
            cout << f;
            cout << "=7" << endl;
            exit(0);
        }
        return;
    }

    string f2 = f+'+'+s[i];
    int sum2 = sum+(s[i]-'0');
    dfs(i+1,s,f2,sum2);

    f2 = f+'-'+s[i];
    sum2 = sum-(s[i]-'0');
    dfs(i+1,s,f2,sum2);

    return;
}


int main() {
    string s;
    cin >> s;
    string f;
    f += s[0];
    int sum = s[0]-'0';
    dfs(1,s,f,sum);
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long int;
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MAX 100000000000000000

void solve(int n)
{
    int tot = 0;
    for(int i=1;i<=(1e7);i++)
    {
        tot = (tot * 10 + 7) % n;
        if(tot==0)
        {
            cout<<i<<endl;
            return;
        }
    }
    cout<<"-1"<<endl;
    return;
}

int main()
{

    //freopen("inputfile.txt","r",stdin);
    IOS;
   int n;cin>>n;
  solve(n);
    return 0;
}


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

const int INF=1e9;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
const int MAXN=100000;

int n;
vector<vector<int> > G(100,vector<int>(100,0));
vector<int> d(100,0),f(100,0);
int t=1;
void dfs(int u){
    d[u]=t++;
    for(int v=0;v<n;v++){
        if(G[u][v]==1&&d[v]==0){
            dfs(v);
        }
    }
    f[u]=t++;
}

int main(){
    cin>>n;
    for(int i=0;i<n;i++){
        int u,k;cin>>u>>k;
        u--;
        for(int j=0;j<k;j++){
            int v;cin>>v;
            v--;
            G[u][v]=1;
        }
    }
    for(int i=0;i<n;i++){
        if(d[i]==0){
            dfs(i);
        }
    }
    for(int i=0;i<n;i++){
        cout<<i+1<<' '<<d[i]<<' '<<f[i]<<endl;
    }
    return 0;
}


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

int bubbleSort(int A[], int N){
    int sw = 0;
    bool flag = 1;
    for (int i = 0; flag; i++){
        flag = 0;
        for (int j = N - 1; j >= i + 1; j--){
            if (A[j - 1] > A[j]){
                swap(A[j - 1], A[j]);
                sw++;
                flag = 1;
            }
        }
    }
    return sw;
}

int main(){
    int A[110], N, sw;
    cin >> N;
    for (int i = 0; i < N; i++){ cin >> A[i];}
    sw = bubbleSort(A,N);
    
    for(int i = 0; i < N; i++){
        if (i){ cout << " ";}
        cout << A[i];
    }
    cout << endl;
    cout << sw << endl;
    return 0;
}


Measured memory_bytes: 3084
import sys
import numpy as np

sys.setrecursionlimit(10 ** 9)
#def input():
#    return sys.stdin.readline()[:-1]
mod = 10**9+7

N = int(input())
#X, Y = map(int,input().split())
A = list(map(int,input().split()))

count = np.bincount(A, minlength=4)
total = np.sum(count * np.arange(4, dtype=int))

b = np.arange(N+1)[:, None]
c = np.arange(N+1)[None, :]
S_bc = 2 * b + 3 * c
dp = np.zeros((N+1,N+1))

for s in range(1,total+1):
    prev = dp
    a = s - S_bc
    dp = prev * a + N
    dp[1:] += prev[:-1] * b[1:]
    dp[:-1, 1:] += prev[1:, :-1] * c[:,1:]
    dp /= (a+b+c)
    dp[a<0] = 0
#    print(s,dp)

ans = dp[count[2],count[3]]
print(ans)

Measured memory_bytes: 18048
S=[input() for i in range(3)]

flag=1
i=0

while flag==1:
  t=S[i][0]
  if t=='a':
    ni=0
  elif t=='b':
    ni=1
  elif t=='c':
    ni=2
    
  S[i]=S[i][1:]
  #print(i,S[i])
  if S[ni]=='':
    print('A' if ni==0 else 'B' if ni==1 else 'C')
    flag=0
  else:
    i=ni

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
char s[21];
int main() {
	cin >> s + 1;
	if (s[1] == 'S')	cout << "Cloudy";
	else if (s[1] == 'C')	cout << "Rainy";
	else if (s[1] == 'R')	cout << "Sunny";
	return 0;
}

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

int main()
{
	int N;
	cin >> N;
	vector<long long> A( N );
	for( int i = 0; i < N; i++ ) {
		cin >> A[i];
	}

	sort( A.begin(), A.end(), greater<long long>() );
	long long ans = A[0];
	for( int i = 1; i < (N + 1) / 2; i++ ) {
		long long mi = min( A[i], A[i - 1] );
		if( i < N / 2 ) ans += mi;
		ans += mi;
	}

	cout << ans << endl;
}


Measured memory_bytes: 4804
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<ll,ll>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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 (a>b) { a=b; return 1; } return 0; }
int main(){
ll cnt=0,ans=0,now=0;
auto modpow=[](ll a,ll b,ll p){
    ll res=1;
    while(b){
        if(b&1){
            res*=a;
            res%=p;
        }
        a*=a;
        a%=p;
        b>>=1;
    }
    return res;
};
ll n,p;
cin>>n>>p;
string s;
cin>>s;
if(p==2||p==5){
    for(int i=0;i<n;i++){
        if((s[i]-'0')%p==0)ans+=i+1;
    }
    cout<<ans<<endl;
    return 0;
}
map<ll,ll> mp;

reverse(all(s));
for(ll i=0;i<n;i++){
    now+=ll(s[i]-'0')*modpow(10ll,i,p);
    now%=p;
      ans+=mp[now];
      if(now==0)ans++;
      mp[now]++;
}
cout<<ans<<endl;
}


Measured memory_bytes: 1044
n,x,y = list(map(int, input().split()))
lst = [0 for i in range(n)]

for i in range(1,n+1):
    for j in range(i+1,n+1):
        num = min(j-i, abs(x-i)+1+abs(y-j))
        lst[num]+=1
        # print(i,j,num)

for k in range(1,n):
    print(lst[k])


Measured memory_bytes: 3444
N = int(input())
zahyo = []

for i in range(N):
    A, B = map(int, input().split())
    left = max(A - B, 0)
    right = min(A + B, 1000000000)
    zahyo.append([left,right])
zahyo.sort()

count = 0
prev = [-2,-1]
for now in zahyo:
    if prev[1] >= now[1]:
        prev = now
    elif prev[1] <= now[0]:
        prev = now
        count += 1
print(count)

Measured memory_bytes: 20104
#include<iostream>
#include<map>
#include<set>
#include<string>
#include<algorithm>
#include<cmath>
#include<vector>
#include<queue>
#include<stack>
#include<limits>
#include<sstream> 
#include<unordered_map>      

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef int itn;
typedef vector<int> vi;
typedef vector<ll> vl;

const int inf = numeric_limits<int>::max() >> 2;
const ll linf = numeric_limits<ll>::max() >> 2;
const ull ulinf = numeric_limits<ull>::max() >> 2;
const double pi = acos(-1);
const int dx[4]={1,0,-1,0};
const int dy[4]={0,1,0,-1};
const int dx8[8]={-1,0,1,-1,1,-1,0,1};
const int dy8[8]={-1,-1,-1,0,0,1,1,1};

#define p_queue(i) priority_queue<i> 
#define rp_queue(i) priority_queue<i, vector<i>, greater<i>> 
#define umap(i,j) unordered_map<i,j>
#define P(p) cout<<(p)<<endl
#define PS(p) cout<<(p)<< " "
#define IN cin >> 
#define rep(i,m,n) for(int i = (m); i < (int)(n); i++)
#define rrep(i,m,n) for(int i = (m-1); i >= (int)(n); i--)
#define inrep(n,a) for(int i = 0; i < (int)(n); i++)cin >> a[i];
#define mod(i) ((i)%(ll)(1e9 + 7))
#define divm(a,b) (mod(a * modpow((ll)b,(ll)(1e9+5))))
#define rsort(a,b,c) sort(a, b, greater<c>())
#define vsort(v) sort(v.begin(), v.end())
#define rvsort(v,c) sort(v.begin(), v.end(), greater<c>()) 
#define ft first
#define sd second
#define pb push_back
#define it insert
#define sz(x) ((int)(x).size())
#define lb(a,n,k) (lower_bound(a,a+n,k) - a) 
#define vlb(a,k)  (lower_bound(a.begin(),a.end(),k) - a.begin())
#define ub(a,n,k) (upper_bound(a,a+n,k) - a) 
#define vub(a,k)  (upper_bound(a.begin(),a.end(),k) - a.begin())
#define YES cout<<"YES"<< endl
#define NO cout<<"NO"<<endl
#define Yes cout<<"Yes"<<endl
#define No cout<<"No"<<endl  
#define yes cout<<"yes"<<endl
#define no cout<<"no"<<endl
#define ret return

ll modpow(ll i,ll j){ ll tmp=1; while(j){ if(j%2)tmp=mod(tmp*i);i=mod(i*i);j/=2;}return tmp;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }

vector<string> split(const string &str, char sep){
    vector<string> v;
    stringstream ss(str);
    string buffer;
    while( getline(ss, buffer, sep) ) {
        v.push_back(buffer);
    }
    return v;
}

//ll ncr[100][100];
//ll nCr(int n, int r){if(n==r) ret ncr[n][r] = 1; if(r==0) ret ncr[n][r] = 1; if(r==1) ret ncr[n][r] = n;if(ncr[n][r]) ret ncr[n][r]; ret ncr[n][r] = nCr(n-1,r) + nCr(n-1,r-1);}

//ll npr[100][100]={};
//ll nPr(int n,int r){if(npr[n][r])ret npr[n][r];if(r==0)ret npr[n][r] = 1;if(r==1)ret npr[n][r] = n;ret npr[n][r] = n * nPr(n-1,r-1);}

//ll nHr(int n,int r){ret nCr(n+r-1,r);}

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


int main(){
    
    int n,W;
    cin >> n >> W;
    ll dp[n+1][W+1] = {};

    ll w[n],v[n];
    rep(i,0,n)cin >> w[i] >> v[i];

    rep(i,0,n){
	rep(j,1,W+1){
	    if(j-w[i] >= 0){
		dp[i+1][j] = max(dp[i][j], dp[i][j-w[i]] + v[i]);
	    }else{
		dp[i+1][j] = dp[i][j];
	    }
	}
    }

    P(dp[n][W]);
    return  0;
}


Measured memory_bytes: 79104
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
ans = 0
for i in range(N):
    A = list(map(int, input().split()))
    res = 0
    for j in range(M):
        res += A[j]*B[j]
    res += C
    if res > 0:
        ans += 1
print(ans)

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

#define MP make_pair
#define PB push_back
#define ALL(x)  (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define RANGEBOX(x,y,maxX,maxY) (0 <= (x) && 0 <= (y) && (x) < (maxX) && (y) < (maxY))
#define RANGE(x, l, r) ((l) <= (x) && (x) <= (r))
#define rep(i, N)  for (int i = 0; i < (int)(N); i++)
#define rrep(i, N) for (int i = N - 1; i >= 0; i--)
#define REP(i, init, N)  for (int i = (init); i < (int)(N); i++)
#define RREP(i, N, last) for (int i = (init - 1); i >= last; i--)
#define PB push_back

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef vector<int> VI;
typedef vector<VI > VVi;
typedef vector<string> VS;
typedef vector<LL> VLL;
typedef pair<int,int> PII;

const int    INF  = 0x3f3f3f3f;
const LL     INFL = 0x3f3f3f3f3f3f3f3fLL;
const double DINF = 0x3f3f3f3f;

int main(){
	ios::sync_with_stdio(false);
    int n;
    LL ans=1;
    cin>>n;
    for(int i=1;i<=n;i++){
        ans*=i;
        ans%=(1000000000+7);
    }

    cout<<ans<<endl;

    return 0;
}


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

#define REP(i,n) for(int i = 0; i < (int)n; ++i)
#define DEBUG(x) cerr << #x << " = " << x << endl

int main() {
  static bool wall[6][6][4];
  const int dx[4] = { 1, 0, -1, 0 };
  const int dy[4] = { 0, 1, 0, -1 };
  REP(i,6) REP(j,6) REP(k,4) {
    int ni = i + dy[k];
    int nj = j + dx[k];
    if(0 <= ni && ni < 6 && 0 <= nj && nj < 6) {
      wall[i][j][k] = 0;
    }
    else {
      wall[i][j][k] = 1;
    }
  }

  string s;
  for(int i = 0; i < 4; i++) {
    getline(cin, s);
    for(int j = 0; j < 4; j++) {
      wall[i][j + 1][1] = (s[j] == '1');
      wall[i + 1][j + 1][3] = (s[j] == '1');
    }
    getline(cin, s);
    for(int j = 0; j < 5; j++) {
      wall[i + 1][j][0] = (s[j] == '1');
      wall[i + 1][j + 1][2] = (s[j] == '1');
    }
  }
  getline(cin, s);
  for(int j = 0; j < 4; j++) {
    wall[4][j + 1][1] = (s[j] == '1');
    wall[5][j + 1][3] = (s[j] == '1');
  }

  string icon = "RDLU";
#if 0
  REP(i,6) REP(j,6) {
    cerr << "(" << i << "," << j << ")";
    REP(k,4) {
      if(wall[i][j][k]) cerr << icon[k];
    }
    cerr << endl;
  }
#endif

  int X = 1, Y = 0, dir = 0;
  string ans = "R";
  do {
#if 0
    cerr << "X = " << X << ", Y = " << Y << ", dir = " << dir << endl;
#endif
    if(wall[Y][X][dir] == 0) {
      Y += dy[dir];
      X += dx[dir];
      if(wall[Y][X][(dir + 1) % 4] == 0) {
        dir = (dir + 1) % 4;
        X += dx[dir];
        Y += dy[dir];
        if(wall[Y][X][(dir + 1) % 4] == 0) {
          dir = (dir + 1) % 4;
          X += dx[dir];
          Y += dy[dir];
          ans.push_back(icon[dir]);
        }
        else {
          ans.push_back(icon[dir]);
        }
      }
      else {
        ans.push_back(icon[dir]);
      }
    }
    else {
      dir = (dir - 1 + 4) % 4;
      ans.push_back(icon[dir]);
    }
  } while(!((X == 1 && Y == 0)));
  ans = ans.substr(0, (int)ans.size() - 1);
  cout << ans << endl;
}

Measured memory_bytes: 1184
N,M,C=map(int,input().split())
B=list(map(int,input().split()))

cc=0
A=[0]*N
for i in range(N):
  A[i]=list(map(int,input().split()))
  sum=0
  for j in range(M):
    sum=sum+A[i][j]*B[j]
    
  if sum>-C:
    cc=cc+1

print(cc)

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

const double pi = 3.14159265358979323846;
const ll mod = 1000000007;

vector<ll> a;
vector<int> seen(1000000);
ll cnt = 0, cnt1 = 0, idx;
void dfs(ll v){
	if(seen.at(v) == 2){
		idx = v;
		return;
	}
	if(seen.at(v) >= 1) cnt++;
	seen.at(v)++;
	cnt1++;
	dfs(a.at(v));
}

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	ll n, k; cin >> n >> k;
	a.resize(n);
	rep(i,n){
		cin >> a.at(i);
		a.at(i)--;
	}
	dfs(0);
	ll cnt2 = cnt1 - cnt * 2;
	if(k < cnt2){
		ll ans = 0;
		for(ll i = 1; i <= k; i++){
			ans = a.at(ans);
		}
		ans++;
		cout << ans << endl;
		return 0;
	}
	ll tmp = (k - cnt2) % cnt;
	int now = idx;
	for(int i = 1; i <= tmp; i++){
		now = a.at(now);
	}
	now++;
	cout << now << endl;
}

Measured memory_bytes: 8744
#include <iostream>
#include <string>
#include <algorithm>
#include <math.h>
#include <random>
#include <time.h>
	using namespace std;
	int main() {
		long long int n, p[100001],yan=0;
		cin >> n;
		for (int i = 1; i <= n; i++) {
			cin >> p[i];
		}
		for (int i = 1; i <= n; i++) {
			if (p[i] == i) {
				yan++;
				if (p[i + 1] == i + 1) {
					i++;
				}
			}
		}
		cout << yan << endl;
	}

Measured memory_bytes: 1024
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <math.h>
#include <queue>
#include <set>
#include <stack>
#include <vector>
using namespace std;
typedef long long int ll;
typedef long double ld;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define Sort(Array) sort(Array.begin(), Array.end())
#define Reverse(a) reverse(a.begin(), a.end())
#define out(ans) cout << ans << endl;
const int MOD = 1000000007;
const int INF = 2147483647;
const ld PI = 3.14159265358979323846;

//------------↓------------- M -------------- E ---------------- M --------------- O ---------------↓--------------//
// コンパイル 
// g++ -std=c++1z
//
// -------型変換--------
// int を string に変換
// string s = to_string(n);
// string を int に変換
// int n = stoi(s);
//
// -------二分探索---------
// k以上の値が最初に現れる時のイテレータ
// lower_bound(data.begin(), data.end(), k)
// kより大きい値が最初の現れる時のイテレータ O(logN)
// upper_bound(data.begin(), data.end(), k)
// kがdataに存在するかをtrue or falseで返す O(logN)
// binary_search(data.begin(), data.end(), k)
// 
//
//
//
//
//
// 
//------------↑------------- M -------------- E ---------------- M --------------- O ---------------↑--------------//







int main(void) {
    
    int N; cin >> N;
    int a[N]; rep(i,N) cin >> a[i];

    int c[9]; rep(i,9) c[i] = 0;
    rep(i,N) {
        if (a[i] < 400) ++c[0];
        else if (a[i] < 800) ++c[1];
        else if (a[i] < 1200) ++c[2];
        else if (a[i] < 1600) ++c[3];
        else if (a[i] < 2000) ++c[4];
        else if (a[i] < 2400) ++c[5];
        else if (a[i] < 2800) ++c[6];
        else if (a[i] < 3200) ++c[7];
        else ++c[8];
    }

    int mn, mx;
    int kind = 0;
    rep(i,8) {
        if (c[i] > 0) ++kind;
    }
    if (kind == 0) {
        mn = 1;
        mx = c[8];
    }
    else {
        mn = kind;
        mx = kind + c[8];
    }
    cout << mn << " " << mx << endl;
    
    return 0;
}









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

using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define MIN(a,b) ((a)>(b)? (b): (a))
#define MAX(a,b) ((a)<(b)? (b): (a))

const long long INF = 1LL << 60;
typedef unsigned long long ll;
const long long MOD = 1000000000 + 7;

int main(){
    string s1,s2,s3;
    cin >> s1 >> s2 >> s3;
    char i1,i2,i3;
    i1 = toupper(s1[0]);
    i2 = toupper(s2[0]);
    i3 = toupper(s3[0]);
    cout << i1 << i2 << i3 << endl;
    return 0;
}

Measured memory_bytes: 256
(N,M,X),*A=$<.map{_1.split.map &:to_i}
p (1<<N).times.map{|i|c,*t=A.transpose.map{|x|N.times.sum{x[_1]*i[_1]}}
t.any?{_1<X}?p: c}.compact.min||-1

Measured memory_bytes: 14552
#include <iostream>
#include <string>
#include <set>

using namespace std;

void input(int& N, set<int>& R_INDEX, set<int>& G_INDEX, set<int>& B_INDEX)
{
  char c;
  for (int i= 0; i < N; i++){
    cin >> c;
    switch(c){
    case 'R':
      R_INDEX.insert(i);
      break;
    case 'G':
      G_INDEX.insert(i);
      break;
    case 'B':
      B_INDEX.insert(i);
      break;
    }
  }
}

long long int findsetnum(set<int>& R_INDEX, set<int>& G_INDEX, set<int>& B_INDEX)
{
  long long int sum = 0;
  int a, b, c;
  set<int>::iterator R_iter, G_iter;
  for (R_iter = R_INDEX.begin(); R_iter != R_INDEX.end(); R_iter++)
    for (G_iter = G_INDEX.begin(); G_iter != G_INDEX.end(); G_iter++){
      a = (B_INDEX.find(2 * (*G_iter) - *R_iter) == B_INDEX.end())? 0 : 1;
      b = (B_INDEX.find(2 * (*R_iter) - *G_iter) == B_INDEX.end())? 0 : 1;
      c = (B_INDEX.find((*G_iter + *R_iter) / 2) == B_INDEX.end() || (*G_iter + *R_iter) % 2 != 0)? 0 : 1;
      sum += (B_INDEX.size() - a - b - c);
    }
  return sum;
}

int main(void)
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N;
  cin >> N;
  set<int> R_INDEX, G_INDEX, B_INDEX;
  input(N, R_INDEX, G_INDEX, B_INDEX);
  cout << findsetnum(R_INDEX, G_INDEX, B_INDEX) << '\n';
  return 0;
}


Measured memory_bytes: 3780
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys
import bisect

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
anss = []
for i in range(1,10):
    for j in range(1,10):
        anss.append(i*j)

if N in anss:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 65516
s = list(input())
lens = len(s)
if lens %2 == 1:
    ans = "No"
else:
    ans = "Yes"
    for i in range(lens//2):
        if s[i*2] == "h" and s[i*2+1] == "i":
            continue
        else:
            ans = "No"
            break
print(ans)

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

int main() {
  int a, b, c;
  cin >> a >> b >> c;
  if(a + b < b + c && a + b < a + c) {
    cout << a + b << endl;
  } else if(a + c < a + b && a + c < b + c) {
    cout << a + c << endl;
  } else {
    cout << b + c << endl;
  }
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline


def main():
    N, K, S = [int(x) for x in input().split()]

    ans = []
    for i in range(K):
        ans.append(S)
    for i in range(N - K):
        if S == 10 ** 9:
            ans.append(10 ** 9 - 1)
        else:
            ans.append(10 ** 9)

    print(*ans)



if __name__ == '__main__':
    main()



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

using namespace std;

typedef long long ll;

ll mod = 1e9+7;

typedef vector< vector<ll> > Matrix;

int N, K, C, T;

vector<int> shuffle(vector<int>& v, int a, int b) {
	vector<int> res;
	for (int i = 0; i < b; ++i) {
		res.push_back(v[a+i]);
	}
	for (int i = 0; i < a; ++i) {
		res.push_back(i);
	}
	for (int i = a+b; i < N; ++i) {
		res.push_back(i);
	}
	return res;
}
vector<int> make_shuffle(int a, int b) {
	vector<int> v(N);
	for (int i = 0; i < N; ++i) {
		v[i] = i;
	}
	v = shuffle(v, a, b);
	vector<int> res(N);
	for (int i = 0; i < N; ++i) {
		res[v[i]] = i;
	}
	return res;
}

vector< vector<ll> > make_E() {
	vector< vector<ll> > res(N*5, vector<ll>(N*5, 0));
	for (int i = 0; i < N*5; ++i) {
		res[i][i] = 1;
	}
	return res;
}
vector< vector<ll> > mul(Matrix A, Matrix B) {
	vector< vector<ll> > res(N*5, vector<ll>(N*5, 0));
	for (int i = 0; i < N*5; ++i) {
		for (int j = 0; j < N*5; ++j) {
			for (int k = 0; k < N*5; ++k) {
				res[i][j] = (res[i][j] + A[i][k] * B[k][j] % mod);
				if (res[i][j] >= mod) res[i][j] -= mod;
			}
		}
	}
	return res;
}

vector< vector<ll> > power(Matrix A, int n) {
	Matrix res = make_E();
	for (int i = 1; i <= n; i <<= 1) {
		if (n & i) {
			res = mul(res, A);
		}
		A = mul(A, A);
	}
	return res;
}

int main() {
	cin >> N >> K >> C >> T;
	vector< vector< vector<ll> > > pat(5, vector< vector<ll> >(N, vector<ll>(N, 0)));
	for (int i = 0; i < K; ++i) {
		int a, b, t; cin >> a >> b >> t; --a, --t;
		vector<int> to = make_shuffle(a, b);
		for (int j = 0; j < to.size(); ++j) {
			++pat[t][j][to[j]];
		}
	}
	vector< vector<ll> > G(N*5, vector<ll>(N*5, 0));
	for (int t = 0; t < 5; ++t) {
		for (int i = 0; i < N; ++i) {
			for (int j = 0; j < N; ++j) {
				int from = i*5;
				int to = j*5+t;
				G[from][to] += pat[t][i][j];
			}
		}
	}
	for (int i = 0; i < N; ++i) {
		for (int t = 1; t < 5; ++t) {
			G[i*5+t][i*5+t-1] = 1;
		}
	}
	vector< vector<ll> > g = power(G, T);
/*	for (int i = 0; i < N*5; ++i) {
		for (int j = 0; j < N*5; ++j) {
			cout << g[i][j] << " ";
		}
		cout << endl;
	}
*/	cout << g[(C-1)*5][0*5] << endl;
}

Measured memory_bytes: 4992
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n,v[60],c[60],r,ans=0;
    cin>>n;
    for(int i=0; i<n; i++)
    {
        cin>>v[i];
    }
    for(int i=0; i<n; i++)
    {
        cin>>c[i];
    }
    for(int i=0; i< n; i++)
    {
        r=v[i]-c[i];
        if(r>0)
        ans=ans+r;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3600
#include <iostream>
#include <stdlib.h>
#include <utility>
#include <math.h>
#include <stdexcept>
#include <algorithm>
#include <vector>
#include <stdio.h>
#define   FOR(i,n) for(int i=0;i<=n;i++)

using namespace std;
int int_sort(const void*a,const void *b) {
    return *(  int *) b - *(int *) a;
    //qsort(b, a, sizeof(long long int), int_sort);
}

int main() {
  int a,b,c,x,count=0;

   cin>>a>>b>>c>>x;

   FOR(j,a){
       FOR(k,b){
           FOR(m,c){
               if(500*j+100*k+50*m==x)
                   count+=1;
           }
       }
   }

   cout<<count;
return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define repi(i,a,b) for(ll (i)=(a);(i)<(b);(i)++)
#define SIZE_OF_ARRAY(array)    (sizeof(array)/sizeof(array[0]))
typedef long long ll;
using namespace std;
int main(){
  double n;
  cin >> n;
  cout << ceil(n/2)<< endl;
  return 0;
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 998244353LL;
constexpr long long INF = 1000000009LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

ll rui(ll a,ll b){
     ll ans=1;
     while(b>0){
        if(b&1) ans=ans*a%MOD;
        a=a*a%MOD;
        b/=2;
    }
     return ans;
}

int main() {
    int n; cin >> n;
    vector<ll> counter(n, 0);
    ll res = 1;
    rep(i, n){
        ll d; cin >> d;
        counter[d]++;
        if(i==0&&d!=0 || i!=0&&d==0) res = 0;
    }
    bool not_find = false;
    for(int i=1; i<n; i++){
        if(counter[i] == 0) not_find = true;
        if(not_find && counter[i] != 0) res = 0;
    }
    if(res == 0) cout << res << ln;
    else{
        for(int i=1; i<n; i++){
            if(counter[i] == 0) break;
            res = res * rui(counter[i-1], counter[i]) % MOD;
        }
        cout << res << ln;
    }
}


Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#include<stdbool.h>

bool *plfl;

long long lim=3000000;
void sieve_of_erat(){
  plfl=malloc(sizeof(bool)*(lim+5));
  long long i,j;
  for(i=0;i<lim+5;i++){plfl[i]=true;}
  plfl[0]=false;
  plfl[1]=false;
  for(i=2;i<lim;i++){
    if(!plfl[i]){continue;}
    for(j=2*i;j<lim;j+=i){
      plfl[j]=false;
    }
  }
  return;
}

int main(){
  sieve_of_erat();
  long long i,r=0,x;
  scanf("%lld",&x);
  for(i=x;i<2000000;i++){
    if(plfl[i]){printf("%lld\n",i);return 0;}
  }
  return 0;
}


Measured memory_bytes: 3072
# -*- coding: utf-8 -*-
x, y, z, k = map(int, input().split())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

bc = [i + j for i in b for j in c]
bc.sort(reverse=True)

abc = [i + j for i in a for j in bc[:min(k, len(bc))]]
abc.sort(reverse=True)

for i in range(k):
    print(abc[i])


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

int main() {
    string s;
    cin >> s;
    ll res = 0;
    for (auto i : s) res+=i-48;
    if (res%9==0) cout << "Yes";
    else cout << "No";
    return 0;
}

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

int main()
{
	int n,i;
	cin>>n;
	set<string> a;
	string tmp;
	for ( i =1; i <= n; ++i) 
	{
		cin >> tmp;
    	a.insert(tmp);
	}
	cout << a.size();
	return 0;
}

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

ll c, n , m, s[10005], p[10005], dp[2][10005];

int main() {
    cin >> c >> n >> m;
    for(int i=0;i<n;i++){
        cin >> s[i] >> p[i];
    }
    for(int i=0;i<n;i++){
        for(int j=0;j<=c;j++){
            int ii = i%2;
            dp[ii^1][j] = max(dp[ii^1][j], dp[ii][j]);
            if(j+s[i] <= c) dp[ii^1][j+s[i]] = max(dp[ii^1][j+s[i]], dp[ii][j]+p[i]);
        }
    }
    for(int i=1;i<=m;i++){
        cout << dp[n%2][c/i]*i << endl;
    }
    return 0;
}



Measured memory_bytes: 3424
N = int(input())
l = [list(map(int, input().split())) for _ in range(N)]

pT, pX, pY = 0, 0, 0

for i in range(N):
    cT, cX, cY = l[i]
    mvT, mvX, mvY = abs(cT-pT), abs(cX-pX), abs(cY-pY)
    
    dam = mvT - (mvX+mvY)

    if dam %2 == 1 or dam < 0:
        print('No')
        exit()

    pT, pX, pY = l[i]

print('Yes')



Measured memory_bytes: 27056
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
typedef long long llong;
char moji[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
char moji2[26]={'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define ld PRId64


llong judge(llong h,llong w){
    llong tmp_h=h/3,tmp_w=w - w/2;
    llong a,b,c,ans=0;
    a=w * tmp_h;
    c= (h-tmp_h) * tmp_w;

    tmp_h+=(c-a)/ (w + tmp_w);
    a= w * tmp_h;
    c= tmp_w * (h-tmp_h);
    b= h*w - a - c;
    ans = max( abs(c-a),c-b);

    tmp_h+=1;
    a= w * tmp_h;
    a= w * tmp_h;
    c= tmp_w * (h-tmp_h);
    b= h*w - a - c;
    if( ans > max( abs(a-b) ,c-b)) ans = max( abs(a-b) ,c-b);
    

    ans = min(w,ans);
    return ans;

} 


int main(){
    llong h,w;
    cin >> h >> w;

    llong ans,ans2;
    if( h%3==0 or w %3==0) cout << 0 << endl;
    else{
        ans=judge(h,w);
        ans2=judge(w,h);
        cout << min(ans,ans2) << endl;
    }
}


Measured memory_bytes: 256
Q, H, S, D = map(int, input().split())
N = int(input())

# Q : 1
# H : 2
# S : 4
# D : 8
N *= 4
ans = 0

price = [(Q / 1, 1, Q), (H / 2, 2, H), (S / 4, 4, S), (D / 8, 8, D)]
price.sort()

for _, n, p in price:
    cnt = N // n
    ans += cnt * p
    N -= cnt * n

print(ans)


Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
using namespace std;

typedef vector<int> vi;
typedef pair<int, int> pii;

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

int T, N, c;
string str, proc;

void process(string& p) {
	if(p == "forward char") {
		if(c < str.size()) c++;
	}
	else if(p == "backward char") {
		if(c > 0) c--;
	}
	else if(p == "forward word") {
		if(c == str.size()) return;
		while(str[c] == ' ' && c < str.size()) c++;
	    while(str[c] != ' ' && c < str.size()) c++;
	}
	else if(p == "backward word") {
		if(c == 0) return;
		while(str[c-1] == ' ' && c > 0) c--;
		while(str[c-1] != ' ' && c > 0) c--;
	}
	else if(p == "delete char") {
		if(c != str.size()) str.erase(c, 1);
	}
	else if(p == "delete word") {
		if(c == str.size()) return;
		int ct = c;
		while(str[ct] == ' ' && ct != str.size()) ct++;
		if(ct == str.size()) return;
		while(str[ct] != ' ' && ct != str.size()) ct++;
		str.erase(c, ct-c);
	}
	else {
		size_t s = p.find_first_of('"');
		size_t e = p.find_last_of('"');
		string a = p.substr(s+1, e-s-1);
	    // cout << a << endl;
		if(c != str.size()) {
			str = str.substr(0, c) + a + str.substr(c, str.size()-1);
		} else {
			str = str + a;
		}
		c = c + a.size();
	}
}

void out() {
	rep(i,c) printf("%c", str[i]);
	printf("^");
	repa(i,c,(int)str.size()-1) printf("%c", str[i]);
	printf("\n");
}

int main() {
	char buf[256];
	cin >> T;
	cin.ignore();
	rep(t,T) {
		fgets(buf, sizeof(buf), stdin);
		*(strchr(buf, '\n')) = '\0';
		str = string(buf);

		scanf("%d\n", &N);
		c = 0;
		rep(i,N) {
			getline(cin, proc);
			process(proc);
//			out();
		}
		out();
	}
}

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

int main() {
	int n, k;
	cin >> n >> k;
	vector<int> V(n);
	for (int i = 0; i < n; i++) {
		cin >> V[i];
	}
	int ans = 0;
	for (int x = 1; x <= min(n, k); x++) {	
		for (int lx = 0; lx <= x; lx++) {
			int rx = x - lx;
			vector<int> pv, mv;
			for (int i = 0; i < lx; i++) {
				int a = V[i];
				if (a >= 0) pv.push_back(a);
				else mv.push_back(a);
			}
			for (int i = 0; i < rx; i++) {
				int a = V[n-1-i];
				if (a >= 0) pv.push_back(a);
				else mv.push_back(a);
			}
			int z = min((int)mv.size(), k - x);
			sort(mv.begin(), mv.end());
			int now = 0;
			for (int i = z; i < mv.size(); i++) {
				now += mv[i];
			}
			for (int e : pv) {
				now += e;
			}
			ans = max(ans, now);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3144
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class Program
{
    void Calc()
    {
        var sc = new Scanner();

        int a = sc.NextInt();
        int b = sc.NextInt();
        int menseki = a * b;
        int mawari = a * 2 + b * 2;
        Console.WriteLine(menseki + " "+ mawari);
    }

    static void Main()
    {
        new Program().Calc();
    }

    class Scanner
    {
        string[] s = new string[0];
        int i = 0;
        char[] cs = new char[] { ' ' };

        public string Next()
        {
            if (i < s.Length) return s[i++];
            s = Console.ReadLine().Split(cs, StringSplitOptions.RemoveEmptyEntries);
            i = 0;
            return s[i++];
        }
        public int NextInt() { return int.Parse(Next()); }
        public long NextLong() { return long.Parse(Next()); }
        public double NextDouble() { return double.Parse(Next()); }
    }
}

Measured memory_bytes: 19936
import math
n = int(input())
max_int = int(math.sqrt(n))+1
i = max_int
ans_tmp = n
while i > 0:
    warikire = n%i
    waru = int(n/i)
    if warikire == 0 and waru <= ans_tmp:
        ans_tmp = waru
    i-=1
warukazu = int(n/ans_tmp)
print(warukazu+ans_tmp-2)

Measured memory_bytes: 40684
def main():
    N = int( input())
    t = 10**18
    A = list( map( int, input().split()))
    ans = 1
    # if Counter(A)[0] > 0:
    #     print(0)
    #     return
    A.sort()
    for a in A:
        ans *= a
        if ans > t:
            print(-1)
            return
    print(ans)
if __name__ == '__main__':
    main()


Measured memory_bytes: 21788
#include <bits/stdc++.h>
#define REP(i, m, n) for(int (i) = (m); (i) < (n); ++i)
#define rep(i, n) REP(i, 0, n)
#define all(x) (x).begin(), (x).end()
using namespace std;
using Graph = vector<vector<int>>;
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; }
typedef long long ll;
typedef pair<ll, ll> P;
const int INF = 1e9+7;
const ll LINF = 1LL<<60;

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(0);
    char x, y;
    cin >> x >> y;

    int a = x - '0';
    int b = y - '0';

    if (a > b) {
        cout << ">" << endl;
    }
    else if (a < b) {
        cout << "<" << endl;
    }
    else cout << "=" << endl;


    return 0;
}

Measured memory_bytes: 256
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

const P: i64 = 1_000_000_007;

pub fn pow(x: i64, n: i64) -> i64 {
    let (mut x, mut y, mut n) = (x % P, 1_i64, n);
    while n > 0 {
        if n % 2 != 0 {
            y = (y * x) % P;
            n -= 1;
        }

        x = (x * x) % P;
        n /= 2;
    }
    y
}

fn choose(n: i64, r: i64) -> i64 {
    let mut t = 1;

    for k in 0..r {
        t *= n - k;
        t %= P;

        t *= pow(k + 1, P - 2); // t/k
        t %= P;
    }

    t
}

fn main() {
    let (n, a, b) = read!(i64, i64, i64);

    // 2^n - C(n, a) - C(n, b) - 1
    let mut total = pow(2, n);
    total += P - choose(n, a);
    total %= P;
    total += P - choose(n, b);
    total %= P;
    total += P - 1;
    total %= P;

    println!("{}", total)
}


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

using ll=long long; 

void solve(){
	int r,d,x2000;
	cin>>r>>d>>x2000;
	int pos=x2000;
	int tmp=0;
	for(int i=0; i<10; i++){
		tmp=r*pos-d;
		cout<<tmp<<endl;
		pos=tmp;
	}
}

signed main(){
	//while(1)
	solve();
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-
'''
所要時間は、分位であった。
'''


# ライブラリのインポート
#import re
import sys
input = sys.stdin.readline
#import heapq
#import bisect
#from collections import deque
#import math

def main():
    P = []
    for line in sys.stdin:
        x, y = map(float, line.strip().split(','))
        P.append(complex(x, y))
    ans = areap(P)
    print(abs(ans))

def areap(P):
    s = 0
    n = len(P)
    for i in range(1,n-1):
        a, b, c = P[0],P[i],P[i+1]
        s += cdot(b-a,c-a)
    return s/2

def cdot(x, y):
    return (x.conjugate() * y).imag

    


    
if __name__ == '__main__':
    main()



Measured memory_bytes: 4724
#include<bits/stdc++.h>
#define INF 2147483647
#define SYOU(x) setprecision(x)
using namespace std;
long long i[300000];
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  long long a=0,b=0,c=0,d=0,e=1,f=0;
  cin >>i[0]>>i[1]>>i[2];
  sort(i,i+3);
  if(i[0]+i[1]==i[2]) cout <<"Yes\n";
  else cout <<"No\n";
  return (0);
}



Measured memory_bytes: 256
#
# 　　  ⋀_⋀　 
#　　  (･ω･)  
# .／ Ｕ ∽ Ｕ＼
#  │＊　合　＊│
#  │＊　格　＊│ 
#  │＊　祈　＊│ 
#  │＊　願　＊│ 
#  │＊　　　＊│ 
#      ￣
#
import sys
sys.setrecursionlimit(10**6)
input=sys.stdin.readline
from math import floor,ceil,sqrt,factorial,log #log2ないｙｐ
from heapq import heappop, heappush, heappushpop
from collections import Counter,defaultdict,deque
from itertools import accumulate,permutations,combinations,product,combinations_with_replacement
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf=float('inf')
mod = 10**9+7
def pprint(*A): 
    for a in A:     print(*a,sep='\n')
def INT_(n): return int(n)-1
def MI(): return map(int,input().split())
def MF(): return map(float, input().split())
def MI_(): return map(INT_,input().split())
def LI(): return list(MI())
def LI_(): return [int(x) - 1 for x in input().split()]
def LF(): return list(MF())
def LIN(n:int): return [I() for _ in range(n)]
def LLIN(n: int): return [LI() for _ in range(n)]
def LLIN_(n: int): return [LI_() for _ in range(n)]
def LLI(): return [list(map(int, l.split() )) for l in input()]
def I(): return int(input())
def F(): return float(input())
def ST(): return input().replace('\n', '')
def main():
    N,K = MI()
    H = LI()
    ans = 0
    for h in H:
        if(h>=K):
            ans+=1
    print(ans)
if __name__ == '__main__':
    main()

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

#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define F0R(i,a) FOR(i,0,a)
#define ROF(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define R0F(i,a) ROF(i,0,a)

using ll = long long;
using ld = long double;
ll INF = LLONG_MAX;

using vi = vector<int>;
using vll = vector<ll>;
using pii = pair<int, int>;

namespace output {
	void pr(int x) { cout << x; }
	void pr(long x) { cout << x; }
	void pr(ll x) { cout << x; }
	void pr(unsigned x) { cout << x; }
	void pr(unsigned long x) { cout << x; }
	void pr(unsigned long long x) { cout << x; }
	void pr(float x) { cout << x; }
	void pr(double x) { cout << x; }
	void pr(ld x) { cout << x; }
	void pr(char x) { cout << x; }
	void pr(const char* x) { cout << x; }
	void pr(const string& x) { cout << x; }
	void pr(bool x) { pr(x ? "true" : "false"); }
	template<class T> void pr(const complex<T>& x) { cout << x; }
	
	template<class T1, class T2> void pr(const pair<T1,T2>& x);
	template<class T> void pr(const T& x);
	
	template<class T, class... Ts> void pr(const T& t, const Ts&... ts) { 
		pr(t); pr(ts...); 
	}
	template<class T1, class T2> void pr(const pair<T1,T2>& x) { 
		pr("{",x.first,", ",x.second,"}"); 
	}
	template<class T> void pr(const T& x) { 
		pr("{"); // const iterator needed for vector<bool>
		bool fst = 1; for (const auto& a: x) pr(!fst?", ":"",a), fst = 0; 
		pr("}");
	}
	
	void print() { pr("\n"); } // print w/ spaces
	template<class T, class... Ts> void print(const T& t, const Ts&... ts) { 
		pr(t); if (sizeof...(ts)) pr(" "); print(ts...); 
	}
}

using namespace output;

vll arr;
ll N, X; 

ll cost (ll i, ll j) {
	if (i == 0) 
		return 5 * arr[j] + 2 * X;
	else 
		return (2 * (1LL * i + 1) + 1) * arr[j] + X;
}

ll calc(int len) {
	int h = 0;
	int x = 0;
	ll cur = 0;
	while (x < N) {
		cur += cost(h, x);
		++x;
		if (x % len == 0) ++h;
	}
	return cur;
}

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

	cin >> N >> X;
	arr.resize(N);
	F0R(i, N) cin >> arr[i];
	reverse(arr.begin(), arr.end());

	int l = 1;
	int h = N-1;
	while (l < h) {
		int m = l + (h - l) / 2;
		ll c1 = calc(m);
		ll c2 = calc(m+1);
		if (c1 <= c2) {
			h = m;
		} else {
			l = m + 1;
		}
	}

	ll ans = min(calc(l), calc(N));
	print(ans);
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <utility>
#include <map>
#include <algorithm>
#include <queue>
#include <cmath>

using namespace std;

int main() {
  int ans = 0;
  int smax = -1;
  for (int i=0; i<5; i++) {
    int a;
    cin >> a;
    int s = (10 - (a%10))%10;
    ans += (a+s);
    smax = max(smax, s);
  }

  cout << (ans - smax) << endl;
}

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

const int INF = 1001001001;

int a[12][12];

int main() {
  int n, m, x;
  cin >> n >> m >> x;
  vector<int> c(n);
  rep(i,n) {
    cin >> c[i];
    rep(j,m) cin >> a[i][j];
  }

  int ans = INF;
  rep(s,1<<n) {
    int cost = 0;
    vector<int> d(m);
    rep(i,n) {
      if (s>>i&1) {
        cost += c[i];
        rep(j,m) d[j] += a[i][j];
      }
    }
    bool ok = true;
    rep(j,m) if (d[j] < x) ok = false;
    if (ok) ans = min(ans, cost);
  }
  if (ans == INF) cout << -1 << endl;
  else cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3604
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<numeric>
#include<iomanip>
using namespace std;

int main() {
	int x, y, z;
	cin >> x >> y >> z;
	x = x - 1;
	int a = x / (y + z);
	if (a*(y + z) + z > x + 1) {
		cout << a - 1 << endl;
	}
	else {
		cout << a << endl;
	}

}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  char S[11];
  char x[]="ACGT";
  int i=0,g=9,sa,m,max=0;
  int a[10]={0};
  char b;
  scanf("%s\n",S);
  while(1){
    if(S[i]!=x[0]&&S[i]!=x[1]){
      if(S[i]!=x[2]&&S[i]!=x[3]){
        i++;
      }
    }
    if(S[i]==x[0]||S[i]==x[1]){
       break;
    }
    else if(S[i]==x[2]||S[i]==x[3]){
        break;
    }
  }
  while(1){
    if(S[g]!=x[0]&&S[g]!=x[1]){
      if(S[g]!=x[2]&&S[g]!=x[3]){
        g--;
        //m=g;
      }
    }
     if(S[g]==x[0]||S[g]==x[1]){
        break;
     }
     else if(S[g]==x[2]||S[g]==x[3]){
        break;
    }
  }
  b=S[g];
  //printf("%s\n",b);
    for(m=0;(g-m)>=i;m++){
      //printf("%d\n",a[0]);
      if(S[g-m]==x[0]||S[g-m]==x[1]){
        max++;
        if(a[0]<=max){
        a[0]=max;
        }
      }
      else if(S[g-m]==x[2]||S[g-m]==x[3]){
        max++;
        if(a[0]<=max){
        a[0]=max;
        }
      }
      else{
        if(a[0]<=max){
        a[0]=max;
        max=0;
        }
      }
    }
        
  printf("%d\n",a[0]);
  return 0;
}
  
        

Measured memory_bytes: 128
from itertools import product
N,A,B,C = map(int,input().split())
L = [int(input()) for _ in range(N)]
cntmin = abs(A-L[0])+abs(B-L[1])+abs(C-L[2])
for x in product(range(4),repeat=N):
    cnt = 0
    a = x.count(1)
    b = x.count(2)
    c = x.count(3)
    if a*b*c==0:continue
    A1 = []
    B1 = []
    C1 = []
    for i in range(N):
        if x[i]==1:
            A1.append(L[i])
        elif x[i]==2:
            B1.append(L[i])
        elif x[i]==3:
            C1.append(L[i])
    cntA = 10*(len(A1)-1)
    La = 0
    for l in A1:
        La += l
    cntA += abs(A-La)
    cntB = 10*(len(B1)-1)
    Lb = 0
    for l in B1:
        Lb += l
    cntB += abs(B-Lb)
    cntC = 10*(len(C1)-1)
    Lc = 0
    for l in C1:
        Lc += l
    cntC += abs(C-Lc)
    cntmin = min(cntmin,cntA+cntB+cntC)
        
print(cntmin)    

Measured memory_bytes: 59372
#include <iostream>
#include <math.h>
//#include <numeric>
#include <vector>
//#include <map>
#include <algorithm>

using namespace std;
#define n_max 100000
#define N_max 100

#define rep(i, a, n) for(int i = a; i < n; i++)
#define rrep(i, a, n) for(int i = a; i > n; i--)
#define lrep(i, a, n) for(long int i = a; i < n; i++)
#define in(a) cin >> a
#define out(a) cout << a << endl

int main()
{
    int N, C, K;
    vector<int> T;

    cin >> N >> C >> K;

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

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

    //for(int i = 0; i < N; i++) { //cout << T.at(i) << endl; }

    int bus = 0;
    int i = 0;
    while(i < N) {
        int max_time = T.at(i++) + K;
        int person = 1;
        for(int j = i; j < N; j++) {
            if(max_time < T.at(j)) { break; }
            person++;
            i++;
            if((person % C) == 0) { break; } 
        }
        bus += (person / C);
        if((person % C) != 0) { bus++; } 
        //bus++;
    }
    
    cout << bus << endl;

    return 0;
}


Measured memory_bytes: 892