akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
const long long INF = 1LL <<60;  
     
long long gcn(long long x,long long y){
  if(x%y==0){
    return y;  
  }
  else{
    return gcn(y,x%y);
  }
}
int main(void){
  long long tmp;
  long long i,j,k;
  long long a,b,c,d;
  long res=0;

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

Measured memory_bytes: 3672
#include<cstdio>
#include<algorithm>
using namespace std;
int a,cnt[105],n,l;
int main(){
	scanf("%d",&n);
	for(int i=1;i<=n;i++){
		scanf("%d",&a);
		l=max(l,a);
		cnt[a]++;
	}
	if(l&1){
		for(int i=0;i<=l/2;i++)
			if(cnt[i])return printf("Impossible"),0;
		if(cnt[l/2+1]!=2)return printf("Impossible"),0;
		for(int i=l/2+2;i<=l;i++)
			if(cnt[i]<2)return printf("Impossible"),0;
	}
	else{
		for(int i=0;i<l/2;i++)
			if(cnt[i])return printf("Impossible"),0;
		if(cnt[l/2]!=1)return printf("Impossible"),0;
		for(int i=l/2+1;i<=l;i++)
			if(cnt[i]<2)return printf("Impossible"),0;
	}
	printf("Possible");
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <cstdio>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;

int cnt[101];
bool prime[101];
long long dp[101][76];
int n;

bool isprime(int k) {

    for (int j=2; j<k; j+=2) if (k%j==0) return false;
    return true;

}

long long solve(int i, int k) {

    if (i == n) return k == 1;
    if (k == 0) return 0;
    if (dp[i][k] != -1) return dp[i][k];

    long long tmp = 0;

    for (int t=0; t<=cnt[i]; t++) {
        if (k%(t+1)==0) {
            tmp += solve(i+1, k/(t+1));
        }
    }

    dp[i][k] = tmp;

    return tmp;

}

int main() {

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

    cin>>n;

    for (int i=2; i<=n; i++) prime[i] = isprime(i);

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

        int m = i;
        for (int j=2; j<=m; j++) {

            if (m%j == 0 && prime[j]) {

                while (m%j==0) {
                    cnt[j]++;
                    m /= j;
                }

            }

        }

    }

    for (int i=0; i<=n; i++) for (int j=0; j<=75; j++) dp[i][j] = -1;

    cout<<solve(2, 75)<<endl;

    return 0;
}


Measured memory_bytes: 256
import java.io.InputStream;
import java.io.PrintStream;
import java.util.*;

public class Main {

  public static void main(String[] args) {
    solve(System.in, System.out);
  }

  static void solve(InputStream is, PrintStream os) {
    Scanner sc = new Scanner(is);

    /* read */
    int n = sc.nextInt();
    int a = sc.nextInt();
    int b = sc.nextInt();
    os.println(Math.min(a * n, b));
  }
}

Measured memory_bytes: 24148
#include<bits/stdc++.h>
using namespace std;
int main(){
	int a,b,c;
	cin >> a >> b >> c;
	if(a==5&b==5&c==7 || a==7&b==5&c==5 || a==5&b==7&c==5){cout <<"YES";}
	else{cout << "NO";}
	


 return 0;
 
 }


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using ld=long double;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pii=pair<int,int>;
using pll=pair<ll,ll>;
const ll LINF=0x1fffffffffffffff;
const int INF=0x3fffffff;
const int MOD=1000000007;
#define VAR(type,...) type __VA_ARGS__;in(__VA_ARGS__)
#define VEC(type,name,size) vector<type> name(size);each(i, name)in(i)
#define rep(i,a,b) for(int i=(a);i<(b);++i)
#define rrep(i,a,b) for(int i=(a-1);i>=(b);--i)
#define each(i,v) for(auto &i:(v))
#define all(v) (v).begin(),(v).end()
#define print(...) out(__VA_ARGS__);cout<<endl
void in(){} template<class T,class... U> void in(T &t,U &...u){cin>>t;in(u...);}
void out(){} template<class T,class... U> void out(T t,U ...u){cout<<t<<" ";out(u...);}
void solve();
int main(){cin.tie(0);ios::sync_with_stdio(0);solve();}

void solve() {
  VAR(int, N);

  ll ans = 0;
  rep(i, 0, N+1) {
    if (i % 3 != 0 && i % 5 != 0) {
      ans+= i;
    }
  }
  print(ans);
}


Measured memory_bytes: 3656
#include <iostream>
#include <iomanip>
#include <algorithm>
#include <vector>
#include <string>
#include <map>
#include <math.h>
#include <deque>
using namespace std;

int main(){
    int n, a;
    cin >> n;
    deque <int> B;
    for (int i = 0; i < n; i++) {
        cin >> a;
        if(i%2 == 0)B.push_back(a);
        else B.push_front(a);
    }
    if(n%2==1) reverse(B.begin(), B.end());
    for(auto x: B) cout << x << " ";
    cout << endl;
    return 0;
}


Measured memory_bytes: 2944
#include <iostream>
#include <string>
#include <vector>
#include <deque>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <set>
#include <sstream>
#include <numeric>
#include <bitset>
#include <complex>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <climits>
#include <cctype>
#include <cassert>
using namespace std;

typedef long long ll;
static const double EPS = 1e-8;
static const double PI = 4.0 * atan(1.0);
bool ISINT(double x){return fabs(x-(int)round(x))<EPS;}
bool ISEQ(double x,double y){return fabs(x-y)<EPS;}
string itos(ll x){stringstream ss;ss<<x;return ss.str();}
#define foreach(itr,c) for(__typeof(c.begin()) itr=c.begin();itr!=c.end();itr++)

int rht[200002];
int lft[200002];

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

  string s;
  
  while (cin >> s) {
    int n = s.size();
    int ans = n;
    
    for (int i = 0; i < n; i++) {
      rht[i] = i + 1;
      lft[i] = i - 1;
    }

    int i = 0;
    
    while (0 <= i && i < n - 1) {
      int j = rht[i];
      
      while (true) {
        if (s[i] == 'S' && s[j] == 'T') {
          ans -= 2;
          i = lft[i];
          j = rht[j];
        } else {
          rht[i] = j;
          lft[j] = i;
          i = j;
          break;
        }
      }
    }

    cout << ans << endl;
  }
}


Measured memory_bytes: 2196
N,T = map(int,input().split())
l = [[int(i) for i in input().split()] for _ in range(N)]
l.sort(key=lambda x:x[0])
OK,ans = False,0
for i in range(N):
    if l[i][1]<=T:
        ans = i
        OK = True
        break
print(l[ans][0] if OK else 'TLE')


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

