akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#include <math.h>

using namespace std;

int main(){
	int n;
	cin>>n;
	set<string> hoge;

	for(int i=0;i<n;i++){
		string teresakunn;
		cin>>teresakunn;
		hoge.insert(teresakunn);
	}

	cout<<hoge.size()<<endl;

	return 0;
}


Measured memory_bytes: 19256
N,K=map(int,input().split())
R,S,P=map(int,input().split())
T=input()
cnt=[0 for _ in range(N)]
score={'r':P,'s':R,'p':S}
for i in range(N):
    if i<K:
        cnt[i]=score[T[i]]
    else:
        if T[i-K]!=T[i]:
            cnt[i]=score[T[i]]
        else:
            if cnt[i-K]==0:
                cnt[i]=score[T[i]]
print(sum(cnt))


Measured memory_bytes: 9992
import java.util.Collections;
import java.util.LinkedList;
import java.util.Scanner;

public class Main {
	public static void main(String args[]){

		Scanner sc = new Scanner(System.in);

		int n = sc.nextInt();
		LinkedList<Integer> inputs = new LinkedList<>();

		for(int i=0;i < n;i++) {
			inputs.add(sc.nextInt());
		}
		Collections.sort(inputs);

		double beforeParam = inputs.pop();
		for(int i=0;i < n - 1;i++) {
			beforeParam = (beforeParam + inputs.pop()) / 2;
		}

		System.out.println(beforeParam);

	}
}

Measured memory_bytes: 21972
#include <bits/stdc++.h>
using namespace std;
string x;
stringstream ss;
int n;
int t;
int a[80000];
int b;
int d;
int main()
{
	while(cin >> x && x!="0")
	{
		int c[11]={};
		n=x.size();
		d=0;
		for(int i=0; i<n; i++)
		{
			ss << x[i];
		    ss >> a[i];
			ss.clear();
		    ss.str("");
		}
		b=0;
		c[0]=1;
		for(int i=1; i<=n; i++)
		{
			if(i%2==0)
			{
				b=(b-a[i-1]+11)%11;
			}
			else
			{
				b=(b+a[i-1])%11;
			}
			d+=c[b];
			if(i<n)
			{
				if(a[i]!=0)
				{
					c[b]+=1;
				}
			}
		}
		cout << d << endl;
	}
	return 0;
}

Measured memory_bytes: 3500
S = input()
cnt_1 = 0
cnt_2 = 0
for i in range(len(S)):
    if i % 2 == 0:
        if S[i] == "0":
            cnt_1 += 1
        else:
            cnt_2 += 1
    else:
        if S[i] == "1":
            cnt_1 += 1
        else:
            cnt_2 += 1
print(min(cnt_1, cnt_2))



Measured memory_bytes: 3188
#include <iostream>
#include <vector>
#include <map>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <numeric>
#include <list> 
#include <cmath>
#include <stdio.h>

using namespace std;
using ll = long long;
#define FOR(i,a,b) for(int i=int(a);i<int(b);i++)
#define REP(i,b) FOR(i,0,b)
#define MP make_pair
#define PB push_back
#define EB emplace_back
#define ALL(x) x.begin(),x.end()
#define INF (1e9)

typedef vector<int> vi;
typedef vector<long long> vll;
typedef pair<int,int> P;

#define CAPITAL
void Yes(bool ex=true){
	#ifdef CAPITAL
	cout<<"YES"<<endl;
	#else
	cout<<"Yes"<<endl;
	#endif
	if(ex)exit(0);
}
void No(bool ex=true){
	#ifdef CAPITAL
	cout<<"NO"<<endl;
	#else
	cout<<"No"<<endl;
	#endif
	if(ex)exit(0);
}

int main() {
    int N, H, W;
    cin >> N >> H >> W;
    int ans = 0;
    REP(i, N) {
        int a, b;
        cin >> a >> b;
        if (a >= H && b >= W) {
            ans += 1;
        }
    }
    printf("%d", ans);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i,n) for(ll i = 0; i < (ll)n; i++)
#define FOR(i,a,b) for (ll i=(a);i<(ll)b; i++)
#define ALL(obj) (obj).begin(),(obj).end()
#define INF 1000000000000000
using namespace std;
typedef long long ll;
typedef pair<long long, long long> pll;
typedef double db;
typedef string str;
typedef pair<ll,ll> p;
const int MOD = 1000000007;


