akhauriyash/Code-Regression huggingface dataset:
k = int(input())
a, b = map(int, input().split())

i = a // k
j = b // k

res = j - i

if res >= 1:
  print('OK')
elif res == 0 and k == 1:
  print('OK')
elif a%k ==0:
  print('OK')
else:
  print('NG')

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

/*連続する正の整数の組合せを求める*/
int Search_Consecutive_Integers(int n)
{
  int count = 0;

  for(int i = 1; 2 < n; i++) {
    n = n - i;
      if(n % (i + 1) == 0) {
        if(n > 1)
          count++;
      }
  }
  return count;
}

int main()
{
  int num;

  while(1) {
    cin >> num;
    if(num <= 0)
      break;
    cout << Search_Consecutive_Integers(num) << endl;
  }

  return 0;
}



Measured memory_bytes: 3096
#include <bits/stdc++.h>
#define RI register int
typedef long long LL;

#define FILEIO(name) freopen(name".in", "r", stdin), freopen(name".out", "w", stdout);

using namespace std;

char buf[1000000], *p1 = buf, *p2 = buf;
inline char gc() {
  if (p1 == p2) p2 = (p1 = buf) + fread(buf, 1, 1000000, stdin);
  return p1 == p2 ? EOF : *(p1++);
}
template <class T> inline void read(T &n) {
  n = 0; RI ch = gc(), f;
  while ((ch < '0' || ch > '9') && ch != '-') ch = gc();
  f = (ch == '-' ? ch = gc(), -1 : 1);
  while (ch >= '0' && ch <= '9') n = n * 10 + (ch ^ 48), ch = gc();
  n *= f;
}

LL qpow(LL a, int k) { LL re = 1; while (k--) re *= a; return re; }

int main() {
  
#ifdef LOCAL
  FILEIO("a");
#endif

  int X; cin >> X;
  for (RI i = -1000; i <= 1000; ++i)
    for (RI j = -1000; j <= 1000; ++j) {
      LL L = qpow(i, 5), R = qpow(j, 5);
      if (L - R == X) return printf("%d %d\n", i, j), 0;
    }
      

  return 0;
}

// created by Daniel yuan


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

const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main(){
    int n, k;
    cin >> n >> k;
    vi a(n);
    rep(i, n) cin >> a[i];
    vi sum(n+1);
    rep(i, n) {
        sum[max(0,i-a[i])]++;
        sum[min(n,i+a[i]+1)]--;
    }
    rep(h, k-1) {
        vi sum2(n+1);
        int val = sum[0];
        sum2[0]++; sum2[min(n,val+1)]--;
        bool full = (val==n);
        rep1(i, n-1) {
            val += sum[i];
            sum2[max(0,i-val)]++;
            sum2[min(n,i+val+1)]--;
            if (i<=n-1 && val!=n) full = false;
        }
        swap(sum, sum2);
        if (full) break;
    }
    vi ans(n);
    ans[0] = sum[0];
    rep1(i, n-1) ans[i] = ans[i-1] + sum[i];
    rep(i, n) printf("%d%c", ans[i], (i<n-1?' ':'\n'));
    return 0;
}


Measured memory_bytes: 5700
from statistics import mean, median,variance,stdev
import numpy as np
import sys
import math
import fractions
import itertools

def j(q):
    if q==1: print("Yes")
    else:print("No")
    exit(0)


def ct(x,y):
    if (x>y):print("")
    elif (x<y): print("")
    else: print("")

def ip():
    return int(input())

def swap(s,pos):
    s[pos]-=1
    s[pos+1]+=1
    print(s)
    if pos == n-2: return s
    if s[pos+2] == 0: swap(s,pos+1)
    return s


n = ip()                              #入力整数1つ
#h,w= (int(i) for i in input().split())      #入力整数横2つ
#n,x,y = (int(i) for i in input().split())    #入力整数横3つ
#n,m,x,y= (int(i) for i in input().split())  #入力整数横4つ
#a = [int(i) for i in input().split()]        #入力整数配列
#a = input()                                  #入力文字列
#a = input().split()                          #入力文字配列
#n = ip()                      #入力セット(整数改行あり)(1/2)
#a=[ip() for i in range(n)]    #入力セット(整数改行あり)(2/2)

#jの変数はしようできないので注意
#全足しにsum変数使用はsum関数使用できないので注意
s = 0
for i in range(n):
    x,y = (int(i) for i in input().split())
    s+=(y-x+1)
print(s)

Measured memory_bytes: 13760
#define _LIBCPP_DEBUG 0
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;

int main(void) {

    string N; cin>>N;
	
    //vector<int> vec(N.length());
	int vec[N.length()+1];
	vec[0] = 0;
    for (ll i = 0; i < N.length() ; i++) {
        vec[i+1] = N[i]-'0';
    }
    ll ans = 0;

    for (ll i = N.length(); i >= 0; --i) {

        if(vec[i]>=10) { // 繰り上げ処理
            vec[i-1]++;
            vec[i] %= 10;
        }

        if(vec[i]<5){
            ans += vec[i];
        }
    	else if(vec[i]==5){
            if(vec[i-1]>=5){
                ans += 10-vec[i];
                vec[i-1]++;
            }else{
                ans += vec[i]++;
            }
        }else{
            ans += 10-vec[i];
            vec[i-1]++;
        }
    }
	cout<<ans<<endl;
	
	
	
	//printf("N.length = %d\n",len);

}


