akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <cstdint>
#include <vector>
#include <algorithm>
#include <utility>
#include <numeric>
#include <string>

int main() {
  size_t D;
  scanf("%zu", &D);

  size_t x;
  scanf("%zu", &x);

  std::vector<int> one;
  for (size_t i = 0; i < x; ++i) {
    char a;
    int p;
    scanf(" %c %d", &a, &p);
    if (a != 'D') continue;
    one.push_back(p);
  }

  size_t y;
  scanf("%zu", &y);
  std::vector<int> two;
  for (size_t i = 0; i < y; ++i) {
    char b, c;
    int q;
    scanf(" %c%c %d", &b, &c, &q);
    if (b != 'D' || c != 'D') continue;
    two.push_back(q);
  }

  std::sort(one.rbegin(), one.rend());
  std::sort(two.rbegin(), two.rend());

  one.resize(std::max(x, D), 0);
  two.resize(std::max(y, D), 0);

  int res = 0;
  for (size_t i = 0; i <= D; ++i) {
    int f1 = std::accumulate(one.begin(), one.begin()+i, 0);
    int f2 = std::accumulate(two.begin(), two.begin()+((D-i)/2), 0);
    res = std::max(res, f1+f2);
  }
  printf("%d\n", res);
}



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

#define EPS (1e-7)
#define INF (1e16)
#define PI (acos(-1))
//const ll mod = 1000000007;
int n, m;
int a[2050], b[2050];
ll c[2050];
ll dist[2000];
bool from1[2005];
bool toN[2005];
bool out[2005];
vector<int> path[2005];
vector<int> pathRev[2005];

void bfs(int from) {
    if(from1[from]) return;
    from1[from] = true;
    for(int i = 0; i < path[from].size(); i++) {
        int to = path[from][i];
        bfs(to);
    }
}

void bfsRev(int from) {
    if(toN[from]) return;
    toN[from] = true;
    for(int i = 0; i < pathRev[from].size(); i++) {
        int to = pathRev[from][i];
        bfsRev(to);
    }
}

int main() {
    //cout.precision(10);
    cin >> n >> m;
    for(int i = 1; i <= m; i++) {
        cin >> a[i] >> b[i] >> c[i];
        path[a[i]].push_back(b[i]);
        pathRev[b[i]].push_back(a[i]);
        c[i] = -c[i];
    }
    for(int i = 1; i <= n; i++) {
        dist[i] = INF;
        from1[i] = toN[i] = out[i] = false;
    }
    dist[1] = 0;
    for(int time = 1; time <= n; time++) {
        for(int i = 1; i <= m; i++) {
            int from = a[i];
            int to = b[i];
            ll cost = c[i];
            dist[to] = min(dist[to], dist[from] + cost);
        }
    }
    for(int i = 1; i <= m; i++){
        int from = a[i];
        int to = b[i];
        ll cost = c[i];
        if(dist[to] > dist[from] + cost) {
            out[to] = true;
            //cout << "inf" << endl;
            //return 0;
        }
    }
    bfs(1);
    bfsRev(n);
    /*
    for(int i = 1; i <= n; i++) {
        if(from)
    }
    */
    for(int i = 1; i <= n; i++) {
        if(out[i] && from1[i] && toN[i]) {
            cout << "inf" << endl;
            return 0;
        }
    }
    cout << -dist[n] << endl;
    return 0;
}


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

#define rp(i, k, n) for (int i = k; i < n; i++)
typedef long long ll;
typedef double ld;



template<class T>inline bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>inline bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }
const ll INF = 1ll << 60;
const ll MOD = 1e9 + 7ll;
const double PI=3.14159265358979323846;

int main() {
    int N; cin >> N;
    vector<int> A;
    A.emplace_back(1e9 + 100);
    while(N--) {
        int a; cin >> a;
        if(a <= *(A.end()-1)) A.emplace_back(a);
        else {
            
            int ok = int(A.size());
            int ng = -1;
            while(abs(ok - ng) > 1) {
                int x = (ok + ng) / 2;
                if(A.at(x) < a) ok = x;
                else ng = x;
            }
            A.at(ok) = a;
        }
    }
    cout << A.size() - 1 << endl;
    return 0; 
}

Measured memory_bytes: 3828
#include <iostream>
#include <string>

using namespace std;

string s;

int main(void)
{
	cin >> s;
	
	int ans = 0;
	char prev = '#';
	for(int i = 0; i < s.size(); i++){
		if(prev != '#' && prev != s[i]) ans++;
		prev = s[i];
	}
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 512
import numpy as np
h,w = (map(int,input().split(' ')))
x = []
for i in range(h):
  x.append(input())
  
y = np.zeros((h,w),dtype=int)
#print(y)           
for n,i in enumerate(x):
  for j in range(w):
    if i[j] == '#':
#同列
      if j >= 1:
        if x[n][j-1] != '#':
          y[n][j-1]  +=1  
      if j < w-1:
        if x[n][j+1] != '#':
   	        y[n][j+1]  +=1  
#前列 
      if n > 0:
        if x[n-1][j] !='#':
          y[n-1][j] +=1
        if j >= 1:
          if x[n-1][j-1] !='#':
            y[n-1][j-1] +=1
        if j < w-1:
          if x[n-1][j+1] !='#':
            y[n-1][j+1] +=1
#後列
      if n < h-1:
        if x[n+1][j] != '#':  
          y[n+1][j] +=1
        if j >= 1:
          if x[n+1][j-1] != '#':
            y[n+1][j-1] +=1
        if j < w-1:
          if x[n+1][j+1] != '#':
            y[n+1][j+1] +=1

y2 = y.astype(np.unicode)
            
for n,i in enumerate(x):
  for n2,j in enumerate(i):
    if j == '#':
      y2[n][n2] ='#'
  print(''.join(list(y2[n])))  
  


Measured memory_bytes: 13068
//#define DEB1 //output check function
//#define DEB2 //same output, input from input.txt

#include <iostream>
#include <algorithm>
#include <string>
#include <fstream>
#include <vector>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <string>
#include <set>
#include <map>
#include <thread>
#include <mutex>
#include <iomanip>

#define ZERO(a) memset(a, 0, sizeof(a))
#define MINUS(a) memset(a, 0xff, sizeof(a))
#define INF(a) memset(a, 0x3f, sizeof(a))
#define ALL(t) (t).begin(),(t).end()
#define FILL(a,c) fill(a, a+ sizeof(a)/sizeof(*a),c)
#define FILL2D(A,c) fill(A[0], A[0] +sizeof(A)/sizeof(**A),c)
#define FILL3D(A,c) fill(A[0][0], A[0][0] +sizeof(A)/sizeof(***A),c)
#define REP(i,m) for(int i=0;i<(m);++i)
#define REPN(i,m,in) for(int i=(in);i<(m);++i)
#define IN(a, x, b) (a<=x && x<b)
#define PB push_back

using namespace std;

using LL = long long;
using PAIR = pair<int, int>;
using PAIRLL = pair<LL,LL>;
using VI = vector<int>;
using VVI = vector<VI>;


template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}


