akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
 
//DEFINE and TYPEDEF--------------------------------------------------------------
 
#define timeKyaHorhaH 1.0 * clock() / CLOCKS_PER_SEC

#define FORG(i,a,n) for(lld i=a;i<n;i++) //for - general
#define FORZ(i,n) for(lld i=0;i<n;i++) //for - zero
#define FORGI(i,a,n,inc) for(lld i=a;i<n;i+=inc) //for - general incremental
#define FORZI(i,n,inc) for(lld i=0;i<n;i+=inc) //for - zero incremental
#define SPEEDUP ios_base::sync_with_stdio(0); cin.tie(NULL); cout.tie(NULL);
#define MEM(a,val) memset(a,val,sizeof(a));
 
#define SORTall(m) sort(m.begin(),m.end());
 
#define st first
#define nd second
#define pb push_back
 
typedef long long int lld;
typedef unsigned long long int ulld;
 
//DEBUGGER------------------------------------------------------------------------
// #define DEBUG(x) cerr<<(#x)<<" is "<<(x)<<"\n" //to debug values of variables
// #define DEBUGON
#define ZINDA cerr<<"\nIdhar-ich hai apun!!\n"; //to debug if code reached that point

vector<string> vec_splitter(string s) {
	for(char& c: s) c = c == ',' ?  ' ': c;
	stringstream ss; ss << s;
	vector<string> res;
	for(string z; ss >> z; res.push_back(z));
	return res;
}

void debug_out(vector<string> args, int idx) { cerr << endl; }
template <typename Head, typename... Tail>
	void debug_out(vector<string> args, int idx, Head H, Tail... T) {
		if(idx > 0) cerr << ", ";
		stringstream ss; ss << H;
		cerr << args[idx] << " = " << ss.str();
		debug_out(args, idx + 1, T...);
	}

#ifdef DEBUGON
	#define debug(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);
	#define DEBUG(...) debug_out(vec_splitter(#__VA_ARGS__), 0, __VA_ARGS__);	
#else
	#define debug(...) 320;
	#define DEBUG(...) 320;
#endif

lld power(lld b, lld e)
{
    if(e==0)
        return 1;
    if(e%2==1)
        return b*power(b*b,(e-1)/2);
    else
        return power(b*b,e/2);
}
 
lld power(lld b, lld e, lld m)
{
	if(e==0)
		return 1;
	if(e%2==1)
		return b*power(((b%m)*(b%m))%m,(e-1)/2,m)%m;
	else
		return power(((b%m)*(b%m))%m,e/2,m)%m;
}
 
int nDig(lld n)
{
	if(n<0) 
		n*=-1;
	if(n==0)
		return 1;

    return floor(log10(n) + 1);
}

#define endl '\n'
#define mod 1000000007

//endl : changed to '\n', to flush comment that definition
//--------------------------------------------------------------------------------

void swagWaalaFunction()
{
	lld n,a,b,c,d;
	cin>>a>>b>>c>>d;

	while(a>0 and c>0)
	{
		c-=b;
		if(c<=0)
			break;
		a-=d;
	}

	// cerr<<a<<" "<<c;
	cout<<((c<=0)?"Yes":"No");
	return;
}

int main()
{
    SPEEDUP;
 	lld t=1;
 	//cin>>t;

 	while(t--)
 		swagWaalaFunction();
	
	// cerr<<"\n"<<timeKyaHorhaH; 	
 	return 0;
}

Measured memory_bytes: 3644
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstring>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <cassert>
using namespace std;
using ll = long long;
const int INF = 1<<30;
const int MOD = (int)1e9 + 7;
const int MAX_N = (int)1e5 + 5;
#define debug(x) cout << #x << ": " << x << endl
template<typename T1, typename T2>
ostream &operator<<(ostream &os, const pair<T1, T2>& p) { os << p.first << " " << p.second; return os; }
template<typename T>
ostream &operator<<(ostream &os, const vector<T> &v) { for(int i = 0; i < (int) v.size(); i++) os << v[i] << (i + 1 != v.size() ? " " : ""); return os; }

void solve()
{
    int a; string s; cin >> a >> s;
    if(a >= 3200) cout << s << endl;
    else cout << "red" << endl;
}

signed main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

Measured memory_bytes: 256
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define int long long
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
const double EPS = 1e-6 ; 
signed main(){
    fastio
    string s ;
    cin >> s ;
    int n = (int) s.size() ; 
    int q ;
    cin >> q; 
    bool isReversed = false ;
    string left = "" , right = "" ;
    while(q--){
        int t ;
        cin >> t ;
        if ( t == 1 ){
            isReversed ^= 1 ; 
        }
        else{
            int k ;
            char c ;
            cin >> k >> c ; 
            if ( not isReversed ){
                if ( k == 1 ){
                    left.push_back(c) ;
                }
                else right.push_back(c) ;
            }
            else{
                if ( k == 1 ){
                    right.push_back(c) ;
                }
                else left.push_back(c) ;
            }
        }
    }
    if ( isReversed ){
        for(int i = (int)right.size() - 1; i >= 0; i--){
            cout << right[i] ; 
        }
        for(int i = (int)s.size() - 1; i >= 0; i--){
            cout << s[i] ; 
        }
        cout << left << endl ; 
    }
    else{
        for(int i = (int)left.size() - 1; i >= 0; i--){
            cout << left[i] ; 
        }
        cout << s << right << endl;
    }
    return 0; 
}

Measured memory_bytes: 1040
#include<iostream>
#include <stdio.h>
#include<string>
#include <cmath>
#include <algorithm>
#include <vector>
#include <cstdint>
#include <queue>
#include <set>
#include <map>
#define MOD 1000000007
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n)  FOR(i,0,n)
#define dump(x)  cout << #x << " = " << (x) << endl;
#define debug(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;
typedef long long ll;
using namespace std;

int main(){

  set<int> a;
  
  int n;
  cin >> n;
  
  REP(i,n){
    int num;
    cin >> num;
    a.insert(num);
  }
  
  cout << a.size() << endl;


 return 0;
}

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

int squared(int x) {
    return x * x;
}

int factorial(int x) {
    int res = 1;
    while (x > 0) {
        res *= x--;
    }

    return res;
}

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

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

    double sum = 0;
    for (int i = 0; i < n; i++) {
        for (int j = i + 1; j < n; j++) {
            sum += (double) sqrt(squared(x[i].first - x[j].first) + squared(x[i].second - x[j].second));
        }
    }

    double res = sum * 2 * factorial(n - 1) / factorial(n);
    printf("%.10f", res);

    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <string>
