akhauriyash/Code-Regression huggingface dataset:
#include <algorithm>
#include <iostream>
#include <map>
#include <numeric>
#include <set>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
#include <queue>
#define MOD (1000000007l)
#define rep(i, n) for(long i = 0; i < n; i++)

using namespace std;

void solve() {
  long D, N;
  cin >> D >> N;

  long a = 1;
  long b = 100;
  if (D == 1) {
    a = 100;
    b = 10000;
  }
  if (D == 2) {
    a = 10000;
    b = 1000000;
  }

  long result = 0;
  while (N) {
    result += a;
    if (result % b) N--;
  }

  cout << result << endl;
}

int main(void) {
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout.precision(12);
  solve();
  return 0;
}


Measured memory_bytes: 256
N,A,B,C,D=map(int,input().split())
S=input()
a=1
for i in range(A,C-2):
    if S[i]==S[i+1]=="#":
        a=0
        break
for i in range(B,D-2):
    if S[i]==S[i+1]=="#":
        a=0
        break
if C>D:
    for i in range(B-1,D):
        if S[i-1]==S[i]==S[i+1]==".":
            break
    else:
        a=0
print("Yes" if a else "No")

Measured memory_bytes: 3572
N,M=map(int,input().split())
G=[list() for _ in range(N+1)]
for i in range(M):
    c,d=map(int,input().split())
    G[c].append(d)
    G[d].append(c)

ans = []
for i in range(1,N+1):
    ans.append(len(G[i]))

for i in range(N):
    print(ans[i])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < n; i++)
#define INF 10000000000
using namespace std;
using ll = long long;
ll dp[3][1002][1002];
int main()
{
    int n, m;
    cin >> n >> m;
    vector<ll> x[3];
    rep(i,n){
        ll a[3];
        rep(cur,3){
            cin >> a[cur];
            x[cur].push_back(a[cur]);
        }
    }
    ll ans = 0;
    rep(i,8){
        vector<ll> v;
        rep(j,n){
        ll tmp = 0;
            if((i+1)&1){
                tmp += x[0][j];
            }else{
                tmp -= x[0][j];
            }
            if((i+1)&2){
                tmp += x[1][j];
            }else{
                tmp -= x[1][j];
            }
            if((i+1)&4){
                tmp += x[2][j];
            }else{
                tmp -= x[2][j];
            }
            v.push_back(tmp);
        }
        sort(v.rbegin(), v.rend());
        ll tmp = 0;
        rep(i,m){
            tmp += v[i];
        }
        ans = max(ans, tmp);
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
loop do
	n = STDIN.gets.to_i
	break if n.zero?

	pattern = ''
	replace = ''
	n.times do
		p, r = STDIN.gets.split
		pattern <<= p
		replace <<= r
	end

	str = ''
	STDIN.gets.to_i.times do
		str <<= STDIN.gets[0]
	end

	puts str.tr(pattern, replace)
end

Measured memory_bytes: 6316
# 座標xからtimes回、距離distだけ移動する
x, times, dist = gets.chomp.split.map(&:to_i)
# 原点からの距離absol
absol = x.abs
# 原点を通りすぎず最接近するまでの手数min
min = absol / dist
# 通り過ぎることができない場合
if min >= times
  # できる限り（times回、距離dist）近づいて出力
  puts absol - times * dist
  # 原点の手前まで最接近してから、原点を奇数回またぐ場合
elsif (times - min).odd?
  # 原点の手前まで最接近して、1回またいだときの位置を出力
  puts (min + 1) * dist - absol
  # 原点の手前まで最接近してから、原点を偶数回またぐ場合
else
  # 原点の手前まで最接近したときを出力
  puts absol % dist 
end

Measured memory_bytes: 14308
object Main extends App {
  val sc = new java.util.Scanner(System.in)
  val S = sc.next()
  val splited = 1.until("keyence".length).map("keyence".splitAt)
  val isExists = S.startsWith("keyence") || S.endsWith("keyence") ||
    splited.exists { case (l, r) => S.startsWith(l) && S.endsWith(r) }
  println(if (isExists) "YES" else "NO")
}


Measured memory_bytes: 55440
#include<bits/stdc++.h>
//#define local
#define forn(a,n) for(int i = a; i < n; i++)
#define mod 1000000007


using namespace std;

typedef long long int ll;
typedef vector<int> vec;
typedef vector<ll> vecl;
typedef unsigned long long int ull;
typedef vector<ull> vecu;


void print(const vecl &a)
{
    forn(0,a.size())
        cout << a[i] << " ";
    cout << "\n";
}
void solve()
{
    int n;
    cin >> n;
    vecl a(n);
    forn(0, n)
        cin >> a[i];
    vecl sum(n);
    sum[n - 1] = a[n-1];
    forn(1, n)
        sum[n - i - 1] = (sum[n - i] + a[n - i - 1]) % mod;
       // print(sum);
    ull ans = 0;
    forn(0, n-1)
    {
        ans %= mod;
        ans += (a[i] * sum[i+1]) % mod;
    }
    ans %= mod;
    cout << ans;
    
}



int main()
{
    #ifdef local
        freopen("input.txt", "r", stdin);
    #endif
            solve();
}

Measured memory_bytes: 6352
#include <iostream>
#include <string>
#include <map>
#include <vector>
#include <algorithm>
#include <set>
#include <stdio.h>
#include <cmath>
#include <queue>
#include <cmath>
#include <math.h>

typedef long long ll;
using namespace std;
ll mod = 1000000007;
int main(void){
    ll N, K;
    cin >> N >> K;
    ll smaller;
    ll larger;
    ll ans = 0;
    for(ll i=K; i<=N+1; i++){
        smaller = i*(i-1)/2;
        larger = i*(2*N-i+1)/2;
        ll res = larger - smaller + 1;
        ans = (ans + res) % mod;
        ans = ans%mod;
    }
    cout << ans << endl;
}



Measured memory_bytes: 3660
#include <cassert>
#include <algorithm>
#include <bitset>
#include <cctype>
#include <cmath>
#include <complex>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <vector>
#include <random>
#include <memory>
#include <utility>
#include <limits>
#include "limits.h"
 
#define rep(i, a, b) for (long long (i) = (a); i < (b); i++)
#define all(i) i.begin(), i.end()
#define debug(...) std::cerr << "[" << #__VA_ARGS__ << "]:", debug_out(__VA_ARGS__)

void debug_out(){std::cerr<<std::endl;}

template<typename Head,typename... Tail>
void debug_out(Head h,Tail... t){
  std::cerr<<" "<<h;
  debug_out(t...);
}

 
template <typename T1, typename T2>
std::ostream& operator<<(std::ostream& os, std::pair<T1, T2> pa) {
  return os << pa.first << " " << pa.second;
}
 
template <typename T>
std::ostream& operator<<(std::ostream& os, std::vector<T> vec) {
  for (int i = 0; i < vec.size(); i++)os << vec[i] << (i + 1 == vec.size() ? "" : " ");
  return os;
}
 
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);}
 
