akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int, int>;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];

    ll ans = 0;
    map<int, int> mp;
    rep(i, N) {
        ++mp[A[i] + i];
        ans += mp[-A[i] + i];
    }

    cout << ans << endl;
}

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

int Main(string s) {
  if (s == "SUN") {
    return 7;
  } else if (s == "MON") {
    return 6;
  } else if (s == "TUE") {
    return 5;
  } else if (s == "WED") {
    return 4;
  } else if (s == "THU") {
    return 3;
  } else if (s == "FRI") {
    return 2;
  } else if (s == "SAT") {
    return 1;
  }
  return 0;
}

int main() {
  string s;
  cin >> s;
  cout << Main(s) << 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 ll;

int main() {
    int a, b;
    cin >> a >> b;
    int ans = 6-a-b;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
N=int(input())
S=input()
 
count=S[1:].count("E")
mincount=count
 
for i in range(1,N):
    if S[i]=="E":
        count-=1
    if S[i-1]=="W":
        count+=1
 
 
    mincount=min(count,mincount)
print(mincount)


Measured memory_bytes: 3740
def insertion_sort(num_list):
    print(' '.join(num_list))

    for i in range(1,len(num_list)):
        popped_num = num_list[i]
        j = i-1
        while j >= 0 and int(num_list[j]) > int(popped_num):
            num_list[j+1] = num_list[j]
            j -=1
        num_list[j+1] = popped_num
        print(' '.join(num_list))


n = input()
num_list = list(input().split())
insertion_sort(num_list)



Measured memory_bytes: 5600
#include<iostream>
#include<stdio.h>
using namespace std;
int main()
{
    int a,b,d,f;double c;
    cin>>a>>b;
    d=a/b;
    f=(a)%(b);
    c=double(a)/double(b);
    printf("%d %d %.5lf\n",d,f,c);



    return 0;
}

Measured memory_bytes: 1192
#include <iostream>
#include <cstdlib>
using namespace std;

int n, m1, m2;
string t[5][5], t_tmp[5][5];
int a1[30], a2[30];

void copy(string from[5][5], string to[5][5]){
  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++){
      to[i][j] = from[i][j];
    }
  }
}

bool alive(int si, int sj, int sk){
  int sum = 0;

  for(int i = si - 1; i <= si + 1; i++){
    if(i < 0 || 5 <= i) continue;

    for(int j = sj - 1; j <= sj + 1; j++){
      if(j < 0 || 5 <= j) continue;

      for(int k = sk - 1; k <= sk + 1; k++){
        if(k < 0 || 5 <= k || i == si && j == sj && k == sk){
          continue;
        }
        if(t_tmp[i][j][k] == '1'){
          sum++;
        }
      }
    }
  }

  for(int i = 0; i < m1; i++){
    if(a1[i] == sum){
      return true;
    }
  }

  return false;
}

bool dead(int si, int sj, int sk){
  int sum = 0;

  for(int i = si - 1; i <= si + 1; i++){
    if(i < 0 || 5 <= i) continue;

    for(int j = sj - 1; j <= sj + 1; j++){
      if(j < 0 || 5 <= j) continue;

      for(int k = sk - 1; k <= sk + 1; k++){
        if(k < 0 || 5 <= k || i == si && j == sj && k == sk){
          continue;
        }
        if(t_tmp[i][j][k] == '1'){
          sum++;
        }
      }
    }
  }

  for(int i = 0; i < m2; i++){
    if(a2[i] == sum){
      return false;
    }
  }

  return true;
}

void move(){
  copy(t, t_tmp);

  for(int i = 0; i < 5; i++){
    for(int j = 0; j < 5; j++){
      for(int k = 0; k < 5; k++){
        if(t_tmp[i][j][k] == '0'){
          if(alive(i, j, k)) t[i][j][k] = '1';
          else               t[i][j][k] = '0';
        }
        else{
          if(dead(i, j, k)) t[i][j][k] = '0';
          else              t[i][j][k] = '1';
        }
      }
    }
  }
}

int main(){
  for(int CASE = 1; cin >> n, n; CASE++){
    if(CASE != 1) cout << endl;
    cout << "Case " << CASE << ":" << endl;

    for(int i = 0; i < 5; i++){
      for(int j = 0; j < 5; j++){
        cin >> t[i][j];
      }
    }

    cin >> m1; for(int i = 0; i < m1; i++) cin >> a1[i];
    cin >> m2; for(int i = 0; i < m2; i++) cin >> a2[i];

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

    for(int i = 0; i < 5; i++){
      if(i != 0) cout << endl;

      for(int j = 0; j < 5; j++){
        cout << t[i][j] << endl;
      }
    }
  }
}

Measured memory_bytes: 1212
#include<cstdio>
#define maxn 100005
using namespace std;
int n,a[maxn];
int main(){
	scanf("%d",&n);
	for (int i=1;i<=n;i++) scanf("%d",&a[i]),a[i]--;
	for (int i=2;i<=n;i++){
		if (a[i]<a[i-1]){
			a[i]++;
			if (a[i]<a[i-1]){printf("No\n");return 0;}
		}
	}
	printf("Yes\n");
	return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <utility>
#include <queue>
#include <stack>
typedef long long ll;
using namespace std;

ll gcd(ll x, ll y){
  return x ? gcd(y%x,x) : y;
}

int main(){
  ll i,j,k,n;
  cin >> n;
  ll a[n];
  for(i=0;i<n;i++)cin >> a[i];
  ll x = a[0];
  for(i=1;i<n;i++){
    x = gcd(x,a[i]);
  }
  cout << x << endl;
  return 0;
}


Measured memory_bytes: 1024
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];
        string[] input = Console.ReadLine().Split();
        int temp = 0;
        bool flag = false;
        for(int i=0; i < N; i++)
        {
            a[i] = int.Parse(input[i]);
            if (a[i] == temp+1) { temp++;flag = true; }
        }
        if (flag == false) { Console.WriteLine("-1"); }
        else { Console.WriteLine(N - temp); }
    }
}


Measured memory_bytes: 31836
// Last Change: 08/27/2019 16:24:15.
// 4567のような1ずつ増える数列を抜き出すアルゴリズム
// O(N)で上記を満たす最長の部分列を見つけることもできる
//
// AGC024 B で使用
#include <algorithm>
#include <array>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <memory>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>

using namespace std;
using ll = long long;

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

  vector<ll> v(N);
  for (ll i = 0; i < N; ++i) {
    ll ipt;
    cin >> ipt;

    v[--ipt] = i;
  }

  // LIS(ただし1ずつの増加)の長さをkとして、これを求める。
  ll k = 1;
  {
    ll i = 1;
    while (i < N) {
      ll cnt = 0;
      while (i < N and v[i - 1] < v[i]) {
        ++cnt;
        ++i;
      }
      k = max(k, cnt + 1);
      i += 1;
    }
  }
  cout << N - k << endl;
}

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

