akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
typedef long long ll;
void print(ll **dp,ll h,ll w){
	for(ll i = 0;i<h;i++)
		{
			
			for(ll j = 0;j<w;j++)
				cout<<dp[i][j]<<" ";
			cout<<endl;
		}
}
ll countways(char **matrix,ll **dp,ll h,ll w){
	for(ll i = 0;i<w;i++)
		if(matrix[0][i] == '.')
			dp[0][i] = 1;
		else
			break;
	for(ll i = 1;i<h;i++)
		if(matrix[i][0] == '.')
			dp[i][0] = 1;
		else
			break;
	for(ll i = 1;i<h;i++)
		for(ll j = 1;j<w;j++)
			if(matrix[i][j] == '.')
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
	//print(dp,h,w);
	return dp[h-1][w-1];
}
int main() {
	// your code goes here
	ll h,w;
	cin>>h>>w;
	char **matrix = new char*[h];
	for(ll i = 0;i<h;i++){
		matrix[i] = new char[w];
		for(ll j = 0;j<w;j++)
			cin>>matrix[i][j];
	}
	ll **dp = new ll*[h];
	for(ll i = 0;i<h;i++){
		dp[i] = new ll[w];
		for(ll j = 0;j<w;j++)
			dp[i][j] = 0;
	}
	cout<<countways(matrix,dp,h,w)<<endl;
	return 0;
}

Measured memory_bytes: 12464
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<ll, ll> p;
 
#define MOD 1000000007
 
