akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>   
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
using namespace std;
#define i64  long long
#define int  long long
 
#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
#define MEM_SIZE 10000
#define DEBUG_OUT true

// int DP[MEM_SIZE][MEM_SIZE] = {0};
// int GMEM[MEM_SIZE][MEM_SIZE] = {0};
template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return;std::cout << e << std::endl;}
template<class T> void DEBUG(string str, T e){if(DEBUG_OUT == false)return;std::cout <<str << ">>" << e << std::endl;}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){ std::cout << e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == 1)return;for(const auto& v : vv){ DEBUG(v); } }
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
template<typename T> void SORT_(std::vector<T>& v,bool GREATER = 0){if(GREATER == 0)sort(v.begin(),v.end());else{sort(v.begin(),v.end(),std::greater<T>());}}

//CODE
void solve(void)
{
  int R,G,B;
  cin>>R>>G>>B;
  int X= 100*R + 10*G + B;
  if(X%4 == 0)
  {
    cout<<"YES"<<endl;
  }
  else
  {
    cout<<"NO"<<endl;
  }
  return;
}


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

  std::cout << std::fixed;
  std::cout << std::setprecision(9);
  solve();

 
  return 0;
}

Measured memory_bytes: 256
while True:
    m,f,r = [int(x) for x in input().split()]
    if (m,f,r)==(-1,-1,-1): break
    s_mf = m + f
    if   m < 0 or f < 0: print('F')
    elif s_mf <  30:     print('F')
    elif s_mf >= 80:     print('A')
    elif s_mf >= 65:     print('B')
    elif s_mf >= 50:     print('C')
    elif r    >= 50:     print('C')
    else:                print('D')

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

int main() {
	int N, l, r, ans;
	cin >> N;
	ans = 0;
	for (int i=0; i < N; i++) {
		cin >> l >> r;
		ans += (r - l + 1);
	}
	cout << ans << endl;
}


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

template<long long mod>
class modint{
private:
  long long a;
public:
  constexpr modint(const long long x = 0) noexcept : a(x%mod) {}
  constexpr long long& value() noexcept { return a; }
  constexpr const long long& value() const noexcept { return a; }
  constexpr modint operator+(const modint rhs) const noexcept {
    return modint(*this) += rhs;
  }
  constexpr modint operator-(const modint rhs) const noexcept {
    return modint(*this) -= rhs;
  }
  constexpr modint operator*(const modint rhs) const noexcept {
    return modint(*this) *= rhs;
  }
  constexpr modint operator/(const modint rhs) const noexcept {
    return modint(*this) /= rhs;
  }
  constexpr modint& operator+=(const modint rhs) noexcept {
    a += rhs.a;
    if(a >= mod) a -= mod;
    return *this;
  }
  constexpr modint &operator-=(const modint rhs) noexcept {
    if(a < rhs.a) a += mod;
    a -= rhs.a;
    return *this;
  }
  constexpr modint& operator*=(const modint rhs) noexcept {
    a = a*rhs.a%mod;
    return *this;
  }
  constexpr modint& operator/=(modint rhs) noexcept {
    long long k = mod-2;
    while(k > 0){
      if(k&1){
        *this *= rhs;
      }
      rhs *= rhs;
      k /= 2;
    }
    return *this;
  }
  friend ostream& operator<<(ostream &os, const modint &X){
    return os << X.a;
  }
  friend istream& operator>>(istream &is, modint &X){
    is >> X.a;
    X.a %= mod;
    if(X.a < 0) X.a += mod;
    return is;
  }
};

template<typename T>
T power(T x, long long k){
  T ret{1};
  while(k > 0){
    if(k&1) ret *= x;
    x *= x;
    k /= 2;
  }
  return ret;
}


int main(){
  using mint = modint<1000000007>;
  int N;
  cin >> N;
  mint ans = power<mint>(10,N) - power<mint>(9,N)*2 + power<mint>(8,N);
  cout << ans << endl;
}


Measured memory_bytes: 3632
import sys
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()

def main():
    N = II()
    ans = 180 * (N - 2)
    return ans

print(main())

Measured memory_bytes: 3064
#include <algorithm>
#include <fstream>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <math.h>
using namespace std;

int main(){
 //   std::ifstream in("input.txt");
 //   std::cin.rdbuf(in.rdbuf());
    int p,q,r;

    cin >> p >> q >> r;

    int time=min(p+q,p+r);
    time = min(time,q+r);

    cout << time <<endl;
}

Measured memory_bytes: 256
#include <vector>
#include <map>
#include <string>
#include <iostream>
#include <cmath>
#include <random>
#include <cctype>
#include <cstdlib>
#include <algorithm>
using namespace std;
#define MK make_pair
#define PB push_back
#define VI vector<int>
#define VII vector<int,int>
#define MSI map<string,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define W1 while(1);
const int MOD = 1000000007;
int main()
{
	string S,T,rest;
	cin >> S >> T;
	if ((S.size() + T.size()) % 2 != 0)
	{
		rest = S.at(S.size()-1);
		S.erase(--S.end());
	}
	REP(i, S.size() )
	{
		cout << S.at(i);
		cout << T.at(i);
	}
	if (rest.size() != 0)cout << rest;
	cout << endl;
	return 0;
}

Measured memory_bytes: 256
// Born Sinner
// old but im not that old
// fuck all you hoes get a grip
import java.util.*;
import java.lang.*;
import java.io.*;
import java.math.BigInteger;