Measured memory_bytes: 5252
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<vector>
using namespace std;
const int maxn=2e5+5;
int val[maxn],ans[maxn];
vector<int> sons[maxn],arr;
void solve(int root,int fa)
{
    int pos=(int)(lower_bound(arr.begin(),arr.end(),val[root])-arr.begin());
    int pre=-1;
    if(pos==(int)arr.size())
        arr.push_back(val[root]);
    else
    {
        pre=arr[pos];
        arr[pos]=val[root];
    }
    ans[root]=(int)arr.size();
    for(int i=0;i<(int)sons[root].size();i++)
    {
        int next=sons[root][i];
        if(next==fa) continue;
        solve(next,root);
    }
    if(pre==-1) arr.pop_back();
    else arr[pos]=pre;
    return;
}
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    int n;
    cin>>n;
    for(int i=1;i<=n;i++)
        cin>>val[i];
    for(int i=1;i<n;i++)
    {
        int u,v;
        cin>>u>>v;
        sons[u].push_back(v);
        sons[v].push_back(u);
    }
    solve(1,0);
    for(int i=1;i<=n;i++) cout<<ans[i]<<'\n';
    return 0;
}


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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);

/* -----  2019/07/07  Problem: ABC 133 C / Link: http://abc133.contest.atcoder.jp/tasks/abc133_c  ----- */


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

	LL L, R; cin >> L >> R;

	LL mod = 2019;
	LL ans = LINF;
	for (LL i = L; i < R && i <= L + 5000; i++) {
		for (LL j = i + 1; j <= R && j <= i + 5000; j++) {
			LL x = (i*j) % mod;
			ans = min(ans, x);
		}
	}

	cout << (ans) << "\n";

	return 0;
}


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

vector<string> input(int H) {
  vector<string> vec(H);
  for(int i = 0; i < vec.size(); i++)
    cin >> vec.at(i);
  return vec;
}

void comp(vector<string> vec, int H, int W) {
  vector<bool> row(H, false);
  vector<bool> col(W, false);
  for(int i = 0; i < row.size(); i++) {
    for(int j = 0; j < col.size(); j++) {
      if(vec.at(i).at(j) == '#') {
        row.at(i) = true;
        col.at(j) = true;
      }
    }
  }
  for(int i = 0; i < row.size(); i++) {
    if(row.at(i)) {
      for(int j = 0; j < col.size(); j++) {
        if(col.at(j))
          cout << vec.at(i).at(j);
      }
      cout << endl;
    }   
  }
}

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> a = input(H);
  comp(a, H, W);
}

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

int main(){
	int a,b;
	while(cin>>a>>b){
		if(a==0&&b==0)break;

		double ans=114514.0;
		rep(i,a+1){
			int x=i;
			int y=a-x;

			// cout<<x<<" "<<y<<endl;

			if(abs(sqrt((x*x)+(y*y))-b)<ans){
				ans=abs(sqrt((x*x)+(y*y))-b);
			}

			// cout<<setprecision(10);
			// cout<<ans<<endl;


		}

		cout<<setprecision(10);
		cout<<ans<<endl;



	}
}

Measured memory_bytes: 3180
#include <iostream>
#include <string>
#include <algorithm>

using namespace std;

void showArray(int a[], int n) {
    for (int i=0; i<n; i++) {
        cout << a[i];
    } cout << endl;
}

void showString(string s) {
    for (int i=0; i<s.size(); i++) {
        cout << s[i];
    }
    cout << endl;
}

void showReverse(string s) {
    for (int i=s.size(); i>=0; i--) {
        cout << s[i];
    }
    cout << endl;
}

int main() {
    string s;
    getline(cin, s);
    // if (s.size() == 2) {
    //     showString(s);
    // } else {
    //     showReverse(s);
    // }

    if (s.length() == 3) {
        swap(s[0], s[2]);
    }
    cout << s << endl;

    return 0; 
}

Measured memory_bytes: 256
from copy import deepcopy as cp
s = input()
c = set(s)
ans = 10**9
for ch in c:
    #全ての文字をiにしよう！
    k = cp(s)
    cand = 0
    while len(set(k)) > 1:
        t = ""
        for i in range(len(k)-1):
            if k[i] == ch or k[i+1] == ch:
                t += ch
            else:
                t += k[i]
        cand += 1
        k = cp(t)
    ans = min(cand, ans)
print(ans)



Measured memory_bytes: 42220
#include <stdio.h>
#define MAX 100000

int A[MAX], n;

int partition(int p, int r) {
  int x, i, j, t;
  x = A[r];
  i = p-1;
  for(j=p; j<r; j++) {
    if(A[j] <= x) {
      i++;
      t=A[i]; A[i]=A[j]; A[j]=t;
    }
  }
  t=A[i+1]; A[i+1]=A[r]; A[r]=t;
  return i+1;
}

