akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<algorithm>
#include<queue>
#include<deque>
#include<cmath>
#include<map>
#include<cstring>
#include<iomanip> //cout << fixed << setprecision(15) << x << endl;

using namespace std;
typedef long long ll;
const int INF = 1e9 + 6;
const ll MOD = 1e9 + 7;
const ll LLINF = 1LL<<60;
//#define P pair<int, int>
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define pb push_back
#define mp make_pair
#define all(x) (x).begin(),(x).end()
/* -- template -- */

struct UnionFind {
    vector<int> par;
    vector<int> si;
    UnionFind(int N) : par(N), si(N) {
        for(int i = 0; i < N; ++i) par[i] = i;
        for(int i = 0; i < N; ++i) si[i] = 1;
    }

    int root(int x) {
        if(par[x] == x)return x;
        return par[x] = root(par[x]);
    }

    void unite(int x, int y) {
        int rx = root(x);
        int ry = root(y);
        if(rx == ry) return;
        par[rx] = ry;
        si[ry] += si[rx];
    }
    bool same(int x, int y) {
        return root(x) == root(y);
    }
    int size(int x) {
        return si[root(x)];
    }
};

int main() {
    int N, M, K; cin >> N >> M >> K;
    vector<vector<int>>friends(N);
    vector<vector<int>>blocks(N);
    UnionFind tree(N);
    rep(i, M) {
        int a, b; cin >> a >> b; --a, --b;
        friends[a].pb(b);
        friends[b].pb(a);
        tree.unite(a, b);
    }
    rep(i, K) {
        int a, b; cin >> a >> b; --a, --b;
        blocks[a].pb(b);
        blocks[b].pb(a);
    }
    rep(i, N) {
        int ans = tree.size(i) - int(friends[i].size()) - 1;
        for(int v : blocks[i]) {
            if(tree.same(v, i))--ans;
        }
        cout << ans << ' ';
    }
}


Measured memory_bytes: 12920
#include<bits/stdc++.h>
using namespace std;
int main(){
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x, n, temp;
    unordered_set<int>s;
    cin>>x>>n;
    for(int i = 0; i < n; i++){
        cin>>temp;
        s.insert(temp);
    }
    int res1, res2;
    for(int i = x; i < INT_MAX; i++){
        if(s.find(i) == s.end()){
            res1 = i;
            break;
        }
    }
    for(int i = x; i > INT_MIN; i--){
        if(s.find(i) == s.end()){
            res2 = i;
            break;
        }
    }
    int res;
    if(abs(res1 - x) < abs(res2 - x)){
        res = res1;
    }
    else{
        res = res2;
    }
    cout<<res;
    s.clear();
    return 0;
}

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

int main(){
  int t, n, k;
  cin >> t;
  for(int r = 0; r < t; r++){
    priority_queue<int> que;
    cin >> n >> k;
    int x[n];
    cin >> x[0];
    for(int i = 1; i < n; i++){
      cin >> x[i];
      que.push(x[i] - x[i - 1]);
    }
    int sum = x[n - 1] - x[0];
    for(int i = 0; i < k - 1; i++){
      //cout << "i:" << i << endl;
      if(que.empty()){
	break;
      }
      sum -= que.top();que.pop();
    }
    //if(n - k <= 1)sum = 0;
    cout << sum << endl;
  }
}

Measured memory_bytes: 2468
// D - Rain Flows into Dams
// https://atcoder.jp/contests/abc133/tasks/abc133_d?lang=en

#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define MAX 100000 + 4
ll n;
ll a[MAX];

int main() {
  scanf("%lld", &n);
  for (ll i=0; i<n; i++)
    scanf("%lld", &a[i]);

  ll x2=0;
  for (ll i=0; i<n; i++) {
    if (i%2)
      x2 -= a[i];
    else
      x2 += a[i];
  }

  ll ans[n] = {0};
  ans[0] = x2/2;
  for (ll i=0; i<n-1; i++) {
    ans[i+1] = a[i]-ans[i];
  }

  for (ll i=0; i<n; i++)
    printf("%lld ", ans[i]*2);
  printf("\n");
}


Measured memory_bytes: 2816
#include<bits/stdc++.h>
using namespace std;
#define itn int
#define int long long
#define mod 1000000007
#define fi first
#define se second
#define be begin()
#define en end()
#define re reverse
#define Set setprecision 
const int INFi=2147483647;
const long long INFl=9223372036854775807LL;
template<typename T> T abs(T a,T b){
    return max(a,b)-min(a,b);
}
template<typename T> T lcm(T a,T b){//最小公倍数
  return (a*b)/gcd(a,b);
}
int  gcd(int a,int b){//最大公約数
  int c=a%b;
  while(true){
    if(c==0) break;
    a=b;
    b=c;
    c=a%b;
  }
  return b;
}
bool IsPrime(int num){
    if (num < 2) return false;
    else if (num == 2) return true;
    else if (num % 2 == 0) return false;
    double sqrtNum = sqrt(num);
    for(int i=3;i<=sqrtNum;i+=2){
	if(num%i==0){
	    return false;
	}
    }
  return true;
}
signed main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int a,b,c;
    //string a;
    cin>>a>>b>>c;
    if(a==b){
	if(a!=c) cout<<"Yes";
	else cout<<"No";
    }
    else if(a==c){
	if(a!=b) cout<<"Yes";
	else cout<<"No";
    }
    else if(b==c){
	if(b!=a) cout<<"Yes";
	else cout<<"No";
    }
    else cout<<"No";
    cout<<"\n";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
//#pragma GCC optimize("O3")
//#pragma GCC target("sse4")
 
#define FOR(i, a, b) for(int i = (a); i < (b); ++i)
#define RFOR(i, b, a) for(int i = (b) - 1; i >= (a); --i)
#define ITER(it, a) for(__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a, value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)((a).size())
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long LL;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = (LL)INF * INF;

const int mod = 1000 * 1000 * 1000 + 7;
const int MAX = 1 << 17;

int add(int a, int b)
{
	return a + b < mod ? a + b : a + b - mod;
}

int mult(int a, int b)
{
	return (LL)a * b % mod;
}

