akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <iomanip>
#include <map>
#include <set>
#include <tuple>
#include <unordered_map>
#include <iterator>
#include <string>
#include <limits>

using namespace std;

using i64 = int64_t;
using P = pair<i64, i64>;
i64 mod = 1000000007;
int int_max = 2147483647;
int max_n = 1e5;


int main(int argc, char **argv) {
    int n;
    cin >> n;

    std::vector<int> as(n+1,0);
    std::vector<int> sub(n+1, 0);
    for (int i=2; i<n+1; ++i) {
        cin >> as[i];
        ++sub[as[i]];
    }

    for (int i=1; i<n+1; ++i) {
        cout << sub[i] << endl;
    }

    return 0;
}

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

int main(){
    int H ,W,rs=0;
    cin  >> H >> W;

    vector<vector<char>> S(H,vector<char>(W));

    for(int i = 0;i < H;i++)
        for(int j = 0; j < W;j++)
            cin >> S.at(i).at(j);
    

    for(int i = 0;i < H;i++){
        for(int j = 0;j < W;j++){
            if(S.at(i).at(j) == '.'){
                    if(j < W-1){
                        if(S.at(i).at(j+1) == '#'){
                            rs++;
                        }
                    }
                    if(j > 0){
                        if(S.at(i).at(j-1) == '#')
                            rs++;
                    }
                    if(i < H-1){
                        if(S.at(i+1).at(j) == '#')
                            rs++;
                    }
                    if(i > 0){
                        if(S.at(i-1).at(j) == '#')
                            rs++;
                    }
                    if(i < H-1 && j < W-1){
                        if(S.at(i+1).at(j+1) == '#')
                            rs++;
                    }
                    if(i < H-1 && j >= 1){
                        if(S.at(i+1).at(j-1) == '#')
                            rs++;
                    }
                    if(i > 0 && j < W-1){
                        if(S.at(i-1).at(j+1) == '#')
                            rs++;
                    }
                    if(i > 0 && j > 0){
                        if(S.at(i-1).at(j-1) == '#')
                            rs++;
                    }
                    cout << rs;
                    rs = 0;
            }else{
                cout << '#';
            }
        }
        cout << endl;
    }
    

}

Measured memory_bytes: 256
import sys

def solve():
    input = sys.stdin.readline
    N = int(input())
    ans = {N}
    if N > 2: ans |= {N-1}
    for i in range(2, N): #N-1の約数ならばsubtractした後1になる。もしくはpow(k, x) == Nの場合
        if i ** 2 > N: break
        if (N - 1) % i == 0:
            ans |= {i}
            if i ** 2 < N - 1:
                ans |= {(N - 1) // i}
        if N % i == 0:
            k = N
            while k % i == 0:
                k //= i
            if k % i == 1: ans |= {i}
            if i ** 2 < N:
                k = N
                while k % i == 0:
                    k //= i
                if k % i == 1: ans |= {i}
    print(len(ans))
    #print(ans)


    return 0

if __name__ == "__main__":
    solve()

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

int D[5];

int main(){
    for (int i=1;i<=6;i++){
        int x;scanf("%d",&x);++D[x];
    }
    sort(&D[1],&D[5]);
    if (D[1]==1&&D[2]==1&&D[3]==2&&D[4]==2) puts("YES");
    else puts("NO");return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <float.h>
#include <random>

#define repeat(i,n) for (int i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge] << '\n'
#define debugArrayP(x,n) for(long long hoge = 0; (hoge) < (n); ++ (hoge)) cerr << #x << "[" << hoge << "]: " << x[hoge].first<< " " << x[hoge].second << '\n'

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = LLONG_MAX/10;
const ll MOD = 1e9+7;


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int M,K;cin>>M>>K;
  if(K>=(1<<M)||(M==1&&K==1)){
    cout<<-1<<endl;
    return 0;
  }
  if(K==0){
    repeat(i,(1<<M)){
      cout<<i<<" "<<i<<(i<(1<<M)-1? " ":"\n");
    }
    return 0;
  }
  repeat(i,(1<<M))if(i!=K){
    cout<<i<<" ";
  }
  cout<<K;
  for(int i=(1<<M)-1;i>=0;i--)if(i!=K){
    cout<<" "<<i;
  }
  cout<<" "<<K<<endl;
  return 0;
}


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

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

    int N;
    cin >> N;
    vector<int> A(N);
    for (int i = 0; i < N; i++) {
        cin >> A[i];
    }
    for (int i = 0; i < N; i++) {
        A.push_back(A[i] - 1);
        A.push_back(A[i] + 1);
    }
    sort(A.begin(), A.end());
    int ans = 0;
    int cnt = 0;
    int num = A[0];
    // for (auto& i : A) cout << i << endl;
    for (int i = 0; i < A.size(); i++) {
        if (A[i] == num)
            cnt++;
        else {
            ans = max(ans, cnt);
            cnt = 1;
            num = A[i];
        }
    }
    ans = max(ans, cnt);
    cout << ans << endl;
}

Measured memory_bytes: 1784
import math

n,k = map(int,input().split())
a = [int(i) for i in input().split()]

a.sort()
r = a[n-1]
l = 0


def calc(t,x):
    return math.ceil(t / x) - 1


while r - l > 1:
    mid = (r+l)//2
    count = 0
    for i in a:
        count += calc(i,mid)
    if count > k:
        l = mid
    else:
        r = mid

print(r)


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