public class Main
{
    static class FastReader{
        BufferedReader br;
        StringTokenizer st;
        public FastReader(){
            br = new BufferedReader(new InputStreamReader(System.in));
        }
        String next(){
            while(st == null || !st.hasMoreElements()){
                try{
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e){
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
        int nextInt(){
            return Integer.parseInt(next());
        }
        long nextLong(){
            return Long.parseLong(next());
        }
        double nextDouble(){
            return Double.parseDouble(next());
        }
        String nextLine(){
            String str = "";
            try{
                str = br.readLine();
            } catch (Exception e){
                e.printStackTrace();
            }
            return str;
        }
    }
    static int modPower(int x, int y, int mod){
        int res = 1;
        x %= mod;
        if(x==0) return 0;
        while(y>0){
            if(y%2==1){
                res = (res*x)%mod;
            }
            y = y>>1;
            x = (x*x)%mod;
        }
        return res;
    }
    static class pair<T1, T2>{
        T1 first;
        T2 second;
        pair(T1 first, T2 second){
            this.first = first;
            this.second = second;
        }
    }
    static int gcd(int a, int b){
        if(b == 0) return a;
        return gcd(b, a%b);
    }

    public static void main (String[] args) throws java.lang.Exception
    {
        FastReader in = new FastReader();
        int n = in.nextInt();
        int[] a = new int[n], b = new int[n];
        for(int i = 0; i < n; i++) {
            a[i] = in.nextInt();
            b[i] = in.nextInt();
        }
        boolean ok = false;

        int i = 0;
        while(i < n){
            int j = i + 1;
            if(a[i] == b[i]) {
                while(j < n && a[j] == b[j]) j++;
            }

            if((j-i) >= 3) {
                ok = true; break;
            }
            i = j;
        }
        System.out.println(ok?"Yes":"No");
    }
}


Measured memory_bytes: 32800
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1LL << 30;
int MOD = 1e9+7;
main(){
    string S;
    int N;
    cin >> S >> N;
    set<string> st;
    for(int i = 0;i < S.size();i++){
        for(int j = 1;j <= 5 && i+j <= S.size();j++){
            st.insert(S.substr(i,j));
        }
    }
    auto itr = st.begin();
    for(int i = 0;i < N-1;i++)itr++;
    cout << *itr << endl;
}

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    string s1 = "", s2 = "";
    for(int i = 0; i < a; ++i){
        s2 += to_string(b);
    }
   for(int i = 0; i < b; ++i){
        s1 += to_string(a);
    }
    if(s1 <= s2){
        cout << s1 << endl;
    }
    else{
        cout << s2 << endl;
    }
}


Measured memory_bytes: 3684
let content = '';
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', buf => {
  content += buf;
});

process.stdin.on('end', () => {
  let [nums, , ...questions] = content.trim().split('\n');
  nums = nums.split(' ').map(n => parseInt(n, 10));
  questions = questions.map(q => q.split(' ').map(n => parseInt(n, 10)));
  const dice = createDice(nums);
  questions
    .map(q => resolve(dice, q))
    .map(dice => dice.right[1])
    .forEach(n => console.log(n));
});

const resolve = (dice, [top, front]) => {
  const dirs = ['N', 'W', 'S', 'E'];
  while (dice.top[0] !== top || dice.top[3] !== front) {
    const dir = dirs[Math.floor(Math.random() * dirs.length)];
    dice = roll(dice, dir);
  }

  return dice;
};

const createDice = nums => ({
  top: [1, 5, 6, 2].map(n => nums[n - 1]),
  right: [1, 3, 6, 4].map(n => nums[n - 1]),
});

const roll = (dice, dir) => {
  switch (dir) {
    case 'W': {
      return Object.assign({}, dice, {
        top: [dice.right[1], dice.top[1], dice.right[3], dice.top[3]],
        right: dice.right.slice(1).concat([dice.right[0]]),
      });
    }
    case 'E': {
      return Object.assign({}, dice, {
        top: [
          dice.right[dice.right.length - 1],
          dice.top[1],
          dice.right[1],
          dice.top[3],
        ],
        right: [dice.right[3]].concat(dice.right.slice(0, -1)),
      });
    }
    case 'S': {
      return Object.assign({}, dice, {
        top: dice.top.slice(1).concat([dice.top[0]]),
        right: [dice.top[1], dice.right[1], dice.top[3], dice.right[3]],
      });
    }
    case 'N': {
      return Object.assign({}, dice, {
        top: [dice.top[3]].concat(dice.top.slice(0, -1)),
        right: [dice.top[3], dice.right[1], dice.top[1], dice.right[3]],
      });
    }
  }
};


Measured memory_bytes: 16652
#C

from math import factorial
MOD = 10**9 + 7

n,m = (int(num) for num in input().split())

if n-m == 1 or n-m == -1:
    print(((factorial(n)%MOD)*(factorial(m)%MOD))%MOD)
elif n==m:
    print(((factorial(n)%MOD)*(factorial(m)%MOD)*2)%MOD)
else:
    print(0)

Measured memory_bytes: 46960
/*
ID: anonymo14
TASK: wormhole
LANG: C++                 
*/
#include<bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<pair<int,int>> vpii;

#define F first
#define S second
#define PU push
#define PUF push_front
#define PUB push_back
#define PO pop
#define POF pop_front
#define POB pop_back

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

#define MOD 1000000007

void solve(int test_case) {//233
	int n;
	cin>>n;
	int cnt = 0;
	int last = 0;
	REP(i,1,n) {
		int val;
		cin>>val;
		if(val>=last) {
			last = val;
			cnt++;
		}
	}
	cout<<cnt;
}

int main() {
	
	////// FILE BASED IO////
	//freopen("wormhole.in", "r", stdin);
	//freopen("wormhole.out", "w", stdout);
	///////////////
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	int t=1;
	//cin>>t;
	REP(i,1,t) {
		solve(i);
	}
	return 0;
}	


Measured memory_bytes: 3656
#include <algorithm>
#include <iostream>
#include <cstring>
#include <cstdio>

using namespace std;

int main()
{
    if (fopen("Test.INP", "r"))
        freopen("Test.INP", "r", stdin);

    int n;
    cin >> n;

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

    int dp[n];
    memset(dp, 0, sizeof(dp));
    dp[0] = 0;
    for (int i = 1; i < n; ++i)
    {
        dp[i] = dp[i - 1] + abs(a[i] - a[i - 1]);
        if (i > 1) dp[i] = min(dp[i], dp[i - 2] + abs(a[i] - a[i - 2]));
    }

    cout << dp[n - 1];
    return 0;
}


Measured memory_bytes: 1024
n = int(input())
a = [int(x) for x in input().split()]
for i in range(n):
    a[i] -= i+1