int binPow(int a, int n)
{
	int res = 1;
	while(n)
	{
		if(n & 1)
			res = mult(res, a);
		a = mult(a, a);
		n >>= 1;
	}
	return res;
}

int x[MAX];

int main()
{
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	int n;
	cin >> n;
	FOR(i, 0, n)
		cin >> x[i];
	int ans = 0;
	int f = 1, s = 0;
	FOR(i, 1, n)
	{
		int d = x[i] - x[i - 1];
		f = mult(f, i);
		s = add(s, binPow(i, mod - 2));
		ans = add(ans, mult(s, d));
	}
	cout << mult(ans, f) << "\n";
	return 0;
}


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

#define rep(i, n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b)for(int i=(int)(a);(i)<(int)(b);i++)
#define BTC 380000.0

typedef unsigned long long ull;
typedef long long ll;

const int INF = 1001001001;

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

    vector<int> num_mgr(m+1);
    int k; int prev; 
    rep(i, n) { 
        cin >> k;
        int foods[k];
        rep(j, k) {
            cin >> foods[j];
            num_mgr[foods[j]]++;
            // cout << num_mgr[foods[j]] << endl;
        }
    }
    int count = 0;
    rep(i, m+1) {
        if (num_mgr[i] == n) count++;
    }
    cout << count << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <stdbool.h>
#include <math.h>

#define MAX 200000 //ベルトラン・チェビシェフの定理より,100000以降の初めの素数は必ず200000以下にあるから.

bool solve(int X);
int X;

int main(int argc, char const *argv[])
{
	scanf("%d", &X);
	for (int i = X; i < MAX; ++i)
	{
		if (solve(i))
		{
			printf("%d\n", i);
			break;
		}
	}

	return 0;
}



bool solve(int X){
	if (X == 2)
	{
		return true;
	}
	
	else if (X%2 == 0)
	{
		return false;
	}

	else{
		int x;
		x = (int)sqrt(X);
		for (int i = 3; i < x+1; i+=2)
		{
			if (X%i == 0)
			{
				return false;
			}
		}

		return true;
	}

}

Measured memory_bytes: 128
//KING NIKAN
#include <bits/stdc++.h>
using namespace std;
int a[10010] ;int ans[110][110] ;
int main() 
{
	ios::sync_with_stdio(false) ;cin.tie(0) ;cout.tie(0) ;
	int h , w , n ;
	cin >> h >> w >> n ;
	for(int i=1 ;i<=n ;i++)
	{
		cin >> a[i] ;
	}
	int k=1 ;
	for(int i=0 ;i<h ;i++)
	{
		if(i%2==0)
		{
			for(int j=0 ;j<w ;j++)
			{
				if(a[k]==0)
				{
					k++ ;
				}
				a[k]-- ;
				ans[i][j]=k ;
			}
		}
		else if(i%2)
		{
			for(int j=w-1 ;j>=0 ;j--)
			{
				if(a[k]==0)
				{
					k++ ;
				}
				a[k]-- ;
				ans[i][j]=k ;
			}
		}
	}
	for(int i=0 ;i<h ;i++)
	{
		for(int j=0 ;j<w ;j++)
		{
			cout << ans[i][j] << " " ;
		}
		cout << "\n" ;
	}
}

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

int main()
{
    long long int H, W, M, i, j, h, w, h_max, w_max;
    cin >> H >> W >> M;
    vector<set<long long int>> h_set(H, set<long long int>());
    vector<set<long long int>> w_set(W, set<long long int>());
    vector<pair<long long int, long long int>> h_score(H);
    for (i = 0; i < H; i++)
    {
        h_score[i].first = 0;
        h_score[i].second = i;
    }
    vector<pair<long long int, long long int>> w_score(W);
    for (i = 0; i < W; i++)
    {
        w_score[i].first = 0;
        w_score[i].second = i;
    }
    for (i = 0; i < M; i++)
    {
        cin >> h;
        h -= 1;
        cin >> w;
        w -= 1;
        h_score[h].first += 1;
        w_score[w].first += 1;
        h_set[h].insert(w);
        w_set[w].insert(h);
    }
    sort(h_score.begin(), h_score.end(), greater<pair<long long int, long long int>>());
    sort(w_score.begin(), w_score.end(), greater<pair<long long int, long long int>>());
    h_max = h_score[0].first;
    w_max = w_score[0].first;
    i = 0;
    j = 0;
    long long int minus = 1;
    if (h_max == 0 && w_max == 0)
    {
        cout << 0 << endl;
        return 0;
    }
    else
    {
        while (h_score[i].first == h_max && i < H)
        {
            j = 0;
            while (w_score[j].first == w_max && j < W)
            {
                if (h_set[h_score[i].second].find(w_score[j].second) == h_set[h_score[i].second].end() || h_set[h_score[i].second].empty())
                {
                    minus = 0;
                    goto OUT;
                }
                j++;
            }
            i++;
        }
    OUT:
        cout << h_max + w_max - minus << endl;
        return 0;
    }
}

Measured memory_bytes: 69000
#include <bits/stdc++.h>
#define int long long
#define mod (int)(1e9+7)
#define inf (int)(3e18+7)
#define rep(i,n) for(int i=0;i<n;i++)
#define REP(i,n) for(int i=1;i<n;i++)
#define P pair<int,int>
#define PiP pair<int,pair<int,int>>
#define all(v) v.begin(),v.end()
#define mkp make_pair
#define mkt make_tuple
#define prique(T) priority_queue<T,vector<T>,greater<T>>
#define vecunique(vec) sort(vec.begin(), vec.end());decltype(vec)::iterator result = std::unique(vec.begin(), vec.end());vec.erase(result, vec.end())
using namespace std;

bool prime(int x) {
	for (int i = 2; i * i <= x; i++) {
		if (x % i == 0)return false;
	}
	return x > 1;
}
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
int kai(int x) {
	if (x == 0)return 1;
	return kai(x - 1) * x % mod;
}
int mod_pow(int x, int y, int mod_) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % mod_;
		}
		x = x * x % mod_;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x)* mod_pow(kai(x - y), mod - 2, mod) % mod * mod_pow(kai(y), mod - 2, mod) % mod;
}
/*--------Library Zone!--------*/


