akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

int main (){
    int n;
    cin>>n;
    bool flag = false;
    while(n){
        int num = n%10;
        n = n/10;
        if(num == 7){
            flag=true;
            break;
        }
    }

    if(flag){
        cout<<"Yes"<<endl;
    }
    else{
        cout<<"No"<<endl;
    }
}


Measured memory_bytes: 3568
#!/usr/bin/env python3
# CGL_3_B: Polygon - Is-Convex


def run():
    n = int(input())
    ps = []

    for _ in range(n):
        x, y = [int(i) for i in input().split()]
        ps.append((x, y))

    if convex(ps):
        print(1)
    else:
        print(0)


def dot(v1, v2):
    x1, y1 = v1
    x2, y2 = v2
    return x1 * x2 + y1 * y2


def orthogonal(v):
    x, y = v
    return -y, x


def convex(ps0):
    p0, *ps1 = ps0
    ps1.append(p0)
    p1, *ps2 = ps1
    ps2.append(p1)
    ret = []
    for pa, pb, pc in zip(ps0, ps1, ps2):
        xa, ya = pa
        xb, yb = pb
        xc, yc = pc
        v1 = (xb - xa, yb - ya)
        v2 = (xc - xb, yc - yb)
        ret.append(dot(orthogonal(v1), v2))

    return all([d >= 0 for d in ret]) or all([d <= 0 for d in ret])


if __name__ == '__main__':
    run()



Measured memory_bytes: 5616
#include <bits/stdc++.h>
using namespace std;
struct Fast {Fast(){std::cin.tie(0);ios::sync_with_stdio(false);cout.precision(20);}} fast;

/* define */
#define FOR(I,X,Y) for(long long (I)=(X);(I)<(Y);(I)++)
#define REP(I,X,Y) for(long long (I)=(Y)-1;(I)>=(X);(I)--)
#define ALL(X) (X).begin(),(X).end()
#define pb push_back
#define COUNT(V,X) (upper_bound((V).begin(),(V).end(),X)-lower_bound((V).begin(),(V).end(),X))
#define debug(x) cerr<<#x<<':'<<x<<endl;
#define DEBUG(v) cerr<<#v<<':';for(auto xXx:v)cerr<<xXx<<' ';cerr<<endl;
#define Yes(X) if(X){cout<<"Yes"<<endl;}else{cout<<"No"<<endl;}
#define YES(X) if(X){cout<<"YES"<<endl;}else{cout<<"NO"<<endl;}
#define ctoi(C) (C-'0')
#define pow2(x) ((long long)((long long)1<<x))

/* alias */
using ll = long long;
using ld = long double;
using vi = vector<int>;
using vii = vector<vector<int>>;
using vl = vector<long long>;
using vll = vector<vector<long long>>;
using pi = pair<int,int>;
using pl = pair<long long,long long>;
template<typename T> using PQ = priority_queue<T>;
template<typename T> using minPQ = priority_queue<T, vector<T>, greater<T>>;

/* const */
const long long dx[] = {1,0,-1,0};
const long long dy[] = {0,1,0,-1};
const long long dx8[] = {1,1,0,-1,-1,-1,0,1};
const long long dy8[] = {0,1,1,1,0,-1,-1,-1};
const long long dx9[] = {1,1,0,-1,-1,-1,0,1,0};
const long long dy9[] = {0,1,1,1,0,-1,-1,-1,0};
const int INF = 1000000007;
const long long LINF = 1000000000000000007;

/* func */
template <typename T> inline bool chmin(T& a, const T& b) {if (a > b) a = b; return a > b;}
template <typename T> inline bool chmax(T& a, const T& b) {if (a < b) a = b; return a < b;}
long long max(long long x,int y){return max(x,(long long)y);}
long long max(int x,long long y){return max((long long)x,y);}
long long min(long long x,int y){return min(x,(long long)y);}
long long min(int x,long long y){return min((long long)x,y);}

/* liblary */



/* main */

signed main(){
    string s;
    cin >> s;
    int ans = 0;
    FOR(i,0,s.size()){
        ans += s[i] == '1';
    }
    cout << ans << endl;
}


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

