akhauriyash/Code-Regression huggingface dataset:
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = Integer.parseInt(sc.next());
        int[][] a = new int[n - 1][3];
        for (int i = 0; i < n - 1; i++) {
            int c = Integer.parseInt(sc.next());
            int s = Integer.parseInt(sc.next());
            int f = Integer.parseInt(sc.next());
            a[i][0] = c;
            a[i][1] = s;
            a[i][2] = f;
        }
        StringBuilder sb = new StringBuilder();
        for (int i = 0; i < n; i++) {
            int temp = 0;
            for (int j = i; j < n - 1; j++) {
                if (temp > a[j][1]) {
                    if (temp % a[j][2] != 0) {
                        temp += a[j][2] - temp % a[j][2] + a[j][0];
                    } else {
                        temp += a[j][0];
                    }
                } else {
                    temp = a[j][0] + a[j][1];
                }
            }
            sb.append(temp + "\n");
        }
        System.out.println(sb.toString());
    }
}

Measured memory_bytes: 23764
import math
from functools import reduce

def gcd(*numbers):
    return reduce(math.gcd, numbers)

k = int(input())
sum = 0
for i in range(1,k+1):
    for j in range(1,k+1):
        for l in range(1,k+1):
            sum += gcd(i,j,l)
print(sum)

Measured memory_bytes: 74812
#include <iostream>
using namespace std;
int main(void){
    int a,b,c,d,e,f,m,n,z=0;
    double r=0;
    cin>>a>>b>>c>>d>>e>>f;
    for(int i=0;i*a*100<=f;i++){
        for(int j=0;i*a*100+j*b*100<=f;j++){
            if(i+j>0){
                for(int k=0;i*a*100+j*b*100+c*k<=f;k++){
                    for(int l=0;i*a*100+j*b*100+c*k+d*l<=f;l++){
                        if(c*k+d*l<=(i*a+j*b)*e){
                            double g =100*(c*k+d*l);
                            double h = i*a*100+j*b*100+c*k+d*l;
                            if(g/h>=r){
                                r=g/h;
                                m=i*a*100+j*b*100+c*k+d*l;
                                n=c*k+d*l;
                            }
                        }
                    }
                }
            }
        }
    }
    cout<<m<<" "<<n<<endl;
}


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

using namespace std;
using ll = long long;

int main() {
	const ll MOD = 1e9 + 7;
	int N;
	cin >> N;
	string s;
	cin >> s;

	vector<vector<ll>> d(N, vector<ll>(26, 0));
	d[0][(int)(s[0] - 'a')] = 1;
	for (int i = 1; i < N; ++i) {
		int idx = s[i] - 'a';
		d[i][idx] += 1;
		for (int j = 0; j < 26; ++j) {
			d[i][j] = (d[i][j] + d[i - 1][j]) % MOD;
		}
	}

	ll res = 0;
	for (int i = 0; i < N; ++i) {
		ll tmp = 1;
		int idx = s[i] - 'a';
		for (int j = 0; j < 26; ++j) {
			if (j == idx) { continue; }
			tmp = (tmp * (d[N - 1][j] - d[i][j] + 1)) % MOD;
		}
		res = (res + tmp) % MOD;
	}

	cout << res % MOD << endl;

	return 0;
}


Measured memory_bytes: 24576
#include <stdio.h>
#include <math.h>
#define pai 3.14159265
int main(void){
	int rad;
	int n_rad = 0;
	int n;
	double p[2] = {0,0};
	
	while(1){
		scanf("%d,%d",&n,&rad);
		if(n == 0&&rad == 0)break;
		p[0] += cos(n_rad*pai/180)*n;
		p[1] += sin(n_rad*pai/180)*n;
		n_rad += rad;
	}
	printf("%d\n%d\n",(int)p[1],(int)p[0]);
	
	return 0;
}

Measured memory_bytes: 604
#include <bits/stdc++.h>
using Int = int64_t;
using UInt = uint64_t;
using C = std::complex<double>;
#define rep(i, n) for(Int i = 0; i < (Int)(n); ++i)
#define guard(x) if( not (x) ) continue;

template<typename T>
using RQ = std::priority_queue<T, std::vector<T>, std::greater<T>>;

int main() {
   Int v, e, r;
   std::cin >> v >> e >> r;
   std::vector<Int> ss(e), ts(e), ds(e);
   rep(i, e) std::cin >> ss[i] >> ts[i] >> ds[i];
   std::vector<std::vector<Int>> edges(v);
   rep(i, e) edges[ss[i]].emplace_back(i);
   std::vector<Int> xs(v);
   std::vector<bool> ys(v);
   ys[r] = true;
   RQ<std::pair<Int,Int>> q;
   q.emplace(0, r);
   while( not q.empty() ) {
      Int x, s; std::tie(x, s) = q.top(); q.pop();
      guard( x == xs[s] );
      for(Int k : edges[s]) {
         Int t = ts[k], d = ds[k];
         guard( ys[t] == false or x + d < xs[t] );
         xs[t] = x + d;
         ys[t] = true;
         q.emplace(x + d, t);
      }
   }
   rep(i, v) {
      if( not ys[i] ) {
         puts("INF");
      }
      else {
         printf("%ld\n", xs[i]);
      }
   }
}

Measured memory_bytes: 25848
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>
#include <bitset>
#include <iomanip>

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

using namespace std;

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


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  vector<string> C(2);
  repeat(i,2)cin>>C[i];
  bool isok=true;
  repeat(j,3){
    isok&=C[0][j]==C[1][2-j];
  }
  cout<<(isok? "YES":"NO")<<endl;
  return 0;
}


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

int n;

int dfs(string s) {
    int ret = 0;
    if (stol(s) > n) return 0;
    if (s.find("3") != string::npos && s.find("5") != string::npos && s.find("7") != string::npos) ret = 1;
    ret += dfs(s + "3");
    ret += dfs(s + "5");
    ret += dfs(s + "7");
    return ret;
}

int main(void){
    cin >> n;
    
    cout << dfs("0") << endl;


}


