akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define INF 1001001001
#define LINF 1001001001001001001
#define MOD 1000000007
#define MOD2 998244353

template<class T,class U>bool chmax(T &a, const U &b){if(a<b){a=b;return 1;}return 0;}
template<class T,class U>bool chmin(T &a, const U &b){if(b<a){a=b;return 1;}return 0;}

#define rep(i,n) for(int i=0,_i=(n);i<_i;++i)
#define rep1(i,a,b) for(int a_=(a),b_=(b),i=a_;i<b_;++i)
#define repr(i,n) for(int _i=(n),i=_i;i>0;--i)

#define db(x) cerr<<#x<<" = "<<x<<" ";
#define db2(x,y) cerr<<"("<<#x<<", "<<#y<<") = ("<<x<<", "<<y<<") ";
#define db3(x,y,z) cerr<<"("<<#x<<", "<<#y<<", "<<#z<<") = ("<<x<<", "<<y<<", "<<z<<") ";
#define ln cout<<endl;

#define all(a)  (a).begin(),(a).end()
#define dig(n)  to_string(n).length()

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define se second
#define fi first

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

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

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

int main(){

    bool flag=false;
    ll ans=0,sum=0;

    ll n,k;
    cin>>n>>k;
    ans = min( n%k ,abs(k - n%k));
    cout<<ans<<endl;

    //cout <<fixed<<setprecision(16)<< << endl;

    //if(flag)cout << "Yes" <<endl;
    //else cout << "No" <<endl;

    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>
using namespace std;
#define REP(i,b,n) for(int i=b;i<n;i++)
#define rep(i,n)   REP(i,0,n)
#define pb         push_back

const int N = 300;
const double inf = 1000;
const double eps=1e-10;

double cost[N][N];
double dp[N][N];

double le(vector<double> &tmp,double tar){
  int l=0,r=tmp.size()-1;
  double ret=-inf;
  while(l <= r){
    int mid=(l+r)/2;
    if (fabs(tmp[mid]-tar)<eps)return tmp[mid];
    else if (tmp[mid] > tar)r=mid-1;
    else l=mid+1,ret=tmp[mid];
  }
  return ret;
}

double ge(vector<double> &tmp,double tar){
  int l=0,r=tmp.size()-1;
  double ret=inf;
  while(l <= r){
    int mid=(l+r)/2;
    if (fabs(tmp[mid]-tar)<eps)return tmp[mid];
    else if (tmp[mid] > tar)r=mid-1,ret=tmp[mid];
    else l=mid+1;
  }
  return ret;
}

void pre(int n,double *in,double div,int L){
  rep(i,n){
    REP(j,i+1,n){
      double maxi=0;
      double mini=10000000;
      cost[i][j]=0;
      for(int k=i;k<=j;k++){
	mini=min(mini,in[k]);
	maxi=max(maxi,in[k]);
      }
      double tmp=(maxi-mini)/div;
      vector<double> hoge;
      REP(k,1,(1<<L)+1){
	hoge.pb(mini+(k-1)*tmp);
      }
      sort(hoge.begin(),hoge.end());
      //rep(k,hoge.size())cout<<hoge[k]<<" " ;cout <<" !!!"<< endl;
      for(int k=i;k<=j;k++){
	double a=le(hoge,in[k]);
	double b=ge(hoge,in[k]);
	//cout << a <<" " << in[k] <<" " << b << endl;
	a=fabs(a-in[k]);
	b=fabs(b-in[k]);
	if (a<b)cost[i][j]+=a*a;
	else cost[i][j]+=b*b;
	//a=(a-in[k])*(a-in[k]);
	//b=(b-in[k])*(b-in[k]);
	//cost[i][j]+=min(a,b);
      }
    }
  }
}

double solve(int n,int M){
  rep(i,n+1){
    rep(j,M+1)dp[i][j]=inf;
  }
  dp[0][0]=0;
  REP(i,2,n+1){
    REP(j,1,M+1){
      rep(k,i-1){
	//cout << k<<" " << i-1 <<" " << cost[k][i-1] << endl;
	dp[i][j]=min(dp[i][j],dp[k][j-1]+cost[k][i-1]);
      }
    }
  }
  return dp[n][M];
}

main(){
  //test();
  int n,M,L;
  double in[N];
  while(cin>>n>>M>>L && n){
    rep(i,n)cin>>in[i];
    pre(n,in,(1<<L)-1,L);
    printf("%.7lf\n",solve(n,M));
  }
  return false;
}

Measured memory_bytes: 2188
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
const Int MOD = 1e9+7;
Int n;
string s[55];
Int dp[55][55][22][33];
Int check(Int u,Int d,Int k,Int c){
  Int flg=1;
  for(Int i=u;i<d;i++)
    flg&=(k<(Int)s[i].size()&&(s[i][k]=='?'||s[i][k]=='a'+c));
  return flg;
}

Int dfs(Int u,Int d,Int k,Int a){
  Int &res=dp[u][d][k][a];
  if(~res) return res;
  res=0;
  
  if(u+1==d&&k==(Int)s[u].size())
    return res=1;

  if(k==(Int)s[u].size()&&k<(Int)s[u+1].size())
    return res=dfs(u+1,d,k,0);

  for(int i=u;i<d;i++)
    if(k>=(Int)s[i].size())
      return res=0;
  
  for(Int c=a;c<26;c++)
    if(check(u,d,k,c)) (res+=dfs(u,d,k+1,0))%=MOD;
  
  for(Int i=u+1;i<d;i++)
    for(Int c=a;c<26;c++)
      if(check(u,i,k,c))
	 (res+=dfs(u,i,k+1,0)*dfs(i,d,k,c+1)%MOD)%=MOD;

  //if(res) cout<<u<<" "<<d<<" "<<k<<" "<<a<<":"<<res<<endl;
  return res;
}

signed main(){
  cin>>n;
  for(Int i=0;i<n;i++) cin>>s[i];
  memset(dp,-1,sizeof(dp));
  cout<<dfs(0,n,0,0)<<endl;
  return 0;
}



Measured memory_bytes: 20368
import java.io.*;

class Main {
	public static void main(String args[]) {
		InputStreamReader isr = new InputStreamReader(System.in);
		BufferedReader br = new BufferedReader(isr);

		try {
			String buf = br.readLine();
			int n = Integer.parseInt(buf);

			long money = 100000;
			for (int i=0;i<n;i++) {
				money = (money/100)*105;
				if (money%1000>0)
					money = money-money%1000+1000;
			}
			System.out.println(money);
		} catch (Exception e) {
			System.out.println("Exception!");
		}
	}
}

Measured memory_bytes: 16852
def main():
    N = int(input())
    A = list(map(int, input().split()))
    A.sort(reverse=True)
    d = {}
    for i in A:
        if i in d:
            d[i] += 1
        else:
            d[i] = 1
    r = 0
    for i in A:
        if d[i] == 0:
            continue
        for j in reversed(range(1,32)):
            t = pow(2, j) - i
            if t == i:
                if d[t] > 1:
                    d[t] -= 2
                    r += 1
            elif t in d and d[t] > 0:
                d[t] -= 1
                d[i] -= 1
                r += 1
    return r
print(main())


Measured memory_bytes: 108628
def my_count(string, substring):
    string_size = len(string)
    substring_size = len(substring)
    count = 0
    for i in range(0,string_size-substring_size+1):
        if string[i:i+substring_size] == substring:
            count+=1
    return count
N = input()
S = input()
print(my_count(str(S), 'ABC'))

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

typedef long long ll;
typedef pair<int, int> pii;
#define FOR(i, n) for(int i=0; i<n; i++)
#define FOR1(i, n) for(int i=1; i<=n; i++)
#define FORI(i, n) for(int i=n-1; i>=0; i--)
template<class T, class U> void umin(T& x, const U& y){ x = min(x, (T)y);}
template<class T, class U> void umax(T& x, const U& y){ x = max(x, (T)y);}
template<class T, class U> void init(vector<T> &v, U x, size_t n) { v=vector<T>(n, (T)x); }
template<class T, class U, typename... W> void init(vector<T> &v, U x, size_t n, W... m) { v=vector<T>(n);  for(auto& a : v) init(a, x, m...); }

int main(int argc, char** argv) {
    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0); cout << setprecision(15);
    if (argc == 2 && atoi(argv[1]) == 123456789) freopen("d:\\code\\cpp\\contests\\stdin", "r", stdin);

    int T = 1;
//    cin >> T;
    FOR1(tt, T){
        ll x, k, d;
        cin >> x >> k >> d;

        ll q = abs(x) / d;
        ll x2;
        if (q > k){
            if (x > 0)
                x2 = x - k*d;
            else
                x2 = x + k*d;
        }
        else{
            if (x > 0)
                x2 = x - q*d;
            else
                x2 = x + q*d;
            ll rem = k-q;
            if (rem%2 == 0){

            }
            else{
                if (x2 > 0)
                    x2 -= d;
                else
                    x2 += d;
            }
        }
        cout << abs(x2) << endl;
    }

    if (argc == 2 && atoi(argv[1]) == 123456789) cout << clock()*1.0/CLOCKS_PER_SEC << " sec\n";
    return 0;
}



