akhauriyash/Code-Regression huggingface dataset:
#define _CRT_SECURE_NO_WARNINGS
#define _USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <unordered_map>
#include <functional>
#include <utility>
#include <tuple>
#include <cctype>
#include <bitset>
#include <complex>
#include <cmath>
#include <array>
using namespace std;
#define INF 0x3f3f3f3f
#define INFLL 0x3f3f3f3f3f3f3f3fLL
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pint;
typedef pair<ll,ll> pll;
typedef tuple<int,int,int> tint;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<pint> vpint;
int dx[8]={0,0,-1,1,1,1,-1,-1};
int dy[8]={-1,1,0,0,1,-1,1,-1};
const int SIZE=550;
//ここまでテンプレ
int main(){
	int A,B,X;
	cin>>A>>B>>X;
	if(A+B>=X && A<=X)
		cout<<"YES"<<endl;
	else
		cout<<"NO"<<endl;
	return 0;
}

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

#define rep(i, n) for(int (i) = 0; (i) < (n); (i)++)
#define repn(i, n) for(int (i) = 1; (i) <= (n); (i)++)
#define repr(i, n) for(int (i) = (n-1); (i) >= 0; (i)--)
#define all(x) (x).begin(), (x).end()
#define lint long long
#define ulint unsigned long long
#define fi first
#define se second
#define setpre(x) cout << fixed << setprecision(x)
#define ii(x) int x; cin >> (x)
#define ii2(x, y) int x, y; cin >> (x) >> (y)
#define out(x) cout << (x) << endl
#define yn(x) cout << ((x)?("Yes"):("No")) << endl
#define YN(x) cout << ((x)?("YES"):("NO")) << endl

inline void logger(){ cout << endl; }
template<typename A, typename... B>
void logger(const A& a, const B&... b){
    cout << a << " , ";
    logger(b...);
}

typedef pair<lint, lint> P;
const lint MOD = 1000000007;
const lint MOD9 = 998244353;
const lint INF = MOD * MOD;
const int MAX = 100005;

/* ...o(^-^)o... */

int main(){
    ii2(n, x); vector<int> vec;
    rep(i, n){
        ii(m); vec.push_back(m); x -= m;
    }
    sort(all(vec)); int res = n + (x / vec[0]);
    out(res);
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define range(a) a.begin(),a.end()
int main(){
	int N;cin>>N;
	int W[N];int sum[N];int temp=0;
	rep(i,0,N){
		cin>>W[i];
		temp+=W[i];
		sum[i]=temp;
	}int ans=sum[N-1];
	rep(i,0,N){
		ans=min(ans,abs(sum[N-1]-2*sum[i]));
	}cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    for (int i = 0; i <= 30; i++) {
        for (int j = 0; j <= 30; j++) {
            if (i * 4 + j * 7 == N) {
                printf("%s\n", "Yes");
                return 0;
            }
        }
    }
    printf("%s\n", "No");
    return 0;
}


Measured memory_bytes: 3588
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#define int long long
using namespace std;
signed main() {
	int X;
	cin >> X;

	for (int A = -1000; A <= 1000; A++) {
		for (int B = -1000; B <= 1000; B++) {

			if (A*A*A*A*A - B*B*B*B*B == X) {
				cout << A << " " << B << endl;
				return 0;
			}
			
		}
	}
}


Measured memory_bytes: 3636
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<=n;i++)
using namespace std;
int main(){
    int K,S,ans=0;
    cin>>K>>S;
    REP(i,K)REP(y,K)if(0<=(S-i-y)&&(S-i-y)<=K)ans++;
    cout<<ans<<endl;
}

Measured memory_bytes: 256
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

N, K = map(int, input().split())


def solve():
    ans = 0
    for i in range(1, N+1):
        tmp = i
        num = 0
        while tmp < K:
            num += 1
            tmp *= 2
        ans += (1/2)**num
    print(ans/N)


solve()


Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for(ll i=0;i<n;i++)
#define repab(i,a,b) for(ll i=a;i<=b;i++)
#define ull unsigned long long int
#define ll long long int
#define LL_MAX 9223372036854775807
#define pb push_back
#define pf push_front
#define mp make_pair
#define popb pop_back
#define vl vector<ll>
#define bs(v,x) binary_search(v.begin(),v.end(),x)
#define popf pop_front
#define p() cout<<'\n'
#define p0(x) cout<<x<<" "
#define p1(x) cout<<x<<'\n'
#define p2(x,y) cout<<x<<" "<<y<<'\n'
#define p3(x,y,z) cout<<x<<" "<<y<<" "<<z<<'\n'
#define pr1(x) cout<<fixed<<setprecision(15)<<x<<'\n'
#define mod 1000000007
#define mod1 998244353
#define fio ios_base::sync_with_stdio(false);cin.tie(NULL)
#define get(n) ll n;cin>>n
#define getvec(v,n) vector<ll> v(n);for(ll i=0;i<n;i++) cin>>v[i];
#define getstr(s) string s;cin>>s
#define all(x) x.begin(),x.end()
#define countBits(x) __builtin_popcount (x)
using namespace std;

int main(){
  fio;
  get(n);
  vector<pair<ll,ll>> v;
  rep(i,n){
    get(x);get(l);
    ll a=x-l;ll b=x+l;
    v.pb({a,b});
  }
  // rep(i,n)
  //   p2(v[i].first,v[i].second);
  sort(all(v));
  ll ans=0;
  ll l=v[0].first;ll r=v[0].second;ll curr=1;
  while(curr<n){
    if(l==v[curr].first&&r==v[curr].second){
      ans++,curr++;
    }
    else if(r==v[curr].second){
      l=v[curr].first;
      ans++,curr++;
    }
    else if(r>v[curr].second){
      l=v[curr].first;
      r=v[curr].second;
      ans++,curr++;
    }
    else if(r<=v[curr].first){
      l=v[curr].first;
      r=v[curr].second;
      curr++;
    }
    else{
      ans++,curr++;
    }
  }
  ans=n-ans;
  p1(ans);
  return 0;
}


Measured memory_bytes: 2420
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>
#include <climits>
#include <vector>
#include <map>
#include <set>
#include <list>
#include <stack>
#include <queue>
#include <algorithm>
#include <iostream>
#include <string>

#define REP(i,n) for(int i=0;i<n;++i)
#define REPR(i,n) for(int i=n;i>=0;--i)
#define REPI(itr,v) for(auto itr=v.begin();itr!=v.end();++itr)
#define REPIR(itr,v) for(auto itr=v.rbegin();itr!=v.rend();++itr)
#define FOR(i,a,b) for(int i=a;i<b;++i)
#define SORT(v,n) sort(v, v+n)
#define SORTV(v) sort(v.begin(), v.end())
#define ALL(v) v.begin(),v.end()
#define llong long long
#define INF 999999999
#define SUR 1000000007
#define pb push_back
#define pf push_front
#define MP make_pair

int dx[] = {0, 0, -1, 1};
int dy[] = {1, -1, 0, 0};

