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

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
#define int ll

const ll MOD = 1000000007;
const ll INF_LL = (ll)1000000007 * 1000000007;
const int INF_INT = (int)1000000007;
const double PI = 3.14159265358979323846;

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

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define irep(itr, st) for (auto itr = (st).begin(); itr != (st).end(); ++itr)
#define irrep(itr, st) for (auto itr = (st).rbegin(); itr != (st).rend(); ++itr)

#define m0(x) memset((x), 0, sizeof((x)))
#define m1(x) memset((x), -1, sizeof((x)))

// xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end()  // sortなどの引数を省略したい
#define RALL(x) (x).rbegin(), (x).rend()  // sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())     // sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x))  //最大値を求める
#define MIN(x) *min_element(ALL(x))  //最小値を求める
#define all(x) (x).begin(), (x).end()

//略記
#define pb emplace_back  // vectorヘの挿入
#define mp make_pair     // pairのコンストラクタ
#define F first          // pairの一つ目の要素
#define S second         // pairの二つ目の要素

#define BITCOUNT __builtin_popcount
#define BITCOUNT_LL(x) __builtin_popcountll(x)

#define perm(c)             \
  sort(all(c));             \
  for (bool c##p = 1; c##p; \
       c##p = next_permutation(all(c)))  //順列 123 132 213 231 312 321

#define BIT(n) (1LL << (n))

#ifdef DEBUG
#define PRINT(A) std::cout << (#A) << ": " << (A) << std::endl;
#else
#define PRINT(A)
#endif

//入力高速化
struct IoSetup {
  IoSetup() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(20);
  }
} iosetup;

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;
}

signed main() {
  int W, H, x, y;
  cin >> W >> H >> x >> y;
  double ans = W * H;
  ans /= 2;
  cout << ans << " ";
  if (x * 2 == W && y * 2 == H) {
    cout << 1 << endl;
  } else {
    cout << 0 << endl;
  }
}

Measured memory_bytes: 256
N, M = map(int, input().split())
DIVZ = 10**9+7

steps = [0]*(N+3)
for i in range(M):
    bb = int(input())
    steps[bb] = -1

steps[0] = 1
for i in range(N):
    if steps[i] > 0:
        if steps[i+1] >= 0:
            steps[i+1] += steps[i]
            steps[i + 1] %= DIVZ
        if steps[i+2] >= 0:
            steps[i+2] += steps[i]
            steps[i+2] %= DIVZ

print(steps[N])



Measured memory_bytes: 12836
def resolve():
    N = int(input())
    H = [int(i) for i in input().split()]
    maxM = 0
    m = 0
    for i in range(N - 1):
        if H[i] < H[i + 1]:
            m = 0
        else:
            m += 1
            maxM = max(maxM, m)
    print(maxM)


resolve()


Measured memory_bytes: 14252
#include<bits/stdc++.h>
using namespace std;
#define all(v) v.begin(), v.end()
using in = int64_t;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define Yes cout<<"Yes"<<endl 
#define No cout<<"No"<<endl
#define yes cout<<"yes"<<endl 
#define no cout<<"no"<<endl
#define vec(a,y,x)  vector<vector<char>> a (y,vector<char>(x))
const double PI=3.14159265358979323846;
const in MOD = 1000000007;
const in INF=1e18+7;
const int inf=1e9+7;
const vector<int> dx={1,0,-1,0};
const vector<int> dy={0,1,0,-1};

int main(){
  string s;
  int k;
  cin>>k;
  cin>>s;
  if(s.size()<=k){
    cout<<s<<endl;
    return 0;
  }
  rep(i,k)
    cout<<s.at(i);
  cout<<"..."<<endl;
}

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

int main()
{
	int N;
	cin >> N;
	vector<pair<int, int>> A(N);
	int a;
	for (int i = 1; i <= N; ++i)
	{
		cin >> a;
		A[i-1] = {a, i};
	}
	sort(A.begin(), A.end());
	for (int i = 0; i < N; ++i)
	{
		cout << A[i].second << ' ';
	}
}


Measured memory_bytes: 1536
S = input()
if S == 'SUN':
    print(7)
elif S == 'MON':
    print(6)
elif S == 'TUE':
    print(5)
elif S == 'WED':
    print(4)
elif S == 'THU':
    print(3)
elif S == 'FRI':
    print(2)
else:
    print(1)

Measured memory_bytes: 2940
#include <stdio.h>
#include <math.h>

int main(){
	long long b;
	while(scanf("%lld", &b), b){
		for(long long n = sqrt(b * 2) + 5; n > 0; --n){
			if(b * 2 - n * n + n > 0 && (b * 2 - n * n + n) % (n * 2) == 0){
				printf("%lld %lld\n", (b * 2 - n * n + n) / (n * 2), n);
				break;
			}
		}
	}
}



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

