akhauriyash/Code-Regression huggingface dataset:
/*
--------------              |   /
      |                     |  /
      |                     | /
      |             *       |/          |    |         ------            *
      |                     |           |    |        /      \
      |             |       |\          |    |       |       |\          |
   \  |             |       | \         |    |       |       | \         |
    \ |             |       |  \        |    |        \     /   \        |
     V              |       |   \        \__/|         -----     \       |
*/
#include <bits/stdc++.h>
using namespace std;

#define EmiliaMyWife ios::sync_with_stdio(0); cin.tie(NULL);
#define mem(i,j) memset(i,j,sizeof (i));
#define F first
#define S second
#define lowbit(x) ((x)&(-(x)))
#define siz(v) (long long)(v).size()
typedef int64_t ll;
typedef uint64_t ull;
const double EPS  = 1e-8;
const int INF     = 0x3F3F3F3F;
const ll LINF     = 4611686018427387903;
const int MOD     = 1e9+7;
/*-----------------------------------------------------------------------------------------------------*/
#define int ll

string s;
struct CMP {
    bool operator()(pair<int,int> a, pair<int,int> b) {
        return s.substr(a.first, a.second)>s.substr(b.first, b.second);
    }
};

signed main() {
	EmiliaMyWife

    int k;
    cin >>s >> k;
    set<string> ans;
    int n = s.size();
    priority_queue<pair<int,int>, vector<pair<int,int>>, CMP> pq;
    for(int i = 0; i < n; i++) {
        pq.push({i, 1});
    }
    while(ans.size() < k) {
        auto x = pq.top();
        pq.pop();
        ans.insert(s.substr(x.first, x.second));
        //cout << x.first << ' ' << x.second << '\n';
        if(x.first+x.second < n)
            pq.push({x.first, x.second+1});
    }
    //for(auto a: ans)
       // cout << a << '\n';
    cout << *ans.rbegin();

	return 0;
}


Measured memory_bytes: 512
#define STOPIT
#include<bits/stdc++.h>
#define rep(i,n,m) for(int i = (n); i <(m); i++)
#define rrep(i,n,m) for(int i = (n) - 1; i >=(m); i--)
using namespace std;
using ll = long long;

void debug_impl() { cerr << endl; }
template <typename Head, typename... Tail>
void debug_impl(Head head, Tail... tail) { cerr << " " << head; debug_impl(tail...); }
#ifndef STOPIT
    #define debug(...)\
    do {\
        cerr << boolalpha << "[" << #__VA_ARGS__ << "]:";\
        debug_impl(__VA_ARGS__);\
        cerr << std::noboolalpha;\
    } while (false)
#else
    #define debug(...) {}
#endif

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr>
istream& operator>> (istream& is, Container& v)
  { for (auto & x : v) { is >> x; } return is; }

template < typename Container, typename Value = typename Container::value_type, enable_if_t<!is_same< Container, string >::value, nullptr_t> = nullptr >
ostream& operator<< (ostream& os, Container const& v) {
  os << "{";
  for (auto it = v.begin(); it != v.end(); it++)
    {os << (it != v.begin() ? "," : "") << *it;}
  return os << "}";
}
int main()
{
    int n;
    cin >> n;
    vector<pair<ll, int>> values;
    rep(i, 0, n)
    {
        ll a;
        cin >> a;
        values.emplace_back(a, i);
    }
    sort(values.rbegin(), values.rend());

    vector<vector<ll>> dp(n+1, vector<ll>(n+1, 0));
    rep(i, 1, n+1)
    {
        auto value = values[i-1];
        rep(left, 0, i+1)
        {
            int right = i - left;

            ll left_move = value.first * abs(value.second - left+1);
            ll right_move = value.first * abs(value.second - n + right);
            if (left>0)
                dp[left][right] = max(dp[left][right], dp[left-1][right]+left_move);
            if (right>0)
                dp[left][right] = max(dp[left][right], dp[left][right-1]+right_move);
            debug(dp[left][right], left, right);
        }
    }

    ll res = 0;
    rep(left, 0, n+1)
        res = max(res, dp[left][n-left]);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 34680
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Scanner;

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

    static class GatheringChildren {
        public void solve(int testNumber, Scanner in, PrintWriter out) {
            char[] s = in.next().toCharArray();
            int[] c = new int[s.length];

            int even = 0; // 偶数
            int odd = 0;

            for (int i = 0; i < s.length - 1; i++) {

                if ((i + 1) % 2 == 0) {
                    even++;
                } else {
                    odd++;
                }

                if (s[i] == 'R' && s[i + 1] == 'L') {
                    int r_pos = i + 1;
                    while (true) {
                        r_pos++;
                        if (s.length <= r_pos) {
                            break;
                        }
                        if (s[r_pos - 1] == 'L' && s[r_pos] == 'R') {
                            break;
                        }
                    }
                    for (int j = i + 1; j < r_pos; j++) {
                        if ((j + 1) % 2 == 0) {
                            even++;
                        } else {
                            odd++;
                        }
                    }

                    if (i % 2 == 0) {
                        c[i] = odd;
                        c[i + 1] = even;
                    } else {
                        c[i] = even;
                        c[i + 1] = odd;
                    }
                    i = r_pos - 1;
                    even = 0;
                    odd = 0;
                }
            }

            for (int i = 0; i < s.length; i++) {
                out.print(c[i] + " ");
            }
        }

    }
}



Measured memory_bytes: 46392
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();

	int N, M, K; cin >> N >> M >> K;
	bool is = false;
	rep(i, 0, N+1) {
		rep(j, 0, M+1) {
			int x = i * (M - j) + j * (N - i);
			if (K == x)is = true;
		}
	}
	cout << (is ? "Yes" : "No") << "\n";


	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fol(i,n) for(int i=0;i<n;i++)
#define pb push_back
typedef long long ll;
typedef pair<int,int> P;
typedef vector<P> vip;

