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

public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);
        int n = scanner.nextInt();
        int isA[] = new int[n + 1];
        int isB[] = new int[n + 1];
        int isC[] = new int[n + 1];

        {
            int m = scanner.nextInt();
            for (int i = 0; i < m; ++i) {
                int user = scanner.nextInt();
                isA[user] = 1;
            }
        }

        {
            int m = scanner.nextInt();
            for (int i = 0; i < m; ++i) {
                int user = scanner.nextInt();
                isB[user] = 1;
            }
        }

        {
            int m = scanner.nextInt();
            for (int i = 0; i < m; ++i) {
                int user = scanner.nextInt();
                isC[user] = 1;
            }
        }

        int ans = 0;
        for (int i = 1; i <= n; i++) {
            if (isA[i] == 0 && isC[i] == 1 || isB[i] == 1 && isC[i] == 1) {
                ans++;
            }
        }
        
        System.out.println(ans);

    }
}



Measured memory_bytes: 26700
#include <bits/stdc++.h>
#define ll long long
#define _n 2020
#define C continue
#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define gc getchar
#define pc putchar
#define mem(a,b) memset(a,b,sizeof(a))
#define _for(i,a,b) for( int i=(a); i<=(b); i++)
#define _rep(i,a,b) for( int i=(a); i>=(b); i--)
using namespace std;
inline int rd()
{
    int x=0,f=1;char ch=gc();
    while(ch<'0'||ch>'9'){if(ch=='-')f=-1;ch=gc();}
    while(ch>='0'&&ch<='9'){x=x*10+ch-'0';ch=gc();}
    return x*f;
}
char ch[200];
inline void rt(int x )
{
    int cnt=0,tmp=x>0?x:-x;
    if (!x) {pc('0');return;}
    if(x<0) pc('-');
    while(tmp>0) {ch[cnt++]=tmp%10+'0';tmp/=10;}
    while(cnt>0) pc(ch[--cnt]);
}
int main()
{
	long long a,b,c,d,ans1,ans2,ans;
	scanf("%lld%lld%lld%lld",&a,&b,&c,&d);
	ans1=a*c;
	ans2=b*d;
	ans=max(ans1,ans2);
	ans=max(ans,a*d);
	ans=max(ans,b*c);
	printf("%lld",ans);
    return 0;
}




Measured memory_bytes: 3780
#include <stdio.h>
int main (){
    long long int N;
    long long int total=1;
    
    scanf("%lld",&N);
    long long int A[N]; 
    
    for(int i=0;i<N;i++){
        scanf("%lld", &A[i]);
    }
    for(int j=0;j<N;j++){
        if(A[j] == 0){  
            printf("0"); 
            return 0;
        }
    }
    for(int k=0;k<N;k++){
        if(A[k]<=1000000000000000000/total){
            total = total*A[k];
            
        } else {
            printf("-1");
            return 0;
        }
    }
    printf("%lld", total);
    
    
return 0;
}

Measured memory_bytes: 2492
///////////////////////////////////////////
//                                       //
//      Gagan_Sharma : DTU               // 
//                                       //                   
///////////////////////////////////////////
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
using namespace __gnu_pbds;

#define int        long long
// #define mp      make_pair
#define eb         emplace_back
#define pb         push_back
#define ss         second
#define ff         first
#define IOS        ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define mod        998244353
#define MOD        (1000*1000*1000+7)
#define MN         LLONG_MIN
#define MX         LLONG_MAX
#define v1d        vector<int>
#define v2d        vector<vector<int>>
#define vip        vector<pair<int,int> >
#define v1s        vector<string>
#define pa         pair<int,int>
#define mxpq(T)    priority_queue <T>
#define mnpq(T)    priority_queue<T,vector<T>,greater<T>>
#define print(v)   for(auto i:v)cout<<i<<" ";cout<<"\n";
#define p2d(v)     for(auto a:v){for(auto b:a)cout<<b<<" ";cout<<endl;}
#define p1d(v)     for(auto a:v)cout<<a<<" ";cout<<endl;
#define ppd(v)     for(auto a:v)cout<<a.ff<<" "<<a.ss<<endl;
#define endl       '\n'
#define input(b,n) for(int i=0;i<n;i++)cin>>b[i];
#define Sort(v)    sort(v.begin(),v.end())
#define RSort(v)   sort(v.rbegin(),v.rend())
#define all(v)     v.begin(),v.end()
int gcd(int a,int b){return b?gcd(b,a%b):a;}
//string s = bitset<64>(a).to_string();

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
#define fbo find_by_order // iterator to the kth element
#define ook order_of_key  //number of items that are strictly smaller than our item k
// #define T pair<int, int>
// #define ordered_set tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>

void read(int n=12){
    ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
    cout<<setprecision(n)<<fixed;
    // #ifndef ONLINE_JUDGE
    //      freopen("input.txt",  "r",  stdin);
    //      freopen("output.txt", "w", stdout);
    // #endif
}

//____________________________________________________________________________________


void solve(){
    int a,b,c,d;cin>>a>>b>>c>>d;
    int turn = 1;
    while(true){
        if(turn == 1){
            c -= b;
            if(c <= 0){
                cout<<"Yes";return ;
            }
            turn = 2;
            continue;
        }
        else{
            a -= d;
            if(a <= 0){
                cout<<"No";return ;
            }
            turn = 1;
            continue;
        }
    }
    
}
 
int32_t main(){
    read();
    int t = 1;
    // cin>>t;
    while(t--){
        solve();
    }
    


    return 0;
}                                                                                         


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

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

typedef long long ll;

const int INF = 1 << 30;
const ll LLINF = 1LL << 62;

int mod = 1000000007;

int main(void){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    string S; cin >> S;
    S[5] = ' '; S[13] = ' ';
    cout << S << endl;
    return 0;
}

Measured memory_bytes: 256
n=int(input())
ab=[]
for i in range(n):
	x,y=map(int,input().split())
	ab.append([x,y])
ab=sorted(ab,key=lambda z:z[1])

a,b,f=0,0,0
for i in range(n):
	a+=ab[i][0]
	b=max(b,ab[i][1])
	if b<a:
		f=1

if f:
	print('No')
else:
	print('Yes')

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

