akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <cstring>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <set>
#include <math.h>
#include <array>
#include <list>
#include <set>
const int MOD=1000000007;
const int INF=1000000000;
using namespace std;
typedef long long ll;
typedef tuple<ll,int,int> tup;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vp;
int tmpmin=1e9;
int main(int argc,char const* argv[])
{
  int n,ans=0;
  cin >> n;
  for(int i=1;i<=n;i++)
    {
      int cnt=0;
      if(i%2==0) continue;
      for(int j=1;j<=i;j++)
	{
	  if(i%j==0) cnt++;
	}
      if(cnt==8)
	{
	  ans++;
	}
    }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
A,B,C,D,E,F=map(int,input().split())

best_sugarwater = 100*A
best_sugar = 0
best_con = 0
max_con = E/(100+E)

maxA = F//(100*A)
for i in range(maxA+1):
    maxB = (F-100*A*i)//(100*B)
    for j in range(maxB+1):
        water = 100*A*i+100*B*j
        maxC = (F-100*A*i-100*B*j)//C
        for k in range(maxC+1):
            maxD = (F-100*A*i-100*B*j-C*k)//D
            for l in range (maxD+1):
                sugar = C*k+D*l
                if sugar + water == 0 :
                    pass
                elif (best_con < sugar/(sugar + water) <= max_con ):
                    best_sugarwater = sugar + water
                    best_sugar = sugar
                    best_con = sugar/(sugar + water)

print(best_sugarwater,best_sugar)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define pb push_back
#define eb emplace_back
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = LLONG_MAX/4;
const ll MOD = 1e9+7;
const int n_max = 1e5+10;

int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    bool ok = true;
    ll ret = 0;
    ll cnt = 0;
    ll x = 1;
    while(cnt < n){
        if(a[cnt] == x)x++;
        cnt++;
    }
    
    cout << (x == 1 ?  -1 : n - x + 1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

const ll mod = 1e9 + 7;

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

    ll n;
    cin >> n;
    ll res = 0;
    REP(i, n) {
        ll num = i + 1;
        if (num % 3 && num % 5) res += num;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s;
    cin>>s;
    map<char , int >m;
    map<char , int >::iterator itr; 
    for(long i=0;i<s.length();i++)m[s[i]]++; 
    for(itr=m.begin();itr!=m.end();itr++){
        if(itr->second%2!=0){
               cout<<"No";
               return 0;
           }
        }
    cout<<"Yes";
    return 0;
}



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

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

int MOD=1e9+7;
ll INF=1e18;

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

int main(){
    int n; cin>>n;
    vector<int> l(2*n);
    for(int i=0; i<2*n; i++) cin>>l[i];
    sort(l.begin(), l.end());
    int ans=0;
    for(int i=0; i<2*n; i+=2) ans+=l[i];
    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);
        String s=sc.nextLine();
        
        if(s.equals("ARC")){
            System.out.println("ABC");
        }
      
       if(s.equals("ABC")){
            System.out.println("ARC");
        }
 
    }
    
}

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

using namespace std;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vll>;

#define REP(i, n, m) for(ll i=n; i<(ll)m; ++i)
#define IREP(i, n, m) for(ll i=n-1; i>=m; --i)
#define rep(i, n) REP(i, 0, n)
#define irep(i, n) IREP(i, n, 0)
#define all(v) v.begin(), v.end()

int main(){
    ll a;
    cin >> a;
    cout << (3*a*a) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<n; i++)
#define repr(i, s, e) for(ll i=s; i>=e; i--)
#define reps(i, s, e) for(ll i=s; i<=e; i++)
#define ll long long
#define inf 1e18
#define all(v) v.begin(),v.end()
#define vsort(v) sort(v.begin(), v.end())
#define vsortr(v) sort(v.begin(), v.end(), greater<ll>())
#define sz(x) x.size()
#define ceil(a, b) (a+b-1)/b
#define ok cout << "ok" << endl;
#define sp << " " <<
using namespace std;
template<typename T> inline bool chmax(T &a, T b){ if(a<b){ a=b; return true; } return false; }
template<typename T> inline bool chmin(T &a, T b){ if(b<a){ a=b; return true; } return false; }
template<typename T> T gcd(T a, T b){ if(b==0) return a; return gcd(b, a%b); }
template<typename T> T lcm(T a, T b){ return a*(b/gcd(a, b)); }
template<typename T> void vdebug(vector<T> v){ for(auto vv : v){ cout << vv << " "; } cout << endl; }
template<typename T> void adebug(T arr[], ll n){ reps(i, 0, n){ cout << arr[i] << " "; } cout << endl; }
void ans(bool b){ if(b) cout << "Yes" << endl; else cout << "No" << endl; }
void ans2(bool b){ if(b) cout << "YES" << endl; else cout << "NO" << endl; }
ll keta(ll num){ ll k=0; while(num>0){ num/=10; k++; } return k; }
int dx[] = {1, -1, 0, 0, 1, -1, 1, -1};
int dy[] = {0, 0, 1, -1, 1, -1, -1, 1};


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

    string s;
    cin >> s;

    ll dp[200010];
    dp[0] = 0;

    rep(i, s.length()){
        if(s[i] != s[i-1]) dp[i+1] = dp[i] + 1;
        else{
            if(i-2 >= 0) dp[i+1] = dp[i-2] + 2;
            else dp[i+1] = 1;
        }
    }

    //adebug(dp, s.length());

    cout << dp[s.length()] << endl;

    return 0;
}


