akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)

using namespace std;

typedef pair<int, int> p;
typedef long long ll;
const int inf = 1000000007;

struct rlcnt {
  ll id;
  ll rcnt;
  ll lcnt;
};

int main() {
  string s;
  cin >> s;
  vector<rlcnt> d;
  ll rc = 0;
  ll lc = 0;
  bool rl = true;  // true r false l
  rep(i, s.size() - 1) {
    if (s[i] == 'R' && rl) rc++;
    if (s[i] == 'L' && rl) rl = false;
    if (s[i] == 'R' && !rl) {
      rl = true;
      rc = 1;
    }
    if (s[i] == 'R' && s[i + 1] == 'L') {
      rlcnt tmp;
      tmp.id = i;
      tmp.rcnt = rc - 1;
      d.push_back(tmp);
    }
  }
  ll index = 0;
  rep(i, s.size() - 1) {
    if (s[i] == 'L' && s[i + 1] == 'R') {
      d[index].lcnt = i - d[index].id - 1;
      index++;
    }
  }
  d[d.size() - 1].lcnt = s.size() - 1 - d[d.size() - 1].id - 1;

  vector<ll> ans(s.size());
  index = 0;
  rep(i, s.size()) {
    if (i == d[index].id) {
      ans[i] = d[index].rcnt / 2 + d[index].lcnt / 2 + (d[index].lcnt % 2) + 1;
      ans[i + 1] =
          d[index].lcnt / 2 + d[index].rcnt / 2 + (d[index].rcnt % 2) + 1;
      index++;
    }
  }
  // rep(i, d.size()) cout << "(" << d[i].id << ", " << d[i].rcnt << ", "
  //                        << d[i].lcnt << ")"
  //                       << ", ";
  // cout << endl;

  // rep(i, s.size()) cout << ans[i] << ", ";
  // cout << endl;
  rep(i, s.size()) cout << ans[i] << endl;
  return 0;
}


Measured memory_bytes: 5344
#include  <iostream>
#include  <stdio.h>
#include <algorithm>
#include <map>
#include <math.h>

using namespace std;
#include <vector>
#define rep(i,n) for (ll i = 0; i < (n) ; i++)
#define INF 1e9
#define llINF 1e18
#define base10_4 10000      //1e4
#define base10_5 100000     //1e5
#define base10_6 1000000    //1e6
#define base10_7 10000000   //1e7
#define base10_8 100000000  //1e8
#define base10_9 1000000000 //1e9

#define MOD 1000000007
#define pb push_back
#define ll long long
#define ull unsigned long long
#define vint vector<int>
#define vll vector<ll>

//#include <stack>
//#include <queue>

// #include <iomanip>
//  cout << fixed << setprecision(15) << y << endl;

string ans_Yes = "Yes"; 
string ans_No = "No"; 
string ans_yes = "yes"; 
string ans_no = "no"; 

double W;
double H;
ll x;
ll y;

ll ltmp;
string stmp;
double dtmp;

int main(){

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    cin >> W >> H >> x >> y;

    cout << W*H/2 << endl;   

    if(W/2==x && H/2==y) cout << 1 << endl;
    else cout << 0 << endl;
}

Measured memory_bytes: 3724
import sys, math
def main():
    def input():
        return sys.stdin.readline()[:-1]
    N, K, Q = map(int,input().split())
    P = [0 for k in range(N)]
    for k in range(Q):
        a = int(input())
        P[a-1] += 1
    for e in P:
        if e > Q-K:
            print("Yes")
        else:
            print("No")
if __name__ == '__main__':
    main()


Measured memory_bytes: 47476
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cstdlib>

using namespace std;

int main()
{
	int i = 0;
	char c;
	string s;
	cin >> s;
	sort(s.begin(), s.end());
	if (s[0] == 'b') {
		cout << 'a' << endl;
		return 0;
	}
	while (s[i]) {
		if (s[i] == s[i + 1]) {
			i++;
			continue;
		}
		if (s[i] == 'z') {
			cout << "None" << endl;
			break;
		}
		if (s[i] + 1 != s[i + 1]) {
			c = s[i] + 1;
			cout << c << endl;
			break;
		}
		i++;
	}
	return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
const  int MAXX=105;
int main()
{
	int n,x[MAXX];
	cin >>n;
	int max=0;
	for(int i=1;i<=n;i++){
		cin >>x[i];
		if(max < x[i]) max=x[i];
	}
	int Min=0x3f3f3f3f;
	for(int i=1;i<=max;i++){
		int sum=0;
		for(int j=1;j<=n;j++){
			sum += (x[j]-i)*(x[j]-i);
		}
		if(sum<Min) Min=sum;
	} 
	printf("%d",Min);
	return 0;
	
	
}

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

#define int long long
#define DBG 1
#define dump(o) if(DBG){cerr<<#o<<" "<<o<<endl;}
#define dumpc(o) if(DBG){cerr<<#o; for(auto &e:(o))cerr<<" "<<e;cerr<<endl;}
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define each(it,c) for(auto it=(c).begin();it!=(c).end();it++)
#define all(c) c.begin(),c.end()
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);

