akhauriyash/Code-Regression huggingface dataset:
A, B = map(int, input().split())
N = int(input())
SF = [[0, 0], [1000, 1000]]
for _ in range(N):
	SF.append(list(map(int, input().split())))
SF.sort()
R = 1
for i in range(N+1):
	if SF[i][1]<=A and B<=SF[i+1][0]:
		R = 0
		break
print(R)



Measured memory_bytes: 5600
//
//  main.cpp
//  Atcoder1
//
//  Created by Hamske on 2020/09/17.
//  Copyright © 2020 Author. All rights reserved.
//

#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#include <string>
#include <sstream>

using namespace std;

//#define pb push_back
//#define mp make_pair
#define fi first
#define se second

typedef long long ll;

//#define rep(_i,iv,n) for(int _i=(int)(iv);_i<(int)(n);++_i)
#define rep0(_i,n) for(int _i=0;_i<(int)(n);++_i)
//#define REP(_i,iv,_l,n) for(int _i=(int)(iv),_l=(int)(n);_i<_l;++_i)
#define REP0(_i,_l,n) for(int _i=0,_l=(int)(n);_i<_l;++_i)

//#define all(x) (x).begin(),(x).end()
#define REPV(v,_itr,_end) for(auto _itr=(v).begin(),_end=(v).end();_itr!=_end;++_itr)
#define REPVC(v,_itr,_end) for(auto _itr=(v).cbegin(),_end=(v).cend();_itr!=_end;++_itr)

#define td typedef
//#define tds(stl,type,name) typedef stl<type > name;
#define tdv(type,name) typedef vector<type > name;

typedef vector<bool> vb;
typedef vector<vb > vvb;
typedef vector<int> vi;
typedef vector<vi > vvi;
typedef vector<ll> vll;
typedef vector<vll > vvll;

#define INF 1<<30

td pair<int, int > pii;
td priority_queue<pii,vector<pii>,greater<pii> > pq;

int find(vi& G,int i){
    int pi=i;
    while (pi!=G[pi]) {
        pi=G[pi];
    }
    while (G[i]!=pi) {
        int temp=G[i];
        G[i]=pi;
        i=temp;
    }
    return pi;
}
bool sameRoot(vi& G,int i,const int j,int *const pi,int *const pj){
    if(i==j){
        return true;
    }
    int pi1=i;
    bool sameFlg=false;
    while (pi1!=G[pi1]) {
        pi1=G[pi1];
        if(pi1==j){
            sameFlg=true;
            break;
        }
    }
    while (G[i]!=pi1) {
        int temp=G[i];
        G[i]=pi1;
        i=temp;
    }
    if(sameFlg){
        return true;
    }
    *pi=pi1;
    *pj=find(G,j);
    return pi1==*pj;
}


void mergeUF(vi& G,vi& rank,const int p1,const int p2){
    if(rank[p1]>rank[p2]){
        G[p2]=p1;
    }else if(rank[p1]>rank[p2]){
        G[p1]=p2;
    }else{
        G[p2]=p1;
        ++rank[p1];
    }
}

int main(int argc, const char * argv[]) {
    int N,M;
    cin>>N>>M;
    
    vi G(N),rank(N,0);
    rep0(i, N){
        G[i]=i;
    }
    int ufNum=N;
    
    rep0(i, M){
        int a1,b1;
        cin>>a1>>b1;
        --a1;
        --b1;
        int pa,pb;
        if(!sameRoot(G, a1, b1, &pa, &pb)){
            mergeUF(G, rank, pa, pb);
            --ufNum;
        }
    }
    cout<<(ufNum-1)<<endl;
    return 0;
}


Measured memory_bytes: 3620
#!usr/bin/env python3
from collections import defaultdict,deque
from heapq import heappush, heappop
from itertools import permutations
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)
mod = 1000000007

def solve():
    n = I()
    s = LI()
    q = I()
    t = LI()
    ans = 0
    for i in t:
        j = bisect.bisect_left(s,i)
        if j < n and i == s[j]:
            ans += 1
    print(ans)
    return

#Solve
if __name__ == "__main__":
    solve()



Measured memory_bytes: 17460
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=1282>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

