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

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	Int n; cin >> n;
	vector<Int> a(13);
	a[0] = 1;
	for(Int i=0; i<n; ++i){
		Int d; cin >> d;
		++a[d];
	}
	if(a[0] >= 2 || a[12] >= 2 || [a](){
		Int res = 0;
		for(Int i=1; i<=11; ++i) res = max(res, a[i]);
		return res;
	}() >= 3){
		cout << 0 << "\n";
	}else{
		Int ans = 0;
		vector<Int> b(25);
		b[0] = b[24] = 1;
		if(a[12]) b[12] = 1;
		vector<Int> c;
		for(Int i=1; i<=11; ++i){
			if(a[i] == 1) c.push_back(i);
			if(a[i] == 2) b[i] = b[24-i] = 1;
		}
		for(Int i=0; i<(1<<c.size()); ++i){
			for(size_t j=0; j<c.size(); ++j){
				if((i>>j)&1) b[c[j]] = 1;
				else b[24-c[j]] = 1;
			}
			Int dif = 1e9;
			for(Int j=0; j<24; ++j)
				for(Int k=j+1; k<=24; ++k)
					if(b[j] & b[k])
						dif = min(dif, k-j);
			ans = max(ans, dif);
			for(size_t j=0; j<c.size(); ++j) b[c[j]] = b[24-c[j]] = 0;
		}
		cout << ans << "\n";
	}
}

Measured memory_bytes: 256
package main

import (
	"bufio"
	"bytes"
	"fmt"
	"os"
	"strconv"
)

const (
	initialBufSize = 10000
	maxBufSize     = 1000000
)

var (
	sc = func() *bufio.Scanner {
		sc := bufio.NewScanner(os.Stdin)
		buf := make([]byte, initialBufSize)
		sc.Buffer(buf, maxBufSize)
		sc.Split(bufio.ScanWords)
		return sc
	}()
)

func getInt() int {
	sc.Scan()
	i, e := strconv.Atoi(sc.Text())
	if e != nil {
		panic(e)
	}
	return i
}

func getString() string {
	sc.Scan()
	return sc.Text()
}

func reverse(s string) string {
	rs := []rune(s)
	for i, j := 0, len(s)-1; i < j; i, j = i+1, j-1 {
		rs[i], rs[j] = rs[j], rs[i]
	}
	return string(rs)
}

func main() {
	str := getString()

	q := getInt()

	rev := 0
	var first bytes.Buffer
	var last bytes.Buffer
	for i := 0; i < q; i++ {
		t := getInt()
		if t == 1 {
			rev++
		} else if t == 2 {
			f, c := getInt(), getString()
			if (f == 1 && rev%2 == 0) || (f == 2 && rev%2 == 1) {
				first.WriteString(c)
			} else if (f == 2 && rev%2 == 0) || (f == 1 && rev%2 == 1) {
				last.WriteString(c)
			}
		}
	}

	var ans string
	if rev%2 == 1 {
		ans = reverse(last.String()) + reverse(str) + first.String()
	} else {
		ans = reverse(first.String()) + str + last.String()
	}
	fmt.Println(ans)
}


Measured memory_bytes: 4224
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	long long int a;
	scanf("%lld", &a);
		if(a % 10 == (a / 10) % 10 && a % 10 == (a / 100) % 10)
		{
			printf("Yes\n");
		}
		else if((a / 10) % 10 == (a / 100) % 10 && (a / 10) % 10 == (a / 1000) % 10)
		{
			printf("Yes\n");
		}
		else
		{
			printf("No\n");
		}
	
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define VIEW(x) do {cerr << #x << ": "; for(auto i : x) cerr << i << " "; cerr << endl;} while(0)
#define ALL(x) (x).begin(),(x).end()
template<class T>bool umax(T &a, const T &b) {if(a<b){a=b;return 1;}return 0;}
template<class T>bool umin(T &a, const T &b) {if(b<a){a=b;return 1;}return 0;}

template<typename A,size_t N,typename T> void FILL(A (&array)[N],const T &val){fill((T*)array,(T*)(array+N),val);}
template<typename T> void FILL(vector<T> &v, const T &x) {fill(v.begin(), v.end(), x);}
template<typename T> void FILL(vector<vector<T>> &v, const T &x) {for(auto &i:v)fill(i.begin(), i.end(), x);}

const int MOD = 998244353;
struct modint {
  long long val;
  modint(long long val=0) : val((val % MOD + MOD) % MOD){}
  modint operator-() const { return modint(-val); }
  modint& operator+=(const modint a) { if ((val += a.val)     >= MOD) val -= MOD; return *this; }
  modint& operator-=(const modint a) { if ((val += MOD-a.val) >= MOD) val -= MOD; return *this; }
  modint& operator*=(const modint a) { (val *= a.val) %= MOD; return *this; }
  modint operator+(const modint a) const { return (modint)*this += a; }
  modint operator-(const modint a) const { return (modint)*this -= a; }
  modint operator*(const modint a) const { return (modint)*this *= a; }
  modint pow(long long n) const { modint r(1), m(val); while (n > 0) { if (n & 1) {r *= m;} m *= m; n >>= 1; } return r; }
  modint inv() const { return pow(MOD-2); }
  modint& operator/=(const modint a) { return (*this) *= a.inv(); }
  modint operator/(const modint a) const { return (modint)*this /= a; }
  bool operator==(const modint &p) const { return val == p.val; }
  bool operator!=(const modint &p) const { return val != p.val; }
  friend ostream &operator<<(ostream &os, const modint &p) { return os << p.val; }
  friend istream &operator>>(istream &is, modint &a) { long long t; is >> t; a = modint(t); return (is); }
};

int main() {
  int n,k; cin >> n >> k;
  vector<pair<int,int>> s(k);
  rep(i,k) {
    cin >> s[i].first >> s[i].second;
    //--s[i].first, --s[i].second;
  }

  vector<modint> imos(n+1);
  vector<modint> ans(n);
  imos[0] =  1;
  imos[1] = -1;
  ans[0] = 1;

  rep(from ,n) {
    if(from != 0) ans[from] = ans[from-1] + imos[from];
    for(auto [l, r] : s) {
      if(from + l <= n)     imos[from + l] += ans[from];
      if(from + r + 1 <= n) imos[from + r + 1] -= ans[from];
    }
  }
  cout << ans[n-1] << endl;
}


Measured memory_bytes: 6420
#include <bits/stdc++.h>
#include <boost/multi_array.hpp>
#include <boost/optional.hpp>
#include <boost/range/irange.hpp>
#include <boost/range/algorithm.hpp>
#include <boost/range/adaptors.hpp>
#include <boost/multiprecision/cpp_int.hpp>
#include <boost/algorithm/string/classification.hpp> // is_any_of
#include <boost/algorithm/string/split.hpp>
#include <boost/algorithm/string/join.hpp>
#include <boost/algorithm/string/replace.hpp>
#include <boost/math/tools/minima.hpp>

const int MOD = 1e9+7;
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = (n); i >= 0; --i)

