akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<list>
#include<set>
#include<map>
#include<utility>
#include<cmath>
#include <iomanip>


#define rep(i,x) for(int i=0;i<(int)(x);i++)
#define reps(i,x) for(int i=1;i<=(int)(x);i++)
#define rrep(i,x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(int i=((int)(x));i>0;i--)

#define all(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
#define INF 2e9

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
typedef long long ll;
typedef long double ld;
int gcd(int a,int b){return b?gcd(b,a%b):a;}

using namespace std;

int main()
{
    ll n, m;
    cin >> n >> m;
    pair<ll, ll> p;
    p.first = 1;
    p.second = n;

    ll flag = 1;

    rep(i, m){
        ll l, r;
        cin >> l >> r;
        if(l > p.second || r < p.first){
            flag = 0;
        }
        if(l > p.first) p.first = l;
        if(r < p.second) p.second = r;
    }

    if(flag == 0){
        cout << 0;
    }else{
        cout << p.second - p.first + 1;
    }

}


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

void dfs(int in, int color,
    const vector<vector<int>>& graph,
    vector<int>& colors) 
{
    vector<bool> checkList(colors.size());
    stack<int> stack;
    stack.push(in);
    colors[in] = color;

    while (!stack.empty())
    {
        int x = stack.top();
        bool canLeave = true;
        for (const auto& g : graph[x]) {
            if (colors[g] == 0) {
                stack.push(g);
                colors[g] = color;
                checkList[g] = true;
                canLeave = false;
            }
        }
        if (canLeave) {
            stack.pop();
        }
    }
}

void wfs(int in, int color,
    const vector<vector<int>>& graph,
    vector<int>& colors)
{
    queue<int> queue;
    queue.push(in);
    vector<bool> checkList(colors.size());
    while (!queue.empty()) 
    {
        int x = queue.front();
        queue.pop();
        colors[x] = color;
        for (auto y : graph[x]) {
            if (!checkList[y]) {
                queue.push(y);
                checkList[y] = true;
            }
        }
    }
}

int main() {
    int n;
    int m;
    cin >> n >> m;
    vector<vector<int>> tree(n);
    vector<int> colors(n);

    for (int i = 0; i < m; ++i) {
        int s, t;
        cin >> s >> t;
        tree[s].push_back(t);
        tree[t].push_back(s);
    }
    int color = 0;
    for (int i = 0; i < n; ++i) {
        if (colors[i] != 0) {
            continue;
        }
        wfs(i, ++color, tree, colors);
        //dfs(i, ++color, tree, colors);
    }

    int qNum;
    cin >> qNum;
    vector<pair<int, int>> question(qNum);
    for (auto& q : question) {
        cin >> q.first >> q.second;
    }

    for (const auto& q : question) {
        if (colors[q.first] == colors[q.second]) {
            cout << "yes" << endl;
        }
        else {
            cout << "no" << endl;
        }
    }
}


Measured memory_bytes: 8896
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
signed main() { 
  ios::sync_with_stdio(false); cin.tie(0);
  int n;
  cin >> n;
  vector<string> s(n);
  vector<int> t(n);
  for (int i = 0; i < n; i++) {
    cin >> s[i] >> t[i];
  }
  string x;
  cin >> x;
  bool passed = false;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (passed) ans += t[i];
    if (s[i] == x) passed = true;
  }
  cout << ans << '\n';
  return 0;
}

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

using namespace std;

struct Initializer {
  Initializer() {
    cin.tie(0);
    ios::sync_with_stdio(0);
    cout << fixed << setprecision(15);
  }
} initializer;

template<typename T> inline istream& operator>>(istream &s, vector<T> &v) {
  for (T &t : v) s >> t;
  return s;
}

template<typename T> inline ostream& operator<<(ostream &s, const vector<T> &v) {
  for (const T &t : v) s << t << endl;
  return s;
}

template<typename T> inline T min(vector<T>& v) {return *min_element(v.begin(), v.end());}

template<typename T> inline T max(vector<T>& v) {return *max_element(v.begin(), v.end());}

template<typename T> inline void sort(vector<T>& v) {sort(v.begin(), v.end());}

template<typename T, typename Function> inline void sort(vector<T>& v, Function func) {sort(v.begin(), v.end(), func);}

template<typename T> inline void rsort(vector<T>& v) {sort(v.rbegin(), v.rend());}

template<typename T> inline void reverse(vector<T>& v) {reverse(v.begin(), v.end());}

template<typename T> inline void unique(vector<T>& v) {v.erase(unique(v.begin(), v.end()), v.end());}

template<typename T> inline void nth_element(vector<T>& v, int n) {nth_element(v.begin(), v.begin() + n, v.end());}

template<typename T> inline bool next_permutation(vector<T>& v) {return next_permutation(v.begin(), v.end());}