int main() {
    ll N,T;
    cin >> N >>T;
    ll ans =0;
    ll last =0;
    for(int i=0;i<N;i++){
        ll t;
        cin >>t;
        if(t-last >T){
            ans +=T;
        }else{
            ans +=(t-last);
        }
        last = t;
    }
    ans +=T;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
S = input()
A = int(S[:2])
B = int(S[2:])
flagAM = False
flagBM = False
if 1 <= A <= 12:
    flagAM = True

if 1 <= B <= 12:
    flagBM = True

if flagAM and flagBM:
    print('AMBIGUOUS')
elif flagAM:
    print('MMYY')
elif flagBM:
    print('YYMM')
else:
    print('NA')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define PI 3.14159265358979323846
#define MAXINF (1e18L)
#define INF (1e9L)
#define EPS (1e-9)
#define MOD ((ll)(1e9+7))
#define REP(i, n) for(int i=0;i<int(n);++i)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define ALL(v) v.begin(),v.end()
#define FIND(v,x) (binary_search(ALL(v),(x)))
#define SORT(v) sort(ALL(v))
#define RSORT(v) sort(ALL(v));reverse(ALL(v))
#define DEBUG(x) cerr<<#x<<": "<<x<<endl;
#define DEBUG_VEC(v) cerr<<#v<<":";for(int i=0;i<v.size();i++) cerr<<" "<<v[i]; cerr<<endl
#define Yes(n) cout<<((n)?"Yes":"No")<<endl
#define YES(n) cout<<((n)?"YES":"NO")<<endl
#define pb push_back
#define fi first
#define se second
using namespace std;
template<class A>void pr(A a){cout << (a) << endl;}
template<class A,class B>void pr(A a,B b){cout << a << " "  ;pr(b);}
template<class A,class B,class C>void pr(A a,B b,C c){cout << a << " " ;pr(b,c);}
template<class A,class B,class C,class D>void pr(A a,B b,C c,D d){cout << a << " " ;pr(b,c,d);}
template<class T> inline bool chmin(T& a, T b){return a>b ? a=b, true : false;}
template<class T> inline bool chmax(T& a, T b){return a<b ? a=b, true : false;}
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll,ll> pll;

int main(void)
{
    ll t1,t2;
    cin >> t1 >> t2;
    ll a1,a2,b1,b2;
    cin >> a1 >> a2 >> b1 >> b2;
    
    a1 *= t1;
    b1 *= t1;
    a2 *= t2;
    b2 *= t2;

    t1 = a1-b1;
    t2 = a2-b2;

    if(t1 > 0){
        t1 = -t1;
        t2 = -t2;
    }

    ll ans = 0;
    if(t1+t2 < 0) pr(0);
    else if(t1+t2 == 0)pr("infinity");
    else{
        ll k = -t1 / (t1+t2);
        if(t1+(k*(t1+t2)) < 0) ans++;
        pr(k*2+ans);
    }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
 
using ll = long long;
using pll = pair<ll, ll>;
#define all(x) (x).begin(), (x).end()
#define call(x) (x).cbegin(), (x).cend()
#define rall(x) (x).rbegin(), (x).rend()
#define pb push_back
#define sz(x) ((x).size())
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define rep(i, a, b) for(ll i = ll(a); i < ll(b); i++)
const double PI = acos(-1);
const int mod = 1e9+7;
const long long INF = (1LL << 60);
const int dx[] = {0,1,0,-1,1,1,-1,-1};
const int dy[] = {1,0,-1,0,1,-1,-1,1};
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;}
ll stringcount(string s, char c){return count(s.cbegin(), s.cend(), c);}
bool isInteger(double x){return floor(x) == x;}
ll ceil(ll a, ll b){return ((a)+(b)-1)/b;}
template<class T> inline bool chmax(T &a, const T &b){ if(a < b){ a=b; return 1; } return 0; }
template<class T> inline bool chmin(T &a, const T &b){ if(a > b){ a=b; return 1; } return 0; }

// 遠隔授業疲れた
// 
// 眠い

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

  ll n;
  cin >> n;
  ll b = 0, c = 0, d = 0;
  rep(i, 0, n){
    ll a;
    cin >> a;
    ll cnt = 0;
    while(a % 2 == 0){
      a /= 2;
      cnt++;
    }
    if(cnt == 0) b++;
    if(cnt == 1) c++;
    if(cnt >= 2) d++;
  }

  if((d+1 >= b && c == 0)|| d >= b) cout << "Yes" << endl;
  else cout << "No" << endl;


  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(void){
    int H,W,i,j;
    while(1){
    cin >> H >> W;
    if (H==0 && W==0){
        break;
    }
    for(i=0;i<H;i++){
        for (j=0;j<W;j++){
            if ((i+j)%2 ==0){
                cout << '#' ;
            }else{
                cout << '.' ;
            }
        }
        cout << endl;
    }
    cout << endl;
    }
}


Measured memory_bytes: 3060
#include<iostream>
#include<functional>
#include<utility>
#include<cmath>
#include<iomanip>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
using namespace std;

int n, m;
string s;


int main() {
	cin >> n >> m;
	if (n >= 13)
	{
		cout << m << endl;return 0;
	}
	if (n>=6)
	{
		cout << m / 2 << endl;return 0;
	
	}
	cout << 0 << endl;
}

Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main(){
  string str;
  bool possible=true;
  cin >> str;
  int i=0;
  while(i<str.size()){
    if(str.substr(i,11)=="dreameraser"){
      i+=11;
    }else if(str.substr(i,10)=="dreamerase"){
      i+=10;
    }else if(str.substr(i,7)=="dreamer"){
      i+=7;
    }else if(str.substr(i,6)=="eraser"){
      i+=6;
    }else if(str.substr(i,5)=="dream"){
      i+=5;
    }else if(str.substr(i,5)=="erase"){
      i+=5;
    }else{
      possible=false;
      break;
    }
  }
  if(possible) cout << "YES\n";
  else cout << "NO\n";
}

Measured memory_bytes: 512
from bisect import bisect_left
I = lambda x: [-1<<50] + [int(input()) for i in range(x)] + [1<<50]

A,B,Q = map(int,input().split())
S,T = I(A),I(B)

for _ in range(Q):
    x = int(input())
    BLS = bisect_left(S,x)  
    BLT = bisect_left(T,x) 

    LS = x - S[BLS-1]
    RS = S[BLS] - x
    LT = x - T[BLT-1]
    RT = T[BLT] - x
    
    print(min(max(LS,LT),max(RS,RT),LS*2+RT,LT*2+RS,RT*2+LS,RS*2+LT))

Measured memory_bytes: 14104
s=input()
K=int(input())

if K==1:
  print(sorted(s)[0])
  exit()
  
topK = sorted(s)[:min(K,len(s))]

indices=[]
for i in range(len(s)):
  if s[i] in topK:indices.append(i)
    
selected=[]
for j in range(len(indices)):
  i = indices[j]
  tmp=[]
  for k in range(min(K,len(s)-i)):
    tmp.append(s[i:i+k+1])
  selected.extend(tmp)
  
selected = sorted(set(selected))

print(selected[K-1])

Measured memory_bytes: 10612
#!/usr/bin/env python3
import numpy as np
stdin = open(0)

A = np.fromstring(stdin.read(), np.int64, sep=' ')[1:]
A = A[A % 2 == 0]
if np.all((A % 3 == 0) | (A % 5 == 0)):
    print('APPROVED')
else:
    print('DENIED')


Measured memory_bytes: 21388
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define pb push_back
#define mp make_pair
#define speed ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int main(){
    int n, k;
    cin >> n >> k;
    string s;
    cin >> s;
    for(int i = 0; i < n; i++){
        if(i+1 != k) cout << s[i];
        else cout << char(s[i]+32);
    }
}

Measured memory_bytes: 256
from itertools import*
from math import*
from collections import*
from heapq import*
from bisect import bisect_left,bisect_right
from copy import deepcopy
inf = float("inf")
mod = 10**9+7
from functools import reduce
import sys
sys.setrecursionlimit(10**7)

N,M = map(int,input().split())
G = [[] for _ in range(3*N)]
for i in range(M):
    u,v = map(int,input().split())
    u -=1
    v -=1
    G[u].append(v+N)
    G[u+N].append(v+2*N)
    G[u+2*N].append(v)
S,T = map(int,input().split())
S -=1
T -=1
def dijkstra(v):
    d = [inf] * (3*N)
    d[v] = 0
    hq =[(0,v)]

    while hq:
        u = heappop(hq)[1]
        for v in G[u]:
            if d[v] > d[u] + 1:
                d[v] = d[u] +1
                heappush(hq,(d[u]+1,v))
    return d
dist = dijkstra(S)
if dist[T]==inf:
    print(-1)
