akhauriyash/Code-Regression huggingface dataset:
/* Priyansh Agarwal*/
#include<bits/stdc++.h>
#include<algorithm>
#include<unordered_map>
#include<vector>
#include<unordered_set>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<map>
using namespace std;
#define fastio() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define MOD 1000000007
#define MOD1 998244353
#define nline "\n"
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define PI 3.141592653589793238462
#define debug(x) cout << #x << " " << x <<endl;
#define set_bits __builtin_popcount
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
/*---------------------------------------------------------------------------------------------------------------------------*/
ll gcd(ll a, ll b) {if (b > a) {return gcd(b, a);} if (b == 0) {return a;} return gcd(b, a % b);}
ll expo(ll a, ll b, ll mod)
{ll res = 1; while (b > 0) {if (b & 1)res = (res * a) % mod; a = (a * a) % mod; b = b >> 1;} return res;}
vector<int> sieve(int n) {int*arr = new int[n + 1](); vector<int> vect; for (int i = 2; i <= n; i++)if (arr[i] == 0) {vect.push_back(i); for (int j = 2 * i; j <= n; j += i)arr[j] = 1;} return vect;}
void extendgcd(ll a, ll b, ll*v) {if (b == 0) {v[0] = 1; v[1] = 0; v[2] = a; return ;} extendgcd(b, a % b, v); ll x = v[1]; v[1] = v[0] - v[1] * (a / b); v[0] = x; return;} //pass an arry of size 3
ll mminv(ll a, ll b) {ll arr[3]; extendgcd(a, b, arr); return arr[0];} //for non prime b
ll mminvprime(ll a, ll b) {return expo(a, b - 2, b);}
bool revsort(ll a, ll b) {return a > b;}
void swap(int &x, int &y) {int temp = x; x = y; y = temp;}
ll combination(ll n, ll r, ll m, ll* fact) {ll val1 = fact[n]; ll val2 = mminvprime(fact[r], m); ll val3 = mminvprime(fact[n - r], m); return ((val1 * val2) % m * val3) % m;}
void google(int t) {cout << "Case #" << t << ": ";}
/*--------------------------------------------------------------------------------------------------------------------------*/
int main()
{
	fastio();
#ifndef ONLINE_JUDGE
	freopen("Input.txt", "r", stdin);
	freopen("Output.txt", "w", stdout);
	freopen("Error.txt", "w", stderr);
#endif
	ll n;
	cin >> n;
	ll ans = 1e18;
	for (ll i = 1; i <= sqrt(n); i++)
		if (n % i == 0)
			ans = min((i + n / i - 2), ans);
	cout << ans << endl;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
const long long MOD = 1e9 + 7;
const long long INF = 1e12;
const int inf = 1e9;
const int mod = 1e9+7;
typedef long long ll;
typedef pair<ll,int> P;
typedef set<int> S;
vector<int> to[10];
int ans = 0;
int n,m;
void solve(int now, int cnt, int p, vector<bool> v){
    if(cnt == n) ans++;
    else{
        for(auto u : to[now]){
            if(u != p && v[u] == 0){
                v[u] = 1;
                solve(u, cnt+1, now, v);
                v[u] = 0;
            }
        }
    }
}
int main(){
    cout << fixed << setprecision(10);
    cin >> n >> m;
    rep(i,m){
        int a,b;
        cin >> a >> b;
        a--;
        b--;
        to[a].push_back(b);
        to[b].push_back(a);
    }
    vector<bool> v(n,0);
    v[0] = 1;
    solve(0, 1, -1, v);
    cout << ans << endl;
    return 0;
}

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

int main(){ 
  int N; cin >> N;
  
  int a = 0, b = 0, c = 0;
  
  int cnt = 0;
  
  for(int i = 0; i < N; i++){
    
    string s; cin >> s;
   
    if( s.front() == 'B' && s.back() == 'A'){ c++;}
    else if( s.front() == 'B'){ b++;}
    else if( s.back() == 'A'){ a++;}
    
    for(int j = 0; j < (int)s.size()-1; j++){
      if(s[j] == 'A' && s[j+1] == 'B'){ cnt++;}
    }
    
  }
  
  if(c > 0){ cnt += c-1;
            if(a > 0){ cnt++; a--; } if( b > 0){ cnt++; b--;}
           }
  
  cnt += min(a,b);
  
  cout << cnt << endl;
  
  return 0;
}

Measured memory_bytes: 256
import std;

// dfmt off
T lread(T = long)(){return readln.chomp.to!T();}
T[] lreads(T = long)(long n){return generate(()=>readln.chomp.to!T()).take(n).array();}
T[] aryread(T = long)(){return readln.split.to!(T[])();}
void scan(TList...)(ref TList Args){auto line = readln.split();
foreach (i, T; TList){T val = line[i].to!(T);Args[i] = val;}}
alias sread = () => readln.chomp();enum MOD = 10 ^^ 9 + 7;
alias PQueue(T, alias less = "a<b") = BinaryHeap!(Array!T, less);
// dfmt on

void main()
{
    real R = lread();
    writefln("%.10f", 2 * PI * R);
}


Measured memory_bytes: 3932
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <random>

using namespace std;


int main()
{
	int A, B;
	int ans = 0;

	cin >> A >> B;

	if ((B - 1) % (A - 1) == 0) {
		ans = (B - 1) / (A - 1);
	}
	else {
		ans = (B - 1) / (A - 1) + 1;
	}

	printf("%d\n", ans);


	return 0;
}



Measured memory_bytes: 256
/*
  _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
 |                                                                 |
 |   author : yash1399     Language : C ++                         | 
 |   college : MSIT                                                | 
 | _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ |  
*/
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <functional>
using namespace std;
# define ll  long long int 
# define TEST int t ; cin>>t; while(t--)
# define line cout<<endl;
# define fast ios_base::sync_with_stdio(false) ; cin.tie(0) ; cout.tie(0);
# define loop(i,a,b) for(long long int i=a;i<b;i++)
# define loopIn(i,a,b) for(long long int i=a;i<=b;i++)
#define MAX_SIZE 10000000
vector<bool> V(MAX_SIZE,false);
int main(){
      fast
      ll r;
      cin>>r;
      ll ans = pow(r,2);
      cout<<ans<<endl;
      return 0;
}

Measured memory_bytes: 1536
#include <stdio.h>
#include <math.h>
#define PI 3.141592654
    int main(void){
        int a, b, c;
        double S, L, h;
        scanf("%d %d %d", &a, &b, &c);
        S = 0.5*a*b*sin(c*PI/180);
        L = a + b + sqrt(a*a + b*b - 2*a*b*cos(c*PI/180));
        h = (2*S)/a;
        printf("%lf\n", S);
        printf("%lf\n", L);
        printf("%lf\n", h);
         return 0;
    }


Measured memory_bytes: 2064
import java.util.*

fun main(args: Array<String>) {
    val sc = Scanner(System.`in`)
    val m = mutableMapOf<String, Int>()
    while (sc.hasNext()) {
        val n = sc.next()
        m[n] = m.getOrDefault(n, 0)+1
    }
    val l = m.toList()
    val ans1 = l.sortedBy { it.second }.last().first
    val ans2 = l.sortedBy { it.first.length }.last().first
    println("$ans1 $ans2")
}


Measured memory_bytes: 30200
#include<iostream>
using namespace std;
int main(){
  int h,n,sum=0;
  cin>>h>>n;
  for(int i=0;i<n;i++){
    int ai;
    cin>>ai;
    sum+=ai;
  }
  if(sum>=h)	cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}

Measured memory_bytes: 256
#template
from collections import Counter
def inputlist(): return [int(j) for j in input().split()]
#template
N = int(input())
L = inputlist()
L.sort()
s = 0
for i in range(N-1):
    s += L[i]
if s > L[-1]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3316
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n;string b;vector<string>u;
  cin>>n;
  map<string,int> p;
  for(int i=0;i<n;i++){
    cin>>b;
    p[b]++;
    u.push_back(b);
  }
  int maxi=-89375;
  for(auto i=p.begin();i!=p.end();i++){
      if(i->second>maxi)
      maxi=i->second;
  }
  for(auto i=p.begin();i!=p.end();i++){
      if(i->second==maxi)
      cout<<i->first<<endl;
  }
}


