akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
class UnionFind
{
public:
    vector<int> Parent;
    UnionFind(int N)
    {
        Parent = vector<int>(N, -1);
    }
    int root(int A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = root(Parent[A]);
    }

    int size(int A)
    {
        return -Parent[root(A)];
    }
    bool connect(int A, int B)
    {
        A = root(A);
        B = root(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

        Parent[A] += Parent[B];
        Parent[B] = A;

        return true;
    }
};
/*
vector<int> tomo[200005],block[200005];
vector<bool> seen(200005);
int cnt;
void dfs(int v){
    seen[v] = true;
    for(auto p:tomo[v]){
        if(seen[p])
            continue;
        cnt++;
        dfs(p);
    }
}
*/
int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<int> a(m), b(m);
    vector<int> c(k), d(k);
    vector<int> con(n),con2(n);
    UnionFind uf(n);
    rep(i,m){
        cin >> a[i] >> b[i];
        a[i]--;
        b[i]--;
        uf.connect(a[i], b[i]);
        con[a[i]]++;
        con[b[i]]++;
        /*
        tomo[a[i]].push_back(b[i]);
        tomo[b[i]].push_back(a[i]);
        */
    }
    rep(i,k){
        cin >> c[i] >> d[i];
        c[i]--;
        d[i]--;
        if(uf.root(c[i]) == uf.root(d[i])){
        con[c[i]]++;
        con[d[i]]++;
    }
    }
    int cnt;
    rep(i, n)
    {
        cnt = uf.size(i)-1;
        cnt -= con[i];
        cout << cnt << " ";
    }
    cout << endl;
}

Measured memory_bytes: 3584
using System;
using System.Collections.Generic;
using System.Linq;

class Program
{
    static void Main(string[] args)
    {
        int N = int.Parse(Console.ReadLine());
        int[] A = new int[N];

        int maxValue = 1;
        int secondMaxValue = 0;

        for(int i = 0; i < N; i++) {
            int currentValue = int.Parse(Console.ReadLine());
            A[i] = currentValue;

            if(maxValue < currentValue) {
                secondMaxValue = maxValue;
                maxValue = currentValue;

            } else if(secondMaxValue < currentValue) {
                secondMaxValue = currentValue;
            
            }
        }

        for(int i = 0; i < N; i++) {
            if (A[i] == maxValue) {
                Console.WriteLine(secondMaxValue);
            
            }
            else {
                Console.WriteLine(maxValue);
            
            }

        }
    }
}

Measured memory_bytes: 17108
//#include<bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<numeric>
#include<vector>
#include<set>
#include<map>
#include<unordered_map>
#include<stack>
#include<queue>
#include<list>
using namespace std;

typedef long long ll;

#define MOD 1000000007

class Comb{
public:
  ll *fac,*finv,*inv;
  Comb(){
    fac = new ll[1000001];
    finv = new ll[1000001];
    inv = new ll[1000001];
    fac[0] = 1;
    for(int i=1;i<1000001;i++){
      fac[i] = i*fac[i-1];
      fac[i] %= MOD;
    }
    inv[1] = 1;
    for(int i=2;i<1000001;i++){
      inv[i] = MOD-inv[MOD%i]*(MOD/i)%MOD;
    }
    finv[0] = 1;
    for(int i=1;i<1000001;i++){
      finv[i] = inv[i]*finv[i-1];
      finv[i] %= MOD;
    }
  }
  ll calc(ll n,ll k){
    ll c = fac[n];
    c *= finv[k];c %= MOD;
    c *= finv[n-k];c %= MOD;
    return c;
  }
};

