akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
using namespace std;


int main(){

    char a;

    cin >> a;
    


    if(a>='a'){ cout << "a" << endl; /*cout << a-'a' << endl;*/}
    else{ cout << "A" << endl; /*cout << a-'a' << endl;*/}

    return 0;
}


Measured memory_bytes: 3620
n, m = map(int, input().split())
ac = [False] * n
wa = [0] * n
for _ in range(m):
    p, s = input().split()
    p = int(p)
    if s == "AC" and ac[p-1] == False:
        ac[p-1] = True
    elif s == "WA" and ac[p-1] == False:
        wa[p-1] += 1
a = 0
w = 0
for i in range(n):
    if ac[i]:
        a += 1
        w += wa[i]
print(a, w)

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

#define forn(i, n) for (int i = 0; i < int(n); ++i)
#define for1(i, n) for (int i = 1; i <= int(n); ++i)
#define F first
#define S second
#define all(x) (x).begin(),(x).end()
#define sz(x) int(x.size())
#define pb push_back

using namespace std;
using ll=long long;
using pii= pair<int, int>;
mt19937 gen(chrono::steady_clock::now().time_since_epoch().count());
template<typename... T> void rd(T&... args) {((cin>>args), ...);}
template<typename... T> void wr(T... args) {((cout<<args<<" "), ...);cout<<endl;}

int n;
ll k;
const int mod=1e9+7;
struct MAT{
    ll a[55][55];
};
MAT mul(MAT &a,MAT &b){
    MAT c;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j){
            c.a[i][j]=0;
            for(int k=1;k<=n;++k)(c.a[i][j]+=a.a[i][k]*b.a[k][j])%=mod;
        }
    }
    return c;
}
int main(){
    cin>>n>>k;
    MAT x,ans;
    memset(ans.a,0,sizeof(ans.a));
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)cin>>x.a[i][j];
        ans.a[i][i]=1;
    }
    while(k){
        if(k&1)ans=mul(x,ans);
        k>>=1,x=mul(x,x);
    }
    ll out=0;
    for(int i=1;i<=n;++i){
        for(int j=1;j<=n;++j)out+=ans.a[i][j];
    }
    cout<<out%mod<<endl;
	//system("pause");
	return 0;
}


Measured memory_bytes: 3736
#include<bits/stdc++.h>
using namespace std;
long long int t[101][100001];
long long int solve(int wt[],int val[],int n,int w)
{
    if(n==0||w==0)
        return 0;
    if(t[n][w]!=-1)
        return t[n][w];
    else
    {
        if(wt[n-1]<=w)
        return t[n][w]=max(val[n-1]+solve(wt,val,n-1,w-wt[n-1]),solve(wt,val,n-1,w));
        else
            return t[n][w]=solve(wt,val,n-1,w);
    }
}
int main()
{
    memset(t,-1,sizeof(t));
    int n,w;
    cin>>n>>w;
    int wt[n],val[n];
    for(int i=0;i<n;i++)
    {
        cin>>wt[i]>>val[i];
    }
    for(int i=0;i<102;i++)
        for(int j=0;j<100002;j++)
    {
        if(i==0||j==0)
            t[i][j]=0;
    }
    cout<<solve(wt,val,n,w)<<endl;
}


Measured memory_bytes: 79232
import java.util.*;

public class Main{
public static void main(String[] args)
{
	Scanner sc=new Scanner(System.in);
  int n=sc.nextInt();
  n=n%10;
  
  if(n==2|| n==4 ||n==5|| n==7||n== 9)
    System.out.println("hon");
  else if(n==0 || n==1|| n==6|| n==8)
    System.out.println("pon");
  else
    System.out.println("bon");
}
}


Measured memory_bytes: 35792
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;++i)
#define rrep(i,n) for(int i=(int)n-1;i>=0;--i)
using namespace std;
using ll = long long;
template<typename T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<typename T> inline bool chmin(T& a,T b){if(b<a){a=b;return 1;}return 0;}
template<typename T> vector<T> make_vec(size_t a){return vector<T>(a);}
template<typename T,typename... Ts>
auto make_vec(size_t a,Ts... ts){return vector<decltype(make_vec<T>(ts...))>(a,make_vec<T>(ts...));}
template<typename T,typename U,typename... V>
typename enable_if<is_same<T,U>::value>::type fill_v(U& u,const V... v){u=U(v...);}
template<typename T,typename U,typename... V>
typename enable_if<!is_same<T,U>::value>::type fill_v(U& u,const V... v){for(auto& e:u)fill_v<T>(e,v...);}

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

    int a, b, c;
    cin >> a >> b >> c;
    cout << (a^b^c) << endl;
}


Measured memory_bytes: 3624
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#include<stdint.h>
#include<tgmath.h>
#include<stdbool.h>
#include<sys/queue.h>
#include<time.h>
#define ll long long
#define min(a, b) ((a) > (b) ? (b) : (a))
#define max(a, b) ((a) > (b) ? (a) : (b))

int x, n, p, q[111];
int main(){
    scanf("%d%d", &x, &n);
    for(int i=0; i<n; i++){
        scanf("%d", &p);
        q[p]++;
    }
    int ans=-1001001;
    for(int i=0; i<=101; i++){
        if(!q[i] && abs(x-ans) > abs(x-i)){
            ans = i;
        }
    }
    printf("%d\n", ans);
    return 0;
}

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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vdb = vector<db>;
using vvll = vector<vll>;
using vst = vector<st>;
using vchar = vector<char>;
using pll = pair<ll, ll>;
using vpll = vector<pll>;
using vvpll = vector<vpll>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
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;}
ll mod = 1000000007;

