akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>

typedef struct{
	int name;
	int win;
	int res;
}teams;

int main(void){
	int n, i, j, a, b, c, d;
	teams t[100];
	
	scanf("%d", &n);
	
	for(i=0; i<n; i++){
		t[i].name=i+1;
		t[i].win=0;
	}
	
	int game = n*(n-1)/2;
	for(i=0; i<game; i++){
		scanf(" %d %d %d %d", &a, &b, &c, &d);

		if(c>d) t[a-1].win += 3;
		else if(c<d) t[b-1].win += 3;
		else {
			t[a-1].win++;
			t[b-1].win++;
		}
	}
	
	for(i=0; i<n; i++){
		for(j=i; j<n; j++){
			if(t[i].win < t[j].win){
				teams tmp = t[i];
				t[i] = t[j];
				t[j] = tmp;
			}
		}
	}
	
	int now=0, count=0;
	t[0].res=1;
	
	for(i=1; i<n; i++){
		if(t[now].win == t[i].win){
			t[i].res=t[now].res;
			count++;
		}
		else{
			t[i].res=t[now].res+count+1;
			count=0;
			now = i;
		}
	}
	
	for(i=0; i<n; i++){
		for(j=i; j<n; j++){
			if(t[i].name > t[j].name){
				teams tmp = t[i];
				t[i] = t[j];
				t[j] = tmp;
			}
		}
	}
	
	for(i=0; i<n; i++){
		printf("%d\n", t[i].res);
	}

	return 0;
}

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

using ll = long long;

constexpr ll MOD = 1e9+7;
constexpr ll INF = 1ll<<60;

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

template<class T>
bool chmin(T &a, T b)
{
	if (a > b)
	{
		a = b;
		return false;
	}
	return true;
}

template<class T>
bool chmax(T &a, T b)
{
	if (a < b)
	{
		a = b;
		return false;
	}
	return true;
}

template<class T>
bool chmax(T &a, initializer_list<T> l)
{
	return chmax(a, *max_element(l.begin(), l.end()));
}

template<class T>
bool chmin(T &a, initializer_list<T> l)
{
	return chmin(a, *min_element(l.begin(), l.end));
}

char F[110][110];
ll dp[110][110];

