akhauriyash/Code-Regression huggingface dataset:
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <regex>
#define REP(i,n) for(int i = 0; i < n; i++)
#define FOR(i,j,n) for(int i = j; i < n; i++)
#define RFOR(i,j,n) for(int i = j-1; i >= n; i--)
#define PREC(n) fixed << setprecision(n)
#define print_array(v) REP(__k, v.size()) { cout << v[__k]; if(__k != v.size()-1) cout << " "; else cout << endl; }
#define YesorNo(a) printf(a?"Yes\n":"No\n")
#define _LIBCPP_DEBUG 0
using namespace std;
int64_t MOD = 1000000007;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  string s;
  cin >> s;
  REP(i,s.size()) cout << "x";
  cout << endl;
  return 0;
}
//templete by private_yusuke

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

void Main()
{
    int n, m;
    cin >> n >> m;
    priority_queue<int, vector<int>, less<int>> a;
    for (int i = 0; i < n; ++i)
    {
        int v;
        cin >> v;
        a.push(v);
    }
    while (m != 0)
    {
        int t = a.top();
        t = t / 2;
        a.pop();
        a.push(t);
        m--;
    }
    ll total = 0;
    while (!a.empty())
    {
        total += a.top();
        a.pop();
    }
    cout << total << endl;
}

int main()
{
    std::cout << std::fixed << std::setprecision(15);
    Main();
}

Measured memory_bytes: 892
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,fma")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>  
#include <complex>
#include <queue>
#include <set>
#include <unordered_set>
#include <list>
#include <chrono>
#include <random>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <map>
#include <unordered_map>
#include <stack>
#include <iomanip>
#include <fstream>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef pair<int,int> p32;
typedef pair<ll,ll> p64;
typedef pair<double,double> pdd;
typedef vector<ll> v64;
typedef vector<int> v32;
typedef vector<vector<int> > vv32;
typedef vector<vector<ll> > vv64;
typedef vector<vector<p64> > vvp64;
typedef vector<p64> vp64;
typedef vector<p32> vp32;
ll MOD = 163577857;
double eps = 1e-12;
#define forn(i,e) for(ll i = 0; i < e; i++)
#define forsn(i,s,e) for(ll i = s; i < e; i++)
#define rforn(i,s) for(ll i = s; i >= 0; i--)
#define rforsn(i,s,e) for(ll i = s; i >= e; i--)
#define ln "\n"
#define dbg(x) cout<<#x<<" = "<<x<<ln
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define INF 2e18
#define fast_cin() ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)
#define all(x) (x).begin(), (x).end()
#define sz(x) ((ll)(x).size())
 
ll mpow(ll a, ll b){
	if(a==0) return 0;
	if(b >= (MOD-1)) b %= (MOD-1);
	if(b==0) return 1;
	ll t1 = mpow(a,b/2);
	t1 *= t1;
	t1 %= MOD;
	if(b%2) t1 *= a;
	t1 %= MOD;
	return t1;
}
 
ll mpow(ll a, ll b, ll p){
	if(a==0) return 0;
	if(b==0) return 1;
	ll t1 = mpow(a,b/2,p);
	t1 *= t1;
	t1 %= p;
	if(b%2) t1 *= a;
	t1 %= p;
	return t1;
}
 
ll modinverse(ll a, ll m){
	ll m0 = m; 
    ll y = 0, x = 1; 
    if (m == 1) return 0; 
    while (a > 1){
        ll q = a / m; 
        ll t = m; 
        m = a % m, a = t; 
        t = y; 
        y = x - q * y; 
        x = t; 
    }
    if (x < 0) x += m0; 
    return x; 
}
 
ll range(ll l, ll r){
	return l + rand()%(r-l+1);
}
 
ll rev(ll v){
	return mpow(v,MOD-2);
}

void solve(){
	
}
 
int main()
{
	fast_cin();
    ll n,k,d,a;
    cin >> n >> k;
    set<ll> s;
	forn(i,k){
		cin >> d;
		forn(j,d){
			cin >> a;
			s.insert(a);
		}
	}
	cout << n - sz(s);
    return 0;
}


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

#define watch(x) cerr << (#x) << ": " << (x) << endl
#define int long long

const int N = 200009;
int n, k, a[N];

int f(int cur) {
    int less_than = 0;
    for(int i = 0; i < n; ++i) {
        int ai = a[i];
        int to_add;
        if(ai == 0) {
            if(cur < 0) {
                to_add = 0;
            } else {
                to_add = n-i-1;
            }
        } else if(ai < 0 && cur < 0) {
            int mult = (cur+ai+1)/ai;
            auto it = lower_bound(a+i+1, a+n, mult);
            to_add = n - (it-a);
        } else if(ai < 0){
            int mult = cur/ai;
            auto it = lower_bound(a+i+1, a+n, mult);
            to_add = n - (it-a);
        } else if(cur < 0) {
            to_add = 0;
        } else {
            int mult = cur/ai;
            auto it = upper_bound(a+i+1, a+n, mult);
            to_add = (it-a) - (i+1);
        }
        less_than += max(0LL, to_add);
    }
    return less_than;
}

int32_t main() {

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    cin >> n >> k;
    for(int i = 0; i < n; ++i) {
        cin >> a[i];
    }

    sort(a, a+n);
    
    int l = -1000000000000000010, r = 1000000000000000010;
    while(r-l > 1) {
        int mid = l + (r-l)/2;

        int ct = f(mid);

        if(ct >= k) {
            r = mid;
        } else {
            l = mid;
        }
    }

    cout << r << endl;
    
    return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
using namespace std;

int main() {
	long long E;
	while (cin >> E) {
		if (E == 0) return 0;
		long long ANS = 1000000000;
		for (long long C = 0; C * C * C <= E; C++) {
			long long D = E - C * C * C;
			long long B = sqrt(D);
			long long A = D - B * B;
			ANS = min(ANS, A + B + C);
		}
		cout << ANS << endl;
	}
}


Measured memory_bytes: 3100
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n) ;i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
#define sz(x) ((int)(x).size())
using ll=long long;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define MOD  1000000007
const ll INF=1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b){ a = b; return 1; } return 0; }