using namespace std;
typedef long long ll;
typedef pair<int, string> P;

int d[2000005][30];

int main()
{
    int n;
    cin >> n;
    for(int i = 0; i <= 2000000; i++){
        for(int j = 0; j < 26; j++) d[i][j] = -1;
    }
    int l = 1;
    P p[200005];
    for(int i = 0; i < n; i++){
        string s;
        cin >> s;
        int k = s.size();
        p[i] = P(k, s);
    }
    ll ans = 0;
    sort(p, p + n);
    for(int u = 0; u < n; u++){
        string s = p[u].second;
        int k = p[u].first;
        int b[26]{0};
        for(int i = 0; i < k; i++) b[s[i] - 'a']++;
        int t = 0;
        for(int i = k - 1; i >= 0; i--){
            b[s[i] - 'a']--;
            for(int j = 0; j < 26; j++){
                if(b[j] > 0 && j != (s[i] - 'a')){
                    int w = d[t][j];
                    if(w != -1){
                        ans += d[w][26];
                    }
                }
            }
            if(d[t][s[i] - 'a'] != -1){
                t = d[t][s[i] - 'a'];
            }
            else{
                d[t][s[i] - 'a'] = l;
                t = l;
                l++;
            }
            ans += d[t][26];
        }
        d[t][26] = 1;
    }
    cout << ans << endl;
}


Measured memory_bytes: 247316
#include <bits/stdc++.h>
#define MOD 998244353
#define pb push_back
#define ll long long int
#define con 1000000007
using namespace std;


int main()
{    ios_base::sync_with_stdio(false);
     cin.tie(NULL);
     cout.tie(NULL);
     ll i,j,k,n,m;
     ll t;
     string s;
     cin>>n>>k;
     ll a[n];
     for(i=0;i<n;i++)
         cin>>a[i];
     unordered_map<ll,bool> m1,m3;
     unordered_map<ll,ll> m2;
     for(i=0;i<k;i++)
     {
         ll l,r;
         cin>>l>>r;
         l--;
         r--;
        // m3[l]=true;
         //m3[r]=true;
         //m2[l]++;
         //m2[r]++;
         if(a[l]<a[r])
             m1[l]=true;
         else if(a[r]<a[l])
             m1[r]=true;
         else
         {
             m1[l]=true;
             m1[r]=true;
         }
     }
     ll ans=0;
     for(i=0;i<n;i++)
     if(m1[i]==false)
             ans++;
     cout<<ans;
}  


Measured memory_bytes: 8136
import java.io.File;
import java.io.IOException;
import java.util.*;
 
public class Main {
	public static void main(String[] args) throws IOException {
		//File file = new File("input.txt");
		//Scanner in = new Scanner(file);
		
		Scanner in = new Scanner(System.in);
		
		long X = in.nextLong();
		long Y = in.nextLong();
		long a = X;
		int ans = 1;
		
		while(2 * a <= Y){
			a = 2 * a;
			ans++;
		}
		
		System.out.println(ans);
	}
}

Measured memory_bytes: 21716
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<iomanip>
#include<math.h>
#include<complex>
#include<queue>
#include<deque>
#include<stack>
#include<map>
#include<set>
#include<bitset>
#include<functional>
#include<assert.h>
#include<numeric>
using namespace std;
#define REP(i,m,n) for(int i=(int)(m) ; i < (int) (n) ; ++i )
#define rep(i,n) REP(i,0,n)
using ll = long long;
const int inf=1e9+7;
const ll longinf=1LL<<60 ;
const ll mod=1e9+7 ;


ll dp[3030][3030];
int main(){
    int n,m;
    cin>>n>>m;
    string s;
    cin>>s;
    vector<int> cnt0(n),cnt1(n);
    rep(i,n)cnt0[i]=s[i]=='0';
    rep(i,n-1)cnt0[i+1]+=cnt0[i];
    rep(i,n)cnt1[i]=s[i]=='1';
    rep(i,n-1)cnt1[i+1]+=cnt1[i];
    dp[0][0]=1;
    int c = 0;
    vector<int> l(n);
    rep(i,n)l[i]=i;
    rep(i,m){
        int x,y;
        cin>>x>>y;
        --x;--y;
        l[x]=max(l[x],y);
    }
    rep(i,n-1)l[i+1]=max(l[i+1],l[i]);
    rep(i,n)rep(j,n+1){
        dp[i][j]%=mod;
        if(j+1<=cnt0[l[i]])dp[i+1][j+1]+=dp[i][j];
        if(i+1-j<=cnt1[l[i]])dp[i+1][j]+=dp[i][j];
    }
    cout<<dp[n][cnt0[n-1]]%mod;
    return 0;
}

Measured memory_bytes: 71936
//**KEEP IT SHORT AND SIMPLE**
#include <bits/stdc++.h>
#define IO ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define FILES freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
#define REP(i,a,b) for (int i = a; i < b; i++)
#define NL '\n'
#define F first
#define S second
#define dot(a, b) (conj(a) * (b)).real()
#define cross(a, b) (conj(a)* (b)).imag()
using namespace std;
typedef long long ll;
typedef long double ld;
typedef bool bl;
typedef vector < vector<long long> > vvl;
typedef vector <long long> vll;
typedef pair <long long, long long> pll;
typedef map <long long, long long> mll;
typedef map <long long, bool> mlb;
typedef priority_queue<long long, vector<long long>, greater<long long> > minPq;
typedef tuple<ll, ll, ll> line;
typedef complex<double> point;
const double pi = 2 * acos(0.0);
const int OO = 0x3f3f3f3f;
vvl Adj;
ll p[15];
ll solve(ll i, vll v)
{
    if(i == v.size())
    {
        for(int j = 0;j < Adj.size();j++)
        {
            ll cnt = 0;
            for(auto it : Adj[j])
                if(v[it - 1])
                    ++cnt;
            if(cnt % 2 != p[j])
                return 0;
        }
        return 1;
    }
    ll ans = solve(i + 1, v);
    v[i] = 1;
    return ans + solve(i + 1, v);
}
int main()
{
    IO
    ll n, m, s, x;
    cin >> n >> m;
    Adj.resize(m);
    REP(i, 0, m)
    {
        cin >> s;
        while(s--)
        {
            cin >> x;
            Adj[i].push_back(x);
        }
    }
    REP(i, 0, m)    cin >> p[i], p[i] %= 2;
    vll v(n, 0);
    cout << solve(0, v);
    return 0;
}


