akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
  public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};

ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);
}

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

const string YES = "YES";
const string NO = "NO";

void solve(std::string S){
    int lost=0;
    for (int i = 0; i < S.size(); i++)
    {
     if(S[i] == 'x') lost++;   
    }

    if(lost <=7){
        cout << YES << endl;
    }else{
        cout << NO << endl;
    }
    
}

int main(){
    std::string S;
    std::cin >> S;
    solve(S);
    return 0;
}


Measured memory_bytes: 256
public class Main {
	
	public static void main(String[] args) {
		List list = new List();
		
		int n = nextInt();
		
		for (int i = 0; i < n; i ++) {
			next();
			if(nextlen > 7) {
				if (nextbuf[6] == 'F') {
					list.deleteFirst();
				} else {
					list.deleteLast();
				}
			} else if (nextbuf[0] == 'd') {
				list.delete(nextInt());
			} else {
				list.insert(nextInt());
			}
		}
		
		List.Node cur = list.nil.next;
		System.out.print(cur.key);
		cur = cur.next;
		
		for (; cur != list.nil; cur = cur.next) {
			System.out.print(" ");
			System.out.print(cur.key);
		}
		System.out.println();
	}
	
	private static class List {
		private static class Node {
			int key;
			Node next, prev;
		}
		
		private Node nil;
		
		private List() {
			nil = new Node();
			nil.next = nil;
			nil.prev = nil;
		}
		
		private void insert(int key) {
			Node x = new Node();
			x.key = key;
			x.next = nil.next;
			nil.next.prev = x;
			nil.next = x;
			x.prev = nil;
		}
		
		private void deleteNode(Node t) {
			t.prev.next = t.next;
			t.next.prev = t.prev;
		}
		
		private void delete(int key) {
			Node cur = nil.next;
			while(cur.key != key) {
				if (cur == nil) return;
				cur = cur.next;
			}
			deleteNode(cur);
		}
		
		private void deleteFirst() {
			deleteNode(nil.next);
		}
		
		private void deleteLast() {
			deleteNode(nil.prev);
		}
	}
	
	private static byte[] buf = new byte[1 << 20];
	private static int len = 0;
	private static int ptr = 0;
	
	private static byte read() {
		if (ptr >= len) {
			try {
				len = System.in.read(buf);
			} catch (Exception e) {
			}
			ptr = 0;
		}
		
		return buf[ptr++];
	}
	
	private static int nextInt() {
		int num = 0;
		
		byte b = read();
		while(!Character.isDigit(b)) b = read();
		while(Character.isDigit(b)) {
			num *= 10;
			num += b - '0';
			b = read();
		}
		
		return num;
	}
	
	private static byte[] nextbuf = new byte[11];
	private static int nextlen;
	
	private static void next() {
		nextlen = 0;
		
		byte b = read();
		while(!Character.isAlphabetic(b) && !Character.isDigit(b)) b = read();
		while(Character.isAlphabetic(b) || Character.isDigit(b)) {
			nextbuf[nextlen++] = b;
			b = read();
		}
	}
}



Measured memory_bytes: 68376
#include <iostream>
#include <vector>

using namespace std;

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

    vector<int> sunuke(N), d(K);
    for(int i=0;i<N;i++)sunuke.at(i) = 1;

    for(int i=0;i<K;i++){
        cin >> d.at(i);
        for(int j=0;j<d.at(i);j++){
            int a;
            cin >> a;
            sunuke.at(a-1) = 0;
        }
    }

    int cnt = 0;
    for(int i=0;i<N;i++){
        if(sunuke.at(i)==1)cnt++;
    }

    cout << cnt << endl;
}

Measured memory_bytes: 3628
local n, p = io.read("*n", "*n")
local ev, od = {}, {}
local a = io.read("*n")
if(a % 2 == 0) then ev[1], od[1] = 2, 0
else ev[1], od[1] = 1, 1 end
for i = 2, n do
  a = io.read("*n")
  if(a % 2 == 0) then
    ev[i] = ev[i - 1] * 2
    od[i] = od[i - 1] * 2
  else
    ev[i] = ev[i - 1] + od[i - 1]
    od[i] = ev[i - 1] + od[i - 1]
  end
end
if(p == 0) then print(ev[n]) else print(od[n]) end


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
using static System.Console;
using System.Text;
using System.IO;
using static System.Math;
namespace AtCoder
{
    class Program
    {
        static public int[] Sarray() { return ReadLine().Split().Select(int.Parse).ToArray(); }
        static public List<int> Slist() { return ReadLine().Split().Select(int.Parse).ToList(); }

        static int N;
        static int[,] Move;
        static int[] dp;
        static List<int>[] inpath;
        static void Main(string[] args)
        {
            var NM = Sarray();
            var N = NM[0];
            var M = NM[1];
            var outpath = new List<int>[N];
            inpath = new List<int>[N];
            for (var i = 0; i < N; ++i)
            {
                outpath[i] = new List<int>();
                inpath[i] = new List<int>();
            }
            for (var i = 0; i < M; ++i)
            {
                var t = Sarray();
                outpath[t[0] - 1].Add(t[1] - 1);
                inpath[t[1] - 1].Add(t[0] - 1);
            }
            dp = new int[N].Select(_ => -1).ToArray();
            var dst = new List<int>();
            for (var i = 0; i < N; ++i)
            {
                if (!outpath[i].Any())
                    dst.Add(i);
                if (!inpath[i].Any())
                    dp[i] = 0;
            }
            foreach (var v in dst)
            {
                foreach (var ie in inpath[v])
                    dp[v] = Max(dp[v], calclen(ie) + 1);
            }
            WriteLine(dp.Max());
        }
        static int calclen(int v)
        {
            if (0 <= dp[v])
                return dp[v];
            foreach (var ie in inpath[v])
                dp[v] = Max(dp[v], calclen(ie) + 1);
            return dp[v];
        }
    }
}

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

flag = 0