using namespace std;

typedef pair<int,int> pii;

int main(){

  while(true){
    string s;
    getline(cin, s);
    if(s == ".") break;

    int len = s.length();
    int l1 = 0, l2 = 0;
    bool f = true;
    stack<int> st; // (:1 [:2
    REP(i,len){
      if(s[i] == '('){
        l1++;
        st.push(1);
      }else if(s[i] == ')'){
        l1--;
        if(st.empty()){
          f = false;
          break;
        }
        int tmp = st.top(); st.pop();
        if(tmp == 2) f = false;
      }else if(s[i] == '['){
        l2++;
        st.push(2);
      }else if(s[i] == ']'){
        l2--;
        if(st.empty()){
          f = false;
          break;
        }
        int tmp = st.top(); st.pop();
        if(tmp == 1) f = false;
      }
    }
    if(f && l1 == 0 && l2 == 0){
      cout <<"yes\n";
    }else{
      cout <<"no\n";
    }
  }
  return 0;
}




Measured memory_bytes: 3136
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define all(v) v.begin(), v.end()
#define fi first
#define se second
using namespace std;
using ll = long long;
using P = pair<int ,int>;
const int INF = 1e9;
const int MOD = 1e9+7;

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

    ll a, b, k; cin >> a >> b >> k;
    if (a>k) {
        a -= k;
    } else {
        k -= a;
        a = 0;
        b -= k;
        if (b<0) b = 0;
    }
    cout << a << " " << b << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000000;
constexpr ll INF= 9 * 1e18;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<int,int> P;

