akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
int INF = 1e9;
int MOD = 1e9+7;
main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(b < c || (a > d && b > c)){
        cout << 0 << endl;
    }else{
        cout << min(b,d) - max(a,c) << endl;
    }
}

Measured memory_bytes: 256
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <fstream>
#include <set>
#include <utility>
#include <algorithm>
#include <queue>
#include <stack>
#include <deque>
#include <numeric>
#include <sstream>
#include <list>
#include <map>
#include <functional>
#include <iterator>

#define rep(i,p,n) for(int i=(int)p;i<(int)n;i++)
#define repp(i,p,n) for(int i=(int)p;i>=(int)n;i--)
#define Sort(x) sort(x.begin(),x.end())
#define PSort(x) sort(begin(x), end(x), pairCompare)
#define ll long long
#define INF 2000000000
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define PI 3.14159265358979
int dx[4] = { -1,0,1,0 }, dy[4] = { 0,1,0,-1 };
using namespace std;

int main(){	
	while (1) {
		int a, d, n,x;
		cin >> a >> d >> n;
		if (a == 0 && a == d&&d == n)break;

		int count = 0;
		for (int i = 0; count != n; i++) {
			x = a + d * i;
			bool f = true;
			if (x < 2)continue;
			else if (x == 2) {
				count++;
				continue;
			}
			else {
				if (x % 2 == 1) {
					for (int j = 3; j <= sqrt(x); j += 2) {
						if (x%j == 0) {
							f = false;
							break;
						}
					}
				}
				else f = false;
			}
			if (f)count++;
		}
		cout << x << endl;
	}

	return 0;
}

Measured memory_bytes: 3004
# coding: utf-8
# Your code here!

n = int(input())
a,b = [int(i) for i in input().split()]
p = [int(i) for i in input().split()]

k=[0,0,0]
for i in p:
    if i <= a:
        k[0]+=1
    elif i <= b:
        k[1]+=1
    else:
        k[2]+=1

print(min(k))

    

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

int main(){
  int N;
  cin >> N;
  string ans = "No";
  
  for(int i = 0; i <= 100; i++){
    for(int j = 0; j <= 100; j++){
      if(N== 4*i + 7*j){
        ans = "Yes";
        break;
      }
    }
  }

  cout << ans << '\n';

  return 0;
}

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

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

int main() {
  long long int n,X;
  cin>>n>>X;
  long long int x[n+1],i;
  for(i=0;i<n;i++)
    cin>>x[i];
  x[n]=X;
  sort(x,x+n+1);
  
  long long int ans=x[0]-x[1];
  
  for(i=0;i<n;i++){
    ans=gcd(ans,x[i+1]-x[i]);
    
  }
  cout<<ans;
       
    
}

