akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
using namespace std;
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false);cin.tie(nullptr);
#endif

#define int long long
#define FILE_IO freopen("input.txt","r",stdin)/#define int long long
#define f first
#define s second
#define endl '\n'
#define all(c) c.begin(),c.end()
#define bp __builtin_popcount
#define debug(x) cerr << #x << " = " << x << endl;

const int MOD = 1e9 + 7;
const int INF = 1000000000;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
template <typename T>void print(T t){for(auto &it : t)cout<<it<<" ";}
inline int powerexp(int a, int b, int m = MOD){ int res = 1;while(b){if(b&1)res = res * a % m;a = a * a % m,b >>= 1;}return res % m;}
inline int modinv(int a){ return powerexp(a,MOD-2,MOD);}
inline int lcm(int a, int b){ int g = __gcd(a,b);return a/g*b;}
inline int add(int x, int y){ x += y; if (x >= MOD) x -=  MOD; return x;}
inline int mul(int x, int y){ return (x * 1ll * y) % MOD;}
inline int sub(int x, int y){ x -= y; if (x<0) x += MOD; return x ;}

//-------------------< start here >-------------------------// 

void solve(){
   string s;
   cin >> s;
   int n = (int)s.length();
   int left[n], right[n], cnt[n];
   for(int i = 0; i < n; i++) cnt[i] = 0;
   for(int i = 0; i < n; i++){
	   if (i == 0){
		   if (s[i] == 'R') left[i] = i;
		   else left[i] = -1;  
		 }
	   else{
		   if (s[i] == 'R') left[i] = i;
		   else left[i] = left[i - 1];
		  } 
	 }
   for(int i = n - 1; i >= 0; i--){
	   if (i + 1 == n){
		    if (s[i] == 'L') right[i] = i;
		    else right[i] = -1; 
		  }
	    else{
		  if (s[i] == 'L') right[i] = i;
		  else right[i] = right[ i + 1];	
		}  
	 }
   for(int i = 0; i < n; i++){
	    if (s[i] == 'R'){
		  if (right[i] == -1) cnt[n - 1]++;
		  else{
			 if ((right[i] - i - 1) % 2 == 0) cnt[right[i] - 1]++;
			 else cnt[right[i]]++; 
			}	
	    }
	    else{
		  if (left[i] == -1) cnt[0]++;
		  else{
		  if ((i - left[i] -1 )	% 2 == 0) cnt[left[i] + 1]++;
		  else cnt[left[i]]++;
		}
	   }
	 }
	 for(int i = 0; i < n; i++) cout << cnt[i] << " ";
 }

//-----------------------------
//comment from here for TOPCODER 
int32_t main(){
   IOS;
   solve();
   //find();
   #ifdef LOCAL_DEFINE
   cerr << "time elapsed " << (double)clock()/CLOCKS_PER_SEC << endl;
   #endif
}


Measured memory_bytes: 3024
/************************************
 *	AUTHOR: 		Divyansh Gaba	*
 *	INSTITUTION: 	ASET, BIJWASAN	*
 ************************************/
#include<bits/stdc++.h>
#define fast ios_base::sync_with_stdio(0); cin.tie(0);
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define REP(i,a,b) for (int i = a; i <= b; i++)


using namespace std;

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


int main()
{
    fast;
    int n,k;
    cin>>n>>k;
    int a[n];
    int ind = -1;
    for(int i = 0;i<n;i++)
        cin>>a[i],ind = a[i]==1?i:ind;
    int ans = 0;
    int extra = 0;
    int i = ind;
    while(i<n-1)
    {
        i+=(k-1);
        ans++;

    }
    extra = (i - n + 1);
    i = ind - extra;
    while(i>0)
    {
        i-=(k-1);
        ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#pragma GCC optimize("O3")

#include <iostream>
#include <algorithm>

using namespace std;

const int N = 18;

int mx[2][1 << N];

void upd(int m, int x) {
	if (mx[0][m] < x) {
		mx[1][m] = mx[0][m];
		mx[0][m] = x;
	}
	else if (mx[1][m] < x) {
		mx[1][m] = x;
	}
}

int main() {
	ios_base::sync_with_stdio(false);
	int n;
	cin >> n;
	for (int i = 0; i < (1 << n); i++) {
		cin >> mx[0][i];
	}
	for (int i = 0; i < n; i++) {
		for (int m = 0; m < (1 << n); m++) {
			if (m >> i & 1) {
				upd(m, mx[0][m ^ (1 << i)]);
				upd(m, mx[1][m ^ (1 << i)]);
			}
		}
	}
	int cur = 0;
	for (int i = 1; i < (1 << n); i++) {
		cur = max(cur, mx[0][i] + mx[1][i]);
		cout << cur << ' ';
	}
}


Measured memory_bytes: 5716
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef double D;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
 
#define rd(x) scanf("%d",&x)
#define rd2(x,y) scanf("%d %d",&x,&y)
#define rl(x) scanf("%lld",&x)
#define rl2(x,y) scanf("%lld %lld",&x,&y)
#define wd(x) printf("%d" ,x)
#define wd2(x,y) printf("%d %d",x,y)
#define wl(x) printf("%lld",x)
#define wl2(x,y) printf("%lld %lld",x,y)
#define PC(x) putchar(x)
#define GC() getchar()
#define NL printf("\n")
#define SP printf(" ")
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define F first
#define S second
#define MP make_pair
#define PB push_back

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL)
#define fr(i,s,e) for(int i=s;i<e;i++)
#define frl(i,s,e) for(ll i=s;i<e;i++)
#define frr(i,s,e) for(int i=s-1;i>=e;i--)
#define frv(i,a) for(int i = 0;i<(int)a.size();i++)
#define frvr(i,a) for(int i = a.size()-1;i>=0;i--)
#define tr(i,a) for(typeof(a.begin()) i = a.begin(); i != a.end();i++)

#define mod 1000000007
#define maxn 100009
#define maxr 100009
int main(){
	//std::ios::sync_with_stdio(false); cin.tie(NULL);
	int n,x;
	rd(n);
	if(n%2==1)
		x=n+1;
	else
		x=n;
	double ans=(double)x/(double)2;
	// if(n%2==1)
	// 	ans+=(double)1;
	//ans=ans/(double)n;
	cout<<setprecision(20)<<(double)ans/(double)(n);
	cout<<endl;
	//wd(ans);
	//NL;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		MyInt mi = new MyInt();

		String longA = mi.makeString(a, b);
		String longB = mi.makeString(b, a);

		if (longA.compareTo(longB) > 0) System.out.println(longB);
		else System.out.println(longA);

		scan.close();
	}
}

