akhauriyash/Code-Regression huggingface dataset:
import copy
h, w, k = map(int, input().split())
cp_c = []
ans = 0
for i in range(h):
    cp_c.append(list(input()))
for i in range(2**h):
    ti = format(i, '06b')
    ti = ti[6-h:]
    for j in range(2**w):
        tj = format(j, '06b')
        tj = tj[6-w:]
        c = copy.deepcopy(cp_c)
        for m in range(h):
            for l in range(w):
                if ti[m] == "1" or tj[l] == "1":
                    c[m][l] = '1'
        cnt = 0
        for s in range(h):
            for t in range(w):
                if c[s][t] == '#':
                    cnt += 1
        if cnt == k:
            ans += 1
print(ans)



Measured memory_bytes: 9284
#include<iostream>
#include<vector>
#include<string>
#include<math.h>
#include<algorithm>
#include<bits/stdc++.h>
using namespace std;
int main(){
	string text, S;
	cin >> S;
	for (int i = 0; i < S.size(); i++) {
		text = "";
		cin >> S.at(i);
		if (i == 0) {
			continue;
		}
		else {
			if (S.at(i - 1) == S.at(i)) {
				text = "Bad";
				break;
			}
			else {
				text = "Good";
			}
		}
	}
	cout << text << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include<algorithm>
#include<string>
#include<stdio.h>
#include<map>
#include<math.h>
#include<queue>
using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int MOD = 1000000007;
const int mod = 1000000007;
const int INF = 1000000001;
const long long LINF = 1e18;
const int MAX = 510000;

int main() {
	string s,ans;
	bool f = 0;
	long long int cnt = 0,m,k;
	cin >> s >> k;
	m = s.size();
	for (int i = 0; i <min(m, k); i++) {
		if (s[i] != '1') {
			ans = s[i];
			f = 1;
			break;
		}
	}
	if (f == 0)cout << 1 << endl;
	else {
		cout << ans << endl;
	}
		return 0;
	}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using vl = vector<ll>;
template<class T> using vc = vector<T>;
template<class T> using vvc = vector<vector<T>>;

#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, n) for (ll i = (n)-1; i >= 0; i--)
#define repe(i, l, r) for (ll i = (l); i < (r); i++)
#define reper(i, l, r) for (ll i = (r)-1; i >= (l); i--)
#define repa(i,n) for (auto& i: n)

template<class T> inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
void init() {cin.tie(0);ios::sync_with_stdio(false);cout << fixed << setprecision(15);}

#ifdef DEBUG
template <class T, class N> void verr(const T& a, const N& n) { rep(i, n) cout << a[i] << " "; cout << "\n" << flush; }
ll dbgt = 1; void err() { cout << "passed " << dbgt++ << "\n" << flush; }
template<class H, class... T> void err(H&& h,T&&... t){ cout<< h << (sizeof...(t)?" ":"\n") << flush; if(sizeof...(t)>0) err(forward<T>(t)...); }
#endif

const ll INF = 5e18;
const ld EPS = 1e-11;
const ld PI = acos(-1.0L);
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
//--------------------------------------------------------------------------------//
// Binary Indexed Tree (Fenwick Tree)
template <typename T>
struct BIT {
    ll n;
    vector<T> d;
    BIT(ll n = 0) : n(n), d(n + 1) {}
    void add(ll i, T x = 1) {
        for (i++; i <= n; i += i & -i) {
            d[i] += x;
        }
    }
    T sum(ll i) {
        T x = 0;
        for (i++; i; i -= i & -i) {
            x += d[i];
        }
        return x;
    }
};

ll A[100000], sa[100000], C[100001];
int main() {
    init();
    ll N;
    cin >> N;
    rep(i, N) cin >> A[i];
    copy(A, A + N, sa);
    sort(sa, sa + N);
    C[0] = N;
    

    ll ok = 0, ng = N, mid;
    while(ng-ok>1){
        mid = (ok + ng) / 2;
        ll mv = sa[mid];
        rep(i, N) C[i + 1] = (A[i] >= mv ? 1 : -1);
        rep(i,N) C[i + 1] += C[i];

        BIT<ll> bt(2 * N + 1);
        ll cnt = 0;
        rep(i,N+1){
            cnt+=bt.sum(C[i]);
            bt.add(C[i]);
        }

        (cnt * 2 >= N * (N + 1) / 2 ? ok : ng) = mid;
    }

    cout << sa[ok] << endl;
}

Measured memory_bytes: 4224
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<cctype>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>
#include<complex>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define LINF (ll)INF*INF
#define MOD 1000000007
#define rep(i,n) for(int i=0;i<(n);i++)
#define loop(i,a,n) for(int i=a;i<(n);i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

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

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

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

class UnionFind{

private:
    vector<int> data;

  public:
      UnionFind(){};
      UnionFind(int size){
          data = vector<int>(size, -1);
      }

    bool same(int x, int y){
        return find(x) == find(y);
    }

    bool unite(int x, int y){
        if(same(x,y)) return(false);
        x = find(x);
        y = find(y);
        if(data[x] > data[y]) swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return(true);
    }

    int find(int x){
        if(data[x] < 0) return(x);
        return(data[x] = find(data[x]));
    }

    int size(int x){
        return(-data[find(x)]);
    }

};



signed main(void) {
    int n,m;
    cin >> n >> m;
    vi x(m),y(m),z(m);
    rep(i,m)cin >> x[i] >> y[i] >> z[i],x[i]--,y[i]--;
    UnionFind uf(n);
    rep(i,m){
        uf.unite(x[i],y[i]);
    }
    vi v(n);
    rep(i,n){
        v[i] = uf.find(i);
    }
    sort(all(v));
    v.erase(unique(all(v)),v.end());
    cout << v.size() << endl;
}


Measured memory_bytes: 4224
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define md 200005
vector<ll> p[md];
int main()
{
	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	ll n, x, mx = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)
		{
			cin >> x;
			mx = max(mx, x);
			p[x].push_back(i);
		}
	ll c = 0, tmp = -1;
	for (ll i = 1; i <= mx; ++i)
		{
			if (p[i].empty()) break;
			if (tmp == -1) {c++; tmp = p[i].front();}
			else
				{
					auto lb = lower_bound(p[i].begin(), p[i].end(), tmp + 1);
					if (lb == p[i].end()) break;
					else tmp = *lb;
					c++;
				}
		}
	if (c == 0) cout << -1 << endl;
	else
		cout << n - c << endl;
}