int main() {
	cin.tie(0);
    ios::sync_with_stdio(false);

    int N;
    cin >> N;

    vector<ll> A(N);

    for(int i = 0; i < N; i++) cin >> A[i];

    vector<ll> dp(N, 1000L);

    for(int i = 0; i < N - 1; i++) {
        ll a = dp[i] / A[i];
        ll b = dp[i] % A[i];
        ll x = dp[i];
        for(int j = i + 1; j < N; j++) {
            x = max(x, a * A[j] + b);
            dp[j] = max(dp[j], x);
        }
    }

    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 3652
#include <stdio.h>
int main()
{
  int a[100];
  int n,k,i,j;
  for(;;){
    scanf("%d%d",&n,&k);
    if(n==0 && k==0) break;
    for(i=0;i<k;i++){
      scanf("%d",&a[i]);
    }
    while(n--){
      for(i=0;i<k;i++){
	scanf("%d",&j);
	a[i] -= j;
      }
    }
    for(i=0;i<k;i++){
      if(a[i] < 0) break;
    }
    if(i==k) printf("Yes\n");
    else printf("No\n");
  }
  return 0;
}

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

int main(){
  string S,T; cin >> S >> T;
  for(int i=0;i<S.size();i++){
    if(S == T){
      cout << "Yes" << endl;
      return 0;
    }
    S = S.back()+S.substr(0,S.size()-1);
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include<stdio.h>

#define NMAX 100000

int binarySearch(int A[], int n, int key){
	int i = 0, left = 0, right = n;
	int mid;
	while(left < right){
		mid = (left + right) / 2;
		if(A[mid] == key){
			return 1;
		}
		else if(key < A[mid]){
			right = mid;
		}
		else{
			left = mid + 1;
		}
	}
	return 0;
}

int main(void){
	int x,i,n,q,key,sum = 0;
	int A[NMAX+1];
	scanf("%d" ,&n);
	for(i = 0; i < n; i++){
		scanf("%d" ,&A[i]);
	}
	scanf("%d" ,&q);
	for(i = 0; i < q; i++){
		scanf("%d" ,&key);
		x = binarySearch(A,n,key);
		if(x != 0){
			sum++;
		}
	}
	printf("%d\n" ,sum);
	return 0;
}


Measured memory_bytes: 2092
N = int(input())
cnt = 0
end_A = 0
start_B = 0
start_B_AND_end_B = 0
for _ in range(N):
    s = input()
    if s.startswith('B') and s.endswith('A'):
        start_B_AND_end_B += 1
    elif s.startswith('B'):
        start_B += 1
    elif s.endswith('A'):
        end_A += 1
    
    cnt += s.count('AB')
    
    
if start_B_AND_end_B >= 1:
    cnt += start_B_AND_end_B - 1
    if end_A >= 1:
        cnt += 1
        end_A -= 1
    if start_B >= 1:
        cnt += 1
        start_B -= 1

cnt += min(end_A, start_B)

print(cnt)

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

int main(){
  string S, T;
  cin >> S >> T;
  int A, B;
  cin >> A >> B;
  string U;
  cin >> U;
  if (U == S) cout << A-1 << " " << B << endl;
  else cout << A << " " << B-1 << endl;
}

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

#define rep(i,start,end) for(int i=start;i<(int)(end);i++)
#define rrep(i,start,end) for(int i=start-1;i>=(int)(end);i--)
#define each(it,v) for(auto &it : v)
#define all(v) (v).begin(),(v).end()

using namespace std;
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using Pii = pair<int,int>;
using Pll = pair<ll,ll>;
using vpii = vector<Pii>;
using vpll = vector<Pll>;

const ll mod=1e9+7;
const int intINF=INT_MAX;
const ll  longINF=LONG_LONG_MAX;
ll power(ll a, ll n, ll m)
{
        ll ret = 1;
        for (; n > 0; n >>= 1, a = a * a % m)
        {
                if (n % 2 == 1)
                {
                        ret = ret * a % m;
                }
        }
        return ret;
}

ll C(int N,int K)
{
        ll x=1,y=1;
        for(int i=1;i<=K;i++)
        {
                x=x*(N-i+1)%mod;
                y=y*i%mod;
        }
        return x*power(y,mod-2,mod)%mod;
}


main()
{
        int n,a,b; cin>>n>>a>>b;

        ll ans=power(2,n,mod)-1;
        ans-=C(n,a)%mod;
        ans-=C(n,b)%mod;
        cout<<(ans%mod+mod)%mod<<endl;
}

Measured memory_bytes: 256
import java.util.*;

 class Main
 {
   public static void main(String args[])
   { 
    input();
   }
   static void input()
   {
     Scanner sc = new Scanner(System.in);
     
     int r = sc.nextInt();
     
     int c = sc.nextInt();
     
     int n[][] = new int[r + 1][c + 1];
     
     int rsum[] = new  int[c + 1];
     
     int csum[] = new int[r];
     
     for(int i = 0; i <= r; i ++)
     {
       for(int j = 0; j <= c; j ++)
       {
         if(i == r)
         {
           n[i][j] = rsum[j];
         }
         else if(j == c)
         {
           n[i][j] = csum[i];
           
           rsum[j] += n[i][j];
         }
         else
         {
           n[i][j] = sc.nextInt();
         
           rsum[j] += n[i][j];
         
           csum[i] += n[i][j];
         }
       }
     }
     output(n);
   }
   static void output(int n[][])
   {
     for(int i = 0; i < n.length; i ++)
     {
       for(int j = 0; j < n[i].length; j ++)
       {
         if(j != 0)System.out.print(" ");
         
         System.out.print(n[i][j]);
       }
       System.out.println();
     }
   }
 }
    


Measured memory_bytes: 41920
#include<iostream>

using namespace std;

int main(){
    long x;
    cin >>x;
    long ans = x / 11;
    //cout << ans << endl;
    ans *= 2;
    //cout << ans << endl;
    long n = x % 11;
    if(n == 0){

    }else if(n <= 6){
        ans++;
    }else{
        ans += 2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <functional>
#include <algorithm>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <vector>
#include <array>
#include <tuple>
#include <utility>
#include <numeric>
#include <iomanip>
#include <cctype>
#include <cmath>
#include <assert.h>
#include <cstdlib>
#include <list>
using namespace std;

using ll = long long;
using ull = unsigned long long;
using PII = pair<int, int>;
using PLL = pair<ll, ll>;

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 (int i = 0; i < v.size(); i++) s << (i == 0 ? "" : ", ") << v[i];
    s << "]";
    return s;
}

#define ALL(a) (a).begin(), (a).end()

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

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

int main() {
    int N;
    cin >> N;
    vector<ll> T(N);
    for (int i = 0; i < N; i++) {
        cin >> T[i];
    }
    ll val = 1;
    for (int i = 0; i < N; i++) {
        val = lcm(val, T[i]);
    }
    cout << val << endl;

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define pb push_back
#define pf pop_front
#define mp make_pair
#define mod 1000000007
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);
#define mat vector<vector<int>>
#define all(x) x.begin(),x.end()
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;i++)
#define inp(a) int a;cin>>a;
#define inpa(a,n)vector<int> a(n);fo(i,n)cin>>a[i];
#define printclock cerr<<"Time : "<<1000*(ld)clock()/(ld)CLOCKS_PER_SEC<<"ms\n";
using namespace std;
#define int ll


auto max(auto a){auto ans=a[0];for(auto i:a)if(i>ans)ans=i;return ans;}
auto min(auto a){auto ans=a[0];for(auto i:a)if(i<ans)ans=i;return ans;}
void print(auto a){for(auto i:a)cerr<<i<<' ';cerr<<'\n';}



signed main()
{
	fio
	inp(n) inp(k)
	inpa(a,n)
	int dp[n+1][k+1];
	memset(dp,0,sizeof(dp));
	dp[0][0]=1;
	fo(i,n)
	{
		int cum=0;
		fo(j,a[i]+1)
		{
			cum+=dp[i][j];
			cum%=mod;
			dp[i+1][j]+=cum;
			dp[i+1][j]%=mod;
		}
		for(int j=a[i]+1;j<=k;j++)
		{
			cum-=dp[i][j-a[i]-1];
			cum%=mod;
			cum=(cum+mod)%mod;
			cum+=dp[i][j];
			cum%=mod;
			dp[i+1][j]+=cum;
			dp[i+1][j]%=mod;
		}
	}
	cout<<dp[n][k]<<'\n';
	printclock;
}

Measured memory_bytes: 79232
#include<stdio.h>
#include<math.h>

int main()
{
    int n, i;
    while(scanf("%d", &n)!=EOF){
        printf("%d: ", n);
        for(i=2; i<=sqrt(n); i++){
            if(n%i==0){
                printf("%d ", i);
                n/=i;
                i=1;
            }
        }
        printf("%d\n", n);
    }
    return 0;
}



Measured memory_bytes: 2748
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        int i, n;
        double a, b;

        while(sc.hasNext()){
            n = sc.nextInt();
            if(n==0)break;
            double[] s = new double[n];
            a = 0.0;
            b = 0.0;
            
            for(i=0;i<n;i++){
                s[i] = sc.nextInt();
                a += Math.pow(s[i], 2);
                b += s[i];
            }
            System.out.println(Math.sqrt((a/n)-(Math.pow(b/n,2))));
        }
    }
}


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

#define ll long long
#define INF 99999999
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

template < typename T > std::string to_string( const T& n )
{
    std::ostringstream stm ;
    stm << n ;
    return stm.str() ;
}

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

    vector<int>NEXT;
    rep(i,N)
    {
        if( (A[i]+2)%2 == 0 ) NEXT.push_back(A[i]);
    }
    rep(i,NEXT.size())
    {
        if( (NEXT[i]+3)%3 != 0 && (NEXT[i]+5)%5 != 0 )
        {
            cout << "DENIED" << endl;
            return 0;
        }
    }
    cout << "APPROVED" << endl;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
 
int main() {
	// your code goes here
	int n,a;
	cin>>n;
	a=n%10;
	if(a==2||a==4||a==5||a==7||a==9)
	cout<<"hon";
	else if(a==3)
	cout<<"bon";
	else
	cout<<"pon";
	return 0;
}

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

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

int main() {
	string s;
	cin >> s;
	int count = 0;
	for (int i = 0; i < s.length(); i++) {
		if (s[i] == 'A')count++;
	}
	if (count == 0 || count == 3)cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3544
/*
khoi orz, go check out his algo
-normie-
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int64_t i=0;i < (int64_t)(n);i++)
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#define FILE_IN "robot.inp"
#define FILE_OUT "robot.out"
#define ofile freopen(FILE_IN,"r",stdin);freopen(FILE_OUT,"w",stdout)
#define fio ios::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nfio cin.tie(0);cout.tie(0)
#define max(x,y) (((x)>(y))?(x):(y))
#define min(x,y) (((x)<(y))?(x):(y))
#define ord(a,b,c) ((a>=b)and(b>=c))
#define MOD (ll(1000000007))
#define MAX 300001
#define mag 1048576
#define fi first
#define se second
#define pow2(x) (ll(1)<<x)
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plll pair<ll,pll>
#define For(i,__,___) for(int i=__;i<=___;i++)
#define Rep(i,__,___) for(int i=__;i>=___;i--)
#define ordered_set tree<long long,null_type,less<long long>,rb_tree_tag,tree_order_statistics_node_update>
#define endl "\n"
#define bi BigInt
#define ll long long
#define pi 3.1415926535897
//------START-----------//

int cmp(pll a, pll b)
{
	if (a.fi==0) return (a.se<b.se);
	return int(double(a.se+1)/a.fi<double(b.se+1)/b.fi);
}
//------END-----------//
ll n,m,k,t,t1,i,j,a,b, res=0,resi,resj;
ll dp[200001][41];
vector<pll> st1,st0;
int main()
{
//	ofile;
	fio;
	cin>>n>>t;
	for (i=0;i<n;i++)
	{
		cin>>a>>b;
		if (a==0) st0.push_back({a,b});
		else st1.push_back({a,b});
	}
	sort(st0.begin(),st0.end(),cmp);
//	for (auto g:st0) cout<<g.fi<<' '<<g.se<<endl;
	sort(st1.begin(),st1.end(),cmp);
//	for (auto g:st1) cout<<g.fi<<' '<<g.se<<endl;
	m=st1.size();
	k=ceil(log2(t))+2;
	for (i=1;i<=k;i++) dp[0][i]=1e9+1;
	for (j=1;j<=k;j++) for (i=1;i<=m;i++)
	{
		dp[i][j]=min(dp[i-1][j],(dp[i-1][j-1]+1)*(st1[i-1].fi+1)+st1[i-1].se);
		dp[i][j]=min(dp[i][j],1e9+1);
//		cout<<i<<' '<<j<<' '<<dp[i][j]<<endl;
	}
	for (i=0;i<=k;i++)
	{
		resi=i;
		if (dp[m][i]>t) continue;
		j=-1; resj=dp[m][i];
//		cout<<st0.size()<<' '<<j<<' '<<' '<<(j<int(st0.size())-1);
//		cout<<resj+1+st0[j+1].se<<' '<<(j<st0.size()-1)<<endl;
		while ((j<int(st0.size())-1)and(resj+1+st0[j+1].se<=t))
		{
//			cout<<j<<' '<<resj+1+st0[j+1].se<<endl;
			j++;
			resj+=1+st0[j].se;
//			cout<<(j<int(st0.size())-1)<<endl;
//			cout<<j<<' '<<resj+1+st0[j+1].se<<endl;
		}
		resi+=j+1;
		res=max(res,resi);
	}
	cout<<res;
}

Measured memory_bytes: 67820
def main():
    a = [ list(map(int, input().split())) for _ in range(3) ]
    f = [ [ False ]*3 for _ in range(3) ]
    n = int(input())
    for i in range(n):
        b = int(input())
        for y in range(3):
            for x in range(3):
                if a[y][x] == b:
                    f[y][x] = True

    is_bingo = False
    # 横に揃う
    for y in range(3):
        is_bingo = all(f[y])
        if is_bingo:
            print("Yes")
            return 0
    # 縦に揃う
    for x in range(3):
        t = []
        for y in range(3):
            t.append(f[y][x])
        is_bingo = all(t)
        if is_bingo:
            print("Yes")
            return 0

    # 斜めに揃う
    is_bingo = all( [f[0][0], f[1][1], f[2][2]] )
    if is_bingo:
        print("Yes")
        return 0
    is_bingo = all( [f[0][2], f[1][1], f[2][0]] )
    if is_bingo:
        print("Yes")
        return 0
    print("No")

main()





Measured memory_bytes: 3064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())



void init() {

}

void input() {

}

void solve() {
  int x, y;
  cin >> x >> y;
  cout << x + y/2 << endl;
}

int main() {
	init();
	input();
	solve();
	return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <iostream>

typedef long long LL;

const int MAXN = 1e5;
int n, ecnt, val[MAXN + 5], head[MAXN + 5], d[MAXN + 5];

struct Edge { int to, nxt; } graph[MAXN * 2 + 5];

inline void link ( const int s, const int t ) {
	graph[++ ecnt] = { t, head[s] };
	head[s] = ecnt;
}

inline int DFS ( const int u, const int f ) {
	if ( d[u] == 1 ) return val[u];
	LL sum = 0; int mx = 0;
	for ( int i = head[u], v; i; i = graph[i].nxt ) {
		if ( ( v = graph[i].to ) ^ f ) {
			int up = DFS ( v, u );
			sum += up, mx = std::max ( mx, up );
		}
	}
	if ( sum - val[u] > std::min ( sum >> 1, sum - mx )
		|| 2 * val[u] < sum || sum < val[u] ) puts ( "NO" ), exit ( 0 );
	return 2 * val[u] - sum;
	// a+b=val, 2a+b=sum, a<=min{sum/2,sum-mx}
}

int main () {
	scanf ( "%d", &n );
	for ( int i = 1; i <= n; ++ i ) scanf ( "%d", &val[i] );
	for ( int i = 1, u, v; i < n; ++ i ) {
		scanf ( "%d %d", &u, &v ), ++ d[u], ++ d[v];
		link ( u, v ), link ( v, u );
	}
	if ( n == 2 ) return puts ( val[1] == val[2] ? "YES" : "NO" ), 0;
	for ( int i = 1; i <= n; ++ i )
		if ( d[i] > 1 )
			return puts ( DFS ( i, 0 ) ? "NO" : "YES" ), 0;
	return 0;
}

Measured memory_bytes: 10952
#include<iostream>
#include<algorithm>
#include<queue>
using namespace std;
priority_queue<int>que;
int n,m;
struct tl{
	int t;
	int w;
};
tl x[1234567];
bool cmp(tl a,tl b){
	if(a.t==b.t) return a.w>b.w;
	return a.t<b.t ;
}
//int t[1234567],w[1234567];
int main(){
	cin>>n>>m;
	for(int i=0;i<n;i++){
		cin>>x[i].t>>x[i].w;
	}
	sort(x,x+n,cmp);
	int sum=0;
	int cnt=0;
	for(int i=0;i<m;i++){
//		cout<<x[cnt].t<<"  "<<x[cnt].w<<endl;
		while(x[cnt].t<=i+1&&cnt<=n){
			que.push(x[cnt].w);
//			sum+=x[cnt].w;
//			cout<<"::::"<<x[cnt].t<<"  "<<x[cnt].w<<endl;
			cnt++;
		}
		if(!que.empty()){
			sum+=que.top();
//			cout<<sum<<endl;
			que.pop();
		}
	}
	cout<<sum<<endl;
	return 0;
} 
/*
6 4
1 2
3 3
1 4
2 1
2 3
2 3
*/

Measured memory_bytes: 1660
import java.util.*;

public class Main {

  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] data = new int[n];
    int sum = 0;

    for (int i = 0; i < n; i++) {
      data[i] = sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      data[i] -= sc.nextInt();
    }

    for (int i = 0; i < n; i++) {
      if (data[i] > 0) sum += data[i];
    }

    System.out.println(sum);
  }

}


