akhauriyash/Code-Regression huggingface dataset:
/**
 *    Creator :  bizarre
 *    Date : 5/2020
 *    Problem Number : 504
**/
#include <bits/stdc++.h>
using namespace std;
#define bizarre  ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define file freopen("input.txt","r",stdin); freopen("output.txt","w",stdout);
#define ll long long
#define ld long double
/*
vector<int> prime_Numbers;
int primes[1000005];
void prime(int n)
{
    primes[1]=primes[0]=0;
    for(int i=2; i<=n; i++)
        primes[i]=true;
    for(int i=2; i<=n; i++)
    {
        if(primes[i]==true)
        {
            prime_Numbers.push_back(i);
            for(int j=i+i; j<=n; j+=i)
                primes[j]=false;
        }
    }
    for(int i=2; i<=n; i++)
        primes[i]+=primes[i-1];
}
void move1step(long long& a, long long& b, long long q)
{
    long long c= a-q*b;
    a=b;
    b=c;
}
long long egcd(long long r0,long long r1,long long& x0,long long& y0)
{
    long long x1=0,y1=1;
    x0=1;
    y0=0;
    while(r1)
    {
        long long q=r0/r1;
        move1step(r0,r1,q);
        move1step(x0,x1,q);
        move1step(y0,y1,q);
    }
    return r0;
}
bool  solve (long long a, long long b, long long c,long long&x, long long& y)
{
    long long g=egcd(a,b,x,y);
    int m=c/g;
    x*=m;
    y*=m;
    return c%g==0;
}
int gcd(int a, int b)
{
    if(b==0)
        return a;
    return gcd(b,a%b);
}
void PrimeFactorization(int n)
{
    for(int i=2; i*i<=n; i++)
    {
        int c=0;
        if(n%i==0)
        {
            while(n%i==0)
            {
                n/=i;
            }

        }
    }

}
long long ncrtane(long long n, long long r)
{
    long long ans=1,cntr=1;
    for(int i=n; i>n-r; i--)
    {
        ans*=i;
        ans/=cntr;
        cntr++;
    }
    return ans;
}
*/
const int N = 1e6 + 5, inf = 2e9, mod = 1e9 + 7;
long long fact[N], inv[N];
long long fp(long long base, long long exp)
{
    if (exp == 0)
        return 1;
    long long ans = fp(base, exp / 2);
    ans = (ans * ans) % mod;
    if (exp % 2 != 0)
        ans = (ans * (base % mod)) % mod;
    return ans;
}

void pre(long long n)
{
    fact[0] = 1;
    inv[0] = 1;
    for (long long i = 1; i <= n; i++)
    {
        fact[i] = (i * fact[i - 1]) % mod;
        inv[i] = fp(fact[i], mod - 2);
    }
}
int ncr(long long n, long long r)
{
    return (((fact[n] * inv[n - r]) % mod) * inv[r]) % mod;
}

int npr(long long n, long long r)
{
    return (fact[n] * inv[n - r]) % mod;
}

int main()
{
    bizarre
    pre(2200);
   ll n,k;
   cin>>n>>k;
   for(int i=1;i<=k;i++)
   {
       if(n-k+1>=i)
       {
        ll res=(ncr(n-k+1,i)%mod);
       res*=ncr(k-1,i-1)%mod;
        res%=mod;
         cout << res << endl;
       }
       else
        cout << 0 << endl;
   }

return 0;
}


Measured memory_bytes: 2304
a, b = map(int,input().split())
s = input()
if len(s) == a+b+1 and s.count('-') == 1:
  pass
else:
  print("No")
  exit(0)

s1,s2 = s.split('-')
if a == len(s1) and b == len(s2):
  print("Yes")
else:
  print("No")


Measured memory_bytes: 3060
#include<stdio.h>