Measured memory_bytes: 27632
// https://atcoder.jp/contests/abc062/tasks/arc074_b

#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define REP(i,n)   for(int i=0; i<(int)(n); i++)
#define FOR(i,b,e) for(int i=(b); i<=(int)(e); i++)
#define DUMP(a, n) REP(_i, n) printf("%d%c", a[_i], _i + 1 == n ? '\n' : ' ')
#define DUMP2D(a, n, m) REP(_i, n) REP(_j, m) printf("%d%c", a[_i][_j], _j + 1 == m ? '\n' : ' '); puts("")

const int N_MAX = 1e5;
const int A_I_MAX = 1e9;
const ll INF = 1e15;

int N;
int a[N_MAX * 3];

ll L[N_MAX + 1];
ll R[N_MAX + 1];

void solve() {
  ll l = 0;
  priority_queue<int, vector<int>, greater<int> > lq;
  REP(i, N) {
    int la = a[i];
    l += la;
    lq.push(la);
  }
  L[0] = l;
  REP(i, N) {
    int li = lq.top();
    int la = a[N + i];
    if (la > li) {
      L[i + 1] = L[i] - li + la;
      lq.pop(); lq.push(la);
    } else {
      L[i + 1] = L[i];
    }
  }
  ll r = 0;
  priority_queue<int, vector<int> > rq;
  for(int i = N * 3 - 1; i >= N * 2; i--) {
    int ra = a[i];
    r += ra;
    rq.push(ra);
  }
  R[N] = r;
  for (int i = N - 1; i >= 0; i--) {
    int rx = rq.top();
    int ra = a[N + i];
    if (ra < rx) {
      R[i] = R[i + 1] - rx + ra;
      rq.pop(); rq.push(ra);
    } else {
      R[i] = R[i + 1];
    }
  }
  // DUMP(L, N + 1);
  // DUMP(R, N + 1);
  ll ans = -INF;
  REP(i, N + 1) ans = max(ans, L[i] - R[i]);
  printf("%lld\n", ans);
}

void input() {
  scanf("%d", &N);
  REP(i, N * 3) scanf("%d", a + i);
}

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


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;
 
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
 
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef long double ld; 
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef pair<ld,ld> point;

ld dist(point a, point b)
{
	return sqrt((a.fi-b.fi)*(a.fi-b.fi)+(a.se-b.se)*(a.se-b.se));
}

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	vector<point> vec;
	int n; cin>>n;
	for(int i=0;i<n;i++)
	{
		ld x,y; cin>>x>>y;
		vec.pb({x,y});
	}
	ld sum=0;
	ld cnt=0;
	sort(vec.begin(),vec.end());
	do
	{
		cnt++;
		for(int i=0;i+1<n;i++)
		{
			sum+=dist(vec[i],vec[i+1]);
		}
	}while(next_permutation(vec.begin(),vec.end()));
	sum/=cnt;
	cout<<fixed<<setprecision(10)<<sum<<'\n';
}


Measured memory_bytes: 3816
use proconio::input;

#[allow(unused_imports)]
use proconio::marker::{Bytes, Chars, Usize1};
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::ops::*;
#[derive(Clone, Debug, Default)]
struct Struct;

//#[proconio::fastout]
fn main() {
    input! {
        mut s:Chars,
    }

    let len = s.len() + 1;
    let mut lmin = vec![0u64;len];
    let mut rmin = vec![0u64;len];

    // 左から見たときの下限
    lmin[0] = 0;
    for i in 1..len {
        if s[i - 1] == '<' {
            lmin[i] = lmin[i - 1] + 1;
        } else {
            lmin[i] = 0;
        }
    }

    // 右から見たときの下限
    s.reverse();
    rmin[0] = 0;
    for i in 1..len {
        if s[i - 1] == '>' {
            rmin[i] = rmin[i - 1] + 1;
        } else {
            rmin[i] = 0;
        }
    }
    s.reverse();
    rmin.reverse();


    let mut ans = 0;
    for i in 0..len {
        ans += max(lmin[i],rmin[i]);
    }
    println!("{}", ans);
}


Measured memory_bytes: 12372
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <math.h>
#include <queue>
using namespace std;
typedef long long ll;
#define PI 3.14159265359

int main() {
  ll N, M, K, A, B;
  cin >> N >> M >> K;
  vector<ll> Avec, Bvec;
  Avec.reserve(N+1);
  Bvec.reserve(M+1);
  Avec.push_back(0);
  Bvec.push_back(0);
  ll A_count = 0;
  bool flag = true;
  for (auto i = 0;i < N; i ++) {
    cin >> A;
    if (!flag) {
      continue;
    }
    A_count += A;
    if (A_count > K) {
      flag = false;
      continue;
    }
    Avec.push_back(A_count);
  }
  ll B_count = 0;
  flag = true;
  for (auto i = 0;i < M; i ++) {
    cin >> B;
    if (!flag) {
      continue;
    }
    B_count += B;
    if (B_count > K) {
      flag = false;
      continue;
    }
    Bvec.push_back(B_count);
  }
  ll B_index = Bvec.size() - 1;
  ll max = B_index;
  for (auto i = 0;i < Avec.size();i ++) {
    for (auto k = B_index;k >= 0; k --) {
      if (Avec[i] + Bvec[k] <= K) {
        break;
      }
      B_index --;
    }
    max = std::max(max, i + B_index);
  }
  cout << max << endl;
  return 0;
}

