akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include<iomanip>
#include<sstream>

using namespace std;
using ll = long long;
constexpr int mod = 1e9+7;
constexpr int md = mod;
vector<ll> ret;
int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    int n,m;
    cin>>n>>m;
    vector<vector<ll>> pv(n+1);
    vector<ll> cp(m),cv(m);
    for(int i=0;i<m;++i){
        int p,v;
        cin>>p>>v;
        cp[i] = p;
        cv[i] = v;
        pv[p].push_back(v);
    }
    for(int i=1;i<=n;++i)if(!pv[i].empty())sort(pv[i].begin(),pv[i].end());
    for(int i=0;i<m;++i){
                    cout << setfill('0') << right << setw(12) << cp[i]*1000000+(int)(lower_bound(pv[cp[i]].begin(),pv[cp[i]].end(),cv[i])-pv[cp[i]].begin()+1 )<< endl;

    }
    return 0;
}



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

int main(){
  int N;
  string s;
  int r=0;
  cin >> N >> s;
  for(int i=0; i<N; i++){
    if(s[i]=='R') r++;
  }
  if(r>N-r){
    cout << "Yes" << endl;
    return 0;
  }
  cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <set>
#include <vector>
#include <cmath>
#include <bitset>
#include <functional>
#include <limits>
#include <map>
using namespace std;

    typedef long long ll;
    #define rep1(i, n) for(ll i = 1; i <=(ll)(n); i++)
    #define rep0(i, n) for(ll i = 0; i <=(ll)(n); i++)

    ll pow(ll a, ll n) { //compute a^n with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a;
            a = a * a;
            n >>= 1;
        }
        return res;
    }

    ll pow(ll a, ll n, ll mod) { //compute a^n (mod mod) with o(logn)
        ll res = 1;
        while (n > 0) {
            if (n & 1) res = res * a % mod;
            a = a * a % mod;
            n >>= 1;
        }
        return res;
    }

    int main(){
        ll n;
        cin >> n;
        if(n%1000 == 0){
            cout << n%1000 <<endl;
        }else{
            cout << 1000- n%1000 <<endl;
        }
        return 0;
    }

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

int main() {
    int a;
    ll b, n;
    cin >> a >> b >> n;
    ll x = b-1;
    if (x > n) x = n;
    ll floor1, floor2;
    floor1 = a*x / b;
    floor2 = x / b;
    ll ans = floor1 - a * floor2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3556
N, Y = map(int,input().split())
count = 0

for a in range(N + 1):
    for b in range(N + 1):
        c = N - (a + b)
        if isinstance(c, float) or c < 0:
            continue
        if Y == 10000*a + 5000*b + 1000*c:
            print(a,b,c)
            count += 1
            break
    else:
        continue
    break

if count == 0:
    print('-1 -1 -1 ')

Measured memory_bytes: 9104
#include<bits/stdc++.h>
using namespace std;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n;
    cin>>n;
    
    vector<int> a(n),b;
    
    for(int i=0; i<n; i++){
		cin>>a[i];
	}
	sort(a.begin(),a.end(),greater<int>());
	
	for(int i=0; i<n; i++){
		
		b.push_back(a[i]);
		if(i)
		  b.push_back(a[i]);
	}
	long long sum=0;
	for(int i=0; i<n-1; i++)
	   sum+=b[i];
	   
	cout<<sum<<endl;
	
}


Measured memory_bytes: 6072
from copy import deepcopy
from itertools import permutations


def warshallfloyd(N):  # ワーシャルフロイド法:全頂点対最短経路 O(n**3)
    DIST = deepcopy(mat)
    for k in range(N):
        for i in range(N):
            for j in range(N):
                DIST[i][j] = min(DIST[i][j], DIST[i][k] + DIST[k][j])
    return DIST


n, m, r = map(int, input().split())
town = list(map(int, input().split()))
abc = [list(map(int, input().split())) for _ in range(m)]

mat = [[10 ** 10] * n for _ in range(n)]
for i in range(n):
    mat[i][i] = 0
for a, b, c in abc:
    mat[a - 1][b - 1] = c
    mat[b - 1][a - 1] = c

ans = float('inf')
dist = warshallfloyd(n)
for route in permutations(town, r):
    bfo, tmp = route[0], 0
    for i in route[1:]:
        tmp += dist[bfo - 1][i - 1]
        bfo = i
    ans = min(ans, tmp)
print(ans)


Measured memory_bytes: 73492
let (%) = (lxor)
let () =
  Scanf.scanf "%d" @@ fun n ->
  let a = Array.init n (fun _ -> Scanf.scanf " %d" ((+) 0)) in
  let rec ext s i =
    if i >= n then (s, i)
    else if s%a.(i) <> s+a.(i) then (s, i)
    else ext (s+a.(i)) (i+1) in

  let rec loop v s l r =
    if l >= n then v else
      let s', r' = ext s r in
      loop (v + (r'-l)) (s'-a.(l)) (l+1) r'
  in loop 0 0 0 0
  |> Printf.printf "%d\n"

Measured memory_bytes: 6144
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <cmath>

using namespace std;

int main(){

    int n;
    cin >> n;
    vector<int> len(2 * n);
    for(int i = 0; i < 2 * n; i++){
        cin >> len[i];
    }
    
    sort(len.begin(), len.end());
    int ans = 0;
    for(int i = 0; i < 2 * n; i+= 2){
        ans += len[i];
    }

    cout << ans << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int v[100010];
int dp[100010];
int n,k;
int f(int i){
    if(i == 1) return 0;
    if(i == k) return abs(v[1]-v[k]);
    if(i <= 0) return 1e9;
    if(dp[i]!=-1) return dp[i];

    dp[i] = abs(v[i]-v[i-1])+f(i-1);
    for(int j = 2 ; j <=k ; j++){
        dp[i] = min(abs(v[i]-v[i-j])+f(i-j),dp[i]);
    }
    return dp[i];
}
int main(){
    memset(dp,-1,sizeof dp);
    memset(v,0,sizeof v);
    cin>>n>>k;
    for(int i = 1 ; i <= n ; i++) cin>>v[i];
    if(k>n) cout<<abs(v[1]-v[n])<<"\n";
    else cout<<f(n)<<"\n";
    return 0;
}


Measured memory_bytes: 5760
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;
import java.util.stream.IntStream;

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

        int N = scanner.nextInt();
//        boolean[][][] ans = new boolean[N][N][N];

        int cnt = 0;
        for (int i = 1; i < N; i++) {
            cnt += (N - 1) / i;
        }

        System.out.println(cnt);
    }

    public static List<Integer> calcDivisor(int a) {
        List<Integer> result = new ArrayList<>();

        // あまりforEach内でlist操作したくないけど
        IntStream.range(1, ((int) Math.pow(a, 0.5)) + 1).forEach(i -> {
            if (a % i == 0) {
                result.add(i);
                if (i != a / i) {
                    result.add(a / i);
                }
            }
        });

        return result;
    }

    public static List<Integer> calcPrimeFactor(int a) {
        List<Integer> result = new ArrayList<>();

        int tmp = a;
        for (int i = 2; i <= a && tmp != 1;) {
            if (tmp % i == 0) {
                result.add(i);
                tmp /= i;
            } else {
                i++;
            }
        }

        return result;
    }
}


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

