akhauriyash/Code-Regression huggingface dataset:
import java.util.*;

public class Main {
	
	public static void main(String[] args)  {
		Scanner scan = new Scanner(System.in);
		double w=Double.parseDouble(scan.next());
		double h=Double.parseDouble(scan.next());
		double x=Double.parseDouble(scan.next());
		double y=Double.parseDouble(scan.next());
		
		System.out.print(w*h/2+" ");
		
		if (x*2==w&&y*2==h) {
			System.out.print(1);
		}else {
			System.out.print(0);
		}
}
}
//end

Measured memory_bytes: 22996
//接尾辞配列の作成
//sa[]は接尾辞の場所
#include <bits/stdc++.h>

using namespace std;

#ifdef DEBUG_MODE
	#define DBG(n) n;
#else
	#define DBG(n) ;
#endif
#define REP(i,n) for(ll (i) = (0);(i) < (n);++i)
#define PB push_back
#define MP make_pair
#define FI first
#define SE second
#define SHOW1d(v,n) {for(int W = 0;W < (n);W++)cerr << v[W] << ' ';cerr << endl << endl;}
#define SHOW2d(v,i,j) {for(int aaa = 0;aaa < i;aaa++){for(int bbb = 0;bbb < j;bbb++)cerr << v[aaa][bbb] << ' ';cerr << endl;}cerr << endl;}
#define ALL(v) v.begin(),v.end()
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000
#define MOD 1000000007

typedef long long ll;
typedef pair<ll,ll> P;
//配列、+１忘れすに。
struct SuffixArray {

	int n,k;
	string S;
	vector<int> rnk,tmp,sa,lcp;
	
	SuffixArray(string s){
		S = s;
		n = s.size();
		rnk.resize(n+1);
		tmp.resize(n+1);
		sa.resize(n+1);
		lcp.resize(n+1);
		construct_sa();
		construct_lcp();
	}
	
	//文字列sの接尾辞配列を構築
	void construct_sa(){
		
		//最初は一文字ランクは文字コードでいい
		for(int i = 0; i <= n;i++){
			sa[i] = i;
			rnk[i] = i < n ? S[i] : -1;
		}
		
		auto comp = [&](int &i, int &j){
			if(rnk[i] != rnk[j]){
				return rnk[i] < rnk[j];
			}
			else{
				int ri =( i + k <= n )? rnk[i + k] : -1;
				int rj =( j + k <= n )? rnk[j + k] : -1;
				return ri < rj;
			}
		};
		
		//k文字についてソートされているところから、2k文字でソートする
		for(k = 1;k <= n ; k *= 2){
			sort(sa.begin(), sa.end(), comp);
			
			//いったんtmpに入れてからrnkに移す
			tmp[sa[0]] = 0;
			for(int i = 1; i <= n; i++)	{
				tmp[sa[i]] = tmp[sa[i -1]] + (comp(sa[i - 1],sa[i]) ? 1 : 0);
			}
			for(int i = 0;i <= n;i++){
				rnk[i] = tmp[i];
			}
		}
	}

	bool contain(string t){
		int a = 0,b = S.length();
		while(b - a > 1){
			int c = (a + b) / 2;
			
			if(S.compare(sa[c],t.length(),t) < 0) a = c;
			else b = c;
		}
		
		return (S.compare(sa[b], t.length(),t) == 0);
	}

	void construct_lcp(){
		int n = S.length();
		for(int i = 0;i <= n;i++)rnk[sa[i]] = i;
		
		int h = 0;
		lcp[0] = 0;
		for(int i = 0;i < n;i++){
			//文字列中で位置iの接尾辞と、接尾辞配列中でそのひとつ前の接尾辞のLCPを求める。
			int j = sa[rnk[i] - 1];
			
			// hを先頭の分一個減らし、後ろが一致しているだけ増やす
			if(h > 0)h--;
			for(;j + h < n && i + h < n;h++){
				if(S[j + h] != S[i + h])break;
			}
			lcp[rnk[i] - 1] = h;
		}
	}
};

int main()
{
	string S;
	int N;
	
	cin >> S; 
	cin >> N;
	SuffixArray sa(S);
		
	for(int i = 0 ;i < N;i++)
	{
		string T;
		cin >> T;
		if(sa.contain(T)) cout << 1 << endl;
		else cout << 0 << endl;
	}
	
	return 0;
}


Measured memory_bytes: 20616
# python template for atcoder1
import sys
sys.setrecursionlimit(10**9)
input = sys.stdin.readline

A, B = map(int, input().split())


def check(n):
    s = str(n)
    for c, cr in zip(s, reversed(s)):
        if c == cr:
            continue
        else:
            return False
    return True


ans = 0
for i in range(A, B+1):
    if check(i):
        ans += 1