int main(){
    ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int N;
	cin>>N;
	int count=0;
	
	for(int i=1;i<=N;i++){
		int n=log10(i);
		if(n%2==0)count++;
	}
	cout<<count;	
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define ull long long
#define mod 1000000007
using namespace std;
ll binpow(ll x,ll y)/* (x^y)%p in O(log y) */{ll res=1;while (y > 0){if(y&1)res=(res*x);y = y>>1;x=(x*x);}return res;}
ll binpowmod(ll x,ll y,ll p)/* (x^y)%p in O(log y) */{ll res=1;x=x%p;while (y > 0){if(y&1)res=(res*x)%p;y = y>>1;x=(x*x)%p;}return res;}
ll mod_inverse(ll n,ll p)/* Returns n^(-1) mod p */{return binpowmod(n,p-2,p);}
ll gcd(ll x,ll y)
{
	if(y==0)
		return x;
	return gcd(y,x%y);
}
bool comp(int x,int y)
{
	return x>y;
}
bool isPowerOfTwo (ll x)  
{  
    /* First x in the below expression is for the case when x is 0 */
    return x && (!(x&(x-1)));  
}

void swap(int &a,int &b)
{
	a=a+b;
	b=a-b;
	a=a-b;
}

void solve()
{
	ll a,b,c,k;
	cin>>a>>b>>c>>k;
	if(k<=a){
		cout<<k;
		return;
	}
	if(k>a && k<=a+b){
		cout<<a;
		return;
	}
	if(k>a+b && k<=a+b+c)
	{
		cout<<a-min(k-a-b,c);
		return;
	}


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

}


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

using namespace std;
#define LL long long

#define wt(x) cerr << #x << " is " << x << '\n';
// #define wt(x) cerr << #x << " is " << x << endl;

const int MAXN = 212345;

multiset <int> s;

int main () {

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

	for (int i = 0; i < n; ++i) {
		int x;
		scanf("%d", &x);

		if (s.empty()) {
			s.insert (x);
			// wt (i);
		}
		else {

			multiset <int> :: iterator it = s.lower_bound (x);

			if (*it == x) {
				if (it == s.begin()) {
					s.insert (x);
				}
				else {
					--it;
					s.erase (it);
					s.insert (x);
				}
			}

			else if (it == s.end()) {
				--it;
				s.erase (it);
				s.insert (x);
			}

			else {
				if (it == s.begin()) {
					s.insert (x);
				}
				else {
					--it;
					s.erase (it);
					s.insert (x);
				}

			}

		}

	}

	int ans = s.size();
	printf("%d\n", ans);


	return 0;
}


Measured memory_bytes: 4992
#include <iostream>
#include <vector>
#include <algorithm>
#include <cassert>

using namespace std;
using ll = long long;
using ull = unsigned long long;
constexpr ll TEN(int n) { return (n==0) ? 1 : 10*TEN(n-1); }

template<uint MD>
struct ModInt {
    uint v;
    ModInt() : v{0} {}
    ModInt(ll v) : v{normS(v%MD+MD)} {}
    static uint normS(const uint &x) {return (x<MD)?x:x-MD;};
    static ModInt make(const uint &x) {ModInt m; m.v = x; return m;}
    ModInt operator+(const ModInt &r) const {return make(normS(v+r.v));}
    ModInt operator-(const ModInt &r) const {return make(normS(v+MD-r.v));}
    ModInt operator*(const ModInt &r) const {return make((ull)v*r.v%MD);}
    ModInt& operator+=(const ModInt &r) {return *this=*this+r;}
    ModInt& operator-=(const ModInt &r) {return *this=*this-r;}
    ModInt& operator*=(const ModInt &r) {return *this=*this*r;}
    static ModInt inv(const ModInt &x) {
        return pow(ModInt(x), MD-2);
    }
};
using Mint = ModInt<TEN(9)+7>;

const int MN = 110;

int main() {
    int n, K;
    cin >> n >> K;
    static Mint dp[MN][MN][256];
    dp[0][0][0] = 1;
    for (int i = 0; i < n; i++) {
        int a;
        cin >> a;
        for (int j = 0; j <= n; j++) {
            for (int k = 0; k < 256; k++) {
                dp[i+1][j][k] += dp[i][j][k];
                if (j) {
                    dp[i+1][j][k] += dp[i][j-1][k^a];
                }
            }
        }
    }

    Mint ans = 0;
    Mint base = 1;
    for (int i = 1; i <= n; i++) {
        base *= i;
        ans += dp[n][i][K] * base;
    }
    cout << ans.v << endl;
    return 0;
}



Measured memory_bytes: 12416
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author
 */

#include <bits/stdc++.h>
using namespace std;

/* TYPES */
#define long int64_t
#define all(v) v.begin(), v.end()
#define fs first
#define sc second
typedef pair<int,int> pii;
typedef pair<int64_t,int> pli;
typedef pair<int64_t,int64_t> pll;
typedef vector<int> vi;
typedef vector<pair<int,int> > vpi;
typedef vector<string> vs;
typedef vector<vector<int> > vvi;
typedef vector<vector<int64_t> > vvl;

/* CONSTANTS */
const long MOD = 1e9+7, LINF = 1e18 + 1e16;
const int INF = 1e9+1;
const double EPS = 1e-10;
const int dx[4] = {-1, 0, 1, 0}, dy[4] = {0, 1, 0, -1};

/* FUNCTIONS */
template<typename T, typename U> inline void setMin(T &x, U y) { if(y < x) x = y; }
template<typename T, typename U> inline void setMax(T &x, U y) { if(x < y) x = y; }
template<typename T>
inline T gcd(T a, T b) {
    T c;
    while(b) c = b, b = a % b, a = c;
    return a;
}
template<typename T>
inline T square(T a) { return a*a; }

class TaskD {

    deque<char> receive_string_and_convert(istream &cin, ostream &cout) {
        string S;
        cin >> S;
        deque<char> dq;
        dq.insert(dq.end(), S.begin(), S.end());
        return dq;
    }

public:
    void solve(istream &cin, ostream &cout) {
        deque<char> dq = receive_string_and_convert(cin, cout);
        bool state = 0;

        int Q;
        cin >> Q;
        for (int _i = 0; _i < Q; _i++) {
            int T;
            cin >> T;
            if (T == 1) {
                state ^= 1;
            } else {
                int F;
                char C;
                cin >> F >> C;
                --F;
                if (F ^ state) {
                    dq.push_back(C);
                } else {
                    dq.push_front(C);
                }
            }
        }

        string result = "";
        while (!dq.empty()) {
            result += dq.front();
            dq.pop_front();
        }
        if (state) {
            reverse(result.begin(), result.end());
        }
        cout << result << endl;
    }
};


class Solver {
public:
    void solve(std::istream& in, std::ostream& out) {
        TaskD *obj = new TaskD();
        obj->solve(in, out);
        delete obj;
    }
};

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    Solver solver;
    std::istream& in(std::cin);
    std::ostream& out(std::cout);
    solver.solve(in, out);
    return 0;
}

Measured memory_bytes: 1388
N, D  = map(int, input().split())
X = [list(map(int, input().split())) for i in range(N)]
ans = 0
for i in range(N):
    for j in range(i+1,N):
        sumD = 0
        for d in range(D):
            sumD += (X[i][d]-X[j][d])**2
        for x in range(128):
            if(sumD==x**2):
                ans += 1
                break
print(ans)

Measured memory_bytes: 3064
mod = 1000000007
eps = 10**-9


def main():
    import sys
    input = sys.stdin.readline

    N = int(input())
    dic = {"AC": 0, "WA":0, "TLE": 0, "RE": 0}
    for _ in range(N):
        S = input().rstrip('\n')
        dic[S] += 1
    print("AC x " + str(dic["AC"]))
    print("WA x " + str(dic["WA"]))
    print("TLE x " + str(dic["TLE"]))
    print("RE x " + str(dic["RE"]))



if __name__ == '__main__':
    main()


Measured memory_bytes: 68228
#include <cstdio>
#include <iostream>
#include <ostream>
#include <type_traits>

using namespace std;