if n % 2 == 0 :
    for i in range(n // 2) :
        if s[i] != s[i + n // 2] :
            flag = 1
else :
    flag = 1

if flag == 1 :
    print('No')
else :
    print('Yes')

Measured memory_bytes: 2940
/**/
#include <iostream>
#include <vector>
#include <cstdlib>
#include <ctime>
using namespace std;

int CalcTheDaySatisfaction(int d, const int N, vector<int>& c, vector<int>& s, int t, vector<int>& last)
{
    int ret = 0;

    // d日目にA[t]Cを開催すると上がる満足度を足す
    ret += s[t];

    // 低下する満足度を計算する
    for( int i = 0; i < N; ++i )
        ret -= c[i] * (d - last[i]);

    return ret;
}


int main()
{
    const int N = 26;

    // 入力
    int D;
    cin >> D;

    vector<int> c(N);
    for( int i = 0; i < N; ++i )
        cin >> c[i];

    vector<vector<int>> s(D);
    for( int i = 0; i < D; ++i ){
        vector<int> tmp(N);
        for( int j = 0; j < N; ++j )
            cin >> tmp[j];
        s[i] = tmp;
    }

    // 初期解生成
    srand((int)time(0));

    vector<int> t(D);
    for( int i = 0; i < D; ++i )
        t[i] = rand() % N;

    // 満足度計算
    int initialSatisfication = 0;
    vector<int> last(N, 0);
    for( int i = 0; i < D; ++i ){
        // last(d, i)を更新する
        last[t[i]] = i + 1;

        // 満足度を更新する
        initialSatisfication += CalcTheDaySatisfaction(i + 1, N, c, s[i], t[i], last);
    }

    int M = 0;
    for( int i = 0; i < M; ++i ){
        int d = rand() % D;
        int q = rand() % N;

        int modificationSatisfication = 0;
        for( int i = 0; i < D; ++i ){
            if( i == d ){
                // last(d, i)を更新する
                last[q] = i + 1;
                // 満足度を更新する
                modificationSatisfication += CalcTheDaySatisfaction(i + 1, N, c, s[i], q, last);
            }
            else {
                // last(d, i)を更新する
                last[t[i]] = i + 1;
                // 満足度を更新する
                modificationSatisfication += CalcTheDaySatisfaction(i + 1, N, c, s[i], t[i], last);
            }
        }

        if( initialSatisfication < modificationSatisfication )
            t[d] = q;
    }

    // 出力
    for( auto& i : t )
        cout << i + 1 << endl;

    /*
    // B, C問題
    //// 入力
    vector<int> t(D);
    for( int i = 0; i < D; ++i )
        cin >> t[i];
    for( int i = 0; i < D; ++i )
        --t[i];

    int M;
    cin >> M;

    vector<int> d(M), q(M);
    for( int i = 0; i < M; ++i )
        cin >> d[i] >> q[i];
    for( int i = 0; i < M; ++i )
        --d[i], --q[i];

    //// 満足度計算
    vector<int> satisfication(D, 0);
    vector<int> last(N, 0);
    for( int i = 0; i < D; ++i ){
        // last(d, i)を更新する
        last[t[i]] = i + 1;

        // 各日の満足度を計算する
        satisfication[i] = CalcTheDaySatisfaction(i + 1, N, c, s[i], t[i], last);
    }

    //// クエリ処理
    vector<int> modificationSatisfication = satisfication;
    for( int i = 0; i < M; ++i ){

        modificationSatisfication[i] = CalcTheDaySatisfaction(d[i] + 1, N, c, s[i], q[i], last);
    }

    // 出力
    cout << satisfication << endl;
    }
    /**/



    return 0;
}
/**/

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

#define for_(i,a,b) for(int i=(a);i<(b);++i)

int main() {
	int n, coin[6] = {500, 100, 50, 10, 5, 1};
	
	while (cin >> n, n) {
		int nn = 1000 - n, ans = 0;
		
		for_(i,0,6) {
			int d = nn / coin[i];
			ans += d;
			nn -= d * coin[i];
		}
		
		cout << ans << endl;
	}
}

Measured memory_bytes: 1164
#include <stdio.h>

int main() 
{
int i;
double a,p,N;
scanf ("%lf",&N);
for (i=1;i<=N;i++)
{
    if (i%2==1)
    {
         a++;
    }
}
p=a/N;
printf ("%.10lf\n",p);
    return 0;
}

Measured memory_bytes: 1720
#include <stdio.h>

int main(void){
	int x1,y1,x2,y2;
	int dx,dy;
	scanf("%d %d %d %d",&x1,&y1,&x2,&y2);
	dx = x2 - x1;
	dy = y2 - y1;
	printf("%d %d %d %d\n",x2-dy,y2+dx,x1-dy,y1+dx);
	return 0;
}

Measured memory_bytes: 128
from copy import deepcopy
from functools import reduce


class Divisor:
    def __init__(self, n):
        """ make divisors list and prime factorization list of n
            complexity: O(n^(1/2))
            used in ProjectEuler No.12, yukicoder No.36
        """
        assert(n >= 1)
        number = n
        if number == 1:
            self.primeFactorization = {1: 1}
        else:
            self.primeFactorization = {}
            for i in range(2, int(n**0.5)+1):
                cnt = 0
                while number % i == 0:
                    cnt += 1
                    number //= i
                if cnt > 0:
                    self.primeFactorization[i] = cnt
            if number > 1:
                self.primeFactorization[number] = 1

    def primeFactors(self):
        return deepcopy(self.primeFactorization)

    def numDivisors(self):
        """ the number of divisors """
        if self.primeFactorization.get(1, 0) == 1:
            return 1
        numDiv = 1
        for _, cnt in self.primeFactorization.items():
            numDiv *= cnt+1
        return numDiv

    def sumDivisors(self):
        return reduce(lambda x, y: x * y, [sum(p**i for i in range(n+1)) for p, n in self.primeFactorization.items()])


def divisorsList(n):
    assert(n >= 1)
    divsList = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divsList.append(i)
            if n // i != i:
                divsList.append(n//i)
    return sorted(divsList)


def subsum(arr, M):
    dp = [0] * (M + 1)
    prev = [-1] * (M + 1)
    dp[0] = 1
    for x in reversed(arr):
        for i in reversed(range(M + 1)):
            if dp[i] and i + x <= M and not dp[i + x]:
                dp[i + x] = 1
                prev[i + x] = i
    assert dp[-1]
    ans = []
    now = M
    while prev[now] != -1:
        ans.append(now - prev[now])
        now = prev[now]
    return ans


def dfs(groups, i, now):
    if i == len(groups):
        print(*now)
        return
    for x in groups[i]:
        now.append(x)
        dfs(groups, i + 1, now)
        now.pop()


def main(N):
    sumall = N * (N + 1) // 2
    group_num = divisorsList(sumall)[1]
    groups = []
    selected = set()
    rest = list(range(1, N + 1))
    for i in range(group_num):
        g = subsum(rest, sumall // group_num)
        groups.append(g)
        selected |= set(g)
        rest = [x for x in rest if x not in selected]
        #print(g, rest)
    edges = []
    for i in range(len(groups)):
        for j in range(len(groups)):
            if i >= j:
                continue
            for x1 in groups[i]:
                for x2 in groups[j]:
                    edges.append((x1, x2))
    print(len(edges))
    for e in edges:
        print(*e)


if __name__ == '__main__':
    N = int(input())
    main(N)
    #for i in range(3, 101):
    #    print(i, end=":")
    #    main(i)


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

int main(){
    int N;
    cin >> N;
    vector<int> p(N+1);
    for (int i = 0; i < N; i++) {
        int n;
        cin >> n;
        p[n] = i+1;
    }
    multiset<long int> num;
    long int ans = 0;
    num.insert(0);
    num.insert(0);
    num.insert(p[N]);
    num.insert(N+1);
    num.insert(N+1);
    for (int i = N-1; i >= 1; i--) {
        auto lb = num.lower_bound(p[i]);
        long int u = *lb;
        lb++;
        long int v = *lb;
        lb--; lb--;
        long int t = *lb;
        lb--;
        long int s = *lb;
        ans += i * ((t-s) * (u - p[i]) + (v-u) * (p[i] - t));
        num.insert(p[i]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 5376
def babble_sort(n, data):
    __count = 0
    for i in range(n-1):
        for j in range(n-i-1):
            if data[j] > data[j+1]:
                tmp = data[j+1]
                data[j+1] = data[j]
                data[j] = tmp
                __count += 1
    return data, __count

def show(data, count):
    for i in range(len(data)):
        if i != (len(data)-1):
            print(data[i], end = " ")
        else:
            print(data[i])
    print(count)

if "__main__" == __name__:
    n = int(input())
    data = list(map(int, input().rsplit()))
    data, count = babble_sort(n, data)
    show(data, count)


Measured memory_bytes: 5608
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;

ll prime[1005];
bool is_prime[1005];
ll mod=1000000000+7;
ll sieve(ll n){
	ll p=0;
	for(ll i=0;i<=n;i++) is_prime[i]=true;
	is_prime[0]=is_prime[1]=false;
	for(ll i=2;i<=n;i++){
		if(is_prime[i]){
			prime[p++]=i;
			for(ll j=2*i;j<=n;j+=i) is_prime[j]=false;
		}
	}
	return p;
}
ll a[1005];

int main()
{
	ll n;
	
	
	scanf("%lld",&n);
	ll p=sieve(n);
	memset(a,0,sizeof(a));
	//2for(ll i=0;i<p;i++){
	//	printf("%lld ",prime[i]);
	//}
	//printf("\n");
	for(ll i=1;i<=n;i++){
		ll k=i;
		while(1){
			if(k==1) break;
			for(ll j=0;j<p;j++){
				if(k%prime[j]==0){
					a[prime[j]]++;
					k/=prime[j];
				
				}
			}
		}
		
	}
	//for(ll i=1;i<=n;i++){
	//	printf("%lld ",a[i]);
	//}
	//printf("====\n");
	ll res=1;
	
	for(ll i=1;i<=n;i++){
		res*=a[i]+1;
		res%=mod;
		//res=res%mod*(a[i]+1)%mod;
	}
	printf("%lld\n",res);
	
	
	
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
	public class Main {
	public static void main(String[] args) {
	Scanner sc= new Scanner(System.in);
	//while(true) {
	int a = sc.nextInt();
	int i;
	//if (a == 0) {
	//break;
	
	for(i=3;i<=a;i++){int j=i;
		if(j%3==0){System.out.printf(" "+i);
		
		}else{
		while(j!=0){if(j%10==3){System.out.printf(" "+i);break;}
		
		j/=10;}
		}}
	System.out.println();
	
	}}
	
	

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

using namespace std;

int main()
{
    int a, b, c, k; cin >> a >> b >> c >> k;

    int Ans = 0;

    int Can = min(a, k);
    k -= Can;
    Ans += Can;

    Can = min(k, b);
    k -= Can;

    Can = min(k, c);
    k -= Can;
    Ans -= Can;

    cout << Ans << endl;
}


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

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

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); i++) 
#define FOR(i, a, b) for(int (i) = a; (i) < (int)b; i++)
#define RREP(i, n) for(int (i)=((int)(n)-1); (i)>=0; i--)
#define RFOR(i, a, b) for(int (i) =((int)(b)-1); (i)>=(int)a; i--)
#define ALL(v) (v).begin(),(v).end()
#define MOD 1000000007
#define NIL -1
#define FI first
#define SE second
#define MP make_pair
#define PB push_back
#define SZ(x)  (int)x.size()
#define SP(x)  setprecision((int)x)


using namespace std ;
typedef long long ll;
typedef vector<int> vint;
typedef vector<vint> vvint;
typedef vector<string> vstr;
typedef pair<int, int> pii;
const int INF = 1e9;
const ll LINF = 1e18;
const double EPS = 1e-9;
ll gcd(ll a, ll b) {return b ? gcd(b, a % b) : a;} //最大公約数
ll lcm(ll a, ll b) {return a / gcd(a, b) * b;} //最小公倍数

//-------------------------------------------------
// 
void yes(){
  cout <<"Yes"<<endl ;
}
void no(){
  cout <<"No"<<endl ;
}


//-------------------------------------------------
// メモ




//-------------------------------------------------


int main()
{
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int n ;
  cin >>n ;
  ll ans = 0 ;
  REP(i,n){
    ll a ;
    cin >> a ;
    ans += a ;
  }
  
  cout << ans - n <<endl;
    
  
  
  
  return 0 ;
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <math.h>
#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;
 
 
int main() {
    ll n,k;
    cin >> n >> k;
    cout << min(abs(n%k),abs(n%k - k)) << endl;
}

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

using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using vint = vector<int>;
using vvint = vector<vint>;
using vvvint = vector<vvint>;
using vdouble = vector<double>;
using vvdouble = vector<vdouble>;
using vvvdouble = vector<vvdouble>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using uint = unsigned int;
using ull = unsigned long long;

template<typename T> using uset = unordered_set<T>;
template<typename T1, typename T2> using umap = unordered_map<T1, T2>;

constexpr int INF = (1 << 30) - 1;
constexpr ll LLINF = 1LL << 60;
constexpr int dy[] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dx[] = {0, 1, 0, -1, 1, 1, -1, -1};
constexpr char el = '\n';
constexpr int mod = 1000000007;
constexpr int mod2 = 998244353;
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 / gcd(a, b) * b); }
template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b) { return (a > b && (a = b, true)); }
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b) { return (a < b && (a = b, true)); }

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

template<typename T>
bool isin(T y, T x, T h, T w) { return (0 <= y && 0 <= x && y < h && x < w); }
template<typename T>
bool isin1(T y, T x, T h, T w) { return (0 < y && 0 < x && y <= h && x <= w); }

template<typename T>
ostream& operator <<(ostream &os, vector<T> &v) {
	if (v.size()) {
		os << v[0];
		for (int i = 1; i < v.size(); i++) os << " " << v[i];
	}
	return (os);
}

template<typename T>
istream& operator >>(istream &is, vector<T> &v) {
	for (auto &u : v) is >> u;
	return (is);
}

template<typename T1, typename T2>
istream& operator >>(istream &is, pair<T1, T2> &p) {
	return (is >> p.first >> p.second);
}


void Main() {
	int X, Y, Z, K; cin >> X >> Y >> Z >> K;
	vll A(X), B(Y), C(Z); cin >> A >> B >> C;
	sort(begin(A), end(A));
	sort(begin(B), end(B));
	sort(begin(C), end(C));
	ll ok = -1, ng = 1e12;

	while (abs(ok-ng)>1) {
		ll limit = (ok+ng)/2;
		ll cnt = 0;
		for (int i = 0; i < X; i++) {
			for (int j = 0; j < Y; j++) {
				for (int k = Z-1; k >= 0; k--) {
					if (A[i] + B[j] + C[k] < limit) {
						break;
					}
					cnt++;
					if (cnt >= K) break;
				}
				if (cnt >= K) break;
			}
			if (cnt >= K) break;
		}
		if (cnt >= K) ok = limit;
		else ng = limit;
	}
	
	ll cnt = 0;
	vll ans;
	for (int i = 0; i < X; i++) {
		for (int j = 0; j < Y; j++) {
			for (int k = Z-1; k >= 0; k--) {
				if (A[i] + B[j] + C[k] <= ok) {
					break;
				}
				ans.push_back(A[i] + B[j] + C[k]);
				cnt++;
			}
		}
	}
	sort(rbegin(ans), rend(ans));
	for (auto &an : ans) {
		cout << an << el;
	}
	while (cnt < K) {
		cout << ok << el;
		cnt++;
	}
}

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


Measured memory_bytes: 3716
import java.io.*;

class Main{
public static void main(String args[]){
     int x;
     String buf;

     BufferedReader br=new BufferedReader(new InputStreamReader(System.in));

     try{
         buf=br.readLine();
         x=Integer.parseInt(buf);
         System.out.println(x*x*x);

     }catch(IOException e){
         System.out.println("入出力エラーです");
     }
}

}


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

int main(){
  ll n,m,k;
  cin >> n >> m >> k;
  m++;
  vector<ll> a(n);
  vector<ll> b(m);
  for(int i=0;i<n;i++) cin >> a[i];
  for(int i=1;i<m;i++){
    cin >> b[i];
    b[i]+=b[i-1];
  }
  
  ll ans=0;
  if(b[m-1]<=k) ans=m-1;
  else{
    for(int i=0;i<m;i++){
      if(b[i]>k){
        break;
      }
      ans=i;
    }
  }
  
  for(int j=0;j<n;j++){
    k-=a[j];
    if(k<0) break;
    ll p;
    if(k>=b[m-1]) p=m-1;
    else if(k<b[1]) p=0;
    else{
      int r=1,l=m-1;
      while(1){
        int i=(r+l)/2;
        if(b[i]<=k&&b[i+1]>k){
          p=i;
          break;
        }
        else if(b[i]>k) l=i;
        else r=i;
      }
    }
    ans=max(ans,p+j+1);
  }
  cout<<ans<<endl;
}


Measured memory_bytes: 6396
#include <bits/stdc++.h>
#define repz(i, z, n) for (decltype(n) i = (z); i < (n); i++)
#define rep(i, n) for (decltype(n) i = 0; i < (n); i++)

#define REPZ(i, z, n) for (decltype(n) i = (z); i <= (n); i++)
#define REP(i, n) for (decltype(n) i = 0; i <= (n); i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(v) ((ll)(v).size())
#define MAX(v) (*max_element(ALL(v)))
#define MIN(v) (*min_element(ALL(v)))
#define INF 1000000000000  // 1E+12

// 略
#define PB push_back
#define F first
#define S second
#define MP make_pair
#define READ cin >>
#define PRINT cout <<
#define PYES cout << "Yes" << endl;
#define POK cout << "OK" << endl;
#define PNO cout << "No" << endl;
#define PNG cout << "NG" << endl;

using namespace std;

// デバッグ用
void debug_out() { cout << endl; }
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cout << H << " ";
  debug_out(T...);
}

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

#ifdef _DEBUG
#define debug(...) debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

// typedef
typedef long long ll;
typedef unsigned long long ul;
typedef long double ld;
typedef pair<ll, ll> pl;

// const
// 円周率
const ld pi = acos(-1);
// mod用
// 1E+9 +7
const ll mod = (int)1e+9 + 7;
// 1s間で可能なループ回数2E+8回
// int        最大値2147483647         〜2E+9
// long long  最大値9223372036854775807〜9E+18
// 総和accumulate
// 単純リストvector<type> push_back
// 連想配列map<key,value> insert,
// 集合set<type>
// pair キーとバリューを格納 firstとsecondでアクセス
// 小数点指定 cout << fixed << setprecision(15) << endl;
// to_string<->stoi
// stoll(longlong)
// stod(double)
// deep copy v1->v2 copy(v1.begin(), v1.end(), back_inserter(v2) );
// 大文字65-90(-32)
// 小文字97-122(+32)
//  priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>>
//  ba;
signed main() {
  // faster
  // C言語流の入出力は使用できない
  ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  int a,b; cin >> a >> b;
  int sum = 1;
  int anumber = 0;
  while(sum<b){
    sum+=a-1;
    anumber++;
  }
  cout << anumber << endl;
  return 0;
}


Measured memory_bytes: 256
n = int(input())
x = list(map(int,input().split()))
a = sum(x)/n
if a-int(a) < 0.5:
  aa = int(a)
  print(sum([(xi-aa)**2 for xi in x]))
else:
  aa = int(a)+1
  print(sum([(xi-aa)**2 for xi in x]))
  
        
  


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

int array[1000][1000];
int X,Y;

void dfs(int y, int x){

  int nx,ny;
  array[y][x]=0;
  for(int dx=-1;dx<=1;dx++)
    for(int dy=-1;dy<=1;dy++){
      nx=x+dx;
      ny=y+dy;
      if(nx<X && ny<Y && nx>=0 && ny>=0 && array[ny][nx]!=0 ) dfs(ny,nx);
    }

}


int main(){

  while(1){
    cin>>X>>Y;
    int cnt=0;
    if(X==0 && Y==0) break;
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++)
	cin>>array[i][j];
    
    for(int i=0;i<Y;i++)
      for(int j=0;j<X;j++)
	if(array[i][j]==1){ 
	  dfs(i,j);
	  cnt++;
	}
    cout<<cnt<<endl;
  }
  return 0;
}

Measured memory_bytes: 1532
import math

def makelist(n, m):
    return [[0 for _ in range(m)] for _ in range(n)]

N = int(input())
sN = str(N)
l = len(sN)

ans = 0
for n in range(1, min(10, N+1)):
    sn = str(n)
    ans += 1
    
    cnt = 1
    for i in range(2, l):
        ans += cnt
        cnt *= 10

    if l == 2:
        if sN >= sn[-1] + sn[0]:
            ans += 1
    elif l > 2 and sN[0] >= sn[-1]:
        if sN[0] == sn[-1]:
            hoge = int(sN[1:-1])
            if sN[-1] < sn[0]:
                hoge -= 1
            ans += hoge + 1
        elif sN[0] > sn[-1]:
            ans += cnt

for n in range(11, N+1):
    sn = str(n)
    if sn[-1] != "0":
        if n > 10 and sn[0] == sn[-1]:
            ans += 1


        cnt = 1
        for i in range(2, l):
            ans += cnt
            cnt *= 10

        if l == 2:
            if sN >= sn[-1] + sn[0]:
                ans += 1
        elif l > 2 and sN[0] >= sn[-1]:
            if sN[0] == sn[-1]:
                hoge = int(sN[1:-1])
                if sN[-1] < sn[0]:
                    hoge -= 1
                ans += hoge + 1
            elif sN[0] > sn[-1]:
                ans += cnt

print(ans)


Measured memory_bytes: 43116
a, b, c, x, y = map(int, input().split())
if x > y:
    print(min(a * x + b * y, a * (x - y) + 2 * c * y, 2 * c * x))
else:
    print(min(a * x + b * y, b * (y - x) + 2 * c * x, 2 * c * y))

Measured memory_bytes: 2940
H, W = map(int, input().split())

pad_s = ['.'*(W+2)]
for h in range(H):
  pad_s.append('.' + input() + '.')
pad_s.append('.'*(W+2))

for i,ss in enumerate(pad_s):
  for j,s in enumerate(ss):
    if s == '#'\
      and pad_s[i][j+1] == '.'\
      and pad_s[i][j-1] == '.'\
      and pad_s[i+1][j] == '.'\
      and pad_s[i-1][j] == '.':
      print('No')
      exit()

print('Yes')

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <algorithm>
#include <vector>
#include <string.h>
#include <string>

using namespace std;

typedef unsigned long long ull;
typedef long long ll;

int main(void) {
	int n, m;
	cin >> n >> m;

	cout << (n - 1)*(m - 1) << endl;

	return 0;
}

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

#define debug(a) cout << #a << " " << a << endl;
#define _debug(a, i) cout << #a << "[" << i << "]" << " = " << a[i] << endl;
#define fastio ios_base::sync_with_stdio(false); \
		cin.tie(0);							     \
		cout.tie(0);
#define sz(arr) int(arr.size())

using namespace std;

using ll = long long;
const ll MOD = 1e9 + 7;
const ll INF = 1e18 + 9;
const double PI = 4.0 * atan(1.0);

ll powmod(ll a, ll b, const ll MOD) { ll res = 1; a %= MOD; assert(b >= 0); for (; b; b >>= 1) { if (b & 1)res = res * a % MOD; a = a * a % MOD; } return res; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a, b); }
ll modInverse(ll n, const ll p) { return powmod(n, p - 2, p); }
ll div_floor(ll a, ll b) { return a / b - (((a ^ b) < 0) and a % b); }
ll div_ceil(ll a, ll b) { return a / b + (((a ^ b) >= 0) and a % b); }

