akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include <bits/stdc++.h>
#include <algorithm>
using namespace std;

int main(){

    int N;
    cin >> N;

    int count=0;
    for(int i=1; i<=N; i++){
        if(i<10) count++;
        else if(i>=100 && i<1000) count++;
        else if(i>=10000 && i<100000) count++;
    }

    cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
bool tr[15];
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0;i<(n);i++)
typedef long long ll;
int main() {
  int a=0,n,b=1,A,B,t=0,T,sa,sb,ans=0;
  string worda,wordb,answord;
  bool flag;
  cin>>n;
  vector<int> list(n);
  rep(i,n){
    cin>>a;
    if(a!=b)t++;
    else if(a==b){b++;}
  }
  if(t==n)cout<<-1<<endl;
  else cout<<t<<endl;
  



  //vector<vector<bool>> sinsetsu(15,vector<bool>(14)),usotsuki(15,vector<bool>(14));
  //vector<vector<int>> sss(15,vector<int>(14))
  //vector<vector<int>> sss(h,vector<int>(w));
  //vector<int> a(k),b(k);
  //char x;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bitset>

const int ms = 8080;
const int mv = ms * 2 + 10;

std::bitset<mv> bits[2];

int main() {
	std::string str;
	int x, y;
	std::cin >> str >> x >> y;
	int state = 0;
	bits[0][ms] = bits[1][ms] = true;
	int on = 0;
	while(on < str.size() && str[on] == 'F') {
		on++;
	}
	bits[0] <<= on;
	int get = 0;
	//std::cout << "got here on " << on << "\n";
	for(; on < str.size(); on++) {
		//std::cout << "on " << on << ", state is " << state << "\n";
		/*for(int j = 0; j < 2; j++) {
			for(int k = 0; k < mv; k++) {
				if(bits[j][k]) {
					//std::cout << "(" << j << ", " << k - ms << ")\n";
				}
			}
		}*/
		if(str[on] == 'T') {
			bits[state] = (bits[state] >> get) | (bits[state] << get);
			get = 0;
			state = 1 - state;
		} else {
			get++;
		}
	}
	bits[state] = (bits[state] >> get) | (bits[state] << get);
	if(bits[0][ms + x] && bits[1][ms + y]) {
		std::cout << "Yes\n";
	} else {
		std::cout << "No\n";
	}
}

Measured memory_bytes: 256
x=int(input())
if x<600:
  print(8)
elif x<800:
  print(7)
elif x<1000:
  print(6)
elif x<1200:
  print(5)
elif x<1400:
  print(4)
elif x<1600:
  print(3)
elif x<1800:
  print(2)
else:
  print(1)

Measured memory_bytes: 9124
#include <bits/stdc++.h>
using namespace std;
using ll=long long;

int main(){
  ll h,n; cin>>h>>n;
  for(int i=0;i<n;i++){
    ll x; cin>>x;
    h-=x;
    if(h<=0){
      cout<<"Yes"<<endl;
      return 0;
    }
  }
  cout<<"No"<<endl;
}


Measured memory_bytes: 256
/*************************************************************************
	> File Name: A.cpp
	> Author: yxg 
 ************************************************************************/

#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<set>
#include<map>
#include<queue>
#include<vector>
#include<stack>
using namespace std;

typedef long long ll;
const ll INF = 1e18;
const int maxn = 1e5+10;

ll a[maxn],b[maxn],n;

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

    cin >> n;
    for(int i=0; i<n; i++) cin>>a[i]>>b[i];
    
    ll ans = 0;
    for(int i=n-1; i>=0; i--){
        if(a[i]%b[i] == 0 || a[i]==b[i]) {
            if(i>=1) a[i-1]+=ans;
            continue;
        }
        if(a[i]<b[i])
            ans += b[i]-a[i];
        else
            ans += b[i]-(a[i]%b[i]);
        if(i>=1) a[i-1]+=ans;
//        cout << "aa " << ans << endl;
    }

    cout << ans << endl;    
}


Measured memory_bytes: 1920
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		long N = sc.nextLong();
		int ans = 0;
		long from = 2;
		while (N > 1 && from * from <= N) {
			while (from * from <= N && (N % from) != 0) {
				from++;
			}
			int got = 0;
			while (N % from == 0) {
				N /= from;
				got++;
			}
			int val = 1;
			while (got >= val) {
				got -= val;
				ans++;
				val++;
			}
		}
		if (N > 1) ans++;
		out.println(ans);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 32768
#include <bits/stdc++.h>
#include <assert.h>
using namespace std;
using i64 = long long;

i64 h, n;
vector<i64> obj;
vector<vector<i64>> dp;

i64 dfs(i64 hn, i64 s)
{
  if (hn == h)
    return 0;
  if (dp[hn][s] != -1)
    return dp[hn][s];
  i64 ans = dfs(hn + 1, obj[hn]);
  for (i64 i = 0; i < 3; i++)
  {
    if (((s >> i) & 3) || ((obj[hn] >> i) & 3))
      continue;
    ans = max(ans, dfs(hn + 1, obj[hn] | (3 << i)) + 1);
  }
  if (s == 0 && obj[hn] == 0)
    ans = max(ans, dfs(hn + 1, (1 << 4) - 1) + 2);
  return dp[hn][s] = ans;
}

int main()
{
  cin >> h >> n;
  obj.resize(h);
  for (i64 i = 0; i < n; i++)
  {
    i64 x, y;
    cin >> x >> y;
    obj[y] |= (1 << x);
  }
  dp.resize(h, vector<i64>(16, -1));
  cout << dfs(1, obj[0]) << endl;
  return 0;
}



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

using namespace std;
using ll = long long;
using pii = pair<int, int>;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  int n;
  while (cin >> n, n) {
    int a[15][15] = {};
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        cin >> a[i][j];
      }
    }
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        a[i][n] += a[i][j];
      }
    }
    for (int j = 0; j <= n; j++) {
      for (int i = 0; i < n; i++) {
        a[n][j] += a[i][j];
      }
    }
    for (int i = 0; i <= n; i++) {
      for (int j = 0; j <= n; j++) {
        cout << setw(5) << a[i][j];
      }
      cout << endl;
    }
  }

  return 0;
}


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

