akhauriyash/Code-Regression huggingface dataset:
a,b,c,d = map(int,input().split())
cc = b//c -(a-1)//c
dd = b//d -(a-1)//d
#a,bの最大公約数
def gcd(a,b):
    if b == 0:
        return a
    else:
        return gcd(b,a%b)

#a,bの最小公倍数
def lcm(a, b):
	return a * b // gcd (a, b)
cd = lcm(c, d)
cdcd = b//cd -(a-1)//cd
print(b-a+1-cc-dd+cdcd)

Measured memory_bytes: 61748
#include<bits/stdc++.h>
using namespace std;
int main() {
  string s;
  cin >> s;
  int cntg = 0, cntp = 0;
  int win = 0, lose = 0;
  for(int i = 0; i < s.size(); ++i) {
    if(s[i] == 'p') {
      if(cntp < cntg) ++cntp;
      else ++lose, ++cntg;
    } else {
      if(cntp < cntg) ++win, ++cntp;
      else ++cntg;
    }
  }

  cout << win - lose << endl;
  return 0;
}
      


Measured memory_bytes: 512
def modpow(a,n,p):
    if n==0:
        return 1
    x=modpow(a,n//2,p)
    x=(x*x)%p
    if (n%2)==1:
        x=(x*a)%p
    return x%p
def modinv(a,p):
    return modpow(a,p-2,p)
fracmod=[0]*(2*(10**6))
fracmod[0]=1
fracmod[1]=1
p=10**9+7
X,Y=map(int,input().split())
for i in range(2,2*(10**6)):
    fracmod[i]=(fracmod[i-1]*i)%p
if (X+Y)%3==0:
    a=(X+Y)//3
    b=X-a
    #print(a,b)
    if (b<0)or(b>a):
        print("0")
    else:
        print((fracmod[a]*modinv(fracmod[a-b],p)*modinv(fracmod[b],p))%p)
else:
    print("0")


Measured memory_bytes: 55788
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define FOR(i,n,m) for(ll i=(n);i<(m);i++)
#define REP(i,n) FOR(i,0,n)
#define REPR(i,n) for(ll i=(n);i>=0;i--)
#define all(vec) vec.begin(),vec.end()
using vl=vector<ll>;
using vvl=vector<vl>;
using P=pair<ll,ll>;
using PP=pair<ll,P>;
using vp=vector<P>;
using vpp=vector<PP>;
using vs=vector<string>;
#define fi first
#define se second
#define pb push_back
const ll MOD=1000000007LL;
const int INF=1<<30;
const ll LINF=1LL<<60;
int main(){
    string st;
    cin>>st;
    int a[26]={};
    if(st.size()!=26){
        REP(i,st.size()){
            a[st[i]-'a']++;
        }
        for(int i=0;i<26;i++){
            if(!a[i]){
                cout<<st<<(char)('a'+i)<<endl;
                return 0;
            }
        }
    }
    string ans(26,'z');
    REP(i,st.size()){
        string temp=st.substr(0,i);
        int b[26]={};
        REP(j,i){
            b[st[j]-'a']++;
        }
        for(char c=st[i]+1;c<='z';c++){
            if(!b[c-'a']){
                temp+=c;
                break;
            }
        }
        if(temp.size()==i+1){
            assert(temp>st);
            cerr<<temp<<endl;
            ans=min(ans,temp);
        }
    }
    if(ans==string(26,'z')){
        cout<<"-1"<<endl;
    }else{
        cout<<ans<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<functional>
#include<string>
#include<algorithm>
#include<sstream>
using namespace std;
int main(){

  string in;
  int n;
  cin >> n;


  for(int i=0;i<n;i++){
    cin >> in;
    int a,b;
    //cout << (int)in[0];
    stable_sort(in.begin(),in.end());
    //cout << in[0] << endl;
    istringstream istr(in);
    istr >> a;
    //cout << a << endl;

    stable_sort(in.begin(),in.end(),greater<char>());
    istringstream str(in);
    str >> b;
    //>>cout << b << endl;
    cout << (b-a) << endl;
  }


}

Measured memory_bytes: 1248
import sys
from io import StringIO
import unittest

def resolve():
    n = int(input())
    a = [int(input()) for _ in range(n)]

    ans = 0
    next_i = 1
    goal = False
    for _ in range(n):
        next_i = a[next_i - 1]
        ans += 1
        if next_i == 2:
            goal = True
            break

    if goal:
        print(ans)
    else:
        print(-1)


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)
    def test_入力例_1(self):
        input = """3
3
1
2"""
        output = """2"""
        self.assertIO(input, output)
    def test_入力例_2(self):
        input = """4
3
4
1
2"""
        output = """-1"""
        self.assertIO(input, output)
    def test_入力例_3(self):
        input = """5
3
3
4
2
4"""
        output = """3"""
        self.assertIO(input, output)

if __name__ == "__main__":
    # unittest.main()
    resolve()

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

#define endl "\n"

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

const ll DIM = 100007;
const ll INF = 1000000007;
ll n,m,k;
ll a,b,c;
ll v[DIM],ans[DIM];
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);
    cin>>n;
    for(ll i=1;i<=n;i++)
      {

cin>>v[i];
if(i>=3)ans[i]+=min(abs(v[i-1]-v[i])+ans[i-1],abs(v[i-2]-v[i])+ans[i-2]);
if(i==2)ans[i]=abs(v[i]-v[i-1]);

      }
      cout<<ans[n];
    return 0;
}


Measured memory_bytes: 1792
#include<stdio.h>
int main(void)
{
	int i,n,max,x;
	char s[101];
	scanf("%d",&n);
	scanf("%s",s);
	max=0;
	x=0;
	for(i=0;i<n;i++) {
	    if(s[i]=='I') {
			x=x+1;
		}
	    if(s[i]=='D'){
			x=x-1;
		}
		if(max<x){
			max=x;
		}
	}
	printf("%d\n",max);
	return 0;
}


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

int main()
{
    //freopen("IN.txt","r",stdin);
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    double r;
    cin>>r;
    cout<<2*M_PI*r;
    return 0;
}

Measured memory_bytes: 3784
#include <stdio.h>
#include <algorithm>
int a, b, f[1002];
int main() {
	while (~scanf("%d%d", &a, &b)) {
		f[0] = 1;
		f[1] = 1;
		for (int i = 2; i <= a + 1; i++) f[i] = (f[i - 1] + f[i - 2]) % 1001;
		std::sort(f, f + a + 2);
		int ret = 1;
		for (int i = 3; i <= a + 1; i++) {
			if (f[i] - f[i - 1] >= b) {
				ret++;
			}
		}
		printf("%d\n", ret);
	}
	return 0;
}