Measured memory_bytes: 25168
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    char a;
    cin>>a;
    if(a >= 'a') cout<<'a'<<endl;
    else cout<<'A'<<endl;
}

Measured memory_bytes: 3564
n = int(input())
C = input()
a, b = 0, n - 1
cnt = 0
while b - a > 0:
    if C[a] == "W" and C[b] == "R":
        cnt += 1
        a += 1
        b -= 1
    if C[a] == "W" and C[b] == "W":
        b -= 1
    if C[a] == "R" and C[b] == "R":
        a += 1
    if C[a] == "R" and C[b] == "W":
        a += 1
        b -= 1
print(cnt)


Measured memory_bytes: 67872
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<int,int> ii;
typedef tree<ii,null_type,less<ii>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
// *st.find_by_order(index), 0-based
// order_of_key(e)

int main() {
	cin.tie(0); cout.tie(0); ios_base::sync_with_stdio(0);
	ll a,b,c,d; cin>>a>>b>>c>>d;
	cout<<max({a*c,a*d,b*c,b*d})<<"\n";
	return 0;
}

Measured memory_bytes: 3648
from math import gcd
def lcm(a, b):
    return a * b // gcd(a, b)

def lcm_g(A):
    ret = 1
    for a in A:
        ret = lcm(ret, a)
    return ret

