akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cstring>
#include <string>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <cmath>
#define FOR(i,a,b) for(int i=a;i<b;i++)
#define MA(i,j) make_pair(i,j)
#define PA pair<int,int>
#define PB push_back
#define PQ priority_queue<int>
#define PGQ priority_queue<int,vector<int>,greater<int> >
#define VE vector<int>
#define VP vector<PA>
#define YES(i) cout<<(i?"YES":"NO")<<endl
#define Yes(i) cout<<(i?"Yes":"No")<<endl
#define MOD 1000000007
#define INF 1000000007
#define PI 3.14159265358979323846
using namespace std;
//
bool F[100005];
bool p[100005];
int C[100005];
void isPrime(int x){
    if(p[x]){
      return;
    }
    if(x<2){
      p[x]=true;
      return;
    }
    if(x==2){
      F[2]=true;
      p[x]=true;
      return;
    }
    if(x%2==0){
      p[x]=true;
      return;
    }
    for(int i=3; i*i<=x; i+=2){
        if(x%i==0){
          p[x]=true;
          return;
        }
    }
    F[x]=true;
    p[x]=true;
    return;
}
int main(){
  int Q;
  cin>>Q;
  FOR(i,1,100001){
    isPrime(i);
  }
  for(int i=3;i<=99999;i+=2){
    if(F[i]&&F[(i+1)/2]){
      C[i]=C[i-2]+1;
    }else{
      C[i]=C[i-2];
    }
  }
  FOR(i,0,Q){
    int L,R;
    cin>>L>>R;
    cout<<(C[R]-C[L-2])<<endl;
  }
  return 0;
}


Measured memory_bytes: 1280
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0,i##_max=(N);i<i##_max;++i)
#define repp(i,l,r) for(int i=(l),i##_max=(r);i<i##_max;++i)
#define per(i,N) for(int i=(N)-1;i>=0;--i)
#define perr(i,l,r) for(int i=r-1,i##_min(l);i>=i##_min;--i)
#define all(arr) (arr).begin(), (arr).end()
#define SP << " " <<
#define SPF << " "
#define SPEEDUP cin.tie(0);ios::sync_with_stdio(false);
#define MAX_I INT_MAX //1e9
#define MIN_I INT_MIN //-1e9
#define MAX_UI UINT_MAX //1e9
#define MAX_LL LLONG_MAX //1e18
#define MIN_LL LLONG_MIN //-1e18
#define MAX_ULL ULLONG_MAX //1e19
  typedef long long ll;
  typedef pair<int,int> PII;
  typedef pair<char,char> PCC;
  typedef pair<ll,ll> PLL;
  typedef pair<char,int> PCI;
  typedef pair<int,char> PIC;
  typedef pair<ll,int> PLI;
  typedef pair<int,ll> PIL; 
  typedef pair<ll,char> PLC; 
  typedef pair<char,ll> PCL; 

inline void YesNo(bool b){ cout << (b?"Yes" : "No") << endl;}
inline void YESNO(bool b){ cout << (b?"YES" : "NO") << endl;}
inline void Yay(bool b){ cout << (b?"Yay!" : ":(") << endl;}

template< typename Monoid >
struct SegmentTree{
  using F = function< Monoid(Monoid, Monoid) >;
  
  int sz;
  vector< Monoid > seg;

  const F _operation;
  const F _update;
  const Monoid M1;

  //SegmentTree(n,f,M1):サイズnの初期化，fは2つの苦汗の要素をマージする二項演算，M1はモノイドの単位元
  SegmentTree(int n, const F _operation, const F _update, const Monoid &M1) : _operation(_operation), _update(_update), M1(M1){
    sz = 1;
    while(sz < n) sz<<=1;
    seg.assign(2*sz,M1);
  }

  //set(k,x):k番目の要素にxを代入
  void set(int k, const Monoid &x){
    seg[k+sz] = x;

  }
  
  //build():segTreeの構築
  void build(){
    for(int k = sz-1; k>0; --k){
      seg[k] = _operation(seg[2*k+0], seg[2*k+1]);
    }
  }

  //update(k,x):k番目の要素をxに変更
  void update(int k, const Monoid &x){
    k += sz;
    seg[k] = _update(seg[k],x);
    while(k>>=1) seg[k] = _operation(seg[2*k+0],seg[2*k+1]);
  }

  //区間[a,b)のMonoidを計算
  Monoid query(int a, int b){
    Monoid L = M1, R = M1;
    for(a += sz, b+=sz; a < b; a>>=1, b>>=1){
      if(a&1) L = _operation(L,seg[a++]);
      if(b&1) R = _operation(seg[--b],R);
    }
    return _operation(L,R);
  }

  //operator[k]:k番目の要素を返す
  Monoid operator[](const int &k) const{
    return seg[k+sz];
  }

};

struct edge{ int f,t; ll c;};
bool comp(const edge& l, const edge& r){
  return l.f < r.f;
}
const int VMAX = 1e5+10;
const int MMAX = 1e5+10;
const ll INF = 1e15;
int V,M;

int main(void){
  SPEEDUP
  cout << setprecision(15);
  cin >> V >> M;
  vector<edge> v(M);
  rep(i,M) cin >> v[i].f >> v[i].t >> v[i].c;
  sort(all(v),comp);
  SegmentTree< ll > minseg(V+1,
      [](ll a, ll b){ return min(a,b); },
      [](ll a, ll b){ return min(a,b); },
      INF);
  minseg.set(1,0);
  minseg.build();
  rep(i,M){
    ll c = minseg.query(v[i].f,v[i].t);
    minseg.update(v[i].t,c+v[i].c);
  }
  if(minseg[V]==INF)cout << -1 << endl;
  else cout << minseg[V] << endl;
  return 0;
}


Measured memory_bytes: 3840
// C++ program to construct array from
// XOR of elements of given array
#include <bits/stdc++.h>
using namespace std;

// function to construct new array
void constructXOR(int A[], int n)
{
	// calculate xor of array
	int XOR = 0;
	for (int i = 0; i < n; i++)
		XOR ^= A[i];

	// update array
	for (int i = 0; i < n; i++)
		A[i] = XOR ^ A[i];
}

// Driver code
int main()
{
	long long int n;
	cin>>n;
	int A[n];
	for(int i=0;i<n;i++)
    {
        cin>>A[i];
    }

	constructXOR(A, n);

	// print result
	for (int i = 0; i < n; i++)
		cout << A[i] << " ";
	return 0;
}


Measured memory_bytes: 4296
n,m=map(int,input().split())
ab=[]
for i in range(m):
    ab.append(list(map(int,input().split())))

    
ans=0




def dfs(start,finish):
    global ans
    finish.add(start)#もう訪れたところ
   # print(finish)
    if len(finish)==n:#全部回ってたら終了
        ans+=1#橋じゃない数
        return 
    for i in adlist[start-1]:

        if i not in finish:#通ったところに入っていないなら通れるということ   
            dfs(i,finish)