Measured memory_bytes: 6316
#include<iostream>
using namespace std;
int main(){
int a,b,c,d,e;
cin >>a>>b>>c>>d>>e;
if(a<40)
a=40;

if(b<40)
b=40;

if(c<40)
c=40;

if(d<40)
d=40;

if(e<40)
e=40;

cout<<(a+b+c+d+e)/5<<endl;
return 0;
}


Measured memory_bytes: 3104
//
// Created on 2019-02-09.
//
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
template<class T> bool INRANGE(T x,T a,T b) { return a<=x&&x<=b; }

#define REP(i,n) for(int i=0;i<(n);++i)
#define ALL(v) (v).begin(),(v).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;

#define PB push_back
#define INF 1e9
#define MOD 1e9+7
#define EPS 1e-9

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

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



    ll N, a, b, c, d, e;
    cin >> N >> a >> b >> c >> d >> e;

    ll min_n = min(a, b);
    min_n = min(min_n,c);
    min_n = min(min_n,d);
    min_n = min(min_n,e);

    ll ans = 5;
    ans += N/min_n-1;
    if (N%min_n != 0) ans++;
    if(ans < 5) ans = 5;

    cout << ans << endl;

    return 0;

}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
using namespace std;
#define N 3 
int main()
{
	int n,i;
		scanf("%d",&n);
		getchar();
	char a[107],b[107],c[107];
	for(i=0;i<n;i++)
		scanf("%c",&a[i]);
	getchar();
	for(i=0;i<n;i++)
		scanf("%c",&b[i]);
	getchar();
	for(i=0;i<n;i++)
		scanf("%c",&c[i]);
	getchar();
		int ans=0;
	for(i=0;i<n;i++){
		if((a[i]==b[i]&&b[i]!=c[i]&&a[i]!=c[i])||(a[i]!=b[i]&&b[i]==c[i]&&a[i]!=c[i])||(a[i]!=b[i]&&b[i]!=c[i]&&a[i]==c[i]))
			ans+=1;
		else if((a[i]!=b[i]&&b[i]!=c[i]&&a[i]!=c[i]))
			ans+=2;
	}
		printf("%d",ans);

}

Measured memory_bytes: 128
#include <iostream>
#include <vector>
#include <string>
#include <sstream>
#include <algorithm>
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
int INF = 1e9+7;
#define all(c) (c).begin(), (c).end()
#define tr(c, i) for(auto i = (c).begin(); i != (c).end(); i++)
#define rep(i,b) for(auto i=0;i<(b);i++)
#define pb push_back
#define sz(c) int((c).size())

const int MAX_N = 50100;
vector<bool> primes(MAX_N, false);

void build()
{
  primes[2] = true;
  for (int i = 3; i*i <= MAX_N; i += 2) {
    if (primes[i]) {
      for (int j = 2; i*j < MAX_N; j++) {
        primes[i*j] = false;
      }
    }
  }
}

int lessthan(int n)
{
  for (int i = n - 1; i > 0; i--) {
    if (primes[i])
      return i;
  }
  return 2;
}

int morethan(int n)
{
  for (int i = n + 1; i < MAX_N; i++) {
    if (primes[i])
      return i;
  }
  return 50021;
}

int main(int argc, char **argv)
{
  for (int i = 3; i < MAX_N; i += 2) {
    primes[i] = true;
  }
  build();
  int n;
  while (cin >> n) {
    cout << lessthan(n) << " " << morethan(n) << endl;
  }

  return 0;
}

Measured memory_bytes: 1204
#include<bits/stdc++.h>
#define ll long long
#define pb push_back
#define pii pair<int,int>
#define mp make_pair
#define fi first
#define se second
#define eb emplace_back
using namespace std;
const int mod = 1e9 + 7;
const int maxn = 2e5 + 233;
vector<int> g[maxn];
int d[maxn],fa[maxn],f[maxn];
int dfs(int x,int fa){
	f[x] = d[x];
	(::fa[x]) = fa;
	for(int y:g[x]){
		if(y==fa)continue;
		d[y] = d[x]+1;
		dfs(y,x);
		f[x] = max(f[x],f[y]);
	}
}
int main()
{
	int n,u,v;cin>>n>>u>>v;
	for(int i=1;i<n;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		g[x].pb(y);
		g[y].pb(x);
	}
	bool bad = d[u]%2;
	dfs(v,-0);
	int step = d[u]/2;
	while(step--){
		u = fa[u];
	}
//	cout<<"!"<<u<< " "<<f[u] << endl;
	if(bad)cout << f[u] << endl;
	else cout << f[u]-1 << endl;
}


Measured memory_bytes: 14720
using System;
using System.Linq;
using System.Collections.Generic;
using System.Diagnostics;
using Debug = System.Diagnostics.Trace;
using SB = System.Text.StringBuilder;
using System.Numerics;
using static System.Math;
using Number = System.Int32;

namespace Program {
	public class Solver {
		Random rnd = new Random();
		public void Solve() {
			var n = ri;
			var ans = 0;
			for (int i = 1; i <= n; i++)
				if (i % 2 == 1) ans++;
			Console.WriteLine(1.0 * ans / n);

		}
		const long INF = 1L << 60;
		static int[] dx = { -1, 0, 1, 0 };
		static int[] dy = { 0, 1, 0, -1 };
		int ri { get { return sc.Integer(); } }
		long rl { get { return sc.Long(); } }
		double rd { get { return sc.Double(); } }
		string rs { get { return sc.Scan(); } }
		public IO.StreamScanner sc = new IO.StreamScanner(Console.OpenStandardInput());

		static T[] Enumerate<T>(int n, Func<int, T> f) {
			var a = new T[n];
			for (int i = 0; i < a.Length; ++i) a[i] = f(i);
			return a;
		}
		static public void Swap<T>(ref T a, ref T b) { var tmp = a; a = b; b = tmp; }
	}
}

#region main
static class Ex {
	static public string AsString(this IEnumerable<char> ie) { return new string(ie.ToArray()); }
	static public string AsJoinedString<T>(this IEnumerable<T> ie, string st = " ") {
		return string.Join(st, ie);
	}
	static public void Main() {
		Console.SetOut(new Program.IO.Printer(Console.OpenStandardOutput()) { AutoFlush = true });
		var solver = new Program.Solver();
		/* 
		var t = new System.Threading.Thread(solver.Solve, 50000000);
		t.Start();
		t.Join();
		//*/
		solver.Solve();
		Console.Out.Flush();
	}
}
#endregion
#region Ex
namespace Program.IO {
	using System.IO;
	using System.Text;
	using System.Globalization;

