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

using namespace std;

//#define FILE_IO

typedef long long LL;

int N, M;
int v[100005];

class BinaryIndexedTree
{
public:
    LL aib[100005];

    void U(int pos, LL val)
    {
        for(; pos <= M; pos += (pos & (-pos)))
            aib[pos] += val;
    }

    void update(int st, int dr, LL val)
    {
        if(st > dr) return;
        U(st, val);
        U(dr + 1, -val);
    }

    LL Q(LL pos)
    {
        LL ans = 0;
        for(; pos > 0; pos -= (pos &(-pos)))
            ans += aib[pos];
        return ans;
    }
}A, B;

int main()
{
    #ifdef FILE_IO
    freopen("1.in", "r", stdin);
    freopen("1.out", "w", stdout);
    #endif

    scanf("%d%d", &N, &M);
    for(int i = 1; i <= N; i++)
        scanf("%d", &v[i]);

    for(int u = 1; u < N; u++)
    {
        int p1 = v[u];
        int p2 = v[u + 1];

        if(p1 < p2)
        {
            B.update(1, p1, p2 - p1);

            A.update(p1 + 1, p2, -1);
            B.update(p1 + 1, p2, p2 + 1);

            B.update(p2 + 1, M, p2 - p1);
        }
        else
        {
            A.update(1, p2, -1);
            B.update(1, p2, p2 + 1);

            B.update(p2 + 1, p1, M - p1 + p2);

            A.update(p1 + 1, M, -1);
            B.update(p1 + 1, M, M + p2 + 1);
        }
    }

    LL mn = 1LL << 60;
    for(int i = 1; i <= M; i++)
    {
        LL a = A.Q(i);
        LL b = B.Q(i);
        LL x = 1LL * A.Q(i) * i + B.Q(i);
        mn = min(mn, x);
    }

    printf("%lld\n", mn);

    return 0;
}


Measured memory_bytes: 2176
#include <iostream>
#include <vector>
#include <deque>
#include <climits>
#include <cmath>
#include <algorithm>
#include <string>
using namespace std;
#define ll long long int
#define ld long long double
#define vi vector<long long int>
#define vc vector<char>
#define vs vector<string>
#define pb push_back
#define mp make_pair
#define f(i,a,n) for(i = (a); i < (n); i++)
#define fi(i,a,n) for(i = (a); i <= (n); i++)
#define F first
#define S second

vector<vector< pair<long long int,long long int>>> v;
vector<long long int> vis;

deque<long long int> p;

void bfs(ll x){
    p.pb(x);
    vis[x] = 0;

    while(p.size()){
        ll y = p[0];
        p.pop_front();
        ll z = vis[y];
        for(ll i=0;i<v[y].size();i++){
            ll t = v[y][i].first;
            ll d = v[y][i].second;
            if(vis[t]==-1){
                if(d%2==0){
                    vis[t] = z;
                }
                else{
                    if(z==0){
                        vis[t] = 1;
                    }
                    else{
                        vis[t] = 0;
                    }
                }
                p.pb(t);
            }

        }
    }
}

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

    ll n;
    cin>>n;

    v.resize(n+1);
    vis.resize(n+1,-1);

    for(ll i=1;i<n;i++){
        ll x,y,z;
        cin>>x>>y>>z;
        v[x].pb(make_pair(y,z));
        v[y].pb(make_pair(x,z));
    }

//    for(ll i=1;i<=n;i++){
//        cout<<i<<" || ";
//        for(ll j=0;j<v[i].size();j++){
//            cout<<"("<<v[i][j].first<<","<<v[i][j].second<<") | ";
//        }
//        cout<<endl;
//    }


    bfs(1);

    for(ll i=1;i<=n;i++){
        cout<<vis[i]<<endl;
    }


}

Measured memory_bytes: 8704
//...Bismillahir Rahmanir Rahim...
// Code by    Asad Bin Saber

#include <bits/stdc++.h>

using namespace std;

// typedefs...
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> pii;
typedef pair<int, pii> piii;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> pll;

// constants...
const double PI = acos(-1);

// defines...
#define MP make_pair
#define PB push_back
#define fi first
#define se second
#define si(a) scanf("%d", &a)
#define sii(a, b) scanf("%d%d", &a, &b)
#define siii(a, b, c) scanf("%d%d%d", &a, &b, &c)
#define sl(a) scanf("%lld", &a)
#define sll(a, b) scanf("%lld%lld", &a, &b)
#define slll(a, b, c) scanf("%lld%lld%lld", &a, &b, &c)

ll gcd(ll a, ll b) {
    while (b) {
        a %= b;
        swap(a, b);
    }
    return a;
}
ll lcm(ll a, ll b)
{
    return (a/gcd(a, b)*b);
}
ll comb(ll a, ll b)
{
    ll x = max(a-b, b), ans=1;

    for(ll K=a, L=1; K>=x+1; K--, L++){
        ans *= K;
        ans /= L;
    }

    return ans;
}


void task()
{
    //code here...
    
    int n, mid;
    
    cin >> n;
    vi ara, mark(n+1);
    
    for(int K=1; K<=100; K++){
		for(int L=1; L<=100; L++){
			for(int M=1; M<=100; M++){
				mid = (K+L)*(K+L) + (L+M)*(L+M) + (M+K)*(M+K);
				if(mid%2==0 && mid<=2*n) mark[mid/2]++;
			}
		}
	}
	
	for(int K=1; K<=n; K++){
		if(mark[K]) cout << mark[K] << "\n";
		else cout << 0 << "\n";
	}
}


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

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

    task();

    return 0;
}




Measured memory_bytes: 3584
n, m = map(int, input().split())
ab = [tuple(map(int, input().split())) for _ in range(m)]

graph = {x:[] for x in range(1, n+1)}
for x, y in ab:
    graph[x] = graph.get(x, []) + [y]
    graph[y] = graph.get(y, []) + [x]

res = 0
for a, b in ab:
    graph[a].remove(b)
    graph[b].remove(a)
    stack = [1]
    visited = []
    while len(stack) > 0:
        v = stack.pop()
        visited.append(v)
        for next in graph[v]:
            if next in visited:
                continue
            if next in stack:
                continue
            stack.append(next)
    if len(visited) != n:
        res += 1
    graph[a].append(b)
    graph[b].append(a)