for i in range(m):
    adlist=[]
    for h in range(n):    
        adlist.append([])
    for j in range(m):
        if i!=j:
            x=ab[j][0]
            y=ab[j][1]
            adlist[x-1].append(y)
            adlist[y-1].append(x)
    finish=set()
    #print(adlist)
    dfs(1,finish)#引数がけすノード
#print(adlist)

print(m-ans)

"""
iのノードを消したときすべてのところを回れるかというう動作をn回繰り返す
こればつ
ノードを消していたから違う線を消さなければならない
だからそれぞれのはしがないと金の隣接リストを作らないイケナイ
"""

Measured memory_bytes: 3064
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include<iterator>
#include<complex>
#include<stack>
#include<sstream>
using namespace std;
typedef  long long int lint;
typedef pair<int, int> P;
typedef pair<lint, lint> LLP;
typedef pair<char, char>CP;
#define rep(i, n) for (int i = 0; i < n; i++)
#define repr(i, n) for (int i = n; i >= 0; i--)
#define sort(v) sort((v).begin(), (v).end())
#define reverse(v) reverse((v).begin(), (v).end())
#define upper(v,hoge) upper_bound(v.begin(),v.end(),hoge)
#define lower(v,hoge) lower_bound(v.begin(),v.end(),hoge)
#define llower(v,hoge) *lower_bound(v.begin(), v.end(), hoge)
#define lupper(v,hoge) *upper_bound(v.begin(), v.end(), hoge)
/*
vector<char>al(26);
al = {'a','b','c','d','e','f','g','h','i','j','k','l','m','n','o','p','q','r','s','t','u','v','w','x','y','z'};
vector<char>AL(26);
AL = {'A','B','C','D','E','F','G','H','I','J','K','L','M','N','O','P','Q','R','S','T','U','V','W','X','Y','Z'};
vector<char>NUM(10);
	NUM = { '0','1','2' ,'3' ,'4' ,'5' ,'6' ,'7' ,'8' ,'9' };
*/



int main() {
	vector<int>V(3);
	rep(i, 3) {
		cin >> V[i];
	}
	sort(V);
	cout << V[2] - V[0] << endl;
}

Measured memory_bytes: 256
#include<iostream>

using namespace std;


int main(){

	int n;
	cin >> n;

	int a,max=-1000000,min=1000000;
	long int sum=0;

	for(int i=0;i<n;i++){
		cin >> a;
		sum += a;
		if(max < a) max = a;
		if(min > a) min = a;
	}
	cout << min << " " << max << " " << sum << "\n";

	return 0;
}




Measured memory_bytes: 3112
#include<stdio.h>
#include<string.h>
#define LEN 100005

typedef struct pp{
char name[100];
int t;
} P;

P Q[LEN];
int head,tail,n;

void enqueue(P x){
Q[tail]=x;
tail=(tail+1)%LEN;
}

P dequeue(){
P x=Q[head];
head=(head+1)%LEN;
return x;
}

int min(int s,int t){return s<t?s:t;}

int main(){
int elaps=0,a,b,i;
P c;
scanf("%d %d",&n,&b);
for(i=1;i<=n;i++){
scanf("%s",Q[i].name);
scanf("%d",&Q[i].t);
}
head = 1; tail=n+1;
while(head != tail){
c=dequeue();
a=min(b,c.t);
c.t-=a;
elaps+=a;
if(c.t>0)enqueue(c);
else{
printf("%s %d\n",c.name,elaps);
}
}
return 0;
}


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

#define fo(i,s,t) for(int i = s; i <= t; ++ i)
#define fd(i,s,t) for(int i = s; i >= t; -- i)
#define bf(i,s) for(int i = head[s]; i; i = e[i].next)
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pb push_back
#define VI vector<int>
#define sf scanf
#define pf printf
#define fp freopen
#define SZ(x) ((int)(x).size())
#ifdef MPS
#define D(x...) printf(x)
#else
#define D(x...)
#endif
typedef long long ll;
typedef double db;
typedef unsigned long long ull;
const int inf = 1<<30;
const ll INF = 1ll<<60;
const db Inf = 1e20;
const db eps = 1e-9;

void gmax(int &a,int b){a = (a > b ? a : b);}
void gmin(int &a,int b){a = (a < b ? a : b);}

int main()
{
	#ifdef MPS	
		fp("1.in","r",stdin);
		fp("1.out","w",stdout);
	#endif
	ll k, a, b;
	cin >> k >> a >> b;
	if(a >= b) cout << k + 1 << endl;
	else
	{
		k -= (a-1);
		if(k%2==0) cout << max(k+1+a-1,(k/2)*b-(k/2-1)*a)<<endl;
		else cout << max(k+1+a-1, (k/2)*b-(k/2-1)*a+1) << endl;
	}
	return 0;
}

Measured memory_bytes: 256
n = int(input())
R = list()

for _ in range(n):
    R.append(int(input()))

ans = R[1] - R[0]
min_R = R[0]

for i in range(1, n):
    ans   = max(ans, R[i] - min_R)
    min_R = min(min_R, R[i])
print(ans)

Measured memory_bytes: 15580
# -*- coding: utf-8 -*-
import numpy as np
T = np.zeros(5, dtype=int)
T[0] = int(input())
T[1] = int(input())
T[2] = int(input())
T[3] = int(input())
T[4] = int(input())
res = np.argsort(T%10)
selected_index = 0
for i in range(5):
  if(T[res[i]]%10 > 0):
    selected_index = res[i]
    break
