akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int n = Integer.parseInt(sc.next());
    int m = Integer.parseInt(sc.next());
    int p[] = new int[m];
    String s[] = new String[m];
    int ac[] = new int[n];
    int wa[] = new int[n];
    int spena = 0;
    int sac = 0;
    
    if(m==0){
      System.out.println("0 0");
      return;
    }
    
    for(int i=0; i<n; i++){
      ac[i] = 0;
      wa[i] = 0;
    }
    
    for(int i=0; i<m; i++){
      p[i] = Integer.parseInt(sc.next());
      s[i] = sc.next();
    }
    
    for(int i=0; i<m; i++){
      if(ac[p[i]-1]>0){
        continue;
      }
      if(s[i].equals("AC")){
        ac[p[i]-1] += 1;
      } else if(s[i].equals("WA")){
        wa[p[i]-1] += 1;
      }
    }
    
    for(int i=0; i<n; i++){
      sac += ac[i];
      if(ac[i]>0){
        spena += wa[i];
      }
    }
    
    System.out.println(sac + " " + spena);
  }
}



Measured memory_bytes: 66028
using System;

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var nstrs = Console.ReadLine().Trim().ToCharArray();
           
            //var ns = new int[nstrs.Length];
            int cnt = 0;
            foreach (var nstr in nstrs)
            {
                if (Int32.Parse(nstr.ToString()) == 2)
                {
                    cnt++;
                }
            }
            Console.WriteLine(cnt);

        }
    }
}

Measured memory_bytes: 13140
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
#define sz(x) int(x.size())
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1001001001;
const int MOD = 1000000007;
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 (b<a) {a=b; return 1;} return 0;}

#ifdef _DEBUG
#include "debug.h"
#else
#define debug(...)
#define print(...)
#endif

map<int, int> prime_factors(int n) {
	map<int, int> res;
	if(n == 1) { // n=1 の素因数分解は n^1
		res[n] = 1;
		return res;
	}
	for(int i = 2, _n = n; i*i <= _n; ++i) {
		while(n % i == 0) {
			++res[i]; // 素因数i^{res[i]}
			n /= i;
			}
		}
	if(n != 1) res[n] = 1; // nが素数のとき
	return res;
}

int main() {
    int n; cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    // pfの結果のfirstが全て異なるならば、pairwise coprime
    // gcdをとって1になるなら、setwise coprime
    // そうでなければ not coprime
    // unordered_set<int> facs;
    unordered_map<int, int> facs;
    int allgcd = a[0];
    bool toGo = true;
    rep(i, n) {
        if (toGo) {
            auto mp = prime_factors(a[i]);
            for(const auto& m: mp) {
                facs[m.fi]++;
                if (m.fi!=1 && facs[m.fi]>1) {
                    toGo = false;
                    break;
                }
            }
        }
        if (i>0) allgcd = gcd(allgcd, a[i]);
    }
    bool ok = false;
    if (toGo) {
        ok = true;
        for(const auto& m: facs) {
            debug(m.fi, m.se);
            if (m.fi!=1 && m.se!=1) {
                ok = false;
                break;
            }
        }
    }
    if (ok) cout << "pairwise coprime" << endl;
    else if (allgcd==1) cout << "setwise coprime" << endl;
    else cout << "not coprime" << endl;
}

Measured memory_bytes: 7196
// JOI 2012-2013 予選4
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<climits>

int D, N;
int T[200];
int A[200], B[200], C[200];
// i日目に服jが着れるか
bool suit[200][200];
// dp[i][j]: i日目に服jを着た時の派手さの差の絶対値の合計の最大値
int dp[200][200];

int main()
{
	std::cin >> D >> N;
	for( int i = 0; i != D; ++i )
		std::cin >> T[i];

	for( int i = 0; i != N; ++i )
		std::cin >> A[i] >> B[i] >> C[i];

	for( int i = 0; i != D; ++i )
	{
		for( int j = 0; j != N; ++j )
		{
			suit[i][j] = A[j] <= T[i] && T[i] <= B[j];

			if( !suit[i][j] )
				dp[i][j] = INT_MIN;
		}
	}

	for( int i = 0; i != D - 1; ++i )
		for( int j = 0; j != N; ++j )
			if( suit[i+1][j] )
				for( int k = 0; k != N; ++k )
					dp[i+1][j] = std::max( dp[i+1][j], dp[i][k] + abs( C[j] - C[k] ) );

	int ans = 0;
	for( int i = 0; i != N; ++i )
		ans = std::max( ans, dp[D - 1][i] );

	std::cout << ans << std::endl;

	return 0;
}

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

int main(){
    int h, w;
    cin >> h >> w;

    vector<string> s(h);
    for(int i=0; i<h; i++){
        cin >> s[i];
    }

    vector<vector<int>> l(h,vector<int>(w,0));
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            //cout << i << " " << j << endl;
            if(s[i][j] != '#'){
                if(j == 0){
                    l[i][j] = 1;
                }else{
                    l[i][j] = 1 + l[i][j-1];
                }
            }
            //cout << l[i][j] << endl;
        }
    }

    vector<vector<int>> r(h,vector<int>(w,0));
    for(int i=0; i<h; i++){
        for(int j=w-1; j>=0; j--){
            if(s[i][j] != '#'){
                if(j == w-1){
                    r[i][j] = 1;
                }else{
                    r[i][j] = 1 + r[i][j+1];
                }
            }
        }
    }

    vector<vector<int>> u(h,vector<int>(w,0));
    for(int j=0; j<w; j++){
        for(int i=0; i<h; i++){
            if(s[i][j] != '#'){
                if(i == 0){
                    u[i][j] = 1;
                }else{
                    u[i][j] = 1 + u[i-1][j];
                }
            }
        }
    }

    vector<vector<int>> d(h,vector<int>(w,0));
    for(int j=0; j<w; j++){
        for(int i=h-1; i>=0; i--){
            if(s[i][j] != '#'){
                if(i == h-1){
                    d[i][j] = 1;
                }else{
                    d[i][j] = 1 + d[i+1][j];
                }
            }
        }
    }

    int max = 0;
    for(int i=0; i<h; i++){
        for(int j=0; j<w; j++){
            if(max < l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3){
                max = l[i][j] + r[i][j] + u[i][j] + d[i][j] - 3;
            }
        }
    }

    cout << max << endl;
    return 0;
}

