akhauriyash/Code-Regression huggingface dataset:
# include <iostream>
# include <algorithm>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <tuple>
# include <unordered_map>
# include <numeric>
# include <complex>
# include <bitset>
# include <random>
# include <chrono>
# include <cstdlib>
# include <tuple>
# include <array>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
using D = double;
constexpr int INF = 2147483647;
constexpr int HINF = INF / 2;
constexpr double DINF = 100000000000000000.0;
constexpr double HDINF = 50000000000000000.0;
constexpr long long LINF = 9223372036854775807;
constexpr long long HLINF = 4500000000000000000;
const double PI = acos(-1);
template <typename T_char>T_char TL(T_char cX) { return tolower(cX); };
template <typename T_char>T_char TU(T_char cX) { return toupper(cX); };
typedef pair<LL, LL> pii;
const int vy[] = { -1, -1, -1, 0, 1, 1, 1, 0 }, vx[] = { -1, 0, 1, 1, 1, 0, -1, -1 };
const int dx[4] = { 0,1,0,-1 }, dy[4] = { 1,0,-1,0 };
int popcnt(unsigned long long n) { int cnt = 0; for (int i = 0; i < 64; i++)if ((n >> i) & 1)cnt++; return cnt; }
LL gcd(LL a, LL b) { if (b == 0)return a; return gcd(b, a%b); };
LL lcm(LL a, LL b) { LL g = gcd(a, b); return a / g*b; };
# define ALL(qpqpq)           (qpqpq).begin(),(qpqpq).end()
# define RALL(qpqpq)           (qpqpq).rbegin(),(qpqpq).rend()
# define UNIQUE(wpwpw)        sort(ALL((wpwpw)));(wpwpw).erase(unique(ALL((wpwpw))),(wpwpw).end())
# define LOWER(epepe)         transform(ALL((epepe)),(epepe).begin(),TL<char>)
# define UPPER(rprpr)         transform(ALL((rprpr)),(rprpr).begin(),TU<char>)
# define FOR(i,tptpt,ypypy)   for(LL i=(tptpt);i<(ypypy);i++)
# define RFOR(i,tptpt,ypypy)  for(LL i=(tptpt);i>=(ypypy);i--)
# define REP(i,upupu)         FOR(i,0,upupu)
# define INIT                 std::ios::sync_with_stdio(false);std::cin.tie(0)

int a, b, c, d;

int main() {
	cin >> a >> b >> c >> d;
	cout << (abs(a - c) <= d || (abs(a - d) <= d&&abs(b - c) <= d) ? "Yes" : "No") << endl;
}

Measured memory_bytes: 384
import fractions

A,B,C,D = list(map(int,input().split()))

G = C*D // fractions.gcd(C,D)

b = B // C + B // D - B // G
am = (A-1) // C + (A-1) // D - (A-1) // G

result = B-A+1-(b-am)
print(result)



Measured memory_bytes: 5048
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int min = 1000;
        int max = 0;
        for (int i = 0 ; i < N ; i++ ) {
            int a = sc.nextInt();
            min = Math.min(min, a);
            max = Math.max(max, a);
        }
        System.out.println(max - min);
    }

}

Measured memory_bytes: 22612
#include<bits/stdc++.h> 
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
#define ifor(n) for(int i=0;i<n;i++) 
#define jfor(n) for(int j=0;j<n;j++)
#define Ifor(n) for(int i=1;i<n;i++) 
#define Jfor(n) for(int j=1;j<n;j++)
const int inf=0x3f3f3f3f;