tim = (T//10 + (T%10 != 0))*10
tim[selected_index] = T[selected_index]
print(sum(tim))


Measured memory_bytes: 12504
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include<queue>
#include<map>
#include<cmath>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define FOR(i, j, limit) for(int i=j; i< limit; ++i)
#define DUMP(a) REP(d,a.size()){cout<<a[d];if(d!=a.size()-1)cout<<" ";else cout<<endl;}
#define LL long long
int INF = 2147483647;
LL LINF = 9223372036854775807;
LL MOD = 1000000007;
typedef pair<int, int>P;
typedef pair<LL, LL>PL;
typedef vector<int> vi;
typedef vector<LL> vl;


int main(){
  string s;
  cin>>s;
  int n = s.size();
  if(n==1){
    cout<<0<<endl;
    return 0;
  }

  int goo=0, paa=0, score=0;
  REP(i, n){
    if(s[i]=='g') ++goo;
    else ++paa;
  }

cout<<(n/2)-paa<<endl;
return 0;

  return 0;
}


Measured memory_bytes: 512
H,W = (int(i) for i in input().split())
N = int(input())
aini = [int(j) for j in input().split()]
al = []
for n in range(len(aini)):
	al.extend([n+1 for o in range(aini[n]) ])
ans = [al[l:l+W] for l in range(0,len(al),W)]

for m in range(H):
	if (m+2)%2!=0:
		ans[m] = ans[m][::-1]		
	print(' '.join(map(str,ans[m])))	


Measured memory_bytes: 3572
#include <bits/stdc++.h>
#define all(x) (x).begin(), (x).end()
using namespace std;
typedef long long ll;
const int MOD = 1e9 + 7;

int main() {
  int n;
  cin >> n;
  vector<int> a(n);
  ll sum = 0;
  int maxi = 0;
  for (int i = 0; i < n; i++) {
    cin >> a[i];
    maxi = max(maxi, a[i]);
    sum += a[i];
  }
  cout << (maxi / 2) + sum - maxi << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(){
     int N;
     cin>>N;
     int maxv=0;
     int sum=0;
     for(int i=0;i<N;i++){
         int H;
         cin>>H;
         if(i==0){
             maxv=H;
             sum++;
             continue;
         }
         if(maxv<=H){
             if(maxv==H){
                 sum++;
             }
             else if(maxv<H){
                 sum++;
                 maxv=H;
             }
         
     }
   
}
  cout<<sum<<endl;
}

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

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

  for (int i = 0; i < s.size(); i++) {
    if(s.at(i)=='9'){
      cout << "Yes" << endl;
      return 0;
    }
  }
  cout << "No" << endl;
}


Measured memory_bytes: 256
#include <cmath>
#include <vector>
#include <queue>
#include <iostream>
#include <bits/stdc++.h>
#define lli long long int
#define mp make_pair
#define pb push_back
using namespace std;

const lli mod = 998244353;

lli power(lli x, lli y) {
    // x %= mod;
    if (y == 0) return 1;
    // return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2)) % mod;
    return ((y % 2 == 1 ? x : 1) * power(x * x, y / 2));
}

vector <long long int> primeNumbers;

void SieveOfEratosthenes(int n){
    bool prime[n+1]; 
    memset(prime, true, sizeof(prime));
    for (int p=2; p*p<=n; p++){ 
        if (prime[p] == true) 
        { 
            for (int i=p*p; i<=n; i += p) 
                prime[i] = false; 
        } 
    } 
    for (int p=2; p<=n; p++){
      if (prime[p]){
        primeNumbers.push_back(p);
      }
    }        
}

#define MAXN 100005
// vector < vector < int >  > v(MAXN);
// int visit[MAXN];
// int d[MAXN];
// int deg[MAXN];

// void dfs(int index, int parent){
//   visit[index] = 1;
//   for(int i = 0;i<v[parent].size();i++){
//     int node = v[parent][i];
//     if(visit[node]) continue;
//     else if (!binary_search(v[index].begin(),v[index].end(),node)){
//       visit[node] = 1;
//       dfs(node,index);
//     }
//   }
// }
void pre(){
}

void solve(){
  int n,k;
  cin>>n>>k;
  int a[n];
  for(int i = 0;i<n;i++) cin>>a[i];

  // sort(a,a+n);
  vector<bool> dp(k+1);
  // memset(dp,-1,sizeof(dp));
  // dp[0] = 0;
  for(int i = 1;i<=k;i++){
    for(int j = 0;j<n;j++){
      if(a[j] <= i && dp[i - a[j]] == false){
        dp[i] = true;
      }
    }
  }
  string ans = (dp[k] == true ? "First" : "Second");
  cout<<ans;






  
}
 
 
int main(){
  ios::sync_with_stdio(0);
  cin.tie(0); cout.tie(0);
  #ifndef ONLINE_JUDGE
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
  #endif
 
  int t;
  // cin>>t;
  // scanf("%d",&t);
  t = 1;
  pre();
  while(t--){
    // cout<<
    solve();
 
    if(t>0){
      cout<<endl;
      // printf("\n");
    } 
  }
 
 
  cerr << "Time : " << (double)clock() / (double)CLOCKS_PER_SEC << "s\n";
 
  return 0;
}


Measured memory_bytes: 3800
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { 
  INIT(){cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


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

  int N = s.size();

  int A, Z;
  RREP(i, N) if(s[i] == 'A') A = i;
  REP(i, N)  if(s[i] == 'Z') Z = i;

  cout << Z-A+1 << "\n";

  return 0;
}

Measured memory_bytes: 720
#include <iostream>
#include <cstring>
#include <stdlib.h>
#include <vector>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <math.h>
#include <string>
#include <map>
#include <cstdlib>
#include <sstream>
#include <bitset>
using namespace std;

typedef long long ll;

int main()
{
    int x,y;
    cin >> x >> y;
    int ans = 0;
    if(x==1) ans += 300000;
    else if(x==2) ans += 200000;
    else if(x==3) ans+=100000;

    if(y==1) ans += 300000;
    else if(y==2) ans += 200000;
    else if(y==3) ans+=100000;

    if(x==1 && y==1) ans += 400000;
    cout << ans << endl; 




    return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define all(vec) vec.begin(),vec.end()
#define sort(vec) sort(all(vec));
using namespace std;
signed main() {
  int n,m;
  scanf("%Ld %Ld",&n,&m);
  int p[m],y[m];
  vector<int>vec[n+1];
  unordered_map<int,int>mp;
  rep(i,m) {
    scanf("%Ld %Ld",&p[i],&y[i]);
    mp[y[i]]=p[i];
    vec[p[i]].push_back(y[i]);
  }
  rep(i,n) {
    sort(vec[i+1]);
  }
  rep(i,m) {
    printf("%06Ld",mp[y[i]]);
    printf("%06Ld\n",lower_bound(all(vec[p[i]]),y[i])-vec[p[i]].begin()+1);
  }
}


Measured memory_bytes: 12580
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#include <cctype>
#include <cmath>
#include <iostream>
#include <queue>
#include <list>
#include <stack>
#include <map>
#include <numeric>
#include <set>
#include <sstream>
#include <string>
#include <vector>
using namespace std;
#define REP(i,a,n) for(int i=(a); i<(int)(n); i++)
#define rep(i,n) REP(i,0,n)
#define FOR(it,c) for(__typeof((c).begin()) it=(c).begin(); it!=(c).end(); ++it)
#define ALLOF(c) (c).begin(), (c).end()
typedef long long ll;
#define INF 100000000

vector<int> G[100005];
int val[100005];

bool visited[100005];
int mn[100005];
int mx[100005];

bool ok;

void dfs(int v){
  visited[v] = true;
  int mmx = INF;
  int mmn = -INF;
  rep(i,G[v].size()){
    int w = G[v][i];
    if(visited[w]) continue;

    dfs(w);
    mmx = min(mmx, mx[w]+1);
    mmn = max(mmn, mn[w]-1);
  }
  mx[v] = mmx;
  mn[v] = mmn;
  if(mmx < mmn) ok = false;
  if(val[v] != -INF){
    mx[v] = val[v];
    mn[v] = val[v];
  }
}
void dfs_ans(int v){
  visited[v] = true;
  rep(i,G[v].size()){
    int w = G[v][i];
    if(visited[w]) continue;

    if(mn[w] <= val[v]+1 && val[v]+1 <= mx[w]){
      val[w] = val[v]+1;
    }
    else if(mn[w] <= val[v]-1 && val[v]-1 <= mx[w]){
      val[w] = val[v]-1;
    }
    else ok = false;
    dfs_ans(w);
  }
}

int main(){
  int N;
  cin >> N;
  rep(i,N-1){
    int A, B;
    cin >> A >> B;
    A--;
    B--;
    G[A].push_back(B);
    G[B].push_back(A);
  }
  int K;
  cin >> K;
  rep(i,100005){
    val[i] = -INF;
    mn[i] = -INF;
    mx[i] = INF;
  }

  int root = -1;
  rep(i,K){
    int V, P;
    cin >> V >> P;
    V--;
    val[V] = P;
    root = V;
  }

  ok = true;
  dfs(root);


  rep(i,100005) visited[i] = false;
  dfs_ans(root);

  if(!ok){
    cout << "No" << endl;
    return 0;
  }

  rep(i,N){
    if(val[i] == -INF){
      cout << "No" << endl;
      return 0;
    }
  }
  cout << "Yes" << endl;
  rep(i,N){
    cout << val[i] << endl;
  }
  
  
  return 0;
}



Measured memory_bytes: 15488
// C.

#include <iostream>
#include <sstream>
#include <algorithm>
#include <vector>

using namespace std;

typedef long long LL;

LL calc(LL a, LL b) {
	LL r = 1LL << 32;
	for (LL i = a; i < min(a + 2020, b); ++i) {
		for (LL j = a + 1; j <= min(a + 2022, b); ++j) {
			r = min(r, (i * j) % 2019);
		}
	}
	return r;
}

int main(int argc, char *argv[]) {
	LL l, r;
	cin >> l >> r;
	LL ans = calc(l, r);
	ans = min(ans, calc(max(l, r - 2020), r));
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int num[100005];
bool judge(int n)
{
	while(n)
	{
		int b=n%10;
		if(num[b])
		{
		  	return false;
		}
	   n/=10;	  
	}
	return true;
}
int main()
{
	int N,K;
	while(scanf("%d%d",&N,&K)!=EOF)
	{
		memset(num,0,sizeof(num));
		int k;
		for(int i=0;i<K;i++)
		{
			scanf("%d",&k);
			  num[k]=1;
		}
		for(int i=N;;i++)
		{
			if(judge(i))
			{
				printf("%d\n",i);
				break;
			}
		}
	}
	return 0;
}


Measured memory_bytes: 640
#include "bits/stdc++.h"
using namespace std;
using ll     = long long;
using pii    = pair<int, int>;
using pll    = pair<ll, ll>;
using vi     = vector<int>;
using vl     = vector<ll>;
using vvi    = vector<vi>;
using vvl    = vector<vl>;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;
template <class T>
bool chmax(T &a, const T &b) {
    return (a < b) ? (a = b, 1) : 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    return (b < a) ? (a = b, 1) : 0;
}
template <class C>
void print(const C &c, std::ostream &os = std::cout) {
    std::copy(std::begin(c), std::end(c), std::ostream_iterator<typename C::value_type>(os, " "));
    os << std::endl;
}

int main() {
    int x;
    cin >> x;
    int m = x % 100;
    int n = x / 100;
    if ((m + 4) / 5 <= n) {
        cout << 1 << "\n";
    } else {
        cout << 0 << "\n";
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <math.h>

using namespace std;

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

	int x;
	vector<int> a;
	for(int i=0; i<n; i++)
	{
		cin >> x;
		a.push_back(x);
	}

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


	int t=0, ans=0;
	if(n%2 == 0) t=1;

	for(int j=0; j<n; j++)
		ans = ans + a[j]*pow(-1, j+t);

	cout << ans << endl;

	return 0;
}

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

using ll = long long;

const int MAXN = 55;
int N;
ll A[MAXN];

int main() {
	ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
	cin >> N;
	for (int i = 0; i < N; i++) {
		cin >> A[i];
	}

	pair<ll, int> mi(A[0], 0);
	pair<ll, int> ma(A[0], 0);
	for (int i = 1; i < N; i++) {
		mi = min(mi, {A[i], i});
		ma = max(ma, {A[i], i});
	}

	auto go = [&](int x, int y) -> void {
		cout << x+1 << ' ' << y+1 << '\n';
		A[y] += A[x];
	};

	cout << 2*N-1 << '\n';
	if (abs(mi.first) < abs(ma.first)) {
		for (int i = 0; i < N; i++) {
			go(ma.second, i);
		}
		for (int i = 1; i < N; i++) {
			go(i-1, i);
		}
	} else {
		for (int i = 0; i < N; i++) {
			go(mi.second, i);
		}
		for (int i = N-1; i >= 1; i--) {
			go(i, i-1);
		}
	}

	for (int i = 1; i < N; i++) {
		assert(A[i] >= A[i-1]);
	}

	return 0;
}


Measured memory_bytes: 256
@A=glob<>;@l=<>;printf sort{$a-$b}map{$x=@v=//;$v[$t=$'>>2*$_&3]+=$t&&$l[$x+=10,$_]for 0..7;$x+=abs$A[$_]-($v[$_]||1e9)for 1..3;$x-31}1..1e5

Measured memory_bytes: 14084
#include <iostream>
#include <string>
#include <sstream>
#include <algorithm>
#include <vector>
#include <utility>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
 
using namespace std;
 
#define rep(i,n) for(int i=0; i<(n); i++)
#define repc(i,s,e) for(int i=(s); i<(e); i++)
#define pb(n) push_back((n))
#define mp(n,m) make_pair((n),(m))
#define all(r) r.begin(),r.end()
#define fi first
#define se second
 
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vii;
typedef vector<ll> vl;
typedef vector<vl> vll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
 
 
const int INF = 10000000;



int main(){
	typedef pair<int,pii> pi_ii;
	int n, m;
	while(cin>>n>>m){
		if(n == 0 && m == 0) break;
		vector<pi_ii> v;
		int t, s, d;
		rep(i, m){
			cin>>t>>s>>d;
			v.pb(pi_ii(t, pii(s, d)));
		}
		sort(all(v));
		vi f(n + 1, 0);
		f[1] = 1;
		rep(i, v.size()){
			if(f[v[i].se.fi]){
				f[v[i].se.se] = 1;
			}
		}
		int ans = 0;
		for(int i = 0; i < f.size(); i++){
			if(f[i]) ans++;
		}
		cout<<ans<<endl;
	}
}

Measured memory_bytes: 1680
import java.util.*;

class Main{
    public static void main(String args[]) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();

        Integer max_len = s.length();
        int[] n_mod = new int[max_len+1];
        int[] map2019 = new int[2019];
        int pow = 1;
        for(int i=max_len-1;i>=0;i--){
            Integer num = Integer.valueOf(s.substring(i, i+1));
            Integer tmp = (num*pow + n_mod[i+1])%2019;
            n_mod[i] = tmp;
            map2019[tmp]+=1;
            pow *= 10;
            pow %= 2019;
        }

        Long count = (long)map2019[0];
        for(int i=0;i<2019;i++){
            Integer num = map2019[i];
            if(num<2)continue;
            count += num*(num-1)/2;
        }
        System.out.println(count);
    }
}


Measured memory_bytes: 46228
#include <cstdio>
#include <cstdlib>
#include <iostream>
#include <fstream>
#include <sstream>
#include <set>
#include <map>
#include <vector>
#include <list>
#include <algorithm>
#include <cstring>
#include <cmath>
#include <string>
#include <queue>
#include <bitset>		//UWAGA - w czasie kompilacji musi byc znany rozmiar wektora - nie mozna go zmienic
#include <cassert>
#include <iomanip>		//do setprecision
#include <ctime>
#include <complex>
using namespace std;

#define FOR(i,b,e) for(int i=(b);i<(e);++i)
#define FORQ(i,b,e) for(int i=(b);i<=(e);++i)
#define FORD(i,b,e) for(int i=(b)-1;i>=(e);--i)
#define REP(x, n) for(int x = 0; x < (n); ++x)
#define ALL(u) (u).begin(),(u).end()

#define ST first
#define ND second
#define PB push_back
#define MP make_pair
#define LL long long
#define ULL unsigned LL
#define LD long double

typedef pair<int, int> PII;

const double pi = 3.141592653589793238462643383279502884197169399375105820974944592307816406286208998628034825342;

LL nwd(LL a, LL b) { return b ? nwd(b, a%b) : a; }

int main()
{
	int N;
	scanf("%d", &N);
	if (N % 2 == 0)
		printf("%d %d %d\n", N / 2, N, N);
	else
	{
		FORQ(x, 1, 3500)FORQ(y, 1, 3500)
		{
			LL m = N*(LL)x*y;
			LL l = 4 * x*y - N*(LL)y - N*(LL)x;
			if (l > 0)
			{
				LL d = nwd(l, m);
				if (d == l)
				{
					printf("%lld %d %d\n", m / d, x, y);
					return 0;
				}
			}
		}
	}
	return 0;
}

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

using namespace std;

int main(void) {
	int N; cin >> N;
	vector<int> A(N), B;
	for (int i = 0; i < N - 1; i++) {
		int b; cin >> b;
		B.push_back(b);
	}

	A[0] = B[0];
	for (int i = 0; i < N - 1; i++) {
		A[i+1] = B[i];
		A[i] = min(B[i], A[i]);
	}

	int sum = 0;
	for (int i = 0; i < N; i++) {
		sum += A[i];
	}
	cout << sum << endl;

	return 0;
}

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

using namespace std;

#define f first
#define s second
#define pb push_back
#define mp make_pair
#define all(v) v.begin(), v.end()
#define sz(v) (int)v.size()

#define MOO(i, a, b) for (int i=a; i<b; i++)
#define M00(i, a) for (int i=0; i<a; i++)
#define MOOd(i,a,b) for (int i = (b)-1; i >= a; i--)
#define M00d(i,a) for (int i = (a)-1; i >= 0; i--)

#define FAST ios::sync_with_stdio(0); cin.tie(0);
#define finish(x) return cout << x << '\n', 0;
#define dbg(x) cerr << ">>> " << #x << " = " << x << "\n";
#define _<< " _ " <<

typedef long long ll;
typedef long double ld;
typedef vector<int> vi;
typedef pair<int,int> pi;
typedef pair<ld,ld> pd;
typedef vector<ll,ll> vll;
typedef pair<ll,ll> pll;

const int MAX_N = 100010;

vector<vi> adj(MAX_N);
int DP[MAX_N];
bool visited[MAX_N];

void dfs(int v) {
	if(visited[v]) return;
	visited[v] = true;
	if(adj[v].size() == 0) {
		DP[v] = 0;
	}	
	for(auto &w : adj[v]) {
		dfs(w);
		DP[v] = max(DP[v], DP[w] + 1);
	}
}


int main() { FAST
	mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
	int n, m;
	cin >> n >> m;
	M00(i, m) {
		int x, y;
		cin >> x >> y;
		x--; y--;
		adj[x].pb(y);
	}
	M00(i, n) dfs(i);
	int best = 0;
	M00(i, n) {
		best = max(best, DP[i]);
	}
	finish(best);
}


Measured memory_bytes: 7552
using System;
using System.Collections.Generic;
using System.Collections;
using System.Collections.Specialized;
using System.Linq;
using System.Text;
using System.IO;
using System.Reflection;
using static System.Math;
using System.Numerics;
static class Program{
	const int mod=(int)1e9+7;
	static void Main(){
		Sc sc=new Sc();
		int[] s=sc.Ia;
		int n=s[0],m=s[1];

		long inf=long.MaxValue>>1;
		var dp=new long[n+1][];
		for(int i=1;i<=n;i++){
			dp[i]=new long[n+1];
			for(int j=1;j<=n;j++){
				if(i!=j){dp[i][j]=inf;}
			}
		}
		for(int i=0;i<m;i++){
			var e=sc.Ia;
			dp[e[0]][e[1]]=dp[e[1]][e[0]]=e[2];
		}
		for(int i=1;i<=n;i++){
			for(int j=1;j<=n;j++){
				for(int k=1;k<=n;k++){dp[j][k]=Min(dp[j][k],dp[j][i]+dp[i][k]);}
			}
		}
		var f=sc.Ia;
		int t=sc.I;

		for(int i = 0;i<t;i++) {
			var g=sc.I;
			if(g==1){var e=sc.Ia;}
			g=sc.I;
			for(int j = 0;j<g;j++) {var e=sc.I;}
			Console.WriteLine("{0}",-1);
			if(sc.S=="NG"){break;}
			g=sc.I;
			for(int j = 0;j<g;j++) {var e=sc.I;}
		}
	}
}

public class Sc{
	public int I{get{return int.Parse(Console.ReadLine());}}
	public long L{get{return long.Parse(Console.ReadLine());}}
	public double D{get{return double.Parse(Console.ReadLine());}}
	public string S{get{return Console.ReadLine();}}
	public int[] Ia{get{return Array.ConvertAll(Console.ReadLine().Split(),int.Parse);}}
	public long[] La{get{return Array.ConvertAll(Console.ReadLine().Split(),long.Parse);}}
	public double[] Da{get{return Array.ConvertAll(Console.ReadLine().Split(),double.Parse);}}
	public string[] Sa{get{return Console.ReadLine().Split();}}
	public object[] Oa{get{return Console.ReadLine().Split();}}
	public int[] Ia2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),int.Parse);}}
	public int[] Ia3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),int.Parse);}
	public int[] Ia3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),int.Parse);}
	public long[] La2{get{return Array.ConvertAll(("0 "+Console.ReadLine()+" 0").Split(),long.Parse);}}
	public long[] La3(int a){return Array.ConvertAll((a.ToString()+" "+Console.ReadLine()).Split(),long.Parse);}
	public long[] La3(bool a,int b,bool c,int d){return Array.ConvertAll(((a?b.ToString()+" ":"")+Console.ReadLine()+(c?" "+d.ToString():"")).Split(),long.Parse);}
	public T[] Arr<T>(int n,Func<T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f();}return a;}
	public T[] Arr<T>(int n,Func<int,T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i);}return a;}
	public T[] Arr<T>(int n,Func<string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(Console.ReadLine().Split());}return a;}
	public T[] Arr<T>(int n,Func<int,string[],T> f){var a=new T[n];for(int i=0;i<n;i++){a[i]=f(i,Console.ReadLine().Split());}return a;}
}

