akhauriyash/Code-Regression huggingface dataset:
import sys
input = sys.stdin.buffer.readline

def main():
    N = int(input())
    
    h = map(int,input().split())
    a = map(int,input().split())
    
    def segfunc(x,y):
        return max(x,y)
        
    def init(init_val):
        for i in range(N+1):
            seg[i+num-1] = init_val[i]
        for i in range(num-2,-1,-1):
            seg[i] = max(seg[2*i+1],seg[2*i+2])
    
    def update(k,x):
        k += num-1
        seg[k] = x
        while k:
            k = (k-1)//2
            seg[k] = segfunc(seg[2*k+1],seg[2*k+2])
            
    def query(p,q):
        if q <= p:
            return ide_ele
        p += num-1
        q += num-2
        ret = ide_ele
        while q-p>1:
            if p&1 == 0:
                ret = segfunc(ret,seg[p])
            if q&1 == 1:
                ret = segfunc(ret,seg[q])
                q -= 1
            p = p//2
            q = (q-1)//2
        ret = segfunc(segfunc(ret,seg[p]),seg[q])
        return ret
        
    ide_ele = 0
    num = 2**N.bit_length()
    seg = [ide_ele]*2*num

    dp = [0]*(N+1)
    
    for he,be in zip(h,a):
        tmp = query(0,he)+be
        if tmp > dp[he]:
            dp[he] = tmp
            update(he,tmp)
    
    print(query(0,N+1))

if __name__ == "__main__":
    main()


Measured memory_bytes: 92252
#include <math.h>
#include <assert.h>

#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

template <typename A, typename B>
std::ostream& operator<<(std::ostream& os, std::pair<A, B>& v) {
    return os << "(" << v.first << " " << v.second << ")";
}

template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T>& v) {
    os << "[ "; for (auto &i: v) os << i << " "; return os << "]";
}

template <typename T>
void eout(const char *s, T H) {
    std::cerr << s << "=" << H << "\n";
}

template <typename T1, typename... T2>
void eout(const char *s, T1 H, T2... T) {
    while (*s != ',') std::cerr << *s++;
    std::cerr << "=" << H << " | "; eout(++s, T...);
}

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(args...)      std::cerr << "DBG:"; eout(#args, args)

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define sz(v)             ((int) v.size())
#define all(v)            (v).begin(), (v).end()

#define no                std::cout << "NO\n"
#define yes               std::cout << "YES\n"

#define INF    	          2147483647
#define LNF               9223372036854775807LL

using ll  = long long int;
using vi  = std::vector<int>;
using vb  = std::vector<bool>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

int solve();
int main() {
    std::ios_base::sync_with_stdio(0); std::cin.tie(0); std::cout.tie(0);

    //inn(t); repr(tc, 1, t + 1)
    (void) solve();

    return 0;
}

int solve() {
    inn(n);
    vi d(n); rep(i, n) in(d[i]);

    ll s = 0; rep(i, n) if (~i&1) s += (ll) d[i]; else s -= (ll) d[i];
    std::vector<ll> a(n); a[0] = s;

    rep(i, n - 1) {
        a[i + 1] = (ll) 2 * d[i] - a[i];
    }
    for (ll i: a) out(i);
    return 0;
}


Measured memory_bytes: 2560
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
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; }

#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;

int powMod(int n, int p, int mod) {
  int res = 1;
  while (p) {
    if (p & 1) (res *= n) %= mod;
    (n *= n) %= mod;
    p >>= 1;
  }
  return res;
}

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

  vector<int> one;
  REP(i, N) if(s[i] == '1') one.emplace_back(i);

  int a = 0, b = 0;
  REP(i, N){
    if(s[i] == '1'){
      a += powMod(2, N-1-i, one.size()+1);
      if((int)one.size()-1 >= 1) b += powMod(2, N-1-i, one.size()-1);
    }
    a %= one.size()+1;
    if((int)one.size()-1 >= 1){
      b %= one.size()-1;
    }
  }

  vector<int> dp(N+1, 1);
  FOR(i, 1, N+1){
    int cnt = __builtin_popcountll(i);
    dp[i] = dp[i%cnt]+1;
  }

  REP(i, N){
    if(s[i] == '1'){
      if(one.size() == 1) cout << 0 << "\n";
      else{
        int t = (b-powMod(2, N-1-i, one.size()-1))%((int)one.size()-1);
        if(t < 0) t += one.size()-1;
        cout << dp[t] << "\n";
      }
    }else{
      int t = (a+powMod(2, N-1-i, one.size()+1))%((int)one.size()+1);
      if(t < 0) t += one.size()+1;
      cout << dp[t] << "\n";
    }
  }

  return 0;
}


Measured memory_bytes: 5764
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(v) v.begin(), v.end()


int main(){
    int x, y;
    cin >> x >> y;
    for(int i = 0; i <= x; i++){
        int j = x - i;
        if(2*i+4*j == y){
                cout << "Yes" << endl;
                return 0;
        }
    }

    cout << "No" << endl;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int n,k,q;
    cin >> n >> k >> q;
    int a[n];
    rep(i,n)cin >> a[i];
    int ans = 1001001001;
    int f[n] = {};

    rep(loop,n){
        vector<int> v;
        int i = 0;
        while(i<n){
            priority_queue<int> que;
            while(i<n){
                if(f[i] == 0){
                    que.push(-a[i]);
                    i++;
                }else{
                    i++;
                    break;
                }
            }
            while(que.size() >= k){
                v.push_back(-que.top());
                que.pop();
            }
        }
        if(v.size() >= q){
            sort(v.begin(), v.end());
            ans = min(ans, v[q-1] - v[0]);
        }
        int mi = 1001001001;
        int arg = 0;
        rep(j,n){
            if(f[j] == 0 && a[j] < mi){
                mi = a[j];
                arg = j;
            }
        }
        f[arg] = 1;
        
    }

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


Measured memory_bytes: 256
s=[int(i) for i in input()]
s.reverse()

a=0
l=[0 for i in range(2019)]
l[0]=1
b=0.1
for i in range(len(s)):
  b=int(b*10)
  b%=2019
  a+=s[i]*b
  a%=2019
  l[a]+=1

answer=0
for i in range(2019):
  answer+=l[i]*(l[i]-1)//2
  
print(answer)

Measured memory_bytes: 75884
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, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}
use std::cmp::max;
fn main(){
    input!{
        s:chars
    };
    let master = vec!['A','C','G','T'];
    let mut ans = 0;
    let len = s.len();
    for i in 0..len {
        let mut  count = 0;
        for j in i..len {
            if master.contains(&s[j]) {
                count += 1;
            } else {
                break;
            }
        }
        ans = max(count,ans);
    }
    println!("{}",ans);
}