int main(){
	int a[40]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
	int n;
	cin>>n;
	cout<<a[n-1]<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

int Parent(int );
int Left(int );
int Right(int );

void maxHeapify(int * ,int );
void buildMaxHeap(int *);

int H; //heap-size = n
int main() {
  int n;
  int i;
  int j;
  int *array;

  scanf("%d",&n);
  H = n;
  array = (int *)malloc(n * sizeof(int));
  for(i=0;i<n;i++) scanf(" %d",&array[i]);

  buildMaxHeap(array);

  for(i=0;i<n;i++) printf(" %d",array[i]);
  printf("\n");
  return 0;
}

int Parent(int i) {
  return i/2;
}

int Left(int i) {
  return 2*i;
}

int Right(int i) {
  return 2*i + 1;
}

void maxHeapify(int *A,int i) {  //i->+1
  int l,r;
  int largest;
  int tmp;
  l = Left(i); //l->+1
  r = Right(i); //r->+1
  // 左の子、自分、右の子で値が最大のノードを選ぶ
  if(l > H && r > H) largest = i;
  else {
    if(l <= H && A[l-1] > A[i-1]) largest = l;  //largest->+1
    else largest = i; //largest->+1
    if(r <= H)
      if(r <= H && A[r-1] > A[largest-1]) largest = r; //largest->+1
  }

  //printf("checklargest %d:%d\n",largest,A[largest-1]);

  //printf("%d : i->%d, left->%d, right->%d\n",i,A[i-1],A[l-1],A[r-1]);
  if(largest != i) {
    tmp = A[i-1];
    A[i-1] = A[largest-1];
    A[largest-1] = tmp;

    maxHeapify(A, largest); //
  }
  
}

void buildMaxHeap(int *A) {
  for(int i=H/2;i>0;i--) maxHeapify(A,i);
}



Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define int long long

using namespace std;
using LL = long long;

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

#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()

const int INF = (int)1e9;
const LL INFL = (LL)1e19;
const int MOD = (int)1e9 + 7;

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

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

    vector<pair<int, int>> c;
    REP(i, n){
        c.pb(make_pair(a[i], b[i]));
    }

    sort(all(c), [](pair<int, int> a, pair<int, int> b) {
        int af = a.first, as = a.second, bf = b.first, bs = b.second;
        /*
        if(af + as == bf + bs){
            return min(af, as) > min(bf, bs);
        }else{
            return max(af, as) > max(bf, bs);
        }
        */
        return af + as > bf + bs;
    });
    LL ans = 0;
    REP(i, n){
        if(i % 2 == 0){
            ans += c[i].first;
        }else{
            ans -= c[i].second;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 3956
function Main(input){
  input = input.split("\n");
  inputStr = input[0].split(" ");
  var H = Number.parseInt(inputStr[0]);
  var W = Number.parseInt(inputStr[1]);
  inputStr = input[1].split(" ");
  var h = Number.parseInt(inputStr[0]);
  var w = Number.parseInt(inputStr[1]);
  
  //計算する
  console.log((H*W)-(h*W)-(H*w)+(h*w));
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<deque>
#include<stack>
#include<cmath>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define All(v) (v).begin(),(v).end()
using ll = long long;
const ll mod = 1000000007;
const ll INF = 100000000000000000LL;
int main(){
    int n,l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(All(s));
    rep(i, n) cout << s[i];
    cout << endl;
}

Measured memory_bytes: 256
int main()
{
  long n;
  scanf("%ld", &n);
  long i, j;
  long plus = n + 1;
  for (i = 1; i * i <= n; i++)
  {
    if (n % i == 0)
    {
      j = n / i;
      if (i + j - 2 < plus)
        plus = i + j - 2;
    }
  }
  printf("%ld", plus);
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
 
int main() {
    int a,b;
    cin >> a >>b;
    int x,y;
    
    x=(a+b)%2;
    y=(a+b)/2;
    if(x==0){
        cout << y << endl;
    }
    else{
        cout << 1+y << endl;
    }
}

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

using namespace std;

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

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

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

int h, w, ax, ay, bx, by, t, flag;
char field[30][30];
char pattern[20];

int main() {

	while(true) {

		scanf("%d%d", &h, &w);

		if (h == 0 && w == 0) break;

		REP(y,h) {
			scanf("%s", field[y]);
			REP(x,w) {
				if (field[y][x] == 'A') {
					ax = x;
					ay = y;
				} else if (field[y][x] == 'B') {
					bx = x;
					by = y;
				}
			}
		}

		scanf("%s", pattern);

		int leng = strlen(pattern);

		t = 0, flag = 0;

		queue<pii> q, nq;
		q.push(pii(ax,ay));

		REP(i,200) {
			t++;

			// girl
			while(!q.empty()) {
				pii p = q.front();
				q.pop();
				REP(j,4) {
					int nx = p.first + dx[j];
					int ny = p.second + dy[j];
					if (0<=nx&&nx<w && 0<=ny&&ny<h && field[ny][nx]!='#' && field[ny][nx]!='A') {
						field[ny][nx] = 'A';
						nq.push(pii(nx,ny));
					}
				}
			}
			while(!nq.empty()) {
				q.push(nq.front());
				nq.pop();
			}

			// ghost
			switch(pattern[i%leng]) {
				case '5':
				break;
				case '8':
				by--;
				if(by<0)by=0;
				break;
				case '6':
				bx++;
				if(bx>=w)bx=w-1;
				break;
				case '4':
				bx--;
				if(bx<0)bx=0;
				break;
				case '2':
				by++;
				if(by>=h)by=h-1;
				break;	
			}

			if (field[by][bx] == 'A') {
				flag = 1;
				break;
			}
		}

		if (flag == 0) {
			printf("impossible\n");
		} else {
			printf("%d %d %d\n", t, by, bx);
		}

	}

	return 0;

}

Measured memory_bytes: 1204
#include<iostream>
using namespace std;
int main()
{
	string s;cin>>s;
	int l=s.size();
	for (int i=0;i<=l-1;i++)
	{
		if (s[i]=='C')
		{
			bool bb=false;
			for (int j=i+1;j<=l-1;j++) if (s[j]=='F') bb=true;
			if (bb) cout<<"Yes";
			else cout<<"No";
			return 0;
		}
	}
	cout<<"No";
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
int main()
{
    string s,t;
    cin>>s>>t;
    int a = s.length();
    int b= t.length();
    int dp[a+1][b+1];
    for(int i=0;i<=a;i++){

        dp[i][0]=0;
    }
      for(int i=0;i<=b;i++){

        dp[0][i]=0;
    }

    for(int i=1;i<=a;i++){
        for(int j=1;j<=b;j++){
            if(s[i-1]==t[j-1]){
                dp[i][j]=dp[i-1][j-1]+1;
            }
            else{
                dp[i][j]=max(dp[i-1][j],dp[i][j-1]);

            }
        }
    }
    vector<char> ans;
   int counter= dp[a][b];
  int x=a,y=b;
   int index =0 ;
   while(counter!=0){
    if(dp[x][y]>dp[x-1][y]&&

              dp[x][y]>dp[x][y-1])
    {
        counter--;
        ans.push_back(s[x-1]);
        index++;
       x=x-1;y=y-1;

    }

    else{
          if(dp[x-1][y]>dp[x][y-1]){
            x=x-1;

          }
          else{

            y=y-1;
          }

    }

   }
   for(int i=ans.size()-1;i>=0;i--){
    cout<<ans[i];
   }
    return 0;
}


Measured memory_bytes: 35456
using System;
using System.Linq;
using System.Text;
using System.Collections;
using System.Collections.Generic;

namespace AtCoder
{
	class Program
	{
		static void Main(string[] args)
		{
			var x = ReadLineInt();
			int fh = x / 500;
			x -= fh * 500;
			int f = x / 5;
			Console.WriteLine((fh * 1000) + (f * 5));
		}
		public static int nCm(int n, int m)
		{
			if (n == 0) return 0;
			if (m == 0) return 1;
			return n * nCm(n-1, m-1) / m;
		}

		public static string ReadLine()
		{
			return Console.ReadLine();
		}

		public static int ReadLineInt()
		{
			return int.Parse(ReadLine());
		}

		public static string[] ReadLineStringSplit(char s=' ')
		{
			return ReadLine().Split(s).ToArray();
		}

		public static int[] ReadLineIntSplit(char s=' ')
		{
			return ReadLine().Split(s).Select(x => int.Parse(x)).ToArray();
		}

		public static long[] ReadLineLongSplit(char s = ' ')
		{
			return ReadLine().Split(s).Select(x => long.Parse(x)).ToArray();
		}
	}
}

Measured memory_bytes: 11092
#include <iostream>
#include <bits/stdc++.h>
#define scan(n)      scanf("%I64d",&n);
#define scan2(a,b)   scanf("%I64d%I64d",&a,&b);
#define scan3(a,b,c) scanf("%I64d%I64d%I64d",&a,&b,&c);
#define sc(n)        scanf("%c",&n);
#define sf(n)        scanf("%lf",&n);
#define ss(n)        scanf("%s",n);
#define forall(i,a,b)for(long long int i=a;i<b;i++)
#define all(a)       a.begin(), a.end()
#define pb           push_back
#define mp           make_pair
#define FAST_IO      ios_base::sync_with_stdio(false); cin.tie(NULL);
#define minimum(a)   *min_element(a.begin(),a.end())
#define maximum(a)   *max_element(a.begin(), a.end())
#define display(a)   for(auto i : a) cout<<i<<" ";
typedef long long int ll;
typedef long double ld;
const int MOD = 1e9 + 7;
using namespace std;
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}
vector<ll> scanVector(ll n, vector<ll> &v)
{
  ll temp;
  for(ll i = 0; i < n ; i++)
  {
     cin>>temp;
     v.pb(temp);
  }
  return v;
}

int main() {
    FAST_IO
    ll t;
    //cin>>t;
    t = 1;
    while(t--)
    {
        ll n,k;
        cin>>n>>k;
        vector<ll> v;
        v=scanVector(n,v);
        //display(v);
        ll dp[n];
        dp[0] = 0;
        dp[1] = abs(v[1]-v[0]);
        for(ll i = 2; i < n ; i++)
        {
            dp[i] = dp[i-1]+abs(v[i]-v[i-1]);
            for(ll j = 2; j <= k; j++)
            {
                if((i-j)>=0)
                {
                    ll temp = dp[i-j] + abs(v[i]-v[i-j]);
                    dp[i] = min(dp[i],temp);
                }
            }
        }
        //display(dp);
        //cout<<endl;
        cout<<dp[n-1]<<endl;
    }
    return 0;
}

Measured memory_bytes: 2020
S = input()
T = input()


n = len(S)

tableS = {}
tableT = {}

for i in range(n):
    f = S[i]
    t = T[i]
    if f  in tableS:
        if tableS[f] != t:
            print('No') 
            exit()
    tableS[f] = t
    if t in tableT:
        if tableT[t] != f:
            print('No')
            exit()
    tableT[t] = f

print('Yes')



Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define sz(x) int(x.size())
#define pb push_back
#define eb emplace_back
using ll=long long;
using P = pair<int,int>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)
const ll MOD=1000000007;



int main() {
    int N,D;
    cin>>N>>D;
    vector<vector<int>> X(N,vector<int>(D));
    rep(i,N){
        rep(j,D){
            cin>>X.at(i).at(j);
        }
    }
    int count=0;
    rep(i,N){
        for(int j=i+1;j<N;j++){
            int d2=0;
            rep(k,D){
                d2+=(X.at(i).at(k)-X.at(j).at(k))*(X.at(i).at(k)-X.at(j).at(k));
            }
            for(int d=0;d*d<=d2;d++){
                if(d*d==d2){count++;}
            }
        }
    }
    cout<<count<<endl;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(a) (a).begin(),(a).end()
#define overload4(_1, _2, _3, _4, name, ...) name
#define rep1(n) for(ll i = 0;i < (n);i++)
#define rep2(i,n) for(ll i = 0;i < (n);i++)
#define rep3(i,a,b) for(ll i = (a);i < (b);i++)
#define rep4(i,a,b,c) for(ll i = (a);i < (b);i += (c))
#define rep(...) overload4(__VA_ARGS__, rep4, rep3, rep2, rep1)(__VA_ARGS__)
#define rrep1(n) for(ll i = (n)-1;i >= 0;i--)
#define rrep2(i,n) for(ll i = (n)-1;i >= 0;i--)
#define rrep3(i,a,b) for(ll i = (a)-1;i >= (b);i--)
#define rrep4(i,a,b,c) for(ll i = (a)-1;i >= (b);i -= (c))
#define rrep(...) overload4(__VA_ARGS__, rrep4, rrep3, rrep2, rrep1)(__VA_ARGS__)
const ll INF=1e18,MOD = 1e9+7;
const int iINF = 1e9;

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

    int n,q,tmp,b,c;
    ll ans = 0;
    cin>>n;
    unordered_map<int,int>mp;
    rep(i,n){
        cin>>tmp;
        mp[tmp]++;
        ans += tmp;
    }
    cin>>q;
    rep(i,q){
        cin>>b>>c;
        ll sum = (c - b) * mp[b];
        mp[c] += mp[b];
        mp[b] = 0;
        ans += sum;
        cout<<ans<<endl;
    }

    return 0;
}



Measured memory_bytes: 7040
A, B, C, D = input().split(' ')
A = int(A)
B = int(B)
C = int(C)
D = int(D)
ab = set([ x for x in range(A, B)])
cd = set([ x for x in range(C, D)])
#print(ab, cd)
print(len(ab & cd))
#print(A,B,C,D)
#print(abs((B-A) - C + ( D-C )))


Measured memory_bytes: 3060
#include <iostream>
#include <cmath>

using namespace std;

int main() {
  int x1, y1, x2, y2;
  cin >> x1 >> y1 >> x2 >> y2;
  int lx = x2 - x1;
  int ly = y2 - y1;
  cout << x2 - ly << " " << y2 + lx << " " << x1 - ly << " " << y1 + lx  << endl;
}

Measured memory_bytes: 764
#include <bits/stdc++.h>
using namespace std;
 
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ", "; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ", "; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << ", " << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << ": " << v.second << ", "; os << "}"; return os; }
template<typename T> void ndarray(vector<T> &vec, int len) { vec.resize(len); }
template<typename T, typename... Args> void ndarray(vector<T> &vec, int len, Args... args) { vec.resize(len); for (auto &v : vec) ndarray(v, args...); }
template<typename T> bool chmax(T &m, const T q) { if (m < q) {m = q; return true;} else return false; }
template<typename T> bool chmin(T &m, const T q) { if (q < m) {m = q; return true;} else return false; }
template<typename T1, typename T2> pair<T1, T2> operator+(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first + r.first, l.second + r.second); }
template<typename T1, typename T2> pair<T1, T2> operator-(const pair<T1, T2> &l, const pair<T1, T2> &r) { return make_pair(l.first - r.first, l.second - r.second); }
#define f first
#define s second
 
int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int len;
    cin >> len;
    cout << 0 << endl;
    string zero;
    cin >> zero;
    int left = 0, right = len - 1;
    while(left <= right) {
        int mid = left + ((right - left) / 2);
        cout << mid << endl;
        string temp;
        cin >> temp;
        if(temp == "Vacant") {
            return 0;
        } if((mid % 2 == 0 && temp != zero) || (mid % 2 != 0 && temp == zero)) {
            right = mid - 1;
        } else {
            left = mid + 1;
        }
    }
}

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

using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
typedef vector<int> Vi;
//typedef tuple<int, int, int> T;
#define FOR(i,s,x) for(int i=s;i<(int)(x);i++)
#define REP(i,x) FOR(i,0,x)
#define ALL(c) c.begin(), c.end()
#define DUMP( x ) cerr << #x << " = " << ( x ) << endl

template <typename T>
T powmod(T n, T k, T mod) {
  if (k == 0) {
    return 1;
  } else if (k % 2 == 0) {
    return powmod(n * n % mod, k / 2, mod);
  } else {
    return n * powmod(n, k-1, mod) % mod;
  }
}

template <typename T>
T inv(T x, T mod) {
  return powmod(x, mod-2, mod);
}

ll fact[(int)1e6+10], inv_f[(int)1e6+10];

template <typename T>
T comb(int n, int k, T mod) {
  assert(0 <= k and k <= n);
  return fact[n] * inv_f[k] % mod * inv_f[n-k] % mod;
}

int main() {
  // use scanf in CodeForces!
  cin.tie(0);
  ios_base::sync_with_stdio(false);

  int H, W, A, B; cin >> H >> W >> A >> B;
  const ll mod = 1e9+7;

  fact[0] = fact[1] = 1;
  FOR(i, 2, 1e6+1) fact[i] = fact[i-1] * i % mod;
  inv_f[(int)1e6] = inv(fact[(int)1e6], mod);
  for (int i = (int)1e6; i > 0; i--) inv_f[i-1] = inv_f[i] * i % mod;


  ll ans = 0;
  FOR(i, B, W) {
    ans += comb(H-A-1+i, i, mod) * comb(A+W-i-2, A-1, mod) % mod;
    ans %= mod;
  }


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


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

# define C continue;
# define R return

# define D double
# define I insert
# define ll long long
# define ld long double

# define ull unsigned long long
# define ui unsigned int

# define pb push_back
# define pf push_front

# define vi vector < int >
# define vc vector < char >
# define vs vector < string >
# define vb vector < bool >
# define vd vector < D >
# define vll vector < ll >
# define vull vector < ull >
# define vld vector < ld >

# define vvi vector < vector < int > >
# define vvb vector < vector < bool > >
# define vvc vector < vector < char > >
# define vvll vector < vector < ll > >
# define vvd vector < vector < D > >
# define vvld vector < vector < ld > >

# define all(v) (v).begin() , (v).end()
# define allrev(v) (v).rbegin() , (v).rend()
# define allcomp(v) v.begin() , v.end() , comp
# define allrevcomp(v) v.rbegin() , v.rend() , comp

# define pii pair < int , int >
# define pll pair < ll , ll >
# define pld pair < ld , ld >
# define pDD pair < D , D >

# define vpld vector < pld >
# define vpii vector < pii >
# define vpll vector < pll >
# define vpDD vector < pDD >

# define vvpii vector < vector < pii > >
# define F first
# define S second
# define mp make_pair

# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define dist(a,b,p,q) sqrt((p-a)*(p-a) + (q-b)*(q-b))

# define pp(n) printf("%.10Lf",n);
# define line cout<<"\n";

string vow = "aeiou";

const int dxhorse[] = {-2, -2, -1, -1, 1, 1, 2, 2};
const int dyhorse[] = {1, -1, 2, -2, 2, -2, 1, -1};

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

const ld pie = 3.14159265358979 ;
const ll mod = 1e9 + 7 ;

void solve ( int test_case )
{
    int a , b;
    cin >> a >> b ; 
    
    if ( a < 10 && b < 10 ) cout << a*b ; 
    else cout << -1 ;
}

int main()
{
    int t = 1;
    // cin >> t;

    for ( int i=0 ; i < t ; i++ ) solve(i);
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll          long long int
#define lld          long double
#define pb          push_back
#define pii         pair<ll,ll>
#define mi          map<ll,ll>
#define vec         vector<ll>
#define all(a)     (a).begin(),(a).end()
#define F           first
#define S           second
#define mod         1000000007
#define nmod         -1000000007
#define N            1000000//31630=sqrt(pow(10,9))
#define rep(i,a,b)	for(ll  i=a;i<b;i++)
#define repi(i,a,b)	for(ll  i=a;i<=b;i++)
#define per(i,a,b)  for(ll i=a;i>=b;i--)
#define mp          make_pair
#define mit         map<ll,ll>::iterator
#define sit         set<ll>::iterator
#define pit         pair<ll,ll>::iterator
#define tr(container, it) for(__typeof(container.begin()) it = container.begin(); it != container.end(); it++)
using namespace std;
ll xo(ll x, ll y) 
{ 
   return (x | y) & (~x | ~y); 
}  
ll bin_Expo(ll x,ll n)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return bin_Expo(x*x,n/2);
    else                             //n is odd
        return x*bin_Expo(x*x,(n-1)/2);
}
ll mod_Expo(ll x,ll n,ll M)
{
		if(x==0)
		return 0;
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return mod_Expo((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*mod_Expo((x*x)%M,(n-1)/2,M))%M;
 
}
//bool pf[N+1ll];
//vec prim;
//void sieve()
//{
//    repi(i,0,N)
//    pf[i]=true;
//	pf[0] = pf[1] = false;
//    for (int i = 2; i <= N; i++) {
//        if (pf[i]) 
//		{
//            prim.push_back(i);
//            for (int j = i + i; j <= N; j+=i) {
//                pf[j] = false;
//            }
//        }
//    }
//}
bool prime_check(ll x)
{
    bool prime = (x >= 2);
    for (ll i = 2; i * i <= x; i++) 
    {
        if (x % i == 0) 
        {
            prime = false;
            break;
        }
    }
    return prime;
}
ll logg(ll base,ll x) 
{
    return (ll)(log(x) / log(base));
}

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	int TESTS=1;
//	cin>>TESTS; 
    while(TESTS--)
    {
    	ll m,i,l,h,j,mx,my,ans,d,n,r,g,b,e,f;
    	cin>>m;
    	cout<<fixed<<setprecision(10);
    	lld k=M_PI;
    	k=k*(2.00)*(m*1.00);
    	cout<<k;
    	
    	
    	
    	
		
	}
	return 0;
} 

Measured memory_bytes: 3732
import java.util.*;
import java.io.*;
import java.lang.reflect.Array;
import java.math.BigInteger;
import java.rmi.server.UnicastRemoteObject;

import static java.lang.Math.*;
import static java.util.Arrays.*;
import static java.util.Collections.*;
 
public class Main{
    static long mod=1000000007;
//    static int dx[]={-1,0,1,0};
//    static int dy[]={0,-1,0,1};

    public static void main(String[] args)   throws Exception, IOException{        
        Reader sc = new Reader(System.in);
        PrintWriter out=new PrintWriter(System.out);

        int n = sc.nextInt();
//        int a[] = sc.nextIntArray(n);
        int a[] = new int[n+1];
        int b[] = new int[n+1];
        for (int i = 1; i < a.length; i++) {
			a[i]=sc.nextInt();
		}
        int e=0;
        for (int i = a.length-1; 0 < i; i--) {
        	int s=0;
        	for (int j = i; j < a.length; j+=i) {
				s+=a[j];
			}
        	if(s%2!=a[i])a[i]++;
        	b[i]=a[i]%2;
        	e+=b[i];
		}
        out.println(e);
        for (int i = 1; i < b.length; i++) {
			if(b[i]>0)out.println(i);
		}

        
        
        
        out.flush();
    }



    static boolean validpos(int x,int y,int r, int c){
        return x<r && 0<=x && y<c && 0<=y;
    }

    static void db(Object... os){
        System.err.println(Arrays.deepToString(os));
    }
}

class P {
	int x, y;
	P(int  x, int y) {
	  this.x=x;
	  this.y=y;
	}
}


//class P {
//    int id, d;
//    P(int  id, int d) {
//        this.id=id;
//        this.d=d;
//    }
//}

//class P implements Comparable<P>{
//    int a,b;
//    P(int a, int b) {
//    	this.b=b;
//    	this.a=a;
//    }
//
//    public int compareTo(P p){
//        return b-p.b;
//    }
//}

class Reader
{ 
    private BufferedReader x;
    private StringTokenizer st;
    
    public Reader(InputStream in)
    {
        x = new BufferedReader(new InputStreamReader(in));
        st = null;
    }
    public String nextString() throws IOException
    {
        while( st==null || !st.hasMoreTokens() )
            st = new StringTokenizer(x.readLine());
        return st.nextToken();
    }
    public int nextInt() throws IOException
    {
        return Integer.parseInt(nextString());
    }
    public int[] nextIntArray(int size) throws IOException{
        int r[] = new int[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextInt(); 
        }
        return r;
    }
    public long[] nextLongArray(int size) throws IOException{
        long r[] = new long[size];
        for (int i = 0; i < size; i++) {
            r[i] = this.nextLong(); 
        }
        return r;
    }
    public long nextLong() throws IOException
    {
        return Long.parseLong(nextString());
    }
    public double nextDouble() throws IOException
    {
        return Double.parseDouble(nextString());
    }
}


Measured memory_bytes: 43400
n = int(input())
h = list(map(int, input().split()))

ans = [0] * n

ans[1] = abs(h[0] - h[1])

for i in range(2, n):
    ans[i] = min(abs(h[i] - h[i-2])+ans[i-2], abs(h[i] - h[i-1])+ans[i-1])
#print(ans)
print(ans[n-1])

Measured memory_bytes: 13928
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int fa[100005];
int Fa(int x) {return fa[x] == x ? x : fa[x] = Fa(fa[x]);}
void Mg(int x, int y) {fa[Fa(x)] = Fa(y);}
int main() {
    ios :: sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    for (int i = 0; i < n; ++ i) fa[i] = i;
    vector <pair <int, int> > v(n);
    vector <int> id1(n), id2(n);
    for (int i = 0; i < n; ++ i) {
        cin >> v[i].first >> v[i].second;
        id1[i] = i, id2[i] = i;
    }
    sort(id1.begin(), id1.end(), [&] (int a, int b) {
        return v[a].first < v[b].first;
    });
    sort(id2.begin(), id2.end(), [&] (int a, int b) {
        return v[a].second < v[b].second;
    });
    vector <pair <int, pair <int, int> > > e;
    for (int i = 0; i < n - 1; ++ i) {
        e.push_back(make_pair(v[id1[i + 1]].first - v[id1[i]].first, make_pair(id1[i], id1[i + 1])));
    }
    for (int i = 0; i < n - 1; ++ i) {
        e.push_back(make_pair(v[id2[i + 1]].second - v[id2[i]].second, make_pair(id2[i], id2[i + 1])));
    }
    sort(e.begin(), e.end());
    ll ans = 0;
    for (int i = 0; i < e.size(); ++ i) {
        int w = e[i].first, u = e[i].second.first, v = e[i].second.second;
        if (Fa(u) == Fa(v)) continue;
        ans += w;
        Mg(u, v);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6772
//qq

#include <stdio.h>

int main (void)
{  
    int i, j;

    for (i = 1; i <= 9; i++){
        for(j = 1; j <= 9; j++){
            printf("%dx%d=%d\n", i, j, i * j);
        }
    }
    return (0);
}


Measured memory_bytes: 2032
#include<stdio.h>

#define INFTY 10000000
#define WHITE 0
#define GRAY 1
#define BLACK 2

typedef struct{
  int data[100];
  int head;
  int tail;
}queue;

queue Q;

int n;
int G[100][100];
int d[100] = {INFTY};
int color[100] = {WHITE};

void BFS(int);
void enqueue(int);
int dequeue();

int main(){
  int i, j;
  int u, k, v;

  scanf("%d",&n);

  for(i = 0 ; i < n ; i++){
    scanf("%d %d",&u,&k);
    for(j = 0 ; j < k ; j++){
      scanf("%d",&v);
      G[u-1][v-1] = 1;
    }
  }

  for(i = 0 ; i < n ; i++) d[i] = INFTY;

  BFS(0);
  
  for(i = 0 ; i < n ; i++){
    if(d[i] == INFTY) printf("%d %d\n",i+1,-1);
      else printf("%d %d\n",i+1,d[i]);
  }
  
  return 0;
}

void BFS(int s){
  int v, u;

  d[s] = 0;
  color[s] = GRAY;
  Q.head = Q.tail = 0;
  
  enqueue(s);

  while(Q.tail < n){
    u = dequeue();
    if(u == INFTY) break;
    for(v = 0 ; v < n ; v++){
      if(G[u][v] == 0) continue;
      if(color[v] == WHITE){
	d[v] = d[u] + 1;
	color[v] = GRAY;
	enqueue(v);
      }
    }color[u] = BLACK;
  }
}
			
void enqueue(int s){

  if(Q.tail >= n) return;

  Q.data[Q.tail] = s;
  Q.tail++;
}

int dequeue(){
  int s;

  if(Q.head == Q.tail) return INFTY;

  s = Q.data[Q.head];
  Q.head++;

  return s;
}
  



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


using namespace std;


#define ll long long
#define mk make_pair
#define pb push_back
#define fi first
#define se second
#define all(x) x.begin(), x.end()
#define sz(x) (int) (x).size()


ll sum(int n);

void go(){
	int n,m;cin>>n>>m;
	if(n==m) cout << "Yes";
	else cout << "No";
}
int main(){
   
   ios_base::sync_with_stdio(0);
   cin.tie(0);
   cout.tie(0);

   go();

   return 0;
}

ll sum(int n){                
   if(n == 0){
      return n;
   }else{
      return sum(n/10) + n%10;
   }
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
while (x->left != NIL) { x = x->left;}
return x;
}
Node treeSearch(Node u, int k){
if (u == NIL || k == u->key) return u;
if(k < u->key) return treeSearch(u->left,k);
else return treeSearch(u->right,k);
}

Node treeSuccessor(Node x){
Node y;
if(x->right != NIL) return treeMinimum(x->right);
y = x->parent;
while (y != NIL && x == y->right)
{
x = y;
y = y->parent;
}
return y;
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

while(x != NIL) {
y = x;
if(z->key < x->key) x = x->left;
else x = x->right;
}
z->parent = y;
if(y == NIL) root = z; //if T is empty
else if(z->key < y->key) y->left = z;
else y->right = z;
}

void inorder(Node u){
if(u != NIL)
{
inorder(u->left);
printf(" %d",u->key);
inorder(u->right);
}
}

void preorder(Node u){
if(u != NIL)
{
printf(" %d",u->key);
preorder(u->left);
preorder(u->right);
}
}

int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } 
  }

  return 0;
}

Measured memory_bytes: 24040
#include<iostream>
#include<algorithm>
#include<string>
#include<stdio.h>
using namespace std;
int main(){

	int X,A,B;
	cin >> X >> A >> B;
	if((A-B)>=0)
		puts("delicious");
	else if((B-A)>=(X+1))
		puts("dangerous");
	else
		puts("safe");

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <iomanip>

using namespace std;
typedef long long LL;

// import here

int main(){
    LL n;
    cin >> n;
    vector<pair<LL,LL>> p(n);
    for(LL i = 0; i < n; ++i){
        cin >> p[i].first >> p[i].second;
    }
    if(n == 2){
        cout << 0.5 << endl;
        cout << 0.5 << endl;
        return 0;
    }
    for(LL i = 0; i < n; ++i){
        vector<double> rvec;
        for(LL j = 0; j < n; ++j){
            if(i == j) continue;
            double r = atan2(p[j].first - p[i].first, p[j].second - p[i].second);
            //cerr << "ra=" << r << endl;
            rvec.push_back(r);
        }
        sort(rvec.begin(), rvec.end());
        double max_r = rvec[0] + M_PI*2 - rvec[rvec.size()-1];
        for(LL j = 0; j+1 < rvec.size(); ++j){
            max_r = max(max_r, rvec[j+1] - rvec[j]);
        }
        double ans = max(0.0, max_r - M_PI) / (2*M_PI);
        cout << setprecision(16) << ans << endl;
    }
    return 0;
}

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

int main() {
	ios_base::sync_with_stdio(0);cin.tie(0);
	string s;
	cin>>s;
	vector<int> res;
	for(char c:s)
		switch(c){
			case '0':
				res.push_back(0);
				continue;
			case '1':
				res.push_back(1);
				continue;
			case 'B':
				if(!res.empty()) res.pop_back();
				continue;
		}
	for(int x:res)
		cout<<x;
	cout<<'\n';
}




Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < n; i++)
using namespace std;
const int INF = 100;

vector<int> num_of_coins(int change)
{
    vector<int> ans(4);
    ans.at(3) = change / 500;
    change %= 500;
    ans.at(2) = change / 100;
    change %= 100;
    ans.at(1) = change / 50;
    change %= 50;
    ans.at(0) = change / 10;

    return ans;
}

int main()
{
    bool first = true;

    while (true)
    {
        int price;
        cin >> price;
        if (price == 0)
        {
            break;
        }

        if (!first)
        {
            cout << endl;
        }

        first = false;

        vector<int> coins(4), yen(4);
        yen = {10, 50, 100, 500};
        rep(i, 4) cin >> coins.at(i);

        vector<int> A(4);
        int min = INF;
        rep(i, coins.at(0) + 1)
        {
            rep(j, coins.at(1) + 1)
            {
                rep(k, coins.at(2) + 1)
                {
                    rep(l, coins.at(3) + 1)
                    {
                        int pay = 10 * i + 50 * j + 100 * k + 500 * l;
                        if (pay < price)
                        {
                            continue;
                        }
                        vector<int> changes = num_of_coins(pay - price);
                        int num = 0;
                        rep(m, 4) num += coins.at(m) + changes.at(m);
                        num -= i + j + k + l;
                        if (num < min)
                        {
                            min = num;
                            A = {i, j, k, l};
                        }
                    }
                }
            }
        }

        rep(i, 4)
        {
            switch (A.at(i))
            {
            case 0:
                break;

            default:
                cout << yen.at(i) << " " << A.at(i) << endl;
                break;
            }
        }
    }
    return 0;
}


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

string s, t;
unordered_map<char, set<int>> h;

int main () {
  cin >> s >> t;

  int N = s.size(), M = t.size();
  rep(i,N) h[s[i]].insert(i);

  int k = 0;
  ll ans = 0;
  rep(i,M) {
    char c = t[i];
    auto it = h[c].lower_bound(k);
    if(it == h[c].end()) {
      it = h[c].lower_bound(0);
      ans += N;
    }

    if(it == h[c].end()) {
      cout << "-1" << endl;
      return 0;
    }

    k = (*it) + 1;
  }

  ans += k;
  cout << ans << endl;


  return 0;
}


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

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

  int h1, m1, h2, m2, k;
  cin >> h1 >> m1 >> h2 >> m2 >> k;

  int s = 60 * h1 + m1;
  int g = 60 * h2 + m2;

  cout << g - s - k << '\n';

  return (0);
}


