akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
//const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

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 {
    mint res(*this);
    return res+=a;
  }
  mint operator-(const mint a) const {
    mint res(*this);
    return res-=a;
  }
  mint operator*(const mint a) const {
    mint res(*this);
    return res*=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 {
    mint res(*this);
    return res/=a;
  }
};

mint f(int n) {
  if (n == 0) return 1;
  mint x = f(n/2);
  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 *= i+1;
  }
  return x / y;
}


int main() {
    int a; cin >> a;
    string s; cin >> s;
    if (a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

Measured memory_bytes: 256
"かけざん"
"最大のものを取得して、一桁になるまでに操作を行う回数を答える"


def kakezan(n):
    ret = 0
    str_n = str(n)
    digit_amount = len(str_n)
    for i in range(digit_amount-1):
        # print(str_n[:i+1])
        # print(str_n[i+1:])
        # print("")
        ret = max(ret, int(str_n[:i+1])*int(str_n[i+1:]))

    return ret


Q = int(input())  # 入力される整数の個数
N = [int(input()) for i in range(Q)]

for n in N:
    cnt = 0
    while n >= 10:
        n = kakezan((n))
        cnt += 1
    print(cnt)



Measured memory_bytes: 5620
N, K = map(int, input().split())
H = [0] + list(map(int, input().split()))
dp = [[10 ** 100] * (N-K+1) for _ in range(N+1)]
dp[0][0] = 0
for x in range(1, N+1):
    for y in range(1, min(x+1, N-K+1)):
        dp[x][y] = min([dp[i][y-1] + max(H[x] - H[i], 0) for i in range(x)])
print(min([dp[i][N-K] for i in range(N+1)]))

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

int main() {
  int n, t;
  cin >> n >> t;
  vector<pair<int,int> > v(n);
  for (int i=0; i<n; i++) cin >> v[i].first >> v[i].second;
  sort(v.begin(), v.end());

  vector<int> dp(t+1, 0);
  for (int i=0; i<n; i++) {
    for (int j=t-1; j>=0; j--) {
      int k = min(t, j + v[i].first);
      dp[k] = max(dp[k], dp[j] + v[i].second);
    }
  }
  cout << dp[t] << endl;

  return 0;
}


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

namespace ConsoleApp1
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            int[] array = Console.ReadLine().Split(' ').Select(i => int.Parse(i)).ToArray();
            HashSet<int> hsTable = new HashSet<int>();
            string message = "YES";

            foreach (int i in array)
            {
                if (!hsTable.Add(i))
                {
                    message = "NO";
                }
            }
            Console.WriteLine(message);
        }
    }
}

//24579 =  hon
//0168 = pon
//3 = bon
//long n = long.Parse(Console.ReadLine());
//long[] inputLongArray = Console.ReadLine().Split(' ').Select(i => long.Parse(i)).ToArray();

//Console.WriteLine(cnt);
//Console.ReadKey();


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

using namespace std;

typedef long long ll;

int main(int argc, char *argv[])
{
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);

  int n; cin >> n;
  vector<pair<int,int>> p;
  for (int i = 0; i < n; ++i) {
    int x, y; cin >> x >> y;
    p.emplace_back(x,y);
  }

  sort(p.begin(), p.end());

  int f, s, ff, ss;
  if (n % 2 == 0) {
    f = p[n/2-1].first, ff = p[n/2].first;
  }
  else {
    f = p[n/2].first;
  }

  for (int i = 0; i < n; ++i) {
    p[i] = make_pair(p[i].second, p[i].first);
  }

  sort(p.rbegin(), p.rend());

  if (n % 2 == 0) {
    s = p[n/2].first, ss = p[n/2-1].first;
    int l = (f+ff+1)/2, h = (s+ss)/2;
    cout << (h-l+1)+(h-l)+(f % 2 != ff % 2 ? 1 : 0)+(s % 2 != ss % 2 ? 1 : 0) << endl;
  }
  else {
    s = p[n/2].first;
    cout << (s-f+1) << endl;
  }

  
  return 0;
}




Measured memory_bytes: 5288
package main

import "fmt"

func main() {
	var a, b, c int
	fmt.Scan(&a, &b, &c)

	ans := make(map[int]int, 3)
	ans[a] = 1
	ans[b] = 1
	ans[c] = 1

	if len(ans) == 1 || len(ans) == 3 {
		fmt.Println("No")
		return
	}
	fmt.Println("Yes")

}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef double db;
typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pa;
typedef unsigned int uint;
typedef unsigned long long ull;
#define w1 first
#define ls (x<<1)
#define w2 second
#define ins insert
#define rs (x<<1|1) 
#define mp make_pair
#define pb push_back
#define mid ((l+r)>>1)
#define sqr(x) ((x)*(x))
#define cle(x) ((x).clear())
#define lowbit(x) ((x)&(-x))
#define SZ(x) (int((x).size()))
#define All(x) (x).begin(),(x).end()
#define ms(x,y) memset(x,y,sizeof (x))
#define rep(i,a,b) for(int (i)=(a);(i)<=(b);(i)++)
#define rep2(i,a,b) for(int (i)=(a);(i)<(b);(i)++)			
#define per(i,a,b) for(int (i)=(a);(i)>=(b);(i)--)
#define Rep(p,x) for(int (p)=head[(x)];(p);(p)=nxt[(p)]) 
#define Rep2(p,x) for(int (p)=cur[(x)];(p);(p)=nxt[(p)])
template<class T>inline void read(T&num){
	num=0;T f=1;char ch=getchar();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
	while(ch>='0'&&ch<='9')num=num*10+ch-'0',ch=getchar();
	num*=f;
}	
inline int getgcd(int x,int y){if(!x)return y;return getgcd(y%x,x);}
inline int power(int x,int k,int p){int res=1;for(;k;k>>=1,x=(ll)x*x%p)if(k&1)res=(ll)res*x%p;return res;}
const double pi=acos(-1);	
inline void judge(){
	freopen("input.txt","r",stdin);
} 
//********************************head*************************************
int main(){
	int n,k;cin>>n>>k;
	if(k<=(n+1)/2)puts("YES");
	else puts("NO");
	return 0;
}

