akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define PII pair<int, int>
#define PLL pair<LL, LL>
#define VI vector<int>
#define VPII vector<PII>
#define LL long long
#define LD long double
#define f first
#define s second
#define MP make_pair
#define PB push_back
#define pb pop_back
#define ALL(c) (c).begin(), (c).end()
#define SIZ(c) (int)(c).size()
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i, b, e) for(int i = (b); i <= (int)(e); ++i)
#define FORD(i, b, e) for(int i = (b); i >= (int)(e); --i)

#define Sim template<class n
Sim, class s> ostream & operator << (ostream &p, pair<n, s> x)
{return p << "<" << x.f << ", " << x.s << ">";}
Sim> auto operator << (ostream &p, n y) -> 
typename enable_if<!is_same<n, string>::value, decltype(y.begin(), p)>::type 
{int o = 0; p << "{"; for(auto c: y) {if(o++) p << ", "; p << c;} return p << "}";}
void dor() {cerr << endl;}
Sim, class...s> void dor(n p, s...y) {cerr << p << " "; dor(y...);}
Sim, class s> void mini(n &p, s y) {if(p>y) p = y;}
Sim, class s> void maxi(n &p, s y) {if(p<y) p = y;}
#ifdef DEB
#define debug(...) dor(__FUNCTION__, ":", __LINE__, ": ", __VA_ARGS__)
#else
#define debug(...)
#endif 

#define int LL
#define I(x) #x " = ", (x), " "
#define A(a, i) #a "[" #i " = ", i, "] = ", a[i], " "
const int M = 1e7;

int n;
VI V;
VI P;
bool B[M];

void sito()
{
	for (int i = 2; i < M; i++)
	{
		if (!B[i])
		{
			P.PB(i);
			for (int j = i; j < M; j += i)
			{
				B[j] = 1;
			}
		}
	}
}

VI dziels(LL x)
{
	VI res;
	for (auto p : P)
	{
		if (p * p > x)
		{
			break;
		}
		if (x % p == 0)
		{
			res.PB(p);
			while (x % p == 0)
			{
				x /= p;
			}
		}
	}
	if (x > 1)
	{
		res.PB(x);
	}
	return res;
}

int eval(int x, int mod)
{
	int r = 0;
	for (auto a : V)
	{
		r = (r * x + a) % mod;
	}
	return r;
}

bool good(int p)
{
	if ((V.back() % p + p) % p != 0)
	{
		return false;
	}
	unordered_map<int, int> mapa;
	debug(p);
	FOR(i, 0, SIZ(V) - p - 1)
	{
		int tmp = (V[i] % p - mapa[i] + 2 * p) % p;
		mapa[i] = (V[i] % p + p) % p;
		mapa[i + p - 1] = (mapa[i + p - 1] - tmp + p) % p;
	}
	FOR(i, 0, SIZ(V) - 2)
	{
		if (mapa[i] != (V[i] % p + p) % p)
		{
			return false;
		}
	}
	return true;
}

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

main()
{
	//ios_base::sync_with_stdio(0);
	//cin.tie(NULL);
	sito();
	scanf("%lld", &n);
	int tmp = 0;
	FOR(i, 0, n)
	{
		int a;
		scanf("%lld", &a);
		V.PB(a);
		tmp = gcd(tmp, abs(a));
	}
	VI kands = dziels(tmp);
	for (auto x : P)
	{
		if (x > n)
		{
			break;
		}
		kands.PB(x);
	}
	VI res;
	debug(tmp, kands);
	for (auto p : kands)
	{
		if (good(p))
		{
			res.PB(p);
		}
	}
	sort(ALL(res));
	res.resize(unique(ALL(res)) - res.begin());
	for (auto x : res)
	{
		printf("%lld\n", x);
	}
	return 0;
}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

typedef int _loop_int;
#define REP(i,n) for(_loop_int i=0;i<(_loop_int)(n);++i)
#define FOR(i,a,b) for(_loop_int i=(_loop_int)(a);i<(_loop_int)(b);++i)
#define FORR(i,a,b) for(_loop_int i=(_loop_int)(b)-1;i>=(_loop_int)(a);--i)

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  cout<<(min(a,b)+min(c,d))<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <cmath>

using namespace std;

typedef unsigned long long ull;

vector<int> T;

struct State{
  int cost, state;
  State(int _cost, int _state){
    cost = _cost;
    state = _state;
  }
  bool const operator < (State s) const{
    return s.cost < cost;
  }
};

set<int> S;
int cx, cy;
int s, g ;

int dijkstra(){
  int dx[] = {-1, 1, -3, 3};
  int cost[] = {cx, cx, cy, cy};
  
  priority_queue<State> que;
  que.push(State(0, s));
  
  while(!que.empty()){
    State q = que.top(); que.pop();
    if(q.state == g) return q.cost;
    
    if(S.find(q.state) != S.end()) continue;
    S.insert(q.state);
    
    int zero;
    int tmp = q.state;
    for(int i = 8 ; i >= 0 ; i--){
      if(tmp % 10 == 0){
	zero = i;
	break;
      }
      tmp /= 10;
    }
    
    for(int i = 0 ; i < 4 ; i++){
      int pos = zero + dx[i];
      
      if(pos < 0) pos += 9;
      if(pos >= 9) pos -= 9;
      int vv = q.state;
      vv /= T[pos];
      vv %= 10;
      
      int v = q.state;
      v -= T[pos] * vv;
      v += T[zero] * vv;
      
      que.push(State(q.cost + cost[i], v));
    }
  }
}

int main(){
  for(int i = 1 ; i <= 100000000 ; i *= 10){
    T.push_back(i);
  }
  reverse(T.begin(), T.end());

  while(cin >> cx >> cy, cx | cy){
    S.clear();
    s = g = 0;
    int v;
    for(int i = 0 ; i < 9 ; i++){
      cin >> v;
      s *= 10;
      s += v;
    }
    for(int i = 0 ; i < 9 ; i++){
      cin >> v;
      g *= 10;
      g += v;
    }
    
    cout << dijkstra() << endl;
    
  }
  return 0;
}

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

int main() {
    int x1, y1, x2, y2;
    cin >> x1 >> y1 >> x2 >> y2;

    int x = x2 - x1;
    int y = y2 - y1;

    cout << x2 - y << " " << y2 + x << " " << x1 - y << " " << y1 + x << endl;

    return 0;
}


