akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <string>
#include <algorithm>
#include <cmath>
#include <map>
#include <vector>
#include <stack>
#include <queue>
#include <tuple>

using namespace std;
typedef long long ll;
int dx[4] = {0,0,1,-1};
int dy[4] = {1,-1,0,0};
const int INF = 1<<29;
const ll LNF = 1LL<<60;

ll v[110];
ll w[110];
ll dp[110][100010];

int main(){
    int a,b,c; cin >> a >> b >> c;
    if(a==b && b==c) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

signed
main(){
		int h,w;
		while(cin >> h >> w && !(h==0 && w==0))
		{
				int sd = h*h + w*w;
				bool hw_exist = false;
				int ans_h = 150, ans_w = 150, ans_sd = ans_h*ans_h+ans_w*ans_w;
				for(int nh=1;nh*nh<sd;nh++)
				{
						for(int nw=nh+1;nh*nh+nw*nw<=sd;nw++)
						{
								if(nh==h && nw==w) continue;
								if(nh*nh+nw*nw == sd && h < nh && nh < ans_h)
								{
										ans_h = nh;
										ans_w = nw;
										hw_exist = true;
								}
						}
				}

				if(hw_exist)
				{
						cout << ans_h << " " << ans_w << endl;
						continue;
				}

				ans_h = 150, ans_w = 150, ans_sd = ans_h*ans_h+ans_w*ans_w;
				for(int nh=1;nh<=200;nh++)
				{
						for(int nw=nh+1;nw<=200;nw++)
						{
								if(nh==h && nw==w) continue;
								int tmp_sd = nh*nh+nw*nw;
								if(tmp_sd > sd)
								{
										if(tmp_sd < ans_sd)
										{
											ans_h = nh;
											ans_w = nw;
											ans_sd = tmp_sd;
										}
								}
						}
				}
				for(int nh=1;nh<=200;nh++)
				{
						for(int nw=nh+1;nw<=200;nw++)
						{
								if(nh==h && nw==w) continue;
								int tmp_sd = nh*nh+nw*nw;
								if(tmp_sd == ans_sd && nh < ans_h)
								{
										ans_h = nh;
										ans_w = nw;
								}
						}
				}

				cout << ans_h << " " << ans_w << endl;
		}
}


Measured memory_bytes: 3076
def solve(string):
    n, q, *abpx = map(int, string.split())
    check = [True] * (n + 1)
    t = [[] for i in range(n + 1)]
    c = [0] * (n + 1)
    d = [1]
    for a, b in zip(*[iter(abpx[:2 * n - 2])] * 2):
        t[a].append(b)
        t[b].append(a)
    for p, x in zip(*[iter(abpx[2 * n - 2:])] * 2):
        c[p] += x
    while len(d) > 0:
        curr = d.pop()
        check[curr] = False
        next_ = [i for i in t[curr] if check[i]]
        for n_ in next_:
            c[n_] += c[curr]
        d.extend(next_)
    return " ".join([str(_c) for _c in c[1:]])


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n + m - 1)])))


Measured memory_bytes: 99888
using System;

namespace atcoderA
{
    class MainClass
    {
        public static void Main(string[] args)
        {
            int[] input = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            int N = input[0];
            int i = input[1];
            Console.WriteLine(N - i + 1);
        }
    }
}

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

int main() {
	int W,H,x,y,r;
	cin >> W >> H >> x >> y >> r;
	if (x>=r && x<=W-r && y>=r && y<=H-r) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

using namespace std;

typedef long long ll;

// Defines and one-liners
#define INF 0x3f3f3f3f
#define LLINF 0x3f3f3f3f3f3f3f3f
template <typename T> inline T& back(vector<T> &vec) { return *(vec.end() - 1); }
template <typename T> inline void pop(vector<T> &vec) { return vec.erase(vec.end() - 1); }

// Scan, Debug, and other nonsense
template <typename T> ostream& operator<<(ostream& out,vector<T> iter){out<<"[";for(auto t:iter){out<<t<<", ";}out<<"]";return out;}
template <typename T> void printArray(ostream& out,T* arr,int sz){out<<"[";for(int i=0;i<sz;i++){out<<arr[i]<<", "; } out<<"]";}
#define OUT_OPERATOR(type, propa, propb) ostream& operator<<(ostream& out,type obj){out<<"("<<#propa<<"="<<obj. propa<<", "<<#propb<<"="<<obj. propb<<")";return out;}

void scan(){}
template<typename F, typename... R> void scan(F &f,R&... r){cin>>f;scan(r...);}
int di_; string dnms_, co_ = ",";
void debug_(){cout<<endl;}
template<typename F, typename... R> void debug_(F f,R... r){while(dnms_[di_] != ',')cout<<dnms_[di_++];di_++;cout<<": "<<f<<",";debug_(r...);}
#define debug(...) dnms_=#__VA_ARGS__+co_,di_=0,debug_(__VA_ARGS__)

ll a, b;

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

    scan(a, b);

    if (abs(b - a) % 2 == 0)
        cout << ((a + b) >> 1) << "\n";
    else
        cout << "IMPOSSIBLE\n";

    return 0;
}

Measured memory_bytes: 256
n = int(input())
v = [float(i) for i in input().split()]
v.sort()

def f(v):
    
    if len(v) == 1:
        print("".join(map(str,v)))
    else:
        v.sort()
        a = v.pop(0)
        b = v.pop(0)
        v.append(((a+b)/2))
        f(v)

f(v)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
int main() {
  long long N,answer=0,i;
  cin >> N;
  vector<long> A(N);
  for (i=0;i<N;i++){
    cin >> A[i];
  }
  long long B=0,C;
  for(i=1;i<N;i++){
    B+=A[i];
  }
  C=B%1000000007;
  answer+=C*A[0];
  answer=answer%1000000007;
  
  for (i=1;i<N-1;i++){
      B-=A[i];
    C=B%1000000007;
    answer+=C*A[i];
    answer=answer%1000000007;
  }
  
  cout<<answer;
  }