signed main() {
	int a, b, c; cin >> a >> b >> c;
	if (a % 2 == 0 || b % 2 == 0 || c % 2 == 0)cout << 0 << endl;
	else {
		cout << min({ a * b,b * c,c * a }) << endl;
	}
}


Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

double distance(ddatas& x,ddatas& y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  ll i,j=0;
  char ans[11];
  string s;
  cin>>s;
  rep(i,s.size()){
    if(s[i]=='B'){
      if(j)j--;
    }else{
      ans[j++]=s[i];
    }
  }
  ans[j]='\0';
  cout<<ans<<endl;
  return 0;
}

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

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

	//calculation
	int output = 0;
	for (int i = 0; i < S.size(); i++) {
		if (S[i] != T[i]) {
			output++;
		}
	}

	//output
	cout << output << endl;


	return 0;
}


Measured memory_bytes: 3920
#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;
    ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
    ll LCM(ll a,ll b){return (a*b)/GCD(a,b);}
    int abs(int x){return x>0?x:-x;}
     
    //const int dx[] = {1, 0, -1, 0, 1, -1, -1, 1};
    //const int dy[] = {0, 1, 0, -1, 1, 1, -1, -1};
     
    int main()
    {
     
    	ll MOD = 1e9 + 7;
    	int n;
    	cin >> n;
    	int a[n];
    	map<int, int> m;
    	REP(i, n){
    		cin >> a[i];
    		m[a[i]]++;
    	}
     
    	bool flag = 0;
     
    	if (n % 2){
    		for (auto x : m){
    			if (x.first == 0){
    				if (x.second != 1) flag = 1;
    			}
    			else if (x.second != 2) flag = 1;
    		}
    	}
    	else {
    		for (auto x : m){
    			if (x.second != 2) flag = 1;
    		}
    	}
     
    	if (flag) cout << 0 << endl;
    	else {
    		ll ans = 1;
    		for (int i = 0; i < n/2; i++){
    			ans *= 2;
    			ans %= MOD;
    		}
     
    		cout << ans << endl;
    	}
     
    }

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


#define INF 1000000000000

signed main()
 {
string s;
cin>>s;
rep(i,s.size()){
  if(i%2==0){
    cout<<s.at(i);
  }
}
}


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

using namespace std;