namespace adaptor = boost::adaptors;
using namespace std;
using boost::math::tools::brent_find_minima;
using boost::irange;
using boost::algorithm::join;
using boost::algorithm::split;
using boost::algorithm::replace_all;
using boost::multiprecision::cpp_int;
using ll = long long;
using P = pair<int, int>;

// TOP
void	Main()
{
	ll	n, a, b;
	cin >> n >> a >> b;
	if (a == b)
	{
		cout << 1 << endl;
		return ;
	}
	if (n == 1 || a > b)
	{
		cout << 0 << endl;
		return ;
	}
	ll minv;
	minv = b + a * (n - 1);
	ll maxv;
	maxv = a + b * (n - 1);
	// if (minv > maxv)
	// 	cout << 0 << endl;
	// else
		cout << maxv - minv + 1 << endl;
}
// END

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


Measured memory_bytes: 256
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <iostream>
#include <cstdlib>
#include <iomanip>
#include <cmath>
#include <math.h>
using namespace std;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    double a;
    double pi = 3.141592653589;
    cin >> a;
    cout << fixed << setprecision(6) << a * a * pi << " " <<
        fixed << setprecision(6) << 2 * a * pi << endl;
}



Measured memory_bytes: 3308
#include <stdio.h>

int main(void){
  int A, B, i, count = 0;
  scanf("%d %d", &A, &B);
  for(i=A; i<=B; i++){
    if(i % 10 == i / 10000 && (i / 10) % 10 == (i / 1000) % 10){
      count++;
    }
  }
  printf("%d",count);
  return 0;
}

Measured memory_bytes: 1696
N=int(input())
A=[int(x) for x in input().split()]
for i in range(N):
    v=A[i]
    j=i-1
    while j>=0 and v<A[j]:
        A[j+1]=A[j]
        j-=1
    A[j+1]=v
    print(' '.join(map(str,A)))

Measured memory_bytes: 5604
#include <algorithm>
#include <iostream>
#include <vector>
#include <string>
#include <map>
using namespace std;

int main() {
  int n, m; cin >> n >> m;
  vector<int> lh(n);
  vector<vector<int>> lv(n);
  for (int &h: lh) cin >> h;
  for (int i = 0; i < m; ++i) { 
    int a, b; cin >> a >> b;
    --a; --b;
    lv[a].push_back(b);
    lv[b].push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < n; ++i) { 
    bool ok = true;
    for (int v: lv[i]) {
      if (lh[v] >= lh[i]) {
        ok = false;
        break;
      }
    }
    if (ok) ++ans;
  }
  cout << ans << endl;
}


Measured memory_bytes: 8732
#include <stdio.h>
 
int main(){
 
   int box[10000];
   int i, n, max, min;
   long int sum = 0;
 
   scanf("%d", &n);
   for (i = 0; i < n; i++){
      scanf("%d", &box[i]);
      sum = sum + box[i];
   }
 
   max = box[0];
   min = box[0];
   for (i = 0; i < n; i++){
      if (max < box[i])
        max = box[i];
      if (min > box[i])
        min = box[i];
   }
 
   printf("%d %d %ld\n", min, max, sum);
 
   return 0;
 
}

Measured memory_bytes: 640
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include<iomanip>

using namespace std;
typedef long long ll;
const ll mod = 1e9 + 7;
const int inf = 1000000;

int main(int argc, const char * argv[]) {
  int N, K, X, Y;
  cin >> N >> K >> X >> Y;
  if (N < K) {
    cout << N * X << endl;
  } else {
    cout << K * X + (N - K) * Y << endl;
  }
  return 0;
}


Measured memory_bytes: 256
#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 main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, m;
    cin >> n >> m;
    for(int i = m/n; i >= 1; i--){
        int num = m - i*n;
        if(num % i == 0){
            cout << i << endl;
            return 0;
        }
    }
    cout << 1 << endl;
    return 0;
}

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

using namespace std;

#define rep(i, n) for(int i = 0; i < n; i++)
#define inv(n, a) for(int i = 0; i < n; i++) cin >> a[i]
#define MOD 1000000007
#define INF 1e7
#define LINF 1e15
typedef long long ll;
typedef long double ld;
using Graph = vector<vector<int>>;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
// 'a' = 97 'z' = 122 => 'a' = 0 'z' = 25

int main() {
    string s;
	int k;
	cin >> s >> k;

	rep(i, (int)s.length()){
		if (s[i] == 'a')
			continue;
		if ('z' - s[i] + 1 <= k){
			k -= ('z' - s[i] + 1);
			s[i] = 'a';
		}
	}
	k = k % 26;
	s[s.length()-1] += k;
	cout << s << endl;
}