#ifdef DEB1
#define DPRINT(x) cout<< #x << "=" << (x) << endl; // print at debug mode
#else
#define DPRINT(x) ;
#endif
#ifdef DEB1
#define DCHECK(x) cout<< "debug check" << #x << endl;
#else
#define DCHECK(x) ;
#endif
 


/*
constant values
*/

//const int dx[] = {1,0,-1,0};
//const int dy[] = {0,1,0,-1};
//const int MX = 31001;

//const ll INF= 1LL<<60 ;//INF = 1001001001001; //1e9

vector<int> V;
// Main program
void solve(){
    //map
    string S;
    cin >> S;
    int N = S.length();
    DPRINT(N);
    S = 'D' + S + 'D';
    DPRINT(S);

    REP(i,N){
        if(S[i+1]=='A') V.PB(0);
        if(S[i+1]=='B'){
            if(S[i+2]=='C'){
                V.PB(1);
            }
            else{
                V.PB(2);
            }
        }
        if(S[i+1]=='C'){
            if(S[i]!='B'){
                V.PB(2);
            }
        }
    }

    //calculate
    int N_V = V.size();
    REP(i,N_V){
        DPRINT(V[i]);
    }
    int weight = 0;
    LL ans = 0;
    REP(i,N_V){
        // A
        if(V[N_V - 1 - i]==0){
            ans += weight;
        }
        // B
        if(V[N_V - 1 - i]==1){
            weight+=1;
        }
        // other
        if(V[N_V - 1 - i]==2){
            weight=0;
        }
    }
    cout << ans << endl;
}



// ----------------------------------------------
int main() {

#ifdef DEB2
    cout << "DEBUG MODE"  << endl;
	ifstream in("input.txt"); //for debug
	cin.rdbuf(in.rdbuf()); //for debug
#endif

	int T=1; 

	for (int i = 0; i < T; ++i) {
		solve();
	}
}

Measured memory_bytes: 1724
import java.util.Scanner;

public class Main {

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

        String ans = "APPROVED";
        for (int i=0;i<N;i++) {
            int A_n = sc.nextInt();
            if (A_n % 2 == 0) {
                if (A_n % 3 != 0 && A_n % 5 != 0) {
                    ans = "DENIED";
                    break;
                }
            }
        }
        System.out.println(ans);
    }
}


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

void bfs(vector<vector<ll>> &friends,vector<bool> &checked,queue<ll> &q,ll &K){
  ll i;
  for(i=0;i<friends.at(K).size();i++){
    if(!checked.at(friends.at(K).at(i))){
      q.push(friends.at(K).at(i));
    }
  }
}

int main(void){
  ll n,m,k;
  cin >> n >> m >> k;
  ll a,b;
  vector<vector<ll>> friends(n,vector<ll>(0));
  ll i;
  for(i=0;i<m;i++){
    cin >> a >> b;
    a--;
    b--;
    friends.at(a).push_back(b);
    friends.at(b).push_back(a);
  }
  
  vector<ll> group(n);
  vector<bool> checked(n,false);
  queue<ll> q;
  for(i=0;i<n;i++){
    if(!checked.at(i)){
      q.push(i);
      while(!q.empty()){
        group.at(q.front())=i;
        bfs(friends,checked,q,q.front());
        checked.at(q.front())=true;
        q.pop();
      }
    }
  }
  
  vector<ll> count(n,0),member(n,0);
  for(i=0;i<n;i++){
    count.at(group.at(i))++;
  }
  for(i=0;i<n;i++){
    member.at(i)=count.at(group.at(i))-1-friends.at(i).size();
  }
  
  ll c,d;
  for(i=0;i<k;i++){
    cin >> c >> d;
    c--;
    d--;
    if(group.at(c)==group.at(d)){
      member.at(c)--;
      member.at(d)--;
    }
  }
  
  cout << member.at(0);
  for(i=1;i<n;i++){
    cout << " " << member.at(i);
  }
}

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

int main(void){
	int S;
	cin >> S;

	int h, m, s;

	h = S/3600;
	S = S%3600;

	m = S/60;
	S = S%60;

	s = S;	
	cout << h << ":" << m << ":" << s << endl;
	return 0;
}

Measured memory_bytes: 3092
M, D = map(int, input().split())


def check(_m, _d):
    _d_list = list(str(_d))
    if len(_d_list) <= 1:
        d10, d1 = 0, _d
    else:
        d10, d1 = map(int, _d_list)
    if d10 >= 2 and d1 >= 2 and d10 * d1 == _m:
        return 1
    return 0


count = 0
for month in range(1, M+1):
    for day in range(1, D+1):
        count += check(month, day)
print(count)


Measured memory_bytes: 3060
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define X first
#define Y second
#define mp make_pair
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
typedef long double LD;
typedef pair<int, int> pii;
typedef unsigned long long uLL;

template <typename T> inline void Read(T &x) {
    char c = getchar();
    bool f = false;
    for (x = 0; !isdigit(c); c = getchar()) {
        if (c == '-') {
            f = true;
        }
    }
    for (; isdigit(c); c = getchar()) {
        x = x * 10 + c - '0';
    }
    if (f) {
        x = -x;
    }
}

const int MAX_N = 1e5 + 5;
const int INF = 0x3f3f3f3f;

int n, a[MAX_N];

