akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repl(i,l,r) for(ll i=(l);i<(r);i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define perl(i,r,l) for(ll i=r-1;i>=l;i--)
#define fi first
#define se second
#define pb push_back
#define ins insert
#define pqueue(x) priority_queue<x,vector<x>,greater<x>>
#define all(x) (x).begin(),(x).end()
#define CST(x) cout<<fixed<<setprecision(x)
#define vtpl(x,y,z) vector<tuple<x,y,z>>
#define rev(x) reverse(x);
using ll=long long;
using vl=vector<ll>;
using vvl=vector<vector<ll>>;
using pl=pair<ll,ll>;
using vpl=vector<pl>;
using vvpl=vector<vpl>;
const ll MOD=1000000007;
const ll MOD9=998244353;
const int inf=1e9+10;
const ll INF=4e18;
const ll dy[8]={1,0,-1,0,1,1,-1,-1};
const ll dx[8]={0,-1,0,1,1,-1,1,-1};
ll powmod(ll n, ll k, ll m) {
ll r=1;
 for(; k>0; k >>=1) {
   if(k&1) r=(r*n)%m;
   n=(n*n)%m;
 }
  return r;
}

ll fact(ll n) {
ll a=1;
rep(i,n) {
a=a*(n-i);
}
return a;
}

ll pow(ll a, ll b) {
ll x=1;
rep(i,b) {
x=x*a;
}
return x;
}

int main() {
  ll N;
  cin >>N;
  vvpl ps(N);
  rep(i,N) {
ll a;
    cin >>a;
    rep(j,a) {
      ll b;
      ll c;
      cin >>b>>c;
      pair<ll,ll> p=make_pair(b-1,c);
      ps.at(i).push_back(p);
    }
  }
  
  
  //endin
  ll psn=0;
  for(int bit=0; bit<(1<<N); ++bit) {
    bitset<20> s(bit);
    bool fumo=true;
    ll a=__builtin_popcount(bit);
        rep(i,N) {
  if(bit&(1<<i)) {
    
    ll aa=ps.at(i).size();
    rep(k,aa) {
      if((ps.at(i).at(k).se==1) &&(!s.test(ps.at(i).at(k).fi))) {
        fumo=false;
        break;
      }
         else if((ps.at(i).at(k).se==0) &&(s.test(ps.at(i).at(k).fi))) {
        fumo=false;
        break;
      }
    
                 }
    
    
    
  }//endif
        }//endrep
    if(fumo) {
      psn=max(psn,a);
    }
  }//endfor
  
  
  cout<<psn<<endl;
}
    

   
  
  
  

Measured memory_bytes: 3632
/*input
3 2
2
1 3
1
3
*/

#include <bits/stdc++.h>

using namespace std;

const int Nmax = 2e6 + 10;

int res;
int n, k;
int c[Nmax];

int main() {
	cin >> n >> k;
	for (int i = 1; i <= k; ++i) {
		int cow;
		cin >> cow;
		while (cow-- > 0) {
			int snuke;
			cin >> snuke;
			c[snuke]++;
		}
	}
	for (int i = 1; i <= n; ++i) {
		if (c[i] == 0) res++;
	}
	cout << res << endl;

}

Measured memory_bytes: 3640
<?php
$abc = explode(" ", trim(fgets(STDIN)));
rsort($abc);
if($abc[0] * 10 + $abc[1] + $abc[2] > $abc[0] + $abc[1] * 10 + $abc[2]){
	printf("%d", $abc[0] * 10 + $abc[1] + $abc[2]);
}else{
	printf("%d", $abc[0] + $abc[1] * 10 + $abc[2]);
}
?>

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//#include <boost/multiprecision/cpp_int.hpp>
//typedef boost::multiprecision::cpp_int ll;
typedef long double dd;
//#define i_7 (ll)(1E9+7)
#define i_7 998244353
#define i_5 i_7-2
ll mod(ll a){
    ll c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
typedef pair<ll,ll> l_l;
ll inf=(ll)1E17;
#define rep(i,l,r) for(ll i=l;i<=r;i++)
#define pb push_back
ll max(ll a,ll b){if(a<b)return b;else return a;}
ll min(ll a,ll b){if(a>b)return b;else return a;}
void Max(ll &pos,ll val){pos=max(pos,val);}//Max(dp[n],dp[n-1]);
void Min(ll &pos,ll val){pos=min(pos,val);}
void Add(ll &pos,ll val){pos=mod(pos+val);}
dd EPS=1E-9;
#define fastio ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
///////////////////////////////////////

int main(){fastio
    ll n;cin>>n;
    ll a[n+1];rep(i,0,n)cin>>a[i];
    ll b[n];rep(i,0,n-1)cin>>b[i];
    ll ans=0;
    rep(i,0,n-1){
        if(b[i]<=a[i]){
            ans+=b[i];
            a[i]-=b[i];
        }else{
            ans+=a[i];
            b[i]-=a[i];
            a[i]=0;
            ll x=min(b[i],a[i+1]);
            ans+=x;
            a[i+1]-=x;
            
        }
    }
    cout<<ans<<endl;
    return 0;
}



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

namespace Dynamic_Programming
{
    class Matrix_Chain_Multiplication
    {
        static void Main(string[] args)
        {
            var n = int.Parse(Console.ReadLine());
            Console.WriteLine(Solve(n));
        }

        static int Solve(int n)
        {
            var dim = new int[n + 1];
            for (int i = 0; i < n; i++)
            {
                var rc = Console.ReadLine().Split(' ').Select(s => int.Parse(s)).ToArray();
                dim[i] = rc[0];
                if (i == n - 1) dim[i + 1] = rc[1];
            }

            var cost = new int[n, n];
            for (int i = 0; i < n; i++)
                cost[i, i] = 0;

            for (int l = 1; l < n; l++)
            {
                for (int i = 0; i < n - l; i++)
                {
                    cost[i, i + l] = int.MaxValue;
                    for (int k = i; k < i + l; k++)
                    {
                        var tmp = cost[i, k] + cost[k + 1, i + l] + dim[i] * dim[k + 1] * dim[i + l + 1];
                        if (tmp < cost[i, i + l]) cost[i, i + l] = tmp;
                    }
                }
            }

            return cost[0, n - 1];
        }

        static int Argmin(List<int> list)
        {
            var min = list[1];
            var index = 1;
            for (int i = 0; i < list.Count; i++)
            {
                if (min > list[i]) { min = list[i]; index = i; }
            }
            return index;
        }
    }
}

Measured memory_bytes: 9576
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <iomanip>
#include <cmath>
#include <map>
using namespace std;
#define REP(i,n) for (int i=0;i<(n);++i)
using ll = long long;
constexpr ll INF = 1LL << 60;
constexpr int MOD = 998244353;
constexpr double PI = 3.141592653589793238;

ll N, K, A[200020], F[200020], C[200020];

bool Q(ll x) {
  ll ret = 0;
  REP(i, N) {
    if(C[i] > x) {
      ll diff = (C[i] - x + F[i] - 1) / F[i];
      ret += diff;
    }
  }
  return ret <= K;
}

int main() {
  cin >> N >> K;
  REP(i, N) cin >> A[i];
  REP(i, N) cin >> F[i];
  sort(A, A + N, greater<ll>());
  sort(F, F + N);
  REP(i, N) C[i] = A[i] * F[i];
  
  ll sum = 0;
  REP(i, N) sum += A[i];
  if(sum <= K) {
    cout << 0 << endl;
    return 0;
  }

  ll l = 0, r = INF;
  while(r - l > 1) {
    ll mid = (l + r) / 2;
    if(Q(mid)) r = mid;
    else l = mid;
  }
  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4992
#include<stdio.h>
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<math.h>
#include<cstring>
using namespace std;
const int inf=1<<30;
int main(){
  int n,x,m[110];cin>>n>>x;
  int minw=inf,sumw=0;
  for(int i=0;i<n;i++){
    cin>>m[i];
    minw=min(minw,m[i]);
    sumw+=m[i];
  }
  cout<<(int)(x-sumw)/minw+n<<endl;
  return 0;
}


Measured memory_bytes: 256
int main(void){
 int N, M, comb_1, comb_2, ans;
 scanf("%d %d", &N, &M);
 comb_1 = (N * (N - 1)) / 2;
 comb_2 = (M * (M - 1)) / 2;
 ans = comb_1 + comb_2;
 printf("%d", ans);
 return 0;
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
using std::cerr;
using std::cin;
using std::cout;
using std::endl;

int main(void) {
  cout << std::fixed << std::setprecision(10);
  cin.tie(0);
  std::ios::sync_with_stdio(false);
  int n, m;
  cin >> n >> m;
  std::vector<int> bulb[10];
  std::vector<int> mod;
  for (int i = 0; i < m; i++) {
    int k;
    cin >> k;
    for (int j = 0; j < k; j++) {
      int s;
      cin >> s;
      bulb[i].push_back(s);
    }
  }
  for (int i = 0; i < m; i++) {
    int p;
    cin >> p;
    mod.push_back(p);
  }
  int result = 0;
  for (int state = 0; state < (1 << n); state++) {
    bool all_on = true;
    for (int i = 0; i < m; i++) {
      std::vector<int> tgt_bulb = bulb[i];
      int on_count              = 0;
      for (auto x : tgt_bulb) {
        int mask = 1 << (x - 1);
        if (mask & state) {
          on_count++;
        }
      }
      if (on_count % 2 != mod[i]) {
        all_on = false;
        break;
      }
    }
    if (all_on) {
      result++;
    }
  }
  cout << result << endl;

  return 0;
}


Measured memory_bytes: 888
#include<bits/stdc++.h>
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define mod 1000000007
#define MAX 1000000000000000
#define all(v) v.begin(),v.end()
#define rep(i,a,b) for(i=(ll)a;i<(ll)b;i++)
#define revrep(i,a,b) for(i=(ll)a;i>=(ll)b;i--)
#define ii pair<ll,pair<ll,ll> >
#define MP make_pair
#define pb push_back
#define f first
#define se second
#define ll long long int
#define vi vector<ii>
ll modexp(ll a,ll b){ ll res = 1; while(b > 0){  if(b & 1) res = (res * a) % mod;  a = (a * a) % mod;  b /= 2;  }  return res; }
#define rs resize
typedef tree< ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update > OST;
#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
    template <typename Arg1>
    void __f(const char* name, Arg1&& arg1){
        cout << name << " : " << arg1 << endl;
    }
    template <typename Arg1, typename... Args>
    void __f(const char* names, Arg1&& arg1, Args&&... args){
        const char* comma = strchr(names + 1, ','); cout.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
    }
#else
#define trace(...)
#endif

const ll N = 100009;
ll i,j,c,n,m;
ii a[N];
string s,ans[N];
stringstream ss;
string go(ll n)
{
    ss << n;
    ss >> s;
    ss.clear();
    while(s.length() < 6) s = "0" + s;
    return s;
}
int main()
{
    std::ios_base::sync_with_stdio(false); cin.tie(NULL);
    cin>>n>>m;
    rep(i,0,m){
        cin>>a[i].f>>a[i].se.f;
        a[i].se.se = i;
    }
    sort(a,a + m);
    rep(i,0,m){
        c = 1;
        j = i;
        while(j < m && a[j].f == a[i].f){
            ans[a[j].se.se] = go(a[j].f) + go(c);
            j += 1;
            c += 1;
        }
        i = j - 1;
    }
    rep(i,0,m) cout<<ans[i]<<endl;
    return 0;
}

Measured memory_bytes: 10368
fun main() {
    val s = next()
    if (s[0] != 'A' || s[1] !in ('a'..'z') || s.last() !in ('a'..'z')) {
        println("WA")
        return
    }
    var cCount = 0
    var otherCount = 0
    (1 until s.lastIndex).forEach {
        if (s[it] == 'C') {
            cCount++
        } else if (s[it] in 'A'..'C') {
            otherCount++
        }
    }
    println(
        if (cCount == 0 || cCount > 1 || otherCount > 0) {
            "WA"
        } else {
            "AC"
        }
    )
}

// # Utils
// ## Input
fun next() = readLine()!!
fun nextInt() = next().toInt()
fun nextLong() = next().toLong()
fun nextDouble() = next().toDouble()
fun nextList() = next().split(" ")
fun nextIntList() = next().split(" ").map(String::toInt)
fun nextLongList() = next().split(" ").map(String::toLong)
fun nextDoubleList() = next().split(" ").map(String::toDouble)

// ## Array
inline fun <reified T> sizedArray(size: Int, default: T) = Array(size) { default }
inline fun <reified T> sized2DArray(row: Int, column: Int, default: T) = Array(row) { Array(column) { default } }

// ## mod^-1
//    [NOTE] CANNOT use this for 0, mod, 2mod, 3mod ...(return wrong value)
fun modinv(num: Long, mod: Long): Long {
    var a = num
    var b = mod
    var u = 1L
    var v = 0L
    while (b > 0) {
        val t = a.div(b)
        a -= t * b
        a = b.also { b = a } // swap a and b
        u -= t * v
        u = v.also { v = u } // swap u and v
    }
    u %= mod
    if (u < 0) u += mod
    return u
}

fun gcd(x: Int, y: Int): Int {
    fun innerGcd(x: Int, y: Int): Int {
        return if (x % y == 0) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

fun gcd(x: Long, y: Long): Long {
    fun innerGcd(x: Long, y: Long): Long {
        return if (x % y == 0L) y else innerGcd(y, x % y)
    }
    return if (x >= y) innerGcd(x, y) else innerGcd(y, x)
}

// classes
class UnionFindTree(val size: Int) {
    private val r = sizedArray(size, -1)
    fun root(x: Int): Int {
        if (r[x] < 0) return x
        return root(r[x])
    }

    fun unite(x: Int, y: Int) {
        var rx = root(x)
        var ry = root(y)
        if (rx == ry) return
        if (r[rx] > r[ry]) {
            rx = ry.also { ry = rx }
        }
        r[rx] += r[ry]
        r[ry] = rx
    }

    fun size(x: Int) = -r[root(x)]

    override fun toString(): String {
        return r.joinToString(separator = ", ")
    }
}

Measured memory_bytes: 36172
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
int main(){
	lli n,k;
	cin>>n;
	lli arr[n][3];
	for(lli i=0;i<n;i++) cin>>arr[i][0]>>arr[i][1]>>arr[i][2];
	lli dp[n][3];
	// dp[0]=max(arr[0][0],max(arr[0][1],arr[0][2]));
	dp[0][0] = arr[0][0];
	dp[0][1] = arr[0][1];
	dp[0][2] = arr[0][2];
	for(lli i=1;i<n;i++){
		dp[i][0]=arr[i][0] + max(dp[i-1][1],dp[i-1][2]);
		dp[i][1]=arr[i][1] + max(dp[i-1][0],dp[i-1][2]);
		dp[i][2]=arr[i][2] + max(dp[i-1][1],dp[i-1][0]);
		// cout<<dp[i][0]<<" "<<dp[i][1]<<" "<<dp[i][2]<<"\n";
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2])); 
}

Measured memory_bytes: 8232
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<string>
#include<cstring> 
#include<cassert>
#include<cmath>
#include<sstream>
#include<fstream>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<stack>
#include<bitset>
using namespace std;
vector<pair<int,int> > nei[100005];
int dis[100005];
bool vis[100005];
int n,m;
void dfs(int v,int d)
{
	if(vis[v]&&dis[v]!=d)
	{
	//	cout<<v<<" "<<dis[v]<<" "<<d<<endl;
		cout<<"No";
		exit(0);
	}
	else if(vis[v]) return;
	dis[v]=d;
	vis[v]=1;
//	cout<<v<<" "<<dis[v]<<" "<<d<<endl;
	for(int i=0;i<nei[v].size();i++)
	{
		dfs(nei[v][i].first,d+nei[v][i].second);
	}
}
int main()
{
	cin>>n>>m;
	for(int i=0;i<m;i++)
	{
		int l,r,d;
		cin>>l>>r>>d;
		l--;
		r--;
		nei[l].push_back(make_pair(r,d));
		nei[r].push_back(make_pair(l,-d));
	}
//	memset(vis,0,sizeof(dis));
	for(int i=0;i<n;i++)
	{
		if(!vis[i]) dfs(i,0);
	}
	cout<<"Yes";
}

Measured memory_bytes: 12032
#include<bits/stdc++.h>
#define rep(i,n,k) for(long long int i=k; i<n; ++i)
#define drep(i,n,k) for(long long int i=n-1; i>=k; --i)
using namespace std;

int main(){
  int n;
  cin >> n;
  int ans;
  ans = n*n*n;
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <queue>

#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int main(int argc, char **argv){
	std::string buf;
	int q;
	std::vector<long> vec;

#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif


#if INPUT_FROM_FILE
	std::getline(ifs, buf);
#else
	std::getline(std::cin, buf);
#endif
	q = std::stoi(buf);

	for(int i = 0; i < q; i++){
#if INPUT_FROM_FILE
		std::getline(ifs, buf);
#else
		std::getline(std::cin, buf);
#endif
		if(buf[0] == '0'){
			std::istringstream stream(buf);
			int tmp, x;

			stream >> tmp >> x;
			vec.push_back(x);
		}
		else if(buf[0] == '1'){
			std::istringstream stream(buf);
			int tmp, p;

			stream >> tmp >> p;
			std::cout << vec[p] << std::endl;
		}
		else{
			vec.pop_back();
		}
	}
	return 0;
}


Measured memory_bytes: 4936
#include <iostream>
#include <vector>

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

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int log2_int(ll x) {
  int cur = 0;
  while (true) {
    if (x < 1LL << cur) {
      return cur - 1;
    }
    cur += 1;
  }
}

// This solution was implemented after the author read the editorial.
ll solve(const VL &a) {
  int n = a.size();
  VI b(n + 2), c(n + 2);
  REP(i, 0, n) {
    b[i + 1] = log2_int(a[i]);
    c[i + 1] = log2_int(a[i] - 1) + 1;
  }
  vector<VI> dp(n + 2, VI(2, 0));
  REP(i, 1, n + 2) {
    REP(y, 0, 2) {
      int next = y ? c[i] : b[i];
      int mi = 1e8;
      REP(x, 0, 2) {
	int prev = x ? b[i - 1] : c[i - 1];
	mi = min(mi, dp[i - 1][x] + abs(next - prev) + abs(b[i] - c[i]));
      }
      dp[i][y] = mi;
    }
  }
  return min(dp[n + 1][0], dp[n + 1][1]);
}


int main(void) {
  int n;
  cin >> n;
  VL a(n);
  REP(i, 0, n) {
    cin >> a[i];
  }
  cout << solve(a) / 2 << endl;
}


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

int main() {
  int A, B;
  cin >> A >> B;
  
  if (A <= 5) cout << 0 << endl;
  if (6 <= A && A <= 12) cout << B / 2 << endl;
  if (13 <= A) cout << B << endl;
  
  return 0;
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func nextLine() string {
	sc.Scan()
	return sc.Text()
}

func sliceAtoi(arr []string) []int {
	si := make([]int, 0, len(arr))
	for _, a := range arr {
		i, _ := strconv.Atoi(a)
		si = append(si, i)
	}
	return si
}

func main() {
	k, _ := strconv.Atoi(nextLine())
	s := sliceAtoi(strings.Split(nextLine(), " "))
	a, b := s[0], s[1]
	n := b % k

	if b-a >= n {
		fmt.Println("OK")
	} else {
		fmt.Println("NG")
	}
}


Measured memory_bytes: 1772
def change_times(arr, char)
  return 0 if arr.all? { |a| a == char }
  new_arr = (0..(arr.size - 2)).to_a.map { |i| arr[i, 2].include?(char) ? char : nil }
  change_times(new_arr, char) + 1
end

char_arr = gets.chomp.split('')
puts char_arr.uniq.map { |char| change_times(char_arr, char) }.min

Measured memory_bytes: 1916
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; ++i)
#define rrep(i, n) for(int i = n-1; i >= 0; --i)
#define fi first
#define se second
using namespace std;
using lint = long long;
using uint = unsigned int;
using ulint = unsigned long long;
using ldouble = long double;
using pii = pair<int, int>;
using pli = pair<lint, lint>;
using pdd = pair<double, double>;
using pld = pair<ldouble, ldouble>;
using v1i = vector<int>;
using v1li = vector<lint>;
using v2i = vector<vector<int>>;
using v2li = vector<vector<lint>>;
using v3i = vector<vector<vector<int>>>;
using v3li = vector<vector<vector<lint>>>;
using v1b = vector<bool>;
using v2b = vector<vector<bool>>;
using v3b = vector<vector<vector<bool>>>;
using v1c = vector<char>;
using v2c = vector<vector<char>>;
using v3c = vector<vector<vector<char>>>;
constexpr lint mod1 = 1e9+7;
constexpr lint mod2 = 998244353;

int main(){
  int x, n, s = -1; cin >> x >> n;
  if(n == 0) s = x;
  else{
    unordered_set<int> u; rep(i, n){int a; cin >> a; u.insert(a);}
    rep(i, 200){
      if(!u.count(x-i)){s = x - i; break;}
      if(!u.count(x+i)){s = x + i; break;}
    }
  }
  cout << s << endl;
  return 0;
}

Measured memory_bytes: 3624
a, b, c, d = map(int, input().split())

seconds = 0

if (b <= c) or (d <= a):
    seconds = 0
elif a - c >= 0:
    if d - b >= 0:
        seconds = b - a
    else:
        seconds = d - a
elif a - c <= 0:
    if b - d >= 0:
        seconds = d - c
    else:
        seconds = b - c
else:
    seconds = "a:{0}, b:{1}, c:{2}, d:{3}".format(a, b, c, d)

print(seconds)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define inc(l,i,r) for (int i=l;i<=r;i++)
#define dec(r,i,l) for (int i=r;i>=l;i--)
#define mid ((l+r)>>1)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define ___ putchar(10);
#define N 400400
using namespace std;
typedef long long ll;

int H, W, n, x[N], y[N];
vector<int> G[N];
set<pii > S;

int main() {//freopen("_in.txt","r",stdin);
	scanf("%d%d%d",&H,&W,&n);
	inc(1,i,n) scanf("%d%d",x+i,y+i), G[y[i]].push_back(x[i]), S.insert(mp(x[i],y[i]));
	inc(1,i,W) G[i].push_back(H+1), sort(G[i].begin(),G[i].end());
	
	int x = 1, y = 1, ans = H;
	while (x <= H && y <= W) {
		if (S.find(mp(x+1,y)) != S.end()) {
			ans = min(ans,x);
			break;
		}
		if (S.find(mp(x+1,y+1)) != S.end()) ++x;
		else {
			ans = min(ans,*lower_bound(G[y].begin(),G[y].end(),x) - 1);
			++x, ++y;	
		}
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 28288
character(50)S,T,ans
read*,S
read*,T
do i=len_trim(S)-len_trim(T)+1,1,-1
  if(check(S,T,i))then
    S(i:i+len_trim(T)-1)=trim(T)
    do j=1,Len_trim(S)
      if(S(j:j)=="?")S(j:j)="a"
    end do
    print"(A)",trim(S)
    stop
  endif
end do
print"(A)","UNRESTORABLE"
contains
pure function check(S,T,ind)
  implicit none
  character(50),intent(in)::S,T
  integer,intent(in)::ind
  integer::i
  logical::check
  check=.true.
  do i=1,len_trim(T)
    if(S(ind+i-1:ind+i-1)/=T(i:i).and.S(ind+i-1:ind+i-1)/="?")check=.false.
  end do
  return
end function
end

Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

ll A, B;

int main() {
	cin >> A >> B;
	cout << max((ll)0, A - 2 * B) << endl;
	return 0;
}

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

const int maxn = 2000000;
vector<int> G[maxn];
int dis[maxn];
bool vis[maxn];
LL cnt [2];


bool dfs(int u, int d)
{
    vis[u] = true;
    dis[u] = d;
    for(int i = 0; i < G[u].size(); i++) {
        int v = G[u][i];
        if(vis[v] == true && dis[v] != (d + 1) % 2)
            return true;
        else if(!vis[v]){
            cnt[(d + 1) % 2] ++;
            if(dfs(v, (d + 1) % 2))
                return true;
        }
    }
    return false;
}

int main()
{
    LL n, m;
    scanf("%lld%lld", &n, &m);
    memset(dis,-1,sizeof(dis));
    for(int i = 1; i <= m; i++) {
        int u, v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        G[v].push_back(u);
    }
    if(dfs(1, 0))
        printf("%lld", n * (n - 1) / 2 - m);
    else{
        cnt[0] ++ ;
        printf("%lld", cnt[0] * cnt[1] - m);
    }
    return 0;
}


Measured memory_bytes: 58624
function insertionSort(A, N) {
  const leng = N - 1; // 5
  for(let i = 0; i <= leng; i++) {
    let v = A[i];
    let j = i - 1;
    while (j >= 0 && A[j] > v) {
      A[j + 1] = A[j];
      j--;
    }
    A[j + 1] = v;
    console.log(A.join(" "));
  }
}
const lines = require("fs").readFileSync("/dev/stdin", "utf8").split("\n");
const ary = lines[1].split(" ").map(n => Number(n));
insertionSort(ary, lines[0]);




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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    string s;
    cin >> s;
    ll q;
    cin >> q;
    bool rev=0;//0はそのまま、1は反転
    string t = {}, b = {};
    while(q--){
        int x;
        cin >> x;
        if(x==1){
            rev^=1;
        }
        else{
            int f;
            char c;
            cin >> f >> c;
            if(f==1 && rev==0 || f==2 && rev==1){
                t = c+t;
            }else {
                b+=c;
            }
        }
    }
    //cout << t << endl;
    if(rev==0)cout << t+s+b << endl;
    else {
        for(i = b.size() - 1; i >= 0; i--)
            cout << b[i];
        for(i=s.size()-1;i>=0;i--)cout << s[i];
        for(i = t.size() - 1; i >= 0; i--)
            cout << t[i];
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 1360
using System;
using System.Linq;

    class Program
    {
        static void Main(string[] args)
        {
            int d;
            int n;
            int[] imp = Console.ReadLine().Split(' ').Select(x => Int32.Parse(x)).ToArray();
            d = imp[0];
            n = imp[1];

            int ans;
            if (d == 0)
            {
                ans = n;
                if (ans == 100) ans = 101;
            }
            else if (d == 1)
            {
                ans = 100 * n;
                if (ans == 10000) ans = 10100;
            }
            else
            {
                ans = 10000 * n;
                if (ans == 1000000) ans = 1010000;
            }
            Console.WriteLine((int)ans);
        }
    }


Measured memory_bytes: 13396
#include <bits/stdc++.h>
    #include <cstdio>
    #include <cstring>
    #include <cmath>
    #include <cstring>
    #include <chrono>
    #include <complex>
    #define ll long long int
    #define ld long double
    #define vi vector<int>
    #define vll vector<ll>
    #define vvi vector < vi >
    #define pii pair<int,int>
    #define pll pair<long long, long long>
    #define mod 1000000007
    #define inf 1000000000000000001;
    #define all(c) c.begin(),c.end()
    #define mp(x,y) make_pair(x,y)
    #define mem(a,val) memset(a,val,sizeof(a))
    #define eb emplace_back
    #define pb push_back
    #define f first
    #define s second
    
    using namespace std;
    int main()
    {
        std::ios::sync_with_stdio(false);
        int T;
        T=1;
        // cin.ignore(); must be there when using getline(cin, s)
        while(T--)
        {
            int n,i,j,pos;
            cin>>n;
            int ar[n+1];
            for(i=1;i<=n;++i)
                cin>>ar[i];
            sort(ar+1,ar+n+1);
            ll ans=0,x;
            for(i=1;i<=n;++i)
            {
                for(j=i+1;j<=n;++j)
                {
                    x=ar[i]+ar[j];
                    pos=lower_bound(ar+1,ar+n+1,x)-ar;
                    --pos;
                    ans=ans+max(0,pos-j);
                }
            }
            cout<<ans<<endl;
        }
        return 0;
    }


Measured memory_bytes: 256
S = input()

if S[0] != 'A':
    print('WA')
    quit()
if S[2:-1].count('C') != 1:
    print('WA')
    quit()
if not all(i.islower() for i in S[1:].replace('C','')):
    print('WA')
    quit()
print('AC')


Measured memory_bytes: 3060
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <vector>
#include <iostream>
#include <map>
using namespace std;
#define lson l,(l+r)/2,rt<<1
#define rson (l+r)/2+1,r,rt<<1|1
#define dbg(x) cout<<#x<<" = "<< (x)<< endl
#define pb push_back
#define fi first
#define se second
map<string,int> m;
int x[999999];
int main(){
    //fflush(stdout)
    m["Male"]=1;
    m["Female"]=0;
    int n;
    scanf("%d",&n);
    string ret;
    cout<<0<<endl;
    fflush(stdout);
    cin>>ret;
    if(ret=="Vacant")return 0;
    int lval=m[ret];
    cout<<n-1<<endl;
    fflush(stdout);
    cin>>ret;
    if(ret=="Vacant")return 0;
    int rval=m[ret];
    int l=0,r=n-1;
    while(true){
        int mid=(l+r)/2;
        cout<<mid<<endl;
        fflush(stdout);
        cin>>ret;
        if(ret=="Vacant")return 0;
        int val=m[ret];
        if((mid-l+1)%2==0 && val==lval){
            r=mid;
            rval=val;
        }else if((mid-l+1)%2==1 && val!=lval){
            r=mid;
            rval=val;
        }else if((r-mid+1)%2==0 && val==rval){
            l=mid;
            lval=val;
        }else if((r-mid+1)%2==1 && val!=rval){
            l=mid;
            lval=val;
        }
    }
    return 0;
}

Measured memory_bytes: 852
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int M = sc.nextInt();
		int X = sc.nextInt();
		int A[] = new int[M];
		int h=0;
		int l=0;
		for(int i =0; i<=M-1; i++) {
			A[i] = sc.nextInt();
		}
		for(int i =0; i<=M-1; i++) {
			if(A[i]<X) {
				l++;
			}else {
				h++;
			}
		}
		if(l>h) {
			System.out.println(h);
		}
		else if(l < h) {
			System.out.println(l);
		}else {
			System.out.println(l);
		}
	}
}

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

using namespace std;

const int INF = 1 << 28;

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

  int ret = *max_element(begin(S), end(S)) - *min_element(begin(S), end(S));

  for(int i = 2; i < S.size(); i++) {
    if(S.size() % i) continue;
    string small, large;
    for(int j = 0; j < S.size(); j += i) {
      string v;
      for(int k = 0; k < i; k++) v += S[j + k];
      if(small.empty()) small = v, large = v;
      else small = min(small, v), large = max(large, v);
    }
    int latte = (*prev(large.end(), 2) - '0') * 10 + large.back() - '0';
    int malta = (*prev(small.end(), 2) - '0') * 10 + small.back() - '0';
    large.pop_back(), large.pop_back();
    small.pop_back(), small.pop_back();
    if(large == small) ret = min(ret, latte - malta);
  }
  int small = INF, large = -INF;
  for(int i = 0; i < S.size(); i++) {
    if(S[i] == '1') {
      if(i + 1 >= S.size()) {
        small = INF, large = -INF;
      } else {
        large = max(large, S[i + 1] - '0' + 10);
        ++i;
      }
    } else {
      small = min(small, S[i] - '0');
    }
  }

  if(small != INF && large != -INF) ret = min(ret, large - small);
  cout << ret << endl;
}

Measured memory_bytes: 3324
/*BISMILLAH
THE WHITE WOLF
NO DREAM IS TOO BIG AND NO DREAMER IS TOO SMALL*/

#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<long long> vll;
typedef vector<int> vi;

#define io ios_base::sync_with_stdio(false)
#define pb push_back

#define eb emplace_back
#define mod   1000000007
#define PI 2*acos(0.0)
#define all(r)(r).begin(),(r).end()
#define dbg(a) cout<<#a<<" ->->->-> "<<a<<"\n"
#define inf 1000000000000000000
#define N 500000
int dirx[] = {1, -1,0, 0, 1, 1, -1, -1}, diry[] = {0, 0, 1, -1, 1, -1, 1, -1};



//=============================================ASIFAZAD==============================================//


int32_t main()
{
    io;
    int cnt = 0,n ;
    cin>>n;
    vector<pii > inp(n);
    for(auto& x: inp) cin>>x.first >>x.second;
    for(int i = 0; i< n-2; i++)
        if(inp[i].first == inp[i].second && inp[i+1].first == inp[i+1].second && inp[i+2].first == inp[i+2].second)
            cnt = 1;
    cout<<(cnt? "Yes":"No");
    return 0;
}


Measured memory_bytes: 3644
#include <stdio.h>
#include <stdlib.h>

int main(){
    int temp,a,b,c;
    scanf("%d %d %d",&a,&b,&c);
    
    if(a>b){
        temp = a;
        a = b;
        b = temp;
    }
    if(b>c){
        temp = b;
        b = c;
        c = temp;
    }
     if(a>b){
        temp = a;
        a = b;
        b = temp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


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

const int maxInput = 1000000000;

int main(void)
{
    int timeLength;
    cin >> timeLength;

    int currentDollar, minDollar;
    cin >> minDollar;
    int maxProfit = maxInput * -1;
    for (int i = 1; i < timeLength; i++) {
        cin >> currentDollar;
        if (maxProfit < currentDollar - minDollar) {
            maxProfit = currentDollar - minDollar;
        }
        if (minDollar > currentDollar) {
            minDollar = currentDollar;
        }
    }

    cout << maxProfit << endl;

    return 0;
}

Measured memory_bytes: 1164
import java.util.*;

import static java.lang.System.*;
import static java.lang.Math.*;

class Main {
	public static Scanner sc = new Scanner(in);
	public static Random rand=new Random();

	public void run() {
		int val=sc.nextInt();

		char exp=sc.next().charAt(0);
		while(exp!='='){
			int exp2=sc.nextInt();
			switch(exp){
			case '+':val+=exp2;break;
			case '-':val-=exp2;break;
			case '*':val*=exp2;break;
			case '/':val/=exp2;break;
			}
			exp=sc.next().charAt(0);
		}
		ln(val);
	}
	public static void main(String[] args) {
		new Main().run();
	}

	public int[] nextIntArray(int n){
		int[] res=new int[n];
		for(int i=0;i<n;i++){
			res[i]=sc.nextInt();
		}
		return res;
	}
	public static void pr(Object o) {
		out.print(o);
	}
	public static void ln(Object o) {
		out.println(o);
	}
	public static void ln() {
		out.println();
	}
}

Measured memory_bytes: 19536
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
    {
     	 Scanner sc = new Scanner(System.in);
      	
     	String[] sep = sc.nextLine().split(" ");
      	int n = Integer.parseInt(sep[0]);
      	int m = Integer.parseInt(sep[1]);
      	int[] bigger = new int[n];
      	String[] sepa = sc.nextLine().split(" ");
      	int sumVote = 0;
      	for(int i = 0; i < n; i++)
        {
         	bigger[i] =  Integer.parseInt(sepa[i]);
          	sumVote += bigger[i];
        }
      	int judge = 0;
      	for(int i = 0; i < n; i++)
        {
          	int amari = sumVote % (4 * m);
            if(bigger[i] > sumVote / (4 * m))
            {
                  judge++;
            }else if(bigger[i] == sumVote / (4 * m) && sumVote % (4 * m) == 0){
             	 judge++;
            }
        }
      
      if(judge >= m)
      {
        	System.out.print("Yes");
      }else{
        	System.out.print("No");
      }
    }
}

Measured memory_bytes: 21716
#include<iostream>
#include<cstring>
using namespace std;
int main()
{
	int a[110];
    int n,k;
    cin>>n>>k;
    int x,y;
    memset(a,0,sizeof(a));
    for(int i=0;i<k;++i)
	{
        cin>>x;
        for(int j=0;j<x;++j)
		{
			cin>>y;
            a[y]=1;
        }
    }
    int ans=0;
    for(int i=1;i<=n;++i)
	{
        if(a[i]==0) 
		 ans++;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3168
#include <stdio.h>
#include <string.h>
#include <math.h>

#define NUM 999999

int main () {
	char buff[64];
	int n;
	int result;
	
	unsigned int i, j;
	unsigned int sq_num = (int)sqrt((double)NUM);
	unsigned int prime[NUM];

	for (i = 0; i < NUM; i++) {
		prime[i] = 1;  // 全ての数に1を立てる
	}
	prime[0] = 0;    // 1は素数ではない

	for (i = 1; i < sq_num; i++) {
		if (prime[i] == 1) {
			// prime[i]が素数なら
			for (j = (i+1); (i+1) * j <= NUM; j++) {
				prime[(i+1) * j - 1] = 0;  // 素数の倍数は素数ではない
			}
		}
	}

	while (fgets (buff, 64, stdin)) {
		sscanf (buff, "%d", &n);

		result = 0;
		for (i = 0; i < n; i++) {
			if (prime[i]) {
				result++;
			}
		}
		
		printf ("%d\n", result);
	}
	
	return 0;
}



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


string S;


void input() {
    cin >> S;
}


int main() {
    input();
    int n = S.size();
    string a = "KIHBR";
    vector<char> w;
    bool judge = true;
    rep(i, n) {
        if (S[i] != 'A') w.push_back(S[i]);
        if (i < n - 1) {
            if (S[i] == 'A' || S[i] == 'K' || S[i] == 'I') {
                if (S[i+1] == 'A') judge = false;
            }
        }
    }
    if (w.size() != 5) {
        judge = false;
    } else {
        rep(i, 5) {
            if (w[i] != a[i]) judge = false;
        }
    }
    if (judge) {
        cout << "YES" << endl;
    } else {
        cout << "NO" << endl;
    }
}


Measured memory_bytes: 256
n = int(input())
aArray = [int(x) for x in input().split()]

incFrag = False
decFrag = False

ans = 1
for i in range(0, n - 1):
    if aArray[i + 1] > aArray[i]:
        if decFrag:
            ans += 1
            decFrag = False
        else:
            incFrag = True
    elif aArray[i + 1] < aArray[i]:
        if incFrag:
            ans += 1
            incFrag = False
        else:
            decFrag = True
print(ans)

# print(*data, sep='\n')


Measured memory_bytes: 62832
#include<bits/stdc++.h>
using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
const LL mod=1000000007;
const int INF=1e7;

int main(){
    LL a,b;
    cin >> a >> b;
    if(a*b<=0) puts("Zero");
    else if(0<a&&0<b) puts("Positive");
    else{
        if((b-a)%2==1) puts("Positive");
        else puts("Negative");
    }
    return 0;
}


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

#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
int main() {
  int N,K;
  cin >> N >> K;
  K--;
  string S;
  cin >> S;
  S[K] = tolower(S[K]);
  cout << S << endl;

  return 0;
}

Measured memory_bytes: 3584
import math
a,b,C = map(float,input().split())
S = a*b*math.sin(math.radians(C))/2
L = a+b+(a**2+b**2-2*a*b*math.cos(math.radians(C)))**0.5
h = S*2/a
print(S)
print(L)
print(h)


Measured memory_bytes: 5700
import java.util.Scanner;

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

		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int after[] = new int[n];

		for (int i = n - 1; i > -1; i--) {
			after[i] = sc.nextInt();
		}
		String str = "";
		for (int k : after) {
			str=str+k+" ";
		}
		System.out.println(str.trim());
	}

}


Measured memory_bytes: 26672
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<algorithm>
using namespace std;
int main()
{
    int a,b;
    while(scanf("%d%d",&a,&b)==2)
    {
        if(a<=8&&b<=8)
            printf("Yay!\n");
        else
            printf(":(\n");
    }
    return 0;
}


Measured memory_bytes: 128
#include<iostream>
#include<cmath>
#include<algorithm>
#include<cstring>
using namespace std;

int main(){
    int a[3],b=0,c[3];
    memset(c,0,sizeof(c));
    for(int i=0;i<=2;i++){
        cin>>a[i];
        if((a[i]%2)==0){
            b++;
            c[i]=1;
        }
    }
        for(int i=0;i<3-1;i++){
        for(int j=0;j<3-i-1;j++){
            if(a[j]>a[j+1]){
                int t=a[j];
                a[j]=a[j+1];
                a[j+1]=t;
                t=c[j];
                c[j]=c[j+1];
                c[j+1]=t;
            }
        }
    }
    if(b==0||b==3){
        int ans=0;
        ans=((a[2]-a[1])+(a[2]-a[0]))/2;
        cout<<ans;
    }

    else{
        int x=(a[2]-a[1])+(a[2]-a[0]);
        if(b==1){
            for(int i=0;i<3;i++){
                if(c[i]==0){
                    a[i]++;
                }
            }
        }
        else{
            for(int i=0;i<3;i++){
                if(c[i]==1){
                    a[i]++;
                }
            }
        }
        int ans=0;
        ans=((a[2]-a[1])+(a[2]-a[0]))/2;

        cout<<ans+1;

    }
}


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

using namespace std;

#define int long long
// #define double long double
#define FOR(i, a, b) for(ll i = (a); i < (b); ++i)
#define FORR(i, a, b) for(ll i = (a); i > (b); --i)
#define REP(i, n) for(ll i = 0; i < (n); ++i)
#define REPR(i, n) for(ll i = n; i >= 0; i--)
#define FOREACH(x, a) for(auto &(x) : (a))
#define VECCIN(x)                                                              \
    for(auto &youso_ : (x)) cin >> youso_
#define bitcnt __builtin_popcount
#define SZ(x) ((ll)(x).size())
#define fi first
#define se second
#define All(a) (a).begin(), (a).end()
#define rAll(a) (a).rbegin(), (a).rend()
template <typename T = long long> inline T IN() {
    T x;
    cin >> x;
    return (x);
}
inline void CIN() {}
template <class Head, class... Tail>
inline void CIN(Head &&head, Tail &&... tail) {
    cin >> head;
    CIN(move(tail)...);
}
#define CCIN(...)                                                              \
    char __VA_ARGS__;                                                          \
    CIN(__VA_ARGS__)
#define DCIN(...)                                                              \
    double __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define LCIN(...)                                                              \
    ll __VA_ARGS__;                                                            \
    CIN(__VA_ARGS__)
#define SCIN(...)                                                              \
    string __VA_ARGS__;                                                        \
    CIN(__VA_ARGS__)
#define Printv(v)                                                              \
    {                                                                          \
        REP(x, v.size()) { cout << v[x] << (x == v.size() - 1 ? "\n" : " "); } \
    }
template <typename T = string> inline void eputs(T s) {
    cout << s << "\n";
    exit(0);
}
template <typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val) {
    std::fill((T *)array, (T *)(array + N), val);
}
template <typename T> using PQG = priority_queue<T, vector<T>, greater<T>>;
template <typename T> using PQ = priority_queue<T>;

typedef long long ll;
typedef pair<ll, ll> PL;
typedef vector<PL> VPL;
typedef vector<ll> VL;
typedef vector<VL> VVL;
typedef vector<double> VD;

#define uni int;

const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
const ll dx[] = {1, 0, -1, 0};
const ll dy[] = {0, 1, 0, -1};
#define PI 3.141592653589793238

VL x, y, a, b;
VL memo[26];

signed main() {
    int N;
    cin >> N;
    vector<int> A(100);
    for(int i = 0; i < N; i++) {
        cin >> A[i];
    }
    double X;
    X = 0;
    for(int i = 0; i < N; i++) {
        X += 1.0 / A[i];
    }
    double Z;
    Z = 1 / X;
    cout << Z << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std; 
int main()
{
  int n, cut;
  int A[50],B[50],i,j,p,c;
  while(1){
      cin>>n>>cut;
      if(n==0&&cut==0)break;
      else{
      for(i=0; i<=n-1; i++)A[i]=n-i;
      while(cut--){
          cin>>p>>c;
          for(j=0; j<n; j++)B[j]=A[j];
          for(j=0; j<p-1; j++)B[j+c]=A[j];
          for(j=0; j<c;j++)B[j]=A[j+p-1];
          for(j=0; j<n;j++)A[j]=B[j]; 
        }}
      cout<<A[0]<<endl;}
      return 0;
    }
 

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

#ifndef DEBUG
#define endl '\n'
#define debug(...)
#else
#define debug(...) __VA_ARGS__
#endif
#define debugf(...) debug(printf(__VA_ARGS__);)

using ll = long long;
const int N = 1e5 + 5;



int (((((main)))))() <%
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);

    ll n; cin >> n;

    if (n & 1) {
        cout << 0 << endl;
        return 0;
    }

    n /= 2;

    ll ans = 0;
    while (n > 1) {
        ans += n / 5;
        n /= 5;
    }

    cout << ans << endl;

    return 0;
%>

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

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



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

#define vi vector<int>
#define vvi vector<vi>
#define pii pair<int,int>
#define ll long long
template<typename T, typename U> 
static inline void amin(T &x, U y){
	if(x>y)
		x = y;
}
template<typename T, typename U> 
static inline void amax(T &x, U y){
	if(x<y)
		x = y;
}
#define rep(i,n) for(int i = 0; i < n; ++i)
#define irep(i,k,n) for(int i = k; i <= n; ++i)
#define irepr(i,k,n) for(int i = k; i >= n; --i)

int inf = 2e9;
ll INF = 2e18;
const int mod = 1e9+7;

int main(){
	int n;
	cin >> n;
	int a[n];
	ll dp[n][n];
	ll sz[n][n];
	rep(i,n){
		cin >> a[i];
		sz[i][i] = a[i];
		dp[i][i] = 0;
	}
	irepr(i,n-1,0){
		irep(j,i+1,n-1){
			ll optimal = INF;
			irep(k,i,j-1){
				ll cur = dp[i][k]+dp[k+1][j]+sz[i][k]+sz[k+1][j];
				if(cur<optimal){
					optimal = cur;
					sz[i][j] = sz[i][k]+sz[k+1][j];
					dp[i][j] = cur;
				}
			}
		}
	}
	cout<<dp[0][n-1]<<endl;
	return 0;
}

Measured memory_bytes: 2688
while True:
    s = input().split(" ")
    a = int(s[0])
    op = s[1]
    b = int(s[2])
    if op == "?":
        break
    elif op == "+":
        print(a + b)
    elif op == "-":
        print(a - b)
    elif op == "*":
        print(a * b)
    else:
        print(a // b)

Measured memory_bytes: 7572
#include<bits/stdc++.h>
using namespace std;
template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;
  cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}
template<class T> ostream &operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto vv : V) os << vv << ","; return os << "]";
}
template<class L, class R> ostream &operator<<(ostream &os, pair<L,R> P) {
  return os << "(" << P.first << "," << P.second << ")";
}
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
typedef long long ll;
const int maxn=1e5+233;

int fa[maxn],r[maxn];
int find(int x){
	if(x==fa[x])return x;
	int fx=fa[x];
	fa[x]=find(fa[x]);
	
	r[x]=(r[x]+r[fx])%2;
	
	return fa[x];
}
void merge(int d,int x,int y){
	int fx=find(x),fy=find(y);
	if(fx!=fy){
		fa[fx]=fy;
		
		r[fx]=(1+r[y]-r[x])%2;
		
	}
}

int n,m;
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++){
		fa[i]=i;
		r[i]=0;
	}
	int x,y,z;
	for(int i=1;i<=m;i++){
		scanf("%d %d %d",&x,&y,&z);
		if(z&1)merge(1,x,y);
		else merge(0,x,y);
	}
	int ans=0;
	for(int i=1;i<=n;i++){
		if(find(i)==i)ans++;
	}
	printf("%d\n",ans);
    return 0;
}




