akhauriyash/Code-Regression huggingface dataset:
n,d = map(int,input().split())
l = list (list(map(int,input().split())) for i in range(n))
#print(l)
count = 0
q = 0
for i in range(n):
  a = l[i]
  for t in range(n):
    b = l[t]
    for c in range(d):
      q += (a[c]-b[c])**2
    if int(q**0.5)**2==q:
      count += 1
    q =0
print(int((count-n)/2))

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

typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;

using namespace std;

const int INF = 2e9 + 7;

int n, m, k;
vector<vector<int>> graph;
vector<vector<int>> contr;
vector<int> col;

void dfs(int v, int c) {
    col[v] = c;
    for (auto i : graph[v]) if (col[i] == -1) dfs(i, c);
}


int main() {
    ios::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    cin >> n >> m >> k;
    graph.resize(n);
    contr.resize(n);
    col.resize(n, -1);
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        graph[--a].push_back(--b);
        graph[b].push_back(a);
    }
    for (int i = 0; i < k; i++) {
        int a, b;
        cin >> a >> b;
        contr[--a].push_back(--b);
        contr[b].push_back(a);
    }
    int cur = 0;
    for (int i = 0; i < n; i++) {
        if (col[i] == -1) {
            dfs(i, cur++);
        }
    }
    unordered_map<int, int> col_sz;
    for (int i = 0; i < n; i++) {
        col_sz[col[i]]++;
    }
    vector<int> ans(n);
    for (int i = 0; i < n; i++) {
        ans[i] = col_sz[col[i]] - graph[i].size() - 1;
        for (auto j : contr[i]) {
            if (col[j] == col[i]) ans[i]--;
        }
    }
    for (auto i : ans) cout << i << " ";
    return 0;
}


Measured memory_bytes: 13440
#include<bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)n; i++)
#define repa(i, s, n) for(int i = s; i < (int)n; i++)
using namespace std;
typedef vector<int> vi;

int main(){
    string S;
    cin >> S;
    vector<char> alpha(26); // 0 = a, 25 = z
    vi counter(26);
    rep(i, 26){
        alpha[i] = 'a' + i;
    }

    rep(i, S.size()){
        rep(j, 26){
            if(S[i] == alpha[j]) counter[j]++;
        }
    }

    rep(i, 26){
        if(counter[i] == 0){
            cout << alpha[i] << endl;;
            return 0;
        }
    }
    cout << "None" << endl;
    
    return 0;
}

Measured memory_bytes: 3752
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define inf 1000000005
#define all(a) (a).begin(), (a).end()
#define ms(a,x) memset(a, x, sizeof(a))
#define mod 10007
#define sz(a) ((ll)(a).size())

template<class T> int getbit(T s, int i) { return (s >> i) & 1; }
template<class T> T onbit(T s, int i) { return s | (T(1) << i); }
template<class T> T offbit(T s, int i) { return s & (~(T(1) << i)); }
template<class T> int cntbit(T s) { return __builtin_popcount(s);}
#define Rep(i,n) for(int i = 0; i < (n); ++i)
#define Repd(i,n) for(int i = (n)-1; i >= 0; --i)
#define For(i,a,b) for(int i = (a); i <= (b); ++i)
#define Ford(i,a,b) for(int i = (a); i >= (b); --i)

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
#define eps 1e-9
typedef pair<int, int> II;
typedef pair<ll, ll> LL;
template<class T> T gcd(T a, T b){ T r; while (b != 0) { r = a % b; a = b; b = r; } return a;}
template<class T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define PI (2 * acos((ld)0))
#define linf (1ll << 60)
#define y1 y32432
#define y0 y435346

#define maxn 400005

int n, m;
vector<int> V[2][maxn];
bool flag[2][maxn];
int RR = 0;

void go(int id, int u){
	if(!id) RR++;
	Rep(i, sz(V[id][u])){
		int v = V[id][u][i];
		if(!flag[1 - id][v]){
			flag[1 - id][v] = 1;
			go(1 - id, v);
		}
	}
}

int main()
{
//	gen();
//	freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    cin >> n >> m;
    For(i, 1, n){
    	int num, x;
    	cin >> num;
    	Rep(run, num){
    		cin >> x;
    		V[0][i].pb(x);
    		V[1][x].pb(i);
    	}
    }
    ms(flag, 0);
    flag[0][1] = 1;
    go(0, 1);
//    cout << RR << endl;
    if(RR == n){
    	cout << "YES" << endl;
    } else cout << "NO" << endl;

    return 0;
}


Measured memory_bytes: 23808
#include <iostream>
#include <string>

using namespace std;

int main(){
	string s;
	int a[3] = {0,0,0};
	cin >> s;
	
	for(int i=0; i<3; i++){
		if(s[i]=='a'){
			a[0]=1;
		}else if(s[i]=='b'){
			a[1]=1;
		}else{
			a[2]=1;
		}
	}
	// cout << a[0] << " " << a[1] << " " << a[2] << endl;
	if(a[0]+a[1]+a[2]==3){
		cout << "Yes"<< endl;
	}else{
		cout << "No" << endl;
	}
	
	return 0;
}

Measured memory_bytes: 764
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<math.h>

int max(int a,int b){
  if(a > b) return a;
  else return b;
}
int min(int a, int b){
  if(a < b) return a;
  else return b;
}

#define PI 3.14159265358979323846264338327950

int main(){

  int a,b,h,m;
  scanf("%d%d%d%d",&a, &b, &h, &m);

/*  double angle = abs( ((double)h + (double)m/60.0) * 30.0 - (double)m * 6.0 );

  double rad = (angle /180.0)* PI;*/

  double rad = (( ((double)h + (double)m/60.0) * 30.0 - (double)m * 6.0 ) / 180.0) * PI;

  //printf("%.10f ",h);
  double ans = sqrt((double)a*a + (double)b*b -(double)2*a*b*cos(rad));
  printf("%.11f",ans);

  return 0;
}


Measured memory_bytes: 2600
using System;
using static System.Console;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

class Program
{
    static void Main(string[] args)
    {
        int n = int.Parse(ReadLine());
        int k = int.Parse(ReadLine());
        int x = int.Parse(ReadLine());
        int y = int.Parse(ReadLine());

        if (n <= k)
        {
            WriteLine(n * x);
        }
        else
        {
            WriteLine(k * x + (n - k) * y);
        }
        ReadKey();
    }
}

Measured memory_bytes: 11092
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner in = new Scanner(System.in);
    long n = in.nextLong();
    long x = in.nextLong();
    long t = in.nextLong();
    long temp = (long) Math.ceil((double) n/x);
    System.out.println(temp*t);
    in.close();
  }
}

