akhauriyash/Code-Regression huggingface dataset:
a,b = list(map(int,input().split()))
s = [1,3,5,7,8,10,12]
t = [4,6,9,11]
u = [2]
if s.count(a) == 1 and s.count(b) == 1:
  print("Yes")
elif t.count(a) == 1 and t.count(b) == 1:
  print("Yes")
elif u.count(a) == 1 and u.count(b) == 1:
  print("Yes")
else:
  print("No")

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

using namespace std;

#define Q int t; scanf("%d", &t); for(int q=1; q<=t; q++)
typedef long long int lli;
typedef pair<int, int> pi;


int main()
{
    int n, m;
    cin >> n >> m;
    vector<string> v(n);
    for(int i=0; i<n; i++){
        cin >> v[i];
    }
    int dp[n][m];
    for(int i=0; i<n; i++){
        for(int j=0; j<m; j++){
            dp[i][j] = 1000000000;
        }
    }
    dp[0][0] = ((v[0][0] == '#')? 1: 0);
    for(int i=1; i<m; i++){
        if(v[0][i] == v[0][i-1]){
            dp[0][i] = dp[0][i-1];
        }
        else
            dp[0][i] = dp[0][i-1] + ((v[0][i] == '#')? 1: 0);
    }

    for(int i=1; i<n; i++){
        if(v[i][0] == v[i-1][0]){
            dp[i][0] = dp[i-1][0];
        }
        else
            dp[i][0] = dp[i-1][0] + ((v[i][0] == '#')? 1: 0);
    }

    for(int i=1; i<n; i++){
        for(int j=1; j<m; j++){
            if(v[i][j] == '.'){
                dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
            }
            else{
                if(v[i-1][j] == '#' && v[i][j-1] == '#'){
                    dp[i][j] = min(dp[i-1][j], dp[i][j-1]);
                }
                else if(v[i-1][j] == '#'){
                    dp[i][j] = min(dp[i-1][j], dp[i][j-1]+1);
                }
                else if(v[i][j-1] == '#'){
                    dp[i][j] = min(dp[i-1][j]+1, dp[i][j-1]);
                }
                else{
                    dp[i][j] = min(dp[i-1][j], dp[i][j-1]) + 1;
                }
            }
        }
    }

    cout << dp[n-1][m-1] << '\n';

    return 0;
}



Measured memory_bytes: 256
// 以下のライブラリを使ってみる.
// dohatsu氏.
// http://judge.u-aizu.ac.jp/onlinejudge/review.jsp?rid=1927353#1
#include<bits/stdc++.h>
using namespace std;
typedef pair<int, int> P;
#define MAX 100005
int V, E;
vector<int> G[MAX];
int depth[MAX];
int cnt[MAX];
int visited[MAX];
vector<P> ans;

void dfs(int pos, int prev){
    visited[pos] = true;
    for(int i = 0; i < (int)G[pos].size(); i++){
        int to = G[pos][i];
        if(to==prev)continue;
        if(!visited[to]){
            depth[to] = depth[pos] + 1;
            dfs(to, pos);
            cnt[pos]+=cnt[to];
            if(cnt[to] == 0) ans.push_back(P(min(pos,to) , max(pos,to)));
        }else if(depth[to] < depth[pos]){
            cnt[pos]++;
            cnt[to]--;
        }
    }
}
 
int main(){
    scanf("%d %d", &V, &E);
    for(int i = 0; i < E; i++){
        int a, b;
        scanf("%d %d", &a, &b);
        G[a].push_back(b);
        G[b].push_back(a);
    }
    dfs(0,-1);
    sort(ans.begin(), ans.end());
    for(int i = 0; i < (int)ans.size(); i++) printf("%d %d\n",ans[i].first, ans[i].second);
    return 0;
}


Measured memory_bytes: 7400
#include <bits/stdc++.h>
#define pb push_back
#define mp make_pair
#define fst first
#define snd second
#define all(cont) cont.begin(), cont.end()
#define foreach(it, l) for (auto it = l.begin(); it != l.end(); it++)
#define fore(i,a,b) for(int i=a,almo5t=b;i<almo5t;++i)
#define SZ(x) ((int)x.size())
#define EPS 1e-9
#define PI acos(-1)
#define MOD 1000000007
#define FIN std::ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)
 
const int N = 0;
 
typedef long long int ll;
 
using namespace std;


 
int main(){
    FIN;
    //freopen("../input.txt", "r", stdin);
    int  d,T;cin>>d>>T;
    fore(i,0,T){
        int val;
        cin>>val;
        d-=val;
    }

    if(d <0 ){
        cout<<"-1\n";
    }else{
        cout<<d<<"\n";
    }


    return 0;
}

// ============== Notes =============== //
// common bugs
// - remove reader 
// - fastio
// - int overflow (especially intermediate expressionns)
// - array bounds (indices bigger than MAXN?, is MAXN correct?)
// - special cases (n=1, graph not connected?)
// - re-initialize efficiently between test cases

Measured memory_bytes: 3648
//ITP 1_3_C
#include <iostream>
using namespace std;

int main(){

  while(1){
    int x, y;
    cin >> x >> y;
   
    if(x == 0 && y == 0) break;
    if(x > y) swap(x, y);
    cout << x << " " << y << endl;
  }
  return 0;
}