Measured memory_bytes: 256
fn main() {
    proconio::input! {
        d: usize,
        c: [i64; 26],
        s: [[i64; 26]; d],
    }

    let mut last_d = vec![0; 26];
    let mut prev = 0;
    for di in 0..d {
        let mut max_v = 0;
        let mut max_i = 0;
        for i in 0..26 {
            let pre_last_di = last_d[i];
            last_d[i] = di + 1;
            let v = sum_di(di, prev, &c, &s, i, &last_d);
            last_d[i] = pre_last_di;
            if v > max_v {
                max_v = v;
                max_i = i;
            }
        }
        prev = max_v;
        last_d[max_i] = di + 1;
        println!("{}", max_i + 1);
    }
}

fn sum_di(di: usize,
    prev: i64,
    c: &Vec<i64>,
    s: &Vec<Vec<i64>>,
    t: usize,
    last_d: &Vec<usize>,
) -> i64 {
    let mut v = prev + s[di][t];
    for i in 0..26 {
        v -= c[i] * ((di + 1 - last_d[i]) as i64);
    }
    v
}


Measured memory_bytes: 2332
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    scanf("%d", &n);
    int arr[n];
    int arr1[1000001];
    int arr2[1000001];
    memset(arr1,0,sizeof(arr1));
    memset(arr2,0,sizeof(arr2));
    for (int i = 0; i < n; i++)
    {
        scanf("%d", &arr[i]);
        arr2[arr[i]]++;
    }
    sort(arr,arr+n);
    for (int i = 0; i < n; i++)
    {

        if(arr1[arr[i]]==0){

            for (int j = arr[i]+arr[i]; j <= arr[n-1]; j=j+arr[i])
            {
                arr1[j] = 1;

            }           
        }
    }
    int cnt = 0;
    
    for (int i = 0 ; i < n; i++)
    {
        if(arr1[arr[i]]==0 && arr2[arr[i]]==1){
            cnt++;
        }
    }
    printf("%d\n",cnt);
    
    
}

Measured memory_bytes: 12312
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;
using vvint = vector<vint>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vchar = vector<char>;
using vvchar = vector<vchar>;
using vp = vector<P>;
using vpp = vector<pair<P, P>>;
using vvp = vector<vp>;

#define rep(i, n) for (int i = 0; i < n; ++i)
#pragma region Debug
istream &operator>>(istream &is, P &a)
{
    return is >> a.first >> a.second;
}
ostream &operator<<(ostream &os, const P &a) { return os << "(" << a.first << "," << a.second << ")"; }

template <typename T>
void view(const std::vector<T> &v)
{
    for (const auto &e : v)
    {
        std::cout << e << " ";
    }
    std::cout << std::endl;
}
template <typename T>
void view(const std::vector<std::vector<T>> &vv)
{
    for (const auto &v : vv)
    {
        view(v);
    }
}
#pragma endregion