Measured memory_bytes: 1024
#include <cstdio>
#include <algorithm>
#pragma warning(disable : 4996)
int n, lp[109], rp[109], l[109], r[109];
int gcd(int x, int y) {
	if (y == 0) return x;
	return gcd(y, x % y);
}
int solve(int pos) {
	if (pos == -1) return 1;
	int lret = solve(l[pos]) * lp[pos];
	int rret = solve(r[pos]) * rp[pos];
	int p = lret / gcd(lret, rret) * rret;
	return p / lp[pos] + p / rp[pos];
}
int main() {
	while (scanf("%d", &n), n) {
		for (int i = 0; i < n; i++) scanf("%d%d%d%d", &lp[i], &rp[i], &l[i], &r[i]), l[i]--, r[i]--;
		int ret = 0;
		for (int i = 0; i < n; i++) ret = std::max(ret, solve(i));
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2552
# input
N = int(input())

# n = a * b + b
#   = b * (a + 1)
# b < a < sqrt(n)

import math
# square cut
sqnc = int(math.sqrt(N))

print(sum(N // b - 1 for b in range(1, sqnc+1) if N % b == 0 and b < N // b -1))


Measured memory_bytes: 2940
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<cmath>
using namespace std;
int n,b;
double d,p[10],h[10];
main()
{
	cin>>d>>n>>b;
	for(int i=0;i<n;i++)cin>>p[i]>>h[i];
	double ans=1e300;
	for(int i=0;i<=b;i++)
	{
		double c=d/2/(i+1);
		double L=1e-15,R=1e15;
		for(int cnt=0;cnt<100;cnt++)
		{
			double M=(L+R)/2;
			bool flag=1;
			for(int j=0;j<n;j++)
			{
				double now=p[j];
				while(now>=c*2)now-=c*2;
				if(M*M*now/c-M*M*now*now/c/c/2<h[j])
				{
					flag=0;
					break;
				}
			}
			(flag?R:L)=M;
		}
		double vy=max(R,sqrt(c));
		ans=min(ans,hypot(c/vy,vy));
	}
	cout<<fixed<<setprecision(9)<<ans<<endl;
}


Measured memory_bytes: 3348
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef pair<string , int> s_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep1(i,n) for(int i=1;i<(int)(n);i++)
#define rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define puf push_front
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
//#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
typedef long long int64;
const int64 INF = 1LL << 58;
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 (a>b) { a=b; return 1; } return 0; }
template<typename T> void remove(T & vector, unsigned int index){vector.erase(vector.begin() + index);}

#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
 
vei to[200005];
vei ans;
void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
}
 
int main() {
  int n, q;
  cin >> n >> q;
  rep(i,n-1) {
    int a, b;
    cin >> a >> b;
    a--;  b--;
    to[a].pub(b);
    to[b].pub(a);
  }
  ans.resize(n);
  rep(i,q) {
    int p, x;
    cin >> p >> x;
    p--;
    ans[p] += x;
  }
  dfs(0);
  rep(i,n) {
    cout << ans[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 23424
#include<iostream> 
#include<vector> 
#include<algorithm> 
#include<iomanip> 
#include<stack> 
#include<unordered_map>
#include<queue> 
#include<map> 
#include<climits>
#include<set> 
#include<string> 
//#include<time.h>
//#include<bits/stdc++.h> 
using namespace std; 
#define lld long long int 
#define eb emplace_back
//to insert pair use eb
#define mp make_pair
#define fi first
#define se second
#define pb push_back

#define X 1000000007
#define Y 998244353
#define E4 10000
#define E5 100000
#define E6 1000000
#define inf 1001001001
#define longinf 2001001001001001001
#define pi 3.1415926535

# define rec2(i,a,b) for(lld i=a;i<b;i++) 
#define rec(i,n) for(lld i=0;i<n;i++)
#define rev(i,a,b) for(lld i=b-1;i>=a;i--)
#define all(v) (v).begin(), (v).end()
#define large(v)  *max_element(all(v))
#define small(v)  *min_element(all(v)) 
#define v vector
const double EPS = 1e-6;

void google(int i)
{  cout<<"Case #"<<i<<":"; }

//prime sieve if needed 
//prime factors of number
lld prime[E6+1]; 
void sieve(lld n) 
{ rec(i,n+1) 
    prime[i]=1; 
   for(lld i=2;i*i<=n;i++) 
     { if(prime[i]!=1) 
          continue; 
         for(lld j=i*i;j<=n;j=j+i) 
          if(prime[i]==1)
           prime[j]=i; 
      }
}

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

//fermat a^(m-2)%mod
lld binarymul(lld a,lld n,lld m)
{  lld res=1; 
 while(n) 
  { if(n%2) 
      { res=(res*a)%m; 
         n--; 
      } 
     a=(a*a)%m; 
     n/=2; 
  }
  return res; 
}
/*
void complexity(time_t end,time_t start)
{ 
  double taken = double(end - start); 
    cout<<"Time : "; 
    cout<<fixed<<taken<<setprecision(8);         cout<<" sec "<<endl;
}
*/
void contest(); 
int main()
{   
    /*
    time_t start, end; 
    time(&start); 
    */
   ios_base::sync_with_stdio(false); 
   cin.tie(0);
     #ifdef PUNEET_GOEL
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    #endif
   //sieve(E6); 
    lld t=1; 


    rec(i,t) 
    {
     //google(i+1); 
      contest(); 
      cout<<endl; 
    }
    /*
     time(&end); 
    complexity(end,start);
    */
	return 0;
}

void contest()
{ 
  string n; 
  cin>>n; 
  lld s=0; 
  rec(i,n.length())
   s+=(n[i]-'0'); 
  
  if(s%9==0) 
  cout<<"Yes"; 
  else 
  cout<<"No"; 
  
}

Measured memory_bytes: 3712
parseInt(x)=parse(Int,x)
parseMap(x::Array{SubString{String},1})=map(parseInt,x)


function main()
	n,k = readline() |> split |> parseMap
	a = readline() |> split |> parseMap
	m = gcd(a)
	x = maximum(a)
	if k%m == 0 && k <= x
		println("POSSIBLE")
	else
		println("IMPOSSIBLE")
	end
end
 
main()

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


typedef long long ll;


bool f(const vector<ll>& A, ll bar, ll K) {
	ll cut = 0;
	for (int i = 0; i < A.size(); ++i) {
		ll k = A[i] / bar - 1;
		if (A[i] % bar) ++k;
		cut += k;
		if (cut > K) break;
	}
	return cut <= K;
}


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

	vector<ll> A(N);
	for (int i = 0; i < N; ++i) cin >> A[i];

	ll m = 1e10, M = 0;
	for (int i = 0; i < N; ++i) {
		if (A[i] <= m) m = A[i];
		if (A[i] >= M) M = A[i];
	}

	if (!K) {
		cout << M << endl;
		return 0;
	}


	ll a = 1, b = M;
	while (a != b) {
		if (b - a == 1) {
			if (f(A, a, K)) b = a;
			else a = b;
			break;
		}

		ll cut = 0;
		ll c = (a + b) / 2;
		if (f(A, c, K)) b = c;
		else a = c;
	}

	cout << a << endl;

	return 0;
}


Measured memory_bytes: 4460
#![allow(unused_mut)]
#![allow(non_snake_case)]
#![allow(unused_variables)]
#![allow(unused_imports)]
#![allow(dead_code)]
use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        W: f64,
        H: f64,
        x: f64,
        y: f64,
    }

    println!("{} {}", W * H / 2.0, (2.0 * x == W && 2.0 * y == H) as u8);
}



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

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            for (;;)
            {
                int a, b;
                char op;
                string[] str = Console.ReadLine().Split(' ');
                a = int.Parse(str[0]);
                op = char.Parse(str[1]);
                b = int.Parse(str[2]);
                if (op == '+')
                {
                    Console.WriteLine("{0}", a + b);
                }

                else if (op == '-')
                {
                    Console.WriteLine("{0}", a - b);
                }

                else if (op == '*')
                {
                    Console.WriteLine("{0}", a * b);
                }

                else if (op == '/')
                {
                    Console.WriteLine("{0}", a / b);
                }

                else if (op == '?')
                {
                    break;
                }

            }
        }
    }
}


Measured memory_bytes: 17828
#include <bits/stdc++.h>
using namespace std;
vector<pair<int,int>> v;
int N, D, A, X, H, cnt[200001];
int bsearch(long long val) {
    int lo = 0, hi = N - 1;
    while (lo <= hi) {
        int mid = (lo + hi) / 2;
        if (val >= v[mid].first) {
            lo = mid + 1;
        } else {
            hi = mid - 1;
        }
    }
    return lo;
}
int main() {
    memset(cnt,0,sizeof cnt);    
    scanf("%d%d%d",&N,&D,&A);
    for (int i = 0; i < N; i++) {
        scanf("%d%d",&X,&H);
        v.push_back({X,H});
    }
    sort(v.begin(),v.end());
    long long bombs = 0;
    long long sum = 0;
    for (int i = 0; i < N; i++) {
        sum += cnt[i];
        v[i].second -= sum * A;
        if (v[i].second <= 0) continue;
        bombs += ceil((double)v[i].second/A);
        sum += ceil((double)v[i].second/A);
        cnt[bsearch((long long)v[i].first + 2 * D)] -= ceil((double)v[i].second/A);
    }
    printf("%lld\n",bombs);
}

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