def is_hcm(x, A):
    for i in range(N):
        if x % A[i] != A[i] // 2:
            return False
    return True

N, M = [int(x) for x in input().split()]
A = [int(x) for x in input().split()]

l = lcm_g(A)
if is_hcm(l // 2, A):
    ans = (2 * M + l) // (2 * l)
else:
    ans = 0

print(ans)

Measured memory_bytes: 20204
def bi(x, length):
    ret = "".join(["0" for _ in range(length)])
    return (ret + str(bin(x))[2:])[-length:]


def solve(inp):
    l = len(inp) - 1
    tot = 0
    for i in range(2**l):
        binary = bi(i, l)
        expression = "".join([inp[j] + "+" if binary[j] == "1" else inp[j] for j in range(l)] + [inp[-1]])

        tot += sum(int(e) for e in expression.split("+"))
    return tot

inp = input()
print(solve(inp))


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

mx = 0
for i in range(n):
  nxt = (i+1) % n
  dist = a[nxt] - a[i]
  dist = (dist + k) % k
  mx = max(mx, dist)

print(k-mx)

Measured memory_bytes: 26420
N=int(input())
A = list(map(int, input().split()))


prev=A[0]
dai=0
count=0

for i in range(0,len(A)):

    # print(prev - A[i])
    if prev>A[i]:
        # print(prev-A[i])
        # print(i)
        dai=prev-A[i]
        count=count+dai
        A[i]=A[i]+dai
    prev=A[i]
# print(A)

print(count)

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

#define stirng string
#define vvi vector<vector<int>>
#define vi vector<int>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const int inf = 1e9 + 7;

int main() {
  int n;
  long double t, a, h;
  cin >> n >> t >> a;
  long double min = 1000000000;
  int ans = 0;
  long double temp;
  for (int i = 0; i < n; i++) {
    cin >> h;
    temp = t - h * 0.006;
    if ((long double)abs(temp - a) < min) {
      min = (long double)abs(temp - a);
      ans = i + 1;
    }
  }
  cout << ans << endl;
  return 0;
}


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

int main() {
  int N,A,B,P1,P2;
  cin>>N>>A>>B;
  P1=N*A,P2=B;
  if (P1<P2){
    cout<<P1<<endl;
  }
  else{cout<<P2<<endl;}
}


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

int main() {
  int N, M;
  cin >> N >> M;
  
  vector<int> ab(2 * M);
  vector<int> Ni(N + 1);
  
  for (int i = 0; i < 2 * M; i += 2) {
    int a, b;
    cin >> a >> b;
    ab.at(i) = a;
    ab.at(i + 1) =b;
  }
  
  for (int i = 0; i < 2 * M; ++i) {
    Ni.at(ab.at(i)) += 1;  
  }
  
  for (int i = 1; i < N + 1; ++i) cout << Ni.at(i) << endl;
}

Measured memory_bytes: 3572
#include"bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
using namespace __gnu_pbds; 
using namespace std;

#define double long double
#define int long long
#define pb push_back 
#define eb emplace_back
#define Z(c) (int)(c).size()
#define L(c) c[Z(c)-1]
#define F first
#define S second
#define nl "\n"
#define mii map<int,int> 
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define rep(i,iv,n) for(int (i)=(iv);(i)<(n);++(i))
#define FO fflush(stdout) 
#define D1(x) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<nl
#define D2(x,y) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<nl
#define D3(x,y,z) cerr <<"At line "<<__LINE__<<" "<<#x<<"="<<x<<" "<<#y<<"="<<y<<" "<<#z<<"="<<z<<nl
#define tr(it,ct) for(auto &(it) : (ct))
#define pi acos(-1)
#define prt(ct) for(auto &(it) : (ct)) cerr<<it<<" "; cerr<<nl
#define prtp(ct) for(auto &(it) : (ct)) cerr<<it.F<<" "<<it.S<<nl; cerr<<nl

typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair< int,int > pii;
typedef pair<pii,pii> ppp;
typedef vector< pii > vp;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, 
             tree_order_statistics_node_update> baap;

void swap(char &a,char &b)
{ auto tm=a; a=b; b=tm; }

void mina(int &a,int b)
{ a=(a<b?a:b); }

void maxa(int &a,int b)
{ a=(a>b?a:b); }

  const int mod=1000000007;
  const int mod2=998244353;
  const int INF=1e18;
  const int N=3e5+35;
  const int M=1005;
 

 void doit()         
 {
   int x; cin>>x;

   int iv=100,tm=0;
   
   while(iv<x){
     int k=iv/100;
     iv+=k;
      tm++;
   }

   cout<<tm;

 }

signed main()
{ 
   ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

   
   int tc=1;                         
 //   cin>>tc;

  rep(i,1,tc+1)
  { // cout<<"Case #"<<i<<": ";
    
   doit();
   if(i<tc)
   cout<<nl;
  }
  

 return 0; 
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
 
using namespace std;
 
int main(){
    int n;
    cin >> n;
    string s;
    cin >> s;
    long r_num = 0;
    long g_num = 0;
    long b_num = 0;
    for (int i=0; i<n; i++){
        if (s[i]=='R'){
            r_num += 1;
        }
        else if (s[i]=='G'){
            g_num += 1;
        }
        else if (s[i]=='B'){
            b_num += 1;
        }
    }
    long sum = r_num * g_num * b_num;
    for (int i=0; i<n-2; i++){
        for(int j=i+1; j<n-1; j++){
            if (n > 2*j-i){
                if (s[i]!=s[j] && s[j]!=s[2*j-i] && s[i]!=s[2*j-i]){
                    sum -= 1;
                }
            }
        }
    }
    if (n<=3){
        sum = 0;
    }
    cout << sum << endl;
}

Measured memory_bytes: 3572
N = int(input())
Alist = list(map(int, input().split()))

flag = True
count = 0
while flag:
	for i in range(N):
		if Alist[i] % 2 != 0:
			flag = False
			break

	if flag:
		for i in range(N):
			Alist[i] = Alist[i] / 2
		count += 1

print(count)

Measured memory_bytes: 3060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

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

      int[] raw = new int[10];
      for( int i=0; i<10; i++){
        raw[i] = Integer.parseInt(br.readLine());
      }
      int[] result = new int[] {-1,-1,-1};
      int target = -1;
      for(int i=0; i<3; i++) {
        for(int j=0; j<10; j++){
          if(result[i] < raw[j]) {
            result[i] = raw[j];
            target = j;
          }
        }
        raw[target] = -1;
      }

      for(int i=0; i<3; i++)
        System.out.println(result[i]);
    }
  }
}


