akhauriyash/Code-Regression huggingface dataset:
#include<iostream>
#include<vector>
#include<cmath>
#include<map>
#include<cstdio>
using namespace std;
#define rep(i,a) for(int i = 0 ; i < a; i ++)
#define loop(i,b,a) for(int i = b ; i < a; i ++)
const int MAX = 1000000;
int main(void){
  bool prime[MAX];
  rep(i,MAX)prime[i] = true;
  prime[0] = prime[1] = false;
  loop(i,2,i * i){
    if(prime[i]){
      for(int j = i + i ; j < MAX ; j += i){
	prime[j] = false;
      }
    }
  }
  //rep(i,100)if(prime[i])cout<<i<<endl;
  int n;
  while(cin>>n){
    int mi,ma;
    mi = n-1; 
    ma = ++n;
    while(!prime[mi]){
      mi--;
    }
    while(!prime[ma]){
      ma++;
    }
    
    cout<<mi<<" "<<ma<<endl;
  }
}

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

#define ll long long
#define deb(x) cerr << #x << ":" << x << "\n"
#define all(x) x.begin(),x.end()
#define sz(x) x.size()

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>

void solve()
{
    int n;
    cin>>n;
    string s;
    cin>>s;
    set<int> st;
    for(int i=1;i<n;i++){
        if(s[i]=='R' && s[i-1]=='W')st.insert(i);
    }
    int ans=0;
    int cnt=min(count(all(s),'R'),count(all(s),'W'));
    int r=count(all(s),'R');
    for(int i=r;i<n;i++)ans+=s[i]=='R';
    // for(int i=1;i<n;i++){
    //     if(s[i]=='R' && s[i-1]=='W'){
    //         auto it=st.upper_bound(i);
    //         if(it==st.end()){
    //             for(int j=i;j<n;j++)ans+=s[i]=='R';
    //             break;
    //         }else{
    //             ++ans;
    //             swap(s[*it],s[i-1]);
    //         }
    //     }
    // }
    cout<<min(ans,cnt)<<"\n";
}

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    // cin >> t;
    while (t--)
    {
        solve();
    }
    return 0;
}

Measured memory_bytes: 5908
#include <cstdio>
#include <iostream>
#include <cstring>
#include <algorithm>
using namespace std;

const int N = 3e5 + 50;

namespace Tree {
#define mid ((L + R) >> 1)
#define x ID(L, R)
#define lc ID(L, mid)
#define rc ID(mid + 1, R)
  int __key[N << 1], __lazy[N << 1];

  inline int ID(int L, int R) {return (L + R) | (L != R);}
  inline void Init() {
    memset(__key, 0, sizeof __key);
    memset(__lazy, 0, sizeof __lazy);
  }
  inline void PushDown(int L, int R) {
    if (!__lazy[x]) return;
    __lazy[lc] += __lazy[x];
    __lazy[rc] += __lazy[x];
    __key[lc] += __lazy[x];
    __key[rc] += __lazy[x];
    __lazy[x] = 0;
  }
  inline void Add(int L, int R, int l, int r, int val) {
    if (l > r || !val) return;
    if (L == l && R == r) {
      __key[x] += val;
      __lazy[x] += val;
      return;
    }
    PushDown(L, R);
    if (r <= mid) Add(L, mid, l, r, val);
    else if (l > mid) Add(mid + 1, R, l, r, val);
    else {
      Add(L, mid, l, mid, val);
      Add(mid + 1, R, mid + 1, r, val);
    }
    __key[x] = max(__key[lc], __key[rc]);
  }

#undef mid
#undef x
#undef lc
#undef rc
}
using namespace Tree;

inline void Read(int &x) {
  x = 0; char ch;
  while (!isdigit(ch = getchar()));
  do {x = (x << 1) + (x << 3) + ch - '0';} while (isdigit(ch = getchar()));
}

int W, H, n;
int x[N], y[N], id[N], rnk[N];
int topU, topD, ans;
pair <int, int> U[N], D[N];

inline bool cmp(int a, int b) {
  return x[a] < x[b];
}

inline void solve() {
  Tree::Init();
  for (int i = 1; i <= n; i ++) id[i] = i;
  sort(id + 1, id + n + 1, cmp);
  int mid = H >> 1, m = n + 10;
  topU = topD = 1;
  U[1].first = D[1].first = 1;
  U[1].second = H; D[1].second = 0;
  Tree::Add(1, m, 1, 1, H);
  for (int l = 1, r = 1, i = 2; l <= n; l = r, i ++) {
    Tree::Add(1, m, 1, i - 1, x[id[l]] - x[id[l - 1]]);
    ans = max(ans, Tree::__key[Tree::ID(1, m)]);
    int up = H, down = 0, p = 0;
    while (x[id[r]] == x[id[l]] && r <= n) {
      if (y[id[r]] > mid) up = min(up, y[id[r]]);
      else down = max(down, y[id[r]]);
      r ++;
    }
    Tree::Add(1, m, i, i, H);
    while (topU && U[topU].second >= up) {
      Add(1, m, U[topU - 1].first + 1, U[topU].first, up - U[topU].second);
      topU --;
    }
    U[++ topU] = make_pair(i - 1, up);
    U[++ topU] = make_pair(i, H);
    while (topD && D[topD].second <= down) {
      Add(1, m, D[topD - 1].first + 1, D[topD].first, D[topD].second - down);
      topD --;
    }
    D[++ topD] = make_pair(i - 1, down);
    D[++ topD] = make_pair(i, 0);
  }
  ans = max(ans, Tree::__key[Tree::ID(1, m)] + W - x[id[n]]);
}

int main() {
  Read(W); Read(H); Read(n);
  for (int i = 1; i <= n; i ++) Read(x[i]), Read(y[i]);
  solve();
  swap(W, H);
  for (int i = 1; i <= n; i ++) swap(x[i], y[i]);
  solve();
  printf("%d\n", ans * 2);
  return 0;
}


