akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <numeric>

template <class T, class U>
inline bool chmin(T &lhs, const U &rhs) {
  if (lhs > rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

template <class T, class U>
inline bool chmax(T &lhs, const U &rhs) {
  if (lhs < rhs) {
    lhs = rhs;
    return true;
  }
  return false;
}

// [l, r) from l to r
struct range {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { ++i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr range(int l_, int r_): l(l_), r(std::max(l_, r_)) { }
  constexpr itr begin() const { return l; }
  constexpr itr end() const { return r; }
};

// [l, r) from r to l
struct revrange {
  struct itr {
    int i;
    constexpr itr(int i_): i(i_) { }
    constexpr void operator ++ () { --i; }
    constexpr int operator * () const { return i; }
    constexpr bool operator != (itr x) const { return i != x.i; }
  };
  const itr l, r;
  constexpr revrange(int l_, int r_): l(l_ - 1), r(std::max(l_, r_) - 1) { }
  constexpr itr begin() const { return r; }
  constexpr itr end() const { return l; }
};

int main() {
  long long N;
  std::cin >> N;
  long long cur = 1;
  std::vector<int> base = { 1 };
  while (cur * 2 + 1 <= N) {
    int add = base.back() + 1;
    base.push_back(add);
    cur = cur * 2 + 1;
  } 
  long long need = N - cur;
  std::vector<int> attach = base;
  for (int i: revrange(0, base.size() + 1)) {
    if (need >> i & 1) {
      int add = attach.back() + 1;
      base.insert(base.begin() + i, add);
      attach.push_back(add);
    }
  }
  std::cout << base.size() + attach.size() << '\n';
  for (int x: base) {
    std::cout << x << ' ';
  }
  for (int i: range(0, attach.size())) {
    std::cout << attach[i] << " \n"[i + 1 == attach.size()];
  }
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define print(x) cout << x << endl
#define rep(i, n) for (int i = 0; i < n; ++i)
typedef long long int ll;

long double f(ll n, ll a, ll k)
{

    ll c = 0;
    while (a < k)
    {
        a *= 2;
        c++;
    }

    return (1.L / n) * pow(0.5, c);
}

int main()
{
    ll n, k;
    cin >> n >> k;
    long double r = 0;
    for (int i = 1; i < n + 1; i++)
    {
        r += f(n, i, k);
    }
    printf("%.12Lf\n", r);

    return 0;
}


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

using namespace std;

int main() {
  int A, B, C, D;
  cin >> A >> B >> C >> D;
  vector<int> time(101, 0);
  time[A]++;
  time[B]--;
  time[C]++;
  time[D]--;
  int sum = 0;
  for (int i = 0; i < time.size(); ++i) {
    sum += time[i];
    time[i] = sum;
  }
  int res = 0;
  for (int i = 0; i < time.size(); ++i) {
    if (time[i] == 2) res++;
  }
  cout << res << endl;
}

Measured memory_bytes: 256
#include<stdio.h>
#define MAX 100000

int A[MAX],n;

int partition(int p, int r){
  int x,i,j,t;
  x=A[r];
  i=p-1;
  for(j=p;j<r;j++){
    if(A[j]<=x){
      i++;
      t=A[i];
      A[i]=A[j];
      A[j]=t;
    }
  }
  t=A[i+1];
  A[i+1]=A[r];
  A[r]=t;
  return i+1;
}

int main(){
  int i,q;

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

  q=partition(0,n-1);

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

  return 0;
}



Measured memory_bytes: 2104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC157C
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] NM = Console.ReadLine().Split(' ');
            int N = int.Parse(NM[0]);
            int M = int.Parse(NM[1]);
                int[] s = new int[M];
                int[] c = new int[M];
                for (int i = 0; i < M; i++)
                {
                    string[] sc = Console.ReadLine().Split(' ');
                    s[i] = int.Parse(sc[0]);
                    c[i] = int.Parse(sc[1]);
                }
                int[] num = new int[N];
                for (int i = 0; i < N; i++)
                {
                    num[i] = -1;
                }
                bool hantei = true;
                for (int i = 0; i < M; i++)
                {
                    if (num[s[i] - 1] == -1)
                    {
                        num[s[i] - 1] = c[i];
                    }
                    else if (num[s[i] - 1] == c[i])
                    {
                    }
                    else
                    {
                        hantei = false;
                    }
                }
            if (N == 1)
            {
                if (hantei == false)
                {
                    Console.WriteLine("-1");
                }
                else if (num[0] == -1)
                {
                    Console.WriteLine(0);
                }
                else
                {
                    Console.WriteLine(num[0]);
                }
            }
            else
            {
                if (hantei == false | num[0] == 0)
                {
                    Console.WriteLine("-1");
                }
                else
                {
                    for (int i = 0; i < N; i++)
                    {
                        if (num[i] == -1)
                        {
                            if (i == 0)
                            {
                                num[i] = 1;
                            }
                            else
                            {
                                num[i] = 0;
                            }
                        }
                    }
                    Console.WriteLine(string.Join("", num));
                }
            }
        }
    }
}


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

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