Measured memory_bytes: 4844
#include<stdio.h>
int main(void){
	int a[5];
	int i;
	for(i=0;i<5;i++){
		scanf("%d",&a[i]);
		if(a[i]<40)a[i]=40;
	}
	printf("%d\n",(a[0]+a[1]+a[2]+a[3]+a[4])/5);
	return 0;
	
	
}

Measured memory_bytes: 600
process.stdin.resume();
process.stdin.setEncoding('ascii');

var input_stdin = "";
var input_stdin_array = "";
var input_currentline = 0;

process.stdin.on('data', function (data) {
    input_stdin += data;
});

process.on('SIGINT', function(){
    input_stdin_array = input_stdin.split("\n");
    main();
    process.exit();
});

process.stdin.on('end', function () {
    input_stdin_array = input_stdin.split("\n");
    main();    
});

function readLine() {
    return input_stdin_array[input_currentline++];
}

/////////////// ignore above this line ////////////////////

function main() {
	var s = readLine().split(" ");
	console.log("A"+s[1][0]+"C");
}


Measured memory_bytes: 22468
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

N = int(input())
A = list(sorted(map(int, input().split())))
B = list(sorted(map(int, input().split())))
C = list(sorted(map(int, input().split())))

base = [0] * N
for i, b in enumerate(B):
    left = -1
    right = N
    while (right - left) > 1:
        mid = left + (right - left) // 2
        if C[mid] > b:
            right = mid
        else:
            left = mid
    base[i] = N - right

acc = [0] * (N + 1)
for i in range(1, N + 1):
    acc[i] = acc[i - 1] + base[i - 1]

ans = 0
for i, a in enumerate(A):
    left = -1
    right = N
    while right - left > 1:
        mid = left + (right - left) // 2
        if B[mid] > a:
            right = mid
        else:
            left = mid
    ans += acc[N] - acc[right]
print(ans)

Measured memory_bytes: 31180
from collections import Counter
from collections import deque
from functools import reduce
from pprint import pprint
import bisect
import copy
import fractions
import itertools
import math
import queue
import random
import sys
import time
sys.setrecursionlimit(10**7)
INF = 10 ** 18
MOD = 10 ** 9 + 7
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def MI(): return map(int, sys.stdin.readline().split())
def II(): return int(sys.stdin.readline())
def IS(): return input()
def C(x): return Counter(x)
def GCD_LIST(numbers): return reduce(fractions.gcd, numbers)
def LCM_LIST(numbers): return reduce(LCM, numbers)
def LCM(m, n): return (m * n // fractions.gcd(m, n))


s = IS()
ans = -INF
for i in range(2, len(s), 2):
    if s[:i//2] == s[i//2:i]:
        ans = max(ans, i)
print(ans)



Measured memory_bytes: 68972
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int N;
  cin >>N;
  vector<int> A(N);
  vector<int> B(N);
  vector<int> C(N-1);
  int ans=0;
  for(int i=0;i<N;i++){
    cin >>A.at(i);
  }
   for(int i=0;i<N;i++){
    cin >>B.at(i);
  }
   for(int i=0;i<N-1;i++){
    cin >>C.at(i);
  }
  for(int i=0;i<N;i++){
    ans+=B.at(i);
    if(i!=0){
    if(A.at(i)==A.at(i-1)+1){
      //cout <<A.at(i)<<" "<<A.at(i-1)+1<<endl;
      ans+=C.at(A.at(i-1)-1);}
    }
    }
  cout <<ans<<endl;
}

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

using namespace std;


#define int long long
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)


using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

signed main() {
    int n, m, c = 0;
    cin >> n >> m;
    rep(i, m) {
        int x;
        cin >> x;
        c |= 1 << x;
    }
    rep(b, (1 << n)) {
        if ((b | c) != c) continue;
        cout << b << ":";
        rep(i, n) {
            if (b & (1 << i)) {
                cout << " " << i;
            }
        }
        cout << endl;
    }
    cout << flush;
    return 0;
}


Measured memory_bytes: 3100
#include <iostream>
#include <sstream>
#include <string>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <cassert>

using namespace std;

#define FOR(i,k,n) for(int i=(k); i<(int)(n); ++i)
#define REP(i,n) FOR(i,0,n)
#define FORIT(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)

template<class T> void debug(T begin, T end){ for(T i = begin; i != end; ++i) cerr<<*i<<" "; cerr<<endl; }
inline bool valid(int x, int y, int W, int H){ return (x >= 0 && y >= 0 && x < W && y < H); }

typedef long long ll;
const int INF = 100000000;
const double EPS = 1e-8;
const int MOD = 1000000007;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
class ParseError {};
struct Result{
  int p;
  vector<int> value;
  Result() {}
  Result(int p, vector<int> v) : p(p), value(v) {}
};
map<string, vector<int> > variables;
Result formula(const string& s, int p);
Result term(const string& s, int p);
Result factor(const string& s, int p);
Result formula(const string& s, int p){
  Result r = term(s, p);
  while(s[r.p] == '+' || s[r.p] == '-'){
    Result r_ = term(s, r.p + 1);
    if(r.value != r_.value) throw ParseError();
    r.p = r_.p;
  }
  return r;
}
Result term(const string& s, int p){
  Result r = factor(s, p);
  while(s[r.p] == '*' || s[r.p] == '/'){
    Result r_ = factor(s, r.p + 1);
    REP(i, r_.value.size()){
      r.value[i] += (s[r.p] == '*' ? +1 : -1) * r_.value[i];
    }
    r.p = r_.p;
  }
  return r;
}
Result factor(const string& s, int p){
  if(s[p] == '('){
    Result r = formula(s, p + 1);
    assert(s[r.p] == ')');
    r.p++;
    return r;
  }else{
    assert(isalpha(s[p]));
    string name;
    while(isalpha(s[p])){
      name += s[p++];
    }
    assert(variables.count(name));
    vector<int> v = variables[name];
    return Result(p, v);
  }
}