Measured memory_bytes: 19868
#include <iostream>
 
int main(){
 
bool sub[30];
 
for(int i=0;i<30;i++)
sub[i]=false;
 
for(int i=0;i<28;i++){
int d;
std::cin>>d;
sub[d-1]=true;
}
 
for(int i=0;i<30;i++){
if(!sub[i])
std::cout<<i+1<<std::endl;
}
 
}

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

int main() {
    int n;
    cin>>n;
    ll x[n],y[n];
    rep(i,n) cin>>x[i]>>y[i];

    map<pair<ll,ll>,int> m;
    rep(i,n){
        rep(j,n){
            if(i==j) continue;
            ll p=x[i]-x[j];
            ll q=y[i]-y[j];
            m[{p,q}]++;
        }
    }

    int ma=0;
    for(auto e : m){
        ma=max(ma,e.second);
    }

    cout<<n-ma<<endl;
}




Measured memory_bytes: 384
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < n; i++)
#define rep1(i,n) for(int i = 1; i < n; i++)
#define repv(i,n) for(int i = n-1; i >= 0; i--)
#define fi first
#define sc second
#define pb push_back
using namespace std;
typedef long long ll;

char BUF[3500000];
inline void I(int&a){scanf("%d",&a);}
inline void I(int&a,int&b){scanf("%d%d",&a,&b);}
inline void I(int&a,int&b,int&c){scanf("%d%d%d",&a,&b,&c);}
inline void I(int&a,int&b,int&c,int&d){scanf("%d%d%d%d",&a,&b,&c,&d);}
inline void L(ll&a){scanf("%lld",&a);}
inline void L(ll&a,ll&b){scanf("%lld%lld",&a,&b);}
inline void L(ll&a,ll&b,ll&c){scanf("%lld%lld%lld",&a,&b,&c);}
inline void L(ll&a,ll&b,ll&c,ll&d){scanf("%lld%lld%lld%lld",&a,&b,&c,&d);}
inline void S(string&str){str.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)str.pb(BUF[i]);}
inline void SV(vector<int>&v){v.clear();scanf("%s",BUF);int s=strlen(BUF);rep(i,s)if('a'<=BUF[i]&&BUF[i]<='z')v.pb(BUF[i]-'a');else v.pb(BUF[i]-'A');}

