akhauriyash/Code-Regression huggingface dataset:
<?php

fscanf(STDIN,"%d %d %d", $n,$a,$b);


    $count_loop = (int)($n/($a+$b));
    $left_count = $n%($a+$b);




    if($left_count>=$a){
        echo $count_loop*$a+$a."\n";
    }else{
        echo $count_loop*$a+$left_count."\n";
    }




Measured memory_bytes: 4604
import java.util.HashSet;
import java.util.Set;

public class Main {

  private static void solve() {
    int a = ni();
    int b = ni();
    int c = ni();

    Set<Integer> set = new HashSet<>();
    set.add(a);
    set.add(b);
    set.add(c);

    if (set.size() == 2) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }

  }

  public static void main(String[] args) {
    new Thread(null, new Runnable() {
      @Override
      public void run() {
        long start = System.currentTimeMillis();
        String debug = args.length > 0 ? args[0] : null;
        if (debug != null) {
          try {
            is = java.nio.file.Files.newInputStream(java.nio.file.Paths.get(debug));
          } catch (Exception e) {
            throw new RuntimeException(e);
          }
        }
        reader = new java.io.BufferedReader(new java.io.InputStreamReader(is), 32768);
        solve();
        out.flush();
        tr((System.currentTimeMillis() - start) + "ms");
      }
    }, "", 64000000).start();
  }

  private static java.io.InputStream is = System.in;
  private static java.io.PrintWriter out = new java.io.PrintWriter(System.out);
  private static java.util.StringTokenizer tokenizer = null;
  private static java.io.BufferedReader reader;

  public static String next() {
    while (tokenizer == null || !tokenizer.hasMoreTokens()) {
      try {
        tokenizer = new java.util.StringTokenizer(reader.readLine());
      } catch (Exception e) {
        throw new RuntimeException(e);
      }
    }
    return tokenizer.nextToken();
  }

  private static double nd() {
    return Double.parseDouble(next());
  }

  private static long nl() {
    return Long.parseLong(next());
  }

  private static int[] na(int n) {
    int[] a = new int[n];
    for (int i = 0; i < n; i++)
      a[i] = ni();
    return a;
  }

  private static char[] ns() {
    return next().toCharArray();
  }

  private static long[] nal(int n) {
    long[] a = new long[n];
    for (int i = 0; i < n; i++)
      a[i] = nl();
    return a;
  }

  private static int[][] ntable(int n, int m) {
    int[][] table = new int[n][m];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[i][j] = ni();
      }
    }
    return table;
  }

  private static int[][] nlist(int n, int m) {
    int[][] table = new int[m][n];
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < m; j++) {
        table[j][i] = ni();
      }
    }
    return table;
  }

  private static int ni() {
    return Integer.parseInt(next());
  }

  private static void tr(Object... o) {
    if (is != System.in)
      System.out.println(java.util.Arrays.deepToString(o));
  }
}



Measured memory_bytes: 22996
import sys
input = sys.stdin.readline
import random
import time
import copy
from operator import itemgetter
time0=time.time()

D=int(input())
C=[0]+list(map(int,input().split()))
S=[0]+[[0]+list(map(int,input().split())) for i in range(D)]


CI=sorted([(v,i) for i,v in enumerate(C)],key=itemgetter(0),reverse=True)
CHO=[i for v,i in CI[:5]]

CHOICES=[[0]]
for i in range(1,D+1):
    SI=sorted([(v,i) for i,v in enumerate(S[i])],key=itemgetter(0),reverse=True)
    CHOICES.append([i for v,i in SI[:5]])
    
ANS=0
T=[0]
LAST=[0]*27
for day in range(1,D+1):
    SCORE=[-1<<30]*27
    for j in range(1,27):
        SC=0
        SC+=S[day][j]

        for k in range(1,27):
            if j==k:
                continue
            SC-=C[k]*(day-LAST[k])
        SCORE[j]=SC

    choose=SCORE.index(max(SCORE))
    T.append(choose)
    LAST[choose]=day

ANS=0
LAST=[[0]*27 for i in range(D+1)]
for day in range(1,D+1):
    for j in range(1,27):
        LAST[day][j]=LAST[day-1][j]
    t=T[day]
    ANS+=S[day][t]
    LAST[day][t]=day

    for j in range(1,27):
        ANS-=C[j]*(day-LAST[day][j])

MAX=ANS
MAXT=copy.deepcopy(T)
d=0
after_t=0

while time.time()-time0<1.77:
    BT=copy.deepcopy(T)
    BLAST=copy.deepcopy(LAST)
    BANS=ANS
    
    d=d%D+1
    after_t=random.choice(CHO+CHOICES[d])

    before_t=T[d]

    ANS+=S[d][after_t]-S[d][before_t]

    T[d]=after_t

    for day in range(d,D+1):
        if T[day]!=before_t:
            ANS+=C[before_t]*(day-LAST[day][before_t])
            LAST[day][before_t]=LAST[day-1][before_t]
            ANS-=C[before_t]*(day-LAST[day][before_t])
        else:
            break

    ANS+=C[after_t]*(d-LAST[d][after_t])
    LAST[d][after_t]=d

    for day in range(d+1,D+1):    
        if T[day]!=after_t:
            ANS+=C[after_t]*(day-LAST[day][after_t])
            LAST[day][after_t]=LAST[day-1][after_t]
            ANS-=C[after_t]*(day-LAST[day][after_t])

    if ANS*10000<MAX*9995:
        T=BT
        LAST=BLAST
        ANS=BANS
    elif ANS>MAX:
        MAX=ANS
        MAXT=copy.deepcopy(T)

print(*MAXT[1:])


Measured memory_bytes: 179540
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rrep(i,n) for(ll i = 1; i <= (n); ++i)
#define drep(i,n) for(ll i = (n)-1; i >= 0; --i)
#define all(v) v.begin(),v.end()
#define len(x) (ll)(x).length()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (ll)(x).size()
#define v(T) vector<T>
#define vv(T) vector<vector<T>>
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
ll gcd(ll a,ll b){if(a%b==0){return b;}else{return(gcd(b,a%b));}}
ll lcm(ll a,ll b){return a*b/gcd(a,b);}
const int INF=1e9;
const ll MX = 1e18;
const int MOD=INF+7;
const int di[] = {-1,0,1,0};
const int dj[] = {0,-1,0,1};
const double PI=acos(-1);

int main() {
  int n,k;
  cin>>n>>k;
  if(n*500>=k){
    cout<<"Yes"<<endl;
    return 0;
  }
  cout<<"No"<<endl;
}