int main(void)
{
  //所持金を入力
  int x;
  scanf("%d",&x);

  //um(嬉しさメーター)を初期化
  int um = 0;

  //500円硬貨で得られるum
  um += x/500*1000;

  //残りの所持金
  x %= 500;

  //5円硬貨で得られるum
  um += x/5*5;

  //umを出力,return 0で終了
  printf("%d\n",um);

  return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <algorithm>
#include <math.h>
#include <set>
#include <string>
#include <vector>
#include <array>
#include <stdlib.h>

#define INT_MAX 2000000000
#define MOD 1000000007
#define ll long long
#define rep(i,a,b) for(i = (a); i < (b); i++)
#define bitget(a,b) (((a) >> (b)) & 1)

using namespace std;

int i, j, k;

int main() {
	int n;
	int a[100000];
	cin >> n;
	rep(i, 0, n)
		cin >> a[i];
	unsigned int b[40000000] = {};
	int ans = 0;
	rep(i, 0, n) {
		if (bitget(b[a[i] / 32], a[i] % 32) == 0) {
			b[a[i] / 32] = b[a[i] / 32] + (1 << (a[i]) % 32);
			ans++;
		}
		else {
			b[a[i] / 32] = b[a[i] / 32] - (1 << (a[i]) % 32);
			ans--;
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 156928
# -*- coding: utf-8 -*-


def main():
    from collections import deque

    h, w = map(int, input().split())
    s = [list(input()) for _ in range(h)]
    dist = [[float('inf') for _ in range(w)] for _ in range(h)]
    is_visited = [[False for _ in range(w)] for _ in range(h)]
    dxy = [(1, 0), (-1, 0), (0, 1), (0, -1)]
    white_count = 0

    for i in range(h):
        for j in range(w):
            if s[i][j] == '.':
                white_count += 1

    # スコアの最大化：全ての白マス－最短距離で(H, W)まで移動するのに必要なマスの数
    # BFS
    # Initialize
    d = deque()
    d.append(tuple((0, 0)))
    dist[0][0] = 1
    is_visited[0][0] = True

    while d:
        di = d.popleft()

        for dy, dx in dxy:
            nx = dx + di[1]
            ny = dy + di[0]

            if (nx < 0 or w <= nx or ny < 0 or h <= ny):
                continue
            elif s[ny][nx] == '#':
                continue
            elif is_visited[ny][nx]:
                continue
            else:
                dist[ny][nx] = dist[di[0]][di[1]] + 1
                is_visited[ny][nx] = True
                d.append((ny, nx))

    if dist[h - 1][w - 1] == float('inf'):
        print(-1)
    else:
        print(white_count - dist[h - 1][w - 1])


if __name__ == '__main__':
    main()


Measured memory_bytes: 3436
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define leadinz zero str.erase(0, min(str.find_first_not_of('0'), str.size()-1));
using namespace __gnu_pbds;
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef tree<ll, null_type, less<ll>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
string text="abcdefghijklmnopqrstuvwxyz";
const int maxn=1e6+7;
//        .--------------.
//        | Try First One|
//        '--------------'
//                |     .--------------.
//                |     |              |
//                V     V              |
//              .--------------.       |
//              |      AC.     |<---.  |
//              '--------------'    |  |
//              (True)|  |(False)   |  |
//           .--------'  |          |  |
//           |           V          |  |
//           |  .--------------.    |  |
//           |  |   Try Again  |----'  |
//           |  '--------------'       |
//           |                         |
//           |  .--------------.       |
//           '->| Try Next One |-------'
//              '--------------'
ll bin_pow(ll a,ll b,ll m)
{
    ll res=1;
    a%=m;
    while(b>0){
        if(b&1)res=res*a%m;
        b>>=1;
        a=a*a%m;
    }
    return res;
}
bool miller_rabin(ll d,ll n)
{
    ll a=2+rand()%(n-4);
    ll x=bin_pow(a,d,n);
    if(x==1 || x==n-1)return true;
    while(d!=n-1){
        x=(x*x)%n;
        d*=2;
        if(x==1)return false;
        if(x==n-1)return true;
    }
    return false;
}
bool prime(ll n,ll k)
{
    if(n==1 || n==4)return false;
    if(n<=3)return true;
    ll d=n-1;
    while(d%2==0)d/=2;
    for(int i=0;i<k;i++){
        if(!miller_rabin(d,n))return false;
    }
    return true;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s,t;
    cin>>s>>t;
    string k="";
    int n=s.size()+t.size();
    int id=0;
    for(int i=0;i<n;i++){
        if(i%2==0)k+=s[id++];
        else k+='#';
    }
    id=0;
    for(int i=0;i<n;i++){
        if(k[i]=='#')k[i]=t[id++];
        else continue;
    }
    cout<<k;
}


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

// 総数を1000000007で割った余り
const long long mod = 1e9 + 7;

using ll  = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define ull unsigned long long
#define ld long double
#define vi vector<int>
#define vll vector<ll>
#define vc vector<char>
#define vs vector<string>
#define vpii vector<pii>
#define vpll vector<pll>

#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; i++)
#define rep1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; i++)
#define repr(i, n) for (int i = ((int)(n)-1); i >= 0; i--)
#define rep1r(i, n) for (int i = ((int)(n)); i >= 1; i--)

#define sz(x) ((int)(x).size())
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()

#define SORT(v, n) sort(v, v + n);
// #define SORT(v, n) stable_sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define RSORT(x) sort(rall(x));
#define pb push_back
#define mp make_pair

#define INF (1e9)
#define PI (acos(-1))
#define EPS (1e-7)

ull gcd(ull a, ull b) { return b ? gcd(b, a % b) : a; }
ull lcm(ull a, ull b) { return a / gcd(a, b) * b; }

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0);
    // cout << fixed << setprecision(5);
    ll n;
    cin >> n;
    vector<ll> h(n + 10);
    h[n + 1] = INF;
    h[0]     = 0;
    rep1(i, n) { cin >> h[i]; }

    bool flg = false;
    for (int i = n; i >= 1; i--) {
        if (h[i - 1] - h[i] > 1) {
            cout << "No" << endl;
            return 0;
        }
        if (h[i - 1] - h[i] == 1) {
            h[i - 1]--;
        }
        flg = true;
    }

    if (flg) {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }

    return 0;
}


Measured memory_bytes: 1024
import sys


def _ia(): return map(int, sys.stdin.readline().strip().split())


def calc(arr, k):
    s = sum(arr)
    n = len(arr)
    kp = k % n if s > 0 else k
    if kp == 0:
        kp = n

    ll = min(kp, n)
    cm = max(arr)
    for i in range(n):
        cn = 0
        for ki in range(i, i+ll):
            cn += arr[ki % n]
            cm = max(cn, cm)

    if s > 0:
        return s * ((k-1)//n) + cm
    else:
        return cm


def main():
    n, k = _ia()
    p = list(map(lambda x: x-1, _ia()))
    c = list(_ia())

    f = [False] * n
    g = []
    for idx in range(n):
        if f[idx]:
            continue

        nxt = idx
        tmp = [c[nxt]]
        f[nxt] = True

        for _ in range(n):
            nxt = p[nxt]
            if nxt == idx:
                break
            tmp.append(c[nxt])
            f[nxt] = True

        g.append(tmp)

    return max(calc(gi, k) for gi in g)


if __name__ == "__main__":
    print(main())


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

using namespace std;


int main (){
	int N,l,r,sum;
  	cin >> N;
  	sum = 0;
    for(int i = 0; i < N; i++){
    	cin >> l >> r;
      	sum += (r - l + 1);
    }
	cout << sum << endl;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
  int n;
  scanf("%d", &n);
  int p[20];
  for(int i = 0; i < n; i++) {
    scanf("%d", &p[i]);
  }

  int num = 0;
  for(int i = 1; i < (n-1); i++) {
    if((p[i-1] < p[i] && p[i] < p[i+1])||
       (p[i+1] < p[i] && p[i] < p[i-1])) {
      num++;
    }
  }
  printf("%d\n", num);
  return 0;
}


Measured memory_bytes: 128
/*
uchiyan ni gallan
*/

#include<bits/stdc++.h>
#define mod 1000000007
#define pp pair<long long,long long>
#define ll long long
#define ff first
#define ss second
#define horse_power ios_base::sync_with_stdio(false); cin.tie(NULL);

using namespace std;
string s,t;
int x,y,n,m;
vector<int> g[100001],dis(100001,0);
void go1(vector<bool> &vis,int i,vector<int> &v){
     vis[i]=1;
     for(auto vv : g[i]){
        if(vis[vv])
            continue;
        go1(vis,vv,v);
     }
     v.push_back(i);
}
void go2(int i,vector<bool> &vis){
    vis[i]=1;
    if(g[i].size()==0){
        dis[i]=0;
        return;
    }
    for(auto v : g[i]){
        if(vis[i]){
            dis[i]=max(dis[i],1+dis[v]);
            continue;
        }
        go2(v,vis);
        dis[i]=max(dis[i],1+dis[v]);
    }

}
void solve(){
   cin>>n>>m;
   for(int i=1;i<=m;i++){
      cin>>x>>y;
      g[x].push_back(y);
   }
   vector<int> v;
   vector<bool> vis(n+1,0);
   for(int i=1;i<=n;i++){
       if(!vis[i])
     go1(vis,i,v);
   }
   fill(vis.begin(), vis.end(), false);
   for(auto k : v){
      if(!vis[k]){
        go2(k,vis);
      }
   }
   int ans=0;
   for(int i=1;i<=n;i++)
   ans=max(ans,dis[i]);
   cout<<ans<<"\n";
}

int main(){
horse_power
int t=1;
//cin>>t;
while(t--){
solve();
}


}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define VI         vector<int>
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);

class UnionFindTree{
  public:
    vector<int> rank,p;

    UnionFindTree() {}

    UnionFindTree(int size){
      rank.assign(size, 0);
      p.assign(size, 0);
      REP(i,size)makeSet(i);
    }

    void makeSet(int x){
      p[x] = x;
      rank[x] = 0;
    }

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

    void unite(int x, int y){
      if(findSet(x) == findSet(y))return;

      x = findSet(x);
      y = findSet(y);

      if(rank[x] > rank[y]){
        p[y] = x;
      }else{
        p[x] = y;
        if(rank[x] == rank[y]){
          rank[y]++;
        }
      }

    }

    int findSet(int x){
      if(x != p[x]){
        p[x] = findSet(p[x]);
      }
      return p[x];
    }

    void print(){
      REP(i,p.size()){
        cout << p[i] << " ";
      }
      cout << endl;
      REP(i,p.size()){
        cout << rank[i] << " ";
      }
      cout << endl;

    }

};

int p[100005];

int main(){
  int n,m;
  cin >> n >> m;
  REP(i,n){
    cin >> p[i+1];
  }

  UnionFindTree uft = UnionFindTree(n+1);
  REP(i,m){
    int x,y;
    cin >> x >> y;
    uft.unite(x,y);
  }

  int ans=0;
  FOR(i,1,n+1){
    if(uft.same(i,p[i]))ans++;
  }
  cout << ans << endl;
}



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

long long num753(long long lim, long long lead, int s, int f, int t) {
  if(lead>lim) return 0;
  
  return ((s*f*t) ? 1:0) +
    num753(lim, 10*lead+3, s, f, 1) +
    num753(lim, 10*lead+5, s, 1, t) +
    num753(lim, 10*lead+7, 1, f, t);
}


int main(int argc, char *argv[]) {
  long long a;
  scanf("%d",&a);

  long long num = num753(a,3,0,0,1)+num753(a,5,0,1,0)+num753(a,7,1,0,0);
  printf("%d\n",num);
  
  return 0;
}



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

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

#define MOD 1000000007LL
#define INF (1LL<<60)

/*

*/
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll N,K;
	while(cin>>N>>K) {
		if(K<=(N-1)*(N-2)/2) {
			vector<PII> es;
			RANGE(i, 1, N) es.PB(MP(0, i));
			ll idx=0;
			RANGE(i, 1, N) RANGE(j, i+1, N) {
				if(idx<(N-1)*(N-2)/2-K) {
					es.PB(MP(i, j));
				}
				idx++;
			}
			cout<<es.size()<<endl;
			REP(i, es.size()) {
				cout<<es[i].FI+1<<" "<<es[i].SE+1<<endl;
			}
		} else {
			cout<<-1<<endl;
		}
	}
	
	return 0;
}


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

int main() {
    int x, n;
    cin >> x >> n;
    vector<int> d(102);
    rep(i, n) {
        int p;
        cin >> p;
        d[p] = 1;
    }
    P ans(99999, -1);
    for(int i = 0; i <= 101; i++) {
        if(d[i] == 1) continue;
        int dif = abs(x-i);
        ans = min(ans, P(dif, i));
    }

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

Measured memory_bytes: 3604
#pragma GCC optimize ("Ofast")
#include<bits/stdc++.h>
using namespace std;
inline void rd(int &x){
  int k, m=0;
  x=0;
  for(;;){
    k = getchar_unlocked();
    if(k=='-'){
      m=1;
      break;
    }
    if('0'<=k&&k<='9'){
      x=k-'0';
      break;
    }
  }
  for(;;){
    k = getchar_unlocked();
    if(k<'0'||k>'9'){
      break;
    }
    x=x*10+k-'0';
  }
  if(m){
    x=-x;
  }
}
inline void wt_L(char a){
  putchar_unlocked(a);
}
inline void wt_L(const char c[]){
  int i=0;
  for(i=0;c[i]!='\0';i++){
    putchar_unlocked(c[i]);
  }
}
int N;
int H[100000];
int main(){
  int i;
  rd(N);
  {
    int Lj4PdHRW;
    for(Lj4PdHRW=0;Lj4PdHRW<(N);Lj4PdHRW++){
      rd(H[Lj4PdHRW]);
    }
  }
  for(i=N-2;i>=0;i--){
    if(H[i]>H[i+1]){
      H[i]--;
    }
  }
  for(i=(1);i<(N);i++){
    if(H[i-1]>H[i]){
      break;
    }
  }
  if(i==N){
    wt_L("Yes");
    wt_L('\n');
  }
  else{
    wt_L("No");
    wt_L('\n');
  }
  return 0;
}
// cLay varsion 20190822-2

// --- original code ---
// int N, H[1d5];
// {
//   int i;
//   rd(N,H(N));
//   for(i=N-2;i>=0;i--) if(H[i]>H[i+1]) H[i]--;
//   rep(i,1,N) if(H[i-1]>H[i]) break;
//   wt(if[i==N,"Yes","No"]);
// }


Measured memory_bytes: 640
import bisect


s = input()
t = input()

memo = {}
alph = "abcdefghijklmnopqrstuvwxyz"

for i, char in enumerate(alph):
    memo[char] = i

li = [[] for i in range(26)]
for i, char in enumerate(s):
    li[memo[char]].append(i)

ans = 0
now_here = -1
# for i, char in enumerate(t):
i = 0
while i < len(t):
    char = t[i]
    if not li[memo[char]]:
        print(-1)
        exit()
    if now_here < li[memo[char]][0]:
        now_here = li[memo[char]][0]
        i += 1
    elif now_here < li[memo[char]][-1]:
        now_here = li[memo[char]][bisect.bisect_right(li[memo[char]], now_here)]
        i += 1
    else:
        ans += 1
        now_here = -1
print(ans*len(s) + now_here + 1)        

Measured memory_bytes: 46448
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);

        int val1 = sc.nextInt();

        int count = 0;
        for (int i = 1; i <= val1; i++) {
            String temp = "" + i;
            if ((temp.length() % 2) != 0) {
                count++;
            }
        }
        System.out.println(count);
    }
}

