akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define rep(i,m,n) for(int i=(int)(m);i<(int)(n);++i)
#define rREP(i,m,n) for(int (i)=(n)-1; (i)>=(m);--(i))
#define all(x) (x).begin(),(x).end()
#define out(y,x,h,w) (y)<0||(x)<0||(y)>=(h)||(x)>=(w)
constexpr int INF = 1000000001;
constexpr ll mod = 1000000007;
constexpr double PI = 3.1415926535897932;

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;
}
inline void init() {
	cin.tie(nullptr); cout.tie(nullptr);
	ios::sync_with_stdio(false);
	cout << fixed << setprecision(15);
}

int main() {
	init();
	
	string s, t; cin >> s >> t;
	bool is = false;
	rREP(i, 0, s.size() - t.size() + 1) {
		string a = s.substr(i, t.size());
		if (a.size() == t.size()) {
			bool ok = true;
			rep(j, 0, a.size()) {
				if (a[j] != '?' && a[j] != t[j])ok = false;
			}
			if (ok) {
				rep(j, 0, t.size()) {
					s[i + j] = t[j];
				}
				rep(j, 0, s.size()) {
					if (s[j] == '?')s[j] = 'a';
				}
				is = true;
				break;
			}
		}
	}
	if (is)cout << s << "\n";
	else cout << "UNRESTORABLE" << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define REP(i,n) for(int i = 0;i < (int)(n);i++)
#define RREP(i,n) for(int i = (int)n-1;i >= 0;i--)
#define FOR(i,s,n) for(int i = s;i < (int)n;i++)
#define RFOR(i,s,n) for(int i = (int)n-1;i >= s;i--)
#define ALL(a) a.begin(),a.end()
//#define IN(a, x, b) (a<=x && x<b)
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;}
template<class T>istream&operator >>(istream&is,vector<T>&vec){for(T&x:vec)is>>x;return is;}
template<class T>inline void IN(T&t){cin>>t;}
template<class T,class... Ts>inline void IN(T&t,Ts&...ts){cin>>t;IN(ts...);}
template<class T>inline void OUT(T t){cout<<t<<"\n";}
template<class T,class... Ts>inline void OUT(T&t,Ts&... ts){cout<<t<<" ";OUT(ts...);}
template<typename T=int>vector<T>mv(size_t a){return vector<T>(a);}
template<typename T=int,typename... Ts>auto mv(size_t a,Ts... ts){return vector<decltype(mv<T>(ts...))>(a,mv<T>(ts...));}
template<typename T,typename V>typename enable_if<is_class<T>::value==0>::type FILL(T&t,const V&v){t=v;}
template<typename T,typename V>typename enable_if<is_class<T>::value!=0>::type FILL(T&t,const V&v){for(auto &e:t)FILL(e,v);}
constexpr long long INF = 1e18;

signed main(){
	int n;
	IN(n);
	auto a = mv(n);
	IN(a);
	map<int,int>mp;
	REP(i,n)mp[a[i]]++;
	OUT(mp.size());
}


Measured memory_bytes: 9916
#　169A　https://atcoder.jp/contests/abc169/tasks/abc169_a


# 1. 入力を受け取ること
# スペース区切りの入力を整数として受け取れる「2　5」　-> 「a=2, b=5」となる
a, b = map(int, input().split())

# print(a)
# print(b)
# 2. 受け取った結果を使って目的の計算をすること
answer = a * b

# 3. 出力すること
print(answer)

Measured memory_bytes: 9068
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep_s(i, s, n) for (int i = (int)(s); i < (int)(n); i++)
using ll = long long;
using vi = vector<int>;
using vll = vector<ll>;

#define MOD 1000000007

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

  vi a(n);
  rep(i, n) {
    cin >> a[i];
  }

  // 買うタイミング
  ll ans = 1000;
  ll kabu = 0;
  rep(now_day, n) { 
    if (now_day == n - 1) {
      // 最終日は売るのみ
      ans += a[now_day] * kabu;
      kabu = 0;
    } else {
      if (a[now_day + 1] > a[now_day]) {
        // 明日が上がるなら
        ll buy_num = ans / a[now_day];
        kabu += buy_num;
        ans -= a[now_day] * buy_num;
      } else if (a[now_day + 1] < a[now_day]) {
        ans += a[now_day] * kabu;
        kabu = 0;
      }
    }
  }

  cout << ans << endl;
}


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