Measured memory_bytes: 4352
#include<bits/stdc++.h>
#define rep(i, n) for(int i=0;i<(n);++i)
#define per(i, n) for(int i=(n)-1;i>=0;--i)
#define repa(i, n) for(int i=1;i<(n);++i)
#define foreach(i, n) for(auto &i:(n))
#define pii pair<int, int>
#define pll pair<long long, long long>
#define all(x) (x).begin(), (x).end()
#define bit(x) (1ll << (x))
using ll = long long;
const ll MOD = (ll)1e9+7;
//const ll MOD = 998244353;
const int INF = (ll)1e9+7;
const ll INFLL = (ll)1e18;
using namespace std;
template<class t>
using vvector = vector<vector<t>>;
template<class t>
using vvvector = vector<vector<vector<t>>>;
template<class t>
using priority_queuer = priority_queue<t, vector<t>, greater<t>>;
template<class t, class u> bool chmax(t &a, u b){if(a<b){a=b;return true;}return false;}
template<class t, class u> bool chmin(t &a, u b){if(a>b){a=b;return true;}return false;}
#ifdef DEBUG
#define OUTPUT(x) (output(x), output("\n"))
#else
#define OUTPUT(x) (void)0
#endif

ll modpow(ll x, ll b){
    ll res = 1;
    while(b){
        if(b&1)res = res * x % MOD;
        x = x * x % MOD;
        b>>=1;
    }
    return res;
}

ll modinv(ll x){
    return modpow(x, MOD-2);
}

bool was_output = false;
template<class t>
void output(t a){
    if(was_output)cout << " ";
    cout << a;
    was_output = true;
}
void outendl(){
    was_output = false;
    cout << endl;
}
ll in(){
    ll res;
    scanf("%lld", &res);
    return res;
}

template<class t>
istream& operator>>(istream& is, vector<t> &x){
    for(auto &i:x)is >> i;
    return is;
}

template<class t, class u>
istream& operator>>(istream& is, pair<t, u> x){
    is >> x.first >> x.second;
    return is;
}

ll C(ll a, ll b){
    ll res = 1;
    rep(i, b){
        res *= (a-i) * modinv(i+1) % MOD;
        res %= MOD;
    }
    return res;
}

int main(){
    ll n = in();
    ll a = in();
    ll b = in();
    ll res = modpow(2, n) % MOD;
    res -= C(n, a) + C(n, b) + 1;
    res %= MOD;
    res += MOD;
    res %= MOD;
    cout << res << endl;
    return 0;
}


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