Measured memory_bytes: 34516
#include <bits/stdc++.h>
#define ll long long int
#define F first
#define S second
const ll mod = 1e9 + 7;
const ll INF = 10000000000000;
#define pb push_back
#define fastio ios_base::sync_with_stdio(0); cin.tie(0);
using namespace std;
int main()
{
	fastio;
	ll a=0,b=0,c=0;
	cin>>a>>b>>c;
	ll s=c-a-b;
	if(s<0)
		cout<<"No";
	else
	{
		s*=s;
		if(s>4*a*b)
			cout<<"Yes";
		else
			cout<<"No";
	}
	
return 0;
}

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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define all(obj) (obj).begin(), (obj).end()
#define bit(n) (1LL << (n))

typedef long long ll;

using namespace std;

int n;  
int x[10], y[10];

double dist(int i, int j) {
  double dx = x[i] - x[j];
  double dy = y[i] - y[j];
  return pow(dx * dx + dy * dy, 0.5);
}
  
void solve() {
  cin>>n;
  for(int i=1; i<=n; i++) cin>>x[i]>>y[i];
  double sum=0;
  vector<int> v(n);
  rep(i, n) v[i] = i+1;
  do {
    rep(i,n-1) sum += dist(v[i], v[i+1]);
  } while(next_permutation(v.begin(), v.end()));
  int factorial = 1;
  for(int i=2; i<=n; i++) factorial*=i;
  cout<<fixed<<setprecision(7)<<sum/factorial;
}

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

