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

typedef int64_t ll;
#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define INF LONG_MAX
struct edge{ll to, cost;};
typedef pair<ll,ll> P;
struct graph{
  ll V;
  vector<vector<edge> > G;
  vector<ll> d;

  graph(ll n){
    init(n);
  }

  void init(ll n){
    V = n;
    G.resize(V);
    d.resize(V);
    REP(i,V){
      d[i] = INF;
    }
  }

  void add_edge(ll s, ll t, ll cost){
    edge e;
    e.to = t, e.cost = cost;
    G[s].push_back(e);
  }

  void dijkstra(ll s){
    REP(i,V){
      d[i] = INF;
    }
    d[s] = 0;
    priority_queue<P,vector<P>, greater<P> > que;
    que.push(P(0,s));
    while(!que.empty()){
      P p = que.top(); que.pop();
      ll v = p.second;
      if(d[v]<p.first) continue;
      for(auto e : G[v]){
        if(d[e.to]>d[v]+e.cost){
          d[e.to] = d[v]+e.cost;
          que.push(P(d[e.to],e.to));
        }
      }
    }
  }
};


int main(void) {
    int64_t K;
    int64_t ans;
    cin >> K;
    
    graph g(K);
    for(int i=0;i<K;i++) {
        if(i == (K-1)) {
            g.add_edge(i,0,1);
        } else {
            g.add_edge(i,i+1,1);
        }
        g.add_edge(i,(i*10)%K,0);
    }
    
    g.dijkstra(1);
    cout << g.d[0]+1 << "\n";
    return 0;
}


Measured memory_bytes: 9208
#include <iostream>
#include <cstdlib>
#include <algorithm>
using namespace std;
int main(){
    int n;
    cin>>n;
    int a[n];
    for (int i=0;i<n;i++){
        cin>>a[i];
    }
    int dp[n];
    dp[0]=0;
    dp[1]=abs(a[1]-a[0]);
    for (int i=2;i<n;i++){
        dp[i]=min((dp[i-2]+abs(a[i]-a[i-2])),(dp[i-1]+abs(a[i]-a[i-1])));
    }
    cout<<dp[n-1]<<endl;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int n;
int v[20+10],c[20+10];
int sum;
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)    cin>>v[i];
    for(int i=0;i<n;i++)    cin>>c[i];
    for(int i=0;i<n;i++)
    {
        if(v[i]>c[i])   sum+=v[i]-c[i];
    }
    cout<<sum;
    return 0;
}

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

string JoinWithSpace(int *array, int size);

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

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

	for (int i = 1; i < n; i++) {
		cout << JoinWithSpace(array, n) << endl;
		int current = array[i];
		int j = i - 1;
		while (j >= 0 && array[j] > current) {
			array[j + 1] = array[j];
			j--;
		}
		array[j + 1] = current;
	}

	cout << JoinWithSpace(array, n) << endl;
	return 0;
}

string JoinWithSpace(int *array, int size) {
	ostringstream oss;
	for (int i = 0; i < size - 1; i++) {
		oss << array[i] << " ";
	}
	oss << array[size - 1];
	return oss.str();
}

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

int main() {
	string s;
	bool sev = false;
	cin >> s;
	for(int i = 0;i < 3;i++){
		if(s[i] == '7')sev = true;
	}
	if(sev)cout << "Yes" << endl;
	else cout << "No" << endl;
 }



Measured memory_bytes: 3628
#include<bits/stdc++.h>
#define REP(i, n) for(int i=0; i<n; i++)
using namespace std;
using ll = long long;
int main() {
    int L, R, d;
    cin >> L >> R >> d;

    int ans = 0;
    for (int i = L; i <= R; i++)
    {
        if(i%d==0) ans++;

    }
    
    cout << ans << endl;
}

Measured memory_bytes: 3628
import numpy as np
N = int(input())-1
As = list(map(int,input().split()))
ans = [0 for i in range(N+1)]
ans[0] = sum(As)
for i in range(N):
	if i % 2 == 1:
		ans[0] -= 2*As[i]
for i in range(1,N+1):
	ans[i] = 2*As[i-1]-ans[i-1]
s = ""
for e in ans:
    s += str(e)
    s += ' '
print(s[:-1])


Measured memory_bytes: 24320
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n;
	cin >> n;

	int m = (n * (n-2) + n % 2) / 2;
	cout << m << endl;

	for (int i = 1; i < n; ++i) {
		int block = n%2 ? n-i : n+1-i;
		for (int j = i+1; j <= n; ++j)
			if (j != block)
				cout << i << " " << j << endl;
	}

	return 0;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(10 ** 9)
input = sys.stdin.readline
from itertools import permutations,  combinations, accumulate
from functools import *
from collections import deque, defaultdict, Counter
from heapq import heapify, heappop, heappush, heappushpop

INF = float('inf')
NIL = - 1

""" Input
S = input().rstrip()
N = int(input())
A = np.array(input().split(), dtype=np.float64)
D = [int(input()) for _ in range(N)]
PX = [[int(x) for x in input().split()] for _ in range(Q)]
"""
import numpy as np


def distance(x, y, D):
    total = 0
    for d in range(D):
        total += np.abs(x[d] - y[d]) ** 2
    return np.sqrt(total)


N, D = map(int, input().split())
X = [[int(x) for x in input().split()] for _ in range(N)]

ret = []
for i in range(N):
    for j in range(i+1, N):
        ret.append(distance(X[i], X[j], D))

counter = 0
for x in ret:
    if x - int(x) > 0:
        continue
    else:
        counter += 1


print(counter)

# def main():

# if __name__ == '__main__':
#     main()


Measured memory_bytes: 13400
#include <cstdio>
#include <functional>
#include <vector>
#include <tuple>
#include <algorithm>
#include <deque>
#include <memory>

using namespace std;

using ll = long long;
int n, m;
int digits[9];
int sticks_for_digits[10] = {-1,2,5,5,4,5,6,3,7,6};
bool called[10000];
bool reachable[10000];

