akhauriyash/Code-Regression huggingface dataset:
/*
    �����悭�ǂ����I
    �_���I�ɍl���悤�I
    �T���v�����m�F���悤!
    ��΂ɒ��߂�ȁI
    �H�v������I
    �z��͏������߂ɂƂ��Ă���

    Twitter�͏I���܂Ń��O�A�E�g�I
    �i�ԈႦ�ĉ�@���c�C�[�g���Ă͂����Ȃ�����j

*/
//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
#include<stdio.h>
#include<cstring>
//namespace
using namespace std;
//�J��Ԃ�
#define REP(i, m, n) for(int i=(int)m; i<(int)n; ++i)
#define rep(i, n) REP(i, 0, n)
//�C�e���[�^
#define all_range(C) begin(C), end(C)
//�ȗ���
typedef long long ll;
typedef pair<int,int> pint;
typedef pair<ll,int> pli;
typedef pair<string,int> pst;

const int inf = 1e9+7;
const ll longinf = 1LL<<60;
const ll mod = 1e9+7;
//�ő�ŏ�
template<typename T1, typename T2> inline void chmin(T1 &a, T2 b) {if(a>b) a=b;}
template<typename T1, typename T2> inline void chmax(T1 &a, T2 b) {if(a<b) a=b;}

//�֐�

//�ő���񐔂����߂�
ll my_gcd(ll x, ll y) {
  ll r;

  while(y!=0) {
    r = x%y;
    x = y;
    y = r;
  }

  return x;
}

//�ŏ����񐔂����߂�
ll my_lcm(ll x, ll y) {

  return (x*y)/my_gcd(x,y);
}

//x��y������߂� ���Q�l�F10^18��܂�
ll my_pow(ll x, ll y) {
  ll sum = 1;

  while(y>0) {
    sum *= x;
    --y;
  }

  return sum;
}

/*�l���������X�y�[�X


*/

//main.cpp----------------------------


int main() {
  int r, g, b, n;
  cin >> r >> g >> b >> n;

  int cnt = 0;
  for(int i=0; i<=n; ++i) {
    for(int j=0; j<=n; ++j) {
      int k = n-(i*r+j*g);
      if(k%b==0&&k>=0) ++cnt;
    }
  }

  cout << cnt << endl;

  return 0;
}


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

using namespace std;

signed main() {
    ll N;
    cin >> N;
    ll now=1;
    while(now*now < N)now++;
    ll root_r = now;
    ll result = 0;
    for(ll i=1; i<root_r; i++){
        if(N % i == 0 && i < (N/i) -1){
            result += N/i -1;
        }
    }
    cout << result << endl;
}


Measured memory_bytes: 384
#include <iostream>
using namespace std;
int main(){
    int n,m;
    cin>>n>>m;
    char square[n][m];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++){
            cin>>square[i][j];
        }
    }
    for(int i=0;i<n;i++){
        bool flag=true;
        for(int j=0;j<m;j++){
            if(square[i][j]=='#'){
                flag=false;
                break;
            }
        }
        if(flag){
            for(int j=0;j<m;j++){
                square[i][j]='!';
            }
        }
    }
    for(int i=0;i<m;i++){
        bool flag=true;
        for(int j=0;j<n;j++){
            if(square[j][i]=='!')continue;
            if(square[j][i]=='#'){
                flag=false;
                break;
            }
        }
        if(flag){
            for(int j=0;j<n;j++){
                square[j][i]='!';
            }
        }
    }
    for(int i=0;i<n;i++){
        bool flag=true;
        for(int j=0;j<m;j++){
            if(square[i][j]!='!'){
                cout<<square[i][j];
                flag=false;
            }
        }
        if(flag==false)cout<<endl;
    }
    return 0;
}


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

int main(void)
{
  int N,K,C,i,j;
  int L[200000];
  int R[200000];
  char S[200000];
  scanf("%d %d %d",&N,&K,&C);
  scanf("%s",&S);

  j = 0;

  for(i=0;j<K;j++)
  {
    while(S[i] == 'x')
    {
      i++;
    }
    L[j] = i;
    i += C+1;
  }

  j = K-1;

  for(i=N-1;j>=0;j--)
  {
    while(S[i] == 'x')
    {
      i--;
    }
    R[j] = i;
    i -= C+1;
  }

  for(i=0;i<K;i++)
  {
    if(L[i] == R[i])
    {
      printf("%d\n",L[i]+1);
    }
  }

  return 0;
}

Measured memory_bytes: 3200
#include <iostream>
#include <algorithm>
#include <math.h>
#include <string.h>
#include <vector>

typedef long long ll;
using namespace std;