Measured memory_bytes: 27032
#include <iostream>
#include <algorithm>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <set>
#include <bitset>
#include <map>
#include <unordered_map>
#include <list>
#include <numeric>
#include <utility>
#include <iterator>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cstring>
#include <climits>
#include <ctime>
#include <cassert>

#define INF 1000000000
#define LINF 9000000000000000000
#define mod 1000000007

#define rep(i,n) for(int i=0;i<int(n);i++)
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define REP(i,a,b) for(int i=(a);i<int(b);i++)
#define all(x) (x).begin(),x.end()
#define pb push_back
#define mp make_pair

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<long long>vll;
typedef pair<int,int> pi;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};
int ddx[8]={-1,-1,0,1,1,1,0,-1};
int ddy[8]={0,1,1,1,0,-1,-1,-1};
bool debug=false;

/*---------------------------------------------------*/

bool b[505][505];
ll lists[505];

/* ---- bitDP part ----*/
void init_bitDP(int n,int m){
  /* create bit list */
  for(int i=0;i<n;i++){
    lists[i]=0;
    for(int j=0;j<m;j++){
      assert(i<505&&j<505);
      if(b[i][j])lists[i]|=(1<<j);
    }
  }
  //cout<<"end bitDP: "<<endl;
}

int bitDP(int n,int m){
  vector<vector<int> >dp(n+1,vector<int>((1<<m),-1));
  //cout<<"dp"<<endl;
  for(int i=0;i<n;i++){
    //cout<<"init: "<<i<<endl;
    for(int j=0;j<(1<<m);j++){
      // assert(i<n&&j<(1<<m));
      dp[i][j]=-INF;
    }
  }
  
  dp[0][0]=0;
  for(int i=1;i<=n;i++){
    for(int j=0;j<(1<<m);j++){
      assert(i<n+5);
      assert(j<(1<<m));
      // cout<<i<<" "<<j<<endl;
      dp[i][j]=max(dp[i-1][j],dp[i-1][j^lists[i-1]]+1);
    }
  }
  return dp[n][0];
}


/* ---- dfs part ---- */
void init_dfs(bool used[]){
  for(int i=0;i<505;i++){
    used[i]=false;
  }
}

int dfs_calc(int n,int m,bool used[]){
  int ret=0;
  for(int i=0;i<n;i++)ret+=used[i];
  for(int i=0;i<m;i++){
    int sum=0;
    for(int j=0;j<n;j++){
      if(used[j])sum+=b[j][i];
    }
    if(sum%2)return -1;
  }
  // cout<<"  OK! ___ "<<ret<<endl;
  return ret;
}

int dfs(int n,int m,int cnt,bool used[]){
  int ret=0;
  if(n==cnt){
    //cout<<dfs_calc(n,m)<<endl;
    return dfs_calc(n,m,used);
  }
  
  used[cnt]=true;
  ret=max(ret,dfs(n,m,cnt+1,used));
  used[cnt]=false;
  ret=max(ret,dfs(n,m,cnt+1,used));  
  
  return ret;
}


/* ---- main ---- */
void solve(int n,int m){
  char c;
  for(int i=0;i<n;i++){
    for(int j=0;j<m;j++){
      cin>>c;
      b[i][j]=c-'0';
    }
  }
  
  if(n<=m){
    bool used[505];
    //cout<<"dfs"<<endl;
    init_dfs(used);
    // cout<<"dfs_in"<<endl;
    cout<<dfs(n,m,0,used)<<endl;
  }else{
    //cout<<"bitDP"<<endl;
    init_bitDP(n,m);
    // cout<<"bitDP_in"<<endl;
    cout<<bitDP(n,m)<<endl;;
  }
  //cout<<"debug; "<<endl;
}

int main(){
  int n,m;
  while(scanf("%d%d",&n,&m),n|m){
    //cout<<n<<" "<<m<<endl;
    solve(n,m);
  }
  return 0;
}



Measured memory_bytes: 208468
#include <iostream>

int main() {
  int one, two, three, four;
  std::cin >> one >> two >> three >> four;
  int total_sec = one + two + three + four;
  int min = total_sec / 60;
  int sec = total_sec % 60;
  std::cout << min << std::endl << sec << std::endl;
}



Measured memory_bytes: 3092
#include <bits/stdc++.h>
using namespace std;
#pragma optimize("-O3")
#define int long long int
#define f first
#define s second
#define pb push_back
#define endl '\n'

main() {
	ios::sync_with_stdio(false);
	cin.tie(NULL);
	cout.tie(NULL);
	string s;
	cin>>s;
	int maxi=0;
	int cnt=0;
	for(int i=0; i<s.size(); i++){
		if(s[i]=='R'){
			cnt++;
			maxi=max(maxi, cnt);
		}
		else{
			maxi=max(maxi, cnt);
			cnt=0;
		}
	}
	cout<<maxi;
	return 0;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  int a, b, m;
  cin >> a >> b >> m;
  
  int mina = 1e9, minb = 1e9;
  vector<int> d(a), e(b);
  for (int i = 0; i < a; i++) {
    cin >> d.at(i);
    mina = min(mina, d.at(i));
  }
  for (int i = 0; i < b; i++) {
    cin >> e.at(i);
    minb = min(minb, e.at(i));
  }
  
  vector<int> x(m), y(m), c(m);
  for (int i = 0; i < m; i++) cin >> x.at(i) >> y.at(i) >> c.at(i);
  
  int ans = mina + minb;
  for (int i = 0; i < m; i++) {
    if (d.at(x.at(i) - 1) + e.at(y.at(i) - 1) - c.at(i) < ans) ans = d.at(x.at(i) - 1) + e.at(y.at(i) - 1) - c.at(i);
  }
  
  cout << ans << '\n';
}

Measured memory_bytes: 2176
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {

        // input
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        
        if (((a>b)&(b>c))||((b>a)&(a>c))||((c>a)&(a>b))||((c>b)&(b>a))) System.out.println("No");
        else System.out.println("Yes");

    }
}


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

int main()
{
    int n,a,b,c,d,e;
    while(~scanf("%d",&n))
    {
        scanf("%d",&b);
        scanf("%d",&c);
        if(n==1)
            printf("Hello World\n");
        else
            printf("%d\n",b+c);
    }
    return 0;
}


Measured memory_bytes: 128
<?php
define("MOD", 10 ** 9 + 7);
list($n, $m) = ints();
init($m);
$cnta = nPr2($m, $n);
$cntb = 0;
for ($i = 0; $i <= $n; ++$i) {
    $c = modMul(nCr2($n, $i), nPr2($m - $i, $n - $i));
    if ($i & 1) $cntb = modSub($cntb, $c);
    else $cntb = modAdd($cntb, $c);
}
echo modMul($cnta, $cntb);
function ints()
{
    return array_map('intval', explode(' ', trim(fgets(STDIN))));
}
// 足し算
function modAdd($x, $y)
{
    return ($x + $y) % MOD;
}