long long pow_mod(long long a, long long b, long long mod=-1) {
  if(b==0)return 1;

  if ((a == 0)||(mod!=-1&&(a+mod)%mod==0)) {
    return 0;
  }
 
  long long x = 1;
 
  while (b > 0) {
    if (b & 1) {
      x = (mod!=-1)?(x * a) % mod:x*a;
    }
    a = (mod!=-1)?(a * a) % mod:a*a;
    b >>= 1;
  }
  return x;
}
 
const long long MOD = 998244353;
// const long long MOD = 1e9 + 7;

using ll = long long;
using P = std::pair<long long, long long>;

ll gcd(ll a,ll b){
  if(a%b==0)return b;
  return gcd(b,a%b);
}

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

  ll n,m;
  std::cin>>n>>m;

  std::vector<ll> a(n),cnt(n);
  rep(i,0,n){
    std::cin>>a[i];
    a[i]/=2;
    ll temp=a[i];
    while(temp%2==0){
      cnt[i]++;
      temp/=2;
    }
  }

  rep(i,0,n){
    if(cnt[i]!=cnt[0]){
      std::cout<<0<<"\n";
      return 0;
    }
  }

  ll x=1;
  rep(i,0,n){
    ll g=gcd(x,a[i]);
    x*=a[i]/g;
  }

  ll lim=m/x;

  if(lim<1)std::cout<<0<<"\n";
  else std::cout<<(lim+1)/2<<"\n";

  return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG //これつけるとA[N]でもいいらしい
//for文のマクロ
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define big 1000000007
#define all(a) sort((a).begin(),(a).end()) //ソートのマクロ
#define Re(a) reverse((a).begin(),(a).end())
int main(){
    int a,b,c;
  cin>>a>>b>>c;
  cout<<min(b/a,c)<<endl;
}
  

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,n,t,A;
    cin>>n>>t>>A;
    double a,p=0,q=0,mn=1000000,ans=0;;
    for(i=1; i<=n; i++)
    {
        cin>>a;
        p=t-(a*0.006);
        q=abs(p-A);

        if(mn>q)
        {mn=q;
            ans=i;
        }


    }
cout<<ans<<endl;




}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
using ll = long long;
ll GetDigit(ll num){ return log10(num)+1; } //numの桁数を求める

int main()
{
    string s;
    cin >>s;
    if(s[2] == s[3] && s[4] == s[5]) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 3716
base = 2500
n,a = map(int, input().split())
dat_x = list(map(int, input().split()))
dat_x = list(map(lambda x: x - a, dat_x))

#print(dat_x)
dp = []
for i in range(50 + 12):
    dp.append([0] * 5002)

dp[0][base] = 1
#print(dp[0][2500 - 10: 2500 + 10])
for i in range(1, n + 1):
    for j in range(5001):
        dp[i][j] += dp[i - 1][j]

        #print(j + dat_x[i-1])
        if dp[i - 1][j] != 0:
            dp[i][j + dat_x[i-1]] += dp[i - 1][j]
    #print(dp[i][2500 - 10: 2500+10])
print(dp[n][base] - 1)

Measured memory_bytes: 6004
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K, A, B;
  cin >> K >> A >> B;
  bool can = false;
  for (int i=A; i<=B; i++){
    if(i%K==0) can = true;
  }
  string ans = "NG";
  if(can) ans = "OK";
  cout << ans << endl;
}

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

#define MOD 1000000007
typedef unsigned long long ull;

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

  int hanten = 0;
  string sentou, matubi;
  sentou = matubi = "";

  for (int i = 0; i < q; i++) {
    int ti, fi;
    string ci;
    cin >> ti;

    if (ti == 1) {
      hanten++;
    } else {
      cin >> fi >> ci;
      // cout << ti << " " << fi << " " << ci << endl;

      if (ti == 1) {
        // 1
        hanten++;
      } else {
        // 2
        if (fi == 1) {
          // 先頭に追加する
          // 反転モードの場合は末尾
          if (hanten % 2 == 0) {
            // 先頭
            sentou = ci + sentou;
          } else {
            // 末尾
            matubi += ci;
          }
        } else {
          // 末尾に追加する
          // 反転モードの場合は先頭
          if (hanten % 2 == 0) {
            // 末尾
            matubi += ci;
          } else {
            // 先頭
            sentou = ci + sentou;
          }
        }
      }
    }

    // cout << i + 1 << ": " << s << endl;
  }

  // 先頭と末尾を繋げる
  s = sentou + s + matubi;

  // 反転させる
  // hantenが偶数なら反転しないでいい
  if (hanten % 2 == 1) {
    reverse(s.begin(), s.end());
  }
  cout << s;
}


Measured memory_bytes: 1360
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,n) for (int64_t i=0; i<(n); ++i)
#define P pair<int,int>
using ll=int64_t;
using namespace std;
#define ketasuu(n) fixed<<setprecision(n)
#define btoe(p) p.begin(),p.end()
#define etob(p) p.rbegin(),p.rend()
#define chmax(x,y) x=max(x,y)




int main(){
    string s; cin>>s;
    if(s[0]==s[1] && s[1]==s[2] || s[1]==s[2] && s[2]==s[3]){
        cout<<"Yes"<<endl;
    }else{
        cout<<"No"<<endl;
    }
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
using lli = long long;
#define rep(i,n) for(int i=0;i<n;i++)
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 (b<a) { a=b; return 1; } return 0; }

lli n;

int main(void){
    cin >> n;
    lli l, r;
    l = 0;
    r = n-1;
    string ls, rs;
    cout << l << endl << flush;
    cin >> ls;
    if(ls == "Vacant") return 0;
    cout << r << endl << flush;
    cin >> rs;
    if(rs == "Vacant") return 0;
    lli x;
    rep(i, 18){
        string s;
        x = (l+r)/2;
        cout << x << endl << flush;
        cin >> s;
        if(s == "Vacant") return 0;
        if((x-l)%2 == 0 && s != ls || (x-l)%2 == 1 && s == ls){
            r = x;
            rs = s;
        }else{
            l = x;
            ls = s;
        }
    }
    return 0;
}


