akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

#define INF 210000000
#define int long long

signed main() {
		int n;
		cin >> n;
		vector<vector<int>> a;
		for(int i=0;i<n;i++){
				int A,B;
				cin >> A >> B;
				vector<int> tmp;
				tmp.push_back(A);
				tmp.push_back(B);
				a.push_back(tmp);
		}
		float ans = 0;
		for(int i=0;i<n;i++){
				for(int j=1;j<n;j++){
						if (j > i){
								int x = abs(a[i][0] - a[j][0]);
								int y = abs(a[i][1] - a[j][1]);
								ans += pow(x * x + y * y,0.5);
						}
				}
		}
		printf("%.10f",ans / n * 2);
}


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

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

    int n;
    cin >> n;
    vector<int> a(n + 2, 0);
    REP(i, n) cin >> a[i + 1];

    int sum = 0;
    REP(i, n + 1) sum += abs(a[i] - a[i + 1]);

    for (int i = 1; i < n + 1; i++) {
        int l = min(a[i - 1], a[i + 1]);
        int r = max(a[i - 1], a[i + 1]);
        if (a[i] >= l && a[i] <= r) cout << sum << '\n';
        else if (a[i] < l) cout << sum - (l - a[i]) * 2 << '\n';
        else if (a[i] > r) cout << sum - (a[i] - r) * 2 << '\n';
    }
    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define rrep(i, n) for (int i = 1; i < (n + 1); ++i)
const double PI = 3.141592653589793238463;
using namespace std;
using ll = long long;
const ll INF = 1LL << 50;
typedef pair<int, int> P;
const int mod = 1e9 + 7;

struct mint
{
    ll x;
    mint(ll x = 0) : x((x % mod + mod) % mod) {}
    mint &operator+=(const mint a)
    {
        (x += a.x) %= mod;
        return *this;
    }
    mint &operator-=(const mint a)
    {
        (x -= mod - a.x) %= mod;
        return *this;
    }
    mint &operator*=(const mint a)
    {
        (x *= a.x) %= mod;
        return *this;
    }
    mint operator+(const mint a) const
    {
        mint res(*this);
        return res += a;
    }
    mint operator-(const mint a) const
    {
        mint res(*this);
        return res -= a;
    }
    mint operator*(const mint a) const
    {
        mint res(*this);
        return res *= a;
    }
    mint pow(ll t) const
    {
        if (!t)
            return 1;
        mint a = pow(t >> 1);
        a *= a;
        if (t % 1)
            a *= *this;
        return a;
    }

    // for prime mod
    mint inv() const
    {
        return pow(mod - 2);
    }
    mint &operator/=(const mint a)
    {
        return (*this) *= a.inv();
    }
    mint operator/(const mint a) const
    {
        mint res(*this);
        return res /= a;
    }
};

struct combination
{
    vector<mint> fact, ifact;
    combination(int n) : fact(n + 1), ifact(n + 1)
    {
        fact[0] = 1;
        for (int i = 1; i < n; ++i)
            fact[i] = fact[i - 1] * i;
        ifact[n] = fact[n].inv();
        for (int i = n; i >= 1; --i)
            ifact[i - 1] = ifact[i] * i;
    }
    mint operator()(int n, int k)
    {
        if (k < 0 || k > n)
            return 0;
        return fact[n] * ifact[k] + ifact[n - k];
    }
};

ll gcd(ll x, ll y)
{
    if (y == 0)
        return x;
    return gcd(y, x % y);
}

ll gcd(vector<ll> a)
{
    ll ans = 0;
    for (ll i = 0; i < a.size(); ++i)
    {
        ans = gcd(ans, a[i]);
    }
    return ans;
}

ll ppow(int v ,int n){
    ll rel =1;
    rep(i,n){
        rel*=v;
        rel%=mod;
    }
    return rel;
}

const int MAX_V = 2 * 1e5 + 500;
int X[MAX_V];
int Y[MAX_V];
// int mm(int i, int j){
//     int rel = max(X[i] - X[j] + Y[i]-Y[j], -(X[i] - X[j] + Y[i]-Y[j]));
//     rel = max(rel,X[i]-X[j]+Y[j]-Y[i]);
//     rel = max(rel,-(X[i]-X[j]+Y[j]-Y[i]));
//     return rel;
// }

int main(){
    int n;
    cin >> n;
    rep(i,n){
        int x,y;cin >> x >> y;
        X[i]=x;Y[i]=y;
    }
    ll a,b,c,d;
    ll e,f,g,h;
    a=c=e=g=-1e9;
    b=d = 1e9;
    f=h = 1e9;
    rep(i,n){
        if(X[i]+Y[i]>a)a = X[i]+Y[i];
        if(X[i]+Y[i]<b)b = X[i]+Y[i];
        if(X[i]-Y[i]>c)c = X[i]-Y[i];
        if(X[i]-Y[i]<d)d = X[i]-Y[i];
        
        if(-X[i]+Y[i]>e)e = -X[i]+Y[i];
        if(-X[i]+Y[i]<f)f = -X[i]+Y[i];
        if(-X[i]-Y[i]>g)g = -X[i]-Y[i];
        if(-X[i]-Y[i]<h)h = -X[i]-Y[i];
    }
    ll rel = -1e1;
    
    rel = max(a-b,c-d);
    rel = max(rel,e-f);
    rel = max(rel,g-h);
    cout << rel <<endl;

}

Measured memory_bytes: 5136
#include <iostream>
#include <vector>
#include <algorithm>
#include <ctype.h>
#include <math.h>
using namespace std;

int main(){
    int n;
    cin>>n;
    vector<int> v(n);
    vector<int> c(n);
    for(int i=0;i<n;i++){
        cin>>v.at(i);
    }
    for(int i=0;i<n;i++){
        cin>>c.at(i);
    }
    int sum=0;
    for(int i=0;i<n;i++){
        if(v.at(i)>c.at(i)){
            sum+=v.at(i)-c.at(i);
        }
    }
    cout<<sum<<endl;
}


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

int  main(){
    ll h, n;
    cin >> h >> n;
    int a;
    rep(i,n){
        cin >> a;
        h-=a;
    } 
    if(h>0) cout << "No" << endl;
    else cout << "Yes" << endl;
    return 0;
}

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