Measured memory_bytes: 67200
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  string s;
  cin >> s;
  regex re("BC");
  string fmt = "D";
  string replaced = regex_replace(s, re, fmt);
  debug(replaced);
  int l = replaced.size();
  int64 ans = 0;
  int64 cnt_a = 0;
  for (int i = 0; i < l; i++) {
    if (replaced[i] == 'A')
      cnt_a++;
    else if (replaced[i] == 'D') {
      ans += cnt_a;
      // cnt_a = 0;
    } else {
      cnt_a = 0;
    }
  }
  cout << ans << endl;
  return 0;
}
// 13:56

Measured memory_bytes: 4028
#include <bits/stdc++.h>
using namespace std;
#define  rep(i, n) for(int i = 0; i < n; i++) 
#define  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    int N;cin >> N;
    string S;cin >> S;
    int ct = 0;
    int tmp = 0;
    rep(i,N){
        if(S[i] == 'A'){
            tmp = 1;
        }else if(tmp == 1 && S[i] == 'B'){
            tmp++;
        }else if(tmp == 2 && S[i] == 'C'){
            ct++;
            tmp = 0;
        }
        else{
            tmp = 0;
        }
    }
    cout << ct << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define LL long long int
#define DL double
#define MLL map<LL,LL>::iterator
#define MSL map<string,L>::iterator
#define MLS map<LL,string>::iterator
#define MSS map<string,string>::iterator
#define MCL map<char,LL>::iterator
#define SL set<LL>::iterator
#define SS set<string>::iterator sl
#define G getline
#define SZ size()
#define IN insert
#define C clear()
#define B begin()
#define F front()
#define T top()
#define E end()
#define EM empty()
#define V vector
#define Q queue
#define DQ deque
#define PQ priority_queue
#define ST stack
#define FI first
#define SE second
#define PI acos(-1)
#define PS push
#define PP pop()
#define PSF push_front
#define PSB push_back
#define PPF pop_front()
#define PPB pop_back()
#define endl "\n"
#define FAST ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
set<LL>v;
int main()
{
    FAST;
    LL n,m,i,j,k,p,q,o,l,s,t,z;
    cin>>n>>m;
    k=1;
    for(i=0;i<70;i++)
    {
        n*=2;
        if(n<m)
        {
           k++;
        }
        else if(n==m)
        {
            k++;
            break;
        }
        else
        {
            break;
        }
    }
    cout<<k<<endl;

    return 0;
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  ll N, M;
  cin >> N >> M;
  vll p(N);
  for(int i = 0; i < N; i++){
    cin >> p.at(i);
    p.at(i)--;
  }
  vvll G(N, vll(0));
  for(int i = 0; i < M; i++){
    ll x, y;
    cin >> x >> y;
    x--; y--;
    G.at(x).push_back(y); G.at(y).push_back(x);
  }
  vector<bool> flag(N, false);
  ll ans = 0;
  for(int i = 0; i < N; i++){
    if(flag.at(i)) continue;

    queue<ll> que;
    que.push(i);
    flag.at(i) = true;

    set<ll> se;
    se.insert(i); se.insert(p.at(i));
    int counter = 1;

    while(!que.empty()){
      ll a = que.front(); que.pop();
      
      for(int j = 0; j < G.at(a).size(); j++){
        ll next = G.at(a).at(j);
        if(flag.at(next)) continue;
        flag.at(next) = true;
        se.insert(next); se.insert(p.at(next));
        counter++;
        que.push(next);
      }
    }
    ans += 2 * counter - se.size();
  }
  cout << ans << endl;
}

Measured memory_bytes: 11392
#include<bits/stdc++.h>
using namespace std;
int a[27];
int main()
{
    long long int i,j,k,z,t,x,y,n;
    string s;
    cin>>s;
    for(i=0;i<s.size();i++)
        a[s[i]-97]++;
    x=0;
    for(i=0;i<26;i++)
    {
        if(a[i]%2)
            x=1;
    }
    if(x)
        cout<<"No"<<endl;
    else
        cout<<"Yes"<<endl;
}

Measured memory_bytes: 3600
import sys
#input = sys.stdin.readline
from sys import setrecursionlimit
setrecursionlimit(10**9)

def inpl(): return list(map(int, input().split()))
N = int(input())
GA = inpl()
GB = inpl()

typ = [GA[i] <= GB[i] for i in range(3)]

