akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1LL << 60;
#define rep(i, a, n) for (ll i = (a); i < (n); i++)
#define debug(x) cerr << #x << ": " << x << endl;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}

int main() {
    ll n, m;
    cin >> n >> m;
    vector<pair<ll, ll>> p;
    rep(i, 0, n) {
        ll a, b;
        cin >> a >> b;
        p.emplace_back(a, b);
    }
    sort(p.begin(), p.end());

    ll ans = 0, res = m;
    rep(i, 0, n) {
        if (p[i].second <= res) {
            ans += p[i].first * p[i].second;
            res -= p[i].second;
        }
        else if (0 < res && res < p[i].second) {
            ans += p[i].first * res;
            res = 0;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 2420
#include <iostream>
#include <utility>
#include <cmath>
#include <stdio.h>

using namespace std;

int main() {
    int n;  cin >> n;
    pair<double,double> *point = new pair<double,double>[n];
    for (int i = 0; i < n; i++)
        cin >> point[i].first >> point[i].second;

    double ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i+1; j < n; j++) {
            double x_1, y_1, x_2, y_2;
            x_1 = point[i].first;
            y_1 = point[i].second;
            x_2 = point[j].first;
            y_2 = point[j].second;
            double tmp = (x_1-x_2)*(x_1-x_2) + (y_1-y_2)*(y_1-y_2);
            ans += sqrt(tmp);
        }
    }

    ans = 2 * ans / n;
    printf("%.12f\n", ans);
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,n,s) for(int i = s; i < (n); ++i)
#define rsrep(i,n,s) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<x<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;

int main() {
    int n;
    cin >> n;
    vint a(n);
    rep(i, n) cin >> a[i];
    int count = 0;
    rep(i, n) {
        if (a[i]%2 == 1) count++;
    }
    yn(count%2 == 0);    
    return 0;
}

Measured memory_bytes: 640
#include <stdio.h>

int main(void){
    int i;
    char s[13];
    scanf("%s", s);

    for(i = 0; i < 4; i++){
        printf("%c", s[i]);
    }
    printf(" ");
	for(i = 4; i < 12; i++){
        printf("%c", s[i]);
    }

    putchar('\n');
	return 0;
}

Measured memory_bytes: 128
S = input()
T = input()
lenS = len(S)
lenT = len(T)
dp = [[0]*(lenT+1) for _ in range(lenS+1)]
for i in range(1,lenS+1):
    for j in range(1,lenT+1):
        if S[i-1]==T[j-1]:
            dp[i][j] = dp[i-1][j-1]+1
        else:
            dp[i][j] = max(dp[i-1][j],dp[i][j-1])
ans = []
while lenS!=0 and lenT!=0:
    if dp[lenS][lenT]==dp[lenS-1][lenT]:
        lenS-=1
    elif dp[lenS][lenT]==dp[lenS][lenT-1]:
        lenT-=1
    else:
        ans.append(S[lenS-1])
        lenS-=1
        lenT-=1
ans = ans[::-1]
print("".join(ans))

Measured memory_bytes: 112220
#include<bits/stdc++.h>
#define lg long long int
#define loop(i,s,e) for(lg i=s;i<=e;i++)
#define iloop(i,s,e) for(lg i=e;i>=s;i--)
#define pb push_back
#define mp make_pair
using namespace std;

lg min(lg a,lg b)
{return a<b?a:b;}
lg max(lg a,lg b)
{return a>b?a:b;}
lg lcm(lg a ,lg b)
{
    return (a*b)/__gcd(a,b);
}
int main()
{
    lg n;
    cin>>n;
    string a1 = "AC", a2 = "WA", a3 = "TLE", a4 = "RE";
    lg b1=0,b2=0,b3=0,b4=0;

    for(lg i=0;i<n;i++)
    {
        string h;
        cin>>h;
        if(h==a1) b1++;
        else if(h==a2) b2++;
        else if(h==a3) b3++;
        else if(h==a4) b4++;
    }

    cout<<a1<<" x "<<b1<<endl;
    cout<<a2<<" x "<<b2<<endl;
    cout<<a3<<" x "<<b3<<endl;
    cout<<a4<<" x "<<b4<<endl;
}


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


int main(){

  int n;
  cin >> n;
  double x[3];

  double y[3];

  for(int i=0; i<n; i++){
    cin >> x[0] >> y[0] >> x[1] >> y[1] >> x[2] >> y[2];

    double a, b, c;
    double r, px, py;

    a = sqrt( (x[0]-x[1])*(x[0]-x[1]) + (y[0]-y[1])*(y[0]-y[1]) );
    b = sqrt( (x[1]-x[2])*(x[1]-x[2]) + (y[1]-y[2])*(y[1]-y[2]) );
    c = sqrt( (x[2]-x[0])*(x[2]-x[0]) + (y[2]-y[0])*(y[2]-y[0]) );

    r = (a*b*c) / (sqrt((a+b+c)*(b+c-a)*(a-b+c)*(a+b-c)));
    px = (((x[0]*x[0])+(y[0]*y[0]))*(y[1]-y[2])+((x[1]*x[1])+(y[1]*y[1]))*(y[2]-y[0])
    +((x[2]*x[2])+(y[2]*y[2]))*(y[0]-y[1]))/(x[0]*(y[1]-y[2])+x[1]*(y[2]-y[0])+x[2]*(y[0]-y[1]))/2;

    py = (((x[0]*x[0])+(y[0]*y[0]))*(x[1]-x[2])+((x[1]*x[1])+(y[1]*y[1]))*(x[2]-x[0])
    +((x[2]*x[2])+(y[2]*y[2]))*(x[0]-x[1]))/(y[0]*(x[1]-x[2])+y[1]*(x[2]-x[0])+y[2]*(x[0]-x[1]))/2;


    printf("%.3lf %.3lf %.3lf\n", px, py, r);
  }




  return 0;
}














// EOF

Measured memory_bytes: 3156
N = int(input())
x, y, h = [[0]*N, [0]*N, [0]*N]
for n in range(N):
  x[n], y[n], h[n] = map(int, input().split())
  if h[n] > 0:
    hi = n

def g(xx, yy, height):
  for n in range(N):
    if max(height-abs(xx-x[n])-abs(yy-y[n]), 0) != h[n]:
      return False
  return True

def f():
  for xx in range(101):
    for yy in range(101):
      height = abs(xx-x[hi])+abs(yy-y[hi])+h[hi]
      if g(xx, yy, height) is True:
        return [xx, yy, height]
print(*f())

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
map<string,int>m;
string n;
int main()
{
	cin>>n;
	m["SUN"]=7;
	//m["SUN"]==7;
	m["MON"]=6;
	m["TUE"]=5;
	m["WED"]=4;
	m["THU"]=3;
	m["FRI"]=2;
	m["SAT"]=1;
	cout<<m[n]; 
} 

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

#define ll long long
#define ld long double

#define rep(i,a,b) for(ll i=a;i<b;i++)
#define repb(i,a,b) for(ll i=a;i>=b;i--)
#define repA(i,A)   for(auto i:A)

#define err() cout<<"=================================="<<endl;
#define errA(A) for(auto i:A)   cout<<i<<" ";cout<<endl;
#define err1(a) cout<<#a<<" "<<a<<endl
#define err2(a,b) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<endl
#define err3(a,b,c) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<endl
#define err4(a,b,c,d) cout<<#a<<" "<<a<<" "<<#b<<" "<<b<<" "<<#c<<" "<<c<<" "<<#d<<" "<<d<<endl

#define mp make_pair
#define pb push_back
#define all(A)  A.begin(),A.end()
#define allr(A)	A.rbegin(),A.rend()
#define ft first
#define sd second

#define pll pair<ll,ll>
#define V vector<ll>
#define S set<ll>
#define VV vector<V> 
#define Vpll vector<pll>

#define endl "\n"

const ll logN = 20;
const ll M = 1000000007;
const ll INF = 1e12;
#define PI 3.14159265

const ll N = 2005;

ll L[N];

int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    ll n;
    cin>>n;
    ll A[n];
    rep(i,0,n)	cin>>A[i], L[A[i]]++;
    rep(i,1,N)	L[i] += L[i-1];
    sort(A,A+n);
    ll cnt = 0;
    rep(i,0,n)	rep(j,i+1,n){
    	ll r = A[i] + A[j];
    	ll l = A[j] - A[i];
    	cnt += (L[r-1] - L[l]);
    	if(A[i] > l and A[i] < r)	cnt--;
    	if(A[j] > l and A[j] < r)	cnt--;
    }
    cout << cnt/3 << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace _0001
{
    public class Program

    {
        public static void Main(string[] args)
        {
            int[] hills = new int[10];
            for (int i = 0 ; i < 10 ; i++)
            {
                hills[i] = ReadInt();
            }
            hills = hills.OrderByDescending(x => x).ToArray();
            Console.WriteLine(hills[0]);
            Console.WriteLine(hills[1]);
            Console.WriteLine(hills[2]);
        }

        static string ReadSt() { return Console.ReadLine(); }
        static int ReadInt() { return int.Parse(Console.ReadLine()); }
        static long ReadLong() { return long.Parse(Console.ReadLine()); }
        static double ReadDouble() { return double.Parse(Console.ReadLine()); }
        static string[] ReadStAr(char sep = ' ') { return Console.ReadLine().Split(sep); }
        static int[] ReadIntAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => int.Parse(e)); }
        static long[] ReadLongAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => long.Parse(e)); }
        static double[] ReadDoubleAr(char sep = ' ') { return Array.ConvertAll(Console.ReadLine().Split(sep), e => double.Parse(e)); }
        static string WriteAr(int[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(double[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }
        static string WriteAr(long[] array, string sep = " ") { return String.Join(sep, array.Select(x => x.ToString()).ToArray()); }

    }

}



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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int n; cin >> n;
	map<int,int> u,v;
	repp(i,0,n/2){
		int a,b; cin >> a >> b;
		++u[a]; ++v[b];
	}
	vector<pair<int,int>> x,y;
	x.push_back(make_pair(0,-1));
	y.push_back(make_pair(0,-1));
	for(auto a : u) x.push_back(make_pair(a.second,a.first));
	for(auto a : v) y.push_back(make_pair(a.second,a.first));
	sort(x.begin(),x.end(),greater<pair<int,int>>());
	sort(y.begin(),y.end(),greater<pair<int,int>>());
	if(x[0].second == y[0].second){
		cout << min(n-x[0].first-y[1].first,n-x[1].first-y[0].first) << endl;
	} else {
		cout << n-x[0].first-y[0].first << endl;
	}
	return 0;
}


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