Measured memory_bytes: 2732
//
//  main.swift
//
//  Created by sun-yryr
//  Copyright © 2019 sun-yryr. All rights reserved.
//

import Foundation

prefix operator *
prefix func * <T> (a: [T]) -> (T, T) {return (a[0], a[1])}
prefix func * <T> (a: [T]) -> (T, T, T) {return (a[0], a[1], a[2])}


func readInt(separator s: Character = " ") -> [Int] {return readLine()!.split(separator: s).map({Int($0)!})}
func readDouble(separator s: Character = " ") -> [Double] {return readLine()!.split(separator: s).map({Double($0)!})}
func readElement(separator s: Character = " ") -> [String] {return readLine()!.split(separator: s).map({String($0)})}

extension String {
    func at(_ i: Int) -> Character {
        precondition(0 <= i && i < self.count)
        return self[self.index(self.startIndex, offsetBy: i)]
    }
}

// 約数の計算。過程でtargetが出てきたらtrue
func yakusu(ai: Int, targets: Set<Int>) -> Bool {
    for i in 1...Int(floor(sqrt(Double(ai)))) {
        if (ai.isMultiple(of: i)) {
            if (targets.contains(i) || targets.contains(ai/i)) {
                return true
            }
        }
    }
    return false
}

func main() {
    let N = readInt()[0]
    let sortedA = readInt().sorted(by: <)
    var dp = Array<Bool>.init(repeating: true, count: sortedA[sortedA.count-1]+1)
    var used = Set<Int>()
    for ai in sortedA {
        if (used.contains(ai)) {
            dp[ai] = false
            continue
        } else {
            used.insert(ai)
            var multipleAi = ai * 2
            while(multipleAi < dp.count) {
                dp[multipleAi] = false
                multipleAi += ai
            }
        }
    }
    var ans = 0
    for ai in used {
        if (dp[ai] == true) {
            ans += 1
        }
    }
    print(ans)
}
main()


Measured memory_bytes: 24804
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <string.h>
using namespace std;
typedef long long ll;
int pi=3.14159;
int a[101];
ll N,K;
int M;
int i;
double z;
int main(){
int n;
cin>>n;
int flag=1;
while(n--)
{
	int num;
	cin>>num;
	if(num%2==0)
		if(num%3!=0&&num%5!=0)
		flag=0;
}
if(flag==1)
printf("APPROVED\n");
else 
printf("DENIED\n");
} 

Measured memory_bytes: 256
#include <cstdio>
#include <cstring>
#include <cmath>
#include <utility>
#include <iostream>
#include <functional>
#include <bitset>
#include <algorithm>
#include <vector>
#include <forward_list>
#include <set>
#include <map>
#include <queue>
#include <deque>
#include <stack>
#include <tuple>
#include <numeric>
#define rep(i, s, g) for ((i) = (s); (i) < (g); ++(i))
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
const ll MOD = 1e9 + 7;
const ll INF = (1ll << 60);

int main(void)
{
    ll n, m;

    cin >> n >> m;

    vector<ll> ans(n + 1, -1);

    vector<vector<ll>> G(n + 1, vector<ll>());

    for (int i = 0; i < m; i++)
    {
        ll a, b;
        cin >> a >> b;

        G[a].push_back(b);
        G[b].push_back(a);
    }

    queue<ll> q;
    q.push(1);

    while (q.size())
    {
        ll p = q.front();
        q.pop();

        for (auto x : G[p])
        {
            if (ans[x] == -1)
            {
                ans[x] = p;
                q.push(x);
            }
        }
    }

    cout << "Yes" << endl;

    for (int i = 2; i <= n; i++)
    {
        cout << ans[i] << endl;
    }
}


Measured memory_bytes: 12980
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const long long INF = 1LL << 60;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; } 
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }

vector<int> dp(100010, INT_MAX);

int main() {
    int N;
    cin >> N;
    dp[0] = 0;

    // 貰う DP --- dp[n] に遷移を集める
    for (int n = 1; n <= N; ++n) {
        for (int pow6 = 1; pow6 <= n; pow6 *= 6) {
            dp[n] = min(dp[n], dp[n - pow6] + 1);
        }
        for (int pow9 = 1; pow9 <= n; pow9 *= 9) {
            dp[n] = min(dp[n], dp[n - pow9] + 1);
        }
    }

    cout << dp[N] << endl;
}

Measured memory_bytes: 640
#include <algorithm>
#include <cmath>
#include <iostream>
#include <numeric>
#include <utility>
#include <string>
#include <unordered_map>
#include <vector>

using namespace std;

vector<int> pnum = {2, 3, 5, 7, 11, 13};

int divcount(int n) {
    int ans = 1;
    for (auto&& p : pnum) {
        int exp = 0;
        int nn = n;
        while (nn % p == 0) {
            exp++;
            nn /= p;
        }
        ans *= exp + 1;
    }
    return ans;
}

int main() {
    int n;
    cin >> n;
    int ans = 0;
    for (int i = 1; i <= n; i += 2) {
        if (divcount(i) == 8) ans++;
    }
    cout << ans << endl;
}


