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

/* // Ordered Set
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds;
typedef tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> ordered_set;
#define os_find(k) find_by_order(k)
#define os_order(k) order_of_key(k)
*/

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef vector<int> vi;
#define f0(i,a,b) for(int i=a;i<b;i++)
#define f1(i,a,b) for(int i=a;i<=b;i++)
#define f2(i,a,b) for(int i=a;i>b;i--)
#define f3(i,a,b) for(int i=a;i>=b;i--)
#define all(a) a.begin(),a.end()
#define pb push_back
#define mp make_pair
#define pii pair<int,int>
#define int long long
#define fi first
#define se second
#define mod 1000000007
#define fast ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define make_graph(k) int x,y; f0(i,0,k){cin>>x>>y; adj[x].pb(y); adj[y].pb(x);}
#define test int t;cin>>t;while(t--)
int fact[3001];
int binExp(int x,int n)
{
    int res=1;
    while(n)
    {
        if(n&1) res=(res*x)%mod;
        x=(x*x)%mod;
        n>>=1;
    }
    return res;
}
int modInv(int i) {return binExp(i,mod-2);}
int ncr(int n,int r) {return (fact[n]*modInv(fact[r]))%mod*modInv(fact[n-r])%mod;}

signed main()
{
    fast

    #ifndef ONLINE_JUDGE
        freopen("inputf.in","r",stdin);
        freopen("outputf.in","w",stdout);
    #endif

    
    fact[0] = 1;
    f1(i,1,3000)
    {
        fact[i] = (fact[i-1]*i)%mod;
    }

    int s;
    cin>>s;

    int maxx = s/3;
    if(maxx==0)
    {
        cout<<0;
        return 0;
    }

    int ans = 0;

    f3(i,maxx,1)
    {
        int cur = s - i*3;
        ans = (ans + ncr(cur+i-1, i-1))%mod;
        // cout<<cur+i-1<<' '<<i<<' '<<ncr(cur+i-1, i-1)<<'\n';
    }
    cout<<ans;
}

Measured memory_bytes: 3676
import math

N = int(input())
XY = []
for _ in range(N):
    xy = list(map(int, input().split()))
    XY.append(xy)

ans = 0
for i in range(N):
    for j in range(N):
        if i == j:
            continue
        ans += math.sqrt(((XY[i][0]-XY[j][0])**2)+((XY[i][1]-XY[j][1])**2))

print(ans/N)


Measured memory_bytes: 3060
#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 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 vl = vector<ll>;
using vvl = vector<vector<ll>>;
using pii = pair<int,int>;
using pll = pair<ll,ll>;
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(){

    int N;
    cin >> N;
    int ans = 0;
    ans += N/500;
    N-=ans*500;
    ans *= 1000;
    ans += (N/5)*5;
    cout << ans << endl;
    
    
    

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <vector>
#include <functional>
#include <cstdlib>
#include <map>
#include <set>
#include <iostream>
#include <string>
#include <ctype.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main(){
	int n,d;
	cin >> n >> d;
	
	if(n%(2*d+1) != 0)
		cout << n/(2*d+1) +1 << endl;
	else 
		cout << n/(2*d+1) << endl;
	
	
	
	return 0;
}

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 vi=vector<int>;
using vll=vector<ll>;
#define MOD 1e9+7

int main(){
    string s;
    cin >> s;
    
    vector<string> moji(4);
    moji[0]="dream"; moji[1]="erase"; moji[2]="dreamer"; moji[3]="eraser";
    rep(i,4) reverse(moji[i].begin(),moji[i].end());
    reverse(s.begin(),s.end());
    int num=0;
    while(1){
        int temp=num;
        rep(j,5){
            if(s[num+j]!=moji[0][j]) break;
            if(j==4) num+=5;
        }
        rep(j,5){
            if(s[num+j]!=moji[1][j]) break;
            if(j==4) num+=5;
        }
        rep(j,7){
            if(s[num+j]!=moji[2][j]) break;
            if(j==6) num+=7;
        }
        rep(j,6){
            if(s[num+j]!=moji[3][j]) break;
            if(j==5) num+=6;
        }
        if(num==s.size()) break;
        if(num==temp){
            cout << "NO" << endl;
            return 0;
        }
    }
    cout << "YES" << endl;
}

Measured memory_bytes: 3668
//Compete against Yourself.
#include <bits/stdc++.h>
#define _ ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define int long long
#define sz(i) (int)(i.size())
#define F first
#define S second
#define L long double
#define P pair<int, int>
const int inf = 0x3f3f3f3f3f3f3f3LL;
const int mod = (int)1e9 + 7;
using namespace std;
#if LOCAL
#include "../../tr.h"
#else
#define tr(...)
#define endl '\n'
#endif
template<class T> void smin(T& a, T val) {if (a > val) a = val;}template<class T> void smax(T& a, T val) {if (a < val) a = val;}
const int N = 5*(int)1e5 + 10;

void yes(){
   cout<<"Yes"<<endl;
   //exit (0);
}
void no(){
   cout<<"No"<<endl;
   //exit (0);   
}

int n, m;
string s, t;

int32_t main(){_
   
   cin >> n >> m;

   int sum = 0;
   for (int i = 0; i < m; ++i)
   {
      int x;
      cin >> x;
      sum += x;
   }


   if (sum >= n){
      yes();
   }
   else{
      no();
   }

   return 0;
}

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

using namespace std;

const ll inf=10e17;
ll n,a[405],dp[405][405],sum[405][405];


int main()
{
    cin >> n;
    for(int i=0;i<n;++i){
        cin >> a[i];
    }
    for(int i=0;i<n;++i){
        for(int j=i;j<n;++j){
            if(i==j){
                dp[i][j]=0;
            }
            else{
                dp[i][j]=inf;
            }
            for(int k=i;k<=j;++k){
                sum[i][j]+=a[k];
            }
        }
    }
    for(int i=0;i<n;++i){
        for(int j=0;i+j<n;++j){
            for(int k=0;k<=i;++k){
                dp[j][j+i]=min(dp[j][j+i],dp[j][j+k]+dp[j+k+1][j+i]+sum[j][j+i]);
            }
        }
    }
    cout << dp[0][n-1];
    return 0;
}