int main(void) {
  int i, q;

  scanf("%d", &n);
  for(i=0; i<n; i++) scanf("%d",&A[i]);
  q = partition(0,n-1);

  for(i=0; i<n; i++) {
    if(i) printf(" ");
    if(i==q) printf("[");
    printf("%d",A[i]);
    if(i==q) printf("]");
  }
  printf("\n");

  return 0;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N;
char C[5] = {'M', 'A', 'R', 'C', 'H'};
ll cnt[5];

int main(){
  cin >> N;
  for (int i = 0; i < N; i++){
    string S; cin >> S;
    for (int j = 0; j < 5; j++){
      if (S[0] == C[j]) cnt[j]++;
    }
  }
  ll ans = 0;
  for (int i = 0; i < 5; i++){
    for (int j = i + 1; j < 5; j++){
      for (int k = j + 1; k < 5; k++){
        ans += cnt[i] * cnt[j] * cnt[k];
      }
    }
  }
  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 3612
def resolve():
    h, n = map(int, input().split())
    lab = []
    while True:
        try:
            a, b = map(int, input().split())
            lab.append([a, b])
        except:
            break
    cost = [0] * (h+1)
    for i in range(1, h+1):
        mb = 10 ** 8
        for j in range(n):
            if i < lab[j][0]:
                mb = min(mb, lab[j][1])
            else:
                mb = min(mb, cost[i - lab[j][0]] + lab[j][1])
        cost[i] = mb
    print(cost[h])
resolve()

Measured memory_bytes: 40688
#include<bits/stdc++.h>
#define gc getchar()
#define ll long long
#define pb push_back
#define mk make_pair
#define rint register int
#define int long long
using namespace std;
const int mod = 1e9+7;
inline int read(){int w=1,s=0;char ch=getchar();while(!isdigit(ch)){if(ch=='-')w=-1;ch=getchar();}while(isdigit(ch)){s=s*10+ch-'0';ch=getchar();}return  w*s;}
int N,f[5050][5050];
char s[5050];
inline ll ksm(ll x,ll y){ll res=1; while(y){if(y&1)res=res*x%mod;y>>=1;x=x*x%mod;} return res;}
signed main()
{
	N=read();scanf("%s",s+1);
	f[0][0]=1;int len=strlen(s+1);
	for(rint i=0;i<N;++i){
		for(rint j=0;j<=N;++j)
		{
			if(f[i][j])
			{
				(f[i+1][j+1]+=2ll*f[i][j]%mod)%=mod;
				f[i+1][j+1]%=mod;
				(f[i+1][max(j-1,0ll)]+=f[i][j])%=mod;
				f[i+1][max(j-1,0ll)]%=mod;
			}
		}
	}
	cout<<1ll*f[N][len]*ksm(ksm(2,len),mod-2)%mod;
	return 0;
}
/*
by was_n
18.11.15
*/


Measured memory_bytes: 197120
//OPTIMIZATIONS
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
//#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN NEEDED)
//#pragma GCC optimize("Ofast,unroll-loops,no-stack-protector,fast-math")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,tune=native")
//OPTIMIZATIONS
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long uu;
typedef long long int lll;
typedef unsigned long long int uuu;
using namespace std;

#define watch(x) cerr << "\n" \
					  << (#x) << " is " << (x) << endl
#define cel(x, y) 1 + ((x - 1) / y)
const double PI = 3.141592653589793238463;
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f;

/*
$alil03

URL: url

Solution Begins here
*/

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	string s;
	cin >> s;
	if (s == "SUN")
	{
		cout << 7;
	}
	else if (s == "MON")
	{
		cout << 6;
	}
	else if (s == "TUE")
	{
		cout << 5;
	}
	else if (s == "WED")
	{
		cout << 4;
	}
	else if (s == "THU")
	{
		cout << 3;
	}
	else if (s == "FRI")
	{
		cout << 2;
	}
	else if (s == "SAT")
	{
		cout << 1;
	}
}

Measured memory_bytes: 256
#!/usr/bin/env python3
import sys
INF = float("inf")


def z_algorithm(S):
    N = len(S)
    Z = [0]*N

    c = 0
    for i in range(1, N):
        if i+Z[i-c] < c+Z[c]:
            Z[i] = Z[i-c]
        else:
            j = max(0, c+Z[c]-i)
            while i+j < N and S[j] == S[i+j]:
                j += 1
            Z[i] = j
            c = i
    Z[0] = len(S)
    return Z


def zfindall(text, pattern, separator="$"):
    N = len(pattern)
    conc = pattern+separator+text
    Z = z_algorithm(conc)

    umu = [i-N-1 for i in range(len(conc)) if Z[i] == N]
    return umu


def solve(N: int, S: str):

    len1 = [0]*10
    len2 = [0]*100
    len3 = [0]*1000
    for c in S:
        # 長さ3
        for i in range(100):
            if len2[i] > 0:
                len3[int(str(i)+c)] = 1

        # 長さ2
        for i in range(10):
            if len1[i] > 0:
                len2[int(str(i)+c)] = 1

        # 長さ1
        len1[int(c)] = 1
    counter = 0
    for i in range(1000):
        if len3[i] == 1:
            counter += 1

    print(counter)
    return


def main():

    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    N = int(next(tokens))  # type: int
    S = next(tokens)  # type: str
    solve(N, S)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3188
N,M=map(int,input().split())
AB=list()
for i in range(N):
  AB.append(list(map(int,input().split())))
AB.sort()
ans=0
for i in range(N):
  if M>=AB[i][1]:
    M-=AB[i][1]
    ans+=AB[i][0]*AB[i][1]
  else:
    ans+=M*AB[i][0]
    M=0
print(ans)


Measured memory_bytes: 27440
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define ll long long
int main(){
  int N;
  cin>>N;
  vector<int> A(N);
  rep(i,N) cin>>A[i];
  sort(all(A));
  int tmp=A[N-1],tmp2=A[0];
  vector<pair<int,int>> P(N-1); 
  rep(i,N-2){
    if(A[N-2-i]<0){
      P[i]=make_pair(tmp,A[N-2-i]);
      tmp-=A[N-2-i];
    }else{
      P[i]=make_pair(tmp2,A[N-2-i]);
      tmp2-=A[N-2-i];
    }
  }
  P[N-2]=make_pair(tmp,tmp2);
  cout<<tmp-tmp2<<endl;
  rep(i,N-1) cout<<P[i].first<<" "<<P[i].second<<endl;
}

Measured memory_bytes: 3072
A = list(input())
B = list(input())

if len(A) > len(B):
    print("GREATER")
elif len(B) > len(A):
    print("LESS")
else:
    for i in range(len(A)):
        if int(A[i]) > int(B[i]):
            print("GREATER")
            quit()
        elif int(A[i]) < int(B[i]):
            print("LESS")
            quit()
        else:
            if i  == len(A) - 1 and int(A[i])==int(B[i]):
                print("EQUAL")


Measured memory_bytes: 3064
import java.text.ParseException;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        SimpleDateFormat format = new SimpleDateFormat("yyyy/MM/dd");
        try (Scanner sc = new Scanner(System.in)) {
            if (sc.hasNext()) {
                String s = sc.next();
                Date date = format.parse(s);
                switch (date.compareTo(format.parse("2019/04/30"))) {
                    case -1:
                    case 0:
                        System.out.println("Heisei");
                        break;
                    default:
                        System.out.println("TBD");
                }
            }
        } catch (ParseException e) {
            e.printStackTrace();
        }
    }
}