print(ans)


Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define P pair<int,int>
#define fi first
#define se second
#define rep(i,n) for(int i=0;i<n;i++)
#define INF 1000000000
#define MOD 1000000007
#define pb push_back
#define all(v) v.begin(),v.end()
int dx[]={0,1,0,-1},dy[]={1,0,-1,0};
int kaijo[222222];
struct edge{int to,cost;};
int gcd(int a,int b){
	if(b==0)return a;
	return gcd(b,a%b);
}
int lcm(int a,int b){
	return a/gcd(a,b)*b;
}
bool prime(int a){
	if(a==1)return false;
	for(int i=2;i*i<=a;i++){
		if(a%i==0)return false;
	}
	return true;
}
bool kosa(double ax,double ay,double bx,double by,double cx,double cy,double dx,double dy){//線分の交差判定
	double ta=(cx-dx)*(ay-cy)+(cy-dy)*(cx-ax);
	double tb=(cx-dx)*(by-cy)+(cy-dy)*(cx-bx);
	double tc=(ax-bx)*(cy-ay)+(ay-by)*(ax-cx);
	double td=(ax-bx)*(dy-ay)+(ay-by)*(ax-dx);
	return tc*td<0&&ta*tb<0;
}
void init_fact(int n){
	kaijo[0]=1;
	for(int i=1;i<=n;i++){
		kaijo[i]=kaijo[i-1]*i;
		kaijo[i]%=MOD;
	}
}
int modpow(int a,int b){
	if(b==0)return 1;
	if(b%2)return modpow(a,b-1)*a%MOD;
	int memo=modpow(a,b/2);
	return memo*memo%MOD;
}
int comb(int a,int b){
	return kaijo[a]*modpow(kaijo[a-b],MOD-2)%MOD*modpow(kaijo[b],MOD-2)%MOD;
}
int g(int x){
	x=modpow(x,MOD-2);
	return x;
}
int n,a[55],mi=INF,ma=-INF,p,m,mii,mai;
signed main(){
	cin>>n;
	rep(i,n){
		cin>>a[i];
		if(mi>a[i]){
			mi=a[i];
			mii=i+1;
		}
		if(ma<a[i]){
			ma=a[i];
			mai=i+1;
		}
		if(a[i]>0)p++;
		if(a[i]<0)m++;
	}
	if(p&&m){
		cout<<2*n-1<<endl;
		if(abs(mi)<=abs(ma)){
			rep(i,n){
				a[i]+=ma;
				cout<<mai<<" "<<i+1<<endl;
			}
			for(int i=1;i<n;i++){
				cout<<i<<" "<<i+1<<endl;
				a[i]+=a[i-1];
			}
		}
		else{
			rep(i,n){
				a[i]+=mi;
				cout<<mii<<" "<<i+1<<endl;
			}
			for(int i=n-2;i>=0;i--){
				cout<<i+2<<" "<<i+1<<endl;
				a[i]+=a[i+1];
			}
		}
	}
	else{
		cout<<n-1<<endl;
		if(a[0]>0){
			for(int i=1;i<n;i++){
				a[i]+=a[i-1];
				cout<<i<<" "<<i+1<<endl;
			}
		}
		else{
			for(int i=n-2;i>=0;i--){
				a[i]+=a[i+1];
				cout<<i+2<<" "<<i+1<<endl;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
    int d;
    cin>>d;
    if(d==25)
    cout<<"Christmas"<<endl;
    if(d==24)
    cout<<"Christmas Eve"<<endl;
    if(d==23)
    cout<<"Christmas Eve Eve"<<endl;
    if(d==22)
    cout<<"Christmas Eve Eve Eve"<<endl;
}

Measured memory_bytes: 3636
import sys
from collections import defaultdict
from collections import deque
import numpy as np
import heapq
from heapq import heappush, heappop
import itertools


#read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines
sys.setrecursionlimit(10 ** 7)

N = int(input())
A = [[] for _ in range(N)]

for i in range(N):
    a = int(input())
    for j in range(a):
        x, y = map(int, input().split())
        A[i].append((x-1, y))

seq = (0, 1)

# print(A)

ans = 0
for pos in itertools.product(seq, repeat=N):
    # print(pos)
    isValid = True
    for i in range(N):
        if pos[i] == 0:
            continue

        for prop in A[i]:
            #print("i", i, prop)
            x, y = prop
            if pos[x] == y:
                continue
            else:
                isValid = False
                break

        if not isValid:
            break

    if isValid:
        a = sum(pos)
        if a > ans:
            ans = a


print(ans)


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

using namespace std; 
#define REP(i, n) for (int i = 0; i < (n); i++)

typedef long long ll;
int main(int argc, char const *argv[])
{
    cin.tie(0);
   	ios::sync_with_stdio(false);
    int N, X, Y; cin >> N >> X >> Y;
    vector<int> res(N,0);
    REP(i, N) {
        REP(j, N) {
            if (j <= i) continue; // i < jを保証
            int dis = min(abs(j-i), abs(i-(X-1)) + 1 + abs(j-(Y-1)));
            res[dis]++;
        }
    }
    for (int i = 1; i < N; i++) {
        cout << res[i] << endl;
    }
    return 0;
}


Measured memory_bytes: 256
n,m=map(int,input().split())

def fac(n):
  if n == 0:
    return 1
  else:
    return n * fac(n-1)

def binom(n,k):
  if n==0 or n==1:
    return 0
  else:
    return fac(n) // (fac(n-k) * fac(k))

print(binom(n,2) + binom(m,2))


Measured memory_bytes: 38384
#define _CRT_SECURE_NO_WARNINGS
//#include <algorithm>
//#include <cstdio>
//#include <vector>
#include <bits/stdc++.h>
using namespace std;
static const int MAX = 500000;
static const int NIL = -1;

class Node {
public:
	int location;
	int p, l, r;
};

class Point {
public:
	int id, x, y;
	Point() {}
	Point(int id, int x, int y) :id(id), x(x), y(y) {}
	bool operator < (const Point &p) {
		return id < p.id;
	}
	void print() {
		printf("%d\n", id);
	}
};

Point P[MAX];
int N;
Node T[MAX];
int np;

inline bool lessX(const Point &p1, const Point &p2) { return p1.x < p2.x; }
inline bool lessY(const Point &p1, const Point &p2) { return p1.y < p2.y; }

int makeKDTree(int l, int r, int depth) {
	if (!(l < r)) return NIL;
	int mid = (l + r) / 2;
	int t = np++;

	if (depth % 2 == 0) {
		sort(P + l, P + r, lessX);
	}
	else {
		sort(P + l, P + r, lessY);
	}
	T[t].location = mid;
	T[t].l = makeKDTree(l, mid, depth + 1);
	T[t].r = makeKDTree(mid + 1, r, depth + 1);

	return t;
}

void find(int v, int sx, int tx, int sy, int ty, int depth, vector<Point> &ans) {
	int loc = T[v].location;
	int a = P[loc].x;
	int b = P[loc].y;

	if (sx <= a && a <= tx &&sy <= b && b <= ty) {
		ans.push_back(P[loc]);
	}
	if (depth % 2 == 0) {
		if (T[v].l != NIL && sx <= a) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		if (T[v].r != NIL && a <= tx) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
	}
	else {
		if (T[v].l != NIL && sy <= b) find(T[v].l, sx, tx, sy, ty, depth + 1, ans);
		if (T[v].r != NIL && b <= ty) find(T[v].r, sx, tx, sy, ty, depth + 1, ans);
	}
}

int main() {
	int n, x, y, sx, tx, sy, ty, q;
	scanf("%d", &n);
	for (int i = 0; i < n; i++) {
		scanf("%d%d", &x, &y);
		P[i] = Point(i, x, y);
	}
	np = 0;
	int root = makeKDTree(0, n, 0);
	vector<Point> ans;
	scanf("%d", &q);
	for (int i = 0; i < q; i++) {
		scanf("%d%d%d%d", &sx, &tx, &sy, &ty);
		ans.clear();
		find(root, sx, tx, sy, ty, 0, ans);
		sort(ans.begin(), ans.end());
		for (int j = 0; j < ans.size(); j++) {
			ans[j].print();
		}
		printf("\n");
		
	}
}

Measured memory_bytes: 16404
#include<bits/stdc++.h>
#define sc(x) scanf("%d",&x)
#define sc2(x,y) scanf("%d%d",&x,&y)
#define scs(x) scanf("%s",x)
#define pr(x) printf("%d",x)
#define prn(x) printf("%d\n",x)
#define memc(x,y) memcpy(&x,&y,sizeof(x))
#define mems(x,y) memset(x,y,sizeof(x))
#define fli() freopen("in.txt","r",stdin)
#define flo() freopen("out.txt","w",stdout)
#define rep(i,v) for(int i=0;i<v;i++)
#define repe(i,v) for(int i=0;i<=v;i++)
#define Rep(i,x,v) for(int i=x;i<v;i++)
#define Repe(i,x,v) for(int i=x;i<=v;i++)
#define repv(i,x) for(auto i=x.begin();i!=x.end();i++)
#define reprv(i,x) for(auto i=x.rbegin();i!=x.rend();i++)
#define dbg(x) cout << #x << " : " << x << endl
#define pb push_back
#define bl putchar('\n')
#define gcc getchar()
#define pcc putchar
#define si size
#define fi first
#define se second
#define MAX 300000
typedef long long ll;
typedef unsigned long long ull;
typedef std::vector<int> vi;
typedef std::pair<int,int> ii;
using namespace std;

long long int cm_sum[MAX] = {0};
long long int MM=1000000000+7;

int main(){
  // fli();
  string st;
  cin>>st;
  int len = st.length();
  long long int ans = 0;
  rep(i,len){
    ans+=(st[i]-'0');
  }
  cout<<((ans%9)?"No":"Yes")<<endl;
  return 0;
}


Measured memory_bytes: 3728
#include <stdio.h>
#include <string.h>

#define MAX_LENGTH 5000

char input0[MAX_LENGTH], input1[MAX_LENGTH];
int dp[MAX_LENGTH][MAX_LENGTH];

int max(int foo, int bar) {
  if (foo > bar) {
    return foo;
  } else {
    return bar;
  }
}

int lcs(int i, int j) {
  if (i == 0 || j == 0) {
    return 0;
  } else if (dp[i][j] >= 0) {
    return dp[i][j];
  } else if (input0[i - 1] == input1[j - 1]) {
    return dp[i][j] = lcs(i - 1, j - 1) + 1;
  } else {
    return dp[i][j] = max(lcs(i, j - 1), lcs(i - 1, j));
  }
}

int main(void) {
  int i, j, k, len0, len1, lenAns;
  char ans[MAX_LENGTH];

  /* 入力を行う */
  fgets(input0, MAX_LENGTH, stdin);
  len0 = strlen(input0);
  fgets(input1, MAX_LENGTH, stdin);
  len1 = strlen(input1);

  /* DPテーブルの初期化を行う */
  for (i = 0; i < MAX_LENGTH; i++) {
    ans[i] = '\0';
    for (j = 0; j < MAX_LENGTH; j++) {
      dp[i][j] = -1;
    }
  }

  /* DPの計算を行う */
  lenAns = lcs(len0, len1);

  i = len0;
  j = len1;
  k = lenAns;
  while (i > 0 && j > 0) {
    if (input0[i - 1] != input1[j - 1]) {
      if (dp[i - 1][j] > dp[i][j - 1]) {
          i--;
      } else {
          j--;
      }
    } else {
      ans[--k] = input0[i - 1];
      i--;
      j--;
    }
  }

  /* 解答を出力します */
  printf("%s\n", ans);
  return 0;
}


Measured memory_bytes: 98176
#include<bits/stdc++.h>
#define DEBUG(x) cout << #x << " = " << x << endl

using namespace std;

const int NMAX = 2e5;
int n, p[NMAX], x[NMAX];

int main() {
  ios::sync_with_stdio(0);
  /* freopen("input.txt", "r", stdin); */
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> p[i];
    if (p[i] == i) {
      x[i] = 1;
    }
  }

  int r = 0;
  int i = 1;
  int j = -1;
  while (i <= n) {
    if (x[i] == 1) {
      j = i;
      while (x[j]) j++;
      r += (j - i + 1) / 2;
      i = j + 1;
    } else {
      i++;
    }
  }

  cout << r;
}


Measured memory_bytes: 1024
N, K = map(int,input().split())
R,S,P = map(int,input().split())
T = input()
V = {'r':P, 's':R, 'p':S}
ans = 0


for i in range(K):
    check = T[i]
    ans += V[check]
    while True:
        i += K
        if i >= N:
            break
        if check == T[i]:
            check = '-1'
        else:
            ans += V[T[i]]
            check = T[i]
print(ans)


Measured memory_bytes: 3316
s = [1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51]
k = int(input())
print(s[k - 1])

Measured memory_bytes: 3060
import collections
n = int(input())
vlist = list(map(int,input().split()))
list_odd = [vlist[i] for i in  range(n) if i % 2 ==0]
list_even = [vlist[i] for i in range(n) if i % 2 !=0]

def f(list1):
  ary1 = [[0,i] for i in range(10**5+2)]
  len1 = len(list1)
  for i in range(len1):
    ary1[list1[i]+1][0] += 1
  ary2 = sorted(ary1)
  return [ary2[-1],ary2[-2]]

list3 = f(list_odd)
list4 = f(list_even)


if list3[0][1] != list4[0][1]:
  print(n-list3[0][0]-list4[0][0])
else:
  x1 = n-list3[0][0]-list4[1][0]
  x2 = n-list3[1][0]-list4[0][0]
  print(min(x1,x2))

Measured memory_bytes: 77164
#pragma GCC optimze("Ofast")
#include <bits/stdc++.h>
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define mod 1000000007
#define md 998244353
#define trace(...)
#define ll long long int
#define ld long double
#define fi first
#define se second
#define fr(i,a,b) for(ll i=a;i<=b;i++)
#define frr(i,b,a) for(ll i=b;i>=a;i--)
#define mem(a) memset(a, 0, sizeof(a))
#define vpi std::vector<pair<int,int>>
#define pii pair<int,int>
#define pb push_back
#define sall(v) sort(v.begin(),v.end())
#define all(v) (v.begin(),v.end())
#define minf -10000000
#define vi vector<int>
const ll infl=0x3f3f3f3f3f3f3f3fLL;
const int infi=0x3f3f3f3f;
typedef tree<pii, null_type, less<pii>, rb_tree_tag, tree_order_statistics_node_update> oset;
auto clk=clock();
mt19937_64 rang(chrono::high_resolution_clock::now().time_since_epoch().count());
int rng(int lim) {
    uniform_int_distribution<int> uid(0,lim-1);
    return uid(rang);
}
ll power(ll x, ll y,ll p) { 
    ll res = 1;      // Initialize result 
    x = x % p;  // Update x if it is more than or equal to p 
    while (y > 0) {  
        if (y & 1) // If y is odd, multiply x with result
            res = (res*x) % p;  
        y = y>>1; // y = y/2 // y must be even now
        x = (x*x) % p;   
    } 
    return res; 
}
ll power(ll x, ll y) { 
    ll res = 1;      // Initialize result 
    while (y > 0) {    
        if (y & 1)// If y is odd, multiply x with result 
            res = (res*x) ;  
        y = y>>1; // y = y/2 // y must be even now 
        x = (x*x);   
    } 
    return res; 
}
 
ll max3(ll a,ll b,ll c){
    return max(a,max(b,c));
}
ll min3(ll a,ll b,ll c){
    return min(a,min(b,c));
}
bool isPrime(ll n) { // Corner cases 
    if (n <= 1) 
        return false; 
    if (n <= 3) 
        return true; 
    if (n % 2 == 0 || n % 3 == 0) 
        return false; 
    for (ll i = 5; i * i <= n; i = i + 6) 
        if (n % i == 0 || n % (i + 2) == 0) 
            return false; 
    return true; 
}

void solve() {
    int n,m;cin>>n>>m;
    vector<pair<ll,ll>> v(n);
    fr(i,0,n-1){
        cin>>v[i].first>>v[i].second;
    }
    sall(v);
    ll cnt=0,ech,rem,ans=0;
    for(auto x:v){
        rem=m-cnt;
        if(rem==0)break;
        ech=x.second;
        ech=min(rem,ech);
        ans+=(ech*x.first);
        cnt+=ech;
    }
    cout<<ans<<endl;
    return ;
}

int main(){
    ios_base::sync_with_stdio(0),cin.tie(0),cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());
    cout<<fixed<<setprecision(8);
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    // freopen("output.txt", "w", stdout);
    #endif
    int t;
    // cin>>t;
    t=1;
    while(t--){
        solve();
    }
    #ifndef ONLINE_JUDGE
    cout<<endl<<endl<<endl<<endl<<"Time elapsed: "<<(double)(clock()-clk)/CLOCKS_PER_SEC<<endl;
    #endif
    return 0;
}

Measured memory_bytes: 4832
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = [0] * M
X = [0] * M
for i in range(M):
  P[i] , X[i] = map(int, input().split())
sum_T = sum(T)
for i in range(M):
  print(sum_T-T[P[i]-1]+X[i])

Measured memory_bytes: 3060
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>	
#include<map>
#include<set>
#include<utility>
#include<cmath>
#include<cstring>
#include<queue>
#include<cstdio>
#include<sstream>
#include<iomanip>
#define loop(i,a,b) for(int i=a;i<b;i++) 
#define rep(i,a) loop(i,0,a)
#define pb push_back
#define mp make_pair
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
using namespace std;
//kaewasuretyuui
typedef long long ll;
typedef pair<int,int> pii;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef pair<int,pii> pip;
typedef vector<pip>vip;
const double PI=acos(-1);
const double EPS=1e-8;
const int inf=1<<30;
class TOPO{//out is tsort's return.
	public:
	vvi G;
	vi out;
	vector<bool>V;
	vi indeg;
	int n;
	bool h;
	TOPO(int size){
		n=size;
		G=vvi(n);
		out=vi(0);
		V=vector<bool>(n);
		indeg=vi(n);
	}
	void add_edge(int s,int t){
		G[s].pb(t);
	}
	void bfs(int s){
		queue<int>q;
		q.push(s);
		V[s]=true;
		h=false;
		while(!q.empty()){
			if(q.size()-1)h=true;
			int u=q.front();q.pop();
			out.pb(u);
			rep(i,G[u].size()){
				int v=G[u][i];
				indeg[v]--;
				if(indeg[v]==0&&!V[v]){
					V[v]=true;
					q.push(v);
				}
			}
		}
	}
	void tsort(){
		rep(i,n)indeg[i]=0;
		rep(i,n)rep(j,G[i].size()){
			int v=G[i][j];
			indeg[v]++;
		}
		rep(i,n)if(indeg[i]==0&&!V[i])bfs(i);
//		rep(i,n)cout<<out[i]<<endl;
	}
};
int main(){
	int n,m;
	cin>>n>>m;
	TOPO tp(n);
	while(m--){
		int a,b;
		cin>>a>>b;
		a--;b--;
		tp.add_edge(a,b);
	}
	tp.tsort();
	rep(i,n)cout<<tp.out[i]+1<<endl;
	cout<<tp.h<<endl;
}

Measured memory_bytes: 2052
n,x = gets.chomp.split(" ").map(&:to_i)
m = Array.new(n)
n.times do |i|
    m[i] = gets.chomp.to_i
end
# とりあえず全種類作る。
x = x - m.inject(:+)
cnt = m.length
# 一番粉が少ないお菓子で可能な限り作る
min_m = m.min
puts cnt + x / min_m

Measured memory_bytes: 1788
#include <bits/stdc++.h>
#define ll long long int
#define MOD 1000000007
#define INF 1000000000000000000

using namespace std;

int main(void){
  string n;
  cin >> n;
  
  ll ans = 0;
  for (int i = 0; i < n.size(); i++){
    ans = (ans + (n[i] - '0')) % 9;
  }

  if (ans == 0)
    cout << "Yes" << endl;
  else
    cout << "No" << endl;
    

  return 0;
}


Measured memory_bytes: 3748
#include<iostream>
#include<cstdio>
#include<cmath>
#define N 50+5
using namespace std;
int n,m,a[N],b[N],c[N],d[N];
int main()
{
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++) scanf("%d%d",&a[i],&b[i]);
	for(int i=1;i<=m;i++) scanf("%d%d",&c[i],&d[i]);
	for(int i=1;i<=n;i++)
	{
		int minn=1e9,k;
		for(int j=1;j<=m;j++)
 		{
			int t = abs(c[j]-a[i])+abs(d[j]-b[i]);
			if(t < minn) minn = t,k = j;
		}
		printf("%d\n",k);
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
using ll = long long;

ll gcd (ll a ,ll b){
    ll c;
    while (a>0) {
        c=a;
        a=b%a;
        b=c;
    }
    return c;
}
int main(){
    ll b,c,d,e,k,n,o=1,p,q,x,y,z,max1=0,ans=1;
    string s,t,u;
    cin>>n;
    ll a[n],r[n],l[n];
    for (ll i=0; i<n; i++) {
        cin>>a[i];
    }
    l[0]=a[0];
    r[n-1]=a[n-1];
    for (ll i=1; i<n; i++) {
        l[i]=gcd(l[i-1],a[i]);
    }
    for (ll i=n-2; i>=0; i--) {
        r[i]=gcd(r[i+1],a[i]);
    }
    max1=r[1];
    for (ll i=1; i<n-1; i++) {
        max1=max(gcd(l[i-1],r[i+1]),max1);
    }
    max1=max(max1,l[n-2]);
    cout<<max1<<endl;
}


Measured memory_bytes: 2560
import java.util.*;

public class Main { // クラス名はMain
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);

		int w = sc.nextInt();

		int h = sc.nextInt();

		int x = sc.nextInt();

		int y = sc.nextInt();

		int r = sc.nextInt();

		int mainasux = x - r;
		int plasx = x + r;

		int mainasuy = y - r;
		int plasy = y + r;

		if (mainasux < 0 || plasx > w || mainasuy < 0 || plasy > h ) {
			System.out.println("No");
		} else if (mainasux >= 0 && plasx <= w) {

			if (mainasuy >= 0 && plasy <= w) {
				System.out.println("Yes");
			}

		}

	}

}