int main(){
    int N;cin>>N;
    vector<pll> pos(N);
    for(int i = 0; i <N; i++) cin>>pos[i].first>>pos[i].second;
    int parity = (abs(pos[0].first)+abs(pos[0].second)) % 2;
    REP(i,N){
        int par2 = (abs(pos[i].first)+abs(pos[i].second)) % 2;
        //45 degree回転する
        pos[i] = pll(pos[i].first + pos[i].second, pos[i].first - pos[i].second);
        if(par2 != parity){
            cout<<-1<<endl;
            return 0;
        }   
    }
    vector<long long>d;
    for(int i = 30; i>=0;i--) d.push_back(1LL<<i);//1<di<10^12
    if(parity%2==0) d.push_back(1);
    cout<<d.size()<<endl;
    REP(j,d.size()) cout<<d[j]<<" ";
    cout<<endl;

    REP(i,N){
        int xdir,ydir;
        ll xsum = 0, ysum = 0;
        FOR(j,0,d.size()){
            if (xsum <= pos[i].first) xdir = 1, xsum += d[j];
            else xdir = -1, xsum -= d[j];

            if(ysum <= pos[i].second) ydir = 1,ysum += d[j];
            else ydir = -1, ysum -= d[j];

            if(xdir == 1 and ydir == 1) cout<<"R";
            else if (xdir == 1 and ydir == -1) cout<<"U";
            else if (xdir == -1 and ydir == -1) cout<<"L";
            else cout<<"D";
        }
        cout<<endl;
    }
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cmath>
#include <cstdio>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>

#define pb push_back
#define debug(x) cout<< #x <<": "<<x<<endl
#define debug2(x,y) cout<< #x <<": "<< x <<", "<< #y <<": "<< y <<endl

using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<int, int> i_i;
typedef pair<i_i, int> p_i;
typedef vector<int> vi;
typedef vector<vector<int> > vvi;
template<class T> using vv=vector<vector< T > >;

vi ts_d;
vi ts_f;

template<class T>
void dfs(int cur, int &time_visit, T graph) {
  // visiting cur
  time_visit += 1;
  ts_d[cur] = time_visit;
  for (auto dst : graph[cur]) {
    if (ts_d[dst] == 0) {
      dfs(dst, time_visit, graph);
    }
  }
  time_visit += 1;
  ts_f[cur] = time_visit;
  return;
}

int main() {
  int time = 0;
  int n;
  cin >> n;
  ts_d.reserve(n);
  ts_f.reserve(n);
  ts_d.assign(1, 0);
  vector<set<int> > graph(n, set<int>());

  for (int i = 0; i < n; ++i) {
    int num;
    cin >> num;
    num -= 1;
    int out;
    cin >> out;
    for (int j = 0; j < out; ++j) {
      int tmp;
      cin >> tmp;
      tmp -= 1;
      graph[i].insert(tmp);
    }
  }

  for (int i = 0; i < n; ++i) {
    if (ts_d[i] == 0) {
      dfs(i, time, graph);
    }
  }

  for (int i = 0; i < n; ++i) {
    printf("%d %d %d\n", i+1, ts_d[i], ts_f[i]);
  }

  return 0;
}

Measured memory_bytes: 5340
/*
Though leaves are many , the root is one.
Through all the lying days of my youth
I swayed my leaves and flowers in the sun.
Now I may wither into the truth.
	  	  	- William Butler Yeats
*/
//#pragma GCC optimize("Ofast,no-stack-protector")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx")
//#pragma GCC target("avx,tune=native")
#include<bits/stdc++.h>
#define int long long
//#include<ext/pb_ds/assoc_container.hpp>
using namespace std;
//using namespace __gnu_pbds;
const int inf=0x3f3f3f3f;
const double eps=1e-6;
const int mod=1000000007;
typedef long long ll;
#ifndef LOCAL
#define cerr if(0)cout
#endif
#define eprintf(...) fprintf(stderr, __VA_ARGS__)
inline string getstr(string &s,int l,int r){string ret="";for(int i=l;i<=r;i++)ret.push_back(s[i]);return ret;}
int modpow(int x,int y,int md=mod){if(y==0)return 1;int ret=modpow(x,y>>1,md);ret=(ll)ret*ret%md;if(y&1)ret=(ll)ret*x%md;return ret;}
int n,k;
int a[200005];
int f[200005];
bool check(int ans){
	int sum=0;
	for(int i=1;i<=n;i++){
		sum+=max(0ll,a[i]-ans/f[i]);
	}
	return sum<=k;
}
signed main(){
	cin>>n>>k;
	for(int i=1;i<=n;i++)cin>>a[i];
	for(int i=1;i<=n;i++)cin>>f[i];
	sort(a+1,a+n+1);
	sort(f+1,f+n+1);
	reverse(f+1,f+n+1);
	int L=-1,R=1e18;
	while(R-L>1){
		int mid=L+R>>1;
		if(check(mid))R=mid;
		else L=mid;
	}
	cout<<R<<endl;
	return 0;
}

Measured memory_bytes: 3328
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b;
  cin >> a;
  int dig = 0;
  int sum = 0;

  while(a){
    dig = a % 10;
    sum += dig;
    a /= 10;
  }
  cout << sum << endl;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

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

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

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

struct Edge{int a,b,c; Edge(){} Edge(int a, int b, int c):a(a),b(b),c(c){}};

int main(){
  int n,m; cin >> n >> m;
  vector<Edge> v;

  int dp[100][100];
  Fill(dp,1001001001);
  
  for(int i = 0; i < m; ++i){
    int a,b,c; cin >> a >> b >> c;a--;b--;
    dp[a][b] = c;
    dp[b][a] = c;
    v.push_back(Edge(a,b,c));
  }

  for(int k = 0; k < n; ++k){
    for(int i = 0; i < n; ++i){
      for(int j = 0; j < n; ++j){
	ChangeMin(dp[i][j],dp[i][k]+dp[k][j]);
      }
    }
  }
  int sum = 0;
  for(auto&e:v){
    if(dp[e.a][e.b]<e.c)sum++;
  }
  cout << sum << endl;
  return 0;
}


Measured memory_bytes: 256
from itertools import groupby, accumulate, product, permutations, combinations
def solve():
  N = int(input())
  A = [list(map(int, input().split())) for _ in range(N)]
  mod = 10**9+7
  dp = [0]*(1<<N)
  dp[0] = 1
  for i in range(1,N+1):
    for com in combinations(range(N),i):
      S = 0
      for k in com:
        S += 1<<k
      for j in com:
        if A[i-1][j]==1:
          dp[S] += dp[S-(1<<j)]
          dp[S] %= mod
  return dp[-1]
print(solve())

Measured memory_bytes: 90080
// B - Strings with the Same Length
#include <bits/stdc++.h>
using namespace std;

int main(){
	int N; string S,T;
	cin>>N>>S>>T;
	string ans = "";
	for(int i=0; i<N; ++i) ans = ans + S[i]+T[i];
	cout<< ans <<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define ll long long int
using namespace std;
int main()
{
	string s;
	cin>>s;
	ll len=s.length(),ans=0,i;
	for(i=0;i<len;i++)
	{
		if(s[i]=='2')
		ans++;
	}
	cout<<ans;
 	return 0;
}


Measured memory_bytes: 256
N = int(input())
p = [int(x) for x in input().split(" ")]

sorted_p = sorted(p)
count = 0
for i in range(N):
    if sorted_p[i] != p[i]: count += 1

if count == 0 or count == 2:
    print("YES")
else:
    print("NO")

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
//const int nmax=10;

long long a(long long N){
  int num=0;
  for(long long i=1;;i++){
    if(N/i<i)break;
    if(N%i==0)num=i;
  }
  if(N/num>num)num=N/num;
  
  //cout <<num;
  
  for(long long i=1;;i++){
    
    //cout <<num<<"   ";
    num=num/10;
    if(num==0){
      num=i;
      break;
    }
  }
  return num;
}
int main(void)
{
  long long N;
  cin >> N;
  cout <<a(N)<< endl;
  return 0;
}





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

int main() {
  string N; cin >> N;
  bool flag = false;
  vector<char> vec(4);
  for (int i = 0; i < 4; i++) {
    vec.at(i) = N.at(i);
  }

  if (vec.at(0) == vec.at(1) && vec.at(1) == vec.at(2)) {
    flag = true;
  }
  else if (vec.at(1) == vec.at(2) && vec.at(2) == vec.at(3)) {
    flag = true;
  }
  
  if (flag) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}




Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
	int n;
	cin >> n;
	int a[n];
	for(int i=0;i<n;i++) cin >> a[i];
	for(int i=n-1;i>0;i--) cout << a[i] << " ";
	cout << a[0] << endl;
}

Measured memory_bytes: 1160
#coding:utf-8
import sys
sys.setrecursionlimit(10**6)
write = sys.stdout.write
dbg = lambda *something : print(*something) if DEBUG else 0
DEBUG = False
def main(input = sys.stdin.readline):
    LMIIS = lambda : list(map(int,input().split()))
    II = lambda : int(input())

    N = II()
    info = []
    for _ in range(N):
        xi, yi, hi = LMIIS()
        if hi != 0:
            xt, yt, ht = xi, yi, hi
        info.append((xi, yi, hi))

    for Cy in range(101):
        for Cx in range(101):
            H = ht + abs(xt - Cx) + abs(yt - Cy)
            found = True
            for xi, yi, hi in info:
                tmp_h = max(H - abs(Cy-yi) - abs(Cx-xi), 0)
                if tmp_h != hi:
                    found = False
                    break
            if found:
                print('{} {} {}'.format(Cx,Cy,H))
                return



if __name__ == '__main__':
    main()


Measured memory_bytes: 41584
s = list(input())

n = len(s)
a = "abcdefghijklmnopqrstuvwxyz"
ans = -1
if n < 26:
    for v in a:
        if v not in s:
            ans = "".join(s + [v])
            break
else:
    for i in range(1, n)[::-1]:
        if s[i-1] < s[i]:
            j = a.index(s[i-1])
            for v in a[j:]:
                if v not in s[:i]:
                    s[i-1] =  v
                    ans = "".join(s[:i])
                    break
            break

print(ans)

Measured memory_bytes: 38256
#include<stdio.h>
#include<stdlib.h>
 
int main(){
 
  int N, i, a, b, c, t, h, v;
  int x[100001], y[100001], n[100001];
  x[0]=0; y[0]=0; n[0]=0;
  scanf("%d", &N);
  for(i=0; i<N; i++){
    scanf(" %d %d %d", &c, &a, &b);
    n[i+1]=c; x[i+1]=a; y[i+1]=b;
  }

  for(i=0; i<N; i++){
    t=n[i+1]-n[i];
    h=(x[i]>x[i+1]?x[i]-x[i+1]:x[i+1]-x[i]);
    v=(y[i]>y[i+1]?y[i]-y[i+1]:y[i+1]-y[i]);
    if(h+v>t){
      printf("No\n"); break;
    }else{
      if(i==N-1){
         if((t-(h+v))%2){
           printf("No\n"); break;
         }else{
           printf("Yes\n"); break;
         }
      }else{
         if((t-(h+v))%2){
           printf("No\n"); break;
         }else
           continue;
      }
    }
  }

}


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

int main() {
    #ifdef DEBUG
        freopen("in.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr);

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

    int ans = 0;
    for (int i = 0; i < n; i++) {
        int x; cin >> x;
        ans += min(x, k - x) * 2;
    }
    cout << ans << '\n';

    return 0;
}


Measured memory_bytes: 256
// http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=ALDS1_7_D
// Tree - Reconstruction of a Tree
// TODO: review

#define SUBMIT

#include <utility>
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <vector>
#include <limits>
#include <numeric>
#include <functional>
#include <set>
#include <cmath>
#include <cstring>
#include <climits>

using namespace std;
using ui64 = unsigned long long;
using i64 = long long;

const int NIL = -1;
const int MAX_T = 40;

int n;
int pos;
vector<int> pre;
vector<int> in;
vector<int> post;

void reconstruct(int left, int right) {
    if (left >= right) return;
    int root = pre[pos];
    pos++;

    int m = distance(in.begin(), find(in.begin(), in.end(), root));
    reconstruct(left, m);
    reconstruct(m + 1, right);
    post.push_back(root);
}

void solve() {
    pos = 0;
    reconstruct(0, pre.size());
    for (int i = 0; i < n; ++i) {
        cout << post[i];

        if (i != n - 1) cout << " ";
        else cout << endl;
    }
}


int main() {
#ifdef SUBMIT
    cin >> n;
    pre.resize(n);
    in.resize(n);
    for (int i = 0; i < n; ++i) cin >> pre[i];
    for (int i = 0; i < n; ++i) cin >> in[i];
#else
    n = 5;
    pre = {1, 2, 3, 4, 5};
    in = {3, 2, 4, 1, 5};
#endif
    solve();
    return 0;
}


Measured memory_bytes: 3140
#include<bits/stdc++.h>
using namespace std;
#define inf INT_MAX
#define INF LLONG_MAX
#define ll long long
#define ull unsigned long long
#define M (int)(1e9+7)
#define P pair<int,int>
#define PLL pair<ll,ll>
#define FOR(i,m,n) for(int i=(int)m;i<(int)n;i++)
#define RFOR(i,m,n) for(int i=(int)m;i>=(int)n;i--)
#define rep(i,n) FOR(i,0,n)
#define rrep(i,n) RFOR(i,n,0)
#define all(a) a.begin(),a.end()
#define IN(a,n) rep(i,n){ cin>>a[i]; }
const int vx[4] = {0,1,0,-1};
const int vy[4] = {1,0,-1,0};
#define PI 3.14159265
#define F first
#define S second
#define PB push_back
#define EB emplace_back
#define int ll
#define vi vector<int>



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

  string s;
  cin>>s;
  int n=s.size();

  vector<int> v(n,0);

  int i=0;
  while(i<n){
    int j=i;
    if(s[j]=='L'){
      i++;
      continue;
    }
    while(j<n&&s[j]=='R') j++;
    v[j]+=(j-i)/2;
    v[j-1]+=(j-i+1)/2;
    i=j;
  }
  

  i=n-1;
  while(i>=0){
    int j=i;
    if(s[j]=='R'){
      i--;
      continue;
    }
    while(j>=0&&s[j]=='L') j--;
    v[j]+=(i-j)/2;
    v[j+1]+=(i-j+1)/2;
    i=j;
  }

  rep(i,n){
    cout<<v[i]<<' ';
  }
  cout<<endl;



}

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

int main()
{
    string s;
    cin >> s;
    string answer = "Yes";
    char c;
    for(int i = 1; i <= (int)s.length(); ++i)
    {
        c = s[i-1];
        if( (i%2 != 0 && c == 'L')
        || (i%2 == 0 && c == 'R'))
        {
            answer = "No";
            break;
        }
    }

    cout << answer << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long  n,m;
	cin >>n >>m;
	if(n==1 || m==1)
	{
		cout <<1;
	 } 
	else 
	{
		if((n*m)%2==0){
			cout << n*m/2;
		}
		else
		{
			cout <<  n*m/2+1; 
		}
	}
} 


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

using namespace std;

typedef long long ll;
typedef pair<ll, ll> P;

#define MOD 1000000007
#define REP(i, N) for (int i = 0; i < N; ++i)
#define REP1(i, N) for (int i = 1; i <= N; ++i)
#define RREP(i, N) for (int i = N - 1; i >= 0; --i)
#define ALL(a) a.begin(), a.end()

int main() {
  int n;
  cin >> n;
  int a[n];
  REP(i, n) cin >> a[i];
  int ans[n];
  ans[0] = 0;
  REP(i, n) ans[0] += (i % 2 == 0 ? 1 : -1) * a[i];
  REP(i, n - 1) ans[i + 1] = 2 * a[i] - ans[i];
  REP(i, n) cout << (i == 0 ? "" : " ") << ans[i];
  cout << "\n";
  return 0;
}

Measured memory_bytes: 2048
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int n;
    cin>>n;
    int arr[n+1];
    for(int i=1;i<=n;i++)
    cin>>arr[i];
    int dp[n+1];
    dp[1]=0;
    dp[2]=abs(arr[2]-arr[1]);
    for(int i=3;i<=n;i++)
    {
        dp[i]=min(dp[i-1]+abs(arr[i]-arr[i-1]),dp[i-2]+abs(arr[i]-arr[i-2]));
    }
    cout<<dp[n]<<"\n";
    return 0;
}