Measured memory_bytes: 2196
function main(data){
    input = data.split("\n");
    len = input[0];
    count = 0;
    temp = input.concat();
    index = temp[1];
    input[1] = 0;
    while(true){
        count += 1;
        if(index == 2){
            console.log(count)
            break;
        }
        index = temp[index];
        if(!input[index]){
            console.log(-1);
            break;
        }
        input[index] = 0;
    }
}

main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

// clang-format off
#define  range(i, l, r) for (int i = (int)(l); i < (int)(r); ++(i))
#define rrange(i, l, r) for (int i = (int)(r) - 1; i >= (int)(l); --(i))

#define  whole(f, x, ...) ([&](decltype((x)) container) { return (f)(  begin(container),  end(container), ## __VA_ARGS__); })(x)
#define rwhole(f, x, ...) ([&](decltype((x)) container) { return (f)( rbegin(container), rend(container), ## __VA_ARGS__); })(x)

#define endl '\n'
#define debug(x) cerr << "(" << __LINE__ << ")" << #x << ": " << (x) << endl

using i32 = int;
using u32 = unsigned int;
using i64 = long long;
using u64 = unsigned long long;

// constexpr i32 mod   = 998244353;
constexpr i32 mod   = 1e9 + 7;
constexpr i32 inf   = 1001001001;
constexpr i64 infll = 1001001001001001001ll;

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

struct IoSetup { IoSetup(int x = 15){ cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(x); cerr << fixed << setprecision(x); } } iosetup;

template <typename T = i64> T input() { T x; cin >> x; return x; }

template <typename T> ostream &operator<<(ostream &os, vector<T> &v) { range(i, 0, v.size()) { os << v[i] << (i + 1 != v.size() ? " " : ""); } return os; } 
template <typename T> istream &operator>>(istream &is, vector<T> &v) { for (T &in : v) is >> in; return is; }

template <typename T1, typename T2> ostream &operator<<(ostream &os, pair<T1, T2> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template <typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }

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

template <typename T1, typename T2> inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template <typename T1, typename T2> inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }
// clang-format on

void solver() {
    int x = input(), y = input(), z = input();
    
    cout << z << " " << x << " " << y << endl;
}

signed main(int argc, char *argv[]) {
    solver();
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,N) for(int i = 0; i < (N); i++)
#define erep(i,N) for(int i = N - 1; i >= 0; i--)
const ll INF = 1000000000;
//const ll MOD = 1000000007;
const ld PI = (acos(-1));
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true;} return false;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true;} return false;}
typedef pair<int, int> P;
typedef pair<ll,ll> PLL;
double rad(double a) {return a * 180 / PI;}