int main(int argc, char const *argv[]) {
  int n, m;
  int L = 0, R = 1e5 + 1;
  cin >> n >> m;
  for (int i = 0; i < m; i++) {
    int l, r;

    scanf("%d %d", &l, &r);

    L = l > L ? l : L;
    R = r < R ? r : R;
  }

  if (L > R)
    cout << 0 << endl;
  else
    cout << R - L + 1 << endl;
  return 0;
}


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

int main(void) {
  int n;
  cin >> n;
  string s;
  vector<int> c(4, 0);
  const int AC = 0;
  const int WA = 1;
  const int TLE = 2;
  const int RE = 3;
  for (int i = 0; i < n; i++) {
    cin >> s;
    if (s == "AC") c[AC]++;
    else if (s == "WA") c[WA]++;
    else if (s == "TLE") c[TLE]++;
    else if (s == "RE") c[RE]++;
  }

  cout << "AC x " << c[AC] << endl;
  cout << "WA x " << c[WA] << endl;
  cout << "TLE x " << c[TLE] << endl;
  cout << "RE x " << c[RE] << endl;

  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

#define MOD 1000000007

int main(void) {
    long double X, Y;
    cin >> X >> Y;
    cout << (ll)log2(Y / X) + 1 << endl;
    return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
using namespace std;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
const int MAX = 210000;
int N;
vector<int>C, V;
void solve() {
    cin >> N;
    C.resize(N);
    V.resize(N);
    for (int i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (int i = 0; i < N; i++) {
        cin >> C[i];
    }
    if (N == 1) {
        if (V[0] - C[0] > 0) {
            cout << V[0] - C[0] << endl;
            return;
        } else {
            cout << 0 << endl;
            return;
        }
    }
    long long ans = 0;
    long long sum_v = 0;
    long long sum_c = 0;
    for (int i = 0; i < N; i++) {
        long long tmp = 0;
        sum_v = 0;
        sum_c = 0;
        for (int j = i; j < N; j++) {
            tmp = (sum_v + V[j]) - (sum_c + C[j]);
            if (tmp > ans) {
                sum_v += V[j];
                sum_c += C[j];
                ans = (sum_v - sum_c);
            }
        }
    }
    if (ans > 0) {
        cout << ans << endl;
    } else {
        cout << 0 << endl;
    }
    return;
}
//逆元を求める関数
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (int i = 2; i < MAX; i++) {
      fac[i] = fac[i-1] * i % MOD;
      inv[i] = MOD - inv[MOD%i] * (MOD/i) % MOD;
      finv[i] = finv[i-1] * inv[i] % MOD;
    }
}
//組み合わせ
long long COM (int n, int k) {
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % MOD) % MOD;
}
int main(int args, char* argv[]) {
    solve();
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int N;cin>>N;
  vector<int> a(N);
  for(int i=0;i<N;i++)cin>>a.at(i);
  sort(a.begin(),a.end());
  
  int p,count=0;
  for(int i=0;i<N;i++){
    if(p!=a.at(i)){
      p=a.at(i);
      count++;
    }
  }
  cout<<count<<endl;
}

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

void main_()
{
    string S;
    cin >> S;

    ll a_count = count(begin(S), end(S), 'a');
    ll b_count = count(begin(S), end(S), 'b');
    ll c_count = S.size() - a_count - b_count;
    cout << (abs(a_count - b_count) <= 1 && abs(a_count - c_count) <= 1 && abs(b_count - c_count) <= 1 ? "YES" : "NO") << endl;
}
int main()
{
    cin.tie(nullptr);
    cout.tie(nullptr);
    ios_base::sync_with_stdio(false);
    main_();
    return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define int long long

signed main(){
	int N; cin >> N;
	vector<int> a(N), num(N);

	for(int i = 0; i < N; i++){
		cin >> a[i];
		num[a[i] - 1]++;
	}
	int ans = 0;
	for(int i = 0; i < N; i++){
		ans += num[i] * (num[i] - 1)/2;
	}
    for(int i = 0; i < N; i++){
		int ans1 = ans;
		int x = num[a[i] - 1];
		ans1 -=  (x*(x - 1) - (x - 2)*(x - 1))/2;
		cout << ans1 << endl;
	}
}

Measured memory_bytes: 5760
import java.util.Scanner;
class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        long N = sc.nextInt();
        sc.close();
        long M;
        long a = N/3;
        long b = N/5;
        long c = N/15;
        M = (1+N)*N
        -a*(a*3+3)
        -b*(b*5+5)
        +c*(c*15+15);
        M = M/2;

        System.out.print(M);
    }
}

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

int main(){
  int N,K,p[3];
  string T;
  cin >> N >> K >> p[0] >> p[1] >> p[2] >> T;
  
  vector<vector<int>> hands(K,vector<int>());
  for(int i=0; i<N; i++){
    if(T[i]=='r') hands[i%K].push_back(2);
    else if(T[i]=='s') hands[i%K].push_back(0);
    else hands[i%K].push_back(1);
  }
  
  int points=0;
  for(int i=0; i<K; i++){
    bool won=false;
    for(int j=0; j<hands[i].size(); j++){
      if(j==0){
        points+=p[hands[i][j]];
        won=true;
      }else if(hands[i][j]==hands[i][j-1]&&won==true){
        won=false;
      }else{
        points+=p[hands[i][j]];
        won=true;
      }
    }
  }
  
  cout << points << endl;
}

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

const int MAX_N = 200005;
int64_t as[MAX_N];

int main() {
  int N;
  scanf("%d", &N);
  for (int i = 0; i < N; ++i) {
    scanf("%lld", as + i);
  }
  int64_t prev = as[0];
  int64_t count = 0;
  for (int i = 1; i < N; ++i) {
    if (as[i] < prev) {
      count += prev - as[i];
      as[i] = prev;
    }
    prev = as[i];
  }
  printf("%lld\n", count);
}


Measured memory_bytes: 5280
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, M;

  cin >> N;  
  vector<string> s(N);   
  for (int i = 0; i < N; i++) {
    cin >> s.at(i);
  }
 
  cin >> M;  
  vector<string> t(M);   
  for (int i = 0; i < M; i++) {
    cin >> t.at(i);
  }
  
  int X = 0;

  for (int i = 0; i < N; i++) {
    int tmpX =0;
    for (int j = 0; j < N; j++) {
      if(s.at(i) == s.at(j)){
        tmpX++;
      }
    }
    for (int k = 0; k < M; k++) {
      if(s.at(i) == t.at(k)){
        tmpX--;
      }
    }
    if(tmpX > X){
      X = tmpX;
    }
  }
  cout << X << endl;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void){
  long n, h, w;
  cin>>n>>h>>w;
  long a[n], b[n], i, count=0;
  for(i=0; i<n; i++){
    cin>>a[i]>>b[i];
    if(a[i]>=h)
      if(b[i]>=w)
	count++;
  }
  cout<<count<<endl;
  return 0;
}