print(res)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
using namespace std;
//#define  ONLINE_JUDGE 1
int main()
{
	/*
	#ifdef ONLINE_JUDGE
	freopen("C:/Users/wyx/Desktop/Amy/wangyixuan/c++/test data/data.txt", "r",stdin);
	#endif
	*/
	/*---------------Begin code---------------*/
	int n;
	double m;
	cin>>n;
	m=2*n*3.1415926535898;
	cout<<m;
	/*---------------End  code----------------*/
	/*
	#ifdef ONLINE_JUDGE
	fclose(stdin);
	#endif
	system("pause");
	*/
	return 0;
}


Measured memory_bytes: 3716
#include <bits/stdc++.h>
using namespace std;
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
// Welcome to my source code!

int main() {
    int n, a;
    cin >> n;
    set<int> s;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if (s.find(a) == end(s)) {
            s.insert(a);
        } else {
            s.erase(a);
        }
    }
    cout << s.size() << endl;
}

Measured memory_bytes: 4864
#include<iostream>
#include<stdio.h>
#include<string.h>
#define N 2200
using namespace std;
char s[N];
int n,m,q,a[N][N];
int cnt_up[N][N],cnt[N][N],sum[N][N],cnt_left[N][N];
int pre(){
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			sum[i][j]=sum[i][j-1]+a[i][j];
		}
	}
	for(int i=1;i<=n;i++)
		for(int j=1;j<=m;j++)
			cnt[i][j]=cnt[i-1][j]+sum[i][j];
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			sum[i][j]=sum[i][j-1]+(a[i][j]&a[i][j-1]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cnt_up[i][j]=cnt_up[i-1][j]+sum[i][j];
		}
	}
	memset(sum,0,sizeof(sum));
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			sum[i][j]=sum[i][j-1]+(a[i][j]&a[i-1][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			cnt_left[i][j]=cnt_left[i-1][j]+sum[i][j];
		}
	}
}
int cal(int xa,int ya,int xb,int yb){
	return cnt[xb][yb]-cnt[xa-1][yb]-cnt[xb][ya-1]+cnt[xa-1][ya-1];
}
int cal_up(int xa,int ya,int xb,int yb){
	return cnt_up[xb][yb]-cnt_up[xa-1][yb]-cnt_up[xb][ya]+cnt_up[xa-1][ya];
}
int cal_left(int xa,int ya,int xb,int yb){
	return cnt_left[xb][yb]-cnt_left[xa][yb]-cnt_left[xb][ya-1]+cnt_left[xa][ya-1];
}
int main(){
	scanf("%d%d%d",&n,&m,&q);
	for(int i=1;i<=n;i++){
		scanf("%s",s+1);
		for(int j=1;j<=m;j++)a[i][j]=(s[j]=='1');
	}
	pre(); 
	for(int i=1;i<=q;i++){
		int xa,ya,xb,yb;
		scanf("%d%d%d%d",&xa,&ya,&xb,&yb);
		int ans=cal(xa,ya,xb,yb)-cal_up(xa,ya,xb,yb)-cal_left(xa,ya,xb,yb);
		printf("%d\n",ans);
	}
}

Measured memory_bytes: 96000
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define l long
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ff first
#define ss second
#define pii pair <int,int>
#define pll pair <ll,ll>
#define testcase() int t; cin>>t; while(t--)

ll M = 1e9 + 7;
ll powerm(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x)%M; y=y>>1; x=(x*x)%M;} return res%M; }
ll power(ll x,ll y){ ll res=1; while(y){ if(y&1) res=(res*x); y=y>>1; x=(x*x);} return res; }
ll max3(ll a,ll b,ll c){ return max( max(a,b),c ); }
ll gcd(ll a,ll b){if(b>a)return gcd(b,a); if(b==0)return a; return gcd(b,a%b);}
const int N = 1e5 + 5;
vector <int> adj[N];
bool vis[N];
int h[N];
int ans;

void dfs(int u)
{
    vis[u] = 1; bool ok=1;
    for(auto it:adj[u])
    {
        if( h[u] <= h[it] )
        {
            ok=0; break;
        }
    }
    if(ok) ans++;
    for(auto it:adj[u])
    {
        if(vis[it]) continue;
        dfs(it);
    }
}


int main() {
	
	//ifstream cin("input.txt");
	//ofstream cout("output.txt");
	ios_base::sync_with_stdio(false); 
    cin.tie(NULL); 
	
	int n,m; cin>>n>>m;
	for(int i=1;i<=n;i++) cin>>h[i];
	for(int i=0;i<m;i++)
	{
	    int u,v; cin>>u>>v;
	    adj[u].pb(v); adj[v].pb(u);
	}
	
	for(int i=1;i<=n;i++)
	{
	    if(vis[i]) continue;
	    dfs(i);
	}
	cout<<ans;
	
	return 0;
}


Measured memory_bytes: 10092
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>

#define rep(i,n) for(int i=0;i<n;i++)
#define rep2(i, s, n) for(int i=s; i<n; i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<int>>;
//	std::cout<<std::fixed<<std::setprecision(10);


int main() {
  double A, B;
  cin >> A >> B;

  double a_mini, b_mini;
  int ans;
  double a_max, b_max;

  a_mini = (A / 0.08);
  a_max = (A + 1) / 0.08;
  b_mini = (B / 0.10);
  b_max = (B + 1) / 0.10;

  ans = ceil(max(a_mini, b_mini));
  if(ans<a_max && ans <b_max) {
    cout << ans << endl;
  } else {
    cout << -1 << endl;
  }

  return 0;
}


Measured memory_bytes: 256
//inlclude前用define 
#define _USE_MATH_DEFINES

//include
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<cmath>
#include<type_traits>
#include<numeric>
//#include<deque>
#include<iomanip>
#include<set>
#include<tuple>
#include<map>
#include<limits>

using namespace std;

//typedef
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<char> VC;
typedef long long int ll;

//define
#define INF 1e9 
#define NUM 1000000007
#define all(x) begin(x), end(x)
#define rep(i,n) for(int i=0;i<(int)(n);i++)

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

  VI x(n),y(n);
  rep(i,n){
      cin>>x[i]>>y[i];
  }
  
  VI v(n);
  double tmp,dist,ave,ans=1e9;
  int cnt=0;
  iota(v.begin(),v.end(),0);
  do{
      /*for(int i=0;i<n;i++){
          cout<<v[i]<<" ";
          if(i==n-1) cout<<"\n";
      }*/
      for(int i=0;i<n-1;i++){
          tmp=pow(x[v[i]]-x[v[i+1]],2)+pow(y[v[i]]-y[v[i+1]],2);
          dist+=sqrt(tmp);
          //cout<<sqrt(tmp)<<endl;
      }
      cnt++;
      
  }while(next_permutation(v.begin(),v.end()));
  cout<<std::setprecision(10)<<dist/cnt<<endl;
}



Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define int long long
using namespace __gnu_pbds;
using namespace std;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;


