akhauriyash/Code-Regression huggingface dataset:
loop do
    a, b, c = gets.split.map(&:to_i)
    break if a == 0
    n = gets.to_i

    tests = (1..n).map { gets.split.map(&:to_i) }
    state = {}

    loop do
        changed = false
        test_num = tests.size
        retests = []
        tests.each do |i, j, k, c|
            if c == 1
                state[i] = state[j] = state[k] = 1
            elsif state[i] == 1 && state[j] == 1
                state[k] = 0
            elsif state[j] == 1 && state[k] == 1
                state[i] = 0
            elsif state[k] == 1 && state[i] == 1
                state[j] = 0
            elsif [i, j, k].any?{|x| state[x] == 0}
                #do nothing
            else
                retests << [i, j, k, c]
            end
        end
        break if retests.size == test_num
        tests = retests
    end

    (1..a+b+c).each do |i|
        puts state[i] || 2
    end
end

Measured memory_bytes: 8932
import Data.List

main :: IO ()
main = do
  n <- getInt
  print $ countIf ((== 8) . length . divisors) [1,3..n]

divisors :: Int -> [Int]
divisors n = [x | x <- [1..n], n `rem` x == 0]

getInt :: IO Int
getInt = read <$> getLine

countIf :: (a -> Bool) -> [a] -> Int
countIf f = length . filter f


Measured memory_bytes: 508
#include <iostream>
#include <stdlib.h>
#include <climits>
using namespace std;

int main(void) {
    int n, min = 0, max = 0, minpos, maxpos;
    int h[100000];
    cin >> n;
    for (int i = 0; i < n; i++) {
        cin >> h[i];
        if (i == 0) {
            min = h[i]; minpos = i;
            max = h[i]; maxpos = i;
        } else {
            if (min >= h[i]) {
                min = h[i];
                minpos = i;
            }
            if (max <= h[i]) {
                max = h[i];
                maxpos = i;
                min = INT_MAX;
                minpos = i;
                continue;
            }
            if ((maxpos < minpos) && (max - min >= 2)) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
#if 0        
        if (i != 0) {
            if (h[i-1]-h[i] >= 2) {
                cout << "No" << endl;
                return 0;
            }
        }
        if (i >= 2) {
            //            if (h[i-2] > h[i-1] && h[i-1] > h[i]) {
            if (h[i-2] > h[i]) {
                cout << "No" << endl;
                return 0;
            }
        }
    }
    cout << "Yes" << endl;
    return 0;
#endif
}


Measured memory_bytes: 640
import math
import itertools
h, w, k = map(int, input().split())
c = []
cnt_ans = 0
for i in range(h):
    c.append(input())
#print(c)
y = itertools.product([0, 1], repeat=h)
x = itertools.product([0, 1], repeat=w)

y = [s for s in y]
x = [s for s in x]

for i in y:
    for j in x:
        cnt_kuro = 0
        for a in range(h):
            if i[a] == 0:
                continue
            for b in range(w):
                if j[b] == 0:
                    continue
                if c[a][b] == "#":
                    cnt_kuro += 1
        if cnt_kuro == k:
            cnt_ans += 1
print(cnt_ans)

Measured memory_bytes: 9116
#include<iostream>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<bits/stdc++.h>
#include<limits>

#define lp2(i,n) for(int i=0;i<n;i++)
#define lp3(i,a,b) for(int i=a;i<b;i++)

using namespace std;
int main(){
  int n,a,h[100002]={},mx=INT_MIN;
  cin>>n;
  lp2(i,n){
    cin>>a;
    if(a!=0){
    h[a]++;
    h[a-1]++;
    h[a+1]++;
    }else{
      h[a]++;
    }
    if(mx<=a)mx=a;
  }
  int ans=INT_MIN;
  lp3(i,0,a+1){
    if(h[i]>ans)ans=h[i];
  }
  cout<<ans<<endl;
  return 0;
  
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i, a, b) for (int i = a; i < (b); i++)
#define rrep(i, a, b) for (int i = a; i >= (b); i--)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
template <class T>
inline bool chmin(T& a, T b) {
   if (a > b) {
      a = b;
      return true;
   }
   return false;
}
template <class T>
inline bool chmax(T& a, T b) {
   if (a < b) {
      a = b;
      return true;
   }
   return false;
}
void hr() {
   cerr << "--------------" << endl;
}
const int INF = 1001001001;
const int MOD = 1000000007;

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

   string s;
   cin >> s;
   int n = s.size();
   reverse(s.begin(), s.end());
   const int m = 2019;
   vector<int> cnt(m);
   int x = 1, tot = 0;
   ll ans = 0;
   rep(i, 0, n) {
      cnt[tot]++;
      (tot += (s[i] - '0') * x) %= m;
      ans += cnt[tot];
      x = x * 10 % m;
   }
   cout << ans << endl;

   return 0;
}

Measured memory_bytes: 3744
#ifdef LOCAL111
	#define _GLIBCXX_DEBUG
#else
	#define NDEBUG
#endif
#define _USE_MATH_DEFINES
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <type_traits>
#include <typeindex>
#include <unordered_map>
#include <unordered_set>
#endif
const int INF = 1e9;
using namespace std;
template<typename T, typename U> ostream& operator<< (ostream& os, const pair<T,U>& p) { os << '(' << p.first << ' ' << p.second << ')'; return os; }

#define endl '\n'
#define ALL(a)  (a).begin(),(a).end()
#define SZ(a) int((a).size())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#ifdef LOCAL111
	#define DEBUG(x) cout<<#x<<": "<<(x)<<endl
	template<typename T> void dpite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
#else
	#define DEBUG(x) true
	template<typename T> void dpite(T a, T b){ return; }
#endif
#define F first
#define S second
#define SNP string::npos
#define WRC(hoge) cout << "Case #" << (hoge)+1 << ": "
template<typename T> void pite(T a, T b){ for(T ite = a; ite != b; ite++) cout << (ite == a ? "" : " ") << *ite; cout << endl;}
template<typename T> bool chmax(T& a, T b){if(a < b){a = b; return true;} return false;}
template<typename T> bool chmin(T& a, T b){if(a > b){a = b; return true;} return false;}

typedef long long int LL;
typedef unsigned long long ULL;
typedef pair<int,int> P;