template<typename T>
void out(T x) { cout << x << endl; exit(0); }
#define watch(x) cout << (#x) << " is " << (x) << endl





using ll = long long;

const ll mod = 1e9+7;
const int maxn = 1e6 + 5;



int n, q;

int a[maxn];
int b[maxn];
vector<int> inds[maxn];

vector<int> t[maxn*4];

void build(int v, int tl, int tr) {
    if (tl == tr) {
	t[v].push_back(b[tl]);
    } else {
	int tm = (tl+tr)/2;
	build(2*v,tl,tm);
	build(2*v+1,tm+1,tr);
	std::merge(t[2*v].begin(),t[2*v].end(),
		   t[2*v+1].begin(), t[2*v+1].end(),
		   std::back_inserter(t[v]));
    }
}

int qry(int v, int tl, int tr, int l, int r) {
    if (l>tr || r<tl) return 0;
    if (l<=tl && tr<=r) {
	return int(std::lower_bound(t[v].begin(),t[v].end(),l)-t[v].begin());
    } else {
	int tm = (tl+tr)/2;
	return qry(2*v,tl,tm,l,r) + qry(2*v+1,tm+1,tr,l,r);
    }
}

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

    memset(b,-1,sizeof(b));

    cin>>n>>q;
    for (int i=1; i<=n; i++) {
	cin>>a[i];
	if (inds[a[i]].size()) {
	    b[i] = inds[a[i]].back();
	}
	inds[a[i]].push_back(i);
    }

    build(1,1,n);

    while (q--) {
	int l,r;
	cin>>l>>r;
	cout<<qry(1,1,n,l,r)<<"\n";
    }
    
    
    return 0;
}


Measured memory_bytes: 207512
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner entrada = new Scanner(System.in);
        int Q[] =new int[3];
        int A = entrada.nextInt();
        int B = entrada.nextInt();
        int C = entrada.nextInt();
        int D = A+B;
        int E = A+C;
        int F = B+C;
        Q[0]=D;
        Q[1]=E;
        Q[2]=F;
        Arrays.sort(Q);
        System.out.println(Q[0]);
    }
}