#define times(n, i)      uptil(0, n, i)
#define upto(f, t, i)    for(decltype(t) _##i = (t), i = (f); i <= _##i; i++)
#define uptil(f, t, i)   for(decltype(t) _##i = (t), i = (f); i < _##i; i++)
#define downto(f, t, i)  for(decltype(t) _##i = (t), i = (f); i >= _##i; i--)
#define downtil(f, t, i) for(decltype(t) _##i = (t), i = (f); i > _##i; i--)
#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define all(v) v.begin(), v.end()
#define ln << "\n"

struct line{};

template<class T> istream& operator>>(istream& in, vector<T>& v) {
    times(v.capacity(), i) in >> v[i];
    return in;
}

template<class T> const ostream& operator<<(ostream& out, const vector<T>& v) {
    times(v.size(), i) out << (i ? " " : "") << v[i];
    return out;
}

template<class T, class...U> typename enable_if<is_same<T, line>::value, string>::type next(istream& in, const U&... args) {
    string s;
    getline(in, s, args...);
    return move(s);
}

template<class T, class...U> typename enable_if<!is_same<T, line>::value, T>::type next(istream& in, const U&... args) {
    T t(args...);
    in >> t;
    return move(t);
}
template<class T, class...U> auto next(const U&... args) -> decltype(next<T>(cin)) {
    return next<T>(cin, args...);
}

template<class T> T sum(const vector<T>& v) {
    T ans = T();
    for(const T& t : v) ans += t;
    return ans;
}

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

    bool b[30] = {};
    times(28, _) b[next<int>() - 1] = true;
    times(30, i) unless(b[i]) cout << i + 1 ln;

    return 0;
}

Measured memory_bytes: 1192
x,y,z,K = map(int, input().split())
a = sorted(list(map(int, input().split())))[::-1]
b = sorted(list(map(int, input().split())))[::-1]
c = sorted(list(map(int, input().split())))[::-1]

def check(p, l=None):
    cnt = 0
    for i in range(x):
        for j in range(y):
            for k in range(z):
                if a[i]+b[j]+c[k] < p:
                    break
                if l is not None:
                    l.append(a[i]+b[j]+c[k])
                cnt += 1
                if cnt >= K:
                    return True
    return False

left = 0
right = a[0]+b[0]+c[0] + 1
while right-left > 1:
    mid = (left+right)//2
    if check(mid):
        left = mid
    else:
        right = mid
#print(left)
ans = []
check(right, ans)
ans += [left]*(K - len(ans))
for i in sorted(ans, reverse=True)[:K]:
    print(i)

Measured memory_bytes: 47580
#include <iostream>

using namespace std;

int main() {
	int a, b, c; cin >> a >> b >> c;
	int ans = -1;
	for (int i = 0; i < 60; ++i) {
		int tmp = ((a + b) * i) % 60;
		if (tmp <= c && c <= tmp + a) {
			ans = (a + b) * i + c - tmp;
			break;
		}
	}
	cout << ans << endl;

	return 0;
}


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

using namespace std;
#define _for(i,j,N) for(int i = (j); i < (N);i++)
#define _rep(i,j,N) for(int i = (j); i <= (N);i++)
#define ALL(x) x.begin(),x.end()
#define LL long long

const int maxn = 100005;
int N,M;
int a[maxn];
int vis[maxn];
int cnt;
vector<int> G[maxn];
vector<int> compo[maxn];

void dfs(int v){
    vis[v] = 1;
    compo[cnt].push_back(a[v]);
    _for(w,0,G[v].size()){
        if(!vis[G[v][w]]) dfs(G[v][w]);
    }
}

int main()
{
    scanf("%d %d",&N,&M);
    _for(i,0,N) scanf("%d",&a[i]);
    _for(i,0,M){
        int w,v;
        scanf("%d %d",&w,&v);
        G[w].push_back(v);
        G[v].push_back(w);
    }
    cnt = 0;
    _for(i,0,N){
        if(!vis[i]){
            dfs(i);
            cnt++;
        }
    }

    LL val = 0;


    _for(i,0,cnt){
        sort(ALL(compo[i]));
        val += compo[i][0];
    }

    vector<int> vi;
    _for(i,0,cnt){
        _for(j,1,compo[i].size()){
            vi.push_back(compo[i][j]);
        }
    }

    int sz = vi.size();
    if(sz < cnt - 2) {
        printf("Impossible\n");
    }
    else{
        sort(ALL(vi));
        _for(i,0,cnt - 2){
            val += vi[i];
        }
        if(cnt == 1) val = 0;
        printf("%lld\n",val);
    }

    return 0;
}


Measured memory_bytes: 10108
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <set>
#include <map>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p; //後半は0で増加・1で平坦・2で減少

struct pos{
  vector<ll> points[3];
  void add_point(p point){
    points[point.second].push_back(point.first);
  }
  void points_sort(){
    REP(i,3) sort(points[i].begin(),points[i].end());
  }
  vector<double> times(){
    points_sort();
    vector<double> res;
    res.push_back(0);
    if(!points[0].empty()&&!points[1].empty()&&(points[0].front()<points[1].front()))
    res.push_back(points[1].front()-points[0].front());
    if(!points[1].empty()&&!points[2].empty()&&(points[1].front()<points[2].front()))
    res.push_back(points[2].front()-points[1].front());
    if(!points[0].empty()&&!points[2].empty()&&(points[0].front()<points[2].front()))
    res.push_back((points[2].front()-points[0].front())*1.0/2);
    if(!points[0].empty()&&!points[1].empty()&&(points[0].back()<points[1].back()))
    res.push_back(points[1].back()-points[0].back());
    if(!points[1].empty()&&!points[2].empty()&&(points[1].back()<points[2].back()))
    res.push_back(points[2].back()-points[1].back());
    if(!points[0].empty()&&!points[2].empty()&&(points[0].back()<points[2].back()))
    res.push_back((points[2].back()-points[0].back())*1.0/2);
    return res;
  }
  double min_pos(double t){
    double res = INF;
    if(!points[0].empty()) res = min(res, points[0].front()+t);
    if(!points[1].empty()) res = min(res, (double) points[1].front());
    if(!points[2].empty()) res = min(res, points[2].front()-t);
    return res;
  }
  double max_pos(double t){
    double res = -INF;
    if(!points[0].empty()) res = max(res, points[0].back()+t);
    if(!points[1].empty()) res = max(res, (double) points[1].back());
    if(!points[2].empty()) res = max(res, points[2].back()-t);
    return res;
  }
};

