akhauriyash/Code-Regression huggingface dataset:
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
 
        for (int i = a; i <= b * a; ++i) {
            if (i % a == 0 && i % b == c) {
                _out.println("YES");
                return;
            }
        }
        _out.println("NO");
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

using namespace std;

int v[1010];
int main() {
    
    int n,mx = 0, mn = 1e9;
    cin >> n;
    
    for (int i = 0; i < n; ++i) {
        cin >> v[i];
        mx = max(mx, v[i]);
        mn = min(mn, v[i]);
    }

    int ans = 1e9;
    for (int i = mn; i <= mx; ++i) {
        int tot = 0;
        for (int j = 0; j < n; ++j) {
            tot += (i - v[j]) * (i - v[j]);
        }
        ans = min(ans, tot);
    }
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#include<stdlib.h>
#include<math.h>
#define ull unsigned long long int
#define ll long long
#define l long
#define sd(x) scanf("%d",x) 
#define sld(x) scanf("%ld",x) 
#define slld(x) scanf("%lld",x) 
#define sllu(x) scanf("%llu",x) 
#define ss(x) scanf("%s",x) 
#define rep(x) for(book[x].onoff=0;book[x].onoff<2;book[x].onoff++)
#define min(x,y) x<y?x:y

typedef struct hon{
  int cost;
  int up[12];
  int onoff;
}lebro;

l hyouka(lebro*book,int N,int M,int X){
  l sum=0;
  int ski[12]={};
  for(int i=0;i<N;i++){
    if(book[i].onoff==0){
      sum+=book[i].cost;
      for(int j=0;j<M;j++){
        ski[j]+=book[i].up[j];
      };
    };
  };
  //printf("%ld\n",sum);
  for(int j=0;j<M;j++){
    //printf("%d\n",ski[j]);
    if(ski[j]<X)return 10000000;
  };
  return sum;
};
  
int main(){
  int N,M,X;
  l ans=10000000;
  sd(&N);sd(&M);sd(&X);
  lebro book[12];
  for(int i=0;i<N;i++){
    sd(&book[i].cost);
    for(int j=0;j<M;j++)
      sd(&book[i].up[j]);
  };
  rep(0)rep(1)rep(2)rep(3)rep(4)rep(5)rep(6)rep(7)
    rep(8)rep(9)rep(10)rep(11){
    ans=min(hyouka(book,N,M,X),ans);
  };
  if(ans==10000000)printf("-1");
  else printf("%ld",ans);
};

Measured memory_bytes: 1736
#include<bits/stdc++.h>
using namespace std ; 
#define ll long long
typedef pair<ll,ll> pr;
typedef vector<ll> vc;
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repr(i,a,b) for(ll i=a;i>=b;i--)
#define reps(i,v) for(ll i=0;i<v.size();i++)
#define test  ll ll int tcase ; cin>>tcase ; while(tcase--) 
#define io ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

int main() {
    io ; 
   
   long long int x ; 
   cin>>x ; 
   long long int ans = 0  , mass = 100 ; 
   while(mass<x){
       mass = mass+ mass/100 ;
       ans++ ; 
   }
   cout<<ans ; 

   
}


Measured memory_bytes: 3652
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n,k;
    string s;
    
    cin >> n >> k;
    cin >> s;
    
    int rl[2] = {0};
    if (s[0] == 'L'){
        rl[0] = 1;
    }
    
    if (s[n-1] == 'R'){
        rl[1] = 1;
    }
    
    int unha = 0;
    for (int i = 0;i < n-1;i++){
        if (s[i] == 'R' && s[i+1] == 'L'){
            unha++;
        }
    }
    if (unha > k){
        cout << n-(2*(unha-k) + rl[0] + rl[1]) << endl;
    }
    else if (unha == k && rl[0] == 1 && rl[1] == 1){
        cout << n-2 << endl;
    }
    else {
        cout << n-1 << endl;
    }
    
}


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

// 総数を1000000007（素数）で割った余り
const long long mod = 1e9 + 7;

using ll = long long;
using pii  = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

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

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

int main(){
    int n;
    cin >> n;
    vll a(n);
    rep(i, n) cin >> a[i];
    ull ans = 1;
    bool big = false;
    rep(i, n) {
        if (a[i] == 0LL) {
            cout << 0 << endl;
            return 0;
        }
        if (big) continue;
        if (log10(ans) + log10(a[i]) > 18.0) big = true;
        ans *= a[i];
    }
    if (ans>1000000000000000000LL || big) cout << -1 << endl;
    else cout << ans << endl;
    return 0;
}


Measured memory_bytes: 4116
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
ll n, W;
ll weight[100005];
ll value[100005];
ll dp[101][100005];
ll ans(ll index,ll w){
    if(w == W){
        return 0;
    }
    if(index > n){
        return 0;
    }
    if(dp[index][w] != -1){
        return dp[index][w];
    }
    ll left = INT_MIN;
    if( w + weight[index] <= W){
    left = value[index] + ans(index+1,w+weight[index]);
    }
    ll right = ans(index+1,w);
    return dp[index][w] = max(left,right);
    
}

int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cin>>n>>W;
    memset(dp,-1,sizeof(dp));
    for(ll i=1;i<=n;i++){
        cin>>weight[i]>>value[i];
    }
    cout<<ans(1,0)<<"\n";
}


Measured memory_bytes: 80128
a, b, c, d= gets.chomp.split.map(&:to_i)
min = 0
max = 0
ans = 0
if b <= c
	puts 0
	exit
end
if a < c
	min = c
else
	min = a
end
if b < d
	max = b
else
	max = d
end
if 0 > max - min
	ans = 0
else
	ans = max - min
end
puts ans

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

#define REP(i, n) for(ll i = 0;i < n;i++)
#define REP1(i, n) for(ll i = 1;i < n;i++)
#define REPR(i, n) for(ll i = n-1;i >= 0;i--)
#define FOR(i, m, n) for(ll i = m;i < n;i++)

#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())

#define ll long long
#define ALL(a)  (a).begin(),(a).end()

#define pb(a) push_back(a)

int now,n,k;