Measured memory_bytes: 256
import kotlin.math.hypot

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xy = (1..n).map {
        readLine()!!.split(" ").let {
            Pair(it[0].toDouble(), it[1].toDouble())
        }
    }
    println(xy.map { (x1, y1) ->
        xy.map { (x2, y2) ->
            hypot(x1 - x2, y1 - y2)
        }.sum()
    }.sum() / n)
}


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

int main( int argc, char *argv[] )
{
int i;
int H;
int W;
char S[ 110 ];

	ios::sync_with_stdio( false );
	cin.tie( 0 );

	cin >> H;
	cin >> W;
	for( i = 0; i < H; i++ )
	{
		cin >> S;
		cout << S << endl;
		cout << S << endl;
	}

	return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
int main(){
int k;
long long ans = 0;
  cin>>k;
  for( int i = 1;i<=k;i++){
  	for(int j = 1;j<=k;j++){
      for(int l = 1;l<=k;l++){
        ans+=gcd(gcd(i,j),l);
      }
    }
  }
cout<<ans<<endl;
}

Measured memory_bytes: 3636
import math

n = int(input())

x = input().split()

y = input().split()

Manhattan = 0.0

Euclidean = 0.0

Chebyshev = 0.0

Minkowski = 0.0

for i in range(n):
  Manhattan += abs(int(x[i])- int(y[i]))

  Euclidean += math.pow((int(x[i])- int(y[i])), 2.0)

  Chebyshev += math.pow(abs(int(x[i])- int(y[i])), 3.0)

  if Minkowski < abs((int(x[i])- int(y[i]))): Minkowski = abs(int(x[i])-int(y[i])) 

Euclidean = math.sqrt(Euclidean)
Chebyshev = Chebyshev**(1/3)
  
print("%.8f"%Manhattan)
print("%.8f"%Euclidean)
print("%.8f"%Chebyshev)
print("%.8f"%Minkowski)


Measured memory_bytes: 5720
#include <algorithm>
#include <iostream>
#include <vector>
using namespace std;
const int MAX = 20000;

int main() {
    int h, w; cin >> h >> w;
    vector<vector<int>> a(h, vector<int>(w));
    for (auto &ai: a) for (auto &aij: ai) cin >> aij;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        int b; cin >> b;
        a[i][j] = abs(a[i][j] - b);
    }
    using vvi = vector<vector<int>>;
    vector<vvi> dp(h, vector<vector<int>>(w, vector<int>(MAX + 80)));
    dp[0][0][abs(a[0][0])] = true;
    for (int i = 0; i < h; i++) for (int j = 0; j < w; j++) {
        if (i + 1 < h) {
            for (int k = 0; k < MAX; k++) {
                dp[i + 1][j][abs(k + a[i + 1][j])] |= dp[i][j][k];
                dp[i + 1][j][abs(k - a[i + 1][j])] |= dp[i][j][k];
            }
        }
        if (j + 1 < w) {
            for (int k = 0; k < MAX; k++) {
                dp[i][j + 1][abs(k + a[i][j + 1])] |= dp[i][j][k];
                dp[i][j + 1][abs(k - a[i][j + 1])] |= dp[i][j][k];
            }
        }
    }
    int ans = 0;
    while (!dp[h - 1][w - 1][ans]) ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 508928
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
typedef  unsigned long long int ull;
typedef pair<ll,ll> P;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
//const ll mod=998244353;
const ll mod=1000000007;
//ios_base::sync_with_stdio(false);
//cin.tie(NULL);
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
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; }
int main(){
    string s;
    cin>>s;
    string t="keyence";
    int n=s.size();
    for(int i=0;i<n;i++){
        int lcnt=0;
        bool ng=false;
        for(int j=0;j<i;j++){
            if(lcnt<t.size()&&s[j]==t[lcnt])lcnt++;
            else ng=true;
        }
        if(ng)continue;
        for(int j=i;j<n;j++){
            int rcnt=lcnt;
            bool flag=false;
            for(int k=j;k<n;k++){
                if(rcnt<t.size()&&s[k]==t[rcnt])rcnt++;
                else flag=true;
            }
            if(!flag&&rcnt==t.size()){
                cout<<"YES"<<endl;
                return 0;
            }
        }
    }
    cout<<"NO"<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define pii pair<int,int>
#define piii pair<int,pii>
#define pll pair<ll,ll>
#define plii pair<ll,pii>
#define vi vector<int>
#define ff first
#define ss second
#define mp make_pair
#define pb push_back
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mx 100001
#define eps 0.00000000001
#define mod 1000000007
#define pi acos(-1)
#define inf 100000000
#define loop(i,b,n) for(int i=b;i<n;++i)
#define rev_loop(i,b,n) for(int i=b;i>=n;--i)
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
using namespace std;
int main()
{
    fio;
    int n;
    cin>>n;
    vector<ll> v1;
    ll a1;
    loop(i,0,n)
    {
        cin>>a1;
        v1.pb(a1);
    }
    SORT(v1);
    ll s1 = 0 , s2 = 0;
    loop(i,0,n)
    {
        if(v1[i]==v1[i+1])
        {
            if(s1<=s2)
                s1 = v1[i];
        else
            s2 = v1[i];
        i++;
        }
    }
    cout<<s1*s2<<endl;
    return 0;
}



Measured memory_bytes: 4240
import bisect

n = int(input())
a_list = [int(x) for x in input().split()]
b_list = [int(x) for x in input().split()]
c_list = [int(x) for x in input().split()]

a_list = sorted(a_list)
b_list = sorted(b_list)
c_list = sorted(c_list)

ans = 0

for b_i in b_list:
    a_count_i = bisect.bisect_left(a_list,b_i)
    c_count_i = len(c_list) - bisect.bisect_right(c_list,b_i)
    ans += a_count_i * c_count_i

print(ans)

Measured memory_bytes: 23640
#include<bits/stdc++.h>
#define pb push_back
#define gc getchar 
using namespace std;
const int N=5e4+10,mod=998244353,g=3;
typedef long long ll;
typedef double db;
 
int n,m,ans,f[N],h[N],t[N],frc[N],nv[N],ivg;
 
char cp;
template<class T>inline void rd(T &x)
{
	cp=gc();x=0;int f=0;
	for(;!isdigit(cp);cp=gc()) if(cp=='-') f=1;
	for(;isdigit(cp);cp=gc()) x=x*10+(cp^48);
	if(f) x=-x;
}
 
inline int fp(int x,int y)
{
	int re=1;
	for(;y;y>>=1,x=(ll)x*x%mod)
	  if(y&1) re=(ll)re*x%mod;
	return re;
}
 
inline int ad(int x,int y){x+=y;return x>=mod?x-mod:x;}
inline int dc(int x,int y){x-=y;return x<0?x+mod:x;} 
inline int C(int n,int m)
{
	if(m>n) return 0;
	return (ll)frc[n]*nv[m]%mod*(ll)nv[n-m]%mod;
}
 
namespace poly{
   int rv[N],L,len;
   
   inline void ntt(int *e,int pr)
   {
   	   int i,j,k,ix,iy,pd,ori,G=pr?g:ivg;
   	   for(i=1;i<len;++i) if(i<rv[i]) swap(e[i],e[rv[i]]);
   	   for(i=1;i<len;i<<=1){
   	      ori=fp(G,(mod-1)/(i<<1));
   	      for(j=0;j<len;j+=(i<<1)){
   	      	for(pd=1,k=0;k<i;++k,pd=(ll)pd*ori%mod){
   	      		ix=e[j+k];iy=(ll)pd*e[j+i+k]%mod;
   	      		e[j+k]=ad(ix,iy);e[i+j+k]=dc(ix,iy);
			}
		  }
	   }
	   if(pr) return;
	   G=fp(len,mod-2);
	   for(i=0;i<len;++i) e[i]=(ll)e[i]*G%mod;
   }
   
   void mul(int *f,int *g,int n,int m)
   {
   	   int i;
   	   for(L=0,len=1;len<=n+m;len<<=1) L++;
	   for(i=1;i<len;++i) rv[i]=(rv[i>>1]>>1)|((i&1)<<(L-1));
	   for(i=n+1;i<len;++i) f[i]=0;
   	   for(i=m+1;i<len;++i) g[i]=0;
   	   ntt(f,1);ntt(g,1);
   	   for(i=0;i<len;++i) f[i]=(ll)f[i]*g[i]%mod;
	   ntt(f,0); 
   }
}
using namespace poly;
 
int main(){
	int i,j,x,y;ivg=fp(g,mod-2);
	rd(n);rd(m);
	f[0]=frc[0]=nv[0]=frc[1]=nv[1]=1;
    for(i=2;i<n+3;++i)
	  frc[i]=(ll)frc[i-1]*i%mod,
	  nv[i]=(ll)(mod-mod/i)*nv[mod%i]%mod;
	for(i=2;i<n+3;++i) nv[i]=(ll)nv[i-1]*nv[i]%mod;
	for(i=1;i<=n;++i) h[i]=nv[i+2];
	for(L=0,len=1;len<=(n<<1);len<<=1) L++;
	for(i=1;i<len;++i) rv[i]=((rv[i>>1]>>1)|((i&1)<<(L-1)));
	ntt(h,1);
	for(j=1;j<=m;++j){
		for(i=0;i<=n;++i) t[i]=(ll)nv[i]*f[i]%mod;
		for(i=n+1;i<len;++i) t[i]=0;
		ntt(t,1);
		for(i=0;i<len;++i) t[i]=(ll)h[i]*t[i]%mod;
		ntt(t,0);
		for(i=0;i<=n;++i)
		 f[i]=ad((ll)(1+C(i+1,2))*f[i]%mod,(ll)t[i]*frc[i+2]%mod);
	}
	for(i=0;i<=n;++i) ans=ad(ans,(ll)C(n,i)*f[i]%mod);
	printf("%d",ans);
	return 0;
}

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

class UnionFind {
private:
  int *par, *rank;

public:
  UnionFind() {}
  UnionFind(int n) {
    par = new int[n];
    rank = new int[n];
    for(int i = 0; i < n; ++i) {
      par[i] = i;
      rank[i] = 0;
    }
  }

  int find(int x) {
    if(par[x] == x) return x;
    return par[x] = find(par[x]);
  }

  bool same(int x, int y) {
    return find(x) == find(y);
  }

  void unite(int x, int y) {
    x = find(x);
    y = find(y);
    if(x == y) return;
    if(rank[x] < rank[y]) {
      par[x] = y;
    } else {
      par[y] = x;
      if(rank[x] == rank[y]) {
        ++rank[x];
      }
    }
  }
};


int main() {
  int n, m;
  while(cin >> n >> m && (n|m)) {
    pair<int,pair<int,int> > es[m];
    for(int i = 0; i < m; ++i) {
      cin >> es[i].second.first
          >> es[i].second.second
          >> es[i].first;
    }
    sort(es, es+m);
    UnionFind uf(n);
    int res = 0;
    for(int i = 0; i < m; ++i) {
      int a = es[i].second.first;
      int b = es[i].second.second;
      if(!uf.same(a,b)) {
        res += es[i].first;
        uf.unite(a,b);
      }
    }
    cout << res << endl;
  }
  return 0;
}

Measured memory_bytes: 1192
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
	Scanner scan = new Scanner(System.in);

	int n = scan.nextInt();
	double[] x = new double[n];
	String[] u = new String[n];
	for(int i = 0; i < n; i++){
	    x[i] = scan.nextDouble();
	    u[i] = scan.next();
	}

	double sum = 0;
	for(int i = 0; i < n; i++){
	    if(u[i].equals("JPY")){
		sum += x[i];
	    }else{
		sum += x[i]*380000.0;
	    }
	}

	System.out.println(sum);
    }
}
		 


