akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(n) begin(n), end(n)
using ll = long long;
using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  rep(snip_i, n) cin >> a.at(snip_i);
  vector<ll> sum(n);
  rep(i, n){
    sum.at(i) = a.at(i);
    if(i > 0) sum.at(i) += sum.at(i-1);
  }
  ll ans1 = 0, ans2 = 0;
  ll pos = 0;
  rep(i, n){//du
    if(i % 2 == 0){
      if(pos <= sum.at(i)){
        ans1 += sum.at(i) - pos + 1;
        pos = sum.at(i) + 1;
      }
    }else{
      if(pos >= sum.at(i)){
        ans1 += pos - sum.at(i) + 1;
        pos = sum.at(i) - 1;
      }
    }
  }

  pos = 0;
  rep(i, n){//du
    if(i % 2 == 1){
      if(pos <= sum.at(i)){
        ans2 += sum.at(i) - pos + 1;
        pos = sum.at(i) + 1;
      }
    }else{
      if(pos >= sum.at(i)){
        ans2 += pos - sum.at(i) + 1;
        pos = sum.at(i) - 1;
      }
    }
  }

  ll ans = min(ans1, ans2);
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 1408
import java.util.*;

class Main{
	public static void main(String[] $){
		System.err.println();
		Scanner s=new Scanner(System.in);
		int a=s.nextInt();
		int b=s.nextInt();
		double x=s.nextInt();

		int v=a*a*b;
		double r=0;
		if(x*2>=v){
			System.err.println("high");
			r=(v-x)*2/a/a;
			System.out.println(Math.atan2(r,a)/Math.PI*180);
		}else{
			System.err.println("low");
			r=x*2/a/b;
			System.out.println(90-Math.atan2(r,b)/Math.PI*180);
		}
		System.err.println(r);
	}
}

Measured memory_bytes: 22996
def two_int():
    N, K = map(int, input().split())
    return N,K

def one_int():
    return int(input())

def one_str():
    return input()

def many_int():
    return list(map(int, input().split()))

a,b = input().split()

aa = "".join([a]*int(b))
bb = "".join([b]*int(a))


print(min(aa,bb))

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
#define REP(i,st,ed) for(register int i=st,i##end=ed;i<=i##end;++i)
#define DREP(i,st,ed) for(register int i=st,i##end=ed;i>=i##end;--i)
typedef long long ll;
template<typename T>inline bool chkmin(T &x,T y){return (y<x)?(x=y,1):0;}
template<typename T>inline bool chkmax(T &x,T y){return (y>x)?(x=y,1):0;}
inline int read(){
	int x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1)+(x<<3)+(c^'0');
	return x*f;
}
inline ll readll(){
	ll x;
	char c;
	int f=1;
	while((c=getchar())!='-' && (c>'9' || c<'0'));
	if(c=='-') f=-1,c=getchar();
	x=c^'0';
	while((c=getchar())>='0' && c<='9') x=(x<<1ll)+(x<<3ll)+(c^'0');
	return x*f;
}
const int maxn=1e6+10,mod=1e9+7;
int f[maxn],sum;
int main(){
	int n=read();
	f[1]=sum=n;
	REP(i,2,n){
		f[i]=(sum+(ll)(n-1)*(n-1)+(n-i+2-(i==2))-f[i-2]+mod)%mod;
		sum=(sum+f[i])%mod;
	}
	printf("%d\n",f[n]);
	return 0;
}


Measured memory_bytes: 4096
import sys
stdin=sys.stdin

ip=lambda: int(sp())
fp=lambda: float(sp())
lp=lambda:list(map(int,stdin.readline().split()))
sp=lambda:stdin.readline().rstrip()

k,t=lp()
a=lp()

x=max(a)

