akhauriyash/Code-Regression huggingface dataset:
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);
		int l = sc.nextInt();

		List<Boolean> a = new ArrayList<>();
		List<Boolean> result = new ArrayList<>();

		for(int i = 0;i < l;i++) {
			a.add(sc.nextInt() == 1 ? true : false);
			result.add(false);
		}

		for(int i = l;i > 0;i--) {
			int loopNum = l / i;
			boolean isEven = false;

			for(int j = loopNum * i; j > i;j-=i) {
				if(result.get(j - 1)) {
					isEven = isEven ? false : true;
				}
			}

			result.set(i - 1,isEven ^ a.get(i - 1));
		}

		int count = 0;
		StringBuffer sb = new StringBuffer();
		for(int i = 0;i < l;i++) {
			if(result.get(i)) {
				count++;
				sb.append((i + 1) + " ");
			}
		}

		if(sb.length() > 0) {
			sb.setLength(sb.length() - 1);
			System.out.println(count);
			System.out.println(sb.toString());
		}else {
			System.out.println("0");
		}
	}
}


Measured memory_bytes: 66992
#include <iostream>
#include<algorithm>
#include<sstream>
#include<cmath>
#include<vector>
#include<iomanip>
#include<map>
#include<set>
#include<queue>
using namespace std;
typedef long long ll;
#define MAX 10000000000
#define rep(i,n) for(int i = 0; i < n;i++)
ll v, n, e, u, k, ans = 0,sum;
bool c[1000001];
template<typename A, size_t N, typename T>
void Fill(A(&array)[N], const T & val) {
	std::fill((T*)array, (T*)(array + N), val);
}
int main(void) {
	int s;cin >> s;
	for (;;) {
		if (s == 4 || s == 2 || s == 1) {
			ans++;
			break;
		}
		if (s % 2 == 1) s = 3 * s + 1;
		else s /= 2;
		ans++;
	}
	cout << ans + 3 << endl;
}

Measured memory_bytes: 256
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
vector<int> eratosu(300000, 1);

int solve(int N) {
    int ret = 0;
    for (int i = N + 1; i <= 2 * N; i++) {
        if (eratosu[i] == 1) ret++;
    }
    return ret;
}

int main() {
    int N;
    eratosu[0] = 0;
    eratosu[1] = 0;
    for (int i = 0; i < eratosu.size(); i++) {
        if (eratosu[i] == 1) {
            for (int j = 2; j * i < eratosu.size(); j++) {
                eratosu[i * j] = 0;
            }
        }
    }

    vector<int> ans;
    while (1) {
        cin >> N;
        if (!N) break;
        ans.push_back(solve(N));
    }

    for (int i : ans) cout << i << endl;
}


Measured memory_bytes: 3652
// フェルマーの小定理
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

const (
	m = 1000000007
)

func mpow(x, y int) int {
	result := 1
	for y != 0 {
		if y&1 == 1 {
			result *= x
			result %= m
		}
		x *= x
		x %= m
		y >>= 1
	}
	return result
}

func mcomb(n, k int) int {
	a := 1
	b := 1
	for i := 0; i < k; i++ {
		a *= n - i
		a %= m
		b *= i + 1
		b %= m
	}
	return a * mpow(b, m-2) % m
}

func main() {
	n := readInt()
	a := readInt()
	b := readInt()

	result := mpow(2, n) - 1
	result -= mcomb(n, a)
	result += m
	result %= m
	result -= mcomb(n, b)
	result += m
	result %= m
	fmt.Println(result)
}

const (
	ioBufferSize = 1 * 1024 * 1024 // 1 MB
)

var stdinScanner = func() *bufio.Scanner {
	result := bufio.NewScanner(os.Stdin)
	result.Buffer(make([]byte, ioBufferSize), ioBufferSize)
	result.Split(bufio.ScanWords)
	return result
}()

func readString() string {
	stdinScanner.Scan()
	return stdinScanner.Text()
}

func readInt() int {
	result, err := strconv.Atoi(readString())
	if err != nil {
		panic(err)
	}
	return result
}


Measured memory_bytes: 1804
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
#include<iterator>
#include<list>

using namespace std;

typedef  long long int lint;

#define rep(i, n) for (lint i = 0; i < n; i++)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define mp make_pair
#define enld endl