else:
    print(dist[T]//3)

Measured memory_bytes: 60532
S = input()
S_reverce = S[::-1]

for n,s in enumerate(S):
    if s == 'A':
        A_num = n + 1
        break
for n,s in enumerate(S_reverce):
    if s == 'Z':
        Z_num = len(S) - n
        break
        
ans = Z_num - A_num + 1
print(ans)

Measured memory_bytes: 3516
//by (111110101)2
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<vector>
#include<deque>
#include<queue>
#include<stack>
#include<set>
#include<map>
#include<algorithm>
#include<functional>
#include<utility>
#include<bitset>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<cstdio>
using namespace std;
int a,b,c;
int main()
{
	cin>>a>>b>>c;
	if((a==b && a!=c) || (a==c && a!=b) || (b==c && a!=b))
	{
		cout<<"Yes"<<endl;
	}
	else
	{
		cout<<"No"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
template <typename A, typename B>
string to_string(pair<A, B> p);
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);
 
string to_string(const string& s) {
  return '"' + s + '"';
}
 
string to_string(const char* s) {
  return to_string((string) s);
}
 
string to_string(bool b) {
  return (b ? "true" : "false");
}
 
string to_string(vector<bool> v) {
  bool first = true;
  string res = "{";
  for (int i = 0; i < static_cast<int>(v.size()); i++) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(v[i]);
  }
  res += "}";
  return res;
}
 
template <size_t N>
string to_string(bitset<N> v) {
  string res = "";
  for (size_t i = 0; i < N; i++) {
    res += static_cast<char>('0' + v[i]);
  }
  return res;
}
 
template <typename A>
string to_string(A v) {
  bool first = true;
  string res = "{";
  for (const auto &x : v) {
    if (!first) {
      res += ", ";
    }
    first = false;
    res += to_string(x);
  }
  res += "}";
  return res;
}
 
template <typename A, typename B>
string to_string(pair<A, B> p) {
  return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}
 
template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}
 
template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
  return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}
 
void debug_out() { cerr << endl; }
 
template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
  cerr << " " << to_string(H);
  debug_out(T...);
}
 
#ifdef LOCAL
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#else
#define debug(...) cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)
#endif


typedef long long ll; 
typedef pair<int, int> pii;
typedef pair<ll, int> pli;
typedef pair<ll, ll> pll;
typedef long double ld;
 
#define mp make_pair
#define pb push_back
#define all(a) a.begin(), a.end()

const int maxN = 502;


void solve() {
  int n, m;
  cin >> n >> m;
  vector<int> a(n);
  int sum = 0;
  for (int i = 0 ; i < n ; i++) {
    cin >> a[i];
    sum += a[i];
  }
  sort(all(a));
  reverse(all(a));
  double r = (1.0 * sum) / (4 * m);
  for (int i = 0 ; i < m ; i++) {
    if (a[i] < r) {
      cout << "No";
      return;
    }
  }
  cout << "Yes";
}
 
int main() {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    
  int t = 1;
  // cin >> t;
  while (t--) {
    solve();
  }
 
  return 0;
}

Measured memory_bytes: 256
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, a, b) for (int i = a; i < (b); i++)
#define FOR(i, n) for (int i = n; i >= 0; i--)
#include <algorithm>
#include <cmath>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
#define ll long long
#define SIZE 100001
#define MOD 1000000007
#define INF 100000000
using namespace std;

int main() {
  int a, b;
  cin >> a >> b;

  if (a % 3 == 0 || b % 3 == 0 || (a + b) % 3 == 0) {
    cout << "Possible" << endl;
  } else
    cout << "Impossible" << endl;

  return 0;
}

Measured memory_bytes: 764
x,y=map(int,input().split())
if x*y>0:
  if x>y:
    print(x-y+2)
  else:
    print(y-x)
elif x==0:
  print(abs(y)+(y<0))
elif y==0:
  print(abs(x)+(x>0))
else:
  print(abs(abs(x)-abs(y))+1)

Measured memory_bytes: 3060
#include <iostream>
#include <bits/stdc++.h>
using namespace std;
typedef long long llint;
const llint MOD = 1'000'000'007;

int main() {

    double R;
    cin >> R;
    cout << setprecision(20) << fixed << 2 * R * acos(-1) << endl;

}

Measured memory_bytes: 3792
#include <algorithm>
#include <iostream>
#include <string>
#include <vector>

using namespace std;

