akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
int main()
{
	int x,a[100],b[100],i,j;
	int max=0,s,t,n;
	scanf("%d",&n);
	for(i=0;i<n;i++)
	{
		scanf("%d",&a[i]);
	}
	for(i=0;i<n;i++)
	{
		scanf("%d",&b[i]);
	}
	for(i=0;i<n;i++)
	{
        s=0;
        for(j=0;j<=i;j++)
        {
        	s+=a[j];
		}
		for(j=i;j<n;j++)
		{
			s+=b[j];
		}
		if(max<s)
		{
			max=s;
		}
	}
	printf("%d",max);
	return 0;
} 

Measured memory_bytes: 256
#include <iostream>
#include <iomanip> //追加
#include <cmath>　//追加
using namespace std;

int main(void){
   double r;
   cin >> r; //浮動小数点数で読む
   
   double pi=acos(-1); //円周率
   cout << fixed  << setprecision(6);
   double area = r*r*pi;
   double cir=2*r*pi;
   cout << area << " " << cir << endl;
}


Measured memory_bytes: 3224
#include <stdio.h>
#include <cctype>
#include <limits.h>
#include <math.h>
#include <complex>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <cstring>
#include <string>
#include <sstream>
#include <algorithm>
#include <iomanip>
#include <iostream>

#define VARIABLE(x) cerr << #x << "=" << x << endl
#define BINARY(x) static_cast<bitset<16> >(x);
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for (int i=m;i<(int)(n);i++)
#define if_range(x, y, w, h) if (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))

const int INF = 1000000000;
const double EPS = 1e-8;
const double PI = 3.14159;
int dx[4]={0, 1, 0, -1}, dy[4]={-1, 0, 1, 0};
using namespace std;
//typedef pair<int, int> P;
struct P {
	int x, y;
	P(int x, int y):x(x), y(y){}
	P(){}
};

/** Problem2013 : Osaki **/
int MAX = 100000;

int toInt(string s)
{
	int h = (s[0]-'0')*10+s[1]-'0';
	int m = (s[3]-'0')*10+s[4]-'0';
	int se = (s[6]-'0')*10+s[7]-'0';
	
	return h*3600 + m*60 + se;
}