int main(int argc, char const *argv[]) {
  string s; cin >> s;
  ll n=sz(s);
  reverse(all(s));
  map<ll,ll> mp;
  ll now=0,ans=0;
  ll ten=1;//10のべき乗の値，最初は10^0=1
  rep(i,n){
    mp[now]++;
    now=(now+(s[i]-'0')*ten)%2019;
    ten*=10;//次の桁を見るために10倍
    ten%=2019;
    ans+=mp[now];
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3760
fun main() {
    class Type(val raw: String = "", val value: String = "", val i: Int = 0, val map: Map<Char, Int> = emptyMap()) {
        fun append(c: Char): Type {
            val m = map.toMutableMap()
            val index = m.getOrPut(c, { i + 1 })
            return Type(raw + c, value + index, i + 1, m)
        }
    }

    val n = readLine()?.toInt() ?: return
    val set = listOf('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j').take(n)
    val standard = hashMapOf<String, String>()
    fun gen(n: Int, r: Int, set: List<Char>, s: Type) {
        if (s.raw.length == n) {
            val key = s.value
            if (!standard.containsKey(key)) {
                standard[key] = s.raw
            }
        } else {
            set.take(n - r).forEachIndexed { i, c ->
                gen(n, r - if (i == n - r - 1) 1 else 0, set, s.append(c))
            }
        }
    }
    gen(n, n - 1, set, Type())
    buildString {
        standard.values.sorted().forEach {
            appendln(it)
        }
    }.let {
        println(it.trimIndent())
    }
}


Measured memory_bytes: 99816
import sys
sys.setrecursionlimit(1000000)

N = int(input())
h = [int(i) for i in input().split()]

memo = {}

def f(i):
  if i == 0:
    return 0
  if i == 1:
    return abs(h[i - 1] - h[i])
  else:
    if i - 1 not in memo:
      memo[i - 1] = f(i - 1)
    if i - 2 not in memo:
      memo[i - 2] = f(i - 2)
    j1 = memo[i - 1] + abs(h[i - 1] - h[i])
    j2 = memo[i - 2] + abs(h[i - 2] - h[i])
    return j1 if j1 < j2 else j2

print(f(N - 1))


Measured memory_bytes: 102796
unittest
{
	assert( [ "25" ].parse.expand.solve == "Christmas" );
	assert( [ "22" ].parse.expand.solve == "Christmas Eve Eve Eve" );
}



import std.conv;
import std.range;
import std.stdio;
import std.string;
import std.typecons;

void main()
{
	stdin.byLineCopy.parse.expand.solve.writeln;
}

auto parse( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto n = input.front.strip.to!( long );
	return tuple( n );
}

auto solve( long n )
{
	switch( n )
	{
		case 22: return "Christmas Eve Eve Eve";
		case 23: return "Christmas Eve Eve";
		case 24: return "Christmas Eve";
		case 25: return "Christmas";
		default: assert( false );
	}
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <map>
#include <set>
#include <vector>
#include <utility>
#include <queue>
#include <stack>
#include <math.h>
#include <algorithm>
#define ll long long
#define add push_back
 
using namespace std; 

ll fact(ll n){
    ll answ = 1;
    for( int i = 1; i <= n; i++){
        answ *= i;
    }
    return answ;
}

ll c(ll n, ll m){
    return fact(n) / (fact(m) * fact(n - m));
}


int main() {

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

    int t;  t = 1; //cin >> t;
    while(t--){
        string s,str; cin >> s >> str;
        int answ = 0;
        for(int i = 0; i < s.length(); i++){
            if(s[i] != str[i]) answ++;
        }
        cout << answ << endl;
    }
    return 0;
}

Measured memory_bytes: 3804
# -*- coding: utf-8 -*-

# AtCoder Beginner Contest
# Problem A

if __name__ == '__main__':
    x, a, b = list(map(int, input().split()))

    if (x + a + 1) <= b:
        print('dangerous')
    elif a < b <= (x + a):
        print('safe')
    else:
        print('delicious')


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

int main(){
  string a,b;
  cin >> a >> b;

  bool f = false;
  for(int i = 0;i <= a.size();i++){
    if(a == b){
      f = true;
      break;
    }
    char tmp = a[a.size()-1];
    a.erase(a.size()-1);
    a.insert(a.begin(),tmp);
  }

  if(f){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }

  return 0;
}


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

int main(){
	int k = 0;
	int kazu = 0;
	int num[1000] = {0};
	string str[1000];
	string hindo;
	string mozisuu = "";
	while(cin >> str[k]){
		for(int i = 0; i < k; i++){
			if(str[k] == str[i]){
				num[i]++;
				break;
			}
		}
		k++;
	}
	for(int i = 0; i < k; i++){
		if(num[i] > kazu){
			kazu = num[i];
			hindo = str[i];
		}
		if(str[i].size() > mozisuu.size()){
			mozisuu = str[i];
		}
	}
	cout << hindo << " " << mozisuu << endl;
}

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

int main() {
    ios::sync_with_stdio(false), cin.tie(NULL), cout.tie(NULL);
    string s;
    cin >> s;
    s = " " + s;
    int n = s.size();
    vector<int> nxt(2019);
    for (int i = 0; i < 2019; ++i) {
        nxt[i] = i * 10 % 2019;
    }
    vector<int> cnt(2019, 0);
    vector<int> tmp(2019);
    long long ans = 0;
    for (int i = 1; i < n; ++i) {
        int num = s[i] - '0';
        for (int x = 0; x < 2019; ++x) {
            tmp[nxt[x]] = cnt[x];
        }
        for (int x = 0; x < 2019; ++x) {
            cnt[(x + num) % 2019] = tmp[x];
        }
        cnt[num] += 1;
        ans += cnt[0];
    }
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 3740
#pragma GCC optimize("Ofast")

//インクルード
#include<algorithm>//sort,二分探索,など
#include<bitset>//固定長bit集合
#include<cmath>//pow,logなど
#include<complex>//複素数
#include<deque>//両端アクセスのキュー
#include<functional>//sortのgreater
#include<iomanip>//setprecision(浮動小数点の出力の誤差)
#include<iostream>//入出力
#include<map>//map(辞書)
#include<numeric>//iota(整数列の生成),gcdとlcm(c++17)
#include<queue>//キュー
#include<set>//集合
#include<stack>//スタック
#include<string>//文字列
#include<unordered_map>//イテレータあるけど順序保持しないmap
#include<unordered_set>//イテレータあるけど順序保持しないset
#include<utility>//pair
#include<vector>//可変長配列

using namespace std;
using Graph = vector<vector<int>>; // グラフ型
typedef long long ll;

//マクロ
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000 //10^12
#define MOD 1000000007 //10^9+7
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MAXR 100000 //10^5:最大のrange(素数列挙などで使用)

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

int main() {
  // 高速化
    std::ios::sync_with_stdio(false);
    std::cin.tie(0);

    int max = 2000;

    int x;
    cin >> x;

    ll vec[max*2+1];
    FOR(i, -max, max){
        vec[i+max] = (pow(i, 5));
    }

    int a = 0;
    int b = 0;

    REP(i, max*2+1){
        REP(j, max*2+1){
            if(vec[i] - vec[j] == x){
                a = i - max;
                b = j - max;
                break;
            }
        }
    }


    cout << a << " " << b  << "\n"; 

    return 0;



}


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

using namespace std;

void solve() {
  int n, k;
  cin >> n >> k;
  vector<int> hs(n);
  for (int i = 0; i < n; ++i) {
    cin >> hs[i];
  }
  int64_t sum = 0;
  sort(hs.begin(), hs.end());
  for (int i = 0; i < n - k; ++i) {
    sum += hs[i];
  }
  cout << sum << endl;
}


int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  solve();
}


Measured memory_bytes: 1152
import math
A, B = list(map(int, input().split()))
a = math.ceil(A / 0.08)
b = math.ceil(B / 0.1)
if a == b:
    print(a)
else:
    if a < b and int(b * 0.08) == A:
        print(b)
    elif a > b and int(a * 0.1) == B:
        print(a)
    else:
        print(-1)


Measured memory_bytes: 9072
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <unordered_set>
#include <queue>
#include <deque>
#include <string>
#include <sstream>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <stack>
#include <cstdio>
#include <climits>
#include <tuple>
#include <ctime>
#include <cstring>
#include <numeric>
#define FOR(i,a,n) for (int i = a; i < n; i++)
#define IFOR(i,n,a) for (int i = n; i >= a; i--)
#define mp make_pair
#define full(a) a.begin(), a.end()
#define sz(x) ((int)(x).size())
#define pii pair<int, int>
#define trav(a,x) for (auto& a : x)
using ull = unsigned long long;
using ll = long long;
using ld = long double;
using namespace std;
const ll mod = 1e9 + 7;
const int N = 5005;

ld exp(int& a)
{
    ld p = ld(1 / ld(a));
    ld ans = 0;
    FOR(i, 1, a + 1)
    {
        ans += ld(p * ld(i));
    }
    return ans;
}

void solve()
{
    int n, k; cin >> n >> k;
    ld res = 0;
    map<int, ld> m;
    vector<int> v(n);
    FOR(i, 0, k)
    {
        int a; cin >> a;
        v[i] = a;
        if (m.find(a) != m.end())
        {
            res += m[a];
            continue;
        }
        m[a] = exp(a);
        res += m[a];
    }
    ld mx = res;
    FOR(i, k, n)
    {
        int l = v[i - k];
        int r; cin >> r;
        v[i] = r;
        res -= m[l];
        if (m.find(r) != m.end())
        {
            res += m[r];
            mx = max(mx, res);
            continue;
        }
        m[r] = exp(r);
        res += m[r];
        mx = max(mx, res);
    }
    cout << setprecision(7) << fixed << mx;

}

int main()
{
    ios::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
    /*int tc;  cin >> tc;
    while (tc--)*/
    solve();
    return 0;
}







Measured memory_bytes: 3652
N, Q=gets.split.map(&:to_i)
S=gets.chomp
lrs=Q.times.map { gets.split.map(&:to_i) }

sum=0
sum_array=[0]

(N-1).times do |i|
  sum += 1 if S[i]=="A" && S[i+1] == "C" 
  sum_array.push(sum)
end

lrs.each do |lr|
  p sum_array[lr[1]-1] - sum_array[lr[0]-1]
end


Measured memory_bytes: 15740
#include<bits/stdc++.h>
using namespace std;
#define  ft  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int a[10];
int go(int i,int n)
{
    int s=0;
    for(;i<=n;i++)
    {
        s+=a[i];
    }
    return s;
}
int main()
{
    ft
    int i,j,k,n,l,x,y,z;
    cin>>n>>x>>y>>z;
    for(i=0;i<n;i++)
    {
        cin>>a[i];
    }
    sort(a,a+n);
    int ans=INT_MAX;
    do
    {
        for(i=0;i<n-2;i++)
        {
            for(j=i+1;j<n-1;j++)
            {
                for(k=j+1;k<n;k++)
                {
                    int s=0;
                    l=i*10+abs(go(0,i)-x);
                    s+=l;
                    l=(j-i-1)*10+abs(go(i+1,j)-y);
                    s+=l;
                    l=(k-j-1)*10+abs(go(j+1,k)-z);
                    s+=l;
                    ans=min(ans,s);
                }
            }
        }
    }while(next_permutation(a,a+n));
    cout<<ans<<"\n";
    return 0;
}

Measured memory_bytes: 3656
using System;
using System.Linq;

class Program
{
    public static void Main(string[] args) {
        int[] s = Console.ReadLine().Split().Select(int.Parse).ToArray();
        if (s[1]/s[0] >= s[2]) Console.WriteLine(s[2]);
        else Console.WriteLine(s[1]/s[0]);
    }
}

Measured memory_bytes: 13268
#include<stdio.h>
#include<iostream>
#include<string.h>
#include<algorithm> 
using namespace std;
const int maxn=3005;
int n,t,a[maxn],b[maxn],dpf[maxn][maxn],dps[maxn][maxn],ma;
int main(){
	scanf("%d%d",&n,&t);
	for(int i=1;i<=n;i++)scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=n;i++){
		for(int j=0;j<=t;j++){
			if(j<a[i])dpf[i][j]=dpf[i-1][j];
			else dpf[i][j]=max(dpf[i-1][j],dpf[i-1][j-a[i]]+b[i]);
			//printf("dpf[%d][%d]=%d\n",i,j,dpf[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<=t;j++){
			if(j<a[n-i+1])dps[n-i+1][j]=dps[n-i+2][j];
			else dps[n-i+1][j]=max(dps[n-i+2][j],dps[n-i+2][j-a[n-i+1]]+b[n-i+1]);
			//printf("dps[%d][%d]=%d\n",n-i+1,j,dps[n-i+1][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=0;j<t;j++){
			ma=max(ma,dpf[i-1][j]+b[i]+dps[i+1][t-j-1]);
		}
	}
	printf("%d\n",ma);
	return 0;
} 

Measured memory_bytes: 70784
def update(bin_tree, x, y, n):
    i = n - 1 + x
    bin_tree[i] = y

    while i > 0:
        i = int((i - 1) / 2)
        bin_tree[i] = min(bin_tree[2*i+1], bin_tree[2*i+2])


def find(bin_tree, x, y, k, l, r):
    if r <= x or y <= l:
        return 2**31-1
    elif x <= l and r <= y:
        return bin_tree[k]
    else:
        vl = find(bin_tree, x, y, 2 * k + 1, l, int((l + r) / 2))
        vr = find(bin_tree, x, y, 2 * k + 2, int((l + r) / 2), r)
        return min(vl, vr)


def main():
    [n, q] = [int(num) for num in input().split()]

    m = 1
    while m < n:
        m *= 2

    bin_tree = [2**31-1 for _ in range(2*m-1)]

    for i in range(q):
        # print(bin_tree)
        [com, x, y] = [int(num) for num in input().split()]

        if com == 0:
            update(bin_tree, x, y, m)
        else:
            print(find(bin_tree, x, y+1, 0, 0, m))


if __name__ == '__main__':
    main()



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

int judge(int x){
    int ans;
    if(x <= 111){
        ans = 111;
    }
    else if(111 < x && x <= 222){
        ans = 222;
    }
    else if(222 < x && x <= 333){
        ans = 333;
    }
    else if(333 < x && x <= 444){
        ans = 444;
    }
    else if(444 < x && x <= 555){
        ans = 555;
    }
    else if(555 < x && x <= 666){
        ans = 666;
    }
    else if(666 < x && x <= 777){
        ans = 777;
    }
    else if(777 < x && x <= 888){
        ans = 888;
    }
    else{
        ans = 999;
    }

    return ans;
}

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

    int ans = judge(n);

    cout << ans<< endl;

    return 0;
}

Measured memory_bytes: 256
N,L=map(int,input().split())
A=list(map(int,input().split()))

for i in range(0,N-1):
    if A[i]+A[i+1]>=L:
        print('Possible')
        for j in range(1,i+1):
            print(j)
        T=[]
        for j in range(i+2,N):
            T.append(j)
        T.sort(reverse=True)
        for j in range(0,len(T)):
            print(T[j])
        print(i+1)
        break
else:
    print('Impossible')

Measured memory_bytes: 66252
import java.util.*;

class Main {
	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);

		String[] stack;
		String line = stdIn.nextLine();
		stack = line.split(" ", 0);

		Stack stack1 = new Stack();

		for (int i = 0; i < stack.length; i++) {
			int tmp = 0;
			switch (stack[i]) {
				case "+":{
					tmp = stack1.pop() + stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}

				/*????????§??????????????§???*/
				case "-":{
					int operand1 = stack1.pop();
					int operand2 = stack1.pop();
					tmp = operand2 - operand1;
					stack1.push(String.valueOf(tmp));
					break;
				}
				case "*":{
					tmp = stack1.pop() * stack1.pop();
					stack1.push(String.valueOf(tmp));
					break;
				}
				default:{
					stack1.push(stack[i]);
					break;
				}
			}
		}
		System.out.println(stack1.pop());

	}
}