int main(){
	int n;
	cin >> n;
	vector<vector<int> > v(3, vector<int>(n, 0));
	for(int i = 0; i < n; i++){
		for(int j = 0; j < 3; j++){
			cin >> v[j][i]; 
		}
	}
	vector<int> dp(3);
	for(int i = 0; i < n; i++){
		vector<int> new_dp(3, 0);
		for(int j = 0; j < 3; j++){
			for(int k = 0; k < 3; k++){
				if(j != k)
					new_dp[k] = max(dp[j] + v[j][i], new_dp[k]);
			} 
		}
		dp = new_dp;
	}
	cout << max(max(dp[0], dp[1]), dp[2]) << endl;
	return 0;
}

Measured memory_bytes: 1792
#include <stdio.h>

int main()
{
  int n;
  scanf("%d", &n);
  
  char s[4];
  int ac = 0, wa = 0, tle = 0, re = 0;
  for (int i = 0; i < n; i++)
  {
    scanf("%s", s);
    switch(s[0])
    {
      case 'A': ac++; break;
      case 'W': wa++; break;
      case 'T': tle++; break;
      case 'R': re++; break;
    }
  }
  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);
  
  return 0;
}

Measured memory_bytes: 2148
//#pragma GCC optimize("O3", "unroll-loops")
//#pragma GCC target("avx2")
#include<bits/stdc++.h>
#define FAST ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define FIXED cout << fixed << setprecision(12)
#define RANDOM srand(94385)
#define all(a) a.begin(), a.end()
#define shuffle(a) \
    for (int i = 0; i < sz(a); ++i) \
        swap(a[i], a[rand() % sz(a)]);
#define enter putchar('\n')
#define space putchar(' ')
#define Mem(a, x) memset(a, x, sizeof(a))
using namespace std;

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

void debug_out() { cerr << '\n'; }
template<typename T, typename ...R>void debug_out(const T &f, const R &...r) {cerr << f << " ";debug_out(r...);}
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__);
inline ll read() {ll x = 0;int f = 0;char ch = getchar();while (ch < '0' || ch > '9') f |= (ch == '-'), ch = getchar();while (ch >= '0' && ch <= '9') x = (x << 3) + (x << 1) + ch - '0', ch = getchar();return x = f ? -x : x;}
inline void write(ll x) {if (x == 0) {putchar('0');return;}if (x < 0) {putchar('-');x = -x;}static char s[23];int l = 0;while (x != 0)s[l++] = x % 10 + 48, x /= 10;while (l)putchar(s[--l]);}
int lowbit(int x) { return x & (-x); }
template<class T>T big(const T &a1, const T &a2) { return a1 > a2 ? a1 : a2; }
template<typename T, typename ...R>T big(const T &f, const R &...r) { return big(f, big(r...)); }
template<class T>T sml(const T &a1, const T &a2) { return a1 < a2 ? a1 : a2; }
template<typename T, typename ...R>T sml(const T &f, const R &...r) { return sml(f, sml(r...)); }
template<class T, class U>inline void checkMin(T &x, U y) { if (y < x) x = y; }
template<class T, class U>inline void checkMax(T &x, U y) { if (y > x) x = y; }
template<class T, class U>inline bool ifMax(T &x, U y) {if (y > x) return x = y, true;return false;}
template<class T, class U>inline bool ifMin(T &x, U y) {if (y < x) return x = y, true;return false;}

const int M = 212345;// 2e5+5
const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3f;
const int mod = 1000000007;// 1e9+7

// HAVE FREE OPEN IN MAIN FUNCTION



void init() {
    char a[5];
    char b[5];
    scanf("%s%s",a,b);
    int cnt=0;
    for (int i = 0; i < 3; ++i) {
        if(a[i]==b[i])cnt++;
    }printf("%d\n",cnt);

}

void solve() {

}

int main() {
    init();

    solve();

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#include <cstdint>
#include <utility>

int const MAXN = 100000;
int const MAXM = 1000000000;

uint64_t dpS[MAXN], dpA[MAXN];
uint64_t N, M;
std::vector<int> G[MAXN];

void mult(std::vector<int>const& ix, std::vector<uint64_t>const& tmp, int b, int e) {
  if(e-b==3) {
    dpA[ix[b+0]] *= tmp[b+1]*tmp[b+2]%M;
    dpA[ix[b+1]] *= tmp[b+0]*tmp[b+2]%M;
    dpA[ix[b+2]] *= tmp[b+1]*tmp[b+0]%M;
    dpA[ix[b+0]] %= M;
    dpA[ix[b+1]] %= M;
    dpA[ix[b+2]] %= M;
    return;
  } else if(e-b==2) {
    dpA[ix[b+0]] = dpA[ix[b+0]] * tmp[b+1] %M;
    dpA[ix[b+1]] = dpA[ix[b+1]] * tmp[b+0] %M;
    return;
  } else if(e-b==1) {
    return; // nothing to do
  }
  int mid = (b+e)/2;
  mult(ix, tmp, b, mid);
  mult(ix, tmp, mid, e);
  uint64_t p = tmp[b];
  for(int i = b+1; i < mid; ++i) p = p*tmp[i]%M;
  for(int i = mid; i < e; ++i) dpA[ix[i]] = dpA[ix[i]]*p%M;
  p = tmp[mid];
  for(int i = mid+1; i < e; ++i) p = p*tmp[i]%M;
  for(int i = b; i < mid; ++i) dpA[ix[i]] = dpA[ix[i]]*p%M;
}

uint64_t dfs(int v, int p) {
  uint64_t ret = 1;
  for(int i = 0; i < G[v].size(); ++i) {
    int c = G[v][i];
    if(c == p) continue;
    ret = ret*(1 + dfs(c, v))%M;
  }
  return dpS[v] = ret;
}

void bfs() {
  std::queue<std::pair<int, int> > q;
  q.push(std::make_pair(0, -1));
  dpA[0] = 1;
  while(q.size() > 0) {
    int v = q.front().first, p = q.front().second; q.pop();
    std::vector<int> ix;
    std::vector<uint64_t> tmp;
    ix.reserve(G[v].size());
    tmp.reserve(G[v].size());
    for(int i = 0; i < G[v].size(); ++i) {
      int c = G[v][i];
      if(c == p) continue;
      q.push(std::make_pair(c, v));
      ix.push_back(c);
      tmp.push_back(dpS[c]+1);
      dpA[c] = dpA[v];
    }
    if(ix.size() > 0) {
      mult(ix, tmp, 0, ix.size());
      for(int i = 0; i < ix.size(); ++i) ++dpA[ix[i]];
    }
  }
}

int main() {
  std::cin >> N >> M;
  for(int i = 0; i < N-1; ++i) {
    int x, y;
    std::cin >> x >> y;
    G[x-1].push_back(y-1);
    G[y-1].push_back(x-1);
  }
  dfs(0, -1);
  bfs();
  for(int i = 0; i < N; ++i) {
    std::cout << (dpS[i]*dpA[i]%M) << std::endl;
  }
}


Measured memory_bytes: 13824
#include <cstdio>
#include <iostream>
#include <array>
#include <vector>
#include <algorithm>
#include <functional>
#include <tuple>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <queue>
#include <utility>
#include <memory>
#include <valarray>
#include <climits>

using namespace std;

using ll = long long int;

#define loop(i, N) for (int i = 0; i < N; ++i)
#define scanInt(x) int x; scanf("%d", &x); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &x); getchar();
#define scanVecInt(A, N) vector<int> A(N); loop(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); loop(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanLLInt(N);
    scanLLInt(A);
    scanLLInt(B);
    if (B < A){
        printf("%d\n", 0);
        return 0;
    }
    if (N == 1){
        if (A == B){
            printf("%d\n", 1);
        }else{
            printf("%d\n", 0);
        }
    }else if (N == 2){
        printf("%d\n", 1);
    }else{
        printf("%lld\n", (B - A) * (N - 2) + 1);
    }
}


Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int N = sc.nextInt();
        int K = sc.nextInt();
        Map<Integer, Integer> map = new HashMap<>();
        
        for (int i=0; i<N; i++) {
            int a = sc.nextInt();
            map.put(a, map.getOrDefault(a, 0) + 1);
        }

        if (map.size() <= K) {
            System.out.println(0);
            return;
        }

        List<Integer> list = new ArrayList<>(map.values());
        list.sort((Integer a, Integer b) -> a - b);
        int sum = 0;
        for (int i=0; i<map.size() - K; i++) {
            sum += list.get(i);
        }
        System.out.println(sum);

    }
}



