akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<vector>
#include<math.h>
#include<string.h>
using namespace std;
#define MAX 200010
#define MOD 998244353
#define NIN -100000000
#define EPS 0.0000000001
int main()
{
    int n,i;
    scanf("%d",&n);
    int A[n+1];
    for(i=0; i<=n; i++)
    {
        scanf("%d",&A[i]);
    }
    int M=1;
    long long int m,ans=0,current=0,leaves=0;
    for(i=n;i>=0;i--)
    {
        current=current+A[i];
        leaves=leaves+A[i];
        if(i<=60)
        {
            m=1;
            m=m<<i;
            if(m<current)
            {
                printf("-1");
                return 0;
            }
        }
        current=(current/2+current%2);
    }
    m=1;
    for(i=0;i<=n;i++)
    {
        current=leaves;
        if(m<leaves)
        {
            current=min(current,m);
            m=(m-A[i]);
            m=m<<1;
        }
        //printf("current=%lld\n",current);
        ans=ans+current;
        leaves=leaves-A[i];
    }
    printf("%lld",ans);
    return 0;
}


Measured memory_bytes: 4192
import java.util.*;

public class Main {

    public static final void main(String args[]) throws Exception {
        new Main().solve();
    }

    void solve() {
        try (Scanner in = new Scanner(System.in)) {
            long x = in.nextLong();
            long y = in.nextLong();
            if (x < y) {
                long t = x;
                x = y;
                y = t;
            }
            System.out.println(x > y + 1 ? "Alice" : "Brown");
        }
    }

    boolean dfs(long i, long j) {
        if (i < 2 && j < 2) return false;
        boolean win = false;
        for (long k = 1; k * 2 <= i; ++k) {
            win |= dfs_opp(i - k * 2, j + k);
        }
        for (long k = 1; k * 2 <= j; ++k) {
            win |= dfs_opp(i + k, j - k * 2);
        }
        return win;
    }

    boolean dfs_opp(long i, long j) {
        if (i < 2 && j < 2) return true;
        boolean win = true;
        for (long k = 1; k * 2 <= i; ++k) {
            win &= dfs(i - k * 2, j + k);
        }
        for (long k = 1; k * 2 <= j; ++k) {
            win &= dfs(i + k, j - k * 2);
        }
        return win;
    }

    void tr(Object... o) {
        System.err.println(Arrays.deepToString(o));
    }
}

Measured memory_bytes: 23124
class Node:
    def __init__(self, key):
        self.key = key
        self.parent = None
        self.left = None
        self.right = None
        
    def insert(self, z):
        if z.key < self.key:
            if self.left:
                self.left.insert(z)
            else:
                self.left = z
                z.parent = self
        else:
            if self.right:
                self.right.insert(z)
            else:
                self.right = z
                z.parent = self

    def preo(self):
        tmp = ""
        tmp += " " + str(self.key)
        if self.left:
            tmp += self.left.preo()
        if self.right:
            tmp += self.right.preo()
        return tmp
    
    def ino(self):
        tmp = ""
        if self.left:
            tmp += self.left.ino()
        tmp += " " + str(self.key)
        if self.right:
            tmp += self.right.ino()
        return tmp
    
    
m = int(input())
T = {}
for i in range(m):
    com = input().split()
    if com[0] == "insert":
        node = Node(int(com[1]))
        if len(T)==0:
            T[node.key] = node
            T["root"] = node
        else:
            T["root"].insert(node)
    else:
        print(T["root"].ino())
        print(T["root"].preo())


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

int main() {
  ll N, A, B, C, D;
  cin >> N >> A >> B >> C >> D;

  ll x = B - A;
  N -= 1;

  for(ll i = 0; i <= N; i++) {
    if(i * C - (N - i) * D <= x && x <= i * D - (N - i) * C) {
      cout << "YES" << endl;
      return 0;
    }
  }

  cout << "NO" << endl;
  return 0;
}



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

#define fastio() ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
long long n,m,c;

void _case()
{
    cin>>n>>m>>c;
    long long a[n][m],b[m],ans=0,x;
    for(int i=0;i<m;i++) cin>>b[i];
    for(int i=0;i<n;i++){
        for(int j=0;j<m;j++) cin>>a[i][j];
    }
    for(int i=0;i<n;i++){
        x=0;
        for(int j=0;j<m;j++) x+=(a[i][j]*b[j]);
        if(x+c>0) ans++;
    }
    cout<<ans<<'\n';
}

main()
{
    fastio();
    _case();

}




Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <queue>
#include <iomanip>

#define REP(i, a, b) for (int i = int(a); i < int(b); i++)
#define dump(val) cerr << __LINE__ << ":\t" << #val << " = " << (val) << endl

using namespace std;

typedef long long int lli;

template<typename T>
vector<T> make_v(size_t a, T b) {
    return vector<T>(a, b);
}

template<typename... Ts>
auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v(ts...))>(a, make_v(ts...));
}

struct Edge {
    int to, mxspeed, cost;
    Edge(int t, int m, int c)
        : to(t), mxspeed(m), cost(c) {}
    Edge() {}
};

struct Data {
    int to, spd, lst;
    double cost;
    Data(int t, int s, int lt, double c) {
        to = t;
        spd = s;
        lst = lt;
        cost = c;
    }
    Data() {}
    bool operator<(const Data &d1) const {
        return cost > d1.cost;
    }
};

int main() {
    int n, m;
    while (cin >> n >> m, n + m) {
        vector<vector<Edge>> G(n);
        int s, g;
        cin >> s >> g;
        s--;
        g--;
        REP(i, 0, m) {
            int x, y, d, c;
            cin >> x >> y >> d >> c;
            x--;
            y--;
            G[x].push_back(Edge(y, c, d));
            G[y].push_back(Edge(x, c, d));
        }
        priority_queue<Data, vector<Data>> pq;
        const double inf = 1e+15;
        auto Cost = make_v(n, n, 35, inf);
        auto used = make_v(n, n, 35, false);
        //vector<vector<double>> Cost(n, vector<double>(35, inf));
        pq.emplace(s, 0, s, 0.0);
        double ans = inf;
        while (pq.size()) {
            auto d = pq.top();
            pq.pop();
            if (used[d.to][d.lst][d.spd]) continue;
            used[d.to][d.lst][d.spd] = true;
            if (d.to == g && d.spd == 1) {
                ans = min(ans, d.cost);
            }
            for (auto &e : G[d.to]) {
                if (e.to == d.lst) continue;
                REP(i, -1, 2) {
                    int ns = d.spd + i;
                    if (ns <= 0 || ns > e.mxspeed) continue;
                    double nc = d.cost + static_cast<double>(e.cost) / ns;
                    if (Cost[e.to][d.to][ns] > nc) {
                        Cost[e.to][d.to][ns] = nc;
                        pq.emplace(e.to, ns, d.to, nc);
                    }
                }
            }
        }
        if (ans <= inf / 2) {
            cout << fixed << setprecision(10) << ans << endl;
        } else {
            cout << "unreachable" << endl;
        }
    }
    return 0;
}



