akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
ll gcdEx(ll a, ll b, ll *x, ll *y){if(!a){*x=0;*y=1;return b;}
ll x1,y1,gcd=gcdEx(b%a,a,&x1,&y1); *x=y1-(b/a)*x1;*y=x1; return gcd;}
ll modI(ll b, ll m)      {ll x,y;gcdEx(b,m,&x,&y);return (x%m+m)%m;}

typedef pair<ll, ll>      pii;
typedef vector<ll>         vi;
typedef vector<pii>         vii;
typedef set<ll>            si;
typedef map<string, ll>    msi;
#define all(x) (x).begin(), (x).end()
#define make_unique(x) sort(all((x))); (x).resize(unique(all((x))) - (x).begin())
#define loop(i,b,n)           for(ll i=b;i<n;i++)
#define loopv(b,n,a)         for(ll i=b;i<n;i+=a)
#define loopr(b,n)           for(ll i=n;i>=0;i--)

#define sum(a)     ( accumulate ((a).begin(), (a).end(), 0ll))
#define mine(a)    (*min_element((a).begin(), (a).end()))
#define maxe(a)    (*max_element((a).begin(), (a).end()))
#define lowb(a, x) ( lower_bound((a).begin(), (a).end(), (x)) - (a).begin())
#define uppb(a, x) ( upper_bound((a).begin(), (a).end(), (x)) - (a).begin())

#define start_routine() int begtime = clock();
#define end_routine() int endtime = clock(); \
                      cerr << "\n\n" << "Time elapsed: " << \
                      (endtime - begtime)*1000/CLOCKS_PER_SEC << " ms\n\n"; \
                      return 0
#define mp                  make_pair
#define ff                  first
#define ss                  second
#define pb                  push_back
#define MOD                 1000000007
#define modA(a,b)           (((a%MOD)+(b%MOD))%MOD)
#define modS(a,b)           (((((a%MOD)-(b%MOD))%MOD)<0)?(int)(MOD+((a%MOD)-(b%MOD))%MOD):(int)(((a%MOD)-(b%MOD))%MOD))
#define modM(a,b)           (ll)((((ll)(a%MOD))*((ll)(b%MOD)))%MOD)
#define modD(a,b)           ((modI(b,MOD)*(a%MOD))%MOD)

#define trace1(x)                  cerr<<#x<<": "<<x<<endl
#define trace2(x, y)               cerr<<#x<<": "<<x<<" | "<<#y<<": "<<y<<endl
#define trace3(x, y, z)            cerr<<#x<<":" <<x<<" | "<<#y<<": "<<y<<" | "<<#z<<": "<<z<<endl
#define trace4(a, b, c, d)         cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<endl
#define trace5(a, b, c, d, e)      cerr<<#a<<": "<<a<<" | "<<#b<<": "<<b<<" | "<<#c<<": "<<c<<" | "<<#d<<": "<<d<<" | "<<#e<< ": "<<e<<end
ll modP(ll x, ll y)         {ll r=1; x%=MOD; while(y>0){if(y&1){r=(r*x)%MOD;}
y=y>>1; x=(x*x)%MOD;} return r;}
ll min(ll a,ll b ) {     if(a<b)     return a;     else    return b;  }
ll max(ll a,ll b ) {     if(a>b)     return a;     else    return b;  }
ll brute(string s)
{
    ll ans=0,n,b;
string ss,a="";
n=s.size();
loop(l,0,n)
{

loop(r,l,n)
{
    a=s;
    loop(k,l,r+1)
    {
    if(a[k]=='1')
a[k]='0';
else
    a[k]='1';
    }
    loop(i,0,n-1)
    if(a[i]==a[i+1])
    ans++;
}
}
    return ans;
}
int main()
{
    cin.sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
ll t;
//  cin>>t;
// freopen("input.txt","r",stdin);freopen("output.txt","w",stdout); 
t=1;
 while(t--)
{
ll ans=0,a,n,b,k;
string s,ss; 
cin>>a>>b>>k;
a-=k; 
if(a<0) 
{
  b+=a;
  if(b<0) 
    b=0; 
  a=0;
} 
cout<<a<<" "<<b;
}
   return 0;

}


Measured memory_bytes: 256
#include <iostream>

using ll = long long;

ll gcd(ll m, ll n) {
  if (n == 0) return m;
  else return gcd(n, m%n);
}

ll lcm(ll m, ll n) {
  return (m*n)/gcd(m,n);
}

ll calc(ll n, ll a, ll b) {
  auto c = n / a;
  auto d = n / b;
  auto e = n / lcm(a, b);

  std::cerr << n << '/' << a << '=' << c << std::endl;
  std::cerr << n << '/' << b << '=' << d << std::endl;
  std::cerr << n << '/' << a*b << '=' << e << std::endl;

  return n - (c + d - e);
}

int main() {
  ll A, B, C, D;

  std::cin >> A >> B >> C >> D;

  auto ans = calc(B, C, D) - calc(A-1, C, D);

  std::cout << ans << std::endl;

  return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int [] A = new int [a];
        int [] C = new int [a-1];
        for(int i=0;i<a;i++){A[i] = sc.nextInt();
                            }
		int ans = 0;
        for(int i=0;i<a;i++){int b = sc.nextInt();
                             ans+=b;
                            }
        for(int i=0;i<a-1;i++){C[i] = sc.nextInt();
                              }
         for(int i=0;i<a-1;i++){if(A[i+1]==A[i]+1){ans+=C[A[i]-1];}
                            }
		System.out.println(ans);
	}
}


Measured memory_bytes: 22736
//的場梨沙★担当
//結城晴★副担当
//日野茜★副担当
#include <vector>
#include <list>
#include <map>
#include <climits>
#include <set>
#include <unordered_set>
#include <unordered_map>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string.h>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <random>
#include <cctype>
#include <complex>
#include <regex>
#include <unordered_map>
#include <string>
#include <algorithm>
#include <cctype>
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <iomanip>
#include <iostream>

