akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
using ll = long long;
using u64 = uint_fast64_t;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007;
//constexpr long long MOD = 998244353;
template<class T1, class T2> inline bool chmax(T1 &a, T2 b) { if (a < b) { a = b; return true;} return false; }
template<class T1, class T2> inline bool chmin(T1 &a, T2 b) { if (a > b) { a = b; return true;} return false; }
inline int popcount(int x) {return __builtin_popcount(x);}
inline int popcount(long long x) {return __builtin_popcountll(x);}
void print() { cout << "\n"; }
template<class T, class... Args>
void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
///////////////////////////////////////////////////////////////////////////////////////////////////////////////

const int COL = 64;
template<int MAX_COL>
struct BitMatrix {
    int N;
    vector<bitset<MAX_COL>> A;
    BitMatrix(int N) : N(N),A(N) {}

    int GaussJordan() {
        int rank = 0;
        for (int col = 0; col < MAX_COL; ++col) {
            int pivot = -1;
            for (int row = rank; row < N; ++row) {
                if (A[row][col]) {
                    pivot = row;
                    break;
                }
            }
            if (pivot == -1) continue;
            swap(A[pivot], A[rank]);
            for (int row = 0; row < N; ++row) {
                if (row != rank && A[row][col]) A[row] ^= A[rank];
            }
            ++rank;
        }
        return rank;
    }
};

using BM = BitMatrix<COL>; 

void solve() {
    int N; cin >> N;
    vector<u64> A(N);
    rep(i,N) cin >> A[i];
    reverse(all(A));
    string S; cin >> S;
    reverse(all(S));
    BM mat(N);
    rep(i,N) {
        if (S[i]=='1') {
            int MAX = mat.GaussJordan();
            int rank = 0;
            rep(bit,COL) {
                if ((A[i]>>bit)&1) {
                    while (rank < MAX) {
                        if (mat.A[rank][bit]) {
                            rep(j,COL) {
                                if (mat.A[rank][j]) A[i] ^= (1ull<<j);
                            }
                            rank++;
                            break;
                        }
                        rank++;
                    }
                }
            }
            if (A[i]) {
                cout << 1 << ln;
                return;
            }
        } else {
            rep(bit,COL) {
                if ((A[i]>>bit)&1) {
                    mat.A[i][bit] = 1;
                }
            }
        }
    }

    cout << 0 << ln;
}

int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    int Q; cin >> Q;
    while (Q--) {
        solve();
    }
}

Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
  int n,s[100],i,j,b,g=0;
  scanf("%d",&n);
  for (i=0;i<n;i++){
    scanf("%d",&s[i]);
    g+=s[i];
  }
  if (g%10){
    printf("%d\n",g);
    return 0;
  }
  for (i=0;i<n-1;i++){
    for (j=i+1;j<n;j++){
      if (s[i]>s[j]){
        b=s[i];
        s[i]=s[j];
        s[j]=b;
      }
    }
  }
  i=0;
  while ((g-s[i])%10==0&&i<n) i++;
  printf("%d\n",(i==n)? 0:g-s[i]);
  return 0;
}

Measured memory_bytes: 128
N, K = map(int, input().split())

if K%2 == 1:
  cand = N // K
  ans = cand\
      + cand * (cand-1) * 3\
      + cand * (cand-1) * (cand-2)
  print(int(ans))
else:
  cand_mod0 = N // K
  ans_mod0 = cand_mod0\
           + cand_mod0 * (cand_mod0-1) * 3\
           + cand_mod0 * (cand_mod0-1) * (cand_mod0-2)
  cand_modhalf = N // K if N % K < K / 2 else (N // K) + 1
  ans_modhalf = cand_modhalf\
           + cand_modhalf * (cand_modhalf-1) * 3\
           + cand_modhalf * (cand_modhalf-1) * (cand_modhalf-2)
  print(int(ans_mod0 + ans_modhalf))

Measured memory_bytes: 3064
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    if (a * b % 2 == 0) {
      System.out.println("Even");
    } else {
      System.out.println("Odd");
    }
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include <cmath>
#include <limits>
#include <utility>
#include <map>
#include <iomanip>
#include <queue>
#include <cctype>
#include <stack>
#include<set>


#define rep(i,p,q) for(ll i = p;i < q;++i)
#define ll long long

using namespace std;

const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll npk(ll n, ll k) {
	ll ret = 1;
	if (n < k || n < 0)return 0;
	rep(i, 0, k) {
		ret *= (n - i);
		ret %= MOD;
	}
	if (ret < 0) ret = 0;
	return ret;
}

//136A
int main(void) {
	ll a, b;
	cin >> a >> b;
	ll ans = max(a + b, a - b);
	cout << max(ans, a * b) << endl;
}

Measured memory_bytes: 256
def readinput():
    k=int(input())
    return k

def main(k):
    amari=[0]*k
    r=0
    count=0
    for i in range(1,k+1):
        count+=1
        r=(10*r+7)%k
        if r==0:
            return count
        if amari[r]>0:
            return -1
        amari[r]+=1
    return -1

if __name__=='__main__':
    k=readinput()
    ans=main(k)
    print(ans)


Measured memory_bytes: 16780
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vl = vector<ll>;

ll gcd(ll b, ll c){
    return c ? gcd(c, b % c) : b;
}

