akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Collections.Generic;
using System.Text;

namespace AtTest.ForBlue.ABC_067
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int n = int.Parse(Console.ReadLine());
            var nodes = new Node[n];
            for (int i = 0; i < n; i++)
            {
                nodes[i] = new Node();

            }
            for (int i = 0; i < n - 1; i++)
            {
                string[] input = Console.ReadLine().Split(' ');
                int a = int.Parse(input[0]) - 1;
                int b = int.Parse(input[1]) - 1;
                nodes[a].edgeTo.Add(b);
                nodes[b].edgeTo.Add(a);
            }

            nodes[0].blackDistance = 0;
            nodes[n - 1].whiteDistance = 0;
            //幅優先探索
            var queue = new Queue<int[]>();
            queue.Enqueue(new int[2] { 0, 1 });//index,distance
            while (queue.Count > 0)
            {
                int index = queue.Peek()[0];
                int distance = queue.Dequeue()[1];
                for (int i = 0; i < nodes[index].edgeTo.Count; i++)
                {
                    if (nodes[nodes[index].edgeTo[i]].blackDistance > -1) continue;
                    nodes[nodes[index].edgeTo[i]].blackDistance = distance;
                    queue.Enqueue(new int[2] { nodes[index].edgeTo[i], distance + 1 });
                }
            }
            queue.Enqueue(new int[2] { n - 1, 1 });
            while (queue.Count > 0)
            {
                int index = queue.Peek()[0];
                int distance = queue.Dequeue()[1];
                for (int i = 0; i < nodes[index].edgeTo.Count; i++)
                {
                    if (nodes[nodes[index].edgeTo[i]].whiteDistance > -1) continue;
                    nodes[nodes[index].edgeTo[i]].whiteDistance = distance;
                    queue.Enqueue(new int[2] { nodes[index].edgeTo[i], distance + 1 });
                }
            }

            int blackCnt = 0, whiteCnt = 0;
            for(int i = 0; i < n; i++)
            {
                if (nodes[i].blackDistance <= nodes[i].whiteDistance)
                {
                    blackCnt++;
                }
                else
                {
                    whiteCnt++;
                }
            }
            string s = blackCnt > whiteCnt ? "Fennec" : "Snuke";
            Console.WriteLine(s);
        }
    }

    class Node
    {
        public int blackDistance, whiteDistance;
        public List<int> edgeTo;
        public Node()
        {
            edgeTo = new List<int>();
            blackDistance = -1;
            whiteDistance = -1;
        }
    }
}


Measured memory_bytes: 31312
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
// #include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
// const ll RANDOM = chrono::high_resolution_clock::now().time_since_epoch().count();
// gp_hash_table<int, int> table;
 
#define ll long long int
#define vii vector< ll >
#define pb push_back
#define pii pair<ll,ll>
#define all(x) x.begin(),x.end()
#define S second
#define F first
#define ins insert
#define ld long double
#define lp(l,r) for(i=l;i<=r;++i)
 
#define lpj(l,r) for(j=l;j<=r;++j)
#define lpr(l,r) for(i=r;i>=l;--i)
#define lprj(l,r) for(j=r;j>=l;--j)
 
#define swap(a,b){ auto _t=a;a=b,b=_t;}
#define flush() cout.flush()
#define popcount __builtin_popcount
#define die() return 0;
 
 
// typedef __int128 bign;
 
 
#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 MD          1000000007
#define M 			111
#define LN 			14
#define fftmod      998244353
#define EPS         (double)1e-10
 
ll md=MD;
ll inf=1e18;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count()); 
 
 
inline ll exp(ll a,ll b){ll r=1LL;while(b>0){if(b&1){r=r*(a%md);r=(r+md)%md;}b/=2;a=(a%md)*(a%md);a=(a+md)%md;}return (r+md)%md;}
ll gcd(ll a,ll b){if(b==0)return a;if(a==0)return b;return gcd(b,a%b);}
inline ll poww(ll a,ll b){ll r=1LL;while(b>0){if(b&1)r=r*a;b/=2;a=a*a;}return (ll)r;}
 
using cd=complex<double>;
const double PI=acos(-1);
 
inline ll rand(ll l,ll r){
	return l+rng()%(r-l+1);
}
vii g[M];
int main(){
 
 
    ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
 
   // ifstream fin("input.txt");ofstream fout("outut.txt");
    ll t,i,j,m,n,s,z,k,p,T;string s1,s2;ll q;ll x,y;
    cin>>n>>k;
    ++i;
    vector<pii> v;
    if(((n-1)*(n-2))/2<k){cout<<"-1\n";die();}
    p=i;
    for(i=2;i<=n;++i){
    	v.pb({1,i});
    }
    k=((n-1)*(n-2))/2-k;
    for(i=2;i<=n;++i){

    	for(j=i+1;j<=n;++j){
    		if(k==0)break;
    		k--;
    		v.pb({i,j});
    	}
    	if(k==0)break;
    }
	cout<<v.size()<<"\n";
	for(auto x:v)cout<<x.F<<" "<<x.S<<"\n";





 
 
 
 
 
 
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#include <vector>
#include <cmath>
#define REP(i, n) for (int i = 0; i < (int)(n); ++i)
#define REP2(i, m, n) for (int i = (m); i < (int)(n); ++i)
#define REPR(i, n) for (int i = (n)-1; i >= 0; --i)
#define REPR2(i, m, n) for (int i = (n)-1; i >= (m); --i)
#define REPx(x, a) for(auto x : a)
#define ALL(a) a.begin(), a.end()
#define SORT(a) sort(ALL(a))
#define SORTR(a) sort(ALL(a), greater<int>())
#define REVERSE(a) reverse(ALL(a))
#define bit_search(bit, n) REP(bit, 1<<(n))
#define bit_check(bit, i) (bit>>(i)) & 1
#define setpre(n) fixed << setprecision((n))
#define UNIQUE(a) do {SORT(a); (a).erase(unique(ALL(a)), (a).end());} while(0)
#define MAX(a) *max_element(ALL(a))
#define MIN(a) *min_element(ALL(a))
#define bisect_left(a, x) lower_bound(ALL(a), (x)) - a.begin()
#define bisect_right(a, x) upper_bound(ALL(a), (x)) - a.begin()
#define INPUT(a) REP(i, a.size()) cin >> a[i];
#define INPUTP(a) REP(i, a.size()) cin >> a[i].first >> a[i].second;
#define ENDL cout << endl;
using namespace std;
using LL = long long;
using LD = long double;
using PII = pair<int, int>;
using VPII = vector<PII>;
using PLL = pair<LL, LL>;
using VPLL = vector<PLL>;
using VI = vector<int>;
using VVI = vector<VI>;
using VLL = vector<LL>;
using VVLL = vector<VLL>;
using VC = vector<char>;
using VS = vector<string>;
using VB = vector<bool>;
const int INF = 1e9;
const LL MOD = 1e9 + 7;

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

int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  VPII key;
  REP(i, m)
  {
    int a, b;
    cin >> a >> b;
    int s = 0;
    REP(j, b)
    {
      int c;
      cin  >> c;
      c--;
      s |= 1<<c;
    }
    key.emplace_back(s, a);
  }
  VI dp(1<<n, INF);
  dp[0] = 0;
  bit_search(s, n)
  {
    REP(i, m)
    {
      int t = s | key[i].first;
      int cost = dp[s] + key[i].second;
      chmin(dp[t], cost);
    }
  }
  int ans = dp.back();
  if (ans == INF) ans = -1;
  cout << ans <<  endl;

  return 0;
}

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

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589