Measured memory_bytes: 11264
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <string>
#include <map>

#define ll long long
#define REP(i,n) for(int i = 0; i < n; i++)
#define PI 3.141592653589
#define MOD 1000000007

using namespace std;

template<typename T> T gcd(T a, T b){return (a % b)? gcd(b, a % b) : b;}
template<typename T> T lcm(T a, T b){return a * b / gcd(a, b);}

void solve_C(){
    int h, w, k;
    cin >> h >> w >> k;
    char c[h][w];
    REP(i,h) REP(j,w) cin >> c[i][j];

    int ans = 0;
    for(int bith = 0; bith < (1 << h); bith++){
        for(int bitw = 0; bitw < (1 << w); bitw++){
            int black = 0;
            for(int i = 0; i < h; i++){
                if(bith & (1 << i)) continue;
                for(int j = 0; j < w; j++){
                    if(bitw & (1 << j)) continue;
                    if(c[i][j] == '#') black++;
                }
            }
            if(black == k) ans++;
        }
    }

    cout << ans << endl;
}

int main(void){
    solve_C();
    
    return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>
#include <utility>
#include <string>
#include <stack>
#include <regex>
 
#define REP(i, n) for (int i = 0; i < n; i++)
#define ALL(v) (v).begin(), (v).end()
 
using namespace std;
 
typedef long long ll;

int main(int argc, char const *argv[])
{
  string s;
  cin >> s;
  int res = 0;
  REP(i,s.size()){
    if (s[i] == '-') res--;
    else res++;
  }
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
using namespace std;

#include <assert.h>
 
#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()
 
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<VI> VVI;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main() {
    int n;
    cin >> n;
    VL a(n), b(n);
    REP(i,n) a[i] = lin(), b[i] = lin();

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

    ll ans = 0;
    REP(i,n) ans += a[i];

    ll mi = 1e18;
    REP(i,n){
        if (a[i] > b[i]){
            mi = min(mi, b[i]);
        }
    }
    ans -= mi;
    cout << ans << endl;

    return 0;
}


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

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

using ll = long long;
using P = pair<ll,ll>;
using grid = vector<vector<int>>;

const int dx[2] = {1, 0};
const int dy[2] = {0, 1};
const int INF = 1<<30;
const ll mod = 998244353LL;

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

int main() {
    string S;
    cin>>S;
    map<char,bool> m;
    int cnt = 0;
    for(auto x:S) {
        m[x] = true;
        cnt++;
    }
    if(S == "zyxwvutsrqponmlkjihgfedcba") cout<<-1<<endl;
    else if(cnt != 26) {
        rep(i,26){
            char c = 'a' + i;
            if(!m[c]) {
                S+=c;
                break;
            }
        }
        cout<<S<<endl;
    }
    else {
        int p = 0;
        rep(i,25){
            char t = S[25-i];
            char s = S[24-i];
            if(s<t){
                p = 25-i;
                break;
            }
        }
        char ch = '{';
        for(int i = p; i < 26; i++){
            if(S[i]>S[p-1]) chmin(ch,S[i]);
        }
        S[p-1] = ch;
        rep(i,p) cout<<S[i];
        cout<<endl;
    }
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
template <class T> void chmin(T& x, T y) { if (x > y) x = y; }
int main() {
    int T; cin >> T;
    while (T--) {
        int N; cin >> N;
        vector<Int> A(N); for (auto &a : A) cin >> a;
        string S; cin >> S;
        vector<Int> base;
        int ans = 0;
        for (int i = N - 1; i >= 0; i--) {
            Int x = A[i];
            for (auto b : base) chmin(x, x ^ b);
            if (x != 0) {
                if (S[i] == '0') base.push_back(x);
                else { ans = 1; break; }
            }
        }
        cout << ans << '\n';
    }
    return 0;
}

Measured memory_bytes: 3516
package main

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

func max(a, b int) int {
	if a < b {
		return b
	}
	return a
}

func solve(ps []float64, N int) float64 {
	dp := make([]float64, N+1) // dp[i]: 表示扔i个为头的硬币的概率
	dp[0] = 1.0
	for _, p := range ps {
		for i:=N; i>=0; i-- {
			dp[i] = dp[i]*(1-p)
			if i > 0 {
				dp[i] += dp[i-1]*p
			}
		}
	}

	ans := 0.0
	for h:=1; h<=N; h++ {
		t := N-h
		if h > t {
			ans += dp[h]
		}
	}

	return ans
}

func readLineNum(bf *bufio.Reader) int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	N, _ := strconv.Atoi(line)
	return N
}

func readLineNums(bf *bufio.Reader) []int {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	nums := []int{}
	for _, field := range fields {
		num, _ := strconv.Atoi(field)
		nums = append(nums, num)
	}
	return nums
}

func readLineFloats(bf *bufio.Reader) []float64 {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	fields := strings.Split(line, " ")
	fs := []float64{}
	for _, field := range fields {
		f , _ := strconv.ParseFloat(field, 64)
		fs = append(fs, f)
	}
	return fs
}

func readLineStrs(bf *bufio.Reader) []string {
	line, _ := bf.ReadString('\n')
	line = strings.Trim(line, "\n")
	return strings.Split(line, " ")
}

func main() {
	bf := bufio.NewReader(os.Stdin)
    N := readLineNum(bf)
    ps := readLineFloats(bf)
    fmt.Println(solve(ps, N))
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i=0; i<n; i++){
    cin >> a[i];
  }
  sort(a.begin(), a.end());
  
  cout << a[n-1]-a[0] << endl;
}



 
  

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int maxb = 2000 * 2000 + 5;
bitset<maxb> f;
int n, sum;
int main()
{
	scanf("%d", &n);
	f[0] = 1;
	for(int i = 1; i <= n; ++i)
	{
		int val;
		scanf("%d", &val);
		sum += val;
		f = f | (f << val);
	}
	for(int i = (sum + 1) / 2; i <= sum; ++i)
		if(f[i])
		{
			printf("%d\n", i);
			return 0;
		}
	return 0;
}

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

using namespace std;

#define IO ios_base::sync_with_stdio(0);cin.tie(0);

int main()
{
  IO;
	int n; cin >> n;
	long long res = 0;
	for (int i = 0; i < n; ++i) {
		long long a; cin >> a;
		while (a % 2 == 0)
		{
			++res;
			a /= 2;
		}
	}
	cout << res << endl;

	return 0;
}


Measured memory_bytes: 896
N = int(input())
A = list(map(int,input().split()))
B = list(map(int,input().split()))

ans = 0
for i in range(N):
    if B[i] <= A[i]:
        ans += B[i]
        continue
    
    if B[i] > A[i]:
        r = B[i] - A[i]
        if r <= A[i+1]:
            ans += A[i] + r
            A[i+1] = A[i+1] - r
            continue
        
        if r > A[i+1]:
            ans += A[i] + A[i+1]
            A[i+1] = 0
            continue
print(ans)

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

typedef pair<pair<string, int>, int> Info;

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

  vector<Info> v;
  
  for (int i=0; i < N; i++) {
    string S;
    int P;
    cin >> S >> P;
    auto pair = make_pair(S, -P);
    Info p = make_pair(pair, i + 1);
    v.push_back(p);
  }

  sort(v.begin(), v.end());

  for (int i =0; i < v.size(); i++) {
    cout << v.at(i).second << endl;
  }  
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
    public static void main(String[]args){
	Scanner sc = new Scanner(System.in);
    int D = sc.nextInt();
    int T = sc.nextInt();
    int S = sc.nextInt();
    if(S*T>=D){
        System.out.println("Yes");
    }else{
        System.out.println("No");
    }
    }
}