int main()
{
	int a, b;
	cin >> a >> b;
	int sum = a * b;
	
	if (sum % 2 == 0)
	{
		cout << "Even" << endl;
	}
	else
	{
		cout << "Odd" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
import sys
from collections import Counter
def input(): return sys.stdin.readline().rstrip()

def main():
    N = int(input())
    A = tuple(map(int, input().split()))
    c = Counter(A)

    data = [0] * (N+1)
    sum_count = 0
    for i, v in c.items():
        if v < 2:
            continue
        value = v * (v - 1) // 2
        data[i] = value - value * (v - 2) // v
        sum_count += value

    print('\n'.join([str(sum_count - data[a]) for a in A]))

if __name__ == '__main__':
    main()


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

#define all(x) x.begin(),x.end()
#define pb push_back
#define ss second
#define ff first
#define int long long int

int32_t main(){
	int n, ans=0;
	cin>>n;
	map<vector<int> , int > my;
	map<vector<int> , int > :: iterator itr;
	for(int i=0;i<n;i++){
		string s; cin>>s;
		vector<int > arr(26,0);
		for(int i=0;i<s.size();i++)	arr[s[i]-'a']++;
		my[arr]++;
	}
	for(itr=my.begin();itr!=my.end();itr++)
	ans += ((itr->ss)*(itr->ss-1))/2;
	cout<<ans<<endl;	 
}

Measured memory_bytes: 29952
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vl=vector<ll>;
using vvl=vector<vl>;
using vs=vector<string>;
using vb=vector<bool>;
using pll=pair<ll,ll>;
using vpll=vector<pll>;
const ll oo=0x3f3f3f3f3f3f3f3fLL;
const double eps = 1e-9;
#define sz(c) ll((c).size())
#define all(c) begin(c),end(c)
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define xx first
#define yy second
#define FOR(i,a,b) for(ll i=(a); i<(b); i++)
#define FORD(i,a,b) for(ll i=ll(b)-1;i>=(a);i--)
#define TR(X) ({if(1) cerr << "TR: " << (#X) << " = " << (X) << endl; })

ll MOD = 1000000007;

int main(){
	cin.sync_with_stdio(0);

	ll N;
	cin >> N;
	vl a(N);
	for(ll &l : a) cin >> l;

	ll sum = 0;
	ll res = 0;
	FORD(i, 1, N) {
		sum += a[i];
		sum %= MOD;

		ll add = sum * a[i-1];
		add %= MOD;

		res += add;
		res %= MOD;
	}

	cout << res << endl;
}


Measured memory_bytes: 4820
#include<iostream>
#include<set>
#include<map>
using namespace std;

typedef pair<int,int> P;

string id = "ENWS";

int dir(char a){
  for(int i=0;i<4;i++)if(a==id[i])return i;
  return -1;
}

int main(){
  int h,w;
  string grid[30];
  bool use[30][30];
  int dx[] = {1,0,-1,0},dy[] = {0,-1,0,1};

  while(cin >> w >> h && (w||h)){
    for(int i=0;i<h;i++)cin >> grid[i];

    int ans = 0;
    while(ans<=180){
      set<P> s;
      int num = 0;
      for(int i=0;i<h;i++){
	for(int j=0;j<w;j++){
	  int d = dir(grid[i][j]);
	  if(0<=d){
	    num++;
	    for(int k=-1;k<3;k++){
	      int dd = (d+k+4)%4;
	      int sy = i+dy[dd], sx = j+dx[dd];
	      if(sy<0 || sx<0 || h<=sy || w<=sx)continue;
	      if(grid[sy][sx] == '.' || grid[sy][sx] == 'X'){
		grid[i][j] = id[dd];
		s.insert(P(sy,sx));
		break;
	      }
	    }
	  }
	}
      }
      if(!num)break;

      for(int i=0;i<h;i++)
	for(int j=0;j<w;j++)use[i][j] = false;

      set<P>::iterator ite;
      for(ite=s.begin();ite!=s.end();ite++){
	int i=(*ite).first,j=(*ite).second;
	if(!use[i][j] && (grid[i][j] == '.' || grid[i][j] == 'X')){
	  for(int k=0;k<4;k++){
	    int sy = i+dy[k], sx = j+dx[k];
	    if(sy<0 || sx<0 || h<=sy || w<=sx || use[sy][sx])continue;
	    int d = dir(grid[sy][sx]);
	    if(d<0)continue;
	    int dd = (k+2)%4;
	    if(d==dd){
	      grid[sy][sx] = '.';
	      if(grid[i][j]!='X')grid[i][j] = id[d];
	      use[sy][sx] = true;
	      break;
	    }
	  }
	}
	use[i][j] = true;
      }
      ans++;
    }
    if(ans>180)cout << "NA\n";
    else cout << ans << endl;
  }
}

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

using namespace std;

typedef unsigned long long u64;

int main(){
  int n,m;
  vector<pair<u64,u64> > a;

  cin >> n >> m;
  for(int i=0; i<n; i++){
    u64 p,q;
    cin >> p >> q;
    a.push_back(pair<u64,u64>(p,q));
  }

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

  int i = 0;
  u64 r = 0;
  while (m > 0) {
    u64 c = a[i].second;
    if (m > c) {
      m -= c;
      r += c*a[i].first;
    } else {
      r +=  m*a[i].first;
      m = 0;
    }
    i++;
  }

  cout << r << endl;

  return 0;
}


Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
int main(){
    int cnt = 0;
    string s1,s2;
    cin >> s1 >> s2;
    while (s1 != s2) {
        string now = s1.substr(0,s1.size()-1);
        now = s1[s1.size()-1] + now;
        s1 = now;
        cnt++;
        if (cnt == s1.size()) break;
    }
    if (cnt < s1.size()) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}


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

int main() {
    int N;
    cin >> N;
    vector<int> H(N);
    for (int i=0; i<N; i++){
        cin >> H[i];
    }
    if (N==1){
        cout << "Yes";
    return 0;
    }
    for (int j=N-2; j>=0; j--){
        if (H[j] > H[j+1]){
            if ((H[j] - H[j+1]) == 1){
                H[j] --;
            }else{
                cout << "No";
                return 0;
            }
        }
    }
    cout << "Yes";
    return 0;
}


Measured memory_bytes: 640
#include <stdio.h>
#include <math.h>

int square(int x) {
    return x * x;
}

int main() {
    int n, town[9][2];
    scanf("%d", &n);
    for (int i = 0; i < n; i++) {
        scanf("%d %d", &town[i][0], &town[i][1]);
    }
    double ans = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            ans += sqrt( square(town[i][0] - town[j][0]) + square(town[i][1] - town[j][1]) );
        }
    }
    ans = ans * 2 / n;
    printf("%.16f", ans);
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
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; }

const ll mod = 1e9+7;


