akhauriyash/Code-Regression huggingface dataset:
// インクルード
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <algorithm>
#include <iomanip>

// 名前空間省略
using namespace std;

// メイン
int main()
{
	// 入出力の高速化
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// 表示精度変更
	cout << fixed << setprecision(16);

    int a;
    int b=0, c=0;
	for(int i=0;i<3;i++){
        cin >> a;
        if(a==5) b++;
        if(a==7) c++;
    }

    if(b==2 && c==1) cout << "YES" << endl;
    else cout << "NO" << endl;
}

Measured memory_bytes: 256
n, m = map(int, input().split())
h = list(map(int, input().split()))
hi = [[i, h[i]] for i in range(len(h))]

hi.sort(key=lambda x: -x[1])

connection = [[] for i in range(n)]
for i in range(m):
    a, b = map(int, input().split())
    connection[a - 1].append(b - 1)
    connection[b - 1].append(a - 1)

flag = [0 for i in range(n)]
for ten in hi:
    if flag[ten[0]] == 0:
        tmp_flag=1
    else:
        tmp_flag=-1
    for other in connection[ten[0]]:
        if ten[1] == h[other]:
            tmp_flag=-1
        if flag[other] == 0:
            flag[other] = -1
    flag[ten[0]] = tmp_flag

print(len([i for i in range(n) if flag[i] ==1]))