Measured memory_bytes: 100556
#include <bits/stdc++.h>
#define MAXN 1000000
using namespace std;
int serve_time[6], deliver_time[6], order_time[6], id[6];

int nearestMultipleOf10(int n){
	return n%10 == 0 ? n :  nearestMultipleOf10(n+1); 
}
int main() {
	for(int i=0;i<5;i++) {
		id[i] = i;
		cin>>serve_time[i];
	}
	
	int minTotal = INT_MAX;
	do{
		deliver_time[id[0]] = serve_time[id[0]];
		int i=1;
		while(i<5){
			order_time[id[i]] = nearestMultipleOf10(deliver_time[id[i-1]]);
			deliver_time[id[i]] = order_time[id[i]] + serve_time[id[i]];
			i++;
		}
		minTotal = min(minTotal, deliver_time[id[4]]);
	}while(next_permutation(id,id+5));
	
	printf("%d\n", minTotal);
}

Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#define ll long long int
#define e 2.7182818
#define pi 3.14159

int main (){
	ll num, res;
	scanf ("%lld", &num);
	for (ll i=1; i<num; i++){
		res += (num-1)/i;
	}
	printf ("%lld", res);

return 0;
}


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

int main(){
    int n,x;
    cin>>n>>x;
    int l[n+1];
    l[0]=0;
    for(int i=1;i<n+1;i++) cin>>l[i];
    int sum=l[0],i=0;
    while(sum<=x){
        i++;
        sum+=l[i];
    }
    cout<<i<<endl;
}

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

using namespace std;

#define MAX_N 1000000
#define MOD 1000000007

long long pow2[MAX_N + 1], fact[MAX_N + 1], fact_inv[MAX_N + 1];

long long mod_inv( long long n, long long mod )
{
    long long b = mod, u = 1, v = 0;
    while ( b > 0 )
    {
        long long t = n / b;
        n -= t * b;
        u -= t * v;

        swap( n, b ), swap( u, v );
    }
    return ( u + mod ) % mod;
}

long long bin_pow( long long a, long long n, long long mod )
{
    long res = 1;
    while ( n > 0 )
    {
        if ( n & 1 ) res = ( res * a ) % mod;
        a = ( a * a ) % MOD;
        n >>= 1;
    }
    return res;
}

void init( int N )
{
    pow2[0] = 1, fact[0] = 1;
    for ( int n = 0; n < N; n++ )
    {
        pow2[n + 1] = ( 2 * pow2[n] ) % MOD;
        fact[n + 1] = ( ( n + 1 ) * fact[n] ) % MOD;
    }

    fact_inv[N] = mod_inv( fact[N], MOD );
    for ( int n = N; n > 0; n-- ) fact_inv[n - 1] = ( n * fact_inv[n] ) % MOD;

    return;
}

long long comb( int n, int r )
{
    long long res = fact[n];
    res *= fact_inv[n - r];
    res %= MOD;

    res *= fact_inv[r];
    res %= MOD;

    return res;
}

long long one_third( int N )
{
    long long ans = 0;
    for ( int i = 1; i <= N; i++ )
    {
        long long w = pow2[i];

        if ( i & 1 )
            w = ( w + 1 ) % MOD;
        else
            w = ( w - 1 ) % MOD;

        long long t = comb( N, i );
        t = ( t * w ) % MOD;
        t = ( t * mod_inv( i, MOD ) ) % MOD;

        ans += t;
        ans %= MOD;
    }

    ans *= mod_inv( bin_pow( 3, N + 1, MOD ), MOD );
    ans %= MOD;

    ans *= mod_inv( N, MOD );
    ans %= MOD;

    return ans;
}

int main( int argc, char **argv )
{
    int N;
    cin >> N;

    init( N );

    cout << one_third( N ) << endl;

    return 0;
}


Measured memory_bytes: 23680
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
	sc.Split(bufio.ScanWords)

	n := nextInt()
	d := nextInt()

	if n <= (2*d + 1) {
		fmt.Println(1)
		return
	}

	//if n%(2*d+1) == 0 {
	//	fmt.Println(n / (2*d + 1))
	//} else {
	//	fmt.Println(1 + n/(2*d+1))
	//}

	// 切り上げ
	fmt.Println((n + (2*d + 1) - 1) / (2*d + 1))

	return
}

