akhauriyash/Code-Regression huggingface dataset:
using System;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using Debug = System.Diagnostics.Debug;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        var a = NextLong;
        var b = NextLong;
        var c = NextLong;
        var d = NextLong;
        var cdiv = GetCount(a, b, c);
        var ddiv = GetCount(a, b, d);
        var bothdiv = GetCount(a, b, c * d);
        Console.WriteLine((b - a + 1) - GetCount(a, b, c) - GetCount(a, b, d) + GetCount(a, b, LCM(c, d)));
    }
    static long GetCount(long min, long max, long div) => (max / div) - ((min - 1) / div);


    static long LCM(long a, long b) => a / GCD(a, b) * b;
    static long GCD(long a, long b)
    {
        while (true)
        {
            if (b == 0) return a;
            a %= b;
            if (a == 0) return b;
            b %= a;
        }
    }

    static readonly TextReader In = Console.In;
    static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0;
            int next = In.Read();
            int rev = 1;
            while (45 > next || next > 57) next = In.Read();
            if (next == 45) { next = In.Read(); rev = -1; }
            while (48 <= next && next <= 57)
            {
                res = res * 10 + next - 48;
                next = In.Read();
            }
            return res * rev;
        }
    }
}



Measured memory_bytes: 13140
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
const ll INF = 1145141919;
const ll MOD = 1000000007;
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}

int main(){

    ll N;
    cin >> N;
    vector<P>v(N);
    rep(i, N){
        cin >> v[i].first;
        v[i].second = i;
    }    
    sort(v.begin(), v.end());
    rep(i, N){
        cout << v[i].second + 1;
        if(i + 1 == N)cout << endl;
        else cout << " ";
    }
    
    return 0;
}


Measured memory_bytes: 2432
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n; cin>>n;
  double a[n], ans = 0;
  for(int i = 0; i < n; i++) cin>>a[i], ans += pow(a[i], -1);
  cout<<pow(ans, -1)<<'\n';
  return 0;
}

Measured memory_bytes: 256
n,k=gets.chomp.split.map { |e| e.to_i }
pos=0.to_f
require'bigdecimal'
require'bigdecimal/util'
if n >= k
  (1..(k - 1)).each do |i|
    c=0
    until i >= k
      i *= 2
      c += 1
    end
    pos += 1r/n *  (1r/2 ** c)
  end
  pos += (n - k + 1) * 1r/n
else
  (1..n).each do |i|
    c=0
    until i >= k
      i *= 2
      c += 1
    end
    pos += 1r/n *  (1r/2 ** c)
  end
end


pos_f=pos.to_f
print pos_f


Measured memory_bytes: 1788
#include <cstdio>
#include <cstdlib>
#include <iostream>

struct Node {
  int val;
  Node *prev, *next;
};

void InitializeList(Node *&nil);
void InsertNode(Node *nil, int targetVal);
void DeleteNodeByKey(Node *nil, int targetVal);
struct Node *SearchFirstOccurrence(Node *nil, int targetVal);
void DeleteNode(Node *nil, Node *targetNode);
void DeleteFirstNode(Node *nil);
void DeleteLastNode(Node *nil);
void PrintValsInList(Node *nil);
void FreeListSpace(Node *nil);

int main() {
  int n, value;
  char cmd[30];
  Node *nil;

  nil = nullptr;

  InitializeList(nil);

  scanf("%d", &n);

  for (int i = 0; i < n; i++) {
    scanf("%s", cmd);
    if (cmd[0] == 'i') {
      if (scanf("%d", &value) != 1) {
        std::cerr << "ERROR! Expect a number following insert command.\n";
        exit(-1);
      }
      InsertNode(nil, value);
    } else if (cmd[0] == 'd') {
      if (cmd[6] == 'F') {
        DeleteFirstNode(nil);
      } else if (cmd[6] == 'L') {
        DeleteLastNode(nil);
      } else {
        if (scanf("%d", &value) != 1) {
          std::cerr << "ERROR! Expect a number following deletion command.\n";
          exit(-1);
        }
        DeleteNodeByKey(nil, value);
      }
    } else {
      std::cerr << "ERROR! Invalid command.\n";
      exit(-1);
    }
  }

  PrintValsInList(nil);
  FreeListSpace(nil);
  nil = nullptr;

  return 0;
}

void InitializeList(Node *&nil) {
  nil = (Node *)calloc(1, sizeof(Node));
  if (!nil) {
    std::cerr << "ERROR! Cannot allocate nil structure.\n";
    exit(-1);
  }

  nil->prev = nil;
  nil->next = nil;
}

void InsertNode(Node *nil, int targetVal) {
  Node *newNode;
  newNode = (Node *)calloc(1, sizeof(Node));
  if (!newNode) {
    std::cerr << "ERROR! Cannot allocate newNode structure.\n";
    exit(-1);
  }

  newNode->val = targetVal;
  newNode->next = nil->next;
  nil->next->prev = newNode;
  nil->next = newNode;
  newNode->prev = nil;
}

void DeleteNodeByKey(Node *nil, int targetVal) {
  DeleteNode(nil, SearchFirstOccurrence(nil, targetVal));
}

struct Node *SearchFirstOccurrence(Node *nil, int targetVal) {
  Node *crrNode;

  crrNode = nil->next;

  while (crrNode != nil && crrNode->val != targetVal) {
    crrNode = crrNode->next;
  }

  return crrNode;
}

void DeleteNode(Node *nil, Node *targetNode) {
  if (targetNode == nil) {
    return;
  }

  targetNode->prev->next = targetNode->next;
  targetNode->next->prev = targetNode->prev;
  free(targetNode);
}

void DeleteFirstNode(Node *nil) { DeleteNode(nil, nil->next); }

void DeleteLastNode(Node *nil) { DeleteNode(nil, nil->prev); }

void PrintValsInList(Node *nil) {
  Node *crrNode;

  crrNode = nil->next;

  while (crrNode != nil) {
    if (crrNode->prev != nil) {
      printf(" ");
    }
    printf("%d", crrNode->val);
    crrNode = crrNode->next;
  }
  printf("\n");
}

void FreeListSpace(Node *nil) {
  while (nil != nil->next) {
    DeleteFirstNode(nil);
  }

  nil->next = nil->prev = NULL;
  free(nil);
}