if k%2==0:
  if x<=(k//2):
    print(0)
  else:
    rest=k-x
    print(x-(rest+1))
    
else:
  if x<=(k//2)+1:
    print(0)
  else:
    rest=k-x
    print(x-(rest+1))
    

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

typedef double du ;
typedef string st ;
typedef long long ll ;
typedef long double ld ;
typedef long long int lli ;

#define vi vector <lli>
#define loop(num) for (lli i = 0 ; i < num ; i ++ )
#define loop2(num) for (lli j = 0 ; j < num ; j ++ )
#define loopcin(num , ar ) for (lli i = 0 ; i < num ; i ++ ) {cin >> ar [i] ;}
#define loopcout(num , ar) for (lli i = 0 ; i < num ; i ++ ) {cout << ar [i] << ' '; }
#define looppu(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . push_back (x) ;}
#define loopin(num , ar) for (lli i = 0 ; i < num ;  i++) {lli x ; cin >> x ; ar . insert (x) ;}

#define forr(num1 , num2) for (lli i = num1 ; i < num2 ; i ++ )
#define forrcin(num1 , num2 , ar ) for (lli i = num1 ; i < num2 ; i ++ ) {cin >> ar [i] ;}
#define forrcout(num1 , num2 , ar) for (lli i = num1 ; i < num2 ; i ++ ) {cout << ar [i] << ' '; }

#define D2forrcin(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cin >> A[i][j] ;}}
#define D2forrcout(num1_1 , num1_2 , num2_1 , num2_2 , A ) for (lli i = num1_1 ; i < num1_2 ; i ++){ for (lli j = num2_1 ; j < num2_2 ; j++){cout << A[i][j] << ' ' ;}cout << endl ;}

#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl

#define F first
#define S second
#define pb push_back
#define pf push_front
#define pob pop_back ()
#define pof pop_front ()

#define fastio ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

signed main ()
{
    fastio
    ll x , y , z ;
    cin >> x >> y >> z ;
    if (x == y && x == z)
        No ;
    else if (x == y || x == z || y == x || y == z || z == x || z == y  )
        Yes ;
    else
        No ;

    return 0 ;
}

/*___________________________________________________________________functions___________________________________________________________________________*/




Measured memory_bytes: 256
class Graph:
    def __init__(self,V,E):
        self.V = V
        self.E = E

    def WF(self,st):
        N,INF = len(self.V),10**7+1
        dp = [INF for _ in range(N)]
        #dp[i]:頂点stから頂点iへの最小距離
        dp[st] = 0
        update = True
        while update:
            update = False
            for i in range(N):
                for j in range(N):
                    if (j,i) in self.E:
                        if dp[i] > dp[j] + self.E[(j,i)]:
                            dp[i] = dp[j] + self.E[(j,i)]
                            update = True
        return dp

def main():
    n = int(input())
    I = [list(map(int,input().split())) for _ in range(n)]
    V = set([i for i in range(n)])
    E = {}
    for i in range(n):
        for j in range(I[i][1]):
            E[(I[i][0],I[i][j*2+2])] = I[i][j*2+3]
    G = Graph(V,E)
    sp = G.WF(0)
    for i in range(n):
        print(i,sp[i])

if __name__ == "__main__":
    main()



Measured memory_bytes: 6288
from functools import reduce
from fractions import gcd


def lcm(a, b):
    return a * b // gcd(a, b)


def main():
    clocks_num = int(input())
    time = [int(input()) for _ in range(clocks_num)]
    print(reduce(lcm, time))


if __name__ == '__main__':
    main()



Measured memory_bytes: 5128
#include <stdio.h>
int main(void){
    double r, are, circ;
    double PI=3.141592653589;
    
    scanf("%lf", &r);
    
    are=PI*r*r;
    circ=PI*r*2;
    
    printf("%f %f\n", are, circ);
    
    return 0;
    
}



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

typedef long long ll;

const int N = 1e6 + 5;
bool p[N];
ll a, b;

void init() {
    for (int i = 2; i < N; ++i) {
        if (!p[i]) {
            for (int j = i + i; j < N; j += i) {
                p[j] = true;
            }
        }
    }
}

ll gcd(ll a, ll b) {
    if (b == 0) return a;
    return gcd(b, a % b);
}

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cin >> a >> b;
    ll c = gcd(a, b);
    ll res = 1;
    for (int i = 2; i < N; ++i) {
        if (c < i) break;
        if (!p[i]) {
            if (c % i == 0) {
                ++res;
                while (c % i == 0) {
                    c /= i;
                }
            }
        }
    }
    if (c >= N) res++;
    cout << res << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(int)(n); i++)

using namespace std;
using LL = long long;
using P = pair<int,int>;

int main(){
	int N, K;
	cin >> N >> K;
	string S;
	cin >> S;
	int dif=0;
	rep(i,N-1) if(S[i]!=S[i+1]) dif++;
	dif=max(0,dif-K*2);
	cout << N-1-dif << endl; 

	return 0;
}

Measured memory_bytes: 3764
#include<stdio.h>
long long a, b, c;
int main() {
    scanf("%lld%lld%lld", &a, &b, &c);
    if(c <= a) {
        printf("%lld %lld", a - c, b);
    }
    else {
        c = c - a;
        a = 0;
        if(b <= c) {
            printf("0 0");
        }
        else {
            printf("0 %lld", b - c);
        }
    }
    return 0;
}

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

using namespace std;

int main()
{   
 string s;
 cin>>s;
 set<char>ss;
 for(int i=0;i<s.size();i++)
 {
    ss.insert(s[i]);
 }
 if(ss.size()==s.size())cout<<"yes"<<endl;
 else cout<<"no";
 
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
using namespace std;
int a[100005];
int main(){
int n;
cin>>n;
	for(int i=1;i<=n;i++){
		cin>>a[i];
	}
	int t;
	int sum=0;
	for(int i=1;i<=n;i++){
			if(a[i]==i){
				sum++;
						t=a[i];
			a[i]=a[i+1];
			a[i+1]=t;
		
			}
	}
	printf("%d",sum);
}

Measured memory_bytes: 640
#include<cstdio>
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<stack>
#include<queue>
#include<numeric>

#define INF (1<<28)
#define rep(i,j) for(int i=0;i<(j);i++)
#define reps(i,j,k) for(int i=(j);i<=(k);i++)
#define fs first
#define sc second
#define pb push_back
#define in(i,j,k) ((j)<=(i)&&(i)<=(k))
using namespace std;

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

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

int main(){
	int w,h;
	while(cin>>w>>h,w){
		vector<vi> bd(h,vi(w,INF));
		vector<vi> wall(2*h-1,vi(w));
		rep(i,2*h-1){
			if(i&1) rep(j,w) cin >> wall[i][j];
			else rep(j,w-1) cin >> wall[i][j];
		}
		queue<pii> q;
		q.push(pii(0,0));
		bd[0][0] = 1;
		while(!q.empty()){
			int x = q.front().sc;
			int y = q.front().fs;
			q.pop();
			rep(i,4){
				int cx = x + dx[i];
				int cy = y + dy[i];
				if(in(cx,0,w-1)&&in(cy,0,h-1)){
					if(wall[2*y + dy[i]][x + min(0,dx[i])]) continue;
					if(bd[cy][cx]>bd[y][x]+1){
						bd[cy][cx] = bd[y][x]+1;
						q.push(pii(cy,cx));
					}
				}
			}
		}
		if(bd[h-1][w-1]==INF) cout << 0 << endl;
		else cout << bd[h-1][w-1] << endl;
	}
	return 0;
}

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

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define w(x)            int x; cin>>x; while(x--)
#define fr(i,a,b)       for(int i = a; i < b; i++)

void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif
}

vector<int> graph[100001];
int dp[100001];

int longest_path(int src)
{
	if (dp[src] != -1)
		return dp[src];
	int is_leaf = 1;
	int best_len = 0;
	for (auto child : graph[src])
	{
		is_leaf = 0;
		best_len = max(best_len, longest_path(child));
	}
	return dp[src] = (is_leaf == 1 ? 0 : 1 + best_len);
}

void solve()
{
	int n, m, u, v;
	cin >> n >> m;
	fr(i, 0, m)
	{
		cin >> u >> v;
		graph[u].pb(v);
	}
	memset(dp, -1, sizeof(dp));
	int ans = 0;
	fr(i, 1, n + 1)
	ans = max(ans, longest_path(i));
	cout << ans << endl;
	return;
}

int32_t main()
{
	c_p_c();
	solve();
	return 0;
}

Measured memory_bytes: 11900
N = int(input())

A = []
for i in range(N):
    s, p = input().split()
    A.append((i+1, s, int(p)))

B = sorted(A, key=lambda x:x[2],reverse=True)
C = sorted(B, key=lambda x:x[1])
for c in C:
    print(c[0])

Measured memory_bytes: 3060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<cassert>
#include<iostream>
#include<sstream>
#include<string>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<utility>
#include<numeric>
#include<algorithm>
#include<bitset>
#include<complex>

using namespace std;

typedef long long Int;
typedef vector<int> vint;
typedef pair<int,int> pint;
#define mp make_pair

template<class T> void pv(T a, T b) { for (T i = a; i != b; ++i) cout << *i << " "; cout << endl; }
template<class T> void chmin(T &t, T f) { if (t > f) t = f; }
template<class T> void chmax(T &t, T f) { if (t < f) t = f; }
int in() { int x; scanf("%d", &x); return x; }

int main() {
	string str;
	cin>>str;
	int i,res;
	int kupc[4]={};
	for(i=0;i<str.size();i++){
		if(str[i]=='K'){
			kupc[0]++;
		}else if(str[i]=='U'){
			kupc[1]++;
		}else if(str[i]=='P'){
			kupc[2]++;
		}else if(str[i]=='C'){
			kupc[3]++;
		}
	}
	res=kupc[0];
	chmin(res,kupc[1]);
	chmin(res,kupc[2]);
	chmin(res,kupc[3]);
	cout<<res<<endl;
	return 0;
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
long long int power(int a,int b)
{
    if(b==0)
        return 1;
    long long int k=power(a,b/2);
    if(b%2==0)
        return ((k%M)*(k%M))%M;
    else
        return ((k%M)*(k%M)*(a%M))%M;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
     #ifndef ONLINE_JUDGE
 
    freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
 
   #endif
   long long int a,b,x;
   cin>>a>>b>>x;
long long int ans= (b/x)- (a/x);

if(a%x==0 )
ans++;
cout<<ans;
   
    return 0;
}








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

struct DATA{
  int number;
  int answer;
  int rank;
};

bool Compare(const DATA&, const DATA&);

int main(){
  int i, num, ans, ran, check;
  char c;
  DATA newdata;
  vector<DATA> data;

  while(1){
    cin >> num >> c >> ans;
    if(num == 0 && ans == 0) break;

    newdata.number = num;
    newdata.answer = ans;
    data.push_back(newdata);
  }

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

  ran = 0;
  for(i=0; i<data.size(); ++i){
    if(i != 0 && data[i].answer == data[i-1].answer){
      data[i].rank = ran;
    }else{
      ++ran;
      data[i].rank = ran;
    }
  }

  while(cin >> check){
    for(i=0; i<data.size(); ++i){
      if(data[i].number == check) break;
    }
    cout << data[i].rank << endl;
  }
  return 0;
}

bool Compare(const DATA& x, const DATA& y){
  return (x.answer > y.answer);
}

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

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))    
#define OUT(P) cout << (P) << endl    
#define OUT2(P1, P2) cout << (P1) << " " << (P2) << endl    
#define PRINT_ARRAY(P) for(int i=0; i<P.size(); i++) cout << P[i] << endl;    
#define PRINT_ARRAY_INLINE(P) do { for(int i=0; i<P.size(); i++) cout << P[i] << " "; cout << endl; } while(0)    
#define PRINT_ARRAY_WITH_LABEL(L, P) do { cout << L << ": "; PRINT_ARRAY_INLINE(P); cout << endl; } while(0)    
typedef long long ll;    
const long DIVIDE = 1e9+7;