Measured memory_bytes: 256
#include <vector>
#include <iostream>
#include <cmath>
#include <map>
#include <algorithm>
#include <fstream>
#include <unistd.h>
#include <string>
#include <numeric>
#include <queue>
#include <deque>
#include <sstream>
#include <iomanip>
#include <set>
#include <sys/time.h>
#include <sys/resource.h>
#include <thread>
#include <chrono>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<bool> vb;
typedef vector<vector<bool>> vvb;
typedef vector<string> vs;
typedef vector<vector<string>> vvs;
typedef vector<char> vc;
typedef vector<vector<char>> vvc;
typedef pair<int, int> P;
typedef pair<ll, ll> PL;
typedef vector<P> vp;
typedef vector<PL> vpl;
typedef vector<vector<P>> vvp;
typedef vector<vector<PL>> vvpl;
const int INF = 1001001001;
const ll LINF = 1e18;
const double pi = 3.1415926535897932;
const string endstr = "\n";
#define FOR(i, a, b) for(ll i = (a); i < b; i++)
#define rep(i, n) for(ll i = 0; i < n; i++)
#define rrep(i, n) for(ll i = n; i >= 0; i--)
#define FORMAP(it, m) for(auto it = m.begin(); it != m.end(); it++)
#define ff first
#define ss second
#define pb push_back

template <typename T>
T gcd(T a, T b) {
    return (a == 0) ? b : gcd(b%a, a);
}
template <typename T>
T lcm(T a, T b) {
    return a / gcd(a, b) * b;
}

bool p_comp_fs(const PL p1, const PL p2){ return p1.first < p2.first;};
bool p_comp_fg(const PL p1, const PL p2){ return p1.first > p2.first;};
bool p_comp_ss(const PL p1, const PL p2){ return p1.second < p2.second;};
bool p_comp_sg(const PL p1, const PL p2){ return p1.second > p2.second;};
bool pcomp(const PL p1, const PL p2){ return p1.ss*p2.ff < p2.ss*p1.ff;};
template <typename T>
vector<T> uniquen(vector<T> vec){
    vec.erase(unique(vec.begin(), vec.end()), vec.end());
    return vec;
}

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

struct stc {ll l, r, v;};

int main(){
    ll N; cin >> N;
    vl T(N+3); T[0] = -1; T[1] = 0;
    rep(i, N){
        cin >> T[i+2]; T[i+2] *= 2; T[i+2] += T[i+1];
    }
    T[N+2] = T[N+1] + 1;
    vl V(N+2, 0);
    rep(i, N){
        cin >> V[i+1]; V[i+1] *= 2;
    }
    
    vector<stc> vs(N+2);
    rep(i, N+2){
        vs[i] = {T[i], T[i+1], V[i]};
    }
    
    vl ans(T[N+1]+1, 0);
    rep(now, T[N+1]+1){
        ll mn = LINF;
        rep(i, N+2){
            auto st = vs[i];
            if(now <= st.l){
                chmin(mn, st.v + abs(now-st.l));
            }
            else if(st.r <= now){
                chmin(mn, st.v + abs(now-st.r));
            }
            else{
                chmin(mn, st.v);
            }
        }
        ans[now] = mn;
    }
    
    double res = 0.0;
    rep(i, T[N+1]){
//        cout << i << " " << ans[i] << endstr;
        res += (double)(ans[i]+ans[i+1])/2.0 / 4.0;
    }
    
    cout << fixed << setprecision(20) << res << endstr;
    return 0;
}


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

void trace(vector<int> A, int N) {
  for (int i = 0; i < N; i++) {
    if (i > 0) cout << ' ';
    cout << A[i];
  }
  cout << endl;
}

void selectionSort(vector<int> A, int N) {
  int count = 0;
  for (int i = 0; i < N; i++) {
    int minJ = i;
    for (int j = i; j < N; j++) {
      if (A[j] < A[minJ]) {
        minJ = j;
      }
    }
    if (minJ != i) {
      int temp = A[i];
      A[i] = A[minJ];
      A[minJ] = temp;
      count++;
    }
  }
  trace(A, N);
  cout << count << endl;
}
  
int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; i++) {
    cin >> A[i];
  }
  selectionSort(A, N);
}


Measured memory_bytes: 3144
#include <iostream>
#include <algorithm>

using namespace std;

const int MAXN = 1000;
const long long INF = 1e18;

long long v[1 + MAXN][3];
pair<long long, long long> sum[1 + MAXN];

int main () {
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
		cin >> v[i][0] >> v[i][1] >> v[i][2];
    long long best = -INF;
	for (int mask = 0; mask < 8; mask++) {
		long long answer = 0;
		for (int i = 1; i <= n; i++) {
			sum[i].first = sum[i].second = 0;
			for (int j = 0; j < 3; j++) {
			    if (mask & (1 << j))
			        sum[i].first += v[i][j];
			    else
			        sum[i].first -= v[i][j];
			    sum[i].second += v[i][j];
			}
		}
		sort(sum + 1, sum + n + 1);
		for (int i = n; i >= n - m + 1; i--)
		    answer += sum[i].first;
		best = max(best, answer);
	}
	cout << best;
	return 0;
}

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

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

using ll = long long;

const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007LL;

ll dp[110][10];
bool memo[110][10];
vector<ll> a;
ll W;

ll f(ll i, ll j){
  if(memo[i][j]) return dp[i][j];
  memo[i][j]=true;
  dp[i][j]=0LL;
  if(j>=2) dp[i][j]+=(f(i-1,j-1)*(a[j-2]*a[W-j]))%mod;
  dp[i][j]+=(f(i-1,j)*(a[j-1]*a[W-j]))%mod;
  if(j<=W-1) dp[i][j]+=(f(i-1,j+1)*(a[j-1]*a[W-j-1]))%mod;
  dp[i][j]%=mod;
  return dp[i][j];
}

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