int main(){
    int a,b,c,d;
    cin >> a >> b >> c >> d;
    if(a+b > c+d){
        cout << "Left" << endl;
    }
    else if(a+b < c+d){
        cout << "Right" << endl;
    }
    else{
        cout << "Balanced" << endl;
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long;
using ld = long double;
#define FOR(NAME, START, NUM) for (ll NAME = START; NAME < (NUM); NAME++)
#define REP(NAME, NUM) for (ll NAME = 0; NAME < (NUM); NAME++)
#define BREP(NAME, NUM) for (ll NAME = (NUM)-1; NAME >= 0; NAME--)
#define ALL(NAME) (NAME).begin(), (NAME).end()
const ll INF = 1000000000000000;

int n,a,b,c,d;
int main(){
    string s;
	cin >> n >> a >> b >> c >> d >> s;
	FOR(i,a-1,c-1){
		if(s.at(i) == '#' && s.at(i+1) == '#'){
			cout << "No" << endl;
			return 0;
		}
	}
	FOR(i,b-1,d-1){
		if(s.at(i) == '#' && s.at(i+1) == '#'){
			cout << "No" << endl;
			return 0;
		}
	}
	if(c > d){
		FOR(i,b-2,d-1){
			if(s.at(i) == '.' && s.at(i+1) == '.' && s.at(i+2) == '.'){
				cout << "Yes" << endl;
				return 0;
			}
		}
	}
	else{
		cout << "Yes" << endl;
		return 0;
	}

	cout << "No" << endl;

}


Measured memory_bytes: 640
x,y=map(int,input().split())
a=[1,3,5,7,8,10,12]
b=[4,6,9,11]
c=[2]

if (x in a and y in a) or (x in b and y in b) or (x in c and y in c):
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3060
package main

import (
  "bufio"
  "fmt"
  "os"
  "strconv"
  "math"
)

func main() {
  sc := bufio.NewScanner(os.Stdin)
  sc.Split(bufio.ScanWords)

  sc.Scan()

  n, _ := strconv.Atoi(sc.Text())

  a := make([]int64, n)
  sign := int64(1)
  var j int
  min := int64(math.MaxInt64)
  for i := 0; i < n; i++ {
    sc.Scan()
    v, _ := strconv.Atoi(sc.Text())
    if v >= 0 {
      a[i] = int64(v)
    } else {
      a[i] = -1 * int64(v)
      sign *= -1
    }
    if a[i] < min {
      min = a[i]
      j = i
    }
  }

  if sign >= 0 {
    sum := int64(0)
    for i := 0; i < n; i++ {
      sum += a[i]
    }
    fmt.Println(sum)
    os.Exit(0)
  }

  sum := int64(0)
  for i := 0; i < n; i++ {
    if i == j {
      sum -= a[i]
    } else {
      sum += a[i]
    }
  }

  fmt.Println(sum)
}


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

#define fors(xx,yy,zz) for(int xx=yy; xx<zz; xx++)
#define all(xx) xx.begin(),xx.end()
#define mod 1000000009
#define pii pair<int,int> 
typedef long long ll;

int main(){
	int n,h;
	cin>>n>>h;
	vector<int> a,b;
	for(int i=0; i<n; i++){
		int x,y;
		cin>>x>>y;
		a.push_back(x);
		b.push_back(y);
	}
	sort(a.begin(),a.end());
	reverse(a.begin(),a.end());
	sort(b.begin(),b.end());
	reverse(b.begin(),b.end());
	int cnt=0;
	for(int i=0; i<b.size(); i++){
		if(b[i]>a[0]&&h>0){
			h-=b[i];
			cnt++;
		}
		else{
			break;
		}
	}
	if(h>0)
	cnt+=(int)ceil((double)h/(double)a[0]);
	cout<<cnt;
	return 0;
}


Measured memory_bytes: 1276
#include<bits/stdc++.h>
using namespace std;
int main(){
	long long N;
	scanf("%lld",&N);

	long long ans=0;
	for(long long L=1;L<=N;L++){
		ans+= ((N-L+2)*(N-L+1))/2;
	}

	for(int i=0;i<N-1;i++){
		long long u,v;
		scanf("%lld%lld",&u,&v);

		if(u>v)swap(u,v);
		
		ans-=u*(N-v+1);
	}

	printf("%lld",ans);

	return 0;
}

Measured memory_bytes: 3836
#pragma GCC optimize("O3")
#include<bits/stdc++.h> 
using namespace std;
using ll=long long;
using P=pair<int,int>;
template<class T> using V=vector<T>; 
#define fi first
#define se second
#define all(v) (v).begin(),(v).end()
const ll inf=(1e18);
const ll mod=1000000007;
ll gcd(ll a,ll b) {return b ? gcd(b,a%b):a;}
ll lcm(ll c,ll d){return c/gcd(c,d)*d;}
struct __INIT{__INIT(){cin.tie(0);ios::sync_with_stdio(false);cout<<fixed<<setprecision(15);}} __init;
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }
ll b[51],p[51];
ll make(ll n,ll x){
   if(x==1)return (n?0:1);
   if(n==0)return 0;
   if(x<=1+b[n-1])return make(n-1,x-1);
   if(x==2+b[n-1])return p[n-1]+1;
   if(x<=b[n-1]*2+2)return p[n-1]+1+make(n-1,x-b[n-1]-2);
   return 2*p[n-1]+1;
}
int main(){
  ll n,x;
  cin>>n>>x;
  b[0]=1;p[0]=1;
  for(int i=0;i<n;i++){
      b[i+1]=b[i]*2+3;
      p[i+1]=p[i]*2+1;
  }
  cout<<make(n,x)<<endl;
}

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

int main() {
    string s;
    cin >> s;
    int head, tail;
    for (int i=0; i<s.size(); i++) {
        if (s.at(i) == 'A') {
            head = i;
            break;
        }
    }
    for (int i=s.size()-1; i>=0; i--) {
        if (s.at(i) == 'Z') {
            tail = i;
            break;
        }
    }
    cout << tail - (head - 1)  << endl;
}

Measured memory_bytes: 640
N = int(input())
B = list(map(int, input().split()))
A = [10**5] * N
A[0] = B[0]

for i in range(N-1):
    if max(A[i], A[i + 1]) > B[i]:
        if A[i] > B[i]:
            A[i] = B[i]
        A[i + 1] = B[i]
    #print("" + str(i) + ":" + str(A))
        
print(sum(A))

Measured memory_bytes: 3060
/*{{{*/
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<string>
#include<iostream>
#include<sstream>
#include<set>
#include<map>
#include<queue>
#include<bitset>
#include<vector>
#include<limits.h>
#include<assert.h>
#define SZ(X) ((int)(X).size())
#define ALL(X) (X).begin(), (X).end()
#define REP(I, N) for (int I = 0; I < (N); ++I)
#define REPP(I, A, B) for (int I = (A); I < (B); ++I)
#define FOR(I, A, B) for (int I = (A); I <= (B); ++I)
#define FORS(I, S) for (int I = 0; S[I]; ++I)
#define RS(X) scanf("%s", (X))
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define CASET int ___T; scanf("%d", &___T); for(int cs=1;cs<=___T;cs++)
#define MP make_pair
#define PB push_back
#define MS0(X) memset((X), 0, sizeof((X)))
#define MS1(X) memset((X), -1, sizeof((X)))
#define LEN(X) strlen(X)
#define F first
#define S second
using namespace std;
typedef long long LL;
typedef unsigned long long ULL;
typedef long double LD;
typedef pair<int,int> PII;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<PII> VPII;
typedef pair<LL,LL> PLL;
typedef vector<PLL> VPLL;
template<class T> void _R(T &x) { cin >> x; }
void _R(int &x) { scanf("%d", &x); }
void _R(LL &x) { scanf("%lld", &x); }
void _R(double &x) { scanf("%lf", &x); }
void _R(char &x) { scanf(" %c", &x); }
void _R(char *x) { scanf("%s", x); }
void R() {}
template<class T, class... U> void R(T &head, U &... tail) { _R(head); R(tail...); }
template<class T> void _W(const T &x) { cout << x; }
void _W(const int &x) { printf("%d", x); }
void _W(const LL &x) { printf("%lld", x); }
void _W(const double &x) { printf("%.16f", x); }
void _W(const char &x) { putchar(x); }
void _W(const char *x) { printf("%s", x); }
template<class T,class U> void _W(const pair<T,U> &x) {_W(x.F); putchar(' '); _W(x.S);}
template<class T> void _W(const vector<T> &x) { for (auto i = x.begin(); i != x.end(); _W(*i++)) if (i != x.cbegin()) putchar(' '); }
void W() {}
template<class T, class... U> void W(const T &head, const U &... tail) { _W(head); putchar(sizeof...(tail) ? ' ' : '\n'); W(tail...); }
#ifdef HOME
 #define DEBUG(...) {printf("# ");printf(__VA_ARGS__);puts("");}
#else
 #define DEBUG(...)
#endif
int MOD = 1e9+7;
void ADD(LL& x,LL v){x=(x+v)%MOD;if(x<0)x+=MOD;}
/*}}}*/
const int SIZE = 1e6+10;
VI d[SIZE];
int main(){
    priority_queue<int>AA;
    int N,M;
    R(N,M);
    FOR(i,1,N){
        int x,y;
        R(x,y);
        d[x].PB(y);
    }
    LL an=0;
    FOR(i,1,M){
        for(int x:d[i])AA.push(x);
        if(!AA.empty()){
            an+=AA.top();
            AA.pop();
        }
    }
    W(an);
    return 0;
}


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

using namespace std;
#define ll long long
#define ull unsigned long long
#define mp make_pair
typedef pair<int, int> pii;
typedef priority_queue<int, vector<int>, greater<int> > small_heap;
typedef priority_queue<int> big_heap;
int n, m, f[200009], g[200009], st[200009], top = 0;
char str[200009];
struct node {
    int v, id;
};
deque<node> q;

int main() {
    memset(g, -1, sizeof(g));
    memset(f, 0x3f, sizeof(f));
    scanf("%d%d", &n, &m);
    scanf("%s", str);
    f[0] = 0, q.push_back({f[0], 0});
    for (int i = 1; i <= n; i++) {
        while (!q.empty() && i - q.front().id > m)q.pop_front();
        if (str[i] == '1')continue;
        if (!q.empty())f[i] = q.front().v + 1, g[i] = q.front().id;
        while (!q.empty() && q.back().v > f[i])q.pop_back();
        if (f[i] != 0x3f3f3f3f)q.push_back({f[i], i});
    }
    if (g[n] == -1)return puts("-1"), 0;
    int now = n;
    while (g[now] != -1) { st[++top] = now - g[now], now = g[now]; }
    while (top) {
        printf("%d ", st[top--]);
    }
    puts("");
    return 0;
}

Measured memory_bytes: 2560
x,y,z = map(int,input().split(' '))
s = []
s.append(abs(y-x)+abs(z-y))
s.append(abs(z-x)+abs(z-y))
s.append(abs(y-x)+abs(z-x))
s.append(abs(z-x)+abs(y-z))
s.append(abs(x-z)+abs(y-x))
s.append(abs(y-z)+abs(x-y))
print(min(s))

Measured memory_bytes: 3064
#include<iostream>
#include<cstdio>
#include<map>
using namespace std;
int main(){
	int n;
	cin>>n;
	map<int,int> mp;
	for(int i = 1; i <= n; i++){
		int d;
		cin>>d;
		mp[d] = i;
	}
	for(int i = 1; i <= n; i++){
		if(i != 1)cout<<" ";
		cout<<mp[i];
	}
	cout<<endl;
	return 0;
}

Measured memory_bytes: 5504
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
#include<cstring>
#include<math.h>
#include<bitset>
#include<queue>
#include<set>
#include<iomanip>
#include<assert.h>
#include<string>
#include<cstdlib>
#include<cctype>
#include<unordered_map>
#include<sstream>
#include<numeric>
#include<stack>
// #include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<int,int>;
constexpr ll INF = 9e18;
constexpr int inf = 1e9;
const double INFD = 1e100;
const ll mod = 1000000007;
const double PI = 3.1415926535897932384626433832795028841971;
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
template<class T> inline bool chmin(T& a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template<class T> inline bool chmax(T& a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};

// intやllをstringに変換
template<typename T> inline string toString(const T &a){
  ostringstream oss;
  oss << a;
  return oss.str();
};
// ----------------------------------------------------------------------------

int main(){
  ll N,x;
  cin >> N >> x;
  vector<ll> a(N);
  vector<ll> min_a(N);
  for(int i=0; i<N; i++){
    cin >> a[i];
    min_a[i] = a[i];
  }
  ll ans = INF;
  for(ll i=0; i<N; i++){
    for(int j=0; j<N; j++){
      chmin(min_a[j],a[(j-i+N)%N]);
    }
    ll sum = 0;
    for(int j=0; j<N; j++){
      sum += min_a[j];
    }
    chmin(ans,sum+i*x);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
using ull=unsigned long long;
#define mod 1000000007
#define mod2 998244353 
#define PI 3.14159265
#define ll long long
#define ld long double
#define pi pair<ll,ll>
#define pb push_back
#define vi vector<ll>
#define sz size()
#define setbits(x)  __builtin_popcount(x)
#define fi first
#define se second
#define lz length()
#define all(x) (x).begin(),(x).end()
#define scf(x) scanf("%lld",&x)
#define rep(i,n) for(ll i=0;i<n;i++)
const int INF = (int)1e9;
const ll IINF=1LL<<62;
const int maxn=10000005;

//int divr[maxn];
/**/
/*void divisor()
{for(int i=2;i<sqrt(maxn);i++)
     {
          if(!divr[i])
          {
               for(int j=i*i;j<maxn;j+=i)if(!divr[j])divr[j]=i;     
          }
     }
     for(int i=1;i<maxn;i++)if(!divr[i])divr[i]=i;
}*/
 
/*const int N=1000005;
ll n;
struct line {
    long long m, c;
    long long eval(long long x) { return m * x + c; }
    long double intersectX(line l) { return (long double) (c - l.c) / (l.m - m); }
};
vector<pair<pi,ll>> rect;
deque<line> dq;
*/
/*int find(int a){
     if(a==par[a])return a;
     return par[a]=find(par[a]);
}
void unite(int a,int b){
     a=find(a),b=find(b);
     if(a==b)return ;
     par[b]=a;
}
ll modexpo(ll a,ll b)
{
     int ans=1LL;
     while(b>0)
     {
          if(b&1)ans=(ans*a)%mod;
          a=(a*a)%mod;
          b>>=1;
     }
     return ans;
}
*/















int main(){
     ll t1,t2;
     cin>>t1>>t2;
     ll a1,a2;cin>>a1>>a2;
     ll b1,b2;cin>>b1>>b2;
     ll p=(a1-b1)*t1;
     ll q=(a2-b2)*t2;
     if(p>0){
          p*=-1;
          q*=-1;
     }
     if(p+q<0)cout<<0;
     else if(p+q==0)cout<<"infinity";
     else {
          ll s=(-p)/(p+q);
          ll rem=(-p)%(p+q);
          if(rem!=0)cout<<2*s+1;
          else cout<<2*s;
     }

}



















































Measured memory_bytes: 3616
h,w = map(int,input().split())
ls = [input() for _ in range(h)]
ll = [['#']*w for _ in range(h)]
for x in range(h):
  for y in range(w):
    if ls[x][y]=='.':
      cnt = 0
      for dx,dy in ((1,0),(0,1),(-1,0),(0,-1),(1,1),(-1,1),(-1,-1),(1,-1)):
        nx,ny = x+dx,y+dy
        if not(0<=nx<h and 0<=ny<w): continue
        if ls[nx][ny]=='#': cnt += 1
      ll[x][y] = cnt
for l in ll:
  print(''.join(map(str,l)))

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

int main(){
   ll N; cin >> N;
   string res = "second";
   for (ll i = 0; i < N; i++)
   {
       ll r; cin >> r;
       if (r % 2 == 1) {
           res = "first"; break;}
   }
   cout << res << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
int main(){
    int n, m; cin >> n >> m;
    vector<int> num(n, 1);
    vector<bool> f(n, false);
    f[0] = true;
    for(int i = 0; i < m; i++) {
        int x, y; cin >> x >> y;
        x--; y--;
        num[x]--;
        num[y]++;
        if(f[x]) f[y] = true;
        if(num[x] == 0) f[x] = false;
    }
    
    int count = 0;
    for(int i = 0; i < f.size(); i++) {
        if(f[i]) count++;
    }
    cout << count << endl;
} 


Measured memory_bytes: 640
// abco54c: One-stroke Path
#include <bits/stdc++.h>

using namespace std;
using vi = vector<int>;

#define rep(i,n) for(int i=0;i<(n);i++)
#define in(x) cin>>(x)
#define oute(x) cout<<(x)<<endl

struct vertex{vi v; bool visit;};
using graph = vector<vertex>;

void dfs(graph &g, int p, int distance, int &count){
  if(distance==g.size()-1){ count++; return; }
  g[p].visit = true;
  for(int c:g[p].v)
    if(!g[c].visit) dfs(g,c,distance+1,count);
  g[p].visit = false;
}

int main(){
  int n,m; in(n);in(m);
  graph g(n);
  rep(i,m){
    int a,b; in(a);in(b);
    g[--a].v.push_back(--b);
    g[b].v.push_back(a);
  }
  int count = 0;
  dfs(g,0,0,count);
  oute(count);
}

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

int w(long long x)
{
	int ans;
	ans=0;
	while (x!=0)
	{
		ans+=x%10;
		x/=10;
	}
	return ans;
}

int main()
{
	int n;
	cin>>n;
	if (n<=999)
	{
		cout<<"ABC"<<endl;
		return 0;
	}
	if (n>999 && n<=1999)
	{
		cout<<"ABD"<<endl;
		return 0;
	}
	return 0;
}

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


int main(void)
{
	int H, W;
	cin >> H >> W;
	char c[H][W];
	int map[H][W];

	int count = 0;
	for (int i = 0; i < H; i++) {
		for (int j = 0; j < W; j++) {
			cin >> c[i][j];
			map[i][j] = -1;
			if (c[i][j] == '#')
				count++;
		}
	}

	queue<tuple<int, int, int>> q;
	map[0][0] = 0;
	q.push(make_tuple(0, 0, 0));
	while (q.size() != 0) {
		auto v = q.front();
		q.pop();

		int x = get<0>(v);
		int y = get<1>(v);
		int val = get<2>(v);
		if (x > 0) {
			if (c[x-1][y] == '.' && map[x-1][y] == -1) {
				map[x-1][y] = val+1;
				q.push(make_tuple(x-1, y, val+1));
			}
		}
		if (x < H-1) {
			if (c[x+1][y] == '.' && map[x+1][y] == -1) {
				map[x+1][y] = val+1;
				q.push(make_tuple(x+1, y, val+1));
			}
		}
		if (y > 0) {
			if (c[x][y-1] == '.' && map[x][y-1] == -1) {
				map[x][y-1] = val+1;
				q.push(make_tuple(x, y-1, val+1));
			}
		}
		if (y < W-1) {
			if (c[x][y+1] == '.' && map[x][y+1] == -1) {
				map[x][y+1] = val+1;
				q.push(make_tuple(x, y+1, val+1));
			}
		}
		if (x == H-1 && y == W-1)
			break;
	}

	if (map[H-1][W-1] == -1)
		cout << "-1" << endl;
	else
		cout << H*W-(map[H-1][W-1]+1)-count << endl;

	return 0;

}


Measured memory_bytes: 256
N,C,K=map(int,input().split())
T=[]
for i in range(N):
  T.append(int(input()))

T.sort()
cnt=1
bus=0
for j in range(N):
  if bus==0:
    start=T[j]
    bus+=1
  elif start+K>=T[j] and bus < C:
    bus+=1
  else:
    cnt+=1
    bus=1
    start=T[j]

print(cnt)

Measured memory_bytes: 7388
n=int(input())
from math import *
a=[int(x) for x in input().split()]
dp=[0 for i in range(n+1)]
dp[1]=0
a.insert(0,0)
dp[2]=abs(a[2]-a[1])
for i in range(3,n+1):
    dp[i]=min(dp[i-1]+abs(a[i]-a[i-1]),dp[i-2]+abs(a[i]-a[i-2]))
#print(dp)    
print(dp[n])    

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

#define rep(i, n) for (int i = 0; i < n; ++i)
#define all(x) (x).begin(),(x).end()
#define endl "\n"

using ll = long long;
using P = pair<int,int>;
using mp =  map<char,int>;

const int MOD = 1e9 + 7;
const int INF = 1001001001;


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

    int a, b, k;
    cin >> a >> b >> k;

    rep(i, k){
        if(i % 2 == 0){
            if(a % 2 == 1){
                a--;
            }
                a /= 2;
                b += a;
        }else{
            if(b % 2 == 1){
                b--;
            }
                b /= 2;
                a += b;
        }
    }

    cout << a << " " << b << endl;


    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

#define MAX 2000000

int H, A[MAX+1];


void maxHeapify(int);

int main() {

  int i;

  scanf("%d", &H);

  for( i=1; i<=H; i++ ) {
    scanf("%d", &A[i]);
  }

  for( i=H/2; i>=1; i-- ) {
    maxHeapify(i);
  }

  for( i=1; i<=H; i++) {
    printf(" %d", A[i]);
  }
  printf("\n");
  return 0;
}

void maxHeapify(int i) {

  int l;
  int r;
  int largest;
  int tmp;

  l = 2 * i;
  r = 2 * i + 1;

  if( l<=H && A[l]>A[i] ) {
    largest = l;
  } else {
    largest = i;
  }
  
  if( r <= H && A[r]>A[largest] ) {
    largest = r;
  }

  if( largest != i ) {
    tmp = A[i];
    A[i] = A[largest];
    A[largest] = tmp;
    maxHeapify(largest);
  }

  return ;
}

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

using namespace std;

int main()
{
  vector<int> a(3);
  for (auto j=0; j < 3; ++j) {
    cin >> a[j];
  }
  sort(a.begin(), a.end());
  int c = 0;
  for (auto j=1; j < 3; ++j) {
    c += abs(a[j] - a[j-1]);
  }
  cout << c << endl;
}

Measured memory_bytes: 256
/**
 * code generated by JHelper
 * More info: https://github.com/AlexeyDmitriev/JHelper
 * @author yassin
 */

#include <bits/stdc++.h>

using namespace std;

class arc092_d {
private:
    int count(int start_num, int end_num, const vector<int> &b) {
        auto it_start = lower_bound(begin(b), end(b), start_num);
        auto it_end = lower_bound(begin(b), end(b), end_num);
        int cnt = it_end - it_start;
        return cnt;
    }
public:
    void solve(istream& in, ostream& out) {
        int N;
        in >> N;
        vector<int> a(N), b(N);
        for (int i = 0; i < N; ++i) {
            in >> a[i];
        }
        for (int i = 0; i < N; ++i) {
            in >> b[i];
        }
        vector<int> res(29, 0);
        for (int j = 0; j < 29; ++j) {
            int T = (1 << j);
            vector<int> cur_a(N), cur_b(N);
            for (int i = 0; i < N; ++i) {
                cur_a[i] = a[i] % (2 * T);
                cur_b[i] = b[i] % (2 * T);
            }
            sort(begin(cur_b), end(cur_b));
            for (int i = 0; i < N; ++i) {
                res[j] += count(T - cur_a[i], 2 * T - cur_a[i], cur_b);
                res[j] += count(3 * T - cur_a[i], 4 * T - cur_a[i], cur_b);
            }
        }
        int ans = 0;
        for (int j = 0; j < 29; ++j) {
            if (res[j] % 2) {
                ans |= (1 << j);
            }
        }
        out << ans << "\n";
    }
};

int main() {
	std::ios::sync_with_stdio(false); cin.tie(nullptr);
	arc092_d solver;
	std::istream& in(std::cin);
	std::ostream& out(std::cout);
	solver.solve(in, out);
	return 0;
}


Measured memory_bytes: 3456
#include <cmath>
#include <iostream>
#include <string>
#include <string.h>
#include <time.h>
#include <stdio.h>
#include <iomanip>
#include <vector>
#include <map>
#include <algorithm>
#include <stack>
#define MAX 100000
typedef long long ll;
using namespace std;

int n, A[50];

int solve(int i, int m)
{
    if (m == 0)
        return 1;
    if (i >= n)
        return 0;
    int res = solve(i + 1, m) || solve(i + 1, m - A[i]);
    return res;
}

int main()
{
    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> A[i];
    }
    int m;
    cin >> m;
    vector<int> M(m);
    for (int i = 0; i < m; i++)
    {
        cin >> M[i];
        if (solve(0, M[i]))
            cout << "yes" << endl;
        else
            cout << "no" << endl;
    }

    return 0;
}



Measured memory_bytes: 3112
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<vector>
#include<string.h>
#include<math.h>
#include<map>
#include<iomanip>

#define MOD 1e9+7;
#define INF 1e17+9;
#define PI acos(-1);

using namespace std;

long long gcd(long long a,long long b){
	if(max(a,b)%min(a,b)==0){
		return min(a,b);
	}else{
		return gcd(min(a,b),max(a,b)%min(a,b));
	}
}

int main() {
	long long N,X;
	cin >> N >> X;
	vector<long long> x(N);
	
	for(long long i=0;i<N;i++){
		cin >> x[i];
	}
	x.push_back(X);
	sort(x.begin(),x.end());
	
	if(x.size()==2){
		cout << x[1]-x[0] << endl;
		return 0;
	}
	
	long long ans=INF;
	for(long long i=1;i<x.size()-1;i++){
		ans=min(ans,gcd(x[i+1]-x[i],x[i]-x[i-1]));
		if(ans==1){
			cout << ans << endl;
			return 0;
		}
	}
	
	cout << ans << endl;
	
	return 0;
}


Measured memory_bytes: 1792
#include <stdio.h>
#include <bits/stdc++.h>
using namespace std;
#define REP(i, a, b) for (int i = (a), _end_ = (b); i < _end_; ++i)
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define mp make_pair
//#define x first
//#define y second
#define pb push_back
#define eb emplace_back
#define SZ(x) (int((x).size()))
#define ALL(x) (x).begin(), (x).end()

template<typename T> inline bool chkmin(T &a, const T &b) { return a > b ? a = b, 1 : 0; }
template<typename T> inline bool chkmax(T &a, const T &b) { return a < b ? a = b, 1 : 0; }

typedef long long LL;
const int MAX_N = 1e5 + 5;
const LL mod = 1e9 + 7;

int n;
int F[105][11], P[105][11];


int main()
{
#ifdef ANONYM
    freopen("data.in", "r", stdin);
    freopen("data.out", "w", stdout);
#endif

    cin >> n;
    REP(i, 1, n+1) {
        REP(j, 0, 10) {
            cin >> F[i][j];
        }
    }
    REP(i, 1, n+1) {
        REP(j, 0, 11) {
            cin >> P[i][j];
        }
    }
    int ans = -0x7fffffff;
    REP(i, 1, 1<<10) {
        int tmp = 0;
        REP(j, 1, n+1) {
            int cnt = 0;
            REP(k, 0, 10) {
                if((i & (1<<k)) && F[j][k]) cnt++;
            }
            tmp += P[j][cnt];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 384
S = input()
flag1 = 0
flag2 = 0
flag3 = 0

if not ('A' in S and 'C' in S):
	print('WA')
	exit() 

if S[0] == 'A':
	flag1 = 1

C_num = 0
for i in range(len(S[2:-1])):
	if S[2+i] == 'C':
		C_num = C_num + 1 
if C_num == 1:
	flag2 = 1

S_list = list(S)
S_list.remove('A')
S_list.remove('C')
if str(S_list).islower():
	flag3 = 1

if flag1 == 1 and flag2 == 1 and flag3 == 1:
	print('AC')
else:
	print('WA')

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

using namespace std;

using int64 = long long;

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

  int n;
  cin >> n;
  vector<int64> xs(n);
  for (int i = 0; i < n; i++) {
    cin >> xs[i];
  }
  vector<int> count(n, -1);
  for (int i = n - 1; i >= 0; i--) {
    if (i == n - 1) {
      count[i] = 0;
    } else {
      if (xs[i] >= xs[i + 1]) {
        count[i] = count[i + 1] + 1;
      } else {
        count[i] = 0;
      }
    }
  }

  int max_value = 0;
  for (int c : count) max_value = max(c, max_value);
  cout << max_value << endl;
}

Measured memory_bytes: 1408
def main():
    n, m = map(int, input().split())
    f = [[False]*2 for _ in range(n+1)]
    for _ in range(m):
        a, b = map(int, input().split())
        if a == 1:
            f[b][0] = True
        if b == n:
            f[a][1] = True
    ans = "IMPOSSIBLE"
    for i in range(1, n+1):
        if f[i][0] and f[i][1]:
            ans = "POSSIBLE"
            break
    print(ans)

if __name__ == "__main__":
    main()

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

if len(s) == 2:
  if s[0] == s[1]:
    print(1,2)
  else:
    print(-1,-1)
  exit()
for i in range(len(s)-2):
  if len(set(s[i:i+3])) < 3:
    print(i+1,i+3)
    exit()

print(-1,-1)

Measured memory_bytes: 9648
#include <bits/stdc++.h>
#include <iostream>
#include <string>
#include <limits.h>
#include <algorithm>
#include <iomanip>
using namespace std;

int main(){
  long long int X, M, ans = 0, A5=0, B5=0 ;
  cin >> X ;
  for(long long int i=-125;i<125;i++){
    A5 = i * i * i * i * i ;
    for(long long int j=-125;j<i;j++){
      B5 = j * j * j * j * j ;
      if(A5 - B5 == X){
        cout << i << " " << j << endl ;
        return 0 ;
      }
    }
  }
  cout << "error" << endl ;
  return 0 ;
}  

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

int main(){
  string s;
  int k;
  cin >> s >> k;
  for (int i=0; i<k; i++){
    if (s[i]!='1') {
      cout << s[i] << endl;
      return 0;
    }
    else continue;
  }
  cout << 1 << endl;
}

Measured memory_bytes: 256
open Printf
open Scanf

module L =
  struct
    include List

    let rec unfold_right f x =
      match f x with
        None -> []
      | Some (a, b) -> a :: unfold_right f b
  end

let solve n k =
  let f x = if x = 0 then None else Some (x mod k, x / k) in
  L.length @@ L.unfold_right f n

let () =
  scanf "%d %d " solve |> printf "%d\n"


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

int main() {
    int N;
  	double A[110];
    cin >> N;
  	for(int i=0; i<N; i++) cin >> A[i];
  	double denomi = 0;
  	double one = 1;
  	for(int i=0; i<N; i++) {
      denomi += one/A[i];
    }
  	double ans = one/denomi;
	cout << setprecision(11) << ans << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<cmath>
#include<cstdlib>
#include<ctime>
#include<queue>
#include<set>
#include<map>
#include<stack>
#include<bitset>
using namespace std;
typedef long long LL;
const int N=2010;
int gi() {
	int w=0;bool q=1;char c=getchar();
	while ((c<'0'||c>'9') && c!='-') c=getchar();
	if (c=='-') q=0,c=getchar();
	while (c>='0'&&c <= '9') w=w*10+c-'0',c=getchar();
	return q? w:-w;
}
bool o[N][N];
int U[N][N],L[N][N],s[N][N];
int main()
{
	int n=gi(),m=gi(),Q=gi(),i,j,lx,rx,ly,ry,ans;char c;
	for (i=1;i<=n;i++)
		for (j=1;j<=m;j++) {
			while ((c=getchar())!='0'&&c!='1');
			o[i][j]=c-'0';

			s[i][j]=s[i-1][j]+s[i][j-1]-s[i-1][j-1]+o[i][j];
			U[i][j]=U[i-1][j]+U[i][j-1]-U[i-1][j-1]+(o[i][j]&&o[i-1][j]);
			L[i][j]=L[i-1][j]+L[i][j-1]-L[i-1][j-1]+(o[i][j]&&o[i][j-1]);
		}
	while (Q--) {
		lx=gi(),ly=gi(),rx=gi(),ry=gi();
		
		ans=s[rx][ry]-s[lx-1][ry]-s[rx][ly-1]+s[lx-1][ly-1];
		ans-=L[rx][ry]-L[lx-1][ry]-L[rx][ly]+L[lx-1][ly];
		ans-=U[rx][ry]-U[lx][ry]-U[rx][ly-1]+U[lx][ly-1];
		
		printf("%d\n",ans);
	}
	
		
	return 0;
}


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

/*
提出前に確認!
- setとmultisetを間違えない
*/

/*
n <= 5000なので必ず5000ステップ以内にループができる
ある場所から始めた時に、5000回やってどこかでループが出てくる
ループが出てきた時に、1ループで収支がプラスなら最大のループ数-1回ループをして、二回回って最大を見れば良さそう
5000 * 5000 * 3? = 7.5 * 10^7だから多分いける

piが全て異なるということから一個の輪になる
このことから1ループはciの総和
*/

int	main(void)
{
	int n, k;
	cin >> n >> k;
	vector<int> p(n);
	for (int i = 0; i < n; i++) cin >> p[i];
	vector<int> c(n);
	for (int i = 0; i < n; i++) cin >> c[i];
	long long ans = c[0];
	for (int start = 1; start <= n; start++)
	{
		int now = start;
		long long tmp = 0;
		int loop_cnt = 0;
		long long loop_value = 0;
		for (int i = 0; i < n; i++)
		{
			now = p[now - 1];
			loop_cnt++;
			loop_value += c[now - 1];
			if (now == start) break ;
		}
		int k2 = k;
		if (k2 / loop_cnt >= 2 && loop_value > 0)
		{
			tmp += (k2 / loop_cnt - 2) * loop_value;
			k2 -= loop_cnt * (k2 / loop_cnt - 2);
		}
		else if (k2 / loop_cnt >= 2) k2 -= loop_cnt * (k2 / loop_cnt - 2);
		for (int i = 0; i < k2; i++)
		{
			now = p[now - 1];
			tmp += c[now - 1];
			ans = max(ans, tmp);
		}
	}
	cout << ans << endl;
	return (0);
}


Measured memory_bytes: 3632
import java.util.Scanner;
public class Main {
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int x=sc.nextInt();
        int fx=0;
        
        for(int i=1;i<=9;i++){
            fx+=x/Math.pow(10,i-1)%10;
        }
        
        if(x%fx==0){
            System.out.println("Yes");
        }else{
            System.out.println("No");
        }
    }
}

Measured memory_bytes: 22100
#include <bits/stdc++.h>
#define N 100010
using namespace std;

int n,k,a[N],mi=0x3fffffff,V[N],Ans=0x3fffffff;
int main()
{
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++) scanf("%d",&a[i]),mi=min(mi,a[i]);
	for(int i=1;i<=n;i++) if(a[i]==mi) V[++V[0]]=i;
	for(int i=1;i<=V[0];i++)
	{
		int j=i; while(V[j+1]-V[i]==1) j++;
		Ans=min(Ans,(i-1+k-1-1)/(k-1)+(n-j+k-1-1)/(k-1));
	}
	cout << Ans << endl;
	return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main() {
    ll h, w;
    cin >> h >> w;

    ll ans = 0;

    if (h == 1 || w == 1) {
        cout << 1 << endl;
        return 0;
    }

    if (h % 2 == 0) {
        ans = (h * w) / 2;
    } else {
        if (w % 2 == 0) ans = (h * w) / 2;
        else ans = (h * w) / 2 + 1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
constexpr ll INF = 1e18;
int main() {
    ll n;cin >> n;
    vector<ll> h(n);
    for(ll i=0;i<n;i++){
        cin >> h[i];
    }
    vector<ll> cost(n,INF);
    cost[0]=0;
    for(ll i=0;i<n;i++){
        for(ll j=1;j<3;j++){
            if(i+j<n)cost[i+j]=min(cost[i+j],cost[i]+abs(h[i]-h[i+j]));
        }
    }
    cout << cost[n-1] << endl;
    return 0;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
#define ll long long
#define ull unsigned long long
#define ls rt << 1
#define rs rt << 1 | 1
#define mp make_pair
#define pb push_back
#define pii pair<int, int>
#define X first
#define Y second
#define pcc pair<char, char>
#define rep(i, x, y) for(int (i) = (x); (i) <= (y); (i) ++)
#define eps 1e-9
using namespace std;
inline int read()
{
	int x = 0, f = 1; char ch = getchar();
	while (ch < '0' || ch > '9') { if (ch == '-') f = -1; ch = getchar(); }
	while (ch >= '0' && ch <= '9') { x = x * 10 + ch - '0'; ch = getchar(); }
	return x * f;
}
const int N = 2e5 + 10;
int n, m, a[N], b[N], ct[N];

int main()
{
    n = read();
    m = read();
    int ans = n;
    rep(i, 1, n)
    {
    	a[i] = read();
    	ct[a[i]] ++;
    	int ps = a[i] - ct[a[i]] + 1;
    	if(ps >= 1)
    	{
    		if(b[ps] == 0) ans --;
    		b[ps] ++;
    	}
    }
    while(m --)
    {
    	int x = read();
    	int y = read();
    	int ps = a[x] - ct[a[x]] + 1;
    	if(ps >= 1)
    	{
    		b[ps] --;
    		if(b[ps] == 0) ans ++;
    	}
    	ct[a[x]] --;
    	a[x] = y;
    	ct[y] ++;
    	ps = a[x] - ct[a[x]] + 1;
    	if(ps >= 1)
    	{
    		if(b[ps] == 0) ans --;
    		b[ps] ++;
    	}
    	cout << ans << endl;
    }
	return 0;
}


Measured memory_bytes: 3712
#define _USE_MATH_DEFINES
#include <cassert>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <sstream>
#include <vector>
#include <queue>
#include <stack>
#include <list>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <complex>
#include <cmath>
#include <numeric>
#include <bitset>
#include <functional>
#include <random>
#include <ctime>

using namespace std;

#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
  cerr << name << ": " << arg1 << endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
  const char* comma = strchr(names + 1, ',');
  cerr.write(names, comma - names) << ": " << arg1 << " |";
  __f(comma + 1, args...);
}

typedef long long int64;
typedef pair<int, int> ii;
const int INF = 1 << 29;
const int MOD = 1e9 + 7;

int main() {
  int sx, sy, tx, ty;
  cin >> sx >> sy >> tx >> ty;
  int X = tx - sx, Y = ty - sy;
  for (int i = 0; i < Y; ++i) cout << 'U';
  for (int i = 0; i < X; ++i) cout << 'R';
  for (int i = 0; i < Y; ++i) cout << 'D';
  for (int i = 0; i < X; ++i) cout << 'L';
  cout << 'L';
  for (int i = 0; i <= Y; ++i) cout << 'U';
  for (int i = 0; i <= X; ++i) cout << 'R';
  cout << "DR";
  for (int i = 0; i <= Y; ++i) cout << 'D';
  for (int i = 0; i <= X; ++i) cout << 'L';
  cout << 'U';
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <string>
using namespace std;
 
int main() {
  float n;
  cin >> n;
  vector<vector<float>> zahyou(2,vector<float>(n));
  vector<vector<float>> kyori(n,vector<float>(n));
  for(int i=0;i<n;i++){
    cin >> zahyou[0][i] >> zahyou[1][i];
  }
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      kyori[i][j]=sqrt(pow((zahyou[0][i]-zahyou[0][j]),2)+pow((zahyou[1][i]-zahyou[1][j]),2));
    }
  }
  float count=0, answer=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<n;j++){
      count+=kyori[i][j];
    }
  }
  answer=count/n;
  cout << fixed << setprecision(10) << answer << endl;
}
  

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

int main()
{
  vector<int> color(3);
  for (auto & c : color)
    cin >> c;
  sort(color.begin(), color.end());
  color.erase(unique(color.begin(), color.end()), color.end());
  cout << color.size();
  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
using namespace std;
static const int N = 1000;

int lcs(string X, string Y) {
  int c[N + 1][N + 1];
  int m = X.size();
  int n = Y.size();
  int maxl = 0;
  X = ' ' + X;
  Y = ' ' + Y;
  for ( int i = 0; i <= m; i++ ) c[i][0] = 0;
  for ( int j = 1; j <= n; j++ ) c[0][j] = 0;

  for ( int i = 1; i <= m; i++ )
    for ( int j = 1; j <= n; j++ ) {
      if ( X[i] == Y[j] )
        c[i][j] = c[i - 1][j - 1] + 1;
      else
        c[i][j] = max(c[i - 1][j], c[i][j - 1]);
      maxl = max(maxl, c[i][j]);
    }

  return maxl;
}

int main() {
  string s1, s2;
  int n; cin >> n;
  for ( int i = 0; i < n; i++ ) {
    cin >> s1 >> s2;
    cout << lcs(s1, s2) << endl;
  }
  return 0;
}


Measured memory_bytes: 7064
#include <iostream>
#include <stdio.h>
#include <math.h> 
#include <algorithm>
#include <numeric>
#include <functional>
#include <vector>
#include <string>
#include <numeric>
#include <bitset>
#include <queue>
#include <map>
#include <typeinfo>

using namespace std;

int main()
{
	long long int n = 0;
	cin >> n;

	vector<long long int> point;

	for (int i = 0; i < 5; ++i) {
		long long int tmp = 0;
		cin >> tmp;
		point.push_back(tmp);
	}

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

	long long int base = 0;
	long long int min_unm = point.at(0);

	base = (n / min_unm) + 1;

	long long int ans = 0;
	if (min_unm == 1) {
		ans = base + 3;
	}
	else {
		ans = base + 4;
	}
	cout << ans << endl;

}

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

Measured memory_bytes: 1024
#![allow(unused_imports)]
#![allow(non_snake_case)]
use std::cmp::*;
use std::collections::*;
use std::io::Write;

#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), std::io::stderr());
            writeln!(err, "{} = {:?}", e, $e).unwrap()
        })*
    };
}

fn main() {
    let d = read::<usize>();
    let c = read_vec::<i64>();
    let mut s = vec![vec![]; d];
    for i in 0..d {
        s[i] = read_vec::<i64>();
    }

    let mut t = vec![];
    for i in 0..d {
        t.push(read::<usize>() - 1);
    }

    let m = read::<usize>();
    for i in 0..m {
        let v = read_vec::<usize>();
        let (d, q) = (v[0] - 1, v[1] - 1);
        t[d] = q;
        let ans = calc_score(&c, &t, &s);
        println!("{}", ans);
    }
}

fn calc_score(c: &Vec<i64>, t: &Vec<usize>, s: &Vec<Vec<i64>>) -> i64 {
    let d = s.len();
    let mut score = 0;
    let mut last = vec![0; 26];
    for i in 0..d {
        score += s[i][t[i]];
        last[t[i]] = i + 1;
        for qi in 0..26 {
            score -= c[qi] * (i as i64 + 1 - last[qi] as i64);
        }
    }
    score
}

fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

fn read_vec<T: std::str::FromStr>() -> Vec<T> {
    read::<String>()
        .split_whitespace()
        .map(|e| e.parse().ok().unwrap())
        .collect()
}


Measured memory_bytes: 2188
import math
import sys
input = sys.stdin.readline
H, N = map(int, input().split())
AB = [tuple(map(int, input().split())) for i in range(N)]

dp = [[10**10, 0] for i in range(H+1)]
dp[0][0] = 0
# i 減らすのに最小で必要なMP

for i in range(1, H+1):
    if dp[i-1][1] > 0:
        dp[i][0] = dp[i-1][0]
        dp[i][1] = dp[i-1][1] - 1
    else:
        for A, B in AB:
            if A > i:
                if dp[i][0] > B:
                    dp[i][0] = B
                    dp[i][1] = A - i
            else:
                if dp[i][0] > dp[i - A][0] + B:
                    dp[i][0] = dp[i-A][0] + B
                    dp[i][1] = dp[i-A][1] + A - i

print(dp[H][0])


Measured memory_bytes: 41456
#include <iostream>
#include <vector>
#include <queue>
#include <algorithm>
using namespace std;
const int INF = 1000000000;

//int h[200005][2] = { 0 };

int main(){
	long long a,b,n;
	b = 0;
	cin>> n;

	for (int i = 1; i <= n; i++) {

		cin >> a;
		if (a != i)b++;
	}
	if (b <= 2)cout << "YES" << endl;
	else cout << "NO" << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define INF 999999999
#define rep(i, n) for(int i = 0;i < n;i++)
#define pb(n) push_back(n)
#define Sort(n) sort(n.begin(), n.end())
#define Rev(n) reverse(n.begin(),n.end())
#define Out(S) cout << S << endl
#define NeOut(S) cout << S
#define HpOut(S) cout << setprecision(20) << S << endl;
#define Vecpr vector<pair<lli,lli>>
int main() {
  lli A,B=0,C,D=0,E,F=INF;
  cin >> A>>B>>C;
  if(A+B+1<C)C=A+B+1;
  Out(B+C);
}
  

Measured memory_bytes: 256
import java.util.*;

public class Main
{
	public static void main(String args[])
	{
		Scanner scan = new Scanner(System.in);
		int n = scan.nextInt();
		int[] b = new int[n-1];
		for(int i=0;i<n-1;i++)
		{
			b[i]=scan.nextInt();
		}
		solve(n,b);
		scan.close();	
	}
	
	private static void solve(int n,int b[])
	{
		int a=b[0];
		for (int i = 0; i < n - 2; i++)
			if (b[i] <= b[i + 1])
				a += b[i];
			else
				a += b[i + 1];
		a += b[n - 2];
		System.out.println(a);
	}
}

Measured memory_bytes: 21844
N, M = map(int, input().split())

H = list(map(int, input().split()))
ma = [0 for _ in range(N)]

for i in range(M):
    A, B = map(int, input().split())
    ma[A - 1] = max(ma[A - 1], H[B - 1])
    ma[B - 1] = max(ma[B - 1], H[A - 1])

ans = 0
for i in range(N):
    ans += H[i] > ma[i]

print(ans)


Measured memory_bytes: 20092