using namespace std;

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

void solve_A(){
    string s;
    cin >> s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes";
    else cout << "No";
    
}

void solve_B(){
    
}

int main(void){
    solve_A();
    
    return 0;
}

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

int main() {
	string s;
	getline(cin, s);
	for (int i = 0; i < s.length(); i++) {
		if (s[i] >= 'A' && s[i] <= 'Z')
			s[i] += 32;
		else if (s[i] >= 'a' && s[i] <= 'z') 
			s[i] -= 32;
	}
	cout << s << endl;
	return 0;
}


Measured memory_bytes: 3180
#include <stdio.h>

int main(void)
{
  while(1){
    int n;
    scanf("%d", &n);
    if(n==0){
      break;
    }

    int a[5000];
    int max;

    int i,j;
    for(i=0; i<n; ++i){
      scanf("%d", &a[i]);
      int sum = 0;
      for(j=i; j>=0; --j){
        sum += a[j];
        if((i==0 && j==0) || sum>max){
          max = sum;
        }
      }
    }

    printf("%d\n", max);
  }

  return 0;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
const int inf = 1000000001;
const ll INF = 1e16;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<<fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

int main() {
	int n, a, i, j, k;
	cin >> n >> a;
	vi x(n);
	for (i = 0; i < n; i++) {
		cin >> x[i];
	}
	vector< vll > dp(n + 1, vll(n + 1, vl(2501, 0)));
	dp[0][0][0] = 1;
	for (i = 0; i < n; i++) {
		for (j = 0; j < n; j++) {
			for (k = 0; k <= 2500; k++) {
				if (dp[i][j][k] != 0) {
					dp[i + 1][j][k] += dp[i][j][k];
					dp[i + 1][j + 1][k + x[i]] += dp[i][j][k];
				}
			}
		}
	}
	ll sum = 0;
	for (j = 1; j <= n; j++) {
		sum += dp[n][j][a*j];
	}
	cout << sum << endl;
}

Measured memory_bytes: 52224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll x = n / (a + b);
    ll ans = x * a + min(n % (a + b), a);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
#include<cstdio>
#include<cstdlib>
#include<cstring>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
void mul(ll a, ll b) {
	a = a * b % INF;
}
///////////////////////////////////////

int main() {
	ll N, X; cin >> N >> X;
	ll res = N;
	ll a = max(N - X, X), b = min(N - X, X);
	while (b) {
		ll q = a / b;
		ll r = a % b;
		res += (b * 2)*q;
		if (r == 0) {
			res -= b;//最後だけ対角線のみになる
		}
		a = b, b = r;//次の平行四辺形は(b,r)
	}
	cout << res << endl;
	return 0;
}

Measured memory_bytes: 764
using System;
using System.Collections.Generic;
using System.Linq;

class Progaram
{
    static void Main(String[] args)
    {
        var a = int.Parse(Console.ReadLine());
        var b = int.Parse(Console.ReadLine());
        var h = int.Parse(Console.ReadLine());

        Console.WriteLine((a + b) * h / 2);
    }
}


Measured memory_bytes: 27388
#include <bits/stdc++.h>
#define dcout cout << fixed << setprecision(15)
#define rep(i, a) for(int i = 0; i < a; i++)
#define arep(i, x) for(auto i : x)
#define all(v) v.begin(), v.end()
#define int long long
#define F first
#define S second
#define VE vector<int>
#define pb(x) push_back(x)
using namespace std;
signed main() {
    int n;
    cin >> n;
    int k;
    cin >> k;
    int r = n;
    int d[10];
    rep(i, 10) {
        d[i] = 0;
    }
    rep(i, k) {
        int enter;
        cin >> enter;
        d[enter]++;
    }
    while(1) {
        bool flag = 0;
        string s = to_string(r);
        rep(j, (int)s.size()) {
            if(d[(s[j] - '0')] == 1) flag = 1;
        }
        if(flag == 0) break;
        r++;
    }
    cout << r;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<set>

int main(){
	int n;
	std::cin >> n;
	std::set<std::string> keihin;
	for(int i=0; i<n; i++){
		std::string s;
		std::cin >> s;
		keihin.insert(s);
	}
	std::cout << keihin.size() << std::endl;
	return 0;
}

Measured memory_bytes: 19172
#include <vector>
#include <iostream>
#include <map>
#include <string>
#include <utility>
#include <algorithm>

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

#define pb push_back

const int INF = 100100100;
const int MOD = (int)1e9 + 7;

using ll = long long;

using namespace std;

int main(){
  int r,g;
  cin >> r >> g;
  cout << 2*g-r << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<n;i++)
#define RREP(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//const ll INF = 1LL << 60;
//const int INF = 1001001001;

int main(void){
    int a,b;
    cin >> a >> b;
    cout << max(a+b,max(a-b,a*b));

    return 0;
}

Measured memory_bytes: 3584
/*
	"We know what we are, but know not what we may be."
*/

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

const int N = 2e5 + 3;
const int M = 1e6 + 7;
const long long INF = 1e18 + 9;
const int SM = 1e3 + 5;
const int logN = 20, BL = 400;
const double EPS = 3e-16;

/*
	"You never know how strong you are until being strong is the only choice you have."
*/

long long solve(long long n, long long a, long long b){
	if(n == 1){
		return a == b;
	}
	else {
		if(a > b){
			return 0;
		}
		else {
			return b * (n - 2) - a * (n - 2) + 1;
		}
	}
}

int main(){
//  freopen(".in", "r", stdin);
//  freopen(".out", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
	
/*
	"With self-discipline most anything is possible."
*/
	
	long long n, a, b; cin >> n >> a >> b;

	cout << solve(n, a, b);

	return 0;
}

/*
	"Reach for it. Push yourself as far as you can."
*/

Measured memory_bytes: 256
using System;
using System.Collections.Generic;//list用
using System.Text;//StringBuilder用
using System.Collections;//ハッシュテーブル用
using System.Linq;

class Program
{
    //Hashtable ht = new Hashtable();
    static List<int> s = new List<int>();
    static List<int>[] sl;
    static decimal result;
    static int N,K;
    //Append(str ○○)関数で文字を追加していく



    static void Main()
    {
        //Modular mo = new Modular(0);//素数で割った余りを出せで使う。()内が初期値。★使い方：Modular型で宣言すると、その時点でのその素数で割った余りを保持する変数になる（powべき乗、Fac累乗、nCr組み合わせも関数として存在）
        //Node<> no = new Node<>();//UnionFind★Find関数で根っこの値を返す（根っこの値が一緒なら同グループ）、Unite関数で二つの木をくっつける
        //Permutation<> pe = new Permutation<>();//配列＆リストを並べ替えた場合の全ケースを出力★All関数でリスト形式で返す。
        //Treap<> tr = new Treap<>();//平衡二分木★Insert()関数で挿入、FindIndex()関数で該当する大きさの物が入るべき配列番号を返す。
        //PriorityQueue<int,int> pr = new PriorityQueue<int,int>();//優先度付キュー★Add(key,value)で格納、Dequeue()で取りだし。keyが小さいものから取り出す。
Read3();
      int H=s[0];
      int W=s[1];
      int A=s[2];
      int B=s[3];
      
      //0と１を固めて、縦横で相互干渉しない形にすればよい。
      for(int j=0;j<B;j++){
            StringBuilder strresult= new StringBuilder("");
      for(int i=0;i<A;i++){
            strresult.Append("0");
      }
        for(int i=A;i<W;i++){
                    strresult.Append("1");
        }
        Console.WriteLine(strresult);
      }
            for(int j=B;j<H;j++){
            StringBuilder strresult= new StringBuilder("");
      for(int i=0;i<A;i++){
            strresult.Append("1");
      }
        for(int i=A;i<W;i++){
                    strresult.Append("0");
        }
        Console.WriteLine(strresult);
      }
    }


    static void Read1()//1項
    {
        string tmp = Console.ReadLine();
        N = int.Parse(tmp);
    }

    static void Read2()//複数項（項目数Ｎ）
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < N; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read3()//1行複数項
    {
        string[] tmp = Console.ReadLine().Split(' ');
        for (int i = 0; i < tmp.Length; i++) { s.Add(int.Parse(tmp[i])); }
    }
    static void Read4()//NK１行
    {
        string[] tmp = Console.ReadLine().Split(' ');
        N = int.Parse(tmp[0]);
        K = int.Parse(tmp[1]);
    }
    static void Read5()//N行K項
    {
        sl = new List<int>[N];
        for (int i = 0; i < N; i++) {
            sl[i] = new List<int>();
            string[] tmp = Console.ReadLine().Split(' ');
            for (int j = 0; j < K; j++) {
                sl[i].Add(int.Parse(tmp[j]));
            }
        }

    }
}


Measured memory_bytes: 16208
def gcd(a, b):
  if b == 0:
    return a
  return gcd(b,  a % b)

def lcm(a, b):
  return a * b / gcd(a, b)

while True:
  try:
    a, b = map(int, raw_input().split())
  except EOFError:
    break
  print "%d %d" % (gcd(a, b), lcm(a, b))

Measured memory_bytes: 6232
#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>;

ll kota(int m){
    ll wa=1;
    rep(i,m){
        wa*=2;
        wa=wa%1000000007;
    }
    return wa;
}

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

    vector <ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans=0;
    sort(a.begin(),a.end());
    if(n%2==1){
        rep(i,n){
            if(a[i]==((i+1)/2)*2){
                continue;
            }
            else{
                ans=-1;
                cout << 0 << endl;
                break;
            }

        }
        if(ans!=-1){
            cout << kota(n/2) << endl;
        }

    }
    else{
        rep(i,n){
            if(a[i]==(2*(i/2)+1)){
                continue;
            }
            else{
                ans=-1;
                cout << 0 << endl;
                break;
            }
        }
        if(ans!=-1){
            cout << kota(n/2) << endl;
        }
    }
    

    return 0;
}

Measured memory_bytes: 3952
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 2e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

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

    if (a > b) {
        cout << 0 << endl;
        return 0;
    }
    if (n == 1 && a != b) {
        cout << 0 << endl;
        return 0;
    }
    ll mn = a * (n - 1) + b;
    ll mx = a + b * (n - 1);
    cout << mx - mn + 1 << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using u32 = uint32_t;
using vi = vector<int>;    using vvi = vector<vi>;
using vb = vector<bool>;   using vvb = vector<vb>;
using vl = vector<ll>;     using vvl = vector<vl>;
using vd = vector<double>; using vvd = vector<vd>;

#define MAXC(c, x) (c = max(c, x))
#define MINC(c, x) (c = min(c, x))

#define REP(i,n) for(auto i = 0 * (n), i##_len = (n); i < i##_len; ++i)
#define ALL(c) (c).begin(), (c).end()
#define FOR(i,s,n) for(ll i=s, i##_len=(ll)(n); i<i##_len; ++i)
#define TEN(x) ((ll)1e##x)
const ll mod = TEN(9) + 7;

const ll INF = 1e9;

template<int64_t mod> struct GF {
	typedef int64_t T;
	T v;
	GF() = default;
	GF(T v) : v((v % mod + mod) % mod) {}
	GF & operator+=(GF x) { v = (v + x.v) % mod; return *this; }
	GF & operator*=(GF x) { v = (v * x.v) % mod; return *this; }
	GF & operator-=(GF x) { v = (v - x.v + mod) % mod; return *this; }
	GF & operator/=(GF x) { return (*this) *= x.inverse(); }
	GF operator+(GF rhs) const { GF lhs = *this; return lhs += rhs; }
	GF operator*(GF rhs) const { GF lhs = *this; return lhs *= rhs; }
	GF operator-(GF rhs) const { GF lhs = *this; return lhs -= rhs; }
	GF operator/(GF rhs) const { GF lhs = *this; return lhs /= rhs; }
	GF inverse() const { // http://topcoder.g.hatena.ne.jp/iwiwi/20130105/1357363348
		T a = v, b = mod, x = 1, y = 0;
		while (b) {
			T t = a / b;
			swap(a -= t * b, b);
			swap(x -= t * y, y);
		}
		return x;
	}
	GF pow(T n) const {
		GF r; r.v = 1;
		for (T x = v; n > 0; n >>= 1) {
			if (n & 1) (r.v *= x) %= mod;
			(x *= x) %= mod;
		}
		return r;
	}
	typedef size_t U;
	static GF fact(U n) {
		static vector<GF> data;
		U m = data.size();
		if (m <= n) {
			data.resize(n + 1);
			if (m == 0) { data[0].v = 1; m++; }
			for (U i = m; i < n + 1; ++i) data[i] = data[i - 1] * i;
		}
		return data[n];
	}
	static GF nCr(U n, U r) { return fact(n) / fact(r) / fact(n - r); }
	static GF nPr(U n, U r) { return fact(n) / fact(r); }
};

int main() {
	#ifdef INPUT_FROM_FILE
	ifstream cin("sample.in");
	ofstream cout("sample.out");
	#endif
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(50);

	ll n, m; cin >> n >> m;
	vl x(n); REP(i, n) cin >> x[i];
	vl y(m); REP(i, m) cin >> y[i];
	sort(ALL(x));
	sort(ALL(y));

	vector<GF<mod>> sx(n); sx[0] = 0;
	REP(i, n - 1) sx[i + 1] = sx[i] + (x[i + 1] - x[i]);
	vector<GF<mod>> ssx(n); ssx[0] = 0;
	REP(i, n - 1) ssx[i + 1] = ssx[i] + sx[i + 1];
	GF<mod> sssx = 0;
	REP(i, n) {
		sssx += (ssx[n - 1] - ssx[i]) - sx[i] * (n - i - 1);
	}

	vector<GF<mod>> sy(m); sy[0] = 0;
	REP(i, m - 1) sy[i + 1] = sy[i] + (y[i + 1] - y[i]);
	vector<GF<mod>> ssy(m); ssy[0] = 0;
	REP(i, m - 1) ssy[i + 1] = ssy[i] + sy[i + 1];

	GF<mod> sssy = 0;
	REP(i, m) {
		sssy += (ssy[m - 1] - ssy[i]) - sy[i] * (m - i - 1);
	}
	cout << (sssx * sssy).v << endl;

}

Measured memory_bytes: 4992
#include "bits/stdc++.h"
#define rep(i,n) for(ll i=0;i<(n);i++)
using namespace std;
using ll = long long;

int main() {
	long long n;
	cin >> n;
	vector<ll> a(n);
	vector<ll> box(100011);
	for (ll i = 0; i <= 100010; i++) {
		box[i] = 0;
	}
	ll sum = 0;
	for (ll i = 0 ; i < n; i++) {
		cin >> a[i];
		box[a[i]]++;
		sum += a[i];
	}
	ll q;
	
	cin >> q;
	for (ll i = 0; i < q; i++) {
		ll b, c;
		cin >> b >> c;
		sum = sum - b * box[b] + c * box[b];
		box[c] += box[b];
		box[b] = 0;
		cout << sum << endl;
	}
	return 0;
}


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

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

#define INF LONG_MAX
#define MOD 1000000007
#define rng(a) a.begin(),a.end()
#define rrng(a) a.end(),a.begin()

struct edge{
  ll from;
  ll to;
  ll cost;
};

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

  ll N,M;
  cin>>N>>M;
  vector<int>A(M),B(M),C(M);
  for(int i=0;i<M;i++)cin>>A[i]>>B[i]>>C[i];
  for(int i=0;i<M;i++)A[i]--,B[i]--;

  vector<edge>v(M);

  for(int i=0;i<M;i++)v[i]={A[i],B[i],-C[i]};

  vector<ll>d(N,LONG_MAX);
  d[0]=0;
  int n=0;
  bool ok=true;
  while(true){
    bool update=false;
    for(auto it:v){
      if(d[it.from]!=LONG_MAX && d[it.to]>d[it.from]+it.cost){
        d[it.to]=d[it.from]+it.cost;
        if(n>=N&&it.to==N-1)ok=false;
        update=true;
      }
    }
    if(!update)break;
    n++;
    if(n>=N+1)break;
  }
  if(ok)cout<<-d[N-1]<<endl;
  else cout<<"inf"<<endl;

  return 0;
}


