akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using VI = vector<int>;
using VL = vector<ll>;
template<class T> using PQ = priority_queue<T, vector<T>, greater<T>>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define each(i, a) for(auto &i : a)
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x) ((y) < 0 || h <= (y) || (x) < 0 || w <= (x))
#define line cout << "------------------------\n" 
#define ENDL(i,n) ((i) == (n) - 1 ? "\n" : " ")
//#define stop system("pause") //comment out this on AOJ.
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
constexpr ld eps = 1e-10; //1e-9?
constexpr ld pi = 3.1415926535897932;
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& is, vector<T>& v) { for (auto& elemnt : v)is >> elemnt; return is; }
template<class T, class U>inline istream& operator>>(istream& is, pair<T, U>& p) { is >> p.first >> p.second; return is; }
template<class T>inline vector<T> vec(size_t a) { return vector<T>(a); }
template<class T>inline vector<T> defvec(T def, size_t a) { return vector<T>(a, def); }
template<class T, class... Ts>inline auto vec(size_t a, Ts... ts) { return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...)); }
template<class T, class... Ts>inline auto defvec(T def, size_t a, Ts... ts) { return vector<decltype(defvec<T>(def, ts...))>(a, defvec<T>(def, ts...)); }

using t3 = tuple<int, int, int>;
int main() {
    init();

    int n; cin >> n;
    VI s(n), l(n), p(n);
    FOR(i, 0, n)cin >> s[i] >> l[i] >> p[i];

    auto dp = defvec<int>(-1, n + 1, 394);
    eFOR(i, 0, n)dp[i][0] = 0;
    FOR(i, 0, n)eFOR(j, 0, 393) {
        eFOR(k, s[i], l[i]) {
            if (k <= j && dp[i + 1][j - k] != -1) {
                chmax(dp[i + 1][j], dp[i + 1][j - k] + p[i]);
            }
        }
        chmax(dp[i + 1][j], dp[i][j]);
    }

    int m; cin >> m;
    VI ans;
    FOR(q, 0, m) {
        int w; cin >> w;
        if (0 < dp[n][w])ans.push_back(dp[n][w]);
    }

    if (ans.size() < m)cout << "-1\n";
    else FOR(i, 0, m)cout << ans[i] << "\n";
}


Measured memory_bytes: 3408
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mood) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mood;
		}
		x = x * x % mood;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}

long double getRadian(double x, double y, double x2, double y2) {
	double radian = atan2(y2 - y, x2 - x);
	return radian;
}

int n, k, a[200000], f[200000];

signed main() {
	cin >> n >> k;
	for (int i = 0; i < n; i++)cin >> a[i];
	for (int i = 0; i < n; i++)cin >> f[i];
	sort(a, a + n);
	sort(f, f + n);
	reverse(f, f + n);
	int mi = -1, ma = 100000000000000;
	while (ma - mi > 1) {
		int md = (ma + mi) / 2;
		int cnt = 0;
		for (int i = 0; i < n; i++) {
			cnt += max((int)0, a[i] - md / f[i]);
		}
		if (cnt <= k) {
			ma = md;
		}
		else {
			mi = md;
		}
	}
	cout << ma << endl;
}

Measured memory_bytes: 3456
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

using namespace std;
using ll = long long;
using vpii = vector<pair<int, int>>;
using vpll = vector<pair<ll, ll>>;
// ceil() 切り上げ, floor() 切り捨て
// next_permutation(all(x))

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

	int ans = 0;
	for (int i = 1; i < n; i++)
	{
		string X = S.substr(0, i);
		bitset<26> XX;
		for (int j = 0; X[j]; j++)
		{
			int idx = X[j] - 'a';
			XX[idx] = true;
		}
		string Y = S.substr(i);
		bitset<26> YY;
		for (int j = 0; Y[j]; j++)
		{
			int idx = Y[j] - 'a';
			YY[idx] = true;
		}
		bitset<26> R = XX & YY;
		ans = max(ans, (int)R.count());
	}
	cout << ans << endl;
}



Measured memory_bytes: 256
#include <functional>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
using namespace std;
const ll MOD = 1000000007LL;

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

    int n;
    cin >> n;

    vector <int> x(n);
    for (int i = 0; i < n; i++) cin >> x[i];

    int ans = 1e9;
    for (int i = 1; i <= 1000; i++) {
        int sum = 0;
        for (int j = 0; j < n; j++) {
            sum += (i - x[j]) * (i - x[j]);
        }
        ans = min(ans, sum);
    }

    cout << ans << "\n";
    return 0;
}

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

int main() {
  int i = 0;
  double x,diff,height[100000];
  while(cin >> x) {
    height[i] = x;
    i++;
  }
  sort(height,height+i);
  diff = height[i-1] - height[0];
  cout << diff << endl;
}

Measured memory_bytes: 0
import numpy as np

N = int(input())
W = list(map(int, input().split()))

S_min = np.sum(W)
for T in range(N+1):
  S1 = np.sum(W[:T])
  S2 = np.sum(W[T:])
  dif = np.abs(S1 -S2)
  if dif <= S_min:
    S_min = dif
  else:
    print(S_min)
    break

Measured memory_bytes: 12500
import java.util.*;

class Main{
  public static void main(String[] args){
    Scanner scan = new Scanner(System.in);
    int a = scan.nextInt();
    int b = scan.nextInt();
    
    
   if(a>=1&&a<=9&&b>=1&&b<=9){
     System.out.println(a*b);
   }else{
     System.out.println(-1);
   }
     
  }
}


Measured memory_bytes: 22740
import sys

sys.setrecursionlimit(10 ** 7)
f_inf = float('inf')
mod = 10 ** 9 + 7


def resolve():
    n = int(input())

    if n % 2 == 0:
        print((n / 2) / n)
    else:
        print((n + 1) / 2 / n)


if __name__ == '__main__':
    resolve()