template<typename T> inline int find(vector<T>& v, T t) {return find(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int in(vector<T> v, T t) {return find(v, t) != (int)v.size();}

template<typename T> inline int lower_bound(vector<T>& v, T t) {return lower_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline int upper_bound(vector<T>& v, T t) {return upper_bound(v.begin(), v.end(), t) - v.begin();}

template<typename T> inline T accumulate(const vector<T>& v) {return accumulate(v.begin(), v.end(), T(0));}

template<typename T> inline void adjacent_difference(vector<T>& v) {adjacent_difference(v.begin(), v.end(), v.begin());}

template<typename T> inline void adjacent_difference(vector<T>& v, vector<T>& u) {adjacent_difference(v.begin(), v.end(), u.begin());}

template<typename T> inline void partial_sum(vector<T>& v, vector<T>& u) {partial_sum(v.begin(), v.end(), u.begin());}

template<typename T> inline T inner_product(vector<T>& v, vector<T>& u) {return inner_product(v.begin(), v.end(), u.begin(), T(0));}

template<typename T, typename Function> inline int count_if(vector<T> v, Function func) {return count_if(v.begin(), v.end(), func);}

template<typename T, typename Function> inline void remove_if(vector<T>& v, Function func) {v.erase(remove_if(v.begin(), v.end(), func), v.end());}

template<typename T, typename Function> inline bool any_of(vector<T> v, Function func) {return any_of(v.begin(), v.end(), func);}

template<typename T> inline vector<T> subvector(vector<T>& v, int a, int b) {return vector<T>(v.begin() + a, v.begin() + b);}

int main() {
  int64_t a, b, c;
  cin >> a >> b >> c;
  cout << min({a % 2 * b * c, b % 2 * a * c, c % 2 * a * b}) << endl;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

#素因数分解を行う関数O(root(N))
#int -> list
def factorize(x):
      res = []
      for i in range(2, int(x**0.5)+1):
          if x%i != 0:
              continue
          cnt = 0
          while x%i == 0:
              x //= i
              cnt += 1 
          res.append((i, cnt))
      if x != 1:
          res.append((x, 1))
      return res
 
def main():
    n = int(readline())
    if n == 1:
        print(0)
        return
    fact = factorize(n)
    num = [int(i) for i in range(50)]
    def f(x):
        i = 2
        j = 2
        cnt = 1
        while 1:
            if x<=i:
                break
            cnt += 1
            j += 1
            i += j
        return cnt 
    ans = 0
    for i, j in fact:
        ans += f(j)
    print(ans)
if __name__ == '__main__':
    main()


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

int main(){
  while(1){
    int H, W;
    cin >> H >> W;
    if(H == 0 && W == 0) break;
    for(int i = 1; i <= H; i++){
      for(int j = 1; j <= W; j++){
        if(i != 1 && j != 1 && i != H && j != W){
          cout << ".";
        }else{
          cout << "#";
        }
      }
    cout << endl;
    }
  cout << endl;
  }

  return 0;
}

Measured memory_bytes: 1152
#include <iomanip>
#include <iostream>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
const int64_t mod = 1e9 + 7;

int main(void) {
  ios::sync_with_stdio(false);
  int64_t N, K;
  cin >> N >> K;

  int64_t answer = 1;
  int64_t min_num = 0;
  int64_t max_num = 0;
  for (int i = 0; i < K; ++i) {
    min_num += i;
    max_num += (N - i);
  }
  for (int i = K; i <= N; ++i) {
    answer = (answer + max_num - min_num + 1) % mod;
    min_num += i;
    max_num += (N - i);
  }
  cout << answer << endl;
  return 0;
}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define ll long long int
#define mod 1000000007
#define pii pair<int, int>
#define fr(n) for (int i = 0; i < n; i++)
#define fr1(n) for (int i = 1; i <= n; i++)
using namespace std;

int main() {
    ios::sync_with_stdio(false);
    int l;
    vector<pair<pii, int>> z;
    vector<bool> a;
    cin >> l;
    if (l == 1) {
        cout << 2 << ' ' << 1 << '\n';
        cout << 1 << ' ' << 2 << ' ' << 0 << '\n';
        return 0;
    }
    while (l > 1) {
        if (l & 1) a.push_back(1);
        else a.push_back(0);
        l >>= 1;
    }
    reverse(a.begin(), a.end());
    int c = 1, n = 0, m = 0;
    fr(a.size()) {
        z.push_back({{i + 1, i + 2}, 0});
        z.push_back({{i + 1, i + 2}, c});
        n = i + 2;
        m++, m++;
        c <<= 1;
        if (a[i]) z.push_back({{1, i + 2}, c}), m++, c++;
    }
    cout << n << ' ' << m << '\n';
    fr(m) cout << z[i].first.first << ' ' << z[i].first.second << ' ' << z[i].second << '\n';
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define int long long
#define endl '\n'
#define pb push_back
#define fi first
#define se second
#define all(c) (c).begin(),(c).end()
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;

template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

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

const ll inf = 2e18;
const int mod = 1e9 + 7;
const int N = 1e5 + 10;

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

	int a, b, m;
	cin >> a >> b >> m;
	int ar1[a], ar2[b];
	for(int i = 0; i < a; i++) {
		cin >> ar1[i];
	}
	for(int i = 0; i < b; i++) {
		cin >> ar2[i];
	}
	int ans = *min_element(ar1, ar1 + a) + *min_element(ar2, ar2 + b);
	for(int i = 0; i < m; i++) {
		int x, y, t;
		cin >> x >> y >> t;
		ans = min(ans, ar1[x - 1] + ar2[y - 1] - t);
	}
	cout << ans;

	return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <string>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#define int long long 
#define mod (1e9 + 7)
#define pb push_back
using namespace std;
typedef pair<int,int> pii;

signed main(){

  int n,m;
  cin>>n>>m;

  priority_queue<int,vector<int>, greater<int> > q;
  int a;
  for(int i=0;i<n;i++){
    cin>>a;
    q.push(a);
  }

  int b,c;
  vector<pii> bc;
  for(int i=0;i<m;i++){
    cin>>b>>c;
    bc.pb(pii(c,b));
  }

  sort(bc.begin(),bc.end(),greater<pii>());
  for(int i=0;i<m;i++){
    if(q.top()<bc[i].first){

      for(int j=0;j<bc[i].second;j++){
        if(q.top()>=bc[i].first) break;
        q.pop();
        q.push(bc[i].first);
      }
    }
    //cout<<bc[i].first<<" "<<bc[i].second<<endl;
  }

  int res=0;
  for(int i=0;i<n;i++){
    res+=q.top();
    q.pop();
  }
  cout<<res<<endl;

  return 0;
}



Measured memory_bytes: 3188
K = int(input())
A,B = map(int,input().split())
flag = False
x = 0
while True:
  if K*x > B:
    break
  if A <= K*x and B >= K*x:
    flag = True
  x += 1
if flag == True:
  print("OK")
else:
  print("NG")

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

int main(void) {
	int N;
	scanf("%d", &N);
	int H[20];
	int ans = 0;
	int HMax = 0;
	for (int i = 0; i < N; i++) {
		scanf("%d", &H[i]);
		if (H[i] >= HMax) ans++;
		HMax = max(HMax, H[i]);
	}

	printf("%d\n", ans);
	return 0;
}


Measured memory_bytes: 3788
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define SZ size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define S second
#define ld long double
#define eps 0.00000000001
#define MAX 1000000007
#define vll vector <ll> 
#define pll pair <ll,ll> 

using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ll powc(ll a, ll b){
    if(b<0){
        return -1;
    }
    ll res=1;
    while(b>0){
        if(b&1){
            res*=a;
        }
        a*=a;
        res%=m9, a%=m9;
        b>>=1;
    }
    return res;
}


int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); 
    ll n , d;
    cin>>n>>d;
    ll ans=0;
    REP(i,0,n){
        ld x, y;
        cin>>x>>y;
        if((ld)sqrt(x*x+y*y)<=(ld)d){
            ans++;
        }

    }
    cout<<ans;
}       

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

int main(){
    int N;
    cin >> N;
    vector<int> vec(N), a(N);
    for (int i=0; i<N; i++) cin >> vec.at(i);

    a.at(0) = 0;
    int sum = 0;
    bool exist = false;

    for (int i=0; i<N-1; i++){
        sum++;
        a.at(i+1) = (vec.at(a.at(i))-1);
        if ((vec.at(a.at(i))-1) == 1) {
            exist = true;
            break;
        }
    }

    if (exist) cout << sum << endl;
    else cout << -1 << endl;    
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<ll, ll> P;
ll Mod = 1000000007;
int main() {
  string S;
  cin >> S;
  ll ans = 0;
  ll power2[114514];
  ll power3[114514];
  power2[0] = 1;
  power3[0] = 1;
  for (int i = 1; i < 114514; i++) {
    power2[i] = power2[i-1] * 2;
    power3[i] = power3[i-1] * 3;
    power2[i] %= Mod;
    power3[i] %= Mod;
  }
  int N = S.size();
  vector<ll> one;
  for (int i = 0; i < (int)S.size(); i++) {
    if (S[i] == '1') {
      one.push_back(i);
    }
  }
  for (int i = 0; i < (int)one.size(); i++) {
    ans += (power2[i] * power3[N - one[i] - 1]) % Mod;
    ans %= Mod;
  }
  ans += power2[(int)one.size()];
  ans %= Mod;
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6084
<?php
/*
    Problem URL : http://abc053.contest.atcoder.jp/tasks/abc053_b

    Score  :
    Result :
    Time   : ms
    Memory : KB
 */

fscanf(STDIN, "%s ", $s);

$posA = strpos($s, 'A');
$posZ = strrpos($s, 'Z');

echo ($posZ - $posA + 1) . PHP_EOL;


Measured memory_bytes: 4728
cache = {}
def gcd(a, b):
    if (a, b) in cache: 
        return cache[(a, b)]
    result = b if a % b == 0 else gcd(b, a % b)
    cache[(a, b)] = result
    cache[(b, a)] = result
    return result
def count(nums):
    freq = {}
    for n in nums:
        freq[n] = True
    if len(freq) == 1: return 1
    if len(freq) == 2: return 3
    return 6

k = int(input())
k += 1
s = 0
for i in range(1, k):
    for j in range(i, k):
        t = gcd(i, j)
        for l in range(j, k):
            s += gcd(t, l) * count([i, j, l])
print(s)

Measured memory_bytes: 12852
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <vector>
#define REP(i, n) for (int i = 0; i < (n); i++)
#define ALL(vec) (vec).begin(), (vec).end()
#define SUM(...) accumulate(ALL(__VA_ARGS__),0LL)
#define DSUM(...) accumulate(ALL(__VA_ARGS__),0.0)
using namespace std;
using ll = long long;
using P = pair<int, int>;

// 便利関数
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}
inline ll gcd(ll a,ll b){if(b == 0) return a;return  gcd(b,a%b);}
inline ll lcm(ll a,ll b){ll g = gcd(a,b);return a / g * b;}

// 出力
void print() { std::cout << '\n'; }
template <class T>void print(const T &x) {std::cout << x <<'\n';}
template <class T, class... Args>void print(const T &x, const Args &... args) {std::cout << x << " ";print(args...);}

const int INF = 2002002002;

void solve(long long a, long long b){
    char A = a + '0';
    char B = b + '0';
    string strA, strB;
    REP(i, b) strA += A;
    REP(i, a) strB += B;
    print(min(strA, strB));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long a;
    scanf("%lld",&a);
    long long b;
    scanf("%lld",&b);
    solve(a, b);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <algorithm>

using namespace std;
 
    
    
int main(){
  char contest[3];
  cin>>contest;
  if (contest[1]=='B'){
    contest[1]='R';
  }else{
    contest[1]='B';
  }
  cout<<contest<<endl;
  
    return 0;
}

Measured memory_bytes: 3044
package main

import (
	"fmt"
)

func main() {

	for {
		//n := ScanedLinetoIntSlice()
		//H, W
		//H := n[0]
		//W := n[1]

		var H, W int

		fmt.Scanln(&H, &W)

		if H == 0 && W == 0 {
			break
		}
		for i := 0; i < H; i++ {
			for j := 0; j < W; j++ {
				fmt.Printf("#")
			}
			fmt.Printf("\n")
		}
			fmt.Printf("\n")

	}

}

/*
func ScanedLinetoIntSlice() []int {

	var sc = bufio.NewScanner(os.Stdin)
	sc.Scan()
	line := sc.Text()

	words := strings.Fields(line)

	var numbers []int

	for _, v := range words {
		number, _ := strconv.Atoi(v)
		numbers = append(numbers, number)
	}

	return numbers
}
*/



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

#define PI 3.141592653589

int main(void) {
	double x,y;
	int angle;
	int a,b;
	x=0;y=0;
	angle=90;
	do {
		scanf("%d,%d",&a,&b);
		x+=cos(angle*PI/180)*a;
		y+=sin(angle*PI/180)*a;
		angle-=b;
	} while(a!=0 && b!=0);
	printf("%d\n",(int)x);
	printf("%d\n",(int)y);
	return 0;
}

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

#define ff first
#define endl "\n"
#define ss second
using namespace std;
#define maxn 2000006
#define pb push_back
#define ll long long
#define lll __int128
#define vll vector<ll>
#define mll map<ll,ll>
#define MOD 1000000007
#define pll pair<ll,ll>
#define ull unsigned long long
#define f(i,x,n) for(ll i=x;i<=n;i++)
#define fr(i,x,n) for(ll i=x;i>=n;i--)
inline ll min(ll a, ll b, ll c) { return min(min(a, b), c);}
inline ll max(ll a, ll b, ll c) { return max(max(a, b), c);}
inline void fastio(){ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL);}

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



int main(){
	fastio();

	ll h,n; cin>>h>>n;
	ll a[n+1]={}, b[n+1]={};
	f(i,1,n) cin>>a[i]>>b[i];

	ll dp[h+1]={};
	f(i,1,h){
		dp[i]=LLONG_MAX;
		f(j,1,n) dp[i]=min(dp[i],dp[max(0ll,i-a[j])]+b[j]);
	}

	cout<<dp[h];

	return 0;
}

Measured memory_bytes: 384
// Ref : https://book.mynavi.jp/ec/products/detail/id=35408

#include <iostream>
using namespace std;

#define N 8
#define FREE -1
#define NOT_FREE 1

int row[N], col[N], dpos[2 * N - 1], dneg[2 * N - 1];

bool X[N][N];

void initialize() {
	// 配置条件の配列の初期化
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) X[i][j] = false;
	}
	// 襲撃マップの配列の初期化
	for (int i = 0; i < N; i++) { row[i] = FREE, col[i] = FREE; }
	for (int i = 0; i < 2 * N - 1; i++) { dpos[i] = FREE, dneg[i] = FREE; }
}

void printBoard() {
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			if (X[i][j]) {
				// 与えられた配置を満足していけなければやり直し
				if (row[i] != j) return;
			}
		}
	}
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < N; j++) {
			cout << ( ( row[i] == j ) ? "Q" : "." );
		}
		cout << endl;
	}
}

