akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#ifdef DEBUG
    #define debug(...) printf(__VA_ARGS__)
#else
    #define debug(...) (void)0
#endif
#define MP make_pair
#define PB push_back
#define LL long long
#define pii pair<int,int>

#define F first
#define S second
#define ALL(x) (x).begin(),(x).end()
#define SZ(x) ((int)(x).size())
//const int inf = 0x7fffffff; //beware overflow
//const LL INF = 0x7fffffffffffffff; //beware overflow
#define mem(x, y) memset(x, (y), sizeof(x) );
#define IOS ios_base::sync_with_stdio(0); cin.tie(0)
template<typename A, typename B>
ostream& operator <<(ostream &s, const pair<A,B> &p) {
     return s<<"("<<p.first<<","<<p.second<<")";
}
template<typename T>
ostream& operator <<(ostream &s, const vector<T> &c) {
    s << "[ ";
    for (auto it : c) s << it << " ";
    s << "]";
    return s;
}
template<typename T>
ostream& operator << (ostream &o, const set<T> &st) {
    o << "{";
    for (auto it=st.begin(); it!=st.end(); it++) o << (it==st.begin() ? "" : ", ") << *it;
    return o << "}";
}
template<typename T1, typename T2>
ostream& operator << (ostream &o, const map<T1, T2> &mp) {
    o << "{";
    for (auto it=mp.begin(); it!=mp.end(); it++) {
        o << (it==mp.begin()?"":", ") << it->fi << ":" << it->se;
    }
    o << "}";
    return o;
}
inline LL getint(){
   LL _x=0,_tmp=1; char _tc=getchar();
   while( (_tc<'0'||_tc>'9')&&_tc!='-' ) _tc=getchar();
   if( _tc == '-' ) _tc=getchar() , _tmp = -1;
   while(_tc>='0'&&_tc<='9') _x*=10,_x+=(_tc-'0'),_tc=getchar();
   return _x*_tmp;
}
#define maxn 1000005
int a[maxn];
int main() {
    int n=getint(), c=getint(), k=getint();
    for(int i=0;i<n;i++) a[i]=getint();
    sort(a, a+n);
    int ans=0;
    int cur=0;
    //[cur .. n) is not fullfilled
    while(cur<n) {
        int t=a[cur]+k;
        int p=1;
        while(cur+p<n && p<c && a[cur+p]<=t ) p++;
        //[ cur .. cur+p)
        cur = cur+p;
        ans++;
    }
    printf("%d\n", ans);
}



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

typedef long long ll;
typedef unsigned long long ull;
typedef unsigned __int128 HASH;
typedef pair<int,int> pii;
typedef pair<ll, ll> pll;
typedef pair<ull, ull> pullull;
typedef pair<ll,int> plli;
typedef pair<double, int> pdbi;
typedef pair<int,pii> pipii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<pii> vpii;
typedef vector<vector<int>> mat;

#define rep(i,n) for (int i=0;i<(n);i++)
#define rep2(i,a,b) for (int i=(a);i<(b);i++)
#define rrep(i,n) for (int i=(n);i>0;i--)
#define rrep2(i,a,b) for (int i=(a);i>b;i--)
#define pb push_back
#define fi first
#define se second
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()

const ll hmod1 = 999999937;
const ll hmod2 = 1000000000 + 9;
const ll INF = 1<<30;
const ll mod = 10000;
const int dx4[4] = {1, 0, -1, 0};
const int dy4[4] = {0, 1, 0, -1};
const int dx8[8] = {1, 1, 1, 0, 0, -1, -1, -1};
const int dy8[8] = {0, 1, -1, 1, -1, 0, 1, -1};
const double pi = 3.141592653589793;

//#define int long long
#define addm(X, Y) ((X) = ((X) + (Y) % mod) % mod)

int n;
int a[10000 + 5];
ll dp[2][5005][2][2];

signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    cin >> n;
    rep(i, n - 1) cin >> a[i];
    int cur = 1, pre = 0;
    rep(i, n) {
        rep(j, n / 2 + 1)rep(k, 2)rep(l, 2) dp[cur][j][k][l] = INF;
        rep(j, min(n / 2 + 1, i + 2)) {
            if (j == i + 1) {
                dp[cur][i + 1][0][0] = 0;
                dp[cur][i + 1][0][1] = a[i];
            }
            else if (j == 0) {
                dp[cur][0][1][0] = 0;
                dp[cur][0][1][1] = a[i];
            }
            else {
                dp[cur][j][0][0] = min(dp[pre][j - 1][0][0], dp[pre][j - 1][1][1]);
                dp[cur][j][0][1] = dp[cur][j][0][0] + a[i];
                dp[cur][j][1][0] = min(dp[pre][j][0][1], dp[pre][j][1][0]);
                dp[cur][j][1][1] = dp[cur][j][1][0] + a[i];
            }
        }
        swap(cur, pre);
    }
    cout << min(dp[pre][n / 2][0][0], dp[pre][n / 2][1][0]) << endl;
}

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

#define itn int
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())

using namespace std;

inline int nxt() {
	int x;
	scanf("%d", &x);
	return x;
}

const int N = 1111111;
const int mod = 1000000007;
using li = long long;

li inv[N];
li fact[N];
li invfact[N];

li C(int n, int k) {
	return fact[n] * invfact[k] % mod * invfact[n - k] % mod;
}

li g(int n, int k) {
	return C((n + k)/2 - 1, k - 1);
}

li f(int n, int k) {
	if (2 * k <= n) {
		return C(n, k);
	}
	li tmp = C(n, k) - g(n, 2 * k - n);
	if (tmp < 0) {
		tmp += mod;
	}
	return tmp % mod;
}

int main() {
	int n = nxt();

	fact[0] = invfact[0] = 1;
	for (int i = 1; i < N; ++i) {
		inv[i] = (i == 1) ? 1 : mod - (mod / i) * inv[mod % i] % mod;
		fact[i] = fact[i - 1] * i % mod;
		invfact[i] = invfact[i - 1] * inv[i] % mod;
	}

	li ans = 0;
	for (int k = 0; k <= n - 1; ++k) {
		ans += f(n - 1, k) * fact[k] % mod * fact[n - 1 - k] % mod;
	}
	cout << ans % mod << "\n";

	return 0;
}