int main(int argc, char **argv)
{
	ll H, W; cin >> H >> W;
	REP(h, H) REP(w, W)
	{
		dp[h][w] = INF;
		cin >> F[h][w];
	}

	if (F[0][0] == '#')
		dp[0][0] = 1;
	else
		dp[0][0] = 0;

	REP(h, H)
	{
		REP(w, W)
		{
			chmin(dp[h][w+1], dp[h][w] + (F[h][w] == '.' && F[h][w+1] == '#'));
			chmin(dp[h+1][w], dp[h][w] + (F[h][w] == '.' && F[h+1][w] == '#'));
		}
	}

	std::cout << dp[H-1][W-1] << std::endl;
}


Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{
  string s;
  cin >> s;
  vector<int> v(4);
  int i;
  for(i=0;i<s.length();i++){
    if(s[i] == 'K') v[0]++;
    if(s[i] == 'U') v[1]++;
    if(s[i] == 'P') v[2]++;
    if(s[i] == 'C') v[3]++;
  }
  sort(v.begin(), v.end());
  cout << v[0] << endl;
  return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define REP(i, n) for(long long i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

int n,W;
int main() {
  int n;
  cin >> n;
  vector<int> b;
  int ans[n] , kaisuu = 0;
  REP(i,n) {
    int ci;
    cin >>ci;
    b.pb(ci);
    if (b[i] >i+1) {
      cout << "-1";
      return 0;
    }
  }
  while (b.size() != 0) {
    for(int i = b.size() - 1;i>=0;i--) {
      if(b[i] == i + 1) {
        ans[kaisuu] = b[i];
        kaisuu++;
        b.erase(b.begin() + i);
        break;
      }
    }
  }
  REP(i,n) {
    cout <<ans[n-i-1] << endl;
  }
}

Measured memory_bytes: 256
import sys
inf = 100100100
ans = inf
H, W, K = map(int, input().split())
S = [0]*H
for i in range(H):
    S[i] = [int(x) for x in sys.stdin.readline().strip()]
for i in range(2**(H-1)):
    group = [0]
    g = 0
    for j in range(H-1):
        if (i >> j) & 1:
            g += 1
        group.append(g)
    g += 1
    c = [[0 for _ in range(W)] for __ in range(g)]
    for j in range(H):
        for k in range(W):
            c[group[j]][k] += S[j][k]
    num = g-1
    now = [0]*g
    def large(now):
        for n in now:
            if n > K:
                return True
        else:
            return False
    def v_vec(twodlis, k):
        ans = []
        for lis in twodlis:
            ans.append(lis[k])
        return ans
    for k in range(W):
        for n in range(len(now)):
            now[n] = now[n] + v_vec(c,k)[n]
        if large(now):
            now = v_vec(c,k)
            num += 1
            if large(now):
                num = inf
                break

    ans = min(ans, num)
print(ans)

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

#define debug(n) cerr << #n << ':' << n << endl;

using namespace std;

using  ll = long long;

template<class T,class U>
using umap = unordered_map<T,U>;

template<class T>
using uset = unordered_set<T>;

template<class T>
inline bool change_max(T&a, const T&b){
  if(b > a){
    a = b;
    return true;
  }
  return false;
}

template<class T>
inline bool change_min(T&a, const T&b){
  if(a > b){
    a = b;
    return true;
  }
  return false;
}

template<long long mod>
class modint{
private:
  long long num;
  long long extgcd(long long a, long long b, long long&x, long long&y)const {
    long long d = a;
    if(b != 0){d = extgcd(b, a%b, y, x);  y -= (a/b) * x;}
    else{x = 1; y = 0;}
    return d;
  }
  long long modinverse()const{
    long long x, y;
    extgcd(num, mod, x, y);
    return (mod + x%mod)%mod;
  }
public:
  modint():num(0){}
  modint(const long long x):num((x < 0?(x+mod):x)%mod ){}
  friend modint operator+(const modint&a, const modint&b)
  {    return modint(a.num + b.num);  }
  friend modint operator-(const modint&a, const modint&b)
  {    return modint(a.num - b.num);  }
  friend modint operator*(const modint&a, const modint&b)
  {    return modint(a.num * b.num);  }
  friend modint operator/(const modint&a, const modint&b)
  {    return modint(a*b.modinverse());  }
  friend ostream& operator<<(ostream&os, const modint&a){
    os << a.num;
    return os;
  }
};


int main(){
  const int mod = 7+(1e+9);
  int n, b;cin >> n >> b;
  modint<mod> k;k = b;
  vector<int> v(n);
  for(auto&&e:v){
    cin >> e;
  }
  modint<mod>x = (k*k+k)/2;
  modint<mod>ans = 0;
  for(int i = 0; i < n; ++i){
    modint<mod>cnt=0;
    modint<mod>pre=0;
    for(int j = 0; j < n; ++j){
      if(v[i] > v[j]){
	cnt=cnt+1;
	if(i > j)pre=pre+1;
      }
    }
    ans = ans + cnt * x - k*pre;
  }
  cout << ans  << endl;
  return 0;
}


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

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> pii;
typedef long long int ll;

void gen_sosuu(int sosuu[]){
  REP(i,100010){
    sosuu[i] = true;
  }
  sosuu[0] = false;
  sosuu[1] = false;
  sosuu[2] = true;
  FOR(i,2,sqrt(100000)+1){
    if(sosuu[i] == false) continue;
    for(int j = 2; i*j<=100000;j++){
      //printf("%d %d %d\n",i*j,i,j);
      sosuu[i*j] =false;
    }
  }
}

int n;

int main(){
  scanf("%d",&n);
  printf("%d\n",n*800-n/15*200);
}


Measured memory_bytes: 256
N, H, W = list(map(int, input().split()))

sizels = []
for _ in range(N):
    sizels.append(list(map(int, input().split())))

cnt = 0
for a, b in sizels:
    if (a >= H) and (b >= W):
        # print(a, b, "OK")
        cnt += 1

print(cnt)


Measured memory_bytes: 3188
import sys


def sieve(N):
    is_prime = [True] * (N + 1)
    prime_list = []
    
    is_prime[0] = is_prime[1] = False
    
    prime_list.append(2)
    for i in range(3, N + 1, 2):
        if is_prime[i]:
            prime_list.append(i)
        for j in range(i * i, N, i):
            is_prime[j] = False
    
    return prime_list
    
primes = sieve(10001)
primes_set = set(primes)

def is_prime(num):
    if num in primes_set:
        return True
    elif num <= 10000:
        return False
    else:
        for prime in primes:
            if num % prime == 0:
                return False
        return True
    
if __name__ == '__main__':
    N = sys.stdin.readline()
    N = int(N)
    ans = 0
    for i in range(N):
        num = sys.stdin.readline()
        num = int(num)
        if is_prime(num): ans += 1
    
    sys.stdout.write(str(ans) + '\n')

Measured memory_bytes: 4620
#include <bits/stdc++.h>
#define ll long long int
#define dbg(x) cout<<"( "<<#x<<" -> "<<x<<" )"<<endl;
using namespace std;
int main()
{
    string s;
    cin>>s;
    int c=0;
    for (int i=0;i<s.length()/2;i++)
    {
        if (s.at(i)!=s.at(s.length()-1-i))
        c++;
    }
    printf("%d\n",c);
    return 0;
}

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

int main() {
    cin.tie(0);ios::sync_with_stdio(false);
    int N,M; cin >> N >> M;
	atcoder::scc_graph scc(N);
    while(M--) {
        int u,v; cin >> u >> v;
        scc.add_edge(u,v);
    }
    auto vv=scc.scc();
    cout << vv.size() << "\n";
    for(auto& v:vv) {
        cout << v.size();
        for(auto& e:v) cout << " " << e;
        cout << "\n";
    }
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> d(N);
  for (int i = 0; i < N ; i++) {
    cin >> d.at(i);
  }
  sort(d.begin(), d.end());
  int ret = 0;
  for (int i = 0; i < N; i++) {
    if (i == 0) {
      ret++;
    }
    else if (d.at(i) != d.at(i - 1)) {
      ret ++;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
ans=1000000000000
for i in range(len(w)):
       if abs(sum(w[:(i+1)])-sum(w[(i+1):]))<ans:
           ans = abs(sum(w[:(i+1)])-sum(w[(i+1):]))
print(ans)


Measured memory_bytes: 3060
#define _USE_MATH_DEFINES 
#include<iomanip> 
#include<cmath>  
#include<iostream>
#include<fstream>
#include<vector>
#include<algorithm>
#include<numeric>
#include<bitset>
#include<map>
#include<unordered_map>
#include<set>
#include<unordered_set>
#include<queue>
#include<deque>
#include<stack>
using namespace std;
typedef long long ll;
#define repi(i,a,b) for(ll i = (ll)(a) ; i < (ll)(b) ; i++)
#define repd(i,a,b) for(ll i = (ll)(a) ; i > (ll)(b) ; i--)
#define rd(x) cin >> x
#define wr(x)  cout << x
#define wrln(x) cout << x << endl

const ll INF = 10000000000000000;

int N, M, R, r[10];
ll roads[202][202], ans = INF;

void warshall_floyd() {
	repi(k, 1, N + 1) {
		repi(i, 1, N + 1) {
			repi(j, 1, N + 1) {
				roads[i][j] = min(roads[i][j], roads[i][k] + roads[k][j]);
			}
		}
	}
}

int main() {
	cin >> N >> M >> R;
	repi(i, 1, N + 1) {
		repi(j, 1, N + 1) {
			roads[i][j] = INF;
		}
	}
	repi(i, 1, N + 1) roads[i][i] = 0;
	repi(i, 0, R) rd(r[i]);
	repi(i, 0, M) {
		int a, b;
		ll c;
		cin >> a >> b >> c;
		roads[a][b] = c;
		roads[b][a] = c;
	}

	warshall_floyd();

	vector<int> v(R);
	iota(v.begin(), v.end(), 1);
	do {
		ll temp = 0;
		repi(i, 1, R) {
			temp += roads[r[v[i - 1] - 1]][r[v[i] - 1]];
		}
		ans = min(ans, temp);
	} while (next_permutation(v.begin(), v.end()));

	wrln(ans);

	return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <cmath>
#include <numeric>
using namespace std;
#define rep(i,a,b) for(int64_t i=(a); i<(b); ++i) // a ≦ i < b 
#define Rrep(i,a,b) for(int64_t i=(a);i>=(b);--i) // reverse repeat. a から b まで減少．
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend() //逆イテレータ
#define INF 10000000000000
#define MOD 1000000007LL
#define RANGE(a,b,c) (a).begin()+(b),(a).begin()+(c) // [b,c) イテレータ
using PII = pair<int64_t, int64_t>;
using VI = vector<int64_t>;
using VVI = vector<VI>;
using VS = vector<string>;
using VP = vector<PII>;
using i64 = int64_t;
template<typename T> void invec(vector<T> &A){for(T& a : A) cin >> a;} // input vector

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

int N, K, S; cin >> N >> K >> S;

rep(_, 0, K) cout << S << ' ';
rep(_, 0, N - K) cout << 999999999 << ' ';

}
// 書いて考える．場合分け．情報整理．
// 境界，出力文字列 チェック．行末にスペース入れない．
// 可読性優先．高速化次点．
// まずは全探索，分割，次にDP
// 制限を見る．境界に注意．求めたい量の変域．動かせる量．
// 偶奇，逆から，ソート，出現回数，出現位置，DP， 余事象，包除
// データ構造． 問題の特徴量．単調性，二分探索
// 存在判定：構成方法，入力の特徴
// gcd, lcm ,素因数分解．
// 例外を十分に含む一般化．想像力の限界
// 小さい系から例示
// 代数的処理．前処理によるクエリ高速化．
// 始めは過剰に例示・場合分けしてもいい．各場合を確実に対処．
// 自明な例から処理，除外．
// 小数のときは，精度の設定する．doubel 変数に数値を入力するときは 123. とする．
// テストケース作成は数表あり
// 実行エラー：vector添え字超え．0割り．



Measured memory_bytes: 1408
#include<bits/stdc++.h>
using ll = long long;
using namespace std;
ll aa[12345678], cost[12345678];
string s[1234];
signed main() {
	ll n, a, ans = 0; cin >> n;
	for (int h = 0; h < n; h++) {
		cin >> s[h] >> aa[h];
	}
	for (int h = 0; h < n; h++) {
		ans = 0; ll z = 0;
		string cnt = "zzzzzzzzzzz";
		for (int i = 0; i < n; i++) {
			if (cost[i] == 0 && s[i] == cnt && ans < aa[i]) {
				ans = aa[i]; z = i + 1;
			}
			if (cost[i] == 0 && s[i] < cnt) {
				cnt = s[i]; ans = aa[i]; z = i + 1;
			}
		}
		cout << z << endl; cost[z - 1]++;
	}
	return 0;
}

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

using namespace std;
typedef long long ll;

int a[15][15];
int n,d;

double cal(int i, int j)
{
    double sum=0;
    for(int k = 0; k < d; k++)
        sum+=(a[j][k]-a[i][k])*(a[j][k]-a[i][k]);
    return sqrt(sum);
}

int main()
{
    cin>>n>>d;
    int ans=0;

    for(int i = 0; i < n; i++)
        for(int j = 0; j < d; j++)
            cin>>a[i][j];
    for(int i = 0; i < n; i++)
        for(int j = i+1; j < n; j++)
        {
            if(cal(i,j) == (int)(cal(i,j)))
               ans++;
        }
    cout<<ans<<endl;

    return 0;
}


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

int main()
{
    int w, h, x, y, r;
    cin >> w >> h >> x >> y >> r;
    if (x >= r && x <= w - r && y >= r && y <= h - r) {
        std::cout << "Yes\n";
    }
    else {
        std::cout << "No\n";
    }
}

Measured memory_bytes: 1120
a = list(input())
b = list(input())
flag = True
if len(a)+1 != len(b):
    flag = False
for i in range(len(a)):
    if a[i] != b[i]:
        flag = False
if not b[len(b) - 1].isalpha:
    flag = False
if flag:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 9128
#include<iostream>
using namespace std;
int main(){
    int a, b;
    cin >>a >>b;
    
    if(a < b) cout << "a < b" << endl;
    else if(a > b) cout << "a > b" << endl;
    else cout << "a == b" << endl;
    
    return 0;
}


Measured memory_bytes: 3096
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {

		Scanner scan = new Scanner(System.in);

		int town = scan.nextInt();
		int[] x = new int[town];
		int[] y = new int[town];
		double ave = 0;
		double sum = 0;

		for(int i=0;i<town;i++) {

			x[i] = scan.nextInt();
			y[i] = scan.nextInt();
		}

		for(int i=0;i<town;i++) {
			for(int j=0;j<town;j++) {
			double	dis = Math.sqrt((x[i]-x[j])*(x[i]-x[j]) + (y[i]-y[j])*(y[i]-y[j]));
				 sum += dis;
				 ave = sum/town;
			}
		}

		System.out.println(ave);
		scan.close();
	}

}


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

using namespace std;

using int64 = long long;

int main() {
  int N, M;
  cin >> N >> M;
  vector< int > ev[100000];
  for(int i = 0; i < M; i++) {
    int x, y;
    cin >> x >> y;
    --x, --y;
    ev[y].emplace_back(x);
  }
  int last = 0, ret = 0;
  for(int i = 1; i < N; i++) {
    bool need = false;
    for(auto &p : ev[i]) need |= p >= last;
    if(need) {
      ++ret;
      last = i;
    }
  }
  cout << ret << endl;
}

Measured memory_bytes: 4992
// 'By Anki'
 
#include<bits/stdc++.h>
// #include<iostream>
using namespace std;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define wr(i) cout<<#i<<" = "<<i<<",  ";
#define wre(i) cout<<#i<<"  =  "<<i<<endl;
#define all(v) v.begin(),v.end()
typedef long long ll;
#define lim 1000000007LL
typedef unsigned long long ull;
#define M 10004
using u64= uint64_t;

int main()
{
fast
ll t=1LL;
// cin>>t;
while(t--)
{
   ll n;
   cin>>n;
   cout<<(1000-n%1000)%1000;
}
} 

Measured memory_bytes: 3636
import heapq


def main():
    S = []
    while True:
        cmd, *v = input().split()
        if cmd == "insert":
            heapq.heappush(S, (-1) * int(v[0]))
            pass
        elif cmd == "extract":
            print(heapq.heappop(S) * (-1))
        else:
            exit()


if __name__ == '__main__':
    main()



Measured memory_bytes: 45836
package main

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

func configure(scanner *bufio.Scanner) {
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 1000005), 1000005)
}
func getNextString(scanner *bufio.Scanner) string {
	scanned := scanner.Scan()
	if !scanned {
		panic("scan failed")
	}
	return scanner.Text()
}
func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}
func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}
func getNextFloat64(scanner *bufio.Scanner) float64 {
	i, _ := strconv.ParseFloat(getNextString(scanner), 64)
	return i
}
func main() {
	fp := os.Stdin
	wfp := os.Stdout
	extra := 0
	if os.Getenv("I") == "IronMan" {
		fp, _ = os.Open(os.Getenv("END_GAME"))
		extra = 100
	}
	scanner := bufio.NewScanner(fp)
	configure(scanner)
	writer := bufio.NewWriter(wfp)
	defer func() {
		r := recover()
		if r != nil {
			fmt.Fprintln(writer, r)
		}
		writer.Flush()
	}()
	solve(scanner, writer)
	for i := 0; i < extra; i++ {
		fmt.Fprintln(writer, "-----------------------------------")
		solve(scanner, writer)
	}
}
func solve(scanner *bufio.Scanner, writer *bufio.Writer) {
	n := getNextInt(scanner)
	k := mint(getNextInt(scanner))

	var ans mint
	ans = k
	for i := 0; i < n-1; i++ {
		ans.mulAs(k)
	}
	fmt.Fprintln(writer, ans)
}