int main(){
  ll n, k;
  cin >> n >> k;
  vll h(n);
  vin(h);
  vll dp(n, mod);
  dp.at(0) = 0;
  rep(i, 0, n)rep(j, max(0ll, i - k), i) chmin(dp.at(i), dp.at(j) + abs(h.at(i) - h.at(j)));
  cout << dp.at(n - 1) << endl;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep2(i, m, n) for(int i=int(m); i<int(n); ++i)
#define drep2(i, m, n) for(int i=int(m-1); i>=int(n); --i)
#define rep(i, n) rep2(i, 0, n)
#define drep(i, n) drep2(i, n, 0)
#define all(a) a.begin(), a.end()
using ll = long long;
using ld = long double;
using V = vector<int>;
using Vll = vector<ll>;
using Vld = vector<ld>;
using Vbo = vector<bool>;
using VV = vector<V>;
using VVll = vector<Vll>;
using VVld = vector<Vld>;
using VVbo = vector<Vbo>;
using P = pair<int, int>;
using Pll = pair<ll, ll>;
using Pld = pair<ld, ld>;
struct fast_ios { fast_ios(){ cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(20); }; } fast_ios_;
template<typename T> inline bool chmin(T &a, T b) { if (a > b) { a = b; return true; } return false; }
template<typename T> inline bool chmax(T &a, T b) { if (a < b) { a = b; return true; } return false; }
template<typename T1, typename T2> istream &operator>>(istream &is, pair<T1, T2> &p) { is >> p.first >> p.second; return is; }
template<typename T1, typename T2> ostream &operator<<(ostream &os, const pair<T1, T2> &p) { os << "(" << p.first << ", " << p.second << ")"; return os; }
template<typename T> istream &operator>>(istream &is, vector<T> &v) { for (auto &e : v) is >> e; return is; }
template<typename T> ostream &operator<<(ostream &os, const vector<T> &v) { for (auto &e : v) os << e << endl; return os; }
template<typename T> inline int count_between(vector<T> &a, T l, T r) { return lower_bound(all(a), r) - lower_bound(all(a), l); } // [l, r)
inline int Log2(ll x) { int k; for (k = 0; x > 0; ++k) x >>= 1; return k; } // number of binary digits
const int INF  = 1<<30;
const ll INFll = 1ll<<62;
const ld EPS   = 1e-10;
const int MOD  = int(1e9)+7;

V c;
Vll ans, sz, dp;

using Graph = vector<vector<int>>;
Graph G;

void dfs(int u, int p=-1) {
  ll tmp = dp[c[u]];
  for (auto v : G[u]) {
    if (v == p) continue;
    dp[c[u]] = 0;
    dfs(v, u);
    sz[u] += sz[v];
    ll x = sz[v] - dp[c[u]];
    ans[c[u]] -= x*(x+1)/2;
  }
  dp[c[u]] = tmp + sz[u];
}

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

  c.assign(n, 0);
  sz.assign(n, 1);
  dp.assign(n, 0);
  ans.assign(n, n*(n+1)/2);

  rep(i, n) {
    cin >> c[i];
    --c[i];
  }

  G.assign(n, V());
  rep(i, n-1) {
    int a, b;
    cin >> a >> b;
    a--; b--;
    G[a].push_back(b);
    G[b].push_back(a);
  }

  dfs(0);
  rep(i, n) {
    ll x = n - dp[i];
    ans[i] -= x*(x+1)/2;
  }

  cout << ans;
  return 0;
}


Measured memory_bytes: 38256
#include<iostream>
#include<algorithm>
using namespace std;
int main()
{
    int a, b, c, x, y, n, ans = 0, cnt = 0;
    cin >> a >> b >> c >> x >> y;
    n = 2*max(x, y);
    ans = a*x+b*y;
    for(int i=2;i <= n;i+=2){
      cnt = max(0, a*(x-i/2)) + max(0, b*(y-i/2)) + c*i;
      if(cnt < ans){
        ans = cnt;
      }
    }

    cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
using ll = long long;
using P = pair<int,int>;
int main()
{
    string s, mae ,usi;
    cin >> s;
    int Q;
    cin >> Q;
    int revcnt = 0;
    rep(i,Q){
        int q;
        cin >> q;
        if (q == 1)revcnt++;
        else{
            int f;
            string c;
            cin >> f >> c;
            if(revcnt%2 == 0){
                if(f == 1)mae   =  c + mae;
                else usi = usi + c;
            }
            else {
                if(f == 1)usi = usi + c;
                else mae = c + mae;
            }

        }

    }
    s = mae + s + usi;
    if(revcnt%2 == 1) reverse(s.begin(),s.end());
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 1512
#include <bits/stdc++.h>
#define ll long long int
#define pb push_back
#define mp make_pair
#define mod 1000000007
#define pi 3.141592653589793
using namespace std;

ll f(ll a, ll b) {
    ll ans = 1;
    ll till = a;
    while (b) {
        if (b % 2) {
            ans *= till;
            ans %= 13;
        }

        till = (till * till) % 13;
        b >>= 1;
    }

    return ans;
}


int main() {
//    cout << setprecision(10);
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);


    string s;
    cin >> s;
    ll n = s.size();
    ll dp[n][13];
    memset(dp, 0, sizeof dp);

    if (s[n - 1] == '?') {
        for (ll i = 0; i < 10; i++) {
            dp[n - 1][i] = 1;
        }
    }

    else {
        dp[n - 1][s[n - 1] - '0'] = 1;
    }

    for (ll i = n - 2; i >= 0; i--) {
        vector<ll> d;
        if (s[i] == '?') {
            for (ll j = 0; j < 10; j++) {
                d.pb(j);
            }
        }

        else {
            d.pb(s[i] - '0');
        }



        for (ll digit : d) {
            for (ll j = 0; j < 13; j++) {
                ll nex = (j - ((digit * f(10, n - 1 - i)) % 13) + 13) % 13;
                if (i + 1 < n) {
                    dp[i][j] = (dp[i][j] + dp[i + 1][nex]) % mod;
                }
            }
        }

    }

    cout << dp[0][5];



}

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

using VS = vector<string>;    using LL = long long;
using VI = vector<int>;       using VVI = vector<VI>;
using PII = pair<int, int>;   using PLL = pair<LL, LL>;
using VL = vector<LL>;        using VVL = vector<VL>;

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))
#define FOR(i, s, e) for (int(i) = (s); (i) < (e); (i)++)
#define FORR(i, s, e) for (int(i) = (s); (i) > (e); (i)--)
//#pragma GCC optimize ("-O3") 
#ifdef YANG33
#include "mydebug.hpp"
#else
#define DD(x) 
#endif
const int INF = 1e9;                          const LL LINF = 1e16;
const LL MOD = 1000000007;                    const double PI = acos(-1.0);
int DX[8] = { 0, 0, 1, -1, 1, 1, -1, -1 };    int DY[8] = { 1, -1, 0, 0, 1, -1, 1, -1 };

/* -----  __MAKE_TIME__  Problem: __PROBLEM__ / Link: __CONTEST_URL__  ----- */
/* ------問題------



-----問題ここまで----- */
/* -----解説等-----



----解説ここまで---- */



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

	LL N, M, R; cin >> N >> M >> R;
	VL a(R);
	FOR(i, 0, R) {
		cin >> a[i];
		a[i]--;
	}
	VVL d(N, VL(N, LINF));
	FOR(i, 0, M) {
		LL a, b, c; cin >> a >> b >> c;
		a--, b--;
		d[a][b] = d[b][a] = min(d[a][b], c);
	}
	FOR(i, 0, N) {
		d[i][i] = 0;
	}
	FOR(k, 0, N)FOR(i, 0, N)FOR(j, 0, N)d[i][j] = min(d[i][j], d[i][k] + d[k][j]);

	LL ans = LINF;
	SORT(a);
	do {
		LL ret = 0;
		FOR(i, 0, R - 1) {
			ret += d[a[i]][a[i+1]];
		}
		ans = min(ans, ret);
	} while (next_permutation(ALL(a)));
	cout << ans << endl;

	return 0;
}


Measured memory_bytes: 640
#include<cmath>
#include<algorithm>
#include<iostream>
#include<vector>
#include<climits>
#include<cfloat>
#define next(P, i) P[(i+1) % P.size()]
using namespace std;

double EPS = 1e-10;

