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

public class Main {

    public static void main(String[] args) throws IOException {
        Scanner sc = new Scanner(System.in);
        PrintWriter pw = new PrintWriter(System.out);
        int n = sc.nextInt();
        long ans = 0;
        for (int i =1;i<=n;i++){
            ans+=1l*i*(n-i+1);
        }
        int[][]a = new int[n][2];
        for (int i =0;i<n-1;i++) {
            int x = sc.nextInt();
            int y = sc.nextInt();
            a[i][0] = Math.min(x, y);
            a[i][1] = Math.max(x, y);
            ans-=(1l*a[i][0]*(n-a[i][1]+1));
        }
        pw.println(ans);
        pw.flush();
    }

    static class Scanner {
        StringTokenizer st;
        BufferedReader br;

        public Scanner(InputStream s) {
            br = new BufferedReader(new InputStreamReader(s));
        }

        public Scanner(FileReader r) {
            br = new BufferedReader(r);
        }

        public String next() throws IOException {
            while (st == null || !st.hasMoreTokens())
                st = new StringTokenizer(br.readLine());
            return st.nextToken();
        }

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

        public long nextLong() throws IOException {
            return Long.parseLong(next());
        }

        public String nextLine() throws IOException {
            return br.readLine();
        }

        public double nextDouble() throws IOException {
            return Double.parseDouble(next());
        }

        public int[] nextIntArr(int n) throws IOException {
            int[] arr = new int[n];
            for (int i = 0; i < arr.length; i++)
                arr[i] = nextInt();
            return arr;
        }

        public boolean ready() throws IOException {
            return br.ready();
        }

    }
}

