akhauriyash/Code-Regression huggingface dataset:
import sys
import heapq
import math
import fractions
import bisect
import itertools
from collections import Counter
from collections import deque
from operator import itemgetter
def input(): return sys.stdin.readline().strip()
def mp(): return map(int,input().split())
def lmp(): return list(map(int,input().split()))

x,y=mp()
ans=0
while x<=y:
    ans+=1
    x*=2
print(ans)

Measured memory_bytes: 5068
#include <bits/stdc++.h>
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP(i, n) FOR(i, 0, n)
#define EACH(i, c) for (typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define EXIST(s, e) ((s).find(e) != (s).end())
#define SORT(c) sort((c).begin(), (c).end())
#define dump(x) cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" \
                      << " " << __FILE__ << endl;
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define MP make_pair
#define SZ(a) int((a).size())

using namespace std;


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

    int n;
    cin >> n;

    vector<int> v;
    int t;
    REP(_, n){cin >> t; v.PB(t);}

    int sum = accumulate(ALL(v), 0);
    int res = INT_MAX;
    int ans = 0;
    REP(i, n){
        if (abs(n*v[i]-sum)<res){
            res = abs(n*v[i]-sum);
            ans = i;
        }
    }

    cout << ans;
    return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>

int main(){
    int x, a;
    while(scanf("%d", &a) != EOF){
        x = 100000;
        for(;a > 0;a--){
            x *= 1.05;
            if(x % 1000)
                x = (x / 1000 + 1) * 1000;
}
        printf("%d\n", x);

    }
    return 0;
}


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

int main(){
    int N,M;
    long long K;
    cin >> N >> M >> K;
    long long SA = 0,SB = 0;
    vector<long long> pA(N+1),pB(M+1);
    pA[0] = 0, pB[0] = 0;
    for(long long i = 1; i < N+1; i++){
        long long A; cin >> A;
        SA += A;
        pA[i] = SA;
    }
    
    for(long long i = 1; i < M+1; i++){
        long long B; cin >> B;
        SB += B;
        pB[i] = SB;
    }
    
    long long ans = 0;
    //cout << pB[3] << endl;
    for(int i = 0; i < N+1; i++){
        //cout << pA[i]<< endl;  
        decltype(pB)::iterator iter_lower = upper_bound(pB.begin(), pB.end(), K-pA[i]); 
        long long n = distance(pB.begin(), iter_lower);
        //cout << i <<" "<< n << endl;
        //cout << K - pA[i] << endl;
        if(K-pA[i]>=0)ans = max(ans, n+i+1-2);
        
    }
    cout << ans << endl;
}


Measured memory_bytes: 6416
def LI():
    return list(map(int, input().split()))


a, b, c, d = LI()

ans = a*c
ans = max(ans, a*d)
ans = max(ans, b*c)
ans = max(ans, b*d)
if a == 0:
    if b != 0:
        ans = max(ans, c)
        ans = max(ans, d)
if b == 0:
    if a != 0:
        ans = max(ans, -1*c)
        ans = max(ans, -1*d)
if c == 0:
    if d != 0:
        ans = max(ans, a)
        ans = max(ans, b)
if d == 0:
    if c != 0:
        ans = max(ans, -1*a)
        ans = max(ans, -1*b)

print(ans)


Measured memory_bytes: 9220
n, m, x=gets.split.map &:to_i
a=(0...n).map{gets.split.map &:to_i}

INF=Float::INFINITY
res=INF
(0...2**n).each{|i|
    cost=0
    v=[0]*m
    (0...n).each{|j|
        if i[j]==1
            cost+=a[j][0]
            (0...m).each{|k| v[k]+=a[j][k+1]} if i[j]==1
        end
    }
    res=cost if res>cost and v.all?{|e|e>=x}
}
puts res<INF ? res : -1


Measured memory_bytes: 14284
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 1e9 + 7;
const int INF = 2e18;