Measured memory_bytes: 3584
#include <algorithm>
#include <cstdio>
int a[105];
int main(){
	int n,m,x=0,y=0;
	scanf("%d%d\n",&n,&m);
	for (int i=1;i<=m;i++){
		scanf("%d",&a[i]);
		if (a[i]&1){
			if (!x) x=i;
			else if (!y) y=i;
			else{
				printf("Impossible\n");
				return 0;
			}
		}
	}
	if (x) std::swap(a[1],a[x]);
	if (y) std::swap(a[y],a[m]);
	for (int i=1;i<=m;i++) printf("%d ",a[i]);
	if (m==1) ++m;
	a[1]--;a[m]++;
	int j=a[1]?1:2;
	printf("\n%d\n",m-j+1);
	for (int i=j;i<=m;i++) printf("%d ",a[i]);
}

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

#define INF 999999999
typedef long long ll;
#define rep(i, n) for (int i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
#define pub push_back
#define pob pop_back
#ifdef LOCAL
  #define de(e) cout << "L" << __LINE__ << ": " << e << "\n" // debug echo
  #define dr(e) cout << "L" << __LINE__ << ": " << #e << " -> " << e << "\n" // debug repr
#else
  #define de(e)
  #define dr(e)
#endif
#define out(fmt, ...) printf(fmt, __VA_ARGS__); printf("\n")
int gcd(int m, int n) { if((0 == m) || (0 == n)){return 0;} while(m != n){ if(m > n){m -= n;}else{n -= m;} } return m; }
int lcm(int m, int n) { if((0 == m) || (0 == n)){return 0;} return (m / gcd(m, n)) * n; }

//
// Implementation
//

int main() {
  int N; scanf("%d", &N);
  vector<int> a(N);
  rep(i, N) scanf("%d", &a[i]);

  map<int, int> cnt;
  rep(i, N) {
    auto itr = cnt.find(a[i]);
    if (itr != cnt.end()) {
      cnt[a[i]]++;
    } else {
      cnt[a[i]] = 1;
    }
  }

  int ans = 0;
  for (auto x : cnt) {
    if (x.first != x.second) {
      de(x.first << " " << x.second);
      if (x.first < x.second) {
        ans += x.second - x.first;
      } else {
        ans += x.second;
      }
    }
  }
  out("%d", ans);
}


Measured memory_bytes: 5120
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  string S, T= "Yes";
  cin >> S;
  for(int i=0; i<S.size(); i++){
    if(i % 2 ==0){
      if (S.at(i) == 'L'){
        T = "No";
        break;
      }
      else
        continue;
    }
    else{
      if (S.at(i) == 'R'){
        T = "No";
        break;
      }
      else
        continue;
    }
  }
  cout << T << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = (0); i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(x) (x).begin(),(x).end()
#define rrng(x) (x).rbegin(),(x).rend()
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define show(x) cout << #x << " = " << (x) << endl
#define show2(x,y) cout << #x << " = " << (x) << ", " << #y << " = " << (y) << endl
#define show3(x,y,z) cout << #x << " = " << (x) << ", " << #y << " = " << (y) <<  ", " << #z << " = " << (z) << endl
#define showv(v) rep(i,v.size()) printf("%d%c", v[i], i==v.size()-1?'\n':' ')
#define showv2(v) rep(j,v.size()) showv(v[j])
#define showt(t,n) rep(i,n) printf("%d%c", t[i], i==n-1?'\n':' ')
#define showt2(t,r,c) rep(j,r) showt(t[j],c)
#define showvp(p) rep(i,p.size()) printf("%d %d\n", p[i].first, p[i].second);
#define printv(v) rep(i,v.size()) printf("%d\n", v[i])
#define printt(t,n) rep(i,n) printf("%d\n", t[i])
#define incl(v,x) find(rng(v),x)!=v.end()
#define incls(s,c) s.find(c)!=string::npos
#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define bit(n,k) ((n>>k)&1) // nのk bit目
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define uni(x) x.erase(unique(rng(x)),x.end())
#define SP << " " <<
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<P> vp;
typedef vector<T> vt;
const int mod = 1000000007;
const double EPS = 1e-9;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
#define dame { puts("No"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
inline int in() { int x; scanf("%d",&x); return x;}
template<typename T>inline ll suma(const v(T)& a) { ll res(0); for (auto&& x : a) res += x; return res;}
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

int dp[105][4][2];

