akhauriyash/Code-Regression huggingface dataset:
import java.util.Arrays;
import java.util.Scanner;


public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] a = new int[n];
		for (int i=0;i<n;i++) {
			a[i]=sc.nextInt();
		}
		Arrays.sort(a);

		if (n%2==0) {
			int from = 0;
			int to = n-1;
			long ans1 = 0;
			long lastNum = a[n/2];
			while(true) {
				ans1 += (lastNum-a[from]);
				lastNum= a[from];
				from++;
				if (to-from==0) break;
				ans1 += (a[to]-lastNum);
				lastNum= a[to];
				to--;
				if (to-from==0) break;
			}
			from = 0;
			to = n-1;
			long ans2 = 0;
			lastNum = a[n/2-1];
			while(true) {
				ans2 += (a[to]-lastNum);
				lastNum= a[to];
				to--;
				if (to-from==0) break;
				ans2 += (lastNum-a[from]);
				lastNum= a[from];
				from++;
				if (to-from==0) break;
			}
			System.out.println(Math.max(ans1, ans2));
		}
		else {
			int from = 0;
			int to = n-1;
			long ans1 = 0;
			long lastNum = a[n/2];
			while(true) {
				ans1 +=  (lastNum-a[from]);
				lastNum= a[from];
				from++;
				if (to-from==0) break;
				ans1 += (a[to]-lastNum);
				lastNum= a[to];
				to--;
				if (to-from==0) break;
			}
			from = 0;
			to = n-1;
			long ans2 = 0;
			lastNum = a[n/2];

			
			while(true) {
				ans2 +=  (a[to]-lastNum);
				lastNum= a[to];

				to--;
				
				if (to-from==0) break;
				ans2 +=  (lastNum-a[from]);
				lastNum= a[from];

				from++;
				if (to-from==0) break;
			}
			System.out.println(Math.max(ans1, ans2));
		}

	}


}


Measured memory_bytes: 52000
#include<bits/stdc++.h>
#define fr(i,a,n) for(ll i=a;i<n;i++)
#define YES cout<<"YES"<<endl
#define all(v) v.begin(),v.end()
#define NO cout<<"NO"<<endl
#define pb(x) emplace_back(x)
#define fastio std::ios_base:: sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define vi vector<ll>
#define mi map<ll,ll>
#define pi pair<ll,ll>
#define what(x) cout<<#x<<" ="<<x<<endl;
using namespace std;
using ll =long long;

ll dp[3005][30005];

int main()
{
    string a,b;
    cin>>a>>b;
    ll n=a.size();
    ll m=b.size();

    fr(i,0,n)
    {
        fr(j,0,m)
        {

            if(a[i]==b[j])dp[i+1][j+1]=1+dp[i][j];
            else dp[i+1][j+1]=max(dp[i][j+1],dp[i+1][j]);
        }
    }

    ll i=n,j=m;
    string ans="";
    while(i!=0 && j!=0 )
    {
        if(a[i-1]==b[j-1])
        {
            ans+=a[i-1];
            i--;j--;
        }
        else
        {
            if(dp[i-1][j]>=dp[i][j-1])i--;
            else j--;
        }
    }

    for(ll i=ans.size()-1;i>=0;i--)
        cout<<ans[i];
    cout<<endl;








}




























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

using namespace std;

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

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;

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

#define MP make_pair
#define SZ(a) int((a).size())
#define EACH(i,c) for(auto i: c)
#define SORT(c) sort((c).begin(),(c).end())

#define ALL(a)  (a).begin(),(a).end()
#define RALL(a) (a).rbegin(), (a).rend()

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

	int N;
	cin >> N;
	VI A(N);
	REP(i, N) cin >> A[i];

	SORT(A);
	int x = A.back(), y = A.front();
	cerr << x << endl;
	EACH(a, A){
		if(abs(x / 2. - a) < abs(x / 2. - y)) y = a;
	}

	cout << x << " " << y << endl;


	return 0;
}

Measured memory_bytes: 640
#include <cassert>
#include <algorithm>
#include <array>
#include <bitset>
#include <cctype>
#include <cstdint>
#include <cmath>
#include <complex>
#include <chrono>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
 
#define rep(i, a, b) for (long long i = (a); (i) < (b); (i)++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}
 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (std::size_t  i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
template<typename T1,typename T2>
inline bool chmax(T1& a,T2 b){return a<b && (a=b,true);}
 
template<typename T1,typename T2>
inline bool chmin(T1& a,T2 b){return a>b && (a=b,true);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;
  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0))return 0;
  long long x = 1;
  while (b > 0) {
    if (b & 1)x = (mod!=-1)?(x * a) % mod:x*a;
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}

// const long long MOD = 998244353;
const long long MOD = 1e9 + 7;

using ll = long long;
using P=std::pair<long long,long long>;

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

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

  ll n;
  std::cin>>n;

  std::string s;
  std::cin>>s;

  std::vector<ll> a(n);
  rep(i,0,n)a[i]=s[i]-'0';

  std::vector<ll> pow(n+1,0);

  ll two=2;
  while(two<=n){
    for(ll i=two;i<=n;i+=two){
      pow[i]++;
    }
    two*=2;
  }

  ll comb=0;
  ll mod=a[0]%2;

  rep(i,1,n){
    comb+=pow[n-i];
    comb-=pow[i];
    if(comb==0){
      mod+=a[i];
      mod%=2;
    }
  }

  if(mod%2){
    std::cout<<1<<"\n";
    return 0;
  }

  if(std::any_of(all(a),[](ll n){return n==2;})){
    std::cout<<0<<"\n";
    return 0;
  }

  comb=0;
  ll xo=(a[0]==1);
  rep(i,1,n){
    comb+=pow[n-i];
    comb-=pow[i];
    if(comb==0){
      xo^=(a[i]==1);
    }
  }

  if(xo==0)std::cout<<0<<"\n";
  else std::cout<<2<<"\n";

  return 0;
}