Measured memory_bytes: 26340
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(), (x).end()
typedef long long ll;
static const int INF (1<<30);
ll mod = 1e9+7;

int main() {
  int N; cin >> N;
  vector<int> A(N);
  rep(i, N) cin >> A[i];

  sort(all(A));


  if (N % 2 == 0) {

    rep(i, N/2) {
      int x = 2 * i + 1;
      if (A[2*i] != x || A[2*i+1] != x) {
        cout << 0 << endl;
        return 0;
      }
    }

  } else {

    rep(i, (N-1)/2) {
      int x = 2 * (i + 1);
      if (A[2*i+1] != x || A[2*i+2] != x) {
        cout << 0 << endl;
        return 0;
      }
    }

  }

  ll ans = 1LL;
  rep(i, N/2) {
    ans *= 2LL;
    ans %= mod;
  }

  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;

const ll LINF = 1e18;
const int INF = 1e9;
const ll MOD = 1000000007;

template<class T> inline bool chmin(T& a, T b){
    if(a > b){
        a = b;
        return true;
    }
    return false;
}
template<class T> inline bool chmax(T& a, T b){
    if(a < b){
        a = b;
        return true;
    }
    return false;
}
vector<bool> seen;
void dfs(const Graph &G, int v){
    seen[v] = true; // vを訪問済みにする
    
    for(auto next_v: G[v]){
        if(seen[next_v]) continue; // next_vが探索済みならスルー
        dfs(G, next_v); // 再帰的に探索
    }
}

int main(){

    char c[2];
    cin >> c[0];
    c[0]++;
    cout << c[0] << endl;
    return 0;
}

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

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

using namespace std;
 
typedef long long int ll;

const ll INF=(ll)1e18;

int N;

int main(){
    cin >> N;

    vector<int> a(N),b(N);

    REP(i,N) cin >> a[i];
    REP(i,N) cin >> b[i];

    int ans = 0;
    REP(k,30){
        int t = 1 << k;

        vector<int> aa(N),bb(N);

        REP(i,N) aa[i] = a[i] % (2*t);
        REP(i,N) bb[i] = b[i] % (2*t);

        sort(aa.begin(),aa.end());
        sort(bb.begin(),bb.end());

        ll s = 0;

        REP(i,N){
            s += lower_bound(bb.begin(), bb.end(), 4 * t - aa[i]) - lower_bound(bb.begin(), bb.end(), 3 * t - aa[i]);
            s += lower_bound(bb.begin(), bb.end(), 2 * t - aa[i]) - lower_bound(bb.begin(), bb.end(), 1 * t - aa[i]);
        }

        if(s % 2 == 1)ans += t;
    }
    cout << ans << endl;
}

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

using namespace std;
#define mx 200000
#define ll long long
int dp(int n,int st){

    if(st==105){
        if(n%st==0)return 1;
        else return 0;
    }


    for(int i=0;i*st<=n;i++){

      if(dp(n-i*st,st+1))return 1;
    }



    return 0;


}
int main()
{


    int n;
    cin>>n;


    cout<<dp(n,100)<<endl;

    return 0;
}



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

int main() {
  int a, b, c, t;

  cin >> a >> b >> c;

  if (a > b) { t = a; a = b; b = t; }
  if (b > c) { t = b; b = c; c = t; }
  if (a > b) { t = a; a = b; b = t; }

  cout << a << " " << b << " " << c << endl;
  
  return 0;
}
  

Measured memory_bytes: 1164
n=int(input())
a=[0]+[int(x) for x in input().split()]
b=[0]*(n+1)

for s in range(n,0,-1):
  i=s
  t=0
  while i<=n:
    t += b[i]
    i += s
  if a[s]!=t%2:
    b[s]=1

print(b.count(1))
for i in range(n):
  if b[i+1]==1:
     print(i+1)


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

using namespace std;

#define REP(i, n)   for(int i = 0; i < (n); i++)
#define REPS(i, n)  for(int i = 1; i <= (n); i++)
#define RREP(i, n)  for(int i = (n)-1; i >= 0; i--)
#define RREPS(i, n) for(int i = (n); i > 0; i--)
#define ALL(v) v.begin(), v.end()
#define RALL(v) v.rbegin(), v.rend()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end())
#define mp make_pair
#define mt make_tuple
#define pb push_back

using ll  = long long;
using pi  = pair<int, int>;
using pl  = pair<ll, ll>;
using vi  = vector<int>;
using vl  = vector<ll>;
using vs  = vector<string>;
using vb  = vector<bool>;
using vvi = vector<vi>;
using vvl = vector<vl>;

const int MOD = 1e9 + 7;
const int INF = 1e9 + 7;
const ll  INFL = 1e18;
const double PI = 3.141592653589793;
const double EPS = 1e-9;

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

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

    ll N; cin >> N;
    vl x(N), y(N); REP(i, N) cin >> x[i] >> y[i];
    REP(i, N)
    {
        ll tmp = x[i];
        x[i] -= y[i];
        y[i] += tmp;
    }

    ll ans = 0;
    chmax(ans, *max_element(ALL(x)) - *min_element(ALL(x)));
    chmax(ans, *max_element(ALL(y)) - *min_element(ALL(y)));
    cout << ans << endl;
}