int Getnum(int& idx,const string& str,map<char,int>& storage1,map<pair<char,int>,int>& storage2){
    int ret = 0;
    if(isdigit(str[idx])){
        while(isdigit(str[idx])){
            ret = ret*10 + (str[idx++]-'0');
        }
    }else{
        char alpha = str[idx++];
        idx++; // [
        int val = Getnum(idx,str,storage1,storage2);
        idx++; // ]
        if(storage1[alpha] <= val) return -1;
        if(storage2.count(pair<char,int>(alpha,val))==0) return -1;
        return storage2[pair<char,int>(alpha,val)];
    }
    return ret;
}
bool declaration_assignment(int& idx,const string& str,
                            map<char,int>& storage1,map<pair<char,int>,int>& storage2){
    char alpha = str[idx++];
    idx++; // [
    int val1 = Getnum(idx,str,storage1,storage2);
    if(val1 == -1) return false;
    idx++; // ]
    if(str.length() == idx){
        storage1[alpha] = val1;
        return true;
    }
    idx++; // =
    if(storage1[alpha] <= val1) return false;
    int val2 = Getnum(idx,str,storage1,storage2);
    if(val2 == -1) return false;
    storage2[pair<char,int>(alpha,val1)] = val2;
    return true;
}
int solve(const string& firstline){
    int res = 0;
    map<char,int> storage1;
    map<pair<char,int>,int> storage2;
    vector<string> Lines; Lines.push_back(firstline);
    string str;
    while(cin >> str){
        if(str == ".") break;
        Lines.push_back(str);
    }
    for(int i = 0;i < Lines.size();i++){
        int idx = 0;
        if(!declaration_assignment(idx, Lines[i], storage1, storage2)) return i + 1;
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    string str;
    while(cin >> str){
        if(str == ".") break;
        cout << solve(str) << endl;
    }
    return 0;
}



Measured memory_bytes: 3160
import Data.List.Split

solve :: [Int] -> Int -> String
solve [x] maxnum = if maxnum - x <= 1 then "Yes" else "No"
solve (x:xs) maxnum = if maxnum - x > 1 then "No" else solve xs (max maxnum x)

main = do
    getLine
    line <- getLine
    let nums = map read (splitOn " " line)
    putStrLn $ solve nums 0


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

int main(){
    int W, H, N; cin >> W >> H >> N;
    int W_begin=0, W_end=W, H_begin=0, H_end=H; 
    for (int i=0; i<N; i++){
        int x, y, a; cin >> x >> y >> a;
        switch (a) {
            case 1: 
                if (x>W_begin) W_begin=x;
                break;
            case 2:
                if (x<W_end) W_end=x;
                break;
            case 3:
                if (y>H_begin) H_begin=y;
                break;
            case 4:
                if (y<H_end) H_end=y;
                break;
        }

    }
    if (W_end-W_begin<=0 || W_end-W_begin<=0) cout << 0 << endl;
    else cout << (W_end-W_begin)*(H_end-H_begin) << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  int d;
  if(n<10) d = n;
  else if(n < 100) d = 9;
  else if(n < 1000){
    d = 9 + (n -99); 
  }
  else if(n < 10000){
    d = 909;
  }
  else if(n < 100000){
    d = 909 + (n - 9999);
  }
  else{
    d = 90909;
  }
  cout << d;


}

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

int main(){
  int x;
  vector<int> a(100);
  vector<int> b(100);
  cin >> x;
  
  for(int i=0; i<x; i++){
    cin >> a.at(i);
    cin >> b.at(i);
  }
  
  int cnt=0;
  for(int i=0; i<x; i++){
    if(a.at(i)==b.at(i)) cnt++;
    else cnt=0;
    
    if(cnt==3) break;
  }
  
  if(cnt>=3) cout << "Yes";
  else cout << "No";
}

Measured memory_bytes: 3648
#include"bits/stdc++.h"
using namespace std;
typedef long long ll;
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {

    ll a,b,c,s=0;
    cin >> a;
    cin >> b >> c;
    for(int i=b;i<=c;i++){
        if(i%a==0){
            s=1;
            break;
        }
    }
    if(s==1)cout << "OK" << endl;
    else cout << "NG" << endl;
}


Measured memory_bytes: 3600
import sys

sys.setrecursionlimit(10000000)
import os
import math
import bisect
import collections
import itertools
import heapq
import re
import queue

# import fractions

ii = lambda: int(sys.stdin.buffer.readline().rstrip())
il = lambda: list(map(int, sys.stdin.buffer.readline().split()))
fl = lambda: list(map(float, sys.stdin.buffer.readline().split()))
iln = lambda n: [int(sys.stdin.buffer.readline().rstrip()) for _ in range(n)]

iss = lambda: sys.stdin.buffer.readline().decode().rstrip()
sl = lambda: list(map(str, sys.stdin.buffer.readline().decode().split()))
isn = lambda n: [sys.stdin.buffer.readline().decode().rstrip() for _ in range(n)]

lcm = lambda x, y: (x * y) // math.gcd(x, y)
# lcm = lambda x, y: (x * y) // fractions.gcd(x, y)

MOD = 10 ** 9 + 7
MAX = float('inf')


def main():
    if os.getenv("LOCAL"):
        sys.stdin = open("input.txt", "r")

    N = ii()
    A = il()
    B = il()
    C = il()

    ret = 0
    for n in range(N):
        ret += B[A[n] - 1]
        if n > 0 and A[n] == A[n - 1] + 1:
            ret += C[A[n - 1]-1]
    print(ret)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3952
#include<stdio.h>
#define MAX 10000
#define NOT   -1

struct Node{int p, l, r;};
struct Node T[MAX];
int n,H[MAX],A[MAX];

int getDepth(int);
int getSibling(int);
void Print(int);

int main( ){
  int i,j,k,l,v,c,r,p;
  scanf("%d",&n);
  for(i = 0; i<n; i++){
    T[i].p = NOT;
  }

  for(i = 0; i < n; i++){
    scanf("%d %d %d",&v, &l,&r);
    T[v].l =l;
    T[v].r = r;
    if( l != NOT){
      T[l].p = v;
    }
    if(r != NOT){
      T[r].p = v;
    }
  }

    for(i = 0; i < n; i++){
      A[i] = getDepth(i);
      H[i] = 0;
    }
    for(i = 0; i < n; i++){
      if(T[i].l == NOT && T[i].r == NOT){
	H[i] = 0;
	 p = T[i].p;
	 c = 1;
	 while(1){
	   if(p == NOT) break;
	   if(H[p] < c)
	     H[p] = c;
	   c++;
	   p = T[p].p;
	   
	 }
      }
    }

    for(i = 0; i < n; i++) Print(i);
    
    return 0;
  }

int getDepth(int u){
  int k = 0;
  while(1){
    u = T[u].p;
    if(u == NOT) break;
    k++;
  }
  return k;
}

void Print(int u){
  int i,c =0;
  printf("node %d: ",u);

  printf("parent = %d, ",T[u].p);
  printf("sibling = %d, ",getSibling(u));

  if(T[u].l != NOT) c++;
  if(T[u].r != NOT) c++;

  printf("degree = %d, ", c);
  printf("depth = %d, ", A[u]);
  printf("height = %d, ", H[u]);

  if ( T[u].p == NOT ){
    printf("root\n");
  }
  else if ( T[u].l == NOT && T[u].r == NOT ){
    printf("leaf\n");
  }
  else {
    printf("internal node\n");
  }
}

 int getSibling(int u){
  if(T[u].p == NOT)
    return NOT;
  if(T[T[u].p].l != u && T[T[u].p].l != NOT)
    return T[T[u].p].l;
  if(T[T[u].p].r != u && T[T[u].p].r != NOT)
    return T[T[u].p].r;
  return NOT;
}



Measured memory_bytes: 2104
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if (a < b) {
			System.out.println("a < b");
		} else {
			if (a == b) {
				System.out.println("a == b");
			} else {
				System.out.println("a > b");
			}
		}
	}

}


Measured memory_bytes: 26192
import sys
import math
from collections import Counter
import itertools
import fractions
#from functools import reduce

# 入力を整数に変換して受け取る
def II(): return int(sys.stdin.readline())
def MI(): return map(int, sys.stdin.readline().split())
# 入力全てを整数に変換したものの配列を受け取る
def LI(): return list(map(int, sys.stdin.readline().split()))
# 入力全てを整数に変換して1引いたものの配列を受け取る
def LLI(rows_number): return [LI() for _ in range(rows_number)]
def SR(): return sys.stdin.readline().rstrip()

ascii_lowercase = 'abcdefghijklmnopqrstuvwxyz'
ascii_uppercase = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ'
ascii_uppercase2 = 'ABCDEFGHIJKLMNOPQRSTUVWXYZABCDEFGHIJKLMNOPQRSTUVWXYZ'

