akhauriyash/Code-Regression huggingface dataset:
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Array;
import java.util.*;
import java.util.Map.Entry;

public class Main{
	
	public static void main(String[] args) throws IOException{
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		Scanner in = new Scanner(System.in);
		
		int N = in.nextInt();
		int[] bitIsOpen = new int[N];
		int[][] P = new int[N][11];
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < 10; j++){
				bitIsOpen[i] += in.nextInt() << j;
			}
			//System.out.println(Integer.toBinaryString(bitIsOpen[i]));
		}
		
		for(int i = 0; i < N; i++){
			for(int j = 0; j < 11; j++){
				P[i][j] = in.nextInt();
			}
		}
		
		long max = Integer.MIN_VALUE;
		for(int bit = 1; bit <= 0b1111111111; bit++){
			long count = 0;
			//System.out.println("pattern:" + Integer.toBinaryString(bit));
			
			for(int i = 0; i < N; i++){
				int bitIslap = bitIsOpen[i] & bit;
				//System.out.println("mattch:" + Integer.toBinaryString(bitIslap));
				int c = 0;
				for(int j = 0; j < 10; j++){
					c += 1 & (bitIslap >> j);
				}
				//System.out.println(c);
				
				count += P[i][c];
			}
			if(count > max){
				max = count;
				//System.out.println("pattern:" + Integer.toBinaryString(bit));
			}
			//System.out.println(count);
		}
		
		System.out.println(max);
	}
}


Measured memory_bytes: 26068
#include <bits/stdc++.h>
using namespace std;
long long INF = 1000000000000;
int main(){
  int N;
  cin >> N;
  vector<long long> A(N);
  for (int i = 0; i < N; i++){
    cin >> A[i];
  }
  long long tv = INF;
  long long fv = -1;
  while (tv - fv > 1){
    long long mv = (tv + fv) / 2;
    long long x = mv;
    for (int i = 0; i < N; i++){
      x = A[i] * 2 - x;
    }
    if (x > mv){
      fv = mv;
    } else {
      tv = mv;
    }
  }
  vector<int> ans;
  ans.push_back(tv);
  for (int i = 0; i < N - 1; i++){
    int tmp = A[i] * 2 - ans.back();
    ans.push_back(tmp);
  }
  for (int i = 0; i < N; i++){
    cout << ans[i];
    if (i < N - 1){
      cout << ' ';
    }
  }
  cout << endl;
}

Measured memory_bytes: 2680
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
  ll n;
  cin>>n;
  ll a[n];
  for(ll i=0;i<n;i++){
    cin>>a[i];
    }
  sort(a,a+n);
  ll count=0;
  for(int i=0;i<n-1;i++)
    {
    if(a[i]==a[i+1])
      {
      count++;
      break;
      }
    }
 
  if(count==0)
    cout<<"YES"<<endl;
  else
    cout<<"NO"<<endl;
  }


Measured memory_bytes: 5180
#include <bits/stdc++.h>
using namespace std;
int i,j,n,k,c,h,w,p[50],q[50];
double sum,a;
int main(){
  for(cin>>n;i<n;i++){
    cin>>a;
    sum+=1/a;
  }
  sum=1/sum;
  printf("%.6f",sum);
}

Measured memory_bytes: 256
n,m=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))
sx=0
sy=0
pr=10**9+7
for i in range(1,n):
    sx+=(x[i]-x[i-1])*(i*(n-i))%pr
for i in range(1,m):
    sy+=(y[i]-y[i-1])*(i*(m-i))%pr
print(sx*sy%pr)

Measured memory_bytes: 18624
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <algorithm>
#include <string>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <fstream>
#include <cassert>
#include <cstring>
#include <unordered_set>
#include <unordered_map>
#include <numeric>
#include <ctime>
#include <bitset>
#include <complex>
#include <random>

using namespace std;

#define int long long
const int N = 51;

int c[N][N];

void init() {
	c[0][0] = 1;
	for (int i = 1; i < N; i++) {
		c[i][0] = 1;
		for (int j = 1; j < N; j++) {
			c[i][j] = c[i - 1][j] + c[i - 1][j - 1];
		}
		c[i][i] = 1;
	}
}

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

    int n, p;
    cin >> n >> p; 
    vector<int> cnt(2);
    for (int i = 0; i < n; i++) {
    	int x;
    	cin >> x;
    	cnt[x % 2]++;
    }
    int ans = 0;
    for (int l = 0; l + p <= cnt[1]; l += 2) {
    	ans += c[cnt[1]][l + p];
    }
    for (int i = 0; i < cnt[0]; i++) {
    	ans *= 2;
    }
    cout << ans << endl;
}   


Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <queue>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <fstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <limits>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toString(T x) { ostringstream sout; sout << x; return sout.str(); }

//math
//-------------------------------------------
template<class T> inline T sqr(T x) { return x * x; }

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define EXISTch(s,c) ((((s).find_first_of(c)) != std::string::npos)? 1 : 0)//cがあれば1 if(1)
#define SORT(c) sort((c).begin(),(c).end())

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = (int)1000000007;
const LL MOD = (LL)1000000007;//10^9+7
const LL INF2 = (LL)100000000000000000;//10^18