int main()
{
#ifdef ANONYM
    freopen("in", "r", stdin);
    freopen("out", "w", stdout);
#endif

    Read(n);
    for(int i=0; i<n; i++) Read(a[i]);
    sort(a, a+n);
    if(n%2 == 0) {
        LL lsum = 0;
        for(int i=0; i<n/2-1; i++) lsum += 2*a[i];
        lsum += a[n/2-1];
        LL rsum = 0;
        for(int i=n/2+1; i<n; i++) rsum += 2*a[i];
        rsum += a[n/2];
        printf("%lld\n", rsum - lsum);
    } else {
        LL lsum1 = 0, rsum1 = 0;
        for(int i=0; i<n/2-1; i++) lsum1 += 2*a[i];
        lsum1 += a[n/2-1];
        for(int i=n/2+1; i<n; i++) rsum1 += 2*a[i];
        lsum1 += a[n/2];
        LL lsum2 = 0, rsum2 = 0;
        for(int i=0; i<n/2; i++) lsum2 += 2*a[i];
        rsum2 += a[n/2];
        for(int i=n/2+2; i<n; i++) rsum2 += 2*a[i];
        rsum2 += a[n/2+1];
        printf("%lld\n", max(rsum1 - lsum1, rsum2 - lsum2));
    }
    return 0;
}


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

int main() {
  string s;
  cin >> s;
  string str1 = "1234", str2 = " ", str3 = "12345678";
  for (int i = 0; i < 4; i++) {
    str1.at(i) = s.at(i);
  }
  for (int i = 0; i < 8; i++) {
    str3.at(i) = s.at(i + 4);
  }
  cout << str1 << str2 << str3 << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int days[12] = {31, 29, 31, 30, 31, 30, 31, 31, 30, 31, 30, 31};
	int date[2];
	int day;
	int i;
	
	while (1){
		scanf("%d %d", &date[0], &date[1]);
		
		if (date[0] == 0){
			break;
		}
		
		day = date[1];
		
		i = 1;
		while (date[0] > i){
			day += days[i - 1];
			i++;		
		}
		
		switch (day % 7){
			case 0:
				printf("Wednesday\n");
				break;
			case 1:
				printf("Thursday\n");
				break;
			case 2:
				printf("Friday\n");
				break;
			case 3:
				printf("Saturday\n");
				break;
			case 4:
				printf("Sunday\n");
				break;
			case 5:
				printf("Monday\n");
				break;
			case 6:
				printf("Tuesday\n");
				break;
		}
	}
	
	return (0);
}

Measured memory_bytes: 584
#include<bits/stdc++.h>
#define enld '\n'
#define rep(i,n) for(int i=0; i<(n); i++)
using namespace std;
using ll = long long;
using P = pair<int,int>;
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("Ofast")
constexpr ll INF = 1e18;
constexpr int inf = 1e9;
constexpr double INFD = 1e100;
constexpr ll mod = 1000000007;
constexpr ll mod2 = 998244353;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
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; }
// ios::sync_with_stdio(false);
// cin.tie(nullptr);
// ---------------------------------------------------------------------------

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int N,H,W;
    cin >> N >> H >> W;
    vector<int> pos(N*W,0);
    vector<int> x(N);
    for(int i=0; i<N; i++){
        cin >> x[i];
    }
    for(int i=0; i<N; i++){
        for(int j=0; j<W; j++){
            if(i%2){
                pos[i*W-x[i]+j]++;
            }else{
                pos[i*W+x[i]+j]++;
            }
        }
    }
    int cnt = 0;
    for(int i=0; i<N*W; i++){
        if(pos[i] == 0) cnt++;
    }
    cout << cnt * H << enld;
    return 0;
}


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

#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define SORT_INV(c) sort((c).begin(), (c).end(), greater<int>())

#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false
#define LL long long
#define Dev 1000000007

//cout << (c)?"Yay!":":(" << endl;

// sort(a.begin(), a.end(), std::greater<int>());
using namespace std;

int main()
{
    int n;
    cin >> n;
    set<string> s;
    rep(i,n){
        string temp;
        cin>>temp;
        s.insert(temp);
    }
    cout<<s.size()<<endl;
    return 0;
}


Measured memory_bytes: 19260
N = int(input())
AB = [list(map(int, input().split())) for _ in range(N - 1)]

graph = [[] for _ in range(N + 1)]
for a, b in AB:
  graph[a].append(b)
  graph[b].append(a)
#print("graph:", graph)

order = []
stack = [1]
parent = [0] * (N + 1)

while stack:
  s = stack.pop()
  order.append(s)
  for g in graph[s]:
    if parent[s] == g:
      continue
    else:
      parent[g] = s
      stack.append(g)
#print("order:", order)
#print("parent:", parent)

color = [-1] * (N + 1)

for e in order:
  ng = color[e]
  c = 1
  for g in graph[e]:
    if parent[e] == g:
      continue
    if c == ng:
      c += 1
    color[g] = c
    c += 1
#print("color:", color)

print(max(color[2:]))
for a, b in AB:
  if parent[a] == b:
    print(color[a])
  else:
    print(color[b])

Measured memory_bytes: 85976
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  
  string S;
  cin >> S;
  
  int N = S.size();
  
  for(int i = 0; i <= (N - 1); i++){
    if(S.at(i) != S.at(N - 1 - i)){
      cout << "No" << endl;
      return 0;
    }
  }

  for(int i = 0; i < (N - 1) / 2; i++){
    if(S.at(i) != S.at((N - 3) / 2 - i)){
      cout << "No" << endl;
      return 0;
    }
  }

  cout << "Yes" << endl;
  
}

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

int N, M;
vector<int> a;

vector<bool> Broken(int n) {
  vector<bool> br(n + 1, false);
  for (int i = 0; i < M; i++) {
    br[a[i]] = true;
  }
  return br;
}

void solve() {
  vector<ll> dp(N + 1);
  vector<bool> isBroken = Broken(N);

  dp[0] = 1;
  dp[1] = (isBroken[1]) ? 0 : 1;
  for (int i = 2; i <= N; i++) {
    dp[i] = (isBroken[i]) ? 0 : (dp[i - 1] + dp[i - 2]) % MOD;
  }
  cout << dp[N] << "\n";
}

int main() {
  cin >> N >> M;
  a.resize(M);
  for (int i = 0; i < M; i++) {
    cin >> a[i];
  }
  solve();
  return 0;
}

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

int main() {
	int n;double m;double sum=0;int z=0;
	cin>>n>>m;
	long long a[n];
	for(int i=0;i<n;i++)
	{
	    cin>>a[i];
	    sum+=a[i];
	    
	}
	double k= (sum/(4*m));
	for(int i=0;i<n;i++)
	{
	    if(a[i]>=k)
	    {
	        z++;
	    }
	}
	if(z>=m)
	{
	    cout<<"Yes";
	}
	else
	{
	    cout<<"No";
	}
	
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define rep1(i,n) for(int i=1;i<=(int)n;i++)
#define sp(n) cout << fixed << setprecision(n)
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; }
typedef long long ll;
using namespace std;
int main(void){
    ll k;cin>>k;

    if(k%7==0)k/=7;
    ll pre=1,tmp=0;
    map<ll,ll> mp;
    while(true){
        tmp++;
        pre%=k;
        if(mp[pre]!=0){
            cout<<-1<<endl;
            return 0;
        }
        if(pre==0){
            cout<<tmp<<endl;
            return 0;
        }
        mp[pre]++;
        pre*=10;pre+=1;
    }
}