int main(){
  int ans=0;
  cin >> n >> k;

	ans=n-k+1;
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 256
s = gets.chomp
result = 0

s.length.times do |i|
	s.slice!(-1)
	half_i = (s.length/2.0).ceil
	half_s = s.scan(/.{1,#{half_i}}/)
	if half_s[0] == half_s[1]
		result = s.length
		break
	end
end
puts result


Measured memory_bytes: 1916
#include <bits/stdc++.h>
#define WHOLE(v) (v).begin(), (v).end()
#define REV_WHOLE(v) (v).rbegin(), (v).rend()
using i64 = int64_t;
using namespace std;
template<typename T> using rev_priority_queue = priority_queue<T, vector<T>, greater<T>>;
template<typename T> using vector2d = vector<vector<T>>;
template<class S, class T> void map_init(map<S, T> &m, S k, T v){if(!m.count(k)) m[k] = v;}
void R_YESNO(bool p) { cout << (p ? "YES" : "NO") << endl; }
void R_YesNo(bool p) { cout << (p ? "Yes" : "No") << endl; }
int main() {
    int H, W;
    cin >> H >> W;
    vector<string> a(H);
    for (int i = 0; i < H; i++) {
        cin >> a[i];
    }
    vector<string> x[2];
    for (int i = 0; i < H; i++) {
        string s[2];
        s[0] = string(W, '.'), s[1] = string(W, '.');
        for(int j = 0; j < W; j++) {
            if(i != 0 && i != H - 1) s[i & 1][j] = a[i][j];
            if(j == 0) {
                s[1][j] = '#';
            } else if(j == W - 1) {
                s[0][j] = '#';
            } else {
                s[!(i & 1)][j] = '#';
            }
        }
        x[0].push_back(s[0]);
        x[1].push_back(s[1]);
    }

    for(auto str : x[0]) cout << str << endl;
    cout << endl;
    for(auto str : x[1]) cout << str << endl;
    return 0;
}

Measured memory_bytes: 1536
// Created by Nandu Vinodan
#include <bits/stdc++.h>

#define db1(x) cout<<#x<<"="<<x<<'\n'
#define db2(x,y) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<'\n'
#define db3(x,y,z) cout<<#x<<"="<<x<<","<<#y<<"="<<y<<","<<#z<<"="<<z<<'\n'
#define rep(i,a,n) for(int i=a;i<=(n);++i)
#define repD(i,a,n) for(int i=a;i>=(n);--i)
#define pb(a) push_back(a)
#define eb(a) emplace_back(a)
#define vi vector<int>
#define pi pair<int, int>
#define INF INT_MAX
#define _INF INT_MIN
#define TC 0

using namespace std;
using ll = long long;

void testcase() {
    int n; cin >> n;

    vector<ll> v(n);
    for (auto& it: v) {
        cin >> it;
    }
    int res = 0;
    sort(v.begin(), v.end());
    for (int i=0; i<n; i++) {
        for (int j=i+1; j<n; j++) {
            for (int k=j+1;k<n; k++) {
                set<int> s;
                s.insert(v[i]);
                s.insert(v[j]);
                s.insert(v[k]);
                if(s.size()==3 && (v[i] + v[j] > v[k]) && (v[i] + v[k] > v[j]) && (v[j] + v[k] > v[i])) {
                    res++;
                }
            }
        }
    }
    cout << res;
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t=1;
    if (TC)
        cin>>t;
    while(t--) {
        testcase();
    }
    return 0;
}

Measured memory_bytes: 3652
'''
問題：
    高橋君は金色の硬貨が好きです。
    自分が持っている 500円硬貨 1枚につき 1000、
    5円硬貨 1枚につき 5の嬉しさ を得ます。

    高橋君は X 円を持っています。
    これを高橋君の嬉しさが最大になるように両替したとき、高橋君の嬉しさはいくらになりますか？

    (なお、利用できる硬貨は 500 円玉、100 円玉、50 円玉、10 円玉、5円玉、1 円玉の 6 種類とします。)
'''

'''
    Xは整数
    0 ≦ X ≦ 1,000,000,000
'''
class A:
    def __init__(self, money, yorokobi):
        self.money = money
        self.yorokobi = yorokobi

    def calc_yorokobi(self, credit):    # credit ：残金を入力として受け取り、喜びを計算して返す
        return int(credit / self.money) * self.yorokobi

    # def print_self(self):
        # print(calc_yorokobi(self, credit))
# 
# def calc_yorokobi(input_money, x, yorokobi):
#     ret = input_money // x * yorokobi
#     return ret

# 標準入力から X の値を取得する
input_x = int(input())

yorokobi_500 = A(500, 1000)
yorokobi_5 = A(5, 5)

result = 0  # 結果格納用
if input_x >= 500:
    # print("1回目：{}".format(result))
    result += yorokobi_500.calc_yorokobi(input_x)   # 高橋500円の喜び
    # print("2回目：{}".format(result))
    result += yorokobi_5.calc_yorokobi(input_x % 500)   # 高橋5円の喜び
    # print("3回目：{}".format(result))
else:
    result += yorokobi_5.calc_yorokobi(input_x)

print(result)

# ret1 = input_x // 500  # 500円で割った商
# ret2 = ret1 * 1000  # 高橋君 500円の喜び
# ret3 = input_x - (ret1 * 500)   # X円から500円の枚数分を引いたお金
# ret4 = ret3 // 5 # （X円から500円の枚数分を引いたお金）÷ 5
# ret5 = ret4 * 5 # 高橋君 5円の喜び
# print(ret2 + ret5)


Measured memory_bytes: 9092
#include<bits/stdc++.h>
    #define ll long long
    #define db double
    #define mod 1000000007
    #define pb push_back
    #define pp pair<ll,ll>
    #define rep(i,a,b) for(ll i=a;i<b;i++)
    #define repe(i,a,b) for(ll i=a;i<=b;i++)
    #define repr(i,a,b) for(ll i=b;i>=a;i--)
    #define maxn 200005
    #define ss second
    #define ff first
    #define lb lower_bound
    using namespace std;
    void solve()
    {
        ll n,k;
        cin >> n >> k;
        map<ll,ll> mp;
        rep(i,0,k)
        {
            ll d;
            cin >> d;
            rep(j,0,d)
            {
                ll x;
                cin >> x;
                mp[x]++;
            }
        }
        ll ans=0;
        repe(i,1,n)
        {
            if(!mp.count(i))
            ans++;
        }
        cout << ans;
    }
    int main()
    {
        ios_base::sync_with_stdio(false);
        cin.tie(NULL);
        ll t=1;
        //cin >> t;
        while(t--)
        solve();
        return 0;
    }

Measured memory_bytes: 3656
import sys
sys.setrecursionlimit(10 ** 6)
# input = sys.stdin.readline    ####
int1 = lambda x: int(x) - 1
def II(): return int(input())

def MI(): return map(int, input().split())
def MI1(): return map(int1, input().split())

def LI(): return list(map(int, input().split()))
def LI1(): return list(map(int1, input().split()))
def LLI(rows_number): return [LI() for _ in range(rows_number)]

INF = float('inf')

from math import floor

def solve():
    a, b, n = MI()

    if n < b:
        q = n
    else:
        q = b - 1
    print(floor(a * q / b))


if __name__ == '__main__':
    solve()


Measured memory_bytes: 9156
#include "bits/stdc++.h"
// Begin Header {{{
#define all(x)          (x).begin(), (x).end()
#define rep(i, n)       for (i64 i = 0, i##_limit = (n); i < i##_limit; ++i)
#define reps(i, s, t)   for (i64 i = (s), i##_limit = (t); i <= i##_limit; ++i)
#define repr(i, s, t)   for (i64 i = (s), i##_limit = (t); i >= i##_limit; --i)
#define var(Type, ...)  Type __VA_ARGS__; input(__VA_ARGS__)
#ifndef DBG
#define trace(...)
#endif
using namespace std;
using i64 = int_fast64_t;
using pii = pair<i64, i64>;
template <class T, class U> inline bool chmax(T &a, const U &b) { return b > a && (a = b, true); }
template <class T, class U> inline bool chmin(T &a, const U &b) { return b < a && (a = b, true); }
inline i64  sigma(i64 n)            { return (n * (n + 1) >> 1); }
inline i64  updiv(i64 a, i64 b)     { return (a + b - 1) / b; }
inline i64  sqr(i64 n)              { return n * n; }
inline string to_string(char c)     { return string(1, c); }
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;

template <class T>
inline vector<T> make_v(const T &initValue, size_t sz) {
    return vector<T>(sz, initValue);
}
template <class T, class... Args>
inline auto make_v(const T &initValue, size_t sz, Args... args) {
    return vector<decltype(make_v<T>(initValue, args...))>(sz, make_v<T>(initValue, args...));
}

inline void input() {}
template <class Head, class... Tail>
inline void input(Head &head, Tail&... tail) { cin >> head; input(tail...); }

inline void print() { cout << "\n"; }
template <class Head, class... Tail>
inline void print(Head &&head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail)) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
inline ostream& operator<< (ostream &out, const vector<T> &vec) {
    static constexpr const char *delim[] = { " ", "" };
    for (const auto &e : vec) out << e << delim[&e == &vec.back()];
    return out;
}

template <typename Func>
struct FixPoint : Func {
    inline constexpr FixPoint(Func &&f) noexcept : Func(forward<Func>(f)) {}

    template <typename... Args>
    inline decltype(auto) operator()(Args &&... args) const {
        return Func::operator()(*this, forward<Args>(args)...);
    }
};

template< typename Func >
inline decltype(auto) makeFixPoint(Func &&f) {
    return FixPoint< Func >{forward< Func >(f)};
}
// }}} End Header

// n が素数ならtrueを返す。 O(sqrt(N))
constexpr bool isPrime(i64 n) // {{{
{
    if (n < 2) return false;
    if (n % 2 == 0) return (n == 2);
    for(i64 i=3; i*i <= n; i += 2) if(n % i == 0) return false;
    return true;
} // }}}

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

    var(i64, X);

    while (!isPrime(X)) ++X;

    print(X);

    return 0;
}


Measured memory_bytes: 256
D = int(input())
c_list = list(map(int,input().split(' ')))
s_list = []
for i in range(D):
    s_list.append(list(map(int,input().split(' '))))
t_list = []
for j in range(D):
    t_list.append(int(input()))
last_list = [0 for k in range(26)]
score = 0
point = 0
for day in range(D):
    point += s_list[day][t_list[day]-1]
    last_list[t_list[day]-1] = day+1
    for c in range(26):
        point -= c_list[c]*((day+1)-last_list[c])
    if(point>-1000000):
        score = point+1000000
    print(point)


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

int main() {
  int n;
  cin >> n;
  vector<int> b(n-1);
  rep(i,0,n-1) cin >> b[i];
  vector<int> a(n,0);
  a[0] = b[0];
  a[n-1] = b[n-2];
  rep(i,1,n-1) {
    a[i] = min(b[i-1],b[i]);
  }
  int ans = 0;
  rep(i,0,n) {
    ans += a[i];
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3584
#include <stdio.h>

int main(void) {
	int p[1048576] = {0},n,i,j,k;
	p[0] = 1;
	p[1] = 1;
	for(i = 4;i <= 1048576;i+=2){
		p[i] = 1;
	}
	for(i = 3;i <= 1025;i+=2){
		if(p[i]){continue;}
		else{
			for(j = i * 3;j <= 1048576;j+=(i * 2)){
				p[j] = 1;
			}
		}
	}
	while(scanf("%d",&n) , n != 0){
		k = 0;
		for(i = 2;i <= n/2;i++){
			if(p[i] == 0 && p[n - i] == 0){k++;}
		}
		printf("%d\n",k);
	}
	return 0;
}

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

#define watch(x) cout<<(#x)<<"="<<(x)<<'\n'
#define mset(d,val) memset(d,val,sizeof(d))
#define setp(x) cout<<fixed<<setprecision(x)
#define forn(i,a,b) for(int i=(a);i<(b);i++)
#define fore(i,a,b) for(int i=(a);i<=(b);i++)
#define pb push_back
#define F first
#define S second
#define pqueue priority_queue
#define fbo find_by_order
#define ook order_of_key
typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<ll> vi;
typedef vector<ii> vii;
typedef long double ld;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> pbds;
void amin(ll &a, ll b){ a=min(a,b); }
void amax(ll &a, ll b){ a=max(a,b); }
void YES(){cout<<"YES\n";} void NO(){cout<<"NO\n";}
void SD(int t=0){ cout<<"PASSED "<<t<<endl; }
const ll INF = ll(1e18);
const int MOD = 998244353;

const bool DEBUG = 0;
const int MAXN = 100005;

int main()
{
	ios_base::sync_with_stdio(0); cin.tie(0);
	
	int n; cin>>n;
	ll ans=0;
	for(ll i=1;i<=n;i++)
	{
		ll ba=0;
		for(ll L=1,R=n;L<=R;)
		{
			ll mid=(L+R)>>1;
			if(i*mid<n){ ba=mid; L=mid+1; }
			else R=mid-1;
		}
		ans+=ba;
	}
	cout<<ans<<'\n';
	
	return 0;
}


Measured memory_bytes: 3608
#include <iostream>

using namespace std;
const int mod = 1000000007;
long long a[2005]={0};
int main()
{
    int n;
    cin >> n;
    for(int i=3;i<=n;i++)
        a[i]=1;
    for(int i=3;i<=n;i++){
        for(int j=3;i-j>=3;j++){
            a[i]=(a[i]+a[j])%mod;
        }
    }
    cout << a[n] << endl;
    return 0;
}


Measured memory_bytes: 3616
#include <bits/stdc++.h>
using namespace std;
#define SELECTER(_1, _2, _3, SELECT, ...) SELECT
#define REP1(i, n) for(int i=0; (i)<(n); (i)++)
#define REP2(i, a, b) for(int i=(a); (i)<(b); (i)++)
#define REP(...) SELECTER(__VA_ARGS__, REP2, REP1,) (__VA_ARGS__)
#define MOD 998244353

template <class T> ostream& operator<<(ostream& os, const vector<T>& v){ os << "{"; for(size_t i=0; i<v.size(); i++) os << v[i] << (i+1==v.size() ? "" : ", "); os << "}"; return os; }
template <class T, class U> ostream& operator<<(ostream& os, const pair<T, U>& p){ return os << "{" << p.first << ", " << p.second << "}"; }

long long dp[333][333][333];

void add(long long &x, long long y){
    x = (x + y) % MOD;
}

int main(){
    string S;
    int K;
    cin >> S >> K;
    K = min(331, K);
    S.push_back('0');
    vector<int> v;
    int cnt = 0;
    for(int i=0; i<int(S.size()); i++){
        if(S[i]=='0'){
            v.push_back(cnt);
            cnt = 0;
        }
        else cnt++;
    }
    reverse(v.begin(), v.end());

    int N = v.size();

    dp[0][0][0] = 1;
    REP(i, N){
        REP(j, 333) REP(k, 333)
            dp[i+1][j][k] = dp[i][j][k];

        REP(j, 333){
            vector<long long> hoge(333);
            hoge[331] = dp[i][j][332];
            for(int k=330; k>=0; k--)
                hoge[k] = hoge[k+1] + dp[i][j][k+1];

            REP(k, 333){
                int x = v[i];
                long long val = dp[i][j][k];

                add(dp[i+1][j][k], hoge[k]);

                for(int l=1; l<=x; l++){
                    if(j+l>=333||k+l>=333) break;
                    add(dp[i+1][j+l][k+l], val);
                }
            }
        }
    }
    long long ans = 0;
    for(int i=0; i<=K; i++){
        add(ans, dp[N][i][0]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 263452
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <deque>
#include <queue>
#include <string>
#include <string.h>
#include <math.h>
#include <iomanip>
#include <stdio.h>
using namespace std;

#define int64 long long
#define pii pair <int64, int64>
#define fr first
#define sc second
#define heap priority_queue
struct piii{
    int64 fr, sc, th;
    bool operator < (const piii &b){
        if (fr != b.fr) return fr < b.fr;
        if (sc != b.sc) return sc < b.sc;
        return th < b.th;
    }
};
///////////////////////////////////////////////
///////////////////////////////////////////////

string s;

int main(){
    cout << setprecision(2) << fixed;
    ios::sync_with_stdio(false), cin.tie(0);
    //freopen("input.txt", "r", stdin);
    cin >> s;
    int res = 0;
    for (int i = 0; i < (s.size() + 1) / 2; i++)
        if (s[i] != s[s.size() - i - 1]) res++;
    cout << res;
    return 0;
}


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

namespace easy_Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            double[] ab = Array.ConvertAll(Console.ReadLine().Split(),double.Parse);
            double resf = (ab[0]+ab[1])/2;
            int res = (int)resf;
            if(res == resf){
                Console.WriteLine(res);
            }else{
                Console.WriteLine("IMPOSSIBLE");
            }
        }
            // float[] ABN = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // long[] NK = Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // long N = NK[0];
            // long K = NK[1];
            // long K = long.Parse(Console.ReadLine());
            // int[] abc = Array.ConvertAll(Console.ReadLine().Split(),int.Parse);
            // string S = Console.ReadLine();
            // int x = int.Parse(Console.ReadLine());
            // int b = int.Parse(Console.ReadLine());
            // int N = int.Parse(Console.ReadLine());
            // float N = float.Parse(Console.ReadLine());
            // string c = Console.ReadLine();
            // string B = Console.ReadLine();
            // string[] s = Console.ReadLine().Split();
            // var s = (new string[] { Console.ReadLine(), Console.ReadLine(), Console.ReadLine() }).Select(float.Parse);
            // float[] a = Array.ConvertAll(Console.ReadLine().Split(),float.Parse);
            // var X = Console.ReadLine();
            // int[,] abcd = new int[NMQ[2],4];
            // int[] A = new int[NMQ[0]];
            // int[] A_num = new int[NMQ[0]];
            // long[] s=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            // var hs=new Dictionary<long,long>();
            // for(int i=0;i<s[0];i++){
            //     long[] q=Array.ConvertAll(Console.ReadLine().Split(),long.Parse);
            //     if(hs.ContainsKey(q[0])){hs[q[0]]+=q[1];}
            //     else{hs.Add(q[0],q[1]);}
            // }
        
        // //最小公倍数
        // static long Lcm(long a, long b)
        // {
        //     return a/Gcd(a,b)*b;
        // }

        // //最大公約数
        // static long Gcd(long m, long n)
        // {
        //     if(n==0)return m;
        //     return Gcd(n,m%n);
        // }
    }
}


Measured memory_bytes: 27396
#include <bits/stdc++.h>
using namespace std;
#include <cstdlib>
char in[120];
pair<pair<string, int>, int> p[110];
int main(){
    int a;
    scanf("%d", &a);
    for(int i =0; i<a; i++){
        int t;
        scanf("%s%d", in, &t);
        string tmp = in;
        p[i] = make_pair(make_pair(in, -t), i);
    }
    sort(p, p +a);
    for(int i =0; i<a; i++){
        printf("%d\n", p[i].second +1);
    }
}

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()
#define RANGE(a, l, r)  (a).begin()+(l),(a).begin()+(r)

int main() {
	int n;
	cin >> n;
	vector<int> cnt(n + 1);
	FOR(i, 2, n) {
		int a;
		cin >> a;
		cnt[a]++;
	}
	FOR(i, 1, n) {
		pv(cnt[i])
	}
	return(0);
}

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

using namespace std;

int main() {
	int h, w, k;
	cin >> h >> w >> k;
	
	vector<string> c(h);
	for(int i = 0; i < h; ++i) {
		cin >> c[i];
	}

	int ans = 0;
	for(int x = 0; x < 1 << h; ++x) {
		for(int y = 0; y < 1 << w; ++y) {
			int cnt = 0;
			for(int i = 0; i < h; ++i) {
				for(int j = 0; j < w; ++j) {
					if(c[i][j] == '#' && !(x >> i & 1) && !(y >> j & 1)) {
						cnt += 1;
					}
				}
			}
			if(cnt == k) {
				ans += 1;
			}
		}
	} 

	cout << ans << '\n';

	return 0;
}


Measured memory_bytes: 3600
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.HashMap;
import java.util.Map.Entry;

public class Main
{

  public static void main(String[] args) throws IOException
  {
    BufferedReader r = new BufferedReader(new InputStreamReader(System.in), 1);
    int n = Integer.parseInt(r.readLine());
    int min = 0;

    HashMap<Integer, Integer> a = new HashMap<Integer, Integer>();

    String[] ls = r.readLine().split("[\\s]+");

    for(String s : ls)
    {
      int x = Integer.parseInt(s);
      if(x > 100000)
      {
        min++;
      }
      else
      {
        a.put(x, (a.get(x) == null ? 0 : a.get(x)) + 1);
      }
    }

    for(Entry<Integer, Integer> e : a.entrySet())
    {
      int x = e.getKey();
      int card = e.getValue();

      if(x <= card)
      {
        min += card - x;
      }
      else
      {
        min += card;
      }
    }

    System.out.println(min);

  }

}

Measured memory_bytes: 53192
#include<cstdio>
#include<cstring>
using namespace std;
const int maxn=20,inf=0x3F3F3F3F;
int n,m,X,A[maxn][maxn],C[maxn],ans=inf,tep[maxn];
int main()
{
	scanf("%d%d%d",&n,&m,&X);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&C[i]);
		for(int j=1;j<=m;j++)
			scanf("%d",&A[i][j]);
	}
	for(int s=1;s<(1<<n);s++)
	{
		int sum=0;memset(tep,0,sizeof(tep));
		for(int i=1;i<=n;i++)
		{
			if(s&(1<<(i-1)))
			{
				sum+=C[i];
				for(int j=1;j<=m;j++) tep[j]+=A[i][j];
			}
		}
		bool suc=true;
		for(int i=1;i<=m;i++) if(tep[i]<X) suc=false;
		if(suc&&sum<ans) ans=sum;
	}
	if(ans==inf) ans=-1;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1728
#include <bits/stdc++.h>
#define ll long long
using namespace std;
const int N = 4e5 + 5, mod = 998244353;


int main(){
    ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
    int n, k;
    cin >> n >> k;
    vector<int> v, v2;
    for(int i = 0; i < n; i++){
        int x;
        cin >> x;
        if(x < 0) v2.push_back(-x);
        else v.push_back(x);
    }
    int ans = 2e9;
    sort(v2.begin(), v2.end());
    for(int i = 0; i < v.size(); i++){
        int idx = k - (i + 1) - 1;
        if(idx < v2.size()) ans = min(ans, v[i] + v[i] + v2[idx]);
    }
    for(int i = 0; i < v2.size(); i++){
        int idx = k - (i + 1) - 1;
        // cout << idx << ' ' << v[idx] << '\n';
        if(idx < v.size()) ans = min(ans, v2[i] + v2[i] + v[idx]);
    }
    if(v.size() >= k) ans = min(ans, v[k - 1]);
    if(v2.size() >= k) ans = min(ans, v2[k - 1]);
    cout << ans;


    return 0;

}




Measured memory_bytes: 1020
#include <iostream>
#include <vector>
#include <string>

using namespace std;

void move(vector<vector<int> >& a, vector<string>& moves, int i, int j, int h, int w) {
  a[i][j]--;
  if (i < h - 1) {
    a[i + 1][j]++;
    moves.push_back(to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 2) + " " + to_string(j + 1));
  }
  else if (j < w - 1) {
    a[i][j + 1]++;
    moves.push_back(to_string(i + 1) + " " + to_string(j + 1) + " " + to_string(i + 1) + " " + to_string(j + 2));
  }
}

int main() {
  int h, w;
  cin >> h >> w;
  vector<vector<int> > a(h, vector<int>(w));
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      cin >> a[i][j];
    }
  }

  vector<string> moves;
  for (int i = 0; i < h; i++) {
    for (int j = 0; j < w; j++) {
      if (a[i][j] % 2) {
	move(a, moves, i, j, h, w);
      }
    }
  }
  cout << moves.size() << endl;
  for (string s : moves) {
    cout << s << endl;
  }
}