int main() {
	int n;
	cin >> n;
	vector<long long> h(n);

	for (int i = 0; i < n;i++) {
		cin >> h[i];
	}

	long long ans = 0, now = 0;

	for (int i = 0; i < n-1; i++) {

		if (h[i] >= h[i+1]) {
			now++;
		}else {
			if (now > ans) {
				ans = now;
				
			}
			now = 0;
		}
	}

	if (now > ans) {
		ans = now;

	}

	cout << ans;

	//system("pause");
	return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <bitset>
#include <fstream>
#include <string>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <deque>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <unordered_map>
#include <cassert>
//#include <boost/multiprecision/cpp_int.hpp>

const double EPS = (1e-10);


using namespace std;
using Int = long long;
//using namespace boost::multiprecision;

const Int MOD = 998244353;

Int mod_pow(Int x, Int n) {
    Int res = 1;
    while(n > 0) {
        if(n & 1) res = (res * x) % MOD; //ビット演算(最下位ビットが1のとき)
        x = (x * x) % MOD;
        n >>= 1; //右シフト(n = n >> 1)
    }
    return res;
}

//最大公約数
template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

//最小公倍数
template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

//入出力高速化(非同期化)
void fast_input() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

char field[70][70];
int d[70][70];

int solve(int H, int W) {
    int INF = 100000000;
    memset(d, 0, sizeof(d));
    for (int i = 0; i < 70; i++) {
        for (int j = 0; j < 70; j++) {
            if (!i || !j) field[i][j] = '#';
            else if (i == H*2 || j == W*2) field[i][j] = '#';
            else field[i][j] = '.';
        }
    }
    for (int i = 0; i < 70; i++) {
        for (int j = 0; j < 70; j++) {
            if (i % 2 == 0 && j % 2 == 0) {
                field[i][j] = '#';
            }
            d[i][j] = INF;
        }
    }

    for (int i = 1; i < H*2; i += 2) {
        for (int j = 1; j < W*2; j += 2) {
            if (j + 1 == W*2) continue;
            char input; cin >> input;
            if (input == '1') field[i][j+1] = '#';
        }
        if (i + 1 == H*2) continue;
        for (int j = 1; j < W*2; j += 2) {
            char input; cin >> input;
            if (input == '1') field[i+1][j] = '#';
        }
    }

    /*for (int i = 0; i <= H*2; i++) {
        for (int j = 0; j <= W*2; j++) {
            cout << field[i][j];
        }
        cout << endl;
    }*/
    int dx[] = {0, 1, 0, -1};
    int dy[] = {1, 0, -1, 0};
    d[1][1] = 2;

    queue<pair<int, int>> q;
    q.push({1, 1});
    while (!q.empty()) {
        pair<int, int> crt = q.front();
        q.pop();
        for (int i = 0; i < 4; i++) {
            int ni = dy[i] + crt.first;
            int nj = dx[i] + crt.second;
            if (field[ni][nj] == '.' && d[ni][nj] > d[crt.first][crt.second] + 1) {
                q.push({ni, nj});
                d[ni][nj] = d[crt.first][crt.second] + 1;
            }
        }
    }

    if (d[2*H-1][2*W-1] == INF) return 0;
    return d[2*H-1][2*W-1]/2;
}

int main(void) {
    int H, W;
    vector<int> ans;
    while (1) {
        cin >> W >> H;
        if (!W && !H) break;
        ans.push_back(solve(H, W));
    }
    for (auto &i: ans) {
        cout << i << endl;
    }
}




Measured memory_bytes: 3072
#include <algorithm>
#include <iostream>
#include <vector>
#include <numeric>
#include <string>
#include <stdio.h>
#include <set>
#include <iomanip>
using namespace std;
 
int main(){
    long long N, K;
    cin >> N >> K;
    long long m = N / K;
    long long a = N - K * m;
    long long b = abs(N - K * m - K);
    cout << min(a, b) << endl;
    return 0;
}

Measured memory_bytes: 3636
def dfs(n, sum ,depth):
    if(depth == 0):
        return int(sum == s)
    else:
        count = 0
        for i in xrange(n+1,10):
            count += dfs(i, sum+i, depth-1)
        return count

while True:
    (n, s) = [int(i) for i in raw_input().split()]
    if((0,0) == (n,s)):
        break
    print dfs(-1,0,n)

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

int main()
{
    int pasuta[3];
    int dorink[2];

    for (int i = 0; i < 3; i++){
        cin >> pasuta[i];
    }
    for (int i = 0; i < 2; i++){
        cin >> dorink[i];
    }

    sort(pasuta, pasuta + 3);
    sort(dorink, dorink + 3);

    cout << (pasuta[0] + dorink[0]) - 50 << endl;

    return (0);
}

Measured memory_bytes: 3164
## coding: UTF-8
import math

A, B = map(int,input().split())

ans = -1
for i in range(1, 1050):
    a = math.floor(i * 0.08)
    b = math.floor(i * 0.10)
    #print(i, a, b)
    if(a == A and b == B):
        ans = i
        break

print(ans)

Measured memory_bytes: 40336
#include <bits/stdc++.h>
using namespace std;
 
#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b) - 1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))
 
#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair
 
typedef long long Int;
typedef vector<int> VI;
typedef pair<int, int> PII;
 
const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000;
const Int LINF = INF * (Int) INF;
const int MAX = 307;
const int MOD = 998244353;

// mt19937 rng;

Int dp[MAX][MAX][MAX];

int nx[MAX];

int main(int argc, char* argv[])
{
	//ios::sync_with_stdio(false); cin.tie(0);
    // rng = mt19937(chrono::steady_clock::now().time_since_epoch().count());

    string s;
    cin >> s;
    int k;
    cin >> k;
    if (k > SZ(s))
        k = SZ(s);

    reverse(ALL(s));

    dp[0][0][0] = 1;

    nx[SZ(s)] = SZ(s);

    RFOR(i,SZ(s), 0) {
        if (s[i] == '0')
            nx[i] = i;
        else
            nx[i] = nx[i + 1];
    }

    FOR(i,0,SZ(s) + 1) {
        RFOR(j,i + 1,0) {
            FOR(k,0,i + 1) {
                if (dp[i][j][k] == 0)
                    continue;
                if ((i == SZ(s) || s[i] == '0') && j > 0) {
                    dp[i][j - 1][k] += dp[i][j][k];
                    dp[i][j - 1][k] %= MOD;
                }
                if (i == SZ(s))
                    continue;
                dp[i + 1][j][k] += dp[i][j][k];
                dp[i + 1][j][k] %= MOD;
                if (s[i] == '1' && nx[i] != SZ(s)) {
                    int cnt = nx[i] - i;
                    dp[nx[i] + 1][j + cnt][k + cnt] += dp[i][j][k];
                    dp[nx[i] + 1][j + cnt][k + cnt] %= MOD;
                }
            }
        }
    }

    Int res = 0;
    FOR(i, 0, k + 1) {
        // cout << i << ' ' << dp[SZ(s)][0][i] << endl;
        res += dp[SZ(s)][0][i];
        res %= MOD;
    }

    cout << res << endl;
    
    
    cerr << 1.0 * clock() / CLOCKS_PER_SEC << endl;
	return 0;
}



Measured memory_bytes: 97740
use std::io::*;
use std::str::FromStr;

fn main() {
    let n: usize = read();
    let d: usize = read();
    let x: Vec<Vec<i64>> = (0..n).map(|_| (0..d).map(|_| read()).collect()).collect();

    let mut ans = 0;
    for i in 0..n {
        for j in i+1..n {
            let mut sum = 0;
            for k in 0..d {
                let po = x[i][k] - x[j][k];
                sum += po * po;
            }
            let sqrt = (sum as f64).sqrt() as i64;
            if sqrt*sqrt == sum {
                ans += 1;
            }
        }
    }
    println!("{}", ans);
}

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


Measured memory_bytes: 4352
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdbool.h>
#include <math.h>

int main(void){
    long long r,d,x;
    scanf("%lld%lld%lld",&r,&d,&x);
    for (int i=0; i<10; i++){
        printf("%lld\n",x*r-d);
        x=x*r-d;
    }
    return 0 ;
}

Measured memory_bytes: 128
N = int(input())
S = input()

R = S.count('R')
G = S.count('G')
B = S.count('B')

res = 0
for i in range(N - 1):
    for j in range(i + 1, N):
        k = j + j - i
        if k >= N:
            break
        if S[i] != S[j] and S[j] != S[k] and S[i] != S[k]:
            res += 1

res = R * G * B - res
print(res)


Measured memory_bytes: 68084
#include <bits/stdc++.h>
#pragma gcc optimize("ofast")
using namespace std;

#define ll long long //data types used often, but you don't want to type them time by time
#define ull unsigned long long
#define ui unsigned int
#define mod 1000000007
#define us unsigned short
#define IOS ios_base::sync_with_stdio(0); //to synchronize the input of cin and scanf
#define INF LONG_MAX
#define PI 3.1415926535897932384626
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define rep(x,j,n)for(int x=j;x<n;x++)
typedef vector<pair<ll,ll>> vpi;
typedef vector<ll> vi;
typedef vector<vi> vvi;

ll modexp(ll a,ll b,ll m)
{
	ll r=1;
	a=a%m;
	while(b>0)
	{
		if(b&1)
		    r=(r*a)%m;
		b>>1;
		a=(a*a)%m;
	}
	return r%m;
}

int main(){
    ll n; cin>>n;
    string a,b;
    rep(i,0,n)
    {
        char c; cin>>c;
        a.pb(c);
    }
    rep(i,0,n)
    {
        char c; cin>>c;
        b.pb(c);
    }
std::string str;
rep(i,0,n)
{
    char c = '1'+i;
    str.pb(c);
}
vector<string>ans;
std::stable_sort(std::begin(str), std::end(str));
do {
    string temp;
    for(auto&& element : str)temp.pb(element);
    ans.pb(temp);
} while (std::next_permutation(std::begin(str), std::end(str)));

ll p = 0, q = 0;
rep(i,0,ans.size())
{
    if(ans[i]==a)p = i;
    if(ans[i]==b)q=i;
}
cout<<fabs(p-q)<<endl;
    return 0;
}


Measured memory_bytes: 2424
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using namespace std;
int MOD = 1000000007;
int INF = numeric_limits<int>::max() / 2;

// 辺に重みをつける場合 
struct Edge{
  int to;
  int cost;
  Edge(int t,int c) : to(t), cost(c) {}
};

typedef pair<int, int> P;
using Graph = vector<vector<Edge>>;

int dist1[100010], dist2[100010];

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

  int N, M, S, T; cin >> N >> M >> S >> T;
  S--; T--;
  
  Graph G1(N), G2(N);
  for(int i=0;i<M;i++){
    int A, B, C, D;
    cin >> A >> B >> C >> D;
    --A; --B;
    G1[A].push_back(Edge(B, C));
    G1[B].push_back(Edge(A, C));
    G2[B].push_back(Edge(A, D));
    G2[A].push_back(Edge(B, D));
  }
  fill(dist1, dist1+N, INF);
  fill(dist2, dist2+N, INF);
  dist1[S] = 0, dist2[T] = 0;
 
  priority_queue<P, vector<P>, greater<P>> que1, que2;
  que1.push(P(0, S));
  que2.push(P(0, T));

  while(!que1.empty()){
      P p = que1.top();
      que1.pop();
      int d = p.first;
      int u = p.second;

      if(d > dist1[u]) continue;

      for(int i = 0; i < G1[u].size(); ++i){
          int v = G1[u][i].to;
          int d2 = G1[u][i].cost;

          if(dist1[v] > dist1[u] + d2){
              dist1[v] = dist1[u] + d2;
              que1.push(P(dist1[v], v));
          }
      }
  }

  while(!que2.empty()){
      P p = que2.top();
      que2.pop();
      int d = p.first;
      int u = p.second;

      if(d > dist2[u]) continue;

      for(int i = 0; i < G2[u].size(); ++i){
          int v = G2[u][i].to;
          int d2 = G2[u][i].cost;

          if(dist2[v] > dist2[u] + d2){
              dist2[v] = dist2[u] + d2;
              que2.push(P(dist2[v], v));
          }
      }
  }

  int A[N], maxi = 0;
  for(int i=N-1;i>=0;i--){
    int cnt = 1000000000000000 - dist1[i] - dist2[i];
    maxi = max(maxi, cnt);
    A[i] = maxi;
  }
  rep(i,N) cout << A[i] << endl;

}

