akhauriyash/Code-Regression huggingface dataset:
#pragma GCC optimize("O3")
#include<bits/stdc++.h>
#define rc(x) return cout<<x<<endl,0
#define pb push_back
#define in insert
#define er erase
#define fd find
#define fr first
#define sc second
typedef long long ll;
const ll INF=0x3f3f3f3f3f3f3f3f;
const ll llinf=LLONG_MAX;
const int inf=INT_MAX;
const int nmax=1e5+5;
const int mod=1e9+7;
using namespace std;
int n,i,l,r,mid;
string s[nmax];
int main()
{
    //freopen("sol.in","r",stdin);
	//freopen("sol.out","w",stdout);
	ios_base::sync_with_stdio(false);cin.tie(0);cerr.tie(0);cout.tie(0);
	cin>>n;
	cout<<0<<endl;
	cout.flush();
	cin>>s[0];
	if(s[0][0]=='V')return 0;
	l=0,r=n;
	while(1+l<=r)
	{
		mid=(l+r)/2;
		cout<<mid<<endl;
		cout.flush();
	    cin>>s[mid];
	    if(s[mid][0]=='V')return 0;
	    if((s[mid]==s[l] && (mid-l)%2==0) || (s[mid]!=s[l] && (mid-l)%2==1))l=mid;
	    else r=mid;
	}
	cout<<l<<endl;
    cout.flush();
    cin>>s[l];
    if(s[l][0]=='V')return 0;
    cout<<r<<endl;
    cout.flush();
    cin>>s[r];
    if(s[r][0]=='V')return 0;
	return 0;
}

Measured memory_bytes: 1620
a = list(map(int, input().split()))
result = [-1, -1, -1]

for i in range(a[0]+1):
   for j in range(a[0]+1-i):
      if (10000*i + 5000*j  + (a[0] - i - j )* 1000) == a[1]:
         result = [i, j, a[0] - i - j]
         break

print(' '.join(map(str, result)))

Measured memory_bytes: 3064
import java.io.*;
import java.util.regex.*;
import java.util.*;

//import java.math.*;
public class Main {
 
    public static void main(String[] args) throws java.io.IOException{
        Scanner scan = new Scanner(System.in);
      //  ArrayList <Double> student= new ArrayList <Double>(); 
//      double [] student =new double [(int)Math.pow(2, 16)-1];
     while(scan.hasNext()){
    	 String line =scan.nextLine();
    	 Pattern p = Pattern.compile("@(\\d)(.)");
    	
    	 Matcher m = p.matcher(line);
    		 while(m.find()){
    		line = m.replaceFirst(repeat("$2",Integer.parseInt(m.group(1))));
    		 m = p.matcher(line);}
    		
    	
    	 
    	 System.out.println(line);
     }
     }
    public static String repeat(String s,int n){
    	String str ="";
    //	int m =Integer.parseInt(n);
    	for(int i=0;i<n;i++){
    		str=str.concat(s);
    	}
    	return str;
    }

     }

Measured memory_bytes: 11000
from sys import stdin

lis = list(map(int, stdin.readline().split()))

if lis[0] > lis[1]:
    lis[0], lis[1] = lis[1], lis[0]
if lis[1] > lis[2]:
    lis[1], lis[2] = lis[2], lis[1]
if lis[0] > lis[1]:
    lis[0], lis[1] = lis[1], lis[0]
    
print(*lis)



Measured memory_bytes: 5604
N, K = map(int, input().split())
A = list(map(int, input().split()))
res = 0
sum = 0
for i in range(N):
  sum += A[i]
  if i-K >= 0:
    sum -= A[i-K]
  res = max(res, sum)
print(0.5*(res+K))

Measured memory_bytes: 24548
#include <bits/stdc++.h>
 
using namespace std;
 
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<ll,ll> P;
typedef vector<P> vp;
typedef vector<string> vs;
typedef vector<bool> vb;

const ll mod=1e9+7;
const ll inf=1e16;

#define rep(i,m,n) for(ll i=m;i<n;i++)
#define repr(i,m,n) for(ll i=m-1;i>=n;i--)
#define fi first
#define se second
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
#define eb(x) emplace_back(x)
#define all(x) x.begin(),x.end()
#define gll greater<ll>()

const ll mx=1e5+5;
vll a(mx,0);

void solve(){
  ll n,m;
  cin >> n >> m;
  rep(i,0,n) {
    ll x;
    cin >> x;
    a[x]++; 
  }
  
  ll ans=0;
  rep(i,0,m){
   ll j=(m-i)%m;
   if(i==j){
    ll u=0; 
    for(ll k=i;k<mx;k+=m) u+=a[k];
    ans+=u/2; 
   }else if(i<j){
    ll s=0,sx=0; 
    for(ll k=i;k<mx;k+=m) s+=(a[k]/2)*2,sx+=a[k]&1; 
    ll t=0,tx=0; 
    for(ll k=j;k<mx;k+=m) t+=(a[k]/2)*2,tx+=a[k]&1; 
    if(sx>tx){
     swap(s,t);
     swap(sx,tx); 
    }
     ans+=sx;
     tx-=sx;
     ll x=min(tx,s);
     ans+=x;
     s-=x;
     ans+=s/2;
     ans+=t/2;
   }
  }
 cout << ans << endl;
}
int main(){
   cin.tie(nullptr);
  ios::sync_with_stdio(false);
  solve();
}  

Measured memory_bytes: 3936
#include <iostream>

using namespace std;

int main(void)
{
    int A, B, sum=0, i;

    cin >> A >> B;

    for(i=1; i<=2; i++){
	if(A>B){
	    sum += A;
	    A--;
	}
	else{
	    sum += B;
	    B--;
	}
    }

    cout << sum << endl;

    return 0;
}

Measured memory_bytes: 256
import sys, bisect, math, itertools, heapq, collections
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9 + 7
eps = 10**-7


def inp():
    '''
    一つの整数
    '''
    return int(input())


def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))


def str_inp():
    '''
    文字列をリストとして読み込む
    '''
    return list(input()[:-1])


n = inp()
a = inpl()
l = [0] * (n + 1)
r = [0] * (n + 1)
l[0] = 1 - a[0]
for i in range(1, n + 1):
    l[i] = l[i - 1] * 2 - a[i]
for i in range(n - 1, -1, -1):
    r[i] = r[i + 1] + a[i + 1]
ans = 0
for i in range(n + 1):
    if min(l[i], r[i]) < 0:
        print(-1)
        exit()
    ans += min(l[i], r[i]) + a[i]
# print(l)
# print(r)
print(ans)