int main() {
  string s, t;
  string ng = "UNRESTORABLE";

  cin >> s >> t;

  int n = (int)s.size();
  int m = (int)t.size();

  if (n < m) {
    cout << ng << endl;
    return 0;
  }

  vector<string> ans;

  for (int i = 0; i <= n - m; i++) {
    string head = s.substr(0, i);
    string tail = s.substr(i + m, n - i - m);
    string mid = s.substr(i, m);
    bool is_ok = true;
    for (int j = 0; j < m; j++) {
      if (mid[j] != '?' && t[j] != mid[j]) {
        is_ok = false;
      }
    }
    if (is_ok) {
      string tmp = "";
      for (int j = 0; j < (int)head.size(); j++) {
        if (head[j] != '?') {
          tmp += head[j];
        } else {
          tmp += 'a';
        }
      }
      tmp += t;
      for (int j = 0; j < (int)tail.size(); j++) {
        if (tail[j] != '?') {
          tmp += tail[j];
        } else {
          tmp += 'a';
        }
      }
      ans.push_back(tmp);
    }
  }
  if (ans.size() != 0) {
    sort(ans.begin(), ans.end());
    cout << ans[0] << endl;
  } else {
    cout << ng << endl;
  }

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
using namespace std;
int main(){
  int a,b,c,d,n,count;
  
  while(cin >> n){
    count = 0;
    for(a = 0;a <=9;a++){
      for(b = 0;b <=9;b++){
	for(c = 0;c <=9;c++){
	  for(d = 0;d <=9;d++){
	    if(a+b+c+d == n){count = count +1;}
	  }
	}
      }
    }
    cout << count << endl;
  }
}

Measured memory_bytes: 0
#include<bits/stdc++.h>
#define pb push_back
#define ld long double
#define mp make_pair
#define vl vector<ll> 
#define ll long long int
#define pl pair<ll, ll>
#define min(a, b, c) min(a, min(b, c))
#define forr(i, n) for(ll i=0; i<n; i++) 
#define forr1(i, n) for(ll i=1; i<=n; i++)
using namespace std;
const ll MOD = 1e9+7;
const ll NUM = 1e3+10;
void solve()
{
    ll n, k;
    cin>>n>>k;
    vl vect(n+1);
    forr1(i, n)
    cin>>vect[i];
    if(k==0){
        cout<<1<<endl;
        return;
    }
    vl positions;
    unordered_map<ll, ll> ma;
    positions.pb(1);
    ma[1]=1;
    for(ll i=1;k!=0; )
    {
        positions.pb(vect[i]);
        k--;
        if(k==0){
            cout<<positions[positions.size()-1];
            return;
        }
        if(ma.find(vect[i])!=ma.end())
        break;
        ma[vect[i]]++;
        i=vect[i];
    }
    ll rep=positions[positions.size()-1], firstind=0;
    forr(i, n)
    {
        if(positions[i]==rep){
            firstind=i;
            break;
        }
    }
    ll cycle=(positions.size()-1)-firstind;
    k%=cycle;
    cout<<positions[firstind+k];
}
int main()
{
    ll test=1;
    //cin>>test;
    while(test--)
        solve();
}

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

typedef long long ll;
typedef vector<int> vi;
typedef pair<int, int> pi;
typedef vector<long long> vl;
typedef pair<long long, long long> pl;
typedef vector<vector<long long>> matrix;

#define F 						first
#define S 						second
#define PB 						push_back
#define MP 						make_pair
#define all(c) 					c.begin(), c.end()
#define f(i,a,b) 				for(ll i=a; i<b; i++)
#define rep(i,n) 				f(i,0,n)
#define tr(c,i) 				for(typeof(c).begin() i = c.begin(); i != c.end(); i++)
#define present(c,x) 			(c.find(x) != c.end())	//for set and map
#define cpresent(c,x) 			(find(all(c),x) != c.end())	//for vectors
#define w(t)					ll t; cin>>t; while(t--)
#define epsilon 				1e-9
#define MOD						(ll)1e9

void doublade() {
	ios::sync_with_stdio(false); cin.tie(0); cout.precision(10);
	#ifndef ONLINE_JUDGE
		freopen("input.txt", "r", stdin);
		freopen("output.txt", "w", stdout);
	#endif
}

int main() {
	doublade();
	// w(t) {
		ll n;
		cin >> n;
		if(n==0) cout<<"1\n";
		else if(n==1) cout<<"0\n";
	// }
	return 0;
}

Measured memory_bytes: 3580
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define all(v) v.begin(), v.end()
const int MOD = 1e9 + 7;
const int INF = 1e9;
//'A' = 65, 'Z' = 90, 'a' = 97, 'z' = 122

int main() {
    int h, w;
    cin >> h >> w;
    char maze[h][w];
    int cnt_black = 0;
    rep(i, 0, h) {
        rep(j, 0, w) {
            cin >> maze[i][j];
            if (maze[i][j] == '#') cnt_black++;
        }
    }

    queue<pair<int, int>> que;
    que.push(make_pair(0, 0));
    int dist[h][w];
    rep(i, 0, h) {
        rep(j, 0, w) {
            dist[i][j] = -1;
        }
    }
    dist[0][0] = 0;
    int dy[4] = {1, 0, -1, 0};
    int dx[4] = {0, 1, 0, -1};
    while (!que.empty()) {
        int y = que.front().first;
        int x = que.front().second;
        que.pop();
        rep(i ,0, 4) {
            int ny = y + dy[i];
            int nx = x + dx[i];
            if (dist[ny][nx] != -1) continue;
            if (maze[ny][nx] == '#') continue;
            if (ny < 0 || h - 1 < ny || nx < 0 || w - 1 < nx) continue;
            que.push(make_pair(ny, nx));
            dist[ny][nx] = dist[y][x] + 1;
        }
    }

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

    cout << h * w - cnt_black - (dist[h - 1][w - 1] + 1) << endl;

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

#define COUT(x) cout << #x << " = " << (x) << " (L" << __LINE__ << ")" << endl
template<class T1, class T2> ostream& operator << (ostream &s, pair<T1,T2> P)
{ return s << '<' << P.first << ", " << P.second << '>'; }
template<class T> ostream& operator << (ostream &s, vector<T> P)
{ for (int i = 0; i < P.size(); ++i) { if (i > 0) { s << " "; } s << P[i]; } return s; }
template<class T> ostream& operator << (ostream &s, vector<vector<T> > P)
{ for (int i = 0; i < P.size(); ++i) { s << endl << P[i]; } return s << endl; }
template<class T> ostream& operator << (ostream &s, set<T> P)
{ for(auto it : P) { s << "<" << it << "> "; } return s << endl; }
template<class T1, class T2> ostream& operator << (ostream &s, map<T1,T2> P)
{ for(auto it : P) { s << "<" << it.first << "->" << it.second << "> "; } return s << endl; }



int main() {
    int N;
    while (cin >> N) {
        long long res = 0;
        long long cur = 0;
        for (int i = 0; i < N; ++i) {
            long long A;
            cin >> A;
            if (cur > A) {
                res += cur - A;
            }
            else {
                cur = A;
            }
        }
        cout << res << endl;
    }
}

Measured memory_bytes: 3620
#include <cstdio>
#include <vector>
#include <algorithm>
#include <functional>
using namespace std;

int main() {
  int N, M; scanf("%d%d", &N, &M);
  vector<vector<int>> graph(N + M);
  for(int i = 0; i < N; ++i) {
    int K; scanf("%d", &K);
    for(int j = 0; j < K; ++j) {
      int L; scanf("%d", &L); --L;
      graph[i].push_back(N+L);
      graph[N+L].push_back(i);
    }
  }
  vector<char> vis(N + M, false);
  function<void(int)> visit = [&](int v) {
    if(vis[v]) return;
    vis[v] = true;
    for(int w : graph[v]) {
      visit(w);
    }
  };
  visit(0);
  for(int i = 0; i < N; ++i) {
    if(!vis[i]) {
      printf("NO\n");
      return 0;
    }
  }
  printf("YES\n");
  return 0;
}


Measured memory_bytes: 8568
#include <bits/stdc++.h>
#define int long long int
#define ii pair<int,int>
#define fi first
#define se second
#define mp make_pair
#define pb push_back
using namespace std;
#define output(x) for (auto a:x) cout<<a<<" ";cout<<endl;
#define output2(x) for (auto a:x) cout<<a.fi<<" "<<a.se<<endl;
#define PI 3.14159265
#define all(x) x.begin(),x.end()

// DEBUG TEMPLATE
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
  *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
  
// DEBUG TEMPLATE ENDS

#define MOD 1000000007
int power(int x,int y,int mod = MOD) 
{ 
  int ret = 1;
  x = x % mod;
  while (y){
    if(y&1) ret = (ret*x)%mod;
    y = y>>1;
    x = (x*x)%mod;
    } 
    return ret%mod; 
}

int num(int l,int r,int d){
  if (l>r) return 0;
  return ((r-l)/d + 1);
}

int sum(vector<int> x){
  int ret = 0;
  for (auto y:x) ret = (ret+y)%MOD;
  return ret%MOD;
}

void solve()
{ 
  string a,b;
  cin>>a>>b;
  int cnt = 0;
  for (int i=0;i<(int) a.size();i++){
    if (a[i]!=b[i]) cnt++;
  }
  cout<<cnt<<endl;
}


/*
  
*/
signed main(){
  int t = 1;
  // cin>>t;
  while (t--)
  solve();
}
// Check MOD values plox :(


Measured memory_bytes: 3920
import heapq as h
import math
import numpy as np
import copy
import itertools

 
# x,y = map(int,input().split())
n = input()
# a = list(map(int,input().split()))
if n=='SUN':
    print(7)
elif n == 'MON':
    print(6)
elif n == 'TUE':
    print(5)
elif n=='WED':
    print(4)
elif n=='THU':
    print(3)
elif n=='FRI':
    print(2)
elif n=='SAT':
    print(1)









Measured memory_bytes: 21556
def main():
    import sys
    input = sys.stdin.readline

    N, mod = map(int, input().split())
    adj = [[] for _ in range(N+1)]
    for _ in range(N-1):
        a, b = map(int, input().split())
        adj[a].append(b)
        adj[b].append(a)

    st = [1]
    seen = [0] * (N+1)
    seen[1] = 1
    par = [0] * (N+1)
    child = [[] for _ in range(N+1)]
    seq = []
    while st:
        v = st.pop()
        seq.append(v)
        for u in adj[v]:
            if not seen[u]:
                seen[u] = 1
                par[u] = v
                child[v].append(u)
                st.append(u)
    seq.reverse()
    dp = [1] * (N+1)
    left = [1] * (N+1)
    right = [1] * (N+1)
    for v in seq:
        tmp = 1
        for u in child[v]:
            left[u] = tmp
            tmp = (tmp * (dp[u] + 1)) % mod
        tmp = 1
        for u in reversed(child[v]):
            right[u] = tmp
            tmp = (tmp * (dp[u] + 1)) % mod
        dp[v] = tmp

    seq.reverse()
    dp2 = [0] * (N+1)
    for v in seq:
        if v == 1:
            continue
        dp2[v] = ((left[v] * right[v])%mod * (dp2[par[v]]+1))%mod
        dp[v] = (dp[v] * (dp2[v]+1))%mod

    for i in range(1, N+1):
        print(dp[i])


if __name__ == '__main__':
    main()


Measured memory_bytes: 82900
#include<iostream>
#include<vector>
#include<string>
#define rep(i, start, end) for (int i = (int)start; i < (int)end; ++i)
#define rrep(i, start, end) for (int i = (int)start - 1; i >= end; --i)
#define all(x) (x).begin(), (x).end()
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a, T b) {if (a < b) {a = b; return true;} return 0;}
template<typename T> inline bool chmin(T& a, T b) {if (a > b) {a = b; return true;} return 0;}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll A, B, C;
    cin >> A >> B >> C;
    if (A + B >= C) {
        cout << "No" << endl;
    }
    else {
        if (4 * A * B < (C - A - B) * (C - A - B)) {
            cout << "Yes" << endl;
        }
        else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
bool check(vector<vector<int>>&grid, set<int>st){
	bool found=false;
	for(int i=0;i<3;i++){
		found=true;
		for(int j=0;j<3;j++){
			if(!st.count(grid[i][j])){
				found=false; 
				break;
			}
		}
		if(found==true) return true;
	}
	for(int i=0;i<3;i++){
		found=true;
		for(int j=0;j<3;j++){
			if(!st.count(grid[j][i])){
				found=false; 
				break;
			}
		}
		if(found==true) return true;
	}
	found=true;
	for(int i=0;i<3;i++){
		if(!st.count(grid[i][i])){
			found=false; 
			break;
		}
	}
	if(found==true) return true;
	found=true;
	for(int i=0;i<3;i++){
		if(!st.count(grid[i][2-i])){
			found=false;
			break;
		}
	}
	if(found==true) return true;
	return false;
}
int main(){
	cin.tie(0);cout.tie(0);ios_base::sync_with_stdio(0);
	vector<vector<int>>grid(3, vector<int>(3));
	for(int i=0;i<3;i++){
		for(int j=0;j<3;j++){
			cin>>grid[i][j];
		}
	}
	int n; cin>>n;
	set<int>st;
	for(int i=0;i<n;i++) {
		int x; cin>>x;
		st.insert(x);
	}
	bool ret= check(grid, st);
	if(ret) cout<<"Yes"<<'\n';
	else cout<<"No"<<'\n';
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
#include <iomanip>
#include <vector>
#include <map>
#include <cmath>
#include <queue>
#include <utility>
#include <functional>
#include <deque>
#include <cctype>
#include <stack>
#include <bitset>

using ll = long long;
typedef unsigned long long ull;
typedef std::pair<int, int>p;
struct edge { int to, cost; };
std::vector<edge>v[1000];
typedef std::vector<std::vector<int>>ma;
ma d;

ll min(ll a, ll b) {
	if (a >= b)return b;
	else return a;
}
ll max(ll a, ll b) {
	if (a >= b)return a;
	else return b;
}
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	return gcd(b, a%b);
}
ll lcm(ll a, ll b) {
	ll g = gcd(a, b);
	return a / g * b;
}

const ll Z = 1000000007;
const ll INF = 1 << 30;
const ll INF2 = 9000000000000000000LL;
bool flag = true;
bool fl = true;
bool f = true;
int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };
std::string abc = "abcdefghijklmnopqrstuvwxyz";

int main() {
	char c[3][3];
	for (int i = 0;i < 3;i++)for (int j = 0;j < 3;j++)std::cin >> c[i][j];
	std::cout << c[0][0] << c[1][1] << c[2][2] << std::endl;
	}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
using namespace std;
typedef long long ll;

struct SparseTable {
	vector<ll>A, log_table;
	vector<vector<int>> tableA;
	int N;

	SparseTable(vector<ll>A_) {
		N = A_.size();
		A.resize(N);
		for (int i = 0; i < N; i++)A[i] = A_[i];

		//対数計算は先にやっておく
		log_table.resize(N+1);
		for (int i = 2; i <= N; i++) {
			log_table[i] = log_table[i >> 1] + 1;
		}

		tableA.resize(N);
		for (int i = 0; i < N; i++) {
			tableA[i].resize(log_table[N] + 1);
		}

		//区間[i,i]
		for (int i = 0; i < N; i++) {
			tableA[i][0] = i;
		}
	}

	void push(int k, ll a) {
		A[k] = a;
	}

	//最大値のインデックスを持つテーブルを作る
	void maxtable() {
		//区間[i,i+2^k)の計算
		for (int k = 1; (1 << k) <= N; k++) {
			for (int i = 0; i + (1 << k) <= N; i++) {
				//区間[i,i+2^(k-1))と区間[i+2^(k-1),i+2^k)の最小値、最大値のインデックス
				int firstA = tableA[i][k - 1];
				int secondA = tableA[i + (1 << (k - 1))][k - 1];

				//最後に出てきた最大値
				if (A[firstA] > A[secondA]) {
					tableA[i][k] = firstA;
				}
				else {
					tableA[i][k] = secondA;
				}
			}
		}
	}

	//区間[s,t]内の最大値のインデックスを返す
	int maxquery(int s, int t) {
		int d = t - s + 1;
		int k = log_table[d];

		int index = 0;

		//区間[s,t]は区間[s,s+2^k)と[t-2^k+1,t)でカバーできる
		if (A[tableA[s][k]] > A[tableA[t - (1 << k) + 1][k]]) {
			index = tableA[s][k];
		}
		else {
			index = tableA[t - (1 << k) + 1][k];
		}

		return index;
	}

	//最小値のインデックスを持つテーブルを作る
	void mintable() {
		//区間[i,i+2^k)の計算
		for (int k = 1; (1 << k) <= N; k++) {
			for (int i = 0; i + (1 << k) <= N; i++) {
				//区間[i,i+2^(k-1))と区間[i+2^(k-1),i+2^k)の最小値、最大値のインデックス
				int firstA = tableA[i][k - 1];
				int secondA = tableA[i + (1 << (k - 1))][k - 1];

				//最後に出てきた最小値
				if (A[firstA] < A[secondA]) {
					tableA[i][k] = firstA;
				}
				else {
					tableA[i][k] = secondA;
				}
			}
		}
	}

	//区間[s,t]内の最小値のインデックスを返す
	int minquery(int s, int t) {
		int d = t - s + 1;
		int k = log_table[d];

		int index = 0;

		//区間[s,t]は区間[s,s+2^k)と[t-2^k+1,t)でカバーできる
		if (A[tableA[s][k]] < A[tableA[t - (1 << k) + 1][k]]) {
			index = tableA[s][k];
		}
		else {
			index = tableA[t - (1 << k) + 1][k];
		}

		return index;
	}
};



int main()
{
	int N; cin >> N;
	vector<ll>a(N);
	for (int i = 0; i < N; i++) {
		cin >> a[i];
	}

	SparseTable st(a);

	ll cnt = 0;
	while (1) {
		st.maxtable();
		int index = st.maxquery(0,N-1);

		if (st.A[index] < N)break;

		ll x = st.A[index] / N;
		ll y = st.A[index] % N;

		st.A[index] = y;
		for (int i = 0; i < N; i++) {
			if (i == index)continue;

			st.A[i] += x;
		}

		cnt+=x;
	}

	cout << cnt << endl;

    return 0;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;
typedef pair<int, int> P;
typedef pair<llong, llong> LP;
typedef pair<int, P> PP;
typedef pair<llong, LP> LPP;

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

int main()
{
   string sa,sb,sc;
   cin>>sa>>sb>>sc;
   char a=toupper(sa[0]);
   char b=toupper(sb[0]);
   char c=toupper(sc[0]);
   cout<<a<<b<<c<<endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cmath>
#include<algorithm>
int ac[10000];//用数组记录sqrt(n)之前的因子
using namespace std;
int main()
{
    int n;
    double sum=0;
    cin>>n;
    for(int i=1;i<=n;i++)
    {
        cin>>ac[i];
    }
    sort(ac+1,ac+1+n);
    sum=(double)(ac[1]+ac[2])/2;
    for(int i=3;i<=n;i++)
    {
        sum=(double)(ac[i]+sum)/2;
    }
    cout<<sum;
}


Measured memory_bytes: 256
def main():
    from math import ceil

    n, *csf = map(int, open(0).read().split())
    csf = list(zip(csf[::3], csf[1::3], csf[2::3]))
    for i in range(n):
        time = 0
        for c, s, f in csf[i:]:
            if time <= s:
                time = s
            else:
                time = s + ceil((time - s) / f) * f
            time += c
        print(time)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3316
k = 0
m = 0
d = int(input())
p = [0]*d
for i in range(d):
  p[i] = int(input())
  if i == 0:
    if p[0] != 0:
      print(-1)
      m = 1
      break
  else:
    if p[i]  <= p[i-1]:
      k += p[i]
    elif p[i] <= 1 + p[i-1]:
      k += 1
    else:
      print(-1)
      m = 1
      break

if m != 1:
  print(k)

Measured memory_bytes: 12024
using System;

namespace ABC099_a
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] array = Console.ReadLine().Split(' ');
            int a = int.Parse(array[0]);
            if((a >= 1) && (a < 1000))
            {
                Console.WriteLine("ABC");
            }
            if(a >= 1000)
            {
                Console.WriteLine("ABD");
            }
        }
    }
}