class MyInt {
	String makeString(int a, int b) {
		String ans = new String();
		for (int i = 0; i < b; i++)
			ans += a;
		return ans;
	}
}

Measured memory_bytes: 23764
#include <iostream>

int main() {
    std::string s;
    std::cin >> s;
    int red_count = 0;
    int blue_count = 0;
    int ans;
    for (int i = 0; i < s.size(); i++) {
        if (s[i] == '0')
            red_count++;
        else
            blue_count++;
    }
    if (red_count == 0 || blue_count == 0) {
        ans = 0;
    }
    else {
        ans = (red_count < blue_count) ? red_count : blue_count;
    }
    std::cout << ans * 2 << std::endl;
}


Measured memory_bytes: 512
import sys

input = sys.stdin.readline

def main():
    ans = 0
    n, m = map(int, input().split())
    all = []
    for i in range(n):
        all.append(list(map(int, input().split())))
    all.sort()
    for a,b in all:
        if m >= b:
            m -= b
            ans += a*b
        else:
            ans += a*(m)
            break
    print(ans)

if __name__ == '__main__':
    main()

Measured memory_bytes: 27520
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }

constexpr char KURO = '#';
constexpr char SHIRO = '.';

struct Tmp
{
public:
  int H, W;
  vector<vector<char>> table;
  using P = pair<int, int>;
  P nextShiroNuruPos;
  P nextKuroNuruPos;
  Tmp(int H, int W);
  void doKuro();
  void doShiro();
};

Tmp::Tmp(int H = 100, int W = 100)
  : H(H)
  , W(W)
  , table(H, vector<char>(W))
  , nextShiroNuruPos(0, 1)
  , nextKuroNuruPos(H-1, 1)
{
  for (int i = 0; i <= H/2; ++i) {
    for (auto& c : table[i]) {
      c = KURO;
    }
  }
  for (int i = H/2+1; i < H; ++i) {
    for (auto& c : table[i]) {
      c = SHIRO;
    }
  }
}

void Tmp::doKuro()
{
  auto& p = nextKuroNuruPos;
  table[p.first][p.second] = KURO;
  p.second += 2;
  if (p.second >= W) {
    p.first -= 2;
    p.second = 1;
  }
  nextKuroNuruPos = p;
  return;
}

void Tmp::doShiro()
{
  auto& p = nextShiroNuruPos;
  table[p.first][p.second] = SHIRO;
  p.second += 2;
  if (p.second >= W) {
    p.first += 2;
    p.second = 1;
  }
  nextShiroNuruPos = p;
  return;
}

void solve(void)
{
  int A, B; cin >> A >> B;
  Tmp t{50, 100};
  for (int _ = 0; _ < A-1; ++_) {
    t.doShiro();
  }
  for (int _ = 0; _ < B-1; ++_) {
    t.doKuro();
  }

  cout << t.H << SPACE << t.W << CRLF;
  for (const auto& row : t.table) {
    for (const auto& c : row) {
      cout << c;
    }
    cout << CRLF;
  }
  return;
}

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

  solve();

  return 0;
}


Measured memory_bytes: 256
package main

import (
    "fmt"
    "os"
    "bufio"
    "strconv"
    // "sort"
)
var sc = bufio.NewScanner(os.Stdin)


func main() {
    sc.Split(bufio.ScanWords)
    // code goes here
    a,_,_,_,e,k := nextInt(),nextInt(),nextInt(),nextInt(),nextInt(),nextInt()
    
    if e-a > k{
        fmt.Println(":(")
    } else {
        fmt.Println("Yay!")
    }
}



func nextInt() int {
    sc.Scan()
    v, e := strconv.Atoi(sc.Text())
    if e != nil { panic(e) }
    return v
}
func nextInt64() int64 {
    sc.Scan()
    v, e := strconv.ParseInt(sc.Text(), 10, 64)
    if e != nil { panic(e) }
    return v
}
func nextString() string {
    sc.Scan()
    return sc.Text()
}
func nextFloat() float64 {
    sc.Scan()
    v, e := strconv.ParseFloat(sc.Text(), 64)
    if e != nil { panic(e) }
    return v
}
func Max(x, y int) int { if x > y { return x }; return y }
func Min(x, y int) int { if x < y { return x }; return y }
func Abs(x int) int { if x > 0 { return x }; return -x }



Measured memory_bytes: 640
n = int(input())
a = list()
for i in range(n):
	x, y = input().split()
	y = int(y)
	if x == "S":
		a.append(y + 0)
	if x == "H":
		a.append(y + 13)
	if x == "C":
		a.append(y + 26)
	if x == "D":
		a.append(y + 39)
for i in range(1, 53):
	if not (i in a):
		if i <= 13:
			print("S {}".format(i - 0))
		elif i <= 26:
			print("H {}".format(i - 13))
		elif i <= 39:
			print("C {}".format(i - 26))
		else:
			print("D {}".format(i - 39))




Measured memory_bytes: 5592
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