# リストを改行区切りで出力する
p2D = lambda x: print(*x, sep="\n")
p2E = lambda x: print(''.join(x))
p2S = lambda x: print(*x, sep=" ")

# ###########################################

A=SR()
T=SR()



if A==T[:len(T)-1]:
    print('Yes')
else:
    print('No')


Measured memory_bytes: 10320
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <set>
#include <cmath>
using namespace std;

int main()
{
	string s, t;
	cin >> s >> t;
	int ans = 1000000000;
	for (/*unsigned*/ int i = 0; i <= s.size()-t.size(); i++) {
		int cur = 0;
		for (/*unsigned*/ int j = 0; j < t.size(); j++) {
			if (s[i+j] != t[j]) cur++;
		}
		ans = min(ans, cur);
	}
	cout << ans;
}



Measured memory_bytes: 3624
/*
author : seryu
title : ABC170A_"Five Variable"
*/
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i = 0; i < n; i++)
#define reps(i,n) for(int i = 1; i <= n; i++)
#define rrep(i,n) for(int i = n-1; i >= 0; i--)
#define rreps(i,n) for(int i = n; i >= 1; i--)
#define mrep(i,j,n) for(int i = j; i < n; i++)
#define mreps(i,j,n) for(int i = j; i <= n; i++)
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define ERASE(x,val) x.erase(remove(all(x), val), x.end())
#define MOD 1000000007
typedef long long ll;
typedef pair<int, int> P;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }

void solve()
{
	int x[5];
	rep(i, 5)cin >> x[i];
	rep(i, 5)if(x[i] == 0)cout << i+1 << endl;
	return;	
}

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 3540
#include "bits/stdc++.h"
#define long int64_t
using namespace std;

struct Solver {
	void solve() {
		int N;
		cin >> N;
		vector<int> C( N ), S( N ), F( N );
		for( int i = 0; i < N-1; ++i ) {
			cin >> C[i] >> S[i] >> F[i];
		}

		for( int i = 0; i < N; ++i ) {
			int t = 0;
			for( int j = i; j < N-1; ++j ) {
				if( t < S[j] ) { t = S[j]; }
				else if( t % F[j] != 0 ) {
					t = t + F[j] - t % F[j];
				}
				t += C[j];
			}
			cout << t << endl;
		}
	}
};

int main() {
	ios::sync_with_stdio( false );
	cout << fixed << setprecision( 10 );
	Solver().solve();
	return 0;
}


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

using namespace std;

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

#define each(i,a) for (auto&& i : a)
#define FOR(i,a,b) for (ll i=(a),__last_##i=(b);i<__last_##i;i++)
#define RFOR(i,a,b) for (ll i=(b)-1,__last_##i=(a);i>=__last_##i;i--)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define __GET_MACRO3(_1, _2, _3, NAME, ...) NAME
#define rep(...) __GET_MACRO3(__VA_ARGS__, FOR, REP)(__VA_ARGS__)
#define rrep(...) __GET_MACRO3(__VA_ARGS__, RFOR, RREP)(__VA_ARGS__)
#define pb push_back
#define all(a) (a).begin(),(a).end()
#define chmin(x,v) x = min(x, v)
#define chmax(x,v) x = max(x, v)

const ll linf = 1e18;
const int inf = 1e9;
const double eps = 1e-12;
const double pi = acos(-1);

template<typename T>
istream& operator>>(istream& is, vector<T>& vec) {
    each(x,vec) is >> x;
    return is;
}
template<typename T>
ostream& operator<<(ostream& os, const vector<T>& vec) {
    rep(i,vec.size()) {
        if (i) os << " ";
        os << vec[i];
    }
    return os;
}
template<typename T>
ostream& operator<<(ostream& os, const vector< vector<T> >& vec) {
    rep(i,vec.size()) {
        if (i) os << endl;
        os << vec[i];
    }
    return os;
}
map<ll, ll> input() {
    ll n; cin >> n;
    vector<ll> D(n); cin >> D;
    map<ll, ll> res;
    each(i, D) res[i]++;
    return res;
}
bool solve() {
    auto cnt1 = input();
    auto cnt2 = input();
    each(p, cnt2) {
        if (cnt1[p.first] < p.second) return false;
    }
    return true;
}
int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    if (solve()) {
        cout << "YES" << endl;
    }
    else {
        cout << "NO" << endl;
    }
}



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

int main() {
    ll n,l;
    std::cin >> n>>l;
    std::vector<ll> a(n);
    for (int i = 0; i < n; i++) {
        std::cin >> a[i];
    }
    
    ll start = -1;
    for (int i = 0; i < n-1; i++) {
        if(a[i]+a[i+1]>=l){
            start = i;
            break;
        }
    }
    if(start==-1){
        std::cout << "Impossible" << std::endl;
        return 0;
    }
    
    std::cout << "Possible" << std::endl;
    
    vector<ll> ans;
    
    ans.push_back(start);
    
    for (int i = start-1; i >= 0; i--) {
        ans.push_back(i);
    }
    
    for (int i = start+1; i < n-1; i++) {
        ans.push_back(i);
    }
    
    for (int i = 0; i < ans.size(); i++) {
        std::cout << ans[ans.size()-1-i]+1 << std::endl;
    }
    
    
    
}


Measured memory_bytes: 2548
#include <cstdio>
#include <vector>
#include <algorithm>
#include <cstdint>

int main() {
  int N;
  scanf("%d", &N);

  std::vector<int> A(N), B(N), C(N);

  for (int &a: A) scanf("%d", &a);
  for (int &b: B) scanf("%d", &b);
  for (int &c: C) scanf("%d", &c);

  std::sort(A.begin(), A.end());
  std::sort(B.begin(), B.end());
  std::sort(C.begin(), C.end());

  /*
  A.erase(std::unique(A.begin(), A.end()), A.end());
  B.erase(std::unique(B.begin(), B.end()), B.end());
  C.erase(std::unique(C.begin(), C.end()), C.end());
  */

  std::vector<intmax_t> Cc(B.size());
  for (size_t i=0; i<B.size(); ++i)
    Cc[i] = C.end() - std::upper_bound(C.begin(), C.end(), B[i]);

  for (size_t i=B.size()-1; i>0; --i)
    Cc[i-1] += Cc[i];

  intmax_t res=0;
  for (size_t i=0; i<A.size(); ++i) {
    size_t j;
    j = std::upper_bound(B.begin(), B.end(), A[i]) - B.begin();
    fprintf(stderr, "%zd\n", j);
    if (j < Cc.size())
      res += Cc[j];
  }

  printf("%jd\n", res);
  return 0;
}