int main()
{
	int N;
	while (cin>>N, N) {
		vector<int> table(MAX);
		string a, b;
		rep(i, N) {
			cin>>a>>b;
			table[toInt(a)]++;
			table[toInt(b)]--;
		}
		
		REP(i, 1, MAX) {
			table[i] += table[i-1];
		}
		
		int ans=0;
		rep(i, MAX) {
			ans = max(ans, table[i]);
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1604
#include "bits/stdc++.h"
using namespace std;
typedef long long LL;
int main() {
	int N, K;
	cin >> N >> K;
	int ans = 1 << 30;
	for (int bit = 0; bit < (1 << N); bit++) {
		int x = 1;
		for (int i = 0; i < N; i++) {
			if (bit&(1 << i)) x *= 2;
			else x += K;
		}
		ans = min(ans, x);
	}
	cout << ans << endl;
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            Solve();
        }
        private const int MOD = 1000000007;
        static void Solve()
        {
            var n = ReadAndParseInt();
            int[] a = new int[n];
            int[] b = new int[n];
            int[] c = new int[n];
            for(int i=0;i<n;++i)
            {
                var abc = ReadAndParseIntArr();
                a[i] = abc[0];
                b[i] = abc[1];
                c[i] = abc[2];

            }
            int[,] dp = new int[n + 1,3];
            for(int i=0;i<n;++i)
            {
                int dpa = i >= 1 ? dp[i - 1, 0] : 0;
                int dpb = i >= 1 ? dp[i - 1, 1] : 0;
                int dpc = i >= 1 ? dp[i - 1, 2] : 0;
                dp[i, 0] = Math.Max(dpb + b[i], dpc + c[i]);
                dp[i, 1] = Math.Max(dpa + a[i], dpc + c[i]);
                dp[i, 2] = Math.Max(dpa + a[i], dpb + b[i]);
            }
            int ans = Math.Max( dp[n-1,0], Math.Max(dp[n-1,1], dp[n-1,2]));
            Console.WriteLine(ans);
        }
        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if (x == 2) { return true; }
            if (x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while (i * i <= x)
            {
                if (x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }
        private static long pow(long x, long n)
        {
            if (n == 0) { return 1; }
            long res = pow(x * x % MOD, n / 2);
            if (n % 2 == 1)
            {
                res = res * x % MOD;
            }
            return res;
        }
        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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


#include <algorithm>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <string>
#include <vector>

using namespace std;

class EGluttony {
public:
  void solve(std::istream &cin, std::ostream &cout) {
    long long int n, k;
    cin >> n >> k;
    vector<long long int> a_vec(n);
    vector<long long int> f_vec(n);
    for (int i = 0; i < n; ++i)
      cin >> a_vec[i];
    sort(a_vec.begin(), a_vec.end());
    for (int i = 0; i < n; ++i)
      cin >> f_vec[i];
    sort(f_vec.begin(), f_vec.end(), greater<>());
    int64_t left = -1;
    int64_t right = 1e+18 + 1;
    int64_t ans = 0;
    while (right - left > 1) {
      int64_t cost = (right + left) / 2;
      int64_t training_count = 0;
      for (int i = 0; i < n; ++i) {
        int64_t a = a_vec[i];
        int64_t f = f_vec[i];
//        middle以下にするための修行回数
        if (a * f > cost) {
          int64_t lack_cost = a * f - cost;
          training_count += (lack_cost + (f - 1)) / f;
        }
      }
      if (training_count > k) {
        left = cost;
      } else {
        right = cost;
        ans = right;
      }
    }
    cout << ans << endl;
  }
};


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


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

typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef pair<ll,ll> pll;
typedef vector<bool> vb;
const ll oo = 0x3f3f3f3f3f3f3f3f;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c), end(c)
#define FOR(i,a,b) for (ll i = (a); i < (b); i++)
#define FORD(i,a,b) for (ll i = (b)-1; i >= (a); i--)
#define mp make_pair
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define TR(X) ({ if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

typedef bitset<2005> bits;

int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	ll n; cin >> n;
	vector<bits> win(n+2);
	FOR(i,0,n) FOR(j,0,i) {
		char c; cin >> c;
		if (c == '1') win[i+1][j+1] = 1; else win[j+1][i+1] = 1;
	}
	FOR(i,0,n) win[i+1][0] = win[i+1][n+1] = 1;
	n += 2;
	
	vector<bits> dwL(n), dwR(n);
	FOR(i,1,n)   dwL[i][i-1] = 1;
	FOR(i,0,n-1) dwR[i][i+1] = 1;
	
	FOR(len,2,n) FOR(i,0,n) {
		ll j = i+len;
		if (j >= n) break;

		bool cur = (dwR[i] & dwL[j] & (win[i] | win[j])).any();
		if (cur) dwR[i][j] = dwL[j][i] = 1;
	}
	
	ll res = 0;
	FOR(i,1,n-1) if (dwL[i][0] && dwR[i][n-1]) res++;
	cout << res << endl;

}



Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
using namespace std;
using ll = long long;

int main(void){
    while(1){
        int h, w;
        cin >> h >> w;
        if(h == 0) break;
        for(int i = 0; i < w; i++) cout << '#';
        cout << endl;
        for(int i = 2; i < h; i++){
            cout << '#';
            for(int j = 2; j < w; j++) cout << '.';
            cout << '#';
            cout << endl;
        }
        for(int i = 0; i < w; i++) cout << '#';
        cout << endl << endl;
    }
    return 0;
}


Measured memory_bytes: 3100
import java.util.*;
import java.io.*;
import java.nio.charset.StandardCharsets;

public class Main {
	int N;
	String S;
	Set<Character>[] befores, afters;
	Map<Integer, Set<Character>> before, after;
	int num;

	public static void main(String[] args) throws IOException {
		InputStreamReader reader = new InputStreamReader(System.in, StandardCharsets.UTF_8);
		BufferedReader in = new BufferedReader(reader);
		Main ins = new Main(in);
		ins.calc();
		ins.showResult();
	}

	Main(BufferedReader in) throws IOException {
		N = Integer.parseInt(in.readLine());
		S = in.readLine();
		this.befores = new Set[S.length()];
		this.afters = new Set[S.length()];
	}

	void calc() {
		// 前集合を求める
		this.befores[0] = new HashSet<Character>();
		for (int i = 1; i < S.length(); ++i) {
			Set<Character> set = new HashSet<>();
			set.addAll(this.befores[i - 1]);
			set.add(S.charAt(i - 1));
			this.befores[i] = set;
		}
		// 後集合を求める
		this.afters[N - 1] = new HashSet<>();
		for (int i = N - 2; i >= 0; --i) {
			Set<Character> set = new HashSet<>();
			set.addAll(this.afters[i + 1]);
			set.add(S.charAt(i + 1));
			this.afters[i] = set;
		}
		Set<String> s = new HashSet<>();

		for (int i = 1; i < N - 1; ++i) {
			for (Character b : this.befores[i]) {
				for (Character a : this.afters[i]) {
					StringBuilder strBuilder = new StringBuilder();
					strBuilder.append(b);
					strBuilder.append(S.charAt(i));
					strBuilder.append(a);
					s.add(strBuilder.toString());
				}
			}
		}
		num = s.size();
	}

	void showResult() {
		System.out.println(num);
	}
}


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

using namespace std;

int solve(int N, int X, const set<int>& as)
{
    int L = 0;

    for (int i = X - 1; i >= 0; --i)
        L += as.count(i);

    int R = 0;

    for (int i = X + 1; i <= N; ++i)
        R += as.count(i);

    auto ans = min(L, R);

    return ans;
}

int main()
{
    ios::sync_with_stdio(false);

    int N, M, X;
    cin >> N >> M >> X;

    set<int> as;

    while (M--)
    {
        int a;
        cin >> a;

        as.insert(a);
    }

    auto ans = solve(N, X, as);

    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
use std::cmp;
use std::fmt::Debug;
use std::str::FromStr;
#[allow(dead_code)]
fn read_as_vec<T>() -> Vec<T>
where
    T: FromStr,
    <T as FromStr>::Err: Debug,
{
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim()
        .split_whitespace()
        .map(|c| T::from_str(c).unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_as_string() -> String {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    s.trim().to_string()
}

fn main() {
    let n: usize = read_as_vec()[0];
    let mut a: Vec<usize> = vec![];

    for _ in 0..n {
        a.push(read_as_vec()[0]);
    }

    if a.iter().all(|x| x % 2 == 0) {
        println!("second");
    } else {
        println!("first");
    }
}


Measured memory_bytes: 2896
#include <cstdio>
#include <vector>
#include <utility>
#include <algorithm>
#include <cstring>
using namespace std;
typedef pair<int,int> ii;
int n,k;
vector<ii> food;
int memo[3005];
int main(){
    scanf("%d%d",&n,&k);
    int a,b;
    for (int x=0;x<n;x++){
        scanf("%d%d",&a,&b);
        food.push_back(ii(a,b));
    }

    sort(food.begin(),food.end());

    memset(memo,-1,sizeof(memo));
    memo[0]=0;

    int ans=0;

    for (int x=0;x<n;x++){
        for (int y=0;y<k;y++){
            if (memo[y]!=-1) ans=max(ans,memo[y]+food[x].second);
        }
        for (int y=k-food[x].first;y>=0;y--){
            if (memo[y]!=-1) memo[y+food[x].first]=max(memo[y+food[x].first],memo[y]+food[x].second);
        }
    }

    printf("%d\n",ans);
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define debug(x) cerr << # x << "; "<< x << endl


int main() {
	int N;
	string S;
	cin >> N >> S;

	for (int i = 0; i < N / 2; i++) {
		if (N % 2 == 1) {
			cout << "No" << endl;
			break;
		}
		 else if (S.at(i) == S.at(N / 2 + i) && i + 1 < N / 2) {
			continue;
		}
		else if (S.at(i) == S.at(N / 2 + i) && i + 1 == N / 2) {
			cout << "Yes" << endl;
		}
		else {
			cout << "No" << endl;
			break;
		}
		}
	if (N == 1) {
		cout << "No" << endl;
	}
	}


Measured memory_bytes: 3628
import math
N,M=map(int,input().split())
if N>=2 and M>1:
    print(int(math.factorial(N)/(math.factorial(2)*math.factorial(N-2))+math.factorial(M)/(math.factorial(2)*math.factorial(M-2))))
    exit()
if N>=2:
    print(int(math.factorial(N)/(math.factorial(2)*math.factorial(N-2))))
elif M>1:
    print(int(math.factorial(M)/(math.factorial(2)*math.factorial(M-2))))
else:
    print(int(N//2+M//2))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
	int n;
	cin >> n;
	vector<int> a(n);
	for(int i=0; i<n; ++i) cin >> a[i];
	sort(a.begin(),a.end(),greater<int>());
	long long ans=a[0];
	for(int i=2; i<n; ++i){
		ans += a[i/2];
	}
	cout << ans << endl;
}

Measured memory_bytes: 4024
#include <stdio.h>

int main(void) {
 int k, a, b;

 scanf("%d", &k);
 scanf("%d%d", &a, &b);

 int largest = (b / k) * k;
 if (a <= largest) {
 puts("OK");
 } else {
 puts("NG");
 }

 return 0;
 }

Measured memory_bytes: 1640
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long int ll;

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


const int MAX_N = 10010, MAX_W = 10010, MAX_V = 10010;

int A, B, C;

int main()
{
	cin >> A >> B >> C;

	if (A == B)
	{
		if (B == C)
		{
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

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

using ll = long long;
using ld = long double;
using pii = pair<int, int>;

#define REP(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))

int dx4[4] = {1,0,-1,0}, dy4[4] = {0,1,0,-1};

int main(){
    int ans=100000;
    string s;
    cin>>s;
    
    for(int i = 0; i < s.size()-2; i++)
    {
        string ss = s.substr(i,3);
        int n = stoi(ss);
        ans=min(ans,abs(n-753));
    }
    

    cout<<ans<<endl;
    return 0;
}

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}
ll nextLong() { ll x; scanf("%lld", &x); return x;}

const int MAX_N = 212345;
int c[MAX_N];
vector<int> g[MAX_N];
ll ans[MAX_N];

// 点に加算、範囲の和
// 内部的には 1-based であるが、利用するときには 0-based な実装
struct BIT {
  using Val = ll;
  int n;
  vector<Val> tree;
  BIT(int n):n(n),tree(n+1) {}
  void fill(Val val) {
    REP(i, n+1) tree[i] = (i&-i) * val;
  }
  void add(int idx, Val val) {
    for (int x=idx+1; x<=n; x+=x&-x) tree[x] += val;
  }
  // sum[0, idx]
  Val range(int idx) {
    Val sum=0;
    for (int x=idx+1; x>0; x-=x&-x) sum += tree[x];
    return sum;
  }
  // sum[a, b]
  Val range(int a, int b) {
    return range(b) - range(a - 1);
  }
};


int in[MAX_N];
int out[MAX_N];
int rin[MAX_N];

void dfs(int cur, int prev, int &k) {
  in[k] = cur;
  rin[cur] = k;
  k++;
  for (int nxt : g[cur]) if (nxt != prev) {
    dfs(nxt, cur, k);
  }
  out[cur] = k;
}


int main2() {
  REP(i, MAX_N) g[i].clear();
  CLR(ans, 0);

  int N = nextInt();
  REP(i, N) c[i] = nextInt() - 1;
  REP(i, N-1) {
    int a = nextInt() - 1;
    int b = nextInt() - 1;
    g[a].push_back(b);
    g[b].push_back(a);
  }

  {
    int k = 0;
    dfs(0, -1, k);
    // pv(in, in+N);
    // pv(out, out+N);
  }

  vector<vector<int>> cs(N);
  REP(i, N) cs[c[i]].push_back(i);

  BIT bit(N + 10);
  bit.fill(1);

  REP(i, N) {

    vector<pair<int,ll>> history;

    vector<int> vs = cs[i];
    sort(ALL(vs), [&](int a, int b) -> bool {
      return rin[a] > rin[b];
    });

    ll val = 0;
    for (int v : vs) {
      for (int u : g[v]) if (rin[v] < rin[u]) {
        int idx = rin[u];

        ll n = bit.range( idx, out[u]-1 );
        val += n * (n+1) / 2;
      }

      int idx = rin[v];
      ll n = bit.range( idx, out[v]-1 );
      bit.add(idx, -n);
      history.push_back({idx, n});
    }
    {
      ll n = bit.range(0, N-1);
      val += n * (n+1) / 2;
    }
    ans[i] = val;
    for (auto p : history) bit.add(p.first, p.second);
  }

  REP(i, N) {
    printf("%lld\n", (ll)(N)*(N+1)/2 - ans[i]);
  }
    cout << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}

Measured memory_bytes: 42204
object Main extends App {
  val in = io.Source.stdin.getLines.toIndexedSeq
  val K = in.head.split(' ').map(_.toInt).apply(1)
  val ls = in.tail.map(_.toInt).toArray.sorted
  //println(K)
  //println(ls)
  
  val ret = (0 to ls.size - K).foldLeft(Int.MaxValue){ (a,i) =>
    val diff = Math.abs(ls(i) - ls(i+K-1))
    Math.min(a, diff)
  }
  println(ret)
}


Measured memory_bytes: 46904
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

queue<P> q1;

char ca[100];
int p[25][2];//place
bool good[25][25];
int used[25][25];
int dis[25][25];
int dp[1<<15][15];

int main(){
	int n,m;
	int i,j,k;
	int a,b,c;
	int x,y;
	int s;
	while(cin>>m>>n){
		if(n==0 && m==0)break;
		k=1;
		for(i=0;i<n;i++){
			cin>>ca;
			for(j=0;j<m;j++){
				if(ca[j]=='x')good[i][j]=false;
				else good[i][j]=true;
				if(ca[j]=='o')p[0][0]=i,p[0][1]=j;
				if(ca[j]=='*')p[k][0]=i,p[k][1]=j,k++;
			}
		}
		for(i=0;i<k;i++){
			memset(used,-1,sizeof(used));
			q1.push(make_pair(p[i][0],p[i][1]));
			for(j=0;x=q1.size();j++){
				while(x--){
					a=q1.front().first,b=q1.front().second,q1.pop();
					if(a<0 || a>=n || b<0 || b>=m)continue;
					if(!good[a][b])continue;
					if(used[a][b]!=-1)continue;
					used[a][b]=j;
					q1.push(make_pair(a-1,b));
					q1.push(make_pair(a+1,b));
					q1.push(make_pair(a,b-1));
					q1.push(make_pair(a,b+1));
				}
			}
			for(j=0;j<k;j++){
				dis[i][j]=used[p[j][0]][p[j][1]];
			}
		}
		k--;
		for(i=0;i<(1<<k);i++)for(j=0;j<k;j++)dp[i][j]=INF;
		for(i=0;i<k;i++)if(dis[0][i+1]!=-1)dp[0][i]=dis[0][i+1];
		for(i=0;i<(1<<k);i++){
			for(j=0;j<k;j++){
				if(i&(1<<j))continue;
				for(x=0;x<k;x++){
					if((i&(1<<x))==0)continue;
					if(dis[j+1][x+1]!=-1)dp[i][j]=min(dp[i][j],dp[i-(1<<x)][x]+dis[j+1][x+1]);
				}
			}
		}
		s=INF;
		for(i=0;i<k;i++){
			s=min(s,dp[(1<<k)-(1<<i)-1][i]);
		}
		if(s==INF)s=-1;
		cout<<s<<endl;
	}
}



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

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

using namespace std;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int INF=1<<29;

int main(){
	int h,w,k; cin>>h>>w>>k;
	int sy,sx,gy,gx; cin>>sy>>sx>>gy>>gx; sy--; sx--; gy--; gx--;
	vector<string> B(h);
	rep(i,h) cin>>B[i];

	vector d(h,vector(w,INF));
	d[sy][sx]=0;
	queue<pair<int,int>> Q;
	Q.emplace(sy,sx);
	while(!Q.empty()){
		int y,x; tie(y,x)=Q.front(); Q.pop();
		rep(dir,4){
			int y2=y,x2=x;
			rep(_,k){
				y2+=dy[dir];
				x2+=dx[dir];
				if(y2<0 || h<=y2 || x2<0 || w<=x2 || B[y2][x2]=='@' || d[y2][x2]<=d[y][x]) break;
				if(d[y2][x2]>d[y][x]+1){
					d[y2][x2]=d[y][x]+1;
					Q.emplace(y2,x2);
				}
			}
		}
	}

	printf("%d\n",d[gy][gx]<INF?d[gy][gx]:-1);

	return 0;
}


Measured memory_bytes: 12096
// https://atcoder.jp/contests/dp/tasks/dp_g

#pragma GCC optimize("O3")
#include <bits/stdc++.h>

using namespace std;

typedef long long int ll;

int a[100005];
bool vis[100005];

void DFS(vector<int> adj[] , int s)
{
    vis[s] = 1;
    for(int i=0 ; i<adj[s].size() ;i++)
    {
        if(!vis[adj[s][i]])
        {
            DFS(adj,adj[s][i]);
        }
        a[s] = max(a[adj[s][i]]+1,a[s]);
    }
}

int main()
{
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n,m;
    cin >> n >> m;
    vector<int> adj[n+1];
    bool in[n+1]={0};
    for(int i=0 ; i<m ; i++)
    {
        int u,v;
        cin >> u >> v;
        adj[u].push_back(v);
        in[v] = 1;
    }
    for(int i=1 ; i<=n ; i++)
    {
        if(!vis[i])
        {
            DFS(adj,i);
        }
    }
    int ans = 0;
    for(int i=1;  i<=n ; i++)
        ans = max(ans,a[i]);
    cout << ans;
    return 0;
}


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

int main(){
  long long N, x, ans=0;
  cin >> N;
  
  if(N%2==1)
    cout << 0 << endl;
  else{
    for(long long i=10; i<=N; i*=5){
      ans += N/i;
    }
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
N, K = map(int, input().split())
l = input().split()
 
cnt=0
end_point=0 
for i,e in enumerate(l):
    if i !=end_point:
        continue 
    #print(i)
    #print(e)
    #print(l)
    #print(l[i:i+K])
    m= min(l[i:i+K])
    try:
        cnt =cnt+1
        for j in range(K):
            l[i+j]=m
        if i+j == len(l)-1:
            cnt=cnt-1
    except:
        print(cnt)
    end_point=i+j
#print(cnt)
#if i==len(l)-1:
    #print(cnt)

Measured memory_bytes: 10612
a = list(map(int,input().split()))
W = a[0]
H = a[1]
x = a[2]
y = a[3]
r = a[4]
if x-r >= 0 and x+r <= W and y-r >= 0 and y+r <= H:
    print("Yes")
else:
    print("No")


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
int main(){
	int N, M; long long K; 
	cin >> N >> M >> K; 
	long long A[200010] = {}; 
	long long B[200010] = {}; 
	long long S[200010] = {}; 
	long long T[200010] = {}; 
	for(int i = 1; i <= N; i++){
		cin >> A[i]; 
		S[i] = A[i] + S[i-1]; 
	}
	for(int i = 1; i <= M; i++){
		cin >> B[i]; 
		T[i] = B[i] + T[i-1]; 
	}
	int ans = 0; 
	for(int i = 0; i <= N; i++){
		long long rem = K - S[i]; 
		if(rem < 0) continue; 
		int a = upper_bound(T, T + M + 1, rem) - T; 
		ans = max(ans, i + a - 1); 
	}
	cout << ans << endl; 
}

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

// 小数点以下桁数
// fixed << setprecision(i)

int gcd(int a,int b){return (a%b==0?b:gcd(b, a%b));}
int64_t lcm(int a,int b){return (int64_t)a*b/gcd(a, b);}
int factorial(int a){int b=1;while(a){b*=a--;}return b;} //13以下対応
bool is_prime(int a){if(a<=1)return false;for(int i=2;(int64_t)i*i<=a;i++){if(a%i==0)return false;}return true;}
int get_adp(double x, int n){return (int)round((x-(int)x)*pow(10,n))%10;} // 小数点以下の指定桁の値を取得

//順列の全列挙
// vector<int> v(N);
// iota(v.begin(), v.end(), 1);       // v に 1, 2, ... N を設定
// do {
//   for(auto x : v) cout << x << " "; cout << "\n";    // v の要素を表示
// } while( next_permutation(v.begin(), v.end()) ); 

//bit全探索
// for (int tmp = 0; tmp < (1 << ビット数); tmp++) {
//   bitset<ビット数> s(tmp);
//   // (ビット列sに対する処理)
// }

int main()
{
  int h, w, k, count_b, ans = 0;
  char a;
  vector<vector<bool>> c(6, vector<bool>(6, false));

  cin >> h >> w >> k;
  for (int i = 0; i < h; i++)
  {
    for (int j = 0; j < w; j++)
    {
      cin >> a;
      if (a == '#')
        c[i][j] = true;
    }
  }
  for (int tmp1 = 0; tmp1 < (1 << h); tmp1++)
  {
    bitset<6> s(tmp1);
    for (int tmp2 = 0; tmp2 < (1 << w); tmp2++)
    {
      count_b = 0;
      bitset<6> t(tmp2);
      for (int i = 0; i < h; i++)
      {
        for (int j = 0; j < w; j++)
        {
          if (s[i] && t[j])
          {
            if (c[i][j])
              count_b++;
          }
        }
      }
      if (count_b == k)
        ans++;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3628
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>

using namespace std;

#include <iostream>
//#include <fstream>

//ifstream cin ("input.in");
//ofstream cout ("output.out");

//ifstream cin (".in")
//ofstream cout (".out");

string s;

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

	int n, k;
	cin>>n;
	cin>>s;
	cin>>k;

	char neededChar = s[k-1];
	for ( int i = 0; i < n; ++i ) {
		if ( s[i] == neededChar ) continue;
		s[i] = '*';
	}

	cout<<s<<'\n';
}

Measured memory_bytes: 256
import math

class Vector:
    def __init__(self,x,y):
        self.x = x
        self.y = y
        
    def __add__(self,other):
        return Vector(self.x+other.x,self.y+other.y)
    
    def __sub__(self,other):
        return Vector(self.x-other.x,self.y-other.y)
    
    def __mul__(self,scalar):
        return Vector(self.x*scalar,self.y*scalar)
    def __rmul__(self, scalar):
        return Vector(self.x*scalar,self.y*scalar)
    
   
    def __repr__(self):
        return str([self.x,self.y])
        
    def norm_2(self):
        return dot(self,self)
    
    def norm(self):
        return math.sqrt(self.norm_2())
    
def v_sum(v1,v2):
    return Vector(v1.x+v2.x,v1.y+v2.y) 
def scalar_multi(k,v):
    return Vector(k*v.x,k*v.y)
def v_diff(v1,v2):
    return v_sum(v1,scalar_multi(-1,v2))
    
def dot(vector1,vector2):
    return vector1.x*vector2.x+vector1.y*vector2.y

def cross(vector1,vector2):
    return vector1.x*vector2.y-vector1.y*vector2.x

cx1,cy1,r1 = map(int,input().split())
c1 = Vector(cx1,cy1)
cx2,cy2,r2 = map(int,input().split())
c2 = Vector(cx2,cy2)

d = c2-c1

cos = (r1**2+d.norm_2()-r2**2)/(2*r1*d.norm())
h = r1*cos/d.norm()*d + c1
l = r1*math.sqrt(1-cos**2)
n = Vector(d.y,-d.x)

a = h + l/n.norm()*n
b = h - l/n.norm()*n

if abs(a.x)<10**(-9):
    a.x = 0
if abs(a.y)<10**(-9):
    a.y = 0
if abs(b.x)<10**(-9):
    b.x = 0
if abs(b.y)<10**(-9):
    b.y = 0

if a.x<b.x:
    print('{} {} {} {}'.format(a.x,a.y,b.x,b.y))
elif a.x>b.x:
    print('{} {} {} {}'.format(b.x,b.y,a.x,a.y))
else:
    if a.y<b.y:
        print('{} {} {} {}'.format(a.x,a.y,b.x,b.y))
    else:
        print('{} {} {} {}'.format(b.x,b.y,a.x,a.y))


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

void Main()
{
    int h, w, k;
    cin >> h >> w >> k;
    string t;
    char s[h][w];
    for(int i = 0; i < h; i++){
        cin >> t;
        for(int j = 0; j < w; j++){
            s[i][j] = t[j] - '0';
        }
    }
    int n_cut_min = 10000000;
    for(int b = 0; b < (1<<(h-1)); b++){
        int nb = 0;
        int idx[h];
        for (int i = 0; i < h; i++)
        {
            idx[i] = nb;
            if((b >> i) & 1) nb++;
        }
        int n_cut = nb;
        int sum[nb+1] = {0};
        for(int i = 0; i < w; i++){
            bool cut = false;
            bool failed = false;
            int s2[nb+1] = {0};
            for (int j = 0; j < h; j++)
            {
                s2[idx[j]] += s[j][i];
            }
            for (int j = 0; j < nb+1; j++)
            {
                if(sum[j] > k){
                    failed = true;
                }
                if(sum[j] + s2[j] > k){
                    cut = true;
                }
            }
            if(failed){
                n_cut = 10000000;
                break;
            }
            if(cut){
                n_cut++;
                for (int j = 0; j < nb+1; j++){ 
                    sum[j] = 0;
                }
            }
            for (int j = 0; j < nb+1; j++){
                sum[j] += s2[j];
            }
        }
        n_cut_min = min(n_cut_min, n_cut);
    }
    cout << n_cut_min << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define all(x) (x).begin(),(x).end()
const int mod=1000000007,MAX=10005,INF=1<<29;
vector<pair<int,ll>> G[MAX];
ll dis[MAX];
int H,W;

void dijkstra(){
    priority_queue<pair<ll,int>,vector<pair<ll,int>>,greater<pair<ll,int>>> PQ;
    
    dis[0]=0;
    PQ.push({0,0});
    while(!PQ.empty()){
        ll a=PQ.top().first;
        int b=PQ.top().second;
        PQ.pop();
        if(dis[b]<a) continue;
        for(int i=0;i<G[b].size();i++){
            int c=G[b][i].first;
            ll d=G[b][i].second;
            if(dis[c]>dis[b]+d){
                dis[c]=dis[b]+d;
                PQ.push(make_pair(dis[c],c));
            }
        }
    }
    return;
}//a,dが長さ

vector<int> dh={0,1,0,-1},dw={1,0,-1,0};

int main(){
    
    std::ifstream in("text.txt");
    std::cin.rdbuf(in.rdbuf());
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    while(1){
        cin>>W>>H;
        if(H+W==0) break;
        
        for(int i=0;i<MAX;i++) dis[i]=INF;
        for(int i=0;i<MAX;i++) G[i].clear();
        
        vector<vector<int>> S(H,vector<int>(W));
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                cin>>S[i][j];
            }
        }
        vector<int> cost(4);
        for(int i=0;i<4;i++) cin>>cost[i];
        
        for(int i=0;i<H;i++){
            for(int j=0;j<W;j++){
                for(int k=0;k<4;k++){
                    for(int l=0;l<4;l++){
                        int toi=i+dh[l],toj=j+dw[l];
                        if(toi<0||toi>=H||toj<0||toj>=W) continue;
                        
                        if(S[i][j]==((4+l-k)%4)) G[k*H*W+(i*W+j)].push_back({l*H*W+(toi*W+toj),0});
                        else G[k*H*W+(i*W+j)].push_back({l*H*W+(toi*W+toj),cost[(4+l-k)%4]});
                    }
                }
            }
        }
        
        dijkstra();
        
        ll ans=INF;
        
        for(int k=0;k<2;k++) ans=min(ans,dis[k*H*W+(H*W-1)]);
        cout<<ans<<endl;
    }
}





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

int main(){
  string S,T;
  cin>>S>>T;
  vector<vector<int>> X(334);
  vector<vector<int>> Y(334);
  for(int i=0;i<S.size();i++){
    X[S[i]].push_back(i);
    Y[T[i]].push_back(i);
  }
  bool j=true;
  for(int i=0;i<334;i++){
    if(!X[i].empty()){
      auto x=X[i].begin();
      char a=T[*x];
      x++;
      while(x != X[i].end()){
        if(a!=T[*x]){
          j=false;
          break;
        }
        x++;
      }
    }
    if(!Y[i].empty()){
      auto y=Y[i].begin();
      char b=S[*y];
      y++;
      while(y != Y[i].end()){
        if(b!=S[*y]){
          j=false;
          break;
        }
        y++;
      }
    }
    if(!j)
      break;
  }
  if(j)
    cout<<"Yes"<<endl;
  else
    cout<<"No"<<endl;
}

Measured memory_bytes: 3080
#include <iostream>
#include <stdio.h>
#include <string>

using namespace std;
string map[12];

int dx[4]={-1,0,1,0};
int dy[4]={0,-1,0,1};

void dfs(int x,int y){
  if(!(0<=x&&x<12&&0<=y&&y<12)){
    return;
  }else if(map[y][x]=='0'){
    return;
  }else{
    map[y][x]='0';
  }
  for(int i=0;i<4;i++){
    dfs(x+dx[i],y+dy[i]);
  }
}

int main(){
  
  while(1){
    int count = 0;
    for(int i=0;i<12;i++){
      cin >> map[i];
    }
    if(getchar()==EOF){
      break;
    }
    for(int i=0;i<12;i++){
      for(int j=0;j<12;j++){
        if(map[j][i]=='1'){
          dfs(i,j);
          count++;
        }
      }
    }
    cout << count << endl;
  }
  return 0;
}
  

Measured memory_bytes: 3176
#pragma target("avx")
#pragma optimize("O3")
#include<bits/stdc++.h>
using ll = int_fast64_t;
using P = std::pair<ll,ll>;
using PP = std::pair<ll,P>;
using V = std::vector<ll>;
template<typename T> using pq = std::priority_queue<T>;
template<typename T> using rpq = std::priority_queue<T, std::vector<T>, std::greater<T>>;

#define REP(i,b,e) for(ll i=b; i<e; i++)
#define ALL(vec) vec.begin(),vec.end()
#define PRINT(vec) printf("[ ");for(auto &i:vec)printf("%ld ",i);puts("]");
#define SCAN(vec) for(auto &i:vec)scanf("%ld",&i)
#define fi first
#define se second

const int MOD = 1e9+7;
const ll INF = 1e18;
int dx[] = {0, 1, 0, -1, 1, 1, -1, -1}, dy[] = {1, 0, -1, 0, 1, -1, -1, 1};

int main(){
	int n, ok = false;
	scanf("%d", &n);
	REP(i, 0, 100) REP(j, 0, 100){
		if(4*i+7*j==n) ok = true;
	}
	puts(ok? "Yes":"No");
	return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#define N 100

int main(){
  int a,i,j,v,n;
  int A[1000];
  
  scanf("%d",&n);
  
  for(i=0;i<n;i++){
    scanf("%d",&A[i]);
    printf("%d",A[i]);
    if(i!=n-1)printf(" ");
  }
  printf("\n");
  
  for(i=1;i<n;i++){
    v = A[i];
    j = i-1;
    while(j >= 0 && A[j] > v){
      A[j+1] = A[j];
      j--;
    }
    A[j+1] = v;
    for(a=0;a<n;a++){ 
      printf("%d",A[a]);
      if(a!=n-1)printf(" ");
    }
    printf("\n");
  }

  return 0;
}
    



Measured memory_bytes: 2044
#include<iostream>
#include<iomanip>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<string>
#include<utility>
#include<numeric>
#include<algorithm>
#include<cmath>
#include<climits>
using namespace std;

using ll = long long;

class Stream{
public:
    Stream(){

    }
    //配列以外の入力を受け取る
    void read(){

    }
    template<typename First, typename... Rest>
    void read(First& first, Rest&... rest){
        cin >> first;
        read(rest...);
    }
    //配列を区切って出力する
    template<typename T>
    void write_vec(vector<T>& v, char divider){
        for(size_t i = 0; i < v.size(); i++){
            cout << v[i] << divider;
        }
    }
};

struct UF{
    const int node_num;
    vector<int> parent;
    vector<int> size;

    UF(int N) : node_num(N), parent(N), size(N, 1) {
        for(int i = 0; i < N; ++i) parent[i] = i;
    }

    //xの根を得る
    int root(int x){
        if(parent[x] == x) return x;
        return parent[x] = root(parent[x]);
    }

    //xが属する木とyが属する木を一つに合わせる
    void unite(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        if(root_x == root_y) return;
        parent[root_y] = root_x;
        size[root_x] += size[root_y];
    }

    //xとyが属する木が同じならtrueを返す
    bool same(int x, int y){
        int root_x = root(x);
        int root_y = root(y);
        return root_x == root_y;
    }

    //xと同じ木に属する要素の数を返す
    int same_size(int x){
        int root_x = root(x);
        return size[root_x];
    }
};

int main(){
    Stream io;
    
    int A, B;
    char op;
    io.read(A, op, B);
    if(op == '+') cout << A + B;
    else cout << A - B;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
ll n;
int main(){
    cin>>n;
    string ans;
    while(n){
        n--;
        ans+=(char)('a'+(n)%26);
        n/=26;
    }
    reverse(all(ans));
    cout<<ans;
}



Measured memory_bytes: 3128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;

int main(int argc, char *argv[]) { ios::sync_with_stdio(false);cin.tie(nullptr);cout.tie(nullptr);


  ll n,m,k;cin>>n>>m>>k;
  vector<int> A(n),B(m);
  ll aSum=0;
  ll bSum=0;
  int bptr=m-1;
  for(int i=0;i<n;i++){cin>>A[i];aSum+=A[i];}
  for(int i=0;i<m;i++){cin>>B[i];bSum+=B[i];}

  int ans=0;
  aSum=0;
  for(int i=0;i<=n;i++){
    if(bptr<0){
      if (aSum<=k){
        ans = max(ans, i);
      }
    }else {
      while(aSum+bSum>k && bptr>=0){
        bSum -= B[bptr];
        bptr--;
      }
      if (aSum+bSum<=k){
        ans = max(ans, i + bptr+1);
      }
    }
    aSum += A[i];
  }
  cout<<ans<<endl;

  return 0;
}


Measured memory_bytes: 4776
#include<stdio.h>

int main(){
int W,H,x,y,r;
scanf("%d %d %d %d %d", &W, &H, &x, &y, &r);

int c_w = x+r;
int c_h = y+r;

if(x-r < 0 || W < c_w || H < c_h || y-r < 0){
  printf("No\n");
}else printf("Yes\n");


}


Measured memory_bytes: 2060
n = int(input())
a = list(input().split())

odd, even = [], []
for i in range(n):
    if i%2 == 0:
        even.append(a[i])
    else:
        odd.append(a[i])

if n%2 == 0:
    even, odd = odd, even
even.reverse()
print(" ".join(even) + " " + " ".join(odd))


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

int main()
{
  int n, k;
  cin >> n >> k;
  int d[10] = { 0 };
  int f;
  for (int i = 0; i < k; i++)
  {
    cin >> f;
    d[f] = 1;
  }
  for (int i = n;; i++)
  {
    int j = i;
    bool ok = true;
    while (j > 0)
    {
      if (d[j % 10] == 1)
      {
        ok = false;
        break;
      }
      j /= 10;
    }
    if (ok)
    {
      cout << i << endl;
      break;
    }
  }
}

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

int main(){
    long long  A,B,x,r;
    cin>>A>>B;
    x = A*B;
    if (A>B){
        long long  tmp = A;
        A = B;
        B = tmp;
    }
    r = A%B;
    
    while(r!=0){
        A = B;
        B = r;
        r = A%B;
    }
    cout<<x/B<<endl;
}


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

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

int main(){
  ll n;
  cin >> n;
  vector<ll> p(5);
  rep(i,5) cin >> p.at(i);

  ll mi = p.at(0);
  rep(i,5) mi = min(mi, p.at(i));

  ll ans = ceil(double(n/double(mi))) + 4;
  cout << ans;
}

Measured memory_bytes: 3608
import math
#L, R = map(int,input().split())
H = int(input())

h = math.ceil(math.log2(H))
if math.log2(H) == math.ceil(math.log2(H)):
  ans = pow(2,h+1)-1
else:
  ans = pow(2,h)-1
    
print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define INF 1000000000000 //10^12

int main(){
    ll n,a,b;
    cin >> n >> a >>b;
    ll ans = n/(a+b) *a;
    if(n%(a+b)<a){
        ans+= n%(a+b);
    }else{
        ans+=a;
    }
    cout << ans <<endl;
}

Measured memory_bytes: 256
S = input()
S = S.replace('BC', 'D').replace('B', ' ').replace('C', ' ').split()

ans = 0
for s in S:
    leftA = 0
    for i, t in enumerate(s[:: -1]):
        if t == 'A':
            ans += max(0, i - leftA)
            leftA += 1

print(ans)

Measured memory_bytes: 5224
import java.util.Scanner;

public class Main {

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

	    long N = Long.parseLong(scanner.next());
	    long[] A = new long[(int)N];

        long sum=0;
	    for (int i=0; i<N; i++) {
	    	sum+= Long.parseLong(scanner.next());
	    }


        System.out.print(sum-N);
	}

}

Measured memory_bytes: 38744
#include <iostream>
using namespace std;
int main()
{
    int H, A;
    do
    {
        cin >> H >> A;
    } while (H > 10000 || H < 1 || A > 10000 || A < 1);
    int T = (H % A) ? H / A + 1 : H / A;
    cout << T << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
	int n;
	cin >> n;
	for (int j=1;j<=n;j++){
	int x = j;
		if (x%3==0){
			cout << " " << j;
			continue;
		}
		while (x){
			if (x%10==3){
				cout << " " << j;
				break;
			}
			x /= 10;
		}
	}
	cout << endl;
}

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

int main() {
    long n, t[5];

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

    sort(t, t + 5);
    long ans = n / t[0];

    if (n % t[0] > 0) {
        ans++;
    }

    cout << ans + 4 << endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<queue>
#include<memory>
#include<map>
#include<set>
#include<unordered_map>
#include<array>
#include<vector>
#include<algorithm>
#include<list>
#include<limits>
#include<stdio.h>
#include<math.h>
#include<string>

using namespace std;
using ll = long long;
using vec = vector<ll>;
using mat = vector<vec>;
using lst = list<ll>;

const ll MOD = 1000000007;



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

	switch (N % 10)
	{
	case 2:
	case 4:
	case 5:
	case 7:
	case 9:
		cout << "hon" << endl;
		break;
	case 0:
	case 1:
	case 6:
	case 8:
		cout << "pon" << endl;
		break;
	case 3:
		cout << "bon" << endl;
	}

	return 0;
}

Measured memory_bytes: 3580
S = input()
mojisu = len(S)
hug_a = 0
hug_b = 0
if mojisu % 2 == 0:
    for i in range(mojisu // 2):
        if S[i] != S[mojisu - (i+1)]:
            hug_a = hug_a + 1
    if hug_a == 0:
        print(0)
    else:
        print(hug_a)
if mojisu % 2 == 1:
    for j in range((mojisu-1) // 2):
        if S[j] != S[mojisu - (j+1)]:
            hug_b = hug_b + 1
    if hug_b == 0:
        print(0)
    else:
        print(hug_b)

Measured memory_bytes: 3064
Option Strict On

Module Module1
    Const m As Int32 = 2
    Dim N, A, tmp(m - 1) As Long

    Sub Main()
        For i As Int32 = 0 To m - 1
            tmp(i) = CLng(Console.ReadLine())
        Next

        'let'
        N = tmp(0) : A = tmp(1)

        Console.WriteLine(
            New String() {"Yes", "No"}(
                Convert.ToInt32(A < N Mod 500)))

    End Sub

End Module


Measured memory_bytes: 13268
// AOJ 2187: Card Game
// 2017.11.6 bal4u@uu

#include <stdio.h>
#include <string.h>
#define TM 0
#if TM
#include <time.h>
#endif

#define SUM 171		// =19*9
#define HALF 86		// =SUM/2+1
int g[10], j[10];
int f[10][171][1<<9], p[10];

int rec(int i, int sg, int combi)
{
	int r, k, mask;

	if (i == 9) return sg >= HALF;
	if (f[i][sg][combi] >= 0) return f[i][sg][combi];
	if (sg >= HALF) return f[i][sg][combi] = p[9-i];
	
	for (r = 0, mask = 1, k = 0; k < 9; k++, mask <<= 1) {
		if (combi & mask) {
			if (g[i] > j[k]) r += rec(i+1, sg+g[i]+j[k], combi^mask);
			else             r += rec(i+1, sg, combi^mask);
		}
	}
	return f[i][sg][combi] = r;
}

int main()
{
	int t, i;
	double x;

#if TM
	clock_t start, end;
	start = clock();
#endif
	for (p[0] = 1, i = 1; i <= 9; i++) p[i] = i*p[i-1];

	scanf("%d", &t);
	while (t-- > 0) {
		for (i = 0; i < 9; i++) scanf("%d", g+i);
		for (i = 0; i < 9; i++) scanf("%d", j+i);
		memset(f, -1, sizeof(f));
		x = 1.0/p[9] * rec(0, 0, (1<<9)-1);
		printf("%.15lf %.15lf\n", x, 1-x);
	}
#if TM
	end = clock();
	printf("time %lf\n", (double)(end-start)/CLOCKS_PER_SEC);
#endif
	return 0;
}

Measured memory_bytes: 5200
t = int(input())
abcd = [tuple(int(x) for x in input().split()) for _ in range(t)]

def calc_gcd(x, y):
    if x < y:
        x, y = y, x
    if y == 0:
        return x
    z = x % y
    return calc_gcd(y, z)

for a,b,c,d in abcd:
    if b > a or b > d:
        print('No')
        continue
    elif c >= b:
        print('Yes')
        continue
    g = calc_gcd(b, d)
    if b - g + (a % g) > c:
        print('No')
    else:
        print('Yes')

Measured memory_bytes: 3064
#include <bitset>
#include <cstring>
#include <iostream>
#include <set>

using namespace std;

int n, k;
int cards[10];
bitset<10> used;
int permutation[4];
set<int> integers;

void rec(int i) {
  if (i < k) {
    for (int j = 0; j < n; j++) if (!used[j]) {
      permutation[i] = j;
      used[j] = 1;
      rec(i+1);
      used[j] = 0;
    }
  } else {
    int integer = 0;
    for (int j = 0; j < k; j++) {
      int x = cards[permutation[j]];
      integer *= (x >= 10 ? 100 : 10);
      integer += x;
    }
    integers.insert(integer);
  }
}

int main() {
  for (;;) {
    memset(cards, 0, sizeof cards);
    used.reset();
    memset(permutation, 0, sizeof permutation);
    integers.clear();
    cin >> n >> k;
    if (!n && !k) return 0;
    for (int i = 0; i < n; i++)
      cin >> cards[i];
    rec(0);
    cout << integers.size() << endl;
  }
}

Measured memory_bytes: 0
#include <queue>
#include <stdio.h>
#include <algorithm>
using namespace std;

int dx[] = {0,1,0,-1},
dy[] = {-1, 0, 1, 0};

typedef pair<int,int> P;

int main(void)
{
	int N,M;

	while(1){
	scanf("%d %d", &N, &M);
	if(N == M && N == 0)
		break;

	char **s = new char *[N];

	for(int i = 0; i < N; i++){
		s[i] = new char [M+1];


	}
	for(int i = 0; i < N; i++)
		scanf("%s", s[i]);

	int count = 0;
	for(int i = 0; i < N; i++){
		for(int j = 0; j < M; j++){
			if(s[i][j] != 'a'){
				char a = s[i][j];
				s[i][j] = 'a';
				count++;
				queue<P> q;
				q.push(P(j,i));

				while(q.size()){
					P p = q.front();	q.pop();

					for(int k = 0; k < 4; k++){
						int nx = dx[k] + p.first, ny = dy[k] + p.second;

						if(ny > -1 && nx > -1 && ny < N && nx < M && s[ny][nx] == a){
							q.push(P(nx,ny));
							s[ny][nx] = 'a';
						}
					}
				}
			}
		}
	}
	printf("%d\n",count);
	}
	return 0;
}

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

struct Vector2D {
	double x;
	double y;

	double abs() const {
		return std::sqrt(x * x + y * y);
	}
	Vector2D& operator-=(const Vector2D& rhs) {
		x -= rhs.x;
		y -= rhs.y;
		return *this;
	}
};

Vector2D operator-(const Vector2D& lhs, const Vector2D& rhs)
{
	return Vector2D(lhs) -= rhs;
}

int main()
{
	int count = 0;
	std::cin >> count;
	for (int i = 0; i < count; ++i) {
		Vector2D pA, pB, pC, pD;
		std::cin >> pA.x >> pA.y >> pB.x >> pB.y >> pC.x >> pC.y >> pD.x >> pD.y;

		Vector2D rAB(pB - pA), rCD(pD - pC);
		const double eps = 1.0e-8;
		if (rAB.abs() >= eps && rCD.abs() >= eps && std::abs(rAB.x * rCD.y - rAB.y * rCD.x) < eps) {
			std::cout << "YES\n";
		} else {
			std::cout << "NO\n";
		}
	}

	return 0;
}

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

typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<long long> VL;
typedef vector<vector<long long>> VVL;
typedef pair<int,int> P;
typedef tuple<int,int,int> tpl;

#define ALL(a)  (a).begin(),(a).end()
#define SORT(c) sort((c).begin(),(c).end())
#define REVERSE(c) reverse((c).begin(),(c).end())
#define EXIST(m,v) (m).find((v)) != (m).end()
#define LB(a,x) lower_bound((a).begin(), (a).end(), x) - (a).begin()
#define UB(a,x) upper_bound((a).begin(), (a).end(), x) - (a).begin()

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RFOR(i,a,b) for(int i=(a)-1;i>=(b);--i)
#define RREP(i,n) RFOR(i,n,0)

#define en "\n"

constexpr double EPS = 1e-9;
constexpr double PI  = 3.1415926535897932;
constexpr int INF = 2147483647;
constexpr long long LINF = 1LL<<60;
constexpr long long MOD = 1000000007; // 998244353;

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

void Main(){
    ll a,b,c,d; cin >> a >> b >> c >> d;
    ll ans = -LINF;
    VL x{a,b}, y{c,d};
    if(a<0 && 0<b) x.push_back(0);
    if(c<0 && 0<d) y.push_back(0);
    for(ll i : x)for(ll j : y){
        ll tmp = i*j;
        chmax(ans, tmp);
    }
    cout << ans << en;
    return;
}

int main(void){
    cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);cout<<fixed<<setprecision(15);
    int t=1; //cin>>t;
    REP(_,t) Main();
    return 0;
}

Measured memory_bytes: 3652