Measured memory_bytes: 3644
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <iomanip>
#include <random>
#include <cstdio>
#include <cmath>
#include <map>
using namespace std;
typedef long long ll;
#define rep(i, n) for(int i = 0; i < (int) n; i++)

ll GCD (ll x, ll y) {
  if (y == 0) return x;
  return GCD(y, x%y);
}
ll LCM (ll x, ll y) {
    return x*y / GCD(x,y);
}

int main() {
    ll a,b;
    cin >> a >> b;
    cout << LCM(a,b) << 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);
		int[] a=new int[5];
		int an=0;
		int kk=9;
		for(int i = 0; i<5; i++){
			a[i]=sc.nextInt();
			if(a[i]%10!=0 && a[i]%10<=kk){
				kk=a[i]%10;
				an=a[i];
			}
		}
		int ans=0;
		int count=0;
		for(int i = 0; i<5; i++){
			if(a[i]==an && count==0){
				count++;
				continue;
			}
			if(ans%10!=0){
				ans+=10-ans%10;
				ans+=a[i];
			}else{
				ans+=a[i];
			}
		}
		if(ans%10!=0){
				ans+=10-ans%10;
				ans+=an;
		}else{
				ans+=an;
		}
		System.out.println(ans);
	}
}


Measured memory_bytes: 21844
#include <bits/stdc++.h>
#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 FORR(i, m, n) for (int i = (m); i >= (n); --i)
#define equals(a, b) (fabs((a) - (b)) < EPS)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
const ll mod = 1000000007;
//const ll mod = 998244353;
const int inf = 1e9 + 10;
const ll INF = 1e18;
const ld EPS = 1e-10;
const int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
const int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }



int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout << fixed << setprecision(25);

  string t;
  cin >> t;

  rep(i, t.length()) cout << (t[i] == 'P' ? 'P' : 'D');
  cout << '\n';




  
  return 0;
}

Measured memory_bytes: 3788
q,w=(%w{+ - *}*3).combination(3),%w{$%$ %%($%%) %%(%%$) ($%%)%% (%%$)%%}.map{|s|s.gsub(?$,"(%%%)").gsub"%","%s"};until f=/0/=~s=gets;s.split.permutation.map{|a,b,c,d|q.map{|x,y,z|w.map{|e|10==eval(e%=[a,x,b,y,c,z,d])&&(puts f=e;break)};f&&break};f&&break};f||p(0)end

Measured memory_bytes: 6500
a = int(input())
b = int(input())
c = int(input())
x = int(input())
ans = 0
count = 0
for i in range(a + 1):
  for j in range(b + 1):
    for k in range(c + 1):
      ans = i * 500 + j * 100 + k * 50
      if ans == x:
        count += 1

print(count)

Measured memory_bytes: 3064
#include <stdio.h>

int main()
{
    int i, x, y, temp;
    for(i = 1; i < 3000; i++)
    {
        scanf("%d %d", &x, &y);
        if (x == 0 && y == 0)break;
        if (x > y)
        {
            temp=x;
            x=y;
            y=temp;
        }
        printf("%d %d\n", x, y);
    }
    return 0;
}



Measured memory_bytes: 2580
package main

import (
	"fmt"
)

type edge struct {
	tail   int
	weight int
}

func dfs(adj [][]edge, visited []bool, dist []int, color []int, v int) {
	for _, e := range adj[v] {
		if visited[e.tail] {
			continue
		}
		visited[e.tail] = true
		dist[e.tail] = dist[v] + e.weight
		if dist[e.tail]%2 == 1 {
			color[e.tail] = 1
		}
		dfs(adj, visited, dist, color, e.tail)
	}
}

func main() {
	var n int
	fmt.Scan(&n)

	adj := make([][]edge, n)
	visited := make([]bool, n)
	dist := make([]int, n)
	color := make([]int, n)
	for i := range adj {
		line := make([]edge, 0)
		adj[i] = line
	}

	for i := 0; i < n-1; i++ {
		var u, v, w int
		fmt.Scan(&u, &v, &w)
		adj[u-1] = append(adj[u-1], edge{v - 1, w})
		adj[v-1] = append(adj[v-1], edge{u - 1, w})
	}

	visited[0] = true
	dfs(adj, visited, dist, color, 0)

	for _, c := range color {
		fmt.Println(c)
	}
}


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