// ---- readfunc
func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}
func nextStr() string {
	sc.Scan()
	return sc.Text()
}


Measured memory_bytes: 1772
#include <bits/stdc++.h>
#define pb push_back

using namespace std;
using ll = long long int;
const int MOD = 1e9 + 7;

int main()
{
	ios::sync_with_stdio(0); cin.tie(0);
	string s; cin >> s;
	int flag = 1;
	int n = s.size();
	for (int i = 0; i < n; ++i)
	{
		if (i%2 == 0 and s[i] != 'h') flag = 0;
		if (i%2 == 1 and s[i] != 'i') flag = 0;
	}
	if (n&1) flag = 0;
	if (flag) cout << "Yes\n";
	else cout <<" No\n";
}

Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;
int main() {
    int n;
	cin>>n;
	vector<int> cnt(26,55);
	for(int i=0;i<n;++i){
		string s;
		cin>>s;
		vector<int> tmp(26,0);
		for(char j:s) tmp[j-'a']++;
		for(int j=0;j<26;++j)
			cnt[j]=min(cnt[j],tmp[j]);
	}
	for(char c='a';c<='z';++c)
		for(int i=0;i<cnt[c-'a'];++i)
			cout<<c;
	cout<<'\n';
    return 0;
}



Measured memory_bytes: 3604
from math import gcd
from collections import defaultdict

MOD = 10**9+7
N = int(input())
d = defaultdict(int)
zero = [0, 0, 0]
for i in range(N):
    a, b = map(int, input().split())
    if a == 0 and b == 0:
        zero[0] += 1
        continue
    if a == 0:
        zero[1] += 1
        continue
    if b == 0:
        zero[2] += 1
        continue

    s = -1 if (a*b) < 0 else 1
    g = gcd(a, b)
    a //= g
    b //= g

    d[(s, abs(a), abs(b))] += 1

ans = 1
for (s, a, b), c1 in d.items():
    if c1 == 0:
        continue
    k = (-s, b, a)
    if k in d:
        c2 = d[k]
        ans *= pow(2, c1, MOD) + pow(2, c2, MOD)-1
        ans %= MOD
        d[k] = 0
    else:
        ans *= pow(2, c1, MOD)
        ans %= MOD

ans *= pow(2, zero[1], MOD)+pow(2, zero[2], MOD)-1
ans %= MOD

ans += zero[0]
ans -= 1
ans %= MOD

print(ans)


Measured memory_bytes: 138276
/*------------------------------------
........Bismillahir Rahmanir Rahim....
..........created by Abdul Aziz.......
------------------------------------*/
#include <iostream>
#include <algorithm>
#include <stdio.h>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#include <queue>
#define   mod  998244353
#define   int  long long 
#define   ld   long double
#define   pb   push_back
#define   vi  vector<int> 
#define   dbg(x)  cerr << #x << " = " << x << '\n'
#define   sz(x)  (int)x.size()
#define   all(a) (a.begin(),a.end())
#define   ff   first
#define   ss   second
#define   pii  pair<int,int> 
#define   lcm(a,b) (a*b)/__gcd(a,b) 
using namespace std; 
 
inline void solve(){ 
    int n,mx=0,ans=1; 
    cin>>n; 
    map <int,int> cnt; 
    for (int i=1,a;i<=n;i++){ 
        cin>>a; 
      	if ((i==1 and a!=0) or (i>1 and a==0)) ans=0;
        cnt[a]++; 
        mx=max(mx,a); 
    } 
    for (int i=1;i<=mx;i++){ 
        for (int j=0;j<cnt[i];j++){ 
            ans = (ans*cnt[i-1])%998244353; 
        } 
    } 
    cout << ans << endl; 
}

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


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

vector<long long>a;

int main(){
	long long N;
	cin >> N;
	for(int i = 0; i < 3*N; i++){
		long long tmp;
		cin >> tmp;
		a.push_back(tmp);
	}
	sort(a.begin(), a.end());
	long long ret = 0;
	for(long long i = N; i < 3*N; i+=2){
		//cout << a[i] << endl;
		ret += a[i];
	}
	cout << ret << endl;
	return 0;
}



Measured memory_bytes: 6512
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin>>n;
    ll a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    for(int i=1;i<n;i++){
        if(a[i]==a[i-1]){
            cout << "NO" <<endl;
            return 0;
        }
    }
    cout << "YES"<<endl;

    return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <assert.h>
#include <stdlib.h>
#include <time.h>
#include <stdio.h>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <string>
#include <string.h>
#include <cmath>
#include <algorithm>
#include <iomanip>
using namespace std;

const int N = 1e3 + 2;
const long long MOD = 1e9 + 7;

int h, w;
string grid[N];
long long dp[N][N];

long long calc(int i, int j)
{
    if (grid[i][j] == '#')
    {
        return 0;
    }
    if (i == h - 1 && j == w - 1)
    {
        return 1;
    }
    long long &ret = dp[i][j];
    if (ret != -1)
    {
        return ret;
    }
    ret = 0;
    if (i + 1 < h)
    {
        ret += calc(i + 1, j);
        ret %= MOD;
    }
    if (j + 1 < w)
    {
        ret += calc(i, j + 1);
        ret %= MOD;
    }
    return ret;
}

int main()
{
    memset(dp, -1, sizeof dp);
    cin >> h >> w;
    for (int i = 0; i < h; ++i)
    {
        cin >> grid[i];
    }
    cout << calc(0, 0) << endl;
    return 0;
}

Measured memory_bytes: 9216
//abc072_b OddString


#include <bits/stdc++.h>
using namespace std;

int main()
{
int i;
int j;
char S[ 100010 ];
char T[ 50010 ];
char C;

	cin >> S;

	i = 0;
	j = 0;
	C = S[ i ];
	while( C != '\0' )
	{
		if( i % 2 == 0 )
		{
			T[ j ] = C;
			j++;
		}

		i++;
		C = S[ i ];
	}


	T[ j ] = '\0';

	cout << T << endl;

	return 0;
}






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

using namespace std;
const int N = 303;

int n, k, MOD, dp[N][N], ps[N][N], c[N][N];

