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

#define ris   return *this
#define tmplt template<class T
#define dbgo  debug& operator<<
tmplt > struct rge { T b, e; };
tmplt > rge<T> range(T i, T j) { return rge<T>{i, j}; }
struct debug {
#ifdef LOCAL
~debug(){cerr<<endl;}
tmplt > dbgo(T x){cerr<<boolalpha<<x;ris;}
tmplt, class C > dbgo(pair<T, C> x){ris<<"("<<x.first<<", "<<x.second<<")";}
tmplt > dbgo(rge<T> x){*this<<"[";for(auto it=x.b;it!=x.e;it++){*this<<", "+2*(it==x.b)<<*it;}ris<<"]";}
tmplt > dbgo(vector<T> x){ris<<range(x.begin(),x.end());}
#else
tmplt > dbgo(const T&){ris;}
#endif
};
#define nav(...) << "[ " << #__VA_ARGS__ ": " << (__VA_ARGS__) << " ] "
using ll = long long;

#define forn(i, n) for(int i = 0; i < int(n); i++)
#define ford(i, n) for(int i = n-1; i >= 0; i--) 

template<typename T> 
void min_self(T& a, T b) { 
    a = min(a, b); 
}
template<typename T>
void max_self(T& a, T b) { 
    a = max(a, b); 
}


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

    string t;
    cin >> t;
    for(char c : t) {
        if(c == '?' || c == 'D') {
            cout << "D";
        } else {
            cout << "P";
        }
    }
    cout << '\n';
}













// Spend more time thinking, it won't hurt

// Read statement carefully
// Solve on paper first!
// Make your infinity big enough
// Overflows (long long)

// Author: blondie


Measured memory_bytes: 3756
import sys,collections as cl,bisect as bs,math
sys.setrecursionlimit(100000)
Max = sys.maxsize
def l(): #intのlist
	return list(map(int,input().split()))
def m(): #複数文字
	return map(int,input().split())
def onem(): #Nとかの取得
	return int(input())
def s(x): #圧縮
	a = []
	aa = x[0]
	su = 1
	for i in range(len(x)-1):
		if aa == x[i+1]:
			a.append([aa,su])
			aa = x[i+1]
			su = 1
		else:
			su += 1
	a.append([aa,su])
	return a
def jo(x): #listをスペースごとに分ける
	return " ".join(map(str,x))
def max2(x): #他のときもどうように作成可能
	return max(map(max,x))

n,m = m()