int main() {
  ll a, b, c;
  cin >> a >> b >> c;
  ll d = c - a - b;
  if(d > 0 && d * d > 4*a*b) cout << "Yes" << endl; 
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3644
// finish date: 2018/08/13
#include <bits/stdc++.h>

using namespace std;

#define FOR(i, a, b) for(int (i)=a;(i)<(b);(i)++)
#define rep(i, n)  FOR(i,0,n)
typedef long long ll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<vector<vector<int>>> vvvi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<double> vd;
typedef vector<vector<double>> vvd;
typedef vector<vector<vector<double>>> vvvd;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, pair<int, int>> plii;
const int bigmod = 1000000007;
const int INF = 1050000000;
const long long INFll = 100000000000000000;


int main() {
    int N;
    cin >> N;
    vi a(N);
    rep(i, N) cin >> a[i];
    int cnt = 0;
    FOR(i, 1, N) {
        if (a[i - 1] == a[i]) cnt++, a[i] = -1;
    }
    cout << cnt << endl;

    return 0;
}



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

int main(){
  int numA, numB, sum = 0;
  cin >> numA >> numB;
  for(numA; numA <= numB; numA++){
    int s = numA % 10;
    int t = numA / 10000 % 10;
    int x = numA / 10 % 10;
    int y = numA / 1000 % 10;
    if(s == t && x == y)
      sum++;
  }
    
    cout << sum << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val S = next()
    val ans = when (S) {
        "SUN" -> 7
        "MON" -> 6
        "TUE" -> 5
        "WED" -> 4
        "THU" -> 3
        "FRI" -> 2
        "SAT" -> 1
        else -> 0
    }
    println("${ans}")
}
fun next() = readLine()!!
fun nextLong() = next().toLong()

Measured memory_bytes: 29740
n = int(input())
hight = list(map(int,input().split()))
dp = [0] + [10**10]*(n-1)

for i in range(1,n):
    dp[i] = min(dp[i], dp[i-1]+abs(hight[i]-hight[i-1]))
    if i > 1:
        dp[i] = min(dp[i], dp[i-2]+abs(hight[i]-hight[i-2]))
print(dp[-1])

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

int main()
{
	int N;
	cin >> N;
	bool ans = false;
	for (int i = 0; i <= 25; i++) {
		for (int j = 0; j <= 13; j++) {
			if (4 * i + 7 * j == N) 
				ans = true;
		}
	}
	if (ans)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <map>
#include <stack>
#include <tuple>
#include <queue>
#include <vector>
#include <cmath>
#include <math.h>
#include <random>



#define REP(i, n) for(int (i) = 0; (i) < (n); ++(i))
#define rREP(i, n) for(int (i) = (n) - 1; (i) >= 0; --(i))
#define ALL(TheArray) TheArray.begin(), TheArray.end()

using lli = long long int;
using pii = std::pair<int, int>;

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;
}

// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~


/* (考察欄)
    中央値の全列挙では間に合わない : 組み合わせだけでO(N^2)
    解はいずれかのaj であるからこれを全探索 or 二分探索で O(NlogN)なら間に合いそう
    判定はO(logN)は厳しそう => 二分探索 with 判定 O(N) が現実的

    二分探索 ~~~> ① 単調性はあるか ? (どんな単調性を見出す ?)
                    その単調性において, [中央値] 最大性or最小性は？
            ~~~> ② 判定は O(N) 程度で可能か ?
    
    ・ 単調性 ~~~> 数列内での"順位" : 
                  「 自身以下の数が"半分"以上ある 」部分列の数が最小 (?)
                  中央値未満 => 以下の数は L/2 以下
                  中央値以上 => 以下の数は L/2 + 1以上
                  ~~~> (以下の数) > (超過の数) <=> 中央値以上の値
                  n(n-1)/4 + 1 overの最小

        ・ then, 自分以下の数が半分以上ある部分列の数は数えられるか O(N) 程度
           全ての数列から自身の値を比較 => 以下 or 超過 の bool で管理可能
           数を累積和使って計算すれば早く答えられる？でもO(N^2)はかかる

    (結論) : わからん！   O(N^2logN)
*/


/* (解説後)
    ① : bool型のものを長さの半分以上か判定するのに, 1と-1を使えば長さに無依存に判定が可能
    ② : 転倒数を学べ
*/

class Bit{ // 1-indexedに注意
    const int n; // 最大値
    std::vector<int> bit;
public:
    Bit(int nn): n(nn){
        bit.resize(n+1, 0);
    }
    // 0で再初期化
    bool clear(){
        std::fill(bit.begin(), bit.end(), 0);
        return true;
    }
    // A[idx]にvalを加算
    bool add(int idx, int val){
        if(n < idx) return false;
        for(int i = idx; i <= n; i += (i & (-i))) bit[i] += val;
        return true;
    }
    // 区間[1, 2, ..., a]の和
    int sum(int idx){
        int res = 0;
        for(int i = idx; i > 0; i -= (i & (-i))) res += bit[i];
        return res;
    }
};

std::vector<int> A, SA;

int main(void){
    int n; scanf("%d", &n);
    A.resize(n); REP(i, n) scanf("%d", &A[i]);
    SA = A; std::sort(SA.begin(), SA.end());
    

    Bit BT(2 * (n + 1));

    lli MSize = n; MSize *= (n+1); MSize /= 2;

    // 二分探索
    int ok = n-1 , ng = -1;
    while(ok - ng > 1){
        
        int t = (ok + ng) / 2;
        int v = SA[t];
                // 判定部分
                BT.clear();
                int S = n+1; BT.add(S, 1);
                lli cnt = 0; // l < r であって, S_l < S_r なるものを数える
                for(int i = 0; i < n; ++i){
                    if(A[i] <= v) S++; else S--;
                    cnt += BT.sum(S-1);
                    BT.add(S, 1);
                }
                // S_l < S_r なるものは MSize - cnt
        
        
        if(MSize - cnt < cnt ) ok = t;
        else ng = t;
    }
    printf("%d\n", SA[ok]);
    

    return 0;
}

Measured memory_bytes: 1792
//B
#include<bits/stdc++.h>
#define se second
#define fi first
#define all(v) v.begin(), v.end()
#define mp make_pair
#define pb push_back

using namespace std;
typedef long long LL;
const LL MOD = 1e9 + 7;
const double PI = 2 * acos(0);

int main() {
	string S, T;
	int ans = 0;
	cin >> S >> T;
	int l = S.length(), l2 = T.length();
	for (int i = 0; i < l - l2 + 1; i++) {
		int cnt = 0;
		for (int j = i; j < i + l2; j++) {
			cnt += S[j] == T[j - i]; 
		}
		ans = max(ans, cnt);
	}
	printf("%d\n", l2 - ans);
}

Measured memory_bytes: 3688
n,k = map(int,input().split())
h = []
for i in range(n):
    h.append(int(input()))
#ここまで入力
h.sort()
mn = 10**9
for i in range(n-k+1):
    if mn > (h[i+k-1]-h[i]):
        mn = h[i+k-1]-h[i]
print(mn)  

Measured memory_bytes: 50392
n = int(input())
ab = [list(map(int, input().split())) for i in range(n)]
ab.sort(key=lambda x: x[1])
"""
締め切りの早いものから実施。
作業時間が締め切りをオーバーしたらFalse
"""

f = True
total = 0
for i in range(n):
    total += ab[i][0]
    if total > ab[i][1]:
        f = False
        break
if f:
    print('Yes')
else:
    print('No')	 

Measured memory_bytes: 53728
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int x = Integer.parseInt(sc.next());
		int a = Integer.parseInt(sc.next());
		int b = Integer.parseInt(sc.next());
		
		System.out.println((x-a)%b);
	}
}


Measured memory_bytes: 22612
//#include "bits/stdc++.h"

#define _USE_MATH_DEFINES
#include<cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <deque>
#include <algorithm>
#include <functional>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <iterator>

using namespace std;

#define rep(i,a,b) for(int i=(a), i##_len=(b);i<i##_len;i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)

#define int ll
#define SZ(x) ((int)(x).size())
#define pb push_back
#define mp make_pair

//typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<ll, int> pli;
typedef pair<double, double> pdd;
typedef vector< vector<int> > mat;

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 (b < a) { a = b; return true; } return false; }

const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;

signed main()
{
	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	cin >> N;

	if (N % 2 == 1)
	{
		cout << N * 2 << endl;
	}
	else
	{
		cout << N << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return 1;
    }
    return 0;
}
typedef long long int ll;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
#define endl "\n"
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
const int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int k;
    cin >> k;
    vector<ll> a(k);
    for(int i = 0; i < k; i++) {
        cin >> a[i];
    }
    reverse(ALL(a));
    ll mn = 2, mx = 2;
    for(int i = 0; i < k; i++) {
        if(mx / a[i] == (mn - 1) / a[i]) {
            cout << -1 << endl;
            return 0;
        }
        mx = (mx / a[i] + 1) * a[i] - 1;
        mn = (mn + a[i] - 1) / a[i] * a[i];
    }
    cout << mn << ' ' << mx << endl;
}


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