int sum(int a, int b) {
	a += b;
	if (a < 0)
		a += MOD;
	else if (a >= MOD)
		a -= MOD;
	return a;
}
void _sum(int &a, int b) {
	a = sum(a, b);
}
int mul(int a, int b) {
	return 1LL * a * b % MOD;
}
void _mul(int &a, int b) {
	a = mul(a, b);
}

void ready() {
	fill(c[0], c[0] + N, 1);
	for (int i = 1; i < N; i++)
		for (int j = 1; j < N; j++)
			c[i][j] = sum(c[i - 1][j - 1], c[i][j - 1]);
}

void calc() {
	for (int x = 0; x < N; x++)
		ps[0][x + 1] = ps[0][x] + (dp[0][x] = 1);
	for (int n = 1; n < N; n++)
		for (int x = 0; x < N; x++) {
			for (int cnt = 1; cnt <= n; cnt++)
				_sum(dp[n][x], mul(c[cnt - 1][n - 1], mul(dp[n - cnt][x], sum(ps[cnt - 1][k + 1], -ps[cnt - 1][x + 1]))));
			ps[n][x + 1] = sum(ps[n][x], dp[n][x]);
		}
}

int main() {
	ios::sync_with_stdio(false), cin.tie(0), cout.tie(0);
	cin >> n >> k >> MOD;
	ready();
	calc();
	cout << dp[n][0];
}


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

// 22:53-22:55
int main(void){
    int a = 0, b = 0; 

    scanf("%d%d", &a, &b);

    if(a <= 8 && b <= 8){
        printf("Yay!\n");
    }else{
        printf(":(\n");
    }

    return 0;

} 


Measured memory_bytes: 256
/*"Success isn't permanent, failure isn't fatal,
                                      it's the courage to continue that counts"*/
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
//using namespace __gnu_pbds;
using namespace std;
//typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define ll long long 
#define scn(n) scanf("%d",&n)
#define lscn(n) scanf("%lld",&n)
#define lpri(n) printf("%lld",n)
#define pri(n) printf("%d",n)
#define pln() printf("\n")
#define priln(n) printf("%d\n",n)
#define lpriln(n) printf("%lld\n",n)
#define rep(i,init,n) for(int i=init;i<n;i++)
#define pb push_back     
#define mp make_pair
#define F first
#define S second
#define gcd __gcd
#define inf INT_MAX
#define ninf INT_MIN
const int mod=1e9+7;         
const int N=2e5+4;

set<int> st;

vector<int> v[N];

int val[N],ans[N],removed[N];

void dfs(int node,int par)
{
	auto it=st.lower_bound(val[node]);

	if(it!=st.end())
	{
		removed[node]=*it; st.erase(*it);
	}
	else
	removed[node]=-1;

	st.insert(val[node]);

	ans[node]=(int)st.size();

	for(int it:v[node])
	if(it!=par)
	dfs(it,node);
	
	//it is guaranteed that val[node] will be present in the current lis
	//now we are returning to it's parent so it is our responsibility to return
	//the same set as we recieved
	//the current element, i.e val[node] may have been replaced something, we stored
	//it in removed[node], so let's remove val[node] from current lis and insert
	//removed[node] if it's not -1.

	st.erase(val[node]);

	if(removed[node]!=-1)
	st.insert(removed[node]);
}

int main()
{
	int n;

	scn(n);

	rep(i,1,n+1)
	scn(val[i]);

	rep(i,0,n-1)
	{
		int a,b;

		scn(a); scn(b); v[a].pb(b); v[b].pb(a);
	}

	dfs(1,-1);

	rep(i,1,n+1)
	priln(ans[i]);

    return 0;
}

Measured memory_bytes: 31416
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

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


int main(){
    ll x;
    cin >> x;
    ll pre = 0;
    pre += 1000 * int(x/500);
    x -= int(x/500) * 500;
    pre += 5 * int(x/5);
    cout << pre << endl;
}

Measured memory_bytes: 256
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <set>
#include <map>
#include <queue>
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <ctime>
#include <cstring>
#include <cctype>
#include <cassert>
#include <limits>
#include <functional>
#include <iomanip>
#include <complex>
#include <bitset>
#include <stack>
using namespace std;
 