int main(){
  ll n;
  cin >> n;
  string s;
  cin >> s;
  set<int> table[26];
  for(int i=0;i<n;i++){
    int index = s[i]-'a';
    table[index].insert(i+1);
  }

  int q;
  cin >> q;
  int type;
  vector<int> ansL;
  for(int i=0;i<q;i++){
    cin >> type;
    if(type == 1){
      int l;
      char c;
      cin >> l >> c;
      if(s[l-1] == c) continue;
      int num = c - 'a';
      int beforeNum = s[l-1]-'a';
      table[beforeNum].erase(l);
      table[num].insert(l);
      s[l-1] = c;
      continue;
    }
    int l,r;
    cin >> l >> r;
    int ans = 0;
    for(int j=0;j<26;j++){
      auto itr = table[j].lower_bound(l);
      if(itr == table[j].end() || *itr > r) continue;
      ans++;
    }
    ansL.push_back(ans);
  }
  for(int i=0;i<ansL.size();i++){
    cout << ansL[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 24452
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.Map;
import java.util.StringTokenizer;
import java.util.TreeMap;

public class Main {

	public static void main(String[] args) throws IOException {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		TaskX solver = new TaskX();
		solver.solve(1, in, out);
		out.close();
	}

	static class TaskX {
		public void solve(int testNumber, InputReader in, PrintWriter out) {

			int n = in.nextInt();
			System.out.println(n/3);

		}
	}

	static class ArrayUtils {
		public static Map<Integer, Integer> getCountMap(int[] array) {
			Map<Integer, Integer> map = new TreeMap<>();
			for (int x : array)
				map.merge(x, 1, Integer::sum);
			return map;
		}
	}

	static class InputReader {
		BufferedReader in;
		StringTokenizer tok;

		public String nextString() {
			while (!tok.hasMoreTokens()) {
				try {
					tok = new StringTokenizer(in.readLine(), " ");
				} catch (IOException e) {
					throw new InputMismatchException();
				}
			}
			return tok.nextToken();
		}

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

		public long nextLong() {
			return Long.parseLong(nextString());
		}

		public int[] nextIntArray(int n) {
			int[] res = new int[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextInt();
			}
			return res;
		}

		public long[] nextLongArray(int n) {
			long[] res = new long[n];
			for (int i = 0; i < n; i++) {
				res[i] = nextLong();
			}
			return res;
		}

		public InputReader(InputStream inputStream) {
			in = new BufferedReader(new InputStreamReader(inputStream));
			tok = new StringTokenizer("");
		}

	}

}


Measured memory_bytes: 20052
fun main(args :Array<String>) {
    val n = readInteger()
    val aArray = readLongList().toLongArray()
    val y1 = aArray.reduceIndexed { index, acc, a ->
        if (index % 2 == 0) acc + a else acc - a
    }

    val yArray = LongArray(n)
    yArray[0] = y1
    for (i in 1 until n) {
        yArray[i] = 2 * aArray[i - 1] - yArray[i - 1]
    }
    println(yArray.joinToString(" "))
}

fun readInteger() = readLine()!!.toInt()
fun readStringList() = readLine()!!.split(" ")
fun readIntegerList() = readStringList().map(String::toInt)
fun readLongList() = readStringList().map(String::toLong)


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

using namespace std;

int main() {
	long long n;
	int x, m;
	cin >> n >> x >> m;

	vector<int> cir;	
	int cur = x;
	vector<bool> vis(m);
	int start = -1;
	long long ans = 0;
	long long sum = 0;
	while(n > 0) {
		if(cur == 0) {
			cout << ans << '\n';
			exit(0);
		}
		if(vis[cur]) {
			start = cur; 
			break;
		}
		n -= 1;
		ans += cur;
		vis[cur] = true;
		cur = 1LL * cur * cur % m;
	}

	if(n == 0) {
		cout << ans << '\n';
		exit(0);
	}

	for(int i = 0; i < m; ++i) {
		vis[i] = false;
	}
	while(!vis[start]) {
		cir.emplace_back(start);
		vis[start] = true;
		sum += start;
		start = 1LL * start * start % m;
	}

	int s = cir.size();
	ans += n / s * sum;
	for(int i = 0; i < n % s; ++i) {
		ans += cir[i];
	}

	cout << ans << '\n';

	return 0;
}

Measured memory_bytes: 3724
#include<iostream>
using namespace std;
int main(){
  int n,k;
  while(cin >>n>>k,n||k){
    int log[100]={0},nlog[100]={0},c,ans=0;
    for(int i=0; i<n; i++){cin >>log[i];}
    int x = 1;
    for(int i=0; i<k; i++){x*=log[i];}
    c = x;
    for(int i=k; i<n; i++){
      x = x*log[i]/log[i-k];
      if(c<x){c = x;}
    }
    for(int i=0; i<n; i++){
      for(int j=i+1; j<n; j++){
	for(int r=0; r<n; r++){
	  if(r == i){nlog[r] = log[j];}
	  else if(r == j){nlog[r] = log[i];}
	  else{nlog[r] = log[r];}
	}
	int f = 1;
	for(int r=0; r<k; r++){f*=nlog[r];}
	if(ans<f){ans = f;}
	for(int r=k; r<n; r++){
	  f = f*nlog[r]/nlog[r-k];
	  if(ans<f){ans = f;}
	}
      }
    }
    if(c<=ans){cout <<ans-c<<endl;}
    else{cout <<"NO GAME"<<endl;}
  }
  return 0;
}

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

int main(void) {
    int n, v[2][100010] = {};
    cin >> n;
    for (int i = 0; i < n / 2; ++i) {
        int ve, vo;
        cin >> ve >> vo;
        ++v[0][ve];
        ++v[1][vo];
    }
    int ce, co, o1, o2, e1, e2;
    o1 = o2 = e1 = e2 = 0;
    for (int i = 1; i < 100005; ++i) {
        if (v[0][i] >= e1) {
            e1 = v[0][i];
            ce = i;
        }
        if (v[1][i] >= o1) {
            o1 = v[1][i];
            co = i;
        }
    }
    for (int i = 1; i < 100005; ++i) {
        if (i != ce && v[0][i] >= e2) {
            e2 = v[0][i];
        }
        if (i != co && v[1][i] >= o2) {
            o2 = v[1][i];
        }
    }
    int ans;
    if (ce != co) {
        ans = n - e1 - o1;
    } else {
        ans = n - max(e2 + o1, e1 + o2);
    }
    cout << ans << "\n";
}


Measured memory_bytes: 1024
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <list>
#include <cmath>
#include <iomanip>
#include <stack>
#include <string>
#include <map>

using namespace std;

int main()
{
	int A, B, C;
	cin >> A >> B >> C;
	if(A*C<=B)
		cout << C << endl;
	else
	cout << B/A	 << endl;

	return 0;
}

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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a<b)?(a=b,1):0;}
template<class T>bool chmin(T &a, const T &b) { return (b<a)?(a=b,1):0;}

using ll=long long;
using R=long double;
const R EPS=1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r){return(r > EPS)-(r < -EPS);}
inline R sq(R x){return sqrt(max(x,0.0L));}

const int dx[8]={1,0,-1,0,1,-1,-1,1};
const int dy[8]={0,1,0,-1,1,1,-1,-1};

const pid_t pid = getpid();
// Problem Specific Parameter:

const int limit = 100010;
vector<int> graph[limit];

// Description: 素集合を管理するデータ構造
// TimeComplexity: 初期化$\mathcal{O}(n)$ 更新$\mathcal{O}(\log n)$
// Verifyed: AOJ DSL_1_A

struct Union_find {
	Union_find(int n) {data.assign(n, -1);}
	int find(int x) {return (data[x] < 0) ? x : data[x] = find(data[x]);}
	void unite(int a, int b) {
		a = find(a), b = find(b);
		if (a != b) {
			if (data[a] < data[b]) swap(a, b);
			data[a] += data[b], data[b] = a;
		}
	}
	bool same(int a, int b) {return find(a) == find(b);}
	int size(int x) {return -data[x];}
	vector<int> data;
};


