akhauriyash/Code-Regression huggingface dataset:
#include<stdio.h>
#include<string.h>
int main(){
  char s[100001], ans[50001];
  int l;
  scanf("%s", s);
  l = strlen(s);
  for(int i = 0; i < l; i += 2){
    ans[i / 2] = s[i];
  }
  printf("%s\n", ans);
  return 0;
}


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

using namespace std;

#define INF 1000000000
#define INFLL 0x3f3f3f3f3f3f3f3fLL 
#define EPS 10e-9
#define MOD 1000000007
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define st first
#define nd second
#define sz(v) int(v.size())
#define all(X) (X).begin(), (X).end()
#define FOR(I, A, B) for(int I = A; I < B; I++)
#define RFOR(I, A, B) for(int I = A; I >= B; I--)

typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,ii> iii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ii> vii;
typedef vector<vii> vvii;
typedef vector<iii> viii;
typedef vector<ll> vll;

vvi adjList;
vi val;
vi sol;
vi PD;

void dfs(int i, int p = -1){
	int l = 0, r = sz(PD)-1;
	while(l < r){
		int mid = (l+r)/2;
		if(PD[mid] >= val[i]){
			r = mid;
		} else {
			l = mid+1;
		}
	}

	int ant = PD[l], antind = l;
	PD[l] = val[i];

	for(int v : adjList[i]){
		if(v != p){
			dfs(v, i);
		}
	}

	l = 0, r = sz(PD)-1;
	while(l < r){
		int mid = (l+r)/2 + 1;
		if(PD[mid] >= INF){
			r = mid-1;
		} else {
			l = mid;
		}
	}

	sol[i] = l+1;

	PD[antind] = ant;
}

int main(){
	int n;
	scanf("%d", &n);
	val.resize(n+1);
	for(int i = 1; i <= n; i++){
		scanf("%d", &val[i]);
	}
	adjList.resize(n+1);
	FOR(i,1,n){
		int u, v;
		scanf("%d %d", &u, &v);
		adjList[v].pb(u);
		adjList[u].pb(v);
	}
	PD.assign(n+1, INF);
	sol.resize(n+1, 0);
	dfs(1);
	for(int i = 1; i <= n; i++){
		printf("%d\n", sol[i]);
	}
	return 0;
}



Measured memory_bytes: 31016
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Stack;

public class Main {
	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String s, ans, yes = "yes", no = "no";
		while (true) {
			s = br.readLine();
			if (s.equals(".")) {
				return;
			}
			Stack<Character> st = new Stack<Character>();
			boolean fin = false;
			ans = yes;
			for (int i = 0; i < s.length(); ++i) {
				char c = s.charAt(i);
				if (c == '(' || c == '[') {
					st.push(c);
					continue;
				}
				if (st.empty()) {
					if (c == ')' || c == ']') {
						ans = no;
						fin = true;
					}
				} else {
					char t = st.peek();
					if (t == '(') {
						if (c == ')') {
							st.pop();
							continue;
						} else if (c == ']') {
							ans = no;
							fin = true;
						}
					} else if (t == '[') {
						if (c == ']') {
							st.pop();
							continue;
						} else if (c == ')') {
							ans = no;
							fin = true;
						}
					}
				}
				if (fin) {
					break;
				}
			}
			if (!st.isEmpty()) {
				ans = no;
			}
			System.out.println(ans);
		}
	}
}

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

int main(){
    int N,A,B;
    cin >> N >> A >> B;
    string S;
    cin >> S;
    vector<int> vec(N);
    int total = 0;
    int abroad = 0;
    for(int i=0;i<N;i++){
        char s = S[i];
        if(s=='a'){
            if(total<A+B){vec[i] = 1; total+=1;}
            else{vec[i]=0;}
        }else if (s == 'b'){
            if(total<A+B && abroad<B){vec[i] = 1; total+=1; abroad+=1;}
            else{vec[i] = 0;}
        }else{vec[i] = 0;}
    }
    for(bool b:vec){
        if(b) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
const int INF = 1e9;
const int MOD = 1e9+7;
#define LL long long
const LL LINF = 1e18;
using namespace std;
#define COUT(v) cout<<(v)<<endl
#define CIN(n)  int(n);cin >> (n)
#define YES(n) cout<<((n)? "YES" : "NO")<<endl
#define Yes(n) cout<<((n)? "Yes" : "No")<<endl
#define POSSIBLE(n) cout << ((n) ? "POSSIBLE" : "IMPOSSIBLE"  ) << endl
#define Possible(n) cout << ((n) ? "Possible" : "Impossible"  ) <<endl

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n) for(int i=0;i<(n);++i)
#define REPR(i,n) for(int i=n;i>=0;i--)

#define FOREACH(x,a) for(auto& (x) : (a) )

#define ALL(obj) (obj).begin(),(obj).end()

#define P pair<int,int>
#define I vector<int>
#define S set<int>
#define pb(v) push_back(v)
#define V vector
#define rt return
int main(){
   int ans = 0;
   CIN(N);
   V<P> vec1,vec2;
   int flag1[1000]={0};
   int flag2[1000]={0};
   REP(a,N){
       CIN(b);CIN(c);
       vec1.pb(make_pair(b,c));
   }
   REP(a,N){
       CIN(b);CIN(c);
       vec2.pb(make_pair(b,c));
   }
   sort(ALL(vec1));
   sort(ALL(vec2));
   P p;
   REP(a,N){
       P p1 = vec2.at(a);
       p.first=0;
       p.second = 10000;
       REP(b,N){
           P p2 = vec1.at(b);
           if(p1.first<=p2.first)break;
           if(flag2[b]==0){
               if(p1.second>p2.second&&p.first<=p2.second){
                   p.first=p2.second;
                   p.second=b;
               }
           }
       }
       if(p.second!=10000){
           flag2[p.second]=1;
           ans++;
       }
   }
   COUT(ans);
   return 0;
}


Measured memory_bytes: 256
N,D=map(int,input().split())
X=[list(map(int,input().split())) for j in range(N)]
count=0

for i in range(N):
    for j in range(i+1,N):
        temp=0
        for k in range(D):
            temp+=(X[i][k]-X[j][k])**2
        temp=(temp)**(1/2)
        if temp ==temp//1:
            count+=1

print(count)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n,m;
  cin>>n>>m;
  /*vector<long long> a(n);
  for(int i=0; i<n; i++)cin>>a[i];
  for(int i=0; i<m; i++){
    a.at(n-1) /= 2;
  }
  long long ans = 0;
  for(int i=0; i<n; i++)ans+=a[i];
  //*/
  priority_queue<int> a;
  int b;
  for(int i=0; i<n; i++){
    cin>>b;
    a.push(b);
  }
  int x;
  for(int i=0; i<m; i++){
    x = a.top();
    a.pop();
    a.push(x/2);
  }

  long long ans = 0;
  for(int i=0; i<n; i++){
    x = a.top();
    a.pop();
    ans += x;
  }

  cout<<ans<<endl;
}

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