Measured memory_bytes: 256
def solve():
    MOD = 998244353

    N, M, K = map(int, input().split())

    # invs[x]: xの逆元 (x:0～n)
    def getInvs(n, MOD):
        invs = [1] * (n+1)
        for x in range(2, n+1):
            invs[x] = (-(MOD//x) * invs[MOD%x]) % MOD
        return invs
    invs = getInvs(N+3, MOD)

    nums = []
    num = M
    for x in reversed(range(1, N)):
        nums.append(num)
        num *= x*(M-1)
        num *= invs[N-x]
        num %= MOD
    nums.append(num)
    nums.reverse()
    #print('nums:', nums)

    ans = sum(nums[:K+1])
    ans %= MOD
    print(ans)

solve()


Measured memory_bytes: 26256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<ii> vii;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
#define fi first
#define se second
#define ALL(x) (x).begin(), (x).end()
#define RALL(x) (x).rbegin(), (x).rend()
#define pf push_front
#define eb emplace_back
#define pb push_back
#define mp make_pair
#define mt make_tuple
#define SZ(x) (int)(x).size()
#define endl '\n'
#define FOR(a, b, c) for (auto(a) = (b); (a) < (c); ++(a))
#define ROF(a, b, c) for (auto(a) = (b); (a) > (c); --(a))
#define F0R(a, b) FOR ((a), 0, (b))
#define R0F(a, b) ROF ((a), (b), -1)
#define CEIL(a, b) ((a) + (b)-1) / (b)
#define SET(a, b) memset((a), (b), sizeof(a))
template <class t>
bool ckmin(t& a, const t& b) {
  return a > b ? a = b, true : false;
}
template <class t>
bool ckmax(t& a, const t& b) {
  return a < b ? a = b, true : false;
}
#ifndef DEBUG
#define DEBUG 0
#endif
#define dout if (DEBUG) std::cerr
#define dvar(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p);
template <class T>
struct IsC {
  template <class C>
  static char test(typename C::const_iterator*);
  template <class C>
  static int test(...);
  static const bool value = sizeof(test<T>(0)) == sizeof(char);
};
template <>
struct IsC<string> {
  static const bool value = false;
};
template <class C>
typename enable_if<IsC<C>::value, ostream&>::type operator<<(ostream& o, const C& c) {
  o << '[';
  for (auto it = c.begin(); it != c.end();)
      o << *it << (++it != c.end() ? ", " : "");
  return o << ']';
}
template <class a, class b>
ostream& operator<<(ostream& o, const pair<a, b>& p) {
  return o << '(' << p.fi << ", " << p.se << ')';
}


struct FT {
  vi A;
  int n;
  FT(int n) : A(n + 1, 0), n(n) {}
  int inline LSOne(int i) { return i & (-i); }
  void add(int i, int v) {
    for (; i; i -= LSOne(i)) A[i] += v;
  }
  void add(int i, int j, int v) { add(j, v); add(i - 1, -v); }
  int query(int i) {
    int sum = 0;
    for (; i <= n; i += LSOne(i)) sum += A[i];
    return sum;
  }
  // lb assumes query(i, i) >= 0 forall i in [1, n]
  // returns min p >= 1, so that [1, p] >= sum
  // if [1, n] < sum, return n + 1
  int lb(int sum) {
    int pos = 0;
    for (int pw = 1 << 25; pw; pw >>= 1)
      if (pos + pw <= n && sum > A[pos | pw]) sum -= A[pos |= pw];
    if (sum) ++pos;
    return pos;
  }
};

void solve() {
  int n, k;
  cin >> n >> k;
  vi as(n + 1);
  F0R (i, n) cin >> as[i + 1];
  FT ft(n + 1);
  while (k-- && count(ALL(as), n) < n) {
    ft.A.assign(n + 1, 0);
    FOR (i, 1, n + 1) {
      int l = max(1, i - as[i]), r = min(n, i + as[i]);
      ft.add(l, r, 1);
    }
    FOR (i, 1, n + 1) {
      as[i] = ft.query(i);
    }
  }
  FOR (i, 1, n + 1) {
    cout << as[i] << ' ';
  }
  cout << endl;
}

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

  int tt = 1;
  FOR (t, 1, tt + 1) {
      // cout << "Case #" << t << ": ";
      solve();
  }

  return 0;
}


Measured memory_bytes: 4784
parseInt(x) = parse(BigInt, x)
parseMap(x::Array{SubString{String},1}) = map(parseInt, x)
function main()
  N = readline()
  sum=0
  for i in 1:length(N)
    sum += parse(Int,N[i])
  end
  #println(sum)
  if sum % 9 == 0
    println("Yes")
  else
    println("No")
  end

end
main()


Measured memory_bytes: 155596
def resolve():
    n = int(input())

    score_t = 0
    score_h = 0
    for _ in range(n):
        t, h = map(str, input().split())
        if t == h:
            score_t += 1
            score_h += 1
        if t > h:
            score_t += 3
        if h > t:
            score_h += 3
    print(score_t, score_h)


resolve()



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

#define ll long long
#define ull unsigned long long

using namespace std;

int main() {
	string S;
	cin >> S;

	ll N = S.size();
	ll MOD = 2019;

	//MODで割った余りの情報に落とす
	vector <ll> rem(N, 0);
	ll base = 1;
	for (int ii = N-1; ii >= 0; --ii){
		ll v = (S[ii] - '0') * base;
		rem[ii] = v % MOD;
		base = (base * 10) % MOD;
	}

	//累積和をとる
	ll ans = 0;
	vector <ll> sum(N+1, 0);
	map<int, int> m;
	for (int ii = N-1; ii >= 0; --ii){
		sum[ii] = (sum[ii+1] + rem[ii]) % MOD;
		m[sum[ii]]++;
		ans += m[sum[ii]] - 1;
		if (sum[ii] == 0){
			ans++;
		}
	}

	cout << ans << "\n";


	return 0;
}


Measured memory_bytes: 6828
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> P;
typedef pair<int,int> Pi;
#define rep(i,n) for(ll i=0;i<n;i++)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define fi first
#define se second
#define endl "\n"

template<typename T> inline bool chmax(T &a, T b){if(a<b){a=b;return true;}return false;}
template<typename T> inline bool chmin(T &a, T b){if(a>b){a=b;return true;}return false;}
template<typename T> ostream& operator<<(ostream& s,const complex<T>& d) {return s<<"("<<d.real()<<", "<<d.imag()<< ")";}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const pair<T1,T2>& d) {return s<<"("<<d.first<<", "<<d.second<<")";}
template<typename T> ostream& operator<<(ostream& s, const vector<T>& d){int len=d.size();rep(i,len){s<<d[i];if(i<len-1) s<<" ";}return s;}
template<typename T> ostream& operator<<(ostream& s,const vector<vector<T>>& d){int len=d.size();rep(i,len){s<<d[i]<<endl;}return s;}
template<typename T> ostream& operator<<(ostream& s,const set<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T> ostream& operator<<(ostream& s,const multiset<T>& v){s<<"{ ";for(auto itr=v.begin();itr!=v.end();++itr) {if (itr!=v.begin()) {s<< ", ";}s<<(*itr);}s<<" }";return s;}
template<typename T1, typename T2> ostream& operator<<(ostream& s,const map<T1,T2>& m){s<<"{"<<endl;for(auto itr=m.begin();itr!=m.end();++itr){s<<" "<<(*itr).first<<" : "<<(*itr).second<<endl;}s<<"}"<<endl;return s;}

const ll mod=1e9+7;
const ll inf=1e17;
const int INF=1e9;
const double EPS=1e-10;
const double PI=acos(-1);

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w,d;
    cin>>h>>w>>d;
    vector<vector<int>> a(h,vector<int>(w));
    vector<Pi> ind(h*w+1);
    rep(i,h)rep(j,w){
        cin>>a[i][j];
        ind[a[i][j]]=Pi(i,j);
    }
    vector<int> g(h*w+1,0);
    FOR(st,1,d+1){
        int now=st;
        for(int ne=st+d;ne<=h*w;ne+=d){ 
            g[ne]=g[now]+abs(ind[now].fi-ind[ne].fi)+abs(ind[now].se-ind[ne].se);
            now=ne;
        }
    }
    int q;
    cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<g[r]-g[l]<<endl;
    }
}

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