signed main() {
	int n, a, b; cin >> n >> a >> b; vector<int>v(n); rep(i, 0, n)cin >> v[i];
	int ans = 0;
	rep(i, 0, n-1) {
		ans += min((v[i + 1] - v[i])*a, b);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,i;
  cin >> n >> i;
  cout << (n+1-i) << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define endl '\n'
using namespace std;
 
typedef long long ll;
typedef long double ld;
#define db(x) cerr << #x << ": " << x << '\n';
#define read(a) int a; cin >> a;
#define reads(s) string s; cin >> s;
#define readb(a, b) int a, b; cin >> a >> b;
#define readc(a, b, c) int a, b, c; cin >> a >> b >> c;
#define readarr(a, n) int a[(n) + 1] = {}; FOR(i, 1, (n)) {cin >> a[i];}
#define readmat(a, n, m) int a[n + 1][m + 1] = {}; FOR(i, 1, n) {FOR(j, 1, m) cin >> a[i][j];}

#define print(a) cout << a << endl;
#define printarr(a, n) FOR (i, 1, n) cout << a[i] << " "; cout << endl;
#define printv(v) for (int i: v) cout << i << " "; cout << endl;
#define printmat(a, n, m) FOR (i, 1, n) {FOR (j, 1, m) cout << a[i][j] << " "; cout << endl;}
#define all(v) v.begin(), v.end()
#define sz(v) (int)(v.size())
#define rz(v, n) v.resize((n) + 1);
#define pb push_back
#define fi first
#define se second
#define vi vector <int>
#define pi pair <int, int>
#define vpi vector <pi>
#define vvi vector <vi>
#define setprec cout << fixed << showpoint << setprecision(20);
#define FOR(i, a, b) for (int i = (a); i <= (b); i++)
#define FORD(i, a, b) for (int i = (a); i >= (b); i--)
const ll inf = 1e18;
const ll mod = 1e9 + 7;
const ll N = 2e5 + 1;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
signed main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	
	string s;
	cin >> s;
	cout << s;
	
	if (s[sz(s) - 1] == 's') cout << "es";
	else cout << "s";
}



















Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <string>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <iomanip>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cassert>
#include <complex>
#include <stdio.h>
#include <time.h>
#include <numeric>
#include <unordered_map>
#include <unordered_set>
#define all(a) a.begin(),a.end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define pb push_back
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef long double ld;
typedef complex<ld> com;
constexpr int inf = 1000000000;
constexpr ll INF = 1000000000000000000;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.141592653589793238;
template<class T, class U> inline bool chmax(T &a, const U &b) { if (a < b) { a = b; return true; } return false; }
template<class T, class U> inline bool chmin(T &a, const U &b) { if (a > b) { a = b; return true; } return false; }

struct edge {
	int from, to, cost;
};

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

	int n, m, p;
	cin >> n >> m >> p;
	vector<edge> graph;
	rep(i, m) {
		int a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		graph.pb({ a,b,p - c });
	}
	vector<int> dis(n, inf);
	dis[0] = 0;
	set<int> st;
	rep(cnt, n) {
		bool update = false;
		rep(i, m) {
			edge e = graph[i];
			if (dis[e.from] != inf && dis[e.to] > dis[e.from] + e.cost) {
				dis[e.to] = dis[e.from] + e.cost;
				update = true;
				if (cnt >= n - 1) st.insert(e.to);
			}
		}
		if (!update) break;
	}
	queue<int> que;
	vector<bool> ok(n);
	que.push(0); ok[0] = true;
	while (!que.empty()) {
		int q = que.front(); que.pop();
		for (edge i : graph) {
			if (i.from == q) {
				if (!ok[i.to]) {
					ok[i.to] = true;
					que.push(i.to);
				}
			}
		}
	}
	queue<int> que2;
	vector<bool> ok2(n);
	que2.push(n - 1); ok2[n - 1] = true;
	while (!que2.empty()) {
		int q = que2.front(); que2.pop();
		for (edge i : graph) {
			if (i.to == q) {
				if (!ok2[i.from]) {
					ok2[i.from] = true;
					que2.push(i.from);
				}
			}
		}
	}
	rep(i, n) {
		if (ok[i] && ok2[i] && st.count(i)) {
			cout << -1 << '\n';
			return 0;
		}
	}
	cout << max(-dis[n - 1], 0) << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i,n) for (int i = 0; i < (n); i++)
#define RREP(i, s, n) for (int i = s; i < (n); i++)
#define ALL(a) a.begin(), a.end()
#define RALL(a) a.rbegin(), a.rend()
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
using namespace std;
using ll = long long;
typedef pair<int, int> pint;
typedef pair<ll, ll> pll;
const ll MOD = 1000000007;
const ll INF = MOD * MOD;
const int inf = (1<<29);

int main() {

    int n;
    cin >> n;
    vector<string> s(n);
    REP(i, n) cin >> s[i];
    
    map<string, int> mp;
    mp["AC"] = 0;
    mp["WA"] = 0;
    mp["TLE"] = 0;
    mp["RE"] = 0;

    for(int i = 0; i < n; i++) {
        mp[s[i]]++;
    }

    cout << "AC x "<< mp["AC"] << endl;
    cout << "WA x "<< mp["WA"] << endl;
    cout << "TLE x "<< mp["TLE"] << endl;
    cout << "RE x "<< mp["RE"] << endl;
    

    return 0;
}

Measured memory_bytes: 6396
/**In the name of Allah, the Most Merciful, the Most Merciful.**/
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define INF 9223372036854775806
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define PI 2*acos(0.0)
#define EPS 1e-9
ll max(ll a,ll b) {if(a>b) return a; else return b;}
ll min(ll a,ll b) {if(a<b) return a; else return b;}

int main()
{
    string s;
    cin>>s;
    int cnt=0;
    for(int i=0;i<3;i++){
        if(s[i]=='R'){
            int x=0;
            for(int j=i;j<3;j++){
                if(s[j]=='S') break;
                x++;
            }
            cnt=max(cnt,x);
        }
    }
    cout<<cnt<<endl;

    return 0;
}




Measured memory_bytes: 3624
let () =
  let s = read_line () in
  let n = String.length s in
  let m = (n + 1) / 2 in
  let rec doit i =
    if i = m  then true
    else if s.[i] <> s.[n-1-i] then false
    else doit (i + 1) in
  let b = doit 0 in
  print_endline (if b then "Yes" else "No")

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

int main(void) {
    int r, g, b, sum;
    cin >> r >> g >> b;
    
    sum = r*100 + g*10 + b;

    if ((sum % 4) == 0){
        cout << "YES" << endl;
    }
    else{
        cout << "NO" << endl;
    }

}


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