Measured memory_bytes: 3628
n= int(input())
s = input()
ans = 0
for i in range(10):
  ii = s.find(str(i))
  if -1 == ii:
    continue
  for j in range(10):
    ij = s.find(str(j), ii+1)
    if -1 == ij:
      continue
    for k in range(10):
      ik = s.find(str(k), ij+1)
      if ik != -1:
        ans += 1
      
print(ans)

Measured memory_bytes: 3064
#pragma GCC target("avx2")
#pragma GCC optimize("O3")
#pragma GCC optimize("unroll-loops")

#include <algorithm>
#include <bitset>
#include <climits>
#include <cmath>
#include <cstring>
#include <deque>
#include <forward_list>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <queue>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef bitset<16> BS;

const ll MOD = 1E+09 + 7;
const ll INF = 1E18;
const int MAX_N = 1E+05;

int N, M;

int X[MAX_N];

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

    cin >> N >> M;

    /*
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            cout << "i = " << i << ", j = " << j << ", dp = " << dp[i][j] << "\n";
        }
    }
    */

    cout << (1 << M) * (100 * N + 1800 * M) << "\n";

    return 0;
}

Measured memory_bytes: 3628
N=int(input())
li=list(map(int,input().split()))
S=sum(li)
x=li[0]
ans=abs(S-2*x)
for n in range(1,N-1):
    x+=li[n]
    new_ans=abs(S-2*x)
    if ans>new_ans:
        ans=new_ans
print(ans)


Measured memory_bytes: 24828
#include<bits/stdc++.h>
using namespace std;
#define pb          push_back
#define vi          vector<int>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define endl        "\n"
#define fast        ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int         long long int
#define mod         1000000007
 
#define test        int tc;cin>>tc;while(tc--)


int32_t main(){
    fast;
    int n;cin>>n;
    string str[n];
    map<string,int>mp;
    for(int i=0;i<n;i++){
        cin>>str[i];
        mp[str[i]]++;
    }
    set<string>s;
    int mx=INT_MIN;
    for(auto x:mp){
        mx=max(mx,x.S);
    }
    for(auto x:mp){
        if(x.S==mx){
            s.insert(x.F);
        }
    }
    for(auto x:s){
        cout<<x<<endl;
    }
}


Measured memory_bytes: 34816
import scala.io.StdIn

object Main {
  def main(args: Array[String]){
    val input = StdIn.readLine().split(" ").toList.map(_.toInt) match {
        case List(m: Int, n: Int) if (m > n) => println("a > b")
        case List(m: Int, n: Int) if (m < n) => println("a < b")
        case _ => println("a == b")
    }
  }
}



Measured memory_bytes: 43700
#include <stdio.h>
#include <iostream>
#include<vector>
#include<algorithm>

int main(int argc, char** argv)
{
    int N;
    std::vector<int>vd;

    std::cin >> N;

    for(int i=0;i<N;i++)
    {
        int d;
        std::cin >>d;

        vd.push_back(d);
    }
    std::sort(vd.begin(),vd.end());

    int K = vd[N/2]-vd[N/2-1];

    std::cout << K;
    
    return 0;
}

Measured memory_bytes: 892
N, M = (int(i) for i in input().split())
A = [1]*(N+1)
for i in range(M):
  a = int(input())
  A[a] = -1

dp=[0 for i in range(N+1)]
#dp[今どこにいるか] = 何通りあるか
dp[0] = 1

for i in range(N):
  if i+1 <= N:
    if A[i+1] == 1:
      dp[i+1] += dp[i]
  if i+2 <= N:
    if A[i+2] == 1:
      dp[i+2] += dp[i]

ans = dp[N]%1000000007

print(ans)


Measured memory_bytes: 463512
//----------BHAVIK DIWANI(PICT_COMP)---------------
#include<bits/stdc++.h>
#include<stdlib.h>
#include<stdio.h>
#define test ll t; cin>>t; while(t--)
#define FOR(p,n) for(ll i=p;i<(ll)n;i++)
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define mod 1000000007
#define ll long long
#define int long long
#define ull unsigned long long
#define MAX 1000005
#define pb push_back
#define mkp make_pair
#define vi vector<int>
#define pii pair<int,int>
#define endl '\n'
#define vs vector<string>
#define mii map<int,int>
#define msi map<string,int>
#define vpii vector< pair<int, int > >
#define vpsi vector< pair< string ,int > >
#define forci(p,q) for(int i=p;i<q;i++)
ll gcd(ll a,ll b){ if(b==0) return a;    return gcd(b,a%b);}
ll lcm(ll a,ll b) { return (a/gcd(a,b)*b);}
ull power(ull a, ull b) {a %= mod;  ull res = 1;  while (b > 0) { if (b & 1) res = res * a % mod;  a = a * a % mod;  b >>= 1; }  return res%mod; }
ll modmul(ll x, ll y){return (x*y)%mod;}
ll modadd(ll x, ll y){return (x+y)%mod;}
ll modsub(ll x, ll y){return (x-y+mod)%mod;}
ll fact[1000007]={0};
void facto() {fact[0]=1;fact[1]=1;for(int i=2;i<100007;i++)fact[i]=(fact[i-1]*i)%mod;}
ll ncr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[r],mod-2)))%mod; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
ll npr(ll n,ll r) {ll res=1; res=fact[n]; res=(res*(power(fact[n-r],mod-2)))%mod; return res;}
inline long long toint(const std::string &s) {std::stringstream ss; ss << s; long long x; ss >> x; return x;}
inline std::string tostring(long long number) {std::stringstream ss; ss << number; return ss.str();}
inline std::string tobin(long long x) {return std::bitset<63>(x).to_string();}
/*bool prime[MAX];
ull sieve(){memset(prime,true,sizeof(prime));for(ull p=2;p*p<MAX;p++){if(prime[p]==true){for(ull i=2*p;i<MAX;i+=p){prime[i]=false;}}}prime[0]=0;prime[1]=0;
}*/
using namespace std;
signed main()
{
	fastio;
	int k,n;
	cin>>k>>n;
	int a[n];
	forci(0,n)
		cin>>a[i];
	int cnt[n];
	int sum=0;
	cnt[0]=k-a[n-1]+a[0];
	sum+=cnt[0];
	for(int i=1;i<n;i++)
	{
		cnt[i]=a[i]-a[i-1];
		sum+=cnt[i];
	}
	int tot[n];
	int res=0;
	tot[0]=k-a[n-1]+a[0];
	res+=tot[0];
	for(int i=1;i<n;i++)
	{
		tot[i]=a[n-i]-a[n-i-1];
		res+=tot[i];
	}
	int mn=INT_MAX;
	int max_mn=INT_MAX;
	for(int i=0;i<n;i++)
	{
		int ans=res-tot[i];
		int n=sum-cnt[i];
		mn=min(ans,n);
		max_mn=min(mn,max_mn);
	}
	cout<<max_mn<<endl;
	
}












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

