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

using namespace std;

using ll = long long;

int main() {
    int N, M;
    cin >> N >> M;
    vector<vector<int>> adj(N);
    for (int i = 0; i < M; i++) {
        int a, b;
        cin >> a >> b, a--, b--;
        adj[a].push_back(b);
        adj[b].push_back(a);
    }
    deque<int> q;
    vector<int> from(N, -1);
    int cnt = 1;
    q.push_back(0);
    from[0] = 0;
    while (cnt < N && q.size() > 0) {
        int x = q.front();
        q.pop_front();
        for (int y : adj[x]) {
            if (from[y] == -1) {
                from[y] = x;
                q.push_back(y);
                cnt++;
            }
        }
    }
    if (cnt == N) {
        cout << "Yes" << endl;
        for (int i = 1; i < N; i++) {
            cout << from[i] + 1 << endl;
        }
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 10104
#include<stdio.h>
int main(void){
   int a[200], k, key = 1, i, l;
   a[0] = 0;
   for( i = 0; i < 201; i++ ) a[i] = 0;
   while ( scanf("%d", &k) != EOF ) {
      if (k == 0) {
         key--;
         for (l = 0; l < 201; l++) {
            if( a[l] == key) {
               printf("%d\n", l);
               a[l] = 0;
            }
         }
      } else {
         a[k] = key;
         key++;
      }
   }
   return 0;
}

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

int main () {
char c;
cin >> c ;

if ( c  == 'a'  || c  == 'i'  || c  == 'u'  || c  == 'e'  || c  == 'o'  ){
cout <<  "vowel" << endl ;
}
else cout << "consonant"  << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
#define endl '\n'
#ifndef FAST_IO
 #define IOS ios_base::sync_with_stdio(false),cin.tie(nullptr);
#endif
#define all(c) c.begin(),c.end()
template<typename T>void print(T t){for(auto &it:t)cout<<it<<" ";cout<<endl;}
void solve(){
  int n;
  cin>>n;
  cout<<(n>999?"ABD":"ABC")<<endl;
}
int32_t main(){
  IOS;
  solve();
  #ifdef LOCAL_DEFINE
  cerr<<"time elapsed "<<(double)clock()/LCOKS_PER_SEC<<endl;
  #endif
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>

int main(){
	long long mod= 1000000007;
	long long ans= 0;

	int n;
	std::string s;
	std::vector<long long> alpList(26, 0);

	std::cin>>n;
	std::cin>>s;

	for(int i=0; i<n; i++)
		alpList[s[i]-'a']++;

	for(int i=0; i<26; i++){
		ans= (ans+ ans*alpList[i])%mod;
		ans= (ans+ alpList[i])%mod;
	}

	std::cout<<ans<<std::endl;
}

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

int main(){
    int N, M, k;
    int p[12];
    vector<vector<int>> s;

    cin >> N >> M;
    for(int m=0;m<M;m++){
        cin >> k;
        s.push_back(vector<int>(k, 0));
        for(int i=0;i<k;i++){
            cin >> s[m][i];
        }
    }
    for(int m=0;m<M;m++) cin >> p[m];

    int ans = 0;
    for(int bit=0;bit<(1<<N);bit++){
        bool all_bright = true;
        for(int m=0;m<M;m++){
            int pnow = 0;
            for(auto smk: s[m]){
                pnow += (bool)(bit & (1<<(smk-1)));
            }
            if(pnow % 2 != p[m]) all_bright = false;
        }
        if(all_bright) ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N;
  cin >> N;
  
  int h, H;
  cin >> H;
  H--;
  
  for (int i=1; i<N; i++) {
    cin >> h;
    if(H - h >= 1){
      cout << "No" <<endl;
    return 0;;
    }
    if(h > H)
      H = h - 1;
    }
  cout <<"Yes"<<endl;
  
}


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

using namespace std;
using llong = long long;
using ldbl = long double;
using lpair = pair<llong, llong>;

#define ALL(x) x.begin(), x.end()

template<typename T>
constexpr T inf = static_cast<T>(pow(10, static_cast<int>(log10(numeric_limits<T>::max())))) + 7;
constexpr llong mod = 1e9+7;

int main() {
	array<int, 2> m, d;
	for (int i = 0; i < 2; ++i) {
		cin >> m[i] >> d[i];
	}

	cout << m[1] - m[0] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <stdio.h>
#include <cmath>
#include <cfloat>
#include <algorithm>
#include <numeric>
#include <vector>
#include <iterator>
#include <set>
using namespace std;

const double PI=acos(-1);

int main(){
    int n, t, a;
    cin >> n >> t >> a;

    int h, ii = -1;
    double min = 9999999;
    for(int i = 0; i < n; i++){
        cin >> h;
        double b = fabs(a - (t - (double)h * 0.006));
        min = std::min(min, b);
        if(fabs(min - b) < DBL_EPSILON ) ii = i+1;
    }
    cout << ii << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import numpy as np
input = sys.stdin.buffer.readline

INF = 10 ** 9

N, Ma, Mb = map(int, input().split())
abcs = [tuple(map(int, input().split())) for _ in range(N)]

delta_c = [(Mb * a - Ma * b, c) for a, b, c in abcs]

cost = INF
positives = []
negatives = []
for delta, c in delta_c:
    if delta == 0:
        cost = min(cost, c)
    elif delta > 0:
        positives.append((delta, c))
    else:
        negatives.append((-delta, c))

dp_pos = np.full(401, INF, np.int64)
dp_pos[0] = 0
for delta, c in positives:
    dp_pos[delta:] = np.minimum(dp_pos[:-delta] + c, dp_pos[delta:])

dp_neg = np.full(401, INF, np.int64)
dp_neg[0] = 0
for delta, c in negatives:
    dp_neg[delta:] = np.minimum(dp_neg[:-delta] + c, dp_neg[delta:])

cost = min(cost, np.amin(dp_pos[1:] + dp_neg[1:]))
if cost >= INF:
    print(-1)
else:
    print(cost)


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

using namespace std;
typedef long long ll;

#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, a, b) for (int i = (a); i < (b); ++i)
#define all(a) (a).begin(), (a).end()

int main()
{
        int N;
        cin >> N;
        set<int> S;

        rep(i, N)
        {
                int d;
                cin >> d;
                S.insert(d);
        }


        
        cout << S.size() << endl;

        return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
typedef long double ld;
typedef complex<ld> Point;
const ll INF = mod * mod;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
const ld eps = 1e-6;
const ld pi = acos(-1.0);
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;

vector<ll> h[1 << 17];
bool fin[1 << 17];

void rotate(vector<int> &c, vector<int> &p) {
	vector<int> ret(p.size());
	rep(i, p.size()) {
		ret[i] = p[c[i]];
	}
	c = ret;
}

ll gcd(ll x, ll y) {
	if (x < y)swap(x, y);
	while (y) {
		ll r = x % y; x = y; y = r;
	}
	return x;
}
ll lcd(ll x, ll y) {
	ll g = gcd(x, y);
	return x / g * y;
}

struct SegT {
private:
	int sz; vector<ll> node;
	const ll init_c = 1;
public:
	ll f(ll a, ll b) {
		return lcd(a, b);
	}
	SegT(int n) {
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
	}
	SegT(vector<ll> v) {
		int n = v.size();
		sz = 1;
		while (sz < n)sz *= 2;
		node.resize(2 * sz - 1, init_c);
		rep(i, n) {
			node[i + sz - 1] = v[i];
		}
		per(i, sz - 1) {
			node[i] = f(node[2 * i + 1], node[2 * i + 2]);
		}
	}
	ll query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0)r = sz;
		if (r <= a || b <= l)return init_c;
		else if (a <= l && r <= b)return node[k];
		else {
			ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
			ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
			return f(vl, vr);
		}
	}
};
ll mod_inverse(ll x, ll n=mod-2) {
	ll ret = 1;
	while (n) {
		if (n % 2)ret = x * ret%mod;
		x = x * x%mod; n >>= 1;
	}
	return ret;
}

void solve() {
	int n,q; cin >> n >> q;
	vector<int> p(n); 
	rep(i, n) {
		cin >> p[i]; p[i]--;
	}
	vector<int> cur;
	rep(i, n)cur.push_back(i);
	rep1(i, 40) {
		rotate(cur, p);
		rep(j, n) {
			if (fin[j])continue;
			h[j].push_back(cur[j]);
			if (cur[j] == j) {
				fin[j] = true;
			}
		}
	}
	vector<ll>ch;
	rep(i, n)ch.push_back(h[i].size());
	SegT st(ch);
	vector<ll> rs(n + 1);
	rep(i, n) {
		ll sum = 0;
		rep(j, h[i].size()) {
			sum += h[i][j]+1;
		}
		sum = sum * mod_inverse(h[i].size()) % mod;
		rs[i + 1] = rs[i] + sum;
		if (rs[i + 1] >= mod)rs[i + 1] -= mod;
	}
	rep(i, q) {
		int l, r; cin >> l >> r; l--; r--;
		ll z = st.query(l, r + 1); z %= mod;
		ll zz = rs[r + 1] - rs[l];
		if (zz < 0)zz += mod;
		ll ans = zz * z%mod;
		cout << ans << endl;
	}
	//rep(i, h[0].size())cout << h[0][i] << endl;
}

int main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	solve();
	//stop
	return 0;
}


Measured memory_bytes: 62868
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define FORit(it,a) for(auto it=a.begin();it!=a.end();it++)
#define ROF(i,a,b) for(int i=a;i>=b;i--)
#define vec vector
#define vi vec<int>
#define vll vec<ll>
#define pb push_back
#define pp pop_back
#define all(x) x.begin(),x.end()
#define testcases ll t;cin>>t;while(t--)
#define mem(a,k) memset(a,k,sizeof(a))
#define F first
#define S second
#define MP(x,y) make_pair(x,y)
#define rt return
#define br break
#define ct continue
#define elif else if
#define ii pair<ll,ll>
#define vecin(a,n,index) for(int i=index;i<n;i++)cin>>a[i]
#define vecout(a,n,index) for(int i=index;i<n;i++)cout<<a[i]<<" ";cout<<endl;
//ll mod = 1000000007;
void solve() {
	string s;
	cin >> s;
	if (s[s.length() - 1] == 's')cout << s << "es" << endl;
	else cout << s << "s" << endl;
}
int main()
{
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
	ios_base::sync_with_stdio(false);	cin.tie(NULL);	cout.tie(NULL);
	// START FROM HERE :)
	solve();
}

Measured memory_bytes: 3648
#include <iostream>
#include <algorithm>
#include <bitset>
#include <tuple>
#include <cstdint>
#include <cstdio>
#include <cctype>
#include <assert.h>
#include <stdlib.h>
#include <stdio.h>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <ctime>
#include <deque>
#include <fstream>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <list>
#include <limits>
#include <map>
#include <memory>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>
#include <math.h>
#define int long long
using namespace std;
signed main() {
	int N;
    cin>>N;

    if(N<2){
        cout<<1<<endl;
    }
    else if(N<4){
        cout<<2<<endl;
    }
    else if(N<8){
        cout<<4<<endl;
    }
    else if(N<16){
        cout<<8<<endl;
    }
    else if(N<32){
        cout<<16<<endl;
    }
    else if(N<64){
        cout<<32<<endl;
    }
    else{
        cout<<64<<endl;
    }
}

Measured memory_bytes: 3476
import java.util.*;

public class Main{
  public static void main(String[] args){
    Scanner scanner = new Scanner(System.in);
    while(true){
      int a = scanner.nextInt();
      int b = scanner.nextInt();
      if(a == 0 && b == 0){
        break;
      }

      for(int j = 0; j < a; j++){
        if(j != 0){
          System.out.print("\n");
        }
        for(int k = 0; k < b; k++){
          if(j == 0 || j == a - 1 || k == 0 || k == b - 1){
            System.out.print("#");
          }
          else{
            System.out.print(".");
          }
        }
      }
      System.out.print("\n\n");
    }
  }
  }

Measured memory_bytes: 36632
#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 a, b;
    cin >> a >> b;

    int ans = max(a - 2*b, 0);
    cout << ans << endl;
    return 0;
}


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

int main(){
    int n,k;    cin >> n >> k;
    ll ans = 1;
    rep(i, n){
        if(i == 0){
            ans *= k;
        }else{
            ans *= (k-1);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
object methods {
  def solver: Unit = {

    val tempList: Seq[Seq[String]] = {
      for(line <- io.Source.stdin.getLines()) yield {
        line.split(' ').toSeq
      }
    }.toSeq

    val S: String = tempList(0)(0)
    val T: String = tempList(1)(0)

    var i = 0
    var notSame: Int = 0
    while(i < S.size){
      if(S(i) != T(i)) notSame += 1
      i += 1
    }

    println(notSame)

  }
}

object Main extends App {
  methods.solver
}

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

using namespace std;

int calcMaximumProfit(vector<int> a) {
	int max_p = -1001001001;
	int min_r = a[0];
	int s = (int)a.size();
	int curr_p;
	for (int i = 1; i < s; i++) {
		curr_p = a[i] - min_r;
		max_p = max(curr_p, max_p);
		if (min_r > a[i]) min_r = a[i];
	}
	return max_p;
}

int main() {

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

	int ans = calcMaximumProfit(a);
	cout << ans << endl;

	return 0;
}





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

int n;
string a[10], b[10];
string s, t;

int calc()
{
	typedef pair<string, int> P;
	set<string> visit;
	queue<P> q;
	
	visit.insert(s);
	q.push(P(s, 0));
	while (q.size()){
		auto st = q.front(); q.pop();
		auto str = st.first;
		auto cnt = st.second;
		if (str == t) return cnt;
		//cout << "_" << str << endl;
		for (int i = 0; i < n; i++){
			string to;
			for (int j = 0; j < str.size(); ){
				if (string(str, j, a[i].size()) != a[i]){
					to += str[j];
					j++;
				}
				else {
					to += b[i];
					j += a[i].size();
				}
			}
			if (visit.count(to)) continue;
			if (to.size() > t.size()) continue;
			visit.insert(to);
			q.push(P(to, cnt + 1));
		}
	}
	return -1;
}

int main()
{
	while (scanf("%d", &n), n){
		for (int i = 0; i < n; i++) cin >> a[i] >> b[i];
		cin >> s >> t;
		printf("%d\n", calc());
	}
}

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

int id = INT_MAX;
int merge(int l, int r) {
	return min(l, r);
}

struct node {
	int val;
	int all;
	node *lch, *rch;
	int size;
	node(int v) : val(v), all(v), size(1) {
		lch = rch = nullptr;
	}
};

random_device rd;

int count(node *t) { return t == nullptr ? 0 : t->size; }
int que(node *t) { return t == nullptr ? id : t->all; }
node *update(node *t) {
	t->size = count(t->lch) + count(t->rch) + 1;
	t->all = merge(que(t->lch), merge(t->val, que(t->rch)));
	return t;
}
node *merge(node *l, node *r) {
	if (l == nullptr || r == nullptr) return l == nullptr ? r : l;
	if (rd() % (l->size + r->size) < l->size) {
		l->rch = merge(l->rch, r);
		return update(l);
	}
	else {
		r->lch = merge(l, r->lch);
		return update(r);
	}
}
pair<node*, node*> split(node *t, int k) {
	if (t == nullptr) return make_pair(nullptr, nullptr);
	if (k <= count(t->lch)) {
		pair<node*, node*> s = split(t->lch, k);
		t->lch = s.second;
		return make_pair(s.first, update(t));
	}
	else {
		pair<node*, node*> s = split(t->rch, k - count(t->lch) - 1);
		t->rch = s.first;
		return make_pair(update(t), s.second);
	}
}
node *insert(node *t, int k, int v) {
	pair<node*, node*> s = split(t, k);
	node *r = merge(s.first, new node(v));
	r = merge(r, s.second);
	return r;
}
node *erase(node *t, int k) {
	pair<node*, node*> s1 = split(t, k), s2 = split(s1.second, 1);
	if (s2.first != nullptr) delete s2.first;
	return merge(s1.first, s2.second);
}
node *find(node *t, int k) {
	if (t == nullptr) return t;
	int c = count(t->lch);
	return k < c ? find(t->lch, k) : k == c ? t : find(t->rch, k - (c + 1));
}
int find(node *t, int l, int r) {
	if (t == nullptr) return id;
	if (r < 0 || l >= count(t)) return id;
	if (l <= 0 && r >= count(t)) return t->all;
	int c = count(t->lch);
	return merge(t->lch == nullptr ? id : find(t->lch, l, r), merge(l <= c && c < r ? t->val : id, t->rch == nullptr ? id : find(t->rch, l - (c + 1), r - (c + 1))));
}
int cnt(node *t, int v) {
	if (t == nullptr) return 0;
	if (t->val < v) return count(t->lch) + 1 + cnt(t->rch, v);
	if (t->val == v) return count(t->lch);
	return cnt(t->lch, v);
}
void print(node *t) {
	if (t == nullptr) return;
	print(t->lch);
	printf(" %d", t->val);
	print(t->rch);
}
node *shift(node *t, int l, int r) {
	pair<node*, node*> s1 = split(t, l), s2 = split(s1.second, r - l), s3 = split(s2.second, 1);
	return merge(s1.first, merge(s3.first, merge(s2.first, s3.second)));
}
void change(node *t, int k, int v) {
	if (t == nullptr) return;
	int c = count(t->lch);
	if (k < c) {
		change(t->lch, k, v);
		update(t);
	}
	else if (k > c) {
		change(t->rch, k - (c + 1), v);
		update(t);
	}
	else {
		t->val = v;
		update(t);
	}
}

int main()
{
	cin.sync_with_stdio(false);
	int n, q, x, y, z;
	cin >> n >> q;
	node *root = nullptr;
	for (int i = 0, a; i < n; i++) {
		cin >> a;
		root = insert(root, i, a);
	}
	while (q--) {
		cin >> x >> y >> z;
		if (x == 0) {
			root = shift(root, y, z);
		}
		else if (x == 1) {
			printf("%d\n", find(root, y, z + 1));
		}
		else {
			change(root, y, z);
		}
	}
	return 0;
}

Measured memory_bytes: 12712
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <functional>
#include "math.h"

using namespace std;
#define FOR(i,a,b) for (int i=(a);i<(b);i++)
#define RFOR(i,a,b) for (int i=(b)-1;i>=(a);i--)
#define REP(i,n) for (int i=0;i<(n);i++)
#define RREP(i,n) for (int i=(n)-1;i>=0;i--)
#define VI vector<int>
#define debug(x) cout<<#x<<": "<<x<<endl
#define DEBUG(x) cout<<#x<<": "<<x<<endl
int N,K;
vector <int > H;





int main()
{

	int M;
	cin >> M;
	cout << 48-M;





}



Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
//Optimisations
#pragma GCC target ("avx2")
#pragma GCC optimization ("unroll-loops")
#pragma GCC optimize("O2")
//shortcuts for functions
#define pb push_back
#define mp make_pair
#define ff first 
#define ss second
#define all(v) v.begin(),v.end()
#define prec(n) fixed<<setprecision(n)
#define n_l '\n'
// make it python 
#define gcd __gcd
#define append push_back
#define str to_string
// utility functions shortcuts
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
#define sswap(a,b) {a=a^b;b=a^b;a=a^b;}
#define swap(a,b) {auto temp=a; a=b; b=temp;}
#define init(dp) memset(dp,-1,sizeof(dp));
#define set0(dp) memset(dp,0,sizeof(dp));
#define bits(x) __builtin_popcount(x)
#define SORT(v) sort(all(v))
#define endl "\n"
#define forr(i,n) for(ll i=0;i<n;i++)
// declaration shortcuts
typedef long long int ll;
#define int ll
// Constants
constexpr int dx[] = {-1, 0, 1, 0, 1, 1, -1, -1};
constexpr int dy[] = {0, -1, 0, 1, 1, -1, 1, -1};
constexpr ll INF = 1999999999999999997; 
constexpr int inf= INT_MAX;
constexpr int MAXSIZE = int(1e6)+5;
constexpr auto PI  = 3.14159265358979323846L;
constexpr auto oo  = numeric_limits<int>::max() / 2 - 2;
constexpr auto eps = 1e-6;
constexpr auto mod = 1000000007;
constexpr auto MOD = 1000000007;
constexpr auto MOD9 = 1000000009;
constexpr auto maxn = 100006;
//void IOfile(){
//freopen(file_name, reade_mode, stdin);
//freopen(file_name, write_mode, stdout);
//}
void fastio(){
ios_base::sync_with_stdio(false);
cin.tie(NULL);
}

int cnt[10][10];

int32_t main(){
	fastio();
	int n;
	cin >> n;
	for(int i = 1; i <= n; i++){
		int k = i;
		string s = to_string(k);
		cnt[s[0]-'0'][s[s.size()-1]-'0']++;
	}
	int ans = 0;
	for(int i = 0; i <= 9; i++){
		for(int j = 0; j <= 9; j++){
			ans += cnt[i][j] * cnt[j][i];
		}
	}
	cout << ans;
}

Measured memory_bytes: 3728
n = int(input())
h = list(map(int, input().split()))

INF = 1 << 40
dp = [INF] * n
dp[0] = 0
dp[1] = abs(h[1] - h[0])
for i in range(1, n - 1):
	dp[i + 1] = min(dp[i-1] + abs(h[i+1] - h[i-1]), dp[i] + abs(h[i+1] - h[i]))

print(dp[-1])

Measured memory_bytes: 52304
#include <bits/stdc++.h>
using namespace std;
const int MM=100013;
const int inf=2000000013;
long long dp[113][MM];
pair<int,int> T[MM];
int main()
{
    ios_base::sync_with_stdio(0);
    int n,W;
    cin>>n>>W;
    for(int i=1;i<=n;i++)   cin>>T[i].first>>T[i].second;
    for(int i=1;i<=n;i++)   for(int j=0;j<=100000;j++)  dp[i][j]=inf;
    dp[1][T[1].second]=T[1].first;
    for(int i=2;i<=n;i++)
    {
        for(int j=1;j<=100000;j++)  dp[i][j]=dp[i-1][j];
        dp[i][T[i].second]=min(dp[i][T[i].second],(long long)T[i].first);
        for(int j=T[i].second+1;j<=100000;j++)
        {
            dp[i][j]=min(dp[i-1][j],dp[i-1][j-T[i].second]+T[i].first);
        }
    }
    int wyn=100000;
    while(dp[n][wyn]>W) wyn--;
    cout<<wyn<<endl;
    return 0;
}


Measured memory_bytes: 78592
n, m = list(map(int, input().split()))
h = list(map(int, input().split()))
a = [0] * m
b = [0] * m
for i in range(m):
    a[i], b[i] = map(int, input().split())
x = [0] * n
for i in range(m):
    if h[a[i]-1] < h[b[i]-1]:
        x[a[i]-1] += 1
    elif h[a[i]-1] == h[b[i]-1]:
        x[a[i]-1] += 1
        x[b[i]-1] += 1
    else:
        x[b[i]-1] += 1
print(x.count(0))


Measured memory_bytes: 21860
/* ***********************************************
Author        :taciturnity
Created Time  :2020/2/21 8:23:51
File Name     :TEST.cpp
************************************************ */

#include <iostream>
#include <vector>
#include <queue>
#include <cstdio>
#include <map>
#include <set>
#include <stack>
#include <string>
#include <cmath>
#include <bitset>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <unordered_map>
#define ll long long
#define INF 0x3f3f3f3f
#define rep(i,x,y) for(int i = x;i <= y;++i)
#define fori(i,x,y) for(int i = x;i >= y; -- i)
#define bug puts("--------------")
#define out(x) cout<<x<<'\n';
inline char gc(){char op[2];scanf("%s",op);return op[0];}
const int N = 2e5+10;
const double eps = 0.00000001;
const ll mod = 1e9 ;
using namespace std;
ll read()
{
    ll x=0,f=1;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return x*f;
}
int main(){
    ll a,b;
    a = read(),b = read();
    if(a%b==0){
        puts("0");
    }
    else{
        a %= b;
        cout<<min(a,b-a);
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstring>
#include <ctime>
#include <iostream>
#include <map>
#include <numeric>
#include <vector>
#include <queue>

#define ALL(v) (v).begin(),(v).end()
#define dump(a) (cerr << #a << "=" << (a) << endl)
#define DUMP(list) cout << "{␣"; for(auto nth : list){ cout << nth << "␣"; } cout << "}" << endl;

using namespace std;

const int INF = INT_MAX / 3;

int main() {
    int K, T;
    cin >> K >> T;
    vector<int> cakes(T, 0);
    priority_queue<int> que;
    bool flag = false;
    map<int, int> cnt;
    for (int nth = 0; nth < T; ++nth) {
        cin >> cakes[nth];
        cnt[cakes[nth]] += 1;
        if (cnt[cakes[nth]] == T) flag = true;
        que.push(cakes[nth]);
    }

    //sort(ALL(cakes), greater<int>());

    while (que.size() != 1) {
        int c1 = que.top(); que.pop();
        int c2 = que.top(); que.pop();
        int diff = c1 - c2;
        que.push(diff);
    }
    cout << ((flag && T != 1)? 0 : que.top() - 1) << 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;

int main(){
  string s;
  cin >> s;
  string w[]={"SUN","MON","TUE","WED","THU","FRI","SAT"};
  
  rep(i,7)if(w[i]==s)cout << 7-i;
  
  return 0;
}


Measured memory_bytes: 256
from sys import setrecursionlimit, exit
setrecursionlimit(1000000000)

def main():
    n = int(input())
    a = tuple(map(int, input().split()))
    odds = [0] * ((n + 1) // 2 + 1)
    for i, v in enumerate(a[::2]):
        odds[i+1] = odds[i] + v
    if n % 2 == 0:
        evens = [0] * (n // 2 + 1)
        for i, v in enumerate(a[1::2]):
            evens[i+1] = evens[i] + v
        ans = -float('inf')
        for i in range(n // 2 + 1):
            ans = max(ans, odds[i] + evens[-1] - evens[i])
        print(ans)
        return
    ans = odds[-1] - odds[1]
    dp = [float('inf')] * n
    dp[0] = a[0]
    dp[1] = a[1]
    ans = max(ans, max(a[:2]) + odds[-1] - odds[2])
    for i in range(2, n):
        if i % 2 == 0:
            dp[i] = dp[i-2] + a[i]
        else:
            dp[i] = max(dp[i-2], dp[i-3]) + a[i]
            ans = max(ans, max(dp[i-1], dp[i]) + odds[-1] - odds[i//2+2])
    print(ans)

main()

Measured memory_bytes: 34024
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    string s;
    cin>>s;
    ll count=1;
    for(ll i=0;i<n-1;i++)
    {
        if(s[i]!=s[i+1]) count++;
    }
    cout<<count<<"\n";
}

Measured memory_bytes: 512
#include <iostream>
#include <string.h>
#include <stdio.h>
#include <map>
#include <vector>
#include <math.h>
#include <algorithm>
using namespace std;

#define rep(i,a) for(int i=0; i<a; i++)
#define rrep(i,a) for(int i=a; i>=0; i--)
#define loop3(i,j,k,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)
#define loop4(i,j,k,l,a) for(int i=0; i<a; i++)for(int j=0; j<a; j++)if(i!=j)for(int k=0; k<a; k++)if(i!=k&&j!=k)for(int l=0; l<a; l++)if(i!=l&&j!=l&&k!=l)
#define rep1(i,a) for(int i=1; i<=a; i++)

#define scnd1(a) scanf("%d", &a)
#define scnd2(a,b) scanf("%d%d", &a,&b)
#define scnd3(a,b,c) scanf("%d%d%d", &a,&b,&c)
#define scnd4(a,b,c,d) scanf("%d%d%d%d", &a,&b,&c,&d)

#define cin1(a) cin >> a;
#define cin2(a,b) cin >> a >> b;
#define cin3(a,b,c) cin >> a >> b >> c;
#define cin4(a,b,c,d) cin >> a >> b >> c >> d;
#define cout1(a) cout << a << endl;
#define cout2(a,b) cout << a << " " << b << endl;
#define cout3(a,b,c) cout << a << " " << b << " " << c << endl;
#define cout4(a,b,c,d) cout << a << " " << b << " " << c << " " << d << endl;
#define prtd1(a) printf("%d\n", a)
#define prtd2(a,b) printf("%d %d\n", a,b)
#define prtd3(a,b,c) printf("%d %d %d\n", a,b,c)
#define prtd4(a,b,c,d) printf("%d %d %d %d\n", a,b,c,d)

#define mem(a,n) memset( a, n, sizeof(a))

typedef long long ll;

int main() {
    int N, M;
    cin >> N >> M;
    
    if ( N == 1 && M == 1 ) {
        cout << 1 << endl;
    } else if ( N == 1 || M == 1) {
        cout << max( N, M)-2 << endl;
    } else {
        cout << (ll)(N-2)*(M-2) << endl;
    }
}



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

using namespace std;

#define rep(i, n) for (int i = 0; i < n; ++i)
#define stl_rep(itr, x) for (auto itr = x.begin(); itr != x.end(); ++itr)
#define stl_repr(itr, x) for (auto itr = x.rbegin(); itr != x.rend(); ++itr)
#define all(x) x.begin(), x.end()
#define allr(x) x.rbegin(), x.rend()

using llong = long long int;

const static llong MOD = 1000000007;
const static int IINF = INT_MAX;
const static llong LINF = LLONG_MAX;
const static int dx[4] = {1, 0, -1, 0};
const static int dy[4] = {0, 1, 0, -1};

template<typename T> T my_gcd(T a, T b) {
    return (a ? my_gcd(b % a, a) : b);
}
template<typename T> T my_lcm(T a, T b) {
    return a * b / my_gcd(a, b);    
}
llong powmod(llong a, llong n) {
    llong res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }

    return res;
}
llong facmod(llong n) {
    if (n == 0) return 1;
    llong res = n;
    for (int i = n - 1; i > 0; --i) {
        res = (res * i) % MOD;
    }

    return res;
}
llong combmod(llong n, llong k) {
    llong res = 1;
    for (int i = 0; i < k; ++i) {
        res = (res * (n - i)) % MOD;
    } 
    res = (res * powmod(facmod(k), MOD - 2)) % MOD;

    return res;
}

int main (int argc, char *argv[]) {
    cin.tie(0);
    ios::sync_with_stdio(false);

    int n, a, b;
    cin >> n >> a >> b;
    if (n == 2) {
        cout << 0 << endl;
        return 0;
    }

    llong ans = powmod(2, n) - 1;
    ans = (ans - combmod(n, a)) % MOD;
    if (ans < 0) ans += MOD;
    ans = (ans - combmod(n, b)) % MOD;
    if (ans <  0) ans += MOD;

    cout << ans << endl;

    return 0;
}


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

int main(){
  string S;
  cin >> S;
  int max_count=0,count=0;
  for(int i=0;i<S.size();i++){
    if(S.at(i)=='A' || S.at(i)=='T' || S.at(i)=='G' || S.at(i)=='C' ){
      count++;
    }
    else{
      max_count=max(max_count,count);
      count=0;
    }
  }
  cout << max(max_count,count) << endl;
}

Measured memory_bytes: 3548
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  long long N;
  cin >> N;
  vector<string> S(N);
  for (long long i = 0; i < N; i++){
    cin >> S.at(i);
  }
  
  sort(S.begin(), S.end());
  
  long long count = 1;
  for (long long i = 0; i < N - 1; i++){
    if (S.at(i) != S.at(i + 1)){
      count++;
    }
  }
  
  cout << count;
}

Measured memory_bytes: 9600
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string s = Console.ReadLine();
		int N = s.Length;
		int[]A = new int[N];
		int[]S = new int[N];
		for(var i=0;i<N;i++){
			if(s.Substring(i,1)=="R"){
				A[i] = 1;
			} else {
				A[i] = -1;
			}
		}
		int ct = 0;
		for(var i=0;i<N;i++){
			if(A[i]==1){
				ct++;
			} else {
				S[i] = ct;
				ct = 0;
			}
		}
		ct = 0;
		for(var i=N-1;i>=0;i--){
			if(A[i]==-1){
				ct++;
			} else {
				S[i] = ct;
				ct = 0;
			}
		}
      	for(var i=0;i<N;i++){
          if(S[i]>0){
            int s1;
            int s2;
            if(i%2==0){
              s1 = (S[i]+S[i+1]+1)/2;
              s2 = (S[i]+S[i+1])/2;
            } else {
              s1 = (S[i]+S[i+1])/2;
              s2 = (S[i]+S[i+1]+1)/2;
            }
             S[i] = s1;
             S[i+1] = s2;
            　i++;
          }
        }
      int[]S2 = new int[N];
        int ct1 = 0;
      	int ct2 = 0;
      	for(var i=0;i<N-1;i++){
          if(A[i]==1){
             if(i%2==0){
               ct1++;
             } else {
               ct2++;
             }
          }
          if(A[i]==1 && i<N-1 && A[i+1]==-1){
         	if(i%2==1){
              S2[i]+=ct2; S2[i+1]+=ct1;
            } else {
              S2[i]+=ct1; S2[i+1]+=ct2;
            }
            ct1=0;ct2=0;
          }
        }
        ct1 = 0;
      	ct2 = 0;
      	for(var i=N-1;i>=1;i--){
          if(A[i]==-1){
             if(i%2==0){
               ct1++;
             } else {
               ct2++;
             }
          }
          if(A[i]==-1 && i>0 && A[i-1]==1){
         	if(i%2==1){
              S2[i]+=ct2; S2[i-1]+=ct1;
            } else {
              S2[i]+=ct1; S2[i-1]+=ct2;
            }
            ct1=0;ct2=0;
          }
        }
		Console.Write(S2[0]);
		for(var i=1;i<N;i++){
			Console.Write(" "+S2[i]);
		}
	}
}

Measured memory_bytes: 16732
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

#define chmax(a, b) (a) = max(a, b)
#define chmin(a, b) (a) = min(a, b)

int main() {
  vector<string> s(3);
  rep(i, 3) { cin >> s[i]; }

  int i = 0;
  vector<int> idx(3, 0);
  while (idx[i] < s[i].size()) {
    const int nxt = s[i][idx[i]] - 'a';
    idx[i]++;
    i = nxt;
  }
  cout << (char)(i + 'A') << endl;
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define debug(x) cerr << #x << ": " << x << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

ll calc(ll n) {
  ll num = 1;
  for (ll i = 1; i <= 2; i++) {
    num = num * (n - i + 1) / i;
  }
  return num;
}

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

  vector<ll> v(n);
  rep(i, n) {
    cin >> v[i];
  }

  map<ll, ll> mm;

  rep(i, n) {
    mm[v[i]]++;
  }
  ll as = 0;
  for (auto x : mm) {
    if (x.second >= 2) {
      as += calc(x.second);
      debug(as);
    }
  }

  rep(i, n) {
    ll aiu = mm[v[i]];
    if (aiu == 2) {
      cout << as - calc(2) << endl;
    } else {
      cout << as - calc(aiu) + calc(aiu - 1) << endl;
    }
  }

  return 0;
}

Measured memory_bytes: 11008
#include <iostream>
#include <fstream>
#include <cmath>
#include <algorithm>
#include <vector>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <cstdlib>
#include <cstdio>
#include <string>
#include <cstring>
#include <cassert>
#include <utility>
#include <iomanip>
#include <chrono>
#include <random>
#include <bitset>

using namespace std;

#define sz(x) (int) x.size()
#define unique(x) x.erase(unique(x.begin(), x.end()), x.end())
#define all(a) a.begin(), a.end()
#define sqr(x) ((x) * (x)) 
#define y1 aksjdaskdjksjfksdjf
#define left kdnvldvoiwejifejg
#define right lkdsjflksdjfdjfk
#define prev asdasfsadjkjsdfjs
#define tm aklsjdasjdasjdkdjjf
#define lcm hddalkwjeidjjhasda
#define random_shuffle asdasdd

const int MAXN = 105000;

int n;
int a[MAXN];

int main() { 

  scanf("%d", &n);
  for (int i = 0; i < n; i++) {
    scanf("%d", &a[i]);
  }
  sort(a, a + n);

  int mx = 0;
  long long sum = 0;
  for (int i = 0; i < n; i++) {
    if (a[i] > 2 * sum) {
      mx = i;
    }
    sum += a[i];
  }

  cout << n - mx << endl;

  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#include <iostream>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <algorithm>
int main() {
  int N,i,j,M;
  j=0;
  cin>>N;
  M=N;
  int A[N];
  for(i=0;i<N;i++){
  cin>>A[i];
  }
  sort(A, A+N);
  
  for(i=0;i<N;i++){
    
  if(j==A[i]){
  M--;
  }
    j=A[i];
  }
  cout<<M<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define REP(i,n) for(ll i = 0; i<(ll)(n); i++)
#define REPS(i,n) for (ll i = 1; i<=(ll)(n); i++)
#define REPD(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=(a);i<=(b);i++)
#define FORD(i,a,b) for(ll i=(a);i>=(b);i--)
#define pb push_back
#define MOD 1000000007
#define MOD2 998244353
#define PI 3.141592653
#define INF 100000000000000 //14
 
 
int main(){
	ld a; ld b; cin >> a >> b;
	ld c = a*b*100;
    ll d = c;
    cout << d/100 << endl;
} 

Measured memory_bytes: 3644
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N,T;
  cin>>N>>T;
  int ans=1001;
  for(int i=0;i<N;i++){
    int c,t;
    cin>>c>>t;
    if(t<=T)
      ans=min(ans,c);
    }
  if(ans==1001)
    cout<<"TLE"<<endl;
  else
    cout<<ans<<endl;
  }

Measured memory_bytes: 256
import java.util.Scanner;
public class Main
{
		public static boolean f1(char a,char b,char c) {
			if(a>'z')a-=26;if(b>'z')b-=26;if(c>'z')c-=26;
			if(a=='t' && b=='h' && c=='e')return true;
			return false;
		}
		public static boolean f2(char a,char b,char c,char d) {
			if(a>'z')a-=26;if(b>'z')b-=26;if(c>'z')c-=26;if(d>'z')d-=26;
			if(a=='t' && b=='h' && c=='i' && d=='s')return true;
			return false;
		}
		public static boolean f3(char a,char b,char c,char d) {
			if(a>'z')a-=26;if(b>'z')b-=26;if(c>'z')c-=26;if(d>'z')d-=26;
			if(a=='t' && b=='h' && c=='a' && d=='t')return true;
			return false;
		}
        public static void main(String args[]) throws Exception
        {
        		int an=0,i;
                Scanner cin=new Scanner(System.in);
                while(cin.hasNext()) {
                	an=0;
                	String str=cin.nextLine(),tp;
                	for(i=0; i<26; ++i) {
                		tp=str;
                		boolean aa=false,bb=false,cc=false;
                		for(int j=0; j<str.length()-2; ++j) {
                			if(f1((char)(tp.charAt(j)+i),(char)(tp.charAt(j+1)+i),(char)(tp.charAt(j+2)+i))) {
                				cc=true;
                			}
                			if(j!=str.length()-3) {
                				if(f2((char)(tp.charAt(j)+i),(char)(tp.charAt(j+1)+i),(char)(tp.charAt(j+2)+i),(char)(tp.charAt(j+3)+i))) {
                					aa=true;
                				}
                				if(f3((char)(tp.charAt(j)+i),(char)(tp.charAt(j+1)+i),(char)(tp.charAt(j+2)+i),(char)(tp.charAt(j+3)+i))) {
                					bb=true;
                				}
                			}
                		}
                		if(aa || bb || cc){
                			an=i;
                			break;
                		}
                	}
                	for(i=0; i<str.length(); ++i) {
                    	if(str.charAt(i)>='a'&&str.charAt(i)<='z'){
                    		if(str.charAt(i)+an>'z')
                    			System.out.print((char)(str.charAt(i)+an-26));
                    		else System.out.print((char)(str.charAt(i)+an));
                    	}
                    	else System.out.print((char)str.charAt(i));
                    }
                    System.out.println();
                }
                cin.close();
        }
}


Measured memory_bytes: 26172
#include<iostream>
#include<vector>
#include <algorithm>
#include <string>
#include <utility>
#include <set>
#include <map>
#include<cmath>
#include <queue>
#include <numeric>
#include <cassert>

using lli = long long int;
lli inf = 1000000007;
using namespace std;

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


void solve()
{
	lli H, W, N;
	cin >> H >> W >> N;
	map<pair<int, int>, int> m;
	for (int i = 0; i < N; i++) {
		int a, b;
		cin >> a >> b;
		for (int dx = -1; dx <= 1; dx++) {
			for (int dy = -1; dy <= 1; dy++) {
				int x = b + dx, y = a + dy;
				if (H < y || y <= 0 || W < x || x <= 0)continue;
				if (m.count(make_pair(y, x)) == 0)m[make_pair(y, x)] = 0;
				m[make_pair(y, x)]++;
			}
		}
	}
	lli ans[10];
	for (int i = 0; i < 10; i++)ans[i] = 0;
	for (auto e : m) {
		if (1 < e.first.first && e.first.first < H && 1 < e.first.second && e.first.second < W)ans[e.second]++;
	}
	ans[0] = (H - 2) * (W - 2) - accumulate(ans, ans + 10, 0);
	for (int i = 0; i < 10; i++)cout << ans[i] << endl;
}

int main()
{
	solve();
	return 0;
}

Measured memory_bytes: 56448
#include <map>
#include <vector>
#include <cstdio>
using namespace std;
int main(){
	int n=0,N,i,j,k,c;
	scanf("%d",&N);
	vector<map<int,int> >dist(N);
	vector<bool>used(N);
	vector<int>cost(N);
	for(;n<N;n++){
		cost[n]=9999999;
		for(scanf("%d%d",&i,&k);k--;dist[i][j]=c)scanf("%d%d",&j,&c); //i->j cost c
	}
	for(cost[0]=0;;){ //dijkstra
		int m=9999999;
		for(i=0;i<N;i++)if(!used[i]&&m>cost[i])m=cost[i];
		if(m==9999999)break;
		for(j=0;j<N;j++)if(m==cost[j]){
			map<int,int>::iterator it=dist[j].begin();
			for(used[j]=1;it!=dist[j].end();it++)if(cost[it->first]>it->second+cost[j])cost[it->first]=it->second+cost[j];
		}
	}
	for(i=0;i<n;i++)printf("%d %d\n",i,cost[i]);
}

Measured memory_bytes: 24488
X = input()

itr = 0
m = 100000

for a in range(len(X)-2):
    b = int(X[a]) * 100 + int(X[a + 1]) * 10 + int(X[a + 2])
    if m > abs(753 - b):
        m = abs(753 - b)
print(m)


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

const ll MOD = 1e9 + 7;
const int A = 0, G = 1, C = 2, T = 3;
ll dp[101][4][4][4]; //初期値0

int main(){
    int n; cin >> n;
    rep(i,4) rep(j,4) rep(k,4) dp[3][i][j][k] = 1;
    dp[3][A][G][C] = dp[3][A][C][G] = dp[3][G][A][C] = 0;
    for(int i = 4; i <= n; i++){
        rep(j,4){ //i-3文字目
            rep(k,4){ //i-2文字目
                rep(l,4){ //i-1文字目
                    rep(m,4){ //i文字目
                        if((j == A && k == G && m == C) || (j == A && l == G && m == C)) continue;
                        dp[i][k][l][m] = (dp[i][k][l][m] + dp[i-1][j][k][l]) % MOD;
                    }
                }
            }
        }
        dp[i][A][G][C] = dp[i][A][C][G] = dp[i][G][A][C] = 0;
    }
    ll ans = 0;
    rep(i,4) rep(j,4) rep(k,4) ans = (ans + dp[n][i][j][k]) % MOD;
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,a,b) for(int i=(a);i<(b);i++)
#define RREP(i,a,b) for(int i=(a);i>=(b);i--)
#define pq priority_queue
#define P pair<int,int>
#define P2 pair<int,P>
#define P3 pair<int,P2>
typedef long long ll; typedef long double ld;
using namespace std;
const int INF=1e9, MOD=1e9+7, around[]={0,1,1,-1,-1,0,-1,1,0,0};
const ll LINF=1e18;
const ld PI=abs(acos(-1));
ll n;
vector<int> vec;

int main(){
	cin >> n; int pos=0;
	while((1LL<<pos)-1<=n) vec.push_back(pos),pos++;
	pos--; n-=(1LL<<pos)-1; vec.pop_back();
	
	while(n){
		int c=0;
		while((1LL<<c)<=n) c++; c--;
		vec.insert(vec.begin()+c,pos);
		n-=(1LL<<c); pos++;
	}
	
	cout << vec.size()+pos << endl;
	REP(i,0,vec.size()) cout << vec[i]+1 << " ";
	REP(i,0,pos) cout << i+1 << " "; cout << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<math.h>
#include<queue>
#include<deque>
#include<stack>
#include<cstdio>
#include<utility>
#include<set>
#include<list>
#include<cmath>
#include<stdio.h>
#include<string.h>
#include<iomanip>
using namespace std;
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define REP(i, n) FOR(i, 0, n - 1)
#define NREP(i, n) FOR(i, 1, n)
using ll = long long;
using pii = pair<int, int>;
using piii = pair<pii, pii>;
const ll dx[4] = { 0, -1, 1, 0 };
const ll dy[4] = { -1, 0, 0, 1 };
const int INF = 1e9 + 7;
int gcd(int x, int y) {
	if (x < y)swap(x, y);
	if (y == 0)return x;
	return gcd(y, x%y);
}
////////////////////////////////////////

int main() {
	int A, B;
	cin >> A >> B;
	char key[100][100];
	for (int i = 0; i < 50; ++i) {
		for (int j = 0; j < 100; ++j) {
			key[i][j] = '#';
		}
	}
	for (int i = 50; i < 100; ++i) {
		for (int j = 0; j < 100; ++j) {
			key[i][j] = '.';
		}
	}
	int i = 0;
	int j = 0;
	int cnt1 = 0;
	while (cnt1 < A-1) {
		key[i][j] = '.';
		j += 2;
		cnt1++;
		if ( j >= 100) {
			if (i % 2 == 0)j = 1;
			else j = 0;
			i+=2;
		}
	}
	int k = 99;
	int l = 0;
	int cnt2 = 0;
	while (cnt2 < B - 1) {
		key[k][l] = '#';
		l += 2;
		cnt2++;
		if (l >= 100) {
			if (k % 2 == 1) {
				l = 1;
			}
			else {
				l = 0;
			}
			k-=2;
		}
	}
	cout << 100 << " " << 100 << endl;
	for (int i = 0; i < 100; i++) {
		for (int j = 0; j < 100; ++j) {
			cout << key[i][j];
		}
		cout << endl;
	}
	return 0;
}


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

using namespace std;

typedef long long int ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define rep2(i,n) for(int i=1;i<=(int)(n);i++)
#define rep3(i,n) for(int i=0;i<=(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
#define repll(i,n) for(ll i=0;i<(ll)(n);i++)
#define repll2(i,n) for(ll i=1;i<=(ll)(n);i++)
#define REPLL(i,m,n) for(ll i=m;i<(ll)(n);i++)
#define INF (int)1e9  //
#define LINF (ll)4e18  //
#define MOD (1e9)+7
#define MP make_pair
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl

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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >>d;

    int sec = 0;

    rep3(i, 100) {
        if (a <= i && i < b && c <= i && i < d) sec++;
    }

    cout << sec << endl;

    return 0;
}



Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define pp pair<int,int>
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define ll long long
#define ld long double
#define all(a) (a).begin(),(a).end()
#define mk make_pair
int main(){
  int h1,m1,h2,m2;
  ll k;
  cin>>h1>>m1>>h2>>m2>>k;
  int awaken=(h2-h1)*60+m2-m1;
  cout<<awaken-k<<endl;
  return 0;
}

Measured memory_bytes: 3636
import java.util.Arrays;
import java.util.Collections;
import java.util.HashSet;
import java.util.List;
import java.util.Scanner;
import java.util.Set;

public class Main {

	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int k = scan.nextInt();

		String array[][] = new String[n][k];

		for (int i = 0; i < k; i++) {
			int d = scan.nextInt();
			for (int h = 0; h < d; h++) {
				int j = scan.nextInt();
				array[j - 1][i] = "aaa";
			}
		}


		String[] list = {null};
		int ans =0;
		for (int b = 0; b < n; b++) {
			String[] a = array[b];

			List asList = Arrays.asList(list);
			List asList1 = Arrays.asList(a);
			Set<String> mySet = new HashSet<String>(asList);
			for (String s : mySet) {
//				System.out.println(s + " " + Collections.frequency(asList1, s));
				if(k== Collections.frequency(asList1, s)) {
					ans += 1;

				}
			}
		}


		System.out.println(ans);
	}
}

Measured memory_bytes: 46376
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main() {
	string s, h = {};
	cin >> s;

	for (int i = 0; i < s.size(); i++) {
		if((i+1)%2!=0)h += s[i];
	}
	cout << h << endl;
}

Measured memory_bytes: 512
<?php
fscanf(STDIN,"%d %d",$a,$b);
$ans = 0;
$b = $b-1;
$pass = false;
for ($i=1; $i <= $a; $i++) {
  $kari = $i + $b;
  if ($kari == 0){
  $pass = true;}
  $l[] = $kari;
	$ans = $ans+ $kari;
}
if($pass){
echo $ans;
}else{
  foreach ($l as $v) $d[] = abs($v);
#  $min = abs($l);
#  var_dump($min);
  $min = min($d);
  if($ans < 0){
    echo $ans + $min;
  }else{
    echo $ans - $min;
  }
}

Measured memory_bytes: 4728