struct Node{
    int key;
    Node *right, *left, *parent;
};

Node *root, *NIL;

void insert(int k){
    Node *y = NIL;
    Node *x = root;
    Node *z;
    
    z = (Node *)malloc(sizeof(Node));
    z->key = k;
    z->left = NIL;
    z->right = NIL;
    
    while (x != NIL) {
        y = x;
        if(z->key < x->key){
            x = x->left;
        }else{
            x = x->right;
        }
    }
    
    z->parent = y;
    if(y==NIL){
        root = z;
    }else{
        if(z->key < y->key){
            y->left=z;
        }else {
            y->right = z;
        }
    }
}

void inorder(Node *u){
    if(u==NIL) return;
    inorder(u->left);
    cout << " " << u->key;
    inorder(u->right);
}

void preorder(Node *u){
    if(u==NIL) return;
    cout << " " << u->key;
    preorder(u->left);
    preorder(u->right);
}

int main(){
    int n,x;
    string com;
    cin >> n;
    
    for(int i=0; i<n; i++){
        cin >> com;
        if(com=="insert"){
            cin >> x;
            insert(x);
        }else if(com=="print"){
            inorder(root);
            cout << endl;
            preorder(root);
            cout << endl;
        }
    }
    
    return 0;
}

Measured memory_bytes: 26456
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<map>
#include<set>
#include<cstdio>
#include<cmath>
#include<deque>
#include<numeric>
#include<queue>
#include<stack>
#include<cstring>
#include<limits>
#include<functional>
#include<unordered_set>
#include<iomanip>
#include<cassert>
#include<regex>
#include<bitset>
#include<complex>
#include<chrono>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
	ll tmp;
	while (m!=0) {
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m) {
	return abs(n * m) / gcd(n, m);//gl=xy
}
 
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
 
using namespace std;

//ここから
vector<ll>a;
ll n,m;

bool C(ll mid){
  ll sum=0;
  rep(i,n){
    sum+=a.end()-lower_bound(all(a),mid-a[i]);
  }
  return sum>=m;
}

void solve(){
  cin>>n>>m;
  a.resize(n);
  rep(i,n)cin>>a[i];
  sort(a.begin(),a.end());
  ll l=0,r=2e5+1;
  while(r-l>1){
    ll mid=(l+r)/2;
    if(C(mid))l=mid;
    else r=mid;
  }
  ll ans=0;
  vector<ll>sum(n+1);
  rep(i,n)sum[i+1]=sum[i]+a[i];
  ll cnt=0;
  rep(i,n){
    ll x=l-a[i];
    int pos=lower_bound(all(a),x)-a.begin();
    ans+=sum[n]-sum[pos];
    ans+=(n-pos)*a[i];
    cnt+=(n-pos);
  }
  //cerr<<cnt<<endl;
  cout<<ans-(cnt-m)*l;
}

int main(){
	ios::sync_with_stdio(false);
  cin.tie(0);
	cout<<fixed<<setprecision(15);
  solve();
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
//3人1チームで、2番目に強い人の強さがチームの強さ
//3N人をNチームに分け、強さの和のmaxを求める
//aをでかい順に並べ、一個おきに足していく　N回
int main(){
  int N;
  cin >> N;
  vector<int> a(3*N);
  rep(i,3*N){
    cin >> a[i];
  }
  long long ans = 0;
  sort(a.begin(),a.end());
  reverse(a.begin(),a.end());
  

  for(int i=1;i<2*N;i += 2){
    ans += a[i];
  }
  cout << ans << endl;
  
}

Measured memory_bytes: 1408
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <stack>
#include <cassert>
#include <functional>
#include <random>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vvl> vvvl;
typedef vector<vvvl> vvvvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<vvb> vvvb;
typedef vector<vvvb> vvvvb;
typedef vector<string> vs;
typedef vector<vs> vvs;
typedef vector<vvs> vvvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<vvd> vvvd;
typedef long double LD;
typedef vector<LD> vld;
typedef vector<pair<LD, LD>> vpld;
typedef pair<ll, ll> PL;
typedef vector<PL> vpl;
typedef vector<vector<PL>> vvpl;
typedef vector<vvpl> vvvpl;
typedef pair<ll, PL> TL;
typedef vector<TL> vtl;
typedef vector<vtl> vvtl;
typedef long double ld;
typedef vector<ld> vld;
const ll LINF = 1e17;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define RFOR(i, a, b) for(ll i = (a); i > b; i--)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n-1; i > -1; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back
#define epb emplace_back
#define ALL(X) (X).begin(),(X).end()

template <typename T> T gcd(T a, T b) {return (a == 0) ? b : gcd(b%a, a);}
template <typename T> T lcm(T a, T b) { return a / gcd(a, b) * b;}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
template <typename T>
vector<T> uniquen(vector<T> vec /* copy */){
    sort(ALL(vec)); vec.erase(unique(vec.begin(), vec.end()), vec.end()); return vec;
}

inline ll popcnt(ll x){return __builtin_popcountll((unsigned long long)x);};
template<class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
//friend bool operator<(const tpl& lhs, const tpl& rhs){
//    return std::tie(lhs.l, lhs.r) < std::tie(rhs.l, rhs.r);
//}

bool bit(ll st, ll b){return ((st>>b)&1) == 1;}


int main(){
#ifdef __DEBUG_LOCAL__
    ifstream file("../../../../../in.txt"); if(file.is_open()) cin.rdbuf(file.rdbuf());
#endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    
    ll N; cin >> N;
    cout << (N + 2 -1) /2 << endstr;
    
    return 0;
}


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

using namespace std;

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

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

    vector<vector<int>> dp0(n + 1, vector<int>(t, 0));
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            dp0[i + 1][j] = max(dp0[i + 1][j], dp0[i][j]);
            if (j + a[i] < t) {
                dp0[i + 1][j + a[i]] = max(dp0[i + 1][j + a[i]], dp0[i][j] + b[i]);
            }
        }
    }

    vector<vector<int>> dp1(n + 1, vector<int>(t, 0));
    for (int i = n; i > 0; i--) {
        for (int j = 0; j < t; j++) {
            dp1[i - 1][j] = max(dp1[i - 1][j], dp1[i][j]);
            if (j + a[i - 1] < t) {
                dp1[i - 1][j + a[i - 1]] = max(dp1[i - 1][j + a[i - 1]], dp1[i][j] + b[i - 1]);
            }
        }
    }

    int res = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < t; j++) {
            res = max(res, dp0[i][j] + dp1[i + 1][t - j - 1] + b[i]);
        }
    }

    cout << res << endl;
}