int main() {
	int n,K;
	cin>>n>>K;
	vector<int> v(n);
	for(int i=0;i<n;i++)cin>>v[i];
	vector<int> dp(n,INT_MAX);
	dp[0]=0;
	for(int i=0;i<n;i++){
		for(int k=1;k<=K;k++){
		dp[i+k]=min(dp[i+k],dp[i]+abs(v[i]-v[i+k]));
	}
	}
	
	cout<<dp[n-1];
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
#define ll long long
using namespace std;
/*
    *
    * Prosen Ghosh
    * American International University - Bangladesh (AIUB)
    *
*/

/*int sum(int n){

      int sum=0;
      while(n!=0){
         sum=sum+n%10;
         n/=10;
      }
      int ans=0
      if((sum/10)==0){
         break;
      }
      else{
          ans=sum(sum(sum(n)));
      }
      return ans;
}*/
int main(){
        
       //char str[100000];
  /*  string str;
       int cnt=0,cnt2=0;
       cin>>str;
       //scanf("%s",&str);
       for(int i=0;i<str.length();i++){
            if(str[i]=='A' && str[i+1]=='C'){
                 cout<<"Yes"<<endl;
                 //break;
                 return 0;
            }
            
       }


       cout<<"No"<<endl;
       return 0;
       */

     ll x,a,b;
     cin>>x>>a>>b;
     ll sum=x-a;
     ll ans=sum%b;
     cout<<ans<<endl;

    return 0;
}

Measured memory_bytes: 3592
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
template<class T,class U> inline bool chmin(T&x,U y){if(x>y){x=y;return true;}return false;}
template<class T,class U> inline bool chmax(T&x,U y){if(x<y){x=y;return true;}return false;}
#define fr(i,n) for(int i=0;i<(n);++i)
#define Fr(i,n) for(int i=1;i<=(n);++i)
#define ifr(i,n) for(int i=(n)-1;i>=0;--i)
#define iFr(i,n) for(int i=(n);i>0;--i)

int main(){
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    string s,t;
    cin>>s>>t;
    int n=s.length(),m{};
    fr(i,n) if(s[i]!=t[i]) ++m;
    cout<<m<<'\n';
}

Measured memory_bytes: 3808
# Paper
class Paper
  def initialize(x, y)
    @x, @y, @grids = x, y, Array.new(x) { Array.new(y, 0) }
  end

  def dye(x, y, size)
    case size
    when 1
      dense(x, y)
      dense(x, y - 1)
      dense(x + 1, y)
      dense(x, y + 1)
      dense(x - 1, y)
    when 2
      dense(x, y)
      dense(x, y - 1)
      dense(x + 1, y - 1)
      dense(x + 1, y)
      dense(x + 1, y + 1)
      dense(x, y + 1)
      dense(x - 1, y + 1)
      dense(x - 1, y)
      dense(x - 1, y - 1)
    when 3
      dense(x, y)
      dense(x, y - 1)
      dense(x + 1, y - 1)
      dense(x + 1, y)
      dense(x + 1, y + 1)
      dense(x, y + 1)
      dense(x - 1, y + 1)
      dense(x - 1, y)
      dense(x - 1, y - 1)
      dense(x, y - 2)
      dense(x + 2, y)
      dense(x, y + 2)
      dense(x - 2, y)
    end
  end

  def graph
    @grids.transpose.each do |row|
      puts row.join(' ')
    end
  end

  def dense(x, y, density = 1)
    @grids[x][y] += density if exists?(x, y)
  end

  def exists?(x, y)
    0 <= x && x <= @x - 1 && 0 <= y && y <= @y - 1
  end

  def max_density
    max_density = 0
    @grids.each do |item|
      max_density = [max_density, item.max].max
    end
    max_density
  end

  def while_grids_sum
    while_grids_sum = 0
    @grids.each do |item|
      while_grids_sum += item.select { |x| x == 0 }.size
    end
    while_grids_sum
  end
end

paper = Paper.new(10, 10)

while line = gets
  x, y, size = line.chomp.split(',').map(&:to_i)
  paper.dye(x, y, size)
end

puts paper.while_grids_sum
puts paper.max_density

Measured memory_bytes: 8664
#pragma warning(disable:4996)
#include <bits/stdc++.h>

using namespace std;

//macro
#define FOR(i,a,b) for(ll i=(ll)(a);i<(ll)(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define EPS (1e-8)
#define equals(a,b)(fabs((a)-(b))<EPS)

using ll = long long;
using ull = unsigned long long;
using vb = vector<bool>;
using vi = vector<int>;
using vll = vector<ll>;
using vs = vector<string>;
using vvb = vector<vb>;
using vvi = vector<vi>;
using vvll = vector<vll>;
//func
template<typename A, typename T>void assign2d(A&arr, ll H, ll W, T t) { arr.resize(H); REP(i, H) arr[i].assign(W, t); }
template<class T> ostream &operator<<(ostream &os, const vector<T> &v) { int n = v.size(); REP(i, n)os << v[i] << (i == n - 1 ? "" : " "); return os; }
template <class T = int> inline T IN() { T x; cin >> x; return x; }
template<class T> inline void OUT(const T &x) { cout << x << "\n"; }
void YESNO(bool c) { OUT(c ? "YES" : "NO"); };
void YesNo(bool c) { OUT(c ? "Yes" : "No"); };
struct pre_ { pre_() { cin.tie(nullptr); ios::sync_with_stdio(false); /*cout << fixed << setprecision(6);*/ } } pre__;

int main() {
	int N, K;
	cin >> N >> K;
	vi L(N);
	REP(i, N) {
		cin >> L[i];
	}
	sort(ALL(L), greater<int>());
	int ans = 0;
	REP(i, K) {
		ans += L[i];
	}
	OUT(ans);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
int main(void) {
	int n,u,k,v;
	cin >> n;
	int m[100][100];
	for (int i = 0; i < n;i++) {
		for (int j = 0; j < n;j++) {
			m[i][j] = 0;
		}
	}
	for (int i = 0; i < n;i++) {
		cin >> u >> k;u--;
		for (int j = 0;j < k;j++) {
			cin >> v; v--;
			m[u][v] = 1;
		}
	}
	for (int i = 0; i < n;i++) {
		for (int j = 0;j < n;j++) {
			if (j)cout << " ";
			cout << m[i][j];
		}
		cout << endl;
	}
}


Measured memory_bytes: 3128
#include <iostream>
#include <cassert>
#include <climits>
#include <bitset>
#include <stack>
#include <queue>
#include <iomanip>
#include <limits>
#include <string>
#include <cmath>
#include <set>
#include <map>
#include <math.h>
#include <algorithm>
#include <vector>
#include <string.h>

using namespace std;
typedef long long ll;

typedef pair<ll,ll> P;
long long int INF = 1e18;
double Pi = 3.1415926535897932384626;
long long int mod = 1000000007;

vector<ll> G[500005];
vector<P> tree[500010];
priority_queue <ll> pql;
priority_queue <P> pqp;
//big priority queue
priority_queue <ll,vector<ll>,greater<ll> > pqls;
priority_queue <P,vector<P>,greater<P> > pqps;
//small priority queue
//top pop

int dx[8]={1,0,-1,0,1,1,-1,-1};
int dy[8]={0,1,0,-1,1,-1,-1,1};
char dir[] = "RULD";
//↓,→,↑,←

#define p(x) cout<<x<<endl;
#define el cout<<endl;
#define pe(x) cout<<x<<" ";
#define ps(x) cout<<fixed<<setprecision(25)<<x<<endl;
#define pu(x) cout<<x;
#define re(i,a,b) for(i=a;i<=b;i++);
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define deba(x) cout<< #x << " = " << x <<endl

ll rui(ll abc,ll bed){
    //abcのbed乗を計算する
    if(bed==0){return 1;}
    else{
        ll ced = rui(abc,bed/2);
        ced *= ced;
        ced %= mod;
        if(bed%2==1){ced*=abc; ced%=mod;}
        return ced;
    }
}

ll i,j,k,ii,jj;
ll n,m,num;
ll a,b,c,d,e,f,g,h,r;
ll vnum[500005],x[500005],y[500005],z[500005];
bool dame;
bool check[500005];
char s[500005],t[500005];

ll gcd(ll a,ll b){
	if(a>b)swap(a,b);
	if(a==b || a==0){
		return b;
	}else{
		return gcd(b%a,a);
	}
}



int main(){
    cin>>n>>m;
	cin>>s>>t;
    a = gcd(n,m);
	b = n * m / a;
	i = 0;
	j = 0;
	while(true){
		if(s[i] != t[j]){
			dame = true;
		}
		i += b / m;
		j += b / n;
		if(i >= n || j >= m){
			break;
		}
	}
	if(dame){
		p(-1);
	}else{
		p(b);
	}
    return 0;
}

Measured memory_bytes: 24576
using System;

class Program
{
 static void Main(string[] args)
 {
   string[] input = Console.ReadLine().Split(' ');
   
   long a = long.Parse(input[0]);
   long b = long.Parse(input[1]);
   long x = long.Parse(input[2]);
   long num1 = 0;
   long num2 = 0;
   long calc = 0;
   
   num1 = a / x;
   num2 = b / x;
   
   if( (a%x) == 0 )
   {
     calc = (num2 - num1) + 1;
   }
   else
   {
     calc = (num2 - num1);
   }
   
   Console.WriteLine(calc);
 }
}


Measured memory_bytes: 13140
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}


constexpr ll INF = 10000000000000000;

struct Edge {
  ll to;
  ll cost;
};

// dijkstra's法 O(|V|log|E|)
using P = pair<ll, ll>;
vector<ll> dijkstra(
  vector<vector<Edge>> const& graph,
  ll const s,
  ll const n
)
{
  vector<ll> d(n+1, INF);
  d[s] = 0;
  priority_queue<P, vector<P>, std::greater<P>> que;
  // (cost, vertex)
  que.push(make_pair(0, s));

  while (!que.empty()) {
    P e = que.top();
    que.pop();

    if (d[e.second] < e.first) continue;
    for (auto itr : graph[e.second]) {
      if (d[itr.to] > d[e.second] + itr.cost) {
        d[itr.to] = d[e.second] + itr.cost;
        que.push(P(d[itr.to], itr.to));
      }
    }
  }
  return d;
}
/*
int main() {
  int n, e;
  cin >> n >> e;
  vector<vector<Edge>> graph(n+1);

  for (int i = 0; i < e; ++i) {
    int to, from, cost;
    cin >> from >> to >> cost;
    graph[to].push_back({from, cost});
    graph[from].push_back({to, cost});
  }

  auto d = dijkstra(graph, 0, n);

  for (int i = 0; i < n; ++i) {
    cout << "shortest cost " << i << " " << d[i] << endl;
  }
}*/

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

  int N,M;
  cin >> N >> M;
  vector<vector<Edge>> G(N+1);
  repr(i, M, 0) {
    int a,b;
    cin >> a >> b;
    G[a].push_back({b, 1});
    G[b].push_back({a, 1});
  }

  auto d = dijkstra(G, 1, N);
  if (d[N] == 2) {
    cout << "POSSIBLE"<< endl;
  } else {
    cout << "IMPOSSIBLE"<< endl;
  }
}