Measured memory_bytes: 1024
// -----------------------------------
// Author     : MatsuTaku
// Affiliation: Tokushima University
// Country    : Japan
// Date       : 04/04/2020
// -----------------------------------

#include <bits/stdc++.h>

using namespace std;
using ll = long long;

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

  ll N; cin>>N;
  if (N==2) {
    cout << 1 << endl;
    return 0;
  }
  set<int> ans;
  ans.insert(N);
  ans.insert(N-1);
  for (ll k = 2; k <= sqrt(N-1); k++) {
    if ((N-1)%k==0) {
      ans.insert(k);
      ans.insert((N-1)/k);
    }
  }
  for (ll k = 2; k <= sqrt(N); k++) {
    auto n = N;
    while (n%k==0)
      n/=k;
    if (n%k==1) {
      ans.insert(k);
    }
  }
  cout << ans.size() << endl;

  return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <iostream>
using namespace std;
int chang(char x){
    return x-'A'+10;
}
int main(){
    char a,b;
    scanf("%c %c",&a,&b);
    if(chang(a)<chang(b)){
        printf("<\n");
        //printf("\n%d<%d.",chang(a),chang(b));
    }
    else if(chang(a)>chang(b)){
        printf(">\n");
        //printf("\n%d>%d.",chang(a),chang(b));
    }
    else{
        printf("=\n");
        //printf("\n%d=%d.",chang(a),chang(b));
    }
    return 0;
}

