akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#ifdef __DEBUG__
    #define DBG(X) cout << #X << " = " << (X) << endl;
    #define SAY(X) cout << (X) << endl;
#else
    #define DBG(X)
    #define SAY(X)
#endif

using namespace std;

using ll = long long int;
using ull = unsigned long long int;
using ld = long double;
using pii = pair<int, int>;
using pll = pair<ll, ll>;

int dx[]={1, 0, -1, 0, 1,-1, 1,-1};
int dy[]={0, 1, 0, -1, 1, 1,-1,-1};
const int INT_INF = (int)(2e9);
const ll  LL_INF = (ll)(2e18);

inline void fast_io() { ios_base::sync_with_stdio(false); cin.tie(nullptr); cout.tie(nullptr); };
template<typename T, typename S> inline ostream& operator<<(ostream& os, const pair<T, S> p) { cout << "[" << p.first << ";" << p.second << "]"; return os; }
template<typename T, typename S> inline ostream& operator<<(ostream& os, const map<T, S> p) { for (auto el : p) cout << "[" << el.first << ";" << el.second << "]"; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const vector<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const deque<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline ostream& operator<<(ostream& os, const set<T>& v) { for (auto el : v) cout << el << " "; return os; }
template<typename T> inline vector<T> fetch_vec(int sz) { vector<T> ret(sz); for (auto& elem : ret) cin >> elem; return ret; }

string S;
int N;
int a,b,c,d;
void input(){
    fast_io();
    cin >> N >> a >> b >> c >> d;
    cin >> S;
    a--,b--,c--,d--;
}

#define NO() do{cout << "No" <<endl; return 0;}while(false);
#define YES() do{cout << "Yes" <<endl; return 0;}while(false);

int solve(){
    for (int i = a; i < d; i++)
    {
        if(S[i]=='#' && S[i+1]=='#') NO()
    }
    if(c<d){
        YES()
    }
    else{
        for (int i = b; i <= d; i++)
        {
            if(S[i]=='#') continue;
            if(S[i-1]=='.' && S[i]=='.' && S[i+1]=='.') YES()
        }
        NO()
    }
    
    return 0;
}   

int main()
{
    input();
    solve();
    return 0;
}

Measured memory_bytes: 592
from sys import stdin
from math import ceil, floor
n = int(stdin.readline().rstrip())
data = [int(x) for x in stdin.readline().rstrip().split()]
m = sum(data) / len(data)
ceil_m = sum([(x-ceil(m))**2 for x in data])
floor_m = sum([(x-floor(m))**2 for x in data])
print(min(ceil_m, floor_m))


Measured memory_bytes: 9096
#include <bits/stdc++.h>
using namespace std;
#define rep(i,N) for(int i=0;i<int(N);++i)
#define rep1(i,N) for(int i=1;i<int(N);++i)
#define all(a) (a).begin(),(a).end()		 //sort(all(vi S)) sort(all(string S))
#define print(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<_<<", "; cerr<<"]"<<endl; }
#define printpair(v) { cerr<<#v<<": [ "; for(auto _ : v) cerr<<"{"<<_.first<<","<<_.second<<"}"<<", "; cerr<<"]"<<endl; }

using P = pair<int, int>;		//P.first, P.second
typedef long long ll;
typedef vector<int> vi;
typedef set<int> seti;
typedef vector<string> vs;

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


vector<vector<pair<int,ll>>> G;
vector<ll> dist;

void dfs(int x, int pre,ll d){
    dist[x] = d;
    for(auto nxt: G[x]){
        if(nxt.first == pre)continue;
        dfs(nxt.first, x, d+nxt.second);
    }
}
int main() {
    int N;cin>>N;
    G.resize(N);
    dist.resize(N);
    rep(i,N-1){
        int a,b;ll c;
        cin>>a>>b>>c;
        a--;b--;
        G[a].push_back({b,c});
        G[b].push_back({a,c});
    }
    int Q,K;cin>>Q>>K;
    K--;
    dfs(K, -1, 0);
    rep(i,Q){
    int x,y;cin>>x>>y;
    x--;y--;
    ll ans = dist[x] + dist[y];
    cout<<ans<<endl;
    }
    print(dist);
}

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

#define in cin
#define out cout

#define REP(i,n) for(int i=0; i<n; i++)
#define REP2(i,s,e) for(int i=s; i<e; i++)
#define REPE(i,s,e) for(int i=s; i<=e; i++)
#define REPR(i,s,e) for(int i=s; i>=e; i--)

#define all(v) v.begin(), v.end()
#define pb push_back

#define ll long long
#define pii pair<int, int>
#define pll pair<ll, ll>
#define rd(n) scanf("%d", &n)

#define x first
#define y second
#define intINF 2147483647
#define llINF 9223372036854775807LL
#define MOD 1000000007

int main()
{
    #ifndef ONLINE_JUDGE
        //freopen("in.txt", "r", stdin);
        //freopen("out.txt", "w", stdout);
    #endif

    ll res = llINF;
    ll d[3]; in >> d[0] >> d[1] >> d[2];

    if( ((d[0]%2)==0) || ((d[1]%2)==0) || ((d[2]%2)==0) )
    {
        res = 0;
    }
    else
    {
        sort(d, d+3);
        res = d[0]*d[1];
    }

    out << res << "\n";

    return 0;
}


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

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

    vector<int> A(N);
    rep(i, N) cin >> A[i];

    deque<int> deq;
    rep(i, N) {
        if (i%2 == N%2) deq.push_back(A[i]);
        else deq.push_front(A[i]);
    }

    for (auto x: deq) cout << x << " ";
    cout << endl;

    return 0;
}

Measured memory_bytes: 3840
# 
import sys

from sys import stdin
input = lambda: stdin.readline().rstrip()

N = int(input())
a = list(map(int,input().split()))

cnt = 0
for i in range(len(a)):
    if (i + 1) % 2 != 0 and a[i] % 2 != 0:
        cnt += 1

print(cnt)

Measured memory_bytes: 9032
import java.util.Scanner;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        double r = sc.nextDouble();
        double pi = Math.PI;
        double area = r*r*pi;
        double length= r*2*pi;
        System.out.printf("%f %f",area,length);
        sc.close();
    }
}


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