int main() {
    long long L, R;
    cin >> L >> R;
    long long base = 2019;
    long long ll = L % base;
    long long rr = R % base;
    if(ll >= rr) {
        rr += base;
    }
    if(R - L >= 2019) {
        cout << 0 << endl;
        return 0;
    }
    // cout << l << r << endl;
    long long tmp = INF;
    for(int i = ll; i <= rr; i++) {
        for(int j = i + 1; j <= rr; j++) {
            long long p = (i * j) % base;
            if(tmp > p) {
                // cout << i << j << endl;
                tmp = p;
            }
        }
    }

    cout << tmp << endl;
    return 0;
}

Measured memory_bytes: 256
#!/usr/bin/env python3

import sys
import math
from bisect import bisect_right as br
from bisect import bisect_left as bl
sys.setrecursionlimit(2147483647)
from heapq import heappush, heappop,heappushpop
from collections import defaultdict
from itertools import accumulate
from collections import Counter
from collections import deque
from operator import itemgetter
from itertools import permutations
mod = 10**9 + 7
inf = float('inf')
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))

n = I()
ans = 1
for i in range(1,n+1):
    ans *= i
    ans %= mod
print(ans)

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

using namespace std;

#define uint unsigned int
#define llong long long int
#define ullong unsigned long long int
#define rep(i, n) for (int i = 0; i < n; ++i)

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, k;
    cin >> n >> k;
    vector<llong> X;
    rep(i, n) {
        llong x;
        cin >> x;
        X.push_back(x);
    }

    llong ans = 1e10;
    rep(i, n - k + 1) {
        llong left = X[i], right = X[i + k - 1];
        ans = min(ans, min(abs(left), abs(right)) + right - left);
    }

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

Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define ll long long
int main()
{
    ll n;
    string s = "";
    cin>>n;
    while(n){
        n--;
        s+=char(n % 26 + 'a');
        n /= 26;
    }
    reverse(s.begin(),s.end());
    cout<<s;
    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define EPS (1e-3)
typedef complex<double> P;

double dot(P a, P b) { return a.real() * b.real() + a.imag() * b.imag(); }

double cross(P a, P b) { return a.real() * b.imag() - a.imag() * b.real(); }

double distance(P s1, P s2, P p) {
  if (dot(s2 - s1, p - s1) < EPS) return abs(p - s1);
  if (dot(s1 - s2, p - s2) < EPS) return abs(p - s2);
  return abs(cross(s2 - s1, p - s1)) / abs(s2 - s1);
}

bool is_intersected(P a1, P a2, P b1, P b2) {
  return cross(a2 - a1, b1 - a1) * cross(a2 - a1, b2 - a1) < -EPS &&
         cross(b2 - b1, a1 - b1) * cross(b2 - b1, a2 - b1) < -EPS;
}

int main() {
  int n;
  while (cin >> n, n) {
    int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    P s(sx, sy), e(ex, ey);
    double m = 1e3;
    for (int i = 0; i < n; i++) {
      int minx, miny, maxx, maxy, h;
      cin >> minx >> miny >> maxx >> maxy >> h;
      vector<P> v = {P(minx, miny), P(minx, maxy), P(maxx, miny), P(maxx, maxy)};
      double d = 1e3;
      for (auto p1 : v) {
        for (auto p2 : v) {
          if (abs(p2 - p1) < EPS) {
            continue;
          }
          if (is_intersected(s, e, p1, p2)) {
            d = 0;
          }
        }
      }
      for (auto p1 : v) {
        d = min(d, distance(s, e, p1));
        for (auto p2 : v) {
          d = min(d, distance(p1, p2, s));
          d = min(d, distance(p1, p2, e));
        }
        m = min(m, d < h ? d : (d * d + h * h) / (2 * h));
      }
    }
    cout << fixed << setprecision(4) << m << endl;
  }
}



Measured memory_bytes: 3144
n,m,X,Y = map(int, input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))
x.append(X)
y.append(Y)
x.sort(reverse = True)
y.sort()
#print(x[0],y[0])
if x[0]<y[0]:
    print('No War')
else:
    print('War')


Measured memory_bytes: 3060
#include <iostream>
#include <assert.h>
#include <vector>
#include <unordered_map>
#include <queue>
#include <climits>
#include <cmath>
#include <algorithm>
#include <unordered_set>
using namespace std;
constexpr int64_t MOD = 1e9 + 1;

int main(){
  std::cin.tie(0);
  std::ios::sync_with_stdio(false);
  using p = pair<int, int>;
  int32_t H,W,M;
  cin >> H >> W >> M;
  vector<p> row_sum(H);
  for (int i = 0; i < H; i++) {
    row_sum[i] = make_pair(0,i);
  }
  vector<p> col_sum(W);
  for (int i = 0; i < W; i++) {
    col_sum[i] = make_pair(0,i);
  }
  vector<vector<int>> tgtr(H);
  vector<vector<int>> tgtc(W);
  for (int i = 0; i < M; i++) {
    int h,w;
    cin >> h >> w;
    row_sum[h-1].first++;
    col_sum[w-1].first++;
    tgtr[h-1].emplace_back(w-1);
    tgtc[w-1].emplace_back(h-1);
  }
  sort(row_sum.begin(), row_sum.end(), greater<p>());
  sort(col_sum.begin(), col_sum.end(), greater<p>());

  int res = 0;
  int rmax = row_sum[0].first;
  int cmax = col_sum[0].first;
  for (int i = 0; i < (int)row_sum.size() && row_sum[i].first == rmax; i++) {
    for (int j = 0; j < 1000 && j < (int)col_sum.size() && col_sum[j].first == cmax; j++) {
      int cur = row_sum[i].first + col_sum[j].first;
      int r = row_sum[i].second;
      int c = col_sum[j].second;
      for (auto t : tgtr[r]) {
        if (t == c) cur--;
      }
      //cout << r << "," << c << "," << cur << endl;
      res = max(res, cur);
    }
  }
  for (int j = 0;j < (int)col_sum.size() && col_sum[j].first == cmax; j++) {
   for (int i = 0; i < 1000 && i < (int)row_sum.size() && row_sum[i].first == rmax; i++) {
      int cur = row_sum[i].first + col_sum[j].first;
      int r = row_sum[i].second;
      int c = col_sum[j].second;
      for (auto t : tgtc[c]) {
        if (t == r) cur--;
      }
      //cout << r << "," << c << "," << cur << endl;
      res = max(res, cur);
    }
  }

  cout << res << endl;
  return 0;
}