Measured memory_bytes: 66124
n = gets.to_i
s = gets.chomp.chars
rs = s.reverse
maxw = s.count("W")
maxe = s.count("E")

w = []
n.times do |i|
  if rs[i] == "W"
    maxw -= 1
  end
  w << maxw
end
west = w.reverse

east = []
n.times do |i|
  if s[i] == "E"
    maxe -= 1
  end
  east << maxe
end

min = n
n.times do |i|
  sum = west[i] + east[i]
  min = sum if min > sum
end

p min

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

typedef long long LL;
typedef pair<int, int> PII;
typedef vector<int> VI;
#define MP make_pair
#define PB push_back
#define X first
#define Y second

#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ALL(a) a.begin(), a.end()
#define SZ(a) (int)((a).size())
#define FILL(a, value) memset(a, value, sizeof(a))
#define debug(a) cout << #a << " = " << a << endl;

const double PI = acos(-1.0);
const LL INF = 1e9 + 47;
const LL LINF = INF * INF;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

const int N = 300 + 7;
int n;
int d[N][N];
int D[N][N];

void relax(int v)
{
	FOR(i, 0, n) FOR(j, 0, n) D[i][j] = min(D[i][j], D[i][v] + D[v][j]);
}

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	
	cin >> n;
	FOR(i, 0, n) FOR(j, 0, n) cin >> d[i][j];
	
	FOR(i, 0, n) FOR(j, 0, n) FOR(k, 0, n) if (d[i][j] > d[i][k] + d[k][j])
	{
		cout << -1 << endl;
		return 0;
	}
	
	FOR(i, 0, n) FOR(j, 0, n) D[i][j] = INF;
	
	LL ans = 0;
	
	vector<pair<int, PII>> e;
	FOR(i, 0, n) FOR(j, i + 1, n) e.PB({d[i][j], {i, j}});
	sort(ALL(e));
	
	for(auto edge: e)
	{
		int u = edge.Y.X;
		int v = edge.Y.Y;
		if (D[u][v] == d[u][v]) continue;
		ans += edge.X;
		D[u][v] = D[v][u] = edge.X;
		relax(u);
		relax(v);
	}	
	
	cout << ans << endl;
	
	cerr << "Time elapsed: " << clock() / (double)CLOCKS_PER_SEC << endl;
	return 0;
}



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

#define fi first
#define se second
#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define each(itr,v) for(auto itr:v)
#define pb(s) push_back(s)
#define mp(a,b) make_pair(a,b)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl
#define maxch(x,y) x=max(x,y)
#define minch(x,y) x=min(x,y)
#define uni(x) x.erase(unique(all(x)),x.end())
#define exist(x,y) (find(all(x),y)!=x.end())
#define bcnt(x) bitset<32>(x).count()

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef pair<P, int> PPI;
typedef pair<ll, ll> PL;
typedef pair<P, ll> PPL;

#define INF INT_MAX/3

#define MAX_N 1000

#define mod 1000000007

ll n,W;
ll w[202];
ll dp[10101];
ll sum=0;

int main(){
	cin.sync_with_stdio(false);
  cin>>n>>W;
  rep(i,n){
    cin>>w[i];
    sum+=w[i];
  }
  sort(w,w+n,greater<ll>());
  dp[0]=1;
  ll res=W>=sum?1:0;
  rep(i,n){
    for(int j=max(0LL,W-sum+1);j<=W-sum+w[i];j++)res=(res+dp[j])%mod;
    sum-=w[i];
    for(int j=W;j>=w[i];j--){
      dp[j]+=dp[j-w[i]];
    }
  }
  cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 3284
#include<bits/stdc++.h>
#define llong long long
#define mkpr make_pair
#define riterator reverse_iterator
using namespace std;

inline int read()
{
	int x=0,f=1; char ch=getchar();
	for(;!isdigit(ch);ch=getchar()) {if(ch=='-') f = -1;}
	for(; isdigit(ch);ch=getchar()) {x = x*10+ch-'0';}
	return x*f;
}

int n;

int main()
{
	scanf("%d",&n); int p = n&(-n);
	if(p==n) {puts("No"); return 0;}
	puts("Yes");
	for(int i=3; i<=n; i+=2)
	{
		printf("%d %d\n%d %d\n%d %d\n%d %d\n",1,i,i,i-1,1,i-1+n,i-1+n,i+n);
	}
	printf("%d %d\n",2,n+1);
	if(!(n&1))
	{
		int x = p>>1,y = (n^p)>>1;
		printf("%d %d\n%d %d\n",n,2*x+1,n+n,2*y+n);
	}
	return 0;
}

Measured memory_bytes: 2304
#include <bits/stdc++.h>
#define int long long
#define uint unsigned int
#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, a, b) for (int i = (a); i < (b); ++i)
#define FORR(i, a, b) for (int i = (a); i >= (b); --i)
#define ALL(a) (a).begin(), (a).end()
#define ALLR(a) (a).rbegin(), (a).rend()
#define SZ(a) ((int)(a).size())
#define PB(a) push_back(a)
#define EMP emplace
#define EMPB(...) emplace_back(__VA_ARGS__)
#define MP(a, b) make_pair(a, b)
#define MT(...) make_tuple(__VA_ARGS__)
#define Bit(n) (1LL << (n))
using namespace std;
using pii = pair<int, int>;
template <class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template <class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
const int MOD = 1000000007;
const int INF = 1LL << 30;
const double EPS = 1e-10;

int N, L, Q;
int x[100010];
int to[100010][20];

void make() {
  int l = 0, r = 0;
  while (l < N) {
    while (r < N && x[r]-x[l] <= L) r++;
    to[l][0] = r-1;
    l++;
  }
  FOR(k, 1, 20) {
    REP(i, N) to[i][k] = to[to[i][k-1]][k-1];
  }
}

bool check(int a, int b, int x) {
  int p = 0;
  for (int i = 0; i < 20; i++) {
    if (x & Bit(i)) {
      a = to[a][i];
    }
  }
  return a >= b;
}

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  
  cin >> N;
  REP(i, N) cin >> x[i];
  cin >> L >> Q;
  make();
  REP(i, Q) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    if (a > b) swap(a, b);
    int ng = 0, ok = N;
    while (ok - ng > 1) {
      int m = (ng + ok) / 2;
      if (check(a, b, m)) ok = m;
      else ng = m;
    }
    cout << ok << endl;
  }

  return 0;
}

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