Measured memory_bytes: 17052
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0,i##_len=(n);i<i##_len;++i)
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
#define All(x) (x).begin(),(x).end()
using namespace std;
typedef long long ll;

int main(){
    int N,M;cin>>N>>M;
    vector<pair<int,int>> v(N);
    REP(i,N) cin>>v[i].first>>v[i].second;
    sort(All(v));
    int j=0,ans=0;
    priority_queue<int> que;
    REP(i,M+1){
        while(j<N&&v[j].first<=i){
            que.push(v[j].second);
            j++;
        }
        if(que.empty()) continue;
        ans+=que.top();que.pop();
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 1660
#include<bits/stdc++.h>
using namespace std;
int valu[5005],weight[5005],nitem,w,dp[2000005];
int knap(int w)
{
	for(int i=1;i<=nitem;i++)
	{
		for(int j=w;j>=weight[i-1];j--)
		{
			dp[j]=max(dp[j-weight[i-1]]+valu[i-1],dp[j]);
		}
	}
	return dp[w];
}
int main()
{
	//freopen("input.txt","r",stdin);
	//freopen("output.txt","w",stdout);
	cin>>nitem>>w;
	memset(dp,0,sizeof(dp));
	for(int i=0;i<nitem;i++)cin>>valu[i]>>weight[i];
	cout<<knap(w)<<endl;
}



Measured memory_bytes: 10916
import numpy as np

N = int(input())
A = np.array(list(int(i) for i in input().split()))

X = np.zeros(N)

X[0] = int(np.sum(A[0::2]) - np.sum(A[1::2]))

for i in range(N-1):
    j = i + 1
    X[j] = int(2*A[j-1] - X[j-1])
for i in range(N):
    print(int(X[i]),end=' ')

Measured memory_bytes: 23124
{-# LANGUAGE BangPatterns #-}
{-# LANGUAGE ScopedTypeVariables #-}
import qualified Data.ByteString.Lazy.Char8 as B
import Data.Maybe
import qualified Data.IntMap as IM
import qualified Data.IntSet as IS
import Debug.Trace

solve :: Int -> Int -> [Int] -> [(Int,Int)] -> Int
solve n m ps xys = answer where

  grp0 = foldr (uncurry uftMerge) IM.empty xys

  im1 :: IM.IntMap (IS.IntSet, IS.IntSet)
--  grp0xxx = (trace ("grp0" ++ show grp0) grp0)
  grp0xxx = grp0
  (im1, _) = foldr op (IM.empty, grp0xxx) (zip [1..] ps) where
    op :: (Int, Int) -> (IM.IntMap (IS.IntSet, IS.IntSet), IM.IntMap Int)
       -> (IM.IntMap (IS.IntSet, IS.IntSet), IM.IntMap Int)
    op (n, p) (jm, grp) = (jm', grp') where
      (r, grp') = getRoot n grp
      jm' = IM.alter f r jm where
        f Nothing         = Just (IS.singleton n, IS.singleton p)
        f (Just (cn, cp)) = Just (IS.insert n cn, IS.insert p cp)

  answer = foldr op 0 im1 where
    op (cn, cp) sum = sum + IS.size (IS.intersection cn cp)

uftMerge :: Int -> Int -> IM.IntMap Int -> IM.IntMap Int
uftMerge x y im | rx == ry = im
                | otherwise = IM.insert rx ry im2
  where (rx, im1) = getRoot x im
        (ry, im2) = getRoot y im1

getRoot :: Int -> IM.IntMap Int -> (Int, IM.IntMap Int)
getRoot x im = case IM.lookup x im of
                 Nothing -> (x, im)
                 Just y -> let (root, im1) = getRoot y im
                           in (root, IM.adjust (const root) x im1)

readBInt :: B.ByteString -> Int
readBInt = fst . fromJust . B.readInt

tmain :: B.ByteString -> Int
tmain cont =
  let remLines0 = map B.words (B.lines cont)
      [bs_n,bs_m]:remLines1 = remLines0
      n = readBInt bs_n
      m = readBInt bs_m
      line2:remLines2 = remLines1
      ps = map readBInt line2
      xys = map (\[x1,x2] -> (readBInt x1,readBInt x2)) remLines2
  in solve n m ps xys

outAnswer :: Int -> IO ()
outAnswer = putStrLn . show

main :: IO ()
main = outAnswer . tmain =<< B.getContents


Measured memory_bytes: 231036
import heapq
N,M=map(int,input().split())
W=[list(map(int,input().split())) for _ in range(N)]
a=[[i,0] for i in range(1,M+2)]
W.extend(a)
W.sort()
q=[]
ans=0
for i,j in W:
    if i>M+1:
        break
    if j!=0:
        heapq.heappush(q,-j)
    else:
        heapq.heappush(q,-j)
        ans-=heapq.heappop(q)
print(ans)

Measured memory_bytes: 42596
n = int(input())
an = list(map(int, input().split()))

total = 0
for i in range(len(an)-1):
    if an[i+1] - an[i] < 0:
        add = (an[i+1] - an[i]) * -1
        an[i+1] += add
        total += add
print(total)

Measured memory_bytes: 32112
#include<iostream>
#include<cstdlib>
#include<cstring>
#include<stack>
#include<queue>
#include<algorithm>
#include<vector>
#include<math.h>
#include<bitset>
#include<iomanip>
using namespace std;

typedef stack<int> IntStack;
typedef queue<int> IntQueue;

const double pi = 3.141592653589793;


//文字0~9をint型0~9に変換
int char_to_int(char c)
{
	if (c == '0') return 0;
	if (c == '1') return 1;
	if (c == '2') return 2;
	if (c == '3') return 3;
	if (c == '4') return 4;
	if (c == '5') return 5;
	if (c == '6') return 6;
	if (c == '7') return 7;
	if (c == '8') return 8;
	if (c == '9') return 9;
	else return -1;
}
//a^b mod MODを計算
long long int ModPower(long long int a, long long int b, long long int MOD)
{
	if (b == 0) return 1;
	else if (b % 2 == 0)
	{
		long long int d = ModPower(a, b / 2, MOD);
		return (d*d) % MOD;
	}
	else
	{
		return (a*ModPower(a, b - 1, MOD)) % MOD;
	}
}
//nCr mod MODを計算
long long int ModCombi(long long int n, long long int r, long long int MOD)
{
	if (n == 0 || r == 0) return 1;

	long long int Kn=1, Kr=1, Knr=1;

	long long int temp = 1;
	for (long long int i = 1; i <= n; i++)
	{
		temp *= i;
		temp %= MOD;
		if (i == n) Kn = temp;
		if (i == r) Kr = temp;
		if (i == n - r) Knr = temp;
	}

	long long int x = ModPower(Kr, MOD - 2, MOD);
	long long int y = ModPower(Knr, MOD - 2, MOD);

	long long int ans;
	ans = Kn * x;
	ans %= MOD;
	ans *= y;
	ans %= MOD;

	return ans;
}


/*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*//*ここまでテンプレ*/



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

	pair<pair<string, int>, int> p[105];
	for (int i = 0; i < N; i++)
	{
		cin >> p[i].first.first >> p[i].first.second;
		p[i].first.second *= -1;
		p[i].second = i + 1;
	}

	sort(p, p + N);

	for (int i = 0; i < N; i++)
	{
		cout << p[i].second << endl;
	}

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll=long long;
using vi = vector<int>;
using vl = vector<ll>;
using Graph = vector<vi>;
using P = pair<int,int>;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
    string s;
    cin >> s;
    int n = s.size();
    string a="",b="";
    rep(i,n){
        if(i<=n/2) a += s[i];
        if(i>=n/2) b += s[i];
    }
    string c = "",d = "";
    for(int i=0;i<(n-1)/2;i++) c += s[i];
    for(int i=(n+3)/2-1;i<n;i++) d += s[i];
    reverse(b.begin(),b.end());
    bool ok = true;
    if(a==b){
        rep(i,c.size()){
            if(c[i] != c[c.size()-1-i]){
                ok = false;
                break;
            }
        }
        rep(i,d.size()){
            if(d[i]!=d[d.size()-1-i]){
                ok = false;
                break;
            }
        }
    }else {
        ok = false;
    }
    cout << (ok? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _LIBCPP_DEBUG 0
using namespace std;
typedef long long int ll;
ll MOD = 1e9 + 7;
int INF = 1 << 20;


int main(void){

    long double a,b,c; cin>>a>>b>>c;
    if(a+b+2*sqrt(a)*sqrt(b) < c){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

long long GCD(long long a, long long b){long long q;while(b){q=a%b;a=b;b=q;}return a;}

signed main(){
	ll N;
	cin >> N;
	ll A;
	cin >> A;
	FOR(i,0,N-1){
		ll B;
		cin >> B;
		A = GCD(A,B);
	}
	cout << A << endl;
}

Measured memory_bytes: 256
n = gets.to_i
an = gets.split(' ').map{|a|a.to_i}


if an.include? 0
  sum=0
  an.map{|a|a.abs}.each{|a|sum+=a}
  p sum
  exit
end

if an.size == 2
  max = an.map{|a|a.abs}.max
  min = an.map{|a|a.abs}.min
  p max - min
  exit
end

a = an.select{|a| a < 0}
if a.size%2 == 1
  min = an.map{|a|a.abs}.min
  sum=0
  an.map{|a|a.abs}.each{|a|sum+=a}
  p sum - min*2
  exit
else
  sum=0
  an.map{|a|a.abs}.each{|a|sum+=a}
  p sum
  
end

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

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

using namespace std;
using lint=long long;

int main(){
	lint n;
	int a0,m; scanf("%lld%d%d",&n,&a0,&m);
	n--;

	vector<lint> sum(m+1);
	vector<int> p(m+1,-1);
	sum[0]=a0;
	p[a0]=0;
	int a=a0,t=0,per;
	while(1){
		if(t==n){
			printf("%d\n",sum[t]);
			return 0;
		}

		t++;
		a=lint(a)*a%m;
		sum[t]=sum[t-1]+a;

		if(p[a]==-1){
			p[a]=t;
		}
		else{
			per=t-p[a];
			break;
		}
	}

	lint ans=sum[p[a]];
	n-=p[a];
	ans+=n/per*(sum[p[a]+per]-sum[p[a]]);
	n%=per;
	ans+=sum[p[a]+n]-sum[p[a]];
	printf("%lld\n",ans);

	return 0;
}


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

using namespace std;

/*  テンプレここから */
typedef long long ll;

#define rep(i, n) for(int i = 0; i < n; i++)
#define repi(i, start, end) for(int i = start; i < end; i++)
#define all(x) (x).begin(), (x).end()
#define INF (1e9)
#define add_mod(a, b, x) ( (ll)(a) + (ll)(b) ) % (ll)(x)
#define mul_mod(a, b, x) ( ((ll)(a) % (ll)(x)) * ((ll)(b) % (ll)(x)) ) % (ll)(x)
#define out(x) cout << (x) << endl;
#define outyes(bool_val) cout << (bool_val ? "yes" : "no") << endl;
#define outYes(bool_val) cout << (bool_val ? "Yes" : "No") << endl;
#define outYES(bool_val) cout << (bool_val ? "YES" : "NO") << endl;
#define outPossible(bool_val) cout << (bool_val ? "Possible" : "Impossible") << endl;
#define outPOSSIBLE(bool_val) cout << (bool_val ? "POSSIBLE" : "IMPOSSIBLE") << endl;

ll sub_mod(ll a, ll b, ll x){
    ll tmp = (a - b) % x;
    if(tmp < 0) tmp += x;
    return tmp;
}
ll gcd(ll a, ll b){
    if(b == 0) return a;
    else return gcd(b, a % b);
}

int dx[] = {0, 1, 0, -1};
int dy[] = {-1, 0, 1, 0};
/*  テンプレここまで */

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

    int w, h, n;
    cin >> w >> h >> n;

    int left_x = 0, right_x = w, up_y = 0, down_y = h;
    rep(i, n){
        int x, y, a;
        cin >> x >> y >> a;

        if(a == 1){
            left_x = max(left_x, x);
        }else if(a == 2){
            right_x = min(right_x, x);
        }else if(a == 3){
            up_y = max(up_y, y);
        }else{
            down_y = min(down_y, y);
        }
    }

    cout << max(0, right_x - left_x) * max(0, down_y - up_y) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <random>
#include <chrono>
 
using namespace std;
using namespace __gnu_pbds;
 
#define endl '\n'
 
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<int, null_type,less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
template<typename T>
static T randint(T lo, T hi){
	return uniform_int_distribution<T>(lo, hi)(rng);
}




int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);
 
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);

	int n, m;
	cin >> n >> m;

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

	vector<int> d(n + 1, -1);
	d[1] = 0;

	queue<int> Q;
	Q.push(1);

	int cnt = 0;

	while(!Q.empty()){
		int u = Q.front();Q.pop();
		cnt++;
		for(auto &v : g[u])
			if(d[v] == -1){
				d[v] = d[u] + 1;
				Q.push(v);
			}
	}

	if(cnt == n){
		cout << "Yes" << endl;
		vector<int> ans(n + 1);
		for(int u = 2; u <= n; u++){
			int mx = n + 5, v = -1;
			for(auto &x : g[u]){
				if(d[x] < mx){
					mx = d[x];
					v = x;
				}
			}
			cout << v << endl;
		}
	}
	else{
		cout << "No" << endl;
	}

	return 0;	
}

Measured memory_bytes: 10704
#include <stdio.h>

int main(void){
	int n;
	scanf("%d", &n);
	int k=n;
	int s[15];
	int i=0;
	int sum=0;
	while(k > 0){
		sum += k%10;
		k /= 10;
		i++;
	}
	if(n % sum ==0)printf("Yes\n");
	else printf("No\n");
	return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using Graph = vector<vector<int>>;
const int INF = 1e9 + 1;
const ll LLINF = 1e18;

int main() {
    int N;
    cin >> N;
    bool ans = true;
    int nowt = 0, nowx = 0, nowy = 0;
    for(int i = 0; i < N; ++i) {
        int t, x, y;
        cin >> t >> x >> y;
        if(!ans)
            continue;
        int dt = t - nowt, dx = abs(x - nowx), dy = abs(y - nowy);
        if(dt < dx + dy)
            ans = false;
        else if((dt - dx - dy) % 2)
            ans = false;
        nowt = t, nowx = x, nowy = y;
    }
    cout << (ans ? "Yes" : "No") << endl;
    return 0;
}


Measured memory_bytes: 256
use std::cmp::max;
use std::collections::BTreeMap;

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: i64 = sc.read();
    let x: i64 = sc.read();
    let d: i64 = sc.read();
    if d == 0 {
        if x == 0 {
            println!("1");
        } else {
            println!("{}", n + 1);
        }
        return;
    }

    let (x, d) = if d < 0 { (-x, -d) } else { (x, d) };
    assert!(d >= 0);

    let mut map = BTreeMap::new();
    map.insert(0, vec![(0, 0)]);

    for k in 1..(n + 1) {
        let header = k * x;
        let key = header.abs() % d;
        let from = (k - 1) * k / 2;
        let to = k * n - (k + 1) * k / 2;
        let offset = header / d;

        map.entry(key)
            .or_insert_with(Vec::new)
            .push((from + offset, to + offset));
    }

    let mut ans = 0;
    for (_, mut segments) in map.into_iter() {
        segments.sort();
        let (mut min_x, mut max_x) = segments[0];
        for &(from, to) in segments.iter().skip(1) {
            if max_x < from {
                ans += max_x - min_x + 1;
                min_x = from;
                max_x = to;
            } else {
                max_x = max(max_x, to);
            }
        }
        ans += max_x - min_x + 1;
    }

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

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    ll N;
    cin >> N;
    vector<ll> A(N);
    bool ok = true;
    rep(i, N) {
        cin >> A[i];
        if (A[i] % 2) {
            ok = false;
        }
    }
    if (ok) {
        cout << "second" << '\n';
    } else {
        cout << "first" << '\n';
    }
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


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

int main(void)
{
    int k,a,b,ans=0;

    scanf("%d",&k);
    scanf("%d %d",&a,&b);

    for (int i = a; i <= b; i++)
    {
        if(i%k==0)
        {
            ans=1;
            break;
        }
    }

    if(ans==1) printf("OK");
    else printf("NG");

    return 0;
}

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

#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL);
#define SUBL freopen("/home/ajinkya/Desktop/input.txt","r",stdin); freopen("/home/ajinkya/Desktop/output.txt","w",stdout); 
#define ll long long
#define ull unsigned long long
#define FI(i,a,n) for(int i=a; i<=n; i++)
#define RFI(i,n,a) for(int i=n; i>=a; i--)
#define FLL(i,a,n) for(ll i=a; i<=n; i++)
#define RFLL(i,n,a) for(ll i=n; i>=a; i--)
#define vi vector<int>
#define vll vector<ll>
#define all(v) v.begin(),v.end()
#define pll pair<ll,ll>
#define pi pair<int, int>
#define GCD(a,b) __gcd(a,b)
#define MP make_pair
#define PB push_back
#define PF push_front
#define LB lower_bound
#define UB upper_bound
#define debug(x) cout << x << endl
#define MOD 1000000007
#define INF LLONG_MAX
#define PI 3.14159265359
using namespace std;




int main()
{
    fastio 
    // SUBL
  	ll n;
  	cin >> n;
  	map<string, ll> m;
  	string s;
  	for(ll i=0; i<n; i++)
  	{
  		cin >> s;
  		sort(all(s));
  		m[s]++;
  	}
  	ll ans=0;
  	for(auto &i:m)
  	{
  		ans += (i.second*(i.second-1))/2;
  	}
  	cout << ans;
    return 0;
}         	

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

int main(void)
{
    IOS
    int a, b;
    cin >> a >> b;
    int s = a+b;
    if (s >= 10) cout << "error" << endl;
    else cout << s << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
	int a[32] = {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};
	int k;
	cin >> k;
	cout << a[k-1] << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String a = sc.next();
        String b = sc.next();

        int n = Integer.parseInt(a + b);
        int sr = (int)Math.sqrt(n);
        if (sr * sr == n) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
s=list(input())
s_reverse=list(reversed(s))
N=len(s)
s2=s[0:(N-1)//2]
s2_reverse=list(reversed(s2))
s3=s[((N+3)-1)//2:N+1]
s3_reverse=list(reversed(s3))
if s==s_reverse and s2==s2_reverse and s3==s3_reverse:
  print("Yes")
else:
  print("No")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define forn(i, n) for (int i = 0; i < int(n); i++)
#define forna(i,a,n) for(int i =a; i < n; i++)
#define fornd(i,a) for (int i = (a)-1; i >= 0; i--)
#define pb push
#define fi first
#define se second
#define __ ios_base::sync_with_stdio(0);cin.tie(0);
typedef long long int unsigned lliu;
typedef long long int lli;
typedef pair<lli,lli> pi;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pi> vpi;

int main(){
    int q, t, f;
    char a;
    bool reversa=false;
    string s, frente="";
    cin>>s>>q;
    forn(i, q){
        cin>>t;
        if(t==1)
            reversa=!reversa;
        else{
            cin>>f>>a;
            if(f==1){
                if(reversa)
                    s.push_back(a);
                else
                    frente.push_back(a);
            } else{
                if(reversa)
                    frente.push_back(a);
                else
                    s.push_back(a);
            }
        }
    }
    if(reversa){
        fornd(i, s.size())
            cout<<s[i];
        forn(i, frente.size())
            cout<<frente[i];
    }else{
        fornd(i, frente.size())
            cout<<frente[i];
        forn(i, s.size())
            cout<<s[i];
    }
    cout<<endl;
}

Measured memory_bytes: 960
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define All(a) a.begin(),a.end()
#define INF 1000000007
const int MOD = 1000000007;
//accumulate(vec.begin(), vec.end(), 0)

int gcd(int x,int y){
  if(x%y==0) return y;
  else return gcd(y,x%y);
}

int main(){
  int n;
  cin >>n;
  cout<< (n+2-1)/2 <<endl;
}


Measured memory_bytes: 256
<?php
list($lowest,$highest,$num)=explode(" ", trim(fgets(STDIN)));


if($highest-$lowest+1<=$num*2){

    for ($k=$lowest;$k<=$highest;$k++){
        echo $k."\n";
    }
    
}else{

    for($i=0;$i<$num;$i++){
        echo $lowest+$i."\n";
    }
    
    for($j=$num;$j>0;$j--){
        echo $highest-($j-1)."\n";
    }
}
?>

Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,n100,n10;
  cin >> n ;
  n100 = n/100;
  n10 = n/10;
  n = n % 10;
  if(n == 2 || n == 4 || n == 5 || n == 7 || n == 9)
  {
    cout << "hon" << endl;
  }
  else if(n == 3){
    cout  << "bon" << endl;
  }
  else{
    cout << "pon" << endl;
  }
}



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

#define int long long
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<(int)(n);++i)
#define rep1(i,n) for(int i=1;i<=(int)(n);++i)
#define rep11(i,n) for(int i=1;i<(int)(n);++i)
#define repo(i,o,n) for(int i=o;i<(int)(n);++i)
#define repm(i,n) for(int i=(int)(n)-1;i>=0;--i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define sperase(v,n) (v).erase(remove(all(v), n), (v).end())
#define vdelete(v) (v).erase(unique(all(v)), (v).end())
#define pb(n) push_back(n)
#define mp make_pair
#define MOD 1000000007
#define INF 9223372036854775807

int n,x,l,ans,sum;

signed main() {
    cin >> n >> x;
    rep(i,n) {
        cin >> l;
        sum += l;
        if (sum <= x) ans++;
    }
    cout << ++ans << endl;
}




Measured memory_bytes: 256
#include<cstdio>

using namespace std;

int main()
{
	long long k, a, b;
	long long i;
	long long bis = 1, yen = 0;
	long div, q, r;

	scanf("%lld %lld %lld", &k, &a, &b);

	if (a >= b - 2)
	{
		printf("%lld\n", k + 1);
	}

	else if(k + 1 < a)
	{
		printf("%lld\n", k + 1);
	}

	else
	{
		div = (k - (a - 1));

		printf("%lld\n", a + div / 2 * (b - a) + div % 2);
	}

	return 0;
}

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

#define rep2(x,fr,to) for(int (x)=(fr);(x)<(to);(x)++)
#define rep(x,to) for(int (x)=0;(x)<(to);(x)++)
#define repr(x,fr,to) for(int (x)=(fr);(x)>=(to);(x)--)
#define all(c) (c).begin(),(c).end()
#define sz(v) (int)(v).size()

using namespace std;
typedef long long ll; typedef vector<int> VI; typedef pair<int,int> pii;
const int MD = (int)1e9 + 7; typedef vector<ll> VL;
void dbg(){ cerr << "\n"; }  template <class T, class ...T2>
void dbg(const T& fst, const T2&...rst){ cerr << fst << ": "; dbg(rst...); }



int main()
{
	
	cin.tie(0); ios_base::sync_with_stdio(false);
	int k, x;
	cin >>k >>x;
	
	rep2(i, max(-1000000, x+1-k) ,min(1000001, x+k)){
		cout << i <<" ";
	}
	cout <<"\n";
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int

signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int l;cin >> l;
    vi in(l);
    FOR(i,l)cin >> in[i];

    int prev1 = 0, prev2 = 0;
    int eo = 0;
    vi odd, even;
    vi comb;
    even.pb(prev1);
    odd.pb(prev2);
    comb.pb(prev2);
    int sum = 0;
    FOR(i, l){
        int a1 = 0, a2 = 0;
        sum += in[i];
        if(in[i] == 0){
            a1 = 2;
            a2 = 1;
        }else if(in[i] & 1){
            a1 = 1;
        }else{
            a2 = 1;
        }
        prev1 = min(prev1 + a1, sum);
        prev2 = min(prev2 + a2, sum);
//        cout << prev1 << " " << prev2 << endl;
        eo = min(eo + a2, prev1);

        comb.pb(eo);
        even.pb(prev1);
        odd.pb(prev2);
    }
    sum = 0, prev1 = 0, prev2= 0;
    int ans = INT_MAX;
    for(int i = l-1; i >= 0; i--){
        int a1 = 0, a2 = 0;
        sum += in[i];
        if(in[i] == 0){
            a1 = 2;
            a2 = 1;
        }else if(in[i] & 1){
            a1 = 1;
        }else{
            a2 = 1;
        }
        ans = min(ans, comb[i+1] + prev1);
        ans = min(ans, odd[i+1] + prev1);
        ans = min(ans, even[i+1] + prev2);
        ans = min(ans, even[i+1] + prev1);
        ans = min(ans, odd[i+1] + prev2);
        prev1 = min(prev1 + a1, sum);
        prev2 = min(prev2 + a2, sum);
    }
    ans = min(ans, prev1);
    ans = min(ans, prev2);

    cout << ans;
}




Measured memory_bytes: 6740
#include <iostream>
#include <vector>
#include <algorithm>
#include <queue>
#include <string>
#include <functional>
#include <set>
#define DB cerr<<"D"<<endl
#define pb push_back
using namespace std; using ll=long long; using ld=long double; const int INF=1e9; const ll LINF=1e18; const double dINF = 1e18; const ld ldINF = 1e18; const double EPS = 1e-6;
template<typename T, typename U, typename O> void caut(T a, U b, O c){cout<<"("<<a<<","<<b<<","<<c<<") ";} template<typename T, typename U> void caut(T a, U b){cout<<"("<<a<<","<<b<<") ";} template<typename T> void caut(T a){cout<<"("<<a<<") ";}
using P=pair<double,int>;
const ll M = 998244353;
void add(ll& x, ll y) {x+=y; x%=M;}
void chmax(ll& x, ll y) {if (x<y) x=y;}

int main() {
  int n,a,b;cin>>n>>a>>b;
  int p[n];
  for(int i=0;i<n;i++) cin>>p[i];
  int f=0,g=0,h=0;
  for(int i=0;i<n;i++) {
    if (p[i] <= a) f++;
    else if (a+1 <= p[i] && p[i] <= b) g++;
    else h++;
  }
  cout<<min({f,g,h})<<endl;
}

Measured memory_bytes: 256
X = int(input())

kosuu = X // 100

amari = X - (kosuu*100)

kosuu5 = amari // 5

amari5 = amari - kosuu5 * 5

if amari5 != 0:
    kosuu5 += 1

if kosuu5 < kosuu + 1:
    print(1)
else:
    print(0)

Measured memory_bytes: 3060
#include <iostream>
#include <math.h> /* pow */
#include <vector> /* vector */
#include <algorithm> /* sort */

using namespace std;
int main(){
    long N,K;
    cin >> N >> K;

    long *logs = new long[N];
    long all_len=0;
    for (long i = 0; i < N; ++i) {
        long buf;
        cin >> buf;
        logs[i] = buf;
        all_len += buf;
    }

    long *div_is = new long[N];
    long div_i_cnt = K;

    double unit = (double) all_len / (K+N);
    for(int i = 0; i < N; ++i)  {
        long div_i = ((long) (logs[i] / unit)) - 1;
        if (div_i < 0) div_i = 0;
        div_is[i] = div_i;
        div_i_cnt -= div_i;
    }

    vector<double> divd_len;
    for(int i = 0; i < N; ++i)  {
        long bo = div_is[i] + 1;
        double len = (double) logs[i] / bo;
        divd_len.push_back(len);
    }

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

//    for (int i = 0; i < N; ++i) {
//        cout << divd_len[i] << endl;
//    }

    long ans = ceil(divd_len[N-div_i_cnt-1]);
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8380
#include <bits/stdc++.h>
#define ll long long
using namespace std;
ll bs[20];
ll D, f0[20], f[20];
ll a[20], an, ans;
void dfs(int x, ll v, ll c)
{
	if(x == an)
	{
		ans += (v == D) * c;
		return;
	}
	if(abs(v - D) > a[x] * 20)return;
	for(int i = 0; i < 20; i ++)
	{
		int cnt;
		if(!x) cnt = f0[i];
		else cnt = f[i];
		if(!a[x])cnt = i < 10;
		if(!cnt) continue;
		dfs(x + 1, v + (i - 10) * a[x], c * cnt);
	}
}
void solve(int n)
{
	an = 0;
	for(int i = 0; i < n; i ++)
	{
		if(i > n - i - 1)break;
		a[an ++] = bs[n - i - 1] - bs[i];
	}
	dfs(0, 0, 1);
}
int main()
{
	for(int i = 0; i <= 9; i ++)
		for(int j = 0; j <= 9; j ++)
			f[i - j + 10] ++;
 
	for(int i = 0; i <= 9; i ++)
		for(int j = 1; j <= 9; j ++)
			f0[i - j + 10] ++;
 
	bs[0] = 1;
	for(int i = 1; i < 19; i ++)
        bs[i] = bs[i - 1] * 10;
	cin >> D;
	for(int i = 1; i <= 19; i ++)
		solve(i);
	cout<<ans<<endl;
	return 0;
}

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

int main() {
	int n, m; cin >> n >> m;
	string s[n]; for(int i = 0; i < n; ++i) cin >> s[i];
	mf_graph<int> mf(n * m + 2);
	int st = n * m, gt = n * m + 1;
	for(int i = 0; i < n; ++i) {
		for(int j = 0; j < m; ++j) {
			if(s[i][j] == '#') continue;
			if((i + j) % 2 == 0) {
				mf.add_edge(st, i * m + j, 1);
				int f = i * m + j;
				if(i - 1 >= 0 and s[i - 1][j] == '.') {
					int t = (i - 1) * m + j;
					mf.add_edge(f, t, 1);
				}
				if(i + 1 < n and s[i + 1][j] == '.') {
					int t = (i + 1) * m + j;
					mf.add_edge(f, t, 1);
				}
				if(j - 1 >= 0 and s[i][j - 1] == '.') {
					int t = i * m + (j - 1);
					mf.add_edge(f, t, 1);
				}
				if(j + 1 >= 0 and s[i][j + 1] == '.') {
					int t = i * m + (j + 1);
					mf.add_edge(f, t, 1);
				}
			} else {
				mf.add_edge(i * m + j, gt, 1);
			}
		}
	}
	cout << mf.flow(st, gt) << '\n';
	auto v = mf.edges();
	for(auto& e : v) {
		if(e.from == st or e.to == gt or e.flow == 0) continue;
		int fy = e.from / m, fx = e.from % m;
		int gy = e.to / m, gx = e.to % m;
		if(fy + 1 == gy) {
			s[fy][fx] = 'v';
			s[gy][gx] = '^';
		}
		if(fy - 1 == gy) {
			s[fy][fx] = '^';
			s[gy][gx] = 'v';
		}
		if(fx + 1 == gx) {
			s[fy][fx] = '>';
			s[gy][gx] = '<';
		}
		if(fx - 1 == gx) {
			s[fy][fx] = '<';
			s[gy][gx] = '>';
		}
	}
	for(int i = 0; i < n; ++i) {
		cout << s[i] << '\n';
	}
	return 0;
}


Measured memory_bytes: 5572
#include<stdio.h>

int main(){
  int n;
  scanf("%d", &n);
  int i;
  int Debt = 100000, r;
  for(i=0; i<n; i++){
    Debt *= 1.05;
    if(Debt % 1000 != 0){
      r = Debt % 1000;
      Debt += 1000-r;
    }
  }
  printf("%d\n", Debt);
  return 0;
}

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

int main(){
  int n;
  cin>>n;
  vector<vector<int>> a(n,vector<int>(n-1));
  rep(i,n){
    rep(j,n-1){
      cin>>a[i][j];
      a[i][j]--;
    }
    reverse(a[i].begin(),a[i].end());
  }
  vector<P> q;
  auto check=[&](int i){
    if (a[i].size()==0) return;
    int j=a[i].back();
    if (a[j].size()==0) return;
    if (a[j].back()==i) {
      P p(i,j);
      if (p.second <p.first) swap(p.first,p.second);
      q.push_back(p);
    }
  };
  rep(i,n) {
    check(i);
  }
  int day=0;
  while (q.size()>0){
    day++;
    sort(q.begin(),q.end());
    q.erase(unique(q.begin(),q.end()),q.end());
    vector<P> prevQ;
    swap(prevQ,q);
    for (P p:prevQ){
      int i=p.first,j=p.second;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (P p:prevQ){
      int i=p.first,j=p.second;
      check(i);
      check(j);
    }
  }
  rep(i,n){
    if (a[i].size() !=0){
      puts("-1");
      return 0;
    }
  }
  cout<<day<<endl;
  return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>

using namespace std;

bool ok(string & s)
{
    int begin = 0, end = s.length() - 1;
    while (begin < end) {
        if (s[begin] != s[end]) return false;
        begin++;
        end--;
    }
    return true;
}

int main()
{
    string s;
    while (cin >> s) {
        if (ok(s)) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>

using namespace std;

int main(){
  
  string str;
  cin >> str;
  
  int cnt = 0;
  int ret = 0;
  for(int i=0; i<3; i++){
    char c = str[i];
    if(c == 'S'){
      ret = max(ret, cnt);
      cnt = 0;
    }
    else{
      cnt++;
      ret = max(ret, cnt);
    }
  }
  
  cout << ret << endl;
  
  return 0;
}

Measured memory_bytes: 3164
#include <iostream>

using namespace std;

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

    int ans10000 = -1, ans5000 = -1, ans1000 = -1;
    for (int i = 0; i <= n; ++i) {
        for (int j = 0; i + j <= n; ++j) {
            int k = n - i - j;
            int total = 10000*i + 5000*j + 1000*k;
            if (total == y) {
                ans10000 = i;
                ans5000 = j;
                ans1000 = k;
            }
        }
    }
    cout << ans10000 << " " << ans5000 << " " << ans1000 << endl;
}

Measured memory_bytes: 256
/************************************/
/* NoobM							*/
/* File Name : at.cpp				*/
/* Date : 21.06.2020 18:00:49 +06	*/
/************************************/

#include <bits/stdc++.h>

#define rr(i, b)    for (int i = 0; i < int(b); i++)
#define vi(n, a) vector <int> a(n); rr(i, n) cin >> a[i]
#define pvec(a) rr(i, a.size()) cout << a[i] << " "; cout << endl
#define bug(x) cout << #x << " " << x << endl
#define ll long long
#define vii vector <int>

using namespace std;

void solve() {
	int n;
	cin >> n;
	
	int x = 0;
	
	vi(n, a);
	
	for(int j : a) {
		x ^= j;
	}
	
	for(int j : a) {
		
		int l = x^j;
		cout << l << " ";
	}
	
	cout << endl;
	
}
 
int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
	
	int t = 1;
	//cin >> t;
	
	while (t--) {
		solve();
	}
    return 0;
}


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

using namespace std;

#define For(i , a , b) for (int i = (a) ; i <= (b) ; i++)
#define Rep(i , n) for (int i = 0 ; i < (n) ; i++)
#define Ford(i , a , b) for (int i = (a) ; i >= (b) ; i--)

const int maxn = 200000 + 1912;
int n , a[maxn];
long long totalSum = 0;
long long sum[maxn];

void ReadData() {
	scanf("%d" , &n);
	For(i , 1 , n) scanf("%d" , &a[i]);
	For(i , 1 , n) a[i + n] = a[i];
	For(i , 1 , n << 1) sum[i] = sum[i - 1] + a[i];
}

long long GetSum(const int l , const int r) {
	return sum[r] - sum[l - 1];
}

bool check(long long limit) {
	int ptr1 = 1 , ptr2 = 2;
	For(i , 1 , n - 1) {
		int last = i + n - 1;
		while (ptr1 < last - 1 && GetSum(i , ptr1) < limit) ptr1++;
		ptr2 = max(ptr2 , ptr1 + 1);
		while (ptr2 < last && GetSum(ptr1 + 1, ptr2) < limit) ptr2++;
		
		if ((ptr2 <= last) &&
		 (GetSum(i , ptr1) >= limit && GetSum(ptr1 + 1 , ptr2) >= limit && GetSum(ptr2 + 1 , last) >= limit) ) return true;
	}
	return false;
}

void Process() {
	long long res = 0;
	long long l = 1 , r = 1000LL * 1000 * 1000 * 1000 * 1000 + 1912;
	while (l <= r) {
		long long mid = (l + r) >> 1;
		if (check(mid)) {
			res = mid;
			l = mid + 1;
		} else r = mid - 1;
	}
	cout << res << endl;
}

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

   // freopen("./baumkuchen.inp" , "r" , stdin);	
   	ReadData();
   	Process();

    return 0;	
}

Measured memory_bytes: 3576
<?php
fscanf(STDIN, '%d', $n);
$line = trim(fgets(STDIN));
$arr = explode(' ', $line);

$times=0;
$flag=1;

while($flag) {
  $flag=0;
  for($j=$n-1;$j>=1;$j--) {
    if($arr[$j]<$arr[$j-1]){
      $tmp = $arr[$j];
      $arr[$j] = $arr[$j-1];
      $arr[$j-1] = $tmp;
      $times++;
      $flag=1;
    }

  }

}
echo implode(' ',$arr),PHP_EOL,$times;
?>



Measured memory_bytes: 9256
import java.util.Scanner;
 
 
public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        if(b < a){
            int w = a;
            a = b;
            b = w;       
        }
        if(c < b){
            int x = b;
            b = c; 
            c = x;      
        }
        if(b < a){
            int y = a;
            a = b;
            b = y;     
        }
        
        System.out.println(a+" "+b+" "+c);
    }
}


Measured memory_bytes: 26404
#include <stdio.h>
#include <stdlib.h>
#define MN 200000
typedef long long LL;
int n,a[MN+5];
LL ans=0;
void res(int x){printf("%d\n",x);exit(0);}
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	for(int i=n;i>=1;i--){
		if(a[i+1]-a[i]>1)res(-1);
		if(a[i]>=i)res(-1);
		if(a[i]!=a[i+1]-1)ans+=a[i];
	}
	printf("%lld\n",ans);
}

Measured memory_bytes: 896
#include <algorithm>
#include <cmath>
#include <iostream>
#include <limits>
#include <numeric>
#include <string>
#include <vector>
using namespace std;
int main() {
  string s, t;
  cin >> s >> t;
  int cunt = 0;
  for (int i = 0; i < s.length(); i++) {
    if (s[i] != t[i]) {
      cunt++;
    }
  }
  cout << cunt << endl;
}

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

using namespace std;
typedef long long ll;

#define  input freopen("in.txt","r",stdin)
#define  output freopen("out.txt","w",stdout)

int main()
{
	//input;
	//output;
	int n, k;
	cin >> n >> k;

	ll x = n/k;
	ll ans = x*x*x;

	if(!(k&1)) 
	{
		ll y = ((2*n)/k) - (n/k);
		ans+=(y*y*y);
	}
	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define what_is(x) cerr<<#x <<" is "<<x<<endl;
#define ll long long 
#define gcd(a,b) __gcd(a,b)
#define pi 2*acos(0.0)
//use emplace_back() instead of push_back()
template<typename T>
void print(T t)
{
	for(const auto& e:t)cout<<e<<" ";
	cout<<endl;
}
int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);	
	ll n,m;
	cin>>n;
	ll a[n];
	for(ll i=0;i<n;i++)
	{
		cin>>a[i];
	}
	map<ll,ll>b;
	for(ll i=0;i<n;i++)
	{
		b[a[i]]++;		
	}
	for(ll i=1;i<=n;i++)
	{
		cout<<b[i]<<"\n";
	}
	return 0;
}

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

const int N=2e5+5;
int n,l[N],r[N],k[N];
vector<int>event[N];

int calc(vector<int>&a)
{
    int res=0;
    priority_queue<int,vector<int>,greater<int>>pq;
    for(int i=1;i<=a.size();i++) event[i].clear();
    for(auto&id:a)
    {
        res+=min(l[id],r[id]);
        k[id]=min(k[id],(int)a.size());
        event[k[id]].push_back(abs(l[id]-r[id]));
    }
    for(int i=1;i<=a.size();i++)
    {
        for(auto&x:event[i]) pq.push(x);
        while(pq.size()>i) pq.pop();
    }
    while(!pq.empty())
    {
        res+=pq.top();
        pq.pop();
    }
    return res;
}

void solve()
{
    cin>>n;
    vector<int>a,b;
    for(int i=1;i<=n;i++)
    {
        cin>>k[i]>>l[i]>>r[i];
        if(l[i]>r[i]) a.push_back(i);
        else b.push_back(i);
    }
    int res=calc(a);
    for(int i=1;i<=n;i++) k[i]=n-k[i];
    cout<<res+calc(b)<<'\n';
}

main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    int t;
    cin>>t;
    while(t--)
        solve();
}


Measured memory_bytes: 19248