Measured memory_bytes: 6364
s = input()
l = len(s)
i =0
while s != 'W' * (l) and s != 'B' * (l):
    x = s[0]
    if x == 'B':
        k = s.find('W')
        s = s[k:]
    else:
        k = s.find('B')
        s = s[k:]
    i += 1
    l = len(s)
print(i)


Measured memory_bytes: 3188
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define rep(i, x, n) for (int i = x; i < (int)(n); i++)
#define sc(x) scanf("%d",&x)
#define scll(x) scanf("%lld",&x)
int main(){
    int w, h, x, y;
    sc(w), sc(h), sc(x), sc(y);
    double ans = (double) w * h;
    ans = (double) ans / 2;
    cout << fixed << setprecision(9) << ans;
    char ans2 = '0';
    if (x*2==w && y*2==h) ans2 = '1';
    cout << " " << ans2 << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <string>
#include <algorithm>
#include <set>
#include <vector>
#include <map>
#include <list>
#include <stack>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <queue>
#define mkp(a, b) make_pair(a, b)
#define pb(t) push_back(t)
#define ft first
#define sc second
#define pt(num) cout << num << "\n"
#define moC(a, s, b) (a)=((a)s(b)+MOD)%MOD
#define max(a, b) ((a)>(b) ? (a):(b))
#define min(a, b) ((a)<(b) ? (a):(b))
#define chmax(a, b) (a<b ? a=b : 0)
#define chmin(a, b) (a>b ? a=b : 0)
#define INF 1000000000000000000
#define MOD 1000000007LL
#define MAX 101010
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
typedef map<ll, ll> Map;

ll N;
ll h[111];

ll rec(ll l, ll r) {
    if(l>=r) return 0;
    
    ll res=0;
    ll i;
    ll min=INF;
    for(i=l; i<r; i++) chmin(min, h[i]);
    res+=min;
    
    vector<ll> ze;
    ze.pb(l-1);
    for(i=l; i<r; i++) {
        h[i]-=min;
        if(h[i]==0) ze.pb(i);
    }
    ze.pb(N);
    
    for(i=0; i<ze.size()-1; i++)
        res+=rec(ze[i]+1, ze[i+1]);
    
    return res;
}

int main(void) {
    cin >> N;
    ll i;
    
    for(i=0; i<N; i++) cin >> h[i];
    
    pt(rec(0, N));
}




Measured memory_bytes: 256
#include <bits/stdc++.h>
#define syosu(x) fixed<<setprecision(x)
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef pair<double,double> pdd;
typedef pair<ll,ll> pll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vp> vvp;
typedef vector<pll> vpll;
typedef pair<int,P> pip;
typedef vector<pip> vip;
const int inf=1<<30;
const ll INF=1ll<<60;
const double pi=acos(-1);
const double eps=1e-9;
const ll mod=1e9+7;
const int dx[4]={0,1,0,-1},dy[4]={1,0,-1,0};

int n,N=0,M;
vvi g;
vi a,b;
vector<vvl> dp;
 
P dfs(int v,int d,int w){
	P p={d,v};
	for(auto u:g[v]) if(u!=w) p=max(p,dfs(u,d+1,v));
	return p;
}
 
bool DFS(int v,int w,int p){
	bool B=0;
	if(v==w) B=1;
	for(auto u:g[v]) if(u!=p){
		B|=DFS(u,w,v);
	}
	if(B){
		a.push_back(v);
		b[v]++;N++;
	}
	return B;
}

int Rec(int v,int p){
	int D=1,B=0;
	vvl DP;
	for(auto u:g[v]) if(u!=p){
		int d=Rec(u,v),D_=D;
		D=max(D,d+1);
		vvl DP_(D,vl(D));
		if(!B){
			for(int i=0;i<d;i++) for(int j=0;j<d;j++){
				(DP_[i+1][j]+=dp[u][i][j])%=mod;
				(DP_[i][j+1]+=dp[u][i][j])%=mod;
			}
			B=1;
		}
		else{
			for(int i=0;i<D_;i++) for(int j=0;j<D_;j++) if(DP[i][j]){
				for(int k=0;k<min(d,M-j+1);k++) for(int l=0;l<min(d,M-i+1);l++){
					if(j+k+1<=M) (DP_[max(i,k+1)][max(j,l)]+=DP[i][j]*dp[u][k][l])%=mod;
					if(i+l+1<=M) (DP_[max(i,k)][max(j,l+1)]+=DP[i][j]*dp[u][k][l])%=mod;
				}
			}
		}
		DP=DP_;
	}
	for(auto u:g[v]) if(u!=p) dp[u].clear();
	if(D==1){
		DP=vvl(1,vl(1));
		DP[0][0]++;
	}
	dp[v]=DP;
	return D;
}

int main(){
	ios::sync_with_stdio(0);
	cin.tie(0);
	cin>>n;
	b=vi(n);
	g=vvi(n);
	dp=vector<vvl>(n);
	for(int i=1;i<n;i++){
		int u,v;
		cin>>u>>v;
		u--;v--;
		g[u].push_back(v);
		g[v].push_back(u);
	}
	int L=dfs(0,0,-1).second,R=dfs(L,0,-1).second;
	DFS(L,R,-1);
	M=N/2;
	ll C=a[N/2],res=0;
	Rec(C,-1);
	for(int i=0;i<=M;i++) for(int j=0;j<=M;j++) (res+=dp[C][i][j])%=mod;
	cout<<res<<endl;
}

Measured memory_bytes: 16176
Floa = [[[0 for i in range(10)]for j in range(3)]for k in range(4)]

x = int(input())
for i in range(x):
    T = list(map(int,input().split()))
    Floa[T[0]-1][T[1]-1][T[2]-1] += T[3]

for i in range(4):
    for j in range(3):
        for k in range(10):
            print(' %d' %Floa[i][j][k],end = '')
        print()
    if i < 3:
        print('####################')



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

int main() {
  int n,k;
  cin >> n >> k;
  int p[n];
  for (int i=1; i<=n; i++) {
    cin >> p[i-1];
  }
  sort(p,p+n);
  int sum = 0;
  for (int i=0; i<=k-1; i++) {
    sum += p[i];
  }
  cout << sum << endl;
 return 0;
}

Measured memory_bytes: 3612
class DSU:
    def __init__(self, n):
        self.__parent = [i for i in range(n+1)]
        self.__size = [1 for _ in range(n+1)]
        self.n = n

    def parentOf(self,x):
        if self.__parent[x] != x:
            self.__parent[x] = self.parentOf(self.__parent[x])
        return self.__parent[x]
    
    def sizeOf(self,x):
        return self.__size[self.parentOf(x)]
    
    def makeUnion(self,x,y):
        p = self.parentOf(x)
        q = self.parentOf(y)
        if p==q:
            return
        if self.__size[p] < self.__size[q]:
            p,q = q,p
        self.__parent[q] = p
        #print("u",self.__size[p],self.__size[q])
        self.__size[p] += self.__size[q]
        #print(self.__size[p],self.__size[q])
    


if __name__ == "__main__":
    n,m,k = (int(x) for x in input().split())
    friendEdge = [ [int(x) for x in input().split()] for _ in range(m) ]
    enemyEdge = [ [int(x) for x in input().split()] for _ in range(k) ]

    d  = DSU(n+1)

    for (u,v) in friendEdge:
        d.makeUnion(u,v)
    

    outEdge = dict()
    for (u,v) in enemyEdge+friendEdge:
        if u not in outEdge:
            outEdge[u] = list()
        if v not in outEdge:
            outEdge[v] = list()
        outEdge.get(u).append(v)
        outEdge.get(v).append(u)

    ans = [0] * n
    for i in range(1,n+1):
        ans[i-1] = d.sizeOf(i) - 1
        # print(ans[i-1])
        for v in outEdge.get(i,list()):
            if d.parentOf(i) == d.parentOf(v):
                #print(i,v)
                ans[i-1] -= 1

    # print(ans)
    print(" ".join( map(str,ans) ))
    







    
    

Measured memory_bytes: 70704
#include <stdio.h>

int main(void)
{
  int n, k, x, y, i, s = 0;

  scanf("%d %d %d %d", &n, &k, &x, &y);

  for (i = 0; i < n; i++) {
    if (i < k) {
      s += x;
    } else {
      s += y;
    }
  }

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

  return 0;
}


Measured memory_bytes: 128
# ABC133C - Remainder Minimization 2019
def main():
    L, R = list(map(int, input().rstrip().split()))
    MOD = 2019
    if R - L + 1 >= MOD:  # L <= 2019n <= R
        print(0)
    else:  # max: 2018 * 2017 patterns
        ans = float("inf")
        L, R = L % MOD, R % MOD
        for i in range(L, R):
            for j in range(i + 1, R + 1):
                ans = min(ans, (i * j) % MOD)
                if ans == 0:
                    print(ans)
                    return
        print(ans)


if __name__ == "__main__":
    main()

Measured memory_bytes: 3064
H,W=gets.split.map(&:to_i)
s=H.times.map{gets.strip.codepoints.unshift(0)}.unshift(Array.new)
r,w=".#".codepoints
dist=Array.new(H+1){Array.new(W+1,Float::INFINITY)}
checked=Array.new(H+1){Array.new(W+1,false)}
dist[1][1]=1
dir=[[1,0],[-1,0],[0,1],[0,-1]]
stack=[[1,1]]
until stack.empty?
	cy,cx=stack.shift
	next if checked[cy][cx]
	checked[cy][cx]=true

	dir.each do |y,x|
		if (1<=cy+y && cy+y<=H) && (1<=cx+x && cx+x<=W) && s[cy+y][cx+x]==w
			checked[cy+y][cx+x]=true
			next
		end
		dist[cy+y][cx+x]=dist[cy][cx]+1 if (1<=cy+y && cy+y<=H) && (1<=cx+x && cx+x<=W) && (dist[cy][cx]+1 < dist[cy+y][cx+x])
		stack << [cy+y,cx+x] if (1<=cy+y && cy+y<=H) && (1<=cx+x && cx+x<=W)
	end
end
cnt=0
for y in 1..H
	for x in 1..W
		cnt+=1 if s[y][x]==w
	end
end
puts dist[H][W].abs==Float::INFINITY ? -1 : H*W-dist[H][W]-cnt


Measured memory_bytes: 2044
#include <iostream>
#include <string>

using namespace std;
typedef long long ll;

int main(){
    string s;
    getline(cin, s);
    for(int i = 0; i < s.size(); ++i){
        if(s.at(i) == '9'){
            s.at(i) = '1';
        }else if(s.at(i) == '1'){
            s.at(i) = '9';
        }
    }
    cout << s << endl;
    return 0;
}


Measured memory_bytes: 256
def Takoyaki(N, d):
    sum = 0
    for i in range(N):
        for j in range(N-i-1):
            sum += d[i] * d[i+j+1]
    return sum

N = int(input())
d = [int(x) for x in input().split()]
print(Takoyaki(N, d))

Measured memory_bytes: 2940
#include <bits/stdc++.h>
#include<math.h>
#include<queue>
#include<cstdio>
#include<set>
#include<map>
using namespace std;
using ll = long long;

int main(){
    int A,B,C,D;
    cin >> A >> B >> C >> D;
    int taka = C/B;
    if(C%B!=0) taka++;
    int ao = A/D;
    if(A%D!=0) ao++;
    if(taka<=ao) cout << "Yes";
    else cout << "No";
    return 0;
}

Measured memory_bytes: 3636
#include<bits/stdc++.h>
using namespace std;
#define LL long long
#define rep(i,a,n) for(int i=a;i<n;++i)
#define per(i,a,n) for(int i=n-1;i>=a;--i)
#define mp make_pair
#define pb push_back
#define fi first
#define se second
#define all(v) v.begin(),v.end()
#define sz(v) ((int)sizeof(v))
#define N 100005
const int inf=2e+9;
char s[N];
int main()
{
    int n,ans;
    scanf("%s",s);
    n=strlen(s);
    ans=(n%2)^(s[0]==s[n-1]);
    puts(ans==1?"First":"Second");
    return 0;
}


Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
	set<int>s;
	for(int i=0;i<3;i++){
		int t;
		cin>>t;
		s.insert(t); 
	} 
	if(s.size()==2){
		puts("Yes");
	}
	else {
		puts("No");
	}
 } 