void ios_init(){
	//cout.setf(ios::fixed);
	//cout.precision(12);
#ifdef LOCAL111
	return;
#endif
	ios::sync_with_stdio(false); cin.tie(0);
}

int main()
{
	ios_init();
	int n, k;
	cin >> n >> k;
	if(n%k == 0) {
		cout << 0 << endl;
	} else {
		cout << 1 << endl;
	}
	return 0;
}


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

int main(){
    int n, m;
    cin >> n >> m;
    vector<vector<int> > A(m);
    rep(i,n) {
        int a, b;
        cin >> a >> b;
        if(a > m) continue;
        A[m-a].push_back(b);
    }
    ll ans = 0;
    priority_queue<int> pq;
    for(int i = m-1; i >=0; --i){
        for(int b : A[i]){
            pq.push(b);
        }
        if( !pq.empty() ){
            ans += pq.top();
            pq.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include <cmath>
#include <map>
#include <algorithm>
using namespace std;
int main(void){
    int N ,M;
    cin >> N >>M;
    if(N>M){
        for(int i = 0; i<N; i++){
            cout <<M;
        }
        cout << endl;
    }else{
        for(int i = 0; i<M; i++){
            cout <<N;
        }
        cout << endl;
        
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        
        
        // 入力情報
        int N = sc.nextInt();
        int W = sc.nextInt();
        
        long[] w = new long[N];
        long[] v = new long[N];
        
        long maxV = -1;
        for(int i = 0; i < N; i ++){
            w[i] = sc.nextLong();
            v[i] = sc.nextLong();
            if (maxV < v[i]) maxV = v[i];
        }
        
        
        int dpSize = (int)(N * maxV);
        
        // dp[k][v] : k番目以下の品物で価値vより大きくなるような重みの最小値
        long[][] dp = new long[N][dpSize];
        
        for(int i = 1; i < N; i ++){
            for(int j = 0; j < dpSize; j ++) dp[i][j] = 0;
        }
        
        for(int j = 0; j < dpSize; j ++){
            dp[0][j] = (v[0] > j) ? w[0] : 0;
        }
        
        for (int i = 1; i < N; i ++){
            for(int j = 0; j < (int)v[i]; j ++){
                // 加えない場合しかない
                long w1 = dp[i-1][j];
                long w2 = w[i];
                
                dp[i][j] = (0 < w1 && w1 < w2) ? w1 : w2;
            }
            
            // (w[i], v[i])を追加するか考える
            for(int j = (int)v[i]; j < dpSize; j ++){
                // 加えない場合
                long w1 = dp[i - 1][j];
                
                // 加える場合
                long before = dp[i - 1][j - (int)v[i]];
                long w2 = before == 0 ? 0 : (before + w[i]);
                
                dp[i][j] = (0 < w1 && w1 < w2) ? w1 : w2;
            }
            
        }
        
        
        long ans = 0;
        for(int j = dpSize - 1; j >= 0; j --){
            if (0 < dp[N-1][j] && dp[N-1][j] <= W){
                ans = j + 1;
                break;
            }
        }

        // 出力
        System.out.print(ans);
    }
}

Measured memory_bytes: 127712
#include<stdio.h>
int main( )
{
    double r,pi;
    pi=3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034;
    scanf("%lf",&r);
    printf("%lf %lf\n", r*r*pi, 2*pi*r);
    
    return 0 ;
    
    
}

Measured memory_bytes: 648
/**
 * Dont raise your voice, improve your argument.
 * --Desmond Tutu
 */

#include <bits/stdc++.h>
using namespace std;

#define DEBUG
#ifndef DEBUG
#define endl "\n"
#define log(args...)
#else
#define log(args...) { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); logf(_it, args); }
void logf(istream_iterator<string> it) {
}
template<typename T, typename ... Args>
void logf(istream_iterator<string> it, T a, Args ... args) {
	cout << *it << " = " << a << endl;
	logf(++it, args...);
}
#endif

#define forn(i,k,n) for(ll i=(k); i<(n); i++)

const double PI = acos(-1);
typedef long long ll;
#define fori(n) for(ll i=0; i<(n); i++)

#define cins(s) string s; cin>>s;
#define cini(i) int i; cin>>i;
#define cinll(l) ll l; cin>>l;
#define cind(d) double d; cin>>d;
#define cinai(a, n) vi a(n); fori(n) { cin>>a[i]; }
#define cinall(a, n) vll a(n); fori(n) { cin>>a[i]; }
#define cinas(s, n) vs s(n); fori(n) { cin>>s[i]; }
#define cinad(a, n) vd a(n); fori(n) { cin>>a[i]; }

typedef pair<int, int> pii;
typedef pair<double, double> pdd;
typedef vector<double> vd;
typedef vector<bool> vb;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<string> vs;
typedef vector<ll> vll;

void solve() {
	cini(n);

	vs ans;

	function<void(int, string)> nf = [&](int len, string pre) {
		if (len == 0) {
			//ans.push_back(pre);
			cout << pre << endl;
			return;
		}
		char mac = 'a';
		for (char c : pre)
			mac = max(mac, c);

		for (char c = 'a'; c <= mac + 1; c++) {
			nf(len - 1, pre + c);
		}
	};

	nf(n - 1, "a");

	//for (int i = ans.size() - 1; i >= 0; i--)
	//	cout << ans[i] << endl;

}

int main() {
	cin.tie(nullptr);
	std::ios::sync_with_stdio(false);
	solve();
}



Measured memory_bytes: 1536
N = int(input())
H = [int(a) for a in input().split()]

result = 'Yes'

if H[0] >= 1:
    H[0] -= 1

for i in range(N-1):
    diff = H[i+1] - H[i]
    if diff >= 1:
        H[i+1] -= 1
    elif diff == 0:
        pass
    elif diff < 0:
        result = 'No'
        break

print(result)

Measured memory_bytes: 14224
#include <bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;

ll f(ll now) {
    if (now==1) return 1;
    return 1 + 2*f(now/2);
}

int main() {
    ios_base::sync_with_stdio(0);
    ll h; cin >> h;
    cout << f(h) << endl;
}


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

#define rep(i, n) for(int i = 0; i < (n); i++)
#define repp(i, l, r) for(int i = (l); i < (r); i++)
#define per(i, n) for(int i = ((n)-1); i >= 0; i--)
#define perr(i, l, r) for(int i = ((r)-1); i >= (l); i--)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define IINF 1000000000
#define LINF 1000000000000000000
#define SP <<" "<<
#define CYES cout<<"Yes"<<endl;
#define CNO cout<<"No"<<endl;

typedef long long LL;
typedef long double LD;

int n,m;
vector<vector<int>> e;

int ans=0;
void dfs(int x, vector<pair<int,int>> &v){
  vector<pair<int,int>> w = v;
  int k = w.size();
  repp(i, x+1, n){
    int mi=IINF;
    w=v;
    rep(j,k){
      mi=min(mi,e[i][w[j].first]);
      w[j].second=min(w[j].second,e[i][w[j].first]);
      if(mi==0) break;
    }
    if(mi>0){
      int tmp=mi;
      rep(j,k){
        tmp+=w[j].second;
      }
      ans=max(ans,tmp);
      w.push_back({i,mi});
      dfs(i,w);
    }
  }
}

int main(){
  cin >> n >> m;
  int u,v,c;
  e=vector<vector<int>>(n,vector<int>(n,0));
  rep(i,m){
    cin >> u >> v >> c;
    u--,v--;
    e[u][v]=c;
    e[v][u]=c;
  }
  vector<pair<int,int>> aa(1,{0,IINF});
  rep(i,n){
    aa[0].first=i;
    dfs(i,aa);
  }
  cout << ans << endl;
  return 0;
}



Measured memory_bytes: 3212
#include <stdio.h>
#include <string.h>
#define SMAX 10
int main(void)
{
  int i, j, slen, spos;
  long long int res, ans = 0;
  char str[SMAX+1];
  scanf("%s%*c", str);
  slen = strlen(str);
  for (i = 0; i < (1 << (slen - 1)); i++) {
    res = str[0] - '0';
    spos = 1;
    for (j = 0; j < slen - 1; j++) {
      if ((i >> j) & 1) {
      	ans += res;
	res = str[spos++] - '0';
      }
      else {
	res = res * 10 + str[spos++] - '0';
      }
    }
    ans += res;
  }
  printf("%lld\n", ans);
}

Measured memory_bytes: 256
N = int(input())
INF = 10**18

dp = [INF]*(N+1)
dp[0] = 0
for i in range(N+1):
    n6 = 6
    n9 = 9
    if i+1 < N+1:
        dp[i+1] = min(dp[i+1],dp[i]+1)
    while n6 < N+1:
        if i+n6 < N+1:
            dp[i+n6] = min(dp[i+n6],dp[i]+1)
        n6 *= 6
    while n9 < N+1:
        if i+n9 < N+1:
            dp[i+n9] = min(dp[i+n9],dp[i]+1)
        n9 *= 9

print(dp[N])

Measured memory_bytes: 3828
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define drep(i,a,b) for(ll i=(a);i>=(b);--i)
#define SIZE(a) ll((a).size())
#define out(a) cout<<(a)<<endl;
const int inf=INT_MAX;
const int MAX = 510000;
const ll MOD = 998244353;


int main(){
  ll k,a,b;cin>>k>>a>>b;
  vll ans(k);
  if(b==1e9){
    rep(i,0,k){
      if(i<a){ans[i]=b;}
      else ans[i]=b-1;
    }
  }
  else{
    rep(i,0,k){
      if(i<a)ans[i]=b;
      else ans[i]=b+1;
    }
  }
  rep(i,0,k){
    cout<<ans[i]<<" ";
  }
  cout<<endl;
}





Measured memory_bytes: 4052
n,m,q=map(int,input().split())
A=[[0]*(n+1) for i in range(n+1)]
for i in range(m):
  a,b=map(int,input().split())
  A[a][b]+=1
B=[[0]*(n+1) for i in range(n+1)]
for i in range(n+1):
  for j in range(n+1):
    if i!=0 and j!=0:
      B[i][j]=B[i-1][j]+B[i][j-1]+A[i][j]-B[i-1][j-1]
    elif i!=0:
      B[i][j]=B[i-1][j]+A[i][j]
    elif j!=0:
      B[i][j]=B[i][j-1]+A[i][j]
    else:
      B[i][j]=A[i][j]
for i in range(q):
  a,b=map(int,input().split())
  print(B[b][b]-B[a-1][b]-B[b][a-1]+B[a-1][a-1])

Measured memory_bytes: 17116
import java.util.Scanner;

class Main{


	public static void main(String[] args) {

		Scanner sc = new Scanner(System.in);			//文字の入力
		String S1 =sc.next();

		for(int i = 0; i < S1.length();i++){
			if(S1.charAt(i) != S1.charAt(S1.length()-1-i)){
				System.out.println("No");

				return;
			}
		}

		System.out.println("Yes");


	}
}

Measured memory_bytes: 23124
# ABC 047: B – すぬけ君の塗り絵 2 イージー / Snuke's Coloring 2 (ABC Edit)
w, h, n = map(int, input().split())

x_min = [0]
x_max = [w]
y_min = [0]
y_max = [h]

for i in range(n):
    x, y, a = [int(s) for s in input().split()]

    if a == 1:
        x_min.append(x)
    elif a == 2:
        x_max.append(x)
    elif a == 3:
        y_min.append(y)
    elif a == 4:
        y_max.append(y)

width = min(x_max) - max(x_min)
height = min(y_max) - max(y_min)
print(width * height if width >= 0 and height >= 0 else 0)

Measured memory_bytes: 3064
//
//  atcoder.cpp
//
//
///
#include <bits/stdc++.h>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/bimap/bimap.hpp>
#include <boost/bimap/multiset_of.hpp>
#include <boost/multi_array.hpp>
#include <boost/math/common_factor.hpp>
#include <boost/algorithm/string.hpp>

#define REP(i, N) for(int i=0; i<(N); i++)
#define REC(f, ...) (void)0; const auto f = [&](const auto f, __VA_ARGS__)
using namespace std;
using namespace boost::math;

using ll = long long;
namespace bst = boost;
template<typename T> class in {
    T value;
public:
    in() { cin >> value; }
    operator const T&() const { return value; }
    operator T&() { return value; }
    in& operator=(T source) { value = source; return *this; }
};
template<> class in<string> : public string {
public:
    in() { cin >> *this; }
};
template<class T> class inseq : public T {
public:
    template<typename... Arg> inseq(Arg... arg) : T(forward<Arg>(arg)...) { for (auto&& i : *this) cin >> i; }
};
template<class T> using invec = inseq<vector<T>>;

auto solve() {
  in<ll> X;

  int cnt = 0;
  ll now = 100;
  for(;;) {
    cnt++;
    now = now + (now / 100LL);
    if (now >= X) {
      cout << cnt << endl;
      return;
    }
  }
}

template<typename T> void plot(const T& func) { cout << func() << endl; }
template<> void plot<void()>(void(&func)()) { func(); }
template<> void plot<double()>(double(&func)()) { cout << setprecision(9) << func() << endl; }

int main() {
  plot(solve);

  return 0;
}



Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define rep(i, m, n) for(int i = m; i < (n); i++)
#define rrep(i,m,n) for(int i = m; i >= n; i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(int i = 0; i < n; i++){ cout << (x[i]) << " ";} cout << endl;
#define printa2(x,m,n) for(int i = 0; i < m; i++){ for(int j = 0; j < n; j++){ cout << x[i][j] << " ";} cout << endl;}
#define printp(x,n) for(int i = 0; i < n; i++){ cout << "(" << x[i].first << ", " << x[i].second << ") "; } cout << endl;
#define INF (1e18)
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
typedef struct{
    int x;
    int y;
} P;
typedef struct{
    ll to;
    ll cost;
} edge;
typedef pair<ll, ll> lpair;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll N;
    ll A,B,C,D;
    cin >> N;
    cin >> A >> B >> C >> D;
    bool is_ok = false;
    ll val = B - A;
    rep(i,0,N){
        ll plus_val = N-1-i;
        ll plus_min = (N-1-i) * C;
        ll plus_max = (N-1-i) * D;

        ll minus_min = -i * D;
        ll minus_max = -i * C;
        ll v1 = plus_max + minus_max;
        ll v2 = plus_min + minus_min;
        if(val >= v2 && val <= v1){
            is_ok = true;
        }

    }
    if(is_ok){
        print("YES");
    }else{
        print("NO");
    }
    // rep(i,1,N-1){
    //     if(B - val >= D){
    //         val += D;
    //     }else if(val - B >= D){
    //         val -= D;
    //     }else if(B - val >= 0){
    //         val += C;
    //     }else{
    //         val -= C;
    //     }
    //     print(val);
    // }
    // if(abs(val - B) >= C && abs(val-B) <= D){
    //     print("YES");
    // }else{
    //     print("NO");
    // }

}


Measured memory_bytes: 256
def tom(x, y, k):
  n = x
  while n >= x and n <= b:
    if n % k == 0:
      return 'OK'
    n += 1
  return 'NG'
k = int(input())
a, b = map(int, input().split())
result = tom(a, b, k)
print(result)

Measured memory_bytes: 9176
// In the name of GOD
#include<bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<"\n";
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\n";
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<"\n";

#define     IOS         ios::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define 	setprecn(x) cout<<fixed<<setprecision(x);
#define 	ll          long long int
#define 	pb          push_back
#define 	pll         pair<ll,ll>
#define 	vll         vector<ll>
#define 	ff          first
#define 	ss          second
#define 	all(a)      (a).begin(),(a).end()
#define 	sz(x)       (ll)x.size()
#define 	mod         1000000007
#define 	inf         10000000000000007
#define 	rep(i,n)    for(ll i=0;i<n;i++)
#define 	repe(i,a,b) for(ll i=a;i<b;i++)
#define 	lbnd        lower_bound
#define 	ubnd        upper_bound
#define 	bs          binary_search

ll power(ll a,ll b,ll m=mod)
{
	if(b==0)
		return 1;
	if(b==1)
		return a;
	ll c=power(a,b/2,m);
	if(b%2==0)
		return((c%m)*(c%m))%m;
	return ((((c%m)*(c%m))%m)*(a%m))%m;
}
/********************************************************/
//	d.erase(unique(all(d)), d.end());

ll a[10000007];
int main()
{
	IOS;
	ll n,k,m,i,j,c=0,cs=0,t;
	t=1;

	// cin>>t;
	string s;
	while(t--)
	{
		cin>>n;
		// n=s.length();
		// ll a[n];
		for(i=2;i*i<=n;i++)
		{
			if(a[i]==0)
			{
				for(j=i*i;j<=n;j+=i)
				{
					if(a[j]==0) a[j]=i;
				}
			}
		}
		for(i=1;i<=n;i++)
		{
			if(a[i]==0) a[i]=i;
			k=i;
			m=1;
			while(k>1)
			{
				j=0;
				ll x=a[k];
				while(k>1 && k%x==0)
				{
					k/=a[k];
					j++;
				}
				m*=(j+1);
				// debug3(k,a[k],j);
			}
			c+=(i*m);
			// debug3(i,m,c)
		}
		
		cout<<c;

		
		cout<<"\n";
	}
	return 0;
}

Measured memory_bytes: 81704
#include<iostream>
#include<algorithm>
#include<climits>
#include<vector>
#include<utility>//pair
#include<cmath>//abs,sqrt
#include<cstring>
#include<map>
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define prin(arg) std::cout<<arg<<"\n"
#define prin2(arg1,arg2) std::cout<<arg1<<" "<<arg2<<"\n"
#define fill(arg,n) memset(arg,n,sizeof(arg))
typedef long long ll;
const int INF=1e+9;
const ll INFLL=1e+17;
using std::cin;
ll n;
ll a[100010];
ll p[100010];
ll sum[100010];
void parity(ll x){//x以上か否かで分類
  rep(i,n){
    if(a[i]>=x) p[i]=1;
    else p[i]=-1;
  }
}
void cumadd(){
  sum[0]=0;
  rep1(i,n) sum[i]=sum[i-1]+p[i-1];
  rep(i,n+1) sum[i]+=n;
}
template <class X>
class BIT{
  X bit[200010];
  ll n;
 public:
  BIT(ll N);
  ll sum(ll i);
  void add(ll i,ll x);
};
template <class X>
BIT<X>::BIT(ll N){
  n=N;
  for(ll i=0;i<N;i++){
    bit[i]=0;
  }
}
template <class X>
ll BIT<X>::sum(ll i){//iまでの和
  X s=0;
  while(i>0){
    s+=bit[i];
    i-=i&(-i);//最後の1bitを引く(ex.0110なら0010を引く)
  }
  return s;
}
template <class X>
void BIT<X>::add(ll i,ll x){
  while(i<=n){
    bit[i]+=x;
    i+=i&(-i);//最後の1bitを足す
  }
}
ll inv(ll x){
  ll res=0;
  parity(x);
  cumadd();
  BIT<ll> b(200010);
  rep(i,n+1){
    res+=b.sum(sum[i]);
    b.add(sum[i],1);
  }
  return res;
}
bool C(ll x){
  return inv(x)>=(n*(n+1)+1)/4;
}
ll bina(ll min,ll max){
  ll lb=min-1,ub=max+1;
  while(ub-lb>1){
    ll mid=(ub+lb)/2;
    if(C(mid)) lb=mid;
    else ub=mid;
  }
  return lb;
}
int main(){
  cin>>n;
  ll max=0,min=1e+9+1;
  rep(i,n){
    cin>>a[i];
    max=std::max(max,a[i]);
    min=std::min(min,a[i]);
  }
  prin(bina(min,max));
  return 0;
}


Measured memory_bytes: 4096
import java.util.*;


class Main{
public static void main(String[] args) {
  Scanner reader=new Scanner(System.in);
  int k=reader.nextInt();
  int n=reader.nextInt();
  int a[]=new int[n];
  int d=0;
  for(int i=0;i<n;i++)
  {
    a[i]=reader.nextInt();
  }
for(int i=1;i<n;i++)
{
  if(a[i]-a[i-1]>d){
  d=a[i]-a[i-1];

}

}
if(k-a[n-1]+a[0]>d)
{
  d=k-a[n-1]+a[0];
}
System.out.println(k-d);
}
}

Measured memory_bytes: 82828
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}




ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  vector<ll> a(n),b(n);
  rep(i,n) cin>>a[i]>>b[i];
  reverse(ALL(a));
  reverse(ALL(b));
  ll ans=0;
  ll tmp=0;
  rep(i,n){
    a[i]+=ans;
    if(a[i]%b[i]==0) tmp=0;
    else tmp=(b[i]-a[i]%b[i]);
    a[i]+=tmp;
    ans+=tmp;
  }
  cout<<ans<<endl;
}

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