// 引き算
function modSub($x, $y)
{
    return ($x + MOD - $y) % MOD;
}

// 掛け算
function modMul($x, $y)
{
    return ($x * $y) % MOD;
}

// 割り算
function modDiv($x, $y)
{
    return modMul($x, modPow($y, MOD - 2));
}

// 累乗（繰り返し二乗法）
function modPow($n, $x)
{
    if ($x === 0) return 1;
    $res = (modPow($n, $x >> 1) ** 2) % MOD;
    if ($x % 2 === 1) $res = modMul($res, $n);
    return $res;
}

// 階乗
function modFac($n)
{
    if ($n === 0) return 1;
    return modMul($n, modFac($n - 1));
}

// 順列
function nPr($n, $r)
{
    if ($r === 0) return 1;
    return modMul(nPr($n, $r - 1), $n - $r + 1);
}

// 組み合わせ
function nCr($n, $r)
{
    $r = min($r, $n - $r);
    if ($r === 0) return 1;
    return modDiv(nPr($n, $r), modFac($r));
}

// 階乗、逆元を前処理
function init($n)
{
    global $fact, $ifact;
    $fact[0] = 1;
    for ($i = 1; $i <= $n; ++$i) $fact[$i] = modMul($fact[$i - 1], $i);
    $ifact[$n] = modDiv(1, $fact[$n]);
    for ($i = $n; $i >= 1; --$i)
        $ifact[$i - 1] = modMul($ifact[$i], $i);
}
// 順列（前処理）
function nPr2($n, $r)
{
    global $fact, $ifact;
    return modMul($fact[$n], $ifact[$n - $r]);
}
// 組み合わせ（前処理）
function nCr2($n, $r)
{
    global $fact, $ifact;
    return modMul(modMul($fact[$n], $ifact[$r]), $ifact[$n - $r]);
}


Measured memory_bytes: 53324
#初期値の入力
import math
standard_deviation = list()

while True:
    student_number = int(input())
    if student_number == 0:
        break
    score_data = list(map(float, input().split()))
    #平均値計算
    score_ave = sum(score_data) / len(score_data)
    score_dispersion = float()
    for data in score_data:
        #偏差を求め分散のための2乗計算
        score_dispersion += (data - score_ave) ** 2
    #分散を求め標準偏差計算
    standard_deviation.append(math.sqrt(score_dispersion / len(score_data)))

#結果表示
for i in standard_deviation:
    print(f"{i:.8f}")



Measured memory_bytes: 5784
#include <cstdio>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 99999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight capacity, cost;
  Edge(int src, int dst, Weight capacity, Weight cost) :
    src(src), dst(dst), capacity(capacity), cost(cost) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.cost != f.cost ? e.cost > f.cost : // !!INVERSE!!
    e.capacity != f.capacity ? e.capacity > f.capacity : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

#define RESIDUE(u,v) (capacity[u][v] - flow[u][v])
#define RCOST(u,v) (cost[u][v] + h[u] - h[v])
pair<Weight, Weight> minimumCostFlow(const Graph &g, int s, int t, Weight F=INF) {
  const int n = g.size();
  Matrix capacity(n, Array(n)), cost(n, Array(n)), flow(n, Array(n));
  REP(u,n) FOR(e,g[u]) {
    capacity[e->src][e->dst] += e->capacity;
    cost[e->src][e->dst] += e->cost;
  }
  pair<Weight, Weight> total; // (cost, flow)
  vector<Weight> h(n);

  for (; F > 0; ) { // residual flow
    vector<Weight> d(n, INF); d[s] = 0;
    vector<int> p(n, -1);
    priority_queue<Edge> Q; // "e < f" <=> "e.cost > f.cost"
    for (Q.push(Edge(-2, s, 0, 0)); !Q.empty(); ) {
      Edge e = Q.top(); Q.pop();
      if (p[e.dst] != -1) continue;
      p[e.dst] = e.src;
      FOR(f, g[e.dst]) if (RESIDUE(f->src, f->dst) > 0) {
        if (d[f->dst] > d[f->src] + RCOST(f->src, f->dst)) {
          d[f->dst] = d[f->src] + RCOST(f->src, f->dst);
          Q.push( Edge(f->src, f->dst, 0, d[f->dst]) );
        }
      }
    }
    if (p[t] == -1) break;

    Weight f = F;
    for (int u = t; u != s; u = p[u])
      f = min(f, RESIDUE(p[u], u));
    for (int u = t; u != s; u = p[u]) {
      total.first += f * cost[p[u]][u];
      flow[p[u]][u] += f; flow[u][p[u]] -= f;
    }
    F -= f;
    total.second += f;
    REP(u, n) h[u] += d[u];
  }
  return total;
}

int main(){
	int i,V,E,F,s,t,e,f;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d%d",&V,&E,&F);
		Graph g(V);
		for(;E--;)scanf("%d%d%d%d",&s,&t,&e,&f),g[s].push_back(Edge(s,t,e,f)),g[t].push_back(Edge(t,s,0,-f));
		pair<int,int> p=minimumCostFlow(g,0,V-1,F);
		printf("%d\n",p.second<F ? -1 : p.first);
	//}
}

Measured memory_bytes: 1228
#include<stdio.h>
#include<string.h>
#include<math.h>
#include<stdlib.h>
#include<limits.h>

#define rep(i,begin,end) for(int i=begin; i<end; i++)
#define revrep(i,begin,end) for(int i=begin; i>end; i--)
#define lld long long int

int main(){
    lld h;
    scanf("%lld", &h);
    lld ans = 0;
    lld buf = 1;
    while(h > 0){
        ans += buf;
        buf *= 2;
        h /= 2;
    }
    printf("%lld", ans);

    return 0;
}

Measured memory_bytes: 128
import sys
a, b, c, k = [int(k) for k in input().split()]
r = 0
while k > 0:
    if k >= a:
        r += a
        k -= a
    else:
        r += k
        k -= k
        continue
    if k >= b:
        k -= b
    else:
        k -= k
    if k >= c:
        r -= c
        k -= c
    else:
        r -= k
        k -= k

print(r)


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

int main() {

    // 1. input.
    long long a, b;
    cin >> a >> b;
    
    // 2. calculate the number of divisors.
    long long d = a / b;
    long long  r = a % b;
    double f = (a + 0.0) / b;
    
    // 3. output answer.
    cout << fixed;
    cout << setprecision(10) << d << " " << r << " " << f << endl;
    return 0;
    
}