Measured memory_bytes: 110892
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<string.h>
#include<math.h>
#include<utility>
#include<map>
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,m,n) for(ll i=m;i<n;i++)
#define REPR(i,n) for(ll i=n-1;i>=0;i--)
#define FORR(i,n,m) for(ll i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K

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

    static ll a[100000];
    
    REP(i,n){
        cin >> a[i];
    }
    ll sum = abs(a[0])+abs(a[n-1]);
    REP(i,n-1){
        sum += abs(a[i]-a[i+1]);
    }
    REP(i,n){
        if(i==0){
            cout << sum - abs(abs(a[i+1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }else if(i==n-1){
            cout << sum - abs(abs(a[i-1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }else{
            cout << sum - abs(abs(a[i-1]-a[i+1])-(abs(a[i]-a[i-1])+abs(a[i]-a[i+1]))) << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 2048
#include<bits/stdc++.h>
#define U [1<<17]={}
typedef long long L;using namespace std;map<L,L> path U;L P U,E U,Z U,H U,C U,A U,O U,X U,B U,k,n,a,b,c,p,r;char s U;
L D(L a){Z[a]=1;for(map<L,L>::iterator I=path[a].begin();I!=path[a].end();I++){L d=I->first;if(d-P[a]){P[d]=a;E[d]=E[a]+1;C[d]=I->second;D(d);Z[a]+=Z[d];!H[a]|Z[H[a]]<Z[d]?H[a]=d:0;}}}
L G(L a){r=A[a]+A[P[a]]+C[a];return r%k?r:0;}
L M(L i){return i?B[i]+M(i-(i&-i)):0;}
L S(L i,L x){for(x=G(x)-M(i+1)+M(i++);i<1<<17;B[i]+=x,i+=i&-i);}
main(){for(cin>>n>>k;p<n-1;p++)cin>>a>>b>>c,path[a][b]=path[b][a]=c;
       for(D(c=p=0);p<n;p++)if(!p|H[P[p]]-p)for(a=p;!c|a;a=H[a])X[a]=p,S(O[a]=c++,H[a]);
       for(cin>>a;cin>>s>>a>>b;)if(*s&2){
           for(c=0;p=X[a],n=X[b],p-n;a=P[p])E[p]<E[n]?swap(p,n),swap(a,b),0:0,c+=M(O[a])-M(O[p])+G(p);cout<<c+abs(M(O[a])-M(O[b]))<<endl;}
       else A[a]+=b,S(O[a],H[a]),a?S(O[a]-1,a):0;}

Measured memory_bytes: 33384
#include "bits/stdc++.h"
#define _overload3(_1,_2,_3,name,...)name
#define _rep(i,n)repi(i,0,n)
#define repi(i,a,b)for(int i=int(a),i##_len=(b);i<i##_len;++i)
#define MSVC_UNKO(x)x
#define rep(...)MSVC_UNKO(_overload3(__VA_ARGS__,repi,_rep,_rep)(__VA_ARGS__))
#define all(c)c.begin(),c.end()
#define write(x)cout<<(x)<<'\n'
using namespace std; typedef long long ll; template<class T>using vv = vector<vector<T>>;
template<class T>auto vvec(int n, int m, T v) { return vv<T>(n, vector<T>(m, v)); }
constexpr int INF = 1 << 29, MOD = int(1e9) + 7; constexpr ll LINF = 1LL << 60;
struct aaa { aaa() { cin.tie(0); ios::sync_with_stdio(0); cout << fixed << setprecision(10); }; }aaaa;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    sort(all(A));
    rep(i, N - 1) {
        if (A[i] == A[i + 1]) {
            write("NO");
            return 0;
        }
    }
    write("YES");
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, s, n) for (int i = (s); i < (n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main() {
  char c;
  cin >> c;
  if (c >= 'A' && c <= 'Z')
    cout << 'A' << endl;
  else
    cout << "a" << endl;
  return 0;
}

Measured memory_bytes: 3648
Aij= [input().split() for l in range(3)]
N=int(input())
b= [int(input()) for i in range(N)]
for j in range(3):
    for k in range(3):
        for n in range(N):
            if int(Aij[j][k])==b[n]:
                Aij[j][k]='0'
if Aij[0].count('0')==3 or Aij[1].count('0')==3 or Aij[2].count('0')==3:
    print('Yes')
elif Aij[0][0]=='0' and Aij[1][0]=='0' and Aij[2][0]=='0':
    print('Yes')
elif Aij[0][1]=='0' and Aij[1][1]=='0' and Aij[2][1]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][2]=='0' and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][0]=='0'and Aij[1][1]=='0'and Aij[2][2]=='0':
    print('Yes')
elif Aij[0][2]=='0' and Aij[1][1]=='0'and Aij[2][0]=='0':
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9296
#include<iostream>

using namespace std;


int main()
{

	int n;
	int A[100000];

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

	int r=n-1;
	int i=0;
	int j=0;

	for(i=0;i<n-1;i++){
		if(A[i]<=A[r]){
			swap(A[i],A[j++]);
		}
	}

	if(A[j]>A[r]) swap(A[j],A[r]);

	
	for(i=0;i<n;i++){
		if(i) cout<<" ";
		if(j==i){
			cout<<"["<<A[i]<<"]";
		}else{
			cout<<A[i];
		}
	}
	cout<<endl;


	return 0;
}



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

#define CPP_STR(x) CPP_STR_I(x)
#define CPP_CAT(x,y) CPP_CAT_I(x,y)
#define CPP_STR_I(args...) #args
#define CPP_CAT_I(x,y) x ## y

#define FOR(i, start, end) for(i64 i = (start), CPP_CAT(i,xxxx_end)=(end); i < CPP_CAT(i,xxxx_end); ++i)
#define REP(i, n) FOR(i, 0, n)

#define ALL(f,c,...) (([&](decltype((c)) cccc) { return (f)(std::begin(cccc), std::end(cccc), ## __VA_ARGS__); })(c))

using i8  = int8_t;
using u8  = uint8_t;
using i16 = int16_t;
using u16 = uint16_t;
using i32 = int32_t;
using u32 = uint32_t;
using i64 = int64_t;
using u64 = uint64_t;

using f32 = float;
using f64 = double;

void solve() {
    u64 n;
    cin >> n;
    cout << pow(n,3) << endl;
}

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


Measured memory_bytes: 384
#include <stdio.h>
#include <iostream>
#include <vector>
#include <algorithm>
#include <functional>
#include <cstdlib>
#include <list>
#include <numeric>
#include <map>
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) (x).begin(),(x).end()
using namespace std;

int a=0, b = 0,c,d, n, k;
string s, t;


int main()
{
	int r, g, b, n, cnt = 0;
	cin >> r >> g >> b >> n;
	rep(i, n / r+1)
	{
		rep(j, n / g+1)
		{
			if (n - i * r - j * g >= 0 && (n - i * r - j * g) % b == 0)
				cnt++;
		}
	}
	
	cout << cnt << endl;

	return 0;
}

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

using namespace std;
typedef long long ll;

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

int main()
{
  int M, N;
  cin >> N >> M;
  vector<int> k(M);
  int s[M][N];
  for(int i=0; i<M; i++)
    {
      cin >> k[i];
      for(int j=0; j<k[i]; j++)
	cin >> s[i][j]; 
    }

  vector<int> p(M);
  for(int i=0; i<M; i++)
    cin >> p[i];

  ll count =0;
  for(ll bits =0; bits<(1<<(N)); bits++)
    {
      for(int i=0; i<M; i++)
	{
	  ll tmp = 0;
	  for(int j=0; j<k[i]; j++)
	    {
	      if(bits & (1<<(s[i][j]-1)))
		tmp++;
	    }
	  
	  if(tmp%2!=p[i])
	    break;
	  else if(i==M-1)
	    count++;
	}
      
      
      
    }
  
  
  cout << count << endl;

  return 0;
}


//cout << setprecision(13);
//next_permutation();
//__gcd();
//reverse();
//set ,tuple ,pair;
//bitset
//vector.find
//vector.count



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


void init(){
    cin.tie(0);
    cin.sync_with_stdio(0);
}

#define ll long long
#define ld long double
#define ull unsigned long long
#define ull unsigned long long
#define mod 1000000007
#define pi (3.1415926)

#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))

#define scd(a)  scanf("%lld",&a)
#define scdd(a,b)	scanf("%lld%lld",&a,&b)
#define scddd(a,b,c)	scanf("%lld%lld%lld",&a,&b,&c)
#define ptab(a)	printf("%lld ",a)
#define pdn(a)	printf("%lld\n",a)
#define pddn(a,b)	printf("%lld %lld\n",a,b)
#define pdddn(a,b,c)	printf("%lld %lld %lld\n",a,b,c)

#define forr(n) for(ll i=0;i<n;i++)
#define rev(n) for(ll i=n-1;i>=0;i--)
#define forp(x, y) for(ll i=x;i<y;i++)
#define loop( j, k, in) for (ll i=j ; i<k ; i+=in)

#define in  cin>>
#define out cout<<
#define en "\n"
#define sp " "
#define eps 1.0E-14
#define l length()
#define preci(x) fixed<<setprecision(x)
#define inf LONG_LONG_MAX
#define ninf LONG_LONG_MIN
int N;
char ans[111];

void odd(int n)
    {
    bool b=1;
        int x = sqrt(n);
    for (int i=2 ; i<=x ; ++i)

    {
        if(n%i == 0) {cout << "NO" << sp; b = 0;  break;}
    }
    if (b)
    cout << "Yes" << sp;
    b=1;
    }


void DFS(int cur,int mx){
//    printf("cur = %d\n",cur);
    if(cur==N){
        ans[N]='\0';
        printf("%s\n",ans);
        return;
    }
    for(int i=0;i<=cur;i++){
        ans[cur]='a'+i;
        DFS(cur+1,max(mx,i));
        if(i>mx) break;
    }
}

void work(){
    scanf("%d",&N);
    DFS(0,0);
}

ll sum (int n ){return ((n*(n+1)) / 2) ;}
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
int main()
{
    init();

    int A, B, M;
 cin >> A >> B >> M;
 vector<int> a(A);
 vector<int> b(B);
 for (int i = 0; i < A; i++)cin >> a[i];
 for (int i = 0; i < B; i++)cin >> b[i];
 int minA = *min_element(a.begin(), a.end());
 int minB = *min_element(b.begin(), b.end());
 int ans = minA+minB;
 for (int i = 0; i < M; i++) {
 int x, y, c;
 cin >> x >> y >> c; x--; y--;
 ans = min(ans, a[x] + b[y] - c);
 }
 cout << ans << endl;
}


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

using ll = long long;
using namespace std;
const int INFint = 1e9+1;
const ll INFll = (ll)1e18+1;
ll MOD=1e9+7;


int main(){
  int N,K;
  cin>>N>>K;
  vector<pair<ll,ll>> x;
  for(int i(0);i<N;i++){
    int t,d;
    cin>>t>>d;
    x.push_back({d,t});
  }
  sort(x.rbegin(),x.rend());
  ll sum(0);
  int used[100001] = {0};
  priority_queue<ll, vector<ll>, greater<ll> > q;
  priority_queue<ll> p;
  ll cnt(0);
  for(int i(0);i<K;i++){
    sum += x[i].first;
    used[x[i].second]++;
    if(used[x[i].second] >= 2) q.push(x[i].first);
    else cnt++;
  }

  for(int i(0);i<N;i++){
    if(used[x[i].second] == 0){
      p.push(x[i].first);
      used[x[i].second] = 1;
    }
  }
  ll ans = sum + cnt*cnt;
  while(!q.empty() && !p.empty()){
    // if(q.top() >= p.top() + cnt*cnt-(cnt-1)*(cnt-1)){
    //   break;
    // }
    sum -= q.top();q.pop();
    sum += p.top();p.pop();
    cnt++;
    ans = max(ans,sum+cnt*cnt);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 6104
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;

int main(){
  int N; int K;
  string S;
  cin >> N >> K >> S;
  S.at(K-1) = (char)tolower(S.at(K-1));
  cout << S << endl;
}

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

int main()
{
    int n;
    cin>>n;
    for(int i=0;i<=n;i++)
    {
        int x = i*1.08;
        if(x==n)
        {
            cout<<i<<endl;
            return 0;
        }
    }
    cout<<":("<<endl;
    return 0;
}

Measured memory_bytes: 256
from collections import defaultdict
import math
n=int(input())
d=defaultdict(int)

if n>2:
    m=int(math.sqrt(n))
    for k in range(1,m):
        for i in range(1,m):
            for j in range(1,m):
                N=i*i+j*j+k*k+i*j+j*k+k*i
                d[N]+=1
for i in range(1,n+1):
    print(d[i])

Measured memory_bytes: 72620
#include <bits/stdc++.h>
#define rep(i,n) for (ll i = 0; i < n; ++i)
#define sz(x) int(x.size())
#define ALL(c) (c).begin(), (c).end()
#define SUM(x) std::accumulate(ALL(x), 0LL)
#define MIN(v) *std::min_element(v.begin(), v.end())
#define MAX(v) *std::max_element(v.begin(), v.end())
#define EXIST(v, x) (std::find(v.begin(), v.end(), x) != v.end())
#define FORV(i, v) for (auto i = v.begin(); i != v.end(); i++)
using namespace std;

using ll = long long;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
const int INF = 1001001001;
const long long INFL = LLONG_MAX / 3;
const double eps = (1e-9);

//組み合わせの数nCrを計算
ll calcNumOfCombination(ll n, ll r){
  ll num = 1;
  for(ll i = 1; i <= r; i++){
    num = num * (n - i + 1) / i;
  }
  return num;
}

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

  int n, p; cin >> n >> p;
  int n_even = 0, n_odd = 0;
  rep(i, n) {
    int a; cin >> a;
    if (a % 2 == 0) n_even++;
    else n_odd++;
  }

  ll p_odd = 0, p_even = 0;
  for (int i = 0; i <= n_even; i++) {
    p_even += calcNumOfCombination(n_even, i);
  }

  for (int i = 0; i <= n_odd; i++) {
    if (i % 2 == p) {
      p_odd += calcNumOfCombination(n_odd, i);
    }
  }

  cout << p_odd * p_even << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<n; i++)
#define rep2(i,a,n) for(int i=(a); i<(n); i++)
#define all(vec) vec.begin(),vec.end()
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vll = vector<ll>;

int main(){
  ll N; cin >> N;
  vll A(N);
  rep(i,N)  cin >> A[i];
  ll ans = 0;
  rep2(i,1,N){
    if(A[i] < A[i-1]){
      ans += A[i-1] - A[i];
      A[i] = A[i-1];
    }
  }
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 4744
#include <iostream>
#include <vector>
#include <cmath>
#include <algorithm>

using namespace std;
// vector<long> trial_division(long n) {
//   vector<long> a;
//   long f = 2;
//   while (n > 1) {
//     if (n % f == 0) {
//       a.push_back(f);
//       n /= f;
//     } else {
//       f += 1;
//     }
//   }
//   return a;
// }
vector<long> trial_division(long n) {
  vector<long> a;
  a.push_back(1); // 後で
  for (long i = 2; i < long(sqrt(n) + 2); i++) {
    while (n % i == 0) {
      n /= i;
      a.push_back(i);
    }
  }
  if (n > 1) {
    a.push_back(n);
  }
  return a;
}

long num_digits(long n) {
  if (n < 0) {
    return -1; // invalid
  } else if (n < 10) {
    return 1;
  }

  long cnt = 1;
  while (n > 0) {
    cnt++;
    n /= 10;
    if (n < 10) {
      return cnt;
    }
  }
  return -1; // invalid
}

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

  long ans = num_digits(n);

  for (long a = 1; a*a <= n; a++) {
    if (n % a != 0) continue;
    const long b = n / a;
    ans = min(ans, max(num_digits(a), num_digits(b)));
  }

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


Measured memory_bytes: 256
//参考：https://qiita.com/DaikiSuyama/items/9dba963ba74396b9b7fd
//インクルード(アルファベット順)
#include <algorithm>     //sort,二分探索,など
#include <bitset>        //固定長bit集合
#include <cmath>         //pow,logなど
#include <complex>       //複素数
#include <deque>         //両端アクセスのキュー
#include <functional>    //sortのgreater
#include <iomanip>       //setprecision(浮動小数点の出力の誤差)
#include <iostream>      //入出力
#include <iterator>      //集合演算(積集合,和集合,差集合など)
#include <map>           //map(辞書)
#include <numeric>       //iota(整数列の生成),gcdとlcm(c++17)
#include <queue>         //キュー
#include <set>           //集合
#include <stack>         //スタック
#include <string>        //文字列
#include <unordered_map> //イテレータあるけど順序保持しないmap
#include <unordered_set> //イテレータあるけど順序保持しないset
#include <utility>       //pair
#include <vector>        //可変長配列

using namespace std;
typedef long long ll;

//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i, n) for (ll i = 0; i < (ll)(n); i++)
#define REPD(i, n) for (ll i = n - 1; i >= 0; i--)
#define FOR(i, a, b) for (ll i = a; i <= (ll)(b); i++)
#define FORD(i, a, b) for (ll i = a; i >= (ll)(b); i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(), (x).end() //sortなどの引数を省略したい
#define SIZE(x) ((ll)(x).size())      //sizeをsize_tからllに直しておく
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 1000000007    //10^9+7:合同式の法
#define MAXR 100000       //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define FIR first    //pairの一つ目の要素
#define SEC second   //pairの二つ目の要素

signed main()
{
    //入力の高速化用のコード
    ios::sync_with_stdio(false);
    cin.tie(nullptr);

    ll N;
    cin >> N;

    vector<int> A(N);
    REP(i, N)
    {
        cin >> A[i];
    }

    sort(ALL(A), greater<int>());
    ll Alice = 0, Bob = 0;

    REP(i, N)
    {
        if (i % 2 == 0)
        {
            Alice += A[i];
        }
        else
        {
            Bob += A[i];
        }
    }

    cout << Alice - Bob << endl;

    return 0;
}


Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define INS(x) x.begin(),x.end()
    

    
int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    int a,b;
    cin>>a>>b;

    for (int i=b*10;i<b*10+10;i++)
    {
        if (int(1.0*i*8/100)==a) {cout<<i<<'\n'; return 0;}
    }

    cout<<"-1\n";
    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define all(s) s.begin(), s.end()
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;
const ll mod = 1e9+7;

int n,t;
vi a;
vi mx,mn;

int main()
{
    cin >> n >> t;
    a.resize(n); rep(i,n) cin >> a[i];
    int t=0;
    mx.resize(n); mn.resize(n);
    drep(i,n){
        if(a[i] > t){
            mx[i] = a[i];
            t = a[i];
        }
        else mx[i] = t;
    }

    int b=INF;
    rep(i,n){
        if(a[i] < b){
            mn[i] = a[i];
            b = a[i];
        }
        else mn[i] = b;
    }

    int mxd = 0;
    vp kumi;
    rep(i,n){
        if(mx[i] - mn[i] > mxd){
            mxd = mx[i] - mn[i];
            kumi.clear();
            kumi.pb(mp(mx[i], mn[i]));
        }
        else if(mx[i] - mn[i] == mxd){
            kumi.pb(mp(mx[i], mn[i]));
        }
        else continue;
    }
    sort(all(kumi));
    vp kumi_a;
    kumi_a.pb(kumi[0]);
    rrep(i, kumi.size()-1){
        if(kumi[i] != kumi[i-1]){
            kumi_a.pb(kumi[i]);
        }
    }
    cout << kumi_a.size() << endl;
}


Measured memory_bytes: 3060
use utf8;

binmode STDOUT, ':utf8';

$N = <STDIN>;
chomp $N;
%name;
$answer = 0;

for ($count = 0; $count < $N; $count++ ) {
	$str = <STDIN>;
	chomp $str;
	if ( $name{$str} != 1 ) {
		$answer++;
	}
	$name{$str} = 1;
}

print $answer;

Measured memory_bytes: 30776
import sys
readline = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 8)
INF = float('inf')
MOD = 10 ** 9 + 7

def main():
    N = int(readline())
    S = readline().decode('utf-8').strip()
    ans = 0
    for i in range(10):
        x = S.find(str(i), 0, N-2)
        if x != -1:
            for j in range(10):
                y = S.find(str(j), x+1, N-1)
                if y != -1:
                    for k in range(10):
                        z = S.find(str(k), y+1, N)
                        if z != -1:
                            ans += 1
    print(ans)
if __name__ == '__main__':
    main()

Measured memory_bytes: 3064
#include <cstdio>
#include <iostream>
#include <cstdlib>
#include <math.h>
#include <algorithm>
#include <string.h>
#include <iomanip>
using namespace std;

int main(void){
    string s,out; 
    int a,b,temp;
    cin >> s;
    temp = stoi(s);
    a = temp / 100;
    b = temp - a*100;
    if(0 < a && a < 13){
        a = 1;
    }else{
        a = 0;
    }
    if(0 < b && b < 13){
        b = 1;
    }else{
        b = 0;
    }
    if(a == 1 && b == 1){
        out = "AMBIGUOUS";
    }else if(a == 1){
        out = "MMYY";
    }else if(b == 1){
        out = "YYMM";
    }else{
        out = "NA";
    }
    cout << out << endl;
}

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

int main()
{
	int a,b;
	int cost;
	cin>>a>>b;
	if(a >= 13)
		cost = b;
	else if(a>= 6)
		cost = b/2;
	else
		cost = 0;
	cout<<cost;
	return 0;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;

namespace CSharpSample01
{
    
    class Program
    {
        

        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());

            HashSet<long> hset = new HashSet<long>();

            for(int i = 0; i < N; i++)
            {
                long a = long.Parse(Console.ReadLine());

                if (hset.Contains(a))
                {
                    hset.Remove(a);
                }
                else
                {
                    hset.Add(a);
                }

            }

            Console.WriteLine(hset.Count);

        }
    }
}

Measured memory_bytes: 22620
k = int(input())

B = [1, 2, 3, 4, 5, 6, 7, 8, 9] #Before list
while len(B) < k:
    k -= len(B)
    #次の桁に更新
    def update_next_digit(B:list)->list:
        N = []  #New list
        for i in range(len(B)):
            op = B[i] % 10  #one place   
            for j in [-1, 0, 1]:
                if 0 <= op+j and op+j <= 9:
                    N.append(B[i]*10+(op+j))
                else:
                    pass
        return N
    N = update_next_digit(B)
    B = N

ans = B[k-1]
print(ans)






Measured memory_bytes: 11028
import sys
readline = sys.stdin.readline

H, W = map(int, readline().split())

Gr = [list(map(lambda x: int(x) if x != '#' else 7, readline().strip())) for _ in range(H)]

Ri = []
for h in range(H):
    if h % 4 == 0:
        Ri.append([6, 3, 1, 4]*W)
    elif h % 4 == 1:
        Ri.append([2, 8, 2, 8]*W)
    elif h % 4 == 2:
        Ri.append([1, 3, 6, 4]*W)
    else:
        Ri.append([5, 8, 5, 8]*W)

for h in range(H):
    for w in range(W):
        if Gr[h][w] != Ri[h][w]:
            Gr[h][w] = -1

stack = [(0, 0)]
used = set(stack)
dim = [(0, -1), (0, 1), (1, 0), (-1, 0)]
while stack:
    nx, ny = stack.pop()
    for dx, dy in dim:
        fx, fy = nx+dx, ny+dy
        if not 0 <= fx < W or not 0 <= fy < H:
            continue
        if Gr[fy][fx] == -1:
            continue
        if (fx, fy) in used:
            continue
        used.add((fx, fy))
        stack.append((fx, fy))
print('YES' if (W-1, H-1) in used else 'NO')            


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

int main(){
  int N;
  cin >> N;
  vector<int> A(N,0);
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  sort(A.begin(),A.end());
  int ans=0;
  for(int i=0;i<N;){
    int cur = A[i];
    bool dif = false;
    for(int j=0;j<=N;j++){
      if(i+j==N){
        //cout << "#" << endl;
        dif = true;
      }else if(A[i+j]!=cur){
        //cout << "$"  << i << j << endl;
        dif = true;
      }
      if(dif){
        i += j;
        if(j>=cur){
          //cout << "+=;" << "(" << j <<" - " << cur << ")" << endl;
          ans += (j-cur);
        }else{
          //cout << "+=:" << j << endl;
          ans += j;
        }
        break;
      }
    }
  }
  cout << ans << endl;
}

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

int main(){
  char c;
  cin>>c;
  
  if(c =='a' || c=='i' || c=='u' || c=='e' || c=='o'){
    cout<<"vowel"<<endl;
  }
  else{
    cout<<"consonant"<<endl;
  }
  
  return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Scanner;
import java.util.function.BiFunction;

public class Main {
  Scanner sc = new Scanner(System.in);

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

  void run() {
    int n = ni();
    int k = ni();
    int sum = k;
    for (int i = 1; i < n; ++i) {
      sum *= k - 1;
    }
    System.out.println(sum);
  }

  int ni() {
    return Integer.parseInt(sc.next());
  }

  void debug(Object... os) {
    System.err.println(Arrays.deepToString(os));
  }

  class BIT<T> {
    int n;
    ArrayList<T> bit;
    BiFunction<T, T, T> bif;

    BIT(int n, BiFunction<T, T, T> bif, T defaultValue) {
      this.n = n;
      bit = new ArrayList<>(n + 1);
      for (int i = 0; i < n + 1; ++i) {
        bit.add(defaultValue);
      }
      this.bif = bif;
    }

    void update(int i, T v) {
      for (int x = i; x <= n; x += x & -x) {
        bit.set(x, bif.apply(bit.get(x), v));
      }
    }

    T reduce(int i, T defaultValue) {
      T ret = defaultValue;
      for (int x = i; x > 0; x -= x & -x) {
        ret = bif.apply(ret, bit.get(x));
      }
      return ret;
    }
  }

}

Measured memory_bytes: 9556
#入力
N,M,Q = map(int,input().split())

a = [0] * Q
b = [0] * Q
c = [0] * Q
d = [0] * Q

ans = 0

for i in range(Q):
    ai,bi,ci,di = map(int,input().split())
    # ai,biは添字
    a[i] = ai -1
    b[i] = bi -1
    c[i] = ci
    d[i] = di

#全探索DFS
def dfs(A):
    if len(A) == N:
        score = 0
        for i in range(Q):
            if (A[b[i]] - A[a[i]] ) == c[i]:
                score += d[i]
        global ans
        ans = max(ans,score)
        return
    #数列の最後の値を確認する
    #数列の長さが 0 のときは1
    prev_last = A[-1] if len(A) > 0 else 1

    #1<A1<A2 ..... < An の単調増加なので
    #vを回す範囲は数列の前回の値の最後の値から
    for v in range(prev_last,M+1):
        A.append(v)
        dfs(A)
        A.pop()

dfs([])

print(ans)


Measured memory_bytes: 9172
n = gets.chomp!.to_i
s_p = []
n.times do |i|
    s, p = gets.chomp!.split(" ")
    s_p << [s, p.to_i, i + 1]
end

s_p.sort! {|a, b| (a[0] <=> b[0]).nonzero? || (b[1] <=> a[1]) }
s_p.each {|x, y, z|
  puts z
}


Measured memory_bytes: 1788
n = gets.to_i
as = gets.split.map &:to_i

m = {}

as.each_with_index{ |a, i|
	if m[a] == nil then
		m[a] = []
	end
	
	m[a] << i
}

ind = -1

res = -1

(1..n).each{ |i|
	if m[i] != nil then
		c_ind = m[i].index{ |x| x > ind } 
		if c_ind != nil then
			ind = m[i][c_ind]
		else
			res = i
			break
		end
	else
		res = i
		break
	end
}

if res == -1 then
	puts 0
elsif res == 1 then
	puts -1
else
	puts n - res + 1
end


Measured memory_bytes: 38284
#include <bits/stdc++.h>
#define MAX (ll)(2e5 + 7)
#define INF (ll)(1e17)
#define MOD (int)(1e9 + 7)
#define PI (double)(3.14159265)
#define IO ios_base :: sync_with_stdio (false);
#define LOG 25

using namespace std;
using ll = long long;

bool ch (string st) {
	int mi = -1;
	for (int i = 0; i < st.size (); i++) {
		int x = st[i] - 'a';
		if (x > mi + 1) {
			return 0;
		}
		mi = max (x , mi);
	}
	return 1;
}
	
int main () {
	int n;
	cin >> n;
	vector<pair<string, int>> sp;
	sp.push_back (make_pair ("a", 0));
	for (int i = 2; i <= n; i++) {
		vector<pair<string, int>> sx;
		for (int j = 0; j < sp.size (); j++) {
			for (int x = 0; x <= sp[j].second + 1; x++) {
				string s = sp[j].first;
				s.push_back ('a' + x);
				sx.push_back (make_pair (s, max (sp[j].second, x)));
			}
		}
		sp = sx;
	}
	for (int i = 0; i < sp.size (); i++) {
		if (sp[i].first.size () == n){
			cout << sp[i].first << "\n";
		}
	}
}


Measured memory_bytes: 10984
#include <iostream>
#include <utility>
#include <map>
#include <vector>
#include <algorithm>
#include <queue>
#include <math.h>
#include <stack>
#include <set>
#include <deque>
#include <cmath>

using namespace std;
typedef long long ll;
ll mod = 1e9+7;
//ll mod = 998244353;
#define rep(i,n) for(int i = 0; i < (n); ++i)

int main() {
    string s;
    cin >> s;
    int n = s.size();
    ll ans = 0;
    rep(i, 1<<(n-1)) {
        ll num = s[0] - '0';
        rep(j, n-1) {
            if ((i>>j) &1) {
                //cout << num << endl;
                ans += num;
                num = s[j+1] - '0';
            }
            else {
                num = num * 10 + s[j+1] - '0';
            }
        }
        //cout << num << endl;
        ans += num;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3608
#include<iostream>
#include<sstream>
#include<algorithm>
#include<climits>
#include<cmath>
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cfloat>
#include<functional>
#include<map>
#include<string>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<deque>
#include<set>
#include<bitset>
#include<list>
#include<numeric>
#include<complex>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<long long, int> ll_i;
typedef pair<double, int> d_i;
typedef pair<long long, long long> ll_ll;
typedef pair<double, double> d_d;
typedef vector<int> Vint;

#define PI 3.141592653589793238462643383279
#define mod 1000000007LL
#define rep(i, n) for(i = 0;i < n;++i)
#define rep1(i, n) for(i = 1;i < n;++i)
#define rep2d(i, j, n) for(i = 0;i < n;++i)for(j = i + 1;j < n;++j)
#define per(i, n) for(i = n - 1;i > -1;--i)
#define int(x) int x; scanf("%d",&x)
#define int2(x, y) int x, y; scanf("%d%d",&x, &y)
#define int3(x, y, z) int x, y, z; scanf("%d%d%d",&x, &y, &z)
#define scn(n, a) rep(i, n)cin >> a[i]
#define sc2n(n, a, b) rep(i, n)cin >> a[i] >> b[i]
#define pri(x) cout << x << "\n"
#define pri2(x, y) cout << x << " " << y << "\n"
#define pri3(x, y, z) cout << x << " " << y << " " << z << "\n"
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define endl "\n"
#define kabe puts("---------------------------")
#define kara puts("")
#define debug(x) cout << " --- " << x << "\n"
#define debug2(x, y) cout << " --- " << x << " " << y << "\n"
#define debug3(x, y, z) cout << " --- " << x << " " << y << " " << z << "\n"
#define X first
#define Y second
#define eps 0.0001
#define prid(x) printf("%.15lf\n", x)

struct result{
  int id, ac, time;
  Vint pena;
  void use(int n){ pena.assign(n, 0); return; }
};

bool myc(result a, result b){
  if(a.ac == b.ac && a.time == b.time)return a.id < b.id;
  if(a.ac == b.ac)return a.time < b.time;
  return a.ac > b.ac;
}

signed main(void){
  int i, j, k;
  for(int testcase = 0;testcase < 1234567;testcase++){
    int3(t, p, r);
    if((t | p | r) == 0)break;

    vector<result> team;
    team.resize(t);
    rep(i, t){
      team[i].use(p); team[i].id = i + 1;
    }

    for(;r--;){
      int3(x, y, z);
      x--; y--;
      string s; cin >> s;
      if(s == "WRONG")team[x].pena[y]++;
      else{
        team[x].ac++;
        team[x].time += z + team[x].pena[y] * 1200;
      }
    }

    sort(all(team), myc);
    rep(i, t)pri3(team[i].id, team[i].ac, team[i].time);


//*/

//*/ break;
  }
  return 0;
}

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

import math

N, D = map(int, input().split())
X = [None] * N
for i in range(N):
    X[i] = list(map(int, input().split()))

ans = 0
for i in range(N):
    for j in range(i+1, N):
        dis_2 = sum([(y - z) ** 2 for (y, z) in zip(X[i], X[j])])
        if int(math.sqrt(dis_2)) ** 2 == dis_2:
            ans += 1

print(ans)


Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
long double X[200100];
int N;
long long Count(long double len)
{
  long long Ans=0;
  for(int i=0;i<N;i++)
  {
    //Ans+=(long long)(X[i]/len);
    Ans+= ceil(X[i]/len)-1;
  }
  return Ans;
}

int main()
	{
	  long long K;
	  cin>>N>>K;
	  for(int i=0;i<N;i++)
	{
		cin>>X[i];
		//X[i]-=0.1;
	}

  long double l=1,r=1e9;
  //while(l<r-0.1)//解答を引っ張ってきた人の条件。なぜかOKだったが、lとｒの整数部が異なる状態でループを出ると問題になるはず
	for(int i=0;i<35;i++)//OK log2(10^9)=30.二分探索だとこのやり方安定する。ただし、浮動小数のせいか34以上でないと通らず。
  //while(!((ceil(r)-ceil(l)) == 0))//NG:左端が初期値0のままだと、右端のceilは0にならず、無限ループ
	//while(!((floor(r)-floor(l)) == 0))//OK:右端がぴったり整数にならなければ成立.(あまりよくない)
  {
    long double mid=(l+r)/2;
    if(Count(mid)<=K) r=mid;
    else	l=mid;
  }
  cout<<(long long)(l+0.999)<<endl;
  return 0;
}

Measured memory_bytes: 6836
#10000a+5000b+1000c=1000/1000*y & a+b+c=n
n,y=map(int,input().split())
y=y//1000
#10a+5b+c=y & a+b+c=n
#をみたすa,b,cの組
for i in range(y//10+1):
  for j in range((y-10*i)//5+1):
    k=n-i-j
    if 10*i+5*j+1*k==y and k>=0:
      print(i,j,k)
      exit()
      
print(-1,-1,-1)

Measured memory_bytes: 3060
import java.util.Scanner;

public class Main {

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

		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		String ans = "";

		if ( b-a == c-b ) {
			ans = "YES";
		} else {
			ans = "NO";
		}
		System.out.println( ans );
	}
}

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

int main(int argc, char const *argv[]) {
  string str;

  getline(cin, str);
  int i;
  for (i = 0; i < str.size(); i++) {
    if ('a' <= str[i] && str[i] <= 'z')
      str[i] -= 32;
    else if ('A' <= str[i] && str[i] <= 'Z')
      str[i] += 32;
  }
  cout << str << endl;

  return 0;
}



Measured memory_bytes: 3152
#include <bits/stdc++.h>
#define INF 1e18
#define int long long
#define Rep(i, a, n) for (int i = (a); i < (n); i++)
#define rep(i, n) Rep(i, 0, n)
#define all(a) (a).begin(), (a).end()
using namespace std;
typedef pair<int, int> P;
typedef pair<int, P> PP;
const int mod = 1000000007;
//const int mod = 998244353;

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

    while (1)
    {
        int t, d, l;
        cin >> t >> d >> l;
        if (t == 0)
            break;
        int ans = 0, last = 0;
        rep(i, t)
        {
            int x;
            cin >> x;
            if (last > 0)
                ans++, last--;
            if (x >= l)
                last = d;
        }
        cout << ans << endl;
    }
}



Measured memory_bytes: 3164
import sys
input = sys.stdin.readline
import bisect
n,m,k = [int(i) for i in input().split()]
ans = [-1]*n

def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

def size(x):
    return -par[find(x)]

par = [-1]*n
g = [[] * n for i in range(n)]
for i in range(m):
  a,b = [int(i) for i in input().split()]
  unite(a-1,b-1)
  ans[a-1] -= 1
  ans[b-1] -= 1
  
def same(x,y):
    return find(x) == find(y)
for i in range(k):
  u, v = map(int, input().split())
  if same(u-1,v-1):
    ans[u-1] -= 1
    ans[v-1] -= 1
  
for i in range(n):
  ans[i] += size(i)
  
print(*ans)

Measured memory_bytes: 20536
n = int(input())
h = list(map(int, input().split()))

inf = 100000000

dp = [inf for _ in [0]*n]

dp[0] = 0
dp[1] = abs(h[1] - h[0])

for i in range(2, n):
	dp[i] = min(dp[i-1] + abs(h[i] - h[i-1]), dp[i - 2] + abs(h[i] - h[i-2]))

print(dp[-1])


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

int n, vis[1000][1000], tot = 0;

inline void add(int x, int y) {
    if (!vis[x][y]) ++tot;
    vis[x][y] = vis[y][x] = 1;
}

int main() {
    cin >> n;
    bool check = false;
    if (n % 2) check = 1, n -= 1;
    int t = n / 2, m = 4 * (n - 1);
    for (int i = 1; i < n / 2; ++i)
        add(i, i + 1),
        add(n - i + 1, i + 1),
        add(i, n - i),
        add(n - i + 1, n - i);
    if (check) {
        add(n + 1, n / 2);
        add(n + 1, n / 2 + 1);
        add(1, n + 1);
        add(n, n + 1);
    } else {
        add(n / 2, 1),
        add(n / 2, n),
        add(n / 2 + 1, n),
        add(n / 2 + 1, 1);
    }
    cout << tot << endl;
    if (check) n += 1;
    for (int i = 1; i <= n; ++i)
        for (int j = i + 1; j <= n; ++j)
            if (vis[i][j])
                printf("%d %d\n", i, j);
    return 0;
}


Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
const int MOD=(int)1e9+7;
const int INF=(int)1e9;
const ll LINF=(ll)1e18;

ll modpow(ll x,ll n){
    ll res=1;
    while(n>0){
        if(n&1)res=res*x%MOD;
        x=x*x%MOD;
        n>>=1;
    }
    return res;
}

int n;
ll ans;
vector<vector<int>> e(200000);

int dfs(int v,int p){
    int res=1;
    for(int u:e[v]){
        if(u!=p){
            int tmp=dfs(u,v);
            res+=tmp;
            ll a=modpow(2,n)-modpow(2,n-tmp);
            ll b=modpow(2,n)-modpow(2,tmp);
            ans+=a*b;
            ans%=MOD;
        }
    }
    return res;
}

int main(){
    cin>>n;
    for(int i=0;i<n-1;i++){
        int s,t;
        cin>>s>>t;
        --s,--t;
        e[s].push_back(t);
        e[t].push_back(s);
    }
    ans=((2-n)*modpow(2,2*n-1))-modpow(2,n);
    ans%=MOD;
    dfs(0,-1);
    ans=(ans+MOD)%MOD;
    ll x=modpow(2,2*n);
    ans*=modpow(x,MOD-2);
    ans%=MOD;
    cout<<ans<<endl;
}

Measured memory_bytes: 20096
#include <stdio.h>
int main(void){
    int a,b,c;
    
    scanf("%d %d %d",&a,&b,&c);
    

  if(a < b && b < c) 
  printf("%d %d %d\n",a ,b ,c);
  
  else if(a <= c && c <= b)
  printf("%d %d %d\n",a ,c ,b);
  
  else if(b <= a && a <= c)
  printf("%d %d %d\n",b ,a ,c);
  
  else if(b <= c && c <= a)
  printf("%d %d %d\n",b ,c ,a);
  
  else if(c <= a && a <= b)
  printf("%d %d %d\n",c ,a ,b);
  
  else if(c <= b && b <= a)
  printf("%d %d %d\n",c ,b ,a);
 

    return 0;
    
}



Measured memory_bytes: 2112
N = int(input())
A = []
max_a = 0
max_index = 0

for i in range(0, N):
    ai = int(input())
    A.append(ai)
    if max_a < ai:
        max_a = ai
        max_index = i

A.remove(max_a)

for i in range(0, N):
    if i != max_index:
        print(max_a)
    else:
        print(max(A))




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

int main() {
  int n;
  cin >> n;
  ll ans=0;
  int y;
  for (ll i=1;i*i<=n;i++) {
    ll d=n/i;
    ans+=i*(d+1)*d/2;
    y=i;
  }
  int z=n/(y+1);
  for (ll i=1;i<=z;i++) {
      ll low=n/(i+1);
      ll high=n/i;
      ll x=high*(high+1)/2-low*(low+1)/2;
      ans+=x*i*(i+1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3648
if __name__ == "__main__":
    s = input()
    k = int(input())

    s_num = [0] * len(s)
    res = k
    for i in range(len(s)):
        tmp = ord(s[i]) - 97
        if tmp != 0 and 26 - tmp <= res:
            res -= (26 - tmp)
            s_num[i] = 0
        else:
            s_num[i] = tmp

    res %= 26

    s_num[-1] += res

    ans = ''
    for i in s_num:
        ans += chr(i + 97)

    print(ans)


Measured memory_bytes: 4212
import math

a,b,x=map(int,input().split())

if 2*x<=a*a*b:
    p1=a*b*b
    p2=2*x
else:
    p1=2*(a*a*b-x)
    p2=a*a*a

sit=math.atan(p1/p2)
print(math.degrees(sit))


Measured memory_bytes: 2940
def main():
    n = int(input())
    a = list(map(int,input().split()))
    
    if 0 in a:
        print(0)
        return
    
    prod = 1
    for i in a:
        prod *= i
        if prod > 10 ** 18:
            print(-1)
            return
    
    print(prod)
    
    return

main()

Measured memory_bytes: 21544
// use std::ops::{Index, IndexMut};
// use std::cmp::{Ordering, min, max};
// use std::collections::{BinaryHeap, BTreeMap};
// use std::collections::btree_map::Entry::{Occupied, Vacant};
// use std::clone::Clone;

fn getline() -> String{
    let mut res = String::new();
    std::io::stdin().read_line(&mut res).ok();
    res
}

macro_rules! readl {
    ($t: ty) => {
        {
            let s = getline();
            s.trim().parse::<$t>().unwrap()
        }
    };
    ($( $t: ty),+ ) => {
        {
            let s = getline();
            let mut iter = s.trim().split(' ');
            ($(iter.next().unwrap().parse::<$t>().unwrap(),)*) 
        }
    };
}

macro_rules! readlvec {
    ($t: ty) => {
        {
            let s = getline();
            let iter = s.trim().split(' ');
            iter.map(|x| x.parse().unwrap()).collect::<Vec<$t>>()
        }
    }
}

macro_rules! mvec {
    ($v: expr, $s: expr) => {
        vec![$v; $s]
    };
    ($v: expr, $s: expr, $($t: expr),*) => {
        vec![mvec!($v, $($t),*); $s]
    };
}

macro_rules! debug {
    ($x: expr) => {
        println!("{}: {:?}", stringify!($x), $x)
    }
}

fn printiter<'a, T>(v: &'a T)
where
    &'a T: std::iter::IntoIterator, 
    <&'a T as std::iter::IntoIterator>::Item: std::fmt::Display {
    for (i,e) in v.into_iter().enumerate() {
        if i != 0 {
            print!(" ");
        }
        print!("{}", e);
    }
    println!("");
}

fn main() {
    let (a, b, c) = readl!(i32, i32, i32);
    println!("{}", a^b^c);
}



Measured memory_bytes: 4352
def main():
    N = int(input())
    v = [list(map(int,input().split())) for _ in range(N)]

    dp = [[0]*3 for _ in range(N+1)]

    for i in range(N):
        for j in range(3):
            for k in range(3):
                if j==k:continue
                dp[i+1][k] = max(dp[i+1][k],dp[i][j]+v[i][k])
    print(max(dp[N][i] for i in range(3)))
main()

Measured memory_bytes: 50216
from math import *

N = int(input())
all_input_list = [list(map(int, input().split())) for i in range(N)]
x, y, h = [all_input_list[i] for i in range(N) if all_input_list[i][2] > 0][0]
for cx in range(101):
    for cy in range(101):
        H = h + abs(cx - x) + abs(cy - y)
        for input_list in all_input_list:
            if (input_list[2] != max(H - abs(cx - input_list[0]) - abs(cy - input_list[1]), 0)):
                break
        else:
            print("%s %s %s" % (cx, cy, H))
            exit()


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

int M,K;

void solve(){
    for(int i = 0; i < (1<<M); ++i){
        if(i==K) continue;
        cout << i << " ";
    }
    cout << K << " ";
    for(int i = (1<<M)-1; i >= 0;--i){
        if(i==K) continue;
        cout << i << " ";
    }
    cout << K << "\n";
}

int main(){
    cin >> M >> K;

    if(M == 0){
        if(K == 0) cout << "0 0" << "\n";
        else cout << -1 << "\n";
    } else if(M == 1){
        if(K == 0) cout << "0 0 1 1" << "\n";
        else cout << -1 << "\n";
    } else if(K >= (1<<M)){
        cout << -1 << "\n";
    } else {
        solve();
    }   
    return 0;
}

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

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n,sum=0,mi=1000000001;
	cin>>n;
	vector<ll>a(n),b(n);
	for(ll i=0;i<n;i++){
		cin>>a.at(i);
		sum+=a.at(i);
		if(i>=1){
			b.at(i)=sum;
		}
	}
	for(ll i=1;i<n-1;i++){
		mi=min(abs(b.at(i)-(sum-b.at(i))),mi);
	}
	if(n==2) mi=abs(a.at(0)-a.at(1));
	cout<<mi<<endl;
	return 0;
}


Measured memory_bytes: 3456
#include <bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define R cin>>
#define Z class
#define ll long long
#define ln cout<<'\n'
#define in(a) insert(a)
#define pb(a) push_back(a)
#define pd(a) printf("%.10f\n",a)
#define mem(a) memset(a,0,sizeof(a))
#define all(c) (c).begin(),(c).end()
#define iter(c) __typeof((c).begin())
#define rrep(i,n) for(ll i=(ll)(n)-1;i>=0;i--)
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define tr(it,c) for(iter(c) it=(c).begin();it!=(c).end();it++)
template<Z A>void pr(A a){cout<<a;ln;}
template<Z A,Z B>void pr(A a,B b){cout<<a<<' ';pr(b);}
template<Z A,Z B,Z C>void pr(A a,B b,C c){cout<<a<<' ';pr(b,c);}
template<Z A,Z B,Z C,Z D>void pr(A a,B b,C c,D d){cout<<a<<' ';pr(b,c,d);}
template<Z A>void PR(A a,ll n){rep(i,n){if(i)cout<<' ';cout<<a[i];}ln;}
ll check(ll n,ll m,ll x,ll y){return x>=0&&x<n&&y>=0&&y<m;}
const ll MAX=1e9+7,MAXL=1LL<<61,dx[4]={-1,0,1,0},dy[4]={0,1,0,-1};
typedef pair<int,int> P;

void Main() {
  int n;
  R n;
  pr(n/3);

}

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


Measured memory_bytes: 256
#include <stdio.h>
#define N 100000

int parent(int i){
  return i/2;
}

int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i + 1;
}

int main(){

  int i, n, A[N+1];

  scanf("%d", &n);
  for(i=1; i<=n; i++){
    scanf("%d", &A[i]);
  }

  for(i=1; i<=n; i++){
    printf("node %d: key = %d, ", i, A[i]);
    if(parent(i) >= 1) printf("parent key = %d, ", A[parent(i)]);
    if(left(i) <= n) printf("left key = %d, ", A[left(i)]);
    if(right(i) <= n) printf("right key = %d, ", A[right(i)]);
    printf("\n");
  }
  
  return 0;
}

Measured memory_bytes: 608
package main

import "fmt"

func main() {

	var X int
	fmt.Scan(&X)

	if X <= 99 {
		fmt.Println("0")
		return
	}
	if 100 <= X && X <= 105 {
		fmt.Println("1")
		return
	}

	d := make([]bool, X+1)
	for i := 0; i <= 99; i++ {
		d[i] = false
	}
	for i := 100; i <= 105; i++ {
		d[i] = true
	}
	for i := 106; i <= X; i++ {
		d[i] = d[i-100] || d[i-101] || d[i-102] || d[i-103] || d[i-104] || d[i-105]
	}
	if d[X] {
		fmt.Println("1")
	} else {
		fmt.Println("0")
	}
}

Measured memory_bytes: 640
#include "bits/stdc++.h"
#define FOR(i, a, b) for (int i = a; i < b; i++)
#define mFOR(i, a, b) for (int i = a; i > b; i--)
#define MP make_pair
#define PB push_back
#define ALL(v) v.begin(), v.end()
#define N 100007
#define INF 1000000007
using namespace std;

typedef long long ll;

ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll fceil(ll a, ll b) { return (a % b == 0 ? a / b : a / b + 1); }
int main()
{
   string s, ans = "Yes";
   cin >> s;
   int n = s.length();
   FOR(i, 0, n)
   {
      if (i % 2 == 0 && s[i] == 'L' || i % 2 == 1 && s[i] == 'R')
      {
         ans = "No";
         break;
      }
   }
   cout << ans << endl; 
   return 0;
}


Measured memory_bytes: 256
fn main() {
    let first_line = read::<isize>();
    let point_cnt = first_line[0];
    let limit = first_line[1];
    let limit_mul = limit * limit;
    let points = read_lines::<isize>(point_cnt as usize);
    let mut avail_cnt = 0;
    for point in points {
        let x = point[0];
        let y = point[1];
        let xy = x * x + y * y;
        if xy <= limit_mul {
            avail_cnt+=1;
        }
    }
    println!("{}", avail_cnt);
}

use std::io::{self, BufRead, Read};
use std::vec::Vec;
fn read<T: std::str::FromStr>() -> Vec<T> {
    let stdin = io::stdin();
    let mut buf = String::new();
    stdin.lock().read_line(&mut buf).unwrap();
    parse_line(&buf)
}

fn read_lines<T: std::str::FromStr>(count: usize) -> Vec<Vec<T>> {
    let stdin = io::stdin();
    let mut stdin = stdin.lock();
    let mut result = Vec::<Vec<T>>::with_capacity(count);
    for _ in 0..count {
        let mut buf = String::new();
        stdin.read_line(&mut buf).unwrap();
        result.push(parse_line(&buf));
    }
    result
}

fn parse_line<T: std::str::FromStr>(string: &str) -> Vec<T> {
    string.trim().split(' ').map(|s| T::from_str(s).ok().unwrap()).collect()
}
// x^2 + y^2 = distance^2

Measured memory_bytes: 12784
n = int(input())
l = list(map(int, input().split()))

ans = 0
for i in range(n-2):
  for j in range(i+1, n-1):
    for k in range(j+1, n):
      if l[i] != l[j] and l[i] != l[k] and l[j] != l[k]:
        if l[i]+l[j] > l[k] and l[i]+l[k] > l[j] and l[j]+l[k] > l[i]: ans += 1
print(ans)

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

#define ll long long
#define vecll vector<ll>
#define vecpair vector<pair<ll, ll>>
#define print(x) cout << x << endl
#define prints(x) cout << x << " "
#define printline cout << endl

int main()
{
    std::ios_base::sync_with_stdio(false);
    ll k;
    ll ans = 0;
    cin >> k;
    ll len = 0;
    ll n = k;
    while (n)
    {
        n = n / 10;
        len++;
    }
    ll init = 0;
    for (ll i = 0; i < len; i++)
    {
        init = init * 10 + 7;
    }
    ans=len;
    if (init < k)
    {
        init = init * 10 + 7;
        ans++;
    }
    ll rems[(ll)1e6];
    memset(rems, 0, sizeof(ll) * (1e6));
    ll d = init;
    while (1)
    {
        if (d % k == 0){
            break;
        }
        if (d < k)
        {
            ans++;
            d = d * 10 + 7;
            continue;
        }
        d = d - (d / k) * k;
        if (rems[d])
        {
            ans = -1;
            break;
        }
        rems[d] = 1;
    }
    print(ans);
    return 0;
}

Measured memory_bytes: 11500