Measured memory_bytes: 12928
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i=0; i<(n); i++)
int main()
{
    int n;
    cin >> n;
    int h[100];
    rep(i, n){
        cin >> h[i];
    }

    int ans = 0;
    int active = 0;
    
    rep(i, n){
        if(h[i] <= active){
            active = h[i];
        }
        else{
            ans += h[i] - active;
            active = h[i];

        }
    }
    cout << ans;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<boost/variant.hpp>
using namespace std;
typedef long long ll;
typedef vector<boost::variant<bool, ll, int, string, double, char*>> any;
template<typename T> inline void pr(const vector<T> &xs){
	for(int i=0; i<xs.size()-1; i++) cout<<xs[i]<<" ";
	(xs.empty()?cout:(cout<<xs[xs.size()-1]))<<endl;
}
template<typename T> inline void debug(const vector<T> &xs){
#ifdef DEBUG
	pr(xs);
#endif
}

pair<ll, ll> dfs(int u, int b, vector<vector<int>> &graph, vector<bool> &visit){
	if(visit[u]) return {0, 0};
	visit[u] = true;
	pair<ll, ll> x = {0, 0};
	for(int v: graph[u]){
		auto p = dfs(v, 1-b, graph, visit);
		x.first += p.first;
		x.second += p.second;
	}
	if(b) x.second++;
	else x.first++;
	return x;
}

int main(){
	int N;
	cin >> N;
	vector<int> X(N), Y(N);
	for(int i=0; i<N; i++){
		cin >> X[i] >> Y[i];
		X[i]--; Y[i]--;
	}

	vector<vector<int>> graph(2e5);
	for(int i=0; i<N; i++){
		graph[X[i]].push_back(Y[i]+1e5);
		graph[Y[i]+1e5].push_back(X[i]);
	}

	vector<bool> visit(2e5);
	ll ans = 0;
	for(int i=0; i<1e5; i++){
		auto p = dfs(i, 0, graph, visit);
		ans += p.first * p.second;
	}
	cout << ans-N << endl;

	return 0;
}


Measured memory_bytes: 13696
# coding:utf-8

import sys

INF = float('inf')
MOD = 10 ** 9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x) - 1 for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def II(): return int(sys.stdin.readline())
def SI(): return input()


def main():
    A = [II() for _ in range(5)]

    res = sum(A)
    loss = []
    for a in A:
        loss.append((10 - int(str(a)[-1])) % 10)

    loss.sort()

    return res + sum(loss[:-1])


print(main())


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

using namespace std;
using ll = long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
using vi = vector<int>;
using vl = vector<ll>;
using vb = vector<bool>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvl = vector<vector<ll>>;
using vvb = vector<vector<bool>>;
using vvs = vector<vector<string>>;
template<typename T> using vv = vector<vector<T>>;
template<typename T> using vvv = vector<vector<vector<T>>>;
template<typename T> using pq = priority_queue<T>;
template<typename T> using pqg = priority_queue<T, vector<T>, greater<T>>;

const int INF = 1e9;
const ll LINF = 1e18;
const ll MOD = 1e9 + 7;
const int DX[4] = {1, 0, -1, 0};
const int DY[4] = {0, 1, 0, -1};

#define _sel(_1, _2, x, ...) x
#define repn(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, a, b) for (ll i = (a); i < (b); i++)
#define rep(i, ...) _sel(__VA_ARGS__, reps, repn)(i, __VA_ARGS__)
#define reppn(i, n) for (ll i = 1; i <= (n); i++)
#define repps(i, a, b) for (ll i = (a); i <= (b); i++)
#define repp(i, ...) _sel(__VA_ARGS__, repps, reppn)(i, __VA_ARGS__)
#define rrepn(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, a, b) for (ll i = (b) - 1; i >= (a); i--)
#define rrep(i, ...) _sel(__VA_ARGS__, rreps, rrepn)(i, __VA_ARGS__)
#define rreppn(i, n) for (ll i = (n); i >= 1; i--)
#define rrepps(i, a, b) for (ll i = (b); i >= (a); i--)
#define rrepp(i, ...) _sel(__VA_ARGS__, rrepps, rreppn)(i, __VA_ARGS__)

#define pb push_back
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define rng(v) (v).begin(), (v).end()
#define rrng(v) (v).rbegin(), (v).rend()
#define siz(x) int((x).size())
#define pow2(x) (1ll << (x))
#define bit(x, n) ((x) >> (n) & 1)
#define prt(x) cout << (x) << endl
#define dbg(x) dbgn(#x, x)

