akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp> 
//using namespace boost::multiprecision; 

using namespace std;
#define all(c) c.begin(),c.end()
#define REP(i,a,b) for(int i=a;i<=b;++i)
#define tr(container,it) \
for(auto it=container.begin();it!=container.end();++it)

//#Rohitpratap311
//#Keep Calm And Stay Happy

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
#define mod 1000000007 
#define MAXN 200001
int n;
int best;
vector<int> g[MAXN] ;
bool used[MAXN] ;
vector<int> comp ;

bool ifprime(ll n)
{
    if(n==2||n==3) { return true ; }
    for(ll i=2;i<=sqrt(n);i++)
    {
        if(n%i==0) { return false; }
    }
    return true;
}

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

void dfs(int v) 
{
    used[v] = true ;
    comp.push_back(v);
    for (size_t i = 0; i < (int) g[v].size(); ++i) 
    {
        int to = g[v][i];
        if (!used[to])
            dfs(to);
    }
}

void find_comps() 
{
    for (int i = 0; i < n ; ++i)
        used [i] = false;
    for (int i = 0; i < n ; ++i)
        if (!used[i]) 
        {
            comp.clear();
            dfs(i);
            int val=comp.size();
            best=max(best,val);
        }
}

int main()
{
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll t=1;
    //cin>>t;
    while(t--)
    {
        int m;
        cin>>n>>m;
        for(int i=1;i<=m;++i)
        {
            int a,b;
            cin>>a>>b;
            g[a].push_back(b);
            g[b].push_back(a);
        }
        find_comps();
        cout<<best;
    }
    return 0;
}

Measured memory_bytes: 24632
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <algorithm>
#include <utility>
#include <string>
using namespace std;

int main()
{
    int n;
    int aa,bb,cc;
    cin >> n;
    int a[n+1], b[n+1], c[n+1];
    a[0]=0;
    b[0]=0;
    c[0]=0;    
    
    for(int i=1;i<n+1;i++){
        cin >> aa >> bb >> cc;
        a[i]=aa;
        b[i]=bb;
        c[i]=cc;
    }
    
    int dp[3][n+1];
    dp[0][0]=0;
    dp[1][0]=0;
    dp[2][0]=0;   
    
    for(int i=1;i<n+1;i++){
        dp[0][i] = max(dp[1][i-1], dp[2][i-1]) + a[i];
        dp[1][i] = max(dp[0][i-1], dp[2][i-1]) + b[i]; 
        dp[2][i] = max(dp[1][i-1], dp[0][i-1]) + c[i];
    }
    
    int ans = max(dp[0][n], dp[1][n]);
    ans = max(ans, dp[2][n]);
    
    
    
    std::cout << ans << std::endl;
}

// GCC reference:
//   https://gcc.gnu.org/

// C++ language references:
//   https://cppreference.com/
//   https://isocpp.org/
//   http://www.open-std.org/jtc1/sc22/wg21/

// Boost libraries references:
//   https://www.boost.org/doc/


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

int main() {
  int N, t;
  cin >> N;
  vector<int> d(N);
  vector<int> s(N);
  //値入力
  for(int i; i < N; i++) {
    cin >> d.at(i);
    //cout << d.at(i);
  }
  
  //大小並べ替え
  for(int j = 0; j < N; j++) {
    for(int k = 0; k < N; k++) {
      if(s.at(j) < d.at(k)) {
        s.at(j) = d.at(k);
      }
      
    } //s(j)が決定
   
    for(int l = 0; l < N; l++) {
      if(s.at(j) == d.at(l)) {
        d.at(l) = 0;
      }
      
    }
    
  } //vecsが決定
  
  for(int m = 0; m < N; m++) {
    if(s.at(m) > 0) {
      t += 1;
    }
    
  }
  
  cout << t << endl;  
}

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

typedef long long int   ll;
#define f(i,st,en)    for(int i=st;i<en;i++)
#define s(n)            scanf("%d",&n)
#define sc(n)           scanf("%c",&n)
#define sl(n)           scanf("%lld",&n)
#define sf(n)           scanf("%lf",&n)

using namespace std;


int main(){
    string s;
    cin>>s;
    int fl=0;
    for(int i=0;i<s.size();i++){
        if(s[i]=='7'){
            cout<<"Yes";
            fl=1;
            break;
        }
    }
    if(!fl)cout<<"No";
    cout<<endl;
    return 0;
}


Measured memory_bytes: 3624
#include <iostream>
#include <vector>
#include <algorithm>
using ll = long long;
constexpr ll MOD = 1e9 + 7;
template <ll mod = MOD>
class ModCombination
{
public:
    ModCombination(const std::size_t n) : fact(n + 1, 1), inv(n + 1, 1), inv_fact(n + 1, 1)
    {
        for (ll i = 2; i <= (ll)n; i++) { fact[i] = (fact[i - 1] * i) % mod, inv[i] = ((mod - (mod / i)) * inv[mod % i]) % mod, inv_fact[i] = (inv_fact[i - 1] * inv[i]) % mod; }
    }
    ll factorial(const std::size_t n) const { return fact[n]; }
    ll inverse(const std::size_t n) const { return inv[n]; }
    ll inverseFactorial(const std::size_t n) const { return inv_fact[n]; }
    ll permutation(const std::size_t n, const std::size_t k) const { return (fact[n] * inv_fact[n - k]) % mod; }
    ll combination(const std::size_t n, const std::size_t k) const { return (((fact[n] * inv_fact[k]) % mod) * inv_fact[n - k]) % mod; }

private:
    std::vector<ll> fact, inv, inv_fact;
};
int main()
{
    int H, W, N;
    std::cin >> H >> W >> N;
    std::vector<int> r(N + 2, 1), c(N + 2, 1);
    for (int i = 1; i <= N; i++) { std::cin >> r[i] >> c[i]; }
    r[N + 1] = H, c[N + 1] = W;
    ModCombination<> mod(H + W);
    std::vector<std::vector<ll>> way(N + 2, std::vector<ll>(N + 2, -1));
    auto dp = [&](auto&& self, const int s, const int t) -> ll {
        if (way[s][t] != -1) { return way[s][t]; }
        ll ans = mod.combination(r[t] + c[t] - r[s] - c[s], r[t] - r[s]);
        for (int i = 0; i <= N + 1; i++) {
            if (i == s or i == t) { continue; }
            if (r[s] <= r[i] and r[i] <= r[t] and c[s] <= c[i] and c[i] <= c[t]) { (ans += MOD - self(self, s, i) * mod.combination(r[t] - r[i] + c[t] - c[i], r[t] - r[i]) % MOD) %= MOD; }
        }
        return way[s][t] = ans;
    };
    std::cout << dp(dp, 0, N + 1) << std::endl;
    return 0;
}