void chmod(ll &M){
    if(M >= mod) M %= mod;
    else if(M < 0){
        M += (abs(M)/mod + 1)*mod;
        M %= mod;
    }
}

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);

    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

int getl(int i, int N) { return i==0? N-1:i-1; };
int getr(int i, int N) { return i==N-1? 0:i+1; };

// 線分 ab の偏角 返り値は[-π, π]
template<typename T>
T argument(const pair<T, T> &a, const pair<T, T> &b){
    double ax=a.first, ay=a.second, bx=b.first, by=b.second;
    return atan2(by-ay, bx-ax);
}

/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */
/* <-----------------------------------------------------------------------------------> */

/* 注意 

    1LL<<60 * N とかのオーバーフローに気を付けろ
    制約がヒントになる、ちゃんと全ての制約を見ろ

*/

int const MAX = 2000000;
long long fac[MAX], finv[MAX], inv[MAX];
void COMinit(){
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for(int i = 2; i < MAX; i++){
        fac[i] = fac[i-1] * i % mod;
        inv[i] = mod - inv[mod%i] * (mod/i) % mod;
        finv[i] = finv[i-1] * inv[i] % mod;
    }
}
long long COM(int n, int k){
    if(n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n-k] % mod) % mod;
}

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

    int n, k; std::cin >> n >> k;
    if (k<n) { std::cout << 0 << std::endl; return 0; }
    
    ll ans = 1;
    rep(i, n) { ans *= (k-i); chmod(ans); }
    std::cout << ans << std::endl;
    
    return 0;
}


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

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


#define print(x) for(auto it : x) cout<< it << ' '; cout << '\n';
typedef long long ll;
typedef unsigned long long ull;

const int MOD = 1e9 + 7;
ll mod(ll a) { return (ll) (a % MOD + MOD) % MOD; }
ll mul(ll a, ll b) { return (ll) mod(mod(a) * mod(b));}

int main() {
    ios::sync_with_stdio(false); cin.tie(0);
    int n; cin >> n;
    vector<ll> dp = {0, 0, 0};
    while (n--) {
        ll a, b, c; cin >> a >> b >> c;
        vector<ll> old = dp;
        dp[0] = a + max(old[1], old[2]);
        dp[1] = b + max(old[2], old[0]);
        dp[2] = c + max(old[0], old[1]);
    }
    cout << max(dp[0], max(dp[1], dp[2])) << '\n';
    return 0;
}


Measured memory_bytes: 3608
#include<stdio.h>
int main()
{
    int i=0,a,b;
    char arr[60];

    scanf("%d%d",&a,&b);
    getchar();
    for(i=0;i<a;i++){
        scanf("%c",&arr[i]);
    }
    arr[b-1]=(arr[b-1]-'A')+'a';
    for(i=0;i<a;i++){
        printf("%c",arr[i]);
    }
    printf("\n");

    return 0;
}



Measured memory_bytes: 1656
n = int(input())
ps = list(map(int, input().split()))
c = 0
for i in range(1,n-1):
  if ps[i-1] < ps[i] < ps[i+1]:
    c += 1
  elif ps[i-1] > ps[i] > ps[i+1]:
    c += 1
print(c)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
int tree[2000020] ;
int ar[500003],idx[6000009],ans[500009] ;
struct str{
    int a,b,c ;
}qry[500002];
bool comp(str s1 , str s2)
{
    if(s1.b!=s2.b) return s1.b<s2.b ;
    return s1.a<s2.a ;
}
void update(int p , int lo , int hi , int pos , int val)
{
    if(lo==hi)
    {
        tree[p]=val ; return ;
    }
    int md=(lo+hi)/2 ;
    if(pos<=md) update(p*2,lo,md,pos,val) ;
    else update(p*2+1,md+1,hi,pos,val) ;
    tree[p]=tree[p*2]+tree[p*2+1] ;
}
int query(int p , int lo , int hi , int l , int r)
{
    if(l<=lo && hi<=r) return tree[p] ;
    if(hi<l || r<lo) return 0 ;
   // cout<<lo<<" "<<hi<<" "<<l<<" k "<<r<<endl ;
    int md=(lo+hi)/2 ;
    int x=query(p*2,lo,md,l,r),y=query(p*2+1,md+1,hi,l,r) ;
    return x+y ;
}
int main()
{
    int n,q ; scanf("%d%d",&n,&q) ;
    for(int i = 1 ; i <= n ; i++) scanf("%d",&ar[i]) ;
    for(int i = 0 ; i < q ; i++)
    {
        int a,b,c ; cin>>a>>b ; c=i ;
        qry[i].a=a ; qry[i].b=b ; qry[i].c=c ;
    }
    sort(qry,qry+q,comp) ;
    //for(int i = 0 ; i < q ; i++) cout<<qry[i].a<<" "<<qry[i].b<<" "<<qry[i].c<<endl ; cout<<endl ;
    int ps=1 ;
    for(int i = 0 ; i < q ; i++)
    {
        while(ps<=qry[i].b)
        {
            int x=ar[ps] ;
            if(idx[x]) update(1,1,n,idx[x],0) ;
            update(1,1,n,ps,1) ;
            idx[x]=ps ;
            ps++ ;
        }
        //cout<<"i : "<<i<<endl ;
        //for(int j = 1 ; j <= 16 ; j++) cout<<tree[j]<<" " ; cout<<endl ;
        ans[qry[i].c]=query(1,1,n,qry[i].a,qry[i].b) ; //cout<<endl ;
    }
    for(int i = 0 ; i < q ; i++) cout<<ans[i]<<endl ;
}


Measured memory_bytes: 19492
n = int(input())
a = list(map(int, input().split()))
leaf = sum(a) - 1
now = 1
ans = 0
for i, num in enumerate(a):
    ans += now
    now -= num
    if leaf >= now:
        leaf -= now
        now *= 2
    elif leaf > 0:
        now += leaf
        leaf = 0
    if now < 0:
        print(-1)
        exit()
print(ans)


Measured memory_bytes: 20020
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rrep(i, n) for (int i = 1; i < (int)(n+1); i++)
int main() {
   int N,A,B;
   cin>>N>>A>>B;
   int ans=0;
   rrep(i,N){
       bool a=true;
       int cnt=0;
       int j=i;
       while(a==true){
           if(j==0){
               a=false;
           }
           else{
               cnt+=j%10;
               j-=j%10;
               j/=10;
           }
       }
       if(A<=cnt&&cnt<=B){
           ans+=i;
       }
   
   }
   cout<<ans<<endl;
}