const auto EPS = 1e-10;
const auto INF = 100000000;
const auto MOD = 1000000007;
typedef pair<ll,ll> P;

int n, m;
char a[50][50], b[50][50];

int main(){
    I(n,m);
    rep(i,n) rep(j,n) cin >> a[i][j];
    rep(i,m) rep(j,m) cin >> b[i][j];
    rep(i,n){
        rep(j,n){
            bool ok = true;
            if(i+m-1 >= n) continue;
            rep(k,m){
                rep(l,m){
                    if(a[i+k][j+l] != b[k][l]){
                        ok = false;
                        break;
                    }
                }
                if(!ok) break;
            }
            if(ok){
                cout << "Yes" << endl;
                return 0;
            }
        }
    }
    cout << "No" << endl;
}
    


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

char a[57][57];
char b[57][57];
int main(){
	int n,m;
	
	cin >> n >> m;
	
	if(n==0||m==0){
		cout << "No";
		return 0;
	}
	for(int i = 0;i < n;i++){
		for(int j = 0;j < n;j++){
			cin >> a[i][j];
		}
	}
	
	for(int i = 0;i < m;i++){
		for(int j = 0;j < m;j++){
			cin >> b[i][j];
		}
	}
	
	int flag;
	for(int i = 0;i < n-m+1;i++){
		for(int j = 0;j < n-m+1;j++){
			flag = 1;
			int k;
			for(k = i;k<i+m;k++){
				for(int l = j;l<j+m;l++){
					if(a[k][l]!=b[k-i][l-j]){
						flag = 0;
						break;
					}
				}
				if(!flag) break;
			}
			if(flag){
				cout << "Yes";
				return 0;
			}
		}
	}
	cout << "No";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int N=100005;
int a[N],n,x;
signed main(){
	scanf("%lld%lld",&n,&x);
	for (int i=1;i<=n;i++)scanf("%lld",&a[i]);
	sort(a+1,a+n+1);
	int ans=0;
	for (int i=1;i<=n;i++){
		if (x>=a[i])ans++;
		x-=min(x,a[i]);
	}
	ans-=x>0;
	printf("%lld\n",ans);
}

Measured memory_bytes: 256
#include <time.h>

#include <stdlib.h>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <cstdint>
#include <cassert>
#include <algorithm>
#include <functional>
#include <iostream>
#include <limits>
#include <vector>
#include <map>
#include <set>
#include <iomanip>
#include <numeric>
#include <cmath>
#include <bitset>

using namespace std;
const int64_t INF=10000000000000000;
template<class T>
void read_1d(std::vector<T>& a,int64_t num){
	a.reserve(num);
	for(int64_t i1=0;i1<num;i1++){
		T temp;
		cin>>temp;
		a.push_back(temp);
	}
}
template<class T>
void read_2d(std::vector<std::vector<T> >&a,int64_t x,int64_t y ){
	a.resize(x);
	for(int64_t i1=0;i1<x;i1++){
		a[i1].reserve(y);
		for(int64_t i2=0;i2<y;i2++){
			T temp;
			cin>>temp;
			a[i1].push_back(temp);
		}
	}
}
template<class InputIterator>
void debug(InputIterator first,InputIterator last){
	for(auto i1=first;i1!=last;i1++){
		cout<<(*i1)<<endl;
	}
}

int main(){
	int64_t n,m;
	cin>>n>>m;
	vector<int64_t> count;
	count.resize(n);

	for(int64_t i1=0;i1<m;i1++){
		int64_t temp1,temp2;
		cin>>temp1>>temp2;
		count[temp1-1]++;
		count[temp2-1]++;
	}
	bool possible=true;
	for(auto i1=count.begin();i1!=count.end();i1++){
		if((*i1)%2==1){
			possible=false;
		}
	}
	if(possible){
		cout<<"YES"<<endl;
	}else{
		cout<<"NO"<<endl;
	}

}

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

int main() {
	ios::sync_with_stdio(0);
	cin.tie(0); cout.tie(0);
	int x; cin >> x;
	int ans;
	for(int i = 1; i <= x; ++ i) {
		if(1LL * i * (i + 1) / 2 >= x) {
			ans = i;
			break;
		}
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 256
import sys
import math
import bisect

def solve():
    a, v = map(int, input().split())
    b, w = map(int, input().split())
    t = int(input())
    d = abs(a - b)
    if d == 0:
        return True
    if v > w and (v - w) * t >= d:
        return True
    return False

def main():
    if solve():
        print('YES')
    else:
        print('NO')

if __name__ == "__main__":
    main()


Measured memory_bytes: 9192
#include <bits/stdc++.h>
#define rep(i, n) for(long long int i = 0; i < n; i++)
#define _rep(i, m, n) for(long long int i = m; i < n; i++)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
const int N = 1000000;
const ll mod = 1000000007;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};

ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}

/*------------------------------------------------------------------*/
int SUM(ll l){
    ll sum = 0;
    ll k = 1;
    ll count = 0;
    while(sum < l){
        sum += k;
        k++;
        if(sum <= l){
            count++;
        }
    }
    return count;
}
int main(){
    ll n; cin >> n;
    ll m = n;
    map<ll,ll> factor;
    for(ll i = 2; i * i <= n; i++){
        while(n % i == 0){
            ++factor[i];
            n /= i;
        }
    }
    if(n != 1) factor[n] = 1;

    ll ans = 0;
    for(auto it : factor){
        //cout << it.first << " " << it.second << endl;
        if(it.second == 1) ans++;
        else ans += SUM(it.second);
    }
    cout << ans << endl;
}

Measured memory_bytes: 3628
#include <math.h>
#include <ctype.h>
#include <limits.h>
#include <assert.h>

#include <stack>
#include <vector>
#include <numeric>
#include <iostream>
#include <algorithm>
#include <functional>

#define nl                std::cout << "\n"
#define in(x)             std::cin  >> (x)
#define out(x)            std::cout << (x) << " "
#define err(x)            std::cerr << #x << "=" << (x) << " | "

#define inn(x)            int x; in(x)
#define rep(i, n)         for (int i =  0 ; i < (n); ++i)
#define per(i, n)         for (int i = (n) - 1; i > -1; --i)
#define repr(i, l, r)     for (int i = (l); i < (r); ++i)

#define no                puts("NO")
#define yes               puts("YES")

using ll  = long long int;
using vi  = std::vector<int>;
using ii  = std::pair<int, int>;
using iii = std::pair< ii, int>;
using vii = std::vector<ii>;

const int N = 1010101;
const int MD = 1e9 + 7;

void solve() {
    inn(n); inn(m);
    vi adj[n];
    vi inv[n];
    rep(i, m) {
        inn(x); --x;
        inn(y); --y;
        adj[x].push_back(y);
        inv[y].push_back(x);
    }

    auto dfs = [&]() {
        std::stack<int> tsort;
        bool visited[n] = {0};

        std::function<void(int)> rdfs = [&](int u) {
            visited[u] = 1;
            for (int v: adj[u]) if (!visited[v]) rdfs(v);
            tsort.push(u);
        };

        rep(i, n) if (!visited[i]) rdfs(i);

        return tsort;
    };

    auto tsort = dfs();

    int d[n] = {0};
    d[tsort.top()] = 0; tsort.pop(); 
    while (!tsort.empty()) {
        int u = tsort.top(); tsort.pop();
        for (int v: inv[u]) d[u] = std::max(d[u], d[v] + 1);
    }

    out(*std::max_element(d, d + n));
}

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

    //inn(t); repr(tc, 1, t + 1)
    solve();

    return 0;
}


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