Measured memory_bytes: 3088
#include <cstdio>
const int MAXN = 1e5;
typedef long long LL;
int A[MAXN];
bool check(int N)
{
	int i, K, t;
	LL sum = 0;
	for(i=0; i<N; ++i)
		sum += A[i];
	if(sum % (LL(1+N)*N/2))
		return 0;
	K = sum / (LL(1+N)*N/2);
	for(i=0; i<N; ++i)
	{
		t = A[i]-A[(i-1+N)%N]-K;
		if(t%N || t>0)
			return 0;
	}
	return 1;
}
int main()
{
	int N, i;
	scanf("%d", &N);
	for(i=0; i<N; ++i)
		scanf("%d", A+i);
	puts(check(N) ? "YES" : "NO"); 
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
#pragma GCC optimize("Ofast")
#define INF 5000000000000000000
#define ll long long
#define pll pair<ll, ll>
using namespace std;
vector<ll> C(26);
vector<vector<ll>> S;

ll change_evaluation(vector<set<ll>>& contest_data, ll t, ll day, ll old) {
  t -= 1;
  day -= 1;
  old -= 1;
  contest_data.at(old).erase(day);
  ll next_t, last_t, next_old, last_old;
  auto itr_t = contest_data.at(t).lower_bound(day);
  next_t = *itr_t;
  itr_t--;
  last_t = *(itr_t);
  auto itr_old = contest_data.at(old).lower_bound(day);
  next_old = *itr_old;
  itr_old--;
  last_old = *(itr_old);

  ll score = S.at(day).at(t) - S.at(day).at(old);
  score += (next_t - day) * (day - last_t) * C.at(t);
  score -= (next_old - day) * (day - last_old) * C.at(old);
  contest_data.at(t).insert(day);
  return score;
}

ll evaluation(vector<ll>& T) {
  ll D = T.size();
  vector<ll> last(26, 0);
  ll score = 0;
  for (ll i = 0; i < D; ++i) {
    ll contest = T.at(i) - 1;
    last.at(contest) = i + 1;
    score += S.at(i).at(contest);
    for (ll j = 0; j < 26; ++j) {
      score -= (i + 1 - last.at(j)) * C.at(j);
    }
  }
  return score;
}

int main() {
  ios::sync_with_stdio(false);
  cin.tie(nullptr);
  //-----------input-------------
  ll D;
  cin >> D;
  vector<ll> T(D);
  S = vector<vector<ll>>(D, vector<ll>(26));
  for (ll i = 0; i < 26; ++i) {
    cin >> C.at(i);
  }
  for (ll i = 0; i < D; ++i) {
    for (ll j = 0; j < 26; ++j) {
      cin >> S.at(i).at(j);
    }
  }
  vector<set<ll>> contest_data(26, {-1, D});
  for (ll i = 0; i < D; ++i) {
    cin >> T.at(i);
    contest_data.at(T.at(i) - 1).insert(i);
  }
  //--------------------------------------
  // vector<ll> last(26, 0);
  // for (ll day = 0; day < D; ++day) {
  //   ll max_contest = 0;
  //   ll max_score = -INF;
  //   for (ll contest = 0; contest < 26; ++contest) {
  //     ll temp_score = evaluation(contest, day, last);
  //     if (temp_score > max_score) {
  //       max_score = temp_score;
  //       max_contest = contest + 1;
  //     }
  //   }
  //   last.at(max_contest - 1) = day;
  //   T.at(day) = max_contest;
  // }

  // for (ll i = 0; i < D; ++i) {
  //   cout << T.at(i) << "\n";
  // }

  ll score = evaluation(T);
  // cout << score << "\n";
  ll M;
  cin >> M;
  for (ll i = 0; i < M; ++i) {
    ll d, q;
    cin >> d >> q;
    score += change_evaluation(contest_data, q, d, T.at(d - 1));
    T.at(d - 1) = q;
    cout << score << "\n";
  }

  // vector<ll> ans = evaluation(C, S, T);
  // for (ll i = 0; i < ans.size(); ++i) {
  //   cout << ans.at(i) << "\n";
  // }
}


Measured memory_bytes: 3696
#include <stdio.h>
int main() {
  int n,f[100][10],p[100][11],max=0,i,x[100],j[10],k,y,l;
  scanf("%d",&n);
  for (i=0;i<n;i++) {
    for (k=0;k<10;k++) {
      scanf("%d",&f[i][k]);
    }
  }
  for (i=0;i<n;i++) {
    for (k=0;k<=10;k++) {
      scanf("%d",&p[i][k]);
    }
  }
  for (j[0]=1;j[0]>=0;j[0]--) {
  for (j[1]=1;j[1]>=0;j[1]--) {
  for (j[2]=1;j[2]>=0;j[2]--) {
  for (j[3]=1;j[3]>=0;j[3]--) {
  for (j[4]=1;j[4]>=0;j[4]--) {
  for (j[5]=1;j[5]>=0;j[5]--) {
  for (j[6]=1;j[6]>=0;j[6]--) {
  for (j[7]=1;j[7]>=0;j[7]--) {
  for (j[8]=1;j[8]>=0;j[8]--) {
  for (j[9]=1;j[9]>=0;j[9]--) {
    for (i=0;i<n;i++) {
      x[i]=0;
    }
    for (i=0;i<n;i++) {
      for (k=0;k<10;k++) {
        x[i]+=f[i][k]*j[k];
      }
    }
    y=0;
    for (i=0;i<n;i++) {
      y+=p[i][x[i]];
    }
    k=1;
    for (i=0;i<10;i++) {
      k*=j[i];
    }
    l=0;
    for (i=0;i<n;i++) {
      if (x[i]==0) {
        l++;
      }
    }
    if ((y>max&&l!=n)||k==1) {
      max=y;
    }
  }}}}}}}}}}
  printf("%d\n",max);
  return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include <string>
using namespace std;
int main()
{
	long n,d,x;
	cin >> n;
	cin >> d >> x;
  	long ans;
	long a[n];
  	int t;
	for(t = 0;t<n;t++){
      cin >> a[t];
    }
  	for(t = 0;t<n;t++){
      ans += (d-1)/a[t]+1;
    }
  	ans += x;
	cout << ans << endl;
	return 0;
}

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

int n,m;
vector<int> s;
int sh;

const int inf=INT_MAX/2;

bool f(int x)
{
    sh=inf;
    vector<int> dp(s.back()+1,inf);
    dp[0]=0;
    // cerr << x << endl;

    for(int i=0,j=0; i<s.back(); i++)
    {
        while(j<n and s[j]<i) j++;
        int inc=x+i>s[0];
        if(j>0) inc=max(inc,x-(i-s[j-1]));
        if(j<n and s[j]<i+x) inc=max(inc,x-(s[j]-i));
        auto &nx=dp[min(i+inc,s.back())];
        nx=min(nx,dp[i]+1);
        // cerr << dp[i] << " ";
    }
    // cerr << "\n";
    for(int i=s.back(); i+x>s.back(); i--)
    {
        if(m>1+dp[i]) return false;
        sh=min(sh,dp[i]+1);
    }
    return true;
}


void solve()
{
    int ok=0;
    int ng=s.back()+1;
    while(ng-ok>1)
    {
        int mid=(ok+ng)/2;
        if(f(mid)) ok=mid;
        else ng=mid;
    }
    f(ok);
    if(ok>0 && sh<inf) cout<<ok<<"\n";
    else cout<<"-1\n";
}


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

    while(1)
    {
        cin>>n>>m;
        if(!n) break;
        s.resize(n);
        for(int &x: s) cin>>x,--x;
        solve();
    }
}



Measured memory_bytes: 7656
#define _'			'
A[_];long P[_],M=1e9+7,F[_],I[_],X;i,j,k,t;
c(a,b)int*a,*b;{t=*a-*b?:a[1]-b[1];}
//c(a,b)long*a,*b;{t=*a<*b?-1:*a>*b;}
p(a,b){return b?p(a%M*a%M,b/2)*(b%2?a:1L)%M:1;}
f(a,b){return F[a+b]*I[a]%M*I[b]%M;}
main(s){
  for(*I=1;++X<_;~scanf("%d",A+i)&&i++%2&&gets(P))I[X]=p(s=F[X]=X*s%M,M-2);
  for(qsort(A,i/2,8,c);j<i;P[j++]=X)
    for(X=f(t=--A[k=++j],s=--A[j]);--k;
        X=t<A[--k]?X:(X-f(s-A[k-1],t-A[k])*P[k]%M+M)%M);
printf("%d",X);}

Measured memory_bytes: 14336
#include<bits/stdc++.h>
#define lln long long int
#define llu unsigned lln
#define sc(n) scanf("%d",&n);
#define scl(n) scanf("%lld",&n);
#define scd(n) scanf("%lf",&n);
#define pf(res) printf("%d\n",res);
#define pfl(res) printf("%lld\n",res);
#define pfd(res) printf("%lf\n",res);
#define maxii 10000005
using namespace std;
typedef pair<int,int> pii;
typedef pair<lln,lln> pll;
typedef vector<int> vi;
typedef vector<lln> vl;
typedef vector<pii> vii;
typedef vector<pll> vll;


lln arr[maxii];
lln arr2[maxii];

int main()
{
    lln n;
    scl(n)
   for(lln i=1;i<=n;i++)arr[i]=1;
    for(lln i=2;i<=n;i++)
    {
        for(lln j=i;j<=n;j+=i)
        {
            arr[j]=arr[j]+1LL;
        }

       // arr[i]=((arr[i-1]+arr[i]));;
    }
    lln sum=0;
    for(int i=2;i<=n;i++)
    {
        lln sum1=arr[i]*i;
        sum+=sum1;
    }
    sum++;
    pfl(sum)


}






Measured memory_bytes: 81772
#include<iostream>
#include<math.h>
using namespace std;
int main() {
  double PI = acos(-1);
  int A,B,H,M;
  cin >> A >> B >> H >> M;
  double ans;
  double arg = abs((double)(H*60+M)/720-(double)M/60);
  ans = sqrt(pow(A-B*cos(2*PI*arg),2)+pow(B*sin(2*PI*arg),2));
  printf("%.10lf\n",ans);
}

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

#define     ll     long long int

int main( )
{
    int ara[] = { 0, 1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51 };
    int k;
    cin >> k;
    cout << ara[k] << '\n';
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pi = pair<int, int>;
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);

    int n, d;
    cin >> n >> d;
    cout << (n-1)/(2*d+1) + 1;
}