if sum(typ) == 3:
    ans = 0
    for g in range(N//GA[0] + 1):
        D = N - GA[0]*g
        for s in range(D//GA[1] + 1):
            b, D2 = divmod(D - GA[1]*s, GA[2])
            ans = max(ans, D2 + g*GB[0] + s*GB[1] + b*GB[2])

elif sum(typ) == 2:
    ans = 0
    x, y = [i for i in range(3) if typ[i]]
    z = [i for i in range(3) if not typ[i]][0]
    for a in range(N//GA[x] + 1):
        b, D = divmod(N - GA[x]*a, GA[y])
        c, D2 = divmod(D + GB[x]*a + GB[y]*b, GB[z])
        ans = max(ans, D2 + c*GA[z])

elif sum(typ) == 1:
    ans = 0
    x, y = [i for i in range(3) if not typ[i]]
    z = [i for i in range(3) if typ[i]][0]
    c, D = divmod(N, GA[z])
    D += GB[z]*c

    for a in range(D//GB[x] + 1):
        b, D2 = divmod(D-GB[x]*a, GB[y])
        ans = max(ans, D2 + GA[x]*a + GA[y]*b)

    for b in range(D//GB[y] + 1):
        a, D2 = divmod(D-GB[y]*b, GB[x])
        ans = max(ans, D2 + GA[x]*a + GA[y]*b)

else:
    ans = 0
    for g in range(N//GB[0] + 1):
        D = N - GB[0]*g
        for s in range(D//GB[1] + 1):
            b, D2 = divmod(D - GB[1]*s, GB[2])
            ans = max(ans, D2 + g*GA[0] + s*GA[1] + b*GA[2])

print(ans)

Measured memory_bytes: 41180
#include<string>
#include<vector>
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<sstream>
#include<functional>
#include<map>
#include<stack>
#include<set>
#include<cmath>

#define REP(i,s,e) for(int i=int(s);i<=int(e);i++)
#define rep(i,n) for(int i=0;i<int(n);i++)

#define EPS 1e-6

using namespace std;

bool f(string a){

string::size_type p=a.find("the");
string::size_type q=a.find("this");
string::size_type r=a.find("that");
if(p!=string::npos || q!=string::npos || r!=string::npos)
return true;
else return false;

	}

int main(){

   string s,s1;

   while(getline(cin,s)){

	int n=s.size();

		rep(j,26){
		rep(i,n){
		if('a'<=s[i] && s[i]<='y') s[i]++;
		else if(s[i]=='z') s[i]='a';
		}

		if(f(s)){ cout << s << endl; break; }

		}

	}

    return 0;
}

Measured memory_bytes: 1184
import sys
N,Y = map(int,input().split())
ans = '-1 -1 -1'

for i in range(2001):
    for j in range(2001):
        if 10000*i + 5000*j + 1000*(N-i-j) == Y :
            if N-i-j >= 0:
                print(str(i) + ' '+str(j) + ' '+ str(N-i-j))
                sys.exit()
print(ans) 

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

int main() {
    long long x, y, a, b, c, i, tra = 0, sum = 0;
    cin >> x >> y >> a >> b >> c;
    int lst_red[a], lst_green[b], lst_transp[c];
    for(i = 0; i < a; i++){
        cin >> lst_red[i];
    }
    for(i = 0; i < b; i++){
        cin >> lst_green[i];
    }
    for(i = 0; i < c; i++){
        cin >> lst_transp[i];
    }
    vector<pair<int, char>> lst(a+b+c);
    for(i = 0; i < a; i++){
        lst.at(i) = make_pair(lst_red[i], 'r');
    }
    for(i = 0; i < b; i++){
        lst.at(a+i) = make_pair(lst_green[i], 'g');
    }
    for(i = 0; i < c; i++){
        lst.at(a+b+i) = make_pair(lst_transp[i], 't');
    }
    sort(lst.begin(), lst.end());
    reverse(lst.begin(), lst.end());
    for(auto p : lst){
        auto val = p.first;
        auto color = p.second;
        if(x + y == tra || (x == 0 && y == 0)) break;
        if(color == 'r' && x != 0){
            sum += val;
            x--;
        }
        if(color == 'g' && y != 0){
            sum += val;
            y--;
        }
        if(color == 't'){
            sum += val;
            tra++;
        }
    }
    /*for(auto p : lst){
        auto val = p.first;
        auto color = p.second;
        cout << val << "," << color << endl;
    }*/
    cout << sum << endl;
}

Measured memory_bytes: 3712
N, K = gets.split.map(&:to_i)
as = gets.split.map(&:to_i)
max = as.select{|a|a>0}.inject(0, :+)

pos = as[0, K].select{|a|a>0}.inject(0, :+)
neg = as[0, K].select{|a|a<0}.inject(0, :+)
lossmin = [pos, -neg].min
(K...N).each do |i|
    if as[i] > 0
        pos += as[i]
    else
        neg += as[i]
    end
    if as[i-K] > 0
        pos -= as[i-K]
    else
        neg -= as[i-K]
    end
    loss = [pos, -neg].min
    lossmin = loss if lossmin > loss
end

puts max - lossmin

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

using namespace std;

const int N = (int) 1e5;
int n,k;
long long a[N+5],ans=(long long)2e15;
int main()
{

    cin>>n>>k;
    for(int i=1;i<=n;i++)
    cin>>a[i];
     for(int i=1;i+k-1<=n;i++)
    {
        int l=i,r=i+k-1;
        ans=min(ans,a[r]-a[l]+min(abs(a[l]),abs(a[r])));
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 1024
def main():
    N = int(input())

    pt = 0
    px = 0
    py = 0
    for i in range(N):
        tin = input().split(" ")
        t, x, y = int(tin[0]), int(tin[1]), int(tin[2])
        d = abs(px-x) + abs(py-y)
        dr = t - pt - d
        if dr < 0 or dr % 2 != 0:
            print("No")
            return
    print("Yes")
    return
main()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define vii vector<int, int>
#define pii pair<int, int>
#define nn "\n"


int main() {

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

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

	int n, k; cin >> n >> k;

	std::vector<int> v(n + 1);
	for (int i = 1; i <= n; ++i) cin >> v[i];

	std::vector<int> dp(n + 1);
	dp[0] = 0;

	for (int i = 2; i <= n; ++i) {
		dp[i] = INT_MAX;
		for (int j = i - 1; j >= 1 and (i - j) <= k; j--) {
			dp[i] = min(dp[i], abs(v[i] - v[j]) + dp[j]);
		}
	}
	cout << dp[n];
	return 0;
}


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

#define rep(i,l,r) for(register int i = l ; i <= r ; i++)
#define repd(i,r,l) for(register int i = r ; i >= l ; i--)
#define rvc(i,S) for(register int i = 0 ; i < (int)S.size() ; i++)
#define rvcd(i,S) for(register int i = ((int)S.size()) - 1 ; i >= 0 ; i--)
#define fore(i,x)for (register int i = head[x] ; i ; i = e[i].next)
#define forup(i,l,r) for (register int i = l ; i <= r ; i += lowbit(i))
#define fordown(i,id) for (register int i = id ; i ; i -= lowbit(i))
#define pb push_back
#define prev prev_
#define stack stack_
#define mp make_pair
#define fi first
#define se second
#define lowbit(x) ((x)&(-(x)))

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

const int inf = 2e8;
const int maxn = 100020;
const ll mod = 1e9 + 7;

int nxt[maxn][2];
ll L,ans;
char s[maxn];
int n,tot,cur;

void dfs(int x,int dth){
	if ( !nxt[x][0] && !nxt[x][1] ) return;
	if ( nxt[x][0] && nxt[x][1] ){
		dfs(nxt[x][0],dth + 1);
		dfs(nxt[x][1],dth + 1);
		return;
	}
	if ( nxt[x][0] ) dfs(nxt[x][0],dth + 1);
	else dfs(nxt[x][1],dth + 1);
	ans ^= lowbit(L - dth);
}
int main(){
	scanf("%d%lld",&n,&L);
	rep(i,1,n){
		scanf("%s",s + 1);
		cur = 0;
		int len = strlen(s + 1);
		rep(j,1,len){
			if ( !nxt[cur][s[j] - '0'] ) nxt[cur][s[j] - '0'] = ++tot;
			cur = nxt[cur][s[j] - '0'];
		}
	}
	dfs(0,0);
	if ( ans ) puts("Alice");
	else puts("Bob");
}



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

typedef long long LL;

int a, b, c, d;
int t[10000];

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

    cin >> a >> b >> c >> d;
    for(int i = a; i <= b; i++)
        t[i] ++;
    for(int i = c; i <= d; i++)
        t[i] ++;
    int cnt = 0;
    for(int i = 0; i < 1000; i++)
        if(t[i] == 2) cnt++;
    cout << max(cnt - 1, 0);

    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	static final long MOD = 1000000007;
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int K = sc.nextInt();
		if(K==1) {
			System.out.println(1);
			sc.close();
			return;
		}
		
		init(N*K);
		
		long[][] dp = new long[N+1][N+1];
		dp[0][0] = 1;
		for(int i=0; i<=N; i++) {
			for(int j=i; j<=N; j++) {
				if(i>0)
					dp[i][j] += dp[i-1][j];
				if(j>i)
					dp[i][j] += dp[i][j-1]*comb(i+j*(K-1)-1, K-2);
				dp[i][j] %= MOD;
			}
		}
		
		System.out.println((dp[N][N]*fac[N])%MOD);
		sc.close();
	}
	
	static long fac[],rev[];
	
	static void init(int N) {
		fac = new long[N+1];
		rev = new long[N+1];
		fac[0] = 1;
		rev[0] = 1;
		for(int i=1; i<=N; i++) {
			fac[i] = fac[i-1]*i%MOD;
			rev[i] = pow(fac[i], MOD-2);
		}
	}
	static int pow(long a, long b) {
		long ans = 1;
		while(b>0) {
			if((b&1)!=0)
				ans = (ans * a)%MOD;
			a = (a * a)%MOD;
			b>>=1;
		}
		return (int)ans;
	}
	static long comb(int a, int b) {
		if(a<0 || b<0 || a<b)
			return 0;
		return (((fac[a]*rev[a-b])%MOD)*rev[b])%MOD;
	}

}

Measured memory_bytes: 114772
#include <iostream>
#include <algorithm>
using namespace std;
const int N=2e5+10;
int n;
char str[N];
int b[N][2];//到第i个字符的0代表W，1代表R的个数 

int main(){
	cin>>n>>str+1;
	for(int i=1;i<=n;i++){
		if(str[i]=='R') b[i][1]=b[i-1][1]+1,b[i][0]=b[i-1][0]; 
		else b[i][1]=b[i-1][1],b[i][0]=b[i-1][0]+1;
	}
	
	//红色个数，白色个数 
	int r=b[n][1], w=b[n][0];
	
	int ans=min(b[r][0],min(w,r));
	cout<<ans;
	return 0;
}


Measured memory_bytes: 5292
#include <cstdio>
#include <algorithm>

int p[105];
bool vis[105];

int main()
{
	int N;scanf("%d",&N);
	int A,B;scanf("%d%d",&A,&B);
	for(register int i=1;i<=N;i++)
		scanf("%d",&p[i]);
	std::sort(&p[1],&p[N+1]);
	register int ans=0;
	while(true)
	{
		register bool fnd=false;
		for(register int i=1;p[i]<=A && i<=N;i++)
			if(!vis[i])
			{
				vis[i]=true,fnd=true;
				break;
			}
		if(!fnd)
			break;
		fnd=false;
		for(register int i=N;p[i]>B && i>=1;i--)
			if(!vis[i])
			{
				vis[i]=true,fnd=true;
				break;
			}
		if(!fnd)
			break;
		fnd=false;
		for(register int i=1;i<=N;i++)
			if(!vis[i] && p[i]>A && p[i]<=B)
			{
				vis[i]=true,fnd=true;
				break;
			}
		if(!fnd)
			break;
		ans++;
	}
	printf("%d\n",ans);
	
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;



int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k, s;
    cin >> k >> s;
    int ans = 0;
    FOR(z, 0, k){
        if(s - z < 0) continue;
        FOR(y, 0, k){
            if(s - z - y < 0 || s - z - y > k) continue;
            ans++;
        }
    }
    cout << ans << "\n";

    return 0;
}


Measured memory_bytes: 256
/*
    Only way to go is UP 
    H1s3nb3rg's Here !!
*/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h> 
#include <cmath>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vll;
typedef long double ld;
typedef pair<int,int> pi;
typedef uint64_t i64;
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<vector<ll>> v2ll;
const int MOD = 1e9+7;
#define FAST_IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define MAIN int main(){FAST_IO;ll tc;cin>>tc;while(tc--){solver();}ret0;}
#define MAIN1 int main(){FAST_IO;solver();ret0;}
#define rep(i,b,e) for(__typeof(e)i=(b)-((b)>(e));i!=(e)-((b)>(e));i+=1-2*((b)>(e)))
#define repa(i,x)  for(auto i:x)
#define vin(x) for(auto &i:x){cin>>i;}
#define vin1(x) for(ll i=1;i<x.size();i++){cin>>x[i];}
#define dbg(x) for(auto i:x){cout<<i<<" ";}cout<<ENDL;
#define ENDL "\n"
#define VALL(a) a.begin(),a.end()
#define ff first
#define ss second
#define sz(x) (int)x.size()
#define MP(a,b) make_pair(a,b)
#define ff first
#define ss second
#define ret0 return 0;
#define ret return;
#define pb(x) push_back(x)
/*----------------------------*/


void solver(){
    string a,b;
    cin>>a>>b;
    ll ans=0;
    rep(i,0,a.length())
        if(a[i]!=b[i])
            ans++;
    cout<<ans<<ENDL;
    ret;
}

MAIN1


Measured memory_bytes: 3800
#include <bits/stdc++.h>
#define ll long long
#define x first
#define y second

using namespace std;

const int MAXN = (int) 50;

pair <int, int> v[MAXN + 1];

vector <int> val;

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int n, i, j, k;
    ios::sync_with_stdio(false);
    cin >> n >> k;
    for(i = 1; i <= n; i++)
        cin >> v[i].x >> v[i].y;
    sort(v + 1, v + n + 1);
    ll ans = (1LL << 62);
    for(i = 1; i <= n; i++) {
        val.clear();
        for(j = i; j <= n; j++) {
            val.push_back(v[j].y);
            sort(val.begin(), val.end());
            int b1 = 0, e1 = k - 1;
            while(e1 < val.size()) {
                if(e1 >= k - 1)
                    ans = min(ans, 1LL * (val[e1] - val[b1]) * (v[j].x - v[i].x));
                b1++;
                e1++;
            }
        }
    }
    cout << ans;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 256
#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <string>
#include <vector>
#include <stdio.h>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <set>
using namespace std;


int sumdigit(int x){
   int sum = 0;
    while(x != 0){
        sum += x % 10;
        x /= 10;
    }
    return sum;
}
int main(){
    int N;
    int K;
    cin >> N >> K;
    vector<int> x(N);
    for(int i = 0; i < N; i++){
        cin >> x[i];
    }
  int d = 0;

  for(int i = 0; i < N; i++){
      if(x[i] > K - x[i]){
          d += (K - x[i])*2;
      }
      else d += x[i]*2;
  }

  cout << d << endl;
}


Measured memory_bytes: 256
# thought greedy was better i am noob
def main():
	n = int(input())
	dp = [0 for i in range(n+4)]
	dp[0]=0
	for i in range(1, n+2):
		p = 1
		dp[i]=1000000000000000
		while i>=p:
			dp[i]=min(dp[i] , dp[i-p]+1)
			p =p*9
		p=1
		while i>=p:
			dp[i]=min(dp[i] , dp[i-p]+1)
			p = p*6
	print(dp[n])
if __name__=="__main__":
	main()

Measured memory_bytes: 79100
#include <stdio.h>
#include <iostream>
#include <queue>
#include <cstdio>
#include <stack>
#include <algorithm>
#include <cmath>
#include <cstring>
#include <string.h>
#include <limits.h>
#include <map>
#include <string>
#include <bitset>
#include <vector>
using namespace std;
int main() {
    string s;
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5] && s.size() == 6) printf("Yes\n");
    else printf("No\n");
    return 0;
}


Measured memory_bytes: 3632
#include <iostream>
#include <iomanip>
#include <random>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <numeric>
#include <cstdlib>
#include <cstring>
#include <deque>
#include <sstream>
#include <bitset>
#include <cassert>
#include <fstream>
#include <queue>

#define len(X) ((int)(X).size())

#ifdef __LOCAL
	#define DBG(X) cout << #X << "=" << (X) << '\n';
#else
	#define DBG(X)
#endif
 
using namespace std;

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

const int INT_INF = (int)(2e9);
const ll  LL_INF  = (ll)(2e18);

const int NIL = -1;
static mt19937 _g(time(nullptr));

inline ll randint(ll a, ll b) { ll w = (_g() << 31LL) ^ _g(); return a + w % (b - a + 1); }
inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T> inline T sign(T x) { return T(x > 0) - T(x < 0); }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for(auto el: v) cout << el << " "; return os; }
template<typename T> inline T fetch() { T ret; cin >> ret; return ret; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for(auto& elem: ret) cin >> elem; return ret; }

const int MAXN = (int)1e5 + 123;

ll a[MAXN], pref[MAXN], pref_pos[MAXN], suff_pos[MAXN];
int n, k;

void solve() {
	cin >> n >> k;

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

		pref[i] = a[i] + (i > 0 ? pref[i - 1] : 0);
		pref_pos[i] = max(0LL, a[i]) + (i > 0 ? pref_pos[i - 1] : 0);
	}

	for(int i = n - 1; i >= 0; --i) {
		suff_pos[i] = suff_pos[i + 1] + max(0LL, a[i]);
	}

	ll answ = 0;

	for(int i = 0; i + k - 1 < n; ++i) {
		ll local = (i > 0 ? pref_pos[i - 1] : 0);
		ll sum = pref[i + k - 1] - (i > 0 ? pref[i - 1] : 0);
		local += suff_pos[i + k];

		answ = max(answ, local);
		answ = max(answ, local + sum);
	}

	cout << answ << '\n';
}

int main() {
	fast_io();
	solve();

	return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < int(n); i++)
#define vi vector<int>
#define all(x) (x).begin(),(x).end()
#define INF (1<<30)-1
using ll = long long;
using namespace std;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T &a, const T &b){ if(a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(b<a) { a=b; return 1; } return 0; }

int main(){
  cin.tie(0), ios::sync_with_stdio(false);
  int n; cin >> n;
  map<int,int> mp;
  vi a(n);
  rep(i,n){
    cin >> a[i];
    mp[a[i]]++;
  }
  int odd = 0, even = 0;
  for(auto x : mp){
    odd += x.second%2;
    even += 1-x.second%2;
  }
  if(even%2 == 0) cout << even+odd;
  else cout << even+odd-1;
  cout << "\n";
  return 0;
}


Measured memory_bytes: 8252
use std::str::FromStr;
use std::fmt::Debug;
use std::cmp;

fn read_line<T>() -> Vec<T>
where T: FromStr, <T as FromStr>::Err : Debug {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().split_whitespace().map(|c| T::from_str(c).unwrap()).collect()
}

fn main() {
    let vec: Vec<String> = read_line();
    let s = &vec[0];
    let cnt = s.len();
    let mut ans: Vec<i32> = Vec::new();
    for _ in 0..cnt { ans.push(0); };

    let mut r_cnt: i32 = 0;
    let mut l_cnt: i32 = 0;
    let mut r_last_idx: usize = 0;

    let mut chars: Vec<char> = s.chars().collect();
    // add invalid 'L' for correct loop execution
    chars.push('L');

    for i in 0..cnt {
        if chars[i] == 'R' && chars[i+1] == 'L' {
            r_cnt += 1;
            r_last_idx = i;
        } else if chars[i] == 'L' && chars[i+1] == 'R' || i == cnt-1 {
            l_cnt += 1;

            let sum = r_cnt + l_cnt;
            if sum % 2 == 0 {
                ans[r_last_idx] = sum / 2;
                ans[r_last_idx+1] = sum / 2;
            } else {
                ans[r_last_idx] = (sum - 1) / 2;
                ans[r_last_idx+1] = (sum - 1) / 2;
                if cmp::max(r_cnt, l_cnt) % 2 == 0 {
                    if r_cnt < l_cnt { ans[r_last_idx] += 1; } else { ans[r_last_idx+1] += 1; };
                } else {
                    if r_cnt > l_cnt { ans[r_last_idx] += 1; } else { ans[r_last_idx+1] += 1; };
                }
            };

            // reset R, L count variables
            r_cnt = 0;
            l_cnt = 0;
        } else {
            if chars[i] == 'R' { r_cnt += 1; } else { l_cnt += 1; };
        }
    }

    for a in ans.iter() { print!("{} ", a); };
    println!();
}

Measured memory_bytes: 4476
#include <vector>
#include <iostream>
#include <string>
using namespace std;
using ll = long long;
int main(){
  string s;
cin >> s;
bool flag=false;
for(int i=0;i<3;i++){
  if(s[i]=='7')flag=true;
}
  if(flag){
cout << "Yes" << endl;
}else{
    cout << "No" << endl;
  }

}

Measured memory_bytes: 3592
#!/usr/bin/env python3
import sys


def solve(S: str):
    n = len(S)
    while True:
        l = len(S)
        i = 0
        while True:
            if i >= len(S) - 1:
                break
            if S[i] != S[i + 1]:
                S = S[:i] + S[i + 2:]
                i = max(i - 1, 0)
            else:
                i += 1
        if l == len(S):
            break
    print(n - len(S))
    return

def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    S = str(next(tokens))  # type: int
    solve(S)

if __name__ == '__main__':
    main()


Measured memory_bytes: 3644
#include <stdio.h>
#include <iostream>
using namespace std;

long long a[100010];
long long mask[61];

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;cin >> n;
  
    for (int i=0;i<n;++i)
        cin >> a[i];

    long long ans=0;
    long long tmp=0;
    for (int i=0;i<n;++i)
        tmp^= a[i];

    ans=tmp;
    tmp= (1LL << 61)-1-tmp;
    //cout << tmp << endl;
    for (int i=0;i<n;++i)
        a[i]&=tmp;
    //cout << ans <<endl;
    tmp=0;
    for (int i=0;i<n;++i)
    {
        for (int j=60;j>=0;--j)
        {
            if ( (a[i]&(1LL<<j))==0 ) continue;
            if ( !mask[j] ){
                mask[j]=a[i];
                break;
            }
            a[i]^=mask[j];
        }
    }
    for (int i=59;i>=0;--i)
    {
       // cout << i << ' ' << mask[i] << tmp <<endl;
        if (mask[i] && (tmp^mask[i])>tmp)
            tmp^=mask[i];
          //cout << i << ' ' << mask[i] << tmp <<endl;
    }
    ans+=tmp*2;
    cout << ans <<endl;

}


Measured memory_bytes: 1024
def main():
    n = int(input())
    tmp = list(map(int, input().split()))
    a = [0]*n
    a[0] = tmp[0]
    ans = a[0]
    for i in range(n-1):
        a[i+1] = tmp[i+1] - tmp[i]
        if a[i+1]>=0: ans += a[i+1]
    print(ans)

if __name__=="__main__": main()

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

#define pb push_back
using namespace std;

using ll = long long;

constexpr int N = 200111;

int n, t, m, x, arr[N];

int main(){
    cin >> n;
    for(int i = 2 ; i <= n ; ++i){
        cin >> x;
        arr[x]++;
    }

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

Measured memory_bytes: 4300
using System;
using System.Linq;

class B
{
	static void Main()
	{
		var a = Console.ReadLine().Split().Select(int.Parse).ToArray();
		Console.WriteLine(a[2] % Gcd(a[0], a[1]) == 0 ? "YES" : "NO");
	}

	static int Gcd(int x, int y) { for (int r; (r = x % y) > 0; x = y, y = r) ; return y; }
}


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

#define ms(s, n) memset(s, n, sizeof(s))
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORd(i, a, b) for (int i = (a) ; i >= (b); i--)
#define FORall(it, a) for (__typeof((a).begin()) it = (a).begin(); it != (a).end(); it++)
#define sz(a) int((a).size())
#define present(t, x) (t.find(x) != t.end())
#define all(a) (a).begin(), (a).end()
#define uni(a) (a).erase(unique(all(a)), (a).end())
#define pb push_back
#define pf push_front
#define mp make_pair
#define fi first
#define se second
#define sp system("pause")
#define prec(n) fixed<<setprecision(n)
#define bit(n, i) (((n) >> (i)) & 1)
#define bitcount(n) __builtin_popcountll(n)
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
typedef pair<int, int> pi;
typedef vector<int> vi;
typedef vector<pi> vii;
const int MOD = (int) 1e9 + 7;
const int INF = (int) 1e9;
const ll LINF = (ll) 1e18;
const ld PI = acos((ld) -1);
const ld EPS = 1e-9;
const int N = (int) 1e5 + 10;
void TimeExecution() {
    cout << "\n\n===>> Time Execution: " << clock() / (double)1000 << " sec(s).";
}
int t;
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0);
    /*
    #ifndef ONLINE_JUDGE
        freopen("in.txt", "r", stdin);
        freopen("out.txt", "w", stdout);
    #endif
    */
    int n, k, ans = 0;
    cin >> n >> k;
    while(n)
    {
        n /= k;
        ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    String S, T;

    String solve() {
        int s = S.length();
        int t = T.length();
        int[][] dp = new int[s+1][t+1];

        for (int i = 1; i <= s; i++) {
            for (int j = 1; j <= t; j++) {
                if (S.charAt(i-1) == T.charAt(j-1)) dp[i][j] = dp[i-1][j-1] + 1;
                else dp[i][j] = Math.max(dp[i][j-1], dp[i-1][j]);
            }
        }

        StringBuilder sb = new StringBuilder();
        int i = s;
        int num = dp[s][t] + 1;
        while (i >= 1) {
            for (int j = t; j >= 1; j--) {
                if (dp[i][j] == (num-1) && S.charAt(i-1) == T.charAt(j-1)) {
                    sb.insert(0, T.charAt(j-1));
                    num--;
                    break;
                }
            }
            i--;
        }

        return sb.toString();
    }

    void main(FastScanner in, PrintWriter out) {
        S = in.next();
        T = in.next();
        out.println( solve() );
    }

    public static void main(String[] args) throws Exception {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        FastScanner in = new FastScanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        Main m = new Main();
        m.main(in, out);
        out.close();
        in.close();
    }

    static class FastScanner {
        BufferedReader br;
        StringTokenizer st;
        public FastScanner(InputStream in) { br = new BufferedReader(new InputStreamReader(in)); }
        public int nextInt() { return Integer.parseInt(next()); }
        public long nextLong() { return Long.parseLong(next()); }
        public double nextDouble() { return Double.parseDouble(next()); }
        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try { st = new StringTokenizer(br.readLine()); }
                catch (IOException e) { e.printStackTrace(); }
            }
            return st.nextToken();
        }
        public String nextLine() {
            String str = "";
            try { str = br.readLine();
            } catch (IOException e) { e.printStackTrace(); }
            return str;
        }
        public void close() throws IOException { br.close(); }
    }
}

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