int main() {
	int n, m, x; cin >> n >> m >> x;
	int ans = INF;

	vector<vector<int>> tb(n, vector<int>(m+1));
	for (int i = 0; i < n; i++) {
		for (int j = 0; j < m+1; j++) {
			cin >> tb[i][j];
		}
	}

	for (int bit = 0; bit < (1 << n); ++bit) {
		int tmp = 0; vector<int> score(m+1);
		for (int j = 0; j < n; j++) {
			if (bit&(1 << j)) {
				tmp += tb[j][0];
				for (int i = 1; i < m+1; i++) {
					score[i] += tb[j][i];
				}
			}
		}

		bool f = true;
		for (int i = 1; i < m+1; i++) {
			if (score[i] < x)f = false;
		}
		if (f) {
			ans = min(ans, tmp);
		}
	}
	if (ans == INF) {
		ans = -1;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	ll N = 50, K;
	cin >> K;
	vector<ll> a(N, N - 1 + K / N);
	K %= N;
	for (int i = 0; i < N; i++) {
		if (i < K) {
			a[i] += N - K;
		}
		else {
			a[i] -= K;
		}
	}
	cout << N << endl;
	for (int i = 0; i < N; i++) {
		cout << a[i] << " \n"[i + 1 == N];
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double PI=acos(-1);
const double EPS=1e-10;

int main(){
	cin.tie(0);ios::sync_with_stdio(false);
	int a,b,h;
	cin>>a>>b>>h;
	cout<<(a+b)*h/2<<endl;
}

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

int main(){
  string s;  cin >> s;
  char c = s[0];
  int N = s.size();
  int ans = 0;
  for(int i = 1; i < N; i++){
    if(c != s[i]) ans++;
    c = s[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 512
def chk(n):
    for i in range(14):
        if i*10 >= n:
            return i*10
    

menu = []
time = []
for i in range(5):
    menu.append(int(input()))
    time.append(menu[i]%10)
#print(menu,time)
min_i = [10,10]
for i in range(5):
    if time[i]!=0:
        if time[i]<min_i[0]:
            min_i[0] = time[i]
            min_i[1] = i
#print(min_i)
ans = 0
for i in range(5):
    if i == min_i[1]:
        ans += menu[i]
    else:
        ans += chk(menu[i])
print(ans)

Measured memory_bytes: 9208
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <cmath>
#include <vector>

using namespace std;
using ll = long long;

ll total[3005][3005];
ll dpmax[3005][3005];
int arr[3005];

int main() {
    int n;
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> arr[i];
        dpmax[i][i] = arr[i];
    }
    for (int i = 0; i < n; i++) {
        for (int j = i; j < n; j++) {
            if (j-1 >= i) {
                total[i][j] = total[i][j-1] + arr[j];
            } else {
                total[i][j] = arr[j];
            }  
        }
    }
    for (int i = 0; i < n; i++) {
        if (i+1 < n) {
            dpmax[i][i+1] = max(arr[i], arr[i+1]);
        }
    }
    for (int k = 2; k < n; k++) {
        for (int i = 0; i < n; i++) {
            if (i+k < n) {
                dpmax[i][i+k] = max(arr[i]+total[i+1][i+k]-dpmax[i+1][i+k], arr[i+k]+total[i][i+k-1]-dpmax[i][i+k-1]);
            }
        }
    }
    
    // printf("%lld %lld", dpmax[0][n-1], dpmax[0][n-1]-(total[0][n-1]-dpmax[0][n-1]));
    printf("%lld", dpmax[0][n-1]-(total[0][n-1]-dpmax[0][n-1]));
    return 0;
}

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

int main() {

    const ll mod = 1000000007;
    ll n; cin >> n;
    ll ans = 1;
	for (ll i = 1; i <= n; i++) {
		ans *= i;
		ans %= mod;
	}
	cout << ans << endl;
	return 0;
}

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

int main()
{
	int a;
	int b;

	cin >> a >> b;

	if (a < b){
		cout << "a < b" << endl;
	}
        if (a > b){
		cout << "a > b" << endl;

	}
	if (a == b){
		cout << "a == b" << endl;
	}

	return 0;
}



Measured memory_bytes: 3088
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	//	"strings"
)

func main() {
	sc := NewScanner()

	a := sc.NextInt()
	b := sc.NextInt()

	if (b-1)%(a-1) == 0 {
		fmt.Printf("%+v\n", (b-1)/(a-1)) // output for debug
	} else {
		fmt.Printf("%+v\n", (b-1)/(a-1)+1) // output for debug
	}
}

type Scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func NewScanner() *Scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 1000)
	return &Scanner{r: rdr}
}
func (s *Scanner) Next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *Scanner) NextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *Scanner) NextInt() int {
	v, _ := strconv.Atoi(s.Next())
	return v
}

func (s *Scanner) NextIntArray() []int {
	s.pre()
	start := s.p
	result := []int{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			result = append(result, v)
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	result = append(result, v)

	return result
}

func (s *Scanner) NextMap() map[int]bool {
	s.pre()
	start := s.p
	mp := map[int]bool{}
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			v, _ := strconv.Atoi(string(s.buf[start:s.p]))
			mp[v] = true
			start = s.p + 1
		}
	}
	v, _ := strconv.Atoi(string(s.buf[start:s.p]))
	mp[v] = true

	return mp
}