int main()
{
    int n;
    string s;
    cin >> n >> s;

    vvint rgb(3, vint());
    rep(i, n)
    {
        switch (s[i])
        {
        case 'R':
            rgb[0].emplace_back(i);
            break;
        case 'G':
            rgb[1].emplace_back(i);
            break;
        case 'B':
            rgb[2].emplace_back(i);
            break;
        }
    }

    ll ans = 0;
    for (int r : rgb[0])
    {
        for (int g : rgb[1])
        {

            ans += rgb[2].size();

            if (r > g)
            {
                int ku = r + (r - g);
                int kd = g - (r - g);

                if (ku < n && s[ku] == 'B')
                    ans--;
                if (kd >= 0 && s[kd] == 'B')
                    ans--;
            }
            else
            {
                int ku = g + (g - r);
                int kd = r - (g - r);
                if (ku < n && s[ku] == 'B')
                    ans--;
                if (kd >= 0 && s[kd] == 'B')
                    ans--;
            }
            if ((r + g) % 2)
                continue;
            int km = (r + g) / 2;
            if (s[km] == 'B')
                ans--;
        }
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3648
import sys
import collections

sys.setrecursionlimit(10 ** 8)

input = sys.stdin.readline


def main():
    H, W, M = [int(x) for x in input().split()]
    HW = [[int(x) for x in input().split()] for _ in range(M)]

    x = set()

    hc = collections.Counter()
    wc = collections.Counter()

    for h, w in HW:
        hc[h] += 1
        wc[w] += 1
        x.add((h, w))

    ans = 0
    hcma = hc.most_common()[0][1]
    wcma = wc.most_common()[0][1]
    f = False
    bost_common = wc.most_common()
    for a in hc.most_common():
        if a[1] != hcma:
            break
        for b in bost_common:
            if b[1] != wcma:
                break
            if (a[0], b[0]) in x:
                ans = max(ans, hcma + wcma - 1)
            else:
                ans = max(ans, hcma + wcma)
                f = True
                break
        if f:
            break

    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 237372
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <vector>

using namespace std;

#define l first
#define r second
#define int long long

int n, m, k;
string s[5000];
int re[5000][5000];
int cx[4] = {0, -1, 0, 1};
int cy[4] = {1, 0, -1, 0};

bool ok(int a, int b)
{
    return (0 <= a && a < n && 0 <= b && b < m);
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cin >> n >> m >> k;
    for (int i = 0; i < n; i++) cin >> s[i];
    int dx, dy;
    for (int i = 0; i < n; i++) for (int j = 0; j < m; j++) if (s[i][j] == 'S')
        dx = i, dy = j;
    vector<pair<int, int> > c = {{dx, dy}}; re[dx][dy] = 1;
    for (int i = 0; i < c.size(); i++)
    {
        for (int j = 0; j < 4; j++)
        {
            int nx = c[i].first + cx[j], ny = c[i].second + cy[j];
            if (ok(nx, ny) && re[nx][ny] == 0 && s[nx][ny] != '#')
            {
                re[nx][ny] = re[c[i].first][c[i].second] + 1;
                if (re[nx][ny] <= k + 1) 
                {
                    c.push_back({nx, ny});
                    if (nx == 0 || nx == n - 1 || ny == 0 || ny == m - 1) {cout << 1; return 0;}
                }
            }
        }
    }
    int ans = 4005;
    for (int i = 0; i < c.size(); i++)
    {
        int len = min(min(c[i].first, c[i].second), min(n - 1 - c[i].first, m - 1 - c[i].second));
        ans = min(ans, (len + k - 1) / k);
    }
    cout << ans + 1;
}

Measured memory_bytes: 16512
#include<bits/stdc++.h>
constexpr long long INFL = 1LL << 60;
constexpr int INF = 1 << 30;

using namespace std;

using ll = long long;
using P = tuple<int, int>;
using iarr = valarray<int>;

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

    vector<string> v{"SS","SW","WS","WW"};
    for(int i = 1; i < N; ++i){
        for(int j = 0; j < 4; ++j){
            if(s[i] == 'o'){
                if(v[j][i] == 'S') v[j] += v[j][i-1];
                else{
                    if(v[j][i-1] == 'S') v[j] += 'W';
                    else v[j] += 'S';
                }
            }else{
                if(v[j][i] != 'S') v[j] += v[j][i-1];
                else{
                    if(v[j][i-1] == 'S') v[j] += 'W';
                    else v[j] += 'S';
                }
            }
        }
    }

    for(int i = 0; i < 4; ++i){
        if(v[i].front() == v[i].back()){
            v[i].pop_back();
            if(v[i].front() == 'S'){
                if(s[0] == 'o'){
                    if(v[i][1] == v[i].back()){
                        cout << v[i] << endl;
                        return 0;
                    }
                }else{
                    if(v[i][1] != v[i].back()){
                        cout << v[i] << endl;
                        return 0;
                    }
                }
            }else{
                if(s[0] == 'o'){
                    if(v[i][1] != v[i].back()){
                        cout << v[i] << endl;
                        return 0;
                    }
                }else{
                    if(v[i][1] == v[i].back()){
                        cout << v[i] << endl;
                        return 0;
                    }
                }
            }
        }
    }
    cout << -1 << endl;

    return 0;
}

Measured memory_bytes: 1152
import sys
input = lambda : sys.stdin.readline().rstrip()
mod = 10**9 + 7

def make_tables(n, mod = 10 ** 9 + 7):
    fac = [1, 1] # 階乗テーブル
    finv = [1, 1] #逆元の階乗テーブル
    inv = [0, 1] #逆元テーブル

    for i in range(2, n + 1):
        fac.append((fac[-1] * i) % mod)
        inv.append((mod -inv[mod % i] * (mod // i)) % mod)
        finv.append((finv[-1] * inv[-1]) % mod)
    return fac, finv

def nCk(n, k, mod = 10 ** 9 + 7):
    k = min(k, n-k)
    return fac[n] * finv[k] * finv[n-k] % mod

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

n, m, k = map(int, input().split())

fac, finv = make_tables(n*m - 2)

ans = 0

for i in range(1, m):
    ans += i*n*n*(m - i)*nCk(n*m - 2, k - 2)
    ans %= mod
for j in range(1, n):
    ans += j*m*m*(n - j)*nCk(n*m - 2, k - 2)
    ans %= mod

print(ans)







Measured memory_bytes: 26908
#include <bits/stdc++.h>
#define ll long long
#define PB push_back
#define MP make_pair

#define REP(i, n) for(int i=0;i<(int)(n);++i)
#define FOR(i,l,h) for(int i=(int)(l);i<=(int)(h);++i)
#define FORD(i,h,l) for(int i=(int)(h);i>=(int)(l);--i)

#define max(a,b) a>b?a:b
#define min(a,b) a>b?b:a

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

#define dump(x)  cerr << #x << " = " << (x) << endl
#define ALL(t) (t).begin(),(t).end()

using namespace std;


int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;cin>>a>>b;
    /*bool arr[3];
    memset(arr , false, sizeof(arr));
    arr[a] = true;
    arr[b] = true;
    for (int i = 1; i <=3; i++) {
        if(arr[i]==false){
            cout<<i;
            return 0;
        }
    }
    */

    if((a==1 && b==2) || (a==2 && b==1)){
        cout<<3;
    }
    else if((a==2 && b == 3) || (a==3 && b==2) ){
        cout<<1;
    }
    else if((a==3 && b == 1) || (a==1 && b==3) ){
        cout<<2;
    }
    return 0;
}


Measured memory_bytes: 256
n=0
W=0
n,W=map(int,input().split())
dp=[W+1]*101010
dp[0]=0
for i in range(n):
    w,v=map(int,input().split())
    j=100000
    while j>=0:
        if dp[j+v]>dp[j]+w:
            dp[j+v]=dp[j]+w
        j-=1
ans=0
for v in range(len(dp)):
    if dp[v]<=W:
        ans=v
print(ans)

Measured memory_bytes: 41452
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;
using PL = pair<long long, long long>;
const int INF = 1001001007;

int main(){
    int a, b; cin >> a >> b;
    //if (b == 1) cout << 0 << endl;
    int ans = 0;
    int k = 1;
    while (k < b){
        ans++;
        k = k - 1 + a;
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
public static void main(String[] args) {
		
		Scanner keyboard = new Scanner(System.in); 
		
		int X  = keyboard.nextInt();
		int Y  = keyboard.nextInt();

		int turu = 2;
		int kame = 4;
		
		String ans = "No";
		
		for(int i=0; i<X+1; i++) {
			if(i*turu + (X-i)*kame == Y) {
				ans = "Yes";
			}
		}
		
		System.out.println(ans);
		keyboard.close();	
	}
}


Measured memory_bytes: 35688
#include  <bits/stdc++.h>
using namespace std;
#define    error(args...){string _s=#args;replace(_s.begin(), _s.end(), ',', ' ');stringstream _ss(_s);istream_iterator<string> _it(_ss);err(_it,args);}
void err  (istream_iterator<string> it) {}
template  <typename T, typename... Args>
void err  (istream_iterator<string> it, T a, Args... args)
{
    cerr << *it << " = " << a <<" ; ";
    err(++it, args...);
    cout << endl;
}
/*----------------------------------------------------------------------------------------------------------------------------------------------------*/
/*Let's start.............*/
#define   ll                long long
#define   pb                push_back
#define   ff                first
#define   ss                second
#define   srt(v)            sort(v.begin(),v.end())
#define   inf               2000000000000000000
#define   mxn               40000
#define   MOD               1000000007
#define   pi                acos(-1)
#define X first
#define Y second

int main()
{
    ll n;
    cin >> n;
    ll a,b;
    cin >> a >> b;
    ll keep = (a/n);
    ll peek = (keep+1)*n;
    keep = (keep*n);
    //error(keep,peek);
    if(keep >= a && keep <= b) cout << "OK" << endl;
    else if(peek >= a && peek <= b) cout << "OK" << endl;
    else cout <<"NG" << endl;
}

/*-------------------------------------------------------------------------------------------------------------------------------------------------------
".....but the truth is that you can increase it slightly."
Day 35.
*/


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

int main(){
    int h,w;cin>>h>>w;
    vector<vector<char>> s(h+2,vector<char>(w+2,'#'));
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            cin>>s[i][j];
        }
    }
    int ans=0;
    vector<int> dy={1,0,-1,0};
    vector<int> dx={0,1,0,-1};
    for(int i=1;i<=h;i++){
        for(int j=1;j<=w;j++){
            if(s[i][j]=='#'){
                continue;
            }
            int ans_i=0;
            vector<vector<int>> v(h+2,vector<int>(w+2,-1));
            v[i][j]=0;
            queue<pair<int,int>> q;
            q.push(make_pair(i,j));
            while(!q.empty()){
                int a,b;
                tie(a,b) = q.front();
                q.pop();
                for(int f=0;f<4;f++){
                    int ny = a+dy[f];
                    int nx = b+dx[f];
                    if(s[ny][nx]!='#'&v[ny][nx]==-1){
                        v[ny][nx]=v[a][b]+1;
                        ans_i = max(ans_i,v[ny][nx]);
                        q.push(make_pair(ny,nx));
                    }
                }
            }
            ans = max(ans,ans_i);
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
//  Created by conan1024hao in 2019.
//  Copyright © 2019 conan1024hao. All rights reserved.
//  専用ライブラリです、自由にコピーして構いません。
//  感谢看我的代码！Wechat:conan1024hao QQ:810396815
#pragma GCC optimize ("O3")
#include <iostream>
#include <iomanip>
#include <istream>
#include <ostream>
#include <sstream>
#include <iterator>
#include <vector>
#include <algorithm>
#include <queue>
#include <deque>
#include <list>
#include <stack>
#include <map>
#include <set>
#include <utility>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <string>
#include <ctime>
#include <cctype>
#include <cstdlib>
#define INF 10e16
#define MOD 1000000007
#define  mod 998244353
#define rep(i, a, n) for (ll i = a; i < (ll)(n); i++)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define mmax(x,y)(x>y?x:y)
#define mmin(x,y)(x<y?x:y)
#define chmax(x,y) x=mmax(x,y)
#define chmin(x,y) x=mmin(x,y)
#define all(x) (x).begin(),(x).end()
#define siz(x) (ll)(x).size()
#define PI acos(-1.0)
using namespace std;
//using Int=int_fast64_t;
typedef long long int ll;
typedef pair<ll,ll>Pll;
typedef pair<int,int>Pin;
long long GCD(long long a, long long b) { return b ? GCD(b, a%b) : a; }
long long LCM(long long a, long long b)  {return a/GCD(a,b)*b;}
int dx[8]={-1,0,1,0};
int dy[8]={0,-1,0,1};
char dir[4]={'u','l','d','r'};
ll cmp1(pair<ll,string>a,pair<ll,string> b){
        if(a.fi!=b.fi)
        return a.fi<b.fi;
        else
        return a.se<b.se;
}
//--------------------------------------------------------------------------

//---------------------------------------------------------------------------
int main(){//問題をちゃんと見ろ!!!!!!!!!!!!!!!!!      llか??????????        memset()!!!!!!!!!!!!       ペナを減らせ!!!!!!!!!!!!!
    cin.tie(0);
    ios::sync_with_stdio(false);
    //-------------------------------
    char x,y;cin>>x>>y;
    if(x<y)
        cout<<'<'<<endl;
    else if(x==y)
        cout<<'='<<endl;
    else
        cout<<'>'<<endl;
    //-------------------------------
    return 0;
}
//---------------------------------------------------------------------------






Measured memory_bytes: 256
import itertools

n, m, q = input().split()
n, m, q = int(n), int(m), int(q)

a, b, c, d = [], [], [], []

for _ in range(q):
    ai, bi, ci, di = input().split()
    a.append(int(ai) - 1)
    b.append(int(bi) - 1)
    c.append(int(ci))
    d.append(int(di))

seqs = itertools.combinations_with_replacement(range(m), n)

ans = 0
for seq in seqs:
    res = 0
    for i in range(q):
        if seq[b[i]] - seq[a[i]] == c[i]:
            res += d[i]
    ans = max(ans, res)
print(ans)


Measured memory_bytes: 68044
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
//#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
// #define mt make_tuple
//typedef tuple<pii,int,int> tp;
//typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
//template<class C>constexpr int size(const C &c){return (int)c.size();}
//template<class T,size_t N> constexpr int size(const T (&xs)[N])noexcept{return (int)N;}
const double PI=acos(-1);
const double EPS=1e-7;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9;
int dx[]={0,1,0,-1};
int dy[]={1,0,-1,0};
int main(){
	string s;
	cin>>s;
	if(s[1]==s[2]&&(s[0]==s[1]||s[2]==s[3]))cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
}


Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String args[]){
		Scanner sc = new Scanner(System.in);
		int[] m = new int[100], f = new int[100], r = new int[100];
		int sum, cnt = 0;
		
		while(true){
			m[cnt] = sc.nextInt();
			f[cnt] = sc.nextInt();
			r[cnt] = sc.nextInt();
			
			if(m[cnt] + f[cnt] + r[cnt] == -3){
				break;
			}
			
			cnt ++;
		}
		
		for(int i = 0; i < cnt; i++){
			if(m[i] < 0 || f[i] < 0){
				System.out.println("F");
			}
			else{
				sum = m[i] + f[i];
				
				if(sum >= 80){
					System.out.println("A");
				}
				else if(65 <= sum && sum < 80){
					System.out.println("B");
				}
				else if(50 <= sum && sum < 65){
					System.out.println("C");
				}
				else if(30 <= sum && sum < 50){
					if(r[i] >= 50){
						System.out.println("C");
					}
					else{
						System.out.println("D");
					}
				}
				else{
					System.out.println("F");
				}
			}
		}
	}
}

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

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

Measured memory_bytes: 4748
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
#define INF = 1000000000;
#define LLINF = 1LL << 62;
#define mod = 1000000007;
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; }

int v[1001];
int main() {
    int a, b, n;
    cin >> a >> b >> n;
    int s, f;
    FOR(i, n){
        cin >> s >> f;
        v[s]++, v[f]--;
    }
    FOR(i, 1000)v[i + 1] += v[i];
    int ans = 0;
    for (int i = a; i < b; i++)if (v[i])ans = 1;
    cout << ans << endl;
}



Measured memory_bytes: 3120
#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>;
#define chmax(x,y) x = max(x,y)
#define chmin(x,y) x = min(x,y)

const int INF = 1e9 + 10;
 
int main() {
    int n, x, t;
    cin >> n >> x >> t;
    cout << (n - 1 + x)/x * t << endl;
    return 0;
}

Measured memory_bytes: 3648
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <algorithm>
#include <set>
#include <map>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#define vll vector<ll>
#define vvv vector<vvl>
#define vvi vector<vector<int> >
#define vvl vector<vector<ll> >
#define vv(a, b, c, d) vector<vector<d> >(a, vector<d>(b, c))
#define vvvl(a, b, c, d) vector<vvl>(a, vvl(b, vll (c, d)));
#define rep(c, a, b) for(ll c=a;c<b;c++)
#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(int argc, char const *argv[]) {
  ll n, k, a;std::cin >> n >> k >> a;
  vvl d = vv(n, 2, 0, ll);
  re(i, n) {
    std::cin >> d[i][0] >> d[i][1];
    d[i][1] = d[i][1]/a + (d[i][1]%a==0?0:1);
  }
  sort(all(d));
  deque<vll> bomb;
  ll s = 0, ans = 0;
  for(int i=0;i<n;i++){
    while(!bomb.empty()&&bomb.front()[0]<=d[i][0]) s-=bomb.front()[1], bomb.pop_front();
    ll need = d[i][1] - s;
    if(need<=0) continue;
    ans += need, s+=need, bomb.push_back(vll{d[i][0]+2*k+1, need});
  }
  std::cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 16640
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		String[] words = new String[N];
		for(int i = 0;i < N;++i)
			words[i] = sc.next();
		sc.close();
		
		boolean flag = true;
		for(int i = 1;i < N;++i) {
			for(int j = 0;j < i;++j) {
				if(words[j].equals(words[i])) {
					flag = false;
					break;
				}
			}
			if(words[i-1].charAt(words[i-1].length()-1) != words[i].charAt(0)) {
				flag = false;
				break;
			}
		}
		
		if(flag)
			System.out.println("Yes");
		else
			System.out.println("No");
	}
}


