akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <numeric>
#include <climits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <stack>
#include <queue>
#include <deque>
#include <algorithm>
#include <functional>
#include <utility>
#include <cctype>
#include <iterator>
////////////////////////////////////////////////
#define REP(i, n) for (int i = 0; i < (int)n; i++)
#define FOR(i, m, n) for (int i = (int)m; i < (int)n; i++)
#define REPvec(itr, mp) for (auto itr = mp.begin(); itr != mp.end(); itr++)
#define REPe(e, mp) for (auto& e : mp)
#define all(x) x.begin(), x.end()
#define MOD 1000000007  // 1e9+7
using namespace std;
using ll = long long int;
using vecint = vector<int>;
using vecll = vector<ll>;
using vec2int = vector<vector<int>>;
using P = pair<int, int>;
////////////////////////////////////////////////
////////////////////////////////////////////////
int main() {
  ////////////////////////////////////////////////
  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);
  ////////////////////////////////////////////////
  int n, m;
  cin >> n >> m;
  vecint cnt(n, 0);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    --a;
    --b;
    cnt[a]++;
    cnt[b]++;
  }
  REPe(e, cnt) {
    if (e % 2 != 0) {
      cout << "NO" << endl;
      return 0;
    }
  }
  cout << "YES" << endl;
}


Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int a, b;
  cin >> a >> b;
  if (a < b){
    rep(i, b){
      cout << a;
    }
  }else{
    rep(i, a){
      cout << b;
    }
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 888
#include <iostream>
#include <string>
#include <cmath>
using namespace std;

int main() {
	string s, t;
	long re = 0;
	cin >> s >> t;
	if (s != t) {
		for (long i = 0; i < (long)s.length(); i++) {
			if (s[i] != t[i])
				re++;
		}
	}
	cout << re << endl;
	return 0;
}

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

using namespace std;
using ll = long long;
using ull = unsigned long long;
using P = pair<int,int>;
#define rep(i,n) for(ll i = 0;i < (ll)n;i++)
#define ALL(x) (x).begin(),(x).end()
#define MOD 1000000007



int main(){
  
  int n,k;
  cin >> n >> k;
  if(k > (n-1)*(n-2)/2){
    cout << -1 << endl;
    return 0;
  }
  ll m = n-1;
  m += (n-1)*(n-2)/2-k;
  cout << m << endl;
  m -= (n-1);
  rep(i,n-1)cout << 1 << " " << i+2 << endl;
  for(int i = 2;i <= n;i++){
    for(int j = i+1;j <= n;j++){
      if(m == 0)break;
      cout << i << " " << j << endl;
      m--;
    }
  }





  


  return 0;
}

Measured memory_bytes: 256
// AOJ 2194

#include <iostream>
#include <vector>

using namespace std;

int main(void)
{
	int n, a, b, c, x;

	while (cin >> n >> a >> b >> c >> x){
		if (n == 0) break;
		vector <int> reel(n);
		for (int i = 0; i < n; i++){
			cin >> reel[i];
		}

		int now = 0, old = x, next = 0;
		if (reel[0] == x){
			now++;
		}
		if (n == now){
			cout << 0 << endl;
			goto END;
		}
		for (int i = 1; i <= 10000; i++){
			next = (a * old + b) % c;
			if (reel[now] == next){
				now++;
				if (now == n){
					cout << i << endl;
					goto END;
				}
			}
			old = next;
		}
		cout << "-1" << endl;
		
		END:;
	}

	return 0;
}

Measured memory_bytes: 1196
//#define __USE_MINGW_ANSI_STDIO 0
#include <iostream>
#include <bits/stdc++.h>
using namespace std;

#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<"\t"<<#z<<" :: "<<z<<endl;

#define boost ios::sync_with_stdio(0); cin.tie(0)

#define fi first
#define se second

typedef long long ll;
typedef double ld;
typedef pair<int, int> pii;

const int N = 1e6 + 5;

/***************************************************************************/

string to_binary(int n) {
	string str;
	while(n) {
		str += (n & 1) ? '1' : '0';
		n >>= 1;
	}
	reverse(str.begin(), str.end());
	return str;
}

vector<pair<pii, int> > edges;
void addEdge(int a, int b, int c) {
	edges.push_back(make_pair(pii(a, b), c));
}

int main() {

	boost;
	int L; cin>>L;
	string sl = to_binary(L);

	int N = sl.length();
	for(int i=1; i<N; i++) {
		addEdge(i, i+1, 0);
		addEdge(i, i+1, 1 << (N-i-1));
	}

	for(int i=1; i<N; i++) {
		if(sl[i] == '1') {
			addEdge(1, i+1, stoi(sl.substr(0, i) + '0', nullptr, 2) << (N-i-1));
		}
	}

	cout<<N<<" "<<edges.size()<<"\n";
	for(auto it : edges) {
		cout<<it.fi.fi<<" "<<it.fi.se<<" "<<it.se<<"\n";
	}
	
	return 0;
}

Measured memory_bytes: 256
use proconio::input;
#[allow(unused_imports)]
use proconio::marker::*;

fn main() {
    input! {
        n: Chars,
    }
    let mut ans = "No";
    for c in n {
        if c == '7' {
            ans = "Yes";
            break;
        }
    }
    println!("{}", ans);
}


Measured memory_bytes: 2180
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <set>
#include <cmath>
#include <map>
#include <fstream>
#include <iterator>
// #include "prettyprint.hpp"

using namespace std;
using ll = long long;

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

    for (int i = 0; i < N; i++)
    {
        cin >> p[i];
    }
    int cnt = 0;
    for (int i = 2; i < N; i++)
    {

        if ((p[i - 2] < p[i - 1] && p[i - 1] < p[i]) || (p[i - 2] > p[i - 1] && p[i - 1] > p[i]))
        {
            cnt++;
        }
    }
    cout << cnt << endl;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int[] numbers = new int[n];
        for (int i = 0; i < n; i++) {
            numbers[i] = sc.nextInt();
        }
        
        int[] gcdLeft = new int[n];
        int[] gcdRight = new int[n];
        gcdLeft[0] = numbers[0];
        gcdRight[n - 1] = numbers[n - 1];
        
        for (int i = 1; i < n; i++) {
            gcdLeft[i] = gcd(gcdLeft[i - 1], numbers[i]);
        }
        for (int i = n - 2; i >= 0; i--) {
            gcdRight[i] = gcd(gcdRight[i + 1], numbers[i]);
        }
        
        int max = Math.max(gcdLeft[n - 2], gcdRight[1]);
        for (int i = 1; i < n - 1; i++) {
            max = Math.max(max, gcd(gcdLeft[i - 1], gcdRight[i + 1]));
        }
        
        System.out.println(max);
    }
    
    public static int gcd(int a, int b) {
        if (b == 0) return a;
        
        return gcd(b, a % b);
    }
}


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