int main() {
	lint N, X;
	cin >> N >> X;
	vector<lint>A(N);
	rep(i, N) {
		cin >> A[i];
	}
	lint ans = 0;
	rep(i, N-1) {
		if (i == 0) {
			if (A[i] >= X) {
				ans += A[i+1];
				A[i+1] = 0;
				ans += A[i] - X;
				A[i] = X;
			}
			else {
				ans += max(lint(0),A[i] + A[i + 1] - X);
				A[i + 1] -= max(lint(0),(A[i] + A[i + 1]) - X);
			}
		}
		else if (i == N - 2) {
			if (A[i+1] >= X) {
				ans += A[i];
				A[i] = 0;
				ans += A[i+1] - X;
				A[i+1] = X;
			}
			else {
				ans += max(lint(0),A[i] + A[i + 1] - X);
				A[i] -= max(lint(0),(A[i] + A[i + 1]) - X);
			}
		}
		else {
			if (A[i] >= X) {
				ans += A[i + 1];
				A[i + 1] = 0;
				ans += A[i] - X;
				A[i] = X;
			}
			else {
				ans += max(lint(0),A[i] + A[i + 1] - X);
				A[i + 1] -= max(lint(0),(A[i] + A[i + 1]) - X);
			}
		}
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
import numpy as np

n = int(input())
a = list(map(int,input().split()))
b = []
cnt = 1
for num in a:
    num -= cnt
    b.append(num)
    cnt += 1
test = [int(np.mean(b))-1,int(np.mean(b)),int(np.mean(b))+1,int(np.median(b))]
test = list(set(test))
ans = []
s = 9999999999999
for i in test:
    cnt = 1
    c = []
    for num in a:
        st = 0
        st = abs(num - (i+cnt))
        c.append(st)
        cnt += 1
    ans.append(np.sum(c))
print(np.min(ans))

Measured memory_bytes: 37492
#include <bits/stdc++.h>
using namespace std;
int gcd(int a,int b){
  if(b==0){
    return a;
  }
  return gcd(b,a%b);
}
int main(){
  int n;
  cin >> n;
  vector<int> a(n+1),l(n),r(n),m(n);
  for(int i=0;i<n;i++){
    cin >> a[i];
  }
  l[0]=a[0];
  r[n-1]=a[n-1];
  for(int i=1;i<n;i++){
    l[i]=gcd(l[i-1],a[i]);
    r[n-i-1]=gcd(r[n-i],a[n-i-1]);
  }
  int ans=0;
  for(int i=0;i<n;i++){
    if(i==0){
      m[i]=r[1];
    }
    else if(i==n-1){
      m[i]=l[n-2];
    }
    else{
      m[i]=gcd(l[i-1],r[i+1]);
    }
    ans=max(ans,m[i]);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1792
# -*- coding: utf-8 -*-
N, C = map(int, input().split(' '))
lim = (10 ** 5 + 2) * 2
buf = [0 for _ in range(lim)]

import collections

c_durations_dict = collections.defaultdict(list)
for _ in range(N):
    s, t, c = map(int, input().split(' '))
    c_durations_dict[c].append((s, t))

for durations in c_durations_dict.values():
    durations.sort(key=lambda x: x[0])
    i = 0
    while i < len(durations):
        s1, t1 = durations[i]
        while i + 1 < len(durations) and t1 == durations[i + 1][0]:
            t1 = durations[i + 1][1]
            i += 1

        buf[s1 * 2 - 1] += 1
        buf[t1 * 2] -= 1
        i += 1

ans = 0
for i in range(1, lim):
    buf[i] += buf[i - 1]
    ans = max(ans, buf[i])

print(ans)


Measured memory_bytes: 59468
#NEED RE-SOLVE LATER.
from collections import deque
n, m = map(int, input().split())
G = [[] for _ in range(n)]
for i in range(m):
    a, b = map(lambda x: x-1, map(int, input().split()))
    G[a].append(b)
    G[b].append(a)

q = deque([0])
visited = [None]+[-1]*(n-1)
while q:
    nx = q.pop()
    for g in G[nx]:
        if visited[g] != -1:
            continue
        visited[g] = nx
        q.appendleft(g)

print('Yes')
print(*[visit+1 for visit in visited[1:]], sep='\n')

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

using namespace std;

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vll;

#define rep(i, a, b) for (int i = a; i < b; i++)
#define rrep(i, a, b) for (int i = a; i > b; i--)
#define repll(i, a, b) for (ll i = a; i < b; i++)

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

  int t, w;
  cin >> t >> w;

  if (t > w)
    cout << "safe" << endl;
  else
    cout << "unsafe" << endl;

  return 0;
}


Measured memory_bytes: 3652
s=gets.chomp
to=(1<<(s.length-1))
ret=0
# bit全探索
for i in 0...to
    t=s+""  # 別オブジェクトに変えたい
    # 文字列が変更されていくので、後ろから見る必要があります
    (s.length-1).downto(1){|j|
        if i&(1<<(j-1))>0
            t.insert(j,"+")
        end
    }
    ret+=eval(t)    # 計算はevalにお任せ
end
puts ret

Measured memory_bytes: 1916
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		//全体の個数を入力
		int n = sc.nextInt();
		// 入力値受け取りとリスト出力用
		int temp;
		//回数カウント用
		int count = 0;
		boolean result = true;
		//全体の個数を入力
		List<Integer> list = new ArrayList<>();
		//リストの入力
		for(int i = 0 ; i < n; i++){
			temp = sc.nextInt();
			list.add(temp);
		}
		for(int t = 0; t < n ; t++){
			if(result){
				temp = list.get(t);
				if(temp % 2 == 0){
					list.set(t,temp/2);
				}else{
					break;
				}
			}

			if(t == n - 1){
				//最初に戻す
				t = 0;
				count++;
			}
		}
		System.out.println(count);
	}
}


Measured memory_bytes: 21844
import sys
from bisect import bisect_left as bl
from collections import defaultdict as dd
input = sys.stdin.readline
S = list(input())[: -1]
d = dd(list)
mod = 10 ** 9 + 7
res = 0
for i in range(len(S)):
  d[S[i]].append(i)
for i in range(len(S)):
  if S[i] == "B":
    l = bl(d["A"], i)
    m = bl(d["?"], i)
    r = bl(d["C"], i)
    res += l * (len(d["C"]) - r) * pow(3, len(d["?"]), mod)
    res %= mod
    res += m * (len(d["C"]) - r) * pow(3, max(len(d["?"]) - 1, 0), mod) * (len(d["?"]) > 0)
    res %= mod
    res += l * (len(d["?"]) - m) * pow(3, max(len(d["?"]) - 1, 0), mod) * (len(d["?"]) > 0)
    res %= mod
    res += m * (len(d["?"]) - m) * pow(3, max(len(d["?"]) - 2, 0), mod) * (len(d["?"]) > 1)
    res %= mod
  elif S[i] == "?":
    l = bl(d["A"], i)
    m = bl(d["?"], i)
    r = bl(d["C"], i)
    res += l * (len(d["C"]) - r) * pow(3, len(d["?"]) - 1, mod)
    res %= mod
    res += m * (len(d["C"]) - r) * pow(3, max(len(d["?"]) - 2, 0), mod) * (len(d["?"]) > 1)
    res %= mod
    res += l * (len(d["?"]) - m - 1) * pow(3, max(len(d["?"]) - 2, 0), mod) * (len(d["?"]) > 1)
    res %= mod
    res += m * (len(d["?"]) - m - 1) * pow(3, max(len(d["?"]) - 3, 0), mod) * (len(d["?"]) > 2)
    res %= mod
  #print(res, i)
print(res)

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

//プロトタイプ宣言を忘れない！！
void trace(int A[], int N);
void sort(int A[], int N);

int main() {


	//C++において、nullがどのような扱いなのか
	int boxes[100];
	int n;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> boxes[i];
	}

	//最初のものを出力
	trace(boxes, n);
	sort(boxes, n);

	return 0;

	
}

//出力関数
void trace(int A[], int N) {

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

		if (i > 0) {
			cout << " ";
			
		}
		cout << A[i];
	}

	cout << ("\n");
}

//ソート関数
void sort(int A[], int N) {
	int j, v;
	//比較が行えるのは２番目から
	for (int i = 1; i < N; i++) {
		v = A[i];
		//j<i-1はソート済みの区間
		j = i - 1;
		//比較対象(A[J])があり、それがvよりも大きいとき
		while (j >= 0 && A[j] > v) {
			//ソート済みを１つ後ろにずらす
			A[j + 1] = A[j];
			j--;
		}
		//目的の場所
		A[j + 1] = v;
		trace(A, N);
	}
}


Measured memory_bytes: 3104
#Python

N = input()
S = raw_input()

