akhauriyash/Code-Regression huggingface dataset:
a,b,k = map(int,input().split())
ans = set()

if(b-a <= k-1):
    for i in range(a,b+1):
        ans.add(i)
else:
    for i in range(a,a+k):
        ans.add(i)

    for i in reversed(range(b-k+1,b+1)):
        ans.add(i)

ans = list(ans)
ans.sort()

for i in range(len(ans)):
  print(ans[i])

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

int main()
{
	int nCount = 0;
	int nArr[4][3][10] = {}; //all 0
	cin >> nCount;
	int nB, nF, nR, nV;
	while (nCount--)
	{
		cin >> nB >> nF >> nR >> nV;
		nArr[nB - 1][nF - 1][nR - 1] += nV;
	}
	for (int b = 0; b < 4; ++b)
	{
		for (int f = 0; f < 3; ++f)
		{
			for (int r = 0; r < 10; ++r)
			{
				printf(" %d", nArr[b][f][r]);
			}
			cout << endl;
		}
		if (3==b)
		{
			break;
		}
		cout << "####################" << endl;
	}

	//system("pause");
	return 0;
}

Measured memory_bytes: 3248
#include <bits/stdc++.h>
using namespace std;
//BITを用いる解法O(mlogn)
const int mod=1e5;
int n,m;
const int bitsize=(1<<20);
int s[100010];
int a[100010];
long long bit[bitsize];
void makebit(){
	for(int i=1;i<n;i++){//扱いやすさの都合上0は用いない
		int now=i;
		while(now<bitsize){
			bit[now]+=s[i];
			now+=(now&-now);
		}
	}
	for(int i=0;i<bitsize;i++)	bit[i]%=mod;
}
int cntbit(int now){
	now--;
	int ans=0;
	while(now>0){
		ans+=bit[now];	ans%=mod;
		now-=now&-now;
	}
	return ans;
}
int main(){
	cin>>n>>m;
	for(int i=1;i<n;i++)	cin>>s[i];
	makebit();
	int now=1;
	int ans=0;
	for(int i=0;i<m;i++){
		cin>>a[i];
		int next=now+a[i];
		if(a[i]>0)	ans+=cntbit(next)-cntbit(now);
		else 	ans+=cntbit(now)-cntbit(next);
		ans%=mod;
		now=next;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 10132
import collections as col
n = int(input())
v = list(map(int,input().split()))

vE,vO = v[0::2],v[1::2]

lmodeE, lmodeO = col.Counter(vE).most_common(), col.Counter(vO).most_common()
modeE, nmodeE = lmodeE[0][0], lmodeE[0][1]
modeO, nmodeO = lmodeO[0][0], lmodeO[0][1]

if modeE == modeO:
    # vEを2番目の最頻値に書き換え
    if len(lmodeE) == 1:
        ans1 = int(n/2)
    else:
        ans1 = n - lmodeE[1][1] - nmodeO
    # vOを2番目の最頻値に書き換え
    if len(lmodeO) == 1:
        ans2 = int(n/2)
    else:
        ans2 = n - nmodeE - lmodeO[1][1]
    # 出力
    print(min(ans1,ans2))
else:
    print(n-nmodeE-nmodeO)


Measured memory_bytes: 21084
package main

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

var scanner = bufio.NewScanner(os.Stdin)

func next() string {
	scanner.Scan()
	return scanner.Text()
}

func nextInt() int {
	i, _ := strconv.Atoi(next())
	return i
}

func main() {
	scanner.Split(bufio.ScanWords)

	s := next()
	sList := strings.Split(s, "")

	prev := ""
	for _, l := range sList {
		if prev == l {
			fmt.Println("Bad")
			return
		}
		prev = l
	}

	fmt.Println("Good")
}


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

using namespace std;

#define int long long
#define ll long long
typedef pair<int, int> P;
#define mod 1000000007
#define INF (1LL<<60)

#define rep(i,n) for(int i=0, i##_len=(n); i<i##_len; ++i)
#define YES puts("YES\n")
#define Yes puts("Yes\n")
#define NO  puts("NO\n")
#define No  puts("No\n")
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }

// ax+by=1の解
ll extgcd(ll a, ll b, ll& x, ll& y) {
	ll d = a;
	if (b != 0) {
		d = extgcd(b, a % b, y, x);
		y -= (a / b) * x;
	}
	else {
		x = 1; y = 0;
	}
	return d;
}


// a^k mod p
int modpow(int a, int k, int p) {
	int ans = 1;
	while (k > 0) {
		if (k % 2 == 1) {
			ans *= a;
			ans %= p;
		}
		a = (a * a) % p;
		k = k / 2;
	}
	return ans;
}

// mod mでのaの逆数
ll mod_inverse(ll a, ll m) {
	return modpow(a, m - 2, m);
//	ll x, y;
//	extgcd(a, m, x, y);
//	return (m + x % m) % m;
}

int fac[20001];

// nCr mod p
ll combination(int n, int r, int p) {
	if (r == 0 || r == n) return 1;
	if (n < r) return 0;
//	if (r > n / 2) r = n - r;
	return (fac[n] * mod_inverse(fac[r], p) % p) * mod_inverse(fac[n-r], p) % p;
}

signed main() {

	fac[0] = fac[1] = 1;
	for (int i = 2; i <= 20000; i++) fac[i] = (fac[i - 1] * i) % mod;

	int N, K;
	cin >> N >> K;
	for (int i = 1; i <= K; i++) {
		cout << combination(N-K+1,i,mod) * combination(K-1,i-1,mod) % mod << endl;
	}

	return 0;
}


Measured memory_bytes: 384
#include<iostream>
#include<algorithm>
#include<string> 
#include<map>
#include<set>
#include<vector>
#include<string.h> 
#include<math.h>
#include<stdio.h> 
#include<queue>
using namespace std; 
int main()
{int x,t;
cin>>x>>t;
if(x<=t)cout<<'0';
else cout<<x-t; 
system("pause");
return 0;
}

Measured memory_bytes: 504
#include<iostream>
using namespace std;
#define MAX 300

int main(void)
{
    int H,W;


    while(1){
        do{
            cin >> H >> W;
        }while(H < 0 || H > MAX || W < 0 || W > MAX);
         
        if(W == 0 && H == 0) break;

        for(int i = 0;i < H;i++){
             for(int j = 0;j < W;j++){
                 if((i + j) % 2 == 0) cout << "#";
                 else cout << ".";
             }
             cout << endl;
        }
        cout << endl;

    }
    return 0;
}

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

#define ALL(obj) (obj).begin(),(obj).end()
#define SPEED cin.tie(0);ios::sync_with_stdio(false);

template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T,vector<T>,greater<T>>;

constexpr long long MOD = (long long)1e9 + 7;
constexpr long long MOD2 = 998244353;
constexpr long long HIGHINF = (long long)1e18;
constexpr long long LOWINF = (long long)1e15;
constexpr long double PI = 3.1415926535897932384626433L;

template <class T> vector<T> multivector(size_t N,T init){return vector<T>(N,init);}
template <class... T> auto multivector(size_t N,T... t){return vector<decltype(multivector(t...))>(N,multivector(t...));}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; exit(0);}}
template <class T, class U>ostream &operator<<(ostream &o, const map<T, U>&obj) {o << "{"; for (auto &x : obj) o << " {" << x.first << " : " << x.second << "}" << ","; o << " }"; return o;}
template <class T>ostream &operator<<(ostream &o, const set<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const multiset<T>&obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr) o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
template <class T>ostream &operator<<(ostream &o, const vector<T>&obj) {o << "{"; for (int i = 0; i < (int)obj.size(); ++i)o << (i > 0 ? ", " : "") << obj[i]; o << "}"; return o;}
template <class T, class U>ostream &operator<<(ostream &o, const pair<T, U>&obj) {o << "{" << obj.first << ", " << obj.second << "}"; return o;}
template <template <class tmp>  class T, class U> ostream &operator<<(ostream &o, const T<U> &obj) {o << "{"; for (auto itr = obj.begin(); itr != obj.end(); ++itr)o << (itr != obj.begin() ? ", " : "") << *itr; o << "}"; return o;}
void print(void) {cout << endl;}
template <class Head> void print(Head&& head) {cout << head;print();}
template <class Head, class... Tail> void print(Head&& head, Tail&&... tail) {cout << head << " ";print(forward<Tail>(tail)...);}
template <class T> void chmax(T& a, const T b){a=max(a,b);}
template <class T> void chmin(T& a, const T b){a=min(a,b);}
void YN(bool flg) {cout << (flg ? "YES" : "NO") << endl;}
void Yn(bool flg) {cout << (flg ? "Yes" : "No") << endl;}
void yn(bool flg) {cout << (flg ? "yes" : "no") << endl;}