Measured memory_bytes: 24144
#include <stdio.h>

int main(){
   int a, b, c;

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

  if((a == b || a == c ) && b != c){
    printf(" Yes");
  } else if((b == a || b == c ) && a != c){
    printf(" Yes");    
  }else if((c == a || c == b ) && a != b){
    printf(" Yes");
  }else {
   printf("No");
  }
  
  return 0;
}



Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using MAP=pair<long,long>;
using Data=pair<MAP,long>;

int main(){
  int i,j,N,Q,cnt=0,a=0,b;
  long s,t,x;
  scanf("%d",&N);
  scanf("%d",&Q);

  vector<Data> event(2*N);
  set<long> se;
  for(i=0;i<N;i++){
    scanf("%ld",&s);
    scanf("%ld",&t);
    scanf("%ld",&x);
    event[cnt++]=Data(MAP(s-x,x),2);
    event[cnt++]=Data(MAP(t-x,x),1);
  }
  sort(event.begin(),event.end());
  cnt=0;
  for(i=0;i<Q;i++){
    scanf("%ld",&x);
    while(1){
      if(event[a].first.first<=x){
        switch(event[a].second){
          case 1:
            se.erase(event[a].first.second);
            break;
          case 2:
            se.insert(event[a].first.second);
            break;
        }
        a++;
      }else{
        break;
      }
    }
    if(se.empty()){
      printf("-1\n");
    }else{
      t=*se.upper_bound(0);
      printf("%d\n",t);
    }
  }
  return 0;
}

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

const ll maxs = 1e6+5;
const ll lmaxs = 20;
ll mod = 1e9+7;
ll oo = 1e15;

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define I insert

void solve(){
    ll n;
    cin>>n;
    double l = n/(double)3;
    double ans = l*l*l;
    cout << fixed << setprecision(6) << ans << endl;
}

int main(){
   
    IOS;
    ll T = 1;
    //cin>>T;
    while(T--){
        solve();
    }
    return 0;
}

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

int main()
{
    int n,x,t, ans=0;
    cin>>n>>x>>t;
    if(n%x==0)
    cout<<(n/x)*t<<endl;
    else
    cout<<((n/x)+1)*t<<endl;
    return 0;
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M, C;
  cin >> N >> M >> C;
  vector<vector<int>> A(N, vector<int>(M));
  vector<int> B(M);
  for(int i = 0; i < M; i++){
    cin >> B.at(i);
  }
  for(int i = 0; i < N; i++){
    for(int j = 0; j < M; j++){
      cin >> A.at(i).at(j);
    }
  }
  int ans = 0;
  for(int i = 0; i < N; i++){
    int sum = 0;
    for(int j = 0; j < M; j++){
      sum += A.at(i).at(j) * B.at(j);
    }
    sum += C;
    if(sum > 0) ans++;
  }
  cout << ans << endl;
}
      

Measured memory_bytes: 3588
/*
 ABC-166
 */
#pragma warning(disable:4996)
#pragma comment(linker, "/STACK:336777216")
#pragma GCC optimize("Ofast")

#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>

using namespace std;
using namespace __gnu_pbds;

typedef long long ll;
#define int long long int
typedef complex<long double> cd;
const long double pi=acos(-1);
typedef double db;
typedef long double ldb;
typedef pair <int, int> pii;
typedef pair <db, db> pdd;
typedef vector<int> vi;
typedef vector<vector<int> > matrix;

#define m1 make_pair
#define pb push_back
#define flush fflush(stdout)
#define IOS std::ios::sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
#define reset(x,v) memset(x,v,sizeof(x))

#define fi first
#define se second
#define endl "\n"
#define debug(x) (cerr << #x << ": " << x << "\n")
#define setbits(x) __builtin_popcount(x)
#define setbitsll(x) __builtin_popcountll(x)
#define all(x) x.begin(),x.end()
#define pii pair<int,int>

inline ll gcd(ll a,ll b){if(a==0) return b;return gcd(b%a,a);}
inline ll power(ll a,ll n,ll m){if(n==0)return 1;ll p=power(a,n/2,m);p=(p%m*p%m)%m;if(n%2) return (p%m*a%m)%m;else return p;}
const ll MOD =998244353;
const ll hell=1000000007;
const int INF = 1e17;
const ll LL_INF = 0x3f3f3f3f3f3f3f3f;
typedef tree<int, null_type, less<int>, rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;

double startTime;
double getCurrentTime() {
    return ((double)clock() - startTime) / CLOCKS_PER_SEC;
}

const int N=300005;