int main(){
    int N;
    cin >> N;
    vector<int> P(N);
    for (int i = 0; i < N; i++) cin >> P[i];
    int ans = 1;
    int m = P[0];
    for (int i = 1; i < N; i++) {
        if (m > P[i]) ans++;
        m = min(m, P[i]);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1024
def search(string,c):
    for i in range(c):
        #print(i,string[i],string[len(string)-1-i])
        if ((string[i])!=(string[len(string)-1-i])):
            return False
    return True
    
SUM=0
#対称の文字列の和を出力
while True:
    try:
        string=list(map(str,input()))
    except EOFError:
        break
    c=int(len(string)/2)
    if len(string)%2==1:                        #奇数の時
        del string[c]
    if search(string,c)==True:
        SUM+=1

print(SUM)
        
    



Measured memory_bytes: 5564
var GET = (function () {function f(s) {return new g(s);}function g(s) {this._s = s.trim().split("\n");}g.prototype.getValue = function (n) {return this._s[n];};g.prototype.getArray = function (n) {return this.stoa(this._s[n]);};g.prototype.slice = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stox(v));};g.prototype.sliceArray = function (s, limit) {return this._s.slice(s, +limit + s || undefined).map(v => this.stoa(v));};g.prototype.stoa = function (s) {return s.split(" ").map(v => this.stox(v));};g.prototype.stox = function (v) {var i = +v;return (i === i) ? i : v;};return f;})();
var o = GET(require("fs").readFileSync("/dev/stdin", "utf8"));

console.log(main());
function main(){
    var N = o.getValue(0);
    return Math.pow(N, 3)
}

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

namespace AtCorder
{
	public class Program
	{
		static void Main(string[] args)
		{
			Scanner cin = new Scanner();
			int n = cin.Int();
			int ans = 0;
			for (int i = 1; i <= n; i++) {
				if (i < 10) {
					++ans;
				} else if (i < 100) {
				} else if (i < 1000) {
					++ans;
				} else if (i < 10000) {
				} else if (i < 100000) {
					++ans;
				}
			}

			Console.WriteLine(ans);
		}
	}

	public class Scanner
	{
		private readonly char[] delimiter_ = new char[] { ' ' };
		private string[] buf_;
		private int index_;
		
		public Scanner()
		{
			buf_ = new string[0];
			index_ = 0;
		}

		public string Next()
		{
			if (index_ < buf_.Length) {
				return buf_[index_++];
			}

			string st = Console.ReadLine();
			while (st == "") {
				st = Console.ReadLine();
			}

			buf_ = st.Split(delimiter_, StringSplitOptions.RemoveEmptyEntries);
			if (buf_.Length == 0) {
				return Next();
			}

			index_ = 0;
			return buf_[index_++];
		}

		public int Int()
		{
			return int.Parse(Next());
		}
		public int[] ArrayInt(int N, int add = 0)
		{
			int[] Array = new int[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Int() + add;
			}
			return Array;
		}

		public long Long()
		{
			return long.Parse(Next());
		}

		public long[] ArrayLong(int N, long add = 0)
		{
			long[] Array = new long[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Long() + add;
			}
			return Array;
		}

		public double Double()
		{
			return double.Parse(Next());
		}

		public double[] ArrayDouble(int N, double add = 0)
		{
			double[] Array = new double[N];
			for (int i = 0; i < N; i++) {
				Array[i] = Double() + add;
			}
			return Array;
		}
	}
}


Measured memory_bytes: 11092
// In the name of God

#include <bits/stdc++.h>

using namespace std;

#define IOS ios_base::sync_with_stdio(false); cin.tie(NULL);
#define debug(x) cout << #x ": " << x << endl;

long long dp[(int)1e5+5][105];
long long w[105];
long long v[105];

int main() {
	IOS
	int n, W;
	cin >> n >> W;
	for(int i=0; i<n; i++) {
		cin >> w[i] >> v[i];
	}
	for(int i=0; i<=W; i++) {
		for(int j=0; j<=n; j++) {
			if(i==0||j==0) dp[i][j] = 0;
			else if(i<w[j-1]) dp[i][j] = dp[i][j-1];
			else dp[i][j] = max(dp[i][j-1], max(dp[i][j], dp[i-w[j-1]][j-1] + v[j-1]));
		}
	}
	cout << dp[W][n];
 	return 0;
}


Measured memory_bytes: 82304
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;

#define fi first
#define se second
#define m_p make_pair
#define p_b push_back
#define e_b emplace_back
#define all(x) (x).begin(),(x).end()
#define uniq(x) ((x).erase(unique(all(x)),(x).end()))
#define sz(x) ((int)(x).size())

#define REP(i,m,n) for(int i=(int)(m);i<(int)(n);i++)
#define rep(i,n) REP(i,0,n)

#ifdef LOCAL//compile with -DLOCAL
#define debug(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<(x)<<endl
#define debug_vec(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = ";\
  rep(i,sz(x)){cerr<<x[i]<<" ";}cerr<<endl
#define debug_mat(x) cerr<<"LINE"<<__LINE__<<" : "<<#x<<" = "<<endl;\
  rep(i,sz(x)){rep(j,sz(x[i])){cerr<<x[i][j]<<" ";}cerr<<endl;}cerr<<endl
#else
#define debug(x) void(0)
#define debug_vec(x) void(0)
#define debug_mat(x) void(0)
#endif

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


int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  int N;
  cin >> N;
  vector<int> A(N);
  rep(i,N)  cin >> A.at(i);

  vector<int> gcdl(N);
  vector<int> gcdr(N);
  gcdl.at(0)=0;
  REP(i,1,N)  gcdl.at(i)=gcd(gcdl.at(i-1),A.at(i-1));
  gcdr.at(N-1)=0;
  for(int i=N-2;i>=0;i--) gcdr.at(i)=gcd(gcdr.at(i+1),A.at(i+1));

  int ans=0;
  rep(i,N)  chmax(ans,gcd(gcdl.at(i),gcdr.at(i)));
  cout << ans << endl;


  return 0;
}

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

ans = ''

# 10は適当
for i in range(1000):
  if n % pow(2, i+1) == 0: # 割れたら 0になる
    ans += '0'
  else: # 割れなかった時
    ans += '1'
    n = n - pow(-2, i)
  if n == 0:
    break
print(ans[::-1])

Measured memory_bytes: 2940
import collections
N = int(input())
k = []
for i in range(N):
  k.append(input())
c = collections.Counter(k)
l = list(c.most_common())
P = l[0][1]
a = []
for i in range(len(l)):
  if l[i][1] == P:
    a.append(l[i][0])
  else:
    break
a.sort()
for j in range(len(a)):
  print(a[j])