int main(){
  int i,b,dice[7],ans,len;
  char couse[101];
  
  for(i=1; i<=6; i++)scanf("%d",&dice[i]);
  scanf("%s",couse);
  len=strlen(couse);
  for(i=0; i<len; i++){
    if(couse[i]=='S'){
      b=dice[1];
      dice[1]=dice[5];
      dice[5]=dice[6];
      dice[6]=dice[2];
      dice[2]=b;
    }
    
    if(couse[i]=='W'){
      b=dice[1];
      dice[1]=dice[3];
      dice[3]=dice[6];
      dice[6]=dice[4];
      dice[4]=b;
    }
    
    if(couse[i]=='N'){
      b=dice[1];
      dice[1]=dice[2];
      dice[2]=dice[6];
      dice[6]=dice[5];
      dice[5]=b;
    }
    
    if(couse[i]=='E'){
      b=dice[1];
      dice[1]=dice[4];
      dice[4]=dice[6];
      dice[6]=dice[3];
      dice[3]=b;
    }
  }
  
  printf("%d\n",dice[1]);
  return 0;
}



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

using namespace std;

int const INF = 1e9;
int const NMAX = 1e5;
int n, k;
int arr[1 + NMAX];
int dp[1 + NMAX];

int main() {
  cin >> n >> k;
  for(int i = 1; i <= n; i++) {
    cin >> arr[i];
    dp[i] = INF;
  }
  dp[1] = 0;
  dp[2] = abs(arr[2] - arr[1]);
  for(int i = 3; i <= n; i++) {
    int index = i;
    for(int j = 1; j <= k; j++) {
      if(i - j >= 1) {
        dp[i] = min(dp[i], dp[i-j] + abs(arr[i] - arr[i-j]));
      }
    }
  }
  cout << dp[n];
}


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

// Increment Decrement
int main() {
  int N, X = 0, m = 0;
  string str;
  cin >> N >> str;

  for (int i = 0; i < N; i++) {
    if (str[i] == 'I') {
      X++;
    } else {
      X--;
    }
    m = max(X, m);
  }

  cout << m << endl;
}

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

