akhauriyash/Code-Regression huggingface dataset:
n, m = gets.split(" ").map(&:to_i)
a = gets.split(" ").map(&:to_i)

cnt = Hash.new{|h,k| h[k] = 0}
n.times do |i|
  cnt[a[i]] += 1
end

m.times do |i|
  b, c = gets.split(" ").map(&:to_i)
  cnt[c] += b
end


cnt = cnt.sort_by{|k,v| -k}
ans = 0


cnt.length.times do |i|
  if n <= cnt[i][1]
    ans += cnt[i][0] * n
    break
  else
    ans += cnt[i][0] * (cnt[i][1])
    n -= cnt[i][1]
  end
end

puts ans


Measured memory_bytes: 31864
#include <bits/stdc++.h>
#define rep(i, n) for(int i= 0; i < (n); i++)
using ll= long long int;
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
ll mod= 1e9 + 7;


int main(){
  int n;
  cin >>n;
  deque<ll> g,r;
  vector<ll>p;
  ll ans=0;
  rep(i,n){
    ll a;
    cin >> a;
    p.push_back(a);
  }
  sort(p.begin(),p.end());
  rep(i,n){
    g.push_back(p.back());
    r.push_front(p.back());
    p.pop_back();
  }

  ll k=g.front();
  ll fir=k;
  g.pop_front();
  rep(i,n-1){
    if(i==n-2){
      ans+=max(abs(k-g.front()),abs(fir-g.front()));
    }
    else if((i+2)%2==0){
      ans+=abs(k-g.back());
      k=g.back();
      g.pop_back();
    }else{
      ans+=abs(k-g.front());
      k=g.front();
      g.pop_front();
    }
  }

  k=r.front();
  fir=k;
  r.pop_front();
  ll ans2=0;
    rep(i,n-1){
    if(i==n-2){
      ans2+=max(abs(k-r.front()),abs(fir-r.front()));
    }
    else if((i+2)%2==0){
      ans2+=abs(k-r.back());
      k=r.back();
      r.pop_back();
    }else{
      ans2+=abs(k-r.front());
      k=r.front();
      r.pop_front();
    }
  }

  cout << max(ans,ans2) << endl;
}


Measured memory_bytes: 5640
N,T = map(int,input().split())
A = list(map(int,input().split()))
pro = {} #利益がkey売るポイントが何個あるかがvalue
m = A[0]
for i in range(1,N):
    if m > A[i]:
        m = A[i]
    elif A[i]-m not in pro:
        pro[A[i]-m] = 1
    else:
        pro[A[i]-m] += 1

mk = 0
ans = 0
for k, v in pro.items():
    if k > mk:
        mk = k
        ans = v
#print(pro)
print(ans)

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

using namespace std;

#define rep(i,n) for(int i=0; i<n; i++)
#define reep(i,a,b) for(int i=a; i<b; i++)
#define INF 0x3f3f3f3f

string s;
int mn[300][300];
int mx[300][300];

int MAX(int l, int r);
int MIN(int l, int r);


int MAX(int l, int r){
	if(mx[l][r]!=-INF) return mx[l][r];
	int &ret = mx[l][r];
	while(s[l] == '(') l++;
	while(s[r] == ')') r--;
	if(l==r&&isdigit(s[l])) return ret = s[l]-'0';
	if(s[l+1]==')') return ret;
	if(s[r-1]=='(') return ret;
	reep(i,l,r+1){
		if(s[i]=='+') ret = max(ret, MAX(l,i-1)+MAX(i+1, r));
		if(s[i]=='-') ret = max(ret, MAX(l,i-1)-MIN(i+1, r));
	}
	return ret;
}

int MIN(int l, int r){
	if(mn[l][r]!=INF) return mn[l][r];
	int &ret = mn[l][r];
	while(s[l] == '(') l++;
	while(s[r] == ')') r--;
	if(l==r&&isdigit(s[l])) return ret = s[l]-'0';
	if(s[l+1]==')') return ret;
	if(s[r-1]=='(') return ret;
	reep(i,l,r+1){
		if(s[i]=='+') ret = min(ret, MIN(l,i-1)+MIN(i+1, r));
		if(s[i]=='-') ret = min(ret, MIN(l,i-1)-MAX(i+1, r));
	}
	return ret;
}

int main(){
	cin>>s;
	rep(i,300){
		rep(j,300){
			mx[i][j] = -INF;
			mn[i][j] = INF;
		}
	}
	cout<<MAX(0,s.size()-1)<<endl;
}

Measured memory_bytes: 3892
def reverse_polish_notation(A):
	ops = {'+': lambda a, b: b + a,
	       '-': lambda a, b: b - a,
	       '*': lambda a, b: b * a}

	stack = []

	for i in A:
		if i in ops:
			stack.append(ops[i](stack.pop(), stack.pop()))
		else:
			stack.append(int(i))

	return stack[0]

if __name__ == '__main__':
	A = list(input().split())
	print(reverse_polish_notation(A))

Measured memory_bytes: 7692
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
#define MAX_N 200005