Measured memory_bytes: 702208
#include<bits/stdc++.h>
using namespace std;
#define pb push_back
#define ll long long int
// #define mp make_pair
#define S second
#define F first
// ll mod=1e9+7 ;
#define fastIO ios_base::sync_with_stdio(false); cin.tie(NULL);
#define input_from_file  freopen("input.txt", "r", stdin);
using namespace std::chrono; 

int main(){                fastIO
  // input_from_file
  ll n;cin>>n;ll vec[n][3];
  for(int i=0;i<n;i++) cin>>vec[i][0]>>vec[i][1]>>vec[i][2];
  ll dp[n][3];dp[0][0]=vec[0][0];dp[0][1]=vec[0][1];dp[0][2]=vec[0][2];
  for(int i=1;i<n;i++){
    dp[i][0]=vec[i][0]+max(dp[i-1][1],dp[i-1][2]);
    dp[i][1]=vec[i][1]+max(dp[i-1][2],dp[i-1][0]);
    dp[i][2]=vec[i][2]+max(dp[i-1][0],dp[i-1][1]);
  }
  cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]});
  return 0;
}

Measured memory_bytes: 8304
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>

using namespace std;

struct point {
  double x, y;
};

int main() {
  int n;
  while (cin >> n, n) {
    vector<point> ps(n);
    for (int i = 0; i < n; ++i)
      scanf("%lf,%lf", &ps[i].x, &ps[i].y);

    int cntmax = 0;
    for (int i = 0; i < 1000; ++i) {
      for (int j = 0; j < 1000; ++j) {
        double x = i * 0.01;
        double y = j * 0.01;
        int cnt = 0;
        auto f = [&](auto &v) { cnt += pow(v.x - x, 2) + pow(v.y - y, 2) <= 1; };
        for_each(ps.begin(), ps.end(), f);
        cntmax = (cntmax < cnt) ? cnt : cntmax;
      }
    }
    cout << cntmax << endl;
  }
}


Measured memory_bytes: 3224
#include "bits/stdc++.h"
using namespace std;
using ll = long long;
using Graph = vector<vector<int>>;
#define int ll
#define double long double
#define YES cout<<"YES"<<'\n'
#define NO cout<<"NO"<<'\n'
#define Yes cout<<"Yes"<<'\n'
#define No cout<<"No"<<'\n'
#define yes cout<<"yes"<<'\n'
#define no cout<<"no"<<'\n'
void YN(bool flg) {cout<<(flg?"YES":"NO")<<'\n';}
void Yn(bool flg) {cout<<(flg?"Yes":"No")<<'\n';}
void yn(bool flg) {cout<<(flg?"yes":"no")<<'\n';}
#define SORT(a) sort(a.begin(),a.end())
#define REVERSE(a) reverse(a.begin(),a.end())
#define REP(i, n) for(int i = 0; i < n; i++)
#define REPR(i, n) for(int i = n; i >= 0; i--)
#define FOR(i, m, n) for(int i = m; i < n; i++)
#define out(n) cout << n << '\n'
typedef vector<int> VI;
typedef vector<string> VS;
typedef vector<bool> VB;
typedef vector<VI> VVI;
const int MOD = 1000000007;
const long long INF = 10e10;
const double PI = acos(-1.0);
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<class T>auto MAX(const T& a) { return *max_element(a.begin(),a.end()); }
template<class T>auto MIN(const T& a) { return *min_element(a.begin(),a.end()); }
template<class T, class U>U SUM(const T& a, const U& v) { return accumulate(a.begin(),a.end(), v); }
template<class T, class U>U COUNT(const T& a, const U& v) { return count(a.begin(),a.end(), v); }
template<class T, class U>int LOWER(const T& a, const U& v) { return lower_bound(a.begin(),a.end(), v) - a.begin(); }
template<class T, class U>int UPPER(const T& a, const U& v) { return upper_bound(a.begin(),a.end(), v) - a.begin(); }
int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
int LCM(int a, int b) { int g = GCD(a, b); return a / g * b; }
int POW(int a, int n) { int r = 1; while (n > 0) { if (n & 1)r *= a; a *= a; n >>= 1; }return r; }
int isPrime(int n){if(n<2){return 0;}for(int i=2; i*i<=n; i++){if(n%i==0){return 0;}}return 1;}
/*素因数分解*/map< int, int >prime_factor(int n){map< int, int > ret;for(int i = 2; i * i <= n; i++) {while(n % i == 0) {ret[i]++;n /= i;}}if(n != 1) ret[n] = 1;return ret;}
/*約数列挙*/vector<int> divisor(int n){vector<int> v; for(int i=1; i*i<=n; i++){if(n%i==0){v.push_back(i);if(i!=n/i){v.push_back(n/i);}}}sort(v.begin(),v.end()); return v;}
//----------------ライブラリとか----------------

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

    int n,m; cin >> n >> m;
    VI a(n),b(n),c(m),d(m); REP(i,n) cin >> a[i] >> b[i]; REP(i,m) cin >> c[i] >> d[i];

    REP(i,n){
        int x = a[i] , y = b[i];
        int manhattan = INF , ans = 114514;
        REP(j,m){
            if(manhattan>abs(x-c[j])+abs(y-d[j])){
                manhattan = abs(x-c[j])+abs(y-d[j]);
                ans = j + 1;
            }
        }
        out(ans);
    }

    return 0;
}

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