Measured memory_bytes: 384
#include<cstdio>
#include<queue>
#include<functional>
#include<map>
#include<climits>
using namespace std;
struct S{int x,y,c,a;}s,t;
struct C:unary_function<S,int>{int operator()(S a,S b){return a.c>b.c;}};
int main()
{
	int h,w,m[30][30],c[4],i,j,k,x[]={1,0,-1,0},d[30][30][4];
	while(scanf("%d%d",&w,&h),h)
	{
		for(i=0;i<h;++i)for(j=0;j<w;++j)scanf("%d",&m[i][j]);
		for(i=0;i<4;++i)scanf("%d",&c[i]);
		for(i=0;i<h;++i)for(j=0;j<w;++j)for(k=0;k<4;++k)d[i][j][k]=INT_MAX;

		priority_queue<S,vector<S>,C>q;
		s.x=s.y=s.c=s.a=0;
		q.push(s);
		for(;;)
		{
			s=q.top(),q.pop();
			if(s.x<0||s.x>=w||s.y<0||s.y>=h)continue;
			if(d[s.y][s.x][s.a]<=s.c)continue;
			if(s.x==w-1&&s.y==h-1)break;
			d[s.y][s.x][s.a]=s.c;
			for(i=0;i<4;++i)
			{
				t=s;
				if(m[s.y][s.x]-i)t.c+=c[i];
				t.a=(t.a+i)%4;
				t.x+=x[t.a], t.y+=x[(t.a+3)%4];
				q.push(t);
			}
		}
		printf("%d\n",s.c);
	}
	return 0;
}