Measured memory_bytes: 3756
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;
import java.io.IOException;
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.io.InputStream;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author __shangu__
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        InputReader in = new InputReader(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        DMakeThemEven solver = new DMakeThemEven();
        solver.solve(1, in, out);
        out.close();
    }

    static class DMakeThemEven {
        public void solve(int testNumber, InputReader in, PrintWriter out) {
            int n = in.nextInt(), m = in.nextInt(), mat[][] = new int[n + 2][m + 2];
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m; ++j) {
                    mat[i][j] = in.nextInt();
                }
            }
            int cnt = 0;
            ArrayList<Integer> r = new ArrayList<>(), c = new ArrayList<>(), r1 = new ArrayList<>(), c1 = new ArrayList<>();
            for (int i = 0; i < n; ++i) {
                for (int j = 0; j < m - 1; ++j) {
                    if ((mat[i][j] & 1) == 1) {
                        r.add(i + 1);
                        c.add(j + 1);
                        r1.add(i + 1);
                        c1.add(j + 2);
                        ++mat[i][j + 1];
                        ++cnt;
                    }
                }
            }

            for (int i = 0; i < n - 1; ++i) {
                if ((mat[i][m - 1] & 1) == 1) {
                    r.add(i + 1);
                    c.add(m);
                    r1.add(i + 2);
                    c1.add(m);
                    ++mat[i + 1][m - 1];
                    ++cnt;
                }
            }

            out.println(cnt);
            for (int i = 0; i < r.size(); ++i) out.printf("%d %d %d %d\n", r.get(i), c.get(i), r1.get(i), c1.get(i));
        }

    }

    static class InputReader {
        public BufferedReader reader;
        public StringTokenizer tokenizer;

        public InputReader(InputStream stream) {
            reader = new BufferedReader(new InputStreamReader(stream), 32768);
            tokenizer = null;
        }

        public String next() {
            while (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        public int nextInt() {
            return Integer.parseInt(next());
        }

    }
}



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

using i64 = int64_t;

class LazySegmentTree {
  private:
    int n;
    vector<i64> node, lazy;

    void eval(int k, int l, int r) {
        if(lazy[k] == 0) return;

        node[k] += lazy[k];

        if(r - l > 1) {
            lazy[2*k+1] += lazy[k] / 2;
            lazy[2*k+2] += lazy[k] / 2;
        }

        lazy[k] = 0;
    }

  public:
    LazySegmentTree(vector<i64> v) {
        int size = (int)v.size();
        n = 1;
        while(n < size) n *= 2;
        node.resize(2*n-1);
        lazy.resize(2*n-1, 0);

        for(int i=0;i<size;++i) node[i+n-1] = v[i];
        for(int i=n-2;i>=0;--i) node[i] = node[2*i+1] + node[2*i+2];
    }

    void update(int a, int b, i64 x, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;

        eval(k, l, r);

        if(b <= l || r <= a) return;

        if(a <= l && r <= b) {
            lazy[k] += (r - l) * x;
            eval(k, l, r);
        }else{
            update(a, b, x, 2*k+1, l, (l+r)/2);
            update(a, b, x, 2*k+2, (l+r)/2, r);
            node[k] = node[2*k+1] + node[2*k+2];
        }
    }

    i64 query(int a, int b, int k=0, int l=0, int r=-1) {
        if(r < 0) r = n;
        if(b <= l || r <= a) return 0;

        eval(k, l, r);
        if(a <= l && r <= b) return node[k];
        i64 vl = query(a, b, 2*k+1, l, (l+r)/2);
        i64 vr = query(a, b, 2*k+2, (l+r)/2, r);
        return vl + vr;
    }
};

int main(){
    int n, q;
    cin >> n >> q;
    vector<i64> v(n+1, 0);
    LazySegmentTree lst = LazySegmentTree(v);
    for(int i=0;i<q;++i){
        int c;
        cin >> c;
        if(c == 0){
            int s, t, x;
            cin >> s >> t >> x;
            lst.update(s, t+1, x);
        }else{
            int s, t;
            cin >> s >> t;
            cout << lst.query(s, t+1) << endl;
        }
    }

    return 0;
}



Measured memory_bytes: 8456
#include <stdio.h>
int main(void){
    int a=0;
    char s[11],t[12];
    scanf("%s %s",s,t);
    for(int i=0; s[i]!='\0';i++){
        if(s[i]!=t[i])
            a=1;
    }
    if(a==0)
        printf("Yes");
    else
        printf("No");
}


Measured memory_bytes: 1736
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
typedef long long ll;
const int inf = 1e8;
struct edge{int to, cost;};
typedef pair<int, int> P;
typedef pair<int, P> PP;

int N, M;
vector<edge> G[111];
int d[111];

int flag[111][111];
int ans;

void dijkstra(int s){
  priority_queue<PP, vector<PP>, greater<PP> >que;
  FOR(i,1,N+1) d[i] = inf;
  d[s] = 0;
  que.push(PP(0, P(s, s)));

  while(!que.empty()){
    PP pp = que.top(); que.pop();
    int v = pp.second.second;
    if(d[v] < pp.first) continue;
    // 来た頂点u
    int u = pp.second.first;
    if(!flag[u][v] && !flag[v][u] && v!=u){
      ans--;
      flag[u][v] = true;
    }
    for(auto &e : G[v]){
      if(d[e.to] > d[v] + e.cost){
        d[e.to] = d[v] + e.cost;
        que.push(PP(d[e.to], P(v, e.to)));
      }
    }
  }
}

int main(){
  cin >> N >> M;
  FOR(i,0,M){
    int a, b, c;
    cin >> a >> b >> c;
    edge e1;
    e1.to = b;
    e1.cost = c;
    edge e2;
    e2.to = a;
    e2.cost = c;
    G[a].push_back(e1);
    G[b].push_back(e2);
  }
  FOR(i,0,N+1) FOR(j,0,N+1) flag[i][j] = false;
  ans = M;
  FOR(i,1,N+1) dijkstra(i);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 384
import java.util.*;
class Main{
  public static void main(String[]args){
    Scanner sc=new Scanner(System.in);
    int n=sc.nextInt();
    boolean b=true;
    for(int i=0;i<n;i++){
    	int a=sc.nextInt();
      if(a%2==0){
      	if(a%3==0||a%5==0){
        }else{
          b=false;
        }
      }
    }
    System.out.print(b?"APPROVED":"DENIED");
  }
}


Measured memory_bytes: 25172
#include<stdio.h>

void main(){
int k,a,b;
int i=0,fl=0;
scanf("%d",&k);

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

for(i=0;i<=b;i++){
if(a<=k*i && k*i<=b)fl=1;
}
if(fl==1)printf("OK\n");
else printf("NG\n");
}

Measured memory_bytes: 1644
#include <stdio.h>
#include <string.h>

int main(void){
    char s[2000001];
    int i, len, sum;

    scanf("%s", s);
    len = strlen(s);
    i = 0;
    sum = 0;
    while (i < len){
        sum += (s[i] -'0');
        i++;
    }
    if  (sum % 9 == 0){
        puts("Yes");
    }else{
        puts("No");
    }
}


Measured memory_bytes: 1788
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
#define REP(i, n) for(int (i)=0; (i)<(n); (i)++)
#define OUT(a) cout << (a) << "\n";
#define ll long long

int main() {
    ll x;
    cin >> x;
    ll ans = (x/11)*2;
    int a = x%11;
    if(a>0 && a<=6) OUT(ans+1)
    else if(a>6) OUT(ans+2)
    else OUT(ans)
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <vector>
#include <cstdint>
#define FOR(i, l, r) for (int i = (l); i < (r); ++i)
#define RFOR(i, l, r) for (int i = (l); i >= (int)(r); i--)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) RFOR(i, n - 1, 0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e9;
const int mod = 1e9 + 7;
using ll = long long;
using P = pair<ll, ll>;
vector<int> to[100005];
int cost[100005];

int x[MX];
int y[MX];

long double dist(ll i, ll j)
{
  int xx = (x[i] - x[j]) * (x[i] - x[j]);
  int yy = (y[i] - y[j]) * (y[i] - y[j]);
  return sqrt(xx + yy);
}

signed main()
{
  long long n;
  cin >> n;
  long double ans = 0;
  vector<int> np(n);
  rep(i, n) np[i] = i;
  float fac = 1;
  FOR(i, 1, n + 1)
  fac *= i;
  //cout << fac << endl;
  rep(i, n)
  {
    cin >> x[i] >> y[i];
  }

  do
  {
    for (int i = 0; i < n - 1; i++)
    {
      ans += dist(np[i], np[i + 1]);
      //cout << np[i]<< " " <<np[i+1]<<" "<<dist(np[i], np[i+1]) << endl;
    }
  } while (next_permutation(np.begin(), np.end()));
  ans /= fac;
  cout <<setprecision(20)<< ans << endl;

  return 0;
}


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

int main() {
  ll n,r;
  std::cin >> n>>r;
  if(n>=10){
      std::cout << r << std::endl;
        }else{
            std::cout << r+100*(10-n)<< std::endl;
        }
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
            #include<set>
            #include<ctype.h>
            #define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
           // #define max(a,b) (a>b?a:b)
          //  #define min(a,b) (a<b?a:b)
            #define int long long
            #define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
            #define forn(i,n) for(int i=0;i<n;i++)
            #define pt(x,y) printf("%.12f %.12f\n",x*co+y*si+px,-x*si+y*co+py);
            #define forr(i,a,n) for(i=a;i<n;i++)
            #define f(x9,y9) for( int i=x9;i<y9;i++)
            using namespace std;
            typedef long long ll;

            void pairsort(int a[], int b[], int k)
            {
                pair<int, int> pairt[k];


                for (int i = 0; i < k; i++)
                {
                    pairt[i].first = a[i];
                    pairt[i].second = b[i];
                }

                sort(pairt, pairt + k);

                for (int i = 0; i < k; i++)
                {
                    a[i] = pairt[i].first;
                    b[i] = pairt[i].second;
                }
            }
            int CheckPrime(int k)
            {
                for(int i=2;i<k;i++)
                    if(k%i==0)
                        return 0;
                return 1;
            }
            int countdigit(long long n)
            {
                return floor(log10(n)+1);
            }

            long long C(int n, int r) {
            if(r>n-r)
                r=n-r;
            long long ans=1;
            for(int i=1;i<=r;i++){
                ans*=n-r+i;
                ans/=i;
            }
            return ans;
            }

            int MOD=1000000;
            //88888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888888

            int32_t main(){
            IOS;

            int X, Y; cin >> X >> Y;
	if (X <= 8 && Y <= 8) cout << "Yay!" << endl;
	else cout << ":(" << endl;
	return 0;
            }





Measured memory_bytes: 256
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"Yes\n"
#define no cout<<"No\n"

//nCr mod m
#define MOD 998244353
#define M 2200000
vector<ll> fact;
bool h=false;
void init(){
	h=true;
	fact=vector<ll>(M);
	fact[0]=fact[1]=1;
	loop(i,2,M)fact[i]=fact[i-1]*i%MOD;
}
// a^b mod MOD
ll powmod(ll a,ll b,ll m=MOD){
	ll out=1;
	ll p=a%m;
	while(b){
		if(b&1)out=out*p%m;
		p=p*p%m;
		b>>=1;
	}
	return out;
}
//nCr
ll nCr(ll n,ll r,ll m=MOD){
	if(!h)init();
	if(n<0||r<0||n<r)return 1;//??????
	ll out=fact[n]*powmod(fact[r]*fact[n-r]%m,m-2,m)%m;
	return out;
}
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}


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

	int n,m;
	cin>>n>>m;
	vi in(n);
	rep(i,n)cin>>in[i];
	vvi G(n);
	rep(i,m){
		int a,b;cin>>a>>b;
		a--;b--;
		G[a].pb(b);
		G[b].pb(a);
	}
	int c=0;
	rep(i,n){
		bool h=true;
		rep(j,G[i].size())if(in[i]<=in[G[i][j]])h=false;
		if(h)c++;
	}
	cout<<c<<endl;
}


Measured memory_bytes: 9796
import sys
sys.setrecursionlimit(10**8)
N, M = map(int, input().split())
edge = [[] for _ in range(N)]
for i in range(M):
  a,b,c = map(int, input().split())
  edge[a-1].append(b-1)
  edge[b-1].append(a-1)

def dfs(v):
  if len(edge[v])==0:
    return 0
  for u in edge[v]:
    if visited[u]==False:
      visited[u]=True
      dfs(u)
  return 0

ans = 0
visited = [False]*N
for i in range(N):
  if visited[i]==False:
    visited[i]=True
    dfs(i)
    ans += 1
print(ans)

Measured memory_bytes: 109760
#include <iostream>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <vector>
#include <queue>
#include <algorithm>
#include <bitset>
#include <cstdlib>
#include <cmath>
#define INF 100000000000
#define MOD 1000000007
#define ll long long int
//#define int long long int
using namespace std;




int main(){
  string S,T;
  cin>>S>>T;
  int A,B; cin>>A>>B;
  string U; cin>>U;

  if(U==S) A--;
  else B--;

  cout<<A<<" "<<B<<endl;

  


  return 0;
   
}


Measured memory_bytes: 256
#include<algorithm>
#include<bitset>
#include<cmath>
#include<complex>
#include<deque>
#include<functional>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<stack>
#include<string>
#include<unordered_map>
#include<unordered_set>
#include<utility>
#include<vector>

using namespace std;
typedef long long ll;

#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define ALL(x) (x).begin(),(x).end()
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define INF 1000000000000
#define MOD 10000007
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define PI 3.141592653589793238462643383279;

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

  ll n;
  cin >> n;
  ll ichi = (n%100)%10;

  if (ichi==3) {
    cout << "bon" << "\n";
  } else if ((ichi == 0)||(ichi==1)||(ichi==6)||(ichi==8)) {
    cout << "pon" << "\n";
  } else {
    cout << "hon" << "\n";
  }
}


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

int main() {
    int N, M; cin >> N >> M;
    vector<vector<int>> G(N);
    for(int i = 0; i < M; ++i) {
        int a, b; cin >> a >> b;
        a--, b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
    }
    int Q; cin >> Q;
    vector<vector<int>> query(Q, vector<int>(3));
    for(auto &q : query) for(auto &e : q) cin >> e;
    reverse(query.begin(), query.end());
    vector<vector<int>> dp(N, vector<int>(11));
    auto dfs = [&](auto &&dfs, int cur, int d, int c) -> void {
        if(dp[cur][d]) return;
        for(int i = 0; i <= d; ++i)
            if(dp[cur][i] == 0) dp[cur][i] = c;
        for(auto &to : G[cur]) dfs(dfs, to, d - 1, c);
    };
    for(auto &q : query) dfs(dfs, q[0] - 1, q[1], q[2]);
    for(int i = 0; i < N; ++i) cout << dp[i][0] << '\n';
    return 0;
}


Measured memory_bytes: 20600
#include<stdio.h>
int A[500005],i,H;
void maxHeapify(int p)
{
    int l=p*2+1;
    int r=p*2+2;
    int lg=p;
    if(l<=H&&A[l]>A[lg])
        lg=l;
    if(r<=H&&A[r]>A[lg])
        lg=r;
    if(lg!=p){

        r=A[p];
        A[p]=A[lg];
        A[lg]=r;
        maxHeapify(lg);
    }
}
int main()
{
    scanf("%d",&H);
    for(i=0;i<H;i++)
        scanf("%d",A+i);
    for(i=H/2;i>=0;i--)
        maxHeapify(i);
    for(i=0;i<H;i++)
        printf(" %d",A[i]);
	puts("");
    return 0;
}

Measured memory_bytes: 2560
#include<iostream>
#include<map>
#include<vector>
#include<queue>
#include<algorithm>
using namespace std;

typedef vector<int> V;
typedef pair<int,V> P;

int main(){
  int n;
  V v1,v2;
  cin >> n;
  v1.resize(n); v2.resize(n);
  for(int i=0;i<n;i++)cin >> v1[i];
  for(int i=0;i<n;i++)v2[i] = i+1;

  map<V,int> m1,m2;
  m1[v1] = 0; m2[v2] = 0;
  queue<P> q;
  q.push(P(0,v1));

  while(q.size()){
    P p = q.front(); q.pop();
    int d = p.first;
    v1 = p.second;
    if(d>3)continue;

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	reverse(v1.begin()+i,v1.begin()+j+1);
	if(m1.find(v1) == m1.end()){
	  m1[v1] = d+1;
	  q.push(P(d+1,v1));
	}
	reverse(v1.begin()+i,v1.begin()+j+1);
      }
    }
  }

  q.push(P(0,v2));
  while(q.size()){
    P p = q.front(); q.pop();
    int d = p.first;
    v2 = p.second;
    if(d>3)continue;

    for(int i=0;i<n;i++){
      for(int j=i+1;j<n;j++){
	reverse(v2.begin()+i,v2.begin()+j+1);
	if(m2.find(v2) == m2.end()){
	  m2[v2] = d+1;
	  q.push(P(d+1,v2));
	}
	reverse(v2.begin()+i,v2.begin()+j+1);
      }
    }
  }  
  
  int m = 9;
  for(map<V,int>::iterator ite=m1.begin();ite!=m1.end();ite++){
    if(m2.find((*ite).first) != m2.end()){
      m = min(m,(*ite).second + m2[(*ite).first]);
    }
  }
  cout << m << endl;
}

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