int main(){
  int n; cin >> n;
  pos X, Y;
  REP(i,n){
    ll x,y; char d;
    cin >> x >> y >> d;
    switch (d) {
      case 'R':
      X.add_point(p(x,0));
      Y.add_point(p(y,1));
      break;
      case 'L':
      X.add_point(p(x,2));
      Y.add_point(p(y,1));
      break;
      case 'U':
      X.add_point(p(x,1));
      Y.add_point(p(y,0));
      break;
      case 'D':
      X.add_point(p(x,1));
      Y.add_point(p(y,2));
      break;
    }
  }
  vector<double> times;
  for(double time: X.times()) times.push_back(time);
  for(double time: Y.times()) times.push_back(time);
  double ans = 1e30;
  for(double t: times){
    ans = min(ans,(X.max_pos(t)-X.min_pos(t))*(Y.max_pos(t)-Y.min_pos(t)));
  }
  printf("%.10f\n",ans);
  return 0;
}


Measured memory_bytes: 2288
//g++ test.cpp -o test.out
//入出力：http://kaitei.net/cpp/iostream/
#include <string.h>
#include <stdlib.h>
#include <math.h>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <iomanip>
using namespace std;

int N;

int main(){
	cin >> N;

	int prediction = N/1.08f+1;

	if((int)((prediction)*1.08f)==N){
		cout << prediction;
		return 0;
	}else if((int)((prediction-1)*1.08f)==N){
		cout << prediction-1;
		return 0;
	}

	cout << ":(";
	return 0;
}

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

using namespace std;
using namespace boost;

main() {
  int64_t n, m;
  cin >> n >> m;

  vector<int64_t> ans(n);
  for (auto i : irange(0L, m)) {
    int64_t a, b;
    cin >> a >> b;
    --a;
    --b;
    ++ans[a];
    ++ans[b];
  }

  for (auto a : ans) {
    cout << a << endl;
  }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cmath>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long LL;
LL a[10000];
LL n;
int main()
{

	cin>>n;
	LL cnt=1;
	LL ans=0;
	for(int i=0;i<n;i++){
		cin>>a[i];
		ans+=a[i]-1;
	}
	cout<<ans<<endl;
	return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define INFTY 10000000000
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
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;}
bool isprime(ll l){
    if(l==1)return false;
    for (ll i = 2; i*i<= l; i++)
    {
        if(l%i==0)return false;
    }
    return true;
}

int main(){

    ll n;cin>>n;
    ll cp = n;
    ll ans=0,l=2;
    if(isprime(n)){
        cout<<1<<endl;
        return 0;
    }
    while(n>=l){
        if(n%l!=0){
            l++;
            continue;
        }else{
            ll c = 0;
            while(n%l==0){
                c++;
                n/=l;
            }
            ll a;
            for (ll i = 1; i <= c; i++)
            {
                if(i*(i+1)<=2*c&&2*c<(i+1)*(i+2)){
                    a = i;
                    break;
                }
            }
            ans += a;
            }
            if(n==1) break;
            if(isprime(n)){
                ans++;
                break;
            }
            l++;
        }
    cout<<ans;

    return 0;
}

Measured memory_bytes: 3628
import java.util.Scanner;
import java.lang.Math;
public class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		String str = scan.nextLine();
		int totalRainy = getConcRainy(str);
		System.out.println(totalRainy);
	}


	public static int getConcRainy(String str){
		int total = 0;
		int max = 0;
		if(str.charAt(0) == 'R'){
			total++;
			max = Math.max(max, total);
		}

		for(int i = 1; i < str.length(); i++){
			if(str.charAt(i - 1) == str.charAt(i) && 
				       str.charAt(i) == 'R'){
			  total++;
			  max = Math.max(total, max);
			} else if(str.charAt(i) == 'R'){
				total = 1;
				max = Math.max(total, max);
			} else {
				total = 0;
			}
		}

		return max;
	}
}


Measured memory_bytes: 27016
import math
H,N = map(int,input().split())
A = [int(x) for x in input().split()]

count = 0
sum2 = []
'''for i in range(2 ** N):
        sum1 = []
        for j in range(len(A)):
            if ( i >> j) & 1 == 1:
                sum1.append(A[j])
        if sum(sum1) == H:
            count = 1
            print("Yes")
            break
'''
if sum(A) >= H:
    print("Yes")

else:
    print("No")


Measured memory_bytes: 14012
#include<bits/stdc++.h>
using namespace std;
int main(int argc, char const *argv[])
{
	long long num;
	cin >> num;
	string ans;
	num --;
	for (int i = 1; i <= 100; ++i)
	{
		long long c = pow(26, i);
		if (c <= num)
		{
			num -= c;
			continue;
		}
		else
		{
			for (int j = 0; j < i; ++j)
			{
				ans.push_back('a' + num % 26);
				num /= 26;
			}
			break;
		}
	}
	reverse(ans.begin(), ans.end());
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 4016
# AOJ ITP2_4_D: Unique
# Python3 2018.6.24 bal4u

n = int(input())
a = list(map(int, input().split()))
ans = []
ans.append(a[0])
for i in range(1, n):
	if a[i] != a[i-1]: ans.append(a[i])
print(*ans)


Measured memory_bytes: 16648
#include <bits/stdc++.h>
using namespace std;
using i64 = long long;
#define rep(i,s,e) for(int (i) = (s);(i) <= (e);(i)++)

int a;
int b;
int main(){
  cin >> a >> b;
  if(a <= b){
    cout << a;
  }
  else{
    cout << a - 1;
  }
  cout << endl;
}


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

int main() {
  int N, K, x;
  x = 1;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++) {
  
    if (2 * x > x + K) x += K;  
    else if (2 * x <= x + K) x *= 2;
  }
  cout << x << endl;
}