int main()
{
  string S;
  cin >> S;

  if ((S.at(0) == 'A' && S.at(1) == 'A' && S.at(2) == 'A') || (S.at(0) == 'B' && S.at(1) == 'B' && S.at(2) == 'B')) {
    cout << "No" << endl;
  }
  else {
    cout << "Yes" << endl;
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    bool inc = false, dec = false, keep = true;
    int cmp = a[0];
    int ans = 1;
    rep(i,n){
        if(keep){
            if(a[i] == cmp) continue;
            if(a[i] < cmp) dec = true;
            else inc = true;
            keep = false;
        }
        else if(inc){
            if(a[i] < cmp){
                inc = false;
                keep = true;
                ++ans;
            }
        }
        else{
            if(a[i] > cmp){
                dec = false;
                keep = true;
                ++ans;
            }
        }
        cmp = a[i];
    }
    cout << ans << endl;
    return 0;
}


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

    int main() {
int n;
long long d;
int ans = 0;
cin >> n >> d;
rep(i,n){
    long long x , y;
    cin >> x >> y;
    if (x * x + y * y <= d * d){
        ans++;
    }
    }
    cout << ans << endl;
    }


Measured memory_bytes: 3628
/*
 * “My code isn't a mess! It's organised chaos!”
 */

/*
 * short     2^15-1 ~ 3e4
 * int       2^31-1 ~ 2e9
 * long x86  2^31-1 ~ 2e9
 * long long 2^63-1 ~ 9e18
 */

#include <bits/stdc++.h>
#define x first
#define y second
#define pb push_back
#define mp make_pair
#define fr(a,b) for (int a=0; a<b; ++a)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
const ll mod = 1000000007ll;
const int infty = numeric_limits<int>::max();
struct _{_(){ios_base::Init i;ios_base::sync_with_stdio(0);cin.tie(0);}}_;
void err() {cerr << endl;}
template<typename T, typename... Ts>
void err(T a, Ts... as) {cerr << a << ' '; err(as...);}

void dfs(int v, vector<vector<int>> &g, vector<int> &vis, vector<int> &ret) {
    vis[v] = 1;
    ret.pb(v);
    for (int u : g[v]) {
        if (!vis[u]) {
            dfs(u, g, vis, ret);
            break;
        }
    }
}

int main() {
    int n, m;
    cin >> n >> m;
    vector<vector<int>> g(n);
    int u, v;
    fr(i,m) {
        cin >> u >> v;
        g[u-1].pb(v-1);
        g[v-1].pb(u-1);
    }
    vector<int> vis(n, 0);
    vector<int> f, s;
    dfs(0, g, vis, f);
    vis[0] = 0;
    dfs(0, g, vis, s);

    if (f.size() == 0) {
        swap(f,s);
    }

    cout << f.size() + s.size() - 1 << endl;
    for (auto it = f.rbegin(); it != f.rend(); ++it) {
        cout << *it+1 << ' ';
    }
    for (auto it = s.begin() + 1; it != s.end(); ++it) {
        cout << *it+1 << ' ';
    }
    cout << endl;

    return 0;
}

Measured memory_bytes: 11512
#include <algorithm>
#include <array>
#include <cstddef>
#include <cstdint>
#include <iostream>
#include <map>
#include <set>
#include <vector>

using namespace std;

int main()
{
    int n, d;
    cin >> n >> d;
    cout << ((n + 2 * d) / (2 * d + 1)) << endl;
}


Measured memory_bytes: 256
x,y,a,b,c=map(int,input().split())
p=list(map(int,input().split()))
q=list(map(int,input().split()))
r=list(map(int,input().split()))
p.sort(reverse=True)
q.sort(reverse=True)
r.sort(reverse=True)
kouho=[]
for i in range(x):
	kouho.append(p[i])
for i in range(y):
	kouho.append(q[i])
kouho.sort()
j=0
for i in range(len(kouho)):
	if kouho[i]<r[j]:
		kouho[i]=r[j]
		j+=1
		if j==c:
			break
print(sum(kouho))

Measured memory_bytes: 109676
#include<bits/stdc++.h>
#define LLI long long int
#define ULTRA 2134567890
#define de(x) if(x==MODE && x!=0)

#define MODE 1

using namespace std;

int main()
{
    int i,j;
    int N;


    bool flag = 0;
    scanf("%d", &N);
    for( i=1; i<=9 ; i++)
    {
        for( j=1; j<=9; j++)
        {
            if( i*j==N)
                flag = 1;
        }
    }

    if(flag)
        printf("Yes\n");
    else
        printf("No\n");

    return 0;
}


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

ll calc_gcd(ll x, ll y) {
    if (y == 0) return x;
    return calc_gcd(y, x % y);
}

ll calc_lcm(ll x, ll y) {
    return (x * y) / calc_gcd(x, y);
}

int main() {
    ll N, M;
    string S, T;
    cin >> N >> M >> S >> T;
    ll g = calc_lcm(max(N, M), min(N, M)), n = g / N, m = g / M;
    if (n > m) {
        ll idx;
        for (int i = 0; i < N; i++) {
            idx = n * i;
            if (idx % m == 0 && S[i] != T[idx / m]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    else {
        ll idx;
        for (int i = 0; i < M; i++) {
            idx = m * i;
            if (idx % n == 0 && T[i] != S[idx / n]) {
                cout << -1 << endl;
                return 0;
            }
        }
    }
    cout << g << endl;
    return 0;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vvvi = vector<vector<vector<int>>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using vvvl = vector<vector<vector<ll>>>;
using vs = vector<string>;
using vb = vector<bool>;
#define FOR(i, m, n) for (int i = (m); i < (n); i++)
#define FORR(i, m, n) for (int i = (m); i >= (n); i--)
#define REP(i, n) FOR(i, 0, (n))
#define REPR(i, n) FORR(i, (n) - 1, 0)
#define REP1(i, n) FOR(i, 1, (n) + 1)
#define REPS(c, s) for (char c : s)
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REV(c) reverse(ALL(c))
#define sz(v) (int)v.size()
#define endl '\n'
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;}
template<class T> inline void prn(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << ' ';}
template<class T> inline void printv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << (i == n - 1 ? endl : ' ');}
template<class T> inline void printvv(vector<vector<T>>& v) {for (auto u : v) printv(u);}
template<class T> inline void printlnv(vector<T>& v) {int n = sz(v); REP(i, n) cout << v[i] << endl;}
const int MOD = 1000000007;
const int INF = 1000000001;
const ll LINF = 1000000001000000001LL;
 
void solve();
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(numeric_limits<double>::max_digits10);
    solve();
    return 0;
}

ll pow_mod(ll n, ll p, ll mod) {
    if (p == 0) {
        return 1;
    } else if (p % 2 == 1) {
        return pow_mod(n, p - 1, mod) * n % mod;
    } else {
        ll s = pow_mod(n, p / 2, mod);
        return s * s % mod;
    }
}

vector<ll> list_mod_inverse(ll n, ll m) {
    vector<ll> inv(n + 1);
    inv[1] = 1;
    for (int i = 2; i <= n; ++i)
        inv[i] = inv[m % i] * (m - m / i) % m;
    return inv;
}

ll nck(ll n, ll k, ll m, vector<ll>& inv) {
    if (n - k < k) k = n - k;
    ll ret = 1;
    REP1(i, k) {
        ret *= ((n - i + 1) * inv[i]) % m;
        ret %= m;
    }
    return ret;
}

void solve() {
    ll n, a, b;
    cin >> n >> a >> b;
    ll ans = pow_mod(2, n, MOD) - 1;
    if (ans < 0) ans += MOD;
    auto l = list_mod_inverse(200200, MOD);
    ans -= nck(n, a, MOD, l);
    if (ans < 0) ans += MOD;
    ans -= nck(n, b, MOD, l);
    if (ans < 0) ans += MOD;
    cout << ans << endl;
}


Measured memory_bytes: 4772
#include<iostream>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;


int main() {
    int  a,b,x;
    cin >> x>>a>>b;
    if (abs(x - a) < abs(x - b))cout << "A" << endl;
    else cout << "B" << endl;
    
    
 
    
    return 0;
}

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

int main(){
	int H,W,N;
	cin>>H>>W>>N;
	int horwMax;
	int count=0;
	horwMax=max(H,W);
	for(int i=0;i*horwMax<N;++i){
		count++;
	}
	cout<<count++<<endl;

	return 0;
}

Measured memory_bytes: 256
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

fn main() {
    input! {
        s: chars,
        t: chars,
    }

    let mut cnt: i32 = 0;
    for (i, j) in s.iter().zip(t.iter()) {
        if i == j {
            cnt += 1;
        } else {
            continue;
        }
    }
    println!("{}", cnt);
}


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

using namespace std;
#define  ll long long
#define ld long double
#define f first
#define s second
//#define x real()
//#define y imag()
#define length(a) (hypot((a).imag() , (a).real()))
#define point complex<ld>
#define perp(a) point((-(a).Y,(a).X))
#define dot(a,b) ( (conj(a)*(b)).real() )
#define cross(a,b) ( (conj(a)*(b)).imag() )
#define rotate0(p,ang) (p * exp(point(0,ang)) )

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

    ll k,cur=0;
    string s="";
    cin >> k;

    for(int i=1; i<=10*k; i++)
    {
        cur = (cur*10 + 7)%k;
        s += '7';
        if (cur==0)
        {
            cout << i << "\n";
            break;
        }
    }
    if (cur) cout << "-1\n";

    return 0;
}


Measured memory_bytes: 18604
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const ll mod = 1e9 + 7;



int main(void){
  string s;
  cin >> s;
  string t = "CODEFESTIVAL2016";
  int cnt = 0;
  REP(i, 0, s.length()) {
    cnt += s[i] != t[i];
  }
  cout << cnt << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
/*
*/
using Graph = vector<bitset<10>>;
ll gcd(ll a,ll b){
  if(b == 0) return a;
  return gcd(b, a % b);
}

int main(){
  ll N,K;
  cin >> N >> K;
  vector<ll> res;

  while(true){
    
    ll r = N%K;
    res.push_back(r);
    N = N/K;
    if(N < K){
      if(N != 0) res.push_back(N);
      break;
    }
  }
  cout << res.size() << endl;
}

Measured memory_bytes: 256
n,l = map(int,input().split())
a = list(map(int,input().split()))
for i in range(n-1):
  if a[i] + a[i+1] >= l:
    print("Possible")
    break
else:
  print("Impossible")
  exit()
li = list(range(1,i+1))+list(range(n-1,i+1,-1))+[i+1]
for x in li:
  print(x)

Measured memory_bytes: 14052
MODE = "stdio"
require 'matrix'
include Math
line = Array.new

if(defined? MODE)
  line = STDIN.read.split("\n")
else
  tmp = '3
  1 2 3 4 5 6
  6 5 4 3 2 1
  5 4 3 2 1 6'.split("\n")
  tmp.each{|s|
    line << s.strip
  }
end
class Dice
  attr_accessor :top, :front, :right, :left, :back, :bottom
  def initialize(arr)
    @top = arr[0]
    @front = arr[1]
    @right = arr[2]
    @left = arr[3]
    @back = arr[4]
    @bottom = arr[5]
  end

  def get_arr
    [@top, @front, @right, @left, @back, @bottom]
  end

  def set_arr(arr)
    @top = arr[0]
    @front = arr[1]
    @right = arr[2]
    @left = arr[3]
    @back = arr[4]
    @bottom = arr[5]
  end

  def roll(s)
    case s
    when "E"
      @top, @right, @bottom, @left = @left,@top, @right, @bottom
    when "W"
      @top, @right, @bottom, @left = @right, @bottom, @left, @top
    when "N"
      @top, @back , @bottom, @front = @front,@top, @back , @bottom
    when "S"
      @top, @back , @bottom, @front = @back , @bottom, @front,@top
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

  def rolls(s)
    s.chars.each do|s|
      roll(s)
    end
    [@top, @front, @right, @left, @back, @bottom]
  end

  def spin
    @front, @right, @back, @left = @left, @front, @right, @back
    [@top, @front, @right, @left, @back, @bottom]
  end

  def equal?(dice)
    tmp = self.get_arr
    cmd = ["", "E","W","N","S","EE"]
    cmd.each do |c|
      self.set_arr(tmp)
      self.rolls(c)
      if(self.top == dice.top)
        4.times do
          if(self.get_arr == dice.get_arr)
            return true
          else
            self.spin
          end
        end
      end
    end
    return false
  end
end

n = line[0].to_i
dice = []

(1..n).each do |num|
  arr = line[num].split(" ").map(&:to_i)
  dice << Dice.new(arr)
end

f = false
dice.combination(2).each do |dice1, dice2|
  f |= dice1.equal?(dice2)
end
puts "Yes" if f==false
puts "No" if f==true

Measured memory_bytes: 9816
#include <iostream>
#include <sstream>

using namespace std;

string change(const string &s)
{
    string ret;
    stringstream ss;

    for (int i = 0; i < s.size(); i++) {
        int num = 1;
        char ch = s[i++];

        while (i < s.size() && ch == s[i]) {
            num++;
            i++;
        }
        i--;

        ss << num;
        ret += ss.str();
        ss.str("");
        ret += (char)(ch);
    }

    return ret;
}

int main()
{
    int n;

    while (cin >> n, n) {
        string s;

        cin >> s;

        for (int i = 0; i < n; i++)
            s = change(s);

        cout << s << endl;
    }

    return 0;
}

Measured memory_bytes: 1360
#include "bits/stdc++.h"
 
using namespace std;
 
constexpr long long int MOD = 1000000007;
//constexpr int MOD = 1000000007;
//constexpr int MOD = 998244353;
//constexpr long long int MOD = 998244353;
constexpr double EPS = 1e-12;
 
//int N, M, K, T, H, W, L, R;
long long int N, M, K, T, H, W, L, R;
 
 
int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
 
	cin >> H >> W;
	int sy, sx, gy, gx;
	cin >> sy >> sx >> gy >> gx;
	sy--, sx--, gy--, gx--;
	vector<string>s(H);
	for (auto &i : s)cin >> i;
	vector<vector<int>>dis(H, vector<int>(W,MOD));
	deque<pair<int, int>>Q;
	Q.push_back({ sy,sx });
	dis[sy][sx] = 0;
	int dir[] = { 1,0,-1,0,1 };
	while (!Q.empty()) {
		int cy, cx;
		tie(cy, cx) = Q.front();
		Q.pop_front();
		for (int i = 0; i < 4; i++) {
			int ny = cy + dir[i];
			int nx = cx + dir[i + 1];
			if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
			if (s[ny][nx] == '#')continue;
			if (dis[ny][nx] > dis[cy][cx]) {
				dis[ny][nx] = dis[cy][cx];
				Q.push_front({ ny,nx });
			}
		}
		for (int i = -2; i <= 2; i++) {
			for (int j = -2; j <= 2; j++) {
				int ny = cy + i;
				int nx = cx + j;
				if (ny < 0 || nx < 0 || ny >= H || nx >= W)continue;
				if (s[ny][nx] == '#')continue;
				if (dis[ny][nx] > dis[cy][cx] + 1) {
					dis[ny][nx] = dis[cy][cx] + 1;
					Q.push_back({ ny,nx });
				}
			}
		}
	}
	if (dis[gy][gx] == MOD)dis[gy][gx] = -1;
	cout << dis[gy][gx] << endl;
}

Measured memory_bytes: 8680
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
#define REP(i, n) FOR(i, 0, n)
#define FOR(i, a, b) for (ll i = a; i < b; i++)
#define ALL(a) (a).begin(), (a).end()
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll, ll> pii;
const ll INF = 1LL << 58;
const ll MOD = 1000000007;
typedef vector<pii> vpii;
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

signed main()
{
    //  以降 cin の入力元が 'input.txt' になる
    //std::ifstream in("input.txt");
    //std::cin.rdbuf(in.rdbuf());
    string S;
    cin >> S;

    int m[2100];
    REP(i, 2100)
    {
        m[i] = 0;
    }
    m[0] = 1;
    int ten = 1;
    int temp = 0;
    REP(i, S.size())
    {
        ten %= 2019;
        temp += (ten * stoi(S.substr(S.size() - 1 - i, 1)));
        temp %= 2019;
        ten *= 10;
        m[temp]++;
    }
    int ans = 0;
    REP(i, 2019)
    {
        ans += (m[i] * (m[i] - 1)) / 2;
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;
int n,a[100002];
long long ans=0;
int dp[100002];
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a[i]);
		dp[i]=1000000007;
	}
	dp[1]=0;
	for(int i=1;i<=n;i++){
		if(i+1<=n){
			dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
		}
		if(i+2<=n){
			dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
		}
	}
	cout<<dp[n]<<endl;
	return 0;
}


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