int main() {
    int x,y,z;
    cin >> x >> y >> z;
    int n = x + y + z;
    ll ans = 0;
    vector<pair<P,P>> v; // (銀 - 金), 金, 銀, 銅
    int f[n] = {};
    rep(i,n){
        pair<P,P> p;
        cin >> p.first.second >> p.second.first >> p.second.second;
        p.first.first = p.second.first - p.first.second;
        v.push_back(p);
    }
    sort(v.begin(), v.end(), greater<pair<P,P>>());
    rep(i,y){
        f[i] = 1;
    }
    int now = y;
    priority_queue<P> gold;
    priority_queue<P> silver;
    rep(i,n){
        if(f[i] == 0){
            gold.push(P(v[i].second.second - v[i].first.second, i));
        }else{
            silver.push(P(v[i].second.second - v[i].second.first, i));
        }
    }
    rep(i,z){
        while(f[gold.top().second] != 0)gold.pop();
        while(f[now] != 0)now++;
        if(silver.top().first + v[now].first.first >= gold.top().first){
            f[silver.top().second] = 2;
            silver.pop();
            silver.push(P(v[now].second.second - v[now].second.first, now));
            f[now] = 1;
        }else{
            f[gold.top().second] = 2;
            gold.pop();
        }
    }

    rep(i,n){
        if(f[i] == 0){
            ans += v[i].first.second;
        }else if(f[i] == 1){
            ans += v[i].second.first;
        }else{
            ans += v[i].second.second;
        }
    }

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


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

int a[200001];
multiset<int> s;
int main()
{
	ios::sync_with_stdio(false);
	int n,k;
	cin>>n>>k;
	for(int i=1;i<=n;i++){
		int x;
		cin>>x;
		a[x]++;
	}
	for(int i=1;i<=n;i++)
		if(a[i]!=0) s.insert(a[i]);
	int ans=0;
	while(s.size()>k){
		ans+=*s.begin();
		s.erase(s.begin());
	}
	cout<<ans;
int fuck;
return 0;
}

Measured memory_bytes: 10368
#include<bits/stdc++.h>
using namespace std;
int f(int x){
if(x==0) return 0;
  else
    return f(x/10)+(x%10);
}
int main(){
  int N;
  cin>>N; int ans=1000;
  for(int i=1;i<=N/2;i++){
  if(f(i)+f(N-i)<ans)
    ans=f(i)+f(N-i);
  
  }cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3616
import java.util.Scanner;

public class Main {
	static final int CHECK = 0;
	static final int RINGO = 1;
	static final int KAKI  = 2;
	static final int MIKAN = 3;
	
	char[][] field;
	int h, w, fruit;

	void run() {
		Scanner scan = new Scanner(System.in);
		while (true) {
			h = scan.nextInt();
			w = scan.nextInt();
			if (h + w == 0)
				break;
			field = new char[h][];
			for (int i = 0; i < h; i++) {
				field[i] = new char[w];
				char[] f = scan.next().toCharArray();
				for (int j = 0; j < w; j++) {
					if (f[j] == '@')
						field[i][j] = RINGO;
					else if (f[j] == '#')
						field[i][j] = KAKI;
					else
						field[i][j] = MIKAN;
				}
			}
			int ans = 0;
			for (int i = 0; i < h; i++) {
				for (int j = 0; j < w; j++) {
					if (field[i][j] != CHECK) {
						ans++;
						fruit = field[i][j];
						bfs(i, j);
					}
				}
			}
			System.out.println(ans);
		}
	}

	void bfs(int y, int x) {
		if (y < 0 || x < 0 || y >= h || x >= w || field[y][x] != fruit)
			return;
		field[y][x] = CHECK;

		bfs(y + 1, x + 0);
		bfs(y + -1, x + 0);
		bfs(y + 0, x + 1);
		bfs(y + 0, x + -1);
	}

	public static void main(String[] args) {
		new Main().run();
	}
}

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

public class Main {

	public static void main(String[] args) {
		new Main().run();
	}

	FastScanner sc;

	int N;
	int M;
	int[] boxes;
	boolean[] isRed;
	void run() {
		sc = new FastScanner();
		
		N = sc.nextInt();
		M = sc.nextInt();
		isRed = new boolean[N];
		
		isRed[0] = true;
		boxes = new int[N];
		for (int i = 0; i < N; i++) {
			boxes[i] = 1;
		}
		for (int i = 0; i < M; i++) {
			int now = sc.nextInt()-1;
			int next = sc.nextInt()-1;
			
			if (isRed[now]) {
				isRed[next] = true;
			}
			boxes[now] = boxes[now] - 1;
			boxes[next] = boxes[next] + 1;
			
			if (boxes[now] == 0) {
				isRed[now] = false;
			}
			
		}
		int ans  =0 ;
		for (int i = 0; i < N; i++) {
			if (isRed[i]) {
				ans++;
			}
		}
		
		System.out.println(ans);
	}
	
	

}

class FastScanner {
	private final InputStream in = System.in;
	private final byte[] buffer = new byte[1024];
	private int ptr = 0;
	private int buflen = 0;

	private boolean hasNextByte() {
		if (ptr < buflen) {
			return true;
		} else {
			ptr = 0;
			try {
				buflen = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (buflen <= 0) {
				return false;
			}
		}
		return true;
	}

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

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

	public boolean hasNext() {
		while (hasNextByte() && !isPrintableChar(buffer[ptr]))
			ptr++;
		return hasNextByte();
	}

	public String next() {
		if (!hasNext())
			throw new NoSuchElementException();
		StringBuilder sb = new StringBuilder();
		int b = readByte();
		while (isPrintableChar(b)) {
			sb.appendCodePoint(b);
			b = readByte();
		}
		return sb.toString();
	}

	public long nextLong() {
		if (!hasNext())
			throw new NoSuchElementException();
		long n = 0;
		boolean minus = false;
		int b = readByte();
		if (b == '-') {
			minus = true;
			b = readByte();
		}
		if (b < '0' || '9' < b) {
			throw new NumberFormatException();
		}
		while (true) {
			if ('0' <= b && b <= '9') {
				n *= 10;
				n += b - '0';
			} else if (b == -1 || !isPrintableChar(b)) {
				return minus ? -n : n;
			} else {
				throw new NumberFormatException();
			}
			b = readByte();
		}
	}

	public int nextInt() {
		long nl = nextLong();
		if (nl < Integer.MIN_VALUE || nl > Integer.MAX_VALUE)
			throw new NumberFormatException();
		return (int) nl;
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}
}

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



struct loc{
  long int x;
  long int y;
};

bool comp(const loc &l1, const loc &l2){
  return l1.x < l2.x;
}

void showvecs(vector<loc> &locs){
  cerr<<"showvec"<<endl;
  for(long int i=0; i<locs.size();++i){
    cerr<<locs[i].x<<","<<locs[i].y<<endl;
  }
  
}

long int getLIS(vector<loc> &locs){
  bool sitamuki = false;
  int nowmax = 0;
  long int dp[locs.size()];
  const long int INF = 114514191919;
  for (long int i=0; i<locs.size(); ++i) {
    dp[i]=INF;
  }
  for (long int i=0; i<locs.size(); ++i) {
    bool update = false;
    *lower_bound(dp, dp+locs.size(), locs[i].y) = locs[i].y;    
  }
  
  return lower_bound(dp, dp+locs.size(), INF) - dp;
}


int main(){
  long int N;
  long int x1,y1,x2,y2;
  vector<loc> locs;
  bool dir = true;
  cin >> x1 >> y1 >> x2 >> y2;
  cin >> N;
  if ((x1-x2) * (y1-y2) < 0){
    dir = false;
  }
  if(!dir){
    y1 = 1000000000 - y1;
    y2 = 1000000000 - y2;
  }

  for(long int i=0;i<N;++i){
    loc lc;
    cin >> lc.x;
    cin >> lc.y;
    if(!dir){
      lc.y = 1000000000 - lc.y;
    }
    if(lc.x < x1 && lc.x < x2 || lc.x > x1 && lc.x > x2 ||
       lc.y < y1 && lc.y < y2 || lc.y > y1 && lc.y > y2){
      continue;
    }
    locs.push_back(lc);
  }
  sort(locs.begin(),locs.end(),comp);
  showvecs(locs);
  const long int lis = getLIS(locs);
  std::cerr<<lis<<endl;
  const double pi = 3.1415926535897932;
  const double bonus = 5 * pi - 20;
  const double pena = 10 * pi - 20;
  double tbonus = 0.0;
  tbonus = lis*bonus;
  if(lis == abs(y1-y2)+1 || lis == abs(x1-x2)+1){
    cerr<<"toomany punt"<<endl;
    tbonus += pena - bonus;
  }

  const double dist = 100.0 * abs(x1-x2) + 100.0 * abs(y1-y2);
  cout<<setprecision(25)<<dist+tbonus<<endl;
  
  return 0;
}

Measured memory_bytes: 6256
#include <bits/stdc++.h>
using namespace std;
int s, t, n, m;
void chkmax(int &a, int b) {a = a > b ? a : b;}
void chkmin(int &a, int b) {a = a < b ? a : b;}
int read() {
	int x = 0, f = 1; char c = getchar();
	while(!isdigit(c)) {
		if(c == '-') f = -f;
		c = getchar();
	}
	while(isdigit(c)) {
		x = (x << 1) + (x << 3) + c - '0';
		c = getchar();
	}
	return x * f;
}
void write(int x) {
	char c[33] = {0}, tot = 0;
	if(x == 0) {puts("0"); return;}
	while(x) {c[++ tot] = x % 10 + '0'; x /= 10;}
	while(tot) {putchar(c[tot --]);}
	return ;
}
char c;
int main() {
	cin >> c;
	if('A' <= c && c <= 'Z') cout << "A";
	if('a' <= c && c <= 'z') cout << "a";
	return 0;
}


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

int main(){
  int i,n,dmax=0,ans=0;
  int a[2][100];
  cin>>n;
  cin>>a[0][0];
  for(i=1; i<n; i++){
    cin>>a[0][i];
    a[0][i]+=a[0][i-1];
  }
  for(i=0; i<n; i++){
    cin>>a[1][i];
  }
  for(i=n-2; i>=0; i--){
    a[1][i]+=a[1][i+1];
  }
  for(i=0; i<n; i++){
    dmax=max(dmax, a[0][i]+a[1][i]);
  }
  cout<<dmax<<endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pll;
vector<ll> p1;
const ll MAX=100000005;
const ll MOD=1000000007;
ll n,len,fin;
ll pow(ll x,ll y){
    if(y==0ll) return 1;
    if(y==1ll) return x;
    ll t=pow(x,y/2);
    if(y%2) return ((t*t)%MOD*x)%MOD;
    return (t*t)%MOD;
}
ll gcd(ll x, ll y){
    if(x==0||y==0) return x+y;
    return gcd(y,x%y);
}
int main(){
    ll t;
    scanf("%lld",&n);
    //for(len=0,t=n;t!=0;t/=10,len++);
    for(ll i=1;i<=10000&&n>=i*i;i++) if(n%i==0){
        if(n/i==i) p1.push_back(i);
        else p1.push_back(i),p1.push_back(n/i);
    }
    for(ll i=0;i<p1.size();i++){
        if(p1[i]<=9ll&&pow(10ll,p1[i]-1)*9ll*p1[i]<n) continue;
        fin+=(pow(10ll,p1[i]-1)*9ll-n/p1[i]+1)%MOD+MOD,fin%=MOD;
    }
    for(ll i=1;i<=min(n-1,MAX/2);i++){
        if(i<=8){
            ll a,b,t,s1=pow(10ll,i-1)*9ll,s2=s1*10ll,dn=n-i-(i+1);
            s1--,s2--;
            //if(i==4) printf("%lld\n",dn);
            if(s1*i+s2*(i+1)>=dn&&dn>=0){
                a=min(dn/i,s1);
                b=(dn-a*i)/(i+1);
                t=dn-a*i-b*(i+1);
                a-=t,b+=t;
                //printf("%lld %lld %lld %lld %lld %d\n",i,(i+1),a,b,dn,a*i+b*(i+1)==dn);
                if(a>=0&&s2>=b) fin+=min(a/(i+1)+1,(s2-b)/i+1),fin%=MOD;
            }
        }
        else{
            ll a,b,t,dn=n-i-(i+1);
            if(dn>=0){
                a=dn/i;
                b=(dn-a*i)/(i+1);
                t=dn-a*i-b*(i+1);
                a-=t,b+=t;
                if(a>=0) fin+=a/(i+1)+1,fin%=MOD;
            }
        }
        //printf("%lld %lld\n",i,fin);
    }
    for(ll i=1;i<=7;i++) for(ll j=i+2;j<=9;j++){
        ll a,b,t,s1=pow(10ll,i-1)*9ll,s2=pow(10ll,j-1)*9ll,dn=n-i-j;
        s1--,s2--;
        for(ll k=i+1;k<j;k++) dn-=pow(10ll,k-1)*9ll*k;
        //printf("%lld %lld %lld %lld\n",i,j,dn,s1*i+s2*j);
        if(s1*i+s2*j>=dn&&dn>=0){
            a=min(dn/i,s1);
            b=(dn-a*i)/j;
            t=dn-a*i-b*j;
            //printf("%lld %lld %lld %lld\n",t,i,j,gcd(i,j));
            if(t%gcd(i,j)!=0) continue;
            for(;t%j!=0;t+=i,a--);
            b+=t/j;
            //printf("%lld %lld %lld %lld %lld %d\n",i,j,a,b,dn,a*i+b*j==dn);
            if(a>=0&&s2>=b) fin+=min(a/(j/gcd(i,j))+1,(s2-b)/(i/gcd(i,j))+1),fin%=MOD;
        }
    }
    printf("%lld\n",fin);
}


Measured memory_bytes: 384
#include <iostream>
#include <string>

using namespace std;

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

    if (s.size() > k)
    {
        cout << string(s.begin(), s.begin()+k);
        cout << "...";
    }
    else
    {
        cout << s;
    }
    return 0;
}

Measured memory_bytes: 3628
def bitCount(i)
  res = 0

  while i > 0 do
    if i % 2 == 1
      res += 1
    end
    i /= 2
  end

  res
end

n, m = gets.chomp.split.map(&:to_i)

l = Array.new(n)
a = Array.new(n)
b = Array.new(n)

n.times do |i|
  l[i], a[i], b[i] = gets.chomp.split.map(&:to_f)
end

ans = 0.0

(1 << n).times do |i|
  if bitCount(i) != m
    next
  end

  sum = 0.0
  
  n.times do |j|
    if (i >> j) % 2 == 0
      next
    end
    n.times do |k|
      if  (i >> k) % 2 == 0 || j >= k
        next
      end
      sum += (l[j] - l[k]) ** 2
      sum += (a[j] - a[k]) ** 2
      sum += (b[j] - b[k]) ** 2
    end
  end

  if sum > ans
    ans = sum
  end
end

puts ans

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

int main() {
    int n;cin >> n;
    vector<vector<ll>> v(n,vector<ll>(2));
    for (int i=0;i<n;i++){
        cin >> v[i][0]>>v[i][1];
    }
    for (int a=0;a<n-1;a++){
        ll cur=1ll*max(v[a][0]/v[a+1][0]+(v[a][0]%v[a+1][0]!=0),v[a][1]/v[a+1][1]+(v[a][1]%v[a+1][1]!=0));
        v[a+1][0]=v[a+1][0]*cur;
        v[a+1][1]=v[a+1][1]*cur;
    }
  //  for(auto u:v)cout<<u[0]<<' '<<u[1]<<endl;
    cout << 1ll*v[n-1][0]+v[n-1][1];
}


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

// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << setprecision(12) << (s) << endl;

// util functions
template<class T> inline T sqr(T x) {return x*x;}

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  #x << " = " << (x) << endl
#define debug(x) #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(){
    INT_IN(N);
    INT_IN(K);
    int p = K;
    REP(i, N - 1){
        p *= K - 1;
    }
    PRINTLN(p);
    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define repr(i, n) for (int i = (n); i >= 0; --i)
#define FOR(i, m, n) for (int i = (m); i < (n); ++i)
#define FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
const ll mod = 1000000007;
const ll mod2 = 998244353;
const ll INF = 1e18;
const long double EPS = 1e-10;

int getsum(int n) {
  int sum = 0;
  while (n > 0) {
    sum += n % 10;
    n /= 10;
  }
  return sum;
}

int main() {
  int n, a, b;
  cin >> n >> a >> b;

  int ans = 0;
  rep(i, n + 1) {
    if (getsum(i) >= a && getsum(i) <= b) ans += i;
  }
  cout << ans << endl;




  
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <unordered_map>
#include <unordered_set>
#include <fstream>

using namespace std;

typedef unsigned long long ll;


int main() {

    int n;
    cin >> n;
    vector<int> numbers (n);

    for(int i = 0; i < n; i++)
        cin >> numbers[i];


    vector<int> prefix_sum (n);
    prefix_sum[0] = numbers[0];

    for(int i = 1; i < n; i++)
    {
        prefix_sum[i] = prefix_sum[i-1] + numbers[i];

    }


    int minDifference = 10e9;

    for(int t = 0; t < n-1; t++)
    {
        int diff = abs(prefix_sum[t] - (prefix_sum[n-1] - prefix_sum[t]));
        //cout << diff << endl;
        if (diff < minDifference)
            minDifference = diff;
    }

    cout << minDifference;
    return 0;


}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  int a,b,c,k;
  cin >> a >> b >> c >> k;

  if (a >= k) {
    cout << k << endl;
    return 0;
  }

  // k > a
  int rem = k - a;
  if (b >= rem) {
    cout << a << endl;
    return 0;
  }

  rem -= b;
  cout << a - rem << endl;
}

Measured memory_bytes: 3652
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
int n, m, v, u, par[200005];
vector<int> G[200005];
queue<int> qu;
int main() {
	scanf("%d%d", &n, &m);
	rep(i,m) {
		scanf("%d%d", &v, &u);
		G[v].push_back(u);
		G[u].push_back(v);
	}
	qu.push(1); par[1] = 1;
	while (!qu.empty()) {
		u = qu.front(); qu.pop();
		for(int nx: G[u]) if(!par[nx]) {
			qu.push(nx);
			par[nx] = u;
		}
	}
	puts("Yes");
	rep(i,n-1) printf("%d\n", par[i+2]);
}

Measured memory_bytes: 13052
#include <bits/stdc++.h>
#define F first
#define S second
using namespace std;
using ll = long long;
typedef pair<int, int> P;
const ll Mod = 1000000007;
int N;
vector<int> Graph[110000];
vector<int> Depth[110000];
vector<int> Deep(110000);
vector<int> Parent(110000);
vector<int> child[110000];
int root = 0;
void BFS() {
  for (int i = 0; i < (int)Deep.size(); i++) {
    Deep[i] = 999999;
  }
  priority_queue<P, vector<P>, greater<P>> Q;
  Q.push(make_pair(0,root));
  Depth[0].push_back(root);
  Deep[root] = 0;
  while (!Q.empty()) {
    P p = Q.top();
    Q.pop();
    for (int i = 0; i < (int)Graph[p.S].size(); i++) {
      if (Deep[Graph[p.S][i]] > p.F + 1) {
        Q.push(make_pair(p.F+1,Graph[p.S][i]));
        Deep[Graph[p.S][i]] = p.F + 1;
        Depth[p.F+1].push_back(Graph[p.S][i]);
        Parent[Graph[p.S][i]] = p.S;
        child[p.S].push_back(Graph[p.S][i]);
      }
    }
  }
}
int main() {
  cin >> N;
  vector<bool> exist(N);
  bool can = false;
  for (int i = 0; i < N; i++) {
    exist[i] = true;
  }
  for (int i = 0; i < N-1; i++) {
    int a,b;
    cin >> a >> b;
    a--; b--;
    Graph[a].push_back(b);
    Graph[b].push_back(a);
  }
  
  BFS();

  int Pa = (int)Graph[0].size();
  for (int i = N; i >= 0; i--) {
    for (int j = 0; j < (int)Depth[i].size(); j++) {
      int s = Depth[i][j];
      int ch = 0;
      vector<int> vec;
      bool Flag = false;
      if (i == 1 && Pa == 1) {
        Flag = true;
      }
      for (int k = 0; k < (int)child[s].size(); k++) {
        if (exist[child[s][k]]) {
          vec.push_back(child[s][k]);
          ch++;
        }
      }
      if (i <= 1) {
        if (Flag) {
          if (ch == 0) {
            continue;
          } else if (ch == 1) {
            can = true;
          } else if (ch >= 2) {
            can = true;
          }
        } else {
          if (ch == 0) {
            continue;
          } else if (ch == 1) {
            exist[s] = false;
            if (Parent[s] == 0) Pa--;
            exist[vec[0]] = false;
            if (Parent[vec[0]] == 0) Pa--;
          } else if (ch >= 2) {
            can = true;
          }
        }
      } else {
        if (ch == 0) {
          continue;
        } else if (ch == 1) {
          exist[s] = false;
          if (Parent[s] == 0) Pa--;
          exist[vec[0]] = false;
          if (Parent[vec[0]] == 0) Pa--;
        } else if (ch >= 2) {
          can = true;
        }
      }
    }
    if (can) {
      break;
    }
  }

  if (can) {
    cout << "First" << endl;
  } else {
    cout << "Second" << endl;
  }
  return 0;
}

Measured memory_bytes: 17780
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <unordered_set>
#include <iomanip>
//#pragma GCC optimize("Ofast")  //デバッグ時にoptimized-outされて邪魔だった
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<string> > vvs;
typedef vector<vector<ll> > vvll;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define floatprec(dig) fixed << setprecision(dig)
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define itn int;
#define invar(typ, var) typ var; cin >> var;
int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
const ll LLINF = 1LL<<60;
const ll MOD = 1000000007;
const double EPS = 1e-9;

signed main(void) {
  cin.tie(0); ios::sync_with_stdio(false);
  
  //mod Kで考える
  invar(int, N); invar(ll, K);
  
  vll A(N);
  //累積和（mod K)
  vll acc(N+1);
  rep(i, N) {
    cin >> A[i];
    acc[i+1] = (acc[i] + A[i]) % K;
  }
  
  //S_i - i (mod K) ごとのiの数
  map<ll,ll> mp;
  ll ans = 0;
  
  //累積和は要素数が + 1
  //S[0] = 0なので，要素が常に満たされる．
  //和の数がK以上になったら，次から使われないので消す．
  queue<ll> que;
  for(int j=0; j<N+1; ++j) {
    //予めKを足す
    ll t = (acc[j] - j) % K;
    if(t < 0) t += K;
    
    ans += mp[t];
    mp[t]++;
    
    que.push(t);
    if(que.size() >= K) {
      mp[que.front()]--;
      que.pop();
    }
  }
  
  fin(ans);
}

Measured memory_bytes: 17536
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <queue>
#include <set>
#include <map>

using namespace std;
typedef long long ll;

int a[32] = {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 main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout << setprecision(10) << fixed;
    int K;
    cin >> K;
    cout << a[K-1] << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
using namespace std;
int main()
{
    int n;
    cin>>n;
	if (n < 10)
		cout<<n;
	else if (n / 10 < 10)
		cout<<9;
	else if (n / 100 < 10)
		cout<< 9 + n - 99;
	else if (n / 1000 < 10)
		cout<<909;
	else if (n / 10000 < 10)
		cout<< 909 + n - 9999;
	else
		cout<<90909;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<pii,int> ppi;
typedef pair<int,pii> pip;

const int MN = 2e5+5;
const int MOD = 1e9+7;
const int INF = 1e9;

int N;
priority_queue<pii> PQ;

int cal(int x, int y)
{
	if(x>y) swap(x,y);
	return min(y-x,x+N-y);
}

int solve(int x)
{
	int l = 0, res = INF;
	for(int r=N-1; r>=0; r--){
		while(PQ.size()&&r<PQ.top().va){
			l = max(l,PQ.top().vb);
			PQ.pop();
		}
		//cout << l << ' ' << r << '\n';
		res = min(res,2*l+r+cal(r,x));
		res = min(res,l+2*r+cal(N-l,x));
	}
	while(PQ.size()) PQ.pop();
	//cout << res << '\n';
	return res;
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    string A,B;
    cin >> A >> B;
    N = A.size();
    int a=0, b=0;
    for(int i=0; i<N; i++){
    	a += A[i]=='1';
    	b += B[i]=='1';
    }
    if(!b){
    	if(!a) cout << 0;
    	else cout << -1;
    	exit(0);
    }
    int r[N],l[N];
    for(int i=0; i<N; i++){
    	for(int j=i; j<i+N; j++){
    		if(B[j%N]=='1'){
    			r[i] = j-i;
    			break;
    		}
    	}
    	for(int j=i; j>i-N; j--){
    		if(B[(j+N)%N]=='1'){
    			l[i] = i-j;
    			break;
    		}
    	}
    }
    int ans = INF;
    for(int i=0; i<N; i++){
    	int cnt = 0;
    	for(int j=0; j<N; j++){
    		if(A[j]==B[(i+j)%N]) continue;
    		//cout << r[j] << ' ' << l[j] << '\n';
    		PQ.emplace(r[j],l[j]);
    		cnt++;
    	}
    	ans = min(ans,solve(i)+cnt);
    }
    cout << ans;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

#define MOD 1000000007

int main(void) {
    int N;
    cin >> N;
    string S1, S2;
    cin >> S1 >> S2;

    long long ans;
    int start;
    if (S1[0] == S2[0]) {
        ans = 3;
        start = 1;
    } else {
        ans = 6;
        start = 2;
    }

    for (int i = start; i < N; ++i) {
        if (S1[i] == S2[i]) {
            if (S1[i - 1] == S2[i - 1]) {
                ans *= 2;
            } else {
                ans *= 1;
            }
            ans = ans % MOD;
        } else {
            if (S1[i - 1] == S2[i - 1]) {
                ans *= 2;
            } else {
                ans *= 3;
            }
            ans = ans % MOD;
            i++;
        }
    }

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

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <queue>
#define FOR(i,a,b) for(int i=(a); i<(b); i++)
#define pb push_back
using namespace std;

const int INF=10000000;
int V;
struct edge {
    int to,money,time;
};
struct state {
    int from, d;
    bool operator<(const state& a)const{
        return d>a.d;
    }
};
vector<vector<edge> > G;

int d[111];
int ds(int s,int g, int r){
    FOR(i,0,111)d[i]=INF;
    d[s]=0;
    priority_queue<state> q;
    q.push({s,0});
    while(q.size()){
        state sta=q.top();
        q.pop();
        int from=sta.from;
        FOR(i,0,G[from].size()){
            const edge& e=G[from][i];
            int to=e.to;
            int cost=r?e.time:e.money;
            if(d[to]>d[from]+cost){
                d[to]=d[from]+cost;
                q.push({to,d[to]});
            }
        }
    }
    return d[g];
}

int main(){
    int n;
    while(1){
        cin>>n>>V;
        if(!(n||V)) break;
        G=vector<vector<edge> >(n+1);
        FOR(i,0,n){
            int a,b,m,t;cin>>a>>b>>m>>t;
            G[a].pb({b,m,t});
            G[b].pb({a,m,t});
        }
        int k;cin>>k;
        FOR(i,0,k){
            int p,q,r;cin>>p>>q>>r;
            cout<<ds(p,q,r)<<endl;
        }
    }
}

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

template<typename T>
ostream& operator<<(ostream &os, vector<T> &v){
	string sep = " ";
	if(v.size()) os << v[0];
	for(int i=1; i<v.size(); i++) os << sep << v[i];
	return os;
}

template<typename T>
istream& operator>>(istream &is, vector<T> &v){
	for(int i=0; i<v.size(); i++) is >> v[i];
	return is;
}

#ifdef DBG
void debug_(){ cout << endl; }
template<typename T, typename... Args>
void debug_(T&& x, Args&&... xs){
	cout << x << " "; debug_(forward<Args>(xs)...);
}
#define dbg(...) debug_(__VA_ARGS__)
#else
#define dbg(...)
#endif

int main() {
	ios_base::sync_with_stdio(false);
	cout << setprecision(20) << fixed;

	vector<int> x(5);
	cin >> x;
	for(int i=0; i<5; i++){
		if(x[i]==0){
			cout << i+1 << endl;
			return 0;
		}
	}
	return 0;
}


Measured memory_bytes: 3644
#include<stdio.h>
#include<math.h>
main()
{
        int px, py, cx, cy, r;
        double a, b, c, tx, ty, ax[2], ay[2];
        scanf("%d %d%*c%d %d %d", &px, &py, &cx, &cy, &r);
        tx = px - cx;
        ty = py - cy;
        if(tx){
                a = pow((ty / tx), 2) + 1;
                b = pow(r, 2) * ty / pow(tx, 2);
                c = pow(pow(r, 2) / tx, 2) - pow(r, 2);
                ay[0] = (b + sqrt(pow(b, 2) - a * c)) / a;
                ay[1] = (b - sqrt(pow(b, 2) - a * c)) / a;
                ax[0] = -ty / tx * ay[0] + pow(r, 2) / tx;
                ax[1] = -ty / tx * ay[1] + pow(r, 2) / tx;
        }else{
                ay[0] = ay[1] = pow(r, 2) / ty;
                ax[0] = sqrt(pow(r, 2) - pow(ay[0], 2));
                ax[1] = -sqrt(pow(r, 2) - pow(ay[1], 2));
        }
        if(ax[0] < ax[1] || (ax[0] == ax[1] && ay[0] < ay[1])){
                printf("%.6f %.6f\n%.6f %.6f\n",
                           ax[0] + cx, ay[0] + cy, ax[1] + cx, ay[1] + cy);
        }else{
                printf("%.6f %.6f\n%.6f %.6f\n",
               ax[1] + cx, ay[1] + cy, ax[0] + cx, ay[0] + cy);
        }
}

Measured memory_bytes: 1824
#pragma GCC optimize(3)
#include<iostream>
#include<iomanip>
#include<stack>
#include<queue>
#include<list>
#include<vector>
#include<set>
#include<map>
#include<string>
#include<algorithm>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#define ll long long
#define db double
#define inf 100001
#define INF (int)1e9
#define pi acos(-1)
#define rd(n) {n=0;char ch;int f=0;do{ch=getchar();if(ch=='-'){f=1;}}while(ch<'0'||ch>'9');while('0'<=ch&&ch<='9'){n=(n<<1)+(n<<3)+ch-48;ch=getchar();}if(f)n=-n;}
using namespace std;
int n,m;

int sum[inf*4],tag[inf*4];

void ST_pushdown(int u,int l,int r,int mid){
	if (tag[u]){
		int ls=u*2,rs=u*2+1;
		sum[ls]+=tag[u]*(mid-l+1);
		sum[rs]+=tag[u]*(r-mid);
		tag[ls]+=tag[u];
		tag[rs]+=tag[u];
		tag[u]=0;
	}
	return;
}

void ST_pushup(int u){
	sum[u]=sum[u*2]+sum[u*2+1];
	return;
}

void ST_modify(int u,int l,int r,int L,int R,int v){
	if (L<=l && r<=R){
		sum[u]+=(r-l+1)*v;
		tag[u]+=v;
		return;
	}
	int mid=(l+r)/2;
	ST_pushdown(u,l,r,mid);
	if (L<=mid){
		ST_modify(u*2,l,mid,L,R,v);
	}
	if (R>mid){
		ST_modify(u*2+1,mid+1,r,L,R,v);
	}
	ST_pushup(u);
	return;
}

int ST_query(int u,int l,int r,int k){
	if (l==r){
		return sum[u];
	}
	int mid=(l+r)/2;
	ST_pushdown(u,l,r,mid);
	if (k<=mid){
		return ST_query(u*2,l,mid,k);
	}
	else{
		return ST_query(u*2+1,mid+1,r,k);
	}
}

struct data{
	int l,r;
}a[inf*3];

bool operator<(data _1,data _2){
	return _1.r-_1.l+1<_2.r-_2.l+1;
}

int main(){
	rd(n) rd(m)
	for (int i=1;i<=n;i++){
		rd(a[i].l) rd(a[i].r)
	}
	sort(a+1,a+n+1);
	int pos=1;
	for (int i=1;i<=m;i++){
		while (pos<=n && a[pos].r-a[pos].l+1<i){
			ST_modify(1,0,m,a[pos].l,a[pos].r,1);
			pos++;
		}
		int ans=n-pos+1;
		for (int j=0;i*j<=m;j++){
			ans+=ST_query(1,0,m,i*j);
		}
		printf("%d\n",ans);
	}
	return 0;
}

Measured memory_bytes: 5888
import java.util.*;
class Main{
	static Scanner s = new Scanner(System.in);

	public static void main(String[] args) {
		int[] parts;
		byte a,b,c;
		while(((a=s.nextByte())|(b=s.nextByte())|(c=s.nextByte()))!=0) {
			parts = new int[a+b+c];
			Arrays.fill(parts,2);
			Exam[] exams = new Exam[s.nextInt()];
			for(int i=0;i<exams.length;++i)
				exams[i]=new Exam(
						Integer.parseInt(s.next()),
						Integer.parseInt(s.next()),
						Integer.parseInt(s.next()),
						Integer.parseInt(s.next())
						);
			Arrays.sort(exams, (o1, o2) -> o2.r-o1.r);
			for(int i=0;i<exams.length;i++) {
				Exam e = exams[i];
				switch (e.r) {
				case 1:
					parts[e.a]=1;
					parts[e.b]=1;
					parts[e.c]=1;
					break;
				case 0:
					boolean
						ba=(parts[e.a]==1),
						bb=(parts[e.b]==1),
						bc=(parts[e.c]==1);
					if(!ba&& bb&& bc)
						parts[e.a]=0;
					if( ba&&!bb&& bc)
						parts[e.b]=0;
					if( ba&& bb&&!bc)
						parts[e.c]=0;
					break;
				}
			}
			System.out.println(Arrays.toString(parts).replaceAll("[^0-9,]", "").replaceAll(",", "\n"));
		}
	}
}
class Exam{
	int a,b,c,r;
	Exam(int p1,int p2,int p3,int re) {
		a=p1-1;
		b=p2-1;
		c=p3-1;
		r=re;
	}
}

Measured memory_bytes: 41416
#include <stdio.h>

int main(){
   int i,n;
   char s[200001];

   scanf("%s",s);
   for (n=i=0;s[i]!='\0';i++) n+=s[i]-'0';
   if (n%9==0) puts("Yes");
   else        puts("No");
   return 0;
}


Measured memory_bytes: 1808
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

def s(generator, splitter, mapper):
    return [ mapper(s) for s in generator().split(splitter) ]

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

n,d,a = get_nums_l()
lines = sys.stdin.readlines()
monsters = [ tuple(map(int, s.split(" "))) for s in lines ]
monsters.sort(key=lambda m: m[0])

ans = (monsters[0][1] + a - 1)//a
areas = [(monsters[0][0] + 2*d, ans*a)]
sum_ = ans*a
area_cursol = 0
for i in range(1, len(monsters)):
    m = monsters[i]
    x = m[0]
    h = m[1]


    while area_cursol < len(areas) and x > areas[area_cursol][0]:
        sum_ -= areas[area_cursol][1]
        area_cursol += 1

    if sum_ < h:
        # ボムつかう
        nokori = h-sum_
        kaisuu = (nokori+a-1)//a
        sum_ += kaisuu*a
        areas.append((x+2*d, kaisuu*a))
        ans += kaisuu

print(ans)

Measured memory_bytes: 121424
#include<stdio.h>
#define N 500
static const int INFTY = (1<<21);
int main(){
  int t,i,j,f,l,q,sum,minv;
  int A[N][N],d[N],h[N],w[N];
  scanf("%d",&t);
  for(i=0;i<t;i++){
    for(j=0;j<t;j++){
      scanf("%d", &q);
      A[i][j] = (q==-1)?INFTY:q; }
  }
  for(i=0; i<t; i++){
    d[i]=INFTY;
    h[i]=-1;
    w[i]=0;
  }
  d[0]=0;
  while(1){
    minv=INFTY;
    f=-1;
    for(i=0; i<t; i++){
      if(minv>d[i] && !w[i]){
	f=i;
	minv=d[i];
      }
    }
    if(f==-1)
      break;
    w[f]=1;
    for(l=0;l<t;l++){
      if(!w[l]&&A[f][l] != INFTY ){
	if(d[l]>A[f][l]){
	  d[l]= A[f][l];
	  h[l]=f;
	}
      }
    }
  }
  sum=0;
  for(i=0;i<t;i++){
    if(h[i]!=-1){
      sum += A[i][h[i]];
    }
  }

  printf("%d\n",sum);

  return 0;
}



Measured memory_bytes: 2112
#include <iostream>
#include <vector>
#include <algorithm>
#include <bitset>
#include <math.h>
#include <iomanip>
#include <map>
#include <queue>
#include <tuple>
#include <math.h>
#include <iomanip>

using namespace std;

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


int main(){
    int N;
    cin >> N;
    
    for(int i=1; i<=N; i++){
        if(N%i!=0) continue;
        int a=N/i;
        if(i<=9 && a<=9){
            cout << "Yes" << endl;
            return 0;
        }
    }
    cout << "No" << endl;

    return 0;
}

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

using namespace std;

int main(){
  
  int a, b;
  cin >> a >> b;
  
  cin.ignore();
  
  int plus = a + b;
  int max = plus; 
  int mult = a * b;
  if(max < mult){
    max = mult;
  }
  int minus = a - b;
  if(max < minus){
    max = minus;
  }

  cout << max << endl;
  return 0;
}
  


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

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int [] A = new int [N];
		
		for (int i=0; i<N; i++){
			A[i]=sc.nextInt();
		}
		Arrays.sort(A);
		
		int left = N/2;
		
		System.out.println(A[left]-A[left-1]);
		sc.close();

	}

}


Measured memory_bytes: 52560
#include <iostream>
#include <string>
#include <algorithm>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cmath>
#include <time.h>
#include <stdio.h>
#include <vector>
#define int long long
#define end getchar();getchar();return 0
int inf = 1000000000;
using namespace std;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
int mypow(int x, int y) {
	if (y == 0)return 1;
	if (y % 2)return mypow(x, y - 1)*x;
	else return mypow(x, y / 2)*mypow(x, y / 2);
}
int Max(int x, int y) {
	if (x > y)return x;
	else return y;
}
int Min(int x, int y) {
	if (x < y)return x;
	else return y;
}
int kai(int x) {
	int cnt=1;
	if (x == 0)return 1;
	cnt = kai(x - 1);
	return x * cnt;
}
int prime(int n) {
	for (int i = 2; i*i <= n; i++) {
		if (n%i == 0)return false;
	}
	return n != 1;
}
void prime_factor(int n){
	int cnt = 1;
	map<int, int>res;
	int m = n;
	for (int i = 2; i<= n; i++) {
		if(prime(i)){
			while (m%i == 0) {
				++res[i];
				m /= i;
			}
		}
	}
	cout << n <<":"<< endl;
	for (int i = 2; i<= n; i++) {
		if (res[i]) {
			cout << i << " " << res[i] << endl;
		}
	}
	cout << endl;
}
/*Library End!*/
int x, y, ans;
signed main() {
	cin >> x >> y;
	int i = x;
	while (1) {
		if (i > y) {
			cout << ans << endl;
			end;
		}
		i *= 2;
		ans++;
	}
}

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

typedef long long int ll; 
#define MOD 1000000007
#define ON 200000
#define rep(i,n) fp(i,0,n)  
#define fp(i,a,b) for(ll i=(a);i<(b);++i)
#define fn(i,a,b) for(ll i=(a);i>(b);i--)
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define FF first
#define SS second
typedef pair<ll, ll> pll; 
typedef vector<pll> vpll;
typedef vector<ll> vll;
#define rs(t) string t;cin>>t
#define ri(t) int t;cin>>t
#define rll(t) long long int t;cin>>t
#define MK make_pair
#define PB push_back
#define PO pop_back
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
///// This part below is only for debug, not used /////
template<typename T> ostream &operator<<(ostream &os, const vector<T> &vec){ os << "["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const deque<T> &vec){ os << "deq["; for (auto v : vec) os << v << ","; os << "]"; return os; }
template<typename T> ostream &operator<<(ostream &os, const set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_set<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T> ostream &operator<<(ostream &os, const unordered_multiset<T> &vec){ os << "{"; for (auto v : vec) os << v << ","; os << "}"; return os; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &pa){ os << "(" << pa.first << "," << pa.second << ")"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
template<typename TK, typename TV> ostream &operator<<(ostream &os, const unordered_map<TK, TV> &mp){ os << "{"; for (auto v : mp) os << v.first << "=>" << v.second << ","; os << "}"; return os; }
#define dbg(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ") " << __FILE__ << endl;
///// END /////

int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);
  rll(n);
  rll(k);
  vll v(n);
  cin >> v;
  ll ans = 0;
  rep(i,n){
  	if(v[i]>=k)
  		ans++;
  }
  cout << ans << endl;
  return 0;
  
}

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

int main(){
    int n, a[210], b[210] = {0};
    cin >> n;
    for(int i = 0; i < n; i++){
        cin >> a[i];
        while(a[i] % 2 == 0){
            a[i] /= 2;
            b[i]++;
        }
    }
    sort(b, b + n);
    cout << b[0] << endl;


    
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define sz(a) (a).size() 
#define all(c) (c).begin(),(c).end()
#define rep(i,n) for(int i=0;i<n;i++)
#define forn(i,n) for(int i=1;i<=n;i++)
#define ford(i,n) for(int i=n;i>=0;i--) 
#define REP(i,a,n) for(int i=a;i<n;i++)
#define foreach(itr,c) for(__typeof((c).begin(),(c).end())itr=c.begin();itr!=c.end();itr++) 
#define fill(a,b) memset(a,b,sizeof(a))
#define re return
#define INF 1e9
#define LINF 1e18
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef vector<int> vi;
typedef vector<pi > vpi; 
int main(){
	ll a,b,c,d;
	cin>>a>>b>>c>>d;
	cout<<max(a*c,max(a*d,max(b*c,b*d)));
	re 0;
}

Measured memory_bytes: 3636
#include <iostream>
long long n,a,b,ans;
using namespace std;
int main(void){
    cin>>n;
    for(int i=0;i<n;i++)ans+=(i+1)*(n-i);
    //cout<<ans<<endl;
    for(int i=0;i<n-1;i++){
        cin>>a>>b;
        if(a>b)swap(a,b);
        ans-=a*(n-b+1);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3640
#include<iostream>
#include<algorithm>
using namespace std;
typedef long long ll;
const int N=200010;
ll a[N],b[N];
int n,m;
ll k;
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);cout.tie(0);
    int res=0;
    cin>>n>>m>>k;
    for(int i=1;i<=n;i++) 
    {
        cin>>a[i];
        a[i]+=a[i-1];
    }
    for(int i=1;i<=m;i++)
    {
        cin>>b[i];
        b[i]+=b[i-1];
    }
    for(int i=0,j=m;i<=n;i++)//这里i一定要从0开始循环要不然会漏掉不在a数组中选数的情况
    {
        while(j&&a[i]>k-b[j]) j--;
        if(a[i]<=k-b[j]) res=max(res,i+j); 
    }
    cout<<res<<endl;
    return 0;
}


Measured memory_bytes: 6280
import java.util.*;

public class Main{
  public static void main(String args[]){
    Scanner sc=new Scanner(System.in);
    String data=sc.next();
	String last=data.substring(data.length()-1,data.length());
    if(last.matches("s")){
	  System.out.println(data+"es");
    }else{
      System.out.println(data+"s");
    }
  }
}

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

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

#include <complex>

#include <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define debug(x) cerr << #x << " = " << (x) << endl;


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

ll power(int k,int n,int M){
  if(n==0) return 1;
  if(n==1) return (ll)k;
  
  ll ret = power(k,n/2,M);
  
  ret=(ret*ret)%M;
  
  if(n%2==1) ret=(ret*k)%M;
  
  return ret;
}

ll power_memo[4010];

ll C(ll d, int m){
  ll res = 1;

  for(int i=0;i<m;i++){
    res = (res * ((d-i)%mod))%mod;
    res = (res * power_memo[i+1])%mod;
  }

  return res;
}

void solve(int n, ll d, int x){
  ll dp[4010] = {};
  ll res[2010] = {};
  
  dp[0] = 1;

  for(int i=0;i<n;i++){
    ll add[4010] = {};
    
    for(int j=0;j<n;j++){
      add[j+x] = -dp[j];
    }

    for(int j=n;j>0;j--){
      dp[j] = (mod + dp[j-1] + add[j])%mod;
    }
    dp[0] = 0;
      
    for(int j=0;j<n;j++){
      dp[j+1] = (dp[j+1] + dp[j])%mod;
    }

    res[i+1] = dp[n]%mod;
    dp[n] = 0;
  }

  ll ans = 0;
  
  for(int i=1;i<=min(d,(ll)n);i++){
    ans = (ans + res[i] * C(d, i) % mod)%mod;
  }

  printf("%lld\n",ans);
}

int main(){

  int n,x;
  ll d;

  for(int i=0;i<2010;i++){
    power_memo[i] = power(i, mod-2, mod);
  }
  
  while(1){
    scanf("%d%lld%d",&n,&d,&x);

    if(n == 0) break;

    solve(n,d,x);
  }
  
  return 0;
}

Measured memory_bytes: 3192
#include <iostream>
#include <string>

using namespace std;

int main() {

    string n;
    cin >> n;

    uint64_t sum = 0;
    for(int i = 0; i < n.length(); i++) sum += n[i] - '0';

    if(sum % 9) cout << "No" << endl;
    else cout << "Yes" << endl;

    return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
int main() {
  double ans,x;
  int N;
  string u;
  cin >> N;
  for(int i=0 ; i<N ; i++){
    cin >> x >> u;
    if(u=="JPY")
      ans+=x;
    else
      ans+=x*380000.0;
  }
  cout << ans << endl;
}


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

int main() {
  int n,q;
  string s;
  cin >> n >> s >> q;
  set<int> alpha[26];
  for(int i=0;i<n;i++)alpha[(int)(s[i]-'a')].insert(i);
  for(int i=0;i<q;i++){
      int t;
      cin >> t;
      if(t==1){
        int I;
        char c;
        cin >> I >> c;
        I--;
        if(s[I]!=c){
            alpha[(int)(s[I]-'a')].erase(I);
            alpha[(int)(c-'a')].insert(I);
            s[I]=c;
        }
      }
      else{
        int l,r;
        cin >> l >> r;
        l--; r--;
        int ans=0;
        for(int j=0;j<26;j++){
            auto u = alpha[j].lower_bound(l);
            if(u!=alpha[j].end() && *u<=r)ans++;
        }
        cout << ans << endl;
      }
  }
}

Measured memory_bytes: 27232