Measured memory_bytes: 256
#pragma GCC target("avx")
//#pragma GCC target("avx512f,avx512dq,avx512cd,avx512bw,avx512vl")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")
#include <bits/stdc++.h>
using namespace std;
#define LL long long
#define DB double
#define ST string
#define BS bitset
#define PA pair<LL,LL>
#define VE vector
#define VL vector<LL>
#define VP vector<pair<LL,LL>>
#define VVL vector<vector<LL>>
#define PQ priority_queue
#define PQS priority_queue<LL,vector<LL>,greater<LL>>
#define PB push_back
#define POB pop_back
#define PF push_front
#define POF pop_front
#define EB emplace_back
#define TS to_string
#define TU to_ullong
#define BPL __builtin_popcountll
#define FOR(i,a,n) for(i=a;i<n;i++)
#define FORR(i,a,n) for(i=n-1;i>=a;i--)
#define rep(i,n) FOR(i,0,n)
#define repr(i,n) FOR(i,0,n)
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SORT(a) sort(ALL(a))
#define REV(a) reverse(ALL(a))
#define UB(a,n) *upper_bound(ALL(a),n)
#define LB(a,n) *lower_bound(ALL(a),n)
#define INF 1145141919810364364
#define PI 3.14159265358979
#define MOD 1000000007
//#define MOD 998244353
#define ERR 0.00000001
//#define ERR 0.00000000000001
#define NUM 200010
#define FAST cin.tie(0);ios::sync_with_stdio(false)