int main(void)
{
    int count = 0;
    int a, b, c;
    cin >> a >> b >> c;
    for (int n = a; n <= b; n++) {
        if ((c%n) == 0)
            count++;
    }
    cout << count << endl;
    return 0;
}

Measured memory_bytes: 3104
import itertools

n = int(input())
l = list(map(int,input().split()))
count = 0

for v in itertools.combinations(l,3):
    if v[0] != v[1] and v[1] != v[2] and v[2] != v[0]:
        if v[0]+v[1] > v[2] and v[1]+v[2] > v[0] and v[2]+v[0] > v[1]:
            count += 1

print(count)

Measured memory_bytes: 9128
#include<cstdio>
#include<iostream>
#include<string>
#include<cstring>
using namespace std;
int H,W;
string s[30][30];
string tmp = "snuke";
int main()
{
	scanf("%d%d",&H,&W);
	for(int i=1;i<=H;i++)
	for(int j=1;j<=W;j++)
	{
		cin>>s[i][j];
	}
	for(int i=1;i<=H;i++)
	for(int j=1;j<=W;j++)
	if(s[i][j] == tmp)
	{
		char y = j+'A'-1;
		int x = i;
		printf("%c%d",y,x);
		break;
	}
	return 0;
}

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


int main(){
    ll a,b,c,k;
  	ll ans = 0;
    cin >> a >> b >> c >> k;
    if(k<=a) ans = k;
    else if(k <= a+b) ans = a;
    else ans = a-(k-a-b);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3600
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define INF 1LL<<62
#define inf 1000000007

int main() {
	ll n;
	cin>>n;
	ll a[100010],cnt=0;
	for(ll i=0;i<n;i++){
		cin>>a[i];
		if(i%2!=0){
			cnt-=a[i];
		}
		else{
			cnt+=a[i];
		}
	}
	cout << cnt<< " ";
	for(ll i=0;i<n-1;i++){
		cnt=a[i]-cnt/2;
		cnt*=2;
		cout << cnt << " ";
	}
	// your code goes here
	return 0;
}

Measured memory_bytes: 2048
N = int(input())
A = list(map(int, input().split()))
cnt = 0

if N == 1:
    print(0)
    exit()

for i in range(1, N):
    if A[i] >= A[i - 1]:
        continue
    else:
        cnt += A[i - 1] - A[i]
        A[i] = A[i - 1]
print(cnt)


Measured memory_bytes: 94088
#include<bits/stdc++.h>
using namespace std;
string st;
int main()
{
    cin>>st;
    if(st[0]=='Y' && st[1]=='A' && st[2]=='K' && st[3]=='I') cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}

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

using namespace std;

int main() {
    unsigned int N;
    cin >> N;

    vector<unsigned int> A(N);
    for (int i=0; i<N; i++) {
        unsigned int a;
        cin >> a;
        A[i] = a;
    }
    sort(A.begin(), A.end());
    
    unsigned int prev = 0;
    vector<unsigned int> compA {};
    map<unsigned int, int> cntA {};
    for (int i=0; i<N; i++) {
        if (prev != A[i]) {
            compA.push_back(A[i]);
            cntA.insert(make_pair(A[i], 1));
            prev = A[i];
        } else {
            cntA[A[i]]++;
        }
    }

    int ans = 0;
    int hbit = 31;
    for (int i = compA.size()-1; i >= 0; i--) {
        unsigned int a = compA[i];
        //cout << a << endl;
        while ((a & (1 << hbit)) == 0) {
            hbit--;
        }

        unsigned int p = ((~a << (31-hbit)) >> (31-hbit)) + 1;
        //cout << "a: " << a << endl;
        //cout << "p: " << p << endl;
        if (a == p) {
            ans += cntA[a]/2;
        } else {
            int anum = cntA[a];
            int pnum = 0;
            if (binary_search(compA.begin(), compA.end(), p)) {
                pnum = cntA[p];
            }
            if (anum < pnum) {
                ans += anum;
                cntA[p] -= anum;
            } else {
                ans += pnum;
                cntA[p] -= pnum;
            }
        }
    }

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 20596
#include<iostream>
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<queue>
using namespace std;
template<typename __T>
inline void read(__T &x)
{
    x=0;
    int f=1;char c=getchar();
    while(!isdigit(c)){if(c=='-')	f=-1;c=getchar();}
    while(isdigit(c))	{x=x*10+c-'0';c=getchar();}
    x*=f;
}
const int mod=998244353;
int C[4005][4005];
int p2[4005];
int calc(int n,int m)
{
	return C[n+m-1][m-1];
}
int vv(int n,int k,int i)
{
	int ans=0;
	int lim=i-1;
	if(i>k)	lim=2*k-i+1;
	for(int j=0;j<=lim/2;j++)
		ans=(ans+1ll*p2[j]*C[lim/2][j]%mod*calc(n-j,k-lim+j))%mod;
	return ans;
}
int main()
{
	int n,k;
	cin>>k>>n;
	C[0][0]=1;
	for(int i=1;i<=4000;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%mod;
	}
	p2[0]=1;
	for(int i=1;i<=4000;i++)
		p2[i]=p2[i-1]*2%mod;
	for(int i=2;i<=2*k;i++)
	{
		long long ans=0;
		if(i&1)
			ans=vv(n,k,i);
		else
			ans=(vv(n,k-1,i-1)+vv(n-1,k-1,i-1))%mod;
		cout<<ans<<endl;
	}
	return 0;
}


Measured memory_bytes: 61440
#include <bits/stdc++.h> 
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define all(vec) vec.begin(), vec.end()
#define tmax(x,y,z) max((x),max((y),(z)))
#define tmin(x,y,z) min((x),min((y),(z)))
typedef long long ll;ll MM = 1000000000;ll mod = MM + 7; ll MMM=9223372036854775807;//2^63 -1
ll GCD(ll x, ll y) {if (y == 0) return x;else return GCD(y, x % y);}
ll LCM(ll x, ll y) { return x / GCD(x, y) * y;}
//cout << fixed << setprecision(10);

int main(){
 ll ans=0,n,k,r,s,p; cin>>n>>k>>r>>s>>p;
  string t; cin>>t;
bool rr=false,ss=false,pp=false;
  for(ll j=0;j<k;j++){
  ll i=j;
  char pre='a';
    while(i<n){
  if(t[i]=='r'){
   if(pre!='r'){ans+=p; pre='r';}
    else  pre='a';
        }
    else if(t[i]=='s'){
         if(pre!='s')  {ans+=r;pre='s';}
      else  pre='a';
                      }
    else if(t[i]=='p'){
      if(pre!='p'){ans+=s;pre='p';}
      else  pre='a';
        
  } 
    i+=k;
  }
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 512
H = int(input())
W = int(input())
N = int(input())

X = 0

if H <= W:
  X = N // W
  if N % W != 0:
    X = X + 1
else :
  X = N // H
  if N % H != 0:
    X = X + 1
  
print(X)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  for(int i=0;i<(n);++i)
#define FORq(i, m, n) for(int i = (m);i <= (n);++i)
#define SCD(n) scanf("%d",&n)
#define SCD2(m,n) scanf("%d%d",&m,&n)
#define SCD3(m,n,k) scanf("%d%d%d",&m,&n,&k)
#define SCLLD(n) scanf("%lld",&n)
#define SCLLD2(m,n) scanf("%lld%lld",&m,&n)
#define SCLLD3(m,n,k) scanf("%lld%lld%lld",&m,&n,&k)
#define PB push_back
#define MP make_pair
#define ARSCD(A,N) REP(i,N){SCD(A[i]);}
#define ARSCD1(A,N) FORq(i,1,N){SCD(A[i]);}
#define PRINTD(n) printf("%d\n",n)
#define PRINTLLD(n) printf("%lld\n",n)
#define DEBUG printf("%s\n","debug")
#define fst first
#define snd second
#define IN(x,S) (S.count(x) != 0)
using namespace std;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector < VI > VVI;
typedef long long ll;
/////////////////////////(๑•﹏•๑｀)/////////////////////////
int main() {
	ll N; SCLLD(N);
	vector<ll> a;
	REP(i,N){
		ll x; SCLLD(x);
		a.PB(x);
	}

	ll ans = 0;
	ll MOD = 1;
	REP(i,a.size()){
		MOD = MOD * a[i];
	}


	REP(i,a.size()){
		ans += a[i] - 1;
	}

	PRINTLLD(ans);
	return 0;
}

Measured memory_bytes: 256
a,b,c = map(int,input().split())
if a==b==c and a%2==1:
    print(0)
elif a==b==c and a%2==0:
    print("-1")
else:
    cnt = 0
    while all(i&1==0 for i in [a,b,c]):
        A = a
        B = b
        C = c
        a = (B+C)//2
        b = (A+C)//2
        c = (A+B)//2
        cnt += 1
    print(cnt)


Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// TODO 自動生成されたメソッド・スタブ
		Scanner scanner = new Scanner(System.in);
		int n = scanner.nextInt();
		int[] a = new int[n];
		int count=0;
		for(int i=0 ; i<n ; i++) {
			a[i] = scanner.nextInt();
		}
		for(int i=0 ; i<a.length ; i=i+2) {
			if(a[i]%2 == 1) {
				count++;
			}
		}

		System.out.println(count);

		scanner.close();

	}

}

Measured memory_bytes: 35632
#coding: UTF-8

import sys

class Algo:
  @staticmethod
  def insersion_sort(A, N):
    for i in range(1, N):
      for k in A:
        if k==A[len(A)-1]:
          print(k)
        else:
          print(k, " ", sep="", end="")
      v = A[i]
      j = i-1
      while j >= 0 and A[j] > v:
        A[j+1] = A[j]
        j -= 1
      A[j+1] = v
    for k in A:
      if k==A[len(A)-1]:
        print(k)
      else:
        print(k, " ", sep="", end="")

N = int(input())
A = list(map(int, input().split()))
Algo.insersion_sort(A, N)

Measured memory_bytes: 6316
H, W, K = gets.chomp.split.map(&:to_i)
c = []
H.times do
  c.push gets.chomp.each_char.to_a
end

count = 0
(0..H).each{ |h|
  (0..(H-1)).to_a.combination(h).each{ |his|
    (0..W).each{ |w|
      (0..(W-1)).to_a.combination(w).each{ |wis|
        a = c.select.with_index{ |eh,ih|
          ! his.include?(ih)
        }.map{ |ch|
          ch.select.with_index{ |ew,iw|
            ! wis.include?(iw)
          }
        }
        if a.flatten(2).select{|e| e == "#"}.size == K
          count += 1
        end
      }
    }
  }
}

puts count


Measured memory_bytes: 14320
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < n; ++i)
#define rep2(i,s,n) for (int i = s; i < n; ++i)
#define all(a) a.begin(),a.end()
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
    int n,k;
    cin >> n >> k;
    int ans = 0;
    rep(i,n) {
        int x;
        cin >> x;
        ans += 2*min(abs(x-0),abs(x-k));
    }
    cout << ans << endl;
}

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