int main(){
    int n, l;
    cin >> n >> l;
    vector<string> s(n);
    rep(i, n) cin >> s[i];
    sort(s.begin(), s.end());
    rep(i, n) cout << s[i];
    cout << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main(){
  int n;
  cin >> n;
  vector<long long> h(n);
  for(int i=0;i<n;i++){
    cin >> h.at(i);
  }
  int cnt=0,ans=0;
  for(int i=0;i<n-1;i++){
    if(h.at(i)>=h.at(i+1)){
      cnt++;
    }
    else{
      cnt=0;
    }
    ans=max(ans,cnt);
  }
  cout << ans << endl;
}

Measured memory_bytes: 1024
"""
def f(n):
    if n < 2:
        return 1
    else:
        return n*f(n-2)
"""
n = int(input())
if n%2 == 1:
    print(0)
else:
    n -= n%10
    res = 0
    tmp = 10
    while tmp <= n:
        res += n // tmp
        tmp *= 5
    print(res)

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

int main() {
  int N, M;
  cin >> N >> M;
  int a, b;
  vector<int> road(N);
  for (int i = 0; i < M; i++){
    cin >> a >> b;
    road.at(a-1)++;
    road.at(b-1)++;
  }
  for (int i = 0; i < N; i++)
    cout << road.at(i) << endl;
}

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

int main() {
  int n, a;
  cin >> n;
  vector<P> d;
  rep(i, n) {
    cin >> a;
    d.emplace_back(a, i+1);
  }
  sort(d.begin(), d.end());
  rep(i, n) cout << d[i].second << " ";
  cout << endl;
  return 0;
}


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

int main(){
    int a,b;
    cin >> a >> b;
    rep(i,3){
        if((i+1) != a && (i+1) != b){
            cout << i+1 << endl;
            return 0;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define booga cout << "booga" << endl
#define ll long long int
/* run this program using the console pauser or add your own getch, system("pause") or input loop */
using namespace std;

int arr[6] = {100,101,102,103,104,105};
int i;
vector<bool> pos;

bool check(int x){
	if(x < 0){
		return false;
	}
	if(x == 0){
		return true;
	}
	if(x < i){
		return pos[x];
	}
	for(int i{0};i < 6;i++){
		if(check(x-arr[i])){
			pos[x-arr[i]] = true;
			return true;
		}
	}
	pos[x] = false;
	return false;
}

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	int x;
	cin >> x;
	pos.resize(x+1,false);
	pos[0] = true;
	for(i = 1;i <= x;i++){
		pos[i] = check(i);
	}
	cout << pos[x];
	return 0;
}





Measured memory_bytes: 256
#include <stdio.h>

#include <vector>
#include <iterator>
#include <algorithm>
#include <iostream>
#include <map>
#include <string>

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

    std::map<std::string, int> S;

    int max_val = 0;
    for (int i = 0; i < N; i++) {
        std::string neko;
        std::cin >> neko;
        S[neko]++;

        if (S[neko] > max_val) {
            max_val = S[neko];
        }
    }

    for (auto e : S) {
        if (e.second == max_val) {
            std::cout << e.first << std::endl;
        }
    }

    return 0;
}

Measured memory_bytes: 25216
#include <bits/stdc++.h>
using namespace std;
int main(void){
    // Your code here!
    int m,f,b;
    cin>>m>>f>>b;
    if(b-m>f){
        cout<<"NA"<<endl;
    }else{
        cout<<max(b-m,0)<<endl;
    }
    return 0;
}




Measured memory_bytes: 3104
#include <bits/stdc++.h>
#define ALL(a) (a).begin(), (a).end()
#define RALL(a) (a).rbegin(), (a).rend()
#define pb push_back
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define rep(i, n) FOR(i, 0, n)
#define ll long long
using namespace std;

const ll P = 1000000007;
const long long INF = 1LL << 60;
int gcd(int a, int b) { return b != 0 ? gcd(b, a % b) : a; }
int lcm(int a, int b) { return a / gcd(a, b) * b; }

int main()
{
  cout << fixed << setprecision(10);
  string S;
  cin >> S;
  int N = S.size();
  int count = 0;
  stack<char> st;
  rep(i,N)
  {
    if(S[i]=='S')
    {
      st.push('S');
    }
    else
    {
      if(st.empty()==false)
      {
        st.pop();
        count ++;
      }
    }
    
  }
  cout << N - 2 * count << endl;
  return 0;
}


Measured memory_bytes: 3756
#include <bits/stdc++.h>
using namespace std;
#define fi first
#define se second
#define countof(array) (sizeof(array) / sizeof(array[0]))
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = (n)-1; i >= 0; --i)
#define rep2(i,n) for(int i = 1; i <= (n); ++i)
#define rrep2(i,n) for(int i = (n); i > 0; --i)
#define srep(i,s,n) for(int i = s; i < (n); ++i)
#define rsrep(i,s,n) for(int i = (n)-1; i >= s; --i)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend()
#define aall(a) (a), (a)+countof(a)//for array sorting
#define raall(a) (a), (a)+countof(a), greater<>()
#define show(x) cout<<#x<<" = "<<(x)<<endl;
#define vfind(v, a) find(all(v), a) != v.end()
#define yn(f) { if (f) puts("YES"); else puts("NO"); }
#define yns(f) { if (f) puts("Yes"); else puts("No"); }
#define show_ary(...) { cout<<#__VA_ARGS__<<" = "; for (const auto& x : (__VA_ARGS__)) { cout<<x<<" "; } cout<<endl; }
#define show_pair(...) cout<<#__VA_ARGS__<<" = "<<endl; for (const auto& x : (__VA_ARGS__)) { cout<<"  "<<x.fi<<" : "<<x.se<<endl; }
#define out_ary(...) { int n = (__VA_ARGS__).size(); rep(i, n) printf("%d%s", (__VA_ARGS__)[i], i != n-1 ? " " : "\n"); }
#define argmax(v) distance((v).begin(), max_element(all(v)))
#define argmin(v) distance((v).begin(), min_element(all(v)))
#define vmax(v) *max_element(all(v))
#define vmin(v) *min_element(all(v))
typedef long long int ll;
typedef pair<int, int> P;
typedef vector<P> vpair;
typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<string> vstr;
typedef vector<bool> vbool;
typedef vector<vint> vvint;
typedef vector<vll> vvll;
typedef vector<vstr> vvstr;
typedef vector<vbool> vvbool;
const ll LINF = 2000000000000000000ll;
const int INF = 1000000100;
const ll MOD = 1e9+7;


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

    long double sa, sb, sc;
    sa = sqrt((long double)a);
    sb = sqrt((long double)b);
    sc = sqrt((long double)c);
    long double res = sc-sa-sb;
    long double eps = 1.0e-14;
    if (res>0.0 && abs(res)>eps) puts("Yes"); 
    else puts("No");
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#define pb push_back
#define mp make_pair
#define ff first
#define ss second
#define ll long long int
#define mem(x) memset(x,0,sizeof(x))
#define setbits(x)  __builtin_popcount(x)
#define ull unsigned long long int
#define all(c) (c).begin(),(c).end()
#define debug(x) cout<<#x<<" :: "<<x<<endl;
#define debug2(x,y) cout<<#x<<" :: "<<x<<"\t"<<#y<<" :: "<<y<<endl;
#define cps CLOCKS_PER_SEC
#define complex cerr << "Time (in ms): " << (double)(clock() - clk) * 1000.0 / cps << '\n';
#define db double
#define endl "\n"
#define  fbo(x) find_by_order(x)
#define  ook(x) order_of_key(x)

using namespace __gnu_pbds;
using namespace std;

typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os1;
typedef tree<int, null_type, greater<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    os2;
typedef vector< int > vi;
typedef vector< vi > vvi;
typedef pair<ll,ll > ii;
typedef pair<ll,int> li;
inline void fast()
{
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
}
const ll pi=31;
const ll MOD[2] = {1187278649, 1149736019};//for double hashing
const ll mod=(ll)(1e9)+7;
ll pmod(ll x,ll n){
  ll r=1;
  while(n)
  {
    if(n&1LL)
      r=(r*x)%mod;
    x=(x*x)%mod;
    n=n/2;
  }
  return r;
}

//think recursively also
const int mxn=(int)(2e5);
vector<int>adj[mxn+1];
bool vis[mxn+1];
ll l=0;
ll a[mxn+1];
ll n,k;
vector<int>v;
vector<int>cyc;
map<ll,ll>id;
bool found=0;
void dfs(int u,int p)
{
    vis[u]=1;

    v.pb(u);
    for(auto it:adj[u])
    {
      
      if(vis[it])
        {
          if(!found)
          {
            found=1;
            cyc.pb(it);
            cyc.pb(u);
          }
          continue;
        }
        dfs(it,u);
    }
    
}
void solve()
{   
  
  cin>>n>>k;
  
  for(int i=1;i<=n;i++)
  {
    cin>>a[i];
    adj[i].pb(a[i]);
  }
  dfs(1,0);
  
  for(int i=0;i<v.size();i++){

     id[v[i]]=i;
  }
  //debug(cyc.size());
  if(found)
  {
    int a1=cyc[0];
    int a2=cyc[1];
    cyc.clear();
    while(a1!=a2)
    {
      cyc.pb(a1);
      a1=a[a1];
    }
    cyc.pb(a2);
    l=cyc.size();
  }
 //debug2(l,v.size());
  if(k<(ll)v.size())
  {
    cout<<v[k]<<endl;
    return;
  }
  //debug(v.size());
  if(found)
  {k-=((ll)v.size());
// debug(k);
  k=k%l;
  cout<<cyc[k]<<endl;
  }
  return;




  


  

 
  
}
int main()
{
   fast();
  
   // int t;
   // cin>>t;
   // for(int casee=1;casee<=t;casee++)
  {// cout<<"Case #"<<casee<<": ";
    solve();
  }
 
 
 
}


Measured memory_bytes: 44528
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <math.h>
#include <ctype.h>
#include <limits.h>	
#define inf (INT_MAX-1)
#define INF 9223372036854775807
#define sq(n) ((n)*(n))
#define rep(i,n) for(i=0;i<n;i++)
#define rev(i,n) for(i=n-1;i>=0;i--)
#define sort(a,n) qsort(a,n,sizeof(TYPE),cmp)
#define sort_r(a,n) qsort(a,n,sizeof(TYPE),cmp_r);
#define chsort(s) qsort(s,strlen(s),sizeof(char),cmp)
#define chsort_r(s) qsort(s,strlen(s),sizeof(char),char_cmp_r);
#define TYPE int
#define MEMSET(a) memset(a,0,sizeof(a))
const int mod=(int)1e09+7;

int in(void){
	int i;scanf("%d",&i);
	return i;
}
long long llin(void){
	long long i;scanf("%lld",&i);
	return i;
}
double din(void){
	double i;scanf("%lf",&i);
	return i;
}
void chin(char s[]){
	scanf("%s",s);
}
void print(int a){
	printf("%d\n",a);
}
void llprint(long long a){
	printf("%lld\n",a);
}
void dprint(double a){
	printf("%.10f\n",a);
}
void print2(int a,int b){
	printf("%d %d\n",a,b);
}
long long max(long long a,long long b){
	return a>b?a:b;
}
long long min(long long a,long long b){
	return a<b?a:b;
}
long long llabs(long long a){
	return a>0?a:-a;
}
double dmax(double a,double b){
	return a>b?a:b;
}
int cmp(const void *a,const void *b){
	return *(TYPE *)a-*(TYPE *)b;
}
int cmp_r(const void *a,const void *b){
	return *(TYPE *)b-*(TYPE *)a;
}
int char_cmp(const void *a,const void *b){
	return strcmp((char *)a,(char *)b);
}
int char_cmp_r(const void *a,const void *b){
	return strcmp((char *)b,(char *)a);
}
void swap(int *a,int *b){
	int t=*a;
	*a=*b;
	*b=t;
}

int main(void){
	int x=in(),t,f=0;
	t=x;
	while(t)f+=t%10,t/=10;
	puts(x%f?"No":"Yes");
	return 0;
}

Measured memory_bytes: 128
import java.util.Scanner;
public class Main {
	public static void main(String[] args) {
		Scanner in = new Scanner(System.in);
		int l = in.nextInt();
		int r = in.nextInt();
		
        int mod = 2019;
		// 2019の倍数が必ずある場合
		if(r-l >= mod) {
			System.out.println(0);
			in.close();
			return;
		}

		long min = Long.MAX_VALUE;
		long remain = 0;
		for ( long i = l; i < r; i++ ) {
			for ( long j = i + 1; j <= r; j++ ) {
				remain = i * j % mod;
				min = remain < min ? remain : min;
			}
		}
		System.out.println(min);
		in.close();
	}
}

Measured memory_bytes: 23380
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
//#include<boost/multiprecision/cpp_int.hpp>
//#include<boost/multiprecision/cpp_dec_float.hpp>
//namespace mp=boost::multiprecision;
//#define mulint mp::cpp_int
//#define mulfloat mp::cpp_dec_float_100
using namespace std;
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
#define max3(a,b,c) max(a,max(b,c))
#define min3(a,b,c) min(a,min(b,c))
//constexpr int MOD=1000000007;
constexpr int MOD=998244353;
#define INF (1<<30)
#define LINF (lint)(1LL<<56)
#define endl "\n"
#define rep(i,n) for(lint (i)=0;(i)<(n);(i)++)
#define reprev(i,n) for(lint (i)=(n-1);(i)>=0;(i)--)
#define Flag(x) (1<<(x))
#define Flagcount(x) __builtin_popcount(x)
#define pint pair<int,int>
#define pdouble pair<double,double>
#define plint pair<lint,lint>
#define fi first
#define se second
typedef long long lint;
int dx[8]={1,1,0,-1,-1,-1,0,1};
int dy[8]={0,1,1,1,0,-1,-1,-1};
const int MAX_N=2e5+5;

int main(void){
    int N;
    cin >> N;
    int div[101]={};
    for(int i=1;i<=N;i++){
        int now=i;
        for(int j=2;j<=N;j++) while(now%j==0) now/=j,div[j]++;
    }
    lint ans=0;
    rep(i,101) div[i]++;
    rep(i,101) if(div[i]>=75) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) if(div[i]>=15 && div[j]>=5) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) if(div[i]>=5 && div[j]>=15) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) if(div[i]>=3 && div[j]>=25) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) if(div[i]>=25 && div[j]>=3) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) for(int k=j+1;k<=100;k++) if(div[i]>=3 && div[j]>=5 && div[k]>=5) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) for(int k=j+1;k<=100;k++) if(div[i]>=5 && div[j]>=3 && div[k]>=5) ans++;
    for(int i=1;i<=100;i++) for(int j=i+1;j<=100;j++) for(int k=j+1;k<=100;k++) if(div[i]>=5 && div[j]>=5 && div[k]>=3) ans++;
    cout << ans << endl;
}