Measured memory_bytes: 256
#include<stdio.h>

#define ZERO 0
#define NINE 9

int main()
{
	int num,a,b,c,d,sum;
	while(~scanf("%d",&num)){
		sum = 0;
		for(a=ZERO;a<=NINE;a++){
			for(b=ZERO;b<=NINE;b++){
				for(c=ZERO;c<=NINE;c++){
					for(d=ZERO;d<=NINE;d++){
						if(a+b+c+d == num){
							sum++;
						}
					}
				}
			}
		}
		printf("%d\n",sum);
	}
	return 0;
}


Measured memory_bytes: 2044
#include <iostream>
#include <string>
#define REP(i,k,n) for(int(i)=(k);(i)<(n);++(i))
using namespace std;

int main()
{
  int a,b,c;
  cin >> a >> b >> c;
  string ans;
  if (b - a == c - b) ans = "YES";
  else ans = "NO";
  cout << ans << endl;

  return 0;
}


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

using namespace std;
int32_t main()
{
 long long n;cin>>n;long long k;cin>>k;;
 long long a[n];
 for(long long i=0;i<n;i++){
  cin>>a[i];
 }
 long long dp[n];
 dp[n-1]=0;
 dp[n-2]=abs(a[n-1]-a[n-2]);

 for(long long i=(n-3);i>=0;i--){
  long long res=INT_MAX;
  long long lim=i+k+1;
  for(long long j=i+1;j<min(n,lim);j++){
   long long pos=abs(a[i]-a[j])+dp[j];
   res=min(res,pos);
  }
  dp[i]=res;
 }

 cout<<dp[0]<<endl;
 return 0;
}


Measured memory_bytes: 5180
#include <bits/stdc++.h>
    using namespace std;
    #define rep(i,a,b) for(int i =a; i<b;++i)
    #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    #define endl "\n"
    typedef   long long int ll;
    //int dp[100005];
    const int N = 4e5+5;
    const int mod = 998244353;
    ll cnt[N],a[N],n,I,temp[N],q,first,x[N],payload[N];

int main()
{
    IOS;
    int t = 1;
   // cin>>t ;
    while(t--)
    {
        cin>>n;
        if(n<=9)
            cout<<n;
        else if(n>9 && n<=99)
        {
            cout<<9;
        }
        else if(n>=100 && n<=999)
            cout<<n-100+1+9;
        else if(n>=1000 && n<=9999)
            cout<<909;
        else if(n>=(int)1e4 && n<=99999)
        {
            cout<<n-(int)1e4+909+1;
        }
        else
            cout<<90909;
    }
}


Measured memory_bytes: 2304
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x) (x).begin(), (x).end()
#define rep(i, s, n) for (i64 i = (s), i##_limit = (n); i < i##_limit; ++i)
#define repr(i, s, t) for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(type, ...) \
    type __VA_ARGS__;  \
    read(__VA_ARGS__);
#ifndef DBG
#define dump(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U>
inline bool chmax(T &a, const U &b) {
    return b > a && (a = b, true);
}
template <class T, class U>
inline bool chmin(T &a, const U &b) {
    return b < a && (a = b, true);
}
constexpr int INF = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> makeV(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}

template <class T, class... Args>
inline auto makeV(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(makeV<T>(initValue, args...))>(
        sz, makeV<T>(initValue, args...));
}

template <class T>
inline istream &operator>>(istream &is, vector<T> &vec) {
    for (auto &e : vec) is >> e;
    return is;
}

inline void read() {}

template <class Head, class... Tail>
inline void read(Head &head, Tail &... tail) {
    cin >> head;
    read(tail...);
}

inline void print() { cout << "\n"; }

template <class Head, class... Tail>
inline void print(Head &&head, Tail &&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream &operator<<(ostream &os, const vector<T> &vec) {
    static constexpr const char *delim[] = {" ", ""};
    for (const auto &e : vec) os << e << delim[&e == &vec.back()];
    return os;
}

template <class Container>
struct Rev {
    Container &x_;
    inline Rev(Container &x) : x_(x) {}
    inline auto begin() { return rbegin(x_); }
    inline auto end() { return rend(x_); }
};
// }}} End Header

signed main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    var(int, N);
    vector<int> a(N);
    read(a);

    i64 ans = 0;
    rep(i, 1, N) { ans += max(0, a[i] - a[i - 1]); }
    print(ans + a[0]);

    return 0;
}


Measured memory_bytes: 256
#line 2 "header.hpp"

//%snippet.set('header')%
//%snippet.fold()%
#ifndef HEADER_H
#define HEADER_H

// template version 2.0
using namespace std;
#include <bits/stdc++.h>