int main(){
  int m, f, r;
  char grade;
  while (true) {
    cin >> m >> f >> r;
    if (m == -1 && f == -1 && r == -1){
      break; 
    }
    if (m == -1 || f == -1) {
      grade = 'F';
    } else if (m + f >= 80) {
      grade = 'A';
    } else if (m + f >= 65) {
      grade = 'B';
    } else if (m + f >= 50) {
      grade = 'C';
    } else if (m + f >= 30) {
      grade = 'D';
      if (r >= 50){
        grade = 'C';
      }
    } else if (m + f < 30) {
      grade = 'F';
    }
    cout << grade << endl;
  }
  return 0;
}


Measured memory_bytes: 3120
$d = {}
def insert(str)
  $d[str] = str
end

def find(str)
  if $d[str]
    puts "yes"
  else
    puts "no"
  end
end

n = gets.chomp.to_i
commands=[]
n.times do
  commands.push(gets.chomp)
end
commands.each do |cmd|
  opn, opd = cmd.split(" ")
  send(opn, opd)
end



Measured memory_bytes: 124636
n,t = map(int,input().split())
ct = [list(map(int,input().split())) for i in range(n)]
T = []

for h in range(n):
  T.append(ct[h][1])
  
if min(T) > t:
  print("TLE")
  exit()