Measured memory_bytes: 256
import math
import sys
from functools import reduce

N, M = map(int, input().split())
A = list(map(int, input().split()))

for i in range(N):
  A[i] = A[i] // 2
  
def lcm_base(x, y):
    return (x * y) // math.gcd(x, y)
  
def lcm_list(numbers):
    return reduce(lcm_base, numbers, 1)

C = lcm_list(A)
B = [0 for _ in range(N)]

for i in range(N):
  B[i] = C // A[i]
  if B[i] % 2 == 0:
    print(0)
    sys.exit()

print( (M // C + 1) // 2)

Measured memory_bytes: 29084
import Control.Applicative
import Control.Monad
import Data.List
import Data.IntSet (IntSet)
import qualified Data.IntSet as IS

main :: IO ()
main = do
  [a, b, c] <- f
  unless (a == 0 && b == 0 && c == 0) $ do
    n <- readLn
    solve (a+b+c) <$> replicateM n f >>= mapM_ print
    main
  where
    f = map read <$> words <$> getLine

solve :: Int -> [[Int]] -> [Int]
solve abc xss = map f [1 .. abc]
  where
    rms = foldl' (\s [i, j, k, r] -> if r == 0
                                     then s
                                     else IS.insert i (IS.insert j (IS.insert k s))) IS.empty xss
    bms = foldl' (\s [i, j, k, r] -> case (IS.member i rms, IS.member j rms, IS.member k rms) of
                                      (True, True, False) -> IS.insert k s
                                      (True, False, True) -> IS.insert j s
                                      (False, True, True) -> IS.insert i s
                                      _ -> s
                   ) IS.empty xss
    f x = if IS.member x bms
          then 0
          else if IS.member x rms
               then 1
               else 2