#define rep(i,a,b) for(auto i=(a); i<(b); ++i)
#define trav(a,x) for(auto& a: x)
#define all(x) begin(x),end(x)
#define sz(x) (int)size(x)
#define PB push_back
using ll = long long;
using ld = long double;
using pii = pair<int,int>;
using vi = vector<int>;

struct edge{int to;};
using graph = vector<vector<edge>>;

int main() {
  cin.sync_with_stdio(0); cin.tie(0);
  cin.exceptions(cin.failbit);

  int n;
  cin >> n;
  bool good = false;
  int run = 0;
  rep(i, 0, n) {
    int a, b;
    cin >> a >> b;
    if (a == b) run++;
    else run = 0;

    good |= run >= 3;
  }
  cout << (good ? "Yes" : "No") << '\n';
}


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

int main()
{
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()>s2.size())
        cout<<"GREATER";
    else if(s1.size()<s2.size())
        cout<<"LESS";
    else
    {
        if(s1>s2)
            cout<<"GREATER";
        else if(s1<s2)
            cout<<"LESS";
        else if(s1==s2)
            cout<<"EQUAL";
    }
    return 0;
}

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

class SLEqual
    {
        static void Main()
    {
        var st = Console.ReadLine();
        int a = int.Parse(st.Split(' ')[0]);
        int b = int.Parse(st.Split(' ')[1]);
        int c = int.Parse(st.Split(' ')[2]);
        if (a < b)
        {
            if (b < c)
                Console.WriteLine("Yes");
            else
                Console.WriteLine("No");
        }
        else
            Console.WriteLine("No");

        }
    }

Measured memory_bytes: 5296
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>

using namespace std;

#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)

using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;

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

    int n; cin >> n;
    vector<ll> c(n, 0);
    vector<ll> d(n+1, 0);
    for (int i = 0; i < n; i++)
    {
        int a; cin >> a; a--;
        c[a]++;
        d[c[a]]++;
    }

    vector<ll> S(n+1, 0), S2(n+1, 0);
    for (int i = 1; i < n+1; i++)
    {
       S[i] = S[i-1] + d[i], S2[i] = S[i] / i;
    }
    

    ll x = n;
    for (ll k = 1; k <= n; k++)
    {
        while( x > 0 && k > S2[x]) --x;
        cout << x << endl;
    }
    
    

}

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

int main(){
	ios::sync_with_stdio(0);
	cin.tie(nullptr);
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
    /* for writing output to output.txt */
    int n; cin >> n;
    //long long sum = 0;
    vector <int> a(n);
    for(int i = 0; i < n - 1; i++){
        cin >> a[i];
        //sum += a[i];
    }
    vector <int> x(n);
    int one = 0;
    for(int i = 0; i < n - 1; i++){
        if(a[i] == 1) one++;
    }
    //cout << one << endl;
    //int j = 2;
    //int count = 0;
    x[0] == one;
    for(int i = 0; i < n - 1; i++){
        x[a[i] - 1]++;
    }
    for(int i = 0; i < n; i++) cout << x[i] << endl;

    return 0;
}


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

#define pb push_back
#define rep(i,n) for(int i=0;i<(n);i++)
#define reps(i,n,s) for(int i=(s);i<(n);i++)
#define rrep(i,n) for(int i=(n-1);i>=0;i--)
#define rreps(i,n,s) for(int i=s;i>=n;i--)
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 (a>b) { a=b; return 1; } return 0; }

using ll = long long;
using namespace std;
constexpr long long MAX = 5100000;
constexpr long long INF = 1LL << 60;
constexpr int MOD = 1000000007;

int main(){
cin.tie(0);
ios::sync_with_stdio(false);
int n;
cin>>n;
vector<ll>a(n);
rep(i,n)cin>>a[i];
vector<ll>s(n,0);
s[0]=a[0];
rep(i,n-1){
    s[i+1]=s[i]+a[i+1];
}
ll res=INF;
rep(i,n-1){
    ll x=s[i];
    ll y=s[n-1]-s[i];
    res=min(res,abs(x-y));
}
cout<<res<<endl;
return 0;
}

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


int main()
{
    long long max = 0, min = 1000000000, n;
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        long long tmp;
        cin >> tmp;
        if (tmp > max) max = tmp;
        if (tmp < min) min = tmp;
    }
    cout << max - min << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Edge = pair<int, int>;
using Graph = vector<vector<Edge>>;
#define REP(i, n) for (int i = 0; i < (n); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
const ll MOD = 1000000007;
const ll nmax = 8;
const ll INF = 1e9;
bool graph[nmax][nmax];
vector<vector<ll>> dist = vector<vector<ll>>(nmax, vector<ll>(nmax, INF));
void warshall_floyd(ll n)
{
    for (size_t i = 0; i < n; i++)
    {
        for (size_t j = 0; j < n; j++)
        {
            for (size_t k = 0; k < n; k++)
            {
                dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
            }
        }
    }
}

class UnionFind
{
public:
    vector<ll> Parent;

    UnionFind(ll N)
    {
        Parent = vector<ll>(N, -1);
    }
    ll find(ll A)
    {
        if (Parent[A] < 0)
            return A;
        return Parent[A] = find(Parent[A]);
    }

    ll size(ll A)
    {
        return -Parent[find(A)];
    }

    bool Union(ll A, ll B)
    {
        A = find(A);
        B = find(B);
        if (A == B)
        {
            return false;
        }
        if (size(A) < size(B))
            swap(A, B);

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

        return true;
    }
};

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

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

ll mulMod(ll a, ll b)
{
    return (((a % MOD) * (b % MOD)) % MOD);
}

ll powMod(ll a, ll p)
{
    if (p == 0)
    {
        return 1;
    }
    else if (p % 2 == 0)
    {
        ll half = powMod(a, p / 2);
        return mulMod(half, half);
    }
    else
    {
        return mulMod(powMod(a, p - 1), a);
    }
}

ll ceil(ll a, ll b)
{
    return (a + b - 1) / b;
}