Measured memory_bytes: 3636
const int LG = 21;
const int FN = 400005;
const long long MOD = 1e9 + 7;
const long long INF = 1e9;
const long long INFLL = 1e18;

#include <bits/stdc++.h>

const double PI = acos(-1);

using namespace std;

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

#define forn(i, n) for (int (i) = 0; (i) != (n); (i)++)
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define fi first
#define se second
#define re return
#define pb push_back
#define uniq(x) sort(all(x)); (x).resize(unique(all(x)) - (x).begin())

#ifdef LOCAL
#define dbg(x) cerr << __LINE__ << " " << #x << " " << x << endl
#define ln cerr << __LINE__ << endl
#else
#define dbg(x) void(0)
#define ln void(0)
#endif // LOCAL

int cx[4] = {-1, 0, 1, 0};
int cy[4] = {0, -1, 0, 1};
string Yes[2] = {"No", "Yes"};
string YES[2] = {"NO", "YES"};
string Psb[2] = {"Impossible", "Possible"};
string psb[2] = {"impossible", "possible"};

ll inq(ll x, ll y)
{
    if (!y) re 1 % MOD;
    ll l = inq(x, y / 2);
    if (y % 2) re l * l % MOD * x % MOD;
    re l * l % MOD;
}

ll rev(ll x)
{
    return inq(x, MOD - 2);
}