Measured memory_bytes: 34472
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>
#include <boost/multiprecision/cpp_int.hpp>

using std::string;
using std::vector;
using std::set;
using std::multiset;
using std::unordered_set;
using std::map;
using std::multimap;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

using boost::multiprecision::cpp_int;
using cpp_dec_float_1000 = boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000, boost::int128_type>>;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

constexpr char CRLF  = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;
constexpr int MOD = 1000'000'007;

template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }
template<class T> T modinv(T a, T m) { T b = m, u = 1, v = 0; while (b) { T t = a / b; a -= t * b; boost::swap(a, b); u -= t * v; boost::swap(u, v); } u %= m; if (u < 0) u += m; return u; }
template<class T> inline bool isSosuu(const T& n) { if (n == T(1)) { return false; } for (T i = 2; i*i <= n; ++i) { if (n % i == 0) { return false; } } return true; }
template<class T> vector<vector<T>> split (const vector<T>& S, T delim) { vector<vector<T>> ret{}; vector<T> buff{}; for (auto c : S) { if (c == delim) { if (!buff.empty()) ret.push_back(buff); buff.clear(); } else { buff.push_back(c); } } if (!buff.empty()) ret.push_back(buff); return ret; }
template<class T> inline void printYesNo(const T& t) { cout << (t ? "Yes" : "No") << CRLF; }
template<class T = int64_t> T modpow(T N, T P, T M) { T ret{1}; N %= M; while (P) { if (P & 0x01) { ret *= N; ret %= M; } P >>= 1; N *= N; N %= M; } return ret; }

/** code for assert debug begin */
int gErr = 0;
#define ASSERT(p) if(!(p)){ gErr = 1; }else{ ; }
/** code for assert debug end */

struct Tmp
{
public:
  int N;
  Tmp(int N)
  : N(N)
  {}
};

void solve(void)
{
  int A, B, C; cin >> A >> B >> C;
  auto ans = A+B == C || A == B+C || B == A+C;
  cout << (ans ? "Yes" : "No") << CRLF;
  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


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

#define max(a,b) ((a)>(b)?(a):(b))

int main(){
		int n,i,j,k,h;
		long xyz[100][3],ans[3],highest=0;
		scanf("%d",&n);
		for(i=0;i<n;i++){
				scanf("%ld%ld%ld",&xyz[i][0],&xyz[i][1],&xyz[i][2]);
				highest=max(highest,xyz[i][2]);
		}
		for(k=highest;;k++){
				for(i=0;i<=100;i++){
						for(j=0;j<=100;j++){
						int f=0;
								for(h=0;h<n;h++){
										if(xyz[h][2]!=max(k-abs(xyz[h][0]-i)-abs(xyz[h][1]-j),0)){
												f=1;
												break;
										}
								}
								if(f==0){
										printf("%ld %ld %ld\n",i,j,k);
										return 0;
								}
						}
				}
		}
		return 0;
}


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

int main() {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    long ab, bc,ac;
    ab = abs(b - a);
    bc = abs(c - b);
    ac = abs(c - a);

    if(ab <= d && bc <= d) {
        cout << "Yes";
    }
        else if (ac <= d) {
            cout << "Yes";
        }
        else {
            cout << "No";
        }
}

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

int main() {
    ll N, x; cin >> N >> x;
    vector<ll> a(N);
    for (int i = 0; i < N; ++i) cin >> a[i];
    ll ans = 0;
    for (int i = 0; i < N-1; ++i) {
        if (a[i] + a[i+1] <= x) continue;
        ans += a[i] + a[i+1] - x;
        a[i+1] = max(0LL, a[i+1] - (a[i] + a[i+1] - x));
        a[i] -= max(0LL, a[i] + a[i+1] - x);
    }
    cout << ans << endl;
    return 0;
}


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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

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

    int n, k;
    cin >> n >> k;

    vector< P > a(n);
    rep(i, n){
        cin >> a[i].first;
        a[i].second = i;
    }

    vector<int> ans;
    int last = -1;
    bool flag = true;
    while(flag){
        SORT_INV(a);
        rep(i, n){
            if(a[i].second == last){
                continue;
            }
            if(a[i].first == 0){
                flag = false;
                break;
            }
            ans.push_back(a[i].second);
            --a[i].first;
        }
        last = ans.back();
        if(flag){
            --k;
        }
        flag &= (k >= 0);
    }

    if(k >= 0){
        cout << -1 << endl;
    }else{
        cout << ans.size() << endl;
        rep(i, ans.size()){
            cout << ans[i] + 1;
            if(i < i_len - 1){
                cout << " ";
            }else{
                cout << endl;
            }
        }
    }

    return 0;
}

Measured memory_bytes: 256
#[allow(unused_macros)]
macro_rules! parse_line {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            iter.next().unwrap().parse::<$t>().unwrap()
        }
    );

    ( $( $t:ty), +) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let mut iter = line.split_whitespace();
            ( $(iter.next().unwrap().parse::<$t>().unwrap()),* )
        }
    );
}

#[allow(unused_macros)]
macro_rules! read_line {
    () => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            line.pop();
            line
        }
    )
}

#[allow(unused_macros)]
macro_rules! parse_vec {
    ( $t:ty ) => (
        {
            let mut line = String::new();
            ::std::io::stdin().read_line(&mut line).unwrap();
            let iter = line.split_whitespace();
            iter.map(|v| v.parse::<$t>().unwrap()).collect::<Vec<_>>()
        }
    )
}

fn solve(k: usize, mut abc: Vec<u64>) -> u64 {
    let n = abc.len();

    abc.sort();

    for _ in 0..k {
        abc[n-1] = abc[n-1]*2;
    }

    abc.iter().sum()
}

fn main() {
    let abc = parse_vec!(u64);
    let k = parse_line!(usize);

    println!("{}", solve(k , abc));
}

#[test]
fn solve_test() {
    assert_eq!(solve(2, vec![3,3,4]), 22);
}


Measured memory_bytes: 4352
using System;
using System.Linq;