Measured memory_bytes: 5500
#include <iostream>
#include <vector>
#include <stdlib.h>
using namespace std;
int main()
{
	vector<int> v;
	int n, bnum,sum = 0;
	int s1 = 0, s2 = 0;
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> bnum;
		sum += bnum;
		v.emplace_back(bnum);
	}
	double half = sum / 2.0;
	for (int i = 0; i < n; i++) {
		if (s1 + v[i] < half) {
			s1 += v[i];
		}
		else {
			s2 = s1 + v[i];
			break;
		}
	}
	if (abs(2 * s1 - sum) > abs(2 * s2 - sum)) {
		cout << abs(2 * s2 - sum);
	}
	else {
		cout << abs(2 * s1 - sum);
	}
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < h.length; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		h[0]--;
		for (int i = 1; i < h.length; i++) {
			if (h[i - 1] < h[i]) {
				h[i]--;
			}
			if (h[i - 1] > h[i]) {
				System.out.println("No");
				return;
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 50404
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<int,int> iii;
typedef vector<int> vi;
typedef vector<ii> vii;
#define getbit(n,i) (((n)&(1LL<<(i)))!=0)
#define setbit0(n,i) ((n)&(~(1LL<<(i))))
#define setbit1(n,i) ((n)|(1LL<<(i)))
#define togglebit(n,i) ((n)^(1LL<<(i)))
#define lastone(n) ((n)&(-(n)))
#define read freopen("debug\\in.txt","r",stdin)
#define write freopen("debug\\out.txt","w",stdout)
#define fi first
#define se second
#define getI(a) scanf("%d",&a)
#define getII(a,b) scanf("%d%d",&a,&b)
#define PI (acos(-1))
#define fastread ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define MOD (1000000007)
#define asz 500005
#define pb push_back
#define ppf pop_front
#define ppb pop_back
#define pf push_front
vector<vector<ll> >res;
void recurse(ll tot,ll pos,ll prev,vector<ll>v) {
    if (pos >= tot) {
        res.pb(v);
        return;
    }
    if (pos == 0) {
        for (ll i = 1; i <= 9; i++) {
            v.pb(i);
            recurse(tot, pos + 1, i, v);
            v.erase(v.begin() + v.size() - 1);
        }
    } else {
        for (ll i = 0; i <= 9; i++) {
            if (abs(prev - i) <= 1) {
                v.pb(i);
                recurse(tot, pos + 1, i, v);
                v.erase(v.begin() + v.size() - 1);
            }
        }
    }
}
int main(){
    fastread;
    ll n,i,j,k,l;
    ll m;
    for(i=1;i<=10;i++){
        vector<ll>empty_vec;
        recurse(i,0,0,empty_vec);
    }
    /*ll sz1=res.size();
    for(i=0;i<sz1;i++){
        for(auto x: res[i])
            cout<<x;
        cout<<endl;
    }
    return 0;*/
    cin>>n;
    ll sz=res[n-1].size();
    for(i=0;i<sz;i++)
        cout<<res[n-1][i];
}

Measured memory_bytes: 23852
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <chrono>
#include <random>
#include <cmath>
using namespace std;
using namespace __gnu_pbds;
#define fastio ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define uid uniform_int_distribution<lli>
#define lli long long int
#define ff first
#define ss second
#define pb push_back
#define popf pop_front()
#define popb pop_back()
#define all(vec) vec.begin(), vec.end()
#define fol(i,a,b) for(int i=a;i<b;i++)
#define forr(x,arr) for(auto& x:arr)
#define sz(x) (x.size())
#define mod 1000000007
#define INF 1000000000000000010
#define vi vector<int>
#define vlli vector<lli>
#define endl "\n"
#define ofk order_of_key
#define fbo find_by_order
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

template<class my>
using indexed_set = tree<my,null_type,less<my>,rb_tree_tag,tree_order_statistics_node_update>;

template <class my>
inline my aabs (const my &a)   { return (a > 0)  ? a : -a;         }
inline lli gcd(lli a, lli b)   { return (b == 0) ? a : gcd(b,a%b); }
inline lli LSOne(lli k)        { return (k&(-k));                  }

inline int inv(lli o, int m = mod) {
  int b = m, u = 0, v = 1, t, a=o%m;
  while (a) {
    t = b / a;
    b -= t * a; swap(a, b);
    u -= t * v; swap(u, v);
  }
  if (u < 0) u += m;
  return u;
}
inline int add(const int &a, const int &b, int m=mod) { return ( a + b ) % m;           }
inline int sub(const int &a, const int &b, int m=mod) { return ( a - b + m ) % m;       }
inline int mul(const int &a, const int &b, int m=mod) { return int ( 1LL * a * b % m ); }
inline int mpow(int a, int b, int m=mod) {
    int ans = 1;
    a=((a%m)+m)%m;
    while (b) {
        if (b & 1) ans = mul(ans, a, m);
        a = mul(a, a, m);
        b >>= 1;
    }
    return ans;
}

void tejas_919()
{
    lli n, k, m, q, u=0, v=0, temp=1, max1=-1, max2=-1, ans=0, a, b, val=0;
    cin>>n;
    multiset<int> se;
    fol(i,0,n)
    {
        cin>>temp;
        auto itr=se.lower_bound(temp);
        if(itr!=se.begin()) se.erase(--itr);
        se.insert(temp);
    }
    cout<<se.size()<<endl;
}

int main()
{
    fastio cout<<endl;
    cout << fixed << setprecision(10);
    int t=1;
    //cin>>t;
    while(t--)
        tejas_919();
}


Measured memory_bytes: 4992
'use strict'

function Main(input) {
  const a = Number(input.split(' ')[0]);
  const b = Number(input.split(' ')[1]);

  const dif = b - a;
  let lowtower = 0;

  for(let i=dif; i>0; i--) {
    lowtower += i;
  }

  console.log(lowtower - b);

}

Main(require("fs").readFileSync("/dev/stdin", "utf8").trim());

Measured memory_bytes: 21064
A, B, K = map(int, input().split())

for i in range(K):
    if i % 2 == 0:
        if A % 2 == 1: A -= 1
        B += A // 2
        A //= 2
    else:
        if B % 2 == 1: B -= 1
        A += B // 2
        B //= 2

print(A, B)

Measured memory_bytes: 2940
(let* ((n (read-line))
    (m (princ-to-string (+ (parse-integer n) 1)))
    (ans 0))
(if (= (length n)1)
    (setq ans n)
    (progn
        (if (not (string= (subseq m 0 1) (subseq n 0 1)))
            (setq ans 1)
        )
        (if (string= (subseq n 0 1) "1")
            (incf ans (* (- (length n) 1) 9))
            (incf ans (+ (* (- (length n) 1) 9) (- (parse-integer (subseq n 0 1))1)))
        )
    )
)
(format t "~A~%" ans)
)

Measured memory_bytes: 24424
#include<stdio.h>
int main()
{
	int a, b;
	scanf("%d %d", &a, &b);
	int ans = 0;
	int c = 1;
	if (1 == b)
	{
		printf("%d", ans);
		return 0;
	}
	while (true)
	{
		c += a - 1;
		ans++;
		if (c>=b)
		{
			printf("%d", ans);
			return 0;
		}

	}

}



Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define mfill(x,y) memset(x,y,sizeof(x))
#define all(v) v.begin(), v.end()
#define in(x,y,h,w) if(0<=x&&x<h&&0<=y&&y<w)
#define y0 y12345
#define y1 y54321

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

using ul = unsigned long;
using ll = long long;
using P = pair<int, int>;
using vint = vector<int>;using vvint = vector<vector<int>>;
using vll = vector<ll>;using vvll = vector<vector<ll>>;
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;}
template <class T>void initvv(vector<vector<T> > &v, int a, int b, const T &t = T()){
	v.assign(a, vector<T>(b, t));
}
template <class T>T gcd(T &a, T &b){if(a<b){swap(a,b);} T r = a%b; while(r!=0){a=b;b=r;r=a%b;} return b;}

vint dx = {-1, 0, 1, 0}, dy = {0, -1, 0, 1};
vint dx8 = {-1, -1, -1, 0, 1, 1, 1, 0}, dy8 = {-1, 0, 1, 1, 1, 0, -1, -1};

int main() {
	cin.tie(0);
   	ios::sync_with_stdio(false);
	debug("debug test\n");
   	int n,m;cin>>n;
	vll a(n);
	rep(i, n){
		cin>>a[i];
	}
	sort(all(a));
	rep(i, n-1){
		if(a[i]==a[i+1]){
			cout << "NO" << endl;
			return 0;
		}	
	}
	cout << "YES" << endl;
	return 0;
}


Measured memory_bytes: 1792
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 K = sc.nextInt();

        int ans = 0;
        int oneNum = Math.min(A,K);
        ans += oneNum;
        K -= oneNum;
        int zeroNum = Math.min(B,K);
        K -= zeroNum;
        int minusOneNum = Math.min(C,K);
        ans -= minusOneNum;
        System.out.println(ans);
    }
}



Measured memory_bytes: 35760
#include <algorithm>
#include <cmath>
#include <deque>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <utility>
#include <vector>
#define MOD 1000000007
using namespace std;
typedef long long ll;
#include <cstring>

int main() {
  ll x, k, d;
  cin >> x >> k >> d;
  if (x > 0 && k > x / d) {
    k -= x / d;
    x -= x / d * d;
  } else if (x > 0) {
    cout << x - k * d << endl;
    return 0;
  } else if (k > abs(x / d)) {
    k -= abs(x / d) + 1;
    x += (abs(x / d) + 1) * d;
  } else {
    cout << abs(x + k * d) << endl;
    return 0;
  }
  if (k % 2 == 0) {
    cout << x << endl;
  } else {
    cout << abs(x - d) << endl;
  }
}

Measured memory_bytes: 3572
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using ld = long double;
using pint = pair<int,  int>;
using pll = pair<ll, ll>;
using edge = pair<int, ll>;
using graph = vector<vector<int>>; 
using WeightedGraph = vector<vector<edge>>;
const ll INF = 1LL << 60;
const int INF32 = 1 << 29;
const ll MOD = 1000000007;

