akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <string>
#include <cmath>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <list>
#include <iostream>
#include <climits>
#include <cfloat>

using namespace std;

char buf[2000];

int main()
{
	cin.getline(buf, sizeof(buf));
	vector<pair<int, int> > v;
	int start = 0;
	for (int i = 0; buf[i] != '\0'; ++i)
	{
		char c = buf[i];
		if (c == ' ' || c == ',' || c == '.')
		{
			int len = i - start;
			if (3 <= len && len <= 6)
				v.push_back(make_pair(start, i-1));
			start = i+1;
		}
	}

	for (int i = 0; i < v.size(); ++i)
	{
		for (int j = v[i].first; j <= v[i].second; ++j)
			putchar(buf[j]);
		if (i != v.size()-1)
			putchar(' ');
	}
	putchar('\n');

	return 0;
}

Measured memory_bytes: 0
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
#define ALL(v) (v).begin(),(v).end()
typedef long long LL;
const int INF = 1 << 25;
const LL MOD = 1000000007LL;
using namespace std;
typedef pair<int, int> P;
LL h[100000];
int main() {
	int N;
	LL A, B;
	cin >> N >> A >> B;
	rep(i, N) cin >> h[i];
	LL l = 0, r = 1 << 30;
	while (r - l > 1) {
		LL m = (l + r) / 2;
		LL sum = 0;
		rep(i, N) {
			sum += (max(h[i] - B*m, 0LL) + (A - B) - 1) / (A - B);
		}
		if (sum <= m) r = m; else l = m;
	}
	cout << r << endl;
}

Measured memory_bytes: 1024
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
using Pair = System.Tuple<int, int>;
using Edge = System.Tuple<int, int, long>;
//using Debug;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var abc = Input.ar;
        if (abc[0] == abc[1] && abc[2] == abc[0])
            WriteLine("Yes");
        else WriteLine("No");
    }
}

public class Input
{
    public static string read => ReadLine();
    public  static int[] ar => Array.ConvertAll(read.Split(' '), int.Parse);
    public  static int num => ToInt32(read);
    public static long[] arL => Array.ConvertAll(read.Split(' '), long.Parse);
    public  static long numL => ToInt64(read);
    public static char[][] gred(int h) 
        => Enumerable.Repeat(0, h).Select(v => read.ToCharArray()).ToArray();
    public static int[][] twodim(int num)
        => Enumerable.Repeat(0, num).Select(v => ar).ToArray();
    public static long[][] twodimL(int num)
        => Enumerable.Repeat(0, num).Select(v => arL).ToArray();
    public const long Inf = (long)1e18;
    public const double eps = 1e-6;
    public  const string Alfa = "abcdefghijklmnopqrstuvwxyz";
    public  const int MOD = 1000000007;
}


Measured memory_bytes: 11092
import sys
import numpy as np
from numba import njit

readline = sys.stdin.readline

@njit('i8,i8,i8[::1]',cache=True)
def loop(n,k,a):
    for j in range(k):
        b = np.zeros(n+1, dtype=np.int64)
        for i in range(n):
            b[max(i-a[i], 0)] += 1
            b[min(i+a[i]+1, n)] -= 1
        a = np.cumsum(b)[:-1]
        if np.all(a==n):
            return(a)
            break
    else:
        return(a)


n, k = map(int, readline().split())
a = np.array(readline().split(), dtype=np.int64)

ans = loop(n,k,a)
print(*ans)

Measured memory_bytes: 129428
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;

typedef long long ll;

#define MOD 1000000007