else:
  for j in range(n):
    if ct[j][1] <= t:
      c = ct[j][0]
      k = j
      break
 

for i in range(k+1,n):
  if ct[i][1] <= t:
    c = min(c,ct[i][0])
    
print(c)

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

int main() {
  int N;
  cin >> N;
  vector<int> sub(N, 0);
  for (int i = 0; i < N - 1; i++) {
    int a;
    cin >> a;
    sub.at(a - 1)++;
  }
  for (int i = 0; i < N; i++) {
    cout << sub.at(i) << endl;
  }
}

Measured memory_bytes: 4024
n = int(input())
a = list(map(int, input().split()))
a = sorted(a, reverse=True)

flag = True
pairs = []
for i in range(1, len(a)):
    if flag:
        if a[i] == a[i-1]:
            pairs.append(a[i])
            if len(pairs) == 2:
                print(pairs[0]*pairs[1])
                exit()
            flag = False
    else:
        flag = True
print(0)


Measured memory_bytes: 14252
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;
typedef long long ll;
const int MAXN = 1e5+10;

int n;
string s[MAXN];

void solve() {
  map<string, ll> m;
  for (int i=0;i<n;i++) {
    sort(s[i].begin(), s[i].end());
    m[s[i]]++;
  }
  ll sum = 0;
  for (auto x : m) {
    sum += x.second * (x.second - 1) / 2;
  }
  cout << sum << endl;
}

