akhauriyash/Code-Regression huggingface dataset:
// type a
//a...いけそう
//b...自信がない
//c...お試し
#pragma region header
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cctype>
#include <assert.h>
#include <time.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#include <cstring>
#include <array>
// ===============================================================
//using系
#pragma region header
using namespace std;
using lint = long long;
using ld = long double;
using ulint = unsigned long long;
const int dx[] = { 1,0,-1,0 };
const int dy[] = { 0,1,0,-1 };
constexpr lint mod = 1000000007;
constexpr long double pi = 3.141592653589793238462643383279;
#pragma endregion
// ========================================================================
//define
#define INF (lint)10000000000000000;
#define mod (int)1000000007
#pragma endregion

int n, m;
vector<pair<int, int>> d;
void input() {
	cin >> n >> m;
	d.resize(m);
	for (int i = 0; i < m; i++)
		cin >> d[i].first >> d[i].second;
	return;
}

int main(void) {
	input();
	map<int, pair<int, int>> mp;
	for (int i = 0; i < n + 2; i++) mp[i] = { 1,0 };
	mp[1] = { 1,1 };
	int ans = 0;
	for (int i = 0; i < m; i++) {
		if (mp[d[i].first].second == 1) mp[d[i].second].second = 1;
		if (mp[d[i].first].first == 1) mp[d[i].first].second = 0;
		mp[d[i].first].first--;
		mp[d[i].second].first++;
	}
	for (int i = 0; i < n + 2; i++) {
		if (mp[i].second == 1) 
			ans++;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 10164
s = input()
a = int(s[:2])
b = int(s[2:])
if a>0 and a<=12 and b>0 and b<=12:
    print('AMBIGUOUS')
elif b>0 and b<=12:
    print('YYMM')
elif a>0 and a<=12:
    print('MMYY')
else:
    print('NA')

Measured memory_bytes: 3060
import math
import sys

def getinputdata():

    # 配列初期化
    array_result = []
    
    data = input()

    
    array_result.append(data.split(" "))

    flg = 1

    try:


        while flg:

            data = input()

            array_temp = []

            if(data != ""):
                
                array_result.append(data.split(" "))

                flg = 1

            else:

                flg = 0
    finally:


        return array_result





arr_data = getinputdata()

a = int(arr_data[0][0])
b = int(arr_data[0][1])
c = int(arr_data[0][2])


print("YES" if b-a == c-b else "NO")

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);++i)
#define FOR(i,n,j) for(int i=(j);i<(n);++i)
#define ssort(n) sort((n).begin(),(n).end())
#define rsort(n) sort((n).begin(),(n).end(),greater<int>())
#define mp make_pair
using ll=long long;
using ld=long double;
typedef pair<int,int> P;
typedef pair<P,int> COST;
#define repl(i,n) for(ll i=0;i<(n);++i)
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
using Graf=vector<vector<ll>>;
#define MAX 1000000007

int main()
{
    int n;double l;
    cin >> n >> l;
    vector<double> taste(n);
    rep(i,n){
        taste[i]=l+i+1-1;
    }
    double sum=0;
    rep(i,n){
        sum+=taste[i];
    }
    
    int ans_i=MAX;
    int p;
    rep(i,n){
        if(abs(taste[i]-0)<ans_i){
            p=i;
            ans_i=abs(taste[i]-0);
        }
    }
    sum-=taste[p];
    cout << sum << endl;
}

Measured memory_bytes: 3732
#include <stdio.h>

int main(void) {
	int s;
	short int a[100000];
	int j, i = 0;

	scanf("%d", &s);

	while (1) {
		if (s % 2 == 0) {
			a[i] = s;
			s = s / 2;
		}
		else {
			a[i] = s;
			s = 3 * s + 1;
		}

		for (j = 0; j <= i; j++) {
			if (a[j]==s) {
				printf("%d\n", i+2);
				return 0;
			}
		}

		i++;
	}

	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define rep2(i, s, n) for (ll i = s; i < (ll)(n); i++)
#define repr(i, n) for (ll i = n; i >= 0; i--)
#define pb push_back
#define COUT(x) cout << (x) << endl
#define COUTF(x) cout << setprecision(15) << (x) << endl
#define ENDL cout << endl
#define DF(x) x.erase(x.begin())  // 先頭文字削除
#define ALL(x) x.begin(), x.end()
#define SORT(x) sort(ALL(x))
#define REVERSE(x) reverse(ALL(x))
#define init() \
  cin.tie(0);  \
  ios::sync_with_stdio(false)
#define debug(x) cerr << "[debug] " << #x << ": " << x << endl;
#define debugV(v)                       \
  cerr << "[debugV] " << #v << ":";     \
  rep(i, v.size()) cerr << " " << v[i]; \
  cerr << endl;
using namespace std;
using ll = long long;
using ld = long double;
using vll = vector<ll>;
using P = pair<ll, ll>;
constexpr ll INF = 0x3f3f3f3f3f3f3f3f;
constexpr ld PI = 3.141592653589793238462643383279;
ll get_digit(ll x) {
  return to_string(x).size();
}

ll gcd(ll x, ll y) {
  return y ? gcd(y, x % y) : x;
}

ll lcm(ll a, ll b) {
  return a / gcd(a, b) * b;
}

vector<P> factorize(ll n) {
  vector<P> result;
  for (ll i = 2; i * i <= n; ++i) {
    if (n % i == 0) {
      result.pb({i, 0});
      while (n % i == 0) {
        n /= i;
        result.back().second++;
      }
    }
  }
  if (n != 1) {
    result.pb({n, 1});
  }
  return result;
}

vll divisor(ll n) {
  vll ret;
  for (ll i = 1; i * i <= n; i++) {
    if (n % i == 0) {
      ret.push_back(i);
      if (i * i != n) ret.push_back(n / i);
    }
  }
  SORT(ret);
  return (ret);
}

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;
}

signed main() {
  init();
  ll N;
  cin >> N;

  ll M = 0;
  ll A = 0;
  ll R = 0;
  ll C = 0;
  ll H = 0;

  rep(i, N) {
    string s;
    cin >> s;
    if (s[0] == 'M') M++;
    if (s[0] == 'A') A++;
    if (s[0] == 'R') R++;
    if (s[0] == 'C') C++;
    if (s[0] == 'H') H++;
  }

  ll ans = 0;
  ans += M * A * R;
  ans += M * A * C;
  ans += M * A * H;
  ans += M * R * C;
  ans += M * R * H;
  ans += M * C * H;
  ans += A * R * C;
  ans += A * R * H;
  ans += A * C * H;
  ans += R * C * H;
  COUT(ans);
  return 0;
}