struct UnionFind {
    vector<int> par; // par[i]:iの親の番号 (例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//dpTable
int dp[100050];

int main(){
    int N;
    cin >> N;
    vector<int> a(N);
    rep (i,N) cin >> a.at(i);
    vector<bool> ans(8,false);
    int cnt = 0;
    rep (i,N) {
        if (a.at(i) <= 399 && a.at(i) >= 1) ans.at(0) = true;
        else if (a.at(i) <= 799) ans.at(1) = true;
        else if (a.at(i) <= 1199) ans.at(2) = true;
        else if (a.at(i) <= 1599) ans.at(3) = true;
        else if (a.at(i) <= 1999) ans.at(4) = true;
        else if (a.at(i) <= 2399) ans.at(5) = true;
        else if (a.at(i) <= 2799) ans.at(6) = true;
        else if (a.at(i) <= 3199) ans.at(7) = true;
        else cnt++;
    }
    int A = 0;
    for (int i = 0; i < 8; i++) {
        if (ans.at(i)) A++;
    }
    cout << (A == 0 ? 1 : A) << ' ' << A + cnt << endl;
    return 0;
}

Measured memory_bytes: 3632
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>
#include <numeric>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
map<int, int> mp;
map<int, int>mm;
#define ll long long
#define ld long double
#define PI 3.14159265358979l




int main() {
	int a, b, c;
	cin >> a >> b >> c;
	if (a*c <= b)cout << c << endl;
	else cout << b / a << endl;
}

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

#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define MIN(a) *min_element(all(a))
#define MAX(a) *max_element(all(a))
#define SUM(a) accumulate(all(a), 0LL)
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define RREP(i, n) for(int (i)=(n)-1; (i)>=0; (i)--)
#define FOR(i, m, n) for(int (i)=(m); (i)<(n); i++)
#define FORR(i, m, n) for(int (i)=(n)-1; (i)>=(m); i--)
#define debug(x) cerr << #x << " = " << x << endl
//#define int long long

typedef long long ll;
//ll const MOD = 998244353;
ll const MOD = 1e9+7;
int const inf = 1e9;
ll const INF = 1e18;

inline void ios_(){cin.tie(0); ios::sync_with_stdio(false);}
template<typename T> int size(const T& a){return (int)a.size();}
template<typename T> T Div(T a, T b){return (a + b - 1) / b;}
template<typename T> bool chmin(T& a, const T& b){if(a > b){a = b; return true;} return false;}
template<typename T> bool chmax(T& a, const T& b){if(a < b){a = b; return true;} return false;}



signed main(){
    int h, w, n;
    cin >> h >> w >> n;
    cout << Div(n, max(h, w)) << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long 
using namespace std;
#define w(x) int x; cin>>x; while(x--)
ll int n,k,mod=1e9+7;
ll int a[3001] , dp[3000][3000];
ll int recur(int i , int j)
{
	if(i==j)
		return a[i];
	if(j-i==1)
		return abs(a[i]-a[j]);
	if(dp[i][j]!=-1)
		return dp[i][j];
	ll int ans1=a[i]-a[i+1]+recur(i+2 , j);
	ll int ans2=a[i]-a[j]+recur(i+1 , j-1);
	ll int ans5=min(ans1 , ans2);
	ll int ans3=a[j]-a[i]+recur(i+1 , j-1);
	ll int ans4=a[j]-a[j-1]+recur(i , j-2);
	ll int ans6=min(ans3 , ans4);
	return dp[i][j]=max(ans5 , ans6);
}

int main()
{
	memset(dp , -1 , sizeof(dp));
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin>>n;
    for(int i=0;i<n;i++)
        cin>>a[i];
    cout<<recur(0 ,n-1 );
}

Measured memory_bytes: 74072
fun main(args: Array<String>) = println(run {
    val (n, k) = readLine()!!.split(" ").map { it.toInt() }

    (k..n+1L).map { c ->
        val max = c*(n+n-c+1)/2
        val min = c*(c-1)/2
        max-min+1
    }.reduce {a, b -> (a + b) % 1_000_000_007 }
})

Measured memory_bytes: 49256
#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 REP(i, n) for(int i = 0; i < (int)(n); i++)
static const int fast_io = [](){ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);return 0;}();
static const int precise_doubles = [](){cout<<fixed<<setprecision(20);return 0;}();
typedef pair<int, int> PII;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
// find_by_order(k) - iterator to k'th element (0-based), order_of_key(k) - #things < k
typedef long double LD;
typedef long long LL;
#define EVAL(x) x
#define NEWL EVAL({cout << '\n';})
#define SPA(x) EVAL({cout << #x" = " << x << ' ';})
#define SPAR(a, b) EVAL({cout<<#a" = ";for(auto it=a;it!=b;)cout<<*(it++)<<" ";cout<<'\n';})
#define SPAV(v) EVAL({cout<<#v" = ";for(auto it=v.begin();it!=v.end();)cout<<*(it++)<<" ";cout<<'\n';})
const int INF = 0x3f3f3f3f; // 1.0e9
const LL LINF = 0x3f3f3f3f3f3f3f3fll; // 4.5e18
const LD eps = 1e-20;
const int mod = 1e9 + 7;
inline int msum(int x, int y) {return (x+y<mod ? x+y : x+y-mod);}
inline int mdif(int x, int y) {return (x>=y ? x-y : x-y+mod);}
inline int mprod(int x, int y) { return (1ll*x*y) % mod; }
inline int mpow(int x, LL y) {LL r=1;while(y){if(y&1)r=mprod(r,x);x=mprod(x,x);y>>=1;}return r;}
inline int minv(int x) { return mpow(x, mod-2); }
//------------------------------------------------------------------------------------------------------

const int K = 1e5 + 10;

int n, k;
int seq_with_gcd[K];

int main() {
    cin >> n >> k;
    int ans = 0;
    for (int g = k; g >= 1; g--) {
        seq_with_gcd[g] = mpow(k/g, n); 
        for (int mul = g+g; mul <= k; mul += g) {
            seq_with_gcd[g] = mdif(seq_with_gcd[g], seq_with_gcd[mul]);
        }
        ans = msum(ans, mprod(g, seq_with_gcd[g]));
    }
    cout << ans << endl;
}





























Measured memory_bytes: 4028
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define INF 1987654321
#define PI 3.14159265358979323846264
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset(a,0,sizeof(a));
#define MEM_1(a) memset(a,-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
using namespace std;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
ll MOD = 1000000007;
ll POW(ll a, ll b, ll MMM = MOD) { ll ret = 1; for (; b; b >>= 1, a = (a*a) % MMM)if (b & 1)ret = (ret*a) % MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,-1,1,0 }, dy[] = { 1,0,0,-1 };
int ddx[] = { 0,0,1,1,1,-1,-1,-1 }, ddy[] = { 1,-1,1,0,-1,1,0,-1 };


int main() {
	int q;
	scanf("%d", &q);
	while (q--)
	{
		long double a, b;
		scanf("%Lf%Lf", &a, &b);
		if (a > b)swap(a, b);
		ll t = sqrtl(a*b - 1);
		if (t == 0)
		{
			puts("0");
			continue;
		}
		ll ans = 2*t;
		if (a<=t)ans--;
		if ((ll)(a*b - 1) / t == t)ans--;
		printf("%lld\n", ans);
	}
}

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

int main() {
  int K;
  cin >> K;
  int cnt = 0, now = 0;
  auto start = chrono::system_clock::now();
  while (++cnt) {
    now = (now * 10 + 7) % K;
    if (now == 0) return cout << cnt << "\n", 0;
    if (static_cast<double>(chrono::duration_cast<chrono::microseconds>(chrono::system_clock::now() - start).count() / 1000.0) > 1990) return cout << -1 << "\n", 0;
  }
}

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

int main(){
  int A,B,C;
  cin >> A >> B >> C;
  
  if (A == B && B != C) {
    cout << "Yes" << endl;
  }
  else if (B == C && C != A) {
    cout << "Yes" << endl;
  }
  else if (C == A && A != B) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
          int a,b;
          scanf("%d%d",&a,&b);
          if((a == 1 && b == 2) || (b == 1 && a == 2))
          {
                    printf("3\n");
          }
          else if((a == 1 && b == 3) || (b == 1 && a == 3))
          {
                    printf("2\n");
          }
          else
          {
                    printf("1\n");
          }
          return 0;

}


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

using namespace std;

#define pb push_back
#define fi first
#define se second
#define FastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
typedef long long ll;

int mod = 1000000007;

int dp[1000][1000];

int main(){
    int h,w;
    cin >> h >> w;
    char a[h][w];
    for(int i = 0; i < h; i++)
        for(int j = 0; j < w; j++)
            cin >> a[i][j];

    dp[0][0] = 1;
    for(int i = 0; i < h; i++){
        for(int j = 0; j < w; j++){
            if(a[i][j] == '#') continue;
            if(i != 0) dp[i][j] = (dp[i][j] + dp[i-1][j])%mod;
            if(j != 0) dp[i][j] = (dp[i][j] + dp[i][j-1])%mod;
        }
    }

    cout << dp[h-1][w-1];

    return 0;
}


Measured memory_bytes: 5120
r, c = map(int, input().split())
M, C = [list(map(int, input().split())) for i in range(r)], [0 for j in range(c)]
for i in range(r):
    for j in range(c):
        C[j] += M[i][j]
        print('%d' %(M[i][j]), end=' ')
    print(sum(M[i]))
for j in range(c):
    print('%d' %(C[j]), end=' ')
print(sum(C))

Measured memory_bytes: 8368
a, b = map(int, input().split())
if b == 1:
    print(0)
else:
    b -= a
    counter = 1
    while b > 0:
        b -= a - 1
        counter += 1