func (s *Scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *Scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


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

int main() {
  float N;
  cin >> N;
  int a = N;
  for (int i = 1; i < 10; i++) {
    if (a/ 100 == i && N / 111 > i) {
      cout << 111 * (i + 1);
      break;
    }else if (N / 111 <= i){
      cout << 111 * i;
      break;
    }
  }
}

Measured memory_bytes: 256
DEBUG = False

S = input()
count = 1
nums_RL = []
pre_char = S[0]
for i in range(1, len(S)):
    next_char = S[i]
    if pre_char != next_char:
        nums_RL.append(count)
        count = 0
    pre_char = next_char
    count += 1
nums_RL.append(count)
if DEBUG:
    print("nums_RL: {}".format(nums_RL))

ans = [0] * len(S)
p = 0
for i in range(len(nums_RL)//2):
    num_R = nums_RL[2*i]
    num_L = nums_RL[2*i+1]
    if DEBUG:
        print("p: {}, num_R: {}, num_L: {}".format(p, num_R, num_L))
    p += num_R
    if (num_R + num_L) % 2 == 0:
        ans[p-1] = (num_R + num_L) // 2
        ans[p] = (num_R + num_L) // 2
    else:
        ans[p-1] = num_L // 2 + (num_R + 1) // 2
        ans[p] = num_R // 2 + (num_L + 1) // 2
    p += num_L
    if DEBUG:
        print("ans: {}".format(ans))
print(*ans)


Measured memory_bytes: 7160
#include <bits/stdc++.h>
#define MAX 1000006
#define MOD 1000000007
#define LL long long
#define NL '\n'
using namespace std;

int n, cnt = 0;
LL arr[201];

int main(){
    std::ios_base::sync_with_stdio(0);

    cin >> n;

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

    bool flag = true;
    while ( flag ){
        for( LL i = 0; i < n; i++ ){
            if( arr[i] % 2 == 0 ) {
                arr[i] = arr[i]/2;
            }else{
                flag = false;
            }
        }
        cnt++;
    }

    cout << cnt-1 << NL;

    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define NIL -1

struct Node{
    int num;
    struct Node* left;
    struct Node* right;
};

struct Node* root;

void insert(int num, struct Node* n){
    if(root == NULL){
        root = (Node*) malloc(sizeof(struct Node));
        root->num = num;
        root->left = NULL;
        root->right = NULL;
        return;
    }

    if(num < n->num){
        if(n->left == NULL){
            n->left = (Node*) malloc(sizeof(struct Node));
            n->left->num = num;
            n->left->left = NULL;
            n->left->right = NULL;
        }else{
            insert(num, n->left);
        }
    }else{
        if(n->right == NULL){
            n->right = (Node*) malloc(sizeof(struct Node));
            n->right->num = num;
            n->right->left = NULL;
            n->right->right = NULL;
        }else{
            insert(num, n->right);
        }
    }
}

void print_middle(struct Node* n){
    if(n == NULL){
        return;
    }
    print_middle(n->left);
    printf(" %d", n->num);
    print_middle(n->right);
}

void print_before(struct Node* n){
    if(n == NULL){
        return;
    }
    printf(" %d", n->num);
    print_before(n->left);
    print_before(n->right);
}

void init(){
    root = NULL;
}

int main(void){
    init();

    int N;
    scanf("%d", &N);

    for(int i = 0; i < N; i++){
        char comm[100];
        int num;
        scanf("%s", comm);

        if(comm[0] == 'i'){
            scanf("%d", &num);
            insert(num, root);
        }else if(comm[0] == 'p'){
            print_middle(root);
            printf("\n");
            print_before(root);
            printf("\n");
        }
    }
}




Measured memory_bytes: 18352
#pragma GCC optimize("Ofast")
#pragma GCC target ("avx")
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
using namespace std;
using ll = long long int;
using ull =  unsigned long long int;


int main() {
	int L, N;
	cin >> N >> L;
	int a = 0, ans = INF, b = 0;
	for (int i = 0; i < N; i++)a += (L + i);
	for (int i = 0; i < N; i++){
		int tmp = 0;
		for (int j = 0; j < N; j++) {
			if (i == j)continue;
			tmp += (L + j);
		}

		if (ans > abs(tmp - a)) {
			ans = abs(tmp - a);
			b = tmp;
		}
	}
	cout << b << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a==b)
    printf("%d",2*a);
  else if(a>b)
    printf("%d",2*a-1);
  else
    printf("%d",2*b-1);
  return 0;
}

Measured memory_bytes: 1712
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i, a, b) for(ll i=(a); i<(b); i++)
#define PER(i, a, b) for(ll i=(a); i>=(b); i--)
#define rep(i, n) REP(i, 0, n)
#define per(i, n) PER(i, n, 0)
#define ALL(a)  (a).begin(),(a).end()
const ll INF = 1e18+18;
const ll MAX = 200000;
const ll MOD = 1000000007;
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl;
#define YES(n) cout << ((n) ? "YES" : "NO") << endl;



int main(){
  ll N;
  cin>>N;
  vector<ll> A(N);
  rep(i, N){
    cin>>A[i];
  }
  sort(ALL(A));
  reverse(ALL(A));
  priority_queue<ll> Q;
  ll Ans=0;
  Ans+=A[0];
  Q.push(A[1]);
  Q.push(A[1]);
  for(ll i=2; i<N; i++){
    Ans+=Q.top();
    Q.pop();
    Q.push(A[i]);
    Q.push(A[i]);
  }
  cout<<Ans<<endl;
} 

Measured memory_bytes: 6924
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#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...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int n, m;
  scanf("%d%d", &n, &m);
  vector<int> a(n);
  int sum = 0;
  for (int i = 0; i < n; ++i) {
    a[i] = m + i;
    // trace(i, a[i]);
    sum += a[i];
  }
  int best = 1 << 30, ret = -1;
  for (int i = 0; i < n; ++i) {
    int rem = sum - a[i];
    int cur = abs(rem - sum);
    if (best > cur) {
      best = cur;
      ret = rem;
    }
  }
  printf("%d\n", ret);
  return 0;
}


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

#define int long long

#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define FORR(i,m,n) for(int i=m;i>=n;i--)
#define pb(x) push_back(x) 
#define SORT(x) sort((x).begin(),(x).end())
#define INF 9999999999
 