Measured memory_bytes: 3548
/* Author: Dhruv Rastogi */
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define int long long
#define all(sdk) sdk.begin(),sdk.end()
#define mll map<int, int>
#define pb push_back
#define rep(i,a,b) for(int i=a;i<b;++i)
#define repd(i,a,b) for(int i=a;i>=b;--i)
#define mp make_pair
#define hell 1000000007
#define endl '\n'
#define vvll vector<vector<int> >
#define vll vector<int>
#define mint map<int,int> 
#define sz(x) (int)x.size()
#define sll set<int>
#define pll pair<int,int>
#define F first
#define S second
const long double PI = acos(-1.0);

void solve(){  
	string s;
	cin>>s;
	rep(i,0,sz(s)){
		if(i%2 and s[i]=='R'){
			cout<<"No"<<endl;
			return;
		}
		else if(i%2==0 and s[i]=='L'){
			cout<<"No"<<endl;
			return;
		}
	}  
	cout<<"Yes"<<endl;
}

signed main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    // cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 256
#include<map>
#include<set>
#include<list>
#include<cmath>
#include<queue>
#include<stack>
#include<cstdio>
#include<string>
#include<vector>
#include<complex>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<numeric>
#include<sstream>
#include<iostream>
#include<algorithm>
#include<functional>
#include<cctype>

#define mp make_pair
#define pb push_back
#define REP(i,a,n) for(int i = a;i < (n);i++)
#define rep(i,n) for(int i = 0;i < (n);i++)
#define all(s) s.begin(), s.end()
#define rall(s) s.rbegin(), s.rend()
#define range(x,min,max) ((min) <= (x) && (x) <= (max))

using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<vector<int> > VVI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef pair<int,int> PII;

const int DX[]={1,0,-1,0},DY[]={0,-1,0,1};

