akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
#define mod ((int)1e9+7)
#define lim 1000000000000000007
#define lim1 18446744073709551615  //Unsigned
#define sq(a) ((a)*(a))
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(),v.rend()
#define mms(v,i) memset(v,i,sizeof(v))
#define pb push_back
#define pf push_front
#define ppb pop_back
#define ppf pop_front
#define REP(i,a,b) for (int i = a; i <= b; i++)
#define REPN(i,a,b) for (int i = a; i >= b; i--)
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;
typedef pair<int,int> pi;
typedef pair<ll,ll> PL;
typedef pair<ll,int> PLI;
typedef pair<int,ll> PIL;
typedef pair<int,pair<int,int> > pii;
typedef pair<double,double> pdd;
typedef tree<int,null_type,less<int>,rb_tree_tag,tree_order_statistics_node_update> indexed_set;
ll power(ll a,ll b) {
   ll res=1;
   while(b){
      if(b%2==1) res=(res*a)%mod;
      a=(a*a)%mod;
      b>>=1;
   }
   return res;
}
ll gcdll(ll a,ll b) {
    if (b==0) return a;
    return gcdll(b,a%b);
}
int gcd(int a,int b) {
    if (b==0) return a;
    return gcd(b,a%b);
}

struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};

const int N = (int)1e5+5;
const int M = (int)1e3+5;
const int Q = 301;
const int logN = 19;

int dp[M][M];
void solve() {
    int h,w;
    cin>>h>>w;
    dp[1][1] = 1;
    string s;
    REP(i,1,h) {
        cin>>s;
        REP(j,1,w) {
            if(i==1 && j==1) continue;
            dp[i][j] = (dp[i-1][j] + dp[i][j-1])%mod;
            if(s[j-1]=='#') dp[i][j] = 0;
        }
    }
    cout<<dp[h][w];
}
int main() {
    //freopen("output.txt","r",stdin);
    //freopen("output.txt","w",stdout);

    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    int T=1;
    //cin>>T;
    REP(TC,1,T) {
        //cout<<"Case #"<<TC<<": ";
        solve();
        cout<<"\n";
    }
}


Measured memory_bytes: 4224
import qualified Data.ByteString.Char8 as BS
import Data.Maybe

readString = map BS.unpack . BS.words

readInt = fst . fromJust . BS.readInt

getString = readString <$> BS.getLine

getInt = readInt <$> BS.getLine

incDec :: String -> Int -> Int -> Int
incDec [] m x = m
incDec (s : ss) m x = incDec ss m' x'
  where
    x' =
      if s == 'I'
        then x + 1
        else x - 1
    m' = maximum [x', m]

main = do
  n <- getInt
  [s] <- getString
  print $ incDec s 0 0


Measured memory_bytes: 508
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i ,n) for(int i = 0 ; i < (n) ; i ++ )
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
using ll = long long;
using vll=vector<ll>;
using P = pair<int, int>;
const int inf=1e9+7;
const ll INF=1e18;
template <typename T> void chmin(T &a, T b) { a = min(a, b); }
template <typename T> void chmax(T &a, T b) { a = max(a, b); }

int main() {
  int n;
  cin>>n;
  vector<ll> a(n);
  rep(i,n) {
    cin>>a[i];
    if(a[i]==0){
     cout<<0<<endl;
      return 0;
    }
  }
  bool ok=true;
  ll ans[110000];
  ans[0]=1;
 for(int i=1;i<=n;i++){
   if(log10(ans[i-1])+log10(a[i-1])>18) ok=false;
   ans[i]=ans[i-1]*a[i-1]; 
    if(ans[i]>1000000000000000000) {
      ok=false;
    }
    if(ans[i]/a[i-1]!=ans[i-1]) ok=false;
  }
  if(ok)cout<<ans[n]<<endl;
  else cout<<-1<<endl;
}






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

int main(){

  int N,ans=0;
  cin >> N;
  long a[N];
  bool tmp=true;
  rep(i,N) cin >> a[i];

  while(tmp){
    tmp = false;
    rep(i,N){
      if(a[i]%2==0){
        ans++;
        a[i] /= 2;
        tmp = true;
      }
    }
  }
  cout << ans << endl;

  return 0;
}


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

using namespace std;

#define MODULE 1000000007
#define MP make_pair

template<class T,class U>inline void chmin(T &t,U f){if(t>f)t=f;}
template<class T,class U>inline void chmax(T &t,U f){if(t<f)t=f;}

typedef pair<int, int> P;
typedef long long LL;
const int INF = INT_MAX / 2;    //int_max->2*e+9
const int MAXN = 100001;
struct edge {
    edge(int to, int cost) : to(to), cost(cost) {}
    int to, cost;
};
vector<int> graph[MAXN];

set<P> like;
int n,tmp;
//-----Template---------


int main(){
    ios::sync_with_stdio(false);
    scanf("%d",&n);
    for (int i = 0; i < n; ++i) {
        scanf("%d",&tmp); tmp--;
        if((find(graph[tmp].begin(),graph[tmp].end(),i)!=graph[tmp].end()) //すかれていて
                &&(like.find(P(i,tmp))==like.end())) {        //まだカウントされて無いなら
            like.insert(P(i, tmp));
        }
        graph[i].push_back(tmp);
    }
    cout<<like.size()<<endl;
}

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

struct StNumCnt
{
  StNumCnt() : m_nNum(0), m_nCnt(0) { }

  int m_nNum;
  int m_nCnt;
};

bool greater_nCnt(const StNumCnt& lhs, const StNumCnt& rhs)
{
  return lhs.m_nCnt > rhs.m_nCnt;
}

void fnInput(vector<int>& rvnNum)
{
  int nNumSiz;
  cin >> nNumSiz;
  rvnNum.resize(nNumSiz);

  for (int& rnNum : rvnNum)
    cin >> rnNum;
}

int fnMinChangeCnt(const vector<int>& cnrvnNum)
{
  map<int, int> mpNumCntEvn, mpNumCntOdd;

  for (int i = 0; i < cnrvnNum.size(); ++i)
    if ( i % 2 == 0 )
      mpNumCntEvn[ cnrvnNum[i] ]++;
    else
      mpNumCntOdd[ cnrvnNum[i] ]++;

  vector<StNumCnt> voNumCntEvn( mpNumCntEvn.size() ),
                   voNumCntOdd( mpNumCntOdd.size() );

  int n = 0;
  for (pair<int, int> PNumCnt : mpNumCntEvn)
  {
    voNumCntEvn[n].m_nNum   = PNumCnt.first;
    voNumCntEvn[n++].m_nCnt = PNumCnt.second;
  }

  n = 0;
  for (pair<int, int> PNumCnt : mpNumCntOdd)
  {
    voNumCntOdd[n].m_nNum   = PNumCnt.first;
    voNumCntOdd[n++].m_nCnt = PNumCnt.second;
  }

  sort(begin(voNumCntEvn), end(voNumCntEvn), greater_nCnt);
  sort(begin(voNumCntOdd), end(voNumCntOdd), greater_nCnt);

  int nMinChangeCnt = INT_MAX;

  for (int i = 0; i < 2; ++i)
    for (int j = 0; j < 2; ++j)
      if (voNumCntEvn[i].m_nNum != voNumCntOdd[j].m_nNum)
        nMinChangeCnt = 
          min( nMinChangeCnt, 
               (int)cnrvnNum.size() - voNumCntEvn[i].m_nCnt - voNumCntOdd[j].m_nCnt );

  return nMinChangeCnt;
}
  
