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

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int count = 0;
		int a = scan.nextInt();
		int b = scan.nextInt();
		int c = scan.nextInt();
		scan.close();
		for(int i = a;i <= b;i++){
			if(c % i == 0)
				count++;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 17352
n, d = gets.chomp.split(" ").map(&:to_i) 
array =[]

(1..n).each do
  array.push(gets.chomp.split(" ").map(&:to_i))
end

cnt = 0
array.combination(2) do |first, second|
  sum = 0
  (0...d).each do |number|
    sum += (first[number] - second[number]) ** 2
  end
  cnt += 1 if (sum ** 0.5).to_i == (sum ** 0.5)
end

puts cnt

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
using namespace std;

int main()
{
    valarray<bool> C(false,52);
    int n, a;
    char s;
    cin >> n;
    REP(i,n) {
        cin >> s >> a;
        a--;
        if (s == 'S') C[a] = true;
        if (s == 'H') C[a+13] = true;
        if (s == 'C') C[a+26] = true;
        if (s == 'D') C[a+39] = true;
    }
    int cnt = 1;
    int s_n = 0;
    char suit[] = "SHCD";
    REP(i,C.size()){
        if (!C[i]) cout << suit[s_n] << " " << cnt << endl;
        cnt++;
        if (cnt == 14) {
            cnt = 1;
            s_n++;
        }
    }

    return 0;
}

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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef long double ld;
const int MOD = 1e9+7;
const int MX = 2e5+5;
const ll  INF = 1e18;
const ld  PI = acos((ld) -1);
template<class T> inline void array_input(T a[], size_t n){for(size_t i = 0; i < n; i++)cin >> a[i];}

long long binExp(long long a, long long b, long long mod){
    long long res = 1;
    while(b > 0){
        if(b % 2) res = res * a % mod;
        a = a * a % mod;
        b /= 2;
    }
    return res;
}

ll gcd(ll a, ll b, ll &x, ll &y){
    x = 1, y = 0;
    int x1 = 0, y1 = 1;
    while(b){
        int q = a/b;
        tie(a, b) = make_tuple(b, a - q * b);
        tie(x, x1) = make_tuple(x1, x - q * x1);
        tie(y, y1) = make_tuple(y1, y - q * y1);
    }
    return a;
}
//#define FILE

int main(){
#ifdef FILE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif // 0

    ll ans = 0;
    int n;
    cin >> n;
    int a[n];
    array_input(a, n);

    for(int i = 1; i < n; i++){
        if(a[i] < a[i-1]){
            ans += (ll) a[i-1]-a[i];
            a[i] = a[i-1];
        }

    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 4408
#include "bits/stdc++.h"
#define rep(i,n) for(int i=0;i<n;i++)
using namespace std;

typedef long long ll;

typedef long long ll;
typedef pair<ll, ll> P;
struct edge { ll to, cost; };

const int MAX_V =100000;
const ll INF = 1LL<<60;

int V;
vector<edge> G[MAX_V];
ll d[MAX_V];

void dijkstra(ll s) {
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d + V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while (!que.empty()) {
        P p = que.top(); que.pop();
        int v = p.second;
        if (d[v] < p.first) continue;
        rep(i,G[v].size()) {
            edge e = G[v][i];
            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(P(d[e.to], e.to));
            }
        }
    }
}

int main() {
    int V, M;
    cin >> V >> M;
    rep(i, V) d[i] = INF;
    int L, R, C;
    rep(i, M) {
        cin >> L >> R >> C;
        L--;
        R--;
        G[L].push_back({R, C});
    }
    rep(i, V - 1) G[i + 1].push_back({i, 0});
    dijkstra(0);
    if (d[V - 1] == INF) cout << -1 << endl;
    else cout << d[V - 1] << endl;
}

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

int main()
{
  int N;
  int count = 0;
  vector<int> arr(210);
  cin >> N;
  for (int i = 0; i < N; i++)
    cin >> arr.at(i);
  while(true)
  {
    bool some_odd = false;
    for (int i = 0; i < N; i++)
    {
      if(arr.at(i) % 2 != 0)
        some_odd = true;
    }
    if (some_odd)
      break;
    for (int i = 0; i < N; i++)
      arr.at(i) /= 2;
    count++;
  }  
  cout << count << endl;
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int N;
vector<int> A, B;

int main(){
    cin >> N;

    A = vector<int>(N);
    B = vector<int>(N);

    rep(i, N) cin >> A[i];
    rep(i, N) cin >> B[i];

    vector<P> tmp(N);
    rep(i, N) tmp[i] = P(A[i], i);

    vector<P> Bs(N);
    rep(i, N) Bs[i] = P(B[i], i);
    sort(Bs.begin(), Bs.end());

    sort(tmp.begin(), tmp.end());
    sort(B.begin(), B.end());

    rep(i, N) {
        if (B[i] < tmp[i].first) {
            puts("No");
            return 0;
        }
    }

    vector<int> to(N);
    rep(i, N) {
        to[ tmp[i].second ] = Bs[i].second;
    }

    vector<bool> vis(N, false);
    int cnt = 0;
    rep(i, N) {
        int x = i;
        bool flg = false;
        while (!vis[x]) {
            vis[x] = true;
            x = to[x];
            flg = true;
        }

        if (flg) cnt++;
    }

    if (2 <= cnt) {
        puts("Yes");
        return 0;
    }

    bool ans = false;
    rep(i, N - 1) {
        if (tmp[i + 1].first <= B[i]) ans = true;
    }

    if (ans) {
        puts("Yes");
    } else {
        puts("No");
    }
}

Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, N;
  string S;
  cin >> N >> S >> K;
  char c = S.at(K - 1);
  for (int i = 0; i < N; i++) {
    if (c != S.at(i)) {
      S.at(i) = '*';
    }
  }
  cout << S << endl;
}

Measured memory_bytes: 256
import collections

n,q = map(int, input().split())

value = ['-'] * (n+1)

connected = [set() for i in range(n+1)]

for i in range(n-1):
  a,b = map(int, input().split())
  connected[a].add(b)
  connected[b].add(a)

for i in range(q):
  p,x = map(int, input().split())
  if value[p] == '-':
    value[p] = 0
  value[p] -= x

queue = collections.deque(connected[1])

if value[1] == '-':
  value[1] = 0
else:
  value[1] = -value[1]

for i in queue:
  if value[i] == '-':
    value[i] = 0
  else:
    value[i] = -value[i]
  value[i] += value[1]


while queue:
  s = queue.popleft()
  v = value[s]
  for i in connected[s]:
    vi = value[i]
    if vi == '-' or vi < 0:
      if vi == '-':
        vi = 0
      value[i] = -(vi-v)
      queue.append(i)
    
print(' '.join(str(i) for i in value[1:]))

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

int mod;

long long modpow(long long x, long long y){
    if (y == 0) return 1;
    if (y % 2) return x * modpow(x, y - 1) % mod;
    long long res = modpow(x, y / 2);
    return res * res % mod;
}

int main()
{
    int n, p;
    cin >> n >> p;
    mod = p;
    string s;
    cin >> s;
    long long ans = 0;
    if (p == 2 || p == 5){
        for (int i = n - 1; i >= 0; i--)
        {
            if ((s[i] - '0') % p == 0) ans += (i + 1);
        }
        cout << ans << endl;
        return 0;
    }
    vector<int> cnt(p + 1);
    long long tmp = 0;
    for (int i = n - 1; i >= 0; i--)
    {
        tmp += (s[i] - '0') * modpow(10, n - i - 1) % mod;
        tmp %= p;
        ans += cnt[tmp];
        cnt[tmp]++;
        if (tmp == 0) ans++;
    }
    cout << ans << endl;
}


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

using namespace std;

int main() {
  int N; cin >> N;
  static double BTC_JPY = 380000.0;
  double sumPrice = 0;
  for(int i = 0; i < N; i++) {
    double x; string u;
    cin >> x >> u;
    sumPrice += ((u == "JPY") ? x : x * BTC_JPY);
  }
  cout << sumPrice << endl;
}


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

int main(){
	int N;
	cin >> N;
	vector<int> v(N);
	for(int i(0);i<N;++i){
		cin >> v[i];
	}
	sort(v.begin(),v.end());
	double ans;
	for(int i(0);i<N-1;++i){
		if(i==0){
			ans = (v[i] + v[i+1])/2.0;
		}else{
			ans = (ans + v[i+1])/2.0;
		}
	}
	cout << ans << endl;
	return 0;
}

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

class Program
{
    static void Main(string[] args)
    {
        var S = Console.ReadLine();
        var T = Console.ReadLine();

        var sMap = new Dictionary<char, char>();
        var tMap = new Dictionary<char, char>();
        for (int i = 0; i < S.Length; i++)
        {
            var s = S[i];
            var t = T[i];
            if (sMap.ContainsKey(s))
            {
                if (sMap[s] != t)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            else
            {
                sMap.Add(s, t);
            }

            if (tMap.ContainsKey(t))
            {
                if (tMap[t] != s)
                {
                    Console.WriteLine("No");
                    return;
                }
            }
            else
            {
                tMap.Add(t, s);
            }
        }

        Console.WriteLine("Yes");

    }
}



Measured memory_bytes: 14688
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <sstream>
#include <iostream>
#include <iomanip>
#define _USE_MATH_DEFINES
#include <cmath>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cfloat>
#include <cmath>
#include <ctime>
#include <cassert>
#include <cctype>
#include <cstdio>
#include <cassert>
using namespace std;

#define EPS 1e-12
#define ull unsigned long long
#define ll long long
#define VI vector<ll>
#define PII pair<ll, ll> 
#define VVI vector<vector<ll> >
#define VVVI vector<vector<vector<ll>>>
#define VVVVI vector<vector<vector<vector<ll>>>>
#define REP(i,n) for(ll i=0,_n=(n);(i)<(ll)_n;++i)
#define REPR(i,n) for(ll i=(ll)(n)-1;0<=(i);--i)
#define RANGE(i,a,b) for(ll i=(ll)a,_b=(ll)(b);(i)<_b;++i)
#define RANGER(i,a,b) for(ll i=(ll)(b)-1,_a=(ll)(a);(_a)<=i;--i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define ALLR(c) (c).rbegin(), (c).rend()
#define PB push_back
#define MP(a, b) make_pair(a, b)
#define POPCOUNT __builtin_popcount
#define POPCOUNTLL __builtin_popcountll
#define CLEAR(table, v) memset(table, v, sizeof(table));
#define UNIFORM_DOUBLE(a, b) (((b-a)*(double)rand()/RAND_MAX)+a) // [a, b) 
#define UNIFORM_LL(a, b) (ll)UNIFORM_DOUBLE(a, b) // [a, b) 
#define IN(v, lo, hi) ((lo)<=(v) && (v)<(hi))
#define DD(v) cout<<#v<<": "<<v<<endl
#define FI first
#define SE second
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const map<T0, T1>& v) { for( typename map<T0, T1>::const_iterator p = v.begin(); p!=v.end(); p++ ){os << p->first << ": " << p->second << " ";} return os; }
template <typename T0, typename T1> std::ostream& operator<<(std::ostream& os, const pair<T0, T1>& v) { os << v.first << ": " << v.second << " "; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<T>& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << " "; } return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const set<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const deque<T>& v) { vector<T> tmp(v.begin(), v.end()); os << tmp; return os; }
template <typename T> std::ostream& operator<<(std::ostream& os, const vector<vector<T> >& v) { for( int i = 0; i < (int)v.size(); i++ ) { os << v[i] << endl; } return os; }
template<typename T>void maxUpdate(T& a, T b) {a = max(a, b);}
template<typename T>void minUpdate(T& a, T b) {a = min(a, b);}
string YN(bool v) { return v ? "Yes":"No"; }
void uniq(VI& es) { sort(ALL(es)); es.erase(unique(ALL(es)), es.end()); }

#define INF (1LL<<60)

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll A,B,C,K;
	while(cin>>A>>B>>C>>K) {
		ll ans=0;
		REP(bi, 1LL<<(2*K)) {
			ll a=A,b=B,c=C;
			REP(i, K) {
				ll t = bi>>(2*i)&3;
				if(t==0) a*=2;
				if(t==1) b*=2;
				if(t==2) c*=2;
			}
			if(a<b && b<c) ans=1;
		}
		cout<<YN(ans)<<endl;
	}
	
	return 0;
}


