akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <queue>
#include <stack>
#include <cstring>

using namespace std;

typedef long long LL;
typedef vector<LL> VL;
typedef vector<vector<LL>> VVL;
typedef vector<string> VS;

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

LL llRead(){
  LL a;
  cin >> a;
  return a;
};

string stringRead(){
  string a;
  cin >> a;
  return a;
};

vector<LL> vlRead(LL a){
  vector<LL> rv;
  REP(i, a){
    LL input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}

vector<string> vsRead(LL a){
  vector<string> rv;
  REP(i, a){
    string input;
    cin >> input;
    rv.push_back(input);
  }
  return rv;
}
vector<vector<LL>> vvlRead(LL a, LL b){
  vector<vector<LL>> rv;
  REP(i, a){
    rv.push_back(vector<LL>());
    REP(j, b) {
      LL input;
      cin >> input;
      rv.at(i).push_back(input);
    }
  }
  return rv;
}

#if 1
#define debug(d) debug1(__LINE__,#d, d)
void debug1(LL line, const char* name, VL& v) {
  cout << line << ":" << name << ":vector<LL>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, LL i) {
  cout << line << ":" << name << ":LL " << i << endl;;
}
void debug1(LL line, const char* name, VS& v) {
  cout << line << ":" << name << ":vector<string>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, VVL& v) {
  cout << line << ":" << name << ":vector<vector<LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    REP(j, (LL)v.at(i).size()) {
      cout << v.at(i).at(j) << " ";
    }
    cout << ", ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, char* s) {
  cout << line << ":" << name << ":char* " << s << endl;;
}
void debug1(LL line, const char* name, vector<const char*>& v) {
  cout << line << ":" << name << ":vector<const char*>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i) << " ";
  }
  cout << endl;
}
void debug1(LL line, const char* name, priority_queue<LL>& p) {
  cout << line << ":" << name << ":priority_queue<LL>(" << p.size() << ") ";
  priority_queue<LL> copy = p;
  while(!copy.empty()) {
    cout << copy.top() << " ";
    copy.pop();
  }
  cout << endl;
}
void debug1(LL line, const char* name, vector<pair<LL,LL>>& v) {
  cout << line << ":" << name << ":vector<pair<LL,LL>>(" << v.size() << ") ";
  REP(i, (LL)v.size()) {
    cout << v.at(i).first << "," << v.at(i).second << " ";
  }
  cout << endl;
}
#else
#define debug(n)
#endif

int main(int argc, const char * argv[]) {
	cout.precision(16);
  // source code

  auto n = llRead();

  if (n%2==0) {
    cout << (n-1)/2 << endl;
  } else {
    cout << n/2 << endl;
  }

  return 0;
}


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

int main() {
    int k;
    string s;
    cin >> k >> s;
    if (s.size() > k) {
        cout << s.substr(0,k) << "..." << endl;
    }
    else{
        cout << s << endl;
    }
}

Measured memory_bytes: 3568
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(ll i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
#define INF 1000000000000000LL
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
//#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl

signed main(){
	IO_STREAM;
	long double A,B;
	cin>>A>>B;
	ll ans;
	ans=(ll)(A*B);
	cout<<ans<<endl;
	return 0;
}


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

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define PI ( acos(-1.0) )
#define mod 1000000007LL
#define maxn 1000002
#define IN freopen("C.in","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define INF 2000000000000000000LL
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

using namespace __gnu_pbds;
using namespace std ;

typedef tree< i64, null_type, less<i64>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef pair<i64, i64> pii;

int main()
{
    i64 i , j , k ;

    scanf("%lld %lld",&i,&j) ;

    if(i%j==0){
        printf("-1\n") ;
        return 0 ;
    }

    printf("%lld\n",i) ;

    return 0 ;
}


Measured memory_bytes: 256
/*
 * wafuIroha.cpp
 *
 *  Created on: 2020/02/23
 *      Author: black
 */
#include <iostream>
using namespace std;

int main(){
	int n;
	cin >> n;
	int count = 0;

	for (int i = 1; i < n+1; ++i){
		count+=i;
	}

	cout << count << endl;

	return 0;
}



Measured memory_bytes: 256
/*huypheu
5 50
50 40 30 20 10
*/

#include <bits/stdc++.h>
#define int long long
using namespace std;

int a[1000007];

signed main()
{
	int n,len;
	cin >> n >> len;
	for(int i=1;i<=n;i++)
	{
		cin >> a[i];
	}
	int ma=0,mi=1;
	for(int i=1;i<n;i++)
	{
		if(a[i]+a[i+1]>ma) ma=a[i]+a[i+1],mi=i;
	}
	if(a[mi]+a[mi+1]<len) cout << "Impossible\n"; else
	{
		cout << "Possible\n";
		for(int i=1;i<mi;i++) cout << i << "\n";
		for(int i=n-1;i>=mi+1;i--) cout << i << "\n";
			cout << mi << "\n";
	}
	return 0;
}

Measured memory_bytes: 1536
Scanf.scanf " %d %d" @@ fun n m ->
  let roads = Array.make n 0 in
  for i = 0 to m - 1 do
    Scanf.scanf " %d %d" @@ fun a b ->
      roads.(a - 1) <- roads.(a - 1) + 1;
      roads.(b - 1) <- roads.(b - 1) + 1
  done;
  Array.iter (fun r -> Printf.printf "%d\n" r) roads

Measured memory_bytes: 384
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	const initialBufSize = 4096
	const maxBufSize = 1000000
	scanner.Buffer(make([]byte, initialBufSize), maxBufSize)
	scanner.Split(bufio.ScanWords)
	var A int
	scanner.Scan()
	A, _ = strconv.Atoi(scanner.Text())
	var B int
	scanner.Scan()
	B, _ = strconv.Atoi(scanner.Text())
	var H int
	scanner.Scan()
	H, _ = strconv.Atoi(scanner.Text())
	var M int
	scanner.Scan()
	M, _ = strconv.Atoi(scanner.Text())
	fmt.Println(solve(A, B, H, M))
}
func solve(A int, B int, H int, M int) float64 {
	shortDegree := 360.0/12.0*float64(H) + 30.0/60.0*float64(M)
	longDegree := 360.0 / 60.0 * float64(M)
	smallDegree := shortDegree
	bigDegree := longDegree
	if smallDegree > bigDegree {
		smallDegree, bigDegree = bigDegree, smallDegree
	}
	diff := bigDegree - smallDegree
	if diff > 180 {
		diff = 360 - diff
	}
	if diff > 180 {
		diff -= 180
	}
	ret := math.Pow(float64(A), float64(2)) + math.Pow(float64(B), float64(2)) - 2.0*float64(A)*float64(B)*math.Cos(diff*math.Pi/180)
	return math.Sqrt(ret)
}