Measured memory_bytes: 2940
#include<stdio.h>
int main(void){
  int n,i,a[51],f,j;
  scanf("%d",&n);
  f=0;
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  for(i=0;i<n-1;i++){
    for(j=i+1;j<n;j++){
      f=f+a[i]*a[j];
    }
  }
  printf("%d\n",f);
  return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define INT long long int
using namespace std;
string s, t = "";
INT n, cnt;
bool f(string x)
{
    for(int i = 0, j = x.size()-1 ; i < j ; i++, j-- )
        if( x[i] != x[j] ) return false;
    return true;
}
int main()
{
    ios::sync_with_stdio(false);
    cin>>s; n = s.size();
    for(int i = 0 ; i < n ; i++ )
        if( s[i] != 'x') t+=s[i];
    for(int i = 0, j = s.size()-1 ; i < j ; i++, j-- )
    {
        if( s[i] == 'x' and s[j] != 'x' ) cnt++, j++;
        else if( s[i] != 'x' and s[j] == 'x' ) cnt++, i--;
    }
    if( f(t) ) cout<<cnt<<endl;
    else cout<<-1<<endl;
    return 0;
}


Measured memory_bytes: 592
n, m = map(int, input().split())

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

a.sort(reverse=True)

a.append(0)
b = 0

if n > 1:
    for i in range(m):
        a[b] //= 2

        if a[b] < a[0] or a[b] < a[b + 1]:
            if a[0] > a[b + 1]:
                b = 0
                a.sort(reverse=True)
            else:
                b += 1

else:
    for i in range(m):
        a[0] //= 2





print(sum(a))


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

int main() {
  int a, b;
  char op;
  cin >> a >> op >> b;
  
  if (op == '+') {
    cout << a + b << endl;
  }
  
  else if (op == '-') {
    cout << a - b << endl;
  }
  
  else if (op == '*') {
    cout << a * b << endl;
  }
  
  else if (op == '/') {
    cout << a / b << endl;
  }
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>
using namespace std;

int		main(void)
{
	string	a;
	cin >> a;
	int		j = a.size() - 1;
	for (int i = 0; i < a.size(); i++, j--)
	{
		if (a.at(i) != a.at(j))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	j = a.size() / 2 - 1;
	for (int i = 0; i < a.size() / 2; i++, j--)
	{
		if (a.at(i) != a.at(j))
		{
			cout << "No" << endl;
			return 0;
		}
	}
	cout << "Yes" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long LL;
std::vector<int> vc;
int main()
{
    int N, R;
    std::cin >> N >> R;
    if (N >= 10)
    {
        std::cout<<R<<'\n';
    }else
    {
        int mu = 100 * (10 - N);
        std::cout<<(R + mu)<<'\n';
    }
    
}

Measured memory_bytes: 256
s = input()
s_out = ""
s = s[1:] if s[0] == "B" else s
for c in s:
  if c == "B":
    s_out = s_out[:-1]
  elif c == "0":
    s_out += "0"
  elif c == "1":
    s_out += "1"
print(s_out)    

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

using namespace std;

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

  int N; cin>>N;

  for (int i = 0; i < N; i++) {
    for (int j = i+1; j < N; j++) {
      auto n = i xor j;
      int c = 0;
      while ((n bitand 1) == 0){
        c++;
        n >>= 1;
      }
      cout << c+1 << ' ';
    }
    cout << endl;
  }

  return 0;
}


Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
int pw(int n,int k){
  if(k<0)return pw(n,k+MOD-1);
  int res=1;
  while(k){
    if(k&1)res*=n;//res%=MOD;
    n*=n;//n%=MOD;
    k>>=1;
  }
  return res;
}
//main
signed main(){
  int N;cin>>N;
  int R=pw(2,N);
  typedef pair<int,int> P;
  set<P> s;
  P m=P(0,0);
  for(int i=0;i<R;i++){
    int a;cin>>a;a*=2;if(m.first<a)m=P(a,i);
    s.insert(P(a,i));
  }
  s.insert(P(-LINF,0));
  std::vector<P> w(R);
  w[0]=m;s.erase(m);
  for(int i=0;i<N;i++){
    for(int j=0;j<pw(2,i);j++){
      int a=w[j].first-1,b=w[j].second;
      P p=*--s.lower_bound(P(a,b));
      if(p.first<-10000)fin("No");
      w[j+pw(2,i)]=p;s.erase(p);
    }
  }
  fin("Yes");
}


Measured memory_bytes: 20736
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <ctime>
#include <climits>
#include <cfloat>
#include <cctype>
#include <string>
#include <vector>
#include <list>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include <complex>
#include <utility>
#include <memory>
#include <iomanip>
#include <algorithm>
#include <functional>
#include <sstream>
#include <assert.h>
using namespace std;
typedef long long ll;
 
int N;
ll k, A[202000], sum[202000];
map<int, int> mp;
 
int main()
{
    cin >> N >> k;
    for (int i = 0; i < N; i++)
        cin >> A[i];
    for (int i = 0; i < N; i++)
    {
        sum[i + 1] = sum[i] + A[i];
        sum[i + 1] %= k;
    }
    ll res = 0;
    for (int i = 0; i <= N; i++)
    {
        sum[i] -= i;
      sum[i]=((sum[i]%k)+k)%k;
        if (i >= k)
            mp[(int)sum[i - k]]--;
        res += mp[(int)sum[i]];
        mp[(int)sum[i]]++;
    }
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 12800
<?php
fscanf(STDIN, "%d", $N);
$A = explode(" ", trim(fgets(STDIN)));

if (!in_array("1", $A)){
    echo -1;
    die();
}

$i = 1;
$val = 0;
foreach ($A as $a){
    if (intval($a) == $i){
        $val++;
        $i++;
    }
}
echo $N - $val;

Measured memory_bytes: 39832
#include<stdio.h>

int N = 100;

int main(){
  int M[N][N];
  int n, u, k, v, i, j;

  scanf("%d", &n);

  for(i=0; i<n; i++){
    for(j=0; j<n; j++) M[i][j] = 0;
  }

  for(i=0; i<n; i++){
    scanf("%d%d", &u, &k);
    u--;
    for(j=0; j<k; j++){
      scanf("%d", &v);
      v--;
      M[u][v] = 1;
    }
  }

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

  return 0;
}


Measured memory_bytes: 2060
s = input()
q = int(input())

head = []
tail = []
flip = 0

for _ in range(q):
	query = input().split()
	if query[0] == '1':
		flip ^= 1
	else:
		f = query[1]
		c = query[2]
		if (f == '1' and flip == 0) or (f == '2' and flip == 1):
			head.append(c)
		else:
			tail.append(c)

if flip:
	head, tail = tail, head
	s = s[::-1]

head = ''.join(head)
tail = ''.join(tail)

print(head[::-1] + s + tail)

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

long long GCD(long long C, long long D){

    if(C < D){
        long long temp;
        temp = C;
        C = D;
        D = temp;
    }

    long long temp;

    while(C % D != 0){
        temp = C; 
        C = D;
        D = temp % D;
    }

    return D;
}

long long LCM(long long C, long long D){
    return (C*D) / GCD(C,D);
}

int main(){

    long long A,B,C,D;

    scanf("%ld %ld %ld %ld",&A,&B,&C,&D);

    /*long long gcd = GCD(C,D);
    long long lcm = LCM(C,D);

    cout << "最大公約数は" << gcd << endl;
    cout << "最小公倍数は" << lcm << endl;*/

    long long ans = (B - A + 1) - ((B/C + B/D - B/LCM(C,D)) - ((A-1)/C + (A-1)/D - (A-1)/LCM(C,D)));

    cout << ans << endl;

    return 0;
}

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

long long d[310][310];

int main() {
    int n, m; long long l; cin >> n >> m >> l;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            if (i != j) d[i][j] = 1e16;
        }
    }
    
    for (int i = 0; i < m; i++) {
        int a, b; long long c; cin >> a >> b >> c;
        a--; b--; d[a][b] = c; d[b][a] = c;
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            d[i][j] = d[i][j] > l ? 1e16 : 1;
        }
    }

    for (int i = 0; i < n; i++) {
        for (int j = 0; j < n; j++) {
            for (int k = 0; k < n; k++) {
                d[j][k] = min(d[j][k], d[j][i] + d[i][k]);
            }
        }
    }
    
    int q; cin >> q;
    while (q--) {
        int s, t; cin >> s >> t; s--; t--;
        if (d[s][t] == 1e16) cout << -1 << "\n";
        else cout << max(d[s][t]-1, 0LL) << "\n";
    }
    return 0;
}

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

//repetition
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;


//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}


int main(){
  int n;
  cin >> n;
  VVI days(n, VI(3,0) );

  rep(i,n)rep(j,3){
    cin >> days[i][j];
  }

  VVLL dp(n+1,VLL(3,0));


  rep(i,n){
    rep(j,3){
      rep(k,3){
        if(j == k) continue;
        dp[i+1][k] = max(dp[i+1][k],dp[i][j] + days[i][k]);
      }
    }
  }
  ll ans = 0;
  rep(i,3) ans = max(dp[n][i],ans);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 11264
def solve_():
    import itertools
    N, x = map(int, input().split())
    a = list(map(int, input().split()))
    s_cost = a.copy()
    cost = sum(s_cost)

    for k, i in itertools.product(range(1, N), range(N)):
        s_cost[i] = a[(i - k) % N] if s_cost[i] > a[(i - k) % N] else s_cost[i]
        if i == N - 1 and cost > k*x + sum(s_cost):
            cost = k*x + sum(s_cost)

    print(cost)

solve_()

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

using namespace std;

int main()
{
  long long a, b, c, d, x, y, ans;
  scanf("%lli%lli%lli%lli", &a, &b, &c, &d);
  ans = a*c;
  ans = max(ans, a*d);
  ans = max(ans, b*c);
  ans = max(ans, b*d);
  printf("%lli\n", ans);
  return 0;
}

Measured memory_bytes: 3812
#include<bits/stdc++.h>
using namespace std;
main(){
    int a, b, N;
    cin >> N;
    vector<int> vec(N);
    for(int i = 0; i < N; i++){
        cin >> vec[i];
    }
    sort(vec.begin(),vec.end());
    reverse(vec.begin(),vec.end());
    a = 0;
    b = 0;
    for(int i = 0; i < N; i++){
        if(i % 2 == 1){
            a += vec[i];
        }
        else{
            b += vec[i];
        }
    }
    cout << b - a << endl;
}

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

using namespace std;
typedef long long ll;
#define int ll

#define REP(i,n) for(ll i=0;i<n;++i)
#define SORT(name) sort(name.begin(), name.end())
#define ZERO(p) memset(p, 0, sizeof(p))
#define MINUS(p) memset(p, -1, sizeof(p))
#if 1
#  define DBG(fmt, ...) printf(fmt, ##__VA_ARGS__)
#else
#  define DBG(fmt, ...)
#endif

const ll LLINF = (1LL<<60);
const int INF = (1LL<<30);
const int MOD = 1000000007;
#define MAX_N 100010

set<string> pat;
//vector<string> pat;
string S;
ll K;

signed main()
{
    cin >> S >> K;

    REP(i, S.length()) {
        string tmp = "";
        ll border = 10;
        border = min(border, (ll)S.length() - i);
        for(ll j = 0; j < border; ++j) {
            tmp += S[i + j];
            pat.insert(tmp);
            //pat.push_back(tmp);
        }
    }
    //SORT(pat);
    //unique(pat.begin(), pat.end());
    ll cnt = 0;
    string ans;
    for(auto& p : pat) {
        if(cnt >= K) { break; }
        ans = p;
        cnt++;
    }
    printf("%s\n", ans.c_str());
    return 0;
}


Measured memory_bytes: 4096
#include<stdio.h>
#include<string.h>
const int maxn =2e5+10;
int main(){
    int n,flag=-1;
    int a[maxn],Max[maxn];
    memset(Max,0,sizeof(Max));
    scanf("%d",&n);
    for(int i=1;i<=n;i++){
        scanf("%d",&a[i]);
        Max[a[i]]++;
        if(flag<a[i])
            flag=a[i];
    }
    for(int i=1;i<=n;i++){
        Max[a[i]]--;
        for(int j=flag;j>=0;j--){
            if(Max[j]!=0){
                printf("%d\n",j);
                break;
            }
        }
        Max[a[i]]++;
    }
    return 0;
}


Measured memory_bytes: 3072
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
#include <map>
#include <set>
#include <string>
#include <iostream>
#include <cassert>
#include <cmath>
using namespace std;

int main() {
        long long x, y;
        scanf("%lld %lld", &x, &y);
        if (x < y) { 
                printf("%lld\n", x);
                return 0;
        }
        if (x % y != 0) {
                printf("%lld\n", x);
                return 0;
        }
        printf("%d\n", -1);
        return 0;
}



Measured memory_bytes: 256
#include "bits/stdc++.h"
#define REP(i,n) for(int i=0;i< (n);i++)
#define REPR(i, n) for(int i = (n);i >= 0;i--)
#define FOR(i, m, n) for(int i = (m);i < (n);i++)
#define FORR(i, m, n) for(int i = (m);i >= (n);i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define ALL(obj) (obj).begin(),(obj).end()

using namespace std;

const int INF = 99999999;
const ll LINF = 9999999999999;

typedef pair<int, int> P;
typedef pair<ll, ll> LP;
int vx[4] = { 0,1,0,-1 };
int vy[4] = { 1,0,-1,0 };

int n,like=0;
vector<int> a;


signed main() {

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

	cin >> n;

	int tmp;
	REP(i, n) {
		cin >> tmp;
		a.push_back(tmp);
	}

	REP(i, n) {
		if (a[a[i]-1] == i+1) {
			//相思相愛
			like++;
		}
	}

	cout << like / 2 << endl;

	return 0;
}

Measured memory_bytes: 892
#include <bits/stdc++.h>
#define LLI long long int
#define FOR(v, a, b) for(LLI v = (a); v < (b); ++v)
#define FORE(v, a, b) for(LLI v = (a); v <= (b); ++v)
#define REP(v, n) FOR(v, 0, n)
#define REPE(v, n) FORE(v, 0, n)
#define REV(v, a, b) for(LLI v = (a); v >= (b); --v)
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define ITR(it, c) for(auto it = (c).begin(); it != (c).end(); ++it)
#define RITR(it, c) for(auto it = (c).rbegin(); it != (c).rend(); ++it)
#define EXIST(c,x) ((c).find(x) != (c).end())
#define fst first
#define snd second
#define popcount __builtin_popcount
#define UNIQ(v) (v).erase(unique(ALL(v)), (v).end())
#define bit(i) (1LL<<(i))

#ifdef DEBUG
#include <Mylib/Debug/debug.cpp>
#else
#define dump(...) ((void)0)
#endif

using namespace std;

template <typename I> void join(ostream &ost, I s, I t, string d=" "){for(auto i=s; i!=t; ++i){if(i!=s)ost<<d; ost<<*i;}ost<<endl;}
template <typename T> istream& operator>>(istream &is, vector<T> &v){for(auto &a : v) is >> a; return is;}
template <typename T> void puts_all(const T &value){std::cout << value << "\n";}
template <typename T, typename ...Args> void puts_all(const T &value, const Args&... args){std::cout << value << " ";puts_all(args...);}

template <typename T, typename U> bool chmin(T &a, const U &b){return (a>b ? a=b, true : false);}
template <typename T, typename U> bool chmax(T &a, const U &b){return (a<b ? a=b, true : false);}
template <typename T, size_t N, typename U> void fill_array(T (&a)[N], const U &v){fill((U*)a, (U*)(a+N), v);}
template <typename T> auto make_vector(int n, int m, const T &value){return vector<vector<T>>(n, vector<T>(m, value));}


struct Init{
  Init(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(12);
    cerr << fixed << setprecision(12);
  }
}init;

int main(){
  int N, K;
  while(cin >> N >> K){
    vector<int> p(N); cin >> p;

    vector<double> a(N);
    REP(i,N){
      a[i] = (double)(p[i] + 1) / 2;
    }

    vector<double> s(N+1);
    REP(i,N) s[i+1] = s[i] + a[i];

    double ans = 0;
    
    REP(i,N){
      if(i+K <= N) chmax(ans, s[i+K] - s[i]);
    }

    puts_all(ans);
  }

  return 0;
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define LL long long
using namespace std;
map<int , int> m;
int main() 
{
    ios_base::sync_with_stdio(0);
    int n;
    cin >> n;
    vector<int> v(n);
    int ans = 0;
    for(int i = 0; i < n; i++)
    {
        cin >> v[i];
        m[v[i]]++;
    }
    sort(v.begin() , v.end());
    reverse(v.begin() , v.end());
    for(auto x : v)
    {
        int i;
        for(i = 1; i <= 2 * 1000 * 1000 * 1000; i *= 2)
        {
            if(i >= x)
            {
                break;
            }
        }
        if(i == x)
        {
            ans += m[i] / 2;
            m[i] = 0;
        }
        else
        {
            int j = i - x;
            ans += min(m[j] , m[x]);
            m[j] -= min(m[j] , m[x]);
            m[x] = 0;
        }
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 19840
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cfloat>
#include <chrono>
#include <climits>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

template <class T1, class T2>
ostream& operator << (ostream& out, pair <T1, T2> p)
{
	out << '(' << p.first << ',' << p.second << ')';
	return out;
}

template <class T1, class T2>
istream& operator >> (istream& in, pair<T1, T2> &p)
{
	in >> p.first >> p.second;
	return in;
}

template <class T>
istream& operator >> (istream& in, vector<T> &v)
{
	for (T &x : v)
		in >> x;
	return in;
}

template <class T>
ostream& operator << (ostream& out, vector<vector<T>> &v)
{
	for (vector<T> &x : v)
		out << x << '\n';
	return out;
}

template <class T>
ostream& operator << (ostream& out, vector<T> &v)
{
	for (T &x : v)
		out << x << ' ';
	return out;
}

long long gcd (long long a, long long b)
{
	if (b > a)
		swap(a, b);
	return (b ? gcd(b, a % b) : a);
}

using ll   = long long;
using pii  = pair<int, int>;
using pll  = pair<long long, long long>;
using tiii = pair<pair<int, int>, int>;
using vi   = vector<int>;
using vl   = vector<long long>;
using vvi  = vector<vector<int>>;
using vvl  = vector<vector<long long>>;

#define F          first
#define S          second
#define First      first.first
#define Second     first.second
#define Third      second
#define mp         make_pair
#define rep(i,a,b) for (int i = a; i < b; i++)
#define per(i,b,a) for (int i = b; i > a; i--)
#define all(x)     x.begin(), x.end()
#define ret(x)     return cout << x, 0;
#define throwex    throw runtime_error ("Found the error.");

const int h = 1000000007;

bool ip(string s)
{
	bool ans = true;
	rep(i,0,s.size())
		if(s[i] != s[s.size()-1-i])
			ans = false;
	return ans;
}

signed main()
{
	ios::sync_with_stdio(false);
	#ifdef ONLINE_JUDGE
	cin.tie(nullptr);
	cout.tie(nullptr);
	cerr.setstate(ios::failbit);
	#endif

	string s;
	cin >> s;
	int n = s.size();
	string s1 = s.substr(0, (n-1)/2);
	string s2 = s.substr((n+3)/2-1, string::npos);
	cout << (ip(s) and ip(s1) and ip(s2) ? "Yes" : "No");
}


Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>

#include <iostream>
#include <iomanip>
#include <sstream>
#include <fstream>
#include <stdint.h>
#include <string.h>

#define _USE_MATH_DEFINES
#include <math.h>

#include <vector>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <deque>
#include <string>

#include <algorithm>
#include <functional>
#include <bitset>
#include <functional>
#include <chrono>
#include <random>

#define sqr(x) (x) * (x)

typedef unsigned int u32;
typedef int i32;
typedef unsigned long long int u64;
typedef long long int i64;
typedef uint16_t u16;
typedef int16_t i16;
typedef uint8_t u8;
typedef int8_t i8;

using namespace std;
using namespace std::chrono;

const i64 mod = 1'000'000'000ll + 7;
//const i64 smod = 998244353ll;
//const i64 inf = 1'000'000'000'000'000'000ll + 7;
const i64 inf = 1'000'000'007;

const long double eps = 1e-8;

const i64 MAXN = 200'000 + 5;


int main(int argc, char* argv[]) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout.precision(15); cout.setf(ios::fixed); cerr.precision(15); cerr.setf(ios::fixed);

    i64 x;
    cin >> x;

    i64 R = 8 - (x - 400) / 200;
    cout << R << endl;

    return 0;
}

Measured memory_bytes: 3648
#include<iostream>
using namespace std;
int main()
{
  int n, t[100], m, s, p[100], x[100];
  cin >> n;
  for(int i = 0; i < n; i++)
  {
    cin >> t[i];
  }
  cin >> m;
  for(int j = 0; j < m; j++)
  {
    cin >> p[j] >> x[j];
  }

  for(int j = 0; j < m; j++)
  {
      int s = 0;
    for(int i = 0; i < n; i++)
    {
      s = t[i] + s;
    }
    cout << endl;
    cout << s - t[p[j] - 1] + x[j];
  }
  return 0;
}


Measured memory_bytes: 256
/***********************
*  Author: xuziyuan    * 
***********************/
 
#include <bits/stdc++.h>
 
#define rt0 return 0
#define rep(i,n) for(LL i=0;i<n;i++)
#define repn(i,n) for(LL i=1;i<=n;i++)
#define replet(c) for(char c='a';c<='z';c++)
#define LL long long
#define pii pair <int,int>
#define pb push_back
#define fi first
#define se second
#define mpr make_pair
#define sqr(a) ((a)*(a))
 
using namespace std;
 
const LL MOD=1e9+7;
 
LL n,prinum[1000];
 
LL CNT1(LL x)
{
	LL ret=0;
	for(LL i=2;i<=100;i++)
	{
		if(prinum[i]>=x) ret++;
	}
	return ret;
}
 
LL CNT2(LL x,LL y)
{
	LL ret=0;
	for(LL i=2;i<=100;i++)
	{
		for(LL j=2;j<=100;j++)
		{
			if(i==j) continue;
			if(prinum[i]>=x&&prinum[j]>=y) ret++;
		}
	}
	return ret;
}
 
LL CNT3(LL x,LL y,LL z)
{
	LL ret=0;
	for(LL i=2;i<=100;i++)
	{
		for(LL j=2;j<=100;j++)
		{
			if(i==j) continue;
			for(LL k=j+1;k<=100;k++)
			{
				if(i==k) continue;
				if(prinum[i]>=x&&prinum[j]>=y&&prinum[k]>=z) ret++;
			}
		}
	}
	return ret;
}
 
int main()
{
	cin>>n;
	for(LL i=2;i<=n;i++)
	{
		LL j=2,p=i;
		while(p>1)
		{
			while(p%j==0)
			{
				prinum[j]++;
				p/=j;
			}
			j++;
		}
	}
	cout<<CNT1(74)+CNT2(14,4)+CNT2(24,2)+CNT3(2,4,4)<<endl;
	rt0;
}

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

using namespace std;
int H, W;

int compress(int depth, int maxd, vector<vector<char>> &V){
  if(depth == maxd) return 1;
  
  int f = 0;
  for(int i = 0; i < H; i++){
    if(V[i][depth % W] == '#') f = 1;
  }
  if(f == 0){
    //フラグが立ってない場合塗りつぶす
    for(int i = 0; i < H; i++){
      V[i][depth % W] = 'x';
    }
  }
    
  f = 0;  
  for(int j = 0; j < W; j++){
    if(V[depth % H][j] == '#') f = 1;
  }
  if(f == 0){
    //フラグが立ってない場合塗りつぶす
    for(int j = 0; j < W; j++){
      V[depth % H][j] = 'x';
    }
  }
  return compress(depth + 1, maxd, V);
}

int main(){
  cin >> H >> W;
  int maxd = max(H ,W);
  //cout << maxd;
  vector<vector<char>> V(H, vector<char>(W, 'a'));
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      cin >> V[i][j];
    }
  }
  
  compress(0, maxd, V);
  
  for(int i = 0; i < H; i++){
    for(int j = 0; j < W; j++){
      if(V[i][j] == 'x') continue;
      cout << V[i][j];
    }
    //if(V[i][0] == 'x') continue;
    cout << endl;
  }
}


Measured memory_bytes: 256
a=int(input())
b=list(map(int,input().split()))
ans=0
for i in range(a):
    for j in range(a):
        for k in range(a):
            if i<j<k:
                n=b[i]
                m=b[j]
                o=b[k]
                if n!=m and n!=o and m!=o and n+m>o and m+o>n and n+o>m:
                    ans+=1
print(ans)

Measured memory_bytes: 9208
#include<stdio.h>
int main()
{
	int i,j,a,b,c;
	for(c=1;;)
	{
		scanf("%d %d",&a,&b);
		if(a==0 && b==0)break;
		for(j=1;j<=a;j++)
		if(j%2==0)
	{
		for(i=1;i<=b;i++)
			{
				if(i%2==0)
					printf("#");
				else
					printf(".");
		}
			printf("\n");
		}
		else
		{
				for(i=1;i<=b;i++)
				{
				if(i%2==0)
					printf(".");
				else
					printf("#");
				}
					printf("\n");
		}	
			printf("\n");
	}
	return 0;
}



Measured memory_bytes: 2040
def main():
    N, A, B, C = map(int, input().split())
    l = [int(input()) for i in range(N)]
    
    ans = int(1e10)
    for i in range(4**N):
        tmp = [0, 0, 0, 0]# 0:a, 1:b, 2:c, 3:使用しない
        count = [0, 0, 0, 0]
        for j in range(N):
            tmp[i&3] += l[j]
            count[i&3] += 1
            i >>= 2
        if tmp[0] > 0 and tmp[1] > 0 and tmp[2] > 0:# a, b,c 用の竹が各一本以上ある
            mp = abs(tmp[0] - A) + abs(tmp[1] - B) + abs(tmp[2] - C) + (count[0]+count[1]+count[2]-3) * 10
            # print(mp)
            ans = min(ans, mp)
    print(ans)


if __name__ == "__main__":
    main()

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

int main() {
  int L,R;cin>>L>>R;
  int ans=2018;
  int Rf=min(R-L,2019);
  for(int i=L;i<L+Rf;i++){
    for(int j=i+1;j<=L+Rf;j++){
      int ansy=((i%2019)*(j%2019))%2019;
      ans=min(ansy,ans);
    }
  }
  cout<<ans<<endl;
}


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

using namespace std;
int a,b,c,d,k,t;
int main() {
    cin>>a>>b>>c>>d>>k;
    if(d>=b)
        t=(c-a)*60+(d-b);
    else
        t=(c-a-1)*60+(d+60-b);
    cout<<t-k<<endl;
    return 0;

}

Measured memory_bytes: 3620
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i, n) for (int i=0;i < (int)(n);i++)

int main(){
    string s;
    cin >> s;
    sort(s.begin(),s.end());
    if (s == "abc") cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
    
}



Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stdlib.h>
#include <cstdint>
#include <cmath>
#include <algorithm>
#include <float.h>
using namespace std;

int main()
{
	string s;

	cin >> s;

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

	if( s == "abc" ) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
    int n; string s; cin >> n >> s;
    if (n%2==1) {puts("No"); return 0;}
    else for (int i=0; i<n/2; i++){
        if (s[i]!=s[n/2+i]) {puts("No"); return 0;}
    }
    puts("Yes");
}

Measured memory_bytes: 256
function Main(input) {
  input = input.split("\n");
  const N = parseInt(input[0]);
  const A = input[1].split(" ");

  let answer = BigInt(A[0]);
  let B = [];
  for (let i = 0; i < N; i++) {
    B[i] = BigInt(A[i]);
  }

  if (A.indexOf("0") === -1) {
    for (let i = 1; i < N; i++) {
      answer = answer * B[i];
      if (answer > BigInt(10 ** 18)) {
        answer = -1;
        break;
      }
    }
  } else {
    answer = 0;
  }


  console.log(String(answer));
}

// デバッグ用
function debug() {
  var input = document.getElementById("input").value;
  Main(input);
}

//* この行以降は編集しないでください（標準入出力から一度に読み込み、Mainを呼び出します）
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 48196
d, g = map(int, input().split())
p = [0] * d
c = [0] * d
for i in range(d):
    p[i], c[i] = map(int, input().split())
ans = 10000000
for i in range(1 << d):
    s = set()
    use = 0
    res = 0
    for j in range(d):
        if i >> j & 1:
            use += p[j]
            res += p[j] * (j + 1) * 100 + c[j]
            s.add(j)
    for j in range(d - 1, -1, -1):
        if res >= g:
            break
        if j in s:
            continue
        use += min(p[j], (g - res + j) // (100 * (j + 1)))
        res += min(p[j], (g - res + j) // (100 * (j + 1))) * 100 * (j + 1)
    if res >= g:
        ans = min(ans, use)
print(ans)


Measured memory_bytes: 73228
S=input()
N=len(S)

tile1=('10'*N)[:N]
tile0=('01'*N)[:N]

ans1=0
ans0=0
for i in range(N):
    ans1+=S[i]!=tile1[i]
    ans0+=S[i]!=tile0[i]

print(min(ans1,ans0))

Measured memory_bytes: 9316
N=int(input())
T,A=map(int,input().split())
height = input().split()
min=1000
minnum=0
for i in range(len(height)):
    z=int(T)-int(height[i])*0.006
    if abs(z-A)<float(min):
        min=abs(z-A)
        minnum=i+1
print(minnum)

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

using namespace std;
#define PB push_back
#define MP make_pair
#define LL long long
#define int LL
#define FOR(i,a,b) for(int i = (a); i <= (b); i++)
#define RE(i,n) FOR(i,1,n)
#define REP(i,n) FOR(i,0,(int)(n)-1)
#define R(i,n) REP(i,n)
#define VI vector<int>
#define PII pair<int,int>
#define LD long double
#define FI first
#define SE second
#define st FI
#define nd SE
#define ALL(x) (x).begin(), (x).end()
#define SZ(x) ((int)(x).size())

template<class C> void mini(C& _a4, C _b4) { _a4 = min(_a4, _b4); }
template<class C> void maxi(C& _a4, C _b4) { _a4 = max(_a4, _b4); }

template<class TH> void _dbg(const char *sdbg, TH h){ cerr<<sdbg<<'='<<h<<endl; }
template<class TH, class... TA> void _dbg(const char *sdbg, TH h, TA... a) {
  while(*sdbg!=',')cerr<<*sdbg++;cerr<<'='<<h<<','; _dbg(sdbg+1, a...);
}

template<class T> ostream& operator<<(ostream& os, vector<T> V) {
  os << "["; for (auto& vv : V) os << vv << ","; os << "]";
  return os;
}

#ifdef LOCAL
#define debug(...) _dbg(#__VA_ARGS__, __VA_ARGS__)
#else
#define debug(...) (__VA_ARGS__)
#define cerr if(0)cout
#endif

#define MAX 100010
int n,l,t[MAX];

int32_t main() {
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout << fixed << setprecision(11);
  cerr << fixed << setprecision(6);
  cin >> n >> l;
  R(i,n){
    cin >> t[i];
  }
  R(i,n-1){
    if(t[i] + t[i+1] >= l){
      cout << "Possible\n";
      R(j,i){
        cout << j+1 << "\n";
      }
      R(j,n-i-1){
        cout << n - j - 1 << "\n";
      }
      return 0;
    }
  }
  cout << "Impossible\n";
}


Measured memory_bytes: 1664
#pragma GCC optimize ("O3")
#pragma GCC optimize ("unroll-loops")

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

#define pb push_back
#define F first
#define S second
#define f(i,a,b)  for(int i = a; i < b; i++)
// #define endl '\n'

using ll = long long;
using db = long double;
using ii = pair<int, int>;

const int N = 1e5+5, LG = 17, MOD = 998244353;
const int SQ = 450;
const long double EPS = 1e-7;
int n, m;
vector<int> adj[N];
int vis[N][3];
int32_t main(){
#ifdef ONLINE_JUDGE
    ios_base::sync_with_stdio(0);
    cin.tie(0);
#endif

  cin >> n >> m;

  f(i,0,m){
    int u, v;
    cin>>u>>v;
    adj[u].pb(v);
  }

  int s,t;
  cin>>s>>t;
  memset(vis,-1,sizeof vis);
  queue<ii>q({ii(s,0)});
  vis[s][0]=0;
  while(q.size()){
    auto cur=q.front(); q.pop();
    for(auto v:adj[cur.F])
    if(vis[v][(cur.S+1)%3]==-1){
      vis[v][(cur.S+1)%3] = vis[cur.F][cur.S] + 1;
      q.push(ii(v,(cur.S+1)%3));
    }
  }
  if(vis[t][0]!=-1)vis[t][0]/=3;
  cout<<vis[t][0]<<endl;

  return 0;
}


Measured memory_bytes: 6912
import itertools
n=int(input())

jyunretu=[]
for i in range(1,n+1):
    jyunretu.append(str(i))
p = itertools.permutations(jyunretu, n)

jyunretulist=[]
for i in p:
    jyunretulist.append(list(i))
    
p=input().split()
q=input().split()

for i ,youso in enumerate(jyunretulist):
    if youso==p:
        a=i
    if youso==q:
        b=i
print(abs(a-b))

Measured memory_bytes: 10228
#!/usr/bin/env python3
import sys


def solve(a: int, b: int):
    c = a*b
    print("Odd" if c % 2 else "Even")
    return


# Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
def main():
    def iterate_tokens():
        for line in sys.stdin:
            for word in line.split():
                yield word
    tokens = iterate_tokens()
    a = int(next(tokens))  # type: int
    b = int(next(tokens))  # type: int
    solve(a, b)

if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
public class Main {
	public static void main(String[] args) throws IOException{
		int n,min=0,max=0;
		long sum=0;
		String[] list;

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		n = Integer.parseInt(br.readLine());
		list = br.readLine().split(" ");

		min = Integer.parseInt(list[0]);
		max = Integer.parseInt(list[0]);

		for(int i = 0; i < n; i++){
			int num = Integer.parseInt(list[i]);
			sum += num;
			if(min > num)min = num;
			if(max < num)max = num;
		}
		System.out.println(min + " " + max + " " + sum);

        br.close();
	}
}

Measured memory_bytes: 28640
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <string.h>
#define s(n)                        scanf("%d",&n)
#define sc(n)                       scanf("%c",&n)
#define sl(n)                       scanf("%I64d",&n)
#define sf(n)                       scanf("%lf",&n)
#define ss(n)                       scanf("%s",n)
#define INF                         (int)1e9
#define EPS                         1e-9
#define bitcount                    __builtin_popcount
#define gcd                         __gcd
#define forall(i,a,b)               for(int i=a;i<b;i++)
#define foreach(v, c)               for( typeof( (c).begin()) v = (c).begin();  v != (c).end(); ++v)
#define all(a)                      a.begin(), a.end()
#define in(a,b)                     ( (b).find(a) != (b).end())
#define pb                          push_back
#define fill(a,v)                    memset(a, v, sizeof a)
#define sz(a)                       ((int)(a.size()))
#define mp                          make_pair
#define MOD                         1000000007
typedef long long ll;
/*For you see , each day i love you
 more.Today more than yesterday
  less than tomorrow.*/
using namespace std;

int main()
{
	int n;s(n);
	
	if(n>=30) cout<<"Yes"<<endl;
	else cout<<"No"<<endl;
	
	return 0;
}

Measured memory_bytes: 3680
#include<stdio.h>


typedef unsigned long long ull ;



ull pow( ull a ,ull b )
{
	ull ret = 1 ;

	if( b > 0 )
	{
		ret = pow( a ,b / 2 ) ;

		ret = ( ret * ret ) % 1000000007 ;


		if( b & 1 )
		{
			ret = ( ret * a ) % 1000000007 ;
		}
	}


	return ret ;
}



int main()
{
	ull m ,n ;
	scanf( "%lld %lld" ,&m ,&n ) ;


	printf( "%lld\n" ,pow( m ,n ) ) ;


	return 0 ;
}

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

using namespace std;

int64_t mod = 1000000007;

int64_t power(int64_t c, int64_t rep)
{
  if(rep == 0)
    {
      return 1;
    }
  else if (rep == 1)
    {
      return c % mod;
    }
  else if (rep % 2 == 0)
    {
      int64_t pow1 = power(c,rep/2) % mod;
      pow1 *= (pow1 % mod);
      return pow1 % mod;
    }
  else
    {
      int64_t pow1 = power(c,rep/2) % mod;
      pow1 *= (pow1 % mod);
      pow1 %= mod;
      pow1 *= (c % mod);
      return pow1 % mod;
    }
}

int main()
{
  int64_t N, K;

  cin >> N >> K;

  for(int64_t i = 1;
      i <= K;
      ++i)
    {
      int64_t div_m = 1;
      int64_t div_c = 1;
      for(int64_t j = 1;
          j <= i;
          ++j)
        {
          div_m *= (N - K + 2 - j) % mod;
          div_m %= mod;
          div_c *= j;
          div_c %= mod;
        }

      int64_t div_m2 = 1;
      int64_t div_c2 = 1;

      for(int64_t j = 1;
          j <= i - 1;
          ++j)
        {
          div_m2 *= (K - j) % mod;
          div_m2 %= mod;
          div_c2 *= j;
          div_c2 %= mod;
        }
      int64_t m1 = div_m * power(div_c, mod - 2) % mod;
      int64_t m2 = div_m2 * power(div_c2, mod - 2) % mod; 
      cout << (m1 * m2) % mod << endl;
    }


  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
 
#define int long long
#define ull unsigned long long
#define ld long double
#define rep(a) rep1(i,a)
#define rep1(i,a) rep2(i,0,a)
#define rep2(i,b,a) for(int i=(b); i<((int)(a)); i++)
#define rep3(i,b,a) for(int i=(b); i>=((int)(a)); i--)
#define all(a) a.begin(),a.end()
#define pii pair<int,int>
#define pb push_back
#define mp make_pair
#define sz(a) ((int)a.size())
#define pow2(x) (1ll<<(x))
#define print0(a) cout << (a) << ' '
#define print1(a) cout << (a) << '\n'
#define print2(a,b) cout << (a) << ' ',print1(b)
#define print3(a,b,c) cout << (a) << ' ',print2(b,c)
#define print4(a,b,c,d) cout << (a) << ' ',print3(b,c,d)
#ifdef i_am_noob
#define debug(a) print1(a)
#else
#define debug(a) 
#endif
#define ordered_set tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
 
using namespace std;
using namespace __gnu_pbds;
 
const int Mod=1000000007,Mod2=998244353;
const int MOD=Mod2;
 
inline int add(int a, int b){return (a+b>=MOD?a+b-MOD:a+b);}
inline int sub(int a, int b){return (a+MOD-b>=MOD?a-b:a+MOD-b);}
int Pow(int a, int b){
	if(!b) return 1;
	int tmp=Pow(a*a%MOD,b>>1);
	return (b&1?tmp*a%MOD:tmp);
}
inline int inverse(int n){return Pow(n,MOD-2);}
 
const int maxn=200005;
//i_am_noob
int n,k,a[maxn],ans=0;

signed main(){
	ios_base::sync_with_stdio(0),cin.tie(0);
	cin >> n >> k;
	rep(n) cin >> a[i];
	sort(a,a+n);
	rep(n) ans+=(n-i<=k?0:a[i]);
	print1(ans);
	return 0;
}

Measured memory_bytes: 1792
#include<iostream>
#include<algorithm>
#include<math.h>
#include<set>
#include<vector>
#include<map>
#include<functional>
#include<iomanip>
#include<queue>
#include<random>
#include<numeric>
#include<string>
#include<cstring>
typedef long long ll;
typedef long double ld;
using namespace std;
ll dx[] = { 0,0,1,-1 };
ll dy[] = { 1,-1,0,0 };

ll gcd(ll a, ll b) {
	if (a<b) { return gcd(b, a); }
	else if (a%b) { return gcd(b, a%b); }
	else { return b; }
}
int main() {
	ll N;
	cin >> N;
	ll a[N + 10];
	for (ll i = 0; i < N; i++) {
		cin >> a[i];
	}
	sort(a, a + N);
	ll x = a[N - 1];
	ll ans = 1e9 + 7;
	for (ll i = 0; i < N-1; i++) {
		ans = min(ans,abs(x - 2*a[i]));
    }
  	ll n=-1,m=-1;
  	for(ll i=0; i<N-1;  i++){
      if(x -ans==2*a[i])
			n=a[i];
	  if(x+ans==2*a[i])
			m=a[i];
    }
  	m=max(n,m);
	cout << a[N - 1] << ' ' << m << endl;
}



Measured memory_bytes: 1024
import scala.annotation.tailrec
import scala.io.StdIn._



object Main extends App {

  solve()
  @tailrec def solve(): Unit = {
    val Array(n, m) = readLine.trim.split(' ').map(_.toInt)
    if (n == 0 && m == 0){
      return
    }
    val money = readLine.trim.split(' ').map(_.toInt)
    println(money.map{a ⇒ Math.min(a, m / n)}.sum)
    solve()
  }
}




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

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

	int n;
	cin >> n;
	map<string, int> cnt;
	for (int i = 0; i < n; i++) {
		string s;
		cin >> s;
		sort(s.begin(), s.end());
		cnt[s]++;
	}
	long long ans = 0;
	for (auto& it : cnt) {
		ans += 1LL * it.second * (it.second - 1) / 2;
	}
	cout << ans << endl;
	return 0;
}



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

#define loop(v, f, l) for(int v = (f), v##_ = (l); v < v##_; ++v)

using namespace std;

typedef long long int lint;
static inline int in(){ int x; scanf("%d", &x); return (x); }
static inline lint inl(){ lint x; scanf("lld", &x); return (x); }

int main()
{
	double highest = 0.0;
	double lowest = DBL_MAX;
	double height;

	while( scanf("%lf", &height) != EOF )
	{
		if( height < lowest )lowest = height;
		if( height > highest ) highest = height;
	}
	printf("%.1lf\n", highest - lowest);
	return (0);
}

Measured memory_bytes: 1236
A = [list(map(int, input().split())) for i in range(3)]  #数字、複数行複数列
N = int(input())  #数字
T = list(int(input()) for i in range(N))  #複数行１列を一つのリストにする

#print(A)
#print(N)
#print(T)

for i in range(3):
    for j in range(3):
        if A[i][j] in T:
            A[i][j] = 999

#print(A)

for i in range(3):
    if A[i][0] + A[i][1] + A[i][2] == 999 * 3:
        print("Yes")
        exit()
    if A[0][i] + A[1][i] + A[2][i] == 999 * 3:
        print("Yes")
        exit()

if A[0][0] + A[1][1] + A[2][2] == 999 * 3:
    print("Yes")
    exit()
if A[2][0] + A[1][1] + A[0][2] == 999 * 3:
    print("Yes")
    exit()

print("No")

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

using namespace std;

int main()
{
  int N;
  scanf("%d", &N);

  multiset< int > sets;
  sets.insert(0);
  for(int i = 0; i < N; i++) {
    int depth;
    scanf("%d", &depth);
    auto p = sets.upper_bound(depth);
    if(p == sets.begin()) {
      puts("No");
    } else {
      int q = *--p;
      sets.erase(p);
      puts("Yes");
      for(int j = q + 1; j <= depth && sets.size() <= N; j++) {
        if(sets.size() == N && *--sets.end() > j) sets.erase(--sets.end());
        sets.insert(j);
      }
    }
  }
}

Measured memory_bytes: 23288
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    int k;
    cin>>k;
    string s;
    cin>>s;
    if(s.length()<=k)cout<<s;
    else {
        for(int i=0;i<k;i++)cout<<s[i];
        cout<<"...";
    }
    return 0;
}

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

int main() {
  int n;
  cin>>n;
  long long a[n+1],sum=0,now=1,ans=1;
  for(int i=0;i<n+1;i++){
    long long l;
    cin>>l;
    a[i]=l;
    sum+=a[i];
  }
  bool ok=true;
  if(a[0]!=0)ok=false;
  if(a[0]==1&&n==0)ok=true;
  for(int i=1;i<=n;i++){
    if(2*now<a[i]){
      ok=false;
      break;
    }
    if(sum<now*2){
      now=sum;
    }
    else{
      now*=2;
    }
    ans+=now;
    now-=a[i];
    sum-=a[i];
  }
  if(ok)cout<<ans<<endl;
  else cout<<-1<<endl;
}

Measured memory_bytes: 4424