int main() {
	int n;
	cin >> n;
	vector<double> V1(n);
	for (int i = 0; i < n; i++) {
		cin >> V1[i];
	}
	vector<double> V2(n);
	for (int i = 0; i < n; i++) {
		cin >> V2[i];
	}

	double sum;
	for (int p = 1; p <= 3; p++) {
		sum = 0;
		for (int j = 0; j < n; j++) {
			sum += pow(fabs(V1[j] - V2[j]), p);
		}
		printf("%.10f\n", pow(sum, 1.0 / p));
	}

	sum = 0;
	for (int j = 0; j < n; j++)
		if (sum < fabs(V1[j] - V2[j]))
			sum = fabs(V1[j] - V2[j]);
	printf("%.10f\n", sum);
}



Measured memory_bytes: 3416
from collections import Counter
n=int(input())
a=[]
for i in range(n):
  a.append(int(input()))
a_counter=Counter(a)
a_max=max(a)
b=a_counter[a_max]
for i in range(n):
  if a[i]!=a_max:
    print(a_max)
  else:
    if b>=2:
      print(a_max)
    else:
      c=a[0:i]+a[i+1:]
      print(max(c))

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

using namespace std;

int main() {
	ios::sync_with_stdio(false);
	int n, k, q;
	cin>>n>>k>>q;
	vector < int > used(n, k - q);
	for (int i = 0; i < q; i++) {
		cin>>k;
		used[k - 1]++;
	}
	for (int i = 0; i < n; i++)
		cout<<((used[i] > 0) ? "Yes\n" : "No\n");
}


Measured memory_bytes: 1024
#include <iostream>

int main(){
	
	//double loop
	//?????????????????§??????
	for(int i = 1; i <= 9; ++i){
		for(int j = 1; j <= 9; ++j){
			std::cout << i << "x" << j << "=" << i*j << std::endl;
		}
	}
	return 0;
}

Measured memory_bytes: 1112
/*Alohomora*/
#include<bits/stdc++.h>
#define ll         long long
#define fl(i,n)    for(i=0;i<n;i++)
#define fld(i,a,b) for(i=a;i>b;i--)
#define fli(i,a,n) for(i=a;i<n;i++)
#define inp(i,a,n) for(i=0;i<n;i++) {cin>>a[i];}
#define op(i,a,n)  for(i=0;i<n;i++) {cout<<a[i]<<" ";}
#define pb         push_back
#define mp         make_pair
#define mod1       100000000000007
#define speedup    ios_base::sync_with_stdio(false),cin.tie(0)
using namespace std;
ll fact(ll n){ if(n==0){return 1;}return (n*fact(n-1))%mod1;}
ll power(ll x, ll y)
{
    ll temp;
    if( y == 0)
        return 1;
    temp = power(x, y/2);
    if (y%2 == 0)
        return temp*temp;
    else
        return x*temp*temp;
}
ll gcd(ll a,ll b){if(b==0){return a;}gcd(b,a%b);}
ll a[2000000];
void sieve(){ll i,j;fli(i,2,1000001){if(a[i]==0){for(j=i*i;j<1000001;j+=i){a[j]=1;}}}}
map<ll,vector<ll> >m1;
vector<ll>v1;
bool compar(const pair<ll,ll> &a, const pair<ll,ll> &b) 
{ 
    return (a.second < b.second);
} 
ll level[1000000];
vector<ll>root;
set<ll>s1;
void factorise(long long n) 
{ 
    while (!(n%2)) 
    { 
        n >>= 1; 
        s1.insert(2);
    } 
    for (long long i=3; i<=sqrt(n); i+=2) 
    { 
        while (n%i==0) 
        { 
        	s1.insert(i);
            n=n/i; 
        } 
    } 
  	if (n>2) 
  	{
       s1.insert(n);
	}
} 

void comp()
{
	ll a,b,c,d,e;
	cin>>a>>b;
	c=a+b;
	d=a-b;
	e=a*b;
	c=max(c,d);
	c=max(c,e);
	cout<<c<<"\n";
}	 
int main()
{
	speedup;
	ll i=0,t;
	ll n;
	//cin>>t;
	t=1;
	while(t--)
	{
	 comp();
	}
}

Measured memory_bytes: 2304
#include <stdio.h>
#define DIV ((long)1e9 + 7)

int main(void) {
	long n, k;
	scanf("%ld%ld", &n, &k);
	long count = 0;
	for (long i = k; i <= n + 1; i++)
		/*
		 * long min, max;
		 * min = k * (0 + (k - 1)) / 2;
		 * max = k * (n + (n - k + 1)) / 2;
		 * count += max - min + 1;
		 * count %= DIV;
		 */
		count = (count + i * (n - i + 1) + 1) % DIV;
	printf("%ld\n", count);
	return 0;
}


Measured memory_bytes: 1732
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x = 0,f = 1; char ch = getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-48;}
	return x*f;
}

const int N = 1e6;
char a[N+3];
int n;

int main()
{
	scanf("%d",&n); scanf("%s",a+1); for(int i=1; i<=n; i++) a[i] -= 49;
	int ans1 = 0;
	for(int i=1; i<=n; i++)
	{
		ans1 ^= (a[i]&1)&(((n-1)&(i-1))==i-1?1:0);
//		printf("%d\n",ans1);
	}
	if(ans1) {puts("1"); return 0;}
	for(int i=1; i<=n; i++) {if(a[i]==1) {puts("0"); return 0;}}
	int ans2 = 0;
	for(int i=1; i<=n; i++)
	{
		ans2 ^= (a[i]>>1)&(((n-1)&(i-1))==i-1?1:0);
	}
	if(ans2) {puts("2"); return 0;}
	puts("0");
	return 0;
}

Measured memory_bytes: 1280
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T
import qualified Data.Vector as V
import qualified Data.Vector.Unboxed as VU
import qualified Data.IntSet as IS
import Data.Tuple (swap)