Measured memory_bytes: 4228
package main

import "fmt"

func main() {
	var a, b, c, d int
	fmt.Scan(&a, &b, &c, &d)
	for {
		c -= b
		if c <= 0 {
			fmt.Print("Yes")
			break
		}
		a -= d
		if a <= 0 {
			fmt.Print("No")
			break
		}
	}
}


Measured memory_bytes: 1752
use std::io::Read;

fn main() {
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();

    let answer = solve(&buf);

    println!("{}", answer);
}

fn solve(input: &str) -> String {
    let mut iterator = input.split_whitespace();

    let mut vec: Vec<Vec<usize>> = Vec::new();
    for _i in 0..3 {
        let mut v = Vec::new();
        for _j in 0..3 {
            v.push(iterator.next().unwrap().parse().unwrap());
        }
        vec.push(v);
    }

    let n: usize = iterator.next().unwrap().parse().unwrap();
    for _i in 0..n {
        let b: usize = iterator.next().unwrap().parse().unwrap();
        for j in 0..3 {
            for k in 0..3 {
                if vec[j][k] == b {
                    vec[j][k] =0;
                }
            }
        }
    }

    return if (vec[0][0] == 0 && vec[0][1] == 0 && vec[0][2] == 0)
        || (vec[1][0] == 0 && vec[1][1] == 0 && vec[1][2] == 0)
        || (vec[2][0] == 0 && vec[2][1] == 0 && vec[2][2] == 0)
        || (vec[0][0] == 0 && vec[1][0] == 0 && vec[2][0] == 0)
        || (vec[0][1] == 0 && vec[1][1] == 0 && vec[2][1] == 0)
        || (vec[0][2] == 0 && vec[1][2] == 0 && vec[2][2] == 0)
        || (vec[0][0] == 0 && vec[1][1] == 0 && vec[2][2] == 0)
        || (vec[0][2] == 0 && vec[1][1] == 0 && vec[2][0] == 0) {
        "Yes".to_string()
    } else {
        "No".to_string()
    }
}


Measured memory_bytes: 4352
#include <stdio.h>

int main(void){
	char words[128];
	int i,j,zure,end;

	for(i=0;i < 128;i++) words[i] = '\0';

	while(scanf("%[^\n]",words) != EOF){// 文字列を配列に読み込む
		getchar();
		zure=0,end=0;
		for(j=0;words[j] != '\0';j++){
			for(i=1;i <= 26;i++){// 1つずつずらしていく
				if((j > 0 && words[j-1] == ' ' || j == 0) && (words[j]+i-26 == 't' || words[j]+i == 't') && (words[j+1]+i-26 == 'h' || words[j+1]+i == 'h')){//1文字目t、2文字目h
						if((words[j+2]+i-26 == 'e' || words[j+2]+i == 'e')){// the
								zure = i;
								end = 1;
								break;
						}else if((words[j+2]+i-26 == 'a' || words[j+2]+i == 'a') && (words[j+3]+i-26 == 't' || words[j+3]+i == 't')){// that
								zure = i;
								end = 1;
								break;
						}else if((words[j+2]+i-26 == 'i' || words[j+2]+i == 'i') && (words[j+3]+i-26 == 's' || words[j+3]+i == 's')){// this
								zure = i;
								end = 1;
								break;
						}
				}
			}
			if(end == 1) break;
		}

		for(i=0;words[i] != '\0';i++){
			if(words[i] >= 'a' && words[i] <= 'z'){
				if(words[i]+zure > 'z'){
					printf("%c",words[i]+zure-26);
				}else{
					printf("%c",words[i]+zure);
				}
			}else{
				printf("%c",words[i]);
			}
		}
		puts("");
		for(i=0;i < 128;i++) words[i] = '\0';
	}
	return 0;
}

Measured memory_bytes: 524
import java.util.Arrays;
import java.util.Scanner;
public class Main {
    public static void main(String[] args) {
    	Scanner scanner = new Scanner(System.in);
    	int seisu = scanner.nextInt();
    	int a[] = new int [seisu];
    	long sum = 0;
    	for(int i = 0;i < seisu;i++){
    		a[i] = scanner.nextInt();
    		sum = sum + a[i];
    	}
    	Arrays.sort(a);
    	System.out.print(a[0]+ " " + a[a.length - 1] + " " +sum);
    	System.out.println();
	}
}


Measured memory_bytes: 41632
# AOJ 0099 Surf Smelt Fishing Contest II
# Python3 2018.6.22 bal4u

import heapq
SFT = 20	# 2**20 = 1048576 > MAX(1000000)
Q = []
n, q = list(map(int, input().split()))
tbl = [0]*(n+1)
for i in range(q):
	id, v = list(map(int, input().split()))
	tbl[id] += v
	f = tbl[id]
	heapq.heappush(Q, ((-f << SFT)|id, id, f))
	while 1:
		f, id, v = Q[0]       # 要素の確認のみ
		if tbl[id] == v:
			print(id, v)
			break
		heapq.heappop(Q)