void solve(long long N, long long M, std::vector<long long> A)
{
    for (int i = 1; i < N; i++)
    {
        A[i] += A[i - 1];
    }
    map<int, int> mod;

    ll ans = 0;

    for (int i = 0; i < N; i++)
    {
        if(A[i]%M == 0) ans++;
        ans += mod[A[i] % M];
        mod[A[i] % M]++;
    }

    cout << ans << endl;
}

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


Measured memory_bytes: 3968
#include <stdio.h>

int main() {
	int addNumber[20];
	int ansNumber[200];
	int needAddN, needAnsN;
	int YorN;
	int i, j;

	scanf("%d", &needAddN);
	for (i = 0; i < needAddN; i++) {
		scanf("%d", &addNumber[i]);
	}
	scanf("%d", &needAnsN);
	for (i = 0; i < needAnsN; i++) {
		scanf("%d", &ansNumber[i]);
	}

	for (i = 0; i < needAnsN; i++) {
		int addBox;
		int down; //??°????????°????????????????????????
		down = -1;
		for (j = needAddN - 1; j >= 0; j--) {
			down++;
			addBox = 0;
			YorN = calc(ansNumber[i], addNumber, needAddN - down, addBox);
			if (YorN == 1) {
				break;
			}
		}
		if (YorN == 1) {
			printf("yes\n");
		}
		else {
			printf("no\n");
		}
	}

	return 0;
}

int calc (int answer, int* addNumber, int count, int addBox) {
	int trueA;
	if (addBox > answer || count < 0) {
		return -1;
	}

	do {
		count--;
		if (count < 0) {
			return -1;
		}
		addBox += addNumber[count];
		if (addBox == answer) {
			trueA = 1;
		}
		else {
			trueA = calc(answer, addNumber, count, addBox);
			addBox -= addNumber[count];
		}
	} while (trueA == -1);

	return 1;
}

Measured memory_bytes: 580
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < int(n); i++)
using namespace std;
using ll = long long;
const int INF = (1<<30)-1;
const long long LINF = (1LL<<62)-1;
const int dx[] = {-1, 0, 1, 0};
const int dy[] = {0, 1, 0, -1};
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t;
  cin >> t;
  rep(i, t) {
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    if (a < b) {
      cout << "No" << endl;
      continue;
    }
    if (b > d) {
      cout << "No" << endl;
      continue;
    }
    if (c >= b-1) {
      cout << "Yes" << endl;
      continue;
    }
    ll l = c+1-a, r = b-1-a;
    swap(l, r);
    l = -l, r = -r;
    ll g = __gcd(b, d);
    ll p = (l+g-1)/g*g;
    if (p <= r)
      cout << "No" << endl;
    else
      cout << "Yes" << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define int long long
#define pii pair<int,int>
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) FOR(i,0,n)
#define ALL(c) (c).begin(),(c).end()
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
#define MINF(a) memset(a,0x3f,sizeof(a))
#define POW(n) (1LL<<(n))
#define IN(i,a,b) (a <= i && i <= b)
using namespace std;
template <typename T> inline bool CHMIN(T& a,T b) { if(a>b) { a=b; return 1; } return 0; }
template <typename T> inline bool CHMAX(T& a,T b) { if(a<b) { a=b; return 1; } return 0; }
template <typename T> inline void SORT(T& a) { sort(ALL(a)); }
template <typename T> inline void REV(T& a) { reverse(ALL(a)); }
template <typename T> inline void UNI(T& a) { sort(ALL(a)); a.erase(unique(ALL(a)),a.end()); }
const int MOD = 1000000007;
const int INF = 0x3f3f3f3f3f3f3f3f;
const double EPS = 1e-10;
/* ---------------------------------------------------------------------------------------------------- */

int N,M;
int A[100010];
pii p[100010];

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  cout << fixed << setprecision(10);

  cin >> N >> M;
  REP(i,N) cin >> A[i];
  sort(A,A+N);
  REP(i,M) cin >> p[i].second >> p[i].first;
  sort(p,p+M);
  reverse(p,p+M);
  vector<int> v;
  REP(i,M) {
    REP(j,p[i].second) {
      v.push_back(p[i].first);
      if (v.size() == N) break;
    }
    if (v.size() == N) break;
  }
  int ans = 0;
  REP(i,N) {
    if (i < v.size()) ans += max(v[i],A[i]);
    else ans += A[i];
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 3704
import java.io.*;

class Main {
	static int fieldlen = 0;
	static int fieldstart = 0;
    public static void main(String[] args) {
        BufferedReader kb = new BufferedReader( new InputStreamReader( System.in ) );
        try {
			
			char[] field = kb.readLine().toCharArray();
			fieldlen = field.length;
			int[] areas = new int[10000];
			int cnt, found, total;

			cnt = total = found  = 0;
            for( int i=0; i<fieldlen; i++ ) {
            	found = getArea( field, i );
            	if( 0 < found ) {
            		areas[cnt] = found;
            		total += areas [cnt++];
            		found = 0;
            		i = fieldstart;
            	}
            }
            
            StringBuilder output = new  StringBuilder( );
            output.append( total ).append( "\n" );
            output.append( cnt ).append( " " );
           	for( int i=0; i<cnt; i++ ) {
           		output.append( areas[i] ).append( " " );
         	}
         	output.deleteCharAt( output.lastIndexOf( " " ) );
         	System.out.println( output );

	    } catch( IOException e ) {
	        System.err.println( e );
	    }
	}
	public static int getArea( char[] field, int start )
	{
		int i, area, cnt, s, t;
		area = cnt = s = t = 0;
		for( i=start; i<fieldlen; i++ ) {
            if( '\\'== field[i] ) {
            	cnt++;
            	t++;
            	area += cnt;
            } else if( 0 < cnt && '/' == field[i] ) {
            	area += cnt;
            	cnt--;
            	if( 0 == cnt ) { break; }
            } else if( '_' == field[i]  ) {
            	s += cnt;
            }
		}
		if( fieldlen == i ) { 
			area = 0;
		} else {
			area = ( area - t + s );
			fieldstart = i;
		}
		return area;
	}

}

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

#define sz(x) (int)x.size()

int main() {

    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);

    int K; cin >> K;
    string x; cin >> x;

    if (sz(x) <= K) {
        cout << x << "\n";
    } else {
        cout << x.substr(0, K) << "..." << "\n";
    }
}


Measured memory_bytes: 3644
#include <bits/stdc++.h>
 
