akhauriyash/Code-Regression huggingface dataset:
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, [ $t:tt ]) => {{
        let len = read_value!($next, usize);
        (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    }};

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

#[allow(unused)]
macro_rules! debug {
    ($($format:tt)*) => (write!(std::io::stderr(), $($format)*).unwrap());
}
#[allow(unused)]
macro_rules! debugln {
    ($($format:tt)*) => (writeln!(std::io::stderr(), $($format)*).unwrap());
}

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input! {
        s: chars,
    }
    let n = s.len() + 1;
    let mut gt = 0;
    let mut lt = 0;
    let mut dp = vec![0; n];
    for i in 0..n {
        if i == n - 1 || s[i] == '>' {
            if i == n - 1 || lt > 0 {
                for j in i - gt - lt..i - lt {
                    dp[j] = max(dp[j], (i - lt) - j);
                }
                for j in i - lt..i + 1 {
                    dp[j] = max(dp[j], j - (i - lt));
                }
                gt = 0;
                lt = 0;
            }
            gt += 1;
        } else {
            lt += 1;
        }
    }
    let mut sum: i64 = 0;
    for i in 0..n {
        sum += dp[i] as i64;
    }
    puts!("{}\n", sum);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 15608
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a,b,c;
  cin >> a >> b;
  c = a*b; 
  if (c%2==0){
  	cout << "Even" << endl;
  }else if(c%2==1){
  	cout << "Odd" << endl;
  }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//型に気を付けよう
//a=0x61=97
#define rep(i,n) for(int i=0;i<n;i++)
typedef long long  ll;
typedef long double  ld;
typedef string str;
typedef pair<int,int> pairii;
typedef vector<int> veci;
const double pi=3.1415926535;
const ll  mod=1000000007;
//桁数指定　cout << fixed << setprecision(2)
int MIN(vector<int> Vec){//配列の最小値
  int n=Vec.size();
  int min= 2147483647;
  for(int i=0;i<n;i++){
    if(min>Vec.at(i))min=Vec.at(i);
  }
  return min;}
int main() {
  int a,b,m,mi=INT_MAX;
  cin>>a>>b>>m;
  veci p(a);
  veci q(b);
  {rep(i,a)cin>>p[i];}
  {rep(i,b)cin>>q[i];}
  rep(i,m){
    int x,y,c;
    cin>>x>>y>>c;
    x--;y--;
    c*=-1;
    c+=p[x];
    c+=q[y];
    mi=min(c,mi);
  }
  mi=min(mi,(MIN(p)+MIN(q)));
  cout<<mi<<endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i=0; i<(int)n; i++)
#define REPR(i, n) for(int i=(int)n-1; i>=0; i--)
#define FOR(i, m, n) for(int i=(int)m; i<(int)n; i++)
#define FORR(i, m, n) for(int i=(int)m-1; i>=(int)n; i--)
#define ALL(x) (x).begin(), (x).end()
#define ASC(v) sort(ALL(v));
#define DESC(v) sort(ALL(v), greater<int>());
#define UNIQ(a) sort(ALL(a));(a).resize(unique(ALL(a)) - a.begin());
#define PRINTD(x, d) cout << fixed << setprecision(d) << x << "\n";
#define DEBUG(x) cout<<#x<<": "<<x<<"\n"
typedef long long ll;
const double PI = acos(-1);
ll lcm(ll a, ll b) { return a / __gcd(a, b) * b; }
bool isprime(int x){ int i; if(x<2)return 0; else if(x==2) return 1; if(x%2==0) return 0; for(i=3; i*i<=x; i+=2) if(x%i==0) return 0; return 1; }
int digsum(int n) { int r=0; while(n>0) { r+=n%10; n/=10; } return r; }
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a = b; return 1; } return 0; }



void solve(long long A, long long B){
	ll res = 0;
	res = A - B*2;
	if (res<0) res = 0;
	cout << res << "\n";
}

int main(){
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    solve(A, B);
    return 0;
}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10**6)
input = sys.stdin.readline

h,w,m = map(int,input().split())

cnth = [0]*h
cntw = [0]*w
target = set()
for i in range(m):
    x,y = map(int,input().split())
    x -= 1
    y -= 1
    cnth[x] += 1
    cntｗ[y] += 1
    target.add(x*10**20 + y)

maxh = max(cnth)
maxw = max(cntw)
ans = maxh + maxw

H, W = set(),set()
for i,c in enumerate(cnth):
    if c == maxh:
        H.add(i)
for i,c in enumerate(cntw):
    if c == maxw:
        W.add(i)
if len(H)*len(W) > m:
    print(ans)
else:
    for h in H:
        for w in W:
            if h*10**20 + w not in target:
                print(ans)
                exit()
    print(ans-1)


Measured memory_bytes: 200100
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=110000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

ll gcd(ll x, ll y){
  if(x%y==0)return y;
  return gcd(y,x%y);
}
ll lcm(ll x,ll y){
  return x/gcd(x,y)*y;
}
struct UnionFind {
    vector<int> par;
    
    UnionFind(int n) : par(n, -1) { }
    void init(int n) { par.assign(n, -1); }
    
    int root(int x) {
        if (par[x] < 0) return x;
        else return par[x] = root(par[x]);
    }
    
    bool issame(int x, int y) {
        return root(x) == root(y);
    }
    
    bool merge(int x, int y) {
        x = root(x); y = root(y);
        if (x == y) return false;
        if (par[x] > par[y]) swap(x, y); // merge technique
        par[x] += par[y];
        par[y] = x;
        return true;
    }
    