Measured memory_bytes: 3608
n=int(input())
a=[int(input()) for i in range(n)]
b=list(set(a))
c=0
for i in range(n):
    if a[i]%2==1:
        c+=1
if len(b)==1 and b[0]==1:
    print("first")
elif sum(a)%2==0:
    if c%2==0 and c>=2:
        print("first")
    else:
        print("second")
else:
    print("first")



Measured memory_bytes: 13204
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <numeric>
#include <regex>
#include <tuple>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
#define modulo 1000000007 // 10^9 + 7
#define INF 1000000000 // 10^9
#define LLINF 1LL<<60



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

	int N;
	string S;
	cin >> N >> S;

	int alpha[26];
	for (int i = 0; i < 26; i++) alpha[i] = 0;

	for (int i = 0; i < N; i++) {
		alpha[S[i] - 'a']++;
	}

	ll ans = 1LL;
	for (int i = 0; i < 26; i++) {
		ans *= (alpha[i] + 1);
		ans %= modulo;
	}

	cout << ans-1 << endl;

	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

int N, X[105];

int main(void) {

	cin >> N;

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

	long long int ans = 999999999999999;

	for (int P = 1; P <= 100; P++) {
		long long int tmp = 0;
		for (int i = 1; i <= N; i++) {
			tmp += (X[i] - P)*(X[i] - P);
		}
		ans = min(ans, tmp);
	}

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

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

#define int long long
#define rep(i,l,r) for(int i=(int)(l);i<(int)(r);i++)
#define all(x) (x).begin(),(x).end()
#define pb push_back
template<class T>bool chmax(T &a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,T b){if(a>b){a=b;return 1;}return 0;}

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

signed main()
{
	int n, a, b, c, d;
	string s;
	cin >> n >> a >> b >> c >> d >> s;
	a--; b--; c--; d--;

	bool ans = true;
	if(a < b and c < d){
		rep(i, a, d){
			if(s[i] == '#' and s[i+1] == '#'){
				ans = false;	
			}
		}
	}else if(b < a and d < c){
		rep(i, b, c){
			if(s[i] == '#' and s[i+1] == '#'){
				ans = false;	
			}
		}
	}else if(a < b and d < c){
		bool flag = false;
		rep(i, b-1, d){
			if(s[i] == '.' and s[i+1] == '.' and s[i+2] == '.'){
				flag = true;
			}
		}
		if(!flag) ans = false;
		else{
			rep(i, a, d){
				if(s[i] == '#' and s[i+1] == '#'){
					ans = false;	
				}
			}
		}
	}else{
		bool flag = false;
		rep(i, d-1, b){
			if(s[i] == '.' and s[i+1] == '.' and s[i+2] == '.'){
				flag = true;
			}
		}
		if(!flag) ans = false;
		else{
			rep(i, b, c){
				if(s[i] == '#' and s[i+1] == '#'){
					ans = false;	
				}
			}
		}
	}

	cout << (ans ? "Yes" : "No") << endl;

	return 0;
}


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

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i,N) cin >> A[i]; 

    int SwapNum = 0; //交換数

    for(int SortedNum = 0; SortedNum < N; ++SortedNum){    //Aの最初からSortedNum個目まではソート済
        bool Swapped = false; //このループで交換が行われたか
        int MinPos = SortedNum;    //未ソート部分での最小要素の位置
        for(int CurPos = SortedNum; CurPos < N; ++CurPos){
            if (A[CurPos] < A[MinPos]){
                Swapped = true;
                MinPos = CurPos;
            }
        }
        swap(A[SortedNum], A[MinPos]);
        if(Swapped) ++SwapNum;
    }


    rep(i,N-1) cout << A[i] << " ";
    cout << A[N-1] << endl;
    cout << SwapNum << endl;
    
    return 0;
}


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