Measured memory_bytes: 24280
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <iomanip>
using namespace std;

int main()
{
    double a[105];
    int n;
    cin >> n;
    double ans=0;
    for(int i=0;i<n;i++){
        cin >> a[i];
        ans=ans+1.0/a[i];
    }
    cout << fixed << setprecision(6);
    cout << 1.0/ans << endl;
    return 0;
}


Measured memory_bytes: 256
use std::vec::Vec;

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>().split_whitespace().map(|e| e.parse().ok().unwrap()).collect()
}

fn read_touple<T: std::str::FromStr + Copy>() -> (T, T) {
  let v: Vec<T> = read_vec();
  assert_eq!(v.len(), 2);
  (v[0], v[1])
}

fn main() {
  let s: String = read();
  if s == "ABC" {
     println!("ARC");
  } else {
     println!("ABC");
  }
}


Measured memory_bytes: 2032
from math import ceil,floor,factorial,gcd,sqrt,log2,cos,sin,tan,acos,asin,atan,degrees,radians,pi,inf,comb
from itertools import accumulate,groupby,permutations,combinations,product,combinations_with_replacement
from collections import deque,defaultdict,Counter
from bisect import bisect_left,bisect_right
from operator import itemgetter
from heapq import heapify,heappop,heappush
from queue import Queue,LifoQueue,PriorityQueue
from copy import deepcopy
from time import time
from functools import reduce
import string
import sys
sys.setrecursionlimit(10 ** 7)
def input() : return sys.stdin.readline().strip()
def INT()   : return int(input())
def MAP()   : return map(int,input().split())
def LIST()  : return list(MAP())

ans = []

def dfs(m):
    if m == 1:
        ans.append(1)
        return 0
    elif m == 2:
        ans.append(2)
        return 0
    else:
        k = ceil(sqrt(1+8*m))//2
        ans.append(k)
        dfs(m-k)

n = INT()
dfs(n)
for x in ans:
    print(x)

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

#define true 1;
#define false 0;

int main(void){
  int n,cnt,N=123456;
  char is_prime[1000000];
  
  for( int i = 0 ; i <= 2*N ; i++ ) is_prime[i] = true;
  
  is_prime[0] = is_prime[1] = false; 
  
  for( int i = 2 ; i*i <= 2*N ; i++ )
    if( is_prime[i] )
      for( int j = i*2 ; j <= 2*N ; j += i )
	is_prime[j] = false;
  
  while(1){

    cnt = 0;

  cin >> n;
  if( n == 0 ) break;

  for( int i = n + 1 ; i <= 2*n ; i++ ){
    if( is_prime[i] ) cnt++;
}

  cout << cnt << endl;

  }

  return 0;
}