void solve(std::vector<long long> A)
{
    vector<int> b(0);
    b.push_back(abs(A[0] - A[1]));
    b.push_back(abs(A[1] - A[2]));
    b.push_back(abs(A[2] - A[0]));
    sort(b.begin(), b.end());

    cout << (b[0] + b[1]) << endl;
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main()
{
    std::vector<long long> A(3);
    for (int i = 0; i < 3; i++)
    {
        scanf("%lld", &A[i]);
    }
    solve(std::move(A));
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
  public static void main (String[] args) {
    Scanner sc = new Scanner(System.in);

    int n = sc.nextInt();
    int[] a = new int[n];

    int max = 0;
    for (int i = 0; i < n; i++) {
      a[i] = sc.nextInt();
      max = Math.max(max, a[i]);
    }

    for (int i = 0; i < n; i++) {
      if (a[i] == max) {
        int ans = 0;
        for (int j = 0; j < n; j++) {
          if(i != j && a[j] == max) {
            ans = max;
            break;
          } else if (i != j) {
            ans = Math.max(ans, a[j]);
          }
        }
        System.out.println(ans);
      } else {
        System.out.println(max);
      }
    }
    
  }
}


Measured memory_bytes: 94184
#define _CRT_SECURE_NO_WARNINGS

#include <iostream>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <math.h>
#include <functional>
#include <algorithm>
#include <utility>

typedef long long Int;
#define REP(i,n) for(int i = 0 ; i < n ; ++i)
#define REPS(a,i,n) for(int i = a ; i < n ; ++i)
using namespace std;

vector<pair<double, double>> point(4);

typedef pair<double, double> P;

int dot(P a, P b){
	return a.first*b.second - a.second*b.first;
}

bool In(P a, P b, P c, P p){
	auto ab = P(b.first - a.first, b.second - a.second);
	auto bc = P(c.first - b.first, c.second - a.second);
	auto ca = P(a.first - c.first, a.second - c.second);
	auto ap = P(p.first - a.first, p.second - a.second);
	auto bp = P(p.first - b.first, p.second - b.second);
	auto cp = P(p.first - c.first, p.second - c.second);

	return (dot(ab, bp) > 0 && dot(bc, cp) > 0 && dot(ca, ap) > 0 || dot(ab, bp) < 0 && dot(bc, cp) < 0 && dot(ca, ap) < 0);

}

int main(){
	while (scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &point[0].first, &point[0].second, &point[1].first, &point[1].second, &point[2].first, &point[2].second, &point[3].first, &point[3].second) != EOF){
		vector<int> aa = { 0, 1, 2, 3 };
		bool f = true;

		do{
			f &= !In(point[aa[0]], point[aa[1]], point[aa[2]], point[aa[3]]);
		} while (next_permutation(aa.begin(), aa.end()));

		cout << (f?"YES":"NO") << endl;
	}

	return 0;
}