int main() {
    string N;
    cin >> N;
    if (N[0] == N[2]){
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
}


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

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

  ll s = a + b;
  ll d = n / s;
  ll m = n % s;
  ll ans = a * d + min(m, a);

  cout << ans << endl;
}

Measured memory_bytes: 384
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int m = Integer.parseInt(sc.next());

		int ans = (n - 1) * (m - 1);
		System.out.println(ans);
		sc.close();
	}
}

Measured memory_bytes: 22868
h, w = map(int, input().split())
ss = [input() for i in range(h)]
sm = ['.'+s+'.' for s in ss]
mm = ['.'*(w+2)]+sm+['.'*(w+2)]

for i in range(1,h+1):
  for j in range(1,w+1):
    if mm[i][j] == '#' and mm[i][j-1] == '.' and mm[i][j+1] == '.' and mm[i-1][j] =='.' and mm[i+1][j] == '.':
      print('No')
      exit()


print('Yes')

Measured memory_bytes: 9180
def main():
    n = int(input())
    c = [i for i, achr in enumerate(input()) if achr=="R"]
    most_right_r = len(c)
    if most_right_r==n:
        print("0")
        exit()

    count = 0
    pre_r_pos = -1
    for i, r_pos in enumerate(c):
        diff_r_pos = r_pos - pre_r_pos - 1
        if diff_r_pos and i<most_right_r:
            if diff_r_pos < most_right_r - i:
                most_right_r -= diff_r_pos
                count+=diff_r_pos
                #print(i, r_pos, diff_r_pos, most_right_r, count)
            else:
                count+=most_right_r - i - 1
                most_right_r -= most_right_r - i - 1
                count+=1
                #print(i, r_pos, diff_r_pos, most_right_r, count)
                break
        pre_r_pos = r_pos

    print(count)