// varibable settings
const long long INF = 1e18;
template <class T> constexpr T inf = numeric_limits<T>::max() / 2.1;

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for (ll i = (ll)(a); i < (ll)(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
#define _rrep(i, n) rrepi(i, 0, n)
#define rrepi(i, a, b) for (ll i = (ll)((b)-1); i >= (ll)(a); --i)
#define r_rep(...) _overload3(__VA_ARGS__, rrepi, _rrep, )(__VA_ARGS__)
#define each(i, a) for (auto &&i : a)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((int)(x).size())
#define pb(a) push_back(a)
#define mp(a, b) make_pair(a, b)
#define mt(...) make_tuple(__VA_ARGS__)
#define ub upper_bound
#define lb lower_bound
#define lpos(A, x) (lower_bound(all(A), x) - A.begin())
#define upos(A, x) (upper_bound(all(A), x) - A.begin())
template <class T> inline void chmax(T &a, const T &b) { if ((a) < (b)) (a) = (b); }
template <class T> inline void chmin(T &a, const T &b) { if ((a) > (b)) (a) = (b); }
template <typename X, typename T> auto make_table(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_table(X x, Y y, Z z, Zs... zs) { auto cont = make_table(y, z, zs...); return vector<decltype(cont)>(x, cont); }

#define cdiv(a, b) (((a) + (b)-1) / (b))
#define is_in(x, a, b) ((a) <= (x) && (x) < (b))
#define uni(x) sort(all(x)); x.erase(unique(all(x)), x.end())
#define slice(l, r) substr(l, r - l)

typedef long long ll;
typedef long double ld;
using vl = vector<ll>;
using vvl = vector<vl>;
using pll = pair<ll, ll>;

template <typename T>
using PQ = priority_queue<T, vector<T>, greater<T>>;
void check_input() { assert(cin.eof() == 0); int tmp; cin >> tmp; assert(cin.eof() == 1); }

#if defined(PCM) || defined(LOCAL)
#else
#define dump(...) ;
#define dump_1d(...) ;
#define dump_2d(...) ;
#define cerrendl ;
#endif

#endif /* HEADER_H */
//%snippet.end()%
#line 2 "solve.cpp"
template<class T=ll> using vec = vector<T>;
struct Fast { Fast() { std::cin.tie(0); ios::sync_with_stdio(false); } } fast;


int solve() {
    vl x(3);
    rep(i, 3)cin>>x[i];
    sort(all(x));

    ll a = x[2] - x[0];
    ll b = x[2] - x[1];
    if ((a+b)%2==0){
        cout << (a+b)/2 << endl;
    }
    else{
        cout << (a+b+3)/2 << endl;
    }

    return 0; 
}


int main(){/*{{{*/
    solve();
    check_input();
    return 0;
}/*}}}*/


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

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int s;
    cin >> s;
    
    //string yy = "" + s[0] + s[1];
    //string mm = "" + s[2] + s[3];

    int y = s / 100;
    int m = s - y*100;

    if(0 < y && y < 13 && 0 < m && m < 13){
        cout << "AMBIGUOUS" << endl;
        return 0;
    }else if(0 < y && y < 13){
        cout << "MMYY" << endl;
        return 0;
    }else if(0 < m && m < 13){
        cout << "YYMM" << endl;
        return 0;
    }
    cout << "NA" << endl;

    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
class Main{
	public static void main(String[] args){
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int[] A = new int[N];
		System.out.print(A[0] = scan.nextInt());
		for(int i = 1; i < N; i++){
			System.out.print(" " + (A[i] = scan.nextInt()));
		}System.out.println();
		for(int i = 1; i < N; i++){
			int key = A[i];
			int j = i - 1;
			while(j >= 0 && A[j] > key){
				A[j + 1] = A[j];
				j--;
			}
			A[j + 1] = key;
			System.out.print(A[0]);
			for(int k = 1; k < N; k++){
				System.out.print(" " + A[k]);
			}System.out.println();
		}
	}
}

Measured memory_bytes: 24256
#include<bits/stdc++.h>
using namespace std ; 
typedef long long ll;
#define forn(i,e) for(ll i=0; i<e; i++)
#define fors(i,e) for(ll i=s; i<e; i++)
#define endl "\n"
#define zoom ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define PB push_back 
#define MP make_pair
#define F first
#define S second


int main()
{

zoom;

ll x , y ; cin >> x >> y ; 

ll temp = (4*x) - y ; 

if(temp >=0 && temp % 2 ==0)
{
	if(temp/2 > x)
		cout << "No " ;
	else
	cout << "Yes " ;

} 
else 
cout << "No " ; 
}

Measured memory_bytes: 3624
#include<bits/stdc++.h>
#define ll long long int
#define ull unsigned long long 
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define pb push_back 
#define mp make_pair
#define inf 2000000009
#define mod 1000000007
using namespace std;


int main()
{ 
  
ll n; 
cin>>n;

string s;
cin>>s;

bool f=1;

if(s.size()%2)
f=0;

else
{
  ll k=s.size()/2;
  for(ll i=0;i<k;i++)
    if(s[i]!=s[i+k])
      f=0;
}
if(f)
cout<<"Yes"<<endl;
else cout<<"No"<<endl;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
using namespace std;
vector<int> MAX(vector<int> v1, vector<int> v2) {
	int s1 = 0, s2 = 0;
	for(int i = 0; i < v1.size(); i++) s1 += v1[i];
	for(int i = 0; i < v2.size(); i++) s2 += v2[i];
	if(s1 > s2) return v1;
	return v2;
}
int n, x, m, l[10], r[10], s[10]; vector<int> ret, v;
void rec() {
	if(v.size() == n) {
		for(int i = 0; i < m; i++) {
			int sum = 0;
			for(int j = l[i] - 1; j < r[i]; j++) sum += v[j];
			if(sum != s[i]) return;
		}
		ret = MAX(ret, v); return;
	}
	v.push_back(-1);
	for(int i = 0; i <= x; i++) v.back()++, rec();
	v.pop_back();
}
int main() {
	scanf("%d%d%d", &n, &x, &m);
	for(int i = 0; i < m; i++) scanf("%d%d%d", &l[i], &r[i], &s[i]);
	rec();
	if(ret.size() == 0) printf("-1\n");
	else {
		for(int i = 0; i < n; i++) {
			if(i) printf(" ");
			printf("%d\n", ret[i]);
		}
	}
}

Measured memory_bytes: 3268
#include <bits/stdc++.h>
 
//#include <unistd.h>
//#include <iostream>
 
using namespace std;
 
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl;
#define DEBUG_MAT(v) cerr<<#v<<endl;for(int i=0;i<v.size();i++){for(int j=0;j<v[i].size();j++) {cerr<<v[i][j]<<" ";}cerr<<endl;}
typedef long long ll;
//#define int ll
 
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
template<class S, class T> pair<S, T> operator+(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first + t.first, s.second + t.second); }
template<class S, class T> pair<S, T> operator-(const pair<S, T> &s, const pair<S, T> &t) { return pair<S, T>(s.first - t.first, s.second - t.second); }
template<class S, class T> ostream& operator<<(ostream& os, pair<S, T> p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
#define X first
#define Y second
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define rrep(i,n) for(int i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(int i=(n);i>0;i--)
#define REP(i,a,b) for(int i=a;i<b;i++)
#define in(x, a, b) (a <= x && x < b)
#define all(c) c.begin(),c.end()
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; }
#define UNIQUE(v) v.erase(std::unique(v.begin(), v.end()), v.end());
const ll inf = 1000000001;
const ll INF = (ll)1e18 + 1;
const long double pi = 3.1415926535897932384626433832795028841971L;
#define Sp(p) cout<<setprecision(25)<< fixed<<p<<endl;
//int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
//int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };
vi dx = {1, 0, -1, 0}, dy = {0, 1, 0, -1};
vi dx2 = { 1,1,0,-1,-1,-1,0,1 }, dy2 = { 0,1,1,1,0,-1,-1,-1 };
#define fio() cin.tie(0); ios::sync_with_stdio(false);
const ll MOD = 1000000007;
//const ll MOD = 998244353;
// #define mp make_pair
//#define endl '\n'

signed main() {
	fio();
	int n, r;
	cin >> n >> r;
	if (n >= 10) {
		cout << r << endl;
	}
	else {
		cout << r + 100 * (10 - n) << endl;
	}
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int check(int a, int b) {
    int k = 0;
    while (a != 0)
    {
        if (a % 10 == b)
        {
            k++;
            break;
        }
        a /= 10;
    }
    if (k == 0) return 1;
    else return 0;
}
int main() {
    int k, n, m;
    cin >> n >> k;
    int d[k];
    for (int i = 0; i < k; ++i)
        cin >> d[i];
    for (int i = n; i < 100000; ++i)
    {
        m = 0;
        for (int j = 0; j < k; ++j)
        {
            if (check(i, d[j]) == 0)
            {
                m++;
                break;
            }
        }
        if (m == 0)
        {
            cout << i;
            break;
        }
    }
}

Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
using Int = int_fast64_t;

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n, k; cin >> n >> k;
	int cnt = 0;
	while(n > 0){
		++cnt;
		n /= k;
	}
	cout << cnt << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ull unsigned long long int
#define ld long double
#define mod 1000000007
#define FT() int t; scanf("%d",&t); while(t--)
#define pb push_back
#define nl printf("\n")
#define fi(i,start,end) for(int i=start; i < (int)end ; ++i)
#define ip(n)   scanf("%d",&n)
#define mz(a)   memset(a,0,sizeof(a))
#define inpArr(A,n) fi(i,0,n)   ip(A[i]);
#define print(a)  for(auto i : a)   cout<<i<<" "; nl;
#define Fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
using namespace std;
ll max(ll a,ll b)   {return a>b?a:b;}
ll min(ll a,ll b)   {return a<b?a:b;}

int main() {
    #ifndef ONLINE_JUDGE
    freopen("D:/Sublime/Rough/input.txt","r",stdin);
    #endif
    //std::cout << std::fixed;
    //std::cout << std::setprecision(6);
    Fastio;
    
    int n;
    cin>>n;
    ll c = 0 ;
    for(int a = 1 ; a<= n;  a ++)
    {
        for(int b = 1 ; b<=n ; b++)
        {
            if(a*b >= n)
                break;
            c++;
        }
    }
    cout<<c<<"\n";

    #ifndef ONLINE_JUDGE
    cout<<"\nTime Elapsed : " << 1.0*clock() / CLOCKS_PER_SEC << " s";
    #endif
    
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define endl '\n'
#define ALL(V) V.begin(),V.end()
template <typename T> using V = vector<T>;
template <typename T> using VV = V<V<T>>;

class StronglyConnectedComponents {
    VV<ll> E, inv_E;
    V<ll> number;
    V<bool> used_dfs;
    ll to_write_num = 0;

    void dfs(ll now) {
        used_dfs[now] = 1;
        for(ll next : E[now]) {
            if(used_dfs[next]) {
                continue;
            }
            dfs(next);
        }
        number[now] = to_write_num++;
    }

    void dfs(ll now, V<bool> &used, vector<ll> &ret) {
        used[now] = 1;
        ret.push_back(now);
        for(ll next : inv_E[now]) {
            if(used[next]) {
                continue;
            }
            dfs(next, used, ret);
        }
    }

    void write_num() {
        for(ll i = 0; i < E.size(); i++) {
            if(!used_dfs[i]) {
                dfs(i);
            }
        }
    }

public:
    StronglyConnectedComponents(const VV<ll> &E) 
        : E(E),
          inv_E(E.size(), V<ll>(0)),
          number(E.size()),
          used_dfs(E.size(), false)
    {
        for(ll i = 0; i < E.size(); i++) {
            for(ll nxt : E[i]) {
                inv_E[nxt].push_back(i);
            }
        }
        write_num();
    }

    VV<ll> scc() {
        VV<ll> ret;
        V<ll> vertex_vec;
        V<bool> used(E.size());
        for(ll i = 0; i < E.size(); i++) {
            vertex_vec.push_back(i);
        }
        sort(vertex_vec.begin(), vertex_vec.end(), [&](ll a, ll b) { return number[a] > number[b]; });
        for(ll vertex : vertex_vec) {
            if(used[vertex]) {
                continue;
            }
            V<ll> to_insert;
            dfs(vertex, used, to_insert);
            ret.push_back(to_insert);
        }
        return ret;
    }
};

bool solve() {
    ll N;
    cin >> N;
    if(!N) return false;

    VV<ll> edges(N);
    V<double> pv(N);
    for(ll i = 0; i < N; i++) {
        double p;
        cin >> p;
        pv[i] = p;
        ll m;
        cin >> m;
        while(m--) {
            ll a;
            cin >> a;
            edges[a - 1].push_back(i);
        }
    }
    
    StronglyConnectedComponents scc(edges);
    auto group = scc.scc();
    
    VV<ll> scc_edges(group.size());
    V<ll> group_id(N);
    for(ll i = 0; i < group.size(); i++) for(ll j : group[i]) group_id[j] = i;
    for(ll i = 0; i < N; i++) {
        for(ll j : edges[i]) {
            if(group_id[i] == group_id[j]) continue;
            scc_edges[group_id[i]].push_back(group_id[j]);
        }
    }

    /*
    for(auto &v : scc_edges) {
        sort(ALL(v));
        auto ite = unique(ALL(v));
        v.erase(ite, v.end());
    }
    */

    double ans = 1;

    for(ll i = 0; i < scc_edges.size(); i++) {
        if(scc_edges[i].size() > 0) continue;
        double tmp = 1;
        for(ll p : group[i]) tmp *= pv[p];
        ans *= (1.0 - tmp);
    }

    cout << ans << endl;
    return true;
}

int main() {
    cout << fixed << setprecision(30);
    while(solve());
    return 0;
}



Measured memory_bytes: 3360
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i, s, n) for (int i = (s); i < (n); ++i)
#define rrep(i, n, g) for (int i = (n)-1; i >= (g); --i)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define len(x) (int)(x).size()
#define dup(x, y) (((x) + (y)-1) / (y))
#define pb push_back
#define Field(T) vector<vector<T>>
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
  int n;
  cin >> n;
  vector<int> p(n);
  rep(i, 0, n) { cin >> p[i]; }
  vector<int> pp = p;
  sort(all(p));
  int ans = 0;
  rep(i,0,n){
    if (p[i] != pp[i]) ans++;
  }
  if (ans <= 2) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        string s = sc.Next();

        long answer = long.MaxValue;
        for (int i = 0; i < s.Length; i++)
        {
            bool ok = false;

            for (int j = 0; j < 26; j++)
            {
                var c = (char)('a' + j);

                bool tmpOk = true;

                for (int k = 0; k < s.Length - i; k++)
                {
                    bool exist = false;
                    for (int l = k; l < s.Length; l++)
                    {
                        if (s[l] == c)
                        {
                            long dist = l - k;
                            if (dist <= i)
                            {
                                exist = true;
                                break;
                            }
                        }
                    }
                    if (!exist)
                    {
                        tmpOk = false;
                        break;
                    }
                }

                if (tmpOk)
                {
                    ok = true;
                    break;
                }
            }

            if (ok)
            {
                answer = i;
                break;
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 25876
a, b, c, x, y = map(int, input().split())
ans = 1e9
for i in range(max(x, y) + 1):
	cal = i * c * 2
	if x > i:
		cal += (x - i) * a
	if y > i:
		cal += (y - i) * b
	ans = min(cal, ans)
print(ans)

Measured memory_bytes: 8984
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			int H = scan.nextInt();
			int W = scan.nextInt();
			String[]S = new String[H];
			char[][]s = new char[H][W];
			
			for(int i = 0;i<H;i++) {
				S[i] = scan.next();
				s[i] = S[i].toCharArray();
			}
			
			int dy[] = {1,0,-1,0};
			int dx[] = {0,1,0,-1};//上右下左
			
			boolean ok =true;
			
			outside:for(int i = 0;i<H;i++) {
				for(int j = 0;j<W;j++) {
					if(s[i][j]=='#') {
						int  count = 0;
						for(int z = 0;z<4;z++) {
							int x = j+dx[z];
							int y = i+dy[z];
							
							if(0<=x&&x<W&&0<=y&&y<H) {
								if(s[y][x]=='#')
								count++;
							}
						}
						if(count==0) {
							//System.out.println(""+i+" "+j+"");
							ok =false;
							break outside;
						}
						
						
						
					}
				}
			}
			
			System.out.println(ok?"Yes":"No");
			
			
			
		}	
	}
}


Measured memory_bytes: 21844
#include <iostream>
#include <algorithm>
#include <float.h>
#include <stdio.h>
#include <math.h>
#define REP(i,n) for (int i = 0; i < n; i++)
using namespace std;

int main() {
    int W, H, R[1000][1000], count = 0;
    while (true) { 
        cin >> H >> W;
        if (H == 0 && W == 0) break;
        R[count][0] = W;
        R[count][1] = H;
        count++;
    }
    
    REP(i,count) {
        for (int j = 0; j < R[i][1]; j++) {
            for ( int k = 0; k < R[i][0]; k++) {
                cout << '#';
            }
            cout <<endl;
        }
        cout << endl;
    }
}


Measured memory_bytes: 3196
#include<iostream>
using namespace std;
int main(){
	int H, W;
	while (true){
		cin >> H >> W;
		if (H == 0 && W == 0)break;
		for (int i = 0; i < H; i++){
			for (int j = 0; j < W; j++){
				cout << "#";
			}
			cout << endl;
		}
		cout << endl;
	}
	return 0;
}

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

using namespace std;
using ll = long long;

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

  int n, m;
  cin >> n >> m;
  vector<int> a(m);
  for (auto &x : a)
    cin >> x;
  int sum = accumulate(a.begin(), a.end(), 0);
  if (n >= sum)
    cout << (n - sum) << endl;
  else
    cout << -1 << endl;

  return 0;
}


Measured memory_bytes: 3624
R, G, B, N = map(int, input().split())
ans = 0
for i in range(N + 1):
    r = i * R
    if r > N:
        break
    for j in range(N + 1):
        g = j * G
        if r + g > N:
            break
        b = N - r - g
        if b >= 0 and b % B == 0:
            ans += 1
print(ans)


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

long long N, K, A[100009], dp[109][100009], mod = 1000000007;

int main() {
	cin >> N >> K;
	for (int i = 1; i <= N; i++) cin >> A[i];

	dp[0][0] = 1;
	for (int i = 1; i <= N; i++) {
		for (int j = 1; j <= K; j++) { dp[i - 1][j] += dp[i - 1][j - 1]; dp[i - 1][j] %= mod; }
		for (int j = 0; j <= K; j++) {
			long long R = dp[i - 1][j];
			long long L = 0; if (j > A[i]) L = dp[i - 1][j - A[i] - 1];
			dp[i][j] = (R - L + mod) % mod;
		}
	}
	cout << dp[N][K] << endl;
	return 0;
}

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

int main(int argc, const char * argv[]) {



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

    /////////////////////
    // Write code below /
    /////////////////////
    int N,a;
    string flag="APPROVED";
    vector<int>A;

    cin>>N;
    rep(i,N){
        cin>>a;
        A.push_back(a);
    }

    rep(i,N){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0){
                flag="DENIED";
            }
        }
    }

    cout<<flag<<endl;

    return 0;
}


Measured memory_bytes: 256
from scipy.sparse import*
i=lambda:tuple(map(int,input().split()))
f=csgraph.dijkstra
n,m,l=i()
d=eval('[0]*-~n,'*-~n)
while m:a,b,c=i();d[a][b]=c;m-=1
d=f(f(d,0)<=l)-1
d[d>n]=-1
for _ in'_'*i()[0]:print(d[i()])

Measured memory_bytes: 18724
import sys
from subprocess import Popen, PIPE
from itertools import groupby
from collections import Counter

def main():
    sys.stdin.readline()
    S = sys.stdin.read().split()
    T = []
    inv_dict = {}
    Factors = Popen(["factor"] + S, stdout=PIPE).communicate()[0].split(b"\n")
    for factors in Factors[:-1]:
        factors = map(int, factors.split()[1:])
        t = 1
        t_inv = 1
        for f, group in groupby(factors):
            n = len(list(group)) % 3
            if n == 1:
                t *= f
            elif n == 2:
                t_inv *= f
        t, t_inv = t * t_inv * t_inv, t * t * t_inv
        T.append(t)
        inv_dict[t] = t_inv

    counter_T = Counter(T)
    ans = 0
    for t, t_cnt in counter_T.items():
        if t == 1:
            ans += 1
            continue
        t_inv = inv_dict[t]
        t_inv_cnt = counter_T[t_inv]
        if t_cnt > t_inv_cnt or (t_cnt == t_inv_cnt and t > t_inv):
            ans += t_cnt
    print(ans)

main()


Measured memory_bytes: 49760
#include <stdio.h>  
#include <string.h>  
#include<math.h>
int main()
{
	long long int sum,n,m;
    	while(~scanf("%lld %lld",&n,&m))
	  {
	  	if(m==0&&n==0)
	  	break;
	  	else
	  	{
		  sum=0;
		  if(m>n)
	  	sum=n+(m-n*2)/4;
	  	
	  else if(n>=m)
	  {
	  	if(m<2)
	  	sum=0;
	  	else
	  	{
	  		sum=m/2;
		  }
	  }
	
	  	printf("%lld\n",sum);
	  }
	}
		
}

Measured memory_bytes: 128
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10**7)
    from collections import Counter, deque
    #from collections import defaultdict
    from itertools import combinations, permutations, accumulate, groupby, product
    from bisect import bisect_left,bisect_right
    from heapq import heapify, heappop, heappush
    from math import floor, ceil
    #from operator import itemgetter

    #inf = 10**17
    #mod = 10**9 + 7

    s = input().rstrip()
    if 'AC' in s:
        print('Yes')
    else:
        print('No')