Measured memory_bytes: 3844
#include <bits/stdc++.h>
using namespace std;
int main(){
  string S;
  cin >> S;
  bool res = false;
  for (int i = 0; i < S.size() - 1; i++){
    if (S.at(i) == 'A' && S.at(i+1) == 'C') res = true;
  }
  if (res){
    cout << "Yes";
  } else {
    cout << "No";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <algorithm>
#include <numeric>
#include <functional>
#include <cmath>
#include <string>

using namespace std;
int main(int argc, const char * argv[]) {
    
    string s;
    cin >> s;

    int t = 753;
    int min = 1000000000;
    for (int i=0; i<s.size()-2; i++) {

        string sub = s.substr(i, 3);
        min = std::min(min, abs((int)stoi(sub) - t));
    }
    cout << min << endl;
    return 0;
}

Measured memory_bytes: 256
from collections import Counter
def MI(): return map(int, input().split())
def II(): return int(input())
def IS(): return input()
def LI(): return list(map(int, input().split()))


n = II()
eigyo_times = [LI() for _ in range(n)]
p = [LI() for _ in range(n)]
bits = []

# それぞれの時間帯で営業するorしないを全探索しても2^10通り
for i in range(2 ** 10):
    op = [0] * 10
    for j in range(10):
        if ((i >> j) & 1):
            op[10-1-j] = 1
            bits.append(op)

profit = -(10**100)
for i, bit in enumerate(bits):
    if bit == [0,0,0,0,0,0,0,0,0,0]:  # 1つ以上の時間帯で店を営業しなければならない
        continue
    tmp_profit = 0
    for j, eigyo_time in enumerate(eigyo_times):
        # joisinoお姉ちゃんと店両方が営業している時間帯の個数を求める
        count = len([k for k in range(10) if bit[k] & eigyo_time[k]])
        tmp_profit += p[j][count]
    profit = max(profit, tmp_profit)
print(profit)


Measured memory_bytes: 3572
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
 
public class Main {
 
	public static void main(String[] args) throws IOException {
		BufferedReader input =new BufferedReader (new InputStreamReader (System.in));
		String strn = input.readLine( );
		int n = Integer.parseInt(strn);
		int[] list = new int[n+1];
		Arrays.fill(list, 0);
		long answer = 1;
		int x = 0;
 
		for(int i=1; i<n+1; i++){
			x = i;
			for(int j=1; j<i+1; j++){
				while((x)%(j) == 0){
					list[j] = list[j]+1;
					x = x / (j);
					if(j==1){
						break;
					}
				}
			}
		}
 
		for(int i=2; i<n+1; i++){
			answer = answer * (list[i]+1);
			answer = answer % (int)(Math.pow(10, 9)+7);
		}
 
		System.out.println(answer);
	}
 
}

Measured memory_bytes: 21460
fun main(args: Array<String>) {
    val n = readLine()!!.toInt()

    var ans = arrayOfNulls<Int>(n)
    val a = readLine()!!.split(" ").map(String::toInt)
    repeat(n){ ans[a[it] -1] = it + 1 }
    println(ans.joinToString(separator = " "))
}


Measured memory_bytes: 58036
#define LOCAL

#undef _GLIBCXX_DEBUG

#include <bits/stdc++.h>
using namespace std;

#define IOS ios::sync_with_stdio(false);cin.tie(0)
#define all(x) x.begin(), x.end()
#define ff first
#define ss second
#define MOD 1000000007LL
#define LLINF 100000000000000005LL
#define INF (int)1e9+1

// Copied from Gennady-Korotkevich's template

template <typename A, typename B>
string to_string(pair<A, B> p);

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p);

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p);

string to_string(const string& s) {
	return '"' + s + '"';
}

string to_string(const char* s) {
	return to_string((string)s);
}

string to_string(bool b) {
	return (b ? "true" : "false");
}

string to_string(vector<bool> v) {
	bool first = true;
	string res = "{";
	for (int i = 0; i < static_cast<int>(v.size()); i++) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(v[i]);
	}
	res += "}\n";
	return res;
}

template <size_t N>
string to_string(bitset<N> v) {
	string res = "";
	for (size_t i = 0; i < N; i++) {
		res += static_cast<char>('0' + v[i]);
	}
	return res;
}

template <typename A>
string to_string(A v) {
	bool first = true;
	string res = "{";
	for (const auto& x : v) {
		if (!first) {
			res += ", ";
		}
		first = false;
		res += to_string(x);
	}
	res += "}\n";
	return res;
}

template <typename A, typename B>
string to_string(pair<A, B> p) {
	return "(" + to_string(p.first) + ", " + to_string(p.second) + ")";
}

template <typename A, typename B, typename C>
string to_string(tuple<A, B, C> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ")";
}

template <typename A, typename B, typename C, typename D>
string to_string(tuple<A, B, C, D> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + ")";
}

template <typename A, typename B, typename C, typename D, typename E>
string to_string(tuple<A, B, C, D, E> p) {
	return "(" + to_string(get<0>(p)) + ", " + to_string(get<1>(p)) + ", " + to_string(get<2>(p)) + ", " + to_string(get<3>(p)) + "," + to_string(get<4>(p)) + ")";
}

void debug_out() {
	cerr << endl;
}

template <typename Head, typename... Tail>
void debug_out(Head H, Tail... T) {
	cerr << " " << to_string(H);
	debug_out(T...);
}

#ifdef LOCAL
#define debug(...) cerr << "\n[" << #__VA_ARGS__ << "]:\n", debug_out(__VA_ARGS__)
#else
#define debug(...) 42
#endif

// End of Gennady-Korotkevich's template 

using llong = long long;
using PII = pair<int, int>;

int main() {
	IOS;
	int a, b; cin >> a >> b;
	cout << 6 - a - b;
}

Measured memory_bytes: 3588
N,x=map(int, raw_input().split() )
A=map(int, raw_input().split() )

A.sort()

ans=0
for i in range(N):
	a=A[i]
	if x-a>=0:
		if i==N-1:
			if x==a:
				ans+=1
		else:
			ans+=1
			x-=a
	else:
		break

print ans

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