int main()
{
    int n,ans,maxi=0;
    cin>>n;
    map<int,int>mp;

    for(int i=1;i<=n;i++)
    {
        int val=i;
        while(val!=0)
        {
            mp[i]++;
            if(val%2!=0) break;
            val/=2;
        }

        if(mp[i]>maxi)
        {
            maxi=mp[i];
            ans=i;
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
using namespace std;

int main(){
	int n,ans=0;
	cin>>n;
	int p[n];
	rep(i,n)cin>>p[i];
	sort(p,p+n);
	rep(i,n){
		if(i==n-1)ans+=p[i]/2;
		else ans+=p[i];
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 256
using AtCoderBeginnerContest147.Questions;
using AtCoderBeginnerContest147.Extensions;
using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace AtCoderBeginnerContest147.Questions
{
    public class QuestionA : AtCoderQuestionBase
    {
        public override IEnumerable<object> Solve(TextReader inputStream)
        {
            yield return inputStream.ReadIntArray().Sum() > 21 ? "bust" : "win";
        }
    }
}


namespace AtCoderBeginnerContest147
{
    class Program
    {
        static void Main(string[] args)
        {
            IAtCoderQuestion question = new QuestionA();    // 問題に合わせて書き換え
            var answers = question.Solve(Console.In);
            foreach (var answer in answers)
            {
                Console.WriteLine(answer);
            }
        }
    }
}

#region Base Classes

namespace AtCoderBeginnerContest147.Questions
{

    public interface IAtCoderQuestion
    {
        IEnumerable<object> Solve(string input);
        IEnumerable<object> Solve(TextReader inputStream);
    }

    public abstract class AtCoderQuestionBase : IAtCoderQuestion
    {
        public IEnumerable<object> Solve(string input)
        {
            var stream = new MemoryStream(Encoding.Unicode.GetBytes(input));
            var reader = new StreamReader(stream, Encoding.Unicode);

            return Solve(reader);
        }

        public abstract IEnumerable<object> Solve(TextReader inputStream);
    }

}

#endregion

#region Extensions

namespace AtCoderBeginnerContest147.Extensions
{
    internal static class TextReaderExtensions
    {
        internal static int ReadInt(this TextReader reader) => int.Parse(ReadString(reader));
        internal static long ReadLong(this TextReader reader) => long.Parse(ReadString(reader));
        internal static double ReadDouble(this TextReader reader) => double.Parse(ReadString(reader));
        internal static string ReadString(this TextReader reader) => reader.ReadLine();

        internal static int[] ReadIntArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(int.Parse).ToArray();
        internal static long[] ReadLongArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(long.Parse).ToArray();
        internal static double[] ReadDoubleArray(this TextReader reader, char separator = ' ') => ReadStringArray(reader, separator).Select(double.Parse).ToArray();
        internal static string[] ReadStringArray(this TextReader reader, char separator = ' ') => reader.ReadLine().Split(separator);
    }
}

#endregion

Measured memory_bytes: 13396
#pragma GCC optimize "trapv"
#include<iostream>
#include <bits/stdc++.h>
using namespace std;
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
#define ll long long
#define ull unsigned long long
#define ui unsigned int
#define vi vector<int>
#define vll vector<ll>
#define pb push_back
#define ld long double
#define mp make_pair
#define pii pair<int,int>
#define mod 1000000007
#define rep(i,n) for(int i=0;i<n;i++)
#define repp(i,a,n) for(int i=a;i<n;i++)
#define all(v) v.begin(),v.end()
#define input(arr,n) for(ll i1=0;i1<n;i1++ )cin>>arr[i1]
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update>//s.order_of_key(val) *s.find_by_order(ind)
int maxAbsValExpr(vector<int>& x, vector<int>& y) {
        int res = 0, n = x.size(), smallest, cur;
        for (int p : {1, -1}) {
            for (int q : {1, -1}) {
                smallest = p * x[0] + q * y[0] + 0;
                for (int i = 1; i < n; ++i) {
                    cur = p * x[i] + q * y[i] + i;
                    res = max(res, cur - smallest);
                    smallest = min(smallest, cur);
                }
            }
        }
        return res;
    }
int main()
{
    fio;
    int t=1;
    //cin>>t;
    while(t--)
    {
        ll n;
        cin>>n;
        //vector<pair<ll,ll> v;
        vector<ll> v1,v2,v3,v4;
        rep(i,n)
        {
            ll x,y;
            cin>>x>>y;
            v1.pb(x+y);
            v2.pb(x-y);
            v3.pb(y-x);
            v4.pb(-x-y);
        }
        sort(all(v1));
        sort(all(v2));
        sort(all(v3));
        sort(all(v4));
        auto it=v1.begin();
        auto it1=v1.end();
        it1--;
        //cout<<abs(*it - *it1)<<endl;
        ll a=abs(v1[0]-v1[n-1]);
        ll b=abs(v2[0]-v2[n-1]);
        ll c=abs(v3[0]-v3[n-1]);
        ll d=abs(v4[0]-v4[n-1]);
        cout<<max(a,max(b,max(c,d)))<<endl;
    }
}

Measured memory_bytes: 9720
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#include<iomanip>
#include<map>
#define int long long
using namespace std;

signed main() {
	int A,B,C;
	cin >> A >> B >> C;
	int r = 0;
	cout << max(B + C - A,r) << endl;
}

Measured memory_bytes: 256
//include
//------------------------------------------
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <queue>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>

using namespace std;

//conversion
//------------------------------------------
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();}

//math
//-------------------------------------------
template<class T> inline T sqr(T x) {return x*x;}

//typedef
//------------------------------------------
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

//container util
//------------------------------------------
#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(typeof((c).begin()) i=(c).begin(); i!=(c).end(); ++i)
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define SORT(c) sort((c).begin(),(c).end())

//repetition
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//constant
//--------------------------------------------
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

//debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int gcd(int a, int b){
   int tmp;
   while(a%b==0){
      tmp=a%b;
      a=b;
      b=tmp;
   }
}

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

bool prime_number(int n){
   if(n < 2){
      return false;
   }
   else if(n == 2){
      return true;
   }
   if(n % 2 == 0){
      return false;
   }
   for(int i=3;i<=n/i;i+=2){
      if(n % i == 0) return false;
      return true;
   }
}

int main(){
   int n,tmp,ans;
   VI s;
   while(1){
      cin >> n;
      if(n==0) break;
      REP(i,n){
         cin >> tmp;
         s.PB(tmp);
      }
      ans=(accumulate(ALL(s),0)-*(min_element(ALL(s)))-*(max_element(ALL(s))))/(n-2);
      cout << ans << endl;
      s.clear();
   }
}

Measured memory_bytes: 1216
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
using namespace std;

int n, ans;
int h[102];


int main(){

	cin >> n;
	for (int i = 0; i < n; i++)cin >> h[i];

	for (int i = 0; i < n; i++){
		while (h[i] != 0){
			for (int j = i+1; j < n; j++){
				if (h[j] != 0) h[j]--;
				else break;
			}
			h[i]--;
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

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

const int maxn = 2e5 + 10;
const int N = 1e5 + 1;

int a[maxn], par[maxn], fen[maxn];
int n;

int get(int x){
	int ret = 0;
	for (x += N; x; x -= x & -x)
		ret += fen[x];
	return ret;
}

void add(int x, int val){
	for (x += N; x < maxn; x += x & -x)
		fen[x] += val;
}

ll check(int x){
	for (int i = 1; i <= n; i++)
		par[i] = (a[i] < x ? 1 : -1);
	for (int i = 1; i <= n; i++)
		par[i] += par[i - 1];

	add(par[0], +1);
	ll ret = 0;
	for (int i = 1; i <= n; i++) {
		ret += get(par[i] - 1);
		add(par[i], +1);
	}
	// vitex
	for (int i = 0; i <= n; i++)
		add(par[i], -1);
	return ret;
}

int main(){
	ios_base::sync_with_stdio(false);
	cin >> n;
	for (int i = 1; i <= n; i++)
		cin >> a[i];
	ll tot = 1ll * n * (n + 1) / 2;
	int lo = 1, hi = 1000 * 1000 * 1000 + 1;
	while (hi - lo > 1){
		int mid = (lo + hi) / 2;
		if (check(mid) > tot / 2)
			hi = mid;
		else
			lo = mid;
	}
	cout << lo << endl;
}

Measured memory_bytes: 1664
N, x = map(int, input().split())
a = list(map(int, input().split()))
a.sort()
sum = 0
count = 0
while True:
  sum += a[0]
  if sum > x:
    break
  count += 1
  del a[0]
  if len(a) == 0:
    break
if x > sum:
  print(count-1)
else:
  print(count)

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

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
int A[202020];
ll S[202020];
ll L[202020][3];
ll R[202020];
void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	
	FOR(i,N) {
		cin>>A[i];
		S[i+1]=S[i]+A[i];
	}
	
	FOR(i,N) {
		if(A[i]==0) {
			L[i+1][0]=min(S[i+1],2+L[i][0]);
		}
		else {
			L[i+1][0]=min({S[i+1],L[i][0]+A[i]%2});
		}
		L[i+1][1]=min(L[i][0],L[i][1])+(1-A[i]%2);
	}
	R[N]=0;
	ll mi=min(L[N][0],L[N][1]);
	for(i=N-1;i>=0;i--) {
		if(A[i]==0) {
			R[i]=min(S[N]-S[i],2+R[i+1]);
		}
		else {
			R[i]=min({S[N]-S[i],(A[i]%2+R[i+1])});
		}
		mi=min({mi,R[i]+L[i][0],R[i]+L[i][1]});
	}
	cout<<mi<<endl;
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 8960
#include <iostream>
#include <string>
using namespace std;
int main(){
  char haiku[19];
  cin >> haiku;
  for (int i=0;i<19;i++){
    if (haiku[i]==','){
      haiku[i] = ' ';
    }
    cout << haiku[i];
  }
  cout << endl;
}

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

int main() {
    string s, t;
    cin >> s >> t;

    int count = 0;
    for (int i = 0; i < s.size(); i++) {
        if (s.at(i) != t.at(i)) {
            count++;
        }
    }

    cout << count << endl;
}

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

ll op(ll a, ll b) {
    return max(a, b);
}

ll e() {
    return (ll)(0);
}

int main(){
    int N; int K; cin >> N >> K;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    segtree<ll, op, e> seg(300010);

    rep(i, N){
        ll tmp = seg.prod(max(0, A[i]-K), min(300000, A[i]+K) + 1) + 1;
        seg.set(A[i], max(tmp, seg.get(A[i])));
    }
    ll ans = seg.prod(0, 300001);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 14860
/*
  Author: @yash_31
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <functional>
#define ll long long int
#define eb emplace_back
#define fatafat ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007
#define ft first
#define sd second
#define mkpr make_pair
#define deb(x) std::cout<<#x<<":"<<x<<endl;
#define whole(x) (x).begin(),(x).end()
#define revwhole(x) (x).rbegin(),(x).rend()
#define endl "\n"
#define fbo find_by_order
#define ook order_of_key
#define init0(x) memset(x,0,sizeof(x));

using namespace std; 
using namespace __gnu_pbds;
typedef tree<ll, null_type, less_equal<ll>, rb_tree_tag,tree_order_statistics_node_update> gharKaSet;
 
const int maxlimit=2e5+2;
const ll inf=1e18;
//TTBDC

ll dp[401][401];
ll pref[401];

ll solve(int L,int R){
  // cout<<"called for (L,R) = "<<L<<","<<R;
  if(dp[L][R]!=-1)return dp[L][R];
  else if(L==R)return dp[L][R] = 0;
  ll res = inf,cres;
  for(int i=0;i<R-L;i++){
    // if(i==0){
    //   cres = solve(i,i+1) + solve(i+2,R) + pref[R];
    // }
    // else if(i==R-2){
    //   cres = solve(L,i-1) + solve(i,i+1) + pref[R];
    // }
    // else {
    //   cres = solve(L,i-1) + solve(i,i+1) + solve(i+2,R) + pref[R];
    // }
    cres = solve(L,L+i) + solve(L+i+1,R) + pref[R];
    cres -= (L-1<0 ? 0 : pref[L-1]);
    res = min(res,cres);
  }
  return dp[L][R] = res;
}

int main()
{
  // fatafat
  int n;
  cin>>n;
  vector<int> v(n);
  for(int i=0;i<n;i++){
    cin>>v[i];
    if(i==0)pref[i]=v[i];
    else pref[i]=pref[i-1]+v[i];
  }
  for(int i=0;i<n;i++){for(int j=0;j<n;j++){dp[i][j]=-1;}}
  cout<<solve(0,n-1);
  return 0;
}

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

#define rep(i,x,y) for(ll i=(x);i<(y);i++)
#define rrep(i,x,y) for(ll i=(ll)(y)-1;i>=(x);i--)
#define all(x) (x).begin(),(x).end()
#ifdef LOCAL
#define dump(x)  cerr << #x << " = " << (x) << endl
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl
#define dassert(...) assert(__VA_ARGS__)
#else
#define dump(x)
#define debug(x)
#define dassert(...)
#endif
//#define int long long

typedef long long ll;
const ll MOD = 1e9 + 7;
const long double EPS = 1e-8;

void solve(long long K){
    vector<int> nums = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
    cout << nums[K-1] << endl;
}

signed main(){
    // ios_base::sync_with_stdio(false);
    // cin.tie(NULL);
    long long K;
    scanf("%lld",&K);
    solve(K);
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n,m;
    int e=0;
    scanf("%d %d",&n,&m);
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            e++;
        }
    }
    for(int i=0;i<m-1;i++){
        for(int j=i+1;j<m;j++){
            e++;
        }
    }
    printf("%d",e);
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define endl "\n"
#define vi vector <int>
#define vl vector <long long>
#define pb push_back
#define mk make_pair
#define pi pair <int,int>
#define pl pair <ll,ll>
#define rep(i,a,n) for(int i=a;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define rep_(i,a,n) for(int i=(n-1);i>=a;i--)
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int a,b;
    cin>>a>>b;
    for(int i=b-a+1;i<a+b;i++)
    	cout<<i<<" ";
}

Measured memory_bytes: 256
let last_i = ref 0

let parent i = int_of_float (floor (float_of_int i) /. 2.)

let left i = 2*i

let right i = 2*i + 1

let extract (t : int array) =
  let ret = t.(1) in
  t.(1) <- t.(!last_i);
  decr last_i;
  let rec max_heapify i =
    let l = left i in
    let r = right i in
    let m = if l <= !last_i && t.(l) > t.(i) then l else i in
    let m = if r <= !last_i && t.(r) > t.(m) then r else m in
    if i = m then ()
    else begin
      let tmp = t.(i) in t.(i) <- t.(m); t.(m) <- tmp;
      max_heapify m
    end in
  max_heapify 1;
  ret

let insert x (t : int array) =
  incr last_i;
  t.(!last_i) <- x;
  let rec doit i =
    if i <= 1 || t.(parent i) >= t.(i) then ()
    else begin
      let pi = parent i in
      let tmp = t.(i) in t.(i) <- t.(pi); t.(pi) <- tmp;
      doit pi
    end in
  doit !last_i

let split_on_char sep s =
  let open String in
  let r = ref [] in
  let j = ref (length s) in
  for i = length s - 1 downto 0 do
    if get s i = sep then begin
      r := sub s (i + 1) (!j - i - 1) :: !r;
      j := i
    end
  done;
  sub s 0 !j :: !r

let () =
  let t = Array.make 2000001 0 in
  while true do
    match read_line () |> split_on_char ' ' with
    | ["extract"] -> print_int (extract t); print_newline ()
    | ["insert"; n] -> insert (int_of_string n) t
    | _ -> exit 0
  done

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

using namespace std;
using ll = long long;
using edge = struct {int to; ll cost;};

#define mod 1000000007
#define REP(i, n) for (int i = 0; i < n; i++)
#define INF (1 << 29)


//long C(long n, long r);
//long long gcd(long long a, long long b);
//long long lcm(long long a, long long b);



void solve()
{
    int n;
    cin >> n;
    set<char> s;
    REP(i, n){
        char _s;
        cin >> _s;
        s.insert(_s);
    }
    if(s.size() == 3){
        cout << "Three" << "\n";
    }
    else if(s.size() == 4) {
        cout << "Four" << "\n";
    }
}

int main()
{
    solve();
    return 0;
}


Measured memory_bytes: 256
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<cstdio>
#include<unordered_map>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define str string
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
const ll Mod = 1000000007;
const ll gosenchou = 5000000000000000;
short gh[2][4] = { { 0,0,-1,1 },{ -1,1,0,0 } };
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to;
	ld cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll ari(ll a, ll b, ll c) {
	return (a + b)*c / 2;
}//等差数列の和
bool suf(ld a, ld b, ld c, ld d) {
	if (b <= c || d <= a) return 0;
	return 1;
}//[a,b),[c,d)
ll fact(ll x, ll k) {//最大値、個数
	ll sum = 1;
	for (int i = 0; i < k; i++)
		sum *= (x--);
	return sum;
}//階乗(正）
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res*x%p;
		x = x*x%p;
		n >>= 1;
	}
	return res;
}
#define int long long
const long long inf = 4523372036854775807;
const int iinf = 1500000000;
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int n, k;
H a[50];
vector<int>x, y;
signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++) {
		cin >> a[i].x >> a[i].y;
		for (int j = 0; j < x.size(); j++) {
			if (x[j] == a[i].x)
				goto stop;
		}
		x.push_back(a[i].x);
	stop:;
		for (int j = 0; j < y.size(); j++) {
			if (y[j] == a[i].y)
				goto loop;
		}
		y.push_back(a[i].y);
	loop:;
	}
	sort(x.begin(), x.end());
	sort(y.begin(), y.end());
	int ans = inf;
	for (int xi = 0; xi < x.size(); xi++) {
		for (int xj = xi; xj < x.size(); xj++) {
			for (int yi = 0; yi < y.size(); yi++) {
				for (int yj = yi; yj < y.size(); yj++) {
					int sum = 0;
					for (int z = 0; z < n; z++) {
						if (x[xi] <= a[z].x&&a[z].x <= x[xj] &&
							y[yi] <= a[z].y&&a[z].y <= y[yj]) {
							sum++;
						}
					}
					if (sum >= k) {
						ans = min(ans, (x[xj] - x[xi])*(y[yj] - y[yi]));
					}
				}
			}
		}
	}
	cout << ans << endl;
	getchar(); getchar();
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
//#define f(i,a,n) for(ll i=a;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll isPrime(int n) 
{ 
	// Corner cases 
	if (n <= 1) 
		return 1; 
	if (n <= 3) 
		return 2; 

	// This is checked so that we can skip 
	// middle five numbers in below loop 
	if (n % 2 == 0 || n % 3 == 0) 
		return 1; 

	for (int i = 5; i * i <= n; i = i + 6) 
		if (n % i == 0 || n % (i + 2) == 0) 
			return 1; 

	return 2; 
} 

ll fact(ll n){ll res = 1;for (ll i = 2; i <= n; i++)res = res * i,res%=1000000007; 
    return res; } 
 
 int gcd(int a, int b) 
{ 
    if (b == 0) 
        return a; 
    return gcd(b, a % b); 
} 
  
 
ll findlcm(ll arr[], int n) 
{ 
   
    ll ans = arr[0]; 
  
    
    for (int i = 1; i < n; i++) 
        ans = (((arr[i] * ans)) / 
                (gcd(arr[i], ans))); 
  
    return ans; 
} 
 
 
int main() 
{
    fast;
    ll t=1;
    //cin>>t;
    while(t--)
    {
    	string s;
      cin>>s;
      ll A[123]={0},k=0;
        for(ll i=0;i<s.size();i++)
      {
          A[s[i]]++;
        }   
      for(ll j=97;j<123;j++)
      {
        if(A[j]==0)
        {
          cout<<char(j);
          k=1;
          break;
        }
      }
      if(k==0)
        cout<<"None";
        
      
    } 
    return 0;
}



Measured memory_bytes: 3748
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {
	public static String str;

	public static void main(String[] args) throws IOException {
		BufferedReader f = new BufferedReader(new InputStreamReader(System.in));
		str = f.readLine();
		int res = 700;
		for (int i = 0; i < 3; i++) {
			if (str.charAt(i) == 'o') {
				res += 100;
			}
		}
		System.out.println(res);
	}
}

Measured memory_bytes: 20948
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using pint = pair<int,int>;
ll mod = 1000000007;
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,1,-1,1,-1};
void chmin(long long &a, long long b) { if (a > b) a = b; }
const long long INF = 1LL<<60;
int gcd(int a,int b){
    if(b == 0) return a;
    else return gcd(b,a%b);
}
int main() {
    ll n,ans = 	9223372036854775807;
    cin >> n;
    for (ll i = 1; i*i <= n; ++i) {
        if(n % i == 0){
            ll tmp = i,d1 = 0;
            while(tmp > 0){
                tmp /= 10;
                d1++;
            }
            ll tmp2 = n/i,d2 = 0;
            while(tmp2 > 0){
                tmp2 /= 10;
                d2++;
            }
            d1 = max(d1,d2);
            ans = min(ans,d1);
        }
    }
    cout << ans << endl;
    return 0;
}

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

const int MaxN = 100000 + 5;
const int INF = 0x7F7F7F7F;

int N, K;
int A[MaxN];

void init() {
    scanf("%d %d", &N, &K);
    for (int i = 1; i <= N; ++i)
        scanf("%d", &A[i]);
}

void solve() {
    int pos = N + 1, neg = 0;
    for (int i = 1; i <= N; ++i) {
        if (A[i] == 0) K--;
        else if (A[i] < 0) neg = max(neg, i);
        else pos = min(pos, i);
    }
    // printf("pos = %d, neg = %d\n", pos, neg);

    int ans = INF;
    if (neg >= K) ans = -A[neg - K + 1];
    if (N - pos + 1 >= K) ans = min(ans, A[pos + K - 1]);
    for (int i = pos; i <= N; ++i) {
        int j = K - (i - pos + 1);
        if (j <= 0 || j > neg) continue;
        int l = -A[neg - j + 1], r = A[i];

        ans = min(ans, min(l * 2 + r, l + r * 2));
    }
    cout << ans << endl;
}

int main() {
    init();
    solve();
    return 0;
}

Measured memory_bytes: 640
N, K = map(int, input().split())
p = list(map(int, input().split()))

for i in range(N):
    p[i] = (p[i]+1)/2

ans = sum(p[:K])
tmp = ans

for i in range(N-K):
    tmp += -p[i] + p[i+K]
    if tmp > ans:
        ans = tmp

print(ans)

Measured memory_bytes: 25060
r,c=map(int, input().split())

idxr = 0
R = []

while idxr <= r - 1:
    R.append(list(map(int,input().split())))
    idxr += 1

for rr in R:
    print(*rr, sum(rr))

RR = []

for idxc in range(c):
    T = 0
    for rrr in R:
        T += rrr[idxc]
    RR.append(T)

print(*RR,sum(RR))


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

using namespace std;

int main()
{
   int n;
   cin>>n;
   int a[n];
   for(int i=0;i<n;i++)
    cin>>a[i];
   int flag=1;
   for(int i=0;i<n;)
   {
       int j;
       for(j=i+1;j<n;j++)
       {
           if(a[j]>a[i])
           {
               i=j;
               break;
           }
           if(a[i]-a[j]>=2)
           {
               flag=0;
               break;
           }
       }
       if(j>=n)
        break;
       if(!flag)
        break;
   }
   if(flag)
    cout<<"Yes";
   else
    cout<<"No";
}


Measured memory_bytes: 640
from collections import defaultdict

N, M = map(int, input().split())
PYm = [0] * M

order = dict()
for i in range(M):
    key = input().strip()
    PYm[i] = list(map(int, key.split()))
    order[key] = i

d = defaultdict(list)
for i in range(M):
    d[PYm[i][0]].append(PYm[i][1])

res = dict()
for pi, ys in d.items():
    for i, y in enumerate(sorted(ys), 1):
        res["{} {}".format(pi, y)] = "{:0>6}{:0>6}".format(pi, i)

for key, _ in sorted(order.items(), key=lambda x: x[1]):
    print(res[key])


Measured memory_bytes: 85636
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n;
    cin >> n;
    vector<ll>a(n);
    REP(i,n)cin >> a[i];
    SORT(a);
    reverse(ALL(a));
    vector<ll>circle;
    ll answer = 0;
    
    int count=0;
    if(n == 2){
        cout << a[0] << endl;
        return 0;
    }
    REP(i,n){
        if(i == 0){
            answer+=a[0];
            count++;
            continue;
        }
        if(count+2 <= n-1){
            count += 2;
            answer+= a[i]*2;
        }else{
            count ++;
            answer+=a[i];
        }
        //cout << answer << endl;
        if(count == n-1)break;
    }
    cout << answer << endl;


    
    return 0;
}

Measured memory_bytes: 4848
#include <bits/stdc++.h>
using namespace std;
#define ll long long
const int MOD=1e9+7;
const long double Pi=acos(-1);
int main(){
  long long a;
  cin>>a;
  long double x=a;
  a*=100;
  a/=108;
  if(a*1.08==x && a*1.08<x+1){cout<<a<<endl;return 0;}
  if((a+1)*1.08>=x && (a+1)*1.08<x+1){cout<<a+1<<endl;return 0;}
  if((a-1)*1.08<=x && (a-1)*1.08>x+1){cout<<a-1<<endl;return 0;}
  cout<<":("<<endl;
} 

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long a,b,n,c,x,y,z;cin >> a >> b >> n;
  x = (a*(min(n,b-1)))/b;
  c = (n/b)*b-1;
  y = (a*c)/b-a*(c/b);
  z = (a*n)/b-a*(n/b);
  cout << max({x,y,z}) << "\n";
}

Measured memory_bytes: 3584
arr = $stdin.gets.chomp.split(" ")
arr.map! do |a_j|
a_j.to_i
end

if arr[0] ==7 and arr[1] == 5 and arr[2] == 5
  puts "YES"
elsif arr[0] == 5 and arr[1] == 7 and arr[2] == 5
  puts "YES"
elsif arr[0] == 5 and arr[1] == 5 and arr[2] == 7
  puts "YES"
else
  puts "NO"
end
  


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

int N;

int GetDigit(int num){
  return to_string(num).length();
}

void solve() {
  int ans = 0;
  for (int i = 1; i <= N; i++) {
    if (GetDigit(i) % 2 != 0) ans++;
  }
  printf("%d", ans);
}

int main() {  
  scanf("%d", &N);
  solve();
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#define st first
#define nd second
#define mp make_pair
#define pb push_back
#define mod 1000000007
#define N 1000005
using namespace std;

typedef long long ll;

ll n, ans;

int main() {
	// freopen("in.txt", "r", stdin);
	// freopen("out.txt", "w", stdout);
	scanf("%lld",&n);
	ans += (n/11)*2;
	n -= ans/2*11;
	if(!n)
		printf("%lld\n", ans);
	else if(n <= 6)
		printf("%lld\n", ans + 1);
	else
		printf("%lld\n", ans + 2);
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <cstdlib>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <bitset>
 
#define rep(i, n) for(int i = 0; i < (n); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define all(v) (v).begin(), (v).end()
#define rev(s) (s).rbegin(), (s).rend()
#define MP make_pair
#define X first
#define Y second
 
using namespace std;
 
typedef long long ll;
typedef pair<int, int> P;

void fin(){
	freopen("test.txt", "r", stdin);
}

int main(){
//	fin();
	while(1){
		int n, m, p;
		cin >> n >> m >> p;

		if(!n) break;
		vector<int> x(n);
		int sum = 0;
		rep(i, n){
			cin >> x[i];
			sum += x[i];
		}

		int res = 0;
		if(x[m-1]) res = sum*(100-p)/x[m-1];

		cout << res << endl;
	}

	return 0;
}

Measured memory_bytes: 1196
n = int(input())

ans = [0, 0, 0, 61, 230, 865, 3247, 12185, 45719, 171531, 643550, 2414454, 9058467, 33985227, 127504505, 478366600, 794717734, 733354121, 261943303, 776803305, 580025381, 51688048, 44657419, 737209731, 604119499, 159693437, 858533109, 639056669, 549054109, 996291083, 531294469, 23314687, 783022045, 855462856, 649970414, 68697295, 409213624, 604356692, 88638656, 978442997, 534833116, 763737161, 785892908, 123883652, 639213333, 181836645, 998121103, 124885216, 501575626, 39816123, 113468411, 799008836, 775465589, 256852905, 664630886, 971550783, 751629411, 51018086, 702530485, 725438992, 696683714, 792638194, 221791721, 149602322, 414054379, 986519078, 981760191, 305799096, 515140586, 406959393, 975058685, 245601370, 324759692, 673385295, 191483611, 570246669, 427196161, 781042769, 569725155, 842176273, 25328739, 847501730, 206282374, 353770801, 323137024, 371653459, 940737264, 123820509, 915711339, 847205021, 252858375, 718889563, 866398347, 738390145, 133009077, 333099663, 170591295, 329869205, 616680192, 597534442, 388130742]

print(ans[n])

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
//    return *(long long*)a - *(long long*)b;
}
//  qsort(A, b, sizeof(int), compare_int);

int main()
{
 
//  int a, b, c, d, e, X, Y;
  int a, b, c,  d, e,f;
  //  double  c;
//  long long  A[1000001]={};
  int  A[2000001]={};
  int  B[2000001]={};
  int  ans[100003]={};
  int  sum[100003]={};
  int  cnt_flag[100003]={};

  int  L[1003]={};


//  long long  a, b, c, d, X, Y;
//  long long   d, X, Y;
  long long JPY;
  double BTC;
  char s[200001]={};
  char t[200001]={};
  char u[200001]={};
//  int N, M;
//  int A[1000000001]={};
//  long long  C[101]={};
  int i,j,k,point;
  int point_A=0, point_B=0;
  int flag=0;
//  int flag[10000003]={};
  int tmp=0;
//  int min=1000000;
  int min=10;
  int len=0;
  int cnt=0;
  int cnt0=0;
  int cnt1=0;
  int num=0;
//  double ans=0.0;
//  long long ans=0;
  int max=0;
//  int sum=0;
//  char alp[26]={'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};

  //  a=0;
//  scanf("%lld %lld", &a, &b);
 
  scanf("%d%d%d", &a, &b,&c);
//  scanf("%s", &s);
//  scanf("%d", &max);

  if(a<=c &&c<=b)  printf("Yes\n");
  else if(b<=c &&c<=a)  printf("Yes\n");
  else   printf("No\n");
/*    
    */

//  printf("%s\n",s);
//    else  
  
return 0;
}


Measured memory_bytes: 256
x = int(input())
i = 0
while i**5 < x and (i + 1)**5 < x:
    i += 1
flag = 0
for j in range(x):
    if flag:
        break
    tmp1 = j ** 5
    if tmp1 < x:
        start, end = 0, x - tmp1
        while start <= end:
            middle = (start + end)//2
            if tmp1 + middle ** 5 > x:
                end = middle - 1
            elif tmp1 + middle ** 5 == x:
                flag = 1
                print(j, -middle)
                break
            else:
                start = middle + 1
    elif tmp1 == x:
        print(j, 0)
        break
    else:
        start, end = 0, tmp1 - x
        while start <= end:
            middle = (start + end) // 2
            if tmp1 - middle ** 5 > x:
                start = middle + 1
            elif tmp1 - middle ** 5 == x:
                flag = 1
                print(j, middle)
                break
            else:
                end = middle -1

Measured memory_bytes: 67832
#include<bits/stdc++.h>
using namespace std;
int dp[3010][6010];
int ans;
int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    int N, T;
    cin >> N >> T;
    vector<pair<int, int> > AB(N);
    for (int i = 0; i < N; ++i) {
        cin >> AB[i].first >> AB[i].second;
    }
    sort(AB.begin(), AB.end());
    for (int i = 0; i < N; ++i) {
        for (int j = 0; j < T+AB[i].first; ++j) {
            dp[i+1][j] = dp[i][j];
            if (j >= AB[i].first) {
                dp[i+1][j] = max(dp[i][j-AB[i].first] + AB[i].second, dp[i+1][j]);
                ans = max(ans, dp[i+1][j]);
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


Measured memory_bytes: 70784
#include<stdio.h>
#include<string.h>
int main(void){
    int h,w;
    char in[1000][30][6];
    char c;
    scanf("%d %d",&h,&w);
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            scanf("%s",in[i][j]);
        }
    }
    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            if(strcmp(in[i][j],"snuke")==0){
                c=(char)j+65;
                printf("%c%d\n",c,i+1);
                break;
            }
        }
    }
    return 0;
}


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

int main() {
    int n;
    cin >> n;
    vector<int> h(n+1);
    rep(i,n) cin >> h[i];
    h[n] = 1001001001;
    int ans = 0;
    int cur = 0;
    int ct = 0;
    while (cur < (n-1)) {
        rep(i,n-cur) {
            if (h[cur+i] >= h[cur+i+1]) {
                ct++;
                continue;
            }
            else {
                cur += i + 1;
                ans = max(ans,ct);
                ct = 0;
                break;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define fi first
#define se second
int main(){
    int n,ans=0;
    cin >> n;
    vector<int> v(n),c(n);
    for(int i=0;i < n;i++)
    {
        cin >> v.at(i);
    }
    for(int i=0;i < n;i++)
    {
        cin >> c.at(i);
    }
    for(int i=0;i < n;i++)
    {
        if(v.at(i)-c.at(i)>0){
            ans+=v.at(i)-c.at(i);
        }
    }

    cout << ans << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
const int N = 1e5 + 10;
int n, m, dg[N], par[N];
bool mark[N];
vector<int> gr[N], rg[N];
void dfs(int v, int prn = -1) {
	vector<int> vc;
	par[v] = prn;
	for (auto u : gr[v]) {
		dg[u]--;
		if (!dg[u])
			vc.push_back(u);
	}
	for (int i = 0; i < vc.size(); i++) {
		dfs(vc[i], v);
	}
	return;
}
int main() {
	cin >> n >> m;
	for (int i = 1; i < n + m; i++) {
		int x, y;
		cin >> x >> y;
		x--, y--;
		gr[x].push_back(y);
		rg[y].push_back(x);
		dg[y]++;
	}
	for (int i = 0; i < n; i++)
		if (dg[i] == 0) {
			dfs(i);
			break;
		}
	for (int i = 0; i < n; i++) 
		cout << par[i] + 1 << "\n";
	return 0;
}


Measured memory_bytes: 23424
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main(void){
	//FILE* fp_in = freopen("data.txt", "r", stdin);
	while(1){
		int N, Q;
		cin >> N >> Q;
		if( N == 0 && Q == 0 ) break;

		vector< string > vs;
		vector< int > st;
		vector< int > wc;
		for(int i = 0; i < N; i++) {
			string s;
			int j, k;
			cin >> s >> j >> k;
			vs.push_back( s );
			st.push_back( j );
			wc.push_back( k );
		}

		for(int i = 0; i < Q; i++) {
			int j;
			bool flg = false;
			cin >> j;
			for(int k = 0; k < N; k++) {
				if( j > wc[k] - st[k] && j <= wc[k] ) {
					cout << vs[k] << " " << j - wc[k] + st[k] << endl;
					flg = true;
					break;
				}
			}
			if( flg == false )
				cout << "Unknown" << endl;
		}

 	}

	//while(1){}
    return 0;
}

Measured memory_bytes: 1304
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <string>
#include <iomanip>
#include <math.h>
#include <utility>
#include <vector>
#include <map>
#include <cstdlib>
#define div1 1000000007
const long long INF = 1LL << 60;
using namespace std;
// a>b -> a==b;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
// a<b -> a==b;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
 
int main(void)
{
    int N, K;

    cin >> N >> K;

    N -= K;

    if(K == 1){
        cout << 0 << endl;
    }

    else{
        cout << N << endl;
    }

    return 0;
}

Measured memory_bytes: 256
import java.util.*;
import java.util.ArrayList;
import java.util.Collection;

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        int[] H = new int[N];
        int[] h = new int[N];
        long ans = 0;
        ArrayList<Integer> list = new ArrayList<Integer>();

        for(int i=0; i<N; i++){
            H[i] = sc.nextInt();
            list.add(H[i]);
        }
        Collections.sort(list);
        for(int i=0; i<N; i++){
            h[i] = list.get(i);
        }
        for(int i=0; i<N-K; i++){
            ans = ans + h[i];
        }
        System.out.println(ans);
    }
}

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

int main() {
	ios_base::sync_with_stdio( false );

	int N, M;
	cin >> N >> M;

	vector<pair<int64_t, int>> p( N );
	for( auto& v: p ) {
		cin >> v.first;
		cin >> v.second;
	}
	sort( p.begin(), p.end() );

	int64_t result = 0;
	int x = 0;
	for( int i = 0; i < N; ++i ) {
		x += p[i].second;

		if( x < M ) {
			result += p[i].first * p[i].second;
		}
		else {
			result += p[i].first * (p[i].second - (x-M));
			break;
		}
	}

	cout << result << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <cstdio>
#include <cmath>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <bitset>
#include <iterator>
#define loop(i, a, b) for(int i = (int)(a); i < (int)(b); i++)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define debug(x)  cout << #x << " = " << (x) << endl;

using namespace std;
using LL = long long;
using ULL = unsigned long long;

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

    for (auto x : a) {
        cout << x.second + 1 << " ";
    }
    cout << endl;
}


Measured memory_bytes: 1664
#include<iostream>
#include<cmath>
#include<vector>
//#include<string>

using namespace std;

void elem_swap(int &a,int &b){
  int temp=a;
  a=b;
  b=temp;
}

int insertionSort(vector<int> &vec,int size,int gap){
  int comp,j,count=0;
  for(int i=gap;i<size;i++){
    comp=vec.at(i);
    j=i-gap;
    while(j>=0&&vec.at(j)>comp){
      vec.at(j+gap)=vec.at(j);
      j=j-gap;
      count++;
    }
    vec.at(j+gap)=comp;
  }
  return count;
}

int shellSort(vector<int> &vec,int size){
  if(size==1) return 0;
  int count=0,loop=0;
  int sizeloop=size;
  vector<int> gap;
  while((sizeloop/2)>0){
    sizeloop/=2;
    loop++;
    gap.push_back(sizeloop);
  }
  for(int i=0;i<loop;i++){
    count+=insertionSort(vec,size,gap.at(i));
  }
  return count;
}

int main(void){
  int size;
  cin>>size;
  int sizeloop=size;
  vector<int> vec(size);
  for(int i=0;i<size;i++) cin>>vec.at(i);
  int count=0,loop=0;
  vector<int> gap1;
  while((sizeloop/2)>0){
    sizeloop=sizeloop/2;
    loop++;
    gap1.push_back(sizeloop);
  }
  if(loop==0){
    gap1.push_back(1);
    loop++;
  }
  count=shellSort(vec,size);
  cout<<loop<<endl;
  for(int i=0;i<loop-1;i++) cout<<gap1.at(i)<<" ";
  cout<<gap1.at(loop-1)<<endl;
  cout<<count<<endl;
  for(int i=0;i<size;i++) cout<<vec.at(i)<<endl;
  return 0;

}



Measured memory_bytes: 6704
#include <iostream>
#include <string>
using namespace std;
int main(){
	int n, k, size, ans = 0;
	while (true){
		int size = 0, ans = 0;
		string s;
		cin >> n;
		if(n==0)
		return 0;
		cin >> k;
		cin >> s;
		for (int i = 0; i < k; i++){
			if (s[i] == 'I'){
				size = 0;
				for (int j = 1; j < k; j += 2){
					if (s[i + j] == 'O' && s[i + j + 1] == 'I'){
						size++;
					}
					else{
						break;
					}
				}
				if (size >= n){
					ans += 1 + size - n;
				}
				i += size * 2;
			}
		}
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 2108
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

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

	vector<int> ans(n);
	for (int i = 0; i < n; i++){
		ans[a[i] - 1] = i + 1;
	}

	for (int i = 0; i < n; i++){
		if(i < n - 1) cout << ans[i] << " ";
		else cout << ans[i] << endl;
	}
	return 0;
}

Measured memory_bytes: 1664
#include<iostream>
using namespace std;
int main(){
	int a,b,c,p,q,r,s;
	while(cin>>a>>b>>c,a)if(c){
		for(r=1;r*r<=a;r++)if(a%r==0){
			p=a/r;
			for(s=c>0?-c:c;s<=(c>0?c:-c);s++)if(s&&c%s==0){
				q=c/s;
				if(p*s+q*r==b){
					cout<<p<<" "<<q<<" "<<r<<" "<<s<<endl; goto END;
				}
			}
		}
		cout<<"Impossible"<<endl; END:;
	}
	else{
		if(a!=1)cout<<a<<" "<<b<<" "<<1<<" "<<0<<endl;
		else cout<<1<<" "<<(b>0?b:0)<<" "<<1<<" "<<(b>0?0:b)<<endl;
	}
	return 0;
}

Measured memory_bytes: 880
using System;

public class Hello
{
    public static void Main()
    {
        var n = int.Parse(Console.ReadLine().Trim());
        string[] line = Console.ReadLine().Trim().Split(' ');
        var a = Array.ConvertAll(line, int.Parse);
        Console.WriteLine(check(a, n) ? "YES" : "NO");
    }
    static bool check(int[] a, int n)
    {
        var count = 0;
        for (int i = 0; i < n; i++)
        {
            if (a[i] != i + 1)
            {
                count++;
                if (count > 2) return false;
            }
        }
        return true;
    }
}


Measured memory_bytes: 13140
parseInt(x::String) = parse(Int, x)
parseInt(x::SubString{String}) = parse(Int, x)
parseInt(x::Char) = parse(Int, x)
parseInt(x::Float64) = trunc(Int, x)
parseFloat(x::String) = parse(Float64, x)
parseFloat(x::Int) = trunc(Float64, x)
parseFloat(x::SubString{String}) = parse(Float64, x)
parseFloat(x::Char) = parse(Float64, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)

function main()
    if parseInt(join(split(readline()))) % 4 == 0
        println("YES")
    else
        println("NO")
    end
end
main()

Measured memory_bytes: 113608