int main(void){
	int n,m;
	cin >> n >> m;

	rep(i, m){
		int a,b;
		cin >> a >> b;
		a--, b--;
		graph[a].push_back(b);
		graph[b].push_back(a);
	}	

	vector<int> deg(n, 0);

	rep(v, n) {
		deg[v] = graph[v].size();
		if(deg[v] %2 == 1) {
			puts("No");
			return 0;
		}
	}

	Union_find uf(n);
	rep(v, n){
		for(auto &v2:graph[v]){
			if(deg[v] == 2 and deg[v2] == 2){
				uf.unite(v, v2);
			}
		}
	}

	int six_over = 0, four = 0;
	rep(v, n){
		if(deg[v] >=6) six_over++;
		if(deg[v] == 4) four++;
	}

	if(six_over >= 1 or four >= 3){
		puts("Yes");
		return 0;
	}

	if(four <= 1){
		puts("No");
		return 0;
	}

	bool ok = false;
	rep(v, n){
		if(deg[v] == 4){
			set<int> adj;
			for(auto &v2:graph[v]){
				adj.insert(uf.find(v2));
			}
			if(adj.size() < 4) ok = true;
		}
	}

	if(ok){
		puts("Yes");
	} else {
		puts("No");
	}

	return 0;
}

Measured memory_bytes: 6528
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<climits>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<numeric>
#include<map>
#include<set>
#define REP(i,m,n) for(int i = m; i < n; i++)
#define rep(i,n) REP(i,0,n)
#define ALL(a)  (a).begin(),(a).end()
#define LL long long
template<class T> void chmax(T & a, T b) { if (a < b) { a = b; } }
template<class T> void chmin(T& a, T b) { if (a > b) { a = b; } }
using namespace std;

const long long LLINF = 1LL << 60;

int main(void) {
	LL N, W;
	cin >> N >> W;
	vector<LL> weight(110), value(110);
	for (int i = 0; i < N; ++i) cin >> weight[i] >> value[i];

	// DPテーブル
	vector<vector<LL> > dp(110, vector<LL>(100100, LLINF));
	//最小化していくDPなのでデカい値で初期化

	// 初期条件
	dp[0][0] = 0;

	// DPループ
	for (int i = 0; i < N; ++i) {
		for (int sum_v = 0; sum_v < 100100; ++sum_v) {
			if (sum_v >= value[i]) {
				dp[i + 1][sum_v] = min(dp[i][sum_v], dp[i][sum_v - value[i]] + weight[i]);
			}
			else {
				dp[i + 1][sum_v] = dp[i][sum_v];
			}
		}
	}

	// 最適値の出力
	LL res = 0;
	for (int sum_v = 0; sum_v < 100100; ++sum_v) {
		if (dp[N][sum_v] <= W) {
			res = sum_v;
		}
	}
	cout << res << endl;
}

Measured memory_bytes: 87296
#include<iostream>
#include<algorithm>
using namespace std;
long dp[41][2];
int n;
long k,a[1<<17];
main()
{
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	for(int i=0;i<=40;i++)for(int j=0;j<2;j++)dp[i][j]=-9e18;
	dp[0][1]=0;
	for(int i=0;i<40;i++)
	{
		for(int j=0;j<2;j++)
		{
			int l=j?(k>>39-i)&1:1;
			for(int x=0;x<=l;x++)
			{
				long now=0;
				for(int I=0;I<n;I++)now+=((a[I]>>39-i)&1)^x;
				now<<=39-i;
				dp[i+1][j&&x==l]=max(dp[i+1][j&&x==l],dp[i][j]+now);
			}
		}
	}
	cout<<max(dp[40][0],dp[40][1])<<endl;
}

Measured memory_bytes: 1024
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.PrintWriter;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) throws Exception {
        try (BufferedInputStream in = new BufferedInputStream(System.in);
             PrintWriter out = new PrintWriter(new BufferedOutputStream(System.out))) {

            Scanner sc = new Scanner(in);

            // 10:16-

            int n = sc.nextInt();
            int d = sc.nextInt();
            int[][] vs = new int[n][d];

            for (int i = 0; i < n; i++) {
                for (int j = 0; j < d; j++) {
                    vs[i][j] = sc.nextInt();
                }
            }

            int pairs = 0;
            for (int i = 0; i < n; i++) {
                for (int j = i + 1; j < n; j++) {
                    if (iseven(dist(vs[i], vs[j]))) {
                        pairs++;
                    }
                }
            }

            out.println(pairs);
        }
    }

    private static boolean iseven(double val) {
        return val - (int) val == 0;
    }

    private static double dist(int[] a, int[] b) {
        double sum = 0.0;
        for (int i = 0; i < a.length; i++) {
            int t = a[i] - b[i];
            sum += t * t;
        }
        return Math.sqrt(sum);
    }
}


Measured memory_bytes: 21716
/*@author hussein zayed ;
    ___  ___
   |\  \|\  \
   \ \  \_\  \
    \ \   ___ \USSEIN
     \ \  \\ \ \
      \ \__\\ \_\
       \|__| \|__|
****************************************
*/

#include <bits/stdc++.h>
using namespace std;
#define fr for(int i=0;i<n;++i)
#define fr1 for(int i=1;i<=n;++i)
#define cinA for(int i=0;i<n;++i){cin>>arr[i];}
#define cinA1 for(int i=1;i<=n;++i){cin>>arr[i];}
#define coutA for(int i=0;i<n;++i){cout<<arr[i]<<" ";}
#define ll long long
#define lnarray sizeof(arr)/sizeof(*arr)
#define vi vector<int>
#define vs vector<string>
void Fast()
{
    ios_base :: sync_with_stdio( 0 ) ;
    cin.tie( 0 ) ;
    cout.tie( 0 ) ;
}
inline int RD()
{
    int i ;
    cin>>i;
    return i;
}

inline float RF()
{
    float i ;
    cin>>i;
    return i;
}

inline double RDO()
{
    double i ;
    cin>>i;
    return i;
}

inline string RS()
{
    string i ;
    cin>>i;
    return i;
}

inline ll RLL()
{
    ll i ;
    cin>>i;
    return i;
}



ll sumSet(ll n)
{
    return (1ll*n*(n+1))/2;
}
string s;


bool isPrime(ll n)
{
    if(n==1)
        return false;
    for(ll i=2; i*i<=n; ++i)
    {
        if(n%i==0)
            return false;
    }
    return true;
}
int sumDigit(int n){
int sum =0;
  while (n != 0)
    {
        sum+=  n % 10;
        n = n / 10;
    }
    return sum;
}

ll power2(int n){
  ll ans=(1<<n);
  return ans;
}