double add(double a, double b){
  if(abs(a+b) < EPS * (abs(a)+abs(b)))return 0;
  return a+b;
}

struct point{
  double x, y;
  point(){}
  point(double x,double y) : x(x) , y(y){}

  point operator - (point p){
    return point(add(x,-p.x), add(y,-p.y));
  }
};

bool cmp_x(const point& p, const point& q){
  if(p.x != q.x)return p.x<q.x;
  return p.y < q.y;
}

double dot(point a, point b) {
  return (a.x * b.x + a.y * b.y);
}

double cross(point a, point b) {
  return (a.x * b.y - a.y * b.x);
}

int is_point_on_line(point a, point b, point c) {
  return cross(b-a, c-a)==0.0 &&
         (dot(b-a, c-a) > -EPS) &&
         (dot(a-b, c-b) > -EPS);
}

int is_intersected_ls(point a1, point a2, point b1, point b2) {

  if(cross(a1-a2,b1-b2)==0){
    return is_point_on_line(a1,a2,b1) || is_point_on_line(a1,a2,b2) 
        || is_point_on_line(b1,b2,a1) || is_point_on_line(b1,b2,a2);
  }
  else {
    return ( cross(a2-a1, b1-a1) * cross(a2-a1, b2-a1) < EPS ) &&
           ( cross(b2-b1, a1-b1) * cross(b2-b1, a2-b1) < EPS );
  }
}

int contain(point p, vector<point> ps){
  point a(p.x,p.y),b(1000000,p.y);

  double ymx=-DBL_MAX,ymn=DBL_MAX;
  for(int i=0;i<ps.size();i++){
    ymx=max(ymx,ps[i].y);
    ymn=min(ymn,ps[i].y);
  }
  if(a.y<=ymn||a.y>=ymx)return 0;

  int cnt1=0;
  for(int i=0;i<ps.size();i++)
    if(is_point_on_line(a,b,ps[i]))cnt1++;
  
  int cnt=0;
  for(int i=0;i<ps.size();i++)
    if(is_intersected_ls(ps[i],next(ps,i),a,b))cnt++;

  return (cnt-cnt1)%2;
}

int crossPol(vector<point> pol1, vector<point> pol2){

  for(int i=0;i<pol1.size();i++)
    if(contain(pol1[i],pol2))return 1;
  
  for(int i=0;i<pol2.size();i++)
    if(contain(pol2[i],pol1))return 1;

  for(int i=0;i<pol1.size();i++)
    for(int j=0;j<pol2.size();j++)
      if(is_intersected_ls(pol1[i],next(pol1,i),pol2[j],next(pol2,j)))return 1;
  
  return 0;
}