class A
{
	static int[] Read() => Console.ReadLine().Split().Select(int.Parse).ToArray();
	static void Main()
	{
		var h = Read();
		var n = h[0];

		var uf = new UF(n);

		for (int i = 0; i < h[1]; i++)
		{
			var q = Read();
			if (q[0] == 0)
				uf.Unite(q[1], q[2]);
			else
				Console.WriteLine(uf.AreUnited(q[1], q[2]) ? 1 : 0);
		}
	}
}

class UF
{
	int[] p;
	public UF(int n) { p = Enumerable.Range(0, n).ToArray(); }

	public void Unite(int a, int b) { if (!AreUnited(a, b)) p[p[b]] = p[a]; }
	public bool AreUnited(int a, int b) => GetRoot(a) == GetRoot(b);
	public int GetRoot(int a) => p[a] == a ? a : p[a] = GetRoot(p[a]);
}


Measured memory_bytes: 42152
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 200001
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll A[MAX_N];
ll B[MAX_N];

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

    ll N;
    cin >> N;
    priority_queue<P, vector<P>, greater<P> > pq;
    
    ll total = 0;
    ll maxB = 0;
    for(ll i = 0; i < N; i++) {
      total += A[i];
      maxB = max(B[i], maxB);
      cin >> A[i] >> B[i];
      pq.push( P(B[i], A[i]) );
    }
	
  	if (total > maxB) {
      cout << "No" << endl;
      return 0;
    }

    ll now = 0;
    while (!pq.empty()) {
      P p = pq.top();
      pq.pop();
      ll deadline = p.first;
      ll required = p.second;
      if (deadline < now || deadline < now + required) {
	cout << "No" << endl;
	return 0;
      }
      now += required;
    }
    cout << "Yes" << endl;
    return 0;
}
    

Measured memory_bytes: 9208
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  string s;
  cin >> s;
  string add = "00000000";
  s = add + s;
  string v[] = {"eam", "mer", "ase", "ser"};
  string t[] = {"dream", "dreamer", "erase", "eraser"};
  while(1){
    string sb = s.substr(s.size()-3);
    int f = -1;
    rep(i, 4){
      if(sb == v[i]){
        int n;
        if(i % 2 == 0) n = 5;
        else if(i == 1) n = 7;
        else n = 6;
        string ts = s.substr(s.size() - n);
        if(ts != t[i]) continue;
        f = i;
      }
    }
    // cerr << sb << endl;
    if(f == -1){
      if(sb == "000"){
        cout << "YES" << endl;
      }else{
        cout << "NO" << endl;
      }
      return 0;
    }else{
      int n;
      if(f % 2 == 0) n = 5;
      else if(f == 1) n = 7;
      else n = 6;
      rep(i, n) s.pop_back();
    }
  }
  return 0;
}

Measured memory_bytes: 512
import java.util.Scanner;
public class Main
{
	public static void main(String[] args)
	{
		Scanner scan=new Scanner(System.in);
		int[] tops=new int[3];
		int height;
		for(int h=0;h<10;h++){
			height=scan.nextInt();
			for(int i=0;i<tops.length;i++){
				if(tops[i]<height){
					for(int j=tops.length-1;i<j;j--){
						tops[j]=tops[j-1];
					}
					tops[i]=height;
					break;
				}
			}
		}
		scan.close();
		for(int i=0;i<tops.length;i++){
			System.out.println(tops[i]);
		}
	}
}

Measured memory_bytes: 26100
#include <bits/stdc++.h>
#define int long long
using namespace std;
 
signed main() {
  int N;
  string S;
  cin >> N;
  cin >> S;
  
  //色ごとの数を数える
  int R = 0;
  int G = 0;
  int B = 0;
  for (int i = 0; i < N; i++){
    if (S.at(i) == 'R'){
      R++;
    }
    else if (S.at(i) == 'G'){
      G++;
    }
    else {
      B++;
    }
  }
  int count = R * G * B;//各色の数の積=三色になる(i,j,k)の数
  
  //三色になる(i-j,i,i+j)の数を引く
  for (int i = 1; i < N - 1; i++){
    for (int j = 1; j <= min(i, N - 1 - i) ; j++){
      if (S.at(i - j) != S.at(i) && S.at(i) != S.at(i + j) && S.at(i - j) != S.at(i + j)){
        count--;
      }
    }
  }
  
  cout << count << endl;
}