ll sumpow2(ll n){
 ll sum=(n*(n+1)*(2*n-1))/6;
 return sum;
}

int main(){
    Fast();
//freopen("output.txt" , "w" , stdout);
//freopen("wall.in" , "r" , stdin);
int n=RD(),arr[n+2],arr1[n+2],cont=0;
fr{
cin>>arr[i];
arr1[i]=arr[i];
}
sort(arr,arr+n);
fr{
 if(arr[i]!=arr1[i])
 cont++;
}
if(cont>2)
cout<<"NO\n";
else
cout<<"YES\n";
}


Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
#include <array>
#include <string>
#include <utility>
#include <vector>

#include <atcoder/maxflow>

constexpr std::array<std::pair<int, int>, 4> dij{{{-1, 0}, {0, -1}, {1, 0}, {0, 1}}};

int main() {
  int n, m;
  scanf("%d %d", &n, &m);

  std::vector<std::string> s(n);
  char buf[131072];
  for (auto& si: s) {
    scanf("%s", buf);
    si = buf;
  }

  atcoder::mf_graph<int> mf(n*m + 2);
  int source = n*m;
  int sink = source+1;
  auto enc = [&](int i, int j) { return i*m + j; };
  auto dec = [&](int e) -> std::pair<int, int> { return {e/m, e%m}; };
  for (int i = 0; i < n; ++i) {
    for (int j = 0; j < m; ++j) {
      if (s[i][j] == '#') continue;
      if ((i+j) % 2 == 0) {
        // fprintf(stderr, "SOURCE -> (%d, %d)\n", i, j);
        mf.add_edge(source, enc(i, j), 1);
      } else {
        mf.add_edge(enc(i, j), sink, 1);
        // fprintf(stderr, "(%d, %d) -> SINK\n", i, j);
        continue;
      }
      for (auto const& [di, dj]: dij) {
        int ni = i + di;
        int nj = j + dj;
        if (!(0 <= ni && ni < n && 0 <= nj && nj < m)) continue;
        if (s[ni][nj] == '#') continue;
        // fprintf(stderr, "+ (%d, %d) -> (%d, %d)\n", i, j, ni, nj);
        mf.add_edge(enc(i, j), enc(ni, nj), 1);
      }
    }
  }

  int f = mf.flow(source, sink);
  printf("%d\n", f);

  auto es = mf.edges();

  for (auto const& e: es) {
    if (e.flow == 0) continue;
    if (e.from == source || e.to == sink) continue;
    auto [i, j] = dec(e.from);
    auto [ni, nj] = dec(e.to);
    if (i == ni) {
      // ><
      auto [jl, jr] = std::minmax(j, nj);
      s[i][jl] = '>';
      s[i][jr] = '<';
    } else {
      // v^
      auto [il, ir] = std::minmax(i, ni);
      s[il][j] = 'v';
      s[ir][j] = '^';
    }
  }

  for (auto const& si: s) printf("%s\n", si.data());
}


Measured memory_bytes: 5188
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>

using namespace std;
#define int long  long int
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

signed main()
{
	int A, B, K;
	cin >> A >> B >> K;
	if (A >= K)
	{
		A = A - K;
	}
	else
	{
		B = B - (K - A);
		A = 0;
	}
	if (B < 0)B = 0;
	cout << A << " " << B;
}

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

int64_t n,a,b,c,A,B;

int main()
{
    cin>>a>>b>>c>>B>>n;
    int64_t A=min(min(4*a,2*b),c);
    if(2*A<=B)
        cout<<n*A;
    else
        cout<<n/2*B+n%2*A;
}


Measured memory_bytes: 256
#pragma region
#include <bits/stdc++.h>
using namespace std;
inline void ci(void){
  return;
}
template <typename First, typename... Rest>
void ci(First& first, Rest&... rest){
  cin >> first;
  ci(rest...);
  return;
}
inline void co(void){
  cout << endl;
  return;
}
template <typename First, typename... Rest>
void co(First first, Rest... rest){
  cout << first << "";
  co(rest...);
  return;
}
#define ll long long
#define ld long double
#define st string
#define wh while
#define ve vector
#define mp make_pair
#define tp tuple
#define mt make_tuple
#define pb push_back
#define pof pop_front
#define pob pop_back
#define pf push_front
#define fr front
#define ft first
#define sc second
#define tos to_string
#define len length
#define rt return
#define br break
#define con continue
#define lcm(n, m) (n * m / __gcd(n, m))
#define np next_permutation
#define repi(i, m, n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i, n) repi(i, 0, n)
#define revi(i, m, n) for(int i=(int)(m) - 1;i>=(int)(n);i--)
#define rev(i, m) revi(i, m, 0)
#define sz(v) ((int)(v).size()) 
#define each(i, n) for(auto&& i: n)
#define all(n) n.begin(), n.end()
#define allr(n) n.rbegin(), n.rend()
#define sp(n) cout << fixed << setprecision(n)
#define pi 3.14159265358979323846
#define inf 1000000007
#pragma endregion
// sqrt ルート, int 2*10^9, gcd　最大公約数
// __builtin_popcount bitの個数

ve<int> dx = {0, 0, 1, -1}, dy = {1, -1, 0, 0};

int main() {
  int a, b, c, d, e;
  ci(a, b, c, d, e);
  co((c * 60 + d) - (a * 60 + b) -e);
}

Measured memory_bytes: 3628
#include <iostream>
#include <string>
#include <cstring>
#include <fstream>
#include <cmath>
#include <iomanip>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <map>
#include <deque>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <list>
#include <unordered_map>

using namespace std;

int main() {
   

    long long n,m,d;
    cin >> n >> m >> d;
    cout << fixed;
    cout << setprecision(12);
    if(d != 0){
        cout << 2.0*(n-d) / (n*n) * (m-1) << endl;
    }else{
        cout << 1.0 / n * (m-1) << endl;
    }
}

Measured memory_bytes: 256
#include<stdio.h>
#define N 8

#define NOT_FREE 1
#define FREE -1

int row[N];
int col[N];
int dpos[2*N-1];
int dneg[2*N-1];