Measured memory_bytes: 3636
#include <algorithm>
#include <cstdio>
#include <iostream>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <stdlib.h>
#include <stdio.h>
#include <bitset>
#include <cstring>
#include <deque>
using namespace std;
#define FOR(I,A,B) for(int I = (A); I < (B); ++I)
#define CLR(mat) memset(mat, 0, sizeof(mat))
typedef long long ll;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> v;
  int d[N]; FOR(i,0,N) cin >> d[i];
  int cnt = 1;
  FOR(i,0,N-1) {
    if(d[i] != d[i+1]) cnt++;
    else {
      v.push_back(cnt);
      cnt = 1;
    }
  }
  v.push_back(cnt);
  if(v.size() == 1) cout << v[0] << endl;
  else if(v.size() == 2) cout << v[0] + v[1] << endl;
  else {
    int ans = 0;
    FOR(i,0,v.size()-2) ans = max(ans, v[i]+v[i+1]+v[i+2]);
    cout << ans << endl;
  }
  return 0;
}

Measured memory_bytes: 3624
#include <bits/stdc++.h>
#define FOR(i, m, n) for (int i = m; i < (n); i++)
#define RFOR(i, m, n) for (int i = (m - 1); i >= 0; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, n, 0)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
using namespace std;
typedef long long ll;
const int mod = 1e9 + 7;

ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }

ll factorial(ll n) {
  ll answer = 1;
  while (n > 1) {
    answer *= n;
    answer %= mod;
    n--;
  }
  return answer;
}

ll combination(ll n, ll r) {
  return factorial(n) / (factorial(r) * factorial(n - r));
}

ll permutation(ll n, ll r) { return factorial(n) / factorial(n - r); }

int main() {
  vector<int> price(3);
  REP(i, 3) { cin >> price[i]; }
  sort(ALL(price));
  cout << price[0] + price[1] << endl;
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<iostream>
#include<stdio.h>
// #include <ext/pb_ds/assoc_container.hpp> // Common file
// #include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
//using namespace __gnu_pbds;
using namespace std;

#define ordered_set tree<ll , null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update>
#define ll  long long
#define mod 1000000007
#define ve vector
#define pi pair<int,int>
#define pb push_back
#define F first
#define S second
#define mxe(v) *max_element(v.begin(),v.end())
#define mne(v) *min_element(v.begin(),v.end())
#define all(v) v.begin(),v.end()
#define FAST ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);

const int inf=1e9+5;
vector<ll>A,B;


ll power(ll a,ll b,ll c)
{
	ll res=1;
	while(b)
	{
		if(b&1LL)
			res=(res*a)%c;
		a=(a*a)%c;
		b/=2;
	}
	return res;
}

void path(ll a,int state)
{
 for(ll i=2;i*i<=a;i++)
 {
  if(a%i==0)
  {
    if(state==0)A.push_back(a/i);
     else B.push_back(a/i);
      path(a/i,state);
      return ;
  }
 }
}

void solve()
{ 
   int n;
    cin>>n;
    vector<int>a(n);
    int cnt=0;
    for(int &x:a)cin>>x;
    sort(a.begin(),a.end());
    for(int i=0;i<n-2;i++)
    {
     for(int j=i+1;j<n-1;j++)
     {
      for(int k=j+1;k<n;k++)
      {
          if(a[i]!=a[j]&&a[i]!=a[k]&&a[j]!=a[k])
          {
           if(a[i]+a[j]>a[k]) cnt++; 
          }
      }
     }
    }
    cout<<cnt<<endl;
}

signed main()
{
//#ifndef ONLINE_JUDGE
    //  freopen("input.txt","r",stdin);
    //  freopen("output.txt","w",stdout);
//#endif
    FAST;
   
    
     int t=1;
    //cin>>t;
     while(t--)
    	solve();
    return 0;
}



Measured memory_bytes: 3660
//
// Created on 2020/09/09.
//


#include <iostream> // cout, endl, cin
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
#include <math.h>
#include <ios>
#include <iomanip>
#include <numeric>

#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
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; }
typedef long long ll;
using namespace std;
const long long LINF =1e18;
const int INF = 1e9;

struct UnionFind {
    vector<int>d;//リンクの情報,子の場合は親の番号、親の場合は連結成分のsize*(-1)
    UnionFind(int n=0):d(n,-1){} //structの初期化。デフォルトのnを0に設定してdを-1(すなわち全ての成分は親であり、サイズは1にする
    int find(int x) {//根を探す
        if(d[x] < 0) return x;
        else  return d[x] = find(d[x]);//根じゃなかったら根を探しに行ってメモ化する。
    }
    bool unite(int x,int y) {//成分を連結する
        x = find(x);
        y = find(y);
        if (x == y) return false;//すでに同じ連結成分
        if(d[x] < d[y]) swap(x,y);//大きいのに小さいのをつける。x←y
        //x.size > y.size
        d[x] += d[y];//xのサイズをふやす
        d[y] = x;//yの根をxにする
        return true;
    }
    bool same(int x,int y) {return find(x)==find(y);}
    int size(int x) {return -d[find(x)];}

};

int main() {
    int n;
    cin>>n;
    int m;
    cin>>m;
    UnionFind friends(n);
    for (int i = 0; i < m; ++i) {
        int a,b;
        cin>>a>>b;
        friends.unite(a,b);
    }

    int ans = 0;
    for (int i = 0; i < n; ++i) {
        chmax(ans,friends.size(i));
    }

    cout<<ans<<endl;

    return 0;
}


Measured memory_bytes: 10204
#include <stdio.h>
#define SIZE 10000

int main() {
  int x[SIZE], y[SIZE], i, j;

  i = -1;
  while (i++ <= SIZE) {
    scanf("%d %d", &x[i], &y[i]);
    if (x[i] == 0 && y[i] == 0)
      break;
  }
  for (j = 0; j < i; j++)
    if (x[j] < y[j])
      printf("%d %d\n", x[j], y[j]);
    else
      printf("%d %d\n", y[j], x[j]);

  return 0;
}

Measured memory_bytes: 624
use std::io::{stdin, Read};
  
fn main() {
    let mut args = String::new();
    stdin().read_line(&mut args);
    let args: Vec<i32> = args.trim().split_whitespace().filter_map(|it|it.parse().ok()).collect();
    let mut zero = String::new();
    for i in 0..args[0] {
        zero += "00";
    }
    println!("{}{}", if args[1] == 100 { 101 } else { args[1] }, zero);
}