Measured memory_bytes: 1216
#include<iostream>
#include<cstdlib>

using namespace std;


struct island {
int tre;
int bri;
};

int compare (const island *a, const island *b) {
	if ( (*a).bri == (*b).bri ) 
		return (*a).tre - (*b).tre;
	else
		return (*a).bri - (*b).bri;
}


island isls[25];

int main() {


	for (;;) {
		int isl;
		cin >> isl;
		if ( isl == 0 )
			break;
		for ( int i=0; i<isl; i++ ) {
			cin >> isls[i].tre >> isls[i].bri;
		}

		qsort(isls, isl, sizeof(island), (int (*) (const void*, const void*))compare);

		int now = 0;
		bool pass = true;

		for ( int i=0; i<isl; i++ ) {
			now += isls[i].tre;
			if (isls[i].bri < now ) {
				pass = false;
				break;
			}
		}
		if ( pass )
			cout << "Yes\n";
		else
			cout << "No\n";
	}
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
  
#define MAX 100000
#define NLL -1

struct Node {
  	
int p,l,r;
	
};

struct Node nd[MAX];

int n,a[MAX],b[MAX];

void dpth(int x,int y){
if(x==NLL)return;
a[x]=y;
dpth(nd[x].l,y+1);
dpth(nd[x].r,y+1);
}

int hght(int z){
int h1=0,h2=0;
if(nd[z].l!=NLL) h1=hght(nd[z].l)+1;
if(nd[z].r!=NLL) h2=hght(nd[z].r)+1;
return b[z]=(h1>h2?h1:h2);
}
int sibling(int a){
if(nd[a].p==NLL)return NLL;
if(nd[nd[a].p].l!=a&&nd[nd[a].p].l!=NLL)return nd[nd[a].p].l;
if(nd[nd[a].p].r!=a&&nd[nd[a].p].r!=NLL)return nd[nd[a].p].r;
return NLL;
}


void print(int x){
int i,c;

printf("node %d: ",x);
printf("parent = %d, ",nd[x].p);
printf("sibling = %d, ",sibling(x));

int degree=0;

if(nd[x].l!=NLL)degree++;
if(nd[x].r!=NLL)degree++;

printf("degree = %d, ",degree);
printf("depth = %d, ",a[x]);
printf("height = %d, ",b[x]);

if(nd[x].p==NLL)printf("root\n");
else if(nd[x].l==NLL&&nd[x].r==NLL) printf("leaf\n");
else  printf("internal node\n");
}

int main(){
int s,l,r,root=0,i;

scanf("%d",&n);

for(i=0;i<n;i++){
nd[i].p=NLL;
}

for(i=0;i<n;i++){
scanf("%d",&s);
scanf("%d",&l);
scanf("%d",&r);

nd[s].l=l;
nd[s].r=r;

if(l!=NLL)nd[l].p=s;
if(r!=NLL)nd[r].p=s;
}

for(i=0;i<n;i++){
if(nd[i].p==NLL)root=i;
}

dpth(root,0);

hght(root);
for(i=0;i<n;i++)print(i);
return 0;
}




Measured memory_bytes: 2108
S = input()
T = input()

def count_diff(Sp):
    cnt = 0
    for i in range(len(Sp)):
        if T[i] != Sp[i]:
            cnt += 1
    return cnt

saved_cnt = len(T)

for i in range(len(S) - len(T) + 1):

    Sp = S[i:i+len(T)]
    
    cnt = count_diff(Sp)
    
    saved_cnt = min(saved_cnt, cnt)
        
print(saved_cnt)

Measured memory_bytes: 9072
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
  int a,b;
  while(1){
    scanf("%d %d",&a,&b);
    if(a==0 && b==0) break;
    int turi=b-a;
    printf("%d %d %d\n",turi%500/100,turi%1000/500,turi/1000);
  }
}

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