int main() {
	int x,y;
	cin>>x>>y;
	if(x==1||x==3||x==5||x==7||x==8||x==10||x==12){
		if(y==1||y==3||y==5||y==7||y==8||y==10||y==12){
			cout<<"Yes"<<endl;
		}
		else{
			cout<<"No"<<endl;
		}
	}
	if(x==2){
		cout<<"No"<<endl;
	}
	if(x==4||x==6||x==9||x==11){
		if(y==4||y==6||y==9||y==11){
			cout<<"Yes"<<endl;
		}
		else{cout<<"No"<<endl;
	}
    }
}

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

using namespace std;

vector<int> v;

int main(){
    int n;
    cin >> n;
    if (n == 0){
        cout << 0 << endl;
        return 0;
    }
    while(n != 0){
        int r = n % -2;
        n /= -2;

        if (r == -1){
            r = 1;
            n += 1;
        }

        v.emplace_back(r);
    }

    reverse(v.begin(), v.end());
    for(auto i : v) cout << i;
    cout << endl;
}

Measured memory_bytes: 256
#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
using namespace std;
int main(){
    int n,d;
    cin >> n >> d;
    if(n<2*d){cout << 1 << endl;}
    else{
        for(int i=0; i<n; i++){
            if((d*2+1)*i>=n){
                cout << i << endl;
                break;
            }
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define SZ(x) ((int)(x).size())
typedef long long ll;
typedef long double ld;
using namespace std;

int main() {
    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0); cout.setf(ios::fixed); cout.precision(20);
    ll n; cin >> n;
    n--;
    cout << n * (n + 1) / 2ll << "\n";
}


Measured memory_bytes: 256
#include <stdio.h>
#define MIN(a, b) ((a) < (b) ? (a) : (b))

int main(){
    int N;
    scanf("%d",&N);
    int B[N-1];
    for (int i = 0; i < N-1; i++)
    {
        scanf("%d",&B[i]);
    }
    int sum = 0;
    sum += B[0];
    for (int i = 1; i < N-1; i++)
    {
        sum += MIN(B[i-1],B[i]);
    }
    sum += B[N-2];

    printf("%d\n",sum);
    return 0;
}

Measured memory_bytes: 128
from sys import stdin
N,K = [int(x) for x in stdin.readline().rstrip().split()]
S = (stdin.readline().rstrip())
zero = []
one = []
tmp = 1
S += "@"

for i in range(N):
    if S[i] == S[i+1]:
        tmp += 1
    else:
        if S[i] == "0":
            zero.append(tmp)
        else:
            one.append(tmp)
        tmp = 1
        
if K >= len(zero):
    print(N)
else:
    if S[0] == "1":
        tmp = sum(zero[:K]) + sum(one[:K+1])
        ans = sum(zero[:K]) + sum(one[:K+1])

        for i in range(0,len(zero)-K):
            tmp -= zero[i]
            tmp += zero[i+K]
            tmp -= one[i]
            if not i+K+1 >= len(one):
                tmp += one[i+K+1]
            ans = max(ans,tmp)
        print(ans)
    else:
        tmp = sum(zero[:K]) + sum(one[:K])
        ans = sum(zero[:K]) + sum(one[:K])

        for i in range(0,len(zero)-K):
            tmp -= zero[i]
            tmp += zero[i+K]
            if i != 0:
                tmp -= one[i-1]
            if not i+K >= len(one):
                tmp += one[i+K]
            ans = max(ans,tmp)
        print(ans)

Measured memory_bytes: 4480
import numpy as np

S = np.array(list(map(int, input())))
N = S.shape[0]

repeat_count = N // 2 + 1
a = np.tile(np.array([0, 1]), repeat_count)[:N]
b = np.tile(np.array([1, 0]), repeat_count)[:N]

result = min(np.sum(np.abs(S - a)), np.sum(np.abs(S - b)))

print(result)


Measured memory_bytes: 16308
#include<stdio.h>

int main (void){
	
	int m,i,s,t,a,b,n,sum;
	int matrix[100][100]={0},vector[100]={0};
	
	scanf("%d %d",&n,&m);
	
	for(i=0;i<n;i++){
		for(t=0;t<m;t++){
			
			scanf("%d",&a);
			matrix[i][t] += a;
		}
	}
	
	for(s=0;s<m;s++){
		scanf("%d",&b);
		vector[s] += b;
	}
	
	for(i=0;i<n;i++){
		sum = 0;
		for(t=0;t<m;t++){
			
		sum += matrix[i][t]*vector[t];
		}
	printf("%d\n",sum);
	}
	
return 0;
}

Measured memory_bytes: 648
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<math.h>
using namespace std;
typedef long long ll;
#define int long long
typedef vector<int> VI;
typedef pair<int, int> pii;
typedef priority_queue<int> PQ;
template<class T>bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
#define fore(i,a) for(auto &i:a)
#define REP(i,n) for(int i=0;i<n;i++)
#define eREP(i,n) for(int i=0;i<=n;i++)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define eFOR(i,a,b) for(int i=(a);i<=(b);++i)
#define SORT(c) sort((c).begin(),(c).end())
#define rSORT(c) sort((c).rbegin(),(c).rend())
#define LB(x,a) lower_bound((x).begin(),(x).end(),(a))
#define UB(x,a) upper_bound((x).begin(),(x).end(),(a))
#define INF 1000000000
#define LLINF 9223372036854775807
#define mod 998244353
//vector<vector<int> > dp;
//vector<vector<vector<int> > > vvvi;
//dp=vector<vector<int> >(N, vector<int>(M,0));
//vector<pair<int,int> > v;
//v.push_back(make_pair(x,y));
//priority_queue<int,vector<int>, greater<int> > q2;

vector<VI> tree;
VI dp;
int N;

int dfs(int v) {
	int res = 1;
	fore(u, tree[v]) {
		res *= dfs(u);
		res %= mod;
	}
	return res + 1;
}


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

	cin >> N;
	vector<pii> A(N),B(N);

	dp.resize(N);
	tree.resize(N);
	REP(i, N) {
		cin >> A[i].first >> A[i].second;
		//A[i].second += A[i].first;

	}
	SORT(A);
	
	set<pii>S;

	for (int i = N - 1; i >= 0; i--) {

		int x = A[i].first, d = A[i].second;
		while (S.size() && S.begin()->first < x + d) {
			tree[i].push_back(S.begin()->second);
			S.erase(S.begin());
		}
		S.emplace(x, i);
	}
	
	int ans = 1;
	for (auto x : S) {
		int v = x.second;
		ans *= dfs(v);
		ans %= mod;
	}

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



Measured memory_bytes: 28416
s = input()
n = len(s)

ans = 0

for bit in range(1 << (n - 1)):
    f = s[0]

    for i in range(n - 1):
        # ここのif文の判定基準が理解できていません。
        if bit & (1 << i):
            f += "+"
        f += s[i + 1]

    ans += sum(map(int, f.split("+")))

print(ans)

Measured memory_bytes: 3060
num_list = list(map(int, input().split()))
# print(num_list)
N = num_list[0]
A = num_list[1]
B = num_list[2]

# 1 <= Num <= N である整数を求める
N_list = []
for i in range(N):
    N_list.append(int(i + 1))
# print(N_list)

# 整数の各桁の合計が範囲内の整数を取り出す
# N_listをstr型に変換する
N_list_str = list(map(str, N_list))
digit_sum_list = []
for i in N_list_str:
    digit_sum = 0
    # 長さを調べる
    str_length = len(i)
    # print(str_length)
    for j in range(str_length):
        digit_sum += int(i[j])

    if A <= digit_sum <= B:
        digit_sum_list.append(int(i))
print(sum(digit_sum_list))

'''
１以上N以下の整数で各桁の和がA以上B以下の整数の和
'''


Measured memory_bytes: 4320
(defn DWT [[N M X Y] xs ys]
  (if  (< (apply max (cons X xs)) (apply min (cons Y ys)))
    "No War"
    "War"))


(defn input []
  (map #(Integer/parseInt % 10) 
    (clojure.string/split (read-line) #" ")))

(println
  (DWT (input) (input) (input)))

Measured memory_bytes: 65716
import scala.annotation.tailrec

object Main {
  def main(args: Array[String]): Unit = {
    val sc = new java.util.Scanner(System.in)

    @tailrec
    def sub(a: Int, op: String, b: Int): Unit = {
      op match {
        case "+" =>
          println(a + b)
          sub(sc.nextInt, sc.next, sc.nextInt)
        case "-" =>
          println(a - b)
          sub(sc.nextInt, sc.next, sc.nextInt)
        case "*" =>
          println(a * b)
          sub(sc.nextInt, sc.next, sc.nextInt)
        case "/" =>
          println(a / b)
          sub(sc.nextInt, sc.next, sc.nextInt)
        case _ =>
      }
    }
    sub(sc.nextInt, sc.next, sc.nextInt)

  }
}

Measured memory_bytes: 45016
n, m = map(int, input().split())
a = [0 for i in range(n)]
b = [0 for i in range(m)]
for i in range(n):
  a[i] = list(map(int, input().split()))
    
for i in range(m):
  b[i] = int(input())

c = [0 for i in range(n)]
for i in range(n):
  for j in range(m):
    c[i] = c[i] + a[i][j] * b[j]
  print(c[i])


Measured memory_bytes: 6024
///in the name of ALLAH
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main()
{
    int n;
    cin>>n;
    ///pre calculate
    int ar[10005];
    int mx=10000;
    memset(ar,0,sizeof(ar));
    for(int i=1;i<=sqrt(n);i++)
    {
        for(int j=1;j<=sqrt(n);j++)
        {
            for(int k=1;k<=sqrt(n);k++)
            {
               ll p=i*i+j*j+k*k+i*j+j*k+k*i;
               if(p<=n)
                    ar[p]++;
            }
        }
    }
    for(int i=1;i<=n;i++)
        cout<<ar[i]<<endl;


}




Measured memory_bytes: 3536
import sys
s = list(input())
t = list(input())
s.sort()
t.sort(reverse=True)
num = min(len(s), len(t))
for i in range(num):
    if ord(s[i]) > ord(t[i]):
        print('No')
        sys.exit()
    elif ord(s[i]) < ord(t[i]):
        print('Yes')
        sys.exit()
    elif ord(s[i]) == ord(t[i]) and i == num-1:
        if len(s) < len(t):
            print('Yes')
            sys.exit()
    elif ord(s[i]) == ord(t[i]):
        continue

print('No')


Measured memory_bytes: 9080
N, K, Q = map(int, input().split())
a = [int(input()) for _ in range(Q)]

count = []
for i in range(N):
    count.append(K-Q)

for i in range(Q):
    count[a[i]-1] += 1
for i in range(N):
    if count[i] <= 0:
        print('No')
    else:
        print('Yes')

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

int main()
{
  int h, w;
  cin >> h >> w;
  string a[h];

  for(int i = 0; i < h; i++){
    cin >> a[i];
  }
  for(int i = 0; i < w+2; i++)cout << "#";
  cout << endl;
  for(int i = 0; i < h; i++){
    cout << "#" << a[i] << "#" << endl;   
  }

  for(int i = 0; i < w+2; i++)cout << "#";

  return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    static Scanner scanner = new Scanner(System.in);

    public static void main(String[]$) {
        int x = scanner.nextInt();
        int a = scanner.nextInt();
        int b = scanner.nextInt();
        System.out.println(b <= a ? "delicious" : b - a <= x ? "safe" : "dangerous");
    }
}

Measured memory_bytes: 21712
#define _USE_MATH_DEFINES
#include <iostream>
#include <stdio.h>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <vector>
#include <cstring>
#include <queue>
#include <functional>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <math.h>
#include <complex>
#include <cassert>
#define rep(i,a,b) for (int i = (a); i < (b); i++)
#define case(i) cout<<"Case #"<<i<<": "
using namespace std;
typedef long long int ll;
typedef complex<double> com;
const int mod = 1e9 + 7;
const int MOD = 998244353;
const ll INF = 4e18;



int main(){
	int a, b, t; cin >> a >> b >> t;
	cout << (t / a) * b << endl;
	return 0;
}

Measured memory_bytes: 256
def judge(ans, d)
  str = ans.to_s
  len = str.length

  flg = false
  for i in 0..len-1
    if d.include?(str[i].to_i)
      flg = true
    end
  end
  flg
end

n,k = gets.chomp.split(" ").map(&:to_i)
d = gets.chomp.split(" ").map(&:to_i)

ans = n

while judge(ans, d)
  ans += 1
end

print ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define inf 100000000
using namespace std;
int main (){
    int h,w;
    int c[11][11]={};


    cin >> h >> w;

    int a[h][w];


    for(int i=0;i<10;i++){
        for (int j = 0; j <10; j++){
            cin >> c[i][j];
        }
    }

    for(int i=0;i<h;i++){
        for(int j=0;j<w;j++){
            cin >> a[i][j];
        }
    }
    



    for(int k=0;k<10;k++){
        for(int i=0;i<10;i++){
            for(int j=0;j<10;j++){
                if(c[i][j]>c[i][k]+c[k][j]){
                    c[i][j]=c[i][k]+c[k][j];
                }
            }
        }
    }
    int ans=0;

for(int i=0;i<h;i++){
    for(int j=0;j<w;j++){
        if(a[i][j]!=-1){
            ans += c[a[i][j]][1];
        }
    }
}
cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define ll int64_t
#include <cstdlib> 
#include <math.h>
#include<cstdio>
#include<cstring>
#define FOR(I, A, B) for (ll I = (A); I <= (B); I++)
#define IOS ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define fo(i,n) for(ll i=0;i<n;i++)
#define sz(a) ll((a).size())
#define pb push_back
#define all(c) (c).begin(),(c).end()
#define tr(c,i) for(auto i = (c).begin(); i != (c).end(); i++)
#define present(c,x) ((c).find(x) != (c).end())
#define cpresent(c,x) (find(all(c),x) != (c).end())
#define dbg(x) cout << #x << " = " << x << endl
#define dbg2(x,y) cout << #x << " = " << x << ", " << #y << " = " << y << endl
#define dbg3(x,y,z) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << endl
#define dbg4(x,y,z,q) cout << #x << " = " << x << ", " << #y << " = " << y << ", " << #z << " = " << z << ", " << #q << " = " << q << endl
#define scan(char_array) scanf("%[^\n]s",&char_array)
#define inin freopen("input3.txt", "r", stdin)


int main(){
	IOS
	//inin;
	ll n;
	cin>>n;
	ll a[n];
    fo(i,n) cin>>a[i];
    ll second[22];
    ll last[22];
    fo(i,22){
    	last[i]=n;
    	second[i]=n;
    }
    ll ans=0;
    for(ll i=n-1;i>=0;i--){
    	ll miin=n-1;
    	fo(j,21){
    		if(a[i]&(1<<j)){
    			miin=min(miin,(last[j]-1));
    			if(second[j]==last[j]) ;
    			else second[j]=last[j];
    			
    			last[j]=i;

    		}
    		else{
    			miin=min(miin,second[j]-1);
    		}
    	}
    	ans+=(miin-i+1);
    	//dbg2(i,ans);

    }
    cout<<ans<<endl;

}

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

int main(){
  int n,k;
  cin >> n >> k;
  double p[n],ans=0;
  for(int i=0;i<n;i++){
    double a;
    cin >> a;
    p[i]=(a+1)/2;
  }
  double q[n+1];
  q[0]=0;
  for(int i=0;i<n;i++) q[i+1]=q[i]+p[i];
  for(int i=0;i+k<=n;i++){
    ans = max(q[i+k]-q[i],ans);
  }
  cout <<fixed << setprecision(10)<< ans << endl;
}

Measured memory_bytes: 3328
import re
n,a,b,c,d = map(int,input().split())
s = input()
a,b,c,d = map(lambda x:x-1,[a,b,c,d])

if re.search(r'##',s[a:max(b,d)+1]):
    print('No')
else:
    if c>d:
        if (re.search(r'\.{3,}',s[b-1:d+2])):
            print('Yes')
        else:
            print('No')
    else:
        print('Yes')

Measured memory_bytes: 3700
using System;
using System.Text;
using System.Collections.Generic;
using System.Linq;
 
class Program {
    static List<int>[] Sub;
    static int[] Salary;
    
    
    static void Main(string[] args) {
        var NAB  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
        var N = NAB[0];
        var A = NAB[1];
        var B = NAB[2];
        var X  = Console.ReadLine().Split().Select(a => long.Parse(a)).ToArray();
      
        var ans = 0L;
        for(int i = 0; i < N-1;i++){
          if((X[i+1] - X[i])*A < B ){
            ans += (X[i+1] - X[i])*A;
          }else{
            ans += B;
          }
        }
        

        Console.WriteLine(ans);
        }
         
}


Measured memory_bytes: 20832
H, W, D = map(int,input().split())
data = [0] * (H * W + D + 1)
for i in range(H):
    A = list(map(int,input().split()))
    for j in range(W):
        data[A[j] + D] = [i, j]
Q = int(input())
S = [0] * (H * W + D + 1)
for i in range(H * W):
    if i >= D:
        S[i + D + 1] = S[i + 1] + abs(data[i + D + 1][0] - data[i + 1][0]) + abs(data[i + D + 1][1] - data[i + 1][1])
for i in range(Q):
    L, R = map(int,input().split())
    print(S[R + D] - S[L + D])

Measured memory_bytes: 66200
#include <iostream>
#include <algorithm>
#include <map>
#include <set>
#include <queue>
#include <cmath>
#include <stack>
#include <vector>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> ii;
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
const int N = 100001;
int t;
int n,k;
int a[N][3],dp[N][3];
int main(){
    cin>>n;
    for(int i=0;i<n;i++)
        for(int j=0;j<3;j++){
            scanf("%d",&a[i][j]);
            if(!i)
                dp[0][j]=a[0][j];
        }
    
    for(int i=1;i<n;i++){
        for(int j=0;j<3;j++){
            dp[i][j]=max(dp[i-1][(j+1)%3],dp[i-1][(j+2)%3])+a[i][j];
        }
    }
    cout<<max(max(dp[n-1][0],dp[n-1][1]),dp[n-1][2]);
}


Measured memory_bytes: 5580
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
 
int main() {
    int n;
    int a;
    cin >> n;
    while(n>0){
        a = n % 10;
        if(a==7){
            cout << "Yes" << endl;
            return 0;
        }
        n = n / 10;
    }
    cout << "No" << endl;
    return 0;
}


Measured memory_bytes: 3636
#include <bits/stdc++.h>
using namespace std;
# define ll long long int
int main(){
	ios::sync_with_stdio(false);
  	cin.tie(0);
  	ll n,i,p=0,l=0;
  	string s;
  	cin>>n;
  	cin>>s;
  	for(i=0;i<n;i++){
  		if(s[i]=='('){
  			p++;
  			continue;
		  }else{
		  	if(p==0){
		  		l++;
		  		continue;
			  }
			  p--;
		  }
	  }for(i=0;i<l;i++){
	  	s='('+s;
	  }for(i=0;i<p;i++){
	  	s.push_back(')');
	  }cout<<s;
}


Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
	int n,b,f,r,v,i,j,w,q,a[4][3][10]={0};
	cin>>n;
	for(i=0;i<n;i++){
		cin>>b>>f>>r>>v;
		a[b-1][f-1][r-1]=a[b-1][f-1][r-1]+v;
	}
	for(q=0;q<4;q++){
		for(j=0;j<3;j++){
			for(w=0;w<10;w++){
				cout<<" "<<a[q][j][w];
			}cout<<endl;
		}if(q!=3){
			cout<<"####################"<<endl;
		}
	}
	return 0;
}


Measured memory_bytes: 3104
#include<iostream>
#include<math.h>
#include<string>
#include<algorithm>
using namespace std;

double a[114514];

int main() {
	int n; cin >> n;
	for (int i = 0; i < n; i++)cin >> a[i];
	sort(a, a + n);
	int ans1, ans2;
	ans1 = a[n - 1];
	double key = a[n - 1] / 2;
	double d = 1100000000;
	for (int i = 0; i < n - 1; i++) {
		if (fabs(a[i] - key) < d) {
			d = fabs(a[i] - key);
			ans2 = a[i];
		}
	}
	cout << ans1 << " " << ans2 << endl;
	return 0;
}


Measured memory_bytes: 1024
import java.util.Scanner;

class Main{
    public static void main(String[] args){
        int H,W;
    	//?¨??????\??????????????????????????§????????????
		Scanner scanner = new Scanner(System.in);
		
		while(true){
			H = scanner.nextInt();
			W = scanner.nextInt();
			if(H == 0 && W == 0){
				break;
			}
			for(int i = 0; i < H;i++){
				for(int j = 0; j < W; j++){
					System.out.print("#");				
				}
				System.out.println();
			}
			System.out.println();
		}
    	scanner.close();
    }
}

Measured memory_bytes: 34332
#include<stdio.h>
#include<stdlib.h>
int main(){

  int N,A[100],i,j,temp,minj,count=0;
  scanf("%d",&N);
  for(i=0;i<N;i++)scanf("%d",&A[i]);
  
  for(i=0;i<N;i++){
    minj=i;
    for(j=i;j<N;j++){
      if(A[j] < A[minj]){
	minj=j;}
      }
    if(i!=minj){
      temp=A[minj];
      A[minj]=A[i];
      A[i]=temp;
     
      count++;
    }
  }
  for(i=0;i<N-1;i++){printf("%d ",A[i]);}
  for(i=N-1;i<N;i++){printf("%d",A[i]);}
  printf("\n");
  printf("%d",count);
  printf("\n");
  

  return 0;
}


Measured memory_bytes: 2052
#include <bits/stdc++.h>
  
using namespace std;
  
template<class T> void ckmin(T &a, T b) { a = min(a, b); }
template<class T> void ckmax(T &a, T b) { a = max(a, b); }
  
#define pb push_back
#define mp make_pair
#define cotu cout
#define itn int
#define Red ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define F first
#define S second
#define sz(x) (int)x.size()
#define all(x) (x).begin(), (x).end()
#define rep(i, n) for(int i = 0; i < n; ++i)
#define repr(i,n) for(int i = n - 1; i >= 0; --i)
#define Rep(i, a, n) for(int i = (a); i <=(n); ++i)
#define repst(i, n) for(auto it = n.begin(); it != n.end(); ++it)
#define Repr(i, a, n) for(int i = (n); i >= (a); --i)
  
#define ordered_set tree<int , null_type,less<int >, rb_tree_tag,tree_order_statistics_node_update> 
  
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
  
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
  
const int inf = int(1e8);
const int mod = 16714589;
const int N = 2e6 + 555; // TL MB
const double PI = acos(-1.0);
double eps = 1e-6;

// {l, r}

int n;
void solve(){   
	int n, m, x;
	cin >> n >> m >> x;
	int c[n], a[n][m];
	rep(i, n){
		cin >> c[i];
		rep(j, m){
			cin >> a[i][j];
		}
	}
	int ans = inf;
	for(int i = 1; i < 1 << n; ++i){
		int b[m], cur = 0;
		rep(j, m) b[j] = 0;
		for(int j = 0; j < n; ++j){
			if(!(i & (1 << j))) continue;
			cur += c[j];
			for(int k = 0; k < m; ++k){
				b[k] += a[j][k];
			}
		}
		bool bad = 0;
		rep(j, m) if(b[j] < x) bad = 1;
		if(!bad) ans = min(ans, cur);
	}
	cout << (ans == inf ? -1 : ans) << '\n';
}	// 0 1 2 2 3 3


 
 
int main()
{
	Red;
	//freopen("input.txt", "r", stdin);s
	//freopen("output.txt", "r", stdin);
  	int T = 1; 
 	//cin >> T; 
  	for(int i = 1; i <= T; ++i){
  		solve();
  	}
    return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
#define FOR(i, a, b) for(int i = (int)a; i <= (int)b; i++)
#define DEC(i, a, b) for(int i = (int)a; i >= (int)b; i--)
typedef pair<int, int> pi;
typedef pair<int, pi> pii;
typedef pair<pi, pi> pipi;
#define f first
#define s second
typedef vector<int> vi;
typedef vector<pi> vpi;
typedef vector<pii> vpii;
#define pb push_back
#define pf push_front
#define all(v) v.begin(), v.end()
#define disc(v) sort(all(v)); v.resize(unique(all(v)) - v.begin());
#define INF (int) 1e9 + 100
#define LLINF (ll) 1e18
#define fastio ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());    //can be used by calling rng() or shuffle(A, A+n, rng)
inline ll rand(ll x, ll y) { ++y; return (rng() % (y-x)) + x; } //inclusivesss

ll r, c, sr, sc, er, ec;
ll dx[] = {-1, 0, 0, 1, -2, -2, -2, -2, -2, -1, -1, -1, -1, 0, 0, 1, 1, 1, 1, 2, 2, 2, 2, 2};
ll dy[] = {0, 1, -1, 0, -2, -1, 0, 1, 2, -2, -1, 1, 2, -2, 2, -2, -1, 1, 2, -2, -1, 0, 1, 2};
char grid[1005][1005];
ll dist[1005][1005];
deque <pii> dq;

int main() {
	fastio; cin >> r >> c >> sr >> sc >> er >> ec;
	FOR(i, 1, r) FOR(j, 1, c) cin >> grid[i][j];
	memset(dist, -1, sizeof dist);
	dq.push_front(pii(0, pi(sr, sc)));
	dist[sr][sc] = 0;
	while (!dq.empty()) {
		pii cur = dq.front(); dq.pop_front();
		ll d = cur.f, x = cur.s.f, y = cur.s.s;
		if (d != dist[x][y]) continue;
		FOR(i, 0, 23) {
			int nx = x + dx[i], ny = y + dy[i];
			if (nx < 1 or ny < 1 or nx > r or ny > c or grid[nx][ny] == '#') continue;
			if (dist[nx][ny] == -1 or dist[nx][ny] > d + (i > 3)) {
				dist[nx][ny] = d + (i > 3);
				if (i <= 3) dq.push_front(pii(d, pi(nx, ny)));
				else dq.push_back(pii(d+1, pi(nx, ny)));
			}
		}
	}
	cout << dist[er][ec];
}


Measured memory_bytes: 12668
package main

import "fmt"

func main() {
	var n, m, x int
	fmt.Scan(&n, &m, &x)

	a := make([]int, m)
	for i := 0; i < m; i++ {
		fmt.Scan(&a[i])
	}

	cost1 := 0
	for i := x; i < n; i++ {
		for _, v := range a {
			if i == v {
				cost1++
			}
		}
	}
	cost2 := 0
	for i := x; i > 0; i-- {
		for _, v := range a {
			if i == v {
				cost2++
			}
		}
	}

	if cost1 < cost2 {
		fmt.Println(cost1)
	} else {
		fmt.Println(cost2)
	}
}


Measured memory_bytes: 512
#include <algorithm>
#include <iostream>
#include <stack>
#include <string>
#include <unordered_set>
#include <vector>

using std::cin;
using std::cerr;
using std::cout;
using std::endl;
using std::make_pair;
using std::pair;
using std::stack;
using std::string;
using std::unordered_set;
using std::vector;

int main(int argc, char* argv[]) {
  int n;
  cin >> n;
  for (int i = 0; i < n; ++i) {
    int a;
    cin >> a;
    if (a % 2 == 0 && !(a % 3 == 0 || a % 5 == 0)) {
      cout << "DENIED";
      return 0;
    }
  }
  cout << "APPROVED";
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <cmath>
#include <algorithm>
#include <cstdlib>
#include <ctime>
#include <cstdio>
#include <functional>
#include <set>
#include <sstream>
#include <map>
#include <queue>

using namespace std;

int main()
{
	int n;
	while(cin>>n,n){
		vector< vector<int> > info(n);
		for(int i=0;i<n;i++){
			int m;
			cin>>m;
			info[i].resize(m);
			for(int j=0;j<m;j++) cin>>info[i][j];
			sort(info[i].begin(),info[i].end());
		}

		int k;
		cin>>k;
		vector<int> out(k);
		for(int i=0;i<k;i++) cin>>out[i];

		vector<int> ans;
		for(int i=0;i<n;i++){
			bool ok=true;
			for(int j=0;j<k && ok;j++) ok=binary_search(info[i].begin(),info[i].end(),out[j]);
			if(ok) ans.push_back(i+1);
		}

		if(ans.size()==1) cout<<ans[0]<<endl;
		else cout<<-1<<endl;

	}

	return 0;
}

Measured memory_bytes: 1260
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int i = sc.nextInt();
        int[] num = new int[i];
        for(int j=0;j<i;j++){
            num[j]=sc.nextInt();
        }
        int cnt=0;
        for(int l=0;l<i;l++){
            for(int m=i-1;m>l;m--){
                if(num[m]<num[m-1]){
                    int t=num[m];
                    num[m]=num[m-1];
                    num[m-1]=t;
                    cnt++;
                }
            }
        }
        for(int k=0;k<i-1;k++){
            System.out.printf("%d ",num[k]);
        }
        System.out.printf("%d\n%d\n",num[i-1],cnt);
        sc.close();
    }
}


Measured memory_bytes: 26588
N = int(input())
S = input()

ans = 0

# find()は最初に一致した部分のみを返す
# 3桁の番号なので高々1000通り調べれば良いだけ
# N<=30000、N(C)3通り全部調べようとすると10**12個くらい調べることになって死ぬ

# 1桁目
for x in range(10):
    if S.find(str(x)) >= 0:
        temp1 = S[S.find(str(x)) + 1:]

        # 2桁目
        for y in range(10):
            if temp1.find(str(y)) >= 0:
                temp2 = temp1[temp1.find(str(y)) + 1:]

                # 3桁目
                for z in range(10):
                    if temp2.find(str(z)) >= 0:
                        ans += 1

print(ans)

Measured memory_bytes: 9040
line = list(map(int,input().split()))
W =line[0]
H = line[1]
x = line[2]
y= line[3]
r=line[4]

if (x+r)<=W and x-r>=0:
    if(y+r)<=H and (y-r)>=0:
        print("Yes")
    else:
        print("No")
else:
    print("No")


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

using namespace std;

int c[1001000],d[1001000];
int n,m,i,j,p,tep=0;
struct node
{
    int l;
    int r;
    bool operator< (const node &p)const
    {
        if(r==p.r)
            return l<p.l;
        return r<p.r;
    }
};
node b[1001000];
int main()
{
    scanf("%d%d",&n,&m);
    //memset(c,0,sizeof(c));
    //memset(d,0,sizeof(d));
    for(i=0; i<m; i++)
        scanf("%d%d",&b[i].l,&b[i].r);
    sort(b,b+m);
    for(i=0; i<m; i++)
    {
        c[b[i].r]=b[i].r;
        d[b[i].l]=b[i].l;
    }
    int len=0;
    for(p=0;p<m;p++)
    {
        //i=b[p].l;
       if(d[b[p].l]>=len)
       {
           len=c[b[p].r];
           tep++;
       }
    }
    printf("%d\n",tep);

    return 0;
}


Measured memory_bytes: 7168
#include "bits/stdc++.h"
using namespace std;

int n,w,wt,val;

int main()
{
	scanf("%d%d",&n,&w);
	vector <long long> prev(w+1,0);
	while(n--)
	{
		scanf("%d%d",&wt,&val);

		vector <long long> curr=prev;
		for(int i=wt;i<=w;i++)
			curr[i]=max(curr[i],prev[i-wt]+val);
		prev=curr;
	}

	printf("%lld",*max_element(prev.begin(),prev.end()));
}

Measured memory_bytes: 4896
use proconio::{input, fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        s: String,
    }

    let r_count = s.match_indices('R').count();
    let g_count = s.match_indices('G').count();
    let b_count = s.match_indices('B').count();

    let mut ans = r_count*g_count*b_count;

    let s = s.as_bytes();
    for i in 0..n {
        for j in i+1..n {
            let k = 2 * j - i;
            if k >= n {
                break;
            }

            if check(s[i], s[j], s[k]) {
                ans -= 1;
            }
        }
    }

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

fn check(a: u8, b: u8, c: u8) -> bool {
    a != b && b != c && c != a
}

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

#define ll long long 
 
using namespace std ;
 
int z , o , ans ;


int main(){

	int n ;

	cin >> n ;

	set<string>vc;

	for( int i = 0 ; i < n ; i ++ ){

		string s ;

		cin >> s ;

		vc.insert(s);

	}

	cout << vc.size() << endl ;

}

Measured memory_bytes: 19220
while True:
    a, op, b = input().split()
    a = int(a)
    b = int(b)
    if op == '+':
        print(a + b)
    elif op == '-':
        print(a - b)
    elif op == '*':
        print(a * b)
    elif op == '/':
        print(int(a / b))
    elif op == '?':
        break


Measured memory_bytes: 5596
#include<iostream>
#include<string>
#include<cmath>
#include<queue>
#include<map>
#include<set>
#include<list>
#include<iomanip>
#include<vector>
#include<random>
#include<functional>
#include<algorithm>
#include<stack>
#include<cstdio>
#include<bitset>
#include<unordered_map>
#include <climits>
#include<fstream>
using namespace std;
//---------------------------------------------------
//ライブラリゾーン！！！！
typedef long long ll;
typedef long double ld;
#define rep(i,j) for(ll i=0;i<(long long)(j);i++)
#define all(a) (a).begin(),(a).end()
const ll Mod = 1000000007;
struct P {
	ll pos, cost;
};
bool operator<(P a, P b) { return a.cost < b.cost; }
bool operator>(P a, P b) { return a.cost > b.cost; }
struct B {//隣接リスト表現
	ll to, cost;
};
struct E {//辺の情報を入れる変数
	ll from, to, cost;
};
bool operator<(E a, E b) {
	return a.cost < b.cost;
}
struct H {
	ll x, y;
};
bool operator<(H a, H b) {
	if (a.x != b.x) return a.x < b.x;
	return a.y < b.y;
}
bool operator>(H a, H b) {
	if (a.x != b.x) return a.x > b.x;
	return a.y > b.y;
}
bool operator==(H a, H b) {
	return a.x == b.x&&a.y == b.y;
}
bool operator!=(H a, H b) {
	return a.x != b.x || a.y != b.y;
}
ll gcm(ll i, ll j) {//最大公約数
	if (i > j) swap(i, j);
	if (i == 0) return j;
	return gcm(j%i, i);
}
ld rad(H a, H b) {
	return sqrt(pow(a.x - b.x, 2.0) + pow(a.y - b.y, 2.0));
}//rad＝座標上の2点間の距離
ll mod_pow(ll x, ll n, ll p) {
	ll res = 1;
	while (n > 0) {
		if (n & 1) res = res * x%p;
		x = x * x%p;
		n >>= 1;
	}
	return res;
}//x^n%p
const ll Inf = 3023372036854775807;
const int inf = 1500000000;
#define int long long
//----------------------------------------------------
//++++++++++++++++++++++++++++++++++++++++++++++++++++
int r, c;
int a[300][300];
signed main() {
	cin >> r >> c;
	int sum = 0;
	for (int i = 0; i < r; i++) {
		for (int j = 0; j < c; j++) {
			cin >> a[i][j];
			a[i][c] += a[i][j];
			a[r][j] += a[i][j];
			sum += a[i][j];
		}
	}
	a[r][c] = sum;
	for (int i = 0; i <= r; i++) {
		for (int j = 0; j <= c; j++) {
			cout << a[i][j] << (j != c ? " " : "\n");
		}
	}
}


Measured memory_bytes: 3312
float b,c,d,e,f;main(a){for(;~scanf("%d%f%f%f%f%f",&a,&b,&c,&d,&e,&f);printf("%.3f %.3f\n",(c-b*d)/a,d))d=(a*f-c*d)/(a*e-b*d);}

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

vector<int> solve(int n) {
    vector<int> a;
    unordered_map<int, vector<int> > mp;
    for (int i = 2; a.size() < n; i++) {
        if (mp.find(i) == mp.end()) {
            if (i % 5 == 1)
                a.push_back(i);
            mp[i << 1].push_back(i);
        } else {
            for (int x: mp[i]) {
                mp[i + x].push_back(x);
            }
            mp.erase(i);
        }
    }
    return a;
}

int main() {
    int n;
    cin >> n;
    vector<int> res = solve(n);
    cout << res[0];
    for (int i = 1; i < n; i++) {
        cout << ' ' << res[i];
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 384
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;

/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

/*---  Type ---*/
typedef long long ll;

/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

// Util
int max(int a, int b, int c) {return max(a, max(b, c));}
int min(int a, int b, int c) {return min(a, min(b, c));}
ll max(ll x, ll y) {return x > y ? x : y;}
ll min(ll x, ll y) {return x < y ? x : y;}
ll max(ll a, ll b, ll c) {return max(a, max(b, c));}
ll min(ll a, ll b, ll c) {return min(a, min(b, c));}

// -------------------------------------------------------------------------------------



int main() {
  string s;
  cin >> s;

  int ans = 0;
  rep(i, 4) {
    if(s[i] == '+') ans++;
    else ans--;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 764
#include <cstdio>
#include <string>
#include <cmath>
#include <string>
#include <algorithm>
#include <iostream>
#include <map>
#include <vector>
using namespace std;
#define rep(i, a, n) for (int i=a;i<n;++i)
#define per(i, a, n) for (int i=n-1; i>=a;--i)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(), (x).end()

// D - Binomial Coefficients
int main(){
    int n;
    cin >> n;

    vector<int> a;
    int src;
    rep(i, 0, n){
        cin >> src;
        a.pb(src);
    }
    sort(all(a));

    int ans_1 = a.back();
    double max_half = ans_1 / 2.0;
    int diff = INT32_MAX;
    int diff_ans = 0;
    rep(i, 0, n){
        if((double)abs(max_half - a[i])<diff){
            diff = abs(max_half - a[i]);
            diff_ans = i;
        }
    }

    cout << ans_1 << " " << a[diff_ans] << endl;
    return 0;
}




Measured memory_bytes: 892
<?php
  $base_num = explode(" ",fgets(STDIN));
  $array = explode(" ",fgets(STDIN));
  $ans = 0;

  $first_num = (int)$base_num[0] - (int)$base_num[1];

  if($first_num <= 0)
  {
    $ans = 1;
  }
  else
  {
    $div_num = (int)$base_num[1] - 1;
    $second_num = (int)($first_num / $div_num);
    if($first_num % $div_num == 0)
    {
      $ans = $second_num + 1;
    }
    else
    {
      $ans = $second_num + 2;
    }
  }
  echo $ans;

Measured memory_bytes: 21876
#include<stdio.h>

 int main(){
     int i,j,h,w;
     while(1){
        scanf("%d%d",&h,&w);
        if(h+w==0)break;
        for(i=0;i<h;i++){
             for(j=0;j<w;j++){
                    if((i+j)%2==0)printf("#");
                    else printf(".");
                    }
             printf("\n");
             }
        printf("\n");
        }
    return 0;
    }


Measured memory_bytes: 2056
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<set>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define ECHO(x) cout<<x<<endl;
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


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

  int tmax=0;

  vector<int> s;
  vector<int> t;
  vector<int> c;
  int p, q, r;
  REP(i, n){
    cin>>p>>q>>r;
    s.push_back(p);
    t.push_back(q);
    c.push_back(r);
    s[i]=2*s[i]-1;
    t[i]=2*t[i];
    tmax=max(tmax, t[i]);
  }
  int tt[tmax];
  int tm[tmax];
  REP(i, tmax) tm[i]=0;
  REP(j, C){
    for(int i=0; i<tmax; ++i) tt[i]=0;
    for(int i=0; i<n; ++i) if(c[i]==j+1) ++tt[s[i]], --tt[t[i]];
    for(int i=1; i<tmax; ++i) tt[i] += tt[i-1];
    for(int i=0; i<tmax; ++i) tm[i] += tt[i]>0 ? 1 : 0;

  }
  int ans=0;
  REP(i, tmax) ans=max(ans, tm[i]);
  cout<<ans<<endl;

  return 0;
}


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

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

using namespace std;



int main() {
    int n,m;
    cin>>n>>m;
    vector<int>broken(n+1);
    rep(i,m){
        int a;
        cin>>a;
        broken[a]=1;
    }
    vector<int>dp(n+2);
    const int mod = 1000000007;
    dp[n]=1;
    for(int i=n-1; i>=0; i--){
        if(broken[i]){
            dp[i]=0;
            continue;
        }
        dp[i]=(dp[i+1]+dp[i+2]) % mod;
    }
    cout<<dp[0]<<endl;

    return 0;
}

Measured memory_bytes: 4036
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define INF 1<<30
#define LINF 1LL<<60

struct UnionFind {
	vector<int> par;
	int n, cnt;
	UnionFind(const int& x = 0) { init(x); }
	void init(const int& x) { par.assign(cnt = n = x, -1); }
	inline int find(const int& x) { return par[x] < 0 ? x : par[x] = find(par[x]); }
	inline bool same(const int& x, const int& y) { return find(x) == find(y); }
	inline bool unite(int x, int y) {
		if ((x = find(x)) == (y = find(y))) return false;
		--cnt;
		if (par[x] > par[y]) swap(x, y);
		par[x] += par[y];
		par[y] = x;
		return true;
	}
	inline int count() const { return cnt; }
	inline int count(int x) { return -par[find(x)]; }
};

struct edge {
	ll u;
	ll v;
	ll cost;
	edge() {}
	edge(ll u, ll v, ll c) :u(u), v(v), cost(c) {}
	bool operator < (const edge& o) const {
		return cost < o.cost;
	}
	bool operator > (const edge& o)const {
		return cost > o.cost;
	}
};

int main(void) {
	cin.tie(0); ios::sync_with_stdio(false);
	ll V, E; cin >> V >> E;
	UnionFind uf(V);
	priority_queue<edge,vector<edge>,greater<edge>> G;
	for (int i = 0; i < E;i++) {
		ll s, t, w; cin >> s >> t >> w;
		G.push(edge(s, t, w));
	}
	ll ans = 0;
	while (!G.empty()) {
		auto e = G.top(); G.pop();
		if (uf.same(e.u, e.v)) continue;
		uf.unite(e.u, e.v);
		ans += e.cost;
	}
	if (uf.count() == 1) cout << ans << endl;
	return 0;
}

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

int main() {
  
  int N;
  cin >> N;
  
  vector<string> vec(N);
  
  for(int i =0;i<N;i++) {
    cin >> vec.at(i);
  }
  
  int S = 1;

  sort(vec.begin(),vec.end());
  
  for(int i = 0;i<N-1;i++) {
    
    if(vec.at(i) != vec.at(i+1)) {
      S++;
    }
  }
  cout << S <<endl;
  return 0;
}


Measured memory_bytes: 9544
import java.util.Scanner;
 class Main {
	
	/**
	 * @param args
	 */
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		
		// TODO Auto-generated method stub
		int S = scanner.nextInt();
					
		System.out.println(S/3600+":"+(S%3600)/60+":"+(S%3600)%60);
		
	}

}

Measured memory_bytes: 26144
#include<bits/stdc++.h>
using namespace std;
int main()
{
  long long a,b,c,k;
  cin>>a>>b>>c>>k;
 // long long count=0;
  if(k<=a){
	 cout<<k<<"\n";  
  }
  else if(k<=(a+b)){
	 cout<<a<<"\n";  
  }
  else{
	 long long r = k-(a+b);
	 cout<<(-r+a)<<"\n";  
  }

}


Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define vll vector<ll>
#define vvll vector<vll>
#define mll map<ll,ll>
#define f(i,m,n) for(i=m;i<n;i++)
#define ee endl
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define take(v,n) for(i=0;i<n;i++) cin>>v[i];
#define NO() cout<<"NO"<<endl
#define YES() cout<<"YES"<<endl
#define fast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sot(v) sort(v.begin(),v.end());
bool isPrime(int n) 
{ 
    // Corner cases 
    if (n <= 1)  return false; 
    if (n <= 3)  return true; 
  
    // This is checked so that we can skip  
    // middle five numbers in below loop 
    if (n%2 == 0 || n%3 == 0) return false; 
  
    for (int i=5; i*i<=n; i=i+6) 
        if (n%i == 0 || n%(i+2) == 0) 
           return false; 
  
    return true; 
}

ll powe(ll x, ll y){
    ll res = 1;
    while (y > 0){
        if (y & 1) res = res*x;
        y = y>>1;
        x = x*x;
    }
    return res;
}

void solve()
{
    ll i,j,k=0,n,l;
    cin>>n>>k;
    vll v(n),w(n);
    for(i=0;i<n;i++)
    {
        cin>>j>>l;
        v[i]=j;
        w[i]=l;
    }
    ll dp[n+1][k+1];
    for(i=0;i<=n;i++)
    {
        dp[i][0]=0;
    }
    for(i=0;i<=k;i++)
    {
        dp[0][i]=0;
    }
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=k;j++)
        {
            if(j<v[i-1])
                dp[i][j]=dp[i-1][j];
            else
                dp[i][j]=max(dp[i-1][j],w[i-1]+dp[i-1][j-v[i-1]]);
        }
    }
    cout<<dp[n][k];



}

int main() {
    fast;
    ll i,j,l,k,t,n;
    t=1;
    while(t--)
    solve();
}


Measured memory_bytes: 82364
import sys

n=int(input())

b_t=0
b_x=0
b_y=0
for _ in range(n):
    t,x,y=map(int,input().split())
    tmp= ( t - b_t) - abs(x - b_x) - abs( y - b_y )
    if( tmp % 2 != 0 or tmp <0):
        print( "No" )
        sys.exit()
    b_t,b_x,b_y=t,x,y

print("Yes")

Measured memory_bytes: 3064