Measured memory_bytes: 4080
using System;

namespace atcoder_BegginerContest89_C
{
    class Program
    {
        static void Main(string[] args)
        {
            var n = long.Parse(Console.ReadLine());
            var s = new string[n];
            long mCnt = 0;
            long aCnt = 0;
            long rCnt = 0;
            long cCnt = 0;
            long hCnt = 0;
            long sum = 0;

            for (int i = 0; i < n; i++)
            {
                s[i] = Console.ReadLine();
                if (s[i][0] == 'M') mCnt++;
                else if (s[i][0] == 'A') aCnt++;
                else if (s[i][0] == 'R') rCnt++;
                else if (s[i][0] == 'C') cCnt++;
                else if (s[i][0] == 'H') hCnt++;
            }

            sum += mCnt * aCnt * rCnt;
            sum += mCnt * aCnt * cCnt;
            sum += mCnt * aCnt * hCnt;
            sum += mCnt * rCnt * cCnt;
            sum += mCnt * rCnt * hCnt;
            sum += mCnt * cCnt * hCnt;

            sum += aCnt * rCnt * cCnt;
            sum += aCnt * rCnt * hCnt;
            sum += aCnt * cCnt * hCnt;
            sum += rCnt * cCnt * hCnt;

            Console.WriteLine(sum);
        }
    }
}


Measured memory_bytes: 15712
public class Main{
  public void run(java.io.InputStream in, java.io.PrintStream out){
    java.util.Scanner sc = new java.util.Scanner(in);
    int[] a, b, c;
    int i, x, sum, f, d;

    a = new int[4]; b = new int[4]; c = new int[4];
    c[0] = 10; c[1] = 50; c[2] = 100; c[3] = 500;
    f = 0;
    for(;;){
      x = sc.nextInt(); if(x == 0)break;
      sum = -x;
      if(f++ > 0)out.println();
      for(i = 0;i < 4;i++){
        a[i] = sc.nextInt(); b[i] = 0; sum += a[i] * c[i];
      }
      for(i = 4;i-- > 0;){
        d = sum / c[i];
        b[i] += d;
        sum -= d * c[i];
      }

      for(i = 0;i < 4;i++)if(a[i] - b[i] > 0)
        out.println(c[i] + " " + (a[i] - b[i]));
    }

    sc.close();
  }
  public static void main(String[] args){
    (new Main()).run(System.in, System.out);
  }
}

Measured memory_bytes: 44404
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define F first
#define S second
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;}
#define OUT(x) cout << x << endl
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dbx[8][3] = {{0,0,0},{1,1,1},{2,2,2},{0,1,2},{0,1,2},{0,1,2},{0,1,2},{2,1,0}};
ll dby[8][3] = {{0,1,2},{0,1,2},{0,1,2},{0,0,0},{1,1,1},{2,2,2},{0,1,2},{0,1,2}};

int main() {
  vvll A(3,vll(3));
  REP(i,3){
    REP(j,3){
      cin >> A.at(i).at(j);
    }
  }
  IN(ll,N);
  AIN(ll,B,N);
  REP(i,N){
    REP(j,3){
      REP(k,3){
        if(B.at(i) == A.at(j).at(k)){
          A.at(j).at(k) = INF;
        }
      }
    }
  }
  bool ans = false;
  REP(i,8){
    bool isbingo = true;
    REP(j,3){
      if(A.at(dbx[i][j]).at(dby[i][j]) != INF)
         isbingo = false;
    }
    if(isbingo)
      ans = true;
  }
  BOUT(ans);
}

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

// ABCテンプレート

#define rep(i,n) for (int i = 0; i<(n); i++)
#define in(n) cin >> (n)
#define out(ans) cout << (ans) << endl;
#define keta(n) cout << fixed << setprecision((n));
using ll = int64_t;
using v = vector<int>;


int main() {
  int N, dasu=1000;
  cin >> N;

  while(dasu<N) {
    dasu += 1000;
  }
  cout << dasu-N << endl;

}

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

using namespace std;