type mint int64

func (mt mint) mod() mint {
	m := mint(1e9 + 7)
	mt %= m
	if mt < 0 {
		return mt + m
	}
	return mt
}
func (mt mint) inv() mint {
	return mt.pow(mint(0).sub(2))
}
func (mt mint) pow(n mint) mint {
	p := mint(1)
	for n > 0 {
		if n%2 == 1 {
			p.mulAs(mt)
		}
		mt.mulAs(mt)
		n >>= 1
	}
	return p
}
func (mt mint) add(x mint) mint {
	return (mt + x).mod()
}
func (mt mint) sub(x mint) mint {
	return (mt - x).mod()
}
func (mt mint) mul(x mint) mint {
	return (mt * x).mod()
}
func (mt mint) div(x mint) mint {
	return mt.mul(x.inv())
}
func (mt *mint) addAs(x mint) *mint {
	*mt = mt.add(x)
	return mt
}
func (mt *mint) subAs(x mint) *mint {
	*mt = mt.sub(x)
	return mt
}
func (mt *mint) mulAs(x mint) *mint {
	*mt = mt.mul(x)
	return mt
}
func (mt *mint) divAs(x mint) *mint {
	*mt = mt.div(x)
	return mt
}



Measured memory_bytes: 1232
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
 
int main(){
  	int n, m;
  	cin >> n >> m;
  	vector<int> ac(n), wa(n);
 
  	rep(i, m){
    	int p;
      	string s;
      	cin >> p >> s;
      	p--;
      	if(ac[p]) continue;
      	if(s == "AC"){
        	ac[p] = 1;
        } else {
        	wa[p]++;
        }
    }
  	
  	int AC = 0, WA = 0;
  	rep(i, n){
    	AC += ac[i];
      	if(ac[i]) WA += wa[i];
    }
  
  	 cout << AC << " " << WA << endl;
}