void Yn(LL a){if(a)printf("Yes\n");else printf("No\n");}
void YN(LL a){if(a)printf("YES\n");else printf("NO\n");}
LL pwmn(LL a,LL n){LL ans=1;while(ans<a)ans*=n;return ans;}
LL LBn(VL &v,LL a){LL mx=v.size(),mn=-1,md;while(mx-mn>1){md=(mx+mn)/2;if(v[md]<a)mn=md;else mx=md;}return mx;}
LL GCD(LL a,LL b){LL c=1,tmp=max(a,b);b=min(a,b);a=tmp;while(c!=0){c=a%b;a=b;b=c;}return a;}
LL LCM(LL a,LL b){return a*b/GCD(a,b);}
int lcmp(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return 1;if(*(LL*)a<*(LL*)b)return -1;return 0;}
int lcmpr(const void* a,const void* b){if(*(LL*)a>*(LL*)b)return -1;if(*(LL*)a<*(LL*)b)return 1;return 0;}
int ccmp(const void* a,const void* b){return *(char*)a-*(char*)b;}
int ccmpr(const void* a,const void* b){return *(char*)b-*(char*)a;}
int scmp(const void* a,const void* b){return strcmp((char*)a,(char*)b);}
int scmpr(const void* a,const void* b){return strcmp((char*)b,(char*)a);}
LL mod(LL a,LL m){if(a%m<0)return a%m+m;else return a%m;}
LL DIV(LL a,LL d){LL m=MOD,x=1,y=0,k;while(m){k=d/m;d-=k*m;swap(m,d);x-=k*y;swap(x,y);}return mod(a*mod(x,MOD),MOD);}
LL POW(LL a,LL n){LL ans=1;while(n>0){if(n&1)ans=ans*a%MOD;a=a*a%MOD;n>>=1;}return ans;}
LL fact[NUM],finv[NUM],inv[NUM];
void comi(){LL i;fact[0]=fact[1]=1;finv[0]=finv[1]=1;inv[1]=1;FOR(i,2,NUM){fact[i]=fact[i-1]*i%MOD;inv[i]=MOD-inv[MOD%i]*(MOD/i)%MOD;finv[i]=finv[i-1]*inv[i]%MOD;}}
LL com(LL n,LL k){if(n<k||n<0||k<0)return 0;return fact[n]*(finv[k]*finv[n-k]%MOD)%MOD;}
bool cmps(pair<LL,LL> a,pair<LL,LL> b){if(a.second!=b.second)return a.second<b.second;return a.first<b.first;}
template<typename T>bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T>bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}