int sum_digits(int num);    
template <class T>    
vector<T> copy_vector(vector<T> vec);    
int gcd(int a, int b);    
// ****** print functions ****** //
template <class T, class U>
void print_pairs(const vector<pair<T, U>> pairs);
template <class K, class V>
void print_map(const map<K, V> m);


int main() {    

    int n, l;
    cin >> n >> l;

    //int total = n * (l + n * (n+1) / 2 - 1);
    vector<int> items(n);
    for(int i=0; i<n; i++) {
        items[i] = l + (i+1) - 1;
    }
    sort(items.begin(), items.end());
    int total = 0;
    int min = items[0];
    for(int i=0; i<n; i++) {
        if(abs(min) > abs(items[i])) {
            min = items[i];
        }
        total += items[i];
    }

    //PRINT_ARRAY_INLINE(items);
    //cout << total << " " << min << endl;
    cout << total - min << endl;

    return 0;    
}    

/******************************/    
/***** DECRARED FUNCTIONS *****/    
/******************************/    

int sum_digits(int num) {    
    int rtn = 0;    
    while(num != 0) {    
        int tmp = num % 10;    
        rtn += tmp;    
        num /= 10;    
    }    
    return rtn;    
}    

// vectorのコピー    
template <class T>    
vector<T> copy_vector(vector<T> vec) {    
    vector<T> rtn;    
    rtn.reserve(vec.size());    
    copy(vec.begin(), vec.end(), back_inserter(rtn));    
    return rtn;    
}    

// ユークリウッドの互除法    
int gcd(int a, int b) {    
    if(b==0) return a;    
    else return gcd(b, a % b);    
}

template <class T, class U>
void print_pairs(const vector<pair<T, U>> &pairs) {
    for(int i=0; i<pairs.size(); i++) { 
        cout << "(" << pairs[i].first << ", " << pairs[i].second << ")" << " "; 
    } 
    cout << endl;
}

template <class K, class V>
void print_map(const map<K, V> &m) {
    for(auto it=m.cbegin(); it!=m.cend(); it++) {
        cout << it->first << ": " << it->second << endl;
    }
}


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

using namespace std;

const int SIZE = 6;
const int yen[] = {1, 5, 10, 50, 100, 500};

int prev(int *p, int *n) // O
{
	int cnt, i;
	cnt = 0; i = SIZE-1;
	while(i > -1) {
		if(!n[i]) { i--; continue; } // zero
		if((*p) < yen[i]) { break; }
		(*p) -= yen[i];
		n[i]--; cnt++;
	}
	return cnt;
}
int myPay(int money, int *n) // ©ªª¥¤×«Å¬
{
	int cnt, i;
	int nn[SIZE];
	cnt = 0; i = SIZE - 1;
	for(int j=0; j < SIZE; j++) nn[j] = 0;
	while(i > -1) {
		if(n[i] <= nn[i]) { i--; continue; } // zero
		if(money < yen[i]) { i--; continue; }
		money -= yen[i];
		nn[i]++; cnt++;
	}
	if(money) return 0;
	return cnt;
}
int oturi(int money) // èª¥¤×«Å¬
{
	int cnt, mod;
	cnt = 0; mod = money;
	for(int i=SIZE-1; i >= 0 && mod; i--) {
		cnt+= mod / yen[i];
		mod = mod % yen[i];
	}
	return cnt;
}
int solve(int p, int *n)
{
	int cnt = 0;
	cnt = prev(&p, n); // O
	if(!p) return cnt; // pay

	int minCnt = INT_MAX, cc = 0;
	for(int i=p; i < 667; i++) {
		cc = myPay(i, n);
		if(cc) {
			cc += oturi(i - p);
			minCnt = min(minCnt, cc);
		}
	}
	if(minCnt != INT_MAX) {
		cnt += minCnt;
	}
	return cnt;

}