class Stack{
	int maxSize = 200;
	int pointer;
	String[] stack = new String[maxSize];

	public void initialize(){
		this.pointer = 0;
	}

	public void push(String x) {
		this.stack[pointer] = x;
		pointer++;
	}

	public int pop() {
		pointer--;
		return Integer.parseInt(stack[pointer]);
	}

}

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

#define rep(i, n) REP(i, 0, n)
#define repr(i, n) for (int i = (n); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
#define MSG(a) cout << #a << " " << a << endl;
#define REP(i, x, n) for (int i = x; i < n; i++)
#define OP(m) cout << m << endl
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;

int main()
{
    ll a, b, x;
    cin >> a >> b >> x;
    if (a == 0)
        OP(b / x + 1);
    else
        OP(b / x - (a - 1) / x);

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define all(v) v.begin(),v.end()	
using namespace std;
typedef long long ll;
const ll MOD=1000000007;
const ll INF=1000000010;
const ll LINF=4000000000000000000;
typedef pair<int,int> P;
int dp[200010];//dp[i]:=[0,i]の部分文字列の中の回文分割の最小値
int co[1<<26];
int main(){
    string s;cin>>s;
    int n=s.length();
    int a=0;
    fill(co,co+(1<<26),INF);
    fill(dp,dp+n+1,INF);
    co[0]=0;
    dp[0]=0;
    for(int i=1;i<=n;i++){
        a^=(1<<(s[i-1]-'a'));
        dp[i]=min(dp[i],co[a]+1);
        for(int j=0;j<26;j++){
            dp[i]=min(dp[i],co[a^(1<<j)]+1);
        }
        co[a]=min(co[a],dp[i]);
    }
    cout<<dp[n]<<endl;
}

Measured memory_bytes: 263556
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;

int main(){
	char s[100], p[100];
	scanf("%s",s);
	scanf("%s",p);
	
	int lgp = strlen(p);
	
	for (int i=0;i<strlen(s);i++){
		//if (s[0] == p[0]){
			for (int j=0; j < lgp; j++){
				if (s[j] != p[j]) break;
				if (j == lgp-1){
					cout << "Yes" << endl;
					return 0;
				}	
			}
		//}
		//????????????????????????
		int dmy = s[0];
		for (int k = 0;k < strlen(s) - 1; k++) s[k] = s[k+1];	
		s[strlen(s)-1] = dmy;	
	}
	cout << "No" << endl;
	return 0;
}

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

int main(){
    double a,b,x;
    cin >> a >> b >> x;
    if(x<a*a*b/2)
        printf("%.6f\n", atan(a*b*b/(x*2))*(180/_Pi));
    else
        printf("%.6f\n", atan(2*(b-x/a/a)/a)*(180/_Pi));
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll n,a,b,c;
ll L[10];
ll dfs(ll i,ll j,ll k,ll l){
	if(i==n){
		if(j!=0&&k!=0&&l!=0){
			return abs(a-j)+abs(b-k)+abs(c-l);
		}else{
			return 1000000000000;
		}
	}
	ll A=dfs(i+1,j+L[i],k,l)+10;
	ll B=dfs(i+1,j,k+L[i],l)+10;
	ll C=dfs(i+1,j,k,l+L[i])+10;
	ll D=dfs(i+1,j,k,l);
	ll E=min(A,B);
	ll F=min(C,D);
	return min(E,F);
}
int main(void){
	cin>>n>>a>>b>>c;
	for(int i=0;i<n;i++){
		cin>>L[i];
	}
	ll ans=dfs(0,0,0,0)-30;
	cout<<ans<<endl;
	
}


Measured memory_bytes: 256
#include<stdio.h>

int selectionSort(int A[], int N) {
    int minj, tmp, sw = 0;
    for(int i = 0; i < N; i++) {
        minj = i;
        for(int j = i; j < N; j++) {
            if(A[minj] > A[j]) {
                minj = j;
            }
        }
        tmp = A[i]; A[i] = A[minj]; A[minj] = tmp;
        if(minj != i) sw++;
    }
    return sw;
}

int main() {
    int A[100], N, sw;

    scanf("%d", &N);
    for(int i = 0; i < N; i++) scanf("%d", &A[i]);

    sw = selectionSort(A, N);

    for(int i = 0; i < N; i++) {
        if(i > 0) printf(" ");
        printf("%d", A[i]);
    }

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

    return 0;
}


Measured memory_bytes: 2760
#include<bits/stdc++.h>
typedef long long ll;
using namespace std;
const ll INF = 1LL<<32;
int n,m;
ll dp[110][110];
void floyd(){
    for(int k = 0 ; k<n ; k++){
        for(int i = 0 ; i<n ; i++){
            if(dp[i][k] == INF)
                continue;
            for(int j = 0 ; j<n ; j++){
                if(dp[k][j] == INF)
                    continue;
                dp[i][j] = min(dp[i][j] , dp[i][k]+dp[k][j]);
            }
        }
    }
}
int main(){
    cin>>n>>m;
    for(int i = 0 ; i<n ; i++){
        for(int j = 0 ; j<n ; j++){
            if(i == j)
                dp[i][j] = 0;
            else
                dp[i][j] = INF;
        }
    }

    for(int i = 0 ; i<m ; i++){
        int s,t,d;
        cin>>s>>t>>d;
        dp[s][t] = d;
    }
    floyd();

    bool flag = 0;
    for(int i = 0 ; i<n ; i++){
        if(dp[i][i] < 0){
            flag = 1;
            break;
        }
    }
    if(flag){
        cout<<"NEGATIVE CYCLE"<<endl;
    }
    else{
        for(int i = 0 ; i<n ; i++){
            for(int j = 0 ; j<n ; j++){
                if(j) cout<<" ";
                if(dp[i][j] == INF){
                    cout<<"INF";
                }
                else
                    cout<<dp[i][j];
            }
            cout<<endl;
        }
    }

    return 0;
}



Measured memory_bytes: 3204
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cstring>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <map>
#include <set>
#include <bitset>
#include <numeric>
#include <utility>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <unordered_map>
using namespace std;

#define REP(i, s) for (int i = 0; i < s; ++i)
#define ALL(v) (v.begin(), v.end())
#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
#define EACH(i, s) for (__typeof__((s).begin()) i = (s).begin(); i != (s).end(); ++i)

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ EACH(it, P) { s << "<" << *it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ EACH(it, P) { s << "<" << it->first << "->" << it->second << "> "; } return s << endl; }

typedef long long  ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int main() {
    int N;
    string s;
    cin>>N>>s;
    int r=0,b=0;
    REP(i,N){
        if(s[i]=='R') r++;
        else b++;
    }
    if(r>b) cout<<"Yes"<<endl;
    else cout<<"No"<<endl;


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
int main(){
    string a;
    cin >> a;
    if (a == "SSS"){
        cout << 0;
    }
    if (a == "SSR"){
        cout << 1;
    }
    if (a == "SRS"){
        cout << 1;
    }
    if (a == "SRR"){
        cout << 2;
    }
    if (a == "RSS"){
        cout << 1;
    }
    if (a == "RSR"){
        cout << 1;
    }
    if (a == "RRS"){
        cout << 2;
    }
    if (a == "RRR"){
        cout << 3;
    }
}

Measured memory_bytes: 3620
package main

import (
	"bufio"
	"fmt"
	"io"
	"os"
	"strconv"
)

const mod = 998244353
const facNum = 300001

func main() {
	sc := newScanner(os.Stdin)
	N := sc.i()
	A := sc.is(N)
	money := 1000
	stock := 0
	for i := 0; i < N; i++ {
		if i == N-1 {
			money += A[i] * stock
		} else if A[i] < A[i+1] {
			buy := money / A[i]
			stock += buy
			money -= A[i] * buy
		} else if stock > 0 {
			money += A[i] * stock
			stock = 0
		}
	}
	fmt.Println(money)
}

// fmt.Println("Yes")
// fmt.Println("No")

// I/O
type scanner struct {
	sc *bufio.Scanner
}

func newScanner(input io.Reader) *scanner {
	sc := bufio.NewScanner(input)
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 1024), int(1e+9))
	return &scanner{sc}
}

func (s *scanner) s() string {
	s.sc.Scan()
	return s.sc.Text()
}

func (s *scanner) i() int {
	i, e := strconv.Atoi(s.s())
	if e != nil {
		panic(e)
	}
	return i
}

func (s *scanner) f() float64 {
	f, e := strconv.ParseFloat(s.s(), 64)
	if e != nil {
		panic(e)
	}
	return f
}

func (s *scanner) bs() []byte {
	return []byte(s.s())
}

func (s *scanner) is(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = s.i()
	}
	return res
}