int main()
{
    char a;

    cin >> a;

    if (a == 'A')cout << "T"<< endl;
    if (a == 'T')cout << "A"<< endl;
    if (a == 'G')cout << "C"<< endl;
    if (a == 'C')cout << "G"<< endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using i64 = long long;

int main() {
    int n;
    std::cin >> n;
    std::vector<int> ret(n + 1);
    for (int i = 1; i < n; i++) {
        int a;
        std::cin >> a;
        ret[a]++;
    }

    for (int i = 1; i <= n; i++) std::cout << ret[i] << '\n';

    return 0;
}


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

int main() {
  long long N;
  cin >> N;
  long long ans = 0;
  
  if (N %2 == 1) {
    cout << 0 << endl;
  }
  else {
    while (N /5 > 0) {
      ans += N / 10;
      N = N /5;
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int N=sc.nextInt();
    int X=N%10;
    if(X==3) {
    	System.out.println("bon");
    }else {
    	if(X==0||X==1||X==6||X==8) {
    		System.out.println("pon");
    	}else {
    		System.out.println("hon");
    	}
    }
  }
}

Measured memory_bytes: 35796
import sys
import heapq, functools, collections
import random
from collections import Counter, defaultdict
 
# read line as a string
# strr = input()
 
# read line as an integer
k = int(input())
 
# read one line and parse each word as a string
# lst = input().split()
 
# read one line and parse each word as an integer
# arr = list(map(int,input().split()))
 
if k%1000 == 0:
    print(0)
else:
    print(1000 - k%1000)

Measured memory_bytes: 76932
# coding: utf-8

# In[3]:

import sys
#input = sys.stdin.readline
A, B = map(int, input().split())
#A = list(map(int, input().split()))


# In[4]:

if abs(A-B)<=1:
    print(A+B)
else:
    mv = max(A, B)
    print(mv*2-1)


# In[ ]:





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

int main() {
    ll n,p;
    std::cin >> n>>p;
    unordered_map<ll,ll> in;
    
    ll rem = p;
    for (int i = 2; i <= sqrt(p); i++) {
        while(rem % i == 0){
            rem /=i;
            in[i]++;
        }
    }
    in[rem]++;
    
    ll result = 1;
    for (auto i : in) {
        result *= (ll)pow(i.first,(ll)(i.second/n));
    }
    std::cout << result << std::endl;
}


Measured memory_bytes: 384
/*          (: -_-_-_- IN THE NAME OF ALLAH -_-_-_- :)          */
/*                    | S e y e d |                             */
/*                    |    3 7    |                             */
/*                   HASHEMESHOON hastam ;)                     */
/*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*//*/
#include <bits/stdc++.h>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <cstdio>
#include <map>
#include <string>
#include <set>
#include <vector>
#include <stack>
#include <deque>
#include <queue>
#include <ctime>
#include <list>
#include <iterator>
#define ll long long
#define ss second
#define ff first
#define pb push_back
using namespace std;
ll n,m,x,y,z,w,t,d,b[200100],a[200100];
string s;
int main(){
    ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    cin>>n;
    for(int i=n;i<1000;i++){
        if(i/100==(i/10)%10 && i/100==(i%10))return cout<<i,0;
    }
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int max_digit = 50;
ll dp[100][2];

int main(){
    int N;
    ll K;
    cin >> N >> K;
    vector<ll> A(N);
    for(int i=0; i<N; i++) cin >> A[i];

    memset(dp, -1, sizeof(dp));
    dp[0][0] = 0;
    for(int d = 0; d < max_digit; d++){
        int cnt = 0;
        ll mask = 1LL << (max_digit - d - 1);
        for(int i = 0; i < N; i++){    
            if(mask & A[i]) cnt++;
        }
        //ビット反転後の個数のコスト
        ll cost0 = mask * cnt;
        ll cost1 = (N - cnt) * mask;

        //sm -> sm
        if(dp[d][1] != -1){
            //選ぶものに制約がないので単純に大きい方を採る
            dp[d+1][1] = max(dp[d+1][1], dp[d][1] + max(cost0, cost1));
        }

        //exact -> sm
        if(dp[d][0] != -1){
            if(K & mask) dp[d+1][1] = max(dp[d+1][1], dp[d][0] + cost0);
        }

        //exact -> exact
        if(dp[d][0] != -1){
            if(K & mask) dp[d+1][0] = max(dp[d+1][0], dp[d][0] + cost1);
            else dp[d+1][0] = max(dp[d+1][0], dp[d][0] + cost0);
        }
    }

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

    return 0;
}

Measured memory_bytes: 1152
x = gets.to_i

y = x.times.map { gets.chomp.to_s }
ac = 0
wa = 0
tle = 0
re = 0
for i in 0..x-1 do
    if y[i] == "AC"
        ac += 1
    elsif y[i] == "WA"
        wa += 1
    elsif y[i] == "TLE"
        tle += 1
    else
        re += 1
    end
end

puts "AC x " + ac.to_s
puts "WA x " + wa.to_s
puts "TLE x " + tle.to_s
puts "RE x " + re.to_s

Measured memory_bytes: 21568
#include <bits/stdc++.h>
#define xx first
#define yy second
#define mp make_pair
#define pb push_back
#define mset(x, y) memset(x, y, sizeof x)
#define mcpy(x, y) memcpy(x, y, sizeof x)
using namespace std;

typedef long long LL;
typedef pair <int, int> pii;

inline int Read()
{
	int x = 0, f = 1, c = getchar();
	for (; !isdigit(c); c = getchar())
		if (c == '-')
			f = -1;
	for (;  isdigit(c); c = getchar())
		x = x * 10 + c - '0';
	return x * f;
}

const int MAXN = 2005;
const int mod = 924844033;

int n, m, fac[MAXN], f[MAXN][MAXN], g[MAXN];

inline void Solve(int l, int c)
{
	while (c --)
		for (int i = n; ~i; i --)
			for (int j = 1; i + j <= n && j <= l >> 1; j ++)
				g[i + j] = (g[i + j] + 1LL * g[i] * f[l][j]) % mod;
}

int main()
{
#ifdef wxh010910
	freopen("data.in", "r", stdin);
#endif
	n = Read(), m = Read();
	f[0][0] = f[1][0] = g[0] = fac[0] = 1;
	for (int i = 1; i <= n; i ++)
		fac[i] = 1LL * fac[i - 1] * i % mod;
	for (int i = 2; i <= n / m + 1; i ++)
		for (int j = 0; j <= i >> 1; j ++)
			f[i][j] = (f[i - 1][j] + f[i - 2][j - 1]) % mod;
	Solve(n / m + 1, n % m << 1), Solve(n / m, m - n % m << 1);
	int ret = 0;
	for (int i = 0; i <= n; i ++)
		if (i & 1)
			ret = (ret - 1LL * g[i] * fac[n - i] % mod + mod) % mod;
		else
			ret = (1LL * g[i] * fac[n - i] + ret) % mod;
	return printf("%d\n", ret), 0;
}


Measured memory_bytes: 14976
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i=0;i<(n);++i)

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	string s;cin >> s;
	string t;cin >> t;
	vector<int> a(26,-1);
	vector<int> b(26,-1);
	rep(i,s.size()){
		int x=s.at(i)-'a';
		int y=t.at(i)-'a';
		if(a[x]!=-1 || b[y]!=-1){
			if(a[x]!=y || b[y]!=x){
				cout << "No" << endl;
				return 0;
			}
		}
		else{
			a[x]=y;
			b[y]=x;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 916
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using V = vector<int>;
using VV = vector<V>;
using VVV = vector<VV>;
using VL = vector<ll>;
using VVL = vector<VL>;
using VVVL = vector<VVL>;
template<class T> using VE = vector<T>;
template<class T> using P = pair<T, T>;
#define rep(i,n) for(int i=0;i<(n);i++)
#define rep1(i,n) for(int i=1;i<=(n);i++)
#define REP(i,k,n) for(int i=(k);i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define output(x,y) cout << fixed << setprecision(y) << x << endl;
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; }
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
const ll MOD = 1e9 + 7;
// const ll MOD = 998244353;
ll upper = MOD + MOD;
ll under = -upper;
ll UPPER = MOD * MOD;
ll UNDER = -UPPER;
const long double pi = 3.141592653589793;
int main() {
	string s;
	cin >> s;
	ll sum = 0;
	int n = s.size();
	rep(i, n) {
		sum += s[i] - '0';
		sum %= 9;
	}
	puts(sum == 0 ? "Yes" : "No");
	return 0;
}

Measured memory_bytes: 3748
program main
real*8 :: n,neck,neckpos,ans
real*8 :: a(5)
read(*,*)n
do i = 1,5
read(*,*)a(i)
end do
neck = minval(a)
ans = ceiling(n/neck,8) + 4

write(*,*) int(ans,8)
end program main

Measured memory_bytes: 2960
import sys

# 再帰上限の変更(デフォルトは1000)
# 大きくしすぎるとREするらしい
sys.setrecursionlimit(10 ** 9)

N, M = map(int, input().split())
XYZ = [list(map(int, input().split())) for i in range(M)]

# XがわかればYがわかるので、あるAiがわかったときどこまでわかるか?をグラフにしてDFSで探索

graph = [[]for i in range(N + 1)]

seen = [0] * (N + 1)

for X, Y, Z in XYZ:
    graph[X].append(Y)
    graph[Y].append(X)


def dfs(a):
    if seen[a] == 1:
        return
    else:
        seen[a] = 1
        for i in graph[a]:
            dfs(i)


ans = 0

for i in range(1, N + 1):
    if seen[i] == 1:
        continue
    else:
        dfs(i)
        ans += 1

print(ans)


Measured memory_bytes: 118144
# coding: utf-8
# Your code here!
N,K=map(int,input().split())

S=list(input())

clu=[]
temp=0
for i in range(1,len(S)):
    if S[i]==S[i-1]:
        temp+=1
    else:
        clu.append(temp)
        temp=0
clu.append(temp)
 
ans=sum(clu)

base=S[0]

zone=False
for i in range(1,len(S)):
    if zone:
        if S[i]==base:
            K-=1
            ans+=2
            zone=False
        else:
            S[i]=base
    else:
        if S[i]!=base and K>0:
            zone=True
            S[i]=base

if zone:
    ans+=1

print(ans)

Measured memory_bytes: 4776
#include <iostream>
#include <vector>
#include <cstring>
#include <cstdint>
#include <tuple>
#include <algorithm>
#include <map>

template<std::uint_fast64_t Mod>
class ModInt{
    using u64 = uint_fast64_t;
public:
    u64 num;
    constexpr ModInt(const u64 x = 0) noexcept : num(x % Mod) {}
    constexpr u64 &value() noexcept { return num; }
    constexpr const u64 &value() const noexcept { return num; }
    constexpr ModInt operator+(const ModInt rhs) const noexcept {
        return ModInt(*this) += rhs;
    }
    constexpr ModInt operator-(const ModInt rhs) const noexcept {
        return ModInt(*this) -= rhs;
    }
    constexpr ModInt operator*(const ModInt rhs) const noexcept {
        return ModInt(*this) *= rhs;
    }
    constexpr ModInt operator/(const ModInt rhs) const noexcept {
        return ModInt(*this) /= rhs;
    }
    constexpr ModInt &operator+=(const ModInt rhs) noexcept {
        num += rhs.num;
        if (num >= Mod) {
            num -= Mod;
        }
        return *this;
    }
    constexpr ModInt &operator-=(const ModInt rhs) noexcept {
        if (num < rhs.num) {
            num += Mod;
        }
        num -= rhs.num;
        return *this;
    }
    constexpr ModInt &operator*=(const ModInt rhs) noexcept {
        num = num * rhs.num % Mod;
        return *this;
    }
    constexpr ModInt &operator/=(ModInt rhs) noexcept {
        u64 exp = Mod - 2;
        while (exp) {
            if (exp % 2) {
                *this *= rhs;
            }
            rhs *= rhs;
            exp /= 2;
        }
        return *this;
    }
    constexpr ModInt &operator=(const u64 num) noexcept {
        this->num = num % Mod;
        return *this;
    }

    constexpr ModInt pow(u64 k){
        return pow(num, k);
    }

    static constexpr ModInt pow(ModInt x, u64 k){
        if(k == 0) return 1;
        if(k % 2 == 0) return pow((x * x).num % Mod, k / 2);
        else return (x * pow(x, k - 1)).num % Mod;
    }
};

template<std::uint_fast64_t Mod>
std::ostream &operator<<(std::ostream &out, const ModInt<Mod> &m)
{
    out << m.num;
    return out;
}

using namespace std;

static const int INF = 1e9 + 7;
int n;
vector<int> a;
map<tuple<int, int, int>, ModInt<INF>> dp;

ModInt<INF> dfs(int mx, int mid, int mn){
    if(mx + mid + mn == n){
        return 1;
    }
    auto status = make_tuple(mx, mid, mn);
    if(dp.count(status)) return dp[status];
    int p = mx + mid + mn;
    ModInt<INF> res = 0;
    if(mx == a[p]){
        res += dfs(mx + 1, mid, mn);
    }
    if(mid == a[p]){
        res += dfs(mx, mid + 1, mn);
    }
    if(mn == a[p]){
        res += dfs(mx, mid, mn + 1);
    }
    return dp[status] = res;
}

int main(){
    cin >> n;
    a.resize(n);
    for(auto&& i : a){
        cin >> i;
    }
    ModInt<INF> ans = dfs(0, 0, 0);
    cout << ans << "\n";
}

Measured memory_bytes: 47360
#![allow(non_snake_case, unused_imports)]

// Input
macro_rules! input { (source = $s:expr, $($r:tt)*) => { let mut iter = $s.split_whitespace(); let mut next = || { iter.next().unwrap() }; input_inner!{next, $($r)*} }; ($($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, bytes) => { read_value!($next, String).into_bytes() }; ($next:expr, usize1) => { read_value!($next, usize) - 1 }; ($next:expr, $t:ty) => { $next().parse::<$t>().expect("Parse error") }; }

// Module
use std::cmp::{min,max};
use std::collections::{HashSet,BTreeMap,VecDeque};

// Main
fn main(){
    input!{
        N: usize,
        K: usize,
        H: [u64; N]
    }
    // ソートしましょう
    let mut H = H;
    H.sort();
    // 全探索して最適値を探る
    let mut ans = 1000000000;
    for i in K-1..N{
        ans = min(ans,H[i]-H[i+1-K]);
    }

    println!("{}", ans);
}


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <sstream>
#define ull unsigned long long
#define ll long long
using namespace std;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a,al=0,bo=0;
    cin >> n;
    vector<int> a_1;
    for(int i=0;i<n;i++){
        cin >> a;
        a_1.push_back(a);
    }
    sort(a_1.begin(),a_1.end(),greater<int>());
    for(int i=0;i<n;i++){
        if(i%2==0){al= al+a_1[i];}
        else if(i%2==1){bo= bo+a_1[i];}
    }
    cout << al-bo << endl;
    return 0;
}


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


int main() {
	int h, w;
	while (1) {
		cin >> h >> w;
		if (h == 0 && w == 0)break;
		for (int i = 1; i <= h; i++) {
			for (int j = 1; j <= w; j++) {
				if (j == 1 || j == w || i == 1 || i == h) {
					cout << "#";
				}
				else {
						cout << ".";
				}
			}
			cout << endl;
		}
		cout << endl;
	}
	
}


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



int main() {
	
	ios::sync_with_stdio(0);
	cin.tie(0);
	string s;
	cin>>s;
	if(s[2] == s[3] and s[4] == s[5])
		cout<<"Yes";
	else 
		cout<<"No";
	return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <queue>
#include <string>
#include <bitset>
#include <list>
#include <iomanip>
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define rrep(i,a,n) for(ll i=n;i>=a;i--)
#define elif else if
#define all(s) s.begin(),s.end()
typedef long long ll;
typedef pair<string,ll> P;
const ll INF = 1e+17;
const ll MODcdf = 998244353;
const ll MODatc = 1000000007;
bool pairCompare(const P& firstElof,const P& secondElof){
    return firstElof.first<secondElof.first;
}
bool pairCompare2(P firstElof,P secondElof){
    return (firstElof.second)%1000>(secondElof.second)%1000;
}
bool less_mod1000(int lhs, int rhs) {
  if ((lhs - rhs) % 1000 != 0)
    return lhs % 1000 < rhs % 1000;
  else // 5で割った余りが等しいなら普通に大小比較する
    return lhs < rhs;
}
string A="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
string a="abcdefghijklmnopqrstuvwxyz";
ll dp[107000];
ll jump(ll start,ll goal){
  if(dp[start]>=0)return dp[start];
  if(start==goal){
    return 1;
  }elif(start>goal){
    return 0;
  }
  return dp[start]=(jump(start+1,goal)+jump(start+2,goal))%MODatc;
}
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    ll n,a,b;
    cin>>n>>a>>b;
    cout<<min(b,n*a)<<endl;
}


Measured memory_bytes: 764
import java.util.*;
	
	
	
	public class Main {
	
		public static void main(String[] args) {
			Scanner sc = new Scanner(System.in);
			int N = sc.nextInt();
			int Y = sc.nextInt();
			int x = 0;
			int y = 0;
			int z = 0;
			
			for(int i = 0;i<=N;i++) {
				x = i;
				for (int j=0;j<=(N-i);j++) {
					y = j;
					z = N-i-j;
					if (Y == 10000*x + 5000*y + 1000*z) {
						System.out.println(x+" "+y+" "+z);
						return;
					}
				}
			}
			
			System.out.println("-1 -1 -1");
			
			sc.close();
			
		}
		
		
	}

Measured memory_bytes: 23636
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define lvector vector<ll>
#define cvector vector<char>
#define svector vector<string>
#define lque queue<ll>
#define lpque priority_queue<ll>
#define dlpque priority_queue<ll,lvector,greater<ll>>
#define P pair<ll,ll>
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define rep(i,n) for(ll i=0; i<n; ++i)
#define print(a) cout << (a) << endl

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll a,b,c,d;cin>>a>>b>>c>>d;
  ll ans=max({a*c,a*d,b*c,b*d});
  print(ans);
  return 0;
}


Measured memory_bytes: 3652
#include<stdio.h>

long long a[200001];
int cnt[200001];
long long sa[200001];
long long ans[200001];


long long comb(int n,int r){
  long long p = 1;
  int i;

  if(n <= 1) return 0;

  for(i = 1;i <= r;i++) p = p*(n - i + 1)/i;

  return p;
}

int main(){
  int n;
  long long x,y;
  int i,j;
  long long sum = 0;

  scanf("%d", &n);

  for(i = 0;i <= 200000;i++){
    cnt[i] = 0;
  }

  for(i = 0;i < n;i++){
    scanf("%d", &a[i]);
    cnt[a[i]]++;
  }

  for(i = 1;i <= n;i++){
    sum += comb(cnt[i],2);
  }

  for(i = 0;i < n;i++){
    ans[i] = comb(cnt[a[i]],2);
    a[i] = comb(cnt[a[i]] - 1,2);
    sa[i] = ans[i] - a[i];
    printf("%lld\n", sum - sa[i]);
  }

  return 0;
}

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

int main() {
  	int N;
  	cin >> N;
  	int max;
  	for (int i = 0; i < 8; i++) {
      	int two_pow_i = int(pow(2, i));
      	if (two_pow_i > N) {
        	max = int(pow(2, i-1));
          	break;
        }
    }
  	cout << max << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast,fast-math,unroll-loops")

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

typedef long long ll;
typedef string str;

#define IOS ios::sync_with_stdio(0); cin.tie(0);
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()


int main() {
    IOS;

	int a,b,c,d,e;
	cin >> a >> b >> c >> d >> e;
	if(!a)cout << 1;
	else if(!b)cout << 2;
	else if(!c)cout << 3;
	else if(!d)cout << 4;
	else cout << 5;
}


Measured memory_bytes: 3648
N, K = map(int, input().split())
MOD = 10**9 + 7

fact = [1]*(N+10)
rfact = [1]*(N+10)
r = 1
for i in range(1, N+10):
  fact[i] = r = r * i % MOD
rfact[N] = r = pow(fact[N], MOD-2, MOD)
for i in range(N, 0, -1):
  rfact[i-1] = r = r * i % MOD

for i in range(1, K+1):
    if N-K-i+1 >= 0:
        v = fact[N-K+1] * rfact[N-K-i+1] * rfact[i] % MOD
        v = v * (fact[K-1] * rfact[i-1] * rfact[K-i] % MOD) % MOD
        print(v)
    else:
        print(0)

Measured memory_bytes: 3444
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        long[] a = new long[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextLong();
        }
        Arrays.sort(a);
        long sum1 = Math.abs(a[(n - 1) / 2] - a[n - 1]);
        for (int i = 1; i <= (n - 1) / 2; i++) {
            sum1 += Math.abs(a[n - i] - a[i - 1]);
            if (n - 1 - i == (n - 1) / 2) {
                break;
            }
            sum1 += Math.abs(a[i - 1] - a[n - 1 - i]);
        }
        long sum2 = Math.abs(a[(n - 1) / 2] - a[0]);
        for (int i = 1; i <= n / 2; i++) {
            sum2 += Math.abs(a[i - 1] - a[n - i]);
            if (i == n / 2) {
                break;
            }
            sum2 += Math.abs(a[n - i] - a[i]);
        }
        System.out.println(Math.max(sum1, sum2));
    }

}


Measured memory_bytes: 62008
# -*- coding: utf-8 -*-
from sys import stdin
from operator import itemgetter
from collections import deque
import math
import pprint
# stdin = open("sample.txt")

def keta(kazu):
    kazu_str = str(kazu)
    kazu_list = [int(kazu_str[i]) for i in range(0, len(kazu_str))]
    return kazu_list

s = stdin.readline().rstrip()

if s[0]=='7' or s[1]=='7' or s[2]=='7':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9896
#include <stdio.h>
#include <math.h>
#include <string.h>
#define pai 3.1415926535

int main(void) {
	int N;
	scanf("%d", &N);
	int x = 0;
	char S[101];
	int max = 0;
	scanf("%s", S);
	for (int i = 0; i <= N; i++) {
		if (x > max) {
			max = x;
		}

		if (S[i] == 'I') {
			x++;
		}
		else {
			x--;
		}
	}
	printf("%d", max);

	return 0;

}

Measured memory_bytes: 128
#d = むずかしさ, v = 推薦度
ans2 = []
while(1):
    tip = []
    tmp = []
    ans = 0
    n, m = map(int,input().split())
    if n == 0 and m == 0:
        break
    else:
        for i in range(n):
            d, v = map(int,input().split())
            tip.append([d, v])
        tip = sorted(tip, key = lambda x: x[1])
        tip.reverse()
        #print(tip)
        for i in range(n):
            if tip[i][0] in tmp:
                pass
            else:
                ans += tip[i][1]
                m += 1
                tmp.append(tip[i][0])
        #print("ans = {}".format(ans))
        ans2.append(ans)

for i in ans2:
    print(i)



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

long mod = 1e9+7;
void Main()
{
    int n, m;
    cin >> n >> m;
    vector<int> s(n);
    vector<int> t(m);
    for (int i = 0; i < n; i++)
    {
        cin >> s[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> t[i];
    }
    vector<vector<long>> p(n, vector<long>(m));
    if(s[0] == t[0]) p[0][0] = 1;
    for (int i = 1; i < n; i++){
        p[i][0] = p[i-1][0];
        if(s[i] == t[0]){
            p[i][0] += 1;
            p[i][0] %= mod;
        }
    }  
    for (int i = 1; i < m; i++){
        p[0][i] = p[0][i-1];
        if(s[0] == t[i]){
            p[0][i] += 1;
            p[0][i] %= mod;
        }
    } 
    for (int i = 1; i < n; i++)
    {
        for (int j = 1; j < m; j++)
        {
            p[i][j] = p[i][j-1];
            p[i][j] %= mod;
            p[i][j] += p[i-1][j];
            p[i][j] %= mod;
            p[i][j] -= p[i-1][j-1];
            if(p[i][j] < mod) p[i][j] += mod;
            p[i][j] %= mod;
            if(s[i] == t[j]){
                p[i][j] += p[i-1][j-1]+1;
                p[i][j] %= mod;
            }
        }
    }
    cout << p[n-1][m-1]+1 << endl;
}

int main(int argc, char **argv)
{
    Main();
    return 0;
}

Measured memory_bytes: 31616
#include <iostream>

int main()
{
  for ( int i = 1 ; ; ++i ) {
    int x = 0 ;
    std::cin >> x ;
    if ( x == 0 )
      break ;
    std::cout << "Case " << i << ": " << x << std::endl ;
  }
  return 0 ;
}

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

ll N, X, Y;
vector<ll> E[100000];

ll dfs(ll v, ll p) {
  ll g = 0;
  for(ll u : E[v]) if(u != p) g = g ^ (dfs(u, v) + 1);
  return g;
}

int main(void) {
  cin >> N;
  REP(i, 0, N - 1) {
    cin >> X >> Y; X--; Y--;
    E[X].push_back(Y);
    E[Y].push_back(X);
  }

  cout << (dfs(0, -1) != 0 ? "Alice" : "Bob") << endl;
}


Measured memory_bytes: 10368
#include <stdio.h>
#include <iostream>
#include <vector>
#include<algorithm>
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());
	reverse(a.begin(), a.end());

	int A = 1;
	for (int i = 0; i < N-1; i++)
	{
		if (a.at(i)!=a.at(i+1))
			A ++;
		
	}
	cout << A << endl;
}

Measured memory_bytes: 256
a=int(input())
b=((a//3)*(3+(3*(a//3))))*(1/2)
c=((a//5)*(5+(5*(a//5))))*(1/2)
d=((a//15)*(15+(15*(a//15))))*(1/2)
e=(a*(1+a)*(1/2))-(b+c-d)
print(int(e))

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

using namespace std;
typedef pair<int,int> P;
typedef long long ll;

int N;
ll a[100005],b[100005],c[100005],d[100005],e[100005];
ll f[100005];
P s[100005];

int main(){

cin.tie(0);
ios::sync_with_stdio(false);

cin>>N;

for(int i=0; i<N; i++){
  cin>>a[i];
  b[i]=a[i];
  s[i]=P(a[i],i);
}

ll add=0;
for(int i=0; i<N; i++){
  if(a[i]<a[0]) add+=a[i];
}

sort(b,b+N);

int k=0;
c[k]=b[0];

for(int i=0; i<N; i++){
  if(b[i]>c[k]){
    k++;
    c[k]=b[i];
  }
}

k=0;
int m=b[0];
for(int i=0; i<N; i++){
  if(b[i]>m){
    k++;
    m=b[i];
  }
  d[k]++;
}

sort(s,s+N);

k=0;
int l=0;
for(int i=0; i<N; i++){
  if(s[i].first>l){
    l=s[i].first;
    e[k]=s[i].second;
    k++;
  }
}

/*for(int i=0; i<k; i++){
  cout<<c[i]<<" "<<d[i]<<" "<<e[i]<<endl;
}*/

ll n=0;
int id=e[k-1];
for(int i=k-1; i>=0; i--){
  n+=d[i];
  if(e[i]==0){
    f[0]=n*c[i]+add;
    break;
  }
  ll p=(c[i]-c[i-1])*n;
  if(e[i]<id) id=e[i];
  f[id]+=p;
}

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

}


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

int main() {
    string S;
    cin >> S;
    
    ll sum=0LL;
    
    
    rep(i, 1 << (S.size()-1)){
        ll c = 0LL;
        ll a=S[0] - '0';
        bitset<9> op(i);
        rep(j, S.size()-1){
            if(op[j]){
                c += a;
                a = 0;
            } else {
                a *= 10LL;
            }
            a += S[j+1] - '0';
        }

        sum += c + a;
    }
    cout << sum << endl;
}

Measured memory_bytes: 256
#include <cmath>
#include <cstdlib>
#include <iostream>
#include <bitset>
#include <deque>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <algorithm>
#include <iterator>
#include <string>
#include <chrono>
#include <random>
#include <tuple>
#include <utility>
#include <fstream>
#include <complex>

const long INF = (1l << 30);
const long LINF = (1l << 60);

long divCeil(long x, long y){
    return (x-1)/y + 1;
}

long a, b;
int main(){
    scanf("%ld%ld", &a, &b);
    if(b == 1){
        printf("0\n");
    }else{
        printf("%ld\n", divCeil(b-1, a-1));
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <array>
#include <string>
#include <stack>
#include <queue>
#include <deque>
#include <unordered_map>
#include <unordered_set>
#include <set>
#include <tuple>
#include <cmath>
#include <algorithm>
#include <functional>
#include <numeric>
#include <cfloat>
#include <climits>
#include <cassert>
#include <random>
struct E {
	int p, h;
};
int main(){
	while (true) {
		int hp_init, hp_max; std::cin >> hp_init >> hp_max; if (hp_init == 0 && hp_max == 0) break;
		int row, column; std::cin >> row >> column;
		std::vector<std::string> state(row); for (auto& line : state) std::cin >> line;
		int t; std::cin >> t;
		std::unordered_map<char, int> damage;
		for (auto i = 0; i < t; ++i) {
			char c; int d; std::cin >> c >> d;
			damage[c] = d;
		}
		int s; std::cin >> s;
		std::vector<std::pair<char, int>> order(s); for (auto& o : order) std::cin >> o.first >> o.second;
		std::vector<std::pair<int, int>> position{ std::make_pair(0, 0) };
		for (const auto o : order) {
			for (auto i = 0; i < o.second; ++i) {
				const auto last = position.back();
				switch (o.first) {
				case 'U': position.emplace_back(last.first - 1, last.second); break;
				case 'D': position.emplace_back(last.first + 1, last.second); break;
				case 'R': position.emplace_back(last.first, last.second + 1); break;
				case 'L': position.emplace_back(last.first, last.second - 1); break;
				default: throw 0;
				}
			}
		}
		int p; std::cin >> p;
		std::vector<int> potion(p); for (auto& pi : potion) std::cin >> pi;
		std::vector<std::vector<int>> max_hp(2, std::vector<int>(1 << p, 0));
		std::deque<E> queue;
		max_hp[0][0] = hp_init; queue.push_back(E{ 0, hp_init });
		for (auto i = 0; i < position.size(); ++i) {
			const auto pos = position[i];
			const auto prev = i & 1;
			const auto current = prev ^ 1;
			std::fill(max_hp[current].begin(), max_hp[current].end(), 0);
			for (int count = queue.size(); count > 0; --count) {
				const auto top = queue.front(); queue.pop_front();
				if (max_hp[prev][top.p] != top.h) continue;
				if (max_hp[prev][top.p] <= damage[state[pos.first][pos.second]]) {
					for (auto j = 0; j < p; ++j) if ((top.p & (1 << j)) == 0) {
						if (max_hp[prev][top.p | (1 << j)] < std::min(hp_max, top.h + potion[j])) {
							queue.push_front(E{ top.p | (1 << j), std::min(hp_max, top.h + potion[j]) });
							max_hp[prev][top.p | (1 << j)] = std::min(hp_max, top.h + potion[j]);
							++count;
						}
					}
				}
				else {
					if (max_hp[current][top.p] < top.h - damage[state[pos.first][pos.second]]) {
						if (max_hp[current][top.p] == 0) queue.push_back(E{ top.p, top.h - damage[state[pos.first][pos.second]] });
						max_hp[current][top.p] = top.h - damage[state[pos.first][pos.second]];
					}
				}
			}
		}
		if (std::all_of(max_hp[position.size() & 1].begin(), max_hp[position.size() & 1].end(), [](int i) {return i == 0; })) {
			std::cout << "NO\n";
		}
		else {
			std::cout << "YES\n";
		}
	}
}



Measured memory_bytes: 3144
// May this submission get accepted!

#pragma GCC optimize ("O3")
#pragma GCC target ("tune=native")
#pragma GCC target ("avx")

#include <bits/stdc++.h>

// 汎用マクロ
#define ALL_OF(x) (x).begin(), (x).end()
#define REP(i,n) for (long long i=0, i##_len=(n); i<i##_len; i++)
#define RANGE(i,is,ie) for (long long i=(is), i##_end=(ie); i<=i##_end; i++)
#define DSRNG(i,is,ie) for (long long i=(is), i##_end=(ie); i>=i##_end; i--)
#define STEP(i, is, ie, step) for (long long i=(is), i##_end=(ie), i##_step = (step); i<=i##_end; i+=i##_step)
#define UNIQUE(v) do { sort((v).begin(), (v).end()); (v).erase(unique((v).begin(), (v).end()), (v).end()); } while (false)
template<class T> bool chmax(T &a, const T &b) {if (a < b) {a = b; return true;} return false; }
template<class T> bool chmin(T &a, const T &b) {if (a > b) {a = b; return true;} return false; }
#define INF 0x7FFFFFFF
#define LINF 0x7FFFFFFFFFFFFFFFLL
#define Yes(q) ((q) ? "Yes" : "No")
#define YES(q) ((q) ? "YES" : "NO")
#define Possible(q) ((q) ? "Possible" : "Impossible")
#define POSSIBLE(q) ((q) ? "POSSIBLE" : "IMPOSSIBLE")
#define DUMP(q) cerr << "[DEBUG] " #q ": " << (q) << " at " __FILE__ ":" << __LINE__ << endl
#define DUMPALL(q) do { cerr << "[DEBUG] " #q ": ["; REP(i, (q).size()) { cerr << (q)[i] << (i == i_len-1 ? "" : ", "); } cerr << "] at " __FILE__ ":" << __LINE__ << endl; } while (false)
template<class T> T gcd(const T &a, const T &b) { return a < b ? gcd(b, a) : b ? gcd(b, a % b) : a; }
template<class T> T lcm(const T &a, const T &b) { return a / gcd(a, b) * b; }

// gcc拡張マクロ
#define popcount __builtin_popcount
#define popcountll __builtin_popcountll

// エイリアス
#define DANCE_ long
#define ROBOT_ unsigned
#define HUMAN_ signed
#define CHOKUDAI_ const
using  ll = DANCE_ HUMAN_ DANCE_;
using ull = DANCE_ ROBOT_ DANCE_;
using cll = DANCE_ DANCE_ CHOKUDAI_;
using  ld = long double;
using namespace std;

// モジュール


// 処理内容
int main() {
    
    ios::sync_with_stdio(false);
    cin.tie(0);
    
    ll n, m; cin >> n >> m;
    vector<ll> a(m), b(m);
    vector<vector<ll>> c(m);
    REP(i, m) {
        cin >> a[i] >> b[i];
        c[i] = vector<ll>(b[i]);
        REP(j, b[i]) {
            cin >> c[i][j];
            --c[i][j]; // 0-indexed
        }
    }

    constexpr ll MINF = 10000000000LL; // 10^10
    vector<ll> dp(1LL << n, MINF);
    dp[0] = 0;
    REP(j, m) {
        ll mask = 0;
        REP(i, b[j]) {
            mask |= 1LL << c[j][i];
        }
        REP(i, 1LL << n) {
            chmin(dp[i | mask], dp[i] + a[j]);
        }
    }

    if (dp[(1LL << n) - 1] == MINF) {
        cout << -1 << endl;
    } else {
        cout << dp[(1LL << n) - 1] << endl;
    }

    
}

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

#define ll long long
#define mod 1000000007
#define ffor(i,a,b) for(int i=a;i<b;i++)
#define bfor(i,a,b) for(int i=a-1;i>=b;i--)
#define mp make_pair
#define pb push_back
#define ff first
#define ss second
#define mem(x,y) memset(x,y,sizeof(x))
#define all(x) x.begin(),x.end()
#define SP(x) setprecision(x)
#define sz(x) (int)x.size()
#define fast  ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define PI 3.14159265358979323846
#define lb lower_bound
#define ub upper_bound
#define bs binary_search
#define endl '\n'

int main()
{
    

    ffor(i,1,6)
    {
        int x;
        cin>>x;
        if(!x)
        {
            cout<<i;
            return 0;
        }
    }
    
    return 0;
}



Measured memory_bytes: 3620
#include<cstdio>
#include<algorithm>
using namespace std;
const int maxn=100005;
int n;
long long a[maxn];
void scanff()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
	}
	sort(a+1,a+n+1);
}
long long ans=0;
long long val[11];
long long nums[11];
int cnt=0;
void work()
{
	for(int i=n;i>=1;)
	{
		if(a[i]==a[i-1])
		{
			val[++cnt]=a[i];
			nums[cnt]=2;
			if(cnt==2)break;
			if(i>=3)
			{
				i-=2;
			}else
			{
				break;
			}
		}else
		{
			i--;
		}
	}
	if(cnt<2)
	{
		printf("0");
	}else
	{
		printf("%lld",val[1]*val[2]);
	}
}
int main()
{
	scanff();
	work();
	return 0;
}


Measured memory_bytes: 896
#include<stdio.h>
#define MAX 200000

int main(){
  int R[MAX],i,n=0;
  int max = -2000000000;

  scanf("%d",&n);

  for(i = 0; i < n; i++ ) scanf("%d",&R[i]);

 int min = R[0];
  for(i = 1; i < n; i++ ){
    if(max < (R[i] - min)) max = (R[i] - min);
    if(min > R[i]) min = R[i];
  }

  printf("%d\n",max);

  return 0;
}




Measured memory_bytes: 2568
h, w = map(int, input().split())
grid = [[0]*(w+2) for _ in range(h+2)]

black = []
for i in range(h):
    for j, k in enumerate(input()):
        if k == "#":
            black.append((i + 1, j + 1))
            grid[i+1][j+1] = 1

ans = 0
d = ((0, 1),
     (1, 0),
     (0, -1),
     (-1, 0),)
while True:
    paint = []
    while black:
        x, y = black.pop()
        if x == 0 or x == h + 1 or y == 0 or y == w + 1:
            continue
        else:
            for nx, ny in d:
                if not grid[nx + x][ny + y]:
                    if x+nx == 0 or x+nx == h + 1 or y+ny == 0 or y+ny == w + 1:
                        continue
                    grid[nx + x][ny + y] = 1
                    paint.append((nx + x, ny + y))

    if len(paint) == 0:
        break
    black = paint[:]
    ans += 1

print(ans)


Measured memory_bytes: 123344
using System;
using System.IO;
using System.Collections.Generic;
using System.Text.RegularExpressions;
using System.Linq;

namespace atcoder_past_problem
{
    class Program
    {
        static void Main(string[] args)
        {
            new Program().Solve(new Input(Console.In));
        }

        public void Solve(Input input)
        {
            var x = input.ReadInt;
            while (true)
            {
                if (x == 2)
                {
                    Console.WriteLine(2);
                    return;
                }

                if (Solve2(x))
                {
                    Console.WriteLine(x);
                    return;
                }
                x++;
            }
        }
        public bool Solve2(int x)
        {
            int b = x / 2;
            for (var i = 3; i <= b; i++)
            {
                if (x % i == 0)
                {
                    x++;
                    return false;
                }
            }
            return true;
        }
    }



    public class Input
    {
        private TextReader Stream { get; }
        private char Separator { get; }
        private Queue<string> InputStream { get; }

        public Input(TextReader stream, char separator = ' ')
        {
            Stream = stream;
            Separator = separator;
            InputStream = new Queue<string>();
        }

        public string Read
        {
            get
            {
                if (InputStream.Count != 0) return InputStream.Dequeue();
                string[] tmp = Stream.ReadLine().Split(Separator);
                for (int i = 0; i < tmp.Length; ++i)
                    InputStream.Enqueue(tmp[i]);
                return InputStream.Dequeue();
            }
        }

        public string ReadLine => Stream.ReadLine();
        public int ReadInt => int.Parse(Read);
        public long ReadLong => long.Parse(Read);
        public double ReadDouble => double.Parse(Read);
        public int[] ReadIntArray => Stream.ReadLine().Split(Separator).Select(i => int.Parse(i)).ToArray();
        public long[] ReadLongArray => Stream.ReadLine().Split(Separator).Select(l => long.Parse(l)).ToArray();
    }
}


Measured memory_bytes: 13268
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <string>
#include <sstream>
#include <vector>
#include <map>
#include <set>
#include <complex>
#include <functional>
#include <utility>
#include <iterator>

#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, m, n) for(int i = (m); i < (int)(n); ++i)
#define ALL(x) (x).begin(), (x).end()
#define INF 2000000000
//#define int long long int

#ifdef LOCAL
  #define eprintf(...) fprintf(stdout, __VA_ARGS__)
#else
  #define eprintf(...) 0
#endif

using namespace std;

typedef long long LL;
typedef unsigned long long ULL;
typedef unsigned int uint;

int main() {
  int n, k;
  cin >> n >> k;
  int x;
  int ans = 0;
  eprintf("n:%d k:%d\n", n,k);
  REP(i, n) {
    cin >> x;
    eprintf("%d\n", x);
    int m = min(x, abs(k-x));
    eprintf("m:%d\n", m);
    ans += m*2;
  }
  cout << ans;

  return 0;
}


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

def factor(n):
    factList = []
    i = 1
    while i * i <= n:
        if n % i == 0:
            factList.append(i)
            factList.append(n // i)
        i += 1

    factList.sort()
    return factList

fact = factor(N)

ans = float('inf')
for i in range(len(fact)):
    f = max(len(str(fact[i])), len(str(fact[-1 - i])))
    ans = min(ans, f)

print(ans)

Measured memory_bytes: 3064
import java.util.Scanner;

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

        int start[] = new int[n+1];
        int finish[] = new int[n+1];

        for (int i=0; i < m; i++){
            int c1 = sc.nextInt();
            int c2 = sc.nextInt();
            if (c1 == 1){
                start[c2] = 1;
            }
            if (c2 == n){
                finish[c1] = 1;
            }
        }
 
        boolean flg=false;
        for(int i=0; i<n; i++) {
            if (start[i] == 1) {
                if (finish[i] == 1) {
                    flg = true;
                    break;
                } 
            }
        }
        
        if(flg){
            System.out.println("POSSIBLE");
        }else{
            System.out.println("IMPOSSIBLE");
        }
 
    }
}