Measured memory_bytes: 11892
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

struct info {
    int X, H;
};

signed main() {
    int N, D, A;
    cin >> N >> D >> A;
    vector<info> monster;
    for (int i = 0; i < N; i++) {
        int X, H;
        cin >> X >> H;
        monster.push_back({X, H});
    }
    auto sorting = [&](info a, info b) {
        return a.X < b.X;
    };
    sort(monster.begin(), monster.end(), sorting);
    vector<info> bomb;
    bomb.push_back({0, 0});
    function<bool(info, int)> comp = [&](info a, int b) {
        return (a.X < b);
    };

    auto attack = [&](int X) {
        auto itr = lower_bound(bomb.begin(), bomb.end(), X, comp);
        if (itr == bomb.begin()) return 0LL;
        return ((bomb.end() - 1)->H - (itr - 1)->H);
    };
    int ans = 0;
    for (auto temp : monster) {
        int remain = temp.H - attack(temp.X);
        if (remain <= 0) continue;
        int count = remain / A + (remain % A != 0);
        bomb.push_back({temp.X + (2 * D), (bomb.end() - 1)->H + A * count});
        ans += count;
    }
    cout << ans << endl;
}

Measured memory_bytes: 11884
#include<iostream>
using namespace std;
int main(void) {
	int base, c5=0, c7=0;
	for (int i = 0; i < 3; i++) {
		cin >> base;
		if (base == 5)c5++;
		else if (base == 7)c7++;
	}
	if (c5 == 2 && c7 == 1)cout << "YES";
	else cout << "NO";
	cout << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define M 1000003
using namespace std;

typedef long long ll;

const int mod = M;

ll mod_pow(ll a,ll x){
  ll res=1;
  while(x){
    if(x%2) res=res*a%mod;
    a=a*a%mod;
    x/=2;
  }
  return res;
}

ll inv(ll x){
  return mod_pow( x, mod - 2 );
}

int X[M], invX[M];

void init(){
  
  int num = 1;
  
  for(int i=1;i<M;i++){
    num *= i;
    num %= mod;
    X[i] = num;
  }
  
  for(int i=0;i<M;i++) invX[i] = inv( X[i] );
  
}

int cal(int x, int d, int n){
  
  if( d == 0 ) return mod_pow( x, n );
  
  int R = ( x * inv( d ) + ( n - 1 ) ) % mod;
  int L = ( x * inv( d ) - 1 + mod ) % mod;
  int l = ( R - ( n - 1 ) - 1 );
  if( l <= 0 ) return 0;
  return ( ( X[R] * invX[L] ) % mod * mod_pow( d, n ) ) % mod;
}

signed main(){
  
  init();
  
  int q;
  cin >> q;
  
  while( q-- ){
    
    int x, d, n;
    cin >> x >> d >> n;
    
    cout << cal( x, d, n ) << endl;
    
  }
  
  return 0;
}


Measured memory_bytes: 16512
/* ?????¢????????¨?????? 586 + 79 = 665(KiB) ??????????????????????????? */
/* ????´°??????????????§ */
#include <iostream>
#include <vector>
#include <cstdio>

struct JobRecord
{
	int staff;
	int job;
	int count;
};

int main(void)
{
	using namespace std;

	int num_of_staffs, num_of_jobs;
	cin >> num_of_staffs >> num_of_jobs;

	vector<JobRecord> v_job_record;
	vector<int> v_staff, v_job, v_count;

	/* ??\???????¨?????????????????????? */
	/* ?????§ 50000 ?????????????????? */
	/* ????????§?????¢????????¨?????? 50000(???) * 3(??????, ??????????¨????, ?????°) * 4(Bytes) = 600000(Bytes) ==> ?´?586KiB */
	while(1)
	{
		JobRecord input;
		cin >> input.staff >> input.job >> input.count;
		if( input.staff == 0 && input.job == 0 && input.count == 0 )
		{
			break;
		}
		
		/* ??\??????????????? */
		v_job_record.push_back(input);
	}

	int num_of_calc;
	cin >> num_of_calc;

	/* ???????¨???? */
	for(int calc_count = 0; calc_count < num_of_calc; calc_count++)
	{
		/* ???????¨???????????????§?????¢????????¨??????????¨??????¨?????? */
		/*   v_unit_price : 10000(??\???????¨?????????§) * 4 = 40000 Bytes */
		/*   v_salary     : 10000(????????°?????§)     * 4 = 40000 Bytes */
		/* ????¨???§ 80000 Bytes ==> ?´? 79 KiB */
		vector<int> v_unit_price(num_of_jobs);	/* ???????????¨????????? */
		vector<int> v_salary(num_of_staffs, 0);	/* ???????????¨?????????. ????????? 0 ????????????????¨???? */

		/* ??\??? */
		for(int job = 0; job < num_of_jobs; job++)
		{
			cin >> v_unit_price[job];
		}

		/* ?¨???? */
		for(int i = 0; i < v_job_record.size(); i++)
		{
			/* ???????????\???????¨??????? 1????????????????????§?????????????????????????????¨???????????? 0??????????????????????????? */
			int staff      = v_job_record[i].staff;
			int job        = v_job_record[i].job;
			int count      = v_job_record[i].count;
			int unit_price = v_unit_price[ job - 1 ];
			
			v_salary[ staff - 1 ] += unit_price * count;
		}
		
		/* ?????? */
		int n = v_salary.size();
		for(int j=0;j<n;j++)
		{
			printf(j<n-1?"%d ":"%d\n",v_salary[j]);
		}
	}

	return 0;
}

Measured memory_bytes: 3788
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int num = 55555;
		boolean isPrime = false;
		List<Integer> list = new ArrayList<>();
		for (int i = 7; i < num; i++) {
			for (int j = 2; j * j <= i; j++) {
				if (i % j == 0) {
					isPrime = false;
					break;
				}
				isPrime = true;
			}
			if (isPrime && i % 5 == 1) {
				list.add(i);
			}
		}
		String ans = "";
		for (int i = 0; i < N; i++) {
			if (i == N - 1) {
				ans += list.get(i);
			} else {
				ans += list.get(i) + " ";
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 23636
x,y = map(int, input().split())
ans = 0
if x == 1:
  ans = 300000
elif x == 2:
  ans = 200000
elif x == 3:
  ans = 100000
  
if y == 1:
  ans += 300000
elif y == 2:
  ans += 200000
elif y == 3:
  ans += 100000
  
if x ==1 and y == 1:
  ans += 400000
  
print(ans)  

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

int main() {
    int A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;

    int sum = 0;
    if (A + B > 2 * C) {
        while (X > 0 && Y > 0) {
            sum += 2 * C;
            --X;
            --Y;
        }
        if (X > 0) {
            if (A > 2 * C) {
                while (X > 0) {
                    sum += 2 * C;
                    --X;
                }
            }
            else {
                while (X > 0) {
                    sum += A;
                    --X;
                }
            }
        }
        else {
            if (B > 2 * C) {
                while (Y > 0) {
                    sum += 2 * C;
                    --Y;
                }
            }
            else {
                while (Y > 0) {
                    sum += B;
                    --Y;
                }
            }
        }
    }
    else {
        sum += X * A + Y * B;
    }

    cout << sum << endl;
}

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cout<<#v<<":";for(int i=0;i<v.size();i++) cout<<" "<<v[i]; cout<<endl

typedef long long ll;
#define vi vector<int>
#define vl vector<ll>
#define vii vector< vector<int> >
#define vll vector< vector<ll> >
#define vs vector<string>
#define pii pair<int,int>
#define pis pair<int,string>
#define psi pair<string,int>
#define pll pair<ll,ll>
const int inf = 1000000001;
const ll INF = 2e18 * 2;
#define MOD 1000000007
#define mod 1000000009
#define pi 3.14159265358979323846
#define Sp(p) cout<<setprecision(15)<< fixed<<p<<endl;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
int dx2[8] = { 1,1,0,-1,-1,-1,0,1 }, dy2[8] = { 0,1,1,1,0,-1,-1,-1 };

#define H 805
#define W 805
vii a(H + 2, vi(W + 2, -1));
int h, w, k;

void bfs(pii start) {
	queue<pii> que;
	que.push(start);
	while (!que.empty()) {
		pii now = que.front();
		que.pop();
		int d = a[now.first][now.second];
		if (d == k) {
			continue;
		}
		for (int i = 0; i < 4; i++) {
			if (a[now.first + dx[i]][now.second + dy[i]] > d + 1) {
				a[now.first + dx[i]][now.second + dy[i]] = d + 1;
				que.push(pii(now.first + dx[i], now.second + dy[i]));
			}
		}
	}
}

int main() {
	int i, j;
	cin >> h >> w >> k;
	int si, sj;
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			char c;
			cin >> c;
			if (c == '#') {
				a[i][j] = -1;
			}
			else if (c == '.') {
				a[i][j] = inf;
			}
			else {
				a[i][j] = 0;
				si = i;
				sj = j;
			}
		}
	}
	bfs(pii(si, sj));
	int m = inf;
	for (i = 1; i <= h; i++) {
		for (j = 1; j <= w; j++) {
			if (a[i][j] >= 0 && a[i][j] <= k) {
				m = min(m, min(min(i - 1, h - i), min(j - 1, w - j)));
			}
		}
	}
	cout << 1 + (m + k - 1) / k << endl;
}

Measured memory_bytes: 2816
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        char[] s = scanner.next().toCharArray();
        long ans = s.length * (s.length - 1L) / 2 + 1;
        long[] count = new long[26];
        for (char c : s) {
            count[c - 'a']++;
        }
        for (long a : count) {
            ans -= a * (a - 1) / 2;
        }
        System.out.println(ans);
    }
}

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