Measured memory_bytes: 11092
def selectionSort(A,N):

  count = 0
  for i in range(len(A)):
    min_pos = i
    for j in range(i, len(A)):
      if A[j] < A[min_pos]:
        min_pos = j
    if min_pos != i:
      A[i], A[min_pos] = A[min_pos], A[i]
      count += 1
  return A, count


N = int(raw_input())
A = map(int, raw_input().split())

A, count = selectionSort(A,N)
print ' '.join(map(str, A))
print count


Measured memory_bytes: 4656
S=input()
od0=0
ev0=0
odn=len(S)//2
for i,ch in enumerate(S):
	if i%2==0:
		if ch=="0":
			ev0+=1
	else:
		if ch=="0":
			od0+=1
print(min(ev0+odn-od0,od0+len(S)-odn-ev0))

Measured memory_bytes: 3188
#include <stdio.h>

int main() {
    unsigned long long int ans,ansc;
    
    long long int n;
    
    scanf("%lld",&n);
    
    unsigned long long int a[n];
    
    for(int i=0;i<n;i++){
        scanf("%lld",&a[i]);
    }
    ans=a[0];
    for(int i=1;i<n;i++){
        ans*=a[i];
    }
    ansc=ans;
    for(int i=0;i<n;i++){
        if(a[i]==0){
            printf("0");
            return 0;
        }else{
            ansc/=a[i];
        }
    }
    if(ansc==1){
        if(ans>1000000000000000000){
            printf("-1");
        }else{
            printf("%lld",ans);
        }
    }else{
        printf("-1");
    }
    
    
    
        return 0;
}