#中央値を求める
a.sort()
if len(a) % 2 == 0:
    c = (a[len(a)//2] + a[len(a)//2-1]) // 2
else:
    c = a[len(a)//2]

def hoge(b):
    v = 0
    for x in a:
        v += abs(x-b)
    return v

print(hoge(c))

Measured memory_bytes: 26180
#include <iostream>
#include <stdio.h>

using namespace std;

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

    int d = a / b, r = a % b;
    double f = (double)a / (double)b;

    printf("%d %d %lf\n", d, r, f);

    return 0;
}


Measured memory_bytes: 3204
#include<iostream>
#include<stdlib.h>
#include<stdio.h>
#include<bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
/*---------------------DEBUGGING--------------------------------------------*/
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif
/*-------------------------------------------------------------------------------------*/
//#define mp make_pair
#define pb push_back
#define ll long long
#define pii pair<int,int>
#define pcc pair<char,char>
#define F first
#define S second
#define int long long
#define pi 3.141592653589793238462643383279502
#define M  1000000007
#define rep(i,a,n) for(int i=a;i<n;i++)
#define INF 10000000000000
#define N 200005
#define vi vector<int>
#define all(v) v.begin(),v.end()
#define endl "\n"
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

signed main()
{
   ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
   int n,d;
   cin>>n>>d;
   int cnt=0;
   d*=d;
   for(int i=0;i<n;i++)
   {
       int x,y;
       cin>>x>>y;
       x*=x;
       y*=y;
       x+=y;
       if(x<=d)cnt++;
   }
   cout<<cnt<<endl;
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
using namespace std;
using lint = long long;
using P = pair<int, int>;
using vec = vector<int>;
using mat = vector<vector<int>>;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define endl "\n"

constexpr int MOD = 1000000007;
const int INF = 1 << 30;

int main() {
    int x, y;
    cin >> x >> y;
    cout << x + y/2 << endl; 
    return 0;
}

Measured memory_bytes: 256
#include<set>
#include<map>
#include<cmath>
#include<ctime>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<random>
#include<cstdlib>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<unordered_map>
#define endl "\n"
#define fi first
#define se second
#define db double
#define gcd __gcd
#define pb push_back
#define mp make_pair
#define lowbit(x) (x & (-x))
#define PII  pair<int, int> 
#define all(x) x.begin(), x.end()
#define debug(x) cout << #x << " = " << x << endl
#define rep(i, a, b) for(__typeof(b) i = a; i <= (b); i++)
#define Rep(i, a, b) for(__typeof(a) i = a; i >= (b); i--)
#define FAST ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
template<class T> inline T qmin(T a, T b) { return a < b ? a : b; }
template<class T> inline T qmax(T a, T b) { return a > b ? a : b; }
typedef long long ll;
typedef unsigned long long ull;
const db eps = 1e-9;
const db PI = acos(-1);
const int inf = 0x3f3f3f3f;
const int mod = (int)1e9 + 7;
const int maxn = (int)3e3 + 5;//remember to modify it, No RE or MLE
const ll INF = 0x3f3f3f3f3f3f3f3f;
using namespace std;

ll qpow(ll x, ll y) { ll ret = 1; for( ; y; y >>= 1, x = (x * x) % mod) if(y & 1) ret = (ret * x) % mod; return ret; }

inline int read(){
	char ch = getchar();
	int x = 0, f = 1;
	while(ch < '0' || ch > '9'){
		if(ch == '-') f = -1;
		ch = getchar();
	}
	while('0' <= ch && ch <= '9'){
		x = x * 10 + ch - '0';
		ch = getchar();
	}
	return x * f;
}

ll dp[maxn][maxn], sum[maxn];
int a[maxn];
int n;

ll dfs(int l, int r){
	if(dp[l][r] != INF) return dp[l][r];
	ll S = sum[r] - sum[l-1];
	dp[l][r] = max(S - dfs(l + 1, r), S - dfs(l, r - 1));
	return dp[l][r];
}

int main()
{
	n = read();
	rep(i, 1, n) a[i] = read(), sum[i] = sum[i-1] + a[i];
	memset(dp, 0x3f, sizeof dp);
	rep(i, 1, n) dp[i][i] = a[i];
	dfs(1, n);
	printf("%lld\n", dp[1][n] - (sum[n] - dp[1][n]));
	return 0;
}

Measured memory_bytes: 70912
let n = Int(readLine()!)!
var words: [String] = []
var ok = true
for _ in 0..<n { words.append(readLine()!) }
for i in 0..<n-1 {
  let endIndex = words[i].index(before: words[i].endIndex)
  let end = words[i][endIndex]
  let start = words[i+1][words[i+1].startIndex]
  ok = (end == start && ok)
}
if Set(words).count == words.count && ok {
  print("Yes")
} else {
  print("No")
}

Measured memory_bytes: 8008
import numpy as np

n = int(input())
h = np.array([int(i) for i in input().split()])

err = 0
f = 0
for i in range(n-1):
  t = h[i+1] - h[i]
  if t>=-1 and f>=-1 and not(t==-1 and f==-1):
    pass
  else:
    err = 1
    break
    
  if t!=0:
    f = t
  
if err==1:
  print('No')
else:
  print('Yes')

Measured memory_bytes: 23132
#include <iostream>
#include <map>
using namespace std;
map<int,long long> mp;
map<int,long long>::iterator it;

int main(){
	long long n,k;
	int a,b;
	
	cin >> n >> k;
	while(n--){
		cin >> a >> b;
		mp[a]+=b;
	}
	for(it = mp.begin();it!=mp.end();it++){
		if(k>it->second) k-=it->second;
		else{
			cout << it->first << endl;
			return 0; 
		}
	}
} 

Measured memory_bytes: 4224
t1, t2, r1, r2 = gets.split.map(&:to_i)
if r1 != -1 && r2 != -1
  puts r1 > r2 ? "Alice"
     : r1 < r2 ? "Bob"
     :           "Draw"
else
  puts t1 < t2 ? "Alice"
     : t1 > t2 ? "Bob"
     :           "Draw"
end



Measured memory_bytes: 6872
#include <iostream>
#include <vector>
#include <cstdlib>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <string>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vvi = vector<vi>; // intの2次元の型に vvi という別名をつける
using vl = vector<ll>;  // long longの1次元の型に vl という別名をつける
using vvl = vector<vl>; // long longの2次元の型に vvl という別名をつける
int MOD = 1000000007; //10^9 + 7

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; }

// 無限大の値
const ll  lINF = 1LL << 60;
const int iINF = 1 << 29;

int main(void){
  int x,t;
  cin  >> x >> t;
  cout << (x-t <= 0 ? 0 : x-t) << endl;
  return 0;
} 

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

int64_t popcount(int64_t n){
  int64_t ret = 0;
  while(n != 0){
    ret++;
    bitset<25> a(n);
    int C = a.count();
    n = n %C;
  }
  return ret;
}

//繰り返し二乗法
int64_t powmod(int64_t x, int64_t n, int64_t mod) { 
  if(mod == 0){
    return 0;
  }
  int64_t ans = 1;
  while (n > 0) {
    if ((n & 1) == 1) {
      ans = ans * x;
      ans %= mod;
    }
    x = x * x;//一周する度にx, x^2, x^4, x^8となる
    x %= mod;
    n >>= 1; //桁をずらす n = n >> 1
  }
  return ans %mod;
}

int main(){
  int N;
  cin >> N;
  string S;
  cin >> S;
  int cnt = 0;
  for(int i=0; i<N; i++){
    if(S[i] == '1'){
      cnt++;
    }
  }
  
  int64_t amari_plus = 0;
  int64_t amari_minus = 0;
  
  for(int i=0; i<N; i++){
    if(S[i] == '1'){
      amari_plus += powmod(2,N-i-1,cnt+1);
      if(cnt != 0){
        amari_minus += powmod(2,N-i-1,cnt-1);
      }
    }
  }
  
  amari_plus %= cnt+1;
  if(cnt > 1){
    amari_minus %= cnt-1;
  }
  
  for(int i=0; i<N; i++){
    if(S[i] == '1'){
      if(cnt == 1){
        cout << 0 << endl;
        continue;
      }
      int64_t x = powmod(2,N-i-1,cnt-1);
      x = amari_minus - x;
      if(x < 0){
        x += cnt-1;
      }
      cout << popcount(x) + 1 << endl;
    }
    else{
      int64_t x = powmod(2,N-i-1,cnt+1);
      x = amari_plus + x;
      x %= cnt+1;
      cout << popcount(x) + 1 << endl;
    }
  }
}

Measured memory_bytes: 3752
n = input()
# 1回の処理で、1文字減、連続部分1増
# 最悪でも「len(n)/2」回で終了

# 全ての文字に対し
# それぞれで統一する場合を全部試しても良さそう

score = 1000
left = 0
for i in range(len(n)):
    alpha = n[i] # i文字目で統一する場合を考える
    _left = 0
    left = 0
    for j in range(len(n)):
        if n[j] != alpha:
            _left += 1
        else:
            left = max(left, _left)
            _left = 0
    left = max(left, _left)
    score = min(score, left)
print(score)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
char in[120];
pair<pair<string,int>,int> p[110];
int main(){
  int a;scanf("%d",&a);
  for(int i=0;i<a;i++){
    int t;scanf("%s%d",in,&t);
    string tmp=in;
    p[i]=make_pair(make_pair(in,-t),i);
  }
  sort(p,p+a);
  for(int i=0;i<a;i++){printf("%d\n",p[i].second+1);

  }
}


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

// 型定義
typedef long long ll;
typedef pair<ll, ll> P;

// forループ
#define REP(i,n) for(ll i=0; i<(ll)(n); ++i)

// 定数宣言
const int INF = 1e9;
const int MOD = 1e9+7;
const ll LINF = 1e18;

// グラフ表現
using Graph = vector<vector<int>>;

// グラフの辺表現
using Edge = map<pair<int,int>,int>;

// n次元配列の初期化。第２引数の型のサイズごとに初期化していく。
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

// 最大公約数
ll gcd(ll a,ll b){
   if (a%b == 0) return(b);
   else return(gcd(b, a%b));
}

// 最小公倍数
ll lcm(ll a, ll b){
    return a*b/gcd(a, b);
}

// pairsをsecond優先キーとして昇順ソート
bool compare_by_b(pair<ll, ll> a, pair<ll, ll> b) {
    if(a.second != b.second){
        return a.second < b.second;
    }else{
        return a.first < b.first;
    }
}

int main()
{
    cout << fixed << setprecision(15);
    ll N;
    cin >> N;

    vector<P> A(N);

    REP(i, N){
        ll X, L;
        cin >> X >> L;
        A[i].first = X-L;
        A[i].second = X+L;
    }

    // 2つ目のキーで昇順ソート
    sort(A.begin(), A.end(), compare_by_b);

    ll ans = 0;
    ll right = 0;
    REP(i, N){
        if(i==0){
            right = A[0].second;
            ans++;
            continue;
        }
        if(right <= A[i].first){
            right = A[i].second;
            ans++;
        }
    }
    
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define int long long
#define INF 1e+18
using namespace std;

unsigned int randxor(){
	static unsigned int x = 1239732;
	x ^= (x << 13);
	x ^= (x >> 7);
	x ^= (x << 17);
	return x;
}

struct node{
	int dat,val,size;
	node *lch,*rch;
	node(int v){
		dat = v;
		val = v;
		lch = 0;
		rch = 0;
		size = 1;
	}
};

int siz(node *t){
	if(!t) return 0;
	return t->size;
}

int dat(node *t){
	if(!t) return INF;
	return t->dat;
}

node* update(node *t){
	t->size = siz(t->lch) + siz(t->rch) + 1;
	t->dat = min(t->val,min(dat(t->lch),dat(t->rch)));
	return t;
}

node* merge(node *x,node *y){
	if(!x) return y;
	if(!y) return x;
	if(randxor() % (x->size + y->size) < x->size){
		x->rch = merge(x->rch,y);
		return update(x);
	}else{
		y->lch = merge(x,y->lch);
		return update(y);
	}
}

typedef pair<node*,node*> P;

P split(node *x,int k){
	if(!x) return P(0,0);
	if(k <= siz(x->lch)){
		P tmp = split(x->lch,k);
		x->lch = tmp.second;
		return P(tmp.first,update(x));
	}else{
		P tmp = split(x->rch,k - siz(x->lch) - 1);
		x->rch = tmp.first;
		return P(update(x),tmp.second);
	}
}

void insert(node **x,int k,node *v){
	P tmp = split(*x,k);
	*x = merge(tmp.first,merge(v,tmp.second));
}

node* erase(node **x,int k){
	P p1 = split(*x,k),p2 = split(p1.second,1);
	*x = merge(p1.first,p2.second);
	return p2.first;
}

void update(node **x,int k,int v){
	P p1 = split(*x,k),p2 = split(p1.second,1);
	p2.first->val = v;
	update(p2.first);
	*x = merge(p1.first,merge(p2.first,p2.second));
}

int get(node **x,int l,int r){
	P p1 = split(*x,l),p2 = split(p1.second,r - l);
	int ret = p2.first->dat;
	*x = merge(p1.first,merge(p2.first,p2.second));
	return ret;
}

signed main(){
	int n,q;
	node *tree = 0;
	cin >> n >> q;
	for(int i = 0;i < n;i++){
		int a;
		cin >> a;
		tree = merge(tree,new node(a));
	}
	for(int i = 0;i < q;i++){
		int x,l,r;
		cin >> x >> l >> r;
		if(!x) insert(&tree,l,erase(&tree,r));
		else if(x == 1) cout << get(&tree,l,r + 1) << endl;
		else update(&tree,l,r);
	}
	return 0;
}


Measured memory_bytes: 12468
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int pntT = 0;
		int pntH = 0;
		int n = sc.nextInt();
		for(int i = 0; i < n; i++) {
			String strT = sc.next();
			String strH = sc.next();
			if(strT.compareTo(strH) > 0 ) {
				pntT += 3;
			} else if(strT.compareTo(strH) == 0 ) {
				pntT += 1;
				pntH += 1;
			} else if(strT.compareTo(strH) < 0 ) {
				pntH += 3;
			}
		}
		System.out.println(pntT + " " + pntH);
		
		sc.close();
	}
	
}


Measured memory_bytes: 29320
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop, heapify
from bisect import bisect_right, bisect_left
import random
from itertools import permutations, accumulate, combinations, product
import sys
import string
from bisect import bisect_left, bisect_right
from math import factorial, ceil, floor, gamma, log
from operator import mul
from functools import reduce


sys.setrecursionlimit(2147483647)
INF = float('INF')
def LI(): return list(map(int, sys.stdin.buffer.readline().split()))
def I(): return int(sys.stdin.buffer.readline())
def LS(): return sys.stdin.buffer.readline().rstrip().decode('utf-8').split()
def S(): return sys.stdin.buffer.readline().rstrip().decode('utf-8')
def IR(n): return [I() for i in range(n)]
def LIR(n): return [LI() for i in range(n)]
def SR(n): return [S() for i in range(n)]
def LSR(n): return [LS() for i in range(n)]
def SRL(n): return [list(S()) for i in range(n)]
def MSRL(n): return [[int(j) for j in list(S())] for i in range(n)]
mod = 10 ** 9 + 7


n = I()
X = LI()
d = [0] * (n - 1)
for i in range(n - 1):
    d[i] = (X[i + 1] - X[i]) % mod



fac = [1] * (n + 1)
inv = [1] * (n + 1)
for j in range(1, n + 1):
    fac[j] = fac[j-1] * j % mod



for i in range(1, n):
    inv[i] = pow(i, mod - 2, mod)




L = [fac[n - 1] * inv[i] % mod for i in range(1, n)]
for k in range(1, n - 1):
    L[k] = (L[k] + L[k - 1]) % mod




ret = 0
for j in range(n - 1):
    ret = (ret + L[j] * d[j] % mod) % mod


print(ret % mod)








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

#include <fstream>
using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;
  /*
     ifstream in("input.txt");
     cin.rdbuf(in.rdbuf());
  //*/
  int H, W;
  cin >> H >> W;
  vector<string> S(H);
  bool bad = false;
  for(int i = 0; i < H; i++) cin >> S[i];
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(S[i][j] == '#'){
        if(!((i > 0 && S[i-1][j] == '#') || (i < H-1 && S[i+1][j] == '#')|| (j > 0 && S[i][j-1] == '#') || (j < W-1 && S[i][j+1] == '#'))) bad = true;
      }
    }
  }
  if(bad) cout <<"No"<<endl;
  else cout << "Yes" <<endl;
}


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