int main(void){
    int N,num,icnt=0;
    cin>>N;
    if(N==1){
        cout<<N<<endl;
        return 0;
    }
    for(int i=1;i<=N;i++){
        int cnt=0,ii=i;
        while(ii%2==0){
            ii/=2;
            cnt++;
        }
        if(cnt>icnt){
            icnt=cnt;
            num=i;
        }
    }
    cout<<num<<endl;
    return 0;
}


Measured memory_bytes: 256
H, W = map(int, input().split())
matrix = [input() for i in range(H)]
matrix2 = [[i[j] for j in range(W)] for i in matrix if i != ''.join(['.'] * W)]
new_H = len(matrix2)
remove_col = ''.join(['.'] * new_H)
i = 0
while i < len(matrix2[0]):
  if ''.join([row[i] for row in matrix2]) == remove_col:
    list(map(lambda x: x.pop(i), matrix2))
  else:
    i += 1
 
print('\n'.join([''.join(i) for i in matrix2]))


Measured memory_bytes: 3064
import sys
sys.setrecursionlimit(10000)

def main():
    ans=[]
    while True:
        w,h=map(int,input().split())
        if w==0 and h==0:
            break
        dis=[-1,0,1]
        c=[[0]*(w+2)]
        for i in range(h):
            c.append([0]+list(map(int,input().split()))+[0])
        c.append([0]*(w+2))
        chk=[[0]*(w+2) for _ in range(h+2)]

        def dfs(x,y):
            chk[x][y]=1
            if x<=0 or y<=0 or x>=h+1 or y>=w+1 or c[x][y]==0:
                return
            for dx in dis:
                for dy in dis:
                    if chk[x+dx][y+dy]==0 and c[x+dx][y+dy]==1:
                        dfs(x+dx,y+dy)
            return

        cnt=0
        for i in range(1,h+1):
            for j in range(1,w+1):
                if chk[i][j]==0:
                    chk[i][j]=1
                    if c[i][j]==1:
                        dfs(i,j)
                        cnt+=1
        ans.append(cnt)
    for i in ans:
        print(i)