Measured memory_bytes: 47772
import java.util.*;
import static java.lang.Integer.*;
import static java.lang.Long.*;
import static java.lang.Math.*;
import static java.lang.System.*;

public class Main {
	public static void main(String[] args) {
		int i,j;
		Scanner sc = new Scanner(in);
		int x = parseInt(sc.next());
		int t = parseInt(sc.next());
		sc.close();
		int an = x-t;
		out.println(an<0?0:an);
	}
}


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

using namespace std;

#define all(x) x.begin(), x.end()
#define sz(x) (int) x.size()
#define pb push_back
#define endl '\n'
#define snd second
#define fst first
#define fastio cin.tie(NULL),cout.sync_with_stdio(true)

typedef long long int ll;
typedef unsigned long long int ull;
typedef vector <int> vi;
typedef pair <ll,ll> ii;

const int mod = 1e9 + 7;
const ll INF = (1LL<<50);
const int N = 1000005;
int main(){
	fastio;
	int n;
	cin >> n;
	vi v1(n), v2(n);
	for(int i = 0; i < n; i++)
		cin >> v1[i];
	for(int i = 0; i < n; i++)
		cin >> v2[i];
	sort(v2.rbegin(), v2.rend());
	int idx = 0, ans = 1;
	for(int i = 0; i < n; i++){
		if(v1[i] == v2[i]){
			while(idx < n and (v2[idx]==v1[i] or v2[i] == v1[idx])){
				idx++;
			}
			if(idx < n){
				swap(v2[idx], v2[i]);
			}
		}
		if(v1[i] == v2[i])ans = 0;
	}
	if(!ans)cout << "No\n";
	else{
		cout << "Yes\n";
		for(auto i:v2){
			cout << i << " ";
		}cout << endl;
	}
	return 0;
}


Measured memory_bytes: 4752
import java.util.Scanner;

//Triangle and Circle
public class Main {

	public static class Point {
		public double x;
		public double y;
		public Point(double x_, double y_) {
			x = x_; y=y_;
		}
	}
	public static class Line {
		public Point s,t;
		public Line(Point s_, Point t_) {
			s = s_; t = t_;
		}
	}
	public static double distanceSP(Line s, Point p) {
		Point r = proj(s, p);
		if (intersectSP(s, r)) return norm(sub(r, p));
		return Math.min(norm(sub(s.s, p)), norm(sub(s.t, p)));
	}
	public static boolean intersectSP(Line s, Point p) {
		return ccw(s.s, s.t, p) == 0;
	}
	public static int ccw(Point a, Point b, Point c) {
		Point p = sub(b, a);
		Point q = sub(c, a);
		if(extp(p, q) > EPS) return 1;		// counter clockwise
		if(extp(p, q) < -EPS)return -1;		// clockwise
		if(inp(p, q) < -EPS) return 2;		// c--a--b on line
		if(Math.abs(norm(p) - norm(q)) < EPS) return -2;	// a--b--c on line
		return 0;				// a--c--b(or a--c=b) on line 
	}
	public static Point sub(Point p1, Point p2) {
		return new Point(p1.x-p2.x, p1.y-p2.y);
	}
	public static Point proj(Line l, Point p) {
		double t = inp(sub(p, l.s), sub(l.s, l.t)) / Math.pow(norm(sub(l.s, l.t)),2);
		Point tp = sub(l.s, l.t);
		return new Point(l.s.x + t*tp.x, l.s.y + t*tp.y);
	}
	public static double inp(Point p1, Point p2) {
		return p1.x*p2.x + p1.y*p2.y;
	}
	public static double extp(Point p1, Point p2) {
		return p1.x*p2.y - p2.x*p1.y;
	}
	public static final double EPS = 1.0e-8;
	public static double norm(Point p) {
		return Math.hypot(p.x, p.y);
	}
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		while(true){
			Point pp = new Point(sc.nextDouble(), sc.nextDouble());
			if(pp.x==0&&pp.y==0)break;
			Point[] p = new Point[3];
			p[0]=pp;
			for(int i=1;i<3;i++)p[i]=new Point(sc.nextDouble(),sc.nextDouble());
			Point c = new Point(sc.nextDouble(),sc.nextDouble());
			double r = sc.nextDouble();
			boolean isB = true;
			for(int i=0;i<3;i++){
				if(!(Math.pow(c.x-p[i].x, 2)+Math.pow(c.y-p[i].y, 2)<=r*r))isB = false;
			}
			if(isB){
				System.out.println("b");continue;
			}
			boolean left = true;
			boolean right = true;
			double min = Integer.MAX_VALUE;
			double max = 0;
			for(int i=0;i<3;i++){
				double ex = extp(sub(p[(i+1)%3], p[i]), sub(c, p[i]));
				if(ex < 0)left = false;
				else if(ex > 0)right = false;
				Line l = new Line(p[i], p[(i+1)%3]);
				//???????????????????????????????????¨???????????? AOJ0129?????§
				Line m = new Line(p[(i+1)%3], p[i]);
				double d = Math.max(distanceSP(l, c), distanceSP(m, c));
				min = Math.min(min, d);
				max = Math.max(max, d);
			}
			boolean in = left|right;
			if(in && min >= r)System.out.println("a");
			else if(!in && min > r)System.out.println("d");
			else System.out.println("c");
		}
	}
}

Measured memory_bytes: 35512
tr=int(input())

a=0
w=0
t=0
r=0

for i in range(tr):
   
    word=input()
    if word=='AC':
        a+=1
    elif word=='WA':
        w+=1
    elif word=='TLE':
        t+=1
    else:
        r+=1
print('AC x '+str(a))
print('WA x '+str(w))
print('TLE x '+str(t))
print('RE x '+str(r))


Measured memory_bytes: 9156
import java.util.Scanner;
import java.lang.Math;

public class Main {
  public static void main(String[] args)
  {
    Scanner scan = new Scanner(System.in);
    int n;
    n = scan.nextInt();
    int a[] = new int[n];
    for (int i = 0; i < n; i++) a[i] = scan.nextInt();
    for (int i = n-1; i > 0; i--) System.out.print(a[i] + " ");
    System.out.println(a[0]);
    scan.close();
  }
}



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

int main(){
    int A1, A2, A3;
    
    cin >> A1 >> A2 >> A3;
    
    if(A1+A2+A3 > 21){
        cout<<"bust"<<endl;
    }
    else{
        cout<<"win"<<endl;
    }

    return 0;
}

Measured memory_bytes: 256
# -*- coding: utf-8 -*-

