akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <fstream>
#include <algorithm>
#include <cassert>
#include <cctype>
#include <cmath>
#include <complex>
#include <cstdio>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;

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

struct edge{
    int from,to;string cost;
    edge(){}
    edge(int f,int t,string c):from(f),to(t),cost(c){}
};

int n,a,S,G;
string d[40];
edge es[400];

void bf(int G){
    rep(i,n)d[i]=INF;
    d[G]="";
    rep(i,6*n+1){
	bool up=0;
	rep(j,a){
	    edge e=es[j];
	    if(d[e.from]!=INF&&d[e.to]>e.cost+d[e.from]){
		if(i>=n&&e.to==S)d[e.to]=INF;
		else d[e.to]=e.cost+d[e.from];
		up=1;
	    }
	}
	if(!up)break;
    }
}

int main(){//ofstream o("E1out");
    while(cin>>n>>a>>S>>G&&n){
	int f,t;string c;
	rep(i,a){cin>>f>>t>>c;es[i]=edge(t,f,c);}
	bf(G);
	cout<<(d[S]!=INF?d[S]:"NO")<<endl;
    }
}

Measured memory_bytes: 0
n,m=map(int,input().split())
mm=[]
for i in range(1,int(m**0.5+1)):
    if m%i==0:
        mm.append(i)
        mm.append(m//i)

mm.sort(key=lambda x:-x)
for i in mm:
    if i<=m/n:
        print(i)
        break

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

using namespace std;

using VI = vector<int>;
using VVI = vector<VI>;
using VB = vector<bool>;
using VVB = vector<VB>;
using VD = vector<double>;
using VVD = vector<VD>;
using VS = vector<string>;
using PII = pair<int, int>;
using VPII = vector<PII>;
using VL = vector<long long>;
using VVL = vector<VL>;

#define sz(var) (int)var.size()
#define REP(var, start, end) for(int var = start; var < (int)end; ++var)
#define CLEAR(var, with) memset(var, with, sizeof(var))
#define ALL(x) x.begin(), x.end()
#define LL long long
#define ULL unsigned long long


int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);
#ifndef ONLINE_JUDGE
	//freopen("tmp.in", "r", stdin);
//	freopen("tmp.out", "w", stderr);
#endif
	int n, m;
	cin >> n >> m;

	VS box(n + 2, string(m + 2, '#'));
	for(int i = 1; i <= n; ++i)
		for(int j = 1; j <= m; ++j)
			cin >> box[i][j];

	REP(i, 0, n + 2)
		cout << box[i] << endl;
	

	return 0;
}

Measured memory_bytes: 256
n,a,b,c,d = map(int,input().split())
s = input()
a -= 1
b -= 1
c -= 1
d -= 1

def rockcheck(l,r):
    rock = 0
    for i in range(l,r+1):
        if s[i] == "#":
            rock += 1
            if rock == 2:
                print("No")
                exit()
        else: rock = 0
rockcheck(a,c)
rockcheck(b,d)

ans = "No"
if c < d: ans = "Yes"
else:
    for i in range(b,d+1):
        if s[i] == "#": continue
        if s[i-1] == "." and s[i+1] == ".":
            ans = "Yes"
            break
print(ans)

Measured memory_bytes: 9508
N, K, Q = map(int, input().split())
X = [int(input()) for _ in range(Q)]

cnt = [0] * N
for q in X:
    cnt[q - 1] += 1

for i in range(N):
    if Q - cnt[i] >= K:
        print("No")
    else:
        print("Yes")


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

const int MAX = 100;

struct Edge {
	Edge(int v1, int v2, int cost) :v1(v1), v2(v2), cost(cost) {};
	bool operator < (const Edge& e) const {
		return cost > e.cost;
	}
	int v1;
	int v2;
	int cost;
};

int parent(int uft[], int c) {
	if (uft[c] == -1)return c;
	return uft[c] = parent(uft, uft[c]);
}

int main() {
	int n;
	int uft[MAX];
	int sum = 0;
	priority_queue<Edge> q;
	
	cin >> n;

	for (int i = 0; i < n; i++) {
		uft[i] = -1;
	}

	for (int i = 0; i < n; i++) {
		for (int j = 0; j < n; j++) {
			int temp;
			cin >> temp;
			if (temp != -1){
				Edge e(i, j, temp);
				q.push(e);
			}
		}
	}

	while (!q.empty()) {
		Edge e = q.top(); q.pop();
		int p1 = parent(uft, e.v1);
		int p2 = parent(uft, e.v2);

		if (p1 != p2) {
			uft[p1] = p2;
			sum += e.cost;
		}
	}

	cout << sum << endl;
}

Measured memory_bytes: 3096
#include<deque>
#include<queue>
#include<vector>
#include<algorithm>
#include<iostream>
#include<set>
#include<cmath>
#include<tuple>
#include<string>
#include<chrono>
#include<functional>
#include<iterator>
#include<random>
#include<unordered_set>
#include<unordered_map>
#include<array>
#include<map>
#include<bitset>
#include<iomanip>
using namespace std;
typedef long long int llint;
typedef long double lldo;
#define mp make_pair
#define mt make_tuple
#define pub push_back
#define puf push_front
#define pob pop_back
#define pof pop_front
#define fir first
#define sec second
#define res resize
#define ins insert
#define era erase
#define RE return 0
//ios::sync_with_stdio(false);
//std::cin.tie(0);
//<< setprecision(20)
const int mod=1e9+7;
const llint big=1e15+100;
const long double pai=3.141592653589793238462643383279502884197;
const long double ena=2.71828182845904523536;
const long double eps=1e-7;
template <class T,class U>void mineq(T& a,U b){if(a>b){a=b;}}
template <class T,class U>void maxeq(T& a,U b){if(a<b){a=b;}}
template <class T> void soun(T& ar)
{sort(ar.begin(),ar.end());ar.erase(unique(ar.begin(),ar.end()),ar.end());}
int main(void){
	llint i,n,m,iti=0,ni=0;cin>>n>>m;
	vector<int>ren(n);
	vector<vector<int>> hen(n);
	for(i=0;i<m;i++){
		int a,b;cin>>a>>b;
		a--;b--;
		hen[a].pub(b);
		hen[b].pub(a);
	}
	queue<int>que;que.push(0);
	while(que.size()>0){
		int ter=que.front();
		que.pop();
		if(ren[ter]!=0){continue;}
		ren[ter]=1;iti++;
		for(auto it:hen[ter]){que.push(it);}
	}
	que.push(1);
	while(que.size()>0){
		int ter=que.front();
		que.pop();
		if(ren[ter]!=0){continue;}
		ren[ter]=2;ni++;
		for(auto it:hen[ter]){que.push(it);}
	}
	if(iti>ni){iti+=n-iti-ni;}
	else{ni+=n-iti-ni;}
	cout<<(iti*(iti-1))/2 + (ni*(ni-1))/2 -m<<endl;
	RE;
}