if __name__=="__main__":
    main()


Measured memory_bytes: 17144
K = int(input())
if K % 2 == 0 or K % 5 == 0:
    print(-1)
else:
    a = 1
    b = a % K
    i = 1
    while True:
        if (7*a) % K == 0:
            print(i)
            break
        else:
            a += (10*b) % K
            b = (10*b) % K
            i += 1 

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

using namespace std;

int main() {
	int n, k;
	cin>>n>>k;
	vector<int> A(n), dp(n, INT_MAX);
	for(int i =0;i<n;i++) cin>>A[i];
	dp[0] = 0;
	for(int i = 0;i<n;i++) {
		int temp = 1;
		while(temp <= k && i+temp < n) {
			dp[i+temp] = min(dp[i+temp], dp[i]+abs(A[i+temp]-A[i]));
			temp++;
		}
	} 
	//for(auto i : dp) cout<<i <<" ";
	cout<<dp[n-1]<<'\n';
	return 0;

}

Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include <cstring>

using namespace std;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int h1, m1, h2, m2, k;
    cin >> h1 >> m1 >> h2 >> m2 >> k;
    cout << (h2 - h1) * 60 + (m2 - m1) - k << "\n";
    return 0;
}


Measured memory_bytes: 3652
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl

using namespace std;

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

