akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
using int64 = long long;
#define int int64
#define rep(i, n) for(int i=0; i<n; i++)
#define FOR(i, a, b) for(int i=a; i<b; i++)
#define SORT(x) sort(x.begin(), x.end())
#define GSORT(x) sort(x.begin(), x.end(), greater<int>())
#define mk make_pair
#define fi first
#define se second
#define pb push_back
#define ALL(x) x.begin(), x.end()
#define V(T) vector<T>
typedef pair<int, int> P;
typedef pair<P, P> PP;
typedef vector<int> vi;
typedef vector<vi> vvi;
int max(int a, int b) {if(b>a) return b; else return a;}
int min(int a, int b) {if(b<a) return b; else return a;}


signed main() {
    int N;
    cin >> N;
    vi d(N);
    rep(i, N) cin >> d[i];

    int res = 0;
    rep(i, N-1) {
        FOR(j, i+1, N) {
            res += d[i]*d[j];
        }
    }

    cout << res << endl;

    return 0;
}

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

#define rep(i,s,n) for (int i = (int)s; i < (int)n; i++)
#define ll long long
#define pb push_back
#define All(x) x.begin(), x.end()
#define Range(x, i, j) x.begin() + i, x.begin() + j
#define lbidx(x, y) lower_bound(x.begin(), x.end(), y) - x.begin()
#define ubidx(x, y) upper_bound(x.begin(), x.end(), y) - x.begin()
#define BiSearchRangeNum(x, y, z) lower_bound(x.begin(), x.end(), z) - lower_bound(x.begin(), x.end(), y)turn idx;
#define deg_to_rad(deg) ((((double)deg)/((double)360)*2*M_PI))
#define rad_to_deg(rad) ((((double)rad)/(double)2/M_PI)*(double)360)

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

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

int main() {
  int N;
  string S;
  cin >> N;
  cin >> S;

  vector<char> s(S.size());
  rep(i, 0, S.size()) {
    s[i] = S[i] + N;
    if (s[i] > 'Z') {
      s[i] -= 26;
    }
  }
  rep(i, 0, s.size()) {
    cout << s[i];
  }
  cout << endl;
};


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define ld long double
#define f first
#define s second
#define pb push_back
#define eb emplace_back
#define mk make_pair
#define mt make_tuple
#define MOD 1000000007
#define fo(i,a,b) for(i=a;i<b;i++)
#define foe(i,a,b) for(i=a;i<=b;i++)
#define all(x) x.begin(), x.end()
#define vi vector<int>
#define vl vector <long long int>
#define pii pair <int,int>
#define pll pair <long long int, long long int>
#define vpii vector< pair<int,int> >
#define vpll vector < pair <long long int,long long int> >
#define boost ios::sync_with_stdio(false); cin.tie(0)
using namespace std;
const int inf = 1e9 + 5;
const ll inf64 = 1e18 + 5;
int main()
{
	boost;
	int n, i;
	cin >> n;
	int g = __gcd(360, n);
	int lcm = (360 * n) / g;
	cout << lcm / n;
}


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

int main() {
  string s;
  cin >> s;

  vector<int> v(s.size());

  if (s.back() == 'W')
    v.back() = 1;

  for (int i = v.size() - 2; i >= 0; --i) {
    if (s[i] == 'W')
      v[i] = v[i + 1] + 1;
    else
      v[i] = v[i + 1];
  }

  long long cnt = 0;
  for (int i = 0; i < v.size(); ++i)
    if (s[i] == 'B')
      cnt += v[i];

  cout << cnt << endl;
}

Measured memory_bytes: 1412
function main(input) {
  input=input.trim();
  const s = input.split("\n")[0];
  const t = input.split("\n")[1];
  var arr1=[]
  var arr2=[]

  function narabi(n,arr){
    for(var i=0; i<n.length; i++){
      arr.push(n.substr(i,1))
    }
  }
  narabi(s,arr1)
  narabi(t,arr2)

  arr1.sort(function(a,b){
    if( a < b ) return -1;
    if( a > b ) return 1;
    return 0;
  });
  arr2.sort(function(a,b){
    if( a < b ) return 1;
    if( a > b ) return -1;
    return 0;
  });
  //console.log(arr1,arr2);

  if(arr1.join("")<arr2.join("")){
    console.log("Yes");
  }else{
    console.log("No");
  }
  
}



main(require('fs').readFileSync('/dev/stdin', 'utf8'));

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

int main() {
    int a;
    int ans=0;
    int mn=10;
    for (int i=0;i<5;i++) {
        cin>>a;
        ans+=(a+9)/10*10;
        if (a%10)
            mn=min(mn,a%10);
    }
    cout<<ans-10+mn<<endl;
    return 0;
}

Measured memory_bytes: 256
main :: IO ()                                                                                                                                         
main = do                                                                                                                                             
  b <- getLine                                                                                                                                        
  putStrLn $ case b of                                                                                                                                
    "A" -> "T"                                                                                                                                        
    "T" -> "A"                                                                                                                                        
    "C" -> "G"                                                                                                                                        
    "G" -> "C"

Measured memory_bytes: 380
// lcmとか__builtin_popcountとかはg++ -std=c++17 default.cppみたいなかんじで

// -fsanitize=undefinedでオーバーフロー検出
#include <bits/stdc++.h>
#define mod 1000000007
#define INF LLONG_MAX
#define ll long long
#define ln cout<<endl
#define Yes cout<<"Yes"<<endl
#define NO cout<<"NO"<<endl
#define YES cout<<"YES"<<endl
#define No cout<<"No"<<endl
#define REP(i,m,n) for(ll i=(ll)(m);i<(ll)(n);i++)
#define rep(i,n) REP(i,0,n)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
using namespace std;
ll dx[4]={1,0,-1,0};
ll dy[4]={0,1,0,-1};

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

    ll a,b,c,d,m,n,maxi=0,f=0,mini=INF,sum=0;
    string str;
    ll k;
    string l,s;
    cin>>str>>s;
    for(ll i=str.length()-s.length();i>=0;i--){
        f=0;
        for(ll j=0;j<s.length();++j){
            if(str[j+i]==s[j]||str[j+i]=='?'){
            }else{
                f=1;
                break;
            }
        }
        if(f==0){
            for(ll j=0;j<s.length();++j){
            str[j+i]=s[j];
            }
            f=2;
            break;
        }
    }
    rep(i,str.length()){
        if(str[i]=='?') str[i]='a';
    }
            if(f!=2) cout<<"UNRESTORABLE"<<endl;
        else cout<<str<<endl;
    return 0;
}