Measured memory_bytes: 27728
# 深さ優先探索の問題
import sys

sys.setrecursionlimit(10**6)
readline = sys.stdin.readline

N, Q = map(int, input().split())

# 隣接リスト
t = [[] for _ in range(N)]
for _ in range(N-1):
    a, b = [int(i) for i in readline().split()]
    t[a-1].append(b-1)
    t[b-1].append(a-1)

# スコア
s = [0] * N
for _ in range(Q):
    p, x = [int(i) for i in readline().split()]
    #s[p-1] = s[p-1] + x
    s[p-1] += x

ans = [0] * N

# 深さ優先探索
def dfs(v, p, value):
    #value = value + s[v]
    value += s[v]
    ans[v] = value
    for c in t[v]:
        if c == p:
            continue
        dfs(c, v, value)

dfs(0, -1, 0)

print(*ans)


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

int main() {
  int H, W;
  string a;
  cin >> H >> W;
  for (int i = 0; i < (W + 2); i++) {
    cout << '#';
  }
  cout << endl;
  for (int i = 0; i < H; i++) {
    cin >> a;
    cout << '#' << a << '#' << endl;
  }
  for (int i = 0; i < (W + 2); i++) {
    cout << '#';
  }
  cout << endl;
}

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

typedef long long int ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef vector<string>vst;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef vector<pii> vii;
typedef vector<pll> vll;

#define fastio ios_base::sync_with_stdio(false);cin.tie(0)
#define all(ct) ct.begin() , ct.end()
#define endl "\n"
#define fr(i,a) for(auto i:a)
#define f(i,a,b) for(int i=a;i<b;++i)
#define fd(i,a,b) for(int i=a;i>=b;--i)
#define pb push_back
#define in(d,v) d.find(v)!=d.end()
#define mp make_pair
#define size(a) int(a.size())

const int mod = 1e9 + 7;
const ll inf = ll(1e18);
const double PI = acos(-1);

ll modexp(ll x,ll n,int md){
    if(n==0)return 1;
    if(n%2==0)return modexp((x*x)%md,n/2,md);
    return (x*modexp((x*x)%md,n/2,md))%md;
}

int main(){
    fastio;
    //clock_t tm = clock();
    string s;
    cin>>s;
    if(s=="AAA" or s=="BBB"){
        cout<<"No"<<endl;
    }
    else{
        cout<<"Yes"<<endl;
    }
    //cout<<((clock()-tm)*1.0)/CLOCKS_PER_SEC<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdlib.h>
#include <string>
#include <iostream>
#include <vector>
using namespace std;

#define MAXN 100010

int dp[MAXN];
int N, M;

vector< vector<int> > graph (MAXN, vector<int>(0));

int q(int k) {
    int i;
    if (dp[k] != -1) return dp[k];

    int max = 0;
    for (i = 0; i < graph[k].size(); i++) {
        int temp = q( graph[k][i] ) + 1;
        if (temp > max) max = temp;
    }
    dp[k] = max;

    return dp[k];
}

int main() {
    int i;
    cin >> N >> M;

    for (i = 0; i < M; i++) {
        int x, y;
        cin >> x >> y;
        x--;
        y--;
        graph[x].push_back(y);
    }

    for (i = 0; i < N; i++) {
        dp[i] = -1;
    }

    int max = 0;
    for (i = 0; i < N; i++) {
        int temp = q(i);
        if (temp > max) max = temp;
    }
    cout << max << endl;
}

Measured memory_bytes: 8192
// in the name of Allah ;
#include<bits/stdc++.h>
using namespace std ;
long long b , ans ;
string s ;
int main() 
{
	cin >> s ;
	for ( auto c : s ) 
	{
		if ( c == 'B' ) 
			b++ ;
		else
			ans += b ;
	}
	cout << ans << endl;



}


Measured memory_bytes: 640
import sys
input = sys.stdin.readline
 
N = int(input())
A = list(map(int, input().split()))
mod = 10 ** 9 + 7
 
sum_A = sum(A) % mod
ans = 0
for a in A[:-1]:
  sum_A -= a
  sum_A %= mod
  ans += a * sum_A
  ans %= mod

ans %= mod
print(ans)

Measured memory_bytes: 105436
use std::io;


fn main() {
    let s = read_one::<String>().chars().collect::<Vec<char>>();
    let ans = "CODEFESTIVAL2016".to_string().chars().collect::<Vec<char>>();
    let mut cnt = 0;
    for i in 0..s.len() {
        if s[i] != ans[i] { cnt += 1; }
    }
    println!("{}", cnt);
}


#[allow(dead_code)]
fn read<T>() -> Vec<T>
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.split_whitespace()
        .map(|s| s.trim().parse().unwrap())
        .collect()
}

#[allow(dead_code)]
fn read_one<T>() -> T
where T:
    std::str::FromStr,
    T::Err: std::fmt::Debug {

    let mut buf = String::new();
    io::stdin().read_line(&mut buf).unwrap();
    buf.trim().parse().unwrap()
}

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

int main(){
    int N;
    cin >> N;
    vector<long long> a(N);
    for (int i = 0; i < N;i++)
        cin >> a[i];

    vector<long long> dp0(N);
    vector<long long> dp1(N);
    dp0[0] = a[0];
    dp1[0] = -a[0];
    for (int i = 1; i < N;i++){
        dp0[i] = max(dp0[i-1] + a[i], dp1[i-1] - a[i]);
        dp1[i] = max(dp0[i - 1] - a[i], dp1[i - 1] + a[i]);
        }
        cout << dp0[N - 1] << endl;
        return 0;
}

Measured memory_bytes: 2560
x,y = map(int, input().split())
lis1 = [1,3,5,7,8,10,12]
lis2 = [4,6,9,11]
if x in lis1 and y in lis1: print('Yes')
elif x in lis2 and y in lis2: print('Yes')
elif x==2 and y==2: print('Yes')
else: print('No')

Measured memory_bytes: 38256
import sys
import math
import heapq
import bisect
sys.setrecursionlimit(10**7)
INTMAX = 9223372036854775807
INTMIN = -9223372036854775808
DVSR = 1000000007
def POW(x, y): return pow(x, y, DVSR)
def INV(x, m=DVSR): return pow(x, m - 2, m)
def DIV(x, y, m=DVSR): return (x * INV(y, m)) % m
def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def FLIST(n):
    res = [1]
    for i in range(1, n+1): res.append(res[i-1]*i%DVSR)
    return res