int main(){
    int N;
    cin >> N;
    vl A(N);
    for(int i = 0; i < N; i++){
        cin >> A.at(i);
    }
    ll a;
    for(int i = 0; i < N - 1; i++){
        if(i == 0){
            a = gcd(A.at(i), A.at(i + 1));
        }
        else{
            a = gcd(a, A.at(i + 1));
        }
    }
    cout << a << endl;
    return 0;
}

Measured memory_bytes: 1024
MOD=10**9+7

S=input()
N=len(S)
dp=[[0 for _ in range(13)] for _ in range(N)]
if S[0]=="?":
    for k in range(10):
        dp[0][k]=1
else:
    dp[0][int(S[0])]=1
for i in range(N-1):
    c=S[i+1]
    nums=[]
    if c=="?":
        nums=[i for i in range(10)]
    else:
        nums=[int(c)]
    for num in nums:
        for j in range(13):
            dp[i+1][(10*j+num)%13]+=dp[i][j]%MOD
print(dp[-1][5]%MOD)


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

int main(){
    int a, b;
    cin >> a >> b;
    int ans = 0;
    for(int i = a; i <= b; i++){
        int ii = i;
        int i1 = ii % 10;
        ii /= 10;
        int i2 = ii % 10;
        ii /= 100;
        if(ii % 10 != i2) continue;
        ii /= 10;
        if(ii % 10 == i1) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include <stdio.h>
#include <stdlib.h>

int compare(const void *a,const void *b){
  return *(int *)a - *(int *)b;
}

int main(){
  int n;
  scanf("%d",&n);
  int a[1000000];
  for(int i=0;i<n;i++){
    scanf("%d",a+i);
  }
  qsort(a,n,sizeof(int),compare);
  int j,k;
  int count;
  int answer;
  for(j=a[1] ; j > 0 ; j--){
    count = 0;
    for(k=0;k<n;k++){
      if(a[k] % j != 0){
        count += 1;
      }
    }
    if(count <= 1){
      answer = j;
      break;
    }
  }
  printf("%d\n",answer);
  return 0;
}

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

#define ll long long
using namespace std;

const int _M=1e5+40;

ll a[_M],t[_M],ans[_M],k=0;

struct
{
    int x,y;
} e[_M];

int fd(int x)
{
    return x==a[x]?x:a[x]=fd(a[x]);//记得要压缩路径
}

int main()
{
    int n,m;
    scanf("%d%d",&n,&m);
    for(int i=1; i<=n; i++)a[i]=i,t[i]=1;
    for(int i=1; i<=m; i++)
        scanf("%d%d",&e[i].x,&e[i].y);
    ll an=(ll)n*(ll)(n-1)/2;   //当将int类型的变量运算后赋值给long long 类型的变量是记得要强转
    ans[k++]=an;
    for(int i=m; i>=1; i--)
    {
        int ra=fd(e[i].x),rb=fd(e[i].y);
        if(ra!=rb)
        {
            an-=((ll)t[ra]*(ll)t[rb]);
            t[ra]+=t[rb];
            a[rb]=ra;
        }
        ans[k++]=an;
    }
    k-=2;
    while(k>=0)
       cout<<ans[k--]<<endl;
    return 0;
}






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

int main(){
  int n;

  while(cin >> n){
    if(n == 0){
      break;
    }

    char t[n];
    int id[n], win[n], lose[n];

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

      win[i] = 0;
      lose[i] = 0;

      for(int j = 0; j < n - 1; j++){
        int x;
        cin >> x;

        if(x == 0) win[i]++;
        else if(x == 1) lose[i]++;
      }
    }

    for(int i = 0; i < n; i++){
      for(int j = i + 1; j < n; j++){
        if(win[i] < win[j] ||
           win[i] == win[j] && lose[i] > lose[j] ||
           win[i] == win[j] && lose[i] == lose[j] && id[i] > id[j]){
          swap(id[i], id[j]);
          swap(t[i], t[j]);
          swap(win[i], win[j]);
          swap(lose[i], lose[j]);
        }
      }
    }

    for(int i = 0; i < n; i++){
      cout << t[i] << endl;
    }
  }
}

Measured memory_bytes: 1152
import java.util.Arrays;
import java.util.Comparator;
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner scanner = new Scanner(System.in);

    int N = scanner.nextInt();
    Block[] blocks = new Block[N];
    for (int i = 0; i < N; i++) {
      blocks[i] = new Block(scanner.nextInt(), scanner.nextInt(), scanner.nextInt());
    }

    Arrays.sort(blocks, Comparator.comparingInt(b -> b.s + b.w));

    final int MAX_W = 20_000;
    long[][] dp = new long[N + 1][MAX_W + 1];
    for (int i = 1; i <= N; i++) {
      Block b = blocks[i - 1];
      for (int j = 0; j <= MAX_W; j++) {
        if (j >= b.w && j - b.w <= b.s) {
          dp[i][j] = Math.max(dp[i - 1][j - b.w] + b.v, dp[i - 1][j]);
        } else {
          dp[i][j] = dp[i - 1][j];
        }
      }
    }

    long max = 0;
    for (int i = 0; i <= MAX_W; i++) {
      max = Math.max(max, dp[N][i]);
    }
    System.out.println(max);
  }

  private static class Block {
    public final int w;
    public final int s;
    public final int v;

    private Block(int w, int s, int v) {
      this.w = w;
      this.s = s;
      this.v = v;
    }
  }
}