void solve(){
    string a,b;cin>>a>>b;
    if (a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0]) cout << "YES"<<endl;
    else cout <<"NO"<<endl;
}

int main(){
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>

using namespace std;

int main(void) {

	int a[3], amx = 0, tmp, k;

	for (int i = 0; i < 3; i++)
	{
		cin >> a[i];
		amx = max(amx, a[i]);

		tmp += a[i];
	}

	cin >> k;

	tmp = tmp + amx * (pow(2,k) - 1);

	cout << tmp << "\n";

	return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.io.*;

public class Main {
    static BufferedReader br = new BufferedReader(new InputStreamReader(System.in), 32768);
    static PrintWriter out = new PrintWriter(System.out);
    static StringTokenizer t;

    static String sn() {
        while (t == null || !t.hasMoreTokens()) {
            try {
                t = new StringTokenizer(br.readLine());
            } catch (IOException e) {
                throw new RuntimeException();
            }
        }
        return t.nextToken();
    }

    static int ni() {
        return Integer.parseInt(sn());
    }

    static long nlo() {
        return Long.parseLong(sn());
    }

    public static void main(String args[]) {
        int t = 1;//ni();
        while (t-- > 0) {
            solve();
        }
        out.close();
    }

    static long mod = (long) 1e9 + 7;

    static long pro(long a, long b) {
        return (a % mod * b % mod) % mod;
    }

    static int maxn = 200005;

    static int bin(int l, int r, List<Integer> list, int cur, int n) {
        int ans = -1;
        while (l <= r) {
            int mid = (l + r) / 2;
            int len = cur - list.get(mid) + 1;
            if ((n - mid + 1) > len / 2) {
                ans = mid;
                r = mid - 1;
            } else
                l = mid + 1;
        }
        return ans;
    }

    static void solve() {
        char s[] = sn().toCharArray();
        int n = s.length;
        HashMap<Character, List<Integer>> map = new HashMap<>();
        int l = -1, r = -1;
        for (int i = 0; i < n; i++) {
            if (map.containsKey(s[i])) {
                List<Integer> temp = map.get(s[i]);
                int size = temp.size();
                int res = bin(0, size - 1, temp, i, size);
                if (res != -1) {
                    l = temp.get(res) + 1;
                    r = i + 1;
                    break;
                }
                map.get(s[i]).add(i);
            } else {
                map.put(s[i], new ArrayList<>());
                map.get(s[i]).add(i);
            }
        }
        out.println(l + " " + r);
    }
}

Measured memory_bytes: 27220
#import sys
MOD = 10 ** 9 + 7
#input = sys.stdin.readline
import math

#import bisect

def sosuhante(n):
    for k in range(2, int(math.sqrt(n))+1):
        if n% k ==0:
            return False
    return True
def cmb(n, r):
    if n - r < r: r = n - r
    if r == 0: return 1
    if r == 1: return n

    numerator = [n - r + k + 1 for k in range(r)]
    denominator = [k + 1 for k in range(r)]

    for p in range(2,r+1):
        pivot = denominator[p - 1]
        if pivot > 1:
            offset = (n - r) % p
            for k in range(p-1,r,p):
                numerator[k - offset] /= pivot
                denominator[k] /= pivot

    result = 1
    for k in range(r):
        if numerator[k] > 1:
            result *= int(numerator[k])

    return result

def kingaku(a,b,n):
    keta=len(str(n))
    return a*n+b*keta

def main():
#    h,w,a,b = map(int, input().split())
#    c = [[0 for j in range(n)] for i in range(n)]
    m1,d1=map(int,input().split())
    m2,d2=map(int,input().split())
    print("1") if d2==1 else print(0)

#    print(n,kingaku(a,b,x))

if __name__ == "__main__":
    main()

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

using namespace std;

typedef long long ll;
typedef long double ld;

const int INF = (int) 1e9 + 123;
const ll LINF = (ll) 1e18 + 123;
const ld EPS = (ld) 1e-12;
const ll MOD = (ll) 1e9 + 7;

#define sz(x) (int) (x).size()
#define mp(x, y) make_pair(x, y)
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define lb(s, t, x) (int) (lower_bound(s, t, x) - s)
#define ub(s, t, x) (int) (upper_bound(s, t, x) - s)
#define rep(i, f, t) for (auto i = f; i < t; i++)
#define per(i, f, t) for (auto i = f; i >= t; i--)

ll power(ll x, ll y, ll mod = MOD) {
    if (y == 0) {
        return 1;
    }
    if (y & 1) {
        return power(x, y - 1, mod) * x % mod;
    } else {
        ll tmp = power(x, y / 2, mod);
        return tmp * tmp % mod;
    }
}

void add(ll &x, ll y, ll mod = MOD) {
    x += y;
    if (x >= mod) x -= mod;
    if (x < 0) x += mod;
}

ll sum(ll x, ll y, ll mod = MOD) {
    add(x, y, mod);
    return x;
}

ll mult(ll x, ll y, ll mod = MOD) {
    return (x * y) % mod;
}

ll div(ll x, ll y, ll mod) {
    return x * power(y, mod - 2, mod);
}

template<typename A, typename B> bool mini(A &x, const B &y) {
    if (y < x) {
        x = y;
        return true;
    }
    return false;
}

template<typename A, typename B> bool maxi(A &x, const B &y) {
    if (y > x) {
        x = y;
        return true;
    }
    return false;
}

template<typename T> void read(T first, T last) {
    while (first != last) {
        cin >> *(first++);
    }
}

template<typename T> void print(T first, T last) {
    while (first != last) {
        cout << *(first++) << " ";
    }
    cout << "\n";
}

void run();

#define TASK ""

int main() {
#ifdef LOCAL
    if (strlen(TASK) > 0) {
        cerr << "Reminder: you are using file i/o, filename: " TASK "!" << endl << endl;
    }
#endif
#ifndef LOCAL
    if (strlen(TASK)) {
        freopen(TASK ".in", "r", stdin);
        freopen(TASK ".out", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
#endif
    cout << fixed << setprecision(12);
    run();
    return 0;
}

// == SOLUTION == //

void run() {
    string s;
    cin >> s;
    string t = s;
    reverse(all(t));
    cout << (s == t ? "Yes\n" : "No\n");
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}


int main() {
    init();
    int a,b;
    cin>>a>>b;
    cout<<a*b-((a*1)+(b*1)-1);

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define pll pair <ll, ll>
#define mp make_pair
#define pyshnapyshnakaa ios_base :: sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define x first
#define y second
#pragma GCC optimize("O3")
#define plll pair <pair <ll, ll>, ll>
#define pllll pair <pair <ll, ll>, pair <ll, ll> >
#define psl pair <string, ll>
#define all(a) a.begin(), a.end()
// #pragma comment(linker, "/stack:2000000000")
 
typedef long long ll;
 
typedef long double ld;
 
using namespace std;
 
const ll maxn = 1e6;
const ll inf = 1e9;
 
ll n, m, k, t;

void yes() {
    cout << "Yes";
    exit(0);
}

void no() {
    cout << "No";
    exit(0);
}

int main() {
    ll q, w, e, d;
    string s;
    ll a, b, c;
    cin >> a >> b >> c;
    ll x = c - a - b;
    if (x < 0) {
        no();
    }
    // if (x > 2 * sqrtl(max(a, b))) {
    //     yes();
    // }
    if (x > 1e9) {
        yes();
    }
    ll x1 = x * x;
    // cout << x1 << endl;
    if (x1 > 4 * a * b) {
        yes();
    }
    else {
        no();
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(nullptr); cout.tie(0)
#define endl "\n"
#define int long long
typedef vector<int> vi;
#define all(x) x.begin(),x.end()
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORD(i,a,b) for(int i=(a);i>=(b);i--)
#define pii              pair <int,int>
#define DEBUG(x) cerr << '>' << #x << ':' << x << endl;
typedef long long ll;
//#pragma comment(linker, "/STACK:667772160")
#define in_range(x, y, r, c) ((x >= 0 && x < r && y >= 0 && y < c))

const double eps=1e-9;
const int MOD=1e9+7;
const int N=1e5+30;
const int inf = 1e17+995;

template< class T > T gcd(T a, T b) { return (b != 0 ? gcd<T>(b, a%b) : a); }
template< class T > T lcm(T a, T b) { return (a / gcd<T>(a, b) * b); }
template <typename T> T exp(T b, T p){T x = 1;while(p){if(p&1)x=(x*b);b=(b*b);p=p>>1;}return x;}
inline int ones(int n) { int res = 0; while(n && ++res) n-=n&(-n); return res; }
inline bool EQ(double a, double b) { return fabs(a-b) < 1e-9; }
void boostIO() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
}

int32_t main() {
boostIO();
int n;
cin>>n;
vi h(n);
    for (int i = 0; i < n; ++i) {
        cin>>h[i];
    }
    vi dp(n,inf);
    dp[0]=0;
    for (int i = 0; i < n; ++i) {
        for(int j:{i+1,i+2}){
            if(j<n){
                dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
            }
        }
    }
    cout<<dp[n-1]<<endl;
}

Measured memory_bytes: 1792
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp4
{
    class Program
    {
        static void Main()
        {
            var a = Console.ReadLine().ToCharArray();
            var b = Console.ReadLine().ToCharArray();

            int asw = 0;
            for(int i =0; i < a.Length; i++)
            {
                if (a[i] != b[i]) 
                {
                    asw++;
                }
            }

            Console.WriteLine(asw);
        }
    }
}


Measured memory_bytes: 28316
#include<iostream>
#include<algorithm>
#include<math.h>
#include<cstring>
#include<vector>

using namespace std;

#define long long long
#define ft(i, a, b) for (int i = (long)a ; i <= (long)b ; i++)
#define fd(i, a, b) for (int i = (long)a ; i >= (long)b ; i--)

const int MAXN = 1e5 + 5;
const long oo = 1e15;


long n;
long a[MAXN] , dp[MAXN];

long choose(int i , int j) {
    return abs(a[i] - a[j]);
}

void Solve() {
    dp[2] = choose(1 , 2);
    ft(i , 3 , n) {
        dp[i] = min(dp[i -1] + choose(i , i - 1) , dp[i - 2] + choose(i , i - 2));
    }
    cout << dp[n];
}

void FastInput() {
    ios_base::sync_with_stdio(NULL);
    cin.tie(NULL);
    cout.tie(NULL);
    //freopen(".inp", "r", stdin);
    //freopen(".out", "w", stdout);
}

void Input() {
    cin >> n;
    ft(i , 1 , n) cin >> a[i];
}

int main() {
    FastInput();
    Input();
    Solve();
}

Measured memory_bytes: 1792
#include "bits/stdc++.h"
#pragma GCC optimize("Ofast")

// Begin {{{
using namespace std;

#ifndef DEBUG
#define dump(...)
#endif

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

template <class T>
inline vector<T> make_v(const T &initvalue, size_t sz) {
    return vector<T>(sz, initvalue);
}

template <class T, class... Args>
inline auto make_v(const T &initvalue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initvalue, args...))>(sz, make_v<T>(initvalue, args...));
}

constexpr int INF = 0x3f3f3f3f;
constexpr int64_t LINF = 0x3f3f3f3f3f3f3f3fLL;
// }}} End

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

    intmax_t N; cin >> N;

    int minv = INF;
    for (intmax_t i = 1; i * i <= N; ++i) {
        if (N % i == 0) {
            string A = to_string(i);
            string B = to_string(N / i);
            chmin(minv, max((int) A.length(), (int) B.length()));
        }
    }

    cout << minv << "\n";

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define endl "\n"
#define fo(i,s,e) for( i=s;i<e;i++)
#define rfo(i,s,e) for(i=s;i>e;i--)
#define LL long long int 
const LL MOD=1e9+7;
#define pb push_back
#define pob pop_back()
#define sp " "
#define ff first
#define ss second
//            When something is important enough, you do it even if the odds are not in your favor.

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
    // code goes here
    int t=1;//cin>>t;
    while(t--){
      LL n,i,ans=0;cin>>n;
      fo(i,1,n+1){
        LL x;cin>>x;
        if((i&1)&&(x&1)) ans++;
      }
      cout<<ans;
    }
    return 0;
}

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

int main() {
  int N;
  cin >> N;
  
  int tot_n = 0;
  
  rep(i, N){
    int l, r;
    cin >> l >> r;
    tot_n += r-l+1;
  }
  
  cout << tot_n << endl;
}

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

struct Dice {
    int s[6];
    void roll (char c) {
        int b;
        if (c == 'E') {
            b = s[0];
            s[0] = s[3];
            s[3] = s[5];
            s[5] = s[2];
            s[2] = b;
        }
        if (c == 'W') {
            b = s[0];
            s[0] = s[2];
            s[2] = s[5];
            s[5] = s[3];
            s[3] = b;
        }
        if (c == 'N') {
            b = s[0];
            s[0] = s[1];
            s[1] = s[5];
            s[5] = s[4];
            s[4] = b;
        }
        if (c == 'S') {
            b = s[0];
            s[0] = s[4];
            s[4] = s[5];
            s[5] = s[1];
            s[1] = b;
        }
        if (c == 'R') {
            b = s[1];
            s[1] = s[2];
            s[2] = s[4];
            s[4] = s[3];
            s[3] = b;
        }
    }
    int top () {
        return s[0];
    }
    int front () {
        return s[1];
    }
    int left () {
        return s[3];
    }
    int right () {
        return s[2];
    }
};

bool f(Dice a, Dice b) {
    for (int i = 0; i < 6; i++) {
        if (a.s[i] != b.s[i]) {
            return false;
        }
    }
    return true;
}

int main() {

  Dice d1, d2;

  for (int i = 0; i < 6; i++) {
      cin >> d1.s[i];
  }

  for (int i = 0; i < 6; i++) {
      cin >> d2.s[i];
  }

  string answer = "No";

  for (int i = 0; i < 4; i++) {
      d2.roll('R');
      for (int j = 0; j < 4; j++) {
          d2.roll('N');
          if (f(d1, d2)) {
              answer = "Yes";
          }
      }
  }

  d2.roll('E');
  for (int i = 0; i < 4; i++) {
    d2.roll('N');
    if (f(d1, d2)) {
      answer = "Yes";
    }
  }

  d2.roll('W');
  d2.roll('W');
  for (int i = 0; i < 4; i++) {
    d2.roll('N');
    if (f(d1, d2)) {
      answer = "Yes";
    }
  }

  cout << answer << endl;

  return 0;

}


Measured memory_bytes: 3228
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
using namespace std;

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

int main(){
    string S;
    ll K;
    cin >> S >> K;
    int len = (int)S.size();
    int point = len;
    for(int i = 0; i < len; i++){
        if(S.at(i) != '1'){
            point = i;
            break;
        }
    }
    if(point + 1 <= K){
        cout << S.at(point) << endl;
    }else{
        cout << 1 << endl;
    }
    return 0;
}

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

int main(){
  ll k;
  cin >> k;
  vector<ll> a;
  for(int i=1;i<=9;i++) a.push_back(i);
  while(true){
    if( k <= a.size() ){
      cout << a.at(k-1) << endl;
      return 0;
    }
    k -= a.size();
    vector<ll> old;
    swap(a,old);
    for(int i=0;i<old.size();i++){
      for(int j=-1;j<=1;j++){
        ll d = old.at(i)%10 + j;
        if( d < 0 || d > 9 ) continue;
        a.push_back(old.at(i)*10+d);
      }
    }
  }
    
  return 0;
}

Measured memory_bytes: 1712
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;

int main() {
    int N,K;
    cin>>N>>K;
    vi A(N);
    int A_sum=0;
    for (int i = 0; i < N; i++){
        cin>>A[i];
        A_sum+=A[i];
    }
    for (int i = 1; i <= floor(sqrt(A_sum)); i++){
        if(A_sum%i!=0)continue;
        ll X=A_sum/i;
        vi B(N);
        ll B_sum=0;
        for (int j = 0; j < N; j++){
            B[j]=A[j]%X;
            B_sum+=B[j];
        }
        sort(B.begin(),B.end());
        ll minus=0;
        ll k=2000000000;
        for (int j = 0; j < N-1; j++){
            minus+=B[j];
            ll plus=X*(N-1-j)-(B_sum-minus);
            k=min(k,max(minus, plus));
        }
        if(k<=K){
            cout<<X<<endl;
            return 0;
        }
    }
    for (int i = floor(sqrt(A_sum)); i > 0; i--){
        if(A_sum%i!=0)continue;
        ll X=i;
        vi B(N);
        ll B_sum=0;
        for (int j = 0; j < N; j++){
            B[j]=A[j]%X;
            B_sum+=B[j];
        }
        sort(B.begin(),B.end());
        ll minus=0;
        ll k=2000000000;
        for (int j = 0; j < N-1; j++){
            minus+=B[j];
            ll plus=X*(N-1-j)-(B_sum-minus);
            k=min(k,max(minus, plus));
        }
        if(k<=K){
            cout<<X<<endl;
            return 0;
        }
    }
}

Measured memory_bytes: 3820
module Mi = Map.Make(struct type t = int let compare = (-) end)
let rec fix f x = f (fix f) x
let () =
  Scanf.scanf "%d %d" @@ fun n k ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" pred) in
  (1, Mi.singleton 0 0, Mi.singleton 0 1, 0) |> fix (fun f (i, sa, cm, ans) ->
    if i > n then ans else
    let si = (Mi.find (i-1) sa + a.(i-1)) mod k in
    let cm =
      if i < k then cm else
        let idx = Mi.find (i-k) sa in
        Mi.add idx (Mi.find idx cm - 1) cm in
    let ans = ans + try Mi.find si cm with _ -> 0 in
    let sa = Mi.add i si sa in
    let cm = Mi.add si (1 + try Mi.find si cm with _ -> 0) cm in
    f (i+1, sa, cm, ans))
  |> Printf.printf "%d\n"


Measured memory_bytes: 34300
import java.util.*;

public class Main {
	//static boolean f;
	
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		/* 入力の受け取り
		 * String s = sc.next();
		 * int a = sc.nextInt();
		 * long a = sc.nextLong();
		 */
		
		// 文字列(String)を文字(char)に分解
		// char[] s_char = s.toCharArray();
		
		int n = sc.nextInt();
		long t[] = new long[n];
		for(int i=0;i<n;i++)
			t[i] = sc.nextLong();
		
		long time = t[0];
		
		if(n != 1) {
			for(int i=1;i<n;i++)
				time = lcm(time,t[i]);
		}
		
		System.out.println(time);
		
		/*
		 * if(f)
		 *	System.out.println("Yes");
		 * else
		 * 	System.out.println("No");
		 */
	}
	
	// ユークリッドの互除法(最大公約数を求める)
	static long gcd(long x, long y) {
		return x%y==0? y : gcd(y,x%y);
	}
		
	// 最小公倍数を求める
	static long lcm(long x, long y) {
		return x / gcd(x, y) * y;
	}
		
}


Measured memory_bytes: 21844
from math import ceil
a, b, c = map(int, input().split())

MAX = max(max(a,b),c)

distance = (MAX-a) + (MAX-b) + (MAX-c)

if distance % 2 == 0:
    print(int(distance/2))

elif distance % 2 == 1:
    print(int(ceil(distance/2) + 1))

Measured memory_bytes: 3064
#include<cstdio>
#include<vector>
#include<map>
#include<climits>
#include<algorithm>
#include<iostream>
#include<queue>
#include<cstring>
using namespace std;
typedef pair<int,int> Pt;
#define MAX 1000001
#define fr first
#define sc second
typedef struct node{
  string name;
  vector<int> vc;
  int sum;
}P;
int main(){
  int n,T[31];
  while(cin >> n && n){
    memset(T,-1,sizeof(T));
    P p[n];
    for(int i=0,s;i<n;i++){
      cin >> p[i].name >> s;
      for(int j=0,a;j<s;j++){
        cin >> a;
        T[a]++;
        p[i].vc.push_back(a);
      }
    }
    for(int i=0;i<n;i++){
      p[i].sum = 0;
      for(int j=0;j<p[i].vc.size();j++){
        p[i].sum += (n - T[p[i].vc[j]]);
      }
    }
    int MAC = INT_MAX;
    string ans;
    for(int i=0;i<n;i++){
      if(MAC > p[i].sum) MAC = p[i].sum,ans = p[i].name;
      else if(MAC == p[i].sum) if(ans>p[i].name) ans = p[i].name;
    }
    cout << MAC << " " << ans << endl;
  }
}

Measured memory_bytes: 1244
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<string>
#include<queue>
#include<set>
#include<map>
#include<vector>
#include<list>
#include<fstream>
#include<cmath>
#include<cctype>
#include<stack>
#include<cstdlib>
#include<ctime>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
priority_queue<int> d2;
priority_queue<int,vector<int>,greater<int> > d1;
const int N=300010;
ll n,a[N],i,ans,ma[N],s;
inline void up(ll&a,ll b){
	if(a<b)a=b;
}
int main(){
	scanf("%lld",&n);
	for(i=1;i<=3*n;++i)scanf("%lld",a+i);
	for(i=1;i<=n;++i){
		d1.push(a[i]);
		ma[n]+=a[i];
	}
	s=ma[n];
	ans=-1ll<<60;
	for(;i<=n<<1;++i){		
		if(a[i]>d1.top()){
			s+=a[i]-d1.top();
			d1.pop();
			d1.push(a[i]);
		}
		ma[i]=s;
	} 
	s=0;
	for(i=3*n;i>n<<1;--i){
		d2.push(a[i]);
		s+=a[i];
	}
	up(ans,ma[n<<1]-s);
	for(;i>n;--i){
		if(a[i]<d2.top()){
			s-=d2.top()-a[i];
			d2.pop();
			d2.push(a[i]);
		}
		up(ans,ma[i-1]-s);
	}
	cout<<ans<<endl;
	return 0;
}

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


class Solution {
public:
  explicit Solution(string &s, const int &K) {
    size_t n = s.size();
    if (n <= K) {
      cout << s;
    }else{
      cout << s.substr(0, K) << "...";
    }
  }
};



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

#ifdef ONLINE_JUDGE
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
#endif
  int K;
  string S;
  cin >> K >> S;
  Solution(S, K);
}

Measured memory_bytes: 3632
from collections import Counter

if __name__ == '__main__':
    N, K = map(int, input().split())
    A = list(map(int, input().split()))

    c = Counter(A)
    sorted_c = sorted(c.values())

    answer = 0
    for i in range(len(c.keys())-K):
        answer += sorted_c[i]
    print(answer)


Measured memory_bytes: 32540
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    int a, b, c;
    cin >> a >> b >> c;
    cout << max(0, c - (a - b));
    return 0;
}


Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

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

func nextInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	n := nextInt()
	r := nextInt()

	if n < 10 {
		fmt.Println(r + 100 * (10 - n))
	} else {
		fmt.Println(r)
	}
}

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

#define mem(arr,x) memset(arr,x,sizeof(arr))
#define pb push_back
#define ll long long
#define mp make_pair
#define rep(i,n)  for(ll i=0;i<n;i++)
#define repi(i,n)  for(ll i=1;i<=n;i++)
#define all(x)   (x.begin(),x.end())

const double PI = 3.1415926535897932;
const int mod = 1e9 + 7;  
const int inf = 1e9 + 7;

int max(int a,int b)
{
	if(a>b)
	return a;
	return b;
}

int main()
{
	
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
ll n,k;
cin>>n>>k;
int h[n];
rep(i,n)
cin>>h[i];
vector<int>dp(n,inf);
dp[0]=0;
for(int i=0;i<n;i++)
{
	for(int j=i+1;j<=i+k;j++)
	{
		dp[j]=min(dp[j],dp[i]+abs(h[i]-h[j]));
	}
}
cout<<dp[n-1]<<'\n';

}


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

#define debug(x) cerr << #x << ": " << x << endl;
#define debug2(x, y) cerr<<"("<<#x<<", "<<#y<<") = "<<"("<<x<<", "<<y<<")"<<endl;
#define debug3(x, y, z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = "<<"("<<x<<", "<<y<<", "<<z<<")"<<endl;