#define rep(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define ROF(i,a,b) for(int i=(a)-1;i>=(b);i--)
#define all(a) (a).begin(),(a).end()
#define rall(a) (a).rbegin(),(a).rend() //sortで大きい順
#define UNIQUE(v) v.erase(unique(all(v)),v.end())
#define SUM(a) accumlate(all(a),0)
#define pb push_back
#define fst first
#define snd second
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<string> vs;
typedef pair<int,int> pii;
typedef long long ll;

main(){
  int sx, sy, tx, ty; cin >> sx >> sy >> tx >> ty;

  rep(i,tx-sx) printf("R");
  rep(i,ty-sy) printf("U");
  rep(i,tx-sx) printf("L");
  rep(i,ty-sy) printf("D");

  printf("D");
  rep(i,tx-sx+1) printf("R");
  rep(i,ty-sy+1) printf("U");
  printf("L");
  printf("U");
  rep(i,tx-sx+1) printf("L");
  rep(i,ty-sy+1) printf("D");
  printf("R");
  printf("\n");
}


Measured memory_bytes: 256
def main():
  import sys
  input = sys.stdin.readline
  n, k = map(int, input().split())
  d =[]
  a =[]
  all = set(range(1,n+1))
  for i in range(k):
    d.append(int(input()))
    all -= set(map(int, input().split()))
  print(len(all))

if __name__ == '__main__':
    main()

Measured memory_bytes: 9224
/*
    ZI0N
*/

#include <bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>

using namespace std;
//using namespace __gnu_pbds;

//VARS
#define int               long long
#define ld                long double
#define mod1              1000000007
#define mod2              998244353
#define pi           `    3.14159265358979323846
#define hs                100006

#define pb                push_back
#define mp                make_pair
#define all(x)            (x).begin(),(x).end()
#define fi                first
#define se                second
#define vc                vector
#define pii               pair<int,int>
#define msi               map<string,int>
#define mii               map<int,int>
#define psi               pair<string,int>
#define pis               pair<int,string>
#define endl              "\n"

//INPUT
#define rep(i,a,b)        for(int i=a;i<b;i++)
#define repe(i,a,b)       for(int i=a;i<=b;i++)
#define bac(i,a,b)        for(int i=a;i>b;i--)
#define bace(i,a,b)       for(int i=a;i>=b;i--)

//FAST
#define ios               ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);

//FUNCTIONS
#define DECIMAL(n)        std::cout << std::fixed << std::setprecision(n)
#define SORT(v)           sort(all(v))
#define DSORT(v)          sort(all(v),greater<int>())
#define REVERSE(v)        reverse(ALL(v))
#define GCD(m,n)          __gcd(m,n)
#define LCM(m,n)          m*(n/GCD(m,n))
#define init(x,a)         memset(x,a,sizeof(x))
#define trav(a, x)        for(auto& a : x)
#define display(x)        trav(a,x) cout<<a<<" ";cout<<endl

void solve(){
    int a,b,c;
    cin>>a>>b>>c;
    cout<<max((int)0,c-a+b);
}


signed main(){
    ios
    int q=1;
    //cin>>q;
    while(q--){
        solve();
    }

    return 0;
}


Measured memory_bytes: 384
/*
#include <boost/multiprecision/cpp_int.hpp>
namespace mp = boost::multiprecision;
typedef mp::cpp_int mint; //*/
#include <bits/stdc++.h>
#define  re(i,j,n) for(li i=(j);i<(n);i++)
#define  rep(i,n) re(i,0,(n))
#define  red(i,n) for(li i=n-1;i>=0;i--)
#define  all(a) begin(a),end(a)
#define  pb(a) push_back(a)
using namespace std;
typedef long int li;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<li> vli;
typedef vector<string> vs;