Measured memory_bytes: 4352
#include <string>
#include <iostream>
#include <vector>
#include <stack>
#include <math.h>
#include <iomanip>
#include <queue>
#include <map>
#include <list>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
#define WHITE 0
#define GRAY 1
#define BLACK 2
#define MAX 1400
#define LARGENUM 1000000007
#define INF 9223372036854775807
#define ull unsigned long long 
typedef pair <ull, int> P;

int M[MAX][MAX], Vertical[MAX][MAX], Horizontal[MAX][MAX];

int main(){
    int N, H, a, b, count = 0;
    ull total = 0;
    list <int> A, B;
    cin >> N >> H;
    rep(i, N){
        cin >> a >> b;
        A.push_back(a);
        B.push_back(b);
    }
    A.sort();
    auto it = A.end();
    it --;
    a = *it;
    B.sort();
    B.reverse();
    while (total < H){
        if (B.empty() || a >= *B.begin()){
            count += (H - total) / a;
            if ((H - total) % a != 0) count++;
            break;
        }
        else {
            total += *B.begin();
            B.pop_front();
            count++;
        }
    }
    cout << count << endl;
    return 0;
}


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

int main() {
  int N;
  cin >> N;
  vector<int> lightnext(N);
  for (int i=0 ; i<N ; i++){
    cin >> lightnext.at(i);
    lightnext.at(i) --;
  }
  int lightpoint = 0;
  int count = 0;
  vector<int> lightcheck(N,0);
  while(true){
    lightpoint = lightnext.at(lightpoint);
    lightcheck.at(lightpoint) ++;
    count ++;
    if (lightcheck.at(lightpoint) == 2){
      cout << -1 << endl;
      break;
    }
    if(lightcheck.at(1) == 1){
      cout << count << endl;
      break;
    }
  }
}


Measured memory_bytes: 1024
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author ParsaAlizadeh
 */

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

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

#define all(x)          x.begin(), x.end()
#define kill(x)         return cout << x << endl, 0;
#define X               first
#define Y               second
#define sep             ' '
#define endl            '\n'
#define file_io         freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);

ll pw(ll a, ll b, ll mod) {
    if (!b)    return 1;
    if (b & 1) return a * pw(a * a % mod, b / 2, mod) % mod;
    return pw(a * a % mod, b / 2, mod) % mod;
}

const ll MAXN  = 1e5 + 10;
const ll INF   = 8e18;
const ll MOD   = 1e9 + 7; // 998244353;

ll n, m, ans;
vector<ll> adj[MAXN];
bitset<MAXN> mark;

void DFS(ll u) {
    mark[u] = true;
    for (ll v : adj[u]) {
        if (mark[v]) continue;
        DFS(v);
    }
}

int main() {
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);
    cin >> n >> m;
    for (ll i = 0; i < m; i++) {
        ll u, v, w;
        cin >> u >> v >> w;
        adj[u].push_back(v);
        adj[v].push_back(u);
    }
    for (ll i = 1; i <= n; i++) {
        if (mark[i]) continue;
        DFS(i);
        ans++;
    }
    cout << ans << endl;

    return 0;
}



Measured memory_bytes: 8832
<?php
fscanf(STDIN, "%d%d%d", $N, $M, $K);
# ブロックがN個
# 色はM種類選べる
# 隣り合うブロックの色が同じ組がK個以下
# 隣り合うブロックの色が同じ組がi個の場合
# 最初のブロックの色は　M種類から選べる
# 色が変わる回数は N-i-1回、2回め以降の色の選択肢は M-1 種類となる
# 色が変わる場所は N-1 箇所から K箇所を選べばよい
define("MOD", 998244353);
prepareMod(2*10**5);
$count = 0;
for($i = 0; $i <= $K; $i++){
    $c = mulm(mulm($M, powerm($M-1, $N-$i-1)) , nCm($N-1, $i));
    $count = addm($count, $c);
}
echo $count;

//掛け算
function mulm($a, $b){
    return ($a * $b) % MOD;
}
//足し算
function addm($a, $b){
    return ($a + $b) % MOD;
}
//累乗
function powerm($a, $b){
    if($b == 0)return 1;
    if($b & 1)return (powerm($a, $b>>1)**2 % MOD) * $a % MOD;
    return powerm($a, $b>>1)**2 % MOD;
}

function prepareMod($n){
    global $f, $invf;
    $f[0] = $invf[0] = $invf[1] = 1;
    for($i = 1; $i <= $n; $i++)$f[$i] = $f[$i-1]*$i%MOD;
    for($i = 2; $i <= $n; $i++)$invf[$i] = (MOD - intdiv(MOD, $i))*$invf[MOD%$i]%MOD;
    for($i = 2; $i <= $n; $i++)$invf[$i] = $invf[$i]*$invf[$i-1]%MOD;
}
function nCm($n, $m){
    global $f, $invf;
    if($n < 0 || $n - $m < 0)return 0;
    return $f[$n] * $invf[$n-$m] % MOD * $invf[$m] % MOD;
}

function o(...$val){
    if(count($val)==1)$val=array_shift($val);
    echo debug_backtrace()[0]['line'].")";
    if(is_array($val)){
        if(count($val) == 0)echo "empty array";
        elseif(!is_array(current($val)))echo "array: ",implode(" ", addIndex($val)),"\n";
        else{
            echo "array:array\n";
            if(isCleanArray($val))foreach($val as $row)echo implode(" ", addIndex($row)),"\n";
            else foreach($val as $i => $row)echo "[".$i."] ".implode(" ", addIndex($row)),"\n";
        }
    }else echo $val."\n";
}
function addIndex($val){if(!isCleanArray($val)){$val = array_map(function($k, $v){return $k.":".$v;}, array_keys($val), $val);}return $val;}
function isCleanArray($array){$clean=true;$i = 0;foreach($array as $k=>$v){if($k != $i++)$clean = false;}return $clean;}

Measured memory_bytes: 34124
#include <stdio.h>

#define maxn 555

char p[maxn][maxn];
char r[maxn][maxn];
char b[maxn][maxn];