void solve()
{
    
    map<int,int>mp;
    int x;
    cin>>x;
    for(int i=0;i<=1000;i++)
    {
        int pr=1;
        for(int j=1;j<=5;j++)
            pr=pr*i;
        mp[pr]=i;
    }
    for(int i= -1000;i<=1000;i++)
    {
        int pr=1;
        for(int j=1;j<=5;j++)
            pr=pr*i;
        
        int z=x+pr;
        if(mp.find(z)!=mp.end())
        {
            cout<<mp[z]<<" "<<i<<endl;
            return;
        }
    }
}

int32_t main()
{
    IOS;
    // startTime=clock();
    int t;
    t=1;
    //cin>>t;
    while(t--)
    {
        solve();
    }
    // cout<<getCurrentTime()<<endl;
    return 0;
}



Measured memory_bytes: 3704
import java.io.PrintWriter
val pw = PrintWriter(System.out)
fun main(args: Array<String>) {
    func()
    pw.flush()
}
fun println(value: Any) { pw.println(value) }

fun func() {
    val (N, X) = listOfInt()
    val L = listOfInt()
    var d = 0
    var ans = 1
   for  (n in 0 until N) {
        d += L[n]
        if (d <= X) ans++
        else break
    }
    println("${ans}")
}

fun next() = readLine()!!
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }


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

#define rep(i, n) for(int i = 0; i<(n); i++)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef long long ll;

int main() {
    string S;
    cin >> S;

    rep(msk, 1 << 3) {
        int sm = S[0] - '0';
        rep(i, 3) {
            if (msk & (1 << i)) sm += S[i + 1] - '0';
            else sm -= S[i + 1] - '0';
        }
        if (sm == 7) {
            cout << S[0];
            rep(i, 3) {
                if (msk & (1 << i)) cout << "+";
                else cout << "-";
                cout << S[i + 1];
            }
            cout << "=7" << endl;
            return 0;
        }
    }
}

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

using namespace std;

#define EPS 1e-10

struct Point{
    double x,y;

    Point(){}
    Point(double x,double y) : x(x),y(y) {}

    Point operator + (const Point &p)const{ return Point(x+p.x,y+p.y); }
    Point operator - (const Point &p)const{ return Point(x-p.x,y-p.y); }
    Point operator * (const double &k)const{ return Point(x*k,y*k); }
};

double dot(const Point &a,const Point &b){ return a.x*b.x+a.y*b.y; }
double cross(const Point &a,const Point &b){ return a.x*b.y - b.x*a.y; }
double norm(const Point &p){ return dot(p,p); }
double abs(const Point &p){ return sqrt(norm(p)); }

#define COUNTER_CLOCKWISE 1
#define CLOCKWISE -1
#define ONLINE_BACK 2
#define ONLINE_FRONT -2
#define ON_SEGMENT 0
typedef Point Vector;

int ccw(Point p0,Point p1,Point p2){
    Vector a = p1 - p0;
    Vector b = p2 - p0;
    if(cross(a,b) > EPS){ return COUNTER_CLOCKWISE; }
    if(cross(a,b) < -EPS){ return CLOCKWISE; }
    if(dot(a,b) < -EPS){ return ONLINE_BACK; }
    if(norm(a) < norm(b)){ return ONLINE_FRONT; }
    return ON_SEGMENT;
}

struct Segment{
    Point s,t;
    Segment(){}
    Segment(Point s,Point t) : s(s),t(t) {}
};

Point projection(const Segment &s,const Point &p){
    Vector b = s.t-s.s;
    double t = dot(p-s.s,b)/norm(b);
    return s.s+b*t;
}

bool isIntersectSP(const Segment &s,const Point &p){
    return (ccw(s.s,s.t,p) == 0);
}

bool isIntersectSS(const Segment &a,const Segment &b){
    Point s[2] = {a.s,a.t}, t[2] = {b.s,b.t};
    return (ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
            ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0);
}

double distanceSP(const Segment &s,const Point &p){
    Point r = projection(s,p);
    if(isIntersectSP(s,r)) return abs(r-p);
    return min(abs(s.s-p),abs(s.t-p));
}

double distanceSS(const Segment a,const Segment b){
    if(isIntersectSS(a,b)){ return 0; }
    return min(min(distanceSP(a,b.s),distanceSP(a,b.t)),
               min(distanceSP(b,a.s),distanceSP(b,a.t)));
}

int main(){
    int Q;
    Segment s1,s2;
    cin >> Q;
    while(Q--){
        cin >> s1.s.x >> s1.s.y >> s1.t.x >> s1.t.y;
        cin >> s2.s.x >> s2.s.y >> s2.t.x >> s2.t.y;
        printf("%.12f\n",distanceSS(s1,s2));
    }
    return 0;
}

Measured memory_bytes: 1248
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

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

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}

template<class t>
istream& operator>>(istream& is, vector<t> &x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream& is, pair<t, u> x){
    is >> x.first >> x.second;
    return is;
}


ll factorial(ll x){
    if(x<=1)return 1;
    const int X_MAX = 400001;
    static vector<ll> dp(X_MAX, -1);
    if(dp[x]>=0)return dp[x];
    return dp[x] = x * factorial(x-1) % MOD;
}

ll C(ll a, ll b){
    ll res1 = factorial(a) * modinv(factorial(b)) % MOD;
    return res1 * modinv(factorial(a-b)) % MOD;
}