vector<point>convex_hull(point* ps, int n){
  sort(ps,ps+n,cmp_x);
  int k=0;
  vector<point>qs(n*2);
 
  for(int i=0;i<n;i++){
    while(k>1&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
 
  for(int i=n-2,t=k;i>=0;i--){
    while(k>t&&cross(qs[k-1]-qs[k-2],ps[i]-qs[k-1])<=0)k--;
    qs[k++]=ps[i];
  }
  qs.resize(k-1);
  return qs;
}

int main(void){
  int n,m;
  point black[100],white[100];

  while(cin >> n >> m,n|m){

    for(int i=0;i<n;i++)
      cin >> black[i].x >> black[i].y;
    
    for(int i=0;i<m;i++)
      cin >> white[i].x >> white[i].y;

    if(n<2||m<2){
      if(n<2 && m<2)cout << "YES" << endl;
      else {
	bool fg=false;
	for(int i=0;i<n;i++){
	  for(int j=0;j<m;j++){
	    if(is_intersected_ls(black[i],black[(i+1)%n],white[j],white[(j+1)%n]))fg=true;
	  }
	}
	if(fg)cout <<"NO"<<endl;
	else cout << "YES" << endl;
      }
      continue;
    }

    vector<point>Black,White;

    Black=convex_hull(black,n);
    White=convex_hull(white,m);
    
    if(crossPol(Black,White))cout << "NO" << endl;
    else cout << "YES" << endl;
  }

  return 0;
}

Measured memory_bytes: 1244
#include<iostream>
#include<math.h>
#include<vector>
#include<algorithm>
#include<cstdio>
#include <string>
using namespace std;
 
int main(){
    string s;
    string soro[10] = {"* = ****",
                        "* =* ***",
                        "* =** **",
                        "* =*** *",
                        "* =**** ",
                        " *= ****",
                        " *=* ***",
                        " *=** **",
                        " *=*** *",
                        " *=**** "};
    bool flag = true;
    while(cin >> s){
        vector<char> c;
        for(int i=0;i<5-s.size();i++){
            c.push_back('0');
        }
        for(int i=0;i<s.size();i++){
            c.push_back(s[i]);
        }
        if(flag){
            flag = false;
        }else{
            cout << endl;
        }
 
        for(int i=0;i<8;i++){
            for(int j=0;j<5;j++){
                cout << soro[c[j]-'0'][i];
            }
            cout << endl;
        }
    }
    return 0;
}



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

void solve() {
    int n, m;
    cin >> n >> m;
    int x = 1900 * m + (n-m) * 100;
    cout << x * (1 << m) << endl;
}

int main() {
    solve();
    return 0;
}


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

using namespace std;

#define REP(i,a,b) for(int i=a;i<(int)b;i++)
#define rep(i,n) REP(i,0,n)
#define all(c) (c).begin(), (c).end()
#define zero(a) memset(a, 0, sizeof a)
#define minus(a) memset(a, -1, sizeof a)
#define watch(a) { cout << #a << " = " << a << endl; }
template<class T1, class T2> inline bool minimize(T1 &a, T2 b) { return b < a && (a = b, 1); }
template<class T1, class T2> inline bool maximize(T1 &a, T2 b) { return a < b && (a = b, 1); }
template<class T> void operator>> (istream& ist, vector<T>& vs) { for(auto& e: vs) cin >> e; }

typedef long long ll;
int const inf = 1<<29;

int main() {
  int n ;cin >> n;cout << n / 3 << endl;
}

Measured memory_bytes: 256
/*
ID: rchalam1
LANG: C++14
TASK:
*/
// For train.usaco.org, fill the template above.

// Competitive Coding Template

// GCC OPTIMIAZTION FLAGS
#ifdef ONLINE_JUDGE
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#endif

#include <bits/stdc++.h>

/*
#include <fstream>
#include <iostream>
#include <string>
#include <vector>
*/
// All Includes for Competitive Coding Template

using namespace std;

using ll = long long;
using ull = unsigned long long;
using ld = long double;

using vi = std::vector<int>;
using vll = std::vector<long long>;
using vull = std::vector<unsigned long long>;

#define FOR(i, a, b) for (auto i = (a); i < (b); ++i)
#define F0R(i, a) FOR(i, 0, a)
#define ROF(i, a, b) for (auto i = (a); i >= (b); --i)
#define R0F(i, a) ROF(i, a, 0)
#define ITR(a, x) for (auto& a: x)

#define FSRT(set) sort((set).begin(),(set).end())
#define RSRT(set) sort((set).rbegin(),(set).rend())
#define CSRT(set, function) sort((set).begin(),(set).end(), (function))
#define TRS(set) sort((set).begin(),(set).end(), greater<>())
#define REV(set) reverse((set).begin(),(set).end());

#define ALL(set) (set).begin(), (set).end()

#define mp make_pair
#define mt make_tuple
#define pb push_back
#define eb emplace_back
#define ff first
#define ss second

// For stdio, call setIO() or setIO("").
void setIO(std::ifstream &readFile, std::ofstream &writeFile, const std::string &name = "", bool stdIO = false)
{
	std::ios_base::sync_with_stdio(false);
	std::cin.tie(nullptr);
	std::cout.tie(nullptr);
	if(!name.empty() && !stdIO)
	{
		readFile.open(name + ".in");
		if(readFile.fail()) return;
		writeFile.open(name + ".out");
		std::cin.rdbuf(readFile.rdbuf());
		std::cout.rdbuf(writeFile.rdbuf());
	}
}

// To time program, create object Timer  to start timing, and call Timer.elapsed().
#include <chrono>

class Timer
{
	std::chrono::time_point<std::chrono::high_resolution_clock> m_beg;
public:
	Timer() : m_beg(std::chrono::high_resolution_clock::now())
	{}

	void reset()
	{ m_beg = std::chrono::high_resolution_clock::now(); }

	[[nodiscard]] long double elapsed() const
	{
		return std::chrono::duration_cast<std::chrono::duration<long double, std::ratio<1> >>(
				std::chrono::high_resolution_clock::now() - m_beg).count();
	}
};

// Defines datatype
using dt = int;
// Defines MAXN value
constexpr dt MAXN = 1e5 + 1;
// Defines Modulus
constexpr dt MOD = 1e9 + 7;
// Defines Floating Point Correction
constexpr long double EPS = 1e-9;

//*****
//START CODE BELOW
//*****

int main(int argc, char *argv[])
{
	static std::ifstream readFile;
	static std::ofstream writeFile;
	setIO(readFile, writeFile);
	int n, m;
	cin >> n >> m;
	vector<int> prefix(n + 1, 0);
	for(int i = 0; i < m; ++i)
	{
		int l, r;
		cin >> l >> r;
		++prefix[l - 1];
		--prefix[r];
	}
	int answer = 0;
	for(int i = 0; i < n; ++i)
	{
		prefix[i] += prefix[i - 1];
		answer += (prefix[i] == m);
	}
	cout << answer << '\n';
}

Measured memory_bytes: 3724
sd = input()
t = input()
n = len(sd)
m = len(t)
s = []
for i in range(n - m, -1, -1):
    t_kamo = sd[i:i + m]
    for j in range(m + 1):
        if j == m:
            print((sd[:i] + t + sd[i + len(t):]).replace("?", "a"))
            exit()
        if t_kamo[j] == "?":
            continue
        elif t_kamo[j] != t[j]:
            break
print("UNRESTORABLE")

Measured memory_bytes: 3064
import math
a,b,c,d = map(int, input().split())

C = b//c - (a-1)//c
D = b//d - (a-1)//d
x = c*d//math.gcd(c,d)
CD = b//x - (a-1)//x

print((b-a+1) - (C+D-CD))

Measured memory_bytes: 8992
#include <bits/stdc++.h>
#include <numeric>
typedef long long ll;
#define rep(i,a,b) for(int i=a;i<b;++i)
#define rrep(i,a,b) for(int i=a;i>=b;--i)
using namespace std;

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

    string Sd, T;
    cin >> Sd >> T;

    set<string> setS;
    rrep(R, Sd.size(), T.size()) {
        int L = R - T.size();
        bool matched = true;

        rep(i, 0, T.size())
            if (Sd[L+i] != '?' and Sd[L+i] != T[i])
                matched = false;

        if (matched) {
            string S;
            rep(i, 0, Sd.size()) S += Sd[i];
            rep(i, 0, T.size()) S[L+i] = T[i];
            rep(i, 0, Sd.size()) if (S[i] == '?') S[i] = 'a';
            setS.insert(S);
        }
    }

    if (setS.empty())
        cout << "UNRESTORABLE\n";
    else
        cout << *setS.begin() << "\n";
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void){
	int m,f,r,p;

	while(1){
		scanf("%d %d %d",&m,&f,&r);
		if(m==-1&&f==-1&&r==-1) break;
		p=m+f;
		if(m==-1||f==-1||p<30) printf("F\n");
		else if(p>=80) printf("A\n");
		else if(p>=65) printf("B\n");
		else if(p>=50||r>=50) printf("C\n");
		else printf("D\n");
		
	}
	return 0;
}

Measured memory_bytes: 584
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define REP(i,n) for(int i=0;i<n;++i)
#define REP1(i,n) for(int i=1;i<=n;++i)
#define SZ(i) int(i.size())
#define eb emplace_back
#define ALL(i) i.begin(),i.end()
#define X first
#define Y second
#ifdef tmd
#define IOS()
#define debug(...) fprintf(stderr,"#%d: %s = ",__LINE__,#__VA_ARGS__),_do(__VA_ARGS__);
template<typename T> void _do(T &&x){cerr<<x<<endl;}
template<typename T, typename ...S> void _do(T &&x, S &&...y){cerr<<x<<", ";_do(y...);}
template<typename It> ostream& _printRng(ostream &os,It bg,It ed)
{
    os<<"{";
    for(It it=bg;it!=ed;it++) {
        os<<(it==bg?"":",")<<*it;
    }
    os<<"}";
    return os;
}
template<typename T> ostream &operator << (ostream &os,vector<T> &v){return _printRng(os,v.begin(), v.end());}
template<typename T> void pary(T bg, T ed){_printRng(cerr,bg,ed);cerr<<endl;}
#else
#define IOS() ios_base::sync_with_stdio(0);cin.tie(0);
#define endl '\n'
#define debug(...)
#define pary(...)
#endif

const int MAXN = 400005;
const ll MOD = 1000000007;

ll mpow (ll bs, ll ep) {
    ll ret = 1;
    while (ep) {
        if (ep & 1) {
            ret = ret * bs % MOD;
        }
        bs = bs * bs % MOD;
        ep >>= 1;
    }
    return ret;
}

ll fac[MAXN], ifac[MAXN];

ll cob (ll n, ll r) {
    if (r < 0 || r > n) {
        return 0;
    }
    return fac[n] * ifac[r] % MOD *ifac[n-r] % MOD;
}
/*********************GoodLuck***********************/
int main () {
    IOS();

    fac[0] = ifac[0] = 1;
    REP1 (i, MAXN-1) {
        fac[i] = fac[i-1] * i % MOD;
        ifac[i] = mpow(fac[i], MOD-2);
    }

    int n, k;
    cin >> n >> k;
    k = min(k, n-1);

    ll ans = 0;
    for (int i=0; i<=k; i++) {
        ans += cob(n,i)*cob(n-1,n-i-1)%MOD;
//        debug(i, cob(n,i),cob(n-1,n-i-1));
        ans %= MOD;
    }

    cout << ans << endl;
}


Measured memory_bytes: 6528
// D.

#include <sstream>
#include <iostream>
#include <algorithm>

using namespace std;

int main(int argc, char *argv[])
{
  int n, m, q;
  cin >> n >> m >> q;
  static int ep[512][512];
  for (int i = 0; i < m; ++i) {
    int l, r;
    cin >> l >> r;
    for (int j = 1; j <= l; ++j) {
      ep[j][r] += 1;
    }
  }
  for (int i = 0; i < q; ++i) {
    int p, q;
    cin >> p >> q;
    int ans = 0;
    for (int j = p; j <= q; ++j) {
      ans += ep[p][j];
    }
    cout << ans << endl;
  }
  return 0;
}


Measured memory_bytes: 1920
#include <iostream>
using namespace std;
typedef long long ll;
ll k;
string s;
int main(void){
    // Your code here!
    cin >> s >> k;
    for (ll i = 0; i < s.length(); i++) {
        if (s[i] == 'a') continue;
        if ('z' - s[i] < k) {
            k += (s[i] - 'z') - 1;
            s[i] = 'a';
        }
    }
    ll u = (s[s.length() - 1] - 'a' + k) % 26;
    s[s.length() - 1] = (char)('a' + u);
    cout << s << endl;
}


Measured memory_bytes: 512
import java.util.*;

public class Main{
    private static void solve(int A, int B){
        int[] b = new int[3];
        for(int x = 0; x <= (B/1000-A)/9; x ++){
            if((B / 1000 - A - 9 * x) % 4 == 0){
                int y = (B / 1000 - A - 9 * x) / 4;
                int z =A - x - y;
                if(y >= 0 && z >= 0){
                    b[0] = x;
                    b[1] = y;
                    b[2] = z;
                    for(int i = 0; i < 3; i ++){
                        System.out.print(b[i] + " ");
                    }
                    return;
                }
            }
        }
        System.out.println("-1 -1 -1");
    }
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int[] a = new int[2];
        for(int i = 0; i < 2; i ++){
            a[i] = input.nextInt();
        }
        input.close();
        int A = a[0];
        int B = a[1];
        solve(A, B);
    }
}