int main()
{
  vector<int> vnNum;
  
  fnInput(vnNum);
  cout << fnMinChangeCnt(vnNum) << endl;

  return 0;
}

Measured memory_bytes: 8916
N=int(input())
d=[];c=[]
for i in range(N):
    di,ci=map(int,input().split())
    d.append(di);c.append(ci)
# print(d) #DB
# print(c) #DB
s=sum([d[i]*c[i] for i in range(N)])
# print(s) #DB
t=0
while s>=10:
    t+=s//10
    s=s//10+s%10

ans=sum(c)-1+t
print(ans)

Measured memory_bytes: 85576
#define _USE_MATH_DEFINES
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<stdio.h>
#include<cmath>
#include<stack>
#include<set>
#include<map>
#include<stdio.h>
#include<functional>
#include<queue>

using ll = long long;

using namespace std;

ll mod = 1000000007;

ll n_pow(ll a, ll n) {
	if (n == 0)return 1;
	ll t = n_pow(a, n / 2);
	t *= t;
	t %= mod;
	if (n % 2 == 1)t *= a;
	return t % mod;
}

const int INF = 1001001001;
//const ll INF = 1e18;

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

ll cal_gcd(ll a, ll b) {
	ll m = max(a, b);
	ll n = min(a, b);
	while (m%n != 0) {
		ll b = m % n;
		m = n;
		n = b;
	}
	return n;
}

ll f(ll a, ll b) {
	ll a4 = a * a*a*a;
	ll ab3 = a * b*b*b;
	ll a2b2 = a * a*b*b;
	ll a3b = a * a*a*b;
	ll b4 = b * b*b*b;
	return a4 + a3b + a2b2 + ab3 + b4;
}

int main() {
	int x;
	cin >> x;
	vector<int>a(1001);
	for (int i = 0; i < 1001; i++) {
		a[i] = i * i*i*i*i;
	}
	for (int i = 0; i < 1001; i++) {
		bool ok = false;
		for (int j = 0; j < 1001; j++) {
			if (a[i] - a[j] == x) {
				cout << i << " " << j << endl;
				ok = true;
				break;
			}
			if (a[j] - a[i] == x) {
				cout << j << " " << i << endl;
				ok = true;
				break;
			}
			if (a[i] + a[j] == x) {
				cout << i << " " << -j << endl;
				ok = true;
				break;
			}
		}
		if (ok)break;
	}
	return 0;
}

Measured memory_bytes: 3628
#include <bits/stdc++.h>
using namespace std;
string s;
int top;
long long st[100005];

void Cal() {
    int b = st[top--], a = st[top--];
    //cout << a << " " << b << " ";
    if (s[0] == '+') a += b;
    else
        if (s[0] == '-') a-=b;
        else a *= b;
    st[++top] = a;
    //cout << st[top] << endl;
}

int main(){
   
    while (1>0) {
        s.clear();
        cin >> s;
        if (s == "") break;
        if (s[0] == '+' || s[0] == '*' || s[0] == '-') Cal();
        else {
            int t=0;
            for (int i = 0; i < s.length(); i++)
                if (t == 0) t = s[i] - '0';
                else t = t * 10 + s[i] - '0';
            st[++top] = t;
        }
        //for (int i = 0; i <= top; i++) cout << st[i] << '\n';
    }
    cout << st[top] << '\n';
}



Measured memory_bytes: 3212
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())
k=int(input())

aaaaa=0
list=[a,b,c,d,e]
for i in range(4):
    for j in range(i+1,5):
        if abs(list[i]-list[j])>k:
            aaaaa=1
if aaaaa==1:
    print(":(")
else:
    print('Yay!')

Measured memory_bytes: 3064
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.InputMismatchException;
import java.util.NoSuchElementException;

public class Main {

	static void exec(MyScanner in, PrintWriter out) {
		in.nextInt();
		int Q = in.nextInt();
		String S = in.next();
		int[] t = new int[S.length()];
		for (int i = 0; i < t.length - 1; i += 1) {
			if (S.charAt(i) == 'A' && S.charAt(i + 1) == 'C') {
				t[i + 1] = t[i] + 1;
			} else {
				t[i + 1] = t[i];
			}
		}
		for (int i = 0; i < Q; i += 1) {
			int l = in.nextInt();
			int r = in.nextInt();
			out.println(t[r - 1] - t[l - 1]);
		}
	}

	public static void main(String[] args) {
		PrintWriter w = new PrintWriter(System.out);
		exec(new MyScanner(System.in), w);
		w.flush();
	}