bool __precomputed_combinatorics = 0;
vector<ll> __fact, __ufact, __rev;

void __precompute_combinatorics()
{
    __precomputed_combinatorics = 1;
    __fact.resize(FN);
    __ufact.resize(FN);
    __rev.resize(FN);
    __rev[1] = 1;
    for (int i = 2; i < FN; i++) __rev[i] = MOD - __rev[MOD % i] * (MOD / i) % MOD;
    __fact[0] = 1, __ufact[0] = 1;
    for (int i = 1; i < FN; i++) __fact[i] = __fact[i - 1] * i % MOD, __ufact[i] = __ufact[i - 1] * __rev[i] % MOD;
}

ll fact(int x)
{
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[x];
}

ll cnk(int n, int k)
{
    if (k < 0 || k > n) return 0;
    if (!__precomputed_combinatorics) __precompute_combinatorics();
    return __fact[n] * __ufact[n - k] % MOD * __ufact[k] % MOD;
}

signed main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    ll n;
    cin >> n;
    vi a(3 * n);
    forn(i, 3 * n) cin >> a[i];
    ll ans = 0;
    sort(all(a));
    reverse(all(a));
    for (int i = 1; i < 2 * n; i += 2) ans += a[i];
    cout << ans;
}

/* Note:
Check constants at the beginning of the code.
    N is set to 4e5 but be careful in problems with large constant factor.
    Setting N in every problem is more effective.
Check corner cases.
    N = 1
No def int long long for now.
Add something here.
*/


Measured memory_bytes: 1408
# coding: utf-8
# Your code here!
# coding: utf-8
# Your code here!
N,M=map(int,input().split())

dp=[10**9]*2**N

dp[0]=0

for _ in range(M):
    a,b=map(int,input().split())
    c=list(map(int,input().split()))
    cl=["0"]*N
    for item in c:
        cl[item-1]="1"
    plus=int(str("".join(cl)),2)
    for i in range(len(dp))[::-1]:
        if dp[i]!=10**9:
            #print(i,i|plus)
            dp[i|plus]=min(dp[i|plus],dp[i]+a)
if dp[-1]!=10**9:
    print(dp[-1])
else:
    print(-1)

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

int main(){
    int n,i;
    cin >> n;
    int button[n+1];
    button[0] = 0;
    for (i=1;i<=n;i++){
        cin >> button[i];
    }
    int bright = 1;
    int times = 0;
    int f = 0;
    while (times <= n){
        times++;
        bright = button[bright];
        if (bright == 2){
            f++;
            cout << times;
            break;
        }
    }
    if (f == 0){
        cout << -1;
    }
}

Measured memory_bytes: 640
#define rep(i, a, b) for(int i = a; i < (int)(b); i++)
#include <bits/stdc++.h>

typedef long long ll;
using namespace std;
template<class T> inline void chmax(T &a, const T &b) {if(a < b) a = b;}
template<class T> inline void chmin(T &a, const T &b) {if(a > b) a = b;}
const long long INF = 1LL<<60;

// const ll DIV = (ll)8e3+7;
const ll MAXN = (ll)8e3+7;


int main(void) {
   ll N;
   cin>>N;
   cout<<N*N<<endl;

   return 0;
}



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


int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
	
	while(test--)
	{
	    long long A,B,a,b,c=0,k,d=0,i,n,j,temp,p,m,ex1,ex2,ex3,ex4,x,y;
	    string s;
	    char s1[20];
	    cin>>s;
	    for(i=0;i<s.length();i++)
	    {
	        if(i==5 || i==13)
	        cout<<" ";
	        else cout<<s[i];
	    }
    }
    
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>

using ll = long long;

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define reps(i, x) for(int i=1;i<=(int)(x);i++)
#define rrep(i, x) for(int i=((int)(x)-1);i>=0;i--)
#define rreps(i, x) for(int i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007
#define put2darr(arr, row, col) rep(i, row) { rep(j, col) { printf("%18d", arr[i][j]); } cout << endl; }

using namespace std;

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

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

/* 1..10
 * rep:   0 1 2 3 4 5 6 7 8 9
 * reps:  1 2 3 4 5 6 7 8 9 10
 * rrep:  9 8 7 6 5 4 3 2 1 0
 * rreps: 10 9 8 7 6 5 4 3 2 1
 */

int n, m, c;
int b[20];
int a[20][20];
int main() {
    cin >> n >>m >>c;
    rep(i, m){
        cin >> b[i];
    }
    rep(i, n){
        rep(j, m){
            cin >>a[i][j];
        }
    }
    int ret = 0;
    rep(i, n) {
        int ans = c;
        rep(j, m) {
            ans += a[i][j] *b[j];
        }
        if(ans>0) ret++;
    }
    cout << ret << endl;
}




Measured memory_bytes: 256
#include <iostream>
#include <functional>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <string>
#include <set>
#include <queue>
#include <map>
using namespace std;
#define rep(i,n) for(ll i=0;i<n;i++)
#define repi(i,n) for(ll i=n-1;i>=0;i--)
#define sll(n) scanf("%lld", &n);
typedef long long ll;
static const ll max_n = 100010;
static const ll mod = 2019;
vector<ll> A(max_n);
vector<ll> B(max_n);
vector<ll> C(max_n);

vector<ll> B_num(max_n);
vector<ll> B_cum_num(max_n);

ll N, K;