double dp[3000][3000];
double p[3000];
int main() {
  ios::sync_with_stdio(0); cin.tie(0);
  int n;
  cin >> n;
  for (int i = 0; i < n; i++)
    cin >> p[i];
  dp[0][0] = 1;
  double ans = 0;
  for (int i = 0; i <= n; i++) {
    for (int j = 0; j+i < n; j++) {
      dp[i+1][j] +=    p[i+j] *dp[i][j];
      dp[i][j+1] += (1-p[i+j])*dp[i][j];
    }
    ans += dp[i][n-i]*(i>n-i);
  }
  cout << setprecision(20) << ans << endl;
}


Measured memory_bytes: 70016
#include <cstdio>
#include <iostream>
#include <vector>
#include <set>
#include <map>
#include <cmath>
#include <string>
#include <cstring>
#include <sstream>
#include <algorithm>
using namespace std;

typedef long long ll;

ll N;


int main()
{
	cin >> N;
	for (ll h = 1; h <= 3500; h++)
		for (ll n = 1; n <= 3500; n++) {
			ll a = N * h * n;
			ll b = 4ll * h * n - N * (n + h);
			if (b <= 0 || a % b != 0) continue;
			ll w = a / b;
			printf("%lld %lld %lld\n", h, n, w); return 0;
		}
	return 0;
}

Measured memory_bytes: 256
/*Template by hemnath_d(Enlightened by chamow)*/
#include<bits/stdc++.h>
using namespace std;
/*--------------------------------------------------------------*/
typedef long long ll;
typedef long double ld;
typedef vector<ll> vec;
typedef vector<int> vi;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
/*--------------------------------------------------------------*/
#define fastread ios_base::sync_with_stdio(false); cin.tie(NULL);
#define pb push_back
#define mp make_pair
#define fx first
#define sx second
#define forw(i,a,n) for(i=a;i<=n;i++)
#define rev(i,a,n) for(i=a;i>=n;i--)
#define For(i,a,n) for(i=a;i<n;i++)
#define Rev(i,a,n) for(i=a;i>n;i--)
#define inf 100000000000000
#define minf -100000000000000
/*--------------------------------------------------------------*/
//Function to add an edge for graph
//Undirected graph
void add_edge(vec adj[],ll a,ll b)
{
    adj[a].pb(b);
    adj[b].pb(a);
}
/*---------------------------------------------------------------*/
//Comparator class for min-heap using priority_queue
//Change the parameters before use
class myComparator
{
public:
    int operator() (/*Datatype*/int p1,/*Datatype*/int  p2)
    {
        return p1/*value*/ > p2/*value*/;
    }
};
/*----------------------------------------------------------------*/
//END OF TEMPLATE
/*----------------------------------------------------------------*/
int main()
{
    fastread;
    string s;
    cin>>s;
    ll co=0,i;
    For(i,0,s.size())
    {
        if(s[i]=='1')
            co++;
    }
    cout<<co<<endl;
    return 0;
}


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

using namespace std;

#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define REV(i,n) for(ll (i) = (n) - 1;(i) >= 0;--i)
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {REP(WW,n)cerr << v[WW] << ' ';cerr << endl << endl;}
#define SHOW2d(v,WW,HH) {REP(W_,WW){REP(H_,HH)cerr << v[W_][H_] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL
#define MOD 998244353

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

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

    ll n;cin >> n;
    ll sum = 0;
    vector<ll> v(n);
    REP(i, n){
        cin >> v[i];
        sum += v[i];
    }

    ll ans = LLINF;
    ll now = 0;
    REP(i, n){
        now += v[i];
        ll a = now;
        ll b = sum - now;
        ans = min(ans, abs(a - b));
    }

    cout << ans << endl;

	return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
 
int main() {

  int a,b;
  cin >> a >> b;
  
  if (a%2 == 1 && b%2 == 1) {
    cout << "Odd" << endl;
  }
    else {
    cout << "Even" << endl;
    }
}

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

using namespace std;
int N;
int W;
vector<int> takaraW;
vector<int> takaraK;
vector<int> olddp;
vector<int> dp;

int main(){
    int kl = 1;
    while(true){
        takaraK.clear();
        takaraW.clear();
        dp.clear();
        cin >> W;
        if(W==0) return 0;
        cin >> N;
        takaraK.resize(N);
        takaraW.resize(N);
        dp.resize(W+1);
        for(int i=0;i<N;i++){
            char comma;
            cin >> takaraK[i] >> comma >>  takaraW[i];
        }
        for(int i=0;i<N;i++){
            olddp = dp;
            for(int j=0;j<W;j++){
                int neww = takaraW[i]+j;
                int newk = takaraK[i]+olddp[j];
                int oldk = olddp[neww];
                if(neww > W) continue;
                if(oldk < newk){
                    dp[neww] = newk;
                }
            }
        }
        int mw=W+2,mk=-1;
        for(int i=0;i<=W;i++){
            if(mk < dp[i]){
                mk = dp[i];mw = i;
            }
        }
        cout << "Case " << kl++ << ":" << endl;
        cout << mk << endl;
        cout << mw << endl;
    }
    return 0;
}

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

//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

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

#define si(a)           scanf("%d",&a)
#define sii(a,b)        scanf("%d %d",&a,&b)
#define siii(a,b,c)     scanf("%d %d %d",&a,&b,&c)

#define sl(a)           scanf("%lld",&a)
#define sll(a,b)        scanf("%lld %lld",&a,&b)
#define slll(a,b,c)     scanf("%lld %lld %lld",&a,&b,&c)

#define un(x)           x.erase(unique(all(x)), x.end())
#define xx              first
#define yy              second
#define pb              push_back
#define mp              make_pair
#define all(v)          v.begin(),v.end()
#define D(x)            cerr << #x " = " << x << '\n'
#define DBG             cerr << "Hi!" << '\n'

#define CLR(a)          memset(a,0,sizeof(a))
#define SET(a)          memset(a,-1,sizeof(a))

#define PI              acos(-1.0)

//inline int setBit(int n,int pos) { return n = n | (1 << pos); }
//inline int resetBit(int n,int pos) { return n = n & ~(1 << pos); }
//inline bool checkBit(int n,int pos) { return (bool)(n & (1 << pos)); }
//inline int countBit(ll n) { return __builtin_popcountll(n); }


//int fx[] = {+0, +0, +1, -1, -1, +1, -1, +1};
//int fy[] = {-1, +1, +0, +0, +1, +1, -1, -1}; //Four & Eight Direction

/******************************************************************************************/

const ll MAX = 100010;
const ll INF = 0x3f3f3f3f;
//const double inf = 1.0/0.0;
//const int MOD = 1000000007;

int dp[3005][3005];
pii nxt[3005][3005];