using namespace std;

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

    int t=n, cnt;
    vector<int> v;
    FOR(i, 1, 20){
        v.pb(t%10);
        t/=10;
        if(t<1){
            cnt=i;
            break;
        }
    }

    int u=0, ans;
    REP(i, cnt) u+=v[i];
    ans=u;
    for(int i=cnt-1; i>0; i--){
        u=v[i]-1;
        for(int j=i-1; j>=0; j--){
            u+=9;
        }
        ans=max(ans, u);
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

Int calc(Int R, Int C, Int D){
  Int a = R/C;
  Int b = R/D;
  Int c = R / ((C/ __gcd(C, D)) * D);
  return (a + b - c);
}

signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  Int A, B, C, D;
  cin>>A>>B>>C>>D;


  Int a = calc(A-1, C, D);
  Int b = calc(B, C, D);
  Int ans = (B - A + 1) - (b - a);
  cout<<ans<<endl;

  return 0;
}


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

int main(void){
  double r, a, l;

  scanf("%lf", &r);

  a = M_PI * r * r;
  l = 2.0 * M_PI * r;
  printf("%lf %lf\n", a, l);
  
  return 0;
}


Measured memory_bytes: 1992
n = int(input())
rev = []
nn = n
def c(n):
    k = 1
    i = 1
    while n > 26 ** i:
        n -= 26 ** i
        k += 1
        i += 1
    return n

def d(n):
    k = 1
    i = 1
    while n > 26 ** i:
        n -= 26 ** i
        k += 1
        i += 1
    return k

n = c(n) - 1
while n > 25:
    r = n % 26
    rev.append(r)
    n //= 26
rev.append(n)
sl = list('abcdefghijklmnopqrstuvwxyz')
l = len(rev)
name = []
for i in range(d(nn) - l):
    name.append('a')
for i in range(len(rev)):
    d = sl[rev[l - 1 - i]]
    name.append(d)
dogname = ''.join(name)
print(dogname)

Measured memory_bytes: 61688
def main():
    N, K = map(int, input().split())
    sum = 0.0

    if N - K >= 0:
        sum = sum + N - K + 1.0

        for i in range(1, K):
            tmp = i
            count = 0
            while tmp < K:
                tmp = tmp * 2
                count += 1
            sum = sum + 0.5**count
    else:
        for i in range(1, N + 1):
            tmp = i
            count = 0
            while tmp < K:
                tmp = tmp * 2
                count += 1
            sum = sum + 0.5**count

    print(round(sum/N, 10))

if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
(* O(b) *)
let solve a b c =
  let rec loop i r =
    if i >= c || r < a then
      i
    else
      loop (i + 1) (r - a)
  in
    loop 0 b

let _ = Scanf.scanf "%d %d %d" (fun a b c -> solve a b c) |> string_of_int |> print_endline

Measured memory_bytes: 384
#include <iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<algorithm>
#include<vector>
using namespace std;
#define db double
const db eps = 1e-8;

struct Point{
    db x, y;
    Point(db x=0, db y=0): x(x), y(y) {}    //必须有初始化
    bool operator < (const Point &p){
        return x < p.x || (x == p.x && y < p.y);
    }
};

typedef Point Vector;
Vector operator + (Vector a, Vector b){ return Point(a.x+b.x, a.y+b.y);}
Vector operator - (Point a, Point b){ return Vector(a.x-b.x, a.y-b.y);}
Vector operator * (Vector a, db k){ return Vector(a.x*k, a.y*k);}
Vector operator / (Vector a, db k){ return Vector(a.x/k, a.y/k);}

//inline将函数名为内联函数，不使用栈空间，直接运算，但不能有while,switch等复杂语句
inline db dot(Vector a, Vector b){
    return a.x*b.x + a.y*b.y;
}
inline db cross(Vector a, Vector b){
    return a.x*b.y - b.x*a.y;
}
db length(Vector a){
    return sqrt(dot(a, a));
}
db angle(Vector a, Vector b){
    return acos(dot(a, b) / length(a) / length(b));
}

int dcmp(db x){
    if(fabs(x) < eps) return 0;
    return x < 0? -1: 1;
}
bool operator == (Point a, Point b){
    return dcmp(a.x-b.x) == 0 && dcmp(a.y-b.y) == 0;
}

struct Segment{
    Point p1, p2;
};
typedef Segment Line;
vector<Point> Polygon;
Point project(Line l, Point p){
    Vector a = l.p2 - l.p1, b = p - l.p1;
    db len_a = dot(a, a);   //这里不加sqrt，是因为下面算投影长度时，要除以两次len_a
    Vector tmp = a * (dot(a, b) / len_a);
    return Point(tmp.x+l.p1.x, tmp.y+l.p1.y);
}
Point reflect(Line l, Point p){
    Point tmp = project(l, p);
    return p + (tmp - p)*2;
}

void line_relation(Point p1, Point p2, Point p3, Point p4){
    Vector a = p2 - p1, b = p4 - p3;
    if(cross(a, b) == 0)
        puts("parallel");
    else if(dot(a, b) == 0)
        puts("orthogonal");
    else
        puts("others");
}
int com_segment_relation(Point p0, Point p1, Point p2){
    Vector a = p1-p0, b = p2-p0;
    db flag = cross(p1-p0, p2-p0);
    if(flag < 0)  return 2;
    else if(flag > 0)  return 1;
    else{       //重合
        if(a.x*b.x < 0 || a.y*b.y < 0) return 3;
        else if(length(a) < length(b)) return 4;
        else return 5;
    }
}