int main(){
    ll n = in();
    ll k = in();
    ll ans = C(2*n-1, n);
    for(int zeros=k+1;zeros<n;++zeros){
        ans -= C(n, zeros) * C(n-1, n-zeros-1) % MOD;
        ans %= MOD;
        ans += MOD;
        ans %= MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 15872
#include<bits/stdc++.h>
using namespace std;
//typedef
typedef long long ll;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<bool> VB;
typedef vector<VB> VVB;
typedef vector<string> VS;
//repetition
#define FOR(i,a,b) for(int i=int(a); i<int(b); ++i)
#define FORD(i,a,b) for(int i=int(a); i<int(b); --i)
#define REP(i,N) for(int i=0; i<int(N); ++i)
#define REPD(i,N) for(int i=0; i<int(N); --i)
//container util
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())
//constant
#define INF 1000000000000 //10^12:∞
#define MOD 1000000007 //10^9+7
#define MAXR 100000 //配列の最大のrenge
//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int main() {
    ll N; cin>>N;
    ll resA = 10;
    ll resB = 9;
    ll resC = 8;
    REP(i,N-1) {
        resA = resA*10 % MOD;
        resB = resB*9  % MOD;
        resC = resC*8  % MOD;
    }
    ll res = (resA - 2 * resB + resC + 2*MOD) % MOD;
    cout<<res;
}


Measured memory_bytes: 3640
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.Arrays;
import java.util.*;

public class Main {

    //private static Object InputStream;

    public static void main(String args[]) throws IOException {
        // Object input;
       Scanner scan=new Scanner(System.in);
       long A=scan.nextLong();
       long B= scan.nextLong();
       long N=scan.nextLong();
       long x=0;
       if(N<B){
           x=N;
       }
       else if(N==B){
           x=N-1;
       }
       else if(N>B){
           x=B-1;
       }
        System.out.println((int)Math.ceil(A*x/B));
    }

}


Measured memory_bytes: 35800
#include<bits/stdc++.h>
#define ll long long
#define mod 1000000007
#define trace(x) cerr<<#x<<": "<<x<<" "<<endl
#define trace2(x, y) cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z) cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define sa(a,n) for(int i =0 ; i<n ; i++) cin>>a[i]
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define scan() int n; cin>>n ; int a[n]; for(int i = 0 ; i<n ; i++) cin>>a[i]
#define print(a,n) for(int i = 0 ; i < n ; i++) cout<<a[i]<<' '
using namespace std;
template <typename T, typename U>
T max(T x, U y)
{
    return x>y ? x : y;
}
template <typename T, typename U>
T min(T x, U y)
{
    return x<y ? x : y;
}
ll dp[100001];
int32_t main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n,k;cin >> n >> k;
    ll a[n];
    for (int i = 0; i < n; ++i)
    {
        cin >> a[i];
    }
    dp[0]=0;
    for(ll i=1;i<=k;i++)
    {
        bool b =0;
        for (int j = 0; j < n; ++j)
        {
            if(i-a[j]>=0 and dp[i-a[j]]==0)
            {b=1;break;}
        }
        if(b)dp[i]=1;
        else dp[i]=0;
    }
    if(dp[k])cout << "First";
    else cout << "Second";
    }

Measured memory_bytes: 1152
package main

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

func gcd(a, b int) int {
	if a < b {
		a, b = b, a
	}
	for b > 0 {
		a, b = b, a%b
	}
	return a
}

func max(x, y int) int {
	if x > y {
		return x
	}
	return y
}

type segmentTree struct {
	data   []int
	offset int
}

func newSegmentTree(n int) segmentTree {
	var result segmentTree
	t := 1
	for t < n {
		t *= 2
	}
	result.offset = t - 1
	result.data = make([]int, 2*t-1)
	return result
}

func (st segmentTree) update(index, value int) {
	i := st.offset + index
	st.data[i] = value
	for i >= 1 {
		i = (i - 1) / 2
		st.data[i] = gcd(st.data[i*2+1], st.data[i*2+2])
	}
}

func (st segmentTree) _query(start, stop, index, left, right int) int {
	if right <= start || stop <= left {
		return 0
	}
	if start <= left && right <= stop {
		return st.data[index]
	}
	a := st._query(start, stop, index*2+1, left, (left+right)/2)
	b := st._query(start, stop, index*2+2, (left+right)/2, right)
	return gcd(a, b)
}

func (st segmentTree) query(start, stop int) int {
	return st._query(start, stop, 0, 0, st.offset+1)
}

func main() {
	N := readInt()
	A := readInts(N)

	st := newSegmentTree(N)
	for i, v := range A {
		st.update(i, v)
	}

	result := st.query(1, N)
	for i := 1; i < N-1; i++ {
		result = max(result, gcd(st.query(0, i), st.query(i+1, N)))
	}
	result = max(result, st.query(0, N-1))
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}

func readInts(n int) []int {
	result := make([]int, n)
	for i := 0; i < n; i++ {
		result[i] = readInt()
	}
	return result
}

func printIntln(v ...int) {
	b := make([]byte, 0, 4096)
	for i := 0; i < len(v)-1; i++ {
		b = append(b, strconv.Itoa(v[i])...)
		b = append(b, " "...)
	}
	b = append(b, strconv.Itoa(v[len(v)-1])...)
	fmt.Println(string(b))
}


Measured memory_bytes: 6400
#include <stdio.h>

void swap(int *a, int *b) {
    int temp = *a;
    *a = *b;
    *b = temp;
}

// flagを用いたバブルソート
int bubbleSort(int A[], int N) {
    int i, j;
    int sw = 0;
    unsigned short flag = 1;
    for(i = 0; flag; i++) {
        flag = 0;
        for(j = N - 1; j >= i + 1; j--) {
            if(A[j] < A[j - 1]) {
                swap(&A[j], &A[j - 1]);
                flag = 1;
                sw++;
            }
        }
    }
    return sw;
}

int main(void) {
    int i, A[100], N, sw;
    scanf("%d", &N);
    for(i = 0; i < N; i++) scanf("%d", &A[i]);

    sw = bubbleSort(A, N);

    for(i = 0; i < N; i++) {
        if (i) printf(" ");
        printf("%d", A[i]);
    }
    printf("\n%d\n", sw);

    return 0;
}