print(-(-n//(m*2+1)))

Measured memory_bytes: 3316
#include<iostream>
#include<vector>
#include<cmath>
 
using namespace std;
 
signed main(){
 
  int N, Z, W, ans = (1<<30);
  vector<int> a;
  
 
  cin>>N>>Z>>W;
 
  a.resize(N);
  
  for(int i = 0; i < N; i++){
    cin>>a[i];
  }
 
  ans = abs(a.back() - W);
 
  if(a.size() >= 2) ans = max(ans, (int)abs(a.back() - a[a.size()-2]));
 
  cout<<ans<<endl;
  
  return 0;
}

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

using namespace std;

const double PI = 3.14159265358979323846;
typedef long long ll;
const double EPS = 1e-9;
#define rep(i, n) for (int i = 0; i < (n); ++i)
//#define rep(i, n) for (ll i = 0; i < (n); ++i)
//typedef pair<ll, ll> P;
typedef pair<double, double> P;
const ll INF = 10e17;
#define cmin(x, y) x = min(x, y)
#define cmax(x, y) x = max(x, y)
#define ret() return 0;

double equal(double a, double b) {
    return fabs(a - b) < DBL_EPSILON;
}

std::istream &operator>>(std::istream &in, set<string> &o) {
    string a;
    in >> a;
    o.insert(a);
    return in;
}

std::istream &operator>>(std::istream &in, queue<int> &o) {
    ll a;
    in >> a;
    o.push(a);
    return in;
}

bool contain(set<int> &s, int a) { return s.find(a) != s.end(); }

//ofstream outfile("log.txt");
//outfile << setw(6) << setfill('0') << prefecture << setw(6) << setfill('0') << rank << endl;
// std::cout << std::bitset<8>(9);
//const ll mod = 1e10;

typedef priority_queue<ll, vector<ll>, greater<ll> > PQ_ASK;

ll digits(ll a) {
    ll sum = 0;
    while (a > 0) {
        sum += a % 10;
        a /= 10;
    }
    return sum;
}

int main() {
    ll n;
    cin >> n;
    ll ans = INF;
    rep(i, n) {
        ll a = i;
        ll b = n - i;
        if (a == 0 || b == 0) continue;
        ll p = digits(a) + digits(b);
        cmin(ans, p);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
		final long MOD = 998244353;
		long[][] dp = new long[D][C];
		long[][] sum = new long[D][C];
		sum[B-1][A-1] = 1;
		for(int i=A; i<C; i++) {
			sum[B-1][i] = (sum[B-1][i-1]*B)%MOD;
		}
		
		for(int i=B; i<D; i++) {
			for(int j=A; j<C; j++) {
				dp[i][j] = dp[i-1][j]*j;
				dp[i][j] += sum[i-1][j-1]*j;
				dp[i][j] %= MOD;
				sum[i][j] = (sum[i][j-1]*(i+1) + dp[i][j])%MOD;
			}
		}
		
		long ans = 0;
		
		long powC = 1;
		for(int i=D-1; i>=B; i--) {
			long powI = 1;
			for(int j=C-1; j>=A; j--) {
				ans = (ans + dp[i][j]*((powC*powI)%MOD))%MOD;
				powI = (powI*(i+1))%MOD;
			}
			powC = (powC*C)%MOD;
		}
		ans = (ans + (powC*sum[B-1][C-1])%MOD)%MOD;
		
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 169728
#include <stdio.h>
int main()
{
  int a,b,c;
  scanf("%d%d%d",&a,&b,&c);
  if (a == b && b == c)
    printf("1");
  else if (a != b && b != c && a != c)
    printf("3");
  else
    printf("2");
}

Measured memory_bytes: 128
#include<iostream>
#include<vector>
#include<math.h>
#include<string>
#include<queue>
#include<map>
#include <stdio.h>
#include<algorithm>
using namespace std;



int main() {
  long long  a,b;
  cin >> a >> b;
  long long mi = min(a,b);
  long long ma = max(a,b);
  string ans;
  if(mi<=0 && ma >=0) ans ="Zero";
  else if(ma <0){
    long long del = ma-mi;
    if(del%2==0){
      ans ="Negative";
    }else {
      ans ="Positive";
    }
  }else{
    ans ="Positive";
  }
  cout << ans<<endl;
  return 0;
}


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


using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007


vector<int> c(26);
vector<vector<int>> v(365,vector<int>(26));
vector<int> contest(365,0);
vector<int> satisfy(26,0);
int d;
int res = 0;

void change_data(int day,int pos){
  vector<int> new_contest = contest;
  int res_ = res;
  int pre = new_contest[day];
  res_ += satisfy[pos];
  res_ += satisfy[pre];
  res_ -= v[day][pre];
  res_ += v[day][pos];
  int pos_satisfy = 0,pre_satisfy = 0;
  int pos_last = 0,pre_last = 0;
  new_contest[day] = pos;
  for(int i = 1;i <= d;i++)pos_last = (new_contest[i-1] == pos ? pos_last = i : pos_last),pos_satisfy += c[pos]*(i-pos_last);
  for(int i = 1;i <= d;i++)pre_last = (new_contest[i-1] == pre ? pre_last = i : pre_last),pre_satisfy += c[pre]*(i-pre_last);
  res_ -= (pos_satisfy+pre_satisfy);
  if(res < res_){
    res = res_;
    contest[day] = pos;
    satisfy[pre] = pre_satisfy;
    satisfy[pos] = pos_satisfy;
  }
}


int main(){
  
  srand((unsigned)time(NULL));
  cin >> d;
  rep(i,26)cin >> c[i];
  rep(i,d)rep(j,26){
    int x;cin >> x;
    v[i][j] = x;
  }
  /*{
    int j = d;
    for(int i = 0;j;i++){
      contest[d-j] = (i%26);
      j--;
    }
  }*/
  {
    vector<int> last(26,0);
    for(int i = 1;i <= d;i++){
      rep(j,26)if(v[i-1][contest[i-1]] < v[i-1][j])contest[i-1] = j;
      last[contest[i-1]] = i;
      res += v[i-1][contest[i-1]];
      rep(j,26)res -= c[j]*(i-last[j]),satisfy[j] += c[j]*(i-last[j]);
    }
  }
  while(1.0*clock()/CLOCKS_PER_SEC <= 0.5){
    //int now_time = clock();
    //if(1.0*now_time/CLOCKS_PER_SEC > 1.7)break;
    int day = rand()%d,pos = rand()%26;
    change_data(day,pos);
  }
  while(1.0*clock()/CLOCKS_PER_SEC <= 1.9){
    int a = rand()%(d-1);
    int res_ = res;
    res_ -= v[a][contest[a]];
    res_ -= v[a+1][contest[a+1]];
    res_ += v[a][contest[a+1]];
    res_ += v[a+1][contest[a]];
    if(res_ > res){
      swap(contest[a],contest[a+1]);
      res = res_;
    }
  }
  rep(i,d)cout << contest[i]+1 << endl;
  //cout << res << endl;///////////


  return 0;
}


Measured memory_bytes: 3668
#include <bits/stdc++.h>
using namespace std;
 
#define int long long
// #define pb push_back
// #define vi vector<int>
// #define usi unordered_set<int> 
// #define si set<int>
// #define umii unordered_map<int, int> 
// #define mii map<int, int>
// #define all(a) a.begin(), a.end()
// #define vii vector<pair<int, int>>
// #define pii pair<int, int>
// #define mod (int)(1e9+7)
// #define INF INT_MAX
 
 
int func(int ind, int sum, vector<int> &w, vector<int> &v, vector<vector<int>> &dp) {
    if (ind >= w.size())
        return 0;
    if (dp[ind][sum] != -1)
        return dp[ind][sum];
    if (w[ind] <= sum) {
        return dp[ind][sum] = max(v[ind] + func(ind+1, sum-w[ind], w, v, dp), func(ind+1, sum, w, v, dp));
    }
    else
        return dp[ind][sum] = func(ind+1, sum, w, v, dp);
}

signed main()
{
   
 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
 
    int n, k; cin >> n >> k;
    vector<int> v(n), w(n);
    vector<vector<int> > dp(n, vector<int> (k+1, -1));
    for (int i=0; i<n; i++) {
        cin >> w[i] >> v[i];
    }
    cout << func(0, k, w, v, dp);
    return 0;
}

Measured memory_bytes: 79488
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)

using namespace std;

typedef unsigned long long ll;

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


int main(){
    vector<vector<int>> a(3, vector<int>(3));

    rep(i, 3){
        rep(j, 3) cin >> a[i][j];
    } 

    int n;

    cin >> n;

    vector<int> b(n);
    rep(i, n) cin >> b[i];

    rep(k, n){
    rep(i, 3){
        rep(j, 3) if(b[k]==a[i][j]) a[i][j] = -1;
    } }

    vector<int> res_tate(3, 0);
    vector<int> res_yoko(3, 0);
    vector<int> res_naname(2, 0);

    rep(i, 3){
        rep(j, 3) res_tate[i] += a[i][j];
    }
    rep(i, 3){
        rep(j, 3) res_yoko[j] += a[i][j];
    }
   
    rep(i, 3) res_naname[0] += a[i][i];

    res_naname[1] = a[0][2] + a[1][1] + a[2][0];

    int res = 0;

    rep(i,3) {
        if(res_yoko[i]==-3) {
            res = 1;
            break;}
        if(res_tate[i]==-3) {
            res = 1;
            break;}
    }
    rep(i, 2) {if(res_naname[i]==-3) {
            res = 1;
            break;}}

    if(res) cout << "Yes";
    else cout << "No";


    return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <string>
#include <atcoder/maxflow>

#define amax(a, b) a = max(a, b)
#define amin(a, b) a = min(a, b)

using ll = long long;

int main() {
    int n, m;
    std::cin >> n >> m;
    std::vector<std::string> s(n);
    atcoder::mf_graph<int> graph(n * m + 2);
    int start = n * m, goal = n * m + 1;
    for (auto &si:s) std::cin >> si;
    for (int i=0; i<n; i++) {
        for (int j=0; j<m; j++) {
            int idx = i * m + j;
            if (s[i][j] == '#') continue;
            if ((i + j) % 2) {
                if (i > 0)   graph.add_edge(idx, idx-m, s[i-1][j] == '.');
                if (i < n-1) graph.add_edge(idx, idx+m, s[i+1][j] == '.');
                if (j > 0)   graph.add_edge(idx, idx-1, s[i][j-1] == '.');
                if (j < m-1) graph.add_edge(idx, idx+1, s[i][j+1] == '.');

                graph.add_edge(start, idx, 1);
            } else {
                graph.add_edge(idx,  goal, 1);
            }
        }
    }
    std::cout << graph.flow(start, goal) << '\n';
    for (auto [from, to, cap, flow]:graph.edges()) {
        // std::cerr << from << ' ' << to << ' ' << cap << ' ' << flow << std::endl;
        if (flow == 0 || from == start || to == goal) continue;
        if (from > to) std::swap(from, to);
        s[from / m][from % m] = (from / m == to / m ? '>' : 'v');
        s[to   / m][to   % m] = (from / m == to / m ? '<' : '^');
    }
    for (auto &si:s) std::cout << si << '\n';
    return 0;
}

Measured memory_bytes: 5508
#include <iostream>
using namespace std;
long long cost[3][30];
int main() {
    int N,C;
    int D[30][30];
    int c[500][500];
    cin >> N >> C;
    for (int i=0; i<C; i++) {
        for (int j=0; j<C; j++) {
            cin >> D[i][j];
        }
    }
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            int t;
            cin >> t;
            c[i][j] = t-1;
        }
    }
    for (int i=0; i<N; i++) {
        for (int j=0; j<N; j++) {
            int group = (i + j) % 3;
            for (int col=0; col<C; col++) {
                cost[group][col]+= D[c[i][j]][col];
            }
        }
    }
    long long min = -1;
    for (int i=0; i<C; i++) {
        for (int j=0; j<C; j++) {
            for (int k=0; k<C; k++) {
                if (i == j || j == k || i == k) continue;
                int _cost = cost[0][i] + cost[1][j] + cost[2][k];
                if (min == -1 || min > _cost) {
                    min = _cost;
                }
            }
        }
    }
    cout << min << endl;
    return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<int,int> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

int a[100001][3];
int n;
bool rev[100001];
int perm[100001];

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin >> n;
	for(int j = 0; j < 3; j++)
	{
		for(int i = 0; i < n; i++)
		{
			cin >> a[i][j];
		}
	}
	for(int i = 0; i < n; i++)
	{
		if(a[i][0]>a[i][1])
		{
			if(a[i][0]-a[i][1]==1&&a[i][1]-a[i][2]==1&&a[i][2]%3==1)
			{
				
			}
			else
			{
				cout<<"No\n"; return 0;
			}
			rev[i] = true;
		}
		else
		{
			if(a[i][0]-a[i][1]==-1&&a[i][1]-a[i][2]==-1&&a[i][0]%3==1)
			{
				
			}
			else
			{
				cout<<"No\n"; return 0;
			}
			rev[i] = false;
		}
		perm[i] = a[i][1]/3;
		if((perm[i]&1)^(i&1))
		{
			cout<<"No\n"; return 0;
		}	
	}
	ll invo = 0; ll inve = 0;
	int revo = 0; int reve = 0;
	for(int i = 0; i < n; i++)
	{
		if(i&1)
		{
			revo^=rev[i];
		}
		else
		{
			reve^=rev[i];
		}
	}
	pbds t;
	for(int i = 0; i < n; i+=2)
	{
		int l = t.order_of_key(perm[i]);
		inve += t.size() - l;
		t.insert(perm[i]);
		inve%=2;
	}
	t.clear();
	for(int i = 1; i < n; i+=2)
	{
		int l = t.order_of_key(perm[i]);
		invo += t.size() - l;
		t.insert(perm[i]);
		invo%=2;
	}
	if(((invo&1)^(reve))||((inve&1)^(revo)))
	{
		cout<<"No\n";
	}
	else
	{
		cout<<"Yes\n";
	}
}


Measured memory_bytes: 4224
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>

using namespace std;

namespace {
	void roll(char c, vector<int>& d)
	{
		switch (c)
		{
		case 'E': swap(d[0], d[3]); swap(d[3], d[5]); swap(d[5], d[2]); break;
		case 'S': swap(d[0], d[1]); swap(d[0], d[4]); swap(d[4], d[5]); break;
		case 'R': swap(d[1], d[2]); swap(d[1], d[4]); swap(d[1], d[3]); break;
		default: break;
		}
	}
}

int main()
{
	vector<int> d1(6), d2(6);

	for (int i = 0; i < d1.size(); ++i)
		cin >> d1[i];

	for (int i = 0; i < d2.size(); ++i)
		cin >> d2[i];

	string ans = "No";
	for (int i = 0; i < d1.size() + 1; i++)
	{
		roll(" SEEEES"[i], d1);

		if (d1[0] == d2[0] && d1[5] == d2[5])
		{
			for (int j = 0; j < d1.size() - 2; j++)
			{
				roll(" RRR"[j], d1);
				if (equal(d1.begin(), d1.end(), d2.begin()))
					ans = "Yes";
			}

			break;
		}
	}

	cout << ans << endl;

	return 0;
}

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

using namespace std;

#define INF 1000000007
#define LINF (1LL << 60)

typedef long long i64;
typedef pair<i64,i64> P;

inline i64 mod(i64 a, i64 m) { return (a % m + m) % m; }

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



int h,w, n, a[101010];
void solve(){
	cin >> h >> w;
	cin >> n;
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	
	int x = 0, y = 0;
	int ans[101][101];
	for(int i = 0; i < n; i++){
		while(a[i]--){
			ans[x][y] = i+1;
			if(x&1) y--;
			else y++;
			if(y == w){
				x++;
				y = w-1;
			}
			if(y == -1){
				x++;
				y = 0;
			}
		}
	}
	
	for(int i = 0; i < h; i++){
		for(int j = 0; j < w; j++){
			cout << ans[i][j];
			if(j != w-1) cout << " ";
		}
		cout << endl;
	}
}

int main(){
	std::cin.tie(0);
	std::ios::sync_with_stdio(false);
	int t = 1;
	//cin >> t;
	while(t--){
		solve();
	}
	
	return 0;
}


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

int main(){
  int H,W,K;
  cin >> H >> W >> K;
  vector<string> c(H);
  for(int i=0; i<H; i++){
    cin >> c[i];
  }
  
  int result=0;
  
  for(int i=0; i<(1<<(H+W)); i++){
    int black=0;
    for(int x=0; x<H; x++){
      for(int y=H; y<H+W; y++){
        if( (c[x][y-H]=='#') && ((i>>x)%2==0) && ((i>>y)%2==0) ) black++;
      }
    }
    if(black==K) result++;
  }
  cout << result << endl;
}

Measured memory_bytes: 3628
# ume 20/01/08
# 466 Byte	WA	32 ms	4720 KB
# 1:03:03.68
H, W = map(int, input().split())
N = int(input())
alist = [[a, i+1] for i, a in enumerate(map(int, input().split()))]
alist.sort()
drow_Order = []
for x in alist:
  for a in range(x[0]):
    drow_Order += [x[1]]
ans = ''
aaa = 0
for row in range(H):
  if row%2==0:
    ans = map(str, drow_Order[row*W:(row+1)*W])
  else:
    ans = map(str, reversed(drow_Order[row*W:(row+1)*W]))
  ans = ','.join(ans)
  print(ans.replace(',', ' '))

Measured memory_bytes: 4592
def main():
    N = input()

    if int(N) < 10:
        print(N)
        return

    n = list(map(int, N))
    x = sum(n)
    n[0] -= 1
    n[1:] = [9] * (len(n) - 1)
    print(max(sum(n), x))

main()


Measured memory_bytes: 3316
import sys

input = sys.stdin.readline

for e in iter(input, '0 0 0 0\n'):
    M, T, P, R = map(int, e.split())

    result = [[0, M, i] + [0] * P for i in range(T + 1)]

    for _ in range(R):
        m, t, p, j = map(int, input().split())
        team_data = result[t]
        if j:
            team_data[-p] += 1
        else:
            team_data[0] += 1
            team_data[1] -= m + 20 * team_data[-p]

    result.sort(reverse=True)
    result.pop()

    for td1, td2 in zip(result[:-1], result[1:]):
        if td1[0] == td2[0] and td1[1] == td2[1]:
            print(td1[2], end='=')
        else:
            print(td1[2], end=',')
    print(result[-1][2])


Measured memory_bytes: 5664
#include<iostream>
using namespace std;
int main(){
	char ch;
	int h,w,count=0;
	cin >> h >> w;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
				cin >> ch;
				if(ch=='#')	count++;
		}
	}
	if((h+w-1)==count)	cout << "Possible\n";
	else	cout << "Impossible\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	int ans=0,i;
	cin>>s;
	for(i=0;i<s.size();i++)
	{
		if(s[i]=='7')ans=1;
	}
	if(ans==1)cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	return 0;
}


