akhauriyash/Code-Regression huggingface dataset:
#![allow(non_snake_case)]
#![allow(dead_code)]
#![allow(unused_macros)]
#![allow(unused_imports)]

use std::str::FromStr;
use std::io::*;
use std::collections::*;
use std::cmp::*;

struct Scanner<I: Iterator<Item = char>> {
    iter: std::iter::Peekable<I>,
}

macro_rules! exit {
    () => {{
        exit!(0)
    }};
    ($code:expr) => {{
        if cfg!(local) {
            writeln!(std::io::stderr(), "===== Terminated =====")
                .expect("failed printing to stderr");
        }
        std::process::exit($code);
    }}
}

impl<I: Iterator<Item = char>> Scanner<I> {
    pub fn new(iter: I) -> Scanner<I> {
        Scanner {
            iter: iter.peekable(),
        }
    }

    pub fn safe_get_token(&mut self) -> Option<String> {
        let token = self.iter
            .by_ref()
            .skip_while(|c| c.is_whitespace())
            .take_while(|c| !c.is_whitespace())
            .collect::<String>();
        if token.is_empty() {
            None
        } else {
            Some(token)
        }
    }

    pub fn token(&mut self) -> String {
        self.safe_get_token().unwrap_or_else(|| exit!())
    }

    pub fn get<T: FromStr>(&mut self) -> T {
        self.token().parse::<T>().unwrap_or_else(|_| exit!())
    }

    pub fn vec<T: FromStr>(&mut self, len: usize) -> Vec<T> {
        (0..len).map(|_| self.get()).collect()
    }

    pub fn mat<T: FromStr>(&mut self, row: usize, col: usize) -> Vec<Vec<T>> {
        (0..row).map(|_| self.vec(col)).collect()
    }

    pub fn char(&mut self) -> char {
        self.iter.next().unwrap_or_else(|| exit!())
    }

    pub fn chars(&mut self) -> Vec<char> {
        self.get::<String>().chars().collect()
    }

    pub fn mat_chars(&mut self, row: usize) -> Vec<Vec<char>> {
        (0..row).map(|_| self.chars()).collect()
    }

    pub fn line(&mut self) -> String {
        if self.peek().is_some() {
            self.iter
                .by_ref()
                .take_while(|&c| !(c == '\n' || c == '\r'))
                .collect::<String>()
        } else {
            exit!();
        }
    }

    pub fn peek(&mut self) -> Option<&char> {
        self.iter.peek()
    }
}

const INF: i64 = 1 << 60;

fn main() {
    let cin = stdin();
    let cin = cin.lock();
    let mut sc = Scanner::new(cin.bytes().map(|c| c.unwrap() as char));
    let N: usize = sc.get();
    let M: usize = sc.get();
    let c: Vec<usize> = sc.vec(M);
    let mut dp = vec![INF; N+1];
    dp[0] = 0;
    for n in 0..N+1 {
        for i in 0..M {
            if n >= c[i] {
                dp[n] = min(dp[n], dp[n - c[i]] + 1)
            }
        }
    }
    println!("{}", dp[N]);
}



Measured memory_bytes: 5036
#include <bits/stdc++.h>
using namespace std;
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree <int,null_type,less <int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;
// #include <ext/rope>
// using namespace __gnu_cxx;
typedef long long int ll;
typedef long double ld;
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define rep(g, i, n) for (ll g = i; g < n; g++)
#define rev(g, n, i) for (ll g = n - 1; g >= i; g--)
#define all(v) v.begin(), v.end()
#define pb push_back
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define ve vector
#define lb lower_bound
#define ub upper_bound
#define bb break
#define cc continue
#define rem 1000000007
#define PI 3.141592653589793238462643383279502
ll power(ll x, ll y, ll p) 
{ 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or 
    while (y > 0) 
    { 
        if (y & 1) 
            res = (res*x) % p; 
        y = y>>1; // y = y/2 
        x = (x*x) % p; 
    } 
    return res; 
} 
ll modInverse(ll n, ll p) 
{ 
    return power(n, p-2, p); 
} 
struct point
{
    ll x,y;
};
int main()
{
    FAST
    // freopen("input1.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    /*ll tests;
    cin>>tests;
    rep (gg,0,tests)
    {}*/
    ld a,b,h,m;
    cin>>a>>b>>h>>m;
    ld ang1=h*30+m/2;
    ll ang2=m*6;
    ang1=360-ang1;
    ang2=360-ang2;
    // cout<<"ang1.. "<<ang1<<" ang2.. "<<ang2<<"\n";
    ld x1=a*cos(ang1*PI/180),y1=a*sin(ang1*PI/180);
    ld x2=b*cos(ang2*PI/180),y2=b*sin(ang2*PI/180);
    // cout<<"x1.. "<<x1<<" y1.. "<<y1<<"\n";
    // cout<<"x2.. "<<x2<<" y2.. "<<y2<<"\n";
    ld ans=sqrt((x2-x1)*(x2-x1)+(y2-y1)*(y2-y1));
    cout<<fixed<<setprecision(20)<<ans<<"\n";
}


Measured memory_bytes: 4252
#include <iostream>
#include<string>
#include<cstdio>
using namespace std;
typedef long long ll;
#define rep(i,n) for(int i = 0;i<(n);i++)

//positionbit目が立っているか判定
bool contain(int mask,int position){
    if((mask&(1<<position))!=0)return true;
    else return false;
}

int main(void){
    string s;
    cin >> s;
    int n = s.size()-1;
    
    ll sum = 0;
    for(int mask = 0; mask<(1<<n);mask++){
        int l = 0;
        ll tmp = 0;
        int r;
        for(r = 0; r < n;r++){
            if(contain(mask,r)){
                string t = s.substr(l,r-l+1);
                ll num = stoll(t);
                tmp += num;
                l = r+1;
            }
        }
        string t = s.substr(l,r-l+1);
        ll num = stoll(t);
        tmp += num;
        sum += tmp;
    }
    cout << sum << endl;
    return 0;
    
}


Measured memory_bytes: 256
import collections
def main():
    A = str(input())
    c = collections.Counter(A)
    c_list = list(c.items())

    ans = len(A)*(len(A)-1)//2
    for i in range(len(c_list)):
    	ans -= c_list[i][1]*(c_list[i][1]-1)//2

    print(ans+1)

if __name__ == "__main__":
    main()

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

#define int long long
const double PI = 3.14159265358979323846;
typedef vector<int> vint;
typedef pair<int, int> pint;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};