Measured memory_bytes: 70912
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	long long int N, A, B, C, D, E;
	cin >> N >> A >> B >> C >> D >> E;
	long long int Min = min(A, min(B, min(C, min(D, E))));
	long long int kiriage = 0;
	if(N % Min == 0){
		kiriage = N / Min;
	}else{
		kiriage = (N / Min) + 1; 
	}
	cout << kiriage + 4 << endl;
}

Measured memory_bytes: 256
read N
read -a W

sum=$(printf "%s\n" ${W[@]} | awk '{sum+=$1} END {print sum}')
arr=()

for ((i=0; i<$N; i++)); do
    left=${W[@]:0:$i}
    X=$(printf "%s\n" ${left[@]} | awk '{sum+=$1} END {print sum}')
    ((Y=sum-X))
    
    if (($X > $Y)); then
        ((V=X-Y))
    else
        ((V=Y-X))
    fi
    arr+=($V)
done

printf "%s\n" ${arr[@]} | sort -n | head -n 1


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

int main() {
	int a, b;
	cin >> a >> b;
	
	if(a > b) swap(a, b);
	
	if(a == 1) {
		if( b==2) cout << 3 << endl;
		else cout << 2 << endl;
	}
	else cout << 1 << endl;
 
    return 0;
}

Measured memory_bytes: 256
#include <string>
#include <iostream>
#include <stack>
#include <queue> // priority_queue も入ってる
#include <set>   // 要素数は size() で取得 multisetもある
#include <map>
#include <array> // sizeはコンパイル時定数で固定
#include <vector>
#include <numeric>   // accumulate, gcd
#include <algorithm> // count_ifに必要
#include <iomanip>   // cout << setprecision(15) << x で小数の出力精度を指定
#include <tuple>
#include <utility> //pair
#include <cmath>

using namespace std;
// 問題が起こるまでintは使用禁止2020-04-13
using ll = long long;

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

template <class InputIterator, class T>
bool contains_itr(InputIterator iterator, const T &value)
{
    if (find(iterator.begin(), iterator.end(), value) == iterator.end())
        return false;
    else
        return true;
}

template <class T>
bool contains_set(set<T> st, const T &value)
{
    if (st.find(value) == st.end())
    {
        return false;
    }
    else
    {
        return true;
    }
}

template <class InputIterator>
auto sum(InputIterator iterator)
{
    return accumulate(iterator.begin(), iterator.end(), 0);
}

// endは排他的(exclusive)なので注意
vector<ll> range(ll begin, ll end)
{
    vector<ll> result;
    for (ll i = begin; i < end; ++i)
    {
        result.push_back(i);
    }
    return result;
}

// =========ここまでテンプレ============

int main()
{
    ll n, k;
    cin >> n >> k;
    vector<ll> a(n);
    rep(i, n) cin >> a[i];
    for (ll i = k; i < n; ++i)
    {
        if (a[i - k] < a[i])
        {
            cout << "Yes" << endl;
        }
        else
        {
            cout << "No" << endl;
        }
    }
}

Measured memory_bytes: 4396
#include <cstdint>
#include <iostream>

using namespace std;

int64_t Gcd(int64_t a, int64_t b)
{
    if (b == 0) {
        return a;
    }
    return Gcd(b, a % b);
}

int main()
{
    int64_t n, start;
    cin >> n >> start;

    int64_t res = 0;
    for (int64_t i = 0; i < n; i += 1) {
        int64_t pos;
        cin >> pos;

        res = Gcd(abs(start - pos), res);
    }

    cout << res << "\n";
    return 0;
}


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

int main(){
	int ans=0;
	int m=0;
	for(int i=0;i<5;i++) {
		int a;
		cin >> a;
		if(a%10) {
			m=max(m,10-a%10);
			a+=10-a%10;
		}
		ans+=a;
	}
	cout << ans-m << endl;
	return 0;
}


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

int main() {
 	    int n;
         cin>>n;
         int arr[n];
         for(int i=0;i<n;i++)cin>>arr[i];
         long int dp[n];
         dp[0]=0; //first stone
         if(n>1)                //imp        
         dp[1]=abs(arr[1]-arr[0]);
         for(int i=2;i<n;i++){
             dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
             //cout<<dp[i]<<" ";
         }
         cout<<dp[n-1]<<endl;

	return 0;
}

Measured memory_bytes: 4728
#include <bits/stdc++.h>
using namespace std;
#define N_MAX 100000