if __name__ == '__main__':
    main()

Measured memory_bytes: 3316
import java.util.Scanner;

public class Main {

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

			int num1 = sc.nextInt();
			int num2 = sc.nextInt();
			
			if(num1 <=8 && num2<= 8) {
				System.out.println("Yay!");
			}else {
				System.out.println(":(");
			}

	}


}




Measured memory_bytes: 23252
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FAST() ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

int main()
{
    FAST();
    int n,i;
    cin>>n;
    for(i=1000; i<=10000; i+=1000)
    {
        if(i>=n)
        {
            cout<<i-n<<endl;return 0;
        }
    }





    return 0;
}





Measured memory_bytes: 3648
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>


using namespace std;
typedef long long ll;

#define mod 1000000007
#define INF 2000000000
#define LLINF 4000000000000000000
#define SIZE 5010

int main(){
    vector<int > nails[SIZE+3];
    int n,m,a,b,x,ans=0;
    
    scanf("%d%d",&n,&m);
    
    for(int i=0;i<=n+2;i++){
        nails[i].resize(i+5,0);
    }
    
    for(int i=0;i<m;i++){
        scanf("%d%d%d",&a,&b,&x);
        
        nails[a][b]++;
        nails[a][b+1]--;
        nails[a+x+1][b]--;
        nails[a+x+2][b+1]++;
        nails[a+x+1][b+x+2]++;
        nails[a+x+2][b+x+2]--;
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            nails[i][j+1]+=nails[i][j];
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            nails[i+1][j]+=nails[i][j];
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            nails[i+1][j+1]+=nails[i][j];
        }
    }
    
    for(int i=1;i<=n;i++){
        for(int j=1;j<=i;j++){
            if(nails[i][j]>0)
                ans++;
        }
    }
    
    printf("%d\n",ans);
    
    return 0;
}

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