int main(void)
{
	int p, cnt;
	int n[SIZE];
	p = cnt = 0;
	while(cin >> p, p)
	{
		for(int i=0; i < SIZE; i++) {
			cin >> n[i];
		}
		printf("%d\n", solve(p, n));
	}
	return 0;
}

Measured memory_bytes: 0
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	//数値の入力
		int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int d = sc.nextInt();
      	//絶対値を用いる
      	int num1 = Math.abs(a-b);
      	int num2 = Math.abs(b-c);
      	int num3 = Math.abs(a-c);
      
      	if(num1 <=d && num2 <=d){
          System.out.println("Yes");
        }else if(num3 <=d){
          System.out.println("Yes");
        }else{
          System.out.println("No");
        }
     }
}

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

#define REP(i,n) for(ll i=0;i<ll(n);++i)
#define RREP(i,n) for(ll i=ll(n)-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<ll(n);++i)
#define RFOR(i,m,n) for(ll i=ll(n)-1;i>=ll(m);--i)
#define ALL(v) (v).begin(),(v).end()
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;

using ll = long long;
using vi = vector<int>;
using vl = vector<ll>;
using vvi = vector<vi>;
using vvl = vector<vl>;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

template <class T> bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template <class T> bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	vl a(n), b(n);
	REP(i, n)cin >> a[i];
	REP(i, n)cin >> b[i];
	ll s = 0;
	REP(i, n)s += a[i];
	REP(i, n)s -= b[i];
	if (s < 0) {
		cout << -1 << endl;
		return 0;
	}
	s = 0;
	vi p;
	int cnt = 0;
	REP(i, n) {
		if (a[i] < b[i]) {
			s += b[i]-a[i];
			cnt++;
		}
		else p.push_back(a[i] - b[i]);
	}
	sort(ALL(p), greater<>());
	ll m = 0;
	REP(i, p.size()) {
		if (m >= s) {
			cout << cnt+i << endl;
			return 0;
		}
		m += p[i];
	}
	cout << cnt+p.size() << endl;
}

Measured memory_bytes: 2428
#include <iostream>
#define REP(i, n) for (int i = 0; i < (n); i++)
using namespace std;

const string YES = "YES";
const string NO = "NO";

void solve(long long A, long long B, long long C){
    if (A * B * C == 175) cout << YES << '\n';
    else cout << NO << '\n';
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    long long A;
    scanf("%lld",&A);
    long long B;
    scanf("%lld",&B);
    long long C;
    scanf("%lld",&C);
    solve(A, B, C);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <bitset>
using namespace std;

const int MAX_ROW = 110; // to be set appropriately
const int MAX_COL = 110000; // to be set appropriately
struct BitMatrix {
    int H, W;
    bitset<MAX_COL> val[MAX_ROW];
    BitMatrix(int m = 1, int n = 1) : H(m), W(n) {}
    inline bitset<MAX_COL>& operator [] (int i) {return val[i];}
};

ostream& operator << (ostream& s, BitMatrix A) {
    s << endl; 
    for (int i = 0; i < A.H; ++i) {
        for (int j = 0; j < A.W; ++j) {
            s << A[i][j] << ", ";
        }
        s << endl;
    }
    return s;
}

void GaussJordan(BitMatrix &A, bool is_extended = false) {
    vector<bool> used(A.H, 0);
    for (int col = 0; col < A.W; ++col) {
        if (is_extended && col == A.W - 1) break;
        int pivot = -1;
        for (int row = 0; row < A.H; ++row) {
            if (used[row]) continue;
            if (A[row][col]) {
                pivot = row;
                break;
            }
        }
        if (pivot == -1) continue;
        for (int row = 0; row < A.H; ++row) {
            if (row != pivot && A[row][col]) A[row] ^= A[pivot];
        }
        used[pivot] = true;
    }
}

const int MD = 60;
int main() {
    int N; cin >> N;
    vector<long long> A(N);
    for (int i = 0; i < N; ++i) cin >> A[i];

    long long res = 0;
    BitMatrix B(MD+1, N+1);
    vector<bool> cannot(MD+1, 0);
    for (long long d = MD; d >= 0; --d) {
        int num = 0;
        for (int i = 0; i < N; ++i) {
            if (A[i] & (1LL<<d)) ++num;
        }
        if (num == 0) {
            cannot[d] = 1;
            continue;
        }
        else if (num & 1) {
            cannot[d] = 1;
            res += (1LL<<d);
            continue;
        }

        for (int i = 0; i < N; ++i) {
            if (A[i] & (1LL<<d)) B[MD-d][i] = 1;
        }
        B[MD-d][N] = 1;
    }
    GaussJordan(B, true);

    //cout << B << endl;

    for (int d = MD; d >= 0; --d) {
        if (cannot[d]) continue;

        // d 行目が (0 0 0 ... 0 | 1) だったらダメ
        bool ok = false;
        for (int i = 0; i < N; ++i) if (B[MD-d][i]) ok = true;
        if (!B[MD-d][N]) ok = true;

        // 結果に 2 × 2^d が寄与
        if (ok) res += (2LL<<d);
    }
    cout << res << endl;
}


Measured memory_bytes: 2560
#include <set>
#include <string>
#include <iostream>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <limits>
using namespace std;
static int imin = std::numeric_limits<int>::min();
static int imax = std::numeric_limits<int>::max();
#define ll long long
#define rep(i, n) for(int i = 0; i<n; ++i)
#define rep1(i, n) for(int i = 1; i<n; ++i)
#define debug(x) cout << #x << ":" << x << "\n";
template<class T>
std::ostream& operator << (std::ostream& os, std::vector<T>& vec){
  std::size_t n = vec.size();
  if(n == 0){
    return os;
  }
  for(int i = 0; i<n - 1; ++i){
    os << vec[i] << " ";
  }
  os << vec[n - 1];
  os << std::endl;
  return os;
}

template <class T>
auto mkVec(unsigned int x){
  return std::vector<int>(x);
}

template <class T>
auto mkVec2(unsigned int x, unsigned int y){
  return std::vector<std::vector<T>>(y, std::vector<T>(x));
}

template <class T>
auto mkVec3(unsigned int x, unsigned int y, unsigned int z){
  return std::vector<std::vector<std::vector<T>>>(z, std::vector<std::vector<T>>(y, std::vector<T>(x)));
}

long long N;
long long ret = 0;

//slow
bool is357(int x){
  auto s = to_string(x);
  return s.find("3") != string::npos && s.find("5") != string::npos && s.find("7") != string::npos;
}

void f(long long x){
  if (x > N){return;};
  if(is357(x)){
    ret++;
  }
  f(x * 10 + 3);
  f(x * 10 + 5);
  f(x * 10 + 7);
}

#ifndef BOOST_TEST_MAIN
int main(int const argc, char const** argv){
  cin >> N;
  f(0);
  cout << ret;
}
#endif


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

class UnionFindTree{
private:
  vector<int> parent;

  
  int getRoot(int i){
    if(parent[i] == i)return i;
    return getRoot(parent[i]);
  }


public:
  UnionFindTree(int n) : parent(n) {
    for(int i=0; i<n; i++)parent[i] = i;
  }


  void unite(int x, int y){
    int rootx = getRoot(x);
    int rooty = getRoot(y);
    
    if(rootx == rooty)return;
    parent[rootx] = rooty;
  }

  bool same(int x, int y){
    return getRoot(x) == getRoot(y);
  }

};
  
int main(){

  int n,q;
  cin >> n >> q;
  UnionFindTree uft(n);

  for(int i=0; i<q; i++){
    int com, x, y;
    cin >> com >> x >> y;
    if(com == 0)uft.unite(x,y);
    else cout << (uft.same(x,y)? 1 : 0) << endl;
  }
    

  return 0;
}



Measured memory_bytes: 3160
#include <iostream>
#include <string>
#include <cmath>
#include <algorithm>
using namespace std;
int main(){
	string s;
	cin>>s;
	char a[10];
	for(int i=0;i<10;i++)a[i]=' ';
	int j=0;
	for(int i=0;i<s.size();i++){
		if(s[i]!='B'){
			a[j]=s[i];
			j++;
		}
		else{
			a[j-1]=' ';
			if(j!=0)j--;
		}
	}
	for(int i=0;i<10;i++){
		if(a[i]!=' ')cout<<a[i];
		else break;
	}
	cout<<endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
using P = pair <int, int>;
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; }
const long long INF = 1LL << 60;
const int mod = 1000000007;

ll dp[100100];
int main() {
   int n,q;
   cin>>n>>q;
   string s;
   cin>>s;
   vector<int>a(n);
   rep(i,n-1){
       if(s[i]=='A'&&s[i+1]=='C'){
           a[i+1]++;
       }
   }
   vector<int>d(n);
   d[0] = a[0];
   rep(i,n-1){
       d[i+1] =d[i]+a[i+1];
   }
   rep(i,q){
       int l,r;
       cin>>l>>r;
       cout << d[r-1]-d[l-1] <<endl;
   }

}

Measured memory_bytes: 4288
#include <bits/stdc++.h>
#define rep(i, a) for (int i = (int)0; i < (int)a; ++i)
#define rrep(i, a) for (int i = (int)a - 1; i >= 0; --i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define RREP(i, a, b) for (int i = (int)a - 1; i >= b; --i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()
using ll = long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

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;
}