    int size(int x) {
        return -par[root(x)];
    }
};
int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);  
  
  string s;
  cin >> s;
  int n=s.size();
  int l=0,r=n-1;
  int ans=0;
  while(r-l>0){
    if(s[l]==s[r]){
      l++;
      r--;
    }
    else{
      if(s[l]=='x'){
        ans++;
        l++;
      }
      else if(s[r]=='x'){
        ans++;
        r--;
      }
      else{
        cout << -1 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;    
}


Measured memory_bytes: 512
<?php
$N = intval(trim(fgets(STDIN)));
$A = explode(' ', trim(fgets(STDIN)));
$c1=$c2=$c3=0;
foreach($A as $a){
    if($a == '1')$c1++;
    if($a == '2')$c2++;
    if($a == '3')$c3++;
}
$dp = array_fill(-1, $N+3, array_fill(-1,$N+3, array_fill(-1,$N+3,0)));
for($k = 0; $k <= $c3; ++$k){
    $dpk = &$dp[$k];
    for($j = 0, $J = $c2 + $c3 - $k; $j <= $J; ++$j){
        for($i = 0, $I = $c1+$c2+$c3-$k-$j; $i <= $I ; ++$i){
            if($i==0&&$j==0&&$k==0)continue;
            $tmp = $N;
            $tmp+=$i*$dpk[$j][$i-1];
            $tmp+=$j*$dpk[$j-1][$i+1];
            $tmp+=$k*$dp[$k-1][$j+1][$i];
            $dpk[$j][$i] = $tmp/($i+$j+$k);
        }
    }
}
echo $dp[$c3][$c2][$c1];

Measured memory_bytes: 926200
line = input().split(" ")
w = int(line[0])
h = int(line[1])
x = int(line[2])
y = int(line[3])
r = int(line[4])
if x - r < 0:
    print("No")
elif w < x + r:
    print("No")
elif y - r < 0:
    print("No")
elif h < y + r:
    print("No")
else:
    print("Yes")


Measured memory_bytes: 5596
temp=input().split()
N=int(temp[0])
M=int(temp[1])
ans=0
INF=1000000000

if abs(N-M)==0:
	ans=2
elif abs(N-M)==1:
	ans=1
else:
	ans=0

#を求める
for i in range(1,N+1):
	ans*=i
	ans%=INF+7
for i in range(1,M+1):
	ans*=i
	ans%=INF+7
print(ans)

Measured memory_bytes: 3064
#include<iostream>
#include<stdio.h>
#include <cstdlib>  // abs() for integer
#include <cmath>    // abs() for float, and fabs()

using namespace std;

int main(void){
    string s;

    int cnt = 0;
    int i; 

    cin >> s;

    for(i=0;i<3;i++){
        if(s[i] == '1') cnt++;
    }

    cout << cnt << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
 
 
using namespace std;
 
typedef long long ll;
 
#define MOD 998244353
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define vi vector<int>
#define vl vector<ll>
#define ld long double
#define vvi vector<vector<int>>
#define vvl vector<vector<long long>>
#define pii pair<int,int>
#define pll pair<long,long>
#define vpii vector<pii>
#define vpll vector<pll>
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define PI 3.1415926535897932384626433832795
#define fix(f,n) fixed<<setprecision(n)<<f
#define all(x) x.begin(),x.end()
#define endl "\n"
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
 
ll newmod(ll a,ll b)
 {
  return ((a%b)+b)%b;
}
 
 
ll powM(ll a,ll b,ll m )
{ 
  a%=m;
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a%m;
    a=a*a%m;
    b>>=1;
  }
 
return ans;
}
 
ll pow(ll a,ll b)
{ 
  
  ll ans=1;
  while(b)
  {
    if(b&1)ans=ans*a;
    a=a*a;
    b>>=1;
  }
 
return ans;
}


int main()
{ 
  IOS;

ll n,k;

cin>>n>>k;

vl a(n+1);

rep(i,1,n+1)cin>>a[i];

ll flag=0;

while(!flag&&k){

k--;
 vl temp(n+2);
for(ll i=1;i<=n;i++)
{
  ll left=max(i-a[i],1LL);
  ll right=min(n,a[i]+i);
 temp[left]++;
 temp[right+1]--;
}


ll cnt=0;
for(ll i=1;i<=n;i++){
  temp[i]+=temp[i-1];
  a[i]=temp[i];
  if(a[i]==n)cnt++;
}

if(cnt==n)flag=1;

}

for(ll i=1;i<=n;i++)cout<<a[i]<<" ";


 return 0;
 
 
}

Measured memory_bytes: 6352
N = int(input())
S = input()

S = list(S)

j = 0
for s in S:
    a = ord(s)
    for i in range(0, N):
        if chr(a) != 'Z':
            a = a + 1
            S[j] = chr(a)
        else:
            a = a - 25
            S[j] = chr(a)
    j = j + 1

S = ''.join(S)

print(S)


Measured memory_bytes: 3060
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a[] = new int[3];
		for (int i = 0; i < 3; i++) {
			a[i] = sc.nextInt();
		}
		Arrays.sort(a);
		if (a[0] == 5 & a[1] == 5 & a[2] == 7) {
			System.out.println("YES");
		} else {
			System.out.println("NO");
		}
	}
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
#include <iostream>
#include<math.h>
using namespace std;
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()
{
    int64_t N;
    cin >> N;
    vector<vector<int64_t>> vec(N, vector<int64_t>(3, 0));
    for (int i=0; i<N; i++) {
        int64_t a, b, c;
        cin >> a >> b >> c;
        vec[i][0] = a;
        vec[i][1] = b;
        vec[i][2] = c;
    }

    vector<vector<int64_t>> dp(N+1, vector<int64_t>(3, 0));
    for (int64_t i=1; i<=N; i++) {
        int64_t a, b, c;
        a = vec[i-1][0];
        b = vec[i-1][1];
        c = vec[i-1][2];
        chmax(dp[i][0], dp[i-1][1] + a);
        chmax(dp[i][0], dp[i-1][2] + a);
        chmax(dp[i][1], dp[i-1][0] + b);
        chmax(dp[i][1], dp[i-1][2] + b);
        chmax(dp[i][2], dp[i-1][0] + c);
        chmax(dp[i][2], dp[i-1][1] + c);
    }

    cout << max({dp[N][0], dp[N][1], dp[N][2]}) << endl;
    return 0;
}

Measured memory_bytes: 14352
n,p = map(int,input().split())
a = list(map(int,input().split()))
odd = 0
even = 0
for ai in a:
    if(ai%2==0):
        even += 1
    else:
        odd += 1

if(p==1)&(odd==0):
    print(0)
elif(p==0)&(odd==0):
    print(2**n)
else:
    print(2**(n-1))


Measured memory_bytes: 61936
N,K = map(int,input().split())
D = list(map(int,input().split()))
while True:
    flg = True
    lis = list(str(N))
    for i in lis:
        if int(i) in D:
            flg = False
    if flg == True:
        print(N)
        exit()
    N += 1


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


int main() {
  
  int N;
  
  cin>>N;
  
  vector<int> A(N);
for (int i = 0; i < N; i++) {
  cin >> A.at(i);
}
  
  sort(A.begin(), A.end()); 
  
  
  
  
  vector<int> B(N);
  for (int i = 0; i < N-1; i++) {
  B.at(i)=A.at(i+1)-A.at(i);
}
  int sw=0;
  for (int i = 0; i < N-1; i++) {
    if(B.at(i)==0){
     sw++;
    }
}
  if(sw==0){
    cout<<"YES"<<endl;
  }else{
    cout<<"NO"<<endl;
  }
  
  
}




Measured memory_bytes: 1792
#include<cstdio>
#include<algorithm>
#include<cmath>
using namespace std;
long long Calc(long long n, int K) {
	int i;
	K++;
	long long r = 0;
	for (i = 1; i <= K; i++) {
		long long t;
		if(i!=K)t = (long long)( powl(n, 1.0L / (K - i + 1)) + 1 - 1e-8);
		else t = n;
		n = (n+t-1)/t;
		r += t;
	}
	return r;
}
int main() {
	int i;
	long long N, A, res = 1e18;
	scanf("%lld%lld", &N, &A);
	for (i = 0; i <= 50; i++) {
		res = min(res, Calc(N, i) + A*i);
	}
	printf("%lld\n", res);
}

Measured memory_bytes: 128
from itertools import product
L, R, d=map(int,input().split())
#C = []
#for i in range(H):
#    C.append((input().replace(".","0").replace("#","1")))
# S=list(map(int,input().split()))
# B=list(map(int,input().split()))
count = 0
for i in range(R+1):
    if i>=L and i%d==0:
        count+=1


print(count)




Measured memory_bytes: 9164
n = int(input())
list_shain_index = list(map(int, input().split()))
list_num_buka = [0]*(n+1)
for num in list_shain_index:
  list_num_buka[int(num)] += 1

list_ans = map(str, list_num_buka[1:])
print(' '.join(list_ans))

Measured memory_bytes: 33956
n=int(input())
s=input()
dp=[(n+1)*[0]for _ in range(n+1)]
ans=0
for i in range(1,n):
    for j in range(i+1,n+1):
        if s[i-1]==s[j-1]:
            dp[i][j]=min(dp[i-1][j-1]+1,j-i)
            ans=max(ans,dp[i][j])
print(ans)

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

using namespace std;

typedef long long ll;
typedef pair<int, int> pp;
double PI=acos(-1);
int const N = 5e5 + 10,M=5e6+10, oo = 1e9;
const int mod = oo+7;
const ll  OO = 3e18;

int n,aa[N];
ll calc(ll m){
    ll an=0;
    for(int i=0;i<n;i++){
        an+=abs(aa[i]-(i+1+m));
    }
    return an;
}
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int i=0;i<n;i++)cin>>aa[i];
    ll l=-1e12,r=1e12,mid1,mid2;
    ll res=OO;