using namespace std;
#define rep(i,n) for(long long i=0; i<(long long)(n);i++)
//rep…「0からn-1まで」の繰り返し
#define rep2(i,s,n) for(long long i=s; i<=(long long)(n);i++)
//rep2…「sからnまで」の繰り返し
#define repr(i,s,n) for(long long i=s;i>=(long long)(n);i--)
//repr…「ｓからnまで」の降順の繰り返し

typedef long long ll;

const int inf = 1e9+7;
const int mod = 1e9+7;

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

    ll amax=0;

    vector<ll>a(n+1),b(m+1);
    bool jdg=true;

    rep(i,n){
        ll A;
        cin>>A;

        //aの塁積時間の配列を作る
        a[i+1]=a[i]+A;

        //初めて累積時間がk分を超えたとき、超えるひとつ前の累積冊数をamax冊とする
        //(bが0冊ならaはamax冊読める)
        if(jdg==true&&a[i+1]>k){
            amax=i;
            jdg=false;
        }
    }
    //aを全部足してもk分以下の時
    if(jdg)amax=n;

    rep(i,m){
        ll B;
        cin>>B;

        //の塁積時間の配列を作る
        b[i+1]=b[i]+B;
    }

    ll ans=0;

    //aが0冊～amax冊までを調べる
    rep(i,amax+1){
        //bmax=(k分-aをi冊読んだ累積時間)以下のbの個数-1
        //→aをi冊読んだ残り時間内で読めるbの冊数
        ll bmax=upper_bound(b.begin(),b.end(),k-a[i])-b.begin()-1;

        //この組み合わせで読めるaとbの合計冊数の最大値
        ans=max(ans,i+bmax);
    }

    cout<<ans<<endl;
}

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

int main() {
  string s;
  cin >> s;
  if(s[0] == s[1] && s[2] == s[3] && s[0] != s[2]) puts("Yes");
  else if(s[0] == s[2] && s[1] == s[3] && s[0] != s[1]) puts("Yes");
  else if(s[0] == s[3] && s[1] == s[2] && s[0] != s[1]) puts("Yes");
  else puts("No");
}

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

int n,m,k,l,a[100][100];

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


Measured memory_bytes: 3104
import java.io.*;

public class Main {
	public static void main(String[] args)throws IOException {
		BufferedReader br = new BufferedReader (new InputStreamReader(System.in));
		
		int n = Integer.parseInt(br.readLine());  //?????£??????????????????????????°?????\????????????
	    String[] cards ;
	    
   //??¨???????????????????¨????????????¶?????????????????????????????????.
	    Boolean[] S = new Boolean[13];
	    Boolean[] H = new Boolean[13];
	    Boolean[] C = new Boolean[13];
	    Boolean[] D = new Boolean[13];
	    
	    for(int i = 0; i < 13 ; i++) {
	    	S[i] = false ;
	    	H[i] = false ;
	    	C[i] = false ;
	    	D[i] = false ;
	    }
	
	//?????£??????????????????????????¨???????????????????¨?????????\???????????????????????????
	    for(int j = 0 ; j < n ; j ++) {
	    	cards = br.readLine().split(" ");
	    	int x = Integer.parseInt(cards[1]);
	    	
	//??????????????¶????????????????????????   	
	    	switch(cards[0].charAt(0)){
	    	      case 'S' : S[x-1] = true ; break ;
	    	      case 'H' : H[x-1] = true ; break ;
	    	      case 'C' : C[x-1] = true ; break ;
	    	      case 'D' : D[x-1] = true ; break ;
	    	}
	    }
	 
	//4?¨???????????????????????????£????????????????????????????????????????????????????????????    
	    int j = 0 ;
	    while( j < 4) {
	    	for(int i = 0; i < 13 ; i++) {
	    		switch(j) {
	    		      case 0 : if( S[i] == false ) 
	    		       System.out.println("S" + " " + (i+1)); break ;
	    		      case 1 : if( H[i] == false ) 
   		    	       System.out.println("H" + " " + (i+1)); break ;
	    		      case 2 : if( C[i] == false ) 
   		    	       System.out.println("C" + " " + (i+1)); break ;
	    		      case 3 : if( D[i] == false ) 
   		    	       System.out.println("D" + " " + (i+1)); break ;
	    		}
	    	}
	    	j++;
	    }
	    
	}
}

Measured memory_bytes: 24160
#include<bits/stdc++.h>
using namespace std;
int main(){
    while(1){
        string s;
        int m;
        cin >> s >> m;
        if(s=="-")break;
        vector<int>h(m);
        for(int i=0;i<m;i++){
            cin >> h[i];
            string cat = s.substr(0,h[i]);
            s.erase(0,h[i]);
            s+=cat;
        }
        cout << s << endl;
    }
}


Measured memory_bytes: 3176
import sys
input = sys.stdin.readline
import math

def INT(): return int(input())
def MAPINT(): return map(int, input().split())
def LMAPINT(): return list(map(int, input().split()))
def STR(): return input()
def MAPSTR(): return map(str, input().split())
def LMAPSTR(): return list(map(str, input().split()))

f_inf = float('inf')

x, n = LMAPINT()
if n == 0:
  _ = input()
  print(x)
  exit()

p = LMAPINT()
for i in range(100):
  if (x-i) not in p:
    print(x-i)
    exit()
  if (x+i) not in p:
    print(x+i)
    exit()

Measured memory_bytes: 62164
#include <iostream>

using namespace std;

int main(){
  int N,M;
  int a,b;
  int i;
  int count[50]={0};
  cin >> N >> M;
  for(i=0;i<M;i++){
    cin >> a >> b;
    count[a-1]++;
    count[b-1]++;
  }
  for(i=0;i<N;i++){
    cout << count[i] << endl;
  }
  return 0;
}



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

using namespace std;