struct Node {
  int value;
  shared_ptr<Node> next;
  Node(int v, shared_ptr<Node> n) : value(v), next(n) {};
  // ~Node() { printf("~Node(%d)\n", value); }
};
struct LinkedList {
  shared_ptr<Node> root;
  int length;
  LinkedList() : length(0) {};
  LinkedList(int v, LinkedList& tail) : length(tail.length+1), root(make_shared<Node>(v, tail.root)) {};
  bool empty()
  {
    return length == 0;
  }
  int size()
  {
    return length;
  }
};
LinkedList nil;
LinkedList cons(int value, LinkedList& list)
{
  return LinkedList(value, list);
}
LinkedList dp[10000];

bool is_left_ge(LinkedList& left, LinkedList& right)
{
  if (left.length > right.length) return true;
  if (left.length < right.length) return false;
  shared_ptr<Node> l = left.root;
  shared_ptr<Node> r = right.root;
  while (!((l == nullptr) && (r == nullptr))) {
    if (l->value > r->value) return true;
    if (l->value < r->value) return false;
    l = l->next;
    r = r->next;
  }
  return true;
}

void solve(int sticks)
{
  if (called[sticks]) return;
  called[sticks] = true;
  LinkedList cur;// = nil;
  //printf("entering solve(%d)\n", sticks);
  //cur.push_back(0);
  for (int i = 0; i < m; i++) {
    int to_consume = sticks_for_digits[digits[i]];
    if (sticks < to_consume) continue;
    solve(sticks-to_consume);
    /*printf("solve(%d) =", sticks-to_consume);
    Node *ptr = dp[sticks-to_consume];
    while (ptr) {
      printf("%d", ptr->value);
      ptr = ptr->next;
    }
    printf("\n");*/
    if (!reachable[sticks-to_consume]) continue;
    LinkedList newlist = cons(digits[i], dp[sticks-to_consume]);
    if (is_left_ge(newlist, cur)) {
      cur = newlist;
    }
  }
  if (cur.length == 0) {
    int c = 0;
    for (int i = 0; i < m; i++) {
      if (sticks_for_digits[digits[i]] == sticks) {
        c = max(c, digits[i]);
      }
    }
    if (c != 0) {
      cur = cons(c, nil);
    }
  }
  else if (cur.length == 1) {
    for (int i = 0; i < m; i++) {
      if (sticks_for_digits[digits[i]] == sticks) {
        cur.root->value = max(cur.root->value, digits[i]);
      }
    }
  }
  if (cur.length != 0) {
    dp[sticks] = cur;
    reachable[sticks] = true;
  }
}

int main()
{
  scanf("%d %d", &n, &m);
  for (int i = 0; i < m; i++) {
    scanf("%d", &(digits[i]));
    //int sticks = sticks_for_digits[digits[i]];
    //digits_for_sticks[sticks] = max(digits_for_sticks[sticks], digits[i]);
  }
  reachable[0] = true;
  called[0] = true;
  dp[0] = LinkedList();
  solve(n);
  shared_ptr<Node> ptr = dp[n].root;
  vector<int> ds;
  while (ptr) {
    ds.push_back(ptr->value);
    ptr = ptr->next;
  }
  for (auto d : ds) {
    printf("%d", d);
  }
  printf("\n");
  return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <queue>
#include <cstring>
#include <vector>
#include <map>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <bitset>
#include <set>
using namespace std;

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define RREP(i,n) for(int i=n-1;i>=0;i--)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)
#define all(i,n) (i),(i+n)

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

typedef pair<int, int> P;
typedef pair<string, int> SP;
typedef long long ll;

const int INF = 1e9;
const ll LLINF = 1e18;
const int MAX_V = 1e6+1;
const ll mod = 1000000007;

// --------------------------------------
int h, w;
char a[1000][1000];

bool grid_inside(int x, int y) {
  if(0 <= x && x < h && 0 <= y && y < w) return true;
  else return false;
}

struct Grid { int x, y, c; };

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

  cin >> h >> w;
  queue<Grid> que;

  REP(i, h) REP(j, w) {
    cin >> a[i][j];
    Grid g = {i, j, 0};
    if(a[i][j] == '#') que.push(g);
  }

  int ans = 0;
  while(!que.empty()) {
    Grid g = que.front(); que.pop();
    REP(i, 4) {
      int nx = g.x + dx4[i];
      int ny = g.y + dy4[i];
      if(grid_inside(nx, ny) && a[nx][ny] == '.') {
        Grid ng = { nx, ny, g.c + 1 };
        que.push(ng);
        ans = max(ans, g.c + 1);
        a[nx][ny] = '#';
      }
    }
  }

  cout << ans << endl;
}


Measured memory_bytes: 13328
/*
    Auther: ghoshashis545 Ashis Ghosh
    College: jalpaiguri Govt Enggineering College
    Date:12/06/2020
*/
#include<bits/stdc++.h>
#include<string>
#include<algorithm>
using namespace std;
#define ll long long
#define int ll
#define ld long double
#define ff first
#define ss string 
#define se second
#define alt(v) v.begin(),v.end()
#define pb emplace_back
#define mp make_pair
#define fab(i,a,b) for(ll i=(a);i<(b);i++)
#define fba(i,a,b) for(ll i=(b);i>=(a);i--)
// ll mod=1000000007;
int dx[]={1,0,-1,0};
int dy[]={0,1,0,-1};

const int N=1e5+5;
int cache[N][3];
int a[N][3];
int n;
int dp(int idx,int f)
{
    if(idx==n)
    return 0;
    int &ans=cache[idx][f];
    if(ans!=-1)
    return ans;
    ans=0;
    for(int i=0;i<3;i++)
    {
        if(i==f)
        continue;
        ans=max(ans,dp(idx+1,i));
    }
    ans+=a[idx][f];
    return ans;
        
}
bool test=0;
void solve()
{
    cin>>n;
    memset(cache,-1,sizeof(cache));
    for(int i=0;i<n;i++)
    cin>>a[i][0]>>a[i][1]>>a[i][2];
    int ans=0;
    for(int i=0;i<3;i++)
        ans=max(ans,dp(0,i));
    cout<<ans;
}