Measured memory_bytes: 35684
import java.util.Scanner;

public class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        long a  = sc.nextLong();
        long b  = sc.nextLong();
        long c  = sc.nextLong();

        long k  = sc.nextLong();

        System.out.println((k % 2 == 0 ? (a - b) : (b - a)));
    }
}

Measured memory_bytes: 21844
import java.io.InputStream;
import java.io.PrintStream;
import java.util.Arrays;
import java.util.Scanner;

public class Main {
	InputStream in = System.in;
	PrintStream out = System.out;

	public void _main(String[] args) {
		Scanner sc = new Scanner(in);

		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int Y = sc.nextInt();

		int[] x = new int[N + 1];
		int[] y = new int[M + 1];

		for (int i = 0; i < N; i++) {
			x[i] = sc.nextInt();
		}
		x[N] = X;

		for (int i = 0; i < M; i++) {
			y[i] = sc.nextInt();
		}
		y[M] = Y;

		Arrays.sort(x);
		Arrays.sort(y);

		int maxX = x[N];
		int maxY = y[0];

		if (maxX < maxY) {
			out.println("No War");
		} else {
			out.println("War");
		}

		sc.close();

	}

	public static void main(String[] args) {
		new Main()._main(args);
	}

}


Measured memory_bytes: 23252
#include <cstdio>
#include <cmath>
#include <cstring>
#include <iostream>

#include <string>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>

#include <algorithm>

using namespace std;

int main(int argc, char *argv[]) {
	int n, a, b;
	cin >> n >> a >> b;
	cout << min(n * a, b) << endl;
}














Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/adaptors.hpp>
#include <boost/range/irange.hpp>

using namespace std;
using namespace boost;
using namespace boost::adaptors;