Measured memory_bytes: 24144
#include <stdio.h>
#include <string.h>
#define N 1500000
#define L 13

char moji[N][L],order[7];

int h1(int key) { return key % N; }
int h2(int key) { return  1 + (key % (N-1)); }

int ctoi(char str){
	if(str == 'A') return 1;
	else if(str == 'C') return 2;
	else if(str == 'G') return 3;
	else if(str == 'T') return 4;
	else return 0;
}

int getKey(char str[]){
	int sum=0,time=1,i;
	for(i=0; i<strlen(str); i++){
		sum += time * (ctoi(str[i]));
		time *= 4;
	}
	return sum;
}

void insert(char str[]){
	int i,key,h;
	key = getKey(str);
	for(i=0; ; i++){
	h = (h1(key) + i * h2(key)) % N;
	if(strcmp(moji[h],str) == 0) break;
	else if(strlen(moji[h]) == 0){
	strcpy(moji[h],str);
	break;
	}
	}
}

int find(char str[]){
	int key,i,h;
	key = getKey(str);
	for(i=0; ; i++){
		h = (h1(key) + i * h2(key)) % N;
		if(strcmp(moji[h],str) == 0) return 1;
		else return 0;
	}
}

int main(){
	int i,j,num;
	char str[L];
	scanf("%d",&num);
	for(i=0; i<N; i++) moji[i][0] = '\0';
	for(i=0; i<num; i++){
	scanf("%s%s",order,str);
	if(strcmp(order,"insert") == 0) insert(str);
	else{ 
	if(find(str) == 1) printf("yes\n"); 
	else  printf("no\n");
	}
	}
	return 0;
}

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