using namespace std;

int main() {
   string S,T;
   cin>>S>>T;

   cout<<T<<S<<endl;
    
}

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

using namespace std; 

typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef vector<PII> VPII;
typedef long long LL;
typedef priority_queue<int> PQ_DESC;
typedef priority_queue<int, vector<int>, greater<int>> PQ_ASC;
typedef priority_queue<PII> PQ_DESC_PII;
typedef priority_queue<PII, vector<PII>, greater<PII>> PQ_ASC_PII;

#define ALL(c) (c).begin(),(c).end()
#define PB push_back
#define MP make_pair
#define SORT_ASC(c) sort(ALL(c))
#define SORT_DESC(c) sort(ALL(c), greater<typeof(*((c).begin()))>())
#define SIZE(a) int((a).size())

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ROF(i,a,b) for(int i=(b-1);i>=(a);--i)
#define REP(i,n) FOR(i,0,n)
#define PER(i,n) ROF(i,0,n)

const double EPS = 1e-10;
const double PI  = acos(-1.0);
const int LARGE_INT = 1e9+100;
const int INF = 2e9+100;
const LL INF_LL = (LL)INF * 300 * 300;
const int MOD = 1e9+7;

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

LL modpow(LL a, LL n) {
    LL res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % MOD;
        a = a * a % MOD;
        n >>= 1;
    }
    return res;
}


vector<bool> IsPrime;
void sieve(size_t max){
    if(max+1 > IsPrime.size()){     // resizeで要素数が減らないように
        IsPrime.resize(max+1,true); // IsPrimeに必要な要素数を確保
    } 
    IsPrime[0] = false; // 0は素数ではない
    IsPrime[1] = false; // 1は素数ではない

    for(size_t i=2; i*i<=max; ++i) // 0からsqrt(max)まで調べる
        if(IsPrime[i]) // iが素数ならば
            for(size_t j=2; i*j<=max; ++j) // (max以下の)iの倍数は
                IsPrime[i*j] = false;      // 素数ではない
}

void Main()
{
    int n = 1e5+10;
    sieve(n+5);

    VI c(n);
    for(int i=1;i<n;i+=2){
        if(IsPrime[i] && IsPrime[(i+1)/2]){
            c[i] ++;
        }
    }
    FOR(i,1,n){
        c[i] += c[i-1];
    }

    int q;cin>>q;
    REP(i,q){
        int l,r;cin>>l>>r;
        cout<<c[r]-c[l-1]<<endl;
    }







	return;
}

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

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

void success(){
    cout << "Yes" << endl;
    exit(0);
}
void fail(){
    cout << "No" << endl;
    exit(0);
}

int main(){
    int N;
    cin >> N;
    vector<int> A(N);
    for(int i=0; i<N; i++) cin >> A[i];
    sort(A.begin(), A.end());
    if(A[N-1] - A[0] >= 2) fail();
    if(A[0] == A[N-1] && A[0] == N-1) success();

    int one = 0;
    for(int i=0; i<N; i++) if(A[i] != A[N-1]) one++;
    int more_cat = N - one;
    int more_col = A[N-1] - one;
    if(more_col <= 0) fail();
    if(more_cat < 2*more_col) fail();
    success();
}

Measured memory_bytes: 640
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;
template<class T>
void read_1d(std::vector<T>& a,int64_t num){
	a.reserve(num);
	for(int64_t i1=0;i1<num;i1++){
		T temp;
		cin>>temp;
		a.push_back(temp);
	}
}
template<class T>
void read_2d(std::vector<std::vector<T> >&a,int64_t x,int64_t y ){
	a.resize(x);
	for(int64_t i1=0;i1<x;i1++){
		a[i1].reserve(y);
		for(int64_t i2=0;i2<y;i2++){
			T temp;
			cin>>temp;
			a[i1].push_back(temp);
		}
	}
}
template<class InputIterator>
void debug(InputIterator first,InputIterator last){
	for(auto i1=first;i1!=last;i1++){
		cout<<(*i1)<<endl;
	}
}

int main(){
	int64_t a,b,c;
	cin>>a>>b>>c;
	if(a%2==1||b%2==1||c%2==1){
		cout<<0<<endl;
	}else if(a==b&&b==c){
		cout<<-1<<endl;
	}else{
		int count=0;
		while(true){
			int64_t divider=((uint64_t)1)<<(count+1);
			if(a%divider==b%divider&&b%divider==c%divider){
				count++;
			}else{
				cout<<count<<endl;
				break;
			}
		}
	}
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,X;
  cin>>A>>B>>C>>X;
  int ans=0;
  for(int a=0;a<A+1;a++){
    for(int b=0;b<B+1;b++){
      for(int c=0;c<C+1;c++){
        if(a*500+b*100+c*50==X){
          ans++;
        }
      }
    }
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i<(n); i++)
#define reps(i,s,n) for(int i=(s); i<(n); i++)
#define all(v) v.begin(),v.end()
#define outve(v) for(auto i : v) cout << i << " ";cout << endl
#define outmat(v) for(auto i : v){for(auto j : i) cout << j << " ";cout << endl;}
#define in(n,v) for(int i=0; i<(n); i++){cin >> v[i];}
#define out(n) cout << (n) << endl
#define fi first
#define se second
#define pb push_back
#define si(v) int(v.size())
#define len(v) int(v.length())
#define lob(v,n) lower_bound(all(v),n)
#define lobi(v,n) lower_bound(all(v),n) - v.begin()
#define upb(v,n) upper_bound(all(v),n)
#define upbi(v,n) upper_bound(all(v),n) - v.begin()
#define mod 1000000007
#define infi 1900000000
#define infl 1100000000000000000
#define cyes cout << "Yes" << endl
#define cno cout << "No" << endl
#define csp << " " <<
#define outset(n) cout << fixed << setprecision(n);
using namespace std;
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vs = vector<string>;
using vc = vector<char>;
using vd = vector<double>;
using vvd = vector<vector<double>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
using vvp = vector<vector<pair<int,int>>>;
template<typename T> using ve = vector<T>;
template<typename T> using pq2 = priority_queue<T>;
template<typename T> using pq1 = priority_queue<T,vector<T>,greater<T>>;
template<typename T> bool chmax(T &a, T b) {if(a < b) {a = b;return 1;}return 0;}
template<typename T> bool chmin(T &a, T b) {if(a > b) {a = b;return 1;}return 0;}




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

    int N;
    cin >> N;
    
    vi gg(N,-1);
    vi ans(N-1,0);
    int color = 0;
    map<pii,int> M;
    vvi G(N);
    
    rep(i,N-1){
        int a,b;
        cin >> a >> b;
        a--,b--;
        G[a].pb(b);
        G[b].pb(a);
        M[{a,b}] = i;
        M[{b,a}] = i;
    }
    
    queue<pii> q;
    q.push({0,-1});
    
    while (!q.empty()) {
        
        pii p = q.front();
        q.pop();
        
        gg[p.fi] = si(G[p.fi])-1;
        chmax(color,gg[p.fi]+1);
        int cc = 1;
        for (auto pp : G[p.fi]) {
            if(gg[pp] >= 0) continue;
            if(cc == p.se) cc++;
            q.push({pp,cc});
            ans[M[{pp,p.fi}]] = cc;
            cc++;
        }
        
        
    }
    
    
    cout << color << endl;
    rep(i,N-1) cout << ans[i] << endl;
    
    

    return 0;
}