int64_t g(int64_t len, int64_t k) {
    auto tmp = 1;
    for (auto j : irange(0L, k)) {
        tmp *= 9;
    }
    for (auto j : irange(0L, k)) {
        tmp *= len - j;
    }
    for (auto j : irange(0L, k)) {
        tmp /= (j + 1);
    }
    return tmp;
}

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

    int64_t k;
    cin >> k;

    int64_t ans = 0;
    int64_t r = 0;
    for (auto i : irange(0uL, n.size())) {
        if (r > k) {
            break;
        }
        if (n[i] != '0') {
            int64_t len = n.size() - i - 1;
            if (len >= k - r) {
                ans += g(len, k - r);
            }
            if (k - r > 0 && len >= k - r - 1) {
                ans += (n[i] - '1') * g(len, k - r - 1);
            }
            ++r;
        }
    }
    if (r == k) {
        ++ans;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
import re


def main():
    S = input()
    T = input()

    S = S.replace("?", ".")[::-1]
    T = T[::-1]

    for i in range(len(S) - len(T) + 1):
        if re.match(S[i:i + len(T)], T):
            s = S[:i].replace(".", "a") + T + S[i + len(T):].replace(".", "a")
            print(s[::-1])
            break
    else:
        print("UNRESTORABLE")


if __name__ == "__main__":
    main()


Measured memory_bytes: 3188
#include <bits/stdc++.h>
#include <stdint.h>
#include <algorithm>
#include <vector>


using namespace std;

int main() {
	int n, k;
	cin >> n >> k;
	
	int ans = 0;
	int tmp;
	for (int i = 0; i < n; i++) {
		cin >> tmp;
		
		if (tmp >= k) {
			ans++;
		}
	}
	
	cout << ans;
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/foreach.hpp>
using namespace std;
#define pi 2*asin(1.0)
#define MAX 10000000
#define MOD 1000000007
#define _GLIBCXX_DEBUG
 
vector<long> fac(MAX);
vector<long> finv(MAX);
vector<long> inv(MAX);
vector<long> Primelist;
//template functions
/////////////////////////
void Prinit(){
long PR=10000001;
vector<long> P(PR,0);
for(long i=2;i*i<PR;i++){
    if(P.at(i)==0){
        long j=i;
      j+=i;
        while(j<PR){
            P.at(j)=1;
             j+=i;         
        }
    }
}

for(long i=2;i*i<PR;i++){//Primelist.size()=446
    if(P.at(i)==0){
        Primelist.push_back(i);
    }
}
}

void Cominit(){
  fac.at(0)=fac.at(1)=1;
  finv.at(0)=finv.at(1)=1;
  inv.at(1)=1;
  for(long i=2;i<MAX;i++){
      fac.at(i)=(fac.at(i-1)*i)%MOD;
      inv.at(i)=MOD-inv.at(MOD%i)*(MOD/i)%MOD;
      finv.at(i)=finv.at(i-1)*inv.at(i)%MOD;
  }
}

long facComb(long N,long M){// nCm%
if(N<M) return 0;
if(N<0||M<0) return 0;
return fac.at(N)*(finv.at(M)*finv.at(N-M)%MOD)%MOD;
}

long Comb(long N,long M){// nCm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
for(long i=M;i>0;i--){
    ans=ans/i;
}
return ans;
}

long Perm(long N,long M){// nPm
long ans=1;
for(long i=N;i>N-M;i--){
    ans=ans*i;
}
return ans;
}

long GCM(long A,long B){
            long W,r;
    if(A<B){

        W=B;
        B=A;
        A=W;
    }
    while(A%B!=0){
        r=A%B;
        A=B;
        B=r;
    }
    return B;
}
long LCM(long A,long B){
    return (A*B)/GCM(A,B);
}

long upDiv(long a,long b){
  return (a+b-1)/b;
}

long strtolong(string str){
istringstream ss;
ss=istringstream(str);
long num;
ss>>num;
return num;
}

long chartolong(char ch){
long num;
num=ch-'0';
return num;
}

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

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


string longtostr(long N){
    string str;
    str=to_string(N);
    return str;
}









/////////////////////////


//Answer


int main() {
long N;
double A;
cin>>N;
if(N%2==0){
  A=(N/2)/(double)N;
}else{
  A=((N+1)/2)/(double)N;
}


cout<< fixed << setprecision(10) << A<<endl;

}




Measured memory_bytes: 237480
D=[]
N,M=map(int,input().split())
cnt_ac=0
cnt_wa=0
if M!=0:
  for i in range(M):
    p,S=input().split()
    D.append((int(p),S))
ac=[0]*N
wa=[0]*N
for i in range(M):
  if D[i][1]=="WA" and ac[(D[i][0]-1)]==0:
    wa[(D[i][0]-1)]+=1
  elif D[i][1]=="AC" and ac[D[i][0]-1]==0:
    ac[(D[i][0]-1)]+=1
for i in range(N):
  if ac[i]==1:
    cnt_ac+=1
    cnt_wa+=wa[i]
print(cnt_ac,cnt_wa)

Measured memory_bytes: 20488
N = int(input())

if N < 10:
    print(N)
elif 10 <= N < 100:
    print(9)
elif 100 <= N < 1000:
    print(N-90)
elif 1000 <= N < 10000:
    print(909)
elif 10000 <= N <100000:
    print(N-9090)
else:
    print(90909)

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#define IO_OP std::ios::sync_with_stdio(0); std::cin.tie(0);
#define F first
#define S second
#define V vector
#define PB push_back
#define MP make_pair
#define EB emplace_back
#define ALL(v) (v).begin(), (v).end()
#define debug(x) cerr << "Line(" << __LINE__ << ") -> " << #x << " is " << x << endl

using namespace std;

typedef long long ll;
typedef pair<int, int> pi;
typedef V<int> vi;

const int M = 1e9 + 7;

int dp[2002];

signed main()
{
	IO_OP;
	
	int s;
	cin >> s;
	dp[0] = 1;
	for(int i = 1; i <= s; i++) {
		for(int j = i - 3; j >= 0; j--) {
			dp[i] = (dp[i] + dp[j]) % M;
		}
	}
	cout << dp[s] << endl;
}



Measured memory_bytes: 3648
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<algorithm>

using namespace std;

typedef long long ll;

const int N=4009;
const int md=924844033;

int n,k;
bool vis[N][N];
int ed[N],tot;
int f[N][N][2];
int g[N],fac[N];

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
		for(int j=0;j<=1;j++)
			if(!vis[i][j])
			{
				int len=0;
				for(int x=i,y=j;x<=n;x+=k,y^=1)
					vis[x][y]=1,++len;
				ed[tot+=len]=1;
			}

	f[1][0][0]=1;
	for(int i=1;i<=tot;i++)
		for(int j=0;j<=n;j++)
		{
			f[i+1][j][0]=(f[i][j][0]+f[i][j][1])%md;
			if(!ed[i])
				f[i+1][j+1][1]=f[i][j][0];
		}

	for(int i=0;i<=n;i++)
		g[i]=(f[tot][i][0]+f[tot][i][1])%md;

	fac[0]=1;
	for(int i=1;i<=n;i++)
		fac[i]=(ll)fac[i-1]*i%md;

	int	ans=fac[n];
	for(int i=1,j=-1;i<=n;i++,j=-j)
		ans=((ll)ans+md+(ll)j*fac[n-i]*g[i]%md)%md;
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 136704
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<cmath>
#include<iomanip>
#include<map>
#include<cstring>
using namespace std;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
#define vivi vector<vi>
const int INF = int(1e9);
typedef long long int ll;

int main(){
    int X, Y, A, B, C;
    cin >> X >> Y >> A >> B >> C;
    ll p[A + 1], q[B + 1], r[C + 1];
    p[A] = INF;
    q[B] = INF;
    rep(i, A)cin >> p[i];
    rep(i, B)cin >> q[i];
    rep(i, C)cin >> r[i];
    sort(p, p + A, greater<ll>());
    sort(q, q + B, greater<ll>());
    sort(r, r + C, greater<ll>());
    ll ans[X + Y + C];
    for(int i = 0;i < X;++i)
        ans[i] = p[i];
    for(int i = 0;i < Y;++i)
        ans[X + i] = q[i];
    for(int i = 0;i < C;++i){
        ans[X + Y + i] = r[i];
    }
    sort(ans, ans + X + Y + C, greater<ll>());
    ll sum = 0;
    for(int i = 0;i < X + Y;++i){
        sum += ans[i];
    }
    cout << sum << endl;
}


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

using namespace std;
typedef long long ll;
typedef long double ld;

int main()
{ 
    ll kk;
    cin >> kk;
    int sol = 0;
    ll tmp = 100;
    while(tmp < kk){
        sol ++;
        tmp += tmp/100;
    }

    cout << sol;
    return 0;
}


Measured memory_bytes: 3600
import java.util.LinkedList;
import java.util.Queue;
import java.util.Scanner;
public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		int[] vx = {-1,0,1,0};
		int[] vy = {0,1,0,-1};



		int h = stdIn.nextInt();
		int w = stdIn.nextInt();

		char[][] maze = new char[h][w];

		for(int i = 0; i < h; i++) {
			maze[i] = stdIn.next().toCharArray();
		}


		int max = 0,cnt=0;


		//s地点を設定
		for(int i = 0; i < h; i++) {
			for(int j = 0; j < w; j++) {
				if(maze[i][j]=='#') {
					continue;
				}
          
				
				int[][] board = new int[h][w];
         
				int sx = j;
				int sy = i;

				Queue<Integer> queueX = new LinkedList<>();
				Queue<Integer> queueY = new LinkedList<>();

              //System.out.println(cnt+" "+sx+" "+sy);

				queueX.add(sx);
				queueY.add(sy);

				while(!queueX.isEmpty()) {
					int x = queueX.poll();
					int y = queueY.poll();

					for(int k = 0; k < 4; k++) {
						int nextX = x + vx[k];
						int nextY = y + vy[k];
		
						if(0 <= nextX && nextX < w && 0 <= nextY && nextY < h && maze[nextY][nextX] == '.' 
								&& board[nextY][nextX] == 0&&!(nextY==sy&&nextX==sx)) {
                          //System.out.println(board[y][x]);
                          //System.out.println(cnt+" "+nextX+" "+nextY);
                          //if(nextY==sy&&nextX==sx)continue;
							board[nextY][nextX] = board[y][x] + 1;
							queueX.add(nextX);
							queueY.add(nextY);
                       
						}
					}

				}
				for(int l = 0; l < h; l++) {
					for(int m = 0; m < w; m++) {
						max = Math.max(max, board[l][m]);
					}
				}
				//System.out.println(max);
              cnt++;
			}
		}

		System.out.println(max);


	}

}