Measured memory_bytes: 40676
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define rep( i, n, m ) for(int i = ( n ); i < ( m ); i++)
#define rep_d( i, n, m ) for(int i = ( n ) - 1; i >= ( m ); i--)
#define sort_asc( X ) sort(( X ).begin(), ( X ).end())
#define sort_desc( X ) sort(( X ).begin(), ( X ).end(), greater <>())

template <class T> bool chmax( T& a, T b );
template <class T> bool chmin( T& a, T b );
int* eratosthenes( int N );
bool bit_search( int pattern, int N );
template <class T> void cumulative_sum( T array, size_t N );

const ll INF = 1LL << 60;
const int k_mod = 1e9 + 7;


bool field[ 2000 ][ 2000 ] = {};
int blight[ 2000 ][ 2000 ] = {};
int main( void ){
	int H, W;
	cin >> H >> W;
	rep( i, 0, H ){
		rep( j, 0, W ){
			string s( "a" );
			if (!scanf( "%1s", &s[ 0 ] ))
				return -1;
			field[ i ][ j ] = ( s == "." ) ? true : false;
		}
	}
	rep( i, 0, H ){
		int cnt = 0;
		bool is_end = false;
		rep( j, 0, W ){
			if (!field[ i ][ j ]){
				rep( k, 1, cnt + 1 ){
					blight[ i ][ j - k ] = cnt;
				}
				blight[ i ][ j ] = 0;
				cnt = 0;
				if (j == W - 1)
					is_end = true;
			}
			else {
				cnt++;
			}
		}
		if (!is_end){
			rep( j, 1, cnt + 1 ){
				blight[ i ][ W - j ] = cnt;
			}
		}
	}
	int maximum = 0;
	rep( i, 0, W ){
		int cnt = 0;
		bool is_end = false;
		rep( j, 0, H ){
			if (!field[ j ][ i ]){
				rep( k, 1, cnt + 1 )
				maximum = max( maximum, cnt + blight[ j - k ][ i ] - 1 );
				cnt = 0;
			}
			else
				cnt++;
		}
		if (!is_end){
			rep( j, 1, cnt + 1 )
			maximum = max( maximum, cnt + blight[ H - j ][ i ] - 1 );
		}
	}
	cout << maximum << endl;

}

int* eratosthenes( int N ){
	int* prime_array = new int[ N + 1 ];
	int lim = N;
	prime_array[ 0 ] = 0;
	prime_array[ 1 ] = 0;
	rep( i, 2, N + 1 ){
		prime_array[ i ] = 1;
	}
	rep( i, 2, lim ){
		if (prime_array[ i ] == 0)
			continue;
		lim = N / i;
		for(int j = i * 2; j < N + 1; j += i){
			prime_array[ j ] = 0;
		}
	}
	return prime_array;
}
template <class T> void cumulative_sum( T array, size_t N ) {
	rep( i, 1, N + 1 ){
		array[ i ] += array[ i - 1 ];
	}
}
template <class T> bool chmax( T& a, T b ) {
	if (a < b){
		a = b; return true;
	}
	return false;
}
template <class T> bool chmin( T& a, T b ) {
	if (a > b){
		a = b; return true;
	}
	return false;
}
bool bit_search( int pattern, int N ){
	int cnt = 0;
	rep( bit, 0, N ){
		if (pattern & ( 1 << bit )){
			cnt++;
		}
	}
	return true;
}


Measured memory_bytes: 19840
n=int(input())
ls=[1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
print(ls[n-1])

Measured memory_bytes: 9132
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;


int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	map<ll,ll> m;
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
		m[A[i]]++;
	}
	ll d = 0;
	for (auto x : m) {
		d += x.second-1;
	}
	cout << N-(d+d%2) << endl;
	return 0;
}