Measured memory_bytes: 24020
using System;
using System.Collections.Generic;
using System.Linq;



namespace CSharpSample01
{



    class Program
    {

        


        static void Main(string[] args)
        {
            int A = int.Parse(Console.ReadLine());
            int[] a = Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray();

            int cnt = 0;
            bool zero = false;
            int min = 1000000009;
            long sum = 0;
            for(int i = 0; i < a.Length; i++)
            {
                if (a[i] < 0) cnt++;
                int v = Math.Abs(a[i]);
                sum += (long)v;
                if (v == 0) zero = true;
                if (min > v) min = v;
            }


            if(cnt % 2 == 0 || zero)
            {
                Console.WriteLine(sum);
            }
            else
            {
                Console.WriteLine(sum - 2 * min);
            }

        }
    }
}

Measured memory_bytes: 29916
#include <bits/stdc++.h>
using namespace std;
#define ll long long
#define ld long double
#define pb push_back
#define all(t) t.begin(), t.end()
#define inrange(i, a, b) (((i)>= min((a), (b))) && ((i) <= max((a), (b))))
typedef vector<ll> vi;
#define fi first
#define se second
#define show(x) cout << #x << " is " << x << "\n";
const ll inf = 9e18;
const ll mod = 998244353;
const ld pi = 3.141592653589793238462643383279502884;

void print(ll a[], ll n){for(ll i=0;i<n;i++){cout<<a[i]<<" ";}cout<<"\n";}
ll power(ll x, ll y, ll M = inf){
    if(y<=0) return 1;
    ll ans = 1;
    x %= M;
    while(y){
        if(y&1)
            ans = (x * ans) % M;

        x = (x * x) % M;
        y >>= 1;
    }
    return ans;
}
ll modInverse(ll n) {return power(n, mod-2, mod);}
inline ll mul(ll a, ll b){ return (a * b) % mod; }
inline ll sub(ll a, ll b){ ll c = a - b; if(c < 0) c += mod; return c; }
inline ll add(ll a, ll b){ ll c = a + b; if(c > mod) c -= mod; return c; }
inline ll divi(ll a, ll b){ return mul(a, modInverse(b)); }

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

//const ll N = 1e5 + 1;
//vector<ll> adj[N];
//bool visited[N];
ll dp[3005][3005];

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    cout<<fixed<<setprecision(10);

    ll n, s;
    cin>>n>>s;
    ll a[n];
    for(int i=0;i<n;i++){
    	cin>>a[i];
	}
	dp[0][0] = 1;
	for(int i=0;i<n;i++){
		for(int j=0;j<=s;j++){
			dp[i+1][j] = add(dp[i+1][j], mul(2, dp[i][j]));
			if(j+a[i]<=s){
				dp[i+1][j+a[i]] = add(dp[i+1][j+a[i]], dp[i][j]);
			}
		}
	}
	
    cout<<dp[n][s]%mod;
    return 0;
}


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

int INF = 1e9;

vector<int>g[200005];//edgeの配列でmax_vに対応するindexは各頂点のindex　それぞれのg[v]に対して複数のedgeが入っている
ll d[200005];//距離
vector<int>ans;
 
void dijkstra(int s){//sは始点
    priority_queue<pair<int, int>, vector<pair<int, int> > , greater<pair<int, int> > > que;
    rep(i, 200005) d[i] = INF;
    d[s] = 0;
    que.push(make_pair(0, s));

    while(!que.empty()){
        pair<int, int> p = que.top(); que.pop();
        int v = p.second;
        if(d[v]<p.first) continue;//最小にならないなら何もしない
        rep(i, g[v].size()){
            int e = g[v][i];
            if(d[e] > d[v] + 1){
                d[e] = d[v]+1;
                ans[e] = v;
                que.push(make_pair(d[e], e));
            }
            
        }
    }
}

int main(void){
    int n, m;
    cin>>n>>m;
    ans.resize(n);
    rep(i, m){
        int a, b;
        cin>>a>>b;
        --a;--b;
        g[a].push_back(b);
        g[b].push_back(a);
    }
    dijkstra(0);
    cout<<"Yes"<<endl;
    rep(i, n-1){
        cout<<ans[i+1]+1<<endl;
    }
    return 0;
}

Measured memory_bytes: 14580
void main() {
  import std.stdio, std.string, std.conv, std.algorithm;

  // 1 -2 4 -8 16 -32
  long n;
  rd(n);
  if (n == 0) {
    writeln(0);
    return;
  }
  int[] a;
  for (long k = 1; n != 0; k *= -2) {
    if (n % (k * (-2)) != 0) {
      a ~= 1;
      n = n - k;
    } else {
      a ~= 0;
    }
  }
  reverse(a);
  writefln("%(%s%)", a);
}

