akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <queue>
#define N 300005
using namespace std;
typedef long long ll;
ll n, mx, a[N], b[N], c[N];
priority_queue<ll> qb, qc;
int main() {
	ll i;
	scanf("%lld", &n);
	for(i=1; i<=3*n; i++) scanf("%lld", &a[i]);
	for(i=1; i<=n; i++) qb.push(-a[i]), b[i] = b[i-1] + a[i];
	for(i=n+1; i<=2*n; i++) {
		b[i] = b[i-1];
		if(qb.top() > -a[i]) {
			b[i] += a[i] + qb.top(); qb.pop();
			qb.push(-a[i]);
		}
	}
	for(i=3*n; i>2*n; i--) qc.push(a[i]), c[i] = c[i+1] + a[i];
	mx = b[2*n] - c[2*n+1];
	for(i=2*n; i>n; i--) {
		c[i] = c[i+1];
		if(qc.top() > a[i]) {
			c[i] -= qc.top() - a[i]; qc.pop();
			qc.push(a[i]);
		}
		mx = max(mx, b[i-1]-c[i]);
	}
	printf("%lld", mx);
	return 0;
}

Measured memory_bytes: 8180
#include <iostream>
#include <algorithm>
#include <cmath>
#include <limits>
#include <vector>
#include <cstdio>
#include <bits/stdc++.h>
#include <set>
#include <map>
#include <stdio.h>
#include <stack>
#include <queue>
#include <deque>
#include <numeric>
#include<bits/stdc++.h>
#include <utility>

#define ALL(obj) (obj).begin(), (obj).end()
#define FOR(i,a,b) for(int i = (a); i < (b); i++)
#define RFOR(i,a,b) for(int i = (a); (b) <= i; i--)
#define REP(i,n) for(int i = 0; i < (n); i++)
#define RREP(i,n) for(int i = n; n <= i; i--)
#define ABS(a) ((a < 0) ? ((-1)*(a)) : (a))
#define elif else if
#define MOD 1000000007
#define INF (1<<29)

using namespace std;
using ll = long long;
map <int ,int> mpa,mpb;
typedef pair<ll, ll> P;
priority_queue<P, vector<P>, greater<P>> pque;

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

  pair<int,int> r[110],b[110];
  bool flag[110];
  int N;
  cin >> N;
  int p,q;

  for(int i=0;i<N;i++){
    cin >> p >> q;
    r[i]=make_pair(p,q);
    flag[i]=true;
  }
  for(int i=0;i<N;i++){
    cin >> p >> q;
    b[i]=make_pair(p,q);
  }
  sort(b,b+N);

  int ans=0;
  for(int i=0;i<N;i++){
    int k=10000;
    for(int j=0;j<N;j++){
      if(!flag[j]) {
        continue;
      }
      if(r[j].first<b[i].first && r[j].second<b[i].second){
        if(k==10000 || r[k].second < r[j].second){
          k=j;
        }
      }
    }
    if(k!=10000){
      flag[k]=false;
      ans++;
    }
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void) {

	int H,W,i,j;



	while(1){


		scanf("%d %d",&H,&W);


		if(H==0&&W==0) break;


		for(i=1;i<=H;i++){


			for(j=1;j<=W;j++){

				if((i+j)%2==0)

					putchar('#');

				else

					putchar('.');


			}


			putchar('\n');


		}


		putchar('\n');


	}


	return 0;


}


Measured memory_bytes: 2100
#include <iostream>
#include <algorithm>
#include <numeric>
#include <vector>

using namespace std;

int calc(string::iterator &itr) {
	if(*itr != '[') {
		int num = 0;
		while(*itr!=']') {
			num = num *  10 + (*itr++ - '0');
		}
		return (num + 1) / 2;
	}
	itr++;
	vector<int> nums;
	while(*itr != ']') {
		nums.push_back(calc(itr) );
	}
	itr++;
	sort(nums.begin(), nums.end());
	return accumulate(nums.begin(), nums.begin() + (nums.size() + 1) / 2, 0);
}

int main() {
	int n;
	cin >> n;
	while(n--) {
		string s;
		cin >> s;
		string::iterator itr = s.begin();
		cout << calc(itr) << endl;
	}
	return 0;
}

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