func (s *scanner) fs(n int) []float64 {
	res := make([]float64, n)
	for i := 0; i < n; i++ {
		res[i] = s.f()
	}
	return res
}

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

//const factorial = new
func Pow(a, n int) int {
	ans := 1
	for n > 0 {
		if (n & 1) == 1 {
			ans = ans * a % mod
		}
		a = a * a % mod
		n = n >> 1
	}
	return ans
}

// a^{-1} (mod) を計算
func Inv(a int) int {
	return Pow(a, mod-2)
}

func Gcd(a, b int) int {
	if a < b {
		return Gcd(b, a)
	}
	for b != 0 {
		a, b = b, a%b
	}
	return a
}

func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}

func combination(n, k int, fac, ifac []int) int {
	if n < k || n < 0 {
		return 0
	}
	if k == 0 {
		return 1
	}
	//while n != 0
	ans := ifac[k] * ifac[n-k] % mod
	return ans * fac[n] % mod
}

func abs(i int) int {
	if i < 0 {
		return -i
	}
	return i
}

// 階乗: factorial
// コンビネーションを計算する際に前もって計算しておく
// fac[k] => k! (mod M)
// ifac[k] => k!^(M-2) (mod M)
// n: ex. 2 * 10^5 => 200001
// fac, ifac := factorial()
func factorial() (fac []int, ifac []int) {
	fac = make([]int, facNum)
	fac[0] = 1
	ifac = make([]int, facNum)
	ifac[0] = 1
	for i := 1; i < facNum; i++ {
		fac[i] = fac[i-1] * i % mod
		ifac[i] = ifac[i-1] * Pow(i, mod-2) % mod
	}
	return
}