void rd(T...)(ref T x) {
  import std.stdio : readln;
  import std.string : split;
  import std.conv : to;

  auto l = readln.split;
  assert(l.length == x.length);
  foreach (i, ref e; x)
    e = l[i].to!(typeof(e));
}


Measured memory_bytes: 256
#include <stdio.h>

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


Measured memory_bytes: 2084
#include<bits/stdc++.h>
using namespace std;
int main(){
  int n,n4=0,n2=0,a;
  cin>>n;
  for(int i=0;i<n;i++){
    cin>>a;
    if(a%4==0) n4++;
    else if(a%2==0) n2++;
  }
  bool n1=(n2>0?true:false);
  if(n==n4+n2) cout<<"Yes";
  else if(n1){
    if(n4+2>n-n4-n2+1) cout<<"Yes";
    else cout<<"No";
  }else{
    if(n4+2>n-n4) cout<<"Yes";
    else cout<<"No";
  }
}

Measured memory_bytes: 256
S=input()
T=input()
dp=[[10**6]*len(S) for i in range(26)]
for i,s in enumerate(S):
    dp[ord(s)-ord('a')][i]=0
for i in range(len(S)-1,-1,-1):
    for j in range(26):
        dp[j][i-1]=min(dp[j][i-1],dp[j][i]+1)
for i in range(len(S)-1,-1,-1):
    for j in range(26):
        dp[j][i-1]=min(dp[j][i-1],dp[j][i]+1)
x=0
i=-1
for t in T:
    ti=ord(t)-ord('a')
    if dp[ti][i]<1e6:
        x+=dp[ti][i+1-len(S)]+1
        i=(i+dp[ti][i+1-len(S)]+1)%len(S)
    else:
        x=-1
        break
print(x)

Measured memory_bytes: 64732
a = []
3.times do
  a.push(gets.chomp.split)
end
N = gets.to_i
d = "d"
N.times do
  b = gets.chomp
  3.times do |i|
    3.times do |j|
      a[i][j] = d if a[i][j] == b
    end
  end
end
r = "No"
3.times do |i|
  if a[i][0]==d && a[i][1]==d && a[i][2]==d or a[0][i]==d && a[1][i]==d && a[2][i]==d
    r = "Yes"
  end
end
if a[1][1]==d
  if a[0][0]==d && a[2][2] or a[0][2] && a[2][0]
    r ="Yes"
  end
end
puts r

Measured memory_bytes: 3836
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<iomanip>
#include<vector>
#include<queue>
#include<deque>
#include<string>
#include<utility>
#include<cmath>
#include<algorithm>
#include<cctype>
#include<set>
#include<map>
#include<bitset>
#include<stack>
#include<ctime>

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> pii;
typedef pair<ll,int> pli;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vpii;
typedef vector<pli> vpli;

inline ll read(){
    ll Hashimoto=0;
	bool Kanna=1;
    char I_Love=getchar();
    while(I_Love<'0'||I_Love>'9'){
        if(I_Love=='-')Kanna=0;
        I_Love=getchar();
    }
    while(I_Love>='0'&&I_Love<='9'){
        Hashimoto=Hashimoto*10+I_Love-'0';
        I_Love=getchar();
    }
    return (Kanna?Hashimoto:-Hashimoto);
}
template<typename T1,typename T2> inline void Umax(T1 &a,T2 b){
	if(a<b)a=b;
}
template<typename T1,typename T2> inline void Umin(T1 &a,T2 b){
	if(a>b)a=b;
}

#define I_Love_Hashimoto_Kanna main
#define fastio ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define filein(s) freopen(s,"r",stdin);
#define fileout(s) freopen(s,"w",stdout);
#define file freopen("I_Love_Hashimoto_Kanna.out","w",stdout);
#define RE cout<<"I_Love_Hashimoto_Kanna"<<endl;
#define Tone(Kanna) cout<<Kanna<<endl;
#define Tall(Hashimoto,Kanna) for(int I_Love=0;I_Love<(Kanna);++I_Love)cout<<Hashimoto[I_Love]<<(I_Love==(Kanna)-1?"\n":" ");
#define FOR(I_Love,Hashimoto,Kanna) for(int I_Love=Hashimoto;I_Love<(Kanna);++I_Love)
#define MP(Hashimoto,Kanna) make_pair(Hashimoto,Kanna)
#define REV(Kanna) reverse(Kanna.begin(),Kanna.end());
#define SORT(Kanna) sort(Kanna.begin(),Kanna.end());
#define UNIQUE(Kanna) Kanna.erase(unique(Kanna.begin(),Kanna.end()),Kanna.end());
#define inf (int)1e9
#define linf (ll)1e18
#define mod (1000000007)

int n;
int d[111111];
int rd[111111];
int a[20][111111];
int b[20][111111];

bool can(int x,int y,int k){
	for(int i=19;i>=0;i--){
		if(k&(1<<i)){
			x=a[i][x];
		}
	}
	return x>=y;
}