int main () {
  string s;
  int K;
  cin >> s >> K;
  int n = s.size();
  dp[0][0][0] = 1;
  rep(i,n)rep(j,4)rep(k,2) {
    int nd = s[i]-'0';
    rep(d,10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  cout << dp[n][K][0] + dp[n][K][1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, a, b) for(int i = a; i < b; i++)
#define rrep(i, a, b) for(int i = b - 1; i >= a; i--)

int main(){
    int n; cin >> n;
    vector<ll> a(n + 1); 
    rep(i, 0, n + 1) cin >> a[i];
    vector<ll> s(n+2, 0);
    s[n] = a[n];
    rrep(i, 0, n) s[i] = a[i] + s[i+1];
    if(a[0] == 1){
        if(n == 0) cout << 1 << endl;
        else cout << -1 << endl;
        return 0;
    }
    ll ans = 0,ro = 1, le = 0, sum = 1;

    rep(i, 0, n + 1){
        le = a[i];
        ro = sum - le;
        if(ro < 0){
            cout << -1 << endl;
            return 0;
        }
        ans += ro + le;
        sum = ro * 2;
        if(i == n) break;
        if(sum > s[i+1]) sum = s[i+1];
        
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 4844
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower

#define lint long long

using namespace std;

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

  cout << (n+1)/2 << endl;

  return 0;
}


Measured memory_bytes: 256
S = input()
T = input()
Ns = len(S)
Nt = len(T)

ans = 0
for i in range(Ns - Nt + 1):
    tmp = 0
    for j in range(Nt):
        if S[i + j] == T[j]:
            tmp += 1
        ans = max(ans, tmp)
print(Nt - ans)

Measured memory_bytes: 9064
#include <iostream>
#include <sstream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <numeric>
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cctype>
#include <cmath>
#include <cassert>
#include <cstdarg>
#include <sys/time.h>
#include <fstream>
//#include "cout.h"

using namespace std;

#define SZ(x) ((int)x.size())
#define MSET(x,a) memset(x, a, (int)sizeof(x))
#define PB push_back
#define VI vector < int >
#define PII pair < int, int >
#define LL long long
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(), (v).end()
#define FIT(it,v) for (__typeof((v).begin()) it = (v).begin(); it != (v).end(); it++)
#define OUT(A) cout << #A << " = "<< (A) << endl
#define OUT2(A, B) cout << "(" << #A << ", " << #B << ") = (" << (A) << ", "<< (B) << ")" << endl
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }

#define present(c, e) ((c).find((e)) != (c).end())
#define cpresent(c, e) (find(ALL(c), (e)) != (c).end())


void solve() {
  LL a, b;
  cin >> a >> b;
  if (abs(a-b)&1) {
    cout << "IMPOSSIBLE" << endl;
    return;
  }
  cout << min(a,b) + abs(a-b)/2 << endl;
}

int main() {
	solve();
	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  all(x) (x).begin(),(x).end()     // 昇順ソート
#define  rall(v) (v).rbegin(), (v).rend() // 降順ソート
#define  INF 1LL << 60
typedef long long int LL;
typedef long long int ll;
#define pll pair<ll, ll>
#define F first
#define S second
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return true; } return false; }
//sort(all(x))とするとソートできるよ
// 10^x は pow(10,(x)) 
// 任意のlogは　対数の底の変換を使う    log(N) / log(任意の底)

int main(){
    LL N;cin >> N;
    vector<LL> D(N);
    rep(i,N)cin >> D[i];
    if(D[0] != 0){
        cout << 0 << endl;
    }
    else{
        map<LL,LL> m;
        rep(i,N)m[D[i]] = 0;
        rep(i,N)m[D[i]]++;
        LL ans = 1;
        LL mod = 998244353;

        if(m[0] >= 2){
            cout << 0 << endl;
        }
        else{
        for(auto itr = m.begin();itr != m.end();itr++){
            if(itr -> F == 0)continue;
            LL ind = itr -> F;


            LL bef = m[ind - 1];

            LL lim = itr -> S;
            LL p = 1;
            rep(i,lim){
                p *= bef;
                p = p % mod;
            }
            ans *= p % mod;
            ans = ans % mod;
        }


        cout << ans << endl;


        }

    }
}



Measured memory_bytes: 7296
pub struct Poper<'a> {
	iter: std::str::SplitWhitespace<'a>,
}

impl<'a> Poper<'a> {
	pub fn new(iter: std::str::SplitWhitespace) -> Poper {
		Poper { iter: iter }
	}
	pub fn read<T: std::str::FromStr>(&mut self) -> T
	where
		<T as std::str::FromStr>::Err: std::fmt::Debug,
	{
		self.iter.next().unwrap().parse().unwrap()
	}
}

fn main() {
	let input = {
		use std::io::Read;
		let mut s = String::new();
		std::io::stdin().read_to_string(&mut s).unwrap();
		s
	};
	let mut iter = Poper::new(input.split_whitespace());
	let n: u64 = iter.read();
	let a: u64 = iter.read();
	let b: u64 = iter.read();

	let r = if n * a < b { n * a } else { b };

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


Measured memory_bytes: 4352
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
using namespace std;
using namespace std;
int main(void){
    int s;
    int x[4];
    cin >> s;
    
    int up = s/100,dw = s % 100;
    if(up >= 1 && up <= 12){
        if(dw >= 1 && dw <= 12){
            cout << "AMBIGUOUS" << endl;
        }else{
            cout << "MMYY" << endl;
        }
    }else{
        if(dw >= 1 && dw <= 12){
            cout << "YYMM" << endl;
        }else{
            cout << "NA" << endl;
        }
    }
    
    return 0;
}

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

using namespace std;

using ll = long long;

const ll MOD = 1000000007;

const int dx[4] = {+1, 0, -1, 0};
const int dy[4] = {0, -1, 0, +1};

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    if(n % max(h, w) == 0){
        cout << n / max(h, w) << endl;
    }else{
        cout << (n / max(h, w)) + 1 << endl;
    }
}

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

struct node{
    int value;
    node *p,*l,*r;
};

node *root, *NIL;

void insert(int value){
    node *y, *x;
    y = NIL;
    x = root;
    node *n = (node *)malloc(sizeof(node));
    n->value = value;
    n->l = n->r = NIL;
    while(x != NIL){
        y = x;
        if(n->value < x->value)
            x = x->l;
        else
            x = x->r;
    }
    n->p = y;
    if(y == NIL) root = n;
    else{
        //x = n;
        if(n->value < y->value) y->l = n;
        else y->r = n;
    }
}


void Preorder(node *u){
    if(u==NIL) return;
    printf(" %d",u->value);
    Preorder(u->l);
    Preorder(u->r);
}

void Inorder(node *u){
    if(u==NIL) return;
    Inorder(u->l);
    printf(" %d",u->value);
    Inorder(u->r);
}

void print(){
    Inorder(root);
    printf("\n");
    Preorder(root);
    printf("\n");
}


int main(){
    int n, value;
    scanf("%d",&n);
    root = (node *)malloc(sizeof(node));
    root = NIL;
    //root->l = root->r = NIL;
    string cmd;
    for(int i=0;i<n;++i){
        cin >> cmd;
        if(cmd == "insert"){
            scanf("%d",&value);
            insert(value);
        }
        else if(cmd == "print"){
            print();
        }
    }
    return 0;
}



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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  string s; cin >> s;
  int n = static_cast<int>(s.size());
  vector<ll> dp1(2019);
  ll cnt = 0;
  for(int i = 0; i < n; ++i){
    vector<ll> dp0(2019);
    int x = s[i] - '0';
    for(int j = 0; j < 2019; ++j){
      dp0[(j*10+x)%2019] += dp1[j];
    }
    dp0[x]++;
    cnt += dp0[0];
    dp1 = move(dp0);    
  }
  cout << cnt << endl;
  return 0;  
}


Measured memory_bytes: 3752
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>

using namespace std;