Measured memory_bytes: 20216
use std::collections::HashMap;

const MOD: i64 = 1000000007;


fn main() {
    let comb = Comb::new(1e5 as usize + 100, MOD);
    let (n, m) = read_tuple::<i64>();

    let fact = prime_factorize(m);

    let mut ans:i64 = 1;
    for (_p, count) in fact.iter() {
        ans *= comb.nck((count + n - 1) as usize, *count as usize);
        ans %= MOD;

    }
    println!("{:?}", ans);

}

fn prime_factorize(mut n: i64) -> HashMap<i64, i64> {
    let mut res = HashMap::new();
    let mut i = 2;
    while i * i <= n {
        let mut count = 0;
        while n % i == 0 {
            count += 1;
            n /= i;
        }
        if count > 0 {
            res.insert(i, count);
        }
        i += 1;
    }

    if n != 1 {
        res.insert(n, 1);
    }
    res
}


/// for nCk
pub struct Comb {
    max: usize,
    m: i64,
    fac: Vec<i64>,
    finv: Vec<i64>,
}

impl Comb {
    /// initialize table 
    /// max: maximum that n as nCk takes
    /// m: MOD, a prime number
    /// O(n)
    pub fn new(max: usize, m: i64) -> Comb {
        let n = max;
        let mut fac = Vec::with_capacity(n);
        fac.push(1);
        fac.push(1);
        let mut finv = Vec::with_capacity(n);
        finv.push(1);
        finv.push(1);
        let mut inv = Vec::with_capacity(n);
        inv.push(1);
        inv.push(1);

        for i in 2..n {
            let i = i as i64;
            let new_fac = fac.last().unwrap() * i % m;
            fac.push(new_fac);
            let new_inv = m - inv[(m % i) as usize] * (m / i) % m;
            inv.push(new_inv);
            let new_finv = finv.last().unwrap() * inv.last().unwrap() % m;
            finv.push(new_finv);
        }

        Comb {
            max: max,
            m: m,
            fac: fac,
            finv: finv
        }
    }

    /// nCk
    pub fn nck(&self, n: usize, k: usize) -> i64 {
        // since n, k are usize, do not need to check `n < 0 || k < 0`
        if n < k || n > self.max {
            panic!("Invalid query (n, k) = ({}, {})", n, k);
        } else {
            self.fac[n] * (self.finv[k] * self.finv[n - k] % self.m) % self.m
        }
    }
}



fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().split_whitespace()
        .map(|e| e.parse().ok().unwrap()).collect()
}
fn read_tuple<T: std::str::FromStr + Copy>() -> (T, T) {
    let temp = read_vec();
    (temp[0], temp[1])
}


Measured memory_bytes: 6396
#include <cstdio>
#include <cstring>
#include <algorithm>

int main(void)
{
    char S[1010], T[1010];

    scanf("%s%s", S, T);
    int n = strlen(S);
    int m = strlen(T);
    int min = 12341234;

    for (int i = 0; i+m <= n; i++)
    {
        int k = 0;
        for (int j = 0; j < m; j++)
        {
            k += (S[i+j] != T[j]);
        }
        min = std::min(min,k);
    }

    printf("%d\n", min);
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    int cnt = 0;
    int max_cnt=0;
    rep(i,s.size()){
        if (s[i] == 'A' || s[i] == 'C' || s[i] == 'G' || s[i] == 'T'){
            cnt ++;
            max_cnt = max(max_cnt, cnt);
        }
        else{
            cnt = 0;
        }
    }
    cout << max_cnt << endl;
}

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

