akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

ll a[200009];

void solve()
{
	int n,i;
	cin>>n;
	for(i=0;i<n;i++) cin>>a[i];
	sort(a,a+n,greater<ll>());
	ll sum =a[0];
	int cnt=n-2;
	int ind=1;
	while(cnt)
	{
		if(cnt==1)
		{
			sum+=a[ind++];
			cnt=0;
		}
		else
		{
			cnt-=2;
			sum += 2*a[ind++];
		}
	}
	cout<<sum<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 5176
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <cmath>
#include <cstring>
#include <utility>
#include <numeric>

using namespace std;

int main(){

    int A, B, C;
    cin >> A >> B >> C;
    if(A == B && A != C){
        cout << "Yes" << endl;
    }
    else if(B == C && A != C){
        cout << "Yes" << endl;
    }
    else if(C == A && C != B){
        cout << "Yes" << endl;
    }
    else{
        cout << "No" << endl;
    }

    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{int W,H,x,y,r;
	scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
	if(r+x<=W&&0<=x-r)
		{if(r+y<=H&&0<=y-r)
		printf("Yes\n");
		else
		printf("No\n");
	}
	else
	printf("No\n");
	return 0;
}

Measured memory_bytes: 584
use proconio::marker::*;
use proconio::*;

fn main() {
    input! {
        n: usize,
        mut a: [usize; n],
    };

    a.sort();
    let a = a.iter().rev().collect::<Vec<_>>();
    let mut ans = *a[0];
    for i in 1..a.len() - 1 {
        ans += *a[(i + 1) / 2];
    }

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


Measured memory_bytes: 7216
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define MOD 1000000007

using namespace std;
using ll = long long;

int main() {
	ll n, k, ans = 1e18;
	cin >> n >> k;
	vector<ll> a(n);
	rep(i,n) {
		cin >> a[i];
		a[i]--;
	}

	ll now = 0;
	vector<ll> move(n, -1);
	move[0] = 0;
	for (ll i = 1; i <= k; ++i) {

		if (move[a[now]] >= 0) {
			ll num = (k - i) % (i - move[a[now]]);
			now = a[now];
			for (ll j = 0; j < num; j++) {
				now = a[now];
			}
			break;
		}
		else {
			now = a[now];
			move[now] = i;
		}
	}
	ans = now + 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 6440
import std.stdio;
import std.c.stdio;
import std.range;
import std.array;
import std.functional;
import std.algorithm;
import std.conv;
import std.container;
import std.math;
import std.numeric;
import std.string;
import std.c.string;
import std.regex;
import std.typecons;

struct Edge {
    int a, b, c, h, r;
}
 
int N, M, H, K;
Edge[] G[100];
int S, T;
int P;
int Pass[256];
const INF = int.max / 4;

bool input() {
    scanf("%d %d %d %d\n", &N, &M, &H, &K);
    if (N == 0 && M == 0 && H == 0 && K == 0) return false;
    foreach (i; 0 .. N) G[i].clear;
    foreach (i; 0 .. M) {
        int a, b, c, h, r;
        scanf("%d %d %d %d %d\n", &a, &b, &c, &h, &r);
        a--; b--; r--;
        G[a] ~= Edge(a, b, c, h, r);
        G[b] ~= Edge(b, a, c, h, r);
    }
    scanf("%d %d\n", &S, &T);
    S--; T--;
    scanf("%d\n", &P);
    Pass[] = INF;
    foreach (i; 0 .. P) {
        int l, d; scanf("%d %d\n", &l, &d);
        int bit = 0;
        foreach (j; 0 .. l) {
            int k;
            scanf("%d", &k);
            k--;
            bit |= (1 << k);
        }
        Pass[bit] = d;
    }
    return true;
}

void solve() {
    void initPass() {
        Pass[0] = 0;
        foreach (i; 0 .. (1<<K)) {
            foreach (j; i + 1 .. (1<<K)) {
                Pass[i | j] = min(Pass[i | j], Pass[i] + Pass[j]);
            }
        }
    }
    initPass;
    struct State {
        int a, h, c;
    }
    const int MaxN = 100;
    const int MaxH = 24;
    bool Time() {
        static int D[MaxN];
        D[] = INF;
        D[S] = 0;
        BinaryHeap!(Array!State, "a.h > b.h") PQ;
        PQ.insert(State(S, 0, 0));
        while (!PQ.empty) {
            State cur = PQ.front; PQ.removeFront;
            foreach (edge; G[cur.a]) {
                int next_h = cur.h + edge.h;
                if (D[edge.b] > next_h) {
                    D[edge.b] = next_h;
                    PQ.insert(State(edge.b, next_h, cur.c + edge.c));
                }
            }
        }
        return D[T] <= H;
    }

    if (!Time) {
        writeln(-1);
        return;
    }

    int Cost(int bit) {
        static int D[MaxN][MaxH + 1];
        foreach (i; 0 .. N) D[i][] = -1;
        int dfs(int v, int h) {
            if (h > H) return INF;
            if (v == T) return 0;
            if (D[v][h] >= 0) return D[v][h];
            int Ret = INF;
            foreach (edge; G[v]) {
                int next_h = h + edge.h;
                int cost = ((bit & (1 << edge.r)) ? 0 : edge.c);
                Ret = min(Ret, cost + dfs(edge.b, next_h));
            }
            return D[v][h] = Ret;
        }
        return dfs(S, 0);
    }

    int Ans = INF;
    foreach (bit; 0 .. (1<<K)) {
        if (Pass[bit] == INF) continue;
        Ans = min(Ans, Cost(bit) + Pass[bit]);
    }
    writeln(Ans);
}

void main() {
    while (input) solve;
}

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

int main (){
  int N,a,b,c,d;
  cin >> N;
  a = N % 10;
  b = N / 10 % 10;
  c = N / 100 % 10;
  d = N / 1000 % 10;
  if (a == b && b == c || b == c && c == d)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
}

Measured memory_bytes: 256
/*
    Author:zeke

    pass System Test!
    GET AC!!
*/
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
using ll = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define rep3(var, min, max) for (ll(var) = (min); (var) < (max); ++(var))
#define repi3(var, min, max) for (ll(var) = (max)-1; (var) + 1 > (min); --(var))
#define Mp(a, b) make_pair((a), (b))
#define F first
#define S second
#define Icin(s) \
    ll(s);      \
    cin >> (s);
#define Scin(s) \
    ll(s);      \
    cin >> (s);
template <class T>
bool chmax(T& a, const T& b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T& a, const T& b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}
typedef pair<ll, ll> P;
typedef vector<ll> V;
typedef vector<V> VV;
typedef vector<P> VP;
ll mod = 1e9 + 7;
ll MOD = 1e9 + 7;
ll INF = 1e18;
// cout << "Case #" << index << " :IMPOSSIBLE";
VV graph;
V vec;
V res;
V dp;
void dfs(ll k,ll prev,ll reg){
    ll g=lower_bound(all(dp),vec[k])-dp.begin();
    ll log_=dp[g];
    dp[g]=vec[k];
    if(dp[g+1]==INF){
        reg=g;
    }
    res[k]=lower_bound(all(dp),INF)-dp.begin();
    for(auto i:graph[k]){
        if(i==prev){
            continue;
        }
        dfs(i,k,reg);
    }
    dp[g]=log_;
    return;
}
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);
    ll n;
    cin>>n;
    vec.resize(n);
    res.resize(n);
    rep(i,n)cin>>vec[i];
    graph.resize(n+1);
    rep(i,n-1){
        ll x,y;
        cin>>x>>y;
        x--;y--;
        graph[x].push_back(y);
        graph[y].push_back(x);
    }
    dp.resize(n,INF);
    dfs(0,-1,0);
    rep3(i,0,n){
        cout<<res[i]<<endl;
    }
}


Measured memory_bytes: 33168
n=int(input())
s=input()
l=[0]*n
r=[0]*n
for i in range(1,n):
    l[i]=l[i-1]+(s[i-1]=="W")
for i in range(n-2,-1,-1):
    r[i]=r[i+1]+(s[i+1]=="E")
ans=n-1
for i in range(n):
    ans=min(ans,l[i]+r[i])
print(ans)

Measured memory_bytes: 27168
N,M = map(int,input().split())
stu = []
cha = []
for _ in range(N):
    a,b = map(int,input().split())
    stu.append([a,b])
for _ in range(M):
    a,b = map(int,input().split())
    cha.append([a,b])
for s in stu:
    ch = 0
    min_d = 1000000000
    for i,c in enumerate(cha):
        d = abs(s[0] - c[0]) + abs(s[1] - c[1])
        if d < min_d:
            ch = i
            min_d = d
    print(ch+1)

Measured memory_bytes: 3064
#include <iostream>
#include <array>
#include <vector>
#include <iomanip>
#include <string>
#include <cmath>
#include <array>
#include <algorithm>
#include <queue>
#include <map>
using namespace std;

typedef  pair<int,int> P;


int main(){
     string s;
     cin>>s;
     string ans;
     for(int i=0;i<s.size();++i){
          if(s[i]=='0'){
               ans+='0';
          }else if(s[i]=='1'){
               ans+='1';
          }else  if(s[i]=='B'&&ans.size()){
               ans.pop_back();
          }
        }
        cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(ll i = m; i < n; i++)
#define IFOR(i, m, n) for(ll i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main(){
  ll N; cin >> N;
  vector<ll> p(N);
  REP(i,N){
    cin >> p[i];
    p[i]--;
  }
  vector<ll> a(N), b(N);
  REP(i,N){
    a[i] = (i+1)*N;
    b[i] = (N-i)*N;
  }
  REP(i,N-1){
    if(p[i]<p[i+1]) a[p[i+1]] += i+1;
    else b[p[i+1]] += i+1;
  }
  REP(i,N) cout << a[i] << " \n"[i==N-1];
  REP(i,N) cout << b[i] << " \n"[i==N-1];
}

Measured memory_bytes: 1152
//#include <iostream>
#include <cstdio>
using namespace std;

int main(){
  while (true){
  	int T, D, L; scanf("%d%d%d",&T,&D,&L); int x, a=0, lv=0;
    if (T==0) break;
    if (T==1) {printf("0\n"); continue;}
    
    for(int i=0; i<T; i++){
      scanf("%d",&x);
      if (x>=L) lv = D;
      if (lv && (i!=T-1)){a++; lv--;}
    }
    printf("%d\n",a);
  }
}


Measured memory_bytes: 2608
#include <stdio.h>
int main(){

    int n, d; //n= num of tree, d = range of check

    //input
    scanf("%d %d", &n, &d);

    //calc
    int watcherNum = n /(d*2+1);
    if( n % (d*2+1) !=0){
        watcherNum++;
    }

    //output
    printf("%d\n", watcherNum);

    return 0;
}


Measured memory_bytes: 128
# include <cmath>
# include <iostream>
# include <queue>
# include <set>
# include <stack>
# include <string>
# include <vector>


using namespace std;


int main() {
    int n, u, v, a, b; cin >> n >> u >> v;
    u--; v--;

    vector<vector<int>> g(n);
    for (int i=0; i<n; i++) g[i].empty();

    for (int i=0; i<n-1; i++) {
        cin >> a >> b;
        a--; b--;
        g[a].push_back(b);
        g[b].push_back(a);
    }

    if (n==2) {
        cout << 0 << endl;
        return 0;
    }

    vector<int> dist1(n, 0);
    queue<pair<int, int>> que;
    que.push(make_pair(v, 0));
    while (!que.empty()) {
        auto p = que.front(); que.pop();
        int cur = p.first;
        int cst = p.second;
        dist1[cur] = cst;

        for (int next_n: g[cur]) {
          if (next_n == v or dist1[next_n] > 0)
            continue;
          que.push(make_pair(next_n, cst + 1));
        }
    }

    vector<int> dist2(n, 0);
    queue<pair<int, int>> que2;
    que2.push(make_pair(u, 0));
    while (!que2.empty()) {
        auto p = que2.front(); que2.pop();
        int cur = p.first;
        int cst = p.second;
        dist2[cur] = cst;

        for (int next_n: g[cur]) {
          if (next_n == u or dist2[next_n] > 0)
            continue;
          que2.push(make_pair(next_n, cst + 1));
        }
    }

    int ans = 0;
    for (int i=0; i<n; i++) {
        if (dist1[i] > dist2[i]) ans = max(ans, dist1[i]);
    }

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



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

int main(void){
	map<char, int>	key;
    key['q'] = 1;
    key['w'] = 1;
    key['e'] = 1;
    key['r'] = 1;
    key['t'] = 1;
    key['a'] = 1;
    key['s'] = 1;
    key['d'] = 1;
    key['f'] = 1;
    key['g'] = 1;
    key['z'] = 1;
    key['x'] = 1;
    key['c'] = 1;
    key['v'] = 1;
    key['b'] = 1;
    key['y'] = 0;
    key['u'] = 0;
    key['i'] = 0;
    key['o'] = 0;
    key['p'] = 0;
    key['h'] = 0;
    key['j'] = 0;
    key['k'] = 0;
    key['l'] = 0;
    key['n'] = 0;
    key['m'] = 0;

	string input;
	while(cin >> input && input != "#"){
		int changed = 0;
		int now = key[input[0]];
		for(int i = 1; i < input.size(); i++){
			if(key[input[i]] != now){
				now = key[input[i]];
				changed++;
			}
		}
		cout << changed << endl;
	}
  return 0;
}

Measured memory_bytes: 1188
#include <iostream>
#include <cstdlib>

using namespace std;

struct Node{
    int key;
    Node *prev;
    Node *next;
};

Node *nil;

void initialization(){
    nil = (Node *)malloc(sizeof(Node));
    nil->next = nil;
    nil->prev = nil;
}

void insert(int key){
    Node *x = (Node *)malloc(sizeof(Node));
    x->key = key;
    x->next = nil->next;
    nil->next->prev = x;
    nil->next = x;
    x->prev = nil;
}

void delete_node(Node *x){
    x->prev->next = x->next;
    x->next->prev = x->prev;
    free(x);
}

void delete_key(int key){
    Node *p = nil->next;
    while(p != nil && p->key != key) p = p->next;
    if(p->key == key) delete_node(p);
}

void delete_first(){
    delete_node(nil->next);
}

void delete_last(){
    delete_node(nil->prev);
}

int main(){
    int n, key;
    string command;

    initialization();

    cin >> n;
    while(n--){
        cin >> command;
        if(command == "insert"){
            cin >> key;
            insert(key);
        } else if(command == "delete"){
            cin >> key;
            delete_key(key);
        } else if(command == "deleteFirst"){
            delete_first();
        } else if(command == "deleteLast"){
            delete_last();
        }
    }
    Node *p = nil->next;
    while(p->next != nil) {
        cout << p->key << " ";
        p = p->next;
    }
    if(p != nil) cout << p->key << endl;

    return 0;
}


Measured memory_bytes: 34384
#include<bits/stdc++.h>
using namespace std;
#define ll long long
int main()
{
	int n;string s,t;
	cin>>n>>s>>t;
	int i=0,prev=0; ll ans=1;
	if(s[0]==t[0])
	{
		ans*=3;
		prev=1;
		i=1;
	}
	else
	{
		ans*=6;
		prev=2;
		i=2;
	}
	for(;i<n;i++)
	{
		if(s[i]==t[i])
		{
			if(prev==1)
				ans = (ans*2LL)%1000000007;

			prev=1;
		}
		else
		{
			if(prev==1){
				ans = (ans*2LL)%1000000007;

			}
			else
				ans = (ans*3L)%1000000007;

			prev=2;
			i++;
		}
		ans =ans % 1000000007;

	}
	cout<<ans<<"\n";
}

Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
#define DEBUG 0
#define nl          '\n'
#if     DEBUG
#define trace(var)  {cerr << "Line " << __LINE__ << ": " << #var << "=" << var << nl;}
#else
#define trace(var)	{}
#endif
#define fori(n)			for(int i = 0; i < n; ++i) 
#define forj(n)			for(int j = 0; j < n; ++j)
#define fork(n)			for(int k = 0; k < n; ++k)
#define forl(n)			for(int l = 0; l < n; ++l)

typedef long long ll;typedef pair<int,int> pii;typedef vector<bool> vbool;typedef vector<int> vint;typedef vector<ll> vll;typedef long double ld;typedef vector<vector<int>> vvi;

const ll N = 10010;
const ll INF = 0x3f3f3f3f;
const ll MOD = 1e9 + 7;

int solve() {
	int n;cin  >> n;
	vint a(n);
	fori(n) cin >> a[i];
	sort(a.begin(), a.end());
	if (a[n-1] == 0) return 1;
	if (n%3 != 0) return 0;
	map<int,int> count;
	fori(n) {
		count[a[i]]++;
	}
	if (count.size() == 3) {
		vint c(3), b(3);
		int i = 0;
		for(auto x : count) {
			b[i] = x.first;
			c[i++] = x.second;
		}
		if (c[0] == c[1] && c[1] == c[2]) { 
			if ((b[0]^b[1]) == b[2]) 
			return 1;
		}
	}
	if (count.size() == 2) {
		vint c(2);
		int i = 0;
		for(auto x : count) {
			c[i++] = x.second;
		}
		int cur = count[0];
		if ((c[0] == 2*c[1] &&  c[1] == cur)||(c[1] == 2*c[0] && c[0] == cur)) return 1;
	}
	return 0;
}
int main() {
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
	if (solve() == 1) cout << "Yes" << nl;
	else cout << "No" << nl;

#if DEBUG
	cerr << "Time: " << (ld)clock() / CLOCKS_PER_SEC << " s" << nl;
	#endif
	return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int main(){
  ll n;
  while(cin>>n){
    int a[100]={0};
    if(n==0){
        cout<<0<<endl;
        continue;
    }
    ll tmp=abs(n), x=1;
    for(int i=0; i<32; ++i){
        x*=2;
    }
    for(int i=32; i>=0; --i){
        if(tmp>=x){
            a[i]=1;
            tmp-=x;
        }
        x/=2;
    }
    if(n>0){
        for(int i=0; i<34; ++i){
            if(a[i]==2){
                a[i]=0;
                ++a[i+1];
            }
            else if(a[i]==1){
                if(i%2){
                    ++a[i+1];
                }
            }
        }
    }
    else{
        for(int i=0; i<34; ++i){
            if(a[i]==2){
                a[i]=0;
                ++a[i+1];
            }
            else if(a[i]==1){
                if(i%2==0){
                    ++a[i+1];
                }
            }
        }
    }
    for(int i=34; i>=0; --i){
        if(a[i]!=0){
            tmp=i;
            break;
        }
    }
    for(int i=tmp; i>=0; --i){
        cout<<a[i];
    }
    cout<<endl;
  }
  return 0;
}




Measured memory_bytes: 256
//name wzq
//内容
//文件名
#include<iostream>
using namespace std;
int main()
{
	long long x,s=100;
	cin>>x;
	int i=0;
	while(1)
	{
		s=s*(1+0.01);
		s=s/1;
		i++;
		if(s>=x)
		break;
	}
	cout<<i<<endl;
}

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

typedef long long ll;
typedef string st;
typedef vector<int> vi;
typedef vector<st> vs;
#define rep(i, n) for(int i = 0; i < n; i++)
#define fogg(i,a,b) for(int i = (a); i <= (b); i++)
#define ford(i,a,b) for(int i = (a); i >= (b); i--)
#define test int t; cin >> t; while(t--)
#define debug(x) cout << '>' << #x << ':' << x << "\n";
#define endl '\n'
#define pb push_back
#define gp " "
#define ff first
#define ss second
#define mp make_pair



int main() {
	
	int r;
	cin >> r;
	double pi = 3.14159;
	cout <<fixed <<setprecision(2)<< 2*pi*r;
	return 0;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N=0;
  cin >> N;
  vector<int> d(N);
  for(int i=0;i<N;i++){
   cin >> d.at(i); 
  }
  
  sort(d.begin(),d.end());
  reverse(d.begin(),d.end());
  
  int count=1;
  
  for(int i=0;i<N-1;i++){
    if(d.at(i)>d.at(i+1)){
     count+=1; 
    }
  }
  
  cout << count << endl;
  return 0; 
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pdd pair<double,double>
#define X first
#define Y second
#define REP(i,a) for(int i=0;i<a;++i)
#define REPP(i,a,b) for(int i=a;i<b;++i)
#define FILL(a,x) memset(a,x,sizeof(a))
#define	foreach( gg,itit )	for( typeof(gg.begin()) itit=gg.begin();itit!=gg.end();itit++ )
#define	mp make_pair
#define	pb push_back
#define sz(a) int((a).size())
#define all(a)  a.begin(), a.end()
#define	debug(ccc)	cout << #ccc << " = " << ccc << endl;
#define present(c,x) ((c).find(x) != (c).end())
const double eps = 1e-8;
#define EQ(a,b) (fabs((a)-(b))<eps)
inline int max(int a,int b){return a<b?b:a;}
inline int min(int a,int b){return a>b?b:a;}
inline ll max(ll a,ll b){return a<b?b:a;}
inline ll min(ll a,ll b){return a>b?b:a;}
const int mod = 1e9+7;
const int N = 1e6+10;
const ll inf = 1e18;

ll power(ll a,ll n){
	if(n==0){
		return 1;
	}
	ll b = power(a,n/2);
	b = b*b%mod;
	if(n%2) b= b*a%mod;
	return b;
}

int add(int a,int b){ return (a+b)%mod;}
int mul(int a,int b){ return (ll)a*b%mod;}

ll A[N];
vector <int> B;

int main(){
 // 	freopen("nice.in","r",stdin);
 // freopen("nice.out","w",stdout);
	int n,l;
	ll sum=0;
	scanf("%d %d",&n,&l);
	REP(i,n){
		scanf("%lld",&A[i]);sum+=A[i];
	}
	int f = 0;
	REP(i,n-1){
		if(A[i]+A[i+1]>=l){
			printf("Possible\n");
			REP(j,i){ printf("%d\n",j+1);}
			for(int j=n-1;j>=i+1;j--)	printf("%d\n",j);
			return 0;
		}
	}
			printf("Impossible\n");return 0;
	


	// int in1 = 0 , in2 = n-1;
	// while(in2!=in1){
	// 	if(sum<l){
	// 		printf("Impossible\n");return 0;
	// 	}
	// 	if(A[in2]<=A[in1]){
	// 		B.pb(in2-1);sum-=A[in2];in2--;
	// 	}else{
	// 		B.pb(in1);sum-=A[in1];in1++;
	// 	}
	// }
	// printf("Possible\n");
	// REP(i,B.size())	printf("%d\n",B[i]+1);
	return 0;
}



Measured memory_bytes: 1536
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD = 1e9+7;



int main(){
    ll N, A, B; cin >> N >> A >> B;
    ll a=0, b=0;
    string S; cin >> S;
    for(int i = 0; i < S.size(); i++){
        if(S[i] == 'a') a++;
        else if(S[i] == 'b') b++;
        if(S[i] == 'a'){
            if(a+b > A+B){
                cout << "No" << endl;
                a--;
            }
            else cout << "Yes" << endl;
        }
        else if(S[i] == 'b'){
            if(a+b > A+B || b > B){
                cout << "No" << endl;
                b--;
            }
            else cout << "Yes" << endl;
        }
        else cout << "No" << endl;
    }

}


Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
const int INF = 1001001001;

template<class Type>
Type modpow(Type a, Type n, Type mod)
{
	Type res = 1;
	while (0 < n) {
		if (n & 1) {
			res = res * a % mod;
		}
		a = a * a % mod;
		n >>= 1;
	}
	return res;
}

template<class Type>
Type gcd(Type x, Type y)
{
	Type r;
	if (x < y) swap(x, y);

	while (0 < y) {
		r = x % y;
		x = y;
		y = r;
	}
	return x;
}

template<class Type>
Type lcm(Type x, Type y)
{
	return x * y / gcd(x, y);
}

template<class Type>
bool is_prime(Type x)
{
	if (x == 2) return true;
	if (x < 2 || x % 2 == 0) return false;

	for (Type i = 3; i <= sqrt(x); i += 2) {
		if (x % i == 0) return false;
	}
	return true;
}

template<class Type>
vector<bool> eratos(Type n)
{
	vector<bool> isPrime(n + 1, true);
	isPrime[0] = isPrime[1] = false;
	for (Type i = 2; i <= n; i++) {
		if (isPrime[i]) {
			Type j = i + i;
			while (j <= n) {
				isPrime[j] = false;
				j = j + i;
			}
		}
	}
	return isPrime;
}

bool binary_search_judge(vector<int> a, int index, int key)
{
	if (key <= a[index]) return true;
	else return false;
}

int binary_search(vector<int> a, int key)
{
	int ng = -1;
	int ok = a.size();
	while (1 < abs(ng - ok)) {
		int mid = (ng + ok) / 2;
		if (binary_search_judge(a, mid, key)) ok = mid;
		else ng = mid;
	}
	return a[ok] == key;
}

int main()
{	
	ll a, b, c, d;
	cin >> a >> b >> c >> d;

	ll e = lcm(c, d);
	ll c_num = b / c - (a - 1) / c;
	ll d_num = b / d - (a - 1) / d;
	ll e_num = b / e - (a - 1) / e;

	cout << (b - a + 1) - c_num - d_num + e_num << endl;
}

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

int main() {
  int N,K;
  cin >> N >> K;
  int sum = 0;
  
  for(int i = 0;i < N;i++){
    int x;
    cin >> x;
    
    if(x < K - x){
      sum += x;
    }
    else{
      sum += K -x;
    }
  }
  cout << sum * 2 << endl;
}

Measured memory_bytes: 256
N=int(input())
x=[0]+list(map(int,input().split()))+[0]
s=0
for i in range(N+1):
	s+=abs(x[i+1]-x[i])
for i in range(1, N+1):
	d1=x[i]-x[i-1]
	d2=x[i+1]-x[i]
	print(s - (2*min(abs(d1), abs(d2)) if d1<0 and d2>0 or d1>0 and d2<0 else 0))


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

int main() {
  char a;
  cin >> a;

  if (a == 'A') {
    cout << 'T' << endl;
  } else if (a == 'C') {
    cout << 'G' << endl;
  } else if (a == 'G') {
    cout << 'C' << endl;
  } else {
    cout << 'A' << endl;
  }

}

Measured memory_bytes: 3592
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <tuple>
#include <utility>
#include <vector>
#define ll long long
#define itn int
#define endl '\n'
#define co(ans) cout<<ans<<endl
#define COYE cout<<"YES"<<endl
#define COYe cout<<"Yes"<<endl
#define COye cout<<"yes"<<endl
#define CONO cout<<"NO"<<endl
#define CONo cout<<"No"<<endl
#define COno cout<<"no"<<endl
#define FORE(i,a) for(auto &i:a)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define FFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define RREP(i,n)  FFOR(i,1,n)
#define PB push_back
#define MP make_pair
#define ALL(V) (V).begin(),(V).end()
#define SORT(V) sort((V).begin(),(V).end())
#define REVERSE(V) reverse((V).begin(),(V).end())
#define EACH(V,i) for(typeof((V).begin()) i=(V).begin();i!=(V).end();++i)
#define equals(a,b) (fabs((a)-(b))<EPS)
#define INF ((1LL<<62)-(1LL<<31))
#define EPS 1e-10
#define PI 3.141592653589793238
#define MOD 1000000007
#define MAX 5100000
using namespace std;
using Edge=pair<ll,ll>;
using Graph=vector<vector<int>>;
inline int toInt(string s){int v;istringstream sin(s);sin>>v;return v;}
template<class T>inline string toString(T x){ostringstream sout;sout<<x;return sout.str();}
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};
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 main(){
  ll N,ans=0;
  cin>>N;
  
  ll CNT[15];
  REP(i,15) CNT[i]=i*(i+1)/2;
  
  ll P=N;
  for(int i=2; i<=sqrt(N); ++i){
    if(P%i==0){
      ll cnt=0;
      while(P%i==0){
        P/=i;
        cnt++;
      }
      for(int j=1; j<=10; ++j){
        if(CNT[j]<=cnt && cnt<CNT[j+1]){
          ans+=j;
          break;
        }
      }
    }
  }
  
  if(P!=1) ans++;
  co(ans);
  return 0;
}

Measured memory_bytes: 3680
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
 
typedef pair<int, int> p;

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

    char a;
    cin >> a;

    if(a >= 'a') a = 'a';
    else a = 'A';

    cout << a << endl;
}

Measured memory_bytes: 3648
#include <iostream>
#include <cmath>
#include <string>

using namespace std;

int main() {
	int a = 0;
	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	for (int i = 0; i < n; i++) {
		if (s[i] == 'I') {
			a++;
		} else {
			a--;
		}
		ans = max(ans, a);
	}
	cout << ans << endl;
	return 0;
}

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

namespace AOJ
{
  class Program
  {
    public static void Main(string[] args)
    {
      var primes = GetPrimes(999999);
      foreach (var n in ReadNumbers())
        Console.WriteLine(primes.Where(x => x <= n).Count());
    }

    static IEnumerable<int> GetPrimes(int n)
    {
      if (n < 2)
        return new List<int>(); 
      var list = Enumerable.Range(2, n - 1).Where(x => x % 2 != 0);
      var primes = new List<int>(new[] { 2 });
      if (list.Any())
      {
        do 
        {
          var i = list.First();
          primes.Add(i);
          list = list.Where(x => x % i != 0).ToList();
        } while (list.Any() && list.Max() > Math.Pow(primes.Max(), 2.0));
      }
      primes.AddRange(list);
      return primes;
    }

    static IEnumerable<int> ReadNumbers()
    {
      string line;
      while ((line = Console.ReadLine()) != null)
        yield return int.Parse(line);
    }
  }
}

Measured memory_bytes: 22928
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <set>
using namespace std;

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

int main()
{
    int n; cin >> n;
    vector<int> l(n);
    rep(i, n){
        cin >> l[i];
    }
    sort(l.begin(), l.end());

    int ans = 0;
    for(int m1 = n - 1; m1 >= 2; m1--){
        for(int m2 = m1 - 1; m2 >= 1; m2--){
            if(l[m1] == l[m2]) continue;
            for(int m3 = m2 - 1; m3 >= 0; m3--){
                if(l[m2] == l[m3] || l[m3] <= l[m1] - l[m2]) continue;

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

Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll MOD = 1e9 + 7;
//constexpr ll MOD = 998244353;
//constexpr ll MOD = ;
ll mod(ll A, ll M) {return (A % M + M) % M;}
constexpr ll INF = 1LL << 60;
template<class T> bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return false;}
template<class T> bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return false;}
ll divceil(ll A, ll B) {return (A + (B - 1)) / B;}
#define FINALANS(A) do {cout << (A) << '\n'; exit(0);} while (false)

int main()
{
  ll a, b, c;
  cin >> a >> b >> c;

  cout << ((c - a - b >= 0 && (c - a - b) * (c - a - b) > 4 * a * b) ? "Yes" : "No") << endl;
}

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

int main()
{
	unsigned long n, m, k;
	std::cin >> n >> m >> k;

	std::vector<unsigned long long> ai, bi;
	ai.resize(n+1);
	bi.resize(m+1);
	ai[0] = 0;
	bi[0] = 0;
	for (auto i = 0; i < n; i++)
	{
		std::cin >> ai[i+1];
		ai[i + 1] += ai[i]; // 累積和の計算
	}
	for (auto i = 0; i < m; i++)
	{
		std::cin >> bi[i+1];
		bi[i + 1] += bi[i];
	}
	bi.push_back(10^9);

	unsigned int count = 0;
	for (unsigned int i = 0; i < ai.size(); ++i)
	{
		if (ai[i] <= k)
		{
			unsigned int idx_large = m+1;
			unsigned int idx_small = 0;
			unsigned int step = (m+1) >> 1;
			unsigned int j = step;
			while ((idx_large - idx_small) > 1)
			{
				step >>= 1;
				step = (step < 1) ? 1 : step;
				if (k >= (ai[i] + bi[j]))
				{
					idx_small = j;
					j += step;
				}
				else
				{
					idx_large = j;
					j -= step;
				}
			}
			count = std::max(count, i + idx_small);
		}
		else
		{
			break;
		}
	}

	std::cout << count << std::endl;

	return 0;
}


Measured memory_bytes: 7984
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const long long INF = 100000000000000000LL;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
ll dp[4001][4001];
short K[4001][4001];
ll accum[4001];

int main(){
  int N;
  cin >> N;
  ll* w = dp[0];
  REP(i, N) cin >> w[i];
  accum[0] = 0;
  for(int i = 0; i < N; i++){
    accum[i + 1] = accum[i] + w[i];
  }
  memset(K, -1, sizeof(K));
  REP(i, N + 1) REP(j, N + 1) dp[i][j] = INF;
  REP(i, N){
    //dp[i][i] = 0;
    //K[i][i] = i;
    dp[i][i + 1] = 0;
    K[i][i + 1] = i;
  }
  for(int w = 2; w <= N; w++){
    for(int i = 0; i + w <= N; i++){
      int j = i + w;
      for(int k = K[i][j - 1]; k <= K[i + 1][j]; k++){
        ll x = dp[i][k] + dp[k][j] + (accum[j] - accum[i]);
        if(dp[i][j] >= x){
          dp[i][j] = x;
          K[i][j] = k;
        }
      }
      //printf("dp[%d][%d] = %lld K: %d -> %d\n", i, j, dp[i][j], K[i][j - 1], K[i + 1][j]);
    }
  }
  cout << dp[0][N] << endl;
  return 0;
}

Measured memory_bytes: 157536
#include<cstdio>
#define MAX(x,y) ((x>y)? x:y)

using namespace std;

int BOX[2];
int n;
int DATE[10];
bool answer=true;


int main()
{
	scanf("%d",&n);
	for(int i=0;i<n;i++)
	{
		BOX[0]=0;BOX[1]=0;
		for(int j=0;j<10;j++)
		{
			scanf("%d",&DATE[j]);
		}
		for(int j=0;j<10;j++)
		{
			if(j==0)BOX[0]=DATE[j];
			else
			{
				if(BOX[0]>DATE[j]&&BOX[1]>DATE[j])answer=false;
				else if(BOX[0]>DATE[j])BOX[1]=DATE[j];
				else if(BOX[1]>DATE[j])BOX[0]=DATE[j];
				else if(BOX[0]>BOX[1])BOX[0]=DATE[j];
				else BOX[1]=DATE[j];

			}
		}
		if(answer==true) printf("YES\n");
		else printf("NO\n");
	}
	return 0;
}

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

using namespace std;

char s[200010];

int main() {
	scanf("%s", s + 1);
	int n = strlen(s + 1);
	int i = 2, ans = 1;
	while (i != n + 1) {
		if (s[i] == s[i - 1]) {
			i ++ ;
			if (i == n + 1) {
				break;
			}
			i ++ ;
			ans ++ ;
			if (i == n + 1) {
				break;
			}
		}
		i ++ ;
		ans ++ ;
	}
	cout << ans << endl ;
	return 0;
}

Measured memory_bytes: 384
// Problem : 
// 			C - Walking Takahashi
// 			
// 		
// Contest : AtCoder - AtCoder Beginner Contest 175
// URL : https://atcoder.jp/contests/abc175/tasks/abc175_c
// Memory Limit : 1024 MB
// Time Limit : 2000 ms
// Powered by CP Editor (https://github.com/cpeditor/cpeditor)

// #pragma GCC optimize ("O3")
// #pragma GCC target ("sse4")

#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef long double ld;
typedef complex<ld> cd;
 
typedef pair<int, int> pi;
typedef pair<ll,ll> pl;
typedef pair<ld,ld> pd;
 
typedef vector<int> vi;
typedef vector<ld> vd;
typedef vector<ll> vl;
typedef vector<pi> vpi;
typedef vector<pl> vpl;
typedef vector<cd> vcd;
 
#define FOR(i, a, b) for (int i=a; i<(b); i++)
#define F0R(i, a) for (int i=0; i<(a); i++)
#define FORd(i,b,a) for (int i = (b)-1; i >= a; i--)
#define F0Rd(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
 
#define bug(x) cout<<#x<<"="<<x<<endl; 
#define sz(x) (int)(x).size()
#define mp make_pair
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
 
template<class T> bool ckmin(T& a, const T& b) { return b < a ? a = b, 1 : 0; }
template<class T> bool ckmax(T& a, const T& b) { return a < b ? a = b, 1 : 0; }
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
const ld pii=3.14159265359; 
const int MOD = 1000000007;
const char nl = '\n';
const int MX = 200001; //check the limits, dummy
 
int main() 
{
	ios_base::sync_with_stdio(0); cin.tie(0);    
	ll X,K,D;
	cin>>X>>K>>D;
	X=abs(X);
	ll val=X/D;
	if(val>=K)
	{
		cout<<X-K*D<<nl;
		return 0;
	}
	ll v1=X-val*D,v2=X-val*D-D;
	v2=abs(v2);
	K-=val;
	if(K%2==0)
		cout<<v1;
	else
		cout<<v2;
	return 0;
}
 
// read the question correctly (ll vs int)
// template by bqi343

Measured memory_bytes: 3652
#S=input()
N=int(input())
#N,M,X,Y=map(int,input().split())
W=[]
can=True
for i in range(N):
    w=input()
    if i==0:
        W.append(w)
        e=w[-1]
        continue
    s=w[0]
    if e==s and not(w in W):
        W.append(w)
        e=w[-1]
        continue
    else:
        can=False
        break
if can:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 38384
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC

int main(){
    int n,k,ans=0;cin>>n>>k;
    string s;cin>>s;
    vector<int> vec(0);
    int tmp=1,cnt=0;
    for(int i=0;i<n;i++){
        if((char)('0'+tmp)!=s[i]){
            vec.pb(cnt);
            cnt=1;
            tmp=1-tmp;
        }
        else cnt++;
    }
    if(cnt>0)vec.pb(cnt);
    if(s[n-1]=='0')vec.pb(0);
    int sz=vec.size();
    if(sz/2<=k)ans=n;
    else{
        tmp=0;
        for(int i=0;i<2*k+1;i++){
            tmp+=vec[i];
        }
        ans=max(ans,tmp);
        for(int i=2*k+1;i<sz;i+=2){
            tmp-=(vec[i-2*k-1]+vec[i-2*k]);
            tmp+=(vec[i]+vec[i+1]);
            ans=max(ans,tmp);
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3992
import java.util.Scanner;
public class Main{
    public static void main(String[]args){
        Scanner scan = new Scanner(System.in);
        int h = scan.nextInt();
        int w = scan.nextInt();
        int n = scan.nextInt();
        int a =Math.max(h,w);
        int b =Math.min(h,w);
        for(int i=0;i<=b;i++){
            if(a*i>=n){
                System.out.println(i);
                break;
            }
        }
    }
}

Measured memory_bytes: 23892
const fs = require('fs')
const reader = (s: string) => (s.split(" "))
 
function Main(input: string) {

  const nums = reader(input).map(i => parseInt(i));

  let sum=0
  nums.forEach( n => sum += n)

console.log(sum > 21 ? "bust" : "win")

}
 
Main(fs.readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <algorithm>
#include <vector>

using namespace std;

#define MAX(x,y) (x>y?x:y)
#define MIN(x,y) (x<y?x:y)
#define ABS(x) (x>0?x:-(x))
#define INF 1000000000

#define MOD 1000000007

void swap(int* a, int* b)
{
	int tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

void swap2(double* a, double* b)
{
	double tmp;
	tmp = *a;
	*a = *b;
	*b = tmp;
}

int gcd(int a, int b)  //最大公約数
{
	if (a < b)
		swap(&a, &b);

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

int lcm(int a, int b)
{
	return a * b / gcd(a, b);
}

long power(long x, int n) { //x^n 計算量O(logn)
	long ans = 1;
	while (n > 0) {
		if ((n & 1) == 1) {
			ans = ans * x;
		}
		x = x * x; //一周する度にx, x^2, x^4, x^8となる
		n >>= 1; //桁をずらす n = n >> 1
	}
	return ans;
}

int combination(int n, int r)
{
	if (r == 0 || r == n)
		return (1);
	else if (r == 1)
		return (n);
	return (combination(n - 1, r - 1) + combination(n - 1, r));
}

int keta(int a, int n)
{
	if (n == 1)
		return a % 10;

	for (int i = 0; i < n - 1; i++)
		a /= 10;

	return a % 10;
}

int main()
{
	int N, M, L, K;

	scanf("%d", &L);

	printf("%f", pow((double)L/3,3));
}


Measured memory_bytes: 384
n,m = map(int, input().split())
ac=0
wa=0
pp=set()
d={}
for i in range(0,m):
    p,s = input().split()
    if p in pp:
        continue
    if s == 'AC':
        pp.add(p)
        ac=ac+1
        wa = wa+d.get(p, 0)
    if p in d.keys():
        d[p] = d[p] + 1
    else:
        d[p]=1
print(ac, wa)

Measured memory_bytes: 21288
#include <stdio.h>
#include <string.h>
#include <stdlib.h>

int tri_judge(int i, int j, int k);

int compare_int(const void *a, const void *b)
{
    return *(int *)b - *(int *)a;
}

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

    qsort(length, n, sizeof(int), compare_int);

    int j, k;
    int ans = 0;

    for (i = 0; i < n; i++)
    {
        for (j = i + 1; j < n; j++)
        {
            for (k = j + 1; k < n; k++)
            {
                if (tri_judge(length[i], length[j], length[k]))
                {
                    ans++;
                    //printf("%d,%d,%d\n", length[i], length[j], length[k]);
                }
                else
                {
                    break;
                }
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}

int tri_judge(int i, int j, int k)
{
    if (i + j > k && j + k > i && k + i > j)
    {
        return 1;
    }
    else
    {
        return 0;
    }
}

Measured memory_bytes: 128
import collections
from sys import stdin


def get_result(data):
    N, S = data[0], data[1:]
    c = collections.Counter(S)
    max_count = max(c.values())
    output_s = [key for key, val in c.items() if val == max_count]
    output_s = sorted(output_s)
    return '\n'.join(output_s)

if __name__ == '__main__':
    raw_data = [val.rstrip('\n') for val in stdin.readlines()]
    data = [val for val in raw_data]
    result = get_result(data)
    print(result)


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

using namespace std;

using ll = long long;

template <int MOD> class ModInt {
private:
  int x;

  ModInt inverse() const {
    int a = x, b = MOD, u = 1, v = 0;
    while (b) {
      auto t = a / b;
      a -= t * b;
      swap(a, b);
      u -= t * v;
      swap(u, v);
    }
    return ModInt(u);
  }

public:
  ModInt() = default;
  ModInt(ModInt &&) = default;
  ModInt &operator=(ModInt &&) = default;
  ModInt(const ModInt &) = default;
  ModInt &operator=(const ModInt &) = default;
  ~ModInt() = default;

  template <typename T> ModInt(T x) : x(((x % MOD) + MOD) % MOD) {}

  auto value() const { return x; }

  ModInt &operator+=(const ModInt &mx) {
    x = (x + mx.x) % MOD;
    return *this;
  }
  ModInt &operator-=(const ModInt &mx) {
    x = (x - mx.x + MOD) % MOD;
    return *this;
  }
  ModInt &operator*=(const ModInt &mx) {
    x = (int)((long long)x * mx.x % MOD);
    return *this;
  }
  ModInt &operator/=(const ModInt &mx) {
    x = (ModInt(x) * mx.inverse()).value();
    return *this;
  }
};
template <int MOD>
bool operator==(const ModInt<MOD> &lhs, const ModInt<MOD> &rhs) {
  return lhs.value() == rhs.value();
}
template <int MOD>
ModInt<MOD> operator+(const ModInt<MOD> &lhs, const ModInt<MOD> &rhs) {
  return ModInt<MOD>(lhs) += rhs;
}
template <int MOD>
ModInt<MOD> operator-(const ModInt<MOD> &lhs, const ModInt<MOD> &rhs) {
  return ModInt<MOD>(lhs) -= rhs;
}
template <int MOD>
ModInt<MOD> operator*(const ModInt<MOD> &lhs, const ModInt<MOD> &rhs) {
  return ModInt<MOD>(lhs) *= rhs;
}
template <int MOD>
ModInt<MOD> operator/(const ModInt<MOD> &lhs, const ModInt<MOD> &rhs) {
  return ModInt<MOD>(lhs) /= rhs;
}
template <int MOD> ostream &operator<<(ostream &os, const ModInt<MOD> &mx) {
  return os << mx.value();
}
template <int MOD> istream &operator>>(istream &is, ModInt<MOD> &mx) {
  long long x;
  is >> x;
  mx = ModInt<MOD>(x);
  return is;
}

template <typename T> class CumulativeSum {
  std::vector<T> _sums;

public:
  CumulativeSum(const vector<T> &v) : _sums(v) {
    _sums.insert(_sums.begin(), 0);
    for (int i = 1; i < (int)_sums.size(); ++i) {
      _sums[i] += _sums[i - 1];
    }
  }

  // sum of [1, index]
  T sum(int index) { return _sums[index]; }

  // sum of [left, right)
  T sum(int left, int right) { return sum(right - 1) - sum(left - 1); }
};

using mInt = ModInt<1000000007>;

int main() {
  int n;
  cin >> n;
  vector<mInt> v(n, 1);
  for (int i = 0; i < n; ++i) {
    v[i] /= i + 1;
  }
  CumulativeSum<mInt> cs(v);
  mInt ans = 0;
  for (int i = 0; i < n; ++i) {
    mInt a;
    cin >> a;
    ans += (cs.sum(n - i) + cs.sum(i + 1) - mInt(1)) * a;
  }
  for (int i = 0; i < n; ++i) {
    ans *= mInt(i + 1);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1408
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


//N:1e5
const int bucket_size = 512;
struct Range_Add_Query {
    // data num, bucket num
    int N, K;
    vector<ll> data;
    vector<ll> bucket_add;

    Range_Add_Query(int n) : N(n) {
        K = (N + bucket_size - 1) / bucket_size;
        data.assign(K * bucket_size, 0LL);
        bucket_add.assign(K, 0LL);
    }

    //[l, r)
    void add(int s, int t, ll x){
        for(int i=0; i<K; i++){
            int left = i * bucket_size;
            int right = (i + 1) * bucket_size;
            if(t <= left || right <= s) continue;
            if(s <= left && right <= t) bucket_add[i] += x;
            else{
                for(int j=max(s, left); j<min(right, t); j++) data[j] += x;
            }
        }
    }

    //get one of data point
    ll get(int i){
        int k = i / bucket_size;
        return (data[i] + bucket_add[k]);
    }
};

int main(){
    ll n, d, a;
    cin >> n >> d >> a;
    using P = pair<ll, ll>;
    vector<P> v(n);
    rep(i, n) cin >> v[i].first >> v[i].second;
    sort(all(v));

    vector<ll> x(n);
    rep(i, n) x[i] = v[i].first;

    ll ans = 0;
    Range_Add_Query raq(n);
    rep(i, n){
        if(v[i].second <= raq.get(i)) continue;
        int t = (upper_bound(all(x), x[i]+2*d) - x.begin());
        ll num = (v[i].second - raq.get(i))/a + (ll)((v[i].second - raq.get(i)) % a != 0);
        ans += num;
        raq.add(i, t, a*num);
    }
    cout << ans << endl;
}


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

typedef long long ll;

int main() {
    int n, m; cin >> n >> m;
    int a[n];
    ll sum = 0;
    for(ll i = 0; i < n; i++) {
        cin >> a[i];
        sum += a[i];
    }
    
    ll cnt = 0;
    for(int i = 0; i < n; i++) {
        if(4 * m * a[i] >= sum) cnt++;
    }

    if(cnt >= m) {
        cout << "Yes";
    }else{
        cout << "No";
    }

    return 0;
}

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

#define rep(i, N) for (int i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; i++)
#define repr(i, N) for (ll i = N-1; i >= 0; i--)
#define repr1(i, N) for (ll i = N; i > 0; i--)

using ll = long long;
using namespace std;

int main(){
    int cnt = 0,ans=0;
    string S;
    cin >> S;

    rep(i,S.length()){
        if(S[i] == 'A' || S[i] == 'C' || S[i] == 'G' || S[i] == 'T'){
            cnt++;
        }else{
            cnt = 0;
        }
        ans = max(ans, cnt);
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long  ll;
#define FOR(i,a,n) for(ll i=(ll)a;i<(ll)n;i++)
#define RFOR(i,a,n) for(ll i=(ll)n-1;i >= (ll)a;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,0,n)
#define ALL(v) v.begin(), v.end()
#define bra(first,second) '(' << first << ',' << second << ')'
ll MOD = 1000000007;
//ll INF = 21474836470000000;
ll INF = 100000000000000000;
long double EPS = 1e-11;
long double PI = 3.141592653589793238;
template<typename T>
void remove(std::vector<T>& vector, unsigned int index){
    vector.erase(vector.begin() + index);
}

using Graph = vector<vector<ll>>;

ll N,M;
vector<ll> A,B(10001000),C(100010);

bool f(ll x){
    ll cnt = 0;
    rep(i,N){
        cnt += B[max(x-A[i],(ll)0)];
    }
    if(cnt >= M) return true;
    else return false;
}

int main(){
    cin >> N >> M;
    rep(i,N){
        ll a;
        cin >> a;
        A.push_back(a);
    }
    sort(ALL(A));
    rep(i,N){
        B[A[i]]++;
    }
    rep(i,100010){
        C[i+1] += C[i] + A[min(i,N)];
    }
    rrep(i,100009){
        B[i] += B[i+1];
    }
    ll l = 0,r = 10000000;
    while(r - l > 1){
        ll mid = (l+r) / 2;
        if(f(mid)){
            l = mid;
        }else{
            r = mid;
        }
    }
    ll ans = 0,cnt = 0;
    rep(i,N){
        ans += A[i] * B[max(l-A[i],(ll)0)] + C[100009] - C[N-B[max(l-A[i],(ll)0)]];
        cnt += B[max(l-A[i],(ll)0)];
    }
    cout << ans - (cnt - M) * l << endl;
}



Measured memory_bytes: 80376
import sys, queue
def input():
    return list(map(int, sys.stdin.readline().strip().split()))
 
n, m = input()
mem = [10 ** 6 for _ in range(n + 1)] # n -> 1 거리
adj = [[] for _ in range(n + 1)]
q = queue.Queue()
for i in range(m):
    a, b = input()
    adj[b].append(a)
    adj[a].append(b)
    if b == 1: 
        q.put(a)
        mem[a] = 1
    if a == 1: 
        q.put(b)
        mem[b] = 1
mem[1] = -1
while not q.empty():
    v = q.get()
    for vv in adj[v]:
        if mem[vv] != 10 ** 6: continue
        mem[vv] = v
        q.put(vv)
 
if 10 ** 6 in mem[2:]:
    print('No')
else:
    print('Yes', *mem[2:], sep='\n')

Measured memory_bytes: 36828