#define LL long long
#define LD long double
#define SC(t,x) static_cast<t>(x)
#define AR(t) vector < t >
#define PII pair < int, int >
#define PLL pair < LL, LL >
#define PIL pair < int, LL >
#define PLI pair < LL, int >
#define MP make_pair
#define PB push_back
#define PF push_front
#define POB pop_back
#define POF pop_front
#define PRF first
#define PRS second
#define INIT(ar,val) memset ( ar, val, sizeof ( ar ) )
#define lp(loop,start,end) for ( int loop = start; loop < end; ++loop )
#define lpd(loop,start,end) for ( int loop = start; loop > end; --loop )
#define lpi(loop,start,end) for ( int loop = start; loop <= end; ++loop )
#define lpdi(loop,start,end) for ( int loop = start; loop >= end; --loop )
#define qmax(a,b) (((a)>(b))?(a):(b))
#define qmin(a,b) (((a)<(b))?(a):(b))
#define qabs(a) (((a)>=0)?(a):(-(a)))

const int INF = 0x3fffffff;
const int SINF = 0x7fffffff;
const long long LINF = 0x3fffffffffffffff;
const long long SLINF = 0x7fffffffffffffff;
const int MAXN = 200007;

int n;
int a[MAXN];

void init ();
void input ();
void work ();