int main(){
    ll i,j;
    ll n;
    cin>>n;
    vector<ll> v;
    for(i=0;i<n;i++){
        ll x;
        cin>>x;
        x=-x;
        auto it=upper_bound(v.begin(),v.end(),x);
        if(it==v.end()) v.pb(x);
        else v[it-v.begin()]=x;       
    }
    cout<<v.size()<<endl;
    
}

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

const int N=1000010;

vector<int> e[N];
int n,sg[N],u,v;

void dfs(int u,int fa)
{
    sg[u]=0;
    for(auto v : e[u])
    {
        if(v==fa)continue;
        dfs(v,u);
        sg[u]^=sg[v]+1;
    }
}

int main()
{
    cin>>n;
    for(int i=1;i<n;++i)
    {
        cin>>u>>v;
        e[u].push_back(v);
        e[v].push_back(u);
    }
    dfs(1,0);
    puts(sg[1]?"Alice":"Bob");
}

Measured memory_bytes: 35328
#include <bits/stdc++.h>
#define mp make_pair
#define pb push_back
#define all(x) x.begin(),x.end()
#define cmin(a,b) (a>b?a=b:a)
#define cmax(a,b) (a<b?a=b:a)
#define mem(a,k) memset(a,k,sizeof(a))
#define lop(i,s,t) for(int i=s;i<(t);++i)
#define rep(i,s,t) for(int i=s;i<=(t);++i)
#define dec(i,s,t) for(int i=s;i>=(t);--i)
#define fore(i,v) for(int i=g[v],d=es[i].d;i;i=es[i].nxt,d=es[i].d)
using namespace std;

#define Pr(f,...) fprintf(stderr,f,##__VA_ARGS__),fflush(stderr)

typedef long long ll;

template<typename T>
void read(T &x){
	x=0; 
	char c;
	for(c=getchar();!isdigit(c);c=getchar()); 
	for(;isdigit(c);c=getchar())x=x*10+c-'0'; 
}

const int N=1e6+50,P=1e9+7,oo=P;

int mul(int a,int b){ return 1ll*a*b%P; }
//int add(int a,int b){ a+=b; return a>=P?a-P:a; }
int sub(int a,int b){ a-=b; return a<0?a+P:a; }
int gcd(int a,int b){ return !b?a:gcd(b,a%b); }

int z,n,sum[N],mx[N],ans;
char s[N];

int main(int argc,char *argv[]){
#ifdef CURIOUSCAT
	freopen("d.in","r",stdin); 
#endif
	scanf("%s",s+1);
	z=0,n=strlen(s+1);
	rep(i,1,n){
		sum[i]=sum[i-1]+(s[i]=='1'?1:-1);
		cmax(z,sum[i]);
	}
	mx[n+1]=-oo;
	dec(i,n,1){
		mx[i]=max(mx[i+1],sum[i]);
	}
	ans=oo;
	lop(k,0,2){
		int w=0,mn=0;
		rep(i,1,n){
			if(s[i]=='?'&&w+mx[i]+2<=z+k){
				w+=2;
			}
			cmin(mn,w+sum[i]);
		}
		cmin(ans,z+k-mn);
	}
	cout<<ans<<endl;
	return 0;
}


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

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

Measured memory_bytes: 256
#include<iostream> 
#include<string> 
#include<vector> 
#include<algorithm> 
#include<cmath>
#include<set>
#include<utility>

using namespace std;


int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	int max = 0;
	vector<int> b(100001);

	for (int i = 0; i < n; i++)
	{
		cin >> a[i];
		b.at(a[i])++;
	}
	sort(a.begin(), a.end());
	
	int ans = 0;
	for (int i = 0; i < a.at(n-1)+1; i++)
	{
		
		int x = 0;
		if (i == 0)
		{
			x = b.at(i) + b.at(i + 1);
		}
		else if (i==a.at(n-1))
		{
			x = b.at(i - 1) + b.at(i) ;
		}
		else
		{
			x = b.at(i - 1) + b.at(i) + b.at(i + 1);
		}
		if (ans < x)
		{
			ans = x;
		}
	}
	cout << ans << endl;

	

}

Measured memory_bytes: 1024
#include <iostream>
#include<algorithm>
#include<set>
#include<iterator>
#include<map>
#include<cmath>
#include<unordered_map>
#include<vector>
using namespace std;
#define int long long
#define endl "\n"
#define pb push_back
#define F first
#define S second
#define fo(i,n) for(int i=0;i<n;++i)
#define all(v) v.begin(),v.end()
#define fastio ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); 
const int inf = (1e18)+7;
const int neginf = -1*((int)1e17 ) + 7 ; 