Measured memory_bytes: 1024
import sys
#DEBUG=True
DEBUG=False
if DEBUG:
    f=open("202007_2nd/D_input.txt")
else:
    f=sys.stdin
#from 2nd count
def cnt_func(num):
    cnt=0
    while num:
        num%=bin(num).count("1")
        cnt+=1
    return cnt+1
n=int(f.readline().strip())
s=f.readline().strip()
input_val=int(s,2)
input_one_count=s.count("1")
#Base value
zero_first=input_val%(input_one_count+1)
one_first=input_val%(input_one_count-1) if input_one_count>1 else 0
ans=0
for idx,emt in enumerate(s):
    p=n-idx-1
    if emt=="0": #inverted to "1"
        ans=cnt_func((zero_first+(pow(2,p,input_one_count+1)))%(input_one_count+1))
    else: #inverted to "0"
        if input_one_count>1:
            ans=cnt_func((one_first-(pow(2,p,input_one_count-1)))%(input_one_count-1))
        else:
            ans=0
    print(ans)
f.close()

Measured memory_bytes: 9560
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>

using namespace std;

//typedef
typedef long long LL;
typedef vector<LL> VL;
typedef vector<VL> VVL;
typedef vector<string> VS;
typedef pair<LL, LL> PLL;

//conversion
inline LL toLong(string s) {LL v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) LL((a).size())
#define EACH(i,c) for(auto i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define UNTIL(p) while(!(p))

//constant
const double EPS = 1e-5;
const double PI  = acos(-1.0);

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

#define PUTS(x) cout << (x) << endl;