namespace _1_10_c
{
    class Program
    {
        static void Main(string[] args)
        {
            //int student = int.Parse(Console.ReadLine());
            while (true)
            {
                int student = int.Parse(Console.ReadLine());
                if (student == 0)
                {
                    break;
                }
                double[] point = new double[student];
                string[] line = Console.ReadLine().Split(' ');
                double[] deviation = new double[student];
                double[] result = new double[student];
                double variance = 0;
                double answer = 0;
                for (int i = 0; i < student; i++)//生徒の点数を格納
                {
                    point[i] = double.Parse(line[i]);
                }
                double average = point.Average();//平均点を求める
                for (int i = 0; i < student; i++)//偏差を求める
                {
                    deviation[i] = point[i] - average;
                }
                for (int i = 0; i < student; i++)//偏差の2乗を求める
                {
                    result[i] = Math.Pow(deviation[i], 2);
                }
                variance = result.Average();//分散を求める
                answer = Math.Sqrt(variance);
                Console.WriteLine(answer);
            }
        }
    }
}



Measured memory_bytes: 16252
#include <bits/stdc++.h>
using namespace std;
int main(void){
    long long mod=1000000007;
    int n;
    cin>>n;
    long long a[400000];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    long long b[100]={};
    for(int i=0;i<n;i++){
        for(int j=0;a[i]!=0;j++){
            b[j]+=a[i]%2;
            a[i]/=2;
        }
    }
    long long ans=0;
    for(int i=0;i<=60;i++){
        long long z=pow(2,i);
        ans+=(((b[i]*(n-b[i]))%mod)*(z%mod))%mod;
        ans%=mod;
    }
    cout<<ans;
}