Measured memory_bytes: 21588
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = s; i < (int)(n); i++)
#define chmax(a, b) a = max(a, b)
#define chmin(a, b) a = min(a, b)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using pii = pair<int, int>;

//const ll INF = 1e18L + 5;
//const int INF = 1e9 + 5;
//const double pi = 3.14159265358979323846;

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

	string s;
	cin >> s;
	rep(i, s.size())
		cout << "x";
	cout << endl;
}


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

#define rep(i, n)      reps (i, 0, n)
#define reps(i, f, n)  for (int i = f; i < int(n); ++i)

struct Node
{
    Node *par, *lch, *rch;
    int val, mini, cnt;
    Node() {
        par = lch = rch = NULL;
        val = mini = 0;
        cnt = 1;
    }
};

typedef pair<Node*, Node*> PPNode;

int getcnt(Node *t) { return t ? t->cnt : 0; }
int getmin(Node *t) { return t ? t->mini : 1 << 29; }

Node* update(Node *t)
{
    t->cnt = getcnt(t->lch) + getcnt(t->rch) + 1;
    t->mini = min(min(getmin(t->lch), getmin(t->rch)), t->val);
    return t;
}

void rotate(Node *t)
{
    Node *p = t->par;
    if (p->lch == t) {
        p->lch = t->rch; t->rch = p;
        if (p->lch) p->lch->par = p;
    } else {
        p->rch = t->lch; t->lch = p;
        if (p->rch) p->rch->par = p;
    }
    t->par = p->par; p->par = t;
    if (t->par) (t->par->lch == p ? t->par->lch : t->par->rch) = t;
    update(p);
}

