akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<queue>
#include<algorithm>
#include<cstring>
 
using namespace std;
 
typedef pair<int,int>pii;
#define INF 0x3f3f3f3f
#define fi first
#define se second
 
int mcos[10005];
vector <pii> G[1000005];
int N;
 
 
void dijkstra(int start){
  priority_queue<pii,vector<pii>,greater<pii> > pq;
 
  pq.push( pii(0,start) );
  memset( mcos,INF,sizeof(mcos));
  mcos[start]=0;
 
   
  while(!pq.empty() ){
    const pii tmp=pq.top();
    pq.pop();
     
    const int now=tmp.se;
     
    if(mcos[now] < tmp.fi) continue;
     
    for(int i=0;i<G[now].size();++i){
      const int newcost = G[now][i].fi + tmp.fi;
      const int next= G[now][i].se;
       
      if(newcost < mcos[next] ){
    mcos[next]=newcost;
    pq.push( pii(newcost,next) );
      }
    }
  }
  return ;
   
}
 
int main (){
  cin>>N;
  int k,u,v,c;
 
  for(int i=0;i<N;i++){
    cin>>u>>k;
    for(int j=0;j<k;j++){
      cin>>v>>c;
      G[u].push_back(make_pair(c,v));
    }
  }
  dijkstra(0);
  for(int i=0;i<N;i++){
    cout<<i<<" "<<mcos[i]<<endl;
  }
  return 0;
}



Measured memory_bytes: 31332
n,k = map(int, input().split())
mod = 10 ** 9 + 7

comb0 = [1] * (n)

for i in range(n-1):
    comb0[i + 1] = comb0[i] * (n - i) * pow(i + 1,mod - 2, mod) % mod

comb1 = [1] * (n)

for i in range(n-1):
    comb1[i + 1] = comb1[i] * (n - 1 - i) * pow(i + 1,mod - 2, mod) % mod

ans = 0

for i in range(min(n - 1, k) + 1):
    ans += comb0[i] * comb1[i]
    ans %= mod

print(ans)

Measured memory_bytes: 80080
#include <iostream>

using namespace std;

int main()
{
    int n, count = 0;
    cin >> n;

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

    for (int j = 0; j < 30; j++)
    {
        for (int i = 0; i < n; i++)
        {
            if (a[i] % 2 == 0)
                a[i] /= 2;
            else{
                cout << count << endl;
                return 0;
            }
        }
        count++;
    }

    cout << count << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
int isprime(int x){
	int i;
	if(x == 2){
 		return 1;
	}
  	if(x<2||x%2==0){
		return 0;
	}
	i = 3;
	while( i <= sqrt(x) ){
		if(x%i==0){
			return 0;
		}
		i = i + 2;
	}
	return 1;
}
int main(){
	int l[999999]={0};
	int r=0,n;
	for(int i=0;i<999999;i++){
		if(isprime(i+1)){
			r++;
		}
		l[i]=r;
	}
	while(scanf("%d",&n)!=EOF){
		printf("%d\n",l[n-1]);
	}
	return 0;
}

Measured memory_bytes: 6500
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<stdlib.h>
#include<queue>
#include<stack>
#include<cstring>
#include<math.h>
#include<map>
using namespace std;
long long a[100010];
long long b[100010];
long long c[100010];
long long aaa[100010];
long long bbb[100010];
long long ccc[100010];
int main()
{
    int n;
    cin>>n;

    for(int i=1; i<=n; i++)
        cin>>a[i];
    for(int i=1; i<=n; i++)
        cin>>b[i];
    for(int i=1; i<=n; i++)
        cin>>c[i];
    sort(a+1,a+1+n);
    sort(b+1,b+1+n);
    sort(c+1,c+1+n);
    for(int i=1; i<=n; i++)
    {
        int l=1;
        int r=n;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(b[mid]>=c[i])
            {
                r=mid-1;
            }
            if(b[mid]<c[i])
            {
                l=mid+1;
            }
        }
        ccc[i]=l-1;
    }
    for(int i=1; i<=n; i++)
    {
        int l=1;
       int r=n;
        while(l<=r)
        {
            int mid=(l+r)/2;
            if(a[mid]>=b[i])
            {
                r=mid-1;
            }
            if(a[mid]<b[i])
            {
                l=mid+1;
            }
        }
        bbb[i]=l-1;
    }
    long long sum=0,sum1=0;
    for(int i=1; i<=n; i++)
    {
        for(int j=ccc[i-1]+1; j<=ccc[i]; j++)
        {
            sum1+=bbb[j];
        }
        sum+=sum1;
    }
    cout<<sum<<endl;

}


Measured memory_bytes: 4480
#pragma GCC optimize("Ofast")
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define PI 3.141592
#define all(a) (a).begin(), (a).end()
#define fi first
#define se second

int main(){
    int r, D;
    cin >> r >> D;
    int x;
    cin >> x;
    for(int i = 0; i < 10; i++){
        x = r * x - D;
        cout << x << endl;
    }
}


Measured memory_bytes: 3524
#include <cstdio>
#include <cstring>

int main(){
    char str[21],res[21];
    int n;
    scanf("%s",str);
    n = strlen(str);

    for(int i = 0; i < n; i++){
        res[n - i - 1] = str[i];
    }
    res[n] = '\0';
    printf("%s\n",res);
    return 0;
}

Measured memory_bytes: 944
#include<stdio.h>