ll gcd(ll n, ll m)
{
	ll tmp;
	while (m != 0)
	{
		tmp = n % m;
		n = m;
		m = tmp;
	}
	return n;
}

ll lcm(ll n, ll m)
{
	return abs(n) / gcd(n, m) * abs(m); //gl=xy
}

using namespace std;

void solve()
{
	int n;
  cin>>n;
  vector<ll>a(n);
  rep(i,n)cin>>a[i];
  vector<bool>b(1e6+5);
  vector<int>ng(1e6+5);
  sort(all(a));
  rep(i,n){
    if(ng[a[i]]){
      ng[a[i]]++;
      continue;
    }
    ng[a[i]]++;
    if(b[a[i]])continue;
    for(int j=a[i]+a[i];;j+=a[i]){
      if(j>1e6)break;
      b[j]=true;
    }
  }
  int ans=0;
  rep(i,n){
    if(ng[a[i]]>=2)continue;
    if(b[a[i]])continue;
    ++ans;
  }
  cout<<ans;
}

int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout << fixed << setprecision(15);
	solve();
	return 0;
}


Measured memory_bytes: 8728
//
// Created by Hideaki Imamura on 2020-03-08.
//
# include <bits/stdc++.h>

using namespace std;
typedef long long ll;
typedef pair <ll, ll> l_l;
typedef pair<int, int> i_i;

template<class T>
inline bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}

template<class T>
inline bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
}

# define EPS (1e-7)
# define INF (1e9)
# define PI (acos(-1))
//const ll mod = 1000000007;

int A, B, M, a[100010], b[100010], x[100010], y[100010], c[100010];