int segment_intersection(Point p1, Point p2, Point p3, Point p4){
    Point node1[2] = {p1, p2}, node2[2] = {p3, p4};
    sort(node1, node1+2), sort(node2, node2+2);
    if(node2[1] < node1[0] || node1[1] < node2[0])  return 0;       //同一直线上，最大最小排除
    else if(cross(p2-p1, p3-p1)*cross(p2-p1, p4-p1) > 0 || cross(p4-p3, p1-p3)*cross(p4-p3, p2-p3) > 0) return 0;
    else    return 1;
}
int main()
{
    Point p1, p2, p3, p4;
    int n;
    cin >>n;
    while(n --){
        cin >>p1.x >>p1.y >>p2.x >>p2.y >>p3.x >>p3.y >>p4.x >>p4.y;
        int flag = segment_intersection(p1, p2, p3, p4);
        cout <<flag;
        cout << "\n";
    }
    return 0;
}



Measured memory_bytes: 3212
#include <cstdio>
#include <iostream>
#include <algorithm>
#include <string>
#include <cstring>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <bitset>
using namespace std;

typedef pair<int, int> P;
#define rep(i, n) for (int i=0; i<(n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end())
#define index(xs, x) (int)(lower_bound(all(xs), x) - xs.begin())
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
set<int> merge(set<int> a, set<int> b) {
  if (a.size() < b.size()) swap(a, b);
  for (int x : b) a.insert(x);
  return a;
}

#define MAX_N (1<<18)
struct SegTree {
  set<int> seg[MAX_N*2-1];
  set<int> query(int a, int b, int k=0, int l=0, int r=MAX_N) {
    if (b <= l || r <= a) return set<int>();
    if (a <= l && r <= b) return seg[k];
    return merge(merge(query(a, b, k*2+1, l, (l+r)/2), query(a, b, k*2+2, (l+r)/2, r)), seg[k]);
  }

  void insert(int a, int b, int x, int k=0, int l=0, int r=MAX_N) {
    if (b <= l || r <= a) return;
    if (a <= l && r <= b) {
      seg[k].insert(x);
      return;
    }
    insert(a, b, x, k*2+1, l, (l+r)/2);
    insert(a, b, x, k*2+2, (l+r)/2, r);
  }
};
SegTree seg[2];

int N;
int AX[100000], AY[100000], BX[100000], BY[100000];
set<P> V[2][200000];
bool S[100000];

signed main() {
  ios::sync_with_stdio(false); cin.tie(0);
  cin >> N;
  vector<int> xs, ys;
  rep(i, N) {
    cin >> AX[i] >> AY[i] >> BX[i] >> BY[i];
    xs.pb(AX[i]), xs.pb(BX[i]);
    ys.pb(AY[i]), ys.pb(BY[i]);
  }
  sort(all(xs)); uniq(xs);
  sort(all(ys)); uniq(ys);
  rep(i, N) {
    AX[i] = index(xs, AX[i]), AY[i] = index(ys, AY[i]);
    BX[i] = index(xs, BX[i]), BY[i] = index(ys, BY[i]);
  }

  rep(i, N) {
    int t, l, r, y;
    if (AY[i] == BY[i]) {
      t = 0;
      l = AX[i], r = BX[i], y = AY[i];
    }
    else if (AX[i] == BX[i]) {
      t = 1;
      l = AY[i], r = BY[i], y = AX[i];
    }
    else assert(false);
    if (l > r) swap(l, r);

    set<P> &vs = V[t][y];

    auto nx = vs.lower_bound(P(l, INF));
    bool ok = (nx == vs.end() || r < nx->_1);
    if (nx != vs.begin()) {
      nx--;
      if (nx->_2 < l) {}
      else ok = false;
    }
    if (!ok) continue;

    set<int> s = seg[t^1].query(y, y+1);
    if (s.lower_bound(l) != s.upper_bound(r)) continue;

    vs.insert(P(l, r));
    seg[t].insert(l, r+1, y);
    S[i] = true;
  }
  rep(i, N) cout << S[i] << "\n";
  return 0;
}

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

int main(){
    char c;
    int ans = 0, flg_R = 0, count = 0;

    for(int i = 0; i < 3; i++){
        std::cin >> c;
        if(c == 'R'){
            flg_R = 1;
            count++;
        }else{
            if(count > ans){
                ans = count;
            }
            count = 0;
        }
    }
    if(c == 'R'){
        ans = count;
    }
    std::cout << ans;

}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
long long bfs(long long n)
{
	queue<pair<long,long> > q;
	long long ans=0;
	q.push({1,1});
	while(!q.empty())
	{
		pair<long,long> pt=q.front();
		  q.pop();
		  if(pt.first*pt.second==n)
		  	   return ans;

		  q.push({pt.first+1,pt.second});
		  q.push({pt.first,pt.second+1});
		   if(pt.first*pt.second==1)
		      	 { ans++;
                   q.push({1,1});
		      	  }
		 
	}

	return 0;
}

long long sol2(long long n)
{
	long long ans=n+5;
	for(long i=1;i<=sqrt(n);i++)
	{

		if(n%i==0)
		{
			long long k=n/i;
			ans=min(ans,(i-1)+(k-1));
		}

	}

	return ans;
}
main()
{
	long long n;
	cin>>n;
	cout<<sol2(n);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define ok() puts(ok?"Yes":"No");
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef set<int> si;
typedef map<string, int> msi;
typedef greater<int> gt;
typedef priority_queue<int, vector<int>, gt> minq;
typedef long long ll;
typedef pair<ll,ll> pll;
const ll LINF = 1e18L + 1;
const int INF = 1e9 + 1;
//clang++ -std=c++11 -stdlib=libc++ 

int main() {
  string s,t; cin >> s >>t;
  bool ok = s.length() + 1 == t.length();
  rep(i, s.length()) {
    if(s[i] != t[i]) ok = false;
  }
  ok();
  return 0;
}

Measured memory_bytes: 3596
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };
    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };
    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };
    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };
    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        a: u64,
        b: u64,
        h: u64,
    }
    println!("{}", (a+b)*h/2);
}