#define rep(i,n) for(int (i)=0;(i)<(int)(n);++(i))
#define repl(i,s,n) for(int i=s; i<=n; ++i)
#define rer(i,l,u) for(int (i)=(int)(l);(i)<=(int)(u);++(i))
#define reu(i,l,u) for(int (i)=(int)(l);(i)<(int)(u);++(i))
#if defined(_MSC_VER) || __cplusplus > 199711L
#define aut(r,v) auto r = (v)
#else
#define aut(r,v) __typeof(v) r = (v)
#endif
#define each(it,o) for(aut(it, (o).begin()); it != (o).end(); ++ it)
#define ktya(x) sort(all(x))
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define all(o) (o).begin(), (o).end()
#define pb(x) push_back(x)
#define mp(x,y) make_pair((x),(y))
#define mset(m,v) memset(m,v,sizeof(m))
#define INF 1e18
#define INFLL 1000000000000000007LL
#define SIZE 200105
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define mind(a,b) (a>b?b:a)
#define maxd(a,b) (a>b?a:b)
#define PI (acos(-1))
typedef vector<int> vi; typedef pair<int, int> pii; typedef vector<pair<int, int> > vpii; typedef long long ll;
typedef pair<int,ll> pill; typedef pair<ll,int> plli; 
typedef pair<double, int> pdi;
template<typename T, typename U> inline void amin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void amax(T &x, U y) { if(x < y) x = y; }
typedef complex<double> P;
ll MOD = 1000000007;
// ll MOD=998244353;
typedef ll Weight;
struct Edge {
	int src, dst;
	Weight weight;
};
bool operator < (const Edge &e, const Edge &f) {
	return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
	e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
ll powMod(ll x, ll k, ll m) {//x^k (mod n)
	if (k == 0)     return 1;
	if (k % 2 == 0) return powMod(x*x % m, k/2, m);
	else            return x*powMod(x, k-1, m) % m;
}
int N,K,Q;
vi PP;

int invmap[114514];
map<int,int> mm;
vi datas;
int cnt[114514]={0};
int main(){
	cin>>N>>K>>Q;
	rep(i,Q){
		int x;
		cin>>x;
		cnt[x]++;
	}
	rep(i,N){
		if(Q-cnt[i+1]>=K)cout<<"No"<<endl;
		else cout<<"Yes"<<endl;
	}
}




Measured memory_bytes: 1024
##a = int(stdin.readline().rstrip())
##b, c = [int(x) for x in stdin.readline().rstrip().split()]
##s = stdin.readline().rstrip()
##a = list(set(b))  重複を削除
##a = list(map(int,[int(x) for x in stdin.readline().rstrip().split()])) a[0, 1, 2, ...]
##a = [[0] * 2 for _ in range(n)]  a[0,0]
##v = [s[i: i+2] for i in range(0, len(s), 2)]
##  s="12345678" を v=["12","34","56","78"] にするイメージ
##s = "".join(list)リストを文字列に変換[""]は区切り文字
##a.sort(key=itemgetter(1))リストをソートできるよ(from operator import itemgetterが必要)
##sort_p = sorted(p) 昇順ソート

# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque, Counter
import math
import pprint
from functools import reduce
import numpy as np
import random
import bisect
import copy
# stdin = open("sample.txt")


MOD = int(1e9+7)
INF = float('inf')
alpha = ["a","b","c","d","e","f","g","h","i","j","k","l","m","n","o","p","q","r","s","t","u","v","w","x","y","z"]

def keta(kazu): # 入力されたintを桁ごとに分解，リストで出力
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

def gcd(*numbers): # 最小公倍数
    return reduce(math.gcd, numbers)

def combination(m,n): # mCn
    
    if n > m:
        return 'すまん'
    return math.factorial(m) // (math.factorial(m-n) * math.factorial(n))

def pow_k(x,n):  # (x**n)の計算の高速化
    if n == 0:
        return 1
    K = 1
    while n > 1:
        if n % 2 != 0:
            K *= x
        x *= x
        n //= 2
    return K * x

def fact(n): # nの素因数分解の結果を辞書で出力 fuct(24) → {2: 3, 3: 1}
    arr = {}
    temp = n
    for i in range(2,int(n**0.5)+1):
        if temp % i == 0:
            cnt = 0
            while temp % i == 0:
                cnt += 1
                temp //= i
            arr[i] = cnt
    if temp != 1:
        arr[temp] = 1
    if arr == {}:
        arr[n] = 1
    return arr
    
def main():
    a = int(stdin.readline().rstrip())
    if a % 9 == 0:
        print("Yes")
    else:
        print("No")
                
main()

Measured memory_bytes: 27308
# coding: utf-8
# Your code here!
haiku = input().split()
count_f = 0
count_s = 0
for l in haiku:
    if l == "5":
        count_f += 1
    elif l == "7":
        count_s += 1
if count_f == 2 and count_s == 1:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 2940
#include <stdio.h>
#include <stdlib.h>
#define MAX 2000001
#define VMAX 10000
int main(){
  unsigned short *A, *B;
  int C[VMAX+1];
  int n, i, j;

  scanf("%d", &n);

  A = malloc(sizeof(short)*n+1);
  B = malloc(sizeof(short)*n+1);

  /* your code */
  for(i = 1 ;i<=n ;i++){
    scanf("%hd",&A[i]);
  }
  for(i = 0;i<=VMAX+1;i++){
    C[i] = 0;
  }
  for(j=1;j<=n;j++){
    C[A[j]] = C[A[j]]+1;
  }
  
  for(i = 1 ;i<=VMAX+1;i++){
    C[i] = C[i]+C[i-1];
  }
  for(j=n ;j>=1 ;j--){
    B[C[A[j]]] = A[j];
    C[A[j]] = C[A[j]]-1;
  }
  for(j = 1;j<n+1;j++){
    if(j ==n)
    printf("%d\n",B[j]);
    else printf("%d ",B[j]);
    }
  return 0;
}



Measured memory_bytes: 9576
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define ld long double
#define ull unsigned long long int
#define ll long long int
#define SPEED ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007ll
#define rep(i,L,R) for(i=L;i<R;i++)
#define DEBUG
#ifdef DEBUG
#define deb2(args...) {dbg,args; cerr<<endl;}
#else
#define deb2(args...)
#endif
struct debb{template<typename T> debb& operator,(const T &v){cerr<<v<<" ";return *this;}}dbg;
#define deb1(args...) do {cerr << #args << " : "; dbg,args; cerr << "\n";} while(0)
#define printa(a,L,R) rep(i,L,R) cout << a[i] <<' ';cout<<"\n";
typedef tree<ll,null_type,less_equal<ll>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
template<typename T>T gcd(T a,T b){if(b==0)return a;else return gcd(b,a%b);}
template<typename T>T lcm(T a,T b){return a/gcd(a,b)*b;}
ll power(ll x,ll y,ll p){ll res=1;x=x%p;while(y>0){if(y&1)res=((res%p)*(x%p))%p;y=y>>1;x=(x*x)%p;}return res;}
ll pow1(ll x,ll y){ll res=1;while(y>0){if(y&1)res=(res*x);y=y>>1;x=x*x;}return res;}
const ll INF = 1e18l+10,N = 1e5+10,MAX = 5000000;
#define sq(X) ((X)*(X))

int main()
{
    string s;
    cin>>s;
    for(ll i=0;i<s.length();i++)   
    {
        if(s[i]=='7')
        {
            cout<<"Yes\n";
            return 0;
        }
    }
    cout<<"No\n";
}

Measured memory_bytes: 3628
//Author: kaiyu
#include <iostream>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <cstring>
#include <string>
#include <queue>
#include <stack>
#include <numeric>
#include <iomanip>
#include <climits>
using namespace std;
typedef long long ll;
#define sz(x) ((long long)(x).size())
#define all(x)  x.begin(),x.end()
#define endl "\n"
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<int,int>
#define tt ll t;cin >> t;while(t--)
#define int3(x,y,z) ll x,y,z;cin >> x >> y >> z;
#define int2(x,y) ll x,y;cin >> x >>y;
#define int1(x) ll x;cin>>x;
#define  fio ios::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
ll power(ll a,ll b,ll m=mod){ ll ans=1; a=a%m;  while(b>0) {  if(b&1)  ans=(1ll*a*ans)%m; b>>=1;a=(1ll*a*a)%m;}return ans;}

ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}


bool cmp(pair<string,int>p1,pair<string,int>p2) {
    return p1.ss > p2.ss;
}