Measured memory_bytes: 1408
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N; cin >> N;
    int A[100010];
    rep(i, N) cin >> A[i];
    int ans = 0;
    map<int, int> mp;
    set<int> st;
    rep(i, N) st.insert(A[i]);
    rep(i, N) mp[A[i]]++;
    for(auto itr = st.begin(); itr != st.end(); itr++) {
        if (mp[*itr] % 2 == 1) ans++;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 9984
object Main extends App {
  import scala.util.matching.Regex

  val keyValPattern: Regex = "([0-9]+)/([0-9]+)/([0-9]+)".r

  val input: String = readLine


  val patternMatch = keyValPattern.findFirstMatchIn(input)
  patternMatch match {
    case Some(m) => println(s"2018/${m.group(2)}/${m.group(3)}")
    case _ => println("error")
  }
}

Measured memory_bytes: 25408
import Control.Monad
import Control.Applicative
solve :: [String] -> [String]
solve ("0":_) = []
solve (n:ss:lines) =
    let n' = read n :: Double in
    let ss' = [read s | s<-words ss] :: [Double] in
    let m = sum ss' / n' in
    let alpha = sqrt (sum [(s - m)^2 | s<-ss'] / n') in
    (show alpha) : solve lines

main =
    mapM_ putStrLn =<< solve . lines <$> getContents

Measured memory_bytes: 5008
import sys
import numpy as np
sys = sys.stdin.buffer.readline
N = int(input())
A = list(map(int, input().split()))

G = []
for i in range(N - 1):
    if A[i] == A[i + 1]:
        s = 'N'
    elif A[i] < A[i + 1]:
        s = 'U'
    else:
        s = 'D'
    G.append(s)
G = np.array(G)
# print(f'{G=}')

if not np.any(G == 'U'):
    print(1000)
    exit()

money = 1000
kabu = 0
for i in range(N - 1):
    if G[i] == 'N':
        continue
    if G[i] == 'U':
        buy_kabu, nokori_money = divmod(money, A[i])
        kabu += buy_kabu
        money = nokori_money
    else:
        money += kabu * A[i]
        kabu = 0
    # print(f'{money=}, {kabu=}')

money += kabu * A[-1]
kabu = 0
# print(f'{money=}, {kabu=}')
print(money)


Measured memory_bytes: 27244
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int row , col;
    cin>>row>>col;

    vector < vector < int > > v ( row , vector < int > ( col , 0 ) );

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

    for ( int i=0 ; i<n ; i++ )
        for ( int j = 0 ; j<col ; j++ ) v[i][j] = 1;

    for ( int i=0 ; i<m ; i++ )
        for ( int j=0 ; j<row ; j++ ) v[j][i] = 1;

    int cnt = 0;
    for ( int i=0 ; i<row ; i++ )
        for ( int j=0 ; j<col ; j++ )
            if ( v[i][j]!=0 ) cnt++;

    /*for ( int i=0 ; i<row ; i++ )
    {
        for ( int j=0 ; j<col ; j++ )
            cout<<v[i][j]<<" ";
        cout<<"\n";
    }*/

    cout<<row*col-cnt<<"\n";
    return 0;


}


Measured memory_bytes: 256
package main

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

// I/O
type Scanner struct {
	sc *bufio.Scanner
}

func NewScanner() *Scanner {
	sc := bufio.NewScanner(os.Stdin)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &Scanner{sc}
}

func (s *Scanner) nextStr() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *Scanner) nextInt() int {
	i, e := strconv.Atoi(s.nextStr())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *Scanner) nextFloat() float64 {
	f, e := strconv.ParseFloat(s.nextStr(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *Scanner) nextRuneSlice() []byte {
	return []byte(s.nextStr())
}

func (s *Scanner) nextIntSlice(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextInt()
	}
	return res
}

func (s *Scanner) nextFloatSlice(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.nextFloat()
	}
	return res
}

type query struct {
	T int
	F int
	C byte
}

func calc(qq []query) ([]byte, []byte, bool) {
	head := true
	left := make([]byte, 0)
	right := make([]byte, 0)
	for _, que := range qq {
		if que.T == 1 {
			head = !head
		} else {
			if (head && que.F == 1) || (!head && que.F == 2) {
				left = append(left, que.C)
			} else {
				right = append(right, que.C)
			}
		}
	}
	return left, right, head
}

func run(input io.Reader, output io.Writer) int {
	sc := NewScanner()
	s := sc.nextStr()
	q := sc.nextInt()
	var qq []query
	for i := 0; i < q; i++ {
		t := sc.nextInt()
		var f int
		var c byte
		if t != 1 {
			f = sc.nextInt()
			c = sc.nextRuneSlice()[0]
		}
		qq = append(qq, query{T: t, F: f, C: c})
	}

	left, right, head := calc(qq)

	if head {
		for i := len(left) - 1; i >= 0; i-- {
			fmt.Printf("%c", left[i])
		}
		fmt.Print(s)
		for i := 0; i < len(right); i++ {
			fmt.Printf("%c", right[i])
		}
		fmt.Println()
	} else {
		for i := len(right) - 1; i >= 0; i-- {
			fmt.Printf("%c", right[i])
		}
		for i := len(s) - 1; i >= 0; i-- {
			fmt.Printf("%c", s[i])
		}
		for i := 0; i < len(left); i++ {
			fmt.Printf("%c", left[i])
		}
		fmt.Println()
	}
	return 0
}

func main() {
	os.Exit(run(os.Stdin, os.Stdout))
}