#print N
#print S
chars=list(S)
#print chars

sum=0
for i in chars:
	if i == "(":
		sum+=1
		#print sum
	elif i== ")":
		sum-=1
		#print sum
		if sum<0:
			S="("+S
			sum=0

S=S+")"*sum

print S

Measured memory_bytes: 2568
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {

    int n, m1 = 0, m2;
    cin >> n;
    vector< int > v(n);
    for(int i = 0; i < n; i++) {
        cin >> v[i];
    }
    vector< int > t = v;
    sort(t.begin(), t.end());
    m1 = t[t.size() - 1], m2 = t[t.size() - 2];

    for(int i = 0; i < n; i++) {
        if(m1 == m2) {
            cout << m1 << endl;
        }
        else if(m1 == v[i]) {
            cout << m2 << endl;
        } else {
            cout << m1 << endl;
        }
    }
}


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

using namespace std;

#define cin_desync()                                                           \
    do {                                                                       \
        ios_base::sync_with_stdio(false);                                      \
        cin.tie(0);                                                            \
    } while (0)

#ifndef ONLINE_JUDGE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1> void __f(const char *name, Arg1 &&arg1) {
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char *names, Arg1 &&arg1, Args &&... args) {
    const char *comma = strchr(names + 1, ',');
    cerr.write(names, comma - names) << " : " << arg1 << " | ";
    __f(comma + 1, args...);
}

#else
#define trace(...)
#endif // ifndef ONLINE_JUDGE

typedef long double ld;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

const int max_N = 1e5 + 10;
int H[max_N];
int dp[max_N];

int main() {
    cin_desync();

    int N, K = 2;
    cin >> N;
    for (int i = 1; i <= N; ++i) {
        cin >> H[i];
    }

    const int inf = 1e9 + 45;
    for (int i = 2; i <= N; ++i) {
        dp[i] = inf;
    }

    for (int i = 1; i <= N; ++i) {
        for (int j = 1; j <= K && (i + j) <= N; ++j) {
            dp[i + j] = min(dp[i + j], dp[i] + abs(H[i] - H[j + i]));
        }
    }

    cout << dp[N] << endl;
}


Measured memory_bytes: 1024
#include <iostream>
#include <vector>
#include<algorithm>
#include<iomanip>
#include<queue>
#include<map>
#include<bitset>
#include<math.h>
using namespace std;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define REP(i,m,n) for(int i=m;i<(int)(n);i++)
typedef pair<int,int> pint;
typedef long long ll;
const int inf   = 1e9+7;
const ll  longinf = 1LL<<60;
const int mod=1e9+7;
int dx[4]={1,0,-1,0}, dy[4]={0,1,0,-1};

vector<int> v[101010],ans[2];
int used[101010];
int calc(int x){
  if(v[x].size()==1)return 0;
  int ret=0;
  rep(i,v[x].size()){
    if((int)v[v[x][i]].size()!=1)ret++;
    }
  return ret;
  }

void dfs(int x,int k,int s){  
  used[x]=true;
  if(v[x].size()==1)return;
  int m=v[x].size();
  ans[s].push_back(k-m+1);
  rep(i,m-2){
    ans[s].push_back(k-i-1);
    }
  rep(i,m){
    if(used[v[x][i]])continue;
    dfs(v[x][i],k-m+1,s);
    }
  }

int main(){
  int n;
  cin>>n;
  rep(i,n-1){
    int x,y;
    cin>>x>>y;
    x--;y--;
    v[x].push_back(y);
    v[y].push_back(x);
    }
  if(n<=3){
    rep(i,n)cout<<i+1<<" ";
    cout<<endl;
    return 0;
    }
  vector<int> st;
  rep(i,n){
    if(calc(i)>=3){
      cout<<-1<<endl;
      return 0;
      }
    if(calc(i)==1)st.push_back(i);
    }
  rep(i,2)st.push_back(v[0][0]);
  rep(j,2){
    ans[j].push_back(n);
    rep(i,n)used[i]=false;
    dfs(st[j],n,j);
    ans[j].push_back(1);
    reverse(ans[j].begin(),ans[j].end());
    }
  int mi=0;
  rep(i,n){
    if(ans[0][i]==ans[1][i])continue;
    if(ans[0][i]<ans[1][i])break;
    if(ans[0][i]>ans[1][i]){
      mi=1;break;
      }
    }
  
  rep(i,n)cout<<ans[mi][i]<<" ";
  cout<<endl;
  return 0;
  }


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