int main() {
  ll H,K;
  cin>>H>>W>>K;
  a.assign(W+1,1LL);
  for(ll i = 2LL;i <= W;i++){
    a[i]=a[i-1LL]+a[i-2LL];
  }
  memo[0][1]=true;
  dp[0][1]=1LL;
  for(int i = 2;i <=W;i++){
    memo[0][i]=true;
    dp[0][i]=0LL;
  }
  cout<<f(H,K)<<endl;
}
  

Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
int main(){
    string s1,s2;
    cin >> s1 >>s2;
    swap(s1[0],s1[2]);
    if(s1==s2){
        cout << "YES" << endl;
    }else {
       cout << "NO" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
static void A_Blackjack(int A1, int A2, int A3)
{
    if (A1 + A2 + A3 >= 22)
        std::cout << "bust";
    else
        std::cout << "win";
}
int main(int, char**)
{
    int A1 = 0;
    int A2 = 0;
    int A3 = 0;
    std::cin >> A1 >> A2 >> A3;
	A_Blackjack(A1, A2, A3);
    return 0;
}


Measured memory_bytes: 256
use std::io::{stdin, Read};
use std::str::FromStr;

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

fn main() {
    let d: usize = read().unwrap();
    let n: usize = read().unwrap();

    let my_n: u64 = if n == 100 { 101u64 } else { n as u64 };
    let a = my_n * 100_u64.pow(d as u32);
    println!("{}", a);
}


Measured memory_bytes: 2120
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define llu unsigned long long int
#define sa(a,n,t) for(int ii=0;ii<n;ii++) scanf("%"#t"",&(a)[ii])
#define rep(i,n) for(int i=0;i<n;i++) 
#define reps(i,a,n) for(int i=a;i<n;i++) 
#define rrep(i,n) for(int i=n-1;i>=0;i--)
#define rreps(i,a,n) for(int i=n-1;i>=a;i--)
#define validl(i,a,b) ((i>=a)&&(i<=b))?1:0
#define validmat(x,y,a,b,c,d) (validl(x,a,b) && validl(y,a,b))?1:0
#define validmn(x,y,m,n) validmat(x,y,0,m,0,n)
#define valid(i,n) validl(i,0,n)
#define v(t) vector<t>
#define vv(t) vector<vector<t> >
#define mk make_pair
#define pb push_back
#define pa(a,n,t)  for(int i=0;i<n;i++) printf("%"#t"",a[i])
#define p2 pair<int,int>
#define p3 pair<p2,int>
#define fi first
#define se second
#define sd(a) scanf("%d",&a)
#define sl(a) scanf("%lld",&a)
#define pl(a) printf("%lld",a)
#define pd(a) printf("%d",a)
#define sf(a) scanf("%lf",&a)
#define pf(a) printf("%lf",a)
#define nline printf("\n")
#define ss(a) scanf("%s",a)
#define ps(a) printf("%s",a)
#define sc(a) scanf("%c",&a)
#define pc(a) printf("%c",&a)
#define mf(m,f) m.find(f)!=m.end()
#define pp3(m) cout<<m.fi.fi<<" "<<m.fi.se<<" "<<m.se<<" "
#define pp2(m) cout<<m.fi<<" "<<m.se<<" "
#define debug 0
/*v(int) adj[200001];
void dfs(int i,int p){
    rep(j,adj[i].size()){
        if(p!=adj[i][j])
            dfs(adj[i][j],i);
    }
}*/
int main()
{
  int k;
  int n;
  int c=0;
  cin>>k;
  if(k%2==0) cout<<"-1\n";
  else{
      c=1;
      n=7;
      while(1){
          if(n%k==0 || c>1000001) break;
          n=(n*10+7)%k;
          c++;
      }
      if(c>1000001) cout<<-1<<endl;
      else
      cout<<c<<endl;
  }
  
}


Measured memory_bytes: 3632
#include <cstring>
#include <sstream>
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <iomanip>
#include <map>
#include <unordered_map>
#include <cmath>
#include <queue>
#include <set>
#include <numeric>
#include <stack>

using namespace std;
typedef long long ll;
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define repr(i, n) for(ll i = n - 1; i >= 0; i--)
#define repone(i, n) for(ll i = 1; i <= (ll)(n); i++)
#define each(i, mp) for(auto i:mp)
#define eb emplace_back
#define F first
#define S second
#define all(obj) (obj).begin(), (obj).end()
const int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
const ll mod = 1000000007;
const ll inf = ll(1e9);
const ll half_inf = ll(1e5);
const ll ll_inf = ll(1e9) * ll(1e9);
typedef unordered_map<ll, ll> mpll;
typedef unordered_map<char, ll> mpcl;
typedef unordered_map<string, ll> mpsl;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vl> vvl;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

ll inl() {
    ll x;
    cin >> x;
    return (x);
}

string ins() {
    string x;
    cin >> x;
    return (x);
}

int main() {
#ifdef MY_DEBUG
#pragma clang diagnostic push
#pragma clang diagnostic ignored "-Wmissing-noreturn"
    while (true) {
#pragma clang diagnostic pop
#endif
        ll n = inl();
        vl a(n);
        rep(i, n) cin >> a[i];

        ll dp[n + 1][2];
        rep(i, n + 1)rep(j, 2)dp[i][j] = 0;
        dp[0][1] = -ll_inf;
        rep(i, n) {
            dp[i + 1][0] = max(dp[i][0] + a[i], dp[i][1] - a[i]);
            dp[i + 1][1] = max(dp[i][0] - a[i], dp[i][1] + a[i]);
        }

        cout << dp[n][0] << endl;
#ifdef MY_DEBUG
    }

#endif
    return 0;
}

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

int main() {
    int n, k;
    cin >> n >> k;
    int r, s, p;
    cin >> r >> s >> p;
    string t;
    cin >> t;
    int sum = 0;
    // p -> 0, r -> 1, s -> 2
    for (int i = 0; i < t.size(); i++) {
        if (i - k >= 0 && t[i - k] == t[i]) {
            t[i] = '#';
            continue;
        }
        if (t[i] == 'r') sum += p;
        if (t[i] == 's') sum += r;
        if (t[i] == 'p') sum += s;
    }
    cout << sum << endl;
    return 0;
}


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

int main()
{
	int n;
	int m[6] = { 0, 0, 0, 0, 0, 0 };

	cin >> n;

	for (int i = 0; i < n; i++) {
		double h;

		cin >> h;

		if (h < 165)
			m[0]++;
		else if (h >= 165 && h < 170)
			m[1]++;
		else if (h >= 170 && h < 175)
			m[2]++;
		else if (h >= 175 && h < 180)
			m[3]++;
		else if (h >= 180 && h < 185)
			m[4]++;
		else
			m[5]++;
	}

	for (int j = 0; j < 6; j++) {
		cout << j + 1 << ":";

		for (int k = 0; k < m[j]; k++)
			cout << "*";

		cout << endl;
	}

	return 0;
}


Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < (int)n; i++)
const int MOD = 1000000007;
// long long a;
string nstr(string str, int n){
  string s = "";
  REP(i, n){
    s += str;
  }
  return s;
}
int main(){
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  string str = "";
  int dx = tx - sx;
  int dy = ty - sy;
  cout << nstr("R", dx) +  nstr("U", dy)  +  nstr("L", dx) +  nstr("D", dy) + "D" +  nstr("R", dx + 1) +  nstr("U", dy + 1) +"LU" +  nstr("L", dx + 1) +  nstr("D", dy + 1) + "R"<< endl;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(){
  int i;
  int j;
  int n;
  int a[100];
  int count=0;
  int minj;
  int tmp;

  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }

  for(i=0;i<n-1;i++){
    minj = i;
    for(j=i;j<n;j++){
      if(a[j] < a[minj]) minj = j;
    }
    if(a[i] != a[minj]){
      tmp = a[i];
      a[i] = a[minj];
      a[minj] = tmp;
      count++;
    }
  }

  for(i=0;i<n;i++){
    printf("%d",a[i]);
    if(i != n-1) printf(" ");
  }
  printf("\n%d\n",count);
  return 0;
}



Measured memory_bytes: 2120
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

//#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = (int)(1e9 + 7);
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (a > b) { a = b; return true; } return false; }

