akhauriyash/Code-Regression huggingface dataset:
import java.io.*; 
import java.util.*;
 
public class Main {
    public static void main(String[] args) throws IOException {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int[] A = new int[N+1];
        for (int i = 1; i <= N; i++) {
        	A[i] = sc.nextInt();
        }
        int[] sum = new int[449];
        int[] B = new int[200001];
        for (int i = N; i >= 1; i--) {
        	if (i > 448) {
        		int tot = 0;
        		for (int j = i; j <= N; j += i) {
        			tot += B[j];
        		}
        		tot = tot % 2;
        		if (tot != A[i]) {
        			B[i] = 1;
        			for (int j = 1; j <= 448; j++) {
        				if (i % j == 0) {
        					sum[j] += 1;
        					sum[j] %= 2;
        				}
        			}
        		}
        	} else {
        		if (sum[i] != A[i]) {
        			B[i] = 1;
        			for (int j = 1; j < i; j++) {
        				if (i % j == 0) {
        					sum[j] += 1;
        					sum[j] %= 2;
        				}
        			}
        		}
        	}
        }
        
        int num = 0;
        for (int i = 1; i <= N; i++) {
        	if (B[i] == 1)
        		num++;
        }
        System.out.println(num);
        for (int i = 1; i <= N; i++) {
        	if (B[i] == 1) {
        		System.out.println(i);
        	}
        }
    }
    
    static class FastScanner { 
        BufferedReader br; 
        StringTokenizer st; 
  
        public FastScanner() { 
            br = new BufferedReader(new InputStreamReader(System.in)); 
        } 
  
        String next() { 
            while (st == null || !st.hasMoreElements()) { 
                try { 
                    st = new StringTokenizer(br.readLine());
                } catch (IOException  e) { 
                    e.printStackTrace(); 
                } 
            } 
            return st.nextToken(); 
        } 
  
        int nextInt() { 
            return Integer.parseInt(next()); 
        } 
  
        long nextLong() { 
            return Long.parseLong(next()); 
        } 
  
        double nextDouble() { 
            return Double.parseDouble(next()); 
        } 
  
        String nextLine() { 
            String str = ""; 
            try { 
                str = br.readLine(); 
            } catch (IOException e) {
                e.printStackTrace(); 
            } 
            return str; 
        }
    }
}

Measured memory_bytes: 50636
#include<iostream>
#include <algorithm>
#include <string>
#include<math.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;
int main() {
    int a,b;
    cin >> a >> b;
    cout << a*a - b << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int a1 = a/1000;
		int a2 = a/100 - a1 * 10;
		int a3 = a/10 -a2 * 10 -a1*100;
	    int a4 = a - a3 * 10 -a2*100 -a1*1000;
	    if(a1 == a2 || a2 == a3 || a3 == a4 ){
	        System.out.println("Bad");
	    }else{
	        System.out.println("Good");
	    }
	}
}

Measured memory_bytes: 22868
$<.each_line do |line|
  a1, b1, c1, a2, b2, c2 = line.split.map(&:to_f)
  a = (a1*b2 - a2*b1)
  x = (c1*b2 - c2*b1) / a + 0
  y = (a1*c2 - a2*c1) / a + 0
  printf "%.3f %.3f\n", x, y
end

Measured memory_bytes: 8664
#include<stdio.h>
int main(void)
{
  int m,f,r;
  while(1){
  scanf("%d %d %d",&m,&f,&r);
    if(m==-1 && f==-1 && r==-1)
	break;
    else{
      if((m==-1 || f==-1)||(m+f)<30) printf("F\n");
      else if (m+f>=80) printf("A\n");
      else if (m+f>=65 && m+f<80)printf("B\n");
      else if (m+f>=50 && m+f<65)printf("C\n");
      else {
	if (r>=50) printf("C\n");
	else printf("D\n");
      }
    }
  }
  return 0;
}			 

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

int main(){
    int X;
    int t;
    int i,nok;

    cin >> X >>t;
    nok =X;
    for(i=1;((i<=t)&&(X-i>=0));i++){
        nok--;
    }

    cout << nok << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>
#include <limits.h>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){

    const ll mod = 2019;

    ll left, right;
    cin >> left >> right;

    if(right - left >= mod){
        cout << 0 << endl;
    }
    else{
        ll ans = mod;
        for(ll i = left; i <= right; i ++){
            for(ll j = i + 1; j <= right; j++){
                ans = min(ans, ( (i * j) % mod ) );
            } 
        }
        cout << ans << endl;
    }


}

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

int main()
{
    ios_base::sync_with_stdio(false); cin.tie(0);
    string s;
    int used[26],n;
    while(cin >> s)
    {
        if(s == "zyxwvutsrqponmlkjihgfedcba")
        {
            cout << -1 << '\n';
            continue;
        }
        memset(used, 0, sizeof used);
        n = s.size();
        for(int i = 0; i < n; i++)
            used[s[i]-'a'] = 1;
        int pos = -1;
        for(int i = 0; i < 26 && pos == -1; i++)
            if(!used[i])
                pos = i;
        if(pos != -1)
            cout << s << char('a'+pos) << '\n';
        else
        {
            int finished = 0;
            for(int i = n-2; i >= 0 && !finished; i--)
            {
                int pos = -1;
                for(int j = i+1; j < n; j++)
                    if(s[j] > s[i] && (pos == -1 || s[j] < s[pos]))
                        pos = j;
                if(pos != -1)
                {
                    swap(s[i], s[pos]);
                    s.resize(i+1);
                    finished = 1;
                }
            }
            cout << s << '\n';
        }
    }
    return 0;
}

Measured memory_bytes: 256
s = input()
t = input()
dp = [[0 for _ in range(len(t)+1)] for _ in range(len(s)+1)]
for i in range(len(s)):
	for j in range(len(t)):
		if s[i] == t[j]:
			dp[i+1][j+1] = dp[i][j] + 1
		elif dp[i+1][j] >= dp[i][j+1]:
			dp[i+1][j+1] = dp[i+1][j]
		else:
			dp[i+1][j+1] = dp[i][j+1]

ans = ""

i, j = len(s), len(t)

while i > 0 and j > 0:
	#if dp[i][j] == dp[i-1][j-1] + 1:
	if s[i-1] == t[j-1]:
		ans += s[i-1]
		i, j = i-1, j-1
	elif dp[i][j-1] >= dp[i-1][j]:
		j -= 1
	else:
		i -= 1

print(ans[::-1])