const int MAXN = 5 * 100000 + 10;

#define int long long

int32_t main() {
    fio
    int a,b,h,m;
    cin >> a >> b >> h >> m;
    if(a<b) swap(a,b);
    h = h*60;
    h=h+m;
    int const time = 12 * 60;
    double rsmall = (double)h/time;
    if(h%time!=0) {
        int to = h/time;
        rsmall-= (double)to;
    }

    double rbig = (double)h / 60;
        int to = h/60;
        rbig-= to;


    double diff = abs(rsmall-rbig);
    if(diff >= 0.500000) {
        diff = (1.00000-diff);
    }
    double angle = ((diff*360.00) * M_PI/180.00);
    int a2 = a*a;
    int b2 = b*b;
    double ans =(double) a2 + (double)b2 - (double)2 * a * b * cos(angle);
    ans = sqrt(ans);
    cout <<setprecision(10)<< ans <<endl;




}






Measured memory_bytes: 4160
# -*- coding : utf-8 -*- 

w,h,n = map(int, input().split())


l,r,u,d = 0,w,h,0
for i in range(n) :
  x,y,a = map(int, input().split())
  if a == 1:
    l = max(l,x)
  elif a == 2:
    r = min(r,x)
  elif a == 3:
    d = max(d,y)
  elif a == 4:
    u = min(u,y)
  