	public class Printer : StreamWriter {
		public override IFormatProvider FormatProvider { get { return CultureInfo.InvariantCulture; } }
		public Printer(Stream stream) : base(stream, new UTF8Encoding(false, true)) { }
	}

	public class StreamScanner {
		public StreamScanner(Stream stream) { str = stream; }

		public readonly Stream str;
		private readonly byte[] buf = new byte[1024];
		private int len, ptr;
		public bool isEof = false;
		public bool IsEndOfStream { get { return isEof; } }

		private byte read() {
			if (isEof) return 0;
			if (ptr >= len) {
				ptr = 0;
				if ((len = str.Read(buf, 0, 1024)) <= 0) {
					isEof = true;
					return 0;
				}
			}
			return buf[ptr++];
		}

		public char Char() {
			byte b = 0;
			do b = read(); while ((b < 33 || 126 < b) && !isEof);
			return (char)b;
		}
		public string Scan() {
			var sb = new StringBuilder();
			for (var b = Char(); b >= 33 && b <= 126; b = (char)read()) sb.Append(b);
			return sb.ToString();
		}
		public string ScanLine() {
			var sb = new StringBuilder();
			for (var b = Char(); b != '\n' && b != 0; b = (char)read()) if (b != '\r') sb.Append(b);
			return sb.ToString();
		}
		public long Long() { return isEof ? long.MinValue : long.Parse(Scan()); }
		public int Integer() { return isEof ? int.MinValue : int.Parse(Scan()); }
		public double Double() { return isEof ? double.NaN : double.Parse(Scan(), CultureInfo.InvariantCulture); }
	}
}

#endregion


Measured memory_bytes: 13136
import collections

K = int(input())

q = collections.deque([(1, 0)])
v = {1}

while len(q) > 0:
    c, p = q.popleft()
    v.add(c)
    if c == 0:
        break

    n1, n10 = (c + 1) % K, (c * 10) % K
    if not n1 in v:
        q.append((n1, p + 1))
    if not n10 in v:
        q.appendleft((n10, p))

print(p + 1)


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

int main() {
	long long a, b, x, pa, pb, ans;
	cin >> a >> b >> x;
	if (a == 0) {
		if (b == 0) ans = 1;
		else {
			pa = -1;
			pb = b / x;
			ans = pb - pa;
		}
	}
	else {
		pa = (a - 1) / x;
		pb = b / x;
		ans = pb - pa;
	}
	cout << ans << endl;
}

Measured memory_bytes: 256
//ex3_3
//TKC001
 
#include<stdio.h>
#include<math.h>
 
int main(void){
	//1.exactを真数, baseを底として対数を求める。
    double exact, base, logkn;
    int digits;
 
    scanf("%lf", &exact);
    scanf("%lf", &base);
 
    logkn = log(exact) / log(base);
	//1.ここまで
 
	//2.logknの小数点を切り捨て
	digits = logkn;
 
	//3.桁数を表示
    printf("%d", digits+1);
 
    return 0;
 
}

Measured memory_bytes: 384
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
#define rep(i,l,r) for (int i=(l); i<=(r); i++)
typedef long long ll;
using namespace std;

const int N=1010;
int n,a[N],res[N];

int main(){
	scanf("%d",&n);
	rep(i,1,n) scanf("%d",&a[i]);
	rep(i,1,n){
		int k=0;
		for (int j=n-i+1; j; j--) if (a[j]==j) { k=j; break; }
		if (!k){ puts("-1"); return 0; }
		res[i]=k;
		rep(j,k,n-i) a[j]=a[j+1];
	}
	for (int i=n; i; i--) printf("%d\n",res[i]);
	return 0;
}

Measured memory_bytes: 256
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<array>
#include<map>
#include<iomanip>
#include<assert.h>
#include<list>
#include<bitset>
#include<stack>
#include<memory>
#include<numeric>
#include <utility>


using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define REP(i, n) for(int i = 0;i < (n);i++)
/*cout<<fixed<<setprecision(20);cin.tie(0);ios::sync_with_stdio(false);*/
const llint mod=1000000007;
const llint inf=2.19e15+1;
const long double pai=3.141592653589793238462643383279502884197;
const long double eps=1e-10;
template <class T,class U>bool chmin(T& a,U b){if(a>b){a=b;return true;}return false;}
template <class T,class U>bool chmax(T& a,U b){if(a<b){a=b;return true;}return false;}
llint gcd(llint a,llint b){if(a%b==0){return b;}else return gcd(b,a%b);}
llint lcm(llint a,llint b){if(a==0){return b;}return a/gcd(a,b)*b;}
template<class T> void SO(T& ve){sort(ve.begin(),ve.end());}
template<class T> void REV(T& ve){reverse(ve.begin(),ve.end());}
template<class T>llint LBI(const vector<T>&ar,T in){return lower_bound(ar.begin(),ar.end(),in)-ar.begin();}
template<class T>llint UBI(const vector<T>&ar,T in){return upper_bound(ar.begin(),ar.end(),in)-ar.begin();}

//ダブリング
//ACLにないんだけど
int main(void){
	int h,i,j,n,m,K;cin>>n>>K;
	vector<llint>X(n+2);
	X[0]=-inf;X[n+1]=inf;
	for(i=1;i<=n;i++){cin>>X[i];}
	vector<int>lgo[18];
	vector<int>rgo[18];
	vector<llint>lsum[18];
	vector<llint>rsum[18];
	for(h=0;h<18;h++){
		lgo[h].res(n+2);rgo[h].res(n+2);
		lsum[h].res(n+2);rsum[h].res(n+2);
	}
	for(i=1;i<=n;i++){
		lgo[0][i]=LBI(X,X[i]+K);
		rgo[0][i]=UBI(X,X[i]-K)-1;
		lsum[0][i]=i;
		rsum[0][i]=i;
	}
	lgo[0][0]=0;lgo[0][n+1]=n+1;
	lsum[0][0]=0;lsum[0][n+1]=n+1;
	rgo[0][0]=0;rgo[0][n+1]=n+1;
	rsum[0][0]=0;rsum[0][n+1]=n+1;
	for(h=1;h<18;h++){
		for(i=0;i<=n+1;i++){
			lgo[h][i]=lgo[h-1][lgo[h-1][i]];
			rgo[h][i]=rgo[h-1][rgo[h-1][i]];
			lsum[h][i]=lsum[h-1][i]+lsum[h-1][lgo[h-1][i]];
			rsum[h][i]=rsum[h-1][i]+rsum[h-1][rgo[h-1][i]];
		}
	}
	int Q;cin>>Q;
	while(Q--){
		int L,R,gL,gR,Lcou=0,Rcou=0;cin>>L>>R;
		gL=L;gR=R;
		llint ans=0;
		for(h=17;h>=0;h--){
			if(lgo[h][gL]<=R){ans-=lsum[h][gL];gL=lgo[h][gL];Lcou+=(1<<h);}
			if(rgo[h][gR]>=L){ans+=rsum[h][gR];gR=rgo[h][gR];Rcou+=(1<<h);}
		}
		ans-=gL;Lcou++;
		ans+=gR;Rcou++;
		if(Lcou!=Rcou){cerr<<"bag"<<endl;}
		
		ans+=Lcou;
		cout<<ans<<endl;
	}
	return 0;
}