Node* splay(Node *t) 
{
    while (t->par) {
        Node *p = t->par, *g = p->par;
        if (g) rotate((p->lch == t) == (g->lch == p) ? p : t);
        rotate(t);
    }
    return update(t);
}

Node* find(Node *t, int k)
{
    int c = getcnt(t->lch);
    if (k == c)     return t;
    else if (k < c) return find(t->lch, k);
    else            return find(t->rch, k - c - 1);
}

Node* merge(Node *l, Node *r)
{
    if (!l || !r) return l ? l : r;
    r = splay(find(r, 0));
    l->par = r; r->lch = l;
    return update(r);
}

PPNode split(Node *t, int k)
{
    if (k == t->cnt) return PPNode(t, NULL);
    t = splay(find(t, k));
    Node *s = t->lch;
    if (s) s->par = t->lch = NULL;
    return PPNode(s, update(t));
}

int main()
{
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    
    int n, q, a, x, y, z;
    cin >> n >> q;
    vector<Node> node(n);
    Node *root = NULL;
    rep (i, n) {
        cin >> a;
        node[i].val = node[i].mini = a;
        root = merge(root, &node[i]);
    }
    rep (i, q) {
        cin >> x >> y >> z;
        if (x == 0) {
            PPNode p1 = split(root, y);
            PPNode p2 = split(p1.second, z - y);
            PPNode p3 = split(p2.second, 1);
            root = merge(p1.first, p3.first);
            root = merge(root, p2.first);
            root = merge(root, p3.second);
        } else if (x == 1) {
            PPNode p1 = split(root, y);
            PPNode p2 = split(p1.second, z - y + 1);
            cout << p2.first->mini << endl;
            root = merge(p1.first, p2.first);
            root = merge(root, p2.second);
        } else {
            root = splay(find(root, y));
            root->val = z;
            update(root);
        }
    }
}