Measured memory_bytes: 1040
n, m = map(int, input().split())
ab = [list(map(int, input().split())) for _ in range(n)]
cd = [list(map(int, input().split())) for _ in range(m)]

for i in range(n):
    minNum, minCnt = 0, -1
    for j in range(m):
        abcdLen = abs(ab[i][0]-cd[j][0]) + abs(ab[i][1]-cd[j][1])
        if minCnt == -1 or minCnt > abcdLen:
            minCnt, minNum = abcdLen, j + 1
    print(minNum)


Measured memory_bytes: 3064
#include <iostream>
#include <algorithm>
#define INFTY 1e9+1

using namespace std;

typedef struct tCard_
{
    char mark;
    int num;
}tCard;

int Partition(tCard card[], int p, int r){
    int x = card[r].num;
    int i = p;
    
    for(int j = p; j < r; j++){
        if(card[j].num <= x){
        swap(card[i++], card[j]);
        }
    }
    swap(card[i], card[r]);
    return i;
}

void QuickSort(tCard card[], int p, int r){
    int q;
    if(p < r){
        q = Partition(card, p, r);
        QuickSort(card, p, q-1);
        QuickSort(card, q+1, r);
    }
}

void Marge(tCard c[], int left, int mid, int right){
    int n1 = mid - left;
    int n2 = right - mid;
    tCard L[n1], R[n2];
    int i, j, k;

    for(i = 0; i < n1; i++){
        L[i] = c[left+i];
    }
    for(i = 0; i < n2; i++){
        R[i] = c[mid+i];
    }

    L[n1].num = INFTY;
    R[n2].num = INFTY;
    i=0; j=0;

    for(k = left; k < right; k++){
        if(L[i].num <= R[j].num){
            c[k] = L[i];
            i++;
        }
        else{
            c[k] = R[j];
            j++;
        }
    }
}