Measured memory_bytes: 3132
D = int(input())
c = [int(i) for i in input().split()]
s = [[int(i) for i in input().split()] for _ in range(D)]
t = [int(input())-1 for _ in range(D)]
ans = 0
llst = [0]*26

for day,i in enumerate(range(D),1):
    llst[t[i]] = day
    ans += s[i][t[i]]
    for j in range(26): ans -= c[j]*(day-llst[j])
    print(ans)

Measured memory_bytes: 9444
#include<bits/stdc++.h>
using namespace std;
bool binarysearch(vector<int> s, int n,int t){
    int left = 0;
    int right = n;
    int mid = (left + right) / 2;
    while(left < right){
      if(s[mid] == t){
        return true;
      }else if(s[mid] < t){
        left = mid + 1;
        mid = (left + right) / 2;
      }else if(s[mid] > t){
        right = mid;
        mid = (left + right) / 2;
      }
    }
  	return false;
}
int main(){
    int n;
    cin >> n;
    vector<int> s(n);
    for(int i = 0;i < n;i++){
        cin >> s[i];
    }
    int q;
    cin >> q;
    vector<int> t(q);
    for(int i = 0;i < q;i++){
        cin >> t[i];
    }
    
    int count = 0;
    for(int i = 0;i < q;i++){
        if(binarysearch(s, n, t[i])){
            count++;
        }
    }
    cout << count << endl;
}