int n, s, nr1, nr5, nr10, nr;
int main() {
	cin >> n >> s;
	nr10 = s / 10000;
	s %= 10000;
	nr5 = s / 5000;
	s %= 5000;
	nr1 = s / 1000;
	nr = nr10 + nr5 + nr1;
	while (nr < n) {
		if (nr + 4 <= n&&nr5) {
			nr5--;
			nr1 += 5;
		}
		else {
			if (nr10) {
				nr10--;
				nr5 += 2;
			}
			else {
				break;
			}
		}
		nr = nr1 + nr5 + nr10;
	}
	if (nr != n) {
		cout << "-1 -1 -1";
	}
	else {
		cout << nr10 << ' ' << nr5 << ' ' << nr1;
	}
}

Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INTINF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	ll ans = 0;
	int tmp;
	int w, a, b;
	cin >> w >> a >>b;
	int l = min(a, b);
	int r = max(a, b);

	cout << max(0, r - (l+w)) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<iomanip>
#include<complex>
#include<cstdio>
#include<vector>
#include<queue>
#include<stack>
#include<cmath>
#include<list>
#include<map>
#include<set>
using namespace std;

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef stack<int> SI;
typedef queue<int> QI;
typedef list<int> LI;
typedef pair<int,int> PII;
typedef long long LL;