N,M,K = LI()
AS=LI()
BS=LI()
ASC=[0]*(N+1)
BSC=[0]*(M+1)

for i in range(N):
    ASC[i+1] = ASC[i] + AS[i]
for i in range(M):
    BSC[i+1] = BSC[i] + BS[i]

# print(ASC)
# print(BSC)

res = 0

for i in range(0, N+1):
    # Aを i冊
    rest = K-ASC[i]
    if rest >= 0:
        idx = bisect.bisect_right(BSC, rest)
        # print("rest:{}, idx: {}".format(rest, idx))
        res = max(res, i+idx-1)
print(res)


Measured memory_bytes: 49040
#include <bits/stdc++.h>
using namespace std;
 
int main () {
    int N,M;
    cin >> N >> M;
    int H[N];
    int ma[N];
    for(int i = 1; i<=N; i++) {
        cin >> H[i];
        ma[i] = 0;
    }
    for(int i = 0; i<M; i++) {
        int a,b;
        cin >> a >> b;
        ma[a] = max(ma[a], H[b]);
        ma[b] = max(ma[b], H[a]);
    }
    int res = 0;
    for(int i = 1; i<=N; i++) {
        if(H[i] > ma[i]) res++;
    }
    cout << res << endl;
    return 0; 
}

Measured memory_bytes: 4408
#include<iostream>
#include<cmath>
#include<numeric>
#include<functional>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<iomanip>
#define rep(i,n) for(int i=0;i<n;i++)
#define rep1(i,n) for(int i=1;i<n;i++)
#define ll long long
#define modbig (10*10*10*10*10*10*10*10*10+7)
using namespace std;

int main(){
  ll n,k;
  cin>>n>>k;
  ll m=n%k;
  cout<<min(m,k-m);
}

Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
const long long mod = 1000000007;
const long long inf = 1ll << 61;
typedef pair<int, int> P;
typedef pair<int,P> PP;
typedef pair<int,PP> PPP;
struct edge { int to;  int cost; };

int l[8];
vector<int>V[4];
int ans=inf;int n, a, b, c; 
signed dfs(int now) {
	if (n == now) {
		if (V[0].size() && V[1].size() && V[2].size()) {
			int xa = 0, xb = 0, xc = 0;
			rep(i, V[0].size())xa += V[0][i];
			rep(i, V[1].size())xb += V[1][i];
			rep(i, V[2].size())xc += V[2][i];
			int Z = 0;
			rep(i,3)Z+=V[i].size();
			ans = min(ans, abs(xa - a) + abs(xb - b) + abs(xc - c) + 10 * (Z-3));
			return 0;
		}
		else return 0;
	}
	rep(i, 4) {
		V[i].push_back(l[now]);
		dfs(now + 1);
		V[i].pop_back();
	}
	return 0;
}

signed main() {
	cin >> n >> a >> b >> c;
	rep(i, n)cin >> l[i];
	dfs(0);
	cout << ans << endl;
}

Measured memory_bytes: 256
N, x = map(int, input().split())
candies = list(map(int, input().split()))

eat = 0
for i in range(1, N):
    cur = candies[i] + candies[i - 1]
    if cur <= x:
        continue
    eat_i = cur - x
    c = min(eat_i, candies[i])
    candies[i] -= c
    eat += eat_i
print(eat)


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

#define ASC(vec) vec.begin(), vec.end()		// 昇順ソート 例：sort(ASC(vec));
#define DESC(vec) vec.rbegin(), vec.rend()	// 降順ソート 例:sort(DESC(vec));
#define rep(i, n) for(int i = 0; i < (n); i++)
#define Rep(i, n) for(int i = 1; i < n; i++)
#define REP(i, vec) for(auto i = vec.begin(); i != vec.end(); ++i)

const int mod = 1000000007;
const int inf = (1 << 21);
const long long INF = 1LL << 60;

using ii = pair<int, int>;
using ll = long long;
using vi = vector<int>;
using vd = vector<double>;
using vb = vector<bool>;
using vl = vector<ll>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vii = vector<pair<int, int>>;
using vll = vector<pair<ll, ll>>;

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline T GCD(T a, T b) { return b ? GCD(b, a % b) : a; }
template<class T> inline T LCM(T a, T b) { return (a + (b - 1)) / b; }

int round_int(int a, int b) { return (a + (b - 1)) / b; }

constexpr array<int, 9> dx = { 0, 1, 0, -1, -1, 1, 1, -1, 0 };
constexpr array<int, 9> dy = { 1, 0, -1, 0, 1, 1, -1, -1, 0 };

// ──────────────────────────────────────────────────────────────────

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

	if (s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
	else cout << "No" << endl;
} 

Measured memory_bytes: 764
# -*- coding: utf-8 -*-
"""
A - Getting Difference
https://atcoder.jp/contests/agc018/tasks/agc018_a

"""
import sys


from fractions import gcd
from functools import reduce

def solve(N, K, A):
    limit = max(A)
    t = reduce(lambda x, y: gcd(x, y), A)
    if K <= limit and K % t == 0:
        return 'POSSIBLE'
    return 'IMPOSSIBLE'


def main(args):
    N, K = map(int, input().split())
    A = [int(a) for a in input().split()]
    ans = solve(N, K, A)
    print(ans)


if __name__ == '__main__':
    main(sys.argv[1:])


Measured memory_bytes: 16268
// Created by sz
#include <bits/stdc++.h>
using namespace std;

const int N = 1e5 + 5;
int a,b,c,d,e,f;
int vis[3001];
int salt_vis[3001];

int main(){
#ifdef LOCAL
    freopen("./input.txt", "r", stdin);
#endif
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    
    cin>>a>>b>>c>>d>>e>>f;
    
    vis[0] = 1;
    for(int i = 100; i<=f; i+= 100){
        if(i - a*100>=0&&vis[i-a*100])vis[i] = 1;
        if(i - b*100>=0&&vis[i-b*100])vis[i] = 1;
    }
    
    salt_vis[0] = 1;
    for (int i = 1; i <= f; i++){
        if(i - c>=0&&salt_vis[i-c])salt_vis[i] = 1;
        if(i - d>=0&&salt_vis[i-d])salt_vis[i] = 1;
    }
    
    int mxw=a*100, mxs = 0;
    for(int i = 100;i<f; i+=100){
        if(!vis[i])continue;
        int mxsalt = i/100 * e;
        for (int j = min(mxsalt, f-i); j >= 0; j--){
            if(salt_vis[j]){
                if(j*mxw>i*mxs){
                    mxw = i;
                    mxs = j;
                }
                break;
            }
        }
    }
    
    cout<<mxw+mxs<<' '<<mxs<<endl;
    
    return 0;
}