Measured memory_bytes: 3272
import java.util.Scanner;

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

		int N = sc.nextInt();   //標準入力
		String Ns = Integer.toString(N) ;   //IntをStringに変換する

		int fx = 0;   //合計を初期化
		String ans = "No" ;   //解答の出力

		for(int i = 0; i < Ns.length(); i++) {   //リストの中身を合計する
			fx += Integer.parseInt(Ns.substring(i, i + 1));   //NsをStringからIntに変換する
		}

		if ( N % fx == 0 ) {
			ans = "Yes" ;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 23124
#include <iostream>
#include <string>
#include <cstdio>
#include <vector>
#include <stdio.h>
#include <algorithm>
#include <functional>
#include <queue>
#include <math.h>
#include <cmath>
#include <unordered_map>

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


const long long MOD = 1000000007;


// Generated by 1.1.7.1 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
int main(){
    long long N;
    scanf("%lld",&N);
    std::vector<long long> A(N);
    std::vector<long long> sum(N,0);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        if(i==0){
            sum[i]=A[i];
        }else{
            sum[i]=sum[i-1]+A[i];
        }
        //cout<<sum[i]<<endl;
    }


    long long ans=0;
    long long tmp=0;
    rep(i,N){
        tmp=(sum[N-1]-sum[i])%MOD;
        
        ans+=(tmp*A[i]);
        ans%=MOD;
    }
    cout<<ans%MOD<<endl;
    return 0;
}


Measured memory_bytes: 6436
#include <cstdio>
#include <vector>
#include <map>
#include <cstring>
#include <iostream>
#define fi first
#define sec second
using namespace std;
typedef pair<int,int> P;

int n, m;
int S;
int ans;
int cell[10][10];
int dy[4] = {1,0,-1,0}, dx[4] = {0,1,0,-1};
int used;
map<P,int> dp;
vector<int> e[30][4]; //0 down 1 right 2 up 3 left
vector<P> num;

int A(int s,int cnt){
	/*
	if(dp[P(used,s)] > 0){
		return dp[P(used,s)];
	}
	*/
	int ret = 0;
	cnt--;
	if(cnt == 0){
		for(int i = 0; i < 4; i++){
			for(int j = 0; j < e[s][i].size(); j++){
				if(e[s][i][j] == S) ret++;
			}
		}
		//dp[P(used,s)] = ret;
		return ret;
	}
	if(s != S) used += 1<<s;
	for(int i = 0; i < 4; i++){
		for(int j = 0; j < e[s][i].size(); j++){
			if(used>>e[s][i][j] & 1) continue;
			if(e[s][i][j] == S) continue;
			ret += A(e[s][i][j],cnt);
			break;
		}
	}
	if(s != S) used -= 1<<s;
	//dp[P(used,s)] = ret;
	return ret;
}

void solve(){
	ans = 0;
	num.clear();
	used = 0;
	dp.clear();
	for(int i = 0; i < 30; i++){
		for(int j = 0; j < 4; j++){
			e[i][j].clear();
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			scanf("%d", &cell[i][j]);
			if(cell[i][j] != 0){
				if(cell[i][j] == 2) S = num.size();
				num.push_back(P(i,j));
			}
		}
	}
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			if(cell[i][j] == 0) continue;
			int tmp;
			for(int k = 0; k < num.size(); k++){
				if(num[k].fi == i && num[k].sec == j){
					tmp = k;
					break;
				}
			}
			for(int k = 0; k < 4; k++){
				int y = i, x = j;
				while(true){
					y += dy[k]; x += dx[k];
					if(0>y||y>=n||0>x||x>=m) break;
					if(cell[y][x] != 0){
						for(int l = 0; l < num.size(); l++){
							if(num[l].fi == y && num[l].sec == x){
								e[tmp][k].push_back(l);
								break;
							}
						}
					}
				}
			}
		}
	}
	ans = A(S,num.size());
	printf("%d\n", ans);
}

int main(){
	while(scanf("%d%d", &m, &n),n||m) solve();
}

Measured memory_bytes: 1216
open System.Collections.Generic

type Scanner() = class
    let mutable hold = [||]
    let mutable index = 0
    member public this.Next() =
        if hold.Length > index
        then 
            index <- index + 1
            hold.[index - 1]
        else
            let mutable st = stdin.ReadLine()
            while st = "" do st <- stdin.ReadLine()
            hold <- st.Split(' ')
            if hold.Length = 0
            then
                this.Next()
            else
                index <- 1
                hold.[index - 1]
            
    member public this.NextI32() =
        this.Next() |> int

    member public this.ArrayI32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI32()|]

    member public this.IArrayI32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI32(), i|]

    member public this.NextI64() =
        this.Next() |> int64
    
    member public this.ArrayI64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextI64()|]

    member public this.IArrayI64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextI64(), i|]

    member public this.NextF32() =
        this.Next() |> float32
    
    member public this.ArrayF32(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF32()|]

    member public this.IArrayF32(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF32(), i|]

    member public this.NextF64() =
        this.Next() |> double
    
    member public this.ArrayF64(n: int) =
        [|for _ in 0 .. n - 1 -> this.NextF64()|]

    member public this.IArrayF64(n: int) =
        [|for i in 0 .. n - 1 -> this.NextF64(), i|]

    member public __.Tuple2Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 2 |> fun x -> x.[0], x.[1]|]
    
    member public __.Tuple3Array n (f : int -> 'a list) =
        [|for _ in 0 .. n - 1 -> f 3 |> fun x -> x.[0], x.[1], x.[2]|]

    member public __.CountDic n (f : unit -> 'a) =
        let seqs = seq {for _ in 0 .. n - 1 -> f()}
        let dic = new Dictionary<'a, int64>();
        for i in seqs do
            if dic.ContainsKey(i)
            then dic.[i] <- dic.[i] + 1L
            else dic.Add(i, 1L)
        dic

end

[<EntryPoint>]
let main _ =
#if DEBUG
    printfn "debuged"
#endif

    let scanner = Scanner()
    let f a = (a * (a - 1L)) / 2L
    let n = scanner.NextI32()
    let arrA = scanner.ArrayI32(n)
    let bx: int64 array = Array.zeroCreate n
    for i in arrA do bx.[i-1] <- bx.[i-1] + 1L
    let sums = Array.fold (fun acc x -> acc + f x) 0L bx

    for i in 0..n-1 do
        let a = bx.[arrA.[i] - 1] - 1L
        sums - a
        |> printfn "%i"

    0


Measured memory_bytes: 35804
# Template 1.0
import sys, re
from collections import deque, defaultdict, Counter, OrderedDict
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians, log,floor
from heapq import heappush, heappop, heapify, nlargest, nsmallest
def STR(): return list(input())
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def list2d(a, b, c): return [[c] * b for i in range(a)]
def sortListWithIndex(listOfTuples, idx):   return (sorted(listOfTuples, key=lambda x: x[idx]))
def sortDictWithVal(passedDic):
    temp = sorted(passedDic.items(), key=lambda kv: (kv[1], kv[0]))
    toret = {}
    for tup in temp:
        toret[tup[0]] = tup[1]
    return toret
def sortDictWithKey(passedDic):
    return dict(OrderedDict(sorted(passedDic.items())))
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

n = INT()
tillnow = 0
for _ in range(n):
    a,b = MAP()

    if(a==b):
        tillnow+=1
    else:
        tillnow = 0
    if(tillnow==3):
        print("Yes")
        exit()
print('No')

Measured memory_bytes: 68300
#include <iostream>
#include <algorithm>
#include <vector>
#include <cmath>
#include <queue>
#include <map>

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

#define debug(vec) for(auto v : vec) cout << v << " "; cout << endl;

#define debug2D(vec2D) for(auto vec : vec2D) { for (auto v : vec) cout << v << " "; cout << endl; } 

using namespace std;

typedef long long ll;

const long long int INF = 1 << 29; //<10^10
//const ll MOD = 998244353;
const ll MOD = 1000000007;

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

  ll h,w,n;
	cin >> h >> w >> n;

	int x = max(h,w);

	std::cout << 1 + (n-1) / x << " ";
}


Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int a;
	int b;
	int c;
	int i;
	int o;
	
	
	scanf("%d %d %d",&a,&b,&c);
	
	o=0;
	
	for (i=a; i <= b; i++){
		if (c%i==0){
			o++;
		}
	}
	printf("%d\n",o);
	
	return (0);
}

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