#define d(x)  cout<<#x<<" = "<<(x)<<endl;
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define EMP empty()
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define REACH(i,c) for(typeof((c).rbegin()) i=(c).rbegin(); i!=(c).rend(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c,n) sort(c,c+n)
#define VSORT(c) sort((c).begin(),(c).end())
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define DFOR(i,b,a) for(int i=(b)-1;i>=(a);--i)
#define DREP(i,n) DFOR(i,n,0)
#define INF 1000000000
#define PI  acos(-1.0)
////////////////////////////////////////////////
#define N 8
int row[N],col[N],dpos[N*2-1],dneg[N*2-1];
bool X[N][N];

void print()
{
	REP(i,N)
	{
		REP(j,N)
		{
			if(X[i][j])
			{
				if(row[i]!=j)return ;
			}
		}
	}
	REP(i,N)
	{
		REP(j,N)
		{
			cout<<((row[i]==j)?"Q":".");
		}
		cout<<endl;
	}
}

void recursive(int i)
{
	if(i==N)
	{
		print();
		return;
	}
	
	REP(j,N)
	{
		if(col[j]+dpos[i+j]+dneg[i-j+N-1]!=0)continue;
		row[i]=j;col[j]|=1;dpos[i+j]|=1;dneg[i-j+N-1]|=1;
		recursive(i+1);
		row[i]^=row[i];col[j]^=col[j];dpos[i+j]^=dpos[i+j];dneg[i-j+N-1]^=dneg[i-j+N-1];
	}
}
int main()
{
	int k;
	scanf("%d",&k);
	REP(i,k)
	{
		int r,c;
		scanf("%d%d",&r,&c);
		X[r][c]=true;
	}
	recursive(0);
	return 0;
}

Measured memory_bytes: 3176
#include<cstdio>
typedef long long LL;
const int MOD=1e9+7;
const int N=43;

int n,x,y,z;
int dp[N][1<<17];
int def,lim,ans=1;

int main() {
	scanf("%d %d %d %d",&n,&x,&y,&z);
	def|=1<<(z-1);
	def|=1<<(y+z-1);
	def|=1<<(x+y+z-1);
	lim=(1<<(x+y+z))-1;
	dp[0][0]=1;
	for(int i=1;i<=n;i++) {
		ans=10ll*ans%MOD;
		for(int s=0;s<=lim;s++) {
			if(!dp[i-1][s]) continue;
			for(int j=1;j<=10;j++) {
				int t=((s<<j)|(1<<(j-1)))&lim;
				if((t&def)!=def) {
					dp[i][t]+=dp[i-1][s];
					if(dp[i][t]>=MOD)
						dp[i][t]-=MOD;
				}
			}
		}
	}
	for(int s=0;s<=lim;s++)
		ans=(ans-dp[n][s]+MOD)%MOD;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 21776
from collections import deque

H,W=map(int,input().split())
Ch,Cw=map(lambda x:int(x)-1,input().split())
Dh,Dw=map(lambda x:int(x)-1,input().split())
S=[input() for i in range(H)]

group=[[-1 for j in range(W)] for i in range(H)]

g=0

def bfs(x,y):
    global g
    group[x][y]=g
    deq=deque([(x,y)])
    while deq:
        h,w=deq.popleft()
        for i in range(-1,2):
            for j in range(-1,2):
                if i*j==0 and (i,j)!=(0,0) and 0<=h+i<H and 0<=w+j<W and S[h+i][w+j]=="." and group[h+i][w+j]==-1:
                    group[h+i][w+j]=g
                    deq.append((h+i,w+j))
    g+=1

for i in range(H):
    for j in range(W):
        if group[i][j]==-1 and S[i][j]==".":
            bfs(i,j)

edge=[[] for i in range(g)]

for i in range(H):
    for j in range(W):
        if S[i][j]==".":
            for k in range(-2,3):
                for l in range(-2,3):
                    if 0<=i+k<H and 0<=j+l<W and group[i+k][j+l]!=-1:
                        edge[group[i][j]].append(group[i+k][j+l])

dist=[10**18 for i in range(g)]
dist[group[Ch][Cw]]=0
deq=deque([group[Ch][Cw]])
while deq:
    v=deq.popleft()
    for nv in edge[v]:
        if dist[nv]>dist[v]+1 and nv!=-1:
            dist[nv]=dist[v]+1
            deq.append(nv)

if dist[group[Dh][Dw]]!=10**18:
    print(dist[group[Dh][Dw]])
else:
    print(-1)


Measured memory_bytes: 157576
S = gets.chomp
T = gets.chomp
 
S_CODES = S.codepoints
T_CODES = T.codepoints
 
S_SIZE = S.size
T_SIZE = T.size
dp = Array.new(S_SIZE + 1) { Array.new(T_SIZE + 1, 0) }
 
S_SIZE.times do |s|
  dp_cur = dp[s]
  dp_next = dp[s+1]
  T_SIZE.times do |t|
    if S_CODES[s] == T_CODES[t]
      dp_next[t+1] = dp_cur[t] + 1
    else
      dp_next[t+1] = dp_cur[t+1]
      dp_next[t+1] = dp_next[t] if dp_next[t+1] < dp_next[t]
    end
  end
end
 
lcs = ''
s = S_SIZE
t = T_SIZE
while s > 0 && t > 0
  if dp[s][t] == dp[s-1][t]
    s -= 1
  elsif dp[s][t] == dp[s][t-1]
    t -= 1
  else
    lcs << S[s-1]
    s -= 1
    t -= 1
  end
end
 
puts lcs.reverse

Measured memory_bytes: 74236
/* A */

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;

int main(){
    int n;
    cin >> n;
    std::vector<int> v(n);

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

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

    cout << v[n/2] - v[n/2 - 1] << endl;

}

Measured memory_bytes: 640
#include <stdio.h>

int main(){

  int S[10000],T[500];
  int i,j,n,q;
  int count = 0;

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

  scanf("%d",&q);
  for(i = 0; i < q; i++){
    scanf("%d",&T[i]);
  }

  //ここから計算
  //Tの最初の要素とSの要素を比較し同じものだけカウント

  for(i = 0; i < q; i++){
    for(j = 0; j < n; j++){
      if(T[i] == S[j]){
	count++;
	break;
      }
    }
  }
  
  printf("%d\n",count);
  return 0;
}



Measured memory_bytes: 2108
#include<cstdio>
#include<cstring>
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
ll t[1000+5],a[1000+5];
ll n,p,q,m1,m2,k1,k2,e1,e2;
ll ans;
int main()
{
	scanf("%lld",&n);
	for(int i=1;i<=n;i++)
		scanf("%lld%lld",&t[i],&a[i]);//比例
	for(int i=1;i<=n;i++)
	{
		ll x=t[i],y=a[i];
		if(x<p||y<q)
		{
			k1=p-x,k2=q-y;
			e1=k1/x,e2=k2/y;
			if(e1*x!=k1) m1=e1+2;
			else m1=p/x;
				
			if(e2*y!=k2) m2=e2+2;
			else m2=q/y;
			x*=max(m1,m2);
			y*=max(m1,m2);
		}
		p=x;
		q=y;
		ans=x+y;
	}
	printf("%lld\n",ans);
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0);
#define FOR(i,s,n) for(int i = s; i < (n); i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(n) (n).begin(), (n).end()
#define RALL(n) (n).rbegin(), (n).rend()
#define ATYN(n) cout << ( (n) ? "Yes":"No") << '\n';
#define CFYN(n) cout << ( (n) ? "YES":"NO") << '\n';
#define OUT(n) cout << (n) << '\n';
using ll = long long;
using ull = unsigned long long;
using pii = pair<int,int>;
using pll = pair<ll,ll>;

int main(void)
{
    IOS
    int n, r;
    cin >> n >> r;
    if (n < 10) r += 100 *(10-n);
    OUT(r)

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <queue>
#include <stack>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <cassert>
#include <ctime>
#include <map>
#include <set>
using namespace std;
#define lowbit(x) (x&(-x))
#define max(x,y) (x>y?x:y)
#define min(x,y) (x<=y?x:y)
#define MAX 100000000000000000
#define MOD 1000000007
#define pi acos(-1.0)
#define ei exp(1)
#define PI 3.141592653589793238462
#define ios() ios::sync_with_stdio(false)
#define INF 1044266558
#define mem(a) (memset(a,0,sizeof(a)))
typedef long long ll;
int a,b,c,x,n;
int main()
{
	while(scanf("%d",&n)!=EOF)
	{
		a=b=c=0;
		for(int i=0;i<n;i++)
		{
			scanf("%d",&x);
			if(!(x%4)) a++;
			else if(x&1) b++;
			else c++;
		}
		if(!c) b--;
		puts(a>=b?"Yes":"No");
	}
	return 0;
}

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

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[] L = new int[N];
		for(int i = 0; i < N; i++) L[i] = sc.nextInt();
		Arrays.sort(L);
		int ans = 0;

		for(int i = 0; i < N; i++) {
			for(int j = i + 1; j < N; j++) {
				// |a - b|より大きい最小の棒のindex
				int low = -1, high = N - 1;
				while(high - low > 1) {
					int mid = (high + low) / 2;
					if(L[mid] > Math.abs(L[i] - L[j])) {
						high = mid;
					} else {
						low = mid;
					}
				}
				int lower = high;

				// a + bより小さい最大の棒のindex
				low = 0; high = N;
				while(high - low > 1) {
					int mid = (high + low) / 2;
					if(L[mid] < L[i] + L[j]) {
						low = mid;
					} else {
						high = mid;
					}
				}
				int upper = low;
				int count = Math.max(0, upper - j);
				ans += count;
			}
		}

		System.out.println(ans);
	}
}

Measured memory_bytes: 26480
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <fstream>
#include <functional>
#include <iostream>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <vector>
using namespace std;
using ll = long long;
#define fst first
#define snd second

/* clang-format off */
template <class T, size_t D> struct _vec { using type = vector<typename _vec<T, D - 1>::type>; };
template <class T> struct _vec<T, 0> { using type = T; };
template <class T, size_t D> using vec = typename _vec<T, D>::type;
template <class T> vector<T> make_v(size_t size, const T& init) { return vector<T>(size, init); }
template <class... Ts> auto make_v(size_t size, Ts... rest) { return vector<decltype(make_v(rest...))>(size, make_v(rest...)); }
template <class T> inline void chmin(T &a, const T& b) { if (b < a) a = b; }
template <class T> inline void chmax(T &a, const T& b) { if (b > a) a = b; }
/* clang-format on */

int main() {
  int N;
  string A, B, C;
  while (cin >> N >> A >> B >> C) {
    int res = 0;
    for (int i = 0; i < N; i++) {
      set<char> S = {A[i], B[i], C[i]};
      res += S.size() - 1;
    }
    cout << res << endl;
  }
  return 0;
}


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

int n,m,a[310][310],cnt[310];
bool vis[310];

bool pass(int lim)
{
	int i,j;
	bool flag=1;
	memset(vis,1,sizeof(vis));
	while (flag)
	{
		flag=0;
		memset(cnt,0,sizeof(cnt));
		for (i=1;i<=n;i++)
		for (j=1;j<=m;j++)
			if (vis[a[i][j]])
			{
				cnt[a[i][j]]++;
				break;
			}
		for (i=1;i<=m;i++)
			if (cnt[i]>lim)
				vis[i]=0,flag=1;
	}
	for (i=1;i<=m;i++)
		if (vis[i]) return 1;
	return 0;
}

int main()
{
#ifdef h10
	freopen("B.in","r",stdin);
	freopen("B.out","w",stdout);
#endif
	int i,j;
	scanf("%d%d",&n,&m);
	for (i=1;i<=n;i++)
	for (j=1;j<=m;j++)
		scanf("%d",&a[i][j]);
	int L=1,R=n,mid;
	while (L<=R)
	{
		mid=(L+R)>>1;
		if (pass(mid))
			R=mid-1;
		else
			L=mid+1;
	}
	printf("%d\n",L);
}


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

using namespace std;

vector<string> su;
string s;
int K;

int main()
{
	cin >> s >> K;
	for (int i = 0; s[i] != '\0'; i++) {
		for (int j = i; j < i + K && s[j] != '\0'; j++) {
			su.push_back(s.substr(i, j - i + 1));
		}
	}
	sort(su.begin(), su.end());
	su.erase(unique(su.begin(), su.end()), su.end());
	cout << su[K-1] << endl;
	return 0;
}

Measured memory_bytes: 1660
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(k,i,n) for(ll i=k;i<n;++i)
int main(void){
    ll n,m;
    cin>>n>>m;
    vector<pair<ll,ll>> a(n);
    rep(0,i,n){
        cin>>a[i].first>>a[i].second;
    }
    sort(a.begin(),a.end());
    ll v=0,ans=0;
    rep(0,i,n){
        ll x=a[i].first,y=a[i].second;
        if(v+y<=m){
            v+=y;
            ans+=x*y;
            if(v==m)break;
        }else{
            ll b=m-v;
            ans+=x*b;
            break;
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <map>
#include <iomanip>
#include <queue>
#include <numeric>


using namespace std;


int main() {

	int H, W;
	bool ans = true, key = false;

	cin >> H >> W;
	
	vector<vector <char> > S(H + 2, vector<char>(W + 2));
	int dx[4] = { -1, 0 ,1 ,0 };
	int dy[4] = { 0,1, 0, -1 };


	for (int i = 1; i <= H ; i++) {
		for (int j = 1; j <= W; j++) {
			cin >> S[i][j];
		}
	}

	for (int i = 1; i <= H; i++) {
		for (int j = 1; j <= W; j++) {
			if (S[i][j] == '#') {
				key = false;
				for (int k = 0; k < 4; k++) {
					if (S[i + dx[k]][j + dy[k]] == '#') {
						key = true;
					}
				}
				if (!key) {
					ans = false;
					goto Ans;
				}
			}
		}
	}

	Ans:

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

	return 0;
}


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

using namespace std;

typedef long long ll;
typedef vector<int> pi;
typedef pair<int,int> vi;

#define F first
#define S second
#define PB push_back
#define MK make_pair
#define REP(i, a, b) for (int i=a; i < b; i++)


bool sort_by(vi c, vi d){
	return c.S < d.S;
}

int main() {
	string s;
	cin >> s;
	int l=0, r=s.size()-1;
	while(l != r){
		if(s[l] != 'A') ++l;
		if(s[r] != 'Z') --r;
		
		if(s[l] == 'A' && s[r] == 'Z') break;
	}
	cout << (l==r? 0:r-l+1);
	

}


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

int main() {
  int N; cin >> N;
  int T[110];
  int total_time = 0;
  for (int i = 0; i < N; i++) {
    cin >> T[i];
    total_time += T[i];
  }
  
  int M; cin >> M;
  int p, x, ans;
  for (int j = 0; j < M; j++) {
    cin >> p >> x;
    ans = total_time - T[p - 1] + x;
    cout << ans << endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
while True:
  ( H, W) = [ int(i) for i in input().split()]
  if H == W == 0:
    break
  
  for h in range( H):
    for w in range( W):
      if h == 0 or h == H-1:
        print( '#', end='')
      elif w == 0 or w == W-1:
        pass
        print( '#', end='')
      else:
        print( '.', end='')
    print()
  print()

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

int main()
{
ll n ;
cin >> n ;
vector<vector<ll>> g(n);
rep(i,n-1){
  ll p ;
  cin >> p ;
  g[i+1].push_back(p-1);
  g[p-1].push_back(i+1);
}
vector<pair<ll,ll>> x(n);
rep(i, n){
  cin >> x[i].first;
}
ll root=0;
vector<vector<ll>> child(n);
vector<ll> par(n);
queue<ll> q;
queue<ll> qq;
q.push(root);
par[root]=-1;
//親の定義と葉を見つける
while(!q.empty()){
  ll p=q.front();
  q.pop();
  if(g[p].size()==1 && p!=root){qq.push(p);}
  for(auto r:g[p]){
    if(r==par[p])continue;
    par[r]=p;
    q.push(r);
  }
}
while(!qq.empty()){
  ll p=qq.front();
  qq.pop();
  child[par[p]].push_back(p);//親に値を追加する
  //根の時は例外処理
  if(child[par[p]].size()==g[par[p]].size()){
    //child[par[p]]に子の値が入ってる
    ll sum=0;
    for(auto r:child[par[p]]){
      sum+=x[r].first+x[r].second;
    }
    bitset<5001> bit;
    bit[0]=1;
    for(auto r:child[par[p]]){
      bit=(bit<<x[r].first)|(bit<<x[r].second);
    }
    ll mx=-1;
    rep(i,x[par[p]].first+1){
      if(bit[i])mx=i;
    }
    if(mx==-1){
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    else{
      x[par[p]].second=sum-mx;
    }
  }
  //全ての葉が親に追加し終わった
  if(child[par[p]].size()==g[par[p]].size()-1 && par[p]!=root){
    //child[par[p]]に子の値が入ってる
    ll sum=0;
    for(auto r:child[par[p]]){
      sum+=x[r].first+x[r].second;
    }
    bitset<5001> bit;
    bit[0]=1;
    for(auto r:child[par[p]]){
      bit=(bit<<x[r].first)|(bit<<x[r].second);
    }
    ll mx=-1;
    rep(i,x[par[p]].first+1){
      if(bit[i])mx=i;
    }
    if(mx==-1){
      cout << "IMPOSSIBLE" << endl;
      return 0;
    }
    else{
      x[par[p]].second=sum-mx;
    }
    qq.push(par[p]);
  }
}
cout << "POSSIBLE" << endl;
return 0;
}

Measured memory_bytes: 384
import java.util.*;
public class Main {
    public static void main(String args[]){
        Scanner sc = new Scanner(System.in);
        int N,T;
        N=sc.nextInt();
        T=sc.nextInt();
        ArrayList<Integer> cost = new ArrayList<>();
        for(int a=0;a<N;a++){
            int c = sc.nextInt();
            int t=sc.nextInt();
            if(t<=T) cost.add(c);
        }
        if(cost.size()!=0) System.out.println(Collections.min(cost));
        else System.out.println("TLE");

    }
}

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

typedef long long ll;

int main() {
	int n;
	cin >> n;
	int v[n];
	int n1[200000];
	int n2[200000];
	int mx1 = -114514;
	int mx2 = -114514;
	int mxx1;
	int mxx2;
	for (int i = 0;i < 200000;i++) {
		n1[i] = 0;
		n2[i] = 0;
	}
	for (int i = 0;i < n;i++) {
		cin >> v[i];
		if (i%2 == 0) {
			n1[v[i]]++;
		} else {
			n2[v[i]]++;
		}
	}
	for (int i = 0;i < 200000;i++) {
		if (mx1 < n1[i]) {
			mx1 = n1[i];
			mxx1 = i;
		}
		if (mx2 < n2[i]) {
			mx2 = n2[i];
			mxx2 = i;
		}
	}
	ll ans = 0;
	if (mxx1 == mxx2) {
		sort(n1,n1+200000);
		sort(n2,n2+200000);
		ans = n - max(n1[200000-1]+n2[200000-2],n1[200000-2]+n1[200000-1]);
	} else {
		ans = (n/2-mx1) + (n/2-mx2);
	}
	cout << ans << endl;
}

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

# 桁数を決める
digit = 1  # 桁数
num = pow(26, digit) # その桁数での最大番号
while num < N:
    digit += 1
    num += pow(26, digit)

# その桁数内でのNの順番を0-indexで求める.
# (つまり, 2桁であれば'aa' -> 0, 'zz' -> 675 となる.)
order = N - (num - pow(26, digit)) - 1

# orderの26進数表記Xを求める.
# 例えば, 3桁でorder=28のとき, X = [0, 1, 2]
X = [0] * digit
cur = digit - 1
while order > 0:
    X[cur] = order % 26
    order //= 26
    cur -= 1

# 各桁の文字は'a' + Xiとなる
ans = []
for x in X:
    c = chr(ord('a') + x)
    ans.append(c)

print(''.join(ans))

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

using namespace std;

int main()
{
    int n,x;
    cin>>n;
    vector<pair<int,int>> vec;
    for(int i=1;i<=n;i++)
    {
        cin>>x;
        vec.push_back(make_pair(x,i));
    }

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

    for(int i=0;i<n;i++)cout<<vec[i].second<<" ";
}


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

typedef long long ll;
const int N = 2000006;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	
	string s;
	cin>>s;
	for(int i=1;i<4;i++){
		if(s[i] == s[i-1]){
			cout<<"Bad";
			return 0;
		}
	}
	 cout<<"Good";
	
	return 0;
}


Measured memory_bytes: 3580
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const ll INF{numeric_limits<ll>::max()/3};
ll N,M,R,d[201][201],r[8],ans;
int main(){
    cin.tie(0),ios_base::sync_with_stdio(0);
    cin>>N>>M>>R;
    for(int i{};i<R;++i)
        cin>>r[i];
    fill(d[0],d[201],INF);
    for(int i{};i<M;++i){
        ll A,B,C;cin>>A>>B>>C;
        d[A][B]=d[B][A]=C;
    }
    for(int k{1};k<=N;++k)
        for(int i{1};i<=N;++i)
            for(int j{1};j<=N;++j)
                d[i][j]=min(d[i][j],d[i][k]+d[k][j]);
    ans=INF;
    sort(r,r+R);
    do{
        ll dist{};
        for(int i{1};i<R;++i)
            dist+=d[r[i-1]][r[i]];
        ans=min(ans,dist);
    }while(next_permutation(r,r+R));
    cout<<ans<<endl;
}


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

const ll INF = 1001001001;

//提出のときに言語がc＋＋似合っていることを確認する

//絶対値の関数
int z(int a,int b){
  if(a>b) return a-b;
  else return b-a;
}





int main(){
  int r;
  cin>>r;
  double ans=2*r*3.1415926535;
  cout<<fixed<<setprecision(8);
  cout<<ans<<endl;
}



Measured memory_bytes: 3788
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace AOJ
{
    class FiveNumber
    {
        static void Main(string[] args)
        {
            var param = Array.ConvertAll(System.Console.ReadLine().Split(' '), new Converter<string,int>(s => int.Parse(s)));
            param = param.OrderByDescending(s => s).ToArray();
            System.Console.WriteLine(string.Join(" ", Array.ConvertAll(param, new Converter<int, string>(s => s.ToString()))));
        }
    }
}

Measured memory_bytes: 6372
#include <bits/stdc++.h>
#define REP(i, n) for (long long i = 0; i < (long long)n; i++)
//#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using Pi = pair<int, int>;
using Pl = pair<ll, ll>;
using Vecl = vector<ll>;
using Graph = vector<vector<int>>;

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll L, R;
  cin >> L >> R;
  if (R - L >= 2019 || L == 0) {
    cout << 0 << endl;
    return 0;
  }
  L = L % 2019;
  R = R % 2019;
  if (L > R) {
    cout << 0 << endl;
    return 0;
  }
  int ans = 2019;
  for (int i = L; i < R; i++) {
    for (int j = i + 1; j <= R; j++) {
      ans = min(ans, (i * j) % 2019);
      if (ans == 0) {
        cout << 0 << endl;
        return 0;
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define For(i, a, b) for(int (i)=(int)(a); (i)<(int)(b); ++(i))
#define rFor(i, a, b) for(int (i)=(int)(a)-1; (i)>=(int)(b); --(i))
#define rep(i, n) For((i), 0, (n))
#define rrep(i, n) rFor((i), (n), 0)
#define fi first
#define se second
using namespace std;
typedef long long lint;
typedef unsigned long long ulint;
typedef pair<int, int> pii;
template<class T> bool chmax(T &a, const T &b){if(a<b){a=b; return true;} return false;}
template<class T> bool chmin(T &a, const T &b){if(a>b){a=b; return true;} return false;}
template<class T> T div_floor(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>=0 ? a/b : (a+1)/b-1;
}
template<class T> T div_ceil(T a, T b){
    if(b < 0) a *= -1, b *= -1;
    return a>0 ? (a-1)/b+1 : a/b;
}

constexpr lint mod = 1e9+7;
constexpr lint INF = mod * mod;
constexpr int MAX = 100010;

typedef struct UnionFindTree{
    vector<int> par;

    UnionFindTree(int n){
        par.resize(n, -1);
    }

    bool is_root(int x){
        return par[x]<0;
    }

    int find(int x){
        if(is_root(x)) return x;
        return par[x] = find(par[x]);
    }

    int size(int x){
        return -par[find(x)];
    }

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

    bool same(int x, int y){
        return find(x) == find(y);
    }
}UF;

int main(){
    int n, q; lint m;
    scanf("%d%lld%d", &n, &m, &q);
    UF uf(n);
    lint cnt = n;
    int a[q], b[q], c[q];
    rep(i, q){
        scanf("%d%d%d", &a[i], &b[i], &c[i]);
        if(c[i] == 0) cnt -= uf.unite(a[i], b[i]);
    }
    int tmp = 0;
    rep(i, q)if(c[i] == 1){
        ++tmp;
        if(uf.same(a[i], b[i]) || m == n-1){
            puts("No");
            return 0;
        }
    }
    puts((tmp == 0 && m == n-1) || (n <= m && m <= n + cnt*(cnt-3)/2) ? "Yes" : "No");
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(ll i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
typedef tuple<ll,ll,ll> Tu;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const double PI=3.14151926535;
const ll INFl=(ll)9223372036854775807/2;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
const ll tMOD=(ll)998244353;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
//int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[8]={0,1,0,-1,1,1,-1,-1},mdy[8]={-1,0,1,0,1,-1,1,-1};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
ll i,o,t,j,l,s,z;
int main(){
	cin>>i>>o>>t>>j>>l>>s>>z;
	ll ans=(i/2)*2+(j/2)*2+(l/2)*2+o;
	if(i>=1&&j>=1&&l>=1){
		i--,j--,l--;
		ll anst=(i/2)*2+(j/2)*2+(l/2)*2+o+3;
		ans=max(ans,anst);
	}
	cout<<ans<<endl;
}

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

int main(){
    int a[3];
    for(int i=0;i<3;i++)cin>>a[i];
    sort(a,a+3);
    int res=0;
    int ev=0,od=0;
    for(int i=0;i<3;i++){
        if(a[i]%2==0)ev++;
        else od++;
    }
    if(ev>od && od!=0){
        for(int i=0;i<3;i++){
            if(a[i]%2==0)a[i]+=1;
        }
        res+=1;
        sort(a,a+3);
        res+=(a[2]-a[0])/2;
        res+=(a[2]-a[1])/2;
    }else if(od>ev && ev!=0){
        for(int i=0;i<3;i++){
            if(a[i]%2!=0)a[i]+=1;
        }
        res+=1;
        sort(a,a+3);
        res+=(a[2]-a[0])/2;
        res+=(a[2]-a[1])/2;
    }else if(ev==0 || od==0){
        sort(a,a+3);
        res+=(a[2]-a[0])/2;
        res+=(a[2]-a[1])/2;
    }
    
    cout<<res;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
  
using namespace std;
  
#define rep(i,n) REP(i,0,n)
#define REP(i,s,e) for(int i=(s); i<(int)(e); i++)
#define repr(i, n) REPR(i, n, 0)
#define REPR(i, s, e) for(int i=(int)(s-1); i>=(int)(e); i--)
#define pb push_back
#define all(r) r.begin(),r.end()
#define rall(r) r.rbegin(),r.rend()
#define fi first
#define se second
  
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
const int INF = 1e9;
const ll MOD = 1e9 + 7;
double EPS = 1e-8;

int main(){
    int n, a ,b;
    cin >> n >> a >> b;
    vi cnt(3);
    rep(i, n) {
        int p;
        cin >> p;
        if(p <= a) cnt[0]++;
        else if(p <= b) cnt[1]++;
        else cnt[2]++;
    }
    sort(all(cnt));
    cout << cnt[0] << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define rep1(i, n) for(int i = 1; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

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

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

template<class T> inline auto __lcm(T& a, T& b) 
{ return a * b / __gcd(a, b); }

template<typename T> void remove(std::vector<T>& vector, unsigned int index)
{ vector.erase(vector.begin() + index); }


int main() {
    int N;  cin >> N;
    string S;  cin >> S;

    int ans = 1;
    rep(i, S.size()-1) {
        if (S[i] != S[i+1]) ans++;
    }

    print(ans);

    return 0;
}

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

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> sx(n);  vector<int> sy(n);
  vector<int> cx(m);  vector<int> cy(m);
  for (int i=0; i<n; i++) cin >> sx.at(i) >> sy.at(i);
  for (int i=0; i<m; i++) cin >> cx.at(i) >> cy.at(i);
  
  for (int i=0; i<n; i++) {
    int d=1000000009,tmp=0,ans=0;
    for (int j=0; j<m; j++) {
      tmp = abs(sx.at(i)-cx.at(j)) + abs(sy.at(i)-cy.at(j));
      if (d>tmp) {
        d = tmp;
        ans = j+1;
      }
    }
    cout << ans << endl;
  }
  
  return 0;
}


Measured memory_bytes: 256
n=gets.to_i
ss=Hash.new
n.times do
  sn=gets.chomp
  if ss[sn]
    ss[sn]+=1
  else
    ss[sn]=1
  end
end
ss2=ss.sort_by{|k,v| [-v,k]}
ss2.size.times do |i|
  if ss2[i][1]==ss2[0][1]
    puts ss2[i][0]
  else
    exit
  end
end


Measured memory_bytes: 47608
# 初期入力
#棒を長さでソートし、
N = int(input())
L = list(map(int, input().split()))
L_sorted =sorted(L)

#3本選ぶ組み合わせ,1番長いもの2本決めると、短いものは最低の長さが決まる　はだめだった
#短い2本選んで、長いものの境界を考えると「lo,hi」がなくなる
import bisect

count =0
for i in range(0,N-1): #一番長い
    for j in range(i+1,N):#真ん中
        x =L_sorted[i] + L_sorted[j]
        index =bisect.bisect_left(L_sorted,x)
        a=1
        #count.append(index -j-a)
        count += max(0,index -j-a)
        #print(L_sorted[i],L_sorted[j],L_sorted[index-a],index,x)

print(count)

Measured memory_bytes: 3188