signed main()
{
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    cin.exceptions(cin.failbit);
//     #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// 	#endif
    int t=1;
    if(test)
    cin>>t;
    while(t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 9600
use std::io::*;
use std::str::FromStr;
use std::collections::VecDeque;

//https://qiita.com/tubo28/items/e6076e9040da57368845
fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let s: Vec<char> = read::<String>().chars().collect();
    let mut buf = VecDeque::new();

    for c in s.iter(){
        if c == &'B' {
            buf.pop_back();
        }else{
            buf.push_back(c);
        }
    }

    for c in buf.iter(){
        print!("{}", c);
    }

    println!("");
}


Measured memory_bytes: 4352
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <cmath>
#include <queue>
#include <numeric>
#include <climits>
#include <iterator>
#include <iomanip>
#include <stack>
#include <set>
#include <cstdio>
#include <bitset>
#include <functional>
#include <tuple>
#include <list>
#include <deque>
using namespace std;
typedef pair<int, int> P;

#define FOR(i, a, n) for (ll i = (ll)a; i<(ll)n; ++i)
#define REP(i, n) FOR(i, 0, n)

typedef long long ll;
typedef vector<int> VI;

int a[200010];
int b[200010];
int main() {
    cin.tie(0);
   	ios::sync_with_stdio(false);
    
    ll n; cin >> n;
    map<string, int> mp;
    REP(i, n){
        ll a; string b; cin >> a;
        if(a==0){
            int c;
            cin >> b >> c;
            mp[b] = c;
        }else if(a==1){
            cin >> b;
            cout << mp[b] << endl;
        }else if(a==2){
            cin >> b;
            mp.erase(b);
        }else if(a==3){
            string c;
            cin >> b >> c;
            for(auto it=mp.lower_bound(b); it!=mp.upper_bound(c); ++it){
                if((*it).second) cout << (*it).first << " " << (*it).second << endl;
            }
            
        }
    }
	return 0;
}


Measured memory_bytes: 25912
#include <bits/stdc++.h>
using namespace std;
#define ll long long
ll a[1000001],i,j,n,m,sum=0;
int main()
{
	cin>>n;
	for(i=1;i<=n;i++)
	{
		scanf("%lld",&a[i]);
	}
	sort(a+1,a+n+1);
	for(i=2;i<=n;i++)
	{
		if(a[i]==a[i-1])
		{
			sum++;
		}
	}
	sum=(sum+1)/2*2;
	cout<<n-sum;
	return 0;
}

Measured memory_bytes: 1024
<?php
  $s = trim(fgets(STDIN));
  $s = explode(' ',$s);
  $a = $s[0];
  $b = $s[1];
 
  if ($a < $b) {
    echo 'a < b' . PHP_EOL;
  } elseif ($a > $b) {
    echo 'a > b' . PHP_EOL;
  } else {
    echo 'a == b' . PHP_EOL;
  }

Measured memory_bytes: 15328
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <utility>
#include <map>
#include <set>
using namespace std;
vector<long long> divisor(long long n){//nの約数列挙
    vector<long long> res;
    for(long long i = 1; i * i <= n; i++){
        if(n % i == 0){
            res.push_back(i);
            if(i != n / i) res.push_back(n / i);
        }
    }
    return res;
}
long long gcd(long long x, long long y){
    if(x < y) swap(x, y);
    if( x % y == 0) return y;
    return gcd(y, x % y);
}
int main(){
    int N, K;
    cin >> N >> K;
    vector<long long> A(N);
    long long sum = 0;
    for(int i = 0; i < N; i++) {
        cin >> A[i];
        sum += A[i];
    }
    long long g = 0;
    for(int i = 1; i < N; i++){
        if(i == 1) g = gcd(A[i], A[i - 1]);
        else g = gcd(g, A[i]); 
    }
    vector<long long> div = divisor(sum);
    sort(div.begin(), div.end());
    for(int i = 0; i < (int)div.size(); i++){
        long long mosum = 0;
        vector<int> mo;
        if(div[i] > g){
            for(int j = 0; j < N; j++){
                if(A[j] % div[i] != 0) mo.push_back(A[j] % div[i]);
            }
            sort(mo.begin(), mo.end());
            int k = mo.size() - 1, h = 0;
            long long c = 0;
            while(k > h){
                c += mo[h];
                mosum += mo[h];
                h++;
                while(c > 0){
                    int res = min(c, div[i] - mo[k]);
                    c -= res;
                    mo[k] += res;
                    if(c > 0) k--;
                }
            }
            if(mosum <= K) g = div[i];
        }
    }
    cout << g << endl;
}

Measured memory_bytes: 3664
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007, INF=(1LL<<60);
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    ll r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    t = " " + t;
    map<char, ll> mp;
    mp['s'] = r;
    mp['p'] = s;
    mp['r'] = p;
    bool maki[n+1];
    memset(maki, 0, sizeof(maki));
    vector<ll> dp(n+1, 0);
    for(int i=1;i<=n;i++){
    	if(i - k > 0){
    		if(t[i] == t[i-k] && maki[i-k]){
    			dp[i] = dp[i-1];
    		}else{
    			dp[i] = dp[i-1] + mp[t[i]];
    			maki[i] = 1;
    		}
    	}else{
    		dp[i] = dp[i-1] + mp[t[i]];
    		maki[i] = 1;
    	}
    }
    cout << dp[n] << endl;
    return 0;
}