struct UnionFind
{
  vector< int > data;

  UnionFind(int sz)
  {
    data.assign(sz, -1);
  }

  bool unite(int x, int y)
  {
    x = find(x), y = find(y);
    if(x == y) return (false);
    if(data[x] > data[y]) swap(x, y);
    data[x] += data[y];
    data[y] = x;
    return (true);
  }

  int find(int k)
  {
    if(data[k] < 0) return (k);
    return (data[k] = find(data[k]));
  }

  int size(int k)
  {
    return (-data[find(k)]);
  }
};

struct LowLink
{
  UnionFind uf;
  vector< vector< int > > g;
  vector< int > used, ord, low, parent;

  LowLink(size_t v) : g(v), used(v, 0), ord(v), low(v), uf(v), parent(v, -1) {}

  virtual void add_edge(int x, int y)
  {
    g[x].push_back(y);
    g[y].push_back(x);
  }

  void dfs(int idx, int &k, int par = -1)
  {
    used[idx] = true;
    ord[idx] = k++;
    low[idx] = ord[idx];

    for(auto &to : g[idx]) {
      if(!used[to]) {
        dfs(to, k, idx);
        low[idx] = min(low[idx], low[to]);
        parent[to] = idx;
        if(ord[idx] >= low[to]) uf.unite(idx, to);
      } else if(to != par) {
        low[idx] = min(low[idx], ord[to]);
      }
    }
  }

  void dfs()
  {
    int k = 0;
    dfs(0, k);
  }
};

struct BiConnectedComponents : LowLink
{
  vector< pair< int, int > > edges;
  vector< int > comp;

  BiConnectedComponents(size_t v) : LowLink(v), comp(v) {}

  void add_edge(int x, int y)
  {
    LowLink::add_edge(x, y);
    edges.push_back(minmax(x, y));
  }

  int operator[](int k)
  {
    return (comp[k]);
  }

  vector< pair< int, int > > build(vector< vector< int > > &t)
  {
    LowLink::dfs();
    int ptr = 0;
    vector< int > cc(g.size());
    for(int i = 0; i < g.size(); i++) {
      if(i == uf.find(i)) cc[i] = ptr++;
    }

    t.resize(ptr);
    for(int i = 0; i < g.size(); i++) {
      comp[i] = cc[uf.find(i)];
    }
    vector< pair< int, int > > vs;
    for(auto &e : edges) {
      int x = comp[e.first], y = comp[e.second];
      if(x == y) continue;
      vs.emplace_back(e.first, e.second);
      t[x].push_back(y);
      t[y].push_back(x);
    }
    sort(begin(vs), end(vs));
    return (vs);
  }
};


int main()
{
  int N, M;
  cin >> N >> M;
  BiConnectedComponents bc(N);
  for(int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    --a, --b;
    bc.add_edge(a, b);
  }
  vector< vector< int > > t;
  cout << bc.build(t).size() << endl;
}


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

#define int long long
#define sp ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define cps CLOCKS_PER_SEC
#define mod (long long)1000000007
#define f first
#define s second
#define debug1(x) cerr<<x<<"\n"
#define debug2(x,y) cerr<<x<<" "<<y<<"\n"
#define debug3(x,y,z) cerr<<x<<" "<<y<<" "<<z<<"\n"
#define nl cerr<<"\n";
#define pq priority_queue
#define inf 0x3f3f3f3f
#define test cerr<<"abcd\n";
#define pi pair<int,int>
#define pii pair<int,pi>
#define pb push_back
#define mxn 500005


int32_t main(){
sp;
    int n;
    cin>>n;
    cout<<(3LL*n*n);
    return 0;
}


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

using namespace std;