Measured memory_bytes: 256
n=int(input())
a=list(map(int,input().split()))
x=0
y=0
for i in range(n):
  if a[i]%2!=0:
    x+=1
  elif a[i]%4==0:
    y+=1

if x<=y:
  print("Yes")
else:
  if x+y==n and x==y+1:
    print("Yes")
  else:
    print("No")

Measured memory_bytes: 20140
#include <bits/stdc++.h>
using namespace std;
using ll =long long;
#define all(v) v.begin(),v.end()
 
int main() {
ll X;
  cin>>X;
  string S,T;
  cin>>S>>T;
  ll K=stoll(S);
  ll D=stoll(T);

  if(X<0) {
X*=-1;
  }

 if(S.size()+T.size()<=17&&D*K<=X) {
cout<<X-K*D<<endl;
   return 0;
 }
    else {
      ll count=X/D;
      X%=D;
      if((K-count)%2==0) {
cout<<X<<endl;
        return 0;
      }
      else {
cout<<D-X<<endl;
        return 0;
      }
    }
}

  
  
  
  
  

  
  
  
  
  


Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);    
    long long t1,t2,a1,a2,b1,b2;
    cin>>t1>>t2>>a1>>a2>>b1>>b2;
    if((a1-b1)*t1+(a2-b2)*t2==0){
        cout<<"infinity";
        return 0;
    }
    if(a1<b1){
        long long tmp;
        tmp=a1;
        a1=b1;
        b1=tmp;
         tmp=a2;
        a2=b2;
        b2=tmp;
    }
    if((a1-b1)*t1+(a2-b2)*t2>0){
        cout<<0;
        return 0;
    }
    long long p=(a1-b1)*t1;
    long long m=(a2-b2)*t2;
    
    long long ans=2*(1+p/-(p+m))-1;

    if(p%(-p-m)==0){
        ans-=1;
    }
    cout<<ans;
    /*
    long long ans=-1;
    long long x=0;
    while(1){
        x+=p;
        if(x>0){
            ans++;
        }
        if(x==0){
            ans++;
            cout <<ans;
            return 0;
        }
        if(x<0){
            cout<<ans;
            return 0;
        }
        x+=m;
        ans++;
    }
    */  
    //long long ans=1-2*((a1-b1)*t1-1)/((a1-b1)*t1+(a2-b2)*t2);
}

Measured memory_bytes: 256
#include <algorithm>
#include <bitset>
#include <cassert>
#include <climits>
#include <cmath>
#include <ctime>
#include <deque>
#include <iostream>
#include <list>
#include <map>
#include <memory.h>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <unordered_map>
#include <unordered_set>
using namespace std;
typedef long double LD;
typedef long long LL;
typedef pair<LL, LL> pll;
typedef pair<int, int> pii;
typedef vector<int> vi;
#ifdef LOCAL
    #define DEBUG(x) { cerr << "# " << #x << ": " << x << endl;}
#else
    #define DEBUG(x)
#endif
mt19937_64 mt(time(0));
/*---------------------------------------------------------------------------------------------------
　　　　　　　　　　　 ∧＿∧  
　　　　　 ∧＿∧ 　（´<_｀ ）　 Welcome to My Coding Space!
　　　　 （ ´_ゝ`）　/　 ⌒i     
　　　　／　　　＼　 　  |　|     
　　　 /　　 /￣￣￣￣/　　|  
　 ＿_(__ﾆつ/　    ＿/ .| .|＿＿＿＿  
　 　　　＼/＿＿＿＿/　（u　⊃  
---------------------------------------------------------------------------------------------------*/
const int MAXN = 1e5 + 10;
int a[MAXN], b[MAXN];





int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cout.precision(10); cout << fixed;
#ifdef LOCAL
    freopen("../test.txt", "r", stdin);
    // freopen("../output.txt", "w", stdout);
#endif
    int n; cin >> n;
    LL ret = 0, tmp = 0;
    vector<pii> nums;
    for (int i = 0; i < n; i++) {
        cin >> a[i] >> b[i];
        nums.emplace_back(a[i], i*2);
        nums.emplace_back(b[i], i*2+1);
        ret += a[i];
        tmp += b[i];
    }
    ret = min(ret, tmp);
    sort(nums.begin(), nums.end());
    set<pii> table;
    tmp = 0;
    for (int i = 0; i < n - 2; i++) {
        table.insert(nums[i]);
        tmp += nums[i].first;
    }
    for (int i = 0; i < n; i++) {
        LL tmp1 = tmp;
        int cnt = 0;
        if (table.find(make_pair(a[i], i*2)) != table.end()) cnt++;
        if (table.find(make_pair(b[i], i*2+1)) != table.end()) cnt++;
        if (cnt == 2) {
            tmp1 += nums[n-2].first + nums[n-1].first;
        } else if (cnt == 0) {
            tmp1 += a[i] + b[i];
        } else {
            if (table.find(make_pair(a[i], i*2)) != table.end()) tmp1 += b[i];
            else tmp1 += a[i];
            if (nums[n-2] != make_pair(a[i], i*2) && nums[n-2] != make_pair(b[i], i*2+1)) {
                tmp1 += nums[n-2].first;
            } else {
                tmp1 += nums[n-1].first;
            }
        }
        ret = min(ret, tmp1);
    }
    cout << ret << endl;







/*---------------------------------------Coding Space End------------------------------------------*/
#ifdef LOCAL
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s." << endl;
#endif
    return 0;
}
/* author:  txingml */
/* picture is from hamayanhamayan(CF handle) */


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

int main() {
  int A, B, C, X;
  cin >> A >> B >> C >> X;
  
  int pattern = 0;

  for(int i=0;i<=C;i++){
    for(int j=0;j<=B;j++){
      for(int k=0;k<=A;k++){
        if(50*i+100*j+500*k==X){
          pattern += 1;
        }
      }
    }
  }
  
  cout << pattern << endl;
}

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