Measured memory_bytes: 256
S = raw_input()

if len(S) != 4:
    print "No"
else:
    Dict = {}
    for s in S:
        if s in Dict.keys():
            Dict[s] += 1
        else:
            Dict[s] = 1
    if all([i==2 for i in Dict.values()]):
        print "Yes"
    else:
        print "No"

Measured memory_bytes: 2568
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define ALL(x) (x).begin(), (x).end()
#define REP(i ,n) for(int i = 0; i < (int)(n); i++)
#define pb push_back
typedef vector<int>vint;
typedef vector<ll>vll;
template<typename T> istream &operator>>(istream &is, vector<T> &vec){ for (auto &v : vec) is >> v; return is; }
template<typename A,typename B>inline void chmin(A &a,B b){if(a>b)a=b;}
template<typename A,typename B>inline void chmax(A &a,B b){if(a<b)a=b;}

int main()
{
  ll A,B,C,K;
  cin >> A >> B >> C >> K;
  ll ans = 0;
  if(K >= A){
    ans += A;
    K -= A;
  }else{
    ans += K;
    K = 0;
  }
  
  if(K >= B){
    K -= B;
  }else{
    K = 0;
  }
  
  if(K >= C){
    ans -= C;
    K -= C;
  }else{
    ans -= K;
    K = 0;
  }
  
  cout << ans << endl;
}


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

#define rep(i, n) for(int i=0; i<(n); ++i)
#define max  200001

//qsort(str, n, sizeof(int), up_comp);
int up_comp(const void *a, const void *b){return *(int*)a - *(int*)b;}
int down_comp(const void *a, const void *b){return *(int*)b - *(int*)a;}
int int_sort( const void * a , const void * b ) {return strcmp(( char * )a , ( char * )b );}
int count_digit(int a){int i=0;while(a!=0){a=a/10;i++;}return i;}
int euclid( int a, int b ){int temp;if(a<b){temp=a;a=b;b=temp;}if(b<1)return -1;if(a%b==0) return b;return euclid(b,a%b);}

int main(void){
 
    int x1, y1, x2, y2;
    int x, y;
    
    scanf("%d%d%d%d", &x1, &y1, &x2, &y2);
    x=x2-x1;
    y=y2-y1;
    
    printf("%d %d %d %d", x2-y, y2+x, x1-y, y1+x);
    
    return 0;
}


Measured memory_bytes: 1704
#include <cstdio>
#include <cmath>
#include <iostream>
#include <vector>
#include <string>
#include <queue>
#include <map>
#include <algorithm>

typedef long long ll;

const ll INF = 9999999;
const double EPS = 1e-10;
const double PI = acos(-1);


int main(int argc, char* argv[])
{
  ll H,W;
  ll c[10][10];
  ll wh[200][200];
  ll distance[10];

  std::cin >> H >> W;
  for (int i = 0; i < 10; i++) {
    for (int j = 0; j < 10; j++) {
      std::cin >> c[i][j];
    }
  }

  for (int w = 0; w < W; w++) {
    for (int h = 0; h < H; h++) {
      std::cin >> wh[w][h];
    }
  }

  for (int i = 0; i < 10; i++) {
    distance[i] = INF;
  }
  distance[1] = 0;

  //std::cout << "-----" << std::endl;
  while(1) {
    bool update = false;
    for (int i = 0; i < 10; i++) {
      for (int j = 0; j < 10; j++) {
	if (distance[j] < INF && distance[j] + c[i][j] < distance[i]) {
	  distance[i] = distance[j] + c[i][j];
	  update = true;
	  //std::cout << i << " " << distance[i] << " " << j << " " << distance[j] << std::endl;
	}
      }
    }
    if (!update){ break; }
  }

  ll ans = 0;
  for (int w = 0; w < W; w++) {
    for (int h = 0; h < H; h++) {
      if (wh[w][h] != -1) {
	ans += distance[wh[w][h]];
      }
    }
  }

  std::cout << ans << std::endl;
  
  return 0;
}



Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<=n;++i)
#define all(a) (a).begin(),(a).end()
#define lb(s,x) lower_bound(all(s),x)-s.begin()
#define ub(s,x) upper_bound(all(s),x)-s.begin()
#define uniq(a) a.erase(unique(all(a)),a.end())
#define debug(x) cout<<#x<<": "<<x<<endl
template<class T,class U>
ostream& operator<<(ostream& o, const pair<T,U> &p){
    o<<"("<<p.first<<", "<<p.second<<")";
    return o;
}
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
typedef long long ll;
const int INF = 1e9;


using P = pair<ll,int>;

// bool coloring(int v,int c,vector<int> &color, vector<vector<Edge>> &g){
//     if(color[v] == -c) return false;
//     if(color[v] ==  c) return true;
//     color[v] = c;
//     for(Edge e : g[v]){
//         if(!coloring(e.to,-c,color,g)){
//             return false;
//         }
//     }
//     return true;
// }


void dfs(int v,ll a,int signT,ll &maxT,ll &minT,
    vector<P> &visited,vector<vector<P>> &g){
    if(visited[v] != P(0,0)){
        ll b = visited[v].first;
        int sign = visited[v].second;
        if(a!=b && sign==signT) maxT = 0;
        if(sign != signT){
            if(abs(a-b)&1) maxT = 0;
            minT = max(minT, abs(a-b)/2);
            maxT = min(maxT, abs(a-b)/2);
        }
        return;
    }
    visited[v] = {a,signT};
    if(signT == +1) minT = max(minT, 1-a);
    if(signT == -1) maxT = min(maxT, a-1);
    for(P &e : g[v]){
        ll sum = e.first;
        int to = e.second;
        dfs(to,sum-a,-signT,maxT,minT,visited,g);
    }
}