Measured memory_bytes: 21736
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const int N = 200;

char s[N][N];
bool vis[N][N];
int dx[4]={0,0,1,-1};
int dy[4]={1,-1,0,0};

void dfs(int x,int y,char c){
	for(int i=0;i<4;i++){
		int tx=x+dx[i];
		int ty=y+dy[i];
		if(s[tx][ty]==c&&!vis[tx][ty]){
			vis[tx][ty]=true;
			dfs(tx,ty,c);
		}
	}
}


int main(){
	int m,n;
	while(scanf("%d%d",&n,&m) && m && n){
		int res=0;
		memset(s,0,sizeof(s));
		memset(vis,false,sizeof(vis));
		for(int i=1;i<=n;i++){
			scanf("%s",s[i]+1);
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=m;j++){
				if(vis[i][j]) continue;
				res++;
				vis[i][j]=true;
				dfs(i,j,s[i][j]);
			}
		}
		printf("%d\n",res);
	}
	return 0;
}


Measured memory_bytes: 3684
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
bool bo[100];
#define ll long long int
int main()
{
	ll a,b,x;
	cin>>a>>b>>x;
/*	ll c=0,q;
	for(ll i=a;i<=b;i++)
	{
		if(i%x==0)
		{
			q=i;
			break;
		}
	}
	//cout<<q<<endl;
	/*for(ll i=q;i<=b;i+=x)
	{
		c++;
	}*/
	if(a%x==0){
	cout<<b/x-a/x+1<<endl;
	}
	else
	{
		cout<<b/x-a/x<<endl;	
	}
}


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