//    for(int i=-10;i<10;i++)cout<<i<<' '<<calc(i)<<endl;
    while(l<=r){
        mid1=(l+l+r)/3;
        mid2=(l+r+r)/3;
        ll s1=calc(mid1),s2=calc(mid2);
//        cout<<mid1<<' '<<mid2<<' '<<s1<<' '<<s2<<endl; 
        if(s1<s2){
            if(s1<res)res=s1;
            r=mid2-1;
        }else {
            if(s2<res)res=s2;
            l=mid1+1;
        }
        
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 1024
# ABC059C - Sequence (ARC072C)
def main():
    n = int(input())
    lst = list(map(int, input().rstrip().split()))
    cnt = [0] * 2
    
    # start with positive number
    cur = 0
    for i, j in enumerate(lst):
        cur += j
        if i % 2 == 0 and cur <= 0:
            cnt[0] += abs(cur) + 1
            cur = 1
        elif i % 2 == 1 and cur >= 0:
            cnt[0] += abs(cur) + 1
            cur = -1

    # start with negative number
    cur = 0
    for i, j in enumerate(lst):
        cur += j
        if i % 2 == 0 and cur >= 0:
            cnt[1] += abs(cur) + 1
            cur = -1
        elif i % 2 == 1 and cur <= 0:
            cnt[1] += abs(cur) + 1
            cur = 1

    print(min(cnt))


if __name__ == "__main__":
    main()


Measured memory_bytes: 14468
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cmath>
#include<map>
#include<iomanip>
#include<cstring>
#define reg register
#define EN std::puts("")
#define LL long long
inline int read(){
	register int x=0;register int y=1;
	register char c=std::getchar();
	while(c<'0'||c>'9'){if(c=='-') y=0;c=std::getchar();}
	while(c>='0'&&c<='9'){x=x*10+(c^48);c=std::getchar();}
	return y?x:-x;
}
int main(){
	int r=read();
	std::printf("%lf",2*3.1415926*r);
	return 0;
}


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

signed main() {
	vector<int>a(3);
	cin >> a[0] >> a[1] >> a[2];
	sort(a.begin(), a.end());
	cout << a[0] << " " << a[1] << " " << a[2] << endl;
}

Measured memory_bytes: 3092
import java.util.Scanner;

public class Main{
	public static void main(String[] args) {
		Input test = new Input();
		test.Judge();
	}
}

class Input {
	public void Judge() {
		Scanner num = new Scanner(System.in);
		int a = num.nextInt();
		int b = num.nextInt();

		if (a > b) {
			System.out.println("a > b");
		} else if(a < b) {
			System.out.println("a < b");
		}else {
                        System.out.println("a == b");
                }
	}
}

Measured memory_bytes: 26192
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long A, B;
  cin >> A >> B;
  if (A % 3 == 0 or B % 3 == 0 or (A+B) % 3 == 0) puts("Possible");
  else puts("Impossible");
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
#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++)
typedef long long ll;

int main(){
	int n,x;
	cin >> n >> x;
	vector<int> l(n);
	rep(i,n){
		cin >> l[i];
	}
	
	int d = 0;
	int ans = 0;
	while(d <= x){
		d += l[ans];
		ans++;
		if(ans == n+1) break;
	}
	
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <iomanip>
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <cmath>
#include <stdlib.h>
#include <stdio.h>
using namespace std;
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; }
const int INF = 1001001000;
const int MOD = 1000000007;

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

using Graph = vector<vector<int>>;
//再帰とかグラフを使うときは予めNの最大値のグローバル配列を取っておく
int N;
vector<int> E[200001];
vector<bool> seen;
typedef pair<int, int> P;
int D[101];
//頂点状態を表すcolor[]において、0は未訪問、1は訪問中、2は完了を表す。
int color[101];
int find_time = 0;

int main() {
    long long N; cin >> N;
    vector<long long> A(N), B(N), C(N);
    for (int i = 0; i < N; i++) cin >> A.at(i);
    for (int i = 0; i < N; i++) cin >> B.at(i);
    for (int i = 0; i < N; i++) cin >> C.at(i);
    sort(A.begin(), A.end());
    sort(B.begin(), B.end());
    sort(C.begin(), C.end());
    long long ans = 0;

    //中部について全探索
    for (int i = 0; i < N; i++) {
        long long numA = lower_bound(A.begin(), A.end(), B.at(i)) - A.begin();
        long long numC = C.end()-(upper_bound(C.begin(), C.end(), B.at(i)));
        ans += numA * numC;
    }

    cout << ans << endl;
}


Measured memory_bytes: 7296
#include<iostream>
#include<stdio.h>
#include<math.h>
#include<algorithm>
#include<vector>
#include<cstdlib>
#include<map>
#include<fstream>
#include<string>
#include<sstream>
#include<iomanip>
#include<iostream>
#include<numeric>
using namespace std;

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int s = max(a, b);
	s = max(s, c);
	cout << a + b + c - s << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <set>
#include <map>
#include <iostream>
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,a) repi(i,0,a)
#define all(a) (a).begin(), (a).end()

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 A[32] = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};