int main() {
  ll n,m;
  cin >> n >> m;
  ll num = (1LL<< m);
  ll t = 1900*m + 100*(n-m);
  ll ans= t*num;
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
	string str, head;
	cin >> str;
	int ans = 0, len = str.length();

	for(int i = 0; i < len / 2 - 1; i++) {
		head.push_back(str[0]);
		str.erase(str.begin());

		int flag = 1;
		for(int j = 0; j < head.length(); j++) {
			if(head[j] != str[j]) {
				flag = 0;
				break;
			}
		}
		if(flag) ans = head.length();
	}

	cout << ans * 2 << endl;

	return 0;
}

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

using namespace std;

#define rep(i, n) for(int i=0; i<(n); ++i)
#define all(c) (c).begin(), (c).end()

int main(){
    int N, M, P;
    while(cin >> N >> M >> P, N|M|P){
        M--;
        vector<int> X(N);
        rep(i, N)cin >> X[i];
        cout << (X[M]? accumulate(all(X), 0) * (100 - P) / X[M]: 0) << '\n';
    }
    return 0;
}

Measured memory_bytes: 1196
#include<bits/stdc++.h>
using namespace std;
#define eps 1e-9
#define For(i,a,b) for(int i=a;i<=b;i++)
#define Fore(i,a,b) for(int i=a;i>=b;i--)
#define lson l,mid,rt<<1
#define rson mid+1,r,rt<<1|1
#define mkp make_pair
#define pb push_back
#define siz size()
#define met(a,b) memset(a,b,sizeof(a))
#define iossy ios::sync_with_stdio(false),cin.tie(0),cout.tie(0)
#define fr freopen
#define pi acos(-1.0)
#define Vector Point
#define fir first
#define sec second
#define endl '\n'
typedef pair<int,int> pii;
typedef unsigned long long ull;
const long long linf=1LL<<62;
const int iinf=1000000009;
const double dinf=1e15;
const int Mod=1e9+9;
const int base=228;
typedef long long ll;
typedef long double ld;
struct Solver {
	int n;
	int a[20005];
	void solve(){
		iossy;
		cin>>n;
		For(i,1,n) cin>>a[i];
		sort(a+1,a+1+n);
		int ans=0;
		For(i,1,n-1) ans+=a[i];
		ans+=a[n]/2;
		cout<<ans<<endl;
	}
};
int main(){
//	p[0]=1;
//	For(i,1,500005) p[i]=p[i-1]*base;
//	while(scanf("%d",&n)!=EOF) solve();
	int t=1;
	Solver solver;
	solver.solve();
	return 0;
}


Measured memory_bytes: 256
s = list(input())
k = int(input())
candidate = []
for i in range(len(s)):
    for j in range(k+1):
        candidate.append(s[i:i+j])
for i in range(len(candidate)):
    candidate[i] = "".join(candidate[i])
candidate = list(set(candidate))
def sort_key(x):
    while len(x) < 5:
        x += "_"
    return x
candidate.sort(key = sort_key)
print(candidate[k])

Measured memory_bytes: 6132
#include <algorithm>
#include <cstdio>
const int INFN = 1e9+7;
const int MAXC = 3;
const int MAXN = 1e5+5;
int C[MAXN][MAXC];
int dp[MAXN][MAXC];
int N;

int solve() {
  for (int j = 0; j < MAXC; ++j) {
    dp[0][j] = 0;
  }
  for (int i = 0; i < N; ++i) {
    for (int j = 0; j < MAXC; ++j) {
      int nxt = (j + 1) % MAXC;
      int prv = (j + 2) % MAXC;
      dp[i+1][nxt] = std::max(dp[i][j] + C[i+1][nxt], dp[i+1][nxt]);
      dp[i+1][prv] = std::max(dp[i][j] + C[i+1][prv], dp[i+1][prv]);
    }
  }
  return *std::max_element(dp[N], dp[N] + MAXC);
}

int main() {
  scanf("%d", &N);
  for (int i = 1; i <= N; ++i) {
    for (int j = 0; j < MAXC; ++j) {
      scanf("%d", &C[i][j]);
      dp[i][j] = 0;
    }
  }
  printf("%d\n", solve());
  return 0;
}

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

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

using namespace std;

int main(){
    int N, T, i, temp = 10000;
    array<int, 100> c, t;
    cin >> N >> T;
    REP(i, N){
        cin >> c[i] >> t[i];
        if(t[i] <= T){
            temp = min(c[i], temp);
        }
    }
    if(temp > 1000){
        cout << "TLE" << endl;
    } else{
        cout << temp << endl;
    }
    return 0;
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
#define rep(i,n) for(long long i=0;i<(long long)(n);i++)
#define REP(i,k,n) for(long long i=k;i<(long long)(n);i++)
#define all(a) a.begin(),a.end()
#define eb emplace_back
#define lb(v,k) (lower_bound(all(v),k)-v.begin())
#define ub(v,k) (upper_bound(all(v),k)-v.begin())
#define fi first
#define se second
#define pi M_PI
#define PQ(T) priority_queue<T>
#define SPQ(T) priority_queue<T,vector<T>,greater<T>>
using ll=long long;
using P=pair<ll,ll>;
using PP=tuple<ll,ll,ll>;
using S=multiset<ll>;
using vi=vector<ll>;
using vvi=vector<vi>;
using vvvi=vector<vvi>;
const ll inf=1001001001001001;
const int INF=1001001001;
const int mod=1000000007;
const double eps=1e-10;
template<class T> bool chmin(T&a,T b){if(a>b){a=b;return true;}return false;}
template<class T> bool chmax(T&a,T b){if(a<b){a=b;return true;}return false;}
template<class T> void out(T a){cout<<a<<'\n';}
template<class T> void outp(T a){cout<<'('<<a.fi<<','<<a.se<<')'<<'\n';}
template<class T> void outvp(T v){rep(i,v.size())cout<<'('<<v[i].fi<<','<<v[i].se<<')';cout<<'\n';}
template<class T> void outv(T v){rep(i,v.size()){if(i)cout<<' ';cout<<v[i];}cout<<'\n';}
template<class T> void outvv(T v){rep(i,v.size())outv(v[i]);}
template<class T> bool isin(T x,T l,T r){return (l)<=(x)&&(x)<=(r);}
template<class T> void YesNo(T b){if(b)out("Yes");else out("No");}
void decimal(int x){cout<<fixed<<setprecision(x);}
//ll GCD(ll a,ll b){if(b==0) return a; return GCD(b,a%b);}
//ll LCM(ll a,ll b){return(a/GCD(a,b))*(b/GCD(a,b))*GCD(a,b);}
ll POW(ll a,ll b){a%=mod;if(b==0)return 1;if(b&1)return a*POW(a,b-1)%mod;ll k=POW(a,b/2);return k*k%mod;}
vi calc(ll x){vi res;while(x>0){res.eb(x%10);x/=10;}reverse(all(res));return res;}

void solve(){
  ll n; cin>>n;
  vi ans(10005,0);
  REP(i,1,200)REP(j,1,200)REP(k,1,200){
    ll p=i*i+j*j+k*k+i*j+j*k+k*i;
    if(0<=p&&p<=10001) ans[p]++;
  }
  REP(i,1,n+1) out(ans[i]);
}

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


Measured memory_bytes: 3640
#include <iostream>
#include <string>
#include <algorithm>
#include <cctype>
using namespace std;

int main(int argc, char const *argv[]) {
  int A, B;
  string S;
  cin >> A >> B;
  cin >> S;

  int n = A + B + 1;

  bool tf = false;

  if (S[A] == '-') {
    int len = 0;
    for (int i = 0; i < S.size(); i++) {
      len++;
    }
    if (len == n) {
      S.erase(S.begin() + A);
      for (int i = 0; i < S.size(); i++) {
        if (isdigit(S[i])) {
          tf = true;
        }
        else {
          tf = false;
          break;
        }
      }
    }
    else tf = false;
  }
  else tf = false;

  if (tf) cout << "Yes" << endl;
  else cout << "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 a = sc.next();
      int count =0;

      for(int i =0;i<3;i++){
        if(a.charAt(i)=='1'){
          count++;
        }
      }

      System.out.println(count);
  }
}

