akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
template<typename T1, typename T2>
inline bool chmax (T1& a, T2 b) {
  if (a < b) {
    a = b;
    return true;
  }
  return false;
}
template<typename T>
class calculate_heights {
  const int n;
  const vector<vector<pair<T, int>>>& grh;
  vector<T> dp, ep;

  void dfs (
      int crr = 0,
      int prt = 0
    ) {
      for (auto const& e : grh[crr]) {
        T w; int nxt; tie(w, nxt) = e;
        if (nxt == prt) continue;
        dfs(nxt, crr);
        chmax(dp[crr], dp[nxt] + w);
      }
    }

  void efs (
      int crr = 0,
      int prt = 0
    ) {
      vector<T> cld = {ep[crr]};
      for (auto const& e : grh[crr]) {
        T w; int nxt; tie(w, nxt) = e;
        if (nxt == prt) continue;
        cld.push_back(dp[nxt] + w);
      }
      sort(cld.begin(), cld.end(), greater<T>());
      for (auto const& e : grh[crr]) {
        T w; int nxt; tie(w, nxt) = e;
        if (nxt == prt) continue;
        ep[nxt] = dp[nxt] + w == cld[0] ?
            cld[1] + w : cld[0] + w;
      }
      for (auto const& e : grh[crr]) {
        T w; int nxt; tie(w, nxt) = e;
        if (nxt == prt) continue;
        efs(nxt, crr);
      }
      chmax(dp[crr], ep[crr]);
    }

  public:
    calculate_heights(
        vector<vector<pair<T, int>>>& grh
      ) :
      n(grh.size()),
      grh(grh),
      dp(n, 0),
      ep(n, 0)
      {
        dfs();
        efs();
      }
    