int main(void){
  
  string S,T = "";
  
  string  divide[4] = {"dream","dreamer","erase","eraser"};
  
  cin >> S;
  
  reverse(S.begin(),S.end());
  
  for(int i = 0; i < 4; i++){
  	  reverse(divide[i].begin(),divide[i].end());
  }
  
  bool can = true;
  
  for(int i = 0; i < S.size();){
    
    bool can2 = false;
    
    for(int j = 0; j < 4; j++){
      string d = divide[j];
      if(S.substr(i,d.size()) == d){
        can2 = true;
        i+= d.size();
      }
    }
    if(!can2){
      can = false;
      break;
    }
  }
  
  if(can) cout << "YES" << endl;
  else cout << "NO" << endl;
  
  return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <algorithm>
#include <cstdlib>
#include <string>

using namespace std;

typedef long long int ll;
#define REP(i, I, N) for (int i = I; i < N; ++i)
#define rep(i, N) REP(i, 0, N)

int main() {
    int N, K;
    string S, ans;
    cin >> N >> K;
    cin >> S;

    rep(i, N) {
        if (i + 1 == K) {
            printf("%c", tolower(S[i]));
        } else {
            printf("%c", S[i]);
        }
    }

    printf("\n");
    return 0;
}


Measured memory_bytes: 256
from collections import deque

H,W=map(int,input().split())
grid=[input() for i in range(H)]
dist=[[-1]*W for _ in range(H)]

black_cells=deque()
for h in range(H):
    for w in range(W):
        if grid[h][w] == "#":
            black_cells.append((h,w))
            dist[h][w]=0

def bfs(black_cells,dist):
        d=0
        while black_cells:
            h,w=black_cells.popleft()
            d=dist[h][w]
            for dx, dy in ((1,0),(0,1),(-1,0),(0,-1)):
                new_h=h+dy
                new_w=w+dx
                if new_h <0 or H <= new_h or new_w < 0 or W<=new_w:
                    continue
                if dist[new_h][new_w]==-1:
                    dist[new_h][new_w]=d+1
                    black_cells.append((new_h,new_w))
        return d

d=bfs(black_cells,dist)
print(d)


Measured memory_bytes: 86620
def ham2(a):
	global m,n,count
	if m <= a:
		count += 1
	a2,a3,a5 = a*2, a*3, a*5
	if a2 <= n: ham2(a2)
	if a3 <= n:	ham3(a3)
	if a5 <= n:	ham5(a5)

def ham3(a):
	global m,n,count
	if m <= a:
		count += 1
	a3,a5 = a*3, a*5
	if a3 <= n:	ham3(a3)
	if a5 <= n:	ham5(a5)
	
def ham5(a):
	global m,n,count
	if m <= a:
		count += 1
	a5 = a*5
	if a5 <= n:	ham5(a5)

while True:
	inp = raw_input()
	if inp == "0": break
	m,n = map(int, inp.split())
	count = 0
	ham2(1)
	print count

Measured memory_bytes: 4244
# input()
# int(input())
# map(int, input().split())
# list(map(int, input().split()))
# list(map(int, list(input()))) # スペースがない数字リストを読み込み
import math
import fractions
import sys
import bisect
import heapq  # 優先度付きキュー(最小値取り出し)
import collections
from collections import Counter
from collections import deque
import pprint

sr = lambda: input()
ir = lambda: int(sr())
lr = lambda: list(map(int, sr().split()))

"""nを素因数分解"""
"""2以上の整数n => [[素因数, 指数], ...]の2次元リスト"""
def factorization(n):
    arr = []
    temp = n
    if n == 1:
        return arr

    for i in range(2, int(-(-n**0.5//1))+1):
        if temp%i==0:
            cnt=0
            while temp%i==0:
                cnt+=1
                temp //= i
            arr.append([i, cnt])

    if temp!=1:
        arr.append([temp, 1])

    if arr==[]:
        arr.append([n, 1])

    return arr

# a^n
def power(a,n,mod):
    x = 1
    while n:
        if n & 1:
            x *= a % mod
        n >>= 1
        a *= a % mod
    return x % mod

# n*(n-1)*...*(l+1)*l
def kaijo(n, l, mod):
    if n == 0:
        return 1
    a = n
    tmp = n-1
    while(tmp >= l):
        a = a*tmp%mod
        tmp -= 1
    return a

inf = 10**18
mod = 10**9+7

n = ir()
s = list(sr())
a = Counter(s)
ans = 1
for _,v in a.items():
    ans = (ans*(v+1))%mod
print((ans-1)%mod)

Measured memory_bytes: 75372
//  cout << char(i+48) << endl;//なぜかaは47と得る時がある。+48で出力もaにできる。
//  cout << char(97) << endl;//アスキーコードでaを出力
// sort(b.begin(), b.end());//bという配列を小さい方からソート
// reverse(b.begin(), b.end());//bという配列をリターン
// 10桁でdouble出力するパターン１ 
// printf("%.10f\n", ma);
// 10桁でdouble出力するパターン２
//cout << fixed << setprecision(10);
//  cout << ma << endl;

/*01 02 03 12 13 23　と６回見ていくパターン 
for(int i=0;i<n-1;i++){
  for(int j=i+1;j<n;j++){
    }
  }
*///vector<vector<int>> data(3, vector<int>(4));//int型の2次元配列(3×4要素の)の宣言
//int64_t a;
//10のi乗pow(10, i);
//10の1/2乗（ルート）pow(10, 0.5)
/*string s; stringでの文字列を数字型に変える方法
  cin >> s;
  rep(i,s.size()-2) {
  int a= (s.at(i)-'0')*100 + (s.at(i+1)-'0')*10+ s.at(i+2) -'0';
    */
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main(){
  int x,y,z;
  cin>>x>>y>>z;
  int a = x - z;
  cout << a / (y+z) << endl;
}

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

#define REP(i, begin, end) for (__typeof(end) i = (begin) - ((begin) > (end)); i != (end) - ((begin) > (end)); i += 1 - 2 * ((begin) > (end)))
#define ALL(c) c.begin(), c.end()
#define SZ(c) (int) c.size()
#define DBG1(x) cout<<#x<<" = "<<x<<"\n"
#if USE_CP_REDIR
#define CP \
    freopen("input.txt","r", stdin); \
    freopen("output.txt","w", stdout);
#endif

using ll = long long;
const ll MOD = 1'000'000'007;
const int MN = 200'000;
    
int main()
{
ios::sync_with_stdio(false);
#ifdef CP
    CP;
#endif
    int n;
    cin >> n;
    vector<int> a(n), b(n);
    map<int,int> cnt_b, cnt_a;
    REP(i, 0, n) cin >> a[i], cnt_a[a[i]]++;
    REP(i, 0, n) cin >> b[i], cnt_b[b[i]]++;

    reverse(ALL(b));
    int j = 0;
    for(int i = 0; i < n; i++){
        if(a[i] == b[i]){
            if(cnt_a[a[i]] + cnt_b[b[i]] > n){
                cout<< "No" << endl;
                return 0;
            }else{
                while(a[j] == a[i] || b[j]==b[i]) j++;
                swap(b[i],b[j]);
                j++;
            }
        }
    }
    cout << "Yes" << endl;
    REP(i,0,n) cout << b[i] << ' ';
    cout << endl;


}

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

int main(void){
    int N, L;
    cin >> N >> L;

    int sum = 0;
    for (int i = 0; i < N ; i++){
        sum += L + i;
    }

    if (L*(N+L-1)<=0){
        cout << sum << endl;
    }else if(L<0){
        cout << sum - (L+N-1) << endl;
    }else{
        cout << sum - L << endl;
    }
    return 0;
}

Measured memory_bytes: 256
N,M = map(int,input().split())
cnt = [0]*31

for i in range(N):
	A = list(map(int,input().split()))
	for j in range(len(A)):
		if j == 0:
			continue
		else:
			cnt[A[j]] += 1

ans = 0
for i in range(M+1):
	if cnt[i]==N:
		ans += 1
print(ans)

Measured memory_bytes: 3060
import java.util.Arrays;
import java.util.Scanner;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int a[] = new int[n];
        for (int i = 0; i < n; i++) {
            a[i] = sc.nextInt();
        }

        int count = 0;
        while (true) {
            for (int i = 0; i < n; i++) {
                if (a[i] % 2 != 0) {
                    System.out.println(count);
                    return;
                }
                a[i] /= 2;
            }
            count++;
        }
    }
}


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

int main(){
    int A[5][4][11], n;
    for ( int i = 1; i <= 4; i++ )
        for ( int j = 1; j <= 3; j++ )
            for ( int k = 1; k <= 10; k++ ) A[i][j][k] = 0;
            
    cin >> n;
    for ( int i = 0; i < n; i++ ){
        int b, f, r, v;
        cin >> b >> f >> r >> v;
        A[b][f][r] += v;
    }
    
    for ( int f = 1; f <= 4; f++ ){
        if ( f > 1 ) cout << "####################\n";
        for ( int b = 1; b <= 3; b++){
            for ( int r = 1; r <= 10; r++ ) {
                cout << " " << A[f][b][r];
            }
            cout << endl;
        }
    }
    
    return 0;
}


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

signed main() {
  ios::sync_with_stdio(false);

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

  int x = count_if(p.begin(), p.end(), [&](int u) { return u <= a; });
  int y = count_if(p.begin(), p.end(), [&](int u) { return a < u && u <= b; });
  int z = count_if(p.begin(), p.end(), [&](int u) { return b < u; });

  cout << min({x, y, z}) << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

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

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  int n;
  cin >> n;
  vector<ll> a(n);
  vector<ll> b,c;
  REP(i,n) cin >> a[i];
  VSORT(a);
  int md=n/2;
  b.push_back(a[md]);
  c.push_back(a[md]);
  REP(i,md){
    b.push_back(a[i]);
    b.push_back(a[n-1-i]);
  }

  REP(i,md){
    c.push_back(a[n-1-i]);
    c.push_back(a[i]);
  }

  ll sum1=0;
  ll sum2=0;
  
  //REP(i,n) cout << b[i] << " " << c[i] << endl;
  //return 0;
  for(int i=1;i<n;i++){
    sum1 += abs(b[i] - b[i-1]);
    sum2 += abs(c[i] - c[i-1]);
  }
  
  cout << max(sum1,sum2) << endl;
    
}

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

int Mymax(int a,int b);
int Mymin(int a,int b);
int main(){
	int N;
	int A,B;
	int i;
	scanf("%d",&N);
	scanf("%d %d",&A,&B);
	int P[N+1];
	for(i=1;i<=N;i++){
		scanf("%d",&P[i]);
	//	printf("%d\n",P[i]);
	}
	
	int problem1[N+1],problem2[N+1],problem3[N+1];
	int index1=0,index2=0,index3=0;
	//与えられた問題の分類
	for(i=1;i<=N;i++){
		if(P[i] <= A){
			index1 += 1;
			problem1[index1] = i;
		}
		if((A < P[i])&&(P[i] <= B)){
			index2 += 1;
			problem2[index2] = i;
		}
		if(B < P[i]){
			index3 += 1;
			problem3[index3] = i;
		}
	}
	
	int x;
	x = Mymin(index1,Mymin(index2,index3));
	printf("%d\n",x);
	
	return 0;
}

int Mymax(int a,int b){
	int r;
	if(a > b){
		r = a;
	}else{
		r = b;
	}
	return r;
}

int Mymin(int a,int b){
	int r;
	if(a < b){
		r = a;
	}else{
		r = b;
	}
	return r;
}

Measured memory_bytes: 128
#include<iostream>
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
  sort(a,a+n);
  int sum=0;
  for(int i=0;i<k;i++)
  {
    sum+=a[i];
  }
  cout<<sum<<"\n";
}


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

#define debug_input freopen("stdin.in", "r", stdin)
#define debug_output freopen("stdout.out", "w", stdout)
#define FOR(i, a, b) for(int i = a; i <= b; i++)
#define FORALL(i, n) for(int i = 0; i < n; i++)
#define FORD(i, a, b) for(int i = a; i >= b; i--)
#define SORT(a) sort(a.begin(), a.end())
#define REV(a) reverse(a.begin(), a.end())
#define NP(a) next_permutation(a.begin(), a.end())
#define endl "\n"
using namespace std;

typedef long long ll;
typedef unsigned long long ull;

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

	int d, t, s;
	cin >> d >> t >> s;
	if((double) d / s > (double) t) {
		cout << "No" << endl;
	}
	else {
		cout << "Yes" << endl;
	}
	return 0;
}