Measured memory_bytes: 89324
package main

import (
	"fmt"
)

func main() {
	var n int
	fmt.Scan(&n)

	a := make([]int, n)
	for i := 0; i < n; i++ {
		fmt.Scan(&a[i])
	}
	count := 0

	for {
		existOdd := false
		for i := 0; i < n; i++ {
			if a[i]%2 != 0 {
				existOdd = true
			}
		}
		if existOdd == true {
			break
		}
		for i := 0; i < n; i++ {
			a[i] /= 2
		}
		count++
	}

	fmt.Println(count)
}


Measured memory_bytes: 1776
import itertools

n=int(input())
l = [int(_) for _ in input().split()]

li=itertools.combinations(l,3)
ans=0
for i in li:
    if i[0]==i[1] or i[1]==i[2] or i[0]==i[2]:
        continue

    temp=list(i)
    temp.sort()
    if temp[0]+temp[1]>temp[2]:
        ans+=1
        # print(temp)
print(ans)

   
    


Measured memory_bytes: 9192
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>
#include <queue>
#include <algorithm>
using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef pair<int, int> P;
const int c_INF = 111111111;
const int c_mINF = -111111111;
const int c_YET = -1;
const int c_Dx[4] = { 0,0,1,-1 };
const int c_Dy[4] = { 1,-1,0,0 };
const int c_div = 1000000007; //10^9 + 7


int main() {
	int A,B,C;
	scanf("%d%d%d" , &A, &B,&C);

	if (C >= A && C <= B) {
		printf("Yes");
	}
	else {
		printf("No");
	}







}

Measured memory_bytes: 128
M=9;main(n,i,j,k,a,b,c){
	double p=atan(1)*4,X[100],Y[100],x,y;
	for(;scanf("%d",&n),n;printf("%d\n",a)){
		for(i=0;i<n;i++)scanf("%lf,%lf",X+i,Y+i);
		for(a=i=0;i<n;i++){
			for(b=k=0;k<M;k++){
				x=X[i]+cos(p*k/M),y=Y[i]+sin(p*k/M);
				for(c=j=0;j<n;j++){
					if((X[j]-x)*(X[j]-x)+(Y[j]-y)*(Y[j]-y)<1+1e-7)c++;
				}
				if(b<c)b=c;
			}
			if(a<b)a=b;
		}
	}
exit(0);}

Measured memory_bytes: 644
N = int(input())
Points = [list(map(int, input().split())) for i in range(N)]

X_dict = {x: [] for x in range(1, 10 ** 5 + 1)}
Y_dict = {y: [] for y in range(1, 10 ** 5 + 1)}
for i, (x, y) in enumerate(Points):
    X_dict[x].append((y, i))
    Y_dict[y].append((x, i))


ans = 0
Visited = [False] * N
for i, (x, y) in enumerate(Points):
    if Visited[i]:
        continue

    stack = [('x', x), ('y', y)]
    cnt = 1
    x_set, y_set = {x}, {y}
    Visited[i] = True
    while stack:
        s, v = stack.pop()
        if s == 'x':
            for yd, j in X_dict[v]:
                if Visited[j]:
                    continue
                else:
                    cnt += 1
                    y_set.add(yd)
                    stack.append(('y', yd))
                    Visited[j] = True
        else:
            for xd, j in Y_dict[v]:
                if Visited[j]:
                    continue
                else:
                    cnt += 1
                    x_set.add(xd)
                    stack.append(('x', xd))
                    Visited[j] = True

    ans += len(x_set) * len(y_set) - cnt

print(ans)


Measured memory_bytes: 102356
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using static System.Console;
using static System.Math;

namespace AtTest.ABC_137
{
    class C
    {
        static void Main(string[] args)
        {
            var sw = new System.IO.StreamWriter(OpenStandardOutput()) { AutoFlush = false };
            SetOut(sw);

            Method(args);

            Out.Flush();
        }

        static void Method(string[] args)
        {
            int n = ReadInt();
            Dictionary<string, long> dict = new Dictionary<string, long>();
            for(int i = 0; i < n; i++)
            {
                string s = Read();
                char[] cs = s.ToCharArray();
                Array.Sort(cs);
                string ss = new string(cs);
                if (!dict.ContainsKey(ss)) dict.Add(ss, 0);
                dict[ss]++;
            }

            long res = 0;
            foreach(string s in dict.Keys)
            {
                res += (dict[s] * (dict[s] - 1)) / 2;
            }
            WriteLine(res);
        }