Measured memory_bytes: 3952
s = input()

bool = [False]

def hantei(s):
    # print(s)
    if s=='':
        bool[0]=True
        return

    if s.count('dream')>=1:
        r=s.replace('dream','')
        hantei(r)

    if s.count('dreamer')>=1:
        r=s.replace('dreamer','')
        hantei(r)

    if s.count('erase')>=1:
        r=s.replace('erase','')
        hantei(r)

    if s.count('eraser')>=1:
        r=s.replace('eraser','')
        hantei(r)
    return

hantei(s)
        

if bool[0]==True:
    print('YES')

if bool[0]==False:
    print('NO')



Measured memory_bytes: 3316
#include<iostream>
#include<cstdio>
using namespace std;
int main(void){
	int a,b,c;
	int tyou=0,hisi=0;
	while(scanf("%d,%d,%d",&a,&b,&c)!=EOF){
		if(a*a+b*b==c*c)
			tyou++;
		if(a==b)
			hisi++;
	}
	cout<<tyou<<endl<<hisi<<endl;

	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
int main()
{
  int n;
  int ans = 0;
  string s;
  cin >> n >> s;
  for (int i = 0; i < n; i++)
  {
    if (s[i] == 'A' && s[i + 1] == 'B' && s[i + 2] == 'C')
    {
      ans += 1;
    }
  }
  cout << ans << endl;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

#define sf scanf
#define pf printf
#define pb push_back
#define mp make_pair
#define IN freopen("input.txt","r",stdin)
#define OUT freopen("output.txt","w",stdout)
#define FOR(i,a,b) for(i=a ; i<=b ; i++)
#define DBG pf("Hi\n")
#define i64 long long int
#define eps (1e-8)
#define xx first
#define yy second
#define ln 17
#define off 2

//using namespace __gnu_pbds;
using namespace std ;

typedef pair<int, int> pi ;
//typedef tree< pi, null_type, less<pi>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;

const i64 mod = 1000000007LL ;
#define INF 2000000000001LL
#define maxn 200005

/*
     *os.find_by_order(k) -> returns the k'th smallest element (indexing starts from 0)
      os.order_of_key(v)  -> returns how many elements are strictly smaller than v
*/

int Left[2002][2002] , Up[2002][2002] ;
int ones[2002][2002] ;
char s[2005][2005] ;

int main()
{
    int n , m , q ;

    scanf("%d %d %d",&n,&m,&q) ;

    for(int i=1 ; i<=n; i++) scanf("%s",s[i]+1) ;

    for(int i=1; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++)
        {
            if( s[i][j]=='1' ) ones[i][j] = 1 ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++)
        {
            if( ones[i][j] == 1 && ones[i-1][j] == 1 ) Up[i][j] = 1 ;
            if( ones[i][j] == 1 && ones[i][j-1] == 1 ) Left[i][j] = 1 ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m ; j++)
        {
            Left[i][j] += Left[i][j-1] ;
            Up[i][j] += Up[i][j-1] ;
        }
        for(int j=1 ; j<=m ; j++)
        {
            Left[i][j] += Left[i-1][j] ;
            Up[i][j] += Up[i-1][j] ;
        }
    }

    for(int i=1 ; i<=n ; i++)
    {
        for(int j=1 ; j<=m; j++) ones[i][j] = ones[i][j-1] + ones[i][j] ;
        for(int j=1 ; j<=m; j++) ones[i][j] += ones[i-1][j] ;
    }

    for(int i=1 ; i<=q ; i++)
    {
        int x1 , y1 , x2, y2 ;
        scanf("%d %d %d %d",&x1,&y1,&x2,&y2) ;

        int nodes = ones[x2][y2] - ones[x1-1][y2] - ones[x2][y1-1] + ones[x1-1][y1-1] ;
        int edgesHor = Left[x2][y2] - Left[x1-1][y2] - Left[x2][y1] + Left[x1-1][y1] ;
        int edgesVer = Up[x2][y2] - Up[x1][y2] - Up[x2][y1-1] + Up[x1][y1-1] ;

        printf("%d\n",nodes-edgesHor-edgesVer) ;
    }


    return 0 ;
}


Measured memory_bytes: 52736
N = int(input())
A = input().split()
B = input().split()
C = input().split()
sum = 0
for i in range(N):
    sum += int(B[int(A[i])-1])
    if i < N-1:
        if int(A[i])+1 == int(A[i+1]):
            sum += int(C[int(A[i])-1])
print(sum)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
#define REP(i,n) for (ll i = 0; i < (n); ++i)


void solve(long long N){
    if(N % 2 == 0){
        cout << N / 2 << endl;
    }else{
        cout << (N + 1) /2 << endl;
    }
}

// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools
int main(){
    long long N;
    scanf("%lld",&N);
    solve(N);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < (int)b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int a, b;
    cin >> a >> b;
    int mn = min(a, b);
    int mx = max(a, b);
    rep(i, 0, mx) {
        cout << mn;
    }
    cout << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.*;

class Main{
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int x = sc.nextInt(),y = sc.nextInt(),z = sc.nextInt();
        int ans1 ,ans2;
        String ans;
        ans1 = x > y ? x - y : y - x;
        ans2 = x > z ? x - z : z - x;
        ans = ans1 < ans2 ? "A" : "B";
        System.out.println(ans);
    }
}


Measured memory_bytes: 22736
#include"bits/stdc++.h"
#define int long long
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=(a);i<(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define itr(i,x) for(auto i=(x).begin();i!=(x).end();++i)
#define All(x) (x).begin(),(x).end()
#define gridif(a,x,b) if((a)<=(x)&&(x)<(b))
using namespace std;
typedef pair<int,int> P;
const int mod=1000000007;

int digitsum(int n,int b){
	if(b<2) return -1;
	if(n<b) return n;
	return digitsum(n/b,b)+n%b;
}
int mpow(int a,int x);
int m_inv(int n){return mpow(n,mod-2);}

int gcd(int x,int y){return y?gcd(y,x%y):x;}
int lcm(int x,int y){return x*y/gcd(x,y);}

signed main(){
    int N;
    cin>>N;
    int T=1,A=1;
    rep(i,N){
    	int t,a;
    	cin>>t>>a;
    	int j=0;
    	int M=max((T-1)/t,(A-1)/a);
    	M++;
    	T=M*t;A=M*a;
    }
    cout<<T+A<<endl;
}

int mpow(int a,int x){
	int ans=1;
	while(x>0){
		if(x%2==1) (ans*=a)%=mod;
		(a*=a)%=mod;
		x>>=1;
	}
	return ans;
}

Measured memory_bytes: 256
n=int(input())
num=[0]*(n+1)
def factorization(n):
    arr = []
    temp = n
    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
for i in range(1,n+1):
    num1=factorization(i)
    for j in range(len(num1)):
        num[num1[j][0]]+=num1[j][1]
ans=1
for i in range(2,n+1):
    if num[i]!=0:
        ans=(ans*(num[i]+1))%(10**9+7)
print(ans)


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

void swap(int *a, int *b) {
	int sub = *a;
	*a = *b;
	*b = sub;
}

int main() {
	int N, A[100];
	int change = 0;

	scanf("%d", &N);
	for (int i = 0;i < N;i++) {
		scanf("%d", A + i);
	}

	for (int i = 0;i < N;i++) {
		for (int j = N - 1;j > i;j--) {
			if (A[j] < A[j - 1]) {
				swap(&A[j], &A[j - 1]);
				change++;
			}
		}
	}

	for (int i = 0;i < N;i++) {
		printf("%d", A[i]);
		if (i + 1 < N)printf(" ");
		else printf("\n");
	}
	printf("%d\n", change);

	return 0;
}

Measured memory_bytes: 1032
using System;
using System.IO;
using System.Net;
using System.Net.Sockets;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

public static class P
{
    public static void Main()
    {
        int n = Reader.NextInt;
        int last = 0;
        int cur = 0;
        int max = 0;
        for (int i = 0; i < n; i++)
        {
            var h = Reader.NextInt;
            if (last >= h) cur++;
            else
            {
                max = Max(max, cur);
                cur = 0;
            }
            last = h;
        }
        Console.WriteLine(Max(max, cur));
    }
}

static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = 0;
    private static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; }  }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static int NextSInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move(); 
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }

    public static long NextLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; while (Buffer[ptr] < 48) Move();
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res;
        }
    }

    public static long NextSLong
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            long res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13140
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
typedef long long int ll;
using namespace std;
int main(){
	string s;
	cin >> s;
	ll check_b=-1;
	ll count=0;
	for(int i=0;i<s.size();i++){
		if(s[i]=='B'&&check_b==-1){
			check_b=i;
		}else if(s[i]=='W'&&check_b!=-1){
			count+=i-check_b;
			check_b+=1;
		}
	}
	cout<<count<<endl;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL)