Measured memory_bytes: 1408
#include<stdio.h>
int main(void)
{
   int a,b,c,x;
   scanf("%d%d%d",&a,&b,&c);
   if(a>b){
      x=a;
      a=b;
      b=x;
   }
   if(a>c){
      x=a;
      a=c;
      c=x;
   }
   if(b>c){
      x=b;
      b=c;
      c=x;
   }
   printf("%d %d %d\n",a,b,c);
   return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
bool Check(int x) {
	char a[10]={};
	sprintf(a,"%d",x);
	int i=0,j=strlen(a)-1;
	while(i<j) {
		if(a[i]!=a[j])
			return false;
		i++,j--;
	}
	return true;
}
int main() {
	#ifdef LOACL
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
	int A,B,ans=0;
	scanf("%d %d",&A,&B);
	for(int i=A;i<=B;i++) {
		if(Check(i)) {
			ans++;
		}
	}
	printf("%d\n",ans);
	return 0;
}

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

template <class t>
using vc = vector<t>;
template <class t>
using vvc = vector<vector<t>>;
typedef long long ll;
typedef vc<int> vi;
typedef vvc<int> vvi;
typedef pair<int, int> pi;

#define uset unordered_set
#define umap unordered_map

#define endl "\n"

#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define rbg rbegin()
#define red rend()

#define all(a) a.bg, a.ed

template <class t, class u>
ostream &operator<<(ostream &os, const pair<t, u> &p) {
    return os << "( " << p.first << ", " << p.second << " )";
}

template <class t>
ostream &operator<<(ostream &os, const vc<t> &v) {
    os << "[ ";
    for (int i = 0; i < v.size(); i++) {
        os << v[i];
        if (i != v.size() - 1) {
            os << ", ";
        }
    }
    return os << " ]";
}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    // cout << fixed << setprecision(18);
    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    // Solution

    int n;
    cin >> n;
    vc<string> cities;
    umap<string, vi> city_score;
    umap<int, int> score_index;
    string s;
    int p;
    for (int i = 1; i <= n; i++) {
        cin >> s;
        cin >> p;
        if (city_score.count(s) == 0) {
            cities.push_back(s);
        }
        city_score[s].push_back(p);
        score_index[p] = i;
    }
    for (auto &e : city_score) {
        sort(e.second.rbg, e.second.red);
    }
    sort(cities.bg, cities.ed);
    for (auto &c : cities) {
        for (auto &score : city_score[c]) {
            cout << score_index[score] << endl;
        }
    }
}


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

int main() {
    int N, K; cin >> N >> K;
    ll h[100010];
    REP(i, N) cin >> h[i];

    ll INF = 1LL << 60;
    ll dp[101000];
    REP(i, 100010) dp[i] = INF;
    dp[0] = 0;

    REP(i, N) {
        FOR(j, 1, K+1) {
            chmin(dp[i+j], dp[i] + abs(h[i] - h[i+j]));
        }
    }
    cout << dp[N-1] << endl;
}


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

int main(){
    long long int x;
    cin >> x;

    vector<long long int> exp5(1000);
    for(long long int i=0; i<1000; i++){
        exp5[i] = i * i * i * i * i;
        //cout << exp5[i] << endl;
    }

    for(int i=0; i<1000; i++){
        long long int b5 = abs(exp5[i] - x);
        int l = lower_bound(exp5.begin(), exp5.end(), b5) - exp5.begin();
        int r = upper_bound(exp5.begin(), exp5.end(), b5) - exp5.begin();
        //cout << b5 << " " << l << " " << r << endl;
        if(r - l == 1){
            if(x > exp5[i]) l *= -1;
            cout << i << " " << l << endl;
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 3584
#include<bits/stdc++.h>
using namespace std;
const int N=105;
int n,a[N],ans;
int main()
{
	scanf("%d",&n);
	for(int i=1;i<=n;i++)
		scanf("%d",&a[i]);
	sort(a+1,a+n+1);
	for(int i=1;i<=n;i++)
		for(int j=i+1;j<=n;j++)
			for(int k=j+1;k<=n;k++)
				if(a[i]+a[j]>a[k]&&a[i]!=a[j]&&a[j]!=a[k])
					ans++;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 3808
#include <bits/stdc++.h>
#define rep(i,a,b) for(int i=a; i< (int)(b); ++i)
#define ALL(x) (x).begin(),(x).end()
#define rALL(x) (x).rbegin(),(x).rend()
typedef long double ld;
using ll=long long;
using namespace std;
const int mod=1e9+7;
const ll inf = 1LL << 60;
const ld pi = (acos(-1));
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }




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

  int n; cin >> n;
  int ans=1000000;
  for(int i=0; i<=6;i++){
    if(pow(2,i)<=n and n<pow(2,i+1)) ans=pow(2,i);
  }
  cout << ans << endl;
}

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

int main() {
  unsigned long long a, b;
  cin >> a >> b;
  unsigned long long gcd;
  unsigned long long x;
  x =  a * b;
  if ( a < b){
    int tmp = a;
    a = b;
    b = tmp;
  }
  gcd = a % b;
  while(gcd){
    a = b;
    b = gcd;
    gcd = a % b;
  }
  cout << x / b << endl;
  
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>
#include <utility>
#include <map>
#include <unordered_map>
#define rep(i,n) for(int i=0;i<n;++i)
using namespace std;
typedef long long int ll;

int main() {
  int N,K;
  cin>>N>>K;
  
  vector<int> H(N);
  rep(i,N){
    cin>>H[i];
  }
  
  ll ans=0;
  sort(H.begin(),H.end());
  for(int i=0;i<N-K;++i){
    ans+=H[i];
  }
  
  cout<<ans<<endl;
  
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 
#define scd second
#define fst first
#define pb push_back
#define mkp make_pair
#define all(x) x.begin(), x.end()
#define VT(T) vector<T>
 
using namespace std;
 
typedef long long int ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<int> vint;
typedef vector<ll> vlong;
typedef vector<pii> vpii;
typedef vector<pll> vpll;
typedef vector<vint> vvint;
typedef vector<vlong> vvlong;
typedef list<int> lint;
typedef list<ll> llong;
typedef list<pii> lpii;
typedef list<pll> lpll;
typedef list<lint> llint;
typedef list<llong> lllong;
 
ll const LINF=numeric_limits<long long int>::max();
int const INF=numeric_limits<int>::max();
 
ll gcd(ll a, ll b){
	return b ? gcd(b,a%b) : a;
}
 
ll pow_mod(ll a, ll e, ll m){
	ll res=1;
	while(e){
		if(e&1) res=res*a%m;
		a=a*a%m;
		e>>=1;
	}
	return res;
}
 
ll inv_mod(ll b, ll m){
	b%=m;
	ll x=0, y=1, r, q, a=m;
	while(b){
		q=a/b;
		r=a%b;
		a=b;
		b=r;
		r=x;
		x=y;
		y=r-q*y;
	}
	x+=m;
	return x%m;
}

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

	int n, cnt=0;
	cin>>n;
	int a=n+1;
	for(int i=0; i<n; i++){
		int p;
		cin>>p;
		if(p<a) cnt++;
		a=min(a,p);
	}

	cout<<cnt<<endl;
}

Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/

#include <bits/stdc++.h>

#define rt0 return 0
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++) 
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))