int main() {
    int N,M; cin >> N >> M;
    vector<ll> A(M);
    for(int i = 0; i < M; ++i) cin >> A[i];
    ll sum = accumulate(ALL(A),0LL);
    ll ans = -1;
    if(sum <= N) ans = N - sum;
    cout << ans << endl;
    return 0;
}


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

int main(){
    int K;
    cin >> K;
    vector<ll> a;
    for (int i=1; i<=9; i++) a.push_back(i);
    while(1) {
        if (a.size() >= K) {
            cout << a[K-1] << endl;
            return 0;
        }
        K -= a.size();
        vector<ll> old;
        swap(a, old);
        for (auto x: old) {
            for (int i=-1; i<=1; i++) {
                int d = x%10 + i;
                if (d < 0 || d > 9) continue;
                ll nx = 10*x + d;
                a.push_back(nx);
            }
        }
    }
    return 0;
}

Measured memory_bytes: 1712
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<cstring>

using namespace std;
int x,y,z;
int main()
{
	cin>>x>>y>>z;
	cout<<(x-z)/(y+z)<<"\n";
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define MIN(a,b) ((a) <= (b) ? (a) : (b))
#define ALL(v) (v).begin(), (v).end()
#define SORT(v) sort( ALL(v) )
#include <math.h>
#define _USE_MATH_DEFINES
using namespace std;
using ll = long long;
using P = pair<int,int>;

double PI = atan(1)*4;

int main()
{
    int R ;
    cin>>R;
    R *= 2;

    cout << setprecision(3);
    cout << fixed;
    cout << (double)PI*(double)R<<endl;
    return 0;
}


Measured memory_bytes: 3696
#include <cstdio>
#include <algorithm>
#include <cmath>
using namespace std;
const int MAXN = 1000005;
int n, tot;
char a[MAXN], b[MAXN];
int f[MAXN], fr[MAXN];

void chk_same() {
    for (int i = 1; i <= n; i++)
        if (a[i] != b[i])
            return;
    puts("0"), exit(0);
}

int main() {
	scanf("%d %s %s", &n, a + 1, b + 1), chk_same();
    for (int i = 1; i <= n; i++)
        if (b[i] != b[i - 1])
            f[tot++] = i - 1;
    f[tot] = n;
    int p = n + 1, ans = 0;
    for (int i = tot; i; i--) {
        p = min(p, f[i - 1] + 1);
        while (p && a[p] != b[f[i]])
            p--;
        if (!p) {
            puts("-1");
            return 0;
        }
        fr[i] = p;
    }
    for (int i = p = 1; i <= tot; i++) {
        while (p < tot && fr[p + 1] - (p - i + 1) < f[i])
            p++;
        ans = max(ans, p - i + 1);
    }
    printf("%d", ans);
	return 0;
}


Measured memory_bytes: 9984
#include<bits/stdc++.h>
#define fi first
#define se second
#define show(x) cerr<<#x<<"="<<x<<"\n"
typedef long long ll;
using namespace std;
//const ll MOD=(ll)1e9+7;
const ll inf=(ll)1e18;
const int dy[]={1,0,-1};
const int dx[]={1,0,-1};
int n,m,h,w;
ll dp[20021][300];

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
  FILE *stream1;
  //FILE *stream2;
  stream1=freopen("in","r",stdin);
  //stream2=freopen("out","w",stdout);
  if(stream1==NULL)return 0;
  //if(stream2==NULL)return 0;
#endif
  while(cin>>n>>m,n){
    int c[20];
    int a[20011];
    for(int i=0;i<m;i++)cin>>c[i];
    a[0]=128;
    for(int j=1;j<=n;j++)cin>>a[j];
    for(int i=0;i<=n+1;i++)for(int j=0;j<=255;j++)dp[i][j]=inf;
    dp[0][128]=0;
    for(int i=0;i<=n;i++){
      for(int j=0;j<=255;j++){
        if(dp[i][j]==inf)continue;
        for(int k=0;k<m;k++){
          int tmp;
          if(j+c[k]<0)tmp=0;
          else if(j+c[k]>255)tmp=255;
          else tmp=j+c[k];
          dp[i+1][tmp]=min(dp[i+1][tmp],dp[i][j]+(a[i+1]-tmp)*(a[i+1]-tmp));
        }
      }
    }
    ll ans=inf;
    for(int i=0;i<256;i++){
      ans=min(ans,dp[n][i]);
    }
    cout<<ans<<endl;
  }
#ifdef LOCAL_DEFINE
  cerr<<"Time elapsed: "<<1.0*clock()/CLOCKS_PER_SEC<<"s.\n";
  fclose(stream1);
  //fclose(stream2);
#endif
  return 0;
}