Measured memory_bytes: 23680
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
typedef long long ll;
const int N=1e6+4;
bool vis[N];
int prime[N],tot;
ll a,b;
ll gcd(ll a,ll b) {
	return b?gcd(b,a%b):a;
}
inline void linear_shaker(int n) {
	vis[1]=true;
	for (register int i=2;i<=n;++i) {
		if (!vis[i]) prime[++tot]=i;
		for (int j=1;j<=tot&&i*prime[j]<=n;++j) {
			vis[i*prime[j]]=true;
			if (i%prime[j]==0) break;
		}
	}
}
int ans=1;
int main() {
	scanf("%lld%lld",&a,&b);
	ll d=gcd(a,b);
	linear_shaker(1e6);
	for (register int i=1;i<=tot;++i) {
		if (d%prime[i]==0) ++ans;
		while (d%prime[i]==0) d/=prime[i];
	}
	if (d>1) ++ans;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3328
n = gets.chomp.to_i
a = [0] + gets.chomp.split(" ").map{|x| x.to_i} + [0]
sum = 0
for i in 0..n do
  sum += (a[i] - a[i+1]).abs
end

for i in 1..n do
  if (a[i]-a[i-1])*(a[i+1]-a[i]) < 0
    print "#{sum - (a[i]-a[i-1]).abs - (a[i+1]-a[i]).abs + (a[i+1]-a[i-1]).abs}\n"
  else
    print "#{sum}\n"
  end
end

Measured memory_bytes: 12940
N,X,Y=map(int,input().split())
c=[[1]]+[[i-1,i+1] for i in range(1,N-1)]+[[N-2]]
c[X-1].append(Y-1)
c[Y-1].append(X-1)
from collections import deque
q=deque()
a=[0]*(N-1)
for i in range(N):
    d=[-1]*N
    d[i]=0
    q.append(i)
    while q:
        p=q.popleft()
        for n in c[p]:
            if d[n]<0:
                q.append(n)
                d[n]=d[p]+1
                a[d[p]]+=1
print(*[i//2 for i in a],sep='\n')

Measured memory_bytes: 81500
#include <bits/stdc++.h>
#include<cmath>
#define N 100005
#define A 1000005
#define MOD 998244353 //1000000007 // //100000000
#define INF 1000000000000000000
#define ll long long
//#define M_PI 3.141592653589793238463

using namespace std;

#define pii pair<ll, ll>
#define piii pair<ll, pii>
#define ft first
#define sd second
#define pb push_back
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repr(i, n) for(ll i = n-1; i >= 0; i--)
#define itr(it, x) for(auto it = x.begin(); it != x.end(); it++)
#define mem(a, b) memset(a, (ll)b, sizeof(a))
#define all(v) v.begin(), v.end()
#define allr(v) v.rbegin(), v.rend()
#define edge(v, x, y) v[x].pb(y); v[y].pb(x);
#define popcount __builtin_popcount
#define ANS(s) {cout << s << "\n"; return;}

//~~~~~~fancy print~~~~~~~//
#define printpii(a) cout << a.ft << " " << a.sd << endl;
#define printpiii(a) cout << a.ft << " " << a.sd.ft << " " << a.sd.sd << endl;
#define print(a, n) rep(i, n) cout << a[i] << " "; cout << endl;
#define printv(v) for(auto x: v)cout << x << " "; cout << endl;
#define printm(a, n, m) rep(i, n) { rep(j, m) cout << a[i][j] << "\t"; cout << endl;}

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

void fast(){ios_base::sync_with_stdio(false);cin.tie(0);cout << setprecision(12) << fixed;}


void solve(){
    ll n, m;
    cin >> n >> m;
    ll l = 1, r = n;
    rep(i, m)
    {
        ll x, y;
        cin >> x >> y;
        l = max(l, x);
        r = min(r, y);
    }
    cout << max(0ll, (r-l+1));
}
main(){
    fast();
    ll t = 1; //cin >> t;
    while(t--){
        solve();
    }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
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; }
int main(){
    cout << fixed << setprecision(10);
    ll a,b;
    cin >> a >> b;
    //cout << "input" << endl;
    if(a > 0){
        cout << "Positive" << endl;
        return 0;
    }
    if(a <= 0 && 0 <= b){
        cout << "Zero" << endl;
        return 0;
    }
    // a < 0 && b < 0
    if((b - a + 1)%2 == 0) cout << "Positive" << endl;
    else cout << "Negative" << endl;

    return 0;
}

Measured memory_bytes: 3620
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int r = sc.nextInt();

		sc.close();

		out.println(3 * r * r);

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}
}


Measured memory_bytes: 21844
N = int(input())
a = list(map(int, input().split()))

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

# memo[0]: 1の箱
# memo[N]: N+1の箱
memo = [0] * N
answer = [0] * N
for i in range(N - 1, -1, -1):
    # print(i, a[i], memo[i])
    answer[i] = (a[i] + memo[i]) % 2
    if answer[i] == 1:
        for divisor in make_divisors(i+1):
            memo[divisor - 1] += 1

print(sum(answer))
# print(answer)
print(' '.join([str(i+1) for i, x in enumerate(answer) if x == 1]))

Measured memory_bytes: 72296
#include <cstdio>
#include <iostream>
#include <string>
#include <vector>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <typeinfo>
#include <numeric>
#include <functional>
#include <unordered_map>
#include <bitset>
#include <stack>
#include <assert.h>
#include <unordered_set>
#include <random>


using namespace std;
using ll = long long;
using ull = unsigned long long;

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


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
























int main(){
    ll n;
    cin >> n;
    vector<ll> a(n);
    REP(i, n){
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<ll>());
    ll ans = a[0];
    ll m = n - 2;
    for(ll i = 1; i < n; i++){
        if(m == 0) break;
        if(m >= 2){
            ans += a[i] * 2;
            m -= 2;
        }
        else{
            ans += a[i];
            m--;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 4756
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

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

typedef long long lint;

using namespace std;

int main(){
  int s;
  cin>>s;
  int a,b;
  a=s/100;
  b=s%100;
  if(a==0)a=13;
  if(b==0)b=13;
  if(a>12 and b>12)cout<<"NA"<<endl;
  else if(a>12)cout<<"YYMM"<<endl;
  else if(b>12)cout<<"MMYY"<<endl;
  else cout<<"AMBIGUOUS"<<endl;
  return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    
    vector<int> h(n, 0);
    rep(i, n)cin >> h[i];
    
    vector<queue<int>> dict(n);
    
    vector<int> a(m, 0), b(m, 0);
    rep(i, m){
        cin >> a[i] >> b[i];
        dict[a[i]-1].push(b[i]-1);
        dict[b[i]-1].push(a[i]-1);
    }
    
    
    int ans = 0;
    rep(i, n){
        if(dict[i].size()==0){
            ans++;
        }else{
            bool flg = true;
            while(!dict[i].empty()){
                int x = dict[i].front();
                dict[i].pop();
                if(h[i]<=h[x])flg=false;
            }
            if(flg)ans++;
        }
    }
    
    cout << ans << endl;
}

Measured memory_bytes: 71740
=begin
1
 セント, 
5
 セント, 
10
 セント, 
25
 セント硬貨を使って 
n
 セント分のお釣りを作ります。
=end

a = gets.to_i

k = 0

[25, 10, 5, 1].each do |x|
    k += a / x
    a %= x
end

print k, "\n"



Measured memory_bytes: 8908
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vint;
typedef pair<int,int> pint;
typedef vector<pint> vpint;
#define rep(i,n) for(int i=0;i<(n);i++)
#define REP(i,n) for(int i=n-1;i>=(0);i--)
#define reps(i,f,n) for(int i=(f);i<(n);i++)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define all(v) (v).begin(),(v).end()
#define eall(v) unique(all(v), v.end())
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define chmax(a, b) a = (((a)<(b)) ? (b) : (a))
#define chmin(a, b) a = (((a)>(b)) ? (b) : (a))
const int MOD = 1e9 + 7;
const int INF = 1e9;

ll N, A, B;

bool solve(ll x, vector<ll> &v){
	// printf("x %lld\n", x);
	ll cnt = 0;
	ll C = A - B;
	for(auto u : v) {
		ll d = u - x * B;
		// printf("u %lld d %lld\n", u, d);
		if(d <= 0) continue;
		ll k = d / C + (d % C ? 1 : 0);
		// printf("%lld\n", k);
		cnt += k;
	}
	if(cnt <= x) return true;
	else return false;
}

int main(void) {
	cin >> N >> A >> B;
	vector<ll> h(N);
	rep(i, N){
		cin >> h[i];
	}

	ll l = -1, r = INF;
	while(r - l > 1) {
		ll m = (l + r) / 2;
		if(solve(m, h)) r = m;
		else l = m;
	}
	printf("%lld\n", r);
	return 0;
}

Measured memory_bytes: 1024
N, K = map(int, input().split(' '))
A = list(map(int, input().split(' ')))
bucket = {}
for ai in A:
    if bucket.get(ai) == None:
        bucket[ai] = 1
    else:
        bucket[ai] += 1
if len(bucket) <= K:
    print(0)
else:
    bucket_sorted = sorted(bucket.items(), key=lambda x:x[1], reverse=True)
    ans = 0
    for k, v in bucket_sorted[K:]:
        ans += v
    print(ans)

Measured memory_bytes: 38964
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define lundi ios_base::sync_with_stdio(false); cin.tie(NULL);

int diff(string a, string b){
    int df = 0;
    for(int i=0;i<a.size();i++){
        if(a[i] != b[i]) df++;
    }
    return df;
}

void solve(){
    string a, b;
    cin>>a>>b;
    int n = a.size();
    int m = b.size();
    int ans = m;
    for(int i=0;i<=n-m;i++){
        ans = min(ans, diff(a.substr(i, m), b));
    }
    cout<<ans<<endl;
}

signed main(){
    // lundi;
    int t=1;
    // cin>>t;
    while(t--) solve();
}

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

long long np[60][2][2];
long long num[60];

main()
{
	int n,p;
	scanf("%d %d",&n,&p);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&num[i]);
	}
	np[0][0][0]=1;
	np[0][1][num[0]%2]=1;
	for(int i=1;i<n;i++)
	{
		if(num[i]%2==0)
		{
			//see before
			for(int j=0;j<2;j++)
			{
				for(int k=0;k<2;k++)
				{
					if(np[i-1][j][k]==0)
					{
						//printf("d\n");
						continue;
					}
					//not use
					np[i][0][k]+=np[i-1][j][k];
					//use
					np[i][1][k]+=np[i-1][j][k];
				}
			}
		}
		else
		{
			//see before
			for(int j=0;j<2;j++)
			{
				for(int k=0;k<2;k++)
				{
					if(np[i-1][j][k]==0)
					{
						//printf("d\n");
						continue;
					}
					//not use
					np[i][0][k]+=np[i-1][j][k];
					//use
					np[i][1][(k+1)%2]+=np[i-1][j][k];
				}
			}
		}
	}/*
	for(int i=0;i<n;i++)
	{
		for(int j=0;j<2;j++)
		{
			for(int k=0;k<2;k++)
			{
				printf("%lld ",np[i][j][k]);
			}
		}
		printf("\n");
	}*/
	printf("%lld",np[n-1][0][p]+np[n-1][1][p]);
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <queue>

#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <functional>
#include <iterator>

using namespace std;

#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define INF (1<<30)
#define ALEN(ARR) (sizeof(ARR) / sizeof((ARR)[0]))
#define MP make_pair
#define mp make_pair
#define pb push_back
#define PB push_back

#if DEBUG
#define _DEBUG(x) cout<<#x<<": "<<x<<endl
#define _DDEBUG(x,y) cout<<#x<<": "<<x<<", "<<#y<<": "<<y<<endl
#else
#define _DEBUG(x) ;
#define _DDEBUG(x,y) ;
#endif

#define ll long long
#define ull unsigned long long
#define MOD 1000000007

/** FOR VECTOR DEBUG */
template <typename T>
ostream& operator<< (ostream& out, const vector<T>& v) {
    if ( !v.empty() ) {
        out << '[';
        copy (v.begin(), v.end(), ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}

/* template end */

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

    ll m, k;
    cin >> m >> k;
    ll p2m = pow(2, m);

    if(m <= 1) {
        if(k == 0) {
            cout << (m == 0 ? "0 0" : "0 0 1 1") << endl;
        } else {
            cout << -1 << endl;
        }
        return 0;
    }

    if(k >= pow(2, m)) {
        cout << -1 << endl;
        return 0;
    }

    vector<ll> b(p2m);
    vector<ll> c(p2m);
    for(ll i = 0; i < p2m; i++) {
        b[i] = i;
        c[p2m - i - 1] = i;
    }
    b.erase(b.begin() + k);
    c.erase(c.begin() + (p2m - k - 1));
    
    vector<ll> ans(p2m * 2);
    ll idx = 0;
    for(auto bi : b) { ans[idx] = bi; idx++; }
    ans[idx++] = k;
    for(auto ci : c) { ans[idx] = ci; idx++; }
    ans[idx++] = k;

    for(int i = 0; i < idx; i++) {
        cout << ans[i] << (i != idx - 1 ? ' ' : '\n');
    }  

    return 0;
}



Measured memory_bytes: 5888
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep2(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep_inv(i, n, m) for(int i = (int)(n); i > (int)(m); i--)
using namespace std;
using ll = long long;
using vl = vector<ll>;
using vc = vector<char>;
using vvl = vector<vl>;
using vvc = vector<vc>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;

int main(){
  ll M;
  cin >> M;

  cout << (24 - M) + 24 << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
long long n,k;
long long a[1100];
vector<long long>PS;
int countMask(int a) {
   int ret = 0;
   for (int x : PS) {
      if ((x & a) == a) {
         ret++;
      }
   }
   return ret;
}
      
    
main(){
  cin>>n>>k;
  for(int i=0; i<n; i++){
    cin>>a[i];
  }
  for(int i=0; i<n; i++){
    long long sum=0;
    for(int j=i; j<n; j++){
      sum+=a[j];
      PS.push_back(sum);
    }
  }
  long long mask=0;
  for(int i=40; i>=0; i--){
    if(countMask(mask | (1LL<<i))>=k){
      mask |= (1LL<<i);
    }
  }
  
  cout<<mask<<endl;
  return 0;
}
  
      
  
  


Measured memory_bytes: 6512
N = int(input())
A = list(map(int, input().split()))

nums = [0]*10**5
for a in A:
  nums[a] += 1
num2 = [0]*10**5
num2[0] = nums[0]+nums[1]
num2[-1] = nums[-1]+nums[-2]
for i in range(1,10**5-1):
  num2[i] = nums[i-1]+nums[i]+nums[i+1]
print(max(num2))

Measured memory_bytes: 13964