typedef long long ll;

#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 trav(a,x) for (auto& a : x)

#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert

const char nl = '\n';

int main() {
	ios_base::sync_with_stdio(0); cin.tie(0);
    int s = 0;
    int c[9]; 
    F0R(i, 9) {
        cin >> c[i];
        s += c[i];
    }
    if (s == (c[0] + c[4] + c[8]) * 3) cout << "Yes" << nl;
    else cout << "No" << nl;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
 
int main() {
  string str;
  cin >> str;
  int counter = 0;

  for(int i = 0; i < str.size() - 1; i++){
      if(str.at(i) == 'B'){
        if(str.at(i+1) == 'W'){
          counter = counter + 1;
        }
      }else if(str.at(i) == 'W'){
        if(str.at(i+1) == 'B'){
          counter = counter + 1;
        }     
      }
    }
 
  	cout << counter << endl;
 
}

Measured memory_bytes: 512
import collections
import sys
import resource
sys.setrecursionlimit(1000000)

n, m = map(int, input().split(' '))

f = [x for x in range(n)]

def find(x):
  if f[x] == x:
    return x
  root = find(f[x])
  f[x] = root
  return root

for i in range(m):
  a, b = map(int, input().split(' '))
  a -= 1
  b -= 1
  if find(a) != find(b):
    f[find(a)] = find(b)

for i in range(n):
  find(i)
  
print(max(collections.Counter(f).values()))


Measured memory_bytes: 174528
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Diagnostics;

namespace AtCoder
{
    class Program
    {
        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }

        const int MOD = 1000000007;

        static long Solve(int N, int M, bool[] broken)
        {
            long[] dp = new long[N + 1];
            dp[N] = 1;
            for (int i = N - 1; i >= 0; --i)
            {
                if (!broken[i])
                {
                    long sum = 0;
                    if (i + 1 <= N) { sum = (sum + dp[i + 1]) % MOD; }
                    if (i + 2 <= N) { sum = (sum + dp[i + 2]) % MOD; }
                    dp[i] = sum;
                }
            }
            return dp[0];
        }

        static void Main(string[] args)
        {
            int[] V = ReadInts();
            int N = V[0], M = V[1];
            bool[] broken = new bool[N];
            for (int i = 0; i < M; ++i)
            {
                int a = ReadInt();
                broken[a] = true;
            }
            Console.WriteLine(Solve(N, M, broken));
        }
    }
}