int main(int argc, char *argv[]) {
  ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout.tie(nullptr);

  string s;cin>>s;
  if(s<="2019/04/30"){
    cout<<"Heisei"<<endl;
  }else{
    cout<<"TBD"<<endl;
  }

  return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<string>
#include <cmath>
using namespace std;
typedef long long ll;
 
int main(){
 
ll ans = 1;
int a[100100] = {0};
const int MOD = 1e9+7;
 
int n;
cin >> n;
 
for(int i = 0; i < n; i++) {int p; cin >> p; a[p]++;}
 
if(n % 2 == 1) {
 if(a[0] != 1)  ans = 0;
else for(int i = 2; i < n; i+=2)
if(a[i] == 2) (ans *= 2) %= MOD;
else {cout << 0 << endl; return 0;}
}
 
else{
for(int i = 1; i < n; i += 2)
if(a[i] == 2)  (ans *= 2) %= MOD;
else  {cout << 0 << endl; return 0;}
}
 
cout << ans << endl;
 
return 0;
}

Measured memory_bytes: 640
#include <bits/stdc++.h>
using namespace std;
#define pb push_back
#define int long long
#define F first
#define S second
typedef pair<int, int> P;
const int N = 30 + 5, INF = 0x3f3f3f3f;
inline int read() {
	int x = 0, f = 0; char ch = 0;
	while (!isdigit(ch)) f |= ch == '-', ch = getchar();
	while (isdigit(ch)) x = (x << 3) + (x << 1) + (ch ^ 48), ch = getchar();
	return f ? -x : x;
}
bool cmp(P a, P b) {
	return b.F * (a.S + 1) < a.F *(b.S + 1) ;
}
vector <P> a; vector <int> b;
int f[N];
signed main() {
	int n = read(), T = read();
	for (int i = 1; i <= n; i++) {
		int x = read(), y = read();
		if (x) a.pb(make_pair(x, y));
		else b.pb(y + 1);
	}
	sort(a.begin(), a.end(), cmp);
	sort(b.begin(), b.end());
	for (int i = 1; i < b.size(); i++) b[i] += b[i - 1];
	for (int i = 1; i <= 30; i++) f[i] = T + 1;
	for (int i = 0; i < a.size(); i++)
		for (int j = 30; j; j--)
			f[j] = min(f[j], (f[j - 1] + 1) * (a[i].F + 1) + a[i].S);
	int ans = 0;
	for (int i = 0; i <= 30; i++) 
		if (f[i] <= T) ans = max(ans, i + (b.empty() ? 0 : upper_bound(b.begin(), b.end(), T - f[i]) - b.begin()));
	printf("%lld\n", ans);
	return 0;
}//cy

Measured memory_bytes: 6512
#include <iostream>
#include <algorithm>  
#include <vector>     
using namespace std;
int main(void){
  
    int N;
    int ans =0;
    cin >> N;
    vector<int> a(100,0);
    for(int i=1;i<=N;i++){
        int x;
        cin >> x;
        a[x] = x;
    }
    for(int j=1;j<=100;j++){
        if(a[j] != 0){
            ans++;
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#import <stdio.h>
#import <stdlib.h>

int compare_int(const void *a, const void *b) {
    return *(int*)b - *(int*)a;
}

int main(int argc, const char * argv[]) {
    int N, K;
    scanf("%d %d", &N, &K);
    int *numbers = (int*)malloc(N * sizeof(int));
    
    int n;
    int i = 0;
    while (scanf("%d", &n) != EOF) {
        numbers[i] = n;
        i++;
    }
    
    qsort(numbers, N, sizeof(int), compare_int);
    
    int s = 0;
    for (int i=0; i<K; i++) {
        s += numbers[i];
    }
    printf("%d", s);
    
    free(numbers);
    return 0;
}


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

#define LL long long
#define fi first
#define se second
#define mp make_pair
#define pb push_back

using namespace std;

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;}
LL powmod(LL a,LL b,LL MOD){LL ans=1;while(b){if(b%2)ans=ans*a%MOD;a=a*a%MOD;b/=2;}return ans;}
const int N = 2e5 +11;
int main(){
	ios::sync_with_stdio(false);
	int n,a,b;
	cin>>n>>a>>b;
	cout<<min(n*a,b);
	return 0;
}

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


vector<int> transenisin(int num){
	vector<int> nisin;
	while(1){
		if(num%2==1)nisin.push_back(1);
		else nisin.push_back(0);
		num=num/2;
		if(num==1){nisin.push_back(1);break;}
	}
	
	return nisin;
}

void print(vector<int> v){
	
	for(int i=0;i<v.size();i++){
		cout<<v[i];
	}
	//cout<<endl;
}
int A,B,C;
void solve(){
	cin>>A>>B>>C;
	
	if(A*C<=B)cout<<C<<endl;
	else cout<<B/A<<endl;
}


int main(){

    solve();
    return 0;
}




Measured memory_bytes: 256
A,B,C,K=map(int, input().split())
# print(A,B,C,K)
s = 0

if A >= K:
    s = s + K
    print(s)

else:
    s = A
    #print("s2",s)
    K = K - A
    #print("K",K)

    if B >= K:
        s = s
        print(s)

    else:
        s = s
        #print("s4",s)
        K = K - B
        #print("K",K)

        if C >= K:
            s = s - K
            print(s)
        else:
            s = s - C
            K = K - C
            print(s)

Measured memory_bytes: 9108
/**
  * Created by ui on 2016/02/03.
  */
object RevirsingNumbers {
    def inputNumbers: List[Long] = {
      val sc = new java.util.Scanner(System.in)
      val n = sc.nextInt()
      List.fill(n)(sc.nextLong())
    }
    def reversingPrint(list: List[Long] ): Unit = {
      val n = list.size
      val r = list.reverse.toArray
      for (i <- 0 until (n-1) )print(r(i) + " ")
      println(r(n - 1))
    }
    def run: Unit = reversingPrint(inputNumbers)

}
object Main {
  def main(args: Array[String]) {RevirsingNumbers.run}
}

Measured memory_bytes: 44948
#include<bits/stdc++.h>
using namespace std;
#ifdef LOCAL_DEBUG
  #include "LOCAL_DEBUG.hpp"
#endif
#define int long long
const int MOD = 1e9 + 7;

int mod_pow(int n, int p, int MOD){
  int r = 1;
  for(; p > 0; p >>= 1){
    if(p & 1LL) r = (r * n) % MOD;
    n = (n * n) % MOD;
  }
  return r; // r = n^p % MOD
}

signed main(){

  int n; cin >> n;
  vector<int> a(n);
  for(int i = 0; i < n; i++){
    cin >> a[i];
  }

  int Max = 0;
  static int imos[300001][61][2];
  for(int i = 0; i < n; i++){
    for(int j = 0; j < 60; j++){
      imos[i+1][j][1] = (imos[i][j][1] + (a[i] >> j & 1));
      imos[i+1][j][0] = (imos[i][j][0] + !(a[i] >> j & 1));
      if(a[i] >> j & 1) Max = max(Max, j+1);
    }
  }

  int ans = 0;
  for(int i = 0; i < n; i++){
    int res = 0;
    for(int j = 0; j < Max; j++){
      if(!(a[i] >> j & 1)){
        if((imos[n][j][1] - imos[i+1][j][1]) == 0) continue;
        res = (res + mod_pow(2, j, MOD) * (imos[n][j][1] - imos[i+1][j][1])) % MOD;
      }else {
        if((imos[n][j][0] - imos[i+1][j][0]) == 0) continue;
        res = (res + mod_pow(2, j, MOD) * (imos[n][j][0] - imos[i+1][j][0]))% MOD;
      }
    }
    ans = (ans + res) % MOD;
  }
  cout << ans << endl;

  return 0;
}


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

const int N = 1e6 + 100;

int main() {
    // freopen("in.txt", "r", stdin);
    ios::sync_with_stdio(0);
    cin.tie(0);

    vector<int> f(100);
    for(int i = 0; i < 5; i++) {
        int x;
        cin >> x;
        f[x] = true;
    }
    for(int i = 1; i <= 5; i++) {
        if(f[i] == 0) {
            cout << i << endl;;
            exit(0);
        }
    }

    return 0;
}



Measured memory_bytes: 3612
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <cmath>
#include <stack>
#include <queue>
#include <set>
#include <map>
#include <iomanip>
using namespace std;
typedef long long ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef vector<string> VS;
typedef vector< vector<int> > VVI;
typedef vector< vector<ll> > VVL;
typedef pair<int,int> PII;
typedef pair<ll,ll> PLL;
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a) (a).begin(),(a).end()
#define pf push_front
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define ub upper_bound
#define lb lower_bound
 
int main(){
  int X,Y,Z;
  cin>>X>>Y>>Z;
  swap(X,Y);
  swap(X,Z);
  cout<<X<<" "<<Y<<" "<<Z<<endl;
}

Measured memory_bytes: 384
#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;
ll a[200009];
ll n;ll k;
int main()
{
    scanf("%d%lld",&n,&k);
    for(int i=1;i<=n;i++)scanf("%lld",&a[i]);
    sort(a+1,a+n+1);
    ll l=-1e18,r=1e18;
    ll answer;
    while(l<=r)
    {
        ll mid=(l+r)/2;ll cnt=0;
        for(int i=1;i<=n;i++)
        {
            if(a[i]>0){
                cnt+=upper_bound(a+1,a+n+1,(long double)mid/a[i])-a-1;
            }
            else if(a[i]<0){
                cnt+=n-(lower_bound(a+1,a+n+1,(long double)mid/a[i])-a-1);
            }
            else if(a[i]==0&&mid>=0)cnt+=n;
            if(a[i]*a[i]<=mid)cnt--;
        }
        if(cnt>=k*2)answer=mid,r=mid-1;
        else l=mid+1;
    }
    cout<<answer<<endl;
    return 0;
}


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

int main(){
	for (;;){
		int n;
		cin >> n;
		if (n == 0) return 0;

		int p0=0, p1=0;

		for (int i = 0; i < n; ++i){
			int a, b;
			cin >> a >> b;
			if (a>b) p0 += a + b;
			if (a == b){ p0 += a; p1 += a; }
			if (a<b) p1 += a + b;
		}
		cout << p0 << ' ' << p1 << endl;
	}
}

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

// 連続するK本のろうそくに火をつけるのが最適
// N本のうち連続するK本のろうそくを選ぶ方法はN-K+1通りしか無いため全探索
// 連続するK本のうち，最も左のものをlとし，最も右のものをrとする
// lとrを訪れれば，自然と残りのろうそくを訪れることになる
// 座標0を出発し，座標xlとxrをともに訪れるための最短時間が求めるべき値

int main()
{
  int N, K;
  cin >> N >> K;
  vector<int> x(N);
  for (int i = 0; i < N; i++)
  {
    cin >> x.at(i);
  }
  long long int ans = 100000000000;
  for (int i = 0; i < N - K + 1; i++)
  {
    int xl = x.at(i);
    int xr = x.at(i + K - 1);
    int res1 = abs(xl) + abs(xr - xl);
    int res2 = abs(xr) + abs(xr - xl);
    long long int t = min(res1, res2);
    ans = min(t, ans);
  }
  cout << ans << endl;
}


Measured memory_bytes: 640
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        String s = sc.next();
        String[] ps;
        ps = s.split("");
        int[] p = new int[ps.length];
        for (int i = 0; i < p.length; i++) {
            p[i] = Integer.valueOf(ps[i]);
        }
        int min = Math.abs(100 * p[0] + 10 * p[1] + p[2] - 753);
        for (int i = 1; i < p.length - 2; i++) {
            if (min > Math.abs(100 * p[i] + 10 * p[i + 1] + p[i + 2] - 753))
                min = Math.abs(100 * p[i] + 10 * p[i + 1] + p[i + 2] - 753);
        }
        System.out.println(min);
    }
}