// i行目のルーンの位置を探索をする再帰関数
void recursive(int i) {
	if (i == N) {
		printBoard();
		return;
	}
	for (int j = 0; j < N; j++) {
		// i, jにルーンがおける可能性がなければ無視
		if (col[j] == NOT_FREE ||
			dpos[i + j] == NOT_FREE ||
			dneg[i - j + N - 1] == NOT_FREE ) continue;
		// i, jにルーンを配置し、襲撃マップを更新
		row[i] = j; col[j] = dpos[i + j] = dneg[i - j + N - 1] = NOT_FREE;
		// 次の行に探索を進める
		recursive(i + 1);
		// i, jに配置した場合の探索が終わったので、襲撃マップを元に戻す
		col[j] = dpos[i + j] = dneg[i - j + N - 1] = FREE;
	}
}

int main() {
	initialize();

	int k; cin >> k;
	for (int i = 0; i < k; i++) {
		int r, c; cin >> r >> c;
		X[r][c] = true;
	}

	recursive(0);

	return 0;
}


Measured memory_bytes: 3104
N = int(input())
if N > 81:
  print("No")
elif N>=1 and N<=10:
  print("Yes")
elif N==12 or N==14 or N==15 or N==16 or N==18 or N==20 or N==21 or N==24 or N==25 or N==27 or N==28 or N==30 or N==32 or N==35 or N==36 or N==40 or N==42 or N==45 or N==48 or N==49 or N==54 or N==56 or N==63 or N==64 or N==72 or N==81:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
N, M = map(int, input().split())
MOD = 10**9 + 7