#define N 1000001
#define ll long long int
#define ff first
#define ss second
#define pb push_back
#define forin for(auto &i : A) cin >> i;
#define forout for(auto i : A) cout<< i<<" ";
const int MAX = 26; 


void solving() {
	ll d, s, t;
	cin >> d >> t >> s;
	if(d <= t * s) cout<<"Yes";
	else cout<<"No";
}

int main() {
    clock_t clk_start = clock();
    fast;
    #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
    #endif

  	ll test = 1;
    //cin >> test;
    ll p = 1;
    while(test--) {
    	solving();
	}

    cerr<<"Execution Time: "<<fixed<<double(clock() - clk_start)/double(CLOCKS_PER_SEC)<<setprecision(6)<<" sec\n"; 
}


Measured memory_bytes: 3800
n, k = map(int, input().split())
s = input()
total = 0

for i in range(n):
    if i == 0:
        if s[i]=="R" and s[i+1]=="R":
            total += 1
    elif i == n-1:
        if s[i]=="L" and s[i-1]=="L":
            total += 1
    else:
        if (s[i]=="R" and s[i+1]=="R") or (s[i]=="L" and s[i-1]=="L"):
            total += 1

print(min(n-1, total + 2 * k))

Measured memory_bytes: 3316
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;

#define mem(dp,a)           memset(dp,a,sizeof dp)
#define rep(i,a,b)          for(ll i=a;i<b;i++)
#define pb(x)               push_back(x)
#define mp(x,y)             make_pair(x,y)
#define fastio              ios_base::sync_with_stdio(false);cin.tie(NULL)
#define F                   first
#define S                   second
#define all(v)              (v).begin(),(v).end()
#define pi					3.14159265359
ll INF=1e18+10;
ll MOD=998244353;