signed main()
{
     ios_base::sync_with_stdio(false);
     cin.tie(NULL);  
//  #ifndef ONLINE_JUDGE
//     freopen ("INPUT.txt" , "r" , stdin);
//     freopen ("OUTPUT.txt" , "w" , stdout);
//  #endif
 
// -------------------------------------Code starts here---------------------------------------------------------------------     

   string s;
   cin>>s;
   int n=s.length();
   for(int i=0;i<n;i++)
      cout<<'x';

// -------------------------------------Code ends here------------------------------------------------------------------
     clock_t clk;
 	clk = clock();
 
    clk = clock() - clk;
 	cerr << fixed << setprecision(6) << "Time: " << ((double)clk)/CLOCKS_PER_SEC << "\n";
 	return 0;
 }


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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,ans=0;cin>>n;
    vector<int> p(n);
    rep(i,n)cin>>p[i];
    rep(i,n-1){
        if(p[i]==i+1){
            swap(p[i],p[i+1]);
            ans++;
        }
    }
    if(p[n-1]==n)ans++;
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 640
import std.stdio, std.array, std.string, std.conv, std.algorithm;
import std.typecons, std.range, std.random, std.math, std.container;
import std.numeric, std.bigint, core.bitop, std.bitmanip;

immutable long MOD = 10^^9 + 7;

void main() {
    auto N = readln.chomp.to!int;
    auto G = new int[][](N);
    foreach (i; 0..N-1) {
        auto s = readln.split.map!(to!int);
        G[s[0]-1] ~= s[1]-1;
        G[s[1]-1] ~= s[0]-1;
    }

    auto mem = new long[][](N, 2);
    auto used = new bool[][](N, 2);

    long dfs(int n, int p, bool b) {
        if (used[n][b]) return mem[n][b];
        long bb = 1;
        long ww = 1;
        long retb = 1;
        long retw = 1;
        if (b) retb = 0;
        foreach (m; G[n]) {
            if (m == p) continue;
            retw *= ww * dfs(m, n, false) % MOD;
            retb *= bb * dfs(m, n, true) % MOD;
            retw %= MOD;
            retb %= MOD;
        }
        used[n][b] = true;
        mem[n][b] = (retw + retb) % MOD;
        return mem[n][b];
    }

    dfs(0, -1, 0).writeln;
}


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