using ll = long long;

const int N = 2e5L + 11;
ll a[N];

bool solve(ll lim, int n) {
	int j = 0, k = 0;
	for(int i = 0; i < n; i ++) {
		while(j < i + n && a[j] - a[i] < lim) j ++;
		while(k < i + n && a[k] - a[j] < lim) k ++;
		if(a[i + n] - a[k] >= lim) return 1;
	}
	return 0;
}

int main() {
	ios :: sync_with_stdio(false);
	int n; cin >> n;
	for(int i = 1; i <= n; i ++) {
		cin >> a[i];
		a[i + n] = a[i];
	}
	partial_sum(a , a + n + n + 1, a);
	ll l = 0, r = 1e18L;
	while(l + 1 < r) {
		ll m = (l + r) / 2;
		if(solve(m, n))
			l = m;
		else
			r = m;
	}
	cout << l << '\n';
}

Measured memory_bytes: 4692
#include <bits/stdc++.h>
#include <iostream>
#include <algorithm>
#include <ctype.h>
#include <math.h>
#include <stack>
#include <string>
#include <string.h>
using namespace std;
double PI = 3.1415926535897932;
long mod = 1000000007;

const long INF = (1<<30);
 
int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] & s[1] == s[2])
    cout << "No" << endl;
  else 
    cout << "Yes" << endl;
}