string a,b;

int call(int x,int y) {
    if(x>=a.size() or y>=b.size()) return 0;
    if(dp[x][y]!=-1) return dp[x][y];
    int ret;
    if(a[x] == b[y]) {
        ret = 1 + call(x+1,y+1);
        nxt[x][y] = {x+1,y+1};
    }
    else {
        ret = max(call(x+1,y),call(x,y+1));
        if(call(x+1,y) == ret) nxt[x][y] = {x+1,y};
        else nxt[x][y] = {x,y+1};
    }
    return dp[x][y] = ret;
}

void print(int x,int y) {
    if(x>=a.size() or y>=b.size()) return;
    if(a[x]==b[y]) cout << a[x];
    print(nxt[x][y].xx,nxt[x][y].yy);
}


int main() {
//    freopen("in.txt","r",stdin);
    //freopen("out.txt","w",stdout);

    cin >> a >> b;

    SET(dp);
    call(0,0);
    print(0,0);
    puts("");
    return 0;
}



Measured memory_bytes: 106496
#include <bits/stdc++.h>
using namespace std;
using Int = long long;
#define rep(i, n) for (int i = 0, i##_len = (int)(n); i < i##_len; i++)
#define PB push_back
#define SZ(x) ((int)(x).size())
#define ALL(v) (v).begin(), (v).end()
#define PUTS(x) cout << (x) << endl;
vector<Int> IntsIn(int n) {
    auto v = vector<Int>(0);
    for (int i = 0; i < n; i++) {
        Int a;
        cin >> a;
        v.push_back(a);
    }
    return v;
}
int main() {
    Int n;
    cin >> n;
    auto a = IntsIn(n);
    auto shortage = 0LL;
    auto shortageCount = 0LL;
    auto surpluses = vector<Int>();
    rep(i, n) {
        Int x;
        cin >> x;
        if (a[i] > x) {
            surpluses.PB(a[i] - x);
        } else if (x > a[i]) {
            shortageCount++;
            shortage += x - a[i];
        }
    }
    sort(ALL(surpluses), greater<Int>());
    if (shortage == 0) {
        puts("0");
        return 0;
    }
    Int current = 0;
    while (shortage > 0 && current < SZ(surpluses)) {
        if (surpluses[current] >= shortage) {
            PUTS(shortageCount + current + 1);
            return 0;
        } else {
            shortage -= surpluses[current];
            current++;
        }
    }
    puts("-1");
}


Measured memory_bytes: 1908
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
#define FOR(i,a,b) for(long long int i=a;i<b;i++)
#define sz(s) (long long int)(s).size()
#define pb push_back
#define mp make_pair
const ll inf = 1000000000;
const ll MOD = 1000000007;

int main(void){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);   
    cout.tie(NULL);
    register ll i,j,k,x,y,m,n,t,q,temp,sum=0,count=0,f=1;
    cin>>n>>m;
    ll a[n+1][m+1];
    char c;
    for(i=0;i<n;i++){
    	for(j=0;j<m;j++){
    		// if(i==0 || j == 0)a[i][j] = 0;
    		// else {
    			cin>>c;
    			if(c == '.')a[i][j] = 0;
    			else a[i][j] = 1;    		
			// }
    	}
    }
    ll dp[n+1][m+1];        
    for(i=0;i<n;i++){
    	for(j=0;j<m;j++){
    		if(i == 0 && j == 0)dp[i][j] = 1;
    		else if(a[i][j] == 1){
    			// cout<<i<<" "<<	j<<"@@";
    			dp[i][j] = 0;    		    		
			}
    		else{
    			if(i-1 >= 0 && j-1 >= 0){
    				if(a[i-1][j] != 1 && a[i][j-1] != 1)
    					dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD;
    				else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
    			}else if(i-1 >= 0){
    				dp[i][j] = dp[i-1][j];
    			}else if(j-1 >= 0){
    				dp[i][j] = dp[i][j-1];
    			}    			
    		}	
    	}
    }
    // for(i=0;i<n;i++){
    // 	for(j=0;j<m;j++){
    // 		cout<<dp[i][j]<<" ";
    // 	}
    // 	cout<<"\n";
    // }
    cout<<dp[n-1][m-1];
}    
    

Measured memory_bytes: 15872
#include <bits/stdc++.h>
 
#define ALL(l)  (l).begin(),(l).end()
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
using namespace std;
typedef long long ll;
//const ll mod =  1000000007;
//const ll maxn = 1000000000;

//---------------------------------------------------------------------------------------------------
using vi = vector<int>; // intの1次元の型に vi という別名をつける
using vll = vector<ll>; // intの1次元の型に vi という別名をつける
using vvll = vector<vll>; // intの2次元の型に vvi という別名をつける
using vs = vector<string>; // stringの1次元の型に vs という別名をつける
using pll = pair<ll, ll>; // これ以降 pii という型名はpair<ll, ll> と同じ意味で使える
//---------------------------------------------------------------------------------------------------

int main(){
    ll a,b;
    cin>>a>>b;
    cout<<max(a+b,max(a-b,a*b))<<endl;
    
}
   



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

using namespace std;

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

vector< vector<P> > G;

struct Union_Find {
    //各要素が属する集合の代表(根)を管理する
    //もし、要素xが根であればdata[x]は負の値を取り、-data[x]はxが属する集合の大きさに等しい
    vector<int> data;
    
    Union_Find(int size) : data(size, -1) {}
    bool Union(int x, int y) {
        x = Find(x);
        y = Find(y);
        bool is_union = (x != y);
        if (is_union) {
            if (data[x] > data[y]) swap(x, y);
            data[x] += data[y];
            data[y] = x;
        }
        return is_union;
    }
    int Find(int x) {
        if (data[x] < 0) { //要素xが根である
            return x;
        } else {
            data[x] = Find(data[x]); //data[x]がxの属する集合の根でない場合、根になるよう更新される
            return data[x];
        }
    }
    bool same(int x, int y) {
        return Find(x) == Find(y);
    }
    int size(int x) {
        return -data[Find(x)];
    }
};

struct Edge {
    int u, v;
    ll cost;
    bool operator<(const Edge& e) const {
        return cost < e.cost;
    }
}; 

struct Graph {
    int n; //頂点数
    vector<Edge> es; //辺集合
    
    ll kruskal() {
        sort(es.begin(), es.end());
        Union_Find uf(n);
        ll min_cost = 0;
        for(int i = 0; i < (int)es.size(); i++) {
            Edge e = es[i];
            if (!uf.same(e.u, e.v)) {
                min_cost += e.cost;
                uf.Union(e.u, e.v);
                G[e.u].emplace_back(e.v, e.cost);
                G[e.v].emplace_back(e.u, e.cost);
            }
        }
        return min_cost;
    }
};