Measured memory_bytes: 21844
#include <iostream>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>
#include <algorithm>
#include <climits>
#include <cmath>
#include <utility>
#include <string>
#include <cstring>
#include <functional>

using namespace std;

const int maxn = 3002;
const int mo = 1e9 + 7;

int n;
double f[maxn], ans = 0;

int main() {

	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	
    cin >> n;

    double p, q;

    f[0] = 1.0;

    for (int i = 1; i <= n; ++i) {
        cin >> p;
        q = 1.0 - p;

        for (int j = i; j >= 0; --j) {
            f[j] *= q;
            if (j > 0)
                f[j] += f[j-1] * p;
        }
    }

    for (int i = n; i > n-i; --i)
        ans += f[i];

    printf("%.10lf\n", ans);

	return 0;
}

Measured memory_bytes: 256
from sys import exit, stdin
L, R = [int(_) for _ in stdin.readline().rstrip().split()]
if R - L > 3000:
    print(0)
else:
    ans = 2018
    for i in range(L, R):
        for j in range(i+1, R+1):
            ans = min(ans, (i*j)%2019)
    print(ans)

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

int main() {
    int N,K;
    cin >> N >> K;
   string S;
   cin >> S;
   if(S[K-1]=='A'){
       S[K-1]='a';
   }else if(S[K-1]=='B' ){
       S[K-1] = 'b';
   }else{
       S[K-1] = 'c';
   }
    cout << S <<endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
using namespace std;
#define REP(i,n) for(int i=0;i<(int)n;++i)
int calc(int y){
}

// LookUp Version
const int N = 1000000;
int eulerPhi(int n) {
  static int lookup = 0, p[N], f[N];
  if (!lookup) {
    REP(i,N) p[i] = 1, f[i] = i;
    for (int i = 2; i < N; ++i) {
      if (p[i]) {
        f[i] -= f[i] / i;
        for (int j = i+i; j < N; j+=i)
          p[j] = 0, f[j] -= f[j] / i;
      }
    }
    lookup = 1;
  }
  return f[n];
}

void naive(int x,int y){
	int pos = -1 , len = -1;
	map<int,int> loop;
	int l = 0;
	while( 1 ){
		loop[x] = l++;
		x = x * 10;
		x %= y;
		if( loop.count(x) ){
			pos = loop[x];
			if( !x ) len = 0;
			else len = l - loop[x];
			break;
		}
	}
	cout << pos << " " << len << endl;
}

char use[1000100];
int answer[1000100];
#include <cstring>
int calclen(int y){
	if( answer[y] ) return answer[y];
	memset(use,0,y);
	int c = 1;
	int len = 0;
	while( use[c] == 0 ){
		use[c] = 1;
		c = c * 10 % y;
		len++;
	}
	return answer[y] = len;
}
int smart(int x,int y){
	int g = __gcd(x,y);
	x /= g;
	y /= g;
	int chk = y;
	int two = 0 , five = 0;
	while( chk % 2 == 0 ) chk /= 2, two++;
	while( chk % 5 == 0 ) chk /= 5, five++;
	int pos = max(two,five);
	if( chk == 1 ){
		cout << pos << " " << 0 << endl;
		return 0;
	}
	cout << pos << " " << calclen(chk) << endl;
}
int main(){
	int x,y;
	map<int ,pair<int,int> > o;
	
	while( cin >> x >> y && x){
		//naive(x,y);
		smart(x,y);
		
	}
}

Measured memory_bytes: 5704
import java.util.*;
public class Main {
    public static void main (String[]args){
        // 標準入力
        Scanner sc = new Scanner(System.in);
        
        int A = sc.nextInt();
        int B = sc.nextInt();
        int C = sc.nextInt();

        sc.close();

        int full = A - B;
        int rest = C - full;

        if (rest >= 0){
            System.out.println(rest);
        } else{
            System.out.println(0);
        }
        

    }   
}

Measured memory_bytes: 23380
import java.util.*;
import java.util.regex.Pattern;
import java.util.regex.Matcher;
import java.io.*;

public class Main {

	public static void main(String[] args) throws IOException {
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		StringTokenizer st = new StringTokenizer(br.readLine());
		int M = Integer.parseInt(st.nextToken());
		int N = Integer.parseInt(st.nextToken());
		String regex = String.format("[0-9]{%d}-[0-9]{%d}",M,N);		
		Pattern p = Pattern.compile(regex);
		String input = br.readLine();
		Matcher q = p.matcher(input);
		if(q.matches()) {
			System.out.println("Yes");
		}else {
			System.out.println("No");
		}
	}

}


Measured memory_bytes: 23124
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text;
using static System.Console;
using static System.Math;

namespace CP
{
    class Atria
    {
        readonly static long mod = 1000000000 + 7;


        static void Main(string[] args)
        {
            int n = int.Parse(ReadLine());
            int[] vs = new int[1007];
            for (int i = 1; i <= n; i++)
            {

                long now = i;
                for (int j = 2; j <= now; j++)
                {
                    while (now > 0 && now % j == 0)
                    {
                        vs[j]++;
                        now /= j;
                    }
                }
            }
            long ans = 1;
            for (int i = 0; i <= n; i++)
            {
                if (vs[i] != 0)
                {
                    ans *= vs[i] + 1;
                    ans %= mod;
                }
            }
            WriteLine(ans);
        }

    }
}

Measured memory_bytes: 11092
#include<iostream>
using namespace std;
int n, m, k, i, j, s, x, sol, ok;
int p[12], w[12], a[12][12];
int main(){
    cin>> n >> m;
    for(i = 1; i <= m; i++){
        cin>> k;
        for(j = 1; j <= k; j++){
            cin>> x;
            a[i][x] = 1;
        }
    }
    for(i = 1; i <= m; i++){
        cin>> p[i];
    }
    while(w[0] == 0){
        ok = 1;
        for(i = 1; i <= m; i++){
            s = 0;
            for(j = 1; j <= n; j++){
                s += w[j] * a[i][j];
            }
            if(s % 2 != p[i]){
                ok = 0;
            }
        }
        sol += ok;
        i = n;
        while(w[i] == 1){
            w[i] = 0;
            i--;
        }
        w[i] = 1;
    }
    cout<< sol;
}


Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define rep(i, n) for(int i=0; i<n; ++i)
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
using namespace std;
using ll = int64_t;
using ld = long double;
using P = pair<int, int>;
using vs = vector<string>;
using vi = vector<int>;
using vvi = vector<vi>;
const int INF = 100010001;
const ll LINF = (ll)INF*INF*10;

int main() {
    int h, w;
    cin >> h >> w;
    vs a(h);
    rep(i, h) {
        cin >> a[i];
    }
    queue<int> q;
    set<int> p;
    rep(i, h) {
        bool x = true;
        rep(j, w) {
            if(a[i][j] == '#') x = false;
        }
        if(x) q.push(i);
    }

    rep(i, w) {
        bool x = true;
        rep(j, h) {
            if(a[j][i] == '#') x = false;
        }
        if(x) p.insert(i);
    }

    vs ans;
    rep(i, h) {
        if(!q.empty() and q.front() == i) {
            q.pop();
            continue;
        }
        ans.push_back("");
        rep(j, w) {
            if(p.find(j) == p.end()) {
                *(ans.end()-1) += a[i][j];
            }
        }
    }

    rep(i, ans.size()) {
        cout << ans[i] << endl;
    }
}

Measured memory_bytes: 256
import bisect
##################################################################
def main():
    Input = [input() for i in range(2)]
    N = int(Input[0])
    L = list(map(int,Input[1].split()))
    L.sort()
    ans = 0
    for i1 in range(0,N-2):
        a = L[i1]
        for i2 in range(i1+1,N-1):
            b = L[i2]
            ans += bisect.bisect_left(L, a+b) - i2 - 1
    print(ans)



if __name__ == "__main__":
    main()


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

#define clr(arr,val) memset(arr,val ,sizeof arr)
//#define first f
//#define second s

typedef  long long ull;
typedef long long ll;
ll const oo=1e18 ;

int const SZ= (int)1e5+5;
//const ll mod=(ll)1e9+7;
    
//int dp[SZ][SZ];
int arr[101][2];
ll dp[100][SZ];
int n,w;
ll solve(int i ,int wt){
    if(i>=n)
        return 0;
    ll &ret=dp[i][wt];
    if(ret!=-1)
        return ret;
    ll mx=0;
    if(wt-arr[i][0]>=0)
        mx=arr[i][1]+solve(i+1,wt-arr[i][0]);
    mx=max(mx,solve(i+1,wt));
    return ret=mx;
}

int main() {
//#ifdef CLION
//    freopen("in.txt", "r", stdin);
//    freopen("out.txt", "w", stdin);
//#endif
    
    cin>>n>>w;
    for(int i=0 ; i<n ;i++){
       cin>>arr[i][0]>>arr[i][1];
    }
    memset(dp,-1,sizeof(dp));
    cout<<solve(0,w)<<endl;
    return 0;
}
 

Measured memory_bytes: 81756
from collections import defaultdict
n=int(input())
c=["M","A","R","C","H"]
d=defaultdict(int, {})
ans=0
for _ in range(n):
  s=input()
  d[s[0]]+=1
for i in range(len(c)):
  for j in range(i+1,len(c)):
    for k in range(j+1,len(c)):
      ans+=d[c[i]]*d[c[j]]*d[c[k]]
print(ans)

Measured memory_bytes: 3316
import java.util.Scanner;

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

		int i;
		for(i = 0; i < len; i++) {
			if(i % 2 != 0) {
				if(s.substring(i, i + 1).equals("R")) {
					System.out.println("No");
					return;
				}
			}else {
				if(s.substring(i, i + 1).equals("L")) {
					System.out.println("No");
					return;
				}
			}
		}
		System.out.println("Yes");
	}
}