Measured memory_bytes: 50060
import sys
input = sys.stdin.readline

s = input().rstrip()
x, y = [int(x) for x in input().split()]

horizontal = []
vertical = []

switch = 1
distance = 0

for i in range(len(s)):
    if s[i] == "F":
        distance += 1
    elif switch:
        horizontal.append(distance)
        distance = 0
        switch ^= 1
    else:
        vertical.append(distance)
        distance = 0
        switch ^= 1

if switch:
    horizontal.append(distance)
else:
    vertical.append(distance)

dp_x = [[0] * (2 * sum(horizontal) + 1) for _ in range(len(horizontal) + 1)]
dp_y = [[0] * (2 * sum(vertical) + 1) for _ in range(len(vertical) + 1)]

sx = sum(horizontal)
sy = sum(vertical)

if not (-sx <= x <= sx and -sy <= y <= sy):
    print("No")
    exit()

dp_x[0][0 + sx] = 1
dp_y[0][0 + sy] = 1
dp_x[1][horizontal[0] + sx] = 1

for i in range(2, len(horizontal) + 1):
    x_ = horizontal[i - 1]
    for j in range(-sx, sx + 1):
        if -sx <= j - x_ <= sx: 
            dp_x[i][j + sx] = max(dp_x[i][j + sx], dp_x[i - 1][j - x_ + sx])
        if -sx <= j + x_ <= sx:
            dp_x[i][j + sx] = max(dp_x[i][j + sx], dp_x[i - 1][j + x_ + sx])


for i in range(1, len(vertical) + 1):
    y_ = vertical[i - 1]
    for j in range(-sy, sy + 1):
        if -sy <= j - y_ <= sy: 
            dp_y[i][j + sy] = max(dp_y[i][j + sy], dp_y[i - 1][j - y_ + sy])
        if -sy <= j + y_ <= sy:
            dp_y[i][j + sy] = max(dp_y[i][j + sy], dp_y[i - 1][j + y_ + sy])

if dp_x[-1][x + sx] and dp_y[-1][y + sy]:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 168412
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>
#include <complex>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
ld PI = acos(-1.0);

void solve() {
    string s, t;
    cin >> s >> t;
    ll n = s.size();
    ll ans = 0;
    for(ll i = 0; i < n; i++) if(s[i] != t[i]) ans++;
    cout << ans << endl;
    return;
}

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

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

typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> ii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;

#define x first
#define y second
#define pb push_back
#define eb emplace_back
#define rep(i,a,b) for(auto i=(a); i<(b); ++i)
#define REP(i,n) rep(i,0,n)
#define all(v) (v).begin(), (v).end()
#define rs resize
#define DBG(x) cerr << __LINE__ << ": " << #x << " = " << (x) << endl

const ld PI = acos(-1.0);
template<class T> using min_queue =
priority_queue<T, vector<T>, greater<T>>;
template<class T> int sz(const T &x) {
    return (int) x.size(); // copy the ampersand(&)!
}

template<class T> ostream& operator<<(ostream &os, vector<T> &v) {
    os << "\n[";
    for(T &x : v) os << x << ',';
    return os << "]\n";
}

struct pairhash {
    public:
    template<typename T1, typename T2>
    size_t operator()(const pair<T1, T2> &p) const {
        size_t lhs = hash<T1>()(p.x);
        size_t rhs = hash<T2>()(p.y);
        return lhs ^ (rhs+0x9e3779b9+(lhs<<6)+(lhs>>2));
    }
};

void run() {
	ll A, B, M;
	cin >> A >> B >> M;
	vi a(A, 0);
	vi b(B, 0);
	ll minA = 10000000;
	ll minB = 10000000;
	for (ll i = 0; i < A; i++) {
		cin >> a[i];
		minA = min(minA, a[i]);
	}
	for (ll i = 0; i < B; i++) {
		cin >> b[i];
		minB = min(minB, b[i]);
	}

	ll res = minA + minB;
	for (ll i = 0; i < M; i++) {
		ll x, y, c;
		cin >> x >> y >> c;
		x--; y--;
		res = min(res, a[x]+b[y]-c);
	}
	cout << res << endl;
}

signed main() {
    // DON'T MIX "scanf" and "cin"!
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout << fixed << setprecision(20);
    run();
    return 0;
}


Measured memory_bytes: 1792
S = list(input())

T = list(input())

ans = 0

for i in range(len(S)-len(T)+1):
    tmp_count = 0
    for j in range(len(T)):
        if S[i+j] == T[j]:
            tmp_count += 1
        #print(i,j)
    ans = max(ans,tmp_count)

print(len(T)-ans)

Measured memory_bytes: 65104
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
class Program
{
    static void Main(string[] args)
    {
            // 入力
            string sA = Console.ReadLine().Trim();
            string sB = Console.ReadLine().Trim();

            System.Diagnostics.Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();

            // 解析
            string sOut = "LESS";
            int iA = sA.Length;
            int iB = sB.Length;
            int iK = iA > iB ? iA : iB;                 // 大きい桁数
            sA = sA.PadLeft(iK, '0');                   // 同じ桁になるまで先頭0パディング
            sB = sB.PadLeft(iK, '0');                   // 同じ桁になるまで先頭0パディング
            int iCmp = sA.CompareTo(sB);
            if (iCmp == 0) { sOut = "EQUAL"; }
            if (iCmp > 00) { sOut = "GREATER"; }

            //出力
            Console.WriteLine("{0}", sOut.ToString().Trim());

            sw.Stop();
#if DEBUG
            Console.WriteLine();
            Console.WriteLine("{0}", sw.Elapsed.ToString());
            Console.WriteLine("続行するには何かキーを押してください．．．");
            Console.ReadKey();
#endif
    }
}


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

using namespace std;
typedef long long ll;
#define forin(in) for(int i=0; i<(int)in.size(); i++) cin>>in[i]
#define forout(out) for(int i=0; i<(int)out.size(); i++) cout<<out[i]<<endl
#define rep(i, n) for(int i=0; i<(n); i++)