    print(counter)

# sum_tap = 1

# for i in range(100):
#     if sum_tap >= b:
#         print(i)
#         break
#     sum_tap += a - 1



Measured memory_bytes: 9144
import java.util.*;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int m = sc.nextInt();
    int x = sc.nextInt();
    int y = sc.nextInt();
    System.out.println(Math.min(n,m)*x+Math.max(0,n-m)*y);

  }
  

  
}


Measured memory_bytes: 21844
N, D = map(int, input().split())

x = [list(map(int, input().split())) for i in range(N)]

ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        else:
            tmp = 0
            for k in range(D):
                tmp += (x[i][k] - x[j][k]) ** 2
            dis = tmp ** 0.5
            if dis.is_integer():
                ans += 1
print(int(ans / 2))

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

int main(){
	int n;
	cin >> n;
	vector<string> s(n);
	for(int i=0;i<n;i++) {
		cin >> s[i];
	}
	sort(s.begin(), s.end());
	vector<pair<int,string> > count;
	int c = 1;
	int key = 0;
	for(int i=1;i<n;i++) {
		if(s[key] == s[i]) {
			c++;
		} else {
			count.push_back({c, s[key]});
			key = i;
			c = 1;
		}
	}
	count.push_back({c,s[key]});
	// 番兵
	count.push_back({0, "last"});
	sort(count.rbegin(),count.rend());
	int i = 0;
	vector<string> ans;
	while(true) {
		ans.push_back(count[i].second);
		if(count[i].first > count[i+1].first) break;
		i++;
	}
	for(int i = ans.size()-1;i>=0;i--) cout << ans[i] << endl;
}

Measured memory_bytes: 21616
import java.util.Arrays;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		String n[] = sc.nextLine().split("");

		LinkedList<String> arr = new LinkedList<>(Arrays.asList(n));

		long cnt = 1;
		String beforeStr = arr.pop();

		while(true) {
			String str = arr.pop();

			if(str.equals(beforeStr)) {
				if(0 >= arr.size()) {
					break;
				}

				beforeStr = str + arr.pop();
			}else {
				beforeStr = str;
			}

			cnt++;
			if(0 >= arr.size()) {
				break;
			}
		}

		System.out.println(cnt);
	}
}

Measured memory_bytes: 52920
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
using ll = long long;
const ll M = 1000000000000000000;

vector<pair<ll,ll>> prime_factorize(ll n){
    vector<pair<ll,ll>> res;
    for(ll a = 2; a * a <= n; a++){
        if(n % a != 0) continue;
        ll ex = 0;
        while(n % a == 0){
            ex++;
            n /= a;
        }
        res.push_back({a,ex});
    }
    if(n != 1) res.push_back({n,1});
    return res;
}