int A, B, C, D, E, F;

int main() {
   cin >> A >> B >> C >> D >> E >> F;

   set<int> sugar, water;
   for (int i = 0; i < 3333; i++) {
      for (int j = 0; j < 3333; j++) {
         int s = C*i + D*j;
         if (s <= F) sugar.insert(s);
      }
   }

   for (int i = 0; i < 33; i++) {
      for (int j = 0; j < 33; j++) {
         int w = A*100*i + B*100*j;
         if (w <= F) water.insert(w);
      }
   }

   const double lim = (double)E / (100+E);
   double noudo = -1;
   int ans1 = 0, ans2 = 0;
   for (int s : sugar) {
      for (int w : water) {
         int sum = s + w;
         double x = (double)s / sum;
         // if (sum > F || sum == 0 || x > lim) continue; if (x > noudo)
         if (sum <= F && x <= lim && x > noudo) {
            noudo = x;
            ans1 = sum, ans2 = s;
         }
      }
   }
   cout << ans1 << " " << ans2 << endl;

   return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define rrng(a) a.rbegin(),a.rend()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef tuple<int,int,int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;
inline int getInt() { int x; scanf("%d",&x); return x;}
template<typename T>inline istream& operator>>(istream&i,v(T)&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const v(T)&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>inline ostream& operator<<(ostream&o,const v(T)&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>inline istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>inline ostream& operator<<(ostream&o,const pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
const double eps = 1e-10;
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
const int MX = 200005;

const int M = 32;

int main() {
  int n,t;
  scanf("%d%d",&n,&t);
  vp p(n);
  cin>>p;
  rep(i,sz(p)) p[i].se++;
  ++t;
  sort(rng(p), [&](P& a, P& b) {
    return (ll)a.se*b.fi < (ll)b.se*a.fi;
  });

  int r = n;
  while (r && p[r-1].fi == 0) --r;
  vl dp(M, INF);
  dp[0] = 1;
  rep(i,r) {
    int a = p[i].fi, b = p[i].se;
    drep(j,M-1) mins(dp[j+1], dp[j]*(a+1)+b);
  }

  int ans = 0;
  vi bs;
  srep(i,r,n) bs.pb(p[i].se);
  sort(rng(bs));
  rep(j,M) {
    int x = dp[j];
    if (x > t) continue;
    int i = 0;
    while (i < sz(bs) && x+bs[i] <= t) {
      x += bs[i];
      ++i;
    }
    maxs(ans, i+j);
  }
  cout<<ans<<endl;
  return 0;
}






















Measured memory_bytes: 2936
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Scanner;

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

    public void solve() {
        Scanner scan = new Scanner(new BufferedReader(new InputStreamReader(System.in)));
        int N = scan.nextInt();
        int[] A = new int[N];
        HashMap<Integer, Integer> map = new HashMap<>();
        for (int i = 0; i < N; i++) {
            A[i] = scan.nextInt();
            int x = map.getOrDefault(A[i], 0);
            map.put(A[i], x+1);
        }
        long max = 0;
        for (int x : map.keySet()) {
            if (map.get(x) <= 1) {
                continue;
            }
            long cnt = map.get(x);
            max += cnt * (cnt - 1)/2;
        }
        for (int i = 0; i < N; i++) {
            int cnt = map.get(A[i]);
            if (cnt <= 1) {
                System.out.println(max);
                continue;
            }
            System.out.println(max - (cnt - 1));
        }
    }
}


Measured memory_bytes: 127096
#include <bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<n;i++)
#define repb(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define o(a) cout<<a<<endl
#define int long long
#define fi first
#define se second
using namespace std;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int,int> pii;

string FizzBuzz(int n){
	string res="";
	if(n%3==0) res+="Fizz";
	if(n%5==0) res+="Buzz";
	if(res==""){
		stringstream ss;
		ss<<n;
		ss>>res;
	}
	return res;
}

signed main(){
	int m,n;
	while(1){
		cin>>m>>n;
		if(m+n==0) break;
		vector<string> s(n+1);
		rep(i,1,n+1) cin>>s[i];
		vi d(m);
		rep(i,0,m) d[i]=i+1;
		int now=0;

		rep(i,1,n+1){
			//cout<<s[i]<<" "<<FizzBuzz(i)<<endl;
			if(s[i]==FizzBuzz(i)){
				now++;
			}else{
				d.erase(remove(all(d),d[now]),d.end());
			}
			if(d.size()==1) break;
			now%=d.size();
		}
		rep(i,0,d.size()){
			cout<<(i?" ":"")<<d[i];
		}
		cout<<endl;
	}
}

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

typedef long long ll;

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

const ll INF = (1ll << 60);
const ll MOD = (ll)1e9 + 7;

signed main()
{
    int n;
    int h[100001];
    cin >> n;
    for (int i = 1; i <= n; i++)
        cin >> h[i];

    int dp[100001] = {0, 0, abs(h[1] - h[2])};

    for (int i = 3; i <= n; i++)
    {
        dp[i] = min(dp[i - 1] + abs(h[i] - h[i - 1]), dp[i - 2] + abs(h[i] - h[i - 2]));
    }
    cout << dp[n] << endl;
}

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

void solve(std::istream &ist, std::ostream &ost)
{
    /* ------- 宣言と入力 ------- */

    long double a, b, c;

    ist >> a >> b >> c;

    /* ------- 計算 ------- */

    if (c - a - b > 0 && 4 * a * b < pow(c - a - b, 2))
    {
        ost << "Yes" << endl;
    }
    else
    {
        ost << "No" << endl;
    }
}

#ifndef WOMAIN
int main()
{
    solve(std::cin, std::cout);
    return 0;
}
#endif


Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        List<Integer> nums = new ArrayList<>();
        for(int i=0; i<n; ++i) {
            nums.add(sc.nextInt());
        }

        int n_max = (int)Float.NEGATIVE_INFINITY; //??????????????§
        int n_min = nums.get(0);
        for(int i=1; i<n; ++i) {
            n_max = Math.max(nums.get(i) - n_min, n_max);
            n_min = Math.min(nums.get(i), n_min);
        }

        System.out.println(n_max);
    }
}

Measured memory_bytes: 105540
N,M = map(int,input().split())

pena_prob = [0]*(10**5 + 10)
ac_prob = [0]*(10**5 + 10)
for i in range(M):
  p,S = input().split()
  p = int(p)
  if(S == 'AC'):
    ac_prob[p] = 1
  elif(S == 'WA'):
    if(ac_prob[p] == 0):
      pena_prob[p] += 1

pena = 0
for i in range(len(ac_prob)):
  if(ac_prob[i] == 1):
   pena += pena_prob[i]    
  
ac = sum(ac_prob)
print(ac, pena)


Measured memory_bytes: 4596
function Main(input) {
	input = input.split("\n");
	const N = parseInt(input[0])
	const Hs = input[1].split(" ").map(x => parseInt(x))

	var isPossible = true

	for(i=0; i < N; i++){
		if(i == 0){
			Hs[i] = Hs[i] - 1
		}else if(Hs[i] >= Hs[i+1]){
			if(Hs[i] - Hs[i+1] >= 2){
				isPossible = false
				break
			}else if(Hs[i-1] == Hs[i]){
				if(Hs[i] - Hs[i+1] == 1){
					isPossible = false
					break
				}
			}else{
				Hs[i] = Hs[i] - 1
			}
		}
	}

	if(isPossible){
		console.log("Yes")
	}else{
		console.log("No")
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

const int maxn=3e3+10;
int n,a[maxn],b[maxn],id[maxn<<1];
char s[maxn<<1];
vector<string> vec;
string ans;

int main(){
	scanf("%d%s",&n,s);
	for(int i=0,cnta=0,cntb=0,last=0;s[i];++i){
		if(s[i]=='a')
			a[++cnta]=i,id[i]=cnta;
		else
			b[++cntb]=i,id[i]=cntb;
		if(cnta==cntb){
			if(a[cnta]<b[cntb]){
				int cnt=1;
				for(int j=last+2,lst=last+1;j<=cnta;++j)
					if(a[j]>b[lst])
						++cnt,lst=j;
				string str;
				for(int j=1;j<=cnt;++j){
					str.push_back('a');
					str.push_back('b');
				}
				vec.push_back(str);
			}
			else{
				string str;
				for(int j=last+1;j<=cnta;++j){
					string tmp;
					for(int k=b[j];k<=a[cnta];++k)
						if(id[k]>=j)
							tmp.push_back(s[k]);
					if(tmp>str)
						str=tmp;
				}
				vec.push_back(str);
			}
			last=cnta;
		}
	}
	for(int i=vec.size()-1;~i;--i)
		if(ans<vec[i]+ans)
			ans=vec[i]+ans;
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 512
S = gets.chomp

alphabet = Array.new(26) {0}

S.chars.each do |c|
  alphabet[c.ord - 'a'.ord] += 1
end

if S.size != 26
  min = alphabet.find_index {|a| a == 0}
  char = ('a'.ord + min).chr
  puts S + char
else
  index = S.size - 1
  (S.size - 1).downto(1) do |i|
    if S[i] < S[i-1]
      index = i - 1
    else
      break
    end
  end

  if index == 0
    puts -1
  elsif index == 1
    puts (S[index-1].ord + 1).chr
  else

    ch = S[-1]
    index.upto(S.size-2) do |i|
      if S[index-1] > S[i]
        ch = S[i-1]
        break
      end
    end

    puts S[0..index-2] + ch
  end
end


Measured memory_bytes: 3836
M=10**9+7
#リストに入力（文字列）
text=input()
lst=list(text)
lst.reverse()
digit=len(lst)

######六桁ごとに区切って、?の数とその他の数字を数える
######たとえば文字列のリストが「9?????81????」だったら
######[[17,0],[8,1],[0,2],[0,2],[0,2],[0,2]]になる
six=[[0,0],[0,0],[0,0],[0,0],[0,0],[0,0]]
for i in range(digit):
  if(lst[i]=="?"):
    six[i%6][1]=six[i%6][1]+1
  else:
    six[i%6][0]=(six[i%6][0]+int(lst[i]))%13

    
######数字部分の余りから5を引く    
rem=-(six[0][0]-3*six[1][0]-4*six[2][0]
      -1*six[3][0]+3*six[4][0]+4*six[5][0]-5)%13

######漸化式を6個用意
def mat1(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-1)%13]+ls[(i-2)%13]
               +ls[(i-3)%13]+ls[(i-4)%13]+ls[(i-5)%13]
               +ls[(i-6)%13]+ls[(i-7)%13]+ls[(i-8)%13]
               +ls[(i-9)%13])%M
  return val_ls
def mat10(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i+3)%13]+ls[(i+6)%13]
               +ls[(i+9)%13]+ls[(i+12)%13]+ls[(i+15)%13]
               +ls[(i+18)%13]+ls[(i+21)%13]+ls[(i+24)%13]
               +ls[(i+27)%13])%M
  return val_ls