Measured memory_bytes: 8984
#include<iostream>
#include<climits>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include<stdio.h>
#include <string>
#include <complex>
#include <functional>
#include <map>
#include <queue>
using namespace std;
using ll = long long;
//typedef pair<string,string> P;
//double dat[100][100];
//int dp[6][1010];//動的計画法
//int prime[100001];
//char str[1010][1010];
//vector<pair<ll,ll>> pc;
//int ABS(int a){return max(a,-a);}
int main(){
    int c[5];
    for(int i=1;i<5;i++) c[i]=0;
    for(int i=0;i<3;i++){
        int a,b;
        cin>>a>>b;
        c[a]++;
        c[b]++;
    }
    int t=0,w=0;
    for(int i=1;i<5;i++){
        if(c[i]==2) t++;
        if(c[i]==1) w++;
    }
    if(t==2&&w==2) cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
using namespace std;
typedef long long ll;
ll dist[5000];
ll ans[5011][5011];
typedef pair<ll, ll>pii;
vector<pii>dat[200];
int main()
{
	int num, kai;
	scanf("%d%d", &num, &kai);
	for (int i = 1; i < num; i++)scanf("%lld", &dist[i]);
	for (int i = 1; i < num; i++)dist[i] += dist[i - 1];
	for (int i = 0; i < num; i++)
	{
		for (int j = 0; j < kai; j++)
		{
			ll z;
			scanf("%lld", &z);
			dat[j].push_back(make_pair(z, i));
		}
	}
	for (int i = 0; i < kai; i++)sort(dat[i].begin(), dat[i].end()), reverse(dat[i].begin(), dat[i].end());
	for (int i = 0; i < kai; i++)
	{
		set<int>se;
		se.insert(-1);
		se.insert(num);
		for (int j = 0; j < num; j++)
		{
			set<int>::iterator it = se.lower_bound(dat[i][j].second);
			int a = *it;
			it--;
			int b = *it;
			int c = dat[i][j].second;
			ll x = dat[i][j].first;
			ans[c + 1][c + 1] += x;
			ans[c + 1][a + 1] -= x;
			ans[b + 1][c + 1] -= x;
			ans[b + 1][a + 1] += x;
			se.insert(c);
		}
	}
	for (int i = num - 1; i >= 0; i--)
	{
		for (int j = 1; j <= num; j++)
		{
			ans[i + 1][j + 1] += ans[i + 2][j + 1] + ans[i + 1][j] - ans[i + 2][j];
		}
	}
	ll maxi = 0;
	for (int i = 0; i < num; i++)
	{
		//printf("%lld\n", dist[i]);
		for (int j = i; j < num; j++)
		{
			maxi = max(maxi, ans[i + 1][j + 1] - dist[j] + dist[i]);
		}
		//for (int j = 0; j < num; j++)printf("%lld ", ans[i][j]); printf("\n");
	}
	printf("%lld\n", maxi);
}

Measured memory_bytes: 217216
import java.util.Scanner;

//Champernowne Constant
public class Main{

	void run(){
		int S = 125000;
		int[] a = new int[S];
		int s = 0;
		for(int i=0;i<S;i++){
			a[i] = s;
			int L = 1000*i, R = L+999;
			if((L+"").length()==(R+"").length())s+=1000*(L+"").length();
			else{
				for(int k=L;k<=R;k++)s+=(k+"").length();
			}
		}
		Scanner sc = new Scanner(System.in);
		for(;;){
			int N = sc.nextInt(), K = sc.nextInt();
			if((N|K)==0)break;
			int id = 0;
			for(int i=0;i+1<S;i++){
				if(a[i]<=N&&N<a[i+1]){
					id = i; break;
				}
			}
			N-=a[id];
			StringBuilder sb = new StringBuilder();
			for(int k=1000*id;sb.length()<=N+K;k++)sb.append(k);
			System.out.println(sb.substring(N, N+K));
		}
	}
	
	public static void main(String[] args) {
		new Main().run();
	}
}

Measured memory_bytes: 13000
def main():
    import sys
    input = sys.stdin.readline

    n, a, b = map(int, input().split())
    p = 10**9 + 7
    count = pow(2, n, p)-1

    for i in [a, b]:
        count -= modcomb(n, i, p)

    print(count % (10**9 + 7))


def modcomb(n, r, p):
    x = 1
    y = 1
    for i in range(r):
        x *= n-i
        x %= p
        y *= i+1
        y %= p
    return x*pow(y, p-2, p) % p


if __name__ == "__main__":
    main()


Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>

using namespace std;

unsigned long gcd(unsigned long a, unsigned long b)
{
    if( a > b ){
        unsigned long t = b;
        b = a;
        a = t;
    }

    if( a == 0 ){ return b;};

    return gcd( a , b % a);
} 

int main()
{
    unsigned long a,b;
    scanf("%lu %lu", &a, &b);

    printf("%lu\n",gcd(a,b));

}

Measured memory_bytes: 3204
#include <iostream>

namespace ABC175
{

  class A
  {
  public:
    A() = default;
    ~A() = default;


    void Run()
    {
      std::string str = {};
      std::cin >> str;

      int A = 0;
      int sum = 0;
      for (auto s : str)
      {
        if (s == 'R')
        {
          sum++;
          if (sum > A) { A = sum; }
        }
        else
        {
          sum = 0;
        }
      }

      std::cout << A << std::endl;
    }
  };

}

int main()
{

  ABC175::A prob;
  prob.Run();

  return 0;
}



Measured memory_bytes: 3196
#include<iostream>
using namespace std;
int main(){
	int n,m,p;
	while(cin>>n>>m>>p,n,m){
		int ans=0,d[n];
		double sum=0.0;
		for(int i=0;i<n;i++){
			cin>>d[i];
			sum+=d[i];
		}
		sum*=100;
		sum-=sum*(p*1.0/100);
		if(d[m-1]){
			ans=sum/d[m-1];
			cout<<ans<<endl;
		}
		else
		cout<<0<<endl;
	}
}

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

#define rep(i,n) for(int i = 0; i < n; i++)
#define REP(i,n) for(int i = 1; i < n; i++)
#define per(i,n) for(int i = n; i >= 0; i--)
#define sz(x) int(x.size())
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define YesorNo(a) printf(a ? "Yes\n" : "No\n")
#define endl '\n'
#define fi first
#define se second
using ll = long long;
using P = pair<int,int>;
using Pl = pair<ll,ll>;
using vi = vector<int>;
using vii = vector<vi>;
using vl = vector<ll>;
using vll = vector<vl>;
using vs = vector<string>;
using vb = vector<bool>;
using vc = vector<char>;
using vcc = vector<vc>;
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
const int inf = (1<<30)-1;
const ll infll = (1LL<<62)-1;
ll ceil(const ll &a, const ll &b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }



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

  int n;
  cin >> n;
  for(int i = 1; i <= n; i++) {
    int x = i * 1.08;
    if(x == n) {
      cout << i << endl;
      return 0;
    }
  }
  cout << ":(" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int P=1e9+7;
const ll oo=1e18;

int mul(int a,int b){ return 1ll*a*b%P; }
int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

ll T,N,A,B,C,D;
map<ll,ll> f;
ll dp(ll x){
	if(f.count(x))return f[x];
	f[x]=x*D;
	if(1.0*x*D>1e18)f[x]=oo;
	vector<ll> a={2,3,5},b={A,B,C};
	lop(k,0,3){
		ll u=x%a[k],v=(a[k]-u)%a[k];
		f[x]=min(f[x],D*u+b[k]+dp(x/a[k]));
		f[x]=min(f[x],D*v+b[k]+dp((x+a[k]-1)/a[k]));
	}
	//Pr("f[%lld]=%lld\n",x,f[x]); 
	return f[x];
}
int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
#endif
	read(T); 
	while(T--){
		read(N),read(A),read(B),read(C),read(D); 
		f.clear(); f[0]=0,f[1]=D;
		cout<<dp(N)<<endl;
	}
	return 0;
}


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