Measured memory_bytes: 13792
import sys
sys.setrecursionlimit(10**9)

n,m = map(int, input().split())

f = [[] * (n+1) for i in range(n+1)]

def dfs(i):
  searched[i] = 1
  ans = 1
  for j in f[i]:
    if searched[j] == 0:
      ans += dfs(j)
  return ans

for i in range(m):
  a,b = map(int, input().split())
  f[a].append(b)
  f[b].append(a)

searched=[0]*(n+1)
ans = 0
for i in range(1, n+1):
  # iの友達の数
  if searched[i] == 0:
    ans = max(ans, dfs(i))
print(ans)

Measured memory_bytes: 210844
# include <bits/stdc++.h>
# define int long long
# define endl "\n"
using namespace std;

const int SIZE = 1e7 + 1;
int arr[SIZE];

void pre() {

	for (int i = 1; i < SIZE; i++) {
		arr[i] = 1;
	}
	for (int i = 2; i < SIZE; i++) {
		for (int j = i; j < SIZE; j += i) {
			arr[j]++;
		}
	}
}

void solve() {

	pre();

	int n;
	cin >> n;
	int Sum = 0;
	for (int i = 1; i <= n; i++) {
		Sum += i * arr[i];
	}
	cout << Sum << endl;
}

signed main() {

	ios_base::sync_with_stdio(0);
	cin.tie(0);

# ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
# endif

	solve();

	return 0;
}