char s[200020];
stack<int>q;

int main()
{
    scanf("%s",s+1);
    int len=strlen(s+1);
    int ans=0;
    for(int i=1;i<=len;i++)
    {
        if(s[i]=='S')
        {
            q.push(1);
        }
        else
        {
            if(!q.empty())
            {
                ans+=2;
                q.pop();
            }
        }
    }
    printf("%d\n",len-ans);
    return 0;
}





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

using namespace std;

#define rep(i, n) for (int i = 0; i < (int)n; ++i)
#define REP(i, a, b) for (int i = (int)a; i < (int)b; ++i)
#define each(i,c) for(__typeof((c).begin()) i = (c).begin(); i != (c).end(); ++i)
#define all(v) v.begin(), v.end()
#define mset(a, n) memset(a, n, sizeof(a))

typedef long long ll;

const int INF = 1000000000;
const int MOD = 1000000007;

int main(int argc, char *argv[]) {
    // cin.tie(0);
    // ios::sync_with_stdio(false);
    int a, b, c, d;
    cin >> a >> b >> c >> d;
    int ans = min(b, d) - max(a, c);
    cout << (ans > 0 ? ans : 0) << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const int maxn = 1e5 + 10;
string s;

int main()
{
    cin >> s;
    int len = s.size();
    int cnt = 0;
    int ans = 0;
    for(int i = 0; i < len; i ++)
      if(s[i] == '0') cnt ++;
    if(cnt < len - cnt) ans = cnt;
    else ans = len - cnt;
    printf("%d\n", ans << 1);
    return 0;
}


Measured memory_bytes: 512
import numpy as np

N = int(input())
plist = []
for i in range(N):
    plist.append(int(input()))    

plist2 = np.array(plist)

tf = np.ones(N,dtype='bool')   

tf[plist.index(max(plist))] = False

print(int(sum(plist2[tf]) + max(plist)/2))

Measured memory_bytes: 12500
using System;
using System.Linq;

public class Test
{
	public static void Main()
	{
		char[] c = Console.ReadLine().ToCharArray();
		int n = c.Length;
		for(int i=0;i!=n;i++){
			c[i] = 'x';
		}
		string s = new String(c);
		Console.WriteLine(s);
		
	}
}

Measured memory_bytes: 13140
import random
import time
import copy

t1=time.time()
d=int(input())
c=input()
cl=[int(n) for n in c.split()]
sl=list()
for i in range(d):
    s=input()
    sl=sl+[int(n) for n in s.split()]
tl=list()
for i in range(d):
    tl.append(random.randint(1,26))
sat=0
for i in range(d):
    sat+=sl[i*26+tl[i]-1]
last=list()
for i in range(26):
    last.append([a for a, x in enumerate(tl) if x==i+1])
dec=0
for i in range(26):
    if last[i]==list():
        dec+=(d*(d+1)/2)*cl[i]
    else:
        for v in range(len(last[i])):
            if v!=len(last[i])-1:    
                dec+=cl[i]*(last[i][v+1]-last[i][v]-1)*(last[i][v+1]-last[i][v])/2
            else:
                dec+=cl[i]*(d-last[i][v]-1)*(d-last[i][v])/2
        dec+=cl[i]*(last[i][0])*(last[i][0]+1)/2
        
def dechf(i,last):
    dech=0
    if last[i]==list():
        dech+=(d*(d+1)/2)*cl[i]
    else:
        for v in range(len(last[i])):
            if v!=len(last[i])-1:    
                dech+=cl[i]*(last[i][v+1]-last[i][v]-1)*(last[i][v+1]-last[i][v])/2
            else:
                dech+=cl[i]*(d-last[i][v]-1)*(d-last[i][v])/2
        dech+=cl[i]*(last[i][0])*(last[i][0]+1)/2
    return(int(dech))


oldlast=copy.deepcopy(last)
oldans=sat-int(dec)
oldtl=copy.copy(tl)
t2=time.time()
newans=0
while t2-t1<1.85:
    if round(t2)%2==0:
        d1=random.randint(1,d)
        d2=random.randint(1,d)
        if d1==d2:
            continue
        q1=tl[d2-1]
        q2=tl[d1-1]
        cha=sl[(d1-1)*26+q1-1]-sl[(d1-1)*26+tl[d1-1]-1]+sl[(d2-1)*26+q2-1]-sl[(d2-1)*26+tl[d2-1]-1]
        i=tl[d1-1]-1
        dech=dechf(i,last)
        i=tl[d2-1]-1
        dech+=dechf(i,last)
        last[tl[d2-1]-1].remove(d2-1)
        last[tl[d1-1]-1].remove(d1-1)
        last[tl[d1-1]-1].append(d2-1)
        last[tl[d1-1]-1].sort()
        last[tl[d2-1]-1].append(d1-1)
        last[tl[d2-1]-1].sort()
        tl[d2-1]=q2
        tl[d1-1]=q1
        i=tl[d1-1]-1
        dech-=dechf(i,last)
        i=tl[d2-1]-1
        dech-=dechf(i,last)
        newans=oldans+cha-dech
    else:
        da=random.randint(1,d)
        q=random.randint(1,26)
        cha=sl[(da-1)*26+q-1]-sl[(da-1)*26+tl[da-1]-1]
        i=tl[da-1]-1
        dech=dechf(i,last)
        last[tl[da-1]-1].remove(da-1)
        last[q-1].append(da-1)
        last[q-1].sort()
        tl[da-1]=q
        i=tl[da-1]-1
        dech-=dechf(i,last)
        newans=oldans+cha-dech
    r=0
    if newans<oldans:
        if 2.7**((newans-oldans)/(1.85-(t2-t1)))<random.random():
            r=1
    if r==1:
        tl=copy.copy(oldtl)
        last=copy.deepcopy(oldlast)
    else:
        oldans=newans
        oldtl=copy.copy(tl)
        oldlast=copy.deepcopy(last)
    t2=time.time()
for i in range(d):
    print(tl[i])
        

Measured memory_bytes: 115420
#include<bits/stdc++.h>
using namespace std;
#define int      long long int
int32_t main()
{   ios_base::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int s,w;
    cin>>s>>w;
    if(w>=s)
    {
        cout<<"unsafe"<<'\n';
    }
    else
    {
        cout<<"safe"<<'\n';
    }
    
    
    
    return 0;
}

Measured memory_bytes: 3556
from functools import reduce
from fractions import gcd

N = int(input())
A = [int(a) for a in input().split()]
def lcm(a,b):
    return (a*b//gcd(a, b))
def lcmm(l):
    return reduce(lcm, l)

m = lcmm(A) - 1
print(sum([m%a for a in A]))

Measured memory_bytes: 5384
#include<bits/stdc++.h>
#define forr(i, a, b) for(int i = (a); i < (b); i++)
#define rep(i,n) for(int i = 0; i < (n); i++)
#define rrep(i,n) for(int i = 1; i <= (n); i++)
#define ALL(a) (a.begin()),(a.end())
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
typedef pair<ll, ll> LP;
const ll LINF = 1LL<<60;
const int INF = 1001001001;

/* --------------------------------------------------- */

int main() {
    int n, k;
    cin >> n >> k;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    rep(i, n - k) {
        if(a[i] < a[i + k]) cout << "Yes" << endl;
        else cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 4048
n = int(input())

max6 = n//6

ans = 10**9

def count_func(m,k): #n:kを何回使うか、k:6or9
    if m<k:
        return m
    for i in range(1,8):
        if m<k**i:
            return count_func(m-k**(i-1),k)+1

    

for i in range(max6+1):
    ct6 = count_func(i,6)
    ct9 = count_func((n-6*i)//9,9)
    am = n-(i*6+((n-6*i)//9)*9)
    ans = min(ans,ct6+ct9+am)
    
print(ans)



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

int main() {
  int N,K;
  cin >> N >> K;
  int d,X;
  vector<int> a(N);
  rep(i,K){
    cin >> d;
    rep(i,d){
      cin >> X;
      a.at(X-1)++;
    }
  }
  int count;
  rep(i,N){
    if(a.at(i)==0){
      count++;
    }
  }
  cout << count <<endl;
}


Measured memory_bytes: 3560
#![allow(non_snake_case, unused)]
use std::cmp::*;
use std::collections::*;
use std::f64::consts::*;

macro_rules! input {
    (source = $s:expr, $($r:tt)*) => {
        let mut iter = $s.split_whitespace();
        let mut next = || { iter.next().unwrap() };
        input_inner!{next, $($r)*}
    };
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

macro_rules! input_inner {
    ($next:expr) => {};
    ($next:expr, ) => {};

    ($next:expr, $var:ident : $t:tt $($r:tt)*) => {
        let $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };

    ($next:expr, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = read_value!($next, $t);
        input_inner!{$next $($r)*}
    };
}

macro_rules! read_value {
    ($next:expr, ( $($t:tt),* )) => {
        ( $(read_value!($next, $t)),* )
    };

    ($next:expr, [ $t:tt ; $len:expr ]) => {
        (0..$len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
    };

    ($next:expr, [ $t:tt ]) => {
        {
            let len = read_value!($next, usize);
            (0..len).map(|_| read_value!($next, $t)).collect::<Vec<_>>()
        }
    };

    ($next:expr, chars) => {
        read_value!($next, String).chars().collect::<Vec<char>>()
    };

    ($next:expr, bytes) => {
        read_value!($next, String).into_bytes()
    };

    ($next:expr, usize1) => {
        read_value!($next, usize) - 1
    };

    ($next:expr, $t:ty) => {
        $next().parse::<$t>().expect("Parse error")
    };
}

fn main() {
    input! {
        s: chars,
        t: chars,
    }
    let mut cnt = 0;
    for i in 0..3 {
        if s[i] == t[i] {
            cnt += 1;
        }
    }
    println!("{}", cnt);
}


Measured memory_bytes: 4352
#include <algorithm>
#include <climits>
#include <complex>
#include <cstring>
#include <iostream>
#include <map>
#include <set>
#include <vector>

// using
using namespace std;

// typedef
typedef long long ll;

// define
#define ALL(c) (c).begin(), (c).end()
#define SORT(c) sort(ALL(c))
#define REVERSE(c) reverse(ALL(c))
#define UNIQ(c) unique(ALL(c))
#define FOR(i, a, b, c) for (int i = (int)(a); i < (int)(b); i += (int)(c))
#define REP(i, n) FOR(i, 0, n, 1)
#define RFOR(i, a, b, c) for (int i = (int)(a); i >= (int)(b); i -= (int)(c))
#define RREP(i, n) RFOR(i, n, 0, 1)

// functions
int ceil(int a, int b) {
    return (a + b - 1) / b;
}
int round(int a, int b) {
    return (a + b / 2) / b;
}
int gcd(int a, int b) {
    return b ? gcd(b, a % b) : a;
}
int lcm(int a, int b) {
    return a * b / gcd(a, b);
}
template <class T> bool amax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
}
template <class T> bool amin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return true;
    }
    return false;
}

// main
int main() {
    int M;
    cin >> M;
    cout << 48 - M << endl;
    return 0;
}


Measured memory_bytes: 256
#include <cmath>
#include <complex>
#include <algorithm>
using namespace std;

#define PCR Point const &

typedef long double Real;
typedef complex<Real> Point;
struct Segment {
    Point p[2];
    Segment (PCR a = Point(), PCR b = Point()){
        p[0] = a, p[1] = b;
    }
    Point & operator [] (int k) { return p[k]; }
    Point const & operator [] (int k) const { return p[k]; }
};
typedef vector<Point> Polygon;
struct Circle { Real radius; Point center; };

#define X real()
#define Y imag()

Real dot(PCR a, PCR b){
    return a.X*b.X + a.Y*b.Y;
}
Real cross(PCR a, PCR b){
    return a.X*b.Y - a.Y*b.X;
}

Point pSP(Segment const & s, PCR p){
    Point base = s[1] - s[0];
    Real r = dot(p - s[0], base) / norm(base);
    return s[0] + base * r;
}

#include <iostream>
#include <cstdio>

int main(){
    Segment s;
    Real x,y;
    cin >> x >> y;
    s[0] = Point(x,y);
    cin >> x >> y;
    s[1] = Point(x,y);
    int q;
    cin >> q;
    for(int i=0;i<q;i++){
        cin >> x >> y;
        Point p = pSP(s, Point(x,y));
        printf("%.10Lf %.10Lf\n", p.X, p.Y);
    }
}

Measured memory_bytes: 1248
if __name__ == '__main__':
    n = int(input())
    a_list = list(map(int,input().split()))
    b_list = list(map(int,input().split()))
    c_list = list(map(int,input().split()))

    answer = 0
    for i in range(n):
        a = a_list[i]
        answer += b_list[a-1]
        if i < n-1:
            next_a = a_list[i+1]
            if next_a - a == 1:
                answer += c_list[a-1]
    print(answer)

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

using namespace std;

// func
// ------------------------------------------------
int CalcSumOfDigit(int n);      // 各桁の和を計算する。
int getDigit(int n);            // 数字の桁数を取得する。
string upper(string str);       // 英字を大文字に変換する。
string lower(string str);       // 英字を小文字に変換する。
vector<pair<long long,long long>> prime_factorize(long long p); // 素因数分解

// class
// ------------------------------------------------
class Combi {
  public:
    Combi();
    long long Combination(long long n, long long k);
    long long nPk_modp(long long n, long long k, long long p);
  private:
    map<long long, map<long long, long long>> memo;
    long long n_num;
    long long k_num;
};

// define
// ------------------------------------------------
#define all(a)        (a).begin(),(a).end()
#define rall(a)       (a).rbegin(),(a).rend()
#define sz(a)         int((a).size())
#define rep(i,n)      for(long long(i)=0;(i)<(n);(i)++)
#define repe(i,n)     for(long long(i)=0;(i)<=(n);(i)++)
#define vsort(v)      sort((v).begin(),(v).end())
#define rvsort(v)     sort(rall((v)))
#define vi            vector<int>
#define GCD(a,b)      __gcd((a),(b))
#define LCM(a,b)      (a)/GCD((a),(b))*(b)
#define kiriage(a,b)  ((a)+(b)-1)/(b)

const int INF = 1e9;

typedef long long ll;
typedef unsigned long long ull;
typedef vector<long> vll;
// code
// ------------------------------------------------
int main() {

    ll n,k;
    cin >> n >> k;

    cout << n - k + 1 << endl;

    return 0;
}
// funcの実体
// ------------------------------------------------
int getDigit(int n) {
  int i = 1;
  while(1) {
    n = n / 10;
    if(n == 1)
      break;
    i++;
  }
  return i;
}
int CalcSumOfDigit(int n) {
  int s = 0;
  while(n) {
    s += n % 10;
    n = n / 10;
  }
  return s;
}

string upper(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(97 <= *itr && *itr <= 122) {
      *itr = *itr - 32;
    }
  }
  return str;
}

string lower(string str) {
  for(auto itr = str.begin();itr != str.end() ; itr++) {
    if(65 <= *itr && *itr <= 90) {
      *itr = *itr + 32;
    }
  }
  return str;
}


Combi::Combi() {
  n_num = -1;
  k_num = -1;
};

ll Combi::Combination(ll n, ll k) {

  ll ret;
  if(memo[n][k] != 0) {
    ret = memo[n][k];
  } else if(n == k || k == 0) {
    memo[n][k] = 1;
    ret = 1;
  } else {
    ret = Combination(n - 1, k - 1) + Combination(n - 1, k);
    memo[n][k] = ret;
  }
  return ret;
}

long long Combi::nPk_modp(long long n, long long k, long long p) {
  ll ans = 1;
  for(long long i = k; i <= n; i++) {
    ans = (ans * i) % p;
  }

  return ans;
};

vector<pair<long long,long long>> prime_factorize(long long p) {
    vector<pair<long long,long long>> ret;

    for(long long x = 2; x * x <= p; ++x) {
        if(p % x != 0) continue;
        long long num = 0;
        while(p % x == 0) {
            num++;
            p /= x;
        }
        ret.push_back(make_pair(x,num));
    }

    if(p != 1) ret.push_back(make_pair(p, 1));
    
    return ret;
}

Measured memory_bytes: 3612
//#include "stdafx.h"
#include <stdio.h>
#include <iostream>
#include <set>
#include <queue>
#include <vector>
#include <algorithm>
#include <math.h>
#include <cmath>
#include <string>
#include <cstring>
#include <climits>
#include <sstream>
#include <iomanip>
#include <map>
#include <stack>
#include <tuple>
#include <numeric>
#include <assert.h>
#include <functional>
#include <unordered_map>
#include <cstdint>

using namespace std;

/*-----------------------------------------------------------------------------
　定義
 -------------------------------------------------------------------------------*/
#define REP(i, n)				for (int (i) = 0 ; (i) < (int)(n) ; ++(i))
#define REPN(i, m, n)			for (int (i) = m ; (i) < (int)(n) ; ++(i))
#define ALL(a)					(a).begin(),(a).end()
#define INF						2e9
#define MOD						(1000 * 1000 * 1000 + 7)
#define Ceil(x, n)				(((((x))+((n)-1))/n))		/* Nの倍数に切り上げ割り算 */
#define CeilN(x, n)				(((((x))+((n)-1))/n)*n)		/* Nの倍数に切り上げ */
#define FloorN(x, n)			((x)-(x)%(n))				/* Nの倍数に切り下げ */
#define IsOdd(x)				(((x)&0x01UL) == 0x01UL)			
#define IsEven(x)				(!IsOdd((x)))						
#define ArrayLength(x)			(sizeof( x ) / sizeof( x[ 0 ]))
#define	MAX_QWORD				((QWORD)0xFFFFFFFFFFFFFFFF)
#define M_PI					3.14159265358979323846
typedef long long				ll;
typedef unsigned long long int	QWORD;
typedef unsigned long long		SQWORD;
typedef pair<ll, ll>			P;

/*-----------------------------------------------------------------------------
　処理
 -------------------------------------------------------------------------------*/
int main()
{
	int N, M, Q;
	cin >> N >> M >>Q;

	static int sum[501][501];
	REP(i, M) {
		int a, b;
		cin >> a >> b;
		sum[a][b]++;
	}

	static int p[100000];
	static int q[100000];
	REP(i, Q) {
		cin >> p[i] >> q[i];
	}

	static int ruiseki[501][501];
	REPN(i, 1, 501) {
		REPN(j, 1, 501) {
			ruiseki[i][j] = ruiseki[i][j - 1] + sum[i][j];
		}
	}
	
	REP(i, Q) {
		ll ans = 0;
		int left = p[i];
		int right = q[i];
		for (int j = left; j <= right; j++) {
			ans += (ruiseki[j][right] - ruiseki[j][left - 1]);
		}
		cout << ans << endl;
	}

	return 0;
}



Measured memory_bytes: 3712
def hoge(n):
  return n * (n-1) // 2

N = int(input())
A = list(map(int, input().split()))

D = {}
for number in A:
  if not number in D:
    D[number] = 0
  D[number] += 1

sum = 0
for key in D:
  sum += hoge(D[key])

for number in A:
  print(sum - hoge(D[number]) + hoge(D[number]-1))

Measured memory_bytes: 88140
#include <bits/stdc++.h>
using namespace std;
int main() {
    int n;
    cin>>n;
    int ans;
    if(n%1000==0)
    ans=0;
    else
    {
        int rem=n%1000;
        ans=1000-rem;
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 3632
def dfs():
  stack = [[0]]
  count = 0
  while stack:
    route = stack.pop()
    if len(route) == N:
      #print 'route=',route
      count += 1
      continue
    now = route[-1]
    for next in filter(lambda x: EDGES[now][x] == 1, range(N)):
      #print 'now,next',now,next
      if next in route:
        continue
      newroute = route[:]
      newroute.append(next)
      stack.append(newroute)
  return count

N,M = map(int, raw_input().split())
EDGES = [[0 for i in range(N)] for i in range(N)]
for i in range(M):
  a,b = map(int, raw_input().split())
  EDGES[a-1][b-1] = 1
  EDGES[b-1][a-1] = 1

print dfs()

Measured memory_bytes: 2696
/*
*/
#include <iostream>
#include <algorithm>
#include <vector>
#include <map>
#include <string>
#include <cmath>

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

    std::map< std::string, std::vector<int> > ans;
    std::map< int, int > num;
    std::vector<std::string> k;

    std::string tmp_key;
    int tmp_p;

    for(int i=0; i< n; i++){
        std::cin >> tmp_key >> tmp_p;
        ans[tmp_key].push_back(tmp_p);
        num[tmp_p] = i+1;
        k.push_back(tmp_key);
    }

    std::sort(k.begin(),k.end());    
    tmp_key = "";
    for(auto itr = k.begin(); itr < k.end(); itr++){
        if(*itr== tmp_key)
        {
        }
        else
        {
            tmp_key = *itr;
            std::sort(ans[*itr].begin(), ans[*itr].end());
            // std::cout << *itr << std::endl;
            for(auto itr2 = ans[*itr].end()-1; itr2 >= ans[*itr].begin(); itr2--){
                std::cout << num[*itr2] << std::endl;
            }
        }
    }


    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int n;
    cin >> n;
    vector<int> a(n);
    int d[100010] = {};
    rep(i, 0, n){
        cin >> a[i];
        if(a[i] != 0) d[a[i] - 1]++;
        d[a[i]]++;
        d[a[i] + 1]++;
    }
    int MAX = 0;
    rep(i, 0, 100010) chmax(MAX, d[i]);
    cout << MAX << endl;
}

Measured memory_bytes: 1920
n = gets.chomp.to_i
csf = []
(n-1).times do
  csf.push gets.split.map(&:to_i)
end
def calc(csfs)
  sum = 0
  csfs.each do |csf|
    c = csf[0]
    s = csf[1]
    f = csf[2]
    if sum > s
      if sum % f == 0
        ds = 0
      else
        ds = f - sum % f
      end
      sum += ds + c
    else
      sum = s + c
    end
  end
  sum
end
0.upto(n-2) do |i|
  puts calc(csf[i..n-1])
end
puts 0


Measured memory_bytes: 1788
#include<bits/stdc++.h>
using namespace std;
int main(){
  int A,B,C,D;cin>>A>>B>>C>>D;
  int left=A+B,right=C+D;
  if(left>right)cout<<"Left"<<endl;
  else if(left==right)cout<<"Balanced"<<endl;
  else cout<<"Right"<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define DAU  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define PLEC return 0;
using namespace std;
bool palin(string s) {
    string aux = s;
    reverse(aux.begin(), aux.end());
    return s == aux;
}
int n;
string s, a, b;
int main() {
    DAU
    cin >> s;
    n = static_cast<int>(s.size());
    for (int i = 0; i < (n - 1) / 2; ++i)
        a += s[i];
    for (int i = (n + 3) / 2 - 1; i < n; ++i)
        b += s[i];
    if (palin(s) && palin(a) && palin(b))
        cout << "Yes";
    else cout << "No";
    PLEC
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const ll mod=1e9+7;
char s[100010];
int vis[30]={0};
int main(){
    int n;
    scanf("%d",&n);
    scanf("%s",s);
    for(int i=0;i<n;i++)
        vis[s[i]-'a']++;
    ll ans=1;
    for(int i=0;i<26;i++)
        if(vis[i]!=0)ans=(ans*(vis[i]+1))%mod;

    printf("%lld\n",(ans-1)%mod);
   return 0;
}

Measured memory_bytes: 384
#include<bits/stdc++.h>
using namespace std;
int main()
{
    int i,nt,n,t,p=0,k,j;
    string s[2],m;
    cin>>s[0]>>s[1];
    cin>>n>>nt;
    cin>>m;
    if(m==s[0]){
        cout<<n-1<<" "<<nt<<endl;
    }
    else{
        cout<<n<<" "<<nt-1<<endl;
    }
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
#define mod             1000000007
#define rep(i,n)        for (int i = 0; i < n; ++i)
#define REP(i,k,n)      for (int i = k; i < n; ++i)
#define REPR(i,k,n)     for (int i = k; i >= n; --i)
#define w(x)            int x; cin>>x; while(x--)
#define mk(arr,n,type)  type *arr=new type[n];
#define pii             pair<int,int>
#define mp              make_pair
#define inrange(i, a, b) ((i >= min(a, b)) && (i <= max(a, b)))
#define fast            ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll              long long
#define w(x)            int x; cin>>x; while(x--)
#define mem(a, b)       memset(a, (b), sizeof(a))

void solve() {
    int s, n, ans = 0, prev, cur;
    cin >> s >> n;
    vector<int> arr(n);
    cin >> prev;
    int first = prev;
    for(int i = 1; i < n; i++) {
        cin >> cur;
        arr[i-1] = cur - prev;
        prev = cur;
    }
    arr[n - 1] = (s - prev) + first;
    sort(arr.begin() , arr.end());
    for(int i = 0; i < n-1; i++) {
        ans+= arr[i];
    }
    cout << ans << endl;    
} 
int main() {
    fast
    solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define ll long long
using namespace std;
 
const int maxn = 1e5;
 
int pos[maxn + 11];
 
int main(){
	int n;
	scanf("%d",&n);
	for (int i = 1; i <= n; i++) {
		int x;
		scanf("%d",&x);
		pos[x] = i;
	}
	set <int> s;
	set <int> :: iterator itl,itr;
	s.insert(0); s.insert(n + 1);
	ll ans = 0;
	for (int i = n; i >= 1; i--) {
		itl = s.lower_bound(pos[i]); itr = itl--;
		int l = *itl;
		int r = *itr;
		if (l == 0) {
			itr++;
			int R = *itr;
			if (r != n + 1) {
				ans += 1ll * pos[i] * (R - r) * i;
			}
		}
		else if (r == n + 1) {
			itl--;
			int L = *itl;
			ans += 1ll * (l - L) * (n - pos[i] + 1) * i;
		}
		else {
			itl--; itr++;
			int L = *itl; int R = *itr;
			ans += (1ll * (l - L) * (r - pos[i]) + 1ll * (R - r) * (pos[i] - l)) * i;
		}
		s.insert(pos[i]);
	}
	printf("%lld\n" , ans);
}

Measured memory_bytes: 8752
#include <bits/stdc++.h>
using namespace std;
#define _GLIBCXX_DEBUG
#define rep(i, from, to) for (int i = from; i < (to); ++i)
#define mp(x,y) make_pair(x,y)
#define all(x) (x).begin(),(x).end()
#define sz(x) (int)(x).size()
#define pb push_back
using ll = long long;
using vin=vector<int>;
using vll=vector<ll>;
using vst=vector<string>;
using P = pair<ll,ll>;
const int inf=1e9+7;
const ll INF=9e18;
template <typename T> bool chmin(T &a, const T& b){if(a > b){a = b;return true;}return false;}
template <typename T> bool chmax(T &a, const T& b){if(a < b){a = b;return true;}return false;}
template<class T> inline void Yes(T condition){ if(condition) cout << "Yes" << endl; else cout << "No" << endl; }
template<class T> inline void YES(T condition){ if(condition) cout << "YES" << endl; else cout << "NO" << endl; }
const int dx[4] = { 1, 0, -1, 0 };
const int dy[4] = { 0, 1, 0, -1 };

int main(){cout<<fixed<<setprecision(20);
		   string s;
           cin>>s;
           bool ans=false;
           if(s=="AKIHABARA")ans=1;
           if(s=="AKIHABAR")ans=1;
           if(s=="AKIHABRA")ans=1;
           if(s=="AKIHABR")ans=1;
           if(s=="AKIHBARA")ans=1;
           if(s=="AKIHBAR")ans=1;
           if(s=="AKIHBRA")ans=1;
           if(s=="AKIHBR")ans=1;
           if(s=="KIHABARA")ans=1;
           if(s=="KIHABAR")ans=1;
           if(s=="KIHABRA")ans=1;
           if(s=="KIHABR")ans=1;
           if(s=="KIHBARA")ans=1;
           if(s=="KIHBAR")ans=1;
           if(s=="KIHBRA")ans=1;
           if(s=="KIHBR")ans=1;
           YES(ans);
}

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

using namespace std;

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

ll gcd(ll a,ll b){
    if(a < b)swap(a,b);
    ll r = a%b;
    while(r!=0){
        a=b;
        b=r;
        r=a%b;
    }
    return b;
}


int main(){
    ll a, b, c, d;
    cin >> a >> b >> c >> d;
    ll e = c*d/gcd(c, d);
    ll cc = b/c-a/c;
    if(a%c==0)cc++;
    ll dd = b/d-a/d;
    if(a%d==0)dd++;
    ll cd = b/e-a/e;
    if(a%e==0)cd++;
    //cout << cc <<' '<< dd <<' '<< cd << endl;
    cout << b-a-(cc+dd-cd)+1 << endl;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define ll long long
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
#define FORR(i,a,b)for(ll i=(a);i<=(b);i++)
#define repR(i,n) for(ll i=n;i>=0;i--)
#define all(v)(v).begin(),(v).end()
#define rall(v)(v).rbegin(),(v).rend()
#define F first
#define S second
#define pb push_back
#define pu push
#define COUT(x) cout<<(x)<<endl
#define PQ priority_queue<ll>
#define PQR priority_queue<ll,vector<ll>,greater<ll>>
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define mp make_pair
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define sz(x) (int)(x).size()
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
const ll MOD = 1000000007LL;
const ll INF = 1LL << 60;
using vll = vector<ll>;
using vvll = vector<vll>;
using vstr = vector<string>;
using pll = pair<ll, ll>;
int main(){
  ll n;
  cin>>n;
  vll a(n);
  rep(i,n) cin>>a[i];
  ll ans=0;
  sort(all(a));
  ll cu=1;
  ll j=a[0];
  for(int i=0;i<n-1;i++){
    if(a[i]==a[i+1]){
      cu++;
    }
    else{
      if(cu<j){
        ans+=cu;
        j=a[i+1];
        cu=1;
      }
      else if(cu>j){
        ans+=cu-j;
        cu=1;
        j=a[i+1];
      }
      else{
        cu=1;
        j=a[i+1];
      }
    }
  }
  if(cu<j){
        ans+=cu;
  }
      else if(cu>j){
        ans+=cu-j;
        
      }
  COUT(ans);
}


Measured memory_bytes: 1024
def examA():
    a, b = LI()
    if b<a:
        a,b = b,a
    if a<=0 and 0<=b:
        print("Zero")
    elif 0<a:
        print("Positive")
    else:
        judge = b-a+1
        if judge%2==0:
            print("Positive")
        else:
            print("Negative")
    return

def examB():
    N, M = LI()
    flag_R = [False]*N
    cnt = [1]*N
    flag_R[0] = True
    for _ in range(M):
        x, y = LI()
        x -= 1; y -= 1
        if flag_R[x]:
            flag_R[y] = True
        cnt[y] += 1
        cnt[x] -= 1
        if cnt[x]==0:
            flag_R[x] = False
    ans = sum(flag_R)
    print(ans)
    return

def examC():
    ans = 0
    print(ans)
    return

def examD():
    ans = 0
    print(ans)
    return

def examE():
    ans = 0
    print(ans)
    return

def examF():
    ans = 0
    print(ans)
    return

import sys,bisect,itertools,heapq,math,random
from copy import deepcopy
from heapq import heappop,heappush,heapify
from collections import Counter,defaultdict,deque
def I(): return int(sys.stdin.readline())
def LI(): return list(map(int,sys.stdin.readline().split()))
def LSI(): return list(map(str,sys.stdin.readline().split()))
def LS(): return sys.stdin.readline().split()
def SI(): return sys.stdin.readline().strip()
global mod,mod2,inf,alphabet,_ep
mod = 10**9 + 7
mod2 = 998244353
inf = 10**18
_ep = 10**(-12)
alphabet = [chr(ord('a') + i) for i in range(26)]

sys.setrecursionlimit(10**6)

if __name__ == '__main__':
    examB()

"""

"""

Measured memory_bytes: 5492
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main() {
    string s, t;
    cin >> s >> t;
    int n = s.length();
    int m = t.length();
    int dp[n + 1][m + 1]{};
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (s[i] == t[j]) {
                dp[i + 1][j + 1] = dp[i][j] + 1;
            } else {
                dp[i + 1][j + 1] = max(dp[i + 1][j], dp[i][j + 1]);
            }
        }
    }
    string ans = "";
    int r = n;
    int c = m;
    while (r > 0 && c > 0) {
        if (s[r - 1] != t[c - 1]) {
            if (dp[r - 1][c] > dp[r][c - 1]) r--;
            else c--;
        } else {
            ans += s[r - 1];
            r--;
            c--;
        }
    }
    reverse(ans.begin(), ans.end());
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 35456
#include <bits/stdc++.h>
#define all(v) v.begin(), v.end()
#define rall(v) v.rbegin(), v.rend()
#define rep(i,n) for (int i=0;i<(int)(n);i++)
#define codefor int test;scanf("%d",&test);while(test--)
#define INT(...) int __VA_ARGS__;in(__VA_ARGS__)
#define LL(...) ll __VA_ARGS__;in(__VA_ARGS__)
#define yn(ans) if(ans)printf("Yes\n");else printf("No\n")
#define YN(ans) if(ans)printf("YES\n");else printf("NO\n")
#define vector1d(type,name,...) vector<type>name(__VA_ARGS__)
#define vector2d(type,name,h,...) vector<vector<type>>name(h,vector<type>(__VA_ARGS__))
#define umap unordered_map
#define uset unordered_set
using namespace std;
using ll = long long;
const int MOD=1000000007;
//入力系
void scan(int& a){scanf("%d",&a);}
void scan(long long& a){scanf("%lld",&a);}
template<class T> void scan(T& a){cin>>a;}
template<class T> void scan(vector<T>& vec){for(auto&& it:vec)scan(it);}
void in(){}
template <class Head, class... Tail> void in(Head& head, Tail&... tail){scan(head);in(tail...);}
//出力系
void print(const int& a){printf("%d",a);}
void print(const long long& a){printf("%lld",a);}
void print(const double& a){printf("%.15lf",a);}
template<class T> void print(const T& a){cout<<a;}
template<class T> void print(const vector<T>& vec){if(vec.empty())return;print(vec[0]);for(auto it=vec.begin();++it!= vec.end();){putchar(' ');print(*it);}}
void out(){putchar('\n');}
template<class T> void out(const T& t){print(t);putchar('\n');}
template <class Head, class... Tail> void out(const Head& head,const Tail&... tail){print(head);putchar(' ');out(tail...);}
//デバッグ系
template<class T> void dprint(const T& a){cerr<<a;}
template<class T> void dprint(const vector<T>& vec){if(vec.empty())return;cerr<<vec[0];for(auto it=vec.begin();++it!= vec.end();){cerr<<" "<<*it;}}
void debug(){cerr<<endl;}
template<class T> void debug(const T& t){dprint(t);cerr<<endl;}
template <class Head, class... Tail> void debug(const Head& head, const Tail&... tail){dprint(head);cerr<<" ";debug(tail...);}
ll intpow(ll a, ll b){ ll ans = 1; while(b){ if(b & 1) ans *= a; a *= a; b /= 2; } return ans; }
ll modpow(ll a, ll b, ll p){ ll ans = 1; while(b){ if(b & 1) (ans *= a) %= p; (a *= a) %= p; b /= 2; } return ans; }
ll updivide(ll a,ll b){if(a%b==0) return a/b;else return (a/b)+1;}

int main(){
    INT(n);
    vector<pair<int,int>> vec(n);
    rep(i,n){
        in(vec[i].first,vec[i].second);
    }
    int maxv=0,dx,dy;
    map<pair<int,int>,int> Map;
    for(int i=0;i<n;i++){
        for(int j=0;j<n;j++){
            if(i==j)continue;
            dx=vec[j].first-vec[i].first;
            dy=vec[j].second-vec[i].second;
            if(Map.count(make_pair(dx,dy))){
                Map[make_pair(dx,dy)]++;
            }else{
                Map[make_pair(dx,dy)]=1;
            }
            maxv=max(maxv,Map[make_pair(dx,dy)]);
        }
    }
    out(n-maxv);
}


Measured memory_bytes: 3832
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), end(x))
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) and (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define rcout(n) cout << right << setw(n)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define INF32 INT32_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b, bool t = false){ if(a<b or (t and a == b)){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b, bool t = false){ if(a>b or (t and a == b)){ a=b; return true; } return false; }


int N;
int A[10010];
map<int, int> f[10010], l;


map<int, int> factorize(int n){
    map<int, int> ret;
    repif(i, 2, i*i <= n) while(n%i == 0) ret[i]++, n/=i;
    if(n != 1) ret[n]++;
    return ret;
}


int modInv(int a, int m = MOD){
    int b = m, u = 1, v = 0;
    while(b){
        int t = a/b;
        a -= t*b; swap(a, b);
        u -= t*v; swap(u, v);
    }
    u %= m;
    if(u < 0) u += m;
    return u;
}


signed main(){
    cin >> N;
    rep(i, 0, N) cin >> A[i];

    rep(i, 0, N){
        f[i] = factorize(A[i]);
        for(auto p : f[i]) chmax(l[p.first], p.second);
    }

    int ans = 0;
    rep(i, 0, N) CHADD(ans, modInv(A[i]));
    for(auto p : l) rep(i, 0, p.second) CHMUL(ans, p.first);

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3968
#include<bits/stdc++.h>  
using namespace std;
int main(){
    ios::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout.precision(30);
    string s;
    int a,b;
    cin>>s;
    a=0;b=0;
    for(int i=0;i<3;i++){
        if(s[i]=='A'){
            a++;
        }
        else{
            b++;
        }

    }
    if(((a==2)&&(b==1))||((a==1)&&(b==2))){
        cout<<"Yes";
    }
    else{
        cout<<"No";
    }
    return 0;
}

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

using namespace __gnu_pbds; 
using namespace std;
using   ll=long long;
using   ld=long double;

#define fast        	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define ordered_set 	tree<pll, null_type,less<pll>, rb_tree_tag,tree_order_statistics_node_update>

#define endl        	"\n"
#define pb          	push_back
#define mp          	make_pair
#define F           	first
#define S           	second
#define int             long long int
#define pll				pair<int , int>

#define ALL(v)      	v.begin(),v.end()
#define ALLR(v)     	v.rbegin(),v.rend()
#define pii         	3.14159265358979323
#define inf     		LLONG_MAX
#define ones(x)     	__builtin_popcount(x)
#define fill(a,b)   	memset(a,b,sizeof(a))
#define mod 			1000000007
#define hell            998244353 

ll mod_pow(ll a,ll b,ll m) 
{
    ll res = 1;
    while(b)	
    {
        if(b&1) 	
        {
        	res=(res*a) % m;
        }
        a=(a*a) % m;
        b>>=1;
    }
    return res;
}

ll mod_inverse(ll a) 
{
	return mod_pow(a , mod-2 , mod);
}

void solve()
{
	string s;
	
	cin >> s;
	
	int f[26] {};
	
	for(auto u : s) {
		f[u-'a']++;
	}
	
	for(int i = 0; i < 26; ++i) {
		if(f[i] == 0) {
			cout << (char)(i+'a');
			
			return;
		}
	}
	
	cout << "None";
}

signed main() {
    fast;
    
    int t = 1;
    
	//cin >> t;
    
    while(t--) {
        solve();
    }
 
    return 0;
}


Measured memory_bytes: 3708
L = list(map(int, input().split()))
X = L[0]
K = L[1]
D = L[2]

if X >=D*K:
    print(abs(X-D*K))
elif X<= -D*K:
    print(abs(X+D*K))
    
if X>=0 and X<D*K:
    N = int(abs(X)/D)
    e = X - N*D
    if (K-N) % 2 == 0:
        print(abs(e))
    else:
        print(abs(e-D))

if X<0 and X>-D*K:
    N = int(abs(X)/D)
    e = -X - N*D
    if (K-N) % 2 == 0:
        print(abs(e))
    else:
        print(abs(e-D))

Measured memory_bytes: 9248
#include<iostream>
#include<algorithm>
using namespace std;
int n, ans;
int a[100];
int main()
{
  cin >> n;
  for (int i = 0; i < n; i++)
  {
    cin >> a[i];
  }
  sort(a, a + n);
  cout << a[n - 1] - a[0] << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
    int a,b;
    cin >> a >> b;
    if (a < b) {
        cout << "a < b" << endl;
    } else if (a > b) {
        cout << "a > b" << endl;
    } else {
        cout << "a == b" << endl;
    }
}


Measured memory_bytes: 3088
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <numeric>
#include <bitset>
#include <cmath>

static const int MOD = 1000000007;
using ll = long long;
using u32 = uint32_t;
using namespace std;

template<class T> constexpr T INF = ::numeric_limits<T>::max()/32*15+208;

template<class T>
class BIT {
    vector<T> bit;
public:
    BIT(int n): bit(vector<T>(n+1, 0)){}

    T sum(int k){
        T ret = 0;
        for (++k; k > 0; k -= (k & -k)) ret += bit[k];
        return ret;
    }

    void add(int k, T x){
        for (; k < bit.size(); k  += (k & -k)) bit[k] += x;
    }
};
int main() {
    int n, q;
    cin >> n >> q;
    BIT<ll> S(n+1), T(n+1);
    for (int i = 0; i < q; ++i) {
        int c;
        scanf("%d", &c);
        if(c == 0){
            ll s, t, x;
            scanf("%lld %lld %lld", &s, &t, &x);
            S.add(s, x);
            S.add(t+1, -x);
            T.add(s, -x*(s-1));
            T.add(t+1, x*t);
        }else {
            ll x, y;
            scanf("%lld %lld", &x, &y);
            printf("%lld\n", T.sum(y)-T.sum(x-1)+y*S.sum(y)-(x-1)*S.sum(x-1));
        }
    }
    return 0;
}


Measured memory_bytes: 4408
"use strict";
function Main(input){
	let xs = input.trim().split(' ')
    //console.log(xs[0],xs[1]);
    if(xs[0]=='D' && xs[1]=='D'){
    	console.log('H');
    }else if(xs[0]=='H' && xs[1]=='H'){
    	console.log('H');   
    } else{
    	console.log('D');
    }
}
Main(require('fs').readFileSync('/dev/stdin','utf8'));

Measured memory_bytes: 11468
x,k,d = map(int, input().split())
if abs(x) >= k*d:
    print(abs(x) - k*d)
else:
    k -= abs(x) // d
    x = abs(x) % d
    x2 = x - d
    if k % 2 == 1:
        print(abs(x2))
    else:
        print(x)

Measured memory_bytes: 9176