const int di[] = {-1, 0, 1, 0};
const int dj[] = {0, -1, 0, 1};

int main() {
    int h, w; cin>> h >> w;
    int si, sj; cin>> si >> sj;
    int ti, tj; cin>> ti >> tj;
    si--; sj--; ti--; tj--;
    vector<string> s(h);
    forin(s);
    const int INF=1e+9;
    vector<vector<int>> dist(h, vector<int>(w, INF));
    deque<pair<int, int>> q;
    dist[si][sj]=0;
    q.emplace_back(si, sj);
    while(!q.empty()){
        int i = q.front().first;
        int j = q.front().second;
        q.pop_front();
        int d = dist[i][j];
        rep(v, 4){
            int ni = i + di[v], nj = j + dj[v];
            if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
            if(s[ni][nj] == '#') continue;
            if(dist[ni][nj] <= d) continue;
            dist[ni][nj] = d;
            q.emplace_front(ni, nj);
        }
        for(int ei = -2; ei <= 2; ei++){
            for(int ej = -2; ej <= 2; ej++){
                int ni = i+ei, nj=j+ej;
                if(ni < 0 || ni >= h || nj < 0 || nj >= w) continue;
                if(s[ni][nj] == '#') continue;
                if(dist[ni][nj] <= d+1) continue;
                dist[ni][nj] = d+1;
                q.emplace_back(ni, nj);
            }
        }
    }
    int ans = dist[ti][tj];
    if(ans == INF) ans = -1;
    cout<< ans << endl;
}


Measured memory_bytes: 9468
#include <iostream>
#include <cmath>
using namespace std;
int x,y,d,e;
double len,minn;
int main(){
	while(1){
		cin >> d>>e;
		if(!(d||e))break;
		minn=10000;
		for(int i=0;i<d;i++){
			x=i;
			y=d-x;
			len=sqrt(x*x+y*y);
			if(fabs(len-e)<minn)minn=fabs(len-e);
		}
		cout << minn<<endl;
	}
}

Measured memory_bytes: 3256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define MOD 1000000007
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
typedef unsigned long long int ull;
typedef long long lint;

int main(void){
    int N;
    cin >> N;
    int comp[N];
    rep(i,N) comp[i]=i+1;
    int P[N],Q[N];
    rep(i,N) cin >> P[i];
    rep(i,N) cin >> Q[i];
    int A=0,B=0,count=1;
    do{
        bool checkA=true,checkB=true;
        rep(i,N) if(comp[i]!=P[i]) checkA=false;
        rep(i,N) if(comp[i]!=Q[i]) checkB=false;
        if(checkA) A=count;
        if(checkB) B=count;
        count++;
    }while(next_permutation(comp,comp+N));
    cout << abs(A-B) << endl;
}

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

using namespace std;

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

struct point {long double x, y;};

long double d(point a, point b){
    return sqrt((a.x - b.x)*(a.x - b.x) + (a.y - b.y)*(a.y - b.y));
}

int main(){
    int N; cin >> N;
    point P[8];
    for (int i = 0; i < N; i++){
        cin >> P[i].x >> P[i].y;
    }

    vector<int> v(N);
    for (int i = 0; i < N; i++) v[i] = i;
    long double sum = 0;
    do{
        for (int i = 0; i < N-1; i++){
            sum += d(P[v[i]], P[v[i+1]]);
        }
    }while ( next_permutation(v.begin(), v.end()));

    for (int i = 2; i <= N; i++) sum = sum / (long double)i;
    cout << fixed << setprecision(10) << sum << endl;
}

Measured memory_bytes: 256
program main
   implicit none
integer(8):: n, i, ans, k
integer(8),allocatable,dimension(:):: a
 
ans=0
k=0
 
read (5,*) n
allocate(a(n))
read(5,*) (a(i),i=1,n)
 
call heapsort(n,a)
 
do i=n,1,-1
    if(mod(n-i,2)==0)then
        ans=ans+a(i)
    else
        ans=ans-a(i)
    endif
enddo
 
write(6,"(i0)") ans
 
end
 
!---http://slpr.sakura.ne.jp/qp/sortf90/---
subroutine heapsort(n,array)
    implicit none
    integer(8),intent(in) :: n
    integer(8), intent(inout) :: array(1:n)
 
    integer ::i,k,j,l
    double precision :: t
 
    if(n.le.0)then
        write(6,*)"Error, at heapsort"; stop
    endif

    if(n.eq.1)return 
        l=n/2+1
        k=n
        do while(k.ne.1)
            if(l.gt.1)then
                l=l-1
                t=array(L)
            else
                t=array(k)
                array(k)=array(1)
                k=k-1
                if(k.eq.1) then
                    array(1)=t
                    exit
                endif
            endif
            i=l
            j=l+l
            do while(j.le.k)
                if(j.lt.k)then
                    if(array(j).lt.array(j+1))j=j+1
                endif
                if (t.lt.array(j))then
                    array(i)=array(j)
                    i=j
                    j=j+j
                else
                    j=k+1
                endif
            enddo
            array(i)=t
    enddo
    return
end subroutine heapsort

Measured memory_bytes: 2876
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
typedef vector<int> vi;
#define endl '\n'
#define fo(i,a,b) for(int i=a;i<=b;i++)
#define rf(i,a,b) for(int i=a;i>=b;i--) 
#define fast_io ios_base::sync_with_stdio(0);
#define show(x) cout<<x<<endl;
#define pret(x) cout<<x<<endl; return 0;
#define disp(x) cout<<x<<" ";
#define let(x,y) cout<<x<<" "<<y<<endl;
ll MOD=1e9+7;
const int maxn=2e5+5;

int f(){
	int x;
	cin>>x;
	return (x>=30);
}