int K;

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

  printf( "%d\n", A[K-1] );

  return 0;
}

Measured memory_bytes: 256
n=int(input())
c=0
a=list(map(int,input().split()))
for i in range(n):
    m=i
    for j in range(i,n):
        if a[m]>a[j]:m=j
    if i!=m:a[m],a[i]=a[i],a[m];c+=1
print(*a)
print(c)


Measured memory_bytes: 5612
n = int(input())

d = {}


class mod_comb_perm:
    def __init__(self,n,mod):
        self.mod = mod
        self.fact = [1 for i in range(n)]
        for i in range(2,n+1):
            self.fact[i-1] = (self.fact[i-2]*i)%mod

    def expo(self,x,n):
        if n == 2:
            return (x * x) % self.mod
        elif n % 2 == 1:
            return (self.expo(x, n - 1) * x) % self.mod
        else:
            temp = self.expo(x, n // 2) % self.mod
            return (temp * temp) % self.mod
    def comb(self,n,k):
        a = (self.fact[n]*self.expo(self.fact[k],self.mod-2))%self.mod
        return (a*self.expo(self.fact[n-k],self.mod-2))%self.mod
    def invm(self,x):
        return (self.expo(self.fact[x],self.mod-2))%self.mod
    def perm(self,n,k):
        return (self.fact[n]*self.expo(self.fact[n-k],self.mod-2))%self.mod


# com = mod_comb_perm(10**5,10**18+3)
d = {}
for i in range(n):
    temp = [0 for i in range(26)]
    s = input()
    for c in s:
        t = ord(c)-97
        temp[t]+=1
    for i in range(26):
        temp[i] = str(temp[i])
    txt = ",".join(temp)
    if txt not in d:
        d[txt] = 1
    else:
        d[txt] += 1
ans = 0
# print(d)
for k in d:
    if d[k] != 1:
        ans += d[k]*(d[k]-1)/2
print(int(ans))

Measured memory_bytes: 21604
import numpy as np


def solve(string):
    n, m, c, *ba = map(int, string.split())
    b = np.asarray(ba[:m])
    a = np.asarray(ba[m:])
    a.resize((n, m))
    return str(np.sum(np.dot(a,b.T) + c > 0))


if __name__ == '__main__':
    n, m, o = map(int, input().split())
    print(solve('{} {} {}\n'.format(n, m, o) + '\n'.join([input() for _ in range(n + 1)])))


Measured memory_bytes: 12440
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <algorithm>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;

int count(int n, int radix) {
    int cnt = 0;
    while(n > 0) {
        cnt += n % radix;
        n /= radix;
    }
    return cnt;
}


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n; 
    cin >> n;
    int ans = 100000;
    REP(k, n + 1) {
        ans = min(ans, count(k, 6) + count(n - k, 9));
    }
    cout << ans << endl;
    return 0;
}


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