int main(){
    ll n; cin >> n;
    const auto &res = prime_factorize(n);
    ll ans = 0;
    for(auto p:res){
        ll i=1;
        while(1){
            if(i*(i+1)/2<=p.second && p.second<(i+1)*(i+2)/2){
                ans += i;
                break;
            }
            i++;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3620
#include<iostream>

int main() {
	int d;
	std::cin >> d;
	switch (d) {
	case 22:
		printf("Christmas Eve Eve Eve");
		break;
	case 23:
		printf("Christmas Eve Eve");
		break;
	case 24:
		printf("Christmas Eve");
		break;
	case 25:
		printf("Christmas");
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef double d;

ll k,a,b,sum=1;

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>k>>a>>b;
	if(b-a>=2)
	{
		if(k<=a)
			cout<<k+1;
		else
		{
			k-=a-1;
			cout<<a+(b-a)*(k/2)+(k%2==1);
		}
	}
	else
		cout<<k+1;
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

fn main() {
    input! {
        n: usize,
        l: usize,
        a: [usize; n],
    }
    let k = (1..n).max_by_key(|&i| a[i - 1] + a[i]).unwrap();
    if a[k - 1] + a[k] < l {
        println!("Impossible");
        return;
    }
    println!("Possible");
    for i in 1..k {
        println!("{}", i);
    }
    for i in (k + 1..n).rev() {
        println!("{}", i);
    }
    println!("{}", k);
}


Measured memory_bytes: 3736
#include <stdio.h>
int str_length(const char s[])
{
	int len = 0;
	while (s[len])len++;
	return len;
}
int main()
{
	char s[1001];
	int w,i,n;
	scanf("%s", s);
	scanf("%d", &w);
	n = str_length(s);
	for (i = 0;i < n;i+=w)
		printf("%c", s[i]);

	return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define   sz(s)         s.size()
#define   ll            long long int
#define   ull           unsigned ll
#define   ld            long double
#define   print(v)      for(ll i=0;i<v.size();i++)cout<<v[i]<<" "
#define   printpair(v)  for(ll i=0;i<v.size();i++)cout<<v[i].first<<" "<<v[i].second<<"\n"
#define   bmd           1000000007
#define   bmd1          998244353
#define   umll          unordered_map<ll,ll>
#define   mll           map<ll,ll>
#define   mcl           map<char,ll>
#define   pll           pair<ll,ll>
#define   F             first
#define   S             second
#define   setp(x)       setprecision(x)
#define   pb            push_back
#define   all(v)        v.begin(),v.end()
#define   tr(a)         for(auto it=a.begin();it!=a.end();it++)
#define   trr(a)        for(auto it1=a.begin();it1!=a.end();it1++)
#define   vll           vector<long long int>
#define   sorty(v)      sort(v.begin(),v.end())
#define   rsort(v)      sort(v.rbegin(),v.rend())
#define   PI            3.1415926535897932384626
#define   db()          cout<<"\n"<<"here"<<"\n"
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;


//---------------------------------------------------------------------------
const int MOD = bmd;
const int N=1e6+100;
inline  ll sqr(ll x){return x*x;}
inline  void normal(ll &a) { a = (a+MOD)%MOD; }
inline  ll modMul(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a*b)%MOD; }
inline  ll modAdd(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); return (a+b)%MOD; }
inline  ll modSub(ll a, ll b) { a %= MOD, b %= MOD; normal(a), normal(b); a -= b; normal(a); return a; }
inline  ll modPow(ll b, ll p) { ll r = 1;b=b%MOD; while(p) { if(p&1) r = modMul(r, b); b = modMul(b, b); p >>= 1; } return r; }
inline  ll modInv(ll a) { return modPow(a, MOD-2); }
inline  ll modDiv(ll a,ll b) { return modMul(a, modInv(b)); }
//---------------------------------------------------------------------------
mll mp;
void fact(ll n)
{
    for(ll i=2;i<=sqrt(n);i++){
        ll c=0;
        while(n%i==0){
            mp[i]++;
            n/=i;
        }
    }
    if(n!=1){
        mp[n]++;
    }
}
void solve()
{
    ll n;
    cin>>n;
    ll ans=0;
    fact(n);
    tr(mp)
    {
        ll y=it->second;
        ll sum=0;
        ll c=1;
        while(sum+c<=y){
            sum=sum+(c++);
            ans++;
        }
    }
    cout <<ans<<"\n";

}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);//first give all input then gives output
    ll t=1;
    //cin>>t;
    while(t--){
        solve();
    }

    return 0;
}


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

int main(void) 
{
   int n;
   cin >> n;
   int rem  = n%1000;
   if(rem == 0) cout << 0 << endl;
   else cout << 1000 - rem << endl;
}

Measured memory_bytes: 3632
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        Integer A = Integer.parseInt(sc.next());
        Integer B = Integer.parseInt(sc.next());
        Integer C = Integer.parseInt(sc.next());
        Integer D = Integer.parseInt(sc.next());

        int s1 = A*B;
        int s2 = C*D;

        if(s1>s2) System.out.println(s1);
        else System.out.println(s2);

    }
}



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

int main()
{
  cin>>N;
  vector<int> a(N);
  for(int i=0; i<N; i++)  cin>>a[i];

  int Alice = 0;
  int Bob = 0;
  int max_num;
  int tmp;
  for(int i=1; i<=N; i++){
    max_num = 0;
    tmp = 0;
    for(int j=0; j<N; j++){
      if(a[j]>max_num){  
        max_num = a[j];
        tmp = j;
      }
    }
    if(max_num == 0)  break;
    a[tmp] = 0;
    if(i%2 != 0)  Alice += max_num;
    else if(i%2 == 0)  Bob += max_num;
  }
  cout<<Alice-Bob<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <deque>
#include <map>
#include <algorithm>
#include <cmath>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include "iomanip"
#include <cstdio>
#include <cstring>
#include <set>
#include <vector>
#include <fstream>
#include <queue>
#include <cassert>
#include <stack>

using namespace std;


typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;

void print(const vi &a) {
    for (auto item : a) {
        cout << item << " ";
        flush(cout);
    }
}

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

    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 1;
    int first = 0;
    int second = 1;
    while (second < n) {
        while (second < n && s[first] == s[second]) {
            second++;
        }
        if (second < n) {
            count++;
            first = second;
            second++;
        }
    }
    cout << count;
    return 0;
}


Measured memory_bytes: 512
using System;
using System.Collections.Generic;
using System.Linq;
 