Measured memory_bytes: 119772
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
//#include <regex>

/* g++ -g -std=c++0x */
/* g++ -g -std=c++11 */

using namespace std;

// freopen("input.txt", "rt", stdin);
// freopen("output.txt", "wt", stdout);

#define ALL(c)          (c).begin(), (c).end()
#define ALLR(c)         (c).rbegin(), (c).rend()
#define FOR(i,a,b)      for (int i=(a); i < (b); ++i)
#define FORR(i,a,b)     for (int i=(a); i > (b); --i)
#define FOR_ALL(i,c)    for (__typeof((c).begin()) i=(c).begin();   \
                             i != (c).end(); ++i)
#define FOR_ALLR(i,c)   for (__typeof((c).rbegin()) i=(c).rbegin(); \
                             i != (c).rend(); ++i)
#define SZ(array)       (sizeof(array)/sizeof(array[0]))
#define lc(x)           (x<<1)     /* 2*x */
#define rc(x)           (x<<1 | 1) /* 2*x+1 */
#define lowbit(x)       (x & (-x)) /* 0b10100 -> 0b100 */

typedef long long       LL;
typedef map<int,int>    MII;
typedef pair<int,int>   PII;
typedef set<int>        SI;
typedef vector<bool>    VB;
typedef vector<double>  VD;
typedef vector<int>     VI;
typedef vector<string>  VS;

/* check if a key is in container C */
template <class C>
inline bool in_(const typename C::key_type& k, const C& A)
{ return A.find(k) != A.end(); }
inline bool in_(const string& s, const string& S)
{ return S.find(s) != string::npos; }

int main()
{
/* #ifndef ONLINE_JUDGE */
/*     freopen("foo", "rt", stdin); */
/* #endif */
    std::ios::sync_with_stdio(false);

    int a; int b; int c; int d;
    cin >> a >> b >> c >> d;
    int e = abs(a - b);
    int f = abs(b - c);
    int g = abs(a - c);
    if (e <= d && f <= d || g <= d)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;
    
}


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

int main()
{
    int a, b, c;
    scanf("%d%d%d",&a, &b, &c);
    if(a == b && b != c) printf("Yes\n");
    else if(a == c && b != c) printf("Yes\n");
    else if(b == c && a != b) printf("Yes\n");
    else printf("No\n");
    return 0;
}

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

bool isprime(int a){
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
		}
		return a!=1;
	}

int main(){
	int a,d,n;
	
	while(cin>>a>>d>>n,a,d,n){
		int b=0;
		
		while(1){
			if(isprime(a)){
				b++;
			}	
			
			if(b==n)break;
			a+=d;
			}
			
			cout<<a<<endl;
		}
		
	return 0;
	}

Measured memory_bytes: 3012
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  vector<ll> a(4);
  rep(i, 4) cin >> a.at(i);
  ll ans = -5e18;
  vector<ll> p;
  p.push_back(a.at(0) * a.at(3));
  p.push_back(a.at(0) * a.at(2));
  p.push_back(a.at(1) * a.at(2));
  p.push_back(a.at(1) * a.at(3));
  rep(i, 4) ans = max(ans, p.at(i));
  cout << ans << endl;
  return 0;
}

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

size_t rankF2(vector<vector<long>>& a){ // calculate rank of matrix in F_2
    long n = a.size(), m = a[0].size();
    size_t now(0), ret(0);
    while(now < m && ret < n){
        size_t i(ret);
        for(; i < n; ++i)if(a[i][now])break;
        if(i == n){
            ++now;
            continue;
        }
        size_t j(i + 1);
        for(; j < n; ++j)if(a[j][now])for(int k = now; k < m; ++k)a[j][k] ^= a[i][k];
        swap(a[ret], a[i]);
        ++ret;
    }
    return ret;
}

int main(){
    constexpr long m = 998244353;
    auto modpow = [&m](long n){
        long r = 1, p = 2;
        while(n){
            if(n & 1){
                r *= p;
                r %= m;
            }
            p *= p;
            p %= m;
            n >>= 1;
        }
        return r;
    };

    long N, M;
    cin >> N >> M;
    bool f = false;
    if(N > M && (f = true))swap(N, M);

    vector<vector<long>> a(N, vector<long>(M));
    if(f)for(int i = 0; i < M; ++i)for(int j = 0; j < N; ++j)scanf("%ld", &a[j][i]);
    else for(auto& i : a)for(auto &j : i)scanf("%ld", &j);

    auto r = rankF2(a);
    cout << modpow(N + M - r - 1) * (modpow(r) - 1) % m << endl;
}

Measured memory_bytes: 1024
import math

N = int(input())

total = 0
   
if N != 1:        
    for i in range(1,int(math.sqrt(N)+1)):
        amari = i
        if N % amari == 0:
            k = N // amari - 1
            if amari == N % k:
                total += N//amari - 1
        #print(amari)

print(total)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define forn(i,a,b) for(int i =a;i<b;i++)
#define fi first
#define se second
#define fast ios_base::sync_with_stdio(false);
#define endl '\n'
using namespace std;

//for debugging 
/*
g++ -D_GLIBCXX_ASSERTIONS -DDEBUG -ggdb3 -std=c++14 
*/

// debugging ends here

typedef long long int ll;
typedef vector<ll> vi;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;


void solve(){
	int n;
	cin >> n;
	int count = 0;
	int d1[n],d2[n];
	for(int i =0;i<n;i++){
		cin>> d1[i] >> d2[i];
	}
	int pos = 0;
	for(int i =0;i<n;i++){
		if(d1[i]==d2[i]){
			count++;
		}
		else{
			count = 0;
		}

		if(count>=3){
			pos|=1;
		}
		// cout << i << " " << count << endl;
	}

	cout<< (pos?"Yes":"No") << endl;
}

int main(){
	fast;
	#ifndef ONLINE_JUDGE
		freopen("input.txt","r",stdin);
		freopen("output.txt","w",stdout);
	#endif

	// int t;cin >> t;while(t--)
		solve();
}