int32_t main(){
    fast_io;
    int t=1;
    // cin>>t;
    while(t--){
    	// show(f());

    	// f();

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

Measured memory_bytes: 3648
#include <stdio.h>
#include <iostream>
#include <math.h>
using namespace std;

double distance(double x1,double y1,double x2, double y2){
	return sqrt( (x1 - x2)*(x1 - x2) + (y1 - y2)*(y1 - y2) );
}

int main()
{
	double x1,y1,x2,y2;
	cin>>x1>>y1>>x2>>y2;
	printf("%.8lf\n",distance(x1,y1,x2,y2));
	return 0;
}

Measured memory_bytes: 3180
def solve():
    k = 0
    N = n
    ans = ""
    if n == 0:
        print(0)
        exit()
    while N:
        k+=1
        if N % 2 == 1:
#            print("------\t" + str(N))
            N -= 1
            ans += "1"
        else:
            ans += "0"
        N //= (-2)  # n=-2 進数
#        print(N)
#    print(k)    #   桁数
    print(ans[::-1])
#    print(a[::-1])



if __name__=="__main__":
    n = int(input())
    solve()



Measured memory_bytes: 9084
import java.util.Scanner;

public class Main{
	public static void main(String[] args){
      Scanner sc = new Scanner(System.in);
      long h = sc.nextLong();
      long w = sc.nextLong();
      
      long ans = (h*w+1)/2;
      
      if(h == 1 || w == 1){
        ans = 1;
      }
      System.out.println(ans);
    }
}


Measured memory_bytes: 21844
a=gets.chomp.to_i
r = []
count = 1
a.times do
  name, score = gets.chomp.split(' ')
  r << [name, score.to_i, count]
  count = count + 1
end
result = r.sort {|a,b| 
  if a[0] == b[0]
    b[1] <=> a[1]
  else
    a[0] <=> b[0]
  end 
}
result.each do |e|
  puts e[2]
end


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

#define rep(i, a) for (int i = 0; i < (a); ++i)
#define REP(i, a, b) for (int i = a; i < (b); ++i)
#define REV(i, a, b) for (int i = a; i > (b); --i)
#define debug(a) cerr << #a << " " << a << endl
#define debug2(a, b) cerr << #a << " " << a << ", " << #b << " " << b << endl

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

void Main() {
  int n;
  cin>>n;
  vector<int> a(n-1);
  rep(i, n-1) cin >> a[i];
  vector<int> ans(n, 0);
  REV(i, n-1, 0) {
    int p = a[i-1]-1;
    ans[p] += 1;
  }
  rep(i, n) cout << ans[i] << 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: 4784
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/adaptor/indexed.hpp>
#define FOR(i,k,n)  for(int i = (k);i < (n);++i)
#define REP(i,n)    FOR(i,0,n)
#define ALL(x) begin(x),end(x)

using namespace std;
using namespace boost::adaptors;
using namespace std::string_literals;
using ll = int64_t;
using vecint = vector<int>;
using vecll = vector<ll>;
using boost::irange;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int n,k;
  cin>>n>>k;
  vecint cnt(n);
  REP(i,k) {
    int d;
    cin>>d;
    REP(j,d) {
      int a;
      cin>>a;
      --a;
      ++cnt[a];
    }
  }
  cout<<count(ALL(cnt),0)<<endl;
  return 0;
}


Measured memory_bytes: 3664
#include <iostream>
#include <sstream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <map>
#include <stdio.h>
#include <iomanip>

using namespace std;

//typedefリスト
typedef vector<long long int> vint;
typedef vector<string> vstr;
typedef long long int llint;

int main(void) {
	int N, ans = 0;
	cin >> N;
	vint A(N), B(N), C(N - 1);
	for (int i = 0; i < N; i++)cin >> A[i];
	for (int i = 0; i < N; i++)cin >> B[i];
	for (int i = 0; i < N - 1; i++)cin >> C[i];
	for (int i = 0; i < N; i++) {
		ans += B[A[i] - 1];
	if (i > 0) {
		if (A[i] - 1 == A[i - 1]) {
			ans += C[A[i - 1] - 1];

		}
	 }
     }
cout << ans << endl;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <string>
#include <vector>
#include <queue>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <deque>
#include <algorithm>
#include <random>
#include <iomanip>

using namespace std;

const int mod = 1e9 + 7;


int main(int argc, char *argv[]) {
	int n;
	cin >> n;
	unordered_map<int, unordered_map<int, long long int>> um1, um2;
	vector<pair<long long int, int>> vp;
	for (int i = 0; i < n; i++) {
		long long int t;
		cin >> t;
		vp.push_back(make_pair(t, i));
	}
	sort(vp.begin(), vp.end());
	reverse(vp.begin(), vp.end());
	um1[0][n] = 0;
	for (int i = 0; i < n; i++) {
		um2.clear();
		for (auto p1 : um1) {
			for (auto p2 : p1.second) {
				int begin = p1.first, end = p2.first;
				long long int val = p2.second;
				long long int left = abs(begin - vp[i].second) * vp[i].first;
				long long int right = abs(end - 1 - vp[i].second) * vp[i].first;
				
					um2[begin + 1][end] = max(um2[begin + 1][end], val + left);
					um2[begin][end - 1] = max(um2[begin][end - 1], val + right);
			}
		}
		um1 = um2;
	}
	long long int res = 0;
	for (auto p1 : um1) {
		for (auto p2 : p1.second) {
			res = max(res, p2.second);
		}
	}
	cout << res << endl;
}


Measured memory_bytes: 4300
#include <bits/stdc++.h> // imports every library in c++
using namespace std; // ; is essential | says that you are USING the libraries

// PRACTICE //

int A, B;

int main() {
    cin >> A;
    cin >> B;
    if (B%A == 0) {
        cout << A + B;
    } else {
        cout << B - A;
    }
    return 0;
}

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

int main(){
    int N; cin >> N;
    vector<int> d(N);

    rep(i,N){
        cin >> d[i];
    }

    sort(d.begin(), d.end());

    cout << d[N/2] - d[(N-1)/2] << endl;
}

    

Measured memory_bytes: 640
#include <iostream>
using namespace std;
int main(){
	int N;
	
	int count=0;
	cin >> N;
	long long* A = new long long[N];
	for (int i = 0;i < N;i++) {
		cin >> A[i];
		if (A[i] % 2 == 1)
			count++;
	}
	if (count % 2 == 0) cout << "YES";
	else cout << "NO";
	

}

Measured memory_bytes: 4408
import heapq as hq
from collections import deque
n,m,s,t=map(int,input().split())
#リンク情報をつくる
yenLinks={}
snkLinks={}
for _ in range(m):
    u,v,a,b=map(int,input().split())
    if u not in yenLinks:
        yenLinks[u]=[(v,a)]
        snkLinks[u]=[(v,b)]
    else:
        yenLinks[u].append((v,a))
        snkLinks[u].append((v,b))
    if v not in yenLinks:
        yenLinks[v]=[(u,a)]
        snkLinks[v]=[(u,b)]
    else:
        yenLinks[v].append((u,a))
        snkLinks[v].append((u,b))
#Dijkstra法をする関数
INF=float('inf')
def dijkstra(start,links,nodeNum):
    ans=[INF for _ in range(nodeNum+1)]
    ans[start]=0
    PQ=[(0,start)]
    hq.heapify(PQ)
    while PQ:
        (Vd,V) = hq.heappop(PQ)
        #print([V,Vd,ans[V]])
        if Vd > ans[V]:
            continue
        for (W,D) in links[V]:
            cand = ans[V] + D
            if cand < ans[W]:
                ans[W] = cand
                hq.heappush(PQ,(ans[W],W))
            #print(PQ)
    return(ans)
#Dijkstra法実行
yenKstra=dijkstra(s,yenLinks,n)
snkKstra=dijkstra(t,snkLinks,n)
#答えを求める
i=n
ans=INF
answers=deque()
while i>0:
    cand = yenKstra[i]+snkKstra[i]
    ans = min(ans,cand)
    answers.append(10**15-ans)
    i-=1
#出力
for _ in range(n):
    print(answers.pop())

Measured memory_bytes: 90208
#include<cstdio>
#include<algorithm>
long long a[100005];

int cmp(long long a,long long b){ return a>b; }

long long min(long long a,long long b){ return a>b?b:a; }

int isOk(long long n,long long m,long long v,long long p,long long k){
    long long sum = v*m;
    long long minus = min(sum,(n-k+1)*m);
    sum -= minus;
    long long my = a[k] + m;
    int ok = 1;
    for(int i = 1; i <= k-1; i++){
        if(i<=(p-1)){
            long long add = min(sum,m);
            sum -= add;
        }
        else{
            if(a[i]>my){
                ok = 0;
                break;
            }
            else{
                long long add = min(sum,my-a[i]);
                sum -= add;
            }
        }
    }
    if(ok==0 || sum!=0) return 0;
    return 1;
}

int main(){
    long long n,m,v,p;
    scanf("%lld%lld%lld%lld",&n,&m,&v,&p);
    for(int i = 1; i <= n; i++) scanf("%lld",&a[i]);
    std::sort(a+1,a+1+n,cmp);
    int l = p, r = n;
    int res = -1;
    while(l<=r){
        int middle = (l+r)/2;
        if(isOk(n,m,v,p,middle)){
            res = middle;
            l = middle + 1;
        }
        else r = middle - 1;
    }
    printf("%d\n",res);
    return 0;
}


Measured memory_bytes: 896
#include<bits/stdc++.h>
#include<stdio.h>
    
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define rep(i,n) FOR(i,0,n)
#define _USE_MATH_DEFINES
#define f first
//#define s second
#define pb push_back
#define mp make_pair
#define f first
#define s second
#define INF 1000000000000000000
#define MAXN (int)(1e7)+1
#define MOD 1000000007
    
using namespace std;
    
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,int> pwi;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector< vector<pair<ll,ll > > > wGraph;
typedef vector<vector<ll> > graph;
//typedef vector<vector<ll> > matrix;
    
    
    
int main(){
    
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    cout<<std::fixed;
    cout<<std::setprecision(2);
    
    string N;
    cin>>N;

    int resto_atual = 0;
    for(int i = 0; i<N.size(); ++i){
        int numero_atual = N[i]-'0';
        resto_atual = (resto_atual + numero_atual)%9;
    }
    
    if(resto_atual%9 == 0) cout<<"Yes\n";
    else cout<<"No\n";

    return 0;   
}

Measured memory_bytes: 3772
#include <cstdio>
#include <iostream>
#include <cassert>
#include <string>
#include <algorithm>
#include <cstring>
#include <utility>
#include <vector>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <deque>
#include <unordered_map>
using namespace std;
typedef long long LL;
typedef pair<int, int> pii;
typedef pair<LL, LL> pll;

int main() {
    string s;
    cin >> s;
    int n = s.length();
    if (n % 2) return !printf("No\n");
    for (int i = 0; i < n; i++) {
        if ((i % 2) && s[i] != 'i') return !printf("No\n");
        if ((i % 2) == 0 && s[i] != 'h') return !printf("No\n");
    }
    puts("Yes");

    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(){
  long long k=1000000007;
  long long n;
  scanf("%lld",&n);
  
  long long ans;
  long long a10 = 1;
  long long a9 = 1;
  long long a8 = 1;
  
  for(int i=1;i<=n;i++){
    a10 = a10 * 10;
    a10 = a10 % k;
    a9 = a9 * 9;
    a9 = a9 % k;
    a8 = a8 * 8;
    a8 = a8 % k;
  }
  
  ans=a10-2*a9+a8;
  if(ans<0){
    ans+=k;
  }
  if(ans<0){
    ans+=k;
  }
  if(ans<0){
    ans+=k;
  }
  if(ans<0){
    ans+=k;
  }
  printf("%lld",ans);
  return 0;
}

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

using namespace std;

#define sz(v)           ((int)((v).size()))
#define clr(v, d)       memset(v, d, sizeof(v))
#define rep(i, v)       for(int i=0; i<sz(v); ++i)
#define lp(i, n)        for(int i=0; i<(int)(n); ++i)
#define lpi(i, j, n)    for(int i=(j); i<(int)(n); ++i)
#define lpd(i, j, n)    for(int i=(j); i>=(int)(n); --i)
#define INF             1000000000

//#define DEBUG

typedef long long ll;
typedef pair<int, int> ii;
typedef vector<ii> vii;
typedef vector<int> vi;

const int N = 1e5+5;
priority_queue<pair<int, int>> all;
priority_queue<pair<int, int>> rep;
priority_queue<pair<int, int>, vector<pair<int, int>>, greater<pair<int, int>> > sol;

int vis[N];

int main()
{
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	int n, k, uniq = 0;
	cin >> n >> k;
	lp(i, n){
		pair<int, int> in;
		cin >> in.second >> in.first;
		all.push(in);
	}
	lp(i, n){
		pair<int, int> in = all.top();
		all.pop();
		if(vis[in.second] > 0 || uniq == k)
			rep.push(in);
		else{
			sol.push(in);
			++vis[in.second];
			++uniq;
		}
	}
	lpi(i, uniq, k){
		sol.push(rep.top());
		++vis[rep.top().second];
		rep.pop();
	}
	while(!rep.empty()){
		ll op1 = 0ll + (uniq-1)*(uniq-1) + rep.top().first;
		ll op2 = 0ll + (uniq)*(uniq) + sol.top().first;
		if(op1 > op2){
			sol.pop();
			sol.push(rep.top());
			rep.pop();
			--uniq;
		}
		else
			break;
	}
	ll ans = 0;
	ans = 1ll * uniq * uniq;
	while(!sol.empty()){
		ans += 0ll + sol.top().first;
		sol.pop();
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 3444
#!usr/bin/env pypy3
from collections import defaultdict, deque
from heapq import heappush, heappop
from itertools import permutations, accumulate
import sys
import math
import bisect
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS():return [list(x) for x in sys.stdin.readline().split()]
def S():
    res = list(sys.stdin.readline())
    if res[-1] == "\n":
        return res[:-1]
    return res
def IR(n):
    return [I() for i in range(n)]
def LIR(n):
    return [LI() for i in range(n)]
def SR(n):
    return [S() for i in range(n)]
def LSR(n):
    return [LS() for i in range(n)]

sys.setrecursionlimit(1000000)

def main():
    s = input()
    print(s[0:3])

main()


Measured memory_bytes: 9308
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<n; i++)
#define rep1(i, n) for(int i=1; i<=n; i++)
#define rrep(i, n) for(int i=n-1; i>=0; i--)
#define rrep1(i, n) for(int i=n; i>=1; i--)
#define all(v) v.begin(),v.end()
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LLINF = 1e18;
const ll MOD = 1e9+7;
const double EPS = 1e-10;
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 n, m; cin >> n >> m;

    if (n == 1 && m == 0) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> v(n, -1);
    bool ok = true;
    rep(i, m) {
        int s, c; cin >> s >> c;
        s--;
        if (s == 0 && c == 0 && n > 1) ok = false;
        if (v[s] != -1 && v[s] != c) ok = false;
        v[s] = c;
    }

    if (!ok) {
        cout << "-1" << endl;
        return 0;
    }

    rep(i, n) {
        if (i == 0) {
            if (v[0] == -1) cout << 1;
            else cout << v[0];
        } else {
            if (v[i] == -1) cout << 0;
            else cout << v[i];
        }
    }
    cout << endl;
}


Measured memory_bytes: 256
import sys

#sys.stdin = open('c_4.txt', 'r')
min_cost = sys.maxint
N = int(raw_input())
num_list = map(int, raw_input().split())

for x in range(-100, 101, 1):
	new_cost = 0
	for y in range(N):
		new_cost += (num_list[y] - x) ** 2
	min_cost = min(new_cost, min_cost)

print str(min_cost)


Measured memory_bytes: 2568
#include<iostream>
using namespace std;
typedef long long ll;
bool is_zero=false;
ll dcnt[13]={},s=0,man[24];
void calc(ll t){
  if(is_zero) return;
  if(t==13){
    ll tmp=1000;
    for(ll i=0;i<24;i++){
      for(ll j=i+1;j<24;j++){
        if(man[i]&&man[j]){
          tmp=min(tmp,min(j-i,24-(j-i)));
        }
      }
    }
    s=max(tmp,s);
    return;
  }
  if(dcnt[t]>=3){
    is_zero=true;
    s=0;
    return;
  }
  if(t==0||t==12){
    if(dcnt[t]>=2){
      is_zero=true;
      s=0;
    }else if(dcnt[t]>=1){
      man[t]=1;
      calc(t+1);
    }else{
      calc(t+1);
    }
    return;
  }
  if(dcnt[t]>=2){
    man[t]=1;
    man[24-t]=1;
    calc(t+1);
    man[t]=0;
    man[24-t]=0;
  }else if(dcnt[t]>=1){
    man[t]=1;
    calc(t+1);
    man[t]=0;
    man[24-t]=1;
    calc(t+1);
    man[24-t]=0;
  }else{
    calc(t+1);
  }
}
signed main(){
  ll n;
  cin >> n;
  ll d[n];
  dcnt[0]++;
  for(int i=0;i<n;i++){
    cin >> d[i];
    dcnt[d[i]]++;
  }
  calc(0);
  cout << s << endl;
}


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

int main(){
  int K, A, B;
  cin >> K >> A >> B;
  
  if(B-A >= K)
    cout << "OK" << endl;
  else{
    string ans = "NG";
    for(int i = A; i <= B; i++){
      if(i % K == 0){
        ans = "OK";
        break;
      }
    }
  cout << ans << endl;
  }
}

Measured memory_bytes: 3624
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int a[3];
int main()
{
	cin>>a[0]>>a[1]>>a[2];
	sort(a,a+3);
	cout<<a[0]+a[1]<<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
long long mo = 1e9 + 7;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> Pii;
typedef pair<ll,ll> Pll;
template<class T, class S> void cmin(T &a, const S &b) { if (a > b)a = b; }
template<class T, class S> void cmax(T &a, const S &b) { if (a < b)a = b; }
template<class A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}cout << "\n";}
ld PI=3.14159265358979323846;

int main(){
    ll a;
    string S;
    cin >> a;
    cout << a + a*a + a*a*a << endl;
}


Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> PII;
#define pb push_back
#define all(c) c.begin(),c.end()
#define allr(c) c.rbegin(),c.rend()
#define MOD 998244353
typedef double ld;
#define PI 3.14159265


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

    ll a , b , c , x , y;
    cin >> a >> b >> c >> x >> y;
    ll AA = a + b;
    ll ans = 0;
    ll tx = x , ty = y;
    if(AA > 2 * c) {
        ans += min(x , y) * c * 2;
        if(min(x , y) == y) {
            x -= y;
            y = 0;
        }
        else {
            y -= x;
            x = 0;
        }
    }

    if(x > 0) {
        if(a * x > 2 * c * x) {
            ans += 2 * x * c;
        }
        else {
            ans += x * a;
        }
    }
    if(y > 0) {
        if(b * y > 2 * c * y) {
            ans += 2 * y * c;
        }
        else {
            ans += y * b;
        }
    }

    cout << min(ans , max(tx , ty) * c * 2) << endl;

    return 0;
}


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

using namespace std;

int main()
{
    vector<int> a(5);
    for (int i = 0; i < 5; i++) {
        cin >> a[i];
    }
    sort(a.begin(), a.end(), greater<int>());
    for (int i = 0; i < 5; i++) {
        if (i > 0) cout << " ";
        cout << a[i];
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3076
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A[3][3];
  int N;
  int num;
  int hit[3][3] = {0};
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      cin >> A[i][j];
    }
  }
  cin >> N;
  for(int k=0;k<N;k++){
    cin >> num;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(A[i][j]==num){
          hit[i][j] = 1;
        }
      }
    }
  }
  string res = "No";
  if(
    hit[0][0]+hit[0][1]+hit[0][2]==3||
    hit[1][0]+hit[1][1]+hit[1][2]==3||
    hit[2][0]+hit[2][1]+hit[2][2]==3||
    hit[0][0]+hit[1][0]+hit[2][0]==3||
    hit[0][1]+hit[1][1]+hit[2][1]==3||
    hit[0][2]+hit[1][2]+hit[2][2]==3||
    hit[0][0]+hit[1][1]+hit[2][2]==3||
    hit[0][2]+hit[1][1]+hit[2][0]==3
  ) res = "Yes";
  cout << res;
}

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