// vs: sorted slice int value
func lowerBound(vs []int, v int) (index int) {
	n := len(vs) / 2
	m := len(vs)
	for m != n {
		if vs[n] < v {
			n = (m-n+1)/2 + n
			//m = m
		} else {
			m = n
			n = n / 2
		}
	}
	return n
}

func IntSlice(n, init int) []int {
	r := make([]int, n)
	for i := range r {
		r[i] = init
	}
	return r
}


Measured memory_bytes: 1776
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<functional>
#include<vector>
#include<queue>
#include<stack>
#include<set>
#include<map>
using namespace std;
#define MOD 1000000007
#define f(i,n) for(int i=0;i<int(n);i++)
#define N 200000


int main() {
	int n, k, t, m;
	int a[100];
	int b[100];
	int x, y, z;
	int s, ans;
	bool v = true;
	ans = 0;
while(true) {

	scanf("%d %d", &n, &m);
	if (n == 0 && m == 0)return 0;
	f(i, n)a[i] = n - i;
		f(i, m) {
			scanf("%d %d", &x, &y);
			f(i, n)b[i] = a[i];
			f(i, y)b[i] = a[i + x - 1];
			f(i, x - 1)b[y + i] = a[i];
			f(i, n)a[i] = b[i];
		}
		printf("%d\n", a[0]);
	}



	return 0;
}