Measured memory_bytes: 1760
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int n, k;
		int a[];

		n = sc.nextInt();
		k = sc.nextInt();
		a = new int[n];
		for (int i = 0; i < n; i++) {
			a[i] = i + 1;
		}
		for (int i = 0; i < k; i++) {
			String st = sc.next();
			int left = 0, right = 0;
			for (int j = 0; ; j++) {
				left *= 10;
				left += st.charAt(j) - '0';
				if (st.charAt(j + 1) == ',') {
					for (int l = j + 2; l < st.length(); l++) {
						right *= 10;
						right += st.charAt(l) - '0';
					}
					break;
				}
			}
			int swap = a[left - 1];
			a[left - 1] = a[right - 1];
			a[right - 1] = swap;
		}
		for (int i = 0; i < n; i++) {
			System.out.println(a[i]);
		}
	}
}

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

int main(){
  int A,B,sum;
  cin >> A >> B;
  
for(int i=0; i<2; i++){
  if(A>=B){
    sum += A;
    A = A-1;
  }
  else{
    sum += B;
    B = B-1;
  }
}
  cout << sum << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <unordered_map>
typedef long long ll;
#define rep(i,m,n) for(ll i = (m); i < (n); i++)
#define rrep(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define print2(x,y) cout << (x) << " " << (y) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " \n"[i == n-1];}
#define printp(x,n) for(ll i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
const ll MOD = 1e9 + 7;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >> s;
    rep(i,0,s.size()){
        if(s[i] == ','){
            cout << " ";
        }else{
            cout << s[i];
        }
    }
    cout << endl;

}


