akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
template<class S, class T> inline S min_L(S a,T b){
  return a<=b?a:b;
}
template<class S, class T> inline S max_L(S a,T b){
  return a>=b?a:b;
}
inline void rd(int &x){
  int k;
  int m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
template<class T> int arrCountVal(int N, T A[], T val){
  int i;
  int res = 0;
  for(i=(0);i<(N);i++){
    if(A[i]==val){
      res++;
    }
  }
  return res;
}
int N;
int A[100000];
int main(){
  int mi;
  int mx;
  int x;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=(0);Lj4PdHRW<(N);Lj4PdHRW++){
      rd(A[Lj4PdHRW]);
    }
  }
  {
    int e98WHCEY;
    int cTE1_r3A;
    if(N==0){
      cTE1_r3A = 0;
    }
    else{
      cTE1_r3A = A[0];
      for(e98WHCEY=(1);e98WHCEY<(N);e98WHCEY++){
        cTE1_r3A = min_L(cTE1_r3A, A[e98WHCEY]);
      }
    }
    mi =cTE1_r3A;
  }
  {
    int xr20shxY;
    int WYIGIcGE;
    if(N==0){
      WYIGIcGE = 0;
    }
    else{
      WYIGIcGE = A[0];
      for(xr20shxY=(1);xr20shxY<(N);xr20shxY++){
        WYIGIcGE = max_L(WYIGIcGE, A[xr20shxY]);
      }
    }
    mx =WYIGIcGE;
  }
  if(mx - mi >= 2){
    wt_L("No");
    wt_L('\n');
    return 0;
  }
  if(mi == mx && mi == N-1){
    wt_L("Yes");
    wt_L('\n');
    return 0;
  }
  x = N - arrCountVal(N,A,mx);
  if((N-x)/2 >= mx-x  &&  mx-x > 0){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20191125-1

// --- original code ---
// int N, A[1d5];
// {
//   int mi, mx, x;
//   rd(N,A(N));
//   mi = min(A(N));
//   mx = max(A(N));
//   if(mx - mi >= 2) wt("No"), return 0;
//   if(mi == mx && mi == N-1) wt("Yes"), return 0;
//   x = N - arrCountVal(N,A,mx);
//   wt( if[(N-x)/2 >= mx-x > 0, "Yes", "No"] );
// }


Measured memory_bytes: 640
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void)
{
	int n,i;
	long long l[87];
	scanf("%d",&n);
	l[0]=2;	l[1]=1;
	for(i=2;i<=n;i++)	{
		l[i]=l[i-1]+l[i-2];
	}
	printf("%lld\n",l[n]);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <vector>
#include <iostream>
#include <vector>
#include <cassert>
#include <algorithm>
#include <functional>
#include <cmath>
#include <queue>
#include <set>
#include <stack>
#include <deque>
#include <map>
using ll=long long;
using namespace std;
const int INF = 7+(1e+9);
int main()
{
    double n;
    cin>>n;
    int k=n/2;
    if((int)n%2==1){
        k++;
    }
    
    cout<<(double)k/n<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define rrep(i,n) for(int i=1;i<(n);++i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int inf = 1001001001;
const int mod = 1000000007;

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n, m;
	cin >> n >> m;
	vector<vector<ll>> a(n, vector<ll>(3));
	rep(i, n)rep(j, 3) cin >> a[i][j];
	ll ans = -inf;
	rep(bit, (1 << 3)) {
		vector<ll> now(n);
		rep(i, n) {
			ll cnt = 0;
			rep(j, 3) {
				if (bit & (1 << j)) cnt += a[i][j];
				else cnt -= a[i][j];
			}
			now[i] = cnt;
		}
		sort(rall(now));
		ll tmp = 0;
		rep(i, m) tmp += now[i];
		ans = max(ans, tmp);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <vector>
#include <string>
#include <cstring>
#include <utility>
#include <queue>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
#include <ctime>
#include <cstdlib>
#include <climits>
using namespace std;

#define MOD1097 1000000007

#define ll long long
#define pint pair<int, int>
#define pll pair<ll, ll>
#define pb push_back
#define mpair make_pair
#define pm(first, second) pb(mpair(first, second))
#define fpf first.first
#define fps first.second
#define spf second.first
#define sps second.second

#define all(X) (X).begin(), (X).end()
#define rall(X) (X).rbegin(), (X).rend()
#define divcel(a, b) (((a) + ((b) - 1)) / (b))

int main(){

	string S, T;
	cin >> S >> T;
	for(int i = 0; i < S.size(); i++){
		if(S[i] != T[i]){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
#include <queue>
#include <map>
#include <set>
using namespace std;
using Int = int64_t;
const Int INF = 1<<30;
const Int MOD = (Int)1e9 + 7;
const Int MAX_N = (Int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    Int n; cin >> n;
    vector<Int> A(n);
    Int sum = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> A[i];
        sum ^= A[i];
    }
    vector<Int> B;
    for(int i = 0; i < n; i++)
    {
        B.push_back(sum ^ A[i]);
    }
    cout << B << endl;
}

signed main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 6880
import java.util.*;
public class Main
{
	public  static  void main(String args[])
	{
		Scanner s=new Scanner(System.in);
		int yen=s.nextInt();
		int hap=0;
		while(yen>=5)
		{
			if(yen>=500)
			{
				yen=yen-500;
				hap=hap+1000;
			}
			if(yen<500 && yen>=5)
			{
				yen=yen-5;
				hap=hap+5;
			}
		}
		System.out.print(hap);
	}
}

Measured memory_bytes: 22996
import java.util.*;
//import java.util.stream.Collectors;

public class Main{
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		int c = Integer.parseInt(sc.next());
		int k = Integer.parseInt(sc.next());
		for(int i=0; i<k; i++){
			if(b >= c){
				c *= 2;
			}else if(a >= b){
				b *= 2;
			}
		}
		System.out.println(a < b && b < c ? "Yes" : "No");
	}
}


Measured memory_bytes: 35748
#include <limits.h>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#include <algorithm>
#include <cassert>
#include <cfloat>
#include <complex>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <regex>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define repLRE(i, l, r) for (ll i = (l); i <= (r); ++i)
#define rrepLRE(i, l, r) for (ll i = (l); i >= (r); --i)
#define Sort(v) sort(v.begin(), v.end())
#define rSort(v) sort(v.rbegin(), v.rend())
#define Reverse(v) reverse(v.begin(), v.end())
#define Lower_bound(v, x) \
  distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) \
  distance(v.begin(), upper_bound(v.begin(), v.end(), x))

using ll = long long;
using ull = unsigned long long;
using P = pair<ll, ll>;
using T = tuple<ll, ll, ll>;
using vll = vector<ll>;
using vP = vector<P>;
using vT = vector<T>;
using vvll = vector<vector<ll>>;
using vvP = vector<vector<P>>;
using dqll = deque<ll>;

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

/* Macros reg. ends here */

const ll INF = 1LL << 50;

int main() {
  // ios_base::sync_with_stdio(0), c
  cout << fixed << setprecision(15);

  ll n, k;
  cin >> n >> k;

  const ll mod = 1000000007;

  vll as(n);
  const ll amax = 2005;
  vll cnt(amax, 0);
  rep(i, n) {
    ll a;
    cin >> a;
    as[i] = a;
    cnt[a]++;
  }

  ll ans = 0;
  rep(i, n-1) repLRE(j, i+1, n-1) if(as[i] > as[j]) ans++;
  repLRE(i, 1, amax-1) cnt[i] += cnt[i-1];

  ans *= k;
  ans %= mod;
  rep(i, n){
    ll a = as[i];
    ll wt = n - cnt[a];
    ans += wt*((k-1)*k/2 % mod);
    ans %= mod;
  }

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


Measured memory_bytes: 3628
input()
from collections import *
c=Counter(map(int,input().split()))
f=lambda x:sorted(-k for k,v in c.items() if v>x)
a=0;r=f(1);s=f(3)
if len(r)>1: a=r[0]*r[1]
if s: a=max(a,s[0]**2)
print(a)

Measured memory_bytes: 24104
#include "bits/stdc++.h"
using namespace std;
 
int main(void) {
    string s;
    cin >> s;
    char alpha = 'a', none = 'z';
    none++;

    int j;
    bool check;

    for(int i=0;i<26;i++) {
        check = false;
        for(j=0;j<s.size();j++) {
            if(alpha == s.at(j)) check = true;
        }
        if(check == false) break;
        alpha++;
    }
    
    if(alpha == none) cout << "None" << endl;
    else cout << alpha << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
int main()
{
  char str[1000];
  cin >> str;
  int len = strlen(str);
  for(int i = 0;i < len;i++){
    if(str[i] == 'A')str[i] = 'X';
    else if(str[i] == 'B')str[i] = 'Y';
    else if(str[i] == 'C')str[i] = 'Z';
    else {
      str[i] -= 3;
    }
    cout << str[i];
  }
  cout << endl;
}

Measured memory_bytes: 1136
import sys
from fractions import gcd
input = lambda: sys.stdin.readline().rstrip()

n = int(input())
a = list(map(int, input().split()))
# 左から
L = [0 for _ in range(n + 1)]
for i in range(n):
    L[i + 1] = gcd(L[i], a[i])

R = [0 for _ in range(n + 1)]
for i in range(n - 1, -1, -1):
    R[i] = gcd(R[i + 1], a[i])

# print(L)
# print(R)
m = 0
for i in range(n):
    m = max(m, gcd(L[i], R[i + 1]))
print(m)


Measured memory_bytes: 16240
/*
これを入れて実行
g++ code.cpp
./a.out
 */
 
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <deque>
#include <algorithm>
#include <utility>
#include <set>
#include <map>
#include <cmath>
#include <math.h>
#include <tuple>
#include <iomanip>
 
using namespace std;
typedef long long ll;
typedef long double ld;
 
int dy4[4] = {-1, 0, +1, 0};
int dx4[4] = {0, +1, 0, -1};
int dy8[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
int dx8[8] = {0, 1, 1, 1, 0, -1, -1, -1};
 
const long long INF = 1LL << 60;
const ll MOD = 1e9 + 7;
 
bool greaterSecond(const pair<int, int>& f, const pair<int, int>& s){
    return f.second > s.second;
}
 
ll gcd(ll a, ll b){
	if (b == 0)return a;
	return gcd(b, a % b);
}
 
ll lcm(ll a, ll b){
    return a / gcd(a, b) * b;
}
 
ll nCr(ll n, ll r){
    if(r == 0 || r == n){
        return 1;
    } else if(r == 1){
        return n;
    }
    return (nCr(n - 1, r) + nCr(n - 1, r - 1));
}
 
ll nPr(ll n, ll r){
    r = n - r;
    ll ret = 1;
    for (ll i = n; i >= r + 1; i--) ret *= i;
    return ret;
}
 
//-----------------------ここから-----------

int main(void){

    int n;
    cin >> n;

    vector<vector<pair<int,int>>> l(n);

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

        l[i].resize(a);

        for(int j = 0; j < a; j++){
            pair<int,int> tmp;

            cin >> tmp.first >> tmp.second;

            tmp.first--;

            l[i][j] = tmp;
        }
    }

    int ans = 0;

    for(int bit = 0; bit < (1 << n); bit++){
        vector<int> st;

        for(int i = 0; i < n; i++){
            if(bit & (1 << i)){
                st.push_back(i);
            }
        }


        vector<bool> h(n, false);

        bool contradict = false;
        int tmpans = 0;

        for(int i = 0; i < st.size(); i++){
            h[st[i]] = true;
        }

        for(int i = 0; i < n; i++){
            if(contradict) break;
            if(h[i]){
                for(int j = 0; j < l[i].size(); j++){

                    if(l[i][j].second == 0 && h[l[i][j].first]){
                        contradict = true;
                        break;
                    }


                    if(l[i][j].second == 1){
                        h[l[i][j].first] = true;
                    }
                }
            }
        }

        for(int i = 0; i < n; i++){
            if(contradict){
                break;
            }
            if(h[i]){
                for(int j = 0; j < l[i].size(); j++){
                    if(l[i][j].second != h[l[i][j].first]){
                        contradict = true;
                        break;
                    }
                }
            }
        }

        if(!contradict){
            for(int i = 0; i < h.size(); i++){
                if(h[i]){
                    tmpans++;
                }
            }
            ans = max(ans, tmpans);
        }


        
    }

cout << ans << endl;

    
}

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

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << setprecision(20) << fixed;

  int N;
  cin >> N;
  int count = 0;
  for(int i = 1; i <= N; ++i){
    if(i <= 9 || (i >= 100 && i < 1000) || (i >= 10000) && (i < 100000)){
      ++count;
    }
  }
  cout << count <<endl;
}

Measured memory_bytes: 256
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var MN=Arr.shift().split(" ").map(Number);
var M=MN[0];
var N=MN[1];
var K=Arr.shift()-0;
var YX=[];
for(var i=0;i<M;i++){
   var str=(Arr.shift()).replace(/J/g,"0").replace(/O/g,"1").replace(/I/g,"2");
   var arr=str.split("").map(Number);
   YX.push(arr);
}
var dp=[];
for(var y=0;y<=M;y++){
   dp[y]=[];
   for(var x=0;x<=N;x++){
      dp[y][x]=[];
      for(var k=0;k<3;k++){
         dp[y][x][k]=0;
      }
   }
}
for(var y=1;y<=M;y++){
   for(var x=1;x<=N;x++){
      for(var k=0;k<3;k++){
            dp[y][x][k]=dp[y][x-1][k]+dp[y-1][x][k]-dp[y-1][x-1][k];
            if(YX[y-1][x-1]===k)dp[y][x][k]++;
      }
   }
}
for(var i=0;i<K;i++){
   var arr=Arr.shift().split(" ").map(Number);
   var y1=arr[0];
   var x1=arr[1];
   var y2=arr[2];
   var x2=arr[3];
   var ans=[];
   for(var k=0;k<3;k++){
      ans.push(dp[y2][x2][k]-dp[y1-1][x2][k]-dp[y2][x1-1][k]+dp[y1-1][x1-1][k]);
   }
   console.log(ans.join(" "));
}

Measured memory_bytes: 155568
import scala.io.StdIn.readLine

object Main {
  def main(args: Array[String]) = {
    val n = readLine.split(" ")(0).toInt
    val c = readLine.split(" ").map(_.toInt)
    val minVal = (0 to n+1).toArray

    for( i <- 2 to n+1 ) {
      for( j <- c ) {
        if(j<=i && minVal(i-j) + 1 < minVal(i)) {
          minVal(i) = minVal(i-j)+1
        }
      }
    }
    println(minVal(n))
  }
}

Measured memory_bytes: 60708
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>

using namespace std;

const int MAXN = 3050;

int n, m;
pair <int, int> a[MAXN];
int dp[2 * MAXN];

int main() {
  //assert(freopen("input.txt","r",stdin));
  //assert(freopen("output.txt","w",stdout));

  scanf("%d %d", &n, &m);

  for (int i = 0; i < n; i++) {
    scanf("%d %d", &a[i].first, &a[i].second);
  }

  sort(a, a + n);

  dp[0] = 0;
  for (int i = 0; i < n; i++) {
    for (int j = m - 1 + a[i].first; j >= a[i].first; j--) {
      int prev = j - a[i].first;
      if (prev <= m - 1) {
        dp[j] = max(dp[j], dp[prev] + a[i].second);
      }
    }
  }

  int ans = 0;
  for (int i = 0; i < 2 * MAXN; i++) {
    ans = max(ans, dp[i]);
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		sc.close();
		if(s.equals("ARC")) {
			System.out.println("ABC");
		}else {
			System.out.println("ARC");
		}
	}

}

Measured memory_bytes: 35648
//
//  main.cpp
//
 
#include <algorithm>
#include <array>
#include <assert.h>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
 
using namespace std;
 
using ll = long long;
using ull = unsigned long long;
 
template<typename T>
vector<T> make_vec_nd(T init, size_t size) {
	return vector<T>(size, init);
}
template<typename T, typename... Args>
auto make_vec_nd(T init, size_t size, Args... rest) {
	auto inner = make_vec_nd(init, rest...);
	return vector<decltype(inner)>(size, inner);
}

#define rep(i,a,b) for(ll i=(a);i<(b);i++)
#define rrep(i,a,b) for(ll i=(a)-1;i>=(b);i--)

int main() {
	ll H, W, A, B;
	cin >> H >> W >> A >> B;
	rep(y,0,H) {
		rep(x,0,W) {
			bool one = false;
			if (x+1 <= A) {
				one = !one;
			}
			if (y+1 <= B) {
				one = !one;
			}
			if (one) {
				cout << 1;
			} else {
				cout << 0;
			}
		}
		cout << endl;
	}
}


Measured memory_bytes: 1280
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <tuple>
#include <queue>
#include <bitset>
#include <map>
#include <unordered_map>
#include <tuple>
#include <utility>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <sys/time.h>

using namespace std;

void solve(long long N, vector<long long> s){
  long long k, x;
  long long a, b;
  long long ans = 0;
  for (long long c = 1; c <= N-2; c++) {
    k = 1;
    x = 0;
    map<int, int> used;
    while (k*c < N-1) {
      a = N-1-k*c;
      b = a - c;
      if (a < 1 || b >= a || b < 1 || used.find(k*c)!=used.end() || used.find(N-1-k*c)!=used.end() || k*c == N-1-k*c) {
        break;
      }
      x += s[k*c];
      x += s[N-1-k*c];
      used[k*c] = 1;
      used[N-1-k*c] = 1;
      ans = max(ans, x);
      k++;
    }
  }
  std::cout << ans << std::endl;
}

int main(){
  long long N;
  scanf("%lld",&N);
  vector<long long> s(N);
  for(int i = 0 ; i < N ; i++){
    scanf("%lld",&s[i]);
  }
  solve(N, s);
  return 0;
}


Measured memory_bytes: 6528
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String {
            bytes
                .by_ref()
                .map(|r| r.unwrap() as char)
                .skip_while(|c| c.is_whitespace())
                .take_while(|c| !c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

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

#[allow(unused_imports)]
use std::cmp::{min, max};

fn main() {
    input!{
        k: usize
    }
    let mut n: usize = 0;
    for _ in 0..k {
        n += 1;
        let mut m = n;
        let mut x = f(n);
        let mut d = 1;
        while d <= n {
            d *= 10;
            let n1 = (n / d + 1) * d - 1;
            let x1 = f(n1);
            if x > x1 {
                m = n1;
                x = x1;
            }
        }
        n = m;
        println!("{}", n);
    }
}

fn f(n: usize) -> f64 {
    let mut m = n;
    let mut s = 0;
    while m > 0 {
        s += m % 10;
        m /= 10;
    }
    n as f64 / s as f64
}


Measured memory_bytes: 4352
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int n = scanner.nextInt();
        r[] a = new r[n];
        for (int i = 0; i < n; i++) {
            a[i] = new r();
            a[i].s = scanner.next();
            a[i].p = scanner.nextInt();
            a[i].i = i + 1;
        }

        Arrays.sort(a, Comparator.<r, String>comparing(ar -> ar.s).reversed().thenComparingInt(ar -> ar.p).reversed());

        for (r r : a) {
            System.out.println(r.i);
        }
    }

    static class r {
        String s;
        int p;
        int i;
    }
}

Measured memory_bytes: 26580
import sys
import math

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    N, P = [int(x) for x in input().split()]
    A = [int(x) for x in input().split()]

    odd = 0
    even = 0
    ans = 0
    def comb(n, r):
        return math.factorial(n) // math.factorial(r) // math.factorial(n - r)
    for a in A:
        if a % 2 == 0:
            even += 1
        else:
            odd += 1

    if P == 0:
        for i in range(0, odd + 1, 2):
            for j in range(even + 1):
                ans += comb(odd, i) * comb(even, j)
        print(ans)
    else:
        for i in range(1, odd + 1, 2):
            for j in range(even + 1):
                ans += comb(odd, i) * comb(even, j)
        print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<cmath>
#include<vector>
#include<queue>
#include<map>
#include<bitset>
#include<set>
#define N (10000010)
#define P (998244353)
#define M ()
#define inf (0x7f7f7f7f)
#define rg register int
#define Label puts("NAIVE")
#define spa print(' ')
#define ent print('\n')
#define rand() (((rand())<<(15))^(rand()))
#define file(s) freopen(s".in","r",stdin),freopen(s".out","w",stdout)
typedef long double ld;
typedef long long LL;
typedef unsigned long long ull;
using namespace std;
namespace fastIO1{
	inline char read(){
		static const int IN_LEN=1000000;
		static char buf[IN_LEN],*s,*t;
		return (s==t?t=(s=buf)+fread(buf,1,IN_LEN,stdin),(s==t?-1:*s++):*s++);
	}
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=read();!isdigit(c);c=read()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=read())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
	inline char readc(char &c){
		for(c=read();!isalpha(c)&&!isdigit(c);c=read())
		if(c==-1)return 0;
	}
	const int OUT_LEN = 10000000;
	char obuf[OUT_LEN],*ooh=obuf;
	inline void print(char c){
		if(ooh==obuf+OUT_LEN)fwrite(obuf,1,OUT_LEN,stdout),ooh=obuf;
		*ooh++=c;
	}
	template<class T>
	inline void print(T x){
		static int buf[30],cnt;
		if(x==0)print('0');
		else{
			if(x<0)print('-'),x=-x;
			for(cnt=0;x;x/=10)buf[++cnt]=x%10+48;
			while(cnt)print((char)buf[cnt--]);
		}
	}
	inline void flush(){fwrite(obuf,1,ooh-obuf,stdout);}
}
namespace fastIO2{
	template<class T>
	inline void read(T &x){
		static bool iosig;
		static char c;
		for(iosig=false,c=getchar();!isdigit(c);c=getchar()){
			if(c=='-')iosig=true;
			if(c==-1)return;
		}
		for(x=0;isdigit(c);c=getchar())x=((x+(x<<2))<<1)+(c^'0');
		if(iosig)x=-x;
	}
}
using namespace fastIO1;
int n,jc[N],inv[N],pw[N],ans;
int ksm(int a,int p){
	int res=1;
	while(p){
		if(p&1)res=1ll*res*a%P;
		a=1ll*a*a%P,p>>=1;
	}
	return res;
}
int C(int n,int m){
	return 1ll*jc[n]*inv[m]%P*inv[n-m]%P;
}
int main(){
	read(n); inv[0]=jc[0]=pw[0]=1;
	for(int i=1;i<=n;i++)jc[i]=1ll*jc[i-1]*i%P,pw[i]=2ll*pw[i-1]%P;
	inv[n]=ksm(jc[n],P-2);for(int i=n-1;i;i--)inv[i]=1ll*inv[i+1]*(i+1)%P;
	for(int i=n/2+1;i<=n;i++)(ans+=1ll*C(n,i)*pw[n-i]%P)%=P;
	printf("%lld\n",(0ll+ksm(3,n)-ans+P-ans+P)%P);
}

Measured memory_bytes: 121088
import sys
class BIT:
    def __init__(self, node_size):
        self._node = node_size+1
        self.bit = [0]*self._node

    def add(self, index, add_val):
        while index < self._node:
            self.bit[index] += add_val
            index += index & -index

    def sum(self, index):
        res = 0
        while index > 0:
            res += self.bit[index]
            index -= index & -index
        return res
def cheak(x):
  c = [0] * n
  for i in range(n):
    if a[i] >= x:
      c[i] = 1
    else:
      c[i] = -1
  ru = [0] * (n+1)
  for i in range(1,n+1):
    ru[i] = c[i-1] + ru[i-1]
  ans = 0
  bit = BIT(n+2)
  MIN = min(ru)
  for i in range(len(ru)):
    ans += i - bit.sum(ru[i]-MIN+1)
    bit.add(ru[i]-MIN+1, 1)
  if ans <= n*(n+1)//4:
    return 1
  else:
    return 0
n = int(input())
a = list(map(int, sys.stdin.readline().split()))
b = sorted(a)
dai = n-1
syo = 0
while True:
  if dai-syo <= 1:
    break
  kon = b[(dai+syo)//2]
  d = cheak(kon)
  if d == 1:
    syo = (dai+syo)//2
  else:
    dai = (dai+syo)//2
if cheak(b[dai]) == 1:
  print(b[dai])
else:
  print(b[syo])

Measured memory_bytes: 97764
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<string>
#include<cmath>
#include<queue>
#include<vector>
#include<sstream>
#include<algorithm>
#include<stack>
#include<bitset>
#include<map>
#include<set>
#define rep(i,n) for(int i=0;(i)<(n);i++)
#define rep1(i,n) for(int i=1;(i)<=(n);i++)
#define mst(a,b) memset(a,b,sizeof(a))
#define scd(a) scanf("%d",&a)
#define scdd(a,b) scanf("%d%d",&a,&b)
#define scddd(a,b,c) scanf("%d%d%d",&a,&b,&c)
#define IOS ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define dbg(a) cout<<"* "<< #a <<" : "<<a<<endl
#define fr first
#define se second
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define lowbit(x) x&(-x)
#define ac cout<<ans<<endl
//#define DEBUG 0
using namespace std;
const double pi=acos(-1.0);
const double eps=1e-6;
const ull hashp=1e7+19;
const ll INF=0x3f3f3f3f3f3f3f3fll;
const int inf=0x3f3f3f3f;
const int mod=1e9+7;
const int maxn=2e5+100;
int head[maxn],cnt;
struct node{
	int nxt,to,id;
}e[maxn];
void add(int a,int b,int id){
	e[++cnt].nxt=head[a],e[cnt].to=b,e[cnt].id=id,head[a]=cnt;
}
int ans[maxn];
int mxcol;
void dfs(int col,int u,int fa){
	int now=1;
	if(now==col)now++;
	for(int i=head[u];i;i=e[i].nxt){
		int to=e[i].to;
		if(to==fa)continue;
		int id=e[i].id;
		ans[id]=now++;
		mxcol=max(mxcol,now-1);
		dfs(now-1,to,u);
		if(now==col)now++;
	}
}
void solve()
{
	int n;scd(n);
	rep1(i,n-1){
		int x,y;
		scdd(x,y);
		add(x,y,i);
		add(y,x,i);
	}
	dfs(0,1,1);
	printf("%d\n",mxcol);
	rep1(i,n-1)printf("%d\n",ans[i]);
}
int main(){
    //IOS;
    //freopen("D://data.txt","r",stdin);
    solve();
    return 0;
}


Measured memory_bytes: 5888
#include<iostream>
#include<math.h>
#include<complex>
#include<cstdlib>
#include<algorithm>
#include<functional>
#include <cstdint>
#include<string.h>

typedef unsigned long long ll;

using namespace std;

int main() {
	int n;
	int i = 0;
	cin >> n;
	char s[1000];
	for (i = 0; i < n; i++) {
		cin >> s[i];
	}
	int k;
	cin >> k;


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

	}
	for (i = 0; i < n; i++) {
		cout << s[i] ;
	}
}



Measured memory_bytes: 256
//---------------------------------------------------------------
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <vector>
#include <cstdlib>
#include <cmath>
#include <math.h>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#include<algorithm>
//---------------------------------------------------------------
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep1(i, n) for (int i = 1; i <= (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define SIZE 100005
#define INF 1e18
#define all(x) x.begin(),x.end()
#define fi first
#define se second
#define vec vector
using pint = pair<int,int>;
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
//---------------------------------------------------------------
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const double pi = acos(-1);
const int mod = 1000000007;
struct mint {
int64_t x;
mint(int64_t x=0):x((x%mod+mod)%mod){}
mint operator-() const { return mint(-x);}
mint& operator+=(const mint a) {if ((x += a.x) >= mod) x -= mod;return *this;}
mint& operator-=(const mint a) {if ((x += mod-a.x) >= mod) x -= mod;return *this;}
mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
mint operator+(const mint a) const { return mint(*this) += a;}
mint operator-(const mint a) const { return mint(*this) -= a;}
mint operator*(const mint a) const { return mint(*this) *= a;}
mint pow(int64_t t) const {if (!t) return 1;mint a = pow(t>>1);a *= a;if (t&1) a *= *this;return a;}
mint inv() const { return pow(mod-2);}
mint& operator/=(const mint a) { return *this *= a.inv();}
mint operator/(const mint a) {return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}
//---------------------------------------------------------------

//↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓


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

    string s;
    ll k;
    cin>>s;
    cin>>k;
    vec<string> res;
    rep(i,s.size()){
        rep1(j,k){
            res.push_back(s.substr(i,j));
        }
    }
    sort(all(res));
    res.erase(unique(all(res)),res.end());
    cout<<res[k-1]<<endl;
}

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

int main() {
    vector<string> s(3);
    rep(i, 3) cin >> s.at(i);
    rep(i, 3) {
        cout << s.at(i).at(0);
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
using System;
class program {
  static void Main(String[] args) {
    String[] input = Console.ReadLine().Split(' ');
    int a = int.Parse(input[0]);
    int b = int.Parse(input[1]);
    int c = a * b;
    if (c % 2 == 0) {
      Console.WriteLine("Even");
    } else {
      Console.WriteLine("Odd");
    }
  }
}

Measured memory_bytes: 11092
#include<bits/stdc++.h>
#define fr(i1,m) for(int i1=0;i1<m;i1++)
using namespace std;
int main()
{
    string s;

       while(cin>>s)
       {
           long l;
           char c;
           stack<char>st;
           l=s.size();
           fr(i,l)
           {
               if(s[i]=='T')
               {
                   if(st.size()>0)
                    {
                   c=st.top();

                   if(c=='S')
                    st.pop();
                   else
                    st.push(s[i]);
                    }
                    else
                           st.push(s[i]);
               }
               else
                  st.push(s[i]);
           }
           cout<<st.size()<<"\n";
       }
        return 0;

}




Measured memory_bytes: 644
#include<cstdio>
#include <iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<queue>
#include<vector>
#include<functional>
#include<cmath>
#include<map>
#include<stack>
#include<cstdlib>
#include<list>
#include<set>
#include<numeric>

#define MOD 1000000007

using namespace std;
typedef long long ll;

int P[100010],sum[100010];

int main()
{
	ll N, M;
	cin >> N >> M;

	cin >> P[0];
	ll pos = P[0];

	for (int i = 1; i <= M - 1; i++) {
		cin >> P[i];
		if (pos < P[i]) {
			sum[pos]++; sum[P[i]]--;
		}
		else {
			sum[P[i]]++; sum[pos]--;
		}
		pos = P[i];
	}

	ll ans = 0;
	for (int i = 1; i <= N-1; i++) {
		ll A, B, C;
		cin >> A >> B >> C;
		sum[i] += sum[i - 1];
		ans += min(A * sum[i],B*sum[i]+C);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 3848
#include<iostream>
using namespace std;
int main() {
    int n, flag, cnt=0;
    cin >> n;
    int A[n];
    for (int i=0; i<n; i++){
        cin >> A[i];
    }
    flag = 1;
    while (flag){
        flag = 0;
        for (int j=n-1; j>0; j--){
            if (A[j] < A[j-1]){
                swap(A[j], A[j-1]);
                flag = 1;
                cnt += 1;
            }
        }
    }
    for (int i=0; i<n; i++){
        if (i==n-1){
            cout << A[i] << endl;
        } else {
            cout << A[i] << " ";
        }
    }
    cout << cnt << endl;
    return 0;
}


Measured memory_bytes: 3088
#include<bits/stdc++.h>
/* #define int long long */
/* #define double long double */
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
#define MOD 1000000007
using namespace std;
using ll = long long;
typedef vector<int> vi;
typedef pair<int, int> P;
#define rrep(i,a,b) for(int i=a;i>=b;i--)
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; }

signed main(){
    ll l, r;
    cin >> l >> r;
    ll ans = 2019;
    if(r - l >= 2019){
        cout << 0 << endl;
        return 0;
    }
    for(ll i = l+1; i <= r; i++){
        for(ll j = l; j < i; j++){
            chmin(ans, ((i*j)%2019));
            if(ans == 0) break;
        }
    }
    cout << ans << endl;
}

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

int main(){

    string s;
    cin >> s;
    string first = "";
    for(int i=0; i<3; i++){
        first.push_back(s[0]);
    }
    if(atoi(s.c_str()) - atoi(first.c_str()) <= 0){
        cout << first << endl;
    }else{
        int temp = (int)(s[0] - '0') + 1;
        cout << temp << temp << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf ll(1e10)
int main()
{
	int n,t,a,u,v;
	cin>>n>>t>>a;
	vector <int> adj[n+1];
	int i;
	for(i=1;i<=n-1;i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	ll bfst[n+1],bfsa[n+1],e;
	char colt[n+1],cola[n+1];
	for(i=1;i<=n;i++)
	{
		bfst[i]=inf;
		bfsa[i]=inf;
		colt[i]=cola[i]='w';
	}
	bfst[t]=0;bfsa[a]=0;colt[t]='g';cola[a]='g';
	queue <int> q;
	q.push(t);
	while(q.size())
	{
		e=q.front();
		q.pop();colt[e]='g';
		for(i=0;i<adj[e].size();i++)
		{
			v=adj[e][i];
			if(colt[v]=='w')
			{
				bfst[v]=bfst[e]+1;
				colt[v]='g';
				q.push(v);
			}
		}
	}
	q.push(a);
	while(q.size())
	{
		e=q.front();q.pop();cola[e]='g';
		for(i=0;i<adj[e].size();i++)
		{
			v=adj[e][i];
			if(cola[v]=='w')
			{
				bfsa[v]=bfsa[e]+1;
				cola[v]='g';
				q.push(v);
			}
		}
	}
	ll dis=0;
	for(i=1;i<=n;i++)
	{
		if(bfsa[i]!=inf&&bfst[i]!=inf)
		{
			if(bfsa[i]>=bfst[i])
			{
				if(bfsa[i]>dis)
				dis=bfsa[i];
			}
		}
	}
	cout<<dis-1;
	
}

Measured memory_bytes: 7680
#include <iostream>
#include <stdio.h>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<math.h>
using namespace std;



int main()
{
	double A, B, X,Y,V,Z;

	cin >> A >> B;

	X = ceil(100 * A / 8);
	Z = ceil(100 * B / 10);



	for (int i = 1;; i++) {
		Y = floor((X + i) * 0.08);

		if (Y > A) {
			Y = X + i - 1;
			break;
		}

	}
		for (int i = 1;; i++) {
			V = floor((Z + i) * 0.1);

			if (V > B) {
				V = Z + i - 1;
				break;
			}



	}
	if (Z <= Y && Z>= X) {
		cout << Z;
	}
	else {
		if (X >= Z && X <= V) {

			cout << X;
		}
		else {
			cout << "-1";
		}
	}

}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <cstdint>

int main() {
  std::int64_t X, K, D;
  std::cin >> X >> K >> D;
  X = std::abs(X);
  const auto n = std::min(K, X / D);
  X -= n * D;
  K -= n;
  std::cout << std::abs(X - D * (K & 1)) << std::endl;
  return 0;
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll f(ll x,ll day)
{
    ll res=0;
    for(int i=1;i<=day;i+=x){
        res++;
    }
    return res;
}
int main ()
{
    int N,D,X,val,res=0;
    cin >> N >> D >> X;
    for(int i=0;i<N;i++){
        cin >> val;
        res = res + f(val,D);
    }
    cout<<res+X;
    return 0;
}
/*
*/





Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        int q = in.nextInt();
        String s = in.next();
        int[] indices = new int[n];

        for (int i = 0; i < s.length() - 1; i++) {
            if (s.charAt(i) == 'A' && s.charAt(i + 1) == 'C') {
                indices[i] = 1;
            }
        }

        int[] sums = new int[n + 1];
        for (int i = 0; i < n; i++) {
            sums[i + 1] = sums[i] + indices[i];
        }

        for (int i = 0; i < q; i++) {
            int l = in.nextInt() - 1;
            int r = in.nextInt() - 1;
            int numAC = sums[r] - sums[l];
            System.out.println(numAC);
        }
    }
}


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

#define PB          push_back
#define PF          push_front
#define MP          make_pair
#define FI          first
#define SE          second
#define SIZE( A )   int( ( A ).size( ) )
#define ALL( A )    ( A ).begin( ), ( A ).end( )
#define ALLR( A )   ( A ).rbegin( ), ( A ).rend( )

using namespace std;

typedef long long           ll;
typedef unsigned long long  ull;
typedef double              lf;
typedef pair< int, int >    pii;
typedef pair< ll, ll >      pll;
typedef vector< bool >      vb;
typedef vector< lf >        vd;
typedef vector< ll >        vll;
typedef vector< int >       vi;
typedef vector< pii >       vpii;

const int MAXN = int( 1e5 )+10;
const int MOD  = int( 360 );
const int oo   = INT_MAX;

int n, cur;
int cnt[3];

int main( ) {

  #ifdef LOCAL
    freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
  #else
    //freopen( "input", "r", stdin );
    //freopen( "output", "w", stdout );
    ios_base::sync_with_stdio( 0 );
    cin.tie( 0 );
  #endif
  while( cin >> n ) {
    cnt[ 0 ] = cnt[ 1 ] = cnt[ 2 ] = 0;
    for( int i = 0; i < n; ++i ) {
      cin >> cur;
      if( cur % 4 == 0 ) ++cnt[ 0 ];
      else if( cur % 2 == 0 ) ++cnt[ 1 ];
      else ++cnt[ 2 ];
    }
    if( cnt[0]+1 == cnt[2] ) {
      cout << (cnt[1] ? "No" : "Yes") << '\n';
    }
    else if( cnt[0] < cnt[2] ) {
      cout << "No" << '\n';
    }
    else {
      cout << "Yes" << '\n';
    }
  }
  return 0;
}


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

int main() {
    int n;
    cin >> n;
    int S[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int H[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int C[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    int D[13] = {0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
    
    char pattern;
    int number;
    for (int i = 0; i < n; i++) {
        cin >> pattern >> number;
        if (pattern == 'S') {
            S[number-1] = 1;
        } else if (pattern == 'H') {
            H[number-1] = 1;
        } else if (pattern == 'C') {
            C[number-1] = 1;
        } else if (pattern == 'D') {
            D[number-1] = 1;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (S[i] == 0) {
            cout << "S" << " " << i + 1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (H[i] == 0) {
            cout << "H" << " " << i + 1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (C[i] == 0) {
            cout << "C" << " " << i + 1 << endl;
        }
    }
    for (int i = 0; i < 13; i++) {
        if (D[i] == 0) {
            cout << "D" << " " << i + 1 << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3108
#include<iostream>
#define ll long long
using namespace std;
ll int min(ll int a,ll int b){
	if(a>b)return b;
	return a;
}
ll int abs(ll int a){
	if(a>0)return a;
	return -a;
}
ll int x[300000];
int main(){
	int n,k;
	ll int sum;
	cin>>n>>k;
	int h[n+16];
	for(int i=0;i<n;i++)cin>>h[i];
	for(int i=1;i<min(k,n);i++){
		x[i]=abs(h[0]-h[i]);
	}
	for(int i=k;i<n;i++){
		sum=10000000000;
		for(int j=i-k;j<i;j++){
			sum=min(sum,x[j]+abs(h[i]-h[j]));
		}
		x[i]=sum;
	}
	cout<<x[n-1];
}/*
5 3
10 30 40 50 20

.0..1..2..3..4
*/

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#include <iomanip>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define N 1000005
#define en cout << endl
#define sp cout << " "
#define precision(x) cout << fixed << setprecision(x);
#define fio                           \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);

ll T, TT = 1, mod = (ll)(1e9 + 7), a[N], b[N], c[N], fq[N] = {0}, ali = LLONG_MAX;
ll dp[201][201][201];
void file()
{
#ifndef ONLINE_JUDGE
    freopen("i.txt", "r", stdin);
#endif
}
ll power(ll x, ll y, ll p = ali)
{
    x = x % p;
    ll res = 1;
    while (y > 0)
    {
        if (y & 1)
        {
            res = (res * x) % p;
        }
        x = (x * x) % p;
        y = y >> 1;
    }
    return res;
}

bool mycpm(ll x, ll y)
{
    if (x > y)
    {
        return 1;
    }
    return 0;
}
void dfs(vector<ll> *v, ll k, vector<ll> &wt)
{
    for (auto x : v[k])
    {
        if (wt[x] == 0)
        {
            wt[x] = 1;
            dfs(v, x, wt);
            wt[k] += wt[x];
        }
    }
}
void solve_testcase()
{
    ll n,  total_09, total_0, total_9;
    cin >> n;
    total_09 = (power(10,n,mod) - power(8,n,mod) + mod) %mod;
    total_0 = (power(9, n, mod) - power(8, n, mod) + mod) % mod;
    total_9=total_0;
    total_09 = (total_09 - total_0+mod)%mod;
    total_09 = (total_09 - total_9+mod) % mod;
    cout<<total_09;
}

int main()
{
    fio;
    file();
    //cin >> TT; //testcase
    for (T = 1; T <= TT; T++)
    {
        //cout<<"Case #"<<T<<": ";
        solve_testcase();
    }
    return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int base1 = 9973;
const int mod1 = 999999937;
const int base2 = 10007;
const int mod2 = 1000000007;

int main() {
    vector<int> power1(256); power1[0] = 1;
    for (int i = 1; i < 256; i++) power1[i] = 1LL * power1[i - 1] * base1 % mod1;
    vector<int> power2(256); power2[0] = 1;
    for (int i = 1; i < 256; i++) power2[i] = 1LL * power2[i - 1] * base2 % mod2;
    string s, t; cin >> s >> t;
    int m = s.size(), n = t.size();
    auto calc = [&](string s, vector<vector<pair<int, int>>> &ret) {
        for (int i = 0; i < s.size(); i++) {
            long long hash1 = 0, hash2 = 0;
            for (int j = i; j < s.size(); j++) {
                (hash1 += power1[s[j] - 'a']) %= mod1;
                (hash2 += power2[s[j] - 'a']) %= mod2;
                ret[j - i + 1].emplace_back(hash1, hash2);
            }
        }
    };
    vector<vector<pair<int, int>>> hs(m + 1), ht(n + 1);
    calc(s, hs);
    calc(t, ht);
    for (int len = min(m, n); len >= 1; len--) {
        sort(ht[len].begin(), ht[len].end());
        for (auto x: hs[len]) {
            auto it = lower_bound(begin(ht[len]), end(ht[len]), x);
            auto jt = upper_bound(begin(ht[len]), end(ht[len]), x);
            if (jt - it) return !(cout << len << endl);
        }
    }
    cout << 0 << endl;
    return 0;
}


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

int main(){
  int N,K;
  cin >> N >> K;
  int move_d = 0;
  for (int i=0; i<N; i++){
    int xi;
    cin >> xi;
    
    move_d += min(xi, K-xi);
  }
  cout << move_d*2;
}

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

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#ifdef _DEBUG_
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl
#else
#define dump(val)
#endif

using namespace std;

typedef long long int ll;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}
template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

template<typename T>
void chmax(T &a, T b) {
    a = max(a, b);
}

using P = pair<int, int>;
P sub(P a, P b) {
    return P(a.first - b.first, a.second - b.second);
}

int gcd(int a, int b) {
    return (b == 0 ? a : gcd(b, a % b));
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int m;
    cin >> m;
    vector<P> xy(m);
    REP(i, 0, m) {
        cin >> xy[i].first >> xy[i].second;
    }
    int ans = 0;
    vector<int> Pair(m);
    vector<bool> used(m, false);
    function<void(int)> dfs = [&](int pos) {
        if (pos == m) {
            int res = 0;
            map<P, int> mp;
            for (int i = 0; i < m; i += 2) {
                P sb = sub(xy[Pair[i]], xy[Pair[i + 1]]);
                bool sig = true;
                if (sb.first < 0) {
                    sb.first = -sb.first;
                    sb.second = -sb.second;
                }
                if (sb.second < 0) {
                    sig = false;
                    sb.second = -sb.second;
                }
                int gd = gcd(sb.first, sb.second);
                sb.first /= gd;
                sb.second /= gd;
                if (sb.first == 0) {
                    sb.second = 1;
                }
                if (sb.second == 0) {
                    sb.first = 1;
                }
                if (!sig && sb.first * sb.second != 0) {
                    sb.second = -sb.second;
                }
                mp[sb] += 1;
            }
            for (auto &e : mp) {
                res += e.second * (e.second - 1) / 2;
            }
            /*
            if (res >= 2) {
                for (auto &e : mp) {
                    cout << e.first.first << " " << e.first.second << " " << e.second << endl;
                }
            }
            */
            chmax(ans, res);
        } else {
            if (pos % 2) {
                REP(i, 0, m) {
                    if (used[i]) continue;
                    Pair[pos] = i;
                    used[i] = true;
                    dfs(pos + 1);
                    used[i] = false;
                    break;
                }
            } else {
                REP(i, 0, m) {
                    if (used[i]) continue;
                    used[i] = true;
                    Pair[pos] = i;
                    dfs(pos + 1);
                    used[i] = false;
                }
            }
        }
    };
    dfs(0);
    cout << ans << endl;
    return 0;
}



Measured memory_bytes: 3152
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cmath>
using namespace std;

using ll = long long;
using P = pair<int, int>;

const int INF = 1e9;
const int MOD = 1e9 + 7;

// 4近傍、8近傍
int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};

int main() {
  // 入力
  int N, M;
  cin >> N >> M;

  int a = 1900 * M + 100 * (N - M);

  // 解答
  cout << a * pow(2, M) << endl;

  return 0;
}


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

using namespace std;

int main()
{
	int n,x,i,c;
	c=0;
	for(i=1;i<=2;i++)
	{
		cin>>x;
		c+=x;
	}
	cin>>x;
	c=c*x/2;
	cout<<c;
	
}

Measured memory_bytes: 256