#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
template<typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

#define F first
#define S second
#define pb push_back
#define pii pair <int, int>
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ld long double
#define int long long

void SOLVE(){
    int n, m;
    cin >> n >> m;
    int t = (n + m - 1) / m;
    cout << t << '\n';
}

signed main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    cout << fixed << setprecision(12);
    int Q = 1;
    //cin >> Q;
    while (Q--){
        SOLVE();
    }

    return 0;
}


Measured memory_bytes: 256
N=int(input())
for i in range(N//4+1):
  if (N%(4*(i+1)))%7==0:
    print("Yes")
    break
else:
  for j in range(N//7+1):
    if (N%(7*(j+1)))%4==0:
      print("Yes")
      break
  else:
    if N%4==0 or N%7==0:
      print("Yes")
    else:
      print("No")

Measured memory_bytes: 9100
/*Enter your code here. Read input from STDIN. Print your output to STDOUT*/
#include <bits/stdc++.h>
using namespace std;
#define endl "\n";
#define int long long
#define fastio ios_base::sync_with_stdio(0); cin.tie(0)
#define maxN 1000000

int32_t main()
{
    fastio;
    
    int n; cin >> n;
    vector<int> a(n); for(auto &x: a) cin >> x;

    int dp[n][n];
    for(int L=n-1; L>=0; L--){
        for(int R=L; R<n; R++){
            if(L == R) dp[L][R] = a[L];
            else dp[L][R] = max(a[L]-dp[L+1][R], a[R]-dp[L][R-1]);
        }
    }

    cout << dp[0][n-1] << endl;
    
    return 0;   
}
    


Measured memory_bytes: 46464
#include "bits/stdc++.h"

/************* Using *************/
using namespace std;
using ll = long long;
using pll = pair<ll, ll>;
using graph_t = vector<vector<ll>>;

/*********** Constants ***********/
const auto INF  = static_cast<int>(1e10);
const auto INFL = static_cast<ll>(1e18);
const auto MOD  = static_cast<ll>(1e9 + 7);
const auto NIL  = nullptr;

/*********** Variables ***********/
ll R;

/************* Utils *************/

/*********** Functions ***********/
bool init() {
    cin >> R;
    return true;
}

void solve() {
}

void output() {
    cout << 3 * R * R << endl;
}

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


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define endl "\n"
#define int long long

const int N = 2e5 + 5;

int n, ans = 0;
int a[N];

int32_t main()
{
	IOS;
	cin >> n;
	int cur = 1;
	for(int i = 1; i <= n; i++)
	{
		cin >> a[i];
		if(a[i] != cur)
			ans++;
		else
			cur++;
	}
	if(ans == n)
		ans = -1;
	cout << ans;
	return 0;
}

Measured memory_bytes: 1792
n=int(input())
s=input()

ans=0

for i in range(10):
	a=s.find(str(i))
	if a == -1:
		continue
	else:
		for j in range(10):
			b=s.find(str(j),a+1)
			if b==-1:
				continue
			else:
				for k in range(10):
					c=s.find(str(k),b+1)
					if c==-1:
						continue
					else:
						ans+=1
						
print(ans)
						
					

Measured memory_bytes: 3060
n=int(input())
A=list(map(int,input().split()))
ans=10**30
for t in range(2):
    a=0
    s=0
    for i in range(n):
        a+=A[i]
        if t and a<=0:
            s+=-a+1
            a=1
            t=0
        elif not(t) and a>=0:
            s+=a+1
            a=-1
            t=1
        else:
            t=1-t
    ans=min(s,ans)
print(ans)


Measured memory_bytes: 63984
#include <stdbool.h>
#include <stdio.h>
#include <stdlib.h>
#include <inttypes.h>
#include <ctype.h>
#include <stdint.h>
#include <string.h>
#include <wchar.h>

#define N_MAX (100)
#define P_MAX (100)
#define DP_ARRAY_SIZE (N_MAX * P_MAX / 32 + 1)

#define MIN(a, b) ((a) < (b) ? (a) : (b))
#define MAX(a, b) ((a) > (b) ? (a) : (b))
#define ABS(a) ((a) < 0 ? -(a) : (a))
#define ABSS(a, b) ((a) > (b) ? (a) - (b) : (b) - (a))

int compare_f(const void *a, const void *b) {
	return *((int64_t *)a) < *((int64_t *)b) ? -1 : 1;
}

int compare_f2(const void *a, const void *b) {
	return *((uint64_t *)a) > *((uint64_t *)b) ? -1 : 1;
}

static size_t comb(const size_t n, const size_t r) {
	size_t result = 1;

	for (size_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t combU64(const uint64_t n, const uint64_t r) {
	uint64_t result = 1;

	for (uint64_t i = 0; i < r; i++) {
		result *= n - i;
		result /= i + 1;
	}

	return result;
}

static uint64_t gcd(uint64_t m, uint64_t n)
{
	uint64_t temp;

	while (m%n != 0) {
		temp = n;
		n = m % n;
		m = temp;
	}

	return n;
}

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

	scanf("%zu %zu %zu", &a, &b, &c);

	puts((a + b == c || b + c == a || c + a == b ? "Yes" : "No"));

	return 0;
}


Measured memory_bytes: 128
#include <algorithm>
#include <bitset>
#include <cassert>
#include <cmath>
#include <ctime>
#include <cstring>
#include <functional>
#include <iostream>
#include <iomanip>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <regex>
#include <vector>

#define fix(n)          cout<<fixed<<setprecision(n)
#define rep(i,n)        for (int i = 0; i < (n); ++i)
#define sort(a)         sort((a).begin(), (a).end())
#define uniq(a)         sort(a);(a).erase(unique((a).begin(), (a).end()), (a).end())
#define reverse(a)      reverse((a).begin(), (a).end())
#define ctos(c)         string(1, (c))
#define out(d)          cout << (d)
#define outl(d)         std::cout<<(d)<<"\n"
#define YES()           cout << "YES" << endl
#define NO()            cout << "NO" << endl
#define Yes()           cout << "Yes" << endl
#define No()            cout << "No" << endl
#define ceil(x, y)      ((x + y - 1) / (y))
#define debug(x)        cerr << #x << ": " << (x) << '\n'
#define debug2(x, y)    cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << '\n'
#define debug3(x, y, z) cerr << #x << ": " << (x) << ", " << #y << ": " << (y) << ", " << #z << ": " << (z) << '\n'
#define dbg(v)          for (size_t _ = 0; _ < v.size(); ++_){ cerr << #v << "[" << _ << "] : " << v[_] << '\n'; }

using namespace std;
using ll = long long;
using ld = long double;
using P = pair<ll,ll>;

const ll MOD = 1000000007; // 10^9 + 7
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

void solve() {
  int h, w; cin >> h >> w;
  vector<string> a(h);
  int cnt = 0;
  rep(i, h) {
    cin >> a[i];
    for (int j = 0; j < w; j++)
      if (a[i][j] == '#') cnt++;
  }
  // debug(cnt);
  int i = 0, j = 0, c = 1;
  while (true) {
    if (i == h - 1 && j == w - 1) {
      if (c == cnt) outl("Possible");
      else outl("Impossible");
      return;
    }

    if (j + 1 < w && a[i][j + 1] == '#') {
      j += 1;
      c++;
    } else if (i + 1 < h && a[i + 1][j] == '#') {
      i += 1;
      c++;
    } else {
      outl("Impossible");
      return;
    }
  }
}

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  srand((unsigned)time(NULL));
  fix(12);

  solve();
}


Measured memory_bytes: 380
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define P pair<int, int>
#define debug(x) cout << #x << ": " << x << ", "
#define debugln(x) cout << #x << ": " << x << '\n'

using namespace std;
using ll = long long;
const int mod = 1e9+7;

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

  string s;
  string t;
  cin >> s >> t;
  int q; cin >> q;

  int ssize = s.size();
  vector<int> ss(ssize+1);
  rep(i, ssize) {
    if (s.at(i) == 'A') {
      ss.at(i+1) = ss.at(i) + 1;
    } else {
      ss.at(i+1) = ss.at(i) - 1;
    }
  }


  int tsize = t.size();
  vector<int> tt(tsize+1);
  rep(i, tsize) {
    if (t.at(i) == 'A') {
      tt.at(i+1) = tt.at(i) + 1;
    } else {
      tt.at(i+1) = tt.at(i) - 1;
    }
  }

  rep(i, q) {
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int s3 = ss.at(b) - ss.at(a-1);
    int t3 = tt.at(d) - tt.at(c-1);
    if (abs(s3-t3) % 3 == 0) {
      cout << "YES" << '\n';
    } else {
      cout << "NO" << '\n';
    }
  }
}

Measured memory_bytes: 1744
#include <bits/stdc++.h>
using namespace std;
int cmp(string ca, string cb) { return ca[1] - cb[1]; }
int bubbleSort(vector<string> &v) {
  int tot = 0;
  for (int i = 0, n = v.size(); i < n; i++) {
    bool isSorted = true;
    for (int j = n - 1; j > i; j--) {
      if (cmp(v[j], v[j - 1]) < 0) {
        isSorted = false;
        swap(v[j], v[j - 1]);
        ++tot;
      }
    }
    if (isSorted) break;
  }
  return tot;
}
int selectionSort(vector<string> &v) {
  int tot = 0;
  for (int i = 0, n = v.size(); i < n; i++) {
    int k = i;
    for (int j = i; j < n; j++) {
      if (cmp(v[j], v[k]) < 0) {
        k = j;
      }
    }
    if (k != i) {
      ++tot;
      swap(v[k], v[i]);
    }
  }
  return tot;
}
template <typename T>
void print(vector<T> &v) {
  cout << v[0];
  for (size_t i = 1; i < v.size(); i++) cout << " " << v[i];
  cout << endl;
}
int main(int argc, char const *argv[]) {
  int n;
  cin >> n;
  vector<string> v(n);
  for (auto &e : v) cin >> e;
  vector<string> w(v);
  bubbleSort(v);
  print(v);
  cout << "Stable" << endl;
  selectionSort(w);
  print(w);
  if (w == v)
    cout << "Stable" << endl;
  else
    cout << "Not stable" << endl;

  return 0;
}



Measured memory_bytes: 3168
#include <algorithm>
#include <bits/stdc++.h>
#include <bitset>
#include <cassert>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <math.h>
#include <memory>
#include <queue>
#include <set>
#include <stack>
#include <utility>
#include <vector>
using namespace std;
#define REP(i, n) for (int64_t i = 0; i < (int64_t)n; i++)
#define REP_FOR(i, a, b) for (int64_t i = (int64_t)a; i < (int64_t)b; i++)
#define REP_REV(i, a, b) for (int64_t i = (int64_t)a; i > (int64_t)b; i--)
#define FORALL(v) (v).begin(), (v).end()
#define mp(a, b) make_pair(a, b)
#define eb(x) emplace_back(x)
#define F first
#define S second
typedef long long ll;
typedef long double ld;
typedef pair<int64_t, int64_t> pii;
typedef pair<ll, ll> pll;
typedef pair<ld, ld> pdd;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<int64_t> vii;
typedef vector<vii> vvii;
const ll mod = 1e9 + 7;
const int64_t infi = 1147483600;
const ll infl = 4e18 + 5;
const char EOL = '\n';
//cout << fixed << setprecision(17) << res << endl;
const ll MOD = 998244353;

int main() {
    ll n;
    cin >> n;
    ll res = 0;
    ll mprice = 0;
    for (ll i = 0; i < n; ++i) {
        ll p;
        cin >> p;
        res += p;
        mprice = max(mprice, p);
    }
    res -= mprice / 2;
    cout << res << endl;
}


Measured memory_bytes: 256
input = STDIN.gets.split('').map(&:to_i)

ret = "No"
input.each_with_index do |item,i|
  if i == 1 || i == 2
    if item == input[i-1] && item == input[i+1]
      ret = "Yes"
      break
    end
  end
end

STDOUT.puts ret

Measured memory_bytes: 1916
//Muhamad Syahreza Trihatmanto
#include <bits/stdc++.h>
using namespace std;

int N;
bool ada = false;

int main (){
    cin >> N;
    for(int r=1; r<=9; r++){
        for(int z=1; z<=9; z++){
            if(r*z == N){
                ada = true;
            }
        }
    }
    if(ada) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}

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

#define for_(i,a,b) for(int i=a;i<b;++i)
#define for_rev(i,a,b) for(int i=a;i>=b;--i)
#define rep(i,n) for(int i=0;i<(n);++i)
#define allof(a) a.begin(),a.end()
#define minit(a,b) memset(a,b,sizeof(a))
#define size_of(a) (int)a.size()

typedef long long lint;
typedef double Double;
typedef pair< int, int > pii;

int N, M, col[110], ans[110];

int main() {
	minit(col, 0);
	
	cin >> N >> M;
	
	for_(i,0,M) {
		int a, l;
		cin >> a >> l;
		for_(j,0,l) col[(a + j) % N] = 1;
	}
	
	minit(ans, 0);
	
	for_(i,0,N) {
		if (col[i]) {
			int len = 0, s = i, t = i + 1;
			
			while (col[s]) {
				col[s] = 0;
				++len;
				s = (s - 1 + N) % N;
			}
			
			while (col[t]) {
				col[t] = 0;
				++len;
				t = (t + 1) % N;
			}
			
			++ans[len];
		}
	}
	
	for_rev(i,105,1) if (ans[i] > 0) cout << i << " " << ans[i] << endl;
}


Measured memory_bytes: 1160
// --------------------<optimizations>--------------------
#pragma GCC optimize("O3")
//(UNCOMMENT WHEN HAVING LOTS OF RECURSIONS)
#pragma comment(linker, "/stack:200000000")
//(UNCOMMENT WHEN TRYING TO BRUTEFORCE WITH A LOT OF LOOPS)
#pragma GCC optimize("unroll-loops")
// -------------------</optimizations>--------------------
 
#include <bits/stdc++.h>
 
using namespace std;
 
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define all(v) (v).begin(),(v).end()
#define f first
#define s second
#define sz(x) ll(x.size())
#define endl '\n'
#define forn(i,n) for(int i=0;i<n;++i)
#define fore(i,l,r) for(int i=int(l);i<=int(r);++i)
#define rep(i,begin,end) for(__typeof(end) i=(begin);i!=(end);i++)
#define fill(a,value) memset(a,value,sizeof(a));
#define gcd(a,b) __gcd((a),(b))
#define watch1(x) cout << (x) << endl
#define watch2(x,y) cout << (x) << " " << (y) << endl
#define watch3(x,y,z) cout << (x) << " " << (y) << " " << (z) << endl
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);
 