int N, K;
int a[110000];
signed main() {
    int idx;
    cin >> N >> K;
    for (int i = 0; i < N; i++) {
        cin >> a[i];
        if (a[i] == 1) {
            idx = i;
        }
    }
    N--;
    K--;
    cout << N / K + (N % K == 0 ? 0 : 1);
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cmath>
using namespace std;
int main()
{
	int n;
 	scanf("%d",&n);
 	int i=0;
 	while(n>=pow(2,i))
 	i++;
 	printf("%.lf\n",pow(2,i-1));
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main(){
  int n,d,r=0;
  cin>>n>>d;
  vector<vector<int>> x(n,vector<int>(d));
  for(auto& v:x)for(auto& i:v)cin>>i;
  for(int i=0;i<n-1;++i)for(int j=i+1;j<n;++j){
    int sum=0,sq;
    for(int k=0;k<d;++k)sum+=(x[i][k]-x[j][k])*(x[i][k]-x[j][k]);
    sq=sqrt(sum);
    if(sq*sq==sum)r++;
  }
  cout<<r;
}

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

int main(int argc, char const* argv[])
{
	int n,a;
	std::vector<int> ai;

	std::cin >> n;
	for (int i = 0; i < n; i++) {
		std::cin >> a;
		ai.push_back(a);
	}
	for (int i = 0; i < n; i++) {
		if (i) {
			std::cout << " ";
		}
		std::cout << ai.back();
		ai.pop_back();
	}
	std::cout << std::endl;

	return 0;
}

Measured memory_bytes: 1216
import java.util.Scanner

import scala.collection.mutable.ArrayBuffer


object Main {

  // u: from
  // v: to
  case class Edge(u: Int, v: Int, w: Long)

  def read() = {
    val sc = new Scanner(System.in)
    val n = sc.nextInt()
    val edges = IndexedSeq.fill(n-1)(Edge(sc.nextInt(), sc.nextInt(), sc.nextInt()))
    (n, edges)
  }

  def solve(n:Int, edges:IndexedSeq[Edge]): IndexedSeq[Int] = {
    val nextList = IndexedSeq.fill(n+1)(ArrayBuffer.empty[Edge])
    for(edge <- edges){
      val from = edge.u
      val to = edge.v
      nextList(from).append(edge)
      nextList(to).append(Edge(to, from, edge.w))
    }
    val visited = Array.fill(n+1)(false)
    // 1から
    visited(1) = true
    val open: java.util.Queue[Int] = new java.util.ArrayDeque[Int]()
    //add, remove
    open.add(1)
    //白:false ,黒:true
    val colors = Array.fill(n+1)(true)
    colors(1) = false


    while(!open.isEmpty){
      val current = open.remove()
      for(edge <- nextList(current)){
        val next = edge.v
        if(!visited(next)) {
          val w = edge.w
          if (w % 2 == 0) {
            colors(next) = colors(current)
          } else {
            colors(next) = !colors(current)
          }
          visited(next) = true
          open.add(next)
        }
      }
    }
    colors.takeRight(n).map(p => if(p) 1 else 0)
  }

  def main(args: Array[String]): Unit = {
    val (n, edges) = read()
    //println(solve(n, edges))
    solve(n,edges).foreach(println)
  }
}

Measured memory_bytes: 118980
#include<bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
 
#define f first
#define s second
#define pb push_back
#define mp make_pair
#define rep(i,a,b) for (int i=a; i<b; i++)
// #define endl "\n"
const int mod = 1000000007;

ll power(ll x, ll y) 
{ 
    ll res = 1;     // Initialize result 
   
    while (y > 0) 
    { 
        // If y is odd, multiply x with result 
        if (y & 1) 
            res = res*x; 
        res%=mod;
        // n must be even now 
        y = y>>1; // y = y/2 
        x = x*x;
        x%=mod;  // Change x to x^2 
    } 
    return res%mod; 
}

int main() {
    ios_base::sync_with_stdio(false);    //Fast I/O
    cin.tie(NULL);
 
    // freopen("input.txt", "r", stdin);    // Read and write from a file
    // freopen("output.txt", "w", stdout);
    int n, m;
    cin >> n >> m;
    string str;
    cin >> str;
    int len = str.size();
    int step=0, i=len-1;
    vector<int> output;
    while(i>0){
        step=m;
        if(i-step < 0){
            output.pb(i);
            break;
        }
        while(str[i-step]=='1')
            step--;
        if(step==0){
            cout << -1 << endl;
            return 0;
        }
        output.pb(step);
        i=i-step;
    }

    for(int i=output.size()-1; i>=0; i--)
        cout << output[i] << " ";
    cout << endl;
 
 
    return 0;
}

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

using namespace std;

typedef long long LL;
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

int main(){
	int N; cin >> N;
	vector<int> a(N),b(N);
	repp(i,0,N) cin >> b[i];
	repm(i,N-1,-1){
		repm(k,i,-1){
			if(k+1 == b[k]){
				a[i] = k+1;
				break;
			}
			if(k == 0) return cout << -1 << endl, 0;
		}
		repp(k,a[i],i+1) b[k-1] = b[k];
	}
	repp(i,0,N) cout << a[i] << endl;
	return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main()
{
    int X,Y,Z,n;
    scanf("%d %d %d", &X,&Y,&Z);
    n=X;
    X=Y;
    Y=n;
    n=X;
    X=Z;
    Z=n;
    printf("%d %d %d",X,Y,Z);
    return 0;
}


Measured memory_bytes: 1696
from collections import Counter
N = int(input())
ans = 0
C = Counter([])
for a in range(1, N + 1):
    for b in range(1, N + 1):
        if a * b >= N:
            break
        ans += 1
        if a == b:
            C[a * b] += 1

for v in C.values():
    if v >= 2:
        ans -= (v - 1)
print(ans)


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

int main(){
  int N, M;
  cin>>N>>M;
  vector<int> answer(N+1);
  for(int i=0; i<M; i++){
    int a, b;
    cin>>a>>b;
    answer.at(a)++;
    answer.at(b)++;
  }
  for(int i=1; i<=N; i++) cout<<answer.at(i)<<endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,h[100005],dp[100005];
int main()
{
	cin >> n;
	for(int i=1; i<=n; i++) cin >> h[i];
	dp[n-1]=abs(h[n-1]-h[n]);
	for(int i=n-2; i>=1; i--) dp[i]=min(dp[i+1]+abs(h[i]-h[i+1]),dp[i+2]+abs(h[i]-h[i+2]));
	cout << dp[1];
	return 0;
}

Measured memory_bytes: 4384
#include <stdio.h>
#include <string.h>
char s[100001];
bool dp[100001];
int main()
{
	scanf("%s",s+1);
	int n=int(strlen(s+1));
	dp[0]=true;
	for (int i=5;i<=n;++i)
		if ((s[i-4]=='d'&&s[i-3]=='r'&&s[i-2]=='e'&&s[i-1]=='a'&&s[i]=='m'&&dp[i-5])||
				(i>=7&&s[i-6]=='d'&&s[i-5]=='r'&&s[i-4]=='e'&&s[i-3]=='a'&&s[i-2]=='m'&&s[i-1]=='e'&&s[i]=='r'&&dp[i-7])||
				(s[i-4]=='e'&&s[i-3]=='r'&&s[i-2]=='a'&&s[i-1]=='s'&&s[i]=='e'&&dp[i-5])||
				(i>=6&&s[i-5]=='e'&&s[i-4]=='r'&&s[i-3]=='a'&&s[i-2]=='s'&&s[i-1]=='e'&&s[i]=='r'&&dp[i-6]))
			dp[i]=true;
	printf("%s",dp[n]?"YES":"NO");
	return 0;
}


Measured memory_bytes: 384
/**
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⣠⡖⠁⠀⠀⠀⠀⠀⠀⠈⢲⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⣼⡏⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣧⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣸⣿⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⣿⣇⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⣿⣿⡇⠀⢀⣀⣤⣤⣤⣤⣀⡀⠀⢸⣿⣿⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⢻⣿⣿⣔⢿⡿⠟⠛⠛⠻⢿⡿⣢⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣀⣤⣶⣾⣿⣿⣿⣷⣤⣀⡀⢀⣀⣤⣾⣿⣿⣿⣷⣶⣤⡀⠀⠀⠀⠀
⠀⠀⢠⣾⣿⡿⠿⠿⠿⣿⣿⣿⣿⡿⠏⠻⢿⣿⣿⣿⣿⠿⠿⠿⢿⣿⣷⡀⠀⠀
⠀⢠⡿⠋⠁⠀⠀⢸⣿⡇⠉⠻⣿⠇⠀⠀⠸⣿⡿⠋⢰⣿⡇⠀⠀⠈⠙⢿⡄⠀
⠀⡿⠁⠀⠀⠀⠀⠘⣿⣷⡀⠀⠰⣿⣶⣶⣿⡎⠀⢀⣾⣿⠇⠀⠀⠀⠀⠈⢿⠀
⠀⡇⠀⠀⠀⠀⠀⠀⠹⣿⣷⣄⠀⣿⣿⣿⣿⠀⣠⣾⣿⠏⠀⠀⠀⠀⠀⠀⢸⠀
⠀⠁⠀⠀⠀⠀⠀⠀⠀⠈⠻⢿⢇⣿⣿⣿⣿⡸⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀⠈⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣼⣿⣿⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠐⢤⣀⣀⢀⣀⣠⣴⣿⣿⠿⠋⠙⠿⣿⣿⣦⣄⣀⠀⠀⣀⡠⠂⠀⠀⠀
⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠉⠀⠀⠀⠀⠀⠈⠉⠛⠛⠛⠛⠋⠁⠀⠀
 *    author:  Daredevil666
 *    institution: IIT Patna
**/
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>
#define nl cout<<"\n";
#define ll long long int
#define REP(i,a,n) for(i=a;i<=n;i++)
#define F(i,a,b) for(i=a;i<b;i++)
#define RF(i,b,a) for(i=b;i>=a;i--)
#define IOS  ios::sync_with_stdio(false);cin.tie(0);
using namespace std;
const ll M=1e9+7;
const ll MAXN=1000200;
ll i,j,mask,test;
ll mod(ll x){
   return ((x%M + M)%M);
}
ll add(ll a,ll b){
  return mod(mod(a)+mod(b));
}
ll mul(ll a,ll b){
  return mod(mod(a)*mod(b));
}
int main()
{
IOS
/*#ifndef ONLINE_JUDGE
   freopen("input.txt","r",stdin);
   freopen("output.txt","w",stdout);
#endif // ONLINE_JUDGE*/
vector<ll> v(MAXN);
F(i,1,1e6+1)
{
    v[i]=2;
}
for(i=2;i*i<=1000000;i++)
{
    for(j=i;i*j<=1000000;j++)
    {
        if(i!=j)
            v[i*j]+=2;
        else
            v[i*j]++;
    }
}
v[1]=1;
ll n;
cin>>n;
ll ans=0;
F(i,1,n)
{
    ans+=v[n-i];
}
cout<<ans;
return 0;
}


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

int dp[3][100005];

int solution(int* arr1 , int* arr2 , int* arr3 , int n){
    
    dp[0][1] = arr1[0];
    dp[1][1] = arr2[0];
    dp[2][1] = arr3[0];


    for(int i=2 ; i<=n ; i++){
        dp[0][i] = max(arr1[i-1]+dp[1][i-1] , arr1[i-1]+dp[2][i-1]);
        dp[1][i] = max(arr2[i-1]+dp[0][i-1] , arr2[i-1]+dp[2][i-1]);
        dp[2][i] = max(arr3[i-1]+dp[0][i-1] , arr3[i-1]+dp[1][i-1]);
    }
    
    return max(dp[0][n] , max(dp[1][n] , dp[2][n]));
}


int main(){
    int n;
    cin>>n;
    int* arr1 = new int[n];
    int* arr2 = new int[n];
    int* arr3 = new int[n];

    for(int i=0 ; i<n ; i++){
        cin>>arr1[i];
        cin>>arr2[i];
        cin>>arr3[i];
    }
    cout<<solution(arr1 , arr2 , arr3 , n)<<endl;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

int Gcd(int a, int b) {
    return b ? Gcd(b, a%b) : a;
}

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

    int N; cin >> N;
    double res = 0.0;

    rep(i, 0, N) {
        double num; string type;
        cin >> num >> type;

        if (type == "BTC") num *= 380000.0;
        res += num;
    }

    printf("%.15lf\n", res);
}

Measured memory_bytes: 384
#include <iostream>
using namespace std;
typedef long long int ll;
int mod=1e9+7;
ll fact[1000000];
ll beki(ll a,ll b,ll mod){ //aのb乗 ただしbは10^18以下
    if(b==0)return 1;
	if(b%2==0){
		ll d=beki(a,b/2,mod);
		return (d*d)%mod;
	}
    return (a*beki(a,b-1,mod))%mod;
}
 
void factorial(ll mod){
    fact[0]=1;
	fact[1]=1;
	for(int i=2;i<1000000;i++){
		fact[i]=(fact[i-1]*i)%mod;
	}
}
 
ll nCr(ll n,ll r){
	ll k=fact[n];
	k=(k*beki(fact[n-r],mod-2,mod))%mod;
	k=(k*beki(fact[r],mod-2,mod))%mod;
 
	return k;
}

ll solve(int h,int w,int i,int j){
    factorial(mod);
    ll ans=0;
    int y=h-i-1;
    int x=j;
    while(y>-1&&x<w+1){
        ans=(nCr(x+y,x)*nCr(h+w-x-y-2,h-y-1)+ans)%mod;      
        x++;
        y--;
    }
    return ans;
}

int main() {
	// your code goes here
	int h,w,i,j;
	cin>>h>>w>>i>>j;
	cout<<solve(h,w,i,j)<<endl;
}

Measured memory_bytes: 8192
public class B
{
  public static void Main()
  {
    string s = System.Console.ReadLine();
    int counter = 0;
    if(s[0] == '1')counter++;
    if(s[1] == '1')counter++;
    if(s[2] == '1')counter++;
    System.Console.WriteLine(counter.ToString());
  }
}

Measured memory_bytes: 13140
import java.util.*;
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		String [] s = new String[n];
		boolean yellow = false;
		for(int i = 0; i < n; i++) {
			s[i] = sc.next();
			if(s[i].equals("Y")) {
				yellow = true;
				break;
			}
		}
		if(yellow) {
			System.out.println("Four");
			}
		else {
			System.out.println("Three");
		}
		sc.close();
	}

}


Measured memory_bytes: 21844
#include <cstdio>
#include <iostream>
#include <math.h>
using namespace std;

int main() {
  int N;
  int sum;
  int x, y;
  cin >> N;
  for (int i = 0; i < N; i++) {
    cin >> x >> y;
    sum += (y - x + 1);
  }
  cout << sum << endl;
  return 0;
}


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

using namespace std;

#define EACH(i,a) for (auto& i : a)
#define FOR(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RFOR(i,a,b) for(int i=(int)b-1;i>=(int)a;--i)
#define REP(i,n) FOR(i,0,n)
#define RREP(i,n) RFOR(i,0,n)
#define ALL(a) (a).begin(),(a).end()
#define debug(x) cerr << #x << ":" << x << endl;
#define OK(ok) cout << (ok ? "Yes" : "No") << endl;
typedef long long ll;

void CINT(){}
template <class Head,class... Tail>
void CINT(Head&& head,Tail&&... tail) {
  cin >> head; CINT(move(tail)...);
}
#define CIN(...) int __VA_ARGS__;CINT(__VA_ARGS__)
#define LCIN(...) ll __VA_ARGS__;CINT(__VA_ARGS__)
#define SCIN(...) string __VA_ARGS__;CINT(__VA_ARGS__)

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

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

  SCIN(s);
  int ans = 0;
  REP(i, s.size()) {
    if (s[i] == '+') ans++;
    else ans--;
  }

  cout << ans << endl;

  return 0;
}



Measured memory_bytes: 256
#include<cstdio>
#include<cstring>
#include<algorithm>
#define N 300010
#define ll long long
#define pa(a, b) (data){a, b}
using namespace std;

struct data{int x; ll y;}d[N];
struct bb{int x, y, id;}b[N];
int n, t[N], cl, m;
ll s[N], f[N], g[N], ans[N], f1[N], f2[N];

inline void solve_f(){
	s[0]=0; for(int i=1; i<=n; i++)s[i]=s[i-1]+t[i];
	f[0]=0; cl=1; d[cl]=pa(0, 0);
	ll y;
	for(int i=1; i<=n; i++){
		while(cl>=2&&d[cl].y-(ll)2*i*d[cl].x<=d[cl-1].y-(ll)2*i*d[cl-1].x)cl--;
		f[i]=max(f[i-1], f[d[cl].x]+(ll)(i-d[cl].x)*(i-d[cl].x+1)/2-s[i]+s[d[cl].x]);
		y=2*(f[i]+s[i])+(ll)i*i-i;
		while(cl>=2&&(y-d[cl-1].y)*(i-d[cl].x)<=(y-d[cl].y)*(i-d[cl-1].x))cl--;
		d[++cl]=pa(i, y);
	}
}

inline bool cmp(bb a, bb b){return a.x<b.x;}

inline void fz(int L, int R, int LL, int RR){
	if(LL>RR)return;
	int mid=(L+R)>>1, m1=LL-1, m2=RR+1;
	while(m1<RR&&b[m1+1].x<mid)m1++;
	while(m2>LL&&b[m2-1].x>mid)m2--;
	
	int x; ll y;
	cl=0;
	for(int i=R; i>=mid; i--){
		y=2*g[i+1]-2*s[i]+(ll)i*i+3*i;
		while(cl>=2&&(y-d[cl-1].y)*(d[cl].x-i)<=(y-d[cl].y)*(d[cl-1].x-i))cl--;
		d[++cl]=pa(i, y);
	}
	for(int i=mid; i>=L; i--){
		while(cl>=2&&d[cl].y-(ll)2*i*d[cl].x<=d[cl-1].y-(ll)2*i*d[cl-1].x)cl--; x=d[cl].x;
		f1[i]=g[x+1]+(ll)(x-i+1)*(x-i+2)/2-s[x]+s[i-1]+f[i-1];
	}
	
	cl=0;
	for(int i=L; i<=mid; i++){
		y=2*(f[i-1]+s[i-1])+(ll)i*i-3*i;
		while(cl>=2&&(y-d[cl-1].y)*(i-d[cl].x)<=(y-d[cl].y)*(i-d[cl-1].x))cl--;
		d[++cl]=pa(i, y);
	}
	for(int i=mid; i<=R; i++){
		while(cl>=2&&d[cl].y-(ll)2*i*d[cl].x<=d[cl-1].y-(ll)2*i*d[cl-1].x)cl--; x=d[cl].x;
		f2[i]=f[x-1]+(ll)(i-x+1)*(i-x+2)/2-s[i]+s[x-1]+g[i+1];
	}
	
	for(int i=L+1; i<=mid; i++)f1[i]=max(f1[i], f1[i-1]);
	for(int i=R-1; i>=mid; i--)f2[i]=max(f2[i], f2[i+1]);
	
	for(int i=LL; i<=m2-1; i++)ans[b[i].id]=max(ans[b[i].id], f1[b[i].x]+t[b[i].x]-b[i].y);
	for(int i=m2; i<=RR; i++)ans[b[i].id]=max(ans[b[i].id], f2[b[i].x]+t[b[i].x]-b[i].y);
	
	if(L<mid)fz(L, mid-1, LL, m1);
	if(mid<R)fz(mid+1, R, m2, RR);
}

int main(){
	scanf("%d", &n);
	for(int i=1; i<=n; i++)scanf("%d", &t[i]);
	for(int i=1; i<=n/2; i++)swap(t[i], t[n-i+1]); solve_f();
	for(int i=n+1; i; i--)g[i]=f[n-i+1];
	for(int i=1; i<=n/2; i++)swap(t[i], t[n-i+1]); solve_f();
	scanf("%d", &m);
	for(int i=1; i<=m; i++){scanf("%d%d", &b[i].x, &b[i].y); b[i].id=i;}
	sort(b+1, b+1+m, cmp);
	for(int i=1; i<=m; i++)ans[b[i].id]=f[b[i].x-1]+g[b[i].x+1];
	fz(1, n, 1, m);
	for(int i=1; i<=m; i++)printf("%lld\n", ans[i]);
	return 0;
}

Measured memory_bytes: 22912
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> V;
#define rep(cnt,e) for(ll cnt=0;cnt<e;cnt++ )
typedef pair<ll,ll> P;
const ll mod = 1e9+7;
const ll INF = INT64_MAX;

ll i,j,k;


int main(){
   ll A,B;
   cin>>A>>B;
   cout<<A*B-A-B+1<<endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>//sort,reverse
#include<utility>//pair
#include<queue>//queue,priority_queue
#include<deque>//double_ended queue
#include<map>//map
using namespace std;
typedef long long LL; 
typedef pair<LL,LL> P;//Pでpair<-,->を表す。
const LL MAX=2000010;
const LL MOD=1000000007;
typedef map<LL,LL>::iterator Itr;

int main()
{ 
    LL n,k;
    cin>>n>>k;
    LL a[n];
    for(int i=0;i<n;i++){
        cin>>a[i];
    }
    sort(a,a+n);
    LL ans=0;
    for(int i=0;i<k;i++){
        ans=ans+a[i];
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 3596
/*****And nothing else matters!******/

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

#define pi 3.1415926535
#define endl "\n"
#define yes cout << "YES\n"
#define no cout << "NO\n"
#define ll long long
#define llu unsigned long long
#define setbits(x) __builtin_popcountll(x)
#define pb push_back
#define mp make_pair
#define sz(x) (int)x.size()
#define tc int test_case; cin >> test_case; while(test_case--)
#define f(i,a,n) for(int i = a ; i < n ; i++)
#define rf(i,n,a) for(int i = n-1 ; i >= a ; i--)
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
#define get(a,n) f(i,0,n) cin >> a[i];
#define show(a,n) f(i,0,n) cout << a[i] << " "; cout << endl;
#define sp(x) fixed << setprecision(10) << x
#define nitro ios:: sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define trace(x) cerr << '>' << #x << ':' << (x) << "\n"
#define trace2(x,y) cerr<< '>' << #x << ':' << (x) << " | " << #y << ':' << (y) << "\n"
#define trace3(a,b,c) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<"\n"
#define trace4(a,b,c,d) cerr<<#a<<"="<<(a)<<", "<<#b<<"="<<(b)<<", "<<#c<<"="<<(c)<<", "<<#d<<"="<<(d)<<"\n"

typedef long double ld;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<pii,int> ppi;
typedef vector<pii> vpi;
typedef map<int,int> mii;
typedef map<ll,ll> mll;

const int inf = 1e9;
const ll inf64 = 1e18;
const int mod = inf + 7;
const int N = 2e5 + 10;

int main()
{
    nitro;
    int n;
    cin >> n;
    vpi a(n);
    f(i,0,n)
        cin >> a[i].F >> a[i].S;
    int cnt = 0;
    f(i,0,n)
    {
        if(a[i].F == a[i].S)
            cnt++;
        else
            cnt = 0;
        if(cnt >= 3)
        {
            cout << "Yes";
            return 0;
        }
    }
    cout << "No";
}


Measured memory_bytes: 3588
/*
QUESTION    :

RULE        :

INPUT       :

OUTPUT      :
*/
/*
    int     :10^9
long long   :10^19
*/
#include<bits/stdc++.h>
#define rep(i,a,n) for(int i=a;i<(n);++i)
#define repeq(i,a,n) for(int i=a;i<=(n);++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
const long double PI =(acos(-1));

int main(){
    int L,R,d;
    int cnt=0;
    cin >> L >> R >>d;
    for(int i=L;i<=R;++i){
        if(i%d==0){
            cnt++;
        }
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#include <atcoder/all>
#define ll long long int
#define ld long double
#define yorn(f) cout<<((f)?"Yes":"No")<<endl;
#define YORN(f) cout<<((f)?"YES":"NO")<<endl;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define repi(i, n) for (ll i = 1; i < (ll)(n); i++)
#define all(x) (x).begin(), (x).end()
#define put(x) cout << x << endl;
#define println(x) cout << x << endl;
using namespace std;
using namespace atcoder;


void Main()
{
    ll n, K;
    cin >> n >> K;

    ll INF = 1e9;

    mcf_graph<int, ll> g(2 * n + 2);
    int s = 2 * n;
    int t = 2 * n + 1;

    g.add_edge(s, t, n * K, INF);

    // 終点・始点とのつなぎ
    rep(i, n) {
        g.add_edge(s, i, K, 0);
        g.add_edge(n + i, t, K, 0);
    }

    rep(i, n) rep(j, n) {
        ll a;
        cin >> a;
        g.add_edge(i, n + j, 1, INF - a);
    }

    auto res = g.flow(s, t, n * K);
    put(n * K * INF - res.second);

    vector<string> S(n, string(n, '.'));
    for (auto e: g.edges()) {
        if (e.from == s || e.to == t || e.flow == 0) continue;
        S[e.from][e.to - n] = 'X';
    }

    rep(i, n) put(S[i]);
}
signed main(){ Main();return 0;}

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

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

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define DEBUG_VEC(v) cout<<#v<<":";REP(i,v.size())cout<<" "<<v[i];cout<<endl
#define ALL(a) (a).begin(),(a).end()

#define CHMIN(a,b) a=min((a),(b))
#define CHMAX(a,b) a=max((a),(b))

// mod
const ll MOD = 1000000007ll;
#define FIX(a) ((a)%MOD+MOD)%MOD

// floating
typedef double Real;
const Real EPS = 1e-11;
#define EQ0(x) (abs(x)<EPS)
#define EQ(a,b) (abs(a-b)<EPS)
typedef complex<Real> P;

int main(){
  int n;
  cin>>n;
  int ans = 0;
  FOR(i,1,n+1)if(i%2==1){
    int cnt = 0;
    FOR(j,1,i+1)if(i%j==0)cnt++;
    if(cnt==8)ans++;
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0; i<(int)(n); i++)
#define RNG(i,from,to) for(int i=(from); i<(int)(to); i++)
#define gcd(i,j) __gcd((i), (j))
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<ll> vecll;
template<typename S, typename T> string to_string(pair<S, T> p) { return "("+to_string(p.first)+","+to_string(p.second)+")"; }
template<typename T> string to_string(T p[2]) { return "["+to_string(p[0])+","+to_string(p[1])+"]"; }
template<typename T> void println(T e){ cout << to_string(e) << endl; }
template<typename T> void println(const vector<T>& v){ cout << "[";for(const auto& e : v){ cout << to_string(e) << ","; }cout << "]";cout << endl; }
template<typename T> void println(const vector<vector<T>>& vv){ for(const auto& v : vv){ println(v); } }
template<typename Iter> void println(Iter first, Iter last){ for(auto it=first; it != last; it++){ cout << *it << " "; }; cout << endl; }
template<typename T> T mod_pow(T x, T n, const T &p) { T ret = 1; while(n > 0) { if(n & 1) (ret *= x) %= p; (x *= x) %= p; n >>= 1; } return ret; }
template<typename T> T mod_inv(T x, const T &p) { return mod_pow(x, p-2, p); }
const ll DVSR = 1e9+7;


int main(int argc, char const *argv[])
{
  ll N; cin >> N;
  vecll AS(N);
  REP(i, N) cin >> AS[i];
  sort(AS.begin(), AS.end());
  // println(AS);
  unordered_set<ll> st;
//   N=II()
// AS=LI()
// AS.sort()
// st = set()


  ll res = 0;
  REP(i, N) {
    if ((i < N) && AS[i+1] == AS[i] || st.find(AS[i]) != st.end()) {
      st.insert(AS[i]);
      continue;
    }
    auto ok = true;
    RNG(k, 1, (int)(sqrt((double)AS[i])+1)) {
      if (AS[i]%k == 0) {
        // cout << k << " " << AS[i] << endl;
        if ((st.find(k) != st.end()) || st.find(AS[i]/k) != st.end()) {
          ok = false;
        }
      }
    }
    if (ok) res += 1;
    st.insert(AS[i]);
  }
  // for (ll i : st) {
  //   cout << i << " ";
  // }
  // cout << endl;
  cout << res << endl;
  return 0;
}


Measured memory_bytes: 12868
#include <iostream>
#include <string>
#define rep(i,n) for(int i=0; i<n; i++)
using namespace std;
int main()
{
	int a, b, ans;
	cin >> a >> b;
	if(b%a == 0) ans = a+b;
	else ans = b-a;
	cout << ans <<endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a >> b;
  
  if (a==1)
    a = 14;
  if (b==1)
    b = 14;
  
  if (a > b)
    cout << "Alice";
  if (a == b)
    cout << "Draw";
  if (a < b)
    cout << "Bob";
  
}

Measured memory_bytes: 3556
#include <iostream>
#include <iomanip>
#include <algorithm>
using namespace std;
#include <cstdio>
#include <tuple>
#include <string>
#include <vector> 
#include <set>
#include <string.h>
#include <map>
#include <cmath>
#include <deque>
using Graph = vector<vector<int>>;
using Graph_Wei = vector<vector<pair<int,int>>>;
using ll = long long;



int main() {

    ll n =0;
    ll k =0;
    cin >> n >> k;
    vector<ll> h(n);
    
    for(ll i=0;i < n;i++) cin >> h[i];

    sort(h.begin(),h.end(),greater<int>());//降順ソート

    ll sum =0;
    
    for(ll i=k;i < n;i++){

        sum = sum + h[i];

    }
    
    
    
    cout << sum << endl;



    return 0;

}
   

Measured memory_bytes: 1792
import java.util.*;

class Main{
	public static void main(String[] $){
		Scanner s=new Scanner(System.in);
		
		int a[]=new int[4];
		Arrays.setAll(a,i->s.nextInt());
		Arrays.sort(a);
		int[]b= {1,4,7,9};
		System.out.println(
				Arrays.equals(a,b)?"YES":"NO"
				);
	}
}

Measured memory_bytes: 27348
# encoding:utf-8
import copy
import random
import bisect #bisect_left　これで二部探索の大小検索が行える
import fractions #最小公倍数などはこっち
import math
import sys

mod = 10**9+7
sys.setrecursionlimit(mod) # 再帰回数上限はでdefault1000

def LI(): return list(map(int, sys.stdin.readline().split()))

N = int(input())
BA = [[] for i in range(N)]
for i in range(N):
    a,b = LI()
    BA[i] = (b,a)

BA.sort()
part_A = [0 for i in range(N)]
for i in range(N):
    B,A = BA[i]
    part_A[i] = A + part_A[i-1]

for i in range(N):
    B,A = BA[i]
    if B - part_A[i] < 0:
        print("No")
        break
else:
    print("Yes")


Measured memory_bytes: 40412
#include <bits/stdc++.h>
using namespace std;
//    std::sort(a.begin(), a.end(), std::greater<int>() );
#define REP(i, s, n) for (int i = s; i < n; ++i)
#define rep(i, n) REP(i, 0, n)
#define SORT(c) sort((c).begin(), (c).end())
#define IINF INT_MAX
#define LLINF LLONG_MAX
#define DEBUG false

using namespace std;
/*
std::vector<std::string> split(const std::string &input, char delimiter)
{
    std::istringstream stream(input);

    std::string field;
    std::vector<std::string> result;
    while (std::getline(stream, field, delimiter))
    {
        result.push_back(field);
    }
    return result;
}
*/
int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    rep(a, n+1)
    {
        rep(b, m+1)
        {
            if (k == (a * m + b * n - 2*a * b))
            {
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import sys
import itertools
# import numpy as np
import time
import math
 
sys.setrecursionlimit(10 ** 7)
 
from collections import defaultdict
 
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

H, N = map(int, readline().split())
A = [0] * N
B = [0] * N

for i in range(N):
    A[i], B[i] = map(int, readline().split())

MAX = 10 ** 10
dp = [MAX] * (H + 1)
dp[0] = 0
for i in range(N):
    for h in range(1, H + 1):
        if A[i] >= h:
            dp[h] = min(dp[h], B[i])
        else:
            dp[h] = min(dp[h], dp[h - A[i]] + B[i])
print(dp[H])


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

using I = long long;
const I M = 998244353;

struct Point {I x, y;};
bool same_line(auto& a, auto& b, auto& p) {
  Point v1{b.x-a.x, b.y-a.y};
  Point v2{p.x-a.x, p.y-a.y};
  return v1.x*v2.y == v1.y*v2.x;
}

int main() {
  int N;
  cin >> N;
  vector<Point> P(N);
  for(auto& i: P) cin >> i.x >> i.y;

  I ans = 1;
  for(auto i=0; i<N; ++i) ((ans *= 2) %= M);
  (ans -= 1 + N + N*(N-1)/2) %= M;

  vector<vector<bool>> used(N, vector<bool>(N));
  for(auto i=0; i<N; ++i) for(auto j=i+1; j<N; ++j) if(!used[i][j]) {
    vector<int> v = {i, j};
    for(auto k=j+1; k<N; ++k) if(same_line(P[i], P[j], P[k])) v.emplace_back(k);
    if(v.size() <= 2) continue;
    for(auto x: v) for(auto y: v) used[x][y] = true;
    I cnt = 1;
    for(auto k=0; k<v.size(); ++k) (cnt *= 2) %= M;
    (ans -= cnt) %= M;
    (ans += 1 + v.size() + v.size()*(v.size()-1)/2) %= M;
  }

  cout << (ans + M) % M << endl;
}


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

#define mx 100005
#define ll long long 

void IO()
{
     #ifndef ONLINE_JUDGE
	freopen("in.txt","r",stdin);
	freopen("out.txt","w",stdout);
	#endif
}

int ar[mx];
char ch[mx];

int m,n,ii;


void solve()
{
	ll x,k,d;
	cin>>x>>k>>d;
	ll dif;
	if(x>=0)
	{
		 dif=x-0;
	}
	else dif=0-x;
	ll bag=dif/d;
	if(dif<=d || bag<=k)
	{
		ll val=dif-bag*d;
		k-=bag;
		if(k%2==0)
		{
			cout<<val<<endl;

		}
		else 
		{
			cout<<abs(d-val)<<endl;
		}
	}
	else
	{
		cout<<abs(dif-k*d)<<endl;
	}
}

int main()
{
	IO();

	int t=1;
	while(t--)
	{
		solve();
	}
	return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define ll long long
#define pi 3.14159265358979
#define mod 1000000007
#define rep(i,n) for(ll i=0;i<n;i++)
using namespace std;

int main(){
    string s;
    cin>>s;
    if(s[0]==s[1]&&s[1]==s[2]){
        cout<<"No";
    }else{
        cout<<"Yes";
    }
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll mod = 1e9+7;
const int max_n = 1e6;
ll a[max_n];
int main(){
  ll n; cin >> n;
  map<ll,ll> ma;
  for(int i=0 ; i<n ; i++){
    cin >> a[i];
    ma[a[i]]++;
  }
  if(ma.count(0)){
    if(n%2==0 || ma[0] != 1){
      cout << 0 << endl;
      return 0;
    }
    ma.erase(0);
  }
  ll ans = 1;
  for(auto ite=begin(ma) ; ite != end(ma) ; ite++){
    if(ite -> second  != 2){
      cout << 0 << endl;
      return 0;
    }
    ans *= ite -> second % mod;
    ans %= mod;
  }
  cout << ans%mod << endl;
  return 0;
}


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

using namespace std;

int main(){
    int k,x;
    cin>>k>>x;
    int l=-1000000;
    int m=1000000;
    l=max(l,x-k+1);
    m=min(m,x+k-1);
    for(int i=l;i<m+1;i++){
        cout<<i<<" ";
    }
    cout <<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> pll;
typedef tuple<ll, ll, ll> tll;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C, X, Y;
    cin >> A >> B >> C >> X >> Y;
    ll answer = 1e12;
    ll maxC = max(X, Y) * 2;
    for (int i = 0; i <= maxC; i += 2)
    {
        answer = min(answer, A * max(0LL, X - i / 2) + B * max(0LL, Y - i / 2) + C * i);
    }
    cout << answer << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll MOD=1e9+7,INF=1e17;
const int iINF=1e9;
#define vi vector<int>
#define vl vector<ll>
ll check[100100][30];
int main(){
    ll n,ans=0;
    bool flag;
    cin>>n;
    string s;
    map<string,ll>mp;
    for(int i=0;i<n;i++){
        cin>>s;
        sort(s.begin(),s.end());
        mp[s]++;
    }
    for(auto x:mp){
        ll num=x.second;
        ans+=(num*(num-1))/2;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 11136
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> l_l;
typedef pair<int , int> i_i;
typedef vector<ll> vel;
typedef vector<int> vei;
typedef vector<char> vec;
typedef vector<bool> veb;
typedef vector<string> ves;
typedef vector<vector<ll>> ve_vel;
typedef vector<vector<int>> ve_vei;
typedef vector<vector<char>> ve_vec;
typedef vector<vector<bool>> ve_veb;
typedef vector<vector<string>> ve_ves;
#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 rep2(i,n) for(int i=2;i<(int)(n);i++)
#define repk(i,k,n) for(int i=k;i<(int)(n);i++)
#define fs first
#define sc second
#define pub push_back
#define pob pop_back
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define maxel(a) *max_element(all(a))
#define minel(a) *min_element(all(a))
#define acc accumulate
#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))
#define mod (1000000007)
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

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

    string s; cin >> s;
    string t;
    ves add = {"dreamer","dream","erase","eraser"};
    reverse(s.begin(), s.end());
    for (int i = 0; i < add.size(); i++) {
        reverse(add[i].begin(), add[i].end());
    }

    rep(i,s.size()/5 + 2) {
        bool check = false;
        rep(j,4) {
            if(add[j] == s.substr(t.size(),add[j].size())) {
                t += add[j];
                check = true;
                continue;
            }  
        }
    }
    cout << ((s == t) ? "YES" : "NO") << endl;
    return 0;

}

Measured memory_bytes: 592
from collections import Counter
N = int(input())
A = input()
B = input()
C = input()

ans = 0
for i in range(N):
    c = Counter()
    c[A[i]] += 1
    c[B[i]] += 1
    c[C[i]] += 1
    for j, (c, v) in enumerate(c.most_common()):
        if j == 0:
            continue
        ans += v
print(ans)


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

int main() {
	std::ios_base::sync_with_stdio(0);
	cin.tie(NULL);
	cout.tie(0);

	int n, m,x; cin >>x>> n >> m;
	if (abs(n - x) <= abs(m - x))cout << "A" << endl;
	else if (abs(n - x) > abs(m - x))cout << "B" << endl;
	return 0;
}



Measured memory_bytes: 3636
#include <iostream>
#include <cmath>
#include <algorithm>
#include <vector>
using namespace std;
int main() {
    int N; cin >> N;
    vector<int> H(N, 0);
    for (int i = 0; i < N; ++i) cin >> H[i];
    int ans = 0, cnt = 0;
    for (int i = 0; i < N - 1; ++i) {
        if (H[i] >= H[i + 1]) cnt++;
        else cnt = 0;
        ans = max(ans, cnt);
    }
    cout << ans << endl;
}

Measured memory_bytes: 640
import java.util.Scanner;

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

        String s=scan.nextLine();
       for(int i=0;i<s.length();i++){
           char a =s.charAt(i);
           if('a'<= a && a<='z'){
               System.out.print(Character.toUpperCase(a));
           }else if('A'<= a && a<='Z'){
               System.out.print(Character.toLowerCase(a));
           }else{
               System.out.print(a);
           }
       }
        System.out.println();
    }
}



Measured memory_bytes: 27136
#include<iostream>
#include <string>
using namespace std;
int main()
{
	int iodd = 0;
	int iedge = 0;
	int patternsum = 0;
	cin >> iodd >> iedge;
	//偶数ゼロの時
	if (iodd == 0) {
		patternsum = (iedge * (iedge - 1) / 2);
	}
	//奇数ゼロの時
	else if (iedge == 0) {
		patternsum = (iodd * (iodd - 1) / 2);
	}
	else {
		patternsum = (iodd * (iodd - 1) / 2) + iedge * (iedge - 1) / 2;
	}

	cout << patternsum;

	return 0;
}

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

class Program
{
    static int N;
    static string S;
    static string T;

    static void Main(string[] args)
    {
        var s = new Scanner();

        S = s.ReadStr();
        T = s.ReadStr();

        Solve();
    }

    static void Solve()
    {
        var ans = 0;
        for (int i = 0; i < 3; i++)
        {
            if (S[i] == T[i]) ans += 1;
        }

        Console.WriteLine(ans);
    }
}

class Scanner
{
    string[] S = new string[0];
    int Index = 0;
    char[] Separators = new char[] { ' ' };

    public string Next()
    {
        if (this.Index < this.S.Length) return this.S[this.Index++];
        var line = "";
        while (line == "") line = Console.ReadLine();
        this.S = line.Split(this.Separators, StringSplitOptions.RemoveEmptyEntries);
        if (this.S.Length == 0) return this.Next();
        this.Index = 0;
        return this.S[this.Index++];
    }

    public string ReadStr()
    {
        return this.Next();
    }

    public char ReadChar()
    {
        return this.Next()[0];
    }

    public int ReadInt()
    {
        return int.Parse(this.Next());
    }

    public uint ReadUInt()
    {
        return uint.Parse(this.Next());
    }

    public long ReadLong()
    {
        return long.Parse(this.Next());
    }

    public int[] ReadIntArray(int n)
    {
        var array = new int[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadInt();
        }
        return array;
    }

    public long[] ReadLongArray(int n)
    {
        var array = new long[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadLong();
        }
        return array;
    }

    public char[] ReadCharArray(int n)
    {
        var array = new char[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadChar();
        }
        return array;
    }

    public string[] ReadStrArray(int n)
    {
        var array = new string[n];
        for (int i = 0; i < array.Length; i++)
        {
            array[i] = this.ReadStr();
        }
        return array;
    }
}



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

int main(void) {
  using namespace std;

  vector<uint> data(3);

  for(uint i=0; i<data.size(); i++)
    cin >> data[i];

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

  vector<uint> ref;
  ref.emplace_back(5);
  ref.emplace_back(5);
  ref.emplace_back(7);
  
  if(data == ref)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  
  return 0;
}


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

using namespace std;

void solve() {
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    for (int i = 0; i < n; i++)
    {
        cin >> a[i];
    }
    
    int t = 0;
    if (n % 2)
    {
        // 奇数
        for (int i = n-1; i >= 0; i-=2 )
        {
            b[t] = a[i];
            t++;
        }
        for (int i = 1; i < n-1; i+=2)
        {
            b[t] = a[i];
            t++;
        }
        
    }
    else
    {
        for (int i = n-1; i > 0; i-=2 )
        {
            b[t] = a[i];
            t++;
        }
        for (int i = 0; i < n-1; i+=2)
        {
            b[t] = a[i];
            t++;
        }
    }
    
    for (int i = 0; i < n; i++)
    {
        cout << b[i];
        if (i != n-1)
        {
            cout << " ";
        }else{
            cout << endl;
        }
        
    }
    
    

}

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

Measured memory_bytes: 4788
#include<iostream>
using namespace std;
const int MAXN=101;
long long f[MAXN],X;
int main(){
	cin>>X;
	f[0]=2;
	for(int i=1;i<=X;i++){
		f[i]=f[i-1]*2+2;
	}
	cout<<f[X]<<endl;
	return 0;
}

Measured memory_bytes: 256
n,m=map(int,input().split())
num=[0]*n
wa=0
ac=0
for i in range(m):
    p,s=input().split()
    p=int(p)
    if s=="WA" and num[p-1]!=-1:
        num[p-1]+=1
    elif s=="AC" and num[p-1]!=-1:
        ac+=1
        wa+=num[p-1]
        num[p-1]=-1
print(ac,wa)


Measured memory_bytes: 3828
#include "bits/stdc++.h"
using namespace std;
#define MODULO 1000000007
#define PI 3.14159265359
typedef long long int ll;
int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int n=3;
    char A[3];
    int ct=0,res=0;
    for(int i=0;i<3;++i)
    cin>>A[i];
    for(int i=0;i<3;++i)
    {
    	if(A[i]=='R')
    	{
    	ct++;
    	res=max(res,ct);
        }
    	else
    	{
    		ct=0;
		}
	}
	cout<<res<<endl;
    return 0;
}


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

#define reb(i,b,n) for(int i=(int)(b); i<(int)(n); i++)
#define rep(i,n) reb(i,0,n)
#define rreb(i,b,n) for(int i = b-1; i >= n; i--)
#define rrep(i,n) reb(i,n,0)
#define each(it,v) for(__typeof((v).begin()) it=(v).begin();it!=(v).end();it++)
#define reach(it,v) for(__typeof((v).rbegin()) it=(v).rbegin();it!=(v).rend();it++)
#define vall(x) (x).begin(), (x).end()
#define rvall(x) (x).rbegin(), (x).rend()
#define vsort(v) sort(vall(v))
#define rvsort(v) sort(rvall(v))
#define len(array) (sizeof (array) / sizeof *(array))
#define aall(x) x, x+len(x)
#define asort(x) sort(aall(x))
#define rasort(a, type) sort(aall(a), greater<type>())
#define afill(a, v) fill(aall(a), v)
#define afill2(a, v, type) fill((type *)a, (type *)(a + len(a)), v)
#define sz(x) (int)(x).size()
#define mp(a, b) make_pair(a, b)
#define fi first
#define se second
#define pb push_back
#define _USE_MATH_DEFINES
#define priArr(table, n) rep(i,n){cout<<table[i]<<' ';}cout<<'\n';
#define priAr2(table,W,H) rep(y,H){rep(x,W)cout<<table[y][x]<<' ';cout<<'\n';}
#define dbg(x) cerr<<__LINE__<<": "<<#x<<" = ["<<(x)<<"]"<<endl;

using namespace std;
using std::stringstream;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline std::string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
template<class F, class T> inline void convert(const F &f, T &t){stringstream ss;ss<<f;ss>>t;}
template<class T> inline T sqr(T x) {return x*x;}

typedef long long ll; typedef unsigned long long ull;
typedef pair <int, int> P; typedef pair <int, P> PP;
typedef vector<int> vi;typedef vector<vi> vvi;typedef vector<string> vs;
typedef vector<ll> vl; typedef vector<P > vP; typedef vector<char> vc;
typedef long double ld;

const static int INF = 0x3f3f3f3f;
const static ll INFL = 0x3f3f3f3f3f3f3f3fLL;
const static double EPS = 1e-9;
const static ll MOD = 1000000007LL;

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

int main(int argc, char *argv[])
{
    int n;
    int a, b;
    int ans = 0;

    cin >> n;

    ans += (n / 500) * 1000;
    ans += ((n % 500) / 5) * 5;

    cout << ans << endl;

    return 0;
}


Measured memory_bytes: 256
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}

fn read_vec2<T: std::str::FromStr>(n: u32) -> Vec<Vec<T>> {
    (0..n).map(|_| read_vec()).collect()
}
fn main(){
    let n = read::<i64>();
    let mut sn = read_vec::<i64>();
    let t = read::<i64>();
    let tn = read_vec::<i64>();
    sn.sort();
    let mut ans = 0;
    for b in tn {
        let mut left = 0;
        let mut right = n;
        while left < right {
            let mid = (left + right) / 2;
            if sn[mid as usize] == b {
                ans += 1;
                break;
            } else if b < sn[mid as usize] {
                right = mid;
            } else {
                left = mid + 1;
            }
        }        
    }
    println!("{}",ans);
}


Measured memory_bytes: 6968
n = gets.chomp.to_i
a = gets.chomp.split(' ').map(&:to_i)

l, r = 0, 0
b = 0
answer = 0
while l < n && r <= n
  if r < n && b ^ a[r] == b + a[r]
    b ^= a[r]
    r += 1
  else
    while (r == n && l < n) || (r < n && b ^ a[r] != b + a[r])
      b ^= a[l]
      answer += r - l
      l += 1
    end
  end
end

puts answer

Measured memory_bytes: 28676