int main() {
  int a[5],k;
  for (int i=0; i<5; i++) {
    cin>>a[i];
  }
  cin>>k;
  sort(a,a+5);
  if (a[4]-a[0]<=k) cout<<"Yay!"<<endl;
  else cout<<":("<<endl;
  return 0;
}

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

int main(){
  string s;
  cin >> s;
  
  int ans = 100;
  
  for ( int i = 0; i < 26; i++ ){
    int j = -1;
    int mx = 0;
    for ( int k = 0; k < s.size(); k++ ){
      if ( s[k] == static_cast<char>('a' + i) ){
        mx = max(mx, k - j - 1);
        j = k;
      }
    }
    
    mx = max( mx, static_cast<int>(s.size()) - j - 1);
    
    ans = min(ans, mx);
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int,input().split()))
ans = []
b = [0] * n

for i in range(1,n+1)[::-1]:
    sum_i = sum(b[(i-1)::i])
    if sum_i%2 != a[i-1]:
        ans.append(i)
        b[i-1] = 1

print(len(ans))
if len(ans) != 0:
    print(*ans)

Measured memory_bytes: 14052
#include<iostream>
#include<algorithm>
using namespace std;
int main() {
	int m, nmin, nmax;
	while (cin >> m >> nmin >> nmax&&m&&nmin&&nmax) {
		int p[200];
		for (int i = 0; i < m; i++)cin >> p[i];
		int soeji, sa1=p[nmin-1]-p[nmin],sa2;
		for (int i = nmin - 1; i <= nmax - 1; i++) {
			if (sa1 <= p[i] - p[i + 1]) {
				sa1 = p[i] - p[i + 1];
				soeji = i+1;
			}
		}
		cout << soeji << endl;
	}
	return 0;
}