int main(){
    // int u, v;
    // bool updated = alse;
    ll N, a, b, c;
    scanf("%lld", &N);
    rep(i,N){
        sll(a);
        A[i] = a;
    }
    rep(i,N){

        sll(b);
        B[i] = b;
    }
    rep(i,N){
        sll(c);
        C[i] = c;
    }

    sort(A.begin(), A.begin()+N);
    sort(B.begin(), B.begin()+N);
    sort(C.begin(), C.begin()+N);

    // cout << *(C.begin() + N-1) << " =?" << C[N-1] <<endl;
    // printf("B[N-1]=%lld\n", B[N-1]);
    B_num[N-1] = distance(lower_bound(C.begin(), C.begin()+N, B[N-1]+1), C.begin()+N);
    B_cum_num[N-1] = B_num[N-1];
    // printf("B_cumnum[%lld]=%lld, B_num[N-1]=%lld\n", N-1, B_cum_num[N-1], B_num[N-1]);
    repi(i,N-1){
        // cout <<"distance "<<i<<"="<< distance(C.begin(), lower_bound(C.begin(), C.begin()+N, B[i]+1)) << endl;
        ll num = distance(lower_bound(C.begin(), C.begin()+N, B[i]+1), C.begin()+N);
        // printf("i=%lld, num = %lld\n", i, num);
        B_num[i] = num;
        B_cum_num[i] = num + B_cum_num[i+1];
        // printf("B_cumnum[%lld]=%lld\n", i, B_cum_num[i]);
    }

    ll ans = 0;
    rep(i, N){
        ll idx = distance(B.begin(), lower_bound(B.begin(), B.begin()+N, A[i]+1));
        ans += B_cum_num[idx];
    }

    printf("%lld\n", ans);

    return 0;

}

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

using namespace std;

#define rep(i, n) for (ll i = 0; i < (n); ++i)
#define fin(ans) cout << (ans) << endl;
#define blank(ans) cout << (ans) << " ";
#define mp(p, q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()

typedef long long ll;
typedef long long lli;
typedef unsigned long long ull;
typedef long double ld;
typedef string str;

typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<ld> vd;
typedef vector<str> vs;
typedef vector<ll> vll;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<ll, str>> vpls;
typedef vector<tuple<str, ll, ll>> vtsl;
typedef vector<vector<ll>> vvll;
typedef vector<vector<char>> vvc;
typedef vector<vector<str>> vvs;

const ld PI = acos(-1.0);
const ll MAX = 9000000000000000000;
const ll MIN = -9000000000000000000;
const ld DMAX = 4500;
const ld DMIN = -4500;
const ll MOD = 1000000007;

//実行部
void Main()
{
  str s; cin >> s;
  for(ll i = 1;i < s.size();i++)
  {
    if(s[i-1] == 'A'&&s[i] == 'C')
    {
      fin("Yes") exit(0);
    }
  }
  fin("No")
  return;
}

//前処理
int main()
{
  //ios::sync_with_stdio(false);
  //cin.tie(0);
  cout << fixed << setprecision(20); //高精度少数表示
  Main();
  return 0;
}


Measured memory_bytes: 256
MAP = {
  1 => 2,
  2 => 5,
  3 => 5,
  4 => 4,
  5 => 5,
  6 => 6,
  7 => 3,
  8 => 7,
  9 => 6,
}

def match_matching(n, nums)
  dp = Array.new(n, nil)
  dp[0] = 0
  1.upto(n) do |i|
    nums.each do |num|
      j = i - MAP[num]
      next if j < 0 || dp[j].nil?
      dp[i] = [dp[i].to_i, dp[j] + 1].max
    end
  end

  remain_length = dp[n]
  ans = 0
  match = n
  while match > 0
    nums.reverse_each do |num|
      if match - MAP[num] >= 0 && dp[match - MAP[num]] == remain_length - 1
        ans = ans * 10 + num
        match -= MAP[num]
        remain_length -= 1
        break
      end
    end
  end
  ans
end

n, m = gets.split.map(&:to_i)
nums = gets.split.map(&:to_i)

puts match_matching(n, nums.sort)

Measured memory_bytes: 5884
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
typedef long long ll;
typedef pair<int, int> P;
typedef pair<long long, long long> Pll;
typedef vector<int> vi;
typedef vector<vector<int>> vvi;
typedef vector<long long> vll;
typedef vector<vector<long long>> vvll;
const long long INF = 1LL << 60;
const int INT_INF = 1 << 30;
const double PI = acos(-1.0);

int main() {
    int n, m;
    cin >> n >> m;
    vvi path(n + 1, vi(n + 1));
    rep(i, m){
        int a, b;
        cin >> a >> b;
        path[a][b] = 1;
        path[b][a] = 1;
    }
    vi junban(n);
    rep(i, n){
        junban[i] = i + 1;
    }
    int ans = 0;
    do{
        bool flag = true;
        rep(i, n - 1){
            if (i == 0 && junban[i] != 1) flag = false;
            if (!path[junban[i]][junban[i + 1]]) flag = false;
        }
        if (flag) ans++;
    } while (next_permutation(all(junban)));
    
    cout << ans << endl;
}


Measured memory_bytes: 3604
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<stack>
#include<string>
#include<map>
#include<tuple>


#define MOD 1000000007
#define rep(i,k,N) for(int i=k;i<N;i++)
#define MP make_pair
#define MT make_tuple //tie,make_tuple は別物
#define PB push_back

typedef long long ll;

using namespace std;

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

int main(){
    ll N;
    cin>>N;
    ll table[10][10] = {};
    rep(i,1,N+1){
        int d = i%10;
        int u = i;
        while(u>=10)u/=10;
        table[u][d]++;
    }
    ll ans = 0;
    rep(i,0,10){
        rep(j,i,10){
            if(i == j)ans += table[i][j] * table[j][i];
            else {ans += table[i][j] * table[j][i]*2;}
        }
    }

    cout<<ans;
    return 0;
}

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

using ull = unsigned long long;
using ll = long long;
using ld = long double;

const int mod = 1e9 + 7;
const int inf = INT_MAX;

class UnionFind {
public:
    int n;
    vector<int> p, r;

    UnionFind(): n(), p(), r() {}
    UnionFind(int n): n(n), p(n), r(n) {
        iota(p.begin(), p.end(), 0);
    }
    int size() const {
        return n;
    }
    int find(int x) {
        return x == p[x] ? x : p[x] = find(p[x]);
    }
    bool merge(int x, int y) {
        int l1 = find(x);
        int l2 = find(y);

        if (l1 == l2)
            return false;
        if (r[l1] > r[l2])
            p[l2] = l1;
        else if (r[l1] < r[l2])
            p[l1] = l2;
        else {
            p[l2] = l1;
            r[l1]++;
        }
        n--;
        return true;
    }
};

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

    int n, m;
    cin >> n >> m;

    UnionFind uf(n);
    while (m--) {
        int a, b;
        cin >> a >> b; --a; --b;
        uf.merge(a, b);
    }

    cout << uf.size() - 1 << '\n';
    return 0;
}