if __name__ == '__main__':
    main()


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

using namespace std;

using ll = int_fast64_t;
constexpr ll llmax = INT_FAST64_MAX; // std::numeric_limits<int_fast64_t>::max()
constexpr ll llmin = INT_FAST64_MIN; // std::numeric_limits<int_fast64_t>::min()
using ull = uint_fast64_t;
constexpr ull ullmax = UINT_FAST64_MAX; // std::numeric_limits<uint_fast64_t>::max()

#define FOR(i, b, e) for (int i = (b); i < (e); ++i)
#define RFOR(i, b, e) for (int i = ((e) - 1); (b) <= i; --i)
#define REP(i, N) for (int i = 0; i < (N); ++i)
#define RREP(i, N) for (int i = ((N) - 1); 0 <= i; --i)
#define scanInt(x) int x; scanf("%d", &(x)); getchar();
#define scanLLInt(x) ll x; scanf("%lld", &(x)); getchar();
#define scanVecInt(A, N) vector<int> A(N); REP(i, N){scanf("%d", &(A[i])); getchar();}
#define scanVecLLInt(A, N) vector<ll> A(N); REP(i, N){scanf("%lld", &(A[i])); getchar();}

int main()
{
    scanInt(A);
    scanInt(B);
    scanInt(C);
    scanInt(D);
    scanInt(E);
    array<int, 5> V = {A, B, C, D, E};
    int min_rem = 10;
    for (auto& e : V){
        min_rem = min(min_rem, (e - 1) % 10 + 1);
    }
    int sum = 0;
    for (auto& e : V){
        sum += ((e - 1) / 10 + 1) * 10;
    }
    cout << (sum - 10 + min_rem) << endl;
}