Measured memory_bytes: 1976
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>
#include <climits>
#include <map>
using namespace std;


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

  map<string, vector<int> > scores;
  map<string, map<int, int > > indexes;
  for (int i = 0; i < N; i++) {
    string s;
    int p;
    cin >> s >> p;
    scores[s].push_back(p);
    indexes[s][p] = i + 1;
  }
  
  for (auto score : scores) {
    sort(score.second.begin(),score.second.end(), greater<int>());
    for (auto sc : score.second){
      cout << indexes[score.first][sc] << endl;
    }
  }

  return 0;
}


Measured memory_bytes: 256
while True:
    n = int(input())
    if n==0:break
    d={}
    for i in range(n):
        c,q,w,e,r,t,y,u,o = input().split()
        d[c] = (int(q)+int(e)+int(t)+int(u))*60+int(w)+int(r)+int(y)+int(o)
    ans = sorted(d.items(), key=lambda x: x[1])
    for j in [0,1,-2]:
        a,b = ans[j]
        print(a)

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

#define REP(i, n) for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n) for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define REP_REV(i, n) for (ll (i) = (ll)(n) - 1 ; (i) >= 0 ; --(i))
#define REPN_REV(i, m, n) for (ll (i) = (ll)(n) - 1 ; (i) >= m ; --(i))
#define ALL(x) x.begin(), x.end()

//#define INF (1e10)
#define MOD (1000000007)

#define print2D(h, w, arr) REP(i, h) { REP(j, w) cout << arr[i][j] << " "; cout << endl; }
template<class T> void print(const T& x) { cout << x << endl; }
template<class T, class... A> void print(const T& first, const A& ... rest) { cout << first << " "; prll(rest...); }
struct PreMain { PreMain() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); } } premain;

ull comb(int n, int r) {
	std::vector<std::vector<ull>> v(n + 1, std::vector<ull>(n + 1, 0));
	for (int i = 0; i < v.size(); i++) {
		v[i][0] = 1;
		v[i][i] = 1;
	}
	for (int j = 1; j < v.size(); j++) {
		for (int k = 1; k < j; k++) {
			v[j][k] = (v[j - 1][k - 1] + v[j - 1][k]);
		}
	}
	return v[n][r];
}

int main() {
	int N, A, B;
	cin >> N >> A >> B;	

	vector<ull> V(N);
	REP(i, N) cin >> V[i];
	sort(V.rbegin(), V.rend());

	double s = 0;
	REP(i, A) s += V[i];

	print(s / A);

	ull a = 0;
	ull b = 0;
	REP(i, A) {
		if (V[i] == V[A - 1]) {
			a++;
		}
	}
	REPN(i, A, N) {
		if (V[i] == V[A - 1]) {
			b++;
		}
	}

	if (a == A) {
		//すべて同じ値だったらB個使ってもいい
		ull ans = 0;
		REPN(j, A, min(static_cast<ull>(B), (a + b)) + 1) {
			ans += comb((a + b), j);
		}
		print(ans);
	}
	else {
		print(comb((a + b), a));
	}

	return 0;
}


Measured memory_bytes: 256
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.io.BufferedWriter;
import java.io.InputStreamReader;
import java.util.StringTokenizer;
import java.io.Writer;
import java.io.OutputStreamWriter;
import java.io.BufferedReader;
import java.io.InputStream;

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

    static class A_Sharing_Cookies {
        public void solve(int testNumber, InputReader in, OutputWriter out) {
            int a = in.nextInt();
            int b = in.nextInt();
            out.printLine(((a + b) % 3 == 0 | (a) % 3 == 0 | (b) % 3 == 0) ? "Possible" : "Impossible");
        }

    }

    static class OutputWriter {
        private final PrintWriter writer;

        public OutputWriter(OutputStream outputStream) {
            writer = new PrintWriter(new BufferedWriter(new OutputStreamWriter(outputStream)));
        }

        public OutputWriter(Writer writer) {
            this.writer = new PrintWriter(writer);
        }

        public void printLine(String s) {
            writer.println(s);
        }

        public void close() {
            writer.close();
        }

    }

    static class InputReader {
        BufferedReader reader;
        StringTokenizer st;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream));
            st = null;
        }

        public String next() {
            while (st == null || !st.hasMoreTokens()) {
                try {
                    String line = reader.readLine();
                    if (line == null) {
                        return null;
                    }
                    st = new StringTokenizer(line);
                } catch (Exception e) {
                    throw new RuntimeException();
                }
            }
            return st.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



Measured memory_bytes: 23380
#include <stdio.h>

int main(void) {

	int a,b,c,cnt;
		cnt = 0;
	scanf("%d" "%d" "%d", &a, &b, &c);
	for( a; a <= b; a++){
		if( c % a == 0){
			cnt = cnt + 1;
		}
	}
printf("%d\n", cnt);
	return 0;
}

Measured memory_bytes: 596
k,n = gets.split.map(&:to_i)
a = gets.split.map(&:to_i)
ans = []
for i in 0..(n-1)
  if i != 0
    x = a[i] - a[i-1]
    ans << x
  else
    x = a[0] + k - a[n-1]
    ans << x
  end
end
puts k - ans.max

Measured memory_bytes: 17156
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto bs = readln.split.to!(int[]);

    int[] solve(int[] as) {
        if (as.empty) {
            return [];
        } else {
            foreach_reverse (i, a; as) {
                if (a == i+1) return solve(as[0..i] ~ as[i+1..$]) ~ a;
            }
            return [-1];
        }
    }

    auto rs = solve(bs);
    if (rs[0] == -1) {
        writeln("-1");
    } else {
        foreach (r; rs) writeln(r);
    }
}