int main() {
  int N, K, sum = 1, a = 0;
  cin >> N >> K;
  
  for (int i = 0; i < N; i++){
    sum *= 2;
    a += 1;
    if (sum > K){
      break;
    }
  }
  for (int i = 0; i < N - a; i++){
    sum += K;
  }
  cout << sum << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<set>
#include<cmath>
#include<stack>
#include<random>
using namespace std;

template <typename T>
void printvec(vector<T> v)
{
    for(auto it=v.begin();it != v.end();it++)
    {
        cout << (*it) << endl;
    }
}

int main(){
    int n,h[100000];
    int cost[100001];
    cin >> n;
    if(n == 1){
        cout << 0 << endl;
        return 0;
    }
    for(int i=0;i<n;i++){
        cin >> h[i];
    }
    cost[0] = 0;
    cost[1] = abs(h[1]- h[0]);
    for(int i=2;i<n;i++){
        cost[i] = min(cost[i-1] + abs(h[i] - h[i-1]), cost[i-2] + abs(h[i] - h[i-2]));
    }

    cout << cost[n-1]<< endl;

    return 0;
}

Measured memory_bytes: 1024
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int a, b, c, d, e;
	while(~scanf("%d",&e))
		{
		a = e/1000;
		b = (e - a*1000)/100;
		c = (e - a*1000 - b*100)/10;
		d = (e - a*1000 - b*100 - c*10);
		if((a == b && b == c) || (b == c && c == d))
			printf("Yes\n");
	    else
	    	printf("No\n");
		}
}

Measured memory_bytes: 128
///Bismillahir Rahmanir Rahim
#include<bits/stdc++.h>
#define        u64             uint64_t
#define        ll              long long
#define        endl            "\n"
#define        PI              acos(-1)
#define        fi              first
#define        si              second
#define        mkp             make_pair
#define        pb              push_back
#define        set0(arr)       memset(arr, 0, sizeof(arr))
#define        setinf(arr)     memset(arr, 126, sizeof(arr))
#define        all(x)          (x).begin(),(x).end()
#define        sz(v)           ((int)(v).size())
#define        IOS             ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
using namespace std;
using          pll        =      pair<ll, ll> ;
using          vl         =      vector<ll> ;
using          vpll       =      vector<pll> ;
using          mll        =      map<ll, ll> ;
using          mcl        =      map<char, ll> ;
using          msl        =      map<string,ll> ;
using          sl         =      set<ll> ;
using          sc         =      set<char> ;
using          dl         =      deque<ll> ;
const int N = 1e6+5 ;

ll      mod = 1e9+7 ;
vl      adj[N] ;
vpll    adjc[N] ;
ll      vis[N] ;
ll      arr[N] ;



int main()
{
    IOS;
    ll a, b, c, d, n, m, p, x, y, z, i, j, k, f = 0, tc, cnt = 0, sum = 0, mul = 1, mi = 1e18, ma = -1e18;
    string   str ;
    char     ch ;
    double   db ;
    ll       l, r ;
    //code

   string s,t;
   cin>>s>>t;
   for(i=0;i<=(sz(s)-sz(t));i++)
   {
          cnt=0;
          for(j=0;j<sz(t);j++)
          {
                 if(s[i+j]!=t[j])
                 {
                        cnt++;
                 }
          }
          mi=min(mi,cnt);
   }
   cout<<mi<<endl;


    //code
    return 0;
}




Measured memory_bytes: 50520
import java.io.BufferedReader;
import java.io.InputStreamReader;
import java.util.Arrays;

public class Main {
	public static void main(String[] args) throws Exception {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String[] sa = br.readLine().split(" ");
		int n = Integer.parseInt(sa[0]);
		Obj[] arr1 = new Obj[n];
		Obj[] arr2 = new Obj[n];
		for (int i = 0; i < n; i++) {
			sa = br.readLine().split(" ");
			int l = Integer.parseInt(sa[0]);
			int r = Integer.parseInt(sa[1]);
			Obj o = new Obj();
			o.i = i;
			o.l = l;
			o.r = r;
			arr1[i] = o;
			arr2[i] = o;
		}
		br.close();

		Arrays.parallelSort(arr1, (o1, o2) -> o1.r - o2.r);
		Arrays.parallelSort(arr2, (o1, o2) -> o2.l - o1.l);

		long ans1 = calc(arr1, arr2, n, false);
		long ans2 = calc(arr1, arr2, n, true);
		System.out.println(Math.max(ans1, ans2));
	}

	static long calc(Obj[] arr1, Obj[] arr2, int n, boolean start) {
		long ans = 0;
		boolean[] used = new boolean[n];
		int now = 0;
		boolean flg = start;
		int i = 0;
		int j = 0;
		while (i < n && j < n) {
			Obj o = arr1[i];
			if (used[o.i]) {
				i++;
			} else {
				if (!flg) {
					long val = now - o.r;
					if (val > 0) {
						ans += val;
						used[o.i] = true;
						flg = true;
						now = o.r;
					}
					i++;
				}
			}
			o = arr2[j];
			if (used[o.i]) {
				j++;
			} else {
				if (flg) {
					long val = o.l - now;
					if (val > 0) {
						ans += val;
						used[o.i] = true;
						flg = false;
						now = o.l;
					}
					j++;
				}
			}
		}
		ans += Math.abs(now);
		return ans;
	}

	static class Obj {
		int i, l, r;
	}
}