main :: IO ()
main = do
  n <- unsafeTextToInt <$> T.getLine :: IO Int
  as <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  let
    as' = VU.fromList as :: VU.Vector Int
    lengthOfLISs :: Tree Int -> VU.Vector Int
    lengthOfLISs = (VU.replicate n 0 VU.//) . flatten . f (0, IS.empty)
      where
        f :: (Int, IS.IntSet) -> Tree Int -> Tree (Int, Int)
        f (l, s) (Node i ts) = Node (i, l') (map (f (l', s')) ts)
          where
            x = as' VU.! i :: Int
            (l', s') = fmap (IS.insert x) . maybe (succ l, s) ((,) l . flip IS.delete s) $ IS.lookupGE x s
  uvs <- sequence . replicate (pred n) $ unsafeListToPair . map (pred . unsafeTextToInt) . T.words <$> T.getLine :: IO [(Int, Int)]
  let
    tree = fromEdgesToTree n uvs 0 :: Tree Int
  VU.mapM_ print . lengthOfLISs $ tree

data Tree a = Node a [Tree a]

extract :: Tree a -> a
extract (Node x _) = x

fromEdgesToAdjacencyVector :: Int -> [(Int, Int)] -> V.Vector [Int]
fromEdgesToAdjacencyVector n = V.accum (flip (:)) (V.replicate n [])

fromEdgesToTree :: Int -> [(Int, Int)] -> Int -> Tree Int
fromEdgesToTree n uvs r = Node r . map (f r) $ adjacency V.! r
  where
    adjacency = fromEdgesToAdjacencyVector n . concatMap (pairToList . ((,) <$> id <*> swap)) $ uvs :: V.Vector [Int]
    f :: Int -> Int -> Tree Int
    f i j = Node j (map (f j) (filter (/= i) $ adjacency V.! j))

flatten :: Tree a -> [a]
flatten t = map extract queue
  where
    queue = t : walk 1 queue
    walk 0 _ = []
    walk l ((Node x ts) : ts') = ts ++ walk (pred l + length ts) ts'
-- flatten (Node x ts) = x : concatMap flatten ts

pairToList :: (a, a) -> [a]
pairToList (x, y) = [x, y]

unsafeListToPair :: [a] -> (a, a)
unsafeListToPair [x, y] = (x, y)

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

using ll=long long;
vector<ll> dp(100010,1001001001);

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll n, k;
  cin >> n >> k;
  vector<ll> h(n);
  rep(i,n) cin >> h[i];
  dp[0] = 0;
  dp[1] = abs(h[1] - h[0]);
  rep(i,n){
    for(int j = 1; j<=k; j++) {
      dp[i+j] = min(dp[i+j], dp[i] + abs(h[i+j]-h[i]));
    }
  }
  n--;
  cout << dp[n] << endl;
}


Measured memory_bytes: 1792
//https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_a
#include <bits/stdc++.h>
using namespace std;
using ll=int64_t;
#define FOR(i,a,b) for(int64_t i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
int main() {
    ll M,D; cin>>M>>D;
    ll ans=0;
    FOR(m,1,M+1){
        FOR(d,1,D+1){
            ll d1=d%10;
            ll d10=d/10;
            if(d1>=2&&d10>=2&&d1*d10==m) ++ans;
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<map>
#include<sstream>
#include<cstring>
#include<algorithm>
#include<string>
using namespace std;
const int maxn = 2e5+7;
int a[maxn];
int p[maxn],q[maxn],r[maxn];
int found1(int x)
{
    return x==p[x]?x : p[x] = found1(p[x]);
}
int found2(int x)
{
    return x==q[x]?x : q[x] = found2(q[x]);
}
int main()
{
    int n,l,k;
    cin >> n >> k >> l;
    int a,b;
    for(int i = 0; i < n; i ++)
    {
        p[i] = i;
        q[i] = i;
    }
    for(int i = 0; i < k; i ++)
    {
        scanf("%d%d",&a,&b);
        int x = found1(a),y = found1(b);
        if(x!=y)
        {
            p[x] = y;
        }
    }
    for(int i = 0; i < l; i ++)
    {
        scanf("%d%d",&a,&b);
        int x = found2(a),y = found2(b);
        if(x!=y)
        {
            q[x] = y;
        }
    }
    for(int i = 1; i <= n; i ++)
    {
        found1(i);
        found2(i);
    }
    map<pair<int,int>,int>mp;
    for(int i = 1; i <= n; i ++)
    {
        mp[make_pair(p[i],q[i])]++;
    }
    for(int i = 1; i <= n; i ++)
    {
        cout << mp[make_pair(p[i],q[i])] << " ";
    }
    cout <<endl;
    return 0;
}

Measured memory_bytes: 13568
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#define ll long long
#define ull unsigned long long
#define si set <ll>
#define vi vector <ll>
#define popcount(x) __builtin_popcountll(x)
#define mii map <ll,ll>
#define vpi vector <pair <ll,ll> >
#define sz(c) (int)c.size()
#define fr first
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define sc second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define mem0(a) memset(a,0,sizeof(a))
#define rep(i,a,n) for( ll i=a ; i<n ; i++)
#define ld long double
#define rall(a) (a).rbegin(),(a).rend()

ll power(ll b,ll e,ll m)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b%m,e/2,m)%m;
  return power(b*b%m,e/2,m);
}
ll power( ll b, ll e)
{
  if(e==0) return 1;
  if(e&1) return b*power(b*b,e/2);
  return power(b*b,e/2);
}

 bool isPowerOfTwo(ll x)
    {
        // x will check if x == 0 and !(x & (x - 1)) will check if x is a power of 2 or not
        return (x && !(x & (x - 1)));
    }


 bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
} 



void solve()
{
   ll n,k;
   cin>>n>>k;
   vi v(n);
   rep(i,0,n) cin>>v[i];
   ll ans=0;
   sort(all(v));
   rep(i,0,k) ans+=v[i];
   cout<<ans;
}


int main()       
{
  fastio
  ll t=1;
  while(t--)
    solve();
  return 0;
}

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

using namespace std;

#define FOR(i, n) for(int i = 0; i < (int) n; i++)
#define rall(x) x.rbegin(), x.rend()
#define all(x) x.begin(), x.end()
#define PB push_back
#define F first
#define S second

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

#define MAX 10000007

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

	ll n, k; cin >> n >> k;
    vi v(n); FOR(i, n) cin >> v[i];
    vi F(n);
    FOR(i, n) cin >> F[i];

    sort(rall(v));
    sort(all(F));

    auto f = [&](ll q){
        ll aux = k;
        for(int i = 0; i < n; i++){
            if(1LL*v[i]*F[i] > q){
                aux -= v[i] - (q)/(F[i]);
            }
        }
        return aux >= 0;
    };


    ll a = -1, b = 1e12+1;
    while(b > a + 1){
        ll q = (a+b)/2;
        if(f(q))
            b = q;
        else 
            a = q;
    }

    cout << b << '\n';

	return 0;
}


Measured memory_bytes: 1792
#include<bits/stdc++.h>
#define pb push_back
using namespace std;


int main(){
	int n,m,x;
	cin>>n>>m>>x;
	std::vector<std::vector<int>> v;
	for(int i =0; i<n; i++){
		std::vector<int> temp;
		int cost;
		cin>>cost;
		temp.push_back(cost);
		for(int j=0; j<m; j++){
			int up;
			cin>>up;
			temp.push_back(up);
		}

		v.push_back(temp);
	}

	// for (int i = 0; i < n; ++i)
	// {
	// 	for (int j = 0; j < m+1; ++j)
	// 	{
	// 		cout<<v[i][j]<<" ";
	// 	}
	// 	cout<<endl;
	// }

	int max = pow(2,n);

	int num = 1;
	std::vector<int> costs;
	while(num<max){
		bitset<12> b(num);
		bool flag=false;
		int total=0;
		std::vector<int> levels(m,0);
		for(int bit=0; bit<12; bit++){
			if(b[bit]==1){
				total += v[bit][0];
				for(int k=0; k<m; k++){
					levels[k]+=v[bit][k+1];
				}
				
			}
		}
		for(int k=0; k<m; k++){
			if(levels[k]<x){
				flag=true;
				break;
			}
		}
		if(flag==false){
			costs.pb(total);
		}
		num++;
	}
	if(costs.size()==0) cout<<-1<<endl;
	else cout<<*min_element(costs.begin(),costs.end())<<endl;



}

Measured memory_bytes: 4140
#include<stdio.h>
int a[200050], b[200050];
int main()
{
    int n,j=0,i;
    scanf("%d",&n);
    for(i=1; i<=n; i++)
        scanf("%d",&b[i]);
    if(n%2==0)
    {
        for(i=n,j=0; i>=1; i--)
        {
            if(i%2==0&&i!=1)
            {
                a[j]=i;
                j++;
            }
        }
        a[j++]=1;
        for(i=3; i<n; i++)
        {
            if(i%2==1)
            {
                a[j]=i;
                j++;
            }
        }
    }
    else
    {
        for(i=n,j=0; i>=1; i--)
        {
            if(i%2==1&&i!=1)
            {
                a[j]=i;
                j++;
            }
        }
        a[j++]=1;
        for(i=2; i<n; i++)
        {
            if(i%2==0)
            {
                a[j]=i;
                j++;
            }
        }
    }
    for(i=0; i<j; i++)
        printf("%d ",b[a[i]]);
    printf("\n");
    return 0;
}

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

int main() {
    string s;
    cin >> s;
    
    for(int i = 0; i < s.size(); ++i){
        if(s[i] == '9'){
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
    return 0;
}

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

int main() {
  int N;
  cin>>N;
  vector<vector<int>> p(N,vector<int>(10));
  for(int i=0;i<N;i++){
    for(int j=0;j<10;j++){
      cin>>p[i][j];
    }
  }
  vector<vector<int>> q(N,vector<int>(11));
  for(int i=0;i<N;i++){
    for(int j=0;j<11;j++){
      cin>>q[i][j];
    }
  }
  vector<int> r(N);
  vector<int> em(N);
  int Z=-2001924167,A;
  for(int i=1;i<1024;i++){
    r=em;
    A=0;
    for(int j=0;j<10;j++){
      if(i&(1<<j)){
        for(int k=0;k<N;k++){
          r[k]+=p[k][j];
        }
      }
    }
    for(int k=0;k<N;k++){
      A+=q[k][r[k]];
    }
    Z=max(A,Z);
  }
  cout<<Z<<endl;
}

Measured memory_bytes: 3576
n, k = map(int, input().split())
p = [int(x) for x in input().split()]
ans_list = [0]
a = 0
ans = 0
ans_ = 0
for i in range(n):
    a += (1+p[i])/2
    ans_list.append(a)
for i in range(n-k+1):
    ans_ = ans_list[i+k]-ans_list[i]
    ans = max(ans, ans_)
    
print(ans)

Measured memory_bytes: 25188
// lannisters don't act like fools
#include <bits/stdc++.h>

using namespace std;
#define yah_faster_baby ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD 1000000007







void solve() {
    int n;
    cin >> n;
    string s;
    cin >> s;
    int count = 0;
    for (int i = 0; i < n; i++) {
        if (s[i] == 'W')
            count++;
    }
    reverse(s.begin(), s.end());
    int count2 = 0;
    for (int i = 0; i < count; i++) {
        if (s[i] == 'W')
            count2++;
    }
    cout << count - count2;

}






int main() {
    yah_faster_baby
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output1.txt", "w", stdout);
#endif // ONLINE_JUDGE
    solve();
    return 0;
}

Measured memory_bytes: 3720
n=int(input())
ss=input()
mod=1000000007
s=[]
for i in range(n):
    s.append(ss[i])
s.sort()
x=s[0]
l=[]
count=1
for i in range(1,n):
    if x==s[i]:
        count+=1
        if i==n-1:
            l.append(count%mod)
    else:
        l.append(count%mod)
        count=1
        x=s[i]
        if i==n-1:
            l.append(count%mod)

y=len(l)
m=1
#print(l)
for i in range(y):
    m=m*(l[i]+1)%mod
print((m-1)%mod if n>1 else 1)

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

int n;

bool match(vector<int> &O, vector<int> &R) {
    for (int i = 0; i < n; i++) {
        if (O.at(i) != R.at(i)) {
            return false;
        }
    }

    return true;
}

int order(vector<int> &R) {
    vector<int> O(n);
    for (int i = 0; i < n; i++) {
        O.at(i) = i + 1;
    }

    int count = 0;
    do {
        count++;
        if (match(O, R)) {
            return count;
        }
    } while (next_permutation(O.begin(), O.end()));
}

int main() {
    cin >> n;
    vector<int> P(n);
    vector<int> Q(n);
    for (int i = 0; i < n; i++) {
        cin >> P.at(i);
    }
    for (int i = 0; i < n; i++) {
        cin >> Q.at(i);
    }

    int ans = abs(order(P) - order(Q));

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

Measured memory_bytes: 256
ab = input().split()
a,b = int(ab[0]),int(ab[1])
d = []
z = b - a 
if ((z-1)*z)/2 >a and ((z+1)*(z+2))/2 > b:
    x,y = ((z-1)*z)/2, ((z+1)*(z+2))
print(int(x - a))

Measured memory_bytes: 3060
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int c[27];
int s[366][27];
int last[27];

const ll INF = 1e9;

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int D;
    cin >> D;
    for(int i = 1; i <= 26; ++i) cin >> c[i];
    for(int i = 1; i <= D; ++i){
        for(int j = 1; j <= 26; ++j){
            cin >> s[i][j];
        }
    }
    for(int d = 1; d <= D; ++d){
        ll score = -INF;
        int id = 1;
        for(int t = 1; t <= 26; ++t){
            ll new_score = s[d][t];
            last[t] = d;
            for(int i = 1; i <= 26; ++i){
                new_score -= c[i] * (d - last[i]);
            }
            if(score < new_score){
                id = t;
                score = new_score;
            }
        }
        cout << id << endl;
    }
    return 0;
}


Measured memory_bytes: 3696
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
int main() {
    int N, M; cin >> N >> M;
    if(N % 2 == 1) {
        rep(i, M) {
            cout << i + 1 << " " << 2 * M - i << endl;
        }
    }
    else {
        rep(i, M / 2) {
            cout << i + 1 << " " << M - i << endl;
        }
        rep(i, M - M / 2) {
            cout << M + 1 + i << " " << 2 * M + 1 - i << endl;
        }
    }
    return 0;
}

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

using i64=int64_t;

#define rep(i,x,y) for(i64 i=i64(x),i##_max_for_repmacro=i64(y); i<i##_max_for_repmacro; ++i)
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define print(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define print(x)
#endif
 
const int inf=1.01e9;
const i64 inf64=4.01e18;
const double eps=1e-9;
 
template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
    os << "[";
    for (const auto &v : vec) {
        os << v << ",";
    }
    os << "]";
    return os;
}

void solve(){
    int N;
    cin >> N;

    vector<vector<int>> A(2,vector<int>(N));
    rep(i,0,2) rep(j,0,N) cin >> A[i][j];

    vector<vector<int>> dp(2,vector<int>(N));
    dp[0][0]=A[0][0];
    rep(i,0,2) rep(j,0,N){
        if(i==0 and j==0) continue;
        if(i>0) dp[i][j]=max(dp[i][j],dp[i-1][j]+A[i][j]);
        if(j>0) dp[i][j]=max(dp[i][j],dp[i][j-1]+A[i][j]);
    }

    cout << dp[1][N-1] << endl;
}

int main(){
    std::cin.tie(0);
    std::ios::sync_with_stdio(false);
    cout.setf(ios::fixed);
    cout.precision(16);
    solve();
    return 0;
}


Measured memory_bytes: 256
//#if 1
//#include"pch.h"
//#define _CRT_SECURE_NO_WARNINGS
//#endif
#include<stdio.h>
#include<stdlib.h>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<algorithm>
#include<iostream>
using namespace std;
int main() {
	int n;
	int d[100];
	int Max = 0, tmp = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> d[i];
	}
	sort(d, d + n);
	for (int i = 0; i < n; i++) {
		if (tmp < d[i]) {
			Max++;
			tmp = d[i];
		}
	}
	cout << Max << endl;
	
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int n, k;
  cin >> n >> k;
  vector<int> p(n);
  for(int i = 0; i < n; i++){
    cin >> p[i];
  }
  sort(p.begin(), p.end());
  int ans = 0;
  for(int i = 0; i < k; i++){
    ans = ans + p[i];
  }
  cout << ans << endl;
}

Measured memory_bytes: 3624
#include "bits/stdc++.h"
using namespace std;

#define all(container) container.begin(), container.end()
#define sortall(container) (sort(container.begin(), container.end()))
#define yn(cond) ((cond) ? (cout << "Yes" << endl) : (cout << "No" << endl))
#define YN(cond) ((cond) ? (cout << "YES" << endl) : (cout << "NO" << endl))

typedef long long       ll;

typedef vector<int>     vi;
typedef vector<ll>      vll;
typedef vector<double>  vd;
typedef vector<bool>    vb;
typedef vector<char>    vc;
typedef vector<string>  vs;
typedef pair<int, int>  pii;
typedef pair<ll, ll>    pll;
typedef vector<vi>		vvi;
typedef vector<vll>		vvll;
typedef vector<vd>		vvd;
typedef vector<vb>		vvb;
typedef vector<vc>		vvc;
typedef vector<vs>		vvs;
typedef vector<pii>     vpii;
typedef vector<pll>     vpll;

typedef struct edge_ {
	ll to;
	ll cost;
} edge;

typedef struct point_ {
	ll x, y;
	point_(ll x = 0, ll y = 0) : x(x), y(y) {}
} point;

template <typename T>
using mat2d = vector<vector<T>>;

constexpr double	PI = 3.14159265358979323846;
constexpr ll		INF = 1 << 15;
constexpr ll		MOD = (ll)1e9 + 7;
constexpr double	EPS = 1e-7;
constexpr int		dy4[4] = { 0, 1, 0, -1 };
constexpr int		dx4[4] = { 1, 0, -1, 0 };
constexpr int		dy8[8] = { 0, 1, 1, 1, 0, -1, -1, -1 };
constexpr int		dx8[8] = { 1, 1, 0, -1, -1, -1, 0, 1 };

template<typename T>
istream& operator >> (istream& is, vector<T>& vec) {
	for (T& x : vec) is >> x;
	return is;
}

template<typename T>
ostream& operator << (ostream& os, const vector<T>& vec) {
	for (const T& x : vec) os << x << " ";
	return os;
}

template<typename S, typename T>
istream& operator >> (istream& is, pair<S, T>& p) {
	is >> p.first >> p.second;
	return is;
}

istream& operator >> (istream& is, point& p) {
	is >> p.x >> p.y;
	return is;
}

template<typename S, typename T>
ostream& operator << (ostream& os, const pair<S, T>& p) {
	os << "{" << p.first << " : " << p.second << "}";
	return os;
}

template<typename T>
ostream& operator << (ostream& os, const set<T>& s) {
	for (const T& x : s) os << x << " ";
	return os;
}

ostream& operator << (ostream& os, const edge e) {
	os << "{to: " << e.to << ", cost: " << e.cost << "}";
	return os;
}

ostream& operator << (ostream& os, const point& p) {
	os << "(" << p.x << " " << p.y << ")";
	return os;
}

/******************************************************************************/
/**********************         Don't make WA !!         **********************/
/******************************************************************************/


int main()
{
	int K, S;
	cin >> K >> S;

	int ans = 0;
	for (int x = 0; x <= K; x++)
		for (int y = 0; y <= K; y++) {
			int z = S - x - y;
			if (z >= 0 && z <= K) ans++;
		}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
typedef long long int ll;
int main()
{
    ll a[10000001],n,sum=0;
    scanf("%lld",&n);
    for(int i=1;i<10000001;i++)a[i]=0;
    for(ll i=2;i<10000001;i++)
    {
        if(a[i]==0)
        {
            for(ll j=i;j<10000001;j+=i)
            {
                a[j]+=(a[j/i]+1);
            }
        }
    }
    for(ll i=1;i<=n;i++)
    sum+=(i*(a[i]+1));
    printf("%lld",sum);
}


Measured memory_bytes: 79856
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cfloat>
#include<climits>
#include<cmath>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;

using lint = long long;
using P = pair<int, int>;
using LLP = pair<long long, long long>;

#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define reps(i, n) for(int i = 1, i##_len = (int)(n) ; i <= i##_len ; ++i)
#define rrep(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define rreps(i, n) for(int i = (int)(n) ; i > 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())
#define REVERSE(x) reverse((x).begin(), (x).end())
#define TWINS(x) cout << ((x) ? "Yay!" : ":(") << '\n'
#define endl '\n'

constexpr int IINF = (1 << 30) - 1;
constexpr long long LLINF = 1LL << 61;
constexpr double EPS = 1e-10;

constexpr int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
constexpr int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    int m1, d1, m2;
    cin >> m1 >> d1 >> m2;

    cout << (m1 != m2) << endl;

    cout << flush;

    return 0;
}

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

int dp[65536];
int t0[16], t[16][16];

int main(){
	const int INF = (int)1e9;
	int n;
	for( ; cin >> n , n; ){
		for( int i = 0; i < n; ++i ){
			cin >> t0[i];
			for( int j = 0; j < n; ++j ){
				cin >> t[i][j];
			}
		}
				
		int m = ( 1 << n );
		fill( dp, dp + m, INF );
		dp[0] = 0;
		for( int s = 0; s < m - 1; ++s ){
			for( int k = 0; k < n; ++k ){
				if( !( s >> k & 1 ) ){
					int x = t0[k];
					for( int j = 0; j < n; ++j ){
						if( s >> j & 1 ){
							x = min( x, t[k][j] );
						}
					}
					dp[s | 1<<k] = min( dp[s | 1<<k], dp[s] + x );
				}
			}
		}
		
		cout << dp[m - 1] << endl;
	}
}

Measured memory_bytes: 1124
import sys
input = sys.stdin.buffer.readline

#n = int(input())
#l = list(map(int, input().split()))

'''
A=[]
B=[]
for i in range():
    a, b = map(int, input().split())
    A.append(a)
    B.append(b)'''

n, k = map(int, input().split())
ans=0
cnt=[0]*n
ans=[0]*n
for i in range(1,n+1):
    a=i
    while a<k:
        a*=2
        cnt[i-1]+=1
    ans[i-1] += (1/2)**(cnt[i-1])*(1/n)
    #print(ans[i-1], cnt[i-1]+2)

print(sum(ans))


Measured memory_bytes: 6900
#include <cstdio>
#include <algorithm>
#include <vector>
#include <cmath>
#include <bitset>
#include <queue>
#include <cstring>
#include <set>
#include <map>

#define rep(i, l, r) for(int i=l; i<=r; i++)
#define dow(i, l, r) for(int i=l; i>=r; i--)
#define clr(x, c) memset(x, c, sizeof(x))
#define travel(x) for(edge *p=fir[x]; p; p=p->n)
#define all(x) (x).begin,(x).end
#define pb push_back
#define fi first
#define se second
#define l(x) Left[x]
#define r(x) Right[x]
#define lowbit(x) (x&-x)
#define pi acos(-1)

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;

inline int read()
{
    int x=0; bool f=0; char ch=getchar();
    while (ch<'0' || '9'<ch) f|=ch=='-', ch=getchar();
    while ('0'<=ch && ch<='9') x=x*10+ch-'0', ch=getchar();
    return f?-x:x;
}

#define maxn 200009

ll d[21], A; int now;
struct node{int l,r; ll D;}; 
bool operator < (node a, node b){return a.l<b.l || (a.l==b.l && a.r<b.r) || (a.l==b.l && a.r==b.r && a.D<b.D);}
map<node,ll>M;

inline void Search(int l, int r, ll D)
{
	if (l<=r)
	{
		if (D==0 && l==r) 
			A+=10;
		else if (D==0)
			A++;
		return;
	}
	ll a=10*(d[l]-d[r]); if (D<-a || a<D) return;
	if (M[(node){l,r,D}]!=0)
	{
		if (M[(node){l,r,D}]==-1) return;
		A+=M[(node){l,r,D}]; return;
	}
	ll tmp=A; 
	rep(i, 0, 9) rep(j, 0, 9) if ((D-(d[l]-d[r])*(i-j))%d[r+1]==0 && (l!=now || j!=0)) 
		Search(l-1,r+1,D-(d[l]-d[r])*(i-j));
	if (tmp!=A) M[(node){l,r,D}]=A-tmp;
	if (tmp==A) M[(node){l,r,D}]=-1;
}

int main()
{
	d[1]=1; rep(i, 2, 18) d[i]=d[i-1]*10;
	int D=read(); rep(i, 1, 18) now=i, Search(i,1,D); printf("%lld\n", A);
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<iomanip>
#include<vector>
#include<string>
#include<cstring>
#include<map>
#include<set>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<climits>
#include<fstream>

#define MOD (1000000007)

using namespace std;

typedef long long int Int;

constexpr Int TEN(int n) { return n == 0 ? 1 : 10 * TEN(n-1); }

const int max_n = 300000+10;
int N;

int main(void) {
    cin>>N;
    vector<int> A(N);

    for(int i = 0;i < N;i++) {
        int a;
        cin>>a;
        A[a-1]++;
    }

    sort(A.begin(),A.end());
    vector<int> s(N+1);
    for(int i = 0;i < N;i++) {
        s[i+1] = s[i]+A[i];
    }

    for(int k = 1;k <= N;k++) {
        int left = 0;
        int right = N/k+1; //[l,r)
        while(left<right-1) {
            int mid = (left+right)/2;
            bool ok = [&](int mid) {
                int l = lower_bound(A.begin(),A.end(),mid)-A.begin();
                int ans = mid*(N-l) + s[l];

                return (ans >= mid*k);
            }(mid);

            if(ok) {
                left = mid;
            } else {
                right = mid;
            }
        }

        cout<<left<<endl;
    }

    return 0;
}
        





Measured memory_bytes: 3200
#include <iostream>
#include <map>
#include <vector>
#include <cmath>
#include <string>
#include <cstring>
#include <algorithm>
#include <climits>
#include <stack>
#include <queue>
#include <set>
#include <cctype>
#include <bitset>
#include <type_traits>

#include <list>
using namespace std;

#define REP(i, n) for (int i = 0; i < (n); ++i)
#define rep(i, a, b) for (int i = a; i < (b); ++i)
#define YES(j) cout << (j ? "YES" : "NO") << endl;
#define Yes(j) std::cout << (j ? "Yes" : "No") << endl;
#define yes(j) std::cout << (j ? "yes" : "no") << endl;

int main(void)
{
    while (1)
    {
        int h, w;
        cin >> h >> w;
        if (h == 0 && w == 0)
            break;
        REP(i, h)
        {
            REP(j, w)
            {
                cout << "#";
            }
            cout << endl;
        }
        cout << endl;
    }
}


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

using namespace std;


int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i++) ans += i % 2;

    cout << fixed << setprecision(9) << (double)ans / n;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <bitset>
#include <vector>
#include <string>
#include <algorithm>
#include <set>
#include <map>
#include <cmath>
#include <regex>
using namespace std;
using ll = long long int;
using dd = long double;
const ll MOD = 1e9 + 7;

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

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

    for (ll i = 0; i < n.size(); i++)
    {
        if (n[i] == '1') {
            n[i] = '9';
        } else if (n[i] == '9') {
            n[i] = '1';
        }
    }
    cout << n << endl;

}

Measured memory_bytes: 256
import sys
from collections import deque
import numpy as np
import math
sys.setrecursionlimit(10**6)
def S(): return sys.stdin.readline().rstrip()
def SL(): return map(str,sys.stdin.readline().rstrip().split())
def I(): return int(sys.stdin.readline().rstrip())
def IL(): return map(int,sys.stdin.readline().rstrip().split())

def Main():
    n = I()
    judge = [0]*4
    for _ in range(n):
        s = S()
        if s=='AC': judge[0] += 1
        elif s=='WA':   judge[1] += 1
        elif s=='TLE':  judge[2] += 1
        else:   judge[3] += 1
    
    print(f'AC x {judge[0]}')
    print(f'WA x {judge[1]}')
    print(f'TLE x {judge[2]}')
    print(f'RE x {judge[3]}')
    return

if __name__=='__main__':
    Main()

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

int main()
{
    int n;
    cin >> n;
    vector<string> w(n);
    for (int i = 0; i < n; i++)
    {
        cin >> w.at(i);
    }
    int count = 0;
    for (int i = 0; i < n - 1; i++)
    {
        if (w.at(i)[w.at(i).size() - 1] == w.at(i + 1)[0])
        {
            count++;
        }
    }
    if (count != n - 1)
    {
        cout << "No" << endl;
    }
    else
    {
        sort(w.begin(), w.end());
        count = 0;
        for (int i = 0; i < n - 1; i++)
        {
            if (w.at(i) == w.at(i + 1))
            {
                count++;
            }
        }
        if (count != 0)
        {
            cout << "No" << endl;
        }
        else
        {
            cout << "Yes" << endl;
        }
    }
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}

module Main where

import Data.Char
import Data.List
import Control.Monad
import Control.Applicative


readInt :: IO Int
readInt = read <$> (input `seq` input)
    where input = do
            !c <- getChar
            if isDigit c || c == '-'
                then (c :) <$> input
                else return []

prints :: Show a => [a] -> IO ()
prints as = putStrLn $ concat $ intersperse " " $ map show as

main = do
    [x, y] <- replicateM 2 readInt
    if x == 0 && y == 0
        then return ()
        else prints [min x y, max x y] >> main



Measured memory_bytes: 4016
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<sstream>
#include<stack>
#include<string>
#include<unordered_set>
#include<vector>

#define ll long long
#define P pair<int,int>
#define FOR(i,N) for(int i=0;i<(int)N;i++)
#define FORIN(i,a,b) for(int i=a;i<(int)b;i++)
#define ALL(x) (x).begin(),(x).end()
#define LAST(x) (x)[(x).size()-1]
#define GI(name) int (name);scanf("%d",&(name))
#define GI2(name1,name2) int (name1),(name2);scanf("%d %d",&(name1),&(name2))
#define GI3(name1,name2,name3) int (name1),(name2),(name3);scanf("%d %d %d",&(name1),&(name2),&(name3))
#define GVI(name,size) vector<int> (name)(size);FOR(i,(size))scanf("%d",&(name)[i])
#define MOD 1000000007

using namespace std;

string to_hex(int x){
    stringstream ss;
    ss<<hex<<x;
    return ss.str();
}

inline int get_int(){
    int ret;
    scanf("%d",&ret);
    return ret;
}

inline vector<int> get_ints(int n){
    vector<int> ret(n);
    FOR(i,n){
        scanf("%d",&ret[i]);
    }
    return ret;
}

inline string get_str(){
    string ret;
    cin>>ret;
    return ret;
}

bool is_prime(int n){
    int s=sqrt(n)+1;
    for(int i=2;i<=s;++i){
        if(n%i==0){
            return 0;
        }
    }
    return 1;
}

vector<P> prime_division(int n){
    vector<P> ret;
    int s=sqrt(n)+1;
    int c=0;
    for(int i=2;i<=n;++i){
        if(n%i==0){
            c=0;
            do{
                ++c;
                n/=i;
            }while(n%i==0);
            ret.push_back(P(i,c));
        }
    }
    return ret;
}

string to_string(string s){
    return s;
}

template<class T>
string to_string(vector<T> v){
    string ret="{";
    FOR(i,v.size()-1){
        ret+=to_string(v[i])+",";
    }
    if(v.size()>0){
        ret+=to_string(LAST(v));
    }
    ret+="}";
    return ret;
}

void debug_print(){
    cerr<<endl;
}

template<class Head,class... Tail>
void debug_print(Head head,Tail... tail){
    cerr<<to_string(head)<<" ";
    debug_print(tail...);
}

template<class... T>
void debug(T... args){
    cerr<<"["<<__LINE__<<"]: ";
    debug_print(args...);
}

void print(){
    cout<<endl;
}

template<class Head,class... Tail>
void print(Head head,Tail... tail){
    cout<<to_string(head);
    print(tail...);
}

int main(){
    ll N,M;
    cin>>N>>M;
    ll ans=0;
    if(2*N<=M){
        ans+=N;
        ans+=(M-2*N)/4;
    }else{
        ans+=M/2;
    }
    print(ans);
    return 0;
}

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

using namespace std;

#define X first
#define Y second
#define mp make_pair
#define pb push_back
#define Debug(...) fprintf(stderr, __VA_ARGS__)

typedef long long LL;
typedef long double LD;
typedef unsigned int uint;
typedef pair <int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
  char c = getchar();
  bool f = false;
  for (x = 0; !isdigit(c); c = getchar()) {
    if (c == '-') {
      f = true;
    }
  }
  for (; isdigit(c); c = getchar()) {
    x = x * 10 + c - '0';
  }
  if (f) {
    x = -x;
  }
}