Measured memory_bytes: 2684
#include"bits/stdc++.h"
using namespace std;

void Main() {
  int a, b;
  cin >> a >> b;
  string as = "", bs = "";
  for (int i = 0; i < b; i++) {
    as += '0' + a;
  }
  for (int i = 0; i < a; i++) {
    bs += '0' + b;
  }
  if (as < bs) cout << as << endl;
  else cout << bs << endl;
}

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  Main();
  return 0;
}


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


using namespace std;

#define REP(var,n) for(int var=0;var<(n);var++)
#define REPP(var,n) for(int var=1;var<(n);var++)
#define ALL(c) (c).begin(),(c).end()

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    int train[501][501] = {};
    int cum[501][501] = {};

    int m1,m2;
    for(int i=0; i<m; i++){
        cin >> m1 >> m2;
        train[m1][m2]++;
    }

    for(int i=1; i<n+1; i++){
        for(int j=1; j<n+1; j++){
            cum[i][j] = cum[i][j-1] + train[i][j];
        }
    }

    int a,b;
    int answer;

    for(int i=0; i<q; i++){
        answer = 0;
        cin >> a >> b;
        for(int j=a; j<=b; j++){
            answer += cum[j][b];
        }
        cout << answer << endl;
    }
    return 0;
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
#include<algorithm>
#include<math.h>
using namespace std;
 
template <class T> using V = vector<T>;
 
using ll = long long;
using db = double;
using st = string;
using ch = char;
using vll = V<ll>;
using vpll =V<pair<ll,ll>>;
using vst = V<st>;
using vdb = V<db>;
using vch = V<ch>;
 
 
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define rFOR(i,a,b) for(ll i=(a);i>(b);i--)
#define oFOR(i,a,b) for(ll i=(a);i<(b);i+=2)
#define bgn begin()
#define en end()
#define SORT(a) sort((a).bgn,(a).en)
#define REV(a) reverse((a).bgn,(a).en)
#define M(a,b) max(a,b)
#define rM(a,b) min(a,b)
#define fi first
#define se second
#define sz size()
#define gcd(a,b) __gcd(a,b)
#define co(a) cout<<a<<endl;
#define ci(a) cin>>a;
 
 
ll sum(ll n) {
  ll m=0;
  FOR(i,0,20){
    m+=n%10;
    n/=10;
    if(n==0){
      break;
    }
  }
  return m;
}
 
 
ll combi(ll n,ll m) {
  ll ans=1;
  rFOR(i,n,n-m){
    ans*=i;
  }
  FOR(i,1,m+1){
    ans/=i;
  }
  return ans;
}
 
 
ll lcm(ll a,ll b){
  ll n;
  n=a/gcd(a,b)*b;
  return n;
}
 
 
/****************************************\
| Thank you for viewing my code:)        |
| Written by RedSpica a.k.a. RanseMirage |
| Twitter:@asakaakasaka                  | 
\****************************************/
 
 
signed main() {
  ll n;
  	ci(n);
  vll A(9);
  FOR(i,0,n){
    ll a;
    	ci(a);
    if(a/400<=7) A[a/400]=1;
    else A[8]++;
  }
  ll ans=0;
  FOR(i,0,8) ans+=A[i];
  ll o=1;
  cout<<M(o,ans)<<" ";
  co(ans+A[8])
    }


Measured memory_bytes: 256
//In The Name Of God
#include <bits/stdc++.h>
#define int long long
#define F first
#define S second
#define mp make_pair
#define L(x) (2*(x))
#define R(x) ((2*(x))+1)
#define pii pair<int, int>
#define pb push_back
using namespace std;
const int N = 3e3 + 5, Mod = 1e9 + 7, P = 727, Lg = 17, TOF = 1900, Inf = 3e18;


int Dp[(1 << Lg)], A[Lg][Lg], Val[(1 << Lg)];

int32_t main(){
      ios_base::sync_with_stdio(0); cin.tie(0);
      int n; cin >> n;
      for(int i = 0; i < n; i++)
            for(int j = 0; j < n; j++)
                  cin >> A[i][j];
      for(int i = 0; i < (1 << n); i++){
            vector< int > bit;
            int now = i;
            while(now){
                  int ct = __builtin_ctz(now);
                  bit.pb(ct);
                  now ^= (1 << ct);
            }
            for(int j = 0; j < (int)bit.size(); j++)
                  for(int k = j + 1; k < (int)bit.size(); k++)
                        Val[i] += A[bit[j]][bit[k]];
      }
      for(int i = 0; i < (1 << n); i++){
            Dp[i] = Val[i];
            for(int j = i; ; j = (j - 1) & i){
                  Dp[i] = max(Dp[i], Dp[i ^ j] + Val[j]);
                  if(!j)
                        break;
            }
      }
      cout << Dp[(1 << n) - 1];
      return 0;
}