Measured memory_bytes: 21844
#include<iostream>
#include<cstdio>
#include<cstring>
#include <cstdlib>  
#include <math.h>
#include <cmath>
#include<cctype>
#include<string>
#include<set>
#include<iomanip>
#include <map>
#include<algorithm>
#include <functional>
#include<vector>
#include<climits>
#include<stack>
#include<queue>
#include<bitset>
#include <deque>
#include <climits>
#include <typeinfo>
#include <utility> 
using namespace std;
using ll = long long;
template<typename T>using min_priority_queue = priority_queue<T, vector<T>, greater<T>>;
const ll inf = 1145141919810364364LL;
#define all(x) (x).begin(),(x).end()
#define puts(x) cout << x << endl
#define rep(i,m,n) for(ll i = m;i < n;++i)
#define pb push_back
#define fore(i,a) for(auto &i:a)
#define rrep(i,m,n) for(ll i = m;i >= n;--i)

int X;
int dp[101010];

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

	cin >> X;
	dp[0] = 1;
	for (int i = 100; i <= 105; i++) {
		for (int j = X; j >= 0; j--) {
			if (!dp[j])continue;
			int temp = 0;
			while (j + temp <= X) {
				dp[j + temp] = 1;
				temp += i;
			}
		}
	}

	puts(dp[X]);

	return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
  ll N,A,B;
  cin >> N >> A >> B;
  ll now,next;
  cin >> now;
  
  ll ans = 0;
  for(int i = 0; i < N-1; i++){
    cin >> next;
    ans += min(abs(now - next)*A, B);
    now = next;
  }
  
  cout << ans << endl;
}



Measured memory_bytes: 256
N=int(input())
A=list(map(int,input().split()))
maxA=max(A)
count=[0]*(maxA+1)
for x in A:
    count[x]+=1
maxc=0
for i in range(2,maxA+1):
    maxc = max(maxc,sum(count[i::i]))

if maxc==N:
    print('not coprime')
elif maxc<=1:
    print('pairwise coprime')
else:
    print('setwise coprime')

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

vector <int> g[100000];
int bef[100000];
int edge[100000];
int len[100000];
int n,m;

int main(){
	scanf("%d%d",&n,&m);
	for(int i=0;i<m;i++){
		int x,y;
		scanf("%d%d",&x,&y);
		x--;y--;
		g[x].push_back(y);
		edge[y]++;
	}
	memset(bef,-1,sizeof(bef));
	stack <int> s;
	for(int i=0;i<n;i++) if(edge[i]==0) s.push(i);
	while(!s.empty()){
		int x=s.top();s.pop();
//		printf("%d %d\n",x+1,len[x]);
		for(int i=0;i<g[x].size();i++){
			int to=g[x][i];
			if(len[to]<len[x]+1){
				len[to]=len[x]+1;
				bef[to]=x;
			}
			edge[to]--;
			if(edge[to]==0) s.push(to);
		}
	}
	
	printf("%d",*max_element(len,len+n));
	return 0;
}

Measured memory_bytes: 6912
#include <iostream>
#include <cmath>
#include <vector>
#include <string>
#include <map>
#include <algorithm>
#include <numeric>
#include <fstream>
#include <iomanip>

typedef long double ld;
typedef long long ll;
const ll INF = (ll)1e18 + 1;
const ll MOD = 1e9 + 7;

// Split
namespace util {

std::vector< std::string > split(std::string s, char delimiter)
{
  std::vector< std::string > vs;
  std::string sub;
  for (auto c : s) {
    if (c == delimiter) vs.push_back(sub), sub.clear();
    else sub += c;
  }
  vs.push_back(sub);
  return vs;
}

} // namespace util

// Minimum, Maximum
template<class T> T minimum(T head, T tail) { return std::min(head, tail); }
template<class H, class... T> H minimum(H head, T... tail) { return std::min(head, minimum(tail...)); }
template<class T> T maximum(T head, T tail) { return std::max(head, tail); }
template<class H, class... T> H maximum(H head, T... tail) { return std::max(head, maximum(tail...)); }

// Output
template<class T, class S> std::ostream& operator << (std::ostream& os, std::pair<T, S> p)
{
  return os << p.first << " " << p.second;
}

template<class T> std::ostream& operator << (std::ostream& os, std::vector< T > v)
{
  for (ll i = 0; i < (ll)v.size(); i++){ os << " [" << i << "]" << v[i]; if (i % 10 == 9) os << std::endl; }
  return os;
}

template<class T, class S> std::ostream& operator << (std::ostream& os, std::vector< std::pair<T, S> > vp)
{
  ll i = 0;
  for (auto p : vp){os << " [" << i++ << "]" << p.first << " " << p.second; if (i % 10 == 0) os << std::endl;}
  return os;
}

void print(){ std::cout << std::endl; }
template<typename H> void print(H head) { std::cout << head << std::endl; }
template<typename H, typename... T> void print(H head, T... tail){ std::cout << head << " ", print(tail...); }

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

  ll N, M;
  std::cin >> N >> M;

  std::vector< ll > vk(M, 0LL);
  std::vector< std::vector<ll> > vs(M);
  for (ll i = 0; i < M; i++) {
    std::cin >> vk[i];
    for (ll j = 0; j < vk[i]; j++) {
      ll s;
      std::cin >> s;
      vs[i].push_back(s-1);
    }
  }

  std::vector< ll > vp(M, 0LL);
  for (ll i = 0; i < M; i++) {
    std::cin >> vp[i];
  }

  ll ans = 0LL;
  for (ll S = 0; S < std::pow(2, N); S++) {
    bool judge = true;
    for (ll i = 0; i < M; i++) {
      ll cnt = 0LL;
      for (auto j : vs[i]) {
	if (S & (1 << j)) {
	  cnt++;
	}
	//if (S == 2) print(S, i, j, S & (1 << j), cnt);
      }
      if (cnt % 2 != vp[i]) {
	judge = false;
      }
    }
    if (judge == true) ans++;
  }

  print(ans);
  return 0;
}