Graph input() {
   Graph g;
   int m;
   cin >> g.n >> m;
   g.es = vector<Edge>(m);
   for(int i = 0; i < m; i++) {
        cin >> g.es[i].u >> g.es[i].v >> g.es[i].cost;
        g.es[i].u--;
        g.es[i].v--;
   }
   return g;
}

void dfs(int cur, int par, vector<ll>& d) {
    for (P nex : G[cur]) {
        if (nex.first == par) continue;
        d[nex.first] = max(d[cur], nex.second);
        dfs(nex.first, cur, d);
    }
}

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	Graph g = input();
    G.resize(g.n);
    ll sum = g.kruskal();
    vector< vector<ll> > maxc(g.n, vector<ll>(g.n, 0));
    for (int i = 0; i < g.n; i++) {
        dfs(i, -1, maxc[i]);
    }
    int q;
    cin >> q;
    for (int i = 0; i < q; i++) {
        int s, t;
        cin >> s >> t;
        s--;
        t--;
        cout << sum - maxc[s][t] << endl;
    }
	return 0;
}

Measured memory_bytes: 133248
n=int(input())
a=list(map(int, input().split()))
ans = 1
if a.count(0)>0:
    print(0)
    exit()
for i in range(n):
    l = len(str(ans))
    L = len(str(a[i]))
    if a[i] > 10**18:
        print(-1)
        exit()
    elif l+L > 20:
        print(-1)
        exit()
    ans *= a[i]
    if ans > 10**18:
        print(-1)
        exit()
print(ans)

Measured memory_bytes: 84572
#include <iostream>

using namespace std;

int main(void) {
    string s;
    cin>>s;
    int price = 700;
    if (s[0] == 'o') price += 100;
    if (s[1] == 'o') price += 100;
    if (s[2] == 'o') price += 100;
    cout<<price<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

using namespace std;

int main(){
	int a,b;
	scanf("%d %d",&a,&b);
	if(a > b){
		printf("a > b\n");
	}else if(a < b){
		printf("a < b\n");
	}else{
		printf("a == b\n");
	}
}



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

int main() {
  int A;
  int B;
  int C;
   cin >> A;
   cin >>  B;
   cin >>  C;
   if(C+B-A<0){
     cout << "0";
   }else{
    cout << C+B-A; 
   }
	return 0;
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
#define lson (o<<1)
#define rson (o<<1|1)
#define fi first
#define sc second
#define dbg(x) cout<<#x<<" = "<<(x)<<endl;
typedef long long ll;
typedef unsigned int uint;
typedef unsigned long long ull;
using namespace std;
const double pi=acos(-1);
const double eps=1e-6;
inline int lowbit(int x){return x&(-x);}
inline int read(){
	int f=1,x=0;char ch;
	do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
	do{x=x*10+ch-'0';ch=getchar();}while(ch>='0'&&ch<='9');
	return f*x;
}
template<typename T> inline T max(T x,T y,T z){return max(max(x,y),z);}
template<typename T> inline T min(T x,T y,T z){return min(min(x,y),z);}
template<typename T> inline T sqr(T x){return x*x;}
template<typename T> inline void checkmax(T &x,T y){x=max(x,y);}
template<typename T> inline void checkmin(T &x,T y){x=min(x,y);}
template<typename T> inline void read(T &x){
x=0;T f=1;char ch;do{ch=getchar();if(ch=='-')f=-1;}while(ch<'0'||ch>'9');
do x=x*10+ch-'0',ch=getchar();while(ch<='9'&&ch>='0');x*=f;
}
template<typename A,typename B,typename C> inline A fpow(A x,B p,C yql){
	A ans=1;
	for(;p;p>>=1,x=1LL*x*x%yql)if(p&1)ans=1LL*x*ans%yql;
	return ans;
}
struct FastIO{
	static const int S=1310720;
	int wpos;char wbuf[S];
	FastIO():wpos(0){}
	inline int xchar(){
		static char buf[S];
		static int len=0,pos=0;
		if(pos==len)pos=0,len=fread(buf,1,S,stdin);
		if(pos==len)return -1;
		return buf[pos++];
	}
	inline int read(){
		int c=xchar(),x=0;
		while(c<=32&&~c)c=xchar();
		if(c==-1)return -1;
		for(;'0'<=c&&c<='9';c=xchar())x=x*10+c-'0';
		return x;
	}
}io;
//#define read io.read
int main()
{
//	freopen("","r",stdin);
//	freopen("","w",stdout);
	int a,b;
	cin >> a >> b;
	if(a<b) cout << "0";
	else cout << "10";
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<utility>
#include<math.h>

using namespace std;

typedef long long ll;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pair<int, int> > vp;

#define pb push_back
#define rep(i, n) for(int i = 0; i < (n); i++)
#define For(i, a, n) for(int i = a; i < (n); i++)
#define out(n) cout << (n) << endl;
#define vut(v) rep(i, v.size()) out(v[i]);

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

  cin >> a >> b >> c;

  out(b / c - a / c + (a % c == 0 ? 1 : 0))
}


Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}

int main(){
  int a,b,c,l,r;
  cin >> a >> b >> c;
  
  int m = max(a,max(b,c));
  
  if((m*3)%2 == (a+b+c)%2){
    cout << (m*3 - (a+b+c)) / 2;
  }else{
    cout << ((m+1)*3 - (a+b+c)) / 2;
  }
  
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,x,y) for(int i=x;i<y;i++)
#define print(A,x,n) rep(I,0,n){cout<<(I ? " ":"")<<A[I]x;}cout<<endl;
#define pprint(A,y,m,n) rep(J,0,m){print(A[J],y,n);}
const long mod=1e9+7;
const int size=1e5;
const int inf=1e9;
int N,M;
vector<pair<int,long>> g[100000];
long dist[100000]; int pre[100000];
void dijkstra(int a){// O(NlogN + M)
	priority_queue<pair<long,int>> pq;
	rep(i,0,N){
		if(i == a){ dist[a] = 0; pq.push({0, a}); }
		else{ dist[i] = inf; pq.push({-inf, i}); }
	}
	while(!pq.empty()){
		int v = pq.top().second;
		pq.pop();
		for(pair<int,long> p:g[v]){
            int u = p.first;
			long t = dist[v] + p.second;
			if(dist[u] > t){
				dist[u] = t;
				pre[u] = v;
				pq.push({-dist[u], u});
			}
		}
	}return;
}
int main(){
	cin>>N>>M;
	int a,b;
	rep(i,0,M){
		cin>>a>>b; a--; b--;
		g[a].push_back({b, 1});
		g[b].push_back({a, 1});
	}
	dijkstra(0);
	cout<<"Yes"<<endl;
	rep(i,1,N) cout<<pre[i] + 1<<endl;
}

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

#define endl '\n';
#define ll long long

int main()
{
	ios::sync_with_stdio(0);
	cin.tie(0);
	
	ll int x;
	string s;
	cin >> s;
	if(s[0]=='S' && s[1]=='U') cout << 7;
	else if(s[0]=='S' && s[1]=='A') cout << 1;
	else if(s[0]=='T' && s[1]=='U') cout << 5;
	else if(s[0]=='M' && s[1]=='O') cout << 6;
	else if(s[0]=='W' && s[1]=='E') cout << 4;
	else if(s[0]=='T' && s[1]=='H') cout << 3;
	else if(s[0]=='F' && s[1]=='R') cout << 2;
	
	return 0;
}

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

const int N = 1000 + 10;

queue< pair<int, int> > q;

int n, m;
int a[N][N];
char s[N][N];
int inq[N][N], d[N][N];

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

inline bool in (int x, int y) { return x > n || x < 1 || y > m || y < 1; }

int main (void) {
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= n; i++) {
		scanf("%s", s[i] + 1);
		for (int j = 1; j <= m; j++) {
			if (s[i][j] == '#') {
				q.push({ i, j });
				inq[i][j] = 1;
			}
		}
	}
	while (!q.empty()) {
		int i = q.front().first;
		int j = q.front().second;
		q.pop();
		for (int k = 0; k < 4; k++) {
			if (inq[i + dx[k]][j + dy[k]]) continue;
			if (in(i + dx[k], j + dy[k])) continue;
			if (s[i + dx[k]][j + dy[k]] == '.') {
				inq[i + dx[k]][j + dy[k]] = 1;
				s[i + dx[k]][j + dy[k]] = '#';
				d[i + dx[k]][j + dy[k]] = d[i][j] + 1;
				q.push({ i + dx[k], j + dy[k] });
			}
		}
	}

	int mx = 0;
	for (int i = 1; i <= n; i++) {
		for (int j = 1; j <= m; j++) {
			mx = max(mx, d[i][j]);
		}
	}
	printf("%d\n", mx);
}