Measured memory_bytes: 2304
//雪花飄飄北風嘯嘯
//天地一片蒼茫

#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/rope>
using namespace std;
using namespace __gnu_pbds;
using namespace __gnu_cxx;
#define ll long long
#define ii pair<ll,ll>
#define iii pair<ii,ll>
#define fi first
#define se second
#define debug(x) cout << #x << " is " << x << endl;

#define rep(x,start,end) for(auto x=(start)-((start)>(end));x!=(end)-((start)>(end));((start)<(end)?x++:x--))
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()

ll MAX(ll a){return a;}
ll MIN(ll a){return a;}
template<typename... Args>
ll MAX(ll a,Args... args){return max(a,MAX(args...));}
template<typename... Args>
ll MIN(ll a,Args... args){return min(a,MIN(args...));}

#define indexed_set tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update>

mt19937 rng(chrono::system_clock::now().time_since_epoch().count());

double rnd(){
	const int INF=1e9;
	return (double)(rng()%INF)/INF;
}

int n;
ll c[26];
ll d[400][26];

void gen(){
	rep(x,0,26) c[x]=rng()%100;
	rep(x,0,n) rep(y,0,26) d[x][y]=rng()%20000;
}

ll calc(vector<int> &contest){
	ll last[26];
	
	memset(last,-1,sizeof(last));
	
	ll res=0;
	rep(x,0,n){
		res+=d[x][contest[x]];
		last[contest[x]]=x;
		
		rep(y,0,26) res-=c[y]*(x-last[y]);
	}
	
	return res;
}

//store curr best
ll best;
vector<int> ans;

ll test(double COOLING_RATE,double SCALE_FACTOR){
	vector<int> curr;
	rep(x,0,n){
		curr.push_back(0);
		
		rep(y,0,26) if (d[x][curr[x]]<d[x][y]) curr[x]=y;
	}
	
	ll val=calc(curr);
	
	best=val;
	ans=curr;
	
	double tempreture=1;
	
	auto begin_time=chrono::steady_clock::now().time_since_epoch().count();
	while (chrono::steady_clock::now().time_since_epoch().count()-begin_time<1950000000){
		int idx=rng()%n;
		int type=curr[idx];
		
		curr[idx]=rng()%26;
	
		ll temp=calc(curr);
		if (temp>val || rnd()<exp((temp-val)*SCALE_FACTOR/tempreture)){
			val=temp;
			
			if (best<val){
				best=val;
				ans=curr;
			}
		}
		else{
			curr[idx]=type;
		}
		
		tempreture*=COOLING_RATE;
	} 
	
	//pls uncomment later
	rep(x,0,n) cout<<ans[x]+1<<endl;
	
	return best;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	
	//freopen("sample2.in","r",stdin);
	
	cin>>n;
	rep(x,0,26) cin>>c[x];
	
	rep(x,0,n){
		rep(y,0,26) cin>>d[x][y];
	}
	
	test(0.999975,0.000006);
	return 0;
	
	for (double cool=0.99998;cool>=0.99997;cool-=0.000005){
		for (double scale=0.000001;scale<=0.00001;scale+=0.000001){
			ll curr=0;
			rep(x,0,20){
				gen();
				curr+=test(cool,scale);
			}
			
			cout<<cool<<" "<<scale<<" "<<curr<<endl;
		}
	}
}


Measured memory_bytes: 4252
#define _CRT_SECURE_NO_WARNINGS

/* include ***********************/
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>

/* define *************************/
//for
#define REP(i,n) for(int i=0,i##_len=(int)(n);i<i##_len;i++)
#define REPS(i,n) for(int i=1,i##_len=(int)(n);i<=i##_len;i++)
#define RREP(i,n) for(int i=(int)(n)-1;i>=0;i--)
#define RREPS(i,n) for(int i=(int)(n);i>0;i--)
#define FOR(i,s,n) for(int i=(int)(s),i##_len=(int)(n);i<i##_len;i++)

//printf
#define PRINTD(d) printf("%d\n",(d))
#define PRINTL(d) printf("%lld\n",(d))

//memset
#define m0(s) memset(s,0,sizeof(s))
#define ml(s) memset(s,63,sizeof(s))
#define fill(s,c) memset(s,c,sizeof(s))

#define INF 1e9

typedef long long ll;


int diff[4][2] = {
	{ 0, -1 },
	{ -1, 0 },
	{ 1, 0 },
	{ 0, 1 },
};

int Min(int a, int b) {
	return (a)<(b) ? (a) : (b);
}
ll Max(ll a, ll b) {
	return (a) > (b) ? (a) : (b);
}
void Swap(int *a, int *b) {
	int tmp = *a;
	*a = *b;
	*b = tmp;
}

int main() {
	char s[5];
	scanf("%s", s);
	int ans = 0;
	REP(i, 4) {
		s[i] == '+' ? ans++ : ans--;
	}
	PRINTD(ans);
}

Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using namespace std;

#define ll long long
#define P pair<int, int>
#define FOR(i, N) for (int i = 0; i < (int)N; i++)
#define FORIN(i, a, b) for (int i = a; i < (int)b; i++)
#define ALL(x) (x).begin(), (x).end()
#define GI(name) \
  int(name);     \
  scanf("%d", &(name))
#define GI2(name1, name2) \
  int(name1), (name2);    \
  scanf("%d %d", &(name1), &(name2))
#define GI3(name1, name2, name3) \
  int(name1), (name2), (name3);  \
  scanf("%d %d %d", &(name1), &(name2), &(name3))
#define GVI(name, size)    \
  vector<int>(name)(size); \
  FOR(i, (size)) scanf("%d", &(name)[i])
#define GS(name) \
  string(name);  \
  cin >> (name);
#define MOD 1000000007
#define DEBUG(...) debug(__LINE__, ":" __VA_ARGS__)

string to_string(string s) {
  return s;
}

template <class T>
string to_string(vector<T> v) {
  string ret = "{";
  FOR(i, v.size() - 1) { ret += to_string(v[i]) + ","; }
  if (v.size() > 0) {
    ret += to_string(v.back());
  }
  ret += "}";
  return ret;
}

void debug() {
  cerr << endl;
}