int k;
int Q[N][N];
int Q_i;
int Q_j;


void initialize(){
  int i,j;

  for(i=0;i<N;i++){
    row[i]=FREE;
    col[i]=FREE;
  }
  
  for(i=0;i<2*N;i++){
    dpos[i]=FREE;
    dneg[i]=FREE;

  }


  
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
	Q[i][j]=FREE;
      }
    }
}

  void printBoard(){
    int i,j;

     for(i=0;i<N;i++){
      for(j=0;j<N;j++){
	if(Q[i][j]==NOT_FREE){
	  if(row[i]!=j)return;
	}
      }
      }

    
    for(i=0;i<N;i++){
      for(j=0;j<N;j++){
	if(row[i]==j)printf("Q");
	else printf(".");
      }
      printf("\n");
    }
  }



  void putQueen(int i){
    
    if ( i == N){
      
      printBoard();
      return;
    }
    
    for ( int j = 0; j < N; j++ ){

      //もしアタックされているならループをスキップ
      if ( col[j] == NOT_FREE || dpos[i+j] == NOT_FREE || dneg[i-j+N-1] == NOT_FREE ) continue;
      
      row[i] = j;
      col[j] = NOT_FREE;
      dpos[i+j] = NOT_FREE;
      dneg[i-j+N-1] = NOT_FREE;

	
        putQueen(i + 1);
	
        row[i] = FREE;
	col[j] = FREE;
	dpos[i+j] = FREE;
	dneg[i-j+N-1] = FREE;
	
    
    }
    
}

  

int main(){

  int a;
  int k;
  int Q_i;
  int Q_j;

  initialize();

  scanf("%d",&k);
  
  for(a=0;a<k;a++){
    scanf("%d%d",&Q_i,&Q_j);
    Q[Q_i][Q_j]=NOT_FREE;
   
  }
  
    putQueen(0);
    
    return 0;
}



Measured memory_bytes: 2112
import bisect, collections, copy, heapq, itertools, math, string, sys
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = float('inf')
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    S = [SS() for _ in range(N)]

    result = ('AC', 'WA', 'TLE', 'RE')
    cnt = collections.Counter(S)

    for i in result:
        print(i, 'x', cnt[i])

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 17280
#include <iostream>

typedef unsigned long long ull;
using namespace std;

int IntMax(int a, int b)
{
  return a > b ? a : b;
}

int GetNumDigits(int val)
{
  int count = 1;
  while (1)
  {
    if (val / 10)
    {
      val /= 10;
      count++;
    }
    else break;
  }
  return count;
}

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

  int min = 100;

  //loopイテレータを素数にする
  for (ull A = 1; A * A <= N; A++)
  {
    if (N % A != 0) continue;
    ull B = N / A;
    int currentNumDigits = IntMax(GetNumDigits(A), GetNumDigits(B));
    if (min > currentNumDigits) min = currentNumDigits;
  }

  std::cout << min << endl;
}


Measured memory_bytes: 256
/* ---------- STL Libraries ---------- */
// IO library
#include <cstdio>
#include <fstream>
#include <iomanip>
#include <ios>
#include <iostream>

// algorithm library
#include <algorithm>
#include <cmath>
#include <numeric>
#include <random>
#include <cstring>

// container library
#include <array>
#include <bitset>
#include <deque>
#include <map>
#include <unordered_map>
#include <queue>
#include <set>
#include <string>
#include <tuple>
#include <vector>
#include <stack>

/* ---------- Namespace ---------- */
using namespace std;

/* ---------- Type ---------- */
using ll = long long;
#define int ll
#define P pair<ll, ll>

/* ---------- Constants  */
const double PI = 3.141592653589793238462643383279;
const ll MOD = 1e9 + 7;
const int INF = 1LL << 55;

signed main() {
    int N;
    cin >> N;
    vector<string> strs(N);
    for (int i = 0; i < N; i++) cin >> strs[i];

    int a = 0;
    int b = 0;
    int B_start = 0;
    int A_end = 0;

    for (string str : strs) {
        if (str[0] == 'B' && str[str.size() - 1] != 'A') B_start++;
        if (str[str.size() - 1] == 'A' && str[0] != 'B') A_end++;
        if (str[0] == 'B' && str[str.size() - 1] == 'A') a++;

        for (int i = 0; i < str.size() - 1; i++) {
            if (str[i] == 'A' && str[i+1] == 'B') b++;
        }
    }

    if (A_end + B_start > 0) {
        cout << a + b + min(A_end, B_start) << endl;
    } else {
        cout << b + max(0LL, a - 1) << endl;
    }



    // cout << max(0LL, a - 1) + b + min(A_end, B_start) + (A_end != B_start && a > 0 ? 1 : 0) << endl;
    return 0;
}

Measured memory_bytes: 768
#include <cassert>

#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
//#include <boost/foreach.hpp>
//#include <boost/range/algorithm.hpp>
#define rep(i,j,k) for(int i=(int)j;i<(int)k;i++)
#define ll long long
#define Sort(v) sort(all(v))
#define INF 1e9
#define LINF 1e18
#define END return 0
#define pb push_back
#define se second
#define fi first
#define pb push_back
#define all(v) (v).begin() , (v).end()
#define MP make_pair
#define MOD 1000000007LL
#define int long long
using namespace std;
int day[12]={31,28,31,30,31,30,31,31,30,31,30,31};
struct edge{int to,cost;};
typedef pair<int,int> P;

bool isupper(char c){if('A'<=c&&c<='Z')return 1;return 0;}
bool islower(char c){if('a'<=c&&c<='z')return 1;return 0;}
bool isPrime(int x){if(x==1)return 0;if(x==2)return 1;if(x%2==0)return 0;for(int i=3;i*i<=x;i++)if(x%i==0)return 0;return 1;}
bool iskaibun(string s){for(int i=0;i<s.size()/2;i++)if(s[i]!=s[s.size()-i-1])return 0;return 1;}
void print(vector<int> v){
    cout<<endl;
    for(int i=0;i<v.size();i++)if(i==0)cout<<v[i];else cout<<" "<<v[i];
    cout<<endl;
}