Measured memory_bytes: 3648
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<functional>
#include<map>
#include<cstdlib>
#include<complex>
#include<numeric>
#include<set>
#include<deque>
#include<queue>

using namespace std;
using Int = long long;
Int INF = 1LL << 60;
const Int MOD = 1000000000 + 7;

template<int Modulo = MOD> struct Mint {
	Int val;
	constexpr Mint(Int v = 0) noexcept : val(v% Modulo) {
		if (val < 0) v += Modulo;
	}
	constexpr int getmod() { return Modulo; }
	constexpr Mint operator - () const noexcept { return val ? Modulo - val : 0; }
	constexpr Mint operator + (const Mint& r) const noexcept { return Mint(*this) += r; }
	constexpr Mint operator - (const Mint& r) const noexcept { return Mint(*this) -= r; }
	constexpr Mint operator * (const Mint& r) const noexcept { return Mint(*this) *= r; }
	constexpr Mint operator / (const Mint& r) const noexcept { return Mint(*this) /= r; }
	constexpr Mint& operator += (const Mint& r) noexcept {
		val += r.val;
		if (val >= Modulo) val -= Modulo;
		return *this;
	}
	constexpr Mint& operator -= (const Mint& r) noexcept {
		val -= r.val;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr Mint& operator *= (const Mint& r) noexcept {
		val = val * r.val % Modulo;
		return *this;
	}
	constexpr Mint& operator /= (const Mint& r) noexcept {
		Int a = r.val, b = Modulo, u = 1, v = 0;
		while (b) {
			Int t = a / b;
			a -= t * b; swap(a, b);
			u -= t * v; swap(u, v);
		}
		val = val * u % Modulo;
		if (val < 0) val += Modulo;
		return *this;
	}
	constexpr bool operator == (const Mint& r) const noexcept {
		return this->val == r.val;
	}
	constexpr bool operator != (const Mint& r) const noexcept {
		return this->val != r.val;
	}
	friend ostream& operator << (ostream& os, const Mint<Modulo>& x) noexcept {
		return os << x.val;
	}
	friend istream& operator >> (istream& is, Mint<Modulo>& x) noexcept {
		Int tmp; is >> tmp;
		x = Mint<Modulo>(tmp);
		return is;
	}
	friend constexpr Mint<Modulo> modpow(const Mint<Modulo>& a, Int n) noexcept {
		Mint res(1), tmp = a;
		while (n > 0) {
			if (n & 1) res *= tmp;
			tmp *= tmp;
			n >>= 1;
		}
		return res;
	}
};

using mint = Mint<>;

bool is_integer(double x) {
	return floor(x) == x;
}

int main() {

	cin.tie(nullptr);
	ios::sync_with_stdio(false);

	Int N, D;
	cin >> N >> D;

	vector<vector<Int>> x(N, vector<Int>(D, 0));
	for (Int i = 0; i < N; i++) {
		for (Int j = 0; j < D; j++) {
			cin >> x[i][j];
		}
	}

	Int ans = 0;
	Int temp;
	double res;
	for (Int i = 0; i < N; i++) {
		for (Int j = i+1; j < N; j++) {
			temp = 0;
			for (Int k = 0; k < D; k++) {
				temp += (x[i][k] - x[j][k]) * (x[i][k] - x[j][k]);
			}
			res = sqrt(temp);
			if (is_integer(res))ans++;
		}
	}
	cout << ans << "\n";
}

Measured memory_bytes: 256
def func(l):
    i = 0
    for num in range(l[0], l[1]+1):
        #print(num)
        if l[2] % num == 0:
            #print(num)
            i = i + 1
    return i

if __name__ == '__main__':
    N = input().split(" ")
    l = []
    for i in N:
        l.append(int(i))

    result = func(l)
    print(result)

Measured memory_bytes: 7696
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    vector<ll> l(n);
    rep(i, n){
        cin >> l[i];
    }
    ll cnt = 0;
    while(accumulate(l.begin(), l.end(), 0LL) != 0){
        bool z = false;
        rep(i, n){
            if(l[i] == 0){
                if(z){
                    cnt++;
                    z = false;
                }
            }else{
                l[i]--;
                z = true;
            }
        }
        if(z) cnt++;
    }
    cout << cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<unordered_map>
#include<set>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const ll INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1e18;
#define Pint pair<int, int>
#define rng(i,a,b) for(int i=int(a);i<int(b);i++)
#define rnr(i,a,b) for(int i=int(a);i>=int(b);i--)
#define rep(i,b) rng(i,0,b)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

int main() {
    ll n, d; cin >> n >> d;
    int ans = 0;
    rep(i, n) {
        ll x, y; cin >> x >> y;
        if(x * x + y * y <= d * d) {
            ++ans;
        }
    }
    cout << ans << endl;
}


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

int main()
{
	int n,m,k;
	cin>>n>>m>>k;
	for(int i=0;i<=n;i++)
	{
		for(int j=0;j<=m;j++)
		{
			if (i*(m-j)+j*(n-i)==k)
			{
				cout<<"Yes"<<endl;
				return 0;
			}
		}
	}
	cout<<"No"<<endl;
	return 0;
}


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

int K, L, R;
double P, E, T;

double dfs(double l, double r, int depth){
	double mid = ( l + r ) / 2.0;
	if(depth == K){
		return T - E <= mid && mid <= T + E ? 1.0 : 0.0;
	}

	//ツ環ョツ全ツづ可甘慊づ慊づェツづゥ
	if( T - E <= l && r <= T + E ){
		return 1.0;
	}

	//ツ環ョツ全ツづ可甘慊づ慊づェツづ按つ「
	if( r < T - E || T + E < l){
		return 0.0;
	}

	double prob = mid < T ? P : 1.0 - P;

	return prob * dfs(l, mid, depth + 1) + (1.0 - prob) * dfs(mid, r, depth + 1);
}

double solve(){
	return dfs(L, R, 0);
}

int main(){
	scanf("%d%d%d%lf%lf%lf", &K, &L, &R, &P, &E, &T);

	printf("%.10f\n", solve());

	return 0;
}

Measured memory_bytes: 0
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <map>
#include <cmath>
using namespace std;
typedef long long ll;

int main()
{
    ll N;
    cin >> N;
    ll ans = N * (N-1) / 2;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <string>
#include <utility>
#include <vector>

using namespace std;
using ll = long long;

constexpr ll infl = 10000000000000007LL;
constexpr int inf = 1000000007;

int main() {
    int n;
    cin >> n;
    vector<vector<int>> graph(n);
    vector<vector<int>> dist(n, vector<int>(n, inf));

    for (int i = 0; i < n; ++i) {
        string s;
        cin >> s;
        dist[i][i] = 0;
        for (int j = 0; j < n; ++j) {
            if (s[j] == '1' && i < j) {
                graph[i].push_back(j);
                graph[j].push_back(i);
                dist[i][j] = dist[j][i] = 1;
            }
        }
    }

    vector<int> assignment(n, -1);
    assignment[0] = 0;
    queue<int> que;
    que.push(0);
    while (!que.empty()) {
        int from = que.front();
        que.pop();
        for (int to : graph[from]) {
            if (assignment[to] == -1) {
                assignment[to] = assignment[from] ^ 1;
                que.push(to);
            } else if (assignment[to] != (assignment[from] ^ 1)) {
                cout << -1 << endl;
                return 0;
            }
        }
    }

    for (int k = 0; k < n; ++k) {
        for (int i = 0; i < n; ++i) {
            for (int j = 0; j < n; ++j) {
                dist[i][j] = min(dist[i][j], dist[i][k] + dist[k][j]);
            }
        }
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            ans = max(ans, dist[i][j]);
        }
    }
    cout << ans + 1 << endl;

    return 0;
}

Measured memory_bytes: 640
import math

a, b, angle = map(float, input().split())
h = b * math.sin(angle / 180 * math.pi)

print("{:.8f}".format(a * h / 2))
print("{:.8f}".format(a + b + math.sqrt(a ** 2 + b ** 2 - 2 * a * b * math.cos(angle / 180 * math.pi))))
print("{:.8f}".format(h))


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int a, b;
  char op;
  while (cin >> a >> op >> b) {
    if (op == '?') break;
    switch (op) {
      case '+':
        cout << a + b << endl;
        break;
      case '-':
        cout << a - b << endl;
        break;
      case '*':
        cout << a * b << endl;
        break;
      case '/':
        cout << a / b << endl;
        break;
      default:
        break;
    }
  }
  return 0;
}