import sys

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def list4d(a, b, c, d, e): return [[[[e] * d for j in range(c)] for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(N=None): return list(MAP()) if N is None else [INT() for i in range(N)]
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

N, _, W = MAP()
A = [W] + LIST()

# memo[i][j] := 現在iターンで、山札からj枚目まで取った状態
memo = list2d(2, N+1, None)
def rec(turn, cnt):
    if memo[turn][cnt] is not None:
        return memo[turn][cnt]
    # 先手番
    if turn % 2 == 0:
        res = -INF
        for nxt in range(cnt+1, N):
            res = max(res, rec(1-turn, nxt))
        # 最後まで取る時は、結果を取得
        res = max(res, abs(A[N]-A[cnt]))
    # 後手番
    else:
        res = INF
        for nxt in range(cnt+1, N):
            res = min(res, rec(1-turn, nxt))
        res = min(res, abs(A[cnt]-A[N]))
    memo[turn][cnt] = res
    return res

ans = rec(0, 0)
print(ans)


Measured memory_bytes: 46556
#include<iostream>
using namespace std;
int main() {
	int i, N, A, B, sum = 0, x;

	cin >> N >> A >> B;

	for (i = 1; i <= N; ++i) {
		x = i / 10000 % 10 + i / 1000 % 10 + i / 100 % 10 + i / 10 % 10 + i % 10;
		if ( x>= A && x <= B) {
			sum += i;
		}
	}

	cout << sum << endl;

	return 0;
}

Measured memory_bytes: 256
/**
*    created: 24.06.2020 14:04:35
**/
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define int long long
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define pcnt(bit) __builtin_popcount(bit)
#define mod 1000000007
#define pi acos(-1.0)
using namespace std;

signed main() {

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

    string s, t;
    cin >> s >> t;
    
    map<int,int> mp;
    rep(i,s.size()) {
        int s1 = s[i] - 'a' + 1;
        int t1 = t[i] - 'a' + 1;
        if (mp[s1] == 0) mp[s1] = t1;
        else if (mp[s1] == t1) continue;
        else if (mp[s1] != t1) {
            cout << "No" << endl;
            return 0;
        }
    }
    map<int,int> mp1;
    for (auto p : mp) {
        if (mp1[p.second] == 0)  mp1[p.second] = p.first;
        else if (mp1[p.second] == p.first) continue;
        else if (mp1[p.second] != p.first) {
            cout << "No" << endl;
            return 0;
        }   
    }
    cout << "Yes" << endl;
    return 0;
}

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

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

#define ALL(a)  begin((a)),end((a))
#define RALL(a) (a).rbegin(), (a).rend()
#define PB push_back
#define EB emplace_back
#define MP make_pair
#define SZ(a) int((a).size())
#define SORT(c) sort(ALL((c)))
#define RSORT(c) sort(RALL((c)))
#define UNIQ(c) (c).erase(unique(ALL((c))), end((c)))

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)

#define FF first
#define SS second
template<class S, class T>
istream& operator>>(istream& is, pair<S,T>& p){
  return is >> p.FF >> p.SS;
}
template<class S, class T>
ostream& operator<<(ostream& os, const pair<S,T>& p){
  return os << p.FF << " " << p.SS;
}
template<class T>
void maxi(T& x, T y){
  if(x < y) x = y;
}
template<class T>
void mini(T& x, T y){
  if(x > y) x = y;
}


const double EPS = 1e-10;
const double PI  = acos(-1.0);
const LL MOD = 1e9+7;
const int INF = 1e9;

int N, M, Q;
void bfs(int u, VI& dis, VVI& G){
  queue<int> q;
  q.push(u);
  dis[u] = 0;

  while(!q.empty()){
	u = q.front();
	q.pop();
	for(int to: G[u]){
	  if(dis[to] == INF){
		dis[to] = dis[u] + 1;
		q.push(to);
	  }
	}
  }
}

void bfs2(int v, int p, int& cnt, VI& iter, VI& best, VVI& G){
  if(best[v] != best[p] + 1) return;

  queue<int> q;
  q.push(v);
  iter[v] = iter[p] + 1;
  ++cnt;

  while(!q.empty()){
	v = q.front();
	q.pop();

	for(int to: G[v]){
	  if(iter[to] == best[to])
		continue;
	  if(iter[v] + 1 != best[to])
		continue;
	  iter[to] = best[to];
	  ++cnt;
	  q.push(to);
	}
  }
}

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

  cin >> N >> M >> Q;
  vector<PII> es(M);
  VVI G(N);
  REP(i,M){
	int u, v;
	cin >> u >> v;
	--u;
	--v;
	es[i] = MP(u, v);
	G[u].EB(v);
	G[v].EB(u);
  }

  VI qs(Q);
  vector<bool> del(M);
  REP(i,Q){
	cin >> qs[i];
	--qs[i];
	del[qs[i]] = true;
  }

  VI best(N, INF);
  bfs(0, best, G);

  VVI GG(N);
  REP(i,M){
	if(!del[i]){
	  PII& e = es[i];
	  GG[e.FF].EB(e.SS);
	  GG[e.SS].EB(e.FF);
	}
  }

  VI iter(N, INF);
  bfs(0, iter, GG);
  
  VI ans(Q);
  REP(i,N)
	if(iter[i] == best[i])
	  ++ans[Q-1];
  
  for(int i=Q-1;i>0;--i){
	int u = es[qs[i]].FF;
	int v = es[qs[i]].SS;
	GG[u].EB(v);
	GG[v].EB(u);

	bool best_u = best[u] == iter[u];
	bool best_v = best[v] == iter[v];

	ans[i-1] = ans[i];
	if(best_u != best_v){
	  if(best_u)
		bfs2(v, u, ans[i-1], iter, best, GG);
	  else
		bfs2(u, v, ans[i-1], iter, best, GG);
	}
  }

  REP(i,Q) cout << N-ans[i] << endl;

  return 0;
}

Measured memory_bytes: 19464
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, e) for (int i = s; i < e; ++i)
#define sort_(a) stable_sort(a.begin(), a.end())
#define rsort(a) stable_sort(a.rbegin(), a.rend())
#define sum(a) accumulate(a.begin(), a.end(), 0LL)
#define join(a, d) accumulate(a.begin() + 1, a.end(), a[0], [](string s, string t) {return s + d + t;})
#define all(a) a.begin(), a.end()
#define degrees(a) a * 180.0 / M_PI;
#define radians(a) a * M_PI / 180.0;
// #define __lcm(a, b) std::__detail::__lcm(a, b)
typedef long long ll;
const long mod = 1e9 + 7;