Measured memory_bytes: 3568
// clang-format off
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define stoi stoll
using pii = pair<int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
#define all(c) begin(c), end(c)
#define rall(c) rbegin(c), rend(c)
#define fore(x, c) for(auto &&x : c)
#define rep(i, a, n) for(int i = a, i##len = (int)(n); i < i##len; ++i)
#define rrep(i, a, n) for(int i = (int)(n - 1); i >= a; --i)
#define sz(c) ((int)c.size())
#define contains(c, x) (c.find(x) != end(c))
#define inseg(l, x, r) ((l) <= (x) && (x) < (r))
#define dump(...)
#define pb push_back
#define eb emplace_back
#define _ 0
const signed INF_ = 1001001001; const long long INF = 1001001001001001001LL;
const int DX[9] = {0,1,0,-1,1,1,-1,-1,0}, DY[9] = {-1,0,1,0,-1,1,1,-1,0};
template<class T> ostream& operator<<(ostream &os, const vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) os<<*i<<(i==end(v)-1?"":" ");return os;}
template<class T> istream& operator>>(istream &is, vector<T> &v) {
  for (auto i = begin(v); i != end(v); i++) is>>*i;return is;}
template<class T,class U> istream& operator>>(istream &is, pair<T,U> &p) {
  is>>p.first>>p.second;return is;}
template<class T, class U> bool chmax(T &a, const U &b){return a<b?a=b,1:0;}
template<class T, class U> bool chmin(T &a, const U &b){return a>b?a=b,1:0;}
template <class T> void psum(T& c) {partial_sum(begin(c), end(c), begin(c));}
template<class T> using heap = priority_queue<T, deque<T>, greater<T>>;
struct before_main_function {
  before_main_function() {
      cin.tie(nullptr); ios::sync_with_stdio(0);
      cout << setprecision(15) << fixed;
  }
} before_main_function;
// clang-format on
//------------------8<------------------------------------8<--------------------