Measured memory_bytes: 32264
#include<bits/stdc++.h>
#define fi first
#define se second
#define mk(x,y) make_pair(x,y)
#define pii pair<int,int> 
using namespace std;
const int maxn=305;
const int mod=1e9+7;
int n,m;
int dp[maxn][maxn][maxn];
int ans;
vector<pii> vec[maxn];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int l,r,x;
		cin>>l>>r>>x;
		vec[r].push_back(make_pair(l,x));
	}
	dp[1][0][0]=3;
	for(int i=0;i<=n;i++){
		for(int j=0;j<=n;j++){
			for(int k=0;k<=n;k++){
				for(int l=0;l<vec[i].size();l++){
					if(1+(j>=vec[i][l].fi)+(k>=vec[i][l].fi)!=vec[i][l].se){
						dp[i][j][k]=0;
					}
				}
				if(i==n) ans=(ans+dp[i][j][k])%mod;
				else{
					dp[i+1][j][k]=(dp[i+1][j][k]+dp[i][j][k])%mod;
					dp[i+1][i][k]=(dp[i+1][i][k]+dp[i][j][k])%mod;
					dp[i+1][i][j]=(dp[i+1][i][j]+dp[i][j][k])%mod;
				}
			}
		}
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 110464
#include <iostream>
#include <set>
#include <cassert>

/*	verified : 2020/08/30
		AtCoder, Absolute Minima
		https://atcoder.jp/contests/abc127/tasks/abc127_f
*/

struct medianset {
	std::multiset<long long> left;
	std::multiset<long long> right;
	long long left_sum;
	long long right_sum;

	medianset() {left_sum = right_sum = 0;}

	void balance() {
		if (left.size() == right.size() + 2) {
			right.insert(*left.rbegin());
			left.erase(--left.end());
			right_sum += *right.begin();
			left_sum -= *right.begin();
		}
		if (left.size() + 1 == right.size()) {
			left.insert(*right.begin());
			right.erase(right.begin());
			left_sum += *left.rbegin();
			right_sum -= *left.rbegin();;
		}
	}

	void insert(long long x) {
		if (left.empty()) {
			left.insert(x);
			left_sum += x;
			return;
		}
		if (x <= *left.rbegin()) {
			left.insert(x);
			left_sum += x;
		} else {
			right.insert(x);
			right_sum += x;
		}
		balance();
	}

	// return false : erasure failed
	bool erase(long long x) {
		auto itr1 = left.end();
		auto itr2 = right.end();
		if (x <= *left.rbegin()) itr1 = left.find(x);
		if (*right.begin() <= x) itr2 = right.find(x);
		if (itr2 != right.end()) {
			right.erase(itr2);
			right_sum -= x;
		} else if (itr1 != left.end()) {
			left.erase(itr1);
			left_sum -= x;
		}
		else return false;
		balance();
		return true;
	}

	std::pair<long long, long long> get_median() {
		assert(left.size());
		if (left.size() == right.size()) return {*left.rbegin(), *right.begin()};
		else return {*left.rbegin(), *left.rbegin()};
	}
};

int main() {
	long long q;
	std::cin >> q;
	medianset st;
	long long sum = 0;
	while (q--) {
		long long x;
		std::cin >> x;
		if (x == 1) {
			long long a, b;
			std::cin >> a >> b;
			st.insert(a);
			sum += b;
		} else {
			x = st.get_median().first;
			std::cout << x << ' ';
			std::cout << x * (long long)st.left.size() - st.left_sum + st.right_sum - x * (long long)st.right.size() + sum << '\n';
		}
	}
}

Measured memory_bytes: 12896
#include <bits/stdc++.h>
#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##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; using ll = long long; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int S, W;
    cin >> S >> W;
    write(S <= W ? "unsafe" : "safe");
}

Measured memory_bytes: 3644
#include <bits/stdc++.h>
#include <math.h>
#include <algorithm>
#include <cstdlib>
#include <string>
#define ll long long
#define ld long double
#define pii pair<int, int>
#define pll pair<ll, ll>
#define f first
#define s second
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back
#define eb emplace_back
#define in insert
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
#define FOR(i, n, x) for(int i = x; i < n; i++)
#define OUT(a, e) FOR(i, e, 0) cout << a[i] << ' '
#define OUTV(a) for(auto i : a) cout << i << ' ';
#define maxim(a, n, mx) FOR(i, n, x)mx = max(mx, a[i]);