using namespace std;

const LL MOD=1e9+7;

string s;
LL dp[100010][5];//第二维0：什么都没有；1：最后一个是A的组合个数，后面以此类推 

int main()
{
	cin>>s;
	dp[0][0]=1;
	rep(i,s.size())
	{
		rep(j,4) dp[i+1][j]=(dp[i+1][j]+dp[i][j]*(s[i]=='?' ? 3:1))%MOD;
		if(s[i]=='A'||s[i]=='?') dp[i+1][1]=(dp[i+1][1]+dp[i][0])%MOD;
		if(s[i]=='B'||s[i]=='?') dp[i+1][2]=(dp[i+1][2]+dp[i][1])%MOD;
		if(s[i]=='C'||s[i]=='?') dp[i+1][3]=(dp[i+1][3]+dp[i][2])%MOD;
	}
	cout<<dp[s.size()][3]<<endl;
	rt0;
}

Measured memory_bytes: 4352
#include <iostream>
#include <vector>
using namespace std;
int foods[] = {100, 101, 102, 103, 104, 105};
int num = 5;
bool dfs(int x, int pos)
{
    if(x == 0) return true;
    if(x < 0 or pos > num) return false;
    bool ok = dfs(x - foods[pos], pos) or dfs(x, pos + 1);
    return ok;
}
signed main()
{
    int x; cin >> x;
    cout << (dfs(x, 0) ? "1" : "0") << endl;
    return 0;
}

Measured memory_bytes: 256
require 'prime'
require 'set'
require 'tsort'
include Math
def max(a,b);              a > b ? a : b                              end
def min(a,b);              a < b ?  a : b                             end
def swap(a,b);             a, b = b, a                                end
def gif;                   gets.to_i                                  end
def gff;                   gets.to_f                                  end
def gsf;                   gets.chomp                                 end
def gi;                    gets.split.map(&:to_i)                     end
def gf;                    gets.split.map(&:to_f)                     end
def gs;                    gets.chomp.split.map(&:to_s)               end
def gc;                    gets.chomp.split('')                       end
def pr(num);               num.prime_division                         end
def digit(num);            num.to_s.length                            end
def array(s,ini=nil);      Array.new(s){ini}                          end
def darray(s1,s2,ini=nil); Array.new(s1){Array.new(s2){ini}}          end
def rep(num);              num.times{|i|yield(i)}                     end
def repl(st,en,n=1);       st.step(en,n){|i|yield(i)}                 end

n = gif
s = []
rep n do
s << gif
end

s.sort!
sum = s.inject(:+)
s.each do |ss|
break if sum % 10 != 0
next if ss % 10 == 0
sum -= ss
end
if sum % 10 == 0
puts 0
else
  puts sum
end

Measured memory_bytes: 2300
#include<stdio.h>

int main(int argc, char *argv[]){

  int a, b, c, d;
  scanf("%1d%1d%1d%1d", &a, &b, &c, &d);
  //printf("%d %d %d %d\n", a, b, c, d);

  while(1){
    if(      (a+b+c+d)==7){
      printf("%d+%d+%d+%d=7\n", a, b, c, d);
      break;
    }else if((a+b+c-d)==7){
      printf("%d+%d+%d-%d=7\n", a, b, c, d);
      break;
    }else if((a+b-c+d)==7){
      printf("%d+%d-%d+%d=7\n", a, b, c, d);
      break;
    }else if((a+b-c-d)==7){
      printf("%d+%d-%d-%d=7\n", a, b, c, d);
      break;
    }else if((a-b+c+d)==7){
      printf("%d-%d+%d+%d=7\n", a, b, c, d);
      break;
    }else if((a-b+c-d)==7){
      printf("%d-%d+%d-%d=7\n", a, b, c, d);
      break;
    }else if((a-b-c+d)==7){
      printf("%d-%d-%d+%d=7\n", a, b, c, d);
      break;
    }else if((a-b-c-d)==7){
      printf("%d-%d-%d-%d=7\n", a, b, c, d);
      break;
    }else{
      break;
    }
  }

  return 0;
}


Measured memory_bytes: 128
n,m = map(int, input().split())
hs = list(map(int, input().split()))
d = [1]*n

for i in range(m):
    a,b = map(int, input().split())
    if hs[a-1] <= hs[b-1]:
        d[a-1] = 0
    if hs[a-1] >= hs[b-1]:
        d[b-1] = 0
    
print(d.count(1))