	static class MyScanner {
		static final int BUFFER_SIZE = 1024;
		private final InputStream in;
		private final byte[] buffer = new byte[BUFFER_SIZE];
		private int point;
		private int readLength;
		MyScanner(InputStream in) {
			this.in = in;
		}
		private int nextByte() {
			if (point < readLength) {
				int result = buffer[point];
				point += 1;
				return result;
			}
			try {
				readLength = in.read(buffer);
			} catch (IOException e) {
				e.printStackTrace();
			}
			if (readLength == -1) {
				return -1;
			}
			point = 1;
			return buffer[0];
		}
		static boolean isPrintableCharExceptSpace(int c) {
			return 33 <= c && c <= 126;
		}
		String next() {
			StringBuilder b = new StringBuilder();
			int c = nextByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = nextByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			do {
				b.appendCodePoint(c);
				c = nextByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return b.toString();
		}
		long nextLong() {
			int c = nextByte();
			while (!(c == -1 || isPrintableCharExceptSpace(c))) {
				c = nextByte();
			}
			if (c == -1) {
				throw new NoSuchElementException();
			}
			boolean minus = false;
			if (c == '-') {
				minus = true;
				c = nextByte();
			}
			long result = 0L;
			do {
				if (!('0' <= c && c <= '9')) {
					throw new InputMismatchException();
				}
				result = result * 10L + (c - '0');
				c = nextByte();
			} while (c != -1 && isPrintableCharExceptSpace(c));
			return minus ? -result : result;
		}
		int nextInt() {
			long n = nextLong();
			if (Integer.MIN_VALUE <= n && n <= Integer.MAX_VALUE) {
				return (int) n;
			}
			throw new InputMismatchException();
		}
		double nextDouble() {
			return Double.parseDouble(next());
		}
	}
}


Measured memory_bytes: 32636
using System;

namespace AizuOnline
{
    class Program
    {
        static void Main(string[] args)
        {
            string x;
            string result = "";
            int idx = 1;
            x = Console.ReadLine();
            while (x != "0") 
            {
                result += String.Format("Case {0}: {1}\n", idx, x);
                x = Console.ReadLine();
                idx++;
            }
            Console.Write(result);
        }
    }
}


Measured memory_bytes: 10512
use std::io;

fn main() {
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let n = match buf.trim().parse::<i32>(){
		Ok(n) => n,
		_ => panic!(""),
	};
	let mut buf = String::new();
	io::stdin().read_line(&mut buf).expect("");
	let iter = buf.split_whitespace();
	let mut v = Vec::new();
	for i in iter {
		match i.parse::<i32>() {
			Ok(j) => v.push(j),
			_ => panic!(""),
		}
	}
	let mut cnt = 0;
	for i in 0..n {
		if v[i as usize] != i + 1 {
			cnt += 1;
		}
		if cnt > 2 {
			break;
		}
	}
	if cnt > 2 {
		println!("NO");
	}else{
		println!("YES");
	}
}

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

typedef long long ll;
typedef int64_t i6;
typedef std::vector<std::vector<int64_t> > Graph;

#define rep(i, n) for (int64_t i = 0; i < n; ++i)
#define rep2(i, n) for (int64_t i = 1; i <= n; ++i)
#define ALL(v) (v).begin(), (v).end()
#define Sort(x) sort(ALL(x))
#define Sort_rev(x) Sort(x);reverse(ALL(x))
#define Push_back(p, a, b) (p).push_back( make_pair( (a), (b) ) )

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<typename V,typename T> bool find_num(V v, T num) { if ( find(ALL(v), num) == v.end() ) { return false; } return true; }

// π M_PI
// deg = rad*180/M_PI

int main() {
    string s;
    cin >> s;
    string t;
    cin >> t;
    int64_t ans = 0;
    rep(i, s.length()) {
        if (s[i] != t[i]) ans++;
    }
    cout << ans << endl;
    return 0;
}


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

using namespace std;

#define int long long
#define all(v) (v).begin(), (v).end()
#define resz(v, ...) (v).clear(), (v).resize(__VA_ARGS__)
#define reps(i, m, n) for(int i = (int)(m); i < (int)(n); i++)
#define rep(i, n) reps(i, 0, n)

template<class T1, class T2> void chmin(T1 &a, T2 b){if(a>b)a=b;}
template<class T1, class T2> void chmax(T1 &a, T2 b){if(a<b)a=b;}

using Pi = pair<int, int>;
using Tapris = tuple<int, int, int>;
using vint = vector<int>;

const int inf = 1LL << 55;
const int mod = 1e9 + 7;

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, a;
  cin >> n >> a;
  cout << (n%500 <= a ? "Yes" : "No") << endl;

  return 0;
}


Measured memory_bytes: 764
package main

import (
	"bufio"
	"fmt"
	"math"
	"os"
	"strconv"
)

func reverse(s string) string {
	runes := []rune(s)
	for i, j := 0, len(runes)-1; i < j; i, j = i+1, j-1 {
		runes[i], runes[j] = runes[j], runes[i]
	}
	return string(runes)
}

func main() {
	var sc = bufio.NewScanner(os.Stdin)
	sc.Buffer([]byte{}, math.MaxInt64)
	sc.Scan()
	S := sc.Text()
	S = reverse(S)
	N := 2019
	var m = make([]int, N)
	// 10と2019は「互いに素」なので、累積和同士の剰余が等しいとき定数倍した累積和同士の剰余も等しい
	// x===y (mod 2019) <=> 10x===10y (mod 2019)
	m[0]++ // s0=0 (何も累積していない)
	total := 0
	ten := 1
	for x := 0; x < len(S); x++ {
		tmp, _ := strconv.Atoi(S[x : x+1])
		total += (tmp * ten) % N
		// 10^x (xが十分大きい) を剰余するとオーバーフローするのでNで剰余取りながら累積和をとる
		ten = (ten * 10) % N
		m[total%N]++
	}
	cnt := 0
	for _, v := range m {
		// 剰余の計算結果から2組ずつ選ぶパターン数を足す
		// ex) 2C2=1, 3C2=3
		cnt += v * (v - 1) / 2
	}
	fmt.Println(cnt)
}


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

struct ed{
    int to;
	int dis;
	int next;
} edge[400050];
int head[100050];
int edge_tot;

void addedge(int from,int to,int dis)
{
	edge_tot += 1;
    edge[edge_tot].to = to;
    edge[edge_tot].dis = dis;
    edge[edge_tot].next = head[from];
    head[from] = edge_tot;
}

int n,m;
long long dis[100005];
queue<int> q;
bool vis[100050],inq[100050];

bool spfa(int s){
    q.push(s);
    inq[s] = true;
    dis[s] = 0;
    long long curmax = 0;
	long long curmin = 0;
    while(!q.empty()){
        int u = q.front();
        q.pop();
        for(int i = head[u];i;i = edge[i].next){
            int v = edge[i].to;
            if(dis[v] == 12345678987654321){
                dis[v] = dis[u] + edge[i].dis;
                curmax = max(curmax,dis[v]);
                curmin = min(curmin,dis[v]);
                if(curmax - curmin > 1000000000) return false;
                vis[v] = 1;
                if(!inq[v])
                    q.push(v);
            }
            else if(dis[v] != dis[u] + edge[i].dis)
                return false;
        }
        inq[u] = false;
    }
    return true;
}

int main()
{
    for(int i = 1;i <= 100000; ++ i)
        dis[i] = 12345678987654321;
    scanf("%d%d",&n,&m);
    int tmp1,tmp2,tmp3;
    for(int i = 1;i <= m; ++ i)
    {
        scanf("%d%d%d",&tmp1,&tmp2,&tmp3);
        addedge(tmp1,tmp2,tmp3);
        addedge(tmp2,tmp1,-tmp3);
    }
    for(int i = 1;i <= n;i++){
        if(!vis[i]){
            vis[i] = 1;
			bool l = spfa(i);
            if(!l){
                printf("No\n");
                return 0;
            }
        }
    }
    printf("Yes\n");
    return 0;
}

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

#define int long long

struct Combination
{
  int mod;
  vector<int> mfact;
  vector<int> rfact;

  /*
    constructor : O(sz+log(mod))    
   */
  Combination(int sz, int mod) : mfact(sz+1), rfact(sz+1), mod(mod) {
    mfact[0] = 1;
    for ( int i = 1; i < (int)mfact.size(); i++ ) {
      mfact[i] = mfact[i-1]*i % mod;
    }
    rfact[sz] = inv(mfact[sz]);
    for ( int i = sz-1; i >= 0; i-- ) {
      rfact[i] = rfact[i+1]*(i+1) % mod;
    }
  }

  int fact(int k) const {
    return (mfact[k]);
  }

  int pow(int x, int n) const {
    int ret = 1;
    while ( n > 0 ) {
      if ( n & 1 ) (ret *= x) %= mod;
      (x *= x) %= mod;
      n >>= 1;
    }
    return (ret);
  }