int main(){
  int N, M, P;
  while(cin >> N >> M >> P && N){
    variables.clear();
    map<string, vector<int> > derived;
    map< vector<int>, string > derived_inv;
    REP(i, M){
      string name;
      vector<int> dim(N);
      cin >> name;
      REP(i, N) cin >> dim[i];
      derived[name] = dim;
      derived_inv[dim] = name;
    }
    string expr;
    cin >> expr;
    REP(i, P){
      string name;
      string deriv;
      cin >> name >> deriv;
      variables[name] = derived[deriv];
    }
    try{
      Result result = formula(expr, 0);
      if(derived_inv.count(result.value)){
        cout << derived_inv[result.value] << endl;
      }else{
        cout << "undefined" << endl;
      }
    }catch(ParseError e){
      cout << "error" << endl;
    }
  }
  return 0;
}

Measured memory_bytes: 1312
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
class modint {
  public:
    using ll = long long;
    ll num;
    static const ll MOD = 1e9+7;
    static vector<modint> factorial;
    modint(): num(0) {};
    modint(ll _n): num((_n + MOD) % MOD) {}
    modint(const modint &r): num(r.num) {}
    operator ll() const { return (num+MOD)%MOD; }
    friend istream& operator>>(istream& is, modint &r){
        ll num_;
        is >> num_;
        r = num_;
        return is;
    }
    modint operator+(const modint &r) const { return modint(num + r.num); }
    modint operator-(const modint &r) const { return modint(num - r.num); }
    modint operator*(const modint &r) const { return modint(num * r.num); }
    template<typename T>
    modint operator^(const T &r) const {
        if(r == 0) return 1;
        return (((*this)*(*this)) ^ (r/2)) * modint(r&1 ? num : 1);
    }
    modint operator/(const modint &r) const { return num * (r^(MOD-2)); }
    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; }
    modint operator/=(const modint &r) { return *this = *this / r; }
    template<typename T>
    modint operator^=(const T &r) { return *this = *this ^ r; }
    static modint fact(int n){
        if((int)factorial.size() <= n) factorial.resize(n+1);
        if(factorial[n]) return factorial[n];
        if(n == 0) return 1;
        return factorial[n] = modint(n) * fact(n-1);
    }
    static modint C(ll n,ll r){
        return n >= r ? fact(n)/(fact(n-r)*fact(r)) : modint(0);
    }
};
vector<modint> modint::factorial;
#define fact(n) modint::fact(n)
#define C(n,r) modint::C(n,r)
#define H(a,b) C(a+b, a)

int main() {
    int X,Y;
    cin>>X>>Y;
    int x = 2 * Y - X;
    int y = 2 * X - Y;
    ll ans;
    if(x >= 0 && y >= 0 && x % 3 == 0 && y % 3 ==0){
        x /= 3;
        y /= 3;
        ans = C(x + y, x);
    }
    else{
        ans = 0;
    }
    cout<<ans<<endl;
}

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

int main(){
    int a=0;
    string S;
    cin >> S;
    int size = S.size();

    if(size %2 == 0){
        for(int i=0; i<size; i++){
            if(S[i] != S[size-i-1]){
                S[i] = S[size-i-1];
                a++;
            }
        }
    } 
    if(size %2 ==1){
        for(int i=0; i<size; i++){
            if(i == size / 2){
                i++;
                break;
            }
            if(S[i] != S[size-i-1]){
                S[i] = S[size-i-1];
                a++;
            }
        }
    }

        cout << a << endl;
}

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

using namespace std; 

int main() 
{
	vector<int> v(3); 	
	cin >> v[0] >> v[1] >> v[2]; 
	sort(v.begin(), v.end()); 
	cout << v[0] + v[1] << "\n";
	
	return 0; 
}


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

vector< long long > vp[230000];
int main()
{
	ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
  	long long n , m;
  	cin >> n >> m;
  	for(int i = 0 ; i < n ; i++){
		long long x , y;
      	cin >> x >> y;
       	vp[x].push_back(y);
    }
  	long long ans = 0;
  	priority_queue< long long > pq;
  	for(int i = 1 ; i <= m ; i++){
  		for(auto x : vp[i]){
  			pq.push(x);
  		}
  		if(!pq.empty()){
  			ans += pq.top();
  			pq.pop();
  		}

  	}
  	
  	cout << ans << endl;
 	return 0; 
}