int main() {
    int n,m,k,c;
    bool f = false;
    cin >> n >> m >> k;
    for (int i=0;i<n;i++) {
        for (int j=0;j<m;j++) {
            //cout << i*(m-j) + j*(n-i) << " " << i*j + (n-i) * (m-j) <<endl;
            if ((k == i*(m-j) + j*(n-i)) or (k == i*j + (n-i) * (m-j))) {

                f = true;
                break;                
            }
        }
    }
    cout << (f ? "Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
/// Bismillah Hir Rahmanir Rahim

#include <bits/stdc++.h>

using namespace std;

#define PI                    acos(-1.0)
#define Pi                    3.141592653589793
#define ff                    first
#define ss                    second
#define pb                    push_back
#define space                 " "
#define all(x)                (x).begin(), (x).end()
#define clr(ar)               memset(ar, 0, sizeof(ar))
#define eprintf(...)          fprintf(stderr, __VA_ARGS__)

/*
template <class T> T gcd(T a,T b){ if(b == 0) return a; return gcd( b,a % b ); }
template <class T> T lcm(T a, T b ){ return ( a / gcd( a,b ) ) * b; }
template<class T> string ToString(const T &x){ stringstream s; s << x; return s.str(); }
template<class T> int ToInteger(const T &x){ stringstream s; s << x; int r; s >> r; return r; }
*/

const int dr[] = { -1, 1, 0, 0 }; /// 4 side moves.
const int dc[] = { 0, 0, -1, 1 };
const int dx[] = { 1, 1, 0, -1, -1, -1, 0, 1 }; /// 8 side moves.
const int dy[] = { 0, 1, 1, 1, 0, -1, -1, -1 };
const int kr[] = { 1, 1, -1, -1, 2, 2, -2, -2 }; /// Knight Moves.
const int kc[] = { 2, -2, 2, -2, 1, -1, 1, -1 };

typedef  long long int            ll;
typedef  map<string,int>          msi;
typedef  map<string, string>      mss;
typedef  map<int,int>	          mii;
typedef  map<ll, ll>              mll;
typedef  map<char,int>            mci;
typedef  map<int,string>	      mis;
typedef  pair<int,int> 	          ii;
typedef  pair<string, int>        psi;
typedef  pair<string, string>     pss;
typedef  vector<int> 	          vi;
typedef  vector<string> 	      vs;
typedef  vector<char>	          vc;
typedef  vector< ii >             vii;

template<class T1> void deb(T1 e1)
{
    cout << e1 << endl;
}
template<class T1,class T2> void deb(T1 e1, T2 e2)
{
    cout << e1 << space << e2 << endl;
}
template<class T1,class T2,class T3> void deb(T1 e1, T2 e2, T3 e3)
{
    cout << e1 << space << e2 << space << e3 << endl;
}

#define sf                    scanf
#define pf                    printf

#define sf1(a)                scanf("%d", &a)
#define sf2(a,b)              scanf("%d %d",&a, &b)
#define sf3(a,b,c)            scanf("%d %d %d", &a, &b, &c)
#define sf4(a,b,c,d)          scanf("%d %d %d %d", &a, &b, &c, &d)

#define sf1ll(a)              scanf("%I64d", &a)
#define sf2ll(a,b)            scanf("%I64d %I64d", &a, &b)
#define sf3ll(a,b,c)          scanf("%I64d %I64d %I64d", &a, &b, &c)
#define sf4ll(a,b,c,d)        scanf("%I64d %I64d %I64d %I64d", &a, &b, &c, &d)

#define READ                  freopen("in.txt", "r", stdin);
#define WRITE                 freopen("out.txt", "w", stdout);
/// The End.

void check_time()
{
#ifdef the_badcoder
    eprintf("%.5lf\n", (double)clock() / CLOCKS_PER_SEC);
#endif
}

const int res = 1e5 + 50;
const ll mod = 1e9 + 7;



int main()
{
    int n, m;
    
    sf2ll( n, m );
    
    if( m >= n ){
        deb("0");
    }
    else {
        deb( n - m );
    }
    return 0;
}


Measured memory_bytes: 384
use std::io;
use std::io::BufRead;

fn read_int(n:&str) -> i32{
    n.parse().unwrap()
}

fn read_times(buff : &str) -> Vec <i32> {
    buff.split_whitespace().map(read_int).collect()
}

fn main(){
    // to increase its lifetime
    let stdin = io::stdin();
    let mut buff = stdin.lock().lines();
    // io::stdin().read_line(&mut buff) just *appends* the input.
    // we can use a function inside which each buff is created, but ..?
    // http://stackoverflow.com/questions/30186037/
    buff.next();
    let times = read_times(& buff.next().unwrap().unwrap()); // REALLY?
    let normal_time :i32 = times.iter().fold(0, |x, y|{x+y});
    // let normal_time :i32 = times.iter().sum();
    // `use of unstable library feature 'iter_arith':
    // `bounds recently changed (see issue #27739)`
    buff.next();
    for line in &mut buff {
        // slice pattern syntax is experimental
        let input : Vec<i32> = line.unwrap()
            .split_whitespace().map(read_int).collect();
        println!("{}",
                 normal_time + input[1] - times[(input[0] -1) as usize]);
    }
}

Measured memory_bytes: 380
#include <iostream>
using namespace std;
typedef long long ll;
ll a,b,c,d,e,ans;
ll f(ll a,ll b){
    if(a<b)swap(a,b);
    if(b==0)return a;
    return f(b,a%b);
}
int main(void){
    cin>>a>>b>>c>>d;
    e=c*d/f(d,c);
    ans=b-a+1;
    ans-=b/c-(a+c-1)/c+1;
    ans-=b/d-(a+d-1)/d+1;
    ans+=b/e-(a+e-1)/e+1;
    cout<<ans<<endl;
}


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

using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int, int> Pii;
typedef pair<int, ll> Pil;
typedef pair<ll, ll> Pll;
typedef pair<ll, int> Pli;

#define fi first
#define se second

const ll MOD = 1e9 + 7;
const ll MOD2 = 998244353;
const ll MOD3 = 1812447359;
const ll INF = 1ll << 62;
const double PI = 2 * asin(1);

void yes() {printf("yes\n");}
void no() {printf("no\n");}
void Yes() {printf("Yes\n");}
void No() {printf("No\n");}
void YES() {printf("YES\n");}
void NO() {printf("NO\n");}

int N, A[105], ans[105];
bool used[105];

int main(){
  cin >> N;
  for (int i = 1; i <= N; i++) {
    cin >> A[i];
    if (i < A[i]){
      cout << -1 << endl;
      return 0;
    }  
  }

  for (int i = N; i >= 1; i--){
    int cnt = i;
    
    for (int j = N; j >= 1; j--){
      if (used[j]) continue;
      if (A[j] != cnt){
        cnt--; continue;
      }

      used[j] = true;
      ans[i] = A[j];
      break;
    }
  }

  for (int i = 1; i <= N; i++){
    cout << ans[i] << endl;
  }

  return 0;
}


Measured memory_bytes: 3632
//#define _GLIBCXX_DEBUG

#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
const int INF= 1e9+5;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";

int main(){
  ll n;cin>>n;
  vl a(n);
  rep(i,n)cin>>a[i];
  ll count=0;
  rep(i,n){
    if(a[i]%2!=0)count++;
  }
  if(count%2!=0)cout<<"NO"<<endl;
  else cout<<"YES"<<endl;
}

Measured memory_bytes: 1024
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}

// get longest common subsequence, O(s.length() * t.length())
struct LCS {
    vvi dp;
    string s, t;
    LCS(string s, string t) : s(s), t(t) {
        dp.assign(s.size() + 1, vi(t.size() + 1, 0));
        for (int i = 1; i <= s.size(); ++i) {
            for (int j = 1; j <= t.size(); ++j) {
                if (s[i - 1] == t[j - 1]) {
                    dp[i][j] = dp[i - 1][j - 1] + 1;
                }
                chmax(dp[i][j], dp[i][j - 1]);
                chmax(dp[i][j], dp[i - 1][j]);
            }
        }
    }
    int length() { return dp[s.size()][t.size()]; }
    string restore() {
        string ret = "";
        deque<char> temp;
        int sidx = s.size();
        int tidx = t.size();
        while (sidx > 0 && tidx > 0) {
            if (s[sidx - 1] == t[tidx - 1]) {
                temp.push_front(s[sidx - 1]);
                --sidx;
                --tidx;
            } else if (dp[sidx][tidx] == dp[sidx - 1][tidx])
                --sidx;
            else
                --tidx;
        }
        for (auto &ch : temp) {
            ret += ch;
        }
        return ret;
    }
};

int main() {
    string s, t;
    cin >> s >> t;
    LCS lcs(s, t);
    cout << lcs.restore() << "\n";
    return 0;
}

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

int main() {
  long long n; cin >> n; 
  long long ans = 0;
  for(int i = 1; i<=n; i++){
    if(i/10==0) ans++;
    else if(i/100>=1&&i/1000==0) ans++;
    else if(i/10000>=1&&i/100000==0) ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
module Main where

import           Data.Maybe

import           Control.Monad       (forM, forM_)
import qualified Data.Vector.Mutable as VM

solveB :: (Int, Int) -> IO Int
solveB (n, m) = do
  let string2Int s = read s :: Int
  table <- VM.replicate (m + 1) 0
  contents <- sequence (replicate n $ getLine >>= (\x -> return $ words x))
  forM_
    contents
    (\line -> do
       let preData = fmap read line
       forM_ (tail preData) (\x -> VM.modify table (+ 1) x))
  forM_
    [1 .. m]
    (\index -> do
       people <- VM.read table index
       if people == n
         then VM.modify table (+ 1) 0
         else VM.modify table (+ 0) 0)
  VM.read table 0

main = do
  ans <- getLine >>= solveB . (\x -> (head x, last x)) . fmap read . words
  putStrLn $ show ans


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

int main(int argc, char const* argv[])
{
	int n, taroPoint=0, hanakoPoint=0;
	string taroStr, hanakoStr;
	cin >> n;
	for (int i=0; i<n; i++) {
		cin >> taroStr >> hanakoStr;
		for (int j=0; j<taroStr.size(); j++) {
			if (taroStr[j] == hanakoStr[j]) {
				if (j != taroStr.size()-1) continue;
				else if (taroStr.size() < hanakoStr.size()) hanakoPoint += 3;
				else if (taroStr.size() > hanakoStr.size()) taroPoint += 3;
				else {
					taroPoint++;
					hanakoPoint++;
				}
			} else if (taroStr[j] < hanakoStr[j]) {
				hanakoPoint += 3;
				break;
			} else {
				taroPoint += 3;
				break;
			}
		}
	}
	cout << taroPoint << " " << hanakoPoint << endl;
	return 0;
}


Measured memory_bytes: 1204
#include <iostream>
#include <string.h>
#include <cmath>
using namespace std;

int n;
int a[5000];

int main()
{
	cin >> n;

	memset(a, 0, sizeof(a));

	int t = 0;

	for (int i = 2; i <= 55555; i += 5) {
		bool f = 0;
		for (int j = 2; j <= sqrt(i); j++) {
			if (i % j == 0) {
				f = 1;
				break;
			}
		}
		if (!f) {
			a[t] = i;
			t++;
		}
	}

	for (int i = 0; i < n - 1; i++)
		cout << a[i] << " ";
	cout << a[n - 1] << endl;

	return 0;
}

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


int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    int n; cin >> n;
    unordered_map<int, int> table;
    int val, cur = 0, pos = n+1;
    for (int i = 1; i <= n; i++) {
        cin >> val;
        table[val] = i;
    }
    int ret = 0;
    for (int i = n; i >= 1; i--) {
        if (table[i] < pos) {
            cur++;
            ret = max(cur, ret);
        }
        else cur = 1;
        pos = table[i];
    }
    cout << n - ret << endl;


    return 0;
}

Measured memory_bytes: 8520
#include <iostream>
#include <string>
#include <algorithm>
#include <numeric>
#include <queue>
#include <utility>
#include <cmath>
using namespace std;

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

int main() {
	string S;
	cin >> S;

	int n = S.size();
	long long ans = 0;

	rep(i, 1 << (n-1)){
		int f = 0;
		int s = 1;

		rep(j, n-1){
			if(i & (1<<j)){
				ans += stoll(S.substr(f,s));
				f = j+1;
				s = 1;
			}else{
				s += 1;
			}
		}
		ans += stoll(S.substr(f, s));
	}



	cout << ans << endl;
}


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

int main() {
  int A, B;
  int ANS = 0;

  cin >> A >> B;

  for (int i = A; i <= B; i++){
    if (((i / 10000 % 10 == i % 10) && (i / 1000 % 10 == i % 100 / 10)))
      ANS++; 
  }

  cout << ANS;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD 1000000007
#define ll long long int
#define pair <ll, ll> pi
#define vector <ll> vi
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define rep(i, a, b) for (int i = a; i <= b; i++)
#define SQ(a) (a) * (a)
#define ordered_set tree<ll, null_type, greater_equal<ll>, rb_tree_tag, tree_order_statistics_node_update> //greater_equal<ll> or less<ll>
// find_by_key()   order_of_key()
//#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
/*bool comp(string a, string b) {
if (a.size() != b.size()) return a.size() < b.size();
return a < b;
}*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //freopen('input.txt', 'r', stdin);
    //freopen('output.txt', 'w', stdout);
    ll i, j, k, n, m, b, d, t, ans = 0,a,x,y;
    cin>>a>>b;
    if(a%3==0||b%3==0||(a+b)%3==0){
        cout<<"Possible"<<endl;
    }
    else{
        cout<<"Impossible"<<endl;

    }
    return 0;
}

Measured memory_bytes: 3604
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N,K,p int 
	
	fmt.Scan(&N,&K)
	As := make([]int, N)

	for i := 0; i < N; i++ {
		fmt.Scan(&p)
		As[i] = p
	}

	sort.Sort(sort.IntSlice(As))

	res := 0
	for i := 0; i < K; i++ {
		res += As[i]
	}
	fmt.Println(res)
}



Measured memory_bytes: 1888
#include <iostream>

using namespace std;

int main(){

   int builds[4][3][10] = {{{0}}};

   int n;
   int b, f, r, v;

   cin >> n;

   for(int i = 0; i < n; i++){
      cin >> b >> f >> r >> v;

      builds[b - 1][f - 1][r - 1] += v;
   }

   for(int i = 0; i < 4; i++){
      for(int j = 0; j < 3; j++){
         for(int k = 0; k < 10; k++){
            cout << " " << builds[i][j][k];
         }
         cout << endl;
      }
      if(i != 3){
         cout << "####################" << endl;
      }
   }

   return 0;
}


Measured memory_bytes: 3080
import math

N = int(input())
X = math.floor(N/1.08)
while X < N/1.08 + 1/1.08:
  if N/1.08 <= X  and X < N/1.08 + 1/1.08:
    X = X
    break
  else:
    X = X+1
 
    
if (N+1)%27 == 0 or (N+14)%27 == 0:
  print(':(')
else:
  print(X)

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define reps(i, n, m) for (int i = (int)(n); i <= (int)(m); i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
#define collect(arr, size) rep(i,size) cin >> arr[i];

int main(){
    int n; cin >> n;
    vector<int> S(n);
    collect(S, n);
    
    int q; cin >> q;
    vector<int> T(q);
    collect(T, q);
    
    rep(i,n){
        rep(j,q){
            if(S[i]!=T[j]) continue;
            T[j] = -1;
        }
    }
    
    int c = 0;
    rep(i,q){
        if(T[i]==-1) c++;
    }
    cout << c << endl;
}


Measured memory_bytes: 3112
N, x = map(int, input().split())
l = list(map(int, input().split()))

before = sum(l)
l[0] = min(x, l[0])
for i in range(1, N):
    s = l[i-1]+l[i]
    if s > x:
        l[i] = x-l[i-1]

print(before-sum(l))


Measured memory_bytes: 14252
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const int maxn = 100+100;
const ll mod = 1e9+7;
int base[maxn];
int main() {
    ios::sync_with_stdio(0);
    int n,k;
    cin>>n>>k;
    int len =0;
    while(n){
        base[len++]=n%k;
        n/=k;
    }
   cout<<len<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<vector>
#include<list>
#include<stack>
#include<queue>
#include<algorithm>
using namespace std;

int main(){
    int mod=1000000007;
    int n;
    int ans;
    for (;;) {
        scanf("%d",&n);
        if (n!=0) {
            vector<int> p(n);
            for (auto&e:p) {
                scanf("%d",&e);
            }
            ans=p[0];
            for (int i=0;i<n;i++) {
                int tmp=0;
                for (int j=i;j<n;j++) {
                    tmp+=p[j];
                    ans=max(ans,tmp);
                }
            }
        } else {
            break;
        }
        printf("%d\n",ans);
    }
    return 0;
}

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

const ll MOD = 1e9+7;

void solve()
{
	ll N,D;
	cin>>N>>D;

	ll count = 0;

	while(N--)
	{
		ll x,y;
		cin>>x>>y;

		double dist = (double)sqrt(x*x + y*y);

		if(dist <= D)
			count++;
	}

	cout<<count<<endl;
}

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

	solve();

	return 0;
} 

Measured memory_bytes: 3712
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace std;
using namespace __gnu_pbds;

#define pb                push_back
#define ppb               pop_back
#define pf                push_front
#define ppf               pop_front
#define all(x)            (x).begin(),(x).end()
#define int               long long
#define fr                first
#define sc                second
#define vc                vector
#define endl              '\n'
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define mem1(a)           memset(a,-1,sizeof(a))
#define mem0(a)           memset(a,0,sizeof(a))
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define LSB(i)            ((i)&-(i))

template<typename T>
using oset = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const int H = 1e4 + 5;
const int N = 1e3 + 3;
int n, h;
int dp[H];
int a[N], b[N];

int dynamic(int health)
{
    if (health <= 0)
        return 0;
    if (dp[health] != -1)
        return dp[health];
    int ans = INT_MAX;
    for (int i = 0; i < n; i++)
    {
        ans = min(ans, dynamic(health - a[i]) + b[i]);
    }
    dp[health] = ans;
    return ans;
}

void solve()
{
    mem1(dp);
    cin >> h >> n;
    for (int i = 0; i < n; i++)
        cin >> a[i] >> b[i];
    cout << dynamic(h);
}
signed main() {
    ios_base::sync_with_stdio(false);
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    int t = 1;
    //cin>>t;
    while (t--) solve();
    return 0;
}

Measured memory_bytes: 640
#N行複数列の文字列複数を行列として入力
table = [input().split() for l in range(3)]
N = int(input())
array = [input() for i in range(N)]
bingo = ""

for k in range(3):
    for j in range(3):
        if table[k][j] in array:
            table[k][j] = 0

        table[k][j] = int(table[k][j])

for l in range(3):
    if table[l][0] + table[l][1] + table[l][2] == 0:
        bingo = "Yes"

for l in range(3):
    if table[0][l] + table[1][l] + table[2][l] == 0:
        bingo = "Yes"

if table[0][0] + table[1][1] + table[2][2] == 0 or table[2][0] + table[1][1] + table[2][0] ==0:
        bingo = "Yes"

if bingo == "":
    bingo = "No"

print(bingo)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define fir first
#define sec second
#define all(x) (x).begin(),(x).end()
#define debug(x) cerr<<#x<<": "<<x<<endl;
#define ll long long
using namespace std;

const int maxn=1e6+7;
ll a[maxn];

int solve(int T){


	int t;cin>>t;
	string ss;cin>>ss;
	for(auto &x:ss) x=('A'+(x-'A'+t)%26);
	cout<<ss<<endl;

    return 0;
}
int main(){
    int T=1;
    //scanf("%d",&T);
    for(int cas=1;cas<=T;cas++) solve(T);
	return 0;
}


Measured memory_bytes: 256
N = int(input())

# (締切, 時間)
DeadlineCost = [] * N

for i in range(N):
    c, d = map(int, input().split())
    DeadlineCost.append((d, c))

DeadlineCost.sort(reverse=True)
#print(DeadlineCost)

t = 0
for i in range(N):
    (d, c) = DeadlineCost.pop()

    t += c
    if t > d:
        print('No')
        exit()

print('Yes')


Measured memory_bytes: 29440
#include <iostream>
using ll=long long;
int cnt_digit(ll n)
{
  int i=0;
  while(n>0)
  {
    n /= 10;
    i++;
  }
  return i;
}

int main()
{
  ll N;
  std::cin >> N;
  int ans = cnt_digit(N);
  for (ll A = 1ll; A*A <= N; A++)
  {
    if(N%A != 0) continue;
    const ll B =N/A;
    const int f=std::max(cnt_digit(A),cnt_digit(B));
    if(ans>f) ans = f;

  }
std::cout << ans << '\n';
}


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

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

Measured memory_bytes: 3584
mod io{
    use std::io::*;
    pub fn read<T: ::std::str::FromStr>()->T{
        let stdin=stdin();
        let ret=stdin.lock().bytes().map(|c|c.unwrap()as char)
        .skip_while(|c|c.is_whitespace())
        .take_while(|c|!c.is_whitespace())
        .collect::<String>().parse().ok().unwrap();
        ret
    }
}
use io::read;
use std::cmp::max;
fn main(){
    let a=read::<i32>();
    let b=read::<i32>();
    println!("{}",max(0,a-b))
}

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

string S;
int main(){
	cin>>S;
	if(S[0]=='R'){
		if(S[1]=='S')cout<<1<<endl;
		else if(S[2]=='R')cout<<3<<endl;
		else cout<<2<<endl;
	}
	else{
		if(S[1]=='R'){
			if(S[2]=='R')cout<<2<<endl;
			else cout<<1<<endl;
		}
		else{
			if(S[2]=='R')cout<<1<<endl;
			else cout<<0<<endl;
		}
	}
}

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

int main(){
	int n;
	cin >> n;
	int a[100];
	for(int i = 0; i < n; i++){
		cin >> a[i];
	}
	for(int i = 0; i < n-1; i++){
		cout << a[n-i-1] << ' ';
	}
	cout << a[0] << endl;
	
	return 0;
}

Measured memory_bytes: 1160
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<string>
#include<cstring>
#include<cmath>
#include<map>
#include<vector>
#include<utility>
#include<queue>
#include<stack>
#include<set>
#include<ctime>
const  int N = 2e5 + 5;
const int mod = 1e9 + 7;
const int INF = 0x3f3f3f3f;
typedef long long ll;
typedef long double lw;
#define sc(n) scanf("%d",&n)
#define fo(i,a,b) for(int i=a;i<b;i++)
#define mem(a,b) memset(a,b,sizeof a)
using namespace std;
char mp[N];
int a, b, c, d, n;
int main()
{
	cin >> n >> a >> b >> c >> d;
	cin >> mp + 1;
	if (c < d)//a<b<d,c<d
	{
		fo(i, a, c)
		{
			if (mp[i] == '#'&&mp[i + 1] == '#')
			{
				puts("No");
				return 0;
			}
		}
		fo(i, b, d)
		{
			if (mp[i] == '#'&&mp[i + 1] == '#')
			{
				puts("No");
				return 0;
			}
		}
		puts("Yes");
	}
	else//a<b<d<c
	{
		fo(i, a, c)
		{
			if (mp[i] == '#'&&mp[i + 1] == '#')
			{
				puts("No");
				return 0;
			}
		}
		fo(i, b-1, d)
		{
			if (mp[i] == '.'&&mp[i + 1] == '.'&&mp[i + 2] == '.')
			{
				puts("Yes");
				return 0;
			}
		}
		puts("No");
	}
	return 0;
}


Measured memory_bytes: 384