Measured memory_bytes: 2816
#include <iostream>
#include <list>

int main() {
	int A, B, K;
	std::cin >> A >> B >> K;
	
	// Kが範囲以上の場合
	if(K > (B - A + 1)) {
		K = B - A + 1;
	}
	
	std::list<int> lst;
	
	for(int i = 0; i < K; i++) {
		lst.push_back(A + i);
		lst.push_back(B - i);
	}
	
	lst.sort();
	lst.unique();
	
	for(const int item : lst) {
		std::cout << item << std::endl;
	}
	
	return 0;
}


Measured memory_bytes: 256
/* Author : Prasuk Jain */
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define int              long long int
#define ull              unsigned long long
#define ld               long double
#define fo(i, n)         for(int i=0; i<n; i++)
#define FOR(i, a, b)     for(int i=a; i<b; i++)
#define rfor(i, n)       for(int i=n-1; i>=0; i--)
#define RFOR(i, a, b)    for(int i=b-1; i>=a; i--)
#define tr(it, v)        for(auto it=a.begin(); it!=a.end(); it++)
#define vi               vector<int>
#define pii              pair<int,int>
#define mii              map<int,int>
#define pqb              priority_queue<int>
#define pqs              priority_queue<int,vi,greater<int>>
#define mp               make_pair
#define pb(x)            push_back(x)
#define hcf(x, y)        __gcd(x, y)
#define lcm(x, y)        boost::math::lcm(x,y)
#define setpre(x, y)     fixed << setprecision(y) << x
#define setbits(x)       __builtin_popcountll(x)
#define zerolead(x)      __builtin_clzll(x)
#define zerotrail(x)     __builtin_ctzll(x)
#define all(x)           x.begin(), x.end()
#define sortall(x)       sort(all(x))
#define PI               3.1415926535897932384626
const int mod = 1e9+7;
const int inf = 1e18;
int mpow(int base, int exp);
bool isprime(int num);
void prifact(int num);

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

void coderprasukj(){ 
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif
}

int32_t main() {
    //coderprasukj();
    int t;
    cin >> t;
    int res=0;
    while(t>=5){
        if(t>=500) {
            t -= 500;
            res += 1000;
        }
        else if(t>5 && t<500){
            t-=5;
            res+=5;
        }
    }
    cout << res << "\n";
    return 0;
}

//*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!*!//

int mpow(int base, int exp) {
    base %= mod;
    int result = 1;
    while (exp > 0) {
        if (exp & 1) result = ((int)result * base) % mod;
        base = ((int)base * base) % mod;
        exp >>= 1;
    }
  return result;
}

bool isprime(int num) {
    if(num <= 1) return false;
    for(int i=2; i*i <= num; i++)
        if(num%i == 0) return false;
    return true;
}

void prifact(int num){
    for(int i=2; i<=num; i++)
    if(num%i == 0){
        int cnt = 0;
        while(num%i == 0)
        cnt++ , num /= i;
        cout << i << "^" << cnt << " ";
    }
    if(num > 1)
    cout << num << "^" << "1" << " ";
}



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

#define MAX 100001
#define INF (1<<30)
class DisjointSet{	// {{{
	public:
	vector<int> rank,p,cnt;

	//{{{ コンストラクタ
	DisjointSet(){}
	DisjointSet(int size){
		rank.resize(size,0);
		p.resize(size,0);
		cnt.resize(size,0);
		for(int i=0;i<size;i++) makeSet(i);
	}
	//}}}
//{{{ 関数
	void makeSet(int x){
		p[x]=x;
		rank[x]=0;
		cnt[x]=1;
	}

	bool same(int x,int y){
		return findSet(x)==findSet(y);
	}
	int findSet(int x){
		if(x!=p[x]){
			p[x]=findSet(p[x]);
		}
		return p[x];
	}

	void unite(int x, int y){
		link(findSet(x), findSet(y));
	}

	int getCount(int x){
		x=findSet(p[x]);
		return cnt[x];
	}

	void link(int x, int y){
		if(x==y)return;
		// x,y はどちらも木の根っこ
		if(rank[x]>rank[y]){
			p[y]=x;
			cnt[x]+=cnt[y];
		}else{
			p[x]=y;
			cnt[y]+=cnt[x];
			if(rank[x]==rank[y]) rank[y]++;
		}
	}

//}}}
};
// }}}

//vector<int> person[MAX];

int main(){
	int n,m,k;	cin>>n>>m>>k;
	vector<int> cnt(n+1,0);

	DisjointSet DS=DisjointSet(n+1);

	for(int i=0;i<m;i++){
		int a,b;	cin>>a>>b;
		//person[a].push_back(b);
		//person[b].push_back(a);
		cnt[a]++;
		cnt[b]++;

		DS.unite(a,b);
	}
	vector<int> ans(n+1);
	for(int i=1;i<=n;i++){
		ans[i]=DS.getCount(i)-cnt[i]-1;
	}

	for(int i=0;i<k;i++){
		int c,d;	cin>>c>>d;
		if(DS.same(c,d)){
			ans[c]--;
			ans[d]--;
		}
	}

	for(int i=1;i<=n;i++){
		if(i>1)cout<<" ";
		cout<<ans[i];
	}cout<<endl;
	return 0;
}


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

const string dir = "ENSW";
const string rdir = "WSNW";
constexpr int rot[4][6] = { {2, 1, 5, 3, 0, 4}, {3, 0, 2, 5, 4, 1},
                            {1, 5, 2, 0, 4, 3}, {4, 1, 0, 3, 5, 2}};

vector<int> roll(vector<int> const& v, char d) {
    const int p = find(begin(dir), end(dir), d) - begin(dir);
    vector<int> res(6);
    for(int i = 0; i < 6; ++i) {
        res[i] = v[rot[p][i]];
    }
    return res;
}