int main(){
    int w,h,i,j;
    while(1){
        scanf("%d%d",&h,&w);
        if(h==0||w==0) break;
        for(i=0;i<h;i++){
            for(j=0;j<w;j++){
                if(i==0||i==h-1||j==0||j==w-1){
                    printf("#");
                }else{
                    printf(".");
                }
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;

}

Measured memory_bytes: 572
#include <iostream>
#include <vector>
#include <algorithm>
#include <climits>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;

int main(){
    ios::sync_with_stdio(false);
    int n,k,ans=INT_MAX;
    cin>>n>>k;
    vector<int>x(n);
    for(int i=0;i<n;i++) cin>>x[i];
    for(int i=0;i<n-k+1;i++){
        int s=x[i],g=x[i+k-1],tmp;
        if(abs(s)>abs(g)) tmp=(abs(g)+abs(g-s));
        else tmp=(abs(s)+abs(s-g));
        if(ans>=tmp) ans=tmp;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
public class Main {
	public static void main(String[] args){
       Scanner sc = new Scanner(System.in);   
	  int a = sc.nextInt();
      int b = sc.nextInt();
      String s = sc.next();
      
      Pattern p = Pattern.compile("^[0-9]{"+a+"}-[0-9]{"+b+"}$");
      Matcher m = p.matcher(s);
      if(m.matches()){
        System.out.println("Yes");
      }else{
        System.out.println("No");
      }
    }
}


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

int main()
{
    double ft,st;
    while(cin>>ft>>st)
    {
        int fr=0,sr=0;
        if(ft<70.0)fr++;
        if(ft<55.0)fr++;
        if(ft<50.0)fr++;
        if(ft<43.0)fr++;
        if(ft<40.0)fr++;
        if(ft<37.5)fr++;
        if(ft<35.5)fr++;
        if(st<148.0)sr++;
        if(st<116.0)sr++;
        if(st<105.0)sr++;
        if(st<89.0)sr++;
        if(st<83.0)sr++;
        if(st<77.0)sr++;
        if(st<71.0)sr++;
        int r;
        r=min(fr,sr);
        if(r==0)cout<<"NA"<<endl;
        if(r==1)cout<<"E"<<endl;
        if(r==2)cout<<"D"<<endl;
        if(r==3)cout<<"C"<<endl;
        if(r==4)cout<<"B"<<endl;
        if(r==5)cout<<"A"<<endl;
        if(r==6)cout<<"AA"<<endl;
        if(r==7)cout<<"AAA"<<endl;
    }
    return 0;
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
 
bool IsPrime(int num)
{
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false; // 偶数はあらかじめ除く

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            // 素数ではない
            return false;
        }
    }

    // 素数である
    return true;
}
int main() {
  int X;
  cin >> X;
  while (IsPrime(X) != true) {
    X++;
  }
  cout << X << endl;
}

Measured memory_bytes: 3548
#include <algorithm>
#include <iostream>
#include <numeric>
#include <vector>
#include <string>
#include <bitset>
#include <tuple>
#include <cmath>
#include <map>

template<typename T> bool chmax( T &a, const T &b ) { if ( a <= b ) { a = b; return ( true ); } else { return ( false ); } }
template<typename T> bool chmin( T &a, const T &b ) { if ( a >= b ) { a = b; return ( true ); } else { return ( false ); } }

using namespace std;

using ll = long long;
using ull = unsigned long long;

using Pll  = pair<ll, ll>;
using Pull = pair<ull, ull>;

#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple

#define F first
#define S second

#define rep( i, n ) for ( int i = 0; i < (int)( n ); ++i )
#define reps( i, n ) for ( int i = 1; i <= (int)( n ); ++i )
#define rrep( i, n ) for ( int i = (int)( ( n ) - 1 ); i >= 0; --i )
#define rreps( i, n ) for ( int i = (int)( ( n ) ); i > 0; --i )
#define arep( i, v ) for ( auto &&i : ( v ) )

template<typename T> T gcd( const T a, const T b ) { return ( b ? gcd( b, a % b ) : a ); }

#define ALL( c ) ( c ).begin(), ( c ).end()
#define RALL( c ) ( c ).rbegin(), ( c ).rend()
#define UNIQUE( c ) ( c ).erase( unique( ( c ).begin(), ( c ).end() ), ( c ).end() )

const ll MOD = 1000000007LL;
const ll INF = 1000000010LL;

#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev

template<typename T = ll> class UnionFind {
public:
	UnionFind( T n ) { rep( i, n ) { par[i] = i; siz[i] = 1; } }
	T find( T x ) { if ( x == par[x] ) return ( x ); else return( par[x] = find( par[x] ) ); }
	void unite( T x, T y ) { T xx = find( x ); T yy = find( y ); if ( xx == yy ) return;
		if ( siz[xx] <= siz[yy] ) swap( xx, yy ); par[yy] = xx; siz[xx] += siz[yy]; }
private:
	vector<T> par, siz;
};

template<typename T = ll> T binpow( T a, T b, T m = MOD ) {
	T res = 1;
	while ( b > 0 ) { if ( b & 1 ) res = res * a % m;
		a = a * a % m; b >>= 1; }
	return ( res );
}


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

	vector<vector<int>> vD( C, vector<int>( C ) );
	vector<vector<int>> vC( 3, vector<int>( C ) );

	rep( i, C )
	{
		rep( j, C )
		{
			cin >> vD[i][j];
		}
	}

	rep( i, N )
	{
		rep( j, N )
		{
			int c;
			cin >> c;
			vC[( i + j ) % 3][c - 1]++;
		}
	}

	ll result = INF;
	rep( i, C )
	{
		rep( j, C )
		{
			if ( i != j )	//	iとjが等しい時は色は変わらない
			{
				rep( k, C )
				{
					if ( ( i != k ) && ( j != k ) )
					{
						ll total = 0;
						rep ( l, C ) total += vD[l][i] * vC[0][l];
						rep ( l, C ) total += vD[l][j] * vC[1][l];
						rep ( l, C ) total += vD[l][k] * vC[2][l];

						chmin( result, total );
					}
				}
			}
		}
	}

	cout << result << endl;

	return ( 0 );
}


Measured memory_bytes: 632
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

function Main(args){
    var input = args.split(" ");
    var N = parseInt(input[0], 10);
    var A = parseInt(input[1], 10);
    var B = parseInt(input[2], 10);
    var totalSum = 0;

    for(var i=0; i<=N; i++){
        var tmpSum = 0;
        var tmpStr = i.toString();
        var len = tmpStr.length;
        for(var j=0; j<len; j++){
            tmpSum += parseInt(tmpStr[j], 10);
        }
        totalSum += ((A<=tmpSum && tmpSum<=B)?i:0);
    }

    console.log( totalSum );
}

Measured memory_bytes: 8128
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long ll;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    string s;
    cin >> s;
    REP(i, s.length() - 2) {
        if(s[i] == s[i+1]) {
            cout << i + 1 << ' ' << i + 2;
            return 0;
        } else if(s[i] == s[i + 2]) {
            cout << i + 1 << ' ' << i + 3;
            return 0;
        }
    }
    if(s[s.length()-2] == s[s.length() - 1]) {
        cout << s.length() - 1<< ' '<<s.length() ;
        return 0;
    }
    cout << -1 << ' ' << -1;

    return 0;
}


Measured memory_bytes: 512
#include <iostream>
using namespace std;
 
int main() {
	int a[100000];int n,m;int high[100000],low[100000];int ans[100000];
	cin >> n >> m;
	for(int i = 0;i < n;i++){
		cin >> a[i];
		high[i]=-1;
		low[i]=-1;
	}
	int p = 0;int k = 0;int highorlow  = 0;
	for(int i = 0;i<n;i++){
		if(i ==0){
			if(a[i]<a[i+1]){
				low[p]=i;
				p++;
				highorlow = -1;
			}
			if(a[i]>a[i+1]){
				high[k]=i;
				k++;
			}
		}
		else if(i==n-1){
			if(a[i]<a[i-1]){
				low[p]=i;
				p++;
			}
			if(a[i]>a[i-1]){
				high[k]=i;
				k++;
			}
		}
		else{
			if(a[i]<a[i+1] && a[i]<a[i-1]){
				low[p]=i;
				p++;
			}
			if(a[i]>a[i+1] && a[i]>a[i-1]){
				high[k]=i;
				k++;
			}
		}
	}
	int w = 0;
	for(int i = 0;i<n;i++){
		if(low[i] == -1){break;}
		if(highorlow+i!=-1){
for(int j = high[i+highorlow];j<=low[i];j++){
			ans[w]= ans[w]+m-a[j];
		}
		w++;
}
		if(high[i] == -1){break;}
		for(int j =low[i];j<=high[i+highorlow+1];j++){
			ans[w]=ans[w]+m-a[j];
		}
		w++;
	}
	for(int i = 1;i<=w;i++){
		if(ans[0]<ans[i]){ans[0]=ans[i];}
	}
	cout << ans[0] << endl;
	return 0;
}

Measured memory_bytes: 2604
n,k=map(int,input().split())
l=list(map(int,input().split()))
s=str(n)
flag=False
while flag==False:
    flag=True
    for j in l:
        if s.count(str(j))!=0:
            s=int(s)
            s+=1
            s=str(s)
            flag=False
            break
print(s)

Measured memory_bytes: 3060
module WeightedGraph
  (Vertex : sig
    type t
    val compare : t -> t -> int
  end)
  (Weight : sig
    type t
    val compare : t -> t -> int
  end) :
sig
  val prim :
    (* 隣接リスト *)
    (Vertex.t -> (Vertex.t * Weight.t) list) ->
    (* 始点 *)
    Vertex.t ->
    (* 最小全域木に含まれる辺のリスト *)
    (Vertex.t * Vertex.t * Weight.t) list
end =
struct
  module VSet = Set.Make (Vertex)
  module WMap = Map.Make (Weight)

  (*
   * プリム法のメインループ
   * es : 隣接リスト
   * vs : 訪れた頂点の集合
   * q : 訪れた頂点から伸びる辺が重み順に入ったヒープ
   * acc : 最小全域木に使うのが確定した辺を入れるやつ
   *)
  let rec prim_aux es acc vs q =
    match WMap.min_binding q with
    | exception Not_found -> acc
    | (w, uvs) ->
        let rec inner = function
          | [] -> prim_aux es acc vs (WMap.remove w q)
          | (u, v) :: uvs ->
              if VSet.mem v vs
              (* vは既に訪れていた *)
              then inner uvs
              (* vはまだ訪れていなかった *)
              else prim_aux es ((u, v, w) :: acc) (VSet.add v vs) @@
                (* vから伸びる辺をキューに追加 *)
                List.fold_left (fun q (u, w) ->
                  (* 現時点で既に訪れている頂点への辺は追加しない *)
                  if VSet.mem u vs
                  then q
                  else WMap.add w ((v, u) :: try WMap.find w q with Not_found -> []) q) (WMap.add w uvs q) (es v) in
        inner uvs
                
  let prim es s =
    prim_aux es [] (VSet.singleton s) @@
      (* 始点から伸びる辺をキューに入れておく *)
      List.fold_left (fun q (v, w) ->
        WMap.add w ((s, v) :: try WMap.find w q with Not_found -> []) q) WMap.empty (es s)
end

module Int = struct
  type t = int
  let compare = compare
end

module G = WeightedGraph (Int) (Int)

let () = Scanf.scanf "%d\n" (fun n ->
  let xys = Array.to_list @@ Array.init n (fun i -> Scanf.scanf "%d %d\n" (fun x y -> x, y, i)) in
  let es = Array.make n [] in
  begin match List.sort (fun (x, _, _) (x', _, _) -> compare x x') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  begin match List.sort (fun (_, y, _) (_, y', _) -> compare y y') xys with
  | [] -> ()
  | (x, y, i) :: rest ->
      ignore @@ List.fold_left (fun (x, y, i) (x', y', j) ->
        es.(i) <- (j, min (abs (x - x')) (abs (y - y'))) :: es.(i);
        es.(j) <- (i, min (abs (x - x')) (abs (y - y'))) :: es.(j);
        (x', y', j)) (x, y, i) rest
  end;
  G.prim (Array.get es) 0
  |> List.map (fun (_, _, w) -> w)
  |> List.fold_left ( + ) 0
  |> Printf.printf "%d\n")


Measured memory_bytes: 65916
#include<stdio.h>

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

  int a[510][510];
  for(int i = 1;i <= h;i ++){
    for(int j = 1;j <= w;j ++){
      scanf("%d",&a[i][j]);
      }
    }
  
  int ans[250000][4] , n = 0;
  for(int i = 1;i <= h;i ++){
    for(int j = 1;j < w;j ++){
      if(a[i][j]%2 == 1){
        a[i][j] --;
        a[i][j+1] ++;
        ans[n][0] = i;
        ans[n][1] = j;
        ans[n][2] = i;
        ans[n][3] = j + 1;
        n ++;
      }
    }
  }

  for(int i = 1;i < h;i ++){
    if(a[i][w]%2 == 1){
      a[i][w] --;
      a[i+1][w] ++;
      ans[n][0] = i;
      ans[n][1] = w;
      ans[n][2] = i+1;
      ans[n][3] = w;
      n ++;
    }
  }

  printf("%d\n",n);
  for(int i = 0;i < n;i ++){
    printf("%d %d %d %d\n",ans[i][0] , ans[i][1] , ans[i][2] , ans[i][3]);
  }

  return 0;
}


Measured memory_bytes: 5188
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>
#include <fstream>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;
const ll inf = 1LL << 60;
template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);

    ll N;
    cin >> N;
    ll ans = inf;
    for (ll i = 1; i*i <= N; i++) {
        if (N%i == 0) {
            chmin(ans, i+N/i);
        }
    }

    cout << ans-2 << endl;
}

Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.HashSet;
import java.util.NoSuchElementException;

public class Main {
	int P,Q;
	HashSet<Integer> set;
	public void setFactors(int n)
	{
		set = new HashSet<Integer>();
		for(int j = 2;(long)j * j <= n;j++){
			while(n % j == 0){
				n /= j;
				set.add(j);
			}
		}

		if(n > 1){
			set.add(n);
		}
	}

	public int gcd(int x,int y){
		return y == 0 ? x : gcd(y,x%y);
	}

	public void solve() {
		P = nextInt();
		Q = nextInt();
		int g = gcd(P,Q);
		Q /= g;
		P /= g;
		setFactors(Q);

		int sum = 1;
		for(int s : set){
			sum *= s;
		}

		out.println(sum);
	}
	public static void main(String[] args) {
		out.flush();
		new Main().solve();
		out.close();
	}

	/* Input */
	private static final InputStream in = System.in;
	private static final PrintWriter out = new PrintWriter(System.out);
	private final byte[] buffer = new byte[2048];
	private int p = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (p < buflen)
			return true;
		p = 0;
		try {
			buflen = in.read(buffer);
		} catch (IOException e) {
			e.printStackTrace();
		}
		if (buflen <= 0)
			return false;
		return true;
	}

	public boolean hasNext() {
		while (hasNextByte() && !isPrint(buffer[p])) {
			p++;
		}
		return hasNextByte();
	}

	private boolean isPrint(int ch) {
		if (ch >= '!' && ch <= '~')
			return true;
		return false;
	}

	private int nextByte() {
		if (!hasNextByte())
			return -1;
		return buffer[p++];
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = -1;
		while (isPrint((b = nextByte()))) {
			sb.appendCodePoint(b);
		}
		return sb.toString();
	}

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

	public long nextLong() {
		return Long.parseLong(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

Measured memory_bytes: 24464
while 1:
    n = int(input())
    if n == 0:
        break

    ans = []
    for _ in range(n):
        data = list(input().split())
        name = data.pop(0)
        data = [int(d) for d in data]
        p = data[0]
        a = data[1]
        b = data[2]
        c = data[3]
        d = data[4]
        e = data[5]
        f = data[6]
        s = data[7]
        m = data[8]
        first = a + b + c + d + e
        multi = (d + e) * (m - 1)
        time = first + multi
        benefit = f * m * s - p
        ratio = benefit / time
        ans.append([name, ratio])

    ans = sorted(ans, key=lambda x: (-x[1], x[0]))
    for a in ans:
        print(a[0])

    print("#")



Measured memory_bytes: 5628
#include<bits/stdc++.h>
using namespace std;
const int N = 2e3+5;
typedef long long ll;
int n,m,c[N][N],ans,op[N],q[N];
bool b[N][N];
char a[N][N];
 
void pre()
{
	for(int i=1;i<=n;++i)
	for(int t=m;t>=1;--t)
	c[i][t]=(b[i][t]?c[i][t+1]+1:0);
}
 
void solve1()
{
	pre();
	for(int t=1;t<=m;++t)
	{
		int top=0;int op1=1;
		for(int i=1;i<=n;++i)
		{
			op1=i;
			while(top&&q[top]>=c[i][t])
			{
				ans=max(ans,min(n-1,i-op[top]+1)*min(m-1,q[top]+1));
				op1=min(op1,op[top]);
				top--;
			}
			op[++top]=op1;q[top]=c[i][t];
		}
	}
}
void solve2()
{
	pre();
	for(int t=1;t<=m;++t)
	{
		int top=0;int op1=1;
		for(int i=1;i<=n;++i)
		{
			op1=i;
			while(top&&q[top]>=c[i][t])
			{
				ans=max(ans,min(n-1,i-op[top])*min(m-1,q[top]));
				op1=min(op1,op[top]);
				top--;
			}
			op[++top]=op1;q[top]=c[i][t];
		}
	}
}
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;++i)scanf("%s",a[i]+1);
	for(int i=1;i<=n+1;++i)
	for(int t=1;t<=m+1;++t)
	{
		if(i==1||i==n+1||t==1||t==m+1)b[i][t]=0;
		else
		{
			int cnt=0;
			for(int i1=i-1;i1<=i;++i1)
			for(int t1=t-1;t1<=t;++t1)
			if(a[i1][t1]=='.')cnt++;
			if(cnt%2)b[i][t]=0;
			else b[i][t]=1;
		}
	}
	n++;m++;
	solve1();
	for(int i=1;i<=n;++i)
	for(int t=1;t<=m;++t)
	{
		if(i==1||i==n||t==1||t==m)b[i][t]=1;
		else
		{
			int cnt=0;
			for(int i1=i-1;i1<=i;++i1)
			for(int t1=t-1;t1<=t;++t1)
			if(a[i1][t1]=='.')cnt++;
			if(cnt%2)b[i][t]=0;
			else b[i][t]=1;
		}
	}
	solve2();
	cout<<ans;
}

Measured memory_bytes: 23808
#include <bits/stdc++.h>
#define rep(i, n) for (int i=0; i<n; ++i)
#define rep1(i, n) for (int i=1; i<=n; ++i)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
constexpr ll  MOD = (1e9+7);
constexpr int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
constexpr int lcm(int a, int b) { return a / gcd(a, b) * b; }

template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
ll factorial(ll n, ll m=2) {
    // calculate n!
    m = max(2LL, m);
    ll rtn = 1;
    for (ll i=m; i<=n; i++) {
        rtn = (rtn * i) % MOD;
    }
    return rtn;
}
ll modinv(ll a, ll m) {
    ll b = m, u = 1, v = 0;
    while (b) {
        ll t = a / b;
        a -= t * b;
        swap(a, b);
        u -= t * v;
        swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
ll modpow(ll a, ll n) {
    ll res = 1;
    while (n > 0) {
        if (n & 1)
            res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    char c; cin >> c;
    cout << ++c << endl;
    return 0;
}

Measured memory_bytes: 764
#include<bits/stdc++.h>
#define watch(x) cout << (#x) << " is " << (x) << endl
typedef long long ll;
using namespace std;
int static fast = [](){
  ios::sync_with_stdio(false);
  cin.tie(0); cout.tie(0); return 0;
}();
// freopen("input.txt", "r", stdin);

int main() {
    int n;
    cin >> n;
    ll l = 0, r = n;
    while (l < r) {
        ll mid = l + (r-l)/2;
        if (mid*mid > n)
            r = mid-1;
        else
        {
            l = mid;
        }
        if (l + 1 == r) {
            if (r*r <= n) cout << r*r << endl;
            else cout << l*l << endl;
            return 0;
        }
        
    }
    cout << l*l << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define inf INT_MAX
#define sc(a) scanf("%d",&a)
#define scc(a,b) scanf("%d %d",&a,&b)
#define sccc(a,b,c) scanf("%d %d %d",&a,&b,&c)
#define pf(a) printf("%d",a)
#define pff(a,b) printf("%d %d",a,b)
#define pfff(a,b,c) printf("%d %d %d",a,b,c)
#define pb(a) push_back(a)
#define em empty()
#define fr front()
#define cl clear()
#define sz size()
#define mp(a,b) make_pair(a,b)
#define fri(b) freopen(b,"r",stdin)
#define fro(b) freopen(b,"w",stdout)
#define fast cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(false)
/*
ID: uslusam1
TASK: test
LANG: C++
*/
using namespace std;

int arr[100013];
int dp[100013];

int mut(int x){
	if(x<0){
		return -x;
	}
	return x;
}
 
int main(){
	//fri("a.txt");
	//fro("b.txt");
	int n,k;
	scc(n,k);
	for(int i=1;i<=n;i++){
		sc(arr[i]);
	}
	for(int i=n-1;i>=1;i--){
		int mini=inf;
		for(int j=1; j<=k && i+j<=n ; j++){
			mini=min(mini,dp[i+j]+mut(arr[i+j]-arr[i]));
		}
		dp[i]=mini;
	}
	cout<<dp[1];
	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;


public class Main {

	private void doit() {
		Scanner sc = new Scanner(System.in);
		while(true){
			int q1 = sc.nextInt();
			if(q1 == 0){
				break;
			}
			int b = sc.nextInt();
			int c1 = sc.nextInt();
			int c2 = sc.nextInt();
			int q2 = sc.nextInt();
			boolean flg = false;
			for(int i = q2; i > 0; i--){
				if( (b - i * c1) < 0) continue;
				int j = (b - i * c1) / c2;
				if(j < 0) continue;
				if(i + j >= q1){
					System.out.println(i + " " + j);
					flg = true;
					break;
				}
			}
			if(! flg){
				System.out.println("NA");
			}
		}

	}
	public static void main(String[] args) {
		Main obj = new Main();
		obj.doit();

	}

}

Measured memory_bytes: 12000
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		
		int X = in.nextInt();
		int A = in.nextInt();
		int B = in.nextInt();
		
		int buy = X-A;
		int count = buy/B;
		int V = B*count;
		int Y = buy-V;
		
		System.out.println(Y);
	}

}


Measured memory_bytes: 21844
N, W = map(int, input().split())
dp = [[0 for i in range(W+1)] for j in range(N+1)]

for i in range(1, N+1):
    v, w = map(int, input().split())
    
    for j in range(1, W+1):
        dp[i][j] = max(dp[i][j], dp[i-1][j], dp[i][j-1])
        if j >= w:
            dp[i][j] = max(dp[i][j], dp[i-1][j-w]+v)
print(dp[N][W])


Measured memory_bytes: 15016
//#pragma GCC optimize("Ofast","unroll-loops","omit-frame-pointer","inline") //Optimization flags
//#pragma GCC option("arch=native","tune=native","no-zero-upper") //Enable AVX
//#pragma GCC target("avx2")  //Enable AVX
#include<bits/stdc++.h>
using namespace std;

#define all(a) begin(a),end(a)
#define F first
#define S second
#define pb push_back
#define mp make_pair
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pi;

#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif

const int mod=1e9+7;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int mul(int a,int b){
  return ((a)*1ll*(b))%mod;
}

void add(int &a,int b){
  a+=b;
  if(a>=mod)a-=mod;
}

int sub(int a,int b){
  a-=b;
  if(a<0){
    a+=mod;
  }
  return a;
}

int powz(int a,int b){
  int res=1;
  while(b){
    if(b&1){
      res=mul(res,a);
    }
    b/=2;
    a=mul(a,a);
  }
  return res;
}

template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
  input>>x.F>>x.S;
  return input;
}

template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
  for(auto& i:x)
    input>>i;
  return input;
}

template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
  for(auto& i:x)
    output<<i<<' ';
  return output;
}

template<typename T>
vector<pair<T,int>> getvec(int n){
  vector<pair<T,int>>a(n);
  for(int i=0;i<a.size();i++){
    cin>>a[i].F;
    a[i].S=i;
  }
  return a;
}

const int N=200005;

void solve(){
  ll h,w;
  cin>>h>>w;
  if(min(h,w)==1){
    cout<<1;
    return;
  }
  ll val=(h+1)/2;
  ll cnt=(w+1)/2;
  ll ans=0;
  ans+=val*cnt;
  ans+=(h-(val))*(w-cnt);
  cout<<ans;
    
  
}

signed main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  int tc=1;
  //cin>>tc;
  for(int _=0;_<tc;_++){
    // cout<<"Case #"<<_+1<<": ";
    solve();
    if(_!=tc-1){
      cout<<'\n';
    }
  }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
    
#define FAST ios_base::sync_with_stdio(false), cin.tie(0), cout.tie(0);
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
    
#define int long long
#define double long double
    
#define all(a)      (a).begin(),(a).end()
#define sz(x)       (int)x.size()
    
#define ff first
#define ss second
#define mp make_pair
         
#define pb push_back
#define endl "\n" 
         
#define f(i,l,r) for(int i=l;i<=r;i++)
#define rf(i,r,l) for(int i=r;i>=l;i--)    

#define bp __builtin_popcountll
#define inf 1e15
    
const int N=1e5+5;
const int M=1e9+7;
int dp[N],a[N];
int n;
int x=0,y=0,z=0;
int go(int p)
{
	if(p==n) return 1;
	if(dp[p]!=-1) return dp[p];
	int cnt=0;
	int need=a[p];
	if(x==need) cnt++;
	if(y==need) cnt++;
	if(z==need) cnt++;
	if(cnt==0)
	return 0;
	if(x==need){
		x++;
	}
	else if(y==need)
	{
		y++;
	}
	else
	{
		z++;
	}
	int ans=1;
	ans=(cnt*go(p+1))%M;
	dp[p]=ans;
	return ans;
}
void solve()
{
	cin>>n;
	f(i,0,n-1) cin>>a[i];
	memset(dp,-1,sizeof(dp));
	int res=go(0);
	cout<<res;
}
signed main()  
{
	FAST
    int t=1;
    // cin>>t;
    for(int tc=1;tc<=t;tc++)
    {
    	// cout<<"Case #"<<tc<<": ";
    	solve();
    }
}


Measured memory_bytes: 4992
#include <stdio.h>
#include <iostream>

using namespace std;

int main()
{
    int flag = 0;
    int N;
    string S;

    cin >> N;
    cin >> S;
    
    if ((N%2) != 0) cout << "No" << endl;
    else {
        for (int i=0;i<N/2;i++) {
            if (S[i] != S[i+N/2]) {
                cout << "No" << endl;
                flag = 0;
                break;
            }
            else {
                flag = 1;
            }
        }
    }
    if (flag == 1) cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 256
N = gets.to_i
A = N.times.map{gets.to_i}
cnt = 0

def fibo(n)
  f = [1, 1]
  i = 1
  while f[i-1] + f[i] < n
    f << f[i-1] + f[i]
    i += 1
  end
  f[1..-1].reverse
end

insertion = ->(a, g = 1) do
  g.step(N-1) do |i|
    v = a[i]
    j = i - g
    while j >= 0 && a[j] > v
      a[j+g] = a[j]
      j -= g
      cnt += 1
    end
    a[j+g] = v
  end
  a
end

shell = ->(a) do
  cnt = 0
  g = fibo(N)
  puts g.size
  puts g.join ' '
  g.each do |i|
    a = insertion.(a, i)
  end
  puts cnt
  a
end

shell.(A.dup).each do |d|
  puts d
end



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

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

    static class AHEX {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            String a = in.next();
            String b = in.next();
            int c = a.compareTo(b);
            out.print(c == 0 ? "=" : c < 0 ? "<" : ">");
        }

    }

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

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

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

        public void close() {
        }

    }
}



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