int32_t main() {
    fastio
        
    int n,m;
    cin>>n>>m;
    
    
    char arr[n][m];
    
    fo(i,n)
        fo(j,m)
        cin>>arr[i][j];
    
    int ct = 0;
    for(int i=0;i<n;++i)
    {
        for(int j=0;j<m;++j)
        {
            if(arr[i][j]=='.')
            {
                if(i-1>=0&&arr[i-1][j]=='#')
                    ct++;
                if(i+1<n&&arr[i+1][j]=='#')
                    ct++;
                if(j-1>=0&&arr[i][j-1]=='#')
                    ct++;
                if(j+1<m&&arr[i][j+1]=='#')
                    ct++;
                if(i-1>=0&&j-1>=0&&arr[i-1][j-1]=='#')
                    ct++;
                if(i+1<n&&j+1<m&&arr[i+1][j+1]=='#')
                    ct++;
                if(i-1>=0&&j+1<m&&arr[i-1][j+1]=='#')
                    ct++;
                if(i+1<n&&j-1>=0&&arr[i+1][j-1]=='#')
                    ct++;
                arr[i][j] = (ct+'0');
                ct = 0;
            }
            
        }
    }
    
    fo(i,n)
    {
        fo(j,m)
            cout<<arr[i][j];
        cout<<endl;
    }
    
    
     
    
    
    

        
        
        
    
            
        
       
        
        
        
    
     
    
    
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<cstdio>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
using namespace std;
typedef long long ll;
typedef unsigned int ui;
const ll mod = 998244353;
const ll INF = (ll)1000000007 * 1000000007;
typedef pair<int, int> P;
#define stop char nyaa;cin>>nyaa;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef long double ld;
typedef complex<ld> Point;
const ld eps = 1e-9;
const ld pi = acos(-1.0);
typedef pair<ll, ll> LP;

int x[1 << 17];
int main(){
	int n, m; cin >> m >> n;
	rep(i, n) {
		cin >> x[i];
	}
	sort(x, x + n);
	vector<int> v;
	rep(i, n - 1) {
		v.push_back(x[i + 1] - x[i]);
	}
	sort(v.begin(), v.end());
	ll ans = 0;
	rep(i, n - m) {
		ans += v[i];
	}
	cout << ans << endl;
	//stop
	return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
typedef long long int lli;
#define vv vector<lli>
#define vp vector<pair<lli,lli>>
#define vpp vector<pair<lli,pair<lli,lli>>>
#define lims(w) (w).begin(),(w).end()
#define rlims(w) (w).rbegin(),(w).rend()
#define pb push_back
#define mp make_pair
#define f(i,a,b) for(lli i=a;i<b;i++)
#define ff first
#define ss second
#define sz(a) (lli)(a.size())
lli inf = (1e18 + 2);

int main()
{
	lli h,w,m,ro,co;
	cin>>h>>w>>m;
	map<lli, lli>r;
	map<lli, lli>c;
	set<pair<lli, lli>>s;
	set<lli>rows;
	set<lli>cols;
	lli maxR = -inf, maxC = -inf;

	f(i,0,m)
	{
		cin>>ro>>co;

		if(rows.count(ro) == 0)
		{
			rows.insert(ro);
			r[ro] = 1;
		}

		else
			r[ro]++;

		if(cols.count(co) == 0)
		{
			cols.insert(co);
			c[co] = 1;
		}

		else
			c[co]++;
		s.insert(mp(ro,co));
	}

	vv rr;
	vv cc;

	for(auto itr = rows.begin(); itr != rows.end(); ++itr)
	{
		maxR = max(maxR, r[*itr]);
	}

 	for(auto itr = rows.begin(); itr != rows.end(); ++itr)
        {
                if(r[*itr] == maxR)
			rr.pb(*itr);
        }

	for(auto itr = cols.begin(); itr != cols.end(); ++itr)
	{
		maxC = max(maxC, c[*itr]);
	}

	for(auto itr = cols.begin(); itr != cols.end(); ++itr)
        {
                if(c[*itr] == maxC)
			cc.pb(*itr);
        }

	lli ans = maxR + maxC;
	lli poss = sz(rr) * sz(cc);
	bool noBomb = false;

	if(m < poss)
		cout<<ans<<endl;
	else
	{
		f(i,0,sz(rr))
			f(j,0,sz(cc))
				if(s.count(mp(rr[i],cc[j])) == 0)
					noBomb = true;
		if(!noBomb)
			ans--;
		cout<<ans<<endl;
	}

	return 0;
}


Measured memory_bytes: 95928
#include<iostream>
#include<cstdio>
#include<cstring>
#include<string>
#include<vector>
#include<cmath>
#include<algorithm>
#include<map>
#include<queue>
#include<deque>
#include<iomanip>
using namespace std;
typedef long long int LL;
typedef pair<int,int> P;
typedef pair<int,pair<int,int> > PP;
typedef pair<LL,int> LP;
const int INF=1<<30;
const LL MAX=1e9+7;

void array_show(int *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%d%c",array[i],(i!=array_n-1?middle:'\n'));
}
void array_show(LL *array,int array_n,char middle=' '){
	for(int i=0;i<array_n;i++)printf("%lld%c",array[i],(i!=array_n-1?middle:'\n'));
}
void print_YES_NO(bool answer){cout<<(answer?"YES":"NO")<<endl;}
void print_Yes_No(bool answer){cout<<(answer?"Yes":"No")<<endl;}
void print_POSSIBLE_IMPOSSIBLE(bool answer){cout<<(answer?"POSSIBLE":"IMPOSSIBLE")<<endl;}

int main(){
	char ca[5];
	cin>>ca;
	if(ca[0]==ca[1] || ca[1]==ca[2] || ca[2]==ca[3])cout<<"Bad"<<endl;
	else cout<<"Good"<<endl;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
#include <deque>
#include <queue>
#include <unordered_map>
#include <stack>
#include <bitset>
#include <cstdlib>
#include <sstream>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll pow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = pow(N, P/2);
        return t*t;
    }
    return N * pow(N, P-1);
}
ll modpow(ll N, ll P,ll k){
    if(P==0) return 1;
    if(P%2==0){
        ll t = modpow(N, P/2,k)%k;
        return t*t%k;
    }
    return N * modpow(N, P-1,k)%k;
}
ll modkai(ll n,ll m,ll k){//n*(n-1)*(n-2)*...(m+1)%k
    if(n == m)return 1;
    return modkai(n-1,m,k)*n%k;
}
ll mod_cnb(ll n,ll m,ll k){//nCm%k,kは十分大きい素数
  int m_=modkai(m,0,k);
  return modkai(n,n-m,k)*modpow(m_,k-2,k)%k;
}
ll gcd(ll n,ll m){
    ll n_ = max(n,m);
    ll m_ = min(n,m);
    if(n_%m_ == 0)return m_;
    return gcd(m_,n_%m_);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}

int main(){
    ll n;cin>>n;
    vector<ll>a(n);
    ll cnt=0;
    bool flag=0;
    rep(i,n){
        ll x;cin>>x;
        if(x==0)flag=1;
        if(x<0)cnt++;
        a[i]=abs(x);
    }
    if(cnt%2==0)flag=1;
    if(flag){
        ll ans=0;
        rep(i,n)ans+=a[i];
        cout<<ans<<endl;
    }
    else {
        sort(a.begin(),a.end());
        ll ans=-a[0];
        rep(i,n-1)ans+=a[i+1];
        cout<<ans<<endl;
    }

}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
 #include <math.h>
 using namespace std;
 
 int main(){
    int a, b;
    int i;

    cin >> a >> b;

    if(a > b){
        for (i=0; i<a; i++)
            cout << b;
        cout << endl;
        }
    else{
         for (i=0; i<b; i++)
            cout << a;
        cout << endl;
        }
    return 0;
 }
 


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define REPLL(i, n) for (ll i = 0; i < (ll)(n); i++)
using namespace std;
template<class T>inline bool chmax(T &a, const T &b){if(a < b){a = b; return 1;}return 0;}
template<class T>inline bool chmin(T &a, const T &b){if(a > b){a = b; return 1;}return 0;}
typedef long long ll;

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int S, W; cin >> S >> W;
  if(S <= W){
    cout << "unsafe" << endl;
  }else{
    cout << "safe" << endl;
  }
}

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