int main() {
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    int Domestic = 0;
    int Abroad = 0;
    for(int i = 0;i < N;i++) {
        if(S.at(i) == 'a') {
            if(Domestic + Abroad < A + B) {
                cout << "Yes" << endl;
                Domestic++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else if(S.at(i) == 'b') {
            if(Domestic + Abroad < A + B && Abroad < B) {
                cout << "Yes" << endl;
                Abroad++;
            }
            else {
                cout << "No" << endl;
            }
        }
        else {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 896
#!/usr/bin/env python3


def solv(a, b):
    k2 = a + b
    if k2 % 2:
        return 'IMPOSSIBLE'
    else:
        return k2 // 2


if __name__ == '__main__':

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

    ans = solv(a, b)

    print(ans)


Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define m 1000000007
#define fastio ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
int main()
{
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r" , stdin);
// 	freopen("output.txt" , "w" , stdout);
// #endif
	int a, b, k;
	cin >> k >> a >> b;
	int c = b % k;
	if (b - c < a)
		cout << "NG";
	else
		cout << "OK";
	return 0;
}

Measured memory_bytes: 3648
#pragma GCC optimize "03"
#include "bits/stdc++.h"
using namespace std;
 
#define ll long long int
#define ld long double
#define pi pair<int, int>
#define pb push_back
#define fi first
#define se second
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#ifndef LOCAL
#define endl '\n'
#endif
 
const int N = 3e3 + 5;
const int mod = 1e9 + 7;
const int inf = 1e9 + 9;
 
int dp[N][N];

signed main() {
	IOS;
	#ifdef LOCAL
		freopen("input.txt","r", stdin);
		freopen("output.txt","w",stdout);
	#endif
	int n;	cin >> n;
	string s;	cin >> s;
	dp[1][1] = 1;
	s = "#" + s;
	for(int i = 1; i < (int)s.length(); i++){
		for(int j = 1; j <= i; j++)
			dp[i][j] = (dp[i][j] + dp[i][j-1]) % mod;
		if(s[i] == '<'){
			for(int j = 1; j <= i; j++){
				dp[i+1][j+1] = (dp[i+1][j+1] + dp[i][j]) % mod;
			}
		}	
		else{
			for(int j = 1; j <= i; j++){
				dp[i+1][1] = (dp[i+1][1] + dp[i][j]) % mod;
				dp[i+1][j+1] = (dp[i+1][j+1] - dp[i][j] + mod) % mod;
			}
		}
	}
	int ans = 0;
	for(int i = 1; i <= n; i++){
		dp[n][i] = (dp[n][i] + dp[n][i-1]) % mod;
		ans = (ans + dp[n][i]) % mod;
	}
	cout << ans;
	return 0;
}

Measured memory_bytes: 34176
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iterator>
/*
#include <map>
#include <functional>
#include <set>
#include <queue>
#include <cstdio>
#include <cmath>
*/
using namespace std;
typedef long long ll;
//typedef pair<ll, ll> P;

/* Union-find
int par[100010];
int trank[100010];

void init(int n) {
   for (int i=0;i<n;i++) {
      par[i] = i;
      trank[i] = 0;
   }
}
int find(int x) {
   if (par[x] == x) {
      return x;
   } else {
      return par[x] = find(par[x]);
   }
}
void unite(int x, int y) {
   x = find(x);
   y = find(y);
   if (x == y) return;
   if (trank[x] < trank[y]) {
      par[x] = y;
   } else {
      par[y] = x;
      if (trank[x] == trank[y]) trank[x]++;
   }
}
bool same(int x, int y) {
   return find(x) == find(y);
}
*/

ll N, X;
ll had_p;
ll ep[70];
ll fp[70];

ll rec(ll Y, int i) {
   if (i <= 0) {
      return (Y > 0) ? 1 : 0;
   }
   Y--;
   if (Y == 0) {
      return 0;
   }

   if (Y < fp[i-1]) {
            //cout << "case1" << endl;
      return rec(Y, i-1);
   }
   Y -= fp[i-1];
   if (Y == 0) {
      //cout << "case2" << endl;
      return ep[i-1];
   }
   Y--;
   if (Y == 0) {
      //cout << "case3" << endl;
      return ep[i-1] + 1;
   }

   if (Y < fp[i-1]) 
   {
      //cout << "case4" << endl;
      return rec(Y, i-1) + ep[i-1] + 1;
   }
   //cout << "case5" << endl;
   return ep[i-1] + 1 + ep[i-1];
}

int main() {
   cin >> N >> X;
   ep[0] = 1;
   fp[0] = 1;
   for (int i=1;i<=N-1;i++) {
      ep[i] = ep[i-1] + 1 + ep[i-1];
      fp[i] = 1 + fp[i-1] +1 + fp[i-1] + 1;
   }
   cout << rec(X, N) << endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <cmath>
#include <cstring>
#include <sstream>
#include <algorithm>
#include <cstdlib>
#include <map>
#include <queue>
#include <utility>
#include <vector>
#include <set>
#include <memory.h>
#include <iomanip>
#include <bitset>
#include <list>
#include <stack>
#include <deque>

using namespace std;

#define mod 1000000007

int main()
{
	int n;
	cin >> n;
	int p[200001] = {};
	for(int i = 0; i < n; i++){
		int tmp;
		cin >> tmp;
		p[tmp] = i;
	}
	int r;
	int ans = mod;
	for(int i = 1; i <= n; i++){
		r = i;
		while(r < n && p[r] < p[r + 1]){
			r++;
		}
		ans = min(ans, n - (r - i + 1));
		i = r;
	}
	cout << ans << endl;
	return 0;
}

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

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

int nums[5];
int ones[5];

int main() {
  REP(i, 5) scanf("%d", &nums[i]);
  int ans = 0;
  REP(i, 5) {
    ans += nums[i] / 10 * 10;
    ones[i] = nums[i] % 10;
  }
  sort(ones, ones+5);
  int p;
  REP(i, 5) {
    if (ones[i] != 0) {
      ans += ones[i];
      p = i;
      break;
    }
  }
  ans += 10 * (5-p-1);
  printf("%d\n", ans);
  
  return 0;
}


Measured memory_bytes: 256
from collections import Counter

if __name__ == '__main__':
    n = int(input())
    vs = list(map(int, input().split()))

    even = vs[::2]
    odd = vs[1::2]

    def solve(even, odd):
        ce = Counter(even)
        co = Counter(odd)
        
        emode = ce.most_common()
        omode = co.most_common()
        
        result = 0
        if emode[0][0] != omode[0][0]:
            for i in range(1, len(emode)):
                result += emode[i][1]
            for i in range(1, len(omode)):
                result += omode[i][1]
            
            return result
        
        else:
            temp1 = 0
            temp2 = 0
            for i in range(1, len(emode)):
                temp1 += emode[i][1]
            
            if len(omode) == -1:
                temp1 += len(odd)
            else:
                for i in range(len(omode)):
                    if i == 1:
                        continue
                    else:
                        temp1 += omode[i][1]
                        
                        
            for i in range(1, len(omode)):
                temp2 += omode[i][1]
            
            if len(emode) == -1:
                temp2 += len(even)
            else:
                for i in range(len(emode)):
                    if i == 1:
                        continue
                    else:
                        temp2 += emode[i][1]
            result = min(temp1, temp2)
            
            return result
        
    print(solve(even, odd))
        
    

Measured memory_bytes: 21952
#include<bits/stdc++.h>
using namespace std;
string s;
int a[10000005],len,ans=0;
int main(){
    cin>>s;
    int len=s.length();
    for(int i=len-1;i>=0;i--){
    	a[len-1-i]=s[i]-'0';
	}
	for(int i=0;i<=len;i++){
		if(a[i]==10)a[i+1]++;
	    if((a[i]==5&&a[i+1]>=5)||(a[i]>5&&a[i]<10))ans+=(10-a[i]),a[i+1]++;
	    if(a[i]==5&&a[i+1]<5)ans+=a[i];
	    if(a[i]<5)ans+=a[i];	
	}
	printf("%d",ans);

	return 0;
}

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

using namespace std;

int main(){
    int N, T, c, t, mincost = 10000;
    int count = 0;
    cin >> N >> T;
    for(int i = 0; i < N; i++){
        cin >> c >> t;
        if(t <= T){
            if(c < mincost) mincost = c;
            count++;
        }
    }

    if(count != 0){
        cout << mincost << endl;
    }else{
        cout << "TLE" << endl;
    }



    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
  int a,b,c,tmp;
  scanf("%d %d %d",&a,&b,&c);
  tmp=a;
  a=b;
  b=tmp;
  
  tmp=a;
  a=c;
  c=tmp;
  printf("%d %d %d",a,b,c);
  return 0;
}


Measured memory_bytes: 128
H, W = map(int, input().split())
a = [list(map(int, input().split())) for i in range(H)]
c = 0
N = 0
ans = []
for i in range(H):
  for j in range(W):
    if a[i][j]%2==1:
      if j+1<W:
        ans.append([i+1,j+1,i+1,j+2])
        a[i][j]-=1
        a[i][j+1]+=1
        N += 1
      elif i+1<H:
        a[i][j]-=1
        a[i+1][j]+=1
        ans.append([i+1,j+1,i+2,j+1])
        N += 1
    
        
print(N)
for i in range(N):
  L=[str(x) for x in ans[i]]
  L=" ".join(L)
  print(L)
  


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

int main(){
    
    string S;
    cin>>S;
    int N=S.size(),ans=0;
    if(N==1) cout<<S[0]-'0'<<endl;
    else{
        bool flag=true;
        for(int i=1;i<N;i++){
            if(S[i]!='9') flag=false;
        }
        if(flag) cout<<S[0]-'0'+(N-1)*9<<endl;
        else cout<<S[0]-'0'+(N-1)*9-1<<endl;
    }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
#include <algorithm>
#include <iostream>
#include <math.h>
#include <vector>
#include <map>
#define ll long long
#define inf 0x3f3f3f3f
using namespace std;
const int maxn = 1e5 + 5;

int a[maxn];
int main()
{
    int n, cnt = 0;
    scanf("%d", &n);
    for(int i=1; i<=n; i++)
        scanf("%d", &a[i]);
    for(int i=1; i<n; i++)
    {
        if(a[i]==i&&a[i+1]==i+1)
            swap(a[i], a[i+1]), ++ cnt;
    }
    if(a[1]==1)
        swap(a[1], a[2]), ++ cnt;
    for(int i=2; i<=n; i++)
    {
        if(a[i] == i)
            swap(a[i-1], a[i]), ++ cnt;
    }
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 640
#include <cstdio>
#include <cstring>
#include <iostream>
using namespace std;
inline char nc() {
	static char buf[100000], *l = buf, *r = buf;
	return l==r&&(r=(l=buf)+fread(buf,1,100000,stdin),l==r)?EOF:*l++;
}
template<class T> void read(T &x) {
	x = 0; int f = 1, ch = nc();
	while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=nc();}
	while(ch>='0'&&ch<='9'){x=x*10-'0'+ch;ch=nc();}
	x *= f;
}
const int inf = 1e9;
const int maxm = 200000 + 5;
int n, m, a[maxm], l, r; 
int mark[maxm];
int judge(int x) {
	for(int i = n, j = n; i > 1; --i, ++j) {
		if(a[i] >= x && a[i - 1] >= x) return 1;
		if(a[j] >= x && a[j + 1] >= x) return 1;
		if(a[i] <  x && a[i - 1] <  x) return 0;
		if(a[j] <  x && a[j + 1] <  x) return 0;
	}
	return a[1] >= x;
}
int sol() {
	int an = -1;
	while(l <= r) {
		int mid = (l + r) >> 1;
		if(judge(mid)) l = mid + 1, an = mid;
		else r = mid - 1;
	}
	return an;
} 
int main() {
//	freopen("testdata.in", "r", stdin);
	l = inf, r = -inf;
	read(n), m = (n << 1) - 1;
	for(int i = 1; i <= m; ++i) {
		read(a[i]);
		l = min(l, a[i]);
		r = max(r, a[i]);
	}
	printf("%d\n", sol());
	return 0;
}

Measured memory_bytes: 1152
#include<algorithm>
#include<iostream>
#include<string>
#include<cstdlib>
#include<cstring>
#include<cmath>
using namespace std;
int pt(double px,double py,double qx,double qy,double rx,double ry,double sx,double sy){
  if(((rx-qx)*(py-qy)-(px-qx)*(ry-qy)<=0&&(sx-rx)*(py-ry)-(px-rx)*(sy-ry)<=0&&(qx-sx)*(py-sy)-(px-sx)*(qy-sy)<=0)||
     ((rx-qx)*(py-qy)-(px-qx)*(ry-qy)>=0&&(sx-rx)*(py-ry)-(px-rx)*(sy-ry)>=0&&(qx-sx)*(py-sy)-(px-sx)*(qy-sy)>=0))
    return 1;
  return 0;
}
int main(){
  int h,i;
  int n;
  cin>>n;
  for(h=0;h<n;h++){
    int x[5],y[5];
    for(i=0;i<5;i++)
      cin>>x[i]>>y[i];
    if(pt(x[3],y[3],x[0],y[0],x[1],y[1],x[2],y[2])^
       pt(x[4],y[4],x[0],y[0],x[1],y[1],x[2],y[2]))
      cout<<"OK"<<endl;
    else
      cout<<"NG"<<endl;
  }
  return 0;
}

Measured memory_bytes: 868
import sys
n=int(input())
a=[int(x) for x in input().split()]
a=sorted(a, reverse=True)
m=1
if a[-1] == 0:
  print(0)
else:
  for i in a:
    m*=i
    if m > 10**18:
      print('-1')
      sys.exit()
  print(m)

Measured memory_bytes: 21788
#include<bits/stdc++.h>
using namespace std;
int dp[333][333][333];
bool used[333][333][333];
typedef pair<int,int> P;
typedef pair<P,int> PP;
int MOD=1000000007LL;
signed main(){
  int n,m;
  cin>>n>>m;
  int l[m],r[m],x[m];
  for(int i=0;i<m;i++) cin>>l[i]>>r[i]>>x[i];
  vector<P> T[n+1];
  for(int i=0;i<m;i++) T[r[i]].push_back(P(l[i],x[i]));
  dp[0][0][0]=1;
  queue<PP> q;
  q.push(PP(P(0,0),0));
  used[0][0][0]=1;
  int ans=0;
  while(!q.empty()){
    PP pp=q.front();q.pop();
    int R=pp.first.first,G=pp.first.second,B=pp.second;
    //cout<<R<<" "<<G<<" "<<B<<":"<<dp[R][G][B]<<endl;
    int t=max(max(R,G),B);
    if(t==n){
      (ans+=dp[R][G][B])%=MOD;
      continue;
    }
    bool f1=0,f2=0,f3=0;
    for(int i=0;i<(int)T[t+1].size();i++){
      int c1=(T[t+1][i].first<=G)+(T[t+1][i].first<=B)+1;
      int c2=(T[t+1][i].first<=R)+(T[t+1][i].first<=B)+1;
      int c3=(T[t+1][i].first<=R)+(T[t+1][i].first<=G)+1;
      f1|=(T[t+1][i].second!=c1);
      f2|=(T[t+1][i].second!=c2);
      f3|=(T[t+1][i].second!=c3);
    }
    if(!f1){
      (dp[t+1][G][B]+=dp[R][G][B])%=MOD;
      if(!used[t+1][G][B]) q.push(PP(P(t+1,G),B)),used[t+1][G][B]=1;
    }
    if(!f2){
      (dp[R][t+1][B]+=dp[R][G][B])%=MOD;
      if(!used[R][t+1][B]) q.push(PP(P(R,t+1),B)),used[R][t+1][B]=1;
    }
    if(!f3){
      (dp[R][G][t+1]+=dp[R][G][B])%=MOD;
      if(!used[R][G][t+1]) q.push(PP(P(R,G),t+1)),used[R][G][t+1]=1;
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 169344
//
//  main.cpp
//  CP-C++
//
//  Created by ALOK KUMAR THAKUR on 05/05/20.
//  Copyright © 2020 ALOK KUMAR THAKUR. All rights reserved.
//

#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define tc() ll T;cin>>T;while(T--)
#define pb push_back
#define Max3(a,b,c) max(a,max(b,c))
#define Min3(a,b,c) min(a,min(b,c))

struct cmp {
    bool operator() (const ll& a, const ll& b){
        return a < b;
    }
};

int main() {
    
    //freopen("input.txt", "r", stdin);
    //freopen("output.txt", "w", stdout);
    
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);cout.tie(NULL);
    
    /*-----------------Code Begins Here------------------*/
    
    ll n,k; cin>>n>>k;
    ll h[n+1], dp[n+1];
    for(ll i=1;i<=n;i++) cin>>h[i];
    dp[n] = 0;
    for(ll i=n-1;i>=1;i--){
        dp[i] = INT_MAX;
        for(ll j=i+1;j<=min((i+k),n);j++)
            dp[i] = min(dp[j]+abs(h[i]-h[j]), dp[i]);
    }
    cout<<dp[1]<<'\n';
    
    /*------------------Code Ends Here-------------------*/
    
    return 0;
}


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

int N, K;
int L[50];

int main() {
    cin >> N >> K;
    rep(i, N) cin >> L[i];

    sort(L, L + N);
    reverse(L, L + N);

    int sum = 0;
    rep(i, K) sum += L[i];

    cout << sum << endl;
}

Measured memory_bytes: 256
def main():
    K, N = map(int, input().split())
    A = list(map(int, input().split()))

    # A.append((K-A[-1]+A[0]))
    # print(A)
    diff = []
    for i in range(N-1):
        diff.append(A[i+1]-A[i])
    diff.append(K-A[-1]+A[0])
    # print(diff)
    
    print(sum(diff)-max(diff))
    

main()

Measured memory_bytes: 26060
#include<bits/stdc++.h>
using namespace std;
#include<cstdio>
#define el "\n"
#define sp " "
typedef long long ll;

main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
		ll n,m,x,y;
		cin>>n>>m;
		vector<ll> g[n+1],v(n+1),p(n+1);
		for(ll i=0;i<m;i++)
		{
			cin>>x>>y;
			g[x].push_back(y);
			g[y].push_back(x);
		}
		queue<ll> q;
		q.push(1);
		v[1]=1;
		ll cnt=1;
		while(!q.empty())
		{
			ll u=q.front();
			q.pop();
			for(auto i:g[u])
			{
				if(!v[i])
				{
					v[i]=1;
					q.push(i);
					p[i]=u;
					cnt++;

				}
			}
		}
		if(cnt==n)
		{
			cout<<"Yes"<<el;
			for(ll i=2;i<=n;i++)
				cout<<p[i]<<el;
		}
		else
			cout<<"No";

	
	
	
	
	
	

	
	
	

}

Measured memory_bytes: 13660
#include<iostream>
using namespace std;
int n,m,a,b,ans=1,x[100001];
bool z[100001]={0};
int main()
{
	cin>>n>>m;
	z[1]=true;
	for(int i=1;i<=n;i++)
	{
		x[i]=1;
	}
	for(int i=1;i<=m;i++)
	{
		cin>>a>>b;
		if(z[a])
		{
			if(!z[b])
			{
				ans++;
				z[b]=true;
			}
			if(x[a]==1)
			{
				z[a]=false;
				ans--;
			}
		}
		x[a]--;
		x[b]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 768
import java.util.Scanner;
import java.util.ArrayList;

public class Main {
	public static void main(String args[]){
		Scanner in=new Scanner(System.in);
		ArrayList<Integer> result= new ArrayList<Integer>();
		ArrayList<Integer> s_set=new ArrayList<Integer>();
		int n=in.nextInt();
		int sum=0;
		int ave;
		int mintmp=1001;
		int maxtmp=-1;
		while (n!=0) {
			for (int i=0;i<n;i++) {
				s_set.add(in.nextInt());
				sum+=s_set.get(i);
				if (mintmp > s_set.get(i)) {
					mintmp=s_set.get(i);
				}
				if (maxtmp < s_set.get(i)) {
					maxtmp=s_set.get(i);
				}
			}
			sum-=maxtmp+mintmp;
			ave=sum/(n-2);
			result.add(ave);

			n=in.nextInt();
			mintmp=1001;
			maxtmp=-1;
			sum=0;
			s_set.clear();
		}

		for (int i=0;i<result.size();i++) {
			System.out.printf("%d%n",result.get(i));
		}
	}
}

Measured memory_bytes: 30328
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
#define REP(i, n) for(int i = 0; i < (int)(n); ++i)
using namespace std;

typedef long long ll;

ll vs[60];
ll cs[60];

ll memo[55][55][105];
int N, K;

ll solve(int bg, int ed, int rest) {
  ll& res = memo[bg][ed][rest];
  if(res < 0) {
    if(rest == 0) {
      res = max(0LL, cs[N] - (cs[ed] - cs[bg]));
    } else {
      res = 0;
      { // 残り不用処理
        vector<ll> ts;
        REP(i, N) {
          if(bg <= i && i < ed) {
            // nothing
          } else {
            ts.push_back(vs[i]);
          }
        }
        sort(ts.begin(), ts.end());
        int tmpRest = rest;
        ll tmp = 0;
        REP(i, ts.size()) {
          if(ts[i] < 0 && tmpRest > 0) {
            --tmpRest;
          } else {
            tmp += ts[i];
          }
        }
        res = max(res, tmp);
      }
      if(bg < ed) {
        res = max(res, solve(bg+1, ed, rest-1));
        res = max(res, solve(bg, ed-1, rest-1));
      }
    }
  }
  return res;
}

int main(void) {
  cin >> N >> K;
  REP(i, N) {
    cin >> vs[i];
    cs[i+1] = cs[i] + vs[i];
  }
  memset(memo, -1, sizeof memo);
  ll res = solve(0, N, K);
  cout << res << endl;
  
  return 0;
}


Measured memory_bytes: 2688
#include<iostream>
int main(void){
    int astart,aend,bstart,bend,aon,bon,count,ba,bb;
    std::cin>>astart>>aend>>bstart>>bend;
    aon=0;
    bon=0;
    ba=0;
    bb=0;
    count=0;
    for(int i=0;i<=100;i++){
        if(astart<=i&&i<=aend){
            aon=1;
        }else{
            aon=0;
        }
        if(bstart<=i&&i<=bend){
            bon=1;
        }else{
            bon=0;
        }
        if(aon==1&&bon==1&&ba==1&&bb==1){
            count++;
        }
        ba=aon;
        bb=bon;
    }
    std::cout<<count<<std::endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<set>
#include<map>
#include<iterator>
#include<stack>
#include<queue>
#include<utility>
#include<functional>
#include<bitset>
#include<numeric>
#include<cstring>
#include<tuple>
using namespace std;

string s1, s2;
vector< char > ans;
int dp[ 3005 ][ 3005 ];

int solve( int i, int j )
{
	if( i == -1 || j == -1 )
	{
		return 0;
	}
	if( dp[ i ][ j ] != -1 )
	{
		return dp[ i ][ j ];
	}
	if( s1[ i ] == s2[ j ] )
	{
		dp[ i ][ j ] = 1 + solve( i - 1, j - 1 );
	}
	else
	{
		dp[ i ][ j ] = max( solve( i - 1, j ), solve( i, j - 1 ) );
	}
	return dp[ i ][ j ];
}

void print( int i, int j )
{
	if( i == -1 || j == -1 )
	{	
		cout << string( ans.rbegin(), ans.rend() ) << "\n";
		exit( 0 );
	}
	if( s1[ i ] == s2[ j ] )
	{
		ans.push_back( s1[ i ] );
		print( i - 1, j - 1 );
		ans.pop_back();
	}
	else
	{
		if( dp[ i ][ j ] == solve( i - 1, j ) )
		{
			print( i - 1, j );
		}
		if( dp[ i ][ j ] == solve( i, j - 1 ) )
		{
			print( i, j - 1 );
		}
	}
}

int main( void )
{
	ios :: sync_with_stdio( 0 );
	cin.tie( 0 );
	
	memset( dp, -1, sizeof( dp ) );
	cin >> s1 >> s2;
	solve( s1.length() - 1, s2.length() - 1 );
	print( s1.length() - 1, s2.length() - 1 );
	return 0;
}

Measured memory_bytes: 35968
import Data.List

xs :: [String]
xs = ["2", "3", "4", "5", "6", "7", "8", "9", "10", "11", "12", "13", "1"]

main :: IO ()
main = do
    [ia, ib] <- map (flip elemIndex xs) <$> words <$> getLine
    putStrLn $ if ia > ib
                  then "Alice"
                  else if ia < ib
                          then "Bob"
                          else "Draw"



Measured memory_bytes: 380
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
using namespace std;

int main()
{
  int x,y,z;
  cin >> x >> y >> z;
  int ans = 1;
  ans += (x-y-2*z)/(y+z);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 384
n,k = map(int,input().split())
mod = 10**9+7
fac = [1]*2001
inv = [1]*2001
finv = [1]*2001
for i in range(2,2001):
  fac[i] = (fac[i-1]*i)%mod
  inv[i]= mod-(inv[mod%i]*(mod//i))%mod
  finv[i] = finv[i-1]*inv[i]
  
def c(x,y):
  return (fac[x]*finv[y]*finv[x-y])%mod
  
for i in range(k):
  a = c(k-1,i)
  b = c(n-k+1,i+1) if n-k+1 >=i+1 else 0
  print((a*b)%mod)
  
  
  

Measured memory_bytes: 10996
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define rfor(i, a, b) for(int i = a; i < (int)b; i++)
#define all(ary) (ary).begin(), (ary).end()
#define debug(x) cerr << #x << ": " << x << '\n'
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
using namespace std;
using v = vector<int>;
using ll = long long;
template <class T = int> T in(){ T x; cin >> x; return (x);}

int main(int argc, char *argv[]){
    int n ; cin >> n;
    cout << n * (n + 1) / 2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <numeric>
#include <iostream>
#include <array>
#include <string>
#include <vector>
#include <cassert>
#include <algorithm>
#include <math.h> 
#include <set>
#include <map>
#include <utility>
#include <deque>
#include <queue>


using namespace std;

#define ll long long int
#define rep(i, n) for(ll i = 0; i < n; i++)
#define repp(i, n) for(int i = 1; i <= n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define riverse(v) reverse((v).begin(), (v).end())
#define pb push_back
#define mp make_pair
#define all(a)  (a).begin(),(a).end()
using vi = vector<int>;
using vs = vector<string>;
using vll = vector<ll>;
using vvi = vector<vi>;
using vvvi = vector<vi>;
const ll MOD = 1e9 + 7;
vi alphabet = { 'a','b','c','d','e','f','g','h','i','j','k','l','m',
               'n','o','p','q','r','s','t','u','v','w','x','y','z' };




int main() {
    int N;
    cin >> N;
    vi C(N - 1);
    vi S(N - 1);
    vi F(N - 1);
    rep(i, N - 1) {
        cin >> C[i];
        cin >> S[i];
        cin >> F[i];
    }
    for (int i = 0; i < N; i++){
        int t = 0;
        for (int j = i; j < N - 1; j++)
        {
            if (t < S[j]) t = S[j];
            else if (t % F[j] == 0);
            else t = t + F[j] - t % F[j];
            t += C[j];
        }
        cout << t << endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>

void print(long long n) {
    char temp;
    if (n != 0) {
        temp = n % 26;
        if (temp == 0) {
            temp = 26;
        }
        n = (n - temp) / 26;
        temp += 96;
        print(n);
        printf("%c", temp);
    }
}

int main() {
    long long n;
    std::cin >> n;
    print(n);
    std::cout << std::endl;
    return 0;
}


Measured memory_bytes: 3636
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
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; }

ll cnt[10][10];

int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	for(int i = 1; i <= n; ++i){
		int head, tail = i%10, num = i;
		while(num/10 > 0){
			num /= 10;
		}
		head = num;
		cnt[head][tail]++;
	}
	ll ans = 0;
	for(int i = 0; i < 10; ++i){
		for(int j = 0; j < 10; ++j){
			ans += cnt[i][j] * cnt[j][i];
		}
	}
	cout << ans << endl;
	return 0;
}

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

int main() {
  int K,N;
  cin >> K >> N;
  vector<int> pl(N);
  for(int i=0;i<N;i++)
    cin >> pl.at(i) ;
  vector<int> d(N);
  d.at(0) = pl.at(N-1) - pl.at(0);
  for(int i=1;i<N;i++)
    d.at(i) = K - pl.at(i) + pl.at(i-1);
  sort( d.begin(),d.end() );
  cout << d.at(0) << endl;
  
}


Measured memory_bytes: 4848
#include <cassert>
#include <iostream>
#include <vector>
#include <stack>
#include <unordered_set>
#include <numeric>
#include <iterator>
#include <unordered_map>
#include <array>
#include <map>
#include <cstring>
#include <iomanip>
#include <string>
#include <algorithm>
#include <cmath>
#include <ctgmath>
#include <set>
#include <queue>
#include <fstream>
#include <ostream>
#include <random>
#include <chrono>
using namespace std;
#define int long long

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

	int r, d, x;
	cin >> r >> d >> x;

	for (int i = 0; i < 10; i++)
	{
		x = r * x - d;
		cout << x << "\n";
	}
}


Measured memory_bytes: 256
import fractions

def lcm(x, y):
    return (x * y) // fractions.gcd(x, y)

a,b,c,d = map(int, input().split())

x = (b//c - (a-1)//c) + (b//d - (a-1)//d -(b//lcm(c,d)) + (a-1)//lcm(c,d))
print(b-a+1-x)


Measured memory_bytes: 5432
#include <algorithm>
#include <iostream>

using namespace std;

const int N = 200000;

int aa[N];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)
		cin >> aa[i];
	int x = 0;
	for (int i = 0; i < n; i++)
		x ^= aa[i];
	for (int i = 0; i < n; i++)
		cout << (x ^ aa[i]) << ' ';
	cout << '\n';
	return 0;
}


Measured memory_bytes: 4292
#include <iostream>
#include <cstdio>
#include <string>
#include <vector>
#include <algorithm>
#include <list>
#include<iomanip>

using namespace std;


int main() {
	int a, b, c;

	cin >> a >> b >> c;

	if (c >= a && c <= b) {
		cout << "Yes";
	} else{
		cout << "No";
	}

	cout << endl;

	return 0;

}

Measured memory_bytes: 256
import math
from functools import reduce
def gcd(*numbers):
    return reduce(math.gcd, numbers)
s=0
K=int(input())
for i in range(1,K+1):
    for j in range(1,K+1):
        for k in range(1,K+1):
            s=s+gcd(i,j,k)
print(s)

Measured memory_bytes: 69544
#include<iostream>
#include<iomanip>
#include<algorithm>
#include<cstdio>
#include<cmath>
#include<map>
#include<numeric>
#include<set>
#include<string>
#include<utility>
#include<vector>

#define rep(i, a, n)  for(int i=a; i<n; i++)
#define per(i, a, n)  for(int i=n-1; i>=a; i--)
#define fill0(n)  setfill('0') << right << setw(n)
#define all(x)  (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define MAX 1000000000
using namespace std;
typedef long long ll;

int ans = 0;
int n, m;
vector<bool> visited(50, false);
vector<vector<bool>> vtx(50, vector<bool>(50, false));
vector<pair<int, int>>  brdg;

void move(int pos){
  visited[pos] = true;
  rep(i, 0, n){
    if(vtx[pos][i] and !visited[i]){
      move(i);
    }
  }
}

int main(){
  int nedge = 0;
  vector<int> edge(2);
  cin >> n >> m;
  rep(i, 0, m){
    int a, b; cin >> a >> b;
    a--;  b--;
    vtx[a][b] = true;
    vtx[b][a] = true;
    brdg.push_back(make_pair(a, b));
  }

  rep(i, 0, m){
    vtx[brdg[i].first][brdg[i].second] = false;
    vtx[brdg[i].second][brdg[i].first] = false;

    rep(j, 0, n)  visited[j] = false;
    move(0);
    bool bridge = false;
    rep(j, 0, n)  if(!visited[j]) bridge = true;
    if(bridge)  ans++;

    vtx[brdg[i].first][brdg[i].second] = true;
    vtx[brdg[i].second][brdg[i].first] = true;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <queue>
#include <algorithm>
#include <cmath>
#include <vector>
#include <stack> 
#include <set>
using namespace std;

const int MAX=500;
const int INF=0x3f3f3f3f;
int level[MAX];  //记录节点层次 
struct dinic{
	long long c;  //容量 
	long long f;  //流量 
}edge[MAX][MAX];
vector<int> E[MAX];

void addedge(int u,int v,long long c){
	E[u].push_back(v);
	E[v].push_back(u);
	edge[u][v].c=c;
}

bool dinic_bfs(int S,int T){    //构造层次网络 
	int i;
	int u,v;  //起、终点 
	queue<int> Q;
	
	memset(level,0,sizeof(level));
	Q.push(S);
	level[S]=1;
	while(!Q.empty()){
		u=Q.front();
		Q.pop();
		for(i=0;i<E[u].size();i++){
			v=E[u][i];
			if(!level[v]&&edge[u][v].c>edge[u][v].f){  //有残余流量 
				level[v]=level[u]+1;
				Q.push(v);
			}
		}
	}
	return level[T]!=0;
}

long long dinic_dfs(int u,int T,long long cpa){  //沿增广路增广 
	long long tmp=cpa,t;
	int i,v;
	
	if(u==T)
	    return cpa;
	for(i=0;i<E[u].size()&&tmp;i++){
		v=E[u][i];
		if(level[u]+1==level[v]){
			if(edge[u][v].c>edge[u][v].f){
				t=dinic_dfs(v,T,min(tmp,(long long)(edge[u][v].c-edge[u][v].f))); 
				edge[u][v].f+=t;
				edge[v][u].f-=t;
				tmp-=t;
			}
		}
	}
	return cpa-tmp;
} 

long long dinic(int S,int T){
	long long maxflow=0,flow=0;
	
	while(dinic_bfs(S,T)){   //汇点不在网络中则结束 
		while(flow=dinic_dfs(S,T,INF))  //多路增广 
		    maxflow+=flow;
	}
	return maxflow;
}

int n;
long long a,tot;

int main(){
	int i,j;
	int s=0,t=200;
	
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%lld",&a);
		for(j=2;j*i<=n;j++)
		    addedge(i,i*j,INF);
		if(a<=0) addedge(s,i,-a);
		else addedge(i,t,a),tot+=a;
	}
	long long mf=dinic(s,t);
	printf("%lld\n",tot-mf);
	
	return 0;
}

Measured memory_bytes: 896
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

/*Atcoder用
 * 		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] tmp = br.readLine().split(" ");
		int a = Integer.parseInt(tmp[0]);
		int b = Integer.parseInt(tmp[1]);
		int c = Integer.parseInt(tmp[2]);


		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String get = br.readLine();
		char[] s = get.toCharArray();
		for(char c:s)System.out.println(c);

		List<Integer> ls = new ArrayList<Integer>();
		String[] tmp = br.readLine().split(" ");
		for (int n = 0; n < N; n++) {
			ls.add(Integer.parseInt(tmp[n]));
		}
 */

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s = br.readLine();

		int sum = 0;
		for(int i = 0;i<4;i++){
			char c = s.charAt(i);
			if(c == '+')sum++;
			else sum--;
		}
		System.out.println(sum);



	}
}

Measured memory_bytes: 21204
#pragma GCC optimize("O3")
#include <bits/stdc++.h>
#define ll long long
#define rep2(i,a,b) for(ll i=a;i<=b;++i)
#define rep(i,n) for(ll i=0;i<n;i++)
#define rep3(i,a,b) for(ll i=a;i>=b;i--)
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pq priority_queue
#define pb push_back
#define eb emplace_back
#define vec vector<int>
#define vecll vector<ll>
#define vecpii vector<pii>
#define vec2(a,b) vector<vec>(a,vec(b))
#define vec2ll(a,b) vector<vecll>(a,vecll(b))
#define vec3(a,b,c) vector<vector<vec>>(a,vec2(b,c))
#define vec3ll(a,b,c) vector<vector<vecll>>(a,vec2ll(b,c))
#define fi first
#define se second
#define endl "\n"
#define all(c) begin(c),end(c)
#define ios ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
#define lb(c,x) distance(c.begin(),lower_bound(all(c),x))
#define ub(c,x) distance(c.begin(),upper_bound(all(c),x))
#define MM " "
#define INF 100000000
using namespace std;
int in() {int x;cin>>x;return x;}
ll lin() {ll x;cin>>x;return x;}
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;}
template<class T> inline void print(pair<T,T> p){cout<<"("<<p.first<<","<<p.second<<") ";}
template<class T> inline void print(vector<pair<T,T>> v){for(auto e:v)print(e); cout<<endl;}
template<class T> inline void print(T v){for(auto e:v)cout<<e<<" ";cout<<endl;}


    
void go();

main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);cout<<fixed<<setprecision(15);
    int tc=1;
    // tc=in();
    while(tc--){
        go();
    }
    return 0;
}

void go(){
    int n=in();
    ll a=lin(),b=lin();
    auto dp = vec2ll(n+2,n+10);
    rep(i,n+1)rep(j,n+2)dp[i][j]=1e16;
    vec p;rep(i,n)p.pb(in());
    rep(j,n+2)dp[0][j]=0;
    rep(i,n){
        rep(j,n+2){
            if( j < p[i]){
                chmin(dp[i+1][j],dp[i][j] + a);
                chmin(dp[i+1][p[i]],dp[i][j]);
            }
            else if(j > p[i]){
                chmin(dp[i+1][j],dp[i][j]+b);
            }
        }
    }
    ll mi=1e16;
    rep(i,n+1)chmin(mi,dp[n][i]);
    cout<<mi<<endl;
}
    



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

int main()
{
    int N;
    cin >> N;
    vector<int> ans(N);
    rep(i, 0, N - 1)
    {
        int x;
        cin >> x;
        ans[x - 1] += 1;
    }
    rep(i, 0, N)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 4040
# input
N, M = map(int, input().split())

c = []

c_append = c.append

for i in range(M):
    sm, cm = map(int, input().split())
    c_append((sm, cm))

ans = -1

# check
for i in range(1000):
    str_i = str(i)

    if N < len(str_i):
        break

    if N == len(str_i) and False not in [int(str_i[sm - 1]) == cm for sm, cm in c]:
        ans = i
        break

print(ans)

Measured memory_bytes: 3064
h,w = map(int,input().split())
ans = float("Inf")
if h % 3 == 0 or w % 3 == 0:
    print(0)
    exit()
for i in range(1,h):
    a = (h-i)*(w//2)
    b = (h-i)*-(-w//2)
    c = ((h-i)//2) * w
    d = -(-(h-i)//2) * w
    ans = min(ans,max(i*w,a,b)-min(i*w,a,b))
    ans = min(ans,max(i*w,c,d)-min(i*w,c,d))
for i in range(1,w):
    a = (w-i)*(h//2)
    b = (w-i)*(h-(h//2))
    c = ((w-i)//2) * h
    d = -(-(w-i)//2) * h
    ans = min(ans,max(i*h,a,b)-min(i*h,a,b))
    ans = min(ans,max(i*h,c,d)-min(i*h,c,d))
print(ans)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <math.h>
#include <algorithm>
#include <map>
#include <set>
#include <vector>
using namespace std;
typedef long long  ll;
#define rep(i,s,n)for(ll i=s;i<n;i++)
#define repe(i,s,n)for(ll i=s;i<=n;i++)

static const double PI = 3.14159265358979;
static const ll MOD = 1e9 + 7;
static const ll INF = (ll)1 << 62;

static const int bn = 32;

ll n, m;
ll c[9][9] = {};
bool v[9] = {};

ll total = 0;
bool allvisited() {
	repe(i, 1, n) {
		if (!v[i]) {
			return false;
		}
	}
	return true;
}
void dfs(int k) {
	if (allvisited()) {
		total++;
		return;
	}

	repe(i, 1, n) {
		if (k != i && c[k][i] && !v[i]) {
			v[i] = true;
			dfs(i);
			v[i] = false;
		}
	}
}

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

	rep(i, 0, m) {
		ll a, b; cin >> a >> b;
		c[a][b] = 1;
		c[b][a] = 1;
	}

	v[1] = true;
	dfs(1);

	cout << total << endl;
	return 0;
}

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

using namespace std;

#define mp make_pair
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define allarr(a) a , a + n
#define ll long long
#define ull unsigned long long 
#define pb push_back
#define fastio ios_base::sync_with_stdio(false) ; cin.tie(NULL); cout.tie(NULL)
typedef pair<int, int> pi;
typedef pair<ll,ll> pll; 
typedef pair<int,pi> trp ;
typedef vector<pi> vpi;
typedef vector<pll> vpll ;
// int ab  (int  x ) { return (x>0?x:-x); }

int main(){
	int n ; 
	cin >> n ; 
	vector<int> a(n); 
	for(int i = 0 ; i < n ; i++ )cin >>a[i] ; 
	for(int i = 0 ; i < n ; i++ ){
		for(int  j =i ; j < n ; j++ ){
			swap(a[i],a[j]); 
			if( is_sorted(all(a)) ){
				cout <<"YES"<<endl; 
				return 0 ; 
			}
			swap(a[i],a[j]); 
		}
	}
	cout <<"NO"<<endl; 
	return 0 ;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <map>
#include <algorithm>
#include <vector>
#include <queue>

#define INF 1 << 29
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define FOR(i,k,n) for(int i=(k);i<(int)(n);i++)

using namespace std;

typedef pair<int,int> s;
typedef long long int ll;

int abs(int x){
  return x > 0 ? x : -x;
}

int length(char c[]){
  int cnt=0;
  for(cnt=0;c[cnt]!='\0';cnt++){
  }
  return cnt;
}

int main(){
  int n,a,b,sum=0;
  scanf("%d %d %d",&n,&a,&b);
  REP(i,n+1){
    int tmp = i;
    int digit = 0;
    while(tmp>0){
      digit += tmp%10;
      tmp/=10;
    }
    if(digit>=a&&digit<=b){
      sum+=i;
    }
  }
  printf("%d\n",sum);
  return 0;
}


Measured memory_bytes: 128
import numpy as np

H,W = map(int,input().split())
temp = np.array([list(input()) for _ in range(H)])
# 周りに壁を、0,1化
map = np.zeros((H+2,W+2),dtype=np.int32)
map[1:-1,1:-1][temp == '.'] = 1

# x軸正方向の集計
def F():
  x = map.copy()
  for row in range(1,H+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x

# y軸
def G():
  x = map.T.copy()
  for row in range(1,W+1):
    zero_idx = np.nonzero(x[row]==0)[0]
    x[row, zero_idx[1:]] = 1-np.diff(zero_idx) # cumsumで求められるように変形
  x = x.cumsum(axis = 1)
  return x.T

answer = np.zeros_like(map)
# x軸
answer += F()
# 逆順
map = map[:,::-1]
answer += F()[:,::-1]
map = map[:,::-1]

# y軸
answer += G()
# 逆順
map = map[::-1,:]
answer += G()[::-1,:]

answer = np.max(answer) - 3
print(answer)

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

int compare_int(const void *a, const void *b)
{
    return *(int*)a - *(int*)b;
}

int main(void)
{
    int N, i, j, k, c=0;
    scanf("%d", &N);
    long int L[N];
    for(i=0; i<N;i++) {
        scanf("%ld", &L[i]);
    }
    qsort(L, N, sizeof(long int), compare_int);

    for(i=0; i<N-2; i++) {
        for(j=i+1; j<N-1; j++) {
            for(k=j+1; k<N; k++) {
                if( (L[i]!=L[j] && L[j]!=L[k] && L[k]!=L[i]) && (L[k] < (L[i]+L[j])) ) {
                    c++;
                }
            }
        }
    }
    printf("%d\n", c);

    return 0;
}

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

#define rep(i, j) for (int i = 0; i < j; i++)
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;
typedef vector<pii> vpii;

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

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

    vi h(n);
    rep(i, n) cin >> h[i];

    int ans = 0;
    rep(i, n) if (h[i] >= k) ans++;

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


Measured memory_bytes: 640
#
# Written by NoKnowledgeGG @YlePhan
# ('ω')
#
#import math
#mod = 10**9+7
#import itertools
#import fractions
#import numpy as np
#mod = 10**4 + 7
"""def kiri(n,m):
  r_ = n / m
  if (r_ - (n // m)) > 0:
    return (n//m) + 1
  else:
    return (n//m)"""

""" n! mod m 階乗
mod = 1e9 + 7
N = 10000000
fac = [0] * N
def ini():
  fac[0] = 1 % mod
  for i in range(1,N):
    fac[i] = fac[i-1] * i % mod"""

"""mod = 1e9+7
N = 10000000
pw = [0] * N
def ini(c):
  pw[0] = 1 % mod
  for i in range(1,N):
    pw[i] = pw[i-1] * c % mod"""

"""
def YEILD():
  yield 'one'
  yield 'two'
  yield 'three'
generator = YEILD()
print(next(generator))
print(next(generator))
print(next(generator))
"""
"""def gcd_(a,b):
  if b == 0:#結局はc,0の最大公約数はcなのに
    return a
  return gcd_(a,a % b) # a = p * b + q"""
"""def extgcd(a,b,x,y):
  d = a
  if b!=0:
    d = extgcd(b,a%b,y,x)
    y -= (a//b) * x
    print(x,y)
  else:
    x = 1
    y = 0
  return d"""
# 最大公約数 と 最小公倍数
"""def gcd(a,b):
  if b == 0:
    return a
  return gcd(b, a % b)
def lcm(a,b):
  g = gcd(a,b)
  return (a * b) // g"""

def readInts():
  return list(map(int,input().split()))
mod = 10**9 + 7

def main():
  import bisect # 二分探索
  n = int(input())
  A = sorted(map(int,input().split()))
  B = map(int,input().split())
  C = sorted(map(int,input().split()))
  print(sum(bisect.bisect_left(A,b) * (n-bisect.bisect_right(C,b)) for b in B))
if __name__ == '__main__':
  main()

Measured memory_bytes: 25920