Measured memory_bytes: 22204
import java.io.*;
import java.math.*;
import java.util.*;

public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;

    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);

    private void solve(Scanner sc) {
        String s = sc.nextLine();

        Set<Character> set = new HashSet<>();
        for (int i = 0; i < s.length(); ++i) {
            char ch = s.charAt(i);
            if (!set.contains(ch)) {
                set.add(ch);
            } else {
                _out.println("no");
                return;
            }
        }
        _out.println("yes");
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();

        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();

        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

Measured memory_bytes: 21972
s = input()
q = int(input())

def addflont(s,c):
    text = "".join([c,s])
    return text
def addback(s,c):
    text = "".join([s,c])
    return text

reverse = 0
r = "";u = ""
for i in range(q):
    t = input()
    if t[0]=="1":
        reverse = reverse^1
    if t[0]=="2":
        if t[2]=="1":
            if reverse==0:
                r = addflont(r,t[4])
            else:
                u = addback(u,t[4])
        elif t[2]=="2":
            if reverse==0:
                u = addback(u,t[4])
            else:
                r = addflont(r,t[4])

s = r + s + u
if reverse==1:
    print(s[::-1])
else:
    print(s)


Measured memory_bytes: 4648
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i,n) for(long long i=0; i<(n); i++)
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; }


int main(){
    ll n; cin>>n;
    vector<ll> a(n), cnt(1e5+5);
    rep(i,n) cin>>a[i];
    rep(i,n){
        if(a[i]>0) cnt[a[i]-1]++;
        cnt[a[i]]++;
        cnt[a[i]+1]++;
    }
    ll res=0;
    rep(i, 1e5+5) chmax(res, cnt[i]);
    cout<<res<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long   signed int LL;
typedef long long unsigned int LU;
#define incID(i, l, r) for(LL i = (l)    ; i <  (r); ++i)
#define incII(i, l, r) for(LL i = (l)    ; i <= (r); ++i)
#define decID(i, l, r) for(LL i = (r) - 1; i >= (l); --i)
#define decII(i, l, r) for(LL i = (r)    ; i >= (l); --i)
#define inc(i, n)  incID(i, 0, n)
#define inc1(i, n) incII(i, 1, n)
#define dec(i, n)  decID(i, 0, n)
#define dec1(i, n) decII(i, 1, n)
#define inID(v, l, r) ((l) <= (v) && (v) <  (r))
#define inII(v, l, r) ((l) <= (v) && (v) <= (r))
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define  ALL(v)  v.begin(),  v.end()
#define RALL(v) v.rbegin(), v.rend()
template<typename T> bool setmin  (T & a, T b) { if(b <  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmax  (T & a, T b) { if(b >  a) { a = b; return true; } else { return false; } }
template<typename T> bool setmineq(T & a, T b) { if(b <= a) { a = b; return true; } else { return false; } }
template<typename T> bool setmaxeq(T & a, T b) { if(b >= a) { a = b; return true; } else { return false; } }
LL mo(LL a, LL b) { assert(b > 0); a %= b; if(a < 0) { a += b; } return a; }
LL fl(LL a, LL b) { assert(b > 0); return (a > 0 ? a / b : (a - b + 1) / b); }
LL ce(LL a, LL b) { assert(b > 0); return (a < 0 ? a / b : (a + b - 1) / b); }
template<typename T> T gcd(T a, T b) { return (b == 0 ? a : gcd(b, a % b)); }
template<typename T> T lcm(T a, T b) { return a / gcd(a, b) * b; }
#define bit(b, i) (((b) >> (i)) & 1)
#define BC __builtin_popcountll
#define SC static_cast
#define SI(v) SC<int>(v.size())
#define SL(v) SC<LL >(v.size())
#define RF(e, v) for(auto & e: v)
#define ef else if
#define UR assert(false)

// ---- ----

template<typename T> class RPQ : public priority_queue<T, vector<T>, greater<T>> { };
template<typename C> void dijkstra(int s, vector<pair<int, C>> g[], C d[]) {
	RPQ<pair<C, int>> q;
	d[s] = 0;
	q.emplace(d[s], s);
	while(! q.empty()) {
		C   c = q.top().FI;
		int v = q.top().SE;
		q.pop();
		if(d[v] != c) { continue; }
		for(auto & e : g[v]) {
			int ev = e.FI;
			C   ec = e.SE;
			if(setmin(d[ev], d[v] + ec)) { q.emplace(d[ev], ev); }
		}
	}
}

int n, m, s, t, d[300000], INF = 1e8;
vector<pair<int, int>> g[300000];

int main() {
	cin >> n >> m;
	inc(i, m) {
		int a, b;
		cin >> a >> b;
		a--; b--;
		g[0 * n + a].EB(1 * n + b, 1);
		g[1 * n + a].EB(2 * n + b, 1);
		g[2 * n + a].EB(0 * n + b, 1);
	}
	cin >> s >> t;
	s--; t--;
	
	inc(i, 3 * n) { d[i] = INF; }
	
	dijkstra(s, g, d);
	
	cout << (d[t] == INF ? -1 : d[t] / 3) << endl;
	
	return 0;
}


Measured memory_bytes: 17792
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return 1;}return 0;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return 1;}return 0;}
template<typename A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 100000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