def mat100(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i+4)%13]+ls[(i+8)%13]
               +ls[(i+12)%13]+ls[(i+16)%13]+ls[(i+20)%13]
               +ls[(i+24)%13]+ls[(i+28)%13]+ls[(i+32)%13]
               +ls[(i+36)%13])%M
  return val_ls
def mat1000(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i+1)%13]+ls[(i+2)%13]
               +ls[(i+3)%13]+ls[(i+4)%13]+ls[(i+5)%13]
               +ls[(i+6)%13]+ls[(i+7)%13]+ls[(i+8)%13]
               +ls[(i+9)%13])%M
  return val_ls
def mat10000(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-3)%13]+ls[(i-6)%13]
               +ls[(i-9)%13]+ls[(i-12)%13]+ls[(i-15)%13]
               +ls[(i-18)%13]+ls[(i-21)%13]+ls[(i-24)%13]
               +ls[(i-27)%13])%M
  return val_ls
def mat100000(ls):
  val_ls=[0]*13
  for i in range(13):
    val_ls[i]=(ls[i]+ls[(i-4)%13]+ls[(i-8)%13]
               +ls[(i-12)%13]+ls[(i-16)%13]+ls[(i-20)%13]
               +ls[(i-24)%13]+ls[(i-28)%13]+ls[(i-32)%13]
               +ls[(i-36)%13])%M
  return val_ls