void MargeSort(tCard c[], int left, int right){
    if(left + 1 < right){
        int mid = (left + right) / 2;
        MargeSort(c, left, mid);
        MargeSort(c, mid, right);
        Marge(c, left, mid, right);
    }
}

bool isStable(tCard c1[], tCard c2[], int N){
    for(int i = 0; i < N; i++){
        if(c1[i].mark != c2[i].mark){ return false; }
    }
    return true;
}

int main(){
    int n;
    tCard qc[100000], mc[100000];
    
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> qc[i].mark >> qc[i].num;
        mc[i].mark = qc[i].mark;
        mc[i].num = qc[i].num;
    }
    
    QuickSort(qc, 0, n-1);
    MargeSort(mc, 0, n);
    
    if(isStable(qc, mc, n)){ cout << "Stable" << endl; }
    else{ cout << "Not stable" << endl; }
    for(int i = 0; i < n; i++){
        cout << qc[i].mark << " " << qc[i].num << endl;
    }

    return 0;
}


Measured memory_bytes: 5444
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 998244353;
typedef long double ld;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second

ll pas[6001][6001];
ll rpas[6002][6001];
ll dp[3001][6001];
void init(int sz) {
	rep(i, 2*sz+1) {
		rep(j, 2*sz+1) {
			if (i == 0 || j == 0)pas[i][j] = 1;
			else pas[i][j] = (pas[i - 1][j] + pas[i][j - 1]) % mod;
		}
	}
	rep(j, 2*sz+1) {
		rep(i, 2*sz+1) {
			rpas[i + 1][j] = (rpas[i][j] + pas[i][j]) % mod;
		}
	}
	dp[0][0] = 1;
	rep(i, sz) {
		rep(j, 2 * i + 1) {
			rep(k, 3) {
				dp[i + 1][j + k] += dp[i][j];
				if (dp[i + 1][j + k] >= mod)dp[i + 1][j + k] %= mod;
			}
		}
	}
}
void solve() {
	int n, x; cin >> n >> x;
	init(n);
	ll ans = 0;
	rep(i, x) {
		ans += dp[n][i];
		if (ans >= mod)ans -= mod;
	}
	//cout << ans << endl;
	/*if (x % 2) {
		for (int i = (x + 1) / 2; i <= n; i++) {
			ans += pas[n - i][i];
			if (ans >= mod)ans -= mod;
		}
	}*/
	//cout << ans << endl;
	rep1(k, n) {
		ll csum = 0;
		if (x % 2 && 2 * k > x) {
			csum++;
		}
		rep1(j, n - 1) {
			if (x-k < 0)continue;
			if (2 * k - x - 2 * j < 0)continue;
			csum += rpas[x-k][2 * k - x - 2 * j];
			if (csum >= mod)csum -= mod;
		}
		csum = csum * pas[n-k][k] % mod;
		ans += csum; if (ans >= mod)ans -= mod;
	}
	cout << ans << endl;
}
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
		return 0;
}