template <class Head, class... Tail>
void debug(Head head, Tail... tail) {
  cerr << to_string(head) << " ";
  debug(tail...);
}

void print() {
  cout << endl;
}

template <class Head, class... Tail>
void print(Head head, Tail... tail) {
  cout << to_string(head);
  print(tail...);
}

int main() {
  GI(N);
  GVI(a, N);
  int sum = accumulate(ALL(a), 0);
  int ans = 0, mindiff = sum;
  FOR(i, N) {
    int diff = abs(sum - a[i] * N);
    if (diff < mindiff) {
      ans = i;
      mindiff = diff;
    }
  }
  print(ans);
  return 0;
}

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

#define pb push_back
#define mp make_pair
#define fs first
#define se second

typedef long long LL;

int n;
string s;
int putFirst, putLast , nowCount;

int main() {
 //   freopen("test.txt","r",stdin);
    cin >> n ;
    cin >> s;
    for (int i =0  ; i < s.size() ; i++) {
        if ( s[i] == '(' ) nowCount++;
        else {
            nowCount--;
            if ( nowCount == -1) {
                nowCount = 0;
                putFirst++;
            }
        }
    }
    putLast = nowCount;

    for (int i =1 ; i <= putFirst; i++) {
        cout << "(";
    }
    cout << s;

    for (int i = 1; i <= putLast; i++) {
        cout << ")";
    }
}


Measured memory_bytes: 256
#include <cstdio>
using namespace std;
int N;
int main() {
  scanf("%d", &N);
  bool ok = true;
  for(int i = 0, A; i < N; ++i) {
    scanf("%d", &A);
    if(A%2==1) continue;
    if(A%3==0 || A%5==0) continue;
    ok = false;
    break;
  }
  printf("%s\n", ok?"APPROVED":"DENIED");
}

Measured memory_bytes: 128
#include<iostream>
#include<string>
#include<algorithm>
#include<iomanip>
using namespace std;
#define pi 3.141592653589793283462
int main(){
	int n;
	int ca=0;
	int cb=0;
	int ia,ib;
	while(1){
		cin>>n;
		if(n==0)
			break;
		for(int i=0;i<n;i++){
		cin>>ia>>ib;
		if(ia>ib)
			ca+=(ia+ib);
		else if(ia<ib)
			cb+=(ia+ib);
		else{
			ca+=ia;
			cb+=ib;
		}
	}
		cout<<ca<<" "<<cb<<endl;
		ca=0;
		cb=0;
   }
	return 0;
}

Measured memory_bytes: 1156
#include<stdio.h>
long long sum=0;
int main(){
	int n,d[55];
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&d[i]);
	}
	for(int i=1;i<=n-1;i++){
		for(int j=i+1;j<=n;j++){
			sum=sum+d[i]*d[j];
		}	
	}
	printf("%lld",sum);
	return 0;
}

Measured memory_bytes: 128
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author tatsumack
 */

#include <iostream>
#include <fstream>

#include <bits/stdc++.h>

#define int long long
#define REP(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define FOR(i, a, b) for (int i = (a), i##_len = (b); i <= i##_len; ++i)
#define REV(i, a, b) for (int i = (a); i >= (b); --i)
#define CLR(a, b) memset((a), (b), sizeof(a))
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define INF 1001001001001001001ll
#define fcout cout << fixed << setprecision(12)

using namespace std;

typedef pair<int, int> P;

class BMixJuice {
public:
    void solve(std::istream& cin, std::ostream& cout) {
        int N, K;
        cin >> N >> K;
        vector<int> p(N);
        REP(i, N) cin >> p[i];
        sort(p.begin(), p.end());
        int res = 0;
        REP(i, K) {
            res += p[i];
        }
        cout << res << endl;

    }
};


signed main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    std::istream& in(std::cin);
    std::ostream& out(std::cout);

    BMixJuice solver;
    solver.solve(in, out);
    return 0;
}


Measured memory_bytes: 3624
h, w = gets.split.map(&:to_i)

a = []
h.times {a << gets.split.map(&:to_i)}

ans = []

h.times do |i|
    (w - 1).times do |j|
        if a[i][j].odd?
            a[i][j + 1] += 1
            ans << [i + 1, j + 1, i + 1, j + 2].join(" ")
        end
    end
end

j = w - 1
(h - 1).times do |i|
    if a[i][j].odd?
        a[i + 1][j] += 1
        ans << [i + 1, j + 1, i + 2, j + 1].join(" ")
    end
end

puts ans.size, ans

Measured memory_bytes: 35324
s = input()
t = input()

import re

s = s.replace("?", ".")[::-1]
t = t[::-1]

for i in range(len(s) - len(t) + 1):
    if re.match(s[i:i+len(t)], t):
        ans = s[:i] + t + s[i+len(t):]
        ans = ans.replace(".", "a")[::-1]
        break

else:
    ans = "UNRESTORABLE"

print(ans)


Measured memory_bytes: 3188
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
template<class T>inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; }return false; }
template<class T>inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; }return false; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

int main() {
    init();

    int n, m, k; cin >> n >> m >> k;
    bool ok = false;
    eFOR(i, 0, n)eFOR(j, 0, m) {
        int sum = m * i + n * j - i * j * 2;
        ok |= sum == k;
    }
    cout << (ok ? "Yes" : "No") << "\n";
}

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

public class Main {
	final int _intMax = Integer.MAX_VALUE; // =2147483647>10^9
	final int _intMin = Integer.MIN_VALUE;
	final long _longMax = Long.MAX_VALUE; // =9223372036854775807L>10^18
	final long _longMin = Long.MIN_VALUE;
	static boolean bElapsed = false;

	void solve() {
		int a = readNum();
		int b = readNum();
		int c = readNum();
		int x = readNum();
		int ans = 0;
		for (int aa = 0; aa <= a; aa++) {
			for (int bb = 0; bb <= b; bb++) {
				for (int cc = 0; cc <= c; cc++) {
					int sum = 500 * aa + 100 * bb + 50 * cc;
					if (sum == x)
						ans++;
				}
			}
		}
		pln(ans);
	}

	int pint(String s) {
		return Integer.parseInt(s);
	}

	long plong(String s) {
		return Long.parseLong(s);
	}

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

	int readNum() {
		String line = readLine();
		return pint(line);
	}

	String[] readFlds() {
		String line = readLine();
		return line.split(" ");
	}