// 1 --6-- 2
// 3 --7-/
// |---5-- 4

// 0+t --6-- 6-t
// 1+t --7-/
//   |---5-- 4-t

int main(void){
    int n,m;
    cin>>n>>m;
    vector<vector<P>> g(n);
    rep(i,m){
        int u,v;
        ll s;
        cin>>u>>v>>s;
        u--, v--;
        g[u].push_back({s,v});
        g[v].push_back({s,u});
    }

    // vector<int> color(n);
    // bool odd_cycle = !coloring(0,+1,color,g);
    // if(odd_cycle){

    // }
    // vector<ll> h(n);
    ll maxT = INF, minT = 0;
    vector<P> visited(n); // <a,sign> (a + sign*t)
    dfs(0,0,+1,maxT,minT,visited,g);
    cout<<max(0LL,maxT-minT+1)<<endl;
    return 0;
}



Measured memory_bytes: 18816
#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(){
  int n,m;
  cin >> n >> m;
  char s[n+10][n+10];
  char t[m+10][m+10];
  rep(i,n){
    rep(j,n){
      cin >> s[i][j];
    }
  }
  rep(i,m){
    rep(j,m){
      cin >> t[i][j];
    }
  }
  int a = n-m+1;
  int count = 0;
  rep(i,a){
    rep(j,a){
      rep(k,m){
        rep(l,m){
          if(s[k+i][l+j] == t[k][l]) ++count;
        }
      }
      if(count == m*m){
        puts("Yes");
        return 0;
      }
      count = 0;
    }
  }
  puts("No");
  return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <vector>
#include <string>
#include <sstream>
#include <utility>
#define rep(i,n) for (int i = 0; i < (n); ++i)

using namespace std;

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

int main () {
    int n, x, y;
    cin >> n >> x >> y;

    vi dist(n+1);
    for (int i=1; i <= n; ++i) {
        for (int j = i+1; j<=n; ++j) {
            int d = min(abs(i-j), 
                    min(abs(x-i) + 1 + abs(y-j), abs(y-i) + 1 + abs(x-j)));
            dist[d]++;
        }
    }
    for (int i = 1; i < n; ++i) 
        cout << dist[i] << endl;
    return 0;
}

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

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

using namespace std;
using namespace __gnu_pbds;
/*
template<typename T>
using ordered_set = tree<T,null_type,less<T>,rb_tree_tag,tree_order_statistics_node_update>;
*/
using ll = long long;
using ull = unsigned long long;
using ld = long double;

#define forn(i, a, n) for (int i = (int)(a); i < (int)(n); ++i)
#define ford(i, a, n) for (int i = (int)(n - 1); i >= (int)(a); --i)
#define fore(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define all(a) (a).begin(), (a).end()
#define fs first
#define sn second
#define trace(a)\
    for (auto i : a) cerr << i << ' ';\
    cerr << '\n'
#define eb emplace_back

#ifndef M_PI
const ld M_PI = acos(-1.0);
#endif

template<typename T>
inline void setmax(T& a, T b) {
    if (a < b) a = b;
}

template<typename T>
inline void setmin(T& a, T b) {
    if (a > b) a = b;
}

const ld eps = 1e-12, eps1 = 1e-12;
const int INF = 2000000000;
const ll LINF = 1ll * INF * INF;
const ll MOD = 1000000007;

struct Line {
    ll a, b, c;

    Line () {}
    Line (ll _a, ll _b, ll _c) : a(_a), b(_b), c(_c) {}

    ld val(ld x) {
        return (c - a * x) / b;
    }
};

const int N = 1e5 + 10;
Line ls[N];
ld vals[N];

struct Cmp {
    Cmp () {}

    bool operator() (const int& x, const int& y) const{
        return (ls[x].a * ls[y].b < ls[x].b * ls[y].a) ^ (ls[x].b < 0) ^ (ls[y].b < 0);
    }
};
using ordered_set = tree<int,null_type,Cmp,rb_tree_tag,tree_order_statistics_node_update>;

ld solve(int n) {
    vector<int> ix(n);
    forn(i, 0, n) ix[i] = i;
    ld l = -1e9, r = 1e9;
    ll cnt = 1ll * n * (n - 1) / 2;
    int its = 85;
    while (its--) {
        ld m = (l + r) / 2;
        //cerr << l << ' ' << r  << '\n';
        //cerr << m << ' ';
        forn(i, 0, n) vals[i] = ls[i].val(m);
        auto cmp = [&](int x, int y) {
            return vals[x] < vals[y] - eps1;
        };
        sort(all(ix), cmp);
        ll rgt = 0;
        ordered_set a;
        //cerr << "lines:\n";
        for (int i : ix) {
            //cerr << i << ' ' << a.order_of_key(i) << '\n';
            rgt += a.order_of_key(i);
            a.insert(i);
        }
        if (rgt > cnt / 2) l = m;
        else r = m;
    }
    return (l + r) / 2;
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); 
    srand((unsigned)chrono::high_resolution_clock::now().time_since_epoch().count());
    cout << fixed << setprecision(12);
    int n;
    cin >> n;
    //n = 4e4;
    const int x = 1e4;
    forn(i, 0, n) /*{
        ls[i].a = rand() % (2 * x) - x;
        ls[i].b = rand() % (2 * x) - x;
        ls[i].c = rand() % (2 * x) - x;
        if (ls[i].a == 0) ++ls[i].a;
        if (ls[i].b == 0) ++ls[i].b;
    }*/cin >> ls[i].a >> ls[i].b >> ls[i].c;
    cout << solve(n) << ' ';
    forn(i, 0, n) swap(ls[i].a, ls[i].b);
    cout << solve(n) << '\n';
}


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

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

	if (n % 10 == 3) {
		cout << "bon" << endl;
	} else if (n % 10 == 0 || n % 10 == 1 || n % 10 == 6 || n % 10 == 8) {
		cout << "pon" << endl;
	} else {
		cout << "hon" << endl;
	}
	return 0;
}

Measured memory_bytes: 3632
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