Measured memory_bytes: 701824
#include <stdio.h>
int main(){
    int n;
    scanf("%d",&n);
    
    if(n/100 ==7){
        printf("Yes");
    }
    else if((n%100)/10 ==7){
        printf("Yes");
    }
    else if(n%10 == 7){
        printf("Yes");
    }
    else{
        printf("No");
    }
    
    
    return 0;
}

Measured memory_bytes: 1720
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;

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


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


}

Measured memory_bytes: 256
/* 
 * Project: AtCoder Beginners Contest 150 C - Count Order
 * Author: toms74209200 <https://github.com/toms74209200>
 *
 * Created on 2020/07/20
 * Copyright (c) 2020 toms74209200
 * 
 * This software is released under the MIT License.
 * http://opensource.org/licenses/mit-license.php
 */
#include <cstdio>
#include <algorithm>
#include <numeric>
#include <vector>
#include <map>
using namespace std;

int n;
vector<int> p;
vector<int> q;

void solve() {

    vector<int> first_list;
    for (int i=1;i<=n;i++) {
        first_list.push_back(i);
    }
    map<vector<int>, int> sort_list;
    do {
        sort_list[first_list] = sort_list.size();
    } while (next_permutation(first_list.begin(), first_list.end()));

    int cnt = abs(sort_list[p] - sort_list[q]);
    printf("%d\n", cnt);
    
}

int main() {

    scanf("%d", &n);
    for (int i=0;i<n;i++) {
        int tmp;
        scanf("%d", &tmp);
        p.push_back(tmp);
    }
    for (int i=0;i<n;i++) {
        int tmp;
        scanf("%d", &tmp);
        q.push_back(tmp);
    }

    solve();

}


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

int main() {

  // int型の2次元配列(3×4要素の)の宣言
  vector<vector<int>> data(3, vector<int>(3));

  // 入力 (2重ループを用いる)
  for (int i = 0; i < 3; i++) {
    for (int j = 0; j < 3; j++) {
      cin >> data.at(i).at(j);
    }
  }
  
  vector<vector<int>> kotae(3,vector<int>(3));
  int N;
  cin>>N;

  for(int k;k<N;k++){
    int H;
    cin>>H;
    for (int i = 0; i < 3; i++) {
      for (int j = 0; j < 3; j++) {

      // 上からi番目、左からj番目の画素が0かを判定
        if (data.at(i).at(j) == H) {
          kotae.at(i).at(j)=1;
        }

      }
    }
  }

  if(kotae.at(0).at(0)==1&&kotae.at(0).at(1)==1&&kotae.at(0).at(2)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(1).at(0)==1&&kotae.at(1).at(1)==1&&kotae.at(1).at(2)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(2).at(0)==1&&kotae.at(2).at(1)==1&&kotae.at(2).at(2)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(0).at(0)==1&&kotae.at(1).at(0)==1&&kotae.at(2).at(0)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(0).at(1)==1&&kotae.at(1).at(1)==1&&kotae.at(2).at(1)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(0).at(2)==1&&kotae.at(1).at(2)==1&&kotae.at(2).at(2)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(0).at(0)==1&&kotae.at(1).at(1)==1&&kotae.at(2).at(2)==1){
   cout <<"Yes"<< endl; 
  }else if(kotae.at(2).at(0)==1&&kotae.at(1).at(1)==1&&kotae.at(0).at(2)==1){
   cout <<"Yes"<< endl; 
  }else{
  cout<<"No"<<endl;
  }

}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
typedef long long ll;
using namespace std;

struct specialPair{
    int a, b;
    specialPair(int p, int q){
        a=p;
        b=q;
    }
    bool operator<(const specialPair& right) const{
        if(a!=right.a) return a<right.a;
        return b>right.b;
    }
    bool operator!=(const specialPair& right) const{
        return (a!=right.a) || (b!=right.b);
    }
};

int x[100010], y[100010];
ll mod=1000000007;
vector<specialPair> v;
vector<pair<int, int>> pr;

ll bit[100010]={};
void bitAdd(int n, ll a){
    for(int i=n; i<100010; i += i&(-i)){
        (bit[i] += a) %= mod;
    }
}
ll bitSum(int n){
    ll res=0;
    for(int i=n; i>0; i -= i&(-i)){
        (res += bit[i]) %= mod;
    }
    return res;
}