Measured memory_bytes: 3072
#define _CRT_SECURE_NO_WARNINGS 1

#include <iostream>
#include <string>
#include <string.h>
#include <limits>
#include <utility>
#include <vector>
#include <algorithm>
#include <functional>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <chrono>

using namespace std;

namespace
{

}

#if 1
int main()
{
	int a, b, k;
	cin >> a >> b >> k;

	for (int i = 0; i < k; i++)
	{
		if (i % 2 == 0)
		{
			if (a % 2 == 1)
			{
				a--;
			}

			int div = a / 2;
			a -= div;
			b += div;
		}
		else
		{
			if (b % 2 == 1)
			{
				b--;
			}

			int div = b / 2;
			b -= div;
			a += div;
		}
	}

	cout << a << " " << b;
}
#endif


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<cmath>
#include<algorithm>
#include<bitset>
#include<map>
#include<functional>
#include<set>
#include<numeric>

#pragma region
using namespace std;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define rep(i,n) FOR(i,0,n)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define rrep(i,n) RFOR(i,0,n)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define COUNT(a,x)  upper_bound(all(a), x) - lower_bound(all(a), x)
#define MCOUNT(a,x,y) upper_bound(all(a), y) - lower_bound(all(a), x)
#define UNIQUE(a) sort(all(a)); a.erase(unique(all(a)), a.end())
#define SUM(a) accumulate(all(a),0)
#define scan(x) scanf("%lld",&x)
#define pb push_back
typedef long long int ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef vector<string> vs;
typedef map<ll, ll> MAP;
typedef set<ll> SET;
typedef double D;
const ll inf = 5555555555555555555;
const ll mod = 1000000007;
const D pi = acos(-1);
const D eps = 1e-10;