struct S{
    int a[3];
};

signed main (){
    int n,h,w;cin>>n>>h>>w;
    cout<<(n-h+1)*(n-w+1)<<endl;
    


}
/*
*/


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

int main(){
    // int型で変数Mを宣言する
    int M;
    0 <= M && M <= 24;
    // 入力はcin>>を利用する
    cin >> M;
    // M時からの時間なので、30日では24-Mの時間分を31日分に足す
    int x = 48 - M ;
    // 問題のx時間は30日が31日に替わるまでの時間は48からM時を引けば算出できる
    cout << x << endl;
}

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

using namespace std;

const int maxN = (int)1E5+5;

vector<int> adj[maxN];
bool marked[maxN];
vector<int> path1, path2;
int n, m;

void goForward(int u, vector<int> &path) {
	for (bool found = true; found; ) {
		found = false;
		marked[u] = true;
		for (int i = 0, sz = adj[u].size(); i < sz; ++i) {
			int v = adj[u][i];
			if (!marked[v]) {
				path.push_back(v);
				u = v;
				found = true;
				break;
			}
		}
	}
}

int main() {
	scanf("%d %d", &n, &m);
	for (int i = 0; i < m; ++i) {
		int u, v;
		scanf("%d %d", &u, &v);
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	memset(marked, false, sizeof(marked));
	goForward(1, path1);
	goForward(1, path2);
	printf("%d\n", (int)path1.size()+(int)path2.size()+1);
	for (int i = path1.size()-1; i >= 0; --i)
		printf("%d ", path1[i]);
	printf("1 ");
	for (int i = 0, sz = path2.size(); i < sz; ++i)
		printf("%d ", path2[i]);
	puts("");
	return 0;
}

Measured memory_bytes: 6904
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>
#include <random>
#include <iomanip>

using namespace std;
typedef long long unsigned int ll;
typedef pair<int, int> P;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

// #define amari(x) ((x) % 1000000007)
#define amari(x) ((x) % 998244353)

#define fillInt(xs, x)        \
  for (int i = 0; i < (x); i++) \
    scanf("%d", &xs[i]);
#define fillLong(xs, x)       \
  for (int i = 0; i < (x); i++) \
    scanf("%ld", &xs[i]);
#define fillString(xs, x)       \
  for (int i = 0; i < (x); i++) \
    cin >> xs[i];
#define sortv(xs) sort(xs.begin(), xs.end())
#define sortvdi(xs) sort(xs.begin(), xs.end(), std::greater<int>())
#define lbv(xs, x) lower_bound(xs.begin(), xs.end(), x) - xs.begin()
#define ubv(xs, x) upper_bound(xs.begin(), xs.end(), x) - xs.begin()
#define bs(xs, x) binary_search(xs.begin(), xs.end(), x)

#define rep(i,n) for(long i=0; i<(n); i++)
#define isValidPoint(x, y, mx, my) x >= 0 && x  < mx && y >= 0 && y < my

int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};

struct Pony
{
    long u, v, w;

    Pony(long u_, long v_, long w_)
    {
        u = u_;
        v = v_;
        w = w_;
    }

    bool operator<(const Pony &another) const
    {
        return u < another.u || (u == another.u && v < another.v);
    };
};

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

  int a,b;

  cin >> a >> b;

  if (a >= 13) {
    cout << b << endl;
  } else if (a >= 6) {
        cout << b/2 << endl;
  } else {
            cout << 0 << endl;
  }

}


Measured memory_bytes: 888
import java.util.Scanner

object Main extends App {
  val sc = new Scanner(System.in)
  val x = sc.nextLong
  val ans = if (x == 0) 0 else {
    val (d, m) = (x / 11L, x % 11L)
    d * 2L + (m match {
      case mm if mm > 6 => 2
      case mm if mm == 0 => 0
      case _ => 1
    })
  }
  println(ans)
}


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