  int inv(int x) const {
    return (pow(x, mod - 2));
  }

  /*
    permutation
   */
  int P(int n, int r) const {
    if ( r < 0 || n < r ) return (0);
    return (mfact[n]*rfact[n-r] % mod);
  }

  /*
    combination
   */
  int C(int n, int r) const {
    if ( r < 0 || n < r ) return (0);    
    return (mfact[n]*rfact[r]%mod * rfact[n-r] % mod);    
  }  

  /*
    combination with repetition
   */
  int H(int n, int r) const {
    if ( n < 0 || r < 0 ) return 0;
    if ( n == 0 && r == 0 ) return 1;
    return C(n+r-1, n);    
  }

  /*
    stirling number
   */
  int S(int n, int r) const {
    int ret;
    for ( int i = 1; i <= r; i++ ) {
      
    }
  }

  /*
    bell number
   */
  int B(int n, int r) const {

  }
};

signed main() {
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  int n, k;
  cin >> n >> k;

  int MOD = 1e9+7;  
  Combination c(2000, MOD);
  cout << c.C(n-1, k-1) << endl;  
  
  return 0;
}



Measured memory_bytes: 3252
#include <bits/stdc++.h>
#define SORT(x) sort((x).begin(), (x).end())
#define ALL(x) (x).begin(), (x).end()
#define rep(i, n) for (ll i = 0; i < n; i++)
#define reps(i, m, n) for (ll i = m; i < n; i++)
#define repr(i, m, n) for (ll i = m; i >= n; i--)
template <class T> bool maxi(T &a, const T &b) {
    if (a < b) { a = b; return 1;} return 0;}
template <class T> bool mini(T &a, const T &b) {
    if (b < a) { a = b; return 1;} return 0;}
#define dame {cout<< "Yes" <<"\n"; return;}
#define INF2 1000000000000000037
#define INF  1000000007
#define MOD  1000000007
#define PI (acos(-1))
using namespace std;
using ll = long long;
using ld = long double;
using P  = pair<ll,ll>;
//--GLOBAL---------------------------------

//--MAIN-----------------------------------
void Main() {
    ll N,M,K; cin>>N>>M>>K;
    rep(i,N+1){
        rep(j,M+1){
            ll ct=i*j+(N-i)*(M-j);
            if(ct==K) dame;
        }
    }
    cout<< "No" <<"\n";
}
//--START----------------------------------
int main() {
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
}
//-----------------------------------------


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

int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int N; cin >> N;
  vector<int> cnt(1e5+1, 0);
  REP(i, N){
    int a; cin >> a;
    if(a != 0){
      cnt[a-1]++; cnt[a]++; cnt[a+1]++;
    }else{
      cnt[a]++; cnt[a+1]++;
    }
  }
  priority_queue<pair<int, int>, vector<pair<int, int> > > pq;
  REP(i,1e5+1){
    pq.push({cnt[i], i});
  }
  auto ans = pq.top();
  cout << ans.first << endl;
}

Measured memory_bytes: 1784
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 52;
const int maxk = 102;
int v[maxn], f[maxn][maxk], g[maxn][maxk];

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
	int n, k;
	cin >> n >> k;

	for (int i = 0; i < n; ++i)
		cin >> v[i];

	int lim = min(n, k);
	for (int i = 0; i <= lim; ++i)
		for (int j = 0; j <= k; ++j)
			f[i][j] = g[i][j] = INT_MIN;

	f[0][0] = g[0][0] = 0;
	for (int i = 1; i <= lim; ++i) {
		for (int j = i; j <= min(k, 2*i); ++j) {
			if (f[i-1][j-1] != INT_MIN)
				f[i][j] = max(f[i][j], f[i-1][j-1] + v[i-1]);
			if (j > 1)
				f[i][j] = max(f[i][j], f[i-1][j-2]);

			if (g[i-1][j-1] != INT_MIN)
				g[i][j] = max(g[i][j], g[i-1][j-1] + v[n-i]);
			if (j > 1)
				g[i][j] = max(g[i][j], g[i-1][j-2]);

			// printf("%d %d:%d %d\n", i, j, f[i][j], g[i][j]);
		}
	}
	
	for (int i = 1; i <= lim; ++i)
		f[i][0] = g[i][0] = 0;
	for (int i = 1; i <= k; ++i)
		f[0][i] = g[0][i] = 0;

	long long ans = 0;
	for (int i = 0; i <= lim; ++i)
		for (int j = 0; j + i <= lim; ++j)
			for (int t = 0; t <= k; ++t)
				for (int z = 0; z + t <= k; ++z)
					ans = max(ans, (long long)f[i][t] + g[j][z]);
	
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
n = int(input())
a = list(map(int, input().split()))
a1, a2 = [],[]
for index, i in enumerate(a, start=1):
  if index % 2 == 0:
    a2.append(i)
  else:
    a1.append(i)

ans = []
if n % 2 == 0:
  ans = a2[::-1] + a1
else:
  ans = a1[::-1] + a2

print(" ".join(str(i) for i in ans))

Measured memory_bytes: 37892
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define repi(i, s, n) for (int i = (s); i < (n); i++)
#ifdef LOCAL
#define INPUT_FILE                              \
  ifstream in("atcoder-problems/arc080_a.txt"); \
  cin.rdbuf(in.rdbuf());
#define print_vec(v)                        \
  rep(l, v.size()) { cout << v[l] << " "; } \
  cout << endl;
#else
#define INPUT_FILE
#define print_vec(v)
#endif
#define CIN_OPTIMIZE \
  cin.tie(0);        \
  ios::sync_with_stdio(false);
typedef pair<int, int> P;
typedef long long ll;
typedef pair<ll, ll> pl;
const int INF = 100100100;
const ll LINF = 1e18 + 100;
const int MOD = 1e9 + 7;

int main() {
  INPUT_FILE CIN_OPTIMIZE;

  int N;
  cin >> N;

  vector<int> c(N);
  rep(i, N) { cin >> c[i]; }

  ll ans = 0;
  ll ans2 = 0;
  rep(i, N) {
    if (c[i] % 4 == 0 && c[i] / 4 >= 1) ans++;
    else if (c[i] % 2 == 0 && c[i] / 2 >= 1) ans2++;
  }

  cout << (ans + ans2 / 2 >= N / 2 ? "Yes" : "No") << endl;
}

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

string s;
bool Yes =false;

void dfs(int a){
  if(a==s.size()){
    Yes=true;
    return;
  }
  if(s.size()-a>=5){
    if(s.substr(a,5)=="dream"){
      dfs(a+5);
    }
    if(s.substr(a,5)=="erase"){
      dfs(a+5);
    }
    if(s.substr(a,7)=="dreamer"){
      dfs(a+7);
    }
    if(s.substr(a,6)=="eraser"){
      dfs(a+6);
    }
  }
  return ;
}
       