int main() {
  int n, p;
  cin >> n >> p;
  string s;
  cin >> s;
  ll ans = 0;
  if (p == 2 || p == 5) {
    for (int i = n - 1; i >= 0; --i) {
      if ((s[i] - '0') % p == 0) {
        ans += (i + 1);
      }
    }
  } else {
    vector<int> pow10(n);
    pow10[0] = 1;
    for (int i = 1; i < n; ++i) {
      pow10[i] = (pow10[i - 1] * 10) % p;
    }
    map<int, int> mp;
    mp[0] = 1;
    int cur = 0;
    for (int i = n - 1; i >= 0; --i) {
      cur = ((pow10[n - 1 - i] * (s[i] - '0')) % p + cur) % p;
      ans += mp[cur];
      mp[cur]++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1668
#include <iostream>
#include <iomanip>
using namespace std;
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout << setprecision(12);

  int N;
  cin >> N;
  double ans = 0;
  for(int i = 0; i < N; ++i){
    double x;
    string u;
    cin >> x >> u;
    if(u == "BTC") x *= 380000;
    ans += x;
  }

  cout << ans << endl;
}


Measured memory_bytes: 256
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**7)
from collections import Counter, deque
from collections import defaultdict
from itertools import combinations, permutations, accumulate, groupby, product
from bisect import bisect_left,bisect_right
from heapq import heapify, heappop, heappush
from math import floor, ceil,pi,factorial
from operator import itemgetter
def I(): return int(input())
def MI(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def LI2(): return [int(input()) for i in range(n)]
def MXI(): return [[LI()]for i in range(n)]
def SI(): return input().rstrip()
def printns(x): print('\n'.join(x))
def printni(x): print('\n'.join(list(map(str,x))))
inf = 10**17
mod = 10**9 + 7

n=I()
lis=LI()
dp=[[0]*n for i in range(n)]
for i in range(n):
    if (n-1)%2==0:
        dp[i][i]=lis[i]
    else:
        dp[i][i]=-lis[i]
#print(dp)
for i in range(n-1,-1,-1):
    for j in range(n):
        #print(i,j)
        if i>=j:
            continue
        else:
            if (n-j+i-1)%2==0:
                if i+1>=n:
                    dp[i][j]=dp[i][j-1]+lis[j]
                elif j-1<0:
                    dp[i][j]=dp[i+1][j]+lis[i]
                else:
                    dp[i][j]=max(dp[i+1][j]+lis[i],dp[i][j-1]+lis[j])
            else:
                if i+1>=n:
                    dp[i][j]=dp[i][j-1]-lis[j]
                elif j-1<0:
                    dp[i][j]=dp[i+1][j]-lis[i]
                else:
                    dp[i][j]=min(dp[i+1][j]-lis[i],dp[i][j-1]-lis[j])
    #print(dp)
print(dp[0][-1])
        
            


Measured memory_bytes: 145172
using System;
using System.Linq;

class Program {
    static void Main(string[] args) {
            var data = Console.ReadLine().Split(' ').Select(double.Parse).ToArray();
            var tree = data[0];
            var canSeeTree = data[1] * 2 + 1;
            Console.WriteLine(Math.Ceiling(tree / canSeeTree));
    }
}


Measured memory_bytes: 13268
#include <bits/stdc++.h>
using namespace std;
 
#define int         long long
#define endl        "\n"
#define pii         pair<int, int>
#define vi          vector<int>
#define sz(x)       (int)x.size()
#define dint        long double


//////////////////////////////////////////////////////////////////////

const int mod = (int)1e9 + 7;
const int MX = 5e5+5;
int modpow(int a, int b);

inline int mul(int a, int b) {
    long long res = ((long long)a % mod * b % mod) % mod;
    return (int)res;
}

inline int add(int a, int b) {
    long long res = a + b;
    if(res >= mod) res -= mod;
    return (int)res;
}

inline int sub(int a, int b) {
    long long res = a - b;
    if(res < 0) res += mod;
    return (int)res;
}

long long pw(int a, int b) {
    long long res = 1;
    if(a < 2) return a;
    long long _a = a;
    while(b) {
        if(b % 2) res = res * _a;
        b /= 2;
        _a = _a * _a;
    }
    return res;
}

int modpow(int a, int b) {
    long long res = 1;
    if(a < 2) return a;
    while(b) {
        if(b % 2) res = mul(res, a);
        b /= 2;
        a = mul(a, a);
    }
    return res;
}

int MI(int a) {
    return modpow(a, mod - 2);
}

int fac[MX];
int ifac[MX];

void pre() {
    fac[0] = fac[1] = 1;
    ifac[0] = ifac[1] = 1;
    for(int i=2; i<MX; i++) fac[i] = mul(fac[i-1], i);
    for(int i=2; i<MX; i++) ifac[i] = MI(fac[i]);
}

long long C(int n, int k) {
    long long res = 1;
    res = mul(res, fac[n]);
    res = mul(res, ifac[k]);
    res = mul(res, ifac[n-k]);
    return res;
}

long long P(int n, int k) {
    long long res = 1;
    res = mul(res, fac[n]);
    res = mul(res, ifac[n-k]);
    return res;
}

//////////////////////////////////////////////////////////////////////



void solve(int TC) { 
    int N, M; cin >> N >> M;
    int ans = 0;
    for(int i=0; i<=N; i++) {
        int cur = 1;
        cur = mul(cur, C(N, i));
        cur = mul(cur, P(M, i));
        int remPos = N - i;
        int remNum = M - i;
        cur = mul(cur, P(remNum, remPos));
        cur = mul(cur, P(remNum, remPos));
        if(i % 2) ans = sub(ans, cur);
        else ans = add(ans, cur);
    }
    cout << ans << endl;
}
 
signed main() {
 
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(12);
    
    pre();

    int T = 1;
    //cin >> T;
    for(int i=1; i<=T; i++) {
        solve(i);
    }
    return 0;
 
}

Measured memory_bytes: 11444
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = 1e9 + 7;
const ll longinf = 1LL << 60;
const ll mod = 1e9 + 7;

int main() {
    int N;
    string S;
    cin >> N >> S;
    int need_open = 0, need_close = 0;
    for(int i = 0; i < N; i++) {
        if(S[i] == '(')
            need_close++;
        else {
            if(need_close == 0)
                need_open++;
            else
                need_close--;
        }
    }
    while(need_open--) cout << '(';
    cout << S;
    while(need_close--) cout << ')';
    return 0;
}


Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    long MOD = (long) 1e9 + 7;

    void run() {
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt(), k = sc.nextInt();
        Combination comb = new Combination(n + 1, MOD);

        for (int i = 1; i <= k; i++) {
            System.out.println(comb.nck(n - k + 1, i) * comb.nck(k - 1, i - 1) % MOD);
        }
    }

    static void debug(Object...os) {
        System.err.println(Arrays.deepToString(os));
    }

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

    static class Combination {
        int n;
        long mod;
        long[] facts;

        public Combination(int n, long mod) {
            this.n = n;
            this.mod = mod;
            facts = new long[n];
            facts[0] = 1;
            for (int i = 1; i < n; i++) {
                facts[i] = facts[i - 1] * i % mod;
            }
        }

        long modpow(long a, long b) {
            if (b == 0) return 1;
            else if (b == 1) return a;

            long x = modpow(a, b / 2);
            return b % 2 == 0 ? x * x % mod : x * (x * a % mod) % mod;
        }

        long inv(long n) {
            return modpow(n, mod - 2);
        }

        public long nck(int n, int k) {
            if (n < k) return 0;
            return facts[n] * (inv(facts[n - k]) * inv(facts[k]) % mod) % mod;
        }
    }
}


Measured memory_bytes: 24276
#include <stdio.h>

void riffle(int *card, int n);
void cut(int *card, int n, int k);

int main(void)
{
	int card[200] = {0};
	int m, n, k;
	int i;
	
	scanf("%d", &n);
	scanf("%d", &m);
	
	for (i = 0; i < 2 * n; i++){
		card[i] = i + 1;
		//printf("%d\n", card[i]);
	}
	
	for (i = 0; i < m; i++){
		scanf("%d", &k);
		if (k == 0){
			riffle(card, n);
		}
		else {
			cut(card, n, k);
		}
	}
	
	for (i = 0; i < 2 * n; i++){
		printf("%d\n", card[i]);
	}
	
	return (0);
}

void riffle(int *card, int n)
{
	int L[100], R[100];
	int i;
	int cnt = 0, cnt1 = 0, cnt2 = 0;
	
	for (i = 0; i < n; i++){
		L[i] = card[i]; //?????´????????????
	}
	
	for (i = n; i < 2 * n; i++){
		R[cnt] = card[i]; //?????´????????????
		cnt++;
	}
	
	//printf("R[1]=%d\n", R[1]);
	
	for (i = 0; i < 2 * n; i++){
		if (i % 2 == 0){
			card[i] = L[cnt1];
			cnt1++; //i?????¶??°??§????????°??£??\
		}
		else {
			card[i] = R[cnt2];
			cnt2++; //i????\???°??§????????°??£??\
		}
	}
}

void cut(int *card, int n, int k)
{
	int tmp_card[200] = {0};
	int i, j = 0;
	
	
	for (i = k; i < 2 * n; i++){
		tmp_card[j] = card[i]; // ?±±B?????????
		j++;
	}
	
	for (i = 0; i < k; i++){
		tmp_card[j] = card[i]; // ?±±A?????????
		j++;
	}
	
	for (i = 0; i < 2 * n; i++){
		card[i] = tmp_card[i];
	}
}

Measured memory_bytes: 600
#include <bits/stdc++.h>
using namespace std;
#define ALL(a) (a).begin(), (a).end()
#define FOR(i, s, n) for (int i = (s); i < (n); i++)
#define rep(i, n) FOR(i, 0, n)
#define repi(i, n) FOR(i, 1, n + 1)
#define pp(v) cout << #v "=" << (v) << endl;
#define ppa(v) cout << "----\n"; rep(i,v.size()) cout << #v << "[" << i << "] = " << v[i] << endl;
#define div_ceil(a,b) ((a) + ((b) - 1)) / (b)

int main() {
  int n,t; cin >> n >> t;
  int ans = 1e9;
  rep(i,n) {
    int c,tt; cin >> c >> tt;
    if (tt > t) continue;
    ans = min(ans, c);
  }
  if (ans == 1e9) {
    cout << "TLE" << endl;
  } else {
    cout << ans << endl;
  }
}

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

// {U}{INT,LONG,LLONG}_{MAX,MIN}
#define ALPHABET    (26)
#define INF         INT_MAX
#define MOD         (1000000007LL)
#define EPS         (1e-10)
#define EQ(a, b)    (abs((a)-(b)) < EPS)

using LL  = long long;

int di[] = {0, -1, 0, 1};
int dj[] = {1, 0, -1, 0};
// }}}

int main() {
    std::ios::sync_with_stdio(false);
    int h, w;cin >> h >> w;
    int c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            cin >> c[i][j];
        }
    }
    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                c[i][j] = min(c[i][j], c[i][k] + c[k][j]);
            }
        }
    }
    int ans = 0;
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            int a;cin >> a;
            if(a == 1 || a == -1) continue;
            ans += c[a][1];
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
#include<string>
#define REP(i,a,b) \
for(int i=a; i<b; i++)
#include<bits/stdc++.h>
#include<algorithm>
#define ll long long int
typedef vector<int> vi;
typedef pair<int,int> ii;
#define sz(a) int((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define present(c,x) ((c).find(x) != (c).end())
#define tr(c,i) for(typeof(c.begin()) i = (c).begin(); i != (c).end();i++)
int main()
{
	int n,m;
	cin >> n >> m;
	vector<char> v[n];
	REP(i,0,n)
	{
		REP(j,0,m)
		{
			char temp;
			cin >> temp;
			v[i].push_back(temp);
		}
	}
	vector<ll> dp[n];
	ll mod = 1000000007;
	REP(i,0,n)dp[i].resize(m,1);
	REP(i,1,n)
	{
		if(v[i][0] == '#')dp[i][0] = 0;
		else dp[i][0] = dp[i-1][0];
	}
	REP(j,1,m)
	{
		if(v[0][j] == '#')dp[0][j] = 0;
		else dp[0][j] = dp[0][j-1];
	}
	REP(i,1,n)
	{
		REP(j,1,m)
		{
			if(v[i][j] == '#')dp[i][j] = 0;
			else
			{
				dp[i][j] = dp[i-1][j]+dp[i][j-1];
				dp[i][j] = dp[i][j]%mod;
			}
		}
	}
	cout << dp[n-1][m-1];
}