template <typename T> inline bool CheckMax(T &a, const T &b) {
  return a < b ? a = b, true : false;
}

template <typename T> inline bool CheckMin(T &a, const T &b) {
  return a > b ? a = b, true : false;
}

int main() {
#ifdef wxh010910
  freopen("d.in", "r", stdin);
#endif
  char s[20];
  scanf("%s", s);
  bool flg = true;
  for (int i = 1; i < strlen(s); ++i) {
    if (s[i] != '9') {
      flg = false;
      break;
    }
  }
  if (flg) {
    int sum = 0;
    for (int j = 0; j < strlen(s); ++j) {
      sum += s[j] - '0';
    }
    printf("%d\n", sum);
  } else {
    printf("%d\n", strlen(s) * 9 + s[0] - '0' - 10);
  }
#ifdef wxh010910
  Debug("My Time: %.3lfms\n", (double)clock() / CLOCKS_PER_SEC);
#endif
  return 0;
}


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

int main() {
  int n;
  ll k;
  cin >> n >> k;
  vector<int> a(n, 0), f(n, 0);
  int sum = 0;
  rep(i, n) {
    cin >> a.at(i);
    sum += a.at(i);
  }

  rep(i, n) cin >> f.at(i);
  sort(a.begin(), a.end());
  sort(f.rbegin(), f.rend());

  ll l = -1, r = 1e13; // lは絶対にダメな値、rは絶対にOKな値にする
  while (r - l > 1) {
    ll mid = (l + r) / 2;
    ll cnt = 0;
    rep(i, n) {
      cnt += max(0ll, a.at(i) - mid / f.at(i)); // a.at(i) - mid / f.at(i) が負になる場合ある
    }
    if (cnt <= k) {
      r = mid;
    } else {
      l = mid;
    }
  }

  cout << r << endl;
  return 0;
}