signed main() {
	string s; cin >> s;
	int a = s.size(), z = 0;
	rep(i, 0, s.size()) {
		if (s[i] == 'A')chmin(a, i);
		if (s[i] == 'Z')chmax(z, i);
	}
	cout << z - a + 1 << endl;
	return 0;
}

Measured memory_bytes: 640
lines = $stdin.read
array = lines.split("\n")

N = array[0].to_i
L = array[1].split(" ").map(&:to_i).sort.reverse

guzai = 0

for i in 0..N-1
  guzai += L[i*2+1]
  #puts "plus #{i*2+1}"
end

puts guzai

Measured memory_bytes: 1788
#include <math.h>
#include <assert.h>
#include <algorithm>
#include <set>
#include <iostream>
#include <vector>
#include <iomanip>
#include <queue>
#include <map>
#include <string>
#include <cstring>
#include <functional>
#include <stack>
#include <array>
#include <random>
#include <chrono>
#include <climits>
#include <bitset>
using namespace std ;
#define rep(i, a, b) for (int i=a; i<(b); i++)
#define forn(i, a) for (int i=0; i<(a); i++)
#define repd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define ford(i,a) for (int i = (a)-1; i >= 0; i--)
#define trav(a,x) for (auto& a : x)
#define int long long
#define ii pair<int,int>
#define ar array
#define FAST_IO ios_base::sync_with_stdio(false) ;cin.tie(NULL);cout.tie(NULL)
#define ms(x,a) memset(x,(int)(a),sizeof(x))
#define sz(x) ((int)(x).size())
#define lb lower_bound
#define ub upper_bound
#define all(x) x.begin(), x.end()
#define ins insert
#define pb push_back
#define endl '\n'
#define ff first
#define ss second
//const int N = 3e5+7 ;
//const int INF = 1e18 ;
//const int MOD = 1e9 + 7 ;

void solve(){
    string s ;
    cin >> s ;
    if(s == "RRR"){
        cout << 3 ;
        return ;
    }
    for(int i = 0 ; i < 2 ; i++){
        if(s[i]=='R'&&s[i+1]=='R'){
            cout << 2 ;
            return ;
        }
    }
    if(s == "SSS"){
        cout << 0 ;
    }
    else{
        cout << 1 ;
    }

}


int32_t main(){
    FAST_IO ;
    int t = 1 ;
//    cin >> t ;
    while(t--){
        solve() ;
    }
}


Measured memory_bytes: 3648
n = int(input())
a = list(map(int, input().split()))
b = list(map(int, input().split()))
c = list(map(int, input().split()))

man = 0
pre = -10

for i in a:
    ai = i-1
    man += b[ai]
    #print(b[ai])
    if pre == ai - 1:
        man += c[pre]
        #print(c[pre])
    pre = ai

print(man)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
#define Maxn 107
#define inf 1000007
char s[Maxn][Maxn];
int last[1000007],pre[1000007],other[1000007],len[1000007],cnt=0;
int n,m;
int calc(int x,int y)
{
    return (x-1)*m+y;
}
void insert(int u,int v,int l)
{
    other[++cnt]=v,pre[cnt]=last[u],last[u]=cnt;
    len[cnt]=l;
}
int dis[1000007];
bool vis[1000007];
priority_queue<pair<int,int> >que;
int dijkstra(int s,int t)
{
    for (int i=1;i<=t;i++)
        dis[i]=inf;
    memset(vis,false,sizeof(vis));
    while (!que.empty()) que.pop();
    que.push(make_pair(0,s));
    dis[s]=0;
    while (!que.empty())
    {
        int u=que.top().second;
        que.pop();
        if (vis[u]) continue;
        vis[u]=true;
        for (int q=last[u];q;q=pre[q])
        {
            int v=other[q];
            if (dis[v]>dis[u]+len[q])
            {
                dis[v]=dis[u]+len[q];
                que.push(make_pair(-dis[v],v));
            }
        }
    }
    return dis[t];
}
int main()
{
    scanf("%d%d",&n,&m);
    for (int i=1;i<=n;i++)
        scanf("%s",s[i]+1);
    for (int i=1;i<=n;i++)
        for (int j=1;j<=m;j++)
        {
            if (i<n)
            {
                int tmp=0;
                if (s[i][j]=='.'&&s[i][j]!=s[i+1][j]) tmp=1;
                insert(calc(i,j),calc(i+1,j),tmp);
            }
            if (j<m)
            {
                int tmp=0;
                if (s[i][j]=='.'&&s[i][j]!=s[i][j+1]) tmp=1;
                insert(calc(i,j),calc(i,j+1),tmp);
            }
        }
    int S=n*m+1,T=n*m+2;
    if (s[1][1]=='.') insert(S,calc(1,1),0); else insert(S,calc(1,1),1);
    insert(calc(n,m),T,0);
    printf("%d\n",dijkstra(S,T));
    return 0;
}

Measured memory_bytes: 5032
#include <bits/stdc++.h>
using namespace std;
const int maxn = 2e3 + 10;
int n, a[maxn], ans;
int main()
{
    cin >> n;
    for(int i = 1; i <= n; ++i) cin >> a[i];
    sort(a + 1, a + n + 1);
    for(int i = 1; i <= n - 2; i++)
        for(int j = i + 1; j <= n - 1; j++)
            for(int k = j + 1; k <= n; ++k){
                if(a[i] + a[j] > a[k]) ++ans;
                else break;
            }
    cout << ans << '\n';
    return 0;
}

Measured memory_bytes: 3636
import java.util.ArrayList;
import java.util.Collections;
import java.util.List;
import java.util.Scanner;

public class Main {

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

        int N = sc.nextInt();
        int K = sc.nextInt();
        List<Integer> a = new ArrayList<>();