Measured memory_bytes: 3088
import java.util.*;
import java.io.*;
class Main {
    public static void main(String[] args) {
        FastScanner sc = new FastScanner();
        int N = sc.nextInt();
        int M = sc.nextInt();
        if(N==M) p("Yes");
        else p("No");
	    
    }
    public static <T> void p(T element) {
	System.out.println(element);
    }
    public static int min(int a, int b, int c) {
	int min = Math.min(a,b);
	min = Math.min(min,c);
	return min;
    }
    public static int max(int a, int b,int c) {
	int max= Math.max(a,b);
	max = Math.max(max,c);
        return max;
    }
}
class FastScanner {
    private final InputStream in = System.in;
    private final byte[] buffer = new byte[1024];
    private int ptr = 0;
    private int buflen = 0;
    private boolean hasNextByte() {
        if (ptr < buflen) {
            return true;
        } else {
            ptr = 0;
            try {
                buflen = in.read(buffer);
            } catch (IOException e) {
                e.printStackTrace();
            }
            if (buflen <= 0) {
                return false;
            }
        }
        return true;
    }
 
    private int readByte() {
        if (hasNextByte())
            return buffer[ptr++];
        else
            return -1;
    }
 
    private boolean isPrintableChar(int c) {
        return 33 <= c && c <= 126;
    }
 