ll dp[30000];

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,A);
  IN(ll,B);
  ll a,b;
  REP(i,1300){
    a = i*0.08;
    b = i * 0.1;
    if(a == A && b == B){
      OUT(i);
      return 0;
    }
  }
  OUT(-1);
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
#include <map>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
typedef long long ll;

int main(){
    ll n,m;
    cin >> n >> m;
    vector<ll> X(m);
    vector<ll> diffX(m-1);
    REP(i,m){
        cin >> X[i];
    }
    sort(X.begin(),X.end());
    REP(i,m-1){
        diffX[i] = X[i+1] - X[i];
    }
    sort(diffX.begin(),diffX.end());
    ll ans = 0;
    REP(i,m-n){
        ans += diffX[i];
    }
    cout << ans << endl;
}


Measured memory_bytes: 1792
N,X,M = map(int,input().split())
from collections import deque
ans = 0
flag = [0] * (M+1)
dic = dict()
q = deque()
for i in range(N):
  if not(flag[X]):
    flag[X] = 1
    dic[X] = i
    q.append(X)
    ans += X
    X = pow(X,2,M)
  else:
    q = list(q)
    loop = q[dic[X]:]
    loop_sum = sum(loop)
    loop_l = len(loop)
    length = N-i - ((N-i)//loop_l * loop_l)
    ans += loop_sum * ((N-i)//loop_l)
    ans += sum(loop[:length])
    break
print(ans)

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

int main(){
    double N,x,ans=0.0;
    string u;
    cin >> N;
    for(int i=0; i<N; i++){
        cin >> x >> u;
        if(u=="JPY")ans+=x;
        else ans+=x*380000.0;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
n=int(input())
al=list(map(int,input().split()))
ac=0
ans=set()
tl=[0]*n
for i in range(n,0,-1):
    if tl[i-1]%2!=al[i-1]:
        ac+=1
        ans.add(i)
        for j in range(1,int(i**0.5)+1):
            if i%j==0:
                tl[j-1]+=1
                if j**2==i:
                    continue
                tl[i//j-1]+=1
print(ac)
if ac>0:
    print(' '.join(map(str,ans)))

Measured memory_bytes: 85352
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
int main() {
    string ans = "Good";
    string s;
    cin>>s;
    for (int i = 1; i < 4; ++i) {
        if(s[i-1] == s[i]){
            ans = "Bad";
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{ 
 int n,a[100],i,l=0,s=1000000001;
 scanf("%d\n",&n);
 for(i=0;i<n;i++){
 scanf("%d",&a[i]);
 
 if(l<a[i]){
 l=a[i]+0;}
 if(s>a[i]){
 s=a[i]+0;}
}
printf("%d\n",l-s);
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int main(void){
		
	int a;
		
	while(1){
		if(scanf("%d", &a) == EOF )
				break;
			
		a = a % 39;
		if(a == 0)	a = 39;
		printf("3C%02d\n", a);
	}
		
	return 0;
}

Measured memory_bytes: 2592
from operator import itemgetter


def f(): return map(int, input().split())


N, M = f()
A = list(f())
BC = [list(f()) for i in range(M)]

BC.sort(key=itemgetter(1), reverse=True)

for b, c in BC:
    A.extend([c]*b)
    if len(A) >= 2*N:
        break

A.sort(reverse=True)
print(sum(A[:N]))


Measured memory_bytes: 34892
#include<cstdio>
#include<algorithm>
using namespace std;
int D[1 << 19], T[1<<19], Mod = 1000000007;
int n, m, K, U[20][20], res;
int main() {
	int i, j, a, b, c, k;
	scanf("%d%d%d", &n, &m, &K);
	for (i = 0; i < K; i++) {
		scanf("%d%d%d", &a, &b, &c);
		U[a-1][b-1] = c + 1;
	}
	D[0] = 1;
	for (i = 0; i < m; i++) {
		for (j = 0; j < n - 1; j++) {
			for (k = 0; k < (1 << (n-1)); k++) {
				if (!((k >> j) & 1) && U[i][j]!=2) {
					T[k] += D[k];
					if (T[k] >= Mod)T[k] -= Mod;
				}
				if (U[i][j] != 1) {
					if ((k >> j) & 1) {
						T[k] += D[k];
						if (T[k] >= Mod)T[k] -= Mod;
					}
					else {
						int t = (k >> j)&(-(k >> j));
						T[k + (1 << j) - (t << j)] = (T[k + (1 << j) - (t << j)] + D[k]) % Mod;
					}
				}
			}
			for (k = 0; k < (1 << (n - 1)); k++) {
				D[k] = T[k];
				T[k] = 0;
			}
		}
	}
	for (i = 0; i < (1 << (n - 1)); i++)res = (res + D[i]) % Mod;
	printf("%d\n", res);
}

Measured memory_bytes: 4224
import sys
sys.setrecursionlimit(10**8)
def ii(): return int(sys.stdin.readline())
def mi(): return map(int, sys.stdin.readline().split())
def li(): return list(map(int, sys.stdin.readline().split()))
def li2(N): return [list(map(int, sys.stdin.readline().split())) for _ in range(N)]
def dp2(ini, i, j): return [[ini]*i for _ in range(j)]
def dp3(ini, i, j, k): return [[[ini]*i for _ in range(j)] for _ in range(k)]
#import bisect #bisect.bisect_left(B, a)
#from collections import defaultdict #d = defaultdict(int) d[key] += value
#from itertools import accumulate #list(accumulate(A))

A, B = mi()

ans = 0

def count(n):
    if n==0:
        return 0
    N = n
    n %= 4
    if n == 1:
        return 1
    if n == 2:
        return N+1
    if n == 3:
        return 0
    if n == 0:
        return N

print(count(A-1)^count(B))

Measured memory_bytes: 3188
from itertools import product
import sys

input = sys.stdin.buffer.readline
sys.setrecursionlimit(10 ** 6 + 100)


class StronglyConnectedComponets:
    def __init__(self, n: int) -> None:
        self.n = n
        self.edges = [[] for _ in range(n)]
        self.rev_edeges = [[] for _ in range(n)]
        self.vs = []
        self.order = [0] * n
        self.used = [False] * n

    def add_edge(self, from_v: int, to_v: int) -> None:
        self.edges[from_v].append(to_v)
        self.rev_edeges[to_v].append(from_v)

    def dfs(self, v: int) -> None:
        self.used[v] = True
        for child in self.edges[v]:
            if not self.used[child]:
                self.dfs(child)
        self.vs.append(v)

    def rdfs(self, v: int, k: int) -> None:
        self.used[v] = True
        self.order[v] = k
        for child in self.rev_edeges[v]:
            if not self.used[child]:
                self.rdfs(child, k)

    def run(self) -> int:
        self.used = [False] * self.n
        self.vs.clear()
        for v in range(self.n):
            if not self.used[v]:
                self.dfs(v)
        self.used = [False] * self.n
        k = 0
        for v in reversed(self.vs):
            if not self.used[v]:
                self.rdfs(v, k)
                k += 1
        return k


class TwoSat(StronglyConnectedComponets):
    def __init__(self, num_var: int) -> None:
        super().__init__(2 * num_var + 1)
        self.num_var = num_var
        self.ans = []

    def add_constraint(self, a: int, b: int) -> None:
        super().add_edge(self._neg(a), self._pos(b))
        super().add_edge(self._neg(b), self._pos(a))

    def _pos(self, v: int) -> int:
        return v if v > 0 else self.num_var - v

    def _neg(self, v: int) -> int:
        return self.num_var + v if v > 0 else -v

    def run(self) -> bool:
        super().run()
        self.ans.clear()
        for i in range(self.num_var):
            if self.order[i + 1] == self.order[i + self.num_var + 1]:
                return False
            self.ans.append(self.order[i + 1] > self.order[i + self.num_var + 1])
        return True


def main() -> None:
    N, D = map(int, input().split())

    flags = [tuple(int(x) for x in input().split()) for _ in range(N)]

    # (X_i, Y_i) -> (i, -i) (i=1, ..., N) と考える
    sat = TwoSat(N)

    # 節 a, b の距離が D 以下の場合，
    # a -> -b つまり -a or -b が成立しなければならない
    for i, (x_i, y_i) in enumerate(flags, 1):
        for j, (x_j, y_j) in enumerate(flags[i:], i+1):
            if abs(x_i - x_j) < D:
                sat.add_constraint(-i, -j)
            if abs(y_i - x_j) < D:
                sat.add_constraint(i, -j)
            if abs(x_i - y_j) < D:
                sat.add_constraint(-i, j)
            if abs(y_i - y_j) < D:
                sat.add_constraint(i, j)
    if sat.run():
        print("Yes")
        print(*[x_i if sat.ans[i] else y_i for i, (x_i, y_i) in enumerate(flags)], sep="\n")
    else:
        print("No")


if __name__ == "__main__":
    main()


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

int main(){
    int K,R;
    cin >> K >> R ;
    /*std::to_string(A);*/
    if(K >= 10){
        cout << R << endl;
    }else{
        cout << R + 100*(10-K) << endl;
    }
    
}


Measured memory_bytes: 256
#include <cstdio>

using namespace std;

int main() {
    long long n, m, l, r, mid;
    
    scanf("%lld %lld", &n, &m);
    
    l = 0, r = 1e18, mid = (l + r) / 2;
    
    while (r - l > 1) {
        if (n >= mid) {
            if (m >= mid * 2) {
                l = mid;
                mid = (l + r) / 2;
            } else {
                r = mid;
                mid = (l + r) / 2;
            }
        } else {
            long long x = (mid - n) * 2;
            
            if (x <= m && m - x >= mid * 2) {
                l = mid;
                mid = (l + r) / 2;
            } else {
                r = mid;
                mid = (l + r) / 2;
            }
        }
    }
    
    printf("%lld\n", l);
    
    return 0;
}


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

using namespace std;

int main()
{
	int n;
	cin >> n;

	vector<pair<int, int >> a(n);
	for(int i = 0; i < n; ++i) {
		int ai;
		cin >> ai;
		a[i] = make_pair(i + 1, ai);
	}

	sort(a.begin(), a.end(), [](pair<int, int> x, pair<int, int> y){ return x.second < y.second;});

	for(auto &x : a) {
		cout << x.first << " ";
	}
}


Measured memory_bytes: 1536
import java.io.*;
import java.util.*;

public class Main {
    public static final long mod = (long)1e9+7;
    public static final long INF = Long.MAX_VALUE/2;
    public static final int inf = Integer.MAX_VALUE/2;

    static void solve(InputReader in, PrintWriter out){
        int d = in.ni();
        int t = in.ni();
        int s = in.ni();
        out.println(d<=t*s?"Yes":"No");
    }

    public static void main(String[] args){
        InputReader in = new InputReader(System.in);
        PrintWriter out = new PrintWriter(System.out);
        solve(in, out);
        out.close();
    }
    public static class InputReader{
        private BufferedReader br;
        private StringTokenizer st;
        public InputReader(InputStream is){
            br = new BufferedReader(new InputStreamReader(is));
            st = null;
        }
        public String ns(){
            if(st == null || !st.hasMoreTokens()){
                try{
                    st = new StringTokenizer(br.readLine());
                }catch (Exception e){
                    throw new RuntimeException(e);
                }
            }
            return st.nextToken();
        }
        public int ni(){
            return Integer.parseInt(ns());
        }
        public long nl(){
            return Long.parseLong(ns());
        }
        public double nd(){
            return Double.parseDouble(ns());
        }
        public char nc(){
            return ns().toCharArray()[0];
        }
        public int[] ni(int n){
            int[] a = new int[n];
            for (int i = 0; i < n; i++) {
                a[i] = ni();
            }
            return a;
        }
        public long[] nl(int n){
            long[] a = new long[n];
            for (int i = 0; i < n; i++) {
                a[i] = nl();
            }
            return a;
        }
        public double[] nd(int n){
            double[] a = new double[n];
            for (int i = 0; i < n; i++) {
                a[i] = nd();
            }
            return a;
        }
    }
}

Measured memory_bytes: 32912
class Bit:
    def __init__(self, n):
        self.size = n
        self.tree = [0] * (n + 1)
 
    def sum(self, i):
        s = 0
        while i > 0:
            s += self.tree[i]
            i -= i & -i
        return s
 
    def add(self, i, x):
        while i <= self.size:
            self.tree[i] += x
            i += i & -i
    
    def reset(self):
        t = self.tree
        for i in range(len(t)):
            t[i] = 0

get_ints = lambda: [int(st) for st in input().split()]
N=int(input())
inarr=get_ints()
sorted_in = sorted(inarr)
comb = N*(N+1) // 4

bit = Bit(2*N+1)
def binsearch(lft, rgt):
    half = (lft + rgt) // 2
    if lft >= half:
        return half
    summed = 0
    res = 0
    bit.reset()
    bit.add(N, 1)
    for x in inarr:
        value = 1 if x >= sorted_in[half] else -1
        summed += value
        count = bit.sum(N + summed)
        bit.add(N + summed, 1)
        res += count
    return binsearch(half, rgt) if res >= comb else binsearch(lft, half)

res = binsearch(0, N)
print(sorted_in[res])


Measured memory_bytes: 63984
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.System.*;

import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

    static void solve() throws Exception {
        String s = scanString(), t = scanString();
        int ans = 0;
        for (int i = 0; i < s.length(); i++) {
            if (s.charAt(i) != t.charAt(i)) ans++;
        }
        out.print(ans);
    }

    static int scanInt() throws IOException {
        return parseInt(scanString());
    }

    static long scanLong() throws IOException {
        return parseLong(scanString());
    }

    static String scanString() throws IOException {
        while (tok == null || !tok.hasMoreTokens()) {
            tok = new StringTokenizer(in.readLine());
        }
        return tok.nextToken();
    }

    static BufferedReader in;
    static PrintWriter out;
    static StringTokenizer tok;

    public static void main(String[] args) {
        try {
            in = new BufferedReader(new InputStreamReader(System.in));
            out = new PrintWriter(System.out);
            solve();
            in.close();
            out.close();
        }
        catch (Throwable e) {
            e.printStackTrace();
            exit(1);
        }
    }
}

Measured memory_bytes: 37388
n, k = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort
f = gets.split.map(&:to_i).sort_by{|e| -e}

a.map!.with_index{|e, i| [e * f[i], f[i]]}
a.sort_by!{|e| -e[0]}

l = 0
r = a[0][0]

while l != r
    m = (l + r) / 2
    s = 0

    a.each do |x, y|
        break if s > k || x <= m
        s += (x - m).fdiv(y).ceil
    end

    s > k ? l = m + 1 : r = m
end

puts l

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

int main() {
	int a, b;
	char op;
	cin >> a >> op >> b;
	if (op == '+')
		cout << a + b << endl;
	else
		cout << a - b << endl;
	return 0;
}

Measured memory_bytes: 256
<?php

fscanf(STDIN,"%d%d",$n,$k);
$l = explode(" ",fgets(STDIN));

//liを長い順で並べなおす
 rsort($l);

$rsl = 0;

//0~kまでのものを足し算する
for ($i = 0; $i < $k; $i++){
    $rsl += $l[$i];
}

echo $rsl;

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

public class Main {

	public static void main(String[] args) throws IOException {

		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] input = br.readLine().split(" ");
		double x1 = Double.parseDouble(input[0]);
		double y1 = Double.parseDouble(input[1]);
		double x2 = Double.parseDouble(input[2]);
		double y2 = Double.parseDouble(input[3]);
		double distance = Math.sqrt((x1 - x2) * (x1 - x2) + (y1 - y2) * (y1 - y2));
		System.out.println(distance);
	}
}

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


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

    int K,N;
    cin >> N >> K;
    double p[N];
    rep(i,N) cin >> p[i];
    double r[N+1];
    r[0]=0;
    rep(i,N) r[i+1]=r[i]+(p[i]+1)/2;
    double ans=0.0;
    double sum=0;
    rep(i,N-K+1){
        ans=max(ans,r[i+K]-r[i]);
    }
    cout << fixed << setprecision(14);
    cout << ans << endl;

}

Measured memory_bytes: 3456
n,a,b=map(int,input().split())
mod=int(1e9+7)
def nCr(a,b):
  global mod
  res = 1
  for i in range(1,b+1):
    res = res * (n-i+1) % mod * pow(i,mod-2,mod) % mod
  return res%mod
print((pow(2,n,mod) - 1 - nCr(n,a) - nCr(n,b) + 2*mod ) % mod)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
typedef long long ll; 
const ll mod = 1e9+7;
#define fo(i, n) for (int i = 0; i < n; i++)
#define sc(n) scanf("%d", &n) 
using namespace std;

int n;

void solve() {
    cin >> n;
    int times[n];
    pair<int, int> deadlines[n];
    fo(i, n) {
        scanf("%d %d", &times[i], &deadlines[i].first);
        deadlines[i].second = i;
    }
    sort(deadlines, deadlines+n);
    int t = 0;
    fo(i, n) {
        t += times[deadlines[i].second];
        if (t > deadlines[i].first) {
            cout << "No";
            return;
        }
    }
    cout << "Yes";

}

int main() {
    int t = 1;
    //scanf("%d", &t);
    while (t--) {
        solve();
    }
    return 0;
}

Measured memory_bytes: 2560
/* ****TCIITB**** */

    #include<bits/stdc++.h>
    #define io          ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0); 
    #define ll          long long
    #define pb          push_back
    #define    endl        '\n'
    #define pii         pair<ll int,ll int>
    #define vi          vector<ll int>
    #define all(a)      (a).begin(),(a).end()
    #define F           first
    #define S           second
    #define sz(x)       (ll int)x.size()
    #define hell        1000000007
    #define rep(i,a,b)    for(ll int i=a;i<b;i++)
    #define lbnd        lower_bound
    #define ubnd        upper_bound
    #define bs          binary_search
    #define mp          make_pair
    #define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
    using namespace std;

    #define N  100005

    int main()
    {
        
        io

        ll n,m;
        cin>>n>>m;
        ll ts=0;
        rep(i,0,m)
        {
            ll x;
            cin>>x;
            ts+=x;
        }
        if(ts>n)
            cout<<"-1";
        else
            cout<<(n-ts);
        
    }

Measured memory_bytes: 3656
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

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

int main(){
	double x1,y1,x2,y2,xq,yq;
	double m,x,y,c;
	scanf("%lf %lf %lf %lf",&x1,&y1,&x2,&y2);
	int q;
	cin>>q;
	for(int i =0;i < q;i++){
		scanf("%lf %lf",&xq,&yq);
		if(x2==x1){
			double xr,yr;
			xr =xq*-1;
			yr =yq;
			//xq *=-1;
			x =(xr+xq)/2;
			y =(yr+yq)/2;
			printf("%.9f %.9f\n",x,y);
		}else{
			m = (y2-y1)/(x2-x1);
			c = y2-m*x2;
			x = (2*m*yq-xq*(m*m-1)-2*m*c)/(m*m+1);
			y = (2*m*xq+yq*(m*m-1)+2*c)/(m*m+1);
			x =(x+xq)/2;
			y =(y+yq)/2;
			printf("%.9f %.9f\n", x, y);
		}
	}
	return 0;
}

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

#define REP(i, n) for(int64_t i = 0; i < n; i++)
#define REPR(i, n) for(int64_t i = n; i >= 0; i--)
#define FOR(i, m, n) for(int64_t i = m; i < n; i++)
#define FORR(i, m, n) for(int64_t i = m; i >= n; i--)
#define ALL(v) v.begin(), v.end()
typedef long long ll;
template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    fill( (T*)array, (T*)(array+N), val );
}
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 INF= 1ll << 60;
const ll MOD = 1000000007;
double EPS = 1e-10;
//----------------------------------------------------------

double n, r;


int main(){
    cin >> n;
    cout << ceil(n/2) << endl;
    return 0;
}

Measured memory_bytes: 256
while True:
    A,op,B = input().split()
    A,B = map(int,[A,B])
    if op == "+":
        print(A + B)
    elif op == "-":
        print(A - B)
    elif op == "*":
        print(A * B)
    elif op == "/":
        print(A // B)
    else:
        break


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

int main(){
    int n;
    cin >> n;
    long long a[n];
    for(int i = 0; i < n; i++){
        cin >> a[i];
    }
    long long count = 0;
    for(int i = 0; i < n ; i++){
        for(int j = 1; ; j++){
            int x = pow(2,j);
            if(a[i] % x == 0){
                count++;
            }else{
                break;
            }
        }
    }
    cout << count << endl;
    return 0;
}

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

int main(){
  int W, H;
  cin>>W>>H;

  int x, y, r;
  cin>>x>>y>>r;

  if(x - r >= 0 && y - r >= 0 && x + r <= W && y + r <= H)
    cout<<"Yes"<<endl;
  else cout<<"No"<<endl;
  return 0;
}



Measured memory_bytes: 3120
#include<utility>
#include<iostream>
#include<string>
#include<algorithm>
#include<set>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#include<cmath>
#include<numeric>
#include<cassert>
#include<random>
using namespace std;
#define MK make_pair
#define F first
#define S second
#define ege pair<int,pair<int,int>> //w,s,t
const int MX=1e9+7;

int a[11000];

int search(int c){
    if(a[c]==c){return c;}
    a[c]=search(a[c]);
    return a[c];
}




int main(){
    int v,e;
    int W=0;
    for(int i=0;i<11000;i++){
        a[i]=i;
    }
    priority_queue<ege> E;
    cin>>v>>e;
    for(int i=0;i<e;i++){
        int s,t,w;
        cin>>s>>t>>w;
        E.push({-1*w,{s,t}});
    }
    while(!E.empty()){
        ege t=E.top();
        E.pop();
        int sp=search(t.S.F);
        int tp=search(t.S.S);
        if(sp==tp){continue;}
        a[sp]=tp;
        W-=t.F;
    }
    cout<<W<<endl;
    
    return 0;
}


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

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

    bool flag = true;
    if (S.at(0) != 'A') {
        flag = false;
    }

    int res = 0;
    for (int i = 2; i < S.size() - 1; i++) {
        if (S.at(i) == 'C') {
            res++;
        }
    }
    if (res != 1) {
        flag = false;
    }

    for (int i = 0; i < S.size(); i++) {
        if (S.at(i) == 'A' || S.at(i) == 'C') {
            continue;
        }
        else if (S.at(i) >= 'a' && S.at(i) <= 'z') {
            continue;
        }
        else {
            flag = false;
        }
    }

    if (flag) {
        cout << "AC" << endl;
    }
    else if (!flag) {
        cout << "WA" << endl;
    }
}

Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <tuple>
#include <stack>
#include <bitset>

#define MAX_N 1001
#define MAX_K 1001
using namespace std;
typedef long long ll;
ll p[MAX_N];

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

    ll N, K;
    cin >> N >> K;
    for (ll i = 0; i < N; i++) cin >> p[i];

    sort(p, p + N);
    ll ans = 0;
    for (ll i = 0; i < K; i++) {
      ans += p[i];
    }
    cout << ans << endl;
    
    return 0;
}
    


Measured memory_bytes: 3116
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define pb push_back
#define fi first
#define se second
typedef pair<ll,ll> P;
#define Mod 1000000007
using VP = vector<P>; using VVP = vector<VP>;
using VI = vector<ll>; using VVI = vector<VI>; using VVVI = vector<VVI>;
#define INF 1ll<<59

int main(){
  ll i,j;
  ll n,k;
  cin>>n>>k;
  if(k==0) {
    cout<<n*n<<endl;
    return 0;
  }
  ll ans=0;
  for(i=k+1;i<=n;i++){
    j=n/i;
    ans+=(i-k)*j;
    ans+=max(0ll,n-i*j-k+1);
  }
  cout<<ans<<endl;
  return 0;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6+10;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl
#define doublecout(a) cout<<fixed<<setprecision(15)<<a<<endl;
#define Cerr(x) cerr<<(x)<<endl
#define fi first
#define se second
#define P pair<ll,ll> 
#define m_p make_pair
#define V vector<ll> 
#define U_MAP unordered_map<ll,ll>

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

//------ 自分を天才だと信じる ------

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

    cin>>a>>s;
    if(a>=3200)Cout(s);
    else Cout("red");
    return 0;
}


Measured memory_bytes: 256
#!/usr/bin/env python
# coding: utf-8

import queue

def readInt():
    return int(input())

def readList():
    return list(input().split())

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

def main():
    n = readInt()
    edges = {}
    edges2 = []
    links = {}
    leaf = queue.Queue()
    for _ in range(n-1):
        a, b = readListI()
        a -= 1
        b -= 1
        edges.setdefault(a, set())
        edges.setdefault(b, set())
        edges[a].add(b)
        edges[b].add(a)
        links.setdefault(a, 0)
        links.setdefault(b, 0)
        links[a] += 1
        links[b] += 1
        edges2.append((a, b))
    for e, l in links.items():
        if l == 1:
            leaf.put(e)
    lc = sorted(readListI())
    ret = {}
    for c in lc:
        e = leaf.get()
        ret[e] = c
        for e2 in edges[e]:
            if e2 in links:
                links[e2] -= 1
                if links[e2] == 1:
                    leaf.put(e2)
    ans = 0
    for a, b in edges2:
        ans += min(ret[a], ret[b])
    print(ans)
    print(" ".join(map(str, [v for e, v in sorted(ret.items())])))


if __name__ == '__main__':
    main()


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

typedef pair<int, int> P;
const int INF = 100000000;

int N,M;
int sx,sy;
int gx,gy;
char maze[1005][1005];

int d[1005][1005];

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

int bfs(){
    queue<P> que;
    for (int i=0;i<=N;i++)
        for (int j=0;j<=M;j++) d[i][j] = INF;
    que.push(P(sx,sy));
    d[sx][sy] = 0;

    while (que.size()){
        P p = que.front();
        que.pop();

        if (p.first==gx && p.second == gy) break;

        for (int i=0;i<4;i++){
            int nx = p.first + dx[i], ny = p.second + dy[i];
            if (0 <= nx && nx < N && 0<= ny && ny < M && maze[nx][ny] != 'X' &&
                    d[nx][ny]==INF){
                que.push(P(nx,ny));
                d[nx][ny] = d[p.first][p.second] + 1;
            }
        }
    }
    return d[gx][gy];
}

int main(){
    int res = 0;
    int num;
    cin >> N >> M >> num;
    for (int i =0;i<N;i++){
        cin >> maze[i];
    }
    int checkx[10],checky[10];
    for (int i = 0; i< N; i++){
        for (int j = 0; j< M; j++){
            if (maze[i][j]=='S') {checkx[0]=i;checky[0]=j;}
            if (maze[i][j]=='1') {checkx[1]=i;checky[1]=j;}
            if (maze[i][j]=='2') {checkx[2]=i;checky[2]=j;}
            if (maze[i][j]=='3') {checkx[3]=i;checky[3]=j;}
            if (maze[i][j]=='4') {checkx[4]=i;checky[4]=j;}
            if (maze[i][j]=='5') {checkx[5]=i;checky[5]=j;}
            if (maze[i][j]=='6') {checkx[6]=i;checky[6]=j;}
            if (maze[i][j]=='7') {checkx[7]=i;checky[7]=j;}
            if (maze[i][j]=='8') {checkx[8]=i;checky[8]=j;}
            if (maze[i][j]=='9') {checkx[9]=i;checky[9]=j;}
        }
    }

    for (int i =0;i<num;i++){
        sx = checkx[i];
        sy = checky[i];
        gx = checkx[i+1];
        gy = checky[i+1];
        res += bfs();
    }
    cout << res << endl;
    return 0;
}


Measured memory_bytes: 7960
#include<stdio.h>
int main(void)
{
	int a, b, d, r;
	double f, fa, fb;
	scanf("%d%d", &a, &b);
	fa=a, fb=b;
	d=a/b; r=a%b; f=fa/fb;
	printf("%d %d %7.5f\n", d, r, f);
	return 0;
}

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

answer = [(97, 'a')]
for _ in range(N - 1):
    new_answer = []
    for i, j in answer:
        for k in range(97, i + 1):
            new_answer.append((i, j + chr(k)))
        new_answer.append((i+1,j+chr(i+1)))
    answer = new_answer[:]

answer = [j for _, j in answer]
answer.sort()
print('\n'.join(answer))


Measured memory_bytes: 24040