ll n = 0, m = 0, ans = 0, sum = 0, cnt = 0, tmp = 0, ma = -inf, mi = inf;
string s;
bool ok, flag;
ll dx[5] = { 1,-1,0,0,0 }, dy[5] = { 0,0,1,-1,0 };
ll ddx[9] = { 1,-1,0,0,1,1,-1,-1,0 }, ddy[9] = { 0,0,1,-1,1,-1,1,-1,0 };
#pragma endregion
#define MAX 111111

ll b[5];
int main(void) {
  cin >> n;
  vll a(n), sm(n, 0);
  rep(i, n) cin >> a[i];
  sm[0] = a[0];
  FOR(i, 1, n) sm[i] = sm[i - 1] + a[i];
  //rep(i, n) cout << sm[i] << endl;

  ans = inf;
  FOR(mid, 1, n - 2) {
	rep(i, 4) b[i] = 0;

	ll mid1 = lower_bound(sm.begin(), sm.begin() + mid, sm[mid] / 2) - sm.begin();
	//cout << mid1 << endl;
	b[0] = sm[mid1];
	b[1] = sm[mid] - sm[mid1];
	if (mid1 > 0) {
	  ll x = sm[mid1-1];
	  ll y = sm[mid] - sm[mid1 - 1];
	  if (x != 0 && y != 0) if (abs(b[0] - b[1]) > abs(x - y)) {
		b[0] = x;
		b[1] = y;
	  }
	}

	ll mid2 = lower_bound(sm.begin() + mid + 1, sm.end(), (sm[n - 1] - sm[mid]) / 2 + sm[mid]) - sm.begin();
	b[2] = sm[mid2] - sm[mid];
	b[3] = sm[n - 1] - sm[mid2];
	if (mid2 > mid) {
	  ll x = sm[mid2 - 1] - sm[mid];
	  ll y = sm[n - 1] - sm[mid2 - 1];
	  if (x != 0 && y != 0) if (abs(b[2] - b[3]) > abs(x - y)) {
		b[2] = x;
		b[3] = y;
	  }
	}

	ma = -inf;
	rep(i, 4)rep(j, 4) {
	  if (i == j)continue;
	  ma = max(ma, abs(b[i] - b[j]));
	}
	ans = min(ans, ma);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3328
#![allow(unused_macros)]
#![allow(dead_code)]
#![allow(unused_imports)]

use itertools::Itertools;
use std::str::FromStr;
use text_io::*;

const U_INF: usize = 1 << 60;
const I_INF: isize = 1 << 60;

pub struct Scanner {
    buf: std::collections::VecDeque<String>,
}
impl Scanner {
    pub fn new() -> Self {
        Self {
            buf: std::collections::VecDeque::new(),
        }
    }
    fn scan_line(&mut self) {
        let mut flag = 0;
        while self.buf.is_empty() {
            let mut s = String::new();
            std::io::stdin().read_line(&mut s).unwrap();
            let mut iter = s.split_whitespace().peekable();
            if iter.peek().is_none() {
                if flag >= 5 {
                    panic!("There is no input!");
                }
                flag += 1;
                continue;
            }
            for si in iter {
                self.buf.push_back(si.to_string());
            }
        }
    }
    pub fn next<T: FromStr>(&mut self) -> T {
        self.scan_line();
        self.buf
            .pop_front()
            .unwrap()
            .parse()
            .unwrap_or_else(|_| panic!("Couldn't parse!"))
    }
    pub fn next_usize(&mut self) -> usize {
        self.next()
    }
    pub fn next_isize(&mut self) -> isize {
        self.next()
    }
    pub fn next_chars(&mut self) -> Vec<char> {
        self.next::<String>().chars().collect()
    }
    pub fn next_string(&mut self) -> String {
        self.next()
    }
    pub fn next_char(&mut self) -> char {
        self.next()
    }
    pub fn next_float(&mut self) -> f64 {
        self.next()
    }
}
fn main() {
    let mut sc = Scanner::new();
    let n = sc.next_usize();
    let m = sc.next_usize();

    let mut x = Vec::with_capacity(m);
    for _ in 0..m {
        let xi = sc.next_isize();
        x.push(xi);
    }

    x.sort();
    let mut diff = Vec::with_capacity(n - 1);
    for i in 1..m {
        diff.push(x[i] - x[i - 1]);
    }

    diff.sort();

    if m > n {
        println!("{}", diff.into_iter().take(m - n).sum::<isize>());
    } else {
        println!("{}", 0);
    }
}


Measured memory_bytes: 8132
N = int(input())
h = list(map(int, input().split()))

c = 0
while 1:
    for i in range(N):
        if h[i] != 0:
            break
    else:
        break
    con0 = 1
    for i in range(N):
        if con0 == 1 and h[i] != 0:
            c += 1
            con0 = 0
        elif con0 == 0 and h[i] == 0:
            con0 = 1
        if h[i] != 0:
            h[i] -= 1

print(c)


Measured memory_bytes: 39408
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		String a = scan.nextLine();
		if (a.matches("[a-z]")) {
			System.out.println("a");
		}else {
			System.out.println("A");
		}
	}

}