Measured memory_bytes: 3072
import java.util.Scanner;
 
public class Main {
	
	public static void main(String args[]){
		Scanner scan = new Scanner(System.in);
 		int n = scan.nextInt();
		String S = scan.next();
		String a[] = new String[S.length()];

		for(int i=0;i< S.length();i++) {
			a[i]=S.substring(i, i+1);
		}

		int min = 0;
		for(int i=1;i<S.length();i++){
			int jmin = 0;
			loop : for(int j=0;j<i;j++){
				for(int k=0;k<j;k++){
					if(a[j].equals(a[k])) continue loop;
				}
				for(int k=i;k<S.length();k++){
					if(a[j].equals(a[k])){
						jmin += 1;
						break;
					}
				}
			}
			if(jmin > min){
				min = jmin;
			}
		}

		System.out.println(min);
	}
 
}

Measured memory_bytes: 21972
#include <stdio.h>
#include <string.h>
#include <stdlib.h>
#include <map>
#include <set>
#include <vector>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <assert.h>
#include <math.h>
#include <stack>
#include <queue>
#include <list>
using namespace std;

// #define __DEBUG__

#ifdef __DEBUG__
bool debug_disabled = false;
#else
bool debug_disabled = true;
#endif

#define dbg if (debug_disabled) {} else cerr