	int[] readNums() {
		String[] flds = readFlds();
		int[] nums = new int[flds.length];
		for (int i = 0; i < flds.length; i++) {
			nums[i] = pint(flds[i]);
		}
		return nums;
	}

	void p(char c) {
		_out.print(c);
	}

	void pln(char c) {
		_out.println(c);
	}

	void p(double d) {
		_out.print(d);
	}

	void pln(double d) {
		_out.println(d);
	}

	void p(long l) {
		_out.print(l);
	}

	void pln(long l) {
		_out.println(l);
	}

	void p(String s) {
		_out.print(s);
	}

	void pln(String s) {
		_out.println(s);
	}

	static BufferedReader _in;
	static PrintWriter _out;

	public static void main(String[] args) {
		long start = System.currentTimeMillis();
		_in = new BufferedReader(new InputStreamReader(System.in));
		_out = new PrintWriter(System.out);
		new Main().solve();
		_out.flush();
		long end = System.currentTimeMillis();
		if (bElapsed) {
			System.err.println((end - start) + "ms");
		}
	}
}


Measured memory_bytes: 21076
#include <bits/stdc++.h>
using namespace std;
const int INF = 0x3f3f3f3f;

int m[205][205],p[205];

int floyd(int n){
	for(int k = 1;k <= n;++k){
		for(int i = 1;i <= n;++i){
			for(int j = 1;j <= n;++j){
				m[i][j] = min(m[i][k]+m[k][j],m[i][j]);
			}
		}
	}
	
	int ans = -INF;
	for(int i = 1;i <= n;++i){
		for(int j = 1;j <= n;++j){
			if(i != j) ans = max(m[i][j],ans);
		}
	}
	
	return ans+1;
}

int bfs(int n){
	memset(p,0,sizeof(p));
	queue <int> q;
	p[1] = 1;
	q.push(1);
	
	while(!q.empty()){
		int u = q.front();q.pop();

		for(int i = 1;i <= n;++i){
			if(m[u][i] == 1){
				if(!p[i]) p[i] = p[u]+1,q.push(i);
				else if(abs(p[u] - p[i]) != 1) return 0;
			}
		}
	}
	return 1;
}

int main()
{
	int n,x;
	scanf("%d",&n);
	
	for(int i = 1;i <= n;++i){
		getchar();
		for(int j = 1;j <= n;++j){
			scanf("%1d",&x);
			if(x) m[i][j] = 1;
			else m[i][j] = INF;
		}
	}
	
	if(bfs(n)) printf("%d\n",floyd(n));
	else printf("-1\n");
	return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void) {
  int h, w;
  int i, j;

  while(1) {
    scanf("%d %d", &h, &w);
    
    if (h == 0 && w == 0)
      break;
    
    for(i = 0; i < h; i++) {
      for (j = 0; j < w; j++) {
	if(i % 2 == 0) {
	  if (j % 2 == 0)
	    putchar('#');
	  else
	    putchar('.');
	}
	else {
	   if (j % 2 == 0)
	    putchar('.');
	  else
	    putchar('#');
	}
      }
      printf("\n");
    }
    printf("\n");
  }
  
  return 0;
}


Measured memory_bytes: 1920
#include<bits/stdc++.h>
#define int long long
using namespace std;
int n,x,_min=1e15+10;
signed main()
{
	scanf("%lld",&n);
	for(register int i=1;i<=5;i++)
	{
		scanf("%lld",&x);
		if(_min>x)
			_min=x;
	}
	int ans=n/_min;
	if(n%_min)
		ans++;
	printf("%lld",ans+4);
	return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        String str = sc.nextLine();
        int len = str.length();
        long mod = (int)Math.pow(10,9)+7;
        long[][] dp = new long[(int)(Math.pow(10, 5))+1][13];
        for(int i=0; i<13; i++) {
            dp[0][i] = 0;
        }
        dp[0][0] = 1;
        int cnt = 0;
        long total = 1;
        
        for(int i=0; i<len; i++) {
            char s = str.charAt(i);
            if(s == '?') {
                for(int j=0; j<13; j++) {
                    dp[i+1][j] = (total+mod*10-dp[i][4-(int)((j+2)/3)]-dp[i][8-(int)((j+1)/3)]-dp[i][12-(int)(j/3)])%mod;
                }
                total = (total*10)%mod;
            } else {
                for(int j=0; j<13; j++) {
                    dp[i+1][j] = 0;
                }
                for(int j=0; j<13; j++) {
                    dp[i+1][(j*10+Character.getNumericValue(s))%13] += dp[i][j];
                }
            }
        }
        System.out.println(dp[len][5]%mod);
        sc.close();
    }
}


Measured memory_bytes: 40712
a = []
5.times do |i|
    a[i] = gets.to_i
end

k = gets.to_i

dis = []
5.times do |i|
    5.times do |j|
        dis.push((a[i]-a[j]).abs)
    end
end
success = true
dis.each do |d|
    if d > k then
        puts ":("
        success = false
        break
    end