Measured memory_bytes: 98684
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

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

typedef long long int ll;

int read_int()
{
    int a;
    scanf("%d", &a);
    return a;
}

int read_lint()
{
    ll a;
    scanf("%lld", &a);
    return a;
}

int read_float()
{
    float a;
    scanf("%f", &a);
    return a;
}

int read_double()
{
    double a;
    scanf("%lf", &a);
    return a;
}

void read_string(char *s)
{
    scanf("%s", s);
}

int cnt[4];

int main()
{
    int n = read_int();
    for (int i = 0; i < n; i++)
    {
        char s[4] = {0};
        read_string(s);
        if (strcmp(s, "AC\0\0") == 0)
        {
            cnt[0]++;
        }
        else if (strcmp(s, "WA\0\0") == 0)
        {
            cnt[1]++;
        }
        else if (strcmp(s, "RE\0\0") == 0)
        {
            cnt[3]++;
        }
        else
        {
            cnt[2]++;
        }
    }
    printf("AC x %d\n", cnt[0]);
    printf("WA x %d\n", cnt[1]);
    printf("TLE x %d\n", cnt[2]);
    printf("RE x %d\n", cnt[3]);

    return 0;
}

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

int main() {
  
  string s;
  
  cin >> s;
  
  int count=0;
  
  for(int i=0; i<4; i++) {
    
    if(s.at(i)=='+') {
      
      count++;
      
    } else if(s.at(i)=='-') {
      
      count--;
      
    }
    
    
  }
  
  cout << count << endl;
    
}

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