int main()
{
    string s,t;cin>>s>>t;
    string res=t+s;
    cout<<res<<endl;
}


Measured memory_bytes: 256
#include <iostream>

 using namespace std;

 int main(void) {
	 int K;
	 cin >> K;
	
		// int a[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
		 //int Num[] = { 1,1, 1,2, 1, 2, 1,1,5,2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2,2,1,15,2, 2, 5, 4, 1, 4, 1, 51 };
		 int N[] = { 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
	cout << N[K - 1] << endl;
	
		 return 0;
	
}


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

typedef struct{
    int num;
    int time_s;
    int time_cs;
    int chosen;
} sensyu_t;
int qsort_comp(const void* x, const void* y)
{
    const sensyu_t* a = (const sensyu_t*)x;
    const sensyu_t* b = (const sensyu_t*)y;
    if((a -> time_s) > (b -> time_s))return 1;
    if((a -> time_s) < (b -> time_s))return -1;
    if((a -> time_cs) > (b -> time_cs))return 1;
    if((a -> time_cs) < (b -> time_cs))return -1;
    return 0;
}
int main()
{
    sensyu_t sensyu[24];
    int i;
    for(i = 0; i < 24; i++){
        scanf("%d %d.%d", &sensyu[i].num, &sensyu[i].time_s, &sensyu[i].time_cs);
        sensyu[i].chosen = 0;
    }
    qsort(&sensyu[0],8,sizeof(sensyu_t),qsort_comp);
    qsort(&sensyu[8],8,sizeof(sensyu_t),qsort_comp);
    qsort(&sensyu[16],8,sizeof(sensyu_t),qsort_comp);
    sensyu[0].chosen = sensyu[1].chosen = 1;
    sensyu[8].chosen = sensyu[9].chosen = 1;
    sensyu[16].chosen = sensyu[17].chosen = 1;
    printf("%d %d.%02d\n",sensyu[0].num,sensyu[0].time_s,sensyu[0].time_cs);
    printf("%d %d.%02d\n",sensyu[1].num,sensyu[1].time_s,sensyu[1].time_cs);
    printf("%d %d.%02d\n",sensyu[8].num,sensyu[8].time_s,sensyu[8].time_cs);
    printf("%d %d.%02d\n",sensyu[9].num,sensyu[9].time_s,sensyu[9].time_cs);
    printf("%d %d.%02d\n",sensyu[16].num,sensyu[16].time_s,sensyu[16].time_cs);
    printf("%d %d.%02d\n",sensyu[17].num,sensyu[17].time_s,sensyu[17].time_cs);
    qsort(sensyu,24,sizeof(sensyu_t),qsort_comp);
    for(i = 0; i < 24; i++){
        if(sensyu[i].chosen == 0){
            printf("%d %d.%02d\n",sensyu[i].num,sensyu[i].time_s,sensyu[i].time_cs);
            break;
        }
    }
    for(i++; i < 24; i++){
        if(sensyu[i].chosen == 0){
            printf("%d %d.%02d\n",sensyu[i].num,sensyu[i].time_s,sensyu[i].time_cs);
            break;
        }
    }
    return 0;
}

Measured memory_bytes: 612
import java.util.*;

class Main{
	
	
	
	
	public static void main(String[] args){
		
		Scanner scan = new Scanner(System.in);
		int S = scan.nextInt();
		
		int h = S/3600;
		int m = (S-h*3600)/60;
		int s = (S-h*3600)-m*60;
		
		System.out.println(h + ":" + m + ":" + s);
		
	}
}

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

using namespace std;

int main(){
    int a, b;
    cin >> a >> b;
    
    int B = b;
    int digit = 0;
    while(B > 0){
        B /= 10;
        digit++;
    }
    int add = 1;
    for(int i = 0; i < digit; i++){
        add *= 10;
    }
    int temp;
    temp = add * a + b;
    for(int i = 1; i <= 1000; i++){
        int mult = i * i;
        if(mult > temp)     break;
        
        if(mult == temp){
            cout << "Yes\n";
            return 0;
        }
    }
    
    cout << "No\n";
}

Measured memory_bytes: 256
/*
	Copyright: razouq (c)
	Author: Anass BENDARSI
	Date: 07/01/2018 12:01:39
	flamers will **** you
*/
#include<bits/stdc++.h>
//#include<flamers.h>
#define ll long long
#define ull unsigned long long
#define F first
#define S second
#define PB push_back
#define MP make_pair
#define POB pop_back
#define dist(a, b) sqrt(a*a + b*b)
using namespace std;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<pair<int, int>> vipi;
bool compare(pi p1, pi p2){
	 if(1) return true;
	 return false;
}

int main(){
//	freopen("input.in", "r", stdin);
//	freopen("output.out", "w", stdout);
	ios::sync_with_stdio(0);
	cin.tie();
	string str;
	cin>>str;
	str[3] = '8';
	cout<<str<<endl;	
	return 0;
}


Measured memory_bytes: 256
n,Ma,Mb=map(int,input().split())
inf=float("inf")
dp=[[[inf]*401 for _ in range(401)] for _ in range(n+1)]
dp[0][0][0]=0

l=[tuple(map(int,input().split())) for _ in range(n)]

for i in range(1,n+1):
    for j in range(401):
        for k in range(401):
            a,b,c=l[i-1]
            dp[i][j][k]=min(dp[i][j][k],dp[i-1][j][k])
            if j-a>=0 and k-b>=0:
                dp[i][j][k]=min(dp[i][j][k],dp[i-1][j-a][k-b]+c)

ans=inf
for i in range(1,401):
    for j in range(1,401):
        if i*Mb==j*Ma:
            ans=min(ans,dp[n][i][j])

print(ans if ans!=inf else -1)

Measured memory_bytes: 133724
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;

        for (int i = 0; i < A.length - 1; i++) {
            for (int j = A.length - 1; j > i; j--) {
                if (A[j] < A[j - 1]) {
                    int tmp = A[j];
                    A[j] = A[j - 1];
                    A[j - 1] = tmp;
                    count++;
                }
            }
        }

        for (int i = 0; i < A.length - 1; i++) {
            System.out.print(A[i] + " ");
        }
        System.out.println(A[A.length - 1]);

        System.out.println(count);

        sc.close();
    }
}