int main(){
    int N,K;
    cin >> N >> K;
    int P[N];
    for(int i=0;i<N;++i){
        cin >> P[i];
    }
    vector<int>q;
    q.insert(q.begin(),P[0]);
    for(int i=1;i<K;++i){
        q.insert(lower_bound(q.begin(),q.end(),P[i]),P[i]);
    }
   
    int c=1;
    if(N==K){
        cout<<1;
        return 0;
    }
    for(int i=K;i<N;++i){
        if(!(P[i]>q[K-1] && P[i-K]==q[0])){
            c+=1;
        }
        q.erase(lower_bound(q.begin(),q.end(),P[i-K]));
        q.insert(lower_bound(q.begin(),q.end(),P[i]),P[i]);
        
    }
    int t=0;
    int r=1;
    for(int i=0;i<N-1;++i){
        
        if(P[i]<P[i+1]){
            r+=1;
        }else{
            if(r>=K){
                t+=1;
            }
            r=1;
        }
    }
    if(r>=K){
        t+=1;
    }
    if(t>0){
        cout << c+1-t;
    }else{
        cout << c;
    }
    return 0;
}

Measured memory_bytes: 2168
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
int cmp(const void* a, const void* b)
{
	return*(int*)a - *(int*)b;
}
int main()
{
	int i, j, n, a[110], num = 0,k;
	scanf("%d", &n);
	for (i = 0; i < n; i++)
	{
		scanf("%d", &a[i]);
	}
	qsort(a, n, sizeof(a[0]), cmp);
	if (n < 3)
	{
		printf("0");
	}
	else
	{
		for (i = 0; i < n - 2; i++)
		{
			for (j = i + 1; j < n - 1; j++)
			{
				if (a[i] != a[j])
				{
					for (k = j + 1; k < n; k++)
					{
						if (a[j]!=a[k]&&a[i] + a[j] > a[k])
						{
							num++;
						}
					}
				}
			}
		}
		printf("%d", num);
	}
	return 0;
}

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

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

    double ans = 0;
    for (int n = 1; n <= N; ++n) {
        double prob = 1.0/N;
        int coin = 0;
        int point = n;
        while (point < K) {
            point *= 2;
            prob /= 2;
        }
        ans += prob;
    }
    cout << fixed << setprecision(12) << ans << endl;
}

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