using namespace std;
const int N = 1e5;
int used[N];
vector<ll> d;



int main()
{
    ll a, b; cin >> a >> b;
    ll n = __gcd(a, b);
    for(ll i = 1; i * i <= n; i++)
    {
        if(n % i == 0)
        {
            d.pb(i);
            if(n / i != i)d.pb(n / i);
        }
    }
    sort(all(d));
    int ans = 0, cnt = 1, sz = d.size();
    FOR(i, sz, 0)
    {
        if(d[i] == 1)continue;
        if(used[i])continue;
        FOR(j, sz, 0)
        {
            if(d[j] % d[i] == 0)used[j] = 1;
        }
        cnt++;
    }
    cout << cnt;
	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<string>
using namespace std;

int main()
{
  int n,m;
  cin>>n>>m;
  vector<pair<long int,int> > a(n);
  for(int i=0;i<n;i++)
  {
    cin>>a.at(i).first>>a.at(i).second;
  }

  sort(a.begin(),a.end());

  long long int ans=0;
  for(int i=0;i<n;i++)
  {
    if(m>a.at(i).second)
    {
      ans+=a.at(i).second*a.at(i).first;
      m-=a.at(i).second;
    }
    else
    {
      ans+=m*a.at(i).first;
      break;
    }
  }

  cout<<ans<<endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int a[10] = {0}, x, c;
  for (int i = 0; i < 3; i++) cin >> x, c += a[x], a[x] = 1;
  cout << (c == 1 ? "Yes" : "No");
}


Measured memory_bytes: 256
import itertools

n,c=map(int,input().split())
dp=[[0]*100002 for i in range(c)]

for i in range(n):
    s,t,x=map(int,input().split())
    dp[x-1][s-1]+=1
    dp[x-1][t]-=1

for i in range(c):
    dp[i]=list(itertools.accumulate(dp[i]))


ans=0

for i in range(100001):
    cnt=0
    for j in range(c):
        if dp[j][i]!=0:
            cnt+=1
    
    ans=max(ans,cnt)


print(ans)

Measured memory_bytes: 159860
#include <iostream>
#include <cstdio>
using namespace std;
const int MAX_N = 1000005;
bool is_prime[MAX_N];
int n;
int main(int argc, const char * argv[])
{
    while (~scanf("%d", &n)) {
        for (int i = 2; i <= n; i++) is_prime[i] = true;
        //エラストテネスのふるい
        int count = 0;
        for (int i = 2; i <= n; i++) {  //2からnまで確認
            if (is_prime[i]) {  //素数iを発見
                count++;
                for (int j = 2*i; j <= n; j += i) {  //iの倍数を消す
                    is_prime[j] = false;
                }
            }
        }
        printf("%d\n",count);
    }
    
    return 0;
}

Measured memory_bytes: 2164
#include <bits/stdc++.h>
using namespace std;
//debug
#ifdef grief
#define debug(...) do{\
	fprintf(stderr , "%s - %d : (%s) = " , __PRETTY_FUNCTION__ , __LINE__ , #__VA_ARGS__ );\
	_DO(__VA_ARGS__);\
}while(0)
template<typename I> void _DO(I&&x){
	cerr<<x<<endl;
}
template<typename I,typename...T> void _DO(I&&x,T&&...tail){
	cerr<<x<<" , ";
	_DO(tail...);
}
#else
#define debug(...)
#endif
//type
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef priority_queue<pll,vector<pll>,greater<pll> > heap;
//macro
#define SZ(x) ((ll)(x).size())
#define ALL(x) (x).begin(),(x).end()
#define F first
#define S second
#define mkp make_pair
#define pb push_back
#define IOS do{ios_base::sync_with_stdio(0); cin.tie(0);}while(0)
const ll INF=4e18;
const ll MAX=1e5+5;
const ll MOD=1e9+7;
//}}}
int main(){
	//IOS;
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	a=max(a,c);
	b=min(b,d);
	cout<<max(0,b-a);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0;i<(int)(n);i++)
#define all(x)    (x).begin(),(x).end()
typedef long long ll;
const int MOD = (int)1e9 + 7;

string makeban(int left,string ban){
  if(left == 0) return ban;
  return makeban(left-1,"b" + ban + "p" + ban + "b");
}

ll solve(vector<ll> p, vector<ll> mid, vector<ll> len, int lv,ll x){
  if(lv == 1){
    string hoge = "bpppb";
    ll buf = 0;
    rep(i,x+1) if(hoge[i] == 'p') buf++;
    return buf;
  }
  if(x == 0)
    return 0;
  if(x == len[lv]-1)
    return p[lv];
  if(x == mid[lv])
    return p[lv-1] + 1;
  if(x < mid[lv])
    return solve(p,mid,len,lv-1,x-1);
  if(x > mid[lv])
    return solve(p,mid,len,lv-1,x-mid[lv]-1) + p[lv-1] + 1;
}

int main(){
  ll n,x;
  cin >> n >> x;
  /*
  if(n <= 0){
    int ans = 0;
    string ban = makeban(n,"p");
    rep(i,x) if(ban[i] == 'p') ans++;
    cout << ans << endl;
    return 0;
  }
  */
  vector<ll> p_max(n+1),mid(n+1),len(n+1);
  p_max[0] = 1;
  mid[0] = 0;
  len[0] = 1;
  rep(i,n){
    p_max[i+1] = 1 + p_max[i]*2;
    len[i+1] = 3 + len[i] * 2;
    mid[i+1] = 1 + len[i];
  }
  cout << solve(p_max,mid,len,n,x-1) << endl;
}



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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define MOD 1000000007
#define cey ce("Yes")
#define cen ce("No")
#define ceY ce("YES")
#define ceN ce("NO")

int main()
{
	int X;
	cin >> X;
	if (X >= 30)cey
	else cen
    return 0;
}



Measured memory_bytes: 3564
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<n;i++)
#define inf 1e9+7
using namespace std;
typedef long long ll;
const double pi=acos(-1);