A = list(map(int, input().split()))
A = sorted([(a, i) for i, a in enumerate(A)])
B = list(map(int, input().split()))
B = sorted([(b, i) for i, b in enumerate(B)])

row = set(); col = set()
K = N * M
num = 0
ans = 1
for n in range(K, 0, -1):
  row_id = col_id = None
  if A:
    if A[-1][0] == n:
      row_id = A.pop()[1]
  if B:
    if B[-1][0] == n:
      col_id = B.pop()[1]
  if row_id is not None and col_id is not None:
    num += 1
    row.add(row_id); col.add(col_id)
  elif row_id is not None:
    ans *= len(col); ans %= MOD
    num += 1
    row.add(row_id)
  elif col_id is not None:
    ans *= len(row); ans %= MOD
    num += 1
    col.add(col_id)
  else:
    ans *= (len(row)*len(col) - num); ans %= MOD
    num += 1

print(ans)

Measured memory_bytes: 3316
using namespace std;
using ll=long long;
#include <string>
#include <vector>
#include <cmath>
#include <iostream>
#include <algorithm>
#define out(S) cout<<(S)<<endl;


int main()
{
	char c;
	cin >> c;
	if (c == 'a' || c == 'i' || c == 'u' || c == 'e' || c == 'o') {
		out("vowel");
	}
	else {
		out("consonant");
	}
}



Measured memory_bytes: 256
//Leonidas
#pragma GCC optimize("Ofast")
//#pragma GCC target ("avx2")
//#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container'.',hpp>
//#include <ext/pb_ds/tree_policy'.',hpp>
//typedef tree < int , null_type, less <int>, rb_tree_tag, tree_order_statistics_node_update> TREE;
#define ll long long
#define ull unsigned long long int
#define pb push_back
#define mp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define pss pair<short,short>
#define pld pair<long double,long double >
#define ld long double
#define piii  pair<pii,int>
#define vii vector<pair<int,int> >
#define st first
#define nd second
#define pll pair<ll,ll>
#define speed ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define M_PI 3.14159265358979323846
//#define int long long
const int mod=1e9+7;
//const int mod=1009;
//const int mod=998244353;
const int inf=1000000009;
const long long INF=1000000000000000009;
const long long big=1000000000000000;
const long double eps=0.000000000000000000001;
using namespace std;
int32_t main()
{
    speed
    int ile=0;
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        int a;
        cin>>a;
        if((a&1)&&(i&1))
            ile++;
    }
    cout<<ile;
    return 0;
}


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

using namespace std;

#define range(i, m, n) for(int i = m; i < n; i++)
#define husk(i, m, n) for(int i = m; i > n; i--)

