akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define repi(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define itr(it,a) for( auto it = (a).begin(); it != (a).end(); ++it )
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()

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

using ll = long long;

const ll mod = 1000000007;

struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=a;
  }
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const {
    return pow(mod-2);
  }
  mint& operator/=(const mint a) {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const {
    mint res(*this);
    return res/=a;
  }
};

struct combination {
  std::vector<mint> fact, ifact;
  combination(int n):fact(n+1),ifact(n+1) {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i) fact[i] = fact[i-1]*i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i) ifact[i-1] = ifact[i]*i;
  }
  mint operator()(int n, int k) {
    if (k < 0 || k > n) return 0;
    return fact[n]*ifact[k]*ifact[n-k];
  }
};

ll N, K;
ll sum[200010];

int main()
{
  std::cin >> N >> K;

  combination comb( N+10 );
  ll ans = 0;

  rep( k, N+10 )
    sum[k] = (N)*(N+1)/2-(N-k)*(N-k+1)/2;

  repi( k, K, N+2 )
    ans = (ans+sum[k]-(k-1)*k/2+1)%mod;

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

  return 0;
}

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

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

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

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

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

    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    printf("%lld %lld %lld\n", x, y, z);

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;
int main(){
	int N; long long int K; cin >> N >> K; 
	long long int A[510] = {}; long long int sum = 0; 
	for(int i = 0; i < N; i++){
		cin >> A[i]; sum += A[i]; 
	}
	vector<long long int> D; 
	for(long long int i = 1; i * i <= sum; i++){
		if(sum % i == 0){
			D.push_back(i); 
			D.push_back(sum / i); 
		}
	}
	sort(D.begin(), D.end(), greater<long long int>()); 
	for(int k = 0; k < D.size(); k++){
		vector<long long int> kp = {}; vector<long long int> km = {};
        long long int sp = 0; long long int sm = 0; 
		for(int i = 0; i < N; i++){
		    long long int tmp = A[i] % D.at(k);
		    if(tmp * 2 <= D.at(k)){
		        kp.push_back(tmp); sp += tmp;
		    }
		    else{
		        km.push_back(D.at(k) - tmp); sm += D.at(k) - tmp;
		    }
		}
        long long int kaisuu = 1e9 + 7; 
        if(sp == sm){
            kaisuu = sp;
        }
        else if(sp > sm){
            sort(kp.begin(), kp.end(), greater<long long int>()); 
            for(int i = 0; i < kp.size(); i++){
                sp -= kp.at(i); sm += D.at(k) - kp.at(i); 
                if(sp <= sm) break;
            }
            if(sp == sm){
                kaisuu = sp; 
            }
        }
        else if(sp < sm){
            sort(km.begin(), km.end(), greater<long long int>()); 
            for(int i = 0; i < km.size(); i++){
                sm -= km.at(i); sp += D.at(k) - km.at(i); 
                if(sp >= sm) break; 
            }
            if(sp == sm){
                kaisuu = sp; 
            }
        }
        if(kaisuu <= K){
			    cout << D.at(k) << endl; break; 
		}
	}
}

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

const long long MOD = 1e9 + 7;

int main() {
  int n;
  std::cin >> n;
  std::vector<long long> a(n);
  for (int i = 0; i < n; ++i)
    std::cin >> a[i];

  long long res = 0;
  for (int k = 0; k < 60; ++k) {
    long long one = 0;
    long long zero = 0;
    for (int i = 0; i < n; ++i) {
      if (a[i] & (1LL << k))
        ++one;
      else
        ++zero;
    }
    long long tmp = one * zero;
    tmp %= MOD;
    tmp *= ((1LL << k) % MOD);
    // for (int h = 0; h < k; ++h)
    //   tmp = 2 * tmp % MOD;
    tmp %= MOD;
    res += tmp;
    res %= MOD;
  }

  std::cout << res << std::endl;
}


Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;