int main(){
    int n; cin >> n;
    vector<pair<string, pair<int, int>>> sps(n);
    for(int i=0; i<n; ++i){
        string s; cin >> s;
        int p; cin >> p;
        sps[i]={s, {-p, i+1}};
    }
    sort(sps.begin(), sps.end());
    for(int i=0; i<n; ++i){
        cout << sps[i].second.second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main(){
    
   ll k;
   cin>>k;
   int ans=-1;
   ll t=0;
   for(int i=1;i<=10000000;i++)
   {
       t=(t*10+7)%k;
       if(t==0)
       {
           ans=i;
           break;
       }
   }
   cout<<ans<<endl;
   return 0;
    
}


Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
int main(){
  string s;
  cin >> s;
  int l=s.size();
  if(l==2){
    if(s[0]==s[1]){
      puts("1 2");
    }else puts("-1 -1");
    return 0;
  }
  for(int i=1;i<l-1;i++){
    if(s[i-1]==s[i]||s[i]==s[i+1]||s[i-1]==s[i+1]){
      printf("%d %d\n",i,i+2);
      return 0;
    }
  }
  puts("-1 -1");
  return 0;
}

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

int32_t main(){
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  set <string> s; string t;
  while(n--){
    cin >> t;
    s.insert(t);
  }
  cout << s.size() << "\n";
}
    

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

const int MAX_N = 500;
const int MAX_C = 30;
const int INF = 1e8;

typedef long long int ll;

int main(){
  // input
  int N,C;
  cin >> N >> C;
  int d[MAX_C][MAX_C];
  for(int i = 0 ; i < C ; i++){
    for(int j = 0 ; j < C; j++){
      cin >> d[i][j];
    }
  }
  
  int data[MAX_N][MAX_N];
  for(int i = 0 ; i < N ; i++){
    for(int j = 0 ; j < N ; j++){
      cin >> data[i][j];
      data[i][j]--;
    }
  }

  ll cost[3][MAX_C];
  for(int i = 0 ; i < 3 ; i++){
    for(int j = 0 ; j < MAX_C ; j++){
      cost[i][j] = 0;
    }
  }
  
  for(int i = 0 ; i < C ; i++){
    for(int j = 0 ; j < N ; j++){
      for(int k = 0 ; k < N ; k++){
	cost[(j + k)%3][i] += d[data[j][k]][i];
      }
    }
  }

  ll res = (1LL << 30);
  for(int i = 0 ; i < C ; i++){
    for(int j = 0 ; j < C ; j++){
      if(i == j)continue;
      for(int k = 0 ; k < C ; k++){
	if(i == k || j == k)continue;
	res = min(res,cost[0][i] + cost[1][j] + cost[2][k]);
      }
    }
  }
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <stdint.h> // uint64_t

#define max(a,b) ((a) > (b) ? (a) : (b))
#define min(a,b) ((a) > (b) ? (b) : (a))
#define NUM_MAX 21
#define BUF_SIZE 100

int get_int(void) {
  int num;
#ifdef BUF_SIZE
  char line[BUF_SIZE];
  if(!fgets(line, BUF_SIZE, stdin)) return 0;
  sscanf(line, "%d", &num);
#else
#error
#endif
  return num;
}

// <arr[0]> <arr[1]> .. <arr[size-1]>
int fget_array(char *arr, int size) {
#ifdef BUF_SIZE
    char line[BUF_SIZE];
    char *tmpbuf = line;
    int i;
    if(!fgets(line, BUF_SIZE, stdin)) return -1;
    for(i = 0; i < size; i++) {
        char *tmp = strtok(tmpbuf, " ");
        arr[i] = strtol(tmp, NULL, 10);
        tmpbuf = NULL;
    }
#else
#error
#endif
    return 0;
}

#define DIVISOR 1000000007

int main(void) {
    int num = get_int();
    int i, j;
    char arr[NUM_MAX+1];
    char graph[NUM_MAX+1][NUM_MAX+1];
    static uint64_t dp[NUM_MAX+1][1<<NUM_MAX];
    for(i = 1; i <= num; i++) {
        fget_array(&arr[1], num);
        for(j = 1; j <= num; j++) {
            graph[i][j] = arr[j];
        }
    }

    for(i = 0; i < num; i++) {
        dp[1][1<<i] = graph[1][i+1];
    }


    int pat, bit;
    for(pat = 1; pat < (1<<num); pat++) {
        int cnt = __builtin_popcount(pat);
        if(cnt==1) continue;
        for(bit = 0; bit < num; bit++) {
            if(!(pat & (1<<bit))) continue;
            if(!graph[cnt][bit+1]) continue;
            int npat = pat & (~(1<<bit));
            dp[cnt][pat] = (dp[cnt][pat] + dp[cnt-1][npat])%DIVISOR;
        }
#ifdef DEBUG
        printf("dp[%d][%d] = %llu\n", cnt, pat, dp[cnt][pat]);
#endif
    }
    printf("%llu\n", dp[num][(1<<num)-1]);
    return 0;
}

Measured memory_bytes: 309376
#include<bits/stdc++.h>
using namespace std;
int main()
{
	string s;
	cin>>s;
    int l=s.size();
    for(register int i=0;i<l;i++)
    {
        if(s[i]=='C')
        {
            for(register int j=i+1;j<l;j++)
            {
                if(s[j]=='F')
                {
                    cout<<"Yes";
                    return 0;
                }
            }
        }
    }
    cout<<"No";
    return 0;
}

Measured memory_bytes: 256
// inputに入力データ全体が入る
function Main(input) {
	ans = 0
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.trim().split("\n");
	s = input[0].split(' ').map((n) => (parseInt(n)))

	ans = Math.floor(s / 2)
	if ((s % 2) == 1) {
		ans++
	}




	//出力
	console.log(ans)
}
//*この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));
// Main(require('fs').readFileSync('./input.txt', 'utf-8'));

Measured memory_bytes: 22080
package main
import(
  "fmt"
)
func main(){
  var n, i int
  i=0
  fmt.Scan(&n)
  a:=make([]int, 1000001)
  for{
    a[i]=n
    if n%2==0{
      n/=2
    }else{
      n=3*n+1
    }
    for j:=0;j<i;j++{
      if a[j]==n{
        fmt.Println(i+2)
        return
      }
    }
    i++
  }
}


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n;
  cin >> n;
  vector<int> v(n);
  for(int i = 0; i<n;i++){
    cin >> v[i];
  }
  vector<int> dp(n);
  dp[0] = 0;
  dp[1] = abs(v[0]-v[1]);
  for(int i = 2; i<n;i++){
    dp[i] = min(abs(v[i]-v[i-1])+dp[i-1],abs(v[i]-v[i-2])+dp[i-2]);
  }
  cout << dp[n-1]<<'\n';
  return 0;
}


Measured memory_bytes: 3980
#include<stdio.h>

int solve(int,int);
int A[2000],n;
int main()
{
  int i=0,m[2000],l;
  
  scanf("%d",&n);
  
  while(i!=n)
    {
      scanf("%d",&A[i]);
      i++;
    }

  scanf("%d",&l);

  for(i=0;i<l;i++)
    {
      scanf("%d",&m[i]);
    }
  for(i=0;i<l;i++)
    {
      if( solve(0,m[i])==1)printf("yes\n");
      else printf("no\n");
    }
  
  return 0;
}

int solve(int i, int m)
{
  int res;
    
  if(m==0)
    return 1;
  if(i>=n)
    return 0;

  res = solve(i+1,m);
  if(res==1) return res;
  else{
    res = solve(i+1,m - A[i]);
    return res;
  }
}


Measured memory_bytes: 2120
#include<iostream>
using namespace std;
int main()
{
    // 半径rの円
    int r;
    cin >> r;
    
    
    // 正12角形の面積を求める式
    
    int s;
    
    s = 3 * r * r;
    
   cout << s << endl;
    return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <algorithm>
#include <math.h>
using namespace std;
int main() {
	long long N[3], K;
	for (int i = 0; i < 3; i++)
	{
		cin >> N[i];
	}
	cin >> K;

	sort(N, N + 3);
	N[2] *= pow(2,K);

	cout << accumulate(N, N + 3, 0) << endl;

	return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np

sr = lambda: sys.stdin.readline().rstrip()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

N = ir()
S = np.array(list('_' + sr()))
Q = ir()
K = lr()
isD = (S == 'D')
isM = (S == 'M')
isC = (S == 'C')
cumD = isD.cumsum()
cumM = isM.cumsum()

for k in K:
    x = cumD.copy()
    x[k:] -= cumD[:-k]
    x *= isM
    x[k+1:] -= isD[1:-k] * (cumM[k:-1] - cumM[:-k-1])
    answer = (x.cumsum() * isC).sum()
    print(answer)
# 05

Measured memory_bytes: 58436
#include<cstdio>

int m, k;
int ans[1<<19], la;

int main() {
	scanf("%d%d", &m, &k);
	if(m==0) {
		if(k==0) puts("0 0");
		else puts("-1");
		return 0;
	}
	if(m==1 && k==0) {
		puts("0 0 1 1");
		return 0;
	}
	if(m==1 && k==1) {
		puts("-1");
		return 0;
	}
	
	if (k<(1<<m)) {
		int la=0;
		for(int i=0;i<(1<<m);i++) {
			if (i==k) continue;
			ans[la++] = i;
		}
		ans[la++] = k;
		for(int i=(1<<m)-1; i>=0;i--) {
			if (i==k) continue;
			ans[la++] = i;
		}
		ans[la++] = k;
		
		for(int i=0;i<la;i++)
			printf("%d%c", ans[i], i<la-1 ? ' ' : '\n');
	} else puts("-1");
	
	return 0;
}

Measured memory_bytes: 2816
using System;
using System.Collections.Generic;
using System.Globalization;
using System.IO.Pipes;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Threading;


class Test
{

    static long mod = (long)1000000007;
    static long[] fact = new long[500001];
    static long[] factinv = new long[500001];
    public static Dictionary<string, long> memo = new Dictionary<string, long>();
    // Driver code 
    public static void Main()
    {

        //var input = Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray();
        //var t = input[0];
        //while (t > 0)
        //{
        //    t--;
        var input1 = Console.ReadLine().Split(' ').Select(xx => long.Parse(xx)).ToArray();
        var s = input1[0];

        var ans = Count(s);

        Console.WriteLine(ans);
    }

    public static long Count(long s)
    {
        string key = s.ToString();
        if (memo.ContainsKey(key))
            return memo[key] % mod;

        if (s == 0)
            return 1;
        if (s < 0)
            return 0;
        
        long count = 0;
        for (int i = 3; i <= s; i++)
        {
            count = (count%mod + Count(s - i)%mod)%mod;
        }
        memo[key] = count % mod;
        return count%mod;
    }

    public static long BinarySearch(long[] arr, long val)
    {
        long low = 0;
        long high = arr.Length;
        while (low < high)
        {
            long middle = low + (high - low) / 2;
            if (arr[middle] > val)
                high = middle;
            else
                low = middle + 1;
        }
        return low;
    }
    public static void Run()
    {
        fact[0] = 1;
        factinv[0] = fast_pow(fact[0], mod - 2);
        for (int i = 1; i <= 500000; ++i)
        {
            fact[i] = fact[i - 1] * i % mod;
            factinv[i] = fast_pow(fact[i], mod - 2);
        }
    }
    public static long GetCom(int n, int r)
    {
        return fact[n] * factinv[r] % mod * factinv[n - r] % mod;
    }
    public static long fast_pow(long a, long b)
    {
        if (b == 0)
            return 1;
        long val = fast_pow(a, b / 2);
        if (b % 2 == 0)
            return val * val % mod;
        else
            return val * val % mod * a % mod;
    }

}













Measured memory_bytes: 23556
#include <iostream>
#include <algorithm>
#include <math.h> 
#include <string>
#include <iomanip>
#include <vector>
using namespace std;
int main(){
    int n;
    cin >> n;
    int d[110];
    for(int i = 0; i < n; i++) cin >> d[i];
    int a[110] = {0};
    int ans = 0;

    for(int i = 0; i < n; i++){
        a[d[i]] = 1;
    }
    
    for(int i = 0; i < 110; i++){
        if(a[i] != 0) ans++;
    }    
    cout << ans << endl;
}




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

struct Card{
	char suit;
	int value;
};

void babblesort(struct Card c[], int n){
	bool flag = true;
	for(int i=0 ; flag ; i++){
		flag = false;
		for(int j=n-1 ; j>=i+1 ; j--){
			if(c[j].value < c[j-1].value){
				Card t = c[j];
				c[j] = c[j-1];
				c[j-1] = t;
				flag = true;
			}
		}
	}
}
	
void selectsort(struct Card c[], int n){
	int minj;
	for(int i=0 ; i<n ; i++){
		minj = i;
		for(int j=i ; j<n ;j++){
			if(c[minj].value > c[j].value){
				minj = j;
			}
		}
		Card t = c[i];
		c[i] = c[minj];
		c[minj] = t;
	}
}

int main() {
	Card c1[100], c2[100];
	
	int n;
	scanf("%d",&n);
	
	for(int i=0 ; i<n ; i++){
		cin>>c1[i].suit>>c1[i].value;
	}
	for(int i=0 ; i<n ; i++) c2[i] = c1[i];
	
	babblesort(c1, n);
	selectsort(c2, n);
	
	bool flag = true;
	for(int i=0 ; i<n ; i++){
		if(c1[i].suit != c2[i].suit){
			flag = false;
			break;
		}
	}
	
	for(int i=0 ; i<n ; i++){
		if(i) printf(" ");
		printf("%c%d",c1[i].suit,c1[i].value);	
	}
	printf("\n");
	printf("Stable\n");
	
	for(int i=0 ; i<n ; i++){
		if(i) printf(" ");
		printf("%c%d",c2[i].suit,c2[i].value);	
	}
	printf("\n");
	if(flag == true){
		printf("Stable\n");
	}else{
		printf("Not stable\n");
	}
	
	return 0;
}

Measured memory_bytes: 1240
//0028 Mode Value
//1`100ÌlªÅå100ñ^¦çêé
//ÅplðoÍ¹æ@¡ÌÅplª éêÍA¬³¢ÉoÍ¹æ

#include<iostream>
#include<algorithm>
#include<limits>
using namespace std;

int main(void)
{
	const int N = 100;
	int a[N+1] = {};
	int i;
	while( cin >> i )
		a[i]++;

	int maxMode = numeric_limits<int>::min();
	for(i = 1; i <= N; i++)
		maxMode = max(maxMode, a[i]);
	for(i = 1; i <= N; i++)
	{
		if(a[i] == maxMode)
			cout << i << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#インポート
import sys

#入力用
def ILI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def ISI(): return map(int, sys.stdin.readline().rstrip().split())
def II(): return int(sys.stdin.readline().rstrip())
def ISS(): return sys.stdin.readline().rstrip().split()
def IS(): return sys.stdin.readline().rstrip()

H, W = ISI()
A = [IS() for _ in range(H)]

for i in range(H):
    print(A[i])
    print(A[i])


Measured memory_bytes: 3064
from subprocess import*
with open('Main.java','w')as f:f.write(r"""
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = Integer.parseInt(sc.next());
		int ans = 0;
		int max = Integer.parseInt(sc.next());
		int min = max;
		boolean up = true;
		boolean down = true;
		for (int i = 1; i < n; i++) {
			int a = Integer.parseInt(sc.next());
			if (up) {
				if (a >= max)
					max = a;
				else
					up = false;
			}
			if (down) {
				if (a <= min)
					min = a;
				else
					down = false;
			}
			if (!up && !down) {
				ans++;
				max = a;
				min = a;
				up = true;
				down = true;
			}
		}
		ans++;
		System.out.println(ans);
	}
}
""")
call(('javac','Main.java'))
call(('java','Main'))

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

int main() {
	int l,cnt=0;
	cin >> l;
	
	for(int i=1;i<=l;i++) {
		int k = log10(i)+1;
		if(k % 2!=0) {cnt++;}
		else continue;
	}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i,n) for(long long i = 0; i < (n); ++i)
#define ll long long
#define P pair<ll,ll>
#define all(v) (v).begin(),(v).end()

const ll mod = 1e9+7;
const ll INF = 1e18;
const double pi = acos(-1.0);

int main(void)
{
    ll a,b; cin>>a>>b;
    cout<<abs(a*b)/__gcd(a,b)<<endl;
    return 0;
}

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

using namespace std;

int main()
{
  vector<string> keitai(9);
  keitai[0] = ".,!? ";  keitai[1] = "abc";  keitai[2] = "def";  keitai[3] = "ghi";
  keitai[4] = "jkl";  keitai[5] = "mno";  keitai[6] = "pqrs"; keitai[7] = "tuv";  keitai[8] = "wxyz";

  int N;
  cin>>N;

  for(int i = 0;i < N;++i){
    string input,output;
    cin>>input;

    int word,t = 0;
    for(int j = 0;j < input.size();++j){
      if(input[j] == '0' && word != 0){
        int num = t % keitai[word - 1].size();
        if(num == 0){
          num = keitai[word - 1].size();
        }
        output = output + keitai[word - 1][num - 1];
        t = 0;
        word = 0;
      }
      else{
        word = input[j] - '0';
        if(word != 0){
          ++t;
        }
      }
    }
    cout<<output<<endl;
  }

  return 0;
}


Measured memory_bytes: 3040
#define _CRT_SECURE_NO_WARNINGS

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

typedef unsigned int uint;
typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<string> vs;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef map<int, int> mii;
typedef map<string, int> msi;
typedef map<int, string> mis;
typedef pair<int, ii> edge;


#define sc(x)  scanf("%d",&x)
#define scl(x) scanf("%lld",&x)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mem(arr,val) memset(arr,val,sizeof arr)
#define sz(v) (int)v.size()
#define rsz(v) v.resize
#define clr(v) v.clear()
#define rev(v) reverse(all(v))
#define lop(i,end) for(int i=0; i<end; i++)
#define rlop(i,start) for(int i=start-1; i>=0; i--)
#define loop(i,start,end) for(int i=start; i<end; i++)
#define rloop(i,start,end) for(int i=start-1; i>=end; i--)
#define PB push_back
#define pb pop_back
#define mP make_pair
#define f first
#define s second

const ll OO = (ll)(4e18) + 9;
const int MOD = (int)(1e9) + 7;
const int oo = 2147483647;
const double EPS = 1e-8;
const double PI = acos(-1.0);

//enum dir { d, r, u, l , dr, ur, dl, ul };
int dx[] = { 1, 0, -1, 0, 1, -1, 1, -1 };
int dy[] = { 0, 1, 0, -1, 1, 1, -1, -1 };

string abc = "abcdefghijklmnopqrstuvwxyz";
string vowels = "aeiou"; //and sometimes "aeiouy"

template<typename X, typename Y> bool ckmin(X& a, Y b) { return a > b ? a = b, true : false; }
template<typename X, typename Y> bool ckmax(X& a, Y b) { return a < b ? a = b, true : false; }

int dcmp(ld d1, ld d2) { return fabs(d1 - d2) <= EPS ? 0 : d1 > d2 ? 1 : -1; } //Compare Double Numbers
ll gcd(ll x, ll y) { return !y ? x : gcd(y, x%y); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
//convert index from 2D array to 1D array. (Zero-indexed)
int conv_2_1(int r, int c, int nCol) { return (nCol*r) + c + 1; }
//convert index from 1D array to 2D array. (Zero-indexed)
ii conv_1_2(int n, int nCol) {
	int r = n / nCol, c = n % nCol;
	return ii(r, c);
}

ll poww(ll num, ll p, ll md = MOD) {
	num %= md;
	ll ret = 1;
	while (p > 0) {
		if (p & 1) ret = (ret * num) % md;
		num = (num * num) % md;
		p >>= 1;
	}
	return ret;
}

void inter(string s) {
	cout << s << endl;
	fflush(stdout);
}


int main()
{
#ifndef ONLINE_JUDGE

#else
	//freopen("pyramid.in", "r", stdin);
#endif
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	char c;
	cin >> c;
	if (c >= 'a') cout << 'a' << endl;
	else cout << "A\n";




	return 0;
}


Measured memory_bytes: 3656