Measured memory_bytes: 81720
#include <iostream>

using namespace std;

int main()
{
    int n1,n2,n3,n4;

    cin>>n1;
    cin>>n2;
    cin>>n3;
    cin>>n4;

    if(n1+n2>n3+n4)
    {
        cout<<"Left";
    }
    if(n1+n2==n3+n4)
    {
        cout<<"Balanced";
    }
      if(n1+n2<n3+n4)
    {
        cout<<"Right";
    }


}




Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define uli unsigned long long int
#define INF 999999999
#define rep(i,m,n) for(int i = m;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
#define mod 1000000007;
bool is_prime(lli x) {
  for(lli i = 2; i * i <= x; i++) {
    if(x % i == 0) return false;
  }
  return true;
}
int main() {
  lli A,B,C=0,D=0,E=0,F=0,G=0,H=0,N,M;
  cin >> A >> B;
  if(A%2==1)A++;
  if(A/2<B)Out("NO");
  else Out("YES");
}


Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

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

    int count = 0;
    for (int i = 0; i < 3; i++) {
        if (s[i] == 'o') count++;
    }

    cout << 700 + 100*count << endl;
}

Measured memory_bytes: 256
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

N = II()
if N == 1:
    print(1)
else:
    a = 2
    b = 1
    for i in range(2, N+1):
        c = a + b
        a = b
        b = c
    print(c)

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

using namespace std;