int main(){
    int n;
    cin >> n;
    vector<bool> d(n);
    for(int i=0;i<n;i++){
        int a,b;
        cin >> a >> b;
        if(a==b) d[i]=true;
        else d[i]=false;
    }
    int num=0,ans=0;
    for(int i=0;i<n;i++){
        if(d[i]) num++;
        else num=0;
        ans=max(ans,num);
    }
    if(ans>=3) cout << "Yes" << endl;
    else cout << "No" << endl;
}

Measured memory_bytes: 3628
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main(){
    int n;
    cin >> n;
    int arr[n];
    for(int i = 0; i < n; i++){
        cin >> arr[i];
    }
    int mod = 1000000007;
    ll sum = 0;
    for(int i = 0 ; i < n; i++){
        sum += arr[i];
        sum = sum%mod;
    }
    
    long ans = 0;
    for(int i = 0; i < n; i++){
        sum -= arr[i];
        if(sum < 0){
            sum += mod;
        }
        ans += arr[i]*sum;
        ans %= mod;
    }
    
    cout << ans << endl;
    
}


Measured memory_bytes: 4420
n=gets.to_i
a=gets.split.map(&:to_i)
b=[a[0]]
1.upto(n-1){|i| b[i]=a[i]+b[i-1]}
mid=b[-1]/2
t1=b.bsearch_index{|x| x>mid}
# t2=b[-1]-b[t1]
m2=2020202020*200000
m1=(b[-1]-2*b[t1]).abs
m2=(b[-1]-2*b[t1-1]).abs if t1-1>=0
puts (m1>m2)? m2:m1

Measured memory_bytes: 17876
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#include<ext/pb_ds/priority_queue.hpp>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
using namespace __gnu_pbds;
typedef long long ll;
typedef pair<int,int> P;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
typedef __gnu_pbds::priority_queue<int,greater<int>,pairing_heap_tag> pq;
int n,a[MAXN];
int main()
{
    int ans=0;
    scanf("%d",&n);
    for(int i=1;i<=n;i++) scanf("%d",&a[i]);
    a[n+1]=0;
    for(int i=1;i<=n+1;i++) ans+=abs(a[i]-a[i-1]);
    for(int i=1;i<=n;i++) printf("%d\n",ans-abs(a[i]-a[i-1])-abs(a[i]-a[i+1])+abs(a[i-1]-a[i+1]));
    return 0;
}



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

int main()
{
	int W, H, N;
	cin >> W >> H >> N;

	int rect[100][100] = {};
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			rect[i][j] = 1;
		}
	}

	
	for (int k = 0; k < N; k++) {
		int x, y, a;
		cin >> x >> y >> a;
		
		if (a == 1) {
			for (int i = 0; i < x; i++) {
				for (int j = 0; j < H; j++) {
					rect[i][j] = 0;
				}
			}
		}

		if (a == 2) {
			for (int i = x; i < W; i++) {
				for (int j = 0; j < H; j++) {
					rect[i][j] = 0;
				}
			}
		}

		if (a == 3) {
			for (int i = 0; i < W; i++) {
				for (int j = 0; j < y; j++) {
					rect[i][j] = 0;
				}
			}
		}

		if (a == 4) {
			for (int i = 0; i < W; i++) {
				for (int j = y; j < H; j++) {
					rect[i][j] = 0;
				}
			}
		}

	}

	int sum = 0;
	for (int i = 0; i < W; i++) {
		for (int j = 0; j < H; j++) {
			sum += rect[i][j];
		}
	}

	cout << sum << endl;
	return 0;

}



Measured memory_bytes: 256
package main

import (
	"fmt"
)

func main() {
	var s string
	fmt.Scan(&s)

	if len(s) == 2 {
		fmt.Println(s)
	} else {
		fmt.Println(reverse(s))
	}
}

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define int long long
typedef pair<int,int> P;
int INF = 1e9+7;
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
signed main() {
    int N;
    cin >> N;
    // 1 2 3 4 5 6 7 8 9 10 11 12 13 <<
    cout << (1+N-1)*(N-1)/2 << endl;
}


Measured memory_bytes: 3636
#include <iostream>
#include <stdio.h>
#include <bits/stdc++.h>
#include <queue>
#include <math.h>
#include <bitset>
#define INF 100000000000
#define N 200000
#define ll long long
using namespace std;

int main(){
    ll n,m;
    cin>>n>>m;
    priority_queue<ll> num;
    vector<ll> data[N];
    
    for (ll i=0; i<n; i++){
        ll p,q;
        cin>>p>>q;
        data[p].push_back(q);
    }
    
    ll ans=0;
    
    for (ll day=1; day<=m; day++){
        for (ll x:data[day]) num.push(x);
        if (!num.empty()){
            ans+=num.top();
            num.pop();
        }
        else continue;
    }
    
    cout<<ans<<endl;
}

Measured memory_bytes: 8064
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#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__)
#define all(x) (x).begin(), (x).end()
#define INF 100000000000
ll a, b, c, n, m, x, y, z, w, h, ans = 0, cnt = 0, mx = 0, mn = INF;
string s, t;

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

    while(cin >> n >> m){
        ll list[n + 1];
        rep(i, 1, n + 1){
            cin >> list[i];
        }
        ll dp[n + 1];
        dp[1] = 0;
        dp[2] = abs(list[1] - list[2]);
        rep(i, 3, n + 1){
            dp[i] = INF;
            rep(j, 1, min((ll)i, m + 1)){
                dp[i] = min(dp[i], dp[i - j] + abs(list[i - j] - list[i]));
            }
        }
        cout << dp[n] << endl;
    }
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a , b , c ,test;

    cin>>test;

    for(int i{0};i<test;i++){
        cin>>a>>b>>c;

        if((a * a == b * b + c * c)||(b * b == a * a + c * c)||(c * c == b * b + a * a)){
            cout<<"YES"<<endl;
        }
        else{
            cout<<"NO"<<endl;
        }

    }

    return 0;
}



Measured memory_bytes: 3072
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
void push(int);
int pop(void);
 