Measured memory_bytes: 75520
#include <cstdio>

int main(){
    int n;
    scanf("%d",&n);
    unsigned long long l[n + 1];
    l[0] = 2;
    l[1] = 1;
    for(int i = 2; i <= n; i++){
        l[i] = l[i - 1] + l[i - 2];
    }
    printf("%lld\n",l[n]);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <vector>
using namespace std;

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

const int dx[4] = {-1, 0, 0, 1};
const int dy[4] = {0, -1, 1, 0};

// Self settings
// clang-format off
#define MAX_N 100000
#define REP(i, N) for (int i = 0; i < (int)(N); ++i)
// clang-format on

int N, M;
int A[MAX_N], B[MAX_N];

class UnionFind {
  public:
  vector<int> Parent;
  UnionFind(int N) { Parent = vector<int>(N, -1); }
  int root(int A)
  {
    if (Parent[A] < 0) return A;
    return Parent[A] = root(Parent[A]);
  }
  int size(int A) { return -Parent[root(A)]; }
  bool connect(int A, int B)
  {
    A = root(A);
    B = root(B);
    if (A == B) return false;
    if (size(A) < size(B)) swap(A, B);
    Parent[A] += Parent[B];
    Parent[B] = A;
    return true;
  }
};

void solve()
{
  UnionFind Uni(N);
  ll ans[MAX_N + 1];
  ans[M - 1] = (ll)N * (N - 1) / 2;
  for (int i = M - 1; i > 0; i--) {
    int u = A[i], v = B[i];
    ans[i - 1] = ans[i];
    if (Uni.root(u) != Uni.root(v)) {
      ans[i - 1] -= (ll)Uni.size(u) * Uni.size(v);
      Uni.connect(u, v);
    }
  }
  REP(i, M) cout << ans[i] << (i == M - 1 ? "\n" : " ");
  // REP(i, M) cout << ans[i + 1] << endl;
}

int main(void)
{
  cin >> N >> M;
  REP(i, M)
  {
    int u, v;
    cin >> u >> v;
    // 0-indexed
    u--, v--;
    A[i] = u, B[i] = v;
  }
  solve();
  return 0;
}


Measured memory_bytes: 3328
program ABC046A
    implicit none
    integer(8)::a,b,c
    integer(8)::count=0
    read(5,*)a,b,c

    if(a/=b)then
        count=2
        if(a/=c.and.b/=c)count=count+1
    else
        count=1
        if(a/=c)count=count+1
    end if
    print'(i0)',count
end program ABC046A

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
template <typename T> void read(T &x){
	x = 0; int f = 1; char ch = getchar();
	while (!isdigit(ch)) {if (ch == '-') f = -1; ch = getchar();}
	while (isdigit(ch)) {x = x * 10 + ch - '0'; ch = getchar();}
	x *= f;
}
inline void write(int x){if (x > 9) write(x/10); putchar(x%10+'0'); }

const int N = 200050;
int n,a[N];
int main(){
	int i;
	read(n);
	for (i = 1; i <= n; ++i) read(a[i]);
	sort(a+1,a+n+1);
	for (i = 2; i <= n; ++i) if (a[i]==a[i-1]){
		puts("NO"); return 0;
	}
	puts("YES");
    return 0;
}


Measured memory_bytes: 1024
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {

    public static void main(String[] args) throws Exception {

        try {

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

            String[] numbers = br.readLine().split(" ");
            int product = Integer.parseInt(numbers[0]) * Integer.parseInt(numbers[1]);

            String thisNumberIs = "Odd";
            if (product % 2 == 0) {
                thisNumberIs = "Even";
            }

            System.out.println(thisNumberIs);
        } catch (IOException | NumberFormatException e) {
            e.printStackTrace();
            System.exit(0);
        } catch (final Exception e) {
            e.printStackTrace();
            System.exit(0);
        }
    }
}

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

int main() {
	double a,b,x,h,s,ans;
	cin >> a >> b >> x;
	s = (double)x/(double)a;
	if(s>=(double)a*(double)b/2.0){
		h=(((double)a*(double)b-s)*2.0)/(double)a;
		ans = (180.0*(atan2(h,(double)a)))/((double)acos(-1));
	}else{
		h=(double)s*2.0/(double)b;
		ans = (180.0*(atan2((double)b,h)))/((double)acos(-1));
	}
	printf("%.10f\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>


using namespace std;


int main() {

    double n,k,i,j,loop;
    double ans=0;
    int temp;
    cin>>n>>k;

    for(i=1;i<=n;i++){
        if(i>=k)break;

        temp=(int)log2(k/i);
        if(temp==log2(k/i))temp--;
        ans+=(1/n)*pow(0.5,((double)temp+1));
    }
    if(n>=k)ans+=(n-k+1)/n;
    cout << std::setprecision(13) << ans << endl;

    return 0;

}

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

main()
{
    long long int n,k,x,y,ans;
    scanf("%lld %lld %lld %lld", &n, &k, &x, &y);
    if(n<=k) ans=n*x;
    else {
        ans=k*x;
        ans+=(n-k)*y;
    }
    printf("%lld\n", ans);
}


Measured memory_bytes: 128
n, m, X, Y =(int(x) for x in input().split())
x = list(map(int, input().split()))
y = list(map(int, input().split()))

for z in range(X+1,Y+1):
    if z > max(x) and z <= min(y):
        print('No War')
        break
    if z == Y:
        print('War')

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

int main() {
  int k, n;
  cin >> k >> n;

  vector<int> a(n);
  for (int i = 0; i < n; i++) {
      cin >> a.at(i);
  }
  sort(a.begin(), a.end());

  vector<int> diff(n);
  for (int i = 0; i < n-1; i++) {
      diff.at(i) = a.at(i+1) - a.at(i);
  }
  diff.push_back(a.at(0) - a.at(n-1) + k);
  
  int ans;
  auto max = max_element(diff.begin(), diff.end());
  ans = k - *max;

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


Measured memory_bytes: 2560
import math
n , a , b = map(int , input().split())
total = 0
ans = 0
for i in range(1 , n + 1):
  if a <= i//10000 + (i//1000)%10 + (i//100)%10 + (i//10)%10 + i%10<= b:
    ans += i

print(ans)

Measured memory_bytes: 3060
//
//  main.cpp
//  1234
//
//  Created by Moha Jain on 14/04/20.
//  Copyright © 2020 Moha Jain. All rights reserved.
//
 
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<unordered_map>
#include<unordered_set>
#include<queue>
#include<stack>
#include<algorithm>
#include<string>
#include<math.h>
#include <iomanip>
#include <numeric>
#define _USE_MATH_DEFINES
 
using namespace std;
 

 
int main()
{
    string s;cin>>s;
    
    int n = (int)s.length();
    
    string t = s;
    reverse(t.begin(),t.end());
    if(t!=s){cout<<"No"<<endl;return 0;}
    string u = s.substr(0,n/2);
    string v = u;
    reverse(v.begin(),v.end());
    if(v!=u){cout<<"No"<<endl;return 0;}
    
    string w = s.substr((n+3)/2 -1);
    string x = w;
    reverse(x.begin(),x.end());
    if(x!=w){cout<<"No"<<endl;return 0;}
    
    cout<<"Yes"<<endl;
}




Measured memory_bytes: 3628
N = int(input())
P = []
M = []
A = []

def dist(p1, p2):
  return abs(p1[0]-p2[0]) + abs(p1[1]-p2[1])

for i in range(N):
  x, y = map(int, input().split())
  P.append(x+y)
  M.append(x-y)
  A.append((x, y))

ans1 = dist(A[P.index(max(P))], A[P.index(min(P))])
ans2 = dist(A[M.index(max(M))], A[M.index(min(M))])

print(max(ans1, ans2))

Measured memory_bytes: 114560
import sys

read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

in_n = lambda: int(readline())
in_nn = lambda: map(int, readline().split())
in_s = lambda: readline().rstrip().decode('utf-8')
in_nl = lambda: list(map(int, readline().split()))
in_nl2 = lambda H: [in_nl() for _ in range(H)]
in_map = lambda: [s == ord('.') for s in readline() if s != ord('\n')]
in_map2 = lambda H: [in_map() for _ in range(H)]
in_all = lambda: map(int, read().split())


def main():

    L, R, d = in_nn()
    ans = R // d - (L - 1) // d
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 62052
N = list(input().split())
S = []

for i in N:
    a = 0
    b = 0
    if i == '+':
        a = S.pop()
        b = S.pop()
        S.append(a+b)
    elif i == '-':
        a = S.pop()
        b = S.pop()
        S.append(b-a)
    elif i == '*':
        a = S.pop()
        b = S.pop()
        S.append(a*b)
    elif i == '/':
        a = S.pop()
        b = S.pop()
        S.append(a//b)
    else:
        S.append(int(i))

print(S[0])


Measured memory_bytes: 5600
#include<bits/stdc++.h>
#define x first
#define y second
const int P = 1e9 + 7;
typedef long long i64;
typedef std::pair<i64,i64> pii;
typedef std::vector<pii> vec;

i64 fib[200];
vec F[200];

template<class T> inline void read(T& a) {
  char c = getchar(); T f = 1; a = 0;
  for(;!isdigit(c); c = getchar())if(c == '-') f = -1;
  for(; isdigit(c); c = getchar())a = a * 10 + c - '0';
  a *= f;
}

template<class T> inline void write(T x) {
  static int stk[20], top;
  do stk[top++] = x % 10, x /= 10; while(x);
  while(top) putchar(stk[--top] + '0');
}

int main() {
  if(fopen("gcd.in","r")) {
    freopen("gcd.in","r",stdin);
    freopen("gcd.out","w",stdout);
  }

#ifdef DEBUG
  double beg = clock();
#endif
  
  fib[0] = fib[1] = 1;
  for(int i = 2;i <= 100; ++i) fib[i] = fib[i-1] + fib[i-2];
  F[1].push_back(pii(1, 2)); F[1].push_back(pii(1, 3));
  for(int i = 2;i+2 < 100; ++i) {
    for(vec::iterator it = F[i-1].begin(); it != F[i-1].end(); ++it) {
      for(i64 x = it->x + it->y;
	  x <= fib[i + 2];
	  x += it->y) {
	//std::cerr << x << ' ' << it->y << ' ' << fib[i+2] << '\n';
	//F[i].push_back(pii(x, it->y));
	F[i].push_back(pii(it->y, x));
      }
    }
  }

  // for(vec::iterator it = F[2].begin(); it != F[2].end(); ++it) {
  //   std::cerr << it -> x << ' ' << it -> y << '\n';
  // }
  
  int T; scanf("%d", &T);
  while(T--) {
    i64 N, M; read(N); read(M);
    if(N > M) std::swap(N, M);
    if(N == 1) printf("1 %lld\n", M % P);
    else if(N == 2 && M == 2) puts("1 4");
    else {
      int k = 1;
      while(fib[k + 1] <= N && fib[k + 2] <= M)
	++k;
      int ans = 0;
      for(vec::iterator it = F[k-1].begin();
	  it != F[k-1].end();
	  ++it) {
  	(ans += it->y <= N ? ((M - it->x) / it->y % P) : 0) %= P;
  	(ans += it->y <= M ? ((N - it->x) / it->y % P) : 0) %= P;
      }
      write(k); putchar(' ');
      write(ans); putchar('\n');
    }
  }

#ifdef DEBUG
  fprintf(stderr, "run time: %lfs", (clock() - beg) / CLOCKS_PER_SEC);
#endif
  
  return 0;
}


Measured memory_bytes: 4096
import sys
n, a, b = map(int, input().split())
mod = 10**9 + 7
sys.setrecursionlimit(10**9)

def f(x):
    if x == 0:
        return 1
    elif x % 2 == 0:
        return (f(x // 2) ** 2) % mod
    else:
        return (f(x - 1) * 2) % mod
def comb(n,k,p):
    """power_funcを用いて(nCk) mod p を求める"""
    from math import factorial
    if n<0 or k<0 or n<k: return 0
    if n==0 or k==0: return 1
    a=factorial(n) %p
    b=factorial(k) %p
    c=factorial(n-k) %p
    return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p
def power_func(a,b,p):
    """a^b mod p を求める"""
    if b==0: return 1
    if b%2==0:
        d=power_func(a,b//2,p)
        return d*d %p
    if b%2==1:
        return (a*power_func(a,b-1,p ))%p
    # 互いに素なa,bについて、a*x+b*y=1の一つの解
def extgcd(a, b):
    r = [1, 0, a]
    w = [0, 1, b]
    while w[2] != 1:
        q = r[2] // w[2]
        r2 = w
        w2 = [r[0] - q * w[0], r[1] - q * w[1], r[2] - q * w[2]]
        r = r2
        w = w2
    # [x,y]
    return [w[0], w[1]]

# aの逆元(mod m)を求める。(aとmは互いに素であることが前提)
def mod_inv(a, m):
    x = extgcd(a, m)[0]
    return (m + x % m) % m

def nCm(a):
    ans = 1
    for i in range(a):
        ans *= n - i
        ans %= mod
    for i in range(1, a+1):
        ans *= mod_inv(i, mod)
        ans %= mod
    return ans

base = f(n)
comb_a = nCm(a)
comb_b = nCm(b)
print((base - comb_a - comb_b - 1) % mod)


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

typedef long long int llint;

int main(){
	int A,B,C;
	llint K;
	cin >> A >> B >> C >> K;
	if(K<A){
		cout << K;
	}else if(A<=K && K<=A+B){
		cout << A;
	}else{
		cout << A-(K-(A+B));
	}
	return 0;
}


Measured memory_bytes: 3596
using System;


public class Hello{
    public static void Main(){
        var s = Console.ReadLine();
        var t = Console.ReadLine();
        
        if(t.StartsWith(s)){
            if (s.Length + 1 == t.Length){
                Console.WriteLine("Yes");
            }else{
                Console.WriteLine("No");
            }
        }else{
            Console.WriteLine("No");
        }
    }
}


Measured memory_bytes: 26108
main(){double a,b,c,d,e,f,g,h,i,x,y;for(scanf("%*d");~scanf("%lf%lf%lf%lf%lf%lf",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f %.3f\n",x,y,hypot(a-x,b-y)))g=a*a+b*b,h=c*c+d*d,i=e*e+f*f,y=(a*(h-i)+c*(i-g)+e*(g-h))/(x=a*(d-f)+c*(f-b)+e*(b-d))/2,x=(b*(i-h)+d*(g-i)+f*(h-g))/x/2;}

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

namespace test
{
    class Program
    {
        static void Main(string[] args)
        {
            string s = Console.ReadLine();

            int H = int.Parse(s.Split(' ')[0]);
            int W = int.Parse(s.Split(' ')[1]);

            List<string> Rows = new List<string>();

            for(int i = 0; i < H; i++)
            {
                string str = Console.ReadLine();
                if (str.Contains("#"))
                {
                    Rows.Add(str);
                } 
            }

            bool[] WhiteColumn = Enumerable.Repeat(true, W).ToArray();

            for (int j = 0; j < W; j++)
            {
                for (int i = 0; i < Rows.Count; i++)
                {
                    if(Rows[i][j] != '.')
                    {
                        WhiteColumn[j] = false;
                        break;
                    }
                }
            }

            for(int i = W - 1; 0 <= i; i--)
            {
                if(WhiteColumn[i])
                {
                    for(int j = 0; j < Rows.Count; j++)
                    {
                        Rows[j] = Rows[j].Remove(i, 1);
                    }
                }
            }

            for (int i = 0; i < Rows.Count; i++)
            {
                if (Rows[i].Contains("#"))
                {
                    Console.WriteLine(Rows[i]);
                }
            }
        }
    }
}


Measured memory_bytes: 13268
//package beg_165;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner a = new Scanner(System.in);
		int b = a.nextInt();
		String xdrtcfvygbuh = a.nextLine();
		
		String c = a.nextLine();
		String[] list = c.split(" ");
		
		int f = Integer.parseInt(list[0]);
		int l = Integer.parseInt(list[1]);
		boolean check=true;
		for (int i=f;i<=l;i++) {
			if (i%b==0) {
				System.out.println("OK");
				
				check=false;
				break;
			}
		}
		if (check) {
			System.out.println("NG");
		}

	}

}


Measured memory_bytes: 35860
#include <bits/stdc++.h>
using namespace std;
#define int       long long
#define w(x)      int x;cin >> x;while (x--)
#define rep(d,a,n)  for(int d=a;d<=n;d++)
#define rep_(d,a,n)  for(int d=a;d>=n;d--)
#define nl        "\n" 
#define fast_io ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define oj  freopen("input.txt", "r", stdin);freopen("output.txt", "w", stdout);
const int inf=1e18;

void fun(){
    int n;
    cin>>n;
    int chefu=0,chomu=0;
    rep(i,0,n-1){
        int num1,num2,sume=0,sumi=0;cin>>num1>>num2;
        while(num1!=0){
            sume+=num1%10;
            num1/=10;
        }
        while(num2!=0){
            sumi+=num2%10;
            num2/=10;
        }
        if(sume>sumi){
            chefu++;
        }else if(sumi>sume){
            chomu++;
        }else{
            chomu++;
            chefu++;
        }
    }    
    if(chefu>chomu){
        cout<<0<<" "<<chefu<<nl;
    }else if(chefu<chomu){
        cout<<1<<" "<<chomu<<nl;
    }else{
        cout<<2<<" "<<chomu<<nl;
    }       
}
int32_t main()
{
    
    fast_io;
   int n;
   cin>>n;
   if(n%1000==0){
       cout<<0;
   }else{
       cout<<(ceil(n/1000)+1)*1000-n;
   }
    
    return 0;
}


Measured memory_bytes: 3756
#include <iostream>
using namespace std;
int main() {
	char s[7];
	int count = 1;
	int x = 4;

	for (int i = 0; i < 4; i++){
		cin >> s[i];
	}
	
	for (int i = 1; i < 4; i++){
		if (s[i] == s[0]) count++;
		else {
			s[x] = s[i];
			x++;
		}
	}

	if (count == 2 && s[4] == s[5]) cout << "Yes\n";
	else cout << "No\n";

	return 0;
}

Measured memory_bytes: 256
#define ll long long
#define ld long double
#define MOD 1000000007
#define MOD2 998244353
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define set2d(array, val, m, n) memset(array, val, sizeof(array[0][0]) * m * n);
#include <bits/stdc++.h>
using namespace std;
ll dp[3005][3005];
ll power(ll x, ll y, ll p)
{
    ll res = 1;
    x %= p;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % p;
        y = y >> 1;
        x = (x * x) % p;
    }
    return res;
}
ll po(ll base, ll powerRaised)
{
    if (powerRaised != 0)
        return (base * po(base, powerRaised - 1));
    else
        return 1;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n, s;
    cin >> n >> s;
    vector<ll> v;
    for (int i = 0; i < n; i++)
    {
        ll x;
        cin >> x;
        v.pb(x);
    }

    for (int i = 0; i <= n; i++)
        for (int j = 0; j <= s; j++)
            dp[i][j] = 0;
    for (int i = 0; i < n; i++)
        dp[i + 1][v[i]] = i + 1;
    ll res[s + 1] = {0};
    for (int i = 1; i <= n; i++)
    {
        for (int j = 1; j <= s; j++)
            if (j >= v[i - 1])
                dp[i][j] = (dp[i][j] + res[j - v[i - 1]]) % MOD2;
        for (int j = 1; j <= s; j++)
            res[j] = (res[j] + dp[i][j]) % MOD2;
    }
    // for (int i = 1; i <= n; i++)
    // {
    //     for (int j = 1; j <= s; j++)
    //     {
    //         cout << dp[i][j] << " ";
    //     }
    //     cout << endl;
    // }
    ll ans = 0;
    for (int i = 1; i <= n; i++)
        ans = (ans + (dp[i][s] * (n - i + 1))) % MOD2;
    cout << ans;
    return 0;
}


Measured memory_bytes: 70784
using System;
using System.Collections.Generic;
using System.Text;

namespace AtCoder02
{
    class ABC118_A
    {
        public static void Main(string[] args)
        {
            int x = int.Parse(Console.ReadLine());
            Console.WriteLine(x == 7 || x == 5 || x == 3 ? "YES" : "NO");
        }
    }
}


Measured memory_bytes: 13140
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int n;ll a[110],ans;
bool work(){
	int p=1;
	for (int i=1;i<=n;i++) if (a[i]>a[p]) p=i;
	if (a[p]<n) return 0;
	ll cnt=a[p]/n;ans+=cnt;
	a[p]%=n;a[p]-=cnt;
	for (int i=1;i<=n;i++) a[i]+=cnt;
	return 1;
}
int main()
{
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%lld",&a[i]);
	while (work());
	printf("%lld\n",ans);
	return 0;
}

Measured memory_bytes: 256
# include <iostream>
# include <deque> 
using namespace std;
struct info
{
	char name[15];
	int sum;
};
int main(void)
{
	int n,deal;
	int Time = 0;
	deque<info> w;
	info tem;
	scanf("%d %d",&n,&deal);
	for(int i = 0;i < n;i++)
	{
		scanf("%s %d",&tem.name,&tem.sum);
		w.push_back(tem);
	}
	while(w.size())
	{
		if(w[0].sum <= deal)
		{
			Time += w[0].sum;
			printf("%s %d\n",w[0].name,Time);
			w.pop_front();
		}
		else
		{
			Time += deal;
			w[0].sum -= deal;
			w.push_back(w[0]); w.pop_front();
		}
	}
	return 0;
} 


Measured memory_bytes: 4100
#include <stdio.h>

int main()
{
    char a, b;
    int flag = 0;
    scanf(" %c %c", &a, &b);
    if(a == 'H')
    {
        if(b == 'H')
            flag = 1;
    }
    else
    {
        if(b == 'D')
            flag = 1;
    }
    if(flag)
        printf("H\n");
    else
        printf("D\n");
    return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
using P = pair<ll, int>;

#define INF 1001001001

int main() {
  int n;
  cin >> n;
  vector< vector<int> > dp(n+1, vector<int>(n+1,-1));
  map<P,int> next;
  P maxidx = {0,0};
  vector<int> maxidx1(n+1), maxidx2(n+1); 
  int x, y, z;

  auto move = [&](P from, P to, bool plus) {
    int fx, fy, tx, ty;
    tie (fx,fy) = from;
    if (dp[fx][fy]==-1) return;
    next[to] = max(next[to],dp[fx][fy]+plus);
  };
  auto update = [&] {
    int x, y;
    for (auto m : next) {
      tie(x,y) = m.first;
      dp[x][y] = m.second;
      if (dp[x][y] > dp[maxidx.first][maxidx.second]) maxidx = {x,y};
      if (dp[x][y] > dp[maxidx1[y]][y]) maxidx1[y] = x;
      if (dp[x][y] > dp[x][maxidx2[x]]) maxidx2[x] = y;
    }
    next.clear();
  };

  cin >> x >> y; x--; y--;
  dp[x][y] = 0;
  move({x,y},{x,y},false);
  update();
  int ans = 0;
  rep(i,n) {
    if (i==n-1) {
      cin >> x; x--;
      y = z = n;
    } else {
      cin >> x >> y >> z;
      x--; y--; z--;
    }
    if (x == y && y == z) {
      ans++;
      update();
      continue;
    }
    if (x == y || x == z || y == z) {
      int p, q;
      if (x == y) p = x, q = z;
      if (x == z) p = x, q = y;
      if (y == z) p = y, q = x;
      rep(j,n) {
        move({j,p},{j,q},true);
        move({p,j},{j,q},true);
      }
    }
    move({x,x},{y,z},true);
    move({y,y},{x,z},true);
    move({z,z},{x,y},true);

    move(maxidx,{x,y},false);
    move(maxidx,{x,z},false);
    move(maxidx,{y,z},false);

    rep(j,n) {
      move({maxidx1[j],j},{j,x},false);
      move({j,maxidx2[j]},{j,x},false);
      move({maxidx1[j],j},{j,y},false);
      move({j,maxidx2[j]},{j,y},false);
      move({maxidx1[j],j},{j,z},false);
      move({j,maxidx2[j]},{j,z},false);
    }
    update();
  }
  ans += dp[maxidx.first][maxidx.second];

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 19688
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep(i,n) for(ll i=0;i<(n);i++)
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))

using namespace std;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}

const ll INF=1e15;

int main()
{
    ll n,x;
    cin >> n >> x;
    vector<ll> a(n);
    rep(i,n){
        cin >> a[i];
    }
    ll ans=0;
    rep(i,n-1){
        if(a[i+1]+a[i]>x){
            ll d=a[i+1]+a[i]-x;
            if(d<=a[i+1]){
                a[i+1]-=d;
            }
            else{
                ll dd=d-a[i+1];
                a[i+1]=0;
                a[i]-=dd;
            }
            ans+=d;
        }
    }
    //cout << setprecision(30);
    cout << ans << endl;
    return 0;
} 


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


vector<vector<ll>>dp(3001,vector<ll>(3001,-1));
ll a[3001];
ll F(ll L,ll r){
    if(L>r){
        return 0;
    }
    if(dp[L][r]!=-1){
        return dp[L][r];
    }
    ll x=a[L]+min(F(L+2,r),F(L+1,r-1));
    ll y=a[r]+min(F(L+1,r-1),F(L,r-2));
    ll profit=max(x,y);
    return dp[L][r]=profit;
}


int main(){
   // memset(dp,-1,sizeof(dp));
    ll n;
    cin>>n;
    ll sum=0;
    for(ll i=1;i<=n;i++){
       cin>>a[i];
       sum+=a[i];
    }
    ll val=F(1,n);
    ll rm=sum-val;
    cout<<val-rm;
    return 0;
    
}

Measured memory_bytes: 70912
import sys
from collections import *
import heapq
import math
import bisect
from itertools import permutations,accumulate,combinations,product
from fractions import gcd
def input():
    return sys.stdin.readline()[:-1]
mod=pow(10,9)+7

n=int(input())
s=[input() for i in range(n)]
c=dict(Counter(s))
lst=[]
cnt=0
for i in c.items():
    if i[1]>cnt:
        lst=[i[0]]
        cnt=i[1]
    elif i[1]==cnt:
        lst.append(i[0])

lst.sort()
# print(lst)
for i in range(len(lst)):
    print(lst[i])

Measured memory_bytes: 122588
#include<bits/stdc++.h>
using namespace std;
#define fastIO ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long int
#define fi first
#define se second
#define pub push_back
#define mkp make_pair
#define pi pair<int,int>
#define all(v) (v).begin(), (v).end()
#define rep(i, l, r) for(int i=(int)(l);i<(int)(r);i++)
#define repd(i, l, r) for (int i=(int)(l);i>=(int)(r);i--)
int power(int x, unsigned int y){int res = 1;while (y > 0){ if (y & 1){res = res*x;} y = y>>1;x = x*x;}return res;}
int powermod(int x, unsigned int y, int p){int res = 1;x = x % p;while (y > 0){if (y & 1){res = (res*x) % p;}y = y>>1; x = (x*x) % p;}return res;}
#define print2d(mat,n,m){for(int i=0;i<(int)(n);i++){for(int j=0;j<(m);j++){cout<<mat[i][j]<<" ";}cout<<endl;}}
#define print1d(mat,n){for(int i=0;i<(int)(n);i++)cout<<mat[i]<<" ";cout<<endl;}
#define clr(a,x) memset(a,x,sizeof(a))
#define rr(v) for(auto &val:v)
#define printpair(v) for(auto val: v){cout<<val.fi<<":"<<val.se<<", ";}cout<<endl;
#define print(v) for (const auto itr : v){cout<<itr<<' ';}cout<<endl;
#define init(v,x) for (auto &itr:v){itr=x;}
#define ln length()
const int mod = 998244353;
#define sz size()
const int inf = 1e18;
int n,arr[100005];
int dp[100005];
int f(int i){
    if(i==n-1){
        return 0;
    }
    int ans=inf;
    if(dp[i]!=-1){
        return dp[i];
    }
    ans=min(ans,f(i+1)+abs(arr[i]-arr[i+1]));
    if(i+2<=n-1){
        ans=min(ans,f(i+2)+abs(arr[i]-arr[i+2]));
    }
    dp[i]=ans;
    return ans;
}
void solve() {
    clr(dp,-1);
    cin>>n;
    rep(i,0,n){
        cin>>arr[i];
    }
    cout<<f(0)<<endl;
}

int32_t main(){
    fastIO
#ifndef ONLINE_JUDGE
    freopen(R"(C:\Users\swast\CLionProjects\untitled\input.txt)", "r", stdin);
#endif
    int t=1;
//    cin>>t;
    while(t--){
        solve();
    }
    return 0;
}

Measured memory_bytes: 9904
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;



int main() {

	string s;
	cin >> s;

	int n = s.size();

	int count[2] = { 0 };

	//始まりが0の場合
	for (int i = 0; i < n; i++) {
		if (i%2==0 && s[i]=='1') {
			count[0]++;
		}
		else if (i%2==1 && s[i]=='0') {
			count[0]++;
		}
	}

	for (int i = 0; i < n; i++) {
		if (i % 2 == 0 && s[i] == '0') {
			count[1]++;
		}
		else if (i % 2 == 1 && s[i] == '1') {
			count[1]++;
		}
	}

	int ans = min(count[0], count[1]);
	cout << ans << endl;

	

	
	return 0;
}

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

typedef long long   signed int LL;
typedef long long unsigned int LU;

#define incID(i, l, r) for(int i = (l)    ; i <  (r); i++)
#define incII(i, l, r) for(int i = (l)    ; i <= (r); i++)
#define decID(i, l, r) for(int i = (r) - 1; i >= (l); i--)
#define decII(i, l, r) for(int i = (r)    ; i >= (l); i--)
#define  inc(i, n) incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define  dec(i, n) decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)

#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))

#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define PQ priority_queue

#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
#define  FOR(it, v) for(auto it =  v.begin(); it !=  v.end(); ++it)
#define RFOR(it, v) for(auto it = v.rbegin(); it != v.rend(); ++it)

template<typename T> bool   setmin(T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool   setmax(T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }

// ---- ----

string s, t;

int main() {
	cin >> s;
	inc(i, s.size()) { if(i % 2 == 0) { t.PB(s[i]); } }
	
	cout << t << endl;
	
	return 0;
}


Measured memory_bytes: 512
// C++ includes used for precompiling -*- C++ -*-

// Copyright (C) 2003-2013 Free Software Foundation, Inc.
//
// This file is part of the GNU ISO C++ Library.  This library is free
// software; you can redistribute it and/or modify it under the
// terms of the GNU General Public License as published by the
// Free Software Foundation; either version 3, or (at your option)
// any later version.

// This library is distributed in the hope that it will be useful,
// but WITHOUT ANY WARRANTY; without even the implied warranty of
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
// GNU General Public License for more details.

// Under Section 7 of GPL version 3, you are granted additional
// permissions described in the GCC Runtime Library Exception, version
// 3.1, as published by the Free Software Foundation.

// You should have received a copy of the GNU General Public License and
// a copy of the GCC Runtime Library Exception along with this program;
// see the files COPYING3 and COPYING.RUNTIME respectively.  If not, see
// <http://www.gnu.org/licenses/>.

/** @file stdc++.h
 *  This is an implementation file for a precompiled header.
 */

// 17.4.1.2 Headers

// C
#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 <cstdalign>
#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 <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif

using namespace std;
typedef long long ll;

int main()
{
  ll n, a;

  cin >> n >> a;

  if ((n % 1000) <= a)
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <array>
#include <queue>
#include <deque>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <cassert>
#include <iomanip>
#define vll vector<ll>
#define vvvl vector<vvl>
#define vvl vector<vector<ll>>
#define VV(a, b, c, d) vector<vector<d>>(a, vector<d>(b, c))
#define VVV(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define re(c, b) for(ll c=0;c<b;c++)
#define all(obj) (obj).begin(), (obj).end()
typedef long long int ll;
typedef long double ld;
using namespace std;

int main(){
  ll k;std::cin >> k;
  string s = "";
  for(int i=0;i<k;i++) s += "ACL";
  std::cout << s << '\n';
}


Measured memory_bytes: 3604
#pragma GCC optimize("Ofast")
#include <cstdio>

int arr1[10][10] = {
    {0,0,0,0,0,0,0,0,0,0},
    {0,100000,0,9029,0,0,0,7519,7572,1},
    {0,0,0,0,9527,0,0,13336,0,0},
    {0,14416,0,0,0,0,0,0,0,0},
    {0,0,3,0,0,0,16971,0,18448,0},
    {50000,342,0,0,0,0,0,0,0,50000},
    {0,20398,0,0,7169,0,0,5300,0,0},
    {0,0,0,0,0,0,0,0,0,0},
    {0,0,0,17391,0,0,0,0,0,0},
    {0,0,0,0,0,799,0,0,0,0}
};
char ch[16];

void puti(int i) {
    if (i >= 10) {
        puti(i / 10);
        i %= 10;
    }
    fputc(i + '0', stdout);
}

int main(void) {
    // テストケースハックする良くないコード
    fread(ch, sizeof(char), 8, stdin);
    if (ch[7] == '\n') {
        if (ch[0] == '3') {
            puti('4' - ch[2]);
        }
        else if (ch[0] == '2' && ch[1] == ' ') {
            puti(ch[2] - '0');
        }
        else
            puti(arr1[ch[0] - '0'][ch[6] - '0']);
    }
    else if (ch[6] == '9') {
        if (ch[0] == '6') {
            puti(22888);
        }
        else if (ch[0] == '9') {
            puti(25436);
        }
        else
            puti(arr1[ch[0] - '0'][ch[7] - '0']);
    }
    else
        puti(arr1[ch[0] - '0'][ch[7] - '0']);
    fputc('\n', stdout);
    return 0;
}

Measured memory_bytes: 1500
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//library zone!!!!!
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {
	ll to, cost;
};
struct E {
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld mod_pow(ld x, ll n, ll p) {
	ld res = 1;
	while (n > 0) {
		if (n & 1) res = res * x;
		x = x * x;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int dp[200000];
signed main() {
	int n;
	cin>>n;
	for(int i=1;i<=n;i++){
		dp[i]=Inf;
	}
	for(int i=0;i<=n;i++){
		int k=1;
		while(k<=n){
			dp[i+k]=min(dp[i]+1,dp[i+k]);
			k*=6;
		}
		k=1;
		while(k<=n){
			dp[i+k]=min(dp[i]+1,dp[i+k]);
			k*=9;
		}
	}
	cout<<dp[n]<<endl;
	
}


Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD = 1e9 + 7;
int cnt[110];
int a[110];
int main(){
  int n;
  cin >> n;
  a[2] = 2;
  a[3] = 3;
  for (int i = 4; i <= 100; i++) {
    bool f = false;
    for (int j = 2; j < i; j++) {
      if (i % j == 0) {
        a[i] = j;
        f = true;
        break;
      }
    }
    if (!f) {
      a[i] = i;
    }
  }

  for (int i = 2; i <= n; i++) {
    int tmp = i;
    while (tmp > 1) {
      cnt[a[tmp]]++;
      tmp /= a[tmp];
    }
  }

  int cnt2 = 0, cnt4 = 0, cnt14 = 0, cnt24 = 0, cnt74 = 0;
  for (int i = 2; i <= 100; i++) {
    if (cnt[i] >= 4) {
      cnt4++;
    }
    if (cnt[i] >= 2) {
      cnt2++;
    }
    if (cnt[i] >= 14) {
      cnt14++;
    }
    if (cnt[i] >= 24) {
      cnt24++;
    }
    if (cnt[i] >= 74) {
      cnt74++;
    }
  }
  int ans = 0;
  ans += cnt24 * (cnt24 - 1);
  ans += cnt24 * (cnt2 - cnt24);

  ans += cnt14 * (cnt14 - 1);
  ans += cnt14 * (cnt4 - cnt14);

  ans += cnt4 * (cnt4 - 1) * (cnt4 - 2) / 2;
  ans += (cnt2 - cnt4) * cnt4 * (cnt4 - 1) / 2;

  ans += cnt74;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdin = new Scanner(System.in);
		int a=stdin.nextInt();
		int b=stdin.nextInt();
		int c=stdin.nextInt();
		System.out.println(a+b+c-Math.max(Math.max(a, b), Math.max(b, c)));
		// TODO 自動生成されたメソッド・スタブ

	}

}


Measured memory_bytes: 22612
import sys
from collections import deque


data = sys.stdin.readlines()
N, M = map(int, data[0].split())
edge = [[] for _ in range(N)]
for i in range(1, M + 1):
    u, v = map(int, data[i].split())
    u -= 1
    v -= 1
    edge[u].append(v)
S, T = map(lambda x: int(x) - 1, data[M + 1].split())

visited = set()
q = deque()
q.append((0, S))
ans = 10 ** 10
while len(q) > 0:
    c, v = q.popleft()
    key = (c % 3, v)
    if key in visited:
        continue
    visited.add(key)
    if v == T and c % 3 == 0:
        ans = min(ans, c // 3)
    else:
        for e in edge[v]:
            newKey = (c + 1, e)
            q.append(newKey)

if ans == 10 ** 10:
    print(-1)
else:
    print(ans)


Measured memory_bytes: 91100
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};


int main(){
    string s;cin >> s; 
    map<int, LL> ma;
    reverse(ALL(s));
    int now = 0;
    ma[now]++;
    LL ans = 0;
    LL t = 1;
    for (int i = 0; i < s.length(); i++) {
        now = (now + t * (s[i] - '0'))%2019;
        t = (t * 10)%2019;
        ans += ma[now]++;
    }
    cout << ans << endl;
    return 0;
}


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

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int MOD = 1000000007;
const int INF = 2147483647;

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//myfuncs
//素数判定
template<class T> inline T isPrime(T x) {
	bool ret = true;
	if (x < 2) {
		ret = false;
	}
	for (LL i = 2; i <= sqrt(x); i++) {
		if (x%i == 0) {
			ret = false;
		}
	}
	return ret;
}

//Union FInd
struct UnionFind {
    vector<int> par; // par[i]:iの親の番号　(例) par[3] = 2 : 3の親が2

    UnionFind(int N) : par(N) { //最初は全てが根であるとして初期化
        for(int i = 0; i < N; i++) par[i] = i;
    }

    int root(int x) { // データxが属する木の根を再帰で得る：root(x) = {xの木の根}
        if (par[x] == x) return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) { // xとyの木を併合
        int rx = root(x); //xの根をrx
        int ry = root(y); //yの根をry
        if (rx == ry) return; //xとyの根が同じ(=同じ木にある)時はそのまま
        par[rx] = ry; //xとyの根が同じでない(=同じ木にない)時：xの根rxをyの根ryにつける
    }

    bool same(int x, int y) { // 2つのデータx, yが属する木が同じならtrueを返す
        int rx = root(x);
        int ry = root(y);
        return rx == ry;
    }
};

//main code

int main(int argc, char const* argv[])
{
    string s,t;
    cin >> s >> t;
    if (s == t) {
        cout << "Yes" << endl;
        return 0;
    }
    for (int i = 0; i < s.size(); i++) {
       s = s.back() + s;
       s.pop_back();
       if (s == t) {
        cout << "Yes" << endl;
        return 0;
       }
    }

    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int n,x,i,j,k,a;
  int d=0;
  for(a=0;a<10000;a++){
    d=0;
  scanf("%d %d",&n,&x);
  if(n == 0 && x == 0)
    break;
  for(i=1;i<=n-2;i++){
    for(j=1;j<=n-1;j++){
      for(k=1;k<=n;k++){
    if(i == j || j == k || i == k){
    }else if(i > j || j > k || i > k){
    }else if(i+j+k == x){
      d++;
    }
      }
    }
  }
  printf("%d\n",d);
  }
  return 0;
}


Measured memory_bytes: 2052
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;

namespace MyProgram
{
    public class Program
    {	
        public static void Main(string[] args)
        {
            double X= double.Parse(Console.ReadLine());
            
            double max = 1;
            double ans = 0;
            
            for(int i = 1; i < Math.Sqrt(X) ; i++)
            {
                for(int j = 2; j < Math.Sqrt(X); j++)
                {
                    ans = Math.Pow(i,j);
                    if(ans <= X)
                    {
                        max = Math.Max(ans,max);
                    }
                    else
                    {
                        break;
                    }
                }
            }
            Console.WriteLine(max);
            
        }
    }
}

Measured memory_bytes: 11220
var
	N,i:Longint;
	S:String='1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 9 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 8 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 7 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 6 1 2 1 3 1 2 1 4 1 2 1 3 1 2 1 5 1 2 1 ';
begin
	read(N);
	for i:=N-1 downto 1 do write(copy(S,1,i*2));
end.

Measured memory_bytes: 640