typedef long long ll;
typedef long double ld; 
typedef pair<ll,ll> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
 
const ll mod = 1e9 + 7;
const int inf = 1e9 + 5;
const int N = 2e5 + 5;

signed main(){
    fastio;
    int i,a,b;
    string s,t,u;
    cin>>s>>t>>a>>b>>u;
    if(u==s)
        cout<<a-1<<" "<<b;
    else
        cout<<a<<" "<<b-1;
    return 0;
}

Measured memory_bytes: 256
/*
 * Remember a 7.0 student can know more than a 10.0 student.
 * Grades don't determine intelligence, they test obedience. 
 * I Never Give Up.
 */
import java.util.*;
import java.util.Map.Entry;
import java.io.*;

import static java.lang.System.out;
import static java.util.Arrays.*;
import static java.lang.Math.*;
class Main {
	private static Reader in=new Reader();
	private static StringBuilder ans=new StringBuilder();
	private static long MOD=1000000007;//10^9+7 
	private static final int N=1000000;//10^6
	private static final int LIM=26;
//	private static final double PI=3.1415;
//	private static ArrayList<Integer> v[]=new ArrayList[N];
//	private static int color[]=new int[N]; //For Graph Coloring
//	private static boolean mark[]=new boolean[N];
//	private static BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
//	private static void dfs(int node){mark[node]=true;for(int x:v[node]){if(!mark[x]){dfs(x);}}}
	private static long powmod(long x,long n,long m){
		if(n==0)return 1;
		else if(n%2==0)return(powmod((x*x)%m,n/2,m));
		else return (x*(powmod((x*x)%m,(n-1)/2,m)))%m;
	}
//	private static void shuffle(String[] arr) {
//		for (int i = arr.length - 1; i >= 2; i--) {
//			int x = new Random().nextInt(i - 1);
//	        String temp = arr[x];
//	        arr[x] = arr[i];
//	        arr[i] = temp;
//	    }
//	 }
	//OJ Doing = Codeforces
	//Double check the code
	public static void main(String[] args) throws IOException{
		String s=in.next();
		int cnt=0;
		for(int i=0;i<s.length();i++){
			if(s.charAt(i)=='+')cnt++;
			else cnt--;
		}
		out.println(cnt);
	}
	static class Pair implements Comparable<Pair>{
		long l;
		long r;
		Pair(){
			l=0;
			r=0;
		}
		Pair(long k,long v){
			l=k;
			r=v;
		}
		@Override
		public int compareTo(Pair o) {
			if(l!=o.l)return (int) (l-o.l);
			else return (int) -(r-o.r);  //changed
		}
		
	}
	static class Reader{
        BufferedReader br;
        StringTokenizer st;
        public Reader()
        {
            br = new BufferedReader(new
                     InputStreamReader(System.in));
        }
 