int main() {
  std::cin.tie(nullptr);
  std::ios::sync_with_stdio(false);
  int64_t n;
  std::cin >> n;
  int ret = 0;
  for (int a = 1; a <= n; a += 2) {
    int cnt = 0;
    for (int i = 1; i <= a; i++) {
      if (a % i == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      ret++;
    }
  }
  std::cout << ret << std::endl;
  return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<random>
using namespace std;
typedef long long int lint;
typedef pair<lint, lint> plint;
typedef pair<double long, double long> pld;
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((lint)(x).size())
#define POW2(n) (1LL << (n))
#define FOR(i, begin, end) for(lint i=(begin),i##_end_=(end);i<i##_end_;i++)
#define IFOR(i, begin, end) for(lint i=(end)-1,i##_begin_=(begin);i>=i##_begin_;i--)
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2>& l, const pair<T1, T2>& r) { return make_pair(l.first - r.first, l.second - r.second); }
const lint MOD = 1e9 + 7, INF = 1e16;


template <std::int_fast64_t Modulus>
class modint
{
	using u64 = std::int_fast64_t;

public:
	u64 a;
	constexpr modint(const u64 x = 0) noexcept : a(x% Modulus) {}
	constexpr u64& value() noexcept { return a; }
	constexpr const u64& value() const noexcept { return a; }
	constexpr modint operator+(const modint rhs) const noexcept
	{
		return modint(*this) += rhs;
	}
	constexpr modint operator-(const modint rhs) const noexcept
	{
		return modint(*this) -= rhs;
	}
	constexpr modint operator*(const modint rhs) const noexcept
	{
		return modint(*this) *= rhs;
	}
	constexpr modint operator/(const modint rhs) const noexcept
	{
		return modint(*this) /= rhs;
	}
	constexpr modint& operator+=(const modint rhs) noexcept
	{
		a += rhs.a;
		if (a >= Modulus)
		{
			a -= Modulus;
		}
		return *this;
	}
	constexpr modint& operator-=(const modint rhs) noexcept
	{
		if (a < rhs.a)
		{
			a += Modulus;
		}
		a -= rhs.a;
		return *this;
	}
	constexpr modint& operator*=(const modint rhs) noexcept
	{
		a = a * rhs.a % Modulus;
		return *this;
	}
	constexpr modint& operator/=(modint rhs) noexcept
	{
		u64 exp = Modulus - 2;
		while (exp)
		{
			if (exp % 2)
			{
				*this *= rhs;
			}
			rhs *= rhs;
			exp /= 2;
		}
		return *this;
	}
};
typedef modint<MOD> ModInt;

ModInt mod_pow(ModInt x, ModInt n) {
	ModInt ret = 1;
	while (n.a > 0) {
		if (n.a & 1) (ret *= x);
		(x *= x);
		n.a >>= 1;
	}
	return ret;
}

lint N;
lint arr[200000];
int main() {
	cin >> N;
	REP(i, N) {
		cin >> arr[i];
	}
	sort(arr, arr + N, greater<lint>());
	ModInt ans = 0;
	ModInt mul = mod_pow(2, N - 1);
	REP(i, N) {
		ans += mul * arr[i];
		mul += mod_pow(2, N - 2);
	}
	ans *= mod_pow(2, N);
	cout << ans.a << endl;
}


Measured memory_bytes: 5184
#include <bits/stdc++.h>
#define INF 1.0e9
using namespace std;
typedef long long ll;

int N, A, B;

int main() {
    cin >> N >> A >> B;
    if (N == 1) cout << "Hello World" << endl;    
    else cout << A+B << endl;
    return 0;
}

Measured memory_bytes: 256
use proconio::input;
use proconio::marker::Usize1;

macro_rules! chmax {
    ($max_v: expr, $v: expr) => {
        if $v > $max_v {
            $max_v = $v;
            true
        } else {
            false
        }
    };
}

fn main() {
    input! {
        n: usize,
        k: usize,
        p: [Usize1; n],
        c: [i64; n],
    };

    let mut vs = vec![];
    let mut b = vec![false; n];
    for i in 0..n {
        if !b[i] {
            let mut v = vec![];
            let mut c = i;
            while !b[c] {
                b[c] = true;
                v.push(c);
                c = p[c];
            }
            vs.push(v);
        }
    }

    let mut ans = c[vs[0][0]];
    for v in vs.iter() {
        let sum_v = v.iter().map(|&v_i| c[v_i]).sum::<i64>();
        let n_v = v.len();
        let mut a = c[v[0]];
        for i in 0..n_v {
            let mut s = 0_i64;
            for j in i..std::cmp::min(2 * n_v, i + k) {
                s += c[v[j % n_v]];
                chmax!(a, s);
            }
        }
        if k > n_v {
            let x = k / n_v;
            let k = k % n_v;
            for i in 0..n_v {
                let mut s = (x as i64 - 1) * sum_v;
                chmax!(a, s);
                for j in i..i + n_v + k {
                    s += c[v[j % n_v]];
                    chmax!(a, s);
                }
            }
        }
        chmax!(ans, a);
    }
    println!("{}", ans);
}


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

int main() {
    ll N,M,K;
    cin>>N>>M>>K;
    vector<ll> A(N);
    vector<ll> B(M);
    vector<ll> a;
    vector<ll> b;
    a.push_back(0);
    b.push_back(0);
    rep(i,N){cin>>A[i];}
    rep(i,M){cin>>B[i];}
    rep(i,N){a.push_back(a[i]+A[i]);}
    rep(i,M){b.push_back(b[i]+B[i]);}
    
    ll j=M;
    ll ans=0;
    rep(i,N+1)
    {
      if(a[i]>K)break;
      while(b[j]>K-a[i])j -=1;
      ans = max(ans,i+j);
    }
    cout<<ans<<endl;
    return 0;
}

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

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

using ll = long long;
using pll = pair<ll, ll>;

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

    ll res = 0;
    rep (i, N.size()) { res += N[i] - '0'; }

    cout << ((res % 9) == 0 ? "Yes" : "No") << endl;

    return 0;
}


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

int main() {
	long long A, B, C, D;
	cin >> A >> B >> C >> D;
	if ((abs(A - B) <= D && abs(B - C) <= D) || abs(A - C) <= D) cout << "Yes" << endl;
	else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <climits>
#include <functional>
#include <iostream>
#include <queue>
#include <utility>
#include <vector>
using namespace std;

int main() {
	int N, u, v;
	cin >> N;
	vector<vector<pair<int, long>>> a(N);
	for (int i = 1; i < N; i++) {
		long w;
		cin >> u >> v >> w;
		a[u - 1].emplace_back(v - 1, w);
		a[v - 1].emplace_back(u - 1, w);
	}
	priority_queue<pair<long, int>, vector<pair<long, int>>, greater<pair<long, int>>> b;
	b.emplace(0, 0);
	vector<bool> c(N);
	vector<long> d(N, LONG_MAX);
	d.front() = 0;
	while (!b.empty()) {
		pair<long, int> e = b.top();
		b.pop();
		c[e.second] = true;
		for (pair<int, long>& i : a[e.second]) {
			if (c[i.first]) continue;
			if (d[e.second] + i.second < d[i.first]) {
				d[i.first] = d[e.second] + i.second;
				b.emplace(d[i.first], i.first);
			}
		}
	}
	for (long& i : d) cout << i % 2 << endl;
}

Measured memory_bytes: 8704
fn read<T: std::str::FromStr>(
    stdin_lock: &mut std::io::StdinLock,
    buf: &mut Vec<u8>,
    delimiter: u8,
) -> T {
    buf.clear();
    let l = std::io::BufRead::read_until(stdin_lock, delimiter, buf).unwrap();
    buf.truncate(l - 1); // remove delimiter
    let s = unsafe { std::str::from_utf8_unchecked(&buf) };
    s.parse().unwrap_or_else(|_| panic!("read"))
}

fn main() {
    let stdin = std::io::stdin();
    let mut stdin_lock = stdin.lock();
    let mut buf: Vec<u8> = Vec::new();
    let n: i32 = read(&mut stdin_lock, &mut buf, b' ');
    let k: i32 = read(&mut stdin_lock, &mut buf, b'\n');
    let mut ans = 0f64;
    for i in 1..n + 1 {
        let mut p = 1f64;
        let mut s = 1;
        while s * i < k {
            s *= 2;
            p /= 2f64;
        }
        ans += p / f64::from(n);
    }
    println!("{:.12}", ans);
}


Measured memory_bytes: 4352
<?php
  $a=trim(fgets(STDIN));
  $b=trim(fgets(STDIN));
if(strlen($a)!=(strlen($b)-1)){
  echo "No";
  exit;
}
$c=substr($b,0,strlen($a));
if($a==$c){
  echo "Yes";
  exit;
}else{
  echo "No";
}
?>

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

int main(){
	int n,k;
	cin >> n >> k;
	ll ans = 0;
	ans = k*pow(k-1,n-1);
	cout << ans << endl;
}

Measured memory_bytes: 4008
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt(); 
		int n = sc.nextInt();
		int[][] array = new int[n + 1][r + 1];
		
		for(int i = 0; i < r ;i ++) {
			for(int j = 0;j < n ; j++) {
				array[j][i] = sc.nextInt();
				array[n][i]  = array[n][i] + array[j][i];
				array[j][r]  = array[j][r] + array[j][i];
				array[n][r]  = array[n][r] + array[j][i];
			}
		}
		for(int i = 0; i <= r; i++) {
			for(int j = 0;j < n ; j++) {
				System.out.print(String.format("%d ",array[j][i]));
			}
			System.out.println(array[n][i]);
		}
	}	
}



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