int main(){
    long long X;
    long long  money = 100;
    cin >> X;

    int res = 0;

    bool mitasu = false;


    while(true){
        if(X <= money){
            break;
        }else{
            money += money/100;
            res++; 
        }
    }

    cout << res << endl;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
char s[200];
long long k, tmp;
int main()
{
    scanf("%s",s);
    scanf("%d",&k);
    int len = strlen(s);
    for(int i=0; ;i++)
    {
        if(s[i] != '1')
        {
            tmp = i;
            break;
        }
        if(i==len-1)
        {
            printf("1\n");
            return 0;
        }
    }
    if(k<=tmp) printf("1\n");
    else printf("%c\n",s[tmp]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int A;
  int B;
  cin >> A;
  cin >> B;
  int X=0;
  for ( int i = A ; i <= B ; i++ ) {
    string s=to_string(i);
    if(s[0]==s[4]&&s[1]==s[3])X++;
  }
  cout << X << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <cstdio>
#include <vector>
#include <iostream>
#include <algorithm>
#include <bits/stdc++.h>
using namespace std;
int main() 
{
    /* Enter your code here. Read input from STDIN. Print output to STDOUT */   
    long long int i,j,k,l,inc,dec,t,r,mod=1000000007;
   	long long int c,d,e,s,ans=0,n,temp,m,p,x,y;
   	//cin>>t;
   	t=1;
   	while(t--)
   	{
   		cin>>n;
   		long long int a[n],dp[n+1];
   		for(i=0;i<n;i++)
   		{
   			cin>>a[i];	
		}
		dp[0]=0;
		dp[1]=0;
		if(n>=2)
		dp[2]=abs(a[1]-a[0]);
		for(i=3;i<=n;i++)
		{
			dp[i]=min(abs(a[i-1]-a[i-2])+dp[i-1],abs(a[i-1]-a[i-3])+dp[i-2]);
		}
		cout<<dp[n]<<endl;
	}
   	
	
   return 0;
}



Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define M 1000000007
#define U 998244353
#define N 1000005
#define int long long
#define sz(c) (int)c.size()
#define fr first
#define ll long long 
#define sc second
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define all(a) (a).begin(),(a).end()
#define rep(i,a,n) for(int i=a ; i<n ; i++)
#define r0 return 0;
#define endl '\n'
#define INF (int)8*1e18
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
	std::cerr << name << " : " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
	const char* comma = strchr(names + 1, ',');std::cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
int power(int x, unsigned int y, unsigned int m)
{
    if (y == 0)
        return 1;
    int p = power(x, y/2, m) % m;
    p = (p * p) % m;
    return (y%2 == 0)? p : (x * p) % m;
}
signed main()
{
	ios_base::sync_with_stdio(0);
	int TESTS=1;
	// cin>>TESTS;
	while(TESTS--)
	{   
		int n;
		cin>>n;
		int m[60];
		rep(i,0,60) m[i] = 0;
		rep(i,0,n){
			int t;
			cin>>t;
			while(t){
				int cur = 1;
				while(cur<=t){
					cur *= 2;
				}
				cur /=2;
				m[(int)log2(cur)]++;
				t -= cur;
				// trace(t);
			}
		}
		int ans=0;
		rep(i,0,60){
			// trace(i,m[i]);
			ans = (ans+(((power(2,i,M)*m[i])%M)*(n-m[i]))%M)%M;
		}
		cout<<(ans)%M;
	}   
}     

Measured memory_bytes: 256
// Problem name: Closed Rooms
#include <cstdio>
#include <algorithm>
#include <queue>

using namespace std;

struct TPoint {int x, y;};

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

const int N = 805;
const int INF = 1e9;

int n, m, k, d[N][N];
char a[N][N];

bool Valid(int x, int y) {return 1 <= x && x <= n && 1 <= y && y <= m;}
bool HasExit(int x, int y) {return x == 1 || x == n || y == 1 || y == m;}

void Solve()
{
    TPoint s;
    for (int i = 1; i <= n; ++i)
        for (int j = 1; j <= m; ++j)
            if (a[i][j] == 'S') s = {i, j};
        
    for (int i = 1; i <= n; ++i) fill(d[i]+1, d[i]+1+m, -1);
    
    int res = INF;
    queue<TPoint> q;
    q.push(s);
    d[s.x][s.y] = 0;
    while (!q.empty())
    {
        TPoint u = q.front(); q.pop();
        if (d[u.x][u.y] <= k)
        {
            if (HasExit(u.x, u.y)) res = 1;
            else res = min(res, (min(min(u.x - 1, n - u.x), min(u.y - 1, m - u.y)) - 1) / k + 2);
        }
        else continue;
        for (int dir = 0; dir < 4; ++dir)
        {
            TPoint v {u.x + dx[dir], u.y + dy[dir]};
            if (Valid(v.x, v.y) && a[v.x][v.y] != '#' && d[v.x][v.y] == -1) q.push(v), d[v.x][v.y] = d[u.x][u.y] + 1;
        }
    }
    printf("%d",res);
}

int main()
{
    scanf("%d%d%d",&n,&m,&k);
    for (int i = 1; i <= n; ++i) scanf("%s",a[i]+1);
    Solve();
    return 0;
}


Measured memory_bytes: 3456
#include<bits/stdc++.h>
using namespace std;
int main()
{
	long long n,a,b,s;
	scanf("%lld %lld %lld",&n,&a,&b);
	if((b-a)%2==0)
		printf("%lld",(b-a)/2);
	else
	{
		s=min(a-1,n-b);
		s+=1;
		s+=max(b-a-1,(long long)0)/2;
		printf("%lld",s);
	}
	return 0;
}

Measured memory_bytes: 256
"""dp1,2[i][j] 
i桁で0をj個含む数で, 
dp1→ Nの上からi桁目までを抽出した数より小さい
dp2→ Nの上からi桁目までを抽出した数に等しい
"""

N = int(input())
K = int(input())
digit = len(str(N))
N_str = str(N)

dp1 = [[0]*4 for _ in range(digit+1)]
dp2 = [[0]*4 for _ in range(digit+1)]

dp2[0][0] = 1

for i in range(1, digit+1):
    for j in range(4):
        if int(N_str[i-1]) != 0:
            if j >= 1:
                dp2[i][j] = dp2[i-1][j-1]
                dp1[i][j] = dp1[i-1][j]+9*dp1[i-1][j-1]+dp2[i-1][j]+dp2[i-1][j-1]*(int(N_str[i-1])-1)
            else:
                dp1[i][j] = dp1[i-1][j]+dp2[i-1][j]
        else:
            dp2[i][j] = dp2[i-1][j]
            if j >= 1:
                dp1[i][j] = dp1[i-1][j]+9*dp1[i-1][j-1]
            else:
                dp1[i][j] = dp1[i-1][j]

        #print(i, j, dp1[i][j], dp2[i][j])

ans = dp1[digit][K]+dp2[digit][K]

print(ans)


Measured memory_bytes: 3064