class CDistinctorNot {
    static void Main(string[] args) {
        int n = int.Parse(System.Console.ReadLine());
        int[] alist = Console.ReadLine().Trim().Split(' ').Select(a => int.Parse(a)).ToArray();
        Array.Sort(alist);
        bool rtn = true;
        int wk = 0;
        for (int i = 0; i < n; i++){
            if (wk == alist[i]) {
                rtn = false;
                break;
            }
            wk = alist[i];
        }
        if (rtn) {
            System.Console.WriteLine("YES");
        } else {
            System.Console.WriteLine("NO");
        }
    }
}

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(N+1);
  vector<int> B(N);
  for(int i = 0;i <= N;i++) cin >> A.at(i);
  for(int i = 0;i < N;i++) cin >> B.at(i);
  
  long long int ans = 0;
  for(int i = 0;i < N;i++){
    if(A.at(i) >= B.at(i)){
      ans += B.at(i);
      B.at(i) = 0;
    }else{
      ans += A.at(i);
      B.at(i) -= A.at(i);
    }
    if(A.at(i+1) >= B.at(i)){
      ans += B.at(i);
      A.at(i+1) -= B.at(i);
    }else{
      ans += A.at(i+1);
      A.at(i+1) = 0;
    }
  }
  
  cout << ans << endl;
  
  return 0;
}

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

using ll = long long;

#define pb push_back
#define ff first
#define ss second
#define all(a) a.begin(), a.end()
#define sz(a) (int)(a.size())
#define clr(a, b) memset(a, b, sizeof(a))
#define REP(i, a, b) for(int i=(int)(a); i<(int)(b); ++i)
#define REPD(i, a, b) for(int i=(int)(a)-1; i>=(int)(b); --i)

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 2e5 + 5;

int n, m, used[N];
vector<int> adj[N];

int dfs(int node) {
	if(used[node])
		return 0;
	used[node] = 1;
	int ret = 1;
	for(int x: adj[node])
		ret += dfs(x);
	return ret;
}

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> n >> m;

    REP(i, 0, m) {
    	int x, y;
    	cin >> x >> y;
    	--x, --y;
    	adj[x].pb(y);
    	adj[y].pb(x);
    }
    int res = 0;
    REP(i, 0, n) {
    	if(!used[i]) {
    		chkmax(res, dfs(i));
    	}
    }
    cout << res << "\n";
    return 0;
}


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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

const int INF = 1e9 + 9;
const int MX = 1e2 + 5;
const int MXVal = 1e5 + 5;

int N, W;
LL weight[MX];
int value[MX];
LL dp[MXVal];

int main() {

	cin >> N >> W;
	for(int i=0;i<N;i++) 
		cin >> weight[i] >> value[i];

	dp[0] = 0;
	for(int j=1;j<MXVal;j++)
		dp[j] = INF;

	for(int i=0;i<N;i++) {
		for(int j=MXVal-1;j>=0;j--) {
			if(j + value[i] < MXVal) {
				dp[j+value[i]] = min(dp[j+value[i]], dp[j] + weight[i]);
			}
		}
	}

	LL ans;
	for(int j=MXVal-1;j>=0;j--) {
		if(dp[j] <= W) {
			ans = j;
			break;
		}
	}

	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 1024
from collections import Counter
from scipy.misc import comb
N=int(input())
a=map(int, input().split())
counter=Counter(a)
ckeys=list(counter.keys())
ans=0
for i in ckeys:
    if i<counter[i]:
        ans+=min(counter[i]-i, counter[i])
    elif i>counter[i]:
        ans+=counter[i]
print(ans)


Measured memory_bytes: 33420
#include <iostream>
#include <algorithm>
#include <string.h>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>
#include <cmath>
using namespace std;
typedef long long ll;

ll N, l, r;
ll arr[200001];

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

	cin >> N;
	for (int i = 1; i <= N; ++i) {
		cin >> arr[i];
	}

	l = 1;
	ll xx = 0, sum = 0, res = 0;

	for (int i = 1; i <= N; ++i) {
		xx ^= arr[i];
		sum += arr[i];
		if (xx != sum) {
			res += (i - l + 1)*(i - l) / 2;
			while (xx != sum) {
				xx ^= arr[l];
				sum -= arr[l++];
			}
			res -= (i - l + 1)*(i - l) / 2;
		}
	}

	if (xx == sum) {
		res += (N - l + 2)*(N - l + 1) / 2;
	}

	cout << res;
}

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

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

using ll = long long;

int main(){
    int t;
    cin>>t;
    while(t--){
        int y,m,d;
        cin>>y>>m>>d;
        int cnt = 0;
        while(y!=1000 || m!=1 || d!=1){
            d++;
            cnt++;
            if(y%3==0 || m%2==1){
                if(d>20){
                    m++;
                    d=1;
                }
            }else{
                if(d>19){
                    m++;
                    d=1;
                }
            }
            if(m>10){
                m = 1;
                d = 1;
                y++;
            }
        }
        cout<<cnt<<endl;
    }
    return 0;
}


Measured memory_bytes: 3088
import sys
input= lambda: sys.stdin.readline().rstrip()
#cythonを使うために実行
#%load_ext Cython
#%%code
def resolve():
    N=int(input())
    ans=0
    for i in range(1,N*2):
        ans+=i
        if ans >= N:
            stop=i+1
            j=ans-N
            break
    for k in range(1,stop):
        if k!=j:print(k)
        
#%%submit!
resolve()


Measured memory_bytes: 3408
#include <bits/stdc++.h>
#define int long long int
using namespace std;
template<typename T,typename U> using P=pair<T,U>;
template<typename T> using V=vector<T>;
template<typename T>bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}