Measured memory_bytes: 9088
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define rep2(i,x,n) for(int i=x; i<(n); i++)
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
int main()
{
    int k, x;
    cin >> k >> x;
    int left = max(-1000000, x - k + 1);
    int right = min(1000000, x + k);
    rep2(i, left, right) cout << i << " ";
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}
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;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ld ans = 0, per;
  // ll n;
  // cin >> n;
  ll n, k, x;
  cin >> n >> k;
  // ll n, m, k;
  // cin >> n >> m >> k;
  fi(1, n + 1) {
    per = 1;
    x = i;
    while(x < k) {
      per /= 2;
      x *= 2;
    }
    ans += per;
  }
  ans /= n;
  cout << setprecision(9) << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl '\n'
#define int long long
#define lint long long
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define FORR(i, a, b) for(int i = (a); i > (b); --i)
#define REP(i, n) FOR(i, 0, n)
#define SZ(v) ((int)v.size())
#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define FINF(a) memset(a, 0x3f, sizeof(a))
#define POW(n) (1LL << (n))
#define POPCNT(n) (__builtin_popcount(n))
#define IN(i, a, b) ((a) <= (i) && (i) <= (b))
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a > b) { a = b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a < b) { a = b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(begin(a), end(a)); }
template <typename T> inline void REV(T& a) { reverse(begin(a), end(a)); }
template <typename T> inline void UNI(T& a) { sort(a.begin(), a.end()); a.erase(unique(a.begin(), a.end()), a.end()); }
template <typename S, typename T> inline T LB(S& v, T a) { return *lower_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int LBP(S& v, T a) { return lower_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> inline T UB(S& v, T a) { return *upper_bound(begin(v), end(v), a); }
template <typename S, typename T> inline int UBP(S& v, T a) { return upper_bound(begin(v), end(v), a) - begin(v); }
template <typename S, typename T> ostream& operator << (ostream& os, const pair<S, T>& p) { os << p.first << " " << p.second; return os; }
template <typename S, typename T> istream& operator >> (istream& is, pair<S, T>& p) { is >> p.first >> p.second; return is; }
template <typename T> ostream& operator << (ostream& os, const vector<T>& v) { for (int i = 0; i < v.size(); ++i) { if (i) os << " "; os << v[i]; } return os; }
template <typename T> istream& operator >> (istream& is, vector<T>& v) { for(T& in : v) is >> in; return is; }
template <typename T = int> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a,make_v<T>(ts...)); }
template <typename T, typename V> typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) { t = v; }
template <typename T, typename V> typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) { for(auto &e : t) fill_v(e, v); }
const lint MOD = 1000000007;
const lint INF = 0x3f3f3f3f3f3f3f3f;
const double PI = 3.14159265358979323846;
const double EPS = 1e-10;