        String next()
        {
            while (st == null || !st.hasMoreElements())
            {
                try
                {
                    st = new StringTokenizer(br.readLine());
                }
                catch (IOException  e)
                {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        int nextInt()
        {
            return Integer.parseInt(next());
        }
 
        long nextLong()
        {
            return Long.parseLong(next());
        }
 
        double nextDouble()
        {
            return Double.parseDouble(next());
        }
 
        String nextLine()
        {
            String str = "";
            try
            {
                str = br.readLine();
            }
            catch (IOException e)
            {
                e.printStackTrace();
            }
            return str;
        }
    }
}         

Measured memory_bytes: 21204
N=int(input())
S=input().split()
for i in range(0,N):
    s=int(S[i])
    if 1<=s<=399:
        S[i]="a"
    if 400<=s<=799:
        S[i]="b"
    if 800<=s<=1199:
        S[i]="c"
    if 1200<=s<=1599:
        S[i]="d"
    if 1600<=s<=1999:
        S[i]="e"
    if 2000<=s<=2399:
        S[i]="f"
    if 2400<=s<=2799:
        S[i]="g"
    if 2800<=s<=3199:
        S[i]="h"
    if 3200<=s:
        S[i]="i"

if "i" in S:
    i=S.count("i")
    B=len(set(S))
    if B==1:
        C=1
        D=N
    else:
        C=B-1
        D=C+i
    
else:
    C=len(set(S))
    D=C

print(C,D)
    

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

using namespace std;

const int INF = 1e9;
const int N = 1e5;
const int MOD = 1e9 + 7;

const double PI = acos(-1);



int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0), cout.tie(0);
    long long n, a, b;
    cin >> n >> a >> b;
    long long ans = 0;
    if ((b - a) % 2 == 0) {
        ans = (b - a) / 2;
    } else {
        if (a - 1 < n - b) {
            ans = a - 1 + (b - (a - 1) - 1) / 2 + 1;
        } else {
            ans = n - b + (n - (a + n - b + 1)) / 2 + 1;
        }
    }
    cout << ans;
}


Measured memory_bytes: 256
extern crate proconio;
use proconio::input;
fn main() {
    input!{
        n: usize,
        arr: [u64; n],
    }

    let mut t = SegmentTree::new(n, 0, &arr);
    let mut ans = 0;

    // t.debug();
    for i in 0..n {
        t.update_number(i, 0);
        ans = std::cmp::max(t.get(0, n), ans);
        // t.debug();
        t.update_number(i, arr[i]);
        // t.debug();
    }

    println!("{}", ans);
}

pub fn cmpfn(l: u64, r: u64) -> u64 {
    num::integer::gcd(l, r)
}

struct SegmentTree {
    e: u64,
    size: usize,
    tree: Vec<u64>,
}
impl SegmentTree {
    /// 値の初期化
    pub fn new(n: usize, e: u64, arr: &[u64]) -> SegmentTree {
        let mut size: usize = 1;
        while size < n  {
            size <<= 1;
        }
        let mut tree: Vec<u64> = Vec::<u64>::with_capacity(2*size);
        for _ in 0..2*size {
            tree.push(e);
        }
        for (i, val) in arr.iter().enumerate() {
            tree[size + i] = *val;
        }

        for i in (1..size).map(|x| size-x) {
            tree[i] = cmpfn(tree[2*i], tree[2*i+1]);
        }

        SegmentTree{
            e,
            size,
            tree,
        }
    }