int main() {
  int n, m;

  cin >> n;
  vector<string> s(n);
  for (int i = 0; i < n; i++) cin >> s[i];
  
  cin >> m;
  vector<string> t(m);
  for (int i = 0; i < m; i++) cin >> t[i];
  
  vector<int> results(n);
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) 
      if (s[i] == s[j]) results[i]++;
    
    for (int j = 0; j < m; j++) 
      if (s[i] == t[j]) results[i]--;
  }
  
  int rmax = 0;
  for (int i = 0; i < n; i++) rmax = max(rmax, results[i]);

  cout << rmax << endl;
}


Measured memory_bytes: 256
S = input()
T = input()

for i in range(len(S)):
    k = []
    for j in range(len(S)):
        if j == 0:
            k.append(S[-1])
            continue
        k.append(S[j - 1])
    S = k
    if "".join(S) == T:
        print("Yes")
        exit()
print("No")

Measured memory_bytes: 3060
#define _CRT_SECURE_NO_WARNINGS
//#define _USE_MATH_DEFINES
#include<stdio.h>
//#include<stdlib.h>
//#include<math.h>
//#include<string.h>
//#include<time.h>
//#define pi acos(-1.0)
#define P(type,x) fprintf(stdout,"%"#type"\n",x)
#define f(i,j) j<=i?i+1:i
int main() {
	int n, A[101],f,i,j;
	while (~fscanf(stdin, "%d",&n),n) {
		for (i = 0; i <= n; i++) fscanf(stdin, "%d", &A[i]);
		for (i = 0; i <= n; i++) {
			f = 1;
			for (j = 1; j < n; j++)
				if (A[f(1, i)] - A[f(0, i)] != A[f(j, i)] - A[f(j - 1, i)]) {
					f = 0;
					break;
				}
			if (f) {P(d, A[i]); break;}
		}
	}
	return 0;
}

Measured memory_bytes: 604
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace 演習4_1_2
{
    class Program
    {
        static void Main(string[] args)
        {
            var sentence = Console.ReadLine();

            var a = sentence.Length;

            var x = (a - 1) / 2;
            var y = (a + 3) / 2;

            var s1 = sentence.Substring(0, x);
            var s2 = sentence.Substring(y-1);
            
            if (s1 == s2)
            {
                Console.WriteLine("Yes");
            }
            else
            {
                Console.WriteLine("No");
            }
        }
    }
}


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


typedef long long ll;

vector<ll> divisor(ll n) { 
  vector<ll> ret;
  for (ll i = 1; (ll)i*i <= n; ++i) { 
    if (n % i == 0) {
      if (i != 1) ret.push_back(i);
      if (i*i != n) { if (n/i != 1) ret.push_back(n/i); }
    }
  }
  sort(ret.begin(), ret.end());
  return ret;
};

bool check(ll n, ll k) { 
  while (n % k == 0) { 
    n /= k;
  }
  if (n >= k) n = n%k;
  if (n == 1) return true;
  return false;
}

int main() {
  ll n; cin >> n;
  vector<ll> d1 = divisor(n);
  vector<ll> ans = divisor(n-1);
  for (ll d : d1) {
    if (check(n,d)) ans.push_back(d);
  }
  // sort(ans.begin(), ans.end());
  cout << ans.size() << endl;
  // for (ll d: ans) {
  //   cout << d << endl;
  // }
}


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

#define rep(i,m) for(int i = 0; i < m; i++)
using ll = long long;

int main(){
  ll n,k;
  cin>>n>>k;
  vector<pair<int,int>> ab(n);
  rep(i,n){
    ll a,b;
    cin>>a>>b;
    ab.at(i)=make_pair(a,b);
  }
  sort(ab.begin(),ab.end());
  rep(i,n){
    if(ab.at(i).second>=k){
      cout<<ab.at(i).first<<endl;
      return 0;
    }else k-=ab.at(i).second;
  }
  return 0;
}


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

using namespace std;

#define LIMIT 100
typedef pair<int64_t, int64_t> ii;