signed main() {
    int N;
    cin >> N;
    vector<set<int>> side(N + 1);
    queue<pair<int, int>> ab;
    for (int i = 0; i < N - 1; i++) {
        int a, b;
        cin >> a >> b;
        ab.emplace(a, b);
    }
    int c = 0;
    while (!ab.empty()) {
        auto now = ab.front();
        ab.pop();
        auto input = [&](int a, int b) {
            set<int> temp = side[a];
            temp.insert(c++);
            side[b] = temp;
        };
        if (!side[now.first].empty() || now.first == 1) {
            input(now.first, now.second);
            continue;
        } else if (!side[now.second].empty() || now.second == 1) {
            input(now.second, now.first);
            continue;
        }
        ab.push(now);
    }
    side[1] = set<int>();
    int M;
    cin >> M;
    vector<int> limit(M);
    for (int i = 0; i < M; i++) {
        int v, u;
        cin >> v >> u;
        {
            auto temp = side[u];
            auto itr = side[v].begin();
            while (itr != side[v].end()) {
                if (temp.find(*itr) == temp.end()) temp.insert(*itr);
                else temp.erase(*itr);
                itr++;
            }
            limit[i] = 0;
            itr = temp.begin();
            while (itr != temp.end()) {
                limit[i] |= (1LL<<*itr);
                ++itr;
            }
        }
    }
    int ans = (1LL<<(N - 1));
    for (int i = 1; i < (1LL<<M); i++) {
        int count = 0;
        for (int j = 0; j < M; j++) count += (i>>j) & 1;
        int temp = 0;
        for (int j = 0; j < M; j++) {
            if (!((i>>j) & 1)) continue;
            temp |= limit[j];
        }
        int now = N - 1;
        for (int j = 0; j < N - 1; j++) if ((temp>>j)&1LL) now--;
        // if (i % 100000 == 0) cout << i << endl;
        if (count % 2 == 1) ans -= (1LL<<now);
        else ans += (1LL<<now);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
h, w = map(int, input().split())

s = [list(input()) for i in range(h)]

dx = (1, 1, 0, -1, -1, -1, 0, 1)
dy = (0, 1, 1, 1, 0, -1, -1, -1)

ans = [[0 for i in range(w)] for j in range(h)]
for i in range(h):
  for j in range(w):
    if s[i][j] == '#':
      ans[i][j] = '#'
    else:
      count = 0
      for k in range(8):
        if i + dx[k] < 0 or h <= i + dx[k]:
          continue
        elif j + dy[k] < 0 or w <= j + dy[k]:
          continue
        elif s[i+dx[k]][j+dy[k]] == '#':
          count += 1
      ans[i][j] = str(count)


for i in range(h):
  print(''.join(ans[i]))


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

int main(void) {
    char s[3];

    cin >> s;
    int c=700;
    for(int i=0; i<3; i++){
       if(s[i]=='o') c+=100;
    }
    
    cout << c << endl;
    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define ALL(x) x.begin(), x.end()
#define iostreamBooster() do{ cin.tie(nullptr); ios_base::sync_with_stdio(false); }while(0)
#define rep(i, s, n) for(i64 i=(s); i < (n); ++i)
using namespace std;
using i64 = long long;
using pii = pair<int, int>;
template<class A, class B>inline bool chmax(A &a, const B &b){return b>a ? a=b,1 : 0;}
template<class A, class B>inline bool chmin(A &a, const B &b){return b<a ? a=b,1 : 0;}
constexpr int INF  = 0x3f3f3f3f;
constexpr i64 LINF = 0x3f3f3f3f3f3f3f3fLL;
constexpr int MOD  = int(1e9) + 7;

signed main()
{
  int N, K;
  string s;

  cin >> N >> s >> K;

  char x = s[K-1];
  for (char &c : s) {
    if (c != x) c = '*';
  }
  cout << s << endl;
  return 0;
}



Measured memory_bytes: 384
fun main(array: Array<String>) {
    val (h, w) = readLine()!!.split(" ").map { it.toInt() }
    for(i in 1..h+2) {
        when (i) {
            1 -> {
                repeat(w+2) {
                    print("#")
                }
                println("")
            }
            h+2 -> {
                repeat(w+2) {
                    print("#")
                }
            }
            else -> {
                val s = readLine()!!
                repeat((w + 2 - s.length) / 2) {
                    print("#")
                }
                print(s)
                repeat((w + 2 - s.length) / 2) {
                    print("#")
                }
                println("")
            }
        }
    }
}

Measured memory_bytes: 37944
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 1000000009
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    rep(i,8){
        string t = "";
        t += s[0];
        int x = i;
        rep(j,3){
            if(x&1){
                t += "+";
                t += s[j+1];
            }else{
                t += "-";
                t += s[j+1];
            }
            x >>= 1;
        }
        int tmp = t[0]-'0';
        rep(j,3){
            tmp += (44 - t[j * 2 + 1]) * (t[j * 2 + 2]-'0');
        }
        if(tmp == 7){
            t += "=7";
            cout << t << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
N=int(input())
numbers =input().rstrip().split(" ")
points=[]
for i in range(1,101):
    summ=0
    for j in range(N):
        summ=summ+(int(numbers[j])-i)*(int(numbers[j])-i)
    points.append(summ)
print(sorted(points)[0])

Measured memory_bytes: 3060
import           Control.Monad
import qualified Data.ByteString.Char8 as BS
import           Data.List
import           Data.Maybe
import qualified Data.Sequence         as Seq

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine

main = do
  n <- getInt
  as <- getIntList
  let aseq = Seq.unstableSort $ Seq.fromList as
      a1 Seq.:< aseq' = Seq.viewl aseq
      aseq'' Seq.:> an = Seq.viewr aseq'

      assortAs ps ns sq | Seq.null sq = (ps, ns)
                        | otherwise =
                          let aj Seq.:< sq' = Seq.viewl sq
                          in
                            if aj > 0
                            then assortAs (aj:ps) ns sq'
                            else assortAs ps (aj:ns) sq'

      (ps, ns) = assortAs [an] [a1] aseq''

      ans = sum ps - sum ns

      printOps [a] [b] = putStrLn $ show a ++ " " ++ show b
      printOps [a] (b:ns) = do putStrLn $ show a ++ " " ++ show b
                               printOps [a-b] ns
      printOps (a:ps) (b:ns) = do putStrLn $ show b ++ " " ++ show a
                                  printOps ps (b-a:ns)

  print ans
  printOps ps ns

Measured memory_bytes: 27516
#include "bits/stdc++.h"
using namespace std;
#define Rep(i,n) for(int i=0;i<n;i++)
#define For(i,n1,n2) for(int i=n1;i<n2;i++)
#define REP(i,n) for(ll i=0;i<n;i++)
#define RREP(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,n1,n2) for(ll i=n1;i<n2;i++)
#define put(a) cout<<a<<"\n"
#define all(a)  (a).begin(),(a).end()
#define SORT(a) sort((a).begin(),(a).end())
#define oorret 0
#define oor(x) [&](){try{x;} catch(const out_of_range& oor){return oorret;} return x;}()
typedef long long ll;
typedef pair<int, int> P;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){if(a>b){a=b;return 1;}return 0;}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){if(a<b){a=b;return 1;}return 0;}

int main(){
    vector<string> st(3);
    REP(i,3){
        cin >> st[i];
    }
    vector<queue<int>> s(3);
    REP(i,3){
        REP(j,st[i].size()){
            s[i].push(st[i][j]-'a');
        }
    }
    int turn = 0;
    while(!s[turn].empty()){
        int temp = s[turn].front();
        s[turn].pop();
        turn = temp;
    }
    cout << (char)('A'+turn) << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, itertools, collections, fractions
sys.setrecursionlimit(10**7)
def lmi(): return list(map(int, input().split()))

n = int(input())
a = [lmi() for i in range(n)]
c = 0
# print(sorted(a, key = lambda x: x[1]))
for i in sorted(a, key = lambda x: x[1]):
    c += i[0]
    # print(c)
    if c > i[1]:
        print('No')
        break
else:
    print('Yes')


Measured memory_bytes: 57228
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define ALL(v) v.begin(),v.end()
using ll = long long;
using pii = pair<int,int>;
using vi = vector<int>;
using vs = vector<string>;
using vb = vector<bool>;
using vll = vector<long long>;
using vpii = vector<pair<int,int>>;
using vivi = vector<vector<int>>;
using vbvb = vector<vector<bool>>;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
const int mod = 1000000007;
const int inf = 1001001001;



int main(void) {
  int n,k;
  cin >> n >> k;
  vi a(n,0);
  set<int> b;
  rep(i,n) {
    int p;
    cin >> p;
    p--;
    a[p]++;
    b.insert(p);
  }
  int cnt = 0;
  int kae = 0;
  sort(ALL(a));
  rep(i,n){
    if(b.size()-kae<=k) break;
    if(a[i]==0)continue;
    cnt+=a[i];
    kae++;
    
  }
  cout << cnt << endl;
  
}




Measured memory_bytes: 10368
MOD = 10 ** 9 + 7
fac = [1] * (5 * 10 ** 5 + 1)
for i in range(len(fac) - 1):
    fac[i + 1] = fac[i] * (i + 1) % MOD


n, k = map(int, input().split())
if k >= n:
    print(fac[2 * n] * pow(2, MOD - 2, MOD) *
          pow(fac[n], MOD - 2, MOD) ** 2 % MOD)
else:
    ans = 0
    for i in range(k + 1):
        ans += fac[n - 1] * pow(fac[i], MOD - 2, MOD) * \
            pow(fac[n - i - 1], MOD - 2, MOD) * fac[n] * pow(fac[n - i],
                                                             MOD - 2, MOD) * pow(fac[i], MOD - 2, MOD) % MOD
    print(ans % MOD)


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

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

  int maxAbs = 0;
  for(int i = 0; i < n; ++i) {
    for(int j = 0; j < n; ++j) {
      int tmpAbs = A[i] - A[j];
      if(i != j && tmpAbs > maxAbs) {
        maxAbs = tmpAbs;
      }
    }
  }

  cout << maxAbs;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cmath>
using namespace std;

int a,b;
char st;
int main(){
  while(true){
  scanf("%d %c %d",&a,&st,&b);
  switch(st){
  case '+':
    printf("%d\n",a+b);
    break;
  case '-':
    printf("%d\n",a-b);
    break;
  case '*':
    printf("%d\n",a*b);
    break;
  case '/':
    printf("%d\n",a/b);
    break;
  default:
    return 0;
     }
  }
  
    return 0;
}

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

#define d(x) cerr << #x ":" << x << endl;
#define dd(x, y) cerr << "(" #x "," #y "):(" << x << "," << y << ")" << endl
#define rep(i, n) for (int i = (int)(0); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
#define dump(v)                  \
    cerr << #v ":[ ";            \
    for (auto macro_vi : v) {    \
        cerr << macro_vi << " "; \
    }                            \
    cerr << "]" << endl;
#define ddump(v)                           \
    cerr << #v ":" << endl;                \
    for (auto macro_row : v) {             \
        cerr << "[";                       \
        for (auto macro__vi : macro_row) { \
            cerr << macro__vi << " ";      \
        }                                  \
        cerr << "]" << endl;               \
    }
using lint       = long long;
const int INF    = 1e9;
const lint LINF  = 1e18;
const double EPS = 1e-10;

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

    vector<vector<int>> D(N, vector<int>(2));
    rep(i, N) { cin >> D[i][0] >> D[i][1]; }

    for (int i = 0; i < N - 2; i++) {
        if (D[i][0] == D[i][1] && D[i + 1][0] == D[i + 1][1] &&
            D[i + 2][0] == D[i + 2][1]) {
            cout << "Yes" << endl;
            return 0;
        }
    }

    cout << "No" << endl;

    return 0;
}

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

#define FOR(i,a,b) for(int i=(a);i<(int)(b);i++)
#define rep(i,n) FOR(i,0,n)
#define ZERO(a) memset(a,0,sizeof(a))
#define pb push_back

int rank[1020];

int main() {
    int n, m;
    ZERO(rank);
    cin >> n >> m;
    vector<int> v;
    rep(i,n) {
        int cost; scanf("%d",&cost);
        v.pb(cost);
    }

    rep(i,m) {
        int c; scanf("%d",&c);
        rep(j,n) if(c >= v[j]) {
            rank[j+1]++; break;
        }
    }

    int ans = 0, ma = 0;
    rep(i,1001) if(ma < rank[i]) {
        ma = rank[i];
        ans = i;
    }
    cout << ans << "\n";

    return 0;
}

Measured memory_bytes: 1276
N=int(input())
A=list(map(int,input().split()))
B=list(map(int,input().split()))
C=list(map(int,input().split()))

P=0
P+=B[A[0]-1]
for i in range(N-1):
    if A[i]!=N and A[i+1]==A[i]+1:
        u=B[A[i+1]-1]
        q=C[A[i+1]-2]
        o=u+q
        P+=o
    else:
        u=B[A[i+1]-1]
        P+=u
    
print(int(P))

Measured memory_bytes: 3064
// Jump, and you will find out how to unfold your wings as you fall.

#include<bits/stdc++.h>

#define F first
#define S second
#define PB push_back
#define sz(s) int((s).size())
#define bit(n,k) (((n)>>(k))&1)

using namespace std;

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int maxn=1e5+10,mod=1e9+7;
const ll inf=1e18;

vector<int>vec,ans;

int main(){
    ios_base::sync_with_stdio(false);cin.tie(0);
    int n;cin>>n;
    vec.resize(n);
    for(int i=0;i<n;i++){
	cin>>vec[i];
    }
    while(sz(vec)){
	int pos=-1;
	for(int i=0;i<sz(vec);i++){
	    if(vec[i]==i+1)
		pos=i;
	}
	if(pos==-1) return cout<<-1<<endl,0;
	ans.PB(vec[pos]);
	while(pos<sz(vec)-1){
	    swap(vec[pos],vec[pos+1]);
	    pos++;
	}
	vec.pop_back();
    }
    reverse(ans.begin(),ans.end());
    for(int x:ans){
	cout<<x<<"\n";
    }
}
// Deathly mistakes:
//  * Read the problem curfully.
//  * Check maxn.
//  * Overflows.


Measured memory_bytes: 256
#include<iostream>
#include<vector>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)

void op(int beg,int end){
  if (beg == end)cout << beg ;
  else cout << beg <<"-"<<end;
}

main(){
  int n;
  while(cin>>n && n){
    vector<int> in(n);
    rep(i,n)cin>>in[i];
    in.push_back(-1);
    int p=1,last=0;
    int cnt=0;
    while(p < in.size()){
      if (p-last == in[p]-in[last]);
      else {
	if (cnt)cout <<" ";
	op(in[last],in[p-1]),last=p;
	cnt++;
      }
      p++;
    }
    cout << endl;
  }
  return false;
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define rep(i,m) for(long long i=0; i<m; i++)
#define per(i,m) for(long long i=m-1; i>=0; i--)
#define FOR(i,n,m) for(long long i=n; i<m; i++)
#define ROF(i,n,m) for(long long i=m-1; i>=n; i--)
#define SORT(v,n) do{sort(v,v+n);reverse(v,v+n);}while(0)
#define all(x) (x).begin(),(x).end()
#define EPS (1e-7)
#define INF (1e18)
#define PI (acos(-1))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
using namespace std;
typedef long long ll;
const ll MOD = 1000000007;
typedef pair<ll, ll> LP;

ll POW(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW(x*x,n/2)%MOD;
  return x%MOD*POW(x,n-1)%MOD;
}

ll POW2(ll x,ll n){
  if(n==0)return 1;
  if(n%2==0)return POW2(x*x,n/2);
  return x*POW2(x,n-1);
}

ll gcd(ll u, ll v) {
  ll r;
  while (0 != v) {
    r = u % v; u = v; v = r;
  }
  return u;
}
 
ll KAI(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI(m-1)%MOD;
}
 
ll KAI2(ll m)
{
  if(m<0) return 0;
  if(m==0) return 1;
  return m*KAI2(m-1);
}

ll extGCD(ll a, ll b, ll &x, ll &y) {
    if (b == 0) {
        x = 1;
        y = 0;
        return a;
    }
    ll d = extGCD(b, a%b, y, x);
    y -= a / b * x;
    return d;
}
 
inline ll mod(ll a, ll m) {
    return (a % m + m) % m;
}
 
ll modinv(ll a) {
    ll x, y;
    extGCD(a, MOD, x, y);
    return mod(x, MOD);
}
 
ll COM(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI(m)%MOD*modinv(KAI(n)%MOD*KAI(m-n)%MOD)%MOD;
}

ll COM2(ll m,ll n)
{
  if(m<n) return 0;
  if(n<0) return 0;
  if(n==0) return 1;
  if(m==n) return 1;
  return KAI2(m)/KAI2(n)/KAI2(m-n);
}

ll DEC(ll x,ll m,ll n)
{
  return x%POW(m,n+1)/POW(m,n);
}

ll keta(ll x,ll n)
{
  if(x==0)return 0;
  return keta(x/n,n)+1;
}

ll DIV(ll x,ll n)
{
  if(x==0)return 0;
  return x/n+DIV(x/n,n);
}

ll ORD(ll x,ll n)
{
  if(x==0)return INF;
  if(x%n!=0)return 0;
  return 1+ORD(x/n,n);
}

int main()
{
  string s;
  ll a[6]={};
  cin >> s;
  rep(i,s.length()){
    if(s[i]=='N')a[0]=1;
    if(s[i]=='W')a[1]=1;
    if(s[i]=='S')a[2]=1;
    if(s[i]=='E')a[3]=1;
  }
  if(a[0]==a[2]&&a[1]==a[3])printf("Yes");
  else printf("No");
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <algorithm>
#include <tuple>
using namespace std;

typedef pair<int,int> P;//駅id,会社id(0は改札外)
map<P,map<P,int>> G;//エッジリスト(キモい)
map<P,int> memo;
const int INF = 1000000000;
typedef tuple<int,int,int> T;//cost,駅id,会社id
priority_queue<T,vector<T>,greater<T>> que;
#define mygc(c) (c)=getchar_unlocked()
void reader(int *x){int k,m=0;*x=0;for(;;){mygc(k);if(k=='-'){m=1;break;}if('0'<=k&&k<='9'){*x=k-'0';break;} }for(;;){mygc(k);if(k<'0'||k>'9')break;*x=(*x)*10+k-'0';}if(m)(*x)=-(*x);}

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

    int N,M;
    //cin>>N>>M;
    reader(&N); reader(&M);
    for(int i=1;i<=N;i++) memo[P(i,0)]=INF;
    for(int i=0;i<M;i++){
        int p,q,c;
        //cin>>p>>q>>c;
        reader(&p); reader(&q); reader(&c);
        G[P(p,c)][P(q,c)]=0;
        G[P(p,c)][P(p,0)]=0;
        G[P(p,0)][P(p,c)]=1;
        G[P(q,c)][P(p,c)]=0;
        G[P(q,c)][P(q,0)]=0;
        G[P(q,0)][P(q,c)]=1;
        memo[P(p,c)]=memo[P(q,c)]=INF;
    }
    memo[P(1,0)]=0;
    que.emplace(0,1,0);
    while(!que.empty()){
        T t = que.top(); que.pop();
        int cost=get<0>(t), station=get<1>(t), company=get<2>(t);
        if(station==N){
            cout<<cost<<endl;
            return 0;
        }
        if(cost>memo[P(station,company)]) continue;
        //if(cost>memo[P(station,0)]+1) continue;
        for(auto &g:G[P(station,company)]){
            const P &p = g.first; int fee=g.second;
            if(cost+fee<memo[p]&&cost+fee<=memo[P(p.first,0)]+1){
                memo[p]=cost+fee;
                que.emplace(cost+fee,p.first,p.second);
            }
        }
    }
    cout<<-1<<endl;
    return 0;
}

Measured memory_bytes: 121076
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Atc_0045
{
    class Program
    {
        static void Main(string[] args)
        {
            var S = Console.ReadLine();

            int A = int.Parse(S.Split(' ')[0]);
            int B = int.Parse(S.Split(' ')[1]);
            int C = int.Parse(S.Split(' ')[2]);

            int K = int.Parse(Console.ReadLine());

            for (int i = 0; i < K; i++)
            {
                if (B <= A)
                {
                    B = 2 * B;

                    continue;
                }

                if (C <= B)
                {
                    C = 2 * C;
                }
            }

            if (B <= A || C <= B)
            {
                Console.WriteLine("No");
            }
            else
            {
                Console.WriteLine("Yes");
            }
        }

    }
}


Measured memory_bytes: 27520
#include <cstdio>
#include <algorithm>

typedef long long LL;
const int Mod = 1000000007;
const int MN = 100005;

inline int qPow(int b, LL e) {
	e = (e % (Mod - 1) + Mod - 1) % (Mod - 1);
	int a = 1;
	for (; e; e >>= 1, b = (LL)b * b % Mod)
		if (e & 1) a = (LL)a * b % Mod;
	return a;
}

int N, A[MN];
LL B[MN];
int stk[MN], val[MN], top;
inline bool cmp(int i, int j) { return A[i] < A[j]; }
int f[MN];

int main() {
	scanf("%d", &N);
	for (int i = 1; i <= N; ++i) scanf("%d", &A[i]);
	A[0] = A[N + 1] = 1;
	for (int i = 1; i <= N; ++i) B[i] = A[i - 1] < A[i] ? A[i] - A[i - 1] : 0;
	for (int i = 1; i <= N; ++i) B[i] += B[i - 1];
	f[0] = 1;
	stk[top = 1] = 0;
	for (int i = 1; i <= N + 1; ++i) {
		f[i] = f[i - 1] * 2 % Mod;
		if (A[i - 1] > A[i]) {
			int p = std::lower_bound(stk + 1, stk + top + 1, i, cmp) - stk;
			f[i] = (f[i] + (LL)qPow(2, B[i - 1] + 1) * (val[top] - val[p] + Mod)) % Mod;
			if (p > 1 && A[i] < A[stk[p]]) f[i] = (f[i] + (LL)qPow(2, B[i - 1] - B[stk[p - 1] + 1] + A[stk[p - 1] + 1] + 1) * (qPow(2, -A[i] + 1) - qPow(2, -A[stk[p]] + 1) + Mod) % Mod * f[stk[p - 1]]) % Mod;
		}
		while (top && A[stk[top]] >= A[i]) --top;
		stk[++top] = i;
		if (top > 1) val[top] = (val[top - 1] + (LL)qPow(2, A[stk[top - 1] + 1] - B[stk[top - 1] + 1] + 1) * (qPow(2, -A[stk[top - 1]]) - qPow(2, -A[stk[top]]) + Mod) % Mod * f[stk[top - 1]]) % Mod;
	}
	printf("%lld\n", (LL)qPow(2, -1) * f[N + 1] % Mod);
	return 0;
}

Measured memory_bytes: 128
#include<cstdio>
#define For(i,A,B) for(i=A;i<=(B);++i)
char a[1005][1005];
void work(int x,int k){
	if(k==4){
		a[x][x]=a[x][x+1]=a[x][x+3]=a[x+1][x+3]=a[x+2][x]=a[x+3][x]=a[x+3][x+2]=a[x+3][x+3]='a';
		a[x+1][x]=a[x+1][x+1]=a[x+2][x+2]=a[x+2][x+3]='b';
		a[x][x+2]=a[x+1][x+2]=a[x+2][x+1]=a[x+3][x+1]='c';
	}else if(k==5){
		a[x][x]=a[x][x+1]=a[x][x+4]=a[x+1][x+4]=a[x+3][x]=a[x+4][x]=a[x+4][x+3]=a[x+4][x+4]='a';
		a[x][x+2]=a[x][x+3]=a[x+1][x]=a[x+2][x]=a[x+2][x+4]=a[x+3][x+4]=a[x+4][x+1]=a[x+4][x+2]='b';
		a[x+1][x+1]=a[x+1][x+2]=a[x+2][x+3]=a[x+3][x+3]='c';
	}else if(k==6){
		a[x][x]=a[x][x+1]=a[x][x+3]=a[x+1][x+3]=a[x+2][x+5]=a[x+3][x+2]=a[x+3][x+3]=a[x+3][x+5]=a[x+4][x]=a[x+5][x]=a[x+5][x+4]=a[x+5][x+5]='a';
		a[x+1][x]=a[x+1][x+1]=a[x+2][x+2]=a[x+2][x+3]=a[x+4][x+1]=a[x+4][x+4]=a[x+4][x+5]=a[x+5][x+1]='b';
		a[x][x+2]=a[x+1][x+2]=a[x+2][x+4]=a[x+3][x+4]='c';
	}else{
		a[x][x]=a[x][x+1]=a[x][x+6]=a[x+1][x+6]=a[x+2][x+2]=a[x+2][x+3]=a[x+3][x+4]=a[x+4][x+4]=a[x+5][x]=a[x+6][x]=a[x+6][x+5]=a[x+6][x+6]='a';
		a[x][x+2]=a[x][x+3]=a[x+2][x+6]=a[x+3][x]=a[x+3][x+6]=a[x+4][x]=a[x+6][x+3]=a[x+6][x+4]='b';
		a[x+1][x+1]=a[x+1][x+2]=a[x+1][x+5]=a[x+2][x+5]=a[x+4][x+1]=a[x+5][x+1]=a[x+5][x+4]=a[x+5][x+5]='c';
	}
}
int main(){
	int n,i,j;
	scanf("%d",&n);
	if(n==2)puts("-1");
	else if(n==3)puts("aa.\n..a\n..a");
	else{
		For(i,1,n)
			For(j,1,n)a[i][j]='.';
		For(i,0,(n>>2)-2)work((i<<2)+1,4);
		i=(n&3)+4;
		work(n-i+1,i);
		For(i,1,n)puts(a[i]+1);
	}
	return 0;
}

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

int main(){
	int h, w, d, in, q;
	cin >> h >> w >> d;
	map<int, int> y;
	map<int, int> x;
	rep(i, h){
		rep(j, w){
			cin >> in;
			in--;
			y[in] = i;
			x[in] = j;
		}	
	}
	cin >> q;
	vector<int> a(h*w);
	rep(i, d){
		int yn = y[h*w-1-i];
		int xn = x[h*w-1-i];
		int ym = yn;
		int xm = xn;
		int dsum = 0;
		for(int j=0; j>=0; j++){
			if(h*w-1-i-j*d < 0) break;
			ym = yn;
			xm = xn;
			yn = y[h*w-1-i-j*d];
			xn = x[h*w-1-i-j*d];
			dsum += abs(ym - yn) + abs(xm - xn);
			a.at(h*w-1-i-j*d) = dsum;
//			cout << h*w-1-i-j*d << ' ' << ym << ' ' << yn  << ' ' << xm << ' ' << xn << ' ' << dsum << endl;
		}
	}
	rep(i, q){
		int ia, ib;
		cin >> ia >> ib;
		ia--; ib--;
		int ans = a.at(ia);
		ans -= a.at(ib);
		cout << ans << endl;
	}
	return 0;
}

Measured memory_bytes: 11264
/*
  author:@bhaskar_8998
*/
#include<bits/stdc++.h>
using namespace std;
typedef long long i64;
typedef vector<i64> vi;
typedef pair<int,int>ii;
typedef vector<ii> vii;
typedef map<int,int> mi;
#define all(A) (A).begin(),(A).end()
#define pb push_back
#define MOD 1000000007
#define ff first
#define ss second
#define deb(x) cerr<<#x<<" "<<x<<"\n";
#define fastio() {ios_base::sync_with_stdio(false);cin.tie(NULL);}

int main(){
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    freopen("error.txt", "w", stderr);
    #endif
    fastio();
    clock_t beg=clock();
    int t=1;
    // cin>>t;
    while(t--){
      int n;
      cin>>n;
      vi v;
      for(int i=0,a;i<n;i++){
        cin>>a;
        v.pb(a);
      }

      sort(all(v));
      reverse(all(v));
      i64 c=v[0];
      int ct=1;
      for(int i=1;i<n-1;i++){
        // cerr<<v[ct]<<" ";
        c+=v[ct];
        if(i%2==0)ct+=1;
      }
      // c+=min(v[n-2],v[1]);
      cout<<c;
    }
    clock_t end=clock(); 
    fprintf(stderr, "\n%lf sec\n", (double)(end-beg)/(CLOCKS_PER_SEC));
    return 0;
}


  

Measured memory_bytes: 5368
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ull unsigned ll
#define PI acos(-1)
#define vi vector<int>
#define pi pair<int, int>
#define pl pair<ll, ll>
template<typename T> using v2 = vector<vector<T>>;
template<typename T> using v3 = vector<vector<vector<T>>>;
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
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; }
const int MOD = 998244353;
const int INF = 1e9 + 200;
const ll INFLL = 2e18 + 200;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    cin >> A;
    vector<int> ans(N, 0);
    for (int i = 0; i <= 30; i++) {
        int cnt = 0;
        for (int j = 0; j < N; j++) if (((A[j]>>i)&1) == 1) cnt++;
        if (cnt == 0) continue;
        for (int j = 0; j < N; j++) {
            if (cnt % 2 == 1) {
                if (((A[j]>>i)&1) == 0) ans[j] |= (1<<i);
            } else {
                if (((A[j]>>i)&1) == 1) ans[j] |= (1<<i);
            }
        }
    }
    for (int i = 0; i < N; i++) {
        cout << ans[i] << (i == N - 1 ? '\n' : ' ');
    }
}

Measured memory_bytes: 4792
import math
A, B, H, M = map(float, input().split())

m_angle = 6.0 * M
h_angle = 30.0 * H + 0.5 * M

theta = abs(h_angle - m_angle)
theta = min(theta, 360.0 - theta)
print(math.sqrt(A * A + B * B - 2 * A * B * math.cos(math.radians(theta))))

Measured memory_bytes: 9384
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<cmath>
#include<map>
#include<iomanip>
#include<queue>
#include<stack>
#include<time.h>
#define rep(i,n)for(int i=0;i<n;i++)
#define int long long
#define ggr getchar();getchar();return 0;
#define prique priority_queue
#define mod 1000000007
#define inf 1e15
#define double long double
using namespace std;
typedef pair<int, int>P;
void pyes() { cout << "Yay!" << endl; }
void pno() { cout << ":(" << endl; }
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;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
//繰り返し二乗法
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
//xCy
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y)* mod_pow(kai(y, y), mod - 2, mod) % mod;
}
int f(int x) {
	int ans = 1;
	for (int i = 1; i <= x; i++) {
		ans *= i;
		ans %= mod;
	}
	return ans;
}
struct edge { int to, cost; };
signed main() {
	int x;
	cin >> x;
	int p = x / 100;
	int q = x % 100;
	if (5 * p < q)cout << 0 << endl;
	else cout << 1 << endl;
	ggr
}


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