Measured memory_bytes: 256
n, m, l = map(int, input().split())
A = []
B = []
for i in range(n):
    A.append(list(map(int, input().split())))
for j in range(m):
    B.append(list(map(int, input().split())))
for i in range(n):
    ci = []
    for k in range(l):
        sum = 0
        for j in range(m):
            sum += A[i][j] * B[j][k]
        ci.append(sum)
    print(" ".join(map(str, ci)))


Measured memory_bytes: 6308
#include<bits/stdc++.h>
using namespace std;
#define IO ios_base::sync_with_stdio(false)
#define ll long long
ll a[200060],b[300000];
vector<ll>v;
map<ll,ll>mp,mp1;
int main()
{
    IO;
    ll i, j, m, k, l=0, g=0, mod,t,tc, n,mn=INT_MAX; ll kk=100;
           cin>>n>>m>>k;
           if(k<m)l=k;
           else l=m-1;
           cout<<(n*l)/m<<endl;
    return 0;
}


Measured memory_bytes: 3604
#include<iostream>

using namespace std;

int main(){
    int A, B;
    cin >> A >> B;
    if( A % 3 == 0 || B % 3 == 0 || (A+B) % 3 == 0){
        cout << "Possible" << endl;
    }  else{
        cout << "Impossible" << endl;
    }
}

Measured memory_bytes: 256
num = list(map(int, input().split()))
age = []

for i in num:
    if i == 1:
        for j in num:
            if j == 9:
                for k in num:
                    if k == 7:
                        for l in num:
                            if l == 4:
                                bool = True

if bool == True:
    print('YES')
else:
    print('NO')
                    
        

Measured memory_bytes: 2940
S = list(input())

while len(S) != 0:
    if "".join(S[-5:]) == "dream" or "".join(S[-5:]) == "erase":
        del S[-5:]
    elif "".join(S[-6:]) == "eraser":
    #elif "".join(a[-6:]) == "eraser":
        del S[-6:]
    elif "".join(S[-7:]) == "dreamer":
        del S[-7:]
    else:
        break
    
if len(S) == 0:
    print("YES")
else:
    print("NO")


Measured memory_bytes: 3956
#include <iostream>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <queue>
#include <stack>

using namespace std;

typedef long long int ll;
typedef pair<int, int> Pii;

const ll mod = 1000000007;

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

  int n, m;
  cin >> n >> m;
  vector<ll> a(n), b(m);
  for (auto &x: a) cin >> x;
  for (auto &x: b) cin >> x;

  sort(a.rbegin(), a.rend());
  sort(b.rbegin(), b.rend());

  a.push_back(0); // sentinel
  b.push_back(0); // sentinel

  ll ans = 1;
  ll vacancy = 0;
  int pa = 0;
  int pb = 0;
  for (ll i = n * m; i > 0; i--) {
    if (a[pa] == i && b[pb] == i) {
      pa++;
      pb++;
      vacancy += pa + pb - 1;
      //ans = ans * 1;
      vacancy--;
    }
    else if (a[pa] == i) {
      pa++;
      vacancy += pb;
      ans = (ans * pb) % mod;
      vacancy--;
    }
    else if (b[pb] == i) {
      pb++;
      vacancy += pa;
      ans = (ans * pa) % mod;
      vacancy--;
    }
    else {
      ans = (ans * vacancy) % mod;
      vacancy--;
    }
    if (vacancy < 0) break;
  }

  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <stdio.h>

int main() {
  int n, k, q;
  scanf("%d%d%d", &n, &k, &q);
  int a[q], b[n];
  for (int i = 0; i < n; i++) {
    b[i] = k-q;
  }
  for (int i=0; i<q; i++) {
    scanf("%d", a+i);
    b[a[i]-1]++;
  }
  for (int i=0; i<n; i++) {
    if (b[i] > 0) {
      printf("Yes\n");
    }else {
      printf("No\n");
    }
  }
  return 0;
}


Measured memory_bytes: 1280
#include<iostream>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<utility>
#include<algorithm>
#include<cstdio>
#include<iomanip>
#include<queue>
#include<stack>

#define ll int64_t
#define Rep(i, n) for (ll i = 0; i < n; i++)

using namespace std;

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

    ll A, B;
    cin >> A >> B;
    cout << (B-1 + A-1 -1) / (A-1) << endl;
}

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

bool dfs1(int v, int prev, vector<vector<int>>& g, vector<bool>& visited, vector<bool>& f) {
    visited[v] = true;
    bool res = false;
    for(auto to : g[v]) {
        if(to == prev) {
            continue;
        }
        if(visited[to]) {
            res = true;
        } else {
            res |= dfs1(to, v, g, visited, f);
        }
    }
    return f[v] = res;
}

int dfs2(int v, vector<vector<int>>& g, vector<bool>& f, int sum, vector<int> const& w) {
    sum += w[v];
    f[v] = true;
    int res = sum;
    for(auto to : g[v]) {
        if(!f[to]) {
            res = max(res, dfs2(to, g, f, sum, w));
        }
    }
    return res;
}

int main() {
    int N, M;
    cin >> N >> M;
    vector<int> w(N);
    for(int i=0; i<N; ++i) {
        cin >> w[i];
    }
    vector<vector<int>> g(N);
    for(int i=0; i<M; ++i) {
        int u, v;
        cin >> u >> v;
        u--; v--;
        g[u].push_back(v);
        g[v].push_back(u);
    }
    vector<bool> visited(N);
    vector<bool> f(N);
    dfs1(0, -1, g, visited, f);
    int res = 0;
    for(int i=0; i<N; ++i) {
        if(f[i]) {
            res += w[i];
        }
    }
    int ma = 0;
    for(int i=0; i<N; ++i) {
        if(!f[i]) {
            ma = max(ma, dfs2(i, g, f, 0, w));
        }
    }
    cout << res + ma << endl;
}


Measured memory_bytes: 19660
Public Class Program
  Shared Sub Main()
    Dim s As String = Console.ReadLine()
    Dim ans As String = "Yes"
    For i As Integer = 0 To s.Length() - 1
      If (i + 1) Mod 2 = 1 Then
        If s(i) = "L" Then
          ans = "No"
          Exit For
        End If
      Else
        If s(i) = "R" Then
          ans = "No"
          Exit For
        End If
      End If
    Next
    Console.WriteLine(ans)
  End Sub
End Class

Measured memory_bytes: 19792