Measured memory_bytes: 3652
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll  a,b,c,d,e,n,k,maxi=0,f=0,mini=INF,sum=0,q;
	string str,g;
    cin>>n;
    rep(i,n+1) sum+=i;
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 3596
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream> 
#include<map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
using namespace std;
#define MAX_MOD 1000000007
#define REP(i,n) for(long long i = 0;i < n;++i)
#define LONG_INF 8000000000000000000
long long dp[200000] = {};
long long if_takeb[200000] = {};
long long waa[200000] = {};
int main(){
	long long n, a, b;
	cin >> n >> a >> b;
	if (a > b) {
		swap(a, b);
	}
	vector<long long> wow;
	REP(i, n) {
		long long c;
		cin >> c;
		wow.push_back(c);
	}
	wow.push_back(LONG_INF);
	int now = 0;
	for (int i = 1;i < n + 1;++i) {
		if (wow[i] - wow[i - 1] >= a) waa[i] = waa[i - 1] + 1;
		else waa[i] = waa[i - 1];
	}
	for (int i = 0;i < n;++i) {
		while (true) {
			if (wow[now] - wow[i] >= b) break;
			now++;
		}
		if_takeb[i] = now;
	}
	dp[0] = 1;
	for (int q = 2;q < if_takeb[0];++q) {
		if (wow[q] - wow[q - 1] < a) goto oh;
	}
	dp[if_takeb[0]-1] += 1;
	oh:;
	for (int i = 1;i < n;++i) {
		if (wow[i] - wow[i - 1] >= a) {
			dp[i] += dp[i - 1];
			dp[i] %= MAX_MOD;
		}
		if (waa[if_takeb[i] - 1] == waa[i + 1] + (if_takeb[i] - 2 - i) && wow[i + 1] - wow[i - 1] >= a) {
			dp[if_takeb[i] - 1] += dp[i - 1];
			dp[if_takeb[i] - 1] %= MAX_MOD;
		}
	}
	cout << dp[n-1] << endl;
	return 0;
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
#define ll long long
using namespace std;
int main()
{
    string n;
    cin>>n;
    ll cnt=0,other;
    for(int i=0;i<n.length();i++)
    {
        if(n[i]=='x')
            cnt++;
        else
            other++;
    }
    if(cnt<=7)
    cout<<"YES"<<endl;
    else
    cout<<"NO"<<endl;

    return 0;
}


Measured memory_bytes: 256
n, k = gets.to_s.split.map{|e|e.to_i}
a = [0] + gets.to_s.split.map{|e|e.to_i}
 
t = Array.new(n+1){ -1 } 
#used = Array.new(n+1){ false }
 
cur = 1
t[1] = i = 0
#used[1] = true
loop do
  
  cur = a[cur]
  i += 1
  if i == k
    puts cur
    exit
  end
  
  t[cur] >= 0 ? break : t[cur] = i
end

dist = t[cur]
# cycle = i - dist
idx = (k - dist) % (i - dist) + dist
puts t.index(idx)

Measured memory_bytes: 30428
x,y=map(int,input().split())
if x==1:
  if y==1:
    print(1000000)
  elif y==2:
    print(500000)
  elif y==3:
    print(400000)
  else:
    print(300000)
elif x==2:
  if y==1:
    print(500000)
  elif y==2:
    print(400000)
  elif y==3:
    print(300000)
  else:
    print(200000)
elif x==3:
  if y==1:
    print(400000)
  elif y==2:
    print(300000)
  elif y==3:
    print(200000)
  else:
    print(100000)
else:
  if y==1:
    print(300000)
  elif y==2:
    print(200000)
  elif y==3:
    print(100000)
  else:
    print(0)


Measured memory_bytes: 3064
INF = 10**9 + 1
def merge(A: list, left: int, mid: int, right: int) -> int:
  cnt = 0
  n1 = mid - left

  L = A[left:mid]
  L.append(INF)
  R = A[mid:right]
  R.append(INF)

  i_l, i_r = 0, 0
  for k in range(left, right):
    if L[i_l] <= R[i_r]:
      A[k] = L[i_l]
      i_l += 1
    else:
      A[k] = R[i_r]
      i_r += 1
      cnt += n1 - i_l
  return cnt

def merge_sort(A: list, left: int, right: int):
  if left + 1 >= right:
    return 0

  mid = (left + right) // 2
  v1 = merge_sort(A, left, mid)
  v2 = merge_sort(A, mid, right)
  v3 = merge(A, left, mid, right)

  return v1 + v2 + v3

n = int(input())
A = list(map(int, input().split()))
print(merge_sort(A, 0, n))



Measured memory_bytes: 27472
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<map>
#include<stack>
#include<queue>
#include<algorithm>
#include<set>
#include<vector>
#include<cmath>
#define lmid l,m,rt<<1
#define rmid m+1,r,rt<<1|1
#define LL long long
#define rl r-l+1
using namespace std;
using namespace std;
using ll = long long;
using P = pair<int, int>;
const ll INF = 999999999;
const ll atcoder = 1000000007;
const int dx[4] = { 1 , 0 , -1 ,0 };
const int dy[4] = { 0 , 1 , 0 , -1 };
int main() {
 
	int dist[210][210];
	int n, m, R,a;
	int r[10];
	int ans = INF;
	for (int i = 0; i < 210; i++) {
		for (int j = 0; j < 210; j++) {
			dist[i][j] = INF;
		}
	}
	cin >> n >> m >> R;
	for (int i = 0; i < R; i++)cin >> r[i];
	for (int i = 0; i < m; i++) {
		int a, b, c;
		cin >> a >> b >> c;
		dist[a][b] = c;
		dist[b][a] = c;
	}
	for (int k = 1; k <= n; k++) {
		for (int i = 1; i <= n; i++) {
			for(int j = 1; j <= n; j++){
				dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
			}
		}
	}
	sort(r, r + R);
	do {
		int s = 0;
		for (int i = 0; i < R - 1; i++) {
			s += dist[r[i]][r[i + 1]];
		}
		ans = min(s, ans);
	} while (next_permutation(r,r+R));
	cout << ans << endl;
	return 0;
}



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

int main() {
  long long A, B, C;
  cin >> A >> B >> C;

  long long ans = 0;
  if (A % 2 == 0 || B % 2 == 0 || C % 2 == 0) {
    ans = 0;
  } else {
    ans = min({A*B, B*C, C*A});
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.math.BigInteger;
import java.util.*;
import java.util.Map.Entry;

public class Main {

	public static void main(String[] args) {
		FastScanner fs = new FastScanner();
	   
	    	int n=fs.nextInt();
	        long d=fs.nextLong();
	        long a[][]=new long[n][2];
	        for(int i=0;i<n;i++) {
	        	a[i][0]=fs.nextLong();
	        	a[i][1]=fs.nextLong();
	        	
	        }
	        int count=0;
	        for(int i=0;i<n;i++) {
	        	long t1=a[i][0]*a[i][0];
	        	t1=t1<0?-t1:t1;
	        	long t2=a[i][1]*a[i][1];
	        	t2=t2<t2?-t2:t2;
	        	double temp=Math.sqrt(t1+t2);
	        	temp=Math.ceil(temp);
//	        	System.out.println(temp);
	        	if( temp-d<=0) {
	        		count++;
	        	}
	        }
	        System.out.println(count);
	    }
	
	
	static void sort(int[] a ) {
		ArrayList<Integer> l = new ArrayList<>();
		for(int i:a) l.add(i);
		Collections.sort(l);
		for(int i=0;i<l.size();i++) a[i]=l.get(i);
	}
	static class FastScanner {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer("");
		String next() {
			while(!st.hasMoreTokens())
				try {
					st = new StringTokenizer(br.readLine());
				}catch(IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a = new int[n];
			for(int i=0;i<n;i++)a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

}


Measured memory_bytes: 61944
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i <= n; i++)
#define FORR(i, m, n) for(int i = m; i >= n; i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define VSORTR(v) sort(v.rbegin(), v.rend());
#define ALL(v) (v).begin(),(v).end()
 
using ll = long long;
using vll = vector<ll>;
using vvll = vector<vector<ll>>;
using P = pair<ll, ll>;

template<typename T> using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
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 ll mod = 1e9 + 7;
const ll inf = 1e18;

int main(){
	cin.tie(0);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    ll a;
    REP(i, 5) {
        cin >> a;
        if (a == 0) {
            cout << i + 1 << endl;
            return 0;
        }
    }
    return 0;
}

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

using namespace std;

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

#define int long long
#define F first
#define S second
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()

void shift()
{
    cin.tie(0);
    cout.tie(0);
    ios_base::sync_with_stdio(0);
}
const int N = 2e5;


signed main()
{
    int a, b, c;
    cin >> a >> b >> c;
    c -= min(a - b, c);
    cout << c;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[100010];
int main(){
    int n, m;
    while(cin>>m>>n){
        ll ans=0, sm=0;
        for(int i=0; i<n; ++i){
            scanf("%d",a+i);
            sm+=a[i];
        }
        if(sm>m){
        	cout<<-1<<endl;
        }
        else{
        	cout<<m-sm<<endl;
        }
    }
  return 0;
}




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

int main(){
  int N;
  cin >> N;
  int64_t ans=1;
  int64_t o=1;
  for(int i=0;i<N;i++){
    int A;
    cin >> A;
    ans*=3;
    if(A%2==0){
      o*=2;
    }else{
      o*=1;
    }
  }
  ans-=o;
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3620
N = int(input())
A = list((int(x) for x in input().split()))
B = list((int(x) for x in input().split()))
C = list((int(x) for x in input().split()))
bonus = 0
for i in range(N-1):
  if A[i]+1 == A[i+1]:
    bonus += C[A[i]-1]
print(sum(B)+bonus)

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

ll gcd(ll a, ll b) {
  if (a < b) {swap(a, b);}
  if (b == 0) return a;
  return gcd(b, a % b);
}

int main() {
  ll A, B;
  cin >> A >> B;
  ll g = gcd(A, B);
  
  //異なる素因数の個数
  ll n = g;
  
  ll a = 2;
  ll num = 0;
  
  // sqrt(g)以下の素数の個数
  while (a*a<=g) {
    if (n % a == 0) {
      while (n % a == 0) {n /= a;}
      num++;
    } else {a++;}
  }
  // sqrt(g)より大きい素数を換算 if (n*n > g)という条件にするとオーバーフローでうまくいかない
  if (n != 1) {num++;}
  
  //1も換算
  cout << num+1<< endl;
}


Measured memory_bytes: 256
def solve(string):
    h, w, *s = string.split()
    h = int(h)
    w = int(w)
    for i in range(h):
        for j in range(w):
            if s[i][j] == ".":
                continue
            check = False
            if i > 0:
                check |= s[i][j] == s[i - 1][j]
            if i < h - 1:
                check |= s[i][j] == s[i + 1][j]
            if j > 0:
                check |= s[i][j] == s[i][j - 1]
            if j < w - 1:
                check |= s[i][j] == s[i][j + 1]
            if not check:
                return "No"
    return "Yes"


if __name__ == '__main__':
    n, m = map(int, input().split())
    print(solve('{} {}\n'.format(n, m) + '\n'.join([input() for _ in range(n)])))


Measured memory_bytes: 3064
from collections import Counter
N = int(input())
s = Counter([input() for k in range(N)])
M = int(input())
t = Counter([input() for k in range(M)])
ans = 0
for e in s:
    if e not in t:
        ans = max(ans,s[e])
    else:
        ans = max(ans,s[e]-t[e])
print(ans)


Measured memory_bytes: 38384
n = gets.to_i
a, b = n.times.map {gets.split.map(&:to_s)}.transpose

M = 10446527
H = []

def get_char(ch)
  if ch == 'A'
    return 1
  elsif ch == 'C'
    return 2
  elsif ch == 'G'
    return 3
  elsif ch == 'T'
    return 4
  end
  0
end

def get_key(s)
  sum = 0
  p = 1

  for i in 0...(s.size)
    sum += p * get_char(s[i])
    p *= 5
  end
  sum
end

def h(key, i)
  (h1(key) + i * h2(key)) % M
end

def h1(key)
  key % M
end

def h2(key)
  1 + (key % (M - 1))
end

def find(s)
  key = get_key(s)
  i = 0

  loop do
    h = h(key, i)
    if H[h] == s
      return true
    elsif H[h].nil?
      return false
    end
    i += 1
  end
end

def insert(s)
  key = get_key(s)
  i = 0

  loop do
    h = h(key, i)
    if H[h] == s
      return
    elsif H[h].nil?
      H[h] = s
      return
    end
    i += 1
  end
end

for i in 0...n
  if a[i][0] == 'i'
    insert(b[i])
  else
    if find(b[i])
      puts 'yes'
    else
      puts 'no'
    end
  end
end


Measured memory_bytes: 286548
#!python3

import sys
iim = lambda: map(int, sys.stdin.readline().rstrip().split())

def resolve():
    it = map(int, sys.stdin.read().split())
    X, N = next(it), next(it)

    if N == 0:
        print(X)
        return
    P = set(next(it) for i in range(N))

    if not X in P:
        print(X)
        return

    i = 1
    while True:
        ans = X - i
        if not ans in P:
            break
        ans = X + i
        if not ans in P:
            break
        i += 1

    print(ans)



if __name__ == "__main__":
    resolve()


Measured memory_bytes: 61836
#include <stdio.h>

int A[200000];

int main(void)
{
	int q, com, x, it = 0;
	scanf("%d", &q);
	while (q--) {
		scanf("%d", &com);
		if (com == 0) {
			scanf("%d", &x);
			A[it++] = x;
		}
		else if (com == 1) {
			scanf("%d", &x);
			printf("%d\n", A[x]);
		}
		else {
			--it;
		}
	}
	return 0;
}



Measured memory_bytes: 2512
import java.util.Scanner;

class Main{
	public static void main(String[] args){
		int i;
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int c = sc.nextInt();
		if(a > b){
			i = a;
			a = b;
			b = i;
		}
		if(b > c){
			i = b;
			b = c;
			c = i;
		} 
		if(a > b){
			i = a;
			a = b;
			b = i;
		}
		System.out.println(a + " " + b + " " + c);
	}
}

Measured memory_bytes: 17164
import java.util.Arrays;
import java.util.Scanner;

public class Main {

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

		int n = stdIn.nextInt();
		for(int i=0;i<n;i++){
			String a = stdIn.next();
			char[] b = new char[10];
			b=a.toCharArray();
			Arrays.sort(b);
			String c = String.valueOf(b);
			int min = Integer.parseInt(c);
			int max = 0;
			for(int j=0;j<8;j++){
				max*=10;
				max+=b[7-j]-'0';
			}
			System.out.println(max-min);
		}
	}
}

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

using namespace std;

int g[120000];
int i,k,n,s,t;

int main()
{
	scanf("%d",&n);
	for (i=1;i<=n;i++)
		scanf("%d",&g[i]);
	sort(g+1,g+n+1);
	if ((g[1]<0) && (g[n]>0))
	{
		for (i=1;i<=n;i++)
			s=s+abs(g[i]);
		printf("%d\n",s);
		t=g[1];
		for (k=1;(k<n) && (g[k]<0);k++);
		for (i=k;i<n;i++)
			printf("%d %d\n",t,g[i]),t=t-g[i];
		printf("%d %d\n",g[n],t),t=g[n]-t;
		for (i=2;i<k;i++)
			printf("%d %d\n",t,g[i]),t=t-g[i];
	}
	else
	if (g[n]<=0)
	{
		for (i=1;i<n;i++)
			s=s+abs(g[i]);
		s=s+g[n];
		printf("%d\n",s);
		t=g[n];
		for (i=1;i<n;i++)
			printf("%d %d\n",t,g[i]),t=t-g[i];
	}
	else
	{
		for (i=2;i<=n;i++)
			s=s+abs(g[i]);
		s=s-g[1];
		printf("%d\n",s);
		t=g[1];
		for (i=2;i<n;i++)
			printf("%d %d\n",t,g[i]),t=t-g[i];
		printf("%d %d\n",g[n],t),t=g[n]-t;
	}
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
int main(void)
{
    int n;
    cin >> n;
    int a[20];
    int x;
    int y;
    int ans=0;
    int bit=0;
    int nowtabel[20];
    for(int i=0;i<20;i++){
        nowtabel[i]=0;
    }
    int run[2];
    run[0]=0;//true
    run[1]=1;//1:regel
    int booltable[20][20];

    for(int i=0;i<20;i++){
        for(int j=0;j<20;j++){
            booltable[i][j]=-1;//unknow
        }
    }

    for(int i=0;i<n;i++){
        cin >>a[i];
        for(int j=0;j<a[i];j++){
            cin >> x >> y;
            booltable[i][x-1]=y;
        }
    }
    for(bit=1;bit<(1<<n);bit++){
        run[0]=0;
        run[1]=1;
        for(int i=0;i<n;i++){

            if(bit & (1<<i)){
                nowtabel[i]=1;
            }else{
                nowtabel[i]=0;
            }

        }

        for(int i=0;i<n;i++){
            if(nowtabel[i]==1){
                run[0]++;
                for(int j=0;j<n;j++){
                 
                    switch(booltable[i][j]){
                        case -1:
                            break;
                        case 1:
                                    //   cout<<booltable[i][j]<<"="<<nowtabel[j]<<" ";
                            if(nowtabel[j]==0){
                                run[1]=0;
                                
                            }
                                break;
                            
                        case 0:
                        
                              //             cout<<booltable[i][j]<<"="<<nowtabel[j]<<" ";
                            if(nowtabel[j]==1){
                                run[1]=0;
                            }    break;
                            
                    }

                }
            }
        }
        //cout<<bit << run[0]<<run[1]<<endl;
        if(run[1]==1){
            ans=max(run[0],ans);
        }

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

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

using M = map<ll, ll>;

ll INF = (1LL<<62)-1;

ll a, b, c, d;
M m;

ll f(ll n) {
  if(n < 0) {
    return INF;
  }
  if(n == 0) {
    return 0;
  }
  if(n == 1) {
    return d;
  }
  if(m[n]) {
    return m[n];
  }

  ll next_val = n * d > 0 ? n * d : INF;
  ll delta = 0;
  while(delta < 5) {
    if ((n + delta) % 2 == 0 && delta >= 1 && delta < 2) {
      ll k = (n+delta)/2;
      next_val = min(next_val, f(k) + delta*d+a);
    }
    if ((n - delta) % 2 == 0 && delta < 2) {
      ll k = (n-delta)/2;
      next_val = min(next_val, f(k) + delta*d+a);
    }
    if ((n + delta) % 3 == 0 && delta >= 1 && delta < 3) {
      ll k = (n+delta)/3;
      next_val = min(next_val, f(k) + delta*d+b);
    }
    if ((n - delta) % 3 == 0 && delta < 3) {
      ll k = (n-delta)/3;
      next_val = min(next_val, f(k) + delta*d+b);
    }
    if ((n + delta) % 5 == 0 && delta >= 1 && delta < 5) {
      ll k = (n+delta)/5;
      next_val = min(next_val, f(k) + delta*d+c);
    }
    if ((n - delta) % 5 == 0 && delta < 5) {
      ll k = (n-delta)/5;
      next_val = min(next_val, f(k) + delta*d+c);
    }
    delta++;
  }
  // printf("%lld, %lld\n", n, next_val);
  return m[n] = next_val;
}

struct Test {
  ll n;
  ll a;
  ll b;
  ll c;
  ll d;
  Test(ll n, ll a, ll b, ll c, ll d): n(n), a(a), b(b), c(c), d(d) {}
};

ll solve(Test t) {
  a = t.a;
  b = t.b;
  c = t.c;
  d = t.d;
  m.clear();
  return f(t.n);
}

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

  vector<Test> v;
  rep(i, t) {
    ll n, a, b, c, d;
    cin >> n >> a >> b >> c >> d;
    Test t(n, a, b, c, d);
    v.push_back(t);
  }
  for(auto t : v) {
    cout << solve(t) << endl;
  }
  return 0;
}

Measured memory_bytes: 4492
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+10;
int n,m,size[N];
bool is[N];
int main()
{
	scanf("%d%d",&n,&m);
	for (int i=1;i<=n;i++) size[i]=1;
	is[1]=1;
	for (int i=1;i<=m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		size[x]--;size[y]++;
		if (is[x]){
			if (size[x]==0) is[x]=0,is[y]=1;
				else is[y]=1;
		}
	}
	int ans=0;
	for (int i=1;i<=n;i++) ans+=is[i];
	printf("%d\n",ans);
	return 0;
}

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

#define lint long long
#define P pair<int, int>
#define LLP pair<long long, long long>
#define REP(i, x, n) for(int i = (x), i##_len = (int)(n) ; i < i##_len ; ++i)
#define rep(i, n) for(int i = 0, i##_len = (int)(n) ; i < i##_len ; ++i)
#define repr(i, n) for(int i = (int)(n) - 1 ; i >= 0 ; --i)
#define SORT(x) sort((x).begin(), (x).end())
#define SORT_INV(x) sort((x).rbegin(), (x).rend())

const int IINF = 1e9 + 100;
const long long LLINF = 2e18 + 129;
const long long MOD = 1e9 + 7;
const int dx4[] = {1, 0, -1, 0}, dy4[] = {0, 1, 0, -1};
const int dx8[] = {1, 1, 0, -1, -1, -1, 0, 1}, dy8[] = {0, -1, -1, -1, 0, 1, 1, 1};
const double EPS = 1e-8;

int w, h;
vector<string> p;
vector< vector<int> > v;

template<typename T>
bool chmax(T &a, T b){
    if(a < b){
        a = b;
        return true;
    }else{
        return false;
    }
}

template<typename T>
bool chmin(T &a, T b){
    if(a > b){
        a = b;
        return true;
    }else{
        return false;
    }
}

void init(void){
    p.clear();
    v.clear();

    p.resize(h);
    v.resize(h, vector<int>(w, -1));

    return;
}

void dfs(int y, int x, char c, int num){
    v[y][x] = num;
    rep(i, 4){
        int ny = y + dy4[i], nx = x + dx4[i];
        if(0 <= ny && ny < h && 0 <= nx && nx < w && v[ny][nx] == -1 && p[ny][nx] == c){
            dfs(ny, nx, c, num);
        }
    }
    return;
}

void build(void){
    int now = 0;
    rep(i, h){
        rep(j, w){
            if(p[i][j] != '.' && v[i][j] == -1){
                dfs(i, j, p[i][j], now);
                ++now;
            }
        }
    }

    return;
}

bool solve(int id, int &d, int &cnt){
    int nowd = 2, nowcnt = 4, xl = w + 1, xr = -1;
    set<int> st;
    rep(i, h){
        rep(j, w){
            if(v[i][j] == id){
                nowd += j;
                if(i + 1 < h && v[i + 1][j] >= 0 && v[i + 1][j] != id){
                    st.insert(v[i + 1][j]);
                }
                if(i == 0 || (i - 1 >= 0 && v[i - 1][j] >= 0 && v[i - 1][j] != id)){
                    chmin(xl, j);
                    chmax(xr, j + 1);
                }
            }
        }
    }

    bool res = true;
    for(auto x : st){
        res &= solve(x, nowd, nowcnt);
    }

    res &= xl * nowcnt < nowd && nowd < xr * nowcnt;

    d += nowd;
    cnt += nowcnt;

    return res;
}

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

    while(cin >> w >> h, w){
        init();

        repr(i, h){
            cin >> p[i];
        }

        build();

        string ans = "UNSTABLE";
        rep(j, w){
            int a = 0, b = 0;
            if(v[0][j] >= 0 && solve(v[0][j], a, b)){
                ans = "STABLE";
                break;
            }
        }

        cout << ans << endl;
    }

    return 0;
}


Measured memory_bytes: 3232
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main(){
    #ifndef ONLINE_JUDGE
        freopen("input.txt","r",stdin);
        freopen("output.txt","w",stdout);
    #endif
    char c;
    int ans=0;
    while(cin>>c) (c=='+')?++ans:--ans;
   	cout<<ans;
   return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define pb push_back
#define sc1(x) scanf("%lld",&x)
#define sc2(x,y) scanf("%lld%lld",&x,&y)
#define sc3(x,y,z) scanf("%lld%lld%lld",&x,&y,&z)
#define MX 100000
#define PI acos(-1)
using namespace std;

typedef long long int ll;

ll arr[100005][30];

map<string,ll>mp;

int main()
{
    ll n;
    sc1(n);
    for(ll i=1;i<=n;i++)
    {
        string str;
        cin>>str;
        sort(str.begin(),str.end());
        mp[str]++;
    }
    ll ans=0;
    auto it=mp.begin();
    while(it!=mp.end())
    {
        ll now=it->second;
        ans+=(now*(now-1))/2;
        it++;
    }
    cout<<ans<<endl;
    return 0;
}




Measured memory_bytes: 11136
IDENTIFICATION DIVISION.
       PROGRAM-ID. ATCODER.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01  indata PIC X(100).
       01  indata2 PIC X(100).
       01  a1 PIC 9(08).
       01  a2 PIC 9(08).
       01  r pic S9(08).
       01 disp pic Z(10)9.
       PROCEDURE DIVISION.
        ACCEPT indata.
        ACCEPT indata2.
        
        UNSTRING indata DELIMITED BY SPACE INTO a1.

         IF a1 >= 3200 THEN
           DISPLAY indata2
         ELSE
           DISPLAY "red"
         END-IF


       STOP RUN.


Measured memory_bytes: 384
#if 0

#endif

#include <bits/stdc++.h>
#define REP(i, n) for(int i=0;i<int(n);++i)
using namespace std;
template<class A>void p(A a){cout << (a) << endl;}
template<class A,class B>void p(A a,B b){cout << a << " "  ;p(b);}
template<class A,class B,class C>void p(A a,B b,C c){cout << a << " " ;p(b,c);}
template<class A,class B,class C,class D>void p(A a,B b,C c,D d){cout << a << " " ;p(b,c,d);}
typedef long long ll;
typedef pair<ll, ll> l_l;
typedef pair<int, int> i_i;
int INF=numeric_limits<int>::max();
// for copy
// for(int i=0;i<N;++i) {

double o_log(ll a, ll b) {
  return log2(b)/log2(a);
}

int main(void) {
  ll n,k;cin>>n>>k;
  int l = o_log(k,n);
  p(l+1);
  return 0;
}



Measured memory_bytes: 256
#  Copyright: this code was written at Dec 30th, 2019. for AtCoder, by Silviase
n, k = map(int, input().split())
r, s, p = map(int, input().split())  # r,s,p
t = input()
hand = [True for i in range(len(t))]  # 勝ったかどうか
result = 0
for i in range(0, k):
    for j in range(i, len(t), k):
        if j >= k and t[j] == t[j - k] and hand[j - k] is True:
            hand[j] = False
            continue
        if t[j] == "r":
            result += p
        elif t[j] == "s":
            result += r
        elif t[j] == "p":
            result += s
print(result)


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

int main() {
  
  int x, a, b;
  cin >> x >> a >> b ;
  
  if (abs(a-x) < abs(b-x)) {
    cout << "A" << endl;
  }
  else {
    cout << "B" << endl;
  }
  
return 0;
}

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

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

    vector<int> a(n), b(n);
    long suma = 0, sumb = 0;
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
        suma += a[i];
    }
    for (int i = 0; i < n; i++)
    {
        cin >> b[i];
        sumb += b[i];
    }

    if (suma > sumb)
    {
        cout << "No" << endl;
        return 0;
    }

    long opt = sumb - suma;
    long ans = 0;

    for (int i = 0; i < n; i++)
    {
        long diff = b[i] - a[i];
        if (diff > 0)
        {
            ans += (diff + 1) / 2;
        }
    }

    if (ans > opt)
    {
        cout << "No" << endl;
    }
    else
    {
        cout << "Yes" << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <iostream>
#include <set>
#include <algorithm>
#include <string>

using namespace std;

string boin = "aiueo";

int main(void){
	while(1){
		int n; cin >> n;
		if(!n) break;
		int maxlen = 0;
		set<string> codes;
		for(int i=0; i<n; i++){
			string str; cin >> str;
			string code;
			code += str[0];
			for(int j=0; j<str.length()-1; j++){
				for(int k=0; k<5; k++){
					if(str[j] == boin[k]){
						code += str[j+1];
						break;
					}
				}
			}
			codes.insert(code);
			maxlen = max(maxlen, (int)code.length());
		}

		if(codes.size() != n){
			cout << -1 << endl;
			continue;
		}

		for(int k=1; k<maxlen+1; k++){
			set<string> sub_codes;
			for(auto code: codes){
				string sub_code = code.substr(0, k);
				sub_codes.insert(sub_code);
			}
			if(sub_codes.size() == n){
				cout << k << endl;
				break;
			}
		}
	}//endwhile
}


Measured memory_bytes: 3192
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
int main(void){
    int n,ans = 0;
    cin >> n;
    vector<int> x(2*n);
    for(int i = 0;i < 2*n;i++) cin >> x[i];
    sort(x.begin(),x.end());
    for(int i = 0;i < 2*n;i+=2){
        ans += x[i];
    }
    cout << ans << endl;
    return 0;
}


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

int main(){
  int i=0;
  string a,b;
  cin>>a>>b;
  if(a.length()>b.length()){
    cout<<"GREATER"<<endl;
    return 0;
  }
  if(a.length()<b.length()){
    cout<<"LESS"<<endl;
    return 0;
  }
  if(a==b){
    cout<<"EQUAL"<<endl;
    return 0;
  }
  while(a[i]==b[i]) i++;
  if(a[i]>b[i]) cout<<"GREATER"<<endl;
  else cout<<"LESS"<<endl;
}

Measured memory_bytes: 256
import sys
sys.setrecursionlimit(1000000000)
import math
from fractions import gcd
def lcm(a, b): return a * b // gcd(a, b)
from itertools import count, permutations
from functools import lru_cache
from collections import deque, defaultdict
from pprint import pprint
ii = lambda: int(input())
mis = lambda: map(int, input().split())
lmis = lambda: list(mis())
INF = float('inf')
N1097 = 10**9 + 7

def meg(f, ok, ng):
    while abs(ok-ng)>1:
        mid = (ok+ng)//2
        if f(mid):
            ok=mid
        else:
            ng=mid
    return ok

def get_inv(n, modp):
    return pow(n, modp-2, modp)

def factorials_list(n, modp):    # 10**6
    fs = [1]
    for i in range(1, n+1):
        fs.append(fs[-1] * i % modp)
    return fs

def invs_list(n, fs, modp):     # 10**6
    invs = [get_inv(fs[-1], modp)]
    for i in range(n, 1-1, -1):
        invs.append(invs[-1] * i % modp)
    invs.reverse()
    return invs

def comb(n, k, modp):
    vn = vk = vn_k = 1
    for i in range(1, n+1):
        vn = vn * i % modp
        if i == k:
            vk = vn
        if i == n-k:
            vn_k = vn
    return vn * get_inv(vk, modp) * get_inv(vn_k, modp) % modp

def comb_from_list(n, k, modp, fs, invs):   
    return fs[n] * invs[n-k] * invs[k] % modp

#

def main():
    N=ii()
    A=lmis()
    print('APPROVED' if all(a%3==0 or a%5==0 for a in A if a%2==0) else 'DENIED')

main()







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

int Mod;
int mpow(int a, int b) {
  int res = 1;
  do {
    if(b & 1) res = 1LL * res * a % Mod;
    a = 1LL * a * a % Mod;
  } while(b >>= 1);
  return res;
}

int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  string s;
  cin >> n >> Mod >> s;
  if(Mod == 2 || Mod == 5) {
    long long ans = 0;
    for(int i = 0; i < n; ++i) {
      if((s[i] - '0') % Mod == 0) {
        ans += i + 1;
      }
    }
    cout << ans << '\n';
    return 0;
  }
  vector<int> cnt(Mod);
  int pref = 0;
  for(int i = 0, p = 1; i < n; ++i, p = 10LL * p % Mod) {
    pref = 10LL * pref % Mod + (s[i] - '0');
    if(pref >= Mod) pref -= Mod;
    cnt[1LL * pref * mpow(p, Mod - 2) % Mod] += 1;
  }
  long long ans = 0;
  for(int i = 0; i < Mod; ++i) {
    ans += 1LL * cnt[i] * (cnt[i] - 1) / 2;
    if(i == 0) ans += cnt[i];
  }
  cout << ans << '\n';
}


Measured memory_bytes: 720