int main() {
  cin>>s;
  dfs(0);
  cout << (Yes? "YES":"NO");
}

Measured memory_bytes: 1792
#include<iostream>
#include<climits>
using namespace std;
int main(){
    int a,b,c,x,y;
    int ans=0;
    cin >> a >> b >> c >> x >> y;

    ans = a * x + b * y;

    if(x > y){
        if(ans > 2 * x * c){
            ans = 2*x*c;
        }
        if(ans > 2*y*c + (x-y) * a){
            ans = 2*y*c + (x-y) * a;
        }
    }else{
        if(ans > 2 * y * c){
            ans = 2*y*c;
        }
        if(ans > 2*x*c + (y-x) * b){
            ans = 2*x*c + (y-x) * b;
        }
    }

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

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

vector <pair<int, int> > vec;

int main(){
	int n;
	long k;
	scanf("%d%ld", &n, &k);
	for(int i = 0; i < n; i++) {
		int a, b;
		scanf("%d%d", &a, &b);
		vec.push_back(make_pair(a, b));
	}
	sort(vec.begin(), vec.end());
	for(int i = 0; i < n; i++) {
		k -= vec[i].second;
		if(k <= 0) {
			printf("%ld\n", vec[i].first);
			return 0;
		}
	}
}


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

int main(){
  int n,m;
  cin >> n >> m;
  int ans=0;
  if(n>1&&m>1){
    ans=(n*(n-1)+m*(m-1))/2;
  }else if(n>1&&m<=1){
    ans=n*(n-1)/2;
  }else if(n<=1&&m>1){
    ans=m*(m-1)/2;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
int main(void){
    int i,n;
    scanf("%d\n",&n);
    int v[n],c[n];
    for (i=0;i<n;i++){
	scanf("%d",&v[i]);
	}
    for (i=0;i<n;i++){
	scanf("%d",&c[i]);
	}

    int x[n];
    int p=0;
    for (i=0;i<n;i++){
	x[i]=v[i]-c[i];
	if(x[i]>=0)p+=x[i];
	}
    printf("%d\n",p);

    return 0;
    }


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

int main(){
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n+1), b(m+1);
    a[0] = b[0] = 0;
    int temp;
    for(int i = 0; i < n; i++){
        cin >> temp;
        a[i+1] = temp + a[i];
    }
    for(int i = 0; i < m; i++){
        cin >> temp;
        b[i+1] = temp + b[i];
    }
    int ans = 0;
    int j = m;
    for(int i = 0; i <= n; i++){
        if(a[i] > k) break;
        while(a[i] + b[j] > k && j > 0){
            j--;
        }
        ans = max(ans, i + j);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 6404
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define rrep(i, n) for (int i = n - 1; i >= 0; i--)
using namespace std;
using Graph = vector<vector<int>>;
#define MOD 1000000007
#define MOD2 998244353
#define INF ((1<<30)-1)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long ll;
typedef pair<ll, ll> P;

int main(){
    ll n, k;
    cin >> n >> k;
    ll ans = 0;
    if (k == 0){
        cout << n * n << endl;
        return 0;
    }

    for(int b = k + 1; b <= n; b++){
        ll c = n / b;
        ll tmp = c * (b - k);
        tmp += max(ll(0), ll(n % b - max(ll(1), k) + 1));
        ans += tmp;
    }
    cout << ans << endl;
    return 0;
}

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

using namespace std;
#define int long long
#define br cout<<"\n"
#define all(V) V.begin(),V.end()
#define rall(V) V.rbegin(),V.rend()
#define umap unordered_map
#define uset unordered_set

typedef vector<int> vi;
typedef vector<vi> vvi;

bool isPwrOf2(int x) { return x && (!(x&(x-1))); }
/*------------------------------------------------*/
string base2(int num)
{
    string s="";
    while(num!=0){
        int rem = abs(num)%(2);
        if(rem==1){
            s+= "1";
        }
        else{
            s+="0";
        }
        num/= (-2);
    }
    reverse(all(s));
    return s;
}
/*------------------------------------------------*/

signed main()
{
    ios_base::sync_with_stdio(false); cin.tie(nullptr);
    // #ifndef ONLINE_JUDGE
    //     freopen("./input.txt", "r", stdin);
    //     freopen("./output.txt", "w", stdout);
    // #endif
    /*------------------------------------------------*/
    string s; cin>>s;
    int n; cin>>n;
    if(n==1){
        cout<<s[0];
    }
    else{
        int i=0;
        while(s[i]=='1'){
            n--;
            if(n<=0){break;}
            i++;
        }
        cout<<s[i];
    }
    /*------------------------------------------------*/
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i) = 0; (i) < (n); ++(i))
#define rrep(i,n) for(int (i) = (n) - 1; (i) >= 0; --(i)) //Reversi rep
#define nfor(i,a,b) for(int (i) = (a); (i) < (b); ++(i)) //Natural for
#define rfor(i,a,b) for(int (i) = (b); (i) >= (a); --(i)) //Reversi for

int main()
{
    int a,b,c;
    cin >> a >> b >> c;
    if (b - c >= 0) {
        cout << "delicious" << endl;
    }else{
        if (a + b - c >= 0) {
            cout << "safe" << endl;
        }else{
            cout << "dangerous" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
      	String result="";
		int a = sc.nextInt();
		String s1 = sc.next();
      	String s2 = sc.next();
      	for(int i=0;i<a;i++)
        {
          result=result+s1.substring(i,i+1)+s2.substring(i,i+1);
        }
      System.out.println(result);
	}
}

Measured memory_bytes: 23764
using System;
using System.Diagnostics;
using System.IO;
using System.Text;
using System.Linq;
using System.Collections.Generic;
using System.Text.RegularExpressions;

class Program
{
    const string Yes = "Yes";
    const string No = "No";
    const long Mod = 1000000007;

    static void Main(string[] args) {
#if DEBUG
        MyDebugger.Test(process, "../TextFile1.txt");
#else
        object ret = process(new StreamReader(Console.OpenStandardInput()));
        Console.WriteLine(ret);
#endif
    }

    static object process(TextReader input) {
        var spl = input.ReadLine().Split(' ');
        var a = int.Parse(spl[0]);
        var b = int.Parse(spl[1]);
        var k = int.Parse(spl[2]);

        for(int i=a; i <= b;) {
            Console.WriteLine(i);
            i++;

            if (i == a + k) {
                i = Math.Max(i, b - (k-1));
            }
        }

        return null;
    }


    static int[] ToIntArray(string strs, int n) {
        var ret = new int[n];
        var spl = strs.Split(' ');
        for (int i = 0; i < n; i++)
            ret[i] = int.Parse(spl[i]);
        return ret;
    }
}


Measured memory_bytes: 13140
IDENTIFICATION DIVISION.
       PROGRAM-ID. test1.
       ENVIRONMENT DIVISION.
       DATA DIVISION.
       WORKING-STORAGE SECTION.
       01 INP PIC 99.
       01 A PIC 9.
       PROCEDURE DIVISION.
       MAIN.
       	ACCEPT INP.
      	COMPUTE A=INP/10.
      	COMPUTE INP=INP - A*10.
      	IF A=9 OR INP=9 THEN
      		DISPLAY "Yes"
      	ELSE
      		DISPLAY "No"
      	END-IF.
        STOP RUN.


Measured memory_bytes: 636
import java.util.Scanner;
public class Main{
 public static void main(String args[]){
  boolean flag=false;
  Scanner scan=new Scanner(System.in);
  String s;

  s=scan.next();
  long r=Long.parseLong(s);
  s=scan.next();
  long g=Long.parseLong(s);
  s=scan.next();
  long b=Long.parseLong(s);

  long x=100*r+10*g+b;

  if(x%4==0)System.out.println("YES");
  else System.out.println("NO");
 }

 ///////////////////////////////////////////////
 public static boolean prime(long a){
  if(a<=1)return false;
  for(int i=2;i*i<=a;i++){
   if(a%i==0)return false;
  }
  return true;
 }
 public static long llpow(long x,long n){
  long ans=1;
  for(int i=0;i<n;i++)ans*=x;
  return ans;
 }
 public static long max(long a,long b){
  if(a<b)return b;
  else return a;
 }
 public static long min(long a,long b){
  if(a>b)return b;
  else return a;
 }
 public static long cei(long x,long y){
  long ans=x/y;
  if(x%y!=0)ans++;
  return ans;
 }
 public static long gcd(long x,long y){
  return (y==1)?gcd(y,x%y):x;
 }
 public static long lcm(long x,long y){
  return x/gcd(x,y)*y;
 }
 public static long fact(long x){
  long ans=1;
  for(int i=0;i<x;i++)ans*=(x-i);
  return ans;
 }
 public static long ncr(long n,long r){
  long ans=1,l=2;
  for(int i=0;i<min(n-r,r);i++){
   ans*=(n-i);
   while(ans%l==0&&l<=min(r,n-r)){
    ans/=l;l++;
   }
  }
  return ans;
 }
 public static long npr(long n,long r){
  long ans=1;
  for(int i=0;i<r;i++)ans*=(n-i);
  return ans; 
 }
 public static long fib(int x){
  long fibo[]=new long[x+10];
  fibo[0]=1;fibo[1]=1;
  for(int i=2;i<x+1;i++)fibo[i]=fibo[i-1]+fibo[i-2];
  return fibo[x];
 }
 public static long dig(long n){
  long d=1,tmp=n;
  while(tmp/10>0){
   tmp/=10;d++;
  }
  return d;}
}



Measured memory_bytes: 35676
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ui unsigned int
#define ull unsigned ll
#define pii pair<int,int>
#define pll pair<ll,ll>
#define db long double
#define mp make_pair
#define X first
#define Y second
#define vi vector<int>
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define rep(i,a,b) for(int i=(a);i<=(b);++i)
#define per(i,b,a) for(int i=(b);i>=(a);--i)
#define rep0(i,a,b) for(int i=(a);i<(b);++i)
#define fore(i,a) for(int i=0;i<(a).size();++i)
#define ls x<<1,l,m
#define rs x<<1|1,m+1,r
#define gc getchar
inline ll rd()
{
	ll x=0,w=1;char c=gc();while(!isdigit(c)&&c!='-')c=gc();
	if(c=='-')c=gc(),w=-1;while(isdigit(c))x=x*10+c-48,c=gc();return x*w;
}
const int N=405,P=998244353;
int n,tt,h[N],f[N][N][2],g[N][2],p[2][N][N];
int dp(int l,int r)
{
	if(l>r)return 0;int o=++tt,val=1e9,nn=0;
	rep(i,l,r)val=min(val,h[i]);
	int lst=l-1,sz=0;f[o][0][0]=1;
	rep(i,l,r+1)if(i==r+1||h[i]==val)
	{
		nn++;int t=dp(lst+1,i-1);
		if(t)
		{
			memset(g,0,sizeof(g));
			rep(s1,0,sz)rep(s2,0,i-lst-1)rep(t1,0,1)rep(t2,0,1)
				g[s1+s2][t1|t2]=(g[s1+s2][t1|t2]+1ll*f[o][s1][t1]*f[t][s2][t2])%P;
			memcpy(f[o],g,sizeof(g));sz+=i-lst-1;
		}
		lst=i;
	}
	nn--;
	rep(i,1,nn)
	{
		memcpy(g,f[o],sizeof(g));
		rep(j,0,r-l+1)g[j+1][0]=(g[j+1][0]+P-f[o][j][0])%P;
		rep(j,0,r-l+1)g[j+1][1]=(g[j+1][1]+f[o][j][0])%P;
		memcpy(f[o],g,sizeof(g));
	}
	int len=val-max(h[l-1],h[r+1]);
	rep(i,0,r-l+1)
	{
		f[o][i][0]=1ll*f[o][i][0]*p[0][r-l+1-i][len]%P;
		f[o][i][1]=1ll*f[o][i][1]*p[1][r-l+1-i][len]%P;
	}
	return o;
}
int main()
{
	n=rd();rep(i,1,n)h[i]=rd();
	rep(i,0,n)p[0][i][0]=p[0][0][i]=1;
	rep(j,1,n)
	{
		p[0][j][1]=2ll*p[0][j-1][1]%P;p[1][j][1]=p[0][j][1]-1;
		rep(k,2,n)p[0][j][k]=1ll*p[0][j][k-1]*p[0][j][1]%P;
		rep(k,2,n)p[1][j][k]=1ll*p[1][j][k-1]*p[1][j][1]%P;
	}
	int t=dp(1,n),s=0;
	rep(i,0,n)rep(j,0,1)s=(s+f[t][i][j])%P;
	printf("%d\n",s);return 0;
}


Measured memory_bytes: 6324
#Union Find

#xの根を求める
def find(x):
    if par[x] < 0:
        return x
    else:
        par[x] = find(par[x])
        return par[x]

#xとyの属する集合の併合
def unite(x,y):
    x = find(x)
    y = find(y)
    
    if x == y:
        return False
    else:
        #sizeの大きいほうがx
        if par[x] > par[y]:
            x,y = y,x
        par[x] += par[y]
        par[y] = x
        return True

#xとyが同じ集合に属するかの判定
def same(x,y):
    return find(x) == find(y)

#xが属する集合の個数
def size(x):
    return -par[find(x)]

N, M = map(int, input().split())
bridges = []

for _ in range(M):
    a, b = map(int, input().split())
    a -= 1
    b -= 1
    bridges.append((a, b))

#初期化
#根なら-size,子なら親の頂点
par = [-1]*N
tot = N*(N-1)//2
ans = [tot]

for a, b in bridges[::-1]:
    if not same(a, b): 
        tot -= size(a)*size(b)
    unite(a, b)
    ans.append(tot)

print('\n'.join(map(str, ans[:-1][::-1])))

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

using namespace std;

const long long MOD = 1000000007;

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

    long long A;

    // 各色の帽子のそれまでの合計
    vector<long long> tmp(3, 0);
    long long count = 1, tmp_count = 0;

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

        tmp_count = 0;
        
        for (int k = 0; k < 3; k++) {
            if (tmp[k] == A) {
                if (tmp_count == 0) {
                    tmp_count += 1;
                    tmp[k] += 1;
                } else {
                    tmp_count += 1;
                }
            }
        }

        count = (count * tmp_count) % MOD;
    }

    cout << count << endl;
	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
//#define N 1000
#define True 1
#define False 0

int isEmpty(void);
int isFull(void);
void push(int);
int pop(void);

int top = 0;
int A[1000];

int main(){
  int a = 0, b = 0, x = 0;
  char s[100];
  
  while((scanf("%s",s)) != EOF){
    if(s[0] == '+'){
      a = pop();
      b = pop();
      push(a + b);
    }
    else if(s[0] == '-'){
      a = pop();
      b = pop();
      push(b - a);
    }
    else if(s[0] == '*'){
      a = pop();
      b = pop();
      push(a * b);
    }
    else {
      x = atoi(s);
      push(x);
    }
  }

  printf("%d\n",pop());
  
  return 0;
}
/*
int isEmpty(void){
  if(top == 0)return True;
  else return False;
}

int isFull(void){
  if(top >= N-1)return True;
  else return False;
}
*/
void push(int x){
  /*
  if((isFull()) == True){
    printf("Overflow!");
  }
  
  else {*/
    top++;
    A[top] = x;
    // }
  
}

int pop(void){
  /*
  if((isEmpty()) == True){
    printf("Underflow!");
  }
  
  else {*/
    top--;
    return A[top + 1];
    //}
}



Measured memory_bytes: 2100
#include<iostream>
#include<vector>
#include<algorithm>
#include<math.h>
#include<queue>
#include<map>
#include<string>
#define all(x) (x).begin(),(x).end()
#define print(x) cout << (x) << endl
typedef long long ll;
typedef long double ld;
const ll MOD = 1000000007;
const ll MOD2 = 998244353;
 
using namespace std;

int main(){
    ll d, t, s;    cin >> d >> t >> s;
    if(d <= t*s)    print("Yes");
    else    print("No");
}

Measured memory_bytes: 3620
#include <iostream>

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

    for (int i = 0; i < 4; i++) {
        std::cout << s[i];
    }

    std::cout << " ";

    for (int i = 4; i < 12; i++) {
        std::cout << s[i];
    }

    putchar('\n');
}


Measured memory_bytes: 256
N = int(input())
L = input().split()
count = 0
for x in range(N-2):
    X = int(L[x])
    for y in range(x+1, N-1):
        Y = int(L[y])
        for z in range(y+1, N):
            Z = int(L[z])

            if X == Y or Y == Z or Z == X:
                pass
            elif X + Y > Z and X + Z > Y and Y + Z > X:
                count += 1
            else:
                pass
print(count)

Measured memory_bytes: 9076
#!/usr/bin/env python3

from pprint import pprint
from collections import deque, defaultdict
import sys

sys.setrecursionlimit(10 ** 6)
input = sys.stdin.buffer.readline
inf = float("inf")

n_vertices, m_edges = map(int, input().split())
edges = [[] for _ in range(n_vertices)]

for _ in range(m_edges):
    x, y = map(int, input().split())
    edges[x - 1].append(y - 1)
# print(edges)

# dp[v] := ノードvを始点としたときの有向パスの長さの最大値
# ノードvの隣接ノードv_adjに対して、dp[v] = max(dp[v], rev[v_adj] + 1)


def rec(v):
    if dp[v] != -1:
        # 既に更新済み
        return dp[v]
    for v_adj in edges[v]:
        dp[v] = max(dp[v], rec(v_adj) + 1)
    return dp[v]


dp = [-1 for _ in range(n_vertices)]
res = 0
for v in range(n_vertices):
    res = max(res, rec(v))

print(res + 1)


Measured memory_bytes: 161500
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr int Inf = 1000000010;
constexpr ll INF= 1000000000000000000;
constexpr ll MOD = 1000000007;
const double PI = 3.1415926535897;
typedef pair<ll,ll> P;

template<typename T>
T Pow(T a,T b) {
    T ret = 1;
    for(int i = 0;i < b;i++) {
        ret *= a;
    }
    return ret;
}

ll mod(ll val) {
    ll res = val % MOD;
    if(res < 0) {
        res += MOD;
    }
    return res;
}

ll RS(ll N, ll P, ll M){
    if(P==0) return 1;
    if(P < 0) {
        return 0;
    }
    if(P%2==0){
        ll t = RS(N, P/2, M);
        return t*t % M;
    }
    return N * RS(N, P-1, M) % M;
}

int main() {
    int N;
    cin >> N;
    string S;
    cin >> S;
    map<pair<string,string>,ll> A;
    map<pair<string,string>,ll> B;
    for(int bit = 0;bit < (1 << N);bit++) {
        vector<bool> cnt(N);
        for(int i = 0;i < N;i++) {
            if(bit & (1 << i)) {
                cnt.at(i) = true;
            }
        }
        string cnt1 = "";
        string cnt2 = "";
        string cnt3 = "";
        string cnt4 = "";
        for(int i = 0;i < N;i++) {
            if(cnt.at(i) == true) {
                cnt1.push_back(S.at(i));
                cnt3.push_back(S.at(2 * N - 1 - i));
            }
            else {
                cnt2.push_back(S.at(i));
                cnt4.push_back(S.at(2 * N - 1 - i));
            }
        }
        A[make_pair(cnt1,cnt2)]++;
        B[make_pair(cnt3,cnt4)]++;
    }
    ll ret = 0;
    for(auto x:A) {
        if(B.count(make_pair(x.first.second,x.first.first))) {
            ret += x.second * B[make_pair(x.first.second,x.first.first)];
        }
    }
    cout << ret << endl;
}

Measured memory_bytes: 60864
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int N = scan.nextInt();
		int ans = 0;
		int[] arr = new int[N];
		for(int i=0;i<N;i++){
			arr[i]=scan.nextInt();
		}
		Arrays.sort(arr);
		if(N>=3){
			for(int i=0;i<N-2;i++){
				for(int j=i+1;j<N-1;j++){
					for(int k=j+1;k<N;k++){
						if(arr[i]!=arr[j] && arr[k]!=arr[j] && arr[i]+arr[j]>arr[k]){
							ans++;
						}
					}
				}
			}
		}
		System.out.println(ans);
	}
}