Measured memory_bytes: 26272
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    int n, m;
    cin >> n >> m;
    int sum = 0;
    for(int i = 0; i < m; i++){
        int a;
        cin >> a;
        sum += a;
    }
    int ans = n - sum;
    if(ans >= 0){
        cout << ans << endl;
    }
    else{
        cout << -1 << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
N,A,B,C,D=map(int,input().split())
S=input()
for i in range(B-1,D-1):
  if S[i:i+2]=='##':
    print('No')
    exit() 
for i in range(A-1,C-1):
  if S[i:i+2]=='##':
    print('No')
    exit()
if C>D:
  for i in range(B-2,D-1):
    if S[i:i+3]=='...':
      print('Yes')
      exit()
  print('No')
  exit()
print('Yes')

Measured memory_bytes: 66264
#include <bits/stdc++.h>
using namespace std;
#define FIN ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

int main() {FIN
	
	int i = 0, j = 0, n;
	string s;
	cin >> s;
	n = s.size();
	for (i = 0; i < n; i++) {
		if (i < n - 1 and s[i] == s[i + 1]) {
			j = i + 2; break;
		}
		if (i < n - 2 and s[i] == s[i + 2]) {
			j = i + 3; break;
		}
	}
	if (i == n)
		cout << "-1 -1" << "\n";
	else
		cout << (i + 1) << " " << j << "\n";
	
	return 0;
}


Measured memory_bytes: 3740
#include<iostream>
#define N 8  // N*N board
#define NF 1  // This place isn't attacked.
#define F 0  // This place is attacked.
void printBoard(void);
void putQueen(int);
int M[N][N],row[N],col[N],dneg[2*N-1],dpos[2*N-1];
int main(){
  for(int i=0; i<N; i++){                     // initiaize
    for(int j=0; j<N; j++){                   // *
      M[i][j] = 0;                            // *
    }                                         // *
    col[i] = row[i] = dneg[i] = dpos[i] = F;  // *
  }                                           // *
  for(int i=N; i<(N*2-1); i++){               // *
    dneg[i] = dpos[i] = F;                    // *
  }                                           // end
  int k;
  std::cin >> k;
  for(int i=0,r,c; i<k; i++){
    std::cin >> r >> c;
    M[r][c] = 1;
  }
  putQueen(0);
  return 0;
}
void printBoard(void){
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      if(M[i][j] && row[i] != j) return;
    }
  }
  for(int i=0; i<N; i++){
    for(int j=0; j<N; j++){
      std::cout << (row[i] == j ? "Q" : ".");
      if(j == N-1) std::cout << "\n";
    }
  }
}
void putQueen(int i){
  if(i == N){
    printBoard();
    return;
  }
  for(int j=0; j<N; j++){
    if(col[j] == NF || dpos[i+j] == NF || dneg[i-j+N-1] == NF) continue;
    row[i] = j;
    col[j] = dpos[i+j] = dneg[i-j+N-1] = NF;
    putQueen(i+1);
    row[i] = col[j] = dpos[i+j] = dneg[i-j+N-1] = F;
  }
}

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#define rep(i,n) for(int i=0; i<(n); i++)
#define rrep(i,n) for(int i=(n)-1; i>=0; i--)

using namespace std;
typedef long long ll;

int main(){
	ll N;
	ll A[100005];
	cin >> N;
	rep(i,N) cin >> A[i];

	ll sum = 0;
	rep(i,N) sum += A[i];

	bool ans = false;
	if( sum % ((N + 1)*N / 2) == 0 ){
		ll cl = 0;
		ll time = sum / ((N + 1)*N / 2);
		A[N-1] -= time * N;
		//ll bf = A[N-1] - time*N;
		//cout << time << " " << bf << endl;
		rrep(i,N) if(i){
			//A[i] -= (ll)(i+1)*time;
			A[i-1] -= (ll)i*time;
			if( A[i-1] != A[i] ){
				if( A[i-1] < A[i] || (A[i-1] - A[i]) % N ){
					cl = -1;
					break;
				}
				ll t = (A[i-1] - A[i]) / N;
				cl += (N - i) * t;
			}
			//if( bf > A[i] ){
			//	A[0] -= N - i;
			//	bf = A[i];
			//}else if( bf < A[i] ){
			//	A[0] = 1;
			//	break;
			//}
		}
		//cout << A[0] << " " << cl << endl;
		ans = (A[0] == cl);
	}

	cout << (ans ? "YES" : "NO") << endl;
}

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

int main() {
  string s;
  cin>>s;
  if(s[0]==s[1]||s[1]==s[2]||s[2]==s[3]){
    cout<<"Bad"<<endl;
  }
  else{
    cout<<"Good"<<endl;
  }
}


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