Measured memory_bytes: 4352
//============================================================================
// Name        : s
// Date        : Tue Mar  5 16:14:07 CST 2019
// Author      : landcold7
// Description : Actions speak louder more than words
//============================================================================
#include "bits/stdc++.h"
using namespace std;

#define pb push_back
#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define mst(x, y) memset(x, y, sizeof(x))
#define pvar(x) cout << #x << ": "
#define fora(e, c) for (auto &e : c)
#define fori(i, a, b) for (int i = a; i < b; ++i)
#define ford(i, a, b) for (int i = a; i > b; --i)
#define output(v) cout << (v) << '\n'
#define jam(x, n) cout << "Case #" << x << ": " << n << "\n"
#define prt(x, a, n) { cout << x[a]; if (a < n - 1) cout << " "; }
#define par(x, s, n, v) if(v) pvar(x); fori(y, s, n) prt(x, y, n) cout << "\n"

#ifndef __has_trace
#define trace(...)
#endif
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef vector<pii> vpii;

const int maxn = (int) 1e5 + 7;
const int mod = (int) 1e9 + 7;

// Digit dp problem

// dp[i][sum][0]: have not see a smaller digit from leftmost(0) till i
// dp[i][sum][1]: already see a smaller digit till i
int dp[maxn][127][2];

void add(int &a, int b) {
    a += b;
    if (a >= mod) {
        a -= mod;
    }
}

void solve() {
    string k; int d;
    cin >> k >> d;

    int n = sz(k);
    dp[0][0][0] = 1;
    fori (i, 1, n + 1) {
        fori (sum, 0, d + 1) {
            for (bool sm_already : {false, true}) {
                for (int digit = 0; digit < 10; ++digit) {
                    if (digit > k[i - 1] - '0' && !sm_already) {
                        break;
                    }
                    add(dp[i][(sum + digit) % d][sm_already || (digit < k[i-1]-'0')], dp[i-1][sum][sm_already]);
                }
            }
        }
    }
    int ret = (dp[n][0][0] + dp[n][0][1]) % mod;
    --ret;
    if (ret == -1) {
        ret = mod - 1;
    }
    output(ret);
}

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



Measured memory_bytes: 10496
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using p = pair<int, int>;
#define INF 1001001001
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repX(i, n ,x) for (int i = x; i < (int)(n); i++)
#define repBack(i, n) for (int i = n; i >= 0; i--)
#define dup(x,y) (((x)+(y)-1)/(y))

int main() {
    int n;
    cin >> n;
    vector<int> p(n);
    rep(i,n)cin >> p[i];
    int ans = 0;
    repX(i,n-1,1){
        if(p[i-1]<p[i]&&p[i]<p[i+1])ans ++;
        else if (p[i - 1] > p[i] && p[i] > p[i + 1])ans++;
    }
    cout << ans << endl;

    return 0;
}

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

int main(){
  int a,b,c;
  cin >> a >> b >> c;
  int n,m;
  n = min(a,b);
  if(a < b){
    m = min(b,c);
  }
  else{
    m = min(a,c);
  }
  cout << n+m << endl;
}

Measured memory_bytes: 3600
from collections import Counter
max_=10**6+1
ans=0

n=int(input())
data=list(map(int,input().split()))

b=[True]*(max_+1)
data.sort()
c=Counter(data)

for d in data:
    if b[d]:
        for j in range(d,max_,d):
            b[j]=False
        if c[d]==1:#複数存在考慮
            ans+=1
print(ans)

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

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

char s[100009];
int A[100009];

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

	int K;
	scanf("%s %d", s, &K);
	int len = strlen(s);

	for (int i = 0; i < len; i++) A[i] = (s[i] - 'a');

	for (int i = 0; i < len; i++) {
		if (A[i] != 0 && 26 - A[i] <= K) {
			K -= (26 - A[i]);
			A[i] = 0;
		}
	}
	A[len - 1] = ((A[len - 1] + K) % 26);

	for (int i = 0; i < len; i++) cout << char('a' + A[i]);
	cout << endl;


	return 0;
}

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

int main(void)
{
    int N;
    cin >> N;
    vector<int> a;
    vector<long long int> asum(N,0);
    for(int i = 0; i < N; ++i) {
        int tmp;
        cin >> tmp;
        a.push_back(tmp);
        ++asum.at(tmp-1);
    }
    long long int nn = 0;
    for(int i = 0; i < asum.size(); ++i) {
        long long int c = asum.at(i);
        if(c >= 2) {
            nn += c*(c-1)/2;
        }
    }
    for(int i = 0; i < a.size(); ++i) {
        long long int c = asum.at(a.at(i)-1);
        if(c >= 3) {
            cout << nn - c*(c-1)/2 + (c-1)*(c-2)/2 << endl;
        } else if(c >= 2) {
            cout << nn - c*(c-1)/2 << endl;
        } else {
            cout << nn << endl;
        }
    }
}



Measured memory_bytes: 5108
fn main() {
    let (a, b): (usize, usize) = (read::<usize>(), read::<usize>());
    println!("{} {}", a * b, 2 * a + 2 * b);
}

// =========
#[allow(unused_imports)]
use std::cmp::{max, min};
#[allow(unused_imports)]
use std::collections::{HashMap, HashSet};
#[allow(unused_imports)]
use std::process::exit;