S = max(0, u-d) * max(0,r-l)
print(int(S))


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using loop = int;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(loop (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(loop (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(loop (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(loop (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n; cin >> n;
    vector<VI> g(n);
    FOR(i, 0, n) {
        int a; cin >> a;
        --a;
        g[i].push_back(a);
    }

    VI dis(n, INF);
    dis[0] = 0;
    queue<int> bfs;
    bfs.push(0);
    while (!bfs.empty()) {
        int now = bfs.front();
        bfs.pop();
        each(to, g[now]) {
            if (!chmin(dis[to], dis[now] + 1))continue;
            bfs.push(to);
        }
    }
    cout << (dis[1] == INF ? -1 : dis[1]) << "\n";
}

Measured memory_bytes: 6144
/*
 * @Date         : 2020-08-10 17:39:48
 * @Author       : ssyze
 * @Description  :
 */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    ll ans = 0;
    for (int i = 1; i <= n; i++) ans += i * (n - i + 1);
    for (ll i = 1, x, y; i < n; i++) {
        cin >> x >> y;
        if (x > y) swap(x, y);
        ans -= x * (n - y + 1);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3624
package main

import "fmt"

func main() {
        var n int
        fmt.Scan(&n)
        if n == 0 {
                fmt.Println(0)
                return
        }

        s := ""
        for n != 0 {
                k := 0
                n, k = n/(-2), n%(-2)
                if k < 0 {
                        n += 1
                        k += 2
                }
                s = string(k+'0') + s
        }
        fmt.Println(s)
}

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

using std::vector;

int main(void)
{
  int N{}, M{}; std::cin >> N >> M;
  vector<int64_t> X(M);
  std::for_each(X.begin(), X.end(), [](auto& x){ std::cin >> x; });

  std::sort(X.begin(), X.end());
  std::adjacent_difference(X.begin(), X.end(), X.begin());
  *X.begin() = 0;

  auto num = M - N;
  int64_t ans{};
  if(num > 0)
  {
    std::sort(X.begin(), X.end(), std::greater<int64_t>());
    ans += std::accumulate(std::next(X.begin(), N - 1), X.end(), 0);
  }

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

Measured memory_bytes: 1024
#include <string>
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <stdlib.h>
#include <algorithm>
#include <list>
#include <math.h>
#include<string.h>
#define reps(i,j,k) for(int i=(j);i<(k);i++)
#define rep(i,j) reps(i,0,j)
#define M -99999999
#define MOD 1000000007
 
//	rep(i,10)cout << i << endl;
using namespace std;

int main(void){
	int n,m,a,dp[100001];
	cin >> n >> m;
	rep(i,n+1){
		dp[i] = 0;
	}
	rep(i,m){
		cin >> a;
		dp[a] = M;
	}
	dp[0] = 1;
	rep(i,n){
		if(dp[i] == M ) continue;
		dp[i] %= MOD;
		//cout << i << " = " << dp[i] << endl;
		if(i+1 <= n && dp[i+1] != M){
			dp[i+1] += dp[i];
		}
		if(i+2 <= n && dp[i+2] != M){
			dp[i+2] += dp[i];
		}
		
		//cout << dp[i+1] << " " << dp[i+2] << endl;
	}
	cout << dp[n]%MOD << endl;
	return 0;
}

Measured memory_bytes: 640
import sys

stdin = sys.stdin

ri = lambda: int(rs())
rl = lambda: list(map(int, stdin.readline().split()))  # applies to only numbers
rs = lambda: stdin.readline().rstrip()  # ignores trailing space

N = ri()
L = []
R = []

for _ in range(N):
    l, r = rl()
    L.append(l)
    R.append(r)

max_l = max(L)
min_r = min(R)
ab = [(max(0, r - max_l + 1), max(0, min_r - l + 1)) for l, r in zip(L, R)]
ab.sort()
mi = float('inf')
answer = max(r - l + 1 for l, r in zip(L, R)) + max(0, min_r - max_l + 1)
for i in range(N - 1):
    mi = min(mi, ab[i][1])
    # miは第１グループの人数
    answer = max(answer, mi + ab[i + 1][0])
print(answer)

Measured memory_bytes: 25036
import sys
import math

sys.setrecursionlimit(10000)
INF = float('inf')


def inp():
    return int(input())


def inl():
    return list(map(int, input().split()))


def inls():
    return input().split()


def Yesif(cond):
    print('Yes' if cond else 'No')


def YESIF(cond):
    print('YES' if cond else 'NO')


def yesif(cond):
    print('yes' if cond else 'no')


a, b = inl()
if a > b:
    print(a + a - 1)
if b > a:
    print(b + b - 1)
if a == b:
    print(a + b)


Measured memory_bytes: 3316
using System;

class Program
{
  static string _trigger;
  static int _margin = 0;
  static string _str;
  static int[] p;
  static int n;
  static void Main()
  {
    var line = Console.ReadLine();
    var _line = line.Split(" ");
    int x = int.Parse(_line[0]);
    n = int.Parse(_line[1]);
    if (n == 0)
    {
      Console.WriteLine(x);
      return;
    }
    p = new int[n];
    line = Console.ReadLine();
    _line = line.Split(" ");
    
    for (int i = 0; i < n; i++)
    {
      p[i] = int.Parse(_line[i]);
      _str += p[i].ToString();
    }
    while(_trigger == null)
    {
      _trigger = Judge(x - _margin);
      if (_trigger == null)
        _trigger = Judge(x + _margin);
      _margin++;
    }
    Console.WriteLine(int.Parse(_trigger));
  }
  
  static String Judge(int _num)
  {
    for (int i = 0; i < n; i++)
    {
      if (_num == p[i])
      {
        return null;
      }
    }
    return _num.ToString();
  }
}

Measured memory_bytes: 27544
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define REPR(i, n) for (int i = (n); i >= 0; i--)
#define ALL(x) (x).begin(), (x).end()
#define OUT(x) std::cout << (x) << std::endl
typedef long long ll;

int main() {
    int n;
    cin >> n;
    map<ll, int> m;
    REP(i, n) {
        int a;
        cin >> a;
        if (m.find(a) != m.end()) {
            OUT("NO");
            return 0;
        }
        m[a] = 1;
    }
    OUT("YES");
    return 0;
}

Measured memory_bytes: 12800
#include "bits/stdc++.h"
using namespace std;
using ll = long long;

int main(){
    int MOD = 1e9+7;
    ll n,k,ans;
    ans = 0;
    cin >> n >> k;
    for(ll i = k; i <= n+1; i++){
        ll mi = i * (i-1) / 2;
        ll ma = i * (n + n - i + 1) / 2;
        ll t = ma - mi + 1;
        (ans += t) %= MOD;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3596
N, H = (int(i) for i in input().split())
A = []
B = []
for index in range(N):
	a, b = (int(i) for i in input().split())
	A.append(a)
	B.append(b)

arg_sorted = sorted(range(N), key=lambda k: B[k], reverse=True)

B_sorted = []
for i in arg_sorted:
	B_sorted.append(B[i])

A_max = max(A)
hits = 0

for b in B_sorted:
	if H <= 0:
		break
	if b > A_max:
		hits += 1
		H -= b
	else:
		break

if H > 0:
	hits += (H-1) // A_max + 1

print(hits)

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

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

    int total = 0;
    for (int i = 1; i <= n; i++) {
        int number = i;
        int sum = 0;
        while (number > 0) {
            sum += number % 10;
            number /= 10;
        }
        if ((sum >= a) && (sum <= b)) {
            total += i;
        }
    }
    cout << total << endl;
    return 0;
}

Measured memory_bytes: 256
import math

A, B, C, D = map(int, input().split())


def count(n, d):
    return n // d


c_dividable = count(B, C) - count(A-1, C)
d_dividable = count(B, D) - count(A-1, D)
cd = C*D // math.gcd(C, D)
cd_dividable = count(B, cd) - count(A-1, cd)

print((B-A+1) - (c_dividable+d_dividable-cd_dividable))


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

using namespace std;

#define int long long

signed main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int x = 1e18, n;
    cin >> n;
    int ans = 1;
    vector<int> b(n);
    for (int i = 0; i < n; i++) {
        cin >> b[i];
        if (!b[i]) {
            cout << 0;
            return 0;
        }
    }
    for (int i = 0; i < n; i++) {
        int a = b[i];
        if (x / a < ans) {
            cout << -1;
            return 0;
        }
        ans *= a;
        if (ans > x) {
            cout << -1;
            return 0;
        }
    }
    cout << ans;
}


Measured memory_bytes: 3992
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    void solve(Scanner sc, PrintWriter pw) {
        String s = sc.next();
        int total = 0;
        for (int i = 0; i < s.length(); i++) {
            total += (s.charAt(i) - '0');
        }
        String result = (total % 9) == 0? "Yes" : "No";
        pw.println(result);
    }
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        new Main().solve(sc, pw);
        pw.flush();
        pw.close();
        sc.close();
    }
}


Measured memory_bytes: 40312
def main():
    s=input()
    q=int(input())
    rot = 0
    A = ''
    B = ''
    for _ in range(q):
        t=input()
        if t=='1':
            rot += 1
        else:
            t = t.split()
            if (int(t[1])+rot)%2==1:
                A += t[2] 
            else:
                B  += t[2]
    if not rot%2:
        print(''.join(A[::-1]+s+B))
    else:
        print(''.join(B[::-1]+s[::-1]+A))        
main()

Measured memory_bytes: 6260
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/range/adaptor/reversed.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
typedef long long int ll;

#define PI (acos(-1))
#define REP(i,n) for(ll (i)=0;(i)<(n);(i)++)

#define dump(x)  cerr << #x << " = " << (x) << endl;
#define dumparr(x) cerr << #x ; for(auto elem: x){cerr << " " << elem;} cerr << endl;
#define dumppairs(x) cerr << #x ; for(auto elem: x){cerr << "(" << elem.first << " " << elem.second << ") ";} cerr << endl;
#define dumpline cerr << "**********************" << endl;
#define dumpwline(x) cerr << "******** " << #x << "=" << (x) << " ********" << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
#define ARRAY_LENGTH(array) (sizeof(array) / sizeof(array[0]))

vector <ll> kabukas = {100000};
ll n;
int main(void){
    cin >> n;
    ll max_kabu = 0;
    ll max_day = -1;
    REP(i, n){
        ll kabuka; cin >> kabuka;
        kabukas.push_back(kabuka);
        if (max_kabu < kabuka){
            max_kabu = kabuka;
            max_day = i;
        }
    }
    kabukas.push_back(-100000);
    ll yen = 1000;
    ll kabu = 0;
    bool nobori = true;
    REP(i, n+1){
        if (kabukas[i] > kabukas[i+1]){
            if (nobori){ //peak
                yen += kabu*kabukas[i];
                kabu = 0;
            }
            nobori = false;
        }
        if (kabukas[i] < kabukas[i+1]){
            if (!nobori){//bottom
                kabu += yen/kabukas[i];
                yen %= kabukas[i];
            }
            nobori = true;
        }
    }
    cout << yen << endl;
    return 0;
}

Measured memory_bytes: 3628