template<typename T>auto&operator<<(ostream&s,const vector<T>&v){s<<"[";bool a=1;for(auto e:v){s<<(a?"":" ")<<e;a=0;}s<<"]";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const pair<T,U>&p){s<<"("<<p.first<<","<<p.second<<")";return s;}
template<typename T>auto&operator<<(ostream&s,const set<T>&st){s<<"{";bool a=1;for(auto e:st){s<<(a?"":" ")<<e;a=0;}s<<"}";return s;}
template<typename T,typename U>auto&operator<<(ostream&s,const map<T,U>&m){s<<"{";bool a=1;for(auto e:m){s<<(a?"":" ")<<e.first<<":"<<e.second;a=0;}s<<"}";return s;}
#define DUMP(x) cout<<#x<<" = "<<(x)<<endl
#define COUT(x) cerr<<#x<<" = "; cout<<(x)<<endl

struct edge { int to, cost; };

const int INF = 1e18;
const int MOD = 1e9+7;

signed main()
{
   string x; cin >> x;
   int cnt = 0, sum = 0;
   for (int i = 0; i < x.size(); i++) {
      if (x[i] == 'S') {
         cnt++;
      } else {
         if (cnt > 0) {
            sum++;
            cnt--;
         }
      }
   }
   COUT(x.size() - 2*sum);

   return 0;
}

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

int main() {
  int A, B, C, D, L, R;
  cin >> A >> B >> C >> D;
  L = A+B;
  R = C+D;
  if(L == R){
    cout << "Balanced" << endl;
  }
  else if(L >= R){
    cout << "Left" << endl;
  }
  else{
    cout << "Right" << endl;
  }
}

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

int main(){
  vector<int> n(3);
  cin >> n.at(0) >> n.at(1) >> n.at(2);
  sort(n.begin(), n.end());
  cout << n.at(0)*n.at(1)/2 << endl;
  //if(n==3||n==5||n==7) cout << "YES" << endl;
  //else cout << "NO" << endl;
  return 0;
}

Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)
	ans := make([]int, n)
	var p int
	m := 1
	for i := 1; i < n; i++ {
		fmt.Scan(&p)
		if p == m {
			ans[m-1]++
		} else {
			m = p
			ans[m-1]++
		}
	}
	for i := 0; i < n; i++ {
		fmt.Println(ans[i])
	}
}


Measured memory_bytes: 6492
#include <iostream>>

using namespace std;

int main() {
  	int d, t, s;
  	cin >> d >>  t >> s;
  	
  	if (d > s * t) {
    	cout << "No" << endl;
    } else {
     	cout << "Yes" << endl; 
    }
  
 	return 0; 
}

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

#define rep(i, n) for(long long i=0;i<n;i++)
using ll = long long;
const ll INF = (1LL<<60);