Measured memory_bytes: 7296
#include <bits/stdc++.h>
#include <algorithm>
#include <map>
#include <cstdlib>
#include <cmath>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;
typedef long long ll;
const double pi=acos(-1);
int main(){
    int n;
    cin >> n;
    map<int,int> mp;
    for(int i=0;i<n;i++){
        int d;
        cin >> d;
        mp[d]++;
    }
    int m;
    cin >> m;
    for(int i=0;i<m;i++){
        int t;
        cin >> t;
        auto itr=mp.find(t);
        if(itr==mp.end() || itr->second<1){
            cout << "NO" << endl;
            return 0;
        }else mp[t]--;
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 9600
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

Q,H,S,D=get_i
N=gets.to_i
one=[Q*4,H*2,S].min
two=[one*2,D].min
puts N/2*two+N%2*one

Measured memory_bytes: 3836
n, m = (int(each) for each in input().split())
h = [int(each) for each in input().split()]
pathlist = list()
for i in range(m):
    pathlist.append([int(each) for each in input().split()])
score = 0

decklist = set(range(1, n+1))
for path in pathlist:
    # もし道のうち前者が高ければ
    if h[path[0]-1] >= h[path[1]-1]:
        # print('remove:', path[1])
        decklist.discard(path[1])
    # 後者が高ければ
    if h[path[0]-1] <= h[path[1]-1]:
        # print('remove:', path[0])
        decklist.discard(path[0])
print(len(decklist))

Measured memory_bytes: 38944
#include<bits/stdc++.h>
using namespace std;
#define ALL(A) A.begin(),A.end()
const long long mod=1000000007;
int main(){
    int M[3]={},c[3][3];
    for(int i=0;i<3;i++)
    {
        for(int j=0;j<3;j++)
        {
            cin>>c[i][j];
            M[i]=max(M[i],c[i][j]);
        }
    }
    bool flag=false;
    for(int a0=0;a0<=M[0];a0++)
    {
        for(int a1=0;a1<=M[1];a1++)
        {
            for(int a2=0;a2<=M[2];a2++)
            {
                int b0=c[0][0]-a0,b1=c[0][1]-a0,b2=c[0][2]-a0;
                if(b0==c[1][0]-a1&&b1==c[1][1]-a1&&b2==c[1][2]-a1&&b0==c[2][0]-a2&&b1==c[2][1]-a2&&b2==c[2][2]-a2)
                flag=true;
            }
        }
    }
    if(flag)
    cout<<"Yes"<<endl;
    else
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define int long long
#define ld long double
#define pb push_back
#define ff first
#define ss second
#define PI acos(-1)
#define bp __builtin_popcountll
#define all(x) x.begin(),x.end()
#define sp fixed<<setprecision
#define pii pair<long long,long long>
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;

int MOD = (1e9)+7;
const int N = 1e6+5;

signed main()
{
    FAST
    int tc=1;
    //cin>>tc;
    for(int ti=1;ti<=tc;ti++)
    {
        int n;
        cin>>n;
        int ans = 0;
        for(int a=1;a<=n;a++)
            ans += (n-1)/a;
        cout<<ans<<endl;
    }
    return 0;
}


Measured memory_bytes: 3656
#include<iostream>

using namespace std;

int main()
{
    int K[] = {1, 1, 1, 2, 1, 2, 1, 5,
         2, 2, 1, 5, 1, 2, 1, 14,
         1, 5, 1, 5, 2, 2, 1, 15,
         2, 2, 5, 4, 1, 4, 1, 51};

    int input = -1;
    do{
        cin >> input;
    }while(input < 0 || input > 32);
    cout << K[input-1] << endl;

    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int>pii;

multiset<int>ml;
priority_queue<pii>pq;

int main()
{
    int n,m;
    cin>>n>>m;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        ml.insert(a);
    }
    for(int i=1;i<=m;i++)
    {
        int a,c;
        cin>>a>>c;
        pq.push(pii(c,a));
    }
    while(!pq.empty())
    {
        pii p=pq.top();
        pq.pop();

        int c=p.second;
        while(c--)
        {
            if(*ml.begin()>=p.first) break;
            ml.erase(ml.begin());
            ml.insert(p.first);
        }
    }
    long long sum=0;
    for(auto it : ml)
    {
        int x = it;
        sum+=1ll*x;
    }
    cout<<sum<<endl;
}


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

int main()
{
    long long n, k;
    cin >> n >> k;

    int a[n];

    vector<int> bucket(n + 1, -1);

    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        a[i]--;
    }

    bucket[0] = 0;
    long long nowp = 0, unroop = 0, roops = 0, roope = 0;

    vector<int> root(n + 1);
    root[0] = 0;
    for (int i = 1; i <= n; i++)
    {
        if(bucket[a[nowp]] == -1)
        {
            bucket[a[nowp]] = i;
            nowp = a[nowp];
            root[i] = nowp;
        }
        else
        {
            unroop = bucket[a[nowp]] - 1;
            roops = bucket[a[nowp]];
            roope = i - 1;
            break;
        }
    }
    if(unroop >= k)
    {
        cout << root[k] + 1 << endl;
    }
    else
    {
        if((k - unroop) % (roope - roops + 1) != 0)cout << root[unroop + (k - unroop) % (roope - roops + 1)] + 1 << endl;
        else cout << root[unroop + (roope - roops + 1)] + 1 << endl;
    }
    
}


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


int main(){
  int64_t N;
  cin >> N;
  vector<int64_t> X(N),P(100,0);
  for(int64_t i=0;i<N;i++){
    cin >> X.at(i);
  }
  for(int64_t i=0;i<100;i++){
    for(int64_t j=0;j<N;j++){
      P.at(i)+=(X.at(j)-i-1)*(X.at(j)-i-1);
    }
  }
  sort(P.begin(),P.end());
  cout << P.at(0) << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define MOD 1000000007
#define all(ppp) ppp.begin(),ppp.end()
#define out(ppp) cout<<(ppp)<<endl
#define out1(ppp) cout<<(ppp) 
#define MAX_CHAR 256

#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push_back

typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
typedef vector<vpi> vvpi;

typedef set<pi> spi;

const int INF=INT_MAX;

void solve(){
    string s;
    cin>>s;
    if(s[1]==s[0]||s[2]==s[1]||s[3]==s[2]){
        out("Bad");
    }else{
        out("Good");
    }
}

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

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

ll f(string s);

int main() {
  string s; ll k;
  cin >> s >> k;

  bool identical = false;
  {
    map<char, int> mp;
    for (char c : s) mp[c]++;
    if (mp.size() == 1) identical = true; 
  }

  if (identical)
  {
    cout << s.size() * k / 2 << endl;
    return 0;
  }

  ll a1 = f(s);
  ll a2 = f(s + s);

  ll ans = a1 * k;
  if (a1 * 2 != a2) ans += (a2 % 2) * (k - 1);

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

ll f(string s)
{
  ll ret = 0;
  size_t i = 1;
  while (i < s.size())
  {
    if (s[i] != s[i-1]) i++;
    else
    {
      ret++;
      i += 2;
    }
  }
  return ret;
}


Measured memory_bytes: 3632
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <stdio.h>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#define rep(i,a,n) for(ll i =(a);i<(n);++i)
#define urep(i,a,n) for(ll i = (a);i>=(n);--i)
#define all(x) (x).begin(),(x).end()
#define INF 1e18
typedef long long ll;
const ll MAX=510000;
const ll mod = 1e9 + 7;
static const double pi = 3.141592653589793;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N,M,Y,C,D,Q,K,R,W,H,P,L,G;
double A,B,X;
ll ans;
string S,T;
ll h[101010];
ll y[101010];
ll a[201010];
ll c[101010];
ll k[101010];
ll b[201010];
ll d[101010];
ll t[101010];
ll p[101010];
ll n[101010];
ll l[101010];
ll r[101010];
ll v[101010];
ll s[101010];
ll x[101010];
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;
}
struct Edge{
	ll to,cost;
	 Edge(ll to, ll cost) : to(to), cost(cost) {}
};
typedef vector<vector<Edge> > AdjList;
AdjList graph;
vector<ll> dist;

struct UnionFind {
    vector<ll> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2
	vector<ll> size;
    UnionFind(ll N) : par(N),size(N) { //最初は全てが根であるとして初期化
        for(ll i = 0; i < N; i++) par[i] = i;
		for(ll i = 0; i < N; i++) size[i] = 1;
    }

    ll root(ll x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }
	ll GetSize(ll x){
		return size[root(x)];
	}

    void unite(ll x, ll y) { // xとyの木を併合
        ll rx = root(x); //xの根をrx
        ll ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
		size[ry]+=size[rx];

    }

    bool same(ll x, ll y) { // 2つのデータx, yが属する木が同じならtrueを返す
        ll rx = root(x);
        ll ry = root(y);
        return rx == ry;
    }
};
bool IsOK(ll len){
        map<string,ll> m;
        rep(i,0,N){
            if(m[S.substr(i,len)]==0){
                m[S.substr(i,len)]=i+len;
            }else{
                if(i>=m[S.substr(i,len)]){
                    return true;
                }
            }
        }
        return false;
}
bool func(double kaku){
    double rad = kaku*pi/180;
    double V;
    cerr<<kaku<<" "<<rad<<endl;
    cerr << B*cos(rad)/sin(rad)<<endl;
    if(B*cos(rad)/sin(rad)>A){
        V = A*A*B-1.0/2.0*A*A*A*sin(rad)/cos(rad);
    }else{
        V = 1.0/2.0*A*B*B*cos(rad)/sin(rad);
    }
    cerr<<V<<endl<<endl;
    return V <= X;
}
int main(){
    string s;
    cin>>s;
    if(s=="hi"||s=="hihi"||s=="hihihi"||s=="hihihihi"||s=="hihihihihi"){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
N = int(input())
# A = list(map(int, input().split()))
# a, b = map(int, input().split())

K = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]

print(K[N-1])

Measured memory_bytes: 3060
from sys import stdin

class Dice:
    def __init__(self, nums):
        self._1 = nums[0]
        self._2 = nums[1]
        self._3 = nums[2]
        self._4 = nums[3]
        self._5 = nums[4]
        self._6 = nums[5]
        self.pos = {
            "E" : self._3,
            "W" : self._4,
            "S" : self._2,
            "N" : self._5,
            "T" : self._1,
            "B" : self._6
        }

    def roll(self, query):
        for q in query:
            if q == "E":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["W"], self.pos["T"], self.pos["E"], self.pos["B"]
            elif q == "W":
                self.pos["T"], self.pos["E"], self.pos["B"], self.pos["W"] = self.pos["E"], self.pos["B"], self.pos["W"], self.pos["T"]
            elif q == "S":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["N"], self.pos["T"], self.pos["S"], self.pos["B"]
            elif q == "N":
                self.pos["T"], self.pos["S"], self.pos["B"], self.pos["N"] = self.pos["S"], self.pos["B"], self.pos["N"], self.pos["T"]

nums = [int(x) for x in stdin.readline().rstrip().split()]
queries = stdin.readline().rstrip()
d = Dice(nums)
d.roll(queries)
print(d.pos["T"])


Measured memory_bytes: 5620
n, y = map(int,input().split())
y = y//1000
for i in range(n+1):
    for j in range (n+1-i):
        k = n - i - j
        if 10*i + 5* j + 1 * k == y:
            print(str(i) +' '+str(j)+' '+str(k))
            exit()
print('-1 -1 -1')

Measured memory_bytes: 9084
#include <stdio.h>

void call(int n) {
int i,d,flag;
//scanf("%d",&n);
for(i=1;i<=n;i++){
 if(i%3==0){
 printf(" %d",i);
}else
{
 d=1;
 flag=0;
 while(flag==0)
 {
  if((i%(10*d)-i%d)/d==3)
  {
    printf(" %d",i);
    flag=1;
  }else{
   d=d*10;
   flag=(i/d==0)?1:0;
  }
 }
}
}
}

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

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

int main(){
    int n,q;
    cin >> n >> q;

    string s;
    cin >> s;

    vector<int> count(n,0);

    for(int i = 1; i < n; ++i){
        string t = s.substr(i-1,2);
        if(t == "AC"){
            count[i] = count[i - 1] + 1;
        }else{
            count[i] = count[i - 1];
        }
    }

    vector<int> ans(q);

    for(int i = 0; i < q; ++i){
        int l,r;
        cin >> l >> r;

        ans[i] = count[r - 1] - count[l - 1];
    }

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

    return 0;
}

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

// #pragma GCC optimize("Ofast")
// #pragma GCC optimize ("unroll-loops")
// #pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

typedef long long ll; 
typedef long double ld; 
#define prarr(a,n) cout<<#a<<" : ";for(ll i=0;i<n;i++) cout<<a[i]<<" "; cout<<endl;
#define prmat(mat,row,col) cout<<#mat<<" :\n";for(ll i=0;i<row;i++) {for(ll j=0;j<col;j++) cout<<mat[i][j]<<"\t";cout<<endl;}
#define pr(...) dbs(#__VA_ARGS__, __VA_ARGS__)
#define all(a) a.begin(),a.end()
#define sz(x) ((int)x.size())
#define endl '\n'
#define F first
#define S second
#define pb push_back
#define vi vector<int>
#define pii pair<int,int>
#define fast_io ios_base::sync_with_stdio(NULL); cin.tie(NULL)
template <class T> void dbs(string str, T t) {cout << str << " : " << t << "\n";}
template <class T, class... S> void dbs(string str, T t, S... s) {ll idx = str.find(','); cout << str.substr(0, idx) << " : " << t << ", "; dbs(str.substr(idx + 1), s...);}
template <class T> void prc(T a, T b) {cout << "["; for (T i = a; i != b; ++i) {if (i != a) cout << ", "; cout << *i;} cout << "]\n";}
template <class T> void prall(T a) { prc(all(a)); }
const int inf=1000*1000*1000+9; 
const ll infl=1ll*inf*inf; 
const int mod=1000*1000*1000+7;

// ------------------------------------------------------------------------------------------ 

const int nax=1e5+5;

void solve(){
    int n,k,x;
    cin>>n>>k;
    map<int,int> m;
    int offset = 0;
    m[0]++;
    ll ans=0;
    vi v;
    v.pb(0);
    for(int i=0;i<n;i++){

        if(i+1>=k) m[v[i+1-k]]--;
        cin>>x;
        x%=k;

        offset+=(k-1);
        offset%=k;

        offset+=x;
        offset%=k;

        ans += m[(k-offset)%k];

        m[(k-offset)%k]++;
        v.pb((k-offset)%k);
    }
    cout<<ans;
}


int main(){
    // clock_t beg=clock(); 
    fast_io; 
    cout << fixed << setprecision(13); 
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    } 
    // clock_t end=clock(); 
    // fprintf(stderr, "%lf\n", (double)(end-beg)/(CLOCKS_PER_SEC));
}

Measured memory_bytes: 10484
import numpy as np
n,m = map(int, input().split())

ac_ques = np.array([0]*n)
count = np.array([0]*n)

for _ in range(m):
    p,s = map(str, input().split())
    if ac_ques[int(p)-1] == 0:
        if s == "WA":
            count[int(p)-1] += 1
        else:
            ac_ques[int(p)-1] = 1

print(sum(ac_ques),sum(ac_ques * count))

Measured memory_bytes: 29748
#include<iostream>
#include<string>
#include<cstdlib>
#include<vector>
#include<algorithm>
#include<functional>

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

using namespace std;

int to_int(string s) {
  return atoi(s.c_str());
}

int a[200001];

int main() {
  int n;
  ll ari = 0;
  cin >> n;

  REP(i,n) {
    cin >> a[i];
    ari += a[i];
  }

  ll su = 0;
  ll result = 50000000000000;
  REP(i,n-1) {
    su += a[i];
    ari -= a[i];
    ll po = abs(su -ari);
    if(po < result) result = po;
  }
  cout << result << endl;

}


Measured memory_bytes: 1024
a, b = list(map(int,input().split()))
a_s = 0
b_s = 0
for i in range(b):
    a_s += 10**i * a
for i in range(a):
    b_s += 10**i * b

a_s = str(a_s)
b_s = str(b_s)

print(min(a_s,b_s))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i++)
#define rep1(i,n) for (int i = 1; i <= (n); i++)
#define repm(i,m,n) for (int i = m; i < (n); i++)
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  int ans;
  if (a <= b) {
    ans = a;
  }
  else {
    ans = a-1;
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 256
// Copyright 2020 yaito3014
#include <algorithm>
#include <bitset>
#include <iostream>
#include <string>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::string s;
  std::cin >> s;
  std::reverse(begin(s), end(s));
  int p = std::count(cbegin(s), cend(s), '1');
  std::vector<int> m1(N, 1), m2(N, 1);
  for (int i = 0; i < N - 1; ++i) {
    if (p > 1) m1[i + 1] = m1[i] * 2 % (p - 1);
    m2[i + 1] = m2[i] * 2 % (p + 1);
  }
  int b1 = 0, b2 = 0;
  for (int i = 0; i < N; ++i) {
    if (s[i] != '1') continue;
    if (p > 1) b1 = (b1 + m1[i]) % (p - 1);
    b2 = (b2 + m2[i]) % (p + 1);
  }
  std::vector<int> table(N + 1, 0);
  for (int i = 1, x = i; i <= N; x = ++i) do
      ++table[i];
    while (x %= std::bitset<32>(x).count());

  for (int i = 0; i < N; ++i) {
    int ans =
        s[N - i - 1] == '1'
            ? p > 1 ? table[(b1 - m1[N - i - 1] + p - 1) % (p - 1)] : -1
            : table[(b2 + m2[N - i - 1] + p + 1) % (p + 1)];
    std::cout << ++ans << '\n';
  }
}


Measured memory_bytes: 5984
N = int(input())

ans = []

for _ in range(N):
    s = list(input())
    s.sort()
    s = ''.join(s)
    ans.append(s)
ans.sort()

now = ans[0]
count = 1
ansans = 0
for a in ans[1:]:
    if a == now:
        count += 1
    else:
        now = a
        tmp = count * (count - 1) // 2
        count = 1
        ansans += tmp

tmp = count * (count - 1) // 2
count = 1
ansans += tmp

print(ansans)


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

#define debug(x) cerr << #x << ": " << x << endl
#define debugArray(x, n)                                                       \
    for(long long hoge = 0; (hoge) < (n); ++(hoge))                            \
    cerr << #x << "[" << hoge << "]: " << x[hoge] << endl
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
const ll INF = LLONG_MAX / 2;
const ll MOD = 1e9 + 7;

ll N, Q;
vector<vll> G;
vll ar;
vll in, out;

void dfs(int v, int p) {
    ar.push_back(0);
    in[v] = ar.size() - 1;
    for(int u : G[v])
        if(u != p) {
            dfs(u, v);
        }
    ar.push_back(0);
    out[v] = ar.size() - 1;
}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> N >> Q;
    G.resize(N);
    in.resize(N);
    out.resize(N);
    for(int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        a--;
        b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0, -1);
    ar.push_back(0);
    while(Q--) {
        ll p, x;
        cin >> p >> x;
        p--;
        ar[in[p]] += x;
        ar[out[p] + 1] -= x;
    }
    for(int i = 1; i < 2 * N; i++) {
        ar[i] += ar[i - 1];
    }
    for(int i = 0; i < N; i++) {
        cout << ar[in[i]] << (i == N - 1 ? "\n" : " ");
    }
    return 0;
}


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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(int i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const double DINF = std::numeric_limits<double>::infinity();
const int MOD = 1000000007;
#define MAX_N 110

ll N;
ll x[MAX_N];
ll y[MAX_N];
ll h[MAX_N];

signed main()
{
    cin >> N;
    ll lb = LLINF, ub = 0;
    REP(i, N) {
        cin >> x[i] >> y[i] >> h[i];
        lb = min(lb, h[i]);
        ub = max(ub, h[i]);
    }

    lb -= 100;
    if(lb < 0) { lb = 0; }
    ub += 100;

    for(ll H = lb; H <= ub; ++H) {
        for(ll Cx = 0; Cx <= 100; ++Cx) {
            for(ll Cy = 0; Cy <= 100; ++Cy) {
                bool isOk = true;
                REP(i, N) {
                    if(max(H - abs(x[i] - Cx) - abs(y[i] - Cy), 0LL) != h[i]) {
                        isOk = false;
                        break;
                    }
                }
                // 見つかった
                if(isOk) {
                    printf("%lld %lld %lld\n", Cx, Cy, H);
                    return 0;
                }
            }
        }
    }
    assert(false);
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main () {
	int k, length = 0;
	char string[100];
	scanf("%d", &k);
	scanf("%s", string);

	for (int i = 0; string[i] != '\0'; i++) {
		length++;
	}
	
	if (length <= k) {
		printf("%s", string);
	}
	else {
		for (int i = 0; i < k; i++) {
			printf("%c", string[i]);
		}
		printf("...");
	}
	
	
	return 0;
}

Measured memory_bytes: 1712
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author teiwa
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            long W = in.nextLong();
            long H = in.nextLong();
            long x = in.nextLong();
            long y = in.nextLong();

            double answer = H * W / (double) 2;
            if (x * 2 == W && y * 2 == H) {
                out.println(answer + " 1");
            } else {
                out.println(answer + " 0");
            }
        }

    }
}