Measured memory_bytes: 3628
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    long k = sc.nextLong();
    int[] a = new int[n];
    long mod = 1000000007;
    long sum = 0;
    long cnt1 = 0;
    long cnt2 = 0;
    for(int i = 0;i < n;i++)a[i]=sc.nextInt();
    for(int i = 0;i < n;i++){
      for(int j = i+1;j < n;j++)if(a[i]>a[j])cnt1++;
    }
    sum = (sum+cnt1*k)%mod;
    for(int i = 0;i < n;i++){
      for(int j = 0;j < n;j++)
        if(a[i]>a[j])cnt2++;
    }
    long kk = (k*(k-1)/2)%mod;
    long s = (cnt2*kk)%mod;
    sum=(sum+s)%mod;
    System.out.println(sum);
  }
}

Measured memory_bytes: 26076
import java.util.*;
import static java.lang.Integer.*;
//import static java.lang.Long.*;
//import static java.lang.Math.*;
import static java.lang.System.*;
import java.io.PrintWriter;

public class Main {
	public static void main(String[] args) {
		int i,j, k;
		Scanner sc = new Scanner(in);
		char[] s = sc.next().toCharArray();
		sc.close();
		boolean f = true;
		LABEL:{
			if(s[0]!='A') {
				f=false;
				break LABEL;
			}
			if(s[1] < 'a' || 'z' < s[1]) {
				f=false;
				break LABEL;
			}
			int c=0;
			for (i = 2; i < s.length-1; i++) {
				if(s[i]=='C') {
					c++;
					if(c>1) {
						f=false;
						break LABEL;
					}
				} else if(s[i] < 'a' || 'z' < s[i]) {
					f=false;
					break LABEL;
				}
			}
			if(c==0) {
				f=false;
				break LABEL;
			}
			if(s[i] < 'a' || 'z' < s[i]) {
				f=false;
				break LABEL;
			}
		}
		out.println(f?"AC":"WA");
	}
}