Measured memory_bytes: 27316
#pragma GCC optimize("O3")

#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <cstring>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <numeric>
#include <bitset>
#include <cassert>
#include <random>
#include <unordered_set>
#include <unordered_map>

#define sz(a) (int)((a).size())
#define all(a) (a).begin(), (a).end()
#define pb push_back
#define mp make_pair

using namespace std;
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using vi = vector<int>;

#define int ll

const int mod = 1e9 + 7;

int pw(int a, int b) {
	int r = 1;
	while (b) {
		if (b & 1) {
			r = 1LL * r * a % mod;
		}
		a = 1LL * a * a % mod;
		b >>= 1;
	}
	return r;
}

int N;
int n;
int K;
vi p;
int num_cyc;
vector<vi> g;
vi col;
vi ver_on_cyc;
vi tps;
vi s;

void dfs(int v) {
	col[v] = 1;
	for (int to : g[v]) {
		if (col[to] == 0) {
			dfs(to);
		}
		else if (col[to] == 1) {
			ver_on_cyc.pb(to);
		}
	}
	col[v] = 2;
	tps.pb(v);
}

int32_t main() {
	ios::sync_with_stdio(0), cin.tie(0);
	cin >> n;
	N = n;
	p.resize(n);
	g.resize(n);
	for (int i = 0; i < n; i++) {
		cin >> p[i];
		if (p[i] != -1) {
			p[i]--;
			g[p[i]].pb(i);
		}
		else {
			K++;
		}
	}
	col.resize(n);
	for (int u = 0; u < n; u++) {
		if (col[u] == 0) {
			dfs(u);
		}
	}
	for (int v : ver_on_cyc) {
		num_cyc = (num_cyc + pw(N - 1, K)) % mod;
	}
	vi s(n, 1);
	for (int u : tps) {
		for (int to : g[u]) {
			s[u] += s[to];
		}
	}
	vi a;
	for (int u = 0; u < n; u++) {
		if (p[u] == -1) {
			a.pb(s[u]);
		}
	}
	assert(sz(a) == K);
	vi dp(K + 1);
	dp[0] = 1;
	for (int s : a) {
		for (int i = K; i > 0; i--) {
			dp[i] = (1LL * dp[i - 1] * s + dp[i]) % mod;
		}
	}
	for (int s : a) {
		if (s > 1) {
			num_cyc = (num_cyc + (s - 1LL) * pw(N - 1, K - 1)) % mod;
		}
	}
	int fac = 1;
	for (int s = 2; s <= K; s++) {
		num_cyc = (num_cyc + 1LL * pw(N - 1, K - s) * fac % mod * dp[s]) % mod;
		fac = 1LL * fac * s % mod;
	}

	cout << ((1LL * N * pw(N - 1, K) - num_cyc) % mod + mod) % mod;
}