int main(){
  int n,k;
  cin>>n>>k;
  vector<int> d(k);
  vector<vector<int>> a(k, vector<int>(n));
  rep(i,k){
    cin>>d[i];
    rep(j,d[i]) cin>>a[i][j];
  }
  int ans=n;
  for(int l=1; l<=n; l++){
    bool have = false;
    rep(i,k)rep(j,n){
      if(l==a[i][j]) have = true;
    }
    if(have) ans--;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;

#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); cerr << endl << "Time elapsed: " << (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms"; return 0
#define speed() cin.tie(0), cout.tie(0), ios_base::sync_with_stdio(false)
// #define exit(a, b) return cout << a, b;

#define loop(i,a,b) for(ll i=a;i<b;i++)
#define all(v) v.begin(), v.end() 
#define len length

#define print(stuff) cout << stuff << endl

#define ll long long
#define ld long double
#define fi first
//#define endl '\n'
#define se second
#define pb push_back
#define mp make_pair
#define lb lower_bound
#define ub upper_bound

typedef tree<ll,null_type,less<ll>,rb_tree_tag,
tree_order_statistics_node_update> indexed_set;

#define vl vector<ll> 
#define sl set<ll>
#define pll pair<ll, ll>
#define mll map<ll, ll> 
#define pq priority_queue<ll>

#define inf (long long int) 1e18
#define eps 0.000001
#define mod 1000000007
#define mod1 998244353
#define MAXN 100001



int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
   /* #ifndef ONLINE_JUDGE
        start_routine();
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif*/

    ll n, k;
    cin>>n>>k;
    string s;
    cin>>s;
    ll x=s[k-1]-'A';
    s[k-1]=char(x+'a');
    cout<<s<<endl;
        
    /*#ifndef ONLINE_JUDGE
        end_routine();
    #endif*/
}


Measured memory_bytes: 256
N = int(input())

def num753(s):
  if int(s) > N:
    return 0
  if all(s.count(c) > 0 for c in "753"):
    ret = 1
  else:
    ret = 0
  for c in "753":
    ret += num753(s + c)
  return ret

print(num753("0"))

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

int main () {
  string s[3];
  cin >> s[0] >> s[1] >> s[2];
  
  int i = 0;
  
  while(1){
    if (s[i].size() == 0){
      cout << char('A' + i) << endl;
      return 0;
    }
    char c=s[i][0];
    s[i].erase(0,1);
    i=c-'a';
  }
}

  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1000000007;
#define INF 1LL<<30
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()

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

    int ans=0;
    rep(i,1000){
        string t=to_string(i);
        if(t.size()==1) t="00"+t;
        else if(t.size()==2) t="0"+t;

        //cout<<t<<endl;
        int id=0;
        rep(j,n){
            if(s[j]==t[id]) id++;
            if(id==3){
                ans++;
                break;
            }
        }
    }

    cout<<ans<<endl;
}


Measured memory_bytes: 3740
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000
#define int long long

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, A, B, C, D, E;
    cin >> N >> A >> B >> C >> D >> E;
    int k = min({A, B, C, D, E});
    cout << 5 + (N - 1)/k << endl;

    return 0;
}


Measured memory_bytes: 256
n,k = map(int,input().split())
a = list(map(int,input().split()))
a.sort()
if k == 1:
  print(0)
  quit()
mod = 10**9+7
fact = [1]
fact_inv = [0]*(n+4)
for i in range(n+3):
  fact.append(fact[-1]*(i+1)%mod)
fact_inv[-1] = pow(fact[-1],mod-2,mod)
for i in range(n+2,-1,-1):
  fact_inv[i] = fact_inv[i+1]*(i+1)%mod
def mod_comb_k(n,k,mod):
  if n*k == 0:
    return 1
  return fact[n] * fact_inv[k] % mod * fact_inv[n-k] %mod

maxS = 0
minS = 0
for i in range(0,n):
  if n-i-1 >= k-1:
    minS += (mod_comb_k(n-i-1,k-1,mod)*a[i])%mod
  if i >= k-1:
    maxS += (mod_comb_k(i,k-1,mod)*a[i])%mod
  minS %= mod
  maxS %= mod
print((maxS-minS)%mod)

Measured memory_bytes: 64932
//https://atcoder.jp/contests/dp/tasks/dp_a

#include<bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define mp make_pair
using namespace std;

using ll = long long;
using ii = pair<int, int>;
const int INF = (int)10e9;
int N;
vector<int> v;
vector<int> dp;

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

    cin >> N;
    v.resize(N);
    dp.resize(N);
    fill(all(dp), 0);

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

    for(int i = 1; i < N; i++) {
        if(i == 1) dp[i] = abs(v[i] - v[i-1]);
        else dp[i] = min(abs(v[i] - v[i-1]) + dp[i-1], abs(v[i] - v[i-2]) + dp[i-2]);
    }

    cout << dp[N-1] << endl;

    return 0;
}


Measured memory_bytes: 1024
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

func main() {
	const mod = 1e+9 + 7
	n, k := readI(), readI()

	ans := 0
	for i := k; i <= n+1; i++ {
		min := sumNtoM(0, i-1)
		max := sumNtoM(n-i+1, n)

		ans += max - min + 1
		ans %= mod
	}
	fmt.Println(ans)
}

func sumNtoM(n, m int) int {
	return (n + m) * (m - n + 1) / 2
}

/*-----------Utils-----------*/

var sc = bufio.NewScanner(os.Stdin)