######漸化式を適用
modulos=[1,0,0,0,0,0,0,0,0,0,0,0,0]
for j in range(six[0][1]):
  modulos=mat1(modulos)
for j in range(six[1][1]):
  modulos=mat10(modulos)
for j in range(six[2][1]):
  modulos=mat100(modulos)
for j in range(six[3][1]):
  modulos=mat1000(modulos)
for j in range(six[4][1]):
  modulos=mat10000(modulos)
for j in range(six[5][1]):
  modulos=mat100000(modulos)
print(modulos[rem])


Measured memory_bytes: 4228
#include <stdio.h>


void priner(int a[],int n){
    int i;
    for(i=0;i<n;i++){
        if(i==(n-1))printf("%d\n",a[i]);
        else printf("%d ",a[i]);
        }

}

void insert(int a[],int n){
    int i,j,k;
    for (i=1;i< n;i++) {
        k=a[i];
        for (j=i;0<j;j--) {
            if(a[j-1]<k)break;
            a[j]=a[j-1];

        }
        a[j]=k;
        priner(a,n);
    }
}

int main(){

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


 return 0;
}


Measured memory_bytes: 2104
package main

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

var sc = bufio.NewScanner(os.Stdin)

func scanInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)

	H, W, N := scanInt(), scanInt(), scanInt()
	MAP := make([][]int, H)
	for i := 0; i < H; i++ {
		MAP[i] = make([]int, W)
	}

	cnt := 0
	for i := 1; i <= N; i++ {
		a := scanInt()
		for j := 0; j < a; j++ {
			h, w := cnt/W, cnt%W
			MAP[h][w] = i
			cnt++
		}
	}

	for i := 0; i < H; i++ {
		if i%2 == 0 {
			for j := 0; j < W; j++ {
				fmt.Printf("%d ", MAP[i][j])
			}
		} else {
			for j := W - 1; j >= 0; j-- {
				fmt.Printf("%d ", MAP[i][j])
			}
		}
		fmt.Printf("\n")
	}
}