Measured memory_bytes: 3980
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vl;
#define rep(i, n) for(ll i = 0;i < n;i++)
#define all(i) i.begin(), i.end()
template<class T, class U> void cmax(T& a, U b) { if (a<b) a = b; }
template<class T, class U> void cmin(T& a, U b) { if (a>b) a = b; }

int n = 20300;
vl ans(20003);
vl c(n), cnt(n), a(n-1), b(n-1);
vector<vi> graph(20030);
int ind = 0;

void dfs(int i, int p) {
  ans[i] = c[ind];
  ind++;
 
  for (auto&& j : graph[i]) {
    if (j != p) {
      dfs(j, i);
    }
  }
}

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

  int n;
  cin >> n;
  rep(i, n-1) {
    cin >> a[i] >> b[i];
    a[i]--; b[i]--;
    cnt[a[i]]++;
    cnt[b[i]]++;
    graph[a[i]].push_back(b[i]);
    graph[b[i]].push_back(a[i]);
  }
  ll sum = 0;
  rep(i, n) {
    cin >> c[i];
    sum += c[i];
  }

  sort(all(c));
  reverse(all(c));
  sum -= c[0];

  vector<pii> cntt(n);
  rep(i, n) {
    cntt[i] = {cnt[i], i};
  }

  sort(all(cntt));
  reverse(all(cntt));

  dfs(cntt[0].second, -1);

  cout << sum << endl;
  rep(i, n) cout << ans[i] << " ";
  cout << endl;
}


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