int main() {
	vector<int64_t> a(7);
	
	for(int i = 0; i < 7; ++i) {
		cin >> a[i];
	}
	
	int I = a[0], J = a[3], L = a[4];
	
	int64_t ans = a[1];
	
	if(I > 2) {
		ans += (I - 2) / 2 * 2;
		I = 2 + (I - 2) % 2;
	}
	
	if(J > 2) {
		ans += (J - 2) / 2 * 2;
		J = 2 + (J - 2) % 2;
	}
	
	if(L > 2) {
		ans += (L - 2) / 2 * 2;
		L = 2 + (L - 2) % 2;
	}
	
	int maxi = 0;
	for(int I1 = 0; I1 <= I; ++I1) {
		int I2 = I - I1;
		
		int x = min({I1, L, J});
		
		maxi = max(maxi, 3 * x + I2 / 2 * 2 + (L - x) / 2 * 2 + (J - x) / 2 * 2);
	}
	
	cout << ans + maxi << endl;
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

const int inf = 2e9;

int n, k;
int h[100100], dp[100100];

int min(int a, int b) {
    return (a < b ? a : b);
}

int main() {
    scanf("%d%d", &n, &k);
    for (int i = 0; i < n; i++) scanf("%d", &h[i]);
    for (int i = 0; i < n; i++) dp[i] = inf;
    dp[0] = 0;
    for (int i = 1; i < n; i++) {
        for (int j = i - 1; j >= i - k && j >= 0; j--) {
            dp[i] = min(dp[i], dp[j] + abs(h[i] - h[j]));
        }
    }
    printf("%d\n", dp[n - 1]);
}

Measured memory_bytes: 896
const config = {
    input: '/dev/stdin',
    newline: '\n'
};

const line = require('fs').readFileSync(config.input, 'utf-8').split(config.newline);

const data = {
    pond : [],
    stack : []
};

const results = line[0].split('').reduce((acc, x, i) => {
    if (x === '\\') {
        acc.stack.push(i);
    } else if (x === '/' && acc.stack.length > 0) {
        const k = acc.stack.pop();
        const hd = acc.pond.filter(xs => xs[0] >= k);
        const tl = acc.pond.filter(xs => xs[0] < k);

        const sum = [k, hd.map(xs => xs[1]).reduce((acc, x) => acc + x, 0) + (i - k)]
        tl.push(sum);
        acc.pond = tl;
    }

    return acc;
}, data);

const sum = results.pond.reduce((acc, x) => acc + x[1], 0);
const l = results.pond.length;

console.log(sum);
console.log(`${l}${l > 0 ? ' ' + results.pond.map(x => x[1].toString()).join(' ') : ''}`);



Measured memory_bytes: 25392
#!/usr/bin/env python
# -*- coding: utf-8 -*-

import sys  # {{{
import os
import time
import re
from pydoc import help
import string
import math
from operator import itemgetter
from collections import Counter
from collections import deque
from collections import defaultdict as dd
import fractions
from heapq import heappop, heappush, heapify
import array
from bisect import bisect_left, bisect_right, insort_left, insort_right
from copy import deepcopy as dcopy
import itertools
# }}}

# pre-defined{{{
sys.setrecursionlimit(10**7)
INF = 10**20
GOSA = 1.0 / 10**10
MOD = 10**9+7
ALPHABETS = [chr(i) for i in range(ord('a'), ord('z')+1)]  # can also use string module
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 LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def DP(N, M, first): return [[first] * M for n in range(N)]
def DP3(N, M, L, first): return [[[first] * L for n in range(M)] for _ in range(N)]
from inspect import currentframe
def dump(*args):
    names = {id(v):k for k,v in currentframe().f_back.f_locals.items()}
    print(', '.join(names.get(id(arg),'???')+' => '+repr(arg) for arg in args), file=sys.stderr)
# }}}

def local_input():# {{{
    from pcm.utils import set_stdin
    import sys
    from pathlib import Path
    parentdir = Path(os.path.dirname(__file__)).parent
    inputfile = parentdir.joinpath('test/sample-1.in')
    if len(sys.argv) == 1:
        set_stdin(inputfile)
# }}}

def solve():
    x, y = map(int, input().split())
    if abs(x-y) <= 1:
        print("Brown")
    else:
        print("Alice")
    return 0

if __name__ == "__main__":# {{{
    try:
        local_input()
    except:
        pass
    solve()
# vim: set foldmethod=marker:}}}


Measured memory_bytes: 107884
fun main(args: Array<String>){
    val n = readLine()!!.toInt()
    val S = readLine()!!.split(' ').map{ it.toInt() }.distinct().sorted()
    val q = readLine()!!.toInt()
    val T = readLine()!!.split(' ').map{ it.toInt() }
    assert (n >= S.size)
    assert (q >= T.size)
    var ans = 0
    for(t in T){
        val idx = binarySearch(t, S)
        if (S[idx] == t) ans++
    }
    println(ans)
}

fun <T: Comparable<T>> binarySearch(element: T, list: List<T>): Int{
    var left = 0
    var right = list.size - 1
    while(left < right){
        val mid = (left+right)/2
        if (list[mid] > element){
            right = mid - 1
        }else if(list[mid] < element){
            left = mid + 1
        }else{ return mid }
    }
    return left
}


Measured memory_bytes: 69480
#include <stdio.h>

int ban[502][502],n,aru[502][502];

void rep(int x, int y, int t) {
   if (x>0 && aru[x-1][y] && ban[x-1][y]>t+1) {
      ban[x-1][y]=t+1;
      rep(x-1,y,t+1);
   }
   if (x>0 && !aru[x-1][y] && ban[x-1][y]>t) {
      ban[x-1][y]=t;
      rep(x-1,y,t);
   }
   if (x<n && aru[x+1][y] && ban[x+1][y]>t+1) {
      ban[x+1][y]=t+1;
      rep(x+1,y,t+1);
   }
   if (x<n && !aru[x+1][y] && ban[x+1][y]>t) {
      ban[x+1][y]=t;
      rep(x+1,y,t);
   }
   if (y>0 && aru[x][y-1] && ban[x][y-1]>t+1) {
      ban[x][y-1]=t+1;
      rep(x,y-1,t+1);
   }
   if (y>0 && !aru[x][y-1] && ban[x][y-1]>t) {
      ban[x][y-1]=t;
      rep(x,y-1,t);
   }
   if (y<n && aru[x][y+1] && ban[x][y+1]>t+1) {
      ban[x][y+1]=t+1;
      rep(x,y+1,t+1);
   } 
   if (y<n && !aru[x][y+1] && ban[x][y+1]>t) {
      ban[x][y+1]=t;
      rep(x,y+1,t);
   } 
}

int main(){
   int  i,j,k,l,n1,x,y,p,t,tt,to;
   long ans;

   scanf("%d",&n);
   n1=n+1;i=0;j=n+1;
   for (;i<=j;i++,j--)
      for (k=i;k<=j;k++) ban[k][i]=ban[k][j]=ban[i][k]=ban[j][k]=i;
   for (i=1;i<=n;i++)
      for (j=1;j<=n;j++) aru[i][j]=1;
   for (i=0;i<=n1;i++) aru[i][0]=aru[i][n1]=aru[0][i]=aru[n1][i]=0;
   ans=0;
   for (k=0;k<n*n;k++) {
      scanf("%d",&p);
      p--;
      x=p%n+1;y=p/n+1;
      t=ban[x-1][y];
      if (t>ban[x+1][y]) t=ban[x+1][y];
      if (t>ban[x][y-1]) t=ban[x][y-1];
      if (t>ban[x][y+1]) t=ban[x][y+1];
      ans+=t;
      rep(x,y,t);
      ban[x][y]=t;
      aru[x][y]=0;
/*     printf("p=%d x=%d y=%d ans=%ld\n",p+1,x,y,ans);
   for (i=0;i<=n1;i++) {
      for (j=0;j<=n1;j++) printf("%d ",ban[i][j]);
      puts("");
   }
      puts("");*/
   }
   printf("%ld\n",ans);
   return 0;
}


Measured memory_bytes: 38460
n,m = map(int,input().split())
S = []
C = []
for i in range(m):
    s,c= map(int,input().split())
    S.append(s)
    C.append(c)
ans = [0]*n
ref = [0]*n
flag = 1

for i in range(m):
    if ref[S[i]-1] == 0:
        ans[S[i]-1] = C[i]
        ref[S[i]-1] = 1
    elif ref[S[i]-1] == 1 and ans[S[i]-1]==C[i]:
        pass
    else:
        flag = 0
        break

if flag==1:
    if n>1 and ans[0]==0:
        if ref[0]==0:
            ans[0]=1
            anss = ""
            for s in ans:
                anss += str(s)
            print(int(anss)) 
        else:
            print(-1)
    elif n>1 and ans[0]!=0:
        anss = ""
        for s in ans:
            anss += str(s)
        print(int(anss))
    else:
        print(ans[0])
else:
    print(-1)


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

int main() {
	// your code goes here
	int n;
	cin>>n;
	int arr[n];
	for(int i = 0;i<n;i++)
	{
		cin>>arr[i];
	}
	ll sum = 0;
	if(n==1)
	cout<<0<<"\n";
	else{
	sort(arr,arr+n,greater<int>());
    sum += arr[0]; // first element..
    int i = 0;
    n = n-2;
    if(n%2==0)
    {
    	while(n>0){
    	sum += 2*arr[i+1];
    	i++;
    	n = n-2;
    	}
    }
    else
    {
    	i = 0;
    	while(n>1){
    	sum += 2*arr[i+1];
    	i++;
    	n = n-2;
    	}
    	sum += arr[i+1];
    }
	
	cout<<sum<<"\n";
	}
	return 0;
}

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

int main() {
  int N;
  cin >> N;
  vector<int> A(N);
  for (int i = 0; i < N; ++i)
    cin >> A[i];
  int ans = 1;
  for (int i = 1; i < N; ++i)
    if (A[i] <= A[i - 1])
      ++ans;
  cout << ans << endl << N << endl;
}


Measured memory_bytes: 3124
n=int(input())
d=list(map(int,input().split()))
d.sort()
count=0
R=d[n//2-1]
L=d[n//2]
if L==R:
    count=0
else:
    count=L-R
print(count)
#print(d)
#print(str(R)+" "+str(L)) 

Measured memory_bytes: 14396
#include <stdio.h>

int main(void) {
	int L, A, B, C, D;
	int i;
	
	scanf("%d", &L); scanf("%d", &A); scanf("%d", &B); scanf("%d", &C); scanf("%d", &D);
	for (i = 0; A > C || B > D; i++){
		A -= C;
		B -= D;
	}
	
	if (A == 0 || B == 0){
	}
	else {
		i++;
	}
	printf("%d\n", L - i);
	
	// your code goes here
	return 0;
}

Measured memory_bytes: 596
#pragma GCC optimize ("O2")
#pragma GCC target ("avx2")
#include<bits/stdc++.h>

using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (n); i++)
#define rep1(i, n) for(int i = 1; i <= (n); i++)
#define co(x) cout << (x) << "\n"
#define cosp(x) cout << (x) << " "
#define ce(x) cerr << (x) << "\n"
#define cesp(x) cerr << (x) << " "
#define pb push_back
#define mp make_pair
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
#define Would
#define you
#define please

int V[3000][3000];
ll dp[3001];

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


	int R, C, K;
	cin >> R >> C >> K;

	rep(i, K) {
		int r, c, v;
		cin >> r >> c >> v;
		V[r - 1][c - 1] = v;
	}

	rep(i, R) {
		ll A[4] = {};
		rep(j, C) {
			chmax(A[0], dp[j]);
			if (V[i][j]) {
				chmax(A[3], A[2] + V[i][j]);
				chmax(A[2], A[1] + V[i][j]);
				chmax(A[1], A[0] + V[i][j]);				
			}
			dp[j] = max(max(A[0], A[1]), max(A[2], A[3]));
		}
	}

	ll kotae = dp[C - 1];

	co(kotae);

	Would you please return 0;
}

Measured memory_bytes: 38752
import java.util.Scanner;
import java.util.stream.IntStream;

public class Main {

	/** 最終的の色の数 */
	private static final int N = 3;

	public static void main(String[] args) {
		try (Scanner scanner = new Scanner(System.in)) {
			int n = scanner.nextInt(), c = scanner.nextInt();
			int[][] d = new int[c][c];
			// cost[a][b]は(i+j)%3がaのコマを色bに塗り替える場合の違和感の和
			int[][] cost = new int[N][c];
			IntStream.range(0, c).forEach(i -> IntStream.range(0, c).forEach(j -> d[i][j] = scanner.nextInt()));
			IntStream.range(0, n).forEach(i -> IntStream.range(0, n).forEach(j -> {
				int now = scanner.nextInt() - 1;
				int index = (i + j) % N;
				IntStream.range(0, c).forEach(k -> cost[index][k] += d[now][k]);
			}));
			System.out.println(IntStream.range(0, c)
					.map(i -> IntStream.range(0, c).filter(j -> i != j)
							.map(j -> IntStream.range(0, c).filter(k -> (i != k) && (j != k))
									.map(k -> cost[0][i] + cost[1][j] + cost[2][k]).min().getAsInt())
							.min().getAsInt())
					.min().getAsInt());
		}
	}
}


Measured memory_bytes: 61304
#include<bits/stdc++.h>
typedef long long int ll;
typedef unsigned long long int ull;
#define BIG_NUM 2000000000
#define HUGE_NUM 1000000000000000000
#define MOD 1000000007
#define EPS 0.000000001
using namespace std;



int N;
int POW[31];

int main(){

	POW[0] = 1;
	for(int i = 1; i <= 30; i++){

		POW[i] = POW[i-1]*2;
	}

	scanf("%d",&N);

	int tmp,ans = 0;

	for(int i = 0; i < N; i++){

		scanf("%d",&tmp);
		for(int k = 30; k >= 0; k--){
			if(tmp%POW[k] == 0){

				ans += k;
				break;
			}
		}
	}

	printf("%d\n",ans);

	return 0;
}


Measured memory_bytes: 3748
def check(num, k):
    if(num == k):
        return True
    else:
        return False


def main():
    a, b, c, k = map(int, input().strip().split())
    ans = 0
    chosen = 0

    if(k<=a):
        if(k==a):
            ans = a
        else:
            ans = k
    else:
        ans = a
        chosen = a
        if((k-chosen)>b):
            chosen += b
            if((k-chosen)<=c):
                if((k-chosen)==c):
                    ans += (-1*c)
                else:
                    ans += (-1*(k-chosen))

    print(ans)
 
main()


Measured memory_bytes: 9188
#define _USE_MATH_DEFINES

#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <utility>
#include <climits>
#include <vector>
#include <map>
#include <queue>
#include <set>
using namespace std;

#define ll long long
const int MOD = 1000000007;//10^9+7
const string SPACE = " ";

ll powsur(ll a, ll b, ll p) {

	if (b == 0) {

		return 1;

	}
	else if (b % 2 == 0) {

		ll d = powsur(a, b / 2, p);
		return ((d%p)*(d%p)) % p;

	}
	else {

		return ((a%p)*powsur(a, b - 1, p) % p) % p;

	}

}
//pは素数,aのb乗をpで割った余り

ll CMOD(ll n, ll r, ll p) {

	ll a = 1, b = 1, c = 1, re;
	for (int i = 1; i <= n; i++) {

		a *= i;
		a = a%p;

	}
	for (int i = 1; i <= r; i++) {

		b *= i;
		b = b%p;

	}
	for (int i = 1; i <= n - r; i++) {

		c *= i;
		c = c%p;

	}
	b = powsur(b, p - 2, p);
	c = powsur(c, p - 2, p);
	re = ((a%p)*(b%p)) % p;
	re = ((re%p)*c%p) % p;

	return re;

}
//pは素数,(nCr)%p

ll gcd(ll a, ll b) {

	if (a > b) {

		ll tmp = a;
		a = b;
		b = tmp;

	}
	ll r;
	r = b%a;
	if (r == 0)return a;
	else return gcd(r, a);

}
//最大公約数

ll lcm(ll a, ll b) {

	return (a / gcd(a, b))*b;

}
//最小公倍数

ll MAX(ll a, ll b) {

	if (a > b)return a;
	else return b;

}
//MAX

ll MIN(ll a, ll b) {

	if (a < b)return a;
	else return b;

}
//MIN

bool p_judge(ll p) {

	if (p == 1)return false;
	else if (p == 2)return true;
	else {

		bool flag = true;
		for (int i = 2; i <= sqrt(p); i++) {

			if (p%i == 0) {

				flag = false;
				break;

			}

		}
		return flag;

	}

}
//素数判定,素数=true,合成数=false

int main() {

	ll N, A[100005], ans = 0;

	cin >> N;
	for (int i = 0; i < N; i++) {

		cin >> A[i];

	}
	sort(A, A + N);

	int tmp = 0, cnt = 0;
	for (int i = 0; i < N; i++) {

		if (A[i] != tmp) {

			if (tmp < cnt) {

				ans += cnt - tmp;

			}
			else if (tmp > cnt) {

				ans += cnt;

			}
			cnt = 1;
			tmp = A[i];

		}
		else {

			cnt++;

		}

	}
	if (tmp < cnt) {

		ans += cnt - tmp;

	}
	else if (tmp > cnt) {

		ans += cnt;

	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 1024
import java.util.Scanner;

public class Main {
	private Scanner sc;
	public static void main(String[] args) {
		new Main();
	}
	
	public Main() {
		sc = new Scanner(System.in);

		int nico = Integer.parseInt(sc.nextLine());

		int[] mul = new int[3];
		for (int i = 0; i < mul.length; i++) {
			mul[i] = 0;
		}
		
		for (int i = 0; i < nico; i++) {
			int num = sc.nextInt();
			
			if (num % 2 != 0) {
				mul[0]++;
			} else if ((num / 2) % 2 != 0) {
				mul[1]++;
			} else {
				mul[2]++;
			}
		}
		
		String ans = "Yes";
		if (mul[0] == (mul[2] + 1)) {
			if (mul[1] != 0) ans = "No";
		} else if (mul[0] > (mul[2] + 1)) {
			ans = "No";
		}
		

		System.out.println(ans);
	}
}

Measured memory_bytes: 48828
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace A
{
    class Program
    {
        public static void Main(string[] args)
        {
            var n = ReadLineInt();
            
            Console.WriteLine((n < 1200) ? "ABC" : "ARC");
            ReadLine();
        }

        /// <summary>
        /// コンビネーション
        /// </summary>
        /// <param name="n"></param>
        /// <param name="m"></param>
        /// <returns></returns>
        static int nCm(int n, int m)
        {
            if (m == 0) return 1;
            if (n == 0) return 0;
            return n * nCm(n - 1, m - 1) / m;
        }

        /// <summary>
        /// stringを一文字ずつintにキャストして配列に変換します。
        /// </summary>
        /// <param name="str"></param>
        /// <returns></returns>
        public static int[] StringCharArrayIntArray(string str)
        {
            List<int> b = new List<int>();
            for (int i = 0; i < str.Length; i++) {
                b.Add( int.Parse(str[i].ToString()));
            }
            return b.ToArray();
        }

        public static string ReadLine()
        {
            return Console.ReadLine();
        }

        public static int ReadLineInt()
        {
            return int.Parse(Console.ReadLine());
        }

        public static string[] ReadLineStringSplit(char a = ' ')
        {
            return ReadLine().Split(a).ToArray();
        }

        public static int[] ReadLineIntSpilit(char a = ' ')
        {
            return ReadLine().Split(a).Select(x => int.Parse(x)).ToArray();
        }

        static string[] GetAplhaLowerArray() => new string[]{ "a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q", "r", "s", "t", "u", "v", "w", "x", "y", "z"};
        static string[] GetAplhaUpperArray() => new string[] { "A", "B", "C", "D", "E", "F", "G", "H", "I", "J", "K", "L", "M", "N", "O", "P", "Q", "R", "S", "T", "U", "V", "W", "X", "Y", "Z" };
    }
}

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

typedef long long ll;
typedef unsigned long long ull;

constexpr size_t MAXN = 1e5;
constexpr size_t MAXM = 1e5;
constexpr int MOD = 1e9 + 7;

std::vector<std::vector<int>> graph;
std::vector<int> dp;
std::vector<bool> traversed;

void traverse(int to) {
  for (int from : graph[to]) {
    if (!traversed[from]) {
      traverse(from);
      traversed[from] = true;
    }
    dp[to] = std::max(dp[to], dp[from] + 1);
  }
}

void solve() {
  int N, M;
  std::cin >> N >> M;
  graph.resize(N + 1);
  dp.resize(N + 1);
  traversed.resize(N + 1);
  for (int i = 0; i < M; ++i) {
    int from, to;
    std::cin >> from >> to;
    graph[to].push_back(from);
  }

  for (int to = 1; to <= N; to++) {
    if (!graph[to].empty()) {
      traverse(to);
    }
  }

  int mx = dp[0];
  for (int to : dp) {
    mx = std::max(to, mx);
  }

  std::cout << mx << "\n";
}

void warp() {
std::ios_base::sync_with_stdio(false);
std::cin.tie(0);
std::cout.tie(0);
// freopen("input.txt", "r", stdin);
// freopen("output.txt", "w", stdout);
}

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


Measured memory_bytes: 18212
import java.util.Scanner;
public class Main{
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
    int n = sc.nextInt();
    int[] array = new int[3];
    for(int i = 0; i < 3; i++){
      array[i] = -1;
    }
    int m = sc.nextInt();
    for(int i = 0; i < m; i++){
      int s = sc.nextInt();
      int c = sc.nextInt();
      if(n!=1&&s==1&&c==0){
        System.out.println(-1);
        return;
      }
      if(array[s-1]!=-1&&array[s-1]!= c){
        System.out.println(-1);
        return;
      }
      array[s-1] = c;
    }
    for(int i = 0; i < 3; i++){
      if(n!=1&&i==0&&array[i]==-1){
        array[i] = 1;
      }
      if(array[i]==-1){
        array[i]=0;
      }
    }
    int num = 0;
    for(int i = 0; i < n; i++){
      num = num*10;
      num+=array[i];
    }
    System.out.println(num);
  }
}

Measured memory_bytes: 21716
#include <cstdio>
#include <iostream>
#include <queue>
typedef long long ll;
using namespace std;
ll MOD = 1000000007;

int main(){
    int N, M;
    cin >> N >> M;
    queue<int> que;
    for(int i=0; i < M; i++){
        int tmp;
        cin >> tmp;
        que.push(tmp);
    }
    ll pre, now;
    if(que.front()==1){
        pre = 1;
        now = 0;
        que.pop();
    }
    else{
        pre = 1;
        now = 1;
    }
    for(int n=0; n<N-1; n++){
        int aaa = now;
        now = (now + pre) % MOD;
        pre = aaa;
        if(n+2 == que.front()){
            now = 0;
            que.pop();
        }
    }
    cout << now << endl;
}

Measured memory_bytes: 640
#include<cstdio>

long long a,b,x;
long long s,e;
int main(){
    scanf("%lld%lld%lld",&a,&b,&x);
    if(a%x==0)s=a/x;//这里的判断是为了看除出来是否为整数，如果不是整数就加一
    else s=a/x+1;
    e=b/x;//这里除出来会自动向下取整，不用判断
    printf("%lld",e-s+1);//这里大家可能有疑问：如果没有答案会输出什么？
    //其实，如果没有答案，e-s会是-1，所以输出的就是0啦。
    return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int sum = 0;
		for(int i = 1; i <= N; i++) {
			sum += i;
		}
		System.out.println(sum);
	}

}

Measured memory_bytes: 27000
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <algorithm>
#include <cmath>
#include <sstream>
#include <iomanip>
using namespace std;
typedef long long int ll;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define yes cout << "yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
#define no cout << "no" << endl

const int INF = 1001001001;
const int mod = 1000000007;
#define PI 3.14159265359;

void P(int x) {cout << x << endl;}
void P(long x) {cout << x << endl;}
void P(double x) {cout << x << endl;}
void P(ll x) {cout << x << endl;}
void P(string x) {cout << x << endl;}
void P(char x) {cout << x << endl;}

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

int main() {
  string a, b;
  cin >> a >> b;
  int con = stoi(a + b);
  rep (i, INF) {
    if (i * i == con) {
      Yes;
      return 0;
    }
    if (i * i > con) break;
  }
  No;



  return 0;
}



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

using namespace std;
#define ll long long int

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

    int D1[100];

    int D2[100];

    int D3[100];

    if (D == 0 && N < 100)
    {
        for (int i = 1; i <= 100; i++)
            D1[i] = i;
        cout << D1[N];
    }
    else if (D == 0 && N==100)
    {
       cout << "101";
    }
    else if (D == 1 && N < 100)
    {
        for (int i = 1; i < 100; i++)
            D2[i] = 100 * i;
        cout << D2[N];
    }
    else if (D == 1 && N == 100)
    {
       cout << 101*100;

    }
    else if (D == 2 && N < 100)
    {
        for (int i = 1; i < 100; i++)
            D3[i] = 10000*i;
        cout << D3[N];
    }
    else if (D == 2 && N == 100 )
    
       cout << 101*10000;

    return 0;
}


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