Measured memory_bytes: 4840
n = int(input())
h = list( map(int,input().split()) )
 
ck = True
for i in range(n-2,-1,-1):
  if h[i] > h[i+1]:
    h[i] -= 1
    if h[i] > h[i+1]:
        ck = False
        break

print('Yes' if ck else 'No')

Measured memory_bytes: 14396
#include <bits/stdc++.h>
typedef long long ll;
typedef unsigned long long ull;
#define reps(i,s,n) for(int (i)=(s);(i)<(n);++(i))
#define rep(i,n) reps(i,0,n)
#define reptr(i,n) for(int (i)=(n);(i)>=0;--(i))
#define All(x) (x).begin(),(x).end()
#define mp make_pair
#define pb push_back
const ll MOD=1e9+7;
using namespace std;

int main(){
  string s;
  cin >> s;
  int key = INT_MAX;
  for(int i=0;i<s.size()-2;i++){
    string tmp = s.substr(i,3);
    int n = stoi(tmp);
    if(abs(n-753)<key){
      key = abs(n-753);
    }
  }
  cout << key << endl;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<math.h>
#include<string.h>
#include<iostream>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<set>
#include<queue>
#include<assert.h>
#include<stdlib.h>
#include<stack>
using namespace std;
/*********************Contest Template***********************/
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<long long,long long> pll;
typedef pair<int,int> Cord;
#define FASTIO ios_base::sync_with_stdio(false);cin.tie(0);
struct S{
    int a,b; S(){}S(int _a,int _b){
        a=_a;
        b=_b;
    }
    const bool operator<(const S &o) const{
        return a<o.a;
    }
};
priority_queue<int,vector<int>,greater<int>> mpq;
#define SPACE 0
#define NL 1
inline void showAll(vector<int> &v,int NL_or_space){ 
    //0 is space, 1 is NL
    for(int &here:v){
        printf("%d",here);
        printf("%c",(NL_or_space)?'\n':' ');
    }
}
/*********************Contest Template***********************/
// const int SIZE=



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

    sort(arr,arr+5);
    int ans=1<<30;

    do{
        int cur=0;
        for(int i=0 ; i<5 ; i++){
            if(i<4) cur=(cur+arr[i]+9)/10*10;
            else cur+=arr[i];
        }
        ans=min(ans,cur);
    }while(next_permutation(arr,arr+5));

    printf("%d\n",ans);
    return 0;
}