        private static string Read() { return ReadLine(); }
        private static char[] ReadChars() { return Array.ConvertAll(Read().Split(), a => a[0]); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 27224
K, N = map(int, input().split())
li = list(map(int, input().split()))
li.append(li[0]+K)
max_distance = 0
for i in range(1, N+1):
    temp = li[i]-li[i-1]
    if max_distance < temp:
        max_distance = temp
print(K-max_distance)

Measured memory_bytes: 77388
#pragma region
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, m, n) for (int i = m; i < n; i++)
#define all(v) v.begin(), v.end()
#define INF 1e9
#define EPS 1e-10
using namespace std;
typedef long long ll;
#pragma endregion

int main()
{
    int n,q,count = 0;
    cin >> n;
    vector<int> S(n);

    rep(i, n){
        cin >> S.at(i);
    }
    
    cin >> q;
    vector<int> T(q);

    rep(i, q){
        cin >> T.at(i);
    }

    rep(i, q){
        rep(j, n){
            if(T.at(i) == S.at(j)){
                count++;
                break;
            }
        }
    }

    cout << count << endl;
}


Measured memory_bytes: 3120
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
string st;
int ans;
char ch[20]={'C','O','D','E','F','E','S','T','I','V','A','L','2','0','1','6'};
int main()
{
	cin>>st;
	for(int i=0;i<16;i++)if(st[i]!=ch[i])ans++;
	cout<<ans;
return 0;
}


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

#define WORD_SIZE_MAX 100

int dict_compare(const char *s1, const char *s2) {
    while (*s1 == *s2) {
        if (*s1 == '\0')
            return 0;
        s1++;
        s2++;
    }
    return *s1 - *s2;
}

int main(void) {
	int n;
	scanf("%d", &n);

	int score[2] = {0, 0};	// ????????¨??±????????????.
	int i;
	for (i = 0; i < n; i++) {
		char words[2][WORD_SIZE_MAX];	// ????????¨??±????????????.
		scanf("%s %s", words[0], words[1]);
		
		int result = dict_compare(words[0], words[1]);
		if (result == 0) {
			score[0] += 1;
			score[1] += 1;
		} else if (result > 0) {
			score[0] += 3;
		} else {
			score[1] += 3;
		}
	}

	printf("%d %d\n", score[0], score[1]);
	return 0;
}

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

int main() {
    int n, m; std::cin >> n >> m;
    std::vector<int> h(n);
    rep(i,n)
        std::cin >> h[i];
    std::vector<int> maxs(n, 0);
    rep(i,m) {
        int a, b; std::cin >> a >> b; --a; --b;
        maxs[a] = std::max(maxs[a], h[b]);
        maxs[b] = std::max(maxs[b], h[a]);
    }

    int ans=0;
    rep(i,n) {
        if (h[i] > maxs[i]) ++ans;
    }
    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 4052
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <map>
#include <bitset>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <sstream>

using namespace std;

vector<string> split(string src, char delim) {
	istringstream ss(src);
	string s;
	vector<string> ret;
	while (getline(ss, s, delim))
		ret.push_back(s);
	return ret;
}

int main() {
	string str;
	while (getline(cin, str)) {
		stack<double> s;
		for (const string& t : split(str, ' ')) {
			if (t == "+") {
				double op1 = s.top(); s.pop();
				double op2 = s.top(); s.pop();
				double ans = op2 + op1;
				s.push(ans);
			}
			else if (t == "-") {
				double op1 = s.top(); s.pop();
				double op2 = s.top(); s.pop();
				double ans = op2 - op1;
				s.push(ans);
			}
			else if (t == "*") {
				double op1 = s.top(); s.pop();
				double op2 = s.top(); s.pop();
				double ans = op2 * op1;
				s.push(ans);
			}
			else if (t == "/") {
				double op1 = s.top(); s.pop();
				double op2 = s.top(); s.pop();
				double ans = op2 / op1;
				s.push(ans);
			}
			else {
				s.push(atoi(t.c_str()));
			}
		}
		cout << fixed << setprecision(6) << s.top() << endl;
		s.pop();
	}
	return 0;
}

Measured memory_bytes: 1276
#include <iostream>
#include <stdint.h>
#include <vector>
#include <limits.h>
#include <utility>
#include <memory>
#include <set>
#include <map>

using namespace std;

using Group = set<int>;

uint64_t calc_convenience(Group& group)
{
  uint64_t island_count = group.size();
  return island_count * (island_count-1) / 2;
}

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

  vector<pair<int,int>> bridges;
  
  for (int m=0; m<M; ++m) {
    int a,b;
    cin >> a >> b;
    bridges.push_back(pair<int,int>(a,b));
  }

  map<int,shared_ptr<Group>> island2group;
  set<shared_ptr<Group>> groups;

  for (int n=0; n<N; ++n) {
    Group new_group = {n+1};
    auto ptr_new_group = make_shared<Group>(new_group);
    island2group[n+1] = ptr_new_group;
    groups.insert(ptr_new_group);
  }

  vector<uint64_t> conveniences = {0};

  for (int m=M-1; m>=0; m--) {
    auto bridge = bridges[m];
    int a = bridge.first, b = bridge.second;
    auto group_a = island2group[a];
    auto group_b = island2group[b];
    uint64_t convenience_prev = calc_convenience(*group_a) + calc_convenience(*group_b);
    if (group_a != group_b) {
      if (group_b->size() > group_a->size())
	swap(group_a,group_b);

      for (int island_b : *group_b) {
	group_a->insert(island_b);
	island2group[island_b] = group_a;
      }
      groups.erase(group_b);
      uint64_t convenience_now = calc_convenience(*group_a);
      conveniences.push_back(conveniences.back()+convenience_now-convenience_prev);
    } else {
      conveniences.push_back(conveniences.back());
    }
  }

  uint64_t final_convenience = conveniences.back();
  for (auto itr = conveniences.rbegin()+1; itr != conveniences.rend(); ++itr) {
    cout << final_convenience - *itr << endl;
  }
  
  return 0;
}


Measured memory_bytes: 28916
#include<stdio.h>

int main(void)
{
 char s[4];
 int d=700,i;

 scanf("%s", s);
 for(i=0;i<3;i++){
 if(s[i]=='o'){
   d+=100;
  }
 }
 printf("%d\n", d);
 return 0;
}


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

int main() {

    int64_t A , B , C , K ;
    cin >> A >> B >> C >> K ;

    if(A > K) cout << K << endl;

    else if(A+B>=K) cout << A << endl;

    else if (A+B < K) cout << A - (K-B-A) << endl;

}

Measured memory_bytes: 3620
N,A,B = map(int,input().split())
H = [int(input()) for _ in range(N)]

def calc(x):
  bomb = 0
  for h in H:
    if h > B*x:
      bomb += ((h-B*x)-1)//(A-B) +1
  return (x >= bomb)

def check(a,b):
  mid = (a+b)//2
  if a == mid:
    return b
  if calc(mid):
    return check(a,mid)
  else:
    return check(mid,b)

print(check(0,10**9))

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


int main(){
    string s,t;
    cin>>s;cin>>t;
    if(s.size()<t.size()) cout<<"LESS"<<endl;
    else if(s.size()>t.size()) cout<<"GREATER"<<endl;
    else{
        rep(i,(int)s.size()){
            if(s[i]>t[i]){
                cout<<"GREATER"<<endl;
                return 0;
            }else if(s[i]<t[i]){
                cout<<"LESS"<<endl;
                return 0;
            }
        }
        cout<<"EQUAL"<<endl;
        return 0;
    }
}

Measured memory_bytes: 3596
//
// Created by kash on 16/05/20.
//

#include <bits/stdc++.h>

using namespace std;
#define mod 1e9+7
#define ll long long
#define rev_rep(it, last, first) for(int it=last-1;it>=first;--it)
#define out(x) cout << x;
#define pln(x) cout << x << "\n";
#define debug(x) cout << "Debug: " << x << "\n";
#define in(x) cin >> x;
#define rep(it, start, end) for(int it=start;it<end;++it)
#define x first
#define y second


void set_io(int inp) {
#ifndef ONLINE_JUDGE
    string folder = string(getenv("HOME")) + "/CLionProjects/CompetitiveProgramming/inputs/";
    string input_file = folder + "input-" + to_string(inp) + ".txt";
    string output_file = folder + "output-" + to_string(inp) + ".txt";
    freopen(input_file.c_str(), "r", stdin);
    freopen(output_file.c_str(), "w", stdout);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);

}

long long int inp_dec() {
    string str;
    in(str);
    ll f = 0;
    int i = 0;

    while (i < str.size()) {
        if (str[i] == '.')
            break;
        f = f * 10 + str[i] - '0';
        i++;
    }
    i++;
    int tmp = 12;
    while (i < str.size()) {
        tmp--;
        f = f * 10 + str[i] - '0';
        i++;
    }
    while (tmp--)
        f *= 10;
    return f;
}

int main() {
    set_io(1);

    int n;
    in(n);

    int cnt[25][25] = {};
    long long sol = 0;
    rep(i, 0, n) {
        int f2 = 0, f5 = 0;
        ll val = inp_dec();
        while (val % 5 == 0) {
            f5++;
            val /= 5;
        }
        while (val % 2 == 0) {
            f2++;
            val /= 2;
        }
        f2 = min(24, f2);
        f5 = min(24, f5);

        int req2 = 24 - f2, req5 = 24 - f5;
        rep(j, req2, 25) {
            rep(k, req5, 25) {
                sol += cnt[j][k];
            }
        }
        cnt[f2][f5]++;
    }
    out(sol)

    return 0;
}


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

long long INF = 1LL<<60;


long long calc(vector<long long>& s, vector<long long>& t, long long x) {

  long long answer = INF;
  
  auto a_ = lower_bound(s.begin(), s.end(), x);
  
  for (int i = 0; i < 2; i++) {
    
    long long ax_ = *prev(a_);

    if (i == 1) {
      ax_ = *a_;
    }

    auto b_ = lower_bound(t.begin(), t.end(), ax_);

    long long bxl_ = *prev(b_);
    long long bxr_ = *b_;

    if (0 < ax_ && 0 < bxl_) {
      answer = min(answer, abs(ax_ - x) + abs(bxl_ - ax_));
    }

    if (0 < ax_ && 0 < bxr_) {
      answer = min(answer, abs(ax_ - x) + abs(bxr_ - ax_));
    }

  }

  return answer;

}


int main() {

  int A, B, Q;
  cin >> A >> B >> Q;

  vector<long long> s;
  s.push_back(0);
  for (int i = 1; i <= A; i++) {
    long long s_;
    cin >> s_;
    s.push_back(s_);
  }
  s.push_back(INF);

  vector<long long> t(B+2);
  t.push_back(0);
  for (int i = 1; i <= B; i++) {
    long long t_;
    cin >> t_;
    t.push_back(t_);
  }
  t.push_back(INF);

  vector<long long> x(Q);
  for (int i = 0; i < Q; i++) {
    cin >> x[i];
  }

  for (int i = 0; i < Q; i++) {

    long long answer = INF;

    answer = min(calc(s,t,x[i]), calc(t,s,x[i]));

    cout << answer << endl;

  }

}

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

using ll = long long int;
typedef long double ld;
typedef pair<ll,ll> pll;

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<ll ,null_type,less<ll >,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
//K-th smallest element(0-based)=> cout << k << "kth smallest: " << *A.find_by_order(k-1) << endl;
//NO OF ELEMENTS < X => cout << "No of elements less than " << X << " are " << A.order_of_key(X) << endl;

#define sz(v) (ll)v.size()
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define gcd(a,b) __gcd(a,b)
#define all(v) v.begin(),v.end()
vector<pair<pll,pll>> queries;
ll glob=0;
void evaluate(ll arr[])
{
	ll ans=0;
	for(auto it:queries)
		if(arr[it.f.s]-arr[it.f.f]==it.s.f)
			ans+=it.s.s;
	glob=max(ans,glob);
}
void recurse(ll cur,ll n,ll m,ll prev,ll arr[])
{
	if(cur==n)
	{
		for(ll i=prev;i<=m;i++)
		{
			arr[cur]=i;
			evaluate(arr);
		}
		return;
	}
	for(ll i=prev;i<=m;i++)
	{
		arr[cur]=i;
		recurse(cur+1,n,m,i,arr);
	}
	return;
}
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(NULL);
	ll n,m,q;
	cin>>n>>m>>q;
	pair<pll,pll> a;
	for(ll i=0;i<q;i++)
	{
		cin>>a.f.f>>a.f.s>>a.s.f>>a.s.s;
		queries.pb(a);
	}
	ll arr[n+1];
	for(ll i=0;i<=n;i++)arr[i]=0;
	recurse(1,n,m,1,arr);
	cout<<glob<<"\n";
	return 0;
}

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