Measured memory_bytes: 8704
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
using Graph = vector<vector<int>>;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    int N,K;
    cin>>N>>K;
    vector<int> h(N);
    rep(i,N) cin>>h[i];
    int ans=0;
    rep(i,N){
        if(h[i]>=K) ans++;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 640
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <string>
#include <vector>
#include <limits>
#include <algorithm>
#include <utility>
#include <sstream>
#include <numeric>
#include <iterator>
#include <map>

using namespace std;

#define repd(i,a,b) for (int i=(a);i<(b);++i)
#define rep(i,n) repd(i,0,n)
typedef long long ll;
typedef pair<int, int> P;

int main(int argc, const char * argv[]) {
  int n;
  cin >> n;
  map<string, bool> mp;
  int ans = 0;
  rep(i, n){
    string s;
    cin >> s;
    // cout << mp[s] << endl;
    if(!mp[s]){
      ans++;
      mp[s] = true;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 18792
#include <bits/stdc++.h>
 
#define int         long long
#define uint        unsigned int
#define ld          long double
#define showoff     ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define pb          push_back
#define pii         pair<int,int>
#define FOR(i,a,b)  for(int i=a;i<b;++i)
#define RFOR(i,a,b) for(int i=a;i>b;--i)
#define f           first
#define se          second
#define maxn        1000005
#define all(v)      v.begin(),v.end()
#define sz(x)       (int)x.size()
#define mod         1000000007
#define pqueue      priority_queue<int>
#define pdqueue     priority_queue< int,vector<int> ,greater< int >>
 
using namespace std;
 
 
//mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
 
int power(int a,int n)
{
    a %= mod;
    if(n == 1)return a;
    if(n == 0)return 1;
    if(n%2)return (a*(power((a*a)%mod,n/2)%mod))%mod;
    return power((a*a)%mod,n/2)%mod;
}
const int inf = (int) 1e18;
 
int inverse(int x){
    return power(x,mod-2)%mod;//little fermat....
}   

signed main()
{
    showoff;
   	int n;
   	cin >> n;
   	vector<pii>v(n+5);
   	FOR(i,1,n+1)cin >> v[i].f,v[i].se = i;
   	sort(v.begin()+1,v.begin()+n+1,greater<pii>());
   	int dp[n+5][n+5];
   	memset(dp,0,sizeof dp);
   	RFOR(i,n,0){
   		FOR(len,0,i){
   			int last_occ = i-len-1;
   			dp[i][len] = max(abs(len+1-v[i].se)*v[i].f+dp[i+1][len+1],abs(n-last_occ-v[i].se)*v[i].f+dp[i+1][len]);
   		}
   	}
   	cout << dp[1][0];
    return 0;
}
//*->for large size of matrix take int not long long if possible......
//*->always take maximum as inf for safer side ... 

Measured memory_bytes: 35064
#include <algorithm>
#include <iostream>
#include <vector>

int main() {
  int N;
  std::cin >> N;
  std::vector<int> Ln(N);
  for (auto &L : Ln) {
    std::cin >> L;
  }
  std::sort(Ln.begin(), Ln.end());

  uint64_t count = 0;

  for (size_t i = 0; i < N; ++i) {
    for (size_t j = i + 1; j < N; ++j) {
      auto cond1 = Ln[i] + Ln[j];
      auto cond2 = Ln[i] - Ln[j];
      auto cond3 = Ln[j] - Ln[i];

      auto pos1 =
          std::lower_bound(Ln.begin() + j, Ln.end(), cond1) - Ln.begin() - 1;
      auto pos2 =
          std::upper_bound(Ln.begin() + j, Ln.end(), cond2) - Ln.begin();
      auto pos3 =
          std::upper_bound(Ln.begin() + j, Ln.end(), cond3) - Ln.begin();

      // std::cout << Ln[i] << "," << Ln[j] << ":" << pos1 << "," << pos2 << ","
      // << pos3 << std::endl;

      count += std::max(0l, pos1 - std::max(pos2, pos3));
    }
  }

  std::cout << count << std::endl;

  return 0;
}

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

Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
#define INF (1<<30)
#define INFLL (1ll<<60)
typedef pair<int, int> P;
#define MOD (1000000007ll)
#define l_ength size
#define EPS (1e-10)

int main(void){
	ll n,a,b,c,d,i,j,l,r;
	cin >> n >> a >> b >> c >> d;
	for(i=0; i<n; ++i){
		j = n - i - 1;
		l = c*i-d*j;
		r = d*i-c*j;
		if(l<=b-a&&b-a<=r){
			cout << "YES" << endl;
			return 0;
		}
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    ll D;
    cin >> D;
    vector<ll> c(27);
    vector<vector<ll>> s(D+1, vector<ll>(27));
    for (int i = 1; i <= 26; ++i) cin >> c[i];
    for (int i = 1; i <= D; ++i)
    {
        for (int j = 1; j <= 26; ++j)
        {
            cin >> s[i][j];
        }
    }
    vector<ll> t(D+1);
    for (int i = 1; i <= D; ++i) cin >> t[i];
    vector<ll> res(D+1, 0);
    vector<ll> last(27, 0);
    for (int d = 1; d <= D; ++d)
    {
        res[d] += res[d - 1] + s[d][t[d]];
        last[t[d]] = d;
        for (int k = 1; k <= 26; ++k)
        {
            res[d] -= c[k] * (d - last[k]);
        }
    }
    for (int d = 1; d <= D; ++d)
    {
        cout << res[d] << endl;
    }
    return 0;
}


Measured memory_bytes: 3640
from collections import Counter
S = input()
C = Counter(S[2:-1])
patience = 1
for s in S[1:]:
    if s == "C" and patience:
        patience -= 1
        continue
    if s.isupper():
        print("WA")
        exit()

if S[0] == "A" and C["C"] == 1:
    print("AC")
else:
    print("WA")

Measured memory_bytes: 3316
// JavaScript source code
"use strict";

let myFunc = (input) => {
    input = input.split("\n");
    let N = parseInt(input[0]);
    let A = parseInt(input[1]);
    for(let i = 0; i <= A; i++){
        if(i > N) break;
        if((N - i) % 500 === 0){
            console.log("Yes");
            return 0;
        }
    }
    console.log("No");
};

myFunc(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 29600
#include <stdio.h>
int main(){
    int a,b,c,m;
    
    scanf("%d %d %d",&a,&b,&c);
    m = 0;
    do{
      if(c%a==0)m++;
      a++;
    }while(a <= b);
    
    printf("%d\n",m);

    return 0;
}

Measured memory_bytes: 596
#include <vector>
#include <stack>
#include <queue>
#include <list>
#include <bitset>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <numeric>
#include <iostream>
#include <iomanip>
#include <string>
#include <chrono>
#include <random>
#include <cmath>
#include <cassert>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <sstream>

using namespace std;



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

    int n, m, K;
    cin >> n >> m >> K;

    if (m == 1) {
        if (K == 1) {
            cout << 1 << '\n';
        } else {
            cout << 0 << '\n';
        }
        return 0;
    }

    const long long MOD = 1000000007;

    int M = 1 << (m - 1);

    vector<vector<long long>> dp(M, vector<long long>(m, 0));
    dp[0][0] = 1;
    auto ndp = dp;

    for (int i = 0; i < n; ++i) {
        for (auto& V : ndp) {
            fill(V.begin(), V.end(), 0);
        }

        for (int j = 0; j < M; ++j) {
            for (int k = 0; k < m; ++k) {
                if (dp[j][k] == 0) {
                    continue;
                }

                for (int nj = 0; nj < M; ++nj) {
                    if (nj & (nj >> 1)) {
                        continue;
                    }
                    int nk = -1;
                    for (int a = -1; a < 1; ++a) {
                        int x = k + a;
                        if (x >= 0 && (nj & (1 << x))) {
                            assert(nk == -1);
                            nk = a < 0 ? k - 1 : k + 1;
                        }
                    }
                    if (nk == -1) {
                        nk = k;
                    }

                    (ndp[nj][nk] += dp[j][k]) %= MOD;
                }
            }
        }
        swap(ndp, dp);
    }

    long long res = 0;
    for (int i = 0; i < M; ++i) {
        res += dp[i][K - 1];
    }
    res %= MOD;
    cout << res << '\n';

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define LLINF 9223372036854775807
#define MOD ll(1e9+7)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cerr<<#x<<": "<<x<<endl

int main(){
    char b;
    cin >> b;
    map<char, char> ans;
    ans['A']='T';
    ans['C']='G';
    ans['G']='C';
    ans['T']='A';
    cout << ans[b] << endl;

    return 0;
}


Measured memory_bytes: 256
//------------------------------------------
// C++ templete 
//------------------------------------------
#include <bits/stdc++.h>
#define int long long
using namespace std;

//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef vector<PII> VP;

//REPEAT
//------------------------------------------
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

//container util
//------------------------------------------
#define pb push_back
#define paired make_pair
#define ALL(a) (a).begin(),(a).end()
#define PRINT(V) for (auto v : (V)) cout << v << " "
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())

//constant
//------------------------------------------
const int MOD = 1000000007;
const int INF = 1061109567;
const double EPS = 1e-10;
const double PI  = acos(-1.0);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

//math
//------------------------------------------
int QP(int a,int b){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int QP(int a,int b,int MOD){int ans=1;do{if(b&1)ans=1ll*ans*a%MOD;a=1ll*a*a%MOD;}while(b>>=1);return ans;}
int GCD(int a,int b){return b?GCD(b,a%b):a;}

//debug
//------------------------------------------
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

//main
//------------------------------------------
signed main(){
    // 入力
    int a, b, c;
    cin >> a >> b >> c;
    if ((a==b&&a!=c)||(a==c&&a!=b)||(b==c&&a!=b)){
        cout << "Yes";
    }
    else{
        cout << "No";
    }
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<math.h>
#include<string>
#include<string.h>
#include<stack>
#include<queue>
#include<vector>
#include<utility>
#include<set>
#include<map>
#include<stdlib.h>
#include<iomanip>

using namespace std;

#define ll long long
#define ld long double
#define EPS 0.0000000001
#define INF 1e9
#define MOD 1000000007
#define rep(i,n) for(i=0;i<n;i++)
#define loop(i,a,n) for(i=a;i<n;i++)
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)

typedef vector<int> vi;
typedef pair<int,int> pii;

int main(void) {
  int i,j;
  string a,b;
  cin>>a>>b;
  if(a.size()<b.size())
    cout<<"LESS"<<endl;
  else if(a.size()>b.size())
    cout<<"GREATER"<<endl;
  else if(a<b)
    cout<<"LESS"<<endl;
  else if(b<a)
    cout<<"GREATER"<<endl;
   else
    cout<<"EQUAL"<<endl;
}


Measured memory_bytes: 384
#include<iostream>
#include<cmath>
#include<cstdlib>
#include<string>
#include<cstring>
#include<algorithm>
#include<vector>

using namespace std;
typedef long long ll;

int main() {
   int N;
   cin >> N;
   ll A[N];
   ll tmp;
   for (int i = 0; i < N; i++) {
      cin >> tmp;
      A[i] = (tmp - i - 1) * 10;
   }
   sort(A, A + N);
   ll ans;
   if (N % 2 == 0) ans = (A[N / 2 - 1] + A[N / 2] ) / 2.;
   else ans = A[(N - 1) / 2];
   
   ll sum = 0;
   for (int i = 0; i < N; i++) {
      sum += abs(A[i] - ans);
   }

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


Measured memory_bytes: 1792
#include <iostream>
#include <algorithm>
#include <functional>
#include <string>
#include <numeric>
#include <vector>
using namespace std;
#define MAXSIZE 200
#define MAXL 100
#define NUM 1000000007
typedef long long int lli;

int main(){
    int n;
    cin >> n;
    vector<int> v;
    for(int i = 0; i < n; i++){
        int q;
        cin >> q;
        v.push_back(q);
    }

    int ans = 0;
    for(int i = 0; i < n; i++){
        int tmp = v[i];
        if(i == n - 1){
            if(i + 1 == v[i]){
                v[i] = v[i - 1];
                v[i - 1] = tmp;
                ans++;
            }
        }else{
            if(i + 1 == v[i]){
                v[i] = v[i + 1];
                v[i + 1] = tmp;
                ans++;
            }
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1020
#include <iostream>
#include <sstream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <climits>
#include <iomanip>
#include <bitset>
#include <algorithm>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <list>
#include <map>

using namespace std;

typedef pair <int, int> ii;

const int N = 22;

int n, m;
int dist[N][N];
char mat[N][N];

int xx[4] = {-1, +1, +0, +0};
int yy[4] = {+0, +0, -1, +1};

bool in(int x, int y) {
  return (x >= 0 && y >= 0 && x < n && y < m);
}

int go(int sx, int sy) {
  bool used[N][N] = {};
  int here = 0;
  queue <ii> q;
  q.push({sx, sy});
  used[sx][sy] = 1;
  dist[sx][sy] = 0;
  while (!q.empty()) {
    int x = q.front().first, y = q.front().second; q.pop();
    used[x][y] = 1;
    //cout << sx << " " << sy << " " << x << " " << y << " " << ans << endl;
    for (int i = 0; i < 4; i++) {
      int nx = x + xx[i];
      int ny = y + yy[i];
      if (in(nx, ny) && !used[nx][ny] && mat[nx][ny] != '#') {
        used[nx][ny] = 1;
        dist[nx][ny] = dist[x][y] + 1;
        q.push({nx, ny});
        here = max(here, dist[nx][ny]);
      }
    }
  }
  here = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      here = max(here, dist[i][j]);
    }
  }
  return here;
}

int main() {
  scanf("%d %d", &n, &m);
  for (int i = 0; i < n; i++) {
    scanf(" %s", mat[i]);
  }
  int ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < m; j++) {
      if (mat[i][j] == '#') continue;
      ans = max(ans, go(i, j));
    }
  }
  printf("%d\n", ans);
  return 0;
}


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

const double EPS = 1e-10;
const ll INF = 100000000;
const ll MOD = 1000000007;

constexpr int MAX_N = 100000;

struct UF{
	int par[MAX_N];
	int rank[MAX_N];
	int si[MAX_N];

	void init(int n){
		rep(i,n){
			par[i] = i;
			rank[i] = 0;
			si[i] = 1;
		}
	}

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

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

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

int n, m;

int main(){
    cin >> n >> m;
    uf.init(n);
    rep(i,m) {
        int a, b;
        cin >> a >> b;
        a--; b--;
        uf.unite(a,b);
    }
    ll x = uf.si[uf.find(0)], y = uf.si[uf.find(1)];
    if (x > y) swap(x, y);
    y = n-x;
    ll ans = x*(x-1)/2+y*(y-1)/2; 
    cout << ans - m << endl;
}
































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

using namespace std;


int main()
{
	uint64_t H, N, A, B;
	cin >> H >> N;
	vector<uint64_t> dp(H + 1, INT_MAX);
	dp[0] = 0;
	for (int i = 0; i < N; ++i)
	{
		cin >> A >> B;
		for (int j = 0; j <= H; ++j)
			if (dp[j] != INT_MAX)
				dp[min(j + A, H)] = min(dp[min(j + A, H)], dp[j] + B);
	}
	cout << dp[H];
	return 0;
}


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

int main()
{
    int n,m;
    cin>>n;
    vector<int>a(n);
    REP(i,n)cin>>a[i];
    cin>>m;
    vector<int>b(m);
    REP(i,m)cin>>b[i];
    if(includes(a.begin(),a.end(),b.begin(),b.end())==true)cout<<1<<endl;
    else cout<<0<<endl;
}


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

int main(void){
	int a,b,c;
	cin>> a>>b>>c;
	int x=abs(a-b),y=abs(a-c),z=abs(b-c);
	cout<<x+y+z-max({x,y,z});

	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
    char name[100];
    int t;
} P;

P Q[LEN];
int head , tail, n;

void enqueue(P x){
    Q[tail] = x;
    tail = (tail +1) % LEN;
}

P dequeue(){
    P x =Q[head];
    head = (head + 1) % LEN;
    return x;
}

int min(int a, int b){ return a<b ? a: b;}

int main(){
    int elaps = 0,c;
    int i,q;
    P u;
    scanf("%d %d", &n, &q);
    
    for(int i=1; i<=n; i++){
        scanf("%s", Q[i].name);
        scanf("%d", &Q[i].t);
        
    }
    head =1; tail=n+1;
    
    while(head != tail){
        u = dequeue();
        c = min(q,u.t);
        u.t-=c;
        elaps += c;
        if(u.t > 0)enqueue(u);
        else{
            printf("%s %d\n", u.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 12760
#include<bits/stdc++.h> //ABC 167_b
#define ll long long
using namespace std;
ll a,b,c,k;
int main(){
	cin>>a>>b>>c>>k;
	if(k<=a) cout<<k;
	else if(k<=a+b) cout<<a;
	else cout<<a-(k-a-b);	
	return 0;
}

Measured memory_bytes: 3600
#include "bits/stdc++.h"
using namespace std;
#define repi(i,a,b) for(int i=(a), i##_len=(b); i<i##_len; ++i)
#define rep(i,n) repi(i,0,n)
#define all(x) (x).begin(),(x).end()
#define tsort(v) sort((v).begin(), (v).end())
#define trev(v) reverse((v).begin(), (v).end())
#define siz(v) ((int)(v).size())
#define ers(v, n) (v).erase((v).begin() + n)
#define el "\n"
#define co(x) cout<<(x)<<el
#define coc(c, a, b) if(c)co((a));else co((b))
#define YES(c) coc(c,"YES", "NO")
#define Yes(c) coc(c,"Yes", "No")
#define yes(c) coc(c,"yes", "no")
#ifdef tqktmp_1
#define gc() getchar(); getchar()
#else
#define gc() 1
#endif
typedef long long lint;

template<class T>bool chmax(T &a, const T &b) { if (a<b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a = b; return 1; } return 0; }

bool f(int n) {
	if ((n / 10000 == n % 10) && ((n / 1000) % 10 == (n % 100) / 10)) return 1;
	return 0;
}

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

	lint a, b, c, d;
	cin >> a >> b >> c >> d;
	if (a + b > c + d)co("Left");
	else if (a + b == c + d)co("Balanced");
	else co("Right");
	gc();
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	static int H_1;
	static int H_2;
	static int M_1;
	static int M_2;
	static int K;
	static int x;
	public static void main(String[]args) {
		Scanner sc=new Scanner(System.in);
		H_1=sc.nextInt()*60;
		M_1=sc.nextInt();
		H_2=sc.nextInt()*60;
		M_2=sc.nextInt();
		K=sc.nextInt();
		x=H_2+M_2-H_1-M_1-K;
		System.out.println(x);
	}
}

Measured memory_bytes: 35688
// depends on: -

/*
usage:

tools::pow2(5) => 25
*/

namespace tools {
  template <typename T> constexpr T pow2(const T x) {
    return x * x;
  }
}
// depends on: -

/*
usage:

tools::floor(5, 3) // => 1
tools::ceil(5, 3) // => 2
*/

namespace tools {
  template <typename T> constexpr T floor(T lhs, T rhs);
  template <typename T> constexpr T ceil(T lhs, T rhs);

  template <typename T> constexpr T floor(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        lhs / rhs :
      lhs < 0 && rhs >= 0 ?
        -ceil<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -ceil<T>(lhs, -rhs) :
        floor<T>(-lhs, -rhs);
  }

  template <typename T> constexpr T ceil(const T lhs, const T rhs) {
    return
      lhs >= 0 && rhs >= 0 ?
        (lhs - 1 + rhs) / rhs :
      lhs < 0 && rhs >= 0 ?
        -floor<T>(-lhs, rhs) :
      lhs >= 0 && rhs < 0 ?
        -floor<T>(lhs, -rhs) :
        ceil<T>(-lhs, -rhs);
  }
}
// depends on: -

/*
a == tools:quo(a, b) * b + tools::mod(a, b)
0 <= tools::mod(a, b) < std::abs(b)
*/

#include <utility>

namespace tools {
  template <typename T> constexpr T quo(const T lhs, const T rhs) {
    return lhs > 0 ? lhs / rhs : rhs > 0 ? -((-lhs - 1 + rhs) / rhs) : (-lhs - 1 + -rhs) / -rhs;
  }
  template <typename T> constexpr T mod(const T lhs, const T rhs) {
    return lhs - quo(lhs, rhs) * rhs;
  }
}

#include <cstdlib>

namespace tools {
  template <typename T> constexpr T round(const T lhs, const T rhs) {
    return std::abs(rhs) % 2 == 0
      ? mod(lhs, rhs) == std::abs(rhs) / 2
        ? floor(lhs, rhs) % 2 == 0
          ? floor(lhs, rhs)
          : ceil(lhs, rhs)
        : mod(lhs, rhs) < std::abs(rhs) / 2
          ? floor(lhs, rhs)
          : ceil(lhs, rhs)
      : mod(lhs, rhs) <= std::abs(rhs) / 2
        ? floor(lhs, rhs)
        : ceil(lhs, rhs);
  }
}

#include <iostream>
#include <cstdint>
#include <numeric>
#include <vector>

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

  const std::int_fast32_t sum = std::accumulate(a.begin(), a.end(), 0);
  const std::int_fast32_t target = tools::round(sum, n);
  std::cout << std::accumulate(a.begin(), a.end(), 0, [target](const std::int_fast32_t s, const std::int_fast32_t a_i) {
    return s + tools::pow2(a_i - target);
  }) << std::endl;
  return 0;
}

Measured memory_bytes: 256
//#include <stdio.h>
#include <math.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <queue>
#include <map>
#include <utility>
#include <iomanip>

using namespace std;

#define ll long long
vector<vector<ll>> dp;
vector<ll> w, v;
ll N, W;

ll res(ll i, ll j)
{
    if (i >= N)
    {
        return 0;
    }

    if (dp.at(i).at(j) != -1)
    {
        return dp.at(i).at(j);
    }
    ll ret;
    if (w.at(i) + j > W)
    {
        ret = res(i + 1, j);
    }
    else
    {
        ret = max(res(i + 1, j), res(i + 1, j + w.at(i)) + v.at(i));
    }

    return dp.at(i).at(j) = ret;
}

void solve()
{
    cin >> N >> W;
    dp = vector<vector<ll>>(N, vector<ll>(100001, -1));
    w = vector<ll>(N);
    v = vector<ll>(N);
    for (ll i = 0; i < N; i++)
    {
        cin >> w.at(i) >> v.at(i);
    }

    cout << res(0, 0) << endl;

    return;
}

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


Measured memory_bytes: 79488
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#define _USE_MATH_DEFINES
#include <math.h>
#include <iomanip>
#include <stdio.h>
#include <numeric>
#include <cmath>
#include <limits>
#include <bitset> 
#include <iterator> 
#include <map>
#include <queue>
#include <set>
#define rep(i,n) for(ll i=0;i<(n); ++i)
#define log(i,n) log(n)/log(i);
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
const long long INF = 1LL << 60;
typedef long long ll;
ll MOD = 1000000007;
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll n, k, d=INF;
	cin >> n >> k;
	vector<ll>h(n);
	rep(i, n)cin >> h[i];
	sort(h.begin(),h.end());
	for (ll i = 0; i <= n-k; i++) {
		d = min(d, abs(h[i] - h[i + k - 1]));
	}
	cout << d << endl;
}


Measured memory_bytes: 1024
#!/usr/bin/env python3
 
from itertools import combinations
 
 
# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    N, M, X = map(int, input().split())
    CA = [[] for _ in range(N)]
    for n in range(N):
        CA[n] = list(map(int, input().split()))
 
    COSTS = []
    for n in range(N):
        for c in combinations(CA, n+1):
            SUM = [0 for _ in range(M)]
            COST = 0
            for ca in c:
                COST += ca[0]
                for m in range(M):
                    SUM[m] += ca[m+1]
            if all(list(map(lambda x: x >= X, SUM))):
                COSTS.append(COST)
    if COSTS:
        print(min(COSTS))
        return
    print(-1)
 
if __name__ == '__main__':
    main()

Measured memory_bytes: 9004
import java.util.Scanner;
public class Main{
	static Scanner sc=new Scanner(System.in);
	public static void main(String[] args) {
		int a[]=new int [6];
		a[0]=1;a[1]=5;a[2]=10;
		a[3]=50;
			a[4]=100;a[5]=500;
			int ans = 0;
			for(int i=0;i<a.length;i++){
				int temp=sc.nextInt();
				ans+=temp*a[i];
			}
			if(ans>=1000)System.out.println(1);
			else System.out.println(0);
		
	}
}

Measured memory_bytes: 17352
"use strict";
function main(input) {
    const line = input.split("\n");
    const N = parseInt(line[0]);
    const A = line[1].split(" ").map(Number);
    console.log(1 / A.reduce((pre, cur) => pre + 1 / cur, 0));
    return;
}
main(require('fs').readFileSync('/dev/stdin', 'utf8'));

Measured memory_bytes: 29236
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>

int main()
{
    int n,d;
    scanf("%d %d",&n,&d);
    int x[n][d];
    int i,j,k,ce,fl,ans=0;
    double dis,sum;
    for(i=0;i<n;i++){
        for(j=0;j<d;j++){
            scanf("%d",&(x[i][j]));
        }
    }

    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
            sum=0;
            for(k=0;k<d;k++){
                sum += (x[i][k]-x[j][k]) * (x[i][k]-x[j][k]);
            }
            dis = sqrt((double)sum);
            
            ce = ceil(dis);
            fl = floor(dis);

            if(ce == fl){
                ans++;
            }
        }
    }

    printf("%d\n",ans);
    

    return 0;
}

Measured memory_bytes: 128
/**
    AUTHOR:JUNSH
    TIME:19/5/19
**/
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define rev(i,a,b) for(int i=(a);i>=(b);--i)
using namespace std;
typedef long long ll;
inline int read(){
    int f=1,x=0;char ch=getchar();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=getchar();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=getchar();}
    return f*x;
}
const int inf=0x3f3f3f3f;
const int maxn=1e5+10;
int a[maxn];
int pre[maxn];
int vis[maxn];
int fin(int x){
    return x==pre[x]?x:pre[x]=fin(pre[x]);
}
void mer(int x,int y){
    int xx=fin(x);
    int yy=fin(y);
    if(xx!=yy){
        pre[xx]=yy;
    }
}
int main(){
    int n,m,x,y,z;
    scanf("%d%d",&n,&m);
    for(int i=1;i<=n;++i)
        pre[i]=i;
    while(m--){
        scanf("%d%d%d",&x,&y,&z);
        mer(x,y);
    }
    int ans=0;
    for(int i=1;i<=n;++i){
        int fa=fin(i);
        if(!vis[fa])ans++;
        vis[fa]=1;
    }
    printf("%d\n",ans);
}


Measured memory_bytes: 1152
n = int(input())
s = list(input())
cnt = 0
for i in range(n-1, -1, -1):
    if s[i] == ')':
        cnt += 1
    elif cnt > 0:
        cnt -= 1
s = cnt*'(' + ''.join(s)
cnt = 0
for i in range(len(s)):
    if s[i] == '(':
        cnt += 1
    else:
        cnt -= 1       
print(s+')'*cnt)


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

int main(){
  const static int N_MAX=1000;
  int N;
  static int A[N_MAX][N_MAX];
  cin >> N;
  for (int i=0 ; i<N ; i++){
    for (int j=0; j<N-1; j++){
      cin >> A[i][j];
    }
  }

  int game[N_MAX]={0};
  bool matched[N_MAX]={false};
  int day=1;

  int matchCount=0;
  int numOfMatches=N*(N-1)/2;

  vector<int> today;
  vector<int> nextday;

  for (int i=0 ; i<N ; i++){
    today.push_back(i);
  }


  while(1){
    // cout << "day:" << day <<"\n";
    bool someMatched=false;
    for (int i=0 ; i<N ; i++){
      matched[i]=false;
    }

    while(today.size()>0){
      int i=today.back();
      today.pop_back();

      if (!matched[i]){
        int o = A[i][game[i]]-1;
        // cout << i+1 << " vs " << o+1 << "\n";
        if ( game[o]<N-1 && A[o][ game[o] ] == i+1 && !matched[o]){
          // cout << "matched(" << i+1 << "," << o+1 << ")\n";
          matched[i]=true;
          matched[o]=true;
          game[i]++;
          game[o]++;
          if (game[i]<N-1){
            nextday.push_back(i);
          }
          if (game[o]<N-1){
            nextday.push_back(o);
          }
          matchCount++;
          someMatched=true;
        }
      }
    }

    if (matchCount==numOfMatches){
      break;
    }

    if (!someMatched){
      day=-1;
      break;
    }

    today.swap(nextday);
    nextday.clear();
    day++;
  }
  cout << day;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
using namespace std;
const ll mod = 1000000007;
const ll mod998 = 998244353;
const ll intmax = 2147483647;
const ll llmax = 9223372036854775807;
const char sp = ' ';

int N, A[100000], B[100000], a[100000], b[100000], aa[100000], bb[100000];
pair<int, int>pa[100000], pb[100000];

int main() {
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
		a[i] = A[i];
	}
	for (int i = 0; i < N; i++) {
		cin >> B[i];
		b[i] = B[i];
	}
	sort(a, a + N);
	sort(b, b + N);
	for (int i = 0; i < N; i++) {
		if (a[i] > b[i]) {
			puts("No");
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		int t = upper_bound(a, a + N, b[i]) - a - 1;
		if (t > i) {
			puts("Yes");
			return 0;
		}
	}
	for (int i = 0; i < N; i++) {
		pa[i] = { A[i],i };
		pb[i] = { B[i],i };
	}
	sort(pa, pa + N);
	sort(pb, pb + N);
	for (int i = 0; i < N; i++) {
		aa[pa[i].second] = i;
		bb[pb[i].second] = i;
	}
	int c = 0;
	int p = 0;
	do {
		c++;
		p = pb[aa[p]].second;
	} while (p);
	if (c == N) {
		puts("No");
	}
	else {
		puts("Yes");
	}
}

Measured memory_bytes: 4096