int main(){
  FAST;
  LL i,ans=0,N;
  cin>>N;
  string S[N];
  rep(i,N)cin>>S[i];
  map<string,bool> m;
  rep(i,N)m[S[i]]=1;
  cout<<m.size()<<endl;
}


Measured memory_bytes: 25540
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<(n); ++i)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
using namespace std;
using Graph = vector<vector<int>>;
typedef long long ll;
typedef pair<int, int> P;
const int inf = INT_MAX;
const ll INF = 1LL << 60;
const ll mod = 1e9+7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};

// 084d

int main(){
    int q;
    cin >> q;
    int l[100005], r[100005];
    rep(i, q) cin >> l[i] >> r[i];

    vector<int> c(100005, 1);
    c[0] = 0, c[1] = 0;
    for(int i=2; i<100005; i++){
        if (!c[i]) continue;
        for(int j=i*2; j<100005; j+=i) c[j] = 0;
    }
    vector<int> judge(100005, 1);
    rep(i, 100004){
        if (c[i]==1 and c[(i+1)/2]==1 and i%2==1){
            judge[i] = 1;
        }else judge[i] = 0;
    }
    rep(i, 100004) judge[i+1] = judge[i] + judge[i+1];
    rep(i, q){ 
        int ll = l[i], rr = r[i];
        cout << judge[rr] - judge[ll-1] << endl;
    }
    return 0;
}


Measured memory_bytes: 2176
#include<bits/stdc++.h>
#define rep(i,a,b) for(int i=int(a);i<int(b);++i)
using namespace std;
typedef long long ll;
int INF = (1LL << 30) - 1;
int MOD = 1e9+7;
main(){
    int N;
    cin >> N;
    vector<ll> V(N);
    rep(i,0,N)cin >> V[i];
    ll ans = 0;
    rep(i,0,61){
        ll mask = 1LL << i;
        int cnt = 0;
        rep(j,0,N){
            if(V[j] & mask)cnt++;
        }
        ll tmp = mask % MOD;
        tmp = tmp * cnt % MOD;
        tmp = tmp * (N - cnt) % MOD;
        ans += tmp;
        ans %= MOD;
    }
    cout << ans << endl;
}

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

"""
input:
5 6
0 1
1 0
1 2
2 4
4 3
3 2
4
0 1
0 3
2 3
3 4

output:
1
0
1
1
"""

import sys
from math import isinf

sys.setrecursionlimit(int(1e5))


def generate_adj_table(_v_info):
    for v_detail in _v_info:
        v_from, v_to = map(int, v_detail)
        init_adj_table[v_from].append(v_to)
    return init_adj_table


def Tarjan(current, low, disc, scc_stack, in_scc_stack):
    global timer
    disc[current] = low[current] = timer
    timer += 1

    # visited[current] = True
    in_scc_stack[current] = True
    scc_stack.append(current)

    current_scc_set = set()
    for adj in adj_table[current]:
        if isinf(disc[adj]):
            Tarjan(adj, low, disc, scc_stack, in_scc_stack)
            low[current] = min(low[current], low[adj])

        elif in_scc_stack[adj]:
            low[current] = min(low[current], disc[adj])

    scc_candidate = -1
    if disc[current] == low[current]:
        while scc_candidate != current:
            scc_candidate = scc_stack.pop()
            current_scc_set.add(scc_candidate)
            # visited[scc_candidate] = False
            in_scc_stack[scc_candidate] = False

        init_scc_sets_list.append(current_scc_set)

    return None