Measured memory_bytes: 380
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);

		int productNum = sc.nextInt();
		int choiseNum = sc.nextInt();
		int totalNum = 0;
		List<Integer> list = new ArrayList<>();
		int num = 0;

		for (int i = 1; i <= productNum; i++ ) {
			num = sc.nextInt();
			list.add(num);
			totalNum += num;
		}


		Collections.sort(list);
		Collections.reverse(list);
		
		for (int i = 1; i <= choiseNum; i++) {
		    if ((list.get(i-1) * 4 * choiseNum) < totalNum) {
		      System.out.println("No");
		      return;  
		    }
		}
		
		System.out.println("Yes");
	}
}

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

namespace AtCorder
{
	public class Program
	{
		const long MOD = 998244353;
		static void Main(string[] args)
		{
			var cin = new Scanner2();
			int n = cin.Int();
			int[] ds = new int[n];
			for (int i = 0; i < n; i++) {
				int d = cin.Int();
				if (i == 0 && d != 0) {
					Console.WriteLine(0);
					return;
				}

				ds[d]++;
			}

			long ans = 1;
			int count = 0;
			for (int i = 0; i < n; i++) {
				if (ds[i] == 0) {
					Console.WriteLine(0);
					return;
				}

				if (i == 0) {
					if (ds[i] != 1) {
						Console.WriteLine(0);
						return;
					}
				} else {
					long prev = ds[i - 1];
					long cur = ds[i];
					for (int j = 0; j < cur; j++) {
						ans = (ans * prev) % MOD;
					}
				}

				count += ds[i];
				if (count >= n) {
					break;
				}
			}

			Console.WriteLine(ans);
		}
	}


	public class Scanner2
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private readonly string filePath_;
		private string[] buf_;
		private int index_;
		Func<string> reader_;

		public Scanner2(string file = "")
		{
			if (string.IsNullOrWhiteSpace(file)) {
				reader_ = Console.ReadLine;
			} else {
				filePath_ = file;
				var fs = new StreamReader(file);
				reader_ = fs.ReadLine;
			}
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = reader_();
			while (st == "") {
				st = reader_();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int() => int.Parse(Next());
		public long Long() => long.Parse(Next());
		public double Double() => double.Parse(Next());

		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}

		public void Save(string text)
		{
			if (string.IsNullOrWhiteSpace(filePath_)) {
				return;
			}

			File.WriteAllText(filePath_ + "_output.txt", text);
		}
	}
}

Measured memory_bytes: 18912
import itertools

K, S = map(int, input().strip().split(' '))

X = range(K + 1)
Y = range(K + 1)
Z = range(K + 1)

count = 0
for i, j in itertools.product(X, Y):
  if S - i - j in Z:
    count += 1
print(count)

Measured memory_bytes: 41564
#include <iostream>
#include <cstdlib>
#include <cstring>
#include <string>
#include <numeric>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

int main() {
    int N;
    vector<int> a;
    
    cin >> N;
    a.push_back(0);
    for (int i = 1; i <= N; i++) {
        int v;
        cin >> v;
        a.push_back(v);
    }
    
    int num_pair = 0;
    for (int i = 1; i <= N; i++) {
        int j = a[i];
        if (i < j && a[j] == i) num_pair++;
    }
    cout << num_pair << endl;
}

Measured memory_bytes: 1020
#include<bits/stdc++.h>
using namespace std;
const long long INF = 1e9;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i,r,n) for(ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i,r,n) for(ll i=(ll)(n-1);i>=r;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(x) x.begin(),x.end()
#define RALL(x) x.rbegin(),x.rend()
#define ll long long int
typedef vector<int> vi;
typedef vector < pair<int, int > > vp;
typedef vector <string> vs;
typedef vector <char> vc;
ll  n, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

/*--------------------template--------------------*/

int main() {
	s = "YES";
	int n, m;
	cin >> n >> m;
	vi v(n + 1);
	REP(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		if (a > b) swap(a, b);
		v[a]++;
		v[b]++;
	}
	REP(i, n) v[i + 1] += v[i];
	REP(i, n + 1) {
		if (v[i] % 2 == 1) {
			s = "NO";
			break;
		}
	}
	cout << s << endl;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define DISP1(as)		for(auto it : as) cout<<it.f<<" "<<it.s<<") ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	2e+5 + 99;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1e+9 + 7;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, k, l, q, x;
string s;

ll a[600],c[505];
vpll b;
vll res;

// < ----------- func eh ---------------- ? //



// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>s;
	ll mini = INF;
	for(ll i=0;i<s.length()-2;i++) {
		mini = min(mini , abs(stoll(s.substr(i,3)) - 753));
	}
	cout<<mini;
}

int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <map>
using namespace std;
int main(void){
    long long n,m,q[100010]={0};
    long long b[100010];
    map<long long,pair<long long,long long>> z{};
    cin>>n>>m;
    for(int i=1;i<=m;i++){
        long long p,y;
        cin>>p>>y;
        z[y].first=i;
        z[y].second=p;
    }
    for(auto x=z.begin();x!=z.end();x++){
        q[x->second.second]++;
        b[x->second.first]=(x->second.second)*1000000+q[x->second.second];
    }
    for(int i=1;i<=m;i++){
        long long u = 100000000000;
        while(b[i]/u==0){
            cout<<0;
            u/=10;
        }
        cout<<b[i]<<endl;
    }
}


Measured memory_bytes: 9344