end
puts 'Yay!' if success


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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll x;
    cin>>x;
    ll ans=0;
    if(x>=500){
        ans+=(x/500)*1000;
        x=x%500;
    }
    if(x>=5){
        ans+=(x/5)*5;
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
N, M, K = map(int, input().split())
A = list(map(int, input().split()))
B = list(map(int, input().split()))

a, b = [0], [0]
for i in range(N):
	a.append(a[i] + A[i])
for i in range(M):
	b.append(b[i] + B[i])

ans, j = 0, M
for i in range(N + 1):
	if a[i] > K:
		break
	while b[j] > K - a[i]:
		j -= 1
	ans = max(ans, i + j)
print(ans)


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

int main(){
  string S;
  cin >> S;
  int B=0,W=0,c=S.size()%2;
  if(c){
    if(S.at(0)=='1') W++;
    else B++;
  }
  for(int i=c; i<S.size(); i+=2){
    if(S.at(i)=='1') B++;
    else W++;
    if(S.at(i+1)=='1') W++;
    else B++;
  }
  cout << S.size()-max(B,W) << endl;
}


Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf=0x3f3f3f3f;
const int MOD=1e9+7;
const int maxn=1e5+10;
ll gcd(ll a, ll b){return (b==0)?a:gcd(b, a%b);}
bool isPrime(ll n){
    if(n<=3){
        return n>1;
    }
    if(n%6!=1&&n%6!=5){
        return false;
    }
    ll sqr=sqrt(n);
    for(ll i=5;i<=sqr;i+=6){
        if(n%i==0||n%(i+2)==0){
            return false;
        }
    }
    return true;
}
int dis[4][2]={0,1,0,-1,1,0,-1,0};
int read(){
    int x=0,f=1;char c=getchar();
    while (c<'0'||c>'9') {if (c=='-') f=-1;c=getchar();}
    while (c>='0'&&c<='9') x=(x<<1)+(x<<3)+(c^48),c=getchar();
    return x*f;
}


int main()
{
	int n;cin>>n;
	float pi=3.1415926535898;
	printf("%lf\n",pi*2*n);
}
 

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

using namespace std;
#define PI 3.1415926535897932384626433832795
#define MOD (1000000007)
#define EPS (1e-15)
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repc(i, s, n) for (int i = (s); i <= (n); i++)
#define rrep(i, n) for (int i = (n) - 1; i >= 0; i--)
#define rrepc(i, s, n) for (int i = (s); i >= (n); i--)
#define bet(x, a, b) (a) <= (x) && (x) < (b)
typedef long long ll;
typedef unsigned long long ull;

int main()
{
	int N, max_i = 0;
	vector<int> ans;

	cin >> N;

	repc(i, 1, N) {
		if (i * (i + 1) / 2 >= N) {
			max_i = i;
			break;
		}
	}

	while (N > 0) {
		if (N > max_i) {
			ans.push_back(max_i);
			N -= max_i;
			max_i--;
		}
		else {
			ans.push_back(N);
			N = 0;
		}
	}

	rrep(i, ans.size()) cout << ans[i] << endl;

	return 0;
}


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

template<typename T> void drop(const T &x){cout<<x<<'\n';exit(0);}

void milkshake() {
  int n;
  cin >> n;
  int ans = 0;
  for(int i = 1; i < n; i++) {
    ans += (n-1) / i;
  }
  cout << ans << '\n';
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int T=1;
  //cin >> T;
  while(T--) milkshake();

  return 0;
}


Measured memory_bytes: 3664
import Data.List

main = do
  n <- readLn :: IO Int
  ps <- map read . words <$> getLine :: IO [Int]
  qs <- map read . words <$> getLine :: IO [Int]
  putStrLn $ show (ans n ps qs)

ans :: Int -> [Int] -> [Int] -> Int
ans n ps qs = abs $ (f n ps) - (f n qs)

f :: Int -> [Int] -> Int
f n ps = g $ elemIndex ps (sort (permutations [1..n]))

g :: Maybe Int -> Int
g (Just n) = n
g Nothing = 0


Measured memory_bytes: 17788
S = input()
ans = [0] * len(S)
cnt = 1
i = 0
k = None
for j in range(1, len(S) + 1):
    if S[j-1] == "R" and S[j] == "L":
        k = j
    if j == len(S) or (S[j-1] == "L" and S[j] == "R"):
        ans[k-1] = (j - i) // 2
        ans[k] = (j - i) // 2
        if (j - i) % 2 == 1:
            if (k - i) % 2 == 0:
                ans[k] += 1
            else:
                ans[k-1] += 1
        i = j
        k = None
print(*ans)


Measured memory_bytes: 6400
#include <stdio.h>
#include <math.h>

int main(void)
{
  int f, g, h, i, j;
  
  scanf("%d %d %d %d %d", &f, &g, &h, &i, &j);
  
  if( f == 0 ){
      printf("1\n");
  } else if( g == 0 ){
      printf("2\n");
  } else if( h == 0 ){
      printf("3\n");
  } else if( i == 0 ){
      printf("4\n");
  } else {
      printf("5\n");
  } 
  return 0;
}

Measured memory_bytes: 1656
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n,k;cin >>n>>k;
	ll ans =k;
	for(int i = 1; i < n; i++) {
		ans *= k - 1;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
def main():
    s = input()
    length = len(s)
    count = 0
    s2 = s[:((length-1)//2)]
    s3 = s[((length+3)//2-1):]
    if s == s[::-1]:
        count += 1

    if s2 == s2[::-1]:
        count += 1

    if s3 == s3[::-1]:
        count += 1

    return 'Yes' if count == 3 else 'No'


if __name__ == '__main__':
    print(main())

Measured memory_bytes: 3064
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <algorithm>


 int A[100000];
 int n;

  int partition(int p,int r){
    int x;
    int i,j;
    int t;

    x = A[r];
    i = p-1;

     for(j=p;j<r;j++){
       if(A[j]<=x){
         i=i+1;
       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(){

    int q;

     scanf("%d",&n);

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

     q = partition(0,n-1);

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

Measured memory_bytes: 2960
#include<stdio.h>
int main(void){
    int n,m;
    int A[100];
    int i,j,k,t;

    scanf("%d%d",&n,&m);
    for(i=0;i<n;i++){
	scanf("%d",&A[i]);
    }

    for(i=1;i<=m;i++){
        for(j=0;j<n-1;j++){
	    if(A[j]%i>A[j+1]%i)
		 t=A[j],A[j]=A[j+1],A[j+1]=t;	
	}
    }

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

    return 0;
}

Measured memory_bytes: 596
h,w,k=map(int,input().split())
import numpy as np
L=[]
for i in range(h):
    l=list(input())
    for j in range(w):
        if l[j]=='#':
            l[j]=1
        else:
            l[j]=0
    L.append(l)
r=np.asarray(L)
ans=np.sum(r)-k
p=np.sum(r,axis=1)
q=np.sum(r,axis=0)
pp=[]
qq=[]
import itertools as it
for i in range(1,h+1):
    for j in it.combinations([x for x in range(h)],i):
        pp.append(j)
for i in range(1,w+1):
    for j in it.combinations([x for x in range(w)],i):
        qq.append(j)
ok=0
for t in it.product(pp,qq):
    s=0
    for pairs in it.product(t[0],t[1]):
        s += r[pairs[0]][pairs[1]]
    P=0
    for i in t[0]:
        P += p[i]
    Q=0
    for i in t[1]:
        Q += q[i]
    if P+Q-s==ans:
        ok += 1
for i in pp:
    num=0
    for j in i:
        num += p[j]
    if num==ans:
        ok += 1
for i in qq:
    num=0
    for j in i:
        num += q[j]
    if num==ans:
        ok += 1
if ans==0:
    ok += 1
print(ok)

Measured memory_bytes: 27100
import numpy as np
n,k = map(int,input().split())
h = np.array(list(map(int,input().split())))
ans = np.zeros(n, dtype=int)
for i in range(1, n):
    s = max(i-k, 0)
    ans[i] = np.min(ans[s:i]+np.abs(h[s:i]-h[i]))
print(ans[-1])

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

const int MOD=1000000007;
//~ const int MOD=998244353;
const int INF=0x3f3f3f3f;
const ll INFL=0x3f3f3f3f3f3f3f3f;

typedef unsigned int uint;
template<class T,uint mod>
struct RollingHash_{
	vector< uint > hashed, power;

	inline uint mul(uint a, uint b){
		return a*(unsigned long long)b%mod;
	}
	RollingHash_(){}
	RollingHash_(T s, uint base = 10007) {
		int sz = (int) s.size();
		hashed.assign(sz + 1, 0);
		power.assign(sz + 1, 0);
		power[0] = 1;
		for(int i = 0; i < sz; i++) {
			power[i + 1] = mul(power[i], base);
			hashed[i + 1] = mul(hashed[i], base) + s[i];
			if(hashed[i + 1] >= mod) hashed[i + 1] -= mod;
		}
	}

	uint get(int l, int r){
		uint ret = hashed[r] + mod - mul(hashed[l], power[r - l]);
		if(ret >= mod) ret -= mod;
		return ret;
	}
};

string s[210000];
unordered_map<uint,unordered_map<int,int>>mp[1200000];
int cnt[26];
RollingHash_<string,1000000007>rh[210000];
char S[2000000];

int main(){
	int n;cin>>n;
	rep(i,n){
		scanf("%s",S);
		s[i]=S;
	}
	rep(i,n){
		rh[i]=RollingHash_<string,1000000007>(s[i]);
		mp[s[i].size()][rh[i].get(1,s[i].size())][s[i][0]-'a']++;
	}
	ll ans=0;
	rep(i,n){
		memset(cnt,0,sizeof(cnt));
		for(char c:s[i]){
			cnt[c-'a']++;
		}
		for(int j=s[i].size();j>=2;j--){
			if(j!=s[i].size())cnt[s[i][j]-'a']--;
			int sz=s[i].size()-j;
			auto hs=rh[i].get(j,s[i].size());
			for(auto&p:mp[sz+1][hs]){
				if(cnt[p.first])ans+=p.second;
			}
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 202796
#include<bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
#define dbg(x...) do { cout << "\033[32;1m " << #x << " -> "; err(x); } while (0)
void err() { cout << "\033[39;0m" << endl; }
template<template<typename...> class T, typename t, typename... A>
void err(T<t> a, A... x) { for (auto v: a) cout << v << ' '; err(x...); }
template<typename T, typename... A>
void err(T a, A... x) { cout << a << ' '; err(x...); }
#else
#define dbg(...)
#endif
typedef long long ll;
typedef pair<int,int> pi;
typedef vector<int> vi;
template<class T> using vc=vector<T>;
template<class T> using vvc=vc<vc<T>>;
template<class T> void mkuni(vector<T>&v)
{
    sort(v.begin(),v.end());
    v.erase(unique(v.begin(),v.end()),v.end());
}
template<class T>
void print(T x,int suc=1)
{
    cout<<x;
    if(suc==1) cout<<'\n';
    else cout<<' ';
}
template<class T>
void print(const vector<T>&v,int suc=1)
{
    for(int i=0;i<v.size();i++)
    print(v[i],i==(int)(v.size())-1?suc:2);
}
#define lson o<<1
#define rson o<<1|1
#define Lson L,mid,lson
#define Rson mid+1,R,rson
const int maxn=2e5+7;
int lz[maxn<<2];
int mx[maxn<<2];
pi seg[maxn];
vi rr[maxn];
int n,m;
const int INF=0x3f3f3f3f;
void build(int L=0,int R=m+1,int o=1)
{
    if(L==R)
    {
        mx[o]=-m+L-1;
        return;
    }
    int mid=L+R>>1;
    build(Lson);
    build(Rson);
    mx[o]=max(mx[lson],mx[rson]);
}
inline void pushdown(int o)
{
    if(lz[o])
    {
        mx[lson]+=lz[o];
        mx[rson]+=lz[o];
        lz[lson]+=lz[o];
        lz[rson]+=lz[o];
        lz[o]=0;
    }
}
void update(int l,int r,int L=0,int R=m+1,int o=1)
{
    if(l<=L&&r>=R)
    {
        lz[o]++;
        mx[o]++;
        return;
    }
    pushdown(o);
    int mid=L+R>>1;
    if(l<=mid) update(l,r,Lson);
    if(r>mid) update(l,r,Rson);
    mx[o]=max(mx[lson],mx[rson]);
}
int query(int l,int r,int L=0,int R=m+1,int o=1)
{
    if(l<=L&&r>=R)
        return mx[o];
    pushdown(o);
    int mid=L+R>>1;
    int ret=-INF;
    if(l<=mid) ret=max(ret,query(l,r,Lson));
    if(r>mid) ret=max(ret,query(l,r,Rson));
    return ret;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cin>>n>>m;
    for(int i=0;i<n;i++) 
    {
        cin>>seg[i].first>>seg[i].second;
        rr[seg[i].first].push_back(seg[i].second);
    }
    build();
    int ans=n-m;
    for(int i=0;i<=m;i++)
    {
        for(auto u:rr[i])
            update(0,u);
        //dbg(i,query(i+1,m+1));
        ans=max(ans,-i+query(i+1,m+1));
    }
    cout<<ans<<'\n';
}

Measured memory_bytes: 16128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <vector>
#include <string>
#include <queue>
#include <utility>
using namespace std;
using ll = long long;
 
int main() {
	ll n;
	int k;
	cin >> n >> k;
	int keta =1;
	int x = k;
	if (n <= k) {
	cout << 1 << endl;
	return 0;
	}
	while (1) {
		keta++;
		x = x * k;
		if (x > n)  break;
	}
	cout << keta << endl;
	return 0;
}


Measured memory_bytes: 764
#include <iostream>
#include <string>
#include <sstream>
#include <iomanip> 
#include <math.h>
#include <stdio.h>
#include <string.h>
#include <queue>
#include <stack>
#include <vector>
#include <map>
#include <set>
#include <functional>
#include <algorithm>
#include <unordered_map>
#include <unordered_set>
#include <bitset>

using namespace std;

#define MAXN 50000

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

	int n, i, j, k, ans;
	cin >> n;
	ans = n * n * n;
	
	cout << ans << "\n";

	return 0;
}


Measured memory_bytes: 256