int main(){

    ll n, k; cin >> n >> k;
    vector<ll> h(n);
    rep(i, n) cin >> h[i];

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

    ll sum = 0;
    rep(i, n-k){
        sum += h[i];
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <cstdio>
#include <cstring>

int n,p[1000001],f[501][501],ind[501][501],dis[501][501],q[30000001][2],h,t;
bool vis[501][501];
void add(int x,int y,int Dis){
//	printf("%d %d %d\n",x,y,Dis);
	dis[x][y]=Dis;
	++t;
	q[t][0]=x;
	q[t][1]=y;
}
void walk(int x,int y){
	if(x>1&&dis[x-1][y]>dis[x][y]+vis[x-1][y])add(x-1,y,dis[x][y]+vis[x-1][y]);
	if(y>1&&dis[x][y-1]>dis[x][y]+vis[x][y-1])add(x,y-1,dis[x][y]+vis[x][y-1]);
	if(x<n&&dis[x+1][y]>dis[x][y]+vis[x+1][y])add(x+1,y,dis[x][y]+vis[x+1][y]);
	if(y<n&&dis[x][y+1]>dis[x][y]+vis[x][y+1])add(x,y+1,dis[x][y]+vis[x][y+1]);
}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n*n;i++)scanf("%d",p+i);
	memset(dis,0x7f7f7f7f,sizeof dis);
	for(int i=1;i<=n;i++)
		for(int j=1;j<=n;j++)
			vis[i][j]=1;
	for(int i=1;i<=n;i++)
		add(1,i,1),add(n,i,1);
	for(int i=2;i<n;i++)
		add(i,1,1),add(i,n,1);
	while(h<t){
		++h;
		walk(q[h][0],q[h][1]);
	}
	long long ans=0;
	for(int i=1;i<=n*n;i++){
		int x=(p[i]-1)/n+1,y=(p[i]%n)?(p[i]%n):n;
		ans+=dis[x][y]-1;
		--dis[x][y];
		vis[x][y]=0;
		add(x,y,dis[x][y]);
		while(h<t){
			++h;
			walk(q[h][0],q[h][1]);
		}
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 171000
/* 
	Author: ankrypt
*/
#include <bits/stdc++.h>

using namespace std;

long long N, K;
long long arr[100005];
long long finalAns;

int main()
{
	scanf("%lld %lld", &N, &K);
	for(int i = 0; i < N; i++) {
		scanf("%lld", &arr[i]);
	}
	
	int left, ans;
	left = N - K;
	ans = 1;

	ans += (left / (K - 1));
	left = (left % (K - 1));

	if (left) {
		ans ++;
	}

	// while(left > 0) {
	// 	left -= (K - 1);
	// 	ans++;
	// }

	printf("%d\n", ans);
	return 0;
}
/*
	Powered by Buggy Plugin
*/


Measured memory_bytes: 1024
from collections import Counter
t=int(input())
l=[]
for i in range(t):
    l.append(input())
z=Counter(l)
print("AC x "+str(z["AC"]))
print("WA x "+str(z["WA"]))
print("TLE x "+str(z["TLE"]))
print("RE x "+str(z["RE"]))

Measured memory_bytes: 16460
def ipt(N=0,switch=0):
    if N == 0:
        return list(map(int,input().split()))
    else:
        if switch==0:
            return [list(map(int,input().split())) for _ in range(N)]
        else:
            return [int(input()) for _ in range(N)]
          
cnt = 0
a=int(input().replace(" ",""))
if int(a**0.5) == a**0.5:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
int recursin(int);
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a[6];
    int b[5]={0},c[4]={0};
    for(int i=0;i<6;i++){
        cin>>a[i];
        b[a[i]]++;

    }
    for(int i=1;i<5;i++){
        c[b[i]]++;
    }
    if(c[1]==2&& c[2]==2){
        cout << "YES"<<endl;
    }
    else{
        cout << "NO"<<endl;
    }
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <string>
#include <vector>
using namespace std;

int main()
{
    long long a;
    string b;
    cin >> a >> b;
    auto p = b.find('.');
    string bsubi = b.substr(0, p);
    string bsubp = b.substr(p + 1, b.size() - p - 1);
    long long bi = atoll(bsubi.c_str());
    long long bp = atoll(bsubp.c_str());
    long long ans = a * bi + a * bp / 100;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3628
/*{{{*/
#include <bits/stdc++.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB emplace_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(int64_t &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const int64_t &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
int main(){
    int N,K;
    R(N,K);
    set<int>AA;
    FOR(i,1,K){
        int m;
        R(m);
        REP(j,m){
            int x;
            R(x);
            AA.insert(x);
        }
    }
    W(N-SZ(AA));
    return 0;
}


Measured memory_bytes: 3772
#include <stdio.h>
int main(void){
    // Your code here!
   
     int x, y; 
     while(1){ 
         scanf("%d %d", &x, &y); 
         if(x==0 && y==0)break; 
         if(x<y){ 
             printf("%d %d\n", x, y); 
         }else{ 
             printf("%d %d\n", y, x); 
         } 
     } 

  
 
 return 0;
}



Measured memory_bytes: 1916
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define mp make_pair
#define deb(a,b,c) cout<<#a<<" = "<<(a)<<", "<<#b<<" = "<<(b)<<", "<<#c<<" = "<<(c)<<endl;
 
typedef long long int ll;
typedef string str;
 
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;     
  
    x = x % p;   
    while (y) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1;  
        x = (x*x) % p; 
    } 
    return res; 
} 
 
ll nCrModP(ll n, ll r, ll p) 
{ 
    if (!r) 
      return 1; 
  
	ll fac[n+1]; 
   	fac[0] = 1; 
    for (ll i=1 ; i<=n; i++) 
        fac[i] = fac[i-1]*i%p; 
  
    return (fac[n]* power(fac[r], p-2,p) % p * power(fac[n-r], p-2,p) % p) % p; 
}
 
ll gcd(ll a, ll b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);
}
 
void fast(){
	ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int main ()
{
	
	ll t,n,m,k,i,j,a,b;
	// cin >> t;
    str st,s;
    cin >> n >> a >> b;
    m=n/a+(n%a!=0);
    cout << m*b << "\n";
    return 0;
}

Measured memory_bytes: 3592
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <math.h>
#include <complex>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <unordered_map>
#include <set>
#include <bitset>
#include <functional>
#include <assert.h>
using ll=long long;
#define int ll
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rep(i,b) rng(i,0,b)
#define gnr(i,a,b) for(int i=int(b)-1;i>=int(a);i--)
#define per(i,b) gnr(i,0,b)
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define SZ(x) x.size()
#define fi first
#define se second
const int INF = 1e9;
using namespace std;

template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;

using pi=pair<int,int>;
using vi=vc<int>;

template<class T>
inline bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<class T>
inline bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

signed main() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout<<fixed<<setprecision(20);

    int N; cin >> N;
    map<char,int> m;
    rep(i,N){
        char c; cin >> c;
        m[c]++;
    }
    if(m.size()==3) cout << "Three" << endl;
    else cout << "Four" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

//Strange String Manipulation
public class Main{

	void run(){
		Scanner sc = new Scanner(System.in);
		for(;;){
			int n = sc.nextInt();
			if(n==0)break;
			double min = 1<<29;
			int S = 0, A = 0, C = 0;
			int[] I = new int[n];
			for(int i=0;i<n;i++)I[i]=sc.nextInt();
			for(int s=0;s<16;s++)for(int a=0;a<16;a++)for(int c=0;c<16;c++){
				int R = s;
				int[] O = new int[256];
				for(int i=0;i<n;i++){
					R = (a*R+c)%256;
					O[(I[i]+R)%256]++;
				}
				double H = 0;
				for(int i=0;i<256;i++)if(O[i]>0)H-=O[i]*1.0/n*Math.log(O[i]*1.0/n);
				if(H+1e-10<min){
					min = H; S = s; A = a; C = c;
				}
			}
			System.out.println(S+" "+A+" "+C);
		}
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 12000