akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<cstdio>
#include<string>
#include<algorithm>
#include<cstdlib>
using namespace std;
int main(){
	int a[10],some;
	for(int i=0;i<3;i++){
		cin>>a[i];
	}
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			if(i!=j && a[i]==a[j]){
				some=a[i];
			}
		}
	}
	for(int i=0;i<3;i++){
		if(some!=a[i]){
			cout<<a[i]<<endl;
			return 0;
		}
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define repi(i,x) for(auto i=(x).begin(),i##_fin=(x).end();i!=i##_fin;i++)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef pair<int , int> Pi;
typedef vector<Pi> VPi;
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
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 INFLL = 1LL<<60;
const int INF = 1<<30;
const double PI=acos(-1);
int main(){
	int n;
	int ans=0;
	cin >>n;
	VPi bule(n),red(n);
	rep(i, n) { cin >> red[i].F >> red[i].S; }
	rep(i, n) { cin >> bule[i].F >> bule[i].S; }
	sort(all(red));
	sort(all(bule));
	int at = -INF;
	int now = INF;
	rep(i, n) {
		at = -INF;
		now = INF;
		for (int j = 0; bule[i].F > red[j].F and j<n; j++) {
			if (bule[i].S > red[j].S) {
				if (chmax(at, red[j].S)) {
					now = j;
				}
			}
		}
		if (now != INF) {
			ans++;
			red[now] = mp(INF, INF);
			sort(all(red));
		}
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 3580
from collections import deque
k = int(input())
queue = deque(range(1, 10))
for _ in range(k):
    x = queue.popleft()
    y = x % 10
    if y != 0:
        queue.append(10*x + y-1)
    queue.append(10*x + y)
    if y != 9:
        queue.append(10*x + y+1)
print(x)

Measured memory_bytes: 11956
#include <iostream>
#include <sstream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <utility>
#include <map>
#include <list>
#include <climits>
#include <set>
#include <deque>
#include <stack>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>

// #define cerr if(false)cerr
#define watch(x) cerr << "> " << #x << ": " << x << "\n";

using namespace std;

template <typename T>
std::ostream &operator <<(std::ostream &out, vector<T> &v) {
	for (typename vector<T>::size_type i = 0; i < v.size(); ++i)
		out << v[i] << " ";
	out << "\n";
    return out;
}
template <typename T, typename N>
std::ostream &operator <<(std::ostream &out, vector<pair<T, N> > &v) {
	for (size_t i = 0; i < v.size(); ++i)
		out << "(" << v[i].first << ", " << v[i].second << ") ";
	out << "\n";
    return out;
}
template <typename T>
std::ostream &operator <<(std::ostream &out, vector<vector<T> > &v) {
	for (size_t i = 0; i < v.size(); ++i) {
		for (size_t j = 0; j < v[i].size(); ++j) {
			out << v[i][j] << " ";
		}
		out << "\n";
	}
   	return out;
}

int main() {

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

	long long n;
	cin >> n;

	map<long long, int> prime_factors_count;
	while (n % 2 == 0) {
		++prime_factors_count[2];
		n >>= 1;
	}

	for (long long i = 3; i * i <= n; i += 2) {
		while (n % i == 0) {
			++prime_factors_count[i];
			n /= i;
		}
	}

	if (n > 2) {
		++prime_factors_count[n];
	}

	int ans = 0;
	for (auto it = prime_factors_count.begin(); it != prime_factors_count.end(); ++it) {
		int occs = it->second;
		int use = 1;
		while (occs >= use) {
			occs -= use;
			++ans;
			++use;
		}
	}

	cout << ans << "\n";

	return 0;

}

Measured memory_bytes: 3664
#include <cstdio>
#include <cstdint>
#include <cassert>
#include <vector>
#include <algorithm>
#include <tuple>
#include <queue>
#include <functional>

template <class Weight>
struct Edge {
  size_t src, dst;
  Weight cost;

  Edge(size_t src, size_t dst, Weight cost=1):
    src(src), dst(dst), cost(cost)
  {}

  bool operator <(const Edge<Weight> &rhs) const {
    if (cost != rhs.cost) return cost < rhs.cost;
    if (src != rhs.src) return src < rhs.src;
    return dst < rhs.dst;
  }
};

template <class Weight>
struct Graph: public std::vector<std::vector<Edge<Weight>>> {
  Graph(size_t n): std::vector<std::vector<Edge<Weight>>>(n) {}

  void connect_with(size_t src, size_t dst, Weight cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
    (*this)[dst].emplace_back(dst, src, cost);
  }

  void connect_to(size_t src, size_t dst, Weight cost=1) {
    (*this)[src].emplace_back(src, dst, cost);
  }

  std::vector<size_t> sccomp(size_t &num) const {
    const size_t V=this->size();
    Graph rev(V);
    for (const auto &v: *this)
      for (const auto &e: v)
        rev.connect_to(e.dst, e.src, e.cost);

    std::vector<bool> used(V);
    std::vector<size_t> vs;
    std::function<void (size_t)> dfs=[&](size_t v) {
      used[v] = true;
      for (size_t i=0; i<(*this)[v].size(); ++i)
        if (!used[(*this)[v][i].dst]) dfs((*this)[v][i].dst);

      vs.push_back(v);
    };

    for (size_t v=0; v<V; ++v)
      if (!used[v]) dfs(v);

    used.assign(V, false);
    std::vector<size_t> cmp(V);
    num = 0;
    std::function<void (size_t)> rdfs=[&](size_t v) {
      used[v] = true;
      cmp[v] = num;
      for (size_t i=0; i<rev[v].size(); ++i)
        if (!used[rev[v][i].dst]) rdfs(rev[v][i].dst);
    };

    for (size_t i=vs.size(); i--;)
      if (!used[vs[i]]) {
        rdfs(vs[i]);
        ++num;
      }

    return cmp;
  }

  std::vector<size_t> sccomp() const {
    size_t tmp;
    return sccomp(tmp);
  }
};

template <class Weight>
std::vector<size_t> tsort(const Graph<Weight>& g) {
  size_t n = g.size();
  size_t k = 0;
  std::vector<size_t> ord(n);
  std::vector<int> in(n);
  for (auto& es: g)
    for (auto& e: es) ++in[e.dst];

  std::queue<size_t> q;
  for (size_t i = 0; i < n; ++i)
    if (in[i] == 0) q.push(i);

  while (!q.empty()) {
    size_t v = q.front();
    q.pop();
    ord[k++] = v;
    for (auto& e: g[v])
      if (--in[e.dst] == 0)
        q.push(e.dst);
  }
  if (*std::max_element(in.begin(), in.end()) != 0) return {};
  return ord;
}

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

  Graph<int> g(N);
  for (size_t i = 1; i < N+M; ++i) {
    size_t A, B;
    scanf("%zu %zu", &A, &B);
    --A;
    --B;
    g.connect_to(A, B, 1);
  }

  auto ts = tsort(g);
  assert(!ts.empty());

  std::vector<size_t> par(N, -1);
  for (size_t i = 0; i < N; ++i) {
    size_t v = ts[i];
    for (auto& e: g[v]) {
      par[e.dst] = e.src;
    }
  }

  for (size_t i = 0; i < N; ++i)
    printf("%zu\n", par[i]+1);
}


Measured memory_bytes: 7800
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector,fast-math")
#pragma GCC target ("sse4")

#include <bits/stdc++.h>

#define deb(x) cout << #x << " is " << x << "\n";

using namespace std;

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    long long n, k, ele;
    cin >>n >>k;
    priority_queue<long long> pq;
    for(long long i = 0; i < n; i++){
    	cin >>ele;
    	pq.push(ele);
    }
    long long ans = 0;
    while(!pq.empty() && k > 0){
    	pq.pop();
    	k--;
    }
    if(pq.empty())
    	cout <<ans;
   	else{
   		while(!pq.empty()){
   			ans += pq.top();
   			pq.pop();
   		}
   		cout <<ans;
   	}
    return 0;
}


Measured memory_bytes: 2420
while True:
    m, f, r = map(int, input().split())
    if m == f == r == -1:
        break
 
    if m == -1 or f == -1:
        print("F")
    elif m + f >= 80:
        print("A")
    elif m + f >= 65:
        print("B")
    elif m + f >= 50:
        print("C")
    elif m + f >= 30:
        if r >= 50:
            print("C")
        else:
            print("D")
    else:
        print("F")


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

int main()
{
  string S;
  cin >> S;
  int ans = 0;
  rep(i, S.size() / 2)
  {
    if (S[i] != S[S.size() - 1 - i])
      ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


int main() {
    int n, l;
    cin >> n >> l;
    vint a(n);
    rep(i, n) cin >> a[i];

    bool possible = false;
    int id = -1;
    rep(i, n-1) {
        if (a[i]+a[i+1] >= l) {
            possible = true;
            id = i;
            break;
        }
    }
    if (possible) {
        puts("Possible");
        rep(i, id) cout << i+1 << endl;
        for (int i = n-2; i >= id; --i) cout << i+1 << endl;
    }
    else puts("Impossible");
    return 0;
}

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

int main() {
  long long a,b,c;
  cin >>a>>b>>c;
  long long sa=LLONG_MAX;
  sa=min(sa,abs(a/2*2*b*c-a*b*c));
  sa=min(sa,abs(b/2*2*a*c-a*b*c));
  sa=min(sa,abs(c/2*2*a*b-a*b*c));
  cout<<sa<<endl;
  return 0;
}
           
           

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <cassert>
#include <string>
#include <algorithm>
#include <vector>
#include <queue>
#include <stack>
#include <functional>
#include <iostream>
#include <map>
#include <set>
#include <cassert>
#include <string.h>
#include <iomanip>

using namespace std;

int main()
{
	int N;
	cin >>N;
	vector <int > v;
	vector <int > T[100000];
	
	vector <int > first;
	vector <int > second;
	int x, y;
	int a, b;
	
	
	for (int i = 0; i<N; i++) {
		cin>>x;
		first.push_back(x);
		
	}
	
	for (int i = 0; i<N; i++)
	{
		cin >> y;
		second.push_back(y);
	}
	
	for (int i = 1; i<=N; i++) 
	{
		v.push_back(i);
		T[0].push_back(i);
	}
	int j = 1;
	
	
	while(std::next_permutation(v.begin(), v.end()))
	{
		//cout << v[0] <<v[1] << v[2] << endl;
		
		for (int i = 0; i<v.size(); i++)
		T[j].push_back(v[i]);
		j++;
		//cout<<endl;
	}
	
	for (int i = 0; i<j; i++)
	{
		if (T[i] == first)
		{ 
			
			a = i;
			break;
		}
		
	}
	
	for (int k = 0; k<j; k++)
	{
		if (T[k] == second)
		{
			b = k;
			break;
		}
	}
	
	cout <<abs(a-b)<<endl;
	
	
	
	
	
	
	
	
	
	
	return 0;
}



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

int main(){
    int N, result = 0;

    cin >> N;
    vector <int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }
    std::sort(vec.begin(), vec.end());
    int max_vec = vec.back();
    vector <bool> divisible(max_vec + 1, false);

    int x = 0;
    for(int i = 0; i < N; i++){
        x = vec[i];
        // 割り切れることが確定している場合は飛ばす
        if(divisible[x]){
            continue;
        }

        // xの倍数は割り切れるので次回のために記録しておく
        for(int j = x; j <= max_vec; j = j + x){
            divisible[j] = true;
        }

        // 同じ数が続く場合は割り切れるのでカウントしない。
        if(i < N-1 && vec[i] == vec[i+1]){
            continue;
        }
        result++;
    }
    cout << result << endl;
    return 0;
}

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

typedef long long ll;
const ll INF = 1LL<<60, MOD = 1e9 + 7;
const double EPS = 1e-9, PI = 3.141592653589793;
#define REP(i,a,b) for(ll i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
#define all(v) (v).begin(), (v).end()

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  ll a,b;
  cin >> a >> b;
  if(a>=13) cout << b << endl;
  else if(a>=6) cout << b/2 << endl;
  else cout << 0 << endl;
  return 0;
}

Measured memory_bytes: 764
#include <iostream>
#include <array>
#include <vector>
#include <string>
#include <numeric>
#include <algorithm>
#include <utility>

#include <atcoder/lazysegtree>

using namespace std;
using namespace atcoder;
#define rep(i,l,r) for(int i = l; i < r; ++i)

typedef long long G;
typedef pair<G, int> S;
typedef pair<G, G> F;

G MOD = 998244353;
S op(S s1, S s2)
    {return {(s1.first + s2.first) % MOD, s1.second + s2.second};}
S e() {return {0, 0};}

S mapping(F f, S s)
    {return {(s.first * f.first + s.second * f.second) % MOD, s.second};}
F composition(F f1, F f2)
    {return {(f2.first * f1.first) % MOD, (f2.second * f1.first + f1.second) % MOD};}
F id() {return {1, 0};}

int main() {
    int n, q, t, l, r, b, c;
    cin >> n >> q;

    vector<S> a(n);
    rep(i, 0, n) {
        cin >> a[i].first;
        a[i].second = 1;
    }

    lazy_segtree<S, op, e, F, mapping, composition, id> lseg(a);

    rep(i, 0, q) {
        cin >> t >> l >> r;
        if (t == 0) {
            cin >> b >> c;
            lseg.apply(l, r, {b, c});
        } else {
            cout << lseg.prod(l, r).first << endl;
        }
    }
}


Measured memory_bytes: 35404
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<cstddef>
#include<queue>
#include<math.h>
#include<iomanip>
using namespace std;

int main()
{
    int n, mx = 0, mn = 1010;
    cin >> n;
    vector<int> x(n);
    for(int i = 0; i < n; ++i){
        cin >> x.at(i);
        mx = max(mx, x.at(i));
        mn = min(mn, x.at(i));
    } 
    int ans = 10101010; 
    for(int j = mn; j <= mx; ++j){
        int len = 0;
        for(int i = 0; i < n; ++i){
            len += (x.at(i) - j) * (x.at(i) - j);
        }
        ans = min(ans, len);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3620
# 各条件の入力
k, n = map(int, input().split())
a_iterator = map(int, input().split())
a = list(a_iterator)

# 判定
diff_list = [(a[i+1] - a[i]) for i in range(n-1)]

ans1 = max(a) - min(a)
ans2 = k - max(diff_list)

ans = min(ans1, ans2)

# 答えの出力
print(ans)


Measured memory_bytes: 25452
#include <bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
const long long LINF = 1e18;
#define dump(x)  cout << 'x' << ' = ' << (x) << ` `;
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOREACH(x,a) for(auto& (x) : (a) )
typedef long long ll;
using namespace std;
typedef pair<ll, ll> P;

template<typename T>
void print(const vector<T> &x) {
    int n = x.size();
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x) {
    int n = x.size();
    rep(i,n) {
        rep(j,x[i].size()) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

template<typename T>
void print(const vector<T> &x, int n) {
    rep(i,n) {
        cout << x[i];
        if (i!=n-1) cout<<" ";
        else cout << endl;
    }
}

template<typename T>
void print(const vector<vector<T>> &x, int n, int m) {
    rep(i,n) {
        rep(j,m) {
            cout << x[i][j] << " ";
        }
        cout << endl;
    }
}

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

void input_init() {
    cin.tie(0); ios::sync_with_stdio(false);
}

int main(int argc, char const *argv[]) {
    int h,w,k; cin>>h>>w>>k;
    vector<string> s(h);
    rep(i,h) cin>>s[i];
    int ans = INF;
    vector<vector<int>> sum(h+1, vector<int>(w+1));
    rep(i,h) rep(j,w) {
        int c = 0;
        if (s[i][j]=='1') c++;
        sum[i+1][j+1] = sum[i][j+1] + sum[i+1][j] - sum[i][j] + c;
    }

    for (int bit = 0; bit < (1<<(h-1)); ++bit) {
        int tmp = 0;
        vector<int> t;
        for (int i = 0; i < h; ++i) {
            if (bit & (1<<i)) t.push_back(i+1);
        }
        tmp += t.size();

        t.push_back(h);

        int ykrm = 0;
        for (int j = 1; j < w; ++j) {
            int tkrm = 0;
            bool ok = true;
            rep(l,t.size()) {
                int m = sum[t[l]][j+1]-sum[t[l]][ykrm]-sum[tkrm][j+1]+sum[tkrm][ykrm];
                if (m>k) {
                    ok = false;
                    break;
                }
                tkrm = t[l];
            }

            bool hoge = true;
            if (!ok) {
                rep(l,t.size()) {
                    int m = sum[t[l]][j]-sum[t[l]][ykrm]-sum[tkrm][j]+sum[tkrm][ykrm];
                    if (m>k) {
                        hoge = false;
                        break;
                    }
                    tkrm = t[l];
                }
                if (hoge) {
                    tmp++;
                    ykrm = j;
                }
                else {
                    tmp = INF+100;
                    break;
                }
            }
        }
        chmin(ans,tmp);
    }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 256
m,n,xl,yl=map(int,input().split())
x=list(map(int,input().split()))
y=list(map(int,input().split()))

x.append(xl)
y.append(yl)
x_mx=max(x)
y_mn=min(y)

res='War' 

if x_mx<y_mn:
	res='No War' 

print(res)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
 
void solve() {
    string s;
    cin>>s;
    if(s[1] != s[0] || s[1] != s[2]) cout<<"Yes";
    else cout<<"No";
}
 
int main() {
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    cout.tie(nullptr);
    cout.precision(10);
    cout<<fixed;
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
#endif
    solve();
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 1000000000
#define LLINF 1000000000000000ll
#define sz(x) ((int)(x).size())
#define fi first
#define sec second
#define all(x) (x).begin(),(x).end()
#define sq(x) ((x)*(x))
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define repn(i,a,n) for(int (i)=(a);(i)<(int)(n);(i)++)
#define EQ(a,b) (abs((a)-(b))<eps)
template<class T> void chmin(T& a,const T& b){if(a>b)a=b;}
template<class T> void chmax(T& a,const T& b){if(a<b)a=b;}
vector<int> g[200100];
int N;
P dfs(int v,int p){
	P res = P(0,v);
	for(int i=0;i<g[v].size();i++){
		if(g[v][i]==p)continue;
		P a = dfs(g[v][i],v);
		a.fi++;
		res = max(res,a);
	}
	return res;
}
int main(){
	cin >> N;
	for(int i=0;i<N-1;i++){
		int x,y;
		cin >> x >> y;
		x--;y--;
		g[x].pb(y);
		g[y].pb(x);
	}
	int v = 0;
	P a = dfs(0,-1);
	P b = dfs(a.sec,-1);
	if(b.fi%3==1)cout << "Second" << endl;
	else cout << "First" << endl;
	return 0;
}

Measured memory_bytes: 26752
import java.util.Scanner;

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

        if (a > b)
            System.out.println("a > b");
        else if (a < b)
            System.out.println("a < b");
        else if (a == b)
            System.out.println("a == b");
    }
}



Measured memory_bytes: 26248
/*
  I_🧡🧡🧡_QMsh
*/

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define x first
#define y second

using namespace std;
using namespace __gnu_pbds; // gp_hash_table<int, int> table;

template <typename T> void smin(T &a, const T &b) { a = (a < b ? a : b); }
template <typename T> void smax(T &a, const T &b) { a = (a > b ? a : b); }

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;

signed main()
{
  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  string s;
  int k;
  cin >> s >> k;
  int n = s.size();
  s += s;
  string t = s;
  ll cnt = 0;
  ll cnt2 = 0;
  if (s[0] == s[1] && s[0] == s[2 * n - 1])
  {
    s[0] = '#';
    cnt++;
  }
  for (int i = 1; i < 2 * n; i++)
  {
    if (s[i] == s[i - 1] || (i == 2 * n - 1 && s[0] == s[i]))
    {
      cnt++;
      s[i] = '#';
    }
  }

  ll ans = (k / 2) * cnt;

  k %= 2;
  if (k == 0)
  {
    k = 2;
    ans -= cnt;
  }

  s = t;

  for (int i = 1; i < k * n; i++)
  {
    if (s[i] == s[i - 1])
    {
      ans++;
      s[i] = '#';
    }
  }

  cout << ans;

  return 0;
}

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

const long long INF = 1ll << 62;

template<class M, class F = std::function<M(M, M)>>
class SegmentTree{
private:
  std::vector<M> data;
  F op;
  M e;
  int length;

public:
  SegmentTree(int n, const F op, const M& e) : op(op), e(e){
    length = 1;
    while(length < n) length <<= 1;
    data = std::vector<M>((length << 1) - 1, e);
  }

  void update(int index, const M& x){
    index += length - 1;
    data[index] = x;

    while(index){
      (--index) >>= 1;
      data[index] = op(data[(index << 1) + 1], data[(index << 1) + 2]);
    }
  }

  M query(int left, int right){
    M l = e, r = e;

    for(left += length - 1, right += length - 1; left < right; (--left) >>= 1, (--right) >>= 1){
      if(!(left & 1)) l = op(data[left++], l);
      if(!(right & 1)) r = op(data[--right], r);
    }

    return op(l, r);
  }
};

using namespace std;

int main(){
  int N, M;
  cin >> N >> M;
  
  vector<pair<pair<int, int>, long long>> e(M);
  for(int i = 0; i < M; i++){
    cin >> e[i].first.first >> e[i].first.second >> e[i].second;
  }
  sort(e.begin(), e.end());
  
  SegmentTree<long long> segTree(N + 1, [](const long long& c0, const long long& c1){
    return min(c0, c1);
  }, INF);
  
  segTree.update(1, 0);
  for(int i = 0; i < M; i++){
    segTree.update(e[i].first.second, min(segTree.query(e[i].first.second, e[i].first.second + 1), segTree.query(e[i].first.first, e[i].first.second) + e[i].second));
  }
  
  if(segTree.query(N, N + 1) < INF) cout << segTree.query(N, N + 1) << endl;
  else cout << -1 << endl;
  
  return 0;
}

Measured memory_bytes: 6968
n,k = map(int, input().split())

if k ==0:
    print(n**2)
    exit()

res=0
for i in range(k+1,n+1):
    a = n//i
    res += (i-k)*a
    b = n % i
    res += max(0,b-k+1)

print(res)

Measured memory_bytes: 9180
package main

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

var isProduct = false

func main() {
	nextReader = newScanner()

	n := nextInt()
	k := nextInt()

	// 中心点1を除く、(n-1)個の頂点から(n-1-1)個の頂点に辺が引けて、重複をなくすため2で割る
	max := (n - 1) * (n - 2) / 2

	if k > max {
		fmt.Println("-1")
		return
	}

	//間引く本数
	delta := max - k

	fmt.Println(delta + n - 1)

	for i := 1; i < n; i++ {
		fmt.Println(1, i+1)
	}

	for a := 2; a < n; a++ {
		for b := a + 1; b <= n; b++ {
			if delta == 0 {
				break
			}
			fmt.Println(a, b)
			delta--
		}
		if delta == 0 {
			break
		}
	}
}

/* --------------------------------------------------------------------------
 *  sort
 * ------------------------------------------------------------------------- */

// type S struct {
//   sort int
// }
// type Sorter []S

// func (a Sorter) Len() int           { return len(a) }
// func (a Sorter) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
// func (a Sorter) Less(i, j int) bool { return a[i].sort < a[j].sort }

// type Sorter []Sortable

// func (a Sorter) Len() int           { return len(a) }
// func (a Sorter) Swap(i, j int)      { a[i], a[j] = a[j], a[i] }
// func (a Sorter) Less(i, j int) bool { return a[i].Axis < a[j].Axis }

/* --------------------------------------------------------------------------
 *  math
 * ------------------------------------------------------------------------- */
func lcm(x, y int) int {
	return x * y / gcd(x, y)
}

func gcd(x, y int) int {
	tmp := x % y
	if tmp > 0 {
		return gcd(y, tmp)
	} else {
		return y
	}
}

func abs(i int) int {
	return int(math.Abs(float64(i)))
}

/* --------------------------------------------------------------------------
 *  debug
 * ------------------------------------------------------------------------- */
func debugln(s ...interface{}) {
	if !isProduct {
		fmt.Println(s...)
	}
}

func debug(s ...interface{}) {
	if !isProduct {
		fmt.Print(s...)
	}
}
func debugf(f string, s ...interface{}) {
	if !isProduct {
		fmt.Printf(f, s...)
	}
}

/* --------------------------------------------------------------------------
 *  std.io
 * ------------------------------------------------------------------------- */
var nextReader func() string

func newScanner() func() string {
	r := bufio.NewScanner(os.Stdin)
	r.Buffer(make([]byte, 1024), int(1e+11))
	r.Split(bufio.ScanWords)
	return func() string {
		r.Scan()
		return r.Text()
	}
}
func nextString() string {
	return nextReader()
}
func nextInt64() int64 {
	v, _ := strconv.ParseInt(nextReader(), 10, 64)
	return v
}
func nextInt() int {
	v, _ := strconv.Atoi(nextReader())
	return v
}
func nextInts(n int) []int {
	r := make([]int, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt()
	}
	return r
}
func nextInt64s(n int) []int64 {
	r := make([]int64, n)
	for i := 0; i < n; i++ {
		r[i] = nextInt64()
	}
	return r
}
func nextFloat64() float64 {
	f, _ := strconv.ParseFloat(nextReader(), 64)
	return f
}

func maxInt(a, b int) int {
	if a > b {
		return a
	} else {
		return b
	}
}

/* --------------------------------------------------------------------------
 *  memo
 * ------------------------------------------------------------------------- */


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

const int mx = 10e5+5;


long long dp[mx];
map<string , int> mp;
set<string> ss;


long long fact(int x){
    if(x == 1) return 1;
    if(dp[x] != 0) return dp[x];
    else{
        long long tmp = (long long)x + fact(x - 1);
        dp[x] = tmp;
        return tmp;
    }

}


int main(){
    int n;
    cin >> n;
    while (n--){
        string s;
        cin >> s;
        sort(s.begin(), s.end());
        if(mp.find(s) == mp.end()){
            mp[s] = 1;
            ss.insert(s);
        }else{
            mp[s]++;
        }
    }
    long long ans = 0;
    set<string>::iterator it;
    for(it = ss.begin(); it!= ss.end(); it++){
        int tmp = mp[*it];
        if(tmp >= 2)
            ans += fact(tmp - 1);    
    }
    
    
    cout << ans << endl;
    
}

Measured memory_bytes: 20608
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
using namespace std;
#define reps(i,b,n) for(int i = b ; i < (int)n ; ++i )
#define rep(i,n) reps(i,0,n)
#define fr first
#define sc second
typedef pair<int,int> Pt;
typedef pair<Pt,Pt> pp;
typedef pair<int,pp> P;
const int dx[] = {1,-1,0,0}, dy[] = {0,0,1,-1};
int w,h,mas[7][7];
Pt St,kago,Gl;
bool used[7][7][7][7];
bool check(int x,int y){
  return x >= 0 && x < h && y >= 0 && y < w && mas[x][y] != 1;
}
int Dijkstra(){
  priority_queue< P,vector<P>,greater<P> > que;
  que.push(P(0,pp(St,kago)));
  used[St.fr][St.sc][kago.fr][kago.sc] = true;
  while(!que.empty()){
    Pt now = que.top().sc.fr , box = que.top().sc.sc;
    int cost = que.top().fr;
    que.pop();
    if(box == Gl) return cost;
    rep(i,4){
      int nx = now.fr + dx[i] , ny = now.sc + dy[i];
      if(!check(nx,ny)) continue;
      int boxx = box.fr , boxy = box.sc , cnt = cost;
      if( nx == boxx && ny == boxy ){
          boxx += dx[i] , boxy += dy[i] , cnt++;
          if(!check(boxx,boxy)) continue;
      }
      if(!used[nx][ny][boxx][boxy]){
        que.push(P(cnt,pp(Pt(nx,ny),Pt(boxx,boxy))));
        used[nx][ny][boxx][boxy] = true;
      }
    }
  }
  return -1;
}
int main(){
  while(cin >> w >> h , w){
    rep(i,h) rep(j,w){
      cin >> mas[i][j];
      if(mas[i][j] == 4) St = Pt(i,j);
      else if(mas[i][j] == 2) kago = Pt(i,j);
      else if(mas[i][j] == 3) Gl = Pt(i,j);
    }
    cout << Dijkstra() << endl;
    fill_n(used[0][0][0],7*7*7*7,false);
  }
}

Measured memory_bytes: 1200
//This code was made by Chinese_zjc_.
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#define int long long
#define INF 0x3fffffffffffffff
using namespace std;
string a;
signed main()
{
	std::ios::sync_with_stdio(false);
	cin>>a;
	if(a[1]=='B')
	{
		cout<<"ARC"<<endl;
	}
	else
	{
		cout<<"ABC"<<endl;
	}
	return 0;
}


Measured memory_bytes: 3564
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using P = pair<int, int>;
#define PI acos(-1)
#define Mod (int)1000000007
#define INFTY (int)INT_MAX
#define Rep(i, n) for (int i = 0; i < (int)(n); i++)
#define BitRep(i, n) for (int i = 0; i < (int)(1 << n); i++)
#define All(vec) vec.begin(), vec.end()
#define Sum(vec) accumulate(vec.begin(), vec.end(), 0)
#define Sort(vec) sort(vec.begin(), vec.end())
#define Reverse(vec) reverse(vec.begin(), vec.end())
#define Count(vec, x) count(vec.begin(), vec.end(), x)
#define Next_permutation(vec) next_permutation(vec.begin(), vec.end())
#define Find(S, s) S.find(s) != string::npos

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


Measured memory_bytes: 3096
#!/usr/bin/env python
import string
import sys
from itertools import chain, dropwhile, takewhile


def read(
    *shape, f=int, it=chain.from_iterable(sys.stdin), whitespaces=set(string.whitespace)
):
    def read_word():
        w = lambda c: c in whitespaces
        nw = lambda c: c not in whitespaces
        return f("".join(takewhile(nw, dropwhile(w, it))))

    if not shape:
        return read_word()
    elif len(shape) == 1:
        return [read_word() for _ in range(shape[0])]
    elif len(shape) == 2:
        return [[read_word() for _ in range(shape[1])] for _ in range(shape[0])]


def readi(*shape):
    return read(*shape)


def readi1(*shape):
    return [i - 1 for i in readi(*shape)]


def readf(*shape):
    return read(*shape, f=float)


def reads(*shape):
    return read(*shape, f=str)


def arr(*shape, fill_value=0):
    if len(shape) == 1:
        return [fill_value] * shape[fill_value]
    elif len(shape) == 2:
        return [[fill_value] * shape[1] for _ in range(shape[0])]


def dbg(**kwargs):
    print(
        ", ".join("{} = {}".format(k, repr(v)) for k, v in kwargs.items()),
        file=sys.stderr,
    )


def main():
    n = readi()
    S = readi(n)
    q = readi()
    T = readi(q)
    ans = 0
    for t in T:
        left = 0
        right = n - 1
        while left != right:
            mid = (left + right - 1) // 2
            if t <= S[mid]:
                right = mid
            else:
                left = mid + 1
        if t == S[left]:
            ans += 1
    print(ans)


if __name__ == "__main__":
    main()



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

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

using std::cin;
using std::cout;
using std::endl;
using std::string;
using std::vector;

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

  vector<int> h(N);
  rep(i, N) cin >> h[i];

  bool water = false;
  int sum = 0;
  rep(i, 101)
  {
    if (water)
    {
      sum++;
    }
    water = false;

    rep(j, N)
    {
      if (h[j] > 0)
      {
        water = true;
        h[j]--;
      }
      else if (water)
      {
        sum++;
        water = false;
      }
    }
  }

  cout << sum << endl;

  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long n,k,l,r;
    string s;
    cin>>n>>k;
    cin>>s;
    vector<long long> pre(n+1);
    for(int i=1;i<n;i++)
    {
        if(s[i-1]=='A' && s[i]=='C')
        {
            pre[i]=1;
        }
    }
    for(int i=1;i<=n;i++)
    {
        pre[i]=pre[i]+pre[i-1];
    }
    while(k--)
    {
        cin>>l>>r;
     if(l==r) cout<<0<<endl;
     else
       {
           r--;
         cout<<pre[r]-pre[l-1]<<endl;
       }

    }
    return 0;


}


Measured memory_bytes: 4200
import math
l = int(input())
r = math.floor(math.log2(l))
n = r+1
pow2r = pow(2, r)
lst = list([i, i+1, 0] for i in range(1, n)) + list([i, i+1, pow(2, i-1)] for i in range(1, n))
for i in range(1, n)[::-1]:
    p = pow(2, i-1)
    if l - p >= pow2r:
        lst.append([i, n, l-p])
        l -= p
print(n, len(lst))
for u, v, w in lst:
    print(u, v, w)

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

int N,M;
pair<int,int> p[110000];

int main(){
    cin >> N >> M;
    int x,y;
    REP(i,M){
        cin >> x >> y;
        // 区間の後ろ側でソートしたい
        p[i] = make_pair(y-1,x-1);
    }
    sort(p, p+M);

    // 共通する橋を一つでも使う島々を一つの区間とする　→　区間の数　＝　落とさなければいけない橋の数
    int ans = 0;
    int t = 0; // １ループ前の右端
    REP(i,M){
        // このループの左端が、一つ前の右端より右　→　同じ橋を使ってない
        if(t <= p[i].second){
            t = p[i].first;
            ++ans;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <stdio.h>
#define _USE_MATH_DEFINES
#include <math.h>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
    long n,k;
    scanf("%ld %ld", &n, &k);
    vector<long> vix(n * n),viy(n * n);
    for(long i = 0; i < n; i++){
        long x,y;
        scanf("%ld %ld", &x, &y);
        for(long j = 0 ; j < n; j++){
            vix[n * i + j] = x;
            viy[n * j + i] = y;
        }
    }
    
    long SAns = LONG_MAX;
    for(long i = 0; i < n * n - 1; i++){
        for(long j = i + 1; j < n * n; j++){
            long nCount = 0;
            for(long k = 0; k < n; k++){
                if((vix[i] - vix[(n+1) * k]) * (vix[j] - vix[(n+1) * k]) > 0){
                    continue;
                }
                if((viy[i] - viy[(n+1) * k]) * (viy[j] - viy[(n+1) * k]) > 0){
                    continue;
                }
                nCount++;
            }
            if(nCount >= k){
                long STmp = abs((vix[i] - vix[j]) * (viy[i] - viy[j]));
                if(STmp < SAns){
                    SAns = STmp;
                }
            }
        }
    }
    
    printf("%ld", SAns);
    return 0;
}


Measured memory_bytes: 3212
//Name: Kyudo: A Japanese Art of Archery
//Level: 1
//Category: やるだけ
//Note:

/**
 * 問題文の通りに処理し、合計するだけ。
 */
#include <iostream>
#include <vector>

using namespace std;

bool solve() {
    int N;
    if(!(cin >> N)) return false;
    if(!N) return false;

    int sum = 0;
    for(int i = 0; i < N/4; ++i) {
        int a;
        cin >> a;
        sum += a;
    }
    cout << sum << endl;
    return true;
}

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

    while(solve()) ;
    return 0;
}

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

namespace Aizu
{
    class OnlineJudge
    {
        public static void Main()
        {
            Enumerable.Range(0, 7).Select(p => Console.ReadLine().Split(' ').Select(int.Parse).ToArray()).ToList().ForEach(p => Console.WriteLine(p[0] - p[1]));
        }
    }
}

Measured memory_bytes: 12088
# -*- coding: utf-8 -*-

N = int(input())
H = list(map(int, input().split())) + [10 ** 10]

ans = 0
tmp = 0
height = 0
for h in H:
    if h <= height:
        tmp += 1
        height = h
    else:
        ans = max(ans, tmp)
        tmp = 0
        height = h

print(ans)


Measured memory_bytes: 14252
#include <bits/stdc++.h>
using namespace std;
 
#define rep(i, n) for (int i = (int)(0); i < (int)(n); ++i)
#define reps(i, n) for (int i = (int)(1); i <= (int)(n); ++i)
#define rrep(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rreps(i, n) for (int i = ((int)(n)); i > 0; i--)
#define irep(i, m, n) for (int i = (int)(m); i < (int)(n); ++i)
#define ireps(i, m, n) for (int i = (int)(m); i <= (int)(n); ++i)
#define FOR(e, c) for (auto &e : c)
#define SORT(v, n) sort(v, v + n);
#define vsort(v) sort(v.begin(), v.end());
#define rvisort(v) sort(v.begin(), v.end(), greater<int>());
#define all(v) v.begin(), v.end()
#define mp(n, m) make_pair(n, m);
#define cout(d) cout<<d<<endl;
#define coutd(d) cout<<std::setprecision(10)<<d<<endl;
#define cinline(n) getline(cin,n);
#define replace_all(s, b, a) replace(s.begin(),s.end(), b, a);
 
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using pii = pair<int, int>;
using vpii = vector<pii>;
using vs = vector<string>;
using vd = vector<double>;
using ul = unsigned long;
 
template<class T, class C> void chmax(T& a, C b){ a>b?:a=b; }
template<class T, class C> void chmin(T& a, C b){ a<b?:a=b; }

int main()
{
  cin.tie( 0 );
  ios::sync_with_stdio( false );
  
  int n;string s;
  cin>>n>>s;
  
  int x=0;
  int max=0;
  rep(i,n){
    if(s[i]=='I')x++;
    if(s[i]=='D')x--;
    if(max<x)max=x;
  }
  cout(max);
  return 0;
}

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

using namespace std;

typedef long long ll;
#define x first
#define y second
#define mp make_pair

string s;
int n;

bool je(string a){
	string b = a;
	reverse(b.begin(), b.end());
	return (a == b);
}

int main(){
ios_base::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
cin >> s;
n = (int)s.size();
if(!je(s)){
	cout << "No" << endl;
	return 0;
}
string a = "";
for(int i = 1 ; i <= (n - 1) / 2 ; ++i){
	a += s[i - 1];
}
if(!je(a)){
	cout << "No" << endl;
	return 0;
}
string b = "";
for(int i = (n + 3) / 2 ; i <= n ; ++i){
	b += s[i - 1];
}
if(!je(b)){
	cout << "No" << endl;
	return 0;
}
cout << "Yes" << endl;

return 0;
}



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

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

#define ll long long
#define endl '\n'
#define REP(i, a, n) for(int i=a; i<n; ++i)
#define pb push_back
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()

typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;

const double PI = 3.141592653589793238460;
const ll mod = 1e9 + 7;

void FAST(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
}

int main(){
  FAST();

  int n, m;
  cin >> n >> m;
  int c = 0, p = 0;
  int AC[100001] = {0}, WA[100001] = {0};

  while(m--){
    int x;
    string str;
    cin >> x >> str;

    if(AC[x])   continue;

    if(str == "AC"){
        AC[x] = 1;
        c++;
        p += WA[x];
    }
    else if(str == "WA")
        WA[x]++;
  }
  cout << c << " " << p << endl;

  return 0;
}












Measured memory_bytes: 1024
# -*- coding: utf-8 -*-
"""
Created on Sat Feb 16 20:52:46 2019

@author: Owner
"""


import collections
import scipy.misc
import sys
import numpy as np
import math
from operator import itemgetter
import itertools
import copy

#素因数を並べる
def prime_decomposition(n):
  i = 2
  table = []
  while i * i <= n:
    while n % i == 0:
      n /= i
      table.append(int(i))
    i += 1
  if n > 1:
    table.append(int(n))
  return table   
# 桁数を吐く
def digit(i):
    if i > 0:
        return digit(i//10) + [i%10]
    else:
        return []
    
def getNearestValueIndex(list, num):
    """
    概要: リストからある値に最も近い値のインデックスを取得する関数
    @param list: データ配列
    @param num: 対象値
    @return 対象値に最も近い値
    """

    # リスト要素と対象値の差分を計算し最小値のインデックスを取得
    idx = np.abs(np.asarray(list) - num).argmin()
    return idx

"""
N, X = map(int, input().split())

x = [0]*N
x[:] = map(int, input().split())

P = [0]*N
Y = [0]*N
for n in range(N):
    P[n], Y[n] = map(int, input().split())
    
all(nstr.count(c) for c in '753')

# 複数配列を並び替え
ABT = zip(A, B, totAB)
result = 0
# itemgetterには何番目の配列をキーにしたいか渡します
sorted(ABT,key=itemgetter(2))
A, B, totAB = zip(*ABT)
A.sort(reverse=True)

# 2進数のbit判定
(x >> i) & 1

# dp最小化問題
dp = [np.inf]*N
for n in range(N):
    if n == 0:
        dp[n] = 0
    else:
        for k in range(1,K+1):
            if n-k >= 0:
                dp[n] = min(dp[n], dp[n-k] + abs(h[n]-h[n-k]))
            else:
                break

"""

N = int(input())

x = [0]*N
u = [0]*N
result = 0
for n in range(N):
    x[n], u[n] = map(str, input().split())
    if u[n] == 'JPY':
        result += float(x[n])
    else:
        result += 380000.0*float(x[n])    
print(result)


Measured memory_bytes: 21912
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
#include <vector>
#include <numeric>

int main(){
    int N, M;
    cin >> N >> M;
    int WA[105000];
    bool AC[105000];
    int goodjob=0;
    int penalty=0;
    for(int i=0; i<N; i++){
        WA[i] = 0;
        AC[i] = false;
    }
    while(M--){
        int p;
        string S;
        cin >> p >> S;
        if(AC[p]) continue;
        if(S == "AC"){
            AC[p]= true;
            goodjob++;
            penalty += WA[p];
        }
        else if(S=="WA"){
            WA[p]++;
        }
    }
    cout << goodjob << " " << penalty << endl;
}

Measured memory_bytes: 768
#include<stdio.h>
#define MAX 100

struct Node {
    int p, r, l;
};

Node T[MAX];
int Pre[MAX], In[MAX], Post[MAX];
int n;

int postorder(int i, int n) {
    if (T[n].l!=-1) {
        i = postorder(i, T[n].l);
    }
    if (T[n].r!=-1) {
        i = postorder(i, T[n].r);
    }
    Post[i] = n;
    return i+1;
}

void recurcive_search(int node, int root) {
    for (int i=0; i<n; i++) {
        if (In[i]==node) {
            if (T[root].l==-1) {
                T[root].l=node;
                T[node].p=root;
                return;
            } else {
                recurcive_search(node, T[root].l);
                return;
            }
        } else if (In[i]==root) {
            if(T[root].r==-1) {
                T[root].r=node;
                T[root].p=root;
                return;
            } else {
                recurcive_search(node, T[root].r);
                return;
            }
        }
    }
}

int reconstruct_tree() {
    int i, root;
    for (i=0; i<n; i++) {
        if (i==0) root = Pre[0];
        else {
            recurcive_search(Pre[i], root);
        }
    }
    return root;
}

int main() {
    int i, root;
    for (i=0; i<MAX; i++) T[i].p=T[i].l=T[i].r=-1;
    scanf("%d", &n);
    for (i=0; i<n; i++) scanf("%d", &Pre[i]);
    for (i=0; i<n; i++) scanf("%d", &In[i]);
    
    root = reconstruct_tree();
    postorder(0, root);

    for (i=0; i<n; i++) {
        if (i==0) printf("%d", Post[i]);
        else printf(" %d", Post[i]);
    }
    printf("\n");

    return 0;
}


Measured memory_bytes: 2672
from collections import deque
#双方向リストにするため、dequeを使用する
#（先頭と末尾に文字を追加するため）
s = deque(input())
q = int(input())

#一番最後に1度だけ反転すればよい
reverse_count = 0
for i in range(q):
  y = input().split()
  if y[0] == '1':
    #反転は最後に行う
    reverse_count += 1
    continue
  elif y[0] == '2':
    if y[1] == '1':
      #文字列の先頭に追加。反転回数が奇数なら、末尾に追加と同義
      if reverse_count % 2 == 1:
        s.append(y[2])
      else:
        s.appendleft(y[2])
    elif y[1] == '2':
      #文字列の末尾に追加。反転回数が奇数なら、先頭に追加と同義
      if reverse_count % 2 == 1:
        s.appendleft(y[2])
      else:
        s.append(y[2])

#最後に一度だけ反転させる
if reverse_count % 2 == 0:
  #元の順序に戻るので、そのまま
  print("".join(s))
else:
  s.reverse()
  print("".join(s))



Measured memory_bytes: 8564
import sys, re
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log2
from itertools import accumulate, permutations, combinations, combinations_with_replacement, product, groupby
from operator import itemgetter, mul
from copy import deepcopy, copy
from string import ascii_lowercase, ascii_uppercase, digits
from bisect import bisect, bisect_left
from fractions import gcd
from heapq import heappush, heappop
from functools import reduce
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def ZIP(n): return zip(*(MAP() for _ in range(n)))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

N = INT()
S = input()

ans = 0
for i in range(1, N):
	S1 = S[:i]
	S2 = S[i:]
	ans = max(ans, len(set(S1) & set(S2)))

print(ans)

Measured memory_bytes: 5200
#ifdef __APPLE__
#include "bits:stdc++.h"
#else
#include <bits/stdc++.h>
#endif

using namespace std;
typedef long long LL;
typedef pair<LL, LL> PLL;

vector<LL> ver,g[100000];

LL vis[100000];
bool isbi(LL a){
  ver.push_back(a);
  bool ok = 1;
  for(LL v: g[a] ) {
    if(vis[v] == -1){
      vis[v] = !vis[a];
      ok &= isbi(v);
    }
    else ok &= vis[a] xor vis[v];
  }
  return ok;
}
int main() {
  memset(vis,-1,sizeof(vis));
  LL n, m, u, v; scanf("%lld%lld", &n, &m);
  for ( LL i = 0; i < m; ++i ) scanf("%lld%lld", &u, &v), --u, --v, g[u].push_back(v), g[v].push_back(u);
  m = -m;
  for ( LL i = 0; i < n; ++i ){
    if(-1 == vis[i]){
      ver.clear();
      vis[i] = 1;
      bool bi = isbi(i);
      if(bi){
        LL ch[2] = {0};
        for(LL v:ver) ++ch[vis[v]];
        m += ch[0] * ch[1];
      }
      else m += (LL) ver.size()*(ver.size() - 1)/2;
    }
  }
  printf("%lld\n",m);
}



Measured memory_bytes: 9208