    auto operator[] (int i) const -> const T {return dp[i];}
};
int main() {
  int n;
  cin >> n;
  vector<vector<pair<long long, int>>> grh(n);
  for (int i = 0; i < n - 1; i++) {
    int s, t; long long d;
    cin >> s >> t >> d;
    grh[s].emplace_back(d, t);
    grh[t].emplace_back(d, s);
  }
  calculate_heights<long long> hgt(grh);
  for (int i = 0; i < n; i++) {
    cout << hgt[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 4988
#include<stdio.h>
 
int main(void)
{
  int pasuta[4];
  int nomimono[3];
  int i,j,mini1,mini2;

  mini1=0;
  mini2=0;
  for(i=1;i<=3;i++)
    {
      scanf("%d",&pasuta[i]);
    }
  for(i=1;i<=2;i++)
    {
      scanf("%d",&nomimono[i]);
    }

  mini1=pasuta[1];
  for(i=2;i<=3;i++)
    {
      if(mini1>pasuta[i])
	{
	  mini1=pasuta[i];
	}
    }

  mini2=nomimono[1];
  if(mini2>nomimono[2])
    {
      mini2=nomimono[2];
    }

  j=(mini1+mini2)-50;

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

Measured memory_bytes: 1020
#include<stdio.h>
int main()
{
	int a,b,x;
	scanf("%d %d",&a,&b);
	x=a+b;
	if(x%3==0||a%3==0||b%3==0){
		printf("Possible\n");
	}
	else{
		printf("Impossible\n");
	}
	return 0;
}


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

int main() {
  string S, T; cin >> S >> T;
  bool ok = true;
  for (int i = 0; i < S.size(); i++) {
    if (S[i] != T[i]) ok = false;
  }
  if (ok) cout << "Yes" << endl;
  else cout << "No" << endl;  
}

Measured memory_bytes: 3624
package main

import(
	"fmt"
	// "sort"
	// "math"
	// "strconv"
	// "strings"
	"os"
	"bufio"
)

func min(a,b int) int{
	if a<b{
		return a
	}
	return b
}

func max(a,b int) int{
	if a>b{
		return a
	}
	return b
}

func toInt(buf []byte) (o int) {
	for _, v := range buf {
		o = o*10 + int(v-'0')
	}
	return
}

type pair struct {
	first int
	second int
}

type pairs []pair

func (a pairs) Len() int {return len(a)}
func (a pairs) Swap(i,j int) {a[i], a[j] = a[j], a[i]}
func (a pairs) Less(i,j int) bool {
	return a[i].first < a[j].first
	if a[i].first > a[j].first {
		return false
	}
	return a[i].second <= a[j].second
}

var bit,sum [100001]int

func main() {
	in := bufio.NewReader(os.Stdin)
	//in, _ := os.Open("a.txt")
	var s string
	s, _ = in.ReadString('\n')
	n := len(s)
	n--
	for i := 0; i < n; i++ {
		if s[i] == '0' {
			bit[i + 1] = 0
		} else {
			bit[i + 1] = 1
 		}
 		sum[i + 1] = sum[i] + bit[i + 1]
	}
	for k := n; k > 0; k-- {
		if 2 * k <= n {
			fmt.Println(k)
			os.Exit(0)
		}
		if (sum[k] - sum[n - k] == 0) || (sum[k] - sum[n - k] == 2*k - n) {
			fmt.Println(k)
			os.Exit(0)
		}
	}
}

Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    vector<pair<int,int> >a;
    for(int i=0;i<n;i++){
        int t1,t2;
        cin>>t1>>t2;
        a.push_back({t2,t1});
    }
    sort(a.begin(),a.end());
    long long t=0;
    int c=0;
    for(int i=0;i<n;i++){
        t=t+a[i].second;
        if(t>a[i].first){
            c=1;
        }
    }
    if(c){
        cout<<"No";
    }
    else{
        cout<<"Yes";
    }
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a, b, c, x;
    cin >> a >> b >> c >> x;
    int ans=0;
    for(int i=0; i<=a; i++){
        for(int j=0; j<=b; j++){
            for(int k=0; k<=c; k++){
                if(i*500+j*100+k*50 == x){
                    ans++;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define ll long long int
#define int ll
//#define slld(t) scanf("%lld",&t)
// #define sd(t) scanf("%d",&t)
// #define pd(t) printf("%d\n",t)
//#define plld(t) printf("%lld\n",t)
#define vec vector < int >
#define vecp vector < pair < int , int > >
#define ff first
#define ss second
#define pb push_back
#define mp make_pair
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define pii pair < int , int >
#define pll pair < ll , ll > 
#define pdd pair<double , double>
#define debug(x)   cerr<<#x<<": "<<x<<endl
#define mod  1000000007
#define N    200005
#define mod1 1000000007
#define mod2 998244353
#define bitcnt __builtin_popcountll
#define PI acos(-1)
#define s3   1.73205080757          // square root 3
const  int inf = (int)1e18+10 ;
const int MAX= 100;

 
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
ordered_set S;

int powmod(int x , int y){
	int res = 1;
	while(y > 0){
		if(y%2==1)
			res = (res*x)%mod;
		x = (x*x)%mod;
		y/=2;
	}
	return res;
}
int mul(int x , int y){
	return (x*y)%mod;
}
int solve(int x , int y){
	int ans = 0;
	   while(x > 0){
	   	   x/=5;
	   	   ans +=  x;
	   }
	   return ans;
}
signed main(){
  fast;
 
  int n;
  cin >> n;
  if(n%2 == 1){
  	cout << 0 << endl;
  	return 0;
  }
  int k = n%10;
  int ans = (n-k)/10;
  ans +=  solve((n-k)/10 , 5) ;
  cout << ans << endl;
 

 }

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

int main(){
	int x, ans;
	cin >> x;
	if(x%2==0){
		ans = pow(x/2, 2);
	}else{
		ans = (x/2)*(x/2+1);
	}
	cout << ans << endl;
	return 0;
}


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

int main() {
  double x1,y1,x2,y2;
  cin >> x1 >> y1 >> x2 >> y2 ;
  
  double ans = sqrt(std::pow((x1-x2),2.0)+std::pow((y1-y2),2.0));
  
 cout << std::fixed << std::setprecision(8) << ans << endl;
  
}


Measured memory_bytes: 3244
n = gets.to_i
a = []
i = 0

if n == 0
    a[i] = 0
end

while n != 0

    if n % (2**(i+1)) != 0

        a[i] = 1
        n -= (-2)**i



    else

        a[i] = 0

    end

    i += 1

end


puts a.reverse.join('')
    

Measured memory_bytes: 3836
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdint>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <valarray>
#include <vector>

#if __has_include(<string_view>)
#include <string_view>
#endif
#if __has_include(<optional>)
#include <optional>

template <class T>
constexpr const T& max(const T& a, const std::optional<T>& b)
{
    return b ? max(a, *b) : a;
}

template <class T>
constexpr const T& max(const std::optional<T>& a, const T& b)
{
    return a ? max(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& max(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a > *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

template <class T>
constexpr const T& min(const T& a, const std::optional<T>& b)
{
    return b ? min(a, *b) : a;
}

template <class T>
constexpr const T& min(const std::optional<T>& a, const T& b)
{
    return a ? min(*a, b) : b;
}

template <class T>
constexpr const std::optional<T>& min(const std::optional<T>& a, const std::optional<T>& b)
{
    if (a && b)
        return *a < *b ? a : b;
    else if (a)
        return a;
    else
        return b;
}

#endif
#if __has_include(<any>)
#include <any>
#endif

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

using namespace std;

template <class T, class U>
istream& operator>>(istream& is, pair<T, U>& pair)
{
    is >> pair.first >> pair.second;
    return is;
}

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

template <class T>
istream& operator>>(istream& is, valarray<T>& collection)
{
    for (auto& item : collection)
        is >> item;
    return is;
}

template <class T>
T peak_and_pop(std::queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.front());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::priority_queue<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

template <class T>
T peak_and_pop(std::stack<T>& q)
{
    assert(!q.empty());
    T t = move(q.top());
    q.pop();
    return t;
}

void solution()
{
    int n;
    cin >> n;
    int head = 0;
    rep(i,n){
        int a;
        cin >> a;
        if(head + 1 == a){
            head = a;
        }
    }
    if(head == 0){
        cout << -1 << '\n';
    }else{
        cout << (n-head) << '\n';
    }
}

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


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	vector<int>v;
	long long int n,h,i,cnt=0,x=0;
	cin>>n;
	for(i=0;i<n;i++)
	{
		cin>>h;
		v.push_back(h);
	}
	for(i=1;i<v.size();i++)
	{
		if(v[i]<=v[i-1])
		{
			cnt++;
			if(cnt>x)
			{
				x=cnt;
			}
		}
		else
		{
			cnt=0;
		}
	}

	cout<<x<<endl;
}

Measured memory_bytes: 892
//#include "stdafx.h"
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define	BitSetV(Val,Bit)		((Val) |= (Bit))			
#define	BitTstV(Val,Bit)		((Val) & (Bit))				
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
vector<P> city[100001];

void dispY(int yLen)
{
	if (0 < yLen) {
		REP(i, yLen) {
			cout << "U";
		}
	} else {
		REP(i, yLen * -1) {
			cout << "D";
		}
	}
}

void dispX(int xLen)
{
	if (0 < xLen) {
		REP(i, xLen) {
			cout << "R";
		}
	} else {
		REP(i, xLen * -1) {
			cout << "L";
		}
	}
}

int main()
{
	int tx, ty, sx, sy;
	cin >> tx >> ty >> sx >> sy;

	int yLen = sy - ty;
	int xLen = sx - tx;
	dispY(yLen);
	dispX(xLen);
	
	dispY(-yLen);
	dispX(-xLen);

	dispX(-1);
	dispY(yLen + 1);
	dispX(xLen + 1);
	dispY(-1);

	dispX(+1);
	dispY(-(yLen + 1));
	dispX(-(xLen + 1));
	dispY(+1);
	cout << endl;
	return 0;
}


Measured memory_bytes: 2560
fn input() -> String {
    let mut buf = String::new(); //A
    std::io::stdin().read_line(&mut buf).unwrap(); //B
    buf.trim().to_string() //C
}

fn main() {
    let line = &input();
    let seg: Vec<i32> = line
        .split_whitespace()
        .map(|s| s.parse::<i32>().unwrap())
        .collect();
    range(seg);
}

fn range(line: Vec<i32>) {
    let mut first_num = 0;
    if line.iter().max() == Some(&0) {
        println!("No");
        return;
    }
    for s in line {
        if first_num != 0 && first_num >= s {
            println!("No");
            return;
        }
        first_num = s;
    }
    println!("Yes");
}


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

using namespace std;

int main() {
    int n, y;
    cin >> n >> y;
    for (int i = 0; i <= n; ++i)
        for (int j = 0; i + j <= n; ++j)
            if (i * 10000 + j * 5000 + (n - i - j) * 1000 == y) {
                cout << i << " " << j << " " << n - i - j;
                return 0;
            }
      cout << "-1 -1 -1";
}


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


int main() {
 int n,a,b;
 cin >> n >>a >>b ;
 ll sum=0;
 int counter=0;
 for(int i = 0; i < n+1; i++){
   int j=i;
   counter=0;
   if(i<10){
     if(i>=a && i<=b) sum+=i;
     continue;
   }
   while(j/10>0){
     counter+=(j%10);
     j/=10;
   }
  counter+=j;
  if(counter>=a && counter<=b) sum+=i;

 }
 cout << sum << endl;
}



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

int main(){
    int N,K,C;
    cin>>N>>K>>C;

    string S;
    cin>>S;

    vector<int> front;
    vector<int> back;
    for(int i=0;i<N;i++){
        if(front.size()==K){
            break;
        }
        if(S[i]=='o'){
            front.push_back(i+1);
            i+=C;
        }
    }
    for(int i=N-1;i>=0;i--){
        if(back.size()==K){
            break;
        }
        if(S[i]=='o'){
            back.push_back(i+1);
            i-=C;
        }
    }

    /*
    for(auto p:front){
        cout<<p<<" ";
    }
    cout<<endl;
    for(auto p:back){
        cout<<p<<" ";
    }
    cout<<endl;
    //*/

    vector<int> ans;
    for(int i=0;i<K;i++){
        if(front[i]==back[K-1-i]){
            ans.push_back(front[i]);
        }
    }

    for(auto p:ans){
        cout<<p<<endl;
    }

    return 0;
}

Measured memory_bytes: 6536
#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 dp[105][4][2];

int main() {
  string s;
  cin >> s;
  int n = s.size();
  int K;
  cin >> K;
  dp[0][0][0] = 1;
  rep(i,n)rep(j,4)rep(k,2) { //i桁目まで決めて、0以外をj個使って
    int nd = s[i]-'0';
    rep(d,10) {
      int ni = i+1, nj = j, nk = k;
      if (d != 0) nj++;
      if (nj > K) continue;
      if (k == 0) {
        if (d > nd) continue;
        if (d < nd) nk = 1;
      }
      dp[ni][nj][nk] += dp[i][j][k];
    }
  }
  int ans = dp[n][K][0] + dp[n][K][1];
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 3612
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define gcd(a,b) __gcd((a),(b))
#define lcm(a,b) ((a)*(b))/gcd((a),(b))
const int maxn = 1e9 + 5;
#define INF 100000000000
const int MOD = 1e9+7;
const double PI = 3.14159265358979323846264338;
const ll MAXN = 1e18;

int n,x[1 << 18],y[1 << 18],t[1 << 18];

int main() {
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	fastio
	cin >> n;
	bool ok = true;
	for(int i=1; i<=n; i++){
		cin >> t[i] >> x[i] >> y[i];
	}
	for(int i=1; i<=n; i++){
		int suma = t[i]-t[i-1];
		int ama = abs(x[i]-x[i-1])+abs(y[i]-y[i-1]);
		if(ama>suma || (suma-ama)%2 != 0){
			ok = false;
		}else{
			true;
		}
	}
	if(ok){
		cout << "Yes\n";
	}else{
		cout << "No\n";
	}
	return 0;
}
//^-^

Measured memory_bytes: 4792
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rrep(i, n) for (int i = (n - 1); i >= 0; i--)
#define ALL(v) v.begin(), v.end()
using namespace std;
using P = pair<int, int>;
typedef long long ll;
vector<string> res;
int n;

void dfs(string tmp, char mx){
  if(tmp.size() == n){
    res.push_back(tmp);
    return;
  }
  for(char c ='a'; c<= mx; c++){
    dfs(tmp + c, ((c == mx)? (char) (mx + 1) : mx));
  }
}

int main() {
  cin >> n;
  string tmp = "";
  dfs(tmp, 'a');
  sort(ALL(res));
  rep(i, res.size()){
    cout << res[i] << endl;
  }
}

Measured memory_bytes: 7356
import sys

# sys.stdin = open('d1.in')


def read_int_list():
    return list(map(int, input().split()))


def read_str_list():
    return input().split()


def read_int():
    return int(input())


def read_str():
    return input()

n = read_int()
a = read_int_list()

b = set(a)
res = len(b)
if res % 2 != 1:
    res -= 1
print(res)


Measured memory_bytes: 14564
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
//template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
/* attention
    long longのシフト演算には気をつけよう
    タイポした時のデバッグが死ぬほどきつくなるので変数名は最低3字くらい使った方がいいかも
*/

int main(){
    int N; cin >> N;
    vector<ll> a(3*N);
    for(int i=0; i<3*N; i++) cin >> a[i];

    ll ans = 0LL;
    sort(a.begin(), a.end(), greater<ll>());

    for(int i=0; i<2*N; i++) if(i%2 == 1) ans += a[i];

    cout << ans << endl;
}

Measured memory_bytes: 2560
#include <iostream>
#include <vector>

using namespace std;

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

    int in;
    long long sum = 0;
    int max = 0;
    for( int i=0; i<n; i++){
        cin >> in;
        if(max <= in) {
            max = in;
        }else{
            sum+=max-in;
        }
    }

    cout << sum << endl;
}

Measured memory_bytes: 3592
#include<iostream>
#include<stack>
#include<string>
#define rep(i,n) for(int i = 0; i < (n); i++)
using namespace std;

int main()
{
    long long n;
    cin >> n;
    stack<char>st;
    if(n <= 26){
        char a = 'a' + n - 1;
        cout << a << endl;
        return 0;
    }else{
        rep(i,10000){
            long long a;
            a = n % 26;
            if(a == 0) st.push('z');
            else st.push('a' + a - 1);
            n /= 26;
            if(st.top() == 'z') n -= 1;
            if(n == 0) break;
        }
    }
    while(!st.empty()){
        cout << st.top();
        st.pop();
    }
    cout << endl;
    return 0;
}

Measured memory_bytes: 3632
#include <iostream>
 
inline unsigned insertion_sort(unsigned a[], unsigned n, unsigned gap){
  unsigned count = 0;
  for(unsigned i = gap; i < n; i++){
    unsigned v = a[i];
    int j = i - gap;
    while(j >= 0 && a[j] > v){
      a[j+gap] = a[j];
      j -= gap;
      count++;
    }
    a[j+gap] = v;
  }
  return count;
}
 
inline void shell_sort(unsigned a[], unsigned n){
  const unsigned gaps[] = {1,8,23,77,281,1073,4193,16577,65921,262913,1050113};
  // generated from pow(4,i)+3*pow(2,i-1)+1 (prefixed with 1)
 
  unsigned gap_num = 0, count = 0;
  while(gaps[gap_num+1] < n) gap_num++;
 
  for(int i = gap_num; i >= 0; i--) count += insertion_sort(a,n,gaps[i]);
 
  std::cout << (gap_num+1) << '\n';
 
  for(int i = gap_num; i; i--) std::cout << gaps[i] << ' ';
  std::cout << gaps[0] << '\n';
 
  std::cout << count << '\n';
}
 
int main(){
  std::ios::sync_with_stdio(false);
  unsigned n;
  unsigned a[1000000];
  std::cin >> n;
  for(unsigned i = 0; i < n; i++) std::cin >> a[i];
  shell_sort(a,n);
  for(unsigned i = 0; i < n; i++) std::cout << a[i] << '\n';
}


Measured memory_bytes: 7048
#include<iostream>
#include<vector>
#include<algorithm>
typedef long long ll;
using namespace std;

int main() {
	int n;
	int a, b;
	ll k, sum = 0;
	cin >> n >> k;
	vector<pair<int, int>>p;
	for (int i = 0; i < n; ++i) {
		cin >> a >> b;
		p.push_back(make_pair(a,b));
	}
	sort(p.begin(), p.end());
	for (int i = 0; i < n; ++i) {
		sum += p[i].second;
		if (sum >= k) {
			cout << p[i].first << endl;
			break;
		}
	}
	return 0;
}


Measured memory_bytes: 1400
#include <stdio.h>
int main(int argc, char const *argv[])
{
  int n;
  scanf("%d",&n);
  int d[n];
  int i,j;
  int c=0;
  for(i=0;i<n;i++){
    scanf("%d",&d[i]);
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      c+=d[i]*d[j];
    }
  }
  printf("%d",c);
  return (0);
}

Measured memory_bytes: 128
#include <iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <vector>
#define rep(i, s, n) for (int i = s; i < (n); i++)
#define ll long long int
using namespace std;

int main(void) {
  char b;
  cin >> b;
  
  if ( b == 'A' ) printf("T\n");
  else if ( b == 'T' ) printf("A\n");
  else if ( b == 'C' ) printf("G\n");
  else printf("C\n");
  
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<string>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<queue>
#include<deque>
#include<regex>
#include<stack>
#include<stdio.h>
#include<vector>
#include<set>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)

typedef int long long ll;
using namespace std;
typedef pair<int,int> P;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
const ll MOD=1e9+7;
static const int MAX = 100;
static const int INF = (1<<23);
template<class T> T gcd(T a, T b){return b? gcd(b,a%b) : a;}
template<class T> T lcm(T a,T b){return a / gcd(a,b)*b;}

int main(){

    int h,w,kk;
    cin>>h>>w>>kk;
    vector<vector<int>> v(h,vector<int>(w,0));

    rep(i,h){
        string s;
        cin>>s;
        int ssum=0;
        rep(j,s.size()){
            v[i][j]=(s[j]=='1'?1:0);
            if(s[j]=='1'){
                ssum++;
            }
        }


    }


    ll zen = pow(2,h-1)+1;
    ll ans = MOD;

    for(int i=0;i<zen;i++){

        ll k = i;
        vector<int> q;
        q.push_back(0);
        for(int j=0;j<h-1;j++){
            if((k>>j)&1){
                q.push_back(j+1);
            }
        }

        q.push_back(h);
        bool ff = false;
        vector<int> rui(q.size()-1,0);
        vector<bool> line(w,false);
        ll ssum = 0;

        for(int j=0;j<w;j++){
            vector<int> srui(q.size()-1,0);

            for(int jj = 0;jj<q.size()-1;jj++){
                int ksum = 0;
                for(int t=q[jj];t<q[jj+1];t++) {
                    if (v[t][j]) {
                       srui[jj]++;
                    }
                }
                if(srui[jj]>kk){
                    ff = true;
                    break;
                }
            }
            if(ff)break;
            bool f = false;
            rep(jk,q.size()-1){
                if(srui[jk]+rui[jk]>kk){
                    f=true;
                }else{
                    rui[jk]+=srui[jk];
                }
            }
            if(f){
                ssum++;
               rui = srui;
            }
        }

        if(!ff) {
            ssum += q.size() - 2;
            ans = min(ans, ssum);
        }



    }
cout<<ans<<endl;










return 0;
}


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

int main() {
    int N,C,K;
    cin >> N >> C >> K;
    vector<int> T(N);
    for(int i=0; i<N; ++i) cin >> T[i];
    sort(T.begin(), T.end());

    int res = 0;
    int cur = 0;
    int num = 1;
    int limit = T[0] + K;
    while(cur < N) {
        ++res;
        while(cur + 1 < N && num < C && T[cur+1] <= limit && limit <= T[cur+1] + K) {
            ++cur;
            ++num;
        }
        ++cur;
        limit = T[cur] + K;
        num = 1;
    }
    cout << res << endl;
}

Measured memory_bytes: 640
n = int(input())
d = set() 
result = []
for _ in range(n):
    command, s = input().split()
    if command == 'insert':
        d.add(s)
    elif command == 'find':
        if s in d:
            result.append('yes')
        else:
            result.append('no')

for r in result:
    print(r)



Measured memory_bytes: 35280
import java.util.*;
public class Main  {
   public static void main(String[] args)  {
      Scanner sc = new Scanner(System.in);
      
      int s = sc.nextInt();
      int w = sc.nextInt();
       
      if (s <= w) {     
         System.out.println("unsafe");
      } else {
         System.out.println("safe");
      }
   }
}


Measured memory_bytes: 35900
#include <iostream>

using namespace std;
int v[1001][1001];
int main()
{

    int viz[1000001][3],cont_viz=0,l,c;
    int h,w;
    char x;
    cin>>h>>w;
    for(int i=1; i<=h; i++)
    {
        for(int j=1; j<=w; j++)
        {
            cin>>x;
            if(x=='#')
            {
                viz[cont_viz][0]=i;
                viz[cont_viz][1]=j;
                viz[cont_viz][2]=0;
                //cout<<i<<" "<<j<<endl;
                cont_viz++;
                v[i][j]=1;
            }
        }
    }
    for(int i=0; i<cont_viz; i++)
    {
        l=viz[i][0];
        c=viz[i][1];
        //cout<<l<<" "<<c<<endl;
        if(l-1>0 && v[l-1][c]==0)
        {
            viz[cont_viz][0]=l-1;
            viz[cont_viz][1]=c;
            viz[cont_viz][2]=viz[i][2]+1;
            cont_viz++;
            v[l-1][c]=1;
           // cout<<l-1<<" A "<<c<<endl;

        }
        if(l+1<=h && v[l+1][c]==0)
        {
            viz[cont_viz][0]=l+1;
            viz[cont_viz][1]=c;
            viz[cont_viz][2]=viz[i][2]+1;
            cont_viz++;
            v[l+1][c]=1;
            //cout<<l+1<<" B "<<c<<endl;
        }
        if(c-1>0 && v[l][c-1]==0)
        {
            viz[cont_viz][0]=l;
            viz[cont_viz][1]=c-1;
            viz[cont_viz][2]=viz[i][2]+1;
            cont_viz++;
            v[l][c-1]=1;
            //cout<<l<<" C "<<c-1<<endl;
        }
        if(c+1<=w && v[l][c+1]==0)
        {
            viz[cont_viz][0]=l;
            viz[cont_viz][1]=c+1;
            viz[cont_viz][2]=viz[i][2]+1;
            cont_viz++;
            v[l][c+1]=1;
            //cout<<l<<" D "<<c+1<<endl;
        }
    }
    //cout<<viz[cont_viz-1][0]<<" "<<viz[cont_viz-1][1]<<endl;
    cout<<viz[cont_viz-1][2];
    return 0;
}
/*
3 3
..#
...
...

*/


Measured memory_bytes: 15872
def solve():
    N, P = map(int, input().split())
    
    ans = 1
    if N==1:
        return P
    else:
        for i in range(2, int(P**(1/N)+1)):
            while P % (i**N) == 0:
                ans *= i
                P //= (i**N)
        return ans
print(solve())

Measured memory_bytes: 3188
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <tuple>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

int main(){
  int x, y;
  cin >> x >> y;
  cout << x + y / 2 << endl;
  return 0;
}


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

signed main() {
	string S, T;
	cin >> S >> T;
	int A, B;
	cin >> A >> B;
	string U;
	cin >> U;
	if (S == U) A--;
	else B--;
	cout << A << " " << B << endl;
}


Measured memory_bytes: 256
n=1<<18;N,m;L[1<<18],p;first[1<<18],next[1<<18];i;
long dat[1<<20],lazy[1<<20],A[1<<18],x;
long update(a,b,k,l,r){
	return a<=l&r<=b?dat[k]+(lazy[k]+=x):l<b&a<r?(dat[k]=fmax(
		update(a,b,2*k+1,l,(l+r)/2),
		update(a,b,2*k+2,(l+r)/2,r)
	))+lazy[k]:dat[k]+lazy[k];
}
long query(a,b,k,l,r){
	return a<=l&r<=b?dat[k]+lazy[k]:l<b&a<r?fmax(
		query(a,b,2*k+1,l,(l+r)/2),
		query(a,b,2*k+2,(l+r)/2,r)
	)+lazy[k]:dat[k]+lazy[k];
}
main(j){
	for(scanf("%d%d",&N,&m);~scanf("%d%d%ld",L+j,&p,A+j);first[p]=j++)next[j]=first[p];
	for(;i++<N;){
		//x=query(0,i+1,0,0,n);
		update(i,i+1,0,0,n);
		for(p=first[i];p!=0;p=next[p])x=A[p],x=update(L[p],i+1,0,0,n);
	}
	x=0;
	printf("%ld",update(0,i+1,0,0,n));
}

/*
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
####################################################################################################
*/


Measured memory_bytes: 12800
#include <bits/stdc++.h>
using namespace std;
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;
}
void print() { cout << "\n"; }
template <class T> void print(const T &x) { cout << x << "\n"; }
template <class T, class... Args> void print(const T &x, const Args &... args) {
    cout << x << " ";
    print(args...);
}
template <class T> void printVector(const vector<T> &v) {
    for(const T &x : v) {
        cout << x << " ";
    }
    cout << "\n";
}
using ll = long long;

#define ALL(v) (v).begin(), (v).end()
#define RALL(v) (v).rbegin(), (v).rend()
const double EPS = 1e-7;
const int INF = 1 << 30;
const ll LLINF = 1LL << 60;
const double PI = acos(-1);
constexpr int MOD = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

//-------------------------------------

using P = pair<int, int>;

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    int odd = (m + 1) / 2;
    int even = m / 2;
    for(int i = 0; i < odd; i++) {
        print(i + 1, odd * 2 - i);
    }
    for(int i = 0; i < even; i++) {
        print(n - i, n - (even * 2 - i));
    }
}

Measured memory_bytes: 3652
import java.util.*;

class Main {

    public static boolean bsearch(ArrayList<Integer> a, int left, int right, int goal) {
        while (left <= right) {
            int mid = (left + right) / 2;
            if (a.get(mid) < goal) {
                left = mid + 1;
            } else if (a.get(mid) > goal) {
                right = mid - 1;
            } else {
                return true;
            }
        }
        return false;
    }

    public static void main(String[] args) {
        Scanner in = new Scanner(System.in);
        int n = in.nextInt();
        ArrayList<Integer> s = new ArrayList<>();
        for (int i = 0; i < n; i++) {
            s.add(in.nextInt());
        }
        Collections.sort(s);
        n = in.nextInt();
        int res = 0;
        for (int i = 0; i < n; i++) {
            if (bsearch(s, 0, s.size() - 1, in.nextInt())) {
                res += 1;
            }
        }
        System.out.println(res);
    }
}

Measured memory_bytes: 81936
import java.io.*
import java.util.*

var pw = PrintWriter(System.out)
fun solve(A: Long, B: Long, C: Long){
    if(A == B) println(C)
    else if(B == C) println(A)
    else println(B)
    pw.flush()
    return
}


fun main(args: Array<String>) {
    fun StringArray(size: Int, init: (Int) -> String = { "\u0000" }): Array<String> {
        return Array<String>(size, init)
    }
    class Scanner(stream: InputStream) {
        private val reader = BufferedInputStream(stream).bufferedReader()
        private var st: StringTokenizer? = null
        fun next(): String {
            while (!(st?.hasMoreTokens() ?: false)) st = StringTokenizer(reader.readLine())
            return st!!.nextToken()
        }
    }
    val sc = Scanner(System.`in`)
    val A = sc.next().toLong()
    val B = sc.next().toLong()
    val C = sc.next().toLong()
    solve(A, B, C)
}



Measured memory_bytes: 31388
#include <stdio.h>
#include <string.h>
#include <limits.h>
#include <math.h>
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <bitset>

typedef unsigned long long ULLONG;
typedef long long LLONG;
static const LLONG MOD_NUM = 998244353; //1000000007;

template<class _T> static void get(_T& a) {
	std::cin >> a;
}
template<class _T> static void get(_T& a, _T& b) {
	std::cin >> a >> b;
}
template<class _T> static void get(_T& a, _T& b, _T& c) {
	std::cin >> a >> b >> c;
}
template <class _T> static _T tp_abs(_T a) {
	if (a < (_T)0) {
		a *= (_T)-1;
	}
	return a;
}

static void exec();

int main()
{
	exec();
	fflush(stdout);
	return 0;
}
template <class _Ty> class PermComb
{
protected:

	_Ty _maxNum = 0;
	_Ty _use_mod = 0;
	_Ty* _fact = 0;
	_Ty* _inv = 0;
	_Ty* _finv = 0;

	PermComb() {}

public:
	PermComb(_Ty maxNum, _Ty use_mod = 0) {
		_maxNum = maxNum;
		_use_mod = use_mod;
		_fact = new _Ty[(unsigned int)maxNum + 1];
		_fact[0] = _fact[1] = 1;

		if (_use_mod) {
			_inv = new _Ty[(unsigned int)maxNum + 1];
			_finv = new _Ty[(unsigned int)maxNum + 1];
			_inv[0] = _inv[1] = 1;
			_finv[0] = _finv[1] = 1;
		}

		for (_Ty i = 2; i <= maxNum; i++) {
			_fact[i] = _fact[i - 1] * i;
			if (_use_mod) {
				_fact[i] %= _use_mod;
				_inv[i] = _use_mod - _inv[_use_mod % i] * (_use_mod / i) % _use_mod;
				_finv[i] = _finv[i - 1] * _inv[i] % _use_mod;
			}
		}
	}

	//	get permutation value
	virtual _Ty nPk(int n, int k) {
		if ((k > _maxNum) || (n > _maxNum) || (k > n) || (k < 0) || (n < 0)) {
			return 0;
		}
		return(_fact[n] / _fact[n - k]);
	}

	//	get combination value
	virtual _Ty nCk(int n, int k) {
		_Ty ans = 0;
		if ((k > _maxNum) || (n > _maxNum) || (k > n) || (k < 0) || (n < 0)) {
			ans = 0;
		}
		else if (_use_mod == 0) {
			ans = nPk(n, k);
			ans /= _fact[k];
		}
		else {
			ans = _fact[n] * (_finv[k] * _finv[n - k] % _use_mod) % _use_mod;
		}
		return ans;
	}

	//	destructor
	~PermComb() {
		delete[] _fact;
		delete[] _inv;
		delete[] _finv;
	}
};
template <class _T> static _T tp_modpow(_T base, _T exp, _T mod = (_T)1) {
	_T ans = 1;
	while (exp > 0) {
		if (exp & 1) {
			ans = (ans * base) % mod;
		}
		base = (base * base) % mod;
		exp >>= 1;
	}
	return ans;
}
template <class _T> static _T tp_modinv(_T a, _T mod) {
	return tp_modpow<_T>(a, mod - 2, mod);
}

static void exec()
{
	int N, M, K;
	get(N, M, K);

	PermComb<LLONG> cmb(N, MOD_NUM);

	LLONG ans = 0;
	for (int i = 0; i <= K; i++) {
		LLONG tmp = (tp_modpow<LLONG>((M - 1), (N - i - 1), MOD_NUM) * M) % MOD_NUM;
		tmp = (tmp * cmb.nCk(N - 1, i)) % MOD_NUM;
		ans = (ans + tmp) % MOD_NUM;
	}
	printf("%lld\n", ans);
}


Measured memory_bytes: 7996
/* << IN THE NAME OF GOD >> */
#include <bits/stdc++.h>
using namespace std;



#define err(x) cerr << #x  << " = "<<  x << '\n'
#define out(x) cout << x << '\n'
#define forp(i, r, l) for(int i = int(r); i < int(l); i++)
#define forn(i, r, l) for(int i = int(r); i > int(l); i--)
#define FAST ios::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll ,ll> pll;
const int maxn = 5e5 + 120;


int n,m ,t = INT_MAX ,a[maxn] ,x ,y;

int main(){FAST;    
       cin >> n >> m;
       memset(a ,63 ,sizeof a);
       forp(i, 1, m + 1){
           cin >> x >> y;
       a[x] = min(a[x] ,y);
    }
       int res = 0;
      forp(i ,1 ,n + 1){
        t = min(t ,a[i]);
        if(t == i)res++ ,t = a[i];
      }
        out(res);
    return 0;

}
 










Measured memory_bytes: 2176
from sys import stdin

n = int(stdin.readline().strip())
t, A = list(map(int, stdin.readline().split()))
h = list(map(int, stdin.readline().split()))

temp = []
for i in range(n):
    temp.append(t - h[i]*0.006)

dist = float('inf')
index = 0
for i, num in enumerate(temp):
    boo = abs(A - num)
    if boo < dist:
        dist = boo
        index = i

print(index+1)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
 
// 最大公約数
ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m % n);
}
 
int main() {
  ll A, B;
  cin >> A >> B;
  ll m = min(A, B);
  int cnt = 1;
  ll g = gcd(A, B);
  ll t = g;
  for (ll i = 2; i * i <= t; i++) {
    if (g % i == 0) cnt++;
    while (g % i == 0) {
      g /= i;
    }
  }
  if (g != 1) cnt++;
  cout << cnt << "\n";
 
  return 0;
}

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

const int mod = 1e9 + 7;

int main() {

  string K;
  int D;
  cin >> K >> D;
  vector<int> dp(D, 0);
  dp[0] = 1;
  int n = K.length();
  int ans = 0;
  vector<int> prefix_sum(n, 0);
  prefix_sum[0] = (K[0] - '0') % D;
  for (int i = 1; i < n; ++i) {
    prefix_sum[i] = (prefix_sum[i-1] + K[i] - '0') % D;
  }

  ans = (prefix_sum[n-1] == 0);
  for (int i = n - 1; i >= 0; --i) {
    int num = K[i] - '0';
    for (int j = (i == 0 ? 1: 0); j < num; ++j) {
      int d = (i == 0 ? 0 : prefix_sum[i-1]) + j;
      for (int r = 0; r < D; ++r) {
        if ((d + r) % D == 0) {
          ans += dp[r];
          if (ans >= mod) {
            ans -= mod;
          }
        }
      }
    }
    vector<int> new_dp(D, 0);
    for (int j = 0; j < D; ++j) {
      for (int d = 1; d <= 9; ++d) {
        int m = (j + d) % D;
        new_dp[m] += dp[j];
        if (new_dp[m] >= mod) {
          new_dp[m] -= mod;
        }
      }
    }
    if (i > 0) {
      ans += new_dp[0];
      if (ans >= mod) {
        ans -= mod;
      }
    }
    for (int j = 0; j < D; ++j) {
      new_dp[j] += dp[j];
      if (new_dp[j] >= mod) {
        new_dp[j] -= mod;
      }
    }
    dp = new_dp;
  }
  cout << ans << '\n';
  return 0;
}


Measured memory_bytes: 3716
#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 SORT(c)    sort((c).begin(),(c).end())
const double EPS = 1e-10;//sample:if((double)>=(double)+EPS)
#define CLR(a) memset((&a), 0 ,sizeof(a))//clear memory
#define dump(x)  cerr << #x << " = " << (x) << endl;//debug
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
//cin,cout release
//std::cin.tie(0);
//ios::sync_with_stdio(false);
int cnt=0,n;

using namespace std;
void koch(int n,double p1x, double p1y, double p2x, double p2y){
  double sx,sy,tx,ty,ux,uy,th=M_PI*60.00/180.0;
  if(n==0)return;
  sx=(2.0*p1x+p2x)/3;
  sy=(2.0*p1y+p2y)/3;
  tx=(p1x+2.0*p2x)/3;
  ty=(p1y+2.0*p2y)/3;
  ux=(tx-sx)*cos(th)-(ty-sy)*sin(th)+sx;
  uy=(tx-sx)*sin(th)+(ty-sy)*cos(th)+sy;
  koch(n-1,p1x,p1y,sx,sy);printf("%f %f\n",sx,sy);
  koch(n-1,sx,sy,ux,uy);printf("%f %f\n",ux,uy);
  koch(n-1,ux,uy,tx,ty);printf("%f %f\n",tx,ty);
  koch(n-1,tx,ty,p2x,p2y);
  cnt++;
}
int main(){
  cin>>n;
  printf("%f %f\n",0.0,0.0);
  koch(n,0,0,100,0);
  printf("%f %f\n",100.0,0.0);
  return 0;
}



Measured memory_bytes: 3228
#include <iostream>
#include <vector>
#include <stack>
#include <utility>
#include <algorithm>
using namespace std;

typedef pair<int, int> pi;

int H, W, N;
vector<pi> D;
stack<int> S;

void add_vec(int x, int y, int id) {
	int d;
	if (y == 0)
		d = x;
	else if (x == W)
		d = W + y;
	else if (y == H)
		d = W + H + (W - x);
	else
		d = W + H + W + (H - y);
	D.push_back(make_pair(d, id));
}

int main(void) {
	cin >> H >> W >> N;
	for (int i = 0; i < N; ++i) {
		int y1, x1, y2, x2;
		cin >> y1 >> x1 >> y2 >> x2;
		if (((y1 == 0 || y1 == H) || (x1 == 0 || x1 == W))
				&& ((y2 == 0 || y2 == H) || (x2 == 0 || x2 == W))) {
			add_vec(x1, y1, i);
			add_vec(x2, y2, i);
		}
	}
	sort(D.begin(), D.end());
	for (int i = 0; i < (int)D.size(); ++i) {
		if (S.empty())
			S.push(D[i].second);
		else {
			if (S.top() == D[i].second)
				S.pop();
			else
				S.push(D[i].second);
		}
	}
	if (S.empty())
		cout << "YES\n";
	else
		cout << "NO\n";
	return 0;
}


Measured memory_bytes: 2420
let m_1e9 = int_of_float 1e9 + 7
let ( +^ ) x y = (x + y) mod m_1e9
let ( -^ ) x y = x - y + if x < y then m_1e9 else 0
let ( *^ ) x y = ((x mod m_1e9) * (y mod m_1e9)) mod m_1e9
let split_string ?(pattern=" ") = Str.split @@ Str.regexp pattern

let n = Scanf.sscanf (read_line ()) "%d" @@ fun n -> n
let a = read_line () |> split_string |> List.map int_of_string

let rec loop ans arr = function
  | [] -> Printf.printf "%d\n" @@ ans
  | x :: xs -> 
    let t = Array.fold_left (fun s i -> s + if i = x then 1 else 0) 0 arr in
    if arr.(0) = x then arr.(0) <- arr.(0) + 1
    else if arr.(1) = x then arr.(1) <- arr.(1) + 1
    else arr.(2) <- arr.(2) + 1;
    loop (ans *^ t) arr xs

let () = loop 1 (Array.make 3 0) a

Measured memory_bytes: 13696
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
typedef pair<int, int> P;
ll Mod = 1000000007;
int main() {
  int N;
  cin >> N;
  int ans = 0;
  int cnt = 0;
  for (int i = 1; i <= N; i+=2) {
    cnt = 0;
    for (int j = 1; j <= i; j++) {
      if (i % j == 0) {
        cnt++;
      }
    }
    if (cnt == 8) {
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
import std.stdio, std.algorithm, std.conv, std.array, std.string, std.math, std.typecons, std.numeric;

void main()
{
    auto N = readln.chomp.to!int;
    auto AS = readln.split.to!(int[]);
    int all = 1, odd = 1;
    foreach (a; AS) {
        int x, y;
        foreach (i; a-1..a+2) {
            ++x;
            if (i&1) ++y;
        }
        all *= x;
        odd *= y;
    }
    writeln(all - odd);
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <iterator>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <sstream> 
#include <vector>
#include <cmath>
#include <map>
#include <set>
#include <queue>
#include <iomanip>
#include <functional>
#pragma GCC optimize("O3")
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define sp system("pause");
#define MOD 998244353 
#define mxN 2005



ll n;
int solve(ll i,ll nn)
{
	while (nn % i == 0)
	{
		nn /= i;
	}
	if (nn % i == 1)
		return 1;
	else
		return 0;
}

int main()
{
	fast;
	
	cin >> n;
	ll ans = 0;
	unordered_set<ll> s;
	ll sqrn = ceil(sqrt(n));
	for (ll i = 2; i <= sqrn; i++)
	{
		if ((n - 1) % i == 0)
		{
			s.insert(i);
			s.insert(n / i);
		}
	}
	for (ll i = 2; i <= sqrn; i++)
	{
		if (solve(i, n))
			s.insert(i);
	}
	/*for (auto t : s)
	{
		if ((n - 1) % t == 0)
			s.insert((n - 1) / t);
	}
	for (ll i = 2; i<n-1; i++)
	{
		if (solve(i,n)) {
			s.insert(i);
		}
	}*/
	s.insert(n);
	s.insert(n - 1);
	
	if (n == 2)
		cout << 1;
	else 
		cout << s.size();

	
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
struct node{
    int v;
    ll c;
    node() {}
    node(int v_, ll c_):
        v(v_), c(c_)
    {}
};
int N, M;
vector<vector<node> > e;
vector<ll> dis;
vector<bool> inq;
vector<ll> inq_cnt;

void spfa(){
    queue<int> q;
    dis.clear(); dis.resize(N, LLONG_MAX );
    inq.clear(); inq.resize(N, false);
    inq_cnt.clear(); inq_cnt.resize(N, 0);
    q.push(0);
    dis[0]=0;
    inq[0]=true;
    inq_cnt[0]=1;
    while(!q.empty()){
        int u=q.front(); q.pop();
        inq[u]=false;
        for(int i=0; i<e[u].size(); ++i){
            int v=e[u][i].v;
            if(v==u)
                continue;
            ll c=e[u][i].c;
            if(dis[u]+c<dis[v]){
                dis[v]=dis[u]+c;
                if(!inq[v]){
                    ++inq_cnt[v];
                    if(inq_cnt[v]>2*N){
                        continue;
                    }
                    inq[v]=true;
                    q.push(v);
                    ++inq_cnt[v];
                }
            }
        }
    }
}

int main(){
    cin>>N>>M;
    e.clear(); e.resize(N, vector<node>());
    for(int i=0; i<M; ++i){
        int u, v;
        ll c;
        cin>>u>>v>>c;
        --u; --v;
        e[u].push_back(node(v, -c));
    }
    spfa();
    if(inq_cnt[N-1]>N){
        cout<<"inf"<<endl;
    }else{
        cout<<-dis[N-1]<<endl;
    }
    return 0;
}


Measured memory_bytes: 384
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int n;
    cin >> n;
    vi b(n);
    rep(i, n) {
        cin >> b[i];
    }
    bool x = true;

    vi ans(n);
    rep(i, n) {
        for(int j=n-i-1; j>=0; --j) {
            if(b[j] == j + 1) {
                ans[n-i-1] = j+1;
                b.erase(b.begin()+j);
                break;
            }
            if(j == 0) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    rep(i, n) {
        cout << ans[i] << '\n';
    }
}

Measured memory_bytes: 256
# N = int(input())
# A = [int(x) for x in input().split()]
# V = [[0] * 100 for _ in range(100)]

N = int(input())
MOD = 10 ** 9 + 7
dp = [[[[0 for _ in range(4)] for _ in range(4)] for _ in range(4)] for _ in range(N + 1)]

# 初期値
for c3 in range(4):
    for c2 in range(4):
        for c1 in range(4):
            c321 = (c3, c2, c1)
            if c321 == (0, 1, 2) or c321 == (1, 0, 2) or c321 == (0, 2, 1):
                continue
            dp[3][c3][c2][c1] = 1

# DPテーブル更新
for n in range(4, N + 1):
    for c3 in range(4):
        for c2 in range(4):
            for c1 in range(4):
                for a in range(4):
                    if a == 2 and c1 == 1 and c2 == 0:
                        continue
                    if a == 2 and c1 == 0 and c2 == 1:
                        continue
                    if a == 1 and c1 == 2 and c2 == 0:
                        continue
                    if a == 2 and c1 == 1 and c3 == 0:
                        continue
                    if a == 2 and c2 == 1 and c3 == 0:
                        continue

                    dp[n][c2][c1][a] += dp[n - 1][c3][c2][c1]
                    dp[n][c2][c1][a] %= MOD

# DPテーブルから答えを出す
ans = 0
for c3 in range(4):
    for c2 in range(4):
        for c1 in range(4):
            ans += dp[N][c3][c2][c1]
            ans %= MOD

print(ans)


Measured memory_bytes: 3320