int main() {
	int a, b, c, d;
	std::cin >> a >> b >> c >> d;
	if (abs(a - c) <= d || (abs(a - b) <= d && abs(b - c) <= d)) {
		std::cout << "Yes" << std::endl;
	} else {
		std::cout << "No" << std::endl;
	}
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <iostream>
#include <cstdio>
#include <memory>
#include <string>
#include <cstdlib>
#include <set>
#include <utility>
#include <vector>
#include <list>
#include <algorithm>
#include <regex>
#include <cmath>
#include <map>
#include <iterator>
#include <climits>
#include <numeric>
#include <bitset>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <array>
#include <valarray>
#include <complex>
#include <random>
#include <functional>
#include <cassert>
#include <chrono>
#include <memory>

using namespace std;

#define int long long
//region TEMPLATE
////@formatter:off
#define double long double
typedef long long ll;
typedef unsigned long long ull;
template<typename T>void __read(T &a) { cin >> a; }
template<typename T, typename ... Args> void __read(T &a, Args &... args) { cin >> a;__read(args...);}
#define make(t, ...) t __VA_ARGS__; __read(__VA_ARGS__)
#define makev(a, n) VI a(n); FOR(n) cin >> a[i];
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define FORIT(p) for(auto it = p.begin(); it != p.end(); it++)
#define FOR(b) for(signed i = 0; i <(b); i++)
#define FORE(i, l, r) for(int i = (l); i < (r); i++)
#define NFOR(i, n) for(int i = (((int) n)-1); i >= 0; i--)
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef pair<int, int> PII;
typedef pair<pair<int, int>, int> PPII;
constexpr ll M7 = 1000000007ll;
constexpr ll M9 = 1000000009ll;
constexpr ll MFFT = 998244353ll;
template<class T> void outv(T &a) { for (auto &x : a) cout << x << ' '; }
static mt19937 rnd(static_cast<unsigned>(chrono::steady_clock::now().time_since_epoch().count())); // NOLINT(cert-err58-cpp)
auto __fast_io__ = (ios_base::sync_with_stdio(false), cin.tie(nullptr)); // NOLINT(cert-err58-cpp,cppcoreguidelines-interfaces-global-init)
////@formatter:on
//endregion


int32_t main() {
//    make(int, n);
//    cout << fixed << setprecision(10) <<  2 * n * M_PI;

    make(int, n, m);
    makev(a, m);
    cout << max(-1ll, n - accumulate(ALL(a), 0ll));
    return 0;
}

Measured memory_bytes: 3740
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

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

    static class CBase2Number {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();


            StringBuilder sb = new StringBuilder();
            while (n != 0) {
                if (n % 2 == 0) {
                    n /= -2;
                    sb.append('0');
                } else {
                    n--;
                    n /= -2;
                    sb.append('1');
                }
            }


            String answer = sb.reverse().toString();
            if (answer.isEmpty()) {
                answer = "0";
            }
            out.println(answer);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
// I 
// A M 
// T H E
// B E S T

// I 
// B E L I E V E 
// I N
// M Y S E L F
#include "bits/stdc++.h"
using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<long long> vll;
typedef vector<vll> vvll;
typedef vector<char> vc;
typedef vector<vc> vvc;
typedef vector<pair<long long,long long> > vpll;
typedef vector<vector<pair<ll,ll> > > vvpll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
 
#define FIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define all(x) x.begin() , x.end()
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define mp make_pair
#define F first
#define S second
#define left (node << 1)
#define right (node << 1) + 1
#define pii pair<int,int> 
#define mii map<int,int>
#define vi vector<int>
#define umii unordered_map<int,int>
#define PI 3.14159265359
// #define mod 998244353
#define mod 1000000007 
#define trace1(x)                cerr<<#x<<": "<<x<<endl
#define trace2(x, y)             cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)          cerr<<#x<<": " <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define FILL(name,val) memset(name , val , sizeof(name))
#define repo(i,o,e) for(int i = o ; i < e ; i++)
#define rep(n) for(int i = 0 ; i < n ; i++)
#define repa(i,sta,end,inc) for(int i = sta ; i <= end ; i += inc)
#define repb(i,sta,end,inc) for(int i = sta ; i >= end ; i -= inc)
const ll sz = 1e5+5;
int dx[] = {1, -1, 0, 0};
int dy[] = {0, 0, 1, -1};
 
const ll inf = 1000000000LL * 1000000000LL;

/*
ll power(ll x , ll y){
    ll res = 1;
    x %= mod;
    while(y){
        if(y&1){
            res = res * x % mod;
        }
        x = x*x % mod;
        y /= 2;
    }
    return res%mod;
}
*/

void solve(){
    double a , b, x;
    cin >> a >> b >> x;
    double h = x / (a*a);
    double ang;
    if(2*x <= a*a*b){
        //triangle
        double P = 2 * a * h / b;
        double B = b;
        ang = atan(P/B);
        ang *= 180 / PI;
        // cout << "triangle" ;
    }   
    else{
        //trapezium
        double P = 2*b - 2*h;
        double B = a;
        ang = atan(P/B);
        // ang = 90 - ang;
        ang *= 180 / PI;
        ang = 90.0 - ang;
        // cout << "trapezium";
    }
    ang = 90.0 - ang;
    cout << setprecision(10) << ang << endl;
    return;
}



int main(){
    FIO;
    int t = 1;
    // cin >> t;   
    while(t--){
        solve();
    }
    return 0;
}

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

#define LL long long
#define Dl double
#define Pb push_back
#define Po pop_back
#define Mp make_pair
#define Ub upper_bound
#define Lb lower_bound
#define In insert
#define All(x) x.begin(), x.end()
#define mem(a, b) memset(a, b, sizeof(a))
#define fast ios_base::sync_with_stdio(0);cin.tie(0)

using namespace std;

typedef vector<LL> Vl;
typedef vector<Vl> VVl;
typedef pair<LL, LL> Pll;
typedef vector<Pll> Vpl;
typedef queue<LL> Ql;
typedef stack<LL> Sl;
#define X first
#define Y second
#define mx3 1010
#define mx4 10010
#define mx5 100010
#define mx6 1000010

LL a[mx6];

int main()
{
    //freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

    LL n, x;
    cin >> n >> x;


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

    LL ans = 0;
    for(LL i = 1; i < n; i++){
        if(a[i - 1] > x){
            ans += a[i];
            a[i] = 0;
            ans += a[i - 1] - x;
            a[i - 1] = x;
        }
        else if(a[i] + a[i - 1] > x){
            ans += a[i] + a[i - 1] - x;
            a[i] = x - a[i - 1];
        }
    }

    cout << ans << '\n';
    return 0;
}



Measured memory_bytes: 1024