int main() {
    cin >> A >> B >> M;
    int min_a = INF;
    int min_b = INF;
    for (int i = 0; i < A; ++i) {
        cin >> a[i];
        min_a = min(min_a, a[i]);
    }
    for (int i = 0; i < B; ++i) {
        cin >> b[i];
        min_b = min(min_b, b[i]);
    }
    for (int i = 0; i < M; ++i) cin >> x[i] >> y[i] >> c[i];

    int ans = min_a + min_b;
    for (int i = 0; i < M; ++i) {
        ans = min(ans, a[x[i] - 1] + b[y[i] - 1] - c[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 2176
# Aizu Problem 00164: Ohajiki Game
#
import sys, math, os, bisect

# read input:
PYDEV = os.environ.get('PYDEV')
if PYDEV=="True":
    sys.stdin = open("sample-input.txt", "rt")


while True:
    n = int(input())
    if n == 0:
        break
    A  = [int(_) for _ in input().split()]
    oha = 32
    i = 0
    while oha != 0:
        oha -= (oha - 1) % 5
        print(oha)
        oha = max(oha - A[i % n], 0)
        print(oha)
        i += 1

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

#define endl '\n'

using namespace std;

int main(){

  cin.tie(0);     // cout と cin の同期を切る
  ios::sync_with_stdio(false);  /* cの stdioストリーム (printfとか)と*/

  string str;

  cin>>str;

  int maxx=0;

  int cnt=0;
  
  for(int i=0;i<str.length();i++){
    if(str[i]=='A'||str[i]=='C'||str[i]=='G'||str[i]=='T'){
      cnt++;
      maxx=max(maxx,cnt);
    }else{
      cnt=0;
    }
  }

  cout<<maxx<<endl;
  
  return 0;

}


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

int main(){

    ll N, K;
    cin >> N >> K;
    vector<ll>cnt(K, 0);
    for(ll i = 1; i <= N; i++)cnt[i % K]++;
    ll ans = 0;
    for(ll a = 1; a <= N; a++){
        ll b = (K - (a % K)) % K;
        if((b + b) % K == 0){
            ans += cnt[b] * cnt[b];
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1792
#include <iostream>
#include <vector>
#include <queue>
#include <stack>
#include <map>
#include <set>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <functional>
#include <string>
#include <algorithm>
#include <climits>
#include <utility>

#define PRINT(STR) cout << STR << endl;
#define REP(i, n) for (int (i) = 0; (i) < (int)(n); (i)++)
#define REG(i, a, b) for (int (i) = ((int)(a)); (i) < ((int)(b)); i++)
#define ALL(V) (V).begin(), (V).end()
#define SPACE " "

typedef long long ll;

using namespace std;

int nextInt() { int n = -1; cin >> n; return n; }
double nextDouble() { double d = -1; cin >> d; return d; }
ll nextll() { ll n = -1; cin >> n; return n; }
string nextString() { string str; cin >> str; return str; }

int INF = 1LL << 25;
double EPS = 1e-9;
int numofbits(int bits)
{
    bits = (bits & 0x55555555) + (bits >> 1 & 0x55555555);
    bits = (bits & 0x33333333) + (bits >> 2 & 0x33333333);
    bits = (bits & 0x0f0f0f0f) + (bits >> 4 & 0x0f0f0f0f);
    bits = (bits & 0x00ff00ff) + (bits >> 8 & 0x00ff00ff);
    return (bits & 0x0000ffff) + (bits >>16 & 0x0000ffff);
}

// BEGIN //////////////////////////////////////////////////////////////
int main() {
    int ls[10];
    int v1,v2;
    while (scanf("%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d,%d",
      ls, ls+1, ls+2, ls+3, ls+4, ls+5, ls+6, ls+7, ls+8, ls+9, &v1, &v2) != EOF) {
        int l_sum = 0;
        REP(i, 10) {
          l_sum += ls[i];
        }
        double l = (double)v1 * l_sum / (v1 + v2);
        REP(i, 10) {
          l -= ls[i];
          if (l <= 0) {
            PRINT(i + 1);
            break;
          }
        }
    }

	return 0;
}
// END   //////////////////////////////////////////////////////////////

Measured memory_bytes: 1208
/*
  Vivek Rathi
  CSE 2nd Year
  MNNIT
*/
#include<bits/stdc++.h>
using namespace std;
#define M 1000000007
#define ll long long int
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define debug1(x) cout<<#x<<" "<<x<<endl;
#define debug2(x,y) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<endl;
#define debug3(x,y,z) cout<<#x<<" "<<x<<" "<<#y<<" "<<y<<" "<<#z<<" "<<z<<endl;
#define present(c,x) ((c).find(x) != (c).end())
#define null NULL
#define mp make_pair
#define fi first
#define se second
#define boost ios_base::sync_with_stdio(false);cin.tie(NULL);
#define inf 1e17
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update>
ll a[22][22],n;
ll dp[5000001];
ll solve(ll mask)
{
	ll i=__builtin_popcount(mask);
	if(i==n) return 1;
	if(dp[mask]!=-1) return dp[mask];
	ll tot=0;
	for(ll j=0;j<n;j++)
	{
		//debug2((mask&(1<<j)==0),a[i][j]);
		if(a[i][j]==1&&((mask&(1<<j))==0))
		{
			//debug1(mask);
			tot=(tot+solve(mask|(1<<j)))%M;
		}
	}
	return dp[mask]=tot;
}
int main()
{
	boost
	cin>>n;
	memset(dp,-1,sizeof(dp));
	for(ll i=0;i<n;i++)
	{
		for(ll j=0;j<n;j++)
		{
			cin>>a[i][j];
		}
	}
	cout<<solve(0)%M<<endl;
	return 0;
}

Measured memory_bytes: 39424
object Main extends App {
  val n: Long = scala.io.StdIn.readLong()
  var i: Long = 1
  var digit = 10000000
  while (i<=math.sqrt(n)) {
    if (n%i == 0) {
      digit = math.min(math.max(i.toString.length, (n/i).toString.length), digit)
    }
    i = i + 1
  }
  println(digit)
}

Measured memory_bytes: 25536
N,M=map(int,input().split())
H=list(map(int,input().split()))
a=[[] for _ in range(N)]
ans=0
for i in range(M):
    A,B=map(int,input().split())
    a[B-1].append(A-1)
    a[A-1].append(B-1)
for i in range(N):
    q=a[i]
    while q:
        b=q.pop()
        if H[i]<=H[b]:
            ans+=1
            break
print(N-ans)

Measured memory_bytes: 31016
#include <iostream>
#include <vector>
#include <cmath>
#include <iomanip>
#include <algorithm>
#include <map>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)

int main() {
	int x,ans=1,t;
	cin>>x;
	for(int a=2;a<35;a++){
	    t=a;
	    while(t<=1000){
	        t*=a;
	        if(t<=x)ans=max(ans,t);
	    }
	}
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
n=int(input())
li=[list(input().split()) for i in range(n)]
x=input()

flag=0
minus=0
zenbu=0
for i in range(n):
  if flag==0:
    minus+=int(li[i][1])
  if li[i][0]==x:
    flag=1
  zenbu+=int(li[i][1])

print(zenbu-minus)

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

using namespace std;

int main(){
    int n;
    cin>>n;
    vector <int> a(n);
    for(int i=0;i<n;i++){
        a[i]=1e9;
    }
    vector <int> b(n-1);
    int res=0;
    for(int i=0;i<n-1;i++){
        cin>>b[i];
        a[i]=min(a[i], b[i]);
        a[i+1]=min(a[i+1], b[i]);
    
        //cout<<a[i]<<a[i+1]<<endl;
    }
    for(int i=0;i<n;i++){
        res+=a[i];
    }
    cout<<res<<endl;
    return 0;
}

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

int main() {
	int a, b, c;
	int s, m, l;
	int ans;
	scanf("%d%d%d", &a, &b, &c);
	s = min(min(a, b), c);
	l = max(max(a, b), c);
	m = (a + b + c) - (s + l);
	printf("%d", ((m - s) / 2 + (m - s) % 2) + (l + (m - s) % 2 - m));
	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MAX=105;
const ll INF=0x3f3f3f3f;
const ll MOD=1e9+7;
ll N,ans,h[MAX],dp[MAX][MAX],order[MAX],hg[MAX],hg_cnt;
pll g[MAX];
ll power(ll x,ll y){
    if(y==0) return 1;
    ll t=power(x,y/2);
    if(y%2) return t*t%MOD*x%MOD;
    return t*t%MOD;
}
int main(){
    scanf("%lld",&N);
    for(ll i=0;i<N;i++) {
        scanf("%lld",&h[i]);
        g[i].first=h[i],g[i].second=i;
    }
    sort(g,g+N);
    hg[hg_cnt++]=1;
    for(ll i=0;i<N;i++) {
        if(hg[hg_cnt-1]!=g[i].first) hg[hg_cnt++]=g[i].first;
        order[g[i].second]=hg_cnt-1;
    }
    dp[0][order[0]]=2;
    for(ll i=0;i<order[0];i++) dp[0][i]=(power(2,hg[order[0]]-hg[i]+1)-power(2,hg[order[0]]-hg[i+1]+1)+MOD)%MOD;
    for(ll i=1;i<N;i++){
        for(ll j=0;j<=min(order[i],order[i-1])-1;j++) dp[i][j]=dp[i-1][j];
        for(ll j=min(order[i],order[i-1]);j<=order[i-1];j++) dp[i][min(order[i],order[i-1])]+=2*dp[i-1][j],dp[i][min(order[i],order[i-1])]%=MOD;
        if(order[i]>order[i-1]){
            ll t=power(2,hg[order[i]]-hg[order[i-1]]);
            for(ll j=0;j<order[i-1];j++) dp[i][j]=(dp[i][j]*t)%MOD;
            dp[i][order[i]]=dp[i][order[i-1]];
            for(ll j=order[i]-1;j>=order[i-1];j--) dp[i][j]=(power(2,hg[order[i]]-hg[j])-power(2,hg[order[i]]-hg[j+1])+MOD)*dp[i][order[i-1]]%MOD;
        }
    }
    for(ll i=0;i<=order[N-1];i++) ans+=dp[N-1][i],ans%=MOD;
    printf("%lld\n",ans);
    return 0;
}


Measured memory_bytes: 384
#include<iostream>

using namespace std;

int main(){
 int x,y;
  
  cin >> x >> y;
  
  if(x==2 || y==2) cout << "No" << endl;
  else if(x==4 && y!=6 && y!=9 && y!=11) cout << "No" << endl;
  else if(x==6 && y!=9 && y!=11) cout << "No" << endl;
  else if(x==9 && y!=11) cout << "No" << endl;
  else if(x==11) cout << "No" << endl;
  else cout << "Yes" << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mem(a,b) memset(a,b,sizeof(a)) 

map<ll,ll>mp;
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0);
	int n;
	cin>>n;
	ll ans;
	for(ll i=1;i*i<=n;i++)
	{
		ans=i;
	}
	cout<<ans*ans<<endl;
	return  0;
}

Measured memory_bytes: 256
/**
*    Username : adhoc_king
*    Name : adhoc_king
*    Institute : IIT Bombay
*/

// #include <bits/stdc++.h>
#include <algorithm>
#include <iostream>
#include <cstring>
#include <vector>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <string>
// #include <deque>
// #include <queue>
// #include <array>
// #include <ctime>
// #include <list>
#include <map>
// #include <set>
// #include <cassert>
// #include <complex>
// #include <sstream>
// #include <forward_list>
// #include <unordered_set>
// #include <unordered_map>
using namespace std;

#define pb push_back
#define mp make_pair
#define scani(n) scanf("%d",&n);
#define EPS 1e-9
#define FOR(i,n) for(int i=0; i<n; i++)
#define X first
#define Y second
#define arrinput for(int i=0; i<n; i++) cin>>arr[i];
#define arrsum for(int i=0; i<n; i++) sum+=arr[i];
#define for0(i,n) for(int i=0; i<n; i++)
#define for1(i,n) for(int i=1; i<=n; i++)
#define forr(i,n) for(int i=n-1; i>=0; i--)
#define all(v) v.begin(), v.end()

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

const int MOD = 1e9+7;
const int n_ = 1e5+1000;
const long double PI = acos(-1.0);

ll gcd (ll a, ll b) {return ( a ? gcd(b%a, a) : b );}
ll power(ll a, ll n) {ll p = 1;while (n > 0) {if(n%2) {p = p * a;} n >>= 1; a *= a;} return p;}
ll power(ll a, ll n, ll mod) {ll p = 1;while (n > 0) {if(n%2) {p = p * a; p %= mod;} n >>= 1; a *= a; a %= mod;} return p % mod;}

bool vowel(char ch) {
    if(ch=='a' || ch=='e' || ch=='i' || ch=='o' || ch=='u') return true;
    else return false;
}

int main()
{
    #define int long long
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    // freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);

    int n;
    cin>>n;
    string str;
    cin>>str;
    int count[26];
    memset(count, 0, sizeof(count));
    for0(i,n) count[str[i] - 'a']++;
    int prod = 1;
    for0(i,26) {
        prod *= (count[i] + 1);
        prod %= MOD;
    }
    cout<<(prod-1+MOD)%MOD;

    return 0;
}

Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <unordered_map>
#include <queue>
 
using namespace std; 

typedef unordered_map<int,unordered_map<int,int>> double_map;
 
int dfs(
    int now, int end, int flow, int *cost,
    vector<bool> &arrived, vector<int> &dp, double_map &g, double_map &costs
) {
    if(now==end||flow==0) return flow;
    arrived[now] = true;
    for(pair<int,int> p : costs[now]) {
        int next = p.first;
        int next_cost = p.second;
        if(arrived[next]) continue;
        if(dp[next]-dp[now]==next_cost) {
            int res = dfs(next,end,min(flow,g[now][next]),cost,arrived,dp,g,costs);
            if(res>0) {
                g[now][next] -= res;
                g[next][now] += res;
                costs[next][now] = -costs[now][next];
                if(g[now][next]==0) {
                    costs[now].erase(next);
                }
                *cost += res*next_cost;
                return res;
            }
        }
    }
    return 0;
}
 
void calc(int v, double_map &costs, vector<int> &dp, int s) {
    dp[s] = 0;
    vector<int> vf(v,1<<30);
    for(int loop = 0; loop < v; loop++) {
        for(int now = 0; now < v; now++) {
            if(dp[now]==1<<30) continue;
            vf[now] = min(vf[now],dp[now]);
            for(pair<int,int> p : costs[now]) {
                int next = p.first;
                int next_cost = p.second;
                vf[next] = min(vf[next],dp[now]+next_cost);
            }
        }
        dp.swap(vf);
    }
}

int min_cost_flow(int v, double_map &g, double_map &costs, int f, int s, int e) {
    int cost = 0;
    int ans = 0;
    while(ans<f) {
        vector<int> dp(v,1<<30);
        calc(v,costs,dp,s);
        vector<bool> arrived(v);
        int flow = dfs(s,e,f-ans,&cost,arrived,dp,g,costs);
        if(flow<=0) {
            return -1;   
        }
        else ans += flow;
    }
    return cost;
}
 
int main() {
    int v,e,f;
    double_map g,costs;
    cin >> v >> e >> f;
    for(int i = 0; i < e; i++) {
        int u,v2,c,d;
        cin >> u >> v2 >> c >> d;
        if(c<=0) continue;
        g[u][v2] = c;
        costs[u][v2] = d;
    }
    int cost = min_cost_flow(v,g,costs,f,0,v-1);
    cout << cost << endl;
}


Measured memory_bytes: 3192
fn input_one<T: std::str::FromStr> () -> Result<T, T::Err> {
    let mut n = String::new();
    std::io::stdin().read_line(&mut n).unwrap();
    n.trim().parse()
}

fn main() {
    let mut h: usize = input_one().unwrap();
    let mut m = 1usize;
    let mut r = 0;
    while h > 1 {
        h >>= 1;
        r += m;
        m *= 2;
    }
    println!("{}", m + r);
}


Measured memory_bytes: 2096
import java.io.IOException;
import java.io.InputStream;
import java.util.NoSuchElementException;


public class Main {
  public static void main(String[] args) {
    FastScanner sc = new FastScanner();
    long N = sc.nextInt();
    
    long M = 1;
    for (; M * (M + 1) / 2 <= N; M ++) {
    }
    
    long last = M * (M + 1) / 2 - N;
    
    StringBuilder sb = new StringBuilder();
    for (int i = 1; i <= M; i ++) {
      if (i != last) {
        sb.append(i);
        sb.append("\n");
      }
    }
    System.out.println(sb);
  }

}


class FastScanner {
	public static String debug = null;

	private final InputStream in = System.in;
	private int ptr = 0;
	private int buflen = 0;
	private byte[] buffer = new byte[1024];
	private boolean eos = false;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				if (debug != null) {
					buflen = debug.length();
					buffer = debug.getBytes();
					debug = "";
					eos = true;
				} else {
					buflen = in.read(buffer);
				}
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen < 0) {
				eos = true;
				return false;
			} else if (buflen == 0) {
				return false;
			}
		}
		return true;
	}

	private int readByte() {
		if (hasNextByte())
			return buffer[ptr++];
		else
			return -1;
	}

	private static boolean isPrintableChar(int c) {
		return 33 <= c && c <= 126;
	}

	private void skipUnprintable() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
	}

	public boolean isEOS() {
		return this.eos;
	}

	public boolean hasNext() {
		skipUnprintable();
		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() {
		return (int) nextLong();
	}

	public long[] nextLongList(int n) {
		return nextLongTable(1, n)[0];
	}

	public int[] nextIntList(int n) {
		return nextIntTable(1, n)[0];
	}

	public long[][] nextLongTable(int n, int m) {
		long[][] ret = new long[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextLong();
			}
		}
		return ret;
	}

	public int[][] nextIntTable(int n, int m) {
		int[][] ret = new int[n][m];
		for (int i = 0; i < n; i ++) {
			for (int j = 0; j < m; j ++) {
				ret[i][j] = nextInt();
			}
		}
		return ret;
	}
}

Measured memory_bytes: 8276
# import sys
import math #sqrt,gcd,pi
# import decimal
# import queue # queue
# import bisect
# import heapq # priolity-queue
# import time
# from itertools import product,permutations,\
#     combinations,combinations_with_replacement
# 重複あり順列、順列、組み合わせ、重複あり組み合わせ
# import collections # deque
# from operator import itemgetter,mul
# from fractions import Fraction
# from functools import reduce

# mod = int(1e9+7)
mod = 998244353
INF = 1<<29
lINF = 1<<35

def readInt():
    return list(map(int,input().split()))

def main():
    a,b,h,m = readInt()
	# 時針、分針の進んだ角度とその差を求める
    r1 = h * 30 + (m / 60) * 30
    r2 = m * 6
    r = abs(r1-r2)
    if r>180:
        r = 360 - r
	# 余弦定理から辺の長さを計算する
    ans = math.sqrt(a * a + b * b - 2 * a * b * math.cos(math.radians(r)))
    print(ans)
    return

if __name__=='__main__':
    main()


Measured memory_bytes: 9500
#include<bits/stdc++.h>
using namespace std;
#define F first
#define S second
#define ll long long
#define pb push_back
#define pf push_front
#define Mid ((l+r)/2)
#define pi pair<int,int>
#define pii pair<pi,int>
#define go ios::sync_with_stdio(0); cin.tie(0); cout.tie(0)
ll n;
ll ans,a[200200];
map <ll,ll> cnt;
int main()
{
    go;
    cin>>n;
    for(ll i=1;i<=n;i++)
        cin>>a[i];
    for(ll i=n;i>=1;i--)
    {
        ans+=cnt[i+a[i]];
        cnt[i-a[i]]++;
    }
    cout<<ans;
    return 0;
}


Measured memory_bytes: 27848
#include <stdio.h>

int main(void){
  int n;
  int i;

  scanf("%d",&n);
  for (i=9;i>0;i--){
    if (n%i==0){
      if (n/i<=9){
        printf("Yes\n");
        return 0;
      }
    }
  }
  printf("No\n");
  return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    int k,s;cin>>k>>s;
    int count=0;
    for(int a=0;a<=k;a++){
        for(int b=0;b<=k;b++){
            if((a+b)<=s&&s-a-b<=k)count++;
        }
    }
cout<<count<<endl;
}



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

int main() {
  int N;
  cin >> N;
  vector<int> moti(N);
  for (int i = 0; i < N; i++) {
    cin >> moti.at(i);
  }
  int M = N;
  sort(moti.begin(), moti.end());
  
  for (int i = 0; i < M - 1; i++) {
    if(moti.at(i)==moti.at(i + 1)) N--;
  }
  
  cout << N <<endl;
}


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

int main() {
	int n, T[100001], m, P[100001], sum, temp, X[100001];
	cin >> n;
	for(int i = 0; i< n; i++){
		cin >> T[i];
	}
	cin >> m;
	for(int i = 0; i< m ; i++){
		cin >> P[i] >> X[i];
	}
	
	for(int i = 0; i<m; i++){
		temp = T[P[i] -1];
		T[P[i]-1] = X[i];
		
		for(int j = 0; j < n; j++){
			sum += T[j]; //和を
		}
		cout << sum << endl;
		sum = 0;
		T[P[i]-1] = temp;
	}
	
	
	return 0;
}

Measured memory_bytes: 256