int S[100];
int top;
 
int main()
{
  int a,b,n;
  char c[100];
  top=0;
  while(scanf("%s",c)!=EOF)
    {
      if(c[0]=='+')
    {
      a=pop();
      b=pop();
      push(a+b);
    }
      else if(c[0] == '-')
    {
      b=pop();
      a=pop();
      push(a-b);
    }
      else if(c[0] == '*')
    {
      a=pop();
      b=pop();
      push(a*b);
    }
      else
    {
      n=atoi(c);
      push(n);
    }
    }
  printf("%d\n",pop());
  return 0;
}
 
void push(int x)
{
  S[++top]=x;
 
}
 
int pop(void )
{
  top--;
  return S[top+1];
}

Measured memory_bytes: 548
#include <iostream>
#include <vector>
#define eol '\n'
using namespace std;

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

  int n,k;
  cin >> n >> k;

  vector<int> d(k);
  for (int i = 0; i < k; i++) {
    cin >> d[i];
  }

  int N,v;
  while (true) {
    N = n;

    bool ok = true;
    for (int j = 0; j < 5; j++) {
      v = N % 10;
      N = N / 10;

      bool include = false;
      for (int i = 0; i < k; i++) {
        if (v == d[i]) {
          include = true;
          break;
        }
      }
      if (include) {
        ok = false;
        break;
      }
      if (N == 0) break;
    }

    if (ok) {
      cout << n << eol;
      break;
    }
    n++;
  }
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#ifdef LOCAL
#include "debug.h"
#else
#define dump(...)
#endif
#define endl '\n'
#define ll long long
#define FOR(i, a, b) for (int i = (int)(a); i < (int)(b); i++)
#define REP(i, x) for (int i = 0; i < (int)(x); i++)
#define REPS(i, x) for (int i = 1; i <= (int)(x); i++)
#define RREP(i, x) for (int i = ((int)(x)-1); i >= 0; i--)
#define RREPS(i, x) for (int i = ((int)(x)); i > 0; i--)
#define INF 2147483647
#define LLINF 9223372036854775807LL
#define vi vector<int>
#define vvi vector<vector<int>>
#define pi pair<int, int>
#define ALL(a) (a).begin(), (a).end()
#define BIT(n) (1LL << (n))
#define TOUPPER(s) transform(s.begin(), s.end(), s.begin(), ::toupper)
#define TOLOWER(s) transform(s.begin(), s.end(), s.begin(), ::tolower)
#define FILLZERO(s, n)                      \
    do {                                    \
        ostringstream os;                   \
        os << setw(n) << setfill('0') << s; \
        s = os.str();                       \
    } while (0);
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end()) //sortしてからつかうこと
#define INIT                               \
    std::cin.tie(nullptr);                 \
    std::ios_base::sync_with_stdio(false); \
    cout << std::fixed << std::setprecision(10);

template <typename T>
vector<T> make_vec(size_t a, T n) { return vector<T>(a, n); }
template <typename T, typename... Ts>
auto make_vec(size_t a, Ts... ts) { return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...)); }
template <class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return 1;
    }
    return 0;
}
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec)
        is >> x;
    return is;
}

constexpr ll MOD = 1e9 + 7;
int dx[8] = {1, 0, -1, 0, 1, 1, -1, -1};
int dy[8] = {0, 1, 0, -1, 1, -1, 1, -1};
ll A, B, C, D, E, F, G, H, N, M, L, K, P, Q, R, W, X, Y, Z;
string S, T;
ll ans = 0;

template <typename T>
T intceil(T a, T b) {
    return (a + (b - 1)) / b;
}

signed main() {
    INIT;
    cin >> A >> B >> H;
    cout << (A + B) * H / 2 << endl;
}

Measured memory_bytes: 3580
N, K = map(int, input().split())
X = [int(x) for x in input().split()]

ans = float('inf')
for left in range(N - K + 1):
    lv, rv = X[left], X[left+K-1]
    ans = min(ans, rv - lv + min(abs(rv), abs(lv)))
print(ans)

Measured memory_bytes: 14252
#include <bits/stdc++.h>
 
using namespace std;
 
using ll = long long;
using ld = long double;
using vi = vector<ll>;
using vvi = vector<vi>;
using pll = pair<ll, ll>;
 
#define all(a) a.begin(), a.end()
#define pb push_back
#define mp make_pair

void solve() {
    ll s; cin >> s;
    vi dp(s + 1);
    dp[0] = 1;
    ll MOD = 1e9 + 7;
    for (int i = 1; i <= s; i++) {
        for (int j = 3; j <= i; j++) {
            if (i >= j)
                dp[i] += dp[i - j];
            dp[i] %= MOD;
        }
    }
    cout << dp[s];
}
 
int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    
    solve();
}

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


using namespace std;

const int MAXN = (int) 1e5;

pair <int, int> v[MAXN + 1];

int main() {
    //fstream cin("A.in");
    //ofstream cout("A.out");
    int i, n;
    ios::sync_with_stdio(false);
    cin >> n;
    for(i = 1; i <= n; i++)
        cin >> v[i].first >> v[i].second;
    sort(v + 1, v + n + 1);
    cout << v[n].first + v[n].second;
    //cin.close();
    //cout.close();
    return 0;
}


Measured memory_bytes: 1024
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
#include <string>



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


map<string, int> mp;
#define ll long long



int main() {
    int n;
    cin >> n;
    ll x = 1;
    for (int i = 1; i <= n;i++) {
        x = x * i % 1000000007;
    }
    cout << x << endl;
}

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

int main(){
  	int i,n,k,a,j,l,c=0,bad=0,count=0;
  	vector<int> d(100);
  	vector<int> num(10000);
 	cin >> n >> k;
  	for(i=0;i<k;i++){
    	cin >> d[i];
      	for(j=0;j<d[i];j++){
         	cin >> a;
          	for(l=0;l<num.size();l++){
            	if(a==num[l]){
                	bad++;
                  	break;
                }
            }
          	if(bad==0) count++;
          	num[c] = a;
          	c++;
          	bad = 0;
        }
    }
  	cout << n - count << endl;
}



Measured memory_bytes: 3676