Measured memory_bytes: 16656
N = int(input())

numlist=set(['3','5','7'])
for i in range(8):
    numlist2=set()
    for num in numlist:
        numlist2.add('3'+num)
        numlist2.add('5'+num)
        numlist2.add('7'+num)
    numlist = numlist.union(numlist2)
    #print(numlist2)
#print(len(numlist))
def chk753(a):
    c3=0
    c5=0
    c7=0
    for i in range(len(a) ):
        if a[i]=='7':
            c7+=1
        elif a[i] == '5':
            c5+=1
        elif a[i] == '3':
            c3+=1
    if c7>0 and c5>0 and c3>0 :
        return True
    else:
        return False

def chkN(a,N):
    if int(a) <= N:
        return True
    else:
        return False

cnt=0
for t in numlist:
    if chk753(t) and chkN(t,N):
        cnt+=1
        #print(t)

print(cnt)

Measured memory_bytes: 10712
#!/usr/bin/env ruby
while line = gets
  a = line.chomp!.to_i

  k = 9
  weights = []
  while a != 0
    if a >= 2 ** k
      a -= (2 ** k)
      weights << k
    end
    k -= 1
  end
  puts weights.map{|w| 2**w}.reverse.join(' ')
end

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

int main(void){
    char c;
    scanf("%c",&c);
    if (c=='A'){
        printf("T\n");
    } else if (c=='T'){
        printf("A\n");
    } else if (c=='G'){
        printf("C\n");
    } else {
        printf("G\n");
    }
    return 0 ;
}

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