int main( void )
{
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    
    ll ans = max(a*b,c*d);
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>
int main(void){
    // Your code here!
    long S,r;
    long sq,sa,x,y,yy;
    long Xa,Ya,Xb,Yb,Xc,Yc;
    
    scanf("%ld\n",&S);
    
    sq = sqrt(S);
    
    //printf("%ld %ld\n",sq,sa);
    int i,j;
    int flag=0;
    for(i=0;S>=i;i++){
        y = i;
        sa = (sq+i)*(sq+i) - S;
        if(sa==0) {x=0;yy=0;break;}
        for(j=1;sa>=j;j++){
            yy = j;
            if(sa%j==0){
                if(j==0) x = 0;
                else     x = sa/j;
                if(x<=1000000000){
                    flag = 1;
                    break;
                }
            }
        }
        if (flag==1) break;
    }
    //y = -1;
    //x = sa;
    
    Xa = 0;
    Ya = 0;
    Xb = x;
    Yb = sq+y;
    Xc = sq+y;
    Yc = yy;
    
    printf("%ld %ld %ld %ld %ld %ld\n",Xa,Ya,Xb,Yb,Xc,Yc);
    
    //確認
    //r = -(Xb-Xa)*(Yc-Ya)+(Xc-Xa)*(Yb-Ya);
    //printf("%ld\n",r);
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int N=1e3+5,M=2e4+5,inf=0x3f3f3f3f,mod=1e9+7;
#define mst(a,b) memset(a,b,sizeof a)
#define lx x<<1
#define rx x<<1|1
#define reg register
#define PII pair<int,int>
#define fi first
#define se second
#define pb push_back
#define il inline
int main(){
	int a,b,c,d;
	cin>>a>>b>>c>>d;
	if(a*b>=c*d) cout<<a*b;
	else cout<<c*d;
	return 0;
}

Measured memory_bytes: 3584
#pragma GCC target("avx2")
#pragma GCC optimize("03")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std; typedef long double ld; typedef long long ll;
typedef unsigned long long ull;
#define endl "\n"
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define rep(i,n) for(int i=0;i<(n);i++)
#define PII pair<int, int>
#define PLL pair<ll, ll>
#define ALL(x) (x).begin(), (x).end()
constexpr int INF=1<<30; constexpr ll LINF=1LL<<60; constexpr ll mod=1e9+7; constexpr int NIL = -1;
template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }
template<class T>inline int popcount(T a) {return __builtin_popcount(a);}
template<class T>inline T emod(T a, T p) { return (a%p + p) % p;}
//-------------------
constexpr int MX = 3003;
ll d[MX][MX];
ll dp[MX][MX][4];
int main() {
    cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15);
    int r,c,k; cin >> r >> c >> k;

    rep(_,k) {
        int r1,c1; ll v1; cin >> r1 >> c1 >> v1;
        d[r1-1][c1-1] = v1;
    }

    rep(i,r) {
        rep(j, c) {
            for(int idx=2; idx>=0; idx--) chmax(dp[i][j][idx+1], dp[i][j][idx]+d[i][j]);
            rep(idx, 4) chmax(dp[i][j+1][idx], dp[i][j][idx]);
            rep(idx, 4) chmax(dp[i+1][j][0], dp[i][j][idx]);
        }
    }
    ll ans = 0;
    rep(i, 4) chmax(ans, dp[r-1][c-1][i]);
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 355616
def read_int():
    return int(input())

def read_int_map():
    return map(int,input().split(' '))

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

def read_s_list_loop(n):
    return [input() for _ in range(n)]

N,M,Q = read_int_map()
ans_map = {}

abcd_list = []
for i in range(Q):
    abcd_list.append(read_int_list())

abcd_list.sort(key=lambda x:(x[0],x[1]))

for abcd in abcd_list:
    a,b,c,d = map(int,abcd)

import copy
import sys
sys.setrecursionlimit(36288000)
all_list = []
def make_list(current=1,n=10,m=10,current_list=[],cnt=0):
    cnt += 1
    for i in range(current,m):
        tmp = copy.deepcopy(current_list)
        tmp.append(i)
        if cnt == n:
            global all_list
            all_list.append(tmp)
        else:
            make_list(i,n,m,tmp,cnt)
make_list(current=1,n=N,m=M+1,current_list=[],cnt=0)
ans = 0
for An in all_list:
    tmp = 0
    for abcd in abcd_list:
        a,b,c,d = map(int,abcd)
        if An[b-1] - An[a-1] == c:
            tmp += d
    ans = max(tmp,ans)
print(ans)

Measured memory_bytes: 106248
#include<iostream>
#include<vector>
#include<map>
using namespace std;

int main(){
    int h,w;
    cin >> h >> w;
    char pic[h][w];

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> pic[i][j];
        }
    }

    for(int i=0;i<h+2;i++){
        for(int j=0;j<w+2;j++){
            if(i==0 || i==h+1 || j==0 || j==w+1){
                cout << '#';
            }else{
                cout << pic[i-1][j-1];
            }
        }
        cout << endl;
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define lli long long
#define all(i) i.begin(),i.end()
#define rall(i) i.rbegin(),i.rend()
#define rep0(i,j) for(int i=0;i<j;i++)
#define rep1(i,j) for(int i=1;i<=j;i++)
#define rep0d(i,j) for(int i=j-1;i>=0;i--)
#define MOD 1000000007

using namespace std;

bool cmpf(const pair<lli, lli> left, const pair<lli, lli> right) {
  	return left.first< right.first;
}

int main(){
    lli n, d, a;
    cin >> n >> d >>a;
    vector<pair<lli, lli>> vec(n);
    rep0(i,n){
        lli x, h;
        cin >> x >> h;
        vec[i] = make_pair(x,h);
    }

    sort(all(vec), cmpf);

    vector<lli> num(n+1,0);
    lli sum, ans;

    ans = sum = num[1]= vec[0].second/a + (vec[0].second%a != 0);
    
    vector<pair<lli, lli>>::iterator last = vec.begin();
    
    rep1(i, n-1){
        vector<pair<lli,lli>>::iterator it = lower_bound(vec.begin(), ++last, make_pair(vec[i].first-2*d, 0), cmpf);
        int diff = distance(vec.begin(), it); 
        // cout << diff << ' ';
        sum=num[i]-num[diff];
        // cout << sum << ' ';
        num[i+1]=num[i]+max(sum, vec[i].second/a + (vec[i].second%a != 0))-sum;
        // cout << num[i+1] << endl;
    }

    cout << num[n];
}

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

typedef struct node{
  struct node *left;
  struct node *right;
  struct node *parent;
  int key;
}Node;
typedef Node *NodePointer;

NodePointer root = NULL;
NodePointer minimum(NodePointer);

NodePointer createNode(void){

  NodePointer tree = malloc(sizeof(Node));
  tree->left = NULL;
  tree->right = NULL;
  tree->parent = NULL;
  tree->key = 0;

  return tree;
}

void insert(int key){

  NodePointer z = createNode();
  NodePointer x = root;
  NodePointer y = NULL;
  z->key = key;
  while(x != NULL){
    y = x;

    if(z->key < x->key){
      x = x->left;
    }else{
      x = x->right;
    }
  }

  z->parent = y;

  if(y == NULL){
    root = z;
  }else if(z->key < y->key){
    y->left = z;
  }else{
    y->right = z;
  }
}

void inorder(NodePointer T){

  if(T != NULL){
    inorder(T->left);
    printf(" %d",T->key);
    inorder(T->right);
  }
}

void preorder(NodePointer T){

  if(T != NULL){
  printf(" %d", T->key);
    preorder(T->left);
    preorder(T->right);
  }
}

NodePointer find(int k, NodePointer T){

  while(T != NULL && T->key != k){
    if(T->key > k){
      T = T->left;
    }else{
      T = T->right;
    }
  }
  return T;
}

NodePointer successor(NodePointer T){
  NodePointer x;
  if(T->right != NULL){
    return minimum(T->right);
  }
  x = T->parent;

  while(x != NULL && T == x->right){
    T = x;
    x = x->parent;
  }
  return x;
}

void  delete(NodePointer T){

  NodePointer x;
  NodePointer y;

  if(T->left == NULL || T->right == NULL){ // 子がいる時
    x = T;
  }else{ // 子がいない時
    x = successor(T);
  }
  if(x->left != NULL){
    y = x->left;
  }else{
    y = x->right;
  }

  if(y != NULL){ // 子の子があるとき
    y->parent = x->parent;
  }

  if(x->parent == NULL){
    root = y;
  }else if(x == x->parent->left){
    x->parent->left = y;
  }else{
    x->parent->right = y;
  }
  if(x != T){
    T->key = x->key;
  }
}

NodePointer minimum(NodePointer T){
  while(T->left != NULL){
    T = T->left;
  }
  return T;
}

int main(){

  int i, n, x;
  char str[10];

  scanf("%d", &n);
  for(i = 0; i < n; i++){
    scanf("%s", str);
    if(str[0] == 'i'){
      scanf("%d", &x);
      insert(x);
    }else if(str[0] == 'p'){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    }else if(str[0] == 'f'){
      scanf("%d", &x);
      if(find( x, root) == NULL){
	printf("no\n");
      }else{
	printf("yes\n");
      }
    }else if(str[0] == 'd'){
      scanf("%d", &x);
      delete(find(x, root));
    }else{
      continue;
    }
  }
  return 0;
}

Measured memory_bytes: 19364
//04, 11, 2018, 10:03:20 Rafaelcs cpp
#include <bits/stdc++.h>

using namespace std;
typedef pair<int, int> pii;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;

int t, a;

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

    cin >> n;
    
    cin >> t >> a;

    t *= 1000, a *= 1000;

    int best = 1e9, besti = -1;

    for(int i = 0 ; i < n ; i++){
        int x;

        cin >> x;

        int temp = t - x * 6;

        if(abs(temp - a) < best){
            besti = i + 1;
            best = abs(temp - a);
        }
    }    

    cout << besti << endl;

    return 0;
}

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