int main(){
  int x1,y1,x2,y2,x3,y3,x4,y4;
  cin >> x1 >> y1 >> x2 >> y2;
  x3=x2-(y2-y1);
  y3=y2+(x2-x1);
  x4=x3-(y3-y2);
  y4=y3+(x3-x2);
  cout << x3 << " " << y3 << " " << x4 << " " << y4 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <sstream>
#include <vector>
#include <cmath>
#include <ctime>
#include <cassert>
#include <ctype.h>
#include <iomanip>
#include <cstdio>
#include <float.h>
#include <queue>
#include <set>
#include <map>
#include <fstream>
#include <cstdlib>
#include <string>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <stack>
#include <functional>
// #include <pair> 
       
using namespace std;
       
#define endl '\n'
#define MOD 1000000007
#define INF 1ll<<30
 
// #define MAX 100010
 
#define eps 1e-11
#define bit_max 1ll<<32
#define _USE_MATH_DEFINES
 
// long long binpow(long long a,long long b)
// {
//     if (b == 1) return a;
//     long long res = binpow(a, b/2)%MOD;
//     if (b % 2) return (res*((res*a)%MOD))%MOD;
//     else return (res * res)%MOD;
// }
 
// long long int fact(long long int a)
// {
//     if(a==0||a==1)
//         return 1;
//     long long int ans = 1;
//     for(int i=a;i>=1;i--)
//         ans = (ans * i);
//     return ans;
// }
 
// long long int ivmod(long long int a)
// {
//     return binpow(a,MOD-2);
// }
 
// long long int ncr(long long int a,long long int b)
// {
//     long long int pans=1;
//     for(int i =a;i>max(b,a-b);i--)
//         pans=pans*i;
//     long long int div = fact(min(b,a-b));
//     // cout<<ans<<"            "<<div<<endl;
//     pans = pans/div;
//     return pans;
// }
long long int gcd(long long int a,long long int b)
{
    if(a%b==0||a==b||b%a==0)
    {
        return b;
    }
    else
    {
        if(a>b)
        {
            return gcd(a%b,b);
        }
        else
        {
            return gcd(a,b%a);
        }
    }

}

int main()
{
    // 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   
    long int n;
    cin>>n;
    unsigned long long int a[n];
    for(int i=0;i<n;i++)
    {
        cin>>a[i];
    }
    unsigned long long int aa=a[0];
    for(int i=0;i<n;i++)
    {
        // cout<<"THIS IS GCD"<<__gcd(aa,a[i])<<endl;
        // cout<<aa<<endl;

        aa = (aa)*(a[i]/__gcd(aa,a[i]));
        // cout<<aa<<endl;

    }
    cout<<aa<<endl;
    return 0;
}

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

int main(){
    string s;
    cin >> s;
    ll tot = 0;
    vector<int> dp(2), p(2);
    dp.at(0) = 0;
    dp.at(1) = 1;
    rep(i,s.size()){
        char c  = s.at(i);
        int d = atoi(&c);
        swap(p,dp);
        dp.at(0) = min(p.at(0)+d,p.at(1)+(10-d));
        if(d==9){
            dp.at(1) = p.at(1);
        }else {
            dp.at(1) = min(p.at(0)+d+1, p.at(1)+(10-d-1));
        }
    }
    ll res = min(dp.at(0),dp.at(1)+1);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 1412
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
#include<string>
#include<cstring>
#include<cstdlib>
#include<utility>
#include<map>
#include<vector>
#include<stack>
#include<queue>
#define loop(i,a,b) for(int i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define pi acos(-1)
#define pb push_back
#define all(v) v.begin(),v.end()
using namespace std;
typedef pair<int,int> p;
typedef long long ll;

int func(int num){
	int res=0;
	while(num!=0){
		res+=num%10;
		num/=10;
	}
	return res;
}

int main(){
	int n,a,b;
	cin>>n>>a>>b;
	int sum=0;
	loop(i,1,n+1)if(a<=func(i) && func(i)<=b)sum+=i;
	cout<<sum<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC optimize ("-ffloat-store")  
#pragma GCC optimize ("-fno-defer-pop")
//setbase - cout << setbase (16); cout << 100 << endl; Prints 64
#define all(a) a.begin(),a.end()
#define ll long long int
#define ld long double
ll power(ll a,ll b,ll m){ if(b==0) return 1; if(b==1) return a%m; ll t=power(a,b/2,m)%m; t=(t*t)%m; if(b&1) t=((t%m)*(a%m))%m; return t;}
ll modInverse(ll a, ll m) { return power(a, m-2, m); }
#define ps push_back
#define fs first
#define takeline cin.ignore();
#define sc second
#define N 3000005
#define endl "\n"
#define mod 1000000007
int main(){

	ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
	
	ll i,j,k,n;
	cin>>n;
	ll ar[n+10];
	for(i=1;i<=n;i++){
		cin>>ar[i];
	}

	ll an=0;
	for(i=2;i<n;i++){
		vector<ll> vc;
		vc.ps(ar[i]); vc.ps(ar[i-1]); vc.ps(ar[i+1]);
		sort(all(vc));
		if(vc[1]==ar[i]){
			an++;
		}
	}
	cout<<an;
	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std ; 
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fast ios_base:: sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int long long int
#define endl "\n"
#define pb push_back
#define bs binary_search
#define lb lower_bound
#define ub upper_bound
#define f first
#define s second
#define pii pair<int,int> 
long long MOD  = 1e9+7;


signed main(){
    fast;
    int n,m; cin >> n >> m;
    char a[n+1][m+1];
    for(int i=1 ; i<=n ; i++){
        for(int j=1 ; j<=m ; j++){
            cin >> a[i][j];
        }
    }

    int dp[n+1][m+1];
    memset(dp,0,sizeof(dp));

    dp[1][1] = 1;
    for(int i=1 ; i<=n  ; i++){
        for(int j=1 ; j<=m ; j++){
            if(a[i][j]=='#')
                continue;
            dp[i][j] = ((dp[i-1][j]%MOD) + (dp[i][j-1]%MOD) + (dp[i][j]%MOD))%MOD;
        }
    }

    cout << dp[n][m]%MOD << endl;
    cerr << endl;
}

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

int main() { 
  string t;
  cin >> t;
  
  for (int i = 0; i < t.size(); i++){
    if (t.at(i) == '?'){
      t.at(i) = 'D';
    }
  }
  
  cout << t << endl;
  
}

Measured memory_bytes: 3756
#define _CRT_SECURE_NO_WARNINGS
#include <bits/stdc++.h>
using namespace std;
#define len(n) (int)n.length()
#define pb push_back
#define ll long long
#define make_pair mkp
#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 ALL(v) (v).begin(), (v).end()
#ifdef DBGPRT
#define dbg(n) cerr << "//" << #n << ":" << n <<endl
#else
#define dbg(n) ;
#endif
typedef pair<ll, ll> LLARR;
#define INF 999999999
const double PI = 3.1415926535897932384626433832795;

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

	int n;
	cin >> n;
	string s;
	cin >> s;
	int ans = 0;
	int x = 0;
	REP(i, n)
	{
		ans = max(ans, (s[i] == 'I' ? ++x : --x));
	}
	cout << ans << endl;
	return 0;
}

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

#define DEBUG 1
 



int main() {

    int N;
    cin >> N;

    vector <long long> A(N);

    for(int i = 0;i < N; i++){
        cin >> A.at(i);
    }

    long long fumidai_total = 0;
    long long previous_fumidai = 0;

    for(int i = 1; i < N; i++){
        if(A.at(i) < A.at(i - 1) + previous_fumidai){
            fumidai_total += A.at(i-1) + previous_fumidai - A.at(i);
            previous_fumidai = A.at(i-1) + previous_fumidai - A.at(i);
        }else{
            previous_fumidai = 0;
        }
    }

    cout << fumidai_total << endl;







    return 0;

}




Measured memory_bytes: 4776
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = ll(1e9) + 1;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, n) for(int i = 1; i <= (int)(n); i++)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } return 0; }

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

  string s;
  cin >> s;

  int dp[n][3];
  for (int i = 0; i < n; ++i) {
    if (i == 0) {
      dp[i][0] = 0;
      dp[i][1] = 0;
      dp[i][2] = 0;
    } else {
      dp[i][0] = dp[i - 1][0];
      dp[i][1] = dp[i - 1][1];
      dp[i][2] = dp[i - 1][2];
    }
    if (s[i] == 'R') dp[i][0] += 1;
    if (s[i] == 'G') dp[i][1] += 1;
    if (s[i] == 'B') dp[i][2] += 1;
  }

  ll ans = 0;
  for (int i = 0; i < n - 2; ++i) {
    for (int j = i + 1; j < n - 1; ++j) {
      if (s[i] == s[j]) continue;

      int fail = j + j - i;
      if ((s[i] == 'G' && s[j] == 'B' ) || (s[j] == 'G' && s[i] == 'B')) {
        ans += dp[n-1][0] - dp[j][0];
        if (s[fail] == 'R') ans -= 1;
      }
      if ((s[i] == 'R' && s[j] == 'B' ) || (s[j] == 'R' && s[i] == 'B')) {
        ans += dp[n-1][1] - dp[j][1];
        if (s[fail] == 'G') ans -= 1;
      }
      if ((s[i] == 'R' && s[j] == 'G' ) || (s[j] == 'R' && s[i] == 'G')) {
        ans += dp[n-1][2] - dp[j][2];
        if (s[fail] == 'B') ans -= 1;
      }
    }
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 3680
#include <cstdio>
int main(){
	long a,b,x,y;
	while (~scanf("%ld%ld", &a, &b)) {
		for(x=a,y=b; x%=y; x^=y^=x^=y);
		printf("%ld %ld\n", y, a*b/y);
	}
}

Measured memory_bytes: 1024
#include <iostream>  // cin,cout
#include <stdio.h>   // printf,scanf (standard input/output)
#include <cmath>     // abs(x),pow(x,2)
#include <string>
#include <string.h>  // strlen, strcmp
#include <algorithm> // min,max, sort(v.begin(),v.end())
#include <vector>
#include <time.h>
using namespace std;

struct Data{
    int A;
    string S;
    
    bool operator<( const Data& right ) const {
        return A == right.A ? S < right.S : A < right.A;
        //return A < right.A;
    }
};

int Func(){
    int x = 0;
    return x;
}

int main(){
    int N;
    float x[10];
    string u[10];
    cin >> N;
    for (int i=0;i<N;i++) {
        cin >> x[i] >> u[i];
    }
    
    float result = 0.0;
    for (int i=0;i<N;i++) {
        if (u[i]=="JPY") result += x[i];
        else result += x[i]*380000.0;
    }
    
    cout << result << 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 P = pair<int, int>;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> t;
  vector<int> three;
  map<int, int> mp;
  rep(i, n){
    cin >> a[i];
    mp[a[i]]++;
  }
  if(mp.size() > 3){
    cout << "No" << endl;
    return 0;
  }
  if(mp.size() == 1){
    if(mp[0] != n){
      cout << "No" << endl;
    }else {
      cout << "Yes" << endl;
    }
  }else if(mp.size() == 2){
    for(auto v: mp){
      t.push_back(v.first);
    }
    if(mp[t[1]] == 2 * mp[0] && mp[0] != 0){
      cout << "Yes" << endl;
    }else {
      cout << "No" << endl;
    }
  }else{
    for(auto v: mp){
      three.push_back(v.first);
    }
    if(mp[three[0]] == mp[three[1]] && mp[three[1]] == mp[three[2]] && (three[0] ^ three[1] ^ three[2]) == 0){
      cout << "Yes" << endl;
    }else{
      cout << "No" << endl;
    }
  }
}


Measured memory_bytes: 4224
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }



signed main(){

    int X; cin >> X;
    int N1 = 0, N2 = INF;
    
    while(N2 - N1 > 1){
        int N = (N1 + N2) / 2;
        int cnt = 0;
        int N0 = N;
        while(N > 2){
            N = (N - 1) / 2;
            cnt++;
        }
        if(cnt <= X) N1 = N0;
        else N2 = N0;
    }
    cout << N1 << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <algorithm>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <regex>
#include <numeric>
using namespace std;


/*--- Macro ---*/
#define rep(i, n) for(int i=0; i<(int)n; i++)
#define rep1(i, n) for(int i=1; i<(int)n; i++)
#define mp make_pair
#define pb push_back


/*---  Type ---*/
typedef long long ll;
typedef pair<int, int> pi;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;


/*--- Constants ---*/
template <typename T> const T INF = numeric_limits<T>::max() / 10;
const int MOD = (int)1e9 + 7;

// 4-direction
int dy4[] = {0,  1, -1,  0};
int dx4[] = {1,  0,  0, -1};

// 8-direction
int dy8[] = {0,  1,  1,  1,  0, -1, -1, -1};
int dx8[] = {1,  1,  0, -1, -1, -1,  0,  1};

// Floating
const double EPS = 1e-11;
#define EQ0(x) (abs(x) < EPS)
#define EQ(x, y) (abs(a-b) < EPS)

int main() {
  int n;
  vector< pair<int, int> > tasks;
  cin >> n;
  rep(i, n) {
    int a, b;
    cin >> a >> b;
    tasks.pb(mp(b, a));
  }

  sort(tasks.begin(), tasks.end());

// for(auto task : tasks) {
//   cout << task.first << ", " << task.second << endl;
// }

  bool enable = true;
  int now = 0;
  for(auto task : tasks) {
    now += task.second;
    if(now > task.first) {
      enable = false;
      break;
    }
  }

  cout << (enable ? "Yes" : "No") << endl;

  return 0;
}

Measured memory_bytes: 2420
n = int(input())
dat = [[0] * 10 for _ in range(10)]
for i in range(1, n+1):
    dat[int(str(i)[0])][int(str(i)[-1])] += 1
res = sum([dat[a][b] * dat[b][a] for a in range(10) for b in range(10)])
print(res)

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

int main(){
    int x,y;
    
    while(1){
        cin >> x >> y;
        if(x == 0 && y == 0)break;
        
        if(x >= y){
            cout << y << " " << x << endl;
        }
        else{
            cout << x << " " << y << endl;
        }
    }
    return 0;
    
}


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

constexpr int MAX_NM = 100000;

long long N, M;
std::string S, T;

long long gcd(long long a, long long b);

long long lcm(long long a, long long b);

int main(){

	std::cin >> N >> M >> S >> T;

	long long G = gcd(N, M);
	long long L = lcm(N, M);

	bool flag = true;

	for(int i = 0; i < G; ++i){
		if(S[i * (L / M)] != T[i * (L / N)]){
			flag = false;
			break;
		}
	}

	if(flag){
		std::cout << L << std::endl;
	}
	else{
		std::cout << -1 << std::endl;
	}

	return 0;
}

long long gcd(long long a, long long b){
	if(a == 0) return b;
	else return gcd(b % a, a);
}

long long lcm(long long a, long long b){
	return a * b / gcd(a, b);
}


Measured memory_bytes: 512
def main():
    S = input()
    K = int(input())
    l = []
    t = 1
    m = S[0]
    if len(S) == 1:
        print(K//2)
        return
    if len(S) == 2:
        if S[0] == S[1]:
            print(K)
            return
        else:
            print(0)
            return
    if len(S) == 3:
        if S[0] == S[1] == S[2]:
            print(3*K//2)
            return
        elif S[0] == S[1] or S[1] == S[2]:
            print(K)
            return
        elif S[0] == S[2]:
            print(K-1)
            return
        else:
            print(0)
            return
    for v in S[1:]:
        if v == m:
            t += 1
        elif t != 1:
            l.append(t)
            t = 1
        m = v
    if t != 1:
        l.append(t)
    ls = 0
    lsm = 0
    lsu = 0
    if S[0] == S[-1]:
        if len(l) == 1 and l[0] == len(S):
            print(l[0] * K//2)
            return
        elif len(l) == 1:
            print(((l[0] + 1)//2) *(K-1) + (l[0] // 2))
            return
        if S[0] == S[1] == S[-2]:
            ls = l[-1] + l[0]
            lsm = l[0]
            lsu = l[-1]
            l = l[1:-1]
        elif S[-1] == S[-2]:
            ls = l[-1] + 1
            lsu = l[-1]
            l = l[:-1]
        elif S[0] == S[1]:
            ls = l[0] + 1
            lsm = l[0]
            l = l[1:]
        else:
            ls = 2
    r = 0
    for i in l:
        r += i // 2
    r *= K
    r += (K-1) * (ls // 2)
    r += (lsm  // 2) + (lsu // 2)
    print(r)
main()


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

typedef long long ll;
using namespace std;
ll a7=1000000007;
ll inf=100000000000000000;

ll min(ll a,ll b){
    if(a<b)return a;
    else return b;
}
ll max(ll a,ll b){
    if(a>b)return a;
    else return b;
}

unordered_map<string,ll> dp[101];

int main(){
    ll n;cin>>n;
    string ii,jj,kk;
    string s;
    for(ll i=0;i<4;i++){
        for(ll j=0;j<4;j++){
            for(ll k=0;k<4;k++){
                ii=to_string(i);
                jj=to_string(j);
                kk=to_string(k);
                s=ii+jj+kk;
                if(s!="012" && s!="021" && s!="201"){
                    dp[3][s]=1;
                }
            }
        }
    }
    string sl;
    string s1,s2;
    string ss;
    for(ll x=3;x<=n-1;x++){
        for(ll i=0;i<4;i++){
            for(ll j=0;j<4;j++){
                for(ll k=0;k<4;k++){
                    for(ll l=0;l<4;l++){
                        ii=to_string(i);
                        jj=to_string(j);
                        kk=to_string(k);
                        sl=to_string(l);
                        s=jj+kk+sl;
                        s1=ii+kk+sl;
                        s2=ii+jj+sl;
                        ss=ii+jj+kk;
                        if(s!="012" && s!="021" && s!="201" && s1!="021" && s2!="021"){
                            dp[x+1][s]=(dp[x+1][s]+dp[x][ss])%a7;
                        }
                    }
                }
            }
        }
    }
    ll sum=0;
    for(ll i=0;i<4;i++){
        for(ll j=0;j<4;j++){
            for(ll k=0;k<4;k++){
                ii=to_string(i);
                jj=to_string(j);
                kk=to_string(k);
                s=ii+jj+kk;
                sum=(sum+dp[n][s])%a7;
            }
        }
    }
    cout<<sum<<endl;
    return 0;
}


Measured memory_bytes: 896
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cassert>
#include <cstring>
#include <string>
#include <vector>
#include <random>
#include <bitset>
#include <queue>
#include <cmath>
#include <unordered_map>
#include <set>
#include <map>
#define INCANT cin.tie(0), cout.tie(0), ios::sync_with_stdio(0), cout << fixed << setprecision(20);
#define rep(i,n) for (int i=0; i<n;++i)
#define ALL(a)  (a).begin(),(a).end()
#define PI 3.14159265358979
typedef long long ll;
using namespace std;
const ll MOD = 1e9+7LL;
const int INF = 2e9;
int N,H,W;

int main() {
  INCANT;
  cin >> N >> H >> W;
  int cnt=0;
  int a,b;
  rep(i, N) {
    cin >> a >> b;
    if (a>=H && b>=W) cnt++;
  }

  cout << cnt << endl;

  return 0;
}

Measured memory_bytes: 3620
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)
#define VL vector<ll>
#define VS vector<string>
#define VB vector<bool>
#define VP vector<pair<ll,ll>>
#define VVL vector<vector<ll>>
#define VVP vector<vector<pair<ll,ll>>>
#define PL pair<ll,ll>
#define ALL(v) (v).begin(), (v).end()
ll d1[4] = {1, -1, 0, 0};
ll d2[4] = {0, 0, 1, -1};
ll N, M, Q;
VL a, b, c, d;

pair<ll, VL> dfs(ll mx, ll to, vector<ll> rec){
    if(to == N){
        ll ret = 0;
        rep(i, 0, Q){
            if(rec[b[i]-1] - rec[a[i]-1] == c[i]) ret += d[i];
        }
        return {ret, rec};
    }
    ll ret = 0;
    VL res;
    rep(i, mx, M+1){
        VL tmp(rec);
        tmp.push_back(i);
        auto e = dfs(i, to+1, tmp);
        if(e.first > ret){
            ret = e.first;
            res = e.second;
        }
    }
    return {ret, res};
}

int main(){
    cin >> N >> M >> Q;
    a.resize(Q);
    b.resize(Q);
    c.resize(Q);
    d.resize(Q);
    rep(i, 0, Q){
        cin >> a[i] >> b[i];
        cin >> c[i] >> d[i];
    }
    auto ans = dfs(1, 0, {});
    cout << ans.first << endl; 
    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;

int main() {
  int n;
  cin >> n;
  vector<pair<int, int>> a(n);
  for (int i = 0; i < n; i++) {
    cin >> a[i].first;
    a[i].second = i + 1;
  }
  sort(all(a));
  for (int i = 0; i < n; i++) {
    cout << a[i].second << flush;
    if (i == n - 1)
      cout << endl;
    else
      cout << " " << flush;
  }
  return 0;
}

Measured memory_bytes: 1664
#include<stdio.h>

int main(){

  int N,A[100];
  int i,j=0;
  int v;
  
  scanf("%d",&N);

  for(i=0;i<N;i++){
    
    scanf("%d",&A[i]);
  }
  for(i=0;i<N-1;i++){
    
    printf("%d ",A[i]);
  }

  printf("%d\n",A[N-1]);
  
  for(j=0;j<N;j++){
  for(i=1;i<N;i++){
    
    v = A[i];
    j = i - 1;
    
      
      while(j>=0 && A[j]>v){
	
	A[j+1] = A[j];
	j--;
	A[j+1] = v;
      }
      
      for(j=0;j<N-1;j++){
	
	printf("%d ",A[j]);
      }
      printf("%d\n",A[N-1]);
    }
  }
  
  return 0;
}


    



Measured memory_bytes: 2048
t, x, y = 0, 0, 0
for i in range(int(input())):
    next_t, next_x, next_y = map(int, input().split())
    diff = abs(x - next_x) + abs(y - next_y)
    if diff > (next_t - t) or (diff - (next_t - t)) % 2 == 1:
        print("No")
        exit(0)
    t, x, y, = next_t, next_x, next_y
print("Yes")


Measured memory_bytes: 3060
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ConsoleApp11
{
    class Class18
    {
        static void Main()
        {
            var I = Console.ReadLine().Split().Select(long.Parse).ToArray();
            long x = I[0];
            long y = I[1];
            long ans = -1;
            if (x % y != 0)
            {
                for(int i = 1; i < 1000000000; i++)
                {
                    if ( i*x % y != 0)
                    {
                        ans = i * x;
                        break;
                    }
                        
                }
            }
            Console.WriteLine(ans);
        }
    }
}


Measured memory_bytes: 13268
#include<bits/stdc++.h>
using namespace std;
int main()
{
    string s; int c=0;
    cin>>s;
    for(int i=0;i<s.length();i++)
    {
        if(s[i]=='C')  c++;
        if(s[i]=='F'&&c>0)
        {
            cout<<"Yes"<<endl;
            return 0;
        }
    }
    cout<<"No"<<endl;
    return 0;
}

Measured memory_bytes: 256
def main():
    s = [-1 if c == 'L' else 1 for c in raw_input()]
    n = len(s)
    lr = [-1]
    for i in xrange(0, n - 1):
        if s[i:i + 2] == [1, -1]:
            lr.append(i)
        elif s[i:i + 2] == [-1, 1]:
            lr.append(i)
    lr.append(n - 1)
    c = [0] * n
    for i in xrange(0, len(lr) - 1, 2):
        p = lr[i + 1]
        a = lr[i + 1] - lr[i]
        b = lr[i + 2] - lr[i + 1]
        c[p] += (a - a // 2) + b // 2
        c[p + 1] += a // 2 + (b - b // 2)
    print " ".join(map(str, c))


if __name__ == '__main__':
    main()


Measured memory_bytes: 8416
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
from heapq import heappop,heappush

n,m = map(int,readline().split())
a = list(map(int,readline().split()))
xy = list(map(int,read().split()))

if(n-m==1):
    print(0)
    exit()

p = ((n-1)-m)*2
if( p > n):
    print('Impossible')
    exit()

sys.setrecursionlimit(10**9)

class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self,x):
        if(self.parents[x] < 0):
            return x
        self.parents[x] = self.find(self.parents[x])
        return self.parents[x]

    def size(self, x):
        return self.parents[ self.find(x) ] * -1

    def same(self, x, y):
        x_root = self.find(x)
        y_root = self.find(y)
        return (x_root == y_root)

    def union(self,x,y):
        x_root = self.find(x)
        y_root = self.find(y)
        if(x_root == y_root):
            return

        if( self.parents[x_root] <= self.parents[y_root] ):
            self.parents[x_root] += self.parents[y_root]
            self.parents[y_root] = x_root
        else:
            self.parents[y_root] += self.parents[x_root]
            self.parents[x_root] = y_root

    def members(self,x):
        root = self.find(x)
        ret = [ i for i in range(self.n) if self.find(i) == root ]
        return ret

    def roots(self):
        ret = [ i for i in range(self.n) if self.parents[i] < 0]
        return ret

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

uf = UnionFind(n)
hqs = [[] for _ in range(n)]

it = iter(xy)
for x,y in zip(it,it):
    uf.union(x,y)

for i in range(n):
    root = uf.find(i)
    heappush(hqs[root], a[i])

ans = []
others = []
for i in range(n):
    if(hqs[i]):
        ans.append(heappop(hqs[i]))
        others += hqs[i]

others.sort()
rem = p - len(ans)
ans += others[:rem]

print(sum(ans))

Measured memory_bytes: 112044
S = input() + 'R'

numbers = [0] * (len(S) - 1)

offset = 0
length = 0
right = 0
left = 0
for index, (s0, s1) in enumerate(zip(S, S[1:])):
    length += 1
    if s0 == 'R' and s1 == 'L':
        right = length - 1
        left = length
    elif s0 == 'L' and s1 == 'R':
        if length % 2 == 0:
            numbers[offset + right] = length // 2
            numbers[offset + left] = length // 2
        elif right % 2 == 0:
            numbers[offset + right] = length // 2 + 1
            numbers[offset + left] = length // 2
        else:
            numbers[offset + right] = length // 2
            numbers[offset + left] = length // 2 + 1
        length = 0
        offset = index + 1

print(*numbers)


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

int main(){
    vector<int> a = {1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51
};
    int k; cin >> k;
    cout << a[k-1] << endl;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#include <algorithm>
#define rep(i,n) for(ll i=0;i<(n);++i)
#define all(a) (a).begin(),(a).end()
using namespace std;
//using Graph = vector<vector<int>>;
typedef long long ll;
//const int mod= 1e+9+7;

int main(){
    int n; cin>>n;
    ll ans =0;
    vector<int>l(n);
    rep(i,n)cin>>l[i];
    sort(l.begin(),l.end());
    for(int i=0;i<n-1;i++){
        for(int j=i+1;j<n;j++){
            int a=lower_bound(l.begin(),l.end(),l[i]+l[j])-l.begin();
            ans+=a-(j+1);
        }
    }
    cout<<ans<<endl;
    }


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

int main(){
	int n, k;
	cin >> n >> k;
	vector<int> cnt(n);
	rep(i, n){
		int d;
		cin >> d;
		cnt.at(d-1)++;
	}
	
	sort(cnt.begin(), cnt.end());
	
	int ans = 0;
	rep(i, n-k) ans += cnt.at(i);

	cout << ans << endl;
}

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

ll N;
ll A, B;

void input() {
    cin >> A >> B;
}

void solve() {
    
}

int main(void){
    input();
    solve();
    cout << ((B%A==0)?(A+B):(B-A)) << endl;
}


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

#pragma GCC target("avx")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define repi(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
#define uniqueV(x)          \
  sort(x.begin(), x.end()); \
  x.erase(unique(x.begin(), x.end()), x.end());
#define debug(x) cerr << #x << ": " << x << '\n'
#define debug2(x, y) cerr << "(" << #x << ", " << #y << ") = " \
                          << "(" << x << ", " << y << ")" << '\n'

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

const long long INF = 3e18 + 12;
const int inf = 1e9;

// ----------------------------------------------

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

  int n;
  cin >> n;
  string s;
  cin >> s;

  map<char, int> front;
  map<char, int> back;

  int ans = 0;

  rep(i, n - 1) {
    rep(j, n) {
      if (j <= i) {
        front[s[j]]++;
      } else {
        back[s[j]]++;
      }
    }

    int count = 0;
    for (auto i = front.begin(); i != front.end(); i++) {
      if (back.find(i->first) != back.end()) {
        count++;
      }
    }

    ans = max(ans, count);

    front.erase(all(front));
    back.erase(all(back));
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt(); //n個後の文字
		char[] s = stdIn.next().toCharArray(); //文字列S
		if(n==0) {
			System.out.println(s);
			System.exit(0);
		}
		
		
		for(int i = 0; i < n; i++) {
			for(int j = 0; j < s.length; j++) {
				if(s[j] == 'Z') {
					s[j] ='A';
				}else {
				
					s[j]++;
				}
			
			}
		}	
		for(char a: s) {
			System.out.print(a);
		}
	}

}



Measured memory_bytes: 26012
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double PI = 3.1415926535897932;   // acos(-1)
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    int sx, sy, tx, ty;
    cin >> sx >> sy >> tx >> ty;
    string ans = "";
    for(int i = 0; i < tx - sx; ++i)    ans += 'R';
    for(int i = 0; i <= ty - sy; ++i)   ans += 'U';
    for(int i = 0; i <= tx - sx; ++i)   ans += 'L';
    for(int i = 0; i <= ty - sy; ++i)   ans += 'D';
    ans += 'R', ans += 'D';
    for(int i = 0; i <= tx - sx; ++i)   ans += 'R';
    for(int i = 0; i <= ty - sy; ++i)   ans += 'U';
    for(int i = 0; i <= tx - sx; ++i)   ans += 'L';
    for(int i = 0; i < ty - sy; ++i)    ans += 'D';
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <queue>
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
#define set0(x) memset(x,0,sizeof(x))
#define FF first
#define SS second
#define PB push_back
#define MP make_pair
using namespace std;
typedef long long ll;
typedef pair<ll,ll> pll;
template<typename T> void read(T &x){
	x = 0;char ch = getchar();int f = 1;
	while(!isdigit(ch)){if(ch == '-')f*=-1;ch=getchar();}
	while(isdigit(ch)){x = x*10+ch-48;ch=getchar();}x*=f;
}
vector<int> G[100010];
int n,m,bcj[100010],d[100010];
int walk(int x,int fa){
	if(d[x]!=2)return x;
	for(auto ct:G[x]){
		if(ct == fa)continue;
		return walk(ct,x);
	}
}
int main() {
	read(n);read(m);
	for(int i=0;i<=n;i++)bcj[i] = i;
	for(int i=0;i<m;i++){
		int u,v;
		read(u);read(v);
		G[u].push_back(v);
		G[v].push_back(u);
		d[u]+=1;
		d[v]+=1;
	}
	int ok = 1,cnt = 0,ccnt = 0,cfnd = 0;
	for(int i=1;i<=n;i++){
		if(d[i]%2 == 1)ok = 0;
		if(d[i]>2){
			if(d[i] == 4){
				ccnt+=1;
				if(ccnt<=2){
					for(auto ct:G[i]){
						if(walk(ct,i) == i)cfnd = 1;
					}
				}
			}
			cnt+=d[i]/2-1;
		}
	}
	if(cnt == 2 && ccnt == 2 && !cfnd){
		ok = 0;
	}
	if(ok && cnt>=2){
		cout<<"Yes"<<endl;
	}else{
		cout<<"No"<<endl;
	}
	return 0;
}


Measured memory_bytes: 6528
#include <algorithm>
#include <cstdio>
#include <set>
#include <vector>
#define ALL(x) (x).begin(), (x).end()
const int MAXN = 1e5+5;
char S[MAXN];
std::set<int> good;
std::vector<int> step;
int M, N;

void display() {
    for (int x: step) {
        printf("%d ", x);
    }
    putchar('\n');
}

void init() {
    for (int i = 0; i <= N; ++i) {
        if (S[i] == '0') {
            good.insert(i);
        }
    }
}

void solve() {
    M = std::min(N, M);
    int cur = N;
    while (cur > 0) {
        int prev = std::max(cur - M, 0);
        auto ptr = good.lower_bound(prev);
        if (*ptr == cur) {
            step.assign({-1});
            return;
        }
        step.push_back(cur - *ptr);
        cur = *ptr;
    }
    std::reverse(ALL(step));
}

int main() {
    scanf(" %d%d%s", &N, &M, S);
    init();
    solve();
    display();
    return 0;
}

Measured memory_bytes: 5752
#include <iostream>
#include <queue>
#include <set>
#include <algorithm>
#include <string>
#include <list>
#include <math.h>
#include <map>
using namespace std;
#define REP(i, k, n) for(int i = k;i < n; i++)
#define rep(i, n) REP(i,0,n)
#define ll long long int
int dx[4] = {0,-1,1,0};
int dy[4] = {-1,0,0,1};
#define eps 10e-6
#define mod 1000000007
int main(void){
	int X;
	cin >> X;
	int maxi = 1;
	for(int i = 2; i < sqrt(X); i++){
		int sum = i;
		while(1){
			sum *= i;
			if(sum > X)break;
		}
		if(sum==i)continue;
		maxi = max(sum/i, maxi);
	}
	cout << maxi << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pi 3.1415926535897932384626
using namespace std;
      
struct P{
  int x,y;
  bool operator < (const P &a )const{
    //if(x!=a.x)
    return y>a.y;
  };
};

int a,b,c,d,i,k,n,m,e,dx[10]={1,0,-1,0,1,1,-1,-1},dy[10]={0,1,0,-1,1,-1,1,-1};
int o[1];
int l[1];
int j[1];

long long x,y,z,mod=1000000007;
//string r;
char r[1];

P u[1];
//queue<int> q;
//stack<int> s;
set<int> s;
map<int,int> p;

vector<int> v;

bool as(P a,P b)
{
  //if(a.x!=b.x)
  //return a.x<b.x;
  return a.x<b.x;
}

long long f(long long x,int k)
{
  if(x<k) return x;
  return f(x/k,k)+x%k;
}

int main()
{
  scanf("%lld %lld",&x,&y);
  z=mod*mod;
  for(int t=2;t<=500000;t++)
  {
    if(f(x,t)==y)
    {
      z=min(z,(long long)t);
      //printf("%d\n",t);
      //return 0;
    }
  }
  if(x==y)
  {
    z=min(z,y+1);
    //printf("%lld\n",y+1);
    //return 0;
  }
  for(int t=1;t<=500000&&t<=y;t++)
  {
    long long p=y-t,q=(x-p)/t;
    //printf("%lld %lld\n",q,p);
    if(x==q*t+p&&t<q&&p<q)
    {
      z=min(z,q);
      //printf("%lld\n",q);
      //return 0;
    }
  }
  if(z==mod*mod)
  puts("-1");
  else printf("%lld",z);
}
//2
//21



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

int main() {
bool a[1100000]={0};
a[1]=1;
for(int i=2;i<550001;i++){
	if(a[i]==1) continue;
	int j=2*i;
	while(j<1100000){
		a[j]=1;
		j=j+i;
	}
}
int aa,d,n;
while(cin>>aa>>d>>n && aa){
	int k=aa;
	while(n>0){
		if(a[k]==0){
			n--;
		}
		k=k+d;
	//	cout<<k<<" "<<n<<endl;
	}

	cout<<k-d<<endl;
}



	return 0;
}

Measured memory_bytes: 4068
import os
import sys

import numpy as np

if os.getenv("LOCAL"):
    sys.stdin = open("_in.txt", "r")

sys.setrecursionlimit(10 ** 9)
INF = float("inf")
IINF = 10 ** 18
MOD = 10 ** 9 + 7
# MOD = 998244353


N = int(sys.stdin.buffer.readline())
X = list(map(int, sys.stdin.buffer.readline().split()))

X = np.array(X, dtype=int)


def calc(p):
    return ((X - p) ** 2).sum()


ans = INF
for i in range(200):
    ans = min(ans, calc(i))
print(ans)


Measured memory_bytes: 21660
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while (sc.hasNext()) {
			int a = sc.nextInt();
			int b = sc.nextInt();
			
			if (a + b == 0) {
				break;
			}
			
			System.out.println(String.format("%d %d", Math.min(a,  b), Math.max(a, b)));
		}
	}
}



Measured memory_bytes: 39388
let rec combos<'a> (lst: 'a list) k : 'a list list =
    let impl () =
        let head = [lst.Head]
        let subcombos = combos lst.Tail (k - 1)
        let ret = subcombos |> List.map (fun x -> head @ x)
        ret @ (combos lst.Tail k)
    if k = 0 then [[]]
    elif lst.IsEmpty then []
    else impl ()

stdin.ReadLine() |> ignore
let input = stdin.ReadLine().Split() |> Array.map int |> Array.toList
let c = combos input 2
let ans = c |> List.sumBy (fun xs -> xs.Head * xs.Tail.Head)

printfn "%d" ans

Measured memory_bytes: 14296
import sys, re, os
from collections import deque, defaultdict, Counter
from math import ceil, sqrt, hypot, factorial, pi, sin, cos, radians
from itertools import permutations, combinations, product, accumulate
from operator import itemgetter, mul
from copy import deepcopy
from string import ascii_lowercase, ascii_uppercase, digits
from fractions import gcd
 
def input(): return sys.stdin.readline().strip()
def INT(): return int(input())
def MAP(): return map(int, input().split())
def S_MAP(): return map(str, input().split())
def LIST(): return list(map(int, input().split()))
def S_LIST(): return list(map(str, input().split()))
 
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
mod = 10 ** 9 + 7

A = MAP()
c = Counter(A)
if len(c) == 2:
    print("Yes")
else:
    print("No")

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

int main() {
	int N, K;
	cin >> N >> K;
	vector<long long> H(N);
	for(int i = 0; i < N; i++)
		cin >> H.at(i);

	if(K >= N) {
		cout << 0 << endl;
		return 0;
	}

	sort(H.begin(), H.end());

	for(int i = 0; i < K; i++)
		H.pop_back();

	long long sum = 0;
	for(int i = 0; i < H.size(); i++)
		sum += H.at(i);

	cout << sum << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define rep(i, n) for(ll i=0; i<(n); ++i)
#define rep1(i,n) for(ll i=1; i<=(n); ++i)
#define repi(i,a,b) for(ll i=a; i<=(b); ++i)
#define rrep(i,n) for(ll i=(n-1); i>=0; --i)
#define ALL(obj) (obj).begin(), (obj).end()
#define RALL(obj) (obj).rbegin(), (obj).rend()
#define pb push_back
#define mp make_pair
#define to_s to_string
#define sz(v) (int)v.size()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() )
#define print(x) cout<<(x)<<'\n'
#define debug(x) cout << #x << ": " << (x) << '\n'
using namespace std;
using ll = long long;
using Edge = pair<ll,ll>;
using Graph = vector<vector<Edge>>;
typedef pair<ll,ll> P;
struct aaa{aaa(){ cin.tie(0); ios::sync_with_stdio(0); cout<<fixed<<setprecision(20);};}aaaaaaa;
int MOD = 1e9 + 7;
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);}
ll devc(ll x, ll y){return 1 + (x-1)/y;}

ll solve(ll N){
    ll ans = 0;
    return ans;
}

int main(){
    ll H, W, N; cin >> H >> W >> N;
    print(devc(N,max(H,W)));
    return 0;
}

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

#define fr(i,n) _back
#define pb	push_back
#define eb	emplace_back
#define mk	make_pair
#define fi	first
#define se	second
#define endl	'\n'

typedef long long ll;
typedef pair<int,int> ii;
typedef vector<ii> vii;
const int INF = 0x3f3f3f3f;
const double PI = acos(-1.0);
const int T = 1e5 + 4;
int n,t;
ll v[T];
ll acum[T];

int main() {
    ios_base::sync_with_stdio(false);
    cin >> n >> t;
    int maxi = -1;
    int lucro = 0;
    int qtd = 0;
    for(int i = 0; i < n; i++) cin >> v[i];
    for(int i = n-1; i >= 0; i--) {
        if(v[i] > maxi) maxi = v[i];
        if(maxi-v[i] > lucro) lucro = maxi-v[i], qtd = 1;
        else if(maxi-v[i] == lucro) qtd++;
    }
    cout << qtd << endl;
    return 0;
}



Measured memory_bytes: 1024
n = int(input())
v = list(map(int,input().split()))
c = list(map(int,input().split()))
ans = 0
# for i in range(2**n):
#   x = []
#   y = []
#   for j in range(n):
#     if (i>>j) & 1:
#       x.append(v[n - j - 1])
#       y.append(c[n - j - 1])
#   ans = max(ans,sum(x) - sum(y))
for i in range(n):
  if v[i] > c[i]:
    ans += v[i] - c[i]
print(ans)

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

int main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << setprecision(20);

  int x1, x2, y1, y2;
  cin >> x1 >> y1 >> x2 >> y2;

  int a = x2 - x1;
  int b = y2 - y1;
  int x3 = x2 - b;
  int y3 = y2 + a;
  int x4 = x3 - a;
  int y4 = y3 - b;

  cout << x3 << " " <<  y3 << " ";
  cout << x4 << " " <<  y4 << endl;

  return 0;
}


Measured memory_bytes: 256
//
//  main.cpp
//  20190730lesson
//
//  Created by Priscilla Leang on 7/30/19.
//  Copyright 漏 2019 Priscilla Leang. All rights reserved.
//

#include <iostream>
using namespace std;
int main(int argc, const char * argv[]) {
    int x, y, m;
    bool b1 = false;
    /*
    m = 0;
    cin>> x;
    for (int i = 1; i<= x; i+=2){  //only odd numbers
        y = 0;
        for(int j = 1; j <= x; j++){
            if (i % j ==0){
                y++;
            }
        }
        if (y == 8){
            m++;
        }
            
    }
    cout << m;
    */
    //next porblem
    cin >> x >> y;
    int a1[x][2];
    m = 1000;
    
    for (int i = 0; i< x; i++){
        for (int j = 0; j < 2; j++){
            cin>> a1[i][j];
        }
    }
    for (int i = 0; i < x; i++){
        if (a1[i][1] <= y && a1[i][0] <= m){
            b1 = true;
            
            m = a1[i][0];
        }
    }
    
    if(b1 == false){
        cout << "TLE";
    }
    else {
        cout << m;
    }
    
    
    
    
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<utility>
#include<map>
#include<set>
#include <sstream>
#include<queue>
#include<stack>
#include<functional>
#include<math.h>
#include <iomanip>
#include <regex>
#include <initializer_list>
#define DBL_MIN 0.000000000000001

#define A_P(n,a,d) (n/2)*(2*a + (n-1)*d)
using namespace std;

//ちゃんとlong型でやってる？

int main(void){
    int M,N;
    cin >> N >> M;

    
    int cnt =0; 
    
    vector<pair<int, int>> graph;
    vector<long int> list(N,INT32_MAX);
    list[0] = 0;
    for(int i =0; i < M; i++){
        int a,b;
        cin >> a >> b;
        auto tmp =  pair<int,int>(a,b);
        graph.push_back(tmp);
    }

    sort(graph.begin(), graph.end());

    for(int i = 0; i < M; i++){
        int a = graph[i].first;
        int b = graph[i].second;
 
        if(list[b-1] > list[a-1] + 1)       
            list[b-1] = list[a-1] + 1;
    }

    if(list[N-1] <= 2){
        cout << "POSSIBLE" << endl;
    }else{
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 6924
a = int(input())
if a <= 599:
    print(8)
elif a < 800:
    print(7)
elif a < 1000:
    print(6)
elif a < 1200:
    print(5)
elif a < 1400:
    print(4)
elif a < 1600:
    print(3)
elif a < 1800:
    print(2)
else:
    print(1)

Measured memory_bytes: 9168
#include <stdio.h>
#include <string.h>
#define N 2000001
int parent(int i);
int left(int i);
int right(int i);
void maxHeapify(int);
void insert(int);
void extract(void);
int n=0;
int A[N];
int main(){
  int i;
  char s[10];
  while(1){
    scanf("%s", s);
    if(s[0]=='i'){
      n++;
      scanf(" %d", &A[n]);
      insert(A[n]);
    }
    else if(s[1]=='x') extract();
    else break;
  }   
    return 0;
}
int parent(int i){
  return i/2;
}
int left(int i){
  return 2*i;
}

int right(int i){
  return 2*i+1;
}  
void maxHeapify(int i){
  int l, r, largest, x;
  l=left(i);
  r=right(i);
  if(l <= n && A[l] > A[i]) largest = l;

  else largest = i;
 
  if(r <= n && A[r] > A[largest]) largest = r;
 
  if(largest != i){
    x=A[i];
    A[i]=A[largest];
    A[largest]=x;
    maxHeapify(largest);
  }
   
}
void insert(int key){
  int i,x; 
  i = n;
  while(i > 1 && A[parent(i)] < A[i]){
    x = A[i];
    A[i] = A[parent(i)];
    A[parent(i)] = x;
    i/=2;
  }   
}
 
void extract(void){
  int max; 
  max = A[1];
  A[1] = A[n];
  n--;
  maxHeapify(1);
  printf("%d\n", max);
}

Measured memory_bytes: 4692
//order_of_key(k): Number of items strictly smaller than k .
//find_by_order(k): K-th element in a set (counting from zero).
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define full(x,n) x,x+n+1
#define full(x) x.begin(),x.end()
#define finish return 0

#define putb push_back
#define f first
#define s second

//logx(a^n)=loga(a^n)/logx(a)
//logx(a*b)=logx(a)+logx(b)
//logx(y)=log(y)/log(x)

#define ordered_set tree<ll,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update>
#define putf push_front
#define gainb pop_back

#define gainf pop_front
#define len(x) (ll)x.size()

// 1/b%mod=b^(m-2)%mod
// (a>>x)&1==0

typedef double db;
typedef long long ll;

const ll ary=2e5+5;
const ll mod=1e9+7;
const ll inf=1e18;

using namespace std;
using namespace __gnu_pbds;
ll n,a[ary];
int main(){
	ios_base::sync_with_stdio(0);
	cin.tie(0);cout.tie(0);
	cin>>n;
	ll sum=0;
	for(int i=1;i<=n;i++){
		cin>>a[i];
		sum+=a[i];
	}
	ll ans=inf,s=0;
	for(int i=1;i<n;i++){
		s+=a[i];
		ans=min(ans,abs(s-(sum-s)));
	}
	cout<<ans;
}

Measured memory_bytes: 1792