akhauriyash/Code-Regression huggingface dataset:
# ------------------- fast io --------------------
import os
import sys
from io import BytesIO, IOBase
 
BUFSIZE = 8192
 
 
class FastIO(IOBase):
    newlines = 0
 
    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None
 
    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()
 
    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()
 
    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)
 
 
class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")
 
 
sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")
 
# ------------------- fast io --------------------
from math import gcd, ceil
 
def pre(s):
    n = len(s)
    pi = [0] * n
    for i in range(1, n):
        j = pi[i - 1]
        while j and s[i] != s[j]:
            j = pi[j - 1]
        if s[i] == s[j]:
            j += 1
        pi[i] = j
    return pi
 
 
def prod(a):
    ans = 1
    for each in a:
        ans = (ans * each)
    return ans
 
def lcm(a, b): return a * b // gcd(a, b)
 
 
def binary(x, length=16):
    y = bin(x)[2:]
    return y if len(y) >= length else "0" * (length - len(y)) + y


N = int(input())
k = int(1e7+1)
muls = [0] * k
for i in range(1, N+1):
    for j in range(0, N+1, i):
        muls[j] += 1

ans = 0
for i in range(1, N+1):
    ans += i * muls[i]

print(ans)


Measured memory_bytes: 151352
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <cmath>
#include <limits>
using namespace std;
using ll = long long;

ll mypow(ll x, ll n) { //x^nの計算
  ll res = 1;
  while (n > 0) {
    if (n & 1){
      res *= x;  // n の最下位bitが 1 ならば x^(2^i) をかける
    }
    x *= x;
    n >>= 1;  // n を1bit 左にずらす
  }
  return res;
}

int main(){
  int X;
  cin >> X;
  vector<bool> num(1000,false);
  num[1]=true;
  for(int i=2;i<=1000;i++){
    int count=2;
    while(mypow(i,count)<=1000){
      num[mypow(i,count)]=true;
      count++;
    }
  }
  for(int i=X;i>=1;i--){
    if(num[i]){
      cout << i << endl;
      return 0;
    }
  }
}

Measured memory_bytes: 3600
n = int(input())
s = list(input())
cum = [[0,0]] #くろ、しろの順
for i in range(n):
    if s[i] == ".":
        cum.append([cum[i][0],cum[i][1]+1])
    else:
        cum.append([cum[i][0]+1,cum[i][1]])
cum.append(cum[-1])
mnm = 1e9
for i in range(n+1):
    if mnm > cum[i][0]-cum[0][0] + cum[-1][1]-cum[i][1]:
        mnm = cum[i][0]-cum[0][0] + cum[-1][1]-cum[i][1]

print(mnm)

Measured memory_bytes: 31396
#include "bits/stdc++.h"
#define double long double
#define int long long
#define mii map<int,int>
#define low lower_bound
#define upp upper_bound
#define inf 1000000007 //10^9+7
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
#define rever(vec) reverse(all(vec));
#define unsort(vec) sort(vec); rever(vec);
#define bisea binary_search
#define cend cout<<endl;
#define F first
#define S second
using namespace std;
signed main() {
  int n,cnt=1;
  cin>>n;
  int a[n];
  rep(i,n) {
    cin>>a[i];
    if(!(a[i]%2)) cnt*=2;
  }
  cout<<pow(3,n)-cnt<<endl;
}

Measured memory_bytes: 384
n = int(input())
s = []
for i in range(n):
    s.append(str(input()))

s_srt = []
for i in range(n):
    s_srt.append(''.join(sorted(s[i])))
s_srt.sort()

tmp = [0,]
k = 0
next = False
for i in range(n - 1):
    if s_srt[i] == s_srt[i + 1]:
        tmp[k] += 1
        next = True
    else:
        if next:
            tmp.append(0)
            k += 1
if tmp[-1] == 0:
    tmp.remove(0)

ans = 0
m = len(tmp)
if m != 0:
    for i in range(m):
        ans += int((tmp[i] + 1) * tmp[i] / 2)

print(ans)

Measured memory_bytes: 18380
import java.util.*;

public class Main {
    static Scanner sc = new Scanner(System.in);
    static long x = 0;
    static long y = 0;
    static long ans = 0;

    public static void main(String[] args) {
        x = sc.nextLong();
        y = sc.nextLong();
        
        if(x <= y) ans = (x >= 0) ? y - x : (-x <= y) ? 1 + y + x : (0 < y) ? 1 - y - x : y - x;
        else ans = (y > 0) ? 2 - y + x : (y == 0) ? 1 + x : (-y <= x) ? 1 + y + x : (0 <= x) ? 1 - y - x : 2 - y + x;
        System.out.println(ans);
    }
}

Measured memory_bytes: 23764
H,W=map(int,input().split())
S=[input()+'.'for _ in range(H)]+['.'*W]
print(('Yes','No')[any(S[y-1][x]==S[y+1][x]==S[y][x-1]==S[y][x+1]=='.'for y in range(H)for x in range(W)if S[y][x]=='#')])

Measured memory_bytes: 3064
#include <algorithm>
#include <bitset>
#include <cmath>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <vector>