Measured memory_bytes: 3608
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int A, B;
  cin >> A;
  cin >> B;
  if (A > 9||B > 9){
    cout << -1 << endl;
  } else {
    cout << A*B << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<typename T1,typename T2> inline void chmin(T1 &a,T2 b){if(a>b) a=b;}
template<typename T1,typename T2> inline void chmax(T1 &a,T2 b){if(a<b) a=b;}
using Int = long long;
const char newl = '\n';

//INSERT ABOVE HERE
signed main(){
  cin.tie(0);
  ios::sync_with_stdio(0);

  Int n;
  cin>>n;

  vector<Int> as(n);
  for(Int i=0;i<n;i++) cin>>as[i];
  sort(as.rbegin(),as.rend());

  Int ans=0;
  priority_queue<Int> pq;
  for(Int i=0;i<n;i++){
    if(!pq.empty()){
      ans+=pq.top();
      pq.pop();
      pq.emplace(as[i]);
      pq.emplace(as[i]);
    }else{
      pq.emplace(as[i]);
    }
  }
  cout<<ans<<newl;
  return 0;
}


Measured memory_bytes: 6848
N = int(input())
S = list(input())
T = list(input())
counter = 0
for i in range(N) :
    if S == T :
        print(N+counter)
        break
    else :
        S.pop(0)
        T.pop(-1)
        counter += 1
        if len(S) == 0 :
            print(2*N)
            

Measured memory_bytes: 3060
A = int(input())
B = int(input())
C = int(input())
D = int(input())

#A通常電　Bのりほ電　C通常バス Dのりぼバス

A_C = (A+C)
A_D = (A+D)
B_C = (B+C)
B_D = (B+D)

print(min(A_C,A_D,B_C,B_D))

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

int D;
long long G;
vector<long long> p, c;

int main() {
  cin >> D >> G;
  p.resize(D); c.resize(D);
  for (int i = 0; i < D; ++i) cin >> p[i] >> c[i];

  long long res = 1<<29;
  for (int bit = 0; bit < (1<<D); ++bit) {
    long long sum = 0;
    long long num = 0;
    for (int i = 0; i < D; ++i) {
      if (bit & (1<<i)) sum += c[i] + p[i] * 100 * (i+1), num += p[i];
    }
    if (sum >= G) res = min(res, num);
    else {
      for (int i = D-1; i >= 0; --i) {
        if (bit & (1<<i)) continue;
        for (int j = 0; j < p[i]; ++j) {
          if (sum >= G) break;
          sum += 100 * (i+1);
          ++num;
        }
      }
      res = min(res, num);
    }
  }
  cout << res << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int n, q, A[20], m;
bool res[40001];

void DP() {
	res[0] = true;
	for (int i = 0; i < n; i++) {
		for (int j = 40000 - A[i]; j >= 0;j--) {
			if (res[j]) {
				res[j + A[i]] = true;
			}
		}
	}
}

int main()
{
	cin >> n;
	for (int i = 0; i < n; i++)
		cin >> A[i];
	DP();
	cin >> q;
	for (int i = 0; i < q; i++) {
		cin >> m;
		cout << (res[m] ? "yes" : "no") << endl;
	}
	return 0;
}

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

vector<int> arr;
int k;

long long cnt(int i, int j) {
	if (j - i == 1) {
		if (arr[i] % k == 0) return 1;
		else return 0;
	}
	int mid = (i + j) / 2;
	long long ret = 0;
	ret += cnt(i, mid);
	ret += cnt(mid, j);
	map<int, int> l, r;
	int sum = 0;
	for (int ind = mid - 1; ind >= i; --ind) {
		sum = (sum + arr[ind]) % k;
		l[sum]++;
	}
	sum = 0;
	for (int ind = mid; ind < j; ++ind) {
		sum = (sum + arr[ind]) % k;
		r[sum]++;
	}
	for (auto it = l.begin(); it != l.end(); ++it) {
		if (r.count((k - it->first) % k)) {
			ret += (long long)it->second * r[(k - it->first) % k];
		}
	}
	return ret;
}

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	int n, t;
	cin >> n >> k;
	for (int i = 0; i < n; ++i) {
		cin >> t;
		arr.push_back(t);
	}
	
	cout << cnt(0, n);
}

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

int main(){
    int H, W;
    scanf("%d%d", &H, &W);
    long long res = 1e18;
    if(H%3 == 0 || W%3 == 0){ printf("0"); return 0; }
    res = min(W, H);
    long long A[3];
    for(int i=1; i<H; i++){
        A[0] = (long long)i*W;
        A[1] = (long long)(H-i)*(W/2);
        A[2] = A[1];
        if(W&1) A[2] = (long long)(H-i)*(W/2 + 1);
        sort(A, A+3);
        res = min(res, A[2]-A[0]);
    }
    for(int i=1; i<W; i++){
        A[0] = (long long)i*H;
        A[1] = (long long)(W-i)*(H/2);
        A[2] = A[1];
        if(H&1) A[2] = (long long)(W-i)*(H/2 + 1);
        sort(A, A+3);
        res = min(res, A[2]-A[0]);
    }
    printf("%lld", res);
    return 0;
}

Measured memory_bytes: 128
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,m;
pair<int,int>p[100005];
int main(){
	cin>>n>>m;
	for(int i=1;i<=m;i++){
		int a,b;
		cin>>a>>b;
		p[i]=make_pair(b,a);
	}
	sort(p+1,p+m+1);
	int pos=1,ans=0;
	while(pos<=m){
		ans++;
		int ed=p[pos].first;
		while(pos<=m&&p[pos].second<ed)pos++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1024
#include<stdio.h>
#include<stdlib.h>
#define N 1000000
#define A_IN 1000000000
int cnt=0;
int n;
int*G;
int A[N];
int c=0;
void insertionSort(int A[], int n, int g){
  int i,v,j;
  for(i=g;i<n;i++){
    v=A[i];
    j=i-g;
    while(j>=0 && A[j]>v){
      A[j+g]=A[j];
      j-=g;
      cnt++;
    }
    A[j+g]=v;
  }
}

void shellSort(int A[],int n){
  int i=0,q;
  cnt=0;
  G=(int *)malloc(n * sizeof(int));
 
  for(q=1;;){
    if(q>n) break;
    G[i]=q;
    i++;
    q=3*q+1;
  }
  c=i;
  for(i=c-1;i>=0;i--){
    insertionSort(A,n,G[i]);
  }
}


int main(){
  int i;
  scanf("%d",&n);
  for(i=0;i<n;i++) scanf("%d",&A[i]);
  
  shellSort(A,n);

  printf("%d\n",c);

  for(i=c-1;i>=0;i--){
    printf("%d",G[i]);
    if(i) printf(" ");
  }
  printf("\n");
  printf("%d\n",cnt);
  for(i=0;i<n;i++)printf("%d\n",A[i]);

  free(G);
  
  return 0;
}



Measured memory_bytes: 5756
#include<cstdio>
#include<algorithm>
using namespace std;
int fa[200005],now[200005];
int look_for(int x){
	if(fa[x]==x){
		return x;
	}
	return fa[x]=look_for(fa[x]);
}
int main(){
	int n,m,i,maxn=0;
	scanf("%d%d",&n,&m);
	for(i=1;i<=n;i++){
		fa[i]=i;
	}
	while(m--){
		int x,y;
		scanf("%d%d",&x,&y);
		fa[look_for(x)]=look_for(y); 
	}
	for(i=1;i<=n;i++){
		now[look_for(i)]++;
	}
	for(i=1;i<=n;i++){
		maxn=max(maxn,now[i]);
	}
	printf("%d",maxn); 
	return 0;
}

Measured memory_bytes: 8704
#include<iostream>
#include<list>

using namespace std;

int main()
{

    list<int> l;

    int n;

    cin>>n;

    char s[20];
    int value;

    for(int j=0;j<n;j++)
    {
        cin>>s;

        if(s[0]=='i')
        {
            cin>>value;
            l.push_front(value);
        }else if(s[6]=='F')
        {
            l.pop_front();
        }else if(s[6]=='L')
        {
            l.pop_back();
        }else
        {
            cin>>value;
            for(list<int>::iterator ite=l.begin();ite!=l.end();ite++)
            {
                if(*ite==value)
                {
                    l.erase(ite);
                    break;

                }
            }
        }

    }

    int i=0;
    for(list<int>::iterator ite=l.begin();ite!=l.end();ite++,i++)
    {
        if(i)
        {
            cout<<" ";
        }
        cout<<*ite;
    }

    cout<<endl;

    return 0;
}



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

int main() {
  int h, w, dx[8]={0,1,0,-1,1,1,-1,-1}, dy[8]={1,0,-1,0,1,-1,1,-1};
  string s[50];
  cin >> h >> w;
  for(int i=0; i<h; i++) cin >> s[i];
  for(int i=0; i<h; cout << endl, i++){
    for(int j=0, num=0; j<w; num=0, j++){
      if(s[i].at(j) == '#'){cout << '#';}
      else{
        for(int k=0; k<8; k++){
          int x=j+dx[k], y=i+dy[k];
          if(x>=0 && x<=w-1 && y>=0 && y<=h-1 && s[y].at(x) == '#') num++; 
      	}
        cout << num;
      }
    }
  }
}


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

int main() {
  vector<int> v(3);
  for (int i=0; i<3; i++) {
    cin >> v.at(i);
  }
  
  sort(v.begin(),v.end());
  int ans=0;
  if ((v.at(2)-v.at(0))%2 != (v.at(2)-v.at(1))%2) {
    ans++;
    v.at(0)++;
    v.at(2)++;
  }
  if ((v.at(2)-v.at(0))%2 == 1) {
    ans++;
    v.at(0)++;
    v.at(1)++;
  }
  ans += (v.at(2)-v.at(0))/2 + (v.at(2)-v.at(1))/2;

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
#include <iostream>
#include <iomanip>
#include <cstdlib> //絶対値整数abs
#include <cmath>   //絶対値少数fbs
#include <math.h>
using namespace std;
#define rep(i, N) for (ll i = 0; i < (N); i++)
typedef long long ll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n, Y;
    cin >> n >> Y;
    ll x = -1;
    ll y = -1;
    ll z = -1;
    bool c = false;
    for (ll i = 0; i <= (Y / 10000); i++)
    {
        if (c)
        {
            break;
        }
        for (ll j = 0; j <= (Y / 5000); j++)
        {
            ll k = (Y - 10000 * i - 5000 * j) / 1000;
            if (k >= 0 && k <= Y / 1000 && i + j + k == n)
            {
                x = i;
                y = j;
                z = k;
                c = true;
                break;
            }
        }
    }
    cout << x << " " << y << " " << z << endl;
}

Measured memory_bytes: 256
N, X, Y = map(int, input().split())

def dist(fr, to):
    return min(
        to - fr,
        abs(to - Y) + 1 + abs(fr - X),
        abs(fr - Y) + 1 + abs(to - X)
    )

cnt = [0] * N

ans = 0
for fr in range(1, N + 1):
    for to in range(fr + 1, N + 1):
        cnt[dist(fr, to)] += 1

print(*(cnt[1:]), sep='\n')


Measured memory_bytes: 3444
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF=1e16;
const int MAX=2500;
const int N=105;
ll n,m,s;
ll a[N][N],b[N][N],c[N],d[N],f[N][MAX+10],v[N][MAX+10];
struct node {
	ll num1,num2,len;
	node() {}
	node(ll a,ll b,ll c) {
		num1=a; num2=b; len=c;
	}
	bool operator<(const node &node1) const {
		return len<node1.len;
	}
	bool operator>(const node &node1) const {
		return len>node1.len;
	}
};
priority_queue<node,vector<node>,greater<node>> q;
inline ll calc(ll x) {
	if (x>MAX) return MAX;
	else return x;
}
int main() {
	ll u,w,x,y,i,j,ans;
	node p;
	scanf("%lld%lld%lld",&n,&m,&s);
	for (i=1;i<=n;i++)
		for (j=1;j<=n;j++)
			b[i][j]=INF;
	for (i=1;i<=m;i++) {
		scanf("%lld%lld%lld%lld",&u,&w,&x,&y);
		a[u][w]=a[w][u]=x;
		b[u][w]=b[w][u]=y;
	}
	for (i=1;i<=n;i++)
		scanf("%lld%lld",&c[i],&d[i]);
	s=calc(s);
	q.push(node(1,s,0));
	for (i=1;i<=n;i++)
		for (j=0;j<=MAX;j++)
			f[i][j]=INF;
	f[1][s]=0;
	while (!q.empty()) {
		p=q.top(); q.pop();
		x=p.num1; y=p.num2;
		if (v[x][y]>0) continue;
		v[x][y]=1;
		if (!v[x][calc(y+c[x])]&&f[x][y]+d[x]<f[x][calc(y+c[x])]) {
			f[x][calc(y+c[x])]=f[x][y]+d[x];
			q.push(node(x,calc(y+c[x]),f[x][y]+d[x]));
		}
		for (i=1;i<=n;i++)
			if (b[x][i]<INF) {
				if (y-a[x][i]>=0&&!v[i][y-a[x][i]]&&f[x][y]+b[x][i]<f[i][y-a[x][i]]) {
					f[i][y-a[x][i]]=f[x][y]+b[x][i];
					q.push(node(i,y-a[x][i],f[x][y]+b[x][i]));
				}
			}
	}
	for (i=2;i<=n;i++) {
		ans=INF;
		for (j=0;j<=MAX;j++)
			ans=min(ans,f[i][j]);
		printf("%lld\n",ans);
	}
	return 0;
} 

Measured memory_bytes: 8280
#include <iostream>
#include <cmath>
using namespace std;
int main()
{

    int h,a,x;
    cin>>h>>a;
    for(int i = 0;i<a;i++) cin>>x,h-=x;
    if(h <= 0) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;
    return 0;
}


Measured memory_bytes: 256
import java.io.IOException;
import java.io.InputStream;

public class Main {
    public static void main(String[] args)throws Exception {
        FastReader in = new FastReader(System.in);
        StringBuilder sb = new StringBuilder();
        int i,j;
        int n=in.nextInt();
        long sum=0;
        for(i=1;i<=n;i++){
            if(i%3!=0 && i%5!=0)
                sum+=i;
        }
        System.out.println(sum);

    }
}

class FastReader {

    byte[] buf = new byte[2048];
    int index, total;
    InputStream in;

    FastReader(InputStream is) {
        in = is;
    }

    int scan() throws IOException {
        if (index >= total) {
            index = 0;
            total = in.read(buf);
            if (total <= 0) {
                return -1;
            }
        }
        return buf[index++];
    }

    String next() throws IOException {
        int c;
        for (c = scan(); c <= 32; c = scan()) ;
        StringBuilder sb = new StringBuilder();
        for (; c > 32; c = scan()) {
            sb.append((char) c);
        }
        return sb.toString();
    }

    int nextInt() throws IOException {
        int c, val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }

    long nextLong() throws IOException {
        int c;
        long val = 0;
        for (c = scan(); c <= 32; c = scan()) ;
        boolean neg = c == '-';
        if (c == '-' || c == '+') {
            c = scan();
        }
        for (; c >= '0' && c <= '9'; c = scan()) {
            val = (val << 3) + (val << 1) + (c & 15);
        }
        return neg ? -val : val;
    }
}





Measured memory_bytes: 32420
#include<iostream>
#include<vector>
#include<string>
#include<functional>
#include<unordered_map>
#include<map>
#include<tuple>
#include<utility>
using namespace std;
int main(int argc, char *argv[])
{
  string s;
  cin >> s;
  const int n = s.size();
  vector<int> ds;
  int sum = 0;
  long long prod = 1;
  for(int i = 0; i < n; i++) {
    ds.push_back(s[i]-'0');
    sum += ds.back();
    prod *= (ds.back() + 1);
  }
  struct myhash : public std::unary_function<pair<long long,int>, std::size_t> {
    std::size_t operator()(const pair<long long,int>& k) const {
      return ((std::get<0>(k) & 0xffffffff) + ((std::get<0>(k) >> 32) & 0xffffffff))  + std::get<1>(k);
    }
  };
  vector<vector<unordered_map<pair<long long,int>,long long,myhash>>> mem(n+1, vector<unordered_map<pair<long long,int>,long long,myhash>>(10*n));
  // vector<vector<map<pair<long long,int>,long long>>> mem(n+1, vector<map<pair<long long,int>,long long>>(10*n));

  function<long long(int,int,long long,int)> rec = [n,sum,prod,&ds,&rec,&mem](int k, int s, long long p, int cmp) {
    auto pcmp = make_pair(p,cmp);
    auto it = mem[k][s].find(pcmp);
    if(it != mem[k][s].end()) return it->second;
    long long cnt = 0;
    if(k == n) {
      if(s < sum
         || ((s == sum) && (p < prod))
         || ((s == sum) && (p == prod) && (cmp < 0))) cnt = 1;
      else cnt = 0;
    } else {
      // k-th digit
      for(int d = 0; d < 10; d++) {
        if(s + d > sum) break; // no more
        int dd = d - ds[k];
        if(dd < 0) dd = -1;
        if(dd > 0) dd = 1;
        cnt += rec(k+1, s+d, p*(d+1), cmp == 0 ? dd : cmp);
      }
    }
    mem[k][s][pcmp] = cnt;
    return cnt;
  };
  cout << rec(0, 0, 1, 0) << endl;
  
  return 0;
}




Measured memory_bytes: 51648
#include<iostream>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>

#define fast_io ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);

using namespace std;

//inline int read(){int t = 0;int neg=1;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1;continue;}t=t*10+c-48;}return neg*t;}
//inline int readl(){long long t = 0;long long neg=1ll;char c;while((c=getchar_unlocked())!='\n'&&c!=' '&&c!=EOF){if(c=='-'){neg=-1ll;continue;}t=t*10+c-48;}return neg*t;}

#define debug(x) cout<<(#x)<<"="<<(x)<<", ";
#define debug1(x) debug(x) cout<<'\n';
#define debug2(x1, x2) debug(x1) debug(x2) cout<<'\n';
#define debug3(x1, x2, x3) debug(x1) debug(x2) debug(x3) cout<<'\n';
#define debug4(x1, x2, x3, x4) debug(x1) debug(x2) debug(x3) debug(x4) cout<<'\n';
#define debug5(x1, x2, x3, x4, x5) debug(x1) debug(x2) debug(x3) debug(x4) debug(x5) cout<<'\n';

typedef long long int lli;
typedef unsigned long long int ulli;
typedef pair<int,int> pi;
typedef pair<lli,lli> plli;
typedef vector<int> vi;
typedef vector<lli> vlli;
typedef vector<pi> vpi;
typedef vector<plli> vplli;
const lli M=1000000007ll;

int main(){
	fast_io 
	int x,y,z; cin>>x>>y>>z;
	cout<<z<<" "<<x<<" "<<y;
	
	return 0;
}

Measured memory_bytes: 3592
#include <stdio.h>

#define MAX_NUM 1000000007

int main(void) {
    long long int tryNum;
    long long int AllNum;
    long long int blueNum;
    long long int redNum;
    long long int yojoNum = 0;
    scanf("%lld%lld%lld", &AllNum, &blueNum, &redNum);

    tryNum = AllNum / (blueNum + redNum);

    if ((AllNum % (blueNum + redNum) == 0)) {
    }
    else {
        yojoNum = AllNum % (blueNum + redNum);
        if (yojoNum > blueNum) {
            yojoNum = blueNum;
        }
    }

    printf("%lld\n", tryNum * blueNum + yojoNum);
    return 0;
}

Measured memory_bytes: 128
#[allow(unused_imports)]
use std::cmp::{max, min, Ordering};
#[allow(unused_imports)]
use std::collections::{BTreeMap, BTreeSet, BinaryHeap, HashMap, HashSet, VecDeque};
#[allow(unused_imports)]
use std::io::{stdin, stdout, BufWriter, Read, StdoutLock, Write};
#[allow(unused_imports)]
use std::iter::FromIterator;
#[allow(unused_imports)]
use std::str::FromStr;

// christmas-eve.rs --- Christmas Eve
// author: Seong Yong-ju <sei40kr@gmail.com>

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let mut s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

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

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

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

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

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

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

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

#[allow(dead_code)]
fn with_bufwriter<F: FnOnce(BufWriter<StdoutLock>) -> ()>(f: F) {
    let out = stdout();
    let writer = BufWriter::new(out.lock());
    f(writer);
}

fn main() {
    input! {
      n: i32,
      k: usize,
      hs: [i32; n]
    }

    let mut xs = hs;
    xs.sort();
    let ans = xs
        .windows(k)
        .map(|ys| (ys[0] - ys[k - 1]).abs())
        .min()
        .unwrap();

    with_bufwriter(|mut out| writeln!(out, "{}", ans).unwrap());
}


Measured memory_bytes: 6396
times, jump = [int(i) for i in input().split()]
line = input()
list1 = []
if times <= 1:
  print("%s" % 0)
else: 
  for i in line.split():
    if i:
      list1.append(int(i))
  mem = [0] * times
  mem[-2] = abs(list1[-1] - list1[-2])
  for i in range(len(list1)-3, -1, -1):
    ans = float("inf")
    end = min(len(list1), i+jump+1)
    for k in range(i+1, end):
      ans = min(ans, abs(list1[i] - list1[k]) + mem[k])
    mem[i] = ans
  print("%s" % mem[0])


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

int cnt = 0;

int insertionsort(int *A, int size, int g){
  for(int i = g; i < size; i++){
    int v = A[i];
    int j = i - g;
    while(j >= 0 && A[j] > v){
      A[j + g] = A[j];
      j = j - g;
      cnt++;
    }
    A[j + g] = v;
  }

  return 0;
}

int shellsort(int *A, int size, int *G, int gnum){
  cnt = 0;
  for(int i = gnum - 1; i >= 0; i--){
    insertionsort(A, size, G[i]);
  }
  return 0;
}

int main(){

  int size;

  cin >> size;

  int *A = new int[size];

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

  int G[100];

  G[0] = 1;

  int i = 1;

  while(i < 100 && G[i - 1] <= size / 2){
    G[i] = 3 * G[i - 1] + 1;
    i++;
  }
  if(i == 1) i++;
  int gnum = i - 1;

  shellsort(A, size, G, gnum);

  cout << gnum << endl;
  for(int i = gnum - 1; i > 0; i--){
    cout << G[i] <<" ";
  }
  cout << G[0] << endl;

  cout << cnt << endl;

  for(int i = 0; i < size; i++){
    cout << A[i] <<endl;
  }



  delete[] A;

  return 0;
}



Measured memory_bytes: 6700
n, c, k = map(int, input().split())

begin = 0

t = 0
cap = 0

L = []
for i in range(n):
    L.append(int(input()))
L = sorted(L)
for i in range(n):
    a = L[i]
    if begin == 0:
        begin = a
    if a <= begin + k and cap < c:
        cap += 1
    else:
        t += 1
        begin = a
        cap = 1
print(t +1)

Measured memory_bytes: 8284
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef std::vector<vector<int> > vvi;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<ll> vll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
typedef vector<vll> vvll;
typedef vector<vi> vvi;
#define debugone(x) cerr << #x << " " << x << "\n"; cerr.flush();
#define debugtwo(x) cerr << #x << "-------------" << "\n";for(auto &it: x) cerr << it << " ";cerr << "\n"; cerr.flush();
#define debugthree(x_, i_, j_) cerr << #x_ << "------------" << "\n";cerr << "from " << i_ << " to " << j_ << "\n";for(ll k_=i_; k_<=j_; k_++) cerr << x_[k_] << " ";cerr << "\n"; cerr.flush();
#define trace1(x)                cerr << #x << ": " << x << endl;
#define trace2(x, y)             cerr << #x << ": " << x << " | " << #y << ": " << y << endl;
#define trace3(x, y, z)          cerr << #x << ": " << x << " | " << #y << ": " << y << " | " << #z << ": " << z << endl;
#define trace4(a, b, c, d)       cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << endl;
#define trace5(a, b, c, d, e)    cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << endl;
#define trace6(a, b, c, d, e, f) cerr << #a << ": " << a << " | " << #b << ": " << b << " | " << #c << ": " << c << " | " << #d << ": " << d << " | " << #e << ": " << e << " | " << #f << ": " << f << endl;

const ll MOD = 1e9 + 7;
const int INF = 2e9;
const int MAX_LOG = 21;
const int MAX_N = 12800;

bool possible(int i, int j, int k, string &s){
	vi digits = {i, j, k};
	int id = 0, charid = 0;
	int n = s.length();
	while(id < 3 && charid < n){
		if(s[charid] - '0' == digits[id]){
			id++;
			charid++;
		}
		else{
			charid++;
		}
	}
	return (id == 3);
}
int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for(int i = 0; i <= 9; i++){
		for(int j = 0; j <= 9; j++){
			for(int k = 0; k <= 9; k++){
				if(possible(i, j, k, s)){
					ans++;
				}
			}
		}
	}
	cout << ans << endl;
}	

Measured memory_bytes: 384
#include <bits/stdc++.h>
#include <ext/pb_ds/detail/standard_policies.hpp>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

typedef long long int ll;
typedef unsigned long long int ull;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> o_set; 

#define     int                 ll
#define     pb                  push_back
#define     mp                  make_pair
#define     xx                  first
#define     yy                  second    
#define     all(a)              a.begin(),a.end()
#define     vi                  vector<int>
#define     vpi                 vector<pii>
#define     pii                 pair<int, int>
#define     present(DT, val)    (DT.find(val) != DT.end()) //for set and map
#define     cpresent(DT, val)   (find(all(DT),val) != DT.end()) //vectors
#define     input               "/home/pollution/Desktop/WorkSpace/C++/Files/input.txt"
#define     output              "/home/pollution/Desktop/WorkSpace/C++/Files/output1.txt"
#define     error               "/home/pollution/Desktop/WorkSpace/C++/Files/error.txt"
#define     IO()                ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define     INF                 2e18
#define     MOD                 1000000007
#define     clr(x)              memset(x, 0, sizeof(x))
#define     init(x, a)          memset(x, a, sizeof(x))
#define     out(a)              for (auto i: a) cout<<i<<' '; cout<<'\n'
#define     cpy(a,b)            memcpy(a,b,sizeof(b))
#define     itos(a)             to_string(a)
#define     ctoi(a)             int(a)-48
#define     setd(val,n)         cout<<fixed<<setprecision(n)<<val<<'\n'


void solve(){
    int n;cin>>n;
    int a[n][3],dp[n][3];clr(a);clr(dp);
    for( int i = 0; i < n; ++i) cin>>a[i][0]>>a[i][1]>>a[i][2];
    dp[0][0]=a[0][0];dp[0][1]=a[0][1];dp[0][2]=a[0][2];
	for(int i = 1; i < n; ++i){
		for(int j = 0; j < 3; ++j){
			for(int k = 0; k < 3; ++k){
				if(j!=k){
					dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
				}
			}
		}
	}
	cout<<max(dp[n-1][0],max(dp[n-1][1],dp[n-1][2]))<<'\n';
}

signed main() { 
    IO();

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


Measured memory_bytes: 4992
#!/usr/bin/env python3
from collections import defaultdict
from collections import deque
from heapq import heappush, heappop
import sys
import math
import bisect
import random
import itertools
sys.setrecursionlimit(10**5)
stdin = sys.stdin
bisect_left = bisect.bisect_left
bisect_right = bisect.bisect_right
def LI(): return list(map(int, stdin.readline().split()))
def LF(): return list(map(float, stdin.readline().split()))
def LI_(): return list(map(lambda x: int(x)-1, stdin.readline().split()))
def II(): return int(stdin.readline())
def IF(): return float(stdin.readline())
def LS(): return list(map(list, stdin.readline().split()))
def S(): return list(stdin.readline().rstrip())
def IR(n): return [II() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def FR(n): return [IF() for _ in range(n)]
def LFR(n): return [LI() for _ in range(n)]
def LIR_(n): return [LI_() for _ in range(n)]
def SR(n): return [S() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
mod = 1000000007
inf = float('INF')

#A
def A():
    s = S()
    a = s.count("-")
    b = s.count("+")
    print(b-a)
    return

#B
def B():
    n = S()
    num = sum(map(int, n))
    n = int("".join(n))
    print(["Yes", "No"][n % num > 0])
    return

#C
def C():
    n, k = LI()
    LI()
    print((n - k) // (k - 1) + 1 + bool((n - k) % (k - 1)))
    return

#D
def D():
    K = II()
    ans = 1
    i = 0
    def Sunuke(a):
        return a / sum(map(int, str(a)))
    def Check(a, i):
        return Sunuke(a + 10 ** i) > Sunuke(ans + 10 ** (i + 1))
    while K:
        print(ans)
        K -= 1
        i += Check(ans, i)
        ans += 10 ** i

    return


#Solve
if __name__ == '__main__':
    D()

Measured memory_bytes: 39408
#include <iostream>
#include <string> 
#include <vector> 
#include <algorithm> 
#include <utility> 
#include <tuple> 
#include <cstdint> 
#include <cstdio> 
#include <map> 
#include <queue> 
#include <set> 
#include <stack> 
#include <deque> 
#include <unordered_map> 
#include <unordered_set> 
#include <bitset> 
#include <cctype> 
#include<math.h>
using namespace std;
//#define int long long
#define m_p make_pair
#define mod 1000000007
#define rep(i,n)  for(int i=0; i<(int)(n); i++)
#define all(v)  v.begin(),v.end()
#define vecin(v) for(int i=0; i<(int)v.size(); i++)cin>>vec[i];
using namespace std;

int jousu(int, int);
int jousu(int x00, int y00) {
	int z00 = 1;
	for (int i = 0; i < y00; i++) {
		z00 *= x00;
	}
	return z00;
}
int kurai(int x00, int y00) {
	int z00 = (x00 % jousu(10, y00)) / jousu(10, y00 - 1);
	return z00;
}
int keta(int x00) {
	int z00 = x00;
	int w00 = 0;
	while (z00 != 0) {
		z00 /= 10;
		w00++;
	}
	return w00;
}



int main() {
	int n,ans;
	cin >> n;
	if (n % 2 == 1)ans = n / 2 + 1;
	else ans = n / 2;
	cout << ans << endl;
}


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

int main(){
  int a,b,c,x,y;
  cin >> a >> b >> c >> x >> y;
  int tmp,tmp1,tmp2;
  tmp = a*x+b*y;
  tmp1 = 2*c*max(x,y);
  tmp2 = 2*c*min(x,y);
  if(x<y) tmp2 += b*(y-x);
  else if(y<x) tmp2 += a*(x-y);
  
  cout << min(tmp,min(tmp1,tmp2)) << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		// 入力
		Scanner sc = new Scanner(System.in);
		double xp0 = sc.nextDouble();
		double yp0 = sc.nextDouble();
		Vector2d p0 = new Vector2d(xp0, yp0);
		double xp1 = sc.nextDouble();
		double yp1 = sc.nextDouble();
		Vector2d p1 = new Vector2d(xp1, yp1);
		int q = sc.nextInt();
		for (int i=0; i<q; i++) {
			double x = sc.nextDouble();
			double y = sc.nextDouble();
			System.out.println(solve(p0, p1, new Vector2d(x, y)));
		}
		sc.close();
	}

	static class Vector2d {
		Vector2d(Double x, Double y){
			this.x = x;
			this.y = y;
		}
		Double x;
		Double y;
		public String toString() {
			return String.format("%1$.10f %2$.10f", x, y);
		}
	}

	public static Vector2d sub(Vector2d v1, Vector2d v2){
		return new Vector2d(v2.x - v1.x, v2.y - v1.y);
	}

	public static String solve(Vector2d p0, Vector2d p1, Vector2d p2) {
		Vector2d v1 = sub(p0, p1);
		Vector2d v2 = sub(p0, p2);
		Double a = v1.x * v2.y - v1.y * v2.x;
		if(a == 0) {
			if(v2.x / v1.x < 0 || v2.y / v1.y < 0) {
				return "ONLINE_BACK";
			} else if(v2.x / v1.x > 1 || v2.y / v1.y > 1) {
				return "ONLINE_FRONT";
			} else {
				return "ON_SEGMENT";
			}
		} else if(a > 0) {
			return "COUNTER_CLOCKWISE";
		} else {
			return "CLOCKWISE";
		}
	}
}



Measured memory_bytes: 42668
# ABC 080 B - Harshad Number
n = int(input())

def harshad(x):
    tot = 0
    X = x
    while x > 0:
        tot += x%10
        x = x // 10
    if (X / tot)%1 == 0:
        return 'Yes'
    else:
        return 'No'
print(harshad(n))

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

int a, b;


void solve(){
  int r = 1;
  while ( r != 0){
    int tmp = b;
    r = a % b;
    a = tmp;
    b = r;
  }
  cout << a << endl;
  return ;
}
int main(){
  cin >> a >> b;
  solve();
  return 0;
}

Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using vec=vector<ll>;
using mat=vector<vec>;
#define For(i,a,b) for(i=a;i<b;i++)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define mod 1000000007
using datas=pair<ll,ll>;
using tdata=pair<datas,ll>;

long mmid(long a,long b,long c){return a<b?(b<c?b:max(a,c)):(b>c?b:min(a,c));}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

ll modncr(ll n,ll r){
  ll i,plus=1;
  rep(i,r){
    plus=(plus*(n-i))%mod;
    plus=moddevide(plus,i+1);
  }
  return plus;
}

ll euclidean_gcd(ll a, ll b) {
  if(a<b) return euclidean_gcd(b, a);
  ll r;
  while ((r=a%b)){a=b;b=r;}
  return b;
}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

void printmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  For(i,0,H+2){
    For(j,0,W+2){cout<<a[i*(W+2)+j];}
    cout<<endl;
  }
}
void inputmap(vector<ll>& a,ll H,ll W){
  ll i,j;
  string ss;
  For(i,1,H+1){
    cin>>ss;
    For(j,1,W+1){
      if(ss[j-1]=='#'){
        a[i*(W+2)+j]=1;
      }else{
        a[i*(W+2)+j]=0;
      }
    }
  }
}

int main(){
  ll i,N,ans=1,f=0,l=1;
  cin>>N;
  string ss;cin>>ss;
  if(ss[0]!='B'){cout<<0<<endl;return 0;}
  rep1(i,N+1)ans=(ans*i)%mod;
  rep1(i,N*2){
    if(ss[i]==ss[i-1])f=1-f;
    if(f){
      if(l<0){cout<<0<<endl;return 0;}
      ans=ans*l%mod;
      l--;
    }else{
      l++;
    }
  }
  if(l==0){
    cout<<ans<<endl;
  }else{
    cout<<0<<endl;
  }
  return 0;
}

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

int main(){
  int a[3];
  cin >> a[0] >> a[1] >> a[2];
  sort(a, a+3);
  if(a[0] == a[1] && a[1] == a[2]){
    cout << 0 << endl;
    return 0;
  }
  int max = a[2];
  int min = a[0];
  int sum = (max - min) / 2;
  sum += (max - min) % 2;
  if((max - min) % 2) a[1]++;
  min = a[1];
  if(max - min > 0){
    sum += (max - min) / 2;
    if((max - min) % 2 == 1) sum += 2;
  }else if(max - min < 0) sum += 1;
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
int main()
{
  int n,a,b;
  scanf("%d%d%d",&n,&a,&b);
  if((a+b)<=n)
      printf("%d 0",min(a,b));
  
  else
      printf("%d %d",min(a,b),(a+b)-n);
            
}


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

int main() {
  string S;
  cin >> S;
  int n=S.size();
  for(int i=0;i<n;i++) {
    if(S.at(i)=='?') {
     S.at(i)='D';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define REP(i,x,n) for(int i=x;i<(int)n;i++)
#define rep(i,n) REP(i,0,n)
#define sp(p) cout<<setprecision(16)<<fixed<<p<<endl;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define SORT(a) sort(all(a))
#define RSORT(a) sort(rall(a))
#define UNIQ(a) unique(all(a))
#define UNIQNUM(a) UNIQ(a)-a.begin()
#define UNIQIT(a) a.erase(UNIQ(a), a.end());
#define VOUT(v,i) cout<<#v<<": ";for(int i=0;i<(int)v.size();i++){cout<<v[i]<<" ";}cout<<"\n";
#define vout(v) VOUT(v,z);
#define vmin(v) *min_element(all(v))
#define vmax(v) *max_element(all(v))
#define vsum(v) accumulate(all(v), 0LL);
#define MOUT(m,r,c) rep(i,r){rep(j,c){cout<<m[i][j]<<" ";}cout<<endl;}
#define mout(m) MOUT(m,m.size(),m[0].size())
#define debg(a) cout<<#a<<": "<<a<<endl;
#define show(a) for(cont &y:a){for(cont &x:y){cout<<x<<" ";}cout<<endl;}
#define digit(a) to_string(a).length();
template<class T>inline int out(const T &t){ print(t); putchar('\n'); return 0; }
template<class T>inline T gcd(T a,T b){if(b==0)return a; return(gcd(b,a%b));}
template<class T>inline T lcm(T a,T b){return a/gcd(a,b)*b;}
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef vector<ll> V;
// const long long MOD=1000000007;
const long long INF = 1e18;
#define EPS (1e-7)
#define PI (acos(-1))
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 solve(long long H){
    ll ex=floor(log2(H))+1;
    // debg(ex);
    ll ret=pow(2,ex)-1;
    cout << ret << "\n";
}

int main(){
    long long H;
    scanf("%lld",&H);
    solve(H);
    return 0;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
#define N 10
using namespace std;
int n,a[N],z[N],ans;
string s,t;

void check(){
  int cp[N],cnt=0;
  for(int i=0;i<n;i++)cp[i]=a[i];
  for(int i=0;i<n;i++){
    int x=cp[i];
    if(!x)continue;
    cnt++;
    for(int j=i;j<=z[i];j++)
      cp[j]=(cp[j]-x+10)%10;
  }
  ans=min(ans,cnt);
}

void dfs(int x){
  if(x==n){
    check();
    return;
  }
  for(int i=x;i<n;i++){
    z[x]=i;
    dfs(x+1);
  }
}

int main(){
  while(1){
    cin>>n;
    if(!n)break;
    cin>>s>>t;
    for(int i=0;i<n;i++)
      a[i]=((s[i]-'0')-(t[i]-'0')+10)%10;
    ans=n;
    dfs(0);
    cout<<ans<<endl;
  }
  return 0;
}

Measured memory_bytes: 3016