Measured memory_bytes: 1996
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <sstream>
#include <bitset>
 
#define INPUT_FROM_FILE (0) 
#if INPUT_FROM_FILE
#include <fstream>
#endif

int calc(const std::vector<int> &p, int c){
	int ret = 0;

	for(int i = 0; i < p.size(); i++){
		ret += std::min(p[i], c % 10);
		c /= 10;
	}

	return ret;
}

int next_c(int c){
	int ret = c / 10 + (c % 10) * 10000000;

	return ret;
}

int main(int argc, char **argv){
	std::vector<int> p(8, 0);


#if INPUT_FROM_FILE
	std::ifstream ifs("test.txt");
	//FILE *fp = fopen("test.txt", "r");
#endif

#if INPUT_FROM_FILE
	while(ifs >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
#else
	while(std::cin >> p[0] >> p[1] >> p[2] >> p[3] >> p[4] >> p[5] >> p[6] >> p[7]){
#endif
		int c = 41412121;
		int max = -1;
		int max_c = 0;

		for(int i = 0; i < 8; i++){
			int m = calc(p, c);

			if(max < m){
				max = m;
				max_c = c;
			}
			else if(max == m && max_c < c){
				max_c = c;
			}
			c = next_c(c);
		}

		std::cout << max_c % 10;
		max_c /= 10;
		for(int i = 1; i < 8; i++){
			std::cout << " " << max_c % 10;;
			max_c /= 10;
		}
		std::cout << std::endl;
	}


 
#if INPUT_FROM_FILE
	//fclose(fp);
#endif
    return 0;
}


Measured memory_bytes: 3076
#include <iostream>

int main(){
    int n;
    std::cin >> n;

    int count = 0;
    int dividable;
    for(int i = 0; i <= (n - 1) / 2; ++i){
        dividable = 0;
        for(int j = 1; j <= n; ++j){
            if(0 == (2 * i + 1) % j){
                ++dividable;
            }
        }

        if(8 == dividable){
            ++count;
        }

    }

    std::cout << count << std::endl;

    return 0;
}


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

int main() {
  int h, w, k;
  cin>>h>>w>>k;
  string c[h];
  for (int i=0; i<h; i++) cin>>c[i];

  int ans = 0;
  for (int i=0; i<(1<<h); i++) {
    for (int j=0; j<(1<<w); j++) {
      int cnt = 0;
      for (int y=0; y<h; y++) {
        for (int x=0; x<w; x++) {
          bool cond1 = ((i >> y) & 1) == 0;
          bool cond2 = ((j >> x) & 1) == 0;
          bool cond3 = c[y][x] == '#';
          if (cond1 && cond2 && cond3) {
            ++cnt;
          }
        }
      }
      if (cnt == k) {
        ++ans;
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3632