typedef long long int ll;

ll dp[100002];

ll func(ll arr[],ll i)
{
	if(dp[i]!=-1)
		return dp[i];
	dp[i] = min(func(arr,i-1)+abs(arr[i-1]-arr[i]),func(arr,i-2)+abs(arr[i-2]-arr[i]));
	return dp[i];
}

int main()
{
	ios::sync_with_stdio(0);
	ll n;
	cin >> n;
	ll arr[n],i,j;
	for(i=0;i<n;i++)
		cin >> arr[i];
	for(i=0;i<n;i++)
		dp[i]=-1;
	dp[0]=0;
	dp[1]=abs(arr[1]-arr[0]);
	ll ans = func(arr,n-1);
	cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 4224
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

ll pw[10];
bool can[12][12];
int h, w;
vector<string> s;
bool rec(vector<ll> l, vector<ll> r, int bit, int depth = 0){
	if(bit == 0){
		int b = (1 << w) - 1;
		rep(i, w / 2){
			rep(j, w) if(b >> j & 1) rep(k, j) if(b >> k & 1){
				if(l[j] == r[k] && l[k] == r[j]){
					b -= 1 << j | 1 << k;
					goto NEXT;
				}
			}
			NEXT:;
		}
		if(__builtin_popcount(b) != w % 2) return 0;
		rep(i, w) if(b >> i & 1) if(l[i] != r[i]) return 0;
		return 1;
	}
	
	if(__builtin_popcount(bit) % 2){
		rep(i, h) if(bit >> i & 1){
			rep(k, w){
				l[k] += pw[depth] * (s[i][k] - 'a');
				r[k] += pw[depth] * (s[i][k] - 'a');
			}
			if(rec(l, r, bit ^ 1 << i, depth + 1)) return 1;
			rep(k, w){
				l[k] -= pw[depth] * (s[i][k] - 'a');
				r[k] -= pw[depth] * (s[i][k] - 'a');
			}
		}
		return 0;
	}
	
	rep(i, h) if(bit >> i & 1){
		for(int j = i + 1; j < h; j++) if(bit >> j & 1) if(can[i][j]){
			rep(k, w){
				l[k] += pw[depth] * (s[i][k] - 'a');
				r[k] += pw[depth] * (s[j][k] - 'a');
			}
			if(rec(l, r, bit ^ 1 << i ^ 1 << j, depth + 1)) return 1;
			rep(k, w){
				l[k] -= pw[depth] * (s[i][k] - 'a');
				r[k] -= pw[depth] * (s[j][k] - 'a');
			}
		}
		return 0;
	}
}
int main(){
	pw[0] = 1; rep(i, 9) pw[i + 1] = pw[i] * 29;
	cin >> h >> w;
	s.resize(h);
	rep(i, h) cin >> s[i];
	rep(i, h) rep(j, i){
		string a = s[i], b = s[j];
		sort(all(a)); sort(all(b));
		if(a == b) can[i][j] = can[j][i] = 1;
	}
	vector<ll> l(w), r(w);
	cout << (rec(l, r, (1 << h) - 1) ? "YES" : "NO") << endl;
	
	return 0;
}

Measured memory_bytes: 256
from collections import Counter
n = int(input())
a = list(map(int, input().split()))

c = Counter(a)
sum = 0
for i in c:
    x = c[i]
    if x > 1:
        sum += x*(x-1)//2

for i in a:
    x = c[i]
    print(sum-x+1)
    

Measured memory_bytes: 26780
#
# agc012 a
#

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2
5 2 8 5 1 5"""
        output = """10"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """10
1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000 1000000000"""
        output = """10000000000"""
        self.assertIO(input, output)


def resolve():
    N = int(input())
    a = list(map(int, input().split()))
    a.sort()
    ans = 0
    for i in range(N):
        a.pop()
        ans += a.pop()
    print(ans)


if __name__ == "__main__":
    # unittest.main()
    resolve()


Measured memory_bytes: 50148
N = int(input())
A = sorted(list(map(int, input().split())))

ret = 0
cnt = 0
n = 0

for i in range(N):
    if n == 0:
        cnt += 1
        n = A[i]
        continue

    if n != A[i]:
        ret += cnt if cnt < n else cnt - n
        n = A[i]
        cnt = 1
    else:
        cnt += 1

if cnt != n:
    ret += cnt if cnt < n else cnt - n

print(ret)


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

int N, M;

int a[50];
int b[50];

bool graph[50][50];
bool visited[50];

void dfs(int v) {

  visited[v] = true;
  
  for (int i = 0; i < N; i++) {
  
    // 繋がっていない場合は次の頂点へ
    if (graph[v][i] == false) {
      continue;
    }
  
    // すでに訪問済みの頂点の場合は次の頂点へ
    if (visited[i] == true) {
      continue;
    }
  
    // 繋がっていて、訪問済みじゃない場合は、次の頂点に継続してチェックする
    dfs(i);
  
  }
}

int main() {

  cin >> N >> M;

  for (int i = 0; i < M; i++) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;
  }

  int answer = 0;

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

    // 頂点を繋がっていないことにする
    graph[a[i]][b[i]] = false;
    graph[b[i]][a[i]] = false;
    
    // 訪問状況をクリア
    for (int j = 0; j < N; j++) {
      visited[j] = false;
    }

    dfs(0);

    bool flg = false;
    
    // 訪問できていない頂点があれば辺iは橋である
    for (int j = 0; j < N; j++) {
      if (visited[j] == false) {
        flg = true;
      }
    }

    if (flg) {
      answer++;
    }

    // 戻す
    graph[a[i]][b[i]] = true;
    graph[b[i]][a[i]] = true;

  }

  cout << answer << endl;

  return 0;

}

Measured memory_bytes: 256
#include <iostream>
#include<string>
#include <typeinfo>
using namespace std;
int main(void){
    // Your code here!
    int x,t;
    
    int sums=0;
    int& sum_a=sums;
    
    cin>>x>>t;
    sum_a=x-t;

    if(sum_a<=0) cout<<"0"<<endl;
    else cout<<sum_a<<endl;

}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        // 空白入力
        Scanner scan = new Scanner(System.in);
        int n = scan.nextInt();
        // 空白入力

        int[] a = new int[200010];
        for(int i=0;i<n;i++){
            a[i] = scan.nextInt();
        }

        int ma = 0;
        for(int i=1;i<n;i++){
            if(a[ma] < a[i]){
                ma = i;
            }
        }

        int temp;
        if(ma > 0){
            temp = 0;
        }else{
            temp = ma + 1;
        }

        for(int i=0;i<n;i++){
            if(ma == i){
                for(int j=0;j<n;j++){
                    if(ma != j){
                        if(a[temp] < a[j]){
                            temp = j;
                        }
                    }
                }
                System.out.println(a[temp]);
            }else{
                System.out.println(a[ma]);
            }
        }
    }
}


Measured memory_bytes: 94704
import java.util.*;

public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		long L = sc.nextLong();
		long R = sc.nextLong();
		sc.close();
		long ans = Long.MAX_VALUE;
		for (long i = L; i <= R - 1; i++) {
			for (long j = i + 1; j <= R; j++) {
				ans = Math.min(ans, (i * j) % 2019);
				if (ans == 0) {
					System.out.println(ans);
					return;
				}
			}
		}
		System.out.println(ans);
	}
}


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

using namespace std;

int main(){

	int A,B;
  	cin >> A >> B;
  
  	if(A==B)
      cout << "Draw" <<endl;
  
  	else if(A==1)
      cout << "Alice" << endl;
  
  	else if(B==1)
       cout << "Bob" << endl;
  
  	else if(A>B)
        cout << "Alice" << endl;
  
  	  	else
       cout << "Bob" << endl;

}

Measured memory_bytes: 3560
#include<iostream>
#include<string>
#define INF (1 << 30)
using namespace std;

int east_dir[3 * 100005];
int west_dir[3 * 100005];

int main() {
    int N, min_change_dir = INF;
    string S;
    cin >> N >> S;
    for (int i = 0; i < S.length(); i++) {
        east_dir[i] = 0;
        west_dir[i] = 0;
    }
    for (int i = 0; i < S.length(); i++) {
        if (S[i] == 'E') east_dir[i]++;
        else west_dir[i]++;
    }
    for (int i = 1; i < S.length(); i++) {
        west_dir[i] += west_dir[i - 1];
    }
    for (int i = S.length() - 2; i >= 0; i--) {
        east_dir[i] += east_dir[i + 1];
    }
    for (int i = 0; i < S.length(); i++) {
        if (i == 0) {
            min_change_dir = min(min_change_dir, east_dir[1]);
        }
        else if (i == S.length() - 1) {
            min_change_dir = min(min_change_dir, west_dir[S.length() - 2]);
        }
        else {
            min_change_dir = min(min_change_dir, east_dir[i + 1] + west_dir[i - 1]);
        }
    }
    cout << min_change_dir << endl;
    return 0;
} 

Measured memory_bytes: 3076
import java.util.*;

public class Main {// Main
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
   int n = sc.nextInt();
   int[] dp = new int[n+1];
     for(int i = 0 ; i < n-1 ; i++) {
    	 dp[sc.nextInt()]++;
     }
     for(int i = 1 ; i <= n ; i++) {
    	System.out.println(dp[i]);
     }
	}

	
}

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

using namespace std;

int main() {
  string s;
  cin>>s;
  
  string cur;
  string last;
  int k = 0;
  for (int i = 0; i < s.size(); i++) {
    cur += s[i];
    if (cur != last) {
      last = cur;
      cur = "";
      k++;
    }
  }
  cout<<k<<endl;
}

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

#define ll long long
#define ull unsigned long long 
#define endl '\n'
#define pii pair<int, int>
#define all(a) a.begin(),a.end()

template <typename T>
inline T gcd(T a, T b) { while (b != 0) swap(b, a %= b); return a; }

int main(){
    int d, n;
    cin >> d >> n;
    if(n==100)
        cout << 101 << string((d>0)?1<<(d):0,'0');
    else
        cout << n << string((d>0)?1<<d:0,'0');
}


Measured memory_bytes: 3616
import math
from functools import reduce


def gcd(*numbers):
    return reduce(math.gcd, numbers)


def main():
    K = int(input())
    s = sum([gcd(i+1, j+1, k+1) for i in range(K) for j in range(K) for k in range(K)])

    print(s)


if __name__=="__main__":
    main()


Measured memory_bytes: 189116
#include <bits/stdc++.h>   
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
     
ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
using Graph = vector<vector<int>>;
Graph G;


int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    int n, a, b, c; cin >> n >> a >> b >> c;
    vector<int> l(n);
    rep(i, n) cin >> l[i];

    int m = pow(4, n);
    int ans_min = 100000000;

    rep(i, m){
        int sum = 0;
        vector<int> x, y, z;
        int k = i;

        rep(j, n){
            if(k % 4 == 1) x.push_back(j);
            else if(k % 4 == 2) y.push_back(j);
            else if(k % 4 == 3) z.push_back(j);
            k /= 4;
        }
        if(x.size() > 0 and y.size() > 0 and z.size() > 0){
            int len_a = 0, len_b = 0, len_c = 0;
            for(auto it : x){
                len_a += l[it];
            }
            sum += abs(len_a - a) + (x.size() - 1) * 10;
            for(auto it : y){
                len_b += l[it];
            }
            sum += abs(len_b - b) + (y.size() - 1) * 10;
            for(auto it : z){
                len_c += l[it];
            }
            sum += abs(len_c - c) + (z.size() - 1) * 10;
        }else continue;
        ans_min = min(sum, ans_min);
    }
    cout << ans_min << endl;
}

Measured memory_bytes: 3992