int gcd(long long a, long long b) { return b != 0 ? gcd(b, a % b) : a; }
// cout << fixed << setprecision(10);
// vector<vector<int>> vec(H, vector<int>(W))    // int H*W

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

    int ans = 1;
    while(N >= K){
        N = N/K;
        ans++;
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll; //int:2*10**9
typedef long double ld;
typedef pair<ll,ll> P;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define vec2(name,i,j,k) vector<vector<ll>> name(i,vector<ll>(j,k))
#define vec3(name,i,j,k,l) vector<vector<vector<ll>>> name(i,vector<vector<ll>>(j,vector<ll>(k,l)))
#define pb push_back
#define MOD 1000000007 //998244353
#define PI 3.141592653
#define INF 100000000000000 //14
//cin.tie(0);cout.tie(0);ios::sync_with_stdio(false);
int main(){
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(a.rbegin(),a.rend());
    ll ans = 0;
    REP(i,n-1){
        ans+=a[(i+1)/2];
    }
    cout << ans << endl;
}

Measured memory_bytes: 4836
import sys
input = sys.stdin.readline
sys.setrecursionlimit(10**9)

from collections import deque

def main():
    n, u, v = map(int, input().split())
    u, v = u-1, v-1
    G = [[] for i in range(n)]
    for i in range(n-1):
        a,b = map(int, input().split())
        a,b = a-1,b-1
        G[a].append(b)
        G[b].append(a)

    def bfs(start):
        dist = [0]*n
        is_leaf = [0]*n
        que = deque()
        que.append((start, -1, 0))
        while que:
            c,p,d = que.pop()
            dist[c] = d
            cnt = 0
            for to in G[c]:
                if to != p:
                    que.append((to,c,d+1))
                    cnt += 1
            if not cnt:
                is_leaf[c] = 1
        return dist, is_leaf

    a, is_leaf = bfs(v)
    b, _ = bfs(u)

    ans = 0
    for i in range(n):
        if not is_leaf[i]:
            continue
        if b[i] >= a[i]:
            continue
        tmp = 0
        d = b[i]
        if d != 0:
            tmp = 2*d
            aoki = d
        else:
            aoki = 0
        tak = a[i]
        m = tak-aoki
        if m%2==1:
            tmp += 2*m -1
        else:
            tmp += 2*(m-1)
        ans = max(ans, tmp)
    print(ans//2)

if __name__ == "__main__":
    main()

Measured memory_bytes: 69500
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#define N_MAX 100

int main()
{
    char buf[N_MAX];
    bool cards[4][13];
    int n, cd, num, i, j, k, l;
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 13; j++)
        {
            cards[i][j] = false;
        }
    }
    scanf("%d", &n);
    for (k = 0; k < n; k++)
    {
        scanf("%s %d", buf, &num);
        if (buf[0] == 'S')
            l = 0;
        else if (buf[0] == 'H')
            l = 1;
        else if (buf[0] == 'C')
            l = 2;
        else if (buf[0] == 'D')
            l = 3;
        else
        {
            printf("error\n");
            exit(1);
        }
        cards[l][num - 1] = true;
    }
    for (i = 0; i < 4; i++)
    {
        for (j = 0; j < 13; j++)
        {
            if (cards[i][j] == false)
            {
                switch (i)
                {
                case 0:
                {
                    printf("S");
                    break;
                }
                case 1:
                {
                    printf("H");
                    break;
                }
                case 2:
                {
                    printf("C");
                    break;
                }
                case 3:
                {
                    printf("D");
                    break;
                }
                default:
                    break;
                }
                printf(" %d\n", j + 1);
            }
        }
    }
    return 0;
}