int main(void){
    int N, M;
    cin >> N >> M;
    for(int i=0; i<N; ++i) cin >> x[i];
    for(int i=0; i<M; ++i) cin >> y[i];
    int now=0;
    for(int i=0; i<N; ++i){
        while(now<M){
            if(y[now]>x[i]) break;
            ++now;
        }
        if(now>0 && now<M){
            v.emplace_back(specialPair(x[i]-y[now-1], y[now]-x[i]));
        }
    }
    if(v.empty()){
        cout << 1 << endl;
        return 0;
    }
    sort(v.begin(), v.end());
    pr.resize(v.size());
    for(int i=0; i<v.size(); ++i){
        pr[i]=make_pair(v[i].b, i);
    }
    sort(pr.begin(), pr.end());
    v[pr[0].second].b=2;
    for(int i=1; i<v.size(); ++i){
        v[pr[i].second].b=v[pr[i-1].second].b;
        if(pr[i-1].first<pr[i].first) ++v[pr[i].second].b;
    }
    bitAdd(1, 1);
    ll sumh=bitSum(v[0].b-1);
    bitAdd(v[0].b, sumh);
    for(int i=1; i<v.size(); ++i){
        if(v[i-1]!=v[i]){
            sumh=bitSum(v[i].b-1);
            bitAdd(v[i].b, sumh);
        }
    }
    cout << bitSum(100009) << endl;
    return 0;
}


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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define pb(n) push_back(n)
#define mp make_pair
#define INF LONG_LONG_MAX
#define yn(f) cout << (f ? "Yes" : "No") << endl;

string s;

signed main() {
    cin >> s;
    if (s[2] == s[3] && s[4] == s[5]) yn(true)
    else yn(false)
}

Measured memory_bytes: 256
#include<stdio.h>
int main(){
    int x,y,z;
    scanf("%d %d %d",&x,&y,&z);
    if(x<=y&&y<=z){
        printf("%d %d %d\n",x,y,z);
    }
    else if(y<=x&&x<=z){
        printf("%d %d %d\n",y,x,z);
    }
    else if(x<=z&&z<=y){
        printf("%d %d %d\n",x,z,y);
    }
    else if(z<=x&&x<=y){
        printf("%d %d %d\n",z,x,y);
    }
    else if(z<=y&&x<=x){
        printf("%d %d %d\n",z,y,x);
    }
    else if(y<=z&&z<=x){
        printf("%d %d %d\n",y,z,x);
    }
    return 0;
}

Measured memory_bytes: 596
# _*_ coding:utf-8 _*_
#  Atcoder_Beginners_Contest121-A
#  TODO https://atcoder.jp/contests/abc121/tasks/abc121_a

def whiteCells(AllHeight,selectHeight,AllWidth,selectWidth):
	answer = (AllHeight-selectHeight)*(AllWidth-selectWidth)
	return answer


if __name__ == '__main__':
	H,W = map(int,input().strip().split(' '))
	hl,wl = map(int,input().strip().split(' '))
	solution = whiteCells(H,hl,W,wl)
	print("{}".format(solution))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
int main()
{
	ios_base::sync_with_stdio(0);
    cin.tie(NULL);
    cout.tie(NULL);
    #ifndef ONLINE_JUDGE
        freopen("input.txt" , "r" , stdin) ;
        freopen("output.txt" , "w" , stdout) ;
    #endif
    int n,i;
    cin>>n;
    i=n%10;
    if(i==2||i==4||i==5||i==7||i==9)
        cout<<"hon";
    else if(i==0||i==1||i==6||i==8)
        cout<<"pon";
    else if(i==3)
        cout<<"bon";
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

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

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

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

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

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


template <typename T>
T amarinasi(T a,T b){
    if(a%b==0)
{
    return a/b;
}
else if(a%b>0)
{
    return a/b+1;
}
else
{
    return a/b-1;
}
}


//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------

int main(){
ll n,k;
cin>>n>>k;
cout<<amarinasi(n-1,k-1)<<endl;

}








Measured memory_bytes: 256
n, m, l = map(int, input().split())
A = [list(map(int, input().split())) for i in range(n)]
B = [list(map(int, input().split())) for i in range(m)]

for i in range(n) :
    for j in range(l) :
        ans = 0
        for k in range(m) :
            ans += A[i][k] * B[k][j]
        if j == l-1 :
            print(ans)
        else :
            print(ans, end=" ")



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

const int MOD = 998244353;
unordered_map < string , int > ans;

int solve(string s){
	if(ans.find(s) != ans.end()) return ans[s];
	if(s.size() == 0) return 1;
	if(s.size() == 1) return 1 + (s[0] == '1');
	int sum = solve(string(s , 1 , s.size()));
	if(s[0] == '1') sum <<= 1;
	for(int i = 1 ; i <= s.size() ; ++i){
		string str(s , 0 , i);
		for(int k = i ; k + i <= s.size() ; k += i){
			for(int l = 0 ; l < i ; ++l)
				str[l] = '0' | (str[l] & s[k + l] & 1);
			sum = (sum + 1ll * solve(str) * solve(string(s , k + i , s.size()))) % MOD;
		}
	}
	return ans[s] = sum;
}

int main(){string s; cin >> s; cout << solve(s); return 0;}

Measured memory_bytes: 5388
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 100010
#define MOD 998244353
#define NIN -100000000
#define EPS 0.0000000001
int main()
{
    int H1,H2,M1,M2,K;
    scanf("%d %d %d %d %d",&H1,&M1,&H2,&M2,&K);
    int up=H1*60+M1,down=H2*60+M2;
    int ans=down-up-K;
    printf("%d",ans);
    return 0;
}


Measured memory_bytes: 3816
#include<stdio.h>
#include<math.h>

int main(){
  float h, w, n;
  scanf("%f %f %f", &h, &w, &n);
    
  if(h < w){
    printf("%d\n", (int)ceil(n / w));
  }
  else{
    printf("%d\n", (int)ceil(n / h));    
  }
    
  return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(sc.hasNextInt()){
			for(int i=0; i<2; i++){
				int a=sc.nextInt();
				int b=sc.nextInt();
				if(a==0){
					break;
				}
				square(a,b);
				System.out.println();
			}
		}











	}
	public static void square(int a,int b){
		for(int i=0; i<a; i++){
			for(int j=0; j<b; j++){
				System.out.print("#");
			}
			System.out.println();
		}
	}



}


Measured memory_bytes: 37372
#include<stdio.h>