Measured memory_bytes: 21844
import sys

a, b = map(int,input().split())
num = int(a*b%2019)

for i in range(a, b + 1):
  for j in range(i + 1, b + 1):
    if(i >= j):
      continue
    num = min(num, (i*j)%2019)
    if(num == 0):
      print(0)
      sys.exit()

print(num % 2019)


Measured memory_bytes: 2940
import java.util.*;
 
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
        
        int n = sc.nextInt();
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int max1 = 0;
        int max2 = 0;

        int max_index = 0;

        for (int i = 0; i < n; i++) {
            if (max1 < a[i]) {
                max2 = max1;
                max1 = a[i];
                max_index = i;
            } else if(max2 < a[i]) {
                max2 = a[i];
            }
        }

        for (int i = 0; i < n; i++) {
            if (max_index == i) {
                System.out.println(max2);
            } else {
                System.out.println(max1);
            }
        }
	}
}


Measured memory_bytes: 109708
#include<bits/stdc++.h>
using namespace std;
#define maxn 300010
const int p=1e9+7;
template <typename T>inline T read()
{
    register T sum=0;
    register char cc=getchar();
    int sym=1;
    while(cc!='-'&&(cc>'9'||cc<'0'))cc=getchar();
    if(cc=='-')sym=-1,cc=getchar();
    sum=sum*10+cc-'0';
    cc=getchar();
    while(cc>='0'&&cc<='9')sum=sum*10+cc-'0',cc=getchar();
    return sym*sum;
}
template <typename T>inline T read(T &a)
{
    a=read<T>();
    return a;
}
template <typename T,typename... Others> inline void read(T& a, Others&... b)
{
    a=read(a);
	read(b...);
}
int n,ans,f[maxn][3][3];
char str[maxn];
void Add(int &x,int y)
{
	x+=y;
	if(x>=p)
		x-=p;
}
int main()
{
	f[0][0][0]=1;
	scanf("%s",str+1);
	n=strlen(str+1);
	for(int i=0;i<n;i++)
		for(int j:{0,1,2})
			for(int k:{0,1,2})
				if(f[i][j][k])
				{
					if(str[i+1]!='0')
					{
						if(k)
							Add(f[i+1][j][k-1],f[i][j][k]);
						else
							Add(f[i+1][min(j+1,2)][k],f[i][j][k]);
					}
					if(str[i+1]!='1')
					{
						if(k==2)
							Add(f[i+1][j][1],f[i][j][k]);
						else
							Add(f[i+1][j][k+1],f[i][j][k]);
					}
				}
	for(int i:{0,1,2})
		for(int j=0;j<=i;j++)
			Add(ans,f[n][i][j]);
	printf("%d\n",ans);
    return 0;
}


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