bool check(vector<int> const& dice) {
    int v1 = dice[0] + dice[5], v2 = dice[2] + dice[4], v3 = dice[1] + dice[3];
    int cnt = 0;
    if(dice[0] < 0) return false;
    if(v1 >= v2 + v3 + 1) return false;
    if(v2 > v1 + v3 + 1) return false;
    if(v2 == v1 + v3 + 1) cnt++;
    if(v3 > v1 + v2 + 1) return false;
    if(v3 == v1 + v2 + 1) cnt++;
    return cnt <= 1;
};

int main() {
    ios::sync_with_stdio(false), cin.tie(0);
    vector<int> v(6);
    while(true) {
        for(int i = 0; i < 6; ++i) cin >> v[i];
        const int n = accumulate(begin(v), end(v), 0);
        if(n == 0) break;
        sort(begin(v), end(v));
        int p, q;
        cin >> p >> q;

        string ans(n, 'Z');
        do {
            auto dice = v;
            if(!check(dice)) continue;
            string t;
            bool lt = false;
            for(int i = 0; i < n; ++i) {
                bool ok = false;
                for(int j = 0; j < 4; ++j) {
                    dice = roll(dice, dir[j]);
                    dice[0]--;
                    if(check(dice) && (lt || ans[i] >= dir[j])) {
                        t += dir[j];
                        lt |= ans[i] > dir[j];
                        ok = true;
                        break;
                    }
                    dice[0]++;
                    dice = roll(dice, rdir[j]);
                }
                if(!ok) {
                    t.clear();
                    break;
                }
            }
            if(t.empty()) continue;
            if(ans.empty()) ans = move(t);
            else ans = min(ans, t);
        } while(next_permutation(begin(v), end(v)));

        if(ans[0] == 'Z') {
            cout << "impossible" << endl;
        } else {
            cout << ans.substr(p - 1, q - p + 1) << endl;
        }
    }
}



Measured memory_bytes: 3296
import math

a, b, x = map(int, input().split())

if a ** 2 * b / 2 <= x:
    print(math.degrees(math.atan(2 * (a ** 2 * b - x) / (a ** 3))))
else:
    print(math.degrees(math.pi / 2 - math.atan(2 * x / (a * b ** 2))))


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

int main(){
    char c;
    cin >> c;
    if(c == 'a' || c == 'e' || c == 'i' || c == 'o' || c == 'u'){
        cout << "vowel" << endl;
    }else{
        cout << "consonant" << endl;
    }

    return 0;
    
}

Measured memory_bytes: 256
def main():
    import sys
    input = sys.stdin.readline
    sys.setrecursionlimit(10 ** 9)
    MOD = 10 ** 9 + 7

    L = int(input())

    if L == 2:
        print (2, 2)
        print (1, 2, 0)
        print (1, 2, 1)
        exit()

    L -= 1

    N = len(bin(L)) - 2 #頂点数


    M = 0
    G = []
    G_append = G.append

    for i in range(N - 1):
        G.append((i + 1, i + 2, 0))
        G.append((i + 1, i + 2, 2 ** (N - 2 - i)))

    # print (G)
    tmp = 2 ** (N - 1)
    for i in range(N - 2, 0, -1):
        if (L >> i) & 1:
            G.append((1, N - i, tmp))
            tmp += 2 ** i

    if 2 ** (N - 1) == L + 1:
        pass
    else:
        if (L >> 0) & 1:
            G.append((1, N, tmp))
            G.append((1, N, tmp + 1))
        else:
            G.append((1, N , tmp))

    print (N, len(G))
    for g in G:
        print (*g, sep = ' ')

if __name__ == '__main__':
    main()

Measured memory_bytes: 9124
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<climits>

using namespace std;

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

struct Edge{
  int to,cost;
  Edge(int _to, int _cost):to(_to), cost(_cost){};
};

int minCost[110][12];
vector<Edge> edge[110];
static const int INF = INT_MAX;

int c,n,m,s,d;

int dijkstra(void){
  priority_queue<P, vector<P>, greater<P> >que;
  que.push(make_pair(0,make_pair(s,c)));

  for(int i=0;i<110;i++)
    for(int j=0;j<12;j++)
      minCost[i][j]=INF;

  while(!que.empty()){
    P p = que.top();
    que.pop();
    
    for(int i=0;i<edge[p.second.first].size();i++){
      Edge e = edge[p.second.first][i];
      if(p.first+e.cost < minCost[e.to][p.second.second]){
	minCost[e.to][p.second.second] = p.first+e.cost;
	que.push(make_pair(p.first+e.cost,make_pair(e.to,p.second.second)));
      }
    }
    
    if(p.second.second==0)continue;
    
    for(int j=0;j<edge[p.second.first].size();j++){
      Edge e = edge[p.second.first][j];
      if(p.first+e.cost/2 < minCost[e.to][p.second.second-1]){
	minCost[e.to][p.second.second-1] = p.first+e.cost/2;
	que.push(make_pair(p.first+e.cost/2,make_pair(e.to,p.second.second-1)));
      }
    }
  }
  int ans=INT_MAX;
  for(int i=0;i<12;i++)
    ans=min(minCost[d][i],ans);

  return ans;
}

int main(void){
  int a,b,f;

  while(cin >> c >> n >> m >> s >> d,c|n|m|s|d){

    for(int i=0;i<=n;i++)edge[i].clear();

    for(int i=0;i<m;i++){
      cin >> a >> b >> f;
      edge[a].push_back(Edge(b,f));
      edge[b].push_back(Edge(a,f));
    }

    cout << dijkstra() << endl;
  }

  return 0;
}

Measured memory_bytes: 0
n, q = map(int,input().split())
graph = [[] for i in range(n+1)]
for i in range(n-1):
    f, t = map(int,input().split())
    graph[f].append(t)
    graph[t].append(f)

px = [0] * (n+1)
for i in range(q):
    p, x = map(int,input().split())
    px[p] += x

v = [0] * (n+1)
q = [[1,0]]
while q:
    x, parent = q.pop()
    v[x] += v[parent]
    v[x] += px[x]
    for y in graph[x]:
        if y == parent:
            continue
        q.append([y,x])