Measured memory_bytes: 1280
#include<bits/stdc++.h>                                                        
using namespace std;
int main()
{
  int N;
  cin >> N;
  int T,A;
  cin >> T >> A;
  vector<int> H(N);
  for(int i=0; i<N; i++){
    cin >> H.at(i);
  }
  double min=fabs(T-H.at(0)*0.006-A);
  double tmp=0;
  int ans;
  for(int i=0; i<N; i++){
    tmp=T-H.at(i)*0.006;
    double x=fabs(A-tmp);
    if(min>x){
      min=x;
      ans=i;
    }
  }
  cout << ans+1 << endl;
}


Measured memory_bytes: 256
//------------------------------>> tsukasa_diary's template <<------------------------------//
#include <bits/stdc++.h>
using namespace std;

#define for_(i,a,b) for(int i=(a);i<(b);++i)
#define for_rev(i,a,b) for(int i=(a);i>=(b);--i)
#define allof(a) (a).begin(),(a).end()
#define minit(a,b) memset(a,b,sizeof(a))

using lint = long long;
using pii = pair< int, int >;

template< typename T > using Vec = vector< T >;

template< typename T > bool in_range(T x, T lb, T ub) { return lb <= x && x < ub; }
template< typename T > bool in_range(T x, T y, T lb, T ub) { return in_range(x, lb, ub) && in_range(y, lb, ub); }

template< typename T > void modAdd(T& a, T b, T mod) { a = (a + b + mod) % mod; }
template< typename T > void modMul(T& a, T b, T mod) { a = (a * b) % mod; }
template< typename T > void minUpdate(T& a, T b) { a = min(a, b); }
template< typename T > void maxUpdate(T& a, T b) { a = max(a, b); }

int bitCount(int x) { return __builtin_popcount(x); }
int bitCount(lint x) { return __builtin_popcountll(x); }

const int dx[4] = {0,1,0,-1}, dy[4] = {-1,0,1,0};
const int Dx[8] = {0,1,1,1,0,-1,-1,-1}, Dy[8] = {-1,-1,0,1,1,1,0,-1};
const double EPS = 1e-9;
const double PI = acos(-1);

//--------------8---------------->> coding space <<-----------------8-------------//

lint extgcd(lint a, lint b, lint &x, lint &y) {
	if (b == 0) {
		x = 1;
		y = 0;
		return a;
	}
	lint d = extgcd(b, a % b, y, x);
	y -= a / b * x;
	return d;
}

lint invmod(lint a, lint MOD) {
    lint x, y;
    extgcd(a, MOD, x, y);
    return (x % MOD + MOD) % MOD;
}

const lint MOD = (lint)1e9 + 7;

int main() {
	int N, K;
	cin >> N >> K;
	
	vector<lint> A(N);
	for (int i=0; i<N; ++i) cin >> A[i];
	sort(A.begin(), A.end());
	
	vector<lint> X(N+1, 1), Y(N+1, 1);
	for (int i=1; i<=N; ++i) {
		X[i] = (X[i-1] * i) % MOD;
		Y[i] = invmod(X[i], MOD);
	}
	
	auto comb = [&](int a, int b) {
		lint ret = (X[a] * Y[b]) % MOD;
		ret = (ret * Y[a-b]) % MOD;
		return ret;
	};
	
	vector<lint> n_min(N, 0), n_max(N, 0);
	for (int i=0; i<N; ++i) {
		if (i <= N-K) n_min[i] = comb(N-i-1, K-1);
		if (i >= K-1) n_max[i] = comb(i, K-1);
	}
	
	lint ans = 0;
	for (int i=0; i<N; ++i) {
//		cerr << A[i] << " " << n_min[i] << " " << n_max[i] << endl;
		lint add = (A[i] * n_max[i]) % MOD;
		lint sub = (A[i] * n_min[i]) % MOD;
		modAdd(ans, add, MOD);
		modAdd(ans, -sub, MOD);
	}
	cout << ans << endl;
}
//--------------8---------------->> coding space <<-----------------8-------------//

Measured memory_bytes: 4224
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main(){
    int t;
    cin >> t;
    if(t%10==2||t%10==4||t%10==5||t%10==7||t%10==9){
        cout << "hon";
    }
    else if(t%10==3){
        cout << "bon";
    }
    else{
        cout << "pon";
    }
    return 0;
}


Measured memory_bytes: 3636
#include <iostream>
#include <numeric>
#include <vector>

struct UnionFind {
    std::vector<int> par, sz;
    int gnum;

    explicit UnionFind(int n)
        : par(n), sz(n, 1), gnum(n) {
        std::iota(par.begin(), par.end(), 0);
    }

    int find(int v) {
        return (par[v] == v) ? v : (par[v] = find(par[v]));
    }

    void unite(int u, int v) {
        u = find(u), v = find(v);
        if (u == v) return;

        if (sz[u] < sz[v]) std::swap(u, v);
        sz[u] += sz[v];
        par[v] = u;
        --gnum;
    }

    bool same(int u, int v) { return find(u) == find(v); }
    bool ispar(int v) { return v == find(v); }
    int size(int v) { return sz[find(v)]; }
};

void solve() {
    int n, m;
    std::cin >> n >> m;

    UnionFind uf(n);
    while (m--) {
        int u, v;
        std::cin >> u >> v;
        uf.unite(--u, --v);
    }

    std::cout << uf.gnum - 1 << "\n";
}

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

    solve();

    return 0;
}


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

int main() {
  long int n;
  long int a[200002] ;
  string s;

  for ( long int i=0 ; i < 200002 ; ++i ) {
    a[i] = -1 ;
  }

  cin >> n;

  for ( long int i=0 ; i < n ; ++i ) {
    cin >> a[i];
  }
  
  sort( a , a + n , greater<long int>());

  for ( long int i=0 ; i < n ; ++i ) {
    if ( a[i] == a[i + 1] ) {
      cout << "NO" << endl;
      return 0;
    }
  }

  cout << "YES" << endl;

}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    long a; cin >> a;
    long sum = 0;
    for(int i = 1; i <= a; i++){
        sum += i;
    }
    for(int i = 1; i <= a; i++){
        if(i%3 == 0 || i%5 == 0 ||i%15 == 0){
            sum -= i;
        }
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 3608
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		if(a<b){
			System.out.println("a < b");
		}else if(a>b){
			System.out.println("a > b");
		}else{
			System.out.println("a == b");
		}
	}
}

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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    int a, b;
    cin >> a >> b;
    int g = __gcd(a, b);
    long long lcm = 1ll * a * b / g;
    cout << lcm;
}

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