#[allow(dead_code)]
const MOD: usize = 1000000007;

fn read<T: std::str::FromStr>() -> T {
    use std::io::Read;
    let stdin = std::io::stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

// =========



Measured memory_bytes: 5028
from collections import deque
n,q=map(int,input().split())
tree=[[] for _ in range(n)]
for i in range(n-1):
    a,b=map(int,input().split())
    a-=1
    b-=1
    tree[a].append(b)
    tree[b].append(a)
cnt=[0]*n
for i in range(q):
    p,x=map(int,input().split())
    cnt[p-1]+=x

stack=deque([[0,0,-1]]) # 現在地、その位置で引き継いできたcount、前の位置

while stack:
    num,count,preb = stack.pop()
    cnt[num]+=count
    for i in tree[num]:
        if i == preb:
            continue
        stack.append([i,cnt[num],num])

print(*cnt)

Measured memory_bytes: 140476
import sys
input = sys.stdin.readline
from collections import *

def compress(l):
    l = list(set(l))
    l.sort()
    idx = defaultdict(int)

    for i in range(len(l)):
        idx[l[i]] = i
    
    return idx
    
class BIT:
    def __init__(self, n):
        self.n = n
        self.bit = [0]*(n+1)
    
    def add(self, i, x):
        i += 1
        
        while i<=self.n:
            self.bit[i] += x
            i += i&(-i)

    def acc(self, i):
        s = 0
        
        while i>0:
            s += self.bit[i]
            i -= i&(-i)
        
        return s

N = int(input())
xy = [tuple(map(int, input().split())) for _ in range(N)]
xy.sort(key=lambda t: t[0])
idx = compress([xy_i[1] for xy_i in xy])
lbit = BIT(N)
rbit = BIT(N)

for i in range(N):
    rbit.add(i, 1)
    
ans = 0
MOD = 998244353

for i in range(N):
    y = xy[i][1]
    rbit.add(idx[y], -1)
    a = i-lbit.acc(idx[y])
    b = lbit.acc(idx[y])
    c = rbit.acc(idx[y])
    d = N-1-i-rbit.acc(idx[y])
    add = 2*pow(2, N-1, MOD)-1
    pa = pow(2, a, MOD)
    pb = pow(2, b, MOD)
    pc = pow(2, c, MOD)
    pd = pow(2, d, MOD)
    add = (add-(pa-1))%MOD
    add = (add-(pb-1))%MOD
    add = (add-(pc-1))%MOD
    add = (add-(pd-1))%MOD
    add = (add-(pa*pb-pa-pb+1))%MOD
    add = (add-(pb*pc-pb-pc+1))%MOD
    add = (add-(pc*pd-pc-pd+1))%MOD
    add = (add-(pd*pa-pd-pa+1))%MOD
    ans += add
    ans %= MOD
    lbit.add(idx[y], 1)

print(ans)

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

namespace AtCoder
{
    class Program
    {
        static void Main(string[] args)
        {
            //[summary]B - Exchange
            var line = ReadLine();
            int a = line[0];
            int b = line[1];
            int k = line[2];

            for(int i = 0; i < k; i++)
            {
                if (i % 2 == 0)
                {
                    if (a % 2 == 1)
                    {
                        a--;
                    }

                    b += a / 2;
                    a /= 2;
                }
                else
                {
                    if (b % 2 == 1)
                    {
                        b--;
                    }

                    a += b / 2;
                    b /= 2;
                }                                  
            }

            Console.WriteLine("{0} {1}", a, b);
        }

        static List<int> ReadLine()
        {
            var line = Console.ReadLine();
            var array = line.Split(' ');

            return array.Select(x => int.Parse(x)).ToList();
        }
    }
}

Measured memory_bytes: 13268
#!/usr/bin/env python
# coding: utf-8

def ri():
    return int(input())

def rl():
    return list(input().split())

def rli():
    return list(map(int, input().split()))

def check(s):
    for i in range(len(s)):
        if s[i] != s[len(s)-1-i]:
            return False
    return True

def main():
    x, y, z = rli()
    print(z, x, y)


if __name__ == '__main__':
    main()


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

inline int read()
{
	int x=0,f=1; char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1; ch=getchar();}
	while(ch>='0'&&ch<='9'){x=x*10+ch-'0'; ch=getchar();}
	return x*f;
}
inline void Add(int &x,int y)
{
	x+=y; if(x>=mod) x-=mod;
	if(x<0) x+=mod;
}
int n,m,k,F[6000][6000];
int main()
{
	F[0][0]=1; n=read(); m=read(); k=read();
	for(int i=0;i<(n+m-1)/(k-1);i++)
		for(int j=0;j<=m;j++) for(int l=0;l<k;l++)
			if(j+l<=m) Add(F[i+1][j+l],F[i][j]);
	int Ans=0; while(m>0)
		Add(Ans,F[(n+m-1)/(k-1)][m]),m-=k-1;
	cout << Ans << endl;
}

Measured memory_bytes: 93440
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
    int a[10],i;
    cin>>a[0]>>a[1]>>a[2]>>a[3]>>a[4]>>a[5]>>a[6]>>a[7]>>a[8]>>a[9];
    for(i=0;i<10;i++){
        cin>>a[i];
    }
    sort(a,a+10);
    cout<<a[9]<<endl;
    cout<<a[8]<<endl;
    cout<<a[7]<<endl;
       return 0;
}