int main(void)
{
    int n, x, y;
    cin >> n >> x >> y;
    if ( x > y ) swap(x,y);
    
    vector<int> cnt(n,0);
    
    for ( int i = 1; i <= n; ++i)
    {
        for ( int j = i+1; j <= n; ++j)
        {
            int length1 = j - i;
            int length2 = abs(i-x) + abs(j-y) + 1;
            int length = min(length1, length2);
            cnt[length] ++;
        }
    }
    
    for ( int i = 1; i < n; ++i) cout << cnt[i] << "\n";    
    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
ll gcd(ll a,ll b){ return __gcd(a,b); }
ll lcm(ll a,ll b){ return a/gcd(a,b)*b; }
 
ll mod=15;
 
ll add(ll a,ll b){
  return (a+b)%mod;
}
 
ll mul(ll a,ll b){
  return (a*b)%mod;
}
 
ll mod_pow(ll a,ll b){
  if(b==0)return 1;
  ll res=mod_pow( mul(a,a) ,b/2);
  if(b&1)res=mul(res,a);
  return res;
}
 
ll euler(ll n){
  ll res=n;
  for(ll i=2;i*i<=n;i++){
    if(n%i==0){
      res=res/i*(i-1);
      while(n%i==0)n/=i;
    }
  }
  if(n!=1)res=res/n*(n-1);
  return res;
}
 
bool isP(ll x){
  for(ll i=2;i*i<=x;i++){
    if(x%i==0)return false;
  }
  return (x>=2);
}
 
ll solve(ll a,ll b){
  ll cnt=0,k=a;
  while(1){
    k=(k*a)%b;
    cnt++;
    if(k==a){
      break;
    }
 
    if(cnt>1e8){
      cnt=euler(b);
      break;
    }
  }
  return cnt;
}
 
int main(){
  ll n;
  cin>>n;
 
  if(isP(n)){
    cout<<1<<endl;
    return 0;
  }
   
  vector<ll> s;
 
  for(ll i=2;i*i<=n;i++){
    if(n%(i*i)==0){
      cout<<-1<<endl;return 0;
    }
    if(n%i==0){
      s.push_back(i);
      s.push_back(n/i);
    }
  }
  ll ans=1;
   
  for(int i=0;i<(int)s.size();i++){
    ll num= euler(n/s[i]);
    ans=lcm(ans, num );
  }
   
 
 
  if( n%ans== 0 || __gcd(n,ans) !=1){
    cout<< -1 <<endl;
    return 0;
  }
   
  ll k=1,cnt=0;
  while(1){
    k=(k*n)%ans;
    cnt++;
    if(k==1){
      break;
    }
    if(cnt>1e8){
      cnt=euler(ans);
      break;
    }
  }
  cout<<cnt<<endl;
 
 
  /*
  ll C=1;
  for(ll i=0;i<n;i++){
    ll k=solve( i , n );
    C=lcm(k,C);
  }
  */
  //  cout<<C<<' '<<ans<<endl;
   
  return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define ll long long
#define p1 19260817
#define p2 19491001
#define m1 666623333
#define m2 1004535809
using namespace std;
int head[1048577],nxt[500005],tot=0;
int w1[500005],w2[500005],w[500005];
int a1[250005],b1[250005];
int a2[250005],b2[250005];
char s[250005];
ll ans=0;
inline int qpow(int a,int b,int mod)
{int res=1,tp=a;
while (b)
{if (b&1) res=1ll*res*tp%mod;
tp=1ll*tp*tp%mod;b>>=1;
}
return res;
}
inline void add(int v1,int v2)
{int bel=(1ll*v1*p1+v2)&1048575,i;
for (i=head[bel];i;i=nxt[i])
{if (w1[i]==v1&&w2[i]==v2) {w[i]++;return;}
}
tot++;nxt[tot]=head[bel];head[bel]=tot;
w1[tot]=v1;w2[tot]=v2;w[tot]=1;
}
inline int ask(int v1,int v2)
{int bel=(1ll*v1*p1+v2)&1048575,i;
for (i=head[bel];i;i=nxt[i])
{if (w1[i]==v1&&w2[i]==v2) return w[i];
}
return 0;
}
inline int sub1(int a,int b)
{return (a-b<0?a-b+m1:a-b);}
inline int sub2(int a,int b)
{return (a-b<0?a-b+m2:a-b);}
inline int add1(int a,int b)
{return (a+b>=m1?a+b-m1:a+b);}
inline int add2(int a,int b)
{return (a+b>=m2?a+b-m2:a+b);}
int main (){
	int i,n,x1=0,x2=0;
	scanf ("%d",&n);
	scanf ("%s",s+1);
	a1[n+1]=1;b1[n+1]=0;
	a2[n+1]=1;b2[n+1]=0;
	int inv1=qpow(p1,m1-2,m1);
	int inv2=qpow(p2,m2-2,m2);
	for (i=n;i>=1;i--)
	{if (s[i]=='<') 
	{a1[i]=1ll*a1[i+1]*p1%m1;
	a2[i]=1ll*a2[i+1]*p2%m2;
	b1[i]=b1[i+1];b2[i]=b2[i+1];
	continue;
	}
	if (s[i]=='>')
	{a1[i]=1ll*a1[i+1]*inv1%m1;
	a2[i]=1ll*a2[i+1]*inv2%m2;
	b1[i]=b1[i+1];b2[i]=b2[i+1];
	continue;
	}
	if (s[i]=='+')
	{b1[i]=sub1(b1[i+1],a1[i+1]);
	b2[i]=sub2(b2[i+1],a2[i+1]);
	a1[i]=a1[i+1];a2[i]=a2[i+1];
	continue;
	}
	b1[i]=add1(b1[i+1],a1[i+1]);
	b2[i]=add2(b2[i+1],a2[i+1]);
	a1[i]=a1[i+1];a2[i]=a2[i+1];
	}
	for (i=n;i>=1;i--)
	{if (s[i]=='+') {x1=add1(x1,1);x2=add2(x2,1);continue;}
	if (s[i]=='-') {x1=sub1(x1,1);x2=sub2(x2,1);continue;}
	if (s[i]=='<') {x1=1ll*x1*inv1%m1;x2=1ll*x2*inv2%m2;continue;}
	x1=1ll*x1*p1%m1;x2=1ll*x2*p2%m2;
	}
	add(0,0);
	for (i=n;i>=1;i--)
	{int r1=(1ll*a1[i]*x1+b1[i])%m1;
	int r2=(1ll*a2[i]*x2+b2[i])%m2;
	ans+=ask(r1,r2);
	add(b1[i],b2[i]);
	}
	printf ("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 16384
require "set"

class St
  attr :p, :cost

  def initialize(p, cost)
    @p = p
    @cost = cost
  end

  def >(other)
    @cost == other.cost ? @p > other.p : @cost > other.cost
  end
end

class PriorityQueue
  def initialize()
    @data = []
  end

  def push(x)
    i = @data.bsearch_index { |y| y > x }
    if i
      @data.insert(i, x)
    else
      @data.push(x)
    end
  end

  def length()
    @data.length
  end

  def pop()
    @data.shift
  end
end

class Dijkstra
  def initialize(n)
    @n = n
    @adj = Array.new(n) { Array.new(0) }
  end

  def set(s, t, cost)
    @adj[s].push({ to: t, cost: cost })
  end

  def calc(s)
    @visited = Array.new(@n, -1)
    que = PriorityQueue.new
    que.push(St.new(s, 0))
    while que.length > 0
      current = que.pop
      cp = current.p
      next if (@visited[cp] != -1)
      @visited[cp] = current.cost
      @adj[cp].each do |a|
        if (@visited[a[:to]] == -1)
          que.push(St.new(a[:to], current.cost + a[:cost]))
        end
      end
    end
  end

  def result(p)
    @visited[p]
  end
end

vn, en, r = gets.split.map(&:to_i)
g = Dijkstra.new(vn)
en.times do
  s, t, d = gets.split.map(&:to_i)
  g.set(s, t, d)
end

g.calc(r)

vn.times do |i|
  res = g.result(i)
  puts(res == -1 ? "INF" : res)
end



Measured memory_bytes: 146336
data = input().split(' ')
h = int(data[0])
w = int(data[1])
s_mat = list()
for _ in range(h):
    s_mat.append(input())
# Count bombs
num_mat = [[0 for _ in range(w)] for _ in range(h)]
for hh in range(h):
    for ww in range(w):
        if s_mat[hh][ww] != '#':
            continue
        # if current cell has a bomb
        if hh + 1 <= h - 1 and ww + 1 <= w - 1:
            num_mat[hh + 1][ww + 1] += 1
        if hh + 1 <= h - 1:
            num_mat[hh + 1][ww] += 1
        if hh + 1 <= h - 1 and ww - 1 >= 0:
            num_mat[hh + 1][ww - 1] += 1
        if ww + 1 <= w - 1:
            num_mat[hh][ww + 1] += 1
        if ww - 1 >= 0:
            num_mat[hh][ww - 1] += 1
        if hh - 1 >= 0 and ww + 1 <= w - 1:
            num_mat[hh - 1][ww + 1] += 1
        if hh - 1 >= 0:
            num_mat[hh - 1][ww] += 1
        if hh - 1 >= 0 and ww - 1 >= 0:
            num_mat[hh - 1][ww - 1] += 1
# print
def get_cell(hh, ww):
    if s_mat[hh][ww] == '#':
        return '#'
    else:
        return str(num_mat[hh][ww])
for hh in range(h):
    print(''.join([get_cell(hh, ww) for ww in range(w)]))

Measured memory_bytes: 3064
import java.io.*;
import java.util.*;
import static java.lang.System.out;

public class Main {
    static MyReader in = new MyReader();

    public static void main(String[] args) {
        int N = in.i();
        int K = in.i();
        int mod = 998244353;
        int[][] LR = new int[K][];
        for (int i = 0; i < K; i++) {
            LR[i] = new int[]{in.i(), in.i()};
        }
        long[] dp = new long[N + 1];
        dp[1] = 1;
        long[] sum = new long[N + 2];
        sum[2] = 1;
        for (int i = 2; i <= N; i++) {
            for (int j = 0; j < K; j++) {
                int r = i - LR[j][0];
                int l = i - LR[j][1];
                if (r < 1) continue;
                if (l < 1) l = 1;
                dp[i] = (dp[i] + sum[r + 1] - sum[l]) % mod;
            }
            sum[i + 1] = (sum[i] + dp[i]) % mod;
        }
        out.println((dp[N] + mod) % mod);
    }
}

class MyReader extends BufferedReader {
    char[] cbuf = new char[1024];
    int head = 0;
    int tail = 0;

    MyReader() {
        super(new InputStreamReader(System.in));
    }

    char next() {
        if (head == tail) {
            try {
                tail = super.read(cbuf, 0, cbuf.length);
            } catch (IOException e) {
                e.printStackTrace();
            }
            head = 0;
        }
        return cbuf[head++];
    }

    void back() {
        head--;
    }

    boolean minus() {
        boolean minus;
        while (true) {
            char c = next();
            if (!isDelimiter(c)) {
                if (!(minus = c == '-')) back();
                return minus;
            }
        }
    }

    void skip() {
        while (isDelimiter(next()));
        back();
    }

    char[] s(int N) {
        char[] cbuf = new char[N];
        read(cbuf, 0, N);
        return cbuf;
    }

    public int read(char[] cbuf, int off, int len) {
        skip();
        int i;
        for (i = 0; i < cbuf.length; i++) {
            char c = next();
            if (isDelimiter(c)) {
                break;
            }
            cbuf[i] = c;
        }
        return i;
    }

    boolean isDelimiter(char c) {
        return c == ' ' || c == '\n' || c == '\r';
    }

    int i() {
        boolean minus = minus();
        int n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }

    int[] ii(final int N) {
        int[] a = new int[N];
        for (int j = 0; j < a.length; j++) a[j] = i();
        return a;
    }

    long l() {
        boolean minus = minus();
        long n = 0;
        while (true) {
            int k = next() - '0';
            if (k < 0 || 9 < k) break;
            n = 10 * n + k;
        }
        return minus ? -n : n;
    }
}


Measured memory_bytes: 36816
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
#include <cstdio>
#include <tuple>
#include <numeric>
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define CST(x) cout<<fixed<<setprecision(x)//小数点以下の桁数指定
#define ct(a) cout<<a<<endl
static const double pi = 3.141592653589793;
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e9+7;
const ll mod= 1e9 + 7;


int V = 200001;//頂点の数
vector<int> G[200001];//辺の情報！
ll C[200001]; //カウンタ
ll d[200001];
ll used[200001];

void dfs(int s) {
	FOR(i, 0, G[s].size()) {
		if (used[G[s][i]] == 1)continue;
			C[G[s][i]] = C[s] + d[G[s][i]];
			used[G[s][i]] = 1;
			dfs(G[s][i]);
	}
}

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

	int N, Q; cin >> N >> Q;
	FOR(i, 0, N-1) {
		int a, b; cin >> a >> b;
		G[a].emplace_back(b);
		G[b].emplace_back(a);
	}
	FOR(i, 0, Q) {
		int p, x; cin >> p >>x;
		d[p] += x;
		
	}
	C[1] = d[1];
	used[1] = 1;
	dfs(1);

	FOR(i, 1, N + 1) {
		cout << C[i] <<" ";
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 27136
#include <algorithm>
#include <cstdint>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <cfloat>

using namespace std;

using lint=int64_t;
using uint=uint32_t;
using ulint=uint64_t;

template<class T>
using vector2d=vector<vector<T>>;

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

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

template <class T>
void OutVec(const vector<T>& vec){
  for(int i = 0; i < vec.size() - 1; ++i){
    cout<<vec[i]<<" ";
  }
  cout<<vec.back()<<endl;
}

template <class T>
void OutVec2d(const vector2d<T>& vec){
  for(auto v:vec){
    OutVec(v);
  }
}

int main(){
  cout << std::fixed << std::setprecision(16);
  cin.tie(nullptr);
  std::ios::sync_with_stdio(false);

  int n;
  cin>>n;
  vector<int> count(n+1);
  for(int i=2;i<=n;i++){
    int a;
    cin>>a;
    count[a]++;
  }
  for(int i=1;i<=n;i++){
    cout<<count[i]<<endl;
  }



  return 0;
}




Measured memory_bytes: 3988
#include <iostream>
#include <string>
#include <vector>

using namespace std;
typedef long long ll;

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

    vector<vector<ll>> dp(n, vector<ll>(n, 0));

    for(ll i = n - 1; i >= 0; --i){
        for(ll j = n - 1; j > i; --j){
            if(s.at(i) == s.at(j)){
                if(j < n - 1){
                    dp.at(i).at(j) = 1 + dp.at(i + 1).at(j + 1);
                }else{
                    dp.at(i).at(j) = 1;
                }
            }else{
                dp.at(i).at(j) = 0;
            }
        }
    }

    ll ans = 0;
    for(ll i = 0; i < n; ++i){
        for(ll j = i + 1; j < n; ++j){
            ans = max(ans, min(j - i, dp.at(i).at(j)));
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 195840
#include <bits/stdc++.h>
typedef  long long ll;
#define INF 1000000000
#define N 100005
using namespace std;
int main(void){
    int a,b,c,x,y;
    cin>>a>>b>>c>>x>>y;
    int ans=INF;
    for(int i=0;i<=max(2*x,2*y);i+=2){
        int tmp=0,num_x,num_y;
        num_x=(x-i/2);
        num_y=(y-i/2);
        if(num_x<0){
            num_x=0;
        }
        if(num_y<0){
            num_y=0;
        }
        tmp=num_x*a+num_y*b+i*c;
        if(tmp<ans){
            ans=tmp;
        }

    }
    cout<<ans<<endl;

}

Measured memory_bytes: 256
n = int(input())
number = list(map(int,input().split()))

def function(n):
    a = []
    if n < 2:
        return a
    while n%2 ==0:
        a.append(2)
        n = n//2
    i = 3
    while i*i <= n:
        if n%i ==0:
            a.append(i)
            n = n//i
        else:
            i += 2
    if n > 1:
        a.append(n)
    return a

diction = {}
for i in range(n):
    prime_factor = function(number[i])
    for k in prime_factor:
        a = prime_factor.count(k)
        if k not in diction:
            diction[k] = a
        elif diction[k] < a:
            diction[k] = a
ans= 1            
for a in diction:
    ans *= a**diction[a]
    
print(ans)

Measured memory_bytes: 7788
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <functional>

using namespace std;
typedef long long int ll;

#define repi(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,a) repi(i,0,a)
#define rrep(i,a) for(ll i=a-1;i>=0;i--)

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

  string ans = "";
  while(N){
    if(N % 2){
      ans = "1" + ans;
      N = (1 - N) / 2;
    }
    else{
      ans = "0" + ans;
      N /= -2;
    }
  }
  if(ans == "") ans = "0";
  cout << ans << endl;
  return 0;
}


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

int64_t comper(vector<int> &vec, int h, int low) {
  if (h >= low) {
    return 0;
  }
  else if (low - h == 1) {
    return vec.at(h);
  }
  else {
    return comper(vec, h+1, low) + (vec.at(h)) * pow(10, low - h - 1);
  }
}
    

int main() {
  string S;
  cin >> S;
  int sz = S.size();
  int low, h;
  vector<int> vec(sz);
  for (int i=0; i < sz; i++) vec.at(i) = S.at(i) - '0';
  vector<vector<int64_t>> ncat(sz, vector<int64_t>(sz + 1));
  int64_t ans = 0;
  for (h=0; h < sz; h++){
    for (low=h+1; low < sz + 1; low++) {
      ncat.at(h).at(low) = comper(vec, h, low);
      if (h == 0 && low == sz)  ans += ncat.at(h).at(low);
      else if (h == 0 && low != sz)  ans += pow(2, sz - low - 1) * ncat.at(h).at(low);
      else if (h != 0 && low == sz)  ans += pow(2, h - 0 - 1) * ncat.at(h).at(low);
      else  ans += pow(2, sz - low - 1) * pow(2, h - 0 - 1) * ncat.at(h).at(low);
    }
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
// AOJ 1350 There is No Alternative
// 2018.3.2 bal4u
 
#include <stdio.h>
//#include <stdlib.h>
#include <string.h>
 
/* UNION-FIND library */
#define MAX 502
short id[MAX], size[MAX], id0[MAX], size0[MAX];
void init(int n) { int i; for (i = 0; i < n; i++) id[i] = i, size[i] = 1; }
int root(int i) { while (i != id[i]) id[i] = id[id[i]], i = id[i]; return i; }
int connected(int p, int q) { return root(p) == root(q); }
void unite(int p, int q)
{
    int i = root(p), j = root(q); if (i == j) return;
    if (size[i] < size[j]) id[i] = j, size[j] += size[i]; else id[j] = i, size[i] += size[j];
}

//#define getchar_unlocked()  getchar()
int in()
{
	int n = 0;
	int c = getchar_unlocked();
	do n = (n<<3)+(n<<1) + (c & 0xf), c = getchar_unlocked();
	while (c >= '0');
	return n;
}

typedef struct { int s, d, c; } T;
T e[50002], e0[50002];
T ee[50002]; int sz;
int f[10002];


int main()
{
	int N, M, i, j, t, MST, ansf, anss;

	N = in(), M = in();
	for (i = 0; i < M; i++) {
		e0[i].s = in()-1, e0[i].d = in()-1, e0[i].c = t = in();
		f[t]++;
	}
	for (i = 1; i <= 10000; i++) f[i] += f[i-1];
	for (i = M-1; i >= 0; i--) t = e0[i].c, e[--f[t]] = e0[i];

	for (i = 0; i < N; i++) id0[i] = i, size0[i] = 1;
	memcpy(id, id0, N << 1), memcpy(size0, size0, N << 1);
	MST = 0, sz = 0;
	for (i = 0; i < M; i++) {
		if (!connected(e[i].s, e[i].d)) {
			unite(e[i].s, e[i].d);
			ee[sz++] = e[i], MST += e[i].c;
		}
	}

	ansf = anss = 0;
	for (i = 0; i < sz; i++) {
		int ss = ee[i].s, dd = ee[i].d;
		memcpy(id, id0, N << 1), memcpy(size0, size0, N << 1);
		t = 0;
		for (j = 0; j < M; j++) {
			if (!connected(e[j].s, e[j].d) && (e[j].s != ss || e[j].d != dd)) {
				unite(e[j].s, e[j].d);
				t += e[j].c; if (t > MST) break;
			}
		}
		if (t != MST) ansf++, anss += ee[i].c;
	}
	printf("%d %d\n", ansf, anss);
	return 0;
}


Measured memory_bytes: 3124
fn main() {
    let mut buf = String::new();
    let handle = std::io::stdin();
    handle.read_line(&mut buf).unwrap();
    let data: Vec<usize> = buf.trim().split_whitespace()
        .map(|a| a.parse().unwrap()).collect();

    let (n, a, b, c, d) = (data[0], data[1], data[2], data[3], data[4]);

    let mut total = 0;
    let mut a_money = 0;
    while n > total {
        total += a;
        a_money += b;
    }
    let mut total = 0;
    let mut c_money = 0;
    while n > total {
        total += c;
        c_money += d;
    }
    let ans = if a_money < c_money {
        a_money
    } else {
        c_money
    };
    println!("{}", ans);
}


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

int main(){
    int a[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    int n;
    cin >> n;
    cout << a[n-1] << endl;
}

Measured memory_bytes: 256
N,K = map(int,input().split())
S = list(input())
siawase = 0
 
LRchange_count = -1#初回必ず+1されるので、初期値を-1にしておく
LRittiFlg = True
temp_char = 'temp'
#temp_renzoku = 0
 
for s in S:
    #print(s,temp_char)
    if s != temp_char:
        LRchange_count += 1
    else:
        siawase += 1
    temp_char = s
    
if S[0] == S[-1]:
    LRittiFlg = True
else:
    LRittiFlg = False
    
if K+1 >= LRchange_count:
    print(len(S)-1)
# elif K-1 == LRchange_count:
#         if LRittiFlg:
#             print(K*2 + siawase)
#         else:
#             print(K*2 + siawase - 1)
else:
    print(min(K*2 + siawase,len(S)-1))

Measured memory_bytes: 4084
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	string s;
	cin >> s;
	reverse(all(s));
	ll ans = 0;
	int n = s.size();
	const int mod = 2019;
	vector<int> tot(n+1), cnt(mod);
	int x = 1;
	rep(i, n) {
		if(i == 0) tot[i+1] = (int) (s[i] - '0');
		else tot[i+1] = (tot[i] + (int) (s[i] - '0')* x) % mod;
		x *= 10;
		x %= mod;
	}
	rep(i, n+1) cnt[tot[i]]++;
	rep(i, mod) ans += cnt[i]*(cnt[i]-1)/2;
	// rep(i, n+1) cout << tot[i] << " ";
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4380
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 1000000007
vector<vector<int> > dp;
vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));

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

	int N;
	cin>>N;
	VI T(N+1);
	VI X(N+1);
	VI Y(N+1);
	REP(i,N)cin>>T[i+1]>>X[i+1]>>Y[i+1];
	T[0]=0;
	X[0]=0;
	Y[0]=0;
	FOR(i,1,N+1){
		int A=T[i]-T[i-1];
		int B=abs(X[i]-X[i-1]);
		B+=abs(Y[i]-Y[i-1]);
		if(A>=B && (A-B)%2==0)continue;
		else{
			cout<<"No"<<endl;
			return 0;
		}
	}
	cout<<"Yes"<<endl;
	
	return 0;
}


Measured memory_bytes: 1408
L,R = map(int,input().split())
list_LR = range(L,R+1)

list_aaa =[]

ans = 2019
l=min(L+2019, R+1)

for i in range(L,l):
    for j in range(i+1,l):
        ans = min(ans,(i*j)%2019)

print(ans)

Measured memory_bytes: 3060
n,k = map(int, input().split())
al = list(map(int, input().split()))

ok, ng = 10**9+1, 0
while abs(ok-ng) > 1:
    mid = (ok+ng) // 2
    # mid = (ok+ng) / 2
    cnt = 0
    for a in al:
        a_cnt = (a-1)//mid
        cnt += max(0,a_cnt)

    if cnt <= k:
        ok = mid
    else:
    	ng = mid

print(ok)

Measured memory_bytes: 94312
/*
                                        //     //     //\\\\\\\\\
                                        \\    //      \\        \\
                                        //   //       //         \\
                                        \\  //        \\          \\
                                        // //         //           \\
                                        \\//          \\            \\       
                                        //\\          //            //
                                        \\ \\         \\           //
                                        //  \\        //          //
                                        \\   \\       \\         //
                                        //    \\      //        //
                                        \\     \\     \\/////////
*/

#include <bits/stdc++.h>
//#include <boost/math/common_factor.hpp>
//#include <boost/multiprecision/cpp_int.hpp>
using namespace std;
//using namespace boost::multiprecision;
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define vint vector <int>
#define vll vector <long long int>
#define endl cout<<'\n'
#define fre(i,l,n) for(long long int i=l;i<n;++i)
#define fr(i,l,n) for(long long int i=l;i<=n;i++)
#define rfre(i,n,l) for(long long int i=n-1;i>=l;i--)
#define rfr(i,n,l) for(long long int i=n;i>=l;--i)
#define tab '\t'
#define debug cout<<'*';
#define s(a) cin>>a
#define p(a) cout<<a
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pii;
typedef pair<long long int,long long int> pll;
typedef pair<int,pair<int,int> > tii;
typedef vector<int> vec;
typedef vector<long long> vecll;
typedef vector<pair<int,int> > vec_pii;
typedef vector<pair<long long int,long long int> > vec_pll;
typedef vector<vector<int> > vvi;
typedef vector<vector<ll> > vvll;
typedef vector<vector<pair<int,int> > > vvpii;
typedef vector<vector<pair<ll,ll> > > vvpll;
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define mod 1000000007
#define Pi 3.14159265358979
#define gcd(a,b) __gcd(a,b)
#define sf(n) scanf("%lld",&(n))
#define pf(n) printf("%lld\n",(n))
#define min3(a,b,c) (min((c),min((a),(b))))
#define max3(a,b,c) (max((a),max((b),(c))))
#define w(t) while(t--)
#define flt(a) cout<<fixed<<setprecision(a)
#define cntSetBits(n) __builtin_popcountll(n)
/*****************************
*****************************/




void solve()
{
    ll n,k;
    s(n);s(k);
    vecll arr(n);
    fre(i,0,n)
    {
        s(arr[i]);
    }
    ll sum = 0;
    sort(arr.begin(), arr.end());
    fre(i,0,k)
    {
        sum += arr[i];
    }
    p(sum);endl;
}



int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    ll t=1;
    // s(t);
    w(t)
    {
        solve();
    }
    return 0;
}









Measured memory_bytes: 3612
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

class Debugger {
public:
	template<typename T>
	void printVector(vector<T> const &vec, bool printSize=true){
		if(printSize){
			cout << vec.size() << endl;
		}
		for(auto &elem : vec){
			cout << elem << " ";
		}
		cout << endl;
	}

	template<typename T>
	void printMatrix(vector<vector<T>> const &matrix){
		cout << matrix.size()<< " ";
		if(!matrix.empty()){
			cout << matrix[0].size();
		}
		cout << endl; 
		for(auto &vec : matrix){
			printVector(vec, false);
		}
		cout << endl;
	}
};

const int maxN = 100005;
const int INF = 1e9;
#define ll long long

class TaskA {
private:
	Debugger debugger;

public:
	void solveOne(int it){
		int l, r , d;
		cin >> l >> r >> d;
		int ans = 0; 
		for(int i = l; i <= r; i++){
			if(i % d == 0){
				ans++;
			}
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};

int main(){
	srand(time(NULL));
	ios_base::sync_with_stdio(false);
	TaskA solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 3632
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.List;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.io.InputStream;
 
public class Main {
 
	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		FastScanner in = new FastScanner(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskB solver = new TaskB();
		solver.solve(1, in, out);
		out.close();
	}
 
	static class TaskB {
		public void solve(int testNumber, FastScanner in, PrintWriter out) {
 
 
			char[] c = in.next().toCharArray();
			int[] num = new int[26];
 
			for (int i = 0; i < c.length; i++) {
				num[c[i] - 'a']++;
			}
 
			boolean isBeautiful = true;
			for (int i = 0; i < num.length; i++) {
				if (num[i] % 2 != 0) {
					isBeautiful = false;
					break;
				}
			}
 
			System.out.println(isBeautiful ? "Yes" : "No");
		}
	}
 
	static class FastScanner {
		private BufferedReader in;
		private StringTokenizer st;
 
		public FastScanner(InputStream stream) {
			in = new BufferedReader(new InputStreamReader(stream));
		}
 
		public String next() {
			while (st == null || !st.hasMoreTokens()) {
				try {
					String rl = in.readLine();
					if (rl == null) {
						return null;
					}
					st = new StringTokenizer(rl);
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return st.nextToken();
		}
 
		public int nextInt() {
			return Integer.parseInt(next());
		}
 
	}
}

Measured memory_bytes: 22612
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store") // to restrict undesirable precision
#pragma GCC optimize ("-fno-defer-pop")// to pop argument of function as soon as it returns
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
//((1.0l)*BIG MULTIPLY MAGIC?)
// string to integer stoi()
// string to long long stoll()
// string.substr(position,length);
// integer to string to_string();
//-----------------------------------------------
ll n; ld ar[10][2]; ld an=0,cnt=0;
void findans(ll mask,ld dst,ll last_i){
	if(__builtin_popcount(mask)==n){
		cnt+=1.0;
		an+=dst;
		return ;
	}

	ll i; ld ans=0;
	for(i=0;i<n;i++){
		if((mask&(1LL<<i))==0){
			ld ndst=sqrt((ar[i][0]-ar[last_i][0])*(ar[i][0]-ar[last_i][0])+(ar[i][1]-ar[last_i][1])*(ar[i][1]-ar[last_i][1]));
			findans((mask|(1LL<<i)),dst+ndst,i);
		}
	}
}
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,l;
	cin>>n;
	for(i=0;i<n;i++){
		cin>>ar[i][0]>>ar[i][1];
	}

	for(i=0;i<n;i++){
		findans((1LL<<i),0.0,i);
	}
	an=an/cnt;
	cout<<fixed<<setprecision(10)<<an;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const long long MOD = 1e9+7;
#define rep(i,n) for(int i=0;i<n;++i)
typedef long long int ll;
typedef unsigned long long ull;
template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
typedef pair<ll,ll> P;


int main()
{
    int n;
    cin>>n;
    vector<int> a(n);
    vector<ll> sum(n);
    rep(i,n)sum[i]=0;
    rep(i,n){
        cin>>a[i];
        if(i)sum[i]=sum[i-1]+(ll)a[i];
        else sum[i]=a[i];
    }
    ll MIN=abs(sum[0]-(sum[n-1]-sum[0]));
    rep(i,n-1)
    {
        ll b=abs(sum[i]-(sum[n-1]-sum[i]));
       // cout<<MIN<<" "<<b<<endl;
        MIN = min(MIN,b);
        //if(MIN!=b)break;
    }
    cout<<MIN<<endl;

    return 0; 
}


Measured memory_bytes: 5640
sx, sy, tx, ty = map(int, input().split())
mx = tx - sx
my = ty - sy
print("U"*my+"R"*mx+"D"*my+"L"*mx+"L"+"U"*(my+1)+"R"*(mx+1)+"DR"+"D"*(my+1)+"L"*(mx+1)+"U")


Measured memory_bytes: 9000
#include <iostream>
#include <stdio.h>
#include <math.h>
#include <string>
#include <algorithm>

using namespace std;

int main()
{
    long long n,s[11];
    cin >> n;
    s[0] = 26;
    int i;
    for (i = 1; s[i-1]<n; i++)
        s[i] = s[i - 1] + pow(26, i+1);

    int a[i];
    for (int j = 0; n>0; j++){
        n--;
        a[j] = n % 26;
        n /= 26;
    }
    for (int j = i-1; j >=0 ;j--)
        printf("%c", 'a' + a[j]);
}

Measured memory_bytes: 4060
#include<bits/stdc++.h>
#include<limits>
#define ll long long
#define F first
#define S second
#define pb push_back
#define oo 1e18
#define endl '\n'
#define si size()
#define all(v) v.begin(),v.end()
#define FASTIO ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define Matrix vector< vector < long long > >
#define vi vector<int>
#define vll vector<ll>
#define vd vector<double>
#define vs vector<string>

using namespace std;

int dx[] = {0,1,0,-1};
int dy[] = {1,0,-1,0};

const long double Pi=acos(-1),e=2.718;
const ll N=1e18,mod=1e9+7 ;


int main ()
{
    FASTIO;
    ll n ;
    cin >> n ;
    ll sum = 1;
    vll a(n);
    for(int i=0;i<n;i++){
        cin >> a[i];
    }
    sort(all(a));
    if(a[0]==0)return cout << 0 << endl,0;
    for(auto x:a){
        if(x > N/sum)return cout << -1 << endl,0;
        sum *= x;
    }
    cout << sum << endl;
    return 0;
}
/**


*/


Measured memory_bytes: 3924
#include <bits/stdc++.h>
using namespace std;
struct st {
	int no;
	string s;
};

const int N = 1e5 + 5;
st a[N];
int flag[N], cnt[N];

int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	for (int i = 0; i < m; i++) {
		cin >> a[i].no >> a[i].s;
	}
	int sum1 = 0, sum2 = 0;
	for (int i = 0; i < m; i++) {
		if (!flag[a[i].no]) {
			if (a[i].s == "WA")
				cnt[a[i].no]++;
			else {
				sum1++;
				flag[a[i].no] = 1;
				sum2 += cnt[a[i].no];
			}
		}
	}
	cout << sum1 << " " << sum2;
	return 0;
}

Measured memory_bytes: 7296
#include <iostream>
#include<algorithm>
#include <string>

using namespace std;

int main(void) {
	string s;

	cin >> s;
	int hug = 0;
	int j = s.length()-1;
	for (int i = 0; i < s.length() ; i++)
	{
		if (i >= j)
		{
			break;
		}
		if (s[i] != s[j])
		{
			hug++;
		}
		
		j--;
	}
	cout << hug;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <array>
#include <algorithm>

using std::cin;
using std::cout;
using std::endl;
using std::array;
using std::sort;
using std::reverse;

int main()
{
  array<int, 3> ary;
  cin >> ary[0] >> ary[1] >> ary[2];

  sort(ary.begin(), ary.end());

  cout << (( ary[2] == ary[0] + ary[1] ) ? "Yes" : "No") << endl;
}



Measured memory_bytes: 256
import java.math.BigInteger;
import java.util.Arrays;
import java.util.Collections;
import java.util.Scanner;

class Main {

	public static void main(String[] args) {
		Scanner s = null;
		try {
			s = new Scanner(System.in);

			while (s.hasNextInt()) {
				BigInteger[] num = { s.nextBigInteger(), s.nextBigInteger() };
				Arrays.sort(num, Collections.reverseOrder());
				System.out.println(gcd(num) + " " + lcm(num));
			}

		} finally {
			s.close();
		}

	}

	public static BigInteger gcd(BigInteger[] num) {
		return num[0].gcd(num[1]);
	}

	private static BigInteger lcm(BigInteger[] num) {
		return (num[0].multiply(num[1])).divide(gcd(num));
	}
}

Measured memory_bytes: 18200
#include <bits/stdc++.h>
using namespace std;
typedef long long lint;

const lint MOD = (lint)1e6 + 3;
lint fact[MOD], fact_inv[MOD], inv[MOD];

lint mod_pow(lint n, lint x){
    lint res = 1;
    while(x){
        if(x&1) res = res * n % MOD;
        x >>= 1, n = n * n % MOD;
    }
    return res;
}

lint solve(lint n, lint x){
    if(x==0 || MOD<=x+n-1) return 0;
    else return fact[x+n-1] * fact_inv[x-1] % MOD;
}

int main(){
    ios::sync_with_stdio(false), cin.tie(nullptr);
    int Q; cin >> Q;
    fact[0] = 1;
    for(lint i=1;i<MOD;i++) fact[i] = fact[i-1] * i % MOD;
    fact_inv[MOD-1] = mod_pow(fact[MOD-1], MOD-2);
    for(lint i=MOD-2;0<=i;i--){
        fact_inv[i] = fact_inv[i+1] * (i+1) % MOD;
        inv[i+1] = fact[i] * fact_inv[i+1] % MOD;
    }

    while(Q--){
        lint x, d, n; cin >> x >> d >> n;
        if(d==0) cout << mod_pow(x, n) << endl;
        else{
            lint y = x * inv[d] % MOD;
            cout << solve(n, y) * mod_pow(d, n) % MOD << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long long n; cin >> n;
    vector<string> s(n);

    for(int i = 0; i < n; i++){
        cin >> s[i];
        sort(s[i].begin(),s[i].end());
    }
    sort(s.begin(),s.end());

    long long count1 = 1;
    long long count2 = 0;
    for(int i = 0; i < n-1; i++){
        if(s[i] == s[i+1]) count1++;
        else{
            count2 += ( count1 * (count1 - 1)) / 2 ;
            count1 = 1;
        }
    }
    count2 += ( count1 * (count1 - 1)) / 2 ;
    cout << count2 << endl;
    return 0;
}

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

int main()
{
  char str1[15], str2[15];
  int len1 = 0, len2 = 0;
  
  char c = getchar();
  while(c != '\n')
  {
    str1[len1++] = c;
    c = getchar();
  }
  str1[len1++] = '\0';
  
  c = getchar();
  while(len2 < (len1-1))
  {
    str2[len2++] = c;
    c = getchar();
  }
  getchar();
  str2[len2++] = '\0';
  
  if(!strcmp(str1,str2))
    printf("Yes");
  else
    printf("No");
  return 0;
  
}

Measured memory_bytes: 3700
use io::*;
use std::process::exit;

fn main() {

    let con = read_string();
    let mut sc = Scanner::new(&con);

    let n: usize = sc.next();
    let y: usize = sc.next();

    let mut t1 = 0;
    let mut t5 = 0;
    let mut t10 = 0;

    for i in 0..n+1 {
        for j in i..n+1 {
           t1 = i;
           t5 = j - i;
           t10 = n - j;

           if t1*1000 + t5*5000 + t10*10000 == y {
               println!("{} {} {}", t10, t5, t1);
               exit(0);
           }
        }
    }
    println!("-1 -1 -1");
}

pub mod io {

    use std;
    use std::str::FromStr;

    pub struct Scanner<'a> {
        iter: std::str::SplitWhitespace<'a>,
    }

    impl<'a> Scanner<'a> {
        pub fn new(s: &'a str) -> Scanner<'a> {
            Scanner {
                iter: s.split_whitespace(),
            }
        }

        pub fn next<T: FromStr>(&mut self) -> T {
            let s = self.iter.next().unwrap();
            if let Ok(v) = s.parse::<T>() {
                v
            } else {
                panic!("Parse error")
            }
        }

        pub fn next_vec_len<T: FromStr>(&mut self) -> Vec<T> {
            let n: usize = self.next();
            self.next_vec(n)
        }

        pub fn next_vec<T: FromStr>(&mut self, n: usize) -> Vec<T> {
            (0..n).map(|_| self.next()).collect()
        }
    }

    pub fn read_string() -> String {
        use std::io::Read;

        let mut s = String::new();
        std::io::stdin().read_to_string(&mut s).unwrap();
        s
    }

    pub fn read_line() -> String {
        let mut s = String::new();
        std::io::stdin().read_line(&mut s).unwrap();
        s.trim_right().to_owned()
    }
}

Measured memory_bytes: 4352
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int s = stdIn.nextInt();
    String hantei = "No";


    for (int a = 1; a <= 9; a++){
      for (int b = 1; b <= 9; b++) {
        if (a * b == s) {
          hantei = "Yes";

                        }

                      }

                    }


      System.out.println(hantei);

    }
    }
//ミャオ


Measured memory_bytes: 22996
import io.StdIn.readLine
object Main extends App {
  val Array(n, m) = readLine.split(" ").map(_.toInt)
  val abs = Seq.fill(n)(readLine.split(" ").map(_.toInt) match {
    case Array(a, b) => (a, b)
  })
  val cds = Seq.fill(m)(readLine.split(" ").map(_.toInt) match {
    case Array(c, d) => (c, d)
  })

  abs foreach {
    case (a, b) =>
    ((-1, 100000000000000000L) /: (cds zipWithIndex)) {
      case ((q, dist), ((c, d), i)) =>
      val newDist = (a - c).abs + (b - d).abs
      if (newDist < dist) (i, newDist)
      else (q, dist)
    } match {
      case (q, dist) =>
      println(q + 1)
    }
  }
}


Measured memory_bytes: 25540
a = list(map(int,input().split()))
N,X,Y = a[0],a[1],a[2]
dic={}
for i in range(1,N):
  for j in range(i+1,N+1):
    dis = min (abs(j-i),abs(X-i)+abs(Y-j)+1)
    if dis not in dic:
      dic[dis]=1
    else:
      dic[dis]+=1

for i in range(1,N):
  if i in dic:
    print(dic[i])
  else:
    print(0)

Measured memory_bytes: 3572
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define for1(i,n) for (ll i=0;i<(n);i++)
#define for2(i,m,n) for (ll i=(m);i<(n);i++)
#define for3(i,m,n,d) for (ll i=(m);i<(n);i+=(d))
#define DEBUG 0
template <class T>
void dumplist(T list)
{
    for (auto item : list) {
        cout << item << " ";
    }
    cout << endl;
}

string solve()
{
    ll N,M,a,b;
    cin >> N >> M;
    set<ll> s1;
    set<ll> s2;
    set<ll> s3;

    for1(i,M) {
        cin >> a >> b;
        if (a == 1) {
            s1.insert(b);
        }
        if (b == N) {
            s2.insert(a);
        }
    }
    set_intersection(s1.begin(),s1.end(),s2.begin(),s2.end(),inserter(s3,s3.end()));
    //dumplist(s1);
    //dumplist(s2);
    //dumplist(s3);
    //cout << s3.size() << endl;
    if (s3.size() > 0) {
        return "POSSIBLE";
    }
    return "IMPOSSIBLE";
}

int main()
{
    do {
        cout << solve() << endl;
    } while (DEBUG);
}


Measured memory_bytes: 9600
N, Y = map(int, input().split())

for x in range(N + 1):
    for y in range(N - x + 1):
        z = N - x - y
        if (10000 * x + 5000 * y + 1000 * z == Y) and z >= 0:
            print(x, y, z)
            exit()

print(-1, -1, -1)


Measured memory_bytes: 9112
#include<iostream>
#include<vector>
#include<algorithm>

int main( int argc, char** argv )
{
  std::vector< int > x( 3 );
  std::cin >> x[ 0 ];
  std::cin >> x[ 1 ];
  std::cin >> x[ 2 ];
  
  const auto y = std::count_if( x.begin(), x.end(), []( const int a ){ if( a == 5 ) { return true; } else return false; } );
  const auto z = std::count_if( x.begin(), x.end(), []( const int a ){ if( a == 7 ) { return true; } else return false; } );
  
  if( y == 2 && z == 1 ) {
  	std::cout << "YES\n";
  } else {
  	std::cout << "NO\n";
  }
  
  return 0;
}

Measured memory_bytes: 888
n,k=map(int,input().split())
h=[int(input()) for i in range(n)]
h.sort()
d=[0]*n
for j in range(n-1):
  d[j+1]=d[j]+h[j+1]-h[j]
m=float('inf')
for l in range(n-k+1):
  m=min(m,d[l+k-1]-d[l])
print(m)
  
  
  
  


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

int main() {
    int n;
    cin >> n;
    double x;
    string u;
    double sum = 0;
    for (int i = 0; i < n; i++) {
        cin >> x;
        cin >> u;
        if (u == "JPY") {
            sum += x;
        }
        else {
            sum += x * 380000.0;
        }
    } 
    cout << sum << endl;
}


Measured memory_bytes: 256
#include<cstdio>
int main(void){int n,a,i,mx=-1<<30,mn=1<<30;long long su=0;scanf("%d",&n);for(i=0;i<n;++i){scanf("%d",&a);if(a>mx){mx=a;}if(a<mn){mn=a;}su+=a;}printf("%d %d %lld\n",mn,mx,su);return(0);}


Measured memory_bytes: 2760