bool dp[1005][1005][1005];

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

    int a,b,c,k;
    cin >> a >> b >> c >> k;
    if(a > b && a > c){
        while(k > 0){
            a *= 2;
            k--;
        }
    }else if(b > a && b > c){
        while(k > 0){
            b *= 2;
            k--;
        }
    }else{
        while(k > 0){
            c *= 2;
            k--;
        }
    }
    cout << a + b + c << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
    #define F first
    #define S second
    using ll = long long;
    const ll mod = 1000000007;
    const ll infi = 1000000000000000;
    const ll md = 998244353;
    using namespace std;
    using vl = vector<ll>;
    using pll =  pair<ll,ll>;

    void solve(){
        ll n;cin>>n;
        cout<<n*(n-1)/2;
        
    }
     
    int main() {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        //int n;cin>>n; for(int i=0;i<n;i++)
        solve();
        return 0;
    } 

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
input = sys.stdin.readline
MOD = 10**9 + 7

n = int(input())
s = input().rstrip()

dp = [[0] * n for _ in range(n)]
dp[0] = [1] * n

used = 0
for i, ch in enumerate(s):
    if ch == "<":
        for j in range(n - used - 1, -1, -1):
            if j-1 >= 0:
                dp[i+1][j-1] = dp[i][j]
        for j in range(n - 1, 0, -1):
            dp[i+1][j-1] += dp[i+1][j]
            dp[i+1][j-1] %= MOD
    else:
        for j in range(n - used - 2, -1, -1):
            dp[i+1][j] = dp[i][j]
        for j in range(1, n - used - 1):
            dp[i+1][j] += dp[i+1][j-1]
            dp[i+1][j] %= MOD
    used += 1

# for line in dp:
#     print(line)
print(sum(dp[-1]) % MOD)

Measured memory_bytes: 113756
class Edge
  attr_accessor :dest, :weight
  def initialize dest, weight
    @dest = dest
    @weight = weight
  end
end


class Graph
  def initialize n
    @n = n
    @adjenceList = []
    n.times do |i|
      @adjenceList[i] = []
    end
  end

  def addEdge i, j, weight
    edge1 = Edge.new j, weight
    @adjenceList[i] << edge1
  end

  def printMatrix
    matrix = []
    @n.times do |i|
      matrix[i] = []
      @n.times do |j|
        matrix[i][j] = 0
      end
    end

    @n.times do |i|
      @adjenceList[i].each do |edge|
        matrix[i][edge.dest] = 1
      end
    end

    matrix.each do |row|
      count = 0
      row.each do |i|
        if count == 0
          print i
          count += 1
        else
          print " ", i
        end
      end
      puts ""
    end
  end
end


count = 0
n = 0
edge_data = []
STDIN.each_line {|line|
  if count == 0
    count += 1
    n = line.to_i
    next
  end

  edge_data << line
}

graph = Graph.new n.to_i
edge_data.each do |edge|
  edge_array = edge.split " "
  count = 0
  vertex = 0
  edge_array.each do |input_data|
    if count == 0
      count += 1
      vertex = input_data.to_i
      next
    end

    if count == 1
      count += 1
      next
    end

    dest = input_data.to_i
    graph.addEdge vertex - 1, dest -1, 0
  end
end

graph.printMatrix



Measured memory_bytes: 6980
//marico el que lo lea
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <stdlib.h>
#include <assert.h>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<int, int> ii;

void fastIO() {std::ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);}

#define pb push_back
#define all(obj) obj.begin(), obj.end()
#define ms(obj, val) memset(obj, val, sizeof(obj))
#define ms2(obj, val, sz) memset(obj, val, sizeof(obj[0])*sz)

#define fst first
#define snd second

template<typename T, typename U> inline void mnze(T &x, U y) {if(y < x) x = y;}
template<typename T, typename U> inline void mxze(T &x, U y) {if(x < y) x = y;}

void _scan( int &x ) { scanf("%d",&x); }
void _scan( long long &x ) { scanf("%lld",&x); }
void _scan( double &x ) { scanf("%lf",&x); }
void _scan( char &x ) { scanf(" %c",&x); }
void _scan( char *x ) { scanf("%s",x); }
template<typename T>
void _scan( vector<T> &v ){
	for(int i=0; i<(int)v.size(); i++) _scan(v[i]);
}
void scan() {}
template<typename T, typename... U>
void scan( T& head, U&... tail ) { _scan(head); scan(tail...);}

template<typename T> void _dbg(const char* sdbg, T h)
	{ cerr<<sdbg<<"="<<h<<"\n"; }