int main() {
  int N,A;
  cin >> N;
  cin >> A;
  bool pay = false;
  if (N <= A){
    pay = true;
  }
  else if (N % 500 <= A) {
    pay = true;
  }
  if(pay) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
def solution(s):
    #todo: check if s is valid
    if s[0] == 'A' and sum([1 for c in s if c =='C']) == 1 and sum([1 for c in s[2:-1] if c =='C']) == 1 and sum([1 for c in s if ord(c) <= ord('Z')]) == 2:
        return 'AC'
    return 'WA'

def main():
    s = raw_input().strip()
    print solution(s)

if __name__ == '__main__':
    main()

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

using namespace std;

int main()
{
    ll n, a, b;
    cin >> n >> a >> b;
    if(a > b)swap(a, b);
    ll ans = 0;
    if(abs(a-b) % 2){
        ans = min(a, n-b+1) + (abs(a-b)-1)/2;
    }
    else{
        ans = abs(a-b)/2;
    }
    cout << ans;
}


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

int main()
{
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  
  while(true)
  {
    if((c -= b) <= 0)
    {
      cout << "Yes" << endl;
      break;
    }
    
    if((a -= d) <= 0)
    {
      cout << "No" << endl;
      break;
    }
  }
  
  return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <cstdio>
#include <vector>
#include <list>
#include <algorithm>
#include <cmath>
#include <stack>
#include <set>
using namespace std;

#define REP(i,n) for(int (i)=0; (i)<(n); (i)++)
#define FOR(i,a,b) for(int (i)=(a); (i)<(b); (i)++)
#define PUSH(n,v) for(int i=0; i<(n); i++) {int j; cin >> j; v.push_back(j);}
#define ALL(v) v.begin(), v.end()

vector<int> v;
int k;

int howmanytrucks(int vol) {
    int cnt = 1;
    int sp = vol;
    REP(i,v.size()) {
        if (v[i] <= sp) sp -= v[i];
        else if (v[i] > vol) return -1;
        else {
            cnt++;
            sp = vol - v[i];
        }
    }
    return cnt;
}

bool notenoughtrucks(int vol) {
    return howmanytrucks(vol) == -1 || howmanytrucks(vol) > k;
}

int getmini(int vol, int minivol) {
    while(1) {
        if (!notenoughtrucks(minivol)) return minivol;
        else if (minivol <= vol) minivol++;
        else break;
    }
    return -1;
}

int binary_minivol(int vol, int minivol) {
    //cout << vol << " " << minivol << endl;
    if (vol - minivol < 2) return getmini(vol, minivol);
    if (notenoughtrucks(vol)) return binary_minivol(vol * 2, vol);
    else if (notenoughtrucks((vol + minivol) / 2)) {
        return binary_minivol(vol, (vol + minivol) / 2);
    }else {
        return binary_minivol((vol + minivol) / 2, minivol);
    }
}

int main() {
    int n;
    cin >> n >> k;
    
    long sum = 0;
    REP(i,n) {
        int j;
        cin >> j;
        sum += j;
        v.push_back(j);
    }
    
    int minivol = sum / v.size();
    minivol = binary_minivol(minivol * 2, minivol);
    if (minivol == -1) minivol = binary_minivol(3, 1);
    
    cout << minivol << endl;
    
    return 0;
}

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

int main() {
	char a[10],b[10],c[10],d = 'A' - 'a';
	cin >> a >> b >> c;
	printf("%c%c%c\n", a[0] + d, b[0] + d, c[0] + d);
	return 0;
}

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

using namespace std;

using ll = long long;
constexpr ll MOD = 1e9 + 7;
constexpr ll INF = 1e18;

int main() {
    string s;
    cin >> s;
    ll k;
    cin >> k;
    set<string>v;
    ll ss=s.size();
    for(ll i=0;i<ss;i++){
        for(ll j=1;j<=k;j++){
            //if(i+j-1>ss)continue;
            v.insert(s.substr(i,j));
        }
    }
    auto it=v.begin();
    for(int i=0;i<k;i++){
        it++;
    }
    cout << *(--it) << endl;
}

Measured memory_bytes: 1664
#include <string>
#include <vector>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <map>
#include <list>
#include <set>
#include <numeric>
#include <queue>
#include <stack>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <climits>
#include <cfloat>
#include <ctime>
#include <complex>
#include <cassert>
#include <array>
#include <bitset> 
#include <unordered_map>
#include <random>

using namespace std;
typedef long long LL;
typedef pair<LL,LL> P;
typedef array<LL,4> A;

const int L=3e5+10;
A vs[L];
LL rs[L];
int X,Y,Z,N;
int main() {
	cin >> X >> Y >> Z;
	N=X+Y+Z;
	for(int i=0;i<N;i++){
		LL a,b,c;
		cin >> a>>b>>c;
		vs[i]=A{{a-b,a,b,c}};
	}
	sort(vs,vs+N);

	{
		LL s=0;
		priority_queue<A> pq;
		for(int i=0;i<Y;i++){
			vs[i][0]=vs[i][3]-vs[i][2];
			s+=vs[i][2];
			pq.push(vs[i]);
		}
		rs[Y]=s;
		for(int i=Y;i<N-X;i++){
			s+=vs[i][2];
			vs[i][0]=vs[i][3]-vs[i][2];
			pq.push(vs[i]);
			A a=pq.top();
			pq.pop();
			s-=a[2];
			s+=a[3];
			rs[i+1]=s;
		}
	}
	{
		priority_queue<A> pq;
		LL s=0;
		for(int i=N-1;i>=N-X;i--){
			s+=vs[i][1];
			vs[i][0]=vs[i][3]-vs[i][1];
			pq.push(vs[i]);
		}
		LL ret=s+rs[N-X];
		for(int i=N-X-1;i>=Y;i--){
			s+=vs[i][1];
			vs[i][0]=vs[i][3]-vs[i][1];
			pq.push(vs[i]);
			A a=pq.top();
			pq.pop();
			s-=a[1];
			s+=a[3];
			ret=max(ret,rs[i]+s);
		}
		cout << ret << endl;
	}

	return 0;
}



Measured memory_bytes: 12544
# 幅優先探索
from collections import deque
H, W = map(int, input().split())
dif = [(-1, 0), (1, 0), (0, 1), (0, -1)]
Map = [list(input()) for i in range(H)]
visited = [[False for i in range(W)] for j in range(H)]
deq = deque()


def bfs(node):
    nx, ny = node
    deq.append(node)

    visited[nx][ny] = True
    distance = [[float("inf") for i in range(W)] for j in range(H)]
    distance[nx][ny] = 0
    while deq:
        x, y = deq.popleft()
        for dx, dy in dif:
            if 0 <= x+dx < H and 0 <= y+dy < W and Map[x+dx][y+dy] == "." and visited[x+dx][y+dy] == False:
                visited[x+dx][y+dy] = True
                distance[x+dx][y+dy] = distance[x][y]+1
                deq.append((x+dx, y+dy))
    return distance


def s_bfs(node):
    nx, ny = node
    deq.append(node)
    Visited = [[False for i in range(W)] for j in range(H)]
    Visited[nx][ny] = True
    distance = [[float("inf") for i in range(W)] for j in range(H)]
    distance[nx][ny] = 0
    while deq:
        x, y = deq.popleft()
        for dx, dy in dif:
            if 0 <= x+dx < H and 0 <= y+dy < W and Map[x+dx][y+dy] == "." and Visited[x+dx][y+dy] == False:
                Visited[x+dx][y+dy] = True
                distance[x+dx][y+dy] = distance[x][y]+1
                deq.append((x+dx, y+dy))
    return distance


ans = 1
roads = deque()
for i in range(H):
    for j in range(W):
        if Map[i][j] == ".":
            roads.append((i, j))

while roads:
    x, y = roads.popleft()
    if visited[x][y] == False:
        B = s_bfs((x, y))
        s = -1
        choice=[]
        most_far_distance = 0
        for i in range(H):
            for j in range(W):
                if B[i][j] != float("inf") and B[i][j] > most_far_distance:
                    most_far_distance = B[i][j]
        for i in range(H):
            for j in range(W):
                if B[i][j] == most_far_distance:
                    choice.append((i, j))

        for s in choice:
            C = s_bfs(s)
            for i in range(H):
                for j in range(W):
                    if C[i][j] != float("inf"):
                        ans = max(ans, C[i][j])
print(ans)

Measured memory_bytes: 9448
#include <iostream>
#include <algorithm>
using namespace std;
int n,k,cnt;
long long ans=5e18,x[60],y[60];
int main(){
    cin>>n>>k;
    for(int i=0;i<n;i++)cin>>x[i]>>y[i];
    for(int a=0;a<n;a++){
        for(int b=0;b<n;b++){
            if(x[b]<x[a])continue;
            for(int c=0;c<n;c++){
                for(int d=0;d<n;d++){
                    if(y[d]<y[c])continue;
                    cnt=0;
                    for(int i=0;i<n;i++)if(x[a]<=x[i]&&x[i]<=x[b]&&y[c]<=y[i]&&y[i]<=y[d])cnt++;
                    if(cnt>=k)ans=min(ans,(x[b]-x[a])*(y[d]-y[c]));
                }
            }
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 384
#include <stdio.h>

int main(void){
    char line[10],sign;
    int i;
    for(;sign=0,scanf("%s",line)!=EOF;){
        for(i=0;i<7;i+=3)
            if(line[i]!= 's' && line[i]==line[i+1] && line[i+1]==line[i+2])
                sign=line[i];
        for(i=0;i<3;i++)
            if(line[i]!='s' && line[i]==line[i+3] && line[i+3]==line[i+6])
                sign=line[i];
        if(line[0]!='s' && line[0]==line[4] && line[4]==line[8])
            sign=line[0];
        if(line[2]!='s' && line[2]==line[4] && line[4]==line[6])
            sign=line[2];
        printf("%c\n",sign==0?'d':sign);
    }
    return 0;
}

Measured memory_bytes: 540
#define _CRT_SECURE_NO_WARNINGS
#include<stdio.h>
#include<vector>
#include<functional>
#include<algorithm>
#include<stdlib.h>
#include<string>
#include<string.h>
#define _USE_MATH_DEFINES
#include<math.h>
#include<deque>
#include<map>
#include<iostream>
using namespace std;
typedef long long ll;
#define rep(i,a,b) for(auto i=a;i<b;i++)
#define all(_x) _x.begin(), _x.end()
#define r_sort(_x) sort(_x.begin(), _x.end(), std::greater<int>())
#define vec_cnt(_a, _n) (upper_bound(all(_a), _n) - lower_bound(all(_a), _n))
int main() {
	int N, x;
	scanf("%d", &N);
	x = N / 2;
	vector<pair<int, int>> A(N);
	vector<int> ans(N);
	rep(i, 0, N)scanf("%d", &A[i].first), A[i].second = i;
	sort(all(A));
	rep(i, 0, N) {
		if (i >= x)ans[A[i].second] = A[x - 1].first;
		else ans[A[i].second] = A[x].first;
	}
	rep(i, 0, N)printf("%d\n", ans[i]);
	return 0;
}


Measured memory_bytes: 4480
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Text;

class TEST{
	static void Main(){
		Sol mySol =new Sol();
		mySol.Solve();
	}
}

class Sol{
	public void Solve(){
		
		var di = new Dictionary<String, int>();
		foreach(var s in S){
			if(!di.ContainsKey(s)) di.Add(s, 0);
			di[s]++;
		}
		
		int ma = 0;
		foreach(var k in di.Keys){
			ma = Math.Max(ma, di[k]);
		}
		
		List<String> L = new List<String>();
		foreach(var k in di.Keys){
			if(di[k] == ma) L.Add(k);
		}
		
		L.Sort(StringComparer.Ordinal);
		Console.WriteLine(String.Join("\n", L));
		
	}
	int N;
	String[] S;
	public Sol(){
		N = ri();
		S = new String[N];
		for(int i=0;i<N;i++) S[i] = rs();
	}

	static String rs(){return Console.ReadLine();}
	static int ri(){return int.Parse(Console.ReadLine());}
	static long rl(){return long.Parse(Console.ReadLine());}
	static double rd(){return double.Parse(Console.ReadLine());}
	static String[] rsa(char sep=' '){return Console.ReadLine().Split(sep);}
	static int[] ria(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>int.Parse(e));}
	static long[] rla(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>long.Parse(e));}
	static double[] rda(char sep=' '){return Array.ConvertAll(Console.ReadLine().Split(sep),e=>double.Parse(e));}
}


Measured memory_bytes: 48380
#include <algorithm>
#include <cstdio>
#include <functional>
#include <iostream>
#include <cfloat>
#include <climits>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <time.h>
#include <complex>
#include <vector>
#include <limits>
#include <iomanip>
#include <cassert>

using namespace std;

typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

#define debug(x) cout << #x << " = " << (x) << endl;
#define rep(i, n) for(int i = 0;i < n;i++)
#define repr(i, n) for(int i = n-1;i >= 0;i--)
#define pb push_back
#define mp make_pair
#define F first
#define S second

const long double pi = 3.141592653589793;
const int mod = 1e9 + 7;

const int H = 1021;
vector<string> vs(H);
vector<vector<int>> d(H, vector<int>(H, INT_MAX));
int sx, sy, ex, ey, N, M;

void dijkstra() {
    d[sx][sy] = 0;
    set<pair<int, pair<int, int>>> q;
    q.insert({0, {sx, sy}});
    while (!q.empty()) {
        auto v = q.begin()->second;
        q.erase(q.begin());

        int x = v.F, y = v.S;
        for(int i = -2;i <= 2;i++) {
          for(int j = -2;j <= 2;j++) {
            int xn = x+i, yn = y+j;
            if(x == xn && y == yn) continue;
            if(xn >= N || xn < 0) continue;
            if(yn >= M || yn < 0) continue;
            int len = 1;
            if(abs(x-xn) == 0 && abs(y-yn) == 1) len = 0;
            if(abs(x-xn) == 1 && abs(y-yn) == 0) len = 0;
            if(vs[xn][yn] == '#') continue;
            if (d[x][y] + len < d[xn][yn]) {
                q.erase({d[xn][yn], {xn, yn}});
                d[xn][yn] = d[x][y] + len;
                q.insert({d[xn][yn], {xn, yn}});
            }
          }
        }
    }
}

int main() {

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

 ios_base::sync_with_stdio(false);
 cin.tie(nullptr);

 cin>>N>>M>>sx>>sy>>ex>>ey;
 sx--;sy--;ex--;ey--;
 rep(i,N) cin>>vs[i];
 dijkstra();

 if(d[ex][ey] == INT_MAX) cout<<-1;
 else cout<<d[ex][ey];


 return 0;
}


Measured memory_bytes: 8916
#include<stdio.h>
#include<string.h>
int main ()
{
    char s[100];
    int a;
    scanf("%d",&a);
    scanf("%s",s);
    if (a % 2 != 0)
    {
        printf("No");
        return 0;
    }

    int i,j;
    i = 0;
    j = a/2;
    for(     ;i < a/2; i++,j++)
    {
        if (s[i] != s[j])
        { 
            printf("No");
             return 0;
        }
    }

    printf("Yes");
    
    return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<cstdio>
#include<cstring>

namespace nowayto
{
	typedef long long ll;
	const int N=2010,MOD=1000000007;
	ll qpow(ll a,ll b){ll c=1;for(;b;b>>=1,a=a*a%MOD)if(b&1)c=c*a%MOD;return c;}
	ll C[N][N],sum0[N][N],sum1[N][N];
	int A,B;
	void initialize()
	{
		scanf("%d%d",&A,&B);
		for(int i=0;i<N;i++)sum0[i][0]=C[i][0]=1;
		for(int i=1;i<N;i++)
			for(int j=1;j<N;j++)
				sum0[i][j]=C[i][j]=(C[i-1][j]+C[i-1][j-1])%MOD;

		for(int i=0;i<N;sum1[i][0]=sum0[i][0],i++)
			for(int j=1;j<N;j++)
				sum1[i][j]=sum0[i][j]=(sum0[i][j]+sum0[i][j-1])%MOD;

		for(int i=0;i<N;i++)
			for(int j=1;j<N;j++)
				sum1[i][j]=(sum1[i][j]+sum1[i][j-1])%MOD;
	}
	ll calc(int x,int y)
	{
		if(x<0 || y<0)return 0;
		if(!y)return x+1;
		ll ret=0;
		if(x>=y)ret=(ret+sum0[y][y]*(x-y+1))%MOD,x=y-1;

		ret=(ret+sum1[y][x])%MOD;

		return ret;
	}
	void solve()
	{
		initialize();
		//猫太强了
		ll ans=0,ret;

		for(int i=0;i<=A;i++)
			for(int j=0;j<B;j++)
			{
				if(B-j-1>A-i)continue;

				int ra=A-i-(B-j-1),rb=B-j-2;

				ret=calc(ra,rb);

				if(!ret)ret=1;
				ret=ret*C[B-1][j]%MOD;
				ans=(ans+ret)%MOD;
					
			}
		printf("%lld\n",ans);
	}
}
int main()
{
	nowayto::solve();
	return 0;
}


Measured memory_bytes: 94976
#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace std;
using namespace __gnu_pbds;
typedef long long ll;

struct int_hash {
    static uint64_t splitmix64(uint64_t x) {
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

struct pair_hash {
    size_t operator()(pair<int, int> x) const {
        return int_hash{}(x.first) ^ (int_hash{}(x.second) << 16);
    }
};

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

const int MOD = 1000000007;
const ll INF = numeric_limits<ll>::max();
const int inf = 1e7;
const int MX = 100001; //check the limits, dummy

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

    string s; cin >> s;
    vector<vector<int>> dp(s.size() + 1, vector<int>(2, inf));
    dp[0][0] = 0;
    dp[0][1] = 1;

    for(int i = 1; i <= s.size(); i++) {
        for(int k = 0; k < 2; k++) {
            int cur = (s[i - 1] - '0' + k);
            if(cur < 10) dp[i][k] = min(dp[i][k], dp[i - 1][0] + cur);
            dp[i][k] = min(dp[i][k], dp[i - 1][1] + 10 - cur);
        }
    }

    cout << dp[s.size()][0] << endl;
}

Measured memory_bytes: 55964
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
)

var sc = bufio.NewScanner(os.Stdin)

func readInt() int {
	sc.Scan()
	i, err := strconv.Atoi(sc.Text())
	if err != nil {
		panic(err)
	}
	return i
}

func main() {
	sc.Split(bufio.ScanWords)
	a, b := readInt(), readInt()

	if 1 <= a && a <= 9 && 1 <= b && b <= 9 {
		fmt.Println(a * b)
	} else {
		fmt.Println("-1")
	}
}


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

int main() {
  int n;
  cin >> n;
  vector<int> ans(n);

  rep(i,n){
    int a;
    cin >> a; 
    a--;
    ans[a] = i;
  }

  rep(i,n){
    cout << ans[i]+1 << endl;
  }

  return 0;

}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define ll long long
#define LEFT(a) ((a)<<1)
#define RIGHT(a) (LEFT(a) + 1)
#define MID(a,b) ((a+b)>>1)
#define MAX(a,b) ((a)>(b)?(a):(b))
#define MIN(a,b) ((a)<(b)?(a):(b))
using namespace std;

const int N = 210000;

int n, m;
pair < int, pair < int, int > > P[N];
ll sum[N];
int p[N];
int ans;

int parent (int x){
    if (p[x] == x)
        return x;
    return p[x] = parent (p[x]);
}

bool F[N];

vector < pair < int, int > > G[N];
vector < int > g[N];

void dfs (int k, int x){
    int I = -1;
    for (int i = 19; i >= 0; i--){
        if (I + (1 << i) >= (int)G[k].size())
            continue;
        if (G[k][I + (1 << i)].F <= x)
            I += (1 << i);
    }
    while (I >= 0 && g[k][I] == 0){
        g[k][I] = 1;
        dfs (G[k][I].S, x);
        I--;
    }
}

map < pair < int, pair < int, int > >, bool > M;

int main()
{
    ios_base::sync_with_stdio(false);
    cin >> n >> m;
    for (int i = 1; i <= n; i++){
        cin >> sum[i];
        p[i] = i;
    }
    for (int i = 1; i <= m; i++)
        cin >> P[i].S.F >> P[i].S.S >> P[i].F;
    sort (P + 1, P + m + 1);
    for (int i = 1; i <= m; i++){
        int u = P[i].S.F, v = P[i].S.S, x = P[i].F;
        G[u].pb ({x, v});
        G[v].pb ({x, u});
        u = parent (u);
        v = parent (v);
        //cout << u << " " << v << endl;
        if (u == v){
            if (sum[u] >= x){
                F[i] = 1;
                //cout << i << " " << P[i].S.F << " " << P[i].S.S << endl;
            }
        }
        else {
            if (sum[u] + sum[v] >= x){
                F[i] = 1;
                //cout << i << " " << P[i].S.F << " " << P[i].S.S << endl;
            }
            p[u] = v;
            sum[v] += sum[u];
        }
    }
    for (int i = 1; i <= n; i++){
        sort (G[i].begin(), G[i].end());
        for (int j = 0; j < (int)G[i].size(); j++)
            g[i].pb (0);
    }
    for (int i = m; i >= 1; i--)
        if (F[i] == 1)
            dfs (P[i].S.F, P[i].F);
    for (int i = 1; i <= n; i++)
        for (int j = 0; j < (int)G[i].size(); j++)
            if (g[i][j])
                M[{G[i][j].F, {i, G[i][j].S}}] = 1;
    for (int i = 1; i <= m; i++)
        if (M[{P[i].F, {P[i].S.F, P[i].S.S}}] == 0)
            ans++;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 37888
#include<stdio.h>
#include<string.h>

int main(void){
    char s[201];
    char p[101];
    char s2[101];
    char *ret;
    scanf("%s%s",s,p);
    strcpy(s2,s);
    strcat(s,s2);
    if((ret=strstr(s,p))!=NULL)
        puts("Yes");
    else
        puts("No");
    return 0;
}


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

#define int long long

#define rep(i,n) for(int i=0;i<(n);i++)
#define pb push_back
#define all(v) (v).begin(),(v).end()
#define fi first
#define se second
typedef vector<int>vint;
typedef pair<int,int>pint;
typedef vector<pint>vpint;

template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

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

    vint d(N);
    rep(i,M){
        int a,b;cin>>a>>b;
        a--;b--;
        d[a]++;d[b]++;
    }

    rep(i,N)cout<<d[i]<<endl;
    return 0;
}


Measured memory_bytes: 256