Measured memory_bytes: 27020
#include <cstdio>

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


Measured memory_bytes: 128
#include <stdio.h>
#include <stdlib.h>
int main(){
	char s[10];
	int i;
  	for(i = 0; i < 10;i++){s[i] = '\0';}
  	scanf("%s",s);
  	i = 0;
    while(s[i]!='\0'){
      if(s[i] == '9') s[i] = '1';
      else s[i] = '9';
      i++;
    }
  	printf("%s\n",s);
}

Measured memory_bytes: 128
a = input()
b = input()
c = input()
next = a[0]
a = a[1:]
while True:
  if next == "a":
    if a == "":
      print("A")
      break
    else:
      next = a[0]
      a = a[1:]
  elif next == "b":
    if b == "":
      print("B")
      break
    else:
      next = b[0]
      b = b[1:]
  else:
    if c == "":
      print("C")
      break
    else:
      next = c[0]
      c = c[1:]

Measured memory_bytes: 9020
#include <iostream>
#include <vector>
#define MOD 1000000007
#define MAX_N 2000000

using namespace std;

long long fact[MAX_N];
long long modpow(long long a, long long n)
{
  if (n == 0) return 1;
  long long b = modpow(a, n/2);
  b = b*b % MOD;
  if (n % 2 == 0) return b;
  else return a*b % MOD;
}
long long moddiv(long long a, long long b) {
  return (a * modpow(b, MOD - 2)) % MOD;
}
void factInit() {
  fact[0] = 1;
  for (int i = 1; i < MAX_N; i++) {
    fact[i] = (i * fact[i - 1]) % MOD;
  }
}
// Combination(binomial coefficients)
long long comb(int n, int r) {
  if (n < r || n < 0 || r < 0) return 0;
  return moddiv(fact[n], (fact[r] * fact[n - r]) % MOD);
}

int main() {
  factInit();
  int X, Y;
  cin >> X >> Y;

  long long ans = 0;
  for (int x = 0; x <= X; x++) {
    int k = X - x;
    if (x <= k && Y == 2*k - x) {
      (ans += comb(k, x)) %= MOD;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define F first
#define S second
#define MP make_pair

using namespace std;

typedef pair<int, int> P;
typedef long long LL;
static const int INF = INT_MAX;


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    int a, b;
    cin >> n >> a >> b;
    int p;
    int cnt1 = 0, cnt2 = 0, cnt3 = 0; 
    for(int i = 0; i < n; ++i) {
        cin >> p;
        if(p <= a) ++cnt1;
        else if(p <= b) ++cnt2;
        else ++cnt3;
    }
    cout << min(cnt1, min(cnt2, cnt3)) << endl;
    return 0;
}



Measured memory_bytes: 256
// D.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

typedef long long LL;

int main(int argc, char *argv[]) {
	int n, k;
	cin >> n >> k;
	vector<LL> v(n);
	for (int i = 0; i < n; ++i) {
		cin >> v[i];
	}
	LL ans = 0;
	vector<LL> a;
	for (int i = 0; i <= k; ++i) {
		if (i) {
			a.push_back(v[i - 1]);
		}
		vector<LL> b = a;
		for (int j = 0; j <= min(n - i, k - i); ++j) {
			if (j) {
				b.push_back(v[n - j]);
			}
			sort(b.begin(), b.end());
			LL tot = accumulate(b.begin(), b.end(), 0LL);
			for (int l = 0; l < (int)b.size() && l < k - i - j; ++l) {
				if (b[l] < 0) {
					tot -= b[l];
				}
			}
			ans = max(ans, tot);
		}
	}
	cout << ans << endl;
	return 0;
}


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

/*
例一とか提出でもAC少しあったから桁落ちとかのミスかと思って
式ミス気付くの遅くなった
*/
int main() {
  int a,b,h,m;
  cin >> a >> b >> h >> m;
  //double PI=3.14159265358979323846264338327950;
  double PI=acos(-1.0);
  double x;
  double h_rad, m_rad, cosx;
  //時針は何分台か関係ある
  //h_rad = PI*2/12*h+PI*2/12/60*m; //-14までok
  h_rad = PI*h/6+PI*m/360; //-16までok
  //h_rad = PI*(h+m/60)/6; //-16までok .0外すと一の位からだめ
  m_rad = PI*m/30; //分針に何時台かは関係ない
  cosx = cos(m_rad-h_rad);
  x = sqrt(a*a+b*b-2*a*b*cosx);
  
  //cout << x << endl; //普通にやるとトータル6桁
  cout << fixed << setprecision(20) << x << endl; //小数点以下20桁で指定
  //printf("%.12lf\n",x); //小数点以下12桁で指定
}



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

int main() {
  int N;
  cin >> N;
  
  vector<int> P;
  P = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  
  cout << P.at(N-1) << endl;
}

Measured memory_bytes: 256