ans = [str(i) for i in v[1:]]
print(' '.join(ans))

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

ll n;

int main(){
    cin>>n;
    if(n%2){
        cout<<0<<endl;
        return 0;
    }
    ll ans=0,x=10;
    while(n>=x){
        ans+=n/x;
        x*=5;
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <vector>
#include <algorithm>
#include <math.h>
#include <queue>
 
using namespace std;
 
struct Point{
    double x,y;
};
 
int main(void){
 
    int sum = 0,tmp;
 
    for(int i = 0; i < 10; i++){
        scanf("%d",&tmp);
        sum += tmp;
    }
 
    printf("%d\n",sum);
 
    return 0;
}


Measured memory_bytes: 2716
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cctype>
#include <algorithm>
#include <string>
#include <iomanip>

using namespace std;

#define pi 3.141592653589
#define repeat(i,n) for(int i=0;i<n;i++)

int main()
{
	string num;
	while (cin >> num)
	{
		if (num == "0") break;

		int sum = 0;
		for (int i = 0; i < num.size(); i++)
		{
			sum += (num[i] - '0');
		}
		cout << sum << endl;
	}
	return 0;
}

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

int main() {
	ios_base::sync_with_stdio( false );

	long Q, H, S, D, N;
	cin >> Q >> H >> S >> D >> N;

	H = min( H, 2*Q );
	S = min( S, 2*H );

	long ans = 0;

	if( 2*S <= D ) {
		ans = N * S;
	}
	else {
		ans = N/2 * D + N%2 * S;
	}

	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
const int N=111;
const int M=3*N;
int dp[N][N][M],a[N],b[N];
int main()
{
    int n,W;
    scanf("%d%d",&n,&W);
    for(int i=0;i<n;i++)
        scanf("%d%d",&a[i],&b[i]);
    for(int i=0;i<n;i++)
    {
        for(int j=0;j<=i;j++)
        {
            for(int h=0;h<=3*j;h++)
            {
                dp[i+1][j][h]=max(dp[i+1][j][h],dp[i][j][h]);
                dp[i+1][j+1][h+a[i]-a[0]]=max(dp[i+1][j+1][h+a[i]-a[0]],dp[i][j][h]+b[i]);
            }
        }
    }
    int ans=0;
    for(int i=0;i<=n;i++)
    {
        for(int j=0;j<=3*i;j++)
        {
            long long curW=(long long)a[0]*i+j;
            if(curW<=W)
                ans=max(ans,dp[n][i][j]);
        }
    }
    printf("%d\n",ans);
    return 0;
}

Measured memory_bytes: 12928
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define INF 2e9
#define ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
int main()
{
  int N; cin >> N;
  while(N != 0){
    if(N % 10 == 7){
      cout << "Yes" << endl;
      return 0;
    }
    N /= 10;
  }
  cout << "No" << endl;
}

Measured memory_bytes: 3596
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#include<cmath>
#include<deque>
#include<set>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define INF 1LL << 60
#define MAX 1000000000

const double PI = 3.14159265358979323846;
ll gcd(ll a, ll b) { return a % b == 0 ? b : gcd(b, a % b); }
ll lcm(ll a, ll b) { return (a / gcd(a, b)) * b; }
ll power(ll x, ll p) { ll a = 1; while (p > 0) { if (p % 2 == 0) { x *= x; p /= 2; } else { a *= x; p--; } }return a; }

int main() {
	int n, table[50][26], m;
	char str[50][51];
	char ans[51] = {0};
	scanf("%d", &n);
	rep(i, 0, n) {
		scanf("%s", str[i]);
		rep(i2, 0, 26)table[i][i2] = 0;
		rep(i2, 0, strlen(str[i])) {
			table[i][str[i][i2] - 'a']++;
		}
	}
	rep(i, 0, 26) {
		m = 100;
		rep(i2, 0, n)m = min(table[i2][i], m);
		rep(i2, 0, m)sprintf(ans, "%s%c", ans, i + 'a');
	}
	puts(ans);
	return 0;
}


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

using namespace std;

int min_cost(array<array<int, 10>, 10> &c, int n, int st,
             vector<vector<int>> &memo) {
  if (n == 1) {
    return 0;
  }

  if (memo[n][st] < 0) {
    int ans;
    bool fst = true;
    for (int i = 0; i <= 9; ++i) {
      if (st & (1 << i)) {
        continue;
      }

      int cost = min_cost(c, i, st | (1 << i), memo) + c[n][i];
      if (fst || cost < ans) {
        ans = cost;
        fst = false;
      }
    }

    memo[n][st] = ans;
  }

  return memo[n][st];
}

int main(int argc, const char *argv[]) {
  int h, w;
  cin >> h >> w;

  array<array<int, 10>, 10> c;
  for (int i = 0; i < 10; ++i) {
    for (int j = 0; j < 10; ++j) {
      cin >> c[i][j];
    }
  }

  vector<vector<int>> va(h, vector<int>(w));
  vector<vector<int>> memo(10, vector<int>(2048, -1));
  int ans = 0;
  for (int i = 0; i < h; ++i) {
    for (int j = 0; j < w; ++j) {
      cin >> va[i][j];
      if (va[i][j] == -1) {
        continue;
      }

      ans += min_cost(c, va[i][j], 0, memo);
    }
  }

  cout << ans << '\n';
}

Measured memory_bytes: 3816
#include <bits/stdc++.h>
#define be(v) (v).begin(),(v).end()
#define pb(q) push_back(q)
typedef long long ll;
using namespace std;
const ll mod=1000000007;
#define doublecout(a) cout<<fixed<<setprecision(10)<<a<<endl;

int main() {
    cin.tie(0);
    cout.tie(0);
    ios::sync_with_stdio(false);
    ll x,a,b;
    cin>>x>>a>>b;
    if(a>=b){
        cout << "delicious"<<endl;
    }
    else if(b-a>x){
        cout << "dangerous"<<endl;
    }else{
        cout << "safe"<<endl;
    }
    return 0;
}


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

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

	string a, b;
	cin >> a >> b;
	int r = stoi(a+b);
	for (int i = 0; i < 1000; ++i){
		if (r == i*i){
			cout << "Yes" << "\n";
			return 0;
		}
	}
	cout << "No" << "\n";
	return 0;
}

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

// int/long:		-2147483648 - 2147483648 (-2^31 <= int < 2^31)
// long/long long:	-9223372036854775808 - 9223372036854775807 (-2^63 <= long < 2^63)
#define	INF (1<<29)
//536870912

#define	MOD 1000000007

int	main() {
	int N;
	cin >>N;
	cout <<N*(N+1)/2 <<endl;
	return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/*int min(int a,int b){
    if(a<b){
        return a;
    }
    return b;
} */
int main(void){
    int N;
    long long ans=0;
    vector<int> A(1000);
    vector<int> B(1000);
    cin >>N;
    for(int i=0;i<N-1;i++) {
        cin >>B.at(i);
    }
    for(int i=1;i<N-1;i++){
        A.at(i)=min(B.at(i),B.at(i-1));
    }
    A.at(0)=B.at(0);
    A.at(N-1)=B.at(N-2);
    for(int i=0;i<N;i++){
        ans+=A.at(i);
        //cout <<A.at(i);
    }
    cout <<ans<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
main()
{
   long long x,i,j,n,p,num1,num2;
   p=0;
   double d=double(1)/5;
   cin>>x;
   for(i=-120;i<=120;i++)
   {
      long long d=pow(i,5);
      //cout<<d<<endl;
      for(j=120;j>=-120;j--)
      {
         long long m=pow(j,5);
         if((d-m)==x)
         {
            num1=i;
            num2=j;
            break;
         }
      }
      if(p==1)
      break;
   }
   cout<<num1<<" "<<num2<<endl;
 
 
}

Measured memory_bytes: 3988
"""
Fennec should do special move on the K monsters with largest health.
then the other monsters take H turns to kill.
so total turns is H[i] for i in low health monsters
"""

def calc_num_turns(K, H):
  H.sort(reverse=True)
  total_turns = sum(H[K:])
  return total_turns


if __name__ == "__main__":
  K = int(input().split()[1])
  H = list(map(int, input().split()))
  print(calc_num_turns(K, H))

Measured memory_bytes: 26764
import sys
s = input()

for i in range(3):                                                                                                                                                                                          
    if s[i] == s[i+1]:                                                                                                                                                                                      
        print('Bad')                                                                                                                                                                                        
        sys.exit()                                                                                                                                                                                          
print('Good')


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

constexpr long long int mod = 1e9 + 7;

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

	vector<int> vec(60);

	/*
	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;

		for (int j = 0; j < 60; j++) {
			vec.at(j) += x & 1;
			x >>= 1;
		}
	}
	*/

	for (int i = 0; i < n; i++) {
		long long int x;
		cin >> x;
		bitset<60> bs(x);
		for (int j = 0; j < 60; j++) {
			if (bs[j]) {
				vec.at(j)++;
			}
		}
	}

	long long int sum = 0;
	long long int base = 1;
	for (int i = 0; i < 60; i++) {
		sum += (base * vec.at(i) % mod) * (n - vec.at(i)) % mod;
		sum %= mod;
		base *= 2;
		base %= mod;
	}
	cout << sum << endl;
}

Measured memory_bytes: 256
n = int(input())
s = []
for _ in range(n):
    s.append(int(input()))

s = sorted(s)
for i in range(n):
    i -= 1
    if i == -1:
        total = sum(s)
    else:
        total = sum(s) - s[i]

    if total%10 != 0:
        print(total)
        exit()

print(0)

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define DUMP(x)  cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define IFOR(i, m, n) for(int i = n - 1; i >= m; i-- )
#define REP(i, n) FOR(i,0,n)
#define IREP(i, n) IFOR(i,0,n)
#define FOREACH(x,a) for(auto& (x) : (a) )
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
const ll INF = 1e18;
/* テンプレートここまで */

int main() {
  ll n,m; cin >> n >> m;
  cout << (n-1) * (m-1) << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using lint     = long long;
const lint inf = 1LL << 60;
const lint mod = 1000000007;

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    lint k, n;
    cin >> k >> n;
    if (k % 2 == 0) {
        vector<int> ret;
        ret.push_back(k / 2);
        while ((int)ret.size() < n) {
            ret.push_back(k);
        }
        for (int i = 0; i < n; ++i) {
            if (i)
                cout << " ";
            cout << ret[i];
        }
        cout << "\n";
    } else {
        vector<int> ret(n, k / 2 + 1);
        for (int i = 0; i < n / 2; ++i) {
            if ((int)ret.size() == n) {
                ret.back()--;
                if (ret.back() == 0)
                    ret.pop_back();
            } else {
                ret.back()--;
                if (ret.back() == 0) {
                    ret.pop_back();
                    continue;
                }
                while ((int)ret.size() < n)
                    ret.push_back(k);
            }
        }
        for (int i = 0; i < (int)ret.size(); ++i) {
            if (i)
                cout << " ";
            cout << ret[i];
        }
        cout << "\n";
    }
    return 0;
}

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

fn main() {
    let (r, w) = (std::io::stdin(), std::io::stdout());
    let mut sc = IO::new(r.lock(), w.lock());

    let n: usize = sc.read();
    let x: Vec<usize> = sc.vec(n);
    let mut x: Vec<(usize, usize)> = x
        .into_iter()
        .enumerate()
        .map(|(i, pos)| (i + 1, pos - 1))
        .collect();
    x.sort_by_key(|x| x.1);
    let mut ans = vec![0; n * n];
    let mut cur = 0;
    let mut q = VecDeque::new();
    for &(i, pos) in x.iter() {
        while cur < pos {
            if ans[cur] == 0 {
                q.push_back(cur);
            }
            cur += 1;
        }
        for _ in 0..(i - 1) {
            if let Some(ans_i) = q.pop_front() {
                assert_eq!(ans[ans_i], 0);
                ans[ans_i] = i;
            } else {
                println!("No");
                return;
            }
        }
        assert_eq!(cur, pos);
        ans[cur] = i;
        cur += 1;
    }

    let mut k_th_k = vec![false; n * n];
    for &(_, pos) in x.iter() {
        k_th_k[pos] = true;
    }

    let mut q = VecDeque::new();
    for i in (0..(n * n)).rev() {
        if k_th_k[i] {
            assert_ne!(ans[i], 0);
            let v = ans[i];
            let remain = n - v;
            for _ in 0..remain {
                if let Some(i) = q.pop_front() {
                    assert_eq!(ans[i], 0);
                    ans[i] = v;
                } else {
                    println!("No");
                    return;
                }
            }
        } else if ans[i] == 0 {
            q.push_front(i);
        }
    }

    println!("Yes");
    for i in 0..(n * n) {
        if i > 0 {
            print!(" ");
        }
        print!("{}", ans[i]);
    }
    println!();
}

pub struct IO<R, W: std::io::Write>(R, std::io::BufWriter<W>);

impl<R: std::io::Read, W: std::io::Write> IO<R, W> {
    pub fn new(r: R, w: W) -> Self {
        IO(r, std::io::BufWriter::new(w))
    }
    pub fn write<S: ToString>(&mut self, s: S) {
        use std::io::Write;
        self.1.write(s.to_string().as_bytes()).unwrap();
    }
    pub fn read<T: std::str::FromStr>(&mut self) -> T {
        use std::io::Read;
        let buf = self
            .0
            .by_ref()
            .bytes()
            .map(|b| b.unwrap())
            .skip_while(|&b| b == b' ' || b == b'\n' || b == b'\r' || b == b'\t')
            .take_while(|&b| b != b' ' && b != b'\n' && b != b'\r' && b != b'\t')
            .collect::<Vec<_>>();
        unsafe { std::str::from_utf8_unchecked(&buf) }
            .parse()
            .ok()
            .expect("Parse error.")
    }
    pub fn vec<T: std::str::FromStr>(&mut self, n: usize) -> Vec<T> {
        (0..n).map(|_| self.read()).collect()
    }
    pub fn chars(&mut self) -> Vec<char> {
        self.read::<String>().chars().collect()
    }
}


Measured memory_bytes: 9340
#![allow(non_snake_case)]
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char)
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let k :i64 = read();
    for _ in 0..k {
        print!("ACL")
    }
}


Measured memory_bytes: 2004
#include<iostream>
#include<vector>
#include<map>
#include<string>
using namespace std;

int main(){
  vector<vector<int> > bingo(3,vector<int>(3));
  vector<int> vc;
  for(int i=0;i<3;i++){
    for(int j=0;j<3;j++){
      int a;
      cin >> a;
      bingo[i][j] = a;
    }
  }
  vector<vector<bool> > check(3,vector<bool>(3,false));
  int n;
  cin >> n;
  for(int num=0;num<n;num++){
    int b;
    cin >> b;
    for(int i=0;i<3;i++){
      for(int j=0;j<3;j++){
        if(bingo[i][j] == b) check[i][j] = true;
      }
    }
  }
  
  bool ans = 0;
  for(int i=0;i<3;i++){
    ans = ans || (check[i][0] && check[i][1] && check[i][2]);
    ans = ans || (check[0][i] && check[1][i] && check[2][i]);
    ans = ans || (check[0][0] && check[1][1] && check[2][2]);
    ans = ans || (check[0][2] && check[1][1] && check[2][0]);
  }

  if (ans==true){
    cout << "Yes" << endl;
  }else{
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
using System;

class ABC_123_B
{
    static void Main(string[] args)
    {
        int A = int.Parse(Console.ReadLine());
        int B = int.Parse(Console.ReadLine());
        int C = int.Parse(Console.ReadLine());
        int D = int.Parse(Console.ReadLine());
        int E = int.Parse(Console.ReadLine());

        int a = A % 10;
        int b = B % 10;
        int c = C % 10;
        int d = D % 10;
        int e = E % 10;

        if (a == 0) a = 10;
        if (b == 0) b = 10;
        if (c == 0) c = 10;
        if (d == 0) d = 10;
        if (e == 0) e = 10;

        int time = 0;
        if(a<b && a<c && a<d && a<e)
        {
            time = A + Wait(B) + Wait(C) + Wait(D) + Wait(E);
        }
        else if(b<a && b<c && b<d && b<e)
        {
            time = Wait(A) + B + Wait(C) + Wait(D) + Wait(E);
        }
        else if(c<a && c<b && c<d && c<e)
        {
            time = Wait(A) + Wait(B) + C + Wait(D) + Wait(E);
        }
        else if(d<a && d<b && d<c && d<e)
        {
            time = Wait(A) + Wait(B) + Wait(C) + D + Wait(E);
        }
        else
        {
            time = Wait(A) + Wait(B) + Wait(C) + Wait(D) + E;
        }

        Console.WriteLine(time);
    }

    static int Wait(int time)
    {
        if (time % 10 == 0) return time;

        return ((time/10)+1)*10 ;
    }
}


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

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {
            var N = cin.ReadInt;
            var K = cin.ReadInt;

            var ans = 1; 

            for (int i = 0; i < N; i++)
            {
                if (ans * 2 < ans + K) ans = ans * 2;
                else ans = ans + K;
            }

            WriteLine(ans);
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}

Measured memory_bytes: 13268
// This file is a "Hello, world!" in C++ language by GCC for wandbox.
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

int main(){
    ll n; cin >> n;
    ll a[n+1];
    ll b[n];
    ll sum = 0;
    for(ll i=0; i<=n; i++) cin >> a[i];
    for(ll i=0; i<n; i++) cin >> b[i];
    
    for(ll i=n-1; i>=0; i--){
        if(b[i] >= a[i+1] + a[i]){
            sum += a[i+1] + a[i];
            a[i] = 0;
        }else if(a[i+1] <= b[i] && b[i] < a[i+1] + a[i]) {
            sum += b[i];
            a[i] -= b[i] - a[i+1];
        }else{
            sum += b[i];
        }
                
    }
    cout << sum << endl;
}
    


Measured memory_bytes: 1792
import numpy as np

n, m, x = map(int, input().split())
a = []
cost_lst = []
for _ in range(n):
    lst = (list(map(int, input().split())))
    cost_lst.append(lst.pop(0))
    a.append(lst)
data = np.array(a)

min_cost = 9999999999

for i in range(2 ** n):
    b = np.zeros(m)
    cost = 0
    num = i
    for j in range(n):
        if num % 2 == 0:
            b += data[j]
            cost += cost_lst[j]
        num = num // 2
    for skill in b:
        if skill < x:
            break
    else:
        min_cost = min(min_cost, cost)

if min_cost == 9999999999:
    print(-1)
else:
    print(min_cost)


Measured memory_bytes: 27128
//Takoyaki 

#include<bits/stdc++.h>
using namespace std;
using ll = long long;
#define int long long
#define rep(i,x,y) for(ll i=x;i<y;i++)
#define nvarep(n,a) ll n;cin>>n;vector<ll>a(n);rep(i,0,n)cin>>a[i]
#define vecrep(n,a,type) vector<type>a(n);rep(i,0,n)cin>>a[i]
#define YN(flag) (flag?"Yes":"No")
#define lcm(a,b) (a/__gcd(a, b)*b)
#define range(a) (a).begin(),(a).end() 
#define pb push_back
#define mp make_pair
#define nnn "\n"
#define spa " "
using p = pair<ll,ll>;
using graph = vector<vector<ll>>;
const int inf = 2147483647;//2*10^9
const ll INF = 9223372036854775807;//9*10^18

signed main (){
    double n,x,t;cin>>n>>x>>t;
    int ans = ceil(n/x)*t;
    cout<<ans<<nnn;
    return 0;
}

Measured memory_bytes: 3712
letter=input()
K=int(input())
import re
ans=[]
X=[chr(i) for i in range(97, 97+26)]
for i in X:
   if i in letter:
      c=[m.end() for m in re.finditer(i, letter)]
      for j in c:
         for i in range(K):
            if j-1+i==len(letter):
               break
            ans.append(letter[j-1:j+i])
   ans=list(set(ans))
   if len(ans)>=5:
      break
ans.sort()
print(ans[K-1])

Measured memory_bytes: 4724
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <numeric>
//#include <function>
using namespace std;
typedef long long unsigned int ll;

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

#define REP(i, n) for(int i = 0; i < (int)(n); i++)


int main() {

  int H, W, h, w;
  cin >> H >> W;
  cin >> h >> w;

  cout << (W - w) * (H - h) << endl; 
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h> 
int k,n,a[505][505];
int main(){
	scanf("%d",&k);
	if (k==1){
		puts("1");
		puts("1");
		return 0;
	}
	int n=2*((k+3)/4);
	for (int i=1;i<=n;i++)
		for (int j=1;j<=n;j++)
			if (i%2==1){
				int t=(i+j)%n;
				if (t+n<k) a[i][j]=t+n;
				else a[i][j]=t;
			}else a[i][j]=(i+j)%n;
	printf("%d\n",n);
	for (int i=1;i<=n;i++){
		for (int j=1;j<=n;j++) printf("%d ",a[i][j]+1);
		puts("");
	}
}

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

using namespace std;

int main() {
    int N; cin >> N;
    vector<int> h(N, 0);
    for (int i = 0; i < N; i++) { cin >> h[i]; }

    vector<int> dp(N, 0);
    dp[1] = abs(h[0] - h[1]);
    for (int i = 2; i < N; i++) {
        dp[i] = min(abs(h[i] - h[i-1]) + dp[i - 1], abs(h[i] - h[i-2]) + dp[i - 2]);
    }
    cout << dp[N - 1] << endl;
}

Measured memory_bytes: 1024
import java.util.ArrayList;
import java.util.List;
import java.util.Scanner;

/**
 * Created by zhangrunfeng on 2/19/20
 */
public class Main {
    class PriorityQueue {
        private int len;
        private List<Long> queArr;

        public PriorityQueue() {
            len = 0;
            queArr = new ArrayList<>();
        }

        public void insert(long val) {
            len++;
            queArr.add(val);

            int currIx = len - 1;
            while (currIx > 0) {
                int parIx = (currIx - 1) / 2;
                if (queArr.get(parIx) < val) {
                    queArr.set(currIx, queArr.get(parIx));
                    currIx = parIx;
                } else {
                    break;
                }
            }
            queArr.set(currIx, val);
        }

        public long extract() {
            long ans = queArr.get(0);
            queArr.set(0, queArr.get(len - 1));
            queArr.remove(len - 1);
            len--;

            if (len == 0) return ans;

            int currIx = 0;
            long desVal = queArr.get(0);
            while (currIx * 2 + 1 < len) {
                int leftChild = currIx * 2 + 1, rightChild = currIx * 2 + 2;
                if (rightChild < len && queArr.get(rightChild) > queArr.get(leftChild)) {
                    leftChild = rightChild;
                }

                if (desVal >= queArr.get(leftChild)) break;

                queArr.set(currIx, queArr.get(leftChild));
                currIx = leftChild;
            }
            queArr.set(currIx, desVal);
            return ans;
        }
    }

    public Main(Scanner sc) {
        PriorityQueue que = new PriorityQueue();
        while (true) {
            String str = sc.next();
            if (str.equals("insert")) {
                long val = sc.nextLong();
                que.insert(val);
            } else if (str.equals("extract")) {
                long val = que.extract();
                System.out.println(val);
            } else if (str.equals("end")) {
                break;
            }
        }
    }

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


Measured memory_bytes: 594096
#include <iostream>

int main(){
  int x1, y1, x2, y2;
  std::cin>>x1>>y1>>x2>>y2;

  int dx = -(y2 - y1);
  int dy = x2 - x1;
  int x3, y3, x4, y4;
  x3 = x2 + dx;
  y3 = y2 + dy;
  x4 = x1 + dx;
  y4 = y1 + dy;

  std::cout<<x3<<" "<<y3<<" "<<x4<<" "<<y4<<std::endl;
  return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void) {
	int a,b,c;

	int i,num= 0;
	scanf("%d",&a);
	scanf(" %d",&b);
	scanf(" %d",&c);
	
	for(i=a;i <= b;i++){
		
	
		if(c % i == 0){
			num++;
		}
	
	}
	
	printf("%d\n",num);
	return 0;
}

Measured memory_bytes: 596
N, M = map(int,input().split())
dic = {}
for _ in range(N):
    a, b = map(int,input().split())
    if a in dic:
        dic[a] += b
    else:
        dic[a] = b

ans = 0
m = 0
for a, b in sorted(dic.items()):
    if m + b >= M:
        ans += a * (M - m)
        break
    m += b
    ans += a * b

print(ans)

Measured memory_bytes: 23000
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
template<class T> bool umin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool umax(T &a, T b) { return a < b ? (a = b, true) : false; }
#define ALL(x) (x).begin(), (x).end()
LL POW(LL a,LL p,LL M){ if(!p) return 1LL;LL T = POW(a,p/2,M);T = T*T%M; if(p&1) T=T*(a%M)%M; return T; }
LL SQRT(LL a) { LL b = (LL)sqrtl(((double)a)+0.5); while(b*b<a) ++b; while(b*b>a) --b; return (b*b==a)?b:-1; }
//endl
//<------------------------edits---------------------------------------------->
const LL MOD = 1e9+7;//998244353
// #define LOCAL LDD
// #define int LL

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  cout.precision(10);cout << fixed;
#ifdef LOCAL
  freopen("input.txt", "rt", stdin);
#endif
  int n,m;cin >> n >> m;
  int sm = 0;
  while(m--){
    int a;cin >> a;
    sm += a;
  } 
  if(sm>n) cout << -1 << endl;
  else cout << n-sm << endl;
  cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s\n";
  return 0;
}

Measured memory_bytes: 3864
#include <stdio.h>
#define NOT_FOUND -1
int A[100000];
int main() {
  int i, j, n, m, l, count=0;
  scanf("%d", &n);
  for(i = 0; i < n; i++) {
    scanf("%d", &A[i]);
  }
  scanf("%d", &m);
  int B[50000];
  for(i = 0; i < m; i++) {
    scanf("%d", &B[i]);
    l = binarySearch(n, B[i]);
    if(l != NOT_FOUND) count++;
  }
  printf("%d\n", count);
  return 0;
}

int binarySearch(int n, int key) {
  int mid, left=0, right=n;
  while(left < right) {
    mid = (left + right)/2;
    if(A[mid] == key) return mid;
    else if(key < A[mid]) right = mid;
    else left = mid + 1;
  }
  return NOT_FOUND;
}

Measured memory_bytes: 1180
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define all(V) V.begin(),V.end()
const ll MOD = 1000000007;

bool dp[81][81][25610];
int A[81][81];

int main() {
	//12805
	for (int i = 0;i < 81;i++) {
		for (int j = 0;j < 81;j++) {
			for (int k = 0;k < 25610;k++) {
				dp[i][j][k] = 0;
			}
		}
	}
	int H, W, B;
	cin >> H >> W;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			cin >> A[i][j];
		}
	}
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			cin >> B;
			A[i][j] -= B;
		}
	}

	dp[0][0][12805] = 1;
	for (int i = 0;i < H;i++) {
		for (int j = 0;j < W;j++) {
			for (int k = 0;k < 25610;k++) {
				if (!dp[i][j][k])continue;
				dp[i + 1][j][k + A[i][j]] = 1;
				dp[i + 1][j][k - A[i][j]] = 1;
				dp[i][j + 1][k + A[i][j]] = 1;
				dp[i][j + 1][k - A[i][j]] = 1;
			}
		}
	}

	for (int k = 0;k < 12800;k++) {
		if (dp[H - 1][W][12805 + k]) {
			cout << k << endl;
			return 0;
		}
		if (dp[H - 1][W][12805 - k]) {
			cout << k << endl;
			return 0;
		}
	}
}