#define all(s) s.begin(), s.end()
#define vi vector<int>
#define pb push_back
#define ii pair<int, int>
#define x first
#define y second

const int N = 400005;
const int MOD = 1000000007;

int n;
int c[N];
int p[N];

int main() {
    ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    cin >> n;
    for (int i = 1; i <= n; i++) {
        cin >> c[i];
    }
    p[0] = 1;
    for (int i = 1; i <= 2 * n; i++) {
        p[i] = p[i - 1] * 2 % MOD;
    }
    sort(c + 1, c + 1 + n);
    int ans = 0;
    for (int i = 1; i <= n; i++) {
        ans = (ans + 1LL * c[i] * (n - i) % MOD * p[2 * n - 2] % MOD) % MOD;
        ans = (ans + 1LL * c[i] * p[2 * n - 1] % MOD) % MOD;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define PI 3.141592653589793
#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, a, n) for (int i = a; i < (n); i++)
#define rrep(i, n, k) for (int i = (n); i >= (k); i--);
#define all(x) (x).begin(), (x).end()
#define vi vector<int>
template<class T> istream &operator>>(istream&is,vector<T>&v){for(auto &elemnt:v)is>>elemnt;return is;}
template<class T,class U> istream &operator>>(istream&is,pair<T,U>&p){is>>p.first>>p.second;return is;}
template<class T>vector<T> make_vector(size_t a){return vector<T>(a);}
template<class T, class... Ts>auto make_vector(size_t a, Ts... ts){return vector<decltype(make_vector<T>(ts...))>(a, make_vector<T>(ts...));}
const int MOD = 998244353;
const int INF = 9e18;

signed main() {
    string S;
    cin >> S;
    if (S == "hi" || S == "hihi" || S== "hihihi" || S == "hihihihi" || S == "hihihihihi") {
        cout << "Yes" << endl;
    } else {
        cout << "No" << endl;
    }
}


Measured memory_bytes: 256
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let v = read_vec::<usize>();
    let (n, m) = (v[0], v[1]);
    let a = read_vec::<i64>();

    let mut ans = a.iter().sum::<i64>();
    let mut heap = BinaryHeap::new();

    let mut used = vec![0; n];

    for i in 0..n {
        heap.push((a[i] - a[i] / 2, i));
    }

    for _ in 0..m {
        let (decreased, i) = heap.pop().unwrap();
        if decreased == 0 {
            break;
        }
        ans -= decreased;
        used[i] += 1;
        let cur_rate = 1 << used[i];
        heap.push((a[i] / cur_rate - a[i] / cur_rate / 2, i));
    }
    println!("{}", ans);
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 11512
#include <stdio.h>

int main (void)
{
 char s[200000];
  int len,i=0;
  
  scanf("%s", &s);
  
  while(s[i]){
    len++;
    i++;
  }
  
  for(i=0;i<len;i++){
    if(s[i] == '?' && s[i-1] == 'P')
      s[i] = 'D';
    if(s[i] == '?' && s[i+1] == 'D')
      s[i] = 'P';
    else if(s[i] == '?')
      s[i] = 'D';
  }
  
    printf("%s", s);
 
  return 0;
  
}


Measured memory_bytes: 1920
import sys
s = list(input())

l = []
before = 0

for i in range(len(s) - 1):
    if s[i] == "L" and s[i + 1] == "R":
        l.append(s[before:i + 1])
        before = i + 1
    if i == len(s) - 2:
        l.append(s[before:i + 1] + ["L"])

for i in range(len(l)):
    for j in range(len(l[i]) - 1):
        if l[i][j] == "R" and l[i][j + 1] == "L":
            l[i][j] = j

a=[]
for i in range(len(l)):
    mid = 0
    ans = [0 for i in range(len(l[i]))]
    for j in l[i]:
        if type(j) == int:
            mid = j
            break
    for j in range(len(l[i])):
        if j == mid:
            ans[mid]+=1
            continue
        if (j - mid) % 2 == 1:
            ans[mid + 1]+=1
        else:
            ans[mid]+=1
    a.extend(ans)
print(*a)

Measured memory_bytes: 64376