int main(){
  int a, b;
  cin >> a >> b;
  double c;
  c = a/(double)b;

  cout << a/b << " ";
  cout << a%b << " ";
  printf("%.8lf\n", c);

 return 0;
}

Measured memory_bytes: 3248
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define vec vector
#define fi first
#define se second
#define eb emplace_back
#define ef emplace_front
#define pof pop_front()
#define pob pop_back()
#define Rep(i,n) for(li i=0,nn=(li)(n);i!=nn;++i)
#define Rep1(i,n) for(li i=1,nn=(li)(n)+1;i!=nn;++i)
#define Size(v) (li)(v.size())
#define SortA(v) sort(v.begin(),v.end())
#define SortD(v) sort(v.rbegin(),v.rend())
#define All(a) (a).begin(),(a).end()
#define Input(a) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii);}
#define Input2(a,b) for(li ii=0,nn=(li)(a.size());ii!=nn;++ii){cin>>(a).at(ii)>>(b).at(ii);}
#define mp make_pair
using li = int64_t;
using intl = int64_t;
using vi = vec<li>;
using vb = vec<bool>;
using vvi = vec<vi>;
using qi = deque<li>;
using pi = pair<li, li>;
using vpi = vec<pi>;
using si = set<li>;
using vsi = vec<si>;
using mii = map<li, li>;
using vmii = vec<mii>;
vec<li> dx = {0, 1, 0, -1, 1, 1, -1, -1};
vec<li> dy = {1, 0, -1, 0, 1, -1, 1, -1};
constexpr li INF = 9223372036854775807;

void Yes(li b) {
	if (b)cout << "Yes";
	else cout << "No";
}
void yes(li b) {
	if (b)cout << "yes";
	else cout << "no";
}

int main() {
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	cout.precision(16);

	li X;
	cin >>X;

	Yes(X>=30);
	


}

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