Measured memory_bytes: 23124
H,W=map(int,input().split())
s=[0 for i in range(0,H)]
for i in range(0,H):
    s[i]=input()

dp=[[-1 for i in range(W)] for j in range(H)]
if s[0][0]=='#':
    dp[0][0]=1
else:
    dp[0][0]=0
for i in range(1,W):
    if s[0][i-1]=='.' and s[0][i]=='#':
        dp[0][i]=dp[0][i-1]+1
    else:
        dp[0][i]=dp[0][i-1]

for i in range(1,H):
    for j in range(0,W):
        fromup=10**5
        fromleft=10**5
        if s[i-1][j]=='.' and s[i][j]=='#':
            fromup=dp[i-1][j]+1
        else:
            fromup=dp[i-1][j]
        if j!=0:
            if s[i][j-1]=='.' and s[i][j]=='#':
                fromleft=dp[i][j-1]+1
            else:
                fromleft=dp[i][j-1]
        dp[i][j]=min(fromup,fromleft)

print(dp[H-1][W-1])


Measured memory_bytes: 43760
#include <bits/stdc++.h>
using namespace std;
typedef vector<int> vi;

#define REP(i,x) for(int i=0;i<(int)(x);i++)

int T, n, m;

bool solve(){
    cin >> n >> m;
    vi v(n);
    REP(i, n) cin >> v[i];
    if(*max_element(v.begin(), v.end()) < m) return false;
    int g = v[0];
    for(int x : v) g = __gcd(g, x);
    return m % g == 0;

}