Measured memory_bytes: 2488
#include <iostream>
#include <cstdio>
#include <cmath>
using namespace std;
#define REP0(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define ALL(c) (c).begin(),(c).end()
int main(){
	int a,b;
	while(scanf("%d%d",&a,&b)!=EOF){
		printf("%d\n",(int)log10(a+b)+1);
	}
	return 0;
}

Measured memory_bytes: 1232
import math

class Point():

    def __init__(self, x, y):
        self.x = x
        self.y = y

x1, y1, x2, y2 = [float(i) for i in input().split()]

point1 = Point(x1, y1)
point2 = Point(x2, y2)

x_dist = point1.x - point2.x
y_dist = point1.y - point2.y

dist = math.sqrt(x_dist ** 2 + y_dist ** 2)

print(dist)


Measured memory_bytes: 5660
import scala.io.Source
import scala.math.{pow, sqrt}

object Main{
  def main(args: Array[String]){
    val in = for{
      in <- Source.stdin.getLines.toList
    } yield in

    val data = in.head.split(" ").toList.map(_.toDouble)
    println(sqrt(pow(data(2) - data(0), 2) + pow(data(3) - data(1), 2)))
  }
}

Measured memory_bytes: 44072
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
typedef long long ll;

int main() {
  int k,x;
  cin>>k>>x;
  cout<< (500*k >= x ? "Yes" : "No")<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rep2(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
const ll INF = 1LL<<60;
const ll MOD = 1e9+7;


int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    ll n,m;cin>>n>>m;
    vector<ll> ac(n,0),wa(n,0);
    rep(i,m){
        int p;cin>>p;p--;
        string s;cin>>s;
        if(s=="WA"){if(ac[p]==0)wa[p]++;}
        else ac[p]=1;
    }
    ll ans1 = 0, ans2 = 0;
    rep(i,n){
        ans1+=ac[i];
        if(ac[i])ans2+=wa[i];
    }
    cout<<ans1<<" "<<ans2;
    return 0;
}

Measured memory_bytes: 1792
i=lambda:map(int,input().split())
h,w,n=i()
r=[0,1,2]
d={}
while n:
	a,b=i();n-=1
	for j in r:
		for k in r:
			if w>=b+k>2<a+j<=h:d[(a+j,b+k)]=d.get((a+j,b+k),0)+1
c=[0]*10
for i in d:c[d[i]]+=1
c[0]=(h-2)*(w-2)-sum(c)
print(*c,sep="\n")

Measured memory_bytes: 166492
def counting(A, **k):
    n = len(A)
    k = max(A)
    B = [0]*(n)
    C = [0]*(k+1)
    
    for j in A:
        C[j] += 1
    for i in range(k):
        C[i+1] += C[i]
    for j in A[::-1]:
        B[C[j]-1] = j
        C[j] -= 1
    
    return B

if __name__ == "__main__":
    input()
    A = list(map(int, input().strip().split()))
    B = counting(A)
    print(" ".join(map(str, B)))

Measured memory_bytes: 246060
# include <iostream>
using namespace std;
int N, sorted_a[59], c[59], ans;

int main() {
  cin >> N;
  for (int i = 1; i <= N; i++) {
    int a; cin >> a;
    sorted_a[a] = i;
  }
  for (int i = 1; i <= N; i++) {
    int b; cin >> b;
    ans += b;
  }
  for (int i = 1; i <= N - 1; i++) cin >> c[i];
  
  for (int i = 1; i <= N; i++) if (sorted_a[i + 1] - sorted_a[i] == 1) ans += c[i];
  
  cout << ans << endl;
  
  return 0;
}

Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;
class Program
{
    static void Main(string[] args)
    {
        string[] s = Console.ReadLine().Split(' ');
        int K = int.Parse(s[0]);
        int S = int.Parse(s[1]);
        int sum = 0;
        for (int z = 0; z <= K; z++)
            for (int y = 0; y <= z; y++)
                for (int x = 0; x <= y; x++)
                {
                    if(x + y + z == S)
                    {
                        if (x == y && y == z)
                            sum++;
                        else if (x == y || y == z || z == x)
                            sum += 3;
                        else
                            sum += 6;
                    }
                }
        Console.WriteLine(sum);
    }
}


Measured memory_bytes: 11092
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < n; i++)
#define vv(T) vector<vector<T>>
using namespace std;
using ll = long long;
using vint = vector<int>;
using vvint = vector<vector<int>>;
using vll = vector<long long>;
using vvll = vector<vector<long long>>;
using vbool = vector<bool>;
using vvbool = vector<vector<bool>>;