// f(X)は整数xを十進法で表したときの各桁の数字の和
int f(int X) {
  int f = 0;
  while (X > 0) {
    f += X % 10;
    X -= X % 10;
    X /= 10;
  }
  return f;
}

int main() {
  int N;
  cin >> N;
  // Nがf(N)で割り切れるか
  if (N % f(N) == 0) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#ABC063A
x, y = map(int, input().split())
a = [1,3,5,7,8,10,12]
b = [4,6,9,11]
if x in a and y in a:
    print("Yes")
elif x in b and y in b:
    print("Yes")
elif x == y == 2:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 3064
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

string s, t, tmp;
int n, m, nm, nxt[500009], d, cnt;
vector<int> vec[500009], src;
int ind[500009], ind2[500009], ld[500009];
bool vis[500009];
queue<int> qu;

void fun()
{
	nxt[0] = -1;
	for (int i = 1, j  = 0; i < m; i++, j++) {
		while (t[i] != t[j]) {
			j--;
			if (j < 0) break;
			j = nxt[j] + 1;
		}
		nxt[i] = j;
	}
}

void gun(int cur)
{
	cnt++;
	for (int i = 0; i < (int)vec[cur].size(); i++) {
		ind[vec[cur][i]]--;
		if (ind[vec[cur][i]] == 0) gun(vec[cur][i]);
	}
}

void fun2(int cur, int v)
{
	ld[cur] = max(ld[cur], v);
	if (ind2[cur] == 0) {
		for (int i = 0; i < (int)vec[cur].size(); i++) {
			ind2[vec[cur][i]]--;
			fun2(vec[cur][i], ld[cur] + 1);
		}
	}
}

int main()
{
	ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	cin >> s >> t;
	n = s.length();
	m = t.length();
	nm = n + m;
	fun();
	for (int i = 0, j = 0; i < nm; i++, j++) {
		if (j == m) {
			vec[(i - m) % n].pb(i%n);
			ind[i%n]++; ind2[i%n]++;
			j = nxt[j - 1] + 1;
		}
		while (s[i%n] != t[j]) {
			j--;
			if (j < 0) break;
			j = nxt[j] + 1;
		}
	}
	for (int i = 0; i < n; i++) {
		if (ind[i] == 0)
			gun(i);
	}
	if (cnt < n)
		cout << -1 << E;
	else {
		for (int i = 0; i < n; i++) {
			if (ind2[i] == 0)
				fun2(i, 0);
		}
		int ans = 0;
		for (int i = 0; i < n; i++) {
			ans = max(ans, ld[i]);
		}
		cout << ans << E;
	}
	//system("pause");
	return 0;
}


Measured memory_bytes: 57756
/*
   AUTHOR :- Gaurang_Kothiya
   
   Quote:-" Great things never come from comfort zones."                                                                                                                
*/
 
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>  
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#include <bitset>
#include <cstdint>
#include <initializer_list>
 
using namespace std;
using namespace __gnu_pbds;  

typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update> data_set; 
#define speed ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define ll long long  
#define ld long double
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fe(x,v)   for(auto &x :v)
#define nf(i,x,n) for(ll i=n;i>=x;i--)
#define all(a)   a.begin(),a.end()
#define rall(a)  a.rbegin(),a.rend()
#define b_s(a,b)   binary_search( all(a),b)
#define lb(v,n)  lower_bound(all(v) ,n )
#define ub(v,n)  upper_bound( all(v) , n)
#define gcd(a,b) __gcd(a,b)
#define pub push_back
#define pob pop_back
#define puf push_front
#define pof pop_front
#define RE rend()
#define RB rbegin()
#define B begin()
#define E end()
#define acc(v, x) accumulate(all(v), x)
#define p(a,b) pair<a,b>
#define F first
#define S second
#define sz size()
#define v(x) vector<x>
#define m(a,b) map<a,b>
#define u_m(a,b) unordered_map<a,b>
#define mm(a,b) multimap<a,b>
#define s(a) set<a>
#define us(a) unordered_set<a>
#define ms(a) multiset<a>
#define maxy __LONG_LONG_MAX__
#define miny INT_MIN
#define PI 3.14159265358979323846
#define MOD 1000000007


void Solve()
{
	int n,k;
	cin>>n>>k;
	
	m(int,int) vis;
	f(i,1,k)
	{
		int d,x;
		cin>>d;
		f(i,1,d)
		{
			cin>>x;
			vis[x]=1;
		}
	}
	int cnt=0;
	f(i,1,n)
	{
		if(vis[i]==0) cnt++;
	}
	cout<<cnt;
	
}

signed main() 
{
	speed		
	
	int q=1;
	//cin>>q;
	
	while(q--)
	Solve();
	
	//cout << "\n\n"<<"Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " seconds.\n";
	return 0;
}

 
 

Measured memory_bytes: 3624