Measured memory_bytes: 49864
#include <bits/stdc++.h>
#define rep(i,a) for(int i=0;i<int(a);++i)
#define REP(i,a,b) for(int i=int(a);i<int(b);++i)
#define pb push_back
#define mp make_pair
#define F first
#define S second
using ll = long long;
using itn = int;
using namespace std;
static const long double GRATIO=(long double)(1+sqrt(5))/2;
ll GCD(ll a, ll b){
    return b ? GCD(b, a%b) : a;
}
ll LCM(ll a, ll b){
    return a/GCD(a,b)*b;
}
int main(){
    ll N,K;
    cin>>N>>K;
    ll ans=0;
    if(K==0) cout<<N*N<<endl;
    else{
        for(ll i=1; i<=N; i++){
            ans+=(N/i)*max(0LL,i-K);
            ans+=max(0LL,N%i-K+1);
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("O3")

#define _GLIBCXX_DEBUG
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <algorithm>
#include <cmath>
#include <iomanip>
#include <cassert>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
using namespace std;

/*----------macros----------*/

//input, output================
#define fastio                          \
std::ios::sync_with_stdio(false);       \
std::cin.tie(nullptr);                  \
std::cout.tie(nullptr)

#define endl '\n'
#define fcout(a)                        \
cout << fixed << setprecision((int)(a))

//typedef===============
typedef long long       ll;
typedef long double     ld;
typedef vector<int>     Vi;
typedef vector<ll>      Vl;
typedef pair<int, int>  Pii;
typedef pair<ll, ll>    Pll;

//const number==========
constexpr ll INF    = (ll)1e9 + 1;
constexpr ll INFll  = (ll)1e18 + 1;
constexpr ll MOD1   = 1000000007;
constexpr ll MOD2   = 998244353;
constexpr ld PI     = 3.141592653589793L;

//member================
#define psb push_back
#define epb emplace_back
#define psf push_front
#define mkp make_pair
#define fst first
#define snd second

//others================
#define sz(x)                           \
(int) x.size()

#define all(x)                          \
(x).begin(), (x).end()

#define rall(x)                         \
(x).rbegin(), (x).rend()

#define rep(i, n)                       \
for(int i = 0; (i) < (n); ++(i))

#define reps(i, n)                      \
for(int i = 1; (i) <= (n); ++(i))

#define rrep(i, n)                      \
for(int i = n - 1; (i) >= 0 ; --(i))

#define repbit(bit, n)                  \
for(int bit = 0; (bit) < (1 << (n)); ++(bit))

#define ifbit(bit, i)                   \
if((bit) & (1 << (i)))

#define CtoI(c)                         \
int((c)) - int('0')

#define ItoC(c)                         \
char((c) + '0')

//functions=============
template<typename T1, typename T2>
inline bool chmax(T1 &a, T2 b)
{ return a < b && (a = b, true); }

template<typename T1, typename T2>
inline bool chmin(T1 &a, T2 b)
{ return a > b && (a = b, true); }

// Vi  dx = {1, 0, -1, 0},
//     dy = {0, 1, 0, -1};

// Vi  dx2 = { 1,1,0,-1,-1,-1,0,1 },
//     dy2 = { 0,1,1,1,0,-1,-1,-1 };

/*--------additional--------*/



/*----------main------------*/

int main() {
fastio;

    string n; cin >> n;
    rep(i, 3){
        if(n[i] == '1') n[i] = '9';
        else if(n[i] == '9') n[i] = '1';
    }

    cout << n << endl;

return 0;
}

Measured memory_bytes: 3616
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;
int main()
{

    int N;
    cin >> N;
    int K, tmp;
    cin >> K;
    long long result;
    result = 0;
    std::vector<long> H;

    for (int i = 0; i < N; i++)
    {
        cin >> tmp;
        H.push_back(tmp);
    }
    std::sort(H.begin(), H.end());

    if (K < N)
    {
        for (int i = 0; i < N - K; i++)
        {
            result += H[i];
        }
    }
    else
    {
        result = 0;
    }

    cout << result << endl;
    return 0;
}

Measured memory_bytes: 2420
"""
    こんにちは。これはクシャルです
    
    Author : thekushalghosh (クシャル)
    Team   : CodeDiggers
 
    I prefer Python language over the C++ language :p :D
        
    Visit my website : thekushalghosh.github.io
"""
import sys,math,cmath,time
start_time = time.time()
##########################################################################
################# ---- THE ACTUAL CODE STARTS BELOW ---- #################
    
def solve():
    print(int(not(int(input()))))
    
################## ---- THE ACTUAL CODE ENDS ABOVE ---- ##################
##########################################################################
 
def main():
    global tt
    if not ONLINE_JUDGE:
        sys.stdin = open("input.txt","r")
        sys.stdout = open("output.txt","w")
    t = 1
    for tt in range(t):
        solve()
    if not ONLINE_JUDGE:
        print("Time Elapsed :",time.time() - start_time,"seconds")
        sys.stdout.close()
    
#---------------------- USER DEFINED INPUT FUNCTIONS ----------------------#
def inp():
    return(int(input()))
def inlt():
    return(list(map(int,input().split())))
def insr():
    return(input().strip())
def invr():
    return(map(int,input().split()))
 
#------------------ USER DEFINED PROGRAMMING FUNCTIONS ------------------#
def counter(a):
    q = [0] * max(a)
    for i in range(len(a)):
        q[a[i] - 1] = q[a[i] - 1] + 1
    return(q)

def counter_elements(a):
    q = dict()
    for i in range(len(a)):
        if a[i] not in q:
            q[a[i]] = 0
        q[a[i]] = q[a[i]] + 1
    return(q)

def string_counter(a):
    q = [0] * 26
    for i in range(len(a)):
        q[ord(a[i]) - 97] = q[ord(a[i]) - 97],1
    return(q)
 
def factors(n):
    q = []
    for i in range(1,int(n ** 0.5) + 1):
        if n % i == 0: q.append(i); q.append(n // i)
    return(list(sorted(list(set(q)))))
 
def prime_factors(n):
    q = []
    while n % 2 == 0: q.append(2); n = n // 2
    for i in range(3,int(n ** 0.5) + 1,2):
        while n % i == 0: q.append(i); n = n // i
    if n > 2: q.append(n)
    return(list(sorted(q)))

def transpose(a):
    n,m = len(a),len(a[0])
    b = [[0] * n for i in range(m)]
    for i in range(m): 
        for j in range(n): 
            b[i][j] = a[j][i]
    return(b)

#-----------------------------------------------------------------------#
        
ONLINE_JUDGE = __debug__
if ONLINE_JUDGE:
    input = sys.stdin.readline
main()

Measured memory_bytes: 62808
#include<bits/stdc++.h>
using namespace std;
int main(){
	char a;
	cin>>a;
	if(a=='a' || a=='e' || a=='i' || a=='o' || a=='u'){
		cout<<"vowel"<<endl;
	}else{
		cout<<"consonant"<<endl;
	}
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp.to_s
ans = 0
s.each_char.with_index(1) do |c, i|
  if i % 2 == 0 && c == "R"
    ans = "No"
  elsif i % 2 == 1 && c == "L"
    ans = "No"
  else
    ans = "Yes"
  end
  if ans == "No"
    break
  end
end
puts ans

Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
int main(){
  int n;
  cin >> n;
  int a[n];
  for(int i=0;i<n;i++) cin >> a[i];

  int flag = 0;

  for(int i=0;i<n;i++){
    if(a[i]%2==0){
      if(a[i]%3!=0 && a[i]%5!=0) flag = 1;
    }
  }

  cout << (flag==0 ? "APPROVED" : "DENIED") << endl;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define LL long long
int n;
int a, b;
int data[100010];
int vis[100010];
struct node
{
	int id, a, b;
//	bool operator <(const node& x)
//	{
//		return (a - b) == (x.a - x.b) ? a > x.a : (a - b) < (x.a - x.b); 
//	}
} seg[100010], tag[100010];
//int vis[100010];
bool cmp1(node x, node y)
{
	return x.a + x.b > y.a + y.b;
}
bool cmp2(node x, node y)
{
	return (x.b - y.a) == (y.b - x.a) ? x.b > y.b : (x.b - y.a) < (y.b - x.a);
}
int main()
{
	ios::sync_with_stdio(false);
	cin.tie(0), cout.tie(0);
	cin >> n;
	for (int i = 1; i <= n; ++i)
	{
		cin >> a >> b;
		seg[i] = tag[i] = (node){i, a, b};
	}
	sort(seg + 1, seg + n + 1, cmp1);
	sort(tag + 1, tag + n + 1, cmp2);
	int l1 = 1, l2 = 1;
	long long sum1 = 0, sum2 = 0;
	for (int i = 1;  i <= n; ++i)
	{
		if (i & 1)
		{
			sum1 += seg[i].a;
		}
		else
		{
			sum2 += seg[i].b;
		}
	}
	cout << sum1 - sum2;
	return 0;
}


Measured memory_bytes: 2560
def High(cx, cy, x, y, h):
    return h + abs(x-cx) + abs(y-cy)

def high(cx, cy, x, y, High):
    return max(High - abs(x-cx) - abs(y-cy), 0)

n = int(input())
l = [list(map(int, input().split())) for _ in range(n)]

from operator import itemgetter
l = sorted(l, key=itemgetter(2) , reverse=1)

for i in range(101):
    for j in range(101):
        H = High(l[0][0], l[0][1], i, j, l[0][2])
        for k in l[1:]:
            if high(k[0], k[1], i, j, H) != k[2]:
                break
        else:
            print(i, j, H)
            break


Measured memory_bytes: 3064
using System;

namespace ITP1_1_C
{
	class Program
	{
		static void Main(string[] args)
		{
			string[] vs = Console.ReadLine().Split(' ');
			int a = int.Parse(vs[0]);
			int b = int.Parse(vs[1]);

			Console.WriteLine($"{a * b} {a * 2 + b * 2}");
		}
	}
}



Measured memory_bytes: 15896
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define rrep(i,n) for(int (i)=((n)-1);(i)>=0;(i)--)
#define itn int
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
const long long INF = 1LL << 60;
const int MOD = 1000000007;
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
//https://www.creativ.xyz/dump-cpp-652/
#define repi(itr, ds) for (auto itr = ds.begin(); itr != ds.end(); itr++)
 
// vector
template <typename T>
istream &operator>>(istream &is, vector<T> &vec) {
    for (T &x : vec) is >> x;
    return is;
}
// pair
template <typename T, typename U>
ostream &operator<<(ostream &os, pair<T, U> &pair_var) {
    os << "(" << pair_var.first << ", " << pair_var.second << ")";
    return os;
}
// vector
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
    os << "{";
    for (int i = 0; i < vec.size(); i++) {
        os << vec[i] << (i + 1 == vec.size() ? "" : ", ");
    }
    os << "}";
    return os;
}
// map
template <typename T, typename U>
ostream &operator<<(ostream &os, map<T, U> &map_var) {
    os << "{";
    repi(itr, map_var) {
        os << *itr;
        itr++;
        if (itr != map_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
// set
template <typename T>
ostream &operator<<(ostream &os, set<T> &set_var) {
    os << "{";
    repi(itr, set_var) {
        os << *itr;
        itr++;
        if (itr != set_var.end()) os << ", ";
        itr--;
    }
    os << "}";
    return os;
}
 
#define DUMPOUT cerr
 
void dump_func() {
    DUMPOUT << endl;
}
template <class Head, class... Tail>
void dump_func(Head &&head, Tail &&... tail) {
    DUMPOUT << head;
    if (sizeof...(Tail) > 0) {
        DUMPOUT << ", ";
    }
    dump_func(std::move(tail)...);
}

#ifdef DEBUG_
#define DEB
#define dump(...)                                                              \
    DUMPOUT << "  " << string(#__VA_ARGS__) << ": "                            \
            << "[" << to_string(__LINE__) << ":" << __FUNCTION__ << "]"        \
            << endl                                                            \
            << "    ",                                                         \
        dump_func(__VA_ARGS__)
#else
#define DEB if (false)
#define dump(...)
#endif

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n; cin>>n;
    string s; cin>>s;
    int q; cin>>q;
    rep(timpo, q){
        int k; cin>>k;
        int d=0,m=0,dm=0,ans=0;
        rep(i,n){
            if(i-k>=0){
                if(s[i-k]=='D') dm -= m, d--;
                if(s[i-k]=='M') m--;
            }
            if(s[i]=='D') d++;
            if(s[i] == 'M'){
                m++;
                dm += d;
            }
            if(s[i] == 'C') ans += dm;
        }
        cout<<ans<<endl;
    }
}

Measured memory_bytes: 1948
#include <stdio.h>

int main(){
	long long int b;
	int n,t,i,a2=0;
	scanf("%d",&n);
	t=n;
	
	if(n%2==0){
		for(i=0;i<n;i++){
			scanf("%lld",&b);
			if(b%4==0){
				t-=2;	
				if(t==0){
					printf("Yes\n");
					return 0;
				}
			}else if(b%2==0){
				a2++;
				if(a2%2==0){
					t-=2;
					a2=0;
				}
				if(t==0){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}else if(n%2==1){
		for(i=0;i<n;i++){
			scanf("%lld",&b);
			if(b%4==0){
				t-=3;	
				if(t<0 || (t==0 && a2==1)|| n==3){
					printf("Yes\n");
					return 0;
				}
			}else if(b%2==0){
				a2++;
				if(a2%2==0){
					t-=2;
					a2=0;
				}
				if(t<0 ||(t==0 && a2==1)){
					printf("Yes\n");
					return 0;
				}
			}
		}
	}
		
	printf("No\n");
	
return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
    using namespace std;
    int k, y;
    long long x;
    const long long maxi[] = {9, 99, 1999, 29999, 399999, 4999999, 59999999, 699999999LL, 7999999999LL, 89999999999LL, 999999999999LL, 9999999999999LL, 109999999999999LL, 1199999999999999LL, 100000000000000000LL};
    long long ten[25];
    int main()
    {
    #ifdef _noname
    	freopen("input.txt", "r", stdin);
    	freopen("output.txt", "w", stdout);
    #endif
    	scanf("%d", &k);
    	ten[0] = 1;
    	for (int i = 1; i <= 16; i++) ten[i] = ten[i - 1] * 10;
    	x = 0;
    	for (int i = 1; i <= k; i++)
    	{
    		y = 0;
    		while (x >= maxi[y]) y++;
    		x += ten[y];
    		printf("%lld\n", x);
    	}
    	return 0;
    }

Measured memory_bytes: 256
import sys
input = sys.stdin.readline

N,X=map(int,input().split())
vA=list(map(int,input().split()))
vA.sort()

res=0
for a in vA:
	if a<=X:
		res += 1
		X -= a
	else:
		break
else:
	if X:
		res = max(0, res-1)

print(res)


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
typedef signed long long ll;

#undef _P
#define _P(...) (void)printf(__VA_ARGS__)
#define FOR(x,to) for(x=0;x<(to);x++)
#define FORR(x,arr) for(auto& x:arr)
#define ITR(x,c) for(__typeof(c.begin()) x=c.begin();x!=c.end();x++)
#define ALL(a) (a.begin()),(a.end())
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,0xff,sizeof(a))
//-------------------------------------------------------

int N;
vector<int> E[202020];
const ll mo=998244353;
ll dp[202020][3][3];

pair<int,int> farthest(int cur,int pre,int d,vector<int>& D) {
	D[cur]=d;
	pair<int,int> r={d,cur};
	FORR(e,E[cur]) if(e!=pre) r=max(r, farthest(e,cur,d+1,D));
	return r;
}

pair<int,vector<int>> diameter() { // diameter,center
	vector<int> D[2];
	D[0].resize(N);
	D[1].resize(N);
	auto v1=farthest(0,0,0,D[0]);
	auto v2=farthest(v1.second,v1.second,0,D[0]);
	farthest(v2.second,v2.second,0,D[1]);
	pair<int,vector<int>> R;
	R.first = v2.first;
	//重心を取る場合
	for(int i=N-1;i>=0;i--) if(D[0][i]+D[1][i]==R.first && abs(D[0][i]-D[1][i])<=1) R.second.push_back(i);

	return R;
}

void dfs(int cur,int pre,int lef) {
	if(lef==0) {
		dp[cur][1][1]=1;
	}
	else {
		dp[cur][0][0]=1;
	}
	
	FORR(e,E[cur]) if(e!=pre) {
		dfs(e,cur,lef-1);
		ll to[3][3]={};
		int a1,a2,b1,b2;
		FOR(a1,3) FOR(a2,3) FOR(b1,3) FOR(b2,3) {
			// +1
			to[min(a1+b1,2)][a2]+=dp[cur][a1][a2]*dp[e][b1][b2]%mo;
			// 0
			to[a1][a2]+=dp[cur][a1][a2]*dp[e][b1][b2]%mo;
			// -1
			to[a1][min(a2+b2,2)]+=dp[cur][a1][a2]*dp[e][b1][b2]%mo;
		}
		
		FOR(a1,3) FOR(a2,3) dp[cur][a1][a2]=to[a1][a2]%mo;
	}
	
}


void solve() {
	int i,j,k,l,r,x,y; string s;
	
	cin>>N;
	FOR(i,N-1) {
		cin>>x>>y;
		E[x-1].push_back(y-1);
		E[y-1].push_back(x-1);
	}
	
	auto R=diameter();
	if(R.second.size()==1) {
		x=R.second[0];
		dfs(x,-1,R.first/2);
		cout<<dp[x][1][1]*((mo+1)/2)%mo<<endl;
	}
	else {
		x=R.second[0];
		y=R.second[1];
		dfs(x,y,R.first/2);
		dfs(y,x,R.first/2);
		ll X=(dp[x][0][1]+dp[x][1][1]+dp[x][2][1])%mo;
		ll Y=(dp[y][0][1]+dp[y][1][1]+dp[y][2][1])%mo;
		cout<<X*Y%mo<<endl;
	}
}


int main(int argc,char** argv){
	string s;int i;
	if(argc==1) ios::sync_with_stdio(false), cin.tie(0);
	FOR(i,argc-1) s+=argv[i+1],s+='\n'; FOR(i,s.size()) ungetc(s[s.size()-1-i],stdin);
	cout.tie(0); solve(); return 0;
}


Measured memory_bytes: 37344
#define LOCAL 1
#pragma region
#define _USE_MATH_DEFINES
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cmath>
#include <complex>
#include <cstdio>
#include <cstring>
#include <ctime>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

template <typename A, typename B>
ostream &operator<<(ostream &out, const pair<A, B> &a) {
  out << "(" << a.first << "," << a.second << ")";
  return out;
}
template <typename T, size_t N>
ostream &operator<<(ostream &out, const array<T, N> &a) {
  out << "[";
  bool first = true;
  for (auto &v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "]";
  return out;
}
template <typename T>
ostream &operator<<(ostream &out, const vector<T> &a) {
  out << "[";
  bool first = true;
  for (auto &v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "]";
  return out;
}
template <typename T, class Cmp>
ostream &operator<<(ostream &out, const set<T, Cmp> &a) {
  out << "{";
  bool first = true;
  for (auto &v : a) {
    out << (first ? "" : ", ");
    out << v;
    first = 0;
  }
  out << "}";
  return out;
}
template <typename U, typename T, class Cmp>
ostream &operator<<(ostream &out, const map<U, T, Cmp> &a) {
  out << "{";
  bool first = true;
  for (auto &p : a) {
    out << (first ? "" : ", ");
    out << p.first << ":" << p.second;
    first = 0;
  }
  out << "}";
  return out;
}
#ifdef LOCAL
#define trace(...) cerr << "@" << __LINE__ << " -> "; __f(#__VA_ARGS__, __VA_ARGS__)
#else
#define trace(...) 
#endif
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...);
}
#define ll long long
#define sz(x) (int)((x).size())
#define all(x) (x).begin(), (x).end()
#pragma endregion

void solve() {
  int n;
  cin >> n;
  vector<int> v(n);
  for (int &x : v) cin >> x, x--;
  vector<bool> vis(n);
  int ans = 0;
  bool found = false;
  int now = 0;
  while (true) {
    if (vis[now]) break;
    vis[now] = 1;
    now = v[now];
    ans++;
    if (now == 1) {
      found = true;
      break;
    }
  }
  cout << (found ? ans : -1) << endl;
}

signed main() {
  cin.tie(nullptr);
  ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
  int t;
  t = 1;
  while (t--) solve();
}

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

int main(){
    
    
    while(true){
        
        
        int a,b;
        cin>>a>>b;
        if(a==0&&b==0)break;
        for(int i=0;i<a;i++){
            for(int j=0;j<b;j++){
                cout<<'#';
            }
            cout<<endl;
        }
        
        cout<<endl;
        
    }
    
    
    
    
}


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

using namespace std;

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

string s;
vector<int> pos[26];
int num_odd = 0;
vector<pi> pairs;
int arr[200005], temp[200005];
ll inv_count = 0;

void merge_sort(int S, int E){
	if (S == E) return;
	int M =  (S+E)/2;
	merge_sort(S,M);
	merge_sort(M+1,E);
	int pt1 = S, pt2 = M+1, pt = S;
	while (pt1 <= M && pt2 <= E){
		if (arr[pt1] < arr[pt2]){
			temp[pt] = arr[pt1];
			pt1++;
		}
		else{
			temp[pt] = arr[pt2];
			inv_count += (M - pt1 + 1);
			pt2++;
		}
		pt++;
	}
	while (pt1 <= M){
		temp[pt] = arr[pt1];
		pt1++;
		pt++;
	}
	while (pt2 <= E){
		temp[pt] = arr[pt2];
		pt2++;
		pt++;
	}
	for (int i = S; i <= E; ++i){
		arr[i] = temp[i];
	}
}

int main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cin >> s;
	int N = s.size();
	for (int i = 0; i < s.size(); ++i){
		pos[s[i]-'a'].push_back(i);
	}
	for (int i = 0; i < 26; ++i){
		if (pos[i].size()%2==1){
			num_odd++;
		}
	}
	if (num_odd > 1){
		cout << -1 << '\n';
		return 0;
	}
	for (int i = 0; i < 26; ++i){
		if (pos[i].size()%2==1){
			for (int j = 0; j < pos[i].size()/2; ++j){
				pairs.push_back(pi(pos[i][j],pos[i][pos[i].size()-j-1]));
			}
			arr[(N-1)/2] = pos[i][(pos[i].size()-1)/2]; 
		}
		else{
			for (int j = 0; j < pos[i].size()/2; ++j){
				pairs.push_back(pi(pos[i][j],pos[i][pos[i].size()-j-1]));
			}
		}
	}
	sort(pairs.begin(),pairs.end());
	for (int i = 0; i < pairs.size(); ++i){
		arr[i] = pairs[i].first;
		arr[N-i-1] = pairs[i].second;
	}
	/*
	for (int i = 0; i < N; ++i){
		cout << arr[i] << '\n';
	}
	*/
	merge_sort(0,N-1);
	cout << inv_count << '\n';
}

Measured memory_bytes: 4620
#include<bits/stdc++.h>
using namespace std;
const int N = 1e5+100;
const int M = 200;
typedef long long ll;
int a[N],b[N],n,m;
ll f[N];

int main(){
	scanf("%d%d",&n,&m);
	for (int i = 0; i < n; ++i)
		scanf("%d%d",&a[i],&b[i]);
	memset(f, 0x3f, sizeof f);
	f[0] = 0;
	for (int i = 0; i < n; ++i)
		for (int j = N - 10; j >= 0; j--)
			if (j - b[i] >= 0) f[j] = min(f[j], f[j-b[i]] + a[i]);

	int ans = 0;
	for (int i = 0; i < N; ++i)
		if (f[i] <= m) ans = i;
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
import sys
import math
from collections import deque
import heapq
import itertools
MAX_INT = int(10e25)
MIN_INT = -MAX_INT
mod = 1000000000+7
sys.setrecursionlimit(1000000)
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

a,b = IL()
print(a*b)

Measured memory_bytes: 65064
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力(スペース改行関係なし)
		int k = sc.nextInt();
		String answer = "";
      
      for(int i = 0 ; i < k ; i++){
      	answer = answer + "ACL";
      
      }


			// 出力
			System.out.println(answer);

		
	}
}

Measured memory_bytes: 38636
N, M, C = map(int, input().split())
B = list(map(int, input().split()))
result = 0
for i in range(N):
    A = list(map(int, input().split()))
    sum =0
    for j in range(len(A)):
        sum+=A[j]*B[j]
    if(sum + C > 0):
        result+=1
print(result)


Measured memory_bytes: 3060
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
    int x, y, z;
    cin >> x >> y >> z;
    swap(x, y);
    swap(x, z);
    cout << x << " " << y << " " << z << endl;
    return 0;
}

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

using namespace std;

typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
//#define int ll
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<ld> vld;
typedef vector<vld> vvld;
typedef pair<ld, ld> pld;

#define inmin(a, b) a = min(a, (b))
#define inmax(a, b) a = max(a, (b))
#define mp(a, b) make_pair((a), (b))
#define ALL(a) a.begin(),a.end()
#define RALL(a) a.rbegin(),a.rend()
#define SZ(a) ((int)((a).size()))
#define watch(x) cerr << (#x) << " = " << (x) << endl;

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
mt19937_64 rng_64(chrono::steady_clock::now().time_since_epoch().count());

template<class T0, class T1>
inline ostream &operator<<(ostream &out, pair<T0, T1> &a) {
    return out << "{" << a.first << ", " << a.second << "}";
}

template<class T>
inline ostream &operator<<(ostream &out, vector<T> &a) {
    out << "[";
    for (int i = 0; i < a.size(); i++)
        out << a[i] << vector<string>{", ", "]  "}[i + 1 == a.size()];
    return out;
}


void smain();

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

#ifdef RUS_HOME
    freopen("input.txt", "r", stdin);
    clock_t start = clock();
#else
    //    freopen("king.in", "r", stdin);
    //    freopen("king.out", "w", stdout);
#endif

    cout << setprecision(12) << fixed;
    smain();

#ifdef RUS_HOME
    cout << "\n\n\n\nTOTAL EXECUTION TIME: " << float(clock() - start) / CLOCKS_PER_SEC << endl;
#endif

    return 0;
}

void smain() {



    int n;
    cin >> n;
    vi cnt(n, 1);
    vector <bool> used(n);

    used[0] = true;

    int m;
    cin >> m;
    for (int i = 0; i < m; i++) {
        int a, b;
        cin >> a >> b;
        a--, b--;
        if (cnt[a] == 0) {
            continue;
        }
        cnt[a]--;
        cnt[b]++;
        if (used[a]) {
            used[b] = true;
        }
        if (!cnt[a]) {
            used[a] = false;
        }

    }
    int sum = 0;
    for (int i = 0; i < n; i++) {
        sum += (used[i]);
    }

    cout << sum;







}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main(){
    int N,K;
    cin>> N >> K;
    vector<int> h(200000);
    for(int i =0;i < N;i++)
    cin >> h[i];
    int ans=0;
    for(int i=0;i<N ;i++){
        if(h[i]>=K)
        ans += 1;
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
$MAX = 1000
$VMAX = 10000

$n = gets.to_i
$a = gets.split.map(&:to_i)
$b = Array.new($MAX)
$t = Array.new($VMAX+1)
$m = $VMAX

def solve
  ans = 0
  v = Array.new($MAX){false}
  $b = $a.sort

  $b.each_with_index do |item, i|
    # $tには、各要素が何番目かが入る
    # $t[item] とすると、itemがソーティングしたときに何番目かが分かる。
    $t[item] = i
  end

  0.upto($n-1) do |i|
    cur = i
    w = 0
    m = $VMAX
    an = 0

    #サイクルを生成するループ
    loop do
      #サイクルが閉じたかどうか
      v[cur] = true
      #サイクル内の要素数
      an += 1
      item = $a[cur]
      #サイクル内のminを更新
      m = [m, item].min
      #コストを足す
      w += item
      #次の要素へ
      cur = $t[item]
      #サイクルが閉じたらbreak
      if v[cur]
        break
      end
    end

    ans += [w+(an-2)*m, m+w+(an+1)*$m].min
  end
  return ans
end

$m = $a.min

ans = solve

puts ans


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

using namespace std;

#define ALL(g) (g).begin(),(g).end()
#define REP(i, x, n) for(int i = (int) x; i < (int)n; i++)
#define rep(i,n) REP(i,0,n)
#define RREP(i, x, n) for(int i = (int) n; i > (int)x; i--)
#define rrep(i,n) RREP(i,0,n)
#define F(i,j,k) fill(i[0],i[0]+j*j,k)
#define P(p) cout<<(p)<<endl;
#define EXIST(s,e) ((s).find(e)!=(s).end())
#define INF 1<<29
#define pb push_back
#define SZ(x) ((int)(x).size())

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

int main (){
  int w, a, b;
  cin >> w >>a>>b;
  if((a <= b && b <= a+w )||(b <= a && a <= b+w)){
    P(0);
  }else if(a<b){
     P(b-a-w);
  }else{
     P(a-b-w);
  }
  
  return 0;
}


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

int main() {
  string s;
  cin >> s;
  vector <int> vec(s.size());
  vector <int> end_point(s.size());
  vector <int> ret(s.size());
  for(int i = 0; i<s.size(); i++){
    if(s.at(i) == 'R')
      vec.at(i) = 1;
    else
      vec.at(i) = -1;
  }
  vec.push_back(1);
  
  int y=0, y_prev=-1;
  
  for(int i = 0; i<s.size(); i++){
    if(vec.at(i) != vec.at(i+1)) {
      y = i;
      if(vec.at(i) == 1){
	ret.at(y) +=(y - y_prev + 1) /2;
	ret.at(y+1) += (y - y_prev) / 2 ;
      } else {
	ret.at(y_prev) += (y - y_prev) / 2 ;
	ret.at(y_prev+1) +=(y - y_prev + 1) /2;
      }
      y_prev=y;      
    }
    
  }
  for(int i = 0; i<s.size(); i++) {
    if(i==0)
      cout << ret.at(i);
    else
      cout << " " << ret.at(i);
  }
  cout << endl;
  return 0;
}


Measured memory_bytes: 2048
import java.util.Scanner;

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

        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int x = sc.nextInt();
        int y = sc.nextInt();
        long ans = 0;

        int min = Math.min(x, y);
        if ((a*min + b*min) > c*min*2) {
            ans += c*min*2;
            x -= min;
            y -= min;
        } else {
            ans += a*min + b * min;
            x -= min;
            y -= min;
        }

        int num = x > y ? a : b;
        int max = Math.max(x, y);
        if (num*max > c*max*2) {
            ans += c*max*2;
        } else {
            ans += num * max;
        }

        System.out.println(ans);
    }
}


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

#define REP(i,s,n) for(int i=s;i<n;i++)
#define rep(i,n) REP(i,0,n)
#define IINF (INT_MAX)
#define MAX_LIMIT 1100
#define MAX 110

using namespace std;

int pre[MAX_LIMIT][3],pre2[MAX_LIMIT][MAX],LIMIT,N,M,X,SEC_E[MAX],SEC_S[MAX],E[MAX],S[MAX];
string tmp;


int main(){
  while(cin >> LIMIT >> N >> M >> X, LIMIT|N|M|X){
    rep(i,N)cin >> tmp >> SEC_E[i] >> SEC_S[i];
    rep(i,M)cin >> tmp >> E[i] >> S[i];
    rep(i,LIMIT+1)rep(j,3)pre[i][j] = -1;
    rep(i,LIMIT+1)rep(j,MAX)pre2[i][j] = -1;
    pre[0][0] = pre2[0][0] = 0;

    rep(i,N)for(int j=1;j>=0;j--)rep(k,LIMIT+1){
	if( pre[k][j] == -1 ) continue;
	int total_money = k + SEC_E[i];
	if( total_money > LIMIT ) continue;
	pre[total_money][j+1] = max(pre[total_money][j+1],pre[k][j]+SEC_S[i]);
      }

    rep(i,3)rep(j,LIMIT+1)if( j ) pre[j][i] = max(pre[j][i],pre[j-1][i]);

    rep(i,M)for(int j=M-1;j>=0;j--)rep(k,LIMIT+1){
	if( pre2[k][j] == -1 ) continue;
	int total_money = k + E[i];
	if( total_money > LIMIT ) continue;
	pre2[total_money][j+1] = max(pre2[total_money][j+1],pre2[k][j]+S[i]);
      }

    rep(i,M+1)rep(j,LIMIT+1)if( j ) pre2[j][i] = max(pre2[j][i],pre2[j-1][i]);

    int ans = 0;

    REP(i,X,M+1)REP(j,1,3)rep(k,LIMIT+1){
      if( pre2[k][i] == -1 || pre[LIMIT-k][j] == -1 ) continue;
      int points = pre2[k][i] + pre[LIMIT-k][j];
      ans = max(ans,points);
    }

    cout << ans << endl;

  }
  return 0;
}

Measured memory_bytes: 1648
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (int i = m; i < (n); ++i)
using namespace std;
using ll = long long;

int main(){
    int n;
    cin >> n;
    vector<int> ne(n);
    rep(i,n){
        cin >> ne[i];
    }
    int cnt = 1;
    bool t = true;
    vector<int> ima(n);
    stack<int> ana;
    ana.push(0);
    rep(j,n){
        if (ne[j] > 0){
            if (ima[ne[j]-1] == 0){
                ana.push(ne[j]);
                ima[ne[j]-1] = 1;
            }
            else{
                cnt += j;
                t = false;
                break;
            }
        }
        else{
            if (ana.top() + ne[j] == 0){
                ana.pop();
                ima[-ne[j]-1] = 0;
            }
            else{
                cnt += j;
                t = false;
                break;
            }
        }
    }
    if (t){
        cout << "OK" << endl;
    }
    else{
        cout << cnt << endl;
    }
}


Measured memory_bytes: 3092