int main() {
  int A;
  int B;
  string op;
  cin >> A >> op >> B;
  if (op == "+") {
    cout << A + B << endl;
  }
  else if (op == "-") {
    cout << A - B << endl;
  }
}

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

int main(){
  int a,b,c,d;
  cin >>a>>b>>c>>d;
  if (a+b==c+d){
    cout << "Balanced" << endl;
  }else if (a+b>=c+d){
    cout << "Left" <<endl;
  }else{
    cout << "Right" <<endl;
  }
}

Measured memory_bytes: 256
import java.util.*;

class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
        int flag = 0;
      
      while(a != 0 || c != 0){
        c -= b;
        if(c <= 0){
          flag = 1;
          break;
        }
        a -= d;
        if(a <= 0){
          flag = 2;
          break;
        }
      }
      if(flag == 1){
        System.out.println("Yes");
      } else if (flag == 2) {
        System.out.println("No");
      }
    }
}

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

void print(vector<int> a, int n){
    for(int k = 0; k < n; k++)
        cout << a[k] << (k == n-1 ? '\n' : ' ');
    return;
}

int main(){
    int n; cin >> n;
    vector<int> a(n);
    for(int i = 0; i < n; i++) cin >> a[i];

    print(a, n);
    for(int i = 1; i < n; i++){
        int v = a[i];
        int j = i - 1;
        while(j >= 0 && a[j] > v){
            a[j+1] = a[j];
            j--;
        }
        a[j+1] = v;
        print(a, n);
    }
    return 0;
}


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