    public boolean hasNext() {
        while (hasNextByte() && !isPrintableChar(buffer[ptr]))
            ptr++;
        return hasNextByte();
    }
 
    public String next() {
        if (!hasNext())
            throw new NoSuchElementException();
        StringBuilder sb = new StringBuilder();
        int b = readByte();
        while (isPrintableChar(b)) {
            sb.appendCodePoint(b);
            b = readByte();
        }
        return sb.toString();
    }
 
    public long nextLong() {
        if (!hasNext())
            throw new NoSuchElementException();
        long n = 0;
        boolean minus = false;
        int b = readByte();
        if (b == '-') {
            minus = true;
            b = readByte();
        }
        if (b < '0' || '9' < b) {
            throw new NumberFormatException();
        }
        while (true) {
            if ('0' <= b && b <= '9') {
                n *= 10;
                n += b - '0';
            } else if (b == -1 || !isPrintableChar(b)) {
                return minus ? -n : n;
            } else {
                throw new NumberFormatException();
            }
            b = readByte();
        }
    }
 
    public int nextInt() {
        long nl = nextLong();
        if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
            throw new NumberFormatException();
        return (int) nl;
    }
 
    public double nextDouble() {
        return Double.parseDouble(next());
    }
}

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

class Main
{
	public static void main (String[] args) throws java.lang.Exception
	{
	    Scanner scanner = new Scanner(System.in);
        int count = scanner.nextInt();
        int valueArray[] = new int[count];
        int costArray[] = new int[count];
        int ans = 0;
        for(int i = 0; i < count; i++){
			valueArray[i] = scanner.nextInt();
        }
        for(int i = 0; i < count; i++){
			costArray[i] = scanner.nextInt();
        }
        for(int i = 0; i < count; i++){
	        if (costArray[i] >= valueArray[i]) {
	        	continue;
	        }
	        ans = ans + valueArray[i] - costArray[i];
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 22996
#include <cstdio>
#define max(a,b) (a > b ? a : b)
int main(){
	int a[5];
	for(int i = 0; i < 5; i++){
		scanf("%d",&a[i]);
	}
	int ans = a[0] - max(a[1]/a[3] + (a[1] % a[3] == 0 ? 0 : 1),a[2]/a[4] + (a[2] % a[4] == 0 ? 0: 1));
	printf("%d\n",ans);
	return 0;
}

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

int main() {
  int H,W,N;
  cin >> H>>W>>N;

  for(int i=0;i<101;i++){
    if(H*i>=W*i&&H*i>=N){
      cout << i << endl;
      break;
    }
    else if(W*i>H*i&&W*i>=N){
      cout << i << endl;
      break;
    }
  }
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<ll, P>IP;
typedef vector<ll> V;
typedef vector<V> V2;
typedef vector<vector<P> > G;
void g_dir(G &graph, ll a, ll b, ll w = 1){graph[a].push_back(P(b, w));}
void g_undir(G &graph, ll a, ll b, ll w = 1){g_dir(graph, a, b, w);g_dir(graph, b, a, w);}
#define rep(i, n) for(ll (i) = 0; (i) < (n); (i)++)
#define rep1(i, n) for(ll (i) = 1; (i) <= (n); (i)++)
#define rrep(i, n) for(ll (i) = (n) - 1; (i) >= 0; (i)--)
#define rrep1(i, n) for(ll (i) = (n); (i) >= 1; (i)--)
template<class T> void chmax(T &a, const T &b){if(a < b){a = b;}}
template<class T> void chmin(T &a, const T &b){if(a > b){a = b;}}
const ll INF = 1145141919;
const ll MOD = 1000000007;
const ll NUM = 101010;

int main(){
    
    string s;
    cin >> s;
    V a(s.size() + 1, 0), b(s.size() + 1, 0);
    rep(i, s.size())if(s[i] == '<')a[i + 1] = a[i] + 1;
    rrep(i, s.size())if(s[i] == '>')b[i] = b[i + 1] + 1;
    ll ans = 0;
    rep(i, s.size() + 1)ans += max(a[i], b[i]);
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 8708
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cstring>

#include <iostream>
#include <complex>
#include <string>
#include <algorithm>
#include <numeric>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#ifndef LOCAL
#define debug(x) ;
#else
#define debug(x) cerr << __LINE__ << " : " << #x << " = " << (x) << endl;

template <typename T1, typename T2>
ostream &operator<<(ostream &out, const pair<T1, T2> &p) {
  out << "{" << p.first << ", " << p.second << "}";
  return out;
}

template <typename T>
ostream &operator<<(ostream &out, const vector<T> &v) {
  out << '{';
  for (const T &item : v) out << item << ", ";
  out << "\b\b}";
  return out;
}
#endif

#define mod 1000000007 //1e9+7(prime number)
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 200010


int main(){
  int n;
  char s[SIZE];
  int counter[26] = {};

  scanf("%d%s", &n, s);

  for(int i=0;i<n;i++){
    counter[s[i]-'a']++;
  }

  ll ans = 1;

  for(int i=0;i<26;i++){
    ans = (ans * (counter[i] + 1)) % mod;
  }

  ans = (ans + mod - 1) % mod;

  cout << ans << endl;


  return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
#define ll long long int
#define pii pair<int,int>
#define F first
#define S second
using namespace std;
ll mod=1e9+7;
int gcd(int arr[],int n){
    int pre=0;
    for(int i=0;i<n;i++){
        pre=__gcd(pre,arr[i]);
    }
    return pre;
}
int main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    int n; cin>>n; int arr[n];
    for(int i=0;i<n;i++) cin>> arr[i];
    vector<int> spf(1000005,0);
    for(int i=1;i<=1e6;i++) spf[i]=i;
    for(int i=4;i<=1e6;i+=2)spf[i]=2;

    for(int i=3;i*i<=1e6;i++){
        if(spf[i]==i){
            for(int j=i*i;j<=1e6;j+=i){
                if(spf[j]==j)spf[j]=i;
            }
        }
    }

    vector<int> cnt(1000005,0);
    int flag=0;
    for(int i=0;i<n;i++){
        int x=arr[i];
        unordered_map<int,int> mp;
        while(x!=1){
            mp[spf[x]]=1;

            x=x/spf[x];
        }
        for(auto x:mp){
            cnt[x.F]+=1;
            if(cnt[x.F]>1)flag=1;
        }
    }
    if(flag){
        if(gcd(arr,n)==1){
            cout<<"setwise coprime"<<endl;
        }else{
            cout<<"not coprime"<<endl;
        }
    }else{
        cout<<"pairwise coprime"<<endl;
    }


}


Measured memory_bytes: 14964
#include <bits/stdc++.h>
#define ll long long int
#define vi vector<ll>
#define vvi vector<vector<ll>>
#define pii pair<ll, ll>
#define pb push_back
#define rep0(i, n) for(ll i = 0;i<n;i++)
#define rep1(i, n) for(ll i = 1;i<n;i++)
#define all(v) v.begin(),v.end()
#define fast                          \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
using namespace std;
const int N = 1e5 + 5;
void solve(){
    int n, x, t;
    cin >> n >> x >> t;
    int k = t * ceil(n/(x*1.0));
    cout << k;
}

int main()
{
    fast;
    solve();
    // int t;
    // cin >> t;
    // while(t--){
    //     solve();
    // }
    return 0;
}


Measured memory_bytes: 3612
H,W = list(map(int,input().split()))
HWlist = []
w = []

for i in range(H):
    list = [i for i in input()]
    if list.count("#") > 0:
        HWlist.append(list)
    for j in range(W):
        if list[j] == "#":
            w.append(j)
    
for i in range(len(HWlist[0])-1,-1,-1):
    if i not in w:
        for j in HWlist:
            del j[i]

for i in range(len(HWlist)):
    print("".join(HWlist[i]))

Measured memory_bytes: 3188
import itertools
n, m, q = map(int, input().split())
list_score = [ list(map(int,input().split(" "))) for i in range(q)]
list_NUM = [i for i in range(1, m+1)]
ans = 0


for l in itertools.combinations_with_replacement(list_NUM, n):
    cnt = 0
    for h in list_score:
        if l[h[1]-1] - l[h[0]-1] == h[2]:
            cnt += h[3]

    ans = max(ans, cnt)

print(ans)

Measured memory_bytes: 9152
#include <iostream>

using namespace std;

int main()
{
	int W, H;
	int x, y, r;

	cin >> W >> H >> x >> y >> r;

	if (x + r > W || x - r < 0 || y + r > H || y - r < 0)
	{
		cout << "No" << endl;
	}
	else
	{
		cout << "Yes" << endl;
	}

	return 0;
}


Measured memory_bytes: 3116
#include <iostream>
#include <algorithm>
#include <string>
#include <cmath>
#include <map>
#include <vector>

#define REP(i,n) for(int i=0;i<(int)n;i++)
#define REP1(j,n) for(int j=0;j<(int)n;j++)
#define REPD(i,n) for(int i=n;i>=0;i--)
#define REPD1(j,n) for(int j=n;j=>0;j--)
#define REPS(i,n) for(int i=1;i<=(int)n;i++)
#define REPS1(j,n) for(int j=1;j<=(int)n;j++)
#define rep(i,a,n) for(int i=a;i<(int)n;i++)
#define SZ(x) ((int)(x).size())	//size() unsigned -> int
#define DescSort(a) sort(a.begin(),a.end(),std::greater<int>())

using namespace std;
typedef long long ll;

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



Measured memory_bytes: 256
import java.util.Arrays;
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        int[] a = new int[3];
        Scanner sc = new Scanner(System.in);

        for (int i = 0; i < 3; i++) {
            a[i] = sc.nextInt();
        }
        Arrays.sort(a);
        System.out.println(a[2] - a[0]);
    }
}


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

int main() {
	int i;
	int flag[26];
	char s;
	for (i = 0; i < 26; i++)flag[i] = 0;
	while (cin >> s) flag[(int)(s - 'a')] = 1;
	for (i = 0; i < 26; i++)if (flag[i] == 0) {
		cout << (char)(i + (int)'a') << endl;
		break;
	}
	if (i == 26)cout << "None" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define REPR(i, n) for (int i = n; i >= 0; i--)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int k;
  string s;
  cin >> k >> s;
  if(s.size()<=k) cout << s << '\n';
  else cout << s.substr(0,k) << "...\n";

  return 0;
}


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

using namespace std;

#define REP(var, n)  for (decltype(n) var = 0; var < (n); var++)
#define RREP(var, n)  for (auto var = n - 1; var != static_cast<decltype(var)>(-1); var--)
#define FOR(var, a, b)  for (auto var = (a); var < (b); var++)
#define RFOR(var, a, b)  for (auto var = b - 1; var != a; var--)

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

#define all(c) begin(c),end(c)

#define D(x) do { std::cerr << x; } while (0)
#define D2(x) do { std::cerr << #x << ": " << x << std::endl; } while (0)


template<typename T>
std::ostream &operator<<(std::ostream &out, const std::vector<T> &v) {
    if (!v.empty()) {
        out << '[';
        std::copy(v.begin(), v.end(), std::ostream_iterator<T>(out, ", "));
        out << "\b\b]";
    }
    return out;
}


template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2> &p) {
    return os << '(' << p.first << ',' << p.second << ')';
}


auto solve() {
    int n, m;
    cin >> n >> m;
    vi x(m);
    for (auto &&e:x) cin >> e;
    sort(all(x));

    vi diff(m - 1);
    FOR(i, 1, m) {
        diff[i-1] = abs(x[i] - x[i - 1]);
    }

    sort(all(diff));
    reverse(all(diff));

    ll sum = accumulate(all(diff), 0ll);
    REP(i, (int)min(n-1,m-1))
        sum -= diff[i];

    return sum;
}


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

//    cout << (solve() ? "Yes" : "No") << endl;
//    cout << (solve() ? "YES" : "NO") << endl;
    cout << solve() << endl;
//    solve();

    return 0;
}


Measured memory_bytes: 1024