template<typename T, typename... U> void _dbg(const char* sdbg, T h, U... t) {
	while(*sdbg != ',')cerr<<*sdbg++;
	cerr<<"="<<h<<","; _dbg(sdbg+1, t...);
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#define debugv(x) {{cerr<<#x<<" = "; for(auto _i:x) cerr<<_i<<", ";cerr<<"\n";}}
#define debuga(x, sz) {{cerr<<#x<<" = ";for(int _i=0;_i<sz;_i++)cerr<<x[_i]<<", ";cerr<<"\n";}}
#else
#define debug(...) (__VA_ARGS__)
#define debugv(x)
#define debuga(x, sz)
#define cerr if(0)cout
#endif

ll MOD = 1e9+7;

inline ll Msum(ll x){return x;}
template<typename... Rest>
inline ll Msum(ll x, Rest... rest){ return (x + Msum(rest...)) % MOD; }

inline ll Mprod(ll x){return x;}
template<typename... Rest>
inline ll Mprod(ll x, Rest... rest){ return x * Mprod(rest...) % MOD; }

inline ll Mnorm(ll x){ return (x%MOD + MOD) %MOD; }

inline ll Msq(ll x){ return (x*x) %MOD; }
inline ll Mpot(ll x, ll e){
	if(!e) return 1;
	return Msq(Mpot(x, e>>1)) * (e & 1 ? x : 1)%MOD;
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////

const int MAXN = 3e5+5;

int n;
char s[MAXN];
int ans[MAXN];

int main(){
	scan(n, s);
	int curw = 0;
	for(int i=1; i<n; i++){
		curw += s[i-1] == 'W';
		ans[i] += curw;
	}
	int cure = 0;
	for(int i=n-2; i>-1; i--){
		cure += s[i+1] == 'E';
		ans[i] += cure;
	}
	int anss = ans[0];
	for(int i=0; i<n; i++) mnze(anss, ans[i]);
	printf("%d\n", anss);

}


Measured memory_bytes: 1664
#include<stdio.h>
  
int main(void){
  
int a,b,c,buf;
  
scanf("%d %d %d",&a,&b,&c);
  
if(a > b){
   buf = a;
   a = b;
   b = buf;
}
  
if(a > c){
   buf = a;
   a = c;
   c = buf;
}
  
if(b > c) {
  buf = b;
  b = c;
  c = buf;
}
  
printf("%d %d %d\n",a,b,c);
 
return 0;
  
}


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

int main(){
    int n;
    cin >> n;
    int a[n];
    for(int i=0; i<n; i++){
        cin >> a[i];
    }
    for(int i=0; i<n; i++){
        if(i) cout<<" ";
        cout << a[n -1- i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 3104
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb push_back 
#define all(a) a.begin(),a.end()
#define lb lower_bound
#define ub upper_bound
#define pii pair<int,int>
#define ld long double
#define F first 
#define S second
#define int long long int
signed main() 
{ 
    fast;
    int a,b;
    cin>>a>>b;
    if(a>b)
        swap(a,b);
    if(a == 1 && b==2)
        cout<<3;
    else if(a == 1 && b==3)
        cout<<2;
    else cout<<1;

} 

Measured memory_bytes: 256
n=int(input())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
def d(a,b):
    if a>b:
        return a-b
    else:
        return b-a
d1=0
d2=0
d3=0
dinf=0
for i in range(n):
    d1+=d(x[i],y[i])
    d2+=(d(x[i],y[i]))**2
    d3+=(d(x[i],y[i]))**3
d2=d2**(1/2)
d3=d3**(1/3)
dinf=d(x[0],y[0])
for i in range(n):
    if dinf<d(x[i],y[i]):
        dinf=d(x[i],y[i])
print(round(d1,6))
print(round(d2,6))
print(round(d3,6))
print(round(dinf,6))



Measured memory_bytes: 5664
import sys
from collections import defaultdict
sys.setrecursionlimit(10**5+1)
readline = sys.stdin.readline
N, = map(int, readline().split())
G = [[] for _ in range(N+1)]
ees = dict()
for v in range(N-1):
    a, b = map(int, readline().split())
    G[a].append(b)
    G[b].append(a)
    ees[v+1] = tuple([min(a,b), max(a,b)])
cd = dict()
cd[1] = 0
ed = dict()

def itree(v, p):
    cdd = 1
    for c in G[v]:
        if c == p:
            continue
        if cdd == cd[v]:
            cdd += 1
        cd[c] = cdd
        ed[tuple([min(c,v), max(c,v)])] = cdd
        cdd += 1
        itree(c, v)


def process():
    itree(1,0)
process()
xs = []
for i in range(N-1):
    xs.append(ed[ees[i+1]])
print(max(xs))
print("\n".join(map(str,xs)))


Measured memory_bytes: 86028
#include <bits/stdc++.h>
#define pb push_back
#define ll long long
#define hell 998244353
#define PI 3.14159265358979323846
#define N 600005
using namespace std;
ll arr[N],tree[4*N];
void up(ll node,ll l,ll r,ll ind,ll x)
{
    if(l==r)
    {
        tree[node]=max(x,tree[node]);
        return ;
    }
    ll mid=(l+r)/2;
    if(ind>=l && ind<=mid)
        up(2*node,l,mid,ind,x);
    else
        up(2*node+1,mid+1,r,ind,x);
    tree[node]=max(tree[2*node],tree[2*node+1]);
}
ll query(ll node,ll l,ll r,ll x,ll y)
{
    if(l>y || r<x)
        return INT_MIN;
    if(l>=x && r<=y)
        return tree[node];
    ll mid=(l+r)/2;
    return max(query(2*node,l,mid,x,y),query(2*node+1,mid+1,r,x,y));
}
int main()
{
   ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
  // cin>>t;
    //int c=0;
    while(t--) {
        ll n,k,i,j,l,r;
        cin>>n>>k;
        ll ans=1;
        for(i=0;i<n;i++)
        {
            cin>>arr[i];
            ++arr[i];
            l=max(1ll,arr[i]-k);
            r=arr[i]+k;
            ll q=query(1,1,N-1,l,r);
            up(1,1,N-1,arr[i],q+1);
        }
        cout<<tree[1];
    }

}


Measured memory_bytes: 14212
#include<bits/stdc++.h>
#define pb push_back 
#define mp make_pair
using namespace std;

const int maxn=1e5+7;
typedef long long ll;

int n,m,ans;
int a[maxn];

int gcd(int a,int b)
{
	return b==0? a:gcd(b,a%b);
}


int main()
{
	int i,j,k;
	scanf("%d%d",&n,&k);
	int maxv=0;
	for(i=1;i<=n;++i)
	{
		 scanf("%d",&a[i]);
		 maxv=max(maxv,a[i]);
	}
	
	j=a[1];
	for(i=2;i<=n;++i) j=gcd(j,a[i]);
	//printf("%d\n",j);
	
	if(k>maxv)
	{
		printf("IMPOSSIBLE\n");
	}
	else if(k%j==0)
	{
		printf("POSSIBLE\n");
	}
	else
	{
		printf("IMPOSSIBLE\n");
	}
	
	return 0;
}


Measured memory_bytes: 640
from collections import deque
z = deque()
for i in range(int(input())):
    c = list(map(int,input().split()))
    if c[0] == 0:
        z.appendleft(c[2]) if c[1] == 0 else z.append(c[2])
    elif c[0] == 1:
        print(z[c[1]])
    else:
        del z[0 if c[1] == 0 else -1]


Measured memory_bytes: 21976
#include <iostream>
#include <vector>
#include <string>
#include <bitset>
using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define REP(i,n) for(int i=0;i<n;i++)
#define pb push_back


// vectorの中身をcout << vs;で表示
template <class T>
ostream &operator<<(ostream &o, const vector<T> &v)
{
    o << "{";
    for (int i = 0; i < (int)v.size(); i++) o << (i > 0 ? ", " : "") << v[i];
    o << "}";
    return o;
}

int main(void) {
	// cin, coutの結びつきを解除し、速くする
	cin.tie(0);
   	ios::sync_with_stdio(false);

	int h, w; cin >> h >> w;

	vector<string> vs;
	REP(i, h) {
		string str;
		cin >> str;
		vs.pb(str);
	}


	bitset<100> bsh; // bitsetは〇〇コンテナないので、固定長
	bitset<100> bsw;

	REP(i, h) {
		REP(j ,w) {
			if (vs.at(i).at(j) == '#') {
				bsh[i] = 1;
				break;
			}
		}
	}

	
	REP(j, w) {
		REP(i, h) {
			if (vs.at(i).at(j) == '#') {
				bsw[j] = 1;
				break;
			}
		}
	}

	
	REP(i, h) {
		REP(j ,w) {
			if (bsh[i] == 0) {
				break;
			}
			if (bsw[j] == 1) {
				cout << vs.at(i).at(j);
				if (j == w - 1) cout << endl;
			} else {
				if (j == w - 1) cout << endl;
			}
		}
	}
	cout << 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;

int main(void)
{
    int N, X, m, sum = 0, imin = 1100;

    cin >> N >> X;

    rep(i, N)
    {
        cin >> m;
        sum += m;

        if (m < imin)
            imin = m;
    }

    cout << N + (X - sum) / imin << endl;

    return 0;
}

Measured memory_bytes: 3600
/*------------------------------------
........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(){
    map <int,int> m;
    int n,ans=0; cin>>n; 
    while (n--){
        int a; cin>>a;
        m[a] = m[a]^1;
    }
    for (auto it: m) if (it.ss&1) ans++;
    cout << ans << endl;
}

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


Measured memory_bytes: 9724
#include <stdio.h>

int A[1000000], n;

int binary(int);

int main()
{
    int i, q, k, sum = 0;
    scanf("%d", &n);
    for (i = 0; i < n; i++)
        scanf("%d", &A[i]);
    scanf("%d", &q);
    for (i = 0; i < q; i++)
    {
        scanf("%d", &k);
        sum += binary(k);
    }
    printf("%d\n", sum);
    return 0;
}

int binary(int key)
{
    int left = 0, right = n, mid;
    while (left < right)
    {
        mid = (right + left) / 2;
        if (key == A[mid])
            return 1;
        else if (key < A[mid])
            right = mid;
        else if (key > A[mid])
            left = mid + 1;
    }
    return 0;
}


Measured memory_bytes: 2156
def hoge() gets.split.map(&:to_i) end
n, m, c = hoge
b = hoge
a = n.times.map{ hoge }

hoge = 0
a.each_with_index do |x, i|
    fuga = c
    x.each_with_index{ |y, j| fuga += y * b[j] }
    hoge += 1 if fuga > 0
end

puts hoge

Measured memory_bytes: 1788
class Combination:                                      # 計算量は O(n_max + log(mod))
    def __init__(self, n_max, mod=10**9+7):
        self.mod = mod
        f = 1
        self.fac = fac = [f]
        for i in range(1, n_max+1):                     # 階乗(= n_max !)の逆元を生成
            f = f * i % mod                             # 動的計画法による階乗の高速計算
            fac.append(f)                               # fac は階乗のリスト
        f = pow(f, mod-2, mod)                          # 階乗から階乗の逆元を計算。フェルマーの小定理より、　a^-1 = a^(p-2) (mod p) if p = prime number and p and a are coprime
                                                        # python の pow 関数は自動的に mod の下での高速累乗を行ってくれる
        self.facinv = facinv = [f]
        for i in range(n_max, 0, -1):                   # 上記の階乗の逆元から階乗の逆元のリストを生成（＝ facinv ）
            f = f * i % mod
            facinv.append(f)
        facinv.reverse()

    def H(self, n, r):                                  # (箱区別:〇　ボール区別:×　空箱:〇)　重複組み合わせ nHm
        if (n == 0 and r > 0) or r < 0: return 0
        return self.fac[n+r-1] * self.facinv[r] % self.mod * self.facinv[n-1] % self.mod

N, M, K = map(int, input().split())
MOD=998244353
C = Combination(N,MOD)
res = 0
p=pow(M-1,N-K-1,MOD)
for k in range(K,-1,-1):
    res += C.H(N - k,k) * M * p
    p *= (M-1)
    p %= MOD
    res %= MOD
print(res)

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

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

    int dif;
    int finish=0;
    rep(i,int(sqrt(x))) {
        if (finish == 1) break;
        if (x%(i+1)==0) {
            dif = i+1;
            rep(j,10000) {
                int b;
                b = j-dif;
                if (int(pow(j,5)-pow(b,5))==x) {
                    cout << j << " " << b << endl;
                    finish = 1;
                    break;
                }
            }
        }
    }

    return 0;
}

Measured memory_bytes: 4124
/*
If you want to aim high, aim high
Don't let that studying and grades consume you
Just live life young
******************************
What do you think? What do you think?
1st on Billboard, what do you think of it
Next is a Grammy, what do you think of it
However you think, I’m sorry, but shit, I have no fucking interest
*******************************
Higher, higher, even higher, to the point you won’t even be able to see me
https://www.a2oj.com/Ladder16.html
*******************************
NEVER DO 300IQ CONTESTS EVER
300IQ AS WRITER = EXTRA NONO
*/
import java.util.*;
import java.io.*;
import java.math.*;

   public class Main
   {
      public static void main(String omkar[]) throws Exception
      {
         BufferedReader infile = new BufferedReader(new InputStreamReader(System.in));  
         char[] input = infile.readLine().toCharArray();
         int N = input.length;
         int[] arr = new int[N+1];
         Arrays.fill(arr, -1);
         if(input[0] == '<')
            arr[0] = 0;
         if(input[N-1] == '>')
            arr[N] = 0;
         for(int i=1; i <= N-1; i++)
            if(input[i-1] == '>' && input[i] == '<')
               arr[i] = 0;
         for(int i=1; i <= N-1; i++)
            if(input[i-1] == '<' && input[i] == '>')
            {
               int left = i;
               while(arr[left] != 0)
                  left--;
               int right = i;
               while(arr[right] != 0)
                  right++;
               int temp = 1;
               for(int a=left+1; a < i; a++)
                  arr[a] = temp++;
               temp = 1;
               for(int a=right-1; a > i; a--)
                  arr[a] = temp++;
               arr[i] = Math.max(arr[i-1],arr[i+1])+1;
            }
         for(int i=0; i <= N; i++)
            if(arr[i] == 0)
            {
               int dex = i-1;
               while(dex >= 0 && arr[dex] < 0)
               {
                  arr[dex] = arr[dex+1]+1;
                  dex--;
               }
               dex = i+1;
               while(dex <= N && arr[dex] < 0)
               {
                  arr[dex] = arr[dex-1]+1;
                  dex++;
               }
            }
         long res = 0L;
         for(int x: arr)
            res += x;
         System.out.println(res);
      }
   }

Measured memory_bytes: 29968
n=int(input())
hi=[]
for i in map(int,input().split()):
    hi.append(i)
#print(hi)
icnt=0
icmax=0
for i in range(n-1):
    if hi[i]>=hi[i+1]:
        icnt=icnt+1
    else:
        icnt=0
    if icnt>icmax:
        icmax=icnt

print(icmax)

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

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n)-1;i>=0;i--)
#define rrep2(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define all(a) (a).begin(),(a).end()

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<P> vp;
typedef vector<ll> vll;

const int INF = 99999999;

bool dfs(int now, int s, const vector<vector<int>> &G, vector<bool> &visited) {
    visited[now] = true;
    for (int nxt : G[now]) {
        if (nxt == s) return false;
        if (visited[nxt]) continue;
        if (!dfs(nxt, s, G, visited)) return false;
    }
    return true;
}

bool isDAG(const vector<vector<int>> &G) {
    int n = G.size();
    rep(i, n) {
        // if (visited[i]) continue;
        vector<bool> visited(n, false);
        if (!dfs(i, i, G, visited)) return false;
    }
    return true;
}

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

    int N, M;
    cin >> N >> M;

    vector<vector<int>> G(N);
    rep(i, M) {
        int a, b;
        cin >> a >> b;
        // a--; b--;
        G[a].emplace_back(b);
    }

    cout << (isDAG(G) ? 0 : 1) << endl;
}

Measured memory_bytes: 3228
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;  //4桁の整数
  
  cin >> N;  //入力
  
  int a;  //一桁目
  int b;  //二桁目
  int c;  //三桁目
  int d;  //四桁目
  
  d = N % 10;
  c = N % 100 - d;
  b = N % 1000 - (c * 10 + d);
  a = N - (b * 100 + c * 10 + d);
  
  if (a == b && b == c){
  	cout << "Yes" << endl;
  } else if (b == c && c == d){
  	cout << "Yes" << endl;
  } else {
  	cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cmath>
#include <limits>
#include <functional>
typedef long long ll;
using namespace std;
#define rep(i, n) for (int (i) = 0; (i) < int(n); i++)
#define mod 1000000007
#define fst first
#define pb push_back


int main()
{
	int N;
	cin >> N;
	vector<double> g(N);
	for (int i = 0; i < N; i++) {
		cin >> g[i];
	}
	sort(g.begin(), g.end());
	double sum = (g[0] + g[1]) / 2;
	for (int i = 2; i < N; i++) {
		sum = (sum + g[i]) / 2;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	string a,b,c,d;
	a="Sunny";
	b="Cloudy";
	c="Rainy";
	cin>>d;
	if(d==a){
		cout<<b;
	}else if(d==b){
		cout<<c;
	}else{
		cout<<a;
	}
}

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

    using namespace std;
    template <typename T>
    void debug(string t, T input) {
        cout<<t<<"-> "<<input<<"\n";
    }
    template <typename T>
    void debug(int i,string t, T input) {
        cout<<"Case#"<<i<<" "<<t<<"-> "<<input<<"\n";
    }

    int main(){
        long long a[4000];
        a[0]=100;
        long long k;
        cin>>k;
        for(int i=1;i<4000;i++){
            a[i]=a[i-1]+(0.01*a[i-1]);
            if(a[i]>=k){
                cout<<i;
                return 0;
            }
        }
        return 0;
    }


Measured memory_bytes: 3628
#include <algorithm>
#include <iterator>
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <time.h>
#include <limits>
#include <math.h>
#include <climits>
#include <numeric>
#include <utility>
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <assert.h>
#include <functional>
#include<unordered_map>

using namespace std;
const double pi=acos(-1.0);
//memset ( a , 0 , n * sizeof(ll) ) ;

#define 	boost  		ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); // don't use if small inpts
#define 	endl 		'\n'
#define 	sl(n) 		scanf("%lld",&n)
#define		mp 			make_pair
#define 	pb 			push_back
#define 	ppb 		pop_back
#define 	fi 			first
#define 	se 			second
#define 	ll 			long long
#define 	ull 		unsigned long long
#define 	pii 		pair<int, int>
#define 	f(i,a,b) 	for(ll i = (ll)(a); i < (ll)(b); i++)
#define 	rf(i,a,b) 	for(ll i = (ll)(a); i > (ll)(b); i--)
#define 	ms(a,b) 	memset((a),(b),sizeof(a))
#define 	max(a,b) 	((a>b)?(a):(b))
#define 	min(a,b) 	((a<b)?(a):(b))
#define 	vec(g1) 	int temp;cin>>temp;g1,push_back(temp);
#define 	abs(x) 		((x<0)?(-(x)):(x))
#define 	MAX 		1000005
#define 	inf 		LLONG_MAX
#define 	MIN 		INT_MIN

//typedef
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<PII> VII;
typedef vector<VI> VVI;
typedef map<int,int> MPII;
typedef set<int> SETI;
typedef multiset<int> MSETI;
typedef long int int32;
typedef unsigned long int uint32;
typedef long long int int64;
typedef unsigned long long int  uint64;


int mod = 1e9 + 7 ;
ll gcd(ll a , ll b){return b==0?a:gcd(b,a%b);}
ll powmod(ll a,ll b) {ll res=1;if(a>=mod)a%=mod;for(;b;b>>=1){if(b&1)res=res*a;if(res>=mod)res%=mod;a=a*a;if(a>=mod)a%=mod;}return res;}
// ll fac[200005];
// ll inverse(ll n){return powmod(n, mod-2);}
// ll nCr(ll n, ll r){return (fac[n] * inverse(fac[r]) % mod * inverse(fac[n-r]) % mod) % mod;}
////****************************************************************************************************************************************************************************************************************////
bool verify( int a[],int n){
             sort(a,a+n);
             int flag=0;
             if(n%2==0){
             	 int k=1;
             	 for(int i=1;i<n;i+=2 ){
             	 	if(a[i]!=a[i-1] || a[i]!=k){ flag=1;break;}
             	 	else k+=2;
             	 }
             	 
             }
             else {
             	 int k=2;
             	 if(a[0]!=0)flag=1;
             	 for(int i=2;i<n;i+=2){
             	 	 if(a[i]!=a[i-1] || a[i]!=k){flag=1;break;} 
             	 	 else k+=2;
             	 }
             }
             if(flag)return false;
             else return true;
             
  
}
int main(){
    int n;
    cin>>n;
    int a[n];
    ll sum=0;
    f(i,0,n){cin>>a[i]; sum+=a[i];}
    
     if(!verify(a,n)){ cout<<"0"<<endl;return 0;}
    int r=n/2;
    cout<<powmod(2,r)<<endl; 
    

}

Measured memory_bytes: 640
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int r, d;
	ll x; cin >> r >> d >> x;
	rep(i, 10){
		x = r * x - d;
		cout << x << endl;
	}
	
	return 0;
}

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

void bad() {
    cout << "Impossible\n";
    exit(0);
}

int main() {
    int n; cin >> n;
    vector<int> f(n + 1, 0);
    int maxx = 0, minn = n + 2;

    for(int i = 0; i < n; ++i) {
        int x; cin >> x;
        f[x]++;
        maxx = max(x, maxx);
        minn = min(x, minn);
    }
    
    if(maxx % 2) {
        if(minn != maxx / 2 + 1)
            bad();
        if(f[minn] != 2)
            bad();
        for(int i = minn + 1; i <= maxx; ++i) {
            if(f[i] < 2)
                bad();
        }
    } else {
        if(minn != maxx / 2)
            bad();
        if(f[minn] != 1)
            bad();
        for(int i = minn + 1; i <= maxx; ++i) {
            if(f[i] < 2)
                bad();
        }
    }

    cout << "Possible\n";
}

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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define br() p("")
#define pn(s) cout << (#s) << " " << (s) << endl
#define p_yes() p("Yes")
#define p_no() p("No")

const ll mod = 1e9 + 7;
const ll inf = 1e18;

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

    // input
    ll money;
    cin >> money;

    ll count = 0;
    vector<ll> A = {25, 10, 5, 1};

    for(ll a : A){
        count += money / a;
        money %= a;
    }
    p(count);
    
    return 0;
}


Measured memory_bytes: 3212
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <complex>
#include <cstring>
#include <cstdlib>
#include <string>
#include <cmath>
#include <queue>
#include <set>
#include <map>
#include <valarray>
#include <bitset>
#include <stack>
using namespace std;

#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()
const int INF = 1<<29;

int dp[1001][101];

int main() {
  int limit, n, m, x;
  while(cin >> limit >> n >> m >> x, limit) {
    int e[n+m], s[n+m];
    REP(i, n+m) {
      string t;
      cin >> t >> e[i] >> s[i];
    }
    REP(i, 1001) REP(j, 101) dp[i][j] = -INF;
    REP(i, 1001) dp[i][0] = 0;
    REP(i, m) {
      for (int j=limit; j>=e[n+i]; --j) {
        for (int k=m-1; k>=0; --k)
          dp[j][k+1] = max(dp[j][k+1], dp[j-e[n+i]][k] + s[n+i]);
      }
    }
    int ans = 0;
    // REP(i, limit+1) {
    //   REP(j, m+1) {
    //     printf("(%d,%d) ",i,j);
    //     cout << dp[i][j] << endl;
    //   }
    // }
    REP(i, n) {
      for (int k=x; k<=m; ++k) {
        if (limit-e[i] < 0) continue;
        ans = max(ans, dp[limit-e[i]][k] + s[i]);
        REP(j, i) {
          if (limit-e[i]-e[j] < 0) continue;
          ans = max(ans, dp[limit-e[i]-e[j]][k] + s[i] + s[j]);
        }
      }
    }
    cout << ans << endl;
  }
  
}

Measured memory_bytes: 1316
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 998244353
int fact[300001];

int modpow(int x, int k) {
  int a = 1;
  while (k > 0) {
    if (k & 1) a = (1LL*a*x) % MOD;
    x = (1LL*x*x) % MOD;
    k >>= 1;
  }
  return a;
}

int inv(int x) {
  return modpow(x, MOD-2);
}

int nCr(int n, int k) {
  if (n < 0 || k < 0 || n < k) return 0;
  return (1LL * fact[n] * inv((1LL*fact[k]*fact[n-k]) % MOD)) % MOD;
}

int N, A, B;
long long K;
signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  fact[0] = 1;
  for (int i=1; i<=300000; i++) {
    fact[i] = (1LL*i*fact[i-1]) % MOD;
  }

  cin >> N >> A >> B >> K;
  int s = 0;
  rep(x, N+1) {
    long long t = K-1LL*A*x;
    if ((t%B)!=0) continue;
    int y = t/B;
    if (y < 0 || y > N) continue;
    s = (s + 1LL*nCr(N, x)*nCr(N, y)) % MOD;
  }
  cout << s << "\n";
  return 0;
}


Measured memory_bytes: 1408
N,M,C = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
ans=0
for i in range(N):
    A = [int(i) for i in input().split()]
    cnt=0
    for j in range(M):
        cnt+=A[j]*B[j]
    cnt+=C
    if cnt>0: ans+=1
print(ans)

Measured memory_bytes: 3060
def get_perfomance(score):
    m, f, r = score
    sum_mf = m + f
    if 0 > m or 0 > f:
        return 'F'
    elif 80 <= sum_mf:
        return 'A'
    elif 65 <= sum_mf:
        return 'B'
    elif 50 <= sum_mf:
        return 'C'
    elif 30 <= sum_mf:
        if 50 <= r:
            return 'C'
        else:
            return 'D'
    else:
        return 'F'

if __name__ == '__main__':
    score_list = []
    while True:
        values = [int(x) for x in input().split()]
        if 3 == values.count(-1):
            break
        score_list.append(values)

    for score in score_list:
        print(get_perfomance(score))

Measured memory_bytes: 7660
#from fractions import gcd
#mod = 10 ** 9 + 7
#N = int(input())
#a = list(map(int,input().split()))
#a,b,c = map(int,input().split())
#ans = [0] * N
import math

def intinput():
    return int(input())

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

def splitintinput():
    return map(int,input().split())

N = intinput()
print(2**int(math.log2(N)))


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector> 
#define MN 1010 
#define MM 201000

typedef std::pair<int, int> P;

P d[MN][2], q[MN * 2];
int Ans[MN][MN], Ans2[MN][MN];
int hh = 0, tt = 0;
int x[MM], y[MM];
std::vector<int> to[MN];

void bfs(int S)
{
	hh = 0; tt = 0;
	memset(d, -1, sizeof(d));
    for(int i = 0; i < to[S].size(); i++)
		d[to[S][i]][0] = P(1, to[S][i]), q[tt++] = P(to[S][i], 0);
	while(hh < tt)
	{
		int u = q[hh].first, o = q[hh].second; hh++;
    	for(int i = 0; i < to[u].size(); i++)
		{
			if(to[u][i] == S) continue;
			if(d[to[u][i]][0].first == -1)
			{
				d[to[u][i]][0].first = d[u][o].first + 1;
				d[to[u][i]][0].second = d[u][o].second;
				q[tt++] = P(to[u][i], 0);
			}
			else if(d[to[u][i]][1].first == -1 && d[to[u][i]][0].second != d[u][o].second)
			{
				d[to[u][i]][1].first = d[u][o].first + 1;
				d[to[u][i]][1].second = d[u][o].second;
				q[tt++] = P(to[u][i], 1);
			}
		}
	}
}

int main()
{
	int n, m; scanf("%d%d", &n, &m);
	for(int i = 1; i <= m; i++)
	{
		scanf("%d%d", &x[i], &y[i]);
		to[x[i]].push_back(y[i]);
	}
	for(int i = 1; i <= n; i++)
	{
		bfs(i);
		for(int j = 1; j <= n; j++)
		{
			if(d[j][0].second != j) Ans[i][j] = d[j][0].first;
			else Ans[i][j] = d[j][1].first;
			Ans2[i][j] = d[j][0].first; 
		}
	}
	for(int i = 1; i <= m; i++) 
	{
		if(Ans[x[i]][y[i]] == -1 && Ans2[y[i]][x[i]] != -1 || Ans[x[i]][y[i]] != -1 && Ans2[y[i]][x[i]] == -1)
			puts("diff");
		else puts("same");
	}
}

Measured memory_bytes: 12288
a=int(input())
b=int(input())
c=int(input())
x=int(input())
ans=0
for ai in range(a+1):
  for bi in range(b+1):
    for ci in range(c+1):
      y=500*ai+100*bi+50*ci
      if x == y:
        ans+=1
      if y>x:
        break
print(ans)

Measured memory_bytes: 9116
#include<iostream>
using namespace std;
int main()
{
    string s, p = "";
    int k;
    cin >> k >> s;
    if(s.size() <= k)
        cout << s;
    else
    {
        for(int i = 0; i < k; i++)
        {
             p = p + s[i];
        }
        cout << p << "...";
    }
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;


int main()	
{
	int n;
	string s;
	stringstream ss;
	cin>>n;
	for(int i=n;i<=999;i++)
	{
		ss<<i;
		ss>>s;
		ss.clear();
		if(s[0]==s[1]&&s[1]==s[2])
		{
			cout<<s<<endl;
			return 0;
		}
	}
}

Measured memory_bytes: 256
// Original: https://github.com/tanakh/competitive-rs
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::BTreeMap;

fn main() {
    input!(n: usize, k: usize);

    if k == 1 {
        println!("0");
    } else {
        println!("{}", n - k);
    }
}


Measured memory_bytes: 4352
#include <iostream>
#include <cstdlib>
#include <string>
#include <vector>
#include <set>
#include <queue>

using namespace std;

int main()
{
    int n, k;
    cin >> n >> k;
    vector<int> h(n);
    set<int> cost;
    int dp[n];
    for (int i=0; i<n; ++i){
        cin >> h[i];
        dp[i] = 0;
    }
    for (int i=1; i<n; ++i){
        for (int j=1; j<=min(k, i); ++j){
            cost.insert(abs(h[i] - h[i-j]) + dp[i-j]);
        }
        dp[i] = *(cost.begin());
        cost.clear();
    }
    cout << dp[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
B - AtCoDeerくんとボール色塗り / Painting Balls with AtCoDeer
https://abc046.contest.atcoder.jp/tasks/abc046_b

"""
import sys


def solve(N, K):
    ans = K
    for _ in range(1, N):
        ans *= (K-1)
    return ans


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 38256
import java.util.Scanner;

public class Main {

    /**
     * @param args
     */
    public static void main(String[] args) {
        Scanner sc=new Scanner(System.in);
        while(true){
            int n = sc.nextInt();
            if(n==0)break;
            boolean f = true;
            int c = 0;
            int ans=0;
            for (int i = 0; i < n; i++) {
                String s = sc.next();
                int add = 0;
                if(s.charAt(0)=='l'){
                    add=1;
                } else {
                    add=2;
                }
                if(s.charAt(1)=='u'){
                    c+=add;
                } else {
                    c-=add;
                }
                if(c==3){
                    if(f)ans++;
                    f=false;
                    
                }
                if(c==0){
                    if(!f)ans++;
                    f=true;
                    
                }
            }
            System.out.println(ans);
        }
    }

}

Measured memory_bytes: 27072
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        n: usize,
        m: usize,
    }
    println!("{}", (n as f64 / m as f64).ceil());
}

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

using namespace std;

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

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

    int a, b;
    cin >> a >> b;

    cout << 1ll * a / gcd(a, b) * b << endl;

    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

#define INPUT_NUMBER 3

int main(void){
    int a,b,c;
    scanf("%d",&a);
    scanf("%d",&b);
    scanf("%d",&c);

    int count=0;

    for(int i=a;i<=b;i++){
        if(c%i==0){
            count++;
        }
    }

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

    return 0;
}


Measured memory_bytes: 1952