signed main() {
  string s;
  cin >> s;
  string t;
  string hi = "hi";
  rep(i, 0, 20) {
    t += hi;
    if (t == s) {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
  return (0 ^ _ ^ 0);
}



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

int main()
{
	int n;
	cin >> n;
	auto m = map<int, int>();
	for(auto i = 0; i < n; ++i){
		int a;
		cin >> a;
		++m[a];
	}
	int ans = 0;
	for(auto it : m){
		ans += (it.second % 2);
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <algorithm>
#include <cmath>
#include <stack>
#include <array>
#include <queue>
#include <string>
#include <vector>
#include <cstring>
#include <sstream>
#include <iomanip>
#include <new>
#include <map>
#define ESP (1e-13)
#define INF 2000000000
#define ll long long


using namespace std;

int main() {
	int N, K;
	cin >> N >> K;
	ll ans = 4 * 1e18;
	pair<ll, ll> p[50];
	
	for (int i = 0;i < N;i++) {
		cin >> p[i].first;
		cin >> p[i].second;
	}
   

	for (int i = 0;i < N;i++) {
		for (int ii = 0;ii < N;ii++) {
			for (int iii = 0;iii < N;iii++) {
				for (int iiii = 0;iiii < N;iiii++) {
					int unko = 0;
					for (int j = 0;j < N;j++) {
						if (p[i].first <= p[j].first&&p[ii].first >= p[j].first&&p[iii].second <= p[j].second&&p[iiii].second >= p[j].second) unko++;
					}
					if (unko >= K) ans=min(ans, 1LL*(p[ii].first - p[i].first)*(p[iiii].second - p[iii].second));
				}
			}
		}
	}

	cout << ans << endl;

}








Measured memory_bytes: 256
n, m = [int(i) for i in input().split()]

city_list = [0]*n

def func(a,b):
    city_list[a-1] += 1
    city_list[b-1] += 1

for i in range(m):
    a, b = [int(i) for i in input().split()]

    func(a,b)

for j in city_list:
    print(j)


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

using namespace std;

typedef long long int lli;

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

    int a, b;

    cin >> a >> b;

    cout << max(max(a+b, a-b), a*b) << endl;

    return 0;
}


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

int main()
{
    int n;
    cin >> n;
    vector<int> d(n);
    rep(i, n) cin >> d.at(i);
    int m;
    cin >> m;
    vector<int> t(m);
    rep(i, m) cin >> t.at(i);

    map<int, int> problems;
    rep(i, n) problems[d.at(i)]++;

    string answer = "YES";
    rep(i, m)
    {
        // cout << t.at(i) << " " << problems.count(t.at(i)) << endl;
        if (problems[t.at(i)] <= 0)
        {
            answer = "NO";
            break;
        }
        else
        {
            int t_count = problems[t.at(i)];
            problems.erase(t.at(i));
            if (t_count > 1)
            {
                problems[t.at(i)] = t_count - 1;
            }
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 11136
/**
  * http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ITP1_11_C&lang=jp
  * Structure and Class - Dice III
  */
object Main {

  case class Dice(numbers: IndexedSeq[Int]) {
    def apply(number: Int): Int = {
      numbers(number)
    }

    def rotateTo(direction: Char): Dice = {
      direction match {
        case 'N' => Dice(IndexedSeq(numbers(1), numbers(5), numbers(2), numbers(3), numbers(0), numbers(4)))
        case 'S' => Dice(IndexedSeq(numbers(4), numbers(0), numbers(2), numbers(3), numbers(5), numbers(1)))
        case 'W' => Dice(IndexedSeq(numbers(2), numbers(1), numbers(5), numbers(0), numbers(4), numbers(3)))
        case 'E' => Dice(IndexedSeq(numbers(3), numbers(1), numbers(0), numbers(5), numbers(4), numbers(2)))
      }
    }

    def find(number: Int): Int = {
      // returns -1 if not found
      numbers.indexWhere(_ == number)
    }

    def adjustWith(dice: Dice): Dice = {
      val operationsToTop = Seq("", "", "N", "W", "E", "S", "NN")
      val operationsToFront = Seq("", "S", "", "WSE", "ESW", "SEEN", "N")
      val dice2 = operationsToTop(this.find(dice(0)) + 1).foldLeft(this)(_.rotateTo(_))
      val dice3 = operationsToFront(dice2.find(dice(1)) + 1).foldLeft(dice2)(_.rotateTo(_))
      dice3
    }
  }

  def main(args: Array[String]): Unit = {
    val dice1 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    val dice2 = Dice(io.StdIn.readLine().split(" ").map(_.toInt))
    if (dice1 == dice2.adjustWith(dice1))
      println("Yes")
    else
      println("No")
  }
}

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

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

int main(){
    string S;
    cin >> S;
    int N = (int)S.size();
    int W_cnt = 0;
    ll cnt = 0;
    rep(i, N){
        if(S.at(i) == 'W'){
            cnt += (i - W_cnt);
            W_cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 832
import numpy as np

s = np.array(list(map(int, input())))

a01 = np.tile([0,1], len(s)//2)
a10 = np.tile([1,0], len(s)//2)

if len(s)%2 != 0:
    a01 = np.append(a01, 0)
    a10 = np.append(a10, 1)

ans01 = np.abs(s -a01)
ans10 = np.abs(s -a10)

if sum(ans01) >= sum(ans10):
    print(sum(ans10))
else:
    print(sum(ans01))

Measured memory_bytes: 17108
#include<stdio.h>

int main(){
int n,i; float sum=0.00;
scanf("%d",&n);
int a[n];
float in[n];
for (i = 0; i < n;scanf("%d",&a[i]),in[i]=(float)1/a[i],sum+=in[i], i++);
if(n==1)
printf("%d",a[0]);
else
printf("%f",1/sum);

}


Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    #define ll long long
    #define ld long double
    #define ff first
    #define ss second
    #define pb push_back
    #define mp make_pair
    #define MOD 1000000007
    #define FAST ios_base::sync_with_stdio(false),cin.tie(0),cout.tie(0);srand(time(NULL))
    int main()
    {
         FAST;
         ll n;
         cin>>n;
         cout<<(ll)n*n*n;
    }

Measured memory_bytes: 256
#include<stdio.h>

int main(){
    int a[3000][2],i,tmp,j;
    i==0;
    while(1){
        scanf("%d %d", &a[i][0], &a[i][1]);
        if(a[i][0]==0&&a[i][1]==0){
            break;
        }
        if(a[i][0]>a[i][1]){
            tmp=a[i][0];
            a[i][0]=a[i][1];
            a[i][1]=tmp;
        }
        i++;
    }

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


    return 0;
}


Measured memory_bytes: 2028
// Problem : D - Teleporter
// Contest : AtCoder - AtCoder Beginner Contest 167
// URL : https://atcoder.jp/contests/abc167/tasks/abc167_d
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
#define pb push_back
#define mp make_pair
#define y1 y114514
#define y2 y1919810
typedef pair <int, int> PII;
#define int long long
#define all(x) (x.begin(),  x.end())
#define lsh(i) (1 << (i))
#define lshll(i) (1LL << (i))
#define repn(i, n) for (int i = 1; i <= (int)n; i++)
#define rep(i, n) for (int i = 0; i < (int)n; i++)
#define range(i, s, t)  for (int i = s; i <= (int)t; i++)
const int INF = 0x3f3f3f3f;
const long double EPS = 1e-6;
long long qread() {
	char c = getchar();
	int neg = 1;
	long long val = 0;
	while (c != '-' && !isdigit(c)) c = getchar();
	if (c == '-') c = getchar(), neg = -1;
	while (isdigit(c)) val = (val << 3) + (val << 1) + c - '0', c = getchar();
	return neg * val;
}
const int N = 200020;
int a[N], n, m, fst[N];
signed main() {
	n = qread(); m = qread();
	repn(i, n) a[i] = qread();
	vector <int> path;
	memset(fst, -1, sizeof(fst));
	path.pb(1);
	fst[1] = 0;
	int cur = 1, st = -1;
	while (true) {
		if (fst[a[cur]] != -1) {
			st = fst[a[cur]];
			break;
		}
		cur = a[cur];
		path.pb(cur);
		fst[cur] = path.size() - 1;
	}
	assert(st != -1);
	rep(i, path.size()) cerr << path[i] << ' '; cerr << endl << st << endl;
	if (m < path.size()) {cout << path[m] << endl; return 0;}
	m -= path.size();
	m %= (path.size()) - st;
	cout << path[st + m] << endl;
	return 0;
}

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

int main(){
  string s;
  cin>>s;
  if(s.at(0)==s.at(1)||s.at(1)==s.at(2)||s.at(2)==s.at(3)){
    cout<<"Bad"<<endl;
  }else{
    cout<<"Good"<<endl;
  }
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<vector>
#include<queue>
#include<map>
#include<tuple>
#include<bitset>
#define rep(index,num) for(int index=0;index<num;index++)
#define rep1(index,num) for(int index=1;index<=num;index++)
#define scan(argument) cin>>argument
#define prin(argument) cout<<argument<<endl
#define kaigyo cout<<endl
#define eps 1e-15
#define mp(a1,a2) make_pair(a1,a2)
typedef long long ll;
using namespace std;
typedef pair<ll,ll> pll;
typedef pair<int,int> pint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
typedef vector<pll> vpll;
ll INFl=1e+18+1;
int INF=1e+9+1;
int main(){
	int N,M;
	int A[301][301];
	bool jissi[301];
	queue<int> Aqueue[301];
	scan(N);scan(M);
	rep1(j,M) jissi[j]=true;
	rep(i,N){
		rep(j,M){
			scan(A[i][j]);
			Aqueue[i].push(A[i][j]);
		}
	}
	int ans=N;
	rep(j,M-1){
		int shukei[301]={};
		rep(i,N){
			shukei[Aqueue[i].front()]++;
		}
		int maxnum=0,maxsport;
		rep1(k,M){
			if(shukei[k]>maxnum){
				maxnum=shukei[k];
				maxsport=k;
			}
		}
		ans=min(ans,maxnum);
		jissi[maxsport]=false;
		rep(i,N){
			while(jissi[Aqueue[i].front()]==false){
				Aqueue[i].pop();
			}
		}
	}
	prin(ans);
	return 0;
}


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

bool allowed[11]; 

bool pos(int n){
  while(n){
    if(!allowed[n%10]){
      return 0; 
    }
    n/=10;
  }
  return 1; 
}

int main(){
  int n,k; cin>>n>>k; 
  for(int i=0;i<10;i++) allowed[i]=1; 
  for(int i=0;i<k;i++){
    int d; cin>>d; 
    allowed[d]=0; 
  }
  for(int i=n;;i++){
    if(pos(i)){
      cout<<i<<endl; 
      return 0; 
    }
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include <queue>
#include<map>
#include<set>
#include <cstring>
using namespace std;
#define ll long long int

#define mod 1000000007

vector<vector<ll>> g(200001) ;
ll cnt = 0 ;

void dfs(ll u , vector<bool> &vis)
{
    vis[u] = true ;
    cnt++ ;

    for(ll i = 0 ; i < g[u].size() ; i++)
    {
        if(!vis[g[u][i]])
            dfs(g[u][i] , vis) ;
    }
}
int main()
{
   ll n , m ;
   cin>>n>>m ;

   for(ll i = 0 ; i < m ; i++)
   {
       ll u , v ;
       cin>>u>>v ;

       g[u].push_back(v) ;
       g[v].push_back(u) ;
   }
   vector<bool> vis(n + 1 , false) ;
   ll ans = 0 ;
   for(ll i = 1 ; i <= n ; i++)
   {
       if(!vis[i])
       {
           dfs(i , vis) ;
           ans = max(ans , cnt) ;
           cnt = 0 ;
       }
   }

   cout<<ans ;

}


Measured memory_bytes: 23400
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;

class Solution {
public:
    long long solve(int n) {
        vector<vector<int>> cnts(10, vector<int>(10, 0));

        for (int i = 1; i <= n; ++i) {
            int x = i;
            int last = x % 10;
            int first = last;
            while (x != 0) {
                first = x % 10;
                x /= 10;
            }
            ++cnts[first][last];
        }

        long long res = 0;
        for (int i = 0; i < 10; ++i) {
            for (int j = 0; j < 10; ++j) {
                res += cnts[i][j] * 1LL * cnts[j][i];
            }
        }
        return res;
    }
};

int main(int argc, char** argv) {
    ios::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin >> n;

    Solution sol;
    cout << sol.solve(n) << "\n";

    return 0;
}

Measured memory_bytes: 256