Measured memory_bytes: 6272
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>
  
#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
  
using namespace std;
  
typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;
  
const int INF=1<<29;
const double EPS=1e-9;
  
const int dx[]={1,0,-1,0,1,1,-1,-1},dy[]={0,-1,0,1,1,-1,-1,1};

int main() {
    int N;
    cin >> N;
    vector<int> A;
    for (int i = 0; i < 3 * N; i++) {
        int a;
        cin >> a;
        A.push_back(a);
    }
    sort(all(A), [](int a, int b){return a > b;});
    long long int sum = 0;
    for (int i = 0; i < N; i++) {
        sum += A[i * 2 + 1];
    }
    cout << sum << endl;
    return 0;
}

Measured memory_bytes: 2420
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define SORT(v, n) sort(v, v+n)
#define VREV(v,n) reverse(v,v+n)
#define REV(v,n) reverse(v,v+n)
#define vi vector<int>
#define pf push_front
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template<class T, size_t N> size_t countof(const T (&array)[N]) { return N; }
template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<"\n";}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}

void mprint(auto *matrix,auto N){
	REP(i,N) cout<<matrix[i]<<(i!=N-1?' ':'\n');
	return;
}


const double EPS =1e-9;
const int INF =2e+9;
const ll INFL =9e+18; //(+1までok)
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

inline int in(){int x; cin>>x; return x;}

int main(void){
	cin.tie(0);
	ios_base::sync_with_stdio(false);
	
	ll N,K,x,y,result=INFL;
	set<ll> X,Y;
	vector<Pll> ve;
	cin>>N>>K;
	REP(i,N){
		cin>>x>>y;
		X.insert(x);
		Y.insert(y);
		ve.pb(Pll(x,y));
	}
	VSORT(ve);

	for(auto xu:X){
		for(auto xf:X){
			for(auto yu:Y){
				for(auto yf:Y){
					int tem=0;
					REP(i,N){
						int x=ve[i].first,y=ve[i].second;
						if((xu<=x&&x<=xf)&&(yu<=y&&y<=yf)) tem++;
					}
					if(tem>=K)	chmin(result,(abs(xf-xu))*(abs(yf-yu)));
				}
			}
		}
	}
	print(result);
	return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define rep(i,j,n) for(int i=(int)(j);i<(int)(n);i++)
#define REP(i,j,n) for(int i=(int)(j);i<=(int)(n);i++)
#define MOD 1000000007
#define int long long
#define ALL(a) (a).begin(),(a).end()
#define vi vector<int>
#define vii vector<vi>
#define pii pair<int,int>
#define priq priority_queue<int>
#define disup(A,key) distance(A.begin(),upper_bound(ALL(A),(int)(key)))
#define dislow(A,key) distance(A.begin(),lower_bound(ALL(A),(int)(key)))
#define tii tuple<int,int,int>
#define Priq priority_queue<int,vi,greater<int>>
#define pb push_back
#define mp make_pair
#define INF (1ll<<60)
signed main(){
  int H,N; cin>>H>>N;
  int sum=0;
  rep(i,0,N){
    int X; cin>>X;
    sum+=X;
  }
  string ans="No";
  if(sum>=H) ans="Yes";
  cout<<ans<<endl;
  }


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i,n) for(int i=0;i<(n);i++)
#define ALL(v) (v).begin(),(v).end()
#define int long long
using namespace std;
typedef vector<int>   vint;
typedef pair<int,int> pint;

int table[26];