int main ()
{
	init ();
	input ();
	work ();
}



void init ()
{
	// Init Everything Here

	ios::sync_with_stdio ( false );
}

void input ()
{
	// input method

	scanf ( "%d", &n );
	lpi ( i, 1, n ) scanf ( "%d", &a[i] );
}

void work ()
{
	// main work

	map < LL, int > mp;
	map < LL, int > ::iterator it;
	LL ps = 0;
	mp[0] = 1;
	LL ans = 0;
	lpi ( i, 1, n ) {
		ps += a[i];
		it = mp.find ( ps );
		if ( it != mp.end () ) ans += it->second;
		++mp[ps];
	}

	cout << ans << endl;
}

Measured memory_bytes: 13568
# -*- coding: utf-8 -*-
data = input().split(" ");
A = data[0];
B = data[1];
K = data[2];

for lop in range(int(A),int(A)+int(K)):
    if lop > int(B):
        break;
    print(lop);
    fg = lop;
        
if int(B)-int(K)+1 >= int(A):
    if fg+1 < int(B)-int(K)+1:
        fg = int(B)-int(K)+1;
    else:
        fg+=1
    for lop in range(fg,int(B)+1):
        print(lop);

Measured memory_bytes: 3064
#include<stdio.h>
#include<math.h>