int n;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.tie(0);
  cin >> n;
  vector<pair<int, int>> s(n);
  multiset<int> x, y;
  range(i, 0, n) {
    cin >> s[i].first >> s[i].second;
    x.insert(s[i].first);
    y.insert(s[i].second);
  }
  int res = 0;
  range(i, 0, n) {
    int cur = s[i].second - s[i].first + 1;
    x.erase(x.find(s[i].first));
    y.erase(y.find(s[i].second));
    cur += max(0, *y.begin() - *prev(x.end()) + 1);
    res = max(res, cur);
    x.insert(s[i].first);
    y.insert(s[i].second);
  }
  sort(s.begin(), s.end());
  vector<pair<int, int>> a;
  range(i, 0, n) {
    while(!a.empty() && a.back().second >= s[i].second) a.pop_back();
    if(a.empty() || a.back().first < s[i].first) a.push_back(s[i]);
  }
  int sz = a.size();
  range(i, 0, sz - 1) {
    int cnt = 0;
    int sx = a[i].first;
    int sy = a[0].second;
    cnt += max(0, sy - sx + 1);
    sx = a[sz - 1].first;
    sy = a[i + 1].second;
    cnt += max(0, sy - sx + 1);
    res = max(res, cnt);
  }
  cout << res;
  return 0;
}


Measured memory_bytes: 11640
#include<bits/stdc++.h>
const int maxn = 7920;
typedef long long ll;
typedef std::vector<ll> vec;
std::set<ll> a0,a1;
vec x0,x1;
int ok[maxn],n;
inline void init(std::set<ll>&s,vec&y){
	y.push_back(*s.begin()); s.erase(s.begin());
	const ll lim = 3e7;
	for(;s.size();){
		auto it = s.upper_bound(lim / *y.rbegin()); --it;
		y.push_back(*it); s.erase(it);
	}
}
int main() {
	std::ios::sync_with_stdio(false),std::cin.tie(0);
	for(int i = 2,c=0;i < maxn;++i)if(!ok[i]){
		(++c >> 1 & 1 ? a0 : a1).insert(i);
		for(int j = i;j < maxn;j += i)ok[j] = 1;
	}
	init(a0,x0), init(a1,x1);
	std::cin >> n;
	for(int i = 1;i <= n;++i) for(int j = 1;j <= n;++j) {
		if(i + j & 1) {
			std::cout << x0[i + j - 3 >> 1] * x1[i + n - j - 2 >> 1] * x0[i + j - 1 >> 1] * x1[i + n - j >> 1] + 1;
		} else {
			std::cout << x0[i + j - 2 >> 1] * x1[i + n - j - 1 >> 1];
		}
		std::cout << " \n"[j == n];
	}
}


Measured memory_bytes: 3328
#include "bits/stdc++.h"
#define YES "YES"
#define NO "NO"
#define Yes "Yes"
#define No "No"
#define DEFAULT LL ans=solve();\
 	if(ans==NONE){\
 	}else{\
 		cout << ans << endl;\
 	}
#define YESNO three(solve(),(OUT(YES),1),(OUT(NO),0))
#define YesNo three(solve(),OUT(Yes),OUT(No))
#define ECHO OUT(solve())
#define three(A,B,C) ((A)?(B):(C))
#define FOR(i,a,b)  for(LL i=(a);i< (LL)(b);i++)
#define EFOR(i,a,b) for(LL i=(a);i<=(LL)(b);i++)
#define RFOR(i,a,b) for(LL i=(b-1);i>=(LL)(a);i--)
#define REP(i,b) FOR(i,zero,b)
#define rep REP
#define EREP(i,b) EFOR(i,zero,b)
#define RREP(i,b) RFOR(i,zero,b)
#define ALL(c) c.begin(),c.end()
#define UNIQUE(c) sort(ALL(c));c.erase(unique(ALL(c)),c.end())
#define MAX(c) (*max_element(ALL(c)))
#define MIN(c) (*min_element(ALL(c)))
#define MP make_pair
#define FI first
#define SE second
#define SI(x) (LL(x.size()))
#define PB push_back
#define DEBUG(a) OUT(a)
#define DEBUG2(a,b) OUT2(a,b)
#define cat cout << __LINE__ << endl
#define OUT(a) cout << (a) << endl
#define OUT2(a,b) cout << (a) <<" "<<(b) << endl
#define zero 0LL
#define all ALL
#define pb emplace_back
#define eb pb
#define int long long
using namespace std;
template<typename T> inline void maximize(T &a, T b) { a = max(a, b); }
template<typename T> inline void minimize(T &a, T b) { a = min(a, b); }
template<typename T> inline bool middle(T a, T b, T c) { return b <= a && a <= c; }
template<class T> inline bool MX(T &l, const T &r) { return l < r ? l = r, 1 : 0; }
template<class T> inline bool MN(T &l, const T &r) { return l > r ? l = r, 1 : 0; }
typedef int LL;
typedef double ld;
typedef int ut;
typedef vector<ut> VI;
typedef vector<VI> VII;
typedef pair<ut, ut> pr;
typedef pair<ut, pr> ppr;
typedef vector<pr> Vpr;
typedef vector<ppr> Vppr;
typedef tuple<int, int, int, int> tapu;
typedef vector<tapu> Vtapu;
typedef priority_queue<pr, Vpr > PQ;
inline void outputVI(VI x) { REP(i, SI(x)) { cout << three(i, " ", "") << x[i]; }OUT(""); }
const int SIZE1 = 5e5 + 1000;
const int SIZE2 = 5010;
const int SIZE3 = 430;
const int SIZE = SIZE1;
const int MAPSIZE = 40;
const LL p998 = 998244353;
const LL p107 = 1000000007;
const LL p = p107;
const LL INF = 1LL << 60;
const long double EPS = 1e-7;
const LL NONE=-2;
#define endl "\n"
ut N, M,K,  Q, D, H, W;
VI edges[SIZE];
LL vals[SIZE], answer = zero;
//LL A[SIZE],B[SIZE],C[SIZE];
LL solve(){
	string s;
	cin >> s;
	if(((int)s.size())%2==1) return false;
	REP(i,s.size()){
		if(i%2 && s[i]!='i') return false;
		if(i%2==0 and s[i]!='h') return false; 
	}
	return true;
	return NONE;
}
 signed main() {
 
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(10);
	LL T=1;
	//cin >> T;
	REP(i,T){
//		DEFAULT;
		YesNo;
	}
	
//	YesNo;
//	YESNO;
//	three(solve(),OUT("First"),OUT("Second"));
	//cin >> N;
	return 0;
 
}