Measured memory_bytes: 256
N= int(input())
nums= list(map(int,input().split(" ")))
for x in range(N):
        if(x!=N-1):
            print(nums[x],end=" ")
        else:
            print(nums[x])
for i in range(1,N):
    a= nums[i]
    j=i-1
    while nums[j]>a and j>=0:
        nums[j+1]=nums[j]
        j-=1
    nums[j+1]=a
    for x in range(N):
        if(x!=N-1):
            print(nums[x],end=" ")
        else:
            print(nums[x])
        
        



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

int main(){
    vector<vector<int>> vec(3 ,vector<int>(3));
    for(int i=0;i<3;i++)for(int j=0;j<3;j++) cin >> vec[i][j];

    for(int i=0;i<3;i++){
        for(int j=min(vec[i][0] ,min(vec[i][1] ,vec[i][2])) ;j>0;j--){
            vec[i][0]-- ;vec[i][1]--; vec[i][2]--;
        }
    }

    for(int i=0;i<3;i++){
        if(!(vec[0][i] == vec[1][i] && vec[1][i] == vec[2][i])){
            cout <<"No" << endl;
            return 0;
        }
    }

    cout << "Yes" << endl;
}


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

bool isLeapYear(int y)
{
	if (y % 400 == 0) return true;
	if (y % 100 == 0) return false;
	if (y % 4 == 0) return true;
	return false;
}

int main()
{
	int a, b;
	bool isFirstDataSet = true;

	while (cin >> a >> b, a + b)
	{
		if (!isFirstDataSet) cout << endl;

		isFirstDataSet = false;
		bool existsLeapYear = false;

		for (int y = a; y <= b; y++)
		{
			if (isLeapYear(y))
			{
				existsLeapYear = true;
				cout << y << endl;
			}
		}
		if (!existsLeapYear) cout << "NA" << endl;
	}

	return 0;
}

Measured memory_bytes: 2976