Measured memory_bytes: 20020
#include<bits/stdc++.h>
using namespace std;
int main() {
	string a,b;
	char c[100005];
	cin>>a>>b;
	int lena=a.size();
	int lenb=b.size();
	for(int i=1;i<=lena+lenb;i++){
		if(i%2==0){
			c[i]=b[i/2-1];
		}
		else{
			c[i]=a[i/2];
		}
	}
	for(int i=1;i<=lena+lenb;i++){
		cout<<c[i];
	}
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <set>
#include <utility>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <map>

const int CMax = 102;

using namespace std;

int main()
{
   int sum = 0, sk;

    for (int i = 0; i < 3; i++) {
        scanf("%d", &sk);
        sum += sk;
    }

    if (sum > 21) cout << "bust" << endl;
    else cout << "win" << endl;

    return 0;
}



Measured memory_bytes: 256
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys
import math
from functools import reduce

def input():
    return sys.stdin.readline()

def gcd(*numbers):
    return reduce(math.gcd, numbers)

def resolve():
    k = int(input())



    sum_ans = 0
    for i in range(1, k+1):
        for j in range(1, k+1):
            for k in range(1, k+1):
                sum_ans += gcd(i, j, k)

    print(sum_ans)






if __name__ == "__main__":
    resolve()



Measured memory_bytes: 69284
#include <bits/stdc++.h>
using namespace std;
#define rep(i, a) for (int i = 0; i < (a); i++)
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
typedef long long ll;
template<typename T>istream& operator>>(istream&i,vector<T>&v){rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(const vector<T>&v){stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,const vector<T>&v){if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v){return i>>v.first>>v.second;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,const pair<T1,T2>&v){return o<<v.first<<","<<v.second;}
template<typename T>bool mins(T& x,const T&y){if(x>y){x=y;return true;}else return false;}
template<typename T>bool maxs(T& x,const T&y){if(x<y){x=y;return true;}else return false;}
template<typename T>ll suma(const vector<T>&a){ll res(0);for(auto&&x:a)res+=x;return res;}

#ifdef _DEBUG
inline void dump() { cerr << endl; }
template <typename Head> void dump(Head &&head) {
  cerr << head;
  dump();
}
template <typename Head, typename... Tail>
void dump(Head &&head, Tail &&... tail) {
  cerr << head << ", ";
  dump(forward<Tail>(tail)...);
}
#define dbg(...)                                                               \
  do {                                                                         \
    cerr << __LINE__ << ":\t" << #__VA_ARGS__ << " = ";                        \
    dump(__VA_ARGS__);                                                         \
  } while (false)
#else
#define dump(...)
#define dbg(...)
#endif

template <typename T> struct edge {
  int src, to;
  T cost;
  edge(int to, T cost) : src(-1), to(to), cost(cost) {}
  edge(int src, int to, T cost) : src(src), to(to), cost(cost) {}
  edge &operator=(const int &x) {
    to = x;
    return *this;
  }
  operator int() const { return to; }
};
template <typename T> using Edges = vector<edge<T>>;
template <typename T> using WeightedGraph = vector<Edges<T>>;
using UnWeightedGraph = vector<vector<int>>;
template <typename T> using Matrix = vector<vector<T>>;

const ll LINF = 1LL << 60;
const int INF = 1001001001;

/////////////////////////////////////////////////////////////////////

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

  string key = "keyence";

  int n = s.size();
  for (int i=0; i<n; i++) {
    for (int j=i+1; j<n; j++) {
      string t = s.substr(0, i+1) + s.substr(j);
      if (t == key) {
        cout << "YES" << endl;
        return 0;
      }
    }
  }
  cout << "NO" << endl;

  return 0;
}


Measured memory_bytes: 3600
#include <bits/stdc++.h>
typedef long long ll;
using namespace std;
int main(){
    int k;
    cin>>k;
    vector<ll> a;
    for(int i=1;i<=9;i++){
        a.push_back(i);
    }
    while(1){
        if(k<=a.size()){
            cout<<a[k-1]<<endl;
            return 0;
        }
        k-=a.size();
        vector<ll> kari;
        swap(a,kari);
        for(ll x:kari){
            for(int i=-1;i<=1;i++){
                int d=x%10+i;
                if(d<0||d>9) continue;
                ll nx=x*10+d;
                a.push_back(nx);
            }
        }
    }
}

Measured memory_bytes: 1712
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>
#include <map>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

int main() {
    int N, a;
    map<int, int> mii;
    cin >> N;
    REP(i, N) {
        cin >> a;
        mii[a]++;
    }

    int ans = 0;
    FOR(i, 1, 1e5 + 1) {
        ans = max(mii[i - 1] + mii[i] + mii[i + 1], ans);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <map>
#include <stack>
using namespace std;
int n, m, cnt;

int main(){
	cin >> n;
	vector<int> v(n+1);
	for (int i = 0; i < n; ++i) {
		int a; cin >> a;
		v[i] = a;
	}
	cin >> m;
	vector<int> num(m);
	for (int i = 0; i < m; ++i) {
		int a; cin >> a;
		num[i] = a;
	}
	for (int i = 0; i < m; ++i) {
		int key = num[i];
		v[n] = key;
		int j = 0;
		while (true) {
			if (v[j] == key) break;
			j++;
		}
		if (j == n) continue;
		else cnt++;
	}
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 3096
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<int,int> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const LL mod=1000000007;
const LL LINF=1LL<<60;
const int INF=1<<30;
int dx[]={1,0,1,-1,1,-1,-1,0};
int dy[]={0,1,1,-1,-1,1,0,-1};



int main(){
    int h,n;cin >> h >> n;
    vector<LL> dp(1<<17,LINF);
    vector<LL> a(n),b(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
    }
    dp[0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < h; j++) {
            if(dp[j] == LINF) continue;
            chmin(dp[j + a[i]],dp[j] + b[i]);
        }
    }
    LL ans = LINF;
    for (int i = h; i < 1<<17; i++) {
        chmin(ans, dp[i]);
    }
    cout << ans << endl;
    return 0;
}


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

int half_and_round_off(int n);

int main(void)
{
	char str[101];
	int flag;
	int left, right;
	int i, n;
	int ans = 0;
	
	while (~scanf("%s", str)){
		flag = 1;
		left = 0;
		right = strlen(str) - 1;
		n = half_and_round_off(strlen(str));
		
		for (i = 0; i < n; i++){
			if (str[left] != str[right]){
				flag = 0;
				break;
			}
			left++;
			right--;
		}
		
		if (flag) ans++;
	}
	
	printf("%d\n", ans);
	
	return (0);
}

int half_and_round_off(int n)
{
	double ans;
	
	ans = (double)n;
	
	return ((int)((ans / 2.0) + 0.5));
}

Measured memory_bytes: 540
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner stdIn=new Scanner(System.in);
		int N=stdIn.nextInt();
		String S=stdIn.next();
		long e[]=new long[N+1];
		long w[]=new long[N+1];
		int z=0;
		long y=0,x=0;
		while(z<N){
			if(S.charAt(z)=='W')
				y++;
			if(S.charAt(N-z-1)=='E')
				x++;
			w[z+1]=y;e[N-z-1]=x;
			z++;
		}z=0;y=0;x=3*100000;
		while(z<N){
			y=w[z]+e[z+1];
			if(y<x)
				x=y;
			z++;
		}
		System.out.println(x);
	}
}

Measured memory_bytes: 32848
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); i ++)
using namespace std;
typedef long long ll;
typedef pair<ll,ll> PL;
typedef pair<int,int> P;
const int INF = 1e9;
const ll MOD = 1e9 + 7;

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

    vector<int> cum(n + 1);
    rep(i,n) cum[i + 1] = (cum[i] + a[i])%k;

    map<int,int> mp;
    mp[0] = 0;
    ll ans = 0;
    queue<int> q;
    rep(i,n + 1) {
        ans += mp[cum[i]];
        mp[cum[i]] ++;
        q.push(cum[i]);
        if (q.size() == k) {
            mp[q.front()] --;
            q.pop();
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 12032
n = int(input())
C = [[0] * 10 for _ in range(10)]
for i in range(1, n + 1):
  C[int(str(i)[0])][i % 10] += 1
  
ans = 0
for i in range(10):
  for j in range(10):
    ans += C[i][j] * C[j][i]
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
typedef long long ll;
using namespace std;

int main(void) {
  ll i, j, k, n, a, b, ans = 0;
  scanf("%lld", &n);
  ll be;
  for(i = 0; i < n; ++i) {
    scanf("%lld", &a);
    if(i) {
      if(be == a) {
        ++ans;
         be = -1;
      } else be = a;
    } else {
      be = a;
    }
  }
  printf("%lld", ans);
  return 0;
}

Measured memory_bytes: 128
n=int(input())
h=list(map(int,input().split()))
ans=0

def f(li):
  global ans
  
  #終了条件
  if li==[]:
    del li
    return
  
  #再帰
  min_num=min(li)
  if min(li)>0:
    ans+=min(li)
    li=list(map(lambda x: x-min(li), li))
  li=[li[:li.index(0)],li[li.index(0)+1:]]
  f(li[0])
  f(li[1])

f(h)
print(ans)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define vi vector<int>
#define vvi vector<vi>
#define vs vector<string>
#define pb push_back
#define P pair<int,int>
#define vp vector<P>
#define PP pair<int,P>
#define vpp vector<PP>
#define fi first
#define se second
#define INF 1e9
#define MOD 1000000007
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define all(x) (x).begin(),(x).end()
int V;
vvi G;
int dfs(int now){
    int res=0;
    vi vec;
    REP(i,G[now].size()){
        vec.pb(dfs(G[now][i]));
    }
    sort(all(vec),greater<int>());
    REP(i,vec.size()){
        res=max(res,vec[i]+i+1);
    }
    return res;
}
int main(){
    cin>>V;
    G.resize(V);
    REP(i,V-1){
        int t;
        cin>>t;
        t--;
        G[t].pb(i+1);
    }
    cout<<dfs(0)<<endl;
    return 0;
}

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

int main() {
  int64_t n;
  cin>>n;
  int z=0;
  if(n==1){
    cout<<1;
  }
  else{
  for(int i=1;i<n;i++){
    if(((i*(i+1))/2)<=n&&(((i+1)*(i+2))/2)>n){
      z+=i+1;
      break;
    }
  }
  int jyogai=((z*(z+1))/2)-n;
  for(int i=1;i<=z;i++){
    if(i==jyogai){
      continue;
    }
    cout<<i<<endl;
  }
  }
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main{
    public static void main(String[] args){
	int i,j,maxago=Integer.MIN_VALUE,min,max=Integer.MIN_VALUE;
	
	Scanner sca = new Scanner(System.in);
	i=sca.nextInt();
	int[] hai= new int[i];
	hai[0]=sca.nextInt();
	min=hai[0];
	for(i=1;i<hai.length;i++){//i->max(assuming)
	    hai[i]=sca.nextInt();
	    if(hai[i]-min>maxago){
		max=hai[i];
		maxago=max-min;
	    }
	    if(hai[i]<min){
		min=hai[i];
	    }
	    
	}
	System.out.println(maxago);
    }
}




Measured memory_bytes: 101360
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        int n = Integer.parseInt(br.readLine());
        StringTokenizer st = new StringTokenizer(br.readLine());
        Double[][] soln = new Double[n][Math.max(1, (n - 1) / 2 + 1)];
        for(int i=0;i<n;i++){
            for(int j=0; j<(n - 1) / 2 + 1; j++){
                soln[i][j]=0D;
            }
        }
        Double[] coins = new Double[n];
        Double prod = 1D;
        for(int i=0;i<n;i++){
            coins[i]=Double.parseDouble(st.nextToken());
            prod*=coins[i];
        }

        if(n==1){
            System.out.println(coins[0]);
            return;
        }

        soln[0][0]=coins[0];
        soln[0][1]=1-coins[0];
        soln[n-1][0]=prod;


        for(int i=1;i<n;i++){
            soln[i][0]=soln[i-1][0]*coins[i];
            for(int j=1;j<=Math.min(i+1,(n-1)/2); j++){
                soln[i][j]=soln[i-1][j]*coins[i] + soln[i-1][j-1]*(1-coins[i]);
            }
        }
        double sum=0;
        for(int i=0;i<=(n-1)/2;i++){
            sum+=soln[n-1][i];
        }
        System.out.println(sum);

    }


}


Measured memory_bytes: 258184
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll mod = 1000000007;

int main(){
  ll n;
  cin >> n;
  vector<pair<ll,ll>>a(n);
  for(int i=0; i<n; i++ ){
    ll x,y;
    cin >> x >> y;
    a[i].first=x+y;
    a[i].second=x-y;
  }
  sort(a.begin(),a.end());
  
  ll count=0;
  for(int i=0; i<n; i++){
    ll base=a[i].second;
    bool next=false;
    ll j=i;
    while(!next){
      j++;
      if(a[j].second>=a[i].first){
        i=j-1;
        next=true;
        count++;
      }
    }
  }
  
  
  cout << count << endl;
  
}
  
  
  


Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
const ll MOD = 1e9 + 7;


int main() {
	ll N;
	cin >> N;
	vector<vector<pair<int,int>>> g(N + 1);
	rep(i, N-1) {
		int a, b,c;
		cin >> a;
		cin >> b;
		cin >> c;
		g[a].pb(make_pair(b, c));
		g[b].push_back(mp(a, c));
	}
	int Q, K;
	cin >> Q >> K;
	vll distK(N + 1, -1);
	distK[K] = 0;
	queue<int> q;
	q.push(K);
	while (!q.empty()) {
		int v = q.front();
		q.pop();
		for (pair<int, int> u : g[v]) {
			if (distK[u.first] != -1) continue;
			distK[u.first] = distK[v] + u.second;
			q.push(u.first);
		}
	}
	vi x(Q);
	vi y(Q);
	rep(i, Q) {
		cin >> x[i];
		cin >> y[i];
	}
	rep(i, Q) {
		ll ans = 0;
		ans += distK[x[i]];
		ans += distK[y[i]];
		cout << ans << endl;
	}
}

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

#define endl '\n'

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

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

    int ans = 0;
    for (int i=0, cur=1; i<n; i++){
        if (a[i] == cur){
            cur++;
        } else{
            ans++;
        }
    }
    cout << (ans == n ? -1 : ans) << endl;

}