int main()
{
	int n;
	cin>>n;
	int out=0;
	for(int a=105;a<=n;a+=2)
	{
		int cnt=0;
		for(int b=1;b*b<=a;b++)
		{
			if(a%b==0)
			{
				cnt++;
				if(b!=(a/b)) cnt++;
			}
		}
		if(cnt==8)
		{
			out++;
		}
	}
	cout<<out<<endl;
	return 0;
}

Measured memory_bytes: 256
// Problem : A - Round Up the Mean
// Contest : AtCoder - AtCoder Beginner Contest 082
// URL : https://atcoder.jp/contests/abc082/tasks/abc082_a
// Memory Limit : 256 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

//#pragma GCC optimize("Ofast")
//#pragma GCC optimize ("unroll-loops")
//#pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define eb emplace_back
#define pb push_back
#define size(s) (int)s.size()
#define int long long
#define vi vector<int>
#define vs vector<string>
#define vv vector<vector<int>>
#define pii pair<int,int>
#define m_p(x,y) make_pair(x,y)
#define vp vector<pair<int,int>>
#define setbits(x) __builtin_popcountll(x)
#define f first
#define se second
#define inc(v,n,x) v.assign(n,x)
#define incd(v,n) v.resize(n)
#define iniz(n) memset(n,0,sizeof(n))
#define inin(n) memset(n,-1,sizeof(n))
#define inimi(n) memset(n,0xc0,sizeof(n))
#define inima(n) memset(n,0x3f,sizeof(n))
#define all(v) (v).begin(),(v).end()