Measured memory_bytes: 3652
#include <algorithm>
#include <iostream>
#include <vector>
#define int long long
using namespace std;

int N;
typedef pair<int, int> pint;

bool cmp(pint a, pint b) { return a.second < b.second; }

signed main() {
    cin >> N;
    vector<pint> A(N);
    int mn = 0;
    for (int i = 0; i < N; ++i) {
        int x, l;
        cin >> x >> l;
        A[i].first = x - l;
        A[i].second = x + l;
        if (x - l < mn) {
            mn = x - l;
        }
    }
    for (int i = 0; i < N; i++) {
        A[i].first -= mn;
        A[i].second -= mn;
    }
    sort(A.begin(), A.end(), cmp);
    int res = 0;
    int endtime = 0;
    for (int i = 0; i < N; ++i) {
        if (A[i].first >= endtime) {
            endtime = A[i].second;
            ++res;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 1792
h, w = list(map(int, input().split()))
s = [input() for _ in range(h)]

d = {(i, j):c for i, row in enumerate(s) for j, c in enumerate(row)}

def next_to_black(i, j):
    directions = ((-1, 0), (1, 0), (0, -1), (0, 1))
    surroundings = ((i + a, j + b) for a, b in directions)
    colors = (d.get(cell, '.') for cell in surroundings)
    return any(color == "#" for color in colors)

black_coords = (coord for coord, c in d.items() if c == "#")
paintable = all(next_to_black(*coord) for coord in black_coords)
print("Yes" if paintable else "No")


Measured memory_bytes: 3316
using System;

namespace noteCsharp
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] inputstr = Console.ReadLine().Split(char.Parse(" "));
            int c = int.Parse(inputstr[2]);
            int b = int.Parse(inputstr[1]);
            int result = 0;
            for(int a = int.Parse(inputstr[0]); a <= b; a++)
            {
                if (c % a == 0)
                {
                    result++;
                }
            }
            Console.WriteLine(result);
        }
    }
}



Measured memory_bytes: 17932
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i,s,f) for(int i=s;i<f;i++)
#define INF 1000000000000000000
#define MOD 1000000007
typedef pair<int, int> P;

template<class T>bool chmax(T& a, const T& b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T& a, const T& b) { if (b < a) { a = b; return 1; } return 0; }