Measured memory_bytes: 3160
#include <bits/stdc++.h>
#define Set(a, v) memset(a, v, sizeof(a))
using namespace std;
inline bool chkmin(int &a, int b) {return b < a ? a = b, 1 : 0;}
inline bool chkmax(int &a, int b) {return b > a ? a = b, 1 : 0;}
const int N = 1e5 + 1e3;
int fuck[N][31];
int main () {
	int n,c;
	cin>>n;
	cin>>c;
	for(int i=1;i<=n;i++){
		int S,T,cn;
		cin>>S>>T>>cn;
		++fuck[S][cn];
		--fuck[T+1][cn];
	}
	int cao[31]={0};
	int ooh=0;
	for(int i=1;i<=1e5+1e3;i++){
		int now = 0;
		for(int j=1;j<=c;j++){
			cao[j]+=fuck[i][j];
			if(cao[j])++now;
		}
		chkmax(ooh,now);
	}
	cout<<ooh<<endl;
    return 0;
}

Measured memory_bytes: 12416
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
ll A[18];
vector<pair<ll,ll>> dp[18][18];


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	ll L,R;
	cin>>L;
	N-=2;
	FOR(i,N) cin>>A[i];
	cin>>R;
	
	if(N==0) {
		cout<<L+R<<endl;
		return;
	}
	
	FOR(i,N) dp[i][1].push_back({A[i],A[i]});
	
	for(l=2;l<=N;l++) {
		for(x=0;x+l<=N;x++) {
			vector<pair<ll,ll>> R;
			
			for(y=x;y<x+l;y++) {
				if(y==x) {
					FORR(d,dp[x+1][l-1]) {
						R.push_back({d.first+A[y],d.first+A[y]+d.second});
					}
				}
				else if(y+1==x+l) {
					FORR(d,dp[x][l-1]) {
						R.push_back({d.first+A[y]+d.second,A[y]+d.second});
					}
				}
				else {
					FORR(d1,dp[x][y-x]) {
						FORR(d2,dp[y+1][x+l-(y+1)]) {
							R.push_back({d1.first+A[y]+d1.second+d2.first,d1.second+d2.first+A[y]+d2.second});
						}
					}
				}
			}
			
			sort(ALL(R));
			ll pre=1LL<<62;
			FORR(r,R) if(r.second<pre) {
				dp[x][l].push_back(r);
				pre=r.second;
			}
		}
		
	}
	
	ll ret=1LL<<62;
	FORR(d,dp[0][N]) ret=min(ret,d.first+d.second);
	cout<<ret+L+R<<endl;
	
	
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 640
S = input()

lS = len(S)
if lS % 2 == 0:
    mind = int(lS/2)
    maeS = S[:mind]
    atS = S[mind:]
#     print(maeS, atS)
else:
    mind = int(lS//2)
    maeS = S[:mind]
    atS = S[mind+1:]
#     print(maeS, atS)
#     print(atS[::-1])

revatS = atS[::-1]
count = 0
# print(maeS, revatS)
for i in range(len(maeS)):
#     print(maeS[i],revatS[i])
    if maeS[i] != revatS[i]:
        count += 1

print(count)
    

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    int n;
    cin >> n;
    int cnt[110] = {};
    for (int i = 2; i <= n; i++)
    {
        int m = i;
        for (int j = 2; j <= n; j++)
        {
            while (m % j == 0)
            {
                cnt[j]++;
                m /= j;
            }
        }
    }
    //rep(i, n) cout << cnt[i + 1] << endl;
    int ans = 0;
    rep(i, 110) if (cnt[i] >= 74) ans++;
    rep(i, 110) Rep(j, i + 1, 110)
    {
        if (cnt[i] >= 2 && cnt[j] >= 24)
            ans++;
        if (cnt[i] >= 24 && cnt[j] >= 2)
            ans++;
        if (cnt[i] >= 14 && cnt[j] >= 4)
            ans++;
        if (cnt[i] >= 4 && cnt[j] >= 14)
            ans++;
    }
    rep(i, 110) Rep(j, i + 1, 110) Rep(k, j + 1, 110)
    {
        if (cnt[i] >= 2 && cnt[j] >= 4 && cnt[k] >= 4)
            ans++;
        if (cnt[i] >= 4 && cnt[j] >= 2 && cnt[k] >= 4)
            ans++;
        if (cnt[i] >= 4 && cnt[j] >= 4 && cnt[k] >= 2)
            ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define fi first
#define se second
#define pb push_back
template<class T> inline int chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline int chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const int INF = 1<<30;
const ll LINF = 1LL<<58;

int ans[202020];
vector<int> A(202020);
vector<int> G[202020];
vector<int> X(202020, INF);

void dfs(int x, int p){
    int tmp = *lower_bound(all(X), A[x]);
    *lower_bound(all(X), A[x]) = A[x];
    ans[x] = lower_bound(all(X), INF) - X.begin();
    for(auto nxt : G[x]) {
        if(nxt == p) continue;
        dfs(nxt, x);
    }
    *lower_bound(all(X), A[x]) = tmp;
    return;
}

void solve() {
    int n;
    cin >> n;
    rep(i, n) cin >> A[i];
    rep(i, n - 1) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        G[a].pb(b);
        G[b].pb(a);
    }
    dfs(0, -1);
    rep(i, n) cout << ans[i] << endl;
    return;
}

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


Measured memory_bytes: 27856
#include <bits/stdc++.h>
using namespace std;
#define ff first
#define ss second
#define len(x) (int)(x.size())
#define all(vs) vs.begin(), vs.end()
using ii = pair<int, int>;
using ll = long long;

int32_t main(){
	ios::sync_with_stdio(0);
	string st;
	cin >> st;
	if(st[2]==st[3] and st[4]==st[5])
		cout << "Yes\n";
	else 
		cout << "No\n";
}


Measured memory_bytes: 3636