int main(void) {
#ifdef DEBUG
  freopen("input.txt", "r", stdin);
#endif

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

  string S;
  cin >> S;
  map<char, int> direc{{'N', 0}, {'W', 0}, {'S', 0}, {'E', 0}};
  for (auto s : S) {
    direc[s] = 1;
  }
  string ans = "Yes";
  if (direc['N'] != direc['S']) {
    ans = "No";
  } else if (direc['W'] != direc['E']) {
    ans = "No";
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3608
#include <iostream>
using namespace std;
int main() {
    int n, b;
    char a;
    cin >> n;
    int card[4][14];
    for (int i = 0; i < 4; i++){
        for (int j = 1; j < 14; j++){
            card[i][j] = 0;
        }
    }
    for(int i = 0; i < n; i++){
        cin >> a >> b;
        if (a == 'S')card[0][b] = 1;
        else if (a == 'H') card[1][b] = 1;
        else if (a == 'C') card[2][b] = 1;
        else card[3][b] = 1;
    }
    
    for (int i = 0; i < 4; i++){
        for (int j = 1; j < 14; j++){
            char d;
            if (card[i][j]) continue;
            if (i == 0) d = 'S';
            else if(i == 1) d = 'H';
            else if(i == 2) d = 'C';
            else d = 'D';
            cout << d << ' ' << j << endl;
        }
    }
    
    return 0;
}



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

int main(){
  int D;
  cin>>D;
  int C[26];
  map<int,int>mp;
  for(int i=0;i<26;i++){
    cin>>C[i];
    if(C[i]>26){
      mp[i]++;
    }   
  }
  
  //cout<<mp[0]<<" "<<mp[1]<<endl;
  
  
  int flag=1;
  int temp=0;
  while(temp<365){
    if(mp[temp%26]==1){
      cout<<temp%26+1<<endl;
    }
    else{
      if(flag){
        cout<<temp%26+1<<endl;
        flag=0;
      }
      else{
        cout<<(temp+3)%26+1<<endl;
        flag=1;
      }
    }
    temp++;
  }
  
  return 0;
}



Measured memory_bytes: 3624
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi = vector<int>;
using vvi = vector<vector<int>>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;
#define all(x) x.begin(),x.end()
#define rep(i,j,n) for (long long i = j; i < (long long)(n); i++)
#define _GLIBCXX_DEBUG
const ll MOD = 1000000007;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//(a+b-1)/b
//priority_queue<ll, vector<ll>, greater<ll>> q;

template<int MOD> struct Fp {  
    long long val;
    constexpr Fp(long long v = 0) noexcept : val(v % MOD) {
        if (val < 0) val += MOD;
    }
    constexpr int getmod() { return MOD; }
    constexpr Fp operator - () const noexcept {
        return val ? MOD - val : 0;
    }
    constexpr Fp operator + (const Fp& r) const noexcept { return Fp(*this) += r; }
    constexpr Fp operator - (const Fp& r) const noexcept { return Fp(*this) -= r; }
    constexpr Fp operator * (const Fp& r) const noexcept { return Fp(*this) *= r; }
    constexpr Fp operator / (const Fp& r) const noexcept { return Fp(*this) /= r; }
    constexpr Fp& operator += (const Fp& r) noexcept {
        val += r.val;
        if (val >= MOD) val -= MOD;
        return *this;
    }
    constexpr Fp& operator -= (const Fp& r) noexcept {
        val -= r.val;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr Fp& operator *= (const Fp& r) noexcept {
        val = val * r.val % MOD;
        return *this;
    }
    constexpr Fp& operator /= (const Fp& r) noexcept {
        long long a = r.val, b = MOD, u = 1, v = 0;
        while (b) {
            long long t = a / b;
            a -= t * b; swap(a, b);
            u -= t * v; swap(u, v);
        }
        val = val * u % MOD;
        if (val < 0) val += MOD;
        return *this;
    }
    constexpr bool operator == (const Fp& r) const noexcept {
        return this->val == r.val;
    }
    constexpr bool operator != (const Fp& r) const noexcept {
        return this->val != r.val;
    }
    friend constexpr ostream& operator << (ostream &os, const Fp<MOD>& x) noexcept {
        return os << x.val;
    }
    friend constexpr Fp<MOD> modpow(const Fp<MOD> &a, long long n) noexcept {
        if (n == 0) return 1;
        auto t = modpow(a, n / 2);
        t = t * t;
        if (n & 1) t = t * a;
        return t;
    }
};
using mint = Fp<MOD>;

mint Combination(ll n, ll k){
    k = min(k , n-k);
    mint ret = 1;
    mint div = 1;
    for(int i = 0; i < k; i++){
        ret *= (n - i);
        div *= (k - i);
    }
    ret /= div;
    return ret;
}

signed main(){
	//cout << fixed << setprecision(10);
	ll n,b; cin >> n >> b;
    ll r = n - b;
    for(int i = 1; i <= b; i++){
        if(i > r + 1){
            cout << 0 << endl;
            continue;
        }
        mint ans = Combination(r + 1 , i);
        ans *= Combination(b- 1, i - 1);
        cout << ans << endl;
    }

	return 0;
}

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

typedef long long int ll;

int main()
{
    ll a, b, c, d;
    cin >> a >> b >> c >> d;

    ll ans = a * c;
    ans = max(ans, a * d);
    ans = max(ans, b * c);
    ans = max(ans, b * d);

    cout << ans;


    return 0;
}

Measured memory_bytes: 3628
#include "bits/stdc++.h"
using namespace std;
#define ll long long int
#define rep(i,n) for( int i = 0; i < n; i++ )
#define rrep(i,n) for( int i = n; i >= 0; i-- )
#define REP(i,s,t) for( int i = s; i <= t; i++ )
#define RREP(i,s,t) for( int i = s; i >= t; i-- )
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define INF 2000000000
#define mod 1000000007
#define INF2 1000000000000000000


int main(void)
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    int N, K;
    cin >> N >> K;
    int p[200010];
    rep(i, N) cin >> p[i];
    int sum = 0;
    int cnt = 0;
    int ans = 0;
    rep(i, N) {
        sum += p[i] + 1;
        cnt++;
        if(cnt >= K) {
            ans = max(ans, sum);
            sum -= p[i - K + 1] + 1;
        }
    }
    cout << fixed << setprecision(12) << ans / 2.0 << endl;

    return 0;
}


Measured memory_bytes: 1024
#include <iostream>
#include <cmath>

using namespace std;

long long a(long long n){
  return 2 * pow(2, n) - 1;
}

long long b(long long n){
  return 4 * pow(2, n) - 3;
}

long long L(long long X, long long n) {

  //cout << n << " " << X << endl;

  if (X < 1) return 0;
  if (n == 0) return 1;
  long long nb = b(n);

  // B1 L1(n - 1) P L2(n - 1) B2

  // B2以上
  if (nb <= X) return a(n);

  // L2以上
  if (nb / 2 + 1 < X) return a(n - 1) + 1 + L(X - (nb / 2 + 1), n - 1);

  // P
  if (nb / 2 + 1 == X) return a(n - 1) + 1;

  // L1以上
  if (1 < X) return L(X - 1, n - 1);

  // B1
  if (1 == X) return 0;
}

int main(void) {
  long long n, X;
  cin >> n >> X;
  cout << L(X, n) << endl;

  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
const int MAX_N = 100100;
const long long MOD = 1000000007;

int main() {
    int n, m;
    cin >> n >> m;
    vector<long long> dp(MAX_N, 0);
    vector<bool> step(MAX_N, true);

    for (int i = 0; i < m; i++) {
        int a;
        cin >> a;
        step.at(a) = false;
    }

    dp.at(0) = 1;
    if (step.at(1) == true) {
        dp.at(1) = 1;
    }

    for (int i = 2; i <= n; i++) {
        if (step.at(i) == false) continue;
        dp.at(i) = dp.at(i-1) + dp.at(i-2);
        dp.at(i) %= MOD;
    }

    cout << dp.at(n) << endl;
    return 0;
}

Measured memory_bytes: 1152
#include <bits/stdc++.h>
#include <bits/stdc++.h>
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<=(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
#define ALL(x) (x).begin(),(x).end() 
#define SIZE(x) ((ll)(x).size())
#define MAX(x) *max_element(ALL(x))
#define MIN(x) *min_element(ALL(x))
#define INF 1000000000
using namespace std;
typedef long long ll;
using namespace std;
using namespace std;

int main() {
    float A, B, H, M;

    cin >> A >> B >> H >> M;

    double rad_H, rad_M;
    rad_H = 2.*M_PI*H/12. + 2.*M_PI*M/12/60.;
    rad_M = 2.*M_PI*M/60.;

    double AB = pow(A, 2.) + pow(B, 2.) - 2*A*B*cos(abs(rad_H- rad_M));
    cout << setprecision(12) << sqrt(AB) << endl;
}

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

int main() {
	long long A, B, C, X, Y;
	cin >> A >> B >> C >> X >> Y;

	long long a = A * X + B * Y;
	for (long long i=0; i<=max(X, Y) * 2ll; i+=2) {
		long long tmp = i * C + max(0ll, (X - i / 2ll)) * A + max(0ll, (Y - i / 2ll)) * B;
		if (tmp < a) {
			a = tmp;
		}
	}
	cout << a << endl;
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef vector<vector<int>> Matrix;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(), (x).end()
static const int INF = 2000000000;


int main(){
  ll x;
  cin >> x;
  ll t = 1;
  while ((t*(t+1))/2 < x) {
    t++;
  }
  cout << t << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<math.h>
typedef long long ll;
using namespace std;
int main(void) {
	ll n, k;
	cin >> n >> k;
	if (n == 1)cout << k << endl;
	else {
		ll ans = k;
		for (ll i = 1;i <= n - 1;i++)ans *= (k - 1);
		cout << ans << endl;
	}
	return 0;
}

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

int main(void){
    int a,b,c; cin >> a >> b >> c;
    vector<int> A;
    A.push_back(a); A.push_back(b); A.push_back(c);

    sort(A.begin(), A.end());
    cout << A[0]+A[1] << endl;
    return 0;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
#define MAXN 100005
#define INF 1000000000
#define MOD 1000000007
#define F first
#define S second
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
int n,m,t,a[MAXN];
vector<int> G[MAXN],rG[MAXN];
int d[MAXN],f[MAXN],p[MAXN],color[MAXN],dp[MAXN];
deque<int> order;
void dfs_visit(int v)
{
	d[v]=++t;
	color[v]=1;
	for(int i=0;i<(int)G[v].size();i++)
	{
		int to=G[v][i];
		if(color[to]==0)
		{
			p[to]=v;
			dfs_visit(to);
		}
	}
	color[v]=2;
	order.push_front(v);
	f[v]=++t;
}
void toposort()
{
	t=0;
	memset(color,0,sizeof(color));
	memset(p,-1,sizeof(p));
	for(int i=1;i<=n;i++)
		if(color[i]==0)
			dfs_visit(i);
}
int main()
{
    scanf("%d%d",&n,&m);
    for(int i=0;i<m;i++)
    {
        int u,v;
        scanf("%d%d",&u,&v);
        G[u].push_back(v);
        rG[v].push_back(u);
    }
    toposort();
    memset(dp,0,sizeof(dp));
    int ans=0;
    for(auto v:order)
    {
        for(auto to:rG[v]) dp[v]=max(dp[v],dp[to]+1);
        ans=max(ans,dp[v]);
    }
    printf("%d\n",ans);
    return 0;

}



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

#define FOR(i, j, k) for(int i = j; i < k; i++)
#define REP(i, j) FOR(i, 0, j)
#define fst first
#define snd second
#define pb push_back
#define eb emplace_back
#define all(obj) (obj).begin(), (obj).end()
#define rall(obj) (obj).rbegin(), (obj).rend()
typedef long long int ll;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef vector<vi> vvi;

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 T> istream &operator>>(istream &is, vector<T> &vec) {
    for(T &x : vec)
        is >> x;
    return is;
}

int main() {

    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.precision(10);
    cout << fixed;

    int q;
    cin >> q;

    priority_queue<ll> lpq;
    priority_queue<ll, vector<ll>, greater<ll>> rpq;

    ll ans_a = 0, ans_b = 0;
    lpq.push(-(1LL << 50LL));
    rpq.push((1LL << 50LL));

    REP(i, q) {
        ll x, a, b;
        cin >> x;
        if(x == 1) {
            cin >> a >> b;
            ans_b += b;

            int n = lpq.size() + rpq.size();
            if(lpq.size() == rpq.size()) {
                if(a < lpq.top() or rpq.top() < a) {
                    ans_a += min(abs(lpq.top() - a), abs(rpq.top() - a));
                }
            } else {
                ans_a += abs(lpq.top() - a);
            }

            if(rpq.top() <= a) {
                rpq.push(a);
            } else {
                lpq.push(a);
            }

            if(rpq.size() > lpq.size()) {
                lpq.push(rpq.top());
                rpq.pop();
            } else if(lpq.size() - rpq.size() > 1) {
                rpq.push(lpq.top());
                lpq.pop();
            }
        } else {
            // cout << ans_a + ans_b << " : " << ans_a << " " << ans_b << endl;
            cout << lpq.top() << " " << ans_a + ans_b << endl;
        }
    }

    return 0;
}


Measured memory_bytes: 3828
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();
        int x = sc.nextInt();
        int y = sc.nextInt();
        int rx = x, ry = y;
        long ans = 0L;
        if(a+b > c*2){
            rx -= Math.min(x, y);
            ry -= Math.min(x, y);
            ans += c * Math.min(x, y) * 2;
        }
        if(0 < rx){
            if(a < c*2) ans += a * rx;
            else ans += c * 2 * rx;
        }
        if(0 < ry){
            if(b < c*2) ans += b * ry;
            else ans += c * 2 * ry;
        }

        System.out.println(ans);
        sc.close();

    }

}


Measured memory_bytes: 22612
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;

  string im[h];

  for(int j = 0; j < w + 2; j++) cout << '#';
  cout << endl;
  
  for(int i = 0; i < h; i++){
    cin >> im[i];
    cout << '#' << im[i] << '#' << endl;
  }

  for(int j = 0; j < w + 2; j++) cout << '#';
  cout << endl;

}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>

using namespace std;

//vector string deque break continue
#define forn(i, s, f) for (int i = (int)s; i < (int)f; i++)
#define ll long long
#define ull unsigned long long
#define ld long double
#define pii pair <int, int>
#define fs first
#define sc second
#define pf push_front
#define pb push_back
#define pop_f pop_front
#define pop_b pop_back
#define eb emplace_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x).size()

template <typename T> istream& operator>>(istream& in, vector <T>& a) {for (auto& i : a) in >> i; return in;}
template <typename T> ostream& operator<<(ostream& out, vector <T>& a)  {for (auto& i : a) out << i << " "; return out;}
template <typename T, typename U> void chkmin(T& a, U b) {if (a > b) a = b;}
template <typename T, typename U> void chkmax(T& a, U b) {if (a < b) a = b;}

int main() {
    ios_base::sync_with_stdio(0), cin.tie(0);
    int n;
    cin >> n;
    vector <int> a(n);
    cin >> a;
    long long ans = 0;
    map <int, int> cnt;
    forn (i, 0, n) {
        ans += cnt[i - a[i]];
        cnt[a[i] + i]++;
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 21152
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools
from collections import deque

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

DR = [1, -1, 0, 0]
DC = [0, 0, 1, -1]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()
     
def main():
    n, k = LI()
    per = [False for i in range(n)]
    for i in range(k):
        d = I()
        a = LI_()
        for person in a:
            per[person] = True
    cnt = 0
    for i in range(n):
        if not per[i]:
            cnt += 1
    print(cnt)


main()



Measured memory_bytes: 10920
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for (int i=0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using ll = long long;
using VI = vector<int>;
using VVI = vector<vector<int>>;

int main(){
  int n,a,b,c;
  cin >> n >> a >> b >> c;
  VI l(n);
  rep(i,n) cin >> l[i];
  
  int p[n];
  rep(i,n) p[i] = i+1;
  
  int M = 1000000;
  do{
    VI sum(n);
    sum[0] = l[p[0]-1];
    rep(i,n-1){
      sum[i+1] = sum[i] + l[p[i+1] - 1];
    }
    
    rep2(i,1,n-1){
      rep2(j,i+1,n){
        rep2(k,j+1,n+1){
          int mp = (k-3)*10;
          mp += abs(a - sum[i-1]);
          mp += abs(b - (sum[j-1] - sum[i-1]));
          mp += abs(c - (sum[k-1] - sum[j-1]));
          
          if(mp < M) M = mp;
        }
      }
    }
  }while(next_permutation(p,p+n));
  
  cout << M;
  
  return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner scan=new Scanner(System.in);
		int a=scan.nextInt();
		String str[]=new String[a];
		for(int i=0;i!=a;i++) {
			str[i]=scan.next();
		}
		String ans="";
		int count=0;
		for(int i=0;i!=a;i++) {
			for(int j=0;j!=i;j++) {
				if(str[i].equals(str[j])) {
					count=1;
				}
			}
			if(i==a-1) {
				break;
			}
			if(str[i].charAt(str[i].length()-1)==str[i+1].charAt(0)) {
				
			}
			else {
				count=1;
			}
		}
		if(count==1) {
			System.out.println("No");
		}
		else {
			System.out.println("Yes");
		}
		}
}

Measured memory_bytes: 21844
#include<cstdio>
#include<algorithm>
#include<cctype>
using namespace std;
#define G getchar()
int read()
{
	int x=0; char ch=G;
	for (;!isdigit(ch);ch=G);
	for (;isdigit(ch);ch=G) x=(x<<3)+(x<<1)+(ch^48);
	return x;
}
#undef G
typedef long long ll;
const int Mod=1e9+7,inv2=Mod+1>>1;
int qpow(int x,int y=Mod-2){
	int res=1;
	for (;y;y>>=1,x=1LL*x*x%Mod)
		if (y&1) res=1LL*res*x%Mod;
	return res;
}

int n,a[200010],cnt[200010],ans;
int pos[200010],postot; int D[200010];
int tri1[200010],tri2[200010],tri3[200010];
void add(int x,int b,int c){
	for (;x<=n;x+=x&-x){
		tri1[x]++;
		tri2[x]=(tri2[x]+b)%Mod;
		tri3[x]=(tri3[x]+c)%Mod;
	}
}
int ask(int *tri,int x){
	int res=0;
	for (;x;x-=x&-x) res=(res+tri[x])%Mod;
	return res;
}
int main()
{
	n=read();
	for (int i=1;i<=n;i++) cnt[a[i]=read()]++;
	int sametot=0,tot=1;
	for (int i=n;i;i--){
		sametot=(sametot+1LL*cnt[i]*(cnt[i]-1)/2)%Mod;
		cnt[i]+=cnt[i+1];
		tot=1LL*tot*(cnt[i]-n+i)%Mod;
	}
	if (tot==0) return puts("0"),0;
	ans=1LL*sametot*tot%Mod*inv2%Mod;
	D[0]=1;
	for (int i=1;i<=n;i++){
		D[i]=D[i-1];
		if (cnt[i]-1-n+i) D[i]=1LL*D[i]*(cnt[i]-1-n+i)%Mod*qpow(cnt[i]-n+i)%Mod;
		else pos[++postot]=i;
	}
	for (int i=1;i<=n;i++){
		int l=(!postot||pos[1]>a[i]?1:pos[upper_bound(pos+1,pos+postot+1,a[i])-pos-1]),r=a[i]-1;
		if (l<=r) ans=(ans+1LL*tot*inv2%Mod*D[a[i]]%Mod*(ask(tri3,r)-ask(tri3,l-1)))%Mod;
		l=a[i]+1,r=(!postot||pos[postot]<=a[i]?n:pos[upper_bound(pos+1,pos+postot+1,a[i])-pos]-1);
		if (l<=r) ans=(ans-1LL*tot*inv2%Mod*qpow(D[a[i]])%Mod*(ask(tri2,r)-ask(tri2,l-1)))%Mod;
		add(a[i],D[a[i]],qpow(D[a[i]]));
		ans=(ans+1LL*tot*(i-ask(tri1,a[i])))%Mod;
	}
	printf("%d\n",(ans+Mod)%Mod);
	return 0;
}

Measured memory_bytes: 5632