// Acknowledgement: Special thanks to kyomukyomupurin, who developed this
// template.
template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::pair<T, U>& p) {
  return os << '(' << p.first << ", " << p.second << ')';
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::vector<T>& vec) {
  int n = 0;
  for (auto e : vec) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::ostream& operator<<(std::ostream& os, const std::set<T>& st) {
  int n = 0;
  for (auto e : st) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T, class U>
std::ostream& operator<<(std::ostream& os, const std::map<T, U>& mp) {
  int n = 0;
  for (auto e : mp) os << (n++ ? ", " : "{") << e;
  return os << (n ? "}" : "{}");
}

template <class T>
std::istream& operator>>(std::istream& is, std::vector<T>& vec) {
  for (T& e : vec) is >> e;
  return is;
}

#ifdef LOCAL
#define debug(...) \
  std::cerr << "[" << #__VA_ARGS__ << "]: ", debug_out(__VA_ARGS__)
#else
#define debug(...)
#endif

void debug_out() { std::cerr << '\n'; }

template <class Head, class... Tail>
void debug_out(Head&& head, Tail&&... tail) {
  std::cerr << head;
  if (sizeof...(Tail) != 0) std::cerr << ", ";
  debug_out(std::forward<Tail>(tail)...);
}
using namespace std;
using int64 = long long;

int main() {
  string S;
  cin >> S;
  int length_s = S.size();
  for (int i = 0; i < length_s - 1; i++) {
    if (S[i] == S[i + 1]) {
      cout << "Bad" << endl;
      return 0;
    }
  }
  cout << "Good" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <cstdlib>
#include <bitset>
#include<vector>
#include<utility>
#include<fstream>
#include<queue>
#include <iomanip>
#include<numeric>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define rep(i, k) for (i = 0; i < k; i++) 
typedef long long ll;
typedef pair<ll, ll> l_l;
int i, j;

int main() {
	ll a, b, k, n, z = 0;
	string s;
	ll d[10002] = {};
	cin >> n;
	rep(i, n) {
		cin >> a;
		while (a % 2 == 0) {
			a /= 2;
			z++;
		}
	}
	cout << z;
}



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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++) cin >> a.at(i);
  
  long long ans = pow(3, n);
  long long minus = 1;
  for(int i = 0; i < n; i++){
    if(a.at(i) % 2 == 0) minus *= 2;
  }
  
  cout << ans - minus << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a)  (a).rbegin(),(a).rend()
#define dup(x,y) (((x)+(y)-1) / (y)) //整数型のまま切り上げ演算する
#define PI 3.14159265359
typedef long long LL;
template<class T> inline void chmax(T& a, T b) { if (a < b) { a = b; } }
template<class T> inline void chmin(T& a, T b) { if (a > b) { a = b; } }
template<class T> inline T gcd(T x, T y) { if (y == 0) { return x; } else if (x == 0) { return y; }return gcd(y, x % y); }
template<class T> inline T lcm(T x, T y) { return (x * y) / gcd(x, y); }
template<class T> inline vector<T> convert_to_binary_number(T x) { vector<T> binary_num; while (x != 1) { binary_num.push_back(x % 2); x /= 2; } binary_num.push_back(1); return binary_num; }
template<class T> inline void print_vector(vector<T> vec) { for (int i = 0; i < vec.size(); i++) { cout << vec[i] << " "; } cout << endl;}
vector<LL> make_divisors(LL n){vector<LL> divisors;for(int i = 1; i <= sqrt(n); i++) {if(n%i == 0){divisors.push_back(i);if(i != n/i){divisors.push_back(n / i);}}}return divisors;}
const LL MOD = 1e9 + 7;
const int INF = 1 << 30;
const LL LLINF = 1LL << 60;
using namespace std;

const LL MAX_V = 1010;
const LL MAX_E = 2010;

//辺の構造体
struct edge {
    LL before_node;
    LL next_node;
    LL cost;
};

LL V, E;//V = 頂点の数, E = 辺の数
vector<LL> dp(MAX_V,LLINF);
vector<edge> edges(MAX_E);//ノードではなく辺に着目

bool bellman_ford(LL start){
    dp[start] = 0;

    for(int v = 0; v < V; v++) {       
        for (int i = 0; i < E; i++) {
            edge e = edges[i];
            if(dp[e.before_node] != LLINF and dp[e.next_node] > dp[e.before_node] + e.cost){
                dp[e.next_node] =  dp[e.before_node] + e.cost;
                if(v == V - 1) return true;
            }
        }
    }

    return false;
}

int main(void){
    LL r;
    cin >> V >> E >> r;

    rep(i, E) {
        LL a, b, c;
        cin >> a >> b >> c;

        edges[i] = {a, b, c};
    }

    if(bellman_ford(r)){
        cout << "NEGATIVE CYCLE" << endl;
    }else{
        rep(i, V){
            if(dp[i] == LLINF) cout << "INF" << endl;
            else cout << dp[i] << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3180
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define INF 1e9
#define PI 3.14159265359
#define MOD 1000000007
#define ALL(v) v.begin(),v.end()
#define ALLR(v) v.rbegin(),v.rend()
typedef long long ll;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//isPrime
//modpow modinv
//getDigit
int main() {
  cout << fixed << setprecision(10);
  char x,y;
  cin >> x >> y;
  if(x==y){
    cout << "=" << endl;
  }else if(x<y){
    cout << "<" << endl;
  }else{
    cout << ">" << endl;
  }
}


Measured memory_bytes: 256
import sys

import numpy as np

readInt = lambda: int(sys.stdin.readline())
readIntN = lambda: [int(v) for v in sys.stdin.readline().split(" ")]


n = readInt()
M = 10 ** 9 + 7


dp = np.zeros((n + 1, 256), dtype=np.uint32)
dp[0, 255] = 1


for i in range(n):
    for j4 in [0, 64, 128, 192]:
        for j3 in [0, 16, 32, 48]:
            j43 = j4 + j3
            for j2 in [0, 4, 8, 12]:
                j432 = j43 + j2
                for j1 in range(4):
                    j = j432 + j1
                    l321 = 4 * (j3 + j2 + j1)
                    for l0 in range(4):
                        if (6 == (j3 + 4 * j1 + l0)) or (6 == (j3 + j2 + l0)) or (6 == (4 * j2 + 4 * j1 + l0)) or (6 == (16 * j1 + j2 + l0)) or (6 == (4 * j2 + 4 * l0 + j1)):
                            continue
                        l = l321  + l0
                        dp[i + 1, l] = (dp[i + 1, l] + dp[i, j]) % M

ret = 0
for v in dp[-1]:
    ret = (ret + v) % M
print(ret)

Measured memory_bytes: 20608
#include <cstdio>
#include <array>
#include <algorithm>
#include <tuple>

constexpr int N = 2e5;
std::array<std::pair<int, int>, N> A;
std::array<long long int, N + 1> S; 

int readInt(void){
    char c;
    do{c = getchar_unlocked();} while(c < '0');
    int res = 0;
    do{res = 10 * res + c - '0'; c = getchar_unlocked();} while(c >= '0');
    return res;
}

int main(void){
    int n, d, a; n = readInt(); d = readInt(); a = readInt(); d <<= 1;
    for(int i = 0; i < n; ++i){
        A[i].first = readInt();
        A[i].second = readInt();
    }
    std::sort(A.begin(), A.begin() + n);
    long long int res = 0, dec = 0;
    int r = 0;
    for(int l = 0; l < n; ++l){
        while(r < n and A[r].first - A[l].first <= d) r++;
        dec -= S[l]; A[l].second -= dec;
        if(A[l].second <= 0) continue;
        long long int p = (A[l].second / a) + (!!(A[l].second % a));
        dec += p * a; S[r] += p * a; res += p;
    }
    printf("%lld\n", res);
    return 0;
}


Measured memory_bytes: 3328
n, p = map(int, input().split())

def factorization(n):
    arr = []
    temp = n
    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

lis = factorization(p)

ans = 1
for i in lis:
    a, b = i
    t = a**(b//n)
    ans *= t

print(ans)

Measured memory_bytes: 9472
import scala.io.StdIn._
import scala.annotation.tailrec

object Main {

  final case class Rotation(run: Dice => Dice){
    final def apply(d: Dice): Dice = run(d)
    final def compose(other: Rotation): Rotation = Rotation(run compose other.run)
    final def andThen(other: Rotation): Rotation = other compose this
  }

  object Rotation {
    final def id = Rotation(d => d)
    final def north = Rotation(d => Dice(List(1,5,2,3,0,4).map(d.pip)))
    final def east = Rotation(d => Dice(List(3,1,0,5,4,2).map(d.pip)))
    final def ccw = Rotation(d => Dice(List(0,3,1,4,2,5).map(d.pip)))

    final def axial(rotation: Rotation): Seq[Rotation] =
      for(i <- 0 to 3) yield List.fill(i)(rotation).fold(id)(_ compose _)

    def enumerateTop(): Seq[Rotation] =
      for(i <- 1 to 6) yield ((0 to i).map(j => if(j % 2 == 0) north else east)).fold(id)(_ compose _)

    def enumerate: Seq[Rotation] = enumerateTop().flatMap(e => axial(ccw).map(e compose _))
  }

  case class Dice(pip: List[Int]){
    lazy val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    def ===(that: Dice): Boolean = pip.corresponds(that.pip)(_ == _)
    def ==(that: Dice): Boolean = all.exists(_ === that)
  }

  @tailrec
  def loop(n:Int, all: Seq[Dice]):Unit = if(n>0){
    val Array(a,b,_*) = readLine.split(" ").map(_.toInt)
    val res = all.filter(d => d.pip(0)==a && d.pip(1)==b)
    println(res(0).pip(2))
    loop(n-1,all)
  }

  def main(args: Array[String]): Unit = {
    val pip = readLine.split(" ").map(_.toInt).toList
    val all: Seq[Dice] = Rotation.enumerate.map(_.run(Dice(pip)))
    val Array(n,_*) = readLine.split(" ").map(_.toInt)
    loop(n,all)
  }

}

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

#define ll long long
#define fw(p) for(int w=0;w<(p);w++)
#define fx(p) for(int x=0;x<(p);x++)
#define fy(p) for(int y=0;y<(p);y++)
#define fz(p) for(int z=0;z<(p);z++)
#define fyg(p,g) for(int y=(g);y<(p);y++)
#define fzg(p,g) for(int z=(g);z<(p);z++)
#define ce(d) cout<<d<<endl;
#define vecp(p) int aa;cin>>aa;(p).push_back(aa);
#define vecpl(p) long long aa;cin>>aa;(p).push_back(aa);
#define vecps(p) string aa;cin>>aa;(p).push_back(aa);
#define vecp2(p) cin>>aa;(p).push_back(aa);
#define vecpl2(p) long long a	b;cin>>ab;(p).push_back(ab);
#define vecps2(p) string ab;cin>>ab;(p).push_back(ab);
#define set0(k,n) for(int nn=0;nn<(n);nn++){ (k).push_back(0); }
#define sorts(c) sort((c).begin(),(c).end());
#define reverses(c) reverse((c).begin(),(c).end());
#define vec(b) vector<int> (b);
#define vecl(b) vector<long long> (b);
#define vecs(b) vector<string> (b);
#define vecsize(b,size) vector<int> (b)((size));
#define pb(b,a) (b).push_back((a));
#define doublece(a,b) cout<<(a)<<' '<<(b)<<endl;
#define pairs(s) vector<pair<int,int>> (s);
#define pairsl(s) vector<pair<ll,ll>> (s);
#define pairss(s) vector<pair<string,string>> (s);
#define pairsp(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairspl(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsps(s) int aa,bb;cin>>aa>>bb;(s).push_back(make_pair(aa,bb));
#define pairsREV(s) (s).push_back(make_pair(bb,aa));
#define pairslREV(s) (s).push_back(make_pair(bb,aa));
#define pairssREV(s) (s).push_back(make_pair(bb,aa));
#define MOD 1000000007

int main()
{
	int N;
	vecl(A)
		cin >> N;
	fx(N) {
		vecpl(A)
	}
	sorts(A)
	ll ans = A.at(N-1);
	ll mini = A.at(0);
	pairs(ANS)
		int k;
	fyg(N-1,1) {
		if (A.at(y) >= 0) { k = y; break; }
		pb(ANS, make_pair(ans, A.at(y)));
		ans -= A.at(y);

	}
	fyg(N-1,k) {
		pb(ANS, make_pair(mini, A.at(y)));
		mini -= A.at(y);
	}
	pb(ANS, make_pair(ans,mini));
	ans -= mini;
	ce(ans)
    fx(N-1) {
		doublece(ANS.at(x).first, ANS.at(x).second)
	}
    return 0;
}



Measured memory_bytes: 3572
#include <iostream>

using namespace std;

int main(){

   // freopen("input.txt", "r", stdin);
   // freopen("output.txt", "w", stdout);

    long long N;
    cin>>N;
    int numCount = 0;
    for(int i=2; (long long)i*i <= N; i++){
        if( N % i == 0){
            int times = 0;
            while(N % i == 0){
                N/= i;
                times++;
            }

            for(int j =1; j<=times; j++){
                times-= j;
                numCount++;
            }
        }
    }

    if(N > 1){
        numCount++;
    }

    cout << numCount <<endl;

    return 0;
}

Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
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; }

double l;
int main() {
    cin >> l;
    double y, t, h;
    // cout << l << endl;
    y = t = h = l/3;
    // cout << y << endl;
    double ans = y*t*h;
    printf("%.14f\n", ans);
}

Measured memory_bytes: 256
//114
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<algorithm>
#include<deque>
#include<queue>
#include<set>
#include<map>
#include<functional>

using namespace std;
#define LL long long
#define ALF "ABCDEFGHIJKLMNOPQRSTUVWXYZ"
#define LLBIG 1999999999999999999LL
#define INTBIG 1111111111
#define MOD 1000000007
#define PI pair<int,int>
#define VI vector<int>
#define VVI vector<vector<int>>

int H, W, h, w, A, B, C;

int main() {
	cin >> A;

	cout << (A == 3 || A == 5 || A == 7 ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
$a = "k";
@b = split(//, "eyence");
$r = "NO";

chomp($s = <>);
if($s =~ /keyence$/){
	$r = "YES";
}elsif($s =~ /^k/){
	if($s =~ /^keyence/){
		$r = "YES";
	}else{
		for (1 .. 5){
			$a .= shift(@b);
			$str = join("", @b);
			if($s =~ /^${a}.*${str}$/){
				$r = "YES";
				last;
			}
		}
	}
}

print "$r\n";


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

const ll MAXN = 200000;
const ll INF = 5001001001001001001;

ll N, K, ans=INF, tmp=0;
vector<ll> Xs, Ys;
vector<pair<ll,ll>> XY;

signed main(){
    cin >> N >> K;
    for(int i=0;i<N;i++) {
        ll x, y;
        cin >> x >> y;
        XY.push_back(make_pair(x,y));
        Xs.push_back(x);
        Ys.push_back(y);
    }
    sort(Xs.begin(),Xs.end());
    sort(Ys.begin(),Ys.end());
    for(int i1=0;i1<N;i1++) {
        for(int i2=i1+1;i2<N;i2++) {                    
            for(int j1=0;j1<N;j1++) {
                for(int j2=j1+1;j2<N;j2++) {
                    tmp = 0;
                    for(int k=0;k<N;k++) {
                        if(XY[k].first>=Xs[i1]&&XY[k].first<=Xs[i2]&&XY[k].second>=Ys[j1]&&XY[k].second<=Ys[j2]) {
                            tmp++;
                        }
                    }
                    if(tmp>=K) {
                        ans = min(ans,(Xs[i2]-Xs[i1])*(Ys[j2]-Ys[j1]));
                    }
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3660
use proconio::{input, fastout};
use proconio::marker::{Chars};
use proconio::marker::Usize1;
use std::cmp::*;

macro_rules! debug {
      ($($a:expr),*) => {
          eprintln!(concat!($(stringify!($a), " = {:?}, "),*), $($a),*);
    }
}

#[fastout]
fn main() {
    input!{
        a: i32,
        b: i32,
        c: i32,
    }

    if a==b {
        println!("{}", c);
    } else if b==c {
        println!("{}", a);
    } else if c==a {
        println!("{}", b);
    }

}


Measured memory_bytes: 2156
#include <stdio.h>
#include <string.h>

#define M 1046527
#define NIL (-1)
#define L 14

char H[M][L];

int getChar(char ch){
  if(ch=='A') return 1;
  else if(ch=='C') return 2;
  else if(ch=='G') return 3;
  else if(ch=='T') return 4;
  else return 0;
}

long long getKey(char str[]){
  long long sum=0, p=1, i;
  for(i=0; i<strlen(str); i++){
    sum+=p*(getChar(str[i]));
    p*=5;
  }
  return sum;
}

int h1(int key){ return key%M;}
int h2(int key){ return 1+(key%(M-1));}

int find(char str[]){
  long long key, i, h;
  key=getKey(str);
  for(i=0;; i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h], str)==0) return 1;
    else if(strlen(H[h])==0) return 0;
  }
  return 0;
}

int insert(char str[]){
  long long key, i, h;
  key=getKey(str);
  for(i=0;; i++){
    h=(h1(key)+i*h2(key))%M;
    if(strcmp(H[h], str)==0) return 1;
    else if(strlen(H[h])==0){
      strcpy(H[h], str);
      return 0;
    }
  }
  return 0;
}

int main(){
  int i, n ,h;
  char str[L], com[9];
  for(i=0; i<M; i++) H[i][0]='\0';
  scanf("%d",&n);
  for(i=0; i<n; i++){
    scanf("%s%s", com, str);

 if(com[0]=='i'){
      insert(str);
    }
    else{
      if(find(str)){
        printf("yes\n");
      }
      else{
        printf("no\n");
      }
    }
  }
  return 0;
}

Measured memory_bytes: 14916
import std.stdio;
import std.conv;
import std.string;
import std.typecons;
import std.algorithm;
import std.array;
import std.range;
import std.math;
import std.regex : regex;
import std.container;
import std.bigint;
import std.ascii;


void main()
{
  auto k = readln.chomp.to!int;
  int a, b;
  bool f;
  readf("%s %s\n", &a, &b);
  foreach (x; a..b+1) {
    if (x % k == 0) {
      f = true;
      break;
    }
  }
  if (f) {
    writeln("OK");
  } else {
    writeln("NG");
  }
}


Measured memory_bytes: 2844
package main

import (
	"fmt"
	"sort"
)

// Ary ...
type Ary []string

func (a Ary) Len() int {
	return len(a)
}

func (a Ary) Swap(i, j int) {
	a[i], a[j] = a[j], a[i]
}

func (a Ary) Less(i, j int) bool {
	return a[i] < a[j]
}

func main() {
	var n, l int
	fmt.Scan(&n, &l)

	var ary Ary
	for i := 0; i < n; i++ {
		var s string
		fmt.Scan(&s)
		ary = append(ary, s)
	}
	// fmt.Printf("n = %d, l = %d, ary = %v\n", n, l, ary)

	sort.Sort(ary)
	// fmt.Printf("sorted ary = %v\n", ary)

	var result string
	for _, a := range ary {
		result += a
	}
	fmt.Println(result)
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
const ll MOD=(ll)1e9+7;
const ll INF=(ll)1e18+10;
const double PI=acos(-1);

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
int dy[]={-1,1,0,0};
int dx[]={0,0,-1,1};

const int MAX = 200010;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int 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;
    }
}

// 二項係数計算
long long COM(int n, int k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
//main関数にCOMinit();を忘れない

long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

int main() {
    COMinit();
    ll n,a,b; cin>>n>>a>>b;

    ll total=(modpow(2,n,MOD)+MOD-1)%MOD;

    if(a>b) swap(a,b);

    ll bunshi=1ll;
    for (int i = n; i > n-a; --i) {
        (bunshi*=i)%=MOD;
    }

    total=(total+MOD-bunshi*finv[(int)a]%MOD)%MOD;

    for(int i=n-a;i>n-b;--i){
        (bunshi*=i)%=MOD;
    }
    total=(total+MOD-bunshi*finv[(int)b]%MOD)%MOD;
    cout<<total<<endl;
    return 0;

}


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

int ri() {
	int n;
	scanf("%d", &n);
	return n;
}

int main() {
	int n = ri();
	int x = 1;
	for (int i = 1; i <= n; i++) x = (int64_t) x * i % 1000000007;
	std::cout << x << std::endl;
	return 0;
}


Measured memory_bytes: 256
#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>
#define rep(i,a,n) for(ll i =(a);i<(n);i++)
#define urep(i,a,n) for(ll i = (a);i>=(n);i--)
#define all(x) (x).begin(),(x).end()
#define INF 1e9
const int mod = 1e9 + 7;
typedef long long ll;
using namespace std;
ll dx[4] = { 1,-1,0,0 };
ll dy[4] = { 0,0,1,-1 };
ll N, M, Q, H, W, D, L, R,K;
ll A;
ll B[200001];
ll ans;
string S;
char s[52][52];
ll gcd(ll a, ll b) {
	if (b == 0)return a;
	else return gcd(b, a%b);
}


int main() {
	cin >> N >> K;
	if (K % 2 == 0) {
		ll num = K / 2;
		ll count=0;
		for (int i = num; i <= N; i += K) {
			count++;
		}
		ans += count * count*count;

	}
	ll num = N / K;
	ans += num * num*num;
	cout << ans << endl;
	cin >> ans;
	return 0;
}

Measured memory_bytes: 256
/*
 Author:Alokit Kumar
   */
  #include<bits/stdc++.h>
  using namespace std;
  #define int long long 
  int32_t main()
  {
    int t,n,i,j,k;
    cin>>n;
    int s=((n-1)*n)/2;
    cout<<s;
  }

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

int main(){
    int_fast64_t N, M;
    cin >> N >> M;

    vector<pair<pair<int_fast64_t, int_fast64_t>, int_fast64_t>> P(M);
    for(int i = 0; i < M; ++i){
        cin >> P[i].first.first >> P[i].first.second;
        P[i].second = i;
    }
    sort(P.begin(), P.end());

    vector<pair<int_fast64_t, int_fast64_t>> D;
    int_fast64_t c(0), p(0), q(0);
    for(auto i : P){
        if(q != i.first.first)q = i.first.first, p = c;
        ++c;
        D.emplace_back(i.second, i.first.first * 1000000 + c - p);
    }
    sort(D.begin(), D.end());

    for(auto i : D)printf("%012lld\n", i.second);
    return 0;
}


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

int main(){

	ios_base::sync_with_stdio(false);
	
	int n;	cin>>n;
	double a = n/1000.00;
	int b = ceil(a/1.00);
	int res = b*1000-n;
	cout<<res<<endl;
	
return 0;
}

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

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

  ll ans = 0;
  set<tuple<int, int, int>> st;
  st.insert(tuple<int, int, int>(a, b, c));
  while (a%2==0 && b%2==0 && c%2==0) {
    int x = (b+c)/2;
    int y = (a+c)/2;
    int z = (a+b)/2;
    a = x;
    b = y;
    c = z;
    if (st.count(tuple<int, int, int>(x, y, z)) > 0) {
      cout << -1 << endl;
      return 0;
    }
    st.insert(tuple<int, int, int>(x, y, z));
    ans++;
  }
  cout << ans << endl;

  return 0;
}


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

int main() {

  int N;
  cin >> N;

  vector<int> A(N);
  vector<int> A2(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }

  A2 = A;
  sort(A.begin(), A.end() , greater<int>());

  for (int i = 0; i < N; i++) {
    if (A2[i] == A[0]) {
      cout << A[1] << endl;
    } else {
      cout << A[0] << endl;
    }
  }

  return 0;

}

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

using namespace std;

int main() {
  int n;
  cin >> n;
  int max4 = n / 4 + 1;
  int max7 = n / 7 + 1;
  for ( int i = 0; i <= max4; i++ ) {
    int left = n - 4 * i;
    if ( left == 0 ) {
      cout << "Yes" << endl;
      return 0;
    }
    for ( int j = 0; j <= max7; j++ ) {
      left -= 7 * j;
      if ( left == 0 ) {
        cout << "Yes" << endl;
        return 0;
      } else if ( left < 0 ) {
        break;
      }
    }
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0

for i in range(A+1):
	for j in range(B+1):
		for k in range(C+1):
			if X == 500*i + 100*j + 50*k:
				ans += 1

print(ans)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i,n) for(long long i=0; i<n; i++)
#define Rep(i,n) for(long long i=1; i<n; i++)
#define ll long long
#include <math.h>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <numeric>
#include <queue>
#include <set>
#include <vector>


using namespace std;
#define PI acos(-1)
using P =pair<ll,ll>;

ll ketasu(ll a){
   ll num=1;
   while(a/10){
       num++;
       a/=10;
   }
   return num;
}

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

ll kosuu(ll a){
    ll sum=0;
    for(ll i=1;i*i<=a;i++){
        if(a%i==0){
            if(a!=1&&i*i!=a){
            sum+=2;
            }else{
             sum++;   
            }
        }
    }
    return sum;
}






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

struct UnionFind {
    vector<int>d;
    UnionFind(int n=0):d(n,-1){}
    int find(int x){
        if((d[x])<0)return x;
        return d[x]=find(d[x]);
    }
    bool unite(int x,int y){
        x =find(x);y=find(y);
        if(x==y)return false;
        if(d[x]>d[y])swap(x,y);
        d[x]+=d[y];
        d[y]=x;
        return true;
    }
    bool same(int x,int y){return find(x)==find(y);};
    ll size(ll x){return -d[find(x)];};
};

int deg[100005];
vector<int> to[100005];





// auto mod int
// https://youtu.be/L8grWxBlIZ4?t=9858
// https://youtu.be/ERZuLAxZffQ?t=4807 : optimize
// https://youtu.be/8uowVvQ_-Mo?t=1329 : division
const int mod = 1000000007;
struct mint {
  ll x; // typedef long long ll;
  mint(ll x=0):x((x%mod+mod)%mod){}
  mint operator-() const { return mint(-x);}
  mint& operator+=(const mint a) {
    if ((x += a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator-=(const mint a) {
    if ((x += mod-a.x) >= mod) x -= mod;
    return *this;
  }
  mint& operator*=(const mint a) { (x *= a.x) %= mod; return *this;}
  mint operator+(const mint a) const { return mint(*this) += a;}
  mint operator-(const mint a) const { return mint(*this) -= a;}
  mint operator*(const mint a) const { return mint(*this) *= a;}
  mint pow(ll t) const {
    if (!t) return 1;
    mint a = pow(t>>1);
    a *= a;
    if (t&1) a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const { return pow(mod-2);}
  mint& operator/=(const mint a) { return *this *= a.inv();}
  mint operator/(const mint a) const { return mint(*this) /= a;}
};
istream& operator>>(istream& is, mint& a) { return is >> a.x;}
ostream& operator<<(ostream& os, const mint& a) { return os << a.x;}

mint f(int n) {
    if(n==0)return 1;
    mint x=f(2/n);
    x*=x;
    if(n%2==1)x*=2;
    return x;
}

mint choose(int n,int a){
    mint x =1,y=1;
    rep(i,a){
      x*=n-i;
      y*=a+i;
    }
    return x/y;
}
const ll m=1000005;

int main()
{
 ll k;
 cin>>k;
 ll tmp=7;
 ll cnt=1;
 while(cnt<100000000){
     if(tmp%k==0){
       cout<<cnt<<endl;
       return 0;
     }
     cnt++;
     tmp=tmp*10+7;
     tmp%=k;
 }
 cout<<-1<<endl;
}

 




Measured memory_bytes: 5984
#include <bits/stdc++.h>
using namespace std;
#define maxn 100010
int a[maxn], b[maxn], c[maxn];
int cmp(int i, int j) {
	return b[i] < b[j] || b[i] == b[j] && a[i] < a[j];
}
int main()
{
	int n, m, ans = 0;
	
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; i++) {
		scanf("%d%d", &a[i], &b[i]);
		c[i] = i;
	}
	sort(c, c + m, cmp);
	int loc = 0;
	for (int i = 0; i < m; i++) {
		if (a[c[i]] >= loc) {
			loc = b[c[i]];
			ans++;
		}
	}
	printf("%d\n", ans);
}


Measured memory_bytes: 1408
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
using namespace std;
typedef long long ll;
ll mod = 1e9+7;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main(){
    int n, q;
    ll k;
    cin >> n >> k >> q;
    vector<ll> correct_point(n);
    rep(i, q) {
        int a;
        cin >> a;
        --a;
        ++correct_point[a];
    }
    rep(i, n) {
        if ( q - correct_point[i] < k ) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 1408
import java.util.Scanner;

public class Main {
 public static void main(String[] args) {
	Scanner in = new Scanner(System.in);
	StringBuilder sb = new StringBuilder();
	while (in.hasNext()) {
	 int w = in.nextInt();
	 int i = 1;
	 sb.setLength(0);
	 while (i <= 512) {
		if ((w & i) == i) {
		 sb.append(i).append(' ');
		}
		i = i << 1;
	 }
	 System.out.println(sb.toString().trim());
	}
 }
}

Measured memory_bytes: 12000
#include<iostream>
#include<algorithm>
#include<vector>
#include<numeric>
#include<string>
#include<cmath>
#include<set>
#include<queue>
#include<deque>
#include<bitset>
#include<iomanip>
#include<cctype>
#include<map>

#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,a,b) for (int (i)=a;(i)<(b);(i)++)
#define all(x) (x).begin(),(x).end()

using namespace std;
const int inf = 1001001000;
const long long int Inf = 1001001001001001000;

void print(vector<vector<int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<vector<long long int>> a){
	for (int i=0;i<a.size();i++){
		for (int j=0;j<a[i].size();j++){
			cout << a[i][j] << " ";
		}
		cout << endl;
	}
}

void print(vector<int> a){
    int n = a.size();
    for (int j=0;j<n;j++) {
        if (j != n-1) cout << a[j] << " ";
        else cout << a[j] << endl;
    }
}

int main(){
	int n;
	cin >> n;
	vector<int> h(n);
	rep(i, n) cin >> h[i];
	vector<int> dp(n,inf);
	dp[0] = 0;
	dp[1] = abs(h[1] - h[0]);
	rep(i, n - 2)
		dp[i + 2] = min(dp[i] + abs(h[i + 2] - h[i]), dp[i + 1] + abs(h[i + 2] - h[i + 1]));
	cout << dp[n - 1] << endl;
	return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>

using namespace std;
#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 (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
string s;

vector <int> ch(26);




int main()
{

	cin >> s;
	REP(i,s.length()){
		ch[s[i]-'a']++;
	}
	int mi = 1000;
	REP(i,26){
		if(ch[i]==0)
			continue;
		int count=0;
		int m = 0;
		REP(j,s.length()){
			if(s[j]-'a'==i){
				if(count > m)
					m = count;
				count=0;
				continue;
			}
			count++;
		}
		if(count > m)
			m = count;

		if(m < mi){
			mi = m;
		}
	}

	cout << mi << endl;



}


Measured memory_bytes: 256
package main

import (
	"bufio"
	"fmt"
	"os"
	"strings"
)

func main() {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Scan()
	var str string
	fmt.Sscanf(scanner.Text(), "%s", &str)
	chars := strings.Split(str, "")

	if len(chars) == 2 {
		fmt.Println(str)
	} else {
		for i := len(chars) - 1; i >= 0; i-- {
			fmt.Print(chars[i])
		}
		fmt.Println()
	}
}


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

#define ll long long
#define ld long double
#define pb push_back
#define popb pop_back
#define beg begin()
#define en end()
#define sz(v) (int)((v).size())
#define all(v) (v).begin(),(v).end()
#define ff first
#define ss second
#define endl "\n"
#define forn(i,a,n) for(int i=a;i<int(n);++i)
#define forb(i,a,n) for(int i=int(n)-1;i>=a;--i)
#define cout(ans) cout<< ans << "\n"
#define mod 1000000007
void speed()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
    cout.tie(NULL);
}





void solve()
{
	int r,c;cin>>r>>c;
	char cc[r+1][c+1];
	ll dp[r+1][c+1];
	forn(i,0,r)
	{
		cin>>cc[i];
	}
	forn(i,0,r)
	{
		forn(j,0,c)
		{
			
			{
				dp[i][j]=-1;
			}
		}
	}
	int flag=1;
	forn(i,0,r)
	{
		if(cc[i][0]=='#')
		{
			flag=0;
		}
		dp[i][0]=flag;
	}
	flag=1;
	forn(i,0,c)
	{
		if(cc[0][i]=='#')
		{
			flag=0;
		}
		dp[0][i]=flag;
	}
	forn(i,0,r)
	{
		forn(j,0,c)
		{
			if(cc[i][j]=='#')
			{
				dp[i][j]=0;
			}
		}
	}
	forn(i,1,r)
	{
		forn(j,1,c)
		{
			if(dp[i][j]!=0)
			{
				dp[i][j]=(dp[i-1][j]%mod+dp[i][j-1]%mod)%mod;
			//	cout(dp[i][j]);
			}

		}
	}
	cout(dp[r-1][c-1]%mod);

}


int main()
{   
    speed();
    //int tc;cin>>tc;
    //while(tc--)
    {
        solve();
    }
}

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

int n,cnt;
long long sum;

int main(){
	scanf("%d",&n);
	for(int i=1;;++i){
		if(i%2==0||i%3==0||i%5==0) printf("%d ",i), sum+=i, ++cnt;
		if(cnt==n-2) break;
	}
	sum%=30; sum+=60;
	if(sum&1){
		printf("29997 %d",30033-sum);
	}
	else{
		for(int i=5;;i+=5)
			if((sum-i)%3==0&&sum-i>=3){
				printf("%d %d",30000-i,30000-sum+i);
				break;
			}
	}
	return 0;
}

Measured memory_bytes: 384
#include<stdio.h>
int main(void)
{
	int a,s[1001],d[1001],f[1001],g[1001],h[1001],i,j;
	scanf("%d",&a);
	while(a!=0){
		j=0;
		for(i=1;i<=a+1;i++){
			scanf("%d %d %d %d",&s[i],&d[i],&f[i],&g[i]);
			h[i]=4*d[i]+9*f[i]+g[i]*4;
		}
		for(i=1;i<=a;i++){
			if(d[i]<=s[a+1]&&f[i]<=d[a+1]&&g[i]<=f[a+1]&&h[i]<=g[a+1]){
				printf("%d\n",s[i]);
				j=1;
			}
		}
		if(j==0){
			printf("NA\n");
		}
		scanf("%d",&a);
	}
	return 0;
}

Measured memory_bytes: 1056
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

int main(void)
{
    cin.sync_with_stdio(false);
    int N;
    cin >> N;

    vector<int> ans(100001);

    set<int> base{1};
    int t = 6;
    while(t <= 100000) {
        base.insert(t); t *= 6;
    }
    t = 9;
    while(t <= 100000) {
        base.insert(t); t *= 9;
    }

    auto que = base;
    int rep = 1;
    while(!que.empty()) {

        for (auto e : que) {
            ans[e] = rep;
        }

        set<int> nxt;
        for(auto e: que) {
            for(auto b: base) {
                if (e + b <= 100000 && ans[e + b] == 0)
                {
                    nxt.insert(e + b);
                }
            }
        }
        cout << endl;
        ++rep;
        que = nxt;
    }
    cout << ans[N] << endl;

    return 0;
}


Measured memory_bytes: 2432
#include <iostream>
    #include<math.h>
    #include <limits>
    #include <iomanip>
    #include <algorithm>
    using namespace std;
    #define rep(i, n) for (int i =0; i < (int)(n); i++)
     
    int main() {
        int N;
        cin >>N;
        int a, b, c;
        a = N % 10;
        N = N / 10;
        b = N % 10;
        N = N / 10;
        c = N % 10;
        if (a == 7 || b == 7 || c == 7)cout << "Yes" << endl;
        else cout << "No" << endl;
     
        return 0;
    }

Measured memory_bytes: 3624
#include <cstdio>
#include <algorithm>
#define LL long long
using namespace std;
LL ans;
int main(){
	int n,i,u,v;
	scanf("%d",&n);
	for(i=1;i<=n;i++)ans+=(LL)i*(n-i+1);
	for(i=1;i<n;i++){
		scanf("%d%d",&u,&v);
		if(u>v)swap(u,v);
		ans-=(LL)u*(n-v+1);
	}
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 1736
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner scan =new java.util.Scanner(System.in);
		int  a1 = scan.nextInt();
		int  a2 = scan.nextInt();
		int  a3 = scan.nextInt();
		if(a1+a2+a3 >= 22) {
		System.out.println("bust");
		}
		else {
			System.out.println("win");
		}
	}

}

Measured memory_bytes: 22100
#include<bits/stdc++.h>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fin(x) freopen(x,"r",stdin)
#define fout(x) freopen(x,"w",stdout)
#define mem(a,b) memset(a,b,sizeof(a))
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll inf=0xc0c0c0c0c0c0c0c0;
const double pi=acos(-1);
ll N,A;
ll qpow(ll b,ll p)
{
	ll res=1;
	while(p)
	{
		if(p&1)res*=b;
		b*=b;
		p>>=1;
	}
	return res;
}	
ll f(ll x){return(N-1)/x+1;}
int main()
{
	scanf("%lld%lld",&N,&A);
	ll m=N;
	for(int K=1;(1ll<<K)<=N;K++)
	{
		// cout<<K<<endl;
		ll low=2;
		while(qpow(low+1,K+1)<=N)low++;
		ll high=low+1;
		ll t1=K*A;
		ll t2=low*K;
		ll t3=qpow(low,K);
		m=min(m,t1+t2+f(t3));
		for(int i=0;i<K;i++)
		{
			t2++;
			t3/=low;
			t3*=high;
			m=min(m,t1+t2+f(t3));
		}
	}
	printf("%lld\n",m);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <cmath>

using namespace std;

#define ll long long

#define DEBUG (0)

typedef struct{
  ll acCount;
  ll waCount;
}prob;

prob p[100005] = {0};

int main()
{
  ll N = 0;
  ll M = 0;
  ll probNo = 0;
  string answer = "";
  const string AC = "AC";
  const string WA = "WA";
  ll i = 0;
  ll acSum = 0;
  ll waSum = 0;

  cin >> N >> M;

  /* 提出０回 */
  if(M == 0){
    cout << 0 << " " << 0 << "\n";
    return 0;
  }

  for(i = 0; i < M; i++){
    cin >> probNo;
    cin >> answer;

    if(p[probNo].acCount >= 1){
      /* すでに正解済みの問題番号の場合はスキップ */
      continue;
    }else{
      if(answer == AC){
        p[probNo].acCount = 1;
      }else{
        p[probNo].waCount++;
      }
    }
  }

  for(i = 0; i <= N; i++){
    acSum += p[i].acCount;
    if(p[i].acCount >= 1){
      waSum += p[i].waCount;
    }
  }

  cout << acSum << " " << waSum << "\n";


#if DEBUG
  for(i = 0; i < 100001; i++){
    cout << "p[" << i << "]---  acCount:" << p[i].acCount << ",  ";
    cout << "waCount: " << p[i].waCount << "\n";
  }
#endif

}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define pb(x) push_back(x)
#define f(i,st,n) for(i=st;i<n;i++)
#define qu queue
#define ps(x) push(x)
#define vec vector
#define ft() front()
#define mst(a,b) memset(a,b,sizeof(a))
#define mod 1000000007
#define sfl(x) scanf("%lld",&x)
#define pfl(x) printf("%lld\n",x)
#define pf(x) printf("%lld",x)
#define mpr make_pair
#define fs first
#define se second
 
 
 
 
ll gcd(ll a,ll b){
    if(a==0){
        return b;
    }                     
    return gcd(b%a,a);
}
ll power(ll x,ll y){            
    ll res=1;
    while(y>0){
        if(y%2==1){
            res=(res*x);
        }
        x=(x*x);
        y=y/2;
    }
    return res;
}
 
 
int main(){
 
/* #ifndef ONLINE_JUDGE
    
   freopen("input.txt", "r", stdin);
   
   freopen("output.txt", "w", stdout);
   #endif*/
   
ll n,i,k,j;
sfl(n);
ll a[3];


vec<ll>dp(3,0),dp1(3,0);


f(i,0,n){
  f(j,0,3){
   sfl(a[j]);

  f(k,0,3){
    if(j!=k){
     dp1[j]=max(dp1[j],dp[k]+a[j]);
    }
  }

  }
  dp=dp1;


  

}

cout<<max(dp[0],max(dp[1],dp[2]));

 
 
 
  
 
 
 
 
 
 
 
 
 
 
 
 
   return 0;
 }

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
const int inf = 1e9;
const ll INF = 1e18;
const double pi = 3.14159265358979323846;
#define rep(i,n) for(ll i=0;i<n;i++)
using Graph = vector<vector<int>>;
using pint = pair<int,int>;
int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};

int main(){
    int k,t;cin>>k>>t;
    int a[t];
    int mx=0,sum=0;
    rep(i,t){
        cin>>a[i];
        mx=max(mx,a[i]);
        sum+=a[i];
    }
    sum-=mx;
    int ans=max(0,mx-1-sum);
    cout<<ans<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
const int INF=1145141919,MOD=1e9+7;
const int64_t LINF=8931145141919364364,LMOD=998244353;
const int dy[]={0,-1,0,1,1,-1,-1,1};
const int dx[]={1,0,-1,0,1,1,-1,-1};

template<typename T>
struct WarshallFloyd {
	const int V;
	// オーバーフロー注意
	const T INF = numeric_limits<T>::max() / 3;
	vector<vector<T>> dist;
	WarshallFloyd(const int V) :
		V(V),
		dist(vector<vector<T>>(V, vector<T>(V, INF)))
		{}
	bool addEdge(int from, int to, T cost) {
		if(cost >= dist[from][to]) return false;
		dist[from][to] = cost;
		return true;
	}
	void build() {
		for(int i = 0; i < V; ++i) {			// 経由点 i
			for(int j = 0; j < V; ++j) {		// 始点 j
				for(int k = 0; k < V; ++k) {	// 終点 k
					dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
				}
			}
		}
	}
	T distance(int from, int to) {
		if(dist[from][to] >= INF) return INF;
		return dist[from][to];
	}
	void debug() {
		for(int i = 0; i < V; ++i) {
			for(int j = 0; j < V; ++j) {
				cout << dist[i][j] << " ";
			}
			cout << "\n";
		}
	}
};


int main() {
	int h, w; cin >> h >> w;
	string s[h]; rep(i,h) cin >> s[i];
	WarshallFloyd<int64_t> wf(h * w);
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			wf.addEdge(y * w + x, y * w + x, 0);
			if(s[y][x] != '#') {
				for(int d = 0; d < 4; ++d) {
					int ny = y + dy[d];
					int nx = x + dx[d];
					if(ny < 0 or h <= ny) continue;
					if(nx < 0 or w <= nx) continue;
					if(s[ny][nx] != '#') {
						wf.addEdge(y * w + x, ny * w + nx, 1);
					}
				}
			}
		}
	}
	wf.build();
	// wf.debug();
	int64_t ans = 0;
	for(int y = 0; y < h; ++y) {
		for(int x = 0; x < w; ++x) {
			if(s[y][x] == '#') continue;
			int64_t tmp = 0;
			for(int gy = 0; gy < h; ++gy) {
				for(int gx = 0; gx < w; ++gx) {
					if(s[gy][gx] == '#') continue;
					ans = max(ans, wf.distance(y * w + x, gy * w + gx));
				}
			}
		}
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 1536
n = gets.chomp.to_i
ary = []
n.times do
  ary << gets.split(' ')
end
 
sum = 0
 
n.times do |i|
  if ary[i][1] == "JPY"
    sum += ary[i][0].to_f
  else
    sum += ary[i][0].to_f * 380000.0
  end
end
 
puts sum

Measured memory_bytes: 1788
s=input()
odd=["R", "U", "D"]
ev=["L", "U", "D"]

def t():
    for i,d in enumerate(s):
        if (i+1)%2==1:
            if not d in odd:
                return "No"
        else:
            if not d in ev:
                return "No"
    return "Yes"

print(t())

Measured memory_bytes: 2940