int main() {
    long long A, B, K;
    cin >> A >> B >> K;

    long long ARem = A - K;
    long long BRem = B;
    if(ARem < 0) {
        BRem = B - std::abs(ARem);

        ARem = std::signbit(ARem) ? 0 : ARem;
        BRem = std::signbit(BRem) ? 0 : BRem;
    }

    cout << ARem << " " << BRem << endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<sstream>
#include<vector>
#include<string>
#include<algorithm>

using namespace std;

int main(){
  int N=0;
  cin>>N;
  vector<long long> vec(N);
  vector<long long> sorted;
  for(int i=0; i<N; i++) cin>>vec[i];
  sorted = vec;
  sort(sorted.begin(),sorted.end());
  int mis=0;
  for(int i=0; i<vec.size(); i++){
    if(vec[i]!=sorted[i]){
      mis++;
    }
  }
  if(mis<=2){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <climits>
#include <queue>
#include <stack>
#define speed ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ll long long
#define eps 1e-8
#define inf INT_MAX
#define mod 1000000009
using namespace std;

inline int FastI() {
	char c = ' '; int a = 0;
	while (!isdigit(c)) c = getchar();
	while (isdigit(c)) {
		a *= 10;
		a += c - '0';
		c = getchar();
	}
	return a;
}

ll xfz(ll v) {
	if (v < 0)
		return 0;
	ll r = 1;
	if ((v + 1) % 2)
		r = v;
	if ((v / 2) % 2)
		r ^= 1;
	return r;
}

int main() {
	speed;
	ll a, b, r = 0;
	cin >> a >> b;
	if (a == 0)
		cout << xfz(b);
	else
		cout << (xfz(a - 1) ^ xfz(b));
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int maxm=2e6+5;
//
const int mod=1e9+7;
const int p=1331;
int h[maxm];
int base[maxm];
//
char s[maxm];
int n;
void init(){
    base[0]=1;
    for(int i=1;i<maxm;i++)base[i]=1ll*base[i-1]*p%mod;
    for(int i=1;i<=n;i++){
        h[i]=(1ll*h[i-1]*p+s[i])%mod;
    }
}
int get(int l,int r){
    return (h[r]-1ll*base[r-l+1]*h[l-1]%mod+mod)%mod;
}
bool check(int mid){
    map<int,int>ma;
    for(int i=n;i>=1;i--){
        if(i+mid-1>n)continue;
        int t=get(i,i+mid-1);
        if(ma.count(t)){
            int x=ma[t];
            if(x>i+mid-1)return 1;
        }else{
            ma[t]=i;
        }
    }
    return 0;
}
signed main(){
    scanf("%d",&n);
    scanf("%s",s+1);
    init();
    int ans=0;
    int l=1,r=n/2;
    while(l<=r){
        int mid=(l+r)/2;
        if(check(mid))ans=mid,l=mid+1;
        else r=mid-1;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 11708
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=2e5+5;
vector<int> adj[N];
const ll mod=1e9+7;
vector<bool> visited(N,false);
ll dp[N][2];

void dfs(int v,int p=-1)
{

    visited[v]=true;

        dp[v][0]=1;
        dp[v][1]=1;
        for(int i=0;i<adj[v].size();i++)
        {
            if(visited[adj[v][i]]==false) dfs(adj[v][i],v);
        }
        for(int i=0;i<adj[v].size();i++)
        {
            if(adj[v][i]==p) continue;
            int t=adj[v][i];
            dp[v][0]*=(dp[t][0]+dp[t][1]);
            dp[v][0]%=mod;
            dp[v][1]*=dp[t][0];
            dp[v][1]%=mod;
        }
        dp[v][0]%=mod;
        dp[v][1]%=mod;
}


int main()
{
   int n; cin>>n;
   if(n==1) {cout<<2; return 0;}
    for(int i=0;i<n-1;i++)
    {
        int x,y; cin>>x>>y;
        adj[x].push_back(y);
        adj[y].push_back(x);
    }
    dfs(1);
    cout<<(dp[1][1]+dp[1][0])%mod;
    return 0;
}


Measured memory_bytes: 17664
import sys
m=166666;s=[1]*m;t=[1]*m
for i in range(m):
 if s[i]:
  k=6*i+5
  s[i+k::k]=[0]*len(s[i+k::k])
  t[-2-i+k::k]=[0]*len(t[-2-i+k::k])
 if t[i]:
  k=6*i+7
  s[-2-i+k::k]=[0]*len(s[-2-i+k::k])
  t[i+k::k]=[0]*len(t[i+k::k])
for e in map(int,sys.stdin):
 print([e-1,sum(s[:(e+1)//6])+sum(t[:(e-1)//6])+2][e>3])


Measured memory_bytes: 9876
#include <iostream>
#include <vector>
#include <climits>
using namespace std;

void Init();
void update(int index, int value, int searchLeft, int searchRight, int left, int right);
int find(int index, int searchLeft, int searchRight, int left, int right);
void lazy_propagate(int index);

const int INF = INT_MAX;

vector<int> tree;
vector<int> lazy;

int n, q;


int main() {

	cin >> n >> q;

	Init();

	for (int i = 0; i < q; i++) {

		int com, a, b, x;
		cin >> com;

		switch (com) {
		case 0:
			cin >> a >> b >> x;
			update(0, x, 0, n, a, b + 1);
			break;

		case 1:
			cin >> a >> b;
			cout << find(0, 0, n, a, b + 1) << endl;
			break;
		}

	}

	return 0;
}

void Init() {

	int _n = 1;
	while (_n < n)
		_n *= 2;
	n = _n;
	tree = vector<int>(2 * n - 1, INF);
	lazy = vector<int>(2 * n - 1, -1);

}

void lazy_propagate(int index) {


	if (lazy[index] == -1)
		return;

	tree[index] = lazy[index];

	if (index < n - 1) {
		lazy[index * 2 + 1] = lazy[index];
		lazy[index * 2 + 2] = lazy[index];
	}
	lazy[index] = -1;

}

void update(int index, int value, int searchLeft, int searchRight, int left, int right) {

	if (right <= searchLeft || searchRight <= left) {
		lazy_propagate(index);
	}
	else if (left <= searchLeft && searchRight <= right) {
		lazy[index] = value;
		lazy_propagate(index);
	}
	else {
		lazy_propagate(index);

		int mid = (searchLeft + searchRight) / 2;
		update(index * 2 + 1, value, searchLeft, mid, left, right);
		update(index * 2 + 2, value, mid, searchRight, left, right);

		tree[index] = min(tree[index * 2 + 1], tree[index * 2 + 2]);
	}


}

int find(int index, int searchLeft, int searchRight, int left, int right) {

	if (right <= searchLeft || searchRight <= left) {
		return INF;
	}
	else if (left <= searchLeft && searchRight <= right) {
		lazy_propagate(index);
		return tree[index];
	}
	else {
		lazy_propagate(index);
		int mid = (searchLeft + searchRight) / 2;
		int lValue = find(index * 2 + 1, searchLeft, mid, left, right);
		int rValue = find(index * 2 + 2, mid, searchRight, left, right);
		return min(lValue, rValue);
	}

}





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

int main() {
  int n; cin >> n;
  int res = 0;
  for(int i=1; i<=n; ++i) {
    string s = to_string(i);
    if(s.length()%2 == 1)
      ++res;
  }
  cout << res << "\n";
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int PREP = (cin.tie(nullptr), ios::sync_with_stdio(false), cout << fixed << setprecision(12), 0);
//int SEGV = getenv("D") || (exit(system("D= SEGFAULT_SIGNALS=all catchsegv ./prog.exe") >> 8), 0);
using Int = long long;
const Int MOD = 998244353;
int main() {
    int N, K; cin >> N >> K;
    vector<int> L(K), R(K);
    for (int i = 0; i < K; i++) cin >> L[i] >> R[i];
    vector<Int> A(N + 1);
    A[1] = 1;
    for (int n = 2; n <= N; n++) {
        for (int i = 0; i < K; i++) {
            A[n] += A[max(0, n - L[i])] - A[max(0, n - R[i] - 1)] + MOD;
        }
        A[n] += A[n - 1];
        A[n] %= MOD;
    }
    cout << (A[N] - A[N-1] + MOD) % MOD << endl;
    return 0;
}


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

int ans[100000],n,k;

int main()
{
    cin>>n>>k;

    int arr[n];

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

    ans[0]=0;
    ans[1]=abs(arr[1]-arr[0]);

    for(int i=2;i<n;i++)
    {
        int minCost = INT32_MAX;

        for(int j=i-1,l=0;j>-1 && l<k;j--,l++)
            minCost = min(minCost,ans[j] + abs(arr[j]-arr[i]));

        ans[i] = minCost;
    }

    cout<<ans[n-1];
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const int INF = 1001001001;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<ll> a(n);
  ll now = 0;
  rep(i, n) {
    cin >> a[i];
    now ^= a[i];
  }
  rep(i, n) {
    ll current = now ^ a[i];
    cout << current << ' ';
  }
  cout << endl;
  return 0;
}

Measured memory_bytes: 4760
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb pushback
#define fr(i,n) for(int i=0;i<n;i++)
#define ifr(i,n) for(int i=n-1;i>=0;i--)


int main() {
    int a[3];
    string ans;
	cin >> a[0]>> a[1]>> a[2];
    sort(a,a+3);
    if(a[0]+a[1]==a[2])ans="Yes";
    else ans = "No";
      cout << ans << endl;
}


Measured memory_bytes: 256
def selection_sort(array):
    N = len(array)
    exc_time = 0
    for i in range(N):
        min_index = i
        for j in range(i, N):
            if array[min_index] > array[j]:
                min_index = j
        if min_index != i:
            array[i], array[min_index] = array[min_index], array[i]
            exc_time += 1
    return exc_time
    
def putsarray(array):
    for i in range(len(array) - 1):
        print(array[i], end=' ')
    print(array[-1])

if __name__ == "__main__":
    N = int(input())
    array = input().split()
    array = [int(n) for n in array]
    exc = selection_sort(array)
    putsarray(array)
    print(exc)


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

const int kN = 200'000 + 5;
char s[kN];
vector<int> g[kN];
bool pushed[kN];
int c[kN][2];

int main() {
    int n, m; scanf("%d%d", &n, &m);
    scanf("%s", s);
    for (int i = 0; i < m; ++i) {
        int u, v; scanf("%d%d", &u, &v);
        u--, v--;
        g[u].push_back(v);
        g[v].push_back(u);
        ++c[u][s[v] - 'A'];
        ++c[v][s[u] - 'A'];
    }
    queue<int> q;
    for (int i = 0; i < n; ++i) {
        if (c[i][0] == 0 || c[i][1] == 0) {
            pushed[i] = true;
            q.push(i);
        }
    }
    while (!q.empty()) {
        int x = q.front(); q.pop();
        for (int u : g[x]) {
            if (pushed[u]) continue;
            --c[u][s[x] - 'A'];
            if (c[u][0] == 0 || c[u][1] == 0) {
                pushed[u] = true;
                q.push(u);
            }
        }
    }
    for (int i = 0; i < n; ++i) {
        if (!pushed[i]) {
            puts("Yes");
            return 0;
        }
    }
    puts("No");
    return 0;
}


Measured memory_bytes: 12544
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define inf 1001001001001001001
#define mod 1000000007
#define mod2 998244353
#define pi acos(-1)
#define all(v) v.begin(),v.end()
int main(){
    vector<string>s(3);
    rep(i,3){
        cin>>s.at(i);
    }
    rep(i,3){
        cout<<s.at(i).at(i);
    }
    cout<<endl;
}


Measured memory_bytes: 3576
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>

using namespace std;

int main()
{
    int d;
    int n, m;
    int p;
    int s;
    set<int> shop;
    while(cin >> d && d)
    {
        s = 0;
        shop.clear();
        shop.insert(0);
        cin >> n >> m;
        for(int i=1;i<n;++i)
        {
            cin >> p;
            shop.insert(p);
        }
        for(int i=0;i<m;++i)
        {
            cin >> p;
            set<int>::iterator it=shop.upper_bound(p);
            set<int>::iterator itt=it;
            --itt;
            if(it == shop.end())
            {
                itt = shop.end();
                --itt;
                s += min( d - p, p - (*itt) );
            }
            else s += min( (*it) - p , p - (*itt) );
        }
        cout << s << endl;
    }
}

Measured memory_bytes: 5880
///...................SUBHASHIS MOLLICK...................///
///.....DEPARTMENT OF COMPUTER SCIENCE AND ENGINEERING....///
///.............ISLAMIC UNIVERSITY,BANGLADESH.............///
///....................SESSION-(14-15)....................///
#include<bits/stdc++.h>
using namespace std;
#define sf(a) scanf("%lld",&a)
#define sf2(a,b) scanf("%lld %lld",&a,&b)
#define sf3(a,b,c) scanf("%lld %lld %lld",&a,&b,&c)
#define pf(a) printf("%lld",a)
#define pf2(a,b) printf("%lld %lld",a,b)
#define pf3(a,b,c) printf("%lld %lld %lld",a,b,c)
#define nl printf("\n")
#define   timesave              ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define MPI map<int,int>mp;
#define fr(i,n) for(i=0;i<n;i++)
#define fr1(i,n) for(i=1;i<=n;i++)
#define frl(i,a,b) for(i=a;i<=b;i++)
/*primes in range 1 - n
1 - 100(1e2) -> 25 pimes
1 - 1000(1e3) -> 168 primes
1 - 10000(1e4) -> 1229 primes
1 - 100000(1e5) -> 9592 primes
1 - 1000000(1e6) -> 78498 primes
1 - 10000000(1e7) -> 664579 primes
large primes ->
104729 1299709 15485863 179424673 2147483647 32416190071 112272535095293 48112959837082048697
*/
//freopen("Input.txt","r",stdin);
//freopen("Output.txt","w",stdout);
//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
main()
{
    timesave;
    long n;
    while(cin>>n)
    {
        long i,ar[55]={0};
        for(i=1;i<=n;i++)
        {
            cin>>ar[i];
        }
        sort(ar+1,ar+n+1);
        double x=ar[1];
        for(i=2;i<=n;i++)
        {
            x=(x+ar[i])/2.0;
        }
        cout<<x<<endl;
    }
}



Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.InputStreamReader;

public class Main {

	public static void main(String[] args) {
		BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
		String buffer;

		try {
			while ((buffer = reader.readLine())  != null) {
				String[] strings = buffer.split(" ");

				int m = Integer.valueOf(strings[0]);
				int f = Integer.valueOf(strings[1]);
				int r = Integer.valueOf(strings[2]);

				if (m == -1 && f == -1 && r == -1) return;
				if (m == -1 || f == -1) {
					System.out.println("F");
				}
				else if (m + f >= 80) {
					System.out.println("A");
				}
				else if (m + f >= 65) {
					System.out.println("B");
				}
				else if (m + f >= 50) {
					System.out.println("C");
				}
				else if (m + f >= 30) {
					if (r >= 50) {
						System.out.println("C");
					}
					else {
						System.out.println("D");
					}
				}
				else {
					System.out.println("F");
				}
			}
		} catch (Exception ex) {
			ex.printStackTrace();
		}
	}
}



Measured memory_bytes: 24272
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
#define debug(x) cout << #x << ": " << x << endl
#define repn(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i, a) for(int i = 0; i < (a); i++)
#define all(v) v.begin(), v.end() 
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define endl '\n'

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	//freopen("input.in", "r", stdin);
	//freopen("output.out", "w", stdout);
	string s;
	cin >> s;
	int f = (int)stoi(s.substr(0, 2));
	int f1 = (int)stoi(s.substr(2, 2));
	int fl = 0, fl1 = 0, fl2 = 0, fl3 = 0;
	if(f < 13 && f > 0) fl = 1;
	if(f < 99 && f >= 0) fl1 = 1;
	if(f1 < 13 && f1 > 0) fl2 = 1;
	if(f1 < 99 && f1 >= 0) fl3 = 1;
	if(fl && fl1 && fl2 && fl3) cout << "AMBIGUOUS" << endl;
	else if(fl && fl3) cout << "MMYY" << endl;
	else if(fl1 && fl2) cout << "YYMM" << endl;
	else cout << "NA" << endl;
	return 0;
}
/*
Things to look out for:
	- Integer overflows
	- Array bounds
	- Special cases
Be careful!
*/


Measured memory_bytes: 256
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
#include<cstring>
#include<cmath>
#include<cstring>
#include<string>
#include<map>
#include<set>
#include<unordered_map>
#define db double
#define ui unsigned int
#define ll long long
#define ull unsiged ll
#define rep(i,l,r) for(int i=l;i<=r;i++)
#define per(i,r,l)for(int i=r;i>=l;i--)
#define boots ios::sync_with_stdio(0); cin.tie(0)
#define pb push_back
#define pp pop_back
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mod 1000000007
#define vii vector<int>
#define vll vector<ll>
#define vpp vector<pii>
#define inf  0x3f3f3f3f
#define lnf LLONG_MAX
#define mii map<int,int>
#define mll map<ll,ll>
#define mil map<int,ll>
#define umii unordered_map<char,int>
#define umll unordered_map<ll,ll>
#define umcc unordered_map<char,char>
#define si(n) scanf("%d",&n)
#define sl(n) scanf("%lld",&n)
#define pf(n) printf("%lld\n",n)
#define sz size()
using namespace std;
const db pi = 3.1415926535898;
const int MX = 5e6 + 7;
const int esp = 1e-6;
ll INV2, INV6;
ll modulo(ll num, ll MOD = mod) { return ((num%MOD) + MOD) % MOD; }
ll gcd(ll a, ll b) { return ((b == 0) ? a : gcd(b, a%b)); }
unordered_map<ui, ll>mp1, mp;
ll phi[MX];
int mu[MX];
char s[MX / 10];
vector<int> pri;
vector<bool> isp(MX, true);
int k;
ll qpow(ll a, ll b)
{
	ll ans = 1;
	while (b)
	{
		if (b & 1)
			ans = ans * a%mod;
		a = a * a%mod;
		b >>= 1;
	}
	return ans;
}
ll INV(ll n)
{
	return qpow(n, mod - 2);
}
ll get_sum(ll d)
{
	if (d == 1)return k - 1;
	return d * d%mod*(qpow(d, k )*INV(d) - 1) % mod*INV(d - 1) % mod;
}
ll get_sum2(int n)
{
	return n * (n + 1) % mod*(2 * n + 1) % mod*INV6%mod;
}
int main()
{
	boots;
	int n, m;
	cin >> n >> m;
	n--;
	m--;
	cout << m / n + (m%n>0) << endl;
	
}

Measured memory_bytes: 896
use proconio::input;

fn main() {
    input! {
        n: usize,
        q: usize,
        a: [u64; n],
    }

    let mut t = FenwickTree::from_vec(a);
    for _ in 0..q {
        input! { f: usize };
        if f == 1 {
            input! { l: usize, r: usize }
            println!("{}", t.sum(l, r));
        } else {
            input! { p: usize, x: u64 }
            t.add(p, x);
        }
    }
}

struct FenwickTree<T> {
    v: Vec<T>,
}

use std::ops::AddAssign;
use num::{Integer, zero};

impl<T: Copy + AddAssign + Integer> FenwickTree<T> {
    fn new(n: usize) -> Self {
        Self {
            v: vec![zero(); n],
        }
    }

    fn from_vec(v: Vec<T>) -> Self {
        let n = v.len();
        let mut t = Self::new(n);
        for i in 0..n {
            let v = t.v[i] + v[i];
            t.v[i] = v;
            let p = i + Self::lsb(i + 1);
            if p < n {
                t.v[p] += v;
            }
        }
        t
    }

    fn add(&mut self, mut i: usize, v: T) {
        let n = self.v.len();
        while i < n {
            self.v[i] += v;
            i += Self::lsb(i + 1);
        }
    }

    fn sum(&self, l: usize, r: usize) -> T {
        self.get(r) - self.get(l)
    }

    fn get(&self, mut i: usize) -> T {
        let mut v = zero();
        while i > 0 {
            v += self.v[i - 1];
            i -= Self::lsb(i);
        }
        v
    }

    fn lsb(i: usize) -> usize {
        i & i.wrapping_neg()
    }
}


Measured memory_bytes: 23072
#include<string>
#include<iostream>
#include <algorithm>
#include<vector>
#include<functional>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#define ll long long
using namespace std;



int main(){
  int N;
  double ANS;
  cin>>N;
  if(N%2==0) ANS=(double)(N/2)/N;
  else ANS=(double)((N+1)/2)/N;
  cout<<setprecision(9)<<ANS<<endl;

  return 0;
}



Measured memory_bytes: 256
#if 1
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <array>
#include <deque>
#include <algorithm>
#include <utility>
#include <cstdint>
#include <functional>
#include <iomanip>
#include <numeric>
#include <assert.h>
#include <bitset>
#include <list>

auto& in = std::cin;
auto& out = std::cout;
#define all(C) std::begin(C), std::end(C)
const double PI = 3.141592653589793238462643383279502884197169399375105820974944;

int32_t N, Inc,Dec;
int32_t res[600000];
auto iter = res;
int main()
{
	using std::endl;
	in.sync_with_stdio(false);
	out.sync_with_stdio(false);
	in.tie(nullptr);
	out.tie(nullptr);

	in >>N>> Inc>>Dec;

	if (N < Inc + Dec - 1 || (int64_t)(Inc)*Dec<N) {
		out << -1 << endl; return 0;
	}
	else if (Inc==1 || Dec==1) {
		if (Inc == 1) {
			if (N == Dec) {
				out << Dec;
				for (int32_t i = Dec-1; i >= 1; --i) {
					out << ' ' << i;
				}
				out << endl;
			}
			else {
				out << -1 << endl;
			}
		}
		else {
			if (N == Inc) {
				out << 1;
				for (int32_t i = 2; i <= Inc; i++)
				{
					out << ' ' << i;
				}
				out << endl;
			}
			else {
				out << -1 << endl;
			}
		}
		return 0;
	}
	else
	{
		for (int32_t i = Inc-1; i >= 0 ; --i)
		{
			*iter++ = N - i;
		}
		for (int32_t i = Dec - 2; i >= 0; --i)
		{
			*iter++ = i+1;
		}

		int32_t rem = N - (iter - res);
		if (rem > (int64_t)(Dec - 1)*(Inc - 1)) {
			out << -1 << endl; return 0;
		}

		int32_t bottom = Dec;
		while (iter < (res + N)) {
			auto iter_last = iter;
			iter += (Dec - 1);
			iter = std::min(res + N, iter);
			auto iter_next = iter;
			for (int32_t i = 0; i < Dec-1 && iter_last<iter; i++)
			{
				*--iter = i + bottom;
			}
			iter = iter_next;
			//for (int32_t i = Dec - 1 - 1; iter != (res + N) && i >= 0; --i)
			//{
			//	*iter++ = i + bottom;
			//}
			bottom += Dec - 1;
			if (bottom >= N - (Inc - 1)) { break; }
		}

		out << res[0];
		for (int32_t i = 1; i < N; i++)
		{
			out << ' ' << res[i];
		}
		out << endl;
	}

	return 0;
}
#endif


Measured memory_bytes: 3328
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

// c++11
#include <array>
#include <tuple>
#include <unordered_map>
#include <unordered_set>

#define mp make_pair
#define mt make_tuple
#define rep(i, n) for (int i = 0; i < (n); i++)

using namespace std;

using ll = long long;
using ull = unsigned long long;
using pii = pair<int, int>;
template <class T>
using max_priority_queue = priority_queue<T>;
template <class T>
using min_priority_queue = priority_queue<T, std::vector<T>, std::greater<T>>;

const int INF = 1 << 29;
const ll LL_INF = 1LL << 60;
const double EPS = 1e-9;
const ll MOD = 1000000007;

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

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N;
    cin >> N;
    vector<int> A(N);
    for (auto &val : A)
    {
        cin >> val;
    }
    reverse(A.begin(), A.end());
    multiset<int> values;
    values.insert(A[0]);
    for (int i = 1; i < N; i++)
    {
        auto p = values.upper_bound(A[i]);
        if (p != values.end())
        {
            values.erase(p);
        }
        values.insert(A[i]);
    }
    cout << values.size() << endl;

    return 0;
}


Measured memory_bytes: 5376
N = int(input())
A = list(map(int,input().split(" ")))
A.sort()
used = [0] * N
pow2_set = reversed([ 1<<i for i in range(36)])
ans = 0
for pow2 in pow2_set:
    l,r = 0,N-1
    while l < r:
        if A[l] + A[r] < pow2:
            l += 1
        elif A[l] + A[r] == pow2:
            if used[l] == 0 and used[r] == 0:
                ans += 1
                used[l],used[r] = 1,1
            else:
                if used[l] == 1:
                    l += 1
                if used[r] == 1:
                    r -= 1
        else:
            r -= 1

print(ans)

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


#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }
template <class T> void amax(T& a,T b){ a=max(a,b);}


int fv(char c){return c=='r'? 0: c=='s'? 1: 2;}

int main() {
	//cin.tie(0); ios_base::sync_with_stdio(false);
	int n,k, r,s,p;
	cin >>n >>k >>r >>s >>p;
	string t;
	cin >>t;
	ll ans =0;
	string te;
	// rsp 012//
	
	vector<string> vs(k);
	rep(i,n) vs[i%k] +=t[i];
	VI tp={r,s,p};
	rep(i, k){
		
		int m = sz(vs[i]);
		vector<VL> dp(m+1, VL(3));
		rep(j, m){
			int z = (fv(vs[i][j])+2)%3;
			amax(dp[j+1][1] ,  dp[j][0] + (z==1? tp[1]:0));
			amax(dp[j+1][2] , dp[j][0] + (z==2? tp[2]:0));
			amax(dp[j+1][0] , dp[j][1] + (z==0? tp[0]:0));
			amax(dp[j+1][2] , dp[j][1] + (z==2? tp[2]:0));
			amax(dp[j+1][0] , dp[j][2] + (z==0? tp[0]:0));
			amax(dp[j+1][1] , dp[j][2] + (z==1? tp[1]:0));
		}
			
		ll mx = *max_element(all(dp[m]));
		//dbg(i, mx);
		ans += mx;
	}
	
	
	cout << ans <<"\n";
	return 0;
}



Measured memory_bytes: 5888
#include "stdio.h"
#include "iostream"
#include "string"
using namespace std;
int main(){
  long int a,b,k,t,i;
  cin>>a>>b>>k;
  for(i=a;i<=b&&i-a<k;i++){
    cout<<i<<endl;
  }
  if(i>b-k+1){t=i;}else{t=b-k+1;}
  for(i=t;i<=b;i++){
    cout<<i<<endl;
  }
  return 0;
}

Measured memory_bytes: 256