const string YES = "Yes";

// vint dist(1e5, -1);
// vvint path(1e5);
// vint ans(1e5);

int main(){
    int n, m;
    cin >> n >>m;
    vvint path(n);
    rep(i, m){
        int a, b;
        cin >> a >> b;
        path[a - 1].push_back(b - 1);
        path[b - 1].push_back(a - 1);
    }

    // vbool isVisited(n, false);
    // vint dist(n, -1);
    queue<int> que;
    que.push(0);
    vint ans(n, -1);
    // ans[0] = 0;
    while(!que.empty()){
        int roomNum = que.front();
        que.pop();
        // isVisited[roomNum] = true;
        for(auto nextRoom : path[roomNum]){
            if(ans[nextRoom] == -1){
                ans[nextRoom] = roomNum;
                que.push(nextRoom);
            }
        }
    }

    cout << YES << endl;
    for(int i = 1; i < n; i++){
        cout << ans[i] + 1 << endl;
    }
    return 0;
}


Measured memory_bytes: 9988
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define F first
#define S second
#define pb push_back
#define PI 3.14159265
#define sz(c) (int)c.size()
#define len(c) (int)c.length()
#define hcf(a, b) __gcd(a, b)
#define all(c) c.begin(), c.end()
#define vint vector<int>
#define vll vector<ll>
#define vpint vector<pair<int, int>>
#define vpll vector<pair<ll, ll>>
#define tr(container, it) \
    for (typeof(container.begin()) it = container.begin(); it != container.end(); it++)
#define fr(it, a, b) \
    for (int it = (a); it < (b); it++)
#define present(container, element) (container.find(element) != container.end())
#define cpresent(container, element) (find(all(container), element) != container.end())
#define maximum(a, b, c) (a > b ? (a > c ? a : c) : (b > c ? b : c))
#define minimum(a, b, c) (a < b ? (a < c ? a : c) : (b < c ? b : c))
typedef long long ll;
typedef long double ld;
typedef unsigned long long lu;
const ll mod = 1e9 + 7;
int32_t main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n, k, m;
    cin >> n >> k;
    m = n % k;
    cout << min(m, k - m) << "\n";
    return 0;
}

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