int main() {
  int N, D, A;
  cin >> N >> D >> A;

  vector<P> m(N);
  rep(i, N) {
    int X, H;
    cin >> X >> H;
    m.at(i) = P(X, (H + A - 1) / A);
  }
  sort(m.begin(), m.end());

  queue<P> q; // 関係する爆発を入れる
  ll acc = 0; // そこまでの爆発により、次のモンスターに対して減らせる体力量
  ll ans = 0;
  rep(i, N) {
    int x = m.at(i).first;
    int num = m.at(i).second;
    while (!q.empty() && q.front().first < x) {
      acc -= q.front().second;
      q.pop();
    }

    num -= acc;

    if (num > 0) {
      ans += num;
      acc += num;
      q.push(P(x + 2 * D, num));
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 2688
#include <iostream>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <queue>
#include <stack>
#include <algorithm>
#include <fstream>
#include <sstream>
#include <iomanip>

using namespace std;

long long MOD = 1000000007;

int main(){
    int N;
    cin >> N;
    vector<int> B(N+1, MOD);
    for(int i=1; i<N; i++){
        cin >> B[i];
    }
    int ans=0;
    for(int i=0; i<N; i++){
        ans+=min(B[i], B[i+1]);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const ll NN = 1e6+10;

int N;
map<string,ll> mp;
int main(){
//	freopen("test.in","r",stdin);
	cin>>N;
	string str;
	for(int i =1;i<=N;i++){
		cin>>str;
		sort(str.begin(),str.end());
		mp[str]++;
	}
	ll total = 0;
	for(auto m:mp){
		total += m.second*(m.second-1)/2;
	}
	cout<<total<<endl;
	return 0;
}

Measured memory_bytes: 11136
#include <iostream>
#include <cstring>
const int MAX_N = 50;
using ull = unsigned long long;
const int MOD = 1e9 + 7;
int n;

struct Matrix {
  int a[MAX_N][MAX_N];
  Matrix() : a() {}
  inline Matrix &operator*=(const Matrix b) {
    register int i, j, k, l;
    register const int *p2;
    static ull tmp[MAX_N];
    ull cur;
    for (i = 0; i < n; ++i) {
      memset(tmp, 0, sizeof(ull) * n);
      for (k = 0, l = (n & ~15); k < l;) {
#define opt                                                   \
  do {                                                        \
    for (cur = a[i][k], p2 = b.a[k], j = 0; j < n; j++, p2++) \
      tmp[j] += cur * (*p2);                                  \
    k++;                                                      \
  } while (0)
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;
        opt;

        for (j = 0; j < n; j++) tmp[j] %= MOD;
      }

      for (; k < n;) {
        opt;
      }
#undef opt

      for (j = 0; j < n; j++) a[i][j] = tmp[j] % MOD;
    }
    return *this;
  }
};

inline int add(int x, int v) { return x + v >= MOD ? x + v - MOD : x + v; }

inline Matrix power(Matrix &a, long long b) {
  Matrix ret;
  for (int i = 0; i < n; ++i) ret.a[i][i] = 1;
  for (; b; b >>= 1, a *= a)
    if (b & 1) ret *= a;
  return ret;
}

int main() {
  std::ios::sync_with_stdio(false);
  std::cin.tie(nullptr);
  std::cout.tie(nullptr);
  Matrix a;
  long long k;
  std::cin >> n >> k;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) std::cin >> a.a[i][j];
  auto ret = power(a, k);
  int ans = 0;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < n; ++j) ans = add(ans, ret.a[i][j]);
  std::cout << ans;
  return 0;
}

Measured memory_bytes: 256
sn=input()
l=len(sn)
n=int(sn)
s=0
t=[[0 for i in range(9)]for j in range(9)]

if l==1:
    print(n)
else:
    s1=0
    for i in range(l-2):
        s1+=(10**i)
    s1+=1
    for i in range(9):
        t[i][i]=s1

    s2=0
    for i in range(l-2):
        s2+=(10**i)

    for i in range(9):
        for j in range(9):
            if i!=j:
                t[i][j]=s2
    for i in range(9):
        for j in range(9):
            if int(sn[0])<i+1:
                s1=s2
            elif int(sn[0])==i+1:
                if int(sn[l-1])<j+1:
                    if len(sn[1:l-1])!=0:
                        t[i][j]+=int(sn[1:l-1])
                else:
                    if len(sn[1:l-1])!=0:
                        t[i][j]+=int(sn[1:l-1])+1
                    else:
                        t[i][j]+=1
            else:
                t[i][j]+=10**(l-2)

    for i in range(9):
        for j in range(9):
                s+=t[i][j]*t[j][i]
    print(s)

Measured memory_bytes: 3064
#include <stdio.h>
char tatami[99][99];
int corner[99][99],h,w;
int D[2][3]={{0,1,'-'},{1,0,'|'}};
int dfs(int i,int j){
	if(i==h)return 1;
	if(j==w)return dfs(i+1,0);
	if(tatami[i][j])return dfs(i,j+1);
	int k=0,l,r=0;
	for(;k<2;k++)if(i+D[k][0]<h&&j+D[k][1]<w&&!tatami[i+D[k][0]][j+D[k][1]]){
		tatami[i][j]=tatami[i+D[k][0]][j+D[k][1]]=D[k][2];
		for(l=0;l<4;l++)corner[i+l/2*(D[k][0]+1)][j+l/2*(D[k][1]+1)]++;
		for(l=0;l<4;l++)if(corner[i+l/2*(D[k][0]+1)][j+l/2*(D[k][1]+1)]>3)break;
		if(l==4)r+=dfs(i,j+1);
		for(l=0;l<4;l++)corner[i+l/2*(D[k][0]+1)][j+l/2*(D[k][1]+1)]--;
		tatami[i][j]=tatami[i+D[k][0]][j+D[k][1]]=0;
	}
	return r;
}
int main(){for(;scanf("%d%d",&h,&w),h;)printf("%d\n",dfs(0,0));return 0;}

Measured memory_bytes: 620
#include<iostream>
using namespace std;
int main(){
	string s;
	cin>>s;
	int l=s.size();
	int i,r=0,p=0;
	for(i=0;i<l;i++){
		if(s[i]=='g')
		r++;
		else
		p++;
	}
	cout<<l/2-p<<endl;
	
	
	
	
	return 0;
} 

Measured memory_bytes: 512
from functools import lru_cache


@lru_cache(maxsize=4096)
def solve(idx, S, num):
    if len(S) == 1 or len(S) == idx:
        return int(S) + num
    # +を入れるパターン
    ret = solve(1, S[idx:], num+int(S[:idx]))
    # +を入れないパターン
    ret += solve(idx+1, S, num)
    return ret


S = input()
print(solve(1, S, 0))

Measured memory_bytes: 3812
#include<iostream>
#include<algorithm>
#include<string>
#include<math.h>
#include<cmath>
#include<vector>
#include<stack>
#include<queue>
#include<functional>
#include<map>
#include<set>
using namespace std;
#define rep(i,n) for(int i=0;i<(n);i++)
typedef long long ll;

map<string, int> mp;
int main() {
	int n;
	cin >> n;
	string s;
	cin >> s;
	mp[s] = 1;
	rep(i, n-1) {
		string w;
		cin >> w;
		if (mp[w] != 0 || s[s.size() - 1] != w[0]) {
			cout << "No" << endl;
			return 0;
		}
		mp[w] = 1;
		s = w;
	}
	cout << "Yes" << endl;
	return 0;


}

Measured memory_bytes: 256
#include <cstdio>  //{{{
#include <iostream>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <algorithm>

#define ALL(c) (c).begin(), (c).end()
#define DUMP(x) std::cerr << #x << ':' << x << '\n';

typedef long long ll;
// clang-format off
template<typename T,typename U>inline bool chmax(T&x,U a){if(x>=a)return 0;x=a;return 1;}
template<typename T,typename U>inline bool chmin(T&x,U a){if(x<=a)return 0;x=a;return 1;}
inline int in(){int x;scanf("%d", &x);return x;}
// clang-format on
// }}}
//{{{ graph.hpp
#ifndef INCLUDE_GRAPH_HPP
#define INCLUDE_GRAPH_HPP
#include <vector>
#include <climits>
namespace orliv {
namespace graph {
struct Edge {
  typedef int weight_type;
  static constexpr weight_type INF =
      std::numeric_limits<weight_type>::max() - 100;

  int from, to;
  weight_type w;
  Edge(int from, int to, weight_type w = 1) : from(from), to(to), w(w) {}
  bool operator<(const Edge& rhs) const {
    if (w != rhs.w) return w > rhs.w;
    if (from != rhs.from) return from < rhs.from;
    return to < rhs.to;
  }
};

typedef Edge::weight_type Weight;
typedef std::vector<Edge> Edges;
typedef std::vector<Weight> Weights;
typedef std::vector<int> Path;
typedef std::vector<int> Nodes;
}
typedef std::vector<graph::Edges> Graph;
}
#endif
//}}}
//{{{ scc.cc
#ifndef INCLUDE_GRAPH_HPP
#include "graph.hpp"
#endif
#include <stack>

namespace orliv {
namespace graph {
namespace scc_internal {
struct SCCImpl {
  const Graph& G;
  int k;
  std::vector<int> ord, low;
  std::stack<int> stack;
  std::vector<bool> instack;
  std::vector<Nodes> scc;
  SCCImpl(const Graph& g)
      : G(g), k(0), ord(g.size(), -1), low(g.size()), instack(g.size()) {}
  std::vector<Nodes> get() {
    for (int v = 0; v < G.size(); v++) {
      if (ord[v] >= 0) continue;
      dfs(v);
    }
    return std::move(scc);
  }

 private:
  void dfs(int v) {
    ord[v] = low[v] = k++;
    stack.push(v);
    instack[v] = true;
    for (const auto& e : G[v]) {
      int u = e.to;
      if (ord[u] < 0) {
        dfs(u);
        low[v] = std::min(low[v], low[u]);
      } else if (instack[u]) {
        low[v] = std::min(low[v], ord[u]);
      }
    }
    if (low[v] != ord[v]) return;

    scc.emplace_back();
    while (1) {
      int u = stack.top();
      stack.pop();
      instack[u] = false;
      scc.back().emplace_back(u);
      if (v == u) break;
    }
  }
};
}
std::vector<Nodes> scc(const Graph& g) {
  return std::move(scc_internal::SCCImpl(g).get());
}
}
}
//}}}

using namespace std;

int main() {
  int V = in(), E = in();
  orliv::Graph g(V);
  for (int i = 0; i < E; i++) {
    int s = in(), t = in();
    g[s].emplace_back(s, t);
  }
  auto scc = orliv::graph::scc(g);
  bool cycle = false;
  for (auto& nodes : scc) {
    cycle |= nodes.size() > 1u;
  }
  if (cycle) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }

  return 0;
}

Measured memory_bytes: 1248
#include <stdio.h>

//座標用の構造体
typedef struct{
  int x_elem;
  int y_elem;
}point;

//a_1,a_2,a_3の順に反時計回りかつa_2が直角な直角二等辺となるa_3を出力
point shift_point(point a1,point a2);

int main(void){
  point apex1,apex2,apex3,apex4;
  //ドット演算子は優先度が最も高いので以下の書き方で入力可能
  scanf("%d%d%d%d",&apex1.x_elem,&apex1.y_elem,&apex2.x_elem,&apex2.y_elem);
  apex3=shift_point(apex1,apex2); //頂点1,2,3の順番で反時計回りになる
  apex4=shift_point(apex2,apex3); //頂点2,3,4の順番で反時計回りとなる
  printf("%d %d %d %d\n",apex3.x_elem,apex3.y_elem,apex4.x_elem,apex4.y_elem);
}

point shift_point(point a1,point a2){
  //答えの保存用の変数を用意
  point ans;
  //a_1からa_2に向かうベクトルのxy成分を計算
  int vec_x=a2.x_elem-a1.x_elem;
  int vec_y=a2.y_elem-a1.y_elem;
  //ベクトル(x,y)を反時計回りに90度回転したベクトルは(-y,x)
  //よってa2を(-vec_y,vec_x)を平行移動した点を出力すれば良い
  ans.x_elem=a2.x_elem-vec_y;
  ans.y_elem=a2.y_elem+vec_x;
  return ans;
}

Measured memory_bytes: 1732
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <string>
#include <utility>
#include <algorithm>
#include <cstdio>
#include <iomanip>
#include <queue>
#include <deque>
#include <stack>
#include <fstream>
#include <cmath>
#include <random>
#include <complex>
#include <functional>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)
using namespace std;
typedef vector<ll> vec;
typedef vector<vec> mat;

const ll inf = 1LL << 60;

template<class T> inline void chmin(T& a, T b) {
    if (a > b) {
        a = b;
    }
}
template<class T> inline void chmax(T& a, T b) {
    if (a < b) {
        a = b;
    }
}

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

    long double A, B, H, M;
    cin >> A >> B >> H >> M;

    // cout << cos(abs(30*H-6*M)/360*2*3.14159265358979) << "\n";

    long double ans = sqrt(A*A+B*B-2*A*B*cos(abs(30*H+0.5*M-6*M)/360*2*3.14159265358979));

    cout << fixed << setprecision(20) << ans << "\n";
}

Measured memory_bytes: 4184
import math
a, b, n = map(int, input().split())

# for i in range(n + 1):
#     x = math.floor((a * i) / b) - a * math.floor(i / b)
#     print(i, x)


if n < b:
    print((a * n) // b - a * (n // b))
else:
    print((a * (b - 1)) // b)


Measured memory_bytes: 9164
N, M = map(int, input().split())
Height = [int(i) for i in input().split()]
check = [1] * N

A_List = [0] * M
B_List = [0] * M
for i in range(M):
    A, B = map(int, input().split())
    A_List[i] = A
    B_List[i] = B



for i in range(M):
    if Height[A_List[i] - 1] > Height[B_List[i] - 1]:
        check[B_List[i] - 1] = 0
    elif Height[A_List[i] - 1] < Height[B_List[i] - 1]:
        check[A_List[i] - 1] = 0
    elif Height[A_List[i] - 1] == Height[B_List[i] - 1]:
        check[B_List[i] - 1] = 0
        check[A_List[i] - 1] = 0


print(sum(check))

Measured memory_bytes: 21856
#include <bits/stdc++.h>
using namespace std;
const int INF = 1000000007;
 
int main(){
  cin.tie(nullptr);
  ios::sync_with_stdio(false);

  int N;
  cin >> N;
  string S[N];
  int64_t A[5] = {}; 
  for(int i=0;i<N;i++){
    cin >> S[i];
    if(S[i][0] == 'M') A[0]++;
    else if(S[i][0] == 'A') A[1]++;
    else if(S[i][0] == 'R') A[2]++;
    else if(S[i][0] == 'C') A[3]++;
    else if(S[i][0] == 'H') A[4]++;
  }
  int64_t ans = 0;
  for(int i=0;i<3;i++){
    for(int j=i+1;j<4;j++){
      for(int k=j+1;k<5;k++){
        ans += A[i] * A[j] * A[k];
      }
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 5760
#include <stdio.h>
#include <math.h>
#define SQ(a) ((a) * (a))

typedef struct{
	double x[20];
	double y[20];
} POINT;


int main(void)
{
	POINT p;
	double s;
	int i, j;
	double menseki;
	
	i = 0;
	
	while (scanf("%lf%*c%lf", &p.x[i], &p.y[i]) != EOF){
		i++;
	}
	
	menseki = 0;
	for (j = 0; j < i; j++){
		menseki += (p.x[j] - p.x[(j + 1) % i]) * (p.y[j] + p.y[(j + 1) % i]);
	}
	
	printf("%f\n", menseki / 2.00 < 0 ? -1 * menseki / 2.00 : menseki / 2.00);
	
	return (0);
}

Measured memory_bytes: 0
#include <iostream>
#include <string>
#include <queue>
#include <stack>
#include <algorithm>
#include <list>
#include <vector>
#include <complex>
#include <utility>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <bitset>
#include <ctime>
#include <map>
#include <unordered_map>
#include <set>
#include <unordered_set>
#include <cassert>
#include <cstddef>
#include <iomanip>
#include <numeric>
#include <tuple>
#include <sstream>
#include <fstream>
#include <functional>

using namespace std;
#define REP(i, n) for (int (i) = 0; (i) < (n); (i)++)
#define FOR(i, a, b) for (int (i) = (a); (i) < (b); (i)++)
#define RREP(i, a) for(int (i) = (a) - 1; (i) >= 0; (i)--)
#define FORR(i, a, b) for(int (i) = (a) - 1; (i) >= (b); (i)--)
#define DEBUG(C) cerr << #C << " = " << C << endl;
using LL = long long;
using VI = vector<int>;
using VVI = vector<VI>;
using VL = vector<LL>;
using VVL = vector<VL>;
using VD = vector<double>;
using VVD = vector<VD>;
using PII = pair<int, int>;
using PDD = pair<double, double>;
using PLL = pair<LL, LL>;
using VPII = vector<PII>;
template<typename T> using VT = vector<T>;
#define ALL(a) begin((a)), end((a))
#define RALL(a) rbegin((a)), rend((a))
#define SORT(a) sort(ALL((a)))
#define RSORT(a) sort(RALL((a)))
#define REVERSE(a) reverse(ALL((a)))
#define MP make_pair
#define FORE(a, b) for (auto &&a : (b))
#define EB emplace_back
#define GREATER(T) T, VT<T> greater<T>
template<typename T> inline bool chmax(T &a, T b){if (a < b){a = b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if (a > b){a = b;return true;}return false;}

const int INF = 1e9;
const int MOD = INF + 7;
const LL LLINF = 1e18;

int main(void) {
    int A, B, C;
    cin >> A >> B >> C;
    int K;
    cin >> K;

    while (K) {
        if (B <= A) {
            B *= 2;
        } else if (C <= B) {
            C *= 2;
        }
        K--;
    }

    if (B > A && C > B) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

Measured memory_bytes: 3632
#include <bits/stdc++.h>
#define r(i,a,n) for(int i=a;i<n;i++)
using namespace std;
int x[191919],y[191919];
int main() {
	int n,a,b,d,e,f,p=0;
	cin>>n>>a>>b;
	r(i,0,n){cin>>d>>e>>f;
		y[max(0,e-f)]--;
		y[min(b,e+f)]++;
		x[max(0,d-f)]--;
		x[min(a,d+f)]++;}
	r(i,1,b+1)y[i]+=y[i-1];
	r(i,1,a+1)x[i]+=x[i-1];
	r(i,0,b)if(y[i]==0){p++;break;}
	r(i,0,a)if(x[i]==0){p++;break;}
	if(p==2)cout<<"No"<<endl;
	else cout<<"Yes"<<endl;
}

Measured memory_bytes: 3880
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC115A
{
    class Program
    {
        static void Main(string[] args)
        {
            int D = int.Parse(Console.ReadLine());


            if (D == 25)
                Console.WriteLine("Christmas");

            else if (D == 24)
                Console.WriteLine("Christmas Eve");

            else if (D == 23)
                Console.WriteLine("Christmas Eve Eve");

            else
                Console.WriteLine("Christmas Eve Eve Eve");


            Console.ReadKey();
        }
    }
}


Measured memory_bytes: 11092
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define f(i,a,n) for(int i=a ; i<n ; i++)
#define pb(v) push_back(v)
#define all(s) s.begin(),s.end()
ll MOD=1e9+7;

int main() {
	//code
	
     ios_base::sync_with_stdio(false); 
     cin.tie(NULL);
     
        int n,m;
        cin>>n>>m;
        char a[n][m];
		int dp[n+1][m+1];
        
               f(i,0,n)
			   {
			   	f(j,0,m)
			   	cin>>a[i][j];
			   }
			   f(i,0,n+1)
			   {
			   	f(j,0,m+1)
			   	  {  dp[1][1]=1;
			   	     if(i==0 || j==0)
					  dp[i][j]=0;
					  else if(a[i-1][j-1]=='#')
					  dp[i][j]=0;
					  else
					  {
					  	dp[i][j]=(dp[i-1][j]%MOD+dp[i][j-1]%MOD)%MOD;
					  }
					  //cout<<dp[i][j]<<" ";
				  }
				  //cout<<endl;
			   }
			   cout<<dp[n][m]<<endl;
			   
			   
			           
          return 0;

}



Measured memory_bytes: 5120
n, k = map(int, input().split())
a = list(map(int, input().split()))

length = len(bin(max(max(a), k))[2:])
n_1 = [0] * length

for i in range(n):
    abin = bin(a[i])[2:].zfill(length)
    for j in range(length):
        if abin[j] == '1':
            n_1[j] += 1

def search(i, left_w):
    if i >= length:
        return 0

    w1 = 2 ** (length - i - 1)
    w0 = 0
    v1 = (n - n_1[i]) * 2 ** (length - i - 1)
    v0 = n_1[i] * 2 ** (length - i - 1)

    if left_w >= 2 * w1:
        if v1 > v0:
            return v1 + search(i+1, left_w - w1)
        else:
            return v0 + search(i+1, left_w - w0)

    if left_w >= w1 and v1 >= v0:
        return max(v1 + search(i+1, left_w - w1), v0 + search(i+1, left_w - w0))
    else:
        return v0 + search(i+1, left_w - w0)

print(search(0, k))


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

using namespace std;

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define dump(x) cerr << #x " = " << (x) << '\n'
#define sz(x) ((int)(x).size())
#define endl '\n'

#ifdef _DEBUG27_
    //#define STRESS 1
#endif

typedef long long llong;

const int INF = 2e9;
const llong LINF = 2e18;

void inv(bool e);
template<typename T> T sign(T a);
template<typename T> void die(T &a);
template<typename T> void umax(T &a, T b);
template<typename T> void umin(T &a, T b);

bool brute, alter;
int cnt_tests = 1;

// Improoving ATC rating. I want to leave this green trash

// Code below

string x;

void inp() {
    cin >> x;
}

void solve() {
    if (x[0] == x[1] && x[1] == x[2]) {
        cout << "Yes";
        return;
    }
    if (x[1] == x[2] && x[2] == x[3]) {
        cout << "Yes";
        return;
    }
    cout << "No";
}

void stress() {

}

void naive() {

}
void run();
int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        ios_base::sync_with_stdio(false);
        cin.tie(0);
        cout.tie(0);
        if (0) {
            freopen("palindrome.in", "r", stdin);
            freopen("palindrome.out", "w", stdout);
        }
    #endif
    srand(time(0));
    #ifdef STRESS
        brute = true;
    #else
        brute = false;
    #endif  
    
    for (int i = 0; (i < cnt_tests); i++) {
        run();
    }
    #ifdef _DEBUG27_
        cout << endl << "Time: " << clock() / 1000.0 << " ms";
    #endif
    return 0;
}

void run() {
    if (!brute) {
        inp();
    }
    else {
        stress();
    }
    solve();
    cout << endl;
}

template<typename T>
void die(T &a) {
    cout << a;
    exit(0);
}

template<typename T>
T sign(T a) {
    if (a == 0)
        return 0;
    if (a < 0)
        return -1;
    return 1;
}

template<typename T>
void umax(T &a, T b) {
    if (b > a)
        a = b;
}

template<typename T>
void umin(T &a, T b) {
    if (b < a)
        a = b;
}

void inv(bool e) {
    if (!e) {
        vector<int> a;
        a[-1] += 1;
    }
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

    printf(VAL);
    fflush(stdout);
*/

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

struct Point
{
  double x;
  double y;
};

double sin60 = sqrt(3.0) / 2.0;
double cos60 = 1.0 / 2.0;

void kock(int depth, Point p1, Point p2)
{
  if (depth == 0)
    return;

  Point s, t, u;
  s.x = (p1.x * 2 + p2.x) / 3;
  s.y = (p1.y * 2 + p2.y) / 3;
  t.x = (p1.x + p2.x * 2) / 3;
  t.y = (p1.y + p2.y * 2) / 3;
  u.x = (t.x - s.x) * cos60 - (t.y - s.y) * sin60 + s.x;
  u.y = (t.x - s.x) * sin60 + (t.y - s.y) * cos60 + s.y;

  kock(depth - 1, p1, s);
  printf("%.10f %.10f\n", s.x, s.y);
  kock(depth - 1, s, u);
  printf("%.10f %.10f\n", u.x, u.y);
  kock(depth - 1, u, t);
  printf("%.10f %.10f\n", t.x, t.y);
  kock(depth - 1, t, p2);
}

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

  Point s, g = {100, 0};

  printf("%.10f %.10f\n", s.x, s.y);
  kock(n, s, g);
  printf("%.10f %.10f\n", g.x, g.y);

  return 0;
}

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

int main(){
    int N, D;
    cin >> N >> D;
    vector<int> people;

    int place;
    place = 1 + D;
    people.push_back(place);
    while(place + D < N){
        place += 2 * D + 1;
        people.push_back(place);
    }
    cout << people.size() << endl;
}

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


#define ll long long int
#define ld long double
#define mod 998244353
#define big 1e18+10
#define small -big
#define pb push_back
#define endl "\n"


template <typename T>

void prarr(T a)
{
     cerr << "[ ";
     
     for(auto i : a){
         cerr << i << " ";
     }
     
     cerr << "]" << endl;
}


#define trace(...) _er(#__VA_ARGS__, __VA_ARGS__)

template <typename Arg1>

void _er(const char* name, Arg1&& arg1){
	cerr << "[" << name << " : " << arg1 << "]" << endl;
}

template <typename Arg1, typename... Args>

void _er(const char* names, Arg1&& arg1, Args&&... args){
    
	const char* comma = strchr(names + 1, ',');
	cerr << "[" ; cerr.write(names, comma - names) << " : " << arg1 << "] ";
	_er(comma+2, args...);
}



void solve() {
    
    
    ll n;
    cin >> n;
    
    ll A[n + 1];
    
    ll c0 = 0;
    
    for(ll i = 1; i <= n; i++) {
        cin >> A[i];
        if(A[i] == 0) c0++;
    }
    
    if(c0 >= 1) {
        cout << 0 << endl;
        return;
    }
    
    ll ans = 1;
    
    ll reach = (ll) 1e18;
    
    for(int i = 1; i <= n; i++) {
        
        ll need = reach / ans;
        
        if(A[i] <= need) {
            ans *= A[i];
        }
        else {
            cout << -1 << endl;
            return;
        } 
        
    }
    
    cout << ans << endl;
}



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

    int t=1;
   // cin >> t;

    while(t--){  
   
         solve();
    }


    return 0;
        
}


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

int main(){
    int n;
    cin>>n;
    int count=0;
    // This is brute force.
    // for(int i=1;i<n;i++){
    //     for(int j=1;j<n;j++){
    //         for(int k=1;k<n;k++){
    //             if(i*j+k==n)
    //             count++;
    //         }
    //     }
    // }

    for(int i=1;i<n;i++){
        count+=(n-1)/i;
    }
    cout<<count<<"\n";
    return 0;
}

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

int main() {
	int m[10];
	for(int i=0; i<10; i++) cin >> m[i];
	sort(m, m+10);
	for(int i=9; i>6; i--) cout << m[i] << endl;

	return 0;
}

Measured memory_bytes: 1180
#include<iostream>
#include<cstring>
#include<cstdio>
#include<vector>
#include<algorithm>

using namespace std;

#define LL long long
inline LL read(){
	LL x=0,f=1;char c=getchar();
	for(;!isdigit(c);c=getchar()) if(c=='-') f=-1;
	for(;isdigit(c);c=getchar()) x=x*10+c-'0';
	return x*f;
}
const LL MAXN = 500010;
const LL INF = 2147483600;

LL R,C,N;
struct point{
	LL x1,y1,x2,y2; bool opr;
}p[MAXN+1],q[MAXN+1];
LL tot; LL stax[MAXN+1],stay[MAXN+1];
LL topx,topy;

inline LL Getx(LL x){return lower_bound(stax+1,stax+topx+1,x)-stax;}
inline LL Gety(LL x){return lower_bound(stay+1,stay+topy+1,x)-stay;}
inline bool Judge(LL x,LL y){return x==1||x==R||y==1||y==C;}
inline LL Pos(LL x,LL y){
	if(x==1) return y; 
	else if(y==C) return C+x-1;
	else if(x==R) return R+C+(C-y); 
	else if(y==1) return 2*C+R+(R-x);
} LL s[MAXN*3];

int main(){
	//freopen("gg.in","r",stdin);
	//freopen(".out","w",stdout);
	R=read(),C=read(),N=read(); stax[++topx]=0; stay[++topy]=0;
	stax[++topx]=R; stay[++topy]=C;
	for(LL i=1;i<=N;i++){
		p[i].x1=read(),p[i].y1=read(),p[i].x2=read(),p[i].y2=read();
		stax[++topx]=p[i].x1; stax[++topx]=p[i].x2;
		stay[++topy]=p[i].y1; stay[++topy]=p[i].y2;
	} 
	sort(stax+1,stax+topx+1); topx=unique(stax+1,stax+topx+1)-stax-1;
	sort(stay+1,stay+topy+1); topy=unique(stay+1,stay+topy+1)-stay-1;
	R=lower_bound(stax+1,stax+topx+1,R)-stax;
	C=lower_bound(stay+1,stay+topy+1,C)-stay;
	for(LL i=1;i<=N;i++){
		p[i].x1=Getx(p[i].x1); p[i].x2=Getx(p[i].x2);
		p[i].y1=Gety(p[i].y1); p[i].y2=Gety(p[i].y2);
		p[i].opr=Judge(p[i].x1,p[i].y1)&Judge(p[i].x2,p[i].y2);
		if(Pos(p[i].x1,p[i].y1)>Pos(p[i].x2,p[i].y2)) swap(p[i].x1,p[i].x2),swap(p[i].y1,p[i].y2);
		if(p[i].opr) q[++tot]=p[i],s[Pos(p[i].x1,p[i].y1)]++,s[Pos(p[i].x2,p[i].y2)]--;//cout<<p[i].x1<<" "<<p[i].y1<<","<<p[i].x2<<" "<<p[i].y2<<": "<<Pos(p[i].x1,p[i].y1)<<" "<<Pos(p[i].x2,p[i].y2)<<": "<<i<<endl;
	} for(LL i=1;i<=R*2+C*2;i++){
		s[i]+=s[i-1];
	} for(LL i=1;i<=tot;i++){
		if(s[Pos(q[i].x2,q[i].y2)]-s[Pos(q[i].x1,q[i].y1)-1]!=0){
			//cout<<Pos(q[i].x2,q[i].y2)<<" "<<Pos(q[i].x1,q[i].y1)<<": "<<s[Pos(q[i].x2,q[i].y2)]-s[Pos(q[i].x1,q[i].y1)-1]<<endl;
			puts("NO"); return 0;
		}
	} puts("YES");
	return 0;
}
/*
5 5 7
0 0 2 4
2 3 4 5
3 5 5 2
5 5 5 4
0 3 5 1
2 2 4 4
0 5 4 1

*/

Measured memory_bytes: 22784
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stdlib.h>
#include <string>
#include <utility>
#include <vector>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define loop(i, x, n) for (int i = (x); i < (n); i++)
#define all(v) (v).begin(), (v).end()
#define int long long
using namespace std;
const int MOD = 1e9 + 7;
const int INF = 1e9;
template<typename T> void cmax(T &a, T b) { a = max(a, b); }
template<typename T> void cmin(T &a, T b) { a = min(a, b); }

signed main() {
  int n, k;
  cin >> n >> k;
  vector<int> h(n);
  rep(i, n) cin >> h[i];

  sort(all(h));
  int ans = INF;
  int high = h[k - 1];
  int low = h[0];
  cmin(ans, high - low);
  for (int i = k; i < n; i++) {
    high = h[i];
    low = h[i - k + 1];
    cmin(ans, high - low);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 1024
#![allow(non_snake_case)]

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
    ($($r:tt)*) => {
        let s = {
            use std::io::Read;
            let mut s = String::new();
            std::io::stdin().read_to_string(&mut s).unwrap();
            s
        };
        let mut iter = s.split_whitespace();
        input_inner!{iter, $($r)*}
    };
}

macro_rules! input_inner {
    ($iter:expr) => {};
    ($iter:expr, ) => {};

    ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    };
    ($iter:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($iter, $t);
        input_inner!{$iter $($r)*}
    }
}

macro_rules! read_value {
    ($iter:expr, ( $($t:tt),* )) => {
        ( $(read_value!($iter, $t)),* )
    };

    ($iter:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
    };

    ($iter:expr, chars) => {
        read_value!($iter, String).chars().collect::<Vec<char>>()
    };

    ($iter:expr, usize1) => {
        read_value!($iter, usize) - 1
    };

    ($iter:expr, $t:ty) => {
        $iter.next().unwrap().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input!{
        N: chars,
        K: usize,
    }
    let mut dp = [[[0; 2]; 4]; 101];
    dp[0][0][0] = 1;
    for (i, &c) in N.iter().enumerate() {
        let d = c as i32 - '0' as i32;
        for j in 0..(K+1) {
            for k in 0..2 {
                for di in 0..10 {
                    let (mut ni, mut nj, mut nk) = (i, j, k);
                    ni += 1;
                    if di != 0 {
                        nj += 1;
                    }
                    if nj > K {
                        continue;
                    }
                    if k == 0 {
                        if di > d {
                            continue;
                        }
                        if di < d {
                            nk = 1;
                        }
                    }
                    dp[ni][nj][nk] += dp[i][j][k];
                }
            }
        }
    }
    println!("{}", dp[N.len()][K][1] + dp[N.len()][K][0]);
}


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

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

    vector <int> w(n);
    for (int i = 0;i < n;i++) {
        cin >> w[i];
    }

    vector <int> s(n-1);
    vector <int> t(n-1);
    int sum = 0;
    for (int i=0;i<n;i++){
        sum = sum + w[i];
    }
    s[0] = w[0];
    for (int i=1;i<n-1;i++){
        s[i] = s[i-1] + w[i];
    }
    for (int i=0;i<n-1;i++){
        t[i] = sum - s[i];
    }  

    int ans = s[0] - t[0];
    if(ans < 0) ans = -ans;

    for (int i=1;i<n-1;i++){
        int tmp = abs(s[i] - t[i]);
        if(tmp < 0) tmp = -tmp;
        if (tmp < ans) {
            ans = tmp;
        }
    }  
    cout << ans << endl;

}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <fstream>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include<iomanip>
#define sqr(x) (x)*(x)
#define ll long long
using namespace std;
ll num[300001],l[300001],r[300001],ans=-1152921504606846976,n,i,j;
priority_queue<int,vector<int>,greater<int>/**/> le;
priority_queue<ll> ri;
int main()
{
	cin>>n;
	for (i=1;i<=n*3;i++)
	{
		cin>>num[i];
		if (i<=n) 
		{
			le.push(num[i]);
			l[n]+=num[i];
		}
		if (i>n*2) 
		{
			ri.push(num[i]);
			r[n+n+1]+=num[i];
		}
	}
	for (i=n+1;i<=n+n;i++)
	{
		l[i]=l[i-1];
		if (le.top()<num[i])
		{
			l[i]=l[i]-le.top()+num[i];
			le.pop();
			le.push(num[i]);
		}
	}
	for (i=n+n;i>n;i--)
	{
		r[i]=r[i+1];
		if (ri.top()>num[i])
		{
			r[i]=r[i]-ri.top()+num[i];
			ri.pop();
			ri.push(num[i]);
		}
	}
	for (i=n;i<=n+n;i++)
	{
		ans=max(ans,l[i]-r[i+1]);
	}
	cout<<ans<<endl;
	return 0;
}

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

using namespace std;

#define x first
#define y second
#define mp make_pair
#define pb push_back

typedef long long ll;

const ll MOD = 1e9+7;
const ll INF = 1e9+5;

int main() {
	int n, m, a, b, c, d, e;
	string s, t, r;
	cin >> a>> b ;
  	if (a == b)
		cout << "Yes\n";
  	else 
      cout <<"No\n";
	return 0;
}	

Measured memory_bytes: 256
#include "bits/stdc++.h"
#include<cassert>
#pragma warning(disable:4996)
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define MRE assert(0)
const int mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<P, int>PP;
vector<int>G[100006];
int dp[100006];

int memo(int now,int par) {
	if (dp[now] != inf)return dp[now];
	int res = 0;
	for (int e : G[now]) {
		if (e == par)continue;
		res ^= (memo(e, now) + 1);
	}
	return dp[now] = res;

}

signed main() {
	int n; cin >> n;
	rep(i, n - 1) {
		int x, y; cin >> x >> y;
		x--; y--;
		G[x].push_back(y);
		G[y].push_back(x);
	}
	rep(i, n)dp[i] = inf;
	memo(0, -1);
	if (dp[0])puts("Alice");
	else puts("Bob");
}

Measured memory_bytes: 11136
#include <iostream>
#include <sstream>
#include <algorithm>
#include <string>

using namespace std;

string i_s(int n){
  stringstream s;
  string str;

  s << n;
  s >> str;

  return str;
}

int s_i(string str){
  stringstream s(str);
  int num;

  s >> num;

  return num;
}

int main(){
  string str;
  int n;

  cin >> n;
  for(int i = 0 ; i < n ; i++){
    cout << "Case " << i+1 << ":" << endl;
    cin >> str;
    int num = s_i(str);
    for(int j = 0 ; j < 10 ; j++){
      num = num * num;
      string s = i_s(num);
      reverse(s.begin(),s.end());
      for(int k = (int)s.size() ; k < 8 ; k++){
	s += "0";
      }      
      reverse(s.begin(),s.end());
      string ss = s.substr(2,4);
      num = s_i(ss);
      cout << num << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 1232
def comb_2(a):
    return int(a*(a-1)/2)

n = int(input())
a = list(map(int,input().split()))
a_cnt = [0 for i in range(n)]
for i in a:
    a_cnt[i-1] += 1

sum_all = 0
for i in a_cnt:
    sum_all += comb_2(i)

for i in a:
    print(sum_all - comb_2(a_cnt[i-1]) + comb_2(a_cnt[i-1] - 1))


Measured memory_bytes: 86992
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
typedef pair<int,P> P1;
typedef pair<P,P> P2;
#define pu push
#define pb push_back
#define mp make_pair
#define eps 1e-7
#define INF 1000000000
#define mod 1000000007
#define fi first
#define sc second
#define rep(i,x) for(long long i=0;i<x;i++)
#define repn(i,x) for(long long i=1;i<=x;i++)
#define SORT(x) sort(x.begin(),x.end())
#define ERASE(x) x.erase(unique(x.begin(),x.end()),x.end())
#define POSL(x,v) (lower_bound(x.begin(),x.end(),v)-x.begin())
#define POSU(x,v) (upper_bound(x.begin(),x.end(),v)-x.begin())
vector<pair<string,P> >vec;

void solve(long long N, vector<long long> A){
	priority_queue<P, vector<P>, greater<P> > que;
	rep(i, N) {
		que.push(P(A[i],1));
	}
	rep(i, N-1) {
		P a, b;
		a = que.top();
		que.pop();
		b = que.top();
		que.pop();
		if (2*a.first >= b.first) {
			que.push(P(a.first+b.first, a.second+b.second));
		} else {
			que.push(P(a.first+b.first, b.second));
		}
	}
	cout << que.top().second << endl;
}

int main(){	
	long long N;
	scanf("%lld",&N);
	vector<long long> A(N-1+1);
	for(int i = 0 ; i <= N-1 ; i++){
		scanf("%lld",&A[i]);
	}
	solve(N, A);
	return 0;
}



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

using namespace std;

template <typename T>
void readElems(vector<T>& vec, int n) {
  int tmp;
  vec.reserve(n);
  for (int i = 0; i < n; ++i) {
    cin >> tmp;
    vec.push_back(tmp);
  }
}

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

  int n;
  cin >> n;

  vector<int> va, vb;
  readElems(va, n + 1);
  readElems(vb, n);

  long cnt = 0;
  for (int i = 0; i < n; ++i) {
    int left = min(va[i], vb[i]);
    cnt += left;
    va[i] -= left;
    vb[i] -= left;

    int right = min(va[i + 1], vb[i]);
    cnt += right;
    va[i + 1] -= right;
    vb[i] -= right;
  }

  cout << cnt << endl;
}


Measured memory_bytes: 1024
#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define rep(i,n) for (int i = 0;i < (n);i++)
#define all(v) v.begin(),v.end()
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
using vl = vector<ll>;
using vvl = vector<vl>;

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

ll mod(ll a){
  return (a % 1000000007);
}

ll lcm(ll a,ll b){
  return (a*b)/gcd(a,b);
}


int main(){
  ll a,b; cin >> a >> b;
  cout << (a-1)*(b-1) << endl;
}

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

int main() {
  string x,y;
  cin >> x >> y;

  if (x < y) cout << "<" << endl;
  if (x > y) cout << ">" << endl;
  if (x == y) cout << "=" << endl;
  return 0;
  

}
  

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

'''

'''

def func():
    '''

    '''

    m = int(raw_input())
    
    for num in range(m):
        init = int(raw_input())
        years = int(raw_input())
        n = int(raw_input())

        answer = 0
        for ope_num in range(n):
            operation, interest, fee = map(float, raw_input().split())
            operation = int(operation)
            if operation == 0:
                a = init
                b = 0
                for year in range(years):
                    b += (int)(a * interest)
                    a -= fee
                    #print a, b
                res = int(a + b)
            if operation == 1:
                a = init
                for year in range(years):
                    a = (int)(a * (1.0 + interest))
                    a -= fee
                    #print a
                res = int(a)

            if answer < res:
                answer = res

        print answer

    return None

if __name__ == '__main__':
    func()
    

Measured memory_bytes: 4276
#include <iostream>
#include <sstream>
#include <bitset>
#include <string>
#include <vector>
#include <ctime>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <algorithm>
#include <cstring>
#include <functional>
#include <cctype>
#include <numeric>
#include <cassert>

using namespace std;

template<typename T> ostream& operator<<(ostream& os, const vector<T>& v){
    os << "{ ";
    for (typename vector<T>::const_iterator it = v.begin(); it != v.end(); ++it)
        os << *it << (it + 1 == v.end() ? "" : ", ");
    os << " }";
    return os;
}

typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<string> vs;
typedef long long ll;
typedef unsigned uint;
typedef unsigned long ul;
typedef unsigned long long ull;

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define loop(i,a,b) for(int i=(a); i<(int)(b); i++)
#define rep(i,b) loop(i,0,b)
#define pb push_back
#define mp make_pair

string c(9,0);
vi n(9);

bool ok(vector<pair<int, char>> t){
    if (t[0].second != t[1].second || t[1].second != t[2].second)
        return false;

    if (t[0].first == t[1].first && t[1].first == t[2].first)
        return true;

    sort(all(t));
    if (t[0].first == t[1].first - 1 && t[1].first == t[2].first - 1)
        return true;
    return false;
}

int solve(){
    vector<pair<int, char>> v(9);
    rep(i, 9) v[i] = make_pair(n[i], c[i]);
    vi g{ 0, 0, 0, 1, 1, 1, 2, 2, 2 };
    do{
        vector<vector<pair<int,char>>> tri(3);
        rep(i, 9) tri[g[i]].push_back(v[i]);
        if (all_of(all(tri), ok))
            return 1;
    } while (next_permutation(all(g)));
    return 0;
}

int main(){
    int k; cin >> k;
    rep(i, k){
        rep(j, 9) cin >> n[j];
        rep(j, 9) cin >> c[j];
        cout << solve() << endl;
    }
}

Measured memory_bytes: 1212
#include <stdio.h>
#define MAX 500000
#define INFTY 2000000000
 
void mergesort(int *,int,int);
void merge(int *,int,int,int);
 
int l[MAX/2+2],r[MAX/2+2];
int count;
int s[MAX];
 
int main()
{
 
  int n,i;
  count=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&s[i]);
  }
 
  mergesort(s,0,n);
 
  for(i=0;i<n;i++){
    if(i>0) printf(" ");
    printf("%d",s[i]);
  }
  printf("\n");
  printf("%d\n",count);
 
  return 0;
}
 
 
 
void mergesort(int a[],int left,int right)
{
  int mid;
  if(left+1<right){
    mid=(left+right)/2;
    mergesort(a,left, mid);
    mergesort(a,mid,right);
    merge(a,left,mid,right);
  }
}
 
void merge(int a[],int left,int mid,int right)
{
  int i,j,k,n1,n2;
  n1=mid-left;
  n2=right-mid;
  for(i=0;i<n1;i++)
    l[i]=a[left+i];
  for(i=0;i<n2;i++)
    r[i]=a[mid+i];
  l[n1]=INFTY;
  r[n2]=INFTY;
  i=0;
  j=0;
  for(k=left;k<right;k++){
    count++;
    if(l[i]<=r[j])
      a[k]=l[i++];
    else
      a[k]=r[j++];
  }
}

Measured memory_bytes: 4508