using namespace std;

template<typename T1,typename T2>istream &operator>>(istream &is, vector<pair<T1,T2>> &v) { for (pair<T1,T2> &t : v) is >> t.f>>t.se; return is; }
template<typename T>istream &operator>>(istream &is, vector<T> &v) { for (T &t : v) is >> t; return is; }
template<typename T>ostream &operator<<(ostream &os, const vector<T> &v) { for (const T &t : v) {os << t <<" ";} os << '\n'; return os; }

const int N=200001;
double pi=acos(-1.0);
int md=1e9+7;
const int INF=1e15;
int dx1[]={0,0,-1,1};
int dy1[]={1,-1,0,0};

template<class T>
T abst(T a)
{return a<0?-a:a;}

void solve()
{
	int a,b;cin>>a>>b;
	cout<<(a+b+1)/2;
}

int32_t main(){
ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL);
int t=1;
//cin>>t;
for(int i=1;i<=t;i++)
{
    solve();
}
return 0;
}


Measured memory_bytes: 3656
#include<iostream>
#include<map>
#include<vector>
#include<algorithm>
#include<cmath>
#include<climits>
#include<ctime>
#include<cstring>
#include<stack>
#include<queue>
#include<sstream>
#include<string>
#include<set>
#include<array>
#include<cassert>

#define ALL(v) (v).begin(),(v).end()
#define REP(i,p,n) for(int i=p;i<(int)(n);++i)
#define rep(i,n) REP(i,0,n)
#define DUMP(list) cout << "{ "; for(auto nth : list){ cout << nth << " "; } cout << "}" << endl
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i);

using namespace std;

int dp[100001];
int a[100001];

const int INF = 1000000000;

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

	fill_n((int *)dp,sizeof(dp)/sizeof(int),INF);
	
	rep(i,n) cin >> a[i];

	rep(i,n){
		*lower_bound(dp,dp+n,a[i])=a[i];	
	}

	cout << lower_bound(dp,dp+n,INF)-dp << endl;

	return 0;
}

Measured memory_bytes: 1940