Measured memory_bytes: 256
#include<bits/stdc++.h> 
#define REP(i, b) for(int i = 0; i < (b); i++)
#define REPS(i, b) for(int i = 1; i <= (b); i++)
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
using vs = vector<string>;
using vb = vector<bool>;
const int INF = 1e9;
const int MOD = 1e9+7;

signed main()
{
    cin.tie(nullptr);
    ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(10);

    vl A(3); REP(i, 3) cin >> A[i];
    sort(ALL(A), greater<ll>());
    ll v = A[0]/2*A[1]*A[2];
    cout << A[0]*A[1]*A[2] - 2*v << endl;
}

Measured memory_bytes: 256
function Main(input){
	var temp = input.split(" ");
	var A = parseInt(temp[0]);
	var B = parseInt(temp[1]);
	var K = parseInt(temp[2]);

	var min = Math.min(A,B);
	var count = 0;
	for(var i=min;i>=1;i--){
		if(A%i===0 && B%i===0){
			count++;
		}
		if(count === K){
			console.log(i);
			break;
		}
	}
}
Main(require("fs").readFileSync("/dev/stdin", "utf8"));

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

using namespace std;

#define MP make_pair
#define PB push_back
#define f first
#define s second

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

//int dr1[] = {-1, 0, 1, 0};
//int dc1[] = {0, 1, 0, -1};
//int dr3[] = {0, 1, 2, 3, 2, 1, 0, -1, -2, -3, -2, -1, -1, 1, 0, 0};
//int dc3[] = {3, 2, 1, 0, -1, -2, -3, -2, -1, 0, 1, 2, 0, 0, -1, 1};
const int MOD = 1000000007;
const int INF = 1000000007;

ll modx(ll a)
{
    return (a%MOD+MOD)%MOD;
}

ll times(ll a, ll b)
{
    return modx(modx(a)*modx(b));
}

ll add(ll a, ll b)
{
    return modx(modx(a)+modx(b));
}

ll sub(ll a, ll b)
{
    return modx(MOD+modx(a)-modx(b));
}

ll fastExp(ll base, ll exp)
{
    if(exp == 0LL)
    {
        return 1LL;
    }

    if(exp%2==0)
    {
        return fastExp(times(base, base), exp/2);
    }
    else
    {
        return times(base, fastExp(times(base, base), exp/2));
    }
}


const int MAXN = (int)1e5+1;
int N;
ll A, B;

int main()
{
    //freopen("input.in","r",stdin);
    //freopen("output.out","w",stdout);
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> A >> B;
    ll C = __gcd(A, B);
    ll ans = 1;
    for(ll i = 2; i*i <= C; i++)
    {
        if(C%i == 0)
        {
            ans++;
            while(C%i == 0)
            {
                C/=i;
            }
        }
    }
    if(C>1)
    {
        ans++;
    }
    cout << ans;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

public class Main {

    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);

        long a = Long.parseLong(scan.next());

        scan.close();

        long n500 = a / 500;

        long amari500 = a % 500;
        long n5 = amari500 / 5;

        System.out.println(1000 * n500 + 5 * n5);
    }

}


Measured memory_bytes: 23636
N = int(input())
prog = list(map(int,input().split()))
def seq(prog,first_Ev=False):
    sign = -1 if first_Ev else 1
    if sign * prog[0] > 0:
        answer = 0
        result = prog[0]
    else:
        answer = abs(sign - prog[0])
        result = sign
    for i in prog[1:]:
        sign *= -1
        result += i
        if result * sign <= 0:
            answer += abs(sign - result)
            result = sign
    return answer
print(min(seq(prog),seq(prog,first_Ev=True)))


Measured memory_bytes: 14332
import os

def main():
	n = int(input())
	s = input()
	count = 1
	erser_count = 0
	for i in s:
		if count == len(s):
			break
		if i == s[count]:
			erser_count += 1
		count += 1
	print(n - erser_count)

if __name__ == "__main__":
	main()


Measured memory_bytes: 3316
#include <bits/stdc++.h>
#define int long long
#define pb push_back
#define double long double
#define pii pair<int, int>
#define FOR(i, a, b) for(int i = a; i < (int)(b); ++i)
#define all(x) x.begin(), x.end()
#define deb(x) cout << (#x) << " is " << (x) << endl;
const int mod = 1000 * 1000 * 1000 + 7;
using namespace std;

inline int add(int a, int b){
	a += b;
	// if(a >= mod)
    //     a -= mod;
    a %= mod;
	return a;
}
 
inline int sub(int a, int b){
    if (b < 0) {
        a /= 0;
    }
	a -= b;
	if(a < 0) {
        a += mod;
        // a /= 0;
    }
    // a %= mod;
	return a;
}

int32_t main() {
    int n, k;
    cin >> n >> k;
    int a[n + 1];
    FOR(i, 1, n + 1) {
        cin >> a[i];
    }
    int d[n + 1][k + 1];
    int p[n + 1][k + 1];
    memset(d, 0, sizeof(int) * (n + 1) * (k + 1));
    memset(p, 0, sizeof(int) * (n + 1) * (k + 1));
    FOR(i, 0, a[1] + 1) {
        d[1][i] = 1;
    }
    p[1][0] = d[1][0];
    FOR(i, 1, k + 1) {
        p[1][i] = add(p[1][i - 1], d[1][i]);
    }
    FOR(i, 2, n + 1) {
        FOR(j, 0, k + 1) {
            if (j - a[i] > 0) {
                d[i][j] = sub(p[i - 1][j], p[i - 1][j - a[i] - 1]);
            }
            else {
                d[i][j] = p[i - 1][j];
            }

            if (j > 0)
                p[i][j] = add(p[i][j - 1], d[i][j]);
            else 
                p[i][j] = d[i][j];
                
        }
    }
    cout << d[n][k];
    return 0;
}

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

int main() {
  long long n, a, b;
  cin >> a >> b >> n;
  if(b > n){
    cout << a*n/b << endl;
    return 0;
  }
  
  cout << a*(b-1)/b << endl;
  return 0;
  }

Measured memory_bytes: 3632