struct Point{double x,y;};

void koch(int,struct Point,struct Point);

int main(){
struct Point l,m;
  int n;
  scanf("%d",&n);
  l.x=0;
  l.y=0;
  m.x=100.0;
  m.y=0;
  printf("%.8f %.8f\n",l.x,l.y);
  koch(n,l,m);
  printf("%.8f %.8f\n",m.x,m.y);

  return 0;
}
void koch(int a,struct Point b,struct Point c){
  if(a == 0){
    return;
  }
  struct Point s,t,u;
  double th;
  th =(M_PI * 60.0) / 180.0;
  s.x = (2.0 * b.x + 1.0 * c.x)/3.0;
  s.y = (2.0 * b.y + 1.0 * c.y)/3.0;
  t.x = (1.0 * b.x + 2.0 * c.x)/3.0;
  t.y = (1.0 * b.y + 2.0 * c.y)/3.0;
  u.x = (t.x - s.x)*cos(th) - (t.y -s.y)*sin(th) + s.x;
  u.y = (t.x - s.x)*sin(th) + (t.y -s.y)*cos(th) + s.y;
  koch(a-1,b,s);
  printf("%.8f %.8f\n",s.x,s.y);
  koch(a-1,s,u);
  printf("%.8f %.8f\n",u.x,u.y);
  koch(a-1,u,t);
  printf("%.8f %.8f\n",t.x,t.y);
  koch(a-1,t,c);
}



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

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;
#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL){
    x=x->left;
  }
  return x;

}

Node treeMaximum(Node x){
  while(x->right!=NIL){
    x=x->right;
  }
  return x;

}

Node treeSearch(Node u, int k){
  if(u==NIL || k==u->key){
    return u;
}
  if(k<u->key){
    return treeSearch(u->left,k);
  }
  else{
    return treeSearch(u->right,k);
  }

}

