akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <assert.h>
#include <cstdio>

// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

inline bool chmin(ll &a, ll b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}

inline bool chmax(ll &a, ll b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

//桁数取得
template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}
//整数乗
ll llpow(ll a, ll n)
{
    if (n == 0)
    {
        return 1;
    }
    else
    {
        ll rep = a;
        for (ll i = 1; i < n; i++)
        {
            rep *= a;
        }
        return rep;
    }
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

template <typename T>
T amarinasi(T a, T b)
{
    if (a % b == 0)
    {
        return a / b;
    }
    else if (a % b > 0)
    {
        return a / b + 1;
    }
    else
    {
        return a / b - 1;
    }
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

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

//連想配列[素因数f.first][個数f.second]
template <typename T>
map<T, T> soinsuubunkai(T n)
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

int main()
{
    ll n;
    cin >> n;
    ll ans = 0;
    for (auto f : soinsuubunkai(n))
    {
        if (f.second == 0)
        {
            continue;
        }
        ll tmp = 0;
        ll i = 0;
        while (1)
        {
            if (f.second < tmp)
            {
                ans += i - 1;
                break;
            }
            i++;
            tmp += i;
        }
    }
    cout << ans << endl;
}

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define ALL(a) (a).begin(), (a).end()
#define rALL(a) (a).rbegin(), (a).rend()
#define SZ(x) ((int)(x).size())
using ll = long long;
using P = pair<int, int>;
using llP = pair<ll, ll>;
using DoP = pair<double, double>;
const int di[] = {0, 1, 0, -1, 1, 1, -1, -1};
const int dj[] = {1, 0, -1, 0, 1, -1, 1, -1};
const int INF = 1 << 29;
const ll INF64 = 1ll << 55;
const int mod = 1000000007;
//const int mod = 998244353;

template <class T>inline bool chmin(T &a, const T b)
{
  if (a > b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline bool chmax(T &a, const T b)
{
  if (a < b)
  {
    a = b;
    return true;
  }
  return false;
}
template <class T>inline void line_out(const vector<T> vec) {
  int n = SZ(vec);
  rep(i, n) {
    cout << vec[i];
    if(i < n-1) cout << " ";
  }
  cout << endl;
  return;
}

struct mint
{
  ll x; // typedef long long ll;
  mint(ll x = 0) : x((x % mod + mod) % mod) {}
  mint operator-() const { return mint(-x); }
  mint &operator+=(const mint a)
  {
    if ((x += a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator-=(const mint a)
  {
    if ((x += mod - a.x) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator*=(const mint a)
  {
    (x *= a.x) %= mod;
    return *this;
  }
  mint operator+(const mint a) const
  {
    mint res(*this);
    return res += a;
  }
  mint operator-(const mint a) const
  {
    mint res(*this);
    return res -= a;
  }
  mint &operator++()
  {
    if ((x += 1) >= mod)
      x -= mod;
    return *this;
  }
  mint &operator--()
  {
    if ((x += mod - 1) >= mod)
      x -= mod;
    return *this;
  }
  mint operator*(const mint a) const
  {
    mint res(*this);
    return res *= a;
  }
  mint pow(ll t) const
  {
    if (!t)
      return 1;
    mint a = pow(t >> 1);
    a *= a;
    if (t & 1)
      a *= *this;
    return a;
  }

  // for prime mod
  mint inv() const
  {
    return pow(mod - 2);
  }
  mint &operator/=(const mint a)
  {
    return (*this) *= a.inv();
  }
  mint operator/(const mint a) const
  {
    mint res(*this);
    return res /= a;
  }
};
// h(n, r) = c(n+r-1, r)
struct combination
{
  vector<mint> fact, ifact;
  combination(int n) : fact(n + 1), ifact(n + 1)
  {
    assert(n < mod);
    fact[0] = 1;
    for (int i = 1; i <= n; ++i)
    fact[i] = fact[i - 1] * i;
    ifact[n] = fact[n].inv();
    for (int i = n; i >= 1; --i)
    ifact[i - 1] = ifact[i] * i;
  }
  mint operator()(int n, int k)
  {
    if (k < 0 || k > n)
    return 0;
    return fact[n] * ifact[k] * ifact[n - k];
  }
};
int main()
{
  int n, m, k;
  cin >> n >> m >> k;
  combination C(n*m);
  mint ans = 0;
  for(ll d = 1ll; d <= m-1; ++d) ans += d*(m-d)*n*n;
  for(ll d = 1ll; d <= n-1; ++d) ans += d*(n-d)*m*m;
  ans *= C(n*m-2, k-2);
  cout << ans.x << endl;
}


Measured memory_bytes: 3328
import math
from functools import reduce
from collections import deque

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n = int(input())
reviews = []
for i in range(n):
    s,p = input().split(" ")
    p = int(p)
    reviews.append((i,s,p))

reviews.sort(key=lambda a:a[2], reverse=True)
reviews.sort(key=lambda a:a[1])

for r in reviews:
    print(r[0]+1)

Measured memory_bytes: 3564
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#include<set>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
#define FOR(i,n) for(int (i)=0;(i)<(n);(i)++)
#define FOR1(i,n) for(int (i)=1;(i)<(n);(i)++)
#define eFOR(i,n) for(int (i)=0;(i)<=(n);(i)++)
#define eFOR1(i,n) for(int (i)=1;(i)<=(n);(i)++)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i) sort((i).begin(),(i).end(), greater<int>());
#define YES(i) cout << ((i) ? "Yes" : "No") << endl;
constexpr auto INF = 1000000000;
constexpr auto LLINF = 922337203685477580;//7;
constexpr auto mod = 1000000007;

int main() {

	int n, k;
	cin >> n >> k;
	string s;
	cin >> s;
	k--;
	if (s[k] == 'A')s[k] = 'a';
	if (s[k] == 'B')s[k] = 'b';
	if (s[k] == 'C')s[k] = 'c';
	cout << s << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <cstdlib>
#include <algorithm>
#include <sstream>
#include <bitset>
#include <math.h>
#include <vector>
#include <set>
using namespace std;

int main (){
    int N, sum = 0;
    cin >> N;
    vector<int> p(N);

    for(int i = 0; i < N; i++){
        cin >> p.at(i);
    }

    sort(p.begin(), p.end());

    int max = p.back();

    for(int i = 0; i < N; i++){
        sum += p.at(i);
    }

    cout << sum - (max/2) << endl;
}

Measured memory_bytes: 256
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<functional>
#include<iomanip>
#include<iostream>
#include<list>
#include<map>
#include<queue>
#include<random>
#include<set>
#include<stack>
#include<string>
#include<utility>
#include<vector>

#define FOR(i,a,b) for(long long i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define FORR(i,a,b) for(long long i=(a);i>=(b);--i)
#define REPR(i,n)   FORR(i,n,0)

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll>pll;

int main() {
	ll N,P;
    cin>>N>>P;

    int isprime[1000010]={0};
	isprime[0]=0;
    isprime[1]=0;
    FOR(i,2,1000000+1){
        isprime[i]=1;
    }
    FOR(i,2,1000000+1){
        if(isprime[i]){
            for(int j=i+i;j<1000000+1;j+=i){
                isprime[j]=0;
            }
        }
    }
    ll ans=1;
    for(ll i=2;i<=1000000+1;++i){
        ll cnt=0;
        if(isprime[i]){
            while(P%i==0){
                cnt++;
                P/=i;
            }
            ans*=pow(i,cnt/N);
        }
    }
    if(N==1){
        ans*=P;
    }
    
    cout<<ans<<endl;
	
	return 0;
}


Measured memory_bytes: 4224
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<ll, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
typedef vector<int> vec;
typedef vector<vector<int>> mat;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << 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; }
//#define int long long

//pair<値,位置のインデックス>でソートしておけば、位置がわかる！！
//大きい順、小さい順にみて、データ構造をうまく使い計算量を減らす
//XについてYを数えたものの合計を、YについてXを数えたものの合計と言い換える

void solve() {
	int n; cin >> n;
    vector<P> p(n);
    rep(i, n) {
        ll x; cin >> x;
		p[i] = P(x, i);
    }
	sort(all(p));
	reverse(all(p));
	//自分より大きいもの位置さえわかれば良さそう
	//大きい順に考えればok
	ll ans = 0;
	multiset<int> se;
	se.insert(-1);
	se.insert(-1);
	se.insert(n);
	se.insert(n);
    rep(i, n) {
		ll y = p[i].fr; int k = p[i].sc;
		se.insert(k);
		auto ite = se.lower_bound(k);
		auto ma2 = ite, ma1 = ite, mi1 = ite, mi2 = ite;
		ma1 ++; ma2 ++; ma2 ++; mi1 --; mi2 --; mi2 --;
		ans += y * ((*ma2 - *ma1) * (*ite - *mi1) + (*mi1 - *mi2) * (*ma1 - *ite));
	}
	cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 6528
#include <bits/stdc++.h>
#include <atcoder/all>
using namespace std;
using namespace atcoder;
using ll = long long;
using ull = unsigned long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vvl = vector<vl>;
using Pt = pair<int, int>;

int main() {
	int N, M;
	cin >> N >> M;
	dsu d(N);
	for (int i = 0; i < M; ++i) {
		int a, b;
		cin >> a >> b;
		--a; --b;
		d.merge(a, b);
	}
	cout << d.groups().size() - 1 << endl;
	return 0;
}

Measured memory_bytes: 8944
#include<iostream>
#include<algorithm>
#include<math.h>
#include<iomanip>
using namespace std;
typedef long long ll;

int main(){
  ll n,k;cin>>n>>k;
  double ans=0;
  for(int i=1;i<=n;i++){
      ll j,p=i;
      for(j=0;p<k;j++,p*=2){}
      ans+=pow(0.5,j);
  }
  ans=ans/(double)n;
  cout<<fixed<<setprecision(9)<<ans<<endl;
  return 0;
}


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

int main() {
	int n ; cin >> n ; 
	std::vector<vector<int> > v;
	v.resize(n+1) ; 
	for ( int i=1; i<=n; ++i ) {
		v[i].resize(3) ; 
		cin >> v[i][0] >> v[i][1] >> v[i][2] ; 
	}
	std::vector<vector<int> > dp;
	dp.resize(n+1) ; 
	dp[0].resize(3) ;
	dp[0][0] = 0 ; 
	dp[0][1] = 0 ; 
	dp[0][2] = 0 ;
	for ( int i=1; i<=n; ++i ) {
		dp[i].resize(3) ; 
		dp[i][0] = max(dp[i-1][1]+v[i][0],dp[i-1][2]+v[i][0]) ; 
		dp[i][1] = max(dp[i-1][0]+v[i][1],dp[i-1][2]+v[i][1]) ; 
		dp[i][2] = max(dp[i-1][0]+v[i][2],dp[i-1][1]+v[i][2]) ; 	 
	}
	cout << max(dp[n][0],max(dp[n][1],dp[n][2])) << endl ;
	return 0 ; 
}

Measured memory_bytes: 11136
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
 
public class Main {
	public void exec() throws IOException {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        PrintWriter out = new PrintWriter(System.out);
        while(true) {
        	int n = Integer.parseInt(br.readLine());
        	if(n==0) break;
        	double[] s = Arrays.stream(br.readLine().split(" ")).mapToDouble(Double::parseDouble).toArray();
        	double m = Arrays.stream(s).average().getAsDouble();
        	out.printf("%.4f\n",Math.sqrt(Arrays.stream(s).map(si -> Math.pow(si-m,2)).sum()/n));
        }
        out.flush();
    }
  
    public static void main(String[] args) throws IOException {
        new Main().exec();
    }
}

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

int solve(int x, int y) {
    if (x <= y && (y >= 0 && x >= 0 || y <= 0 && x <= 0)) {
        return y - x;
    } else if (-x <= y) {
        return solve(-x, y) + 1;
    } else {
        return solve(x, -y) + 1;
    }
}

int main() {
    int x, y;
    cin >> x >> y;
    cout << solve(x, y);
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  ll S = 0, m = 1e18;
  int cnt = 0;
  bool flag = false;
  REP(i, N){
    ll tmp; cin >> tmp;
    if(tmp < 0) cnt++;
    if(tmp == 0) flag = true;
    m = min(m, abs(tmp));
    S += abs(tmp);
  }
  if(cnt%2 == 1 && flag == false){
    cout << S - 2 * m << endl;
  }else{
    cout << S << endl;   
  }
}

Measured memory_bytes: 256
package main

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

var sc = bufio.NewScanner(os.Stdin)

func main() {
    var n string
    if sc.Scan() {
        n = sc.Text()
    }
    
    num, _ := strconv.Atoi(n)

    if num % 2 == 1 {
        fmt.Println(float64(num/2+1)/float64(num))
    } else {
        fmt.Println(float64(num/2)/float64(num))
    }
}

Measured memory_bytes: 640
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>

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

int main(int argc, char* argv[]) {
  // RRLLLLRLRRLL
  // x
  //   x
  //     x

  string s;
  cin >> s;
  vector<int> count(s.length());

  int i = 0;
  while (i < s.length()) {
    int rs = i;
    int rl = 0;
    while (s[i] == 'R') {
      ++rl;
      ++i;
    }
    int ls = i;
    int ll = 0;
    while (s[i] == 'L') {
      ++ll;
      ++i;
    }

    for (int j = rs; j < rs + rl - 1; ++j) {
      count[j] = 0;
    }
    count[rs + rl - 1] = (rl + 1) / 2 + ll / 2;
    count[ls] = rl / 2 + (ll + 1) / 2;
    for (int j = ls + 1; j < ls + ll - 1; ++j) {
      count[j] = 0;
    }
  }

  for (const auto c : count) {
    cout << c << " ";
  }

  return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0;i<n;i++)
using namespace std;
template<class T>bool chmax(T &a, const T &b) { if (b>a) { 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; }
const long long INF = 2LL << 60;
using ll = long long;
using P = pair<ll, ll>;
struct Node{
    int num;
    int pre;
    int cnt;
};
int main(int argc, char const *argv[]){
    ll n;
    cin >> n;
//    n--;
    vector<char> ans;
    while(n>0){
        if(n%26==0){
            ans.push_back('z');
            n--;
        }else {
            ans.push_back('a' + n % 26 - 1);
        }
        n/=26;
    }
    rep(i,ans.size()){
        cout << ans[ans.size()-i-1];
    }
    cout << endl;

    return 0;
}




Measured memory_bytes: 3628
import math
n = int(input())
s = [input() for _ in range(n)]

cnt = 0

for i, item in enumerate(s):
    s[i] = ''.join(sorted(s[i]))
s = sorted(s)


def combinations_count(n, r):
    return math.factorial(n) // (math.factorial(n - r) * math.factorial(r))


cnt2 = 0
for i in range(n-1):
    if s[i] == s[i+1]:
        if cnt2 == 0:
            cnt2 += 2
        else:
            cnt2 += 1
    else:
        if cnt2 != 0:
            f = combinations_count(cnt2, 2)
            cnt += f
            cnt2 = 0

if cnt2 != 0:
    f = combinations_count(cnt2, 2)
    cnt += f
    cnt2 = 0
print(cnt)

Measured memory_bytes: 11496
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdlib>
#include<tuple>
#define int long 
using namespace std;

signed main() {
	int N,K,X,Y;
	cin >> N >> K >> X >> Y;
	if(N >= K) {
		cout << K * X + (N - K) * Y << endl;
	}
	else {
		cout << X * N << endl;
	}
}

Measured memory_bytes: 256
import java.util.Scanner;
 
public class Main{
  public static void main(String[] えーびーしー百三十八){
    Scanner 入力 = new Scanner(System.in);
    int これ以上 = 入力.nextInt();
    int 三千二百 = 3200;
    String 赤じゃないやつ = 入力.next();
    String 赤 = "red";
    if(これ以上 >= 三千二百)
      System.out.println(赤じゃないやつ);
    else
      System.out.println(赤);
  }
}

Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
#define fi first
#define se second
#define endl '\n'
#define y1 holyshit
#define all(x) x.begin(),x.end()
const int inf=0x3f3f3f3f;

ll X,K,D;

int main(){
	ios_base::sync_with_stdio(0); cin.tie(0);
	cin>>X>>K>>D;
	if(X<0) X*=-1LL;
	ll ans=0;
	if((double)K*(double)D<(double)X){
		double a=(double)X-(double)K*(double)D;
		cout<<(ll)a;
		return 0;
	}
	else{
		ans=X-(X/D)*D;
		if((K-X/D)%2==1) ans-=D;
	}
	cout<<abs(ans);
	return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>

using namespace std;

typedef long long ll;

int main() {
    int n, k = 0, i = 0;  cin >> n;
    vector<ll> a(n), x(n-1), y(n-1);
    for (int i = 0; i < n; i++)
        cin >> a[i];
    sort(a.begin(), a.end());
    while (k+1 < n-1 && a[k+1] < 0)   k++;
    ll ans = 0, p = a[n-1], m = a[0];
    for (int j = 1; j <= k; j++) {
        x[i] = p;   y[i] = a[j];
        p -= a[j];  i++;
    }
    for (int j = k+1; j < n-1; j++) {
        x[i] = m;   y[i] = a[j];
        m -= a[j];  i++;
    }
    x[i] = p;   y[i] = m;
    cout << p - m << endl;
    for (int j = 0; j < n-1; j++)
        cout << x[j] << " " << y[j] << endl;
    return 0;
}

Measured memory_bytes: 5636
import java.io.*;
import java.util.*;
import static java.lang.Math.*;

public class Main {
    public static void main(String[] args) {
        Main main = new Main();
        main.solve(args);
    }

    public void solve(String[] args) {
        MyScanner scanner = new MyScanner();
        int N = scanner.nextInt();
        int x = 0;
        int y = 0;
        int t = 0;
        for (int i = 0; i < N; i++) {
            int nextt = scanner.nextInt();
            int nextX = scanner.nextInt();
            int nextY = scanner.nextInt();
            int diff = Math.abs(nextX -x) + Math.abs(nextY -y);
            int tdiff = nextt - t;
            if (tdiff < diff) {
                System.out.println("No");
                return;
            }
            diff = tdiff - diff;
            if (diff < 0) {
                System.out.println("No");
                return;
            } else if (diff % 2 != 0){
                System.out.println("No");
                return;
            }
            x = nextX;
            y = nextY;
            t = nextt;
        }
        System.out.println("Yes");
    }

    static boolean isSquare(int n){
        double fsqrt = Math.sqrt(n);
        int m = (int) fsqrt;
        return m*m == n;
    }


    private class MyScanner {
        String[] s;int i;BufferedReader br;String reg = " ";
        MyScanner () {
            s = new String[0];i = 0;br = new BufferedReader(new InputStreamReader(System.in));
        }
        public String next() {
            try {
                if (i < s.length) return s[i++];
                String line = br.readLine();
                while (line.equals("")) {line = br.readLine();}
                s = line.split(reg, 0);
                i = 0;return s[i++];
            } catch (Exception e) {e.printStackTrace();}
            return null;
        }
        public int nextInt() {
            try {return Integer.parseInt(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public double nextDouble() {
            try {return Double.parseDouble(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
        public long nextLong()  {
            try {return Long.parseLong(next());} catch (Exception e) {e.printStackTrace();}
            return -1;
        }
    }
}


Measured memory_bytes: 43836
N = int(input())
S = input()
ans = 0
for i in range(1000):
  a = i//100
  b = i//10 % 10
  c = i % 10 
  target = a
  for d in S:
    if d == str(target):
      if str(target) == str(a):
        a = 999
        target = b
      elif str(target) == str(b):
        b = 999
        target = c
      elif str(target) == str(c):
        c = 999
        ans += 1
        break
print(ans)

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

#define each(i, c) for (auto& i : c)
#define mkp(a, b) make_pair(a, b)

typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9+7;

template<typename P, typename Q> ostream& operator << (ostream& os, pair<P, Q> p) { os << "(" << p.first << ": " << p.second << ")"; return os; }
template<typename T> ostream& operator << (ostream& os, vector<T> v) { os << "("; each (i, v) os << i << ", "; os << ")"; return os; }
template<typename K, typename V> ostream& operator << (ostream& os, map<K, V> m) { os << "{"; each (i, m) os << i << ", "; os << "}"; return os; }

int main() {
  string s;
  cin >> s;
  ll n = s.size();

  ll k;
  cin >> k;

  ll dp[105][2][k+1];
  memset(dp, 0, sizeof(dp));

  dp[0][0][0] = 1;
  for (ll i = 0; i < n; ++i) {
    for (ll j = 0; j < 2; ++j) {
      for (ll ki = 0; ki <= k; ++ki) {
        ll x = s[i] - '0';
        for (ll d = 0; d < 10; ++d) {
          ll in = i+1;
          ll jn = j;
          ll kn = ki;
          if (d > 0) ++kn;
          if (kn > k) continue;
          if (j == 0) {
            if (d > x) continue;
            if (d < x) jn = 1;
          }
          dp[in][jn][kn] += dp[i][j][ki];
        }
      }
    }
  }

  ll ans = dp[n][0][k] + dp[n][1][k];
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
n = int(input())
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())

m = min(a, b, c, d, e)

if m >= n:
    cnt = 1
elif n % m != 0:
    cnt = n // m + 1
else:
    cnt = n // m

print(cnt + 4)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <sstream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <complex>
using namespace std;

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;

#ifndef typeof
#define typeof __typeof__
#endif // typeof

#define all(c) (c).begin(), (c).end()
#define rall(c) (c).rbegin(), (c).rend()
#define tr(c, i) for(typeof((c).begin()) i = (c).begin(); i != (c).end(); i++)
#define rtr(c, i) for(typeof((c).rbegin()) i = (c).rbegin(); i != (c).rend(); i++)
#define repby(i, a, b, step) for(typeof(b) i = (a); i < (b); i += (step))
#define repab(i, a, b) repby(i, (a), (b), 1)
#define rep(i, n) repab(i, 0, (n))
#define pb push_back
#define sz(c) int((c).size())

int nsums(int n, int x)
{
  int res = 0;

  for (int a = 0; a < x; a++) {
    for (int b = a; b < x; b++) {
      for (int c = b; c < x; c++) {
        for (int d = c; d < x; d++) {
          if (a + b + c + d == n) {
            vi v;
            v.pb(a); v.pb(b); v.pb(c); v.pb(d);
            do {
              res++;
            } while (next_permutation(all(v)));
          }
        }
      }
    }
  }
  return res;
}

int main(int argc, char **argv)
{
  int n;

  while (cin >> n) {
    cout << nsums(n, 10) << endl;
  }

  return 0;
}

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

int main() {
    int N;
    cin >> N;
    vector<int> vec(N);
    for (int i = 0; i < N; i++) {
    cin >> vec.at(i);
    }

    sort(vec.begin(), vec.end());
  
 int syamu=1;
  
  for (int i = 0; i < N-1; i++) {
    if(vec.at(i) < vec.at(i+1) ){
      syamu +=1;
    }
  }
    
  cout << syamu << endl;
 
 }

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

//#define int long long
typedef long long ll;

typedef unsigned long long ul;
typedef unsigned int ui;
const ll mod = 1000000007;
const ll INF = mod * mod;
const int INF_N = 1e+9;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
#define all(v) (v).begin(),(v).end()
typedef pair<ll, ll> LP;
typedef long double ld;
typedef pair<ld, ld> LDP;
const ld eps = 1e-12;
const ld pi = acos(-1.0);
//typedef vector<vector<ll>> mat;
typedef vector<int> vec;

//繰り返し二乗法
ll mod_pow(ll a, ll n, ll m) {
	ll res = 1;
	while (n) {
		if (n & 1)res = res * a%m;
		a = a * a%m; n >>= 1;
	}
	return res;
}

struct modint {
	ll n;
	modint() :n(0) { ; }
	modint(ll m) :n(m) {
		if (n >= mod)n %= mod;
		else if (n < 0)n = (n%mod + mod) % mod;
	}
	operator int() { return n; }
};
bool operator==(modint a, modint b) { return a.n == b.n; }
modint operator+=(modint &a, modint b) { a.n += b.n; if (a.n >= mod)a.n -= mod; return a; }
modint operator-=(modint &a, modint b) { a.n -= b.n; if (a.n < 0)a.n += mod; return a; }
modint operator*=(modint &a, modint b) { a.n = ((ll)a.n*b.n) % mod; return a; }
modint operator+(modint a, modint b) { return a += b; }
modint operator-(modint a, modint b) { return a -= b; }
modint operator*(modint a, modint b) { return a *= b; }
modint operator^(modint a, int n) {
	if (n == 0)return modint(1);
	modint res = (a*a) ^ (n / 2);
	if (n % 2)res = res * a;
	return res;
}

//逆元(Eucledean algorithm)
ll inv(ll a, ll p) {
	return (a == 1 ? 1 : (1 - p * inv(p%a, a)) / a + p);
}
modint operator/(modint a, modint b) { return a * modint(inv(b, mod)); }

const int max_n = 1 << 18;
modint fact[max_n], factinv[max_n];
void init_f() {
	fact[0] = modint(1);
	for (int i = 0; i < max_n - 1; i++) {
		fact[i + 1] = fact[i] * modint(i + 1);
	}
	factinv[max_n - 1] = modint(1) / fact[max_n - 1];
	for (int i = max_n - 2; i >= 0; i--) {
		factinv[i] = factinv[i + 1] * modint(i + 1);
	}
}
modint comb(int a, int b) {
	if (a < 0 || b < 0 || a < b)return 0;
	return fact[a] * factinv[b] * factinv[a - b];
}
using mP = pair<modint, modint>;

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



void solve() {
	int N, M; cin >> N >> M;
    vector<LP> pv;
    rep(i, N){
        int a; cin >> a;
        pv.push_back(make_pair(a, 1));
    }
    rep(i, M){
        int b,c; cin >> b >> c;
        pv.push_back(make_pair(c, b));
    }

    sort(all(pv), greater<LP>());
    ll cnt=0;
    ll res=0;
    rep(i, N+M){
        if(cnt + pv[i].second > N){
            res += pv[i].first * (N-cnt);
            break;
        }
        res += pv[i].first * pv[i].second;
        cnt += pv[i].second;
    }

    cout << res << endl;
}

signed main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  //cout << fixed << setprecision(10);
  //init_f();
  //init();
  //int t; cin >> t; rep(i, t)solve();
  solve();
//   stop
    return 0;
}


Measured memory_bytes: 10608
import Data.List

main = do
  s <-getLine
  let ans = compute s
  print ans

compute :: String -> Int
compute s = head $ tail
  [ l
  | (s1,l) <- reverse $ zip (inits s) [0..]
  , even l
  , let (as,bs) = splitAt (div l 2) s1
  , as == bs
  ]


Measured memory_bytes: 1020
# -*- coding: utf-8 -*-
"""
A - Red or Not
https://atcoder.jp/contests/abc138/tasks/abc138_a

"""
import sys


def solve(a, s):
    return s if a >= 3200 else 'red'


def main(args):
    a = int(input())
    s = input()
    ans = solve(a, s)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main() {
	int X; cin >> X;
	vector<int> arr(110000, 1);
	for (int i = 2; i * i < 110000; i++)
	{
		if(arr[i]) {
			for (int j = 0; i * (j+2) < 110000; j++)
			{
				arr[i*(j+2)] = 0;
			}
		}
	}
	
	for (int i = X; i < 110000; i++)
	{
		if(arr[i]) {
			cout << i << endl;
			return 0;
		}
	}
	
	return 0;
}


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


int main(){

	int N;
	cin >> N;
	int S = 0, M = 0;
	for (int i = 0;i < N;i++) {
		int p;
		cin >> p;
		S += p;
		M = max(p, M);
}
	cout << S - M / 2 << endl;

	return 0;
}

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

using namespace std;

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
const int N = 2e5+50;
const int M = 1e6;
const ll oo = 1e18;
const int mod = 1e9+7;

int dp[N][2],a[110];
int n,k;

int calc(int k,int t){
	if(k <= 0)return 1;
	int &ret = dp[k][t];
	if(ret != -1)return !ret;
	ret = 0;
	for(int i=0;i<n;i++){
		if(a[i] > k)continue;
		ret |= calc(k-a[i],!t);
	}
	return !ret;
}

int main(){
	memset(dp,-1,sizeof(dp));
	cin>>n>>k;
	for(int i=0;i<n;i++)cin>>a[i];
	cout << (calc(k,0) ? "Second" : "First") << endl;
}

Measured memory_bytes: 9600
from sys import exit

n=int(input())
w=input()

a=set()
a.add(w)
w=w[-1]
cnt=0

for _ in range(n-1):
	x=input()
	if x in a or w!=x[0]:
		cnt=1
	w=x[-1]
	a.add(x)

if cnt==0:
	print("Yes")
else:
	print("No")

Measured memory_bytes: 3064
#include <iostream>
#include <stdio.h>
#include <string.h>

using namespace std;

int n, i, j, k, v, ok, maze[200][200], memo[200][200];

const int INF = 10000001;

int main(void) {
    while(1) {
        scanf("%d", &n);
        if(n == 0) break;

        ok = 0;
        memset(memo, 0, sizeof(memo));

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

        for(i = 0; i < n; i++) {
            int m = INF;
            for(j = 0; j < n; j++) {
                if(maze[i][j] <= m) {
                    m = maze[i][j];
                }
            }
            for(j = 0; j < n; j++) {
                if(maze[i][j] == m) {
                    memo[i][j] += 1;
                }
            }
        }

        for(j = 0; j < n; j++) {
            int m = -1;
            for(i = 0; i < n; i++) {
                if(maze[i][j] >= m) {
                    m = maze[i][j];
                }
            }
            for(i = 0; i < n; i++) {
                if(maze[i][j] == m) {
                    memo[i][j] += 1;
                }
            }
        }

        for(i = 0; i < n; i++) {
            for(j = 0; j < n; j++) {
                if(memo[i][j] == 2) {
                    v = maze[i][j];
                    ok = 1;
                }
            }
        }

        if(ok) {
            printf("%d\n", v);
        } else {
            printf("%d\n", 0);
        }
    }
    return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
using uint = unsigned int;
using lint = long long int;
using ulint = unsigned long long int;
template<class T = int> using V = vector<T>;
template<class T = int> using VV = V< V<T> >;
template<class T, class U> void assign(V<T>& v, int n, const U& a) { v.assign(n, a); }
template<class T, class... Args> void assign(V<T>& v, int n, const Args&... args) { v.resize(n); for (auto&& e : v) assign(e, args...); }


template<class T> struct ConvexHullTrick {
  struct Line { T a, b; };
  ConvexHullTrick(bool f = false) : monotone(f) {}
  void add(T a, T b) {
    if (l.empty() or a < l[0].a) {
      while (l.size() >= 2 and !is_need({a, b}, l[0], l[1])) {
        l.pop_front();
      }
      l.emplace_front((Line) {a, b});
    } else if (a > l.back().a) {
      while (l.size() >= 2 and !is_need(l[l.size() - 2], l.back(), {a, b})) {
        l.pop_back();
      }
      l.emplace_back((Line) {a, b});
    } else assert(false);
  }
  T max(T x) {
    if (monotone) {
      while (l.size() >= 2 and l[0].a * x + l[0].b <= l[1].a * x + l[1].b) {
        l.pop_front();
      }
      return l[0].a * x + l[0].b;
    }
    int ok = 0, ng = l.size();
    while (ng - ok > 1) {
      int m = ok + ng >> 1;
      (l[m - 1].a * x + l[m - 1].b <= l[m].a * x + l[m].b ? ok : ng) = m;
    }
    return l[ok].a * x + l[ok].b;
  }
private:
  deque<Line> l;
  bool monotone;
  bool is_need(const Line& l, const Line& m, const Line& r) {
    return m.b * (r.a - l.a) > l.b * (r.a - m.a) + r.b * (m.a - l.a);
  }
};

using CHT = ConvexHullTrick<lint>;

int main() {
  cin.tie(nullptr); ios_base::sync_with_stdio(false);
  int n; cin >> n;
  lint c; cin >> c;
  V<lint> h(n); for (int i = 0; i < n; ++i) cin >> h[i];
  CHT cht;
  V<lint> dp(n, 1e18);
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i] = 0;
    } else {
      dp[i] = -cht.max(h[i]) + h[i] * h[i] + c;
    }
    cht.add(2 * h[i], -(dp[i] + h[i] * h[i]));
  }
  cout << dp.back() << '\n';
}

Measured memory_bytes: 6656
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;
#define pai 3.141592653589793238462643383279


int main(){
    int a, b, h, m; cin >> a >> b >> h >> m;
    double tyou = 30*h + 0.5*m;
    double tann = 6*m;
    double kaku = min(360 - abs(tyou - tann), abs(tyou-tann));
    kaku = pai*(kaku/180);
    //cout << kaku << endl;
    double ans = a*a + b*b - 2*a*b*cos(kaku);
    //cout << ans << endl;
    printf("%.12lf\n", sqrt(ans));
}

Measured memory_bytes: 4192
use std::io;
use io_ext::Reader;

fn main() {
    let stdin = io::stdin();
    let mut r = Reader::new(io::BufReader::new(stdin.lock()));
    let n = r.read_line().parse().unwrap();
    // let n = 7;
    let dists: Vec<usize> = r.read_line().split_whitespace().map(|s| s.parse().unwrap()).collect();
    // let dists = vec![0, 3, 2, 1, 2, 2, 1];

    let mut counts: Vec<usize> = vec![0; n];
    for &d in &dists {
        counts[d] += 1;
    }

    if dists[0] != 0 || counts[0] != 1 {
        println!("{}", 0);
        return;
    }

    let mut count: usize = 1;
    let mut ans: usize = 1; 
    for i in 0..(counts.len() - 1) {
        let prev = counts[i];
        let curr = counts[i + 1];
        
        if curr == 0 {
            if count != dists.len() {
                ans = 0;
            }
            break;
        }

        count += curr;
        let mul = prev % 998244353;
        for _ in 0..curr {
            ans *= mul;
            ans %= 998244353;
        }
    }

    println!("{}", ans);
}

/// Extension of io module.
pub mod io_ext {
    use std::io::BufRead;

    pub struct Reader<R> {
        buf: String,
        inner: R,
    }

    impl<R> Reader<R> {
        #[inline]
        pub fn new(inner: R) -> Self {
            Reader { buf: String::new(), inner: inner }
        }

        #[inline]
        pub fn into_inner(self) -> R {
            self.inner
        }
    }

    impl<R: BufRead> Reader<R> {
        #[allow(deprecated)]
        #[inline]
        pub fn read_line(&mut self) -> &str {
            self.buf.clear();
            self.inner.read_line(&mut self.buf).unwrap_or_else(|e| panic!("{}", e));
            self.buf.trim_right()
        }
    }
}

/// Module supporting to parse strings.
pub mod parse {
    use std::str::FromStr;
    use std::borrow::Borrow;

    pub trait ParseNext: Iterator {
        fn parse_next<F: FromStr>(&mut self) -> F;
    }

    impl<'a, S: Borrow<str>, I: Iterator<Item=S>> ParseNext for I {
        fn parse_next<F: FromStr>(&mut self) -> F {
            if let Some(s) = self.next() {
                match s.borrow().parse() {
                    Ok(x) => x,
                    Err(_) => panic!("provided string cannot be parsed")
                }
            } else {
                panic!("iterator has no next element")
            }
        }
    }
}


Measured memory_bytes: 8444
S = input()
n = int(input())

d = 1
S1 = []
S2 = []
for i in range(n):
    Q = list(input().split())
    if Q[0] == '1':
        d *= -1
    else:
        f = Q[1]
        c = Q[2]
        if f == '1':
            if d == 1:
                S1.append(c)
            else:
                S2.append(c)
        else:
            if d == 1:
                S2.append(c)
            else:
                S1.append(c)
if d == 1:
    ans = ''.join(S1[::-1]) + S + ''.join(S2)
else:
    ans = ''.join(S2[::-1]) + S[::-1] + ''.join(S1)

print(ans)

Measured memory_bytes: 70232
#include <iostream>
#include <string>
#include <deque>
#include <vector>
typedef unsigned int UINT;
using namespace std;

int main(void) {
    int N, A, B;
    cin >> N >> A >> B;
    int plan1 = N * A;
    int plan2 = B;
    int ans = (plan1 < plan2) ? plan1 : plan2;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
    int N ;
    cin >> N ;
    vector<int> A(N);
    vector<double> B(N-1);
    for (int i = 0 ; i < N ; i++) {
        cin >> A.at(i) ;
    }
    //いつもの入力パターン
    sort(A.begin(),A.end());
    
     B.at(0) = ( A.at(0) + A.at(1) ) / 2.0;
    
    for (int i = 1 ; i < N - 1 ; i++) {
      B.at(i)  =  ( B.at(i-1) + A.at(i+1) ) / 2 ;
    }
    cout << fixed << setprecision(15) << B.at(N-2);
}


Measured memory_bytes: 256
x = int(input())
if 400 <= x < 600:
    ans = 8
elif 600 <= x < 800:
    ans = 7
elif 800 <= x < 1000:
    ans = 6
elif 1000 <= x < 1200:
    ans = 5
elif 1200 <= x < 1400:
    ans = 4
elif 1400 <= x < 1600:
    ans = 3
elif 1600 <= x < 1800:
    ans = 2
elif 1800 <= x < 2000:
    ans = 1
print(ans)

Measured memory_bytes: 9200
package main

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

func getScanner(fp *os.File) *bufio.Scanner {
	scanner := bufio.NewScanner(fp)
	scanner.Split(bufio.ScanWords)
	scanner.Buffer(make([]byte, 500001), 500000)
	return scanner
}

func getNextString(scanner *bufio.Scanner) string {
	scanner.Scan()
	return scanner.Text()
}

func getNextInt(scanner *bufio.Scanner) int {
	i, _ := strconv.Atoi(getNextString(scanner))
	return i
}

func getNextInt64(scanner *bufio.Scanner) int64 {
	i, _ := strconv.ParseInt(getNextString(scanner), 10, 64)
	return i
}

func main() {
	fp := os.Stdin
	if len(os.Args) > 1 {
		fp, _ = os.Open(os.Args[1])
	}

	scanner := getScanner(fp)
	writer := bufio.NewWriter(os.Stdout)

	n := getNextInt(scanner)
	d := getNextInt(scanner)

	ans := (n-1)/(2*d+1) + 1

	fmt.Fprintln(writer, ans)
	writer.Flush()
}


Measured memory_bytes: 640
import java.util.Scanner;

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

		String s2 = s1.substring(0, (s1.length() - 1) / 2);
		String s3 = s1.substring((s1.length() + 3) / 2 - 1);
		boolean result = isPalindrome(s1) && isPalindrome(s2) && isPalindrome(s3);

		System.out.println(result ? "Yes" : "No");
	}

	private static boolean isPalindrome(String text) {
		for (int i = 0; i < text.length(); i++) {
			String s1 = text.substring(i, i + 1);
			String s2 = text.substring(text.length() - i - 1, text.length() - i);
			if (!s1.equals(s2)) {
				return false;
			}
		}

		return true;
	}
}


Measured memory_bytes: 23636
#include <bits/stdc++.h>
using namespace std;
using lint = long long int;

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

    string s;
    cin >> s;

    for(auto& e : s) {
        e -= 'A';
        e += n;
        e %= 26;
        e += 'A';
    }

    cout << s << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void){
    int a, b;
    scanf("%d %d", &a, &b);
    if(a<=1000 && a>= -1000 && b<=1000 && b>= -1000 ){
        if(a < b){
            printf("a < b\n");
        }else if(a > b){
            printf("a > b\n");
        }else{
            printf("a == b\n");
        }
    }
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
using namespace std;
int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<pair<int, int>>> grh(n);
  for (int i = 0; i < m; i++) {
    int s, t, w;
    cin >> s >> t >> w;
    s--;
    t--;
    grh[s].push_back({w, t});
    grh[t].push_back({-w, s});
  }
  stack<int> stk;
  vector<int> prt(n, -1);
  vector<int> val(n);
  for (int i = 0; i < n; i++) {
    if (prt[i] != -1) {
      continue;
    }
    stk.push(i);
    prt[i] = i;
    val[i] = 0;
    while (!stk.empty()) {
      int crr = stk.top();
      stk.pop();
      for (auto e : grh[crr]) {
        int w = e.first;
        int nxt = e.second;
        if (prt[crr] == nxt) {
          continue;
        }
        if (prt[nxt] != -1) {
          if (val[nxt] - val[crr] != w) {
            cout << "No" << '\n';
            return 0;
          } else {
            continue;
          }
        }
        stk.push(nxt);
        prt[nxt] = crr;
        val[nxt] = val[crr] + w;
      }
    }
  }
  cout << "Yes" << '\n';
  return 0;
}

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


int main(){
    int n;
    cin>>n;
    vector<int> a(n);
    rep(i,n) cin>>a[i];

    vector<int> ans;
    vector<bool> b(n+1,false);
    for(int i=n;i>=1;i--){
        int sm=0;
        for(int j=i;j<=n;j+=i){
            if(b[j]) sm++;
        }

        if(a[i-1]==1 && sm%2==0){
            b[i]=true;
            ans.push_back(i);
        }
        else if(a[i-1]==0 && sm%2==1){
            b[i]=true;
            ans.push_back(i);
        }
    }

    cout<<ans.size()<<endl;
    if(ans.size()==0) return 0;
    rep(i,ans.size()){
        cout<<ans[i]<<" ";
    }
    cout<<endl;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#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)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

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

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

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

  int n;
  cin >> n;
  vint p(n);
  rep(i, n) cin >> p[i];
  vint a(n);
  rep(i, n) a[p[i]-1] = i;
  int ans = 0;
  int li = 0, ri = 1;
  while(ri < n) {
    if(a[ri] < a[ri-1]) {
      chmax(ans, ri-li);
      li = ri;
    }
    ++ri;
  }
  chmax(ans, ri-li);
  cout << n-ans << endl;

  return 0;
}


Measured memory_bytes: 3456
#include "iostream"
#include "climits"
#include "list"
#include "queue"
#include "stack"
#include "set"
#include "functional"
#include "algorithm"
#include "string"
#include "map"
#include "unordered_map"
#include "unordered_set"
#include "iomanip"
#include "cmath"
#include "random"
#include "bitset"
#include "cstdio"

using namespace std;

const long long int MOD = 1000000007;

long long int N, M, K, H, W, L, R;

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

	cin >> N >> M;
	if (N & 1 && M & 1) {
		cout << "Odd\n";
	}
	else {
		cout << "Even\n";
	}

	return 0;
}

Measured memory_bytes: 764
// Undone
#include <bits/stdc++.h>
#define int long long
#define double long double
#define INF 1e18
using namespace std;
signed main() {
  string s; cin >> s;
  int ans = 0;
  for (int i = 0; i < s.length(); i++) {
    int t = 0;
    for (int j = i; j < s.length(); j++) {
      if (s[j]=='A'||s[j]=='C'||s[j]=='T'||s[j]=='G') {
        t++;
      } else {
        break;
      }
    }
    ans = max(ans,t);
  } 
  cout<<ans<<endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#include "string"
#define endl '\n'
#define pi pair<int,int>
#define ff first
#define ss second
#define int long long 
#define boost ios_base::sync_with_stdio(false);cin.tie(nullptr)

const int N=1e5+5;
const int inf = 1e10;

int dp[101][N];
int n,w;
int a[101],v[101];

int solve(int id,int val){
    if(val<0)
        return -inf;
    if(id>n)
        return 0;
    int &tmp = dp[id][val];
    if(tmp != -1)
        return tmp;
    tmp = solve(id+1,val);
    tmp = max(tmp,solve(id+1,val-a[id])+v[id]);
    return tmp;
}
int32_t main() { 
    boost;
    cin>>n>>w;
    for(int i=1;i<=n;i++)
    	cin>>a[i]>>v[i];
    memset(dp,-1,sizeof dp);
    int ans=solve(1,w);
    cout<<ans<<endl;
}           





Measured memory_bytes: 79232
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

lli n, k;

int main(void){
    cin >> n >> k;
    lli ans = 0;
    for(lli b = k+1; b <= n; b++){
        ans+=n/b*(b-k) + max(0LL, n%b-k+1);
        if(k == 0) ans--;
        //cout << ans << endl;
    }
    cout << ans << endl;
    return 0;
}


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



int main(){
	string s;
	cin >> s;
	if (s.size() == 2) {
		cout << s << endl;
		return 0;
	}
	else {
		cout << s[2] << s[1] << s[0] << endl;
		return 0;
	}
}

Measured memory_bytes: 256
/*#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include<bits/stdc++.h>

using namespace std;
# define ll long long
# define int long long  //comment it out when MLE
# define endl "\n"
#define gok ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
# define mod 998244353
# define pi acos(-1)
# define fi first
# define se second
int add(int a, int b) {
	a += b;
	if (a >= mod) a -= mod;
	return a;
}

int mul(ll a, int b) {
	a *= b;
	return a % mod;
}
signed main()
{
    gok
  int a,b,c,d;
  cin>>a>>b>>c>>d;
  int c1 = (c-1)/b;
  int c2 = (a-1)/d;
  //cout<<c1<<" "<<c2<<endl;
    if(c1>c2)
    cout<<"No";
  else
    cout<<"Yes";


















    return 0;
    }


Measured memory_bytes: 3652
n,m=map(int,input().split())
ans=0
if n==3:
  ans+=100000
elif n==2:
  ans+=200000
elif n==1:
  ans+=300000
if m==3:
  ans+=100000
elif m==2:
  ans+=200000
elif m==1:
  ans+=300000
if n==1 and m==1:
  ans+=400000
print(ans)

Measured memory_bytes: 3060