signed main()
{
    string s,t; cin>>s>>t;

    REP(i,26) table[i]=-1;
    
    REP(i,s.size()){
        int a=s[i]-'a';
        int b=t[i]-'a';
        if(table[a]==-1){
            table[a]=b;
        }
        else if(table[a]!=b){
            cout<<"No"<<endl;
            return 0;
        }
    }
    REP(i,26){
        if(count(table,table+26,i)>1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;

}


Measured memory_bytes: 776
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
#define rep(i,n) for(int i=0;i<(n);++i)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define all(x) (x).begin(), (x).end()
#define PI 3.14159265358979323846264338327950L
using namespace std;
typedef long long ll;
typedef long double ld;
int main() {
    int n,k;
    cin>>n>>k;
    vector<int> a(n);
    if(n==k){
        cout<<1;
        return 0;
    }
    int at;
    rep(i,n){
        cin>>a[i];
        if(a[i]==1) at=i+1;//左からi番目に最小値
    }
    if((n-1)%(k-1)==0) cout<<(n-1)/(k-1);
    else cout<<(n-1)/(k-1)+1;
}

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

using namespace std;
#define fordebug int hoge;cin>>hoge;
#define DEKAI 1000000007
#define INF (1<<28)
#define lp(i,n) for(int i=0;i<n;i++)
#define lps(i,j,n) for(int i=j;i<n;i++)
#define floot10 cout<<fixed<<setprecision(10);

//from ok 2018-12-02 must retry
//condate=18-12-5
struct Node{
	Node *parent, *left, *right;
	int key, priority;
};

Node *deleteN(Node*,int);

Node *root, *NIL;


Node *rightRotate(Node *t){
	Node *s = t->left;
	t->left = s->right;
	s->right = t;
	return s;
}

Node *leftRotate(Node *t){
	Node *s = t->right;
	t->right = s->left;
	s->left = t;
	return s;
}

Node *insert(Node *t,int key, int priority){
	if(t == NIL){//cout<<key<<" "<<priority<<endl;
		Node *temp;
		temp = new Node;
		temp->key = key;
		temp->priority = priority;
		temp->left = NIL;
		temp->right = NIL;
		return temp;
	}
	if(key == t->key){
		return t;
	}
	
	if(key < t->key){
		t->left = insert(t->left, key, priority);
		if(t->priority < t->left->priority)
			t = rightRotate(t);
	} else {
		t->right = insert(t->right, key, priority);
		if(t->priority < t->right->priority)
			t = leftRotate(t);
	}
	return t;
}

bool find(Node *t, int key){
	while(t != NIL && key != t->key){
		if(key < t->key) t = t->left;
		else t = t->right;
	}
	return t!=NIL;
}

void inorder(Node *t){
	if(t == NIL) return;
	cout<<" "<<t->key;
	inorder(t->left);
	inorder(t->right);
}

void preorder(Node *t){
	if(t == NIL)return;
	preorder(t->left);
	cout<<" "<<t->key;
	preorder(t->right);
}

void print(Node *t){
	preorder(t);
	cout<<endl;
	inorder(t);
	cout<<endl;
}

Node *_delete(Node *t, int key){
	if(t->left == NIL && t->right == NIL){
		if(t->parent != NIL){
			if(t->parent->left->key == key) t->parent->left = NIL;
			else t->parent->right = NIL;
		}
		//delete t;
		return NIL;
	}else if(t->left == NIL)
		t = leftRotate(t);
	else if(t->right == NIL)
		t = rightRotate(t);
	else {
		if(t->left->priority > t->right->priority)
			t = rightRotate(t);
		else
			t = leftRotate(t);
	}
	return deleteN(t,key);
}

Node *deleteN(Node *t, int key){
	if(t == NIL)
		return NIL;
	if(key < t->key)
		t->left = deleteN(t->left, key);
	else if(key > t->key)
		t->right = deleteN(t->right, key);
	else 
		return _delete(t,key);
	return t;
}

int main(){
	int n, k, p;
	string order;
	
	cin>>n;
	
	for(int i = 0; i < n; i++){
		cin>>order;
		
		if(order == "insert"){
			cin>>k>>p;
			root = insert(root,k,p);
		} else if(order == "find"){
			cin>>k;
			cout<<(find(root,k)?"yes":"no")<<endl;
		} else if(order == "delete"){
			cin>>k;
			root = deleteN(root,k);
		} else if(order == "print"){
			print(root);
		}
	}
	return 0;
}


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

int main(void)
{
    int n, a, z;    
    cin >> n;
    a = 100;
    z = 0;
    vector<int> xs;
    rep (i, n) {
        int x;
        cin >> x;
        xs.push_back(x);
        if (x > z) z = x;
        if (x < a) a = x;
    }
    int total = 0;
    int min_total = 10000 * n;
    for (int i=a;i<=z;i++) {
        total = 0;
        for (int x : xs) {
            total += abs(i-x) * abs(i-x);
        }
        if (total < min_total) min_total = total;
    }
    cout << min_total << endl;
}


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

int main(){
  int n;
  cin >> n;
  vector<int> a(n);
  vector<int> b(9);
  for(int i = 0; i < n; i++){
    cin >> a.at(i);
    if(a.at(i) < 400){
      b.at(0)++;
    }else if(a.at(i) >= 400 && a.at(i) < 800){
      b.at(1)++;
    }else if(a.at(i) >= 800 && a.at(i) < 1200){
      b.at(2)++;
    }else if(a.at(i) >= 1200 && a.at(i) < 1600){
      b.at(3)++;
    }else if(a.at(i) >= 1600 && a.at(i) < 2000){
      b.at(4)++;
    }else if(a.at(i) >= 2000 && a.at(i) < 2400){
      b.at(5)++;
    }else if(a.at(i) >= 2400 && a.at(i) < 2800){
      b.at(6)++;
    }else if(a.at(i) >= 2800 && a.at(i) < 3200){
      b.at(7)++;
    }else if(a.at(i) >= 3200){
      b.at(8)++;
    }
  }
  int c = 0;
  for(int i = 0; i < 8; i++){
    if(b.at(i) >= 1){
      c++;
    }
  }
  int comin, comax;
  if(b.at(8) == 0){
    comin = c;
    comax = c;
  }else if(b.at(8) >= 1){
    if(c == 0){
      comin = 1;
      comax = b.at(8);
    }else{
      comin = c;
      comax = c+b.at(8);
    }
  }
  cout << comin << " " << comax << endl;
}


Measured memory_bytes: 256
r,c = map(int,input().split())
table = list()
last_t = list()
for i in range(r):
    a = list(map(int,input().split()))
    table.append(a)

for i in range(r):
    table[i].append(sum(table[i]))

for i in range(c+1):
    b=0
    for j in range(r):
        b += table[j][i]
    else:
        last_t.append(b)
else:
    table.append(last_t)

for i in range(r+1):
    for j in range(c+1):
        if j >=1 and j<c:
            print(" "+str(table[i][j]),end="")
        elif j == c:
            print(" "+str(table[i][j]))
        else:
            print(table[i][j],end="")
                  


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

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

	vector<int> v( 101 );
	int x = 0;

	int a;
	while( cin >> a ) {
		v[a] += 1;

		if( v[a] > x ) {
			x = v[a];
		}
	}

	for( int i = 1; i < v.size(); ++i ) {
		if( v[i] == x ) {
			cout << i << '\n';
		}
	}
}



Measured memory_bytes: 3080
#include <iostream>
#include <climits>
#include <cstdio>
#include <cstdlib>
#include <stdio.h> 
#include <map>
#include <cmath>
#include <cstring>
#include <stack>
#include <queue>
#include <set>
#include <sstream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	int n,k;
	cin>>n>>k;
	vector<int> v;
	for (int i=0; i<n; i++) {
		int t;
		cin>>t;
		v.push_back(t);
	}
	
	sort(v.begin(), v.end());
	
	long long sum = 0;
	for (int i=0; i<n; i++) {
		if(i<n-k && n-k > 0) {
			sum+=v[i];		
		}
	}
	
	cout << sum;
	return 0;
}


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

vector<vector<int>> G;
vector<int> ans;
vector<int> visited;

void bfs() {
  queue<pair<int,int>> que;
  que.emplace(-1, 0);
  while(!que.empty()) {
    int from = que.front().first;
    int cur = que.front().second;
    que.pop();

    ans[cur] = from;

    for (auto to : G[cur]) {
      if(!visited[to]) {
        que.emplace(cur, to);
        visited[to] = 1;
      }
    }
  }
}

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

  int n,m;
  cin >> n >> m;

  visited.resize(n,0);
  G.resize(n);
  ans.resize(n, 0);
  for (int i = 0; i < m; i++) {
    int a,b;
    cin >> a >> b;
    a--, b--;

    G[a].push_back(b);
    G[b].push_back(a);
  }

  bfs();
  cout << "Yes" << '\n';
  for (int i = 1; i < n; i++) {
    cout << ans[i] + 1 << '\n';
  }

}