int main( void ) {
	int n, m;
	scanf("%i %i", &n, &m);
	
	for( int i = 0; i < n; i++ ) {
		scanf("%s", p[i]);
	}
	
	for( int i = 0; i < n; i++ ) {
		for( int j = 0; j < m; j++ ) {
			r[i][j] = b[i][j] = '.';
		}
	}
	
	for( int i = 0; i < n; i++ ) {
		r[i][0] = '#';
	}
	
	for( int i = 0; i < n; i++ ) {
		if( i % 2 == 0 ) {
			for( int j = 0; j < m-1; j++ ) {
				r[i][j] = '#';
			}
		}
		
		for( int j = 0; j < m; j++ ) {
			if( p[i][j] == '#' ) {
				r[i][j] = '#';
			}
		}
	}
	
	for( int i = 0; i < n; i++ ) {
		b[i][m-1] = '#';
	}
	
	for( int i = 0; i < n; i++ ) {
		if( i % 2 ) {
			for( int j = 1; j < m; j++ ) {
				b[i][j] = '#';
			}
		}
		
		for( int j = 0; j < m; j++ ) {
			if( p[i][j] == '#' ) {
				b[i][j] = '#';
			}
		}
	}
	
	for( int i = 0; i < n; i++ ) {
		puts(r[i]);
	}
	
	puts("");
	
	for( int i = 0; i < n; i++ ) {
		puts(b[i]);
	}
	
	return 0;
}

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

int main()
{
	int n, c = 0;
	int a[1000], b[1000];
	bool f[1000];

	cin >> n;

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

	memcpy(b, a, sizeof(a));
	sort(b, b + n);
	memset(f, 0, sizeof(f));

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

	for (int i = 0; i < n; i++) {
		if (f[i] == 0){
			int s = 0;
			while (a[i] != b[i]) {
				int j = i, k = i;
				while (f[j] == 1 || a[j] != b[i])
					j++;
				while (f[k] == 1 || a[k] != b[j])
					k++;
				swap(a[j], a[k]);
				c += a[j] + a[k];
				f[j] = 1;
				s++;
			}
			if ((s - 2) * b[i] > (s + 2) * b[0])
				c -= (s - 2) * b[i] - (s + 2) * b[0];
			f[i] = 1;
		}
	}

	cout << c << endl;

	return 0;
}


Measured memory_bytes: 3168
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main{
	public static void main(String[] args) throws IOException{
		String input;
		int [][] a = new int[26][2];
		for(int i = 0; i < 26;i++){
			a[i][0] = 97+i;
		}
		char [] c2;
    	BufferedReader br = new BufferedReader(new InputStreamReader(System.in));

    	while((input = br.readLine()) != null){
    		input = input.toLowerCase();
    		c2 = input.toCharArray();
    		for(int i = 0;i < c2.length;i++ ){
    			for(int j = 0; j< 26;j++){
    				if(c2[i] == a[j][0]) a[j][1]++;
    			}
    		}
    	}
    	br.close();

    	for(int i = 0; i < 26; i++){
    		System.out.println((char)a[i][0] +" : "+a[i][1]);
    	}
    }
}

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

using namespace std;

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

    int n, k;
    cin >> n >> k;
    const int MAX = ((n - 1) * (n - 2)) / 2;
    if (k > MAX) {
        cout << "-1\n";
        return 0;
    }
    vector<pair<int, int> > edges;
    for (int i = 1; i < n; i++) {
        edges.push_back({0, i});
    }

    int curr_val = MAX,
        curr_u = 1, curr_v = 2;
    while (curr_val > k) {
        curr_val--;
        edges.push_back({curr_u, curr_v});
        curr_v++;
        if (curr_v >= n) {
            curr_u++;
            curr_v = curr_u + 1;
        }
    }
    cout << edges.size() << '\n';
    for (auto p : edges) {
        cout << p.first + 1 << ' ' << p.second + 1 << '\n';
    }
}

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

#define INF 2e+9
#define MAX_N 100000

int dp[MAX_N];
int n;
vector<int> a;

void solve() {
    fill(dp, dp+n, INF);
    for (int i=0; i<n; ++i) {
        *lower_bound(dp, dp+n, a[i]) = a[i];
    }
    cout << lower_bound(dp, dp+n, INF) - dp << endl;
}

int main() {
    cin >> n;
    a.resize(n);
    for(int i=0; i<n; ++i) cin >> a[i];
    solve();
    return 0;
}


Measured memory_bytes: 3628
#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 <functional>
#include <cassert>

typedef long long ll;
using namespace std;

#define mod 1000000007 //1e9+7
#define INF 1000000000 //1e9
#define LLINF 2000000000000000000LL //2e18
#define SIZE 100


void calc(int n,int m,int p){
  int x[SIZE],c=0;

  for(int i=0;i<n;i++){
    scanf("%d",x+i);
    c += x[i] * (100-p);
  }  

  if(x[m-1]==0)
    puts("0");
  else
    printf("%d\n",c/x[m-1]);
  
  return;
}

int main(){
  int n,m,p;
  
  while(1){
    scanf("%d%d%d",&n,&m,&p);

    if(n==0) break;
    
    calc(n,m,p);
  }

  return 0;
}

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

int main() {
  string S;
  cin >> S;
  vector<int> P(2);
  for(auto& i: P) cin >> i;

  vector<int> d = {0, 0};
  for(auto i: S) {
    if(i=='T') d.emplace_back(0);
    else       ++d.back();
  }

  auto ok = true;
  for(auto k: {0, 1}) {
    unordered_set<int> dp;
    dp.emplace(d[k]);
    for(auto i=k+2; i<d.size(); i+=2) {
      unordered_set<int> nex;
      for(auto j: dp) {
        nex.emplace(j-d[i]);
        nex.emplace(j+d[i]);
      }
      dp = nex;
    }
    ok &= dp.count(P[1-k]);
  }
  cout << (ok?"Yes":"No") << endl;
}


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

int main(){
  int N;
  cin >> N;
  string A[N];
  for(int i=0;i<N;i++){
    cin >> A[i];
  }
  bool ans = true;
  for(int i=1;i<N;i++){
    int s = A[i-1].size();
    if(A[i-1][s-1] != A[i][0]){
      ans = false;
      break;
    }
    for(int j=0;j<i;j++){
      if(A[i] == A[j]){
        ans = false;
        break;
      }
    }
  }
  cout << (ans ? "Yes" : "No") << endl;
}
  

Measured memory_bytes: 384
k = int(input())

flag = 0
count = len(str(k))

if k % 2 == 0:
  print(-1)
  exit()
  
if str(k)[-1] == '5':
  print(-1)
  exit()

count = len(str(k))
test = int('7' * count)
amari = test % k
while True:
  if amari == 0:
    break
  else:
    amari = (amari * 10 + 7) % k
    count += 1
  
print(count)