Measured memory_bytes: 1920
#------------------------template--------------------------#
import os
import sys
from math import *
from collections import *
from fractions import *
from bisect import *
from heapq import*
from io import BytesIO, IOBase
def vsInput():
    sys.stdin = open('input.txt', 'r')
    sys.stdout = open('output.txt', 'w')
BUFSIZE = 8192
class FastIO(IOBase):
    newlines = 0
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
ALPHA='abcdefghijklmnopqrstuvwxyz'
M=10**9+7
EPS=1e-6
def value():return tuple(map(int,input().split()))
def array():return [int(i) for i in input().split()]
def Int():return int(input())
def Str():return input()
def arrayS():return [i for i in input().split()]


#-------------------------code---------------------------#
#vsInput()

x,k,d=value()

x=abs(x)

moves=min(x//d,k)
k-=moves
x=x-moves*d

# print(x,k)

if(k%2): ans=abs(x-d)
else: ans=x

print(ans)

Measured memory_bytes: 10488
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005,M=1e9+7;
int a[N],inv[N],n,ans;
int ksm(int x,int y){
	int ans=1;
	for (;y;y>>=1,x=x*x%M)
		if (y&1)(ans*=x)%=M;
	return ans;
}
signed main(){
	scanf("%lld",&n);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	for (int i=1;i<=n;i++)inv[i]=(inv[i-1]+ksm(i,M-2))%M;
	for (int i=1;i<=n;i++)(ans+=a[i]*(inv[i]+inv[n-i+1]-1))%=M;
	(ans+=M)%=M;
	for (int i=1;i<=n;i++)(ans*=i)%=M;
	printf("%lld\n",ans);
}


Measured memory_bytes: 1792