int main()
{
    int n;
    cin>>n;
    int a[n];
    rep(i,n) cin>>a[i];
    sort(a,a+n);
    cout<<a[n-1]-a[0]<<endl;

    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <string>
#include <map>
#include <algorithm>
#include <fstream>
#include <math.h>
using namespace std;
typedef long long ll;


int main(){
int n,m;cin>>n>>m;
if(n==m)cout<<"Yes";
else cout<<"No";

}

Measured memory_bytes: 256
import java.io.*;
import java.util.*;

public class Main {
    static ContestScanner in;
    static Writer out;
    public static void main(String[] args) {
        Main main = new Main();
        try {
            in = new ContestScanner();
            out = new Writer();
            main.solve();
            out.close();
            in.close();
        } catch (IOException e) {
            e.printStackTrace();
        }
    }

    void solve() throws IOException {
        int a = in.nextInt();
        int b = in.nextInt();
        int c = in.nextInt();
        System.out.println(a <= c && c <= b ? "Yes" : "No");
    }
}


class Writer extends PrintWriter{
    public Writer(String filename)throws IOException
    {super(new BufferedWriter(new FileWriter(filename)));}
    public Writer()throws IOException{super(System.out);}
}
class ContestScanner implements Closeable{
    private BufferedReader in;private int c=-2;
    public ContestScanner()throws IOException
    {in=new BufferedReader(new InputStreamReader(System.in));}
    public ContestScanner(String filename)throws IOException
    {in=new BufferedReader(new InputStreamReader(new FileInputStream(filename)));}
    public String nextToken()throws IOException {
        StringBuilder sb=new StringBuilder();
        while((c=in.read())!=-1&&Character.isWhitespace(c));
        while(c!=-1&&!Character.isWhitespace(c)){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public String readLine()throws IOException{
        StringBuilder sb=new StringBuilder();if(c==-2)c=in.read();
        while(c!=-1&&c!='\n'&&c!='\r'){sb.append((char)c);c=in.read();}
        return sb.toString();
    }
    public long nextLong()throws IOException,NumberFormatException
    {return Long.parseLong(nextToken());}
    public int nextInt()throws NumberFormatException,IOException
    {return(int)nextLong();}
    public double nextDouble()throws NumberFormatException,IOException
    {return Double.parseDouble(nextToken());}
    public void close() throws IOException {in.close();}
}


Measured memory_bytes: 22484
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <cstring>
#include <iomanip>

using namespace std;

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


Measured memory_bytes: 256
import math,string,itertools,fractions,heapq,collections,re,array,bisect,sys,random,time,copy,functools

sys.setrecursionlimit(10**7)
inf = 10**20
mod = 10**9 + 7

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def LI_(): return [int(x)-1 for x in sys.stdin.readline().split()]
def LF(): return [float(x) for x in sys.stdin.readline().split()]
def LS(): return sys.stdin.readline().split()
def I(): return int(sys.stdin.readline())
def F(): return float(sys.stdin.readline())
def S(): return input()



def main():
    R,C,N = LI()
    a = []
    def ff(x,y):
        if x == 0:
            return (0,y)
        if x == R:
            return (R,-y)
        if y == 0:
            return (R+1, -x)
        return (1, x)

    for _ in range(N):
        x1,y1,x2,y2 = LI()
        if (0 < x1 < R and 0 < y1 < C) or (0 < x2 < R and 0 < y2 < C):
            continue
        a.append((ff(x1,y1),_))
        a.append((ff(x2,y2),_))
    a.sort()
    b = [a[i][1] for i in range(len(a))]
    s = [None] * (len(b))
    si = -1
    for c in b:
        if si < -1:
            si += 1
            s[0] = c
            continue
        if s[si] == c:
            si -= 1
        else:
            si += 1
            s[si] = c

    if si > 1:
        return 'NO'
    return 'YES'

print(main())








Measured memory_bytes: 115288
#include <bits/stdc++.h>
using namespace std;
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)

void solve()
{
   int r;
   cin >> r;
   double cur=2.0*M_PI*r;
    cout << setprecision(10) << cur << endl;
}


int main()
{
    fast_io;
    int t;
    //cin >> t;
t=1;
    for (int tt=1;tt<=t;tt++)
    {
        solve();
        

    }

    
    return 0;
}




Measured memory_bytes: 3808
<?php
/**
 * ABC127
 * D - Integer Cards
 */

// $s = trim(fgets(STDIN));
// fscanf(STDIN, "%d %d", $a, $b);
// $n = array_map('intval', explode(' ', trim(fgets(STDIN))));

fscanf(STDIN, "%d %d", $n, $m);
$a = explode(' ', trim(fgets(STDIN)));
for ($i = 0; $i < $m; $i++) {
    fscanf(STDIN, "%d %d", $b_list[$i], $c_list[$i]);
}

sort($a);
arsort($c_list);
$k = 0;
foreach ($c_list as $i => $c) {
    for ($j = 0; $j < $b_list[$i]; $j++) {
        if ($k == $n) {
            break;
        }
        $tasks[$k] = $c;
        $k++;
    }
}

for ($i = 0; $i < $k; $i++) {
    if ($a[$i] > $tasks[$i]) {
        break;
    }
    $a[$i] = $tasks[$i];
}

echo array_sum($a), PHP_EOL;


Measured memory_bytes: 31288
#include <iostream>
#include <vector>

using namespace std;

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

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

    vector<long long> y(m);
    for (int i = 0; i < m; i++) {
        cin >> y[i];
    }

    long long x_sum = 0;
    for (int i = 0; i < n; i++) {
        x_sum += i * x[i] - (n - i - 1) * x[i];
        x_sum %= 1000000007;
    }

    long long y_sum = 0;
    for (int i = 0; i < m; i++) {
        y_sum += i * y[i] - (m - i - 1) * y[i];
        y_sum %= 1000000007;
    }

    cout << x_sum * y_sum % 1000000007 << endl;
}


Measured memory_bytes: 1792
#define _USE_MATH_DEFINES
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <cstring>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <queue>
#include <deque>
#include <stack>
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <numeric>
#include <functional>
#include <cctype>
#include <list>
#include <limits>
#include <cassert>
#include <random>
#include <time.h>
#include <unordered_set>
// #include <boost/multiprecision/cpp_int.hpp>



using namespace std;
using Int = long long;
// using namespace boost::multiprecision;

const double EPS = 1e-10;
long long const MOD = 1000000007;

typedef vector<int> vec;
typedef vector<vec> mat;

long long mod_pow(long long x, long long n) {
    long long res = 1;
    for (int i = 0;i < 60; i++) {
        if (n >> i & 1) res = res * x % MOD;
        x = x * x % MOD;
    }
    return res;
}

long long my_mod_pow(long long x, long long n) {
	long long ret = 1;
	for (; n > 0; n >>= 1, x = x * x % MOD) {
		if (n & 1) {
			ret = ret * x % MOD;
		}
	}
	return ret;
}

template<typename T>
T gcd(T a, T b) {
    return b != 0 ? gcd(b, a % b) : a;
}

template<typename T>
T lcm(T a, T b) {
    return a * b / gcd(a, b);
}

void fastInput() {
    cin.tie(0);
    ios::sync_with_stdio(false);
}

int main(void) {
    int N; cin >> N;
    vector<int> L(N);
    for (int i = 0; i < N; i++) {
        cin >> L[i];
    }
    sort(L.begin(), L.end());

    long long ans = 0;
    for (int i = 0; i < N; i++) {
        for (int j = 0; j < N; j++) {
            if (i == j) continue;
            int l, r;
            l = (int)(lower_bound(L.begin(), L.end(), L[i] - L[j] + 1) - L.begin());
            l = max((int)(lower_bound(L.begin(), L.end(), L[j] - L[i] + 1) - L.begin()), l);
            r = (int)(lower_bound(L.begin(), L.end(), L[i] + L[j]) - L.begin());
            int tmp = 0;
            if (l <= i && i < r) tmp++;
            if (l <= j && j < r) tmp++;
            if (r <= l) continue;
            ans += r - l - tmp;
        }
    }

    cout << ans / 6 << endl;
}

Measured memory_bytes: 256
//***___********* ___*****___****___***___*********//
/*  |   \  |   | |   |   |   \  |     |     |   |  **
/*  |   |  |   | |___|   |   _  |__   |___  |___|  **
/*  |   |  |   | |   \   |  | | |         | |   |  **
/*  |___/  |___| |    \  |__| | |___  ____| |   |  **
//*************************************************/
#include<bits/stdc++.h>
#define ff double
#define endl "\n"
#define M 1000000007
#define forever while(1)
#define ll long long
#define pb push_back
#define vi vector<long long>
#define mii map<int,int>
#define pii pair<int,int>
#define set_zero(arr) memset(arr,0,sizeof(arr))
#define test ll t;cin>>t;while(t--)
#include <ext/pb_ds/tree_policy.hpp>
#define REP(i,n) for(int i=0;i<(n);i++)
#include <ext/pb_ds/assoc_container.hpp>
#define FOR(i,a,b) for(int i=(a);i<=(b);i++)
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);
#define buffer cin.ignore(numeric_limits<streamsize>::max(),'\n');
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
using namespace std;
using namespace __gnu_pbds;