int main(void){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin>>s;
    PUTS(s == "ABC" ? "ARC" : "ABC");
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi; 
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;

#define sz(a) int((a).size())
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
#define rall(c) (c).rbegin(),(c).rend()
#define ini(a, i) memset(a, i, sizeof(a))
#define contains(c, i) ((c).find(i) != (c).end())
#define present(i, c) (find(all(c), i) != (c).end())

#define trav(x, c) for(auto &x : c)
#define rep(i, n) for(int i = 0; i < n; i++)
#define repa(i, b, e) for(int i = (b)-((b)>(e)); i != (e)-((b)>(e)); i += 1-2*((b)>(e)))

#define debug(args...) { string s_(#args); replace(all(s_), ',', ' '); stringstream ss_(s_); istream_iterator<string> it_(ss_); cerr_(it_, args); }
void cerr_(istream_iterator<string> it) { (void) it; }
template<class T, class... Args> void cerr_(istream_iterator<string> it, T a, Args... args) { cerr << *it << " = " << a << endl; cerr_(++it, args...); }

template<class T, class S>  ostream& operator<<(ostream& os, const pair<T, S>& p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep; for (const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<class T> ostream& operator<<(ostream &os, const set<T> &s) { os << '{'; string sep; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<class T, class S> ostream& operator<<(ostream &os, const map<T, S> &m) { os << '{'; string sep; for (const auto &x : m) os << sep << x, sep = ", "; return os << '}'; }
template<class T, size_t size> ostream& operator<<(ostream &os, const array<T, size> &arr) { os << '{'; string sep; for (const auto &x : arr) os << sep << x, sep = ", "; return os << '}'; }

//=========================

void run_test() {
	int n; cin >> n;
    int ans = 0;
    repa(i, 1, n + 1) {
        int a; cin >> a;
        if(i % 2 && a % 2) ans++;
    }
    cout << ans << endl;
}

//=========================

int main() {
	ios::sync_with_stdio(false); cin.tie(nullptr);
	//int t_ = 1, t__; cin >> t__; while(t_ <= t__) { cout << "Case #" << t_++ << ": "; run_test(); }
	// int t_; cin >> t_; while(t_--) run_test();
	run_test();
	return 0;	
}


Measured memory_bytes: 3516
#include<stdio.h>
int main()
{
    int a,b,c,d;
    scanf("%d %d %d %d",&a,&b,&c,&d);
    if(a<b && c<d)
    {
        printf("%d",a+c);
    }
    else if(a<b && c>d)
    {
        printf("%d",a+d);
    }
    else if(a>b && c<d)
    {
        printf("%d",b+c);
    }
    else if(a>b && c>d)
    {
        printf("%d",b+d);
    }
     else if(a==b && c<d)
    {
        printf("%d",b+c);
    }
     else if(a==b && c>d)
    {
        printf("%d",b+d);
    }
     else if(a>b && c==d)
    {
        printf("%d",b+c);
    }
     else if(a<b && c==d)
    {
        printf("%d",a+c);
    }
     else
    {
        printf("%d",b+c);
    }
    return 0;

}


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

// Shrotening
#define fst first
#define snd second
#define pb push_back
#define mp std::make_pair

// Loop
#define FOR(i,a,b) for(auto i=(a);i<(b);++i)
#define RFOR(i,a,b) for(auto i=(a);i>=(b);--i)

#define REP(i,a) for(long i=0;i<(a);++i)
#define RREP(i,a) for(long i=(a);i>=0;--i)

#define EACH(i,a) for(auto (i)=(a).begin(),_END=(a).end();i!=_END;++i)
#define REACH(i,a) for(auto (i)=(a).rbegin(),_END=(a).rend();i!=_END;++i)

//Algorithm
#define ALL(a) (a).begin(), a.end()
#define RALL(a) (a).rbegin(), a.rend()
#define EXIST(a,x) ((a).find(x)!=(a).end())
#define SORT(a) std::sort((a).begin(), (a).end())
#define UNIQUE(a) std::sort((a).begin(), a.end()), a.erase(std::unique((a).begin(), a.end()), a.end());
#define SUM(a) std::accumulate((a).begin(), (a).end(), 0);

//Setting
#define OPT std::cin.tie(0);std::ios::sync_with_stdio(false);

//debug message
bool debug = true;
#define MSG(s)   if(debug){std::cout << s << std::endl;}
#define DEBUG(x) if(debug){std::cout << "debug(" << #x << "): " << x << std::endl;}

//alias
typedef long long LL;
typedef std::vector<char> VC;
typedef std::vector<int>  VI;
typedef std::vector<long> VL;
typedef std::vector<long long> VLL;

typedef std::vector< VC > VC2;
typedef std::vector< VI > VI2;
typedef std::vector< VL > VL2;
typedef std::vector< VLL > VLL2;

typedef std::pair<int,int> PII;

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

    std::map<char,int> map;
    for(auto c: S) {
        if(map.count(c) == 0) {
            map.insert(mp(c, 1));
        } else {
            map[c] += 1;
        }
    }

    bool flag = false;
    for(char c='a'; c<='z'; ++c) {
        if(map.count(c) == 0) {
            flag = true;
            std::cout << c << std::endl;
            break;
        }
    }
    if(!flag) {
        std::cout << "None" << std::endl;
    }
}

Measured memory_bytes: 512
# include <cstdio>
int N , C ;
int s[100000] , t[100000] , c[100000];
int sm[200002];
int tt[200002];
int main ()
{
	scanf ("%d%d" ,&N ,&C );
	for ( int i =0; i < N ; i ++)
	scanf ("%d%d%d" ,&s[ i ] ,&t[ i ] ,&c[ i ]);
	for ( int i =1; i <= C ; i ++)
	{
		for ( int j =0; j <200002; j ++) tt [ j ]=0;
		for ( int j =0; j < N ; j ++) if ( c [ j ]== i ) tt [ s [ j ]*2 -1]++ , tt [ t [ j ]*2] --;
		for ( int j =1; j <200002; j ++) tt [ j ]+= tt [j -1];
		for ( int j =0; j <200002; j ++) if ( tt [ j ] >0) sm [ j ]++;
	}
	int mx =0;
	for ( int j =0; j <200002; j ++) if ( mx < sm [ j ]) mx = sm [ j ];
	printf ("%d\n" , mx );
}


Measured memory_bytes: 2944
#include <stdlib.h>
#include <stdio.h>
#include <iostream> 
#include <string.h>
using namespace std;
int main(){
	char a[1001];
	char b[1001];
	char s;
	cin.get(a,1001);
	int w;
	scanf("%d",&w);
	for(int i=0;i<strlen(a);i=i+w){
		printf("%c",a[i]);
	}
	return 0;
} 

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc075/tasks/abc075_c
# グラフの橋という概念を扱う問題 #関節点と似た概念

# 螺旋本の用語を使えば、prenum[p]<lowest[u]となるedge(p,u)が橋

import sys
sys.setrecursionlimit(2**16 - 1)
from collections import defaultdict

INF = 10**9
N, M = list(map(int, input().split()))
G = defaultdict(list)
for _ in range(M):
    a, b = list(map(int, input().split()))
    G[a].append(b)
    G[b].append(a)

# graph Gがdefaultdictで定義された隣接リストであること前提とする。
# n_Vは頂点数
prenum = defaultdict(lambda: None)
parent = defaultdict(lambda: None)
lowest = defaultdict(lambda: None)
timer = 0  # dfsに入った順番を記録(prenum用)
is_visited = defaultdict(lambda: False)  # 木を作るために循環してはいけない
root = 0

# 1のフェーズ、prenumとparent,lowestについて確定していく。


def dfs(cur, prev):  # 次に訪問するノードが以前のノードprevではないことを識別する必要があるので引数がこうなっている
    # 関数に入るときにprenumとparentを確定してく
    global timer
    prenum[cur] = lowest[cur] = timer  # 教科書の説明とは違ってprenumは0スタートだが本質的な違いはない
    timer += 1
    parent[cur] = prev
    is_visited[cur] = True

    # 次のノードに訪問していく
    for nx in G[cur]:  # nxは次に探索すべきノード
        if (not is_visited[nx]):
            dfs(nx, cur)
            lowest[cur] = min(lowest[cur], lowest[nx]
                              )  # 子のlowestの最小値が取得できる
        elif nx != prev:  # 探索済みにつながる木以外の経路 いわゆるback-edge
            # back-edge先のノードの方とどっちが小さいか比較
            lowest[cur] = min(lowest[cur], prenum[nx])


dfs(1, None)

# 2のフェーズ bredgeを見つけていく
# 螺旋本の用語を使えば、prenum[p]<lowest[u]となるedge(p,u)が橋
ans = 0
for u, p in parent.items():
    if p is None:
        continue
    if prenum[p] < lowest[u]:
        ans += 1
print(ans)


Measured memory_bytes: 38384
# coding: utf-8
import sys
#from operator import itemgetter
sysread = sys.stdin.readline
#from heapq import heappop, heappush
#from collections import defaultdict
sys.setrecursionlimit(10**7)
#import math
#from itertools import combinations
def run():
    N,M = map(int, sysread().split())
    H = [0] + list(map(int, sysread().split()))
    to = [[] for _ in range(N+1)]
    for _ in range(M):
        a,b = map(int, sysread().split())
        to[a].append(b)
        to[b].append(a)

    ret = 0
    for i in range(1, N+1):
        val = H[i]
        no = False
        for k in to[i]:
            if val <= H[k]:
                no = True
                break
        if not no:

            ret += 1
    print(ret)

if __name__ == "__main__":
    run()

Measured memory_bytes: 30300
#include<bits/stdc++.h>
using namespace std;
typedef pair<int,int> P;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
#define MOD 1000000007
int n,m;
int a[100100],b[100100];
int main(){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	scanf("%d",&m);
	int ans = 0;
	for(int i=0;i<m;i++){
		scanf("%d",&b[i]);
		int l = 0, r = n;
		while(r-l>1){
			int mid = (l+r)/2;
			if(a[mid]>b[i])r=mid;
			else l=mid;
		}
		if(a[l]==b[i])ans++;
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3692
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int check = n%10;
    if(check==2||check==4||check==5||check==7||check==9)
    {
        cout<<"hon";
    }
    else if(check==0||check==1||check==6||check==8)
    {
        cout<<"pon";
    }
    else
    {
        cout<<"bon";
    }
}


Measured memory_bytes: 3604
#include <stdio.h>
#include <string.h>

int is_odd_Symmetry(const char str[], int len);
int is_even_Symmetry(const char str[], int len);

int main(void) {
    char str[100];
    int cnt = 0;
    int len;
    
    while(scanf("%s", str) != EOF) {
        len = (int)strlen(str);
        
        if(len == 1) {
            cnt++;
        } else {
            if(len % 2 != 0) {
                if(is_odd_Symmetry(str, len)) {
                    cnt++;
                }
            } else if(len % 2 == 0) {
                if(is_even_Symmetry(str, len)) {
                    cnt++;
                }
            }
        }
    }
    
    printf("%d\n", cnt);
    
    return(0);
}

int is_odd_Symmetry(const char str[], int len) {
    int i, range;
    int count = 0;
    
    range = len / 2;
    
    for(i = 0; i < range; i++) {
        if(str[i] == str[len - i - 1]) {
            count++;
        }
    }
    
    if(count == range) {
        return(1);
    }
    else {
        return(0);
    }
}

int is_even_Symmetry(const char str[], int len) {
    int i, range;
    int count = 0;
    
    range = (len / 2);
    
    for(i = 0; i < range; i++) {
        if(str[i] == str[len - i - 1]) {
            count++;
        }
    }
    
    if(count == range)
        return(1);
    else
        return(0);
}

Measured memory_bytes: 540
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define rep(i,a,n) for (int i=a;i<n;i++)
#define per(i,a,n) for (int i=n-1;i>=a;i--)
#define mp make_pair
#define fi first
#define se second
#define SZ(x) ((int)(x).size())
#define lli long long int
#define pii pair<int,int>
#define vii vector<pii>
#define pb push_back
#define eb emplace_back
#define em emplace
#define all(v)  v.begin(),v.end()
#define mod 1000000007
#define vi vector<int>
#define vl vector<lli>
#define vll vector<pair<lli,lli>>
#define pll pair<lli,lli>
#define vvi vector<vector<int>>
#define vvl vector<vector<lli>>
#define error(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#define tk(args...) take(args);
#define posLSB(X) __builtin_ctz(X)
#define num1bit(X) __builtin_popcount(X)
#define numlead0(X) __builtin_clz(X)
#define umreserve(X) X.reserve(32768); X.max_load_factor(0.25);
void err(istream_iterator<string> it) {} template<typename T, typename... Args> void err(istream_iterator<string> it, T a, Args... args) { cout << *it << " = " << a << "\n"; err(++it, args...);}
void take() {} template<typename T, typename... Args> void take( T & a, Args & ... args ) { cin>>a; take(args...); }
template<class T>
void printvec(vector<T> &a){
	for(T &x:a){
		cout<<x<<" ";
	}
	cout<<endl;
}
template<class T>
void printarr(T a[],lli n){
	for(lli i=0;i<n;i++){
		cout<<a[i]<<" ";
	}
	cout<<endl;
}
struct HASH{
  size_t operator()(const pair<int,int>&x)const{
    return (size_t) x.first * 37U + (size_t) x.second;
  }
};

#define endl "\n"

lli add(lli a, lli b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

lli mul(lli a, lli b) {
	return a * 1ll * b % mod;
}

inline bool setmin(lli &x, lli y) { return (y < x) ? x = y, 1 : 0; }
inline bool setmax(lli &x, lli y) { return (y > x) ? x = y, 1 : 0; }

lli power_mod(lli a,lli x){if(x==0) return 1;lli y=power_mod(a,x/2);lli ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
lli inv(lli a){return power_mod(a,mod-2);}
lli power(lli a, lli x){ if(x==0) return 1; lli y= power(a,x/2); lli ans=(y*y); if(x%2) ans*=a; return ans;}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	int n;
	cin>>n;
	string a;
	cin>>a;
	vector<int> dp(n+1);
	for(int i=1;i<=n;i++)dp[i]=1;
	for(int i=0;i<n-1;i++){
		vector<int> newdp(n+1);
		if(a[i]=='<'){
			for(int j=1;j<=i+2;j++){
				newdp[j]=add(dp[n],mod-dp[j-1]);
			}
		}
		else{	
			for(int j=1;j<=i+2;j++){
				newdp[j]=dp[j-1];
			}
		}
		for(int i=1;i<=n;i++)newdp[i]=add(newdp[i-1],newdp[i]);
		
		dp=newdp;
	}
	cout<<dp[n]<<endl;	
}


Measured memory_bytes: 256
#if 1

#include <bits/stdc++.h>
using namespace std;
int n;
long long d[20005];

struct XY
{
    int w,s,v;
}a[1005];

bool cmp(XY x,XY y)
{
    return x.w+x.s < y.w+y.s;
}

int main()
{
    scanf("%d",&n);
    for(int i = 1;i <= n;i++)
    {
        scanf("%d %d %d", &a[i].w, &a[i].s, &a[i].v);
    }
    sort(a+1,a+n+1,cmp);
    long long ans = 0;
    for(int i = 1;i <= n;i++)
    {
        for(int j = a[i].s;j >= 0;j--)
        {
            d[j+a[i].w] = max(d[j+a[i].w],d[j]+a[i].v);

        }
        //for(int j = 0;j <= 30;j++) cout << d[j] << " ";
        //cout << '\n';
    }
    for(int i = 0;i <= 20004;i++)
    {
        //cout << d[i] << " ";
        ans = max(ans,d[i]);
    }
    printf("%lld",ans);
}

#endif // 1

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,a[N],cnt[N];
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		cnt[a[i]]++;
	}
	int m=n;
	while (!cnt[m]) m--;
	int s=n-cnt[m];
	if (cnt[m-1]!=s)
		return puts("No"),0;
	if (m==n-1&&cnt[m]==n)
		return puts("Yes"),0;
	if (2*m-s>n||m<=s)
		return puts("No"),0; 
	puts("Yes");
	return 0;
}

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

const long long INF = 1LL<<60;
using ll = long long;
using P = pair<int,int>;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

class UnionFind{
public:
    // 親の番号を格納する
    // Parent -> -(the size)
    vector<int> Parent;
    
    // initialization
    // all nodes are roots
    UnionFind(int N){
        Parent =  vector<int>(N, -1);
    }
    
    int root(int A){
        if (Parent[A] < 0) return A; // A is in its own group.
        return Parent[A] = root(Parent[A]); // exchange parents
    }
    
    long long size(int A){
        return -Parent[root(A)];
    } 
    
    void connect(int A, int B){
        A = root(A);
        B = root(B);
        
        if (A == B) return; //already connected
        if (size(A) < size(B)) swap(A, B);
        
        Parent[A] += Parent[B]; //小さい方を大きい方にくっつける
        Parent[B] = A; //小さい方を大きい方にくっつける
    }
};
 
 
int main(){
    int N;
    cin >> N;
    
    vector<int> x(N),y(N);
    for (int i = 0; i < N; i++) cin >> x[i] >> y[i];
    
    using pint = pair<int, int>; //edgeを表現する
    using Edge = pair<long long, pint>; 
    vector<Edge> edges;
    
     // x 軸方向にソートして隣接している部分のみ
    vector<int> ids(N);
    iota(ids.begin(), ids.end(), 0); //???????
    sort(ids.begin(), ids.end(), [&](int i, int j) {return x[i] < x[j];});
    
    for (int i = 0; i+1 < ids.size(); i++){
        int u = ids[i];
        int v = ids[i+1];
        edges.push_back( Edge(x[v] - x[u], pint(u, v) ) );
    }
    
     // y軸方向にソートして隣接している部分のみ考える
    sort(ids.begin(), ids.end(), [&](int i, int j) {return y[i] < y[j]; } );
    for (int i = 0; i+1 < ids.size(); i++){
        int u = ids[i];
        int v = ids[i+1];
        edges.push_back( Edge(y[v] - y[u], pint(u, v)) );
    }
    
    sort(edges.begin(), edges.end()); //edge.costが小さい順にソートする
    UnionFind Uni(N);
    long long res = 0;
    
    for (auto e : edges){
        long long cost = e.first;
        int u = e.second.first;
        int v = e.second.second;
        if(Uni.root(u) == Uni.root(v)) continue;
        Uni.connect(u, v);
        res += cost;
    }
    
    cout << res << endl;
}

Measured memory_bytes: 7536
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {

		Scanner in = new Scanner(System.in);

		while(true) {

			int a = in.nextInt();
			String op = in.next();
			int b = in.nextInt();

			if(op.equals("+")) {
				System.out.println(a + b);
			}else if(op.equals("-")) {
				System.out.println(a - b);
			}else if(op.equals("*")) {
				System.out.println(a * b);
			}else if(op.equals("/")) {
				System.out.println(a / b);
			}else if(op.equals("?")) {
				break;
			}
		}
	}
}

Measured memory_bytes: 26304
#include<iostream>

using namespace std;

int main (){
	int a,b,c;
	cin >> a >> b >> c;
	
	if(c > a && c < b) {
		cout << "Yes" << endl;
	} else if (c < a && c >  b) {
		cout << "Yes" << endl;
	} else cout << "No" << endl;
	
	return 0; 
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define INF 1000000005
#define MOD 1000000007
#define EPS 1e-10
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define all(v) (v).begin(),(v).end()

using namespace std;

typedef pair<int,int>P;

const int MAX_N = 101;
const int MAX_M = 51;

ll comb[MAX_M][MAX_M];
double p[MAX_N];
int t[MAX_N],v[MAX_N];
double bp[MAX_N][MAX_M];
double prt[MAX_N];
double ans[MAX_N];

int main()
{
    int n,m,L;
	cin >> n >> m >> L;
	rep(i,n){
        cin >> p[i] >> t[i] >> v[i];
        p[i] /= 100.0;
	}
    comb[0][0] = 1;
    for(int i = 1;i<=m;i++){
        comb[i][0] = 1;
        for(int j=1;j<=i;j++){
            comb[i][j] = comb[i-1][j-1] + comb[i-1][j];
        }
    }
    rep(i,n){
        if(v[i] == 0){
            prt[i] = INF;
        }else{
            prt[i] = (double)L / v[i];
        }
    }
    rep(i,n){
        rep(j,m+1){
            bp[i][j] = 1.0;
            bp[i][j] *= comb[m][j];
            rep(k,j){
                bp[i][j] *= p[i];
            }
            rep(k,m-j){
                bp[i][j] *= (1.0 - p[i]);
            }
        }
    }
    rep(i,n){
        bool flag = false;
        ans[i] = 0.0;
        rep(j,m+1){
            double tm = bp[i][j];
            rep(k,n){
                double sm = 0.0;
                if(k != i){
                    if(prt[i] + j*t[i] >= prt[k]){
                        if(t[k] == 0){
                            flag = true;
                            break;
                        }
                        int c = (int)((prt[i] + j*t[i] - prt[k] + EPS) / t[k]) + 1;
                        if(c > m){
                            flag = true;
                            break;
                        }
                        for(int l=c;l<=m;l++){
                            sm += bp[k][l];
                        }
                    }else{
                        sm = 1.0;
                    }
                    tm *= sm;
                }
            }
            if(flag){
                break;
            }
            ans[i] += tm;
        }
        printf("%.10lf\n",ans[i]);
    }
	return 0;
}

Measured memory_bytes: 3292
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define de(x) cout<<#x<<"="<<x<<endl
const int N=2e5+7;
char s[N];
int a[27];
int dj[N];
bool gman(){
	for(int i=0;i<26;i++)
		if(a[i]==0)return false;
	return true;
}
int nextt[N][27];
int nw[27];
int main(){
    scanf("%s",&s);
    for(int i=0;i<26;i++)nw[i]=N-1;
    int len=strlen(s);
    int no=0;
    for(int i=len-1;i>=0;i--){
        dj[i]=no;
        a[s[i]-'a']=1;
        for(int j=0;j<26;j++){
            nextt[i][j]=nw[j];
        }
        nw[s[i]-'a']=i;
        if(gman()){
            memset(a,0,sizeof(a));
            no++;
        }
    }
    for(int i=0;i<26;i++){
        if(a[i]==0){
            printf("%c",i+'a');break;
        }
    }
    //de(no);
    if(no==0)return 0;
    int tmp;
    for(int i=0;i<26;i++){
        if(a[i]==0 ){
            tmp=nw[i];break;
        }
    }
    for(int i=no-2;i>=0;i--){
        for(int j=0;j<26;j++){
            if( dj[tmp]-1== dj[ nextt[tmp][j] ] ){
               // de(i);
                printf("%c",'a'+j);
                tmp=nextt[tmp][j];break;
               // de(tmp);
                //for(int k=0;k<26;k++){
                  // de( nextt[tmp][k]);
                   // de( dj[ nextt[tmp][j] ]);
                //}
            }
        }
    }
    for(int i=0;i<26;i++)
    if( nextt[tmp][i]==N-1){
        printf("%c",i+'a');
        return 0;
    }
}

/*
acrabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyzabcdefghijklmnopqrstuvwxyz

*/


Measured memory_bytes: 22272
d,d_=dict(),dict()
s,t=input(),input()
l=len(s)
for i in range(l):
    if s[i] not in d:
        d[s[i]]=[i]
    else:
        d[s[i]].append(i)
for i in range(l):
    if t[i] not in d_:
        d_[t[i]]=[i]
    else:
        d_[t[i]].append(i)
x=[sorted(i[1]) for i in list(d.items())]
y=[sorted(i[1]) for i in list(d_.items())]
x.sort()
y.sort()
print("Yes" if x==y else "No")

Measured memory_bytes: 29348
import java.util.Scanner;
import java.util.Set;
import java.util.TreeSet;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int K = sc.nextInt();
        Set<Integer> hash_set = new TreeSet<Integer>();
        for (int i = 0; i < K ; i++) {
            if (A + i <= B) {
                hash_set.add(A + i);
            }
        }
        for (int i = 0 ; i < K ; i++) {
            if(B - i>= A) {
                hash_set.add(B - i);
            }
        }
        for (Integer value : hash_set) {
            System.out.println(value);
        }
    }

}


Measured memory_bytes: 23124
//By Ralif Rakhmatullin
#include<iostream>
#include<fstream>
#include<string>
#include<cstring>
#include<math.h>
#include<cassert>
#include<iomanip>
#include<algorithm>
#include<vector>
#include<map>
#include<ctime>
#include<queue>
#include<stack>
#include<set>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<bitset>
#include<valarray>
#include<iterator>
#include<list>
#define ll long long
#define ull unsigned long long
#define mp make_pair
#define S second
#define ld long double
#define F first
#define y1 LOL
#define ld long double
#define pb push_back
#define len length
#define sz size
#define beg begin
const ll INF = (ll)1e18 + 123;
const int inf=(int)2e9 + 123; 
const int mod=1e9+7;
using namespace std;
int n, a[1011];
ll ev = 0, odd = 0;
bool is1 = 0, is2 = 0;
vector<int> v, ans;
int main(){
	unsigned int FOR;
 	asm("rdtsc" : "=A"(FOR));
  	srand(FOR);
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	//cout.tie(0);
	//freopen(".in","r",stdin);
	//freopen(".out","w",stdout);
	cin >> n;
	for(int i = 1; i <= n; i ++){
		cin >> a[i];
		if(a[i] >= 0){
			if(i % 2 == 1){
				odd += a[i];
				is1 = 1;
			}else{
				ev += a[i];
				is2 = 1;
			}
		}
	}
	if(!is1 && !is2){
		int mx = -inf, pos = 0;
		for(int i = 1; i <= n; i ++){
			if(a[i] > mx){
				mx = a[i];
				pos = i;
			}
		}
		cout << mx << "\n" << n - 1 << endl;
		while(n > pos){
			cout << n << endl;
			n --;
		}
		while(n > 1){
			cout << 1 << endl;
			n --;
		}
		return 0;
	}
	if(!is2 || odd > ev){
		cout << odd << endl;
		for(int i = 1; i <= n; i += 2){
			if(a[i] >= 0)
				v.pb(i);
		}
	}else{
		cout << ev << endl;
		for(int i = 2; i <= n; i += 2){
			if(a[i] >= 0)
				v.pb(i);
		}
	}
	int sz = (int)v.sz() - 1;
	while(n > v[sz]){	
		ans.pb(n);
		n --;
	}
	while(v[0] > 1){
		for(int j = 0; j <= sz; j ++){
			v[j] --;
		}
		ans.pb(1);
	}
	for(int i = 0; i < sz; i ++){
		while(v[i + 1] - v[i] > 2){
			ans.pb((v[i] + v[i + 1]) / 2);	
			for(int j = 1; j <= sz; j ++)
				v[j] -= 2;
		}	
		if(v[i] + 2 == v[i + 1]){
			ans.pb(v[i] + 1);
			v.erase(v.beg());
			sz --;
			for(int j = 0; j <= sz; j ++)
				v[j] -= 2;
			i --;
		}
	}
	cout << (int)ans.sz() << endl;
	for(auto x : ans)
		cout << x << endl;
	return 0;
}

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

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef pair <ll, ll> pll;
typedef pair <int, int> pii;

typedef tree <ll, null_type, less <ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// order_of_key(val): returns the number of values less than val
// find_by_order(k): returns an iterator to the kth largest element (0-based)

#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (ll)(a.size())
#define endl "\n"

template <class Ch, class Tr, class Container>
basic_ostream <Ch, Tr> & operator << (basic_ostream <Ch, Tr> & os, Container const& x) 
{
    os << "{ ";
    for(auto& y : x) 
    {
        os << y << " ";
    }
    return os << "}";
}

template <class X, class Y>
ostream & operator << (ostream & os, pair <X, Y> const& p) 
{
    return os << "[" << p.ff << ", " << p.ss << "]";
}

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

    return gcd(b, a%b);
}

ll modexp(ll a, ll b, ll c)
{   
    a%=c;

    ll ans = 1;

    while(b)
    {
        if(b&1)
        {
            ans = (ans*a)%c;
        }

        a = (a*a)%c;
        b >>= 1;
    }

    return ans;
}

ll nxt()
{
    ll x;
    cin >> x;
    return x;
}

const ll L = 1e5+5;

void solve()
{
    string s;
    cin >> s;

    if(s[2] == s[3] && s[4] == s[5])
    {
        cout << "Yes" << endl;
    }   

    else
    {
        cout << "No" << endl;
    }
}

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    
    ll T = 1;
    // T = nxt();

    while(T--)
    {
        solve();
    }

    return 0;
}

Measured memory_bytes: 256