Measured memory_bytes: 2104
#include <bits/stdc++.h>
#define REP(i,n) for (int i=0;i<(n);i++)
#define ALL(a) (a).begin(),(a).end()
#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 ll long long
#define ull unsigned long long
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};

using namespace std;
const int Max = 1000000;
void update(vector<int> &a,int x){
  for(int i = x;i<Max;i++){
    a[i] = min(a[i-x]+1,a[i]);
  }
}
    

int main(){
  vector<int> a(Max,Max);
  vector<int> o(Max,Max);
  a[0]=0;o[0]=0;
  for(int i=0;;i++){
    int x=i*(i+1)*(i+2)/6;
    if(x>Max)break;
    update(a,x);
    if(x&1)update(o,x);
  }
  int n;
  while(cin>>n,n){
    cout << a[n] << " " << o[n] << endl;
  }
    return 0;
}

Measured memory_bytes: 10472
#include <iostream>

using namespace std;

#define int long long

const int N = 2e5 + 10;

int a[N];

int32_t main() 
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);    
    int n, k;
    cin >> n >> k;
    for (int i = 0; i < n; ++i) cin >> a[i];
    for (int i = k; i < n; ++i)
    {
        if (a[i] > a[i - k]) cout << "Yes\n";
        else cout << "No\n";
    }
    return 0;
}

Measured memory_bytes: 5216
a, b, c, x, y = map(int, input().split())
res = 2*c*min(x, y) if a+b >= 2*c else (a+b)*min(x, y)
print(res+(x-y)*min(2*c, a)) if x >= y else print(res+(y-x)*min(2*c, b))

Measured memory_bytes: 38384
#!/usr/bin/env python3
N = int(input())
L = sorted([int(s) for s in input().split()])


def check_search(middle, idx_short2, l_lng, l_lows):
    return l_lows[middle] + l_lows[idx_short2] > l_lng


l_lows = L[:2]
triangles = 0


for l_lng in L[2:]:
    for idx, l_low in enumerate(l_lows):
        left = 0
        right = len(l_lows) - 1 - idx
        end = right
        while (left < right):
            middle = (left + right) // 2
            if check_search(middle, len(l_lows) - 1 - idx, l_lng, l_lows):
                right = middle
            else:
                left = middle + 1
        triangles += (end - right)
    l_lows.append(l_lng)

print(triangles)

Measured memory_bytes: 42476
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int a = sc.nextInt();
    int b = sc.nextInt();
    int c = sc.nextInt();
    if(a == b && b ==c){
      System.out.println("1");
    }else if(a == b || b == c || c == a){
      System.out.println("2");
    }else{
      System.out.println("3");
    }
  }
}

Measured memory_bytes: 21716
N = str(input())
num = N[-1]
num = int(num)
 
if num == 3:
  print('bon')
elif num == 0 or num==1 or num==6 or num==8:
  print('pon')
elif num ==2:
  print('hon')
elif num == 4:
  print('hon')
elif num==5:
  print('hon')
elif num==7:
  print('hon')
elif num==9:
  print('hon')

Measured memory_bytes: 9132