//  ***** MAIN *****
int main(){
  //ios::sync_with_stdio(false);
  cin.tie(NULL);

  string s;
  cin >> s;

  for (int i = 0; i < s.size()-1; ++i) {
    if (s[i] == s[i+1]){
      printf("%d %d\n", i+1, i+2);
      return 0;
    }

    if ( i<s.size()-2 && s[i] == s[i+2] ){
      printf("%d %d\n", i+1, i+3);
      return 0;
    }
  }

  printf("-1 -1\n");

  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
 
using namespace std;
 
int main(){
    int N;
  	cin >> N;
  int  d = N%10;
  if(d==2 || d==4 || d == 5 || d==7||d==9){
    cout << "hon";
  }
  else if(d==0 || d==1 || d==6||d==8){
    cout << "pon";
  }
  else if(d==3){
    cout << "bon";
  }
}


Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
struct edge {
    int to;     // 辺の行き先
    int weight; // 辺の重み
    edge(int t, int w) : to(t), weight(w) { }
};
using Graph = vector<vector<int>>;
using dou =long double;
string Yes="Yes";
string YES="YES";
string NO="NO";
string No="No";
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
#define rep(i, n)         for(int i = 0; i < (int)(n); i++)
#define brep(n)           for(int bit=0;bit<(1<<n);bit++)
#define erep(i,container) for (auto i : container)
#define irep(i, n)        for(int i = n-1; i >= (int)0; i--)
#define rrep(i,m,n) for(int i = m; i < (int)(n); i++)
#define reprep(i,j,h,w) rep(i,h)rep(j,w)
#define all(x) (x).begin(),(x).end()
#define aall(x,n) (x).begin(),(x).begin()+(n)
#define VEC(type,name,n) std::vector<type> name(n);rep(i,n)std::cin >> name[i];
#define pb push_back
#define pf push_front
#define lb lower_bound
#define ub upper_bound
#define res resize
#define as assign
#define fi first
#define se second
#define itn int
#define mp make_pair
#define sum(a) accumulate(all(a),0ll)
#define keta fixed<<setprecision
#define vvector(name,typ,m,n,a)vector<vector<typ> > name(m,vector<typ> (n,a))
#define vvvector(name,t,l,m,n,a) vector<vector<vector<t> > > name(l, vector<vector<t> >(m, vector<t>(n,a)));
#define vvvvector(name,t,k,l,m,n,a) vector<vector<vector<vector<t> > > > name(k,vector<vector<vector<t> > >(l, vector<vector<t> >(m, vector<t>(n,a)) ));
 
typedef long long ll;
const int INF = 2000000000;
const ll INF64 = 922337203685477580ll;
const int mod = 1000000007ll;
const ll  MOD = 1000000007LL;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int x,y,a,b,c;
    std::cin >> x>>y>>a>>b>>c;
    VEC(ll,p,a);
    VEC(ll,q,b);
    VEC(ll,r,c);
    sort(all(p),greater<ll>());
    sort(all(q),greater<ll>());
    sort(all(r),greater<ll>());
   // std::cout << 123 << std::endl;
    int aa=x-1,bb=y-1,cc=0;
    while((p[aa]<r[cc]||q[bb]<r[cc])&&cc<c){
        if((p[aa]<r[cc]&&q[bb]<r[cc])){
            if(p[aa]<q[bb]){
                p[aa]=r[cc];
                cc++;
                aa--;
                if(aa<0)aa++;
                continue;
            }
            else {
                q[bb]=r[cc];
                cc++;
                bb--;
                if(bb<0)bb++;
                continue;
            }
        }
        else if(p[aa]<r[cc]){
            p[aa]=r[cc];
                cc++;
                aa--;
                if(aa<0)aa++;
                continue;
        }
        else if(q[bb]<r[cc]){
            q[bb]=r[cc];
                cc++;
                bb--;
                if(bb<0)bb++;
                continue;
        }
        cc++;
        if(aa<0)aa++;
        if(bb<0)bb++;
    }
    ll ans=0;
    rep(i,x){
        ans+=p[i];
    }
    rep(i,y){
        ans+=q[i];
    }
    std::cout << ans << std::endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>
#include<algorithm>
using namespace std;
typedef long long ll;
int main(){
	ll n;
	cin >> n;
	vector<ll>x(n);

	for (ll i = 0; i < n; i++)	cin >> x[i];

	sort(x.begin(), x.end());
	
	cout << x[n / 2] - x[n / 2 - 1] << endl;
	return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i,m,n) for(int i=m; i<n; i++)
#define co(n) cout << n << endl
using namespace std;
int main(){
  long a, b, c=0, d=0, e, f, g, h, n;
  string s="NO";
  cin >> a >> b >> c;
  rep(i,1,b+1){
    if(a*i%b==c){
      s="YES";
      break;
    }
  }
  co(s);
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int main(){
	int k,t;
	cin>>k>>t;
	int cake[t];
	rep(i,t)cin>>cake[i];
	sort(cake,cake+t);
	int res=0;
	if((k+1)/2<cake[t-1])res=cake[t-1]-k/2;
	cout<<max(0,2*res-1)<<endl;
	return 0;
}

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

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

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

  vector<pair<int,int>> v;
  int n = N/2;
  for(int i = 0; i < 1 << n; i++){
    pair<int,int> res = {0,0}; //{cnt,sum}
    for(int j = 0; j < n; j++){
      if((i >> j) & 1){
        res.first++;
        res.second += a[j];
      }
    }
    v.push_back(res);
  }
  sort(v.begin(),v.end());

  int ans = 0;
  for(int i = 0; i < 1 << (N-n); i++){
    int cnt = 0,sum = 0;
    for(int j = 0; j < (N-n); j++){
      if((i >> j) & 1){
        cnt++;
        sum += a[n+j];
      }
    }
    auto left = lower_bound(v.begin(),v.end(),make_pair(K-cnt,L-sum));
    auto right = upper_bound(v.begin(),v.end(),make_pair(K-cnt,R-sum));
    ans += right - left;
  }
  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 19484
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author toshibablack
 */

#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstring>
#include <fstream>
#include <functional>
#include <iostream>
#include <iomanip>
#include <iterator>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <utility>
#include <vector>

#define ll long long int
#define FOR(i, a, b) for(int i=(a);i<(b);++i)
#define REP(i, n) for(int i=0;i<n;++i)
#define FOREACH(x, a) for(auto& (x) : (a))
#define ALL(a) (a).begin(),(a).end()
#define COUT(x) out << (x) << endl;
#define M0(x) memset(x,0,sizeof(x))
#define MINF(x) memset(x,0x3f,sizeof(x))
#define MMINUS(a) memset(a,0xff,sizeof(a))

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

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

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

int gcd(int a,int b){return b?gcd(b,a%b):a;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}

using namespace std;

class CRectangleCutting {
public:
    ll W, H, x, y;

    void solve(std::istream& in, std::ostream& out) {
        in >> W >> H >> x >> y;
        out << (double)W * (double)H / 2.0;
        out << " ";
        int ans = abs(W - 2*x) < 1.0 / INF && abs(H - 2*y) < 1.0 / INF ? 1 : 0;
        COUT(ans);
    }
};


int main() {
    CRectangleCutting solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}


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

int main() {
    ll s; cin >> s;
    ll ans = 0;
    int cnt=0;
    ll tmp = s;
    while(tmp!=0){
        tmp /= 10;
        cnt++;
    }

    for(int i=0; i<(1<<cnt-1); i++){
        ll s_tmp = s;
        ll ite = 0;
        for(int j=0; j<cnt-1; j++){
            if(1<<j & i){
                ans += s_tmp%(ll)pow(10,j+1-ite);
                s_tmp /= (ll)pow(10,j+1-ite);
                ite=j+1;                
            }
        }
        ans+=s_tmp;
    }

    cout << ans << endl;

}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<vector>
#include<queue>
#include<bitset>
#include<string>
#include<stack>
#include<set>
#include<unordered_set>
#include<map>
#include<unordered_map>
#include<cstring>
#include<complex>
#include<cmath>
#include<iomanip>
#include<numeric>
#include<algorithm>
#include<list>
#include<functional>
#include<cassert>
#define mp make_pair
#define pb push_back
#define X first
#define Y second
#define y0 y12
#define y1 y22
#define INF 1987654321
#define PI 3.141592653589793238462643383279502884
#define fup(i,a,b,c) for(int (i)=(a);(i)<=(b);(i)+=(c))
#define fdn(i,a,b,c) for(int (i)=(a);(i)>=(b);(i)-=(c))
#define MEM0(a) memset((a),0,sizeof(a));
#define MEM_1(a) memset((a),-1,sizeof(a));
#define ALL(a) a.begin(),a.end()
#define SYNC ios_base::sync_with_stdio(false);cin.tie(0)
using namespace std;
typedef long long ll;
typedef long double ld;
typedef double db;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<int, int> Pi;
typedef pair<ll, ll> Pll;
typedef pair<double, double> Pd;
typedef vector<int> Vi;
typedef vector<ll> Vll;
typedef vector<double> Vd;
typedef vector<Pi> VPi;
typedef vector<Pll> VPll;
typedef vector<Pd> VPd;
typedef tuple<int, int, int> iii;
typedef tuple<ll, ll, ll> LLL;
typedef vector<iii> Viii;
typedef vector<LLL> VLLL;
typedef complex<double> base;
const ll MOD = 998244353;
ll POW(ll a, ll b, ll MMM = MOD) {ll ret=1; for(;b;b>>=1,a=(a*a)%MMM)if(b&1)ret=(ret*a)% MMM; return ret; }
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { if (a == 0 || b == 0)return a + b; return a*(b / gcd(a, b)); }
int dx[] = { 0,1,0,-1,1,1,-1,-1 }, dy[] = { 1,0,-1,0,1,-1,1,-1 };

char s[5]="RGBY";
int main() {
	int n,m,d;
	scanf("%d%d%d",&n,&m,&d);
    fup(i,0,n-1,1)
	{
        fup(j,0,m-1,1)
		{
            int c = ((i+j)%(2*d))/d*2 + ((i-j+m)%(2*d))/d;
            printf("%c",s[c]);
        }
       puts("");
    }
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
using VS = vector<string>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "-----------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause")
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10;
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T>inline istream& operator>>(istream& is, deque<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    ll n; cin >> n;
    cout << n * (n - 1) / 2 << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;typedef long long ll;typedef vector<ll> vl;typedef vector<vl> vvl;typedef pair<ll,ll> pl;typedef vector<pl> vp;const ll INF=1001001001;const ll LINF=1001001001001001001;const ll D4[]={0,1,0,-1,0};const ll D8[]={0,1,1,0,-1,-1,1,-1,0};template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
#define fore(i,a,b) for(ll i=(ll)(a);i<=(ll)(b);++i)
#define rep(i,n) fore(i,0,(n)-1)
#define all(x) (x).begin(),(x).end()

void solve(){
    ll h,w,k;cin>>h>>w>>k;
    vector<string> s(h);
    rep(i,h)cin>>s[i];

    ll ans=INF;
    rep(i,1<<(h-1)){
        vl to(h);
        ll id=0;
        rep(j,h){
            to[j]=id;
            if(!(i>>j&1))id++;
        }
        vl sum(id);
        ll tmp=id-1;
        bool ng=0;
        rep(j,w){
            vl cnt(id);
            rep(l,h)if(s[l][j]=='1')cnt[to[l]]++;
            rep(l,id)if(cnt[l]>k)ng=1;
            if(ng)break;
            bool ov=0;
            rep(l,id)if(sum[l]+cnt[l]>k)ov=1;
            if(ov){
                tmp++;
                rep(l,id)sum[l]=cnt[l];
            }else{
                rep(l,id)sum[l]+=cnt[l];
            }
        }
        if(ng)continue;
        chmin(ans,tmp);
    }
    cout<<ans<<endl;
}

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


Measured memory_bytes: 256
s = list(input())
q = set(list(s))
alpha = set([chr(i+ord('a')) for i in range(26)])
if alpha - q:
    use = alpha - q
    use = list(use)
    use.sort()
    print("".join(s) + use[0])
    exit()
for i in range(len(s)-1,-1,-1):
    asc = ord(s[i])
    q = set(s[:i+1])
    for j in range(asc,ord('z')+1):
        if chr(j) not in q:
            s[i] = chr(j)
            print("".join(s[:i+1]))
            exit()
print(-1)


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

#define Fast ios_base::sync_with_stdio(0);cin.tie(0),cout.tie(0)
#define FO freopen("in.txt", "r", stdin)
#define FC freopen("out.txt", "w", stdout)
#define aise cout<<"aise"<<endl
#define pb push_back
#define mp make_pair
#define ll long long
#define mset(v, a) memset(v, a, sizeof(v))
#define pll pair< ll, ll >
#define pdd pair< double, double >
#define ff first
#define ss second
#define pi acos(-1.0)
#define mxN 100010
#define inf 1e9

double dis(pdd a, pdd b)
{

    double x = sqrt((a.ff-b.ff)*(a.ff-b.ff)+(a.ss-b.ss)*(a.ss-b.ss));
    return x;
}

double fact(ll x)
{

    ll ans = 1;
    for(ll i = 1; i <= x; i++) ans*=i;
    return double(ans);
}

int main()
{

    ll n;
    cin >> n;
    vector<ll> v;
    for(ll i = 0 ; i < n; i++) v.pb(i);
    vector<pdd> vg;
    for(ll i = 0; i < n; i++)
    {

        double x, y;
        cin >> x >> y;
        vg.pb(mp(x,y));
    }
    double ans=0.0;
    do
    {

        for(ll i = 0; i < v.size()-1; i++)
        {

            ll id1= v[i], id2= v[i+1];
            ans+=dis(vg[id1], vg[id2]);
        }
    }while(next_permutation(v.begin(),v.end()));
    printf("%.10lf\n", double(ans/fact(n)));
}


Measured memory_bytes: 256
import itertools

s = input()
l = len(s)
ans = int(s)
for i in range(1, l):
    x = list(itertools.combinations(list(range(1, l)), i))
    for xi in x:
        p = 0
        for q in xi:
            ans += int(s[p:q])
            p = q
        ans += int(s[q:])
print(ans)


Measured memory_bytes: 3060
import sys
sys.setrecursionlimit(10 ** 6)
input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

def printlist(lst, k='\n'): print(k.join(list(map(str, lst))))
INF = float('inf')
from collections import deque
def solve():
    n, q = MI()
    e = [[] for _ in range(n)]
    for _ in range(n - 1):
        a, b = MI1()
        e[a].append(b)
        e[b].append(a)

    point = [0] * n
    for _ in range(q):
        p, x = MI()
        p -= 1
        point[p] += x

    d = deque([(0, point[0])])
    used = [0] * n
    used[0] = 1

    l = 1
    while l > 0:
        v, p = d.popleft()
        l -= 1
        for nv in e[v]:
            if used[nv]: continue
            used[nv] = 1
            point[nv] += p
            d.append((nv, point[nv]))
            l += 1

    printlist(point, " ")

if __name__ == '__main__':
    solve()


Measured memory_bytes: 67284
#include <stdio.h>

double solve(double q, double x) {
	if(fabs(x*x*x-q) < 0.00001*q) {
		return x;
	}
	
	return solve(q, x-(x*x*x-q)/(3*x*x));
}

int main(void) {
	int q;
	while(scanf("%d\n", &q) == 1) {
		if(q == -1) break;
		
		printf("%.6lf\n", solve((double)q, (double)q/2.0));
	}
	return 0;
}

Measured memory_bytes: 640
#include<iostream>
#include<string.h>
#include<queue>
#include<map>
#include<vector>
#include <cstdlib>
#include<algorithm>
#include <cstdio>
#include <cctype>
using namespace std;
const long long INF=10000000000000LL;
typedef long long ll;
typedef pair<ll,ll> P;
ll N,Ma,Mb,K=0,C[45];
ll A,B[100005]={};
ll T,a,b,c,d;
ll ans=0;
bool h,o;
//bool D[100005];
string str,str2[55][55];
map<string,int> m;
vector<int> v[10];
ll dp[45][405][405];
int main(){
	cin>>a>>b>>c>>d;
	cout<<max(a*b,c*d)<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <iomanip>
using namespace std;
typedef long long int ll;

ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define drep(i, n) for(int i = n - 1; i >= 0; i--)

const int INF = 1001001001;
const ll LINF = 1001002003004005006ll;

int main() {
  string s;
  cin >> s;
  if (s[2] == s[3] && s[4] == s[5]) Yes;
  else No;
  return 0;
}

Measured memory_bytes: 256
#include <cstdlib>
#include <cstdio>
#include <array>
#include <algorithm>

using namespace std;

int main()
{
  std::array<int, 3> a;
  scanf("%d %d %d", a.data(), a.data() + 1, a.data() + 2);
  std::sort(a.begin(), a.end());
  
  puts( a[0] == a[1] && a[1] == 5 && a[2] == 7 ? "YES" : "NO");
  return 0;
}




Measured memory_bytes: 128
#include<bits/stdc++.h>
#define eps 0.000000001
using namespace std;
typedef long double ld;
typedef pair<int,int> p;
typedef pair<ld,p> P;

int n;
ld px[200],py[200],pz[200],vx[200],vy[200],vz[200],r[200],vr[200];

ld getlen(int a,int b,ld M){
  ld ax=px[a]+vx[a]*M,ay=py[a]+vy[a]*M,az=pz[a]+vz[a]*M,ar=r[a]-vr[a]*M;
  ld bx=px[b]+vx[b]*M,by=py[b]+vy[b]*M,bz=pz[b]+vz[b]*M,br=r[b]-vr[b]*M;
  ld dx=ax-bx,dy=ay-by,dz=az-bz;
  return sqrt(dx*dx+dy*dy+dz*dz)-(ar+br);
}

ld check(int a,int b){
  ld L=0,R=100,M;
  int s=0;
  while(s++<50){
    M=(L+R)/2;
    ld len=getlen(a,b,M),len1=getlen(a,b,M+eps);
    if(len<len1||len<0)R=M;
    else L=M;
  }
  if(getlen(a,b,R)>0)return 1000;
  return R;
}

int main(){
  while(cin>>n,n){
    for(int i=0;i<n;i++)
      cin>>px[i]>>py[i]>>pz[i]>>vx[i]>>vy[i]>>vz[i]>>r[i]>>vr[i];
    priority_queue<P,vector<P>,greater<P> > q;
    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++)
	q.push(P(check(i,j),p(i,j)));
      q.push(P(r[i]/vr[i],p(i,i)));
    }
    ld used[200]={};
    while(!q.empty()){
      ld t=q.top().first;
      int a=q.top().second.first,b=q.top().second.second;
      q.pop();
      if(used[a]||used[b])continue;
      used[a]=used[b]=t;
    }
    for(int i=0;i<n;i++)printf("%.10Lf\n",used[i]);
  }
  return 0;
}

Measured memory_bytes: 4504
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
 
namespace ABC118A
{
    class Program
    {
        static void Main(string[] args)
        {
 
 
                    var word = Console.ReadLine().Split();
                    int a = int.Parse(word[0]);
                    int b = int.Parse(word[1]);
                    int max = 0;
 
            if (b % a == 0)
            {
                max = a + b;
               
 
            }
            else
                max = b - a;
                    Console.WriteLine(max);
                    Console.ReadKey();
 
 
 
                }
            }
        }
 

Measured memory_bytes: 13140
x, y = map(int, input().split())

a = [1, 3, 5, 7, 8, 10, 12]
b = [4, 6, 9, 11]
c = [2]

if any(x == i for i in a) and any(y == i for i in a):
       print('Yes')
elif any(x == i for i in b) and any(y == i for i in b):
       print('Yes')
elif any(x == i for i in c) and any(y == i for i in c):
       print('Yes')
else:  print('No')

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
using namespace std;
ll a,b,c;
int main()
{
	scanf("%lld%lld%lld",&a,&b,&c);
	if(b>=a)puts("1");
    else if(c>=b)puts("-1");
    else cout<<((a-b)/(b-c)+((a-b)%(b-c)>=1))*2+1<<endl;
    return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 1000000000 + 7;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n, m;
int dp[155][80][1005];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    while (true) {
        cin >> n >> m;
        if (n == 0 && m == 0) break;
        vector<vector<pair<int, int>>> st(155);
        rep(i, n) {
            int k;
            cin >> k;
            rep(j, k) {
                int x, d;
                cin >> x >> d;
                x--;
                st[i].push_back({x, d});
            }
        }
        rep(i, 155)rep(j, 80)rep(k, 1005) dp[i][j][k] = INT_MAX;
        for (auto p : st[0]) {
            dp[0][0][p.fi] = 0;
        }
        if (m != 0) {
            for (auto p : st[1]) {
                dp[1][1][p.fi] = 0;
            }
        }
        rep(i, n)rep(j, m + 1) {
            for (auto now : st[i]) {
                if (dp[i][j][now.fi] == INT_MAX) continue;
                if (i + 1 >= n) continue;
                for (auto nx : st[i + 1]) {
                    dp[i + 1][j][nx.fi] = min(dp[i + 1][j][nx.fi], dp[i][j][now.fi] + abs(now.fi - nx.fi) * (now.se + nx.se));
                }
                if (i + 2 >= n || j + 1 > m) continue;
                for (auto nx : st[i + 2]) {
                    dp[i + 2][j + 1][nx.fi] = min(dp[i + 2][j + 1][nx.fi], dp[i][j][now.fi] + abs(now.fi - nx.fi) * (now.se  + nx.se));
                }
            }
        }
        int ans = INT_MAX   ;
        rep(j, m + 1)rep(k, 1001) ans = min(ans, dp[n - 1][j][k]);
        rep(j, m)rep(k, 1001) ans = min(ans, dp[n - 2][j][k]);
        cout << ans << endl;
    }
}

Measured memory_bytes: 51812
#include<bits/stdc++.h>
using namespace std;
long long int dp[200005][3];
long long int mx=99001090900;
int main(){
  int n;
  cin>>n;
  dp[0][0]=0;dp[0][1]=0;dp[0][2]=0;
  for(int i=1;i<=n;i++){
    cin>>dp[i][0];
    cin>>dp[i][1];
    cin>>dp[i][2];
  }
  for(int i=1;i<=n;i++){
    for(int k=0;k<3;k++){
      long long int maxim=dp[i][k];
      for(int j=0;j<3;j++){
      	if(j==k)continue;
        maxim=max(maxim,dp[i][k]+dp[i-1][j]);
      }
      dp[i][k]=maxim;
    }
  }
  long long int maxim=max(dp[n][0],max(dp[n][1],dp[n][2]));
  cout<<maxim;
  return 0; 
}

Measured memory_bytes: 4352
import sys
import numpy as np
input = sys.stdin.readline

def main():
    N, M = map(int, input().split())
    INF = int(1e10)
    dp = [INF] * (1 << N)
    dp[0] = 0
    bits = set()
    bits.add(0)
    for i in range(M):
        a, b = map(int, input().split())
        c = list(map(int, input().split()))
        # cを状態keyに変換
        key = 0
        for t in c:
            key += 1 << (t - 1)
        # bits内のbitとkeyのORを更新
        # 更新したbitはbitsに追加
        add_bits = set()
        for bit in bits:
            tmp = bit | key
            if dp[bit] + a < dp[tmp]:
                dp[tmp] = dp[bit] + a
                add_bits.add(tmp)
        bits |= add_bits
    
    if dp[(1 << N) - 1] == INF:
        print(-1)
    else:
        print(dp[(1 << N) - 1])

if __name__ == "__main__":
    main()

Measured memory_bytes: 12980
#include <iostream>
#include <vector>
#include <set>
#include <cmath>
#include <algorithm>
#include <string>
#include <utility>
#include <map> 
#include <queue>
#include <stack>
#include <iomanip>
#include <sstream>
#define MP make_pair
#define PB push_back
#define S size()
#define B begin()
#define E end()
#define ll long long
#define REP(i,a,n) for(ll i=a; i<n; ++i)
#define RED(i,n,a) for(ll i=n; i>=a; --i)
#define m9 1000000007
#define endl "\n"
#define F first
#define SE second
#define ld long double



using namespace std;

ll gcd(ll a, ll b){
    if(a%b==0){
        return b;
    }
    else{
        return gcd(b, a%b);
    }
}
ld area(ld x1, ld y1, ld x2, ld y2, ld x3, ld y3){
    return abs(x1*(y2-y3)+x2*(y3-y1)+x3*(y1-y2))/2;
}
struct cmp{
    bool operator()(const pair<ll,ll> &a, const pair <ll,ll> &b)const{
        ll lena=a.SE-a.F+1, lenb=b.SE-b.F+1;
        if(lena==lenb){
            return a.F<b.F;
        }
        return lena>lenb;
    }
};


int main(){
    //freopen("input.txt", "r", stdin); 
    //freopen("output.txt", "w", stdout);
   ios_base::sync_with_stdio(false);
    cin.tie(NULL);
  ll n;
  cin>>n;
  vector <ll> v(n);
  REP(i,0,n){
      cin>>v[i];
  }
  ll dp[n];
  REP(i,0,n){
      dp[i]=0;
  }
  dp[1]=abs(v[1]-v[0]);
  REP(i,2,n){
      dp[i]=min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout<<dp[n-1];
   
}


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

class Program
{
    static void Main(string[] args)
    {
        int[] NL = ReadLineParseIntArray();
        int N = NL[0];
        int L = NL[1];
        int sum = Enumerable.Range(L, N).Sum();
        int min = int.MaxValue;
        foreach(int i in Enumerable.Range(L, N))
        {
            if (Abs(i) < Abs(min))
                min = i;
        }
        WriteLine(sum - min);
    }
      static int[] ReadLineParseIntArray() => ReadLine().Split(' ').Select(int.Parse).ToArray();
}

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

using namespace std;


unsigned long long L[100];
int main()
{
  L[0] = 2;
  L[1] = 1;
  int n;
  cin >> n;
  for (int i = 2;i <= 86; i++) L[i] = L[i-1] + L[i-2];
  cout << L[n] << "\n";
}


Measured memory_bytes: 256