Measured memory_bytes: 25172
#include<set>
#include<map>
#include<cmath>
#include<deque>
#include<stack>
#include<ctime>
#include<queue>
#include<vector>
#include<cstdio>
#include<cstring>
#include<climits>
#include<iostream>
#include<algorithm>
#define LL long long
using namespace std;
int read(){
	int f=1,x=0;char c=getchar();
	while(c<'0'||'9'<c){if(c=='-')f=-1;c=getchar();}
	while('0'<=c&&c<='9') x=(x<<3)+(x<<1)+(c^48),c=getchar();
	return f*x;
}
#define MAXN 200000
#define INF 0x3f3f3f3f
int main(){
	int n=read();
	for(int i=1;i<=9;i++)
		for(int j=1;j<=9;j++)
			if(i*j==n){
				puts("Yes");
				return 0;
			}
	puts("No");
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,k,ans,a[55];
int main() {
	ios::sync_with_stdio(false);
	cin >> n >> k;
	for(int i = 1; i <= n; i++)
		cin >> a[i];
	sort(a + 1,a + n + 1);
	for(int i = n; i > n - k; i--)
		ans += a[i];
	cout << ans << endl;
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int N = 305;
ld dp[N][N][N];
int mark[N][N][N], n;

ld solve(int t1, int t2, int t3) {
	int t0 = n - (t1 + t2 + t3);
	if (t0 == n)
		return 0;
	ld &ans = dp[t1][t2][t3];
	if (mark[t1][t2][t3])
		return ans;
	mark[t1][t2][t3] = 1;
	ans = 1;
	if (t1)
		ans += solve(t1 - 1, t2, t3) * ((ld) t1 / n);
	if (t2)
		ans += solve(t1 + 1, t2 - 1, t3) * ((ld) t2 / n);
	if (t3)
		ans += solve(t1, t2 + 1, t3 - 1) * ((ld) t3 / n);
	ans /= (1 - ((ld)t0 / n));
	return ans;
}

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int t[4] = {};
	cin >> n;
	for(int i = 0; i < n; i++){
		int a;
		cin >> a;
		t[a]++;
	}
	cout << fixed << setprecision(12) << solve(t[1], t[2], t[3]);
	return 0;
}


Measured memory_bytes: 269476
// ---------- BEG ../defs.hpp BEG ----------
#ifndef atcoder_defs_hpp
#define atcoder_defs_hpp
#include <cstdio>
#include <cstdint>
#include <cinttypes>
#include <cmath>
#include <string>
#include <vector>
#include <iostream>
#include <utility>
#include <algorithm>
#include <numeric>
#include <functional>
using namespace std;
using i8t = std::int64_t;
using u8t = std::uint64_t;
using vi8t = std::vector<i8t>;
using vvi8t = std::vector<std::vector<i8t>>;
using vu8t = std::vector<u8t>;
#include <limits>
static const i8t i8t_max=numeric_limits<i8t>::max();
static const i8t i8t_min=numeric_limits<i8t>::min();
#include <unordered_map>
#include <unordered_set>
template<typename Key,typename Value> using map_t=std::unordered_map<Key, Value>;
template<typename Key> using set_t=std::unordered_set<Key>;
#define F3(i,i0,iN,step) for(i8t i=i0,i##_N=iN;i<i##_N;i+=step)
#define F2(i,i0,iN) F3(i,i0,iN,1)
#define F(i,N) F3(i,0,N,1)
#define FR(i,N) for(i8t i=N;i--;)
#define R(V) i8t V;std::cin>>V;
#define RV(V,N) std::vector<i8t> V;F(_i,N){R(_x)V.push_back(_x);}
#define RL1(line) std::getline(std::cin,line);
#define RL(line) std::string line;RL1(line)
#define RM(V,L,C) std::vector<char> V;F(_i,L){RL(_l)F(_j,C)V.push_back(_l[_j]);}
#define P(X) std::cout<<(X)<<std::endl;
template<typename T> T umax(T& ans,T const& value) {if(value>ans)ans=value;return ans;}
template<typename T> T umin(T& ans,T const& value) {if(value<ans)ans=value;return ans;}
template<typename T> struct identity { using type = T; };
#endif
// ---------- END ../defs.hpp END ----------

int main() {
  R(N)R(A)R(B);

  i8t ans=N/(A+B)*A;
  N%=(A+B);
  ans+=std::min(N,A);
  P(ans);
  return 0;
}


Measured memory_bytes: 256
n = gets.chomp.to_i
v = gets.chomp.split.map(&:to_i)
c = gets.chomp.split.map(&:to_i)
b = 0
for a in 0..n - 1
  if v[a] - c[a] > 0
    b = b + v[a] - c[a]
  end
end
puts b


Measured memory_bytes: 1788
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <queue>
#include <numeric>
#include <string>
#include <iostream>
#include <string.h>
#include <map>
#include <set>
#include <functional>

using namespace std;

const int INF = (1<<30) - 1;

int senbei[10][10000];

int main(){
	ios::sync_with_stdio(false);
    int R, C;
    while(cin >> R >> C, R|C){
        for(int i=0; i<R; i++)
            for(int j=0; j<C; j++)
                cin >> senbei[i][j];
        int ans = 0;
        for(int p=0; p<(1<<R); p++){
            int tans = 0;
            for(int i=0; i<C; i++){
                int cnt = 0;
                for(int j=0; j<R; j++)
                    cnt += senbei[j][i] ^ (p>>j&1);
                tans += max(cnt, R-cnt);
            }
            ans = max(ans, tans);
        }
        cout << ans << endl;
    }
        
	return 0;
}

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

int main()
{
   
    long long int n;
    cin>>n;
    vector<long long int> v;
    for(long long int i=0;i<n;i++)
    {
        long long int x;
        cin>>x;
        v.push_back(x);
    }
    long long int dp[n];
    for(int i=0;i<n;i++)
    dp[i]=1000000005;

    dp[0]=0;
    
    for(long long int i=0;i<n;++i)
    {
        for(long long int j=1;j<=2;++j)
        {
            if(i+j<n)
            {
                dp[i+j]=min(dp[i+j],dp[i]+abs(v[i]-v[i+j]));
            }
        }
    }
    
    cout<<dp[n-1];
    return 0;
}


Measured memory_bytes: 1908
#include <bits/stdc++.h>
using namespace std;
char s[100005], t[100005];
int nt[100005][26];
int main(){
    scanf("%s%s", s+1, t+1);
    int n = strlen(s+1), m = strlen(t+1);
    for(int i=n;i>=1;i--){
        for(int j=0;j<26;j++) nt[i][j] = nt[i+1][j];
        nt[i][s[i]-'a'] = i;
    }
    long long ans = 0;
    int cur = 1;
    for(int i=1;i<=m;i++){
        if(nt[cur][t[i]-'a'] == 0){
            if(nt[1][t[i]-'a'] == 0){
                printf("-1\n");
                return 0;
            }
            ans += n-cur+1;
            ans += nt[1][t[i]-'a'] - 1 + 1;
            cur = nt[1][t[i]-'a'] + 1;
        }
        else{
            ans += nt[cur][t[i]-'a'] - cur + 1;
            cur = nt[cur][t[i]-'a']+1;
        }
    }
    printf("%lld\n", ans);
}

Measured memory_bytes: 14156
#include<bits/stdc++.h>
using namespace std;
using ll  = long long;
using vl  = vector<ll>;
using vi  = vector<int>;
#define _GLIBCXX_DEBUG
#define IO_STREAM cin.tie(0);ios::sync_with_stdio(false)
#define all(x) x.begin(),x.end()
#define rep(i,sta,end) for(int i=sta;i<end;++i)
#define lcm(a,b) (a)/__gcd((a),(b))*(b)
#define pb push_back
const ll INF = 1000000000000000;
const ll MOD = 1000000007;
const double PI = acos(-1);
//||
#define DBG(a,b,c,d) //cout<<a<<" "<<b<<" "<<c<<" "<<d<<" "<<endl
//DBG("","","","");

int main(){
	IO_STREAM;
	int N;	cin>>N;
	double ans;
	if(N%2==0){
		ans=0.5;
	}
	else{
		ans=(N/2+1);
		ans=ans/(double)N;
	}
	cout << fixed << setprecision(9);
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int N, M;
  cin >> N >> M;
  int u[M], v[M];
  for (int i = 0; i < M; i++) {
    cin >> u[i] >> v[i];
    u[i]--;
    v[i]--;
  }
  int S, T;
  cin >> S >> T;
  S--;
  T--;
  vector<int> adj[N];
  for (int i = 0; i < M; i++) {
    adj[u[i]].push_back(v[i]);
  }
  deque<int> q;
  q.push_back(S);
  int d[N];
  int INF = 1000000000;
  for (int i = 0; i < N; i++) {
    d[i] = INF;
  }
  d[S] = 0;
  int vis[N]{};
  vis[S] = 1;
  int cnt = 0;
  int vis1[N]{};
  int vis2[N]{};
  while(!q.empty()) {
    int t = q.front();
    q.pop_front();
    for (int i : adj[t]) {
      if (vis1[i] == 1) continue;
      vis1[i] = 1;
      for (int j : adj[i]) {
        if (vis2[j] == 1) continue;
        vis2[j] = 1;
        for (int k : adj[j]) {
          if (vis[k] == 0) {
            vis[k] = 1;
            d[k] = d[t] + 1;
            q.push_back(k);
          }
        }
      }
    }
  }
  if (d[T] != INF) {
    cout << d[T] << "\n";
  } else {
    cout << "-1";
  }
  return 0;
}

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

signed main(){
  int n,k,x,y,cnt=0;
  cin>>n>>k;
  k*=k;
  while(n--){
    cin>>x>>y;
    x*=x;
    y*=y;
    if(k>=x+y) cnt++;
  }
  cout<<cnt<<endl;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
using namespace std;
int n, m;

int get(int x) {
  int pos = n / x, yu = n % x;
  if(yu >= m) yu = yu - m + 1;
  else yu = 0;
  return pos * (x - m) + yu;
}

int main() {
  cin >> n >> m;
  if(!m) printf("%lld\n", 1ll * n * n);
  else {
    ll ans = 0;
    for(int i = m + 1; i <= n; ++i) {
     // printf("%d\n", get(i));
      ans += get(i);
    }
    printf("%lld\n", ans);
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>

using namespace std;

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

	int n;
	cin >> n;

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

	int flag = 1;
	int con = 0;

	while (flag) {
		flag = 0;
		for (int j = n - 1; j >= 1; j--) {
			if (a[j] < a[j - 1]) {
				swap(a[j], a[j - 1]);
				con++;
				flag = 1;
			}
		}
	}

	for (int i = 0; i < n; i++) {
		if (i > 0) {
			cout << ' ';
		}
		cout << a[i];
	}
	cout << endl;
	cout << con << endl;
}


Measured memory_bytes: 3212
N,M = map(int,input().split())
ABC = [list(map(int,input().split())) for _ in [0]*M]

E = [{} for _ in [0]*N]
for a,b,c in ABC:
    E[a-1][b-1] = -c


INFTY = 10**18
d = [INFTY]*N
d[0] = 0

def update():
    done = [False]*N
    done[0] = True
    q = [0]
    qp = q.pop
    qa = q.append
    while q:
        i = qp()
        di = d[i]
        for j,c in E[i].items():
            d[j] = min(d[j],d[i]+c)
            if not done[j]:
                qa(j)
                done[j] = True

for _ in range(N-1):update()
dc = d[:]
for _ in range(N):update()
if dc[-1]!=d[-1]:
    print("inf")
else:
    print(-d[-1])

Measured memory_bytes: 52696
#include<iostream>
using namespace std;
int main(){
	int n,m,cos[200],ans,k;
	char tab[200][10],now[10];
	while(cin>>n>>m,n||m){
		ans=0;
		for(int i=0;i<n;i++)
			cin>>tab[i]>>cos[i];
		for(int i=0;i<m;i++){
			cin>>now;
			for(int j=0;j<n;j++){
				for(k=7;k>=0;k--){
					if(tab[j][k]=='*')
						continue;
					if(tab[j][k]!=now[k])
						break;
				}
				if(k==-1){
					ans+=cos[j];
					break;
				}
			}
		}
		cout<<ans<<endl;
	}
	return 0;
}

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

int pot[200010];

int main()
{
    int n;
    cin >> n;
    int m;
    cin >> m;
    for(int i = 0; i < m; ++i){
        int a, b;
        cin >> a >> b;
        if(a == 1 || a == n){
            pot[b] ++;
            if(pot[b] == 2){
                cout << "POSSIBLE";
                return 0;
            }
        }
        if(b == 1 || b == n){
            pot[a] ++;
            if(pot[a] == 2){
                cout << "POSSIBLE";
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE";
    return 0;
}


Measured memory_bytes: 1024
class UnionFind:
    def __init__(self, n):
        self.par = [i for i in range(n)]
        self.rank = [0] * n
        
    def find(self, x):
        if self.par[x] == x:
            return x
        else:
            self.par[x] = self.find(self.par[x])
            return self.par[x]
        
    def union(self, x, y):
        xx = self.find(x)
        yy = self.find(y)
        if self.rank[xx] < self.rank[yy]:
            self.par[xx] = yy
        else:
            self.par[yy] = xx
            if self.rank[xx] == self.rank[yy]:
                self.rank[xx] += 1
        self.par[x] = self.find(x)
        self.par[y] = self.find(y)
                
    def same_check(self, x, y):
        return self.find(x) == self.find(y)
    
n, m = map(int, input().split())
union = UnionFind(n)

for _ in range(m):
    a, b, c = map(int, input().split())
    a -= 1
    b -= 1
    union.union(a, b)

for i in range(n):
    union.find(i)
print(len(set(union.par)))

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

count = 0
for idx, a in enumerate(A):
	food = a - 1
	count += B[food]
	if(idx < len(A) - 1 and A[idx] + 1 == A[idx+1]):
		count += C[food]
print(count)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <iomanip>
using namespace std;

int main(){
    double PI=3.14159265358979323846;
    double a;
    cin >> a;

    cout << std::fixed << std::setprecision(6) << PI * a * a <<  " " << 2 * PI * a << endl;
    return 0;
}


Measured memory_bytes: 3276
n,m = map(int,input().split())
x = []
y = []
z = []
for i in range(n):
    a,b,c = map(int,input().split())
    x.append([a,b,c])
    y.append([-1*a,-1*b,-1*c])


max = 0
for i in range(2):
    for j in range(2):
        for k in range(2):
            list = []
            sum = 0
            for l in range(n):
                if i == 1:
                    tmp1 = x[l][0]
                else:
                    tmp1 = y[l][0]
                if j == 1:
                    tmp2 = x[l][1]
                else:
                    tmp2 = y[l][1]
                if k == 1:
                    tmp3 = x[l][2]
                else:
                    tmp3 = y[l][2]
                list.append(tmp1+tmp2+tmp3)
            list.sort()
            for t in list[n-m:]:
                sum += t
            if sum > max:
                max = sum
print(max)


Measured memory_bytes: 3444
use std::cell::Cell;

const MOD: i32 = 1000000007;

fn main() {
	let mut s = String::new();
	use std::io::Read;
	std::io::stdin().read_to_string(&mut s).unwrap();
	let mut s = s.split_whitespace();
	let n: usize = s.next().unwrap().parse().unwrap();
	let mut edges = vec![vec![]; n];
	for _ in 0..n - 1 {
		let a = s.next().unwrap().parse::<usize>().unwrap() - 1;
		let b = s.next().unwrap().parse::<usize>().unwrap() - 1;
		edges[a].push(b);
		edges[b].push(a);
	}
	let tree = Tree::new(edges);
	tree.dfs();
	let y = tree.calc();
	let x = mod_pow(tree.two_power[n] as i64, MOD as u32 - 2, MOD as i64);
	println!("{}", y as i64 * x % MOD as i64);
}

struct Tree {
	edges: Vec<Vec<usize>>,
	children: Vec<Cell<u32>>,
	two_power: Vec<i32>,
}

impl Tree {
	fn new(edges: Vec<Vec<usize>>) -> Tree {
		let n = edges.len();
		let pow: Vec<_> = (0..n + 1)
			.scan(1, |s, _| {
				let a = *s;
				*s = a * 2 % MOD;
				Some(a)
			})
			.collect();
		Tree { edges: edges, children: vec![Cell::new(0); n], two_power: pow }
	}

	fn dfs(&self) {
		let mut q1 = vec![(0, std::usize::MAX)];
		let mut q2 = vec![];
		while let Some(p) = q1.pop() {
			q2.push(p);
			for e in self.edges[p.0].iter() {
				if *e == p.1 {
					continue;
				}
				q1.push((*e, p.0));
			}
		}
		while let Some(p) = q2.pop() {
			let mut c = 0;
			for e in self.edges[p.0].iter() {
				if *e == p.1 {
					continue;
				}
				c += self.children[*e].get() + 1;
			}
			self.children[p.0].set(c);
		}
	}

	fn calc(&self) -> i32 {
		let mut r = 0;
		let mut q1 = vec![(0, std::usize::MAX)];
		let mut q2 = vec![];
		while let Some(p) = q1.pop() {
			q2.push(p);
			for e in self.edges[p.0].iter() {
				if *e == p.1 {
					continue;
				}
				q1.push((*e, p.0));
			}
		}
		while let Some(p) = q2.pop() {
			let mut csum = 0;
			let mut pat = 0;
			for e in self.edges[p.0].iter() {
				if *e == p.1 {
					continue;
				}
				let c = self.children[*e].get() + 1;
				pat = (pat + self.two_power[c as usize] - 1) % MOD;
				csum += c;
			}
			let n = self.edges.len();
			pat = (pat + self.two_power[n - 1 - csum as usize] - 1 + 1) % MOD;
			pat = (self.two_power[n - 1] + MOD - pat) % MOD;
			r = (r + pat) % MOD;
		}
		r
	}
}

fn mod_pow(a: i64, n: u32, m: i64) -> i64 {
	let mut r = 1;
	let mut a = a;
	let mut n = n;
	while n > 0 {
		if n & 1 != 0 {
			r = r * a % m;
		}
		a = a * a % m;
		n >>= 1;
	}
	r
}


Measured memory_bytes: 34968
#include<bits/stdc++.h>
using namespace std;
int n,m,a[15],b[15];
char g[15][15];
bool check(int x)
{
	if(x>=m) return 1;
	if(~b[x]) return check(x+1);
	int tmp=0;
	for(int i=x;i<m;i++) tmp^=!(~b[i]);
	for(int i=x;i<m;i++) 
	{
		if(!(~b[i]))
		{
			b[i]=x;
			b[x]=i;
			bool flg=1;
			for(int j=0;j<n;j++) if(g[j][x]!=g[a[j]][i]) flg=0;
			if(i==x&&flg&&tmp&&check(x+1)) return 1;
			if(i!=x&&flg) return check(x+1);
			b[x]=b[i]=-1;
		}
	}
	return 0;
}
bool dfs(int x)
{
	if(x>=n) return check(0);
	if(~a[x]) return dfs(x+1);
	int tmp=0;
	for(int i=x;i<n;i++) tmp^=!(~a[i]);
	for(int i=x;i<n;i++)
	{
		if(!(~a[i]))
		{
			a[i]=x;
			a[x]=i;
			if((tmp||i!=x)&&dfs(x+1)) return 1;
			a[i]=a[x]=-1;
		}
	}
	return 0;
}
int main()
{
	cin>>n>>m;
	memset(a,-1,sizeof(a));
	memset(b,-1,sizeof(b));
	for(int i=0;i<n;i++) for(int j=0;j<m;j++) cin>>g[i][j];
	if(dfs(0)) puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PP;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
//#define INF 810114514
#define PI 3.141592653589
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE do { cout << "0" << endl; return 0; } while (false)
#define MM <<" "<<
#define Endl endl
#define debug false
#define debug2 false

vector<ll> inc(vector<ll> X){
    ll N = X.size();
    vector<ll> Y(N+1,0);
    REP(i,N){
        ll r = max(0ll,i-X[i]);
        Y[r]++;
        r = min(N,i+X[i]+1);
        Y[r]--;
    }
    REP(i,N){
        Y[i+1]+=Y[i];
    }
    Y.pop_back();
    return Y;
}

	
int main(void){
    int N,K,a;
    vector<ll> A;
    cin >> N >> K;
    REP(i,N){
        cin >> a;
        A.push_back(a);
    }
    vector<ll> fin(N,N);
    
    REP(i,K){
        A = inc(A);
        if(A==fin)break;
        /*
        REP(j,A.size()){
            cout << A[j] << " ";
        }cout << endl;
        */
    }
    REP(j,A.size()){
        cout << A[j] << " ";
    }cout << endl;
    
    return 0;
}



Measured memory_bytes: 9572
import sys
from collections import defaultdict
from heapq import *
sys.setrecursionlimit(10**8)

input = sys.stdin.readline

def main():
    """ main """
    N,D = map(int, input().split())
    if N % (2*D+1) == 0:
        print(N//(2*D+1))
    else:
        print(N//(2*D+1)+1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
def get_primes(n):
    is_prime = [True] * (n + 1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5) + 1):
        if not is_prime[i]:
            continue
        for j in range(i * 2, n + 1, i):
            is_prime[j] = False
    return [i for i in range(n + 1) if is_prime[i]]

def get_division(N, prime):
    counter = 0
    _prime = prime
    while _prime < N:
        counter += N // _prime
        _prime *= prime
    return counter

N = int(input())

primes = get_primes(N)

counter = 0
counter1 = 0
counter2 = 0
counter3 = 0
counter4 = 0
for prime in primes:
    if get_division(N, prime) >= 74:
        counter += 1
    if get_division(N, prime) >= 24:
        counter1 += 1
    if get_division(N, prime) >= 14:
        counter2 += 1
    if get_division(N, prime) >= 4:
        counter3 += 1
    if get_division(N, prime) >= 2:
        counter4 += 1

total = counter + (counter4 - 1) * counter1 + (counter3 - 1) * counter2 + \
        (counter4 - 2) * counter3 * (counter3 - 1) / 2
print(int(total))
        

Measured memory_bytes: 3316
//is there any case of -1 or any special corner cases ?
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define vi vector<int>
#define pi pair<int,int>
#define all(v) v.begin(),v.end()
#define zeros(arr) memset(arr,0,sizeof(arr));
#define precise(num)  cout<<fixed; cout << std::setprecision(num)
#define nl cout<<"\n";
#define test int t;cin>>t;while(t--) 
const int maxx  = 2*1e6 , limit = 9*1e18 , MOD=1e9+7;
string binary(int n){bitset<60>b(n) ;string p =b.to_string();return p;}
int decimal(string n) { int dec_value = 0;  int base = 1;  for (int i = n.size() - 1; i >= 0; i--) { if (n[i] == '1') 
dec_value += base; base = base * 2; } return dec_value; } 
bool isPrime(int n){if (n <= 1) return false; if (n <= 3) return true;if (n % 2 == 0 || n % 3 == 0) return false;
for (int i = 5; i * i <= n; i = i + 6) if (n % i == 0 || n % (i + 2) == 0) return false; return true; }
int pow (int x, int n,int mod) {if (n == 0) return 1; int res = pow (x, n / 2,mod);res = (res * res) % mod;if (n % 2) res = (res * x ) % mod;return res;}

#define boost  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define endl '\n';

int32_t main(){
  	char p;
  cin >> p;
  if(p >= 'A' && p <= 'Z'){
    	cout<<'A'<<endl;
   }
  else{
  	cout<<'a'<<endl;
  }
  
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
int main()
{
  long long int n,i;
  float s=0.0;
  cin>>n;
  long long int arr[n];
  for(i=0;i<n;i++)
  {
    cin>>arr[i];
  }
  for(i=0;i<n;i++)
  {
    s+=(float)1/arr[i];
  }
  //cout<<s<<endl;
  cout<<(float)(1/s)<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main
{
	public static void main(String arg[])
	{
		Scanner sc = new Scanner(System.in);
		while(sc.hasNext())
		{
			String str1 = sc.next();
			String str2 = sc.next();
			int hi=0;
			int bl=0;
			if(str1.equals("0")&&str2.equals("0"))
				return;
			for(int i=0; i<4; i++){
				if(str1.charAt(i)==str2.charAt(i))	
					hi++;
			}
			for(int i=0; i<4; i++)
				for(int j=0; j<4;j++)
					if(i==j)
						continue;
					else
						if(str1.charAt(i)==str2.charAt(j))
							bl++;

			System.out.println(hi+" "+bl);
		}
	}

}

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

using namespace std;

char c[8005];
int x,y;
int nx,ny;
int sx=10000,sy=10000;
int F[8005];
int dpx[8005][20005],dpy[8005][20005];
vector<int> X,Y;

int check_x(int x){

  if(nx==0){
    if(sx==x) return 1;
    else return 0;
  }

  dpx[0][sx-X[0]]=1;
  dpx[0][sx+X[0]]=1;

  for(int j=1; j<nx; j++){
    if(sx<=x){
      for(int i=sx; i<=x; i++){
        dpx[j][i]=dpx[j-1][i-X[j]]+dpx[j-1][i+X[j]];
      }
    }
    else{
      for(int i=sx; i>=x; i--){
        dpx[j][i]=dpx[j-1][i-X[j]]+dpx[j-1][i+X[j]];
      }
    }
  }

  return dpx[nx-1][x];

}

int check_y(int y){

  if(ny==0){
    if(sy==y) return 1;
    else return 0;
  }

  dpy[0][sy-Y[0]]=1;
  dpy[0][sy+Y[0]]=1;

  for(int j=1; j<ny; j++){
    if(sy<=y){
      for(int i=sy; i<=y; i++){
        dpy[j][i]=dpy[j-1][i-Y[j]]+dpy[j-1][i+Y[j]];
      }
    }
    else{
      for(int i=sy; i>=y; i--){
        dpy[j][i]=dpy[j-1][i-Y[j]]+dpy[j-1][i+Y[j]];
      }
    }
  }

  return dpy[ny-1][y];

}

int main() {

cin.tie(0);
ios::sync_with_stdio(false);

cin>>c>>x>>y;

string s=c; int n=s.size();

int j=0; 

for(int i=0; i<n; i++){
  if(c[i]=='T'){
    j++;
  }
  if(c[i]=='F'){
    F[j]++;
  }
}

for(int i=0; i<=j; i++){
  if(i%2==0){
    if(F[i]){
      if(i==0) continue;
      X.push_back(F[i]);
    }
  }else{
    if(F[i]){
      Y.push_back(F[i]);
    }
  }
}

x=x+sx; y=y+sy;

sx+=F[0]; 

nx=X.size(); ny=Y.size(); 

if(check_x(x)&&check_y(y)) cout<<"Yes"<<endl;
else cout<<"No"<<endl;


//cout<<x<<endl;
//cout<<dpx[nx-1][x]<<endl;
//cout<<X[0]<<endl;

}


Measured memory_bytes: 313984
#include <bits/stdc++.h>
#define all(x) begin(x), end(x)
#define dbg(x) cerr << #x << " = " << x << endl
#define _ << ' ' <<
using namespace std;
using ll = long long;
using vi = vector<int>;

int n, k, v[50], dp[50][50][100];

int g(int p, int q, int r)
{
    vector<int> x;
    for (int i = 0; i < p; ++i)
        x.push_back(v[i]);
    for (int i = n - 1; i > q; --i)
        x.push_back(v[i]);
    sort(all(x));
    int sum = accumulate(all(x), 0);
    for (int i = 0; i < r && i < x.size() && x[i] < 0; ++i)
        sum -= x[i];
    return sum;
}

int f(int p, int q, int r)
{
    if (r == k || p > q) return g(p, q, k - r);
    if (dp[p][q][r] != -1) return dp[p][q][r];
    int sol = g(p, q, k - r);
    if (p <= q)
    {
        sol = max(sol, f(p + 1, q, r + 1));
        sol = max(sol, f(p, q - 1, r + 1));
    }
    return dp[p][q][r] = sol;
}

int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cin >> n >> k;
    for (int i = 0; i < n; ++i)
        cin >> v[i];

    memset(dp, -1, sizeof dp);
    cout << f(0, n - 1, 0);
}


Measured memory_bytes: 1280
#include <iostream>

using namespace std;

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

int main(){
  int m, d, d1 = 0, d2 = 0, cnt = 0;
  cin >> m >> d;
  
  rep(i, m) {
  	rep(j, d) {
  		d1 = j / 10;
  		d2 = j % 10;
  		if (d1 >= 2 && d2 >= 2 && d1 * d2 == i) {
  			++cnt;
  		}
  	}
  }
  cout << cnt << endl;
}

Measured memory_bytes: 256
# https://atcoder.jp/contests/abc117/tasks/abc117_d
=begin
3 7
1 6 3

14

4 9
7 4 0 3

46

1 0
1000000000000

1000000000000
=end
N, upper_bit = gets.split.map(&:to_i)
A = gets.split.map(&:to_i)
beki_ary = (1..39).to_a.each_with_object([1]) { |i, obj| obj << (obj.last * 2)}
already_min = false

ans = 0
39.step(0, -1) do |digest|
  ones = A.count { |str| str[digest] == 1 }
  if ones * 2 >= N
    already_min = true if upper_bit[digest] == 1
    ans += beki_ary[digest] * ones
  else
    if already_min || (upper_bit[digest] == 1)
      ans += beki_ary[digest] * (N - ones)
    else
      ans += beki_ary[digest] * ones
    end
  end
end
p ans


Measured memory_bytes: 8844
#include<iostream>
using namespace std;
int main(){
	int n;
	int i,j,k;
	int s=4000000;
	int a[105];
	cin>>n;
	for(i=0;i<n;i++){
		cin>>a[i];
	}
	for(i=-100;i<=100;i++){
		k=0;
		for(j=0;j<n;j++){
			k+=(a[j]-i)*(a[j]-i);
		}
		if(s>k)s=k;
	}
	cout<<s<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int H, N; cin >> H >> N;
  vector<int> A(N + 1, 0);
  vector<int> B(N + 1, 0);
  REP(i, N){
    cin >> A[i+1] >> B[i+1];
  }
  vector<vector<int> > dp(N+1, vector<int>(H+1, 1e9));
  dp[0][0] = 0;
  REP(i, N){
    REP(j, H + 1){
      dp[i+1][j] = min(dp[i][j], dp[i+1][max(0, j-A[i+1])] + B[i+1]);
    }
  }
  cout << dp[N][H] << endl;
}

Measured memory_bytes: 39424
#include <bits/stdc++.h>
#include <boost/multiprecision/cpp_int.hpp>

using namespace std;
using namespace boost::multiprecision;

#define REP(i, n) for (long long i = 0; i < (long long)(n); i++)
#define REPI(i,a,b) for(int i=int(a);i<int(b);++i)
#define ALL(x) (x).begin(),(x).end()
inline cpp_int between(cpp_int n, cpp_int x) {
  if(n >= 0)
    return (n/x)+1;
  else
    return 0;
}

int main () {
  string s;
  long long k;

  cin >> s >> k;

  int one_pos = 0;
  REP(i, k) {
    if(s[i] != '1') {
      one_pos = i;
      break;
    }
  }

  cout << s[one_pos] << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
const int N = 2e5+1;
ll fac[N],inv[N];
const ll mod = 1e9+7;
ll binpow(ll x,ll pow)
{
	ll res=1ll;
	while(pow)
	{
		if(pow&1)	res=res*x%mod;
		x=x*x%mod;
		pow/=2;
	}
	return res;
}
void build()
{
	int i;
	fac[0]=1ll;
	for(i=1;i<N;++i)	fac[i] = 1ll*fac[i-1]*i%mod;
	inv[N-1]=binpow(fac[N-1],mod-2);
	for(i=N-2;i>=0;i--)	inv[i] = 1ll*inv[i+1]*(i+1)%mod;
}
ll nCk(int n,int k)
{
	return 1ll*fac[n]*inv[k]%mod*inv[n-k]%mod;
}
int main()
{
	build();
	int i,r,c,a,b;
	scanf("%d %d %d %d",&r,&c,&a,&b);
	ll n[r-a];
	for(i=0;i<r-a;++i)
	{
		n[i] = nCk(i+b-1,b-1);
		if(n[i]==0)		n[i]=1;
	}
	ll ans = 0ll;
	for(i=0;i<r-a;i++)
	{
		ans = (ans + n[i]*nCk(r-i-1+c-b-1,r-i-1) %mod)%mod;
	}
	printf("%lld",ans);
}

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

static const int N = 100;

int main() {
	int n;
	int p[N + 1], m[N + 1][N + 1];
	cin >> n;
	for (int i = 1; i <= n; i++) {
		cin >> p[i - 1] >> p[i];
	}

	for (int i = 0; i <= n; i++)m[i][i] = 0;
	for (int l = 2; l <= n; l++) {
		for (int i = 1; i <= n - l + 1; i++) {
			int j = i + l - 1;
			m[i][j] = (1 << 21);
			for (int k = i; k <= j - 1; k++) {
				m[i][j] = min(m[i][j], m[i][k] + m[k + 1][j] + p[i - 1] * p[k] * p[j]);
			}
		}
	}
	cout << m[1][n] << endl;

	return 0;



}


Measured memory_bytes: 3108
import sys
ns = lambda: sys.stdin.readline().rstrip()
ni = lambda: int(ns())
nm = lambda: map(int, sys.stdin.readline().split())
nl = lambda: list(nm())

n = ni()

a = [ni() for _ in range(n)]
count = 0
nexti = 0
for i in range(n):
    if nexti == 1:
        print(count)
        exit()
    else:
        nexti = a[nexti] - 1
        count += 1
print(-1)


Measured memory_bytes: 7084
/*
Please Chant The Holy Name Of Lord Krisna(The Supreme Personality Of Godhead)

      "Hare Krisna Hare Krisna Krisna Krisna Hare Hare
       Hare Rama Hare Rama Rama Rama Hare Hare ......."

Surrender yourself to the Lotus Feet of Krisna, serve devotees and Srila Prabhupada
*/

//13-9-20
#include <bits/stdc++.h>

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long
#define pb emplace_back
#define sz(s) (int)s.size()
#define all(v)                            v.begin(),v.end()
#define fr(i,n)                           for(int i=0;i<n;i++)
#define fr1(i,n)                          for(int i=1;i<=n;i++)
#define fro(i,a,b)                        for(int i=a;i<=b;i++)
#define d(a)                              cout << #a << " : " << a << " ";
#define dl(a)                             cout<< #a <<" : " << a << endl;
#define print(v)  for(auto x : v)         {cout<<x<<" ";   }  cout<<endl;
#define PRINT(v)  for(auto x : v)         {cout<<x.first<<" "<<x.second<<endl;}
#define TEST                              int tc;cin>>tc; while(tc--)

using namespace std;

const int MOD = 1e9+7;
const int INF = 1e9+8;
const double pi = 3.14159265359;

int binpow(int a, int b)
{
    a %= MOD;
    int res = 1;
    while (b > 0)
    {
        if (b & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        b >>= 1;
    }
    return res%MOD;
}

void solve()
{
    // Can you solve it by brute force?
    // kkp
    // Are you sure you want to code so soon?? -_-
    // Simplify your code a little more. :)

    int n;
    cin >> n;

    int ans = binpow(10, n) - 2*binpow(9, n) + binpow(8,n) ;
    ans %= MOD;
    ans += MOD;
    ans %= MOD;

    cout << ans << endl;

}

int32_t main()
{
    //IOS;

    //TEST
    solve();

    return 0;
}



Measured memory_bytes: 3612
arr=[int(x) for x in input().split()]
if(arr[0]< arr[2]):
    if(arr[2]<=arr[1]<=arr[3]):
        print(arr[1]-arr[2])
    elif(arr[1]<arr[2]):
        print('0')
    else:
        print(arr[3]-arr[2])
else:
    if(arr[0]<=arr[3]<=arr[1] ):
        print(arr[3]-arr[0])
    elif(arr[3]<arr[0]):
        print('0')
    else:
        print(arr[1]-arr[0])


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template <size_t I, class H, class... T> struct TupleReaderWriter{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple_cat(tuple<H>(v),TupleReaderWriter<sizeof...(T)-1,T...>::r(i));}static void w(ostream&o,tuple<H,T...>&t,string d){TupleReaderWriter<I-1,H,T...>::w(o,t,d);o<<d<<get<I>(t);}};
template <class H, class... T> struct TupleReaderWriter<0,H,T...>{static tuple<H,T...> r(istream&i){H v;i>>v;return tuple<H>(v);}static void w(ostream&o,tuple<H,T...>&t,string d){o<<get<0>(t);}};
template<class T>istream&operator>>(istream&i,vector<T>&v){for(auto&x:v)i>>x;return i;}
template<class T>ostream&operator<<(ostream&o,vector<T>&v){string delim="";for(auto&x:v)o<<delim<<x,delim=" ";return o;}
template <class... T> istream& operator>>(istream&i,tuple<T...>& t) { t = TupleReaderWriter<sizeof...(T), T...>::r(i); return i; }
template <class... T> ostream& operator<<(ostream& o, tuple<T...>& t) { string delim = " "; TupleReaderWriter<sizeof...(T) - 1, T...>::w(o, t, delim); return o; }
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
const i64 MOD = 1e9 + 7;
// O(log a)
int64_t powmod(int64_t a, int64_t p) {
    int64_t value = 1;
    for(int64_t mul = a; p > 0; p >>= 1, mul = (mul * mul) % MOD) {
        if(p & 1) value = (value * mul) % MOD;
    }
    return value;
}

int64_t invmod(int64_t x) {
    return powmod(x, MOD - 2);
}

struct Factorial {
    vector<int64_t> val;
    vector<int64_t> inv;
};

// O(N)
Factorial GetFact(int N) {
    N++;
    Factorial fact;
    fact.val = vector<int64_t>(N);
    fact.inv = vector<int64_t>(N);
    fact.val[
        0
    ] = 1;
    for(int i = 1; i < N; i++) {
        fact.val[i
        ] = int64_t(fact.val[i - 1
        ] * i) % MOD;
    }
    fact.inv[
        0
    ] = 1;
    fact.inv[N - 1
    ] = powmod(fact.val[N - 1
    ], MOD - 2);
    for(int i = N - 1; i > 0; i--) {
        fact.inv[i - 1
        ] = int64_t(fact.inv[i
        ] * i) % MOD;
    }
    return fact;
}

int64_t Permutation(int n, int m, const Factorial &f) {
    if(n < m || m < 0 || n < 0) return 0;
    return (f.val[n] * f.inv[n - m]) % MOD;
}

int64_t Combination(int n, int m, const Factorial &f) {
    if(n < m || m < 0 || n < 0) return 0;
    return ((f.val[n] * f.inv[m] % MOD) * f.inv[n - m]) % MOD;
}

int main() {
    i64 X, Y, N;
    cin >> X >> Y;
    N = X + Y;
    if(N % 3 != 0) {
        cout << 0 << endl;
        return 0;
    }
    N /= 3;
    X -= N, Y -= N;
    if(X < 0 || Y < 0) {
        cout << 0 << endl;
        return 0;
    }
    Factorial f = GetFact(3e6);
    i64 ans = Combination(X + Y, X, f);
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 47104
#include <bits/stdc++.h>
using namespace std;
#define array_input int n;cin>>n;int a[n+1],i;for(i=1;i<=n;i++){cin>>a[i];}
#define array_output for(i=1;i<=n;i++){cout<<a[i]<<" ";}cout<<endl;
#define INF 2147483647
#define long_INF 18446744073709551615
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef long double ld;
const double pi=acos(-1);
const double eps=1e-6;

void read(int &x)
{
    x=0;
	char c=getchar();
    while(c<'0' || c>'9')c=getchar();
    while(c>='0' && c<='9')
	{
        x=x*10+c-'0';
        c=getchar();
    }
}

void write(int x)
{
    if(x==0)
	{
		putchar(48);
		return;
	}
    int len=0,dg[20];
    while(x>0)
	{
		dg[++len]=x%10;
		x/=10;
	}
    for(int i=len;i>=1;i--)
	{
		putchar(dg[i]+48);
	}
}

int main()
{
	string s;
	cin>>s;
	int f1=0,f2=0,f3=0;
	for (int i=0;i<=s.size();i++)
	{
		if (s[i]=='a')
		{
			f1=1;
		}
		if (s[i]=='b')
		{
			f2=1;
		}
		if (s[i]=='c')
		{
			f3=1;
		}
	}
	if (f1==1 && f2==1 && f3==1)
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
	return 0;
}

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

int main()
{
    int A, B;
    std::cin >> A >> B;

    if (B % A == 0)
    {
        std::cout << A + B << std::endl;
    }
    else
    {
        std::cout << B - A << std::endl;
    }

    return 0;
}

Measured memory_bytes: 256
zero_nine = (0..9).to_a
while gets
  n,s = $_.chomp.split.map{|x| x.to_i}
  break if n == 0 && s == 0
  count = 0
  zero_nine.combination(n) do |x|
    count += 1 if x.reduce{|sum,p| sum+p} == s
  end
  puts count
end

Measured memory_bytes: 6100