Node treeSuccessor(Node x){
   Node y;
  if(x->right!=NIL){
    return treeMinimum(x->right);
  }
  y=x->parent;
  while(y!=NIL && x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y
  if(z->left==NIL || z->right==NIL){
    y=z;
  }
  else{
    y=treeSuccessor(z);
  }
  if(y->left!=NIL){
    x=y->right;
  }
  if(x!=NIL){
    x->parent=y->parent;
  }
  if(y->parent==NIL){
    root=x;
  }
  else if(y==y->parent->left){
    y->parent->left=x;
  }
  else{
    y->parent->right=x;
  }
  if(y!=z){
    z->key=y->key;
  }
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;

  while(x!=NIL){
    y=x;
    if(z->key<x->key){
      x=x->left;
    }
    else{
      x=x->right;
    }
  }
  z->parent=y;
  if(y==NIL){
    root=z;
  }
  else if(z->key<y->key){
    y->left=z;
  }
  else{
    y->right=z;
  }
}

void inorder(Node u){
  if(u == NIL)return;
    inorder(u->left);
    printf(" %d",u->key);
    inorder(u->right);
}
void preorder(Node u){
  if(u == NIL)return;
    printf(" %d",u->key);
    preorder(u->left);
    preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}

int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> H(N);
  REP(i, N) H[i] = nextInt();
  reverse(ALL(H));
  int ans = 0;
  int move = 0;
  for (int i = 0; i + 1 < N; i++) {
    if (H[i] <= H[i+1]) {
      move++;
      chmax(ans, move);
    } else {
      move = 0;
    }
  }

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

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


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

int main() {
#ifdef HOME
    freopen("dat.in", "r", stdin);
    freopen("dat.out", "w", stdout);
#endif
    ios::sync_with_stdio(false);
    cin.tie(0), cout.tie(0);
    int H, W, h, w;

    cin >> H >> W >> h >> w;
    if (H % h == 0 && W % w == 0) {
        cout << "No\n";
        return 0; }

    cout << "Yes\n";
    for (int i = 0; i < H; ++i) {
        for (int j = 0; j < W; ++j)
            if (i % h == 0 && j % w == 0)
                cout << int(1e9 - 1) << ' ';
            else if (i % h == h - 1 && j % w == w - 1)
                cout << int(-1e9) << ' ';
            else
                cout << "0 ";
        cout << '\n'; }


    return 0; }


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

int n, q;
int s[1000000];
int sorted[1000001];
multiset<int> ls;

bool check(int r, int x)
{
	typedef multiset<int>::iterator Iterator;
	
	vector<pair<int, int> > v;
	v.push_back(make_pair(-(1 << 28), 0));
	for (Iterator it = ls.begin(); it != ls.end(); it++){
		int bg = lower_bound(sorted, sorted + n, *it - r) - sorted;
		int ed = upper_bound(sorted, sorted + n, *it) - sorted;
		// [bg, ed)
		v.push_back(make_pair(bg, ed));
	}
	v.push_back(make_pair(n, 1 << 28));
	
	/*for (int i = 0; i < v.size(); i++){
		printf("[%d %d) ", v[i].first, v[i].second);
	}
	puts("");*/
	
	for (int i = 0; i + 1 < v.size(); i++){
		int bg = v[i].second;
		int ed = v[i + 1].first;
		if (bg < ed) x -= ed - bg;
	}
	
	return x >= 0;
}

int main()
{	
	scanf("%d %d", &n, &q);
	for (int i = 0; i < n; i++){
		scanf("%d", &s[i]);
	}
	
	{
		vector<pair<int, int> > v;
		for (int i = 0; i < n; i++){
			v.push_back(make_pair(s[i], i));
		}
		sort(v.begin(), v.end());
		for (int i = 0; i < v.size(); i++){
			sorted[i] = v[i].first;
		}
	}
	
	string com;
	int x;
	for (int i = 0; i < q; i++){
		cin >> com >> x;
		if (com == "ADD"){
			ls.insert(s[--x]);
		}
		else if (com == "REMOVE"){
			ls.erase(ls.find(s[--x]));
		}
		else if (com == "CHECK"){
			int left = -1;
			int right = 1e9 + 7;
			while (left + 1 < right){
				int mid = (left + right) / 2;
				if (check(mid, x)) right = mid;
				else left = mid;
			}
			if (left > (int)1e9) puts("NA");
			else printf("%d\n", left + 1);
		}
	}
}

Measured memory_bytes: 16824
H, W = map(int, input().split())
S = [input() for _ in range(H)]

def next(h, w, pre_h, pre_w):
    if S[pre_h][pre_w] == '.' and S[h][w] == '#':
        return r[pre_h][pre_w] + 1
    else:
        return r[pre_h][pre_w]

r = []

r.append([])
r[0].append( 1 if S[0][0] == '#' else 0)
for w in range(1,W):
    r[0].append( next(0, w, 0, w-1) )

for h in range(1,H):
    r.append([])
    r[h].append( next(h, 0, h-1, 0) )

    for w in range(1, W):
        if r[h-1][w] > r[h][w-1] or \
            (r[h-1][w] == r[h][w-1] and S[h][w-1] == S[h][w]):
            r[h].append( next(h, w, h, w-1) )
        else:
            r[h].append( next(h, w, h-1, w) )

print(r[H-1][W-1])


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

int main(){
    int N;
    cin >> N;
    double p[N+1];
    for(int i=1;i<=N;i++){
        cin >> p[i];
    }

    double dp[N+2][N+2]={};
    dp[0][0]=1.0;

    for(int i=1;i<=N;i++){
        for(int j=0;j<i;j++){
            dp[i][j+1]+=dp[i-1][j]*p[i];
            dp[i][j]+=dp[i-1][j]*(1.0-p[i]);
        }
    }

    double ans=0.0;
    for(int i=(N+1)/2;i<=N;i++){
        ans+=dp[N][i];
    }

    printf("%.10f\n",ans);
}

Measured memory_bytes: 70656
#pragma GCC optimize ("O3")

#include <bits/stdc++.h>

using namespace std;

#ifdef LOCAL
#include <prettyprint.hpp>
#define debug(...)  cerr << "[" << #__VA_ARGS__ << "]: ", d_err(__VA_ARGS__);
#else
#define debug(...) 83;
#endif

void d_err() {
    cerr << endl;
}

template <typename H, typename... T>
void d_err(H h, T... t) {
    cerr << h << " ";
    d_err(t...);
}

#define ALL(x) (x).begin(), (x).end()
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define REP(i, n) FOR(i, 0, n)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define bcnt __builtin_popcountll

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef pair<ll,ll> Pll;
typedef pair<int,int> Pin;

ll INF = 1e16;
int inf = 1e9;
ll MOD = 1e9+7;

int main(){
    cin.tie(0);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(20);
    
    ll N, L, T;
    cin >> N >> L >> T;

    vector<ll> X(N), W(N);
    REP(i, N) cin >> X[i] >> W[i];

    vector<ll> Y(N);
    ll Y0;
    REP(i, N) {
        if (W[i] == 1) {
            Y[i] = (X[i] + T) % L;
        } else {
            Y[i] = ((X[i] - T) % L + L) % L;
        }

        if (i == 0) Y0 = Y[i];
    }

    sort(ALL(Y));

    ll cnt = 0;
    FOR(i, 1, N) {
        if (W[0] == W[i]) continue;

        if (W[0] == 1) {
            if (T * 2 < abs(X[i] - X[0])) continue;

            ll remain = T * 2 - abs(X[i] - X[0]);
            cnt += 1 + remain / L;

        } else {
            if (T * 2 < L - abs(X[i] - X[0])) continue;

            ll remain = T * 2 - L + abs(X[i] - X[0]);
            cnt -= 1 + remain / L;
        }
    }

    debug(cnt)

    cnt = (cnt % N + N) % N;


    int idx = -1;
    REP(i, N) if (Y[i] == Y0) {
        idx = i;
        if (W[0] == 2) break;
    }

    debug(cnt, idx)
    cnt = ((idx - cnt) % N + N) % N;

    FOR(i, cnt, N) cout << Y[i] << endl;
    FOR(i, 0, cnt) cout << Y[i] << endl;

}


Measured memory_bytes: 3584
//============================================================================
// Name        : JOI.cpp
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================

#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <math.h>
#include <stdio.h>
#include <vector>
using namespace std;
typedef long long ll;
int N;
ll A[201];
int main() {
	cin>>N;
	ll R;
	ll L;
	ll ans=1000000000;
	for(int i=0;i<N;i++){
		cin>>A[i];
		L=0;
		R=A[i];
		while(R>1){
			if(R%2==0){
				R=R/2;
				L++;
			}
			if(R%2!=0){
				ans=min(ans,L);
				break;
			}
		}
	}


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


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

using namespace std;

const int MAX_N = 2e5 + 200;

int n, head[MAX_N], current, up[MAX_N];
bool tag[MAX_N];

struct edge
{
    int to, nxt;
} edges[MAX_N << 1];

void addpath(int src, int dst)
{
    edges[current].to = dst, edges[current].nxt = head[src];
    head[src] = current++;
}

int max_dist, pt;

void dfs(int u, int fa, int dep)
{
    if (max_dist < dep)
        pt = u, max_dist = dep;
    up[u] = fa;
    for (int i = head[u]; i != -1; i = edges[i].nxt)
        if (edges[i].to != fa)
            dfs(edges[i].to, u, dep + 1);
}

int main()
{
    memset(head, -1, sizeof(head));
    scanf("%d", &n);
    for (int i = 1, u, v; i <= n - 1; i++)
        scanf("%d%d", &u, &v), addpath(u, v), addpath(v, u);
    int A, B;
    dfs(1, 0, 0), max_dist = 0, A = pt, dfs(pt, 0, 0), B = pt;
    if ((max_dist + 1) % 3 == 2)
        puts("Second");
    else
        puts("First");
    return 0;
}

Measured memory_bytes: 17696
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << x << endl;


#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 10000


int main(){
  ll n,x;
  ll ans = 0;
  
  scanf("%lld%lld",&n,&x);

  ans = n;
  n = n-x;
  ll last = x;
  
  while(x > 0){
	cerr << n << " " << x << endl;

	last = x;
	
	ans += n/x * x * 2;
	
	ll t = n%x;
	n = x;
	x = t;
  }

  ans -= last;

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


Measured memory_bytes: 256
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int dy[4] = {0,0,1,-1};
int dx[4] = {1,-1,0,0};
map<vector<int>, int> mp;
void init(vector<int> v) {
  queue<vector<int> > que;
  que.push(v);
  while(!que.empty()) {
    vector<int> cur = que.front(); que.pop();
    int idx = 0;
    FOR(i,0,8) {
      if(cur[i] == 0) {
        idx = i;
        break;
      }
    }
    int dist = mp[cur];

    FOR(k,0,4) {
      int nx = idx % 4 + dx[k];
      int ny = idx / 4 + dy[k];
      if(nx < 0 || nx >= 4 || ny < 0 || ny >= 2) continue;
      vector<int> nv = cur;
      swap(nv[idx], nv[ny * 4 + nx]);
      if(mp.count(nv) == 0) {
        mp[nv] = dist + 1;
        que.push(nv);
      }
    }
  }
}
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  vector<int> v;
  FOR(i,0,8) v.push_back(i);
  mp[v] = 0;
  init(v);
  string s;
  while(getline(cin, s)) {
    stringstream ss(s);
    int val;
    vector<int> v2;
    while(ss>>val) v2.push_back(val);
    cout << mp[v2] << endl;
  }
  return 0;
}

Measured memory_bytes: 5644
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define endl "\n"
#define pb push_back
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<n;i++)
#define per(i,n) for(ll i=n-1;i>=0;i--)
#define rep1(i,n) for(ll i=1;i<=n;i++)
#define per1(i,n) for(ll i=n;i>=1;i--)
const int N = 1e5;
ll par[N], sz[N], ans[N];
ll fp(ll x)
{
    if(par[x] == x)
        return x;
    return par[x] = fp(par[x]);
}
void _u(ll x, ll y)
{
    x = fp(x);
    y = fp(y);
    if(x == y)
        return;
    par[x] = y;
    sz[y] += sz[x];
}
void solve()
{
    ll i, j, n, m, k, x, y;
    cin >> n >> m >> k;
    rep1(i, n)
    par[i] = i, sz[i] = 1;
    rep1(i, m)
    {
        cin >> x >> y;
        ans[x]--;
        ans[y]--;
        _u(x, y);
    }

    rep1(i, k)
    {
        cin >> x >> y;
        if(fp(x) == fp(y))
            ans[x]--, ans[y]--;
    }
    rep1(i, n)
    cout << ans[i] - 1 + sz[fp(i)] << " ";





}

int main()
{


    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int t = 1;
    //    cin >> t;
    while(t--)
    {
        solve();
        cout << endl;
    }

}




Measured memory_bytes: 3840
#include <bits/stdc++.h>
#define ll long long
#define f(i, a, b) for(ll i=a; i<b; i++)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using namespace std;
ll findSubarraySum(ll arr[], ll n, ll sum = 0) 
{
    unordered_map<ll, ll> prevSum;
    ll res = 0;
    ll currsum = 0;
    for (ll i = 0; i < n; i++)
    {
        currsum += arr[i];
        if (currsum == sum) res++;
        if (prevSum.find(currsum - sum) != prevSum.end()) res += (prevSum[currsum - sum]);
        prevSum[currsum]++;
    }
    return res; 
} 
ll gcd(ll a, ll b) 
{ 
    if (a == 0) 
        return b; 
    return gcd(b % a, a); 
} 
  
ll findGCD(ll arr[], ll n) 
{ 
    ll result = arr[0]; 
    for (ll i = 1; i < n; i++)
        result = gcd(arr[i], result); 
  
    return result; 
} 
ll powmp(ll x, ll y, ll p) 
{ 
    ll res = 1;     x = x % p;   
    while (y > 0) 
    {  
        if (y & 1)  res = (res*x) % p; 
        y = y>>1; 
        x = (x*x) % p;   
    } 
    return res; 
} 

int main()
{
    ios_base::sync_with_stdio(false); 
    cin.tie(NULL);
    ll n,p; cin>>n>>p;
    ll x=n-2*p;
    if(x>=0) cout<<x;
    else cout<<'0';
}


Measured memory_bytes: 892
#include <bits/stdc++.h>
#define ALL(a)  (a).begin(),(a).end()

using namespace std;
int main(){
  int h,w,k,i,j;
  cin >> h >> w >> k;
  vector<vector<char>> A(h,vector<char>(w));
  for(i=0;i<h;i++){
  	for(j=0;j<w;j++){
      cin>>A.at(i).at(j);
    }
  }
  vector<vector<int>> ans(h,vector<int>(w));
  int n=1,m;
  for(i=0;i<h;i++){
    if(find(ALL(A.at(i)), '#')==A.at(i).end()){
      for(j=0;j<w;j++){
      	ans.at(i).at(j)=ans.at((i==0?1:i-1)).at(j);
      }
    }
    else{
      m=n;
      for(j=0;j<w;j++){
        if(A.at(i).at(j)=='#'){
      	  n=m;
          m++;
        }
        ans.at(i).at(j)=n;
      }
      n++;
    }
  }
  
  for(i=h-2;i>=0;i--){
    if(find(ALL(A.at(i)), '#')==A.at(i).end()){
      for(j=0;j<w;j++){
        ans.at(i).at(j)=ans.at(i+1).at(j);
      }
    }
  }
  
  
  for(i=0;i<h;i++)for(j=0;j<w;j++)cout<<ans.at(i).at(j)<<(j==w-1?'\n':' ');
  return 0;
}

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

def RD(): return sys.stdin.read()
def II(): return int(input())
def MI(): return map(int,input().split())
def LI(): return list(map(int,input().split()))
def TI(): return tuple(map(int,input().split()))


def main():
    N, M = MI()
    A = LI()
    sumA = sum(A)
    ans = N - sumA
    if ans<0:
        print(-1)
    else:
        print(ans)



if __name__ == "__main__":
	main()

Measured memory_bytes: 68072