Measured memory_bytes: 164352
//contact me:subhajitmahata06@gmail.com 
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h> 
using namespace std;
#define fast ios_base::sync_with_stdio(0);cin.tie(0)
#define ll long long
#define fo(i,n) for(ll i=0;i<n;i++)
#define Fo(i,k,n) for(ll i=k;i<n;i++)
#define fr(i,k,n) for(ll i=k;i>n;i--)
#define deb(x) cout << #x << "=" << x << endl
#define deb2(x, y) cout << #x << "=" << x << "," << #y << "=" << y << endl
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define all(x) x.begin(), x.end()
#define clr(x) memset(x, 0, sizeof(x))
#define sortall(x) sort(all(x))
#define tr(it, a) for(auto it = a.begin(); it != a.end(); it++)
#define PI 3.1415926535897932384626
#define endl "\n"
typedef pair<int, int>	pii;
typedef pair<ll, ll>	pl;
typedef vector<int>		vi;
typedef vector<ll>		vl;
typedef vector<pii>		vpii;
typedef vector<pl>		vpl;
typedef vector<vi>		vvi;
typedef vector<vl>		vvl;

#define int ll
//===========================templates=========================
 int32_t main() {
    fast;
    ll h,n;
    cin>>h>>n;
    ll res=0;
    res=h/n;
    if(h%n)
    res++;
    cout<<res;
	return 0;
}


Measured memory_bytes: 256
from collections import deque
n = int(input())
li = []
l = []
di = {}
for i in range(n):
    a, b = map(int, input().split())
    li.append((a+b, -a, i))
    l.append((b+a, -b, i))
    di[i] = False
li.sort(reverse=True)
l.sort(reverse=True)
li = deque(li)
l = deque(l)
left, right = 0, 0
while li:
    while True and li:
        p = li.popleft()
        if di[p[2]]:
            continue
        di[p[2]] = True
        left += -p[1]
        break
    if len(l) != 0:
        while True and l:
            q = l.popleft()
            if di[q[2]]:
                continue
            di[q[2]] = True
            right += -q[1]
            break
print(left-right)


Measured memory_bytes: 120136