bool prime(int n) {
    for (int i = 2; i <= sqrt(n); i++) {
        if (n % i == 0)return false;
    }
    return n != 1;
}
int gcd(int x, int y) {
    if (y == 0)return x;
    return gcd(y, x % y);
}
int lcm(int x, int y) {
    return x / gcd(x, y) * y;
}
int mod_pow(int n, int p, int m) {
    if (p == 0) return 1;
    if (p % 2 == 0) {
        int t = mod_pow(n, p / 2, m);
        return (t * t) % m;
    }
    return n * mod_pow(n, p - 1, m) % m;
}
int extGCD(int a, int b, int& x, int& y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    long long d = extGCD(b, a % b, y, x);
    y -= a / b * x;
    return d;
}
int modinv(int a, int m) {
    int b = m, u = 1, v = 0;
    while (b) {
        long long t = a / b;
        a -= t * b; swap(a, b);
        u -= t * v; swap(u, v);
    }
    u %= m;
    if (u < 0) u += m;
    return u;
}
int digit(int x) {
    int cnt = 0;
    while (x > 0) {
        cnt += x % 10;
        x /= 10;
    }
    return cnt;
}
int read() {
    int tmp;
    cin >> tmp;
    return tmp;
}
int xor128() {
    static int x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    int t = (x xor (x << 11));
    x = y; y = z; z = w;
    return (w = (w xor (w >> 19)) xor (t xor (t >> 8)));
}
map<int, int> factaring(int x) {
    map<int, int>ans;
    int now = 2;
    while (now * now <= x) {
        if (x % now == 0) {
            x /= now;
            ans[now]++;
        }
        else now++;
    }
    if (x != 1) ans[x]++;
    return ans;
}
int comb(int n, int k) {
    k = min(k, n - k);
    int x = 1, y = 1;
    rep(i, k) {
        y *= i + 1;
        y %= MOD;
    }
    for (int i = n - k + 1; i <= n; i++) {
        x *= i;
        x %= MOD;
    }
    return x * modinv(y, MOD) % MOD;
}

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

    string s;
    cin >> s;
    rep(i, 3) {
        if (s[i] == '7') {
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<stdio.h>
#include<math.h>
int main ()
{
  int c,a,b,cosB,sinB,s;
  
  scanf("%d",&c);
  scanf("%d",&a);
  scanf("%d",&b);
  cosB=(a*a+c*c-b*b)/2*a*c;
  sinB=sqrt(1-cosB*cosB);
  s=(a*c*sinB)/2;
  printf("%d",s);
}

Measured memory_bytes: 128
#include <iostream>      // cout, endl, cin
#include <string>        // string, to_string, stoi
#include <vector>        // vector
#include <algorithm>     // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility>       // pair, make_pair
#include <tuple>         // tuple, make_tuple
#include <cstdint>       // int64_t, int*_t
#include <cstdio>        // printf
#include <map>           // map
#include <queue>         // queue, priority_queue
#include <set>           // set
#include <stack>         // stack
#include <deque>         // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset>        // bitset
#include <cctype>        // isupper, islower, isdigit, toupper, tolower

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

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

int main()
{
        int N;
        cin >> N;
        vector<int> vec(N + 1);
        rep(i, N) cin >> vec[i];
        int cnt, ans = 1000;
        rep(i, N)
        {
                cnt = 0;
                while (vec[i] % 2 == 0)
                {
                        cnt++;
                        vec[i] /= 2;
                }
                ans = min(cnt, ans);
        }
        cout << ans << endl;

        return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
    public static void main(String[] args) {
        try {
            // 標準入力
            InputStreamReader isr = new InputStreamReader(System.in);
            BufferedReader br = new BufferedReader(isr);
            int n = Integer.parseInt(br.readLine());
            String str1[] = br.readLine().split(" ");
            int arr1[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr1[i] = Integer.parseInt(str1[i]);
            }
            String str2[] = br.readLine().split(" ");
            int arr2[] = new int[n];
            for (int i = 0; i < n; i++) {
                arr2[i] = Integer.parseInt(str2[i]);
            }
            int arr[] = new int[n];
            int index = 0;
            int temp = 0;
            for (int i = 0; i < n; i++) {
                temp += arr1[i];
                arr[index++] = temp + getTotal(arr2, i);
            }
            int max = arr[0];
            for (int i = 1; i < n; i++) {
                if (max < arr[i]) {
                    max = arr[i];
                }
            }
            System.out.println(max);
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    public static int getTotal(int arr[], int tmp) {
        int sum = 0;
        for (int i = tmp; i < arr.length; i++) {
            sum += arr[i];
        }
        return sum;
    }

}


Measured memory_bytes: 23124
def max_heapify(A, i):
    l = 2 * i
    r = 2 * i + 1
    largest = i
    if l < len(A) and A[l] > A[i]:
        largest = l
    else:
        largest = i
    if r < len(A) and A[r] > A[largest]:
        largest = r

    if largest != i:
        temp = A[i]
        A[i] = A[largest]
        A[largest] = temp
        max_heapify(A, largest)


def build_maxheap(A):
    i = len(A) // 2
    while i >= 1:
        max_heapify(A, i)
        i -= 1


if __name__ == '__main__':
    # ??????????????\???
    num_of_data = int(input())
    A = [int(x) for x in input().split(' ')]
    A.insert(0, 0) # ?????????1??????????????????????????????????????????

    # ???????????????
    build_maxheap(A)
    A = A[1:]  # ???????????????????????????

    # ???????????????
    print(' {0}'.format(' '.join(map(str, A))))

Measured memory_bytes: 65924
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int k = sc.nextInt();
        int x = sc.nextInt();
        sc.close();

        if (500 * k >= x) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 21716
s = gets.to_i

n = 0
step = 1
digit = 1
stack = []
start = 0

loop {
	over = false
	(start..9).each{|k|
		f = -> d {(n + step) / d - n / d}
		addition = digit * (step - f[3] - f[5] + f[15]) + 4 * (f[3] + f[5]) 
		
		if s <= addition
			stack << k
			over = true
			start = 0
			break
		else
			s -= addition
			n += step
			start = 1
		end
	}
	
	if over
		step /= 10
		break if step == 0
	else
		step *= 10
		digit += 1
	end
}

x = stack.join.to_i + 1
str = ""
loop {
	str += 
		x % 15 == 0 ? "FizzBuzz" :
		x % 3 == 0 ? "Fizz" :
		x % 5 == 0 ? "Buzz" :
		x.to_s
	break if str.size - s >=  20
	x += 1
}

puts str[s-1..s+18]

Measured memory_bytes: 6124
#include<bits/stdc++.h>
#define lli long long int
#define pb push_back

using namespace std;


int main() {
    lli n,temp;
    cin>>n;
    map<lli,lli> m;
    map<lli,lli>:: iterator k;
    for(int i=0;i<n;i++){
    	cin>>temp;
    	m[temp] = 1-m[temp];
	}
	lli ans = 0;
	for(k=m.begin();k!=m.end();k++){
		ans += k->second;
	}
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 6528
#include <iostream>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>


using namespace std;
const int maxn = 105;
const int inf = 0x3f3f3f3f;
typedef long long ll;


int main() {
#ifdef AZUKI_LOCAL
    freopen("../input.txt", "r", stdin);
    //freopen("../output.txt", "w", stdout);
#endif
    int n, m;
    ll k;
    while (cin >> n >> m >> k) {
        vector<ll> a(n), b(m), sum_a, sum_b;
        for (int i = 0; i < n; ++i) {
            cin >> a[i];
        }
        for (int i = 0; i < m; ++i) {
            cin >> b[i];
        }
        int ans = 0;
        sum_a.push_back(0);
        sum_b.push_back(0);
        for (int i = 0; i < n; ++i) {
            if (sum_a[i] > k) break;
            sum_a.push_back(sum_a[i] + a[i]);
        }
        for (int i = 0; i < m; ++i) {
            if (sum_b[i] > k) break;
            sum_b.push_back(sum_b[i] + b[i]);
        }
        int j = (int) sum_b.size() - 1;
        for (int i = 0; i < sum_a.size(); ++i) {
            if (sum_a[i] > k) break;
            while (sum_b[j] + sum_a[i] > k) {
                --j;
            }
            ans = max(ans, i + j);
        }
        cout << ans << endl;
    }

    return 0;
}


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

int main() {
  int count =0;
  int N;
  int ko=1;
  cin>>N;
  vector<int>A(N);
  rep(i,N){
    cin>>A[i];
  }
  rep(i,N){
    if(ko!=A[i]){
      count++;
    }
    else{
      ko++;
    }
  }
  if(count==N){
    cout<<-1;
    return 0;
  }
  cout<<count;
}


Measured memory_bytes: 1024
#include<iostream>
using namespace std;
int main()
{
    int a,b,c;
    int f;
    int d;
    cin>>a>>b>>c;
    f=a-b;
    d=c-f;
    if(d<0)
    {
        cout<<0;
    }
    else
    {
       cout<<d;
    }




    return 0;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,N) for(int i=0;i<(N);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
using namespace std;
typedef long long ll;
int main(){
    cout << fixed << setprecision(10);
    string s;
    cin >> s;
    reverse(s.begin(),s.end());
    int x = 1, tot = 0;
    vector<int> cnt(2019);
    ll ans = 0;
    rep(i,s.size()){
        cnt[tot] ++;
        tot += (s[i] - '0') * x;
        tot %= 2019;
        ans += cnt[tot];
        x = x*10%2019;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3760
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC target("avx")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define rrep(i,n) for(int (i)=1;i<=(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define MOD 1000000007
#define INF 1e18
#define int long long
#define endl "\n"
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
typedef long long ll;
typedef pair<int, int> P;
int gcd(int a,int b){return b?gcd(b,a%b):a;};
int lcm(int a,int b){return a/gcd(a,b)*b;};
int mod(int a,int b){return (a+b-1)/b;};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
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;};

int dp[220][220];

signed main() {
	cin.tie(0);
	cout.tie(0);
	ios::sync_with_stdio(false);
	//cout << fixed << setprecision(15);
	
	int D, N;
	cin >> D >> N;
	int t[D], a[N], b[N], c[N];
	rep(i, D) cin >> t[i];
	rep(i, N) cin >> a[i] >> b[i] >> c[i];

	rep(i, D - 1) {
		int tmp = t[i];
		int ntmp = t[i + 1];
		rep(j, N) {
			if(tmp < a[j] || b[j] < tmp) continue;
			rep(k, N) {
				if(a[k] <= ntmp && ntmp <= b[k]) {
					chmax(dp[i+1][k], dp[i][j] + abs(c[j] - c[k]));
				}
			}
		}
	}

	int ans = 0;
	rep(i, N) {
		chmax(ans, dp[D - 1][i]);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3416
n = []
while (True):
	x = list(input().split())
	if x[1] == '?':
		break
	elif x[1] == '+':
		n.append(int(x[0]) + int(x[2]))
		pass
	elif x[1] == '-':
		n.append(int(x[0]) - int(x[2]))
		pass
	elif x[1] == '*':
		n.append(int(x[0]) * int(x[2]))
		pass
	elif x[1] == '/':
		n.append(int(x[0]) / int(x[2]))
		pass
for i in n:
	print(int(i))

Measured memory_bytes: 7676
#include <stdio.h>
int main(void){
    int a,b,c;
    int tmp;
    scanf("%d %d %d",&a,&b,&c);
    if(a>b){
        //a b koukan
        tmp=a;
        a=b;
        b=tmp;
    }
    if(b>c){
        tmp=b;
        b=c;
        c=tmp;
    }
    if(a>b){
        tmp=a;
        a=b;
        b=tmp;
    }
    printf("%d %d %d\n",a,b,c);
    return 0;
}


Measured memory_bytes: 2700
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
using namespace std;

typedef long long ll;

set < long long > lunlun;

void solve(ll x, int i){

	if(x > 3234566667)	return;

	if(lunlun.size() > 100000)	return;

	lunlun.insert(x);

	ll _x = x * 10 + i;
//	cout << x << " " << _x << endl;

	solve(_x, i);

	if(i < 9) {
		_x = (x * 10) + (i+1);
//		cout << x << " " << _x << " " << i << endl;
		solve(_x, i+1);
	}

	if(i > 0) {
		_x = (x * 10) + (i-1);
//		cout << x << " " << _x << " " << i << endl;
		solve(_x, i-1);
	}
}

int main(){

	for(ll i = 1; i <= 9; ++i) {

		solve(i,(int)i);
	}

//	sort(lunlun.begin() , lunlun.end(), [&](ll const &a, ll const &b) {return a < b; });

//	cout << lunlun.size() << endl;

	vector < ll > res;
	
	for(set < ll > :: iterator it = lunlun.begin(); it != lunlun.end(); ++it) {
		res.push_back(*it);
	}

//	for(int i = 0; i < 100; ++i)
//		cout << res[i]<< " ";
//	cout << endl;
	int k;

	cin >> k;

	cout << res[k-1] << endl;

	return 0;
}

Measured memory_bytes: 6136
#include <stdio.h>
 
int main(void) {
    int a;
    int b;
    int c;
    scanf("%d%d%d",&a,&b,&c);
    //a,b,c?????????????????¨??¨??§3!=6??????????????§??????????????¨??¨????????°??????
    if(a<=b&&b<=c) printf("%d %d %d\n",a,b,c);
    else if(a<=c&&c<=b) printf("%d %d %d\n",a,c,b);
    else if(b<=a&&a<=c) printf("%d %d %d\n",b,a,c);
    else if(b<=c&&c<=a) printf("%d %d %d\n",b,c,a);
    else if(c<=a&&a<=b) printf("%d %d %d\n",c,a,b);
    else if(c<=b&&b<=a) printf("%d %d %d\n",c,b,a);
    /*
    // ??\?§£
    // ??\??????????????§???????????£????????????????????????????????°?????????
    // ?????????????????§???????????????????????§????????????????????????
    int a[3];
    int i,j;
    int t;
    for(i=0;i<3;i++){
    	scanf("%d",&a[i]);
    }
    // j????????????????????????????????????????????´??????????????§????´?????¢???????????????????
    for(i=0;i<3;i++){
    	for(j=0;j+1<3-i;j++){
    		if(a[j]>a[j+1]){
				t=a[j];
				a[j]=a[j+1];
				a[j+1]=t;			
    		}
    	}
    }
    printf("%d %d %d\n",a[0],a[1],a[2]);
    // ?????????????????\?§£
    // ???????????°???????????§?????¨????°??????¨????¨?????±??????????
    // ?±???????????????? a1 a2 a3 ??¨????????¨???
    // a1=????°????
    // a2=????¨?-?????§???-????°????
    // a3=?????§???
    // ??¨?????????
    // ????°????????????§???????±?????????´??????if???????????£????±??????????????????????
    // math.h???include????????°fmin(),fmax()??¨????????¢??°???????????????
    
    // #include <stdio.h>
	// #include <math.h> <- ????????????????????????

    int a,b,c;
    int MIN=1000,MAX=-1000,SUM=0;
    scanf("%d %d %d",&a,&b,&c);
	MIN=fmin(MIN,a);
	MIN=fmin(MIN,b);
	MIN=fmin(MIN,c);
	MAX=fmax(MAX,a);
	MAX=fmax(MAX,b);
	MAX=fmax(MAX,c);
	SUM=a+b+c;
	printf("%d %d %d\n",MIN,SUM-MAX-MIN,MAX);
	*/
    return 0;
}

Measured memory_bytes: 596
import bisect
import collections
import functools
import heapq
import math
import sys
from collections import deque
from collections import defaultdict
input = sys.stdin.readline
MOD = 10**9+7

N,M = map(int,(input().split()))
dp = [float("inf")]*(2**N)
dp[0] = 0
for i in range(M):
    a,b = map(int,(input().split()))
    c = list(map(int,(input().split())))
    d = 0
    for j in c:
        d += 2**(j-1)
    for j in range(2**N):
        dp[j|d] = min(dp[j|d],dp[j]+a)

ans = dp[-1]
if ans != float("inf"):
    print(ans)
else:
    print(-1)

Measured memory_bytes: 44252
#include<bits/stdc++.h>
using namespace std;
const int INF=1e9;
int main(){
  int n,m;cin >> n >> m;
  vector<int> a(m);
  vector<int> c(m);
  for(int i=0;i<m;i++){
    int b;cin >> a[i] >> b;
    for(int j=0;j<b;j++){
      int t;cin >> t;
      t--;
      c[i]+=(1<<t);
    }
  }
  vector<int> dp(1<<n,INF);
  dp[0]=0;
  for(int i=0;i<m;i++){
    for(int j=0;j<(1<<n);j++){
      dp[j|c[i]]=min(dp[j|c[i]],dp[j]+a[i]);
    }
  }
  if(dp[(1<<n)-1]>=INF){
    cout << -1 << endl;
  }
  else{
    cout << dp[(1<<n)-1] << endl;
  }
}

Measured memory_bytes: 256
program main
	integer*4 n, a(1:200010), b(1:200010)
	read *, n
	read *,(a(i),i=1,n)
	do i = 1, n/2
		b(i) = a(n-i*2+2)
		b(n-i+1) = a(n-i*2+1)
	end do
	if (mod(n,2) .eq. 1) b(n/2+1) = a(1)
	write(6,*) (b(i),i = 1,n)
	end

Measured memory_bytes: 5248
#include <bits/stdc++.h>  // g++ -std=c++14 -o a a.cpp

using namespace std;

typedef pair<int, int> P;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define repto(i, n) for(int i = 0; i <= (n); i++)
#define all(c) (c).begin(), (c).end()
#define uniq(c) c.erase(unique(all(c)), (c).end()) // ユニークなvectorにする。連続した値を除去して切り出す。
#define _1 first
#define _2 second
#define pb push_back
#define INF 1145141919
#define MOD 1000000007
#define DEBUG(x) cout << #x << ": " << x << endl;

__attribute__((constructor))
void initial() {
  cin.tie(0);
  ios::sync_with_stdio(false);
}

int E[2001][2001] = {{0}};
int T[2001] = {0};
const int TAKEN = 1;

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

  rep(i, N) {
    rep(j, N) {
      int w;
      cin >> w;
      if (w == -1) {
         E[i][j] = INF;
      } else {
         E[i][j] = w;
      }
      // DEBUG(E[i][j]);
	}
  }

  T[0] = TAKEN;
  int count = 1;
  int sum = 0;

  while (count < N) {
    int minW = INF;
    int minI = -1;
    int minJ = -1;
    rep(i, N) {
       if (T[i] == TAKEN) {
          rep(j, N) {
			if(T[j] != TAKEN) {
              int w = E[i][j];
              if (w < minW) {
//                DEBUG(i);
//                DEBUG(j);
//                DEBUG(w);
                minW = w;
                minI = i;
                minJ = j;
              }
			}
          }
       }
    }
//    DEBUG("--------------------");
//    DEBUG(minI);
//    DEBUG(minJ);
//    DEBUG(minW);

	T[minJ] = TAKEN;
//	rep (i , N) {
//		DEBUG(i);
//		DEBUG(T[i]);
//	}

	count++;
	sum += minW;
  }

  cout << sum << endl;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for (ll i = a; i < b; i++)
#define REP(i,b) FOR(i,0,b)
#define RFOR(i,a,b) for (ll i = a-1; i >= b; i--)
#define RREP(i,a) RFOR(i,a,0)
#define REPALL(i,x) for (ll i = 0; i < x.size(); i++)
#define RREPALL(i,x) for (ll i = x.size()-1; i >= 0; i--)
#define REPITR(itr,x) for (auto itr = (x).begin(); itr != (x).end(); itr++)
#define ALL(x) (x).begin(), (x).end()
#define SORT(x) sort(ALL(x))
#define MIN_ELEMENT(x) min_element(ALL(x))
#define MAX_ELEMENT(x) max_element(ALL(x))
#define COUNT(x,num) count(ALL(x), num)
#define MEMSET(x,val) memset(x, val, sizeof(x))
#define MAX(a,b) a = max(a,b)
#define MIN(a,b) a = min(a,b)
#define debug(x) cerr<<__LINE__<<": "<<(#x)<<" = "<<(x)<<endl;
void YES(bool flag) {cout<<(flag ? "YES" : "NO")<<endl;}
void Yes(bool flag) {cout<<(flag ? "Yes" : "No")<<endl;}
void yes(bool flag) {cout<<(flag ? "yes" : "no")<<endl;}
#define e1 first
#define e2 second
#define nextline putchar('\n')
typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> VI;
typedef vector<vector<int>> VVI;
typedef vector<ll> VLL;
typedef vector<vector<ll>> VVLL;
const int INF = 1e7;
const ll MOD = 1e9 + 7;

int A, B, M;
int min_a = INF, min_b = INF, ans;
VI a, b, c;

int main()
{
    cin>>A>>B>>M;
    a.resize(A);
    b.resize(B);
    REP(i,A) {
        cin>>a[i];
        MIN(min_a, a[i]);
    }
    REP(i,B) {
        cin>>b[i];
        MIN(min_b, b[i]);
    }
    ans = min_a + min_b;
    REP(i,M) {
        int x, y, c;
        cin>>x>>y>>c;
        MIN(ans, a[x-1] + b[y-1] - c);
    }
    cout<<ans<<endl;

    return 0;
}


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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

ll modpow(ll x, ll n, ll mod = MOD) {
    ll res = 1;
    while (n > 0) {
        if (n & 1) res = res * x % mod;
        x = x * x % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<ll> a(n);
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    if (a[0] != 0) {
        cout << 0 << endl;
        return 0;
    }

    ll ans = 0;
    vector<int> cnt(n, 0);
    int hoge = 3;
    ans = hoge--;
    cnt[a[0]]++;
    for (int i = 1; i < n; i++) {
        if (a[i] == 0) {
            (ans *= hoge--) %= MOD;
        } else {
            (ans *= cnt[a[i] - 1]--) %= MOD;
        }
        cnt[a[i]]++;
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
using namespace std;
int A[200005];
int main(){
  int N,M;
  cin>>N;
  for(int i=1; i<N; i++){
    int t;
    cin>>t;
    A[t-1]++;
  }
  for(int i=0; i<N; i++) cout<<A[i]<<endl;
  return 0;
}


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

int main() {

	int n, c; cin >> n >> c;
	const int T = 100005;
	vector<int> accum(T, 0);
	map<pair<int, int>, bool> mp;
	for (int i = 0; i < n; i++) {
		int s, t, c; cin >> s >> t >> c;
		if (mp[{s, c}]) {
			accum[s + 1]++;
		}
		else {
			accum[s]++;
		}
		if (mp[{t, c}]) {
			accum[t]--;
		}
		else {
			accum[t + 1]--;
		}
		mp[{s, c}] = true;
		mp[{t, c}] = true;
	}
	for (int i = 1; i < T; i++) {
		accum[i] += accum[i - 1];
	}
	int ans = *max_element(accum.begin(), accum.end());
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 16172
n = int(input())
f = [list(map(int, input().split())) for i in range(n)]
p = [list(map(int, input().split())) for i in range(n)]

ans = 0
for j in range(n):
    ans += p[j][f[j][0] & 1]
for i in range(2, 1024):
  bene = 0
  for j in range(n):
    count = 0
    for k in range(10):
      count += f[j][k] & (i >> k)
    bene += p[j][count]
  ans = max(ans, bene)
print(ans)

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

int H, W, K;
int res = 0;
vector<vector<char>> C(7, vector<char>(7));
vector<vector<char>> tmp(7, vector<char>(7));

int main(){
    cin >> H >> W >> K;
    for(int i = 1; i <= H; i++){
        for(int j = 1; j <= W; j++){
            cin >> C[i][j];
            tmp[i][j] = C[i][j];
        }
    }

    for(int i = 0; i < pow(2, H); i++){
        for(int j = 0; j < pow(2, W); j++){
            int cn = 0;
            for(int s = 0; s < H; s++){
                if((i >> s) & 1){
                    for(int k = 1; k <= W; k++) tmp[s+1][k] = '.';
                }
            }
            for(int s = 0; s < W; s++){
                if((j >> s) & 1){
                    for(int k = 1; k <= H; k++) tmp[k][s+1] = '.';
                }
            }
            for(int x = 1; x <= H; x++){
                for(int y = 1; y <= W; y++){
                    if(tmp[x][y] == '#') ++cn;
                    tmp[x][y] = C[x][y];
                }
            }
            if(cn == K) ++res;
        }
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 3984
#include<iostream>
#include<string>
#include<algorithm>    
#include<cmath>
#include<map>
#include<vector>
#include<math.h>
#include<stdio.h>
#include<queue>
#define int long long
#define mod (int)(1000000007)
using namespace std;
int test[123456];
signed main() {
	int n, m, a, b = 0, ans = 0; cin >> n >> m;
	cout << (n + m - 1) / m << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cmath>
#include<cstdio>
using namespace std;
const float cos60=0.5;
const float sin60=sqrt(3.0)*0.5;
void func(int N,float x1,float y1,float x2,float y2){
	float x[5];
	float y[5];
	x[0]=x1;
	y[0]=y1;
	x[4]=x2;
	y[4]=y2;
	x[1]=(x1*2+x2)/3;
	y[1]=(y1*2+y2)/3;
	x[3]=(x1+x2*2)/3;
	y[3]=(y1+y2*2)/3;
	x[2]= x[1] + (x[3]-x[1]) * cos60 - (y[3]-y[1])*sin60;
	y[2]= y[1] + (x[3]-x[1]) * sin60 + (y[3]-y[1])*cos60;
	if(N==1){
		for(int i=0;i<4;++i){
			printf("%.7f %.7f\n",x[i],y[i]);
		}
	}else{
		for(int i=0;i<4;++i){
			func(N-1,x[i],y[i],x[i+1],y[i+1]);
		}
	} 
}
int main(){
	int N;
	cin>>N;
	if(N>0){
		func(N,0,0,100,0);
	}else{
		printf("0.0000000 0.0000000\n");
	}
	printf("100.0000000 0.0000000\n");
	return 0;
}


Measured memory_bytes: 3200
#include "bits/stdc++.h"
using namespace std;

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define LL long long

int h,w,k;
LL mod = 1000000007;
LL dp[101][9];

int comb[8] = {1,2,3,5,8,13,21,34};

int main(){
  cin>>h>>w>>k;
  if(w==1){
    cout<<1<<endl;
    return 0;
  }
  //cerr<<h<<" "<<w<<" "<<k<<endl;
  REP(i,101){
    REP(j,w+1){
      dp[i][j]=0;
    }
  }
  //cerr<<h<<" "<<w<<" "<<k<<endl;

  dp[1][1] = comb[w-2];
  dp[1][2] = comb[max(0,w-3)];
  //cerr<<h<<" "<<w<<" "<<k<<endl;
  FOR(i,2,h+1){
    FOR(j,1,w+1){
      dp[i][j] = dp[i-1][j] * comb[max(0,j-2)] * comb[max(0,w-j-1)] % mod;
      if(j > 1){
	dp[i][j] += dp[i-1][j-1] * comb[max(0,j-3)] * comb[max(0,w-j-1)] % mod;
      }
      if(j < w){
	dp[i][j] += dp[i-1][j+1] * comb[max(0,j-2)] * comb[max(0,w-j-2)] % mod;
      }
      dp[i][j] %= mod;
    }
  }

  cout<<dp[h][k]%mod<<endl;
  return 0;
}



Measured memory_bytes: 256
n,m,x=map(int,input().split())
d=[]
for i in range(n):
    s=list(map(int,input().split()))
    d.append(s)
ans=float("inf")
for i in range(2**n):
    string=format(i,"0%ib"%(n))
    c=0
    data=[0 for _ in range(m+1)]
    for k in range(n):
        if string[k]=="1":
            for j in range(1,m+1):
                data[j]+=d[k][j]
            c+=d[k][0]
    if all(data[j]>=x for j in range(1,m+1)):
        ans=min(ans,c)
if ans!=float("inf"):
    print(ans)
else:
    print(-1)
    

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

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

int main()
{
  int X, Y; cin >> X >> Y;
  int z = Y - X*2;
  if( z%2 == 0 && 0 <= z/2 && z/2 <= X  )
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 3668
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,m,v,p,s,mx,c,r,b,a[100005];
signed main()
{
	scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
	for(int i=1;i<=n;i++) scanf("%lld",a+i);
	sort(a+1,a+n+1),c=a[n-p+1],b=0,r=p,v=n-v,s=0,mx=0;
	for(int i=n;i>=1;i--) if(a[i]<c) break;else b++;
	for(int i=n-p;i>=1;i--)
	{
		s+=(a[i+1]-a[i])*(n-p+1-i);
		if(s<=min(n-p,v)*m&&a[n-p+1]-a[i]<=m) r++;else break;
	}
	return printf("%lld\n",r),0;
}//ZKAKIOI

Measured memory_bytes: 4576
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>

using namespace std;
//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;

int main() {
	int n, i;
	cin >> n >> i;
	cout << n - i + 1 << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 2147483647;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
struct RMQ{
  vector<int> data;
  int N;
  RMQ(int n){
    N = 1;
    while(N < n) N *= 2;
    data = vector<int>(2 * N, INF);
  }
  void update(int k, int x){
    k += N - 1;
    data[k] = x;
    while(k > 0){
      k = (k - 1) / 2;
      data[k] = min(data[2 * k + 1], data[2 * k + 2]);
    }
  }
  int query(int a, int b){
    return query(a, b, 0, 0, N);
  }
  inline int query(int a, int b, int k, int l, int r){
    if(b <= l || r <= a) return INF;
    else if(a <= l && r <= b){
      return data[k];
    }else{
      return min(query(a, b, 2 * k + 1, l, (l + r) / 2), query(a, b, 2 * k + 2, (l + r) / 2, r));
    }
  }
};

int main(){
  int H, W, Q;
  while(cin>>H>>W>>Q && H){
    if(H < W){
      //HlogW * Q = 10^7log10^3
      vector<RMQ> rmq(H, RMQ(W));
      REP(y, H){
        REP(x, W){
          int t; scanf("%d", &t);
          rmq[y].update(x, t);
        }
      }
      REP(i, Q){
        int y1, x1, y2, x2;
        scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
        int res = INF;
        for(int y = y1; y <= y2; y++){
          res = min(res, rmq[y].query(x1, x2 + 1));
        }
        printf("%d\n", res);
      }
    }else{
      //WlogH * Q
      vector<RMQ> rmq(W, RMQ(H));
      REP(y, H){
        REP(x, W){
          int t; scanf("%d", &t);
          rmq[x].update(y, t);
        }
      }
      REP(i, Q){
        int y1, x1, y2, x2;
        scanf("%d %d %d %d", &y1, &x1, &y2, &x2);
        int res = INF;
        for(int x = x1; x <= x2; x++){
          res = min(res, rmq[x].query(y1, y2 + 1));
        }
        printf("%d\n", res);
      }
    }
  }
  return 0;
}

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

typedef pair <int, int> ii;

const int Maxn = 100005;
const int Maxd = 3;
const int Inf = 1000000000;

int n, m;
vector <int> neigh[Maxn];
int dist[Maxn][Maxd];
int s, t;
queue <ii> Q;

int main()
{
    scanf("%d %d", &n, &m);
    for (int i = 0; i < m; i++) {
        int a, b; scanf("%d %d", &a, &b);
        neigh[a].push_back(b);
    }
    fill((int*)dist, (int*)dist + Maxn * Maxd, Inf);
    scanf("%d %d", &s, &t);
    dist[s][0] = 0;
    Q.push(ii(s, 0));
    while (!Q.empty()) {
        ii v = Q.front(); Q.pop();
        int d = dist[v.first][v.second];
        if (v == ii(t, 0)) { printf("%d\n", d / Maxd); return 0; }
        for (int i = 0; i < neigh[v.first].size(); i++) {
            ii u = ii(neigh[v.first][i], (v.second + 1) % Maxd);
            if (d + 1 < dist[u.first][u.second]) {
                dist[u.first][u.second] = d + 1;
                Q.push(u);
            }
        }
    }
    printf("-1\n");
    return 0;
}


Measured memory_bytes: 6912
#include<bits/stdc++.h>
using namespace std;
int main(){
	int N;
	cin>>N;
	int ans=0;
	for(int i=1;i<=N;i++){
		int tmp=0;
		int base=i;
		while(base){
			tmp++;
			base/=10;
		}
		if(tmp&1)
			ans++;
	}	
	cout<<ans<<endl;
	return 0;
}

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

int main(){
  int n;
  cin >> n;
  int tmp;
  int ans=0;
  for(int i=0;i<n;i++){
    cin >> tmp;
    if(tmp!=i+1){ans++;}
  }
  if(ans == 0 || ans == 2){
    cout << "YES" << endl;
  }
  else{
    cout << "NO" << endl;
  }
  return 0;
}


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

using namespace std;
#define sd(x) scanf("%d", &x);
#define sdl(x) scanf("%lld", &x);
#define pr(x) printf("%d\n", x);
#define prl(x) printf("%lld\n", x);

long long int mod = 1000000007;

long long int gcd(long long int a, long long int b)
{
    if (b < a)
        return gcd(b, a);
    else if (b % a == 0)
        return a;
    else
        return gcd(b % a, a);
}

long long fast_exp(long long a, long long n, long long mod1)
{

    if (n == 0)
        return 1;
    else if (n == 1)
        return a;
    if (n % 2 == 0)
        return fast_exp((a * a) % mod1, n / 2, mod1);
    else
        return (a * fast_exp((a * a) % mod1, n / 2, mod1)) % mod1;
}
bool is_square(long long a)
{
    long long int b = sqrt(a);
    if (b * b == a)
        return true;
    else
        return false;
}
long long n_fact[1000001];
void calc_fact(int n) // calculates the factorial % mod and stores in n_fact upto n
{
    n_fact[0] = 1;
    for (int c(1); c <= n; c++)
        n_fact[c] = (c * n_fact[c - 1]) % mod;
    return;
}
long long calc_inverse_mod(long long x, long long mod)
{
    return fast_exp(x, mod - 2, mod);
}
bool n_primes[100001] = {false};
void calc_primes(int n)
{
    for (int c(2); c <= 100000; c++)
    {
        if (n_primes[c] == true)
            continue;
        for (int c1(c + c); c1 <= 100000; c1 = c1 + c)
            n_primes[c1] = true;
    }
    return;
}
bool is_palindrome(string a)
{
    string b = a;
    reverse(b.begin(), b.end());
    if (b == a)
        return true;
    else
        return false;
}


double dp[100000];
int done[100000];
unordered_map<int,vector<int>>graph;

void dfs(int i,int prev)
{
   
    if (done[i]!=0)
        return;
    double e=0;
    done[i]=1;
    int siz=0;
    for (int c=0;c<graph[i].size();c++)
        {
            if (graph[i][c]==prev)
                continue;
            dfs(graph[i][c],i);
            e+=1+dp[graph[i][c]];
            siz++;
        }
      
      
        dp[i]=e/max(1,siz);
    return ;

}
int main()
{

    ios_base::sync_with_stdio(false);
    int t;
    t = 1;

    for (int tt = 0; tt < t; tt++)
    {
       int k,n;
       cin >> k >> n;
       vector<int>arr;
       for (int c=0;c<n;c++)
        {
            int a;
            cin >> a;
            arr.push_back(a);
        }
        int mini = k;
        for (int c=0;c<n;c++)
        {
            if (c==0)
                mini=min(mini,arr[n-1]-arr[0]);
            else
                mini=min(mini,k-arr[c]+arr[c-1]);
            
        }
        cout  << mini << endl;
    }
    return 0;
}


Measured memory_bytes: 1400
#include<bits/stdc++.h>
using namespace std;
char C[500500];
int L=200000,R=200002;
int main()
{
   scanf("%s",C+200001);
  while(C[R])
    R++;
   int T,tmp=0;
   cin>>T;
  while(T--)
  {
    int A;
    cin>>A;
    if(A==1)
      tmp^=1;
    else
    {
      int B;
      cin>>B;
      B--;
      B^=tmp;
      if(B==0)
      {
        cin>>C[L];
        L--;
      }
      else
      {
        cin>>C[R];
        R++;
      }
    }
  }
  if(tmp)
    for(int i=R-1;i>L;i--)
      cout<<C[i];
  else
  	for(int i=L+1;i<R;i++)
      cout<<C[i];
  return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
/*
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
#include<stack>
#include<cassert>
#include<functional>
*/
#define int long long int
#define double long double
using namespace std;
#define INT_DMAX 1000000007
#define INF 1000000000000000007
const int MAX_N = 1 << 17;
#define rep(i,n) for(int (i)=0, i##_len = (n);(i)<i##_len;(i)++)
#define reps(i,x) for(int (i)=1;(i)<=(int)(x);(i)++)
#define rrep(i,x) for(int (i)=((int)(x)-1);(i)>=0;(i)--)
#define rreps(i,x) for(int (i)=((int)(x));(i)>0;(i)--)
#define FOR(i,a,b) for (int (i) = (a); (i) < (b); (i)++)
#define pb push_back
#define mp make_pair
#define bit(n) ((int)(1)<<(n))
#define all(x) (x).begin(),(x).end()
#define debug(x) std::cout << #x << ": " << (x) << std::endl 
#define nint int
using namespace std;

int dy[]={0, 0, 1, -1, 0};
int dx[]={1, -1, 0, 0, 0};
typedef pair<int,int> p;
typedef pair<double,double> dop;
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
int gcd(int a,int b){return b?gcd(b,a%b):a;}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);
    };
}aaaaaaa;


signed main()
{
int n;
std::cin >> n;
std::vector<int> s(n,0);
int sum = 0;
rep(i,n){
    int temp;
    std::cin >> temp;
    s[i] = temp;
    sum += temp;
}
std::sort(s.begin(),s.end());
if(sum % 10 == 0){
    for(int i = 0; i < n; i++){
        if(s[i] % 10 != 0){
            sum -= s[i]; 
            break;
        }
    }
}
if(sum % 10 == 0){
    sum = 0;
}
std::cout << sum << std::endl;
return 0;
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"runtime/debug"
	"strconv"
)

var in = NewScanner(os.Stdin, 0)

/* this is port of top c++ answer to test go performance */
func main() {
	debug.SetGCPercent(-1)
	n, d := in.Int(), in.Int()
	a := in.Array1Int(n)
	ans := 0
	for i := 1; i <= n; i++ {
		ans += a[i]
	}
	ans += d * (n - 1)
	f := make([]int, n+1)
	f[1] = a[1]
	for i := 2; i <= n; i++ {
		f[i] = Min2(a[i], f[i-1]+d)
	}
	g := make([]int, n+1)
	g[n] = a[n]
	for i := n - 1; i >= 1; i-- {
		g[i] = Min2(a[i], g[i+1]+d)
	}
	for i := 2; i <= n-1; i++ {
		ans += Min2(f[i], g[i])
	}
	Pln(ans)
}

const M7 = 1000000007

type Scanner struct {
	*bufio.Scanner
}

func NewScanner(r io.Reader, max int) *Scanner {
	s := bufio.NewScanner(r)
	s.Split(scanWords)
	if max <= 0 {
		max = 1048576
	}
	s.Buffer([]byte{}, max)
	return &Scanner{s}
}
func (s *Scanner) Int() int {
	s.Scan()
	i, e := strconv.ParseInt(s.Text(), 10, 64)
	if e != nil {
		panic(e)
	}
	return int(i)
}
func (s *Scanner) Array1Int(n int) []int {
	r := make([]int, n+1)
	for i := 1; i <= n; i++ {
		r[i] = s.Int()
	}
	return r
}
func isSpace(b byte) bool {
	return b == ' ' || b == '\n' || b == '\r' || b == '\t'
}
func scanWords(data []byte, atEOF bool) (advance int, token []byte, err error) {
	start := 0
	for start < len(data) && isSpace(data[start]) {
		start++
	}
	for i := start; i < len(data); i++ {
		if isSpace(data[i]) {
			return i + 1, data[start:i], nil
		}
	}
	if atEOF && len(data) > start {
		return len(data), data[start:], nil
	}
	return start, nil, nil
}
func Min2(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func Pln(s ...interface{}) {
	fmt.Println(s...)
}

type ByteSlice []byte
type IntSlice []byte


Measured memory_bytes: 8704
#include <iostream>
using namespace std;
int main()
{
    int n,r;
    cin >> n >> r;

	if(n>=10)
	{
		// r_in = r
		cout << r << endl;
	}
	else
	{
		// r = r_in - 100*(10-n)
		// r_in = r + 100*(10-n)
		cout << r + 100*(10-n);
	}

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <fstream>
#include <stdio.h>
#include <math.h>
#include <time.h>
#include <string>
#include <tuple>
#include <vector>
#include <map>
#include <unordered_map>
#include <list>
#include <set>
#include <stack>
#include <queue>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <cassert>
using namespace std;
#define LL long long
#define MP(a, b) make_pair(a, b)
#define POWER9 1000000000
#define MOD POWER9+7
#undef INT_MIN
#undef INT_MAX
#define INT_MIN -2147483647
#define INT_MAX 2147483647
#define LL_MIN (LL)-9223372036854775807
#define LL_MAX (LL)9223372036854775807
#define PI 3.14159265359

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

	int N;
	cin >> N;
	int l = 0;
	int x = 0;
	int y = 0;
	for(int i=0; i<N; i++){
		int t,X,Y;
		cin >> t >> X >> Y;
		if(abs(x-X)+abs(y-Y) > t-l || (abs(x-X)+abs(y-Y))%2 != (t-l)%2){
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;

	return 0;
}



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

using namespace std;

#define max(a,b) (a > b ? a: b)
//#define max3(a,b,c) a > max(b,c) ? a : max(b,c)

int main()
{
    int n;
    scanf("%d",&n);
    int* a= new int[n];
    int* b= new int[n];
    int* c= new int[n];
    for(int i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        scanf("%d",&b[i]);
        scanf("%d",&c[i]);
    }
    
    int** dp= new int* [3];
    for(int i=0;i<3;++i)
    dp[i]= new int [n];
    
    dp[0][0]=a[0];
    dp[1][0]=b[0];
    dp[2][0]=c[0];
    for(int i=1;i<n;i++)
    {
        
        dp[0][i]= max(dp[1][i-1],dp[2][i-1])+a[i];
        dp[1][i]= max(dp[0][i-1],dp[2][i-1])+b[i];
        dp[2][i]= max(dp[1][i-1],dp[0][i-1])+c[i];
        
    }
    cout<<(dp[0][n-1] > max(dp[1][n-1],dp[2][n-1]) ? dp[0][n-1] : max(dp[1][n-1],dp[2][n-1]))<<endl;
    return 0;
    
}

Measured memory_bytes: 2688