Measured memory_bytes: 13824
n, k = map(int, input().split())
a = [0 for i in range(n)]
for i in range(k):
    d = int(input())
    aa = list(map(int, input().split()))
    for i in aa:
        a[i-1] += 1

ans = 0
for i in range(n):
    if a[i-1] == 0:
        ans += 1

print(ans)


Measured memory_bytes: 9188
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i = 0;i < (n);i++)
using ll = long long;
const ll MOD=1000000007;
const long long INF = 1LL << 60;
const double pi=acos(-1);





int main() 
{
  ll N; cin>>N;
  ll ans=0;
  rep(i,N)
  {
    ll a; cin>>a;
    if(i%2==0&&a%2==1) ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 3636
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.BufferedReader;
import java.util.Hashtable;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        TaskC solver = new TaskC();
        solver.solve(1, in, out);
        out.close();
    }

    static class TaskC {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            Hashtable<String, Integer> table = new Hashtable<>();
            for (int i = 0; i < n; i++) {
                String s = in.next();
                int len = s.length();
                Character[] ar = new Character[len];
                for (int j = 0; j < len; j++)
                    ar[j] = s.charAt(j);
                Arrays.sort(ar);
                StringBuilder s2 = new StringBuilder();
                for (int j = 0; j < len; j++)
                    s2.append(ar[j]);
                String str = new String(s2);
                if (!table.containsKey(str)) {
                    table.put(str, 1);
                } else {
                    int old = table.get(str);
                    table.replace(str, old + 1);
                }
            }
            long ans = 0;
            for (String s : table.keySet()) {
                long rep = table.get(s);
                ans += (rep * (rep - 1)) / 2;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 72584
#include<stdio.h>

int main(void){
   int m,f,r;

   while(1){
      scanf("%d %d %d", &m, &f, &r);

      if(m==-1 && f==-1 && r==-1) break;

      if(m+f>=80) printf("A\n");
      else if(m+f<80 && m+f>=65) printf("B\n");
      else if(m+f<65 && m+f>=50) printf("C\n");
      else if(m+f<50 && m+f>=30 && m!=-1 && f!=-1){
         if(r>=50) printf("C\n");
         else printf("D\n");
      }
      else if(m+f<30 || m==-1 || f ==-1) printf("F\n");
   }
   return 0;
}



Measured memory_bytes: 2128
# coding: utf-8
# Your code here!
a,b,c = map(int,input().split())
count = 0
if a == b:
    if c % a == 0:
        print(1)
    else:
        print(0)
else:
    for i in range(a, b + 1, 1):
        if c % i == 0:
            count = count + 1
    print(count)


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

int main(){
  long n,a,b;
  cin >> n >> a >> b;
  if(n==1&&a!=b) cout << 0 << endl;
  else if(n==1&&a==b) cout << 1 << endl;
  else if(b-a<0) cout << 0 << endl;
  else cout << (n-2)*(b-a)+1 << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  int sx,sy,tx,ty;
  cin>>sx>>sy>>tx>>ty;
  int nx = sx;
  int ny = sy;
  while(ny < ty){
    cout << 'U';
    ny++;
  }
  while(nx < tx){
    cout << "R";
    nx++;
  }
  while(ny > sy){
    cout << "D";
    ny--;
  }
  while(nx > sx){
    cout << "L";
    nx--;
  }
  cout << "L";
  nx--;
  while(ny < ty+1){
    cout << "U";
    ny++;
  }
  while(nx < tx){
    cout << "R";
    nx++;
  }
  ny--;
  cout << "D";
  nx++;
  cout << "R";
  while(ny > sy-1){
    cout << "D";
    ny--;
  }
  while(nx > sx){
    cout << "L";
    nx--;
  }
  cout << "U";
  ny++;
  cout << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n;
    cin>>n;
    int h[n];
    for(int i=0;i<n;i++){
        cin>>h[i];
    }
    --h[0];
    bool can=true;
    for(int i=1;i<n;i++){
        if(h[i-1]<h[i])--h[i];
        else if(h[i-1]>h[i])can=false;
    }
    if(can)cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
}


Measured memory_bytes: 640
# -*- coding: utf-8 -*-
"""
A - Anti-Adjacency
https://atcoder.jp/contests/yahoo-procon2019-qual/tasks/yahoo_procon2019_qual_a

"""
import sys


def solve(N, K):
    if (N+1) //2 >= K:
        return 'YES'
    return 'NO'


def main(args):
    N, K = map(int, input().split())
    ans = solve(N, K)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3064
import sys

read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 9)
INF = 1 << 60
MOD = 1000000007


def f(n):
    if n % 2 == 0:
        return n // 2
    else:
        return 3 * n + 1


def main():
    s = int(readline())

    d = dict()

    a = s
    d[a] = 1
    for i in range(2, 10000000):
        a = f(a)
        if a in d:
            ans = i
            break
        else:
            d[a] = i

    print(ans)
    return


if __name__ == '__main__':
    main()


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

int main() {
    int n, T;
    cin >> n >> T;
    int c[n], t[n];
    for (int i = 0; i < n; i++) {
        cin >> c[i] >> t[i];
    }
    int min_c = 10000;
    int min_i = 10000;
    for (int i = 0; i < n; i++) {
        if (t[i] <= T && c[i] < min_c) {
            min_c = c[i];
            min_i = i;
        }
    }
    if (min_i == 10000) {
        cout << "TLE" << endl;
    } else {
        cout << min_c << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

#define rep0(n) for(int i=0;i<n;i++)
#define rep(n) for(int i=1;i<=n;i++)

double const pi=3.1415926535;

int printint(int n){
	cout<<n<<endl;
	return 0;
}

int prints(string s){
	cout<<s<<endl;
	return 0;
}

int main(){
	string s;
	cin>>s;
	printf("%c%d%c\n",s[0],s.length()-2,s[s.length()-1]);
	return 0;
}

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

using namespace std;

typedef long long int lint;



int main() {
    int a,b,c;
    cin >> a >> b >> c;
    
    int mul = a*b*c;
    

    if(mul == 175){
        cout << "YES" << endl;

    }else{
        cout << "NO" << endl;

    }









    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstring>
#include<vector>
#include<sstream>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<utility>
#include<climits>
#include<set>
using namespace std;
#define ll long long


int main(){ 
	ios_base::sync_with_stdio(false);
	    cin.tie(0);
	    cout.tie(0);
	    
	#ifndef ONLINE_JUDGE
	    freopen("input.txt","r",stdin);
	    freopen("output.txt","w",stdout);
	#endif

	ll n;cin>>n;
	vector<ll> v(n);
	for(int i=0;i<n;i++)
		cin>>v[i];
	ll ans=0;
	ll modul=1000000007;
	ll sum=0;

	for(int i=0;i<n;i++)
	{	
		ll temp=(v[i] * sum)%modul;
		ans=(ans + temp)%modul;
		sum= (sum + v[i])%modul;

	}
	cout<<ans;
    
}


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

int main(){
  int h, w;
  cin >> h >> w;
  vector<string> str(h);
  for(int i=0; i<h; ++i) cin >> str[i];
  vector<int> cnt(26,0);
  for(int i=0; i<h; ++i) for(int j=0; j<w; ++j){
    ++cnt[str[i][j] - 'a'];
  }
  bool ansis = true;
  if(h%2 == 0 && w%2 == 0){
    for(int i=0; i<26; ++i){
      if(cnt[i] %4 !=0) ansis = false;
    }
  }
  else if(h%2 == 1 && w%2 == 1){
    int mod1 = 0, mod2 = 0, mod3 = 0;
    for(int i=0; i<26; ++i){
      if(cnt[i] %4 == 1) ++mod1;
      if(cnt[i] %4 == 2) ++mod2;
      if(cnt[i] %4 == 3) ++mod3;
    }
    if(mod1+mod3 > 1 || mod2+mod3 > (h+w-2)/2) ansis = false;
  }
  else{
    int mod2 = 0;
    for(int i=0; i<26; ++i){
      if(cnt[i] %4 == 1 || cnt[i] %4 == 3) ansis = false;
      if(cnt[i] %4 == 2) ++mod2;
    }
    if(w%2 && mod2 > h/2) ansis = false;
    if(h%2 && mod2 > w/2) ansis = false;
  }
  cout << (ansis? "Yes": "No") << endl;
}

Measured memory_bytes: 3616
public class Main {

	public static void main(String[] args) {
	
		java.util.Scanner scanner = new java.util.Scanner(System.in);
		int a = scanner.nextInt();
		int b = scanner.nextInt();
		
		int num = a;
		int num2 = b;
		
		if(num > num2){
			System.out.println("a"+" "+">"+" " +"b");
		}else if(num < num2){
			System.out.println("a"+" "+"<"+ " "+"b");	
		}else if(num == num2){
			System.out.println("a"+" "+ "==" +" " + "b");
		}

	}
}

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

using namespace std;


int main()
{
    int n , m;
    cin >> n >> m;
    vector<bool>visited(n , false);
    bool ans = false;
    for(int i = 0 ; i < m ; i++){
        int a , b;
        cin >> a >> b;
        a--;b--;
        if(a == 0){
            if(visited[b]){
                ans = true;
            }
            visited[b] = true;
        }
        else if(b == n - 1){
            if(visited[a]){
                ans = true;
            }
            visited[a] = true;
        }
    }

    if(!ans){
        cout << "IMPOSSIBLE";
        return 0;
    }
    else{
        cout << "POSSIBLE";
        return 0;
    }
    return 0;
}


Measured memory_bytes: 256
from fractions import gcd

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

M = C * D // gcd(C, D)

ans = (B - A + 1) - (B // C - (A - 1) // C) - (B // D - (A - 1) // D) + (B // M - (A - 1) // M)

print(ans)


Measured memory_bytes: 5560
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);

		String S = sc.next();

		switch(S) {
		case "SUN":
			System.out.println(7);
			break;
		case "MON":
			System.out.println(6);
			break;
		case "TUE":
			System.out.println(5);
			break;
		case "WED":
			System.out.println(4);
			break;
		case "THU":
			System.out.println(3);
			break;
		case "FRI":
			System.out.println(2);
			break;
		case "SAT":
			System.out.println(1);
			break;
		}


	}
}

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

long long exponentiation_by_squaring(long long a, long long b){
    if(b == 0) return 1;
    if(b % 2 == 1){
        return exponentiation_by_squaring(a, b - 1) * a;
    }else{
        long long tmp = exponentiation_by_squaring(a, b / 2);
        return tmp * tmp;
    }
}

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

    long long h;
    cin >> h;

    long long cnt = 0, ans = 0;
    while(true){
        h /= 2;
        long long tmp = 1;
     	for(int i = 0; i < cnt; i++){
        	tmp *= 2;
        }
        ans += tmp;
        cnt++;
        if(h == 0){
            break;
        } 
    }

    cout << ans << endl;

    return 0;
}


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

int main() {
  int n, k;
  string s;
  cin >> n >> k >> s;

  int ans = 0;
  for (int i = 0; i < n - 1; ++i) {
    if (s[i] == s[i + 1])
      ans++;
  }

  ans = min(ans + 2 * k, n - 1);

  cout << ans << endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define REP(i,m,n) for(int i=(int)(m); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define REPL(i,m,n) for(ll i=(ll)(m); i<(ll)(n); i++)
#define repl(i,n) REP(i,0,n)
#define all(v) v.begin(), v.end()
const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;

int main() {
  int N;
  vector<int> l;
  cin >> N;
  int temp;
  REP(i, 0, N) {
    cin >> temp;
    l.push_back(temp);
  }
  sort(l.begin(), l.end());

  // j, ... , i, ... target
  int count = 0;
  int index = 0;
  int is_first = 0;
  for(int i=N-2;i>=1;i--){
    is_first = 0;
    while (1) {
      if (is_first == 0){
        index = i+1; // index of target number
        is_first = 1;
      }
      else{
        index++;
      }
      if(index >= N)
        break;

      // cout << " i: " << i << " index: " << index << endl;
      // cout << l[i] << " " << l[index] << endl;

      for(int j=i-1;j>=0;j--){
        if(l[i]+l[j] > l[index]){
          count++;
          // cout << "j: " << j << " i: " << i << " index: " << index << endl;
          // cout << l[j] << " " << l[i] << " " << l[index] << endl;
        }
        else{
          break;
        }
      }
    }
  }

  int ans = count;
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] Args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		char c[] = s.toCharArray();
		c[5] = ' ';
		c[13] = ' ';
		for(int i=0;i<=18;i++) {
			System.out.print(c[i]);
		}
	}
}

Measured memory_bytes: 21332
while True:
    h,w=map(int,input().split())
    if h==0 and w==0:
        break
    for i in range(h):
        for k in range(w):
            if (i+k)%2==0:
                print("#",end="")
            else:
                print(".",end="")
        print()
    print()


Measured memory_bytes: 7008
#!/usr/bin/env python3
import sys


def solve(N: int, Q: int, S: str, l: "List[int]", r: "List[int]"):
    table = [0] * (N + 1)

    for i in range(N):
        table[i + 1] = table[i] + (1 if S[i : i + 2] == "AC" else 0)

    for i in range(Q):
        print(table[r[i] - 1] - table[l[i] - 1])

# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    Q = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    l = [int()] * (Q)  # type: "List[int]"
    r = [int()] * (Q)  # type: "List[int]"
    for i in range(Q):
        l[i] = int(next(tokens))
        r[i] = int(next(tokens))
    solve(N, Q, S, l, r)

if __name__ == '__main__':
    main()


Measured memory_bytes: 15828
#include<bits/stdc++.h>
using namespace std;
#define gcd(a,b) __gcd(a,b)
#define pb push_back
#define sevensins ios_base::sync_with_stdio(false);cin.tie(NULL);
#define ll long long int
#define mod  1000000007
#define vect vector<long long int>
#define bins binary_search
#define vecti vector<int>::iterator
#define bitout __builtin_popcount
#define binsrch binary_search
int main() 
{sevensins
ll i,j,k,n,flag=0;
cin>>n;
while(n!=0)
{
  k=n%10;
  if(k==7)
  flag=1;
  n=n/10;
}

if(flag==1)
cout<<"Yes\n";
else
cout<<"No\n";

return 0;
}


Measured memory_bytes: 3640
#include<bits/stdc++.h>
#pragma GCC target ("avx2")
#pragma GCC optimization ("Ofast")
#pragma GCC optimization ("unroll-loops")
#pragma comment(linker, "/stack:200000000")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
using namespace std;
#define int long long 
typedef pair<int,int>pi;
typedef vector<int>vi;

const int MAXN=200005;
const int MOD=1000000007;

#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define DEC(i,a,b) for(int i=(a);i>=(b);i--)
#define pb push_back
#define mp make_pair
#define sz(v) ((int)(v).size())
#define all(v) (v).begin(),(v).end()
#define db(x) cerr<<#x<<" = "<<x<<"\n"
#define LOW(v,x) (lower_bound(all(v),(x))-(v).begin())
#define UP(v,x) (upper_bound(all(v),(x))-(v).begin())

int N,K,A[MAXN];
main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin>>N>>K;
	FOR(i,1,N) cin>>A[i];
	int s=0, e=1e18;
	while (e-s>1){
		int m = (s+e)/2;
		int cuts = 0;
		FOR(i,1,N){
			cuts += (A[i]+m-1)/m - 1;
		}
		if (cuts <= K) e = m;
		else s = m;
	}
	cout<<e;
}




Measured memory_bytes: 5168
#!usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
def LI(): return list(map(int, sys.stdin.readline().split()))
def I(): return int(sys.stdin.readline())
def LS():return list(map(list, sys.stdin.readline().split()))
def S(): return list(sys.stdin.readline())[:-1]
def IR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = I()
    return l
def LIR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = LI()
    return l
def SR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = S()
    return l
def LSR(n):
    l = [None for i in range(n)]
    for i in range(n):l[i] = SR()
    return l
mod = 1000000007

#A
"""
x,a,b = LI()
if abs(a-x) < abs(b-x):
    print("A")
else:
    print("B")
"""
#B
s = S()
alp = list("qwertyuiopasdfghjklzxcvbnm")
alp.sort()
d = defaultdict(int)
for i in alp:
    d[i] += 1
for i in s:
    d[i] -= 1
for i in d.keys():
    if d[i] > 0:
        print(i)
        quit()
print("None")
#C
"""
n = I()
d = defaultdict(int)
a = LI()
for i in a:
    d[i] += 1
d = list(d.items())
d.sort(key = lambda x:-x[0])
l = 0
k = 0
for i,j in d:
    if j >= 2:
        if l == 0:
            l = i
        else:
            k = i
        if j >= 4:
            k = i
    if k != 0:break
print(l*k)
"""

#D
"""
n = I()
s1 = S()
s2 = S()
ans = 0
i = 0
key = 1
d = defaultdict(int)
while i < n:
    if s1[i] == s2[i]:
        if not d[s1[i]]:
            d[s1[i]] = 1
            if i == 0:
                ans = 3
            else:
                if key:
                    ans *= 2
        key = 1
    else:
        if not d[s1[i]] and not d[s2[i]]:
            d[s1[i]] = 1
            d[s2[i]] = 1
            if i == 0:
                ans = 6
            else:
                if key:
                    ans *= 2
                else:
                    ans *= 3
        if not d[s1[i]]:
            d[s1[i]] = 1
            if not key:
                ans *= 2
        if not d[s2[i]]:
            d[s2[i]] = 1
            if not key:
                ans *= 2
        key = 0
        i += 1
    i += 1
    ans %= mod
print(ans)
"""

#E

#F

#G

#H

#I

#J

#K

#L

#M

#N

#O

#P

#Q

#R

#S

#T


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

int main(){
    char str[3][3];
    for(int i=0; i<3; i++){
        for(int j=0; j<3; j++){
            cin >> str[i][j];
        }
    }
    cout << str[0][0] << str[1][1] << str[2][2] << endl;
    return 0;
}

Measured memory_bytes: 3596