int main() {
  cin >> n;
  for (int i=0;i<n;i++) {
    cin >> s[i];
  }
  solve();
}


Measured memory_bytes: 18176
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define fi first
#define se second
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
typedef pair<ll,Pll> PlP;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

vector<ll> pickdiv(ll n){
    vector<ll> res;
    for(ll i=1; i*i <=n;i++){
        if(n%i)continue;
        res.emplace_back(i);
        ll q = n/i;
        if(q != i){
            res.emplace_back(q);
        }
    }
    return res;
}

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    vector<ll> a(N+1);
    REP(i,1,N+1){
        ll cur = i;
        while(cur <= N){
            a[cur]++;
            cur += i;
        }
    }
    REP(i,1,N){
        ans += a[i];
    }
    cout << ans << endl;
}

Measured memory_bytes: 11172
import sys
sys.setrecursionlimit(10**6)

#def input():
#  return sys.stdin.readline()[:-1]

n,q=map(int,input().split())
cnt=[0]*(n)
g=[[] for _ in range(n)]
for _ in range(n-1): #木グラフの隣接リストを作成
  a,b=map(int,input().split())
  g[a-1].append(b-1)
  g[b-1].append(a-1)
for _ in range(q):
    a , b = map(int,input().split())
    a = a - 1
    cnt[a] += b

def dfs(now,prev=-1):
  for next in g[now]:
    if next==prev:
      continue
      
    cnt[next]+=cnt[now]
    dfs(next,now)
dfs(0)
print(*cnt)

Measured memory_bytes: 283008
#include <stdio.h>

#define	N 100

int main(void)
{
  int n;
  char s[N], t[N];

  scanf("%d", &n);
  scanf("%s %s", s, t);

  for(int i=0; i<n; i++) {
    printf("%c%c", s[i], t[i]);
  }
  printf("\n");

  return 0;
}

Measured memory_bytes: 128
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <array>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <vector>

using namespace std;
int keta(long long n)
{
	return (int)log10(n) + 1;
}

int main(void)

{
	cin.tie(0);
	ios::sync_with_stdio(false);
	long long N;
	cin >> N;
	vector<long long> result;
	for (long long i = 1; i * i <= N; i++)
	{

		if (N % i == 0)
		{
			int tmp = max(keta(i), keta(N / i));
			result.push_back(tmp);
		}
	}
	cout << *min_element(result.begin(), result.end());
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <map>
#include <cmath>
#include <iomanip>
#include <queue>
#include <stack>
#include <functional>
#define rep(i,n) for(int i=0;i<n;i++)
using ll = long long;
using namespace std;
int main() {
	ll n, m, ans = 0, A[101010];
	cin >> n >> m >> ans;
	cout << (n + m)*ans / 2 << endl;
	return 0;
}


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

using namespace std;

using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  int n, k;
  cin >> n >> k;
  cout << n - k + 1 << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
 
int main() {
	// your code goes here
char s[15],t[15];
cin>>s>>t;
int l,i,c=0;
l=strlen(s);
for(i=0;i<l;i++)
{
    if(s[i]==t[i])
    c++;
}
if(c==l)
cout<<"Yes";
else
cout<<"No";
}


Measured memory_bytes: 3600
#include<iostream>
#include<vector>
#include<algorithm>

using namespace std;

int a;
vector<int> vec;
int main(){
	for(int i=0;i<3;i++){
    	cin >> a;
      	vec.push_back(a);
    }
  	sort(vec.begin(),vec.end());
  	cout << vec[0]+vec[1]+vec[2]*10 << '\n';
  	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#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 LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

#define int ll //!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!

typedef vector<int> vi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef vector<pii> vp;

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


signed main(void) {
    int n,m;
    cin >> n >> m;
    vi a(n),b(m);
    rep(i,n)cin >> a[i];
    rep(i,m)cin >> b[i];
    int ans = 0;
    rep(i,m){
        int p = 0;
        rep(j,m-i){
            while(p < n && a[p] != b[i+j])p++;
            ans = max(ans,j);
            if(p == n)break;
            p++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 3192
s=sorted(input())
t=sorted(input())[::-1]
for i in range(min(len(s),len(t))):
    if s[i]<t[i]:
        print("Yes")
        break
    elif s[i]>t[i]:
        print("No")
        break
else:
    if len(s)<len(t):
        print("Yes")
    else:
        print("No")

Measured memory_bytes: 3060