int N;
string S[1010];

void _main() {
    cin >> N;
    int ans = 0;
    REP (i, N) {
        cin >> S[i];
        ans += (S[i] == "E869120");
    }
    cout << ans << endl;
}

signed main(signed argc, char **argv) {
    if (argc > 1) {
        if (strchr(argv[1], 'i')) freopen("input.txt", "r", stdin);
        if (strchr(argv[1], 'o')) freopen("output.txt", "w", stdout);
    }
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed << setprecision(10);
    _main();
    return 0;
}


Measured memory_bytes: 3320
import java.util.Scanner;

public class Main{

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int k = Integer.parseInt(sc.next());
		int ans = 0;
		
		for(int i = 1 ; i <= k ;i++) {
			for(int j = 1 ; j <= k ; j++) {
				for(int l = 1 ; l <= k ; l++) {
					int temp = gcd(i,j);
					ans += gcd(temp,l);
				}
			}
		}
		
		System.out.println(ans);


	}
	
	static int gcd(int a , int b) {
		if(a < b) {
			return gcd(b,a);
		}
		int temp = 0 ;
		
		if(a == 0) {
			return b;
		}
		if(b == 0) {
			return a;
		}
		if(a != 0 || b != 0) {
		while (a % b != 0){
			temp = a;
			a = b;
			b = temp % b;
		}
		}
		return b;
	}
		
		
	}




Measured memory_bytes: 27452
def f(a):
	ans = ""
	s = a[0]
	c = 1
	for i in range(1,len(a)):
		if a[i] == s:
			c += 1
		else:
			ans += str(c) + s
			s = a[i]
			c = 1
	ans += str(c) + s
	return ans
	
while 1:
	n = input()
	if n == 0: break
	a = raw_input()
	for i in range(n):
		a = f(a)
	print a

Measured memory_bytes: 4996
#include<iostream>
#include <algorithm>
#include <functional>
#include<vector>
#include<math.h>
#include <assert.h>
#include<bitset>
#include<string>
#include <deque>
#include<queue>
#include <iomanip>
#include<map>
#include <random>
#include<type_traits>
#include<stack>
#include <sstream> 
#include <limits>
#include <numeric>
#include<string.h>
#include<set>
#include <climits>
using namespace std;
typedef unsigned long long ull;
#define ll long long int
static const double PI = 3.141592653589793;
const ll INF = 100000000000000;
ll mod = 1000000007;
//typedef vector<int> V;
//typedef vector<V> VV;
//typedef vector<VV> VVV;



int main() {
	string s;
	cin >> s;
	ll y[100005];
	for (ll i = 0; i < s.length(); i++)y[i] = 1;
	for (long long int i = 0; i < s.length()-2; i++) {
		if (s[i] == 'R' && s[i + 1] == 'R') {
			y[i + 2] += y[i];
			y[i] = 0;
		}
	}
	for (long long int i = s.length()-1; i >1; i--) {
		if (s[i] == 'L' && s[i - 1] == 'L') {
			y[i -2] += y[i];
			y[i] = 0;
		}
	}
	for (ll i = 0; i < s.length(); i++) {
		cout << y[i] << endl;
	}
}


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

int main()
{
	int V;
	cin >> V;
	vector<vector<int>> d(V, vector<int>(V));
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < V; j++) {
			cin >> d[i][j];
		}
	}
	long long res = 0;
	for (int i = 0; i < V; i++) {
		for (int j = 0; j < i; j++) {
			res += min(d[i][j], d[j][i]);
		}
	}
	cout << res << endl;
	return 0;
}

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

inline int read()
{
	int ret=0; char c=getchar();
	while(c<48||c>57)c=getchar();
	while(c>=48&&c<=57)ret=ret*10+c-48,c=getchar();
	return ret;
}

int fl;
char s[55];
int aa[55],o[55],n,a[55];