Measured memory_bytes: 3992
#include <bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
#define db(x) (cerr << #x << ": " << (x) << '\n')
#define cps CLOCKS_PER_SEC
#define tests(t) int t; cin >> t; while(t--)
#define iceil(n, x) (((n) + (x) - 1) / (x))
#define eb emplace_back
#define pb push_back
#define pf push_front
#define pob pop_back
#define pof pop_front
#define sz size()
#define all(v) (v).begin(), (v).end()
#define uni(v) sort(all(v)), (v).erase(unique(all(v)), (v).end())
#define fi first
#define se second
#define bitcount(x) __builtin_popcount(x)
#define bit(x) (1LL << x)
#define PI acos(-1.0)
#define EPS 1e-9

#define mod 1000000007
#define maxn 200005

using namespace std;

using namespace __gnu_pbds;
template<class key, class cmp = std::less<key>>
using ordered_set = tree<key, null_type, cmp, rb_tree_tag, tree_order_statistics_node_update>;
///All indexing is 0-based
///methods: find_by_order(k); & order_of_key(k);
///To make it an ordered_multiset, use pairs of (value, time_of_insertion)
///to distinguish values which are similar

typedef long long ll;
typedef double ld;
typedef pair<ll, ll> par;

ll N,K,mark[maxn],arr[maxn],A[maxn],c;

int main()
{
    #ifdef acm
    freopen("a.in","r",stdin);
    #endif // acm
    ios_base::sync_with_stdio(0);
    cin.tie(0);

    cin >> N >> K;

    for(int i=1;i<=N;i++)
        cin >> A[i];
    ll pos = 1;
    while(!mark[pos] && c<K){
        mark[pos]=++c;
        arr[c] = pos;
        pos = A[pos];
    }

    if(c==K){
        cout << pos << "\n";
        return 0;
    }

    ll tam = c-mark[pos]+1;
    K-=c;
    ll ini = mark[pos];
    cout << arr[ ini + K%tam ] << "\n";











}


Measured memory_bytes: 7964
#include "bits/stdc++.h"
#include "math.h"
 
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<bool> vb;
typedef vector<vb> vvb;
typedef vector<int> vin;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define rep(i,a,b) for(ll i=(a);i<(b);++i)
#define SIZE(a) int((a).size())
#define out(a) cout<<(a)<<endl;
const int INF=INT_MAX;
const int MAX = 510000;
const int MOD = 1000000007;

int main(){
  
  ll n=1,x=1;
  while(n!=0){
    ll ans=0;
    cin>>n>>x;
    if(n==0){break;}
    rep(i,1,n+1){
      rep(j,i+1,n+1){
        rep(k,j+1,n+1){
          if(i+j+k==x){ans++;}
        }
      }
    }
    cout<<ans<<endl;
  }
  
}


Measured memory_bytes: 3092
#include <iostream>
#include <algorithm>
using namespace std;
int main(){
	int n, m, x, a[100];
	cin >> n >> m >> x;
	for (int i = 0; i < m; i++) {
		cin >> a[i];
	}
	int ta = 0, iwa = 0;
	for (int i = 0; i < m; i++) {
		if (a[i] < x) {
			ta++;
		}
		else {
			iwa++;
		}
	}
	if (ta > iwa) {
		cout << iwa << endl;
	}
	else {
		cout << ta << endl;
	}
	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include<vector>
using namespace std;
#define ll long long int
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    string s1,s2;
    cin>>s1>>s2;
    if(s1.size()+1!=s2.size())
        cout<<"No\n";
    else
    {
        string s=s2.substr(0,s1.size());
        if(s==s1)
            cout<<"Yes\n";
        else
            cout<<"No\n";
    }

}


Measured memory_bytes: 3644
// #pragma GCC optimize("unroll-loops", "omit-frame-pointer", "inline")
// #pragma GCC option("arch=native", "tune=native", "no-zero-upper")
// #pragma GCC
// target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,avx2,tune=native")
// #pragma GCC optimize("Ofast")
// #pragma GCC optimize("tree-vectorize","openmp","predictive-commoning")
// #pragma GCC option("D_GLIBCXX_PARALLEL","openmp")
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef vector<int> vi;
typedef vector<ll> vll;
// #define int long long
#define pb push_back
#define mp make_pair
#define eps 1e-9
#define INF 2000000000               // 2e9
#define LLINF 2000000000000000000ll  // 2e18 (llmax:9e18)
#define fi first
#define sec second
#define all(x) (x).begin(), (x).end()
#define sq(x) ((x) * (x))
#define dmp(x) cerr << #x << ": " << x << endl;

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

template <class T>
using MaxHeap = priority_queue<T>;
template <class T>
using MinHeap = priority_queue<T, vector<T>, greater<T>>;
template <class T>
vector<T> vect(int len, T elem) {
  return vector<T>(len, elem);
}

template <class T, class U>
ostream &operator<<(ostream &os, const pair<T, U> &p) {
  os << p.fi << ',' << p.sec;
  return os;
}
template <class T, class U>
istream &operator>>(istream &is, pair<T, U> &p) {
  is >> p.fi >> p.sec;
  return is;
}
template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) {
    os << vec[i];
    if (i + 1 < vec.size()) os << ' ';
  }
  return os;
}
template <class T>
istream &operator>>(istream &is, vector<T> &vec) {
  for (int i = 0; i < vec.size(); i++) is >> vec[i];
  return is;
}
void fastio() {
  cin.tie(0);
  ios::sync_with_stdio(0);
  cout << fixed << setprecision(20);
}

#define endl "\n"