Measured memory_bytes: 256
// vvvvvvvvvvvv TEMPLATE vvvvvvvvvvvv
#include <bits/stdc++.h>
using namespace std; using ll = long long; using P = pair<ll, ll>;
const ll linf = 1e18; const double eps = 1e-12, pi = acos(-1);
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define each(i,a) for (auto&& i : a)
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define eb emplace_back
#define all(a) begin(a),end(a)
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)
#define min(x,y) (x < y ? x : y)
#define max(x,y) (x < y ? y : x)
template<typename Head> void out(Head h) { cout << h << endl; } template<typename Head, typename... Tail>void out(Head h, Tail... t) { cout << h << " "; out(t...); }
template<typename T> istream& operator>>(istream& is, vector<T>& v) { each(x,v) is >> x; return is; }
template<typename T> ostream& operator<<(ostream& os, const vector<T>& v) { rep(i,v.size()) { if (i) os << " "; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<string>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
template<typename T> ostream& operator<<(ostream& os, const vector<vector<T>>& v) { rep(i,v.size()) { if (i) os << endl; os << v[i]; } return os; }
struct yes_no : std::numpunct<char> { string_type do_truename() const { return "Yes"; } string_type do_falsename() const { return "No"; } };
void solve(); int main() {
  ios::sync_with_stdio(false); cin.tie(0); locale loc(locale(), new yes_no); cout.imbue(loc); cout << fixed << setprecision(10) << boolalpha;
  solve();
}
// ^^^^^^^^^^^^ TEMPLATE ^^^^^^^^^^^^

void solve() {
  ll n; cin >> n;
  vector<ll> a(n); cin >> a;
  each(x, a) --x;
  stack<ll> S;
  string ans = "";
  ll cnt = 0, pot = 0, pos = 0;
  rep(i, 2*n) {
    // cout << cnt << " " << pot << " " << ans << endl;
    if (S.size() > 0 && pos < n && S.top() == a[pos]) {
      S.pop();
      ans += ')';
      --pot;
      ++pos;
    }
    else {
      S.push(cnt++);
      ans += '(';
      ++pot;
    }
    if (pot < 0) {
      cout << ":(" << endl;
      return;
    }
  }
  if (pot > 0) {
    cout << ":(" << endl;
    return;
  }
  cout << ans << endl;
}



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

typedef long long ll;

const int mod = 1e9 + 7;

ll cal[2005][2005];

int main() {
    ll n, k;
    cin >> n >> k;
    cal[0][0] = cal[1][0] = cal[1][1] = 1;
    for (int i = 1; i <= 2000; i++) {
        cal[i][0] = 1;
        for (int j = 1; j <= i; j++) {
            cal[i][j] = cal[i - 1][j - 1] + cal[i - 1][j];
            cal[i][j] %= mod; 
        }
    }
    for (int i = 1; i <= k; i++) {
        ll a = cal[k - 1][i - 1];
        ll b = 0;
        if (n - k + 1 >= i) b = cal[n - k + 1][i];
        cout << a * b % mod << '\n';
    }

    return 0;
} 

Measured memory_bytes: 30208
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <functional>
#include <vector>
#define nummax 110000
using namespace std;

int gcd(int a, int b)
{
	int x;
	while (1)
	{
		x = a % b;
		if (x == 0)
			return b;
		else
		{
			a = b;
			b = x;
		}
	}
}

int main() {
	int i, iout = 0, N, A[nummax], ans, gcdL[nummax], gcdR[nummax], gcdtmp, gcdmax = 0, imax;
	cin >> N;
	for (i = 1; i <= N; i++)
	{
		cin >> A[i];
	}
	gcdL[1] = A[1];
	gcdR[N] = A[N];
	for (i = 2; i <= N; i++)
	{
		gcdL[i] = gcd(gcdL[i - 1], A[i]);
	}
	for (i = N - 1; i >= 1; i--)
	{
		gcdR[i] = gcd(gcdR[i + 1], A[i]);
	}
	for (i = 1; i <= N; i++)
	{
		if (i == 1)
			gcdtmp = gcdR[2];
		else if (i == N)
			gcdtmp = gcdL[N - 1];
		else gcdtmp = gcd(gcdL[i - 1], gcdR[i + 1]);
		if (gcdtmp > gcdmax)
		{
			gcdmax = gcdtmp;
			imax = i;
		}
	}
	cout << gcdmax << endl;
}

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

#define ALL(x) x.begin(), x.end()

using namespace std;

typedef long long ll;
typedef vector<int> vi;

void solve(void) {

	int n;
	cin >> n;

	vi A(n);
	for(int& x : A) {
		cin >> x;
	}

	vi dp(n);
	dp[0] = 0;
	dp[1] = abs(A[1] - A[0]);

	for(int i = 2; i < n; i++) {
		dp[i] = min(dp[i-1] + abs(A[i]-A[i-1]), dp[i-2] + abs(A[i]-A[i-2]));
	}

	cout << dp[n-1] << '\n';

}

int main(void) {

	solve();
	return 0;
}


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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9;
const ll MOD = 1e9 + 7;

const int MAXN = 1e6 + 5;

char c[MAXN];

int cnt[200];
int cnt_delete[200];

struct node {
	char sym;
	node *prv, *nxt;
	
	node () {
		sym = 0;
		prv = nxt = NULL;
	}
} my_list[MAXN];

node * head;

node * my_erase(node * cur) {
	if (cur == head) {
		head = cur->nxt;
	}
	if (cur->prv != NULL) {
		cur->prv->nxt = cur->nxt;
	}
	if (cur->nxt != NULL) {
		cur->nxt->prv = cur->prv;
	}
	cnt[cur->sym]--;
	return cur->nxt;
}

void solve(){
	scanf("%s", &c[0]);
	int n = strlen(c);
	char prv = 0;
	int top = 0;
	REP(i, 0, n) {
		if (c[i] != prv) {
			my_list[top].sym = c[i] - 'A';
			if (top > 0) {
				my_list[top].prv = &my_list[top - 1];
				my_list[top - 1].nxt = &my_list[top];
			}
			top++;
			cnt[c[i] - 'A']++;
		}
		prv = c[i];
	}
	char maxi = 0;
	REP(i, 1, 3) {
		if (cnt[i] > cnt[maxi]) {
			maxi = i;
		}
	}
	head = &my_list[0];
	node * cur = head;
	while(!(cnt[maxi] == cnt[(maxi + 1) % 3] || cnt[maxi] == cnt[(maxi + 2) % 3])) {
		while(cur != NULL && cur->sym != maxi) {
			cur = cur->nxt;
		}
		if (cur == NULL) {
			break;
		}
		if ((cur->prv == NULL || cur->nxt == NULL || cur->nxt->sym != cur->prv->sym)) {
			cur = my_erase(cur);
		} else {
			cur = cur->nxt;
		}
	}
	
	/*printf("%d %d %d\n", cnt[0], cnt[1], cnt[2]);
	for(cur = head; cur != NULL; cur = cur->nxt) {
		putchar(cur->sym + 'A');
	}
	putchar('\n');
	return;*/
	
	cur = head;
	while(!(cnt[0] == cnt[1] && cnt[0] == cnt[2])) {
		if (cur == head && cur->nxt == NULL) {
			return;
		}
		if (cur->nxt == NULL) {
			cur = head;
		}
		char x = cur->sym;
		char y = cur->nxt->sym;
		char z = 0 + 1 + 2 - x - y;
		if ((cnt[x] >= cnt[z] && cnt[y] >= cnt[z] || (cnt[z] < cnt[x] || cnt[z] < cnt[y]) && cnt[x] != cnt[y]) 
			&& (cur->prv == NULL || cur->nxt->nxt == NULL || cur->prv->sym != cur->nxt->nxt->sym)) {
			cur = my_erase(cur);
			cur = my_erase(cur);
		} else {
			cur = cur->nxt;
		}
		
		//printf("%d %d %d\n", cnt[0], cnt[1], cnt[2]);
	}
	
	for(cur = head; cur != NULL; cur = cur->nxt) {
		putchar(cur->sym + 'A');
	}
	putchar('\n');
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

long long Min(long long a,long long b){
  if(a > b){
    return b;
  }
  else{
    return a;
  }
}

int main() {
  long long n,a,b,c,d,e;
  cin >> n >> a >> b >> c >> d >> e;
  long long min = Min(a,b);
  min = Min(min,c);
  min = Min(min,d);
  min = Min(min,e);
  if(min >= n){
    cout << 5 << endl;
  }
  else{
    if(n%min == 0){
      cout << n/min+4 << endl;
    }
    else{
      cout << n/min+5 << endl;
    }
  }
}


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

using namespace std;

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    int K;
    cin >> s >> K;
    int n = s.size();
    int dp[n+1][2][K+5];
    memset(dp, 0, sizeof(dp));
    dp[0][0][0] = 1;

    for (int i = 0; i < n; ++i) for (int j = 0; j < 2; ++j) for (int k = 0; k < K+1; ++k) {
        int lim = j ? 9 : s[i]-'0';
        for (int d = 0; d < lim+1; ++d) {
            dp[i+1][j || d < lim][k + (d != 0)] += dp[i][j][k];
        }
    }
    cout << dp[n][0][K] + dp[n][1][K] << '\n';

    return 0;
}


Measured memory_bytes: 256
# AOJ 2801: Suntan
# Python3 2018.7.11 bal4u

from bisect import bisect_left

T, N = int(input()), int(input())
a, s, t = [0], [0], [0]
for i in range(N):
	_s, _t = map(int, input().split())
	s.append(_s)
	t.append(_t)
	a.append(a[-1]+_t-_s)
s.append(1<<62)
t.append(1<<62)
ans = 0
k = bisect_left(t, T, 0)-1
for i in range(1, N+1):
	x = s[i]+T
	k = bisect_left(t, x, k)-1
	y = a[k]-a[i-1]
	if x > s[k+1]: y += x-s[k+1]
	if y > ans:
		ans = y;
		if ans == T: break
print(ans)


Measured memory_bytes: 17832
import sys
sys.setrecursionlimit(10**7) #再帰関数の上限,10**5以上の場合python
import math
from copy import copy, deepcopy
from copy import deepcopy as dcp
from operator import itemgetter
from bisect import bisect_left, bisect, bisect_right#2分探索
#bisect_left(l,x), bisect(l,x)#aはソート済みである必要あり。aの中からx未満の要素数を返す。rightだと以下
from collections import deque, defaultdict
#deque(l), pop(), append(x), popleft(), appendleft(x)
#q.rotate(n)で → にn回ローテート
from collections import Counter#文字列を個数カウント辞書に、
#S=Counter(l),S.most_common(x),S.keys(),S.values(),S.items()
from itertools import accumulate,combinations,permutations,product#累積和
#list(accumulate(l))
from heapq import heapify,heappop,heappush
#heapify(q),heappush(q,a),heappop(q) #q=heapify(q)としないこと、返り値はNone
from functools import reduce,lru_cache#pypyでもうごく
#@lru_cache(maxsize = None)#maxsizeは保存するデータ数の最大値、2**nが最も高効率
from decimal import Decimal
from argparse import ArgumentParser

args=ArgumentParser()
args.add_argument('-loc', '--local', type=bool,default=False)
LOCAL=args.parse_args().local

def input(): 
    x=sys.stdin.readline(); 
    if x[-1]=="\n": 
        return x.rstrip() 
    return x
    
def printe(*x):_=print("## ",*x,file=sys.stderr) if LOCAL else 0
def printl(li): _=print(*li, sep="\n") if li else None
def argsort(s, return_sorted=False): 
    inds=sorted(range(len(s)), key=lambda k: s[k])
    if return_sorted: return inds, [s[i] for i in inds]
    return inds
def alp2num(c,cap=False): return ord(c)-97 if not cap else ord(c)-65
def num2alp(i,cap=False): return chr(i+97) if not cap else chr(i+65)
def matmat(A,B):
    K,N,M=len(B),len(A),len(B[0])
    return [[sum([(A[i][k]*B[k][j]) for k in range(K)]) for j in range(M)] for i in range(N)]
def matvec(M,v):
    N,size=len(v),len(M)
    return [sum([M[i][j]*v[j] for j in range(N)]) for i in range(size)]
def T(M):
    n,m=len(M),len(M[0])
    return [[M[j][i] for j in range(n)] for i in range(m)]
def binr(x): return bin(x)[2:]
def bitcount(x): #xは64bit整数
    x= x - ((x >> 1) & 0x5555555555555555)
    x= (x & 0x3333333333333333) + ((x >> 2) & 0x3333333333333333)
    x= (x + (x >> 4)) & 0x0f0f0f0f0f0f0f0f 
    x+= (x >> 8); x+= (x >> 16); x+= (x >> 32) 
    return x & 0x7f

def main():
    mod = 1000000007
    #w.sort(key=itemgetter(1),reverse=True)  #二個目の要素で降順並び替え

    N = int(input())
    #N, K = map(int, input().split())
    P = tuple(map(int, input().split())) #1行ベクトル
    Q = tuple(map(int, input().split()))
    #L = tuple(int(input()) for i in range(N)) #改行ベクトル
    #S = tuple(tuple(map(int, input().split())) for i in range(N)) #改行行列
    a=-1
    b=-1
    cnt=0
    for j in permutations(tuple(range(1,N+1)),N):
        cnt+=1
        jt=tuple(j)
        if jt==P:
            a=cnt
        if jt==Q:
            b=cnt
    print(abs(a-b))




if __name__ == "__main__":
    main()

Measured memory_bytes: 77492
#include <iostream>
#include <string>
#include <cstring>
#include <algorithm>
#include <functional>
#include <cmath>
#include <set>
#include <queue>
#include <deque>
#include <vector>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
using namespace std;
typedef unsigned long long ull;
typedef long long ll;

int main()
{
	int N, K;
	cin >> N >> K;
	vector<ll> a(N);
	for (auto i = 0; i < N; ++i)
	{
		cin >> a[i];
	}

	auto ans = LLONG_MAX;
	for (auto i = 0; i < (1 << (N - 1)); ++i)
	{
		auto next = a[0] + 1;
		auto sum = 0ll;
		auto num = 1;
		for (auto j = 0; j < N - 1; ++j)
		{
			if (a[j + 1] < next)
			{
				auto bit = 1 << j;
				if ((i & bit) != 0)
				{
					sum += next - a[j + 1];
					++num;
					++next;
				}
			}
			else
			{
				++num;
				next = a[j + 1] + 1;
			}
		}

		if (num >= K)
		{
			ans = min(ans, sum);
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
sd = input()
t = input()

n = len(sd)
m = len(t)
s = []

# sd を後ろから見ていき、 t の入りそうな場所を探す
for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]
    for j in range(m + 1):
        # 1文字ずつ順に入りうるか調べ、最後まで入るなら "?" を "a" に置き換えて出力
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break

print("UNRESTORABLE")

Measured memory_bytes: 9108
#include <bits/stdc++.h>
using namespace std;
 
#define REP(i, n) for (ll i = 0; i < n; i++)
#define REPR(i, n) for (ll i = n; i >= 0; i--)
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define FORR(i, m, n) for (ll i = m; i >= n; i--)
#define REPO(i, n) for (ll i = 1; i <= n; i++)
#define ll long long
#define INF (ll)1 << 60
#define MINF (-1 * INF)
#define ALL(n) n.begin(), n.end()
#define MOD 1000000007
#define P pair<ll, ll>

ll n, q;
vector<ll> l, v[400][26], cnt(400);
string s;
int main() {
    cin >> n >> q >> s;
    for(int i = 1; i <= sqrt(n); i++){
        if(n % i == 0){
            l.push_back(i);
            if(i != n / i)l.push_back(n / i);
        }
    }
    sort(ALL(l), greater<ll>());
    REP(i, l.size()){
        REP(j, l[i]){
            REP(k, 26){
                v[i][k].push_back(0);
            }
        }
    }
    REP(i, n){
        REP(j, l.size()){
            v[j][s[i] - 'a'][i % l[j]]++;
            if(v[j][s[i] - 'a'][i % l[j]] == n / l[j])cnt[j]++;
        }
    }
    //REP(i, l.size())cout << cnt[i]<<endl;
    REP(i, q){
        ll a;
        char c;
        cin >> a >> c;
        a--;
        REP(j, l.size()){
            if(v[j][s[a] - 'a'][a % l[j]] == n / l[j])cnt[j]--;
            v[j][s[a] - 'a'][a % l[j]]--;
        }
        REP(j, l.size()){
            v[j][c - 'a'][a % l[j]]++;
            if(v[j][c - 'a'][a % l[j]] == n / l[j])cnt[j]++;
        }
        ll ans = 0;
        REP(j, l.size()){
            if(cnt[j] == l[j])ans = l[j];
        }
        cout << ans << endl;
        s[a] = c;
    }
}



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

//solution:
int vis[100'001];

void dfs(vector<vector<int>>& adj, int u) {
  vis[u] = 1;
  for(auto& v: adj[u]) if(!vis[v]) {
    dfs(adj, v);
  }
}

void hike() {
  int n, m; cin >> n >> m;
  vector<vector<int>> adj(n + 1);
  for(int i = 0; i < m; ++i) {
    int u, v; cin >> u >> v;
    adj[u].push_back(v);
    adj[v].push_back(u);
  }
  int c = 0;
  for(int i = 1; i <= n; ++i) if(!vis[i]) {
    dfs(adj, i);
    c++;
  }
  cout << c - 1 << "\n";
}

signed main() {
  int t = 1; //cin >> t;
  while(t--) hike();
  return 0;
} //farewell, until we meet again..

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

int main() {
  int n, k;
  cin >> n >> k;
  double ans = 0;
  REP(i, 1, n+1){
    double tmp = 1;
    for(int j=i; j<k; j*=2) tmp/=2;
    ans += tmp/n;
  }
  cout << setprecision(12) << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <list>
#include <cassert>
#include <unordered_map>

#define _(x) { cout << #x << " = " << x << " "; }

const double E = 1e-8;
const double PI = acos(-1);
typedef long long ll;

using namespace std;

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> v(n);
    for (int i = 0; i < n; ++i) cin >> v[i];
    ll sum = 0, ans1 = 0, ans2 = 0;
    for (int i = 0; i < n; ++i) {
        sum += v[i];
        if (i % 2 == 0) {
            if (sum <= 0) {
                ans1 += (1 - sum);
                sum = 1;
            }
        } else if (sum >= 0) {
            ans1 += (sum+1);
            sum = -1;
        }
    }
    sum = 0;
    for (int i = 0; i < n; ++i) {
        sum += v[i];
        if (i % 2 == 1) {
            if (sum <= 0) {
                ans2 += (1-sum);
                sum = 1;
            } 
        } else if (sum >= 0) {
            ans2 += (1+sum);
            sum = -1;
        }
    }
    cout << min(ans1, ans2) << '\n';
    return 0;
}



Measured memory_bytes: 640
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;

//素因数分解
vector<pair<ll,int>> factorize(ll n){
    vector<pair<ll,int>>res;
    for(ll i=2;i*i<=n;i++){
        if(n%i)continue;
        res.emplace_back(i,0);
        while (n%i == 0)
        {
        n /= i;
        res.back().second++;
        }
        
    }
    if(n != 1) res.emplace_back(n,1);
    return res;
}

int main(){
    int n;
    cin >> n;
    int d[n];
    for(int i=0;i<n;i++)cin >> d[i];
    sort(d,d+n);
    bool ans=false;
    if(d[(n/2)-1] < d[n/2])ans =true;
    if(ans)cout << d[n/2] - d[(n/2)-1] << endl;
    else cout << 0 << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <functional>
#include <cstdio>
#include <climits>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

int main() {
    int H, W, h, w;
    cin >> H >> W;
    cin >> h >> w;
    cout << (H - h) * (W - w) << endl;
}


Measured memory_bytes: 256
import java.util.*;
 
public class Main {
	
	static int N;
	static int[] ary = new int[256];
	
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		for(int i=0;i<=9;i++){
			for(int j=0;j<=9;j++){
				for(int k=0;k<=9;k++){
					for(int l=0;l<=9;l++){
						ary[i+j+k+l]++;
					}
				}
			}
		}
		
		while(sc.hasNext()){
			N = sc.nextInt();
			System.out.println(ary[N]);
		}
	}
}

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

int main()
{
    double pi=3.14159265358979;
    double a, b, x;
    cin >> a >> b >> x;

    double height = x/a/a;
    double ans;
    double y;

    if(height*2<=b){
        y = x*2/a/b;
        ans = 90-180/pi*atan(y/b);
    }else{
        y = x*2/a/a-b;
        ans = 90 - 180/pi*atan(a/(b-y));
    }
  
    printf("%f\n",ans);
  
    return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>
void swap(int *x,int *y);
int main(){
  int i,j,N,flag=1,*A,count=0;

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

  while(flag){
    flag=0;
    for(j=N-1;j>0;j--){
      if(A[j]<A[j-1]){
	swap(&A[j],&A[j-1]);
	flag=1;
	count++;
      }
    }
  }
  for(i=0;i<N-1;i++){
    printf("%d ",A[i]);
  }
  printf("%d\n",A[N-1]);
  printf("%d\n",count);
  
  free(A);
  return 0;
}
void swap(int *x,int *y){
  int a;
  a=*x;
  *x=*y;
  *y=a;
}

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

int main()
{
    int n, h, w;
    cin >> n >> h >> w;
    int a[1002], b[1002];
    int ans = 0;
    for(int i = 0; i < n; i++){
        cin >> a[i] >> b[i];
        if(a[i] >= h && b[i] >= w) ans++;
    }
    cout << ans << endl;
}

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

int main(){
  long long N,s,j,u,ans,c;
  string S;
  ans=0;
  cin>>S;
  j=0;
  N=S.size();
  for(int i=0;i<N;i++){
    if(S[i]=='W'){
      ans+=j;
    }
    else{
      j++;
    }
    }
 cout<<ans<<endl;
}

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

void rec(int d, ll val, vector<ll> &all)
{
    all.push_back(val);
    if (d == 10)
        return;
    for (int i = -1; i <= 1; i++)
    {
        int add = (val % 10) + i;
        if (add >= 0 && add <= 9)
            rec(d + 1, val * 10 + add, all);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int k;
    cin >> k;
    vector<ll> all;
    for (int v = 1; v < 10; v++)
        rec(1, v, all);

    sort(all.begin(), all.end());
    cout << all[k - 1] << endl;
    return 0;
}


Measured memory_bytes: 5340
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <queue>
#define FILL(a, n, x) memset((a), (x), sizeof ((a)[0]) * (n))
#define COPY(a, n, b) memcpy((b), (a), sizeof ((a)[0]) * (n))
using namespace std;

typedef long long li;

const int mod = 1e9 + 7;
inline int Add(int x) { return x >= mod ? x - mod : x; }
inline void Add(int &x, int y) { x += y; if (x >= mod) x -= mod; }
inline int Sub(int x) { return x < 0 ? x + mod : x; }
inline void Sub(int &x, int y) { x -= y; if (x < 0) x += mod; }
inline int Mul(int x, int y) { return (li)x * y % mod; }

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

const int maxn = 2e5;

int n, m, lim;
char s[maxn + 1];
int dp[maxn + 1];
int sum[maxn + 2];

void GetLim(void) {
  int cnt = 0;
  for (int i = 0; i < m; ++i) {
    if (s[i] == 'R') ++cnt; else break;
  }
  if (cnt & 1) lim = cnt; else lim = cnt + 1;
  cnt = 0;
  for (int i = 0; i < m; ++i) {
    if (s[i] == 'R') ++cnt; else {
      if (cnt & 1) lim = min(lim, cnt);
      cnt = 0;
    }
  }
}

void SolveSame(void) {
  static int dp[maxn + 1][2][2];
  dp[0][0][0] = dp[0][1][1] = 1;
  for (int i = 1; i < n; ++i) {
    for (int x = 0; x <= 1; ++x) {
      for (int y = 0; y <= 1; ++y) {
        for (int z = 0; z <= 1; ++z) {
          if (y != 1 || z != 1) {
            Add(dp[i][x][z], dp[i - 1][x][y]);
          }
        }
      }
    }
  }
  int ans = Add(Add(dp[n - 1][0][0] + dp[n - 1][0][1]) + dp[n - 1][1][0]);
  printf("%d\n", ans);
}

int main(void) {
  scanf("%d%d%s", &n, &m, s);
  if (s[0] == 'B') {
    for (int i = 0; i < m; ++i) {
      s[i] ^= 'R' ^ 'B';
    }
  }
  if (count(s, s + m, 'R') == m) {
    // the same
    SolveSame();
    return 0;
  }

  GetLim();
  lim = lim + 1 >> 1;
  if (n & 1) {
    puts("0");
    return 0;
  }
  n /= 2;

  for (int i = 1; i <= lim; ++i) {
    Add(dp[i], 2 * i);
  }
  for (int i = 1; i <= n; ++i) {
    // printf("this is %d\n", i);
    // calc dp[i]
    int L = max(1, i - lim), R = i;
    Add(dp[i], Sub(sum[R] - sum[L]));
    sum[i + 1] = Add(sum[i] + dp[i]);
  }
  printf("%d\n", dp[n]);
  return 0;
}


Measured memory_bytes: 3456
//c++ テンプレ
#include<bits/stdc++.h>
using namespace std;

typedef long long llint;
typedef long double ld;

#define inf 1e18
#define mod 1000000007
priority_queue<llint,vector<llint>,greater<llint> > que;
priority_queue<llint> Que;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int n;
llint a[100005];
llint sum=0;
void calc(int b,int c){
    llint x=a[b];
    sum-=(b*x);
    a[b]=0;
    a[c]+=x;
    sum+=(c*x);
}
void solve(){
    cin >> n;
    for(int i=0;i<n;i++){
        llint x;
        cin >> x;
        a[x]++;
    }
    for(llint i=1;i<100005;i++){
        sum+=(i*a[i]);
    }
    int q;
    cin >> q;
    int b,c;
    for(int i=0;i<q;i++){
        cin >> b >> c;
        calc(b,c);
        cout << sum << endl;
    }
   
}

int main(){
    solve();
    return 0;
}




Measured memory_bytes: 4336
#include <iostream>
#include <vector>
#include <list>
#include <unordered_set>
#include <set>
#include <unordered_map>
#include <map>
#include <stack>
#include <queue>
#include <cassert>
#include <cmath>
#include <algorithm>
#include <stdlib.h>
#include <stdio.h>
#include <fstream>
#include <tuple>

//....................................................................................................................//

using std::cin;
using std::cout;
using std::vector;
using std::list;
using std::unordered_set;
using std::set;
using std::map;
using std::unordered_map;
using std::multimap;
using std::unordered_multimap;
using std::pair;
using std::make_pair;
using std::min;
using std::max;
using std::swap;
using std::stack;
using std::deque;
using std::queue;
using std::ios_base;
using std::ifstream;
using std::ofstream;
using std::string;
using std::tuple;
using std::make_tuple;
using std::get;
using std::upper_bound;
using std::lower_bound;
using std::max_element;
using std::min_element;

//....................................................................................................................//

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned long ul;

[[maybe_unused]] const string endl = "\n";
[[maybe_unused]] const string sep = " ";
[[maybe_unused]] const string yes = "YES\n";
[[maybe_unused]] const string no = "NO\n";
[[maybe_unused]] const string ng = "NG\n";
[[maybe_unused]] const string ok = "OK\n";
[[maybe_unused]] const double pi = acos(-1);

//....................................................................................................................//



int main() {
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout.precision(10);
    string s;
    cin >> s;
    if (s[1] == 'R') {
        cout << "ABC";
    } else {
        cout << "ARC";
    }

    return 0;
}


Measured memory_bytes: 3132
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector2d(int,shop,n,10);
    vector2d(ll,my,n,11);
    in(shop,my);
    //rep(i,n)debug(shop[i]);
    int kaburi=0;
    ll ans=-1000000000000000000,d=0;
    for(int i=1;i<(1<<10);i++){
        bitset<10> bits(i);
        d=0;
        for(int y=0;y<n;y++){
            kaburi=0;
            for(int x=0;x<10;x++){
                kaburi+=(bits.test(x)&&shop[y][x]==1);
            }
            d+=my[y][kaburi];
        }
        ans=max(ans,d);
    }
    out(ans);
}

Measured memory_bytes: 3748
#include<bits/stdc++.h>
using namespace std;  
#pragma GCC optimize("Ofast") 
#define int long long
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define pb push_back 
#define eb emplace_back
#define fn for(int i =0 ;i <n;i++)
#define fn1 for( int i =1;i<=n; i++)
#define fm for(int j =0 ;j <m;j++)
#define fm1 for(int j =1;j<=m;j++)
#define fi first
#define se second
#define endl '\n'
#define PI  3.14159265358979323846
#define MOD 1000000007
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
const int N = 2e6+5;
const int INF = 1e18L;
#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...);
}
char ar[10][10];
int dp[N];
signed main(){
  #ifndef ONLINE_JUDGE
  freopen("input.txt","r",stdin);
  freopen("output.txt","w",stdout);
  #endif
  IOS;
  int T=1;
  // cin >> T;
  while(T--){
    int n , m, k;
    cin >> n >> m >> k;
    int tot =0;
    fn{
      fm{
        cin >> ar[i][j];
        tot+=ar[i][j]=='#';
      }
    }
    int ans =0;
    for(int r =0 ; r < 1<<n; r++){
      for(int c =0 ;c < 1<<m; c++){
        int b= 0 ;
        int vis[n][m]={};
        fn{
          if(((r>>i)&1)){
            fm{
              vis[i][j]=1;
              b+=ar[i][j]=='#';
            } 
          }
        }
        fm{
          if(((c>>j)&1)){
            fn{
               if(!vis[i][j]){
                b+=ar[i][j]=='#';
                vis[i][j]=1;
              }
            }
          }
        }
        // trace(tot, b , k);
        if(tot - b == k)ans++;
      }
    }
    cout<<ans;
  
  
  }
  return 0;
}

Measured memory_bytes: 3656
sx, sy, tx, ty = map(int, input().split())

w = tx - sx
h = ty - sy

print('R'*w, end='')
print('U'*h, end='')
print('L'*w, end='')
print('D'*h, end='')
print('D'*1, end='')
print('R'*(w+1), end='')
print('U'*(h+1), end='')
print('L'*1, end='')
print('U'*1, end='')
print('L'*(w+1), end='')
print('D'*(h+1), end='')
print('R'*1, end='')



Measured memory_bytes: 61828
import java.util.Scanner;

public class Main {
	
	static int maxA = (int)1e5;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int A[] = new int[N];
		for(int i=0;i<N;i++)A[i]=sc.nextInt();
		sc.close();
		
		int num[] = new int[maxA];
		
		for(int i=0;i<N;i++) num[A[i]]++;
		
		int cnt = 0;
		int dec = 0;
		for(int i=0;i<maxA;i++) {
			if(num[i]==0)continue;
			dec += (num[i]-1);
			cnt++;
		}
		
		int ans = 0;
		if(dec%2==0) ans = cnt;
		else ans = cnt - 1;
		
		System.out.println(ans);
	}
}


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

typedef long long int ll;

#define endl '\n'

bool cmp(pair <ll,ll> a, pair <ll,ll> b){

    if(a.first < b.first){
        return true;
    }
    if(a.first == b.first){
        if(a.second < b.second){
            return true;
        }
    }
    return false;

}

int main()
{

    std::ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);

    ll n;
    cin>>n;

    vector < pair <ll,ll> > vec;

    for(ll i=0;i<n;i++){
        ll a,b;
        cin>>a>>b;
        vec.push_back({b,a});
    }

    sort(vec.begin(),vec.end(),cmp);

    ll t = 0;

    for(ll i=0;i<n;i++){
        if(t+vec[i].second <= vec[i].first){
            t+=vec[i].second;
        }
        else{
            cout<<"No"<<endl;return 0;
        }
    }

    cout<<"Yes"<<endl;


}


Measured memory_bytes: 6256
#include<bits/stdc++.h>
using namespace std;
int main (){
int N, K;
cin >> N >> K;
int count = 0;
int x = N - K ;
int k = K - 1;
if(x % k == 0) cout <<( x / k) +1 << endl;
else cout << (x / k )+2 << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#include<bitset>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define PI 3.14159265359
typedef long long LL;

template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> void print_vector(vector<T> vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << vec[i] << " ";
	}
	cout << "]" << endl;
}
template<class T> void print_pair_vector(vector<pair<T, T> > vec) {
	cout << "[ ";
	for (int i = 0; i < vec.size(); i++) {
		cout << "(" << vec[i].first << "," << vec[i].second << ") ";
	}
	cout << "]" << endl;
}

const int INF = 1 << 30;

int main(void) {
	string a, b;
	cin >> a >> b;

	string tmp = a + b;
	int target_value = atoi(tmp.c_str());

	bool is_square = false;
	for (int i = 1; i <= 10000; i++) {
		if (target_value == i*i) {
			is_square = true;
		}
	}
	if (is_square) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <climits>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <string>
#include <deque>
#define INF_INT (INT_MAX / 2)
#define INF_LONG (LONG_MAX / 2)
//#define DEBUG true
#define DEBUG false
using namespace std;

const int MAX = 100001;
const int MOD = 1000000007;

typedef long long ll;
typedef pair< int, int > pii;
typedef pair< ll, ll > pll;
typedef pair< ll, int > pli;
typedef pair< int, ll > pil;

int ceil(int x, int y){
  return (x % y == 0) ? x / y : x / y + 1;
}

int gcd(int x, int y){
  return y ? gcd(y, x % y) : x;
}

int lcm(int x, int y){
  return x / gcd(x, y) * y;
}

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

  double t, x;
  cin >> t >> x;

  double ans = t / x;

  printf("%.4lf\n", ans);

  return 0;
}

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

using namespace std;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

typedef long long ll;
typedef pair<ll, ll> P;
const ll INF = 1LL<<60;

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

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

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

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

  string s;
  cin >> s;

  if(s[2]==s[3] && s[4]==s[5]){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }



  return 0;
}


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

int main() {
    int k, x,hidari, migi;
    cin >> k >> x;
    hidari = x - k + 1;
    migi = x + k - 1 ;
    for (int i = 0; i < migi - hidari+1; i++){
        cout << i + hidari << " ";
    }
    cout << endl;
}

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

using ll = long long int;
using P = std::pair<int, int>;

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

int main()
{
    ll res = 1;

    int n;
    std::cin >> n;

    std::vector<ll> v(n);

    rep(i, n)
    {
        ll a;
        std::cin >> a;
        v[i] = a;
        if (v[i] == 0)
        {
            std::cout << 0 << std::endl;
            return 0;
        }
    }

    rep(i, n)
    {

        if (res > (ll)1e18 / v[i])
        {
            std::cout << -1 << std::endl;
            return 0;
        }
        res *= v[i];
    }

    std::cout << res << std::endl;

    return 0;
}


Measured memory_bytes: 4052
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
void rec(int d,long long val,vector<long long>&all){
  all.push_back(val);
  if(d==10) return;
  for(int j=-1;j<=1;j++){
    int add=(val%10)+j;
    if(add>=0&&add<=9) rec(d+1,val*10+add,all);
  }
}

int main(){
    int k;
    cin>>k;
    vector<long long>all;
    for(int v=1;v<10;++v) rec(1,v,all);
  sort(all.begin(),all.end());
  cout<<all[k-1]<<endl;
}


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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    int n;
    cin >> n;
    vector<int> a(n), b(n), c(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    for (int i = 0; i < n; i++) cin >> b[i];
    for (int i = 0; i < n; i++) cin >> c[i];
    sort(a.begin(), a.end());
    sort(c.begin(), c.end());

    ll cnt = 0;
    for (int i = 0; i < n; i++) {
        ll A = lower_bound(a.begin(), a.end(), b[i]) - a.begin();
        ll B = c.end() - upper_bound(c.begin(), c.end(), b[i]);
        cnt += A * B;
    }

    cout << cnt << endl;

    return 0;
}

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

int main()
{
    int n;
    cin >> n;
    
    bool test = false;
    
    while(n != 0)
    {
        if(n % 10 == 7)
        {
            test = true;
            break;
        }
        
        n /= 10;
    }
    
    if(test)
    {
        cout << "Yes";
    }
    else
    {
        cout << "No";
    }

    return 0;
}


Measured memory_bytes: 3552