int main(){
//入力
int n;
int ans=0;
int cnt=0;

    cin >> n ;
    
    for(int i=1;i<=n;i++){
        if(i%2==0)continue;
        for(int j=1;j<=i;j++){
            if(i%j==0)cnt++;
        }
        if(cnt==8)ans++;
        cnt=0;
    }

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

Measured memory_bytes: 3592
#include<stdio.h>
main(){
  int ar,br,cr,dr,al,bl,cl,dl;
  float r,l;
  ar=br=cr=dr=al=bl=cl=dl=0;
  while(scanf("%f %f",&l,&r)!=EOF){
    if(l>=1.1){
      al++;
    }
    else if(l>=0.6 && l<1.1){
      bl++;
    }
    else if(l>=0.2 && l<0.6){
      cl++;
    }
    else{
      dl++;
    }
    if(r>=1.1){
      ar++;
    }
    else if(r>=0.6 && r<1.1){
      br++;
    }
    else if(r>=0.2 && r<0.6){
      cr++;
    }
    else{
      dr++;
    }
  }
  printf("%d %d\n%d %d\n%d %d\n%d %d\n",al,ar,bl,br,cl,cr,dl,dr);
  return 0;
}

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

long long gcd(long long a, long long b){
    long long x,r;
    if(a < b){
      x = a;
      a = b;
      b = x;
      }
    for(x = 0; b != 0; x++){
      r = a%b;
      a = b;
      b = r;
    }
    return a;
}
int main(void){
    long long a, b;

    while(cin >> a >> b){
    long long lcm = a*b/gcd(a,b);
    cout << gcd(a,b) << " " << lcm << endl;
}

    return 0;
}


Measured memory_bytes: 3032
#include<bits/stdc++.h>
using namespace std;
#define lli long long int
#define pb push_back
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define yoi cout<<"yo"<<endl;
#define debug(x) cerr << #x << " is " << x << endl;
#define all(x) x.begin(),x.end()
const lli inf=1e18;
const int mod=1e9+7;
int main(){
IOS;
int n,k;
cin>>n>>k;
int a[n];
int count=0,i;
for(i=0;i<n;i++){
    cin>>a[i];
    if(a[i]>=k)
        count++;
}
cout<<count<<endl;
}


Measured memory_bytes: 640
'''
def comb(n,k,p):
  """power_funcを用いて(nCk) mod p を求める"""
  from math import factorial
  if n<0 or k<0 or n<k: return 0
  if n==0 or k==0: return 1
  a=factorial(n) %p
  b=factorial(k) %p
  c=factorial(n-k) %p
  return (a*power_func(b,p-2,p)*power_func(c,p-2,p))%p

def power_func(a,b,p):
  """a^b mod p を求める"""
  if b==0: return 1
  if b%2==0:
    d=power_func(a,b//2,p)
    return d*d %p
  if b%2==1:
    return (a*power_func(a,b-1,p ))%p
'''

def comb_mod(n, r, MOD):
    if n < 0 or r < 0 or n < r:
        return 0

    factrial = [1] * (n+1)
    for k in range(1, n+1):
        factrial[k] = (factrial[k-1] * k) % MOD

    fact_inv = [1] * (n+1)
    fact_inv[n] = pow(factrial[n], MOD - 2, MOD)
    for k in range(n-1, -1, -1):
        fact_inv[k] = (fact_inv[k+1] * (k+1)) % MOD

    return (factrial[n] * fact_inv[r] * fact_inv[n-r]) % MOD

x,y=map(int,input().split())

if (2*y-x)%3!=0 or (2*x-y)%3!=0:
    print(0)
else:
    k=(2*y-x)//3
    l=(2*x-y)//3
    a = comb_mod(k+l,l,10**9+7)
    print(a)


Measured memory_bytes: 55796
# -*- coding: utf-8 -*-
import sys
from collections import deque
sys.setrecursionlimit(10**9)
INF=10**18
MOD=10**9+7
input=lambda: sys.stdin.readline().rstrip()
YesNo=lambda b: bool([print('Yes')] if b else print('No'))
YESNO=lambda b: bool([print('YES')] if b else print('NO'))
int1=lambda x:int(x)-1

def main():
    H,W,K=map(int,input().split())
    dpdp=[[0]*2 for _ in range(W)]
    dpdp[0][0]=1
    for i in range(W-1):
        dpdp[i+1][0]=dpdp[i][0]+dpdp[i][1]
        dpdp[i+1][1]=dpdp[i][0]
    
    dp=[[0]*W for _ in range(H+1)]
    dp[0][0]=1
    for i in range(H):
        for j in range(W):
            if j==0 or j==W-1:
                dp[i+1][j]+=dp[i][j]*(sum(dpdp[W-2]))
            else:
                dp[i+1][j]+=dp[i][j]*(sum(dpdp[max(j-1,0)])*sum(dpdp[max(W-2-j,0)]))
            dp[i+1][j]%=MOD
            if j<=W-2:
                dp[i+1][j+1]+=dp[i][j]*(sum(dpdp[max(j-1,0)])*sum(dpdp[max(W-3-j,0)]))
                dp[i+1][j+1]%=MOD
            if j>=1:
                dp[i+1][j-1]+=dp[i][j]*(sum(dpdp[max(j-2,0)])*sum(dpdp[max(W-2-j,0)]))
                dp[i+1][j-1]%=MOD
    print(dp[-1][K-1])

if __name__ == '__main__':
    main()


Measured memory_bytes: 39152
#include <iostream>
#include <vector>

using namespace std;

class UnionFind{
    public:
        UnionFind(){
            UnionFind(0);
        }

        UnionFind(int N){
            rnk.resize(N);
            par.resize(N);
            for(int i=0;i<N;i++){
                rnk[i] = 0;
                par[i] = i;
            }
        }

        int root(int x){
            if(par[x] == x) return x;
            return par[x] = root(par[x]);
        }

        bool same(int x, int y){
            x = root(x); y = root(y);
            return x == y;
        }

        void unite(int x, int y){
            x = root(x); y = root(y);
            if(x == y) return;

            if(rnk[x] < rnk[y]){
                par[x] = y;
            }else{
                par[y] = x;
                if(rnk[x] == rnk[y]){
                    rnk[x]++;
                }
            }
        }

    private:
        vector<int> rnk, par;
};

int main(){
    int N,M; cin >> N >> M;
    vector<int> P(N);
    for(int i=0;i<N;i++){
        cin >> P[i];
        P[i]--;
    }

    UnionFind uf = UnionFind(N);
    for(int i=0;i<M;i++){
        int x,y; cin >> x >> y;
        x--; y--;
        uf.unite(x,y);
    }
    int cnt = 0;
    for(int i=0;i<N;i++){
        if(uf.same(i, P[i])) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 1408
#include<iostream>
#include<cstdio>
#include<climits>
#include<algorithm>
#include<vector>
#include<string>
#include<string.h>
#include<sstream>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<cmath>
#include<typeinfo>
using namespace std;
#define inf 0x3f3f3f3f
#define fast ios::sync_with_stdio(false); cin.tie(0)
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)
#define clr(a,b) memset((a),b,sizeof(a))
#define all(c) c.begin(), c.end()
#define rall(c) c.rbegin(), c.rend()
#define sz(a) int((a).size())
#define pb push_back
#define fr first
#define sc second
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef pair<ll,ll> pll;
//const ld PI = 3.1415926535897932384626433832795L;

template<typename T>
inline void input(T &a) {
    static int ed;
    a = 0;
    while (!isdigit(ed = getchar()) && ed != '-') { }
    char neg = 0;
    if (ed == '-') {
        neg = 1;
        ed = getchar();
    }
    while (isdigit(ed)) {
        a = 10 * a + ed - '0';
        ed = getchar();
    }
    if (neg) a = -a;
}

template<typename T = int>
inline T nxt() {
    T res;
    input(res);
    return res;
}

int gcd(int a, int b){return b==0? a : gcd(b,a%b);}

#define mod 1000000007
ll mark[100100],size[100100];
int main(){
    int t=1;
    //cin>>t;
    while(t--){
        int n,m,a,b,ans=0; cin>>n>>m;
        for(int i=0;i<=n;i++) size[i]=1;
        mark[1]=1;
        while(m--){
            cin>>a>>b;
            if(size[a]>0){
            if(size[a]-1>0){
                if(mark[a]==1){
                    mark[b]=1;}
            }else{
                if(mark[a]==1){
                    mark[a]=0;
                    mark[b]=1;}
            }
                size[a]--;
                size[b]++;
            }
        }
        for1(i,n){
            if(mark[i]==1) ans++;
        }
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <string>
#include <algorithm>
#define T_MAX 31
#define N_MAX 21
using namespace std;


struct Pdata{
  string name;
  int point;
  int m; 
};

bool operator < ( const Pdata &p, const Pdata &q ){
  if( p.point == q.point ){
    return p.name < q.name;
  }else{
    return p.point < q.point;
  }
}

int main () {
  while ( 1 ) {
    int n;
    cin >> n;
    if( !n ) { return 0; }
    int table[ T_MAX ] = { 0 };
    int ds[ N_MAX ][ T_MAX ] = { 0 };
    Pdata p[ N_MAX ];
    
    for( int i = 0; i < n; i++ ) {
      cin >> p[ i ].name >> p[ i ].m;
      for( int j = 0; j < p[ i ].m; j++ ) {
        cin >> ds[ i ][ j ];
        table[ ds[ i ][ j ] ]++;
      }
    }
    for( int i = 0; i < n; i++ ) {
      p[ i ].point = 0;
      for( int j = 0; j < p[ i ].m; j++ ) {
        p[ i ].point += ( n - table[ ds[ i ][ j ] ] + 1 );
      }
    }
    sort( p, p + n );
    cout <<  p[ 0 ].point << " " << p[ 0 ].name << endl;
  }
  
}

Measured memory_bytes: 1216
#include <bits/stdc++.h>
using namespace std;
long long int power(long long int x,long long int y) 
{ 
    long long int res = 1;     // Initialize result 
  // x=x;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x); 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x);  // Change x to x^2 
    } 
    return res; 
}
long long int power(long long int x,long long int y,long long int m) 
{ 
    long long int res = 1;     // Initialize result 
   x=x%m;
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = (res*x)%m; 
   
        // y must be even now 
        y = y>>1; // y = y/2 
        x = (x*x)%m;  // Change x to x^2 
    } 
    return res; 
}

long long int gcd(long long int a, long long int b){ 
    if (a == 0) 
        return b;  
    return gcd(b % a, a);  
 } 
 long long int lcm(long long int a, long long int b)  
 { 
     long long int temp;
    
    return (a*b)/gcd(a, b);  
 }
 
int main() {
        long long int t=0;
        string c;
        string s;
       long long int n,m,o=0,l,d=1,i,j,p=0,k,f;
       double pie=3.141592653589793238;
    long long int MOD=1000000007;
    cin>>n;
    while(n)
    {
        if(n==1)
        {p=p+d;
        break;}
        else
        {
            p=p+d;
            d=d*2;
            n=n/2;
        }
    }
    cout<<p;
 return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <set>
#include <cmath>

using namespace std;

int main(void){
    int N;
    vector<int> A;
    
    cin >> N;
    for(int i=0;i<N;i++){
        int a;cin >> a;A.push_back(a);
    }
    
    int cnt;
    for(int i=1;i<N;i++){
        if(A[i]==A[i-1]){
            A[i]=-1;
            cnt++;
        }
    }
    cout << cnt;
    return 0;
}

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

namespace AtTest.EducationalDP
{
    class D
    {
        static void Main(string[] args)
        {
            Method(args);
            Console.ReadLine();
        }

        static void Method(string[] args)
        {
            int[] nw = ReadInts();
            int n = nw[0];
            int w = nw[1];
            int[][] wvs = new int[n][];
            for(int i = 0; i < n; i++)
            {
                wvs[i] = ReadInts();
            }
            long[] dp = new long[w+1];
            for(int i = 0; i < n; i++)
            {
                long[] newDp = new long[w+1];
                for(int j = 0; j <= w; j++)
                {
                    if (j - wvs[i][0] < 0) newDp[j] = dp[j];
                    else newDp[j] = Math.Max(
                        dp[j], dp[j - wvs[i][0]] + wvs[i][1]);
                }
                dp = newDp;
            }
            Console.WriteLine(dp[w]);
        }

        private static string Read() { return Console.ReadLine(); }
        private static int ReadInt() { return int.Parse(Read()); }
        private static long ReadLong() { return long.Parse(Read()); }
        private static double ReadDouble() { return double.Parse(Read()); }
        private static int[] ReadInts() { return Array.ConvertAll(Read().Split(), int.Parse); }
        private static long[] ReadLongs() { return Array.ConvertAll(Read().Split(), long.Parse); }
        private static double[] ReadDoubles() { return Array.ConvertAll(Read().Split(), double.Parse); }
    }
}


Measured memory_bytes: 30940
#include<stdio.h>
int main(){
    
    long long n,m,i,t=0;
    scanf("%lld %lld",&n,&m);
    long long a[m];
    for(i=0;i<m;i++){
        scanf("%lld",&a[i]);
        t+=a[i];
    }
    if(n-t>=0)
        printf("%lld",n-t);
    else
        printf("-1");
    return 0;
    
}


Measured memory_bytes: 1808
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef vector<pair<ll,ll> > vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
const int INF=1e9;
int main(){
  ll d,g;cin>>d>>g;
  vll p(d),c(d);
  rep(i,0,d){
    cin>>p[i]>>c[i];
  }
  ll minmon=INF,m;
  rep(i,0,1<<10){
    ll ten=0,mondai=0;
    rep(j,0,d){
      if(i>>j&1){
        ten+=100*(j+1)*p[j]+c[j];
        mondai+=p[j];
      }
      else{m=j;}
    }
    if(ten>g){minmon=min(minmon,mondai);}
    else if(g-ten<100*p[m]*(m+1)){
      ll x=(g-ten)/(100*(m+1));
      mondai+=((g-ten)%(100*(m+1))==0)?x:x+1;
      minmon=min(minmon,mondai);
    }
  }
  cout<<minmon<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for (int i = (a); i <= (b); ++ i)
#define rrp(i,a,b) for (int i = (a); i >= (b); -- i)
#define gc() getchar()
#define fir first
#define sec second
typedef pair<int,int> pii;
typedef double db;
typedef long long ll;
template <typename tp>
inline void read(tp& x) {
  x = 0; char tmp; bool key = 0;
  for (tmp = gc(); !isdigit(tmp); tmp = gc())
    key = (tmp == '-');
  for (; isdigit(tmp); tmp = gc())
    x = (x << 3) + (x << 1) + (tmp ^ '0');
  if (key) x = -x;
}
template <typename tp>
inline void ckmn(tp& x,tp y) {
  x = x < y ? x : y;
}
template <typename tp>
inline void ckmx(tp& x,tp y) {
  x = x < y ? y : x;
}

const int N = 5010;
char str[N], mn, tmp[N << 1];
int n, k;
bool diff(int p1,int p2,int len) {
  rep (i, 0, len-1) {
    if (tmp[p1 - i] != tmp[p2 - i])
      return tmp[p1-i] < tmp[p2-i];
  }
  return 0;
}
int main() {
  read(n), read(k);
  scanf("%s", str+1);
  mn = 'z';
  rep (i, 1, n) mn = min(mn, str[i]);
  while (k > 1) {
    rep (i, 1, n) tmp[i] = str[i];
    rep (i, n+1, 2*n) tmp[i] = str[2 * n - i + 1];
    int cur = 0, cnum = 0, rec = 0;
    rep (i, 1, 2*n) {
      if (tmp[i] == mn) {
	if (i < 2*n && tmp[i+1] == mn) {
	  ++ rec;
	  continue;
	} else {
	  if (rec > cnum && i >= n) {
	    cur = i, cnum = rec;
	  } else if (rec == cnum && i >= n) {
	    if (diff(i - rec, cur - rec, n - rec))
	      cur = i;
	  }
	  rec = 0;
	}
      }
    }
    rep (i, 1, n) str[i] = tmp[cur - n + i];
    int key = 1;
    rep (i, 1, n) if (str[i] != mn) key = 0;
    if (key) break;
    -- k;
  }
  rep (i, 1, n) tmp[i] = str[i];
  rep (i, n+1, 2*n) tmp[i] = str[2 * n - i + 1];
  int cur = 1;
  rep (i, 2, n+1) {
    int key = 0;
    rep (j, 0, n-1) {
      if (tmp[i+j] != tmp[cur+j]) {
	if (tmp[i+j] < tmp[cur+j]) key = 1;
	break;
      }
    }
    if (key == 1) cur = i;
  }
  rep (j, 0, n-1) putchar(tmp[cur + j]);
  puts("");
  return 0;
}


Measured memory_bytes: 256
n = int(input())
xy = []

for _ in range(n):
    xy.append(input().split())

dist = 0

for i in range(n):
    for j in range(n):
        if i != j:
            dist += (((int(xy[i][0]) - int(xy[j][0]))**2 + (int(xy[i][1]) - int(xy[j][1]))**2)**0.5)/n

print(dist)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
typedef unsigned long long ull;
#define MP make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define FORR(x,arr) for(auto& x:arr)
#define VI vector<int>
#define PII pair<int, int>
#define FI first
#define SE second
#define ALL(x) (x).begin(), (x).end()
const int INF=1<<30;
const ll LINF=1LL<<60 ;
const ll MOD=1e9+7 ;
//-------------------


int main(){
	ll x,y; cin >> x >> y;
	ld mx = y/x;
	ll ans;
	ll bit = 1;
	while(bit <= mx){
		bit *= 2;
		ans += 1;
	}

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

Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int n,k,a[100],sum=0,sum1=0,i,b,min,max,min1;
    scanf("%d",&n);
    for(i=0;i<n;i++)
    {
        scanf("%d",&a[i]);
        sum+=a[i];
    }
    for(i=1,min=max=0;i<n;i++)
    {
        if(a[i]<a[min])
            min=i;
        if(a[i]>a[max])
            max=i;
    }
    for(i=a[min];i<=a[max];i++)
    {
        if(i==a[min])
            min1=n*i*i-2*i*sum;
        b=n*i*i-2*i*sum;
        if(b<min1)
            min1=b;
    }
    for(i=0;i<n;i++)
    {
        sum1+=a[i]*a[i];
    }
    printf("%d",sum1+min1);
}


Measured memory_bytes: 128
k = int(input())
a,b = list(map(int, input().split()))
s = [i for i in range(a,b+1)]
cnt = 0
for j in range(0,len(s)):
    if s[j]%k == 0:
        cnt +=1
    else:
        cnt+=0
if cnt==0:
    print('NG')
else:
    print('OK')

Measured memory_bytes: 9192
#include<bits/stdc++.h>
using namespace std;
#define INFTY 1<<20
typedef long long int ll;
const int MOD=1000000007;
using Graph = vector<vector<int>>;
using ipair = pair<ll,ll>;
bool operator< (const ipair a, const ipair b){return a.first < b.first;};
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll gcd(ll a, ll b) { return b?gcd(b,a%b):a;}
ll lcm(ll a, ll b) { return a/gcd(a,b)*b;}

int main(){
  ll a,b,c,k;
  cin>>a>>b>>c>>k;
  ll ans = 0;
  ll num=k;
  if(num<=a){
    ans +=num;
    cout<<ans;
    return 0;
  }
  else{
    num -= a;
    ans+= a;
    if(num<=b){
      cout<<ans;
      return 0;
    }
    else{
      num -= b;
      ans -= num;
      cout<<ans;
      return 0;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define All(V) v.begin(), v.end()
typedef long long int ll;
typedef pair<int, int> P;
const ll MOD = 1e9+7, INF = 1e9;

int main()
{
  string s, t; cin >> s >> t;
  for(int i = 0; i < s.size(); i++){
    cout << s[i];
    if(i < t.size())cout << t[i];
  }
  cout << endl;
  system("pause");
}

Measured memory_bytes: 504
#include<stdio.h>
int main(){
  long int p[10000001],e[10000001]={0},f[10000001],i,j,k=0,n,r=1,l,m;
  scanf("%ld",&n);
  for(i=0;i<=n;i++)f[i]=1;
  for(i=2;i<=n;i++)if(!e[i]){p[k]=i;k++;for(j=i;j<=n;j+=i)e[j]=1;}
  for(i=0;i<k;i++)for(j=p[i];j<=n;j+=p[i]){l=1;m=j;while(m%p[i]==0){l++;m/=p[i];}f[j]*=l;}
  for(i=2;i<=n;i++)r+=f[i]*i;
  printf("%ld",r);
}

Measured memory_bytes: 163140
def main():
    s = input()
    count = s.count(s[0])
    if count == 2:
        strip = s.strip(s[0])
        if strip.count(strip[0]) == 2:
            print('Yes')
        else:
            print('No')
    else:
        print('No')


if __name__ == '__main__':
    main()


Measured memory_bytes: 2940
#include <vector>
#include <string>
#include <iostream>
#include <algorithm>
#include <cstdio>
using namespace std;
string x,y;

vector<string> split(string &str, const char *delim){
	vector<string> result;
	int cutAt;
	while( (cutAt = str.find_first_of(delim)) != str.npos ){
		if(cutAt > 0){
			result.push_back(str.substr(0, cutAt));
		}
		str = str.substr(cutAt + 1);
	}
	if(str.length() > 0){
		result.push_back(str);
	}
	return result;
}

void solve(string &exp){
	int i=0,j,r;
	vector<string> token = split(exp,"|");
	for(;i<token.size();i++){
		string t=token[i].substr(1,token[i].size()-2);
		vector<string> prob = split(t,"&");
		for(r=j=0;j<prob.size();j++){
			if(prob[j][0]!='~'&&find(prob.begin(),prob.end(),y+prob[j])!=prob.end())r++;
		}
		if(!r)break;
	}
	puts(i==token.size()?"no":"yes");
}
int main(){x="#",y="~";for(string str;getline(cin,str),str!=x;solve(str));}

Measured memory_bytes: 1184
import java.io.*;
import java.util.*;

public class Main {

	
	public static void main(String[] args) {
		FastScanner in=new FastScanner();
		PrintWriter out=new PrintWriter(System.out);
	//	int t=in.nextInt();
	//	while(t-->0)
		solve(in,out);
		out.close();
	}

    static void solve(FastScanner in,PrintWriter out){
     long x=Math.abs(in.nextLong());
     long k=in.nextLong();
     long d=in.nextLong();
     long ans=x-Math.min(x/d,k)*d;
     k-=Math.min(x/d,k);
     if(k%2==0) out.println(ans);
     else out.println(Math.abs(ans-d));
    }    
	



	static void sort(int[] a) {
		ArrayList<Integer> l=new ArrayList<>();
		for (int i:a) l.add(i);
		Collections.sort(l);
		for (int i=0; i<a.length; i++) a[i]=l.get(i);
	}
	
	static class FastScanner {
		BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st=new StringTokenizer("");
		String next() {
			while (!st.hasMoreTokens())
				try {
					st=new StringTokenizer(br.readLine());
				} catch (IOException e) {
					e.printStackTrace();
				}
			return st.nextToken();
		}
		
		int nextInt() {
			return Integer.parseInt(next());
		}
		int[] readArray(int n) {
			int[] a=new int[n];
			for (int i=0; i<n; i++) a[i]=nextInt();
			return a;
		}
		long nextLong() {
			return Long.parseLong(next());
		}
	}

	
}


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

using namespace std;
using ll = long long;

#define REP(i, n) for (ll i = 0; i < n; i++)
#define INF 9223372036854775807
#define all(x) (x).begin(), (x).end()

ll ts = 1000000007;

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

  ll a, b;
  cin >> a >> b;

  cout << (a < 10 && b < 10 ? a * b : -1) << "\n";
}

Measured memory_bytes: 256
object Main{
  def main(args: Array[String]){
    val input=io.Source.stdin.getLines().mkString("\n")
    println(solve(input).trim())
  }

  def solve(input:String):String={
    val Array(n,m)=input.split(" ").map(_.toInt)
    ( ( (n-m)*100 + m*1900 ) * List.fill(m)(2).product ).toString
  }
}


Measured memory_bytes: 25544
#include<bits/stdc++.h>
#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL)

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

ll n, d;
int br;
int main() {
    IOS; cin >> n >> d;
    for(int i=0; i<n; ++i) {
        ll a, b; cin >> a >> b;
        if(a*a+b*b<=d*d) ++br;
    }
    cout << br;
    return 0;
}


Measured memory_bytes: 3648
#include<bits/stdc++.h>
using namespace std;
int main(){
  int a=0,b=0;
  cin>>a>>b;
  int ans=0;
  if(a>=13){
    ans=b;
  }
  else if(6<=a&&a<=12){
    ans=b/2;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 3552
si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
lmsi = lambda: list(map(str, input().split()))
smii = lambda: sorted(map(int, input().split()))

# ----------

S = si()

ans = 0
ans += S.count('+')
ans -= S.count('-')

print(ans)

Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>
#define ll long long
#define rep(i,l,r)for(ll i=(l);i<(r);i++)
int upll(const void*a, const void*b){return*(ll*)a<*(ll*)b?-1:*(ll*)a>*(ll*)b?1:0;}
void sortup(ll*a,int n){qsort(a,n,sizeof(ll),upll);}
#define MOD 1000000007

ll m[200010],p[200010];
int mcnt,pcnt;
int main(){
	int n,k;
	scanf("%d%d",&n,&k);
	rep(i,0,n){
		int t;
		scanf("%d",&t);
		if(t>=0)p[pcnt++]=t;
		else m[mcnt++]=-t;
	}
	sortup(m,mcnt);
	sortup(p,pcnt);
	
	//K==Nのとき
	if(k==n){
		ll ans=1;
		rep(i,0,mcnt)ans=ans*(MOD-m[i])%MOD;
		rep(i,0,pcnt)ans=ans*p[i]%MOD;
		printf("%lld",ans);
		return 0;
	}
	
	//Kが奇数かつ負のみのとき
	if(k%2==1&&mcnt==n){
		ll ans=1;
		rep(i,0,k)ans=ans*(MOD-m[i])%MOD;		
		printf("%lld",ans);
		return 0;
	}
	
	ll ans=1;
	while(k){
		if(k>=2 && mcnt>=2 &&(pcnt<=1 || (pcnt>=2 && m[mcnt-1]*m[mcnt-2]>=p[pcnt-1]*p[pcnt-2]))){
			ans=ans*m[--mcnt]%MOD;
			ans=ans*m[--mcnt]%MOD;
			k-=2;
		}else{
			ans=ans*p[--pcnt]%MOD;
			k--;
		}
	}
	printf("%lld",ans);
}


Measured memory_bytes: 4104
#template
def inputlist(): return [int(j) for j in input().split()]
#template
A,B = input().split()
A = int(A)
from decimal import Decimal
B = Decimal(B)
ans = str(A*B)
n = len(ans)
ansa = ''
for i in range(n):
    if ans[i] == '.':
        break
    ansa += ans[i]
print(ansa)

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

// Macros
#define F  first
#define S  second
#define PB push_back

// Rename Datatypes
using ll  = long long;
using ld  = long double;
using pii = pair<int,int>;

// Common Functions
ll fastpow(ll a, ll ex){ ll res = 1; while(ex){ if(ex & 1) res *= a; a *= a; ex >>= 1; } return res; }
ll fastpow(ll a, ll ex, ll m){ a %= m; ll res = 1; while(ex){ if(ex & 1) res = (a*res) % m; a = (a*a) % m; ex >>= 1; } return res; }
ll modinverse(ll a, ll m){ ll m0 = m, y = 0, x = 1; while (a > 1){ ll q = a / m; a %= m; swap(a,m); x -= q*y; swap(x,y); } if(x < 0) x += m0; return x; }

// HELPERS
//  Tedious Grid Movements
vector<pii> moves_grid = { {0,1} , {0,-1} , {1,0} , {-1,0} };
inline bool move_okay(int x, int y, int n, int m) { return 0 <= x and x < n and 0 <= y and y < m; }
//  Remember:
//   * vec.assign() GOOD; vec.resize() BAD
//   * comparator uses <


// CODE STARTS HERE

void solve(){
	int n;
	cin >> n;

	vector<int> arr(n);
	for(auto& i : arr){
		char ch; cin >> ch;
		i = ch == 'W';
	}

	// array needs to be sorted
	// ops are swapping and reversing a element

	int ops = 0;

	for(int i = 0, j = n - 1; i < j; ){
		if(arr[i] == 1 and arr[j] == 0){
			++ops;
			swap(arr[i], arr[j]);
		}

		if(arr[i] == 0) ++i;
		if(arr[j] == 1) --j;
	}

	cout << ops << "\n";
}

signed main (void){
	// Fast_IO
	ios::sync_with_stdio(false);
	cin.tie(nullptr);

	// Set Fixed Notation (default sucks), High Precision for Floating-Point Output
	cout << fixed << setprecision(20);

	// Multiple TCs
	int tt = 1;
	// cin >> tt;
	while(tt--) solve();
}


Measured memory_bytes: 3972
import java.util.*;
import java.math.*;

public class Main {
    public static void main(String[] args) throws Exception {
        Scanner sc = new Scanner(System.in);
        Main m = new Main(sc);
        m.show(m.solve());
    }
    
    Scanner sc;
    String S;
    String answer = null;
    
    //入力
    Main(Scanner sc) {
        this.sc = sc;
        S = sc.next();
    }
    
    //解答処理
    String solve() {
        int countC = 0;
        int countUp = 0;
        if (S.charAt(0) == 'A' && !Character.isUpperCase(S.charAt(1))){  //先頭にAがあり、かつ2文字目が大文字でないか
            
            for (int i=2; i<S.length()-1; ++i){ //探索範囲は3文字目以降、末尾から2文字目まで
                if(S.charAt(i) == 'C'){ //Cが含まれていればカウント
                    ++countC;
                }
                if(Character.isUpperCase(S.charAt(i))){ //大文字があればカウント
                    ++countUp;
                }
                if(countC > 1 || countUp >1){  //Cか大文字の存在があればループ終了
                    break;
                }
            }
        }
        
        if(countC == 1 && !Character.isUpperCase(S.charAt(S.length()-1))){ //文字列の条件を満たす場所にCが1つだけあり、かつ大文字が先頭のA以外にない場合
            answer = "AC";
        }else{
            answer = "WA";
        }
        
        return answer;
    }
    
    //出力
    void show(String answer) {
        System.out.println(answer);
    }
}

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

double m500, m1000;

void solve(){
	if(m500 >= 70.00 || m1000 >= 148.00) cout << "NA" << endl;

	else if(m500 >= 55.00 || m1000 >= 116.00) cout << "E" << endl;

	else if(m500 >= 50.00 || m1000 >= 105.00) cout << "D" << endl;

	else if(m500 >= 43.00 || m1000 >= 89.00) cout << "C" << endl;

	else if(m500 >= 40.00 || m1000 >= 83.00) cout << "B" << endl;

	else if(m500 >= 37.50 || m1000 >= 77.00) cout << "A" << endl;

	else if(m500 >= 35.50 || m1000 >= 71.00) cout << "AA" << endl;

	else cout << "AAA" << endl;
}

int main(){
	while(cin >> m500 >> m1000){
		solve();
	}
}

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


int main(){
    string str;
    vector<int>ans(26);
    while(getline(cin, str)){
        for(int i=0; i<str.size(); i++){
            if(str[i]>='a' && str[i]<='z'){
                ans[str[i]-'a']+=1;
            }
            else if(str[i]>='A' && str[i]<='Z'){
                ans[str[i]-'A']+=1;
            }        
        }
    }
    for(int i=0; i<26; i++){
        cout << char('a'+i) << " : " << ans[i] << endl;
    }

}


Measured memory_bytes: 3140
#pragma GCC optimize("O3")
//#pragma GCC optimize ("unroll-loops")
#pragma GCC target ("avx2")
#define io_init cin.tie(0);ios::sync_with_stdio(0);cout<<setprecision(20)
#include <bits/stdc++.h>
constexpr int INF = 2147483647;
constexpr long long int INF_LL = 9223372036854775807;
constexpr int MOD = 1000000007;
constexpr double PI = 3.14159265358979323846;
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

int main() {
	ll N, K;
	cin >> N >> K;
	vector<ll> A(N);
	for (int i = 0; i < N; i++)cin >> A[i];
	vector<ll> cnt(63, 0);
	for (int i = 0; i < N; i++) {
		for (int j = 0; j < 63; j++)if (A[i] & (1LL << j))cnt[j]++;
	}
	ll ans = 0;
	bool flag = 0; //K未満フラグ
	for (ll j = 62; j >= 0; j--) {
		if (cnt[j] < N - cnt[j]) { //立てた方が得
			if (!flag && ((K & (1LL << j)) == 0) )ans += (1LL << j) * cnt[j]; //立てられない
			else ans += (1LL << j) * (N - cnt[j]);
		}
		else { //立てない方が得
			if (!flag && ((K & (1LL << j)) != 0) ) {
				flag = true;
			}
			ans += (1LL << j) * cnt[j];
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 4032