int a[1000010];
int primes[1000010];

int gcd(int a, int b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

void solve() {
    int n;
    cin >> n;
    set<int> as;
    bool bad = false;
    for (int i = 0; i < n; ++i) {
        cin >> a[i];
        if (a[i] != 1 && as.find(a[i]) != as.end()) {
            bad = true;
        }
        as.insert(a[i]);
    }
    int cur_g = a[0];
    for (int i = 1; i < n; ++i) {
        cur_g = gcd(cur_g, a[i]);
    }
    if (cur_g != 1) {
        cout << "not coprime" << endl;
        return;
    }
    for (int i = 2; i < 1000003; ++i) {
        if (primes[i] == 0) {
            int cnt = 0;
            if (as.find(i) != as.end()) ++cnt;
            for (int j = 2 * i; j < 1000010; j += i) {
                primes[j] = 1;
                if (as.find(j) != as.end()) ++cnt;
            }
            if (cnt > 1) {
                bad = true;
                break;
            }
        }
    }
    if (bad) {
        cout << "setwise coprime" << endl;
        return;
    }
    cout << "pairwise coprime" << endl;
}

int main() {
    cout.setf(ios::fixed, ios::floatfield);
    cout.setf(ios::showpoint);
    cout.precision(12);
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);

    int T = 1;
    // cin >> T;
    for (int i = 1; i <= T; ++i) {
        solve();
    }

    return 0;
}


Measured memory_bytes: 58240
#include<stdio.h>

int main(void) {

	char S[4];

	scanf("%s", S);
	for (int i = 0; i < 3; ++i) {
		if (S[i] == S[i + 1]) {
			puts("Bad");
			return 0;
		}
	}
	puts("Good");
	return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
int main() {
	int N, M;
	cin >> N >> M;
	vector<pair<int, int>>vec;
	for (int i = 0; i < M; i++) {
		int a, b;
		cin >> a >> b;
		vec.push_back(make_pair(b,a));
    }
	sort(vec.begin(),vec.end());
	int cnt = 0;
	int p = 0;
	for (int i = 0; i < M; i++) {
		if (p < vec[i].second){
          cnt++;
          p = vec[i].first - 1;
        }
	}
	cout << cnt << endl;
}

Measured memory_bytes: 1400
mod=10**9+7
n,k=map(int,input().split())
A=tuple(map(int,input().split()))
DP=[[0]*(k+1) for _ in range(n)]
acc=[0]*(k+2)
for i in range(k+1):
    if i<=A[0]:
        DP[0][i]=1
    acc[i+1]=acc[i]+DP[0][i]
for i in range(1,n):
    for j in range(k+1):
        DP[i][j]=(acc[j+1]-acc[max(0,j-A[i])])%mod
    acc[0]=0
    for j in range(k+1):
        acc[j+1]=(acc[j]+DP[i][j])%mod
print(DP[-1][-1])

Measured memory_bytes: 119404