int main(){
  int N;
  string s,t;
  cin >> N >> s >> t;
  
  string ans="";
  
  for(int i=0;i<N;i++){
    ans += s.at(i);
    ans += t.at(i);
  }
  cout << ans;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include <iomanip>
#include<cmath>
#include<stdio.h>
#include<map>
#define rep(i,n) for(int i=0;i<(n);i++)
#define ll long long
#define sort(s) sort(s.begin(),s.end())
#define r(s) reverse(s.begin(),s.end())
#define please return
constexpr auto AC = 0;
using namespace std;

int main() {
	int a, b;
	int ans = 0;
	cin >> a >> b;
	for (int i = 11; i <= b; i++) {
		int n = i / 10;
		int m = i % 10;
		if (n>1&&m>1&&n * m <= a && n * m > 0)ans++;
	}
	cout << ans << endl;
	please AC;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int H,W,K;
int x,y;
int d;
int m[111][111];
vector<int>v;
int main(){
    cin>>H>>W>>K;
    for(int i=1;i<=K;i++){
        int z;
        cin>>z;
        while(z--){
            m[x][y]=i;
            if(d==0)y++;
            else y--;
            if(y==W)d=1-d,x++,y--;
            if(y==-1)d=1-d,x++,y++;
        }
    }
    for(int i=0;i<H;i++){
        for(int j=0;j<W;j++){
            cout<<m[i][j]<<' ';
        }
        cout<<'\n';
    }
    return 0;
}


Measured memory_bytes: 384
#include <functional>
#include <stdexcept>
#include <streambuf>
#include <exception>
#include <algorithm>
#include <iostream>
#include <iterator>
#include <typeinfo>
#include <utility>
#include <complex>
#include <numeric>
#include <climits>
#include <cstring>
#include <cstdlib>
#include <fstream>
#include <sstream>
#include <cassert>
#include <iomanip>
#include <cstring>
#include <locale>
#include <memory>
#include <iosfwd>
#include <string>
#include <bitset>
#include <cstdio>
#include <limits>
#include <vector>
#include <cmath>
#include <ctime>
#include <deque>
#include <queue>
#include <stack>
#include <list>
#include <map>
#include <ios>
#include <new>
#include <set>
 
#define int long long
#define ll long long 
#define F first
#define S second
#define make make_pair
#define pb push_back
#define sz(x) (ll)(x.size()) 
#define all(x) x.begin (), x.end ()

using namespace std;

typedef long double ld;

const int MOD = (int)1e9 + 7;
const int N = (int)1e5 * 5 + 22;
const ll INF = (ll)1e18;
const double eps = (double)1e-6;

int n, m, a[N], b[N], c[1111][1111];
int dp[N];


signed main () {
    #ifdef Maga
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cin >> n >> m;
    for (int mask = 0; mask <= (1 << n) - 1; ++mask){
        dp[mask] = INF;
    }
    dp[0] = 0;
    for (int i = 1; i <= m; ++i) {
        cin >> a[i] >> b[i];
        for (int j = 1; j <= b[i]; ++j) {
            cin >> c[i][j];
        }
    }
    for (int i = 1; i <= m; ++i) {
        for (int mask = 0; mask <= (1 << (n)) - 1; ++mask) {
            int x = mask;
            for (int j = 1; j <= b[i]; ++j) {
                x = (x | (1 << (c[i][j] - 1)));
            }
            dp[x] = min(dp[mask] + a[i], dp[x]);
        }
    }
    if (dp[(1 << n) - 1] >= INF) cout << -1;
    else
    cout << dp[(1 << (n)) - 1];

    
    return 0;
}   

Measured memory_bytes: 14592
#include <iostream>
using namespace std;
int main(){
    int x,y;
    while(cin>>x&&cin>>y){
        if(x==0&&y==0){
            break;
        }
        if(x>y){
            cout<<y<<" "<<x<<endl;
        }
        else{
            cout<<x<<" "<<y<<endl;
        }
    }
    return 0;
}



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

#define pb push_back
#define mp make_pair
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef complex<double> point;
typedef double DOUBLE;
#define xx real()
#define yy imag()

#define REP(i, a, b) for(int i = (a); i < (int)(b); i++)
#define REPN(i, a, b) for(int i = (a); i <= (int)(b); i++)
#define FA(it, x) for(__typeof((x).begin()) it = (x).begin(); it != (x).end(); it++)
#define SZ(x) (int)(x).size()
#define BE(x) (x).begin(), (x).end()
#define SORT(x) sort(BE(x))
#define _1 first
#define _2 second

#define x1 gray_cat_x1
#define y1 gray_cat_y1

template<class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

#define file "I1"

const double EPS = 1e-9;
const double PI = acos(-1.);
const int INF = 1e9 + 10;
const ll MOD = 1e9 + 7;

const int MAXN = 2e5 + 5;
char s[3][MAXN];

set<char> st;

void solve(){
	int n;
	scanf("%d", &n);
	REP(i, 0, 3) {
		scanf("%s", &s[i][0]);
	}
	int ans = 0;
	REP(i, 0, n) {
		st.clear();
		REP(j, 0, 3) {
			st.insert(s[j][i]);
		}
		ans += SZ(st) - 1;
	}
	printf("%d\n", ans);
}   

int main(){

    //freopen(file".in", "r", stdin); freopen(file".out", "w", stdout);
    int t = 1;
    //cin >> t;
    while(t--){
        solve();    
    }
}


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

using namespace std;

using PII = pair<int,int>;
#define MP make_pair
#define FF first
#define SS second

double P, X;
int N;
vector<PII> G[100010];

double dfs1(int u, int p){
  double res = 0.;
  for(auto e: G[u]){
	if(e.FF == p) continue;
	res += P * (e.SS + dfs1(e.FF, u));
  }
  
  return res;
}

double dfs2(int u, int p){
  double res = X;
  for(auto e: G[u]){
	if(e.FF == p) continue;
	res += P * (e.SS + dfs2(e.FF, u));
  }
  
  return res;
}

int main(){
  cin >> P;
  cin >> N;
  for(int i=0;i<N-1;++i){
	int u, v, c;
	cin >> u >> v >> c;
	--u;
	--v;
	G[u].push_back(MP(v,c));
	G[v].push_back(MP(u,c));
  }

  X = dfs1(0, -1);
  cout << fixed << setprecision(9) << dfs2(0, -1) << endl;
  
  return 0;
}

Measured memory_bytes: 15004
/**
 *    author  : 𝒌𝒚𝒐𝒎𝒖𝒌𝒚𝒐𝒎𝒖𝒑𝒖𝒓𝒊𝒏
 *    created : 2019-12-29 23:28:35
**/

#include <iostream>
#include <deque>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
#include <complex>
#include <numeric>
#include <bitset>
#include <cassert>
#include <cctype>
#include <iomanip>
#include <random>
#include <utility>
#include <chrono>

using namespace std;

using int64 = long long;
template<class T> ostream& operator<<(ostream& os, vector<T>& _) { os << '{'; for (T& x : _) { os << x; if (&x != &_.back()) os << ','; } os << '}'; return os; }
template<class T, class U> ostream& operator<<(ostream& os, pair<T, U>& p) { return os << '{' << p.first << " " << p.second << '}'; }

#ifdef LOCAL
#define debug(_) cerr << #_ << ": " << (_) << '\n'
#else
#define debug(_) 1728
#endif

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

  int x; cin >> x;

  auto f = [](int n) -> bool {
    for (int i = 2; i * i <= n; ++i) {
      if (n % i == 0) return false;
    }
    return true;
  };

  while (1) {
    if (f(x)) {
      cout << x << endl;
      return 0;
    }
    ++x;
  }

  return 0;
}

Measured memory_bytes: 256
from collections import deque

if __name__ == '__main__':
    n, k = list(map(int, input().split(" ")))
    p = list(map(int, input().split(" ")))

    d = deque([0])
    for i in range(n):
        d.append(d[i] + p[i])

    # print(d)

    max_sum = 0
    rangeN = n - k + 1

    for i in range(rangeN):
        sum_d = d[i + k] - d[i]
        if max_sum < sum_d:
            max_sum = sum_d
    # print(max_sum)

    # r_array = [sum(p[i:i + k]) for i in range(rangeN)]
    print((max_sum + k) / 2)


Measured memory_bytes: 25572
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

int main(void){
  SPEEDUP
  cout << setprecision(15);
  int N,K,S;cin >> N >> K >> S;
  int ans = 1e9;
  if(S==ans) ans = 1;
  rep(i,N){
    if(i<K) cout << S SPF;
    else cout << ans SPF;
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 1280
#include <stdio.h>

int main(){
	int K, A, B;
	scanf("%d \n%d %d", &K, &A, &B);
	for (int i = A; i <= B; i++){
		if (i%K == 0){
			printf("OK");
			return 0;
		}
	}
	printf("NG");
return 0;
}

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

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

#define fr first
#define sc second

int main(){
	static int n;
	static int a[200010];
	static int b[200010];
	scanf("%d",&n);
	for(int i = 0 ; i < n ; i ++)scanf("%d",&a[i]);
	for(int i = 0 ; i < n ; i ++)scanf("%d",&b[i]);
	
	ll ret = 0;
	ll cnt = 0;
	for(int i = 0 ; i < n ; i ++){
		if(a[i] != b[i])cnt ++;
	}
	
	priority_queue<P> que;
	for(int i = 0 ; i < n ; i ++){
		que.push(P(b[i],i));
	}
	while(!que.empty()){
		P p = que.top(); que.pop();
		int l = p.sc-1; if(l == -1)l = n-1;
		int r = p.sc+1; if(r == n)r = 0;
		if(b[p.sc] <= b[l]+b[r])continue;
		if(a[p.sc] == b[p.sc])continue;
		if((b[p.sc]-a[p.sc])%(b[l]+b[r]) == 0){
			ret += (b[p.sc]-a[p.sc])/(b[l]+b[r]);
			b[p.sc] = a[p.sc];
			cnt --;
			if(cnt == 0)break;
			continue;
		}
		ret += b[p.sc]/(b[l]+b[r]);
		b[p.sc] %= b[l]+b[r];
		if(b[p.sc] < a[p.sc]){
			cout << -1 << endl;
			return 0;
		}
		//if(a[p.sc] == b[p.sc])cnt --;
		//if(cnt == 0)break;
		que.push(P(b[p.sc],p.sc));
		/*for(int i = 0 ; i < n ; i ++){
			cout << b[i] << " " ;
		}cout << endl;*/
	}
	
	for(int i = 0 ; i < n ; i ++){
		if(a[i] != b[i]){
			cout << -1 << endl;
			return 0;
		}
	}
	cout << ret << endl;
}

Measured memory_bytes: 3956
#include <iostream>
#include <math.h>
#include <algorithm>

using namespace std;

int main(void){
  long long int sum = 0, i = 1, n;
  cin >> n;
  while( i < n ){
    sum = sum + i;
    i++;
  }
  cout << sum << endl;
  
  return 0;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    string s, t;
    cin >> s >> t;
    for (int i = 0; i < n; i++)
    {
        cout << s[i] << t[i];
    }
    cout << "\n";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end())
#define VRSORT(v) sort(v.rbegin(), v.rend())
#define ll long long
#define pb(a) push_back(a)
#define INF 1000000000
#define MOD 1000000007
using namespace std;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef pair<int, P> PP;
typedef pair<ll, LP> LPP;

typedef vector<unsigned int>vec;
typedef vector<vec> mat;
//typedef tuple<ll, ll, ll> T;

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

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

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int x;cin>>x;
    int ans=1;
    for(int i=1;i<x;i++){
        for(int p=2;p<x;p++){
            int num = pow(i,p);
            if(num>x) break;
            chmax(ans,num);
        }
    }
    cout<<ans<<endl;
}


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

int xx1, yy1, xx2, yy2, xx3, yy3, xx4, yy4;

int main() {
    cin >> xx1 >> yy1 >> xx2 >> yy2;

    int dx = xx2 - xx1;
    int dy = yy2 - yy1;

    xx3 = xx2 - dy;
    yy3 = yy2 + dx;

    xx4 = xx1 - dy;
    yy4 = yy1 + dx;

    printf("%d %d %d %d\n", xx3, yy3, xx4, yy4);
}

Measured memory_bytes: 256
n =int(input())
A = list(map(int, input().split()))
ans = 1
flag = 0
sa = A[0]

for a in A:
    if a > sa:
        if flag != 2 :
            flag = 1
        else:
            ans += 1
            flag = 0
            
    elif a < sa:
        if flag != 1:
            flag = 2
        else:
            ans += 1
            flag = 0
    
    sa = a

print(ans)


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

int main(){
    int x, y, W, H, r;
    cin >> W >> H >> x >> y >> r;
    if(r <= x && W - r >= x && r <= y && H - r >= y){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

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

public class Main {
	public static void main(String arg[]) {

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		double v[] = new double[n];

		for (int i = 0; i < n; i++) {
			v[i] = sc.nextDouble();
		}
		sc.close();

		Arrays.sort(v);

		double s = (v[0] + v[1]) / 2;

		if (n >= 3) {
			for (int i = 2; i < n; i++) {

				s = (s + v[i]) / 2;

			}
		}
		System.out.println(s);

	}
}

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

int main()
{
    string s;
    cin >> s;
    int cnta, cntb, cntc;
    cnta = cntb = cntc = 0;
    for (int i=0; i<3; i++)
    {
        if (s[i] == 'a') cnta ++;
        if (s[i] == 'b') cntb ++;
        if (s[i] == 'c') cntc ++;
    }
    if (cnta == 1 && cntb == 1 && cntc == 1) cout << "Yes" << endl;
    else cout << "No" << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define FOR(i, a, n) for(int (i) = (int)(a); (i) < (int)(n); ++(i))
#define FORe(i, a, n) for(int (i) = (int)(a); (i) <= (int)(n); ++(i))
#define rFOR(i, a, n) for(int (i) = (int)(n)-1; (i) >= (int)(a); --(i))
#define rFORe(i, a, n) for(int (i) = (int)(n); (i) >= (int)(a); --(i))
#define REP(i, n) FOR((i), 0, (n))
#define REPe(i, n) FORe((i), 1, (n))
#define REPo(i, n) FORe((i), 0, (n))
#define rREP(i, n) rFOR((i), 0, (n))
#define rREPe(i, n) rFORe((i), 1, (n))
#define rREPo(i, n) rFORe((i), 0, (n))
#define rep(i, n) FOR((i), 0, (n))
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define fi first
#define se second
#define dup(x, y) (((x)+(y)-1)/(y))
#define vc(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
using ll = long long;
using P = pair<int,int>;
using pll = pair<ll,ll>;
using T = tuple<int,int,int>;
using vi = vector<int>;
using vvi = vector<vi>;
using vl = vector<ll>;
using vs = vector<string>;
using vp = vector<P>;
using vt = vector<T>;

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

// UnionFind
struct UnionFind {
  vector<int> d;
  UnionFind(int n=0): d(n,-1) {}
  int find(int x) {
    if (d[x] < 0) return x;
    return d[x] = find(d[x]);
  }
  bool unite(int x, int y) {
    x = find(x); y = find(y);
    if (x == y) return false;
    if (d[x] > d[y]) swap(x,y);
    d[x] += d[y];
    d[y] = x;
    return true;
  }
  bool same(int x, int y) { return find(x) == find(y);}
  int size(int x) { return -d[find(x)];}
};

int main() {
  int n,m;
  cin>>n>>m;
  UnionFind uf(n);
  REP(i, m) {
    int a, b;
    cin >> a >> b;
    uf.unite(a,b);
  }
  int ans = 0;
  REP(i, n) {
    chmax(ans, uf.size(i));
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 4056
#include <bits/stdc++.h>
#define pb push_back
#define S second
#define F first

using namespace std;
typedef long long ll;
#define int ll
typedef pair<int,int> pii;
const int maxn = 2e5 + 20;
const int mod  = 1e9  + 7;

int seq[maxn];
int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(false);
    int n;
    cin >> n;
    int mabs = 0;
    int ans = 0;
    for (int i = 1;i <= n;i++){
        cin >> seq[i];
        if (abs(seq[i]) > mabs){
            mabs = abs(seq[i]);
            ans = i;
        }
    }
    if (mabs == 0){
        cout << 0 << endl;
        return 0;
    }

    vector<pii> v;
    for (int i= 1;i <=n;i++){
        if (i == ans) continue;
        v.pb({ans,i});
    }
    if (seq[ans] > 0){
        for (int i = 2;i <= n;i++){
            v.pb({i - 1,i});
        }
    }else {
        for (int i = n;i > 1;i--){
            v.pb({i,i - 1});
        }
    }
    cout << v.size() << endl;
    for (pii p : v){
        cout << p.F << ' '<< p.S << endl;
    }
    return 0;
}


Measured memory_bytes: 256
using System;

class Program
{
    static void Main(string[] args)
    {
        var n = int.Parse(Console.ReadLine());
        var s = Console.ReadLine().Split(' ');

        var X = new int[n];
        var Y = new int[n];
        for (int i = 0; i < n; i++)
        {
            X[i] = int.Parse(s[i]);
            Y[i] = X[i];
        }

        Array.Sort(Y);

        var a = Y[n / 2 - 1];
        var b = Y[n / 2];

        for (int i = 0; i < n; i++)
        {
            if (a < X[i])
            {
                Console.WriteLine(a);
            }
            else
            {
                Console.WriteLine(b);
            }
        }
    }
}


Measured memory_bytes: 34248
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Math;

namespace A_ABC141
{
    class MainClass
    {

        static int[] s;

        public static void Main(string[] args)
        {
//            s = Array.ConvertAll(ReadLine().Split().ToArray(), int.Parse);
            string u = ReadLine();
            string ans = "Sunny";
            if(u=="Sunny"){
                ans = "Cloudy";
            }else if (u=="Cloudy"){
                ans = "Rainy";
            }
            WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13140
#include <iostream>
#include <iomanip>
#include <stdio.h>
int main(void){
    int a,b;
    double c,d;
    std::cin >> a>>b;
    c=a;
    d=b;
    std::cout<<std::fixed;
    std::cout << a/b<<" "<<a%b<<" "<<std::setprecision(5)<<c/d<<std::endl; //printf("%.5f\n",c/d);
}



Measured memory_bytes: 3280
#include<bits/stdc++.h>
using namespace std;
#define int long long

signed main(){
	int n, a, b;
	cin >> n >> a >> b;
	if(n == 1){
		if(a == b)cout << 1 << endl;
		else cout << 0 << endl;
	}else{
		int tmp = a * (n - 1) + b;
		int tmp1 = b * (n - 1) + a;
		int ans = tmp1 - tmp + 1;
		if(ans < 0)ans = 0;
		cout << ans << endl;
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#define each(i, n) for (int i = 0; i < n; i++)
#ifdef DEBUG
# define show(expr) cerr << #expr << " = " << expr << endl
#else
# define show(expr)
#endif
using namespace std;

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);
  string s;
  cin >> s;
  int rest = 0;
  char l = s.front(), r = s.back();
  if (l == r) {
    rest = s.size() + 1;
  }
  else {
    bool left = false;
    for (auto c : s) {
      if (c == l && !left)
        left = true;
      else if (c == r && left)
        left = false;
      else rest++;
    }
  }
  cout << (rest % 2 == 0 ? "Second" : "First") << endl;
}


Measured memory_bytes: 512
#include "iostream"
#include "math.h"
#include "algorithm"
using namespace std;

int H, W;
int status[10][10000];
int gap[10];
int box;
int num;
int ans;

int main() {
	cin >> H >> W;
	while (H != 0 && W != 0) {
		for (int i = 0; i < H; i++) {
			for (int j = 0; j < W; j++) {
				cin >> status[i][j];
			}
		}
		for (int j = 0; j < W; j++) {
			for(int i=0;i<H;i++){
				if (status[i][j])box++;
			}
			box = max(box, H - box);
			ans += box;
			box = 0;
		}
		for (int n = 1; n < pow(2,H); n++) {
			for (int i = 0; i < H; i++) {
				if (n%(int)pow(2, i + 1) >= pow(2, i))gap[i] = true;
				else gap[i] = false;
			}
			for (int j = 0; j < W; j++) {
				for (int i = 0; i < H; i++) {
					if (status[i][j] ^ gap[i])box++;
				}
				box = max(box, H - box);
				num += box;
				box = 0;
			}
			if (ans < num)ans = num;
			num = 0;
		}
		cout << ans<<"\n";
		ans = 0;
		cin >> H >> W;
	}
	return 0;
}

Measured memory_bytes: 3508
#include<cstdio>
#include<iostream>
#include<set>
#include<vector>
#include<algorithm>
#include<cmath>
#include<string>

using namespace std;

const int CMax = 100002;

int x, a, b;

int main(){
    scanf("%d %d %d", &x, &a, &b);
    if (abs(b-x) < abs(a-x)){
        printf("B\n");
    } else {
        printf("A\n");
    }
}


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


int main(){
  int A, B , C;
  cin >> A >> B >> C;
  
  int K;
  cin >> K;
  
  int a = K;
  
  
  while(a+1){ //K回までできる.終了判定が中にあるのでK+1回操作
    a--;
    //条件を満たしていたら終了
    if( B > A && C > B){
      cout << "Yes" << endl;
      return 0;
    }
    
    if( A >= B ){
      B *= 2;
    }
    else if(B >= C ){
      C *= 2;
    }
    
  }
  
  cout << "No" << endl;
  return 0;
  
}

Measured memory_bytes: 3632
#include<algorithm>
#include<iostream>
#include<stdio.h>
#include<iostream>
#include<stdio.h>
#include<vector>
#include<set>
#include<string>
#include<iomanip>
#include<queue>
#include<functional>
#include<cmath>
#include<map>
#define rep(i,n) for(int i=0; i<(int)n; i++)//n回繰り返す
#define rrep(i,n)for(int i=n-1;i>=0;i--)
#define REP(i,n) for (int i = 1; i <= (int)n; i++)//i=1からi=nまで
using namespace std;
using ll = long long;
using P = pair<int, int>;
using graph = vector<vector<int>>;
const ll mod = pow(10, 9) + 7;
const int INF = 1e9;
const ll LINF = 1e18;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

int main() {
    double K ; cin >>K ;
    double A, B; cin >> A >> B;
    
    while (A <= B) {
        if (A / K == (int)A / (int)K) {
            cout << "OK" << endl;
            return 0;
        }
        A++;
    }
    cout << "NG" << endl;
}




    


   









    


















































































































































































































































































































Measured memory_bytes: 3720
#include <stdio.h>

int main() {

  int A, B, K, count = 0, i;
  if(A < B) {
    i = A;
    A = B;
    B = i;
  }
  scanf("%d %d %d", &A, &B, &K);
  for(i = B; i >= 1; i--) {
    if((A % i == 0) && (B % i == 0)) {
      count++;
    }
    if(count == K) {
      break;
    }
  }
  printf("%d\n", i);
  return 0;
}


Measured memory_bytes: 128
#include <iostream>
#include <string>
#include<math.h>
using namespace std;

int main() {
	int N;
	cin >> N;
	int fx=0,a=N;
	while (true) {
		fx += a % 10;
		a /= 10;
		if (a == 0) break;
	}
	if (N%fx == 0)cout << "Yes" << endl;
	else cout << "No" << endl;
}

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

int main(void) {
    int N, M;
    int maxl,minr;
    int l,r;
    int ans;
    cin >> N >> M;

    maxl = 0;
    minr = INT_MAX;
    for(int i=0;i<M;i++) {
        cin >> l >> r;
        if(maxl < l) {
            maxl = l;
        }
        if(minr > r) {
            minr = r;
        }
    }

    if(maxl > minr) {
        ans = 0;
    } else {
        ans = minr -maxl + 1;
    }

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


Measured memory_bytes: 256
import sys
from bisect import bisect
 
class BIT():#1-indexed
	def __init__(self, size):
		self.table = [0 for _ in range(size+2)]
		self.size = size
 
	def Get(self, i):#iを返す
		s = 0
		while i > 0:
			s += self.table[i]
			i -= (i & -i)
		return s
 
	def PointAdd(self, i, x):#
		while i <= self.size:
			self.table[i] += x
			i += (i & -i)
		return
 
	def SegAdd(self, l, r, x):#lからrにxを足す
		self.PointAdd(l, x)
		self.PointAdd(r+1, -x)
		return
 
 
n, d, a = map(int, input().split())
d *= 2
mo = sorted([list(map(int, input().split())) for _ in range(n)])
for i in range(n):
	mo[i][1] = (mo[i][1]-1)//a + 1
reach = []
moo = [x[0] for x in mo]
mooo = [x[1] for x in mo]
for x in moo:
	reach.append(bisect(moo, x+d)-1)
#print(reach)
 
bit = BIT(n)
 
ans = 0
for i, h in enumerate(mooo):
	gap = max(0, h - bit.Get(i+1))
	bit.SegAdd(i+1, reach[i]+1, gap)
	ans += gap
 
print(ans)

Measured memory_bytes: 110812
/*
Author: Sagar Gupta
E mail: sagar.june97p@gmail.com
*/

#pragma comment(linker, "/STACK:268435456")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
using namespace std;
#define endl ("\n")
#define deb(n) cerr << #n << " = " << (n) << '\n'
#define PI (3.141592653589)
#define ordered_set tree<int, null_type, std::less<int>, rb_tree_tag, tree_order_statistics_node_update>
#define MOD 1000000007

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    cout << fixed;
    cout.precision(10);
    // Those who forgive themselves, and are able to accept their true nature...THEY ARE THE STRONG ONES

    int count = 0;
    int h, a;
    cin >> h >> a;
    while(h > 0)
    {
        h -= a;
        count++;
    }
    cout << count;
    return 0;
}

Measured memory_bytes: 256
import heapq

N, M, s, t = map(int, input().split())
inf = 10 ** 18

def dijkstra(start, G):
    q = [(0, start)]
    heapq.heapify(q)
    cost = [inf] * N
    cost[start] = 0
    while q:
        c, v = heapq.heappop(q)
        if c > cost[v]:
            continue
        for d, u in G[v]:
            tmp = d + cost[v]
            if tmp < cost[u]:
                cost[u] = tmp
                heapq.heappush(q, (tmp, u))
    return cost

# G = [(cost, edge), ...]
Ga = [[] for _ in range(N)]
Gb = [[] for _ in range(N)]
for _ in range(M):
    u, v, a, b = map(int, input().split())
    u, v = u - 1, v - 1
    Ga[u].append((a, v))
    Ga[v].append((a, u))
    Gb[u].append((b, v))
    Gb[v].append((b, u))

s2i = dijkstra(s - 1, Ga)
i2t = dijkstra(t - 1, Gb)

c = [0] * N
tmp = 10 ** 18
for i in range(N):
    tmp = min(tmp, s2i[-(i + 1)] + i2t[-(i + 1)])
    c[-(i + 1)] = tmp

for cc in c:
    print(10 ** 15 - cc)


Measured memory_bytes: 84304
import java.util.*;

public class Main {
	Scanner sc = new Scanner(System.in);

	void doIt() {
		int N = sc.nextInt();
		int M = sc.nextInt();
		pInt[] drink = new pInt[N];
		for(int i = 0; i < N; i++) {
			drink[i] = new pInt(sc.nextInt(), sc.nextInt());
		}
		Arrays.sort(drink);
		long ans = 0;
		for(int i = 0; i < N; i++) {
			if(M > drink[i].cap) {
				ans += drink[i].cap * drink[i].cost;
				M -= drink[i].cap;
			}
			else {
				ans += M * drink[i].cost;
				System.out.println(ans);
				return;
			}
		}
	}
	
	class pInt implements Comparable<pInt>{
		long cost;
		long cap;
		pInt(long c, long n){
			cost = c;
			cap = n;
		}
		@Override
		public int compareTo(pInt arg0) {
			return (int)(this.cost - arg0.cost);
		}
		
		
	}
	
	public static void main(String[] args) {
		new Main().doIt();
	}
}


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

int main() {
  int N;
  cin >> N;
  vector<int> vec(N);
  
  for (int i=0; i<N ; i++) {
    cin >> vec.at(i);
  }
  sort(vec.begin(), vec.end());
  reverse(vec.begin(), vec.end());
  
  int alice=0;
  int bob=0;
  for (int i=0; i<N ; i++) {
    if (i%2==0)
      alice+=vec.at(i);
    else 
      bob+=vec.at(i);
  }
  
  cout << alice-bob << endl;
}


Measured memory_bytes: 256
n, x = map(int, input().split())
array = list(map(int, input().split()))

count = 0
array = sorted(array)
for i in range(n):
    x = x - array[i]
    if x >= 0:
        count += 1
    else:
        break
if x > 0:
    count -= 1
print(count)

Measured memory_bytes: 3064
{**
 * Author  : Nguyen Canh Toan
 * Problem : C - Sqrt Inequality
 * Link    : https://atcoder.jp/contests/panasonic2020/tasks/panasonic2020_c
**}
uses math;
const std='tmp';
var a,b,c:int64;
    input,output:text;
procedure main();
var ans:int64;
begin
  read(a,b,c);
  if (c-(a+b+2*sqrt(a)*sqrt(b))>0) then write('Yes') else write('No');
end;
BEGIN
  //assign(input,std+'.inp');reset(input);
  //assign(output,std+'.out');rewrite(output);
    main();
  //close(input);
  //close(output);
END.

Measured memory_bytes: 128
//#include<bits/stdc++.h>
//using namespace std;
#include<stdio.h>
#include<string.h>
const int MAXN=1e6+50;
char s[MAXN];
int main ()
{   scanf("%s",s);
   int ans=0;
    for(int i=strlen(s)-1;i>=1;i--)
      {     if(s[i]>='6'||(s[i]=='5'&&s[i-1]>='5'))  
          {ans+='0'+10-s[i];s[i-1]++;}
          else
            ans+=s[i]-'0';
	  }
	  if(s[0]>='6')  ans+='0'+10-s[0]+1;
	  else
	  ans+=s[0]-'0';
	  printf("%d",ans);
	  return 0;
}

Measured memory_bytes: 1152
#include<bits/stdc++.h>
using namespace std;
int main(){
  long long  n,k;cin>>n>>k;
  long long  arr[n];
  long long count=0;
  for(long long int i=0;i<n;i++){
    cin>>arr[i];
    if(arr[i]>=k){
      count++;}
  }
  
  cout<<count;
  

}


Measured memory_bytes: 1024
#include <stdio.h>

int main(void) {
    
    int width;
    int height;
    int x;
    int y;
    int radius;

    scanf("%d %d %d %d %d", &width, &height, &x, &y, &radius);

    if(x < radius || y < radius || x + radius > width || y + radius > height) {
        printf("No\n");
        return 0;
    }

    printf("Yes\n");
    return 0;
}

Measured memory_bytes: 584
object Main extends App {
  import scala.io.StdIn._
  val Array(a,b,k) = readLine().split(" ").map(_.toLong)
  val ansA = List(a-k,0).max
  val ansB = List(b-List(k-a,0).max,0).max
  println(s"$ansA $ansB")
}

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

int main(){

  int a[4];
  int A,B;
  for(int i=0;i<4;i++)cin >> a[i];
  A=a[0]*a[1];
  B=a[2]*a[3];
  if(A>B){
    cout << A;
  }else if(A<=B){
  	cout << B;
  }
  return 0;
}

Measured memory_bytes: 256
s = raw_input()
n = len(s)
c = [s.count(chr(i + ord('a'))) for i in range(26)]
b = [n / 3, n / 3, n / 3]
if n % 3 == 1:
	b[0] += 1
if n % 3 == 2:
	b[0] += 1
	b[1] += 1

c = sorted(c)[::-1]
for i in range(3):
	if c[i] > b[i]:
		print 'NO'
		break
else:
	print 'YES'


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

int main() {
  int N, L;
  cin >> N >> L;
  vector<string> v(N);
  for (int i = 0; i < N; ++i) {
    cin >> v.at(i);
  }
  sort(v.begin(), v.end());
  for (int i = 0; i < N; ++i) {
    cout << v.at(i);
  }
  cout << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<long long, long long>;
const long long INF = 1001001001;
const long long MOD = 1000000007;
const double EPS = 1e-10;
struct Edge { int from, to; long long cost; };
using Graph = vector<vector<Edge>>;

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

    int n;
    cin>>n;
    cout<<(1000-n%1000)%1000<<endl;
}

Measured memory_bytes: 3632
#include<stdio.h>

int main(void){
  int num[3];
  int five_count,seven_count;

  five_count=0;
  seven_count=0;

  scanf("%d",&num[0]);
  scanf("%d",&num[1]);
  scanf("%d",&num[2]);
  
  for(int i=0;i<3;i++){
    if(num[i]==5)five_count++;
    if(num[i]==7)seven_count++;
  }

  if(five_count==2 && seven_count==1){
    printf("YES");
  }else printf("NO");

  return 0;
}

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

// 基本テンプレート
#pragma region MACRO
#define P(x) cout << (x) << endl
#define p(x) cout << (x)
#define PED cout << "\n"
#define rep(i,n) for(int i=0; i<(int)n; ++i)
#define REP(i,x,n) for(int i=x; i<(int)n; ++i)
#define repi(i,n) for(int i=0; i<=(int)n; ++i)
#define REPI(i,x,n) for(int i=x; i<=(int)n; ++i)
#define ILP while(true)
#define FOR(i,c) for(__typeof((c).begin())!=(c).begin(); i!=(c).end(); ++i)
#define ALL(c) (c).begin(), (c).end()
#define mp make_pair
#pragma endregion

// 型
#pragma region TYPE_DEF
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<string, string> pss;
typedef pair<string, int> psi;
typedef pair<int, string> pis;
typedef vector<int> vi;
typedef vector<double> vd;
typedef vector<long double> vld;
typedef vector<long> vl;
typedef vector<long long> vll;
typedef vector<string> vs;
#pragma endregion

// Effective std
#pragma region ESTD
template<typename C, typename T> int count(C& c, T t) { return count(ALL(c), t); }
template<typename C, typename F> int count_if(C& c, F f) { return count_if(ALL(c), f); }
template<typename C, typename T> void erase(C& c, T t) { remove(ALL(c), t), c.end(); }
template<typename C> void remove(vector<C>& c, unsigned int index) { c.erase(c.begin()+index); }
template<typename C, typename T, typename U> void replace(C& c, T t, U u) { replace(ALL(c), t, u); }
template<typename C, typename F, typename U> void replace_if(C& c, F f, U u) { (ALL(c), f, u); }
template<typename C> void reverse(C& c) { reverse(ALL(c)); }
template<typename C> void sort(C& c) { sort(ALL(c)); }
template<typename C, typename Pred> void sort(C& c, Pred p) { sort(ALL(c), p); }
#pragma endregion

// 定数
#pragma region CONST_VAL
constexpr int PI = (2*acos(0.0));
constexpr int EPS = (1e-9);
constexpr int MOD = (int)(1e9+7);
constexpr int INF = 100000000;
#pragma endregion


int main()
{
    int n, c, k;
    cin >> n >> c >> k;
    vi t;
    rep(i, n) {
        int a;
        cin >> a;
        t.push_back(a);
    }
    sort(t);

    vi v;
    int ans = 0;
    rep(i,n) {
        if(i+1<=v.size()) continue;

        if(t.size()-v.size()>=c) {
            REP(j,i,i+c) {
                if(t[j]<=t[i]+k) {
                    v.push_back(0);
                }
            }
        }
        else {
            REP(j,i,t.size()) {
                if(t[j]<=t[i]+k) {
                    v.push_back(0);
                }
            }
        }
        ans++;
    }
    P(ans);
    return 0;
}



Measured memory_bytes: 1400
n = input()
mark = ['S', 'H', 'C', 'D']
cards = ["{} {}".format(mark[i], j+1) for i in range(4) for j in range(13)]
for i in range(n):
    cards.remove(raw_input())
while len(cards) != 0:
    print cards.pop(0)

Measured memory_bytes: 6436