Measured memory_bytes: 9080
#include<bits/stdc++.h>
using namespace std;
#define ll long long 
// memo  fixed  setprecision(20);
using vvll = vector<vector<ll>>;
ll mod =1e9+7;
/*"itob" int to "N"base */           template<typename TypeInt> string itob(const TypeInt v, int base){static const char table[] = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ";string ret;static numeric_limits<TypeInt> t;TypeInt n = v;if (t.is_signed) {if (v < 0) n *= -1;}while (n >= base) {ret += table[n%base];n /= base;}ret += table[n];if (t.is_signed) {if (v < 0 && base == 10) ret += '-';}reverse(ret.begin(), ret.end());return ret;}
/*"chmin" a = MAX*/                  template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
/*"chmax" a = MIN*/                  template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
/*"ctoi"  char to int*/              int ctoi(char c) {return c-'0';}
/*"gcd"   MAX Euclidean */           ll gcd(ll a,ll b){if(b==0)return a; return gcd(b,a%b);}
    /*"lcm"   MIN*/                      ll lcm(ll a,ll b){ll g = gcd(a,b);return a/g*b;}
/*"primecheck"If prime,return true.*/bool primecheck(ll n){if(n < 2) return false;else{for(int i = 2; i * i <= n; i++){if(n % i == 0) return false;}return true;}}
string  reverserange(string s,ll a,ll b){reverse(s.begin()+a-1,s.begin()+b); return s;}
ll modpow(ll a,ll n, ll mod){ll res = 1;while(n>0){if (n%2==1){res = res * a % mod;}a = a * a % mod;n/=2;}return res;}
int main() {
    int d,t,s;
    cin >> d >> t >>s;
    ll che = t*s;
    if(che>=d){
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
}
    



Measured memory_bytes: 3596
//Nihal Mittal - nihal_47
//Strike First , Strike Hard , No Mercy !!

/**⠀⠀⠀⠀⠀⠀⣀⣤⣤⣄⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⣠⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⣀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⣰⣿⣿⣿⣿⠿⠿⣿⣿⣿⣿⣿⣿⣿⣧⢀⠀⠀⠀⠀
⠀⠀⠀⣿⣿⣿⠋⠀⠀⠀⠀⠀⠙⠀⠙⣿⣿⣿⣷⢳⢀⠀⠀⠀
⠀⠀⣠⣿⣿⣿⢸⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⢀
⠀⠀⣸⣿⣿⣿⠸⠀⠀⠀⠒⠒⠒⠐⠀⠀⢿⣿⣿⣿⣿⣿⠀⠀
⠀⣴⣿⣿⣿⡿⠀⠒⣋⣙⡒⢰⠀⠤⣖⠒⢾⣿⣿⣿⣿⣧⠀⠀
⢺⣿⣿⣿⣿⢀⠀⠀⠉⠉⠉⠸⠀⡇⠉⠉⠀⢿⣿⣿⣿⣄⠀⠀
⠀⠙⣿⣿⣧⢻⠀⠀⠀⠀⠀⠠⠀⠰⠀⠀⠀⣸⠸⣿⣿⠿⠰⠀
⠀⠀⠀⠹⣿⣿⣿⣷⠀⡠⠙⣲⣔⣅⢡⣰⣷⣿⣿⣿⣧⠀⠀⠀
⠀⠀⠀⣼⣿⣿⣿⣿⠀⡿⠭⠭⠭⠭⢿⠀⣿⢻⣿⣿⠃⠀⠀⠀
⠀⠀⠀⠙⠛⣿⢻⠹⣿⠐⠙⠛⠟⠉⢀⣴⡟⢿⣿⡏⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⡟⠀⠀⠻⣦⣤⣶⠾⠋⠀⠀⠁⡦⢄⢀⠀⠀⠀
⠀⠀⠀⠀⡠⠁⡇⠑⢄⠀⠀⠀⠀⠀⠀⠔⠀⠀⠁⠀⠀⠀⠉⠁
⠀⠔⠊⠁⠀⠀⣇⠀⠀⠀⠑⡤⠤⢎⠁⠀⠀⡘⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⢢⠠⠀⡠⢆⠀⠀⡠⠙⢄⠀⡸⠀
**/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long
#define ld long double
#define mk make_pair
#define pb push_back
#define in insert
#define se second
#define fi first
#define inf 1e18 + 10
#define mod 1000000007
#define watch(x) cout << (#x) << " is " << (x) << "\n"
#define all(v) (v).begin(),(v).end()
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(0);
#define pii pair<ll,ll>
#define vi(x) vector<x>
#define maxn 100005
#define ordered_set tree<ll, null_type,less<ll>, rb_tree_tag,tree_order_statistics_node_update> 
using namespace std;
using namespace __gnu_pbds;

signed main()
{
    fast;
  
    ll n,w,i,j,ans=0,sum=0;
    cin>>n>>w;
    ll arr[n+2][2];
    for(i=1;i<=n;i++) cin>>arr[i][0]>>arr[i][1],sum += arr[i][1];
    ll dp[n+2][sum+2];
    for(i=0;i<=n;i++)
    {
    	for(j=0;j<=sum;j++) dp[i][j] = inf;
    }

    dp[0][0] = 0;
    for(i=1;i<=n;i++) dp[i][0] = 0;
    for(i=1;i<=n;i++)
    {
    	for(j=1;j<=sum;j++)
    	{
    		if(arr[i][1] <= j) dp[i][j] = min(dp[i-1][j] , dp[i-1][j - arr[i][1]] + arr[i][0]);
    		else dp[i][j] = dp[i-1][j];
    	}
    }
    for(i=1;i<=sum;i++)
    {
    	if(dp[n][i] <= w) ans = i;
    }
    cout<<ans;

}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i < (n);i++)
#define ALL(obj) (obj).begin(),(obj).end()
using namespace std;

const long long INF = 1LL << 60;
const int MOD = (int)1e9 + 7;
typedef long long ll;
//約数列挙
vector<long long> divisor(long long n) {
    vector<long long> ret;
    for (long long i = 1; i * i <= n; i++) {
        if (n % i == 0) {
            ret.push_back(i);
            if (i * i != n) ret.push_back(n / i);
        }
    }
    //sort(ret.begin(), ret.end()); // 昇順に並べる
    return ret;
}
vector<int> dx={1,0,-1,0};vector<int> dy={0,-1,0,1};
int n;
vector<int> weight;
vector<vector<int>> dp;
int rec(int l,int r){
    if(dp[l][r]!=-1)return dp[l][r];
    if(abs(l-r)<=1)return 0;
    int res = 0;
    if(abs(weight[l] - weight[r-1])<=1 && rec(l+1,r-1) == r - l - 2){
        res = r-l;
    }
    for(int mid=l+1;mid<=r-1;mid++){
        res = max(res, rec(l,mid) + rec(mid,r));
    }
    return dp[l][r] = res;
}
signed main () {
    scanf("%d",&n);
    while(n!=0){
        weight.assign(n,-1);
        REP(i,n){
            int tmp;scanf("%d",&tmp);
            weight[i]= tmp;
        }
        dp.assign(n+1,vector<int>(n+1,-1));
        rec(0,n);
        printf("%d\n",dp[0][n]);
        scanf("%d",&n);
    }
}


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

using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vb = vector<bool>;
using pii = pair<int, int>;
using vii = vector<pii>;
using vs = vector<string>;
#define all(x) x.begin(), x.end()
// int di[] = {0, 1, 0, -1};
// int dj[] = {1, 0, -1, 0};
const ll MOD = 1e9 + 7;
const ll INF = 1e9;
#define x first
#define y second


int main(int argc, char **argv) {
	ios::sync_with_stdio(false), cin.tie(nullptr);
#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif

	string s, t; cin >> s >> t;
	int ans = s.length();
	for (int i = 0; i < s.length() - t.length() + 1; ++i) {
		int cur = 0;
		for (int j = 0; j < t.length(); ++j) {
			cur += s[i + j] != t[j];
		}
		ans = min(ans, cur);
	}
	cout << ans << endl;
}


Measured memory_bytes: 3656
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define pi 3.1415926
int arr[200005];
int main(){
	int n;
	cin>>n;
	for(int i=1;i<n;i++){
		int a;
		cin>>a;
		arr[a]++;
	}
	for(int i=1;i<=n;i++){
		cout<<arr[i]<<endl;
	}
}

Measured memory_bytes: 4372
use std::collections::VecDeque;

fn readline() -> String {
    let mut line = String::new();
    std::io::stdin().read_line(&mut line).unwrap();
    line.trim().to_string()
}

fn main() {
    let (n, m) = {
        let token = readline()
            .split(' ')
            .filter_map(|x| x.parse::<usize>().ok())
            .collect::<Vec<usize>>();
        (token[0], token[1])
    };

    let a = (0..n)
        .map(|_| readline().chars().collect::<Vec<char>>())
        .collect::<Vec<_>>();

    let mut queue: VecDeque<(usize, usize)> = VecDeque::new();
    let mut dist: Vec<Vec<i32>> = vec![vec![1000005; m]; n];

    for i in 0..n {
        for j in 0..m {
            if a[i][j] == '#' {
                dist[i][j] = 0;
                queue.push_back((i, j));
            }
        }
    }

    while let Some((i, j)) = queue.pop_front() {
        for (ni, nj) in [(!0usize, 0usize), (1, 0), (0, !0), (0, 1)]
            .iter()
            .map(|&(di, dj)| (i.wrapping_add(di), j.wrapping_add(dj)))
            .filter(|&(ni, nj)| ni < n && nj < m)
        {
            if dist[i][j] + 1 < dist[ni][nj] {
                dist[ni][nj] = dist[i][j] + 1;
                queue.push_back((ni, nj));
            }
        }
    }

    if let Some(ans) = dist.iter().filter_map(|x| x.iter().max()).max() {
        println!("{}", ans);
    }
}


Measured memory_bytes: 27896
using System;
using System.Collections;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.Numerics;

namespace AtCoderWorkspace
{
    public class Solver
    {
        public void Solve()
        {
            var cin = new Scanner();
            
            var s = cin.next();
            var t = cin.next();







            Console.WriteLine(t + s);
        }
    }

    class Scanner
    {
        string[] s;
        int i;

        char[] cs = new char[] { ' ' };

        public Scanner()
        {
            s = new string[0];
            i = 0;
        }

        public string next()
        {
            if (i < s.Length) return s[i++];
            string st = Console.ReadLine();
            while (st == "") st = Console.ReadLine();
            s = st.Split(cs, StringSplitOptions.RemoveEmptyEntries);
            if (s.Length == 0) return next();
            i = 0;
            return s[i++];
        }

        public int nextInt()
        {
            return int.Parse(next());
        }
        public int[] ArrayInt(int N, int add = 0)
        {
            int[] Array = new int[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt() + add;
            }
            return Array;
        }

        public int[] DPArrayInt(int N, int ex)
        {
            int[] Array = new int[N+ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextInt();
            }
            return Array;
        }

        public long nextLong()
        {
            return long.Parse(next());
        }

        public long[] ArrayLong(int N, long add = 0)
        {
            long[] Array = new long[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong() + add;
            }
            return Array;
        }

        public long[] DPArrayLong(int N, int ex)
        {
            long[] Array = new long[N + ex];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextLong();
            }
            return Array;
        }

        public double nextDouble()
        {
            return double.Parse(next());
        }


        public double[] ArrayDouble(int N, double add = 0)
        {
            double[] Array = new double[N];
            for (int i = 0; i < N; i++)
            {
                Array[i] = nextDouble() + add;
            }
            return Array;
        }
    }   

    class Program
    {
        static void Main(string[] s) => new Solver().Solve();
    }
}