#define INF 1000007
#define MOD 998244353
#define int long long int
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define rep(i, n) FOR(i, 0, n)
int gcd(int a, int b)
{
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) { return a / gcd(a, b) * b; }
int mpow(int N, int P, int M) //繰り返し自乗法
{
    if (P == 0)
        return 1;
    if (P % 2 == 0)
    {
        int t = mpow(N, P / 2, M);
        return t * t % M;
    }
    return N * mpow(N, P - 1, M) % M;
}
signed main()
{
    int r;
    cin >> r;
    cout << r * r << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<numeric>
#include<algorithm>
#include<tuple>

using namespace std;

int solve(int n, vector<int>& vec, vector<vector<pair<int,int> > >& xyss){
    int ret;
    if(n>0){
        int a,b;
        vec[n-1] = 0;
        a = solve(n-1, vec, xyss);
        vec[n-1] = 1;
        b = solve(n-1, vec, xyss);
        return max(a,b);
    }else{
        for(auto i=0; i<vec.size(); ++i)
        {
            if(vec[i]==0) continue;
            for(auto xy : xyss[i])
            {
                if(vec[xy.first] != xy.second) return 0;
            }
        }
        return accumulate(vec.begin(), vec.end(), 0);
    }
    return 0;
}

int main(){
    int n;
    cin >> n;
    vector<vector<pair<int,int> > > xyss;
    for(auto i=0; i<n; ++i){
        int a;
        cin >> a;
        vector<pair<int,int> > xys;
        for (auto j=0; j<a; ++j){
            int x,y;
            cin >> x >> y;
            xys.push_back(make_pair(x-1,y));
        }
        xyss.push_back(xys);
    }
    vector<int> vec(n,0);
    int ret = solve(n,vec,xyss);
    cout << ret << endl;
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#define N 100
#define APEX 0
#define MID 1
#define BOTTOM 2

int n, M[N][N];
int color[N], d[N], f[N], tt;
void dfs_search(int m){
  int l;
  color[m]=MID;
  d[m]=++tt;
  for(l=0;l<n;l++){
    if(M[m][l]==0)continue;
    if(color[l]==APEX){
      dfs_search(l);
    }
  }
  color[m]=BOTTOM;
  f[m]=++tt;
}

void dfs(){
  int m;
  for(m=0;m<n;m++){
    color[m]=APEX;
    tt=0;
  }
  for(m=0;m<n;m++){
    if(color[m]==APEX) dfs_search(m);
  }
  for(m=0;m<n;m++){
    printf("%d %d %d\n", m+1, d[m], f[m]);
  }
}

int main(){
  int m, l, o, i, j;
  scanf("%d", &n);
  for(i=0;i<n;i++){
    for(j=0;j<n;j++){
      M[i][j]=0;
    }
  }
  for(i=0;i<n;i++){
    scanf("%d %d", &m, &o);
    m--;
    for(j=0;j<o;j++){
      scanf("%d", &l);
      l--;
      M[m][l]=1;
    }
  }
  dfs();
  return 0;
}


Measured memory_bytes: 2036
#include <bits/stdc++.h>
#define REP(i, n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i, a, b) for(ll i = (a); i < (ll)b; i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define INF (1ll << 60)
#define sz(x) int(x.size())
using namespace std;
typedef long long ll;
using vl = vector<ll>;
using vvl = vector<vl>;
typedef double db;
typedef string str;
typedef pair<ll, ll> p;
constexpr int MOD = 1000000007;
using ll = long long;
template <class T> inline bool chmin(T &a, T b) {
    if(a > b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> inline bool chmax(T &a, T b) {
    if(a < b) {
        a = b;
        return true;
    }
    return false;
}

void print(const std::vector<int> &v) {
    std::for_each(v.begin(), v.end(), [](int x) { std::cout << x << " "; });
    std::cout << std::endl;
}

// https://kira000.hatenadiary.jp/entry/2019/02/23/053917
// https://atcoder.jp/contests/jsc2019-qual/tasks/jsc2019_qual_b
//数列(an)について、i<jかつai>ajとなる組(i,j)の個数

struct fenwick_tree {
    typedef int T;
    T n;
    // size n の tree を作成する際の
    // n の値は数列の最大値より大きなものを設定する必要がある
    vector<T> bit;
    // x&-x
    // xの最も下の立っているビット
    // 各要素の初期値は 0
    fenwick_tree(T num) : bit(num + 1, 0) { n = num; }

    // a_i += w
    void add(T i, T w) {
        for(T x = i; x <= n; x += x & -x) {
            bit[x] += w;
        }
    }
    // [1, i] の和を計算.
    T sum(T i) {
        T ret = 0;
        for(T x = i; x > 0; x -= x & -x) {
            ret += bit[x];
        }
        return ret;
    }
    // [left+1, right] の和を計算.
    T sum(T left, T right) { return sum(right) - sum(left); }
};
ll modpow(ll a, ll p) {
    if(p == 0)
        return 1;
    if(p % 2 == 0) {
        ll halfp = p / 2;
        ll half = modpow(a, halfp);
        return half * half % MOD;
    } else {
        return a * modpow(a, p - 1) % MOD;
    }
}

ll calcComb(ll a, ll b) {
    if(b < 0) {
        return 0;
    }
    if(a < 0) {
        return 0;
    }
    if(a < b) {
        return 0;
    }
    if(b > a - b) {
        return calcComb(a, a - b);
    }
    ll ansMul = 1;
    ll ansDiv = 1;
    REP(i, b) {
        ansMul *= (a - i);
        ansDiv *= (i + 1);
        ansMul %= MOD;
        ansDiv %= MOD;
    }
    ll ans = ansMul * modpow(ansDiv, MOD - 2);
    ans %= MOD;
    return ans;
}

int main() {
    ll N, K;
    cin >> N >> K;
    vector<ll> A(N);
    REP(i, N) { cin >> A[i]; }
    // https://qiita.com/wisteria0410ss/items/296e0daa9e967ca71ed6
    //転倒数
    fenwick_tree f_tree(2010);
    // fenwick tree の i 番目の値が x であるとき, 値が i である要素が x
    // 個あるものとみなす
    ll ans = 0;
    for(int j = 0; j < N; j++) {
        ans += j - f_tree.sum(A[j]);
        ans %= MOD;
        f_tree.add(A[j], 1);
    }
    ll cnt = 0;
    REP(i, N) {
        REP(j, N) {
            if(i == j) {
                continue;
            }
            if(A[i] != A[j]) {
                cnt++;
            }
        }
    }
    ll res = (ans * K) % MOD;
    // cout << ans << endl;
    // cout << cnt << endl;
    res += (cnt / 2 * calcComb(K, 2)) % MOD;
    res %= MOD;
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 256
# 入力
S = gets.chomp

# bit全探索を行う
(1 << 3).times do |i|
  # 使った演算子を覚えておく配列
  op = []
  # S[0]は最初の文字なので絶対に加算
  res = S[0].to_i
  3.times do |j|
    if i[j] == 1
      # i[j]が1のときresにS[j+1]をたす
      res = res + S[j+1].to_i
      op.push('+')
    else
      # i[j]が1のときresからS[j+1]をひく
      res = res - S[j+1].to_i
      op.push('-')
    end
  end
  # resが7かどうかチェック
  if res == 7
    puts "#{S[0]}#{op[0]}#{S[1]}#{op[1]}#{S[2]}#{op[2]}#{S[3]}=7"
    exit
  end
end

Measured memory_bytes: 1788
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<iostream>
#include<map>
#include<numeric>
#include<queue>
#include<set>
#include<sstream>
#include<vector>
using namespace std;
using uint = unsigned int;
using ll = long long;
const int M = 1e9 + 7;
const ll MLL = 1e18L + 9;
#pragma unused(M)
#pragma unused(MLL)
#ifdef LOCAL
#include"rprint.hpp"
#else
template <class... T> void printl(T&&...){ }
template <class... T> void printc(T&&...){ }
template <class... T> void prints(T&&...){ }
template <class... T> void printd(T&&...){ }
#endif

int edges[8][8];
int count(int visited, int cur, int n){
    if(visited == (1 << n) - 1){ return 1; }
    int ret = 0;
    for(int i=0;i<n;i++){
        if(edges[cur][i] && i != cur && !(visited & (1 << i))){
            ret += count(visited | (1 << i), i, n);
        }
    }
    return ret;
}
int main(){
    int n, m;
    cin >> n >> m;
    for(int i=0;i<m;i++){
        int a, b;
        cin >> a >> b;
        a--; b--;
        edges[a][b] = edges[b][a] = 1;
    }
    cout << count(1, 0, n) << '\n';
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
  char name[100];
  int t;
}P;

P Q[LEN+1];
int head, tail, n;

void enqueue(P x){
  Q[tail] = x;
  tail=(tail+1)%LEN;
}

P dequeue(){
  P x=Q[head];
  head=(head+1)%LEN;
  return x;
}
int min(int a, int b){
  return  a< b? a:b;
}

int main(){
  int elaps = 0, c;
  int i, q;
  P u;
  scanf("%d %d", &n, &q);

  for ( i = 1; i <= n; i++){
    scanf("%s", Q[i].name);
    scanf("%d", &Q[i].t);
  }
  head=1;
  tail=n+1;
  while(head!=tail){
    u=dequeue();
    c=min(q,u.t);
    u.t-=c;
    elaps+=c;
    if(u.t>0)enqueue(u);
    else{
	printf("%s %d\n",u.name,elaps);
      }
  }

  return 0;
}



Measured memory_bytes: 11872
#include<bits/stdc++.h>
using namespace std;
#define ld long double
int main()
{
	ios::sync_with_stdio(0);cin.tie(0);
	ld a,b,c;
	cin>>a>>b>>c;
	if(a+b+2*sqrtl(a*b)<c)cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 256
import std.stdio;

void main() {
	
	for (;;) {
		int m, f, r;
		"%d %d %d\n".readf(&m, &f, &r);
		if (m == -1 && f == -1 && r == -1) break;
		
		string g = "";
		int s = m + f;
		if (m == -1 || f == -1) g = "F";
		else if (s >= 80) g = "A";
		else if (65 <= s && s < 80) g = "B";
		else if (50 <= s && s < 65) g = "C";
		else if (30 <= s && s < 65) g = r >= 50 ? "C" : "D";
		else g = "F";
		g.writeln;
	}
}

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

N = INT()
s = [INT() for _ in range(N)]
s.sort()

ans = sum(s)

if ans%10 == 0:
	for x in s:
		if x%10 != 0:
			ans -=x
			break
	else:
		ans = 0

print(ans)

Measured memory_bytes: 13680
import sys
input = sys.stdin.readline


def main():
    N = int(input())
    P = list(map(int, input().split()))

    cnt = 1
    min_num = P[0]
    for p in P:
        if p < min_num:
            min_num = p
            cnt += 1

    print(cnt)


if __name__ == "__main__":
    main()


Measured memory_bytes: 24436
import sys

readline = sys.stdin.readline
MOD = 10 ** 9 + 7
INF = float('INF')
sys.setrecursionlimit(10 ** 5)


def main():
    x = list(map(int, readline().split()))
    K = int(readline())
    x.sort(reverse=True)

    ans = x[0] * 2 ** K + x[1] + x[2]
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 61792
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<algorithm>
#include<bitset>
#include<vector>
#include<deque>
#include<queue>
#include<map>
#include<set>
#include<stack>
#include<cmath>
#include<iomanip>
#include <functional>
using namespace std;
typedef long long ll;
const int mod = 1000000007;
const int INF = 1 << 28;
const double EPS = 1e-10;
//cout << fixed << std::setprecision(9)
//memset(a, 0, sizeof(a));
//--------------------------


int main()
{
	vector<int> a;
	a.resize(3);

	cin >> a[0] >> a[1] >> a[2];

	sort(a.begin(), a.end());
	
	if (a[0] == 5 && a[1] == 5 && a[2] == 7) {
		cout << "YES" << endl;
	}
	else {
		cout << "NO" << endl;
	}

	return 0;
}








Measured memory_bytes: 256
// AtCoder165 C

#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <math.h>
#include <assert.h>
#include <string.h>
#include <memory.h>
#include <malloc.h>
#include <stdlib.h>

// qsortで用いる比較用関数．*a<*bならaが先になる．
int compare(const void* a, const void* b) {
    return *(int*)a - *(int*)b;
}

int main() {
    int i,j;
    int n;
    int bingo[3][3];
    int b,k;
    int isBingo = 0;// false

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

    scanf("%d", &n);
    for(i=0;i<n;i++){
        scanf("%d", &b);
        for(j=0;j<3;j++){
            for(k=0;k<3;k++){
                if(bingo[j][k] == b) bingo[j][k] = 0;
            }
        }
    }

    for(i=0;i<3;i++){
        if(bingo[i][0]+bingo[i][1]+bingo[i][2]==0) isBingo = 1;
    }

    for(i=0;i<3;i++){
        if(bingo[0][i]+bingo[1][i]+bingo[2][i]==0) isBingo = 1;
    }
    if(bingo[0][0] + bingo[1][1] + bingo[2][2] == 0)isBingo = 1;
    if(bingo[0][2] + bingo[1][1] + bingo[2][0] == 0)isBingo = 1;
    
    if(isBingo){
        printf("Yes");
    }else{
        printf("No");
    }
    return 0;
}

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

#define DUMP(x) cerr << #x << "=" << x << endl
#define DUMP2(x, y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<")"<< endl
#define BINARY(x) static_cast<bitset<16> >(x)

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

#define in_range(x, y, w, h) (0<=(int)(x) && (int)(x)<(int)(w) && 0<=(int)(y) && (int)(y)<(int)(h))
#define ALL(a) (a).begin(),(a).end()

typedef long long ll;
const int INF = 1e9;
typedef pair<int, int> PII;
int dx[4]={0, -1, 1, 0}, dy[4]={-1, 0, 0, 1};

int d[110][110];
int w[110][110];

int main()
{
    ios::sync_with_stdio(false);

    int N, M;
    cin >> N >> M;

    rep(i, N) rep(j, N) d[i][j] = (i == j ? 0 : INF);
    rep(i, M) {
        int U, V, C;
        cin >> U >> V >> C;
        U--, V--;
        d[U][V] = d[V][U] = C;
        w[U][V] = w[V][U] = C;
    }

    rep(k, N) rep(i, N) rep(j, N) d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

    int ans = 0;
    rep(i, N) REP(j, i+1, N) {
        if (d[i][j] != INF && d[i][j] < w[i][j]) {
            ans++;
        }
    }
    cout << ans << endl;
}



Measured memory_bytes: 512
#include <iostream>

using namespace std;

int main()
{
    double w;
    string c[] = {"heavy", "light heavy", "middle",
                "light middle", "welter", "light welter",
                "light", "feather", "bantam",
                "fly", "light fly"};

    while (cin >> w) {
        if (w > 91.0) 
            cout << c[0];
        else if (w > 81.0)
            cout << c[1];
        else if (w > 75.0)
            cout << c[2];
        else if (w > 69.0)
            cout << c[3];
        else if (w > 64.0)
            cout << c[4];
        else if (w > 60.0)
            cout << c[5];
        else if (w > 57.0)
            cout << c[6];
        else if (w > 54.0)
            cout << c[7];
        else if (w > 51.0)
            cout << c[8];
        else if (w > 48.0)
            cout << c[9];
        else
            cout << c[10];

        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 1232
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
//#define num 1000000007
#define pi acos(-1.0)
//cout << fixed << setprecision (20);   小数点以下2０桁まで
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'0'+=16;        で大文字に
//'大文字'+=32;    で小文字に
//s[i]-'0'でchar文字→int数に;
//string s = to_string(int数);
//int n = stoi(string文字列)
//実行時間制約2秒では２×10^8回くらいまで計算できる



int main() {
  int w,h,n;
  cin >> w>>h>>n;

  int hi=1;
  int m=w;
  int s=1;
  int u=h;
  
  rep(i,n){
  int x,y,a;
  cin >> x >> y >> a;
    if(a==1) hi=max(hi,x+1);
    if(a==2) m=min(m,x);
    if(a==3) s=max(s,y+1);
    if(a==4) u=min(u,y);
  }
  
  cout << max(m-hi+1,0)*max(u-s+1,0) <<endl;
  
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<string>
#include<vector>
#include<list>
#include<set>
#include<map>
#include<queue>
#include<stack>
#include<cctype>
#include<climits>
#include<bitset>
#define ld long double
#define ll long long int
#define ull unsigned long long int
#define rep(i,n) for(i=0;i<n;i++)
#define fin(ans) cout<<(ans)<<endl
#define INF INT_MAX
#define vi vector<int>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pair<int,int> >
#define vvi vector<vector<int> >
#define vvc vector<vector<char> >
#define vvs vector<vector<string> >
#define P 1000000007
#define STI(s) atoi(s.c_str())//string to int
using namespace std;
template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
const long long LLINF=1LL<<60;
//set<int>::iterator it;
//|\_
//g++ -std=c++1z temp.cpp
//./a.out


int main(void){ios::sync_with_stdio(false);cin.tie(0);
//////////////////////////////////////////////////////
    int i,n;
    cin>>n;
    vector<int> v(n),w(n);
    rep(i,n){
        cin>>v[i];
        w[i]=v[i];
    }
    int cen=n/2;
    sort(w.begin(),w.end());
    map<int,int> m;
    rep(i,n){
        if(w[i]<w[cen]||w[i]>w[cen]){
            // cout<<w[i]<<endl;
            m[w[i]]=w[cen];
        }
        if(w[i]>=w[cen]&&w[i-1]<w[cen]){
            cen--;
            // cout<<w[i]<<endl;
            m[w[i]]=w[cen];
        }
    }
    rep(i,n)cout<<m[v[i]]<<endl;
//////////////////////////////////////////////////////
return 0;}





Measured memory_bytes: 13568
#include<bits/stdc++.h>
using namespace std;
void solve3()
{
    puts("aa.");
    puts("..b");
    puts("..b");
}
string mp[10][10];
void init()
{
    mp[4][0] = "aabc";
    mp[4][1] = "ddbc";
    mp[4][2] = "efgg";
    mp[4][3] = "efhh";
    mp[5][0] = "aabbc";
    mp[5][1] = "dee.c";
    mp[5][2] = "d.ffd";
    mp[5][3] = "eg..d";
    mp[5][4] = "eg.cc";
    mp[6][0] = "aab.cc";
    mp[6][1] = "ccbdd.";
    mp[6][2] = "d.aa.b";
    mp[6][3] = "d.c..b";
    mp[6][4] = ".ac..d";
    mp[6][5] = ".a.eed";
    mp[7][0] = "aab.c..";
    mp[7][1] = "..bdc..";
    mp[7][2] = "ee.d.ff";
    mp[7][3] = "c.bb..a";
    mp[7][4] = "c...eea";
    mp[7][5] = ".bcc..d";
    mp[7][6] = ".b..aad";
}
string ans[1001];
void fillit(int x, int m)
{
    for (int i = x, cnt = 0; cnt < m; i++, cnt++)
    {
        for (int j = 0; j < m; j++) ans[i][x + j] = mp[m][cnt][j];
    }
}
int main()
{
    init();
    int n; scanf("%d", &n);
    if (n == 2) puts("-1");
    else if (n == 3) solve3();
    else 
    {
        for (int i = 0; i < n; i++)
        {
            ans[i].resize(n); 
            fill(ans[i].begin(), ans[i].end(), '.');
        }
        int a = n / 4, b = n % 4;
        a--; b += 4;
        int now = 0;
        fillit(now, b); now += b;
        while (a--) fillit(now, 4), now += 4;
        for (int i = 0; i < n; i++) cout << ans[i] << '\n';
    }
    return 0;
}

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

int main() {
    string s;
    cin >> s;

    cout << s;
    if (s[s.length() - 1] == 's')
        cout << "es" << endl;
    else
        cout << "s" << endl;
    return 0;
}


Measured memory_bytes: 3624
#define _CRT_SECURE_NO_WARNINGS
// #define _USE_MATH_DEFINES
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <cstdlib>
#include <functional>
#include <locale>
#include <cctype>
#include <sstream>
#include <iomanip>    // 10????????? cout << setprecision(10) << double;
#include <queue>
using namespace std;

typedef long long LL;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef map<int, int> MAPII;
typedef multimap<int, char, greater<int> > MuMAPIC;
typedef vector<pair<int, int> > VPII;
typedef multimap<int, string, greater<int> > MuMIS;
typedef pair<int, int> P;
typedef pair<int, pair<P, P> > PP;

#define MP make_pair
#define FAST_IO  cin.tie(0); ios::sync_with_stdio(false);
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
//for gcc (???test)
// #define FOREACH_IT(it,c) for(typeof(c)::iterator it=(c).begin(); it!=(c).end(); ++it)
//for Visual Studio
#define foreach_it(type,it,c) for(type::iterator it=c.begin(),c_end=c.end();it!=c_end;++it)
// for Debug.
#define DUMP_VVI(b) FOR(i,0,b.size()){FOR(j,0,b[i].size())printf("%d ",b[i][j]);puts("");}
#define D_OUT(str,value) if(dbgF){cout<<str<<" : "<<value<<endl;}
// ??\??????push_back(d)???array[d]???????????????1??????§?????????
// int INPUT_INT() {int d;cin>>d;return d;}
template<class T>T IN() { T d; cin >> d; return d; }
// ??????§????¢??´????°???Greatest Common Divisor???
LL gcd(LL a, LL b) { return (b > 0) ? gcd(b, a%b) : a; }
// ?????°?????¢??????°???Least Common Multiple???
LL lcm(LL a, LL b) { return a / gcd(a, b) * b; }
// Y???´???????????????´?????????
bool uruu(LL Y) { return (((Y % 4 == 0 && Y % 100 != 0) || Y % 400 == 0) ? true : false); }

// vector???¨???
// vec[i][j]?????????????\????????\?????????¨??????vec???????????????????????????????????????.

#define INF 1000000

// ------------------- include, typedef, define END. -------------------

int main() {

	int month = 0, day = 0;
	int daySum = 0;	// 1???1??\???????????\??°
	int month_days[12] = { 31,29,31,30,31,30,31,31,30,31,30,31 };
	string youbi[7] = { "Thursday","Friday","Saturday","Sunday","Monday","Tuesday","Wednesday" };
	while (cin >> month >> day, month|| day) {
		FOR(i, 0, month-1) {
			daySum += month_days[i];
		}
		daySum += (day - 1);

		cout << youbi[daySum%7] <<endl;
		daySum = 0;
	}

	return 0;
}

Measured memory_bytes: 1196
a,b=input().split()
a=int(a)
b=int(b)
e=a
d=b
c=1
if a>b:
  for i in range(1,e):
    if a%(e-i)==0 and b%(e-i)==0:
      a=a/(e-i)
      b=b/(e-i)
      c=c*(e-i)
  print(int(a*b*c))
if a<b:
  for i in range(1,d):
    if a%(d-i)==0 and b%(d-i)==0:
      a=a/(d-i)
      b=b/(d-i)
      c=c*(d-i)
  print(int(a*b*c))

Measured memory_bytes: 9156
n,m=map(int,input().split())
a=list(map(int,input().split()))
a.sort()
if n==1:
    print(a[0]*2)
    exit()
from bisect import bisect_left,bisect_right
#幸福度がx以上がm以上か？
def f(x):
    global n,a
    ret=0
    for i in range(n):
        ret+=(n-bisect_left(a,x-a[i]))
    return ret
#端がやはりコーナーケース(ここまじでバグらせんな)
l,r=-1,10**6
while l+1<r:
    k=l+(r-l)//2
    if f(k)>=m:
        l=k
    else:
        r=k
co,ans=0,0
for i in range(n):
    co+=(n-bisect_right(a,l-a[i]))
    ans+=(n-bisect_right(a,l-a[i]))*a[i]
print(2*ans+(m-co)*l)

Measured memory_bytes: 84980
#include <string>
#include <bits/stdc++.h>
#include <stdio.h>
#include<math.h>
#include <ctype.h>
using namespace std;

int main() {
  int n,m;
  cin >> n >> m;
  vector<int> vec(m);
  for(int i=0;i<m;i++){
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  vector<int> t(m-1);
  for(int i=0;i<m-1;i++){
    t.at(i)=vec.at(i+1)-vec.at(i);
  }
  sort(t.begin(),t.end());
  int sum=0;
  
  
  for(int i=0;i<m-n;i++){
    sum=sum+t.at(i);
  }
  cout << sum << endl;
}
 

Measured memory_bytes: 1024
import java.io.PrintStream;
import java.util.Scanner;

class Main {

    public static void main(String[] args) {
        doit(args, new Scanner(System.in), System.out);
    }

    static void doit(String[] args, Scanner scanner, PrintStream out) {
        while (scanner.hasNext()) {
            int n = scanner.nextInt();
            int limit = (int) Math.sqrt(n);
            boolean[] composites = new boolean[n + 1];
            composites[0] = composites[1] = true;
            int target = 2;
            while (true) {
                for (int i = target * 2; i <= n; i += target) {
                    composites[i] = true;
                }
                boolean found = false;
                for (int i = target + 1; i <= limit; i++) {
                    if (!composites[i]) {
                        target = i;
                        found = true;
                        break;
                    }
                }
                if (!found) {
                    break;
                }
            }
            int count = 0;
            for (int i = 2; i <= n; i++) {
                if (!composites[i]) {
                    count++;
                }
            }
            out.println(count);
        }
    } 
}

Measured memory_bytes: 16000
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
int n,m,ans,C[4010][4010],sum[4010][4010],sum2[4010][4010];
int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<=n+m;++i)
		for(int j=*C[i]=1;j<=i;j++)
			C[i][j]=(C[i-1][j]+C[i-1][j-1])%mod;
	for(int i=0;i<=n+m;++i)
		for(int j=*sum[i]=1;j<=n+m;++j)		
			sum[i][j]=(C[i][j]+sum[i][j-1])%mod;
	for(int i=0;i<=n+m;++i)
		for(int j=0;j<=n+m;++j)
			sum2[i][j]=((j?sum2[i][j-1]:0)+sum[i][j])%mod;
	for(int t=0;t<=n;++t)
		for(int s=0;s<t;++s)
			ans=(ans+1ll*C[m-1][t-s]*sum2[t-s-1][s])%mod;
	printf("%d",(ans+n+1)%mod);
}

Measured memory_bytes: 188672
#include <stdio.h>

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

  double x;
  char u[3];

  double money = 0.0;
  for(int i = 0;i < N;i++){
    scanf("%lf%s",&x,u);
    if(u[0] == 'J')
      money += x;
    else
      money += x*380000;
  }

  printf("%lf\n",money);

  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<iostream>
#include<math.h>
#include<cstring>
#include<algorithm> 
using namespace std;

int main()
{
	int n,m;
	cin>>n>>m;
	int a;
	for(int i=1;i<=m;i++)
	{
		cin>>a;
		n-=a;
	}
	if(n<0)
		cout<<"-1";
	else
		cout<<n;
}
 

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

using namespace std;
typedef long long ll;
const int N = 2e5 + 5;

int n;

int NumOfDigit(int n){
    if(n==0)return 0;
    return NumOfDigit(n/10)+1;
}

int main() {
    scanf("%d",&n);
    int d = NumOfDigit(n);
    int ans = 0;
    int cnt = pow(10,d-1);
    if(d%2)ans=n-cnt+1;
    while(cnt){
        if(NumOfDigit(cnt)%2==0)
            ans+=cnt-cnt/10;
        cnt/=10;
    }
    printf("%d",ans);
    return 0;
} 

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

int main() {
    int n; cin >> n;
    string x; cin >> x;

    constexpr int kMod = 998244353;
    int cnt = 0;
    vector<int> dp(n + 1), gd(n + 1);
    vector<vector<int>> dv(n + 1);
    for (int i = 1; i <= n; ++i) {
        for (int j = i; j <= n; j += i) dv[j].push_back(i);
    }
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0 && n % i != 0 && (n + n) % i == 0) {
            for (int d : dv[i]) gd[d] = true;
        }
    }

    for (int i = 0; i < n; ++i) {
        int nxt = 0;
        if (x[i] == '1') nxt = (cnt * 2 + 1) % kMod;
        else nxt = cnt * 2 % kMod;
        if ((i + 1) * 2 <= n) {
            dp[(i + 1) * 2] = nxt;
            if (gd[(i + 1) * 2]) {
                string t = "";
                for (int j = 0; j <= i; ++j) t += x[j];
                for (int j = 0; j <= i; ++j) t += (x[j] ^ '0' ^ '1');
                string r = "";
                for (int j = 0; j < n; ++j) r += t[j % t.size()];
                if (r <= x) dp[(i + 1) * 2]++;
            }
        }
        cnt = nxt;
    }
    for (int i = 1; i <= n; ++i) {
        for (int d : dv[i]) if (i > d && (i / d) % 2 == 1) (dp[i] += kMod - dp[d]) %= kMod;
    }
    int ans = 0;
    for (int i = 0; i < n; ++i) ans = (ans * 2 + (x[i] - '0')) % kMod;
    ans = 1LL * (ans + 1) * (n + n) % kMod;
    for (int i = 1; i <= n; ++i) {
        if (i % 2 == 0 && n % i != 0 && (n + n) % i == 0) {
            ans += kMod - 1LL * dp[i] * (n + n) % kMod;
            if (ans >= kMod) ans -= kMod;
            ans += 1LL * dp[i] * i % kMod;
            if (ans >= kMod) ans -= kMod;
        }
    }
    printf("%d\n", ans);
}


Measured memory_bytes: 24964
#include "bits/stdc++.h"
using namespace std;
typedef long long int ll;
#define m 1000000007
#define MAXN 1000001
#define satya ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define cil(a,b) (((a-1)/b)+1)
//#define init int t;cin>>t;while(t--)
#define in(a) ll a;scanf("%lld",&a)
#define ine(a,b) ll a,b;scanf("%lld lld",&a,&b)



ll spf[MAXN]; 

void sieve1() 
{ 
	spf[1] = 1; 
	for (int i=2; i<MAXN; i++) 

		spf[i] = i; 

	for (int i=4; i<MAXN; i+=2) 
		spf[i] = 2; 

	for (int i=3; i*i<MAXN; i++) 
	{ 
		if (spf[i] == i) 
		{ 
			for (int j=i*i; j<MAXN; j+=i) 

				if (spf[j]==j) 
					spf[j] = i; 
		} 
	} 
} 

ll  getFactorization(int x) 
{ 
	vector<int> ret; 
	long long int p=0;
	while (x != 1) 
	{ 
		ret.push_back(spf[x]); 
		x = x / spf[x]; 
	} 
	sort(ret.begin(),ret.end());
	for(int i=0;i<ret.size()-1;i++) 
	{
	    if(ret[i]!=ret[i+1])
	    p=p+ret[i];
	}
	p=p+ret[ret.size()-1];
	return p;
} 

ll d[1000055],u=0;
void Sieve(int n) 
{ 
	bool prime[n+1]; 
//	ll u=0;
	memset(prime, true, sizeof(prime)); 

	for (int p=2; p*p<=n; p++) 
	{ 
		if (prime[p] == true) 
		{ 
			for (int i=p*2; i<=n; i += p) 
				prime[i] = false; 
		} 
	} 

	for (int p=2; p<=n; p++) 
	if (prime[p]) 
	{
	    d[u]=p;
	    u++;
	}
} 

ll minverse(ll x,ll n,ll M)
{
    if(n==0)
        return 1;
    else if(n%2 == 0)        //n is even
        return minverse((x*x)%M,n/2,M);
    else                             //n is odd
        return (x*minverse((x*x)%M,(n-1)/2,M))%M;

}
ll prime(ll n){
    ll i;
    if(n==1||n==0)
    return 0;
    for(i=2;i<sqrt(n);i++)
    {
        if(n%i==0)
        return 0;
    }
    return 1;
}
int main() {
       satya;
     //sieve1(); 
     //Sieve(100);
    	   string s;
    	   cin>>s;
    	   string p,y;
    	   p+=s[0];
    	   ll p1=1;
    	   for(int i=1;i<s.size();i++)
    	   {
    	       y+=s[i];
    	       if(y!=p)
    	       {
    	           p1++;
    	           p="";
    	           p+=y;
    	           y="";
    	           
    	       }
    	   }
      cout<<p1<<endl;
    return 0;
}

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

struct dice{
    int s[6];
    int *stb[6];
};

int main(void){
    dice d1;
    string str;
    int *tmp;

    for(int i = 0; i < 6; i++){
        cin >> d1.s[i];
        d1.stb[i] = &d1.s[i];
    }
    cin >> str;

    for(int i = 0; str[i] != '\0'; i++){
        switch (str[i])
        {
        case 'E':
            tmp = d1.stb[0];
            d1.stb[0] = d1.stb[3];
            d1.stb[3] = d1.stb[5];
            d1.stb[5] = d1.stb[2];
            d1.stb[2] = tmp;
            break;

        case 'N':
            tmp = d1.stb[0];
            d1.stb[0] = d1.stb[1];
            d1.stb[1] = d1.stb[5];
            d1.stb[5] = d1.stb[4];
            d1.stb[4] = tmp;
            break;
        
        case 'W':
            tmp = d1.stb[0];
            d1.stb[0] = d1.stb[2];
            d1.stb[2] = d1.stb[5];
            d1.stb[5] = d1.stb[3];
            d1.stb[3] = tmp;
            break;

        case 'S':
            tmp = d1.stb[0];
            d1.stb[0] = d1.stb[4];
            d1.stb[4] = d1.stb[5];
            d1.stb[5] = d1.stb[1];
            d1.stb[1] = tmp;
            break;

        default:
            break;
        }
    }
    cout << *d1.stb[0] << endl;
}


Measured memory_bytes: 3172
#include <bits/stdc++.h>
using namespace std;
#define PI 3.141592653589793
#define MOD 1000000007
#define rep(i, n) for (ll i = 0; i < n; i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef long double ld;


int main(){
    ll X;
    cin >> X;
    rep(i,X + 1){
        ll sum = (i + 1) * i / 2;
        if(sum >= X){
            cout << i << endl;
            return 0;
        }
    }

}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}
//INSERT ABOVE HERE

int solve(){
  int N;
  cin>>N;
  if(N == 0) return 0;

  map<int, int> room;
  map<int, int> cnt;

  for(int i=0;i<N;i++){
    _int month, day, hour, minute;
    char ch;
    _int id;
    scanf("%d/%d %d:%d %c %d", &month, &day, &hour, &minute, &ch, &id);
    minute = hour * 60 + minute;
    if(ch == 'I') assert(room.count(id) == 0), room[id] = minute;
    if(ch == 'O'){
      assert(room.count(id) != 0);
      if(id == 0){
        for(auto &p:room){
          int t = room[id];
          int id2, t2; tie(id2, t2) = p;
          cnt[id2] += minute - max(t, t2);
        }
      }
      if(id != 0){
        if(room.count(0)) cnt[id] += minute - max(room[id], room[0]);
      }
      room.erase(id);
    }
  }

  int ans = 0;
  for(auto p:cnt) if(p.first != 0 )Max(ans, p.second);
  cout<<ans<<endl;
  return 1;
}

signed main(){
  //srand((unsigned)time(NULL));
  //cin.tie(0);
  //ios_base::sync_with_stdio(0);
  //cout << fixed << setprecision(12);

  while(solve());

  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <vector>
#include <map>
using namespace std;

int main()
{
    int n;
    cin >> n;
    map<int, int> m;
    vector<int> v(n);
    for(int i = 0; i < n; ++i)
    {
        int t;
        cin >> t;
        m[t] += 1;
        v[i] = t;
    }

    long long int totalAns = 0;
    for(pair<int,int> p : m)
    {
        long long int t = p.second;
        totalAns += (t * (t-1) / 2);
    }

    for(int i : v)
    {
        int t = m[i];
        long long int num1 = (t * (t-1) / 2);
        int t2 = t-1;
        long long int num2 = (t2 * (t2-1) / 2);
        
        cout << totalAns - (num1 -num2) << endl;
    }
}

Measured memory_bytes: 8320
#!/usr/bin/env python
# -*- coding: utf-8 -*-
# べき乗は、a ** n or pow(a, n)
X = int(input())
# X = a**5 - b**5 
#   = (a-b)(a**4 + a**3 * b + a**2 * b**2 + a * b**3 + b**4)
# よって、X は　a-b　の倍数 X%(a-b) = 0

# a**5  = b**5 + X
#   a   = ( b**5 + X )**(1/5)
# X< 10**9 を満たす a,bの最大値は、120 , 119
flag = False
for ai in range(-119,120):
    for bi in range(-120,119):
        if ai - bi != 0 and X > (ai - bi):
            if X % (ai - bi) == 0:
                if ai**5 - bi**5 ==X:
                    print(int(ai),int(bi))
                    flag = True
                    break
        else:
            if ai**5 - bi**5 ==X:
                print(int(ai),int(bi))
                flag = True
                break
    if flag:
        break

Measured memory_bytes: 9204
#include <iostream>
using namespace std;
#define int long long int

signed main() {
    string s;
    cin>>s;
    
    int count = 0;
    
    for(char ch : s)
    if(ch=='R')
    count++;
    
    if(count==3)
    cout<<3<<"\n";
    else if(count==1)
    cout<<1<<"\n";
    else if(count==2)
    {
        if(s[0]==s[1] || s[1]==s[2])
        cout<<2<<"\n";
        else
        cout<<1<<"\n";
    }
    else
    cout<<0<<"\n";
    
	return 0;
}

Measured memory_bytes: 3564
#include <algorithm>
#include <cfloat>
#include <climits>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <functional>
#include <iostream>
#include <map>
#include <memory>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <utility>
#include <vector>

using namespace std;

typedef long long ll;

#define sz size()
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define all(c) (c).begin(), (c).end()
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define per(i,a,b) for(ll i=b-1LL;i>=(a);--i)
#define clr(a, b) memset((a), (b) ,sizeof(a))
#define ctos(c) string(1,c)
#define print(x) cout<<#x<<" = "<<x<<endl;

#define MOD 1000000007



int main(){
	ll n,k;
	cin>>n>>k;
	ll n1 = n/2+n%2;
	if(n1>=k){
		cout << "YES" << endl;
	}
	else{
		cout << "NO" << endl;
	}
 	return 0;
}

Measured memory_bytes: 256