Measured memory_bytes: 26240
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
#include<unordered_map>
using namespace std;
int main(){
    int N, M;
    cin >> N;
    string s[110], t[110];
    unordered_map<string, int> point;
    for(int i = 1;i <= N;i++){
        cin >> s[i];
        point[s[i]]++;
    }
    cin >> M;
    for(int i = 1;i <= M;i++){
        cin >> t[i];
        point[t[i]]--;
    }
    int max = 0;
    for(int i = 1;i <= N;i++){
        if(point[s[i]] > max)max = point[s[i]];
    }
    cout << max;
}


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

int main() {
  int A, B, C, ans;
  cin >> A >> B >> C;
  ans = C - (A - B);
  if (ans <= 0) {
    cout << 0 << endl;
  }
  else {
    cout << ans << endl;
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;
//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
 
 
 
 


/*ll modexpo(ll a,ll b)
{
     ll res=1LL;
     while(b>0)
     {
          if(b&1)res=(res*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return res;
}*/



int main()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    int a[26]={0};
    for(int i=0;i<n;i++)a[s[i]-'a']++;
    ll res=1LL;
    for(int i=0;i<26;i++)
    {
         if(a[i]!=0){
              res=1LL*res*(a[i]+1LL)%mod;
         }
    }
    cout<<(res-1LL+mod)%mod;

}















 














 
 

















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

int d;
vector<int> c;
vector<vector<int>> s;

template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}

int main() {
    cin >> d;
    c.resize(26);
    s.resize(d, vector<int>(26));
    for (int i = 0; i < 26; i++) {
        cin >> c[i];
    }
    for (int i = 0; i < d; i++) {
        for (int j = 0; j < 26; j++) {
            cin >> s[i][j];
        }
    }
    vector<int> last(26, -1);
    vector<int> ans(d);
    for (int i = 0; i < d; i++) {
        int happiness_max = INT_MIN;
        for (int j = 0; j < 26; j++) {
            int happiness = 0;
            for (int k = 0; k < 26; k++) {
                if (j == k) {
                    happiness += s[i][k];
                } else {
                    happiness -= c[k] * (i - last[k]);
                }
            }
            if (chmax(happiness_max, happiness)) {
                ans[i] = j;
            }
        }
    }
    for (int i = 0; i < d; i++) {
        cout << ans[i] + 1 << endl;
    }
}


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

#define mod 1000000007
#define maxn 200005
int c[maxn], pre[maxn], dp[maxn];

int main() {
  int n;
  cin >> n;
  for (int i = 1; i <= n; i++) scanf("%d", c + i);
  n = unique(c, c + n + 1) - c;
  dp[1] = 1;
  pre[c[1]] = 1;
  for (int i = 2; i < n; i++) {
    dp[i] = (dp[i - 1] + dp[pre[c[i]]]) % mod;
    pre[c[i]] = i;
  }
  cout << dp[n - 1] << endl;
  return 0;
}