template<typename T, typename U> inline bool umax(T& m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U> inline bool umin(T& m, U x) { if (m > x) { m = x; return true; } return false; }
template<typename T> inline void errv(T& v) { for (auto x: v) cerr << x << " "; cerr << endl; }
inline void errv(vb& v) { for (auto x: v) cerr << (x ? 1 : 0) << " "; cerr << endl; }
template<typename T> inline void dbgn(string n, T x) { cerr << n << ": " << x << endl; }
template<typename T> inline void dbgn(string n, vector<T>& v) { cerr << n << ": "; errv(v); }
template<typename T> inline void dbgn(string n, vv<T>& m) { cerr << n << ":" << endl; for (auto& v: m) errv(v); }


int main() {
    string s;
    cin >> s;
    cout << s[0];
    cout << s[1];
    cout << s[2];
    cout << endl;

    return 0;
}


Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
template <class T> inline bool chmin(T &a, T b) {if (a > b){a = b;return true;}return false;}
template <class T> inline bool chmax(T &a, T b) {if (a < b){a = b;return true;}return false;}

int main(){
    int n; cin >> n;
    // vector<pair<pair<string, int>, int>> sp(n);
    vector<tuple<string,int,int>> a;

    for(int i=1; i<=n; i++) {
        string s; int p;
        cin >> s >> p;
        p=-p;
        a.push_back(tie(s, p, i));
    }
    sort(a.begin(), a.end());
    rep(i, n) {
        cout << get<2>(a.at(i)) << endl;
    }

}

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

template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()

const int mod = 1e9+7;




int main() {
    ll n, k;
    cin >> n >> k;
    vector<ll> p, m;
    if (n == k) {
        ll ini = 1;
        rep (i, n) {
            ll d;
            cin >> d;
            if (d < 0) {
                d = d - floor(1.0 * d / mod) * mod;
            }
            ini *= d;
            ini %= mod;
        }
        cout << ini << endl;
        exit(0);

    }
    rep (i, n) {
        ll d;
        cin >> d;
        if (d > 0) {
            p.push_back(d);
        } else {
            m.push_back(d);
        }
    }
    sort(all(p), greater<ll>());
    sort(all(m));
    if (p.size() == 0 && k % 2) {
        sort(all(m), greater<ll>());
        rep (i, k) {
            m[i] = m[i] - floor(1.0 * m[i] / mod) * mod;
        }
        ll ini = 1;
        rep (i, k) {
            ini *= m[i];
            ini %= mod;
        }
        ini += mod;
        ini %= mod;
        cout << ini << endl;
        exit(0);
    }
    priority_queue<ll> pq;
    ll ini = 1;
    if (k % 2) {
        ini = p[0];
        p.erase(p.begin());
        k--;
    }
    rep (i, p.size() / 2) {
        pq.push(p[i * 2] * p[i * 2 + 1]);
    }
    rep (i, m.size() / 2) {
        pq.push(m[i * 2] * m[i * 2 + 1]);
    }
    rep (i, k/2) {
        ll d = pq.top();
        d %= mod;
        ini *= d;
        ini %= mod;
        pq.pop();
    }
    cout << ini << endl;
}




Measured memory_bytes: 6668
#include <stdio.h>

int main(void) {

  int x, y;
  scanf("%d %d", &x, &y);

  while(x!=0||y!=0) {
    if(x > y) {
      printf("%d %d\n", y ,x);
    } else {
      printf("%d %d\n", x ,y);
    }
    scanf("%d %d", &x, &y);
  }
 return 0;
}

Measured memory_bytes: 600
import collections
import sys

input = sys.stdin.readline

def myindex(l, x, default=-1):
    if x in l:
        return l.index(x)
    else:
        return default

def main():
    N = int(input())
    S = []
    for _ in range(N):
        S.append(input()[:-1])
    
    M = int(input())
    T = []
    for _ in range(M):
        T.append(input()[:-1])

    countS = list(zip(*collections.Counter(S).items()))
    countT = list(zip(*collections.Counter(T).items()))

    ans = 0
    for i, tmp in enumerate(countS[0]):
        cntS = countS[1][i]
        myidxT = myindex(countT[0], tmp)
        cntT = countT[1][myidxT]*(myidxT != -1)
        ans = max(ans, cntS-cntT)
    
    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 3316
#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: 256
#include<stdio.h>
int main(){
    int count, min, max, num;
    long int sum;
    scanf("%d %d", &count, &min);
    max = min;
    sum = min;
    for(int i=1; i<count; i++){
        scanf("%d", &num);
        sum += num;
        if(max < num){
            max = num;
        }else if(num < min){
            min = num;
        }
    }
    printf("%d %d %ld\n", min, max, sum);
}


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

class Point {
public:
  double x, y;
  Point(double x = 0, double y = 0):x(x), y(y){}
  Point operator +(Point p) { return Point(x+p.x, y+p.y);}
  Point operator -(Point p) { return Point(x-p.x, y-p.y);}
  Point operator *(double t) { return Point(x*t, y*t);}
};

typedef Point Vector;

double gaiseki(Vector a, Vector b) {
  return a.x*b.y - a.y*b.x;
}

double naiseki(Vector a, Vector b) {
  return a.x*b.x + a.y*b.y;
}

bool isHekomi(Point a, Point b, Point c, Point d) {
  double temp1;
  double temp2;
  int count = 0;
  for(int i = 0; i < 4; i++) {
    switch(i) {
    case 0:
      temp1 = gaiseki(d-a, c-a);
      temp2 = gaiseki(c-a, b-a);
      break;
    case 1:
      temp1 = gaiseki(a-b, d-b);
      temp2 = gaiseki(d-b, c-b);
      break;
    case 2:
      temp1 = gaiseki(b-c, a-c);
      temp2 = gaiseki(a-c, d-c);
      break;
    case 3:
      temp1 = gaiseki(c-d, b-d);
      temp2 = gaiseki(b-d, a-d);
      break;
    }
    if(temp1 >= 0 && temp2 >= 0 || temp1 <= 0 && temp2 <= 0) count++;
  }
  if(count == 4) return false;
  else           return true;
}

int main() {
  Point a, b, c, d;
  while(scanf("%lf,%lf,%lf,%lf,%lf,%lf,%lf,%lf", &a.x, &a.y, &b.x, &b.y, &c.x, &c.y, &d.x, &d.y) != EOF) {
    if(!isHekomi(a, b, c, d)) cout << "YES" << endl;
    else cout << "NO" << endl;
  }
  return 0;
}

Measured memory_bytes: 0
#include <stdio.h>
#include <string.h>
int main(void){
    char s[5];
    int i,j;
    scanf("%s",s);
    for(i=0;i<8;i++){
        char siki[8]={'\0'};
        siki[0]=s[0];
        for(j=0;j<3;j++){
            if(i&(1<<j))
                sprintf(siki,"%s%c%c",siki,'+',s[j+1]);
            else
                sprintf(siki,"%s%c%c",siki,'-',s[j+1]);
        }
        int g=(siki[0]-'0');
        for(j=1;siki[j]!='\0';j+=2){
            if(siki[j]=='+')
                g=g+(siki[j+1]-'0');
            else
                g=g-(siki[j+1]-'0');
        }
        if(g==7){
            for(j=0;siki[j]!='\0';j++){
                printf("%c",siki[j]);
            }
            printf("=7\n");
            return 0;
        }
    }
    
}


Measured memory_bytes: 128
#include<stdio.h>
#include<stdlib.h>

int compare_long_long_int(const void *a, const void *b)
{
    return *(int*)b - *(int*)a;
}

int main(){

    int N;
    int K;
    int i;
    long long int A[200000];
    long long int ans=0;

    scanf("%d",&N);
    scanf("%d",&K);

    for(i=0;i<N;i++){
        scanf("%lld",&A[i]);
        ans+=A[i];
    }

    qsort(A,N,sizeof(long long int),compare_long_long_int);

    for(i=0;i<K;i++){
        ans -= A[i];
    }

    if(ans > 0){
        printf("%lld\n",ans);
    }else{
        printf("0\n");
    }
}

Measured memory_bytes: 3324
N = int(input())
A = [int(x) for x in input().split()]
B = [int(x) for x in input().split()]
C = [int(x) for x in input().split()]

mae = -1
manzoku = 0
for i in range(N):
    manzoku += B[A[i] - 1]
    if A[i]-mae == 1:
        manzoku += C[mae-1]
    mae = A[i]

print(manzoku)


Measured memory_bytes: 3064
#include <stdio.h>
#include <stdlib.h>

#define MAX_N (1000)
#define MAX_M (40)
#define ABS(x) ((x) >= 0 ? (x) : -(x))

int main(int argc, char *argv[]) {
  int N, X[MAX_N], Y[MAX_N], U_m, V_m;
  int m, d[MAX_M];
  // read input
  scanf("%d", &N);
  for (int i = 0; i < N; i++)
    scanf("%d %d", &X[i], &Y[i]);
  // check if it is impossible given any m
  int odd_even = 0;  // 1 is even, -1 is odd
  for (int i = 0; i < N; i++) {
    int tmp = (X[i] + Y[i]) % 2 == 0 ? 1 : -1;
    if (odd_even == 0) {
      odd_even = tmp;
    } else if (odd_even != tmp) {
      printf("-1\n");
      return 0;
    }
  }
  // fake : use all ones
  // int max_dis = 0;
  // for (int i = 0; i < N; i++) {
  //   int dis = ABS(X[i]) + ABS(Y[i]);
  //   max_dis = max_dis >= dis ? max_dis : dis;
  // }
  // printf("%d\n", max_dis);
  // printf("1");
  // for (int i = 1; i < max_dis; i++)
  //   printf(" 1");
  // printf("\n");
  // for (int i = 0; i < N; i++) {
  //   char c;
  //   c = X[i] > 0 ? 'R' : 'L';
  //   for (int k = 0; k < ABS(X[i]); k++)
  //     printf("%c", c);
  //   c = Y[i] > 0 ? 'U' : 'D';
  //   for (int k = 0; k < ABS(Y[i]); k++)
  //     printf("%c", c);
  //   for (int k = ABS(X[i]) + ABS(Y[i]); k < max_dis; k++)
  //     if (k % 2 == 0)
  //       printf("R");
  //     else
  //       printf("L");
  //   printf("\n");
  // }

  // complete solution
  m = 31;
  for (int i = 0; i < m; i++)
    d[i] = 1 << i;
  // When even, add last arm with length 1 with mode R (modification needed on output)
  if (odd_even == 1) {
    // below is needed to pretend last arm doesn't exist while solving
    for (int i = 0; i < N; i++)
      X[i]--;
  }
  printf("%d\n", odd_even == 1 ? m + 1 : m);
  printf("%d", d[0]);
  for (int i = 1; i < m; i++)
    printf(" %d", d[i]);
  if (odd_even == 1)
    printf(" %d", 1);
  printf("\n");
  // calculate arm mode for each case
  for (int i = 0; i < N; i++) {
    int su[MAX_M], sv[MAX_M];
    int U_m = X[i] + Y[i];
    int V_m = X[i] - Y[i];
    for (int j = 0, decomp = (1 << (m - 1)) + (U_m - 1) / 2; j < m; j++, decomp /= 2)
      su[j] = decomp % 2;  // 1 if add 0 if subtract
    for (int j = 0, decomp = (1 << (m - 1)) + (V_m - 1) / 2; j < m; j++, decomp /= 2)
      sv[j] = decomp % 2;  // 1 if add 0 if subtract
    for (int j = 0; j < m; j++) {
      if (su[j] && sv[j])
        printf("R");
      else if (!su[j] && sv[j])
        printf("D");
      else if (su[j] && !sv[j])
        printf("U");
      else if (!su[j] && !sv[j])
        printf("L");
    }
    if (odd_even == 1)
      printf("R");
    printf("\n");
  }
    
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<stdio.h>
#include<string>
#include<vector>
#include<map>
#include<tuple>
#include<algorithm>
#include<cmath>
#include<limits>
#include<set>
#include<queue>
using namespace std;
#define int long  long int
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }
typedef pair<int, int>P;
const int INF = 1e8;

signed main() {
	string a, b;
	cin >> a >> b;
	a += b;
	int num = stoi(a);
	for (int i = 1; i * i <= num; i++) {
		if (num == i * i) {
			cout << "Yes";
			return 0;
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
 
using namespace std;
 
struct node{
 
	long long int a,b;
 
};
 
bool cmp(node e,node f)
 
{
 
	if(e.a!=f.a)
 
	return e.a<f.a;
 
	else
 
	return e.b>f.b;
 
}
 
int main(){
 
long long int n,m,y=0;
 
cin>>n>>m;
 
node d[n+1];
 
for(int i=1;i<=n;i++)
 
cin>>d[i].a>>d[i].b;
 
sort(d+1,d+n+1,cmp);
 
for(int i=1;i<=n;i++){
 
	if(d[i].b<m)
 
	{
 
		y+=d[i].a*d[i].b;
 
		m-=d[i].b;
 
	}
 
	else
 
	{
 
		y+=d[i].a*m;
 
		break;
 
	}
 
}
 
cout<<y;
  return 0;
}

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

const int mod = 1000000007;

int main() {
	
	int n,m;
	cin >> n >> m;
	vector<int> a(m);
	for(auto &i : a) cin >> i;
	vector<int> dp(n+1);
	
	for(int i=0; i<m; i++){
		dp.at(a.at(i))=-1;
	}
	
	dp.at(0)=1;
	for(int i=0; i<=n-2; i++){
		if(dp.at(i)!=-1 && dp.at(i+1)!=-1) {
			dp.at(i+1)+=dp.at(i);
			dp.at(i+1)%= mod;
		}
		if(dp.at(i)!=-1 && dp.at(i+2)!=-1) {
			dp.at(i+2)+=dp.at(i);
			dp.at(i+2)%= mod;
		}
	}
	if(dp.at(n-1)!=-1 && dp.at(n)!=-1) {
		dp.at(n)+=dp.at(n-1);
		dp.at(n)%= mod;
	}
	
	cout << dp.at(n) << endl;
	
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<cstdlib>
#include<algorithm>
using namespace std;
int main() {
	int n, l,m=10000; cin >> n >> l;
	for (int i = l; i < l + n; i++) {
		m = min(abs(m), abs(i));
	}
	if ((2 * l + n - 1) * n / 2 > 0)cout << -m + (2 * l + n - 1) * n / 2 << endl;
	else cout << m + (2 * l + n - 1) * n / 2 << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <complex>
#include <sstream>
#include <string>
#include <algorithm>
#include <deque>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <vector>
#include <set>
#include <limits>
#include <cstdio>
#include <cctype>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <ctime>
using namespace std;
#define REP(i, j) for(int i = 0; i < (int)(j); ++i)
#define FOR(i, j, k) for(int i = (int)(j); i < (int)(k); ++i)
#define SORT(v) sort((v).begin(), (v).end())
#define REVERSE(v) reverse((v).begin(), (v).end())
const double EPS = 1e-12;
const double INF = 1e12;
#define EQ(a,b) (abs((a)-(b)) < EPS)
typedef complex<double> P;
const int MAX_N = 105;
#define DEBUG

struct C {
  P p; double r;
  C(const P &p, double r) : p(p), r(r) { }
};

struct L : public vector<P> {
  L(const P &a, const P &b) {
    push_back(a); push_back(b);
  }
};

vector<P> crosspointCC(const C &c1, const C &c2){
  vector<P> res;
  double d = abs(c1.p - c2.p);
  double rc = (d * d + c1.r * c1.r - c2.r * c2.r) / (2 * d);
  double dfr = c1.r * c1.r - rc * rc;
  if(EQ(dfr, 0.0)) dfr = 0.0;
  else if(dfr < 0.0) return res;
  double rs = sqrt(dfr);

  P diff = (c2.p - c1.p) / d;
  res.push_back(c1.p + diff * P(rc, rs));
  res.push_back(c1.p + diff * P(rc, -rs));
  return res;
}

double cross(const P& a, const P& b) {
  return imag(conj(a)*b);
}

double dot(const P& a, const P& b) {
  return real(conj(a)*b);
}

int ccw(P a, P b, P c) {
  b -= a; c -= a;
  if (cross(b, c) > 0)   return +1;       // counter clockwise
  if (cross(b, c) < 0)   return -1;       // clockwise
  if (dot(b, c) < 0)     return +2;       // c--a--b on line
  if (norm(b) < norm(c)) return -2;       // a--b--c on line
  return 0;
}

bool intersectSS(const L &s, const L &t) {
  return ccw(s[0],s[1],t[0])*ccw(s[0],s[1],t[1]) <= 0 &&
    ccw(t[0],t[1],s[0])*ccw(t[0],t[1],s[1]) <= 0;
}

double dist(P &a, P &b, vector<L> &ls, int s, int t){
  L l = L(a, b);
  FOR(i, s, t) if(!intersectSS(l, ls[i])) return INF;
  return abs(a - b);
}

int main() {
  int N;
  while(cin >>N && N){
    vector<P> ps;
    vector<L> ls;
    int bx, by, br, x, y, r;
    scanf("%d %d %d", &bx, &by, &br);
    ps.push_back(P(bx, by));
    FOR(i, 1, N){
      scanf("%d %d %d", &x, &y, &r);
      vector<P> cs = crosspointCC(C(P(bx, by), br), C(P(x, y), r));
      REP(j, cs.size()) ps.push_back(cs[j]);
      ls.push_back(L(cs[0], cs[1]));
      bx = x;
      by = y;
      br = r;
    }
    ps.push_back(P(bx, by));
    int psize = ps.size();
    vector< vector<double> > d(psize, vector<double>(psize, INF));
    REP(i, psize) FOR(j, i + 1, psize) d[i][j] = d[j][i] = dist(ps[i], ps[j], ls, (i + 1 == psize ? (int)ls.size() : (i - 1) / 2), (j + 1 == psize ? (int)ls.size() : (j - 1) / 2 + 1));
    vector<double> dp(psize, INF);
    dp[0] = 0.0;
    REP(i, psize){
      if(dp[i] == INF) continue;
      FOR(j, i + 1, psize){
        if(d[i][j] == INF) continue;
        dp[j] = min(dp[j], dp[i] + d[i][j]);
      }
    }
    printf("%.6lf\n", dp[psize - 1]);
  }
  return 0;
}

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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(n, k);
    for (int i = 0; i < q; i++) {
        int w;
        cin >> w;
        a[w - 1]++;
    }
    for (int i = 0; i < n; i++) {
        cout << (a[i] - q <= 0 ? "No" : "Yes") << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
n, q = map(int, input().split())
query = [list(map(int, input().split())) for _ in range(q)]

ans = (n - 2)** 2
c, wh = [n - 2, n - 2], [[None] * (n - 2), [None] * (n - 2)]
for num, x in query:
    num, x = num - 1, x - 2
    if c[num] > x:
        for i in range(x, c[num]):
            wh[num][i] = c[1 - num]
        c[num] = x
    ans -= wh[num][x]
    wh[num][x] = 0
print(ans)


Measured memory_bytes: 114072
def solve():
  N = int(input())
  k = 1
  while N>pow(26,k):
    N -= pow(26,k)
    k += 1
  ans = ''
  N -= 1
  for i in range(k,1,-1):
    ans += chr(ord('a')+N//pow(26,i-1))
    N%=pow(26,i-1)
  ans += chr(ord('a')+N%26)
  return ans
print(solve())

Measured memory_bytes: 9192
A = int(input())
B = int(input())
C = int(input())
X = int(input())

count = 0

for a in range(A+1):
    for b in range(B+1):
        for c in range(C+1):
            if 500*a + 100*b + 50*c == X:
                count += 1
    
print(count)

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

using namespace std;


int main() {
  #ifdef LOCAL
  freopen("sol.in", "r", stdin);
  freopen("sol.out", "w+", stdout);
  #endif
  ios_base::sync_with_stdio(false);
  cin.tie(0);
  int n, m;
  cin >> n >> m;
  vector<vector<int>> g(n);
  for (int i = 0; i < m; i++) {
    int a, b;
    cin >> a >> b;
    g[a - 1].push_back(b - 1);
  }
  vector<int> dp(n);
  function<int(int)> solve = [&](int v) {
    if (dp[v] > 0) {
      return dp[v];
    }
    int ret = 0;
    for (int& u : g[v]) {
      ret = max(ret, 1 + solve(u));
    }
    return dp[v] = ret;
  };
  int ans = 0;
  for (int i = 0; i < n; i++) {
    dp[i] = solve(i);
    ans = max(ans, dp[i]);
  }
  cout << ans << '\n';
  return 0;
}

Measured memory_bytes: 8832
/* Manish Pant - insider_pants */

#include <bits/stdc++.h>
using namespace std;
#ifndef ONLINE_JUDGE
    #include "debug.h"
#endif

#define F first
#define S second
#define endl "\n"
#define pb push_back
typedef long long ll;
typedef long double ldob;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;

void fast()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
}

const int N = 1e6 + 5;
vector<int> val;
vector<int> v(N);
int n;

void solve()
{
    int gcd = 0;
    for(int i : val)
    {
        v[i]++;
        gcd = __gcd(gcd, i);
    }

    if(gcd != 1)
    {
        cout << "not coprime\n";
        return;
    }

    for(int i = 2; i < N; i++)
    {
        for(int j = i + i; j < N; j += i)
            v[i] += v[j];
        
        if(v[i] > 1)
        {
            cout << "setwise coprime\n";
            return;
        }
    }

    cout << "pairwise coprime\n";
}

int main()
{
    fast();
    cin >> n;
    for(int i = 0; i < n; i++)
    {
        int a; cin >> a;
        val.pb(a);
    }
    solve();
}

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

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

long long MOD = 1000000000 + 7;

int main(){
  int N;
  ll K;
  cin >> N >> K;
  int log_K = floor(log2(K));
  // cerr << N << " " << log_K << endl;
  vector<vector<int>> next(log_K + 1, vector<int>(N));

  for(int i = 0; i < N; i++){
    int tmp;
    cin >> tmp;
    // cerr << i << " : " << tmp << endl;
    next.at(0).at(i) = tmp-1;
  }

  for(int k = 0; k < log_K; k++){
    for(int i = 0; i < N; i++){
      if(next[k][i] == -1){
        next[k+1][i] = -1;
      } else { 
        next[k+1][i] = next[k][next[k][i]];
        // cerr << k+1 << " " << i << " " << next[k+1][i] << endl;
      }
    }
  }

  int ans = 0;
  for(ll k = log_K; k >= 0; k--){
    if((K>>k)&1){
      ans = next[k][ans];
    }
  }
  cout << ans+1<< endl;

}

Measured memory_bytes: 51280
import java.util.*;


public class Main {
	public static void main(String[] args){
	
		Scanner sc = new Scanner(System. in);
		String line = sc.nextLine();
		char[] str = line.toCharArray();
		int n = line.length();
				
		char[] rts = new char[20];
		
		for(int i=0;i<n;i++){
			rts[i]=str[n-i-1];
		}
		
		for(int i=0;i<n;i++){
		System.out.print(rts[i]);
		}
		System.out.println();
	}
}




Measured memory_bytes: 26020
#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 - 1; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define FORR(i,m,n) for(int i = m - 1; i >= n; i--)
#define ALL(v) v.begin(), v.end()
#define itn int
#define Yes() cout << "Yes" << endl
#define No() cout << "No" << endl
#define YES() cout << "YES" << endl
#define NO() cout << "NO" << endl
#define println(x) cout << x << endl
#define print(x) cout << x << " "
template<typename T, typename U>
inline bool CMAX(T &m, U x) { if (m < x) { m = x; return true; } return false; }
template<typename T, typename U>
inline bool CMIN(T &m, U x) { if (m > x) { m = x; return true; } return false; }

typedef long long lint;
typedef long double ldouble;
const int INF = 1e9;
const lint LINF = 1e18;
const int MOD = 1e9+7;

vector<lint> g;
vector<lint> p;
void init(int n){
    REP(i,n) {g[i] = i; p[i] = 1;}
}

int root(int x){
    if(g[x] == x) return x;
    else return g[x] = root(g[x]);
}
bool unite(int x,int y){
    x = root(x);
    y = root(y);
    if(x == y) return false;
    if(p[x] < p[y]) swap(x,y);
    p[x] += p[y];
    g[y] = x;
    return true;
    
}
int len(int x){
    return p[root(x)];
}
bool same(int x,int y){
    return root(x) == root(y);
}
int main(){
    int n,m;
    cin >> n >> m;
    g = vector<lint>(n);
    p = vector<lint> (n);
    vector<pair<int,int>> hasi(m);
    vector<lint> ans(m);
    REP(i,m){
        int a,b;
        cin >> a >>b;
        a--;b--;
        hasi[i].first = a;
        hasi[i].second = b;
    }
    init(n);
    ans[m - 1] = (lint(n)*lint((n - 1))) / 2;
    REPR(i,m){
        if(i == 0) break;
        if(same(hasi[i].first,hasi[i].second)){
            ans[i - 1] = ans[i];
            unite(hasi[i].first,hasi[i].second);
        }else{
            ans[i - 1] = ans[i] - lint(len(hasi[i].first)) * lint(len(hasi[i].second));
            unite(hasi[i].first,hasi[i].second);
        }
    }
    REP(i,m) println(ans[i]);
    return 0;
}

Measured memory_bytes: 4480
#include<bits/stdc++.h>
using namespace std;
int main()
{
  string S,T;
  cin>>S>>T;
  int ans=100000;
  for(int i=0;i<=S.length()-T.length();i++)
  {
    int cnt=0;
    for(int j=0;j<T.length();j++)
      if(S[i+j]!=T[j])
        cnt++;
    ans=min(ans,cnt);
  }
  cout<<ans<<endl;
  return 0;
}

Measured memory_bytes: 3644
import sys
import collections
import copy
import math
def input(): return sys.stdin.readline().strip()
N = int(input())
A = [int(i) for i in input().split()]
B = [int(i) for i in input().split()]
C = [int(i) for i in input().split()]
ans = sum(B)
for i in range(N-1):
    if A[i+1] -A[i] == 1:
        ans += C[A[i]-1]
print(ans)


Measured memory_bytes: 38384
#include<cstdio>
using ull = unsigned long long;

int main(){
    ull N;
    scanf("%llu", &N);
    ull last = 0, power = 26, digit = 0;
    while(last < N){
        last += power;
        digit++;
        power *= 26;
    }
    last -= (power /= 26);
    power /= 26;
    for (size_t i = 0; i < digit; i++){
        printf("%c", 'a' + (N - last - 1)/power);
        N -= ((N-last-1)/power + 1)*power;
        last -= power;
        power /= 26;
    }
    printf("\n");
	return 0;
}

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

typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pair<int, int> > vii;
#define rrep(i, m, n) for(int (i)=(m); (i)<(n);  (i)++)
#define erep(i, m, n) for(int (i)=(m); (i)<=(n); (i)++)
#define  rep(i, n)    for(int (i)=0; (i)<(n);  (i)++)
#define rrev(i, m, n) for(int (i)=(n)-1; (i)>=(m); (i)--)
#define erev(i, m, n) for(int (i)=(n); (i)>=(m); (i)--)
#define  rev(i, n)    for(int (i)=(n)-1; (i)>=0; (i)--)
#define vrep(i, c)    for(__typeof((c).begin())i=(c).begin(); i!=(c).end(); i++)
#define  ALL(v)       (v).begin(), (v).end()
#define mp            make_pair
#define pb            push_back
template<class T, class S> inline bool minup(T& m, S x){ return m>(T)x ? (m=(T)x, true) : false; }
template<class T, class S> inline bool maxup(T& m, S x){ return m<(T)x ? (m=(T)x, true) : false; }

const int    INF = 1000000000;
const ll     MOD = 1000000007LL;
const double EPS = 1E-12;

int n, m;
int s, t, c, d;
int dp[500][500];

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

  rep(i, n) rep(j, n) dp[i][j] = INF;
  rep(i, n) dp[i][i] = 0;
  rep(i, m){
    scanf("%d,%d,%d,%d", &s, &t, &c, &d);
    dp[s - 1][t - 1] = c;
    dp[t - 1][s - 1] = d;
  }

  scanf("%d,%d,%d,%d", &s, &t, &c, &d);
  rep(k, n) rep(i, n) rep(j, n) minup(dp[i][j], dp[i][k] + dp[k][j]);

  cout << c - d - dp[s - 1][t - 1] - dp[t - 1][s - 1] << endl;

  return 0;
}

Measured memory_bytes: 1272
N = int(input())
dp = [[0]*10 for _ in range(10)]
for a in range(N+1):
    A = str(a)
    dp[int(A[0])][int(A[-1])] += 1
ans = 0
for i in range(1,10):
    for j in range(1,10):
        ans += dp[i][j]*dp[j][i]
print(ans)

Measured memory_bytes: 73396
n,T=map(int,input().split())
st=[list(map(int,input().split())) for _ in range(n)]
st=sorted(st,key=lambda x:(x[0],x[1]))
for i in range(n):
  if st[i][1]<=T:
    print(st[i][0])
    exit()
print('TLE')

Measured memory_bytes: 3060
def typing(s) : 
  t = list()
  for i in range(len(s)) :
    if s[i] == '0' :
      t.append('0')
    elif s[i] == '1' : 
      t.append('1')
    else : 
      if len(t) > 0 :
         t.pop()
     
  return t

s = input()
ans = "".join(typing(s))
print(ans)


Measured memory_bytes: 3060
n = 0
g = []
res = 0


def dfs(i, path):
    global n, g, res
    path.append(i)
    if len(path) == n:
        res += 1
        path.pop()
        return

    for j in g[i]:
        if not j in path:
            dfs(j, path)
    path.pop()


def main():
    global n, g, res
    n, m = map(int, input().split())
    g = [set() for _ in range(n)]
    for _ in range(m):
        a, b = map(lambda s: int(s) - 1, input().split())
        g[a].add(b)
        g[b].add(a)

    path = []
    dfs(0, path)
    print(res)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3064
// digit dp (keep track if below some threshold number in state)
// https://atcoder.jp/contests/dp/tasks/dp_s

#include <bits/stdc++.h>
using namespace std;

using ll = long long;
#define rep(i, a, b) for(auto i = (a); i < (b); ++i)
#define sz(x) (int)(x).size()

const int MOD = 1000000007;
const int MAXD = 10000;
const int MAXK = 100;
ll dp[MAXD + 5][MAXK][2]; // # digits, modulo k, isbelow

void add(auto& a, auto b){a = (a + b) % MOD;}

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

  string s;
  cin >> s;
  int k;
  cin >> k;
  int n = sz(s);
  dp[0][0][0] = 1;
  rep(i, 0, n) {
    rep(j, 0, k) {
      rep(c, '0', '9' + 1) {
        rep(below, 0, 2) {
          if (!below and c > s[i]) continue;
          int j2 = (j + (c - '0')) % k;
          bool below2 = below || c < s[i];
          add(dp[i + 1][j2][below2], dp[i][j][below]);
        }
      }
    }
  }
  dp[n][0][1] = (dp[n][0][1] - 1 + MOD) % MOD; // exclude 0...00 since it's not a valid answer
  cout << (dp[n][0][1] + dp[n][0][0]) % MOD << '\n';
}


Measured memory_bytes: 15872
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
    string  A,B,C;
    int N=0, Count=0;
    cin >> N >> A >> B >> C;

    for(int i=0;i<N;++i){
        if (A[i]!=B[i]&&A[i]!=C[i]&&B[i]!=C[i]){
            Count += 2;
        }else if(A[i]==B[i]&&A[i]==C[i]&&B[i]==C[i]){
        }else{
            ++Count;
        }
    }
    cout << Count << endl;
}

Measured memory_bytes: 256
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六 12/15 20:56:50 2018

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

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;

inline void OPEN(string s){
	freopen((s + ".in").c_str(), "r", stdin);
	freopen((s + ".out").c_str(), "w", stdout);
}

#define fir first
#define sec second

const int MAXN = 2e5;
PII a[MAXN+5];

int main()
{
	int h, w; scanf("%d %d", &h, &w);
	int n; scanf("%d", &n);
	for(int i = 1; i <= n; i++){
		int x, y; scanf("%d %d", &x, &y);
		a[i] = PII(x, y);
	}
	sort(a + 1, a + 1 + n);
	for(int dis = 1, y = 0, i = 1; dis <= h; dis++){
		bool flag = false;
		for(; i <= n; ){
			if(a[i].fir < dis) i++;
			else if(a[i].fir > dis) break;
			else{
				if(a[i].sec <= y){
					printf("%d\n", dis-1);
					return 0;
				}
				else if(a[i].sec == y + 1) flag = true;
				i++;
			}
		}
		if(!flag) y++;
	}
	printf("%d\n", h);
    return 0;
}


Measured memory_bytes: 1792
#include <cstdlib>
#include <cctype>
#include <cstring>
#include <cstdio>
#include <cmath>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <sstream>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <fstream>
#include <numeric>
#include <iomanip>
#include <bitset>
#include <list>
#include <stdexcept>
#include <functional>
#include <utility>
#include <ctime>
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;;
#define MEM(a,b) memset((a),(b),sizeof(a))
const LL INF = 1e9 + 7;
const int N = 1e3 + 10;
vector<int> v[N];
vector<int> vp;
int in[N], s[N], top;
int cnt = 0;
int dfn[N], low[N];
int flag[N];
int tot = 0;
void dfs(int x)
{
	dfn[x] = low[x] = ++cnt;
	in[x] = 1;
	s[top++] = x;
	for (auto y : v[x])
	{
		if (flag[y]) continue;
		if (dfn[y])
		{
			if (in[y])
				low[x] = min(low[x], dfn[y]);
		}
		else
		{
			dfs(y);
			low[x] = min(low[x], low[y]);
		}
		if (tot > 1) return;
	}
	if (tot > 1) return;
	if (dfn[x] == low[x])
	{
		tot = 0;
		while (1)
		{
			int y = s[--top];
			tot++;
			in[y] = 0;
			if (y == x) break;
		}
	}
}

bool solve(int n)
{
	MEM(in, 0);
	MEM(dfn, 0);
	top = 0;
	cnt = 0;
	tot = 0;
	for (int i = 1; i <= n; i++)
	{
		int x = i;
		if (flag[x]) continue;
		if (dfn[x]) continue;
		dfs(x);
	}
	if (tot <= 1) return false;
	return true;
}
int main()
{
	//freopen("input.txt", "r", stdin);
	//freopen("output.txt", "w", stdout);
	int n, m;
	cin >> n >> m;
	while (m--)
	{
		int x, y;
		cin >> x >> y;
		v[x].push_back(y);
	}
	if (!solve(n))
	{
		puts("-1");
		return 0;
	}

	for (int i = 1; i <= n; i++)
	{
		flag[i] = 1;
		if (!solve(n))
		{
			flag[i] = 0;
			vp.push_back(i);
		}
	}
	printf("%d\n", vp.size());
	for (auto& x : vp) printf("%d\n", x);
	return 0;
}

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

#define fastio 			ios::sync_with_stdio(0);	cin.tie(0); cout.tie(0);  cout<<fixed;  cout<<setprecision(12);
#define randomINT 		mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#define	newl 			cout<<"\n"
#define DISP(as)		for(auto it : as) cout<<it<<" ";newl;
#define all(x)         	(x).begin(),(x).end()
#define mset(x,val)    	memset(x,val,sizeof(x))
#define newl           	cout<<"\n"
#define pb             	push_back
#define mp             	make_pair
#define f 				first
#define s 				second
#define dline          cerr<<"///REACHED///\n";
#define deb1(x)        cerr<<#x<<" = "<<x<<'\n';
#define deb2(x,y)      cerr<<'['<<#x<<','<<#y<<"] = "<<'['<<x<<','<<y<<']'<<'\n';
#define deb3(x,y,z)    cerr<<'['<<#x<<','<<#y<<','<<#z<<"] = "<<'['<<x<<','<<y<<','<<z<<']'<<'\n';

typedef long long 				ll;
typedef long double 			ld;
typedef vector<ll> 				vll;
typedef pair<ll , ll> 			pll;
typedef pair<ld, ld> 			pld;
typedef unordered_map<ll, ll> 	um;
typedef vector<pll> 			vpll;

const ll 	MAX5 	= 	1e+5 + 7;
const ll 	MAX7 	= 	1e+7 + 7;
const ll 	MAXN 	= 	MAX7;
const ll   	INF   	=  	0x7f7f7f7f7f7f7f7f;
const int  	INFi 	=  	0x7f7f7f7f;
const ll 	MOD		=  	1000000007;

// <------------- Declare Variables Here ------------> //

ll T = 1;
ll n, q, x, K;
string s,t;

// <------------- Implement Functions Here ----------> //

// <------------- Start of main() -------------------> //

void MAIN() {
	cin>>n;
	n = sqrt(n);
	cout<<n*n;
}


int main() {
	fastio; randomINT;
	//cin >> T;
	while (T--) {
		MAIN();
	}
	return 0;
}


Measured memory_bytes: 3692
#include<bits/stdc++.h>
#define INF 1<<28
using namespace std;

int n, m, x;
int book[22][22]; //0:cost, 1~ algorithm
int memo[1<<15][15];

bool check(int bit){

  int algo[22];
  memset(algo, 0, sizeof(algo));

  for(int i=0;i<n;i++){
    if(bit&(1<<i)){
      for(int j=0;j<m;j++) algo[j] += book[i][j+1];
    }
  }

  bool ok = true;
  for(int i=0;i<m;i++) if(algo[i] < x) ok = false;

  return ok;
}


int dfs(int bit, int p){

  if(~memo[bit][p]) return memo[bit][p];

  if(p == n){
      if(check(bit)) return memo[bit][p] = 0;
      else return memo[bit][p] = INF;
  }

  return memo[bit][p] = min(dfs(bit|1<<p, p+1)+book[p][0], dfs(bit, p+1));

}

int main(){

  cin >> n >> m >> x;
  for(int i=0;i<n;i++){
    cin >> book[i][0];
    for(int j=0;j<m;j++) cin >> book[i][j+1];
  }

  memset(memo, -1, sizeof(memo));
  int ans = dfs(0, 0);
  if(ans >= INF) cout << -1 << endl;
  else cout << ans << endl;

}


Measured memory_bytes: 5552
from decimal import Decimal, ROUND_HALF_UP
n=int(input())
for i in range(n):
    x1,y1,x2,y2,x3,y3=map(float,input().split())
    a=2*(x1-x2)
    b=2*(y1-y2)
    c=x1**2+y1**2-x2**2-y2**2
    d=2*(x1-x3)
    e=2*(y1-y3)
    f=x1**2+y1**2-x3**2-y3**2
    x=(c*e-b*f)/(a*e-b*d)+0.0
    y=(c*d-a*f)/(b*d-a*e)+0.0
    r=((x-x1)**2+(y-y1)**2)**0.5
    print(Decimal(str(x)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(y)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP),Decimal(str(r)).quantize(Decimal('0.001'), rounding=ROUND_HALF_UP))


Measured memory_bytes: 6452
N=int(input())
T=list(map(int,input().split()))
V=list(map(int,input().split()))
S=sum(T)
v=[0]*(sum(T)*2+1)
def f(x,l,r,vmax):
    if x<l:
        return vmax+(l-x)
    elif l<=x<=r:
        return vmax
    else:
        return vmax+(x-r)
for i in range(S*2+1):
    l=0
    r=0
    v[i]=f(i*0.5,l,r,0)
    for j in range(N):
        r+=T[j]
        v[i]=min(v[i],f(i*0.5,l,r,V[j]))
        l=r

    v[i]=min(v[i],f(i*0.5,l,r,0))
ans=0
for i in range(S*2):
    ans+=(v[i+1]+v[i])*0.25
print(ans)


Measured memory_bytes: 44892
#include <bits/stdc++.h>                                                                                                                                                                       
using namespace std;                                                                                                                                                                           
                                                                                                                                                                                               
int main(){                                                                                                                                                                                    
                                                                                                                                                                                               
        string n;                                                                                                                                                                              
        cin >> n;                                                                                                                                                                              
        if(n[0] == '7' || n[1] == '7' || n[2] == '7'){                                                                                                                                         
                cout << "Yes";                                                                                                                                                                 
        } else {                                                                                                                                                                               
                cout << "No";                                                                                                                                                                  
        }                                                                                                                                                                                      
                                                                                                                                                                                               
        return 0;                                                                                                                                                                              
}        

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

#define M 1046527
#define L 14

char H[M][L];

int getChar(char ch) {
    if (ch == 'A')
        return 1;
    else if (ch == 'C')
        return 2;
    else if (ch == 'G')
        return 3;
    else if (ch == 'T')
        return 4;
    else
        return 0;
}

long long getKey(char str[]) {
    long long sum = 0, p = 1, i;
    for (i = 0; i < strlen(str); i++) {
        sum += p*(getChar(str[i]));
        p *= 5;
    }
    return sum;
}

int h1(int key) {
    return key % M;
}

int h2(int key) {
    return 1 + (key % (M - 1));
}

int find(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) return 0;
    }
    return 0;
}

int insert(char str[]) {
    long long key, i, h;
    key = getKey(str);
    for (i = 0; ; i++) {
        h = (h1(key) + i * h2(key)) % M;
        if (strcmp(H[h], str) == 0) return 1;
        else if (strlen(H[h]) == 0) {
            strcpy(H[h], str);
            return 0;
        }
    }
}

int main()
{
    int i, n, h;
    char str[L], com[9];

    for (i = 0; i < M; i++)
        H[i][0] = '\0';

    scanf("%d", &n);

    for (i = 0; i < n; i++) {
        scanf("%s %s", com, str);

        if (com[0] == 'i') {
            insert(str);
        }
        else {
            if (find(str))
                printf("yes\n");
            else
                printf("no\n");
        }
    }
    return 0;
}

Measured memory_bytes: 16032
#define _CRT_SECURE_NO_WARNINGS
#include<bits/stdc++.h>
#define fi first
#define se second
#define pb push_back
#define E "\n"

using namespace std;
const long long MOD = (long long)1e9 + 7;

int a, b;

int main()
{
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cin >> a >> b;
    int ans = 6;
    ans -= a;
    ans -= b;
    cout << ans << E;
    //system("pause");
    return 0;
}

Measured memory_bytes: 256