Measured memory_bytes: 3652
n=int(input())

ba=[]
for _ in range(n):
  a,b=map(int,input().split())
  ba.append([b,a])
  
ba.sort()

time=0
for item in ba:
  b=item[0]
  a=item[1]
  #print(a,b,time)
  
  time+=a
  if time>b:
    print("No")
    exit()
print("Yes")
  


Measured memory_bytes: 76376
import java.io.*;
import java.util.*;

class Main {
	static final String YES = "Yes";
	static final String NO = "No";

	public static void main(String[] args) throws Exception {
		final Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int[][] txy = new int[N][3];
		for (int i = 0; i < N; i++) {
			txy[i][0] = sc.nextInt();
			txy[i][1] = sc.nextInt();
			txy[i][2] = sc.nextInt();
		}
		Arrays.sort(txy, (a, b) -> Long.compare(a[0], b[0]));
		int a = 0, b = 0;
		for (int i = 0; i < N; i++) {
			int move = txy[i][0] - (i == 0 ? 0 : txy[i - 1][0]);
			int dist = d(txy[i][1], txy[i][2], a, b);
			if (move < dist || (move - dist) % 2 == 1) {
				System.out.println(NO);
				return;
			}

			a = txy[i][1];
			b = txy[i][2];
		}

		System.out.println(YES);
	}

	private static int d(int x, int y, int x2, int y2) {
		return Math.abs(x - x2) + Math.abs(y - y2);
	}
}


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

using namespace std;

int main() {
	int a, b, c;
	scanf("%d%d%d", &a, &b, &c);
	
	if (a == b && a == c) return 0 * printf("No\n");
	if (a == b || a == c || b == c) printf("Yes\n");
	else printf("No\n");
}


Measured memory_bytes: 256
#include <iostream>

using namespace std;

int main()
{
    string x;
    cin>>x;
    if(x=="SAT") cout<<"1";
    if(x=="SUN") cout<<"7";
    if(x=="MON") cout<<"6";
    if(x=="TUE") cout<<"5";
    if(x=="WED") cout<<"4";
    if(x=="THU") cout<<"3";
    if(x=="FRI") cout<<"2";
    return 0;
}


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

#define MOD 1000000007
#define rep(i, n) for(ll i=0; i < (n); i++)
#define rrep(i, n) for(ll i=(n)-1; i >=0; i--)
#define ALL(v) v.begin(),v.end()
#define rALL(v) v.rbegin(),v.rend()
#define FOR(i, j, k) for(ll i=j;i<k;i++)
#define debug_print(var) cerr << #var << "=" << var <<endl;
#define DUMP(i, v)for(ll i=0;i<v.size();i++)cerr<<v[i]<<" "

using namespace std;
typedef long long int ll;
typedef vector<ll> llvec;
typedef vector<double> dvec;
typedef pair<ll, ll> P;
typedef long double ld;
struct edge{ll x, c;};

ll mod(ll a, ll mod){
  ll res = a%mod;
  if(res<0)res=res + mod;
  return res;
}