        int ans = N;
        for(int i = 0; i < N; i++){
            int v = sc.nextInt();
            a.add(v);
        }

        a.sort(null);

        boolean[][] preSum = new boolean[N + 1][K + 9];
        boolean[][] postSum = new boolean[N + 1][K + 9];

        preSum[0][0] = postSum[0][0] = true;

        int len = a.size();

        for(int i = 1; i <= len; i++){
            preSum[i][0] = true;
            int v = a.get(i - 1);
            for(int j = K; j >= 0; j--){
                preSum[i][j] = preSum[i - 1][j];
                if(j - v >= 0){
                    preSum[i][j] |= preSum[i - 1][j - v];
                }
            }
        }

        Collections.reverse(a);

        for(int i = 1; i <= len; i++){
            postSum[i][0] = true;
            int v = a.get(i - 1);
            for(int j = K; j >= 0; j--){
                postSum[i][j] = postSum[i - 1][j];
                if(j - v >= 0){
                    postSum[i][j] |= postSum[i - 1][j - v];
                }
            }
        }

        Collections.reverse(a);

        for(int i = 1; i <= len; i++){

            int v = a.get(i - 1);
            if(v >= K){
                ans -= 1;
                continue;
            }

            boolean[] isExists = new boolean[K + 1];
            for(int j = K - 1; j >= 0; j--){
                isExists[j] = postSum[N - i][j] || isExists[j + 1];
            }

            for(int j = 0; j <= K - 1; j++){
                if(preSum[i - 1][j] && ((K - v - j) < 0 || isExists[K - v - j])){
                    ans -= 1;
                    break;
                }
            }

        }

        System.out.println(ans);
    }
}


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

int n, dp[N][N], lim;
string s;

int solve(int idx1, int idx2){
   if(idx1 > lim or idx2 >= n){
      return 0;
   }

   int &ans = dp[idx1][idx2];
   if(~ans)
      return ans;

   ans = 0;
   if(s[idx1] != s[idx2]){
      return ans = 0;
   }

   return ans = 1 + solve(idx1+1, idx2+1);
}

void solve0(){
   cin >> n;
   cin >> s;

   memset(dp, -1, sizeof dp);

   int ans = 0;
   for (int i = 0; i < n; ++i)
   {
      for (int j = i+1; j < n; ++j)
      {
         lim = j - 1;
         smax(ans, solve(i, j));
      }
   }

   cout<<ans;
}

int32_t main(){_

   int q = 1;
   // cin >> q;

   while(q--){
      solve0();
   }

   return 0;
}

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

using namespace std;

int main(){
	
	int n,a,b; 

	cin >> n;
	
	if(n==1){
		cout << "Hello World" << endl;
	}else{
		cin >> a >> b; 
		
		cout << a+b << endl;
	}
	
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <queue>

int n;
int main() {
  scanf("%d", &n);

  bool reversed = false;
  std::deque<int> que;
  for (int i = 0; i < n; i++) {
    int a;
    scanf("%d", &a);
    if (!reversed) {
      que.push_back(a);
    } else {
      que.push_front(a);
    }
    reversed = !reversed;
  }

  if (!reversed) {
    auto i = que.begin();
    for (; (i + 1) != que.end(); i++) {
      printf("%d ", *i);
    }
    printf("%d\n", *i);
  } else {
    auto i = que.rbegin();
    for (; (i + 1) != que.rend(); i++) {
      printf("%d ", *i);
    }
    printf("%d\n", *i);
  }
  return 0;
}


Measured memory_bytes: 3072
import java.io.PrintStream;
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception{
		new Main(new Scanner(System.in), System.out, System.err).exec();
	}
	public final Scanner sc;
	public final PrintStream out, err;
	public Main(final Scanner sc, final PrintStream out, final PrintStream err) {
		this.sc = sc;this.out = out;this.err = err;
	}
	static public final long pair(int a, int b) {return (((long)a) << 32) + b;}
	static public final int getPair1(long v) {return (int)(v >> 32);}
	static public final int getPari2(long v) {return (int)(v & 0xFFFFFFFF);}

	static public final long quad(long a, long b, long c, long d) {
		return ((a&0xFFFF)<< 48) + ((b&0xFFFF)<< 32) + ((c&0xFFFF)<< 16) +(d&0xFFFF);}
	static public final int getQuad1(long v) {return (int)( v >> 48          );}
	static public final int getQuad2(long v) {return (int)((v >> 32) & 0xFFFF);}
	static public final int getQuad3(long v) {return (int)((v >> 16) & 0xFFFF);}
	static public final int getQuad4(long v) {return (int)( v        & 0xFFFF);}

	static public final long record(int e, int m, int i) {
		return quad(-1, e, m, i);
	}
	static public final int re(long record) {
		return getQuad2(record);
	}
	static public final int rm(long record) {
		return getQuad3(record);
	}
	static public final int ri(long record) {
		return getQuad4(record);
	}

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

	private int p;
	private int[] inv;
	private int[] fact;
	private int[] finv;
	public final int mod(long v) {
		v %= p;
		return (int)(v < 0 ? v+p : v);
	}
	public final int mul(long a, long b) {
		return mod(a*b);
	}
	public final void initFact(double limit, double p) {
		initFact((int)limit, (int)p);
	}
	public final void initFact(int limit, int p) {
		this.p = p;
		this.inv = new int[limit+1];
		this.fact = new int[limit+1];
		this.finv = new int[limit+1];
		fact[1] = finv[1] = inv[0] = inv[1] = 1;
		for(int i=2;i<=limit;i++) {
			int a = p / i;
			int b = p % i;
			inv[i]  = mul(-a, inv[b]);
			fact[i] = mul(fact[i-1], i);
			finv[i] = mul(finv[i-1], inv[i]);
		}
	}
	public final int comb(int m, int n) {
		return mul(mul(fact[m], finv[n]), finv[m-n]);
	}
	//------------------------------------------
	static long lcm (long a, long b) {
		long temp;
		long c = a;
		c *= b;
		while((temp = a%b)!=0) {
			a = b;
			b = temp;
		}
		return (long)(c/b);
	}
	//------------------------------------------


	public void exec() throws Exception{
		final int N = sc.nextInt();
		final int[] a = new int[N+1];
		for(int i=1;i<=N;i++) {
			a[i] = sc.nextInt();
		}
		int broken = 0;
		int index = 1;
		for(int i=1;i<=N;i++) {
			if(a[i]==index) {
				index++;
				continue;
			}else {
				broken++;
			}
		}
		if(broken == N) {
			out.println(-1);
		}else {
			out.println(broken);
		}
	}
}