func init() {
	if len(os.Args) >= 2 {
		if os.Args[1] == "debug" {
			debug()
		}
	}
	const maxBuf = 200100
	var buf []byte = make([]byte, maxBuf)
	sc.Split(bufio.ScanWords)
	sc.Buffer(buf, maxBuf)
}

func debug() {
	testFile, err := os.Open("./test/sample-1.in")
	if err != nil {
		fmt.Fprintln(os.Stderr, "Error : There is no testfile.")
		os.Exit(1)
	}
	sc = bufio.NewScanner(testFile)
}

func readS() string {
	sc.Scan()
	return sc.Text()
}

func readSs(a int) []string {
	b := make([]string, a)
	for i := 0; i < a; i++ {
		b[i] = readS()
	}
	return b
}

func readI() int {
	sc.Scan()
	r, _ := strconv.Atoi(sc.Text())
	return r
}

func readIs(a int) []int {
	b := make([]int, a)
	for i := 0; i < a; i++ {
		b[i] = readI()
	}
	return b
}

func readF() float64 {
	sc.Scan()
	r, _ := strconv.ParseFloat(sc.Text(), 64)
	return r
}

func readFs(a int) []float64 {
	b := make([]float64, a)
	for i := 0; i < a; i++ {
		b[i] = readF()
	}
	return b
}


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

int main() {
  int a=0;
  int b;
  
  for (int i=0;i<5;i++){
    cin >> b;
    if (b == 0){
      a = i + 1;
      break;
    }
  }
  
  cout << a << endl;
  
  
  
}


Measured memory_bytes: 3592
#include <iostream>

using namespace std;

int main(){
  int D, T, S;
  cin >> D >> T >> S;
  
  double time = (double)D/S;
  
  if (T >= time){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
  return 0;
}

Measured memory_bytes: 3580
#include <iostream>
#include <string>
#include <vector>
#include <ios>
#include <iomanip>
#include <stack>
#include <queue>
#include <algorithm>

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

using namespace std;

const int INF = 100000000;

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

  float sum = 0;
  REP(i,n){
    float x;
    string s;
    cin >> x >> s;
    if (s == "JPY") {
      sum += x;
    }else{
      sum += 380000.0 * x;
    }
  }

  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define ll long long
#define mod 998244353
using namespace std;
ll gcd(ll a, ll b)
{
    if (b == 0)
        return a;
    return gcd(b, a % b);

}
int main()
{
    ios_base:: sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
    ll k;
    cin>>k;
    queue<ll>q;
    set<ll>s;
    for(ll i=1;i<=9;i++)
    {
        q.push(i);
        k--;
        s.insert(i);
        if(k==0)
        {
            cout<<i;
            return 0;
        }
    }
    vector<ll>v;
    while(!q.empty())
    {
        ll flag = 0;
        ll fi = q.front();
        q.pop();
        for(ll i=-1;i<=1;i++)
        {
            ll a = fi*10;
            ll b = fi%10;
            b += i;
            if(b < 0 || b>9)
                continue;
            a = a+b;
            if(s.find(a) != s.end())
                continue;
            q.push(a);
            s.insert(a);
            k--;
            //v.pb(a);
            //cout<<a<<endl;
            if(k == 0)
            {
                cout<<a;
                return 0;
                flag = 1;
                break;
            }
        }
        if(flag)
            break;
    }

}


Measured memory_bytes: 5504
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    String c[] = new String[3];
    
    for (int i = 0; i < 3; i++)
      c[i] = sc.next();
    
    for (int i = 0; i < 3; i++)
      System.out.print(c[i].substring(i, i+1));
  }
}

Measured memory_bytes: 21844
#include <cstdio>
int main(){
    int input;
    int i;
    //scanf("%d",&input);
    int first=0,second=0,third=0;
    for(i=0;i<10;++i){
        scanf("%d",&input);
        if(input>first){
            third=second;
            second=first;
            first=input;
        }
        else if(input>second){
            third=second;
            second=input;
        }
        else if(input>third){
            third=input;
        }
    }
    printf("%d\n%d\n%d\n",first,second,third);
    return 0;
}

Measured memory_bytes: 1028
#include <iostream>
using namespace std;
main(){
	int n;
	int w;
	cin >> n;
	for(int i=0;i<n;i++){
		cin >> w;
		cout << "Case " << i+1 << ":" << endl;
		for(int j=0;j<10;j++){
			w = w*w;
			w /= 100;
			w = w % 10000;
			cout << w << endl;
		}
	}
}

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

using namespace std;
using   ll=long long;

#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);

#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define pll				pair<int , int>
#define int             long long int
#define endl            "\n"

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			998244353