Measured memory_bytes: 1024
def main():
    A, B, C = map(int, input().split())
    misery = False
    if A == B:
        if C != A:
            misery = True
    elif B == C:
        if A != B:
            misery = True
    elif C == A:
        if B != A:
            misery = True
    if misery :
        print("Yes")
    else:
        print("No")
if __name__ == "__main__":
    main()

Measured memory_bytes: 3060
#include <iostream>
using namespace std;
typedef long long ll;

int main() {
    int N;
    bool is_overflow = false;
    bool is_zero = false;
    ll res = 1, max = 1e18;
    cin >> N;
    for (int i = 0; i < N; ++i){
        ll a;
        cin >> a;
        if (a == 0) {
            is_zero = true;
            break;
        }
        if ( (double)a > (double)max / (double)res ) {
            is_overflow = true;
        }
        res *= a;
        if (res > max) {
            is_overflow = true;
        }
    }

    if (is_zero){
        cout << 0 << endl;
    } else if (is_overflow){
        cout << -1 << endl;
    } else{
        cout << res << endl;    
    }
	return 0;
}

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

using namespace std;

#define ok1 printf("ok1\n");
#define ok2 printf("ok2\n");
#define M 1000000000000000000LL
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,s,n) for(int i=(s);i<(n);i++)
#define repr(i,n) for(int i=n-1;i>=0;i--)
#define REPR(i,s,n) for(int i=(s);i>=(n);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define pb push_back
#define pf push_front
#define MIN(a,b) a=min((a),(b))
#define MAX(a,b) a=max((a),(b))
#define SIZE(v) (int)v.size()
#define Eunique(v) v.erace(unique(all(v)),v.end())
#define pvec(v)　rep(i,v.size()){cout << v[i] << " ";}
#define INF 0x3f3f3f3f
#define mset(m,v) memset(m,v,sezeof(m))
#define mod (ll)(1e9 +7);