class Program
{
    static void Main(string[] args)
    {
        // 1 < K < 1000000
        var K = int.Parse(Console.ReadLine());

        // 偶数の場合、Kの倍数は存在しない
        if (K % 2 == 0)
        {
            Console.WriteLine("-1");
            return;
        }

        // 1の位が0 or 5の場合、Kの倍数は存在しない
        if (K % 5 == 0)
        {
            Console.WriteLine("-1");
            return;
        }

        int x = 7;
        int count = 1;

        while (true)
        {
            if (count > 1000000) break;
            // Xが割り切れたら終了
            if (x % K == 0) break;

            /* 割り切れなければ次の桁をKで割った余りに加算
             * 
             * K = 101のとき
             * 7 ≡ 7 (mod 101)
             * 
             * この時、77 = 7 * 10 + 7なので両辺に10をかけて7を足す
             * 7 * 10 + 7 ≡ 7 * 10 + 7 (mod 101)
             * 77 ≡ 77 (mod 101)
             * 
             * この操作を繰り返すと
             * 777 ≡ 777 (mod 101) ≡ 70 (mod 101)
             * 7777 ≡ 707 (mod 101) ≡ 0
             * 
             * なのでXをKで割った余りに10をかけて7を足す操作を繰り返し、0になった7の数列がKの倍数である
             */

            x = x % K * 10 + 7;
            count++;
        }

        Console.WriteLine(count);
    }
}


Measured memory_bytes: 27484
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
#define fi first
#define se second
#define pb push_back
#define all(x) x.begin(),x.end()
#define forn(i,a,n) for(int i=a; i < n; i++)
typedef long long int lli;
typedef long double Double;
typedef pair<int,int> pii;
typedef pair<lli,lli> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
const int maxn = 3005;
const int mod = 998244353;
const lli inf = 1e17;
lli dp[maxn][maxn][4];
lli mat[maxn][maxn];
int r,c;

lli solve(int i, int j, int s){
	if(s > 3) return -inf;

	if(i == r && j == c){
		if(s <= 2) return mat[i][j];
		return 0;
	}
	
	lli &res = dp[i][j][s];
	if(res != -1) return res;
	res =0;
	if(i+1 <= r){
		res = max(res,solve(i+1,j,0));
		if(s < 3)
			res = max(res,solve(i+1,j,0) + mat[i][j]);
	}

	if(j +1 <= c){
		res = max(res,solve(i,j+1,s));
		res = max(res,solve(i,j+1,s+1) + mat[i][j]);
	}

	return res;
}

void solve(){
	int k;
	cin >> r >> c >> k;
	for(int i=1; i <=k; i++){
		int x,y,v;
		cin >> x >>y >> v;
		mat[x][y] = v;
	}
	memset(dp,-1,sizeof(dp));
	cout << solve(1,1,0) << endl;
}

int main(){__
	int t=1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 356620
#include<stdio.h>
#include<stdlib.h>

int main()
{
    int a,b,c;
    scanf("%d%d%d", &a, &b, &c);
    int p,q,r;
    p=abs(a-b)+abs(a-c);
    q=abs(a-b)+abs(b-c);
    r=abs(a-c)+abs(b-c);
    int x=p<q?p:q;
    int y=x<r?x:r;
    printf("%d\n", y);
}


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

/*alias*/
#define REP(i,n) for (int i = 0; i < (n); i++)
#define ALL(obj) (obj).begin(), (obj).end()
using ll=long long;

using namespace std;

/*input*/
double a,b,t;

/*funcs*/


/*main*/
int main(){
    cin>>a>>b>>t;
    int p=(t+0.5)/a;
    cout<<p*b;
}

Measured memory_bytes: 256
#include<stdio.h>

int main(){
int H,W;
int n=10;
int c[n][n];

scanf("%d%d",&H,&W);
int A[H][W];
for(int i=0;i<n;i++){
	for(int j=0;j<n;j++){
		scanf("%d",&c[i][j]);
	}
}
for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
		scanf("%d",&A[i][j]);
	}
}
int C[n];
for(int j=0;j<n;j++){
	for(int k=0;k<n;k++){
		for(int l=0;l<n;l++){
			C[l]=c[l][1]+c[k][l];
			if(c[k][1]>C[l]){
				c[k][1]=C[l];
			}
		}
	}
}
int sum=0;
for(int i=0;i<H;i++){
	for(int j=0;j<W;j++){
		if(A[i][j]!=-1){
			sum=sum+c[A[i][j]][1];
		}
	}
}
printf("%d\n",sum);

}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <sstream>
#define ABS(x) ((x)<0? -(x):(x))
using namespace std;

int n, m, a, d;
string s[31];

string itos(int num){
	stringstream ss;
	ss << num;
	return ss.str();
}

bool moveRight(int x, int y){
	if (x+1 < n && s[y][x+1] == '1') return false;
	else return true;
}

bool moveLeft(int x, int y){
	if (x > 1 && s[y][x-2] == '1') return false;
	else return true;
}

int main(){
	int correct[31];
	int now;
	string ans;

	while (~scanf("%d\n", &n)) {
		if (n == 0) {
			break;
		}
		// initialize
		scanf("%d\n", &m); m--;
		scanf("%d\n", &a); a--;
		scanf("%d\n", &d);
		for (int i = 0; i < d; i++) {
			getline(cin, s[i]);
		}
		ans = itos(1);
		// find correct path by calc from bottom to top
		correct[d] = a;
		for (int i = d; i > 0 ; i--) {
			now = correct[i];
			if(now > 0 && s[i-1][now-1] == '1') { // move left
				correct[i-1] = now-1;
			}else if (now < n-1 && s[i-1][now] == '1') { // move right
				correct[i-1] = now+1;
			}else {
				correct[i-1] = now;
			}
		}
		// main
		now = m;
		for (int i = 0; i < d; i++) {
			if(now > 0 && s[i][now-1] == '1') { // move left
				now--;
			}else if (now < n-1 && s[i][now] == '1') { // move right
				now++;
			}else {
				if(now+1 == correct[i] && moveRight(now, i)){
					ans = itos(i+1) + " " + itos(now+1);
					break;
				}else if(now-1 == correct[i] && moveLeft(now, i)){
					ans = itos(i+1) + " " + itos(now);
					break;
				}
			}
		}
		if (correct[0] == m) {
			ans = itos(0);
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long int n=0,i=0,count=0,j=0,ans=0;
  	cin >> n;
    	for(i=2;i*i<=n;i++){
        	if(n%i==0){
            	count=0;
              	while(n%i==0){count++;n=n/i;}
				ans += (sqrt(1+8*count)-1)/2;
              	//cout << ans << endl;
            }
        }
  	if(n!=1){ans++;}
  	cout << ans << endl;
}

Measured memory_bytes: 3688