Measured memory_bytes: 14404
S = input().strip()

n = len(S)
ans = [0] * n
r = 0
for i in range(n):
    if S[i] == 'R':
        r += 1
    else:
        if r > 0:
            ans[i] = 1 + r // 2
            ans[i - 1] = 1 + (r - 1) // 2
            r = 0

l = 0
for i in reversed(range(n)):
    if S[i] == 'L':
        l += 1
    else:
        if l > 0:
            ans[i] = ans[i] + l // 2
            ans[i + 1] = ans[i + 1] + (l - 1) // 2
            l = 0

print(' '.join(map(str, ans)))


Measured memory_bytes: 10484
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp>
#define ll long long int
#define ld long double
#define pb push_back
#define pll pair<ll, ll> 
#define vl vector<ll> 
#define vvl vector< vector<ll> > 
#define vlp vector< pair<ll, ll> >
#define vllp vector<pair<pll, ll> > 
#define mll map<ll, ll> 
#define rep(i,a)  for(ll i=0; i< a; i++)
#define rep1(i,a)   for(ll i = 1; i< a; i++)
#define foi(i, a, b)    for(ll i = a; i<b ; i++)
#define fod(i, a, b)    for(ll i = a; i>=b ; i--)
#define mp make_pair
#define all(v)  (v).begin(), (v).end()
#define fst first
#define sec second
#define ff first.first
#define fs first.second
#define max3(a, b, c)   max(max(a, b), c)
#define min3(a, b, c)   min(min(a, b), c)
#define MAX 1000001
#define MOD 1000000007
// #define MOD 998244353
#define endl "\n"
#define INF (ll)1e18
#define s(v) (ll)v.size()
#define e(v) v.empty()
#define bscount(x) __builtin_popcountll(x)
// #define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

using namespace std;
// using namespace __gnu_pbds;

ll gcd(ll a, ll b){if(b==0)return a;return gcd(b, a%b);}
ll lcm(ll a, ll b){return a*b/gcd(a, b);}
ll fexp(ll a, ll b){ll ans = 1;while(b){if(b&1) ans = ans*a%MOD; b/=2;a=a*a%MOD;}return ans;}
ll inverse(ll a, ll p){return fexp(a, p-2);} 
void ingraph(vvl& graph, ll m){ll x, y;rep(i, m){cin>>x>>y;x--, y--;graph[x].pb(y);graph[y].pb(x);}}
ll modify(ll n){ll res = n;res%=MOD;res+=MOD;res%=MOD;return res;}

int main(){
    // #ifndef ONLINE_JUDGE
    //     freopen("../input.txt", "r", stdin);
    //     freopen("../output.txt", "w", stdout);
    // #endif
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    ll t;
    // cin>>t;
    t = 1;
    while(t--){
    	ll x;
    	rep(i, 5){
    		cin>>x;
    		if(x == 0)	cout<<i+1;
    	}
    }
}

Measured memory_bytes: 3644
from decimal import Decimal as D
import sys

def S(P,Q,R):
    #      R
    #
    #P
    #          Q

    PQ=[Q[0]-P[0],Q[1]-P[1]]
    PR=[R[0]-P[0],R[1]-P[1]]
    s=PQ[0]*PR[1]-PQ[1]*PR[0]
    return s

while True:
    try:
        x1,y1,x2,y2,x3,y3,xp,yp=[D(i) for i in input().split(" ")]
        A=[x1,y1]
        B=[x2,y2]
        C=[x3,y3]
        P=[xp,yp]

        if (S(A,B,P)>0 and S(B,C,P)>0 and S(C,A,P)>0) or (S(A,B,P)<0 and S(B,C,P)<0 and S(C,A,P)<0):
            print("YES")
        else:
            print("NO")
    except EOFError:
        sys.exit()
    

Measured memory_bytes: 10064
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdlib.h>
#include <algorithm>
#include <functional>

#define COUNTOF(array) (sizeof(array) / sizeof(array[0]))

using namespace std;