#define NDEBUG
#ifdef DEBUG
#include "../cout11.h"
#undef NDEBUG
#endif
#include <cassert>

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> ii;
typedef pair<ll,ll> llll;
typedef pair<double,double> dd;

typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<ii> vii;
typedef vector<vector<ii>> vvii;
typedef vector<ll> vll;

#define sz(a)  int((a).size())
#define pb  push_back
#define FOR(var,from,to) for(int var=(from);var<=(to);++var)
#define rep(var,n)  for(int var=0;var<(n);++var)
#define rep1(var,n)  for(int var=1;var<=(n);++var)
#define repC2(vari,varj,n)  for(int vari=0;vari<(n)-1;++vari)for(int varj=vari+1;varj<(n);++varj)
#define ALL(c)  (c).begin(),(c).end()
#define RALL(c)  (c).rbegin(),(c).rend()
#define tr(i,c)  for(auto i=(c).begin(); i!=(c).end(); ++i)
#define found(s,e)  ((s).find(e)!=(s).end())
#define mset(arr,val)  memset(arr,val,sizeof(arr))
#define mid(x,y) ((x)+((y)-(x))/2)
#define IN(x,a,b) ((a)<=(x)&&(x)<=(b))


bool solve(int H, int W, vector<string>& a){
    int te = (H-1) + (W-1);
    vector<int> pat(te, 1);
    rep(i, H-1) pat[i] = 0;
    char board[8][8];
    do{
        mset(board, '.');
        int x=0,y=0;
        board[y][x] = '#';
        rep(i,te){
            if (pat[i] == 1) ++x;
            else ++y;
            board[y][x] = '#';
        }
#ifdef DEBUG
        cout << pat << endl;
        rep(y,H){
            rep(x,W) putchar(board[y][x]);
            putchar('\n');
        }
        cout << '-' << endl;
        rep(y,H){
            cout << a[y] << endl;
        }
#endif
        bool ok = true;
        rep(y,H)rep(x,W){
            if (board[y][x] != a[y][x]){
                ok = false; goto bad;
            }
        }
        return true;
    bad:
        ;

    } while(next_permutation(ALL(pat)));

    return false;
}

int main() {
    int H,W;
    cin >> H>>W;
    vector<string> a(H);
    rep(i,H) cin >> a[i];
    cout << (solve(H,W,a) ? "Possible":"Impossible") << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>

int main(void){
    long int n,k,num;
    scanf("%ld%ld",&n,&k);
    if(n%k==0){
        printf("0\n");
        return 0;
    }
    n -= (n/k)*k;
    num = ((n/k)+1)*k-n;
    if(n<=num){
        printf("%ld\n",n);
    }else{
        printf("%ld\n",num);
    }
    return 0;
}


Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define repr(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) for(int i=0;i<n;i++)
#define reprrev(i,a,b) for(int i=b-1;i>=a;i--) // [a, b)
#define reprev(i,n) reprrev(i,0,n)
typedef long long ll;
typedef unsigned long long ull;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const ll mod = 1e9+7;

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

ll modpow(ll x, ll n){
    if(n==0) return 1;
    ll res=modpow(x, n/2);
    if(n%2==0) return res*res%mod;
    else return res*res%mod*x%mod;
}

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

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

// get<K>(tuple型の変数)

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

const int inf = 1<<29;
int n, m;
int s, t;
vector<int> adj[200005];
vector<vector<int>> dist;

using tpl = tuple<int, int, int>;

void input(){
    cin >> n >> m;
    rep(i, m){
        int u, v; cin >> u >> v;
        --u, --v;
        adj[u].push_back(v);
    }
    cin >> s >> t;
    --s; --t;
}

void Dijkstra(int s){
    dist.resize(n, vector<int>(3, inf));
    priority_queue<tpl, vector<tpl>, greater<tpl>> pq;
    dist[s][0] = 0;
    pq.push(make_tuple(0, s, 0));

    while(!pq.empty()){
        int d, now, r;
        tie(d, now, r) = pq.top(); pq.pop();
        if(dist[now][r] < d) continue;
        for(auto to : adj[now]){
            int nr = getr(r, 3);
            if(dist[to][nr] > d+1){
                dist[to][nr] = d+1;
                pq.push(make_tuple(dist[to][nr], to, nr));
            }
        }
    }
}

void solve(){
    Dijkstra(s);
    int ans = dist[t][0];
    if(ans == inf) cout << -1 << endl;
    else cout << ans / 3 << endl;

}

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

    input();
    solve();
    
    return 0;
}

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

int main() {
  int N;
  scanf("%d\n", &N);
  vector<int> h(N);
  for (int i = 0; i < N; i++) {
    scanf("%d", &h[i]);
  }

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

  printf("%d\n", dp[N-1]);
}

Measured memory_bytes: 1024
#include <iostream>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef long long LL;
const int MAXN = 1e3+17;
int main(int argc ,char const *argv[])
{
    #ifdef noob
    freopen("Input.txt","r",stdin);freopen("Output.txt","w",stdout);
    #endif
    int n,m;
    cin>>n>>m;

    if(n==1&&m==1)
    	cout<<1<<endl;
    else if(n==1)
    	cout<<m-2<<endl;
    else if(m==1)
    	cout<<n-2<<endl;
    else 
   	 cout<<1LL*(n-2)*(m-2)<<endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
using namespace std;
int main(){
int A,B,C,D,E,F;
 cin>>A>>B>>C;
  D=10*A+B+C;
  E=10*B+A+C;
  F=10*C+A+B;
  cout<<max({D,E,F})<<endl;
  return 0;
}


Measured memory_bytes: 256