void solve(int x,int y){
	int l=0,r=100000;
	while(l<r-1){
		int mid=l+r>>1;
		if(can(x,y,mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
}

bool can2(int x,int y,int k){
	for(int i=19;i>=0;i--){
		if(k&(1<<i)){
			x=b[i][x];
		}
	}
	return x>=y;
}

void solve2(int x,int y){
	int l=0,r=100000;
	while(l<r-1){
		int mid=l+r>>1;
		if(can2(x,y,mid))r=mid;
		else l=mid;
	}
	printf("%d\n",r);
}

int I_Love_Hashimoto_Kanna() {
	//完全想清楚了再开始写。
	//写不顺、不知道怎么写、很乱的时候，停下来好好想想。
	//做得慢总比做不出好。
	fastio;
	n=read();
	FOR(i,0,n){
		d[i]=read();
		rd[i]=-d[i];
	}
	reverse(rd,rd+n);
	int L=read();
	d[n]=2*inf;
	FOR(i,0,n){
		a[0][i]=upper_bound(d,d+n,d[i]+L)-d-1;
		b[0][i]=upper_bound(rd,rd+n,rd[i]+L)-rd-1;
	}
	FOR(i,0,20){
		b[i][n-1]=n-1;
		a[i][n-1]=n-1;
	}
	FOR(j,0,19)FOR(i,0,n){
		a[j+1][i]=a[j][a[j][i]];
		b[j+1][i]=b[j][b[j][i]];
	}
	int q=read();
	while(q--){
		int x=read()-1,y=read()-1;
		if(x<y)solve(x,y);
		else solve2(n-1-x,n-1-y);
	}
	return 0;
}


Measured memory_bytes: 18688
from collections import Counter


def solve():

    n = int(input())
    vlist = list(map(int, input().split()))

    evens = []
    odds = []

    for i in range(n):
        v = vlist[i]
        if i % 2 == 0:
            evens.append(v)
        else:
            odds.append(v)

    evensCollection = Counter(evens).most_common()
    oddsCollection = Counter(odds).most_common()

    evensCollection.append([0, 0])
    oddsCollection.append([0, 0])

    if evensCollection[0][0] != oddsCollection[0][0]:
        print(n - (evensCollection[0][1] + oddsCollection[0][1]))

    else:
        print(min(n-(evensCollection[1][1]+oddsCollection[0][1]),
                  n-(evensCollection[0][1]+oddsCollection[1][1])))


if __name__ == "__main__":
    solve()


Measured memory_bytes: 66156
#include <iostream>
using namespace std;
int main(void){
    int i=1;
    long long A, B;
    cin >> A >> B;
    if(A>B){
        swap(A,B);
    }
    for (;;){
        if(i*A%B == 0){
            break;
        }else{
            i++;
        }
    }
    cout << i*A << endl;
}

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
 
public class Main {
    private static boolean debug = false;
    private static boolean elapsed = false;
 
    private static PrintWriter _out = new PrintWriter(System.out);
    private static PrintWriter _err = new PrintWriter(System.err);
 
    private void solve(Scanner sc) {
        int a = sc.nextInt();
        int b = sc.nextInt();
 
        if (a == b) {
            _out.println("Draw");
        } else if (a == 1) {
            _out.println("Alice");
        } else if (b == 1) {
            _out.println("Bob");
        } else {
            _out.println((a > b ? "Alice" : "Bob"));
        }
    }
    private static BigInteger C(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        for (long i = r; i > 1; --i) {
            res = res.divide(BigInteger.valueOf(i));
        }
        return res;
    }
    private static BigInteger P(long n, long r) {
        BigInteger res = BigInteger.ONE;
        for (long i = n; i > n - r; --i) {
            res = res.multiply(BigInteger.valueOf(i));
        }
        return res;
    }
    /*
     * 10^10 > Integer.MAX_VALUE = 2147483647 > 10^9
     * 10^19 > Long.MAX_VALUE = 9223372036854775807L > 10^18
     */
    public static void main(String[] args) {
        long S = System.currentTimeMillis();
 
        Scanner sc = new Scanner(System.in);
        new Main().solve(sc);
        _out.flush();
 
        long G = System.currentTimeMillis();
        if (elapsed) {
            _err.println((G - S) + "ms");
        }
        _err.flush();
    }
}

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

#define rep(i,z) for(int i = 0; i<(int)(z); i++)
#define rep1(i,z) for(int i = 1; i<=(int)(z); i++)
 
using namespace std;

typedef long long ll;
const ll MOD=1e9+7;
using pear = pair<int,int>;

int main(){
  ll n; cin>>n;
  vector<ll> a(n);
  rep(i, n) cin>> a[i];
  ll now = a[0], ans = 0;
  for(int i = 1; i < n; i++){
      now = max(now, a[i]);
      ans += now - a[i];
  }
  cout<< ans <<endl;
}

Measured memory_bytes: 4820
#include<iostream>
#include<string>
using namespace std;
int main(){
    int n;
    for(cin>>n;n--;){
        int k=0;
        string a,b;
        cin >> a;
        cin >> b;
        if(a.size() < b.size()) swap(a,b);//????????????a>b?????????
        while(b.size() < a.size()) b = '0' + b;//????????????a==b?????????
        for(int i=a.size()-1;i>=0;i--){//???????????????????????????
            a[i] += b[i] - '0' + k;
            if(a[i] > '9'){
                a[i]-=10;
                k = 1;
            }
            else k = 0;
        }
        if(k)   a="1"+a;//??°??????????????????????????????????¶?????????¨???
        if(a.size() > 80)   cout << "overflow" << endl;
        else    cout << a << endl;
    }
    return 0;
}

Measured memory_bytes: 3144
a, b, c = list(map(int,input().split()))
if a < b:
  lst = list(range(a,b))
  if c in lst:
    print("Yes")
  else:
    print("No")
else:
  lst = list(range(a,b,-1))
  if c in lst:
    print("Yes")
  else:
    print("No")



Measured memory_bytes: 2940
#include <unordered_set>
#include <algorithm>
#include <fstream>
#include <iostream>
#include <cstring>
#include <cassert>
#include <fstream>
#include <climits>
#include <cstdio>
#include <vector>
#include <string>
#include <memory>
#include <queue>
#include <cmath>
#include <list>
#include <set>
#include <map>


using namespace std;

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

const int maxn=1e5+10;

vector<int> edge[maxn];
int color[maxn];

vector<int> path;
int n;

int dfs(int u,int prev)
{
  if(u==n)
  {
    return 1;
  }
  for(int i=0;i<edge[u].size();i++)
  {
    if(edge[u][i]==prev) continue;
    int ret=dfs(edge[u][i],u);
    if(ret)
    {
      if(edge[u][i]!=n)
        path.push_back(edge[u][i]);
      return ret;
    }
  }
  return 0;
}

void dfs(int u)
{
  color[u]=1;
  for(int i=0;i<edge[u].size();i++)
    if(color[edge[u][i]]==-1)
      dfs(edge[u][i]);
}

int main()
{
//  freopen("/Users/qianjay/Documents/apac/in", "r", stdin);
  scanf("%d",&n);
  for(int i=0;i<n-1;i++)
  {
    int u,v;
    scanf("%d%d",&u,&v);
    edge[u].push_back(v);
    edge[v].push_back(u);
  }
  memset(color,-1,sizeof(color));
  color[1]=1;
  color[n]=0;
  
  dfs(1,-1);
  reverse(path.begin(),path.end());
//  for(int i=0;i<path.size();i++)
//    cout<<path[i]<<" ";
//  cout<<endl;
  for(int i=0,j=(int)path.size()-1;i<j;i++,j--)
  {
    color[path[i]]=1;
    color[path[j]]=0;
  }
  if(path.size()%2)
    color[path[path.size()/2]]=1;
  dfs(1);
  for(int i=0;i<path.size();i++)
    if(color[path[i]]==1)
      dfs(path[i]);
  int num=0;
//  for(int i=1;i<=n;i++)
//    cout<<color[i]<<" ";
//  cout<<endl;
  for(int i=1;i<=n;i++)
    if(color[i]>0) num++;
  if(num>n-num) cout<<"Fennec"<<endl;
  else cout<<"Snuke"<<endl;
  return 0;
}

Measured memory_bytes: 14588
a, b = map(int, input().split())
lis=[]
for i in map(int, input().split()):
    lis.append(i)
res=[1]*a
for i in range(b):
    c, d = map(int, input().split())
    if(lis[c-1]>lis[d-1]):
        res[d-1]=0
    elif(lis[c-1]<lis[d-1]):
        res[c-1]=0
    else:
        res[d - 1] = 0
        res[c - 1] = 0
print(sum(res))

Measured memory_bytes: 20116
// Reads multiple ints in a line, separate by a space.
// It works even if the actual number of ints is smaller than n.
// WARNING: This function does not work for -2^31.
// NOTE: This function does not handle error cases.
fun fastReadInts(n: Int): IntArray {
    val xs = IntArray(n)
    val s = readLine()!!
    var currentValue = 0
    var isNegative = false
    var currentIndex = 0
    for (c in s) {
        if (c == ' ') {
            xs[currentIndex] = currentValue * if (isNegative) -1 else 1
            currentValue = 0
            isNegative = false
            currentIndex++
        } else if (c == '-') {
            isNegative = true
        } else {
            currentValue *= 10
            currentValue += c - '0'
        }
    }
    xs[currentIndex] = currentValue * if (isNegative) -1 else 1
    return xs
}

fun main(args: Array<String>) {
    val n = readLine()!!.toInt()
    val xs = fastReadInts(n)
    xs.sortDescending()

    val output = StringBuilder()
    if (xs.all { it >= 0 }) {
        for (i in 1..(n - 2)) {
            output.append("${xs[n - 1]} ${xs[i]}\n")
            xs[n - 1] = xs[n - 1] - xs[i]
        }
        output.append("${xs[0]} ${xs[n - 1]}\n")
        xs[0] = xs[0] - xs[n - 1]
        println(xs[0])
        print(output)
    } else if (xs.all { it < 0 }) {
        for (i in 1..(n - 1)) {
            output.append("${xs[0]} ${xs[i]}\n")
            xs[0] = xs[0] - xs[i]
        }
        println(xs[0])
        print(output)
    } else {
        val firstNegativeIndex = xs.indexOfFirst { it < 0 }
        for (i in 1 until firstNegativeIndex) {
            output.append("${xs[n - 1]} ${xs[i]}\n")
            xs[n - 1] = xs[n - 1] - xs[i]
        }
        for (i in firstNegativeIndex until n) {
            output.append("${xs[0]} ${xs[i]}\n")
            xs[0] = xs[0] - xs[i]
        }
        println(xs[0])
        print(output)
    }
}

Measured memory_bytes: 60632
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<ll> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1e8;
int main(){
	vi in(3);
	rep(i,3)cin>>in[i];
	sort(all(in));
	bool h=false;
	rep(i,3)if(in[i]%2==0)h=true;
	ll out=in[0]*in[1];
	if(h)out=0;
	cout<<out<<endl;
}
 
 







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

#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")

using namespace std;

typedef long long ll;
typedef long double ld;



void solve() {
    string s;
    cin >> s;
    if (s == "ABC") cout << "ARC\n";
    else cout << "ABC\n";

}

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    solve();
    return 0;
}

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

int main(){
	long long n;
	cin>>n;
	char s[n];
	for(int i=0;i<n;i++)cin>>s[i];

	int cnt_l=0,cnt_r=0,cnt2[n],res=0;
	int cnt=0,tmp_e[n],tmp_w[n];
	int cnt_e=0,cnt_w=0;
	for(int i=0;i<n;i++){
		if(s[i]=='E'){
			cnt_e +=1;
		}else{
			cnt_w+=1;
		}
	}
	//i番目がリーダーの時のリーダーより東に位置し東を向いている人の数
	for(int i=0;i<n;i++){
		if(s[i]=='E'){
			tmp_e[i] = cnt_e-1;
			cnt_e--;
		}else{
			tmp_e[i] = cnt_e;
		}
	}

	//i番目がリーダーの時のリーダーより西に位置し西を向いている人の数
		for(int i=n-1;i>=0;i--){
			if(s[i]=='W'){
				tmp_w[i] = cnt_w-1;
				cnt_w--;
			}else{
				tmp_w[i] = cnt_w;
			}
		}

	res = 1 <<30;
	for(int i=0;i<n;i++){
		res = min(res,tmp_e[i]+tmp_w[i]);
	}

	cout<<res<<endl;
}


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

using ll=long long; 

void solve(){
	int n;
	string s;
	cin>>n>>s;
	int maxi=0;
	int cnt=0;
	for(auto e:s){
		if(e=='I'){
			cnt++;
			maxi=max(maxi, cnt);
		}else{
			cnt--;
		}
	}
	cout<<maxi<<endl;
}

signed main(){
	//while(1)
	solve();
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
/* * * *   * * *   	* * * */
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
#define ms(a,v) memset(a,v,sizeof a)
/* * * *   * * *   	* * * */
/* *
 *
 * Author: Hamkor a.k.a. OakenSh1eld
 *
 * */
int main(){
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	ll n; cin>>n;
	vector<ll> div;
	for(ll i=1; i*i<=n; ++i) if(n%i ==0){
		div.push_back(i);
		if(n/i != i) div.push_back(n/i);
	}
	sort(div.begin(), div.end());
	ll ans = 1000000000000000000;
	for(ll i: div) ans = min(ans, i-1 + n/i - 1);
	cout<<ans;
	return 0;
}


Measured memory_bytes: 384
//#pragma GCC target ("avx2")
//#pragma GCC optimize ("Ofast")
//#pragma GCC optimize ("unroll-loops")

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

#define int long long

using namespace std;
using namespace __gnu_pbds;

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

const int N = (int)(1e6 + 5);
const int M = (int)(1e9 + 7);
const int INF = (int)(1e18 + 9);
const int dx[] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[] = {0, 0, 1, -1, 1, -1, 1, -1};

int n;
int a[N];
int t[N];

void build(int v = 1, int tl = 1, int tr = n) {
  if (tl == tr)
    t[v] = a[tl];
  else {
    int tm = (tl + tr) >> 1;
    build(v * 2, tl, tm);
    build(v * 2 + 1, tm + 1, tr);
    t[v] = __gcd(t[v * 2], t[v * 2 + 1]);
  }
}

void update(int pos, int x, int v = 1, int tl = 1, int tr = n) {
  if (tl == tr) {
    t[v] = x;
    return;
  }
  int tm = (tl + tr) >> 1;
  if (pos <= tm)
    update(pos, x, v * 2, tl, tm);
  else
    update(pos, x, v * 2 + 1, tm + 1, tr);
  t[v] = __gcd(t[v * 2], t[v * 2 + 1]);
}

int get(int l, int r, int v = 1, int tl = 1, int tr = n) {
  if (l > tr || r < tl)
    return 0;
  if (l <= tl && tr <= r)
    return t[v];
  int tm = (tl + tr) >> 1;
  return __gcd(get(l, r, v * 2, tl, tm), get(l, r, v * 2 + 1, tm + 1, tr));
}

signed main() {
  ios_base :: sync_with_stdio(0);
  cin.tie(0);
  cin >> n;
  int gcd = 0;
  for (int i = 1; i <= n; ++i) {
    cin >> a[i];
    gcd = __gcd(gcd, a[i]);
  }
  build();
  int ret = gcd;
  for (int i = 1; i <= n; ++i) {
    int x = a[i];
    if (i != n)
      update(i, a[i + 1] * 2);
    else
      update(i, a[i - 1] * 2);
    ret = max(ret, get(1, n));
    update(i, x);
  }
  cout << ret;
  return 0;
}


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


int main(){
  int x;
  cin >> x;
  int ans = 1;
  for(int i=2; i<=pow(x,0.5); i++){
    int p=i;
    while(p*i<=x) p *=i;
    if(p!=i&&p>ans) ans = p;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256