int main() {
    int n,m,t[100],p[100],x[100],j,k,sum=0;
    scanf("%d",&n);
    for (int i = 0;i<n;i++){
        scanf("%d",&j);
        t[i] = j;
    }
    scanf("%d",&m);
    for (int i = 0;i<m;i++){
        scanf("%d%d",&j,&k);
        sum+=k;
        for(int x= 0;x<n;x++){
            if(x==j-1) continue;
            sum+=t[x];
        }
        printf("%d\n",sum);
        sum=0;
    }
    return 0;
}

Measured memory_bytes: 1708
import sys
def input(): return sys.stdin.readline().strip()

def func(S, char):
    l = len(char)
    if int(S[0]) in char:
        num = 0
        for c in char:
            if int(c) < int(S[0]): num += 1
        if len(S) == 1: return num + 1
        return num * l ** (len(S) - 1) + func(S[1:], char)
    else:
        num = 0
        for c in char:
            if int(c) < int(S[0]): num += 1
        return num * l ** (len(S) - 1)

def main():
    S = input()
    ans = func(S, [3, 5, 7]) - func(S, [3, 5]) - func(S, [5, 7]) - func(S, [3, 7]) + func(S, [3]) + func(S, [5]) + func(S, [7])
    for i in range(1, len(S)):
        n = len(S) - i
        ans += 3 ** n - 3 * 2 ** n + 3
    print(ans)


if __name__ == "__main__":
    main()


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

#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define sz(x) (int)x.size()
#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i, k , n) for(int i = k; i <= n; i++)
typedef long long ll;

const char nl = '\n' ;
const ll MOD = 1e9 + 7;


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

   int a, b, k; cin >> a >> b >> k;
   if(b-a +1 <= 2*k)
   {
      REP(i, a, b)
         cout << i << nl;
      return 0;
   }
   REP(i,a, a+k-1)
      cout << i << nl;
   for(int i = b-k+1; i <= b; i++)
      cout << i << nl;


   return 0;
}


Measured memory_bytes: 3660
#include <iostream>
#include <algorithm>
#include <vector>
using namespace std;
#define reps(i,s,n) for(int (i) = (s); (i) < (n); ++(i))
#define rep(i,n) reps(i,0,n)
using ll = long long;
     
int main(){
	int n;
	int score;
	int num=0;
	cin >> n;
	vector<int> c(9,0);//色

	rep(i,n){
		cin >> score;
		num = score/400;
		if(score >= 3200) num = 8;
		c[num]++;
	}
	int min = 0,max = 0;
	rep(i,8){//0-7
		if(c[i]>0){
			min++;
			max++;		
		}	
//cout<< i << endl;
	}
	if(c[8] >0){//自由に選べる
		if(min>=1 && min <= 8){}//色が1色いじょう、8色以下　→　そこの色にする
		else if(min==0)min = 1;//色が0色の時は１色に固める
		
		max += c[8];
//		if(max + c[8] >= 8) max = 8;
//		else max += c[8];
		
	} 
	//cout << "c[8]:" <<c[8] << endl;
	cout << min <<" "  << max << endl;
     
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  int sum=0;
  rep(i,10){
    int n;
    cin>>n;
    sum+=n;
  }
  cout<<sum<<endl;
}

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

#define X first
#define Y second
#define LL long long
#define ULL unsigned long long
#define PB push_back
#define MP make_pair
#define PII pair<int,int>
#define IOS ios::sync_with_stdio(0);cin.tie(0);
#define IN freopen("in", "r", stdin);
#define OUT freopen("out", "w", stdout);

struct number
{
	int val,st;
	bool operator <(const number &b)const 
	{
		return val<b.val;
	}
}a[100010];

int main()
{
	int n;
	scanf("%d",&n);
	int ans=0;
	for (int j=1;j<=n;++j)
	{
		scanf("%d",&a[j].val);
		a[j].st=j;
	}
	sort(a+1,a+n+1);
	for (int j=1;j<=n;++j)
	{
		if (a[j].st%2!=j%2) ++ans;
	}
	ans/=2;
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll> vll;
typedef pair<ll,ll> pll;

int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int s, w;
	cin >> s >> w;
	if(w >= s) cout << "unsafe\n";
	else cout << "safe\n";
}


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

const int maxn = 1e5+5;
int n, a[maxn];
const int M = 1e9+7;
int mult(int a, int b) {
    return (1LL*a*b) % M;
}
int modexp(int a, int b) {
    int res = 1;
    while (b > 0) {
        if (b & 1) res = mult(res,a);
        a = mult(a,a);
        b >>= 1;
    }
    return res;
}
void msub(int& a, int b) {
    a = (a-b+M) % M;
}
int fac[maxn], ifac[maxn];

int comb(int a, int b) {
    if (a < b) return 0;
    int res = fac[a];
    res = mult(res,ifac[b]);
    res = mult(res,ifac[a-b]);
    return res;
}

int ans[maxn];
bool seen[maxn];
int dupe = -1;

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin >> n;
    for (int i = 0; i < n+1; i++) {
        cin >> a[i];
        if (seen[a[i]]) {
            dupe = a[i];
        }
        seen[a[i]] = true;
    }
    fac[0] = 1;
    ifac[0] = 1;
    for (int i = 1; i <= n+1; i++) {
        fac[i] = mult(i,fac[i-1]);
        ifac[i] = modexp(fac[i],M-2);
    }
    for (int i = 1; i <= n+1; i++) {
        ans[i] = comb(n+1,i);
        //cout << i << ": " << ans[i] << '\n';
    }
    int l = 0, r = n;
    while (a[l] != dupe) l++;
    while (a[r] != dupe) r--;
    int num = (n+1) - (r-l+1);
    //cout << "l = " << left << ", r = " << right << '\n';
    for (int i = 1; i <= n+1; i++) {
        msub(ans[i],comb(num,i-1));
    }

    //output
    for (int i = 1; i <= n+1; i++) {
        cout << ans[i] << '\n';
    }
}



Measured memory_bytes: 2944