using namespace std;

int main(){

    int N, A, B;
    
    cin >> N >> A >> B;
    vector<int> P(N);
    int p1=0,p2=0,p3=0;
    for(int i=0; i<N; i++){
        cin >> P[i];
        if(P[i] <= A){
            p1++;
        }else if(B < P[i]){
            p3++;
        }else{
            p2++;
        }
    }

    cout << min({p1,p2,p3}) << endl;

    return 0;
}


Measured memory_bytes: 256
// Aizu 2199: Differential Pulse Code Modulation
// 2017.9.21 bal4u@uu
// 2017.12.10

#include <stdio.h>
#include <string.h>

#define INF   0x1fffffff
int code[18];				// code book
int dp[20001][257];			// Sum of Squares

char buf[15], *p;
int getsint()
{
	int n = 0;
	if (*p == '-') {
		p++; while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
		return -n;
	}
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int getint()
{
	int n = 0;
	while (*p >= '0') n = (n<<3) + (n<<1) + (*p++ & 0xf);
	return n;
}

int main()
{
	int n, m, i, j, k, x, s, t, ans;

	while (fgets(p=buf, 15, stdin) && *p != '0') {
		n = getint(), p++, m = getint();
		for (j = 0; j < m; j++) fgets(p=buf, 10, stdin), code[j] = getsint();

		memset(dp, 0x33, sizeof(dp));
		dp[0][128] = 0;

		for (k = 0; k < n; k++) {
			fgets(p=buf, 10, stdin), x = getint();
			for (i = 0; i < 256; i++) {
				if (dp[k][i] > INF) continue;
				for (j = 0; j < m; j++) {
					t = i + code[j];
					if (t < 0) t = 0;
					if (t >= 256) t = 255;
					s = (t-x)*(t-x) + dp[k][i];
					if (s < dp[k+1][t]) dp[k+1][t] = s;
				}
			}
		}

		for (ans = INF, i = 0; i < 256; i++) 
			if (dp[n][i] < ans) {
				ans = dp[n][i]; if (ans == 0) break;
			}
		printf("%d\n", ans);
	}
	return 0;
}

Measured memory_bytes: 21748
#include<iostream>
using namespace std;
int main() {
	int a;
	int ans;
	ans = 0;
	for (int i = 1; i <= 5; i++) {
		cin >> a;
		if (a <= 40) {
			a = 40;
		}
		ans = ans + a;
	}
	cout << ans / 5 << endl;
}


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

using namespace std;

#define REP(i, a, b) for (int i = (a), i##_end_ = (b); i < i##_end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

typedef long long LL;



vector<string> v,g;
set<string> s,t;
int ans;


int main()
{
	int n,m; string temp;
	cin >> n;
	REP(i,0,n){
		cin >> temp;
		s.insert(temp);
		v.push_back(temp);
	}
	cin >> m;
	REP(i,0,m){
		cin >> temp;
		g.push_back(temp);
	}
	set<string>::iterator it = s.begin();
	while(it != s.end()){
		int cur = 0;
		REP(i,0,v.size()) if (v[i] == (*it)) cur++;
		REP(i,0,g.size()) if (g[i] == (*it)) cur--;
		ans = max(ans, cur);
		it++;
	}
	cout << ans;

	return 0;
}


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

using namespace std;

string repr(string s,int p,int q,int r){
  int tmp;
  string s_tmp=s;
  while ((tmp = s_tmp.find("P")) >= 0){s_tmp.replace(s_tmp.find("P"),1,to_string(p));}
  while ((tmp = s_tmp.find("Q")) >= 0){s_tmp.replace(s_tmp.find("Q"),1,to_string(q));}
  while ((tmp = s_tmp.find("R")) >= 0){s_tmp.replace(s_tmp.find("R"),1,to_string(r));}
  return s_tmp;
}

string op_plus(string left,string right){
  int l,r;
  if (left[0]=='-'){l=2-(left[1]-'0');}
  else {l=left[0]-'0';}
  if (right[0]=='-'){r=2-(right[1]-'0');}
  else {r=right[0]-'0';}
  return to_string(max(l,r));
}

string times(string left,string right){
  int l,r;
  if (left[0]=='-'){l=2-(left[1]-'0');}
  else {l=left[0]-'0';}
  if (right[0]=='-'){r=2-(right[1]-'0');}
  else {r=right[0]-'0';}
  return to_string(min(l,r));
}

string solve(string str){
  while (str.substr(0,2) == "--"){str.erase(str.begin(),str.begin()+2);}
  if (str.length() == 1||str.length() == 2){
    if (str == "0"){
      return "0";
    } else if (str == "1"){
      return "1";
    } else if (str == "2"){
      return "2";
    } else if (str == "-0"){
      return "2";
    } else if (str == "-1"){
      return "1";
    } else if (str == "-2"){
      return "0";
    } else {
      cout << str << " :Error" << endl;
      return "-1";
    }
  }
  if (str[0] == '(') {
    str.erase(str.begin());
    str.pop_back();
  }
  int brcount = 0;
  int ind = 0;
  while (ind < str.length()){
    if (str[ind] == '('){++brcount;}
    if (str[ind] == ')'){--brcount;}
    if ((brcount == 0)&&(str[ind] == '+' || str[ind] == '*')) break;
    ++ind;
  }
  if (ind == str.length()){
    return to_string(2-(solve(str.substr(1,str.length()-1))[0]-'0'));
  }
  string left,right;
  left = solve(str.substr(0,ind));
  right = solve(str.substr(ind+1,str.length()-(ind+1)));
  if (str[ind] == '+'){
    return op_plus(left,right);
  }
  if (str[ind] == '*'){
    return times(left,right);
  }
}

int main(){
  string s,s_tmp;
  int sum;
  while (1){
    cin >> s;
    if (s == ".") {
      break;
    }
    sum = 0;
    for (int p=0;p<3;p++){
      for (int q=0;q<3;q++){
        for (int r=0;r<3;r++){
          s_tmp = repr(s,p,q,r);
          if (solve(s_tmp) == "2" ){++sum;}
        }
      }
    }
    cout << sum << endl;
  }
  return 0;
}

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

int main()
{
    int n, *x, *x_sorted, med, medplus;
    scanf("%d", &n);
    x = new int[n];
    x_sorted = new int[n];
    for (int i = 0; i < n; i++)
    {
        scanf("%d", x + i);
        x_sorted[i] = x[i];
    }
    std::sort(x_sorted, x_sorted + n);
    med = x_sorted[n / 2 - 1];
    medplus = x_sorted[n / 2];
    for (int i = 0; i < n; i++)
    {
        if (x[i] <= med) printf("%d\n", medplus);
        else printf("%d\n", med);
    }

    delete[] x;
    delete[] x_sorted;
    return 0;
}

Measured memory_bytes: 3712
#include<iostream>
#include<iomanip>
#include<stdio.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<functional>
#include<math.h>
#include<unordered_set>
using namespace std;

const int MAX = 100000;


int main() {
	int ans = 0;
	string str;
	cin >> str;

	for (int i = 0; i < str.length(); i++) {
		ans += str[i] - '0';
	}

	if (ans == 1)cout << 10 << endl;
	else cout << ans << endl;

	return 0;
}

Measured memory_bytes: 384
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
#[allow(unused_imports)]
use std::f64::consts::*;

#[allow(unused)]
const INF: usize = std::usize::MAX / 4;
#[allow(unused)]
const M: usize = 1000000007;

#[allow(unused_macros)]
macro_rules! debug {
    ($($a:expr),* $(,)*) => {
        #[cfg(debug_assertions)]
        eprintln!(concat!($("| ", stringify!($a), "={:?} "),*, "|"), $(&$a),*);
    };
}

fn main() {
    input! {
        n: usize,
    }
    let mut result = 0usize;
    for a in 1..n {
        result += (n + a - 1) / a - 1;
    }
    println!("{}", result);
}


Measured memory_bytes: 2172
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>

using namespace std;

int main() {
	int N;
	cin >> N;
	map<char, long long> m;
	for (int i = 0; i < N; i++) {
		string s;
		cin >> s;
		m[s[0]]++;
	}
	long long ret = 0;
	string march = "MARCH";
	for (int i = 0; i < 5; i++)
		for (int j = i + 1; j < 5; j++)
			for (int k = j + 1; k < 5; k++)
				ret += m[march[i]] * m[march[j]] * m[march[k]];
	cout << ret << endl;
	system("pause");
	return 0;
}

Measured memory_bytes: 504
A = list(map(int, input().split()))
if A[0] == 0:
    print(1)
if A[1] == 0:
    print(2)
if A[2] == 0:
    print(3)
if A[3] == 0:
    print(4)
if A[4] == 0:
    print(5)


Measured memory_bytes: 9036
import java.util.*;
// warm-up
public class Main {

	static void solve() {
		Scanner sc = new Scanner(System.in);
		int r = sc.nextInt(), c = sc.nextInt(), n=r;
		System.out.println("#"+"#".repeat(c)+"#");
		while (n-->0) System.out.println("#"+sc.next()+"#");
		System.out.println("#"+"#".repeat(c)+"#");
		sc.close();		
	}

	public static void main(String args[]) {
		solve();
	}

}

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

using namespace std;

int main()
{
	map<string,string>P;

	P["101"]=" ";
	P["000000"]="'";
	P["000011"]=",";
	P["10010001"]="-";
	P["010001"]=".";
	P["000001"]="?";
	P["100101"]="A";//A
	P["10011010"]="B";
	P["0101"]="C";
	P["0001"]="D";
	P["110"]="E";
	P["01001"]="F";
	P["10011011"]="G";
	P["010000"]="H";
	P["0111"]="I";
	P["10011000"]="J";
	P["0110"]="K";
	P["00100"]="L";
	P["10011001"]="M";
	P["10011110"]="N";
	P["00101"]="O";
	P["111"]="P";
	P["10011111"]="Q";
	P["1000"]="R";
	P["00110"]="S";
	P["00111"]="T";
	P["10011100"]="U";
	P["10011101"]="V";
	P["000010"]="W";
	P["10010010"]="X";
	P["10010011"]="Y";
	P["10010000"]="Z";

	map<char,string>PP;

	PP[65]="00000";
	PP[66]="00001";
	PP[67]="00010";
	PP[68]="00011";
	PP[69]="00100";
	PP[70]="00101";
	PP[71]="00110";
	PP[72]="00111";
	PP[73]="01000";
	PP[74]="01001";
	PP[75]="01010";
	PP[76]="01011";
	PP[77]="01100";
	PP[78]="01101";
	PP[79]="01110";
	PP[80]="01111";
	PP[81]="10000";
	PP[82]="10001";
	PP[83]="10010";
	PP[84]="10011";
	PP[85]="10100";
	PP[86]="10101";
	PP[87]="10110";
	PP[88]="10111";
	PP[89]="11000";
	PP[90]="11001";
	PP[32]="11010";
	PP[46]="11011";
	PP[44]="11100";
	PP[45]="11101";
	PP[39]="11110";
	PP[63]="11111";

	string str;

	while(getline(cin,str))
	{
		string dec;
		string set;
		string enc;

		for(int i=0;i<str.length();i++)dec+=PP[str[i]];
		for(int i=0;i<dec.length();i++)
		{
			set += dec[i];
			if(!(P[set].empty()))
			{
				enc += P[set];
				set.erase(set.begin(),set.end());
			}
		}
		cout << enc << endl;
	}
	
	return 0;
}

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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

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

const string YES = "Yes";
const string NO = "No";

int main(){
    int a, b, c;
    cin >> a >> b >> c;
    if (c<=a+b) cout << YES << endl;
    else cout << NO << endl;
    return 0;
}


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

#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define trav(a, x) for (auto& a : x)
#define all(x) x.begin(), x.end()
#define sz(x) (int)(x).size()
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

struct Tree {
	typedef int T;
	const T LOW = 0;
	T f(T a, T b) { return a+b; }

	int n;
	vi s;
	Tree() {}
	Tree(int m, T def=0) { init(m, def); }
	void init(int m, T def) {
		n = 1; while (n < m) n *= 2;
		s.assign(n + m, def);
		s.resize(2 * n, LOW);
		for (int i = n; i --> 1; )
			s[i] = f(s[i * 2], s[i*2 + 1]);
	}
	void update(int pos, T val) {
		pos += n;
		s[pos] = val;
		for (pos /= 2; pos >= 1; pos /= 2)
			s[pos] = f(s[pos * 2], s[pos * 2 + 1]);
	}
	T query(int l, int r) { return que(1, l, r, 0, n); }
	T que(int pos, int l, int r, int lo, int hi) {
		if (r <= lo || hi <= l) return LOW;
		if (l <= lo && hi <= r) return s[pos];
		int m = (lo + hi) / 2;
		return f(que(2 * pos, l, r, lo, m),
				que(2 * pos + 1, l, r, m, hi));
	}
};

const int N = 1e5 + 10;
bool isPrime[N];
Tree tree(N);

void pre() {
	fill(isPrime, isPrime + N, true);
	isPrime[0] = isPrime[1] = false;
	for(int i = 2; i < N; i++) {
		if(isPrime[i]) {
			for(int j = 2*i; j < N; j += i) {
				isPrime[j] = false;
			}
		}
	}
	for(int i = 0; i < N; i++) {
		if(isPrime[i] && (i+1)%2 == 0 && isPrime[(i+1)/2]) {
			tree.update(i, 1);
		}
	}
}

int main() {
	pre();
	int q;
	scanf("%d", &q);
	while(q--) {
		int l, r;
		scanf("%d %d", &l, &r);
		printf("%d\n", tree.query(l, r+1));
	}
}

Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define MOD 1000000007
#define vec vector
using namespace std;
int main()
{
	int n,i;
	cin>>n;
	int a[n],b[n],c[n];
	for(i=0;i<n;i++)
	{
		cin>>a[i]>>b[i]>>c[i];
		if(i>0)
		{
			a[i] += max(b[i-1],c[i-1]);
			b[i] += max(a[i-1],c[i-1]);
			c[i] += max(b[i-1],a[i-1]);
		}
	}
	int x = max(a[n-1],b[n-1]);
	cout<<max(x,c[n-1]);
}

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

int main(){
    int n;
    cin >> n;
    ll ans = 0;
    for(int i = 1; i <= n; ++i){
        if(i%3 == 0) continue;
        if(i%5 == 0) continue;
        ans += i;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3592
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func next() string {
	sc.Scan()
	return sc.Text()
}

func nextInt() int {
	sc.Scan()
	i, _ := strconv.Atoi(sc.Text())
	return i
}

func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(next(), 64)
	return f
}

func nextInts(n int) []int {
	slice := make([]int, n)
	for i := 0; i < n; i++ {
		slice[i] = nextInt()
	}
	return slice
}

func main() {
	sc.Split(bufio.ScanWords)
	n, s, k := nextInt(), next(), nextInt()
	for i := 0; i < n; i++ {
		if s[i] != s[k-1] {
			fmt.Printf("*")
		} else {
			fmt.Printf("%c", s[i])
		}
	}
	fmt.Printf("\n")
}


Measured memory_bytes: 640
//(・ω・)
#include <stdio.h>
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, atoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <iomanip> //setprecision
#include <limits>
#include <sstream> //istringstream
#include <stdlib.h>
#include <list>
#include <iterator>//std::advance()
using namespace std;

int main(){
   int n,k;
   cin >> n >> k;
   vector<int> d(k);
   vector<int> ans(n,0);
   for(int i=0; i<k; i++){
       cin >> d[i];
       for(int j=0; j<d[i]; j++){
           int a;
           cin >> a;
           ans[a-1]++;
       }
   }
   int sum=0;
   for(int i=0; i<n; i++){
       if(ans[i]==0) sum++;
   }
   cout << sum << endl;
}

Measured memory_bytes: 3632