Measured memory_bytes: 250924
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i,n) for(int i=0; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
int main()
{
    int n,h,max=0,ans=0;
    cin>>n;
    rep(i,n){
        cin>>h;
        if(max>h){
           ans=-1;
           break;
        }else if(max<h){
            h--;
        }
        max=h;
    }
    if(ans==0) cout << "Yes";
    else cout<<"No";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
using namespace std;
signed main(){
  string S,T="";
  cin>>S;
  S+="B";
  int N=S.size(),ans=0;
  for(int i=0,j=0;i<N;i++){
    if(S[i]=='A')
      T+='0';
    else if(i<N-1 && S.substr(i,2)=="BC")
      T+='1',i++;
    else{
      int n=0;
      for(char c:T){
        if(c=='1')
          ans+=n;
        else
          n++;
      }
      T="";
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3928
package main

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

var scanner = bufio.NewScanner(os.Stdin)
const INF = 0x7fffffff
func main() {
	scanner.Scan()
	n, _ := strconv.Atoi(scanner.Text())
	top := make([]int, 0)
	bottom := make([]int, 0)
	for i := 0; i < n; i++ {
		scanner.Scan()
		buf := strings.Split(scanner.Text(), " ")
		a, _ := strconv.Atoi(buf[0])
		b, _ := strconv.Atoi(buf[1])
		top = append(top, a)
		bottom = append(bottom, b)
	}
	dp := make([][]int, n+1)
	for i := range dp {
		dp[i] = make([]int, n+1)
	}
	for i := 0; i < n; i++ {
		for j := 0; j < n; j++ {
			dp[i][j] = INF
		}
	}
	for j := 0; j < n; j++ {
		dp[0][j] = 0
	}
	for i := 1; i < n; i++ {
		for j := 0; j < n-i; j++ {
			tmp := make([]int, 0)
			for k := 0; k < i; k++ {
				tmp = append(tmp, dp[k][j] + dp[i - k - 1][j + k + 1] +top[j] * bottom[j + k] * top[j + k + 1] * bottom[j + i])
			}
			sort.Ints(tmp)
			dp[i][j] = tmp[0]
		}
	}
	fmt.Println(dp[n-1][0])
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}


Measured memory_bytes: 2948
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
template <typename T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template <typename T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
#define MOD 1000000007LL

int main(){
  ll H, W, K;
  cin >> H >> W >> K;

  vll count1(W-1, 0); //count1.at(i)...i~i+1に線があるとき
  vll count2(W, 0); //count2.at(i)...i番目の左右に線がないとき(i-1~i, i~i+1)
  for(int tmp = 0; tmp < (1 << (W-1)); tmp++){
    //1が隣あってないか
    bool ok = true;
    for(int i = 0; i < W-2; i++){
      if((tmp >> i) & (tmp >> (i+1))){
        ok = false;
        break;
      }
    }
    if(!ok) continue;

    for(int i = 0; i < W-1; i++){
      if((tmp >> i) & 1) count1.at(i)++;
    }

    for(int i = 0; i < W; i++){
      bool flag = true;
      if(i > 0){
        if((tmp >> (i-1)) & 1) flag = false; 
      }
      if(i < W-1){
        if((tmp >> i) & 1) flag = false;
      }
      if(flag) count2.at(i)++;
    }
  }

  vvll dp(H+2, vll(W, 0));
  dp.at(1).at(0) = 1;
  for(int i = 2; i < H+2; i++){
    for(int j = 0; j < W; j++){
      if(j > 0) dp.at(i).at(j) += dp.at(i-1).at(j-1) * count1.at(j-1) % MOD;
      dp.at(i).at(j) %= MOD;
      dp.at(i).at(j) += dp.at(i-1).at(j) * count2.at(j) % MOD;
      dp.at(i).at(j) %= MOD;
      if(j < W-1) dp.at(i).at(j) += dp.at(i-1).at(j+1) * count1.at(j) % MOD;
      dp.at(i).at(j) %= MOD;
    }
  }
  cout << dp.at(H+1).at(K-1) << endl;
}

Measured memory_bytes: 256
// <------------- Template -----------------------> //


#include<bits/stdc++.h>
using namespace std;

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(0);	
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll ,ll> 			pll;
typedef pair<ld,ld> 			pld;
typedef unordered_map<ll,ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5+7;
const ll 	MAX7 	= 	1e+7+7;
const ll 	MAXN 	= 	2 * 1e18;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9+7;

vll adj[200];ll visit[300]={};

// <------------- Declare Variables Here ------------> //

ll t=1;
ll n,x,y,q;
string s;


// <------------- Implement Functions Here ----------> //



// <------------- Start of main() -------------------> //

void MAIN() {
	ll n,d,x;
	cin >> n >> d >> x;

	for(ll i=0;i<n;i++) {
		cin>>y;
		q = 0;
		while(q*y + 1 <= d) x++,q++;
	}
	cout<<x;
}

int main() {
	fastio;randomINT;
	//cin>>t;
	while(t--) {
		MAIN();
	}
	return 0;
}


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

int main() {
  int n;
  long int a[1010];
  string s = "APPROVED";

  cin >> n;

  for ( int i=0 ; i < n ; ++i ) {
    cin >> a[i];
    if (a[i] % 2 == 0 ) {
      if (!((a[i] % 3 == 0 ) || (a[i] % 5 == 0)))
      s = "DENIED";
    }
  // cout << n << i << a[i] << s << endl;
  }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <stdarg.h>
#include <stdio.h>
#include <stdlib.h>

int dp[100010], M, k[100010]={0};
int **G;

int max(int len, ...) {
    int i, _max, num;
    va_list ap;
    va_start(ap, len);

    _max = va_arg(ap, int);
    for (i = 1; i < len; i++) {
        num = va_arg(ap, int);
        if (num > _max)
            _max = num;
    }
    va_end(ap);
    return _max;
}

int rec(int v) {
    int i, res;
    if (dp[v] != -1) return dp[v]; // 既に更新済み

    res = 0;
    for (i=0;i<k[v];i++) {
        int nv = G[v][i];
        res = max(2,res, rec(nv) + 1);
    }
    return dp[v] = res; // メモしながらリターン
}

int main(void) {
    int i, N, res, x, y;
    scanf("%d%d", &N, &M);
    G = (int **)malloc(sizeof(int *)*N);
    for (i=0;i<N;i++) {
        G[i] = (int *)malloc(sizeof(int)*M);
    }

    for (i=0;i<M;i++) {
        scanf("%d%d", &x, &y);
        x--; y--;
        G[x][k[x]++] = y;
    }

    for (i=0;i<N;i++) dp[i] = -1;
    res = 0;
    for (i=0;i<N;i++) res = max(2,res,rec(i));
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 404352
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x) x
#define rep(...) MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c) c.begin(),c.end()
#define mp make_pair
#define write(x) cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
template<class T, class U>bool chmax(T& a, U&& b) { return a < b ? a = b, 1 : 0; }
template<class T, class U>bool chmin(T& a, U&& b) { return b < a ? a = b, 1 : 0; }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

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

    rep(i, S.size()) {
        if (i % 2 == 0) {
            if (S[i] == 'R' || S[i] == 'U' || S[i] == 'D') {

            }
            else {
                write("No");
                return 0;
            }
        }
        else {
            if (S[i] == 'L' || S[i] == 'U' || S[i] == 'D') {
            
            }
            else {
                write("No");
                return 0;
            }
        }
    }

    write("Yes");
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = 0
Sum = sum(a)
for i in range(n):
  Sum = Sum- a[i]
  ans = ans  + a[i] * Sum
if ans > 10 ** 9:
  ans = ans % (10 **9 + 7)
print(ans)

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

int main(){
	int N, i;
	scanf("%d", &N);
	vector<int> a(N);
	for(i = 0; i < N; i++){
		scanf("%d", &a[i]);
	}
	sort(a.begin(), a.end());
	int f = 1;
	for(i = 0; i < N; i++){
		if(a[i] != 0){
			f = 0;
		}
	}
	if(f == 1){
		printf("Yes\n");
		return 0;
	}
	if(N % 3 != 0){
		printf("No\n");
		return 0;
	}
	int k = N / 3;
	if(a[0] != a[k - 1] || a[k] != a[2 * k - 1] || a[2 * k] != a[3 * k - 1]){
		printf("No\n");
		return 0;
	}
	int x = a[0], y = a[k], z = a[2 * k];
	if((x ^ y) == z || (y ^ z) == x || (z ^ x) == y){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main(){
    int64_t x;
    cin >> x;

    bool tyokin=true;
    int nen=0;int64_t hyaku=100;
    while(tyokin){
        hyaku = hyaku + hyaku*0.01;
        nen +=1;
        if(hyaku >= x){
            cout << nen <<endl;
            tyokin = false;
        }
    }
}

Measured memory_bytes: 3652
import java.util.Scanner;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Iterator;
import java.util.Collections;
import java.util.Comparator;

class Main{
        public static void main(String args[]){
                Scanner scan = new Scanner(System.in);
                int N;
                N = scan.nextInt();
                ArrayList<Integer> a = new ArrayList<Integer>();
                for(int i=0; i<N; i++)a.add(scan.nextInt());

                Collections.sort(a);
                //check(a);
                double max = (double)a.get(N-1);
                //System.out.println("max = "+max);
                double harfMax = max / 2;
                //System.out.println("harfMax = "+harfMax);

                double r_ = max,r = a.get(0);
                for(int i=0; i<N-1; i++){
                        if(r_ > Math.abs((double)a.get(i) - harfMax)){
                                r_ = Math.abs((double)a.get(i) - harfMax);
                                r = a.get(i);
                        }
                }
                System.out.print((int)max+" "+(int)r);
        }

        public static void check(ArrayList<Integer> a){
                System.out.print("sorting ->");
                for(int i=0; i<a.size(); i++)System.out.print(a.get(i)+" ");
                System.out.print(" ");
        }
}


Measured memory_bytes: 58900
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
using P = pair<ll,ll>;
const ll mod = 1e9+7;
#define ALL(x) (x).begin(),(x).end()
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)
#define REPS(i,n) for(ll (i)=1;(i)<=(n);(i)++)
#define RREP(i,n) for(ll (i)=(n-1);(i)>=0;(i)--)
#define RREPS(i,n) for(ll (i)=(n);(i)>0;(i)--)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());

template<class T> inline void chmin(T& a, T b){
    if (a > b){
        a = b;
    }
}

template<class T> inline void chmax(T& a, T b){
    if (a < b){
        a = b;
    }
}

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<fixed<<setprecision(12);
    ll N;
    cin >> N;
    ll maisuu = (N + 999)/1000;
    cout << maisuu * 1000 - N << "\n";
}

Measured memory_bytes: 3632
def solve(S):
    if len(S) == 1:
        return 0

    j = 0
    ans = 0
    for i in range(0, len(S)):
        if S[i] == "W":
            ans += (i - j)
            j += 1
    return ans


if __name__ == "__main__":
    print(solve(input()))


Measured memory_bytes: 3500
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/detail/standard_policies.hpp>
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
using namespace std;
using namespace __gnu_pbds;
using ll = int64_t;
using ld = long double;
using ull = uint64_t;
using pl = pair<ll, ll>;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

ll n, k, amax;

vector<ll> a;

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

int main() {
  ios::sync_with_stdio(0);
  cout.precision(10);

  cin >> n >> k;
  a.resize(n);
 
 for (int i = 0; i < n; i++) {
   cin >> a[i];
   amax = max(amax, a[i]);
 }
 if (k > amax) {
   cout << "IMPOSSIBLE" << endl;
   exit(0);
 }

 ll cur = a[0];
 for (int i = 1; i < n; i++) {
   cur = gcd(cur, a[i]);
 }

 if (k % cur != 0) {
   cout << "IM";
 }
  cout << "POSSIBLE" << endl;
}

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

colors = [0]*9
for a in A:
    colors[min(8, a//400)] += 1
ansmin = 0
for c in colors[:-1]:
    if c:
        ansmin += 1
x = 0
if ansmin < colors[-1]:
    x = 1
print("{} {}".format(max(ansmin, x), ansmin+colors[-1]))

Measured memory_bytes: 3064
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));
#include<math.h>
#include<limits.h>
#include<iostream>
#include<string>
#include<vector>
#include<stdio.h>
#include<sstream>
#include<list>
#include<queue>
#include<algorithm>
#include<functional>
#include<map>
#include<set>
#include<utility>
#include<initializer_list>
#include<tuple>
#include<regex>
using namespace std;
#define ull unsigned long long
#define ll long long
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(t) t.begin(), t.end()
#define mat(type, row, col, init) vector<vector<type>>(row, vector<type>(col, init));

int main() {
	string a, b;
	cin >> a >> b;
	if (a.length() < b.length()) {
		cout << "LESS";
	}
	else if (a.length() > b.length()) {
		cout << "GREATER";
	}
	else {
		int n = a.length();
		rep(i, n) {
			if (a[i] == b[i]) continue;
			else {
				if (a[i] < b[i]) {
					cout << "LESS";
					return 0;
				}
				else {
					cout << "GREATER";
					return 0;
				}
			}

		}
		cout << "EQUAL";
	}

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for (ll i=0; i<(ll)(n); i++)
#define repd(i,n) for (ll i=n-1; i>=0; i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define PF push_front
#define PB push_back

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    vector<int> ans;
    rep(i,n){
        cin >> a.at(i);
    }
    list<int> b;
    if(n%2==0){
        for(int i=0; i<n-1; i+=2){
            b.PB(a.at(i));
            b.PF(a.at(i+1));
        }
    }
    if(n%2==1){
        for(int i=0; i<n; i++){
            if(i%2==0){
                b.PF(a.at(i));
            }
            else{
                b.PB(a.at(i));
            }
        }
    }
    for(auto i=b.begin(); i!=b.end(); i++){
        cout << *(i) << " ";
    }
    cout << endl;
}

Measured memory_bytes: 9216
#include <bits/stdc++.h>
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll D, G; cin >> D >> G;
  vector<ll> p(D, 0);
  vector<ll> c(D, 0);
  REP(i, D){
    cin >> p[i] >> c[i];
  }
  ll ans = 10000;
  REP(i, 1<<D){
    ll tmp = 0, cnt = 0, idx = -1;
    REP(j, D){
      if((i >> j) & 1){
        tmp += (j+1)*100*p[j] + c[j];
        cnt += p[j];
      }else{
        idx = j;
      }
    }
    if(tmp >= G){
      ans = min(ans, cnt);
    }else{
      if(idx == -1) continue;
      REP(k, p[idx]){
        tmp += (idx+1)*100;
        cnt++;
        if(tmp >= G){
          ans = min(ans, cnt);
          break;
        }
      }
    }
  }
  cout << ans << endl;
}

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

int main() {
    int N = 0;
    int total = 0, max = 0, tmp;
    scanf("%d", &N);
    for (int n = 0; n < N; n++) {
        tmp = 0;
        scanf("%d", &tmp);
        total += tmp;
        if (tmp >= max) {
            max = tmp;
        }
    }
    printf("%d", total - max / 2);
    return 0;
}

Measured memory_bytes: 128
def solve():
    n = int(input())
    p = list(map(int, input().split()))
    cost = 0
    for i in range(n-1):
        if p[i] != i+1:
            cost += 1
    if cost <= 2:
        print("YES")
    else:
        print("NO")
    return 0

if __name__ == '__main__':
    solve()

Measured memory_bytes: 8880
#include <iostream>
using namespace std;
#include<string.h>
#include<set>
#include<stdio.h>
#include<math.h>
#include<queue>
#include<map>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cstring>
#include <cstdio>
#include <cstdlib>
#include<stack>
#include<vector>
int main()
{
    char a[10],b[10];
    cin>>a>>b;
    if(a[0]>b[0])
        cout<<">"<<endl;
    else if(a[0]==b[0])
        cout<<"="<<endl;
    else
        cout<<"<"<<endl;
    return 0;
}


Measured memory_bytes: 764
import sys
sys.setrecursionlimit(10**7)
n = int(input())
to = [[] for _ in range(n)]
for _ in range(n - 1):
    u, v, w = map(int, input().split())
    u -= 1
    v -= 1
    to[u].append((v, w))
    to[v].append((u, w))
ans = [-1] * n
def dfs(u=0, c=0, parent=-1):
    ans[u] = c
    for v, w in to[u]:
        if v == parent:
            continue
        dfs(v, (c + w) & 1, u)

dfs()
print(*ans, sep='\n')


Measured memory_bytes: 88752
n = int(input())
s = [input() for i in range(n)]

# 辞書作成
s_dict = dict()
for i in s:
    if i not in s_dict:
        s_dict[i] = 1
    else:
        s_dict[i] += 1

m = max(s_dict.values())
ans = []
for k, v in s_dict.items():
    if v == m:
        ans.append(k)
ans.sort()
# ソート
print(*ans, sep="\n")


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

using VI = vector<int>;
using VVI = vector<VI>;
using PII = pair<int, int>;
using LL = long long;
using VL = vector<LL>;
using VVL = vector<VL>;
using PLL = pair<LL, LL>;
using VS = vector<string>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))

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

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;

LL dp[1000010];
LL acc[1000010];

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

  LL N; cin >> N;
  dp[N] = acc[N] = N;
  dp[N-1] = N * N % MOD;
  acc[N-1] = (dp[N-1] + dp[N]) % MOD;
  for(int i=N-2;i>=1;--i){
	(dp[i] = (N-1)*(N-i-2)%MOD + N*(i+1)%MOD + acc[i+1] + MOD - dp[i+2]) %= MOD;
	(acc[i] = acc[i+1] + dp[i]) %= MOD;
  }
  cout << dp[1] << endl;

  return 0;
}


Measured memory_bytes: 15872
wordinput = list(input())
text = ""
for i in range(len(wordinput)) :
    if wordinput[i] == "0" :
        text += "0"
    elif wordinput[i] == "1" :
        text += "1"
    elif wordinput[i] == "B" :
        text = text[:-1]
print(text)

Measured memory_bytes: 3060
import math

N = int(input())

for l in range(N):
    s = input()
    hh = int(s[0:2])
    mm = int(s[3:5])

    deg2 = 6 * mm
    deg1 = 30 * hh + deg2 / 12

    #print(deg1, deg2)
    d = abs(deg1-deg2)
    if d < 30 or 330 < d:
        print("alert")
    elif 90 <= d and d <= 270:
        print("safe")
    else:
        print("warning")



Measured memory_bytes: 5652
#include<iostream>
#include<cmath>
#include<cstring>
#include<algorithm> 
using namespace std;
int main()
{	
	int r2,r,sum,m[1000],i;
	cin>>r2>>r;
	sum=r2;
		int k=0;
		while(sum)
		{
		 	m[k]=sum%r;
		 	k++;
		 	sum=sum/r;
		}
		//for(i=k-1;i>=0;i--)
		//	printf("%d",m[i]);
		cout<<k;
 } 

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

using namespace std;

int main() {
int n, k, q;
cin >> n >> k >> q;
int arr[n];
for(int i = 0; i < n; i++){
	arr[i] = k;
}
for(int i = 0 ; i < q; i++){
	int a;
	cin >> a;
	arr[a - 1]++;
}



for(int i = 0; i < n; i++){
	if((arr[i] - q) <= 0){
		cout << "No" << endl;
	} else {
		cout << "Yes" << endl;
	}
}
}

Measured memory_bytes: 4032
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,m,count=0,b;
  string u[300],t[300];
  int a[300];
  cin >> n;
  for(int i=0; i<n; i++) cin >> u[i];
  cin >> m;
  for(int i=0; i<m; i++) cin >> t[i];
     
  b=0;
  for(int i=0; i<m; i++){
    for(int j=0; j<n; j++){
      if(t[i]==u[j]){
        a[b] = 1;
        break;
      }
      else a[b] = 0;
    }
    b++;
  }
  //for(int i=0; i<m; i++) cout << a[i] << " ";
  for(int i=0; i<m; i++){
    if(a[i]==1){
      if(count==0){
        cout << "Opened by " << t[i] << endl;
        count = 1;
        }
        else if(count==1){
        cout << "Closed by " << t[i] << endl;
        count = 0;
        }
      }
    else cout << "Unknown " << t[i] << endl;
  }
  return 0;
}


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

int main(void)
{
	int n;
	cin >> n;
	vector<int> a(n);
	for (int i = 0; i < n; i++)
		cin >> a[i];
	sort(a.begin(), a.end());
	cout << a.back() - a.front() << endl;
	return 0;
}


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

struct llist{
	int key;
	llist* prev,* next;
};

llist* first;

void init(){
	first=(llist*)malloc(sizeof(llist));
	first->prev=first;
	first->next=first;
}

void lldelete(llist* ptr){
	if(ptr==first)return;
	ptr->prev->next=ptr->next;
	ptr->next->prev=ptr->prev;
	free(ptr);
}

void deleteFirst(){
	lldelete(first->next);
}

void deleteLast(){
	lldelete(first->prev);
}

void deletekey(int key){
	llist* ptr=first->next;
	while(ptr->key!=key&&ptr!=first)
		ptr=ptr->next;
	lldelete(ptr);
}

void insert(int key){
	llist* newll=(llist*)malloc(sizeof(llist));
	newll->key=key;
	newll->next=first->next;
	first->next->prev=newll;
	first->next=newll;
	newll->prev=first;
}

void printList(){
	llist* cur=first->next;
	int isf=0;
	while(true){
		if(cur==first)break;
		if(isf++>0)printf(" ");
		printf("%d",cur->key);
		cur=cur->next;
	}
	printf("\n");
}

int main(){
	int key,n,i;
	int size=0;
	char com[20];
	int np=0,nd=0;
	scanf("%d",&n);
	init();
	for(i=0;i<n;++i){
		scanf("%s%d",com,&key);
		if(com[0]=='i'){insert(key);++np;++size;}
		else if(com[0]=='d'){
			if(strlen(com)>6){
				if(com[6]=='F')deleteFirst();
				else if(com[6]=='L')deleteLast();
			}else{
				deletekey(key);++nd;
			}
		}
		--size;
	}
	printList();
	return 0;
}


Measured memory_bytes: 34408
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	vector<string> a(3);
	rep(i,3) cin >> a.at(i);
	string s="";
	rep(i,3) s+=a.at(i).at(0);
	cout << s << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n,k; cin >> n >> k;
    ll ret = 0;
    ll t;
    if(k % 2){
        t = n / k;
        ret = t*t*t;
    }
    else {
        t = n / (k / 2);
        ll odd = (t+1)/2;
        ll even = t/2;
        ret = odd * odd * odd + even * even * even;
        
    }
    cout << ret << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cmath>
#include <random>
#include <ctime>
#include <sstream>
#include <numeric>
#include <queue>
using namespace std;

int main(){
    int n,k ;
    cin >> n >> k;
    vector<int> h(n) ;
    for (size_t i = 0; i < n; i++)
    {
        cin >> h.at(i) ;
    }
    sort(h.begin(),h.end()) ;
    int ans = 1000000000 ;
    for (size_t i = 0; i < n-k+1; i++)
    {
        if (h.at(i + k -1) - h.at(i) < ans )
        {
            ans = h.at(i + k -1) - h.at(i) ;
        }
        
    }
    cout << ans << endl ;
}

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

int main() {
	int N;
	vector<int> intArray;
	cin >> N;
	for (int i = 0; i < N; i++)
	{
		int temp;
		cin >> temp;
		intArray.emplace_back(temp);

	}
	sort(intArray.begin() , intArray.end());
	cout << intArray[intArray.size()-1] - intArray[0]  << endl;
	

}


Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;

int main()
{
	int n, m, x, a[102], cost1 = 0, cost2 = 0;

	cin >> n >> m >> x;



	for (int i = 0; i < m; i++) {
		cin >> a[i];
		if (a[i] < x)
			cost1++;
		else if (a[i] > x)
			cost2++;
	}

	if (cost1 > cost2)
		cout << cost2 << endl;
	else
		cout << cost1 << endl;

	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#define MOD 1000000007
using namespace std;
typedef long long ll;

int main(){

int a,b,c,d,sum;

cin >> a;
cin>> b;
cin >> c;
cin >> d;

if(a > b) sum += b;
else sum += a;

if(c > d) sum += d;
else sum += c;

cout << sum << endl;

return 0;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define ll long long
#define pb push_back
#define st first
#define N 200005
#define nd second
#define ii pair<int,int>
#define fr freopen("input.txt","r",stdin);freopen("output.txt","w",stdout);

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	string s;
	//fr
	cin>>s;
	int ans=0;
	for(int i=0;i<s.length()/2;i++){
		if(s[i]!=s[s.length()-i-1]) ans++;
	}
	cout<<ans;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
typedef long long ll;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

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

    for(int i = 0; i < N - 3; i++) {
        if(s[i] == s[i + 2]) {
            cout << i + 1 << " " << i + 3 << endl;
            return 0;
        }
    }

    cout << -1 << " " << -1 << endl;
    return 0;
}

Measured memory_bytes: 512
#pragma GCC optimize("O3")
//#pragma GCC target("avx2")
//#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

template <typename T>
void print(T x) {
    cout << x << "\n";
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REVFOR(i, m, n) for (int i = (n - 1); i >= (m); --i)
#define REP(i, n) FOR(i, 0, n)
#define REVREP(i, n) REVFOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);

    string s;
    cin >> s;

    int ans = 0;
    REP(i, s.size()) ans += s[i] == '1';

    print(ans);
}

Measured memory_bytes: 3620
#XORはビットごとに独立しているので各ビットで0*1の演算回数を数える
n=int(input())
A=list(map(int,input().split()))
B=[0]*62 #1の個数カウント
mod=10**9+7

for i in range(n):
    a=bin(A[i])
    for j in range(len(a)-2):
        if a[-j-1]=="1":
            B[-j-1]+=1

ans=0
cnt=1 #2の累乗管理
for b in range(len(B)):
    prd=B[-b-1]*(n-B[-b-1])
    ans+=prd*cnt%mod
    cnt*=2
    ans%=mod
    cnt%=mod
print(ans)

Measured memory_bytes: 122808
#!usr/bin/env python3
import sys
import math
import string
import collections
import fractions
import random
from operator import itemgetter
import itertools
from collections import deque
import copy
import heapq
import bisect

MOD = 10 ** 9 + 7
INF = float('inf')
input = lambda: sys.stdin.readline().strip()

sys.setrecursionlimit(10 ** 8)

N = int(input())
ans = 0
for i in range(1, N+1):
    if i%3 != 0 and i%5 != 0:
       ans += i
print(ans)

Measured memory_bytes: 10932
// Problem : C - Half and Half
// Contest : AtCoder - AtCoder Beginner Contest 095
// URL : https://atcoder.jp/contests/abc095/tasks/arc096_a?lang=en
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=1;i<=(int)n;i++)
#define REP(i,n) for(int i=0;i<(int)n;i++)
#define ll long long
#define mod 1000000007
int lcm(int x,int y){
	return x/__gcd(x,y)*y;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int cost1=a*x+b*y;
    int cost2=0;
    if(x<y){
    	cost2=min(c*2*x+(y-x)*b,y*c*2);
    }else{
    	cost2=min(c*2*y+(x-y)*a,x*c*2);
    }
    cout<<min(cost1,cost2)<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define MAX_N 7500000
using namespace std;
int main()
{
    int m,n;
    while(cin >> m >> n, m | n)
    {
        vector<bool> A(MAX_N + 10, 0);
        int cnt = 0;
        for(int i=m; cnt < n; i++)
        {
            if(A[i])
                continue;
            cnt++;
            for(int j=i; j<MAX_N; j+=i)
            {
                A[j] = true;
            }
        }
        for(int i=m; i<MAX_N; i++)
        {
            if(A[i]) 
                continue;
            cout << i << endl;
            break;
        }
    }
    return 0;
}


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

int main(){
    string s = "abcdefghijklmnopqrstuvwxyz";
    int i;
    char a,b;

    cin >> a;

    for(i=0;i<25;i++){
        if(s.at(i) == a){
            b = s.at(i+1);
        }
    }
    if(a == s.at(25)){
        b = s.at(0);
    }



    cout << b << endl;

}

Measured memory_bytes: 256
def p_factors(n):
    if n < 2:
        return []
    
    d = 2
    result = []
    while n > 1 and d*d <= n:
        if n % d == 0:
            result.append(d)
        while n % d == 0:
            n //= d
        d += 1
        
    if n > 1:
        # n is a prime
        result.append(n)
    return result

def sieve_of_eratosthenes(ub):
    # O(n loglog n) implementation.
    # returns prime numbers <= ub.
    if ub < 2:
        return []
    prime = [True]*(ub+1)
    prime[0] = False
    prime[1] = False
    p = 2
    while p*p <= ub:
        if prime[p]:
            # don't need to check p+1 ~ p^2-1 (they've already been checked).
            for i in range(p*p, ub+1, p):
                prime[i] = False
        p += 1
    return [i for i in range(ub+1) if prime[i]]

def gcd(a, b):
    if a < b:
        a, b = b, a
    while b:
        a, b = b, a%b
    return a

def gcd_list(lst):
    if len(lst) == 0:
        return 0
    if len(lst) == 1:
        return lst[0]
    g = abs(lst[0])
    for l in lst[1:]:
        g = gcd(g, abs(l))
    return g

N = int(input())
A = [int(input()) for _ in range(N+1)]

cands = set(sieve_of_eratosthenes(N) + p_factors(gcd_list(A)))
answer = []
A = list(reversed(A))

for p in cands:
    flag = True
    # f(x) = Q(x) (x^p - x) + \sum_{i = 0}^{p-2} h_i x^i (mod p), 
    # where h_i = \sum_{j < N, j % (p-1) = i} a_j
    if A[0] % p != 0:
        flag = False
    else:
        for i in range(1, min(N, p-1) + 1):
            h = 0  
            j = i
            while j <= N:
                h = (h + A[j]) % p
                j += p - 1
            if h != 0:
                flag = False
                break
                
    if flag:
        answer.append(p)

if answer:
    answer = sorted(answer)
print(*answer, sep='\n')

Measured memory_bytes: 3572
class Dice:
    def __init__(self, data):
        self.data = data
    
    def move(self, direction):
        if direction == 'E':
            self.data[0], self.data[3], self.data[5], self.data[2] = \
                self.data[3], self.data[5], self.data[2], self.data[0]
        elif direction == 'N':
            self.data[0], self.data[4], self.data[5], self.data[1] = \
                self.data[1], self.data[0], self.data[4], self.data[5]
        elif direction == 'S':
            self.data[0], self.data[1], self.data[5], self.data[4] = \
                self.data[4], self.data[0], self.data[1], self.data[5]
        elif direction == 'W':
            self.data[0], self.data[2], self.data[5], self.data[3] = \
                self.data[2], self.data[5], self.data[3], self.data[0]
        elif direction == 'R':
            self.data[1], self.data[2], self.data[4], self.data[3] = \
                self.data[3], self.data[1], self.data[2], self.data[4]
        elif direction == 'L':
            self.data[1], self.data[2], self.data[4], self.data[3] = \
                self.data[2], self.data[4], self.data[3], self.data[1]

    def moveTopTo(self, target):
        for a in range(4):
            if self.data[0] == target:
                break
            self.move('W')
        if self.data[4] == target:
            self.move('S')
        elif self.data[1] == target:
            self.move('N')
    
    def moveFrontTo(self, target):
        for a in range(4):
            if self.data[1] == target:
                break
            self.move('R')

    def getTop(self):
        return self.data[0]
    
    def getRight(self):
        return self.data[2]

dice = Dice(input().split())
c = int(input())

for a in range(c):
    (t, f) = input().split()
    dice.moveTopTo(t)
    dice.moveFrontTo(f)
    print(dice.getRight())

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




int main(){
  int n;
  cin>>n;
  long long sum=0;
  vector<long long>b;
  for(int i=0;i<n;i++){
    long long a;
    cin>>a;
    b.push_back(a);
    sum+=a;
  }
  long long sum2=0;
  long long ans2=1000000000000000000;
  for(int i=0;i<n-1;i++){
    sum2+=b.at(i);
    sum-=b.at(i);
    ans2=min(ans2,abs(sum2-sum));
  }
  cout <<ans2;
}

Measured memory_bytes: 2420