int main(int argc, char *argv[]){
    ios::sync_with_stdio(false);
    cout << (solve() ? "POSSIBLE" : "IMPOSSIBLE") << endl;
    return 0;
}


Measured memory_bytes: 640
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define mt make_tuple
#define pqueue priority_queue
const int inf=1e9+7;
const ll mod=1e9+7;
const ll mod1=998244353;
const ll big=1e18;
const double PI=2*asin(1);

int main() {
  int A, B, C;
  cin>>A>>B>>C;
  if(A+B>=C) cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
}



Measured memory_bytes: 3596
N, K = map(int, input().split())
x = list(map(int, input().split()))
ans = 10 ** 9
for i in range(N-K+1):
  dista = abs(x[i]) + abs(x[i+K-1] - x[i])
  distb = abs(x[i+K-1]) + abs(x[i+K-1] - x[i])
  dist = min(dista, distb)
  if(dist < ans):
    ans = dist
    
print(ans)

Measured memory_bytes: 14252
#include<bits/stdc++.h>
                using namespace std;
                #define lli long long int
                #define fr(i,a,b) for(int i=a;i<b;i++)
                #define bfr(i,a,b) for(int i=a;i>=b;i--)
                #define fio ios_base::sync_with_stdio(false); cin.tie(NULL),cout.tie(NULL);
                #define tc int t;cin>>t;while(t--)
                #define mod 1000000007 
                #define all(vec) vec.begin(),vec.end()  
                #define ld long double


                   

               
        int main()
                {
                       
                       
                    
                     fio


                     lli x,y;
                     cin>>x>>y;
                     if(x==1 || y==1)cout<<1;
                     else 
                     cout<<(lli)ceil((x*y)/2.000);


                     


                     



                     

                     

                     

                     





                     


                     







                     


                     

                     

                     


return 0;}

Measured memory_bytes: 256