void solve() {
  int N, M;
  cin >> N >> M;
  vector<int> H(N);
  cin >> H;
  vector<vector<int>> g(N);
  for (int i = 0; i < M; i++) {
    int a, b;
    cin >> a >> b;
    a--;
    b--;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  for (int i = 0; i < N; i++) {
    bool judge = true;
    for (auto u : g[i]) {
      if (H[u] >= H[i]) judge = false;
    }
    if (judge) ans++;
  }
  cout << ans << endl;
  return;
}

signed main() {
  fastio();
  solve();
  // int t; cin >> t; while(t--)solve();

  // int t; cin >> t;
  // for(int i=1;i<=t;i++){
  //   cout << "Case #" << i << ": ";
  //   solve();
  // }
  return 0;
}


Measured memory_bytes: 8744
// 基本テンプレート
 
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <string>
#include <cstring>
#include <deque>
#include <list>
#include <queue>
#include <stack>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
#include <set>
#include <complex>
#include <cmath>
#include <limits>
#include <cfloat>
#include <climits>
#include <ctime>
#include <cassert>
#include <numeric>
#include <fstream>
#include <functional>
using namespace std;
 
#define rep(i,a,n) for(int (i)=(a); (i)<(n); (i)++)
#define repq(i,a,n) for(int (i)=(a); (i)<=(n); (i)++)
#define repr(i,a,n) for(int (i)=(a); (i)>=(n); (i)--)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define int long long int
 
template<typename T> void chmax(T &a, T b) {a = max(a, b);}
template<typename T> void chmin(T &a, T b) {a = min(a, b);}
template<typename T> void chadd(T &a, T b) {a = a + b;}
 
typedef pair<int, int> pii;
typedef long long ll;
 
int dx[] = {0, 0, 1, -1};
int dy[] = {1, -1, 0, 0};
const ll INF = 1001001001001001LL;
const ll MOD = 1000000007LL;

int N, M, S, T;

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

using Graph = vector< vector<Edge> >;

struct Elem {
    int cur, cost;
    Elem() {}
    Elem(int a, int b) : cur(a), cost(b) {}
    bool operator<(const Elem &e) const {
        return cost > e.cost;
    }
};

void solve(const Graph &G, vector<int> &dist, int start_p, int which_cost) {
    priority_queue<Elem> que;
    dist[start_p] = 0;
    que.push(Elem(start_p, 0));

    while(que.size()) {
        Elem cur_e = que.top(); que.pop();

        int u = cur_e.cur;
        if(dist[u] < cur_e.cost) continue;

        for(auto e : G[u]) {
            int cost = (which_cost == 0 ? e.yen : e.snuuk);
            int v = e.to, n_cost = cur_e.cost + cost;
            if(dist[v] > n_cost) {
                dist[v] = n_cost;
                que.push(Elem(v, n_cost));
            }
        }
    }
}
 
signed main() {
    cin >> N >> M >> S >> T; S--; T--;
    Graph G(N);
    for(int i=0; i<M; i++) {
        int u, v, a, b; cin >> u >> v >> a >> b;
        u--; v--;
        G[u].push_back(Edge(v, a, b));
        G[v].push_back(Edge(u, a, b));
    }

    vector<int> dist_y(N, INF), dist_s(N, INF);
    solve(G, dist_y, S, 0);
    solve(G, dist_s, T, 1);

    vector<int> ans(N);
    int init_yen = 1000LL * 1000LL * 1000LL * 1000LL * 1000LL;
    for(int i=0; i<N; i++) {
        ans[i] = init_yen - (dist_y[i] + dist_s[i]);
    }
    for(int i=N-2; i>=0; i--) {
        ans[i] = max(ans[i], ans[i+1]);
    }
    for(int i=0; i<N; i++) {
        cout << ans[i] << endl;
    }
    return 0;
}

Measured memory_bytes: 13056
count = gets.to_i;

aryX = gets.split(' ').map(&:to_i);
aryY = gets.split(' ').map(&:to_i);
aryZ = Array.new(count)

for index in 0..count -1 do
	aryZ[index] = (aryX[index].to_i - aryY[index].to_i).abs;
end

sumP1 = 0.to_f;
for indexP1 in 0..count - 1 do
	sumP1 = sumP1 + aryZ[indexP1].to_f;
end

sumP2 = 0.to_f;
for indexP2 in 0..count - 1 do
	sumP2 = sumP2 + aryZ[indexP2] * aryZ[indexP2];
end

sumP3 = 0.to_f;
for indexP3 in 0..count - 1 do
	sumP3 = sumP3 + aryZ[indexP3] * aryZ[indexP3] * aryZ[indexP3];
end

sumPmax = aryZ[0].to_f;
for indexPmax in 0..count - 1 do
	if sumPmax < aryZ[indexPmax] then
		sumPmax = aryZ[indexPmax];
	end
end

puts "%.6f" % sumP1;
puts "%.6f" % Math.sqrt(sumP2);
puts "%.6f" % Math.cbrt(sumP3);
puts "%.6f" % sumPmax;

Measured memory_bytes: 8880
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int cnt=0;
    string s,t;
    cin>>s>>t;
    for(int i=0;i<s.size();i++)
    {
        if (s[i]!=t[i])
            cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3852
#include <iostream>
#include <cstdio>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <stack>
#include <queue>
#include <string>
#include <utility>
#include <algorithm>
#include <functional>
#include <deque>
#define INF 1e9
#define MAX_K 1001
#define MAX_N 10001
using namespace std;

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

int N, K;

int score[MAX_K * 4][MAX_K * 4];
int sum[MAX_K * 4][MAX_K * 4];

int query(int x, int y) {
    return sum[x + K][y + K] - sum[x + K][y] - sum[x][y + K] + sum[x][y];
}

int main(){
    cin >> N >> K;
    for (int i = 1; i <= 4 * K; ++i) {
        fill(sum[i], sum[i] + 4 * K, 0);
        fill(score[i], score[i] + 4 * K, 0);
    }
    for (int i = 0; i < N; ++i) {
        int x, y;
        char c;
        cin >> x >> y >> c;
        if (c == 'W') {
            x += K;
        }
        x = x % (2 * K);
        y = y % (2 * K);
        if (x == 0)
            x = 2 * K;
        if (y == 0)
            y = 2 * K;
        score[x][y] += 1;
        score[x][y + 2 * K] += 1;
        score[x + 2 * K][y] += 1;
        score[x + 2 * K][y + 2 * K] += 1;
    }

    for (int i = 1; i <= 4 * K; ++i) {
        for (int j = 1; j <= 4 * K; ++j) {
            sum[i][j] = score[i][j] + sum[i][j - 1] + sum[i - 1][j] - sum[i - 1][j - 1];
        }
    }
    int ans = 0;
    for (int i = 1; i <= 2 * K; ++i) {
        for (int j = 1; j <= 2 * K; ++j) {
            ans = max(ans, query(i, j) + query(i + K, j + K));
        }
    }
    
    cout << ans << endl;
    
    return 0;
}


Measured memory_bytes: 125440
n = int(input())
a = list(map(int,input().split()))
l = sum(a)
b = list()
t = 0
ans = 10**10
for i in a:
    t += i
    b.append(t)
for j in b:
    x = abs(l-(2*j))
    if x < ans:
        ans = x

print(ans)

Measured memory_bytes: 26220
#include <vector>
#include <algorithm>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <iostream>
#include <cstdio>
#include <cmath>
#include <cstring>
using namespace std;
int a,b;
int main()
{while(1){
	cin>>a>>b;
if(!a&&!b) return 0;
cout<<min(a,b)<<' '<<max(a,b)<<endl;
}}

Measured memory_bytes: 1160