int read()
{
	char ch=getchar();int f=0;
	while(ch<'0'||ch>'9') ch=getchar();
	while(ch>='0'&&ch<='9') {f=f*10+(ch^48);ch=getchar();}
	return f;
}
bool comp(string a,string b){return a<b;}

int main()
{

int m,n;
cin>>m>>n;
int sum=0;
int a;
for(int i=0;i<n;i++){
    cin>>a;
    sum+=a;
}
if(sum>=m)
    cout<<"Yes"<<endl;
else
    cout<<"No"<<endl;


return 0;
}




Measured memory_bytes: 256
#include<bits/stdc++.h>
#define pb           push_back
#define pii          pair<int,int>
#define vi           vector<int>
#define vpii         vector<pair<int,int>>
#define gph          map<int, vector<int>>
#define mp           make_pair
#define FOR(i, n) for (int i = 0; i <  (int)(n); i++)
#define FOR1(i, n) for (int i = 1; i <= (int)(n); i++)
#define FORD0(i, n) for (int i = (int)n; i >= 0; i--)
#define FORD1(i, n) for (int i = (int)n; i >= 1; i--)
#define FORS(i, n) for(; i < (int)(n); i++)
#define debug(X) { cout << #X << " = " << (X) << endl; }
#define printArr(A,n) { cout << #A << " = "; FOR(i,n) cout << A[i] << ' '; cout << endl; }
using namespace std;
#define int long long int
vi adj[(int)1000];
vi diam;
int levels[111] = {0};
vi dfs(int cur, int P){
    vi a, b;
    for(int child: adj[cur]){
        if(child != P){
            vi temp =dfs(child, cur);
            if(temp.size() >= a.size()){
               swap(a, b); 
               swap(a, temp);
            }
            else if(temp.size() >= b.size()){
                swap(temp, b);
            }
        }
    }
    a.pb(cur);
    if(diam.size() < a.size() + b.size() + 1){
        diam = a;
        diam.insert(diam.end(),b.begin(), b.end());
    }
    return a;
}

void pre(int cur, int P, int l){
    int cnt = 0;
    for(int child: adj[cur]){
        if(child == P)continue;
        pre(child, cur, l + 1);
        cnt++;
    }
    levels[l] = max(levels[l], cnt);
}
signed main(){
    ios_base::sync_with_stdio(false);cin.tie(NULL);
    
    int n;cin >> n;
    int x, y;
    FOR(i, n -1){
        cin >> x >> y;
        adj[x].pb(y);
        adj[y].pb(x);
    }
    dfs(1, -1);

    reverse(diam.begin(), diam.end());
//    for(int x: diam)cout <<x << " ";cout <<endl;
    int minC = (diam.size()+1)/2;
    int minL = 1e18;
    int c = diam.size()/2;
    if(diam.size() & 1){
    
        //edge split
        //centre node number is c
        c= diam[c];
        for(int child: adj[c]){
            pre(child, c, 0);
            pre(c, child, 0);
            int cnt = 1;
            int j = 0;
            while(levels[j] != 0){
                cnt *= levels[j];
                j++;
            }
            minL = min(minL, cnt * 2);
            memset(levels, 0, sizeof levels);
        }
        //node split
        int cnt = adj[c].size();
        for(int child: adj[c]){
            pre(child, c, 0);
        }
        int j =0;
        while(levels[j] != 0)cnt *= levels[j], j++;
        minL = min(minL, cnt);
    }else{
       //edge split
       int c2 = c-1; 
       c = diam[c];
       c2 = diam[c2];
       pre(c2, c, 0);
       pre(c, c2, 0);
       int cnt =1;
       int j = 0;
       while(levels[j] != 0){
        cnt *= levels[j], j++;
       }
       minL = min(minL, cnt * 2);
    }
    cout << minC << " " << minL;
}




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

int main(){
  int N;
  cin >> N;
  vector<int> V(N),C(N);
  for(int i=0;i<N;i++) cin >> V.at(i);
  for(int i=0;i<N;i++) cin >> C.at(i);
  
  int total = 0;
  for(int i=0;i<N;i++){
    int dif = V.at(i)-C.at(i);
    if(dif>0) total += dif;
  }
  
  cout << total;
}

Measured memory_bytes: 256
#include <cstdio>
#include <climits>
#include <vector>
#include <algorithm>
#include <queue>
#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 99999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

#define RESIDUE(s,t) (capacity[s][t]-flow[s][t])
Weight augment(const Graph &g, const Matrix &capacity, Matrix &flow,
    const vector<int> &level, vector<bool> &finished, int u, int t, Weight cur) {
  if (u == t || cur == 0) return cur;
  if (finished[u]) return 0;
  finished[u] = true;
  FOR(e, g[u]) if (level[e->dst] > level[u]) {
    Weight f = augment(g, capacity, flow, level, finished,
        e->dst, t, min(cur, RESIDUE(u, e->dst)));
    if (f > 0) {
      flow[u][e->dst] += f; flow[e->dst][u] -= f;
      finished[u] = false;
      return f;
    }
  }
  return 0;
}
Weight maximumFlow(const Graph &g, int s, int t) {
  int n = g.size();
  Matrix flow(n, Array(n)), capacity(n, Array(n)); // adj. matrix
  REP(u,n) FOR(e,g[u]) capacity[e->src][e->dst] += e->weight;

  Weight total = 0;
  for (bool cont = true; cont; ) {
    cont = false;
    vector<int> level(n, -1); level[s] = 0; // make layered network
    queue<int> Q; Q.push(s);
    for (int d = n; !Q.empty() && level[Q.front()] < d; ) {
      int u = Q.front(); Q.pop();
      if (u == t) d = level[u];
      FOR(e, g[u]) if (RESIDUE(u,e->dst) > 0 && level[e->dst] == -1)
        Q.push(e->dst), level[e->dst] = level[u] + 1;
    }
    vector<bool> finished(n); // make blocking flows
    for (Weight f = 1; f > 0; ) {
      f = augment(g, capacity, flow, level, finished, s, t, INF);
      if (f == 0) break;
      total += f; cont = true;
    }
  }
  return total;
}

int main(){
	int i,V,E,s,t,e;
	//for(scanf("%d",&T);T;putchar(--T?' ':'\n')){
		scanf("%d%d",&V,&E);
		Graph g(V);
		for(;E--;)scanf("%d%d%d",&s,&t,&e),g[s].push_back(Edge(s,t,e)),g[t].push_back(Edge(t,s,0));
		printf("%d\n",maximumFlow(g,0,V-1));
	//}
}

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