const int mod = 1e9+7;
const int M = 10000000;

ll fac[M], finv[M], inv[M];

//前処理
void Cinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < M; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1]*inv[i]%mod;
    }
}

ll C(int n, int k){
    if(n < k)   return 0;
    if(n < 0 || k < 0)  return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

int main(){
    ll x,y;    cin >> x >> y; 
    if((x+y)%3){
        cout << 0 << endl;
    }else if(2*y-x < 0 || 2*x-y < 0){
        cout << 0 << endl;
    }else{
        ll n = (2*y-x)/3;
        ll m = (2*x-y)/3;
        Cinit();
        cout << C(n+m, m) << endl;
    }
}


Measured memory_bytes: 234624
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <deque>
#include <complex>
#include <algorithm>
#include <cstdio>
#include <cmath>
#include <cstring>

#define REP(i,x) for(int i=0 ; i<(int)(x) ; i++)
#define ALL(x) (x).begin(),(x).end()
#define LL long long

using namespace std;

int main(){
    int N, T;
    scanf("%d %d", &N, &T);
    vector<pair<int, int> > events(N);
    int res = 0;
    int prev_to = 0;
    REP(i, N){
        int from;
        scanf("%d", &from);
        int to = from + T;
        from = max(from, prev_to);
        res += to - from;
        prev_to = to;
    }
    printf("%d\n", res);
    return 0;
}

Measured memory_bytes: 1792
using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int[] In = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
            int n = In[0];
            int h = In[1];
            int w = In[2];
            int cnt = 0;
            for(int i = 0; i < n; i++)
            {
                int[] In2 = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();
                int a = In2[0];
                int b = In2[1];
                if (a >= h && b >= w) cnt++;
            }
            Console.WriteLine(cnt);
        }
    }
}


Measured memory_bytes: 28524
#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 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);
    
    string S;
    cin >> S;

    int Q;
    cin >> Q;

    vector<int> T(Q), F(Q);
    vector<char> C(Q);
    bool rev = false;
    REP(i, Q) {
        cin >> T[i];

        if (T[i] == 1) rev ^= 1;
        else {
            cin >> F[i] >> C[i];
        }
    }

    if (rev) reverse(S.begin(), S.end());

    REP(i, Q) {
        if (T[i] == 1) rev ^= 1;
        else {
            --F[i];

            if (rev) F[i] ^= 1;

            if (F[i]) {
                S += C[i];
            } else {
                S.insert(0, 1, C[i]);
            }
        }
    }

    cout << S << endl;
}


Measured memory_bytes: 2832
import sys

# import re
import math
import collections
# import decimal
import bisect
import itertools
import fractions
# import functools
import copy
import heapq
import decimal
# import statistics
import queue
# import numpy as np

sys.setrecursionlimit(10000001)
INF = 10 ** 16
MOD = 10 ** 9 + 7
# MOD = 998244353

ni = lambda: int(sys.stdin.readline())
ns = lambda: map(int, sys.stdin.readline().split())
na = lambda: list(map(int, sys.stdin.readline().split()))


# ===CODE===


def main():
    n, k = ns()
    a = na()

    for _ in range(min(k,42)):
        imos = [0 for _ in range(n)]

        for i, ai in enumerate(a):
            imos[max(0, i - ai)] += 1
            if i + ai + 1 < n:
                imos[i + ai + 1] -= 1

        val = 0
        for i, im in enumerate(imos):
            val += im
            a[i] = min(val, n)

        # if min(a) == n:
        #     break

    print(*a, sep=" ")


if __name__ == '__main__':
    main()


Measured memory_bytes: 172692
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define ve vector
#define chmin(x,y) x = min(x,y)

int main(){
    int n,m,q;
    cin >> n >> m >> q;
    
    ve<ve<int>> lr(n+2,ve<int>(n+2,0));
    rep(i,m){
        int l,r;
        cin >> l >> r;
        lr[l][r]++;
    }
    rep(i,n+1)rep(j,n+1) lr[i][j+1] += lr[i][j];
    rep(i,n+1)rep(j,n+1) lr[j+1][i] += lr[j][i];

    rep(Q,q){
        int p,q;
        cin >> p >> q;
        int ans =  lr[q][q] + lr[p-1][p-1] - lr[p-1][q] - lr[q][p-1];
        printf("%d\n", ans);
    }
    return 0;
}


Measured memory_bytes: 4696