ll mod_pow(ll a,ll b,ll m)
{
    ll res = 1;
    while(b)
    {
        if(b&1)
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(int a , int m)
{
	return mod_pow(a , m - 2 , m);
}

void solve() {
	int n;
	
	cin >> n;
	
	int a[n];
	int b[n];
	
	for(int i = 0; i < n; ++i) {
		cin >> a[i] >> b[i];
	}
	
	int ok = 0;
	
	for(int i = 0; i < n-2; ++i) {
		if(a[i] == b[i] && a[i+1] == b[i+1] && a[i+2] == b[i+2]) {
			ok = 1;
		}
	}
	
	if(ok) {
		cout << "Yes";
	}
	else {
		cout << "No";
	}
}

signed main() {
	fast;
   
    int t = 1;

	//cin >> t;

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

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
#define rep(i, m, n) for (int i = m; i < n; ++i)

int N, K;
vector<int> L;

int dfs(int n) {
  if (n >= N) return n;
  int ret = 1e9;
  for (auto p : L) {
    if(n == 0 && p == 0) continue;
    ret = min(ret, dfs(10 * n + p));
  }
  return ret;
}

int main() {
  cin >> N >> K;
  vector<int> D(K);
  rep(i, 0, K) cin >> D[i];
  rep(i, 0, 10) {
    bool ok = true;
    rep(j, 0, K) if (i == D[j]) ok = false;
    if (ok) L.push_back(i);
  }
  cout << dfs(0) << endl;
  return 0;
}


Measured memory_bytes: 256
import sys
read = sys.stdin.read
def main():
    s = list(input())
    t = list(input())
    s.sort()
    t.sort(reverse=True)
    s = "".join(s)
    t = "".join(t)
    if s < t:
        print('Yes')
    else:
        print('No')


if __name__ == '__main__':
    main()

Measured memory_bytes: 61808
#include <bits/stdc++.h>
//#include <ext/pb_ds/tree_policy.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
//template<typename key, typename val>
//using ordered_tree =
//  tree<key, val, less<>, rb_tree_tag, tree_order_statistics_node_update>;
typedef long long int64;
typedef complex<double> comp;
const double pi = 3.14159265358979323846;
const int inf = (int)1e+9 + 2;
const int64 inf64 = (int64)1e+18 + 2;
const double dinf = 1e+20;
const int mod = 1'000'000'007;//998244353;
const int base = 2187;
const double eps = 1e-8;
const int N = 1'000'000;
const int LOGN = 18;

int n, m, k;

void solve(int test)
{
  cin >> n;
  vector<int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
  }
  sort(begin(a), end(a));
  cout << a[n / 2] - a[n / 2 - 1] << '\n';
}

void precalc()
{
}

int main()
{
  ios::sync_with_stdio(0);
  cin.tie(0), cout.tie(0);
  precalc();
  int test = 1;
  //cin >> test;
  //auto start = chrono::high_resolution_clock::now();
  for (int i = 1; i <= test; ++i)
    solve(i);
  //cerr << chrono::duration_cast<chrono::milliseconds>(chrono::high_resolution_clock::now() - start).count() << '\n';
  return 0;
}


Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#define rep(i,n) for(int i=0;i<(n);i++)
#define SORT(x) (sort(x.begin(),x.end()))
#define psortsecond(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.second<b.second;});
#define psortfirst(A,N) sort(A,A+N,[](const pii &a, const pii &b){return a.first<b.first;});
#define All(x) (x).begin(),(x).end()
using namespace std;
using pii  = pair<int,int>;
long long gcd(long long a, long long b){return (b == 0 ? a : gcd(b, a%b));}
long long lcm(long long a, long long b){return a*b/gcd(a,b);}
typedef long long ll;
#define MOD 1000000007
#define EPS 10e-8

int main() {
    ll N,A[5];
    cin>>N;
    rep(i,5){
        cin>>A[i];
    }
    ll y=A[0];
    rep(i,4){
        y=min(y,A[i+1]);
    }
    cout<<(N%y==0 ? N/y+4 : N/y+5) <<endl;
}

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

map<ll, ll> mp;
int main() {
	ll n; cin >> n;
	rep(i, 0, n) {
		ll a; cin >> a;
		mp[a]++;
	}

	ll x = 0, y = 0;
	ll ans = 0;
	for (map<ll, ll>::iterator it = mp.end();; it--) {
		if (it == mp.end())continue;

		if (it->second >= 4) {
			if (x == 0) {
				x = it->first;
				ans = x * x;
				break;
			}
			else {
				y = it->first;
				ans = x * y;
				break;
			}
		}
		else if (it->second >= 2) {
			if (x == 0) {
				x = it->first;
			}
			else {
				y = it->first;
				ans = x * y;
				break;
			}
		}
		if (it == mp.begin()) break;
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 6528
n, m = map(int, input().split())
ab = [tuple(int(x) for x in input().split()) for _ in range(m)]

s = [[] for i in range(n)]
for a, b in ab:
    s[a - 1].append(b - 1)
    s[b - 1].append(a - 1)

route = [[x, 0] for x in s[0]]
c = [[] for i in range(n)]
while 1:
    next = []
    for x in route:
        for y in s[x[0]]:
            if y == x[1]:
                continue
            if y in x:
                #print(x, y, c)
                if y not in c[x[0]]:
                    c[x[0]].append(y)
                if x[0] not in c[y]:
                    c[y].append(x[0])
                for i in range(len(x) - 1):
                    if x[i + 1] not in c[x[i]]:
                        c[x[i]].append(x[i + 1])
                    if x[i] not in c[x[i + 1]]:
                        c[x[i + 1]].append(x[i])
                    if x[i + 1] == y:
                        break
            else:
                next.append([y] + x)
    if len(next) == 0:
        break
    route = [] + next

#print(s)
#print(c)

ans = 0
for i in range(n):
    ans += len(s[i]) - len(c[i])

print(ans // 2)






Measured memory_bytes: 5876
#include<iostream>
#include<complex>
using namespace std;
int main()
{
    int n,k,d,a,i,j;
    bool s[101]={0};
    cin >> n >> k;
    for(i=0;i<k;i++){
        cin >> d;
        for(j=0;j<d;j++){
            cin >> a;
            if(s[a]==0){
                s[a]=1;
                n--;
            }
        }
    }
    cout << n;
    return 0;
}

Measured memory_bytes: 3636
import math

N, M = map(int, input().split())
MOD = 10 ** 9 + 7
if N == M:
    print(math.factorial(N) ** 2 * 2 % MOD)
elif abs(N-M) == 1:
    print(math.factorial(max(N, M)) * math.factorial(min(N, M)) % MOD)
else:
    print(0)


Measured memory_bytes: 5188
from decimal import Decimal, getcontext
a,b,c = input().split()
getcontext().prec = 10000
a = Decimal(a).sqrt()
b = Decimal(b).sqrt()
c = Decimal(c).sqrt()
if a+b+Decimal(1e-14)< c:
	print("Yes")
else:
  	print("No")

Measured memory_bytes: 5076
program Project1;

{$APPTYPE CONSOLE}

uses
  SysUtils;
var
  a:string;
begin
  try
    { TODO -oUser -cConsole メイン : ここにコードを記述してください }
    Readln(a);

    if (a[1] = a[3]) then
      Writeln('H')
    else
      Writeln('D');
    Readln;
  except
    on E: Exception do
      Writeln(E.ClassName, ': ', E.Message);
  end;
end.


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define MOD 1000000007
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
using P = pair<int,int>;
  
int main()
{
  ll N,K,S;
  cin >> N >> K >> S;

  if(S!=1000000000){
    REP(i,N){
      if(i<K){
        cout << S;
      }else{
        cout << 1000000000;
      }
      if(i!=N-1){
        cout << " ";
      }
    }
    cout << endl;
  }else{
    REP(i,N){
      if(i<K){
        cout << S;
      }else{
        cout << 999999999;
      }
      if(i!=N-1){
        cout << " ";
      }
    }
    cout << endl;
  }
}

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

int main() {
 int a, b, c, d, e;
 cin >> a >> b >> c >> d >> e;
 int hour = c-a;
 if(b <= d){
 int sa = hour*60 +(d-b);
 cout << sa-e << endl;
  return 0;
 }
 if(b > d){
 int sa = hour*60 - (b-d);
 cout << sa-e << endl;
 }
}


Measured memory_bytes: 3636