Measured memory_bytes: 76288
#include <iostream>
#include <algorithm>
#include <tuple>
#include <vector>
#include <string>
#include <queue>
#include <cmath>
#include <iomanip>

using namespace std;
char s[50][50];
int value[50][50];
bool mark[50][50];

int main()
{
    int h, w;
    cin >> h >> w;
    int num = 0;
    for (int i = 0; i < h; i++)
    {
        for (int j = 0; j < w; j++)
        {
            cin >> s[i][j];
            value[i][j] = 1001001001;
            mark[i][j] = false;
            if (s[i][j] == '#')
                num++;
        }
    }

    queue<pair<int, int>> que;
    int x = 0, y = 0;
    value[0][0] = 0;
    que.push({x, y});

    int sx[4] = {1, 0, -1, 0};
    int sy[4] = {0, 1, 0, -1};

    while (!que.empty())
    {
        pair<int, int> now = que.front();
        que.pop();
        x = now.first;
        y = now.second;
        for (int i = 0; i < 4; i++)
        {
            if (x + sx[i] < h && 0 <= x + sx[i] && y + sy[i] < w && 0 <= y + sy[i])
            {
                if (mark[x+sx[i]][y+sy[i]]==false && s[x + sx[i]][y + sy[i]] == '.')
                {
                    mark[x+sx[i]][y+sy[i]]=true;
                    //cout << value[x+sx[i]][y+sy[i]] << endl;
                    value[x+sx[i]][y+sy[i]] = min(value[x+sx[i]][y+sy[i]], value[x][y]+1);
                    //cout << value[x+sx[i]][y+sy[i]] << endl;
                    que.push({x+sx[i], y+sy[i]});
                }
            }
        }
    }

    if(value[h-1][w-1] == 1001001001){
        cout << -1 << endl;
        return 0;
    }

        int ans = h * w - (value[h - 1][w - 1] + 1) - num;

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

Measured memory_bytes: 384
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <list>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <array>
#include <algorithm>
#include <tuple>
#include <numeric>

int main()
{
	int A, B, C;
	std::cin >> A >> B >> C;

	if (A == B && B == C)
		std::cout << "Yes\n";
	else
		std::cout << "No\n";
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    int a,b;
    int tmp;
    cin>>a>>b;
    if(a>=b)
    {
        tmp=a;
        a=b;
        b=tmp;
    }
    for(int i=0;i<b;i++)
    {
        cout<<a;
    }
}


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

int main(){
  int ax,ay,bx,by;
  cin >> ax >> ay >> bx >> by;
  int cx,cy,dx,dy;
  cx=bx+ay-by;
  cy=by+bx-ax;
  dx=ax+ay-by;
  dy=ay+bx-ax;
  cout << cx << " " << cy << " " << dx << " " << dy << endl;
  return 0;
}

Measured memory_bytes: 3636
#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 ALL(v) v.begin(), v.end()
using namespace std;
typedef long long ll;
typedef long double ld;
int main()
{
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  int a,b,c,d;
  cin >> a >> b >> c >> d;

  cout << max(a*b,c*d) << endl;
  return 0;
}

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

vector<vector<int>>adj;

int bfs(int z,int rot,int to){
	vector<int>dist(z,1e7);
	dist[rot]=0;
	queue<int>q({rot});
	while(!q.empty()){
		int u = q.front();
		q.pop();
		for(int v:adj[u]){
			if(dist[v]>dist[u]+1){
				dist[v]=dist[u]+1;
				q.push(v);
			}
		}
	}

	return dist[to];
}
vector<int>C;
vector<int>color;
vector<bool>vis;
int dx[4]={1,0,-1,0};
int dy[4]={0,-1,0,1};

void dfs(int u, int z){
	vis[u]=true;
	color[u]=z;
	int x = u/w;
	int y = u%w;
	for(int i=0;i<4;i++){
		int nx=x+dx[i];
		int ny=y+dy[i];
		if(nx>=0 && nx<h && ny>=0 && ny<w){
			int v = nx*w+ny;
			if(C[v]==1 && !vis[v])dfs(v,z);
		}
	}
}


int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin>>h>>w;
	C=vector<int>(h*w);
	color=vector<int>(h*w,-1);
	vis=vector<bool>(h*w);
	int ch,cw,dh,dw;
	cin>>ch>>cw>>dh>>dw;
	ch--;cw--;dh--;dw--;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			char c;
			cin>>c;
			if(c=='.')C[i*w+j]=1;
			else C[i*w+j]=0;
		}
	}
	int z=0;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(C[i*w+j]==0)continue;

			if(color[i*w+j]==-1){
				dfs(i*w+j,z++);
			}
			
		}
	}
	adj.resize(z);
	map<pair<int,int>,bool>dic;
	for(int i=0;i<h;i++){
		for(int j=0;j<w;j++){
			if(C[i*w+j]==0)continue;

			int c1=color[i*w+j];

			for(int a=i-2;a<=i+2;a++){
				for(int b=j-2;b<=j+2;b++){
					if(a<0 ||b<0 ||a>=h || b>=w)continue;
					if(C[a*w+b]==0)continue;

					int c2=color[a*w+b];
					if(c2!=c1 && !dic.count({c1,c2})){
						adj[c1].push_back(c2);
						adj[c2].push_back(c1);
						dic[{c1,c2}]=dic[{c2,c1}]=true;
					}
				}
			}
		}
	}

	int rot=color[ch*w+cw];
	int to =color[dh*w+dw];

	int ans = bfs(z,rot,to);
	if(ans>=1e7)ans=-1;
	
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 43260
#include <bits/stdc++.h>
#include <vector> 
# include <cstdint>
#define FOR(i,l,r) for(int i=(l);i<(r);++i)
#define RFOR(i,l,r) for(int i=(l);i>=(int)(r);i--)
#define rep(i,n)  FOR(i,0,n)
#define rrep(i,n)  RFOR(i,n-1,0)