Measured memory_bytes: 2560
#include<bits/stdc++.h>
#define int long long
#define f(i,n) for(int i=0;i<n;i++)
#define F first
#define S second
#define mod 1000000007
#define P pair<int,int>
using namespace std;
int x[200000];
signed main(){
	int n,ans=0;
	cin>>n;
	f(i,n){
		cin>>x[i];
		if((i&&x[i]-x[i-1]>1)||(i==0&&x[i])){
			puts("-1");
			return 0;
		}
	}
	for(int i=n-1;i>=0;i--){
		if(x[i]>=x[i+1])ans+=x[i];
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 1792
#include <iostream>
#include <iomanip> //! for setprecision(10)
#include <math.h>
#include <algorithm>
#include <functional> 
#include <string>
#include <vector>

#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <utility>
#include <limits.h>

using namespace std;

typedef long long LL;

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define dump(c) { for (auto it = c.begin(); it != c.end(); ++it) if (it == c.begin()) cout << *it; else cout << ' ' << *it; cout << endl; } 
#define dumpMap(m) { for (auto it: m) cout << it.first << "=>" << it.second << ' '; }

const int MOD = 1000000007;

const int MAXN = 100;
const int MAXV = 100000;
int dp[MAXN+1][MAXV+1];
int w[MAXN+1];
int v[MAXN+1];

int main()
{
	cin.tie(0);
	ios::sync_with_stdio(0);
    
    int N, W;
    cin >> N >> W;
    for (int i = 1; i <= N; ++i) {
        cin >> w[i] >> v[i];
    }

    //! i = 1
    for (int val = 1; val <= MAXV; ++val) {
        if (val <= v[1]) {
            dp[1][val] = w[1];
        } else {
            dp[1][val] = W+1; //! cannot achieve within the weight constraint
        }
    }

    for (int i = 2; i <= N; ++i) {
        for (int val = 1; val <= MAXV; ++val) {
            if (val <= v[i]) {
                dp[i][val] = min(dp[i-1][val], w[i]);
            } else {
                dp[i][val] = min(W+1, min(dp[i-1][val], dp[i-1][val-v[i]] + w[i]));
            }
        }
    }

    int ans = 0;
    for (int val = MAXV; ans == 0 && 1 <= val; --val) {
        if (dp[N][val] <= W) {
            ans = val;
        }
    }
    
    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 39296
s = input().rstrip()

N = s.count('N')
W = s.count('W')
S = s.count('S')
E = s.count('E')

if (N > 0 and S == 0) or (N == 0 and S > 0):
    print('No')
    exit()
if (W > 0 and  E== 0) or (W == 0 and E > 0):
    print('No')
    exit()
print('Yes')


Measured memory_bytes: 3060
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

k = ni()
a = list(li())

if a[-1] != 2:
    print(-1)
    
else:
    lower = 2
    upper = 3
    exist = True
    for ai in a[-2::-1]:
        if lower%ai > 0 and upper%ai > 0 and lower//ai == upper//ai:
            exist = False
            print(-1)
            break
        
        lower = -(-lower//ai) * ai
        upper = (upper//ai) * ai + (ai-1)
        
    if exist:
        print(lower, upper)

Measured memory_bytes: 14256
#include<bits/stdc++.h>
#define F first
#define S second
#define REP(i, a, b, c) for(int i = a; i <= b; i+=c)
#define pb push_back
#define int long long int
#define MOD 1000000007
using namespace std;

double dp[3001][3001];
int32_t main()
{
  ios :: sync_with_stdio(false); cin.tie(0);
  int t = 1;

  for (int i9 = 1; i9 <= t; i9++)
  {
    int n;
    cin >> n;
    double a[n];
    for (int i = 0; i < n; i++)
    {
      cin >> a[i];
    }
    memset(dp, 0.0, sizeof(dp));
    for (int i = 0; i <= n; i++)
    {
      for (int x = 0; x <= (n + 1) / 2; x++)
      {
        if (x == 0)
          dp[i][x] = 1.0;
        else if (i == 0 and x != 0)
          dp[i][x] = 0;
        else
          dp[i][x] = a[i - 1] * dp[i - 1][x - 1] + (1 - a[i - 1]) * dp[i - 1][x];
      }
    }
    cout << setprecision(9) << dp[n][(n + 1) / 2];
  }
}



Measured memory_bytes: 74040
H, W = map(int, input().split())
if H % 2 == 0 and not W == 1:
    A = (H / 2) * W
elif H == 1:
    A = 1
else:
    if W % 2 == 0 and not H == 1:
        A = (((H + 1)/2)*(W / 2)) + ((((H + 1)/2)-1)*(W / 2))
    elif W == 1:
        A = 1
    else:
        A = ((H + 1)/2)*((W + 1)/2) + (((H + 1)/2) - 1)*(((W + 1)/2) - 1)
print(int(A))

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

using namespace std;

int main() {
  int n, k;
  int ans = 0;
  cin >> n >> k;
  for (int i = 1; i <= n; ++i) {
    int a = 0;
    cin >> a;
    if (a >= k) {
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a[202020],i,n,sum=0,big;
int main()
{
    scanf("%lld",&n);
    for(i=0;i<n;i++)scanf("%lld",&a[i]);

    big=a[0];
    for(i=1;i<n;i++)
    {
        if(a[i]<=big)sum=sum+big-a[i];
        else big=a[i];
    }
    printf("%lld",sum);
    return 0;
}


Measured memory_bytes: 5280
#include <bits/stdc++.h>
#define rep(i, n, m) for (int i = (int)(n); i < (int)(m); i++)
#define repr(i, n, m) for (int i = (int)(n) - 1; i >= (int)(m); i--)
using namespace std;
using ll = int64_t;
const int MOD = 1000000007; // 10^9+7

int main() {
    int n; cin >> n;
    map<int, int> cnt;
    vector<bool> f(1000001, false);

    rep(i, 0, n) {
        int a; cin >> a;
        cnt[a]++;
        f[a] = true;
    }

    for(size_t i = 1; i < f.size(); i++) {
        if (f[i]) {
            size_t k = 2;
            while (i * k < f.size()) {
                f[i * k] = false;
                k++;
            }
        }
    }

    for (auto &&i : cnt)
    {
        if (i.second != 1) f[i.first] = false;
    }

    int ans = 0;
    for (auto &&i : f)
    {
        if (i) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 13048
#include <iostream>
#include <fstream>
#include <vector>
#include <queue>
#include <iomanip>
#include <algorithm>
#include <string.h>
#define INF 1000000001

using namespace std;

ifstream in("sssp.in");

const int MAXV = 100005;
const int MAXM = 100005;

int v, e, s, x, y, c;
vector <pair<int, int> > g[MAXV];
int cost[MAXV];
priority_queue<pair <int, int> > q;

void dijkstra(){
	for(int i = 0; i < v; i++) 
		cost[i] = INF;

	cost[s] = 0;
	q.push(make_pair(s,0));

	while(!q.empty()){

		int node = q.top().first;
		int costt = q.top().second;

		q.pop();

    for(int i = 0; i < g[node].size(); i++){
    	pair<int, int> poss = g[node][i];
    	if(cost[poss.first] > poss.second - costt){
    		cost[poss.first] = poss.second - costt;
    		q.push(make_pair(poss.first, -cost[poss.first]));
    	}
		}
	}
}

int main(){	
	cin >> v >> e >> s;
	for(int i = 0; i < e; ++i){
		cin >> x >> y >> c;
		g[x].push_back(make_pair(y, c));
	}
	dijkstra();

	for(int i = 0; i < v; ++i){
		if(cost[i] == INF) 
			cout << "INF" << '\n';
		else 
			cout << cost [i] << '\n';
	}

  return 0;
}



Measured memory_bytes: 20320
import operator as op
import re
import sys
from bisect import bisect, bisect_left, insort, insort_left
from collections import Counter, defaultdict, deque
from copy import deepcopy
from decimal import Decimal
from functools import reduce
from itertools import (
    accumulate, combinations, combinations_with_replacement, groupby,
    permutations, product)
from math import (acos, asin, atan, ceil, cos, degrees, factorial, gcd, hypot,
                  log2, pi, radians, sin, sqrt, tan)
from operator import itemgetter, mul
from string import ascii_lowercase, ascii_uppercase, digits

# For getting input from input.txt file
# sys.stdin = open('input.txt', 'r')

# Printing the Output to output.txt file
# sys.stdout = open('output.txt', 'w')


def inp():
    return(int(input()))


def inlist():
    return(list(map(int, input().split())))


def instr():
    s = input()
    return(list(s[:len(s)]))


def invr():
    return(map(int, input().split()))


def def_value():
    return 0


s = input()

if s.isupper():
    print("A")
else:
    print("a")


Measured memory_bytes: 10304
"""

https://atcoder.jp/contests/abc141/tasks/abc141_f

=====答えを見た=====

奇数の桁は取り除いて0にしておく
後は適当に掃きだす

"""

from sys import stdin

N = int(stdin.readline())

A = list(map(int , stdin.readline().split() ))

allxor = 0
for i in range(N):
    allxor ^= A[i]
ans = 0

for i in range(60,-1,-1):

    ni = 2**i
    if ni & allxor > 0:
        ans += ni
        for j in range(N):
            if ni & A[j] > 0:
                A[j] ^= ni

able = [True] * N
for i in range(60,-1,-1):

    ni = 2**i
    ind = None
    for j in range(N):
        if able[j] and A[j] & ni > 0:
            ind = j
            able[j] = False
            break

    if ind != None:
        for j in range(N):
            if A[j] & ni > 0 and ind != j:
                A[j] ^= A[ind]
#print (A)
pl = 0
for i in range(N):
    pl ^= A[i]
print (ans + pl * 2)


Measured memory_bytes: 83468
# coding: utf-8

from collections import Counter

# 入力
n, k = [int(i) for i in input().split()]
a = [int(i) for i in input().split()]
c = Counter(a)

# メイン処理
loop_count = 0
count = 0
for key, value in sorted(c.items(), key=lambda x:x[1], reverse=True):
    if loop_count >= k:
        count += value
    loop_count += 1

# 出力
print(count)

Measured memory_bytes: 39296
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> lpair;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
#define rREP(i,m,n) for(ll i = (m); i >= (n); i--)
#define print(x) cout << (x) << endl;
#define printa(x,n) for(ll i = 0; i < n; i++){ cout << (x[i]) << " ";} cout<<endl;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int a,b,c,d;
    cin >> a >> b >> c >> d;

    if (abs(a-c) <= d || (abs(a-b) <= d & abs(b-c) <= d))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }
    
}


Measured memory_bytes: 256
import qualified Data.Text as T
import qualified Data.Text.IO as T
import qualified Data.Text.Read as T

main :: IO ()
main = do
  [a, b, n] <- map unsafeTextToInt . T.words <$> T.getLine :: IO [Int]
  print $ a * min (pred b) n `div` b

unsafeTextToInt :: T.Text -> Int
unsafeTextToInt s = case T.signed T.decimal s of
  Right (n, _) -> n


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

ll cnt[200001];

int main()
{
	ll n;
	cin >> n;
	vector<ll> A;
	for(ll i = 0;i<n;i++)
	{
		ll x;
		cin>>x;
		x--;
		cnt[x]++;
		A.push_back(x);
	}
	ll ans = 0;
	for(ll i = 0;i<200001;i++)
	{
		ans += cnt[i]*(cnt[i]-1)/2;
	}
	for(ll i =0;i<n;i++)
	{
		ll Ans = ans;
		Ans -= (cnt[A[i]])*(cnt[A[i]]-1)/2;
		Ans += (cnt[A[i]]-1)*(cnt[A[i]]-2)/2;
		cout<<Ans<<endl;
	}
	
	return 0;
}

Measured memory_bytes: 4848
require 'set'

n = gets.to_i
l = gets.split.map(&:to_i)

len = l.length
count = 0

result_set = Set.new

(0..len-3).each do |i|
  (i+1..len-2).each do |j|
    next if l[i] == l[j]
    (j+1..len-1).each do |k|
      next if l[j] == l[k] || l[i] == l[k]
      next unless (l[i] + l[j] > l[k]) && (l[j] + l[k] > l[i]) && (l[k] + l[i] > l[j])
      result = [l[i], l[j], l[k]]
      count += 1
    end
  end
end

puts count


Measured memory_bytes: 14504
#include<iostream>
#include<math.h>
#include<iomanip>
#include<string.h>
#include<cstdio>
#include<cstdlib>

using namespace std;

class node{
public:
  int key;
  node *prev;
  node *next;
};

node *nil;

void insert(int x){
  node *n1;
  n1 = (node *)malloc(sizeof(node));
  n1->key = x;
  n1->next = nil->next;
  nil->next->prev = n1;
  n1->prev = nil;
  nil->next = n1;
}

void deletex(node *n1){
  if(n1 == nil) return;
  n1->next->prev = n1->prev;
  n1->prev->next = n1->next;
  free(n1);
}

node *search(int x){
  node *cur = nil->next;
  while(cur != nil && cur->key != x){
    cur = cur->next;
  }
  return cur;
}

int main(){

  int n;

  cin >> n;

  nil = (node *)malloc(sizeof(node));
  nil->prev = nil;
  nil->next = nil;

  for(int i = 0; i < n; i++){
    char s[100];
    cin >> s;
    if(strlen(s) == 6){
      int x;
      cin >> x;
      if(s[0] == 'i') insert(x);
      else deletex(search(x));
    }
    else if(s[6] == 'F') deletex(nil->next);
    else deletex(nil->prev);
  }

  node *cur = nil->next;
  while(cur != nil->prev){
    cout << cur->key << " ";
    cur = cur->next;
  }
  cout << cur->key << endl;


  return 0;

}


Measured memory_bytes: 34344
#include<stdio.h>
int main(){
  int w,h,x,y,c;
  double s;
  scanf("%d%d%d%d", &w, &h, &x, &y);
  if(x*2==w && y*2==h){
    c=1;
  }else{
    c=0;
  }
  s=(double)w*h/2;
  printf("%lf %d", s, c);
  return 0;
}

Measured memory_bytes: 128
#include<stdio.h>

int main(void)
{
	unsigned long int a, b, c;
	unsigned long long int sum = 0;
	int i;

	scanf("%ld", &a);

	for (i = 1; i <= a; i++) {
		if (0 == (i % 3)) {
		}

		else if (0 == (i % 5)) {
		}

		else {
			sum = sum + i;
		}
	}

	printf("%lld", sum);

	return 0;
}

Measured memory_bytes: 1732
#include<iostream>
#include<stdio.h>
#include<vector>
#include<algorithm>
#include<set>
#include<string>
#include<map>
#include<string.h>
#include<complex>
#include<math.h>
#include<queue>
#include <functional>
#include<time.h>
#include <stack>
#include<iomanip>
using namespace std;
#define rep(i,a,n) for(int i=(a);i<(n);i++)
#define ll long long
#define llint long long int
#define reverse(v)  reverse(v.begin(), v.end());
#define Yes(ans) if(ans)cout<<"Yes"<<endl; else cout<<"No"<<endl;
#define YES(ans) if(ans)cout<<"YES"<<endl; else cout<<"NO"<<endl;
#define hei(a) vector<a>
#define whei(a) vector<vector<a>>
#define UF  UnionFind 
#define Pint pair<int,int>
#define keta(a)  fixed << setprecision(a)
constexpr auto INF = 100000000000;
constexpr auto mod = 1000000007;
//辞書順はnext_permutation( begin( v ), end( v ) );やで！
struct edge { int to, cost; };

//sは初めの点、vは頂点size、dは最短距離を求める(初期化はINF),Gは有向グラフ
void dijkdtra(int s, int v, vector<int>& d, whei(edge)& G) {
	priority_queue<Pint, vector<Pint>, greater<Pint>> que;//firstが距離、secondが頂点
	d[s] = 0;//スタートの距離はもちろんzero
	que.push(Pint(0, s));
	while (!que.empty()) {
		Pint p = que.top();
		que.pop();
		int V = p.second;
		if (d[V] < p.first)continue;
		for (int i = 0; i < G[V].size(); i++) {
			edge e = G[V][i];
			if (d[e.to] > d[V] + e.cost) {
				d[e.to] = d[V] + e.cost;
				que.push(Pint(d[e.to], e.to));
			}
		}
	}
}

int main() {
	int a, b, c;
	cin >> a >> b >> c;
	int ans = min(b / a, c);
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef vector<int> vi;

const int INF = 1000000000;

int main() {FIN
    
    int n, i, j, mn = INF, mx = -INF, c, t;
    cin >> n;
    vi ns(n);
    for (i = 0; i < n; i++) {
		cin >> ns[i];
		mn = min(mn, ns[i]);
		mx = max(mx, ns[i]);
	}
	
	c = INF;
	for (i = mn; i <= mx; i++) {
		t = 0;
		for (j = 0; j < n; j++)
			t += (ns[j] - i) * (ns[j] - i);
		c = min(c, t);
	}
	
	cout << c << "\n";
    
    return 0;
}


Measured memory_bytes: 3528
num_black,black=map(int,input().split())
if black+num_black<=1000000:
    right=black+num_black
else:
    right=1000000
if black-num_black>=-1000000:
    left=black-num_black
else:
    left=-1000000
for ans in range(left+1,right):
    print(ans,end="")
    if ans != right:
        print(" ",end="")
print()


Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define ll long long
#define pb push_back
#define fi first
#define se second 
#define mp make_pair
#define int long long
signed main()
{
    IOS
    int n; cin>>n;
    int arr[n],brr[n];
    for(int i=0;i<n;i++) cin>>arr[i];
    for(int i=0;i<n;i++) brr[i] = arr[i];
    sort(arr,arr+n);
    int count = 0;
    for(int i=0;i<n;i++)
    {
        if(arr[i] != brr[i]) count++;
    }
    if(count == 0 || count == 2) cout<<"YES";
    else cout<<"NO";
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

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

		int x = scan.nextInt();
		int y = scan.nextInt();

		int a = 0;

		if(x <= 3) {
			a += (4 - x) * 100_000;
		}
		if(y <= 3) {
			a += (4 - y) * 100_000;
		}
		if(x*y == 1) {
			a += 400_000;
		}

		System.out.println(a);

	}

}


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

#define rep(i,n) for(ll i=0;i<(n);++i)
using ll = int_fast64_t;
using pll = pair<ll,ll>;
constexpr ll INF = 1LL<<60;
constexpr ll MOD = 1e9+7;
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(a>b){a=b;return 1;}return 0;}
#if loc||local
template<class T>void dump(T&& t){cerr<<t<<endl;}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){cerr<<h<<", ";dump(forward<Ts>(t)...);}
#else
void dump(){}
template<class T,class... Ts> void dump(T&& h, Ts&&... t){}
#endif
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T> ostream &operator<<(ostream& os,vector<T>const& v){for(auto const& vi:v)os<<vi<<" ";return os;}
template<class T,class U> ostream &operator<<(ostream& os,pair<T,U>const& p){os<<p.first<<","<<p.second;return os;}
template<class T>vector<T> vec(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto vec(size_t a, Ts... ts){return vector<decltype(vec<T>(ts...))>(a, vec<T>(ts...));}

signed main(){

  ll n,m,k;
  cin>>n>>m>>k;
  vector<ll> a(n),b(m);
  cin>>a>>b;

  vector<ll> asum(n+1),bsum(m+1);
  rep(i,n)asum[i+1]=asum[i]+a[i];
  rep(i,m)bsum[i+1]=bsum[i]+b[i];

  ll ans = 0;
  rep(i,n+1){
    ll base = asum[i];
    ll key = k-base;
    if(base>k)continue;
    auto itr = upper_bound(begin(bsum),end(bsum),key);
    itr--;
    ll id = itr-begin(bsum);
    chmax(ans,id+i);
  }
  cout<<(ans)<<endl;

}

Measured memory_bytes: 9596
#include <iostream>
#include <sstream>
#include <fstream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <algorithm>
#include <functional>
#include <utility>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <numeric>
#include <string.h>
#define rep(i, x) for (int i = 0; i < (int)(x); i++)
#define repn(i, x) for (int i = 1; i <= (int)(x); i++)
#define repr(i, x) for (int i = ((int)(x) - 1); i >= 0; i--)
#define reprn(i, x) for (int i = ((int)(x)); i > 0; i--)
#define all(x) (x).begin(),(x).end()
using namespace std;
typedef long long int64;
const double PI = 3.14159265358979323846;
const double EPS = 1e-12;
const int INF = 1<<29;
const long long  INFL = 1e18;
const int MOD = 1000000007;
void solve() {
	int n; cin >> n;
	vector<int> h(n);
	rep (i, n) {
		cin >> h[i];
	}
	int cnt = 0;
	int ans = 0;
	for (int i = 0; i < (n - 1); ++i) {
		if (h[i] >= h[i + 1]) {
			cnt++;
		} else {
			cnt = 0;
		}
		ans = max(ans, cnt);
	}
	cout << ans << endl;
	return;
}

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int a, b, ans;
    char op;
    while(op != '?'){
        cin >>a >>op >>b;
      	if(op=='?') break;
        else if(op=='+') ans = a+b;
        else if(op=='-') ans = a-b;
        else if(op=='*') ans = a*b;
        else if(op=='/') ans = a/b;
        cout << ans << endl;
    }
}


Measured memory_bytes: 3104
def main():
    n,m=map(int,input().split())
    a=sorted(map(int,input().split()))
    bc=[list(map(int,input().split())) for _ in range(m)]
    bc.sort(key=lambda x: x[1], reverse=True)
    i = 0
    for b,c in bc:
        for _ in range(b):
            if i < len(a) and a[i] < c:
                a[i] = c
                i += 1
            else:
                print(sum(a))
                return
    print(sum(a))
    
if __name__ == "__main__":
    main()

Measured memory_bytes: 33216
#include <iostream>
#include <fstream>
#include <string>
#include <algorithm>
#include <vector>
#include <list>
#include <math.h>
#include <iomanip>
#include <map>
#define rep(i,n) for(int i=0;i<(n);i++)
using namespace std;




int N,M;
//int A_max = 1000 * 1000 * 1000;
//int B_max = 1000 * 100;
//int A[A_max];
//int B[B_max];

//int dp[A_max][B_max];

int dfs(int i, int res){
  return 0;
}


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

  vector<pair<int, int> > pairs(N);

  rep(i,N){
    cin>>pairs[i].first;
    cin>>pairs[i].second;
  }

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

  long long total = 0;
  int num = 0;
  int f = false;
  rep(i,N){
    rep(j, pairs[i].second){
      if(num == M) break;
      num++;
      total += (long long)pairs[i].first;
    }
    if(f) break;
  }
  cout<< total << endl;


}

Measured memory_bytes: 1024
import sys


def solve():
    input = sys.stdin.readline
    mod = 10 ** 9 + 7
    a, b = list(map(int, input().rstrip('\n').split()))
    if a <= 9 and b <= 9:
        print(a * b)
    else:
        print(-1)


if __name__ == '__main__':
    solve()


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <stdlib.h>
#include <string.h>

#define U1 unsigned char
#define S1 char
#define	S4 int
#define DU double
#define VD void

#define COMMAND_LENGTH     (10)   /* 命令の文字数 */

typedef struct st_node ST_NODE;
typedef struct st_node
{
	ST_NODE* st_parent;
	ST_NODE* st_left;
	ST_NODE* st_right;
	S4 s4_key;
};

VD vd_d_insert(ST_NODE**, S4);
VD vd_d_print(ST_NODE*);
static VD vd_s_printPreOrder(ST_NODE*);
static VD vd_s_printInOrder(ST_NODE*);
ST_NODE* st_dp_newST_NODE(S4);

S4 main()
{
	ST_NODE* st_tp_root;
	S4 s4_t_numCommand;
	S4 s4_t_iCommand;
	S1 s1_tp_command[COMMAND_LENGTH];
	S4 s4_t_insertKey;
	S4 s4_t_RtnStrcmp;

	st_tp_root = (ST_NODE*)NULL;

	//命令数
	(VD)scanf("%d", &s4_t_numCommand);

	//コマンド実行
	for (s4_t_iCommand = (S4)0; s4_t_iCommand < s4_t_numCommand; s4_t_iCommand++)
	{
		//TODO コマンドにより引数が異なる問題
		//コマンド(insert or print)
		(VD)scanf("%s", s1_tp_command);

		//コマンドの実行
		//isertとprintfしか入力されない前提で作成
		//コマンドの種類を増やす場合、print用のelse if文を追加すること。
		s4_t_RtnStrcmp = (S4)strcmp(s1_tp_command, "insert");
		if (s4_t_RtnStrcmp == (S4)0)
		{
			//insertならキーの値を取得
			(VD)scanf("%d", &s4_t_insertKey);
			vd_d_insert(&st_tp_root, s4_t_insertKey);
		}
		else
		{
			vd_d_print(st_tp_root);
		}
	}

	return((S4)0);
}


VD vd_d_insert(ST_NODE** st_ap2_root, S4 s4_a_key)
{
	ST_NODE* st_tp_parentNode;
	ST_NODE* st_tp_indexNode;
	ST_NODE* st_tp_insertNode;

	st_tp_insertNode = st_dp_newST_NODE(s4_a_key);

	st_tp_parentNode = (ST_NODE*)NULL;
	st_tp_indexNode = *st_ap2_root;

	while (st_tp_indexNode != (ST_NODE*)NULL)
	{
		st_tp_parentNode = st_tp_indexNode;
		if (st_tp_insertNode->s4_key < st_tp_indexNode->s4_key)
		{
			st_tp_indexNode = st_tp_indexNode->st_left;
		}
		else
		{
			st_tp_indexNode = st_tp_indexNode->st_right;
		}
	}
	st_tp_insertNode->st_parent = st_tp_parentNode;

	if (st_tp_parentNode == (ST_NODE*)NULL)
	{
		*st_ap2_root = st_tp_insertNode;
	}
	else if (s4_a_key < st_tp_parentNode->s4_key)
	{
		st_tp_parentNode->st_left = st_tp_insertNode;
	}
	else
	{
		st_tp_parentNode->st_right = st_tp_insertNode;
	}
}

VD vd_d_print(ST_NODE* st_ap_root)
{
	vd_s_printInOrder(st_ap_root);
	printf("\n");
	vd_s_printPreOrder(st_ap_root);
	printf("\n");
}

//st_ap_node…探索開始ノード
static VD vd_s_printPreOrder(ST_NODE* st_ap_node)
{
	if (st_ap_node == (ST_NODE*)NULL)
	{
		return;
	}

	printf(" %d", st_ap_node->s4_key);
	vd_s_printPreOrder(st_ap_node->st_left);
	vd_s_printPreOrder(st_ap_node->st_right);
}

//st_ap_node…探索開始ノード
static VD vd_s_printInOrder(ST_NODE* st_ap_node)
{
	static s4_s_printedNumNode = (S4)0;

	if (st_ap_node == (ST_NODE*)NULL)
	{
		return;
	}

	vd_s_printInOrder(st_ap_node->st_left);
	printf(" %d", st_ap_node->s4_key);
	vd_s_printInOrder(st_ap_node->st_right);
}

//ST_NODEのコンストラクタもどき
ST_NODE* st_dp_newST_NODE(S4 s4_a_key)
{
	ST_NODE* st_tp_node;
	st_tp_node = (ST_NODE*)malloc(sizeof(ST_NODE));
	st_tp_node->st_parent = (ST_NODE*)NULL;
	st_tp_node->st_left = (ST_NODE*)NULL;
	st_tp_node->st_right = (ST_NODE*)NULL;
	st_tp_node->s4_key = s4_a_key;

	return(st_tp_node);
}



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

int main() {
  int n;
  cin >> n;
  string s,t;
  cin >> s;
  cin >> t;
  
  rep(i, n) {
    cout << s[i] << t[i];
  }
  cout << endl;
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long
#define increase(a) sort(a.begin(), a.end())
#define decrease(a) sort(a.rbegin(), a.rend())
#define loop(n) for(ll i = 0; i<n; i++)
using namespace std;

int main(){
    int n, m;
    cin>>n>>m;
    if(n==m) cout<<"Yes\n";
    else cout<<"No\n";
    return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    int n, m, d;

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

    void run() {
        FastReader sc = new FastReader();
        n = sc.nextInt();
        m = sc.nextInt();
        d = sc.nextInt();
        solve();
    }

    void solve() {
        if (n <= 2 * d) {
            double ans = 2.0 * (n - d) / n / n * (m - 1);
            System.out.printf("%.50f\n", ans);
        } else if (d == 0) {
            double ans = 1.0 * (n - d) / n / n * (m - 1);
            System.out.printf("%.50f\n", ans);
        } else {
            double ans = 2.0 * (n - d) / n / n * (m - 1);
            System.out.printf("%.50f\n", ans);
        }
    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt()
        {
            return Integer.parseInt(next());
        }

        long nextLong()
        {
            return Long.parseLong(next());
        }

        double nextDouble()
        {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}


Measured memory_bytes: 21332
#include <iostream>
#include <vector>
#include <array>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <algorithm>
#include <iomanip>
#include <cmath>
#include <limits>

using namespace std;

int s_to_int(const string& s) {
	int res = 0;
	for (char c : s) {
		res = res * 10 + (c - '0');
	}
	return res;
}

int main (int argc, char* argv[]) {
	string s;
	cin >> s;

	int l = s_to_int(s.substr(0, 2));
	int r = s_to_int(s.substr(2, 2));

	if (l == 0 && r == 0) {
		cout << "NA" << endl;
	} else if (l <= 12) {
		if (r <= 12) {
			if (l == 0) {
				cout << "YYMM" << endl;
			} else if (r == 0) {
				cout << "MMYY" << endl;
			} else {
				cout << "AMBIGUOUS" << endl;
			}
		} else {
			if (l == 0) {
				cout << "NA" << endl;
			} else {
				cout << "MMYY" << endl;
			}
		}
	} else {
		if (r <= 12) {
			if (r == 0) {
				cout << "NA" << endl;
			} else {
				cout << "YYMM" << endl;
			}
		} else {
			cout << "NA" << endl;
		}
	}
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define vi vector<int>
typedef long long ll;

int main(){
  ll N, A, B;cin >> N >> A >> B;
  cout << A * (N/(A+B)) + min(N % (A+B), A);
}


Measured memory_bytes: 256
//高知能系Vtuberの高井茅乃です。
//Twitter: https://twitter.com/takaichino
//YouTube: https://www.youtube.com/channel/UCTOxnI3eOI_o1HRgzq-LEZw

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

#define INF 1999999999
#define REP(i,n) for(int i=0;i<n;i++)
#define REP1(i,n) for(int i=1;i<=n;i++)
#define MODA 1000000007 

int main() {
	int ans = 0;
	int tmp;
	int a, b;
	cin >> a >> b;
	tmp = b -a;
	int l = 0;
	REP1(i, tmp - 1) l += i;

	cout << l-a << endl;
}

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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var l = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long N = l[0], M = l[1];

            var total = 0L;
            if (M >= 2 * N)
            {
                total = N;
                M -= 2 * N;
                total += M / 4;
            }
            else
                total = M / 2;

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13396
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize("unroll-loops")
#pragma warning(disable : 4996)
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<unordered_map>
#include<unordered_set>
#include<time.h>
#include<random>
#include<array>


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-1;i >= n;--i)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout<<(x)<<'\n'
#define pe(x) cout<<(x)<<" "
#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define lb(v,n) lower_bound(v.begin(), v.end(), (n))
#define ub(v,n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i,v.size())cout << v[i] << ((i == v.size() - 1) ? "\n" : " ")
template<typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template<typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int>P;
typedef array<int, 3> arr3;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353; constexpr int MAX = 2000020;
const double pi = acos(-1); constexpr double EPS = 1e-8;
constexpr ll INF = 1e18;
void y(bool cond) {
	if (cond)print("Yes");
	else print("No");
}

int A, B, C, D, E, X, Y, Z, M, N;
string S, T;
void solve() {
	cin >> S;
	int ans = 0;
	REP(i, S.size()) {
		if (S[i] == '+')ans++;
		else ans--;
	}
	print(ans);
}


signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q; cin >> q;
	//while (q--)
	solve();
}



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

int main(){
	int a1, a2, b1, i, n, num;
	
	while(cin>>a1>>a2>>b1){
		num=n=20-a1-a2;
		if(n>a1)num--;
		if(n>a2)num--;
		if(n>b1)num--;
		if(num<4)cout<<"NO"<<endl;
		if(num>=4)cout<<"YES"<<endl;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <algorithm>
#include <string.h>
#include <iostream>
#include <stdio.h>

using namespace std;

typedef long long ll;
const ll N = 110;
ll n, m, q;
ll a[N], b[N], c[N], d[N];
ll s[20], res;

void dfs(ll u, ll last) {
	if (u > n) {
		ll cnt = 0;
		for (ll i = 1; i <= q; i++) {
			if (s[b[i]] - s[a[i]] == c[i]) {
				cnt += d[i];
			}
		}
		res = max(res, cnt);
		return;
	}
	for (ll i = last; i <= m; i++) {
		s[u] = i;
		dfs(u + 1, i);
	}
}

int main() {
	cin >> n >> m >> q;
	for (ll i = 1; i <= q; i++) cin >> a[i] >> b[i] >> c[i] >> d[i];
	dfs(1, 1);

	cout << res << endl;

	return 0;
}

Measured memory_bytes: 3640
#define _USE_MATH_DEFINES
#include <iostream>
#include <sstream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
#include <random>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define REPE(i, n) for (int (i)=0; (i) <= (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }






signed main()
{
	int M;
	cin >> M;
	cout << 24 + (24 - M) << endl;
}




Measured memory_bytes: 3560
#include <iostream>

using namespace std;

int main()
{
    ios_base::sync_with_stdio(0);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int p = max(a, c);
    int k = min(b, d);
    if (p <= k)
        cout << k - p;
    else
        cout << "0";
    return 0;
}


Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))

cnt1,cnt2=0,0
for i in a:
    if i%2!=0:
        cnt1+=1
    if i%4==0:
        cnt2+=1
print('Yes' if cnt2>=cnt1 or (len(a)%2!=0 and cnt2+1>=cnt1) else 'No')

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

x_1=[]
y_1=[]
for i in range(n):
    a,b=map(int,input().split())
    x_1.append(a)
    y_1.append(b)

x_2=[]
y_2=[]
for i in range(m):
    c,d=map(int,input().split())
    x_2.append(c)
    y_2.append(d)
    
for i in range(n):
    min_l=abs(x_1[i]-x_2[0])+abs(y_1[i]-y_2[0])
    ans=0
    for j in range(m):
        e=abs(x_1[i]-x_2[j])+abs(y_1[i]-y_2[j])
    
        if min_l >e:
            min_l=e
            ans=j
    print(ans+1)  

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(a,n) for (ll a = 0; a < (n); ++a)
using namespace std;
typedef long long ll;
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 ll INF = 1e18;

template< typename T = int >
struct Edge {
  int from, to;
  T cost;
  int idx;

  Edge() = default;

  Edge(int from, int to, T cost = 1, int idx = -1) : from(from), to(to), cost(cost), idx(idx) {}

  operator int() const { return to; }
};

template< typename T = int >
struct Graph {
  vector< vector< Edge< T > > > g;
  int es;

  Graph() = default;

  explicit Graph(int n) : g(n), es(0) {}

  size_t size() const {
    return g.size();
  }

  void add_directed_edge(int from, int to, T cost = 1) {
    g[from].emplace_back(from, to, cost, es++);
  }

  void add_edge(int from, int to, T cost = 1) {
    g[from].emplace_back(from, to, cost, es);
    g[to].emplace_back(to, from, cost, es++);
  }

  void read(int M, int padding = -1, bool weighted = false, bool directed = false) {
    for(int i = 0; i < M; i++) {
      int a, b;
      cin >> a >> b;
      a += padding;
      b += padding;
      T c = T(1);
      if(weighted) cin >> c;
      if(directed) add_directed_edge(a, b, c);
      else add_edge(a, b, c);
    }
  }
};

/**
 * @brief BFS(幅優先探索)
 */
template< typename T >
vector< T > bfs(const Graph< T > &g, int s) {
  T max_cost = 0, beet = 0;
  for(auto &es : g.g) {
    for(auto &e : es) max_cost = max(max_cost, e.cost);
  }
  ++max_cost;
  const auto INF = numeric_limits< T >::max();
  vector< T > dist(g.size(), INF);
  vector< queue< int > > ques(max_cost + 1);
  dist[s] = 0;
  ques[0].emplace(s);
  for(T cost = 0; cost <= beet; cost++) {
    auto &que = ques[cost % max_cost];
    while(!que.empty()) {
      int idx = que.front();
      que.pop();
      if(dist[idx] < cost) continue;
      for(auto &e : g.g[idx]) {
        auto next_cost = cost + e.cost;
        if(dist[e.to] <= next_cost) continue;;
        dist[e.to] = next_cost;
        beet = max(beet, dist[e.to]);
        ques[dist[e.to] % max_cost].emplace(e.to);
      }
    }
  }
  return dist;
}


int main(){
    int n,u,v;
    cin >> n >> u >> v;
    u--;v--;
    Graph<int> g(n);
    g.read(n-1,-1,false,false);
    auto dista = bfs(g,v);
    auto distt = bfs(g,u);
    int M = 0;
    rep(i,n){
        if(dista[i]>distt[i])chmax(M,dista[i]);
    }
    cout << M-1 << endl;
    return 0;
}


Measured memory_bytes: 11680
import java.util.Scanner;

public class Main {
	public static void main(String[] args){
		Scanner stdIn = new Scanner(System.in);
		int K = stdIn.nextInt();
		int A = stdIn.nextInt();
		int B = stdIn.nextInt();
		int ans = 0;

		for(int a = A; a <= B ; a++){
			if(a % K == 0){
				ans = 1;
				break;
			}
		}
		if(ans == 1){
			System.out.println("OK");
		}
		else{
			System.out.println("NG");
		}
		stdIn.close();
	}
}

Measured memory_bytes: 35640
#include<iostream>
#include<algorithm>
#include<math.h>
#include<queue>
#include<vector>
#include<climits>
#include<map>
#include<string>
#include<functional>
#include<iomanip>
#include<deque>
#include<random>
#include<set>

using namespace std;
typedef long long ll;
typedef double lldo;
#define mp make_pair
#define pub push_back
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define sz(x) int(x.size())
ll gcd(ll a, ll b) { if (a % b == 0) { return b; } else  return gcd(b, a % b); }
ll lcm(ll a, ll b) { if (a == 0) { return b; }return a / gcd(a, b) * b; }
template<class T>ll LBI(vector<T>& ar, T in) { return lower_bound(ar.begin(), ar.end(), in) - ar.begin(); }
template<class T>ll UBI(vector<T>& ar, T in) { return upper_bound(ar.begin(), ar.end(), in) - ar.begin(); }

string n;
ll k, dp[101][4][2] = {};

int main() {
	cin >> n;
	cin >> k;
	dp[0][0][0] = 1;
	rep(i, sz(n)) {
		rep(j, k + 1) {
			dp[i + 1][j][1] += dp[i][j][1];
			if (n[i] == '0') {
				dp[i + 1][j][0] += dp[i][j][0];
			}
			else {
				dp[i + 1][j][1] += dp[i][j][0];
				if (j < k)dp[i + 1][j + 1][0] += dp[i][j][0];
			}
			if (j < k) {
				dp[i + 1][j + 1][1] += dp[i][j][1] * 9;
				if (n[i] > '1')dp[i + 1][j + 1][1] += dp[i][j][0] * (n[i] - '0' - 1);
			}
		}
	}
	cout << dp[sz(n)][k][0] + dp[sz(n)][k][1] << endl;
	return 0;
}

Measured memory_bytes: 256