int main(void) {
	unsigned long int N, n, sum = 0;
	
	cin >> N;
	n = N;
	
	while(n / 10 > 0){
	    sum += n % 10;
	    n /= 10;
	}
	
	sum += n;
	
	if(N % sum == 0){
	    cout << "Yes" << endl;
	}else{
	    cout << "No" << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = (n + 0.5) / 1.08
b = n / 1.08
# print(a,b)
ans = -1
for i in range(int(b)-2,int(a)+2):
    if n <= i*1.08 < n+1:
        ans = i
        break
if ans == -1:
    print(":(")
else:
    print(ans)

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

int main(){
    int n,m;
    cin >> n >> m;
    vector<pair<int,int>> roads(n);
    for (int i = 0; i < n; i++){
        roads[i] = make_pair(i,0);
    }
    int a,b;
    for (int i = 0; i < m; i++){
        cin >> a >> b;
        a--;
        b--;
        roads[a].second++;
        roads[b].second++;
    }
    for (int i = 0; i<n; i++){
        cout << roads[i].second << endl;
    }

}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>

template <class T>
inline void read(T &x) {
    x = 0;
    int f = 0;
    char ch = getchar();
    while (!isdigit(ch))    { f |= ch == '-'; ch = getchar(); }
    while (isdigit(ch))     { x = (x << 1) + (x << 3) + (ch ^ 48); ch = getchar(); }
    x = f ? -x : x;
    return;
}

typedef long long LL;

const LL mod = 1e9 + 7;

LL n, k, ans, min, max;

int main() {
    read(n), read(k);
    for (; k <= n + 1; ++k) {
        min = k * (k - 1) / 2;
        max = (n - k + 1 + n) * k / 2;
        ans += (max - min) % mod;
        ++ans;
        ans %= mod;
    }
    printf("%lld\n", ans);
    return 0;
}

Measured memory_bytes: 3760
N = int(input())
T, A = map(int, input().split())
Hlist = list(map(int, input().split()))

answer_id = 10000
answer_height_diff = 10000

for i, hight in enumerate(Hlist, 1):
    tempareture = T - hight * 0.006
    if answer_height_diff > abs(A - tempareture):
        answer_height_diff = abs(A - tempareture)
        answer_id = i

print(answer_id)

Measured memory_bytes: 3188
#define SUBMIT

// https://beta.atcoder.jp/contests/abc105

#include <iostream>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cstring>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

int main() {
    int N, K;
    cin >> N >> K;

    if (N % K == 0) {
        cout << "0" << endl;
    } else {
        cout << "1" << endl;
    }

    return 0;
}

Measured memory_bytes: 764
x, k, d = map(int, input().split())
x = abs(x)
num = x // d
if num >= k:
    ans = x - k*d
else:
    if (k-num)%2 == 0:
        ans = x - num*d
    else:
        ans = min(abs(x - num*d - d), abs(x - num*d + d))

print(ans)

Measured memory_bytes: 61900
#include <iostream>
#include <string>
#include <vector>
#include <queue>
#include <deque>
#include <stack>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <cstring>
#include <cmath>
#include <cstdlib>
#include <algorithm>
#include <random>
#include <iomanip>
#include <cassert>
#include <complex>
#include <functional>
 
using namespace std;
 
typedef long long ll;

int main() {
  ios_base::sync_with_stdio(false); cin.tie(0);
#ifdef LOCAL
  freopen("input.txt", "r", stdin);
#endif
  int n;
  cin >> n;
  vector <int> a(n);
  for (int i = 0; i < n; ++i) {
    cin >> a[i];
    --a[i];
  }
  if (n == 2) {
    cout << "-1\n";
    return 0;
  }
  vector <int> hate(n);
  for (int i = 0; i < n; ++i) ++hate[a[i]];
  set <int> have;
  for (int i = 0; i < n; ++i) have.insert(i);
  vector <int> ans;
  vector <bool> used(n);
  int who = -1;
  for (int i = 0; i < n; ++i) {
    for (int j : have) {
      if (j == who) continue;
      int x = a[j];
      if (!used[x] && hate[x] == n - i - 1) {
        continue;
      }
      ans.push_back(j);
      used[j] = 1;
      --hate[x];
      who = x;
      break;
    }
    have.erase(ans.back());
    if (n - i - 1 <= 6) break;
  }
  vector <int> cur;
  for (int j : have) cur.push_back(j);
  vector <int> best;
  do {
    if (cur.front() == who) continue;
    bool bad = false;
    for (int i = 0; i + 1 < (int)cur.size(); ++i) {
      if (cur[i + 1] == a[cur[i]]) {
        bad = true;
        break;
      }
    }
    if (!bad) {
      if (best.empty() || cur < best) best = cur;
    }
  } while (next_permutation(cur.begin(), cur.end()));

  for (int x : ans) {
    cout << x + 1 << ' ';
  }
  for (int x : best) {
    cout << x + 1 << ' ';
  }
}


Measured memory_bytes: 6272
#include <bits/stdc++.h>
#define FOR(i,a,b) for (int i = (a); i < (b); ++i)
#define RFOR(i,a,b) for (int i = (b)-1; i >= (a); --i)
#define REP(i,n) FOR(i,0,(n))
#define REPS(i,n) FOR(i,1,(n)+1)
#define RREP(i,n) RFOR(i,0,(n))
#define ALL(x) (x).begin(),(x).end()
#define RALL(x) (x).rbegin(),(x).rend()
#define DEBUG(x)  cout << #x << " = " << (x) << endl;
#define SORT(x) sort(ALL(x));
#define RSORT(x) sort(RALL(x));
#define SUM(x) accumulate(ALL(x),0);
#define FI first
#define SE second
#define PB push_back
#define EB emplace_back
#define SZ(x) (int)(x).size()
#define BN(x) ((1<<x)-1)
#define DUP(x,y) (((x)+(y)-1)/(y))
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using pii = pair<int, int>;
using tiii = tuple<int, int, int>;
const ll mod = 1e9+7;
const int INF = (1<<30)-1;
const ll INFLL = (1LL<<62)-1;
const int dx[4] = {1,0,-1,0};
const int dy[4] = {0,1,0,-1};
//cout << fixed << setprecision(10);

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

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

vi to[200005];
vi ans;

void dfs(int v, int p = -1) {
  for (int u : to[v]) {
    if (u == p) continue;
    ans[u] += ans[v];
    dfs(u,v);
  }
  return;
}

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

  int N, Q; cin >> N >> Q;
  REP(i,N-1) {
    int a, b; cin >> a >> b;
    --a; --b;
    to[a].PB(b);
    to[b].PB(a);
  }

  ans.resize(N);
  REP(i,Q) {
    int p, x; cin >> p >> x;
    --p;
    ans[p] += x;
  }

  dfs(0);
  REP(i,N) {
    cout << ans[i] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 23808
#include<stdio.h>
#include<string.h>
#include<queue>
using namespace std;
#define MAXN 363000  //9!==326880
struct node
{
    int s[9];
    int a;
    int b;
    int step;
};
int fac[10]= {1,1,2,6,24,120,720,5040,40320,362880};//分别存储1--9的阶乘值
int dir[4][2]= {-1,0,1,0,0,-1,0,1};
int aim=322561;//123456780对应的hash值
bool vis[MAXN];
node str,now,next;
int cantor(const int *s)
{
    int sum=0;
    for(int i=0; i<9; i++)
    {
        int num=0;
        for(int j=0; j<i; j++)
            if(s[j]>s[i])
                num++;
        sum+=(num*fac[i]);
    }
    return (sum+1);
}
bool bfs()
{
    memset(vis,0,sizeof(vis));
    queue<node>q;
    q.push(str);
    vis[str.b]=1;
    while(!q.empty())
    {
        now=q.front();
        q.pop();
        int x=now.a/3;
        int y=now.a%3;
        for(int i=0; i<4; i++)
        {
            int tx=x+dir[i][0],ty=y+dir[i][1];
            if(tx<0||tx>=3||ty<0||ty>=3)
                continue;
            next=now;
            next.a=tx*3+ty;
            next.s[now.a]=next.s[next.a];
            next.s[next.a]=0;
            next.b=cantor(next.s);
            if(!vis[next.b])
            {
                vis[next.b]=1;
                if(next.b==aim)
                {
                    return true;
                }
                next.step=now.step+1;
                q.push(next);
            }
        }
    }
    return 0;
}
char sss[3];
int main()
{
    char q[10];
    for(int i=0; i<9; i++)
    {
        scanf("%s",sss);
        q[i]=sss[0];
    }
    int len=strlen(q);
    int num=0;
    for(int i=0; i<len; i++)
    {
        if(q[i]>='1'&&q[i]<='9')
        {
            str.s[num++]=q[i]-'0';
        }
        else if(q[i]=='0')
        {
            str.s[num]=0;
            str.a=num++;
        }
    }
    str.b=cantor(str.s);
    if(str.b==aim)
        printf("%d\n",0);
    else if(bfs())
        printf("%d\n",next.step+1);
    return 0;
}



Measured memory_bytes: 4084
#include <stdio.h>

char gd_sosuu_list[300000];

void make_gd_sosuu_list(void) {
	int i,j,next;
	for(i=6,next=5;i<300000;i+=next) {
		gd_sosuu_list[i]=1;
		next=(next==5)?2:5;
	}
	for(i=6;i<300000;i++) {
		if(gd_sosuu_list[i]) {
			for(j=i+i;j<300000;j+=i)gd_sosuu_list[j]=0;
		}
	}
}

int main(void) {
	int input;
	int i;
	make_gd_sosuu_list();
	while(1) {
		scanf("%d",&input);
		if(input==1)break;
		printf("%d:",input);
		for(i=6;i<=input;i++) {
			if(input%i==0 && gd_sosuu_list[i])printf(" %d",i);
		}
		putchar('\n');
	}
	return 0;
}

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

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

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

int main(){
  int N;
  cin >> N;
  
  vector<int> A(100002, 0);
  for (int i = 0; i < N; i++){
    int a;
    cin >> a;
    
    A.at(a)++;
    A.at(a + 1)++;
    A.at(a + 2)++;
  }
  
  int ans = 0;
  for (int i = 0; i < 100002; i++){
    ans = max(ans, A.at(i));
  }
  
  cout << ans << endl;
}

Measured memory_bytes: 3756
#include<bits/stdc++.h>
#define range(i,a,b) for(int i = (a); i < (b); i++)
#define rep(i,b) for(int i = 0; i < (b); i++)
#define all(a) (a).begin(), (a).end()
#define show(x)  cerr << #x << " = " << (x) << endl;
#define int long long
using namespace std;

template <typename X, typename T>
auto vectors(X x, T a) {
	return vector<T>(x, a);
}

template <typename X, typename Y, typename Z, typename... Zs>
auto vectors(X x, Y y, Z z, Zs... zs) {
	auto cont = vectors(y, z, zs...);
	return vector<decltype(cont)>(x, cont);
}

template<typename T>
ostream& operator << (ostream& os, vector<T>& v){
	rep(i,v.size()){ os << v[i] << (i == v.size() - 1 ? "" : " "); } return os;
}
template<typename T>
istream& operator >> (istream& is, vector<T>& v){
	for(T& x: v){ is >> x; } return is;
}

signed main(){
	int n, k;
	cin >> n >> k;

	int ans = 0;
	rep(i,n){
		int a;
		cin >> a;
		ans += a >= k;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
l = list(map(int, input().split()))

if n%2 == 0:
  l_ = [0]*(n//2)
  for i in range(n):
    l_[(n-(l[i])-1)//2] += 1
  for j in range(len(l_)):
    if l_[j] != 2:
      print(0)
      exit()
  else:
    print((2**(n//2))%(10**9+7))

else:
  l_ = [0]*(n//2+1)
  for i in range(n):
    l_[(n-(l[i])-1)//2] += 1
  for j in range(len(l_)):
    if j != len(l_)-1: 
      if l_[j] != 2:
        print(0)
        exit()
    else:
      if l_[j] != 1:
        print(0)
        exit()
  else:
    print((2**(n//2))%(10**9+7))


Measured memory_bytes: 52588
S = input()
T = input()

dic = {}
dic_rev = {}


def solve():
    for s, t in zip(S, T):
        if t in dic.keys():
            if s != dic[t]:
                print('No')
                return
        else:
            dic[t] = s
    for s, t in zip(S, T):
        if s in dic_rev.keys():
            if t != dic_rev[s]:
                print('No')
                return
        else:
            dic_rev[s] = t
    print('Yes')
    return


solve()

Measured memory_bytes: 3632
N=int(input())
T,A=map(int,input().split())
H=list(map(int,input().split()))
z=10**3
ans=1001
for i in range(N):
    if abs(A-(T-H[i]*0.006))<z:
        z=abs(A-(T-H[i]*0.006))
        ans=i+1
print(ans)

Measured memory_bytes: 3064
#include <cstdio>
using namespace std;
const int maxn = 1e5+5;
int d[maxn];
int n;
int main(){
//freopen("input.txt", "r", stdin);
    while(scanf("%d", &n) == 1){
        for(int i = 0; i < n; i++)
            scanf("%d", &d[i]);
        bool fg1;
        if(n == 1)
        {
            printf("1\n");
            continue;
        }
//        fg1 = d[1] - d[0] ? true : false;
        int ans = 0;
        int len = 1;
        
        for(int i = 1; i < n; i++)
        {
            if(len == 1) 
            {
                int t  = d[i] - d[i-1];
                if(t == 0) continue;
                else fg1 = (t > 0) ? true: false;
            }
            if(fg1 == true) 
            {
                if(d[i] >= d[i-1]) {len++; continue;}
                else{
                    fg1 = false;
                    if(len > 1){ans++; len = 1;}
                }
            }
            else{
                if(d[i] <= d[i-1]) {len++;continue;}
                else{
                    fg1 = true;
                    if(len > 1){ans++; len = 1;}
                }
            }
        }
        printf("%d\n", ans+1);
    }
    return 0;
}

Measured memory_bytes: 512
#!/usr/bin/env python3
# -*- coding: utf-8 -*-

"""042-b"""


from queue import PriorityQueue
import sys


def main():
    """Main function."""
    pq = PriorityQueue()
    N, L = map(int, sys.stdin.readline().split(' '))

    for l in range(N):
        pq.put(sys.stdin.readline()[:-1])

    while True:
        sys.stdout.write(pq.get())
        if pq.empty():
            break
    sys.stdout.write('\n')


if __name__ == '__main__':
    sys.exit(main())

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

#define PI 3.1415926535898
#define AG (PI/180.0)

int main() {
	int rad, adv;
	double x=0.0, y=0.0,dir=0.0;
	while (scanf("%d%*c%d",&adv,&rad)&&(adv!=0.0||rad!=0.0)) {
		x += (double)adv*sin(dir*AG);
		y += (double)adv*cos(dir*AG);
		dir += (double)rad;
	}
	printf("%d\n%d\n",(int)x,(int)y);
}

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

namespace ConsoleApplication1
{
    class Program
    {
        static void Main(string[] args)
        {
            StringBuilder sb = new StringBuilder();

            string input;

            bool isStart = true;

            while (!string.IsNullOrEmpty(input = Console.ReadLine()))
            {
                if (!isStart) sb.Append("\n");
                else isStart = false;

                int n = input.Length;

                int[] memo = new int[5];

                for (int i = n - 1, j = 4; i >= 0; i--, j--)
                {
                    memo[j] = int.Parse(input[i].ToString());
                }

                char[,] map = new char[8, 5];

                for (int i = 0; i < 2; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        map[i, j] = '*';
                    }
                }

                for (int i = 0; i < 5; i++) map[2, i] = '=';

                for (int i = 3; i < 8; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        map[i, j] = '*';
                    }
                }

                for (int i = 0; i < 5; i++)
                {
                    if (memo[i] >= 5)
                    {
                        map[0, i] = ' ';
                        memo[i] -= 5;
                    }
                    else
                    {
                        map[1, i] = ' ';
                    }

                    map[memo[i] + 3, i] = ' ';
                }

                for (int i = 0; i < 8; i++)
                {
                    for (int j = 0; j < 5; j++)
                    {
                        sb.Append(map[i, j]);
                    }
                    sb.Append("\n");
                }
            }
            Console.Write(sb);
        }
    }
}

Measured memory_bytes: 9180
#include<bits/stdc++.h>
#define int long long
#define for1(i, n) for(int i = 1; i <= (n);i++)
#define puts(x) cout << x << "\n"
constexpr int mod = 1000000007;
using namespace std;
int d, c[30], l[30], s[400][30];
signed main() {
	cin >> d;
	for1(i, 26)cin >> c[i];
	for1(i, d)for1(j, 26)cin >> s[i][j];
	for1(i, d) {
		int p = 0, k = -mod;
		for1(j, 26) {
			int kj = s[i][j] + c[j] * (i - l[j]) * 2.00 + c[j] * 12;
			if (kj > k) { p = j; k = kj; }
			else if (kj == k && c[j] > c[p])p = j;
		}
		puts(p); l[p] = i;
	}
}

Measured memory_bytes: 3720
#include <bits/stdc++.h>
#include <cmath>
using namespace std;
int main()
{
    int n, m;
    cin >> n >> m;
    int a[n], b[n], c[m], d[m];
    for (int i = 0; i < n; i++)
    {
        cin >> a[i] >> b[i];
    }
    for (int i = 0; i < m; i++)
    {
        cin >> c[i] >> d[i];
    }

    for (int i = 0; i < n; i++)
    {
        int min_dist = INT_MAX;
        int min_indx = 0;
        for (int j = 0; j < m; j++)
        {
            int dist = abs(a[i] - c[j]) + abs(b[i] - d[j]);
            if (dist < min_dist)
            {
                min_indx = j;
                min_dist = dist;
            }
        }
        min_indx++;
        cout << min_indx << endl;
    }
    return 0;
}

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

#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
#define LL long long
#define pii pair <int,int>
#define fi first
#define se second
#define pb push_back
#define mpr make_pair

using namespace std;

const LL MOD=1e9+7;

LL n,pwm1[200020],pw[200020],pwp1[200020],num=0,resm1=0,res=0,resp1=0;
string s;

int get(LL x)
{
	int ret=0,y;
	while(x>0)
	{
		y=__builtin_popcount(x);
		x%=y;
		ret++;
	}
	return ret;
}

int main()
{
	cin>>n>>s;
	rep(i,n) num+=s[i]-'0';
	pwm1[0]=pw[0]=pwp1[0]=1;
	repn(i,200010)
	{
		if(num-1>0) pwm1[i]=pwm1[i-1]*2%(num-1);
		if(num>0) pw[i]=pw[i-1]*2%num;
		pwp1[i]=pwp1[i-1]*2%(num+1);
	}
	rep(i,n)
	{
		if(num-1>0) resm1=(resm1+(s[i]=='1')*pwm1[n-i-1])%(num-1);
		if(num>0) res=(res+(s[i]=='1')*pw[n-i-1])%num;
		resp1=(resp1+(s[i]=='1')*pwp1[n-i-1])%(num+1);
	}
	rep(i,n)
	{
		if(s[i]=='0')
		{
			LL tmp=(resp1+pwp1[n-i-1])%(num+1);
			printf("%d\n",get(tmp)+1);
		}
		else
		{
			if(num==1)
			{
				puts("0");
				continue;
			}
			LL tmp=(resm1-pwm1[n-i-1]+num-1+num-1)%(num-1);
			printf("%d\n",get(tmp)+1);
		}
	}
	return 0;
}

Measured memory_bytes: 8536
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
int main() {
  int a,b;
  cin>>a>>b;
  if(a==b){
	cout<<"Draw"<<endl;
  }
  if(a>b){
  	if (b==1){
      cout<<"Bob"<<endl;
    }else{
      cout<<"Alice"<<endl;
    }
  }
  if(a<b){
    if(a==1){
      cout<<"Alice"<<endl;
    }else{
      cout<<"Bob"<<endl;
    }
  }
}
  





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

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

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

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

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

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

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

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

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

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())

n,q=map(int,input().split())
uf=UnionFind(n)
for i in range(q):
  A=list(map(int,input().split()))
  if A[0]==0:
    uf.union(A[1],A[2])
  else:
    if uf.same(A[1],A[2]):
      print(1)
    else:
      print(0)

Measured memory_bytes: 11572
#include<iostream>
#include<algorithm>
#include<cstdio>
#include<cstring>
#include<vector>
using namespace std;
int n,m;
int A[100010],B[100010];
long long dp[100010],S[100010];
bool cmp(int x,int y)
{
	return S[x]-dp[x]<S[y]-dp[y];
}
vector<int>e[100010],son[100010];
int id[100010];
bool cmp2(int x,int y)
{
	return A[x]<A[y];
}
bool book[100010];
int fa[100010];
int find(int x)
{
	return fa[x]==x?x:fa[x]=find(fa[x]);
}
int work()
{
	for(int i=1;i<=n;i++)
		id[i]=i;
	sort(id+1,id+n+1,cmp2);
	for(int j=1;j<=n;j++)
	{
		int u=id[j];
		book[u]=true;
		fa[u]=u;
		for(int i=0;i<e[u].size();i++)
		{
			int v=e[u][i];
			if(book[v])
			{
				int f=find(v);
				if(f!=u)
				{
					fa[f]=u;
					son[u].push_back(f);
				}
			}
		}
	}
	return id[n];
}
long long res1[100010],res2[100010];
void solve(int u)
{
	S[u]=B[u];
	if(!son[u].size()){
		dp[u]=A[u]+B[u];
		return ;
	}
	for(int i=0;i<son[u].size();i++)
	{
		solve(son[u][i]);
		S[u]+=S[son[u][i]];
	}
	sort(son[u].begin(),son[u].end(),cmp);
	long long nsum=0;
	for(int i=0;i<son[u].size();i++)
	{
		int v=son[u][i];
		res1[i]=max(nsum+dp[v],i>0?res1[i-1]:0);
		nsum+=S[v];
	}
	res2[son[u].size()]=0;
	for(int i=son[u].size()-1;i>=0;i--)
	{
		int v=son[u][i];
		res2[i]=max(dp[v],res2[i+1]+S[v]);
	}
	dp[u]=1e18;nsum=0;
	for(int i=0;i<son[u].size();i++)
	{
		int v=son[u][i];
		long long val=0;
		if(i>0)val=max(val,res1[i-1]);
		val=max(val,nsum+res2[i+2]);
		val=max(val,A[u]+S[u]-S[v]);
		val=max(val,S[u]-S[v]+dp[v]);
		dp[u]=min(dp[u],val);
	}
	return ;
}
int main()
{
	scanf("%d %d",&n,&m);
	for(int i=1;i<=n;i++)
	{
		scanf("%d %d",&A[i],&B[i]);
		A[i]=max(A[i]-B[i],0);
	}
	for(int i=1;i<=m;i++)
	{
		int u,v;
		scanf("%d %d",&u,&v);
		e[u].push_back(v);
		e[v].push_back(u);
	}
	int rt=work();
	solve(rt);
	printf("%lld\n",dp[rt]);
	return 0;
}

Measured memory_bytes: 18172
from collections import defaultdict


def solve():
    s = input()
    t = input()
    ds = defaultdict(int)
    for c in s:
        ds[c] += 1
    nums_s = sorted(ds.values())
    dt = defaultdict(int)
    for c in t:
        dt[c] += 1
    nums_t = sorted(dt.values())
    return "Yes" if nums_s == nums_t else "No"


if __name__ == "__main__":
    print(solve())


Measured memory_bytes: 4016
// doot diddly donger cuckerino Hahahahahah


#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")

#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace __gnu_pbds;
using namespace __gnu_cxx;
using namespace std;

using ll = long long;
using ld = long double;
using pll = pair<ll, ll>;
using vi = vector<int>;

template <typename T> using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

const ld PI = acos(-1);

template <typename T> inline T mini(T& x, T y) { return x = min(x, y); }
template <typename T> inline T maxi(T& x, T y) { return x = max(x, y); }
mt19937 rnd(chrono::high_resolution_clock::now().time_since_epoch().count());

class BGoToJail {
public:
  
  void solve(std::istream& cin, std::ostream& cout) {
    int n;
    cin >> n;
    bool ok = false;
    int cnt = 0;
    for (int i = 0; i < n; ++i) {
      int x, y;
      cin >> x >> y;
      if (x == y) {
        cnt++;
      } else {
        cnt = 0;
      }
      if (cnt == 3) ok = true;
    }
    cout << (ok ? "Yes" : "No") << endl;
  }
};

int32_t main() {
    std::ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    std::cout.tie(nullptr);
	BGoToJail solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3652
#include <stdio.h>

int n,time,v[100][100],a[100],d[100],f[100]; 

void visit(int);

void dfs()
{
  int u;
  for(u=0;u<n;u++)
    {
      a[u]=0;
      time=0;
    }
  for(u=0;u<n;u++)
    {
      if(a[u]==0){visit(u);}
    }
  for(u=0;u<n;u++)
    {
      printf("%d %d %d\n",u+1,d[u],f[u]);
    }
}

void visit(int u)
{
  int b;
  a[u]=1;
  d[u]=++time;
  for(b=0;b<n;b++)
    {
      if(v[u][b]==0)continue;
      if(a[b]==0){visit(b);}
    }
  a[u]=2;
  f[u]=++time;

}


int main()
{
  int i,j,u,k,a;

  scanf("%d",&n);

  for(i=0;i<n;i++)
    {
       for(j=0;j<n;j++)
	 {
	   v[i][j]=0;
	 }
    }
  
  for(i=0;i<n;i++)
  {
    scanf("%d %d",&u,&k);
    u--;
    for(j=0;j<k;j++)
      {
        scanf("%d",&a);
	a--;
	v[u][a]=1;
      }
  }

  dfs();

  return 0;
}
  



Measured memory_bytes: 2128
#include <iostream>
#include<algorithm>
#include<math.h>
#include<string>
#include<cstdlib>
#include<cmath>

using namespace std;
int main(){
    int n,t;
    cin>>n>>t;
    int ans=0;
    int st;
    int time;
    cin>>st;
    for(int i=0; i<n-1; i++){
        cin>>time;
        if(time-st<t){
            ans+=time-st;
            st=time;
        }
        else{
            ans+=t;
            st=time;
        }
    }
    cout<<ans+t<<endl;
    return 0;
}


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

using namespace std;
int main(){
    long long N, K;
    vector<long long> vec;

    cin >> N>> K;
    int x;
    vec.push_back(0);

    for (long long n = 0; n < N; n++)
    {
        cin >> x;
        vec.push_back(vec.back() + x);
    }

    for (long long i = K; i < N; i++)
    {
        if (vec.at(i) - vec.at(i - K) < vec.at(i + 1) - vec.at(i + 1 - K))
        {
            cout << "Yes"
                 << "\n";
        }
        else
        {
            cout << "No"
                 << "\n";
        }
    }

}


Measured memory_bytes: 5360
// Sky's the limit :)
#include <bits/stdc++.h>
using namespace std;
#define int long long

signed main() {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    
    int T = 1; 
    // cin >> T; 
    while (T--) {
        int a, b, c;
        cin >> a >> b >> c;

        cout << c << ' ' << a << ' ' << b << '\n';
    }
    
    return 0;
}



Measured memory_bytes: 3656