Measured memory_bytes: 13140
road = []

for i in range(3):
  a,b = map(int, input().split(" "))
  road.append(a)
  road.append(b)

flag = 0

for j in range(4):
  if road.count(j + 1) >= 3 or road.count(j + 1) == 0:
    flag = 1

if flag == 0:
  print("YES")
else:
  print("NO")



Measured memory_bytes: 2940
#include <iostream>
#include <string>
#include <algorithm>
#include <cassert>
#include <limits>
#include <numeric>
#include <type_traits>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <functional>
#include <utility>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <complex>
#include <climits>
#include <queue>

using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef pair<ll, ll> P;
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)

const double PI = 3.1415926535897932;
/******define variable start******/
ll a, b, k;
/*******define variable end*******/
ll solve(){
    cin >> a >> b >> k;
    if(a < k){
        cout << 0 << " " << max((ll)0, b-k+a) << endl;
    }else{
        cout << max(a-k,(ll)0) << " " << b << endl;
    }
    return 0;
}
int main(){
    //clock_t start = clock();
    cout << std::fixed << std::setprecision(10);
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    ll end_solve = solve();
    /*
    clock_t end = clock();
    const double time = static_cast<double>(end - start) / CLOCKS_PER_SEC * 1000.0;
    printf("time %lf[ms]\n", time);
    */
    return (int)end_solve;
}


Measured memory_bytes: 256