//ll f[200005];
//ll kCn(ll k, ll n) { return (f[n] * modInverse((f[n - k] * f[k]) % MOD, MOD)) % MOD; }



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

	fastio;
	ll h;
	cin >> h;
	int n = 50;
	while ((1LL << n) > h)
		--n;
	cout << (1LL << (n + 1)) - 1;
	return 0;
}

Measured memory_bytes: 256
//
//  main.cpp
//  Study
//
//  Created by 佐々木勇星 on 2020/03/12.
//  Copyright © 2020 佐々木勇星. All rights reserved.
//

#include <iostream>
#include <vector>
#include <cmath>
#include <sstream>
#include <iomanip>
#include <algorithm>

using namespace std;


int main(int argc, const char * argv[]) {
    

    int a, b, ans = 0;
    
    cin >> a >> b;
    
    if(a < b)
    {
        for(int i= b-1; i>=0; i--)
        {
            ans += a * pow(10, i);
        }
    } else if (a >= b)
    {
        for(int i=a-1; i>=0; i--)
        {
            ans += b * pow(10, i);
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 512
#include <algorithm>
#include <cassert>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <iostream>
#include <vector>
#include <map>
#include <queue>
using namespace std;
using ll = long long;

class range {private: struct I{int x;int operator*(){return x;}bool operator!=(I& lhs){return x<lhs.x;}void operator++(){++x;}};I i,n;
public:range(int n):i({0}),n({n}){}range(int i,int n):i({i}),n({n}){}I& begin(){return i;}I& end(){return n;}};

void get_chunk(int N, int K, vector<int>& chunk) {
  vector<vector<int>> vg(N);
  for (int j : range(K)) {
    int p, q; scanf("%d%d", &p, &q);
    p--; q--;
    vg[p].push_back(q);
    vg[q].push_back(p);
  }
  vector<vector<int>> lll;
  vector<char> vis(N);
  for (int i : range(N)) {
    if (vis[i]) continue;
    queue<int> q;
    q.push(i);

    vector<int> vis2;
    while (!q.empty()) {
      int j = q.front(); q.pop();
      if (vis[j]) continue;
      vis[j] = 1;
      vis2.push_back(j);
      for (auto k : vg[j]) {
        if (!vis[k]) q.push(k);
      }
    }
    lll.push_back(vis2);
  }
  chunk.assign(N, 0);
  for (int i : range(lll.size())) {
    for (int k : lll[i]) {
      chunk[k] = i;
    }
  }
}

int main() {
  int N, K, L;
  while (scanf("%d%d%d", &N, &K, &L) != EOF) {
    vector<int> ch1, ch2;
    get_chunk(N, K, ch1);
    get_chunk(N, L, ch2);

    map<pair<int, int>, int> cnt;
    for (int i : range(N)) {
      cnt[make_pair(ch1[i], ch2[i])]++;
    }

    for (int i : range(N)) {
      if (i) printf(" ");
      int d = cnt[make_pair(ch1[i], ch2[i])];
      printf("%d", d);
    }
    puts("");
  }
}


Measured memory_bytes: 18784
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <string>

#define ll long long

int main()
{
    std::string S, T;
    std::cin >> S >> T;

    bool check = true;
    if(!(1 <= S.size() and S.size() <= 10)) {
        check = false;
    }
    else if(T.size() != (S.size() + 1)) {
        check = false;
    }
    else {
        for(int i=0; i < S.size(); i++) {
            if(S[i] != T[i]) {
                check = false;
                break;
            }
        }
    }
    if(check) {
        std::cout << "Yes" << std::endl;
    }
    else {
        std::cout << "No" << std::endl;
    }
}

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

#define Fast cin.tie(0), ios::sync_with_stdio(0)
#define All(x) x.begin(), x.end()
#define louisfghbvc int t; cin >> t; while(t--)
#define sz(x) (int)(x).size()
using namespace std;
typedef long long LL;
typedef pair<LL, LL> ii;
typedef vector<LL> vi;

template<typename T> istream& operator>>(istream &is, vector<T> &v) { for(auto &it : v) is >> it; return is; }
template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '{'; string sep = ""; for(const auto &x : v) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }

void dbg_out() { cerr << "\n"; }
template<typename Head, typename... Tail> void dbg_out(Head H, Tail... T) { cerr << ' ' << H; dbg_out(T...); }

const int N = 1e5+5;

void solve(){
    int x;
    cin >> x;
    cout << (x^1) << "\n";
}

int main()
{
    Fast;
    //louisfghbvc{
        solve();
    //}
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
#define int long long
using namespace std;
const int N=200005,MAs=2147483647;
int n;
int a[N];
int ans=0;
signed main(){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++){
        scanf("%lld",&a[i]);ans+=a[i];
        a[i]+=a[i-1];
    }
    int QUERY=MAs;
    for(int i=1;i<n;i++){
        QUERY=min(QUERY,abs(2*a[i]-ans));
    }
    printf("%lld\n",QUERY);
    exit(0);
}

Measured memory_bytes: 1792
class UnionFind:
    def __init__(self, n):
        # 親要素のノード番号を格納　par[x] == x の時そのノードは根
        self.par = [i for i in range(n+1)]
        # 木の高さを格納する（初期状態では0)
        self.rank = [0] * (n+1)
        # 各々の集合の要素数（根が代表して値を持っておく）
        self.count = [1] * (n+1)

    # 検索
    def find(self, x):
        # 根ならその番号を返す
        root = x
        queue = [x]
        data = []
        while queue:
            now = queue.pop()
            if self.par[now] == now:
                root = now
            else:
                # 根でないなら親の要素で再検索
                data.append(now)
                queue.append(self.par[now])
        # 検索する過程で親を更新
        #for y in data:
            #self.par[y] = root
        return root

    # 併合
    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)
        t = (x == y)
        if UnionFind.same_check(self,x,y):
            return t
        if self.rank[x] < self.rank[y]:
            self.par[x] = y
            self.count[y] += self.count[x]
            self.count[x] = 0
        else:
            self.par[y] = x
            self.count[x] += self.count[y]
            self.count[y] = 0
            if self.rank[x] == self.rank[y]:
                self.rank[x] += 1
        return t


    # 同じ集合に属しているか判定
    def same_check(self, x, y):
        return self.find(x) == self.find(y)

    # 属している集合の要素数
    def size(self,x):
        q = UnionFind.find(self,x)
        return self.count[q]

n,m,k = map(int,input().split())
u = UnionFind(n)
ans = [-1 for i in range(n)]
for i in range(m):
    a,b = map(int,input().split())
    a -= 1
    b -= 1
    ans[a] -= 1
    ans[b] -= 1
    u.union(a,b)
#print(*ans)
for i in range(k):
    c,d = map(int,input().split())
    c -= 1
    d -= 1
    if u.same_check(c,d):
        ans[c] -= 1
        ans[d] -= 1

print(*[u.size(i)+x for i,x in enumerate(ans)])

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

public class Main {

	void submit() {
		String s = nextToken();
		int ret = Integer.MAX_VALUE;
		for (char c = 'a'; c <= 'z'; c++) {
			ret = Math.min(ret, go(s, c));
		}
		out.println(ret);
	}
	
	int go(String s, char c) {
		outer: for (int ans = 0; ans <= s.length() - 1; ans++) {
			for (int j = 0; j < s.length() - ans; j++) {
				boolean good = false;
				for (int k = j; k <= j + ans; k++) {
					good |= s.charAt(k) == c;
				}
				if (!good) {
					continue outer;
				}
			}
			return ans;
		}
		return Integer.MAX_VALUE;
	}

	void preCalc() {

	}

	void stress() {

	}

	void test() {

	}

	Main() throws IOException {
		br = new BufferedReader(new InputStreamReader(System.in));
		out = new PrintWriter(System.out);
		preCalc();
		submit();
		//stress();
		//test();
		out.close();
	}

	static final Random rng = new Random();

	static int rand(int l, int r) {
		return l + rng.nextInt(r - l + 1);
	}

	public static void main(String[] args) throws IOException {
		new Main();
	}

	BufferedReader br;
	PrintWriter out;
	StringTokenizer st;

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

	String nextString() {
		try {
			return br.readLine();
		} catch (IOException e) {
			throw new RuntimeException(e);
		}
	}

	int nextInt() {
		return Integer.parseInt(nextToken());
	}

	long nextLong() {
		return Long.parseLong(nextToken());
	}

	double nextDouble() {
		return Double.parseDouble(nextToken());
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

const int INF = 1e9+5;

int main(){
  string s;
  cin >> s;
  int N = s.size();
  ll res = 0;
  for(int i=0;i<(1<<(N-1));++i){
    ll tmp = 0;
    for(int j=0;j<N-1;j++){
      tmp*=10;//最初はスルーされる
      tmp+= s[j] - '0';//1桁足す
      if(i&(1<<j)) res+=tmp,tmp=0;
    }
    //最後はループでやらないからここで追加
    tmp*=10;
    tmp+= s.back()- '0';
    res+=tmp; 
  }
  cout << res << endl;
}

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

using namespace std;

const long long mod = 924844033;

int N, K;

long long dp1[2020][2020][4];

long long dp2[2020][2020];

long long C[2020][2020];
long long fact[2020];

long long dp3[2020];

void init(){
	fact[0] = 1;
	for(int i = 0; i < 2020; ++i){
		C[i][0] = 1;
		C[i][i] = 1;
		if(i > 0) fact[i] = (fact[i - 1] * i) % mod;
	}
	for(int i = 2; i < 2020; ++i){
		for(int j = 1; j < i; ++j){
			C[i][j] = (C[i - 1][j - 1] + C[i - 1][j]) % mod;
		}
	}
}

long long solve(){
	init();
	for(int i = 0; i < 2020; ++i) for(int j = 0; j < 2020; ++j){
		for(int k = 0; k < 4; ++k){
			dp1[i][j][k] = 0;
		}
	}
	dp1[1][0][0] = 1;
	dp1[1][1][1] = 1;
	for(int i = 1; i < 2010; ++i){
		for(int j = 0; j < 2010; ++j){
			for(int k = 0; k < 4; ++k){
				dp1[i + 1][j][(k & 1) << 1] += dp1[i][j][k];
				dp1[i + 1][j][(k & 1) << 1] %= mod;
				
				if(k < 2){
					dp1[i + 1][j + 1][(k & 1) << 1] += dp1[i][j][k];
					dp1[i + 1][j + 1][(k & 1) << 1] %= mod;
				}
				
				dp1[i + 1][j + 1][((k & 1) << 1) | 1] += dp1[i][j][k];
				dp1[i + 1][j + 1][((k & 1) << 1) | 1] %= mod;
			}
		}
	}
	
	for(int i = 0; i < 2020; ++i) for(int j = 0; j < 2020; ++j){
		dp2[i][j] = 0;
	}
	dp2[0][0] = 1;
	for(int i = 0; i < K; ++i){
		int a = N / K;
		if(i < N % K) a++;
		for(int j = 0; j <= N; ++j){
			for(int k = 0; k <= a; ++k){
				if(j + k > N) continue;
				long long val = (dp1[a][k][0] + dp1[a][k][2]) % mod;
				dp2[i + 1][j + k] += (dp2[i][j] * val);
				dp2[i + 1][j + k] %= mod;
			}
		}
	}
	
	for(int i = 0; i < 2020; ++i) dp3[i] = 0;
	for(int i = N; i >= 0; --i){
		long long all = dp2[K][i] * fact[N - i];
		for(int j = i + 1; j <= N; ++j){
			long long cur = dp3[j] * C[j][i];
			cur %= mod;
			all -= cur;
			all %= mod;
		}
		dp3[i] = all;
	}
	
	long long ans = dp3[0];
	ans %= mod;
	ans += mod;
	ans %= mod;
	return ans;
}

void input(){
	scanf("%d%d", &N, &K);
}

int main(){
	input();
	long long ans = solve();
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 182656
var GET=(function(){function f(s){return new g(s);}function g(s){this._s=s.trim().split("\n");this._y=0;}g.prototype.a=function(f){var s=this._s, y=this._y, r;if(typeof s[y]==="string")s[y]=s[y].split(" ").reverse();r=s[y].pop();if(!s[y].length)this._y++;return f?r:+r;};g.prototype.l=function(f){var s=this._s[this._y++].split(" ");return f?s:s.map(a=>+a);};g.prototype.m=function(n,f){var r=this._s.slice(this._y,this._y+=n).map(a=>a.split(" "));return f?r:r.map(a=>a.map(a=>+a));};g.prototype.r=function(n,f){var r=this._s.slice(this._y,this._y+=n);return f?r:r.map(a=>+a);};return f;})();
var o=GET(require("fs").readFileSync("/dev/stdin","utf8"));
function xArray(v){var a=arguments,l=a.length,r="Array(a["+--l+"]).fill(0).map(x=>{return "+v+";})";while(--l)r="Array(a["+l+"]).fill(0).map(x=>"+r+")";return eval(r);}
var bellmanFord = (function(){
  var INF = 1e9;
  function f(graph,start){
    return new bellmanFord(graph,start);
  }
  function bellmanFord(graph,start){
    var n = graph.length;
    var dist = this.d = Array(n).fill(INF);
    dist[start] = 0;
    for(var i = 1; i < n; i++){
      for(var v = 0; v < n; v++){
        if(dist[v] === INF)continue;
        for(var k = 0; k < graph[v].length; k++){
          var e = graph[v][k];
          if(dist[e.to] > dist[v] + e.cost){
            dist[e.to] = dist[v] + e.cost;
          }
        }
      }
    }
    for(var v = 0; v < n; v++){
      if(dist[v] === INF)continue;
      for(var k = 0; k < graph[v].length; k++){
        var e = graph[v][k];
        if(dist[e.to] > dist[v] + e.cost){
          dist[e.to] = -INF;
        }
      }
    }
    for(var i = 1; i < n; i++){
      for(var v = 0; v < n; v++){
        if(dist[v] !== -INF)continue;
        for(var k = 0; k < graph[v].length; k++){
          dist[graph[v][k].to] = -INF;
        }
      }
    }
  }
  bellmanFord.prototype.dist = function(i){
    return this.d[i];
  };
  return f;
})();

console.log(main());
function main(){
  var n = o.a();
  var m = o.a();
  var p = o.a();
  var graph = xArray("[]",n);
  for(var i = 0; i < m; i++){
    var t = o.l(), a = t[0]-1, b = t[1]-1, c = t[2];
    graph[a].push({to:b,cost:p-c});
  }
  var bf = bellmanFord(graph,0);
  if(bf.dist(n-1) === -1e9)return -1;
  if(bf.dist(n-1) >= 0)return 0;
  return -bf.dist(n-1);
}

Measured memory_bytes: 10640
#include<stdio.h>
int main(){
	int n,cnt=0;
	char a[101];
	char b[101];
	char c[101];
	scanf("%d",&n);
	scanf("%s",&a);
	scanf("%s",&b);
	scanf("%s",&c);
	for(int i=0;i<n;i++){
		if(a[i]==b[i] && b[i]==c[i] && a[i]==c[i])cnt+=0;
		else if(a[i]!=b[i] && b[i]!=c[i] && a[i]!=c[i])cnt+=2;
		else if(a[i]==b[i])cnt+=1;
		else if(b[i]==c[i])cnt+=1;
		else if(a[i]==c[i])cnt+=1;
				
				
			}
			printf("%d",cnt);
}



Measured memory_bytes: 128
#include <stdio.h>
#include <string.h>
#include <stdbool.h>
#include <stdlib.h>
int max(const void *a, const void *b){return *(int*)b - *(int*)a;}

int n;
int a[200000];

int main(void)
{
    int m1,m2;
    scanf("%d",&n);
    m1 = 0;
    m2 = 0;
    for(int i=0;i<n;i++) 
    {
        scanf("%d",&(a[i]));
        if(a[i] > m1)
        {
            m2 = m1;
            m1 = a[i];
        }else if(a[i] > m2)
        {
            m2 = a[i];
        }
    }
    
    for(int i =0;i<n;i++)
    {
        printf("%d\n", a[i] == m1 ? m2 : m1 );
    }

    return 0;
}


Measured memory_bytes: 2304
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <queue>
#include <cmath>
#include <climits>
#include <iomanip>
#include <set>
#include <map>
using namespace std;
typedef long long ll;
struct edge{
    ll p;//点
    ll w;//辺の重み*-1
};
vector<vector<edge> > graph(100000);
vector<ll> res(100000);
ll v,e,r;//vは頂点,eは辺,rは始点
void dijkstra(){
  for(int i = 0;i < v;i++)res[i] = pow(10,18);
    res[r] = 0;
    priority_queue<pair<ll,ll> > que;//重み、頂点
    que.push(make_pair(0,r));
    while(!que.empty()){
        edge now;
        now.p = que.top().second;
        now.w = que.top().first * -1;
        que.pop();
        if(res[now.p] < now.w)continue;
        for(int i = 0;i < (int)graph[now.p].size();i++){
            if(res[graph[now.p][i].p] > now.w + graph[now.p][i].w){
                res[graph[now.p][i].p] = now.w + graph[now.p][i].w;
                que.push(make_pair(res[graph[now.p][i].p] * -1,graph[now.p][i].p));
            }
        }
    }
}
int main(){
  ll h,w;
  cin >> h >> w;
  v = 10;
  e = 100;
  vector<ll> cost(10);
  for(int i = 0;i < 10;i++){
    for(int j = 0;j < 10;j++){
      ll in;
      cin >> in;
      edge memoa = {j,in};
      graph[i].push_back(memoa);
    }
  }
  for(int i = 0;i < 10;i++){
    r = i;
    dijkstra();
    cost[i] = res[1];
  }
  
  ll ans = 0;
  for(int i = 0;i < h;i++){
    for(int j = 0;j < w;j++){
      ll num = 0;
      cin >> num;
      if(num == -1)continue;
      ans += cost[num];
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 6220
#include <iostream>
#include <algorithm>
using namespace std;
typedef long long ll;
int main(void) {
  int n, t;
  cin >> n >> t;
  ll ans = 0;
  int a = 0;
  int b;
  for (int i = 0; i < n; i++) {
    cin >> b;
    ans += min(b - a, t);
    a = b;
  }
  cout << ans + t << endl;
  return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <unordered_map>
#include <unordered_set>
using namespace std;

#define ABS(a) (((a) >= 0) ? (a) : -(a))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define MIN(a, b) ((a) > (b) ? (b) : (a))
#define FOR(i, a, b) for (int i = (a); i <= (b); ++i)
#define RFOR(i, a, b) for (int i = (a); i >= (b); --i)
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define POW_10_5 100000
#define POW_10_9 1000000000
#define INF (numeric_limits<int>::max()/2)
#define int long long

typedef pair<int, int> Pair;

// ---
const int Nlim = 2 * POW_10_5;
const int Clim = 2 * POW_10_5 + 1;
const int M = POW_10_9 + 7;
int N;
int C[Nlim];

int Ans() {
  int dp[Nlim];
  int last[Clim];
  fill(last, last+Clim, -1);
  dp[0] = 1;
  last[C[0]] = 0;
  FOR(i, 1, N-1) {
    dp[i] = dp[i-1];
    if (last[C[i]] != -1 && last[C[i]] != i-1) {
      dp[i] = (dp[i] + dp[last[C[i]]]) % M;
    }
    last[C[i]] = i;
  }

  return dp[N-1];
}

signed main() {
  cin >> N;
  REP(i, N) { cin >> C[i]; }

  auto ans = Ans();

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


Measured memory_bytes: 4992