void move(string s[12], int i, int j){
	s[i][j] = '0';
	if(i > 0 && s[i-1][j] == '1') move(s,i-1,j);
	if(i < 11 && s[i+1][j] == '1') move(s,i+1,j);
	if(j > 0 && s[i][j-1] == '1') move(s,i,j-1);
	if(j < 11  && s[i][j+1] == '1') move(s,i,j+1);
}
int main(){
	string s;
	string area[12];
	while(cin >> s){
		int count = 0;
		for(int i = 0; i < 12; i++){
			area[i] = s;
			if(i == 11) break;
			cin >> s;
		}
		for(int i = 0; i < 12; i++){
			for(int j = 0; j < 12; j++){
				if(area[i][j] == '1'){
					move(area,i,j);
					count++;
				}
			}
		}
		cout << count << endl;
	}
	return 0;
}

Measured memory_bytes: 0
def main():
    a = int(input())                    
    b = int(input())
    c = int(input())
    x = int(input())

    money = 0
    ans = 0

    for i in range(a+1):
        for j in range(b+1):
            for k in range(c+1):
                money = 500 * i + 100 * j + 50 * k
                if money == x:
                    #print(i, j, k)
                    ans += 1

    print(ans)

if __name__ == "__main__":
    main()


Measured memory_bytes: 38896
#include<stdio.h>
int min(int a,int b){return a>b?b:a;}
int f(int x){return x>0?x:-x;}
int a[200010],dp[200010];
int main(){
	int i,j,n,k;
	scanf("%d%d",&n,&k);
	for(i=0;i<n;i++)scanf("%d",&a[i]);
	for(i=1;i<=k;i++)dp[i]=f(a[i]-a[0]);
	for(i=k+1;i<n;i++){
		dp[i]=2147483647;
		for(j=1;j<=k;j++)dp[i]=min(dp[i],dp[i-j]+f(a[i]-a[i-j]));
	} 
	printf("%d",dp[n-1]);
	return 0;
}

Measured memory_bytes: 896
#include <iostream>
#include<string>
#include<cmath>
#include<ciso646>
#include<cstring>
#include<iomanip>
#include<vector>
#include<algorithm>
#include<utility>
#include<map>
#include<math.h>

using ll = long long;
ll M = 1e18;

using namespace std;
int main()
{
	int n;
	cin >> n;
	vector<ll> a(n);
	ll ans = 1;
	for (int i = 0;i < n;i++) {
		cin >> a[i];
	}
	sort(a.begin(), a.end());
	if (a[0] == 0) {
		cout << "0";
		return 0;
	}
	for (int i = 0;i < n;i++) {
		if ( M/ans<a[i]) {
			cout << "-1";
			return 0;
		}
		if(i!=n)ans *= a[i];
	}
	cout << ans;

}


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

void print_vec(vector<int> vec) {
    cout << "{";
    for(auto s: vec) cout << s << " ";
    cout << "}" << endl;
}

int main() {
    int N; cin >> N;
    vector<int> D(N);
    rep(i,N) cin >> D.at(i);
    sort(D.begin(),D.end());
    cout << D.at(N/2) - D.at(N/2-1) << endl;
}

Measured memory_bytes: 640