int main(){
	cin.tie(0);
   	ios::sync_with_stdio(false);
	while(1) {
		int N, M;
		cin >> N >> M;
		if (N == 0 && M == 0) break;
		int r;
		cin >> r;
		VVI tbls(M, VI(1260));
		rep (i, r) {
			int t, n, m, s;
			cin >> t >> n >> m >> s;
			if (s == 0) {
				tbls[m - 1][t]--;
			} else {
				tbls[m - 1][t]++;
			}
		}
		rep (i, M) {
			REP (j, 1, 1260) {
				tbls[i][j] += tbls[i][j - 1];
			}
		}
		int q;
		cin >> q;
		rep (i, q) {
			int ts, te, student;
			cin >> ts >> te >> student;
			cout << count_if(tbls[student - 1].begin() + ts, tbls[student - 1].begin() + te, [&](int x) {return (x >= 1); }) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 50940
n = gets.to_i
array = gets.split().map(&:to_i)

array_abs = array.map(&:abs)

case array.select {|a| a < 0}.size % 2
when 0
	p array_abs.inject(:+)
when 1
	min, *array_abs = array_abs.sort
	p array_abs.inject(:+) - min
end

Measured memory_bytes: 11760
#include <bits/stdc++.h>
// atoi : atoi(str.c_str())
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  vvi c(3,vi(3));
  rep(i,3){
    rep(j,3){
      cin >> c.at(i).at(j);
    }
  }
  rep(i,3){
    rep(j,3){
      int x = c.at(i%3).at(j%3) + c.at((i+1)%3).at((j+1)%3);
      int y = c.at(i%3).at((j+1)%3) + c.at((i+1)%3).at(j%3);
      if(x != y){
        cout << "No" << endl;
        return 0;
      }
    }
  }
  cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<math.h>
int main(){
	double a,b,c,s,t;
	while(~scanf("%lf%lf%lf",&a,&b,&c)){
		s = sqrt(b*b-a*a/4)*a/2;
		t = sqrt(c*c + 2*b*c)*b/2;
		printf("%lf\n",s+t);
	}
	return 0;
}

Measured memory_bytes: 652
fn is_yy(n: usize) -> bool {
    n == 0 || n > 12
}

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_line(&mut buf).unwrap();

    let s01 = &buf[..2];
    let s02 = &buf[2..];
    let n01: usize = s01.parse().unwrap();
    let n02: usize = s02.trim().parse().unwrap();

    let ans = match (is_yy(n01), is_yy(n02)) {
        (true, true) => "NA",
        (true, false) => "YYMM",
        (false, true) => "MMYY",
        (false, false) => "AMBIGUOUS",
    };

    println!("{}", ans);
}

Measured memory_bytes: 4352
#include <iostream>
#define nmax 3005
using namespace std;
int n, v[nmax];
long long dp[nmax][nmax];

int main()
{
    int i, j;
    cin >> n;
    for(i = 1; i <= n ;i++)
        cin>>v[i];

    for(i = 1; i <= n; i++)
        dp[i][i] = v[i];

    for(i = n; i >= 1; i--)
        for(j = i + 1; j <= n; j++)
            dp[i][j] = max(v[i] - dp[i+1][j], v[j] - dp[i][j - 1]);

    cout << dp[1][n];

    return 0;
}

Measured memory_bytes: 70016
import java.math.BigDecimal;
import java.util.Scanner;

public class Main {
    public static void main(String args[] ) throws Exception {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        BigDecimal sum = new BigDecimal(0);
        for (int i = 0; i < n; i++) {
        	int num = sc.nextInt();
        	new BigDecimal(num);
        	BigDecimal gyaku =  new BigDecimal(1).divide(new BigDecimal(num), 10, BigDecimal.ROUND_DOWN);
        	sum = sum.add(gyaku);
		}
        System.out.println(new BigDecimal(1).divide(sum, 10, BigDecimal.ROUND_DOWN).toString());
    }
}


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

using namespace std;

#define ll long long
#define ull unsigned long long
#define re register
#define il inline
#define inf 0x3f3f3f
#define N 100010
using namespace std;

ll f[N], g[N], a[N];
char op, lst;

int main() {
  int n, x, y = 0, i, cnt = 0;
  cin >> n;
  ll ans = 0;
  for (i = 1; i <= n; ++i) {
    cin >> x;
    lst = op;
    if (i < n)
      cin >> op;
    if (lst == '-') {
      x = -x;
      a[++cnt] = x;
    }
    if (y <= 0 && x > 0)
      cnt++, a[cnt] = x;
    if (y > 0 && x > 0)
      a[cnt] += x;
    y = x;
  }
  f[1] = a[1];
  for (i = cnt; i >= 1; --i)
    g[i] = g[i + 1] + abs(a[i]);
  for (i = 2; i <= cnt; ++i)
    f[i] = f[i - 1] + a[i];
  ans = f[cnt];
  for (i = 1; i < cnt; ++i)
    if (a[i + 1] < 0)
      ans = max(ans, f[i + 1] - a[i + 2] + g[i + 3]);
  cout << ans;
}


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

typedef long long ll;

#define rep(i, n) for (ll i = 0; i < (ll)n; ++i)
#define INF 10e7
#define MOD 1000000000 + 7
#define MAX 51000
#define all(x) (x).begin(), (x).end()
#define MX(x) *max_element(all(x))
#define MN(x) *min_element(all(x))
using namespace std;

void solve(void)
{
    string s, t;
    cin >> s >> t;
    sort(all(s));
    sort(all(t));
    reverse(all(t));
    string ans = "No";
    if (s < t)
        ans = "Yes";
    cout << ans << endl;
}
int main(void)
{
    solve();
}

Measured memory_bytes: 3604
N=int(input()) 
d=list(map(int, input().split()))  #リスト入力 「a1 a2 a3 ...」みたいな配列のような入力のとき

heal=0
for n in range(N):
    for i in range(n+1,N):
        heal+=d[n]*d[i]

print(heal)

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#include<unordered_map>
#include<unordered_set>
#pragma warning(disable:4996)
using namespace std;
using ld = long double;
template<class T>
using Table = vector<vector<T>>;
const ld eps=1e-9;

//// < "D:\D_Download\Visual Studio 2015\Projects\programing_contest_c++\Debug\a.txt"
int main() {
	int N; cin >> N; int M; cin >> M;
	vector<int>cards(2*N);
	iota(cards.begin(), cards.end(), 1);
	for (int i = 0; i < M; ++i) {
		int a; cin >> a;
		if (a) {

			vector<int>newcards(2 * N);
			for (int j = 0; j < 2 * N; ++j) {
				int num;
				if (j < 2 * N - a) {
					num = j + a;
				}
				else {
					num = j - (2*N-a);
				}

				newcards[j] = cards[num];
			}
			cards = newcards;
		}
		else {
			vector<int>newcards(2*N);
			for (int j = 0; j < 2 * N; ++j) {
				int num = j % 2 ? N + j / 2 : j / 2;
				newcards[j] = cards[num];
			}
			cards = newcards;
		}
	}
	for (auto c : cards) {
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<utility>
using namespace std;
typedef long long ll;
#define rep(i,a,n)	for(int i=a;i<n;i++)
#define rrep(i,a,n) for(int i=(a-1);i>=n;i--)
 
ll gcd(ll a,ll b){
	if(b==0)return a;
	return gcd(b,a%b);
}
ll lcm(ll a,ll b){
	ll g=gcd(a,b);
	return a/g*b;
}
 
ll digitsum(ll a){
	ll x=0;
	while(a>0){
		x+=a%10;
		a/=10;
	}
	return x;
}
int main(){
	string s;
	cin>>s;
	int ans=0;
	if(s[0]=='1')ans++;
	if(s[1]=='1')ans++;
	if(s[2]=='1')ans++;
	cout<<ans<<endl;
}

Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author Jaynil
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        BRollerCoaster solver = new BRollerCoaster();
        solver.solve(1, in, out);
        out.close();
    }

    static class BRollerCoaster {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt();
            int k = in.nextInt();
            int ans = 0;
            for (int i = 0; i < n; i++) {
                if (in.nextInt() >= k) ans++;
            }
            out.println(ans);
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 31696
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.Collectors;

public class Main {
    public static void main(String[] args){
        Scanner scan = new Scanner(System.in);
        int K=scan.nextInt();
        int N=scan.nextInt();
        List<Integer> houseDist=new ArrayList<Integer>();
        for(int i=0;i<N;i++){
            houseDist.add(scan.nextInt());
        }
        List<Integer> sortedDist = houseDist.stream().sorted().collect(Collectors.toList());
        List<Integer> betweenHouse = new ArrayList<Integer>();
        for(int i=1;i<N;i++){
            betweenHouse.add(sortedDist.get(i)-sortedDist.get(i-1));
        }
        betweenHouse.add(sortedDist.get(0)+(K-sortedDist.get(N-1)));
        int max = betweenHouse.stream().mapToInt(value -> value).max().getAsInt();
        int sum = betweenHouse.stream().mapToInt(value -> value).sum() - max;
        System.out.println(sum);
    }
}

Measured memory_bytes: 99688
def base10to(n, b):
    if (int(n/b)):
        return base10to(int(n/b), b) + str(n % b)
    return str(n % b)


N = int(input())
f = []
for i in range(N):
    f.append(list(map(int, input().split())))
p = []
for i in range(N):
    p.append(list(map(int, input().split())))
ans = []
for i in range(1,1024):
    lis = list(base10to(i, 4).zfill(5))
    temp = 0
    for k in range(N):
        count = 0
        for j in range(len(lis)):
            if lis[j] == '0':
                count += f[k][2*j]*0 + f[k][2*j + 1]*0
            elif lis[j] == '1':
                count += f[k][2*j]*1 + f[k][2*j + 1]*0
            elif lis[j] == '2':
                count += f[k][2*j]*0 + f[k][2*j + 1]*1
            elif lis[j] == '3':
                count += f[k][2*j]*1 + f[k][2*j + 1]*1
        temp += p[k][count]
    ans.append(temp)
print(max(ans))


Measured memory_bytes: 3064
n=int(input())
a,b=list(map(int,input().split()))
p=list(map(int,input().split()))

first=0
second=0
third=0

for i in range(n):
    if p[i]<=a:
        first+=1
    elif a<p[i]<=b:
        second+=1
    else:
        third+=1

print(min(min(first,second),third))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <algorithm>
#include <string.h>
#include <iomanip>
#include <math.h>

typedef long long int ll;

#define FOR(i,n,m) for(ll i=(ll)(m);i<(ll)(n);++i)
#define REP(i,n) FOR(i,n,0)
#define IREP(i,n) for(ll i=(ll)(n);i>=0;--i)
#define OF64 std::setprecision(10)

const ll MOD = 1000000007;

using namespace std;

struct Edge {
	ll f;
	ll t;
	ll c;
	Edge(ll f, ll t, ll c)
		:f(f), t(t), c(c)
	{}
	Edge() {}
};

Edge E[2005];
ll d[1005];

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

	REP(i, M)
	{
		ll a, b, c;
		cin >> a >> b >> c;
		a--; b--;
		E[i] = Edge(a, b, c);
	}
	REP(i, N)
	{
		d[i] = INT64_MIN;
	}
	d[0] = 0;
	ll m = INT64_MIN;
	REP(i, 2 * N + 1)
	{
		bool update = false;
		REP(j, M)
		{
			Edge e = E[j];
			if (d[e.f] != INT64_MIN&&d[e.t] < d[e.f] + e.c)
			{
				d[e.t] = d[e.f] + e.c;
				update = true;
			}
		}
		if (!update)
		{
			break;
		}
		if (i == N)
		{
			m = d[N - 1];
		}
	}

	if (m != d[N - 1] && m != INT64_MIN)
	{
		cout << "inf" << endl;
	}
	else {
		cout << d[N - 1] << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
    private static final int MOD = 1_000_000_007;
    private static final String YES = "Yes";
    private static final String NO = "No";

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

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

        long[] ans = solve(N, A);
        for (int i=0; i<N; i++) {
            System.out.println(ans[i]);
        }

    }

    private static long[] solve(int N, int[] A) {
        long[] ans = new long[N];

        long[] count = new long[N + 1];
        for (int i=0; i<N; i++) {
            count[A[i]]++;
        }
        long max = 0;
        for (int i=1; i<=N; i++) {
            if (count[i] >= 2) {
                max += count[i] * (count[i]-1) / 2;
            }
        }

        for (int i=0; i<N; i++) {
            ans[i] = max - count[A[i]] * (count[A[i]]-1) / 2;
            if (count[A[i]] >= 2) {
                ans[i] += (count[A[i]]-1) * (count[A[i]]-2) /2;
            }
        }

        return ans;
    }
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int p[n];
    for (int i = 0; i < n; i++) {
        cin >> p[i];
    }
    sort(p, p+n);
    int sum = 0;
    for (int i = 0; i < k; i++) {
        sum += p[i];
    }
    cout << sum << endl;
return 0;
}

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

using namespace std;

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

typedef long long ll;

const int Inf = 1e9;
const double EPS = 1e-9;

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

int lcm(int a, int b) {
    return a * b / gcd(a, b);
}

int bitCount(long bits) {
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x, a, b;  cin >> x >> a >> b;
    if (a >= b) {
      cout << "delicious" << '\n';
    } else if (b - a <= x) {
      cout << "safe" << '\n';
    } else {
      cout << "dangerous" << '\n';
    }

    return 0;
}


Measured memory_bytes: 256
from collections import deque

N, M = list(map(int, input().split()))
v = [[] for _ in range(N)]
for _ in range(M):
    A, B = list(map(lambda x: int(x) - 1, input().split()))
    v[A].append(B)
    v[B].append(A)

ans = [None]*N
ans[0] = 0

stack = deque()
stack.append(0)
while stack:
    x = stack.popleft()
    connected = v[x]
    for u in connected:
        if ans[u] == None:
            ans[u] = x + 1
            stack.append(u)
print('Yes')
print(*ans[1:], sep='\n')

Measured memory_bytes: 38568
#include<stdio.h>
#include<string.h>
int main(){
	char a[21],b[21]="";
	int i,j,n;

	scanf("%s",a);
	i=strlen(a);
	n=i-1;
	for(j=0;j<i;j++){
		b[j]=a[n];
		n--;
		
	}
	printf("%s\n",b);
	
	return 0;

}

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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,int> ii;
typedef pair <ii,int> iii;

const int mod = 1e9 + 7;
const int N = 100005;

void solve(){
	int n;
	ll r = 0, g = 0, b = 0;
	string s;
	cin >> n >> s;
	for(char c:s){
		if(c == 'R')r++;
		else if(c == 'G')g++;
		else b++;
	}
	ll ans = r*g*b;
	for(int i = 0; i < sz(s); i++){
		for(int d = 1; (i + 2*d) < sz(s); d++){
			ans -= (s[i] != s[i+d] and s[i] != s[i+2*d] and s[i+d] != s[i+2*d]);
		}
	}
	cout << ans << endl;
}

int main(){
	fastio;
	int t = 1;
	//cin >> t;
	while(t--)
		solve();
	return 0;
}


Measured memory_bytes: 3632
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""076-c"""


import sys

def kmp(T, P):
    n, m = len(T), len(P)
    j = 0
    k = 0
    fail = kmp_fail(P)
    while j < n:
        if T[j] == P[k] or T[j] == '?':
            if k == m - 1:
                return j - m + 1
            j += 1
            k += 1
        elif k > 0:
            k = fail[k-1]
        else:
            j += 1
    return -1

def kmp_fail(P):
    n = len(P)
    fail = [0] * n
    j = 1
    k = 0
    while j < n:
        if P[j] == P[k]:
            fail[j] = k + 1
            j += 1
            k += 1
        elif k > 0:
            k = fail[k - 1]
        else:
            j += 1
    return fail


def main():
    """Main function."""
    S_p = input()
    T = input()

    pos = kmp(S_p, T)

    if pos < 0:
        print('UNRESTORABLE')
        sys.exit(0)

    S_cand = S_p[:pos] + T + S_p[pos+len(T):]
    S_cand = S_cand.replace('?', 'a')

    pos_ = 0
    while pos_ >= 0:
        pos_ = kmp(S_p[pos+1:], T)
        if pos_ >= 0:
            pos = pos + pos_ + 1
            S_cand2 = S_p[:pos] + T + S_p[pos+len(T):]
            S_cand2 = S_cand2.replace('?', 'a')
            S_cand = S_cand if S_cand < S_cand2 else S_cand2

    print(S_cand)

if __name__ == '__main__':
    sys.exit(main())

Measured memory_bytes: 3188
def nc2(n):
    if n==0:
        return 0
    return n*(n-1)/2


n=int(input())
arr=[int(i) for i in input().strip().split(" ")]
ans=0
dic={}
for i in arr:
    dic[i]=dic.get(i,0)+1
for i in dic:
    if dic[i]==1 :
        continue
    ans+=nc2(dic[i])
    
#print(dic)

for i in range(n):
    curr_nc2=nc2(dic[arr[i]])
    # print(curr_nc2)
    print(int(ans-curr_nc2+nc2(dic[arr[i]]-1)))
    

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

using namespace std;

int main() {
    int n, k;
    cin >> n >> k;

    for (int i = 0; i < n; ++i) {
        int a;
        cin >> a;
    }

    cout << (n + k - 3) / (k - 1) << endl;
    return 0;
}

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

#define int long long
 
// loop
#define FOR(i, a, b) for (int i = (a); i < (b); i++) 	// a ~ b-1	(ascending)
#define REP(i, n) FOR(i, 0, n)							// 0 ~ n-1
#define NREP(i, n) FOR(i, 1, n + 1)						// 1 ~ n
#define RFOR(i, a, b) for (int i = (a); i >= (b); i--)	// a ~ b	(descending)
#define RREP(i, n) RFOR(i, n, 0)						// n ~ 0
#define RNREP(i, n) RFOR(i, n, 1)						// n ~ 1
 
// container operation
#define EACH(i, c) for (auto i = (c).begin(); i != (c).end(); i++)
#define ASORT(c) std::sort((c).begin(), (c).end())
#define DSORT(c) std::sort((c).begin(), (c).end(), std::greater<typeof((c).front())>())
#define SIZE(x) ((int)(x).size())
 
// debug
#define check(x) std::cout << #x << " = " << x << '\n'
 
// print
#define cout(x) std::cout << x << '\n'
 
// type alias
using VI = std::vector<int>;
using VII = std::vector<VI>;
using VB = std::vector<bool>;
using VBB = std::vector<VB>;
using VS = std::vector<std::string>;
using PII = std::pair<int, int>;

std::string yes = "Yes\n";
std::string no = "No\n";

void solve();

signed main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  solve();
  return 0;
}

void solve() {
  std::string s;
  std::cin >> s;
  // check(SIZE(s));
  int total = 0;
  for (int i = 0; i < (1 << (SIZE(s) - 1)); i++) {
    std::bitset<10> b(i);
    // check(b);
    b.set(SIZE(s) - 1);

    int sum = 0;
    int count = 1;
    for (int j = 0; j < SIZE(s); j++) {
      // check(j);
      if (b.test(j)) {
        // check(count);
        // check(s.substr(j + 1 - count, count));
        sum += std::stoll(s.substr(j + 1 - count, count));
        count = 1;
      } else {
        count++;
      }
    }
    // check(sum);
    total += sum;
    // cout("");
  }
  cout(total);
}


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

int main() {
  int n,a,b,ans;
  cin >> n;
  for(int i=0;i<n;i++){
  	cin >> a >> b;
    ans += (b-a+1);
    a=0,b=0;
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
<?php
  list($n) = explode(" ", trim(fgets(STDIN)));
  $a = explode(" ", trim(fgets(STDIN)));
  $b = explode(" ", trim(fgets(STDIN)));
  $c = explode(" ", trim(fgets(STDIN)));

  $ans = 0;
  for($i=0; $i<$n; $i++){
//    echo $b[$a[$i]-1].PHP_EOL;
    $ans += $b[$a[$i]-1];
    if($i > 0 && $a[$i] - $a[$i-1] == 1){
      $ans += $c[$a[$i-1]-1];
    }
  }

  echo $ans;

Measured memory_bytes: 5240
import java.util.Scanner;

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

    int A = scanner.nextInt();
    int B = scanner.nextInt();
    if (B == 1) {
      System.out.println(0);
    } else {
      System.out.println((B - 2) / (A - 1) + 1);
    }
  }
}

Measured memory_bytes: 22484
#include<cmath>
#include<iostream>

using namespace std;
typedef long long ll;

int N;
int T, A;
ll H[1001];
int main() {
  cin >> N;
  cin >> T >> A;
  for (int i = 1; i <= N; i++) {
    cin >> H[i];
  }

  int k = 0;
  double minv = 1e9;
  for (int i = 1; i <= N; i++) {
    double temp = T - H[i] * 0.006;
    if (minv > abs(A - temp)) {
      minv = abs(A - temp);
      k = i;
    }
  }

  cout << k << endl;
  return 0;
}

Measured memory_bytes: 256