// #define int long long
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define SORT(v, n) sort(v, v + n);
#define REVERSE(v, n) reverse(v, v+n);
#define vsort(v) sort(v.begin(), v.end());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
#define PI (acos(-1))
#define FILL(v, n, x) fill(v, v + n, x);
#define sz(x) int(x.size())

using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vs = vector<string>;
using vpll = vector<pair<ll, ll>>;

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; }

const ll INF = 1e15;
const int MOD = 1e9+7;
const ll LINF = 1e18;

signed main()
{
  cin.tie( 0 ); ios::sync_with_stdio( false );
  ll n; cin>>n;
  ll ans=0;
  reps(i,n-1){
    ans+=i;
  }
  cout<<ans<<endl;
}

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

void solve(std::istream &in, std::ostream &out);

int main() {
#ifdef LOCAL
  freopen("../IO/d.in", "r", stdin);
//  freopen("../IO/d.out", "w", stdout);
#else
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
#endif
  solve(std::cin, std::cout);
  return 0;
}

vector<int> col[3];

int64_t go(vector<int> &a, vector<int> &b, vector<int> &c) {
  int64_t ans = 0;
  int csz = c.size();
  for (int i : a) {
    for (int j : b) {
      if (j < i) continue;
      auto it = upper_bound(c.begin(), c.end(), j);
      if (it == c.end()) continue;
      int remaining = csz - int(it - c.begin());
      it = lower_bound(c.begin(), c.end(), j + (j - i));
      if (it != c.end() && *it == j + j - i) {
        --remaining;
      }
      ans += max(0, remaining);
    }
  }
  return ans;
}

void solve(std::istream &in, std::ostream &out) {
  int n;
  in >> n;
  for (int i = 0; i < n; ++i) {
    char c;
    in >> c;
    if (c == 'R') col[0].push_back(i);
    else if (c == 'G') col[1].push_back(i);
    else col[2].push_back(i);
  }
  int p[3]={0,1,2};
  int64_t cnt = 0;
  do {
    cnt += go(col[p[0]],col[p[1]],col[p[2]]);
  } while (next_permutation(p, p + 3));
  out << cnt << '\n';
}



Measured memory_bytes: 3652
//g++ -std=c++14 test.cpp -o test.out
 
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
#include <vector>
#include <queue>
#include <map> 
#include <utility>
#include <limits.h>
#include <bitset>
#include <set>
using namespace std;
 
#define LL long long int
const LL INF = (1LL<<60);
const int INF_INT = 2147483647-1e6-1;
const LL mod = 1000000007ll;
const int mod_int = 1000000007;
 
LL N;
//点iと点j1,点j2,点j3...が隣接していて、
//かつそれぞれの移動コストがc1,c2,c3....である時
//adj[i] = {(c1,j1),(c2,j2),(c3,j3),.....}と決める
vector<vector<pair<LL,LL>>> adj;

LL Q,K;
LL x[100000],y[100000];
 
vector<LL> ans;
 
void solve(){
	//ダイクストラ　計算量は辺の数をE,頂点数をVとした時,O(ElogV)
	//pair<スタート地点からの最短距離,頂点番号>
	//pairのfirstが小さいものから取り出せる優先度付きキュー
	priority_queue<pair<LL,LL>,vector<pair<LL,LL>>,greater<pair<LL,LL>>> q;
	vector<LL> dist(N+1,INF);//スタート地点と点iの最小距離をdist[i]とおく
	dist[K] = 0;//点Kをスタート地点に決める
	q.push(pair<LL,LL>(0,K));

	while(!q.empty()){
		pair<LL,LL> now = q.top();q.pop();
		int now_v = now.second;
		if(dist[now_v]<now.first) continue;
		for(int i=0;i<adj[now_v].size();i++){
			LL next_v = adj[now_v][i].second;
			LL cost = adj[now_v][i].first;
			if(dist[next_v]>dist[now_v]+cost){
				dist[next_v] = dist[now_v] + cost;
				q.push(pair<LL,LL>(dist[next_v],next_v));
			}
		}
	}

	//この時点で、スタート地点(点K)と
	//点iの距離がdist[i]に保管されている
	for(int i=0;i<Q;i++){
		ans.push_back(dist[x[i]]+dist[y[i]]);
	}
}
 
int main(){
    cin >> N;
    adj = vector<vector<pair<LL,LL>>>(N+1);
    for(int i=0;i<N-1;i++){
    	LL a,b,c;cin >> a >> b >> c;
    	adj[a].push_back(pair<LL,LL>(c,b));
    	adj[b].push_back(pair<LL,LL>(c,a));
    }
    cin >> Q >> K;
    for(int i=0;i<Q;i++){
    	cin >> x[i] >> y[i];
    }
 
    solve();
 
    for(int i=0;i<Q;i++)cout << ans[i] << endl;
    return 0;
}

Measured memory_bytes: 13040
#include<iostream>
#include<numeric>
#include<algorithm>
using namespace std;
  
int main(){
  int N;
  cin>>N;
  int a[N];
  cin>>a[0];
  int ans=a[0];
  for(int i=1;i<N;i++){
    cin>>a[i];
    int x=max(a[i],ans);
    int y=min(a[i],ans);
    while(1){
      int z=x+y;
      x=max(x,y);
      y=z-x;
      x=x%y;
      if(x==0){
        ans=y;
        break;
      }
    }      
  }
  cout<<ans<<endl;
}


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

int main()
{
    int n;
    cin >> n;
    int a[1002][1002];
    for(int i = 0; i < n; i++){
        for(int j = 0; j < n - 1; j++){
            cin >> a[i][j];
            a[i][j]--;
        }
    }
    int times[1002] {0};
    int fight[1002] {0};
    vector<int> v[2];
    for(int i = 0; i < n; i++){
        if(a[a[i][0]][0] == i) v[0].push_back(i);
    }
    int c = 0;
    while(true){
        for(int x : v[c % 2]){
            int op = a[x][times[x]];
            if(fight[x] == 0 && fight[op] == 0 && a[op][times[op]] == x){
                fight[x] = 1;
                fight[op] = 1;
                times[x]++;
                times[op]++;
                if(times[x] < n - 1) v[(c + 1) % 2].push_back(x);
                if(times[op] < n - 1) v[(c + 1) % 2].push_back(op);
            }
        }
        v[c % 2].clear();
        for(int x : v[(c + 1) % 2]) fight[x] = 0;
        c++;
        if(v[c % 2].size() == 0) break;
    }
    for(int i = 0 ; i < n; i++){
        if(times[i] != n - 1){
            cout << -1 << endl;
            return 0;
        }
    }
    cout << c << endl;
}

Measured memory_bytes: 4224