int main()
{
	scanf("%s",s+1); n=strlen(s+1);//s0 sn
	for(int i=1; i<=n; ++i)aa[i]=a[i]=s[i]-96;
	if(n==26){
		fl=0;
		for(int i=26; i; --i){
			if(a[i]!=27-i)fl=1;
		}
		if(!fl){
			puts("-1");
			return 0;
		}
		next_permutation(a+1,a+n+1);//  //
		for(int i=1; i<=n; ++i)
		{
		printf("%c",a[i]+96);//(int)
		if(a[i]!=aa[i])return 0;
		}
		exit(0);//return 0
	}
	for(int i=1; i<=n; ++i)o[a[i]]=1;
	cout<<s+1;//()
	for(int i=1; i<=26; ++i)if(!o[i]){
		printf("%c",i+96);
		return 0;
	}//...
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using vin=vector<int>;
const int inf=1e9+7;
const ll INF=1e18;


int main() {
 int a,b,c;
  cin>>a>>b>>c;
  int k;
  cin>>k;
  int ans=0;
  int x=max(max(a,b),c);
 ans=a+b+c-x;
  ans+=x*pow(2,k);
  cout<<ans<<endl;
}

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

int main() {
  string fo, ac;
  cin >> fo >> ac;
  int count = 0;
  
 if(fo.at(0) == ac.at(0)){
   count = count+1;
 }
 if(fo.at(1) == ac.at(1)){
   count = count+1;
 }
 if(fo.at(2) == ac.at(2)){
   count = count+1;
 }
  cout << count << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define pb push_back
#define fs first
#define sc second
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
using namespace std;

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

const int INFTY=1e9;

int main() {
    int i, j, k, n, ans;
    scanf("%d%d", &n, &k);
    vector<vi> f(n+2), b(n+2);
    vi a(n+1);
    for(i=1; i<=n; i++) scanf("%d", &a[i]);
    f[0]=b[n+1]=vi(k);
    f[0][0]=b[n+1][0]=1;
    for(i=1; i<=n; i++) {
        f[i]=f[i-1];
        for(j=k-1; j>=a[i]; j--) f[i][j]|=f[i][j-a[i]];
    }
    for(i=n; i>=1; i--) {
        b[i]=b[i+1];
        for(j=k-1; j>=a[i]; j--) b[i][j]|=b[i][j-a[i]];
    }
    for(i=n+1; i>=1; i--) {
        for(j=1; j<k; j++) b[i][j]+=b[i][j-1];
    }
    ans=0;
    for(i=1; i<=n; i++) {
        for(j=0; j<k; j++) if(f[i-1][j]) {
            if(j>=k-a[i] || b[i+1][k-1-j]>b[i+1][k-1-a[i]-j]) {
                ans++;
                break;
            }
        }
    }
    printf("%d\n", n-ans);
    return 0;
}

Measured memory_bytes: 195968
#include<algorithm>
#include <iostream>
#include<cstdio>
#include<cmath>
#include<iomanip>
#include<string>
using namespace std;
int main() {

	int a, b;
	cin >> a >> b;

	if (a % 2 == 1 && b % 2 == 1) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
a = input()
b = input()
a = int(a)
b = b.split()
b = [int(s) for s in b]
c = 0
flag = True
while True:
    
    for i in range(a):
        if b[i] % 2 != 0:
            flag = False
        b[i] = b[i] / 2
        
    if flag == False:
        break
    c += 1

    

    
print(c)

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int n,sum,ans;
string s;
int main()
{
	cin>>n>>s;
	for(int i=0;i<=s.size()-1;i++) 
		if(s[i]=='R')sum++;
	ans=sum;
	for(int i=0;i<=sum-1;i++) 
		if(s[i]=='R')
			ans--;
	cout<<ans;
}

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

int main() {
	// your code goes here
	long long int n,k;
	cin >> n >> k;
	long long int arr[n],sum=0;
	for(int i=0; i<n; i++)
	{
		cin >> arr[i];
	}
	sort(arr,arr+n);
	reverse(arr,arr+n);
	for(int j=0; j<k; j++)
	{
		if(j<n)
		arr[j]=0;
	}
	for(int i=0;i<n;i++)
	{
		sum=sum+arr[i];
	}
	cout << sum;
	
	
	return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
	#define D(x...) printf(x)
#else
	#define D(x...)
#endif
typedef long long ll;
int ans;
int main()
{
	int n;
	scanf("%d", &n);
	if (n < 3) printf("No\n");
	else
	{
		int m = n-3;
		if (m%4 != 0 && m%4 != 2 && m%4 != 3 && __builtin_popcount(n) == 1) printf("No\n"), exit(0);
		printf("Yes\n");
		printf("%d %d\n%d %d\n%d %d\n%d %d\n%d %d\n", 1, 2, 2, 3, 3, n+1, n+1, n+2, n+2, n+3);
		int upto = 4;
		bool sec = 1;
		int a = 0, b = 0;
		if (m%4 == 1 && (n & 4)) {}
		else
		{
			int largestbit = 0;
			for (int i = 0; i < 29; i++)
			{
				if (n & (1 << i)) largestbit = i;
			}
			a = (1 << largestbit);
			b = n-a;
		}
		while (m >= 4)
		{
			if (upto == 4) printf("%d %d\n", 1, upto);
			else if (sec && upto == a) printf("%d %d\n", b, a);
			else printf("%d %d\n", 4, upto);
			printf("%d %d\n", upto+3, upto);
			printf("%d %d\n", upto, upto+1);
			printf("%d %d\n", upto+1, upto+2);
			printf("%d %d\n", upto+2, n+upto+3);
			printf("%d %d\n", n+upto+3, n+upto);
			printf("%d %d\n", n+upto, n+upto+1);
			printf("%d %d\n", n+upto+1, n+upto+2);
			upto+=4;
			m-=4;
		}
		if (m == 1)
		{
			if (n & 4) // e.g n == 12
			{
				assert(upto == n);
				printf("%d %d\n", 2*n, 4);
				printf("%d %d\n", n-4, n);
			}
			else
			{
				printf("%d %d\n", n, b);
				printf("%d %d\n", a, 2*n);
			}
		}
		if (m >= 2)
		{
			printf("%d %d\n", upto+1, upto);
			printf("%d %d\n", upto, 1);
			printf("%d %d\n", 1, n+upto+1);
			printf("%d %d\n", n+upto+1, n+upto);
		}
		if (m == 3)
		{
			printf("%d %d\n", upto+2, n+upto+1);
			printf("%d %d\n", 2, n+upto+2);
		}
	}
}

Measured memory_bytes: 2688
#include <iostream>
#include <algorithm>

int main()
{
    int n;

    std::cin >> n;

    if (n == 0) {
        std::cout << "0" << std::endl;
        return 0;
    }

    int a = n;
    std::string binary;
    while (a != 0) {
        if (a % 2 != 0) {
            binary = binary + "1";
            a = (a - 1) / -2;
        } else {
            binary = binary + "0";
            a = a / -2;
        }

    }

    std::reverse(binary.begin(), binary.end());
    std::cout << binary << std::endl;

    return 0;
}


Measured memory_bytes: 256
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, gcd
from itertools import accumulate, permutations, combinations, product, groupby, combinations_with_replacement
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = [input() for _ in range(N)]
AC = 0
WA = 0
TLE = 0
RE = 0

for s in S:
    if s == "AC":
        AC += 1
    if s == "WA":
        WA += 1
    if s == "TLE":
        TLE += 1
    if s == "RE":
        RE += 1

print("AC x {}".format(AC))
print("WA x {}".format(WA))
print("TLE x {}".format(TLE))
print("RE x {}".format(RE))


Measured memory_bytes: 17260
/*
    Life Before Death, Strength Before Weakness, Journey Before Destination
    ------------------------------------------------------------------------
    You don't become great by trying to be great.
    You become great by wanting to do something,
    and then doing it so hard that you become great in the process.
    */

    //#pragma comment(linker, ack:200000000")
    #pragma GCC optimize ("Ofast")
    #pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
    #include <bits/stdc++.h>
    using namespace std;
    #define rep(i, n)    for(ll i = 0; i < (n); ++i)
    #define repA(i, a, n)  for(ll i = a; i <= (n); ++i)
    #define repD(i, a, n)  for(ll i = a; i >= (n); --i)
    #define trav(a, x) for(auto& a : x)
    #define all(x) x.begin(), x.end()
    #define sz(x) (int)(x).size()
    #define fill(a)  memset(a, 0, sizeof (a))
    #define fst first
    #define snd second
    //#define mp make_pair
    #define pb push_back
    #define PI           3.141592653589793238462643383279502884197169399  /* pi */
    // #define te
    typedef long double ld;
    typedef long long ll;
    typedef pair<ll, ll> pii;
    typedef vector<ll> vi;
    const int maxN = 200100;
    typedef pair<pii, ll> piii;

    void solve() {
        ll a, b;
        cin >> a >> b;
        ll g = __gcd(a, b);
        ll cnt = (a*b)/g;
        cout << cnt << endl;
    }

    int main() {
      cin.sync_with_stdio(0); cin.tie(0);
      cin.exceptions(cin.failbit);
      // ll ti;   cin >> ti;  while(ti--)
      solve();
      return 0;
    }


Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <algorithm>
#include <vector>
#include <cassert>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(int i=0;i<x;i++)
#define repn(i,x) for(int i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
int h,w;
string s[405];
int par[200005],ran[200005];
void init(){ for(int i=0;i<200005;i++) par[i] = i; }
int find(int x){ if(x == par[x]) return x; else return par[x] = find(par[x]); }
void unite(int x,int y){
	x = find(x); y = find(y); if(x==y) return;
	if(ran[x] < ran[y]) par[x] = y;
	else{
		par[y] = x;
		if(ran[x] == ran[y]) ran[x]++;
	}
}
bool same(int x,int y){ return find(x)==find(y); }
int cnt[200005][2];
int main(){
	cin>>h>>w;
	int n = h, m = w;
	rep(i,h){
		cin>>s[i];
	}
	init();
	rep(i,h){
		rep(j,w){
			int dx[4]={0,1,0,-1};
			int dy[4]={1,0,-1,0};
			rep(k,4){
				int nx = i+dx[k];
				int ny = j+dy[k];
				if(0<=nx&&nx<n&&0<=ny&&ny<m&&s[i][j] != s[nx][ny]){
					unite(i*401+j,nx*401+ny);
				}
			}
		}
	}
	rep(i,h){
		rep(j,w){
			cnt[find(i*401+j)][(s[i][j]=='#')] ++;
		}
	}
	ll ans = 0;
	for(int i=0;i<200005;i++) ans+=1LL*cnt[i][0]*cnt[i][1];
	cout<<ans<<endl;
}

Measured memory_bytes: 3200
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int arr[] =new int[n];
        for(int i=0;i<n;i++){
            arr[i]=sc.nextInt();
        }
        int ret =0;
        for(int i=1;i<=n;i++){
            if (i <= arr[i-1]&&arr[arr[i-1]-1]==i){
                ret++;
            }

        }
        System.out.println(ret);
    }

 }


Measured memory_bytes: 32136
// バケット法による解
#include <iostream>
using namespace std;

int main() {
    int N;
    int d[110];
    cin >> N;
    for (int i = 0; i < N; ++i) cin >> d[i];

    int num[110] = {0};  // バケット
    for (int i = 0; i < N; ++i) {
        num[d[i]]++;  // d[i] が 1 個増える
    }

    int res = 0;  // 答えを格納
    for (int i = 1; i <= 100; ++i) {  // 1 <= d[i] <= 100 なので 1 から 100 まで探索
        if (num[i]) {  // 0 より大きかったら
            ++res;
        }
    }
    cout << res << endl;
}



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

const int N=2e5+20,MOD=1e9+7;

int n,k,zero,neg;
long long x,ans=1;
vector <pair <long long,int>> v;

int main()
{
	scanf("%d%d",&n,&k);
	for(int i=0;i<n;i++)
	{
		scanf("%lld",&x);
		if(x>0) v.push_back({x,+1});
		else if(x<0) v.push_back({-x,-1});
		else v.push_back({x,0});
	}

	sort(v.begin(),v.end(),greater <pair <long long,int>>());
	for(int i=0;i<k;i++)
	{
		ans=(ans*v[i].first)%MOD;
		if(v[i].second==-1) neg++;
	}

	if(neg%2==0) return 0 * printf("%lld",ans);

	int lneg=-1,lpos=-1;
	for(int i=k-1;i>=0;i--)
		if(v[i].second==-1 and lneg==-1) lneg=i;
		else if(v[i].second==1 and lpos==-1) lpos=i;

	int rneg=-1,rpos=-1;
	for(int i=k;i<n;i++)
		if(v[i].second==-1 and rneg==-1) rneg=i;
		else if(v[i].second==1 and rpos==-1) rpos=i;

	bool case1=false,case2=false;
	if(lneg!=-1 and rpos!=-1) case1=true;
	if(lpos!=-1 and rneg!=-1) case2=true;

	if(case1 or case2) ans=1;
	if(case1 and case2)
	{
		if(1ll*v[rpos].first*v[lpos].first>=1ll*v[rneg].first*v[lneg].first)
		{
			for(int i=0;i<k;i++)
				if(i!=lneg) ans=(ans*v[i].first)%MOD;
			ans=(ans*v[rpos].first)%MOD;
		}
		else
		{
			for(int i=0;i<k;i++)
				if(i!=lpos) ans=(ans*v[i].first)%MOD;
			ans=(ans*v[rneg].first)%MOD;
		}
	}
	else if(case1)
	{
		for(int i=0;i<k;i++)
				if(i!=lneg) ans=(ans*v[i].first)%MOD;
			ans=(ans*v[rpos].first)%MOD;
	}
	else if(case2)
	{
		for(int i=0;i<k;i++)
				if(i!=lpos) ans=(ans*v[i].first)%MOD;
			ans=(ans*v[rneg].first)%MOD;
	}
	else if(v.back().second==0) ans=0;
	else
	{
		ans=1;
		for(int i=n-1;i>n-1-k;i--)
			ans=(ans*v[i].first)%MOD;
		ans=(MOD-ans)%MOD;
	}
	printf("%lld",ans);
}

Measured memory_bytes: 7420
<?php

fscanf(STDIN, "%d %d %d %d", $sx, $sy, $tx, $ty);

$x = $tx - $sx;
$y = $ty - $sy;

for($cntY=0;$cntY<$y;$cntY++){
	print('U');
}

for($cntX=0;$cntX<$x;$cntX++){
	print('R');
}

for($cntY=0;$cntY<$y;$cntY++){
	print('D');
}

for($cntX=0;$cntX<$x;$cntX++){
	print('L');
}

print('L');

for($cntY=0;$cntY<$y+1;$cntY++){
	print('U');
}

for($cntX=0;$cntX<$x+1;$cntX++){
	print('R');
}

print('DR');

for($cntY=0;$cntY<$y+1;$cntY++){
	print('D');
}

for($cntX=0;$cntX<$x+1;$cntX++) {
	print('L');
}	

print('U');

Measured memory_bytes: 4604
private fun readStrings() = readLine()!!.split(" ")
private fun readInts() = readStrings().map { it.toInt() }

fun main(args: Array<String>) {
    val N = readInts()[0]
    val p = readInts()
    val arrangedElements = p.mapIndexed { index, pi -> pi == index + 1 }
    val arrangedGroupSizes = mutableListOf<Int>()

    var previousArranged = false
    var continuousArrangedCounts = 0
    for (arranged in arrangedElements + listOf(false)) {
        if (arranged) {
            continuousArrangedCounts += 1
            previousArranged = true
        } else {
            if (previousArranged) {
                arrangedGroupSizes.add(continuousArrangedCounts)
                continuousArrangedCounts = 0
            }
            previousArranged = false
        }
    }

    println(arrangedGroupSizes.map { (it + 1) / 2 }.sum())
}

Measured memory_bytes: 51716
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;
typedef pair<double, double> P;

void solve()
{
	int n;
	while(cin >> n, n)
	{
		vector<P> pin(n);
		char c;
		for(int i = 0; i < n; ++i)
		{
			cin >> pin[i].first >> c >> pin[i].second;
		}
		sort(pin.begin(), pin.end());
		if(pin[0].first == pin[1].first && pin[0].second > pin[1].second)
		{
			P p = pin[0];
			pin[0] = pin[1];
			pin[1] = p;
		}
		bool isUsed[101] = {false};
		isUsed[0] = true;
		P current = pin[0];
		bool update = true;
		while(update)
		{
			update = false;
			double max_slope = -99999999;
			int max_pin = 0;
			for(int i = 1; i < n; ++i)
			{
				if(current.first < pin[i].first)
				{
					if(max_slope < (pin[i].second - current.second) / (pin[i].first - current.first))
					{
						max_slope = (pin[i].second - current.second) / (pin[i].first - current.first);
						max_pin = i;
						update = true;
					}
				}
			}
			if(update)
			{
				isUsed[max_pin] = true;
				current = pin[max_pin];
			}
		}
		current = pin[0];
		update = true;
		while(update)
		{
			update = false;
			double min_slope = 99999999;
			int min_pin = 0;
			for(int i = 1; i < n; ++i)
			{
				if(current.first < pin[i].first)
				{
					if(min_slope > (pin[i].second - current.second) / (pin[i].first - current.first))
					{
						min_slope = (pin[i].second - current.second) / (pin[i].first - current.first);
						min_pin = i;
						update = true;
					}
				}
			}
			if(update)
			{
				isUsed[min_pin] = true;
				current = pin[min_pin];
			}
		}
		int ans = 0;
		for(int i = 0; i < n; ++i)
		{
			if(isUsed[i] == false)
			{
				++ans;
			}
		}
		cout << ans << endl;
	}
}

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

Measured memory_bytes: 1236
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
const ll INF=ll(1e18)+1;
int main() {
  ios::sync_with_stdio(false);
	cin.tie(0);
  string s;
  ll n;
  cin>>s;
  n=s.size();

  reverse(s.begin(),s.end());
  s+='0';
  ll dp[n+2][2];
  rep(i,n+2)rep(j,2)dp[i][j]=INF;
  dp[0][0]=0;
  //1 繰りさがり
  rep(i,n+1){
     rep(j,2){
       ll now=s[i]-'0';
       if (j==1)now++;
    //   cout<<now<<'n';
      // if (now)
       if(now<10)
      dp[i+1][0]=min(dp[i+1][0],dp[i][j]+now);
      if(now>0)
        dp[i+1][1]=min(dp[i+1][1],dp[i][j]+10-now);
     }
     //cout<<dp[i+1][0]<<endl;
  //   cout<<dp[i+1][1]<<endl;


  }
cout<<dp[n+1][0]<<endl;
//  cout<<dp[n][0]<<' '<<dp[n][1];

}


Measured memory_bytes: 17052
#!/usr/bin python3
# -*- coding: utf-8 -*-

def main():
    N = int(input())
    P = list(int(input()) for _ in range(N))
    dp = [0]*(N+1)   #dp[i]:１づつ増加する部分列の最大の数字がiとなるものの最大長さ

    ret = 0;
    for p in P:
        dp[p] = dp[p - 1] + 1
        ret = max(ret, dp[p])

    print(N - ret)

if __name__ == '__main__':
    main()

Measured memory_bytes: 24640
n = int(input())
s = list(input())

ans = 0
s1 = ''
s2 = ''

for i in range(1, n):
    s1 = set(s[:i])
    s2 = set(s[i:])
    tmp = 0
    for c in s1:
        if(c in s2):
            tmp += 1
    if(ans < tmp):
        ans = tmp

print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
const long long inf = 1e15;
typedef long long ll;
typedef long double ld;
typedef pair <ll, ll> pii;

void faster()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

const ll MAXN = 1e6 + 10;
const ll N = 4000 + 10;
const ll MN = 200 + 10;
const ll mod = 1e6;

ll a[MAXN] , dp[MAXN];
pii p[MAXN];


int main()
{
	faster();
	int n;
	cin >> n;
	for (int i = 0; i < n; i++)
		dp[i] = inf;
	for (int i = 0; i < n; i++)
		cin >> a[i];
	dp[0] = 0;
	dp[1] = abs(a[1] - a[0]);
	for (int i = 2; i < n; i++)
	{
		dp[i] = min(dp[i - 1] + abs(a[i] - a[i - 1]), dp[i - 2] + abs(a[i] - a[i - 2]));
	}
	cout << dp[n - 1] << endl; 
}

Measured memory_bytes: 6400
#include <iostream>
#include <iomanip>
#include <vector>
#include <map>
#include <queue>
#include <algorithm>

using namespace std;

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

  vector<int> v1(100001), v2(100001);
  int temp;
  for (int i = 0; i < n; i++) {
    cin >> temp;
    if (i % 2 == 0) {
      v1[temp]++;
    } else {
      v2[temp]++;
    }
  }

  vector<pair<int, int> > p1(100001), p2(100001);
  for (int i = 0; i <= 100000; i++) {
    p1[i] = make_pair(v1[i], i);
    p2[i] = make_pair(v2[i], i);
  }

  sort(p1.begin(), p1.end());
  sort(p2.begin(), p2.end());

  int ind1 = 100000;
  int ind2 = 99999;
  if (p1[ind1].second != p2[ind1].second) {
    cout << n - p1[ind1].first - p2[ind1].first << endl;
  } else {
    cout << n - max(p1[ind1].first + p2[ind2].first, p1[ind2].first + p2[ind1].first) << endl;
  }

  return 0;
}


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

using namespace std;

using int64 = long long;

int main()
{
  // W/(W+B)≧ P/100
  // W*100  ≧ P(W+B)
  // W*100-PW-PB≧0
  // (100-P)W-PB≧0

  int N, P;
  cin >> N >> P;
  int64 all = 0LL;
  vector< int64 > vs;
  for(int i = 0; i < N; i++) {
    int64 W, B;
    cin >> W >> B;
    all += P * B;
    vs.emplace_back((100 - P) * W + P * B);
  }
  sort(begin(vs), end(vs));
  reverse(begin(vs), end(vs));
  for(int i = 0; i < N; i++) {
    all -= vs[i];
    if(all <= 0) {
      cout << i + 1 << endl;
      return (0);
    }
  }
}

Measured memory_bytes: 1400
#include <bits/stdc++.h>
#define show(x) cerr << #x << " = " << x << endl
using namespace std;
using ll = long long;
using ld = long double;
constexpr ll MOD = 1000000007LL;
template <typename T>
constexpr T INF = numeric_limits<T>::max() / 10;
template <typename Functor>
struct fix_type
{
    Functor functor;
    template <typename... Args>
    decltype(auto) operator()(Args&&... args) const& { return functor(functor, std::forward<Args>(args)...); }
};
template <typename Functor>
fix_type<typename std::decay<Functor>::type> fix(Functor&& functor) { return {std::forward<Functor>(functor)}; }

int main()
{
    int N;
    cin >> N;
    vector<ll> X(N);
    for (int i = 0; i < N; i++) {
        cin >> X[i];
    }
    auto x = X;
    sort(x.begin(), x.end());
    const ll left = x[N / 2 - 1];
    const ll right = x[N / 2];
    for (int i = 0; i < N; i++) {
        if (X[i] <= left) {
            cout << right << endl;
        } else {
            cout << left << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 5376
#include <set>
#include <map>
#include <queue>
#include <ctime>
#include <cmath>
#include <cstdio>
#include <bitset>
#include <vector>
#include <cstring>
#include <cassert>
#include <iostream>
#include <algorithm>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const ld pi=acos(ld(-1));	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
const int maxn=2e5+5;
int tot,n;
pa q[maxn];
int X1,Y1,X2,Y2,dx=1,dy=1;
vector<int>f;
ld ans;
int main(){
	read(X1);read(Y1);read(X2);read(Y2);
	if(X1>X2)X1*=-1,X2*=-1,dx*=-1;
	if(Y1>Y2)Y1*=-1,Y2*=-1,dy*=-1;
	read(n);
	rep(i,1,n){
		int x,y;read(x);read(y);
		x*=dx;y*=dy;
		if(x<X1||x>X2||y<Y1||y>Y2)continue;
		q[++tot]=mp(x,y);
	}
	sort(q+1,q+tot+1);
	rep(i,1,tot){
		if(!SZ(f)||q[i].w2>f.back())f.pb(q[i].w2);
		else{
			int j=lower_bound(All(f),q[i].w2)-f.begin();
			f[j]=q[i].w2;
		}
	}
	if(min(X2-X1,Y2-Y1)+1==SZ(f)){
		f.pop_back();
		ans+=10*pi-20;
	}
	ans+=(X2-X1+Y2-Y1)*100.;
	ans-=(20-5*pi)*SZ(f);
	printf("%.12f\n",double(ans));
	return 0;
}

Measured memory_bytes: 2936
#include<stdio.h>

int main(void)
{
   int a, b, c, d, e, f;

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

   if(a>b) e = b;
   else    e = a;

   if(c>d) f=d;
   else    f=c;

   printf("%d\n", e+f);
   return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define rep2(i, x, n) for(int i = x, i##_len = (n); i < i##_len; ++i)
#define all(n) begin(n), end(n)
using ll = long long;
using P = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vc = vector<char>;
using vb = vector<bool>;
using vd = vector<double>;
vi dir = {-1, 0, 1, 0, -1, -1, 1, 1, -1};

int main() {
  ll n;
  cin >> n;
  vl v(n, 1);
  rep(i, n) {
    ll a;
    cin >> a;
    a *= -1;
    auto it = upper_bound(all(v), a);
    *it = a;
  }
  cout << lower_bound(all(v), 1) - v.begin() << endl;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

const ll mod = 1000000007;

int main() {
    string S;
    int ans = 0;
    cin >> S;
    vector<string> array = {"SUN", "MON", "TUE", "WED", "THU", "FRI", "SAT"};
    rep(i, 7){
        if(array[i] == S){
            ans = 7 - i;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
p=print
b=1
for e in iter(input,'0 0'):
 b or p()
 b=f=0;s,t=map(int,e.split())
 for y in range(s,t+1):
  if(y%4==0)*(y%100)or y%400==0:p(y);f=1
 f or p('NA')


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

int main() {
	int n, k;
	cin >> n >> k;
	long long sum[n + 1], p;
	sum[0] = 0;
	for (int i = 1; i <= n; i++) {
		cin >> p;
		sum[i] = sum[i - 1] + p + 1;
	}
		
	long long res = 0;
	for (int i = 0; i < n - k + 1; i++) {
		res = max(res, sum[i + k] - sum[i]);
	}
	cout << fixed << setprecision(11);
	cout << res / 2.0;
  	return 0;
}

Measured memory_bytes: 1792