ll modpow(ll a, ll n, ll mod){
  ll res=1;
  while(n>0){
    if(n&1) res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll modinv(ll a, ll mod){
  return modpow(a, mod-2, mod);
}

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

bool is_prime(ll n){
  ll i = 2;
  if(n==1)return false;
  if(n==2)return true;
  bool res = true;
  while(i*i <n){
    if(n%i==0){
      res = false;
    }
    i = i+1;
  }

  //if(i==1)res = false;
  if(n%i==0)res=false;
  return res;
}

struct UnionFind{
  ll N;
  llvec p;
  llvec cnt;
  UnionFind(ll n){
    N = n;
    p=llvec(N);
    cnt=llvec(N, 0);
    rep(i, N){
      p[i] = i;
      cnt[i] = 1;
    }
  }

  void con(ll a, ll b){
    P at = root(a);
    P bt = root(b);
    if(at.second!=bt.second){
      if(at.first>bt.first){
        swap(at, bt);
        swap(a, b);
      }
      p[at.second] = bt.second;
      cnt[bt.second]+=cnt[at.second];
      p[a]=bt.second;
    }
  }

  P root(ll a){
    ll atmp = a;
    ll c=0;
    while(atmp!=p[atmp]){
      atmp = p[atmp];
      c++;
    }
    p[a] = atmp;
    return {c, atmp};
  }

  bool is_con(ll a, ll b){
    P at=root(a);
    P bt=root(b);
    return at.second == bt.second;
  }
  
};

struct dijkstra{
  ll N;
  llvec d;
  vector<vector<edge>> e;
  dijkstra(ll n){
    N = n;
    //d = llvec(N, 1e18);
    e = vector<vector<edge>>(N);
  }

  void add_edge(ll from, ll to, ll cost){
    e[from].push_back({to, cost});
  }

  void run(ll start){
    priority_queue<P, vector<P>, greater<P>> que;
    que.push({0, start});
    d = llvec(N, 1e18);
    d[start]=0;
    while(!que.empty()){
      P q = que.top();que.pop();
      ll dc = q.first;
      ll x = q.second;
      if(dc>d[x]){
        continue;
      }else{
        for(auto ip: e[x]){
          if(d[ip.x]<=d[x]+ip.c){
            continue;
          }else{
            d[ip.x]= d[x]+ip.c;
            que.push({d[ip.x], ip.x});
          }
        }
      }
    }
  }  
};


/**************************************
** A main function starts from here  **
***************************************/
int main(){
  ll N;cin >> N;
  string S;
  cin >> S;
  llvec l(N+1, 0);
  llvec r(N+1, 0);
  rep(i, N){
    ll tmp = 0;
    if(S[i]=='W')tmp+=1;
    l[i+1] = tmp + l[i];
  }
  rep(i, N){
    ll tmp = 0;
    if(S[N-i-1]=='E')tmp+=1;
    r[N-i-1] = tmp + r[N-i];
  }
  ll ans = 1e10;
  rep(i, N){
    ans = min(ans, l[i] + r[i+1]);
  }
  cout << ans;
  return 0;
}


Measured memory_bytes: 8272
import math

n, d = map(int, input().split())
c = [0]*n

for i in range(n):
	c[i] = (list(map(int, input().split())))
cnt = 0
for i in range(n):
	for j in range(i+1, n):
		sum = 0
		for k in range(d):
			s = (c[i][k]-c[j][k]) ** 2
			sum += s
		dist = math.sqrt(sum)

		if dist.is_integer():
			cnt += 1
			
print(cnt)

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

using namespace std;
#define inf             0x3f3f3f3f
#define INF             2e18
#define eps             1e-9

#define FastRead        ios_base::sync_with_stdio(0);cin.tie(0)
#define fRead           freopen("input.txt","r",stdin)
#define fWrite          freopen("output.txt","w",stdout)

#define LL              long long
#define ull            unsigned long long
#define PI              acos(-1.0)
#define pb              push_back
#define mk              make_pair
#define pii             pair<int,int>
#define pLL             pair<LL,LL>
#define ff              first
#define ss              second
#define all(a)          a.begin(),a.end()
#define SQR(a)          ((a)*(a))
#define min3(a,b,c)     min(a,min(b,c))
#define max3(a,b,c)     max(a,max(b,c))
#define min4(a,b,c,d)   min(min(a,b),min(c,d))
#define max4(a,b,c,d)   max(max(a,b),max(c,d))
#define max5(a,b,c,d,e) max(max3(a,b,c),max(d,e))
#define min5(a,b,c,d,e) min(min3(a,b,c),min(d,e))
#define vi              vector <int>
#define vL              vector <LL>
#define LB(a,x)         (lower_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which does not compare less than val.
#define UB(a,x)         (upper_bound(all(a),x)-a.begin()) //  first element in the range [first,last) which compares greater than val.
#define prec(n)         fixed << setprecision(n)

#define MEM(a,x)        memset(a,x,sizeof(a))
#define SORT(v)         sort(v.begin(),v.end())
#define REV(v)          reverse(v.begin(),v.end())
#define Unique(a)       sort(all(a)),a.erase(unique(all(a)),a.end())

#define FOR(i,a,b)      for(int i=a;i<=b;i++)
#define ROF(i,a,b)      for(int i=a;i>=b;i--)
#define REP(i,b)        for(int i=0;i<b;i++)
#define IT(it,x)	    for(it=x.begin();it!=x.end();it++)
int main()
{
    LL n;
    cin>>n;
    double s=0;
    for(int i=0;i<n;i++)
    {
        double x;
        cin>>x;
        s+=(1.0/x);
    }
    s=1.0/s;
    cout<<prec(10)<<s;

}


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

int a, b, p, q, s, t, cnt;

int main()
{
    int i;

    cin >> a >> b;

    for(i=a; i<=b; i++){
        p=i/10000, q=i/1000%10, s=i/10%10, t=i%10;
        if(p==t && q==s) cnt++;
    }

    cout << cnt;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
typedef long long ll;
using namespace std;
const  ll INF = 1e9;
const  ll MOD = 1e9 + 7;
#define repi(i,n,init) for(ll i=init;i<(n);i++)

int main()
{
    int n;
    cin >> n;
    int ans = 1,m;
    cin >> m;
    repi(i,n,1){
        int p;
        cin >> p;
        if(m >= p){
            ans++;
            m = p;
        }
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<vector>
#include<map>
#include<cstring>
 
#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define inf (1<<29) 
#define all(n) (n).begin(),(n).end()
#define MAX_V 1100
using namespace std;
 
//follow
struct edge
{
  int to,cap,rev;
  edge(int to=inf,int cap=inf,int rev=inf):to(to),cap(cap),rev(rev){}
};
  
vector<edge> G[MAX_V];
int level[MAX_V];
int iter[MAX_V];
bool used[MAX_V];
  
void init(int V)
{
  rep(i,V)G[i].clear();
}
  
void add_edge(int from,int to,int cap)
{
  G[from].push_back(edge(to,cap,G[to].size()));
  G[to].push_back(edge(from,0,G[from].size()-1));
}
 
int dfs(int v,int t,int f)
{
  if(v == t)return f;
  used[v] = true;
  for(int i=0;i<G[v].size();i++)
    {
      edge &e = G[v][i];
      if(e.cap > 0 && !used[e.to])
    {
      int d = dfs(e.to,t,min(f,e.cap));
      if(d > 0)
        {
          e.cap -= d;
          G[e.to][e.rev].cap += d;
          return d;
        }
    }
    }
  return 0;
}
  
int max_flow(int s,int t)
{
  int flow = 0;
  for(;;)
    {
      memset(used,0,sizeof(used));
      int f = dfs(s,t,inf);
      if(f == 0)
    {
      return flow;
    }
      flow += f;
    }
}
  
//
 
int main()
{
  int N,k,K,s,t,day;
  while(cin >> N,N)
    {
      cin >> k;
      K = k;
      s = k + N;
      t = s + 1;
      init(t+1);
      map<int,int> days;
      vector<int> vday;
      rep(i,k)
    {
      cin >> day;
      vday.push_back(day);
    }
      sort(all(vday));
      vday.erase(unique(all(vday)),vday.end());
      rep(i,vday.size())
    {
      days[vday[i]] = i;
      add_edge(s,i,1);
    }
 
      rep(i,N)
    {
      cin >> k;
      rep(j,k)
        {
          cin >> day;
          if(days.find(day) != days.end())
        {
          add_edge(days[day],K+i,1);
        }
        }
      add_edge(K+i,t,1);
    }
 
      cout << max_flow(s,t) << endl;
 
    }
  return 0;
}

Measured memory_bytes: 1536
#include<iostream>
#include<map>
using namespace std;
 
int main() {
  long long n, m, current, f, s;
  map<long long, long long> memo;
  long long sum = 0, ans = 0;
  scanf("%lld %lld", &n, &m);
  for (long long i=0; i<n; i++) {
    scanf("%lld", &current);
    sum += current;
    if (memo.find(sum % m) == memo.end()) {
      memo[sum % m] = 0;
    }
    memo[sum % m]++;
  }
  for (map<long long, long long>::iterator it = memo.begin(); it != memo.end(); ++it) {
    f = it->first;
    s = it->second;
    if (s > 1) ans += (s*(s-1)/2);
    if (f == 0) ans += s;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 4224
#include <vector>
#include <map>
#include <set>
#include <stack>
#include <queue>
#include <algorithm>
#include <utility>
#include <functional>
#include <sstream>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <climits>
#include <fstream>
#include <iomanip>
using namespace std;
inline int toInt(string s) { int v; istringstream sin(s); sin >> v; return v; }
template<class T> inline string toStr(T x) { ostringstream sout; sout << x; return sout.str(); }
typedef vector<int> vi;
typedef vector<vi>  vvi;
typedef vector<string> vs;
typedef pair<int, int> pii;
typedef long long ll;
#define ALL(a) (a).begin(),(a).end()
#define RALL(a) (a).rbegin(),(a).rend()
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define REP(i,n) FOR(i,0,(n)-1)
const double EPS = 1e-10;
const double PI = acos(-1.0);
const int INF = INT_MAX / 2;
const int MOD = 1000000007;
typedef vector<ll> vl;
typedef vector<vl> vvl;

int main() {
	double N, K;
	cin >> N >> K;
	vi A(N);
	REP(i, N) {
		cin >> A[i];
	}
	int ans = 1, t = K;
	while (t < N) {
		t += (K-1);
		ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 640
program main
      implicit none
      integer :: n, m, i, ansac, answa
      integer, allocatable :: p(:)
      integer, allocatable :: ac(:)
      integer(8), allocatable :: wa(:)
      character(2), allocatable :: s(:)


      read *, n, m
      allocate( p(m) )
      allocate( s(m) )
      do i = 1, m
        read *, p(i), s(i)
      end do
      
      allocate( ac(n) )
      allocate( wa(n) )
      ac = 0
      wa = 0
      do i = 1, m
        if ( s(i) == 'AC' ) then
          ac(p(i)) = 1
        else if ( s(i) == 'WA' ) then
          if ( ac(p(i)) == 1 ) then
          else
            wa(p(i)) = wa(p(i)) + 1
          end if
        end if
      end do 

      ansac = 0
      answa = 0
      do i = 1, n
        ansac = ansac + ac(i)
        if( ac(i) == 1 ) then
          answa = answa + wa(i)
        end if
      end do

      print *, ansac, answa

end program main


Measured memory_bytes: 1920
/**
 * @copyright (c) 2020 Daisuke Hashimoto
 */

#include <bits/stdc++.h>
using namespace std;
using Pair = pair<int64_t, int64_t>;
constexpr int64_t kInf = INT64_MAX / 2L;

// std::cout << std::setprecision(20) << 1.1 << endl;

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

  int64_t H, W, A_row, B_col;
  cin >> H >> W >> A_row >> B_col;
  vector<vector<int64_t>> result(H, vector<int64_t>(W, 0));
  for (int64_t r = B_col; r < H; ++r) {
    for (int64_t c = 0; c < A_row; ++c) {
      result[r][c] = 1;
    }
  }
  for (int64_t r = 0; r < B_col; ++r) {
    for (int64_t c = A_row; c < W; ++c) {
      result[r][c] = 1;
    }
  }

  for (int64_t r = 0; r < H; ++r) {
    int64_t zero = 0;
    int64_t one = 0;
    for (int64_t c = 0; c < W; ++c) {
      if (result[r][c] == 0) {
        ++zero;
      } else {
        ++one;
      }
    }
    if (min(zero, one) != A_row) {
      cout << "No" << endl;
    }
  }
  for (int64_t c = 0; c < W; ++c) {
    int64_t zero = 0;
    int64_t one = 0;
    for (int64_t r = 0; r < H; ++r) {
      if (result[r][c] == 0) {
        ++zero;
      } else {
        ++one;
      }
    }
    if (min(zero, one) != B_col) {
      cout << "No" << endl;
    }
  }

  for (int64_t r = 0; r < H; ++r) {
    for (int64_t c = 0; c < W; ++c) {
      cout << result[r][c];
    }
    cout << endl;
  }
  return 0;
}


Measured memory_bytes: 10996
#!/usr/bin/env python
import os
import sys
from io import BytesIO, IOBase


#a=[int(x) for x in input().split()]
#n=int(input())

def main():
    mod=998244353

    def po(a,n):
        ans=1
        while n:
            if n&1:
                ans=(ans*a)%mod
            a=(a*a)%mod
            n//=2
        return ans


    n,m,k=[int(x) for x in input().split()]
    
    f=[1]
    for i in range(1,n+5):
        f.append(f[-1]*i%mod)

    def fac(n):
        if n<0:
            return 0
        return f[n]
    
    def nCr(n,r):
        if n<0 or r>n or r<0:
            return 0
        return fac(n)*po(fac(r)*fac(n-r),mod-2)%mod

    val=0
    for i in range(k+1):
        ans=1
        ans=(ans*nCr(n-1,i))%mod
        ans=(ans*m)%mod
        ans=(ans*po(m-1,n-i-1))%mod
        val=(ans+val)%mod
    print(val)

# region fastio

BUFSIZE = 8192


class FastIO(IOBase):
    newlines = 0

    def __init__(self, file):
        self._fd = file.fileno()
        self.buffer = BytesIO()
        self.writable = "x" in file.mode or "r" not in file.mode
        self.write = self.buffer.write if self.writable else None

    def read(self):
        while True:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            if not b:
                break
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines = 0
        return self.buffer.read()

    def readline(self):
        while self.newlines == 0:
            b = os.read(self._fd, max(os.fstat(self._fd).st_size, BUFSIZE))
            self.newlines = b.count(b"\n") + (not b)
            ptr = self.buffer.tell()
            self.buffer.seek(0, 2), self.buffer.write(b), self.buffer.seek(ptr)
        self.newlines -= 1
        return self.buffer.readline()

    def flush(self):
        if self.writable:
            os.write(self._fd, self.buffer.getvalue())
            self.buffer.truncate(0), self.buffer.seek(0)


class IOWrapper(IOBase):
    def __init__(self, file):
        self.buffer = FastIO(file)
        self.flush = self.buffer.flush
        self.writable = self.buffer.writable
        self.write = lambda s: self.buffer.write(s.encode("ascii"))
        self.read = lambda: self.buffer.read().decode("ascii")
        self.readline = lambda: self.buffer.readline().decode("ascii")


sys.stdin, sys.stdout = IOWrapper(sys.stdin), IOWrapper(sys.stdout)
input = lambda: sys.stdin.readline().rstrip("\r\n")

# endregion

if __name__ == "__main__":
    main()

Measured memory_bytes: 81108
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,k;
  cin >> n >> k;
  int sum=0;
  vector<int>h(n);
  for(int i=0;i<n;i++) {
    cin >> h.at(i);
    if(h.at(i)>=k) {
      sum+=1;}
    }
  cout << sum << endl;
  return 0;
  }
    
      


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

int isPrime(int n);

int dp[1000000]={};

int main(){
  int n;
  for(int i=2;i<=1000000;i++){
      if(isPrime(i)) dp[i]=dp[i-1]+1;
      else dp[i]=dp[i-1];
  }
  
  while(cin >> n){
    cout << dp[n]<< endl;
  }
  
}

int isPrime(int n){
  for(int i=2;i*i<=n;i++){
    if(n%i==0) return 0;
  }
  return 1;
}

Measured memory_bytes: 5064
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin,(obj).end()
#define SORT(list) sort(ALL((list)));
using namespace std;
using ll = long long;
int main(){
    ll n;
    cin >> n;
    ll h[n];
    REP(i,n)cin >> h[i];
    int move_distance;
    
    ll max=0;
    move_distance=0;
    REP(i,n-1){
        if(h[i] < h[i+1]){    
            
            if(move_distance > max)max = move_distance;
            move_distance=0;
        }
        else{
            move_distance++;
        }
    }
    if(move_distance > max)max = move_distance;
    cout << max << endl;
    return 0;
}

Measured memory_bytes: 1024
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <queue>
#include <ctime>
#include <cassert>
#include <complex>
#include <string>
#include <cstring>
#include <chrono>
#include <random>
#include <queue>
#include <bitset>
#include <stack>
#include <functional>

#ifdef LOCAL
    #define eprintf(...) fprintf(stderr, __VA_ARGS__)
#else
    #define eprintf(...) 42
#endif

#define rep(i, n) for(int i = 0, i##_len = (n); i < i##_len; ++i)
#define repp(i, m, n) for(int i = m, i##_len = (n); i < i##_len; ++i)
#define reprev(i, n) for(ll i = (n-1LL); i >= 0; --i)
#define all(x) (x).begin(), (x).end()
template <class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return 1; } return 0; }
template <class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return 1; } return 0; }
template <class T> T gcd(T a, T b) { return b ? gcd(b, a % b) : a; }
using namespace std;

typedef long long ll;
typedef unsigned long long ull;
typedef pair <ll,ll> P;
typedef long double ld;

int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w;
    cin >> h >> w;
    vector<string> s(h);
    rep (i, h) cin >> s[i];
    vector<int> count(26);
    rep (i, h) rep (j, w) count[s[i][j] - 'a']++;
    int c2 = 0, c1 = 0;
    rep (i, 26) if (count[i] & 2) c2++;
    rep (i, 26) if (count[i] & 1) c1++;
    int m2 = (h % 2 ? w / 2 : 0) + (w % 2 ? h / 2 : 0), m1 = (h % 2) && (w % 2);
    eprintf("c=%d,m=%d c=%d,m=%d\n", c2,m2, c1,m1);
    if ((c2 - m2) % 2 == 0 && c2 <= m2 && c1 == m1) cout << "Yes\n";
    else cout << "No\n";
    return 0;
}

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

public class AtCoderA
{
    static void Main()
    {
        var sc = new Scanner();

        int n = sc.NextInt();
        int[] a = sc.IntArray();

        Dictionary<int, int> dic = new Dictionary<int, int>();
        foreach (var num in a)
        {
            if (!dic.ContainsKey(num))
            {
                dic.Add(num, 1);
            }
            else
            {
                dic[num]++;
            }
        }

        int answer = 0;
        foreach (var item in dic)
        {
            if (item.Key != item.Value)
            {
                if (item.Key > item.Value)
                {
                    answer += item.Value;
                }
                else
                {
                    answer += item.Value - item.Key;
                }
            }
        }

        Console.WriteLine(answer);
    }

    class Scanner
    {
        private string[] _line;
        private int _index;
        private const char Separator = ' ';

        public Scanner()
        {
            _line = new string[0];
            _index = 0;
        }

        public string Next()
        {
            while (_index >= _line.Length)
            {
                _line = Console.ReadLine().Split(Separator);
                _index = 0;
            }

            return _line[_index++];
        }

        public int NextInt() => int.Parse(Next());
        public long NextLong() => long.Parse(Next());
        public double NextDouble() => double.Parse(Next());
        public decimal NextDecimal() => decimal.Parse(Next());
        public char NextChar() => Next()[0];
        public char[] NextCharArray() => Next().ToCharArray();

        public string[] Array()
        {
            _line = Console.ReadLine().Split(Separator);
            _index = _line.Length;
            return _line;
        }

        public int[] IntArray() => Array().Select(int.Parse).ToArray();
        public long[] LongArray() => Array().Select(long.Parse).ToArray();
        public double[] DoubleArray() => Array().Select(double.Parse).ToArray();
        public decimal[] DecimalArray() => Array().Select(decimal.Parse).ToArray();
    }
}


Measured memory_bytes: 28508
import java.io.*;

class Main{
	public static void main(String args[]) throws IOException{
		BufferedReader buf = new BufferedReader(new InputStreamReader(System.in));
		int n = Integer.parseInt(buf.readLine());
		StringBuilder sb = new StringBuilder();
		
		int num = 0;
		for(int j=3; j<=n; j++){
			if(j%3==0){
				sb.append(" "+j);
			} else {
				num = j;
				while(num != 0){
					if(num%10==3){
						sb.append(" "+j);
						break;
					} else{
						num = num/10;
					}	
				}
			}			

		}
		System.out.println(sb);
	}
}

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

const int INF = 1e9+7;

int main() {
	long long x;
	cin >> x;
	long long count = x/11*2;
	int n = x%11;
	if(n>0 && n<7){
		count += 1;
	}else if(n>0 && n>6){
		count += 2;
	}
	cout << count << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <numeric>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <array>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
using namespace std;
typedef long long unsigned int ll;

#define EPS (1e-7)
#define INF (1e9)
#define PI (acos(-1))

int GCD(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   if(_a % _b == 0){
      return _b;
   }
   else{
      return GCD(_b, _a % _b);
   }
}

int LCM(const int& a, const int& b){
   const int& _a = max(a,b);
   const int& _b = min(a,b);
   return (_a*_b)/(GCD(_a, _b));
}

int main(){
   int N;
   cin >> N;
   set<int> d;
   for(int i = 0; i < N; i++){
      int d_tmp;
      cin >> d_tmp;
      d.insert(d_tmp);
   }
   cout << d.size()<< endl;


   return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();
        if (A==B && B!=C) {
            System.out.println("Yes");
            return;
        }
        if (A==C && C!=B) {
            System.out.println("Yes");
            return;
        }
        if (B==C && C!=A) {
            System.out.println("Yes");
            return;
        }
        System.out.println("No");
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main(void){
  int a[100000],h,n,i,b=0;
  scanf("%d %d",&h,&n);
  for(i=0;i<n;i++){
    scanf("%d",&a[i]);
  }
  while(1){
    h=h-a[b];
    b=b+1;
    if(b==n){
      break;
    }
  }
  if(h<=0){
    printf("Yes\n");
  }
  else{
    printf("No\n");
  }
  return 0;
}


Measured memory_bytes: 2036
#include "bits/stdc++.h"
using namespace std;
#define rep(i,a,n) for(ll i=a;i<n;i++)
#define ALL(s) s.begin(),s.end()
#define P pair<int,int>
const int M=100010;
const int MOD=1000000007;
const int INF=1000000007;
using ll=long long;

int n,m,a[55],b[55],dist[55][55]={};
int wf(int x){
	rep(i,0,m){
		if(i==x)continue;
		dist[a[i]][b[i]]=dist[b[i]][a[i]]=0;
	}
	bool can=true;
	rep(k,1,n+1){
		rep(i,1,n+1){
			rep(j,1,n+1){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	rep(i,1,n+1){
		rep(j,1,n+1){
			if(dist[i][j]==INF)can=false;
		}
	}
	rep(i,0,55)rep(j,0,55)if(i!=j)dist[i][j]=INF;
	return !can;
}


int main() {
	rep(i,0,55)rep(j,0,55)if(i!=j)dist[i][j]=INF;
	cin>>n>>m;
	rep(i,0,m)cin>>a[i]>>b[i];
	int ans=0;
	rep(i,0,m)ans+=wf(i);
	cout<<ans<<endl;
		
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    string S;
    long long N=0,tt=0,ans=0;
    cin>>N;
    ans=N;

    while(N!=0){
        tt+=N%10;
        N=N/10;
    }

    if(ans%tt==0){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }

}

Measured memory_bytes: 256
#include <bits/stdc++.h> //C++の標準ライブラリを一行で一括でインクルードする
#include <math.h> //数学関数と数学定数を利用する
#define rep(i,n) for (int i = 0; i < (n); i++)
#define PI 3.141592653589793
using namespace std;
typedef long long ll;
template<class T> void chmax(T &a,T b) { if (a<b) a=b;}
template<class T> void chmin(T &a,T b) { if (a>b) a=b;}
int gcd(int a, int b){//ユークリッドの互除法
  if (a < b) gcd(b,a); //aの方がbよりでかいのが前提
  if (b == 0) return a; //aをbで割り切れたらreturn
  else gcd(b, a % b);
}
int lcm(int a, int b){
  return a / gcd(a,b) * b;
}
const int INF = 1<<30;
const int MOD = 1000000007;
int dx[4] = {0,0,-1,1};
int dy[4] = {-1,1,0,0};
// 区間加算にも対応した BIT
template <class Abel> struct BIT {
    vector<Abel> dat[2];
    Abel UNITY_SUM = 0;                     // to be set
    
    /* [1, n] */
    BIT(int n) { init(n); }
    void init(int n) { for (int iter = 0; iter < 2; ++iter) dat[iter].assign(n + 1, UNITY_SUM); }
    
    /* a, b are 1-indexed, [a, b) */
    inline void sub_add(int p, int a, Abel x) {
        for (int i = a; i < (int)dat[p].size(); i += i & -i)
            dat[p][i] = dat[p][i] + x;
    }
    inline void add(int a, int b, Abel x) {
        sub_add(0, a, x * -(a - 1)); sub_add(1, a, x); sub_add(0, b, x * (b - 1)); sub_add(1, b, x * (-1));
    }
    
    /* a is 1-indexed, [a, b) */
    inline Abel sub_sum(int p, int a) {
        Abel res = UNITY_SUM;
        for (int i = a; i > 0; i -= i & -i) res = res + dat[p][i];
        return res;
    }
    inline Abel sum(int a, int b) {
        return sub_sum(0, b - 1) + sub_sum(1, b - 1) * (b - 1) - sub_sum(0, a - 1) - sub_sum(1, a - 1) * (a - 1);
    }
    
    /* debug */
    void print() {
        for (int i = 1; i < (int)dat[0].size(); ++i) cout << sum(i, i + 1) << ",";
        cout << endl;
    }
};

int N;
ll D,A;
vector<ll> X,H;

bool comp(int i, int j){
  return X[i] < X[j];
}

int main(){
  cin >> N >> D >> A;
  X.resize(N); H.resize(N);
  rep(i,N) cin >> X[i] >> H[i];
  
  vector<int> ids(N);
  rep(i,N) ids[i] = i;
  sort(ids.begin(),ids.end(),comp);
  
  vector<ll> nX(N),nH(N);
  rep(i,N) nX[i] = X[ids[i]], nH[i] = H[ids[i]];
  X = nX, H = nH;
  
  BIT<ll> bit(N+10);
  rep(i,N) bit.add(i+1,i+2, H[i]);
  ll res = 0;
  
  rep(i,N){
    ll cur = bit.sum(i+1, i+2);
    if(cur <= 0) continue;
    
    ll need = (cur + A - 1)/A;
    
    ll right = X[i] + D * 2;
    int id = upper_bound(X.begin(), X.end(), right) - X.begin();
    
    bit.add(i+1,id+1,-need * A);
    res += need;
  }
  
  cout << res << endl;
  
  return 0;
}

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

//#define int long long
#define ll long long
#define all(v) (v).begin(), (v).end()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_INF = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

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;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};

signed main()
{   
    gearup;
    int n; cin >> n;
    vl a(n);
    rep(i,n) cin >> a[i];
    ll res = 0;
    rep(i,61){
        ll n0=0,n1=0;
        rep(j,n){
            if(a[j]&(1LL<<i))n1++;
            else n0++;
        }
        ll di = (1LL<<i) % MOD;
        ll ans = n1*n0 % MOD;
        ans = ans * di % MOD;
        res = (res + ans) % MOD;
    }
    cout << res << endl;
}


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

int main()
{
  int A, B;
  string S;
  cin >> A >> B >> S;
  
  bool flag = true;
  if(S[A] != '-') flag = false;
  for(int i = 0; i < A && flag; ++i)
  {
    if(S[i] < '0' || S[i] > '9') flag = false;
  }
  for(int i = A + 1; i < A + B && flag; ++i)
  {
    if(S[i] < '0' || S[i] > '9') flag = false;
  }
  
  cout << (flag ? "Yes" : "No") << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <stack>
using namespace std;

int main(){
  int W, H;
  while(cin >> W >> H && W>0 && H>0){
    int map[400];
    for(int i=0;i<400;i++)
      map[i]=0;
    int at[2];

    for(int i=0;i<H;i++){
      string s;
      cin >> s;
      for(int j=0;j<W;j++){
        map[20*i+j]=(s[j]=='.'?1:(s[j]=='@'?2:0));
        if(s[j]=='@'){
          at[0]=i; at[1]=j;
        }
      }
    }

    vector<int> list[400];  //??£??\?????????
    for(int i=0;i<400;i++){
      if(i>=20) //???
        if(map[i-20]>0) list[i].push_back(i-20);
      if(i%20>0) //???
        if(map[i-1]>0) list[i].push_back(i-1);
      if(i%20<19) //???
        if(map[i+1]>0) list[i].push_back(i+1);
      if(i<380) //???
        if(map[i+20]>0) list[i].push_back(i+20);
    }

    bool d[400];
    for(int i=0;i<400;i++) d[i]=false;

    stack<int> cur;
    cur.push(at[0]*20+at[1]);
    d[at[0]*20+at[1]]=true;

    while(!cur.empty()){
      bool flg=false;
      for(vector<int>::iterator it=list[cur.top()].begin();it!=list[cur.top()].end();it++){
        if(!d[*it]){
          flg=true;
          cur.push(*it);
          d[*it]=true;
          break;
        }
      }
      if(flg) continue;
      cur.pop();
    }

    int cnt=0;
    for(int i=0;i<400;i++)
      if(d[i]) cnt++;

    cout << cnt << endl;
  }

  return 0;  
}

Measured memory_bytes: 3244
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main(){
	int N, T;
	cin>>N>>T;
	vector<int> A, B;
	A.resize(N);
	B.resize(N-1);
	cin>>A[0];
	int min=A[0];
	for(int i=1; i<N; i++){
		cin>>A[i];
		B[i-1]=A[i]-min;
		if(min > A[i]){
			min=A[i];
		}
	}
	
	sort(B.begin(), B.end());

	int cnt=0;
	for(int i=N-2; i>0; i--){
		if(B[i]==B[i-1]){
			cnt++;
		}else{
			break;
		}
	}

	cout<<cnt+1<<endl;

	return 0;
}


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

template<typename T, typename U> bool chmin(T &a, const U &b) {
	return (a > b ? a = b, true : false);
}
template<typename T, typename U> bool chmax(T &a, const U &b) {
	return (a < b ? a = b, true : false);
}
const long long INF = 1000000000;

typedef long long ll;

#define writeln(n) cout<<n<<"\n";

typedef pair<int, int> P;
typedef pair<string, int> Psi;



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

	int n;
	cin>>n;

	if(n/100 ==7){
		writeln("Yes");
		return 0;
	}
	n%=100;
	if(n /10 ==7){
		writeln("Yes");
				return 0;
	}
	n%=10;
	if(n == 7){
		writeln("Yes");
						return 0;

	}

	writeln("No");
}


Measured memory_bytes: 3644
#include <vector>
#include <list>
#include <map>
#include <set>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <cctype>
#include <string>
#include <cstring>
#include <ctime>
#include <queue>
#include <climits>
#include <cassert>
using namespace std;

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

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

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define rep(i,n)  FOR(i,0,n)
#define foreach(c,itr) for(__typeof((c).begin()) itr=(c).begin();itr!=(c).end();itr++)

const double EPS = 1e-9;
const double PI  = acos(-1.0);
const int dx[] = {-1,1,0,0};
const int dy[] = {0,0,1,-1};

#define CLR(a) memset((a), 0 ,sizeof(a))
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

int R, C, N;

int get(int x, int y)
{
	if (x == 0 || x == R || y == 0 || y == C) {
		int u = 0;
		if (y == 0) {
			u = x;
		} else if (x == R) {
			u = R + y;
		} else if (y == C) {
			u = R + C + (R - x);
		} else {
			u = (R + C) * 2 - y; 
		}
		return u;
	} else {
		return -1;
	}
}

int lf[100010];

vector<pair<int, pii>> vec;
set<int> st;

int main() {
	cin >> R >> C >> N;

	rep(i, N) {
		int a, b, c, d;
		cin >> a >> b >> c >> d;
		int s = get(a, b), t = get(c, d);
		if (s == -1 || t == -1) continue;
		if (s > t) swap(s, t);
		lf[i] = s;
		vec.eb(s, mp(i, 1));
		vec.eb(t, mp(i, -1));
	}

	sort(vec.begin(), vec.end());

	for (auto t : vec) {
		int tp = t.se.se, id = t.se.fi;

		if (tp == 1) {
			st.insert(t.fi);
		} else {
			auto it = st.upper_bound(lf[id]);
			if (it != st.end()) {
				puts("NO");
				return 0;
			}
			st.erase(lf[id]);
		}
	}
	puts("YES");

    return 0;
}

Measured memory_bytes: 6000
from heapq import heappop, heappush

n, m = map(int, input().split())
xy = [tuple(int(x)-1 for x in input().split()) for _ in range(m)]

R = [[] for _ in range(n)]
h = [0] * n

for x, y in xy:
    R[x].append(y)
    h[y] += 1

S = []

st = []

for i in range(n):
    if h[i] == 0:
        heappush(st, i)

while len(st) > 0:
    temp = heappop(st)
    S.append(temp)
    for x in R[temp]:
        h[x] -= 1
        if h[x] == 0:
            heappush(st, x)

#print(S)

dp = [0] * n

for x in S:
    for y in R[x]:
        dp[y] = max(dp[y], dp[x] + 1)

print(max(dp))


Measured memory_bytes: 90072
#include <stdio.h>
int main(void)
{
	int N, M, X, i = 0, t = 0;
	scanf("%d", &N);
	scanf("%d", &M);
	scanf("%d", &X);
	int A[100];
	while (i < M)
	{
		scanf("%d", &A[i]);
		i++;
	}
	for (i = 0; i < M; i++)
	{
		if (A[i] < X)
			t++;
	}
	if (t < M / 2)
		printf("%d\n", t);
	else
		printf("%d\n", M - t);
	return 0;
}

Measured memory_bytes: 128
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
#include <iomanip>
#include <set>
#include <stdio.h>
#include <ctype.h>
using namespace std;
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define INF 1145141919364364
#define int long long
#define all(vec) vec.begin(),vec.end()
#define P pair<int,int>
#define S second
#define F first
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x%y);
}
int lcm(int x, int y) {
	return x / gcd(x, y)*y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x%i == 0)return false;
	}
	return true;
}
int kai(int x, int y) {
	int res = 1;
	for (int i = x - y + 1; i <= x; i++) {
		res *= i; res %= mod;
	}
	return res;
}
int mod_pow(int x, int y, int m) {
	int res = 1;
	while (y > 0) {
		if (y & 1) {
			res = res * x % m;
		}
		x = x * x % m;
		y >>= 1;
	}
	return res;
}
int comb(int x, int y) {
	if (y > x)return 0;
	return kai(x, y) * mod_pow(kai(y, y), mod - 2, mod) % mod;
}

int n, c[200000];
int ans;
int x, y;
int a, b;

signed main() {
	cin >> n;
	for (int i = 0; i < n; i++)cin >> c[i];
	int k = 1;
	for (int i = 0; i < 2 * n - 1; i++) {
		k *= 2;
		k %= mod;
		if (i == 2 * n - 3)b = k;
	}
	a = k;
	sort(c, c + n);
	reverse(c, c + n);
	x = a;
	y = b;
	for (int i = 0; i < n; i++) {
		ans += x * c[i];
		ans %= mod;
		x += y;
		x %= mod;
	}
	cout << ans % mod << endl;
}

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

int main(){
    int a, b; cin >>a >> b;
    
    if(a > b) cout << "a > b" << endl;
    else if (a < b) cout << "a < b" << endl;
    else cout << "a == b" << endl;
    
    return 0;
}


Measured memory_bytes: 3072
N, D = map(int, input().split())
A = []
for i in range(N):
    x = list(map(int, input().split()))
    A.append(x)

def check(x, y):
    s = 0
    for a, b in zip(x, y): s += (a - b) ** 2

    for i in range(0, s+1):
        if i * i == s: return 1
    return 0


ans = 0
for i in range(N):
    for j in range(i+1, N): ans += check(A[i], A[j])
print(ans)


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define fi first
#define se second
#define mp make_pair
#define itrfor(itr,A) for(auto itr = A.begin(); itr !=A.end();itr++)
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
typedef long long llong;
char moji[26]={'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'};
char moji2[26]={'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'};
char moji3[10]={'0','1','2','3','4','5','6','7','8','9'};
#define Sort(a) sort(a.begin(),a.end());
#define Reverse(a) reverse(a.begin(),a.end());
#define print(a) cout << a << endl;
#define MOD llong(1e9+7)
#define MAX int(2 * 1e5 +5)
#define debug(x)  cout << #x << " = " << (x) << endl;
#define pi acos(-1.0)
#define int llong
#define INF llong(1e17)
void myprint(int* A,int A_num){
   REP(i,A_num) cout << A[i] << " ";
   cout << endl;
}

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

    int n = s.length();

    int res[n] = {};
    int tmp = 0;
    REP(i,n){
        if(s[i] == 'R'){
            tmp ++;
        }
        else{
            if(tmp %2 == 1){
                res[i-1] += int(tmp/2) + 1;
                res[i] += int(tmp / 2);
            }
            else{
                res[i-1] += tmp /2;
                res[i] += tmp / 2;
            }
            tmp = 0;
        }
        
    }

    tmp = 0;
    REPR(i,n-1){
        if(s[i] == 'L'){
            tmp ++;
        }
        else{
            if(tmp %2 == 1){
                res[i+1] += int(tmp/2) + 1;
                res[i] += int(tmp / 2);

            }
            else{
                res[i+1] += tmp /2;
                res[i] += tmp / 2;
            }
            tmp = 0;
        }
        
    }

    REP(i,n){
        cout << res[i] << " ";
    }
    cout << endl;

}

Measured memory_bytes: 1408
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
#[allow(unused_macros)]
macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};
 
    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}
 
#[allow(unused_macros)]
macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };
 
    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };
 
    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };
 
    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };
 
    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };
 
    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

// -----------------------------------------------------------------------------
// main
// -----------------------------------------------------------------------------
fn main(){
    input!{
        k: u64
    }
    println!("{}", (k/2)*((k+1)/2));
}



Measured memory_bytes: 4352