M = 2019
L, R = map(int, input().split())
if R-L > M//3:
    print(0)
    exit(0)

L %= M
R %= M
if L>=R:
    R += M

res = 2222
for i in range(L,R):
    for j in range(i+1,R+1):
        res = min(res, i*j%M)

print(res)


Measured memory_bytes: 3060
from collections import defaultdict, Counter, namedtuple, deque

NN = 202020
MOD = 10**9+7
INF = float("inf")

f = [0]*NN
rf = [0]*NN
inv = [0]*NN
f[0], f[1] = 1, 1
rf[0], rf[1] = 1, 1
inv[1] = 1

for i in range(2, NN):
    f[i] = (f[i-1] * i) % MOD
    inv[i] = (-inv[MOD % i] * (MOD // i)) % MOD
    rf[i] = (rf[i-1] * inv[i]) % MOD


def C(n, r):
    return (f[n] * rf[r] * rf[n-r]) % MOD


def prime_factorize(n):
    a = []
    while n % 2 == 0:
        a.append(2)
        n //= 2
    f = 3
    while f * f <= n:
        if n % f == 0:
            a.append(f)
            n //= f
        else:
            f += 2
    if n != 1:
        a.append(n)
    return a


n, m = map(int, input().split())
primes = Counter(prime_factorize(m))


ans = 1
for k, v in primes.items():
    ans = (ans*C(v+n-1, v))%MOD

print(ans)

Measured memory_bytes: 45680
# Union Find 木
def find(parent, i):
    t = parent[i]
    if t < 0:
        return i
    t = find(parent, t)
    parent[i] = t
    return t


def unite(parent, i, j):
    i = find(parent, i)
    j = find(parent, j)
    if i == j:
        return
    parent[j] += parent[i]
    parent[i] = j


N, K, L = map(int, input().split())

roads = [-1] * N
rails = [-1] * N

for i in range(K):
    p, q = map(int, input().split())
    unite(roads, p - 1, q - 1)

for i in range(L):
    r, s = map(int, input().split())
    unite(rails, r - 1, s - 1)

d = {}
for i in range(N):
    t = (find(roads, i), find(rails, i))
    if t in d:
        d[t] += 1
    else:
        d[t] = 1

print(*[d[(find(roads, i), find(rails, i))] for i in range(N)])


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

int main() {
    string s, t, s_d, t_d;

    cin >> s;
    cin >> t;

    sort(s.begin(), s.end());
    sort(t.begin(), t.end(), greater<char>());
 
    if (s < t){
        cout << "Yes" << endl;
    }

    else
    {
        cout << "No" << endl;
    }
    
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define MD 1000000007
#define INF 1ll<<60
typedef pair<ll, ll> P;
template <typename T>
std::string tostr(const T &t){std::ostringstream os;os << t;return os.str();}
int dx[4]={1, 0, -1, 0}, dy[4]={0, 1, 0, -1};

int main(){
    int a,b;
    cin>>a>>b;
    if(a<=b) {
        for(int i=0;i<b;i++){
            cout<<a;
        }
        cout<<endl;
    }else{
        for(int i=0;i<a;i++){
            cout<<b;
        }
        cout<<endl;
    }
    return 0;
}


Measured memory_bytes: 256
n = gets.to_i
d = []
n.times do |i|
  d.push(gets.to_i)
end

(n-1).times do |i|
  (i+1..n-1).each do |k|
    if d[i] > d[k] then
      d[k],d[i] = d[i],d[k]
    end
  end
end

cnt = 1
(n-1).times do |i|
  if d[i] < d[i+1] then
    cnt += 1
  end
end
print("#{cnt}\n")

Measured memory_bytes: 1788
#include <bits/stdc++.h>
//#include <boost/multiprecision/cpp_int.hpp>
//#include <ext/pb_ds/assoc_container.hpp>
//#include <ext/pb_ds/tree_policy.hpp>
#pragma GCC optimize("O3")
#define REP(i,n) for(int i=0;i<n;i++)
#define REPP(i,n) for(int i=1;i<=n;i++)
#define ALL(obj) (obj).begin(), (obj).end()
#define EPS (1e-9)
#define INF (1e17)
#define PI (acos(-1))
//const double PI = acos(-1);
//const double EPS = 1e-15;
//long long INF=(long long)1E17;
//#define i_7 (long long)(1e9+7)
#define i_7 998'244'353
long mod(long a){
    long long c=a%i_7;
    if(c>=0)return c;
    return c+i_7;
}
long long po(long a, long b){
    if(b==0){
        return 1;
    }
    
    long long z = po(a,b/2);
    z = mod(z*z);
    if(b%2!=0){
        z = mod(a*z);
    }
    return z;
}
 
bool prime_(int n){
  if(n==1){
    return false;
  }else if(n==2){
    return true;
  }else{
    for(int i=2;i<=std::sqrt(n);i++){
      if(n%i==0){
        return false;
      }
    }
    return true;
  }
}
 
long long gcd_(long long a, long long b){
  if(a<b){
    std::swap(a,b);
  }
  if(a%b==0){
    return b;
  }else{
    return gcd_(b,a%b);
  }
}
 
long long lcm_(long long x, long long y){
  return (x/gcd_(x,y))*y;
}
 
//using namespace std;
//using namespace boost::multiprecision;
//using namespace __gnu_pbds;

int main(){
  using namespace std;
  int n, s;
  cin>>n>>s;
  long long a[n];
  REP(i, n) cin>>a[i];
  
  vector<long long> dp(s + 1, 0);
  long long ans = 0;
  REP(i, n){
    dp[0] += 1;
    dp[0] = mod(dp[0]);
    for(int t = s; t >= 0; t--){
      if(t + a[i] > s) continue;
      dp[t + a[i]] += dp[t];
      dp[t + a[i]] = mod(dp[t + a[i]]);
    }
    ans += dp[s];
    ans = mod(ans);
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3740
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
#include <ctype.h>

#define lli long long int
#define MAX(a,b) ((a)>(b)?(a):(b))

int main(void)
{
	int n;
	scanf("%d",&n);
	
	int *b;
	b = (int*)malloc(sizeof(int)*(n));
	int *a;
	a = (int*)malloc(sizeof(int)*(n));
	int i = 0;
	while (i < n-1)
	{
		scanf("%d",&b[i]);
		i++;
	}
	i = 0;
	a[0] = b[0];
	while (i < n-1)
	{
		if(a[i] > b[i])
			a[i] = b[i];
		a[i+1] = b[i];
		i++;
	}
	i = 0;
	int sum = 0;
	while (i < n)
	{
		sum+=a[i];
		i++;
	}
	printf("%d\n",sum);
	return(0);
}


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

using namespace std;

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

	string prev;
	cin >> prev;
	q--;

	set<string> s;
	s.insert(prev);

	bool ok = true;

	while(q--)
	{
		string next;
		cin >> next;

		ok &= next.front() == prev.back();
		ok &= (not s.count(next));

		s.insert(next);

		prev = next;
	}

	cout << (ok ? "Yes" : "No") << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cmath>
#include<iostream>
#include<vector>
#include<algorithm>
#include<map>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
ll inf = 1000000007;
ll c[15];
int main() {
	ll n, m, x;
	cin >> n >> m >> x;
	vector<vector<ll>>a(n);
	
	for (int i = 0; i < n; i++) {
		cin >> c[i];
		a[i].resize(m);
		for (int j = 0; j < m; j++) {
			cin >> a[i][j];
		}
	}
	ll ans = inf;
	for (int bit = 0; bit < (1 << n); bit++) {
		ll sum = 0;
		vector<ll>check(m, 0);
		bool ok = true;
		for (int i = 0; i < n; i++) {
			if (bit & (1 << i)) {
				sum += c[i];
				for (int j = 0; j < m; j++) {
					check[j] += a[i][j];
				}
			}
		}
		for (int k = 0; k < m; k++) {
			if (check[k] < x) {
				ok = false;
			}
		}
		if (ok) {
			ans = min(ans, sum);
		}

	}
	if (ans == inf) {
		cout << "-1" << endl;
	}
	else {
		cout << ans << endl;
	}
	return 0;
}



Measured memory_bytes: 3644
n = int(input())
L = tuple(map(int, input().split()))
L = sorted(L, reverse=True)

counts = 0
for i in range(n-2):
    a = L[i]
    for j in range(i+1, n-1):
        cc = a - L[j]
        left = j
        right = n
        while right - left > 1:
            mid = (right+left)//2
            if L[mid] > cc:
                left = mid
            else:
                right = mid
        counts += left - j
print(counts)


Measured memory_bytes: 42988
#include <stdio.h>
#include <string.h>
#include <math.h>
#include <iostream>
#include <string>
#include <cctype>
#include <algorithm>
#include <climits>
#include <list>

using namespace std;

int main()
{
	int n;
	string taro, hanako;
	int score[2] = {};
	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> taro >> hanako;
		if (taro > hanako) score[0] += 3;
		else if (taro < hanako) score[1] += 3;
		else {
			score[0]++;
			score[1]++;
		}
	}
	printf("%d %d\n", score[0], score[1]);
	return 0;
}

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

int main()
{
    int W,H,x,y,r;

    cin >> W >> H >> x >> y >> r;
    
    if(((x+r) <= W) && 
       ((y+r) <= H) &&
       ((x-r) >= 0) &&
       ((y-r) >= 0))
    {
        cout << "Yes" << endl;
    }
    else
    {
        cout << "No" << endl;
    }

    return 0;
}



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

int main() {
  string S;
  cin >> S;
  int ans = 0;
  REP(i,4) {
    if ( S[i] == '+' ) {
      ans++;
    }
    else {
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include<vector>
#include<cmath>
#include<map>
#include<cstdlib>
#include<iostream>
#include<sstream>
#include<fstream>
#include<string>
#include<algorithm>
#include<cstring>
#include<cstdio>
#include<set>
#include<stack>
#include<bitset>
#include<functional>
#include<ctime>
#include<queue>
#include<deque>
#include<complex>
#include<cassert>
using namespace std;
#define pb push_back
#define pf push_front
typedef long long lint;
typedef complex<double> P;
#define mp make_pair
#define fi first
#define se second
typedef pair<int,int> pint;
#define All(s) s.begin(),s.end()
#define rAll(s) s.rbegin(),s.rend()
#define REP(i,a,b) for(int i=a;i<b;i++)
#define rep(i,n) REP(i,0,n)
//問題文および制約はちゃんと確認しよう！
//サイズは10^5じゃなくて2×10^5とかかもしれないし、重要な制約・条件を見落としているかも
//とりあえずサンプルを読んでから解法を考えよう？
int x[100100];
int main()
{
	int n,k,q,a,out=0;
	cin>>n>>k>>q;
	memset(x,0,sizeof(x));
	rep(i,q){
		cin>>a;a--;x[a]++;
	}
	rep(i,n){
		if(k>q-x[i]) cout<<"Yes"<<endl;//out++;
		else cout<<"No"<<endl;
	}
	//cout<<out<<endl;
}


Measured memory_bytes: 1152
#include <bits/stdc++.h>
using namespace std;
#define inf (int)(1e9)

int main(){
	int H, W, i, j;
	scanf("%d%d", &H, &W);
	vector<string> s(H);
	for(i = 0; i < H; i++){
		cin >> s[i];
	}
	vector<vector<int>> dp(H, vector<int>(W, inf));
	dp[0][0] = (s[0][0] == '.' ? 0 : 1);
	for(i = 0; i < H; i++){
		for(j = 0; j < W; j++){
			if(i > 0){
				if(s[i][j] == '.'){
					dp[i][j] = min(dp[i][j], dp[i - 1][j]);
				}
				else if(s[i - 1][j] == '.'){
					dp[i][j] = min(dp[i][j], dp[i - 1][j] + 1);
				}
				else{
					dp[i][j] = min(dp[i][j], dp[i - 1][j]);
				}
			}
			if(j > 0){
				if(s[i][j] == '.'){
					dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				}
				else if(s[i][j - 1] == '.'){
					dp[i][j] = min(dp[i][j], dp[i][j - 1] + 1);
				}
				else{
					dp[i][j] = min(dp[i][j], dp[i][j - 1]);
				}
			}
		}
	}
	printf("%d\n", dp[H - 1][W - 1]);
	return 0;
}

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

int main(){
    int n;
    vector<int> con(0);
    scanf("%d",&n);

    int i,j;
    for(i=0;i<n;i++){
        cin>>j;
        con.push_back(j);
    }

    vector<int> sa(0);
    int m;
    for(i=0;i<n;i++){
        for(j=i+1;j<n;j++){
                m=abs(con.at(i)-con.at(j));
                sa.push_back(m);
        }
    }

    sort(sa.begin(),sa.end());
    cout<<sa.back()<<endl;
    return 0;
}


Measured memory_bytes: 256