void inputData(int R[], int *N)
{
	cin >> *N;
	for (int i = 0; i < *N; i++)
	{
		cin >> R[i];
	}
}

bool isPrimeNumber(int in)
{
	if (in == 2) return true;
	if (in % 2 == 0) return false;
	int s = (int)sqrt((double)in);

	for (int i = 3; i <= s; i=i+2)
	{
		if ((in % i) == 0)
		{
			return false;
		}
	}
	return true;
}

static const int MAX = 10000;

int main()
{
	int R[MAX];
	int N;
	int count = 0;
	inputData(R, &N);
	for (int i = 0; i < N; i++)
	{
		if (isPrimeNumber(R[i]))
		{
			count++;
		}
	}
	cout << count << endl;
	return 0;
}

Measured memory_bytes: 3096
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <ctype.h>
#include <map>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <cctype>
#include <queue>
#include <set>
#include <list>
#define PI 3.141592653
#define rep(i,a,n) for(int i=a;i<(int)n;++i)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;
const ll INF=1e9+7;

int main(void) {
	int n;
	cin >> n;
	vector<int> d(n);
	rep(i, 0, n)cin >> d[i];
	int ans = 0;
	rep(i, 0, n) {
		rep(j, i + 1, n) {
			ans += d[i] * d[j];
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
int main(){
    int H,W;
    string s[50];
    int dx[4] = {0,1,0,-1};
    int dy[4] = {1,0,-1,0};
    cin >> H >> W;
    for(int i=0;i<H;i++) cin >> s[i];

    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            if(s[i][j]=='#'){
            int flag = 0;
                for(int k=0;k<4;k++){
                    int x = i + dx[k];
                    int y = j + dy[k];
                    if(x<0||x>=H) continue;
                    if(y<0||y>=W) continue;
                    if(s[x][y]=='.')  flag+=1;
                    flag-=1;
                    //cout << flag << ' '<< i<<' '<< j << ' ' << k << endl;
                }
                if(flag==0){
                    cout <<"No";
                    return 0;
                }
            }
        }
    }
    cout << "Yes";
    return 0;
}

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

signed main(void)
{
	int n, x, l;
	int now, cnt;
	cin >> n >> x;

	now  = 0;
	cnt = 1;
	rep(i, n)
	{
		cin >> l;
		now += l;
		if (now <= x)
			cnt++;
	}
	cout << cnt << endl;
}


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

int main()
{
    std::string s, T;
    std::cin >> s;
    std::cin >> T;
    
    for (int i = s.length() - T.length(); i >= 0;  i--) {
        bool ok = true;
        for (int j = 0; j < T.length(); j++) {
            if(s[i+j] != T[j] && s[i+j] != '?') {
                ok = false;
                break;
            }
        }
        if(ok) {
            for (int j = 0; j < T.length(); j++) {
                s[i+j] = T[j];
            }
            for (int j = 0; j < s.length(); j++) {
                if(s[j] == '?') s[j] = 'a';
            }
            std::cout << s << std::endl;
            return 0;
        }
    }
    
    std::cout << "UNRESTORABLE" << std::endl;
    
    return 0;
}

Measured memory_bytes: 256
#define _USE_MATH_DEFINES

#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <cmath>
#include <cstring>
#include <algorithm>
#include <vector>
#include <queue>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

using namespace std;

typedef pair<long long int, long long int> P;
typedef tuple<int, int, int> T;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

int main(){
    int N;
    cin >> N;
    double A[1100];
    double S = 0;
    for(int i = 0; i < N; i++){
        cin >> A[i];
        S += 1 / A[i];
    }
    printf("%.10f\n", 1 / S);
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<utility>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<complex>
#define INF 2147483647
#define llINF 9223372036854775807
#define pb push_back
#define mp make_pair 
#define F first
#define S second
#define ll long long

using namespace std;
int main(){
  int num[1010]={};
  for(int i=1;i<=1001;i++){
    num[i]=num[i-1]+i;
  }
  int n;
  while(cin>>n,n){
    int ans=0;
    for(int i=0;i<=1000;i++){
      for(int j=i+2;j<=1000;j++){
	if(num[j]-num[i]==n){ans++;}
      }
    }
    cout<<ans<<endl;
  }
  return 0;
}



Measured memory_bytes: 3076
#include <iostream>
#include <fstream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <bitset>
#include <algorithm>
#include <complex>
#include <array>
#include <functional>
using namespace std;

#define REP(i,n) for(int i=0; i<n; ++i)
#define FOR(i,a,b) for(int i=a; i<=b; ++i)
#define FORR(i,a,b) for (int i=a; i>=b; --i)
#define ALL(c) (c).begin(), (c).end()

typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<double> VD;
typedef vector<VI> VVI;
typedef vector<VL> VVL;
typedef vector<VD> VVD;
typedef pair<int,int> P;
typedef pair<ll,ll> PL;

template<typename T> void chmin(T &a, T b) { if (a > b) a = b; }
template<typename T> void chmax(T &a, T b) { if (a < b) a = b; }

int in() { int x; scanf("%d", &x); return x; }
ll lin() { ll x; scanf("%lld", &x); return x; }

int main(void){
    ll x, k, d;
    cin >> x >> k >> d;
    if (x < 0) x *= -1;
    ll ans;
    if (x / d >= k) ans = x - k * d;
    else {
        ll r = x % d;
        k -= x / d;
        if (k % 2 == 0) ans = r;
        else ans = d - r;
    }
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
const int mod = 1e9+7;
 
int dx[]={1,-1,0,0,1,-1,1,-1};
int dy[]={0,0,1,-1,1,-1,-1,1};






 
int32_t main()
{

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

  int r;
  cin>>r;
 
 double p=acos(-1);
 cout<<setprecision(10)<<fixed<<p*2*r*1.0<<"\n";


}




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

using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define MOD 1000000007LL

#define rep(i, n) for(ll (i) = 0LL;(i) < (ll)(n);(i)++)
#define rep2(i, s, e) for(ll (i) = (ll)(s);(i) < (ll)(e);(i)++)
#define repi(i, n) for(ll (i) = 0LL;(i) <= (ll)(n);(i)++)
#define repi2(i, s, e) for(ll (i) = (ll)(s);(i) <= (ll)(e);(i)++)
#define per(i, n) for(ll (i) = (ll)(n) - 1LL;(i) >= 0LL;(i)--)
#define per2(i, s, e) for(ll (i) = (ll)(s) - 1LL;(i) >= (ll)(e);(i)--)
#define peri(i, n) for(ll (i) = (ll)(n);(i) >= 0LL;(i)--)
#define peri2(i, s, e) for(ll (i) = (ll)(s);(i) >= (ll)(e);(i)--)
#define iter(i, it) for(auto &(i): (it))

template<typename T, typename U> ostream& operator<<(ostream &s, const pair<T, U> m) {
    cout << "(" << m.first << ", " << m.second << ")";
    return s;
}
template<typename T, typename U> ostream& operator<<(ostream &s, const map<T, U> m) {
    ll c = 0;
    cout << "{ ";
    iter(i, m) cout << i << (c++ == m.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const vector<T> &v) {
    cout << "{ ";
    rep(i, v.size()) cout << v[i] << (i == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}
template<typename T> ostream& operator<<(ostream &s, const list<T> &v) {
    ll c = 0;
    cout << "{ ";
    iter(i, v) cout << i << (c++ == v.size() - 1 ? " " : ", ");
    cout << "}";
    return s;
}

int main(void) {
    vector<ll> A{5, 5, 7};
    vector<ll> B(3);
    rep(i, 3) cin >> B[i];
    sort(B.begin(), B.end());
    if(A == B) cout << "YES";
    else cout << "NO";
    cout << endl;
    return 0;
}


Measured memory_bytes: 3528
#include <iostream>
#include <map>

constexpr int M = 1000000007;

#define int long long

using namespace std;

int modpow(int n, int k = M - 2) {
  if (k == 0) return 1;
  auto prev = modpow(n, k / 2);
  if (k % 2 == 0)
    return (prev * prev) % M;
  else
    return (((prev * prev) % M) * n) % M;
}

int comb(int n, int k) {
  int res = 1;
  for (int i = 1; i <= k; i++) {
    res *= n - i + 1;
    res %= M;
    res *= modpow(i);
    res %= M;
  }
  return res;
}

map<int, int> factorize(int n) {
  map<int, int> factors;
  for (int i = 2; i * i <= n; i++) {
    while (n % i == 0) {
      factors[i]++;
      n /= i;
    }
  }
  if (n != 1)
    factors[n] = 1;
  return factors;
}

signed main() {
  int n, m;
  cin >> n >> m;
  auto&& factors = factorize(m);
  int patterns = 1;
  for (auto&& p : factors) {
    patterns *= comb(n - 1 + p.second, p.second);
    patterns %= M;
  }
  cout << patterns << endl;
}


Measured memory_bytes: 256
#include <stdio.h>

int main(){
    char str[4];
    int a = 0;
    scanf("%s", str);

    if(str[0] == '1') a++;
    if(str[1] == '1') a++;
    if(str[2] == '1') a++;

    printf("%d\n", a);
    return 0;
}

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

int main()
{
	int a;
	int result[1000];
	int b[1000];
	int i;
	int total = 0;
	cin >> a;
	
	for (i = 0; i < a; i++)
	{
		cin >> b[i];
	}

	sort(b,b+a);

	for (i = 0; i < a-1; i++)
	{
		result[i] = b[i + 1] - b[i];
	}

	for (i = 0; i < a - 1; i++)
	{
		total += result[i];
	}

	cout << total;

	return 0;
}

Measured memory_bytes: 256
{-# LANGUAGE BangPatterns #-}
import           Control.Exception           (assert)
import           Control.Monad
import           Control.Monad.Primitive
import qualified Control.Monad.ST            as ST
import qualified Data.Array.IO               as IO
import qualified Data.Array.ST               as ST
import qualified Data.Array.Unboxed          as A
import           Data.Bits
import qualified Data.ByteString.Char8       as BS
import           Data.Char
import           Data.Foldable
import           Data.List
import qualified Data.Map.Strict             as Map
import           Data.Maybe
import qualified Data.Sequence               as Seq
import qualified Data.Set                    as Set
import qualified Data.Vector                 as VB
import qualified Data.Vector.Mutable         as VBM
import qualified Data.Vector.Unboxed         as V
import qualified Data.Vector.Unboxed.Mutable as VM
import           Debug.Trace

readInt = fst . fromJust . BS.readInt
readIntList = map readInt . BS.words
getInt = readInt <$> BS.getLine
getIntList = readIntList <$> BS.getLine
getIntVec n = V.unfoldrN n (BS.readInt . BS.dropWhile isSpace) <$> BS.getLine

readInteger = fst . fromJust . BS.readInteger
readIntegerList = map readInteger . BS.words
getInteger = readInteger <$> BS.getLine
getIntegerList = readIntegerList <$> BS.getLine

inf :: Int
inf = 10^18

main = do
  [n, d] <- getIntList
  xs <- replicateM n $ do
    [x, y] <- getIntList
    let x' = fromIntegral x :: Double
        y' = fromIntegral y :: Double
        dist = sqrt (x'*x' + y'*y')
        d' = fromIntegral d :: Double
    return $ if dist <= d' then (1::Int) else 0
  print $ sum xs


Measured memory_bytes: 67360
import java.util.*;
import java.io.PrintWriter;

public class Main{
	public static void main(String[] args){
		Scanner sc=new Scanner(System.in);
		int n=sc.nextInt();
		long ans=0;
		for(long i=1; i<=n; i++){
			ans+=i*((n/i)+1)*(n/i)/2;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 35808
def inpl(): return [int(i) for i in input().split()]
import sys
import numpy 
N = int(input())
A = numpy.asarray([inpl() for _ in range(N)])
ans = 0
for i in range(N):
    A[i][i] = 10**9+1
for i in range(N):
    for j in range(i):
        mindis = numpy.min([A[i] + A[j]])
        if mindis > A[i][j]:
            ans += A[i][j]
            continue
        if mindis < A[i][j]:
            print(-1)
            sys.exit()

print(ans)

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

int main(void){
   int N;
   cin>>N;
   vector<int> a(N);
   for(int i=0;i<N;i++){
      cin>>a[i];
   }
   sort(a.begin(),a.end());
   int number[100005]={0};
   for(int i=0;i<N;i++){
      number[a[i]]++;
   }
   int ans=0;
   for(int i=1;i<=100000;i++){
      ans=max(ans,number[i]+number[i-1]+number[i+1]);
   }
   cout<<ans<<endl;
   return 0;
}



Measured memory_bytes: 1024
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
#
# Created: Jul, 13, 2020 08:21:54 by Nobody
# $Author$
# $Date$
# $URL$
__giturl__ = "$URL$"


from sys import stdin
input = stdin.readline


def main():
  N = int(input())
  A = [int(input()) for _ in range(N)]

  B = sorted(A)
  max_ = B[-1]

  for x in A:
    if x == max_:
      print(B[-2])
    else:
      print(max_)


if(__name__ == '__main__'):
  main()


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

ll solve() {
    ll N, K;
    cin >> N >> K;
    ll ans = 0;
    while ( N > 0 ) {
        ans++;
        N /= K;
    }
    return ans;
}

int main() {
    auto ans = solve();
    cout << ans << "\n";
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
using namespace std;
#define rep(i,x) for(ll i = 0; i < (ll)(x); i++)
#define rrep(i,x) for(ll i = (ll)(x)-1;0 <= i; i--)
#define reps(i,x) for(ll i = 1; i < (ll)(x)+1; i++)
#define rreps(i,x) for(ll i = (ll)(x); 1 <= i; i--)
#define debug(x) cerr << #x << ": " << (x) << "\n";
#define all(x) (x).begin(), (x).end()
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> Pll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef vector<vector<vector<ll>>> vvvl;
const ll INF = numeric_limits<ll>::max()/4;
const int n_max = 1e5+10;

void print() {
    cout << endl;
}

template <class Head, class... Tail>
void print(Head&& head, Tail&&... tail) {
    cout << head;
    if (sizeof...(tail) != 0) cout << ' ';
    print(forward<Tail>(tail)...);
}

template <class T>
void print(vector<T> &vec) {
    for (auto& a : vec) {
        cout << a;
        if (&a != &vec.back()) cout << ' ';
    }
    cout << endl;
}

template <class T>
void print(vector<vector<T>> &df) {
    for (auto& vec : df) {
        print(vec);
    }
}

template<class T, class U>
void print(pair<T,U> &p){
    print(p.first, p.second);
}

int main(){
    ll n,q; cin >> n >> q;
    vector<ll> a(n);
    rep(i,n) cin >> a[i];
    vector<ll> x(q);
    rep(i,q) cin >> x[i];
    auto up = [&](ll x){
        ll ok = n, ng = -1;
        while(abs(ok - ng) > 1){
            ll m = (ok + ng) / 2;
            if(a[m] > x)ok = m;
            else ng = m;
        }
        return ok;
    };
    auto low = [&](ll x){
        ll ok = n, ng = -1;
        while(abs(ok - ng) > 1){
            ll m = (ok + ng) / 2;
            if(a[m] >= x)ok = m;
            else ng = m;
        }
        return ok;
    };
    vector<ll> odd(n+1, 0), even(n+1, 0), sum(n+1,0);
    rep(i,n){
        if(i & 1){
            odd[i+1] = odd[i] + a[i];
            even[i+1] = even[i];
        }
        else{
            odd[i+1] = odd[i];
            even[i+1] = even[i] + a[i];
        }
        sum[i+1] = sum[i] + a[i];
    }
    // print(sum);print(odd);print(even);

    rep(i,q){
        ll ok = 0, ng = 1e9 + 10;
        while(abs(ok - ng) > 1){
            ll med = (ok + ng) / 2;
            ll r = up(x[i] + med), l = low(x[i] - med);
            if(r - l <= n - r)ok = med;
            else ng = med;
        }
        ll r = up(x[i] + ok);
        // debug(x[i]);debug(ok);debug(r);
        ll ans = sum[n] - sum[r];
        if(n & 1){
            if(2 * r >= n)ans += even[2*r - n];
        }
        else{
            if(2 * r >= n)ans += odd[2*r-n];
        }
        cout << ans << "\n";
    }
}

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


int main() {
  int x, a, b;
  cin >> x >> a >> b;
  cout << (x-a) % b;
  return 0;
}



Measured memory_bytes: 3572
X = int( input().strip() ) ;

d = {} ;
for x in range ( 150 ) : 
	v1 = pow ( x, 5 ) ; 
	d[x] = v1 ; 
	d[-x] = -v1 ;
ans = None ;
for A in d :
	if not ans is None :
		break ;
	for B in d :
		if d[A] - d[B] == X : 
			ans = ( A, B, ) ; 
			break ;
if not ans is None :
	print ( "{0} {1}".format ( ans[0] , ans[1] ) );

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

int main() {
	int a, b, c, d, e, f; cin >> a >> b >> c >> d >> e >> f;
	cout << a + b + c + d - min(min(min(a, b), c), d) + max(e, f) << endl;
	return 0;
}

Measured memory_bytes: 1164