def scc():
    disc = [float('inf')] * vertices
    low = [float('inf')] * vertices
    # visited = [False] * vertices
    scc_stack = list()
    in_scc_stack = [False] * vertices

    for v in range(vertices):
        if isinf(disc[v]):
            Tarjan(v, low, disc, scc_stack, in_scc_stack)

    return init_scc_sets_list


def solve():
    for question in q_list:
        flag = False
        ele1, ele2 = map(int, question)
        for each in scc_sets_list:
            if (ele1 in each) and (ele2 in each):
                flag = True
                break
        if flag:
            print('1')
        else:
            print('0')

    return None


if __name__ == '__main__':
    _input = sys.stdin.readlines()
    vertices, edges = map(int, _input[0].split())
    v_info = map(lambda x: x.split(), _input[1:edges + 1])
    q_num = int(_input[edges + 1])
    q_list = map(lambda x: x.split(), _input[edges + 2:])

    init_adj_table = tuple([] for _ in range(vertices))
    adj_table = generate_adj_table(v_info)

    timer = 0
    init_scc_sets_list = []
    scc_sets_list = scc()
    solve()

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

using namespace std;


#define uniq(x)  x.erase(unique(x.begin(),x.end()), x.end()) //Unique value find from vector
#define upper(arr,n,fixed) upper_bound(arr,arr+n,fixed)-arr  //Upper value search  >
#define lower(arr,n,fixed) lower_bound(arr,arr+n,fixed)-arr  //Lower value search  >=
#define FOR(i,a,n) for(int i=a; i<(int)n; i++)
#define FORI(i,a,n) for(int i=a; i>=(int)n; i--)
#define pii pair<int,int>
#define vpii vector<pii>
#define mp make_pair
#define fi first
#define se second
#define pb push_back
#define sz(a) int((a).size())
#define fastIO() ios_base::sync_with_stdio(0); cin.tie(0)
#define endl "\n"
#define all(a) a.begin(), a.end()
#define MEMSET(p,i) memset(p,i,sizeof(p))

typedef long long LL;

LL memo[100010];
LL v[100010];
int n, k;

LL dp(int i)
{
	if(i >= n)
		return 1e9;

	if(i == n-1)
		memo[i] = 0;

	if(memo[i] != -1)
		return memo[i];

	LL &dpm = memo[i];
	dpm = 0;
	LL best = 1e9;
	FOR(j,1,k+1){
		best = min(best, abs(v[i]-v[i+j])+dp(i+j));
	}

	return dpm += best;
}

int main(void)
{
	fastIO();

	cin >> n >> k;

	MEMSET(v,0);
	FOR(i,0,n)
		cin >> v[i];
	
	MEMSET(memo,-1);

	cout << dp(0) << endl;
}

Measured memory_bytes: 6528
//============================================================================
// Name        : abc141_b.cpp B - Tap Dance
// Author      :
// Version     :
// Copyright   : Your copyright notice
// Description : https://atcoder.jp/contests/abc141/tasks/abc141_b
//============================================================================

#include <iostream>
using namespace std;

int main() {
	string S;
	cin >> S;
	int l = S.size();
	string c;
	bool flag = true;
	for (int i = 0; i < l; ++i) {
		c = S[i];
		if (i % 2 == 0) { // 奇数文字目
			if (c != "R" && c != "U" && c != "D") {
				flag = false;
				break;
			}
		} else {
			if (c != "L" && c != "U" && c != "D") {
				flag = false;
				break;
			}
		}
	}
	cout << ((flag) ? "Yes" : "No") << endl;
	return 0;
}


Measured memory_bytes: 256
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		
		String s = sc.next();
        if(s.charAt(2)==s.charAt(3) && s.charAt(4)==s.charAt(5)){System.out.println("Yes");}
		else{System.out.println("No");}
	}
}


Measured memory_bytes: 22740
import java.util.*;
public class Main {
    public void solve() {
        Scanner scan = new Scanner(System.in);
        int a = scan.nextInt();
        if (a >= 30) {
            System.out.println("Yes");
        } else {
            System.out.println("No");
        }
    }
        public static void main(String[]args){
            new Main().solve();
        }
    }

Measured memory_bytes: 35700
import java.util.*;
	import java.util.Map.Entry;
	 
	 
	 class Main {
		 static int mod =  (int) (Math.pow(10,9)+7);
//		 static int mod =  (int) 998244353;
		 static List<ArrayList<Integer>> list= new ArrayList<ArrayList<Integer>>();
		 static int a_dist[];
		 public static void main(String[] args) {
	    	
	        Scanner sc = new Scanner(System.in);
	        int N = sc.nextInt();
	        String S = sc.next();
	        char[] c = S.toCharArray();
	        int wcnt =0;
	        int rcnt =0;
	        int[] wm = new int[N];
	        int[] rm = new int[N];
	        
	        
	        for(int i=0;i<N;i++) {
	        	if(c[i]=='W') {
	        		wm[wcnt]=i;
	        		wcnt++;
	        	} else {
	        		rm[rcnt]=i;
	        		rcnt++;
	        	}
	        }
	        if(wcnt==0) {
	        	System.out.println(0);
	        	return;
	        }
	        long ans=0;
	        int wnow=0;
	        int rnow=rcnt-1;
	        while(wnow<N&&rnow>=0&&wm[wnow]<rm[rnow]) {
	        	ans++;
	        	wnow++;
	        	rnow--;
	        }
	        
	        
	        System.out.println(ans);
		 }
		 
	}

Measured memory_bytes: 42584
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

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

    int N;
    cin >> N;
    vector<P> V;
    for (int i = 0; i < N; ++i) {
        int A, B;
        cin >> A >> B;
        V.push_back(make_pair(B, A));
    }
    sort(V.begin(), V.end());

    ll now = 0;
    for (auto &p : V) {
        now += p.second;
        if (now > p.first) {
            cout << "No" << endl;
            exit(0);
        }
    }
    cout << "Yes" << endl;

    return 0;
}

Measured memory_bytes: 6512
#include<stdio.h>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
ll mod = 1000000007;
#define SIZE 200000
ll inv[SIZE + 1];
ll kai[SIZE + 1];
ll invkai[SIZE + 1];
void invinit()
{
	inv[1] = 1;
	for (int i = 2; i <= SIZE; i++)
	{
		inv[i] = mod - (mod / i)*inv[mod%i] % mod;
	}
	kai[0] = invkai[0] = 1;
	for (int i = 1; i <= SIZE; i++)
	{
		kai[i] = kai[i - 1] * i%mod;
		invkai[i] = invkai[i - 1] * inv[i] % mod;
	}
}
ll com(ll a, ll b)
{
	if (b < 0 || a < b)return 0;
	return (invkai[b] * invkai[a - b]) % mod*kai[a] % mod;
}
int main()
{
	int num;
	scanf("%d", &num);
	invinit();
	ll r = 0;
	int bef;
	ll t = 0;
	for (int i = 0; i < num; i++)
	{
		int z;
		scanf("%d", &z);
		if (i != 0)
		{
			t = (t + kai[num - 1] * inv[i]) % mod;
			r = (r + t*(z - bef)) % mod;
		}
		bef = z;
	}
	printf("%lld\n", r);
}

Measured memory_bytes: 4864
#include <bits/stdc++.h>
#define REP(i, a, n) for(ll i = ((ll) a); i < ((ll) n); i++)
using namespace std;
typedef long long ll;
 
string S;
 
int main(void) {
  cin >> S;
 
  REP(i, 0, S.length() - 1) {
    if(S[i] == 'A' && S[i + 1] == 'C') {
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}

Measured memory_bytes: 256