const double pi = acos(-1.0);

typedef vector<int> vi;
typedef string ss;
typedef vector<string> vs;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vll> vvll;
typedef deque<ll> dll;
typedef pair<ll,ll> P;
ll dx[4] = {1,0,-1,0},dy[4] = {0,1,0,-1};

ll gcd(ll x,ll y)
{
    ll r;
    while((r = x % y) != 0)
    {
        x = y;
        y = r;
    }
    return y;
}

ll lcm(ll a,ll b){
    ll g = gcd(a,b);
    return a / g * b; // Be careful not to overflow
}

ll digsum(ll n){
    ll sum = 0;
    while(n > 0){
        sum += n % 10;
        n /= 10;
    }

    return sum;
}

int main()
{
    ll n;
    cin >> n;
    vll a(n),tmp(n);
    rep(i,n){
        cin >> a[i];
        tmp[i] = a[i];
    }

    sort(all(tmp));

    rep(i,n){
        if(a[i] != tmp[n-1])cout << tmp[n-1] << endl;
        else cout << tmp[n-2] << endl;
    }
    
    return 0;
}

Measured memory_bytes: 4736
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>

using namespace std;

int main() {
	vector<int> l(3, 0);
	cin >> l[0] >> l[1] >> l[2];

	sort(l.begin(), l.end());
	int S = l[0] * l[1] / 2;
	cout << S << endl;
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,w[105],f[105],ans=2e9;
int main()
{
	cin >> n;
	for(int i = 1; i <= n; i++){
		cin >> w[i];
		f[i]=f[i-1]+w[i];
	}
	for(int i = 1; i < n; i++){
		ans = min(ans,abs(f[n]-f[i]-f[i]));
	}
	cout << ans << endl;
	return 0;
 } 

Measured memory_bytes: 256
import itertools

n_str = input()
n = int(n_str)
digits = len(n_str)
nums = ('3', '5', '7')
count = 0
for i in range(3, digits + 1):
    for strs in itertools.product(*[nums]*i):
        m = int(''.join(strs))
        if ('3' in strs) and ('5' in strs) and ('7' in strs) and m <= n:
            count += 1
print(count)


Measured memory_bytes: 3060
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <cstdlib>
using namespace std;
#define Ma_PI 3.141592653589793
#define eps 0.00000000000000000000000001
#define LONG_INF 10000000000000000
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
int main() {
	int a, b, c;
	cin >> a >> b >> c;
	cout << a + b + c << endl;
}


Measured memory_bytes: 3120