long long int gcd(long long int m, long long int n ){
	if ( ( 0 == m ) || ( 0 == n ) )	return 0;
	while( m != n ){
		if ( m > n ) m = m - n;
		else n = n - m;
	}
    return m;
}

long long int lcm(long long int m, long long int n ){
	if ( ( 0 == m ) || ( 0 == n ) ) return 0;
	return ((m / gcd(m, n)) * n);
}

int main(){
    long long int n, m;
    char s[100010], t[100010];
    cin >> n >> m >> s >> t;
    if(s[0]!=t[0]){
        cout << "-1" << endl;
        return 0;
    }
    long long int min = lcm(n, m);
    for(int i=0;i<n;++i){
        if(i*m%n==0){
            int j = i*m/n;
            if(s[i]!=t[j]){
                cout << "-1" << endl;
                return 0;
            }
        }
    }
    cout << min << endl;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define s size
#define pb push_back
#define in insert
#define PI 3.1415926535897932384626433832795
#define MOD 100000007
#define F first
#define S second
#define aLL(str) (str).begin(), (str).end()
#define IOS                  \
	ios::sync_with_stdio(0); \
	cin.tie(0);              \
	cout.tie(0)
#define ll long long
typedef vector<ll> vl;
typedef map<ll,ll> ml;
typedef vector<string> vs;
typedef vector<vector<int>> vvi;

int main()
{IOS;
int t;
t=1;
while(t--)
{ll x,n,i,g,ans,l,r;
cin>>x>>n;
ll v[101]={0};
for(i=0;i<n;i++)
{
 cin>>g;
 v[g]=1;
} l=x,r=x;
while(1)
{if(v[l]!=1)
{
    cout<<l;
    break;
}
if(v[r]!=1)
{
    cout<<r;
    break;
}
l--;
r++;
}}
return 0;}

Measured memory_bytes: 3616
/****************************************************************
# @Author:      iLovePKU_zbtxdy
# @DateTime:    2020-02-07 14:24:52
# @Description: Think twice. Code once. 
# @More: Once lots of AC, try Brute-force,dynamic programming
****************************************************************/
#include<bits/stdc++.h>
using namespace std;
#define close std::ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define eps 1e-8
#define int long long 
typedef long long ll;
const int maxn = 1e6+10;
const int INF = 0x3f3f3f3f;
const ll linf = 0x3f3f3f3f3f3f3f3f;
const double PI = acos(-1.0);
ll mod = 1e9+7;
ll bin(ll x , ll n , ll MOD){
    ll ret = MOD != 1;
    for(x %= MOD; n ; n >>= 1, x = x * x % MOD)
        if(n & 1)ret = ret * x % MOD;
    return ret;
}
int n , len , k , tot[maxn];
vector<int > v;
int32_t main()
{
    cin >> n >> k;
    len = sqrt(n);
    for(int i = 1; i <= len; i++){
        if(n % i == 0){
            v.emplace_back(i);
            if(i != n / i)v.emplace_back(n / i);
        }
    }sort(v.begin(), v.end());
    int size  = v.size();
    ll ans = 0;
    for(int i = 0 ; i < size ; i++){
        tot[i] = bin(k , (v[i] + 1) / 2, mod);
        for(int j = 0 ; j < i ; j++){
            if(v[i] % v[j] == 0){
                tot[i] = (tot[i] + mod - tot[j]) % mod;
            }
        }
        if(v[i] & 1){ans += tot[i] * v[i]; ans %= mod;}
        else {ans += tot[i] * (v[i] / 2) ; ans %= mod;}
    }cout << ans << endl;
    system("pause");
}
/***************************************************************************
*stuff you should look for
*int overflow, array bounds
*special cases (n=1?), set tle
*do smth instead of nothing and stay organized
***************************************************************************/

Measured memory_bytes: 504
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vs = vector<string>;
using msi = map<string, int>;
using mii = map<int, int>;
using psi = pair<string, int>;
using pii = pair<int, int>;
using vlai = valarray<int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,s,n) for(int i=s;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define fs first
#define sc second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define INF 1E9
#define EPS 1E-9
#define MOD (ll)(1E9+7)
#define PI 3.1415926535897932384

template <class T>ostream &operator<<(std::ostream &o, const vector<T> &v)
{
	rep(i, v.size()) {
		o << (i > 0 ? " " : "") << v[i];
	}
	return o;
}

int main() {
	int n,ans=1;
	cin >> n;
	vi v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}
	sort(all(v));
	if (n == 1) {
		cout << 1 << endl;
		return 0;
	}
	for (int i = 1; i < n; i++) {
		if (v[i - 1] != v[i]) ans++;
	}
	cout << ans << endl;
}


Measured memory_bytes: 256
n = int(input())
ans = [0]*n
for i in range(1,100):
  for j in range(1,100):
    for k in range(1,100):
      num = i*i+j*j+k*k+i*j+i*k+j*k
      if num <= n:
        ans[num-1] += 1
for i in range(n):
  print(ans[i])
        

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

void Main()
{
    int n, k, r, s, p;
    int b[3];
    cin >> n >> k >> b[0] >> b[1] >> b[2];
    string t;
    cin >> t;
    vector<int> tt(n);
    for (int i = 0; i < n; i++)
    {
        if (t[i] == 'r') tt[i] = 0;
        if (t[i] == 's') tt[i] = 1;
        if (t[i] == 'p') tt[i] = 2;
    }
    
    vector<vector<long>> dp(n, vector<long>(3));
    for (int i = 0; i < n; i++)
    {
        for (int j = 0; j < 3; j++)
        {
            int cb = (3+tt[i]-j)%3==1 ? b[j] : 0;
            if (i >= k) {
                dp[i][j] = max(dp[i-k][(j+1)%3], dp[i-k][(j+2)%3]) + cb;
            } else {
                dp[i][j] = cb;
            }
        }
    }
    long ans = 0;
    for (int i = 0; i < k; i++)
    {
        long tmp = 0;
        for (int j = 0; j < 3; j++)
        {
            tmp = max(dp[n-1-i][j], tmp);
        }
        ans += tmp;
    }
    
    cout << ans << endl;
}

int main(int argc, char **argv)
{
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    Main();
    return 0;
}


Measured memory_bytes: 9252
if __name__ == '__main__':
    import sys
    input = sys.stdin.readline



    ss = str(input()[:-1])

    for s in ss[::2]:
        if s == 'L':
            print('No')
            exit()

    for s in ss[1::2]:
        if s == 'R':
            print('No')
            exit()
    print('Yes')


Measured memory_bytes: 3060