#define int long long
using namespace std;
const int MX = 1e6;
const int inf = 1e13;
const int mod = 1e9+7;
#define ll long long
map<char, int> m;
signed main() {
    int h,w;
    cin >> h >> w;
    rep(i,h) {
        string str;
        cin >> str;
        rep(j,w) {
            m[str[j]]++;
        } 
    }
    if(h%2==0 && w%2==0) {
        for(auto mm: m) {
            if(mm.second%4!=0) {
                cout << "No" << endl;
                return 0;
            }
        }
        cout << "Yes" << endl;
    }else if(h%2&&w%2) {
        map<int, int> ma;
        for(auto mm: m) {
            ma[mm.second%4]++;
        }
        if(ma[1]!=1) {
            cout << "No" << endl;
            return 0;
        }
        if(ma[3]) {
            cout << "No" << endl;
            return 0;
        }
        if(ma[2]<=(h/2+w/2)) {
            cout << "Yes" << endl;
        }
        
    }else {
        if(w%2) swap(h,w); 
        map<int, int> ma;
        for(auto mm: m) {
            ma[mm.second%4]++;
        }
        //cout << ma[2]<<" "<<h/2 << endl;
        if(ma[1]||ma[3]) {
            cout << "No" << endl;
            return 0;
        }
        if(ma[2]<=w/2) {
            //cout << ma[2] << endl;
            cout << "Yes" << endl;
            return 0;
        }
        cout << "No" << endl;
    }

  return 0;
}



Measured memory_bytes: 3608
#include <stdio.h>
int main(void){
    int a,b,c,x;
    int N = 0;
    scanf("%d %d %d",&a,&b,&c);
    for(x = a; x <= b; x++)
    {
        if (c % x == 0)
        N = N + 1;
    }
    
    printf("%d\n",N);
    return 0;
}



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

using namespace std;

bool check(int x){
	return x%7==1 || x%7==6;
}

bool isprime(vector<int> cand, int x){
	if(x<=1) return false;
	for(unsigned int i=0;i<cand.size()&&cand[i]<x;i++){
		if(cand[i] <= 0) continue;
		if(x%cand[i]==0){
			return false;
		}
	}
	return true;
}

int main(){
	int n;
	while(cin >> n, n!=1){
		vector<int> cand;
		for(int i=1;i<=sqrt(n);i++){
			if(n%i == 0 && check(i) && check(n/i)){
				if(i != 1) cand.emplace_back(i);
				if(i != n/i) cand.emplace_back(n/i);
			}
		}
		//cout << cand.size() << endl;
		sort(cand.begin(),cand.end());
		for(int i=cand.size()-1;i>=0;i--){
			/*for(auto x:cand){
				cout << x << " ";
			}
			cout << endl;*/
			if(!isprime(cand,cand[i])){
				cand[i] = -1;
			}
		}

		cout << n << ":";
		for(int i=0;i<cand.size();i++){
			if(cand[i] >= 0) cout << " " << cand[i];
		}
		cout << endl;
	}

	
	return 0;
}

Measured memory_bytes: 3116
n,k=map(int,input().split())
l=[]
for i in range(n):
    l.append(list(map(int,input().split())))
l.sort()
l.append([-1,-1])
a=[]
b=[]
for i in range(n):
    if l[i][0]==l[i+1][0]:
        b.append(l[i][1])
    else:
        a.append(l[i][1])
ans=len(a)*len(a)+sum(a)
#print(ans)
if len(b)>0:
    ans+=sum(b)
    b.sort()
    a.sort()
    i=0
    ai=0
    bi=0
    an=len(a)
    bn=len(b)
    while i<n-k:
        if ai<an and bi<bn:
            ap=a[ai]
            bp=b[bi]
            if ap+2*(an-ai-1)+1>=bp:
                bi+=1
                ans-=bp
            else:
                ans-=ap+2*(an-ai-1)+1
                ai+=1
        elif ai<an:
            ap=a[ai]
            ans-=ap+2*(an-ai-1)+1
            ai+=1
        elif bi<bn:
            ans-=b[bi]
            bi+=1
        i+=1
    print(ans)
else:
    a.sort(reverse=True)
    print(sum(a[:k])+k*k)


Measured memory_bytes: 66392
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

using namespace std;

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

int main(){
    int N,K;
    cin>>N>>K;
    if(K==1)cout<<0;
    else cout<<N-K;
    return 0;
}

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

using namespace std;

#define sqr(x) ((x) * (x))
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define fin(name) auto varfin=freopen(name, "r", stdin);varfin=varfin
#define fout(name) auto varfout=freopen(name, "w", stdout);varfout=varfout
#define I(x, a) for(auto x : a)
#define F(i, l, r) for(auto i = l; i < r; ++i)
#define E(i, l, r) for(auto i = l; i <= r; ++i)
#define DF(i, l, r) for(auto i = l; i >= r; --i)
#define clean(a) memset((a),0,sizeof (a))
#define sync ios_base::sync_with_stdio(0);cin.tie(0)
#define all(x) (x).begin(),(x).end()
#define ret return
#define cont continue
#define brk break
#define ins insert
#define sz(a) ((int)(a).size())

typedef long long ll;
typedef unsigned long long ull;
typedef long double dbl;
typedef pair <int, int> pii;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)1e9 + 7;
const dbl eps = (dbl)1e-8;
const int maxn = (int)1e5 + 5;
const dbl pi = acos(-1);

int L, n, m;
vector <pair<pii, int>> es;

int main() {
//    fin("t.in");
    sync;
    cin >> L;
    L--;
    n = 20;
    ll x = 0;
    E(i, 0, 18) {
    	es.pb({{n - i - 1, n - i}, 0});
    	if (L >= (1 << (i + 1)) - 1) {
    		es.pb({{n - i - 1, n - i}, (1 << i)});
    		x = (1 << (i + 1));
    	}
    }
    L -= x;
    DF(i, 17, 0) {
    	while (L >= (1 << i)) {
    		es.pb({{1, n - i}, x});
    		L -= (1 << i);
    		x += (1 << i);
    	}
    }
    if (L != -1)
	    es.pb({{1, n}, x + L});
    assert(sz(es) <= 60);
    cout << n << " " << sz(es) << "\n";
    I(e, es) {
    	cout << e.X.X << " " << e.X.Y << " " << e.Y << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <math.h>
#include <functional>
#include <iomanip>
#include <bitset>
#include <numeric>
#include <queue>
#include <map>
using namespace std;
#define rep(i, n) for (int i = 0; i < n; i++)
const long long mod = 1000000007;
typedef long long ll;
typedef pair<int, double> P;
const vector<int> di = {-1, 0, 1, 0};
const vector<int> dj = { 0, 1, 0, -1 };



int main() {

	string w;
	cin >> w;

	rep(i, w.size()) {
		int cnt = 0;
		rep(j, w.size()) {
			if (w.at(i) == w.at(j)) cnt++;
		}
		if (i == (w.size() - 1) && w.size() > 1) {
			cout << "Yes" << endl;
			break;
		}
		if (cnt%2 == 0) {
			continue;
		}
		else if (cnt % 2 != 0) {
			cout << "No" << endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256