Measured memory_bytes: 60756
#include "bits/stdc++.h"
using namespace std;
int main() {
	int n, k;
	cin>>n>>k;
	vector<int>x(n);for(auto &v : x) cin >> v;
	int ans = INT_MAX;
	for (int l = 0; l <= n - k; l++) {
		int r = l + k - 1;
		ans = min(ans, x[r] - x[l] + min(abs(x[l]), abs(x[r])));
	}
	cout << ans << endl;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <stdlib.h>
int fw(const void *a, const void *b)
{
    return *(long int *)a - *(long int *)b;
}
int bw(const void *a, const void *b)
{
    return *(long int *)b - *(long int *)a;
}
int main()
{
    int a, b, x;
    scanf("%d %d %d", &x, &a, &b);
    if (x == 1)
    {
        printf("Hello World");
    }
    if (x == 2)
    {
        printf("%d", a + b);
    }
    return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define fi first
#define se second
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repp(i, a, b) for (int i = a; i <= (b); ++i)
#define repr(i, a, b) for (int i = a; i >= (b); --i)
typedef long long ll;
const int INF = 1001001001;
const ll LINF = 1001001001001001001ll;
const int MOD = 1000000007;

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() {
  string O;
  cin >> O;
  string E;
  cin >> E;
  rep(i, E.size()) { cout << O[i] << E[i]; }
  if (O.size() == E.size() + 1)
    cout << O[O.size() - 1];
  cout << endl;
}

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






#define pf                  printf
#define sf(a)               scanf("%d",&a)
#define sfl(a)              scanf("%lld",&a)
#define sff(a,b)            scanf("%d %d",&a,&b)
#define sffl(a,b)           scanf("%lld %lld",&a,&b)
#define sfff(a,b,c)         scanf("%d %d %d",&a,&b,&c)
#define sfffl(a,b,c)        scanf("%lld %lld %lld",&a,&b,&c)
#define sffff(a,b,c,d)      scanf("%d %d %d %d",&a,&b,&c,&d)
#define sffffl(a,b,c,d)     scanf("%lld %lld %lld %lld",&a,&b,&c,&d)
#define sfffff(a,b,c,d,e)   scanf("%d %d %d %d %d",&a,&b,&c,&d,&e)
#define sfffffl(a,b,c,d,e)  scanf("%lld %lld %lld %lld %lld",&a,&b,&c,&d,&e)
#define sfc(a)              scanf("%c",&a)
#define pii                 pair<int,int>
#define ms(a,b)             memset(a,b,sizeof(a))
#define pb(a)               push_back(a)
#define pbp(a,b)            push_back({a,b})
#define db                  double
#define ft                  float
#define ll                  long long
#define ull                 unsigned long long
#define pii                 pair<int,int>
#define ff                  first
#define ss                  second
#define sz(x)               x.size()
#define all(x)              x.begin(),x.end()
#define CIN                 ios_base::sync_with_stdio(0); cin.tie(0)
#define max3(a, b, c)       max(a, b) > max(b, c) ? max(a, b) : max(b, c)
#define min3(a, b, c)       min(a, b) < min(b, c) ? min(a, b) : min(b, c)
#define for0(i,n)           for(int i=0;i<n;i++)
#define for1(i,n)           for(int i=1;i<=n;i++)
#define forrev(i,n)         for(int i=n-1; i>=0; i--)
#define forab(i,a,b)        for(int i=a;i<=b;i++)
#define forba(i,b,a)        for(int i=b;i>=a;i--)
#define stlloop(x)          for(__typeof(x.begin()) it=x.begin();it!=x.end();it++)
#define gcd(a, b)           __gcd(a, b)
#define lcm(a, b)           ((a)*((b)/gcd(a,b)))
#define case1(z)            cout<<"Case "<<z<<": "
#define case2(z)            printf("Case %d: ",z)
#define PI                  acos(-1) //3.14159265358979323846264338328
#define valid(tx,ty)        tx>=0 && tx<row && ty>=0 && ty<col
#define intlim              2147483648
#define N                   200005
#define inf                 100000008
#define mod                 1000000007

/*------------------------------Graph Moves----------------------------*/
//const int fx[]={+1,-1,+0,+0};
//const int fy[]={+0,+0,+1,-1};
//const int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};   // Kings Move
//const int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};  // Kings Move
//const int fx[]={-2, -2, -1, -1,  1,  1,  2,  2};  // Knights Move
//const int fy[]={-1,  1, -2,  2, -2,  2, -1,  1}; // Knights Move
/*---------------------------------------------------------------------*/



int main()
{
	ll a,b=0,t,x;
	cin>>t;
	x=t;
	while(t>0)
	{
		a=t%10;
		t/=10;
		b+=a;
	}
	//cout<<b<<endl;
	if(x%b==0)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
	return 0;
}






























Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int n;
int a[100100];
int main() {
    scanf("%d",&n);
    for (int i=0; i<n ;i++) scanf("%d",&a[i]);
    int x1 = 0;
    for (int i=0; i<n; i++) {
        if (i%2==0) x1+=a[i];
        else x1-=a[i];
    }
    printf("%d ",x1);
    for (int i=1; i<n; i++) {
        x1 = 2*a[i-1]-x1;
        printf("%d ",x1);
    }
}


Measured memory_bytes: 1664
#define _CRT_SECURE_NO_WARNINGS
#include <cstdio>
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <map>
#include <iterator>
#include <functional>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <fstream>
#include <iomanip>
#include <unordered_map>
#include <unordered_set>
#include <numeric>
#include <cmath>
#include <list>
#include <sstream>
#include <tuple>
#include <complex>
#include <stdio.h>
using namespace std;
#pragma GCC optimize("O3")
#pragma GCC target("sse4")

typedef long double LD;
typedef long long LL;
typedef pair<int, int> PII;
typedef pair<LD, LD> PDD;
typedef pair<LL, LL> PLL;
typedef vector<int> VI;
typedef vector<LL> VLL;
typedef vector<char> VCH;
typedef vector<LD> VLD;
typedef vector<string> VS;
typedef vector<VS> VSS;
typedef vector<VI> VVI;
typedef vector<VLL> VVLL;
typedef vector<VCH> VVCH;
typedef vector<PII> VPII;
typedef vector<PLL> VPLL;
typedef vector<PDD> VPDD;
#define MP make_pair
#define PB push_back
#define X first
#define Y second
#define next fake_next
#define prev fake_prev
#define left fake_left
#define right fake_right

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define RFOR(i,b,a) for(int i = (b) - 1; i >= (a); --i)
#define REP(i, t) FOR(i,0,t)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())

const LD PI = acos(-1.0);
const LL mod = 1000000007;
const LL INF = 1e9;
const LL LINF = 1e18;
const LL MAXQ = 1007;
const int MAXN = 10007;

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	//freopen("In.txt", "r", stdin);

	string s;
	cin >> s;
	bool a1, a2, a3, a4;
	a1 = a2 = a3 = a4 = 0;

	FOR(i, 0, SZ(s))
		if (s[i] == 'S')
			a1 = 1;
		else
			if (s[i] == 'N')
				a2 = 1;
			else
				if (s[i] == 'W')
					a3 = 1;
				else
					a4 = 1;

	if (a1 == a2 && a3 == a4)
		cout << "Yes";
	else
		cout << "No";
	//cin >> s;


	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import Control.Arrow
import Data.Int
import Data.Foldable
import qualified Data.Vector.Unboxed as VU
import qualified Data.ByteString.Char8 as B

solve :: Int -> VU.Vector Int16 -> Int
solve n hs = fst dp
 where
  -- dp[i]: minimal cost of moving from 1st to i-th place
  dp :: (Int, Int)
  dp = VU.ifoldl'
    ( \(!dp1, !dp2) !i !v -> if i == 0
      then (0, dp1)
      else if i == 1
        then (dp1 + abs (fromIntegral $ v - hs VU.! 0), dp1)
        else
          ( min (dp1 + abs (fromIntegral $ v - hs VU.! (i - 1)))
                (dp2 + abs (fromIntegral $ v - hs VU.! (i - 2)))
          , dp1
          )
    )
    (-1, -1)
    hs

main = do
  let readInt :: Integral a => B.ByteString -> Maybe (a, B.ByteString)
      readInt = fmap (first fromIntegral . second B.tail) . B.readInt

  n  <- (\vec -> (vec VU.! 0)) . VU.unfoldrN 1 readInt <$> B.getLine
  hs <- VU.unfoldrN n readInt <$> B.getLine
  print $ solve n hs


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

using namespace std;
typedef long long int ll;

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

int main() {
  int N, i;
  scanf("%d %d", &N, &i);
  printf("%d\n", N - i + 1);
}


Measured memory_bytes: 128
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>
#include <cmath>
#include <stdio.h>
#include <functional>

using namespace std;
using ll = long long;
using ld = double;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll, ll>; //(x, y, dx, dy)
const ll INF = 1e17;
const ld eps = 1e-10;
const ll MOD = 1e9 + 7;

const double pi = acos(-1.0);

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N;
	cin >> N;
	vector<ll> c(N);
	for (int i = 0;i < N;i++) {
		cin >> c[i];
		c[i]--;
	}
	vector<ll> sum(2e5+10);
	vector<ll> dp(N + 1);
	dp[0] = 1;
	for (int i = 0;i < N;i++) {
		dp[i + 1] = (dp[i + 1] + dp[i]) % MOD;
		if (i == 0 || c[i] != c[i - 1]) {
			dp[i + 1] = (dp[i + 1] + sum[c[i]]) % MOD;
			sum[c[i]] = (sum[c[i]] + dp[i]) % MOD;
		}
	}
	cout << dp[N] << endl;
	return 0;
}


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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repp(i, n, m) for(int (i) = (n); (i) < (m); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define ldou long double
#define fi first
#define se second
#define setpre(x) std::cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define ii3(x, y, z) int x, y, z; cin >> (x) >> (y) >> (z)
#define out(x) cout << (x) << endl
#define outs(x) cout << (x) << " "
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl
#define bit_c(x) __builtin_popcountll(x)

inline void logger(){ std::cout << " [LOGGER] " << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , "; logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 200005;

/* ...o(^-^)o... */

int main(){
    unsigned long long a; string b;
    cin >> a >> b;
    b.replace(1, 1, "");
    unsigned long long c = stoi(b);
    unsigned long long res = (a * c) / 100;
    cout << res << endl;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
#include <cmath>
#include <iostream>

using namespace std;

int main() {
  int N,K;
  cin>>N>>K;
  string S;
  cin>>S;
  if(S[K-1]=='A') S[K-1]='a';
  else if(S[K-1]=='B') S[K-1]='b';
  else S[K-1]='c';
  cout<<S;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <valarray>
#include <vector>

#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>

using namespace std;

#define all(c) c.begin(), c.end()
#define repeat(i, n) for (int i = 0; i < static_cast<int>(n); i++)
#define debug(x) #x << "=" << (x)
#define dump(x) cerr << debug(x) << " (L:" << __LINE__ << ")" << endl

typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long> vl;
typedef vector<vector<long>> vvl;
typedef vector<string> vs;

template <typename T>
ostream& operator<<(ostream& os, const vector<T>& vec)
{
    os << "[";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << ",";
    }
    os << "]";
    return os;
}

template <typename T>
T input()
{
    T t;
    cin >> t;
    return t;
}

template <typename T>
vector<T> input(const int N)
{
    vector<T> v(N);
    repeat(i, N) cin >> v[i];
    return v;
}

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

long long lcm(long long a, long long b)
{
    return (a / gcd(a, b)) * b;
}

long long mul(const long long& a, const long long& b, const long long& mod)
{
    return ((a % mod) * (b % mod)) % mod;
}

long long power(const long long& x, const long long& y, const long long& mod)
{
    if (y == 0) {
        return 1;
    } else if (y == 1) {
        return x % mod;
    } else {
        long long value = power(x, y / 2, mod);
        if (y % 2 == 0) {
            return mul(value, value, mod);
        } else {
            return mul(value, value, mod) * x % mod;
        }
    }
}

long long div(const long long& a, const long long& b, const long long& mod)
{
    return mul(a, power(b, mod - 2, mod), mod);
}

map<long long, long long> factorials;
long long factorial(const long long& n, const long long& mod)
{
    if (n == 0 || n == 1) {
        return 1;
    }
    if (factorials[n] != 0) {
        return factorials[n];
    }
    factorials[n] = n * factorial(n - 1, mod) % mod;
    return factorials[n] % mod;
}

long long combination(const long long& n, const long long& x, const long long& mod)
{
    long long numerator = 1;
    long long denominator = 1;
    repeat(i, x)
    {
        numerator *= (n - i) % mod;
        numerator %= mod;
        denominator *= (i + 1) % mod;
        denominator %= mod;
    }
    return div(numerator, denominator, mod);
}

int main()
{
    int A, B;
    cin >> A >> B;
    int total = 0;

    for (int i = 0; i < 2; ++i) {
        if (A < B) {
            total += B;
            B--;
        } else {
            total += A;
            A--;
        }
    }
    cout << total << endl;
    return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<vector>
#include<cstdio>
#include<cmath>

using namespace std;

int main(){
    int n, m;
    cin >> n >> m;
    int c[m];
    for(int i=0; i < m; i++)cin >> c[i];

    int dp[50001]={0};

    for(int i = 1; i <= 50000; i++){
        dp[i] = 100000;
    }

    for(int i = 0; i <= 50000; i++){
        for(int j = 0; j < m; j++){
            if(i + c[j] <= n){
                dp[i + c[j]] = min(dp[i+c[j]], dp[i] + 1);
            }
        }
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 3292
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;
 


public class Main {
	static int a1[]= {0,-1,0,1};
	static int b1[]= {-1,0,1,0};
	private static Scanner sc = new Scanner(System.in);
	//result = Math.pow(num1, num3)
	//StringBuffer str = new StringBuffer(hoge1);
	//String hoge2 = str.reverse().toString();
	//map.containsKey(A)

	//Map<String, Integer> map = new HashMap<String, Integer>(n);
	/*for ( キーのデータ型 key : マップの名前.keySet() ) {
		データのデータ型 data = マップの名前.get( key );
		
		// keyやdataを使った処理;
	}*/
	//int i = Integer.parseInt(s);
	//Queue<String> qq=new ArrayDeque<>(); //add,poll,peek
	//Deque<String> qq=new ArrayDeque<>();//push,pop,peek
	//ArrayList<String> cc = new ArrayList<>(n);
	//Collections.sort(list);
	//Array.sort(list);   cc.contains(tmp)
	//Arrays.asList(c).contains("a")
	//list.set(1,"walk");
	public static void main(String[] args) {
		int X=sc.nextInt();
		int ans=0;
		for(int i=X/100;i!=0;i--) {
			int v=X-i*100;
			if(v<=5*i) {
				ans=1;
				break;
			}
		}
		p(ans);
	}
	static void p(String ans) {System.out.println(ans);};
	static void p(int ans) {System.out.println(ans);};
	static void p() {System.out.println();};
	static void p(long ans) {System.out.println(ans);};
	static void p(double ans) {System.out.println(ans);};
}
	

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

int main() {
  int h, w;
  cin >> h >> w;
  char a[h][w];
  int i, j;
  for (i = 0; i < h; i++) {
    for (j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }
  for (i = 0; i < h + 2; i++) {
    for (j = 0; j < w + 2; j++) {
      if (i == 0 || i == h + 1) {
        cout << '#';
      } else {
        if (j == 0 || j == w + 1) {
          cout << '#';
        } else {
          cout << a[i - 1][j - 1];
        }
      }
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 256
s = list(input())

cnt = 0
for i in range(len(s)):
  if i%2 == 1:
    if s[i] == "R":
      print("No")
      cnt = 1
      break
  else:
    if s[i] == "L":
      print("No")
      cnt = 1
      break
if cnt == 0:
  print("Yes")

Measured memory_bytes: 3060
#include <stdio.h>
int main(void)
{
	int H,W;
	int i,j;

	while(1){
	    scanf("%d %d",&H,&W);
	    if(H==0 && W==0){
	        break;
	    }
	    for(i=1;i<=H;i++){
		    for(j=1;j<=W;j++){
			    printf("#");
		    }
		    printf("\n");
        }
        printf("\n");
	}
	return 0;
}


Measured memory_bytes: 2056
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
using namespace std;

bool is_exponential(int x) {
  if (x == 1)
    return true;
  int y = x;
  for (int i = 2; i < sqrt(x) + 1; i++) {
    y = x;
    while (y % i == 0) {
      y /= i;
      if (y == 1) {
	return true;
      }
    }
  }
  return false;
}

int main() {
  int x;
  cin >> x;
  while (!is_exponential(x) && x > 0) {
    x -= 1;
  }
  cout << x << endl;
  return 0;
}


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

template <class T>
struct SegmentTree {
    using Merger = std::function<T(T, T)>;

    int length;
    std::vector<T> dat;
    T unit;
    Merger merge;

    explicit SegmentTree(int n, T unit, Merger merge)
        : length(1), unit(unit), merge(merge) {
        while (length < n) length <<= 1;
        dat.assign(length * 2, unit);
    }

    T query(int ql, int qr) {
        ql = std::max(ql, 0);
        qr = std::min(qr, length);
        ql += length, qr += length;

        T lacc = unit, racc = unit;
        while (ql < qr) {
            if (ql & 1) {
                lacc = merge(lacc, dat[ql]);
                ++ql;
            }
            if (qr & 1) {
                --qr;
                racc = merge(dat[qr], racc);
            }
            ql >>= 1, qr >>= 1;
        }
        return merge(lacc, racc);
    }

    void update(int nidx, T elem) {
        nidx += length;
        dat[nidx] = elem;

        while (nidx > 0) {
            nidx >>= 1;
            T vl = dat[nidx * 2 + 0];
            T vr = dat[nidx * 2 + 1];
            dat[nidx] = merge(vl, vr);
        }
    }
};

int main() {
    int n;
    std::cin >> n;

    SegmentTree<int> seg(n, 0, [](int a, int b) { return a + b; });

    int q;
    std::cin >> q;
    while (q--) {
        int t;
        std::cin >> t;

        if (t == 0) {
            int i, x;
            std::cin >> i >> x;
            --i;
            seg.update(i, seg.query(i, i + 1) + x);
        } else {
            int l, r;
            std::cin >> l >> r;
            --l, --r;
            std::cout << seg.query(l, r + 1) << std::endl;
        }
    }
    return 0;
}



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

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


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

#define mp make_pair
#define fst first
#define snd second
#define forn(i,n) for (int i = 0; i < int(n); i++)
#define forn1(i,n) for (int i = 1; i <= int(n); i++)
#define popcnt __builtin_popcount
#define ffs __builtin_ffs

using namespace std;

typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef pair<int,ll> pil;
typedef pair<ll,ll> pll;
template <typename T> using vec = vector<T>;
typedef vec<int> vi;
typedef vec<ll> vl;


template <typename T> T id(T b) {return b;};
template <class It> bool all(It f,It l){return std::all_of(f,l,id<bool>);}
template <class It> bool any(It f,It l){return std::any_of(f,l,id<bool>);}
template <typename T> void chmax(T &x, T y) {if (x < y) x = y;}
template <typename T> void chmin(T &x, T y) {if (x > y) x = y;}
void fastio() { ios_base::sync_with_stdio(false); cin.tie(nullptr); }
constexpr ll TEN(int n) { if (n == 0) return 1LL; else return 10LL*TEN(n-1); }

int a,b;

int main()
{
  cin >> a >> b;
  int c = 1;

  int res = 0;
  while (c < b) {
    res++;
    c = res*a-res+1;
  }

  cout << res << endl;

  return 0;
}


Measured memory_bytes: 256
n, m = map(int, input().split())
SC = [list(map(int, input().split())) for _ in range(m)]
ans = ["*"] * n
for i, j in SC:
  if ans[i - 1] == "*":
    ans[i - 1] = j
  elif ans[i - 1] != j:
    print(-1)
    exit()
if n != 1 and ans[0] == 0:
  print(-1)
  exit()
for i in range(n):
  if n != 1 and i == 0 and ans[i] == "*":
    ans[i] = 1
  elif n == 1 and i == 0 and ans[i] == "*":
    ans[i] = 0
  elif i != 0 and ans[i] == "*":
    ans[i] = 0
ans = "".join(map(str, ans))
print(ans)

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

public class Main {

	final static long MOD = 1000000007;
	public static String[] Ws = null;
	public static int wsIndx = 0;
	public static BufferedReader in = null;
	public static void main(String[] args) throws Exception {
		solution(args);
		if(in!=null){
			in.close();
		}
	}

	public static void solution(String[] args) throws Exception{

		String S = nextString();




		System.out.println(S.compareTo("2019/04/30")<=0?"Heisei":"TBD");

	}
	public static String[] toStringArray(String s) {
		String[] tmp = new String[s.length()];
		char[] c = s.toCharArray();
		for (int i = 0; i < tmp.length; i++) {
			tmp[i] = String.valueOf(c[i]);
		}
		return tmp;
	}

	public static void check() throws Exception{
		if(in == null){
			in = new BufferedReader(new InputStreamReader(System.in));
		}
		if(Ws==null || Ws.length<=wsIndx){
			Ws = in.readLine().split(" ");
			wsIndx=0;
		}
	}
	public static int nextInt()throws Exception{
		check();
		return Integer.parseInt(Ws[wsIndx++]);
	}

	public static long nextLong()throws Exception{
		check();
		return Long.parseLong(Ws[wsIndx++]);
	}

	public static String nextString()throws Exception{
		check();
		return Ws[wsIndx++];
	}

	public static int[] nextInts()throws Exception{
		check();
		int[] tmp = new int[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Integer.parseInt(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static long[] nextLongs()throws Exception{
		check();
		long[] tmp = new long[Ws.length];
		for(int i=0;i<tmp.length;i++){
			tmp[i]=Long.parseLong(Ws[i]);
		}
		wsIndx=Ws.length;
		return tmp;
	}

	public static String[] nextStrings()throws Exception{
		check();
		wsIndx=Ws.length;
		return Ws;
	}


}


Measured memory_bytes: 21076
#include <stdio.h>

int main(void) {

  int id[100],correct[100],rank[100];
  int max,count=1,flag=0;
  int query;
  int n=0,i,j,temp;

  while(1) {

    scanf("%d,%d",&id[n],&correct[n]);
    //printf("%d %d",id[n],correct[n]);
    if(id[n]==0 && correct[n]==0) break;

    n++;

  }
  //printf("%d\n",n);
  /*for(i=0;i<n;i++) {
    rank[i]=id[i];
    }*/
  //for(i=0;i<n;i++) printf("%d,%d:%d\n",id[i],correct[i],rank[i]);
  /*for(i=0;i<n-1;i++) {
    for(j=0;j<n-i-1;j++) {
      if(correct[j]<correct[j+1]) {
	temp=correct[j];
	correct[j]=correct[j+1];
	correct[j+1]=temp;
	temp=rank[j];
	rank[j]=rank[j+1];
	rank[j+1]=temp;
      }
    }
    }*/
  
  max=correct[0];
  for(i=0;i<n;i++) {
    if(max<correct[i]) max=correct[i];
  }

  for(i=max;i>=0;i--) {
    for(j=0;j<n;j++) {
      if(correct[j]==i) {
	rank[j]=count;
	flag=1;
      }
    }
    if(flag==1) {
      count++;
      flag=0;
    }
  }

  //for(i=0;i<n;i++) printf("%d,%d:%d\n",id[i],correct[i],rank[i]);
  while(scanf("%d",&query)!=EOF) {

    for(i=0;i<n;i++) {
      if(query==id[i]) printf("%d\n",rank[i]);
    }

  }

  return 0;
}

    

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,x,n) for(int i=(x);i<(n);i++)
#define all(v) (v).begin(),(v).end()
#define int long long
using namespace std;
const int MOD=1e9+7;
const int INF=1e9;
const double ESP=1e-5;
template<typename T> void cmax(T &a, T b) {a = max(a, b);}
template<typename T> void cmin(T &a, T b) {a = min(a, b);}
using Graph=vector<vector<int>>;
int h,w,c;
Graph mp(h,vector<int> (w,0));
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ans;

void change(int y,int x,int col,int pre){
  if(col==pre)return;
  mp[y][x]=col;
  rep(i,4){
    int nx=x+dx[i],ny=y+dy[i];
    if(0<=nx&&nx<w&&0<=ny&&ny<h&&mp[ny][nx]==pre){
      change(ny,nx,col,pre);
    }
  }
  return;
}
void f(int cnt){
  if(cnt==4){
    change(0,0,c,mp[0][0]);
    change(0,0,INF,mp[0][0]);
    int tmp=0;
    rep(i,mp.size())rep(j,mp[i].size())if(mp[i][j]==INF)tmp++;
    cmax(ans,tmp);
  }else{
    loop(i,1,7){
      Graph tmp=mp;
      change(0,0,i,mp[0][0]);
      f(cnt+1);
      mp=tmp;
    }
  }
}

signed main(){
  while(cin>>h>>w>>c){
    if(h==0&&w==0&&c==0)break;
    mp=vector<vector<int>> (h,vector<int> (w,0));
    rep(i,h)rep(j,w)cin>>mp[i][j];
    ans=0;
    f(0);
    cout<<ans<<endl;
  }

 return 0;
}



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

int gcd(int a, int b) {
  if(a < b) return gcd(b, a);
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main () {
  int n;
  cin >> n;
  vector<int> a(n);

  int aMin = 1e9 + 1;
  rep(i,n) cin >> a[i];

  vector<int> l(n), r(n);
  l[0] = 0;
  r[n-1] = 0;

  for(int i = 1; i < n; i++) {
    l[i] = gcd(a[i-1], l[i-1]);
    r[n-1-i] = gcd(a[n-i], r[n-i]);
  }

  int ans = 1;
  rep(i,n) ans = max(ans, gcd(l[i], r[i]));

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 1408
n=int(input())
a=[]
for i in range(n):
    b=int(input())
    a.append(b)
a.sort()
b=a

if n%2==0:
    for i in range(int(n/2-1)):
        a[int((n/2))+1+i]=2*a[int((n/2))+1+i]
        a[i]=-2*a[i]
    a[int(n/2)-1]=(-1)*a[int(n/2)-1]   
    print(sum(a))
else:
    for i in range(int(n/2)):
        a[int((n/2))+1+i]=2*a[int((n/2))+1+i]
        a[i]=-2*a[i]
    a[int(n/2)]=(-1)*a[int(n/2)]
    a[int(n/2)-1]=a[int(n/2)-1]*0.5     
    c=sum(a)
    
    b[int(n/2)+1]=0.5*b[int(n/2)+1]
    b[int(n/2)]=(-1)*b[int(n/2)]
    b[int(n/2)-1]=2*b[int(n/2)-1]
    d=sum(b)
    print(int(max(c,d)))

       

Measured memory_bytes: 7416
#include <stdio.h>
#include <stdlib.h>
int main() {
	int i;

	int n;
	int* Rt;
	int dif, maxProfit = -1000000000;
	int min;

	do {
		scanf("%d", &n);
	} while (n < 2 || 200000 < n);

	Rt = (int*)malloc(sizeof(int) * n);

	for (i = 0; i < n; i++) {
		scanf("%d", &Rt[i]);
	}

	min = Rt[0];

	for (i = 1; i < n; i++) {
		dif = Rt[i] - min;
		if (maxProfit < dif) {
			maxProfit = dif;
		}
		if (Rt[i] < min) {
			min = Rt[i];
		}
	}

	printf("%d\n", maxProfit);

	return 0;
}


Measured memory_bytes: 2552
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author emli
 */


#include <bits/stdc++.h>



#define forn(i, n) for(int i = 0 ; (i) < (n) ; ++i)
#define forx(i, n) for(int i = 1 ; (i) <= (n) ; ++i)
#define ll long long
#define all(x) (x).begin(),(x).end()
#define sqr(x) (x) * (x)
#define debug(x) cout << #x <<" = " << x << endl
#define printvpair(v) for(auto x : v) cout << x.first  <<" " << x.second << endl;
#define printv(v) if (v.size()> 0) {for(auto x : v) cout << x << " "; cout << endl;}
#define MINUS(a) memset(a,0xff,sizeof(a))

const int INF = INT_MAX / 2;
const int N = (int)2e2 + 7;

const int dx[4] = {0,  0, 1, -1};
const int dy[4] = {1, -1, 0,  0};
using namespace std;

class ARightTriangle {
public:
	void solve(std::istream& cin, std::ostream& cout) {
		ios::sync_with_stdio(false);
        cin.tie(nullptr);
        int a,b,c;
        cin >> a >> b >> c;
        cout << (a * b) / 2 << endl;
	}
};


int main() {
	ARightTriangle solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> PP;
typedef vector<ll> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(ll)(n);i++)
#define REP(i,k,n) for(ll i=(ll)(k);i<(ll)(n);i++)
#define all(v) v.begin(),v.end()
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
const int mod=1e9+7;
const ll inf=1001001001001001;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}

int main(){
    ll n;cin>>n;
    vvi v(2,vi(3));
    rep(i,2)rep(j,3)cin>>v[i][j];
    vi dp(n+1);
    REP(i,1,n+1){
        chmax(dp[i],dp[i-1]);
        rep(j,3)if(v[0][j]<=i)chmax(dp[i],dp[i-v[0][j]]+v[1][j]-v[0][j]);
    }
    ll m=dp[n]+n;
    dp=vi(m+1);
    REP(i,1,m+1){
        chmax(dp[i],dp[i-1]);
        rep(j,3)if(v[1][j]<=i)chmax(dp[i],dp[i-v[1][j]]+v[0][j]-v[1][j]);
    }
    out(m+dp[m]);
}

Measured memory_bytes: 195584
n = input()
for i in range(2**3):
    op =[]
    for j in range(3):
        if i >> j & 1:
            op.append('+')
        else:
            op.append('-')
    formula = n[0] + op[0] + n[1] + op[1] + n[2] + op[2] + n[3]
    if eval(formula) == 7:
        print(formula + '=7')
        exit()

Measured memory_bytes: 9056
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<map>
#include<cstdio>
#include<stack>
#include<queue>
#include<fstream>
#include<cstdio>
#include<deque>
#include<iomanip>
#include <numeric>
//#include<bits/stdc++.h>

using namespace std;
#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;++i)
#define REP(i,s,n) for(int i=(s);i<(n);++i)
#define repr(i,n) for(int i=n-1;i>=0;--i)
#define REPR(i,s,n) for(int i=(s);i>=(n);--(i))
#define all(a) (a).begin(),(a).end()
#define reall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
const double pi = acos(-1.0);

typedef vector<int> vi;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef deque<ll> dll;
typedef pair<ll, ll> P;
typedef vector<P> vP;
const ll mod = 1e9 + 7;
ll dx[4] = { 1,0,-1,0 };
ll dy[4] = { 0,1,0,-1 };

void printvll(vll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) cout << v[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}
void printvvll(vvll v) {
	cout << "------------------------------------------------\n";
	rep(i, v.size()) {
		rep(j, v[i].size()) {
			cout << v[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void prints(string s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) cout << s[i] << " ";
	cout << endl;
	cout << "------------------------------------------------\n";
}

void printvs(vs s) {
	cout << "------------------------------------------------\n";
	rep(i, s.size()) {
		rep(j, s[i].size()) {
			cout << s[i][j] << " ";
		}
		cout << endl;
	}
	cout << "------------------------------------------------\n";
}

void Yes(bool x) {
	if (x) cout << "Yes\n";
	else cout << "No\n";
}

void YES(bool x) {
	if (x) cout << "YES\n";
	else cout << "NO\n";
}

void yes(bool x) {
	if (x) cout << "yes\n";
	else cout << "no\n";
}

uintmax_t combination(unsigned int n, unsigned int r) {
	if (r * 2 > n) r = n - r;
	uintmax_t dividend = 1;
	uintmax_t divisor = 1;
	for (unsigned int i = 1; i <= r; ++i) {
		dividend *= (n - i + 1);
		divisor *= i;
	}
	return dividend / divisor;
}

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

	ll  d, n, r ,l ,k, ans = 0, ret = M;
	bool flag = false, flag2 = false;
	string s, t;
	char c;
	cin >> c;
	if (c == 'A') cout << 'T' << endl;
	else if (c == 'C')cout << 'G' << endl;
	else if (c == 'G')cout << 'C' << endl;
	else if (c == 'T')cout << 'A' << endl;
	return 0;

}


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

ans = 0
for d in range(1,N):
    max_now = 0
    if (N-1) % d == 0:
        now = 0

        i, j = 0, N-1
        while i < j:
            now += S[i] + S[j]
            max_now = max(now, max_now)
            i += d
            j -= d
    else:
        now = 0

        i, j = 0, N-1
        while i < N-1 and j > d:
            now += S[i] + S[j]
            max_now = max(now, max_now)
            i += d
            j -= d
    
    ans = max(max_now, ans)

print(ans)


Measured memory_bytes: 84692
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <algorithm>
#include <iomanip>
#include <math.h>
#include <string.h>
using namespace std; using ll = long long; using pll = pair<ll, ll>;
using vl = vector<ll>; using vll = vector<vl>; using vpll = vector<pll>;
int ctoi(char c) {
	switch (c) {
	case '0': return 0; case '1': return 1; case '2': return 2;
	case '3': return 3; case '4': return 4; case '5': return 5;
	case '6': return 6; case '7': return 7; case '8': return 8;
	case '9': return 9;  default: return 0;
	}
}
bool pairCompare(const pll firstElof, pll secondElof)
{
	return firstElof.first > secondElof.first;
}
//**Snippetリスト**//
//rep, vin, all, iteLoop//
//gcdlcm, isPrime, eratos, divisor, modinv, bitSearch, bitList, dfs, bfs//
//dijkstra, UnionFind, COM, digitDP//
ll i, j, k, l; ll N, M, K, H, W, L, X, Y, Z;
ll MOD = 1000000007; ll INF = 9999999999999; ll ans = INF;
vl flag, color, D; vll path;
//***********//
int main() {
	// 1 -2 4 -8 16 
	cin >> N;
	vl Ans;
	if (N == 0) cout << 0;
	else {
		ll k = 0;
		ll P = abs(N);
		while (N != 0) {
			ll p = pow(-2, k);
			if (abs(N) % abs(p*-2) != 0) {
				Ans.push_back(1);
				N -= p;
			}
			else {
				Ans.push_back(0);
			}
			//cout << N;
			k++;
		}
		reverse(Ans.begin(), Ans.end());
		for (i = 0; i < Ans.size(); i++) {
			cout << Ans[i];
		}
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
	char X, Y;
 
	cin >> X >> Y;
 
	if(X>Y){
		cout << '>' <<endl;
	}
 
	else if(X==Y){
		cout << '=' <<endl;
	}
 
	else{
		cout << '<' <<endl;
	}
 
}

Measured memory_bytes: 3628
using System;
using System.Collections;
using System.Collections.Generic;
using System.IO;
using System.Linq;

namespace C
{
    public class Program
    {
        static void Main(string[] args)
        {
            var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            Console.SetOut(sw);
            Solve();
            Console.Out.Flush();
        }

        public static void Solve()
        {
            var n = int.Parse(Console.ReadLine());
            var ai = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var answer = 0;
            for (var i = 0; i < ai.Length; i++)
            {
                while (ai[i] % 2 == 0)
                {
                    ai[i] /= 2;
                    answer++;
                }
            }
            Console.WriteLine(answer);
        }
    }
}


Measured memory_bytes: 12128
#if defined(__GNUC__)
#include <bits/stdc++.h>
// __GNUC__
#else
#include "bits/stdc++.h"
#endif
using namespace std;

#define int long long

#if defined(__GNUC__)
#define __int32 __int32_t
#endif // __GNUC__

#define itn __int32
#define REP(i, n) for(itn (i) = 0; (i) < (n); (i)++)
#define REP2(i, x, n) for(itn (i) = x; (i) < (n); (i)++)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define SORT(x) sort(ALL(x))
#define RSORT(x, T) sort(ALL(x), greater<T>())
#define REVERCE(x) reverce(ALL(x))

#define INT_POW(x, y) [](int a, int b) -> int {int c = a; REP(i, b - 1){c *= a;} return c;}(x, y)
#define INT_POWM(x, y, m) [](int a, int b, int m) -> int {int c = a; REP(i, b - 1){c *= a; c %= m;} return c;}(x, y, m)

itn main() {
	ios::sync_with_stdio(false);

	int a, b, c;

	cin >> a >> b >> c;

	if (a + b + c >= 22) {
		cout << "bust";
	}
	else {
		cout << "win";
	}

	return 0;
}


Measured memory_bytes: 256
#include <stdio.h>
int main(void){
	int n, m, c, s, d, ss[3]={-1,-1,-1}, ans=0;
	scanf("%d%d",&n,&m);
	for(int i=0; i<m; i++){
        scanf("%d%d",&s,&c);
		if( ss[s-1] != -1 && ss[s-1] != c ){ printf("-1\n"); return 0; }
		if( ss[s-1] != -1 ){ continue; }
        ss[s-1] = c;
      	if	   ( (s==3) || (s==2 && n==2) || (s==1 && n==1) ){ d=  1; }
      	else if( 		   (s==2 && n==3) || (s==1 && n==2) ){ d= 10; }
      	else if( 							  s==1 && n==3  ){ d=100; }
      	ans += (d*c);
	}
  	if	   ( (n==2 || n==3) && ss[0]==0 ){ printf("-1\n"); return 0; }
    else if(  n==2 && ans< 10 ){ ans+= 10; }
  	else if(  n==3 && ans<100 ){ ans+=100; }
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1736
#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(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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;

ll N;
ll ans = 1ll<<60;

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

  for( ll i = 1; i*i <= N; ++i ) if( N % i == 0 )
    chmin( ans, i+N/i-2 );

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

  return 0;
}

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

int main(){
	char a[100000];
	int m,num;
	cin>>num>>m>>a;
	int count =0, pcount=1;
	for(int i=0; i<num-1; i++) {
		if(a[i+1]==a[i]) count++;
		else pcount++;
	}
	
	while(pcount>1 && m>0){
		if(pcount>2){
			count+=2;
			pcount=pcount-2;
			m--;
		}
		else{
			count++;
			pcount--;
			m--;
		}
	}
	cout<< count;
	return 0;
} 


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;

void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };


// 線分 ab の偏角 返り値は[-π, π]
double argument(const pair<double, double> &a, const pair<double, double> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

const ll inf = 1LL<<60;


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

    int n; cin >> n;
    vector<int> a(n);
    rep(i, n){
        int x; cin >> x;
        a[x-1]++;
    }
    sort(a.begin(), a.end());
    vector<int> s(n+1);
    rep(i, n) s[i+1] = s[i] + a[i];
    repr(k, 1, n+1){
        int l = 0, r = n/k+1; // l:ok r:ng
        while(r-l > 1){
            int mid = (l+r)>>1;
            bool ok = [&](int mid){
                int i = lower_bound(a.begin(), a.end(), mid) - a.begin();
                int sum = mid*(n-i) + s[i];
                return (sum >= mid*k);
            }(mid);
            if(ok) l = mid; else r = mid;
        }
        cout << l << endl;
    }

    return 0;
}

Measured memory_bytes: 3200
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <stdbool.h>
#define LL long long
#define INF 1<<31-1
#define LLINF 1<<63-1
#define MIN(x,y) ((x)<(y)?(x):(y))
#define MAX(x,y) ((x)<(y)?(y):(x))
#define MOD 1000000007
#define NUM 100001
void swap(int* x,int* y){
  int tmp=*x;*x=*y;*y=tmp;
}
int par[NUM];
int UF(int n){//初期化
  for(int i=0;i<NUM;i++)par[i]=-1;
}
int Find(int x){//x番目のノードが属する木の根を探す
  if(par[x]<0)return x;
  else return par[x]=Find(par[x]);
}
int Size(int x){//x番目のノードが属する木の要素数を返す
  return -par[Find(x)];
}
bool Same(int x,int y){//x番目のノードとy番目のノードが同じ木に属しているか返す
  return Find(x)==Find(y);
}
void Unite(int x,int y){//2つの木を結合する
  x=Find(x);y=Find(y);
  if(x!=y){
    par[x]+=par[y];
    par[y]=x;
  }
}

int main() {
  int r,D,i,ans[11];
  scanf("%d%d%d",&r,&D,&ans[0]);
  for(i=1;i<11;i++){
    ans[i]=ans[i-1]*r-D;
    printf("%d\n",ans[i]);
  }    
	return 0;
}


Measured memory_bytes: 128
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc =new Scanner(System.in);
    long H=sc.nextInt();
    long W=sc.nextInt();
    if((H==1)||(W==1)){System.out.println(1);}else{
    long X=(H*W+1)/2;
    System.out.println(X);}
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
long long  n,a,cnt;


   /// start driven program
const int N=1e6+7  , MOD= 1e9+7;
long long mod(long long k, long long n){
    return ((k %= n) < 0) ? k+n : k;
}

long long fact(int n){
    if(n==1) return 1;
    return mod( mod(n,MOD) * fact(n-1)  , MOD);
}

int main(){

        int n; cin>>n;;
        cout<<fact(n);
}


Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
int dp[3005];
 
int main() {
  string s;
  cin>>s;
  dp[0]=1;
  long long tmp=0;
  long long ten=1;
  long long ans=0;
  for(int i=s.size()-1;i>=0;i--) {
    tmp=(tmp+(s[i]-'0')*ten)%2019;
    ans+=dp[tmp]++;
    ten=(ten*10)%2019;
  }
  cout<<ans;
  return 0;
}


Measured memory_bytes: 3712
def main():
    n = int(input())
    s = input()
    dp = [[0]*(n+1) for i in range(n+1)]
    ans = 0
    for i in range(n-1)[::-1]:
        for j in range(i+1,n)[::-1]:
            if s[i] == s[j]:
                dp[i][j] = max(dp[i][j], dp[i+1][j+1] + 1)
                ans = max(ans, min(dp[i][j],j-i))
    print(ans)
main()


Measured memory_bytes: 229768
#include "bits/stdc++.h"
using namespace std;
#define Would
#define you
#define all(n)  n.begin(),n.end()
#define rall(n) n.rbegin(),n.rend()
typedef long long ll;
const ll INF = 2147483647;
const ll MOD = 1e9 + 7;
const double EPS = 1e-10;
const double pi = acos(-1);//3.1415926535897932384626433832795028...
const ll SIZE = 2000005;
int dx[] = { 1,0,-1,0 }, dy[] = { 0,1,0,-1 }, alp[30];
ll fac[SIZE], finv[SIZE], inv[SIZE];
vector<ll>dij;
struct edge { ll to, cost; };
vector<vector<edge> >G;
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; }

ll mod_pow(ll a, ll b) {
	ll res = 1, mul = a;
	for (int i = 0; i < 31; ++i) {
		if (b >> i & 1) {
			res *= mul;
			res %= MOD;
		}
		mul = (mul * mul) % MOD;
	}
	return res;
}

void addedge(int from, int to, int cost) {
	G[from].push_back({ to,cost });
	G[to].push_back({ from,cost });
}

template<typename T>
vector<T> make_v(size_t a) { return vector<T>(a); }

template<typename T, typename... Ts>
auto make_v(size_t a, Ts... ts) {
	return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}

template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T & t, const V & v) { t = v; }

template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T & t, const V & v) {
	for (auto& e : t) fill_v(e, v);
}

template<typename T>
void outp(vector<T>v) {
	for (int i = 0; i < v.size(); ++i) {
		cout << v[i];
		if (i != v.size() - 1) { cout << " "; }
	}
}

double add(double a, double b) {
	if (abs(a + b) < EPS * (abs(a) + abs(b))) { return 0; }
	return a + b;
}

double len(int a, int b, int c, int d) {
	return (double)sqrt((a - c) * (a - c) + (b - d) * (b - d));
}


ll dp[1005][1005];
char g[1005][1005];
int main() {
	ll a, b;
	cin >> a >> b;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			cin >> g[i][j];
		}
	}
	dp[0][0] = 1;
	for (int i = 0; i < a; ++i) {
		for (int j = 0; j < b; ++j) {
			if (i < a - 1 && g[i + 1][j] == '.') { dp[i + 1][j] += dp[i][j]; dp[i + 1][j] %= MOD; }
			if (j < b - 1 && g[i][j + 1] == '.') { dp[i][j + 1] += dp[i][j]; dp[i][j + 1] %= MOD; }
		}
	}

	cout << dp[a - 1][b - 1] % MOD << endl;
}

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

int dp[100001];
int n, h[100001], k;

int go(int i) {
    if(i == n - 1) return 0;
    if(dp[i] != -1) return dp[i];
    int tot = INT_MAX;
    for(int j = 1; j <= k; j++){
        if(i + j <= n - 1){
            tot = min(go(j+i) + abs(h[i] - h[j+i]), tot);
//            cout << tot << " ";
        } else {
            break;
        }
    }
    return dp[i] = tot;
}

int main(){
    ios::sync_with_stdio(0); cin.tie(0);
    memset(dp, -1, sizeof dp);
    cin >> n >> k;
    for(int i = 0; i < n; i++){
        cin >> h[i];
    }
    cout << go(0);
}


Measured memory_bytes: 5760
#![allow(unused_imports)]

use text_io::*;
use proconio::*;
use std::collections::*;
use std::process::exit;
use std::cmp::*;
use itertools::Itertools;

fn main() {
    input! {
    a:usize,
    }
    println!("{}",if a==25 {"Christmas"}else if a==24{"Christmas Eve"}else if a==23{"Christmas Eve Eve"}else {"Christmas Eve Eve Eve"})
}

Measured memory_bytes: 2084
#include <stdio.h>
#include <stdlib.h>
int main(){

  int N,i,j, *A,dummy,count = 0,minj;

  scanf("%d",&N);
  A = (int *)malloc(N * sizeof(int));
  for(j = 0;j < N;j++) {
    scanf("%d",&A[j]);
  }
  for(i = 0;i < N;i++){
    minj = i;
    for(j = i;j < N;j++){
      if(A[j] < A[minj]){
        minj = j;
      }
    }
    if(i != minj) count++;
    dummy = A[minj];
    A[minj] = A[i];
    A[i] = dummy;
  }
  for(j = 0;j < N;j++){
    printf("%d",A[j]);
    if(j != N - 1) printf(" ");
  }
  printf("\n%d\n",count);

  
  return 0;
}



Measured memory_bytes: 2144