    /// indexの値をnumで更新する.
    pub fn update_number(&mut self, mut index: usize, num: u64) {
        self.tree[index + self.size] = num;
        index = (index + self.size) / 2;
        while index > 0 {
            self.tree[index] = cmpfn(self.tree[2*index], self.tree[2*index+1]);
            index >>= 1;
        }
    }

    /// [l, r)での範囲の答えを得る.
    pub fn get(&self, l: usize, r:usize) -> u64 {
        // println!("{}, {}, {}", self.size, l, r);
        self.rec(0,self.size,l,r)
    }

    fn rec(&self, min: usize, max: usize, l: usize, r:usize) -> u64 {
        let mid = (min + max)/2;
        if l == min && r == max {
            return self.tree[self.size/(r-l) + l/(r-l)];
        }

        if l < mid && mid < r{
            cmpfn(self.rec(min, mid, l, mid) , self.rec(mid, max, mid, r))
        }else if mid <= l {
            self.rec(mid, max, l, r)
        }else if r <= mid {
            self.rec(min, mid, l, r)
        }else{
            0
        }
    }

    fn debug(&self){
        println!("{:?}", self.tree);
    }
}


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


// typedef tree<int, null_type, less<int>, rb_tree_tag,tree_order_statistics_node_update>  ordered_set;
#define ll long long
 
#define fr(i,a,b) for (ll i = (a), _b = (b); i <= _b; i++)
#define frr(i,a,b) for (ll i = (a), _b = (b); i >= _b; i--)
#define rep(i,n) for (ll i = 0, _n = (n); i < _n; i++)
#define repr(i,n) for (ll i = n - 1; i >= 0; i--)
#define fill(ar,val) memset(ar, val, sizeof(ar))
#define fill0(ar) fill((ar), 0)
#define debug(x) cout<<#x<<": "<<x<<endl
 
#define ld long double
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
 
typedef pair<int, int> ii;
typedef pair<ii, int> iii;
typedef vector<ii> vii;
typedef vector<int> vi;
ll dp[100005];
ll MOD=1000000007;
ll mark[100005];

    vector<ll>v[100005];
    vector<ll>v1[100005];
    ll n1;
#define INF 1000000000000000000
ll dfs(ll n)
{
    mark[n]=1;
    ll x=0;

    rep(i,v[n].size())
    {
        if(!mark[v[n][i]])
        {
            v1[n].pb(v[n][i]);
            dfs(v[n][i]);
            x++;
        }
    }
    // debug(n);
    // debug(x);
    if(!x)
    {
        dp[n]=2;
    }
}
ll fn(ll n)
{
    // debug(n);
    if(n<=0||n>n1)
        return 0;
    if(dp[n]!=-1)
    {
        return dp[n];
    }
    ll x=1;ll y=1;
    rep(i,v1[n].size())
    {
        x=(x*fn(v1[n][i]))%MOD;
        ll z=v1[n][i];
        rep(j,v1[z].size())
        {
            y=(y*fn(v1[z][j]))%MOD;
        }
    }
    if(y==0)
        y++;
    // debug(x);
    // debug(y);
    return dp[n]=(x+y)%MOD;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout<<setprecision(11);
    long double pi= 3.14159265358979323846;
    // ll n;
    ll k;
    cin>>n1;
    rep(i,100005)
    {
        dp[i]=-1;
    }
    rep(i,n1-1)
    {
        ll a,b;
        cin>>a>>b;
        v[a].pb(b);
        v[b].pb(a);
    }
    dfs(1);
    rep(i,3)
    {
        // debug(dp[i+1]);
    }
    cout<<fn(1);

    return 0;
}

Measured memory_bytes: 21120