Measured memory_bytes: 21716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int maxn=1e6+5;
map<pii,int> M;
int main() {
	const ll mod=1e10;
	std::vector<ll> V(1);
	int n;cin>>n;
	for(int i=1;i<=n;i++) {
		long double x;cin>>x;
		V.push_back(llround(x*10000000000.0));
	}
	ll ans=0;
	for(int i=1;i<=n;i++) {
		int two=0,five=0;ll tem=V[i];
		while(tem&&tem%2==0) two++,tem/=2;
		while(tem&&tem%5==0) five++,tem/=5;
		for(int t=max(20-two,0);t<=20;t++) {
			for(int f=max(20-five,0);f<=20;f++) {
				ans+=M[{t,f}];
			}
		}
		M[{min(20,two),min(20,five)}]++;
	}
	cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 5496
N = int(input())
TXY = [[int(x) for x in input().split()] for _ in range(N)]

now = [0,0,0]
for txy in TXY:     
    time = txy[0]-now[0]
    dist = abs(txy[1]-now[1])+abs(txy[2]-now[2])
    if time>=dist and (time%2)==(dist%2):
        now = txy
        continue 
    else:
        print("No") 
        break
else:
    print("Yes")

Measured memory_bytes: 21108
#include<bits/stdc++.h>
using namespace std;
#define int long long int 
int32_t main()
{
    int n,m,q;
    cin>>n>>m>>q;
    int dp[n+1][n+1];
    memset(dp,0,sizeof(dp));
    for(int i=0;i<m;i++)
    {
        int x,y;
        cin>>x>>y;
        dp[x][y]++;
    }
    for(int i=0;i<=n;i++)
         for(int j=1;j<=n;j++)
            dp[i][j]+=dp[i][j-1];

    for(int i=0;i<n;i++)
         for(int j=0;j<=n;j++)
            dp[i+1][j]+=dp[i][j];
    for(int i=0;i<q;i++)
    {
        int x,y;
        cin>>x>>y;
        cout<<dp[y][y]+dp[x-1][x-1]-dp[x-1][y]-dp[y][x-1]<<endl;
    }
}

Measured memory_bytes: 5536
import numpy as np

H, W = map(int, input().split())
A = np.array([list(input()) for i in range(H)])

mask = A=='.'

row_idx = np.logical_not(np.all(mask, axis=1))
col_idx = np.logical_not(np.all(mask, axis=0))

for a in A[row_idx][:, col_idx]:
    print(''.join(list(a)))


Measured memory_bytes: 22368
n,m = gets.split.map(&:to_i)

if n==1 && m==1
  puts 1
  exit
end

if n==1 || m == 1
  puts [n,m].max-2
  exit
end

if n==2 || m == 2
  puts 0
  exit
end

puts (n-2)*(m-2)



Measured memory_bytes: 1788
#include <bits/stdc++.h>
using namespace std;
const int MOD =(int)(1e9)+7;
int main()
{
    int N,K;
    cin >> N >> K;
    long long ans=0;
    int a[N];
    vector<long long>B(N);
    for(int i=0;i<N;i++){
        cin >> a[i] >> B[i];
    }

    for(int i=0;i<N;i++){
        bool ok=true;
        for(int j=31;j>=0;j--){
            ok&=((K&(1<<j))!=0)||((a[i]&(1<<j))==0);
        }
        if(ok)ans+=B[i];
    }

    for(int b=31;b>=0;b--){
        if((K&(1<<b))==0)continue;
        long long sum=0;
        for(int i=0;i<N;i++){
            bool ok=true;
            for(int j=31;j>=0;j--){
                if(j>b){
                    ok&=((K&(1<<j))!=0)||((a[i]&(1<<j))==0);
                }
                else if(j==b){
                    ok&=((a[i]&(1<<j))==0);
                }
            }
            if(ok)sum+=B[i];
        }
        ans=max(ans,sum);
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1408
#include <cstdio>
#include <cstring>
#include <string>
#include <cmath>
#include <cassert>
#include <iostream>
#include <algorithm>
#include <stack>
#include <queue>
#include <vector>
#include <set>
#include <map>
#include <bitset>
using namespace std;

#define repl(i,a,b) for(int i=(int)(a);i<(int)(b);i++)
#define rep(i,n) repl(i,0,n)
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define all(x) (x).begin(),(x).end()
#define dbg(x) cout<<#x"="<<x<<endl

#define INF 1<<30

int red[100010];
int whi[100010]; //white

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

  red[1]=1;
  fill(red+2, red+n+2, 0);
  whi[1]=0;
  fill(whi+2, whi+n+2, 1);

  rep(i,m){
    int x,y;
    scanf("%d %d", &x, &y);
    if(red[x]==1){
      if(whi[x]>0) whi[x]--;
      else red[x]=0;

      if(red[y]==1) whi[y]++;
      else red[y]=1;
    } else {
      whi[x]--;
      whi[y]++;
    }
  }

  int res=0;
  repl(i,1,n+2){
    if(red[i]==1) res++;
  }

  cout<<res<<endl;

  return 0;
}


Measured memory_bytes: 1024
import heapq
from collections import defaultdict, deque
from math import ceil, factorial, gcd
import sys

sys.setrecursionlimit(10 ** 7)
INF = float("inf")
MOD = 10 ** 9 + 7

si = lambda: input().strip()
ii = lambda: int(input())
mii = lambda: map(int, input().split())
lmii = lambda: list(map(int, input().split()))
smii = lambda: sorted(map(int, input().split()))


K = ii()

ans = 0


for i in range(1, K+1):
    for j in range(1, K+1):
        for k in range(1, K+1):
            ans += gcd(gcd(i, j), k)

print(ans)

Measured memory_bytes: 9468
# coding: utf-8
# Your code here!

N = int(input())
A = [0] + list(map(int, input().rstrip().split(' '))) + [0]

cum_A = [abs(A[0])]
for i in range(len(A)-1):
    cum_A.append(cum_A[i] + abs(A[i+1] - A[i]))
    
for i in range(1, N+1):
    print(cum_A[i-1] + cum_A[-1] - cum_A[i+1] + abs(A[i+1] - A[i-1]))


Measured memory_bytes: 14040
def compare(ar1,ar2):
    count = 0
    for i in range(len(ar1)):
        if ar1[i] != ar2[i]:
            count+=1
    return count

s = input()
t = input()
lowest = len(t)
for i in range(len(s)-len(t)+1):
    res = compare(t,s[i:i+len(t)])
    if res < lowest:
        lowest = res
print(lowest)

Measured memory_bytes: 9040
#if 0

#endif

#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;

int N, M;
pair<int,int> PD[10010];
int main() {
  while (cin >> N >> M && N) {
    int d, p;
    for (int i=0; i<N; ++i) {
      cin >> d >> p;
      PD[i] = make_pair(p, d);
    }
    sort(PD, PD+N, greater<pair<int,int>>());
    int ans = 0;
    for (int i = 0; i < N; i++) {
      int p = PD[i].first; int d = PD[i].second;
      if (M >= d) {
        M -= d;
      } else if (M < d && M > 0) {
        ans += p * (d-M);
        M = 0;
      } else {
        ans += p * d;
      }
    }
    cout << ans << endl;
  }
}



Measured memory_bytes: 3104
S=input()
n= len(S)
ng = 0
s = 0
e = n
for i in range((e-s)//2):
  if S[s+i] != S[e-i-1]:
    ng = 1
nn = (n-1)//2
for i in range(nn//2):
  if S[i] != S[nn-i-1]:
    ng = 1
nn = (n+3)//2 - 1
for i in range((n-nn)//2):
  if S[nn+i] != S[n-i-1]:
    ng = 1
if ng == 1:
  print("No")
else:
  print("Yes")


Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
#define r(i,a,n) for(int i=a;i<=n;i++)
int main(){
	long long a,b,c,s=0;
	cin>>a>>b;
	r(i,0,a){
		r(j,0,a){
			int z=b-i-j;
			if(0<=z&&z<=a)s++;
		}
	}cout<<s<<endl;
}

Measured memory_bytes: 256
import copy

D,G=map(int,input().split())

prob_list=[]
for i in range(D):
  p,c=map(int,input().split())
  prob_list.append([p,c])
#print(prob_list)

answer=10**9
for i in range(2**D):
  bit=[0]*D
  ii=i
  for j in range(D):
    bit[j]=ii%2
    ii//=2
  #print(bit)
    
  pl=copy.deepcopy(prob_list)
  cnt=0
  score=0  
  for i in range(D):
    if bit[i]==1:
      cnt+=pl[i][0]
      score+=pl[i][0]*100*(i+1)+pl[i][1]
      pl[i][0]=0

  if cnt>=answer:
    continue
      
  if score>=G:
    answer=min(answer,cnt)
    #print(bit,cnt)
  else:
    for i in reversed(range(D)):
      if pl[i][0]==0:
        continue
      
      while(pl[i][0]>0):
        pl[i][0]-=1
        cnt+=1
        score+=100*(i+1)
        if score>=G:
          break    
      if pl[i][0]==0:
        score+=pl[i][1]
        
      if score>=G:
        break

    answer=min(answer,cnt)
    #print(bit,cnt)
      
print(answer)

Measured memory_bytes: 3444
using System;
using System.Collections.Generic;
using System.Linq;
using System.IO;
using System.Text.RegularExpressions;
using System.Diagnostics;
using static System.Math;

//var input = Console.ReadLine().Split().Select(int.Parse).ToArray();
namespace AtCoderSolve
{

    class Solve
    {
        const int mod = 1000000007;
        const int INF = 2147483647;
        const long SINF = 9223372036854775807;

        static string s, t;

        public static void Input()
        {
            var cin = new Solve();
            s = Console.ReadLine();
            t = Console.ReadLine();
        }

        static void Main(string[] args)
        {
            Input();
            //var sw = new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false };
            //Console.SetOut(sw);

            var ss = s.ToCharArray();
            var tt = t.ToCharArray();
            Array.Sort(ss);
            Array.Sort(tt);
            Array.Reverse(tt);
            string S = "";
            string T = "";
            for(var i = 0; i < ss.Length; i++)
            {
                S += ss[i];
            }
            for(var i = 0; i < tt.Length; i++)
            {
                T += tt[i];
            }

            Console.WriteLine(string.Compare(S, T) < 0 ? "Yes" : "No");

            //Console.Out.Flush();
        }

        public int[] SplitReader()
        {
            int[] array = Console.ReadLine().Split().Select(int.Parse).ToArray();
            return array;
        }
        public long[] SplitReaderL()
        {
            long[] array = Console.ReadLine().Split().Select(long.Parse).ToArray();
            return array;
        }
    }
}

    



Measured memory_bytes: 13524
import sys
# input = sys.stdin.readline
sys.setrecursionlimit(10 ** 9)
MOD = 10 ** 9 + 7

N = int(input())
S1 = list(input())
S2 = list(input())

if S1[0] == S2[0]:
    ans = 3
    flag = True #縦の時
    i = 1
else:
    ans = 6
    flag = False
    i = 2
while i < N:
    if S1[i] == S2[i]:
        i += 1
        if flag:
            ans = (ans * 2) % MOD
        else:
            flag = True
    else:
        i += 2
        if flag:
            ans = (ans * 2) % MOD
            flag = False
        else:
            ans = (ans * 3) % MOD
    
print (ans)
            


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

using namespace std;
using ll = long long;


const int MOD = 1e9+7;

class Edge{
public:
    ll from,to, value;
    Edge(int f,int t, int c){
        from = f;
        to = t;
        value = c;
    }
};

// a^n mod を計算する
long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

// a^{-1} mod を計算する
long long modinv(long long a, long long mod) {
    return modpow(a, mod - 2, mod);
}

int main(){
    int X,Y;
    cin >> X >> Y;
    ll ans = 0;
    vector<ll> kaizyo;
    kaizyo.push_back(1);
    for(int i = 1;i <= 1e6+10;i++){
        kaizyo.push_back(kaizyo.back()*i);
        kaizyo.back() %= MOD;
    }
    for(int i = 0;i <= X;i++){
        int x = i;
        int y = 2 * i;
        if(y > Y){
            continue;
        }
        int remainx = X - x;
        int remainy = Y - y;
        if(remainy * 2 == remainx){
            int remain  = remainy;
            ans += kaizyo[remain + i] * modinv(kaizyo[remain], MOD) % MOD * modinv(kaizyo[i], MOD) % MOD;
            ans %= MOD;
        }
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 10604
N, Y = map(int,input().split())
for x in range(N+1):
    for y in range(N+1):
        z = N-x-y
        if z < 0:
            continue
        if (10000*x+5000*y+1000*z) == Y:
            print(x,y,z)
            exit()
print(-1,-1,-1)

Measured memory_bytes: 3060
#include <stdio.h>
 
int main() {
 
  int n,m,i,j;
  int a,b;
  int A[100][100] = {0};
  int B[100] = {0};
  int c[100] = {0};
 
  scanf("%d %d " ,&n,&m);
 
  for(j=0; j<n; j++) {
  for(i=0; i < m; i++) {
    scanf("%d",&a);
    A[j][i] = a;
  }
}
 
  for(j=0; j<m; j++) {
    scanf("%d",&b);
    B[j] = b;
  }
 
  for(j=0;j<n ; j++){ 
  for(i = 0; i<m; i++){
     c[j] = c[j] + A[j][i]*B[i];
    }
  }
 
  for(i=0;i<n;i++) {
    printf("%d\n",c[i]);
  }
  return 0;
}



Measured memory_bytes: 2140