#ifndef LOCAL_
#define fprintf if( false ) fprintf
#endif // LOCAL_
#define dumpl(x1) fprintf(stderr, "#%s.%d (%s) = (%ld)\n", __func__, __LINE__, #x1, x1);
#define dumpll(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%ld, %ld)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define dumpd(x1) fprintf(stderr, "#%s.%d (%s) = (%lf)\n", __func__, __LINE__, #x1, x1);
#define dumpdd(x1, x2) fprintf(stderr, "#%s.%d (%s, %s) = (%lf, %lf)\n", __func__, __LINE__, #x1, #x2, x1, x2);
#define loop for(;;)
 
struct S002 {
  int n;
  S002& operator > (long& x) {
    n = x;
    return *this;
  }
  S002& operator > (long&& x) {
    n = x;
    return *this;
  }
  S002& operator >= (long& x) {
    if( scanf("%ld", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (double& x) {
    if( scanf("%lf", &x) <= 0 ) exit(0);
    return *this;
  }
  S002& operator >= (std::string& s) {
    if( not (std::cin >> s) ) exit(0);
    return *this;
  }
  template<typename a>
  S002& operator >= (std::vector<a>& v) {
    v.resize(n);
    for(long i = 0; i < n; ++i) {
      *this >= v[i];
    }
    return *this;
  }
  template<typename a, std::size_t s>
  S002& operator >= (std::array<a, s>& x) {
    for(long i = 0; i < (long)s; ++i) {
      *this >= x[i];
    }
    return *this;
  }
};

struct Solver {
  long w, a, b;
  Solver() {
    S002 reader;
    reader >= w >= a >= b;
  }
  void solve() {
    long res = b - w <= a and a <= b + w ? 0 : std::min(std::abs(b - (a + w)), std::abs((b + w) - a));
    printf("%ld\n", res);
  }
};
 
int main() {
  loop std::unique_ptr<Solver>(new Solver())->solve();
  return 0;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void)
{
    long n;
    scanf("%ld", &n);
    char a[100];

    int i=0, b;

    while(n!=0){
        n--;
        b = n%26;
        a[i] = 'a' + b;
        n = n/26;
        i++;
    }

    for(int j=i-1; j>=0; j--){
        printf("%c", a[j]);
    }


}

Measured memory_bytes: 1624
using namespace std;

#include <bits/stdc++.h>

#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

const int N = 2e5 + 5;
int ans = 0, q = 0;

int can(char t, int ost) {
    int am = ('z' - t + 1);
    if (ost < am)
        return -1;
    return am;
}
char next(char c) {
    return ((c == 'z') ? 'a' : c + 1);
}
void solve() {
    string s;
    int k;
    cin >> s >> k;
    int res;
    for (auto &c: s) {
        if (c == 'a')
            continue;
        res = can(c, k);
        if (res == -1)
            continue;
        k -= res;
        c = 'a';
    }
    k %= 26;
    while (k != 0) {
        k--;
        s[s.size() - 1] = next(s[s.size() - 1]);
    }
    cout << s;
}

int main() {
    #ifdef _DEBUG27_
        if (1)
            freopen("input.txt", "r", stdin);
    #else
        if (0) {
            freopen("weapons.in", "r", stdin);
            freopen("weapons.out", "w", stdout);
        }
    #endif

    solve();

    #ifdef _DEBUG27_
        cout << endl << "Time: " << clock() / 1000.0 << " ms";
    #endif
    return 0;
}

/** CLEARING BUFFER

    cout << VAL << flush;

    OR

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


Measured memory_bytes: 512
#include<iostream>
#include<iomanip>
using namespace std;
int main()
{
double x;
double r=0,t=0;
cin>>x;
r = 2 * x * 3.141592653589;
t = x * x * 3.141592653589;
cout<<setprecision(6)<<fixed<<t<<" "<<setprecision(6)<<fixed<<r<<endl;
return 0;
}

Measured memory_bytes: 3268
n, t = map(int, input().split())
apple = [list(input().split()) for _ in range(n)]
orange = []
for i, j  in zip(apple, range(n)):
    if int(apple[j][1]) <= t:
        orange.append(int(apple[j][0]))
    else:
        pass
print(min(orange) if len(orange) > 0 else "TLE")

Measured memory_bytes: 3060
S = input()
T = input()

dp = [[0 for j in range(len(T) + 1)] for i in range(len(S) + 1)]

for i in range(len(S)):
    for j in range(len(T)):
        if S[i] == T[j]:
            dp[i + 1][j + 1] = max(dp[i][j] + 1, dp[i + 1][j], dp[i][j + 1])
        else:
            dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1])

res = []

i = len(S)
j = len(T)

while i and j:
    if dp[i][j] == dp[i - 1][j]:
        i -= 1
    elif dp[i][j] == dp[i][j - 1]:
        j -= 1
    else:
        res.append(S[i - 1])
        i -= 1
        j -= 1

print(''.join(res[::-1]))

Measured memory_bytes: 153224
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using vi = vector<int>;

template<typename T> ostream& operator<<(ostream &os, const vector<T> &v) { os << '['; string sep = ""; for (const auto &x : v) os << sep << x, sep = ", "; return os << ']'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const pair<A, B> &p) { return os << '(' << p.first << ", " << p.second << ')'; }
template<typename A> ostream& operator<<(ostream &os, const set<A> &s) { os << '{'; string sep = ""; for (const auto &x : s) os << sep << x, sep = ", "; return os << '}'; }
template<typename A, typename B> ostream& operator<<(ostream &os, const map<A, B> &m) { os << '{'; string sep = ""; for (const auto &x : m) os << sep << x.first << " -> " << x.second, sep = ", "; return os << '}'; }

#ifdef MY_DEBUG_FLAG
void debug() { cerr << '\n'; }
template<typename Ini, typename... Fim> void debug(Ini I, Fim... F) { cerr << " " << I; debug(F...); }
#define db(...) cerr << "DEBUG (" << #__VA_ARGS__ << ") ==", debug(__VA_ARGS__)
#else
#define db(...)
#endif

#define pb push_back
#define eb emplace_back
#define ff first
#define ss second
#define fast ios_base::sync_with_stdio(false), cout.tie(nullptr), cin.tie(nullptr)
#define sz(a) ((int)(a).size())
#define rep(i,a,b) for(int i=(a); i<(b); i++)
#define dec(i,n,a) for(int i=(n); i>=(a); i--)
#define clr(a,v) memset(a, v, sizeof(a))
#define all(a) (a).begin(),(a).end()

constexpr int inf = 0x3f3f3f3f;
constexpr int maxn = 1e5 + 10;
constexpr int mod = 1000000007;

int p[maxn], c[maxn], fam[maxn], aux;
bool mark[maxn];
vi head, sz;
vector<ll> cost;
vector<ll> rep, repmenos;

void dfs(int u, int tam, ll cs) {
	mark[u] = 1;
	if(mark[p[u]])
		head.pb(u), sz.pb(tam+1), cost.pb(cs+c[u]), fam[u] = aux++;
	else
		dfs(p[u], tam+1, cs+c[u]), fam[u] = fam[p[u]];
}

ll dfs2(int u, int k) {
	if(!k) return 0;
	return max(0ll, dfs2(p[u], k-1)) + c[u];
}

int main() {
	int n, k; scanf("%d %d", &n, &k);
	rep(i,1,n+1) scanf("%d", &p[i]);
	rep(i,1,n+1) scanf("%d", &c[i]);
	rep(i,1,n+1)
		if(!mark[i]) dfs(i, 0, 0);
	db(head, sz, cost);
	ll ans = -inf;

	for(int i = 1; i <= n; i++) {
		if(cost[fam[i]] > 0) {
			ll normal = 1ll * cost[fam[i]] * (k / sz[fam[i]]);
			ans = max(ans, normal + dfs2(i, k % sz[fam[i]]));
			if(k >= sz[fam[i]])
				ans = max(ans, normal - cost[fam[i]] + dfs2(i, sz[fam[i]]));
		} else {
			ans = max(ans, dfs2(i, min(k, sz[fam[i]])));
		}
	}
	
	printf("%lld\n", ans);
}

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

int main(){
    double pai=3.141592653589;
    char chk[10], t[1000];
    int ans=0;
    string ask,tmp;
    scanf("%s",&chk);
    ask=chk;
    transform(ask.begin(),ask.end(),ask.begin(),::toupper);
    for(;;){
        scanf("%s",&t);
        tmp=t;
        if(tmp=="END_OF_TEXT") break;
        transform(tmp.begin(),tmp.end(),tmp.begin(),::toupper);
        if(tmp==ask){
            ans++;
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 3284
import sys
mina=10**10
def waru(a,b):
  if a%b==0:
    return a//b
  else:
    return (a//b)+1
N,H=map(int,input().split())
A=list()
B=list()
for i in range(N):
  a,b=map(int,input().split())
  A.append(a)
  B.append(b)
ma=max(A)
ind=A.index(ma)
B=[i for i in B if i>ma]
B=sorted(B,reverse=True)
cou=1
s=0
for i in range(len(B)):
  s+=B[i]
  if H<=s:
    print(i+1)
    sys.exit()
H=H-s
print(len(B)+waru(H,ma))

Measured memory_bytes: 93180
def main():
    N = int(input())
    A = [input() for i in range(3)]
    ans = 0
    for i in range(N):
        cur = {A[0][i], A[1][i], A[2][i]}
        # print(cur)
        ans += (len(cur) - 1)
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 38384
#include<bits/stdc++.h>
using namespace std;
 
int main()
{
  int a,b,c;
  cin>>a>>b>>c;
  int k=max(a,max(b,c));
  if(k==a && (b+c)==a)
    cout<<"Yes";
  else if(k==b && (a+c)==b)
    cout<<"Yes";
  else if(k==c && (a+b)==c)
    cout<<"Yes";
  else 
    cout<<"No";
  
  return 0;
}
  
  

Measured memory_bytes: 256
N, M = map(int, input().split())
# 電球に対するスイッチの対応関係は、
# [[k1に対応するスイッチ],[k2に対応するスイッチ][k3に対応するスイッチ]...]
# みたいにする
switchToBulb = []
for _ in range(M):
  l = list(map(int, input().split()))
  l.pop(0)
  switchToBulb.append(l)

table = list(map(int, input().split()))

# 全探索しよう
# bit全探索を行う
# スイッチのパターンで全探索を行う
count = 0
for i in range(2 ** N):
    onSwitch = []
    for j in range(N):  # このループが一番のポイント
        if ((i >> j) & 1):  # 順に右にシフトさせ最下位bitのチェックを行う
            onSwitch.append(j + 1)  # フラグが立っていたら bag に果物を詰める
    
    check = [0 for _ in range(1, M+1)]
    for number in onSwitch:
      for index in range(len(switchToBulb)):
        if number in switchToBulb[index]:
          check[index] += 1

    check = [0 if i % 2 == 0 else 1 for i in check]

    if check == table:
      count += 1

print(count)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main(){
	ll a,b,i,flag=0;
  	cin>>a;
  	for(i=1;i<=9;i++){
     	 if(a%i==0 && ((a/i) <= 9)){
          	flag=1;
           	break;
         }
    }
  	if(flag)
      	cout<<"Yes"<<endl;
  	else
      cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define intt long long 
using namespace std;
const int maxx = 100000;
intt A[maxx];
intt n,T,H;
intt Ans=1<<30;
intt read(){intt k;cin>>k;return k;}
intt x[maxx],y[maxx],h[maxx];
intt mx,mi,limit;
bool chick(int XX,int YY){
	mx=-1<<30;limit=-mx;
	mi=-mx;
	for(int i=1;i<=n;i++){
		intt p1=abs(x[i]-XX);
		intt p2=abs(y[i]-YY);
		if(h[i]){
			intt Ans=h[i]+p1+p2;
			mx=max(Ans,mx);
			mi=min(Ans,mi);
		}
		else {
			limit=min(p1+p2,limit); 
		} 
	}	
//	cout<<XX<<"  "<<YY<<"____"<<mx<<"___"<<mi<<endl;
	if(mx!=mi)return 0;
	if(mx>limit)return 0;
	H=mx;
	return 1;
}
int main(){
	n=read();
	for(int i=1;i<=n;i++)x[i]=read(),y[i]=read(),h[i]=read();
	for(int i=0;i<=100;i++)	
		for(int j=0;j<=100;j++){	
			if(chick(i,j)){
				cout<<i<<" "<<j<<" "<<H<<endl;
				return 0;
			}
		}	
	return 0;
}	


Measured memory_bytes: 256
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
using namespace std;

#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define SIZE(x) ((int)(x).size())

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

int main() {
  ll n, m = 1000;
  cin >> n;
  vector<ll> a(n);
  REP(i, n) {
    cin >> a[i];
  }
  REP(i, n-1) {
    ll tmp = 0;
    if (a[i] < a[i+1]) {
      tmp = m / a[i];
    }
    m += (a[i+1] - a[i]) * tmp;
  }
  cout << m << endl;
  return 0;
}


Measured memory_bytes: 3612