const int MOD = 1e9 + 7;
const int INF = 1e9;
const ll LINF = 1e18;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const int ddy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

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

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

bool compareP(pair<int, int> a, pair<int, int> b) {
    if (a.second != b.second) {
        return a.second < b.second;
    } else {
        return a.first < b.first;
    }
}

int main() {
    int n, k, ans = 0;
    cin >> n >> k;
    int h;
    rep(i, n) {
        cin >> h;
        if (h >= k)
            ans++;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;
typedef long long ll;

int main() {
  int N, X, L, D = 0;
  
  cin >> N >> X;
  
  int cnt = 0;
  if(D <= X) cnt++;
  
  for(int i = 0; i < N; i++) {
    cin >> L;
    D += L;
    if(D <= X) cnt++;
  }
  
  cout << cnt << endl;
  
  return 0;
}

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

using bellman_cost = int;
template<class V, class E>
struct Graph
{
	int sz;
	vector<V> v;
	vector<vector<E>> e;
	Graph(int n) : sz(n), v(n), e(n) {}
	template<class... Args>
	inline void assign_vertex(int pos, Args... args) {
		v[pos] = V(args...);
	}
	template<class... Args>
	inline void add_edge(int pos, Args... args) {
		e[pos].emplace_back(args...);
	}
	inline int size() {
		return sz;
	}
};

template<class T>
struct Vertex_Cost
{
	T cost;
	bool valid = false;
	Vertex_Cost(T v1) : cost(v1) {}
	Vertex_Cost() {}
};
using vertex = Vertex_Cost<bellman_cost>;

template<class T>
struct Edge_Cost
{
	int to;
	T cost;
	Edge_Cost(int t, T c) : to(t), cost(c) {}
	Edge_Cost() {}
};
using edge = Edge_Cost<bellman_cost>;
using graph = Graph<vertex, edge>;

template<class T, class V, class E>
void Bellmanford(Graph<V, E>& G, int s, T INF_COST)
{
	auto &v = G.v;
	auto &e = G.e;
	for (auto& vv : v) vv.cost = INF_COST;
	v[s].cost = 0;
	v[s].valid = true;
	for (int i = 0; i + 1 < (int) v.size(); i++) {
		for (int j = 0; j < (int) v.size(); j++) {
			for (auto& x: e[j]) {
				if (v[j].cost == INF_COST) continue;
				v[x.to].cost = min(v[x.to].cost, v[j].cost + x.cost);
				v[x.to].valid = true;
			}
		}
	}
	vector<int> not_valid;
	for (int i = 0; i < (int) v.size(); i++) {
		for (auto& x: e[i]) {
			if (v[i].cost == INF_COST) continue;
			if (v[x.to].cost > v[i].cost + x.cost) {
				not_valid.emplace_back(x.to);
			}
		}
	}
	for (auto& x: not_valid) {
		auto dfs = [&](auto f, int pos) {
			if (!v[pos].valid) return;
			v[pos].valid = false;
			for (auto& y: e[pos]) {
				f(f, y.to);
			}
		};
		dfs(dfs, x);
	}
}


void solve(long long N, long long M, long long P, std::vector<long long> A, std::vector<long long> B, std::vector<long long> C) {
	graph g(N);
	for (int i = 0; i < M; i++) {
		g.add_edge(A[i]-1, B[i]-1, -(C[i] - P));
	}
	Bellmanford(g, 0, INT_MAX);
	if (!g.v[N-1].valid) cout << -1 << endl;
	else cout << max(-g.v[N-1].cost , 0) << endl;
}

signed main() {
	long long N;
	scanf("%lld",&N);
	long long M;
	scanf("%lld",&M);
	long long P;
	scanf("%lld",&P);
	std::vector<long long> A(M);
	std::vector<long long> B(M);
	std::vector<long long> C(M);
	for(int i = 0 ; i < M ; i++){
		scanf("%lld",&A[i]);
		scanf("%lld",&B[i]);
		scanf("%lld",&C[i]);
	}
	solve(N, M, P, std::move(A), std::move(B), std::move(C));
	return 0;
}


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

int main()
{
  int A, B, res = 0;
  cin >> A >> B;
  for(int i = A; i < B + 1; i++)
  {
    if(i % 10 == i /10000 && i / 10 % 10 == i / 1000 % 10)
      res++;
  }
  cout << res << endl;
}


Measured memory_bytes: 256