int main(){
    int N;

    scanf("%d", &N);

    char *S = (char *) malloc(sizeof(char) * (N + 1));

    scanf("%s", S);

    int left2right[10], right2left[10];

    for(int i = 0; i < 10; i ++){
        left2right[i] = right2left[i] = -1;
    }
    for(int i = 0; i < N; i ++){
        if(left2right[S[i] - '0'] == -1){
            left2right[S[i] - '0'] = i;
        }
    }
    for(int i = N - 1; i >= 0; i --){
        if(right2left[S[i] - '0'] == -1){
            right2left[S[i] - '0'] = i;
        }
    }
    int ans = 0;

    for(int i = 0; i < 10; i ++){
        for(int j = 0; j < 10; j ++){
            if(left2right[i] == -1 || right2left[j] == -1 || left2right[i] >= right2left[j]){
                continue;
            }
            int exist[10];

            for(int k = 0; k < 10; k ++){
                exist[k] = 0;
            }
            for(int k = left2right[i] + 1; k < right2left[j]; k ++){
                if(exist[S[k] - '0'] == 0){
                    exist[S[k] - '0'] = 1;
                }
            }
            for(int k = 0; k < 10; k ++){
                if(exist[k] == 1){
                    ans ++;
                }
            }
        }
    }
    printf("%d\n", ans);
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<cstdlib>
#include<ctime>
#include<stack>
#include<queue>
#include<set>
#include<map>
#include<vector>
#define mem(name,value) memset(name,value,sizeof(name))
#define loop(i,from,to) for(int i=from;i<to;i++)
#define loopr(i,from,to) for(int i=from;i>=to;i--)
#define pb push_back
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
const int INF=0x3f3f3f3f;

const int maxn=1000000+5;
int pr[maxn];
bool is_pr[maxn];

int sieve(int n){
    int p=0;
    loop(i,0,n+1) is_pr[i]=true;
    is_pr[0]=is_pr[1]=false;
    loop(i,2,n+1){
        if(is_pr[i]){
            pr[p++]=i;
            for(int j=2*i;j<=n;j+=i)
                is_pr[j]=false;
        }
    }
    return p;
}

int main()
{
    int n;
    while(cin>>n)
        cout<<sieve(n)<<endl;
}

Measured memory_bytes: 4308
def pad_zero(s, n):
	s = str(s)
	return ("0" * n + s)[-n:]

def main():
	N = int(input())
	F = [[int(f) for f in input().split(" ")] for i in range(N)]
	P = [[int(p) for p in input().split(" ")] for i in range(N)]

	total_profit = []
	for b in range(1, 2 ** 10):
		sale_bit = list(pad_zero(format(b, 'b'), 10))
		profit = 0
		for i in range(len(F)):
			f = F[i]
			p = P[i]
			profit += p[sum([fjk * int(s) for (fjk, s) in zip(f, sale_bit)])]
		total_profit.append(profit)
	print(max(total_profit))


main()

Measured memory_bytes: 9208
#include <bits/stdc++.h>
using namespace std;
 
 
int main() {
 
  string s;
  cin>>s;

  vector<int> found_char(26,0);
  for(int i=0;i<s.size();i++){
    char wk=s.at(i);
    found_char.at(wk-'a')++;
  }

  bool flg=false;
  char not_found='?';
  for(int i=0;i<26;i++){
    if(found_char.at(i)==0){
      not_found=(char)(i+'a');
      break;
    }

    if(i==26-1)
      flg=true;
  }


  if(flg)
    cout<<"None"<<endl;
  else
    cout<<not_found<<endl;

	return 0;
}

Measured memory_bytes: 3704
#include<iostream>
#include<vector>
#include<string>
#include<array>
#include<cmath>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<numeric>
#include<iomanip>
#include<utility>
#include<cstdlib>
#include<typeinfo>
typedef long long int lint;

lint gcd(lint a, lint b) {
    if (b == 0)
        return a;

    return gcd(b, a % b);
}
lint lcm( lint m, lint n )
{
	// 引数に０がある場合は０を返す
	if ( ( 0 == m ) || ( 0 == n ) )
		return 0;
	
	return ((m / gcd(m, n)) * n); // lcm = m * n / gcd(m,n)
}//lcm
using namespace std;
#define INF 1000000005
int main()
{
lint n,m;
std::string s;
std::string t;
std::cin >> n >> m;
std::cin >> s >> t;
lint out = 0;
//if(n > m){
    /*if(n % m == 0){
        int step = n / m;
        int index = 0;
        for(int i = 0; i < n; i += step){
            if(s[i] != t[index]){
                out = -1;
                break;
            } 
            index++;
        }
        if(out != -1){
            out = n;
        }
    } else {*/
        lint gc = gcd(n,m);
        lint steps = n/gc;
        lint stept = m/gc;
        lint indexs = 0;
        lint indext = 0;
        while(indexs < n && indext < m){
            if(s[indexs] != t[indext]){
                out = -1;
                break;
            } 
            indext += stept;
            indexs += steps;
        }
        if(out != -1){
            out = n * stept;
        } 
    //}
/*}else {
    if(m % n == 0){
        int step = m / n;
        int index = 0;
        for(int i = 0; i < m; i += step){
            if(t[i] != s[index]){
                out = -1;
                break;
            } 
            index++;
        }
        if(out != -1){
            out = m;
        }
    } else {
        int gc = gcd(n,m);
        int steps = n/gc;
        int stept = m/gc;
        int index = 0;
        for(int i = 0; i < m; i += stept){
            if(t[i] != s[index]){
                out = -1;
                break;
            } 
            index += steps;
        }
        if(out != -1){
            out = lcm(n,m);
        } 
    //}
}*/

std::cout << out << std::endl;
return 0;
}

Measured memory_bytes: 512
# coding: utf-8
A = input()
B = input()
flg = 2
if len(A) > len(B):
    flg = 0
elif len(A) < len(B):
    flg = 1
else:
    for i in range(len(A)):
        if int(A[i]) > int(B[i]):
            flg = 0
            break
        elif int(A[i]) < int(B[i]):
            flg = 1
            break
print(['GREATER', 'LESS', 'EQUAL'][flg])


Measured memory_bytes: 3060
n,m = map(int,input().split())
ab = [list(map(int,input().split())) for i in range(n)]
cd = [list(map(int,input().split())) for i in range(m)]
for i in ab:
	man = []
	for j in cd:
		man.append(abs(i[0]-j[0])+abs(i[1]-j[1]))
	print(man.index(min(man))+1)

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

int main() {
  int n,m;
  cin >> n >> m;
  int d[n],d2[n],ans=0;
  fill(d,d+n,1<<29);
  fill(d2,d2+n,1<<29);
  for(int i=0,x; i<m; i++) {
    cin >> x;
    d[x-1]=d2[x-1]=0;
  }
  for(int i=1; i<n; i++) d[i]=min(d[i],d[i-1]+1);
  for(int i=n-2; i>=0; i--) d2[i]=min(d2[i],d2[i+1]+1);
  for(int i=0; i<n; i++) ans=max(ans,min(d[i],d2[i]));
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3884