akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()
#define strall(v) (v).cbegin(),(v).cend()
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}

int main(){
  ll n = 1e15;
  cin >> n;
  ll a,b,c,d,e;
  cin >> a >> b >> c >> d >> e;
  chmin(a,b);
  chmin(a,c);
  chmin(a,d);
  chmin(a,e);
  
  cout << (n + a -1)/ a + 4 << endl;


}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
    int A, B, C;
    scanf("%d %d %d", &A, &B, &C);

    if ((A == B && C != A) ||
        (B == C && A != B) ||
        (C == A && B != C))
    {
        printf("Yes");
    }
    else
    {
        printf("No");
    }
    return (0);
}

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

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

using namespace std;

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  rep(i,n) {
    cin>> vec[i];
    --vec[i];
  }
  int cnt = 0;
  rep(i,n) {
    if( i == vec[vec[i]] ) {
      ++cnt;
    }
  }
  cout << (int)(cnt)/2 << endl;
  return 0;
}


Measured memory_bytes: 640
#include <bits/stdc++.h>
#define int long long
#define double long double
#define endl "\n"
#define fastio ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define pb(x) push_back(x)
#define mp(a,b) make_pair(a,b)
#define ms(v,x) memset(v,x,sizeof(v))
#define ff first
#define ss second
#define frr(i,n) for(int i=0;i<n;i++)
#define td(v) v.begin(),v.end()
#define M   1000000007 // 1e9 + 7
#define MAXN 3010
using namespace std;
typedef pair<int,int> pii;
inline int mod(int n, int m){int ret = n%m; if(ret < 0) ret += m; return ret;}
int gcd(int a, int b){return (b == 0 ? a : gcd(b, a%b));}
int exp(int a,int b,int m){
    if(b==0) return 1;
    if(b==1) return mod(a,m);
    int k = mod(exp(a,b/2,m),m);
    if(b&1){
        return mod(a*mod(k*k,m),m);
    }    else return mod(k*k,m);
}

int dp[MAXN][MAXN];

int32_t main(){
	fastio;
	string s,t;
	cin>>s;
	cin>>t;
	int n = s.size();
	int m = t.size();
	dp[0][0] = 0;	
	for(int i=0;i<=n;i++){
		for(int j=0;j<=m;j++){
			if(i==0 || j==0)dp[i][j] = 0;
			else if(s[i-1]==t[j-1])dp[i][j] = 1 + dp[i-1][j-1];
			else dp[i][j] = max(dp[i-1][j],dp[i][j-1]);
		}
	}
	string res="";
	int i=n,j=m;
	while(i>0 && j>0){
		if(s[i-1]==t[j-1]){
			res+=s[i-1];
			i--;
			j--;
		}else {
			if(dp[i-1][j]>dp[i][j-1])i--;
			else j--;
		}
	}
	reverse(res.begin(),res.end());
	cout<<res<<endl;
}

Measured memory_bytes: 70912
import sys
stdin = sys.stdin
 
sys.setrecursionlimit(10**5) 
 
def li(): return map(int, stdin.readline().split())
def li_(): return map(lambda x: int(x)-1, stdin.readline().split())
def lf(): return map(float, stdin.readline().split())
def ls(): return stdin.readline().split()
def ns(): return stdin.readline().rstrip()
def lc(): return list(ns())
def ni(): return int(stdin.readline())
def nf(): return float(stdin.readline())

n,w = li()
wv = []
for _ in range(n):
    wv.append(tuple(li()))
    
MAX = 10**15
SIZE = 10**5+1
UPPER = 10**12
    
dp = [[MAX]*SIZE for _ in range(n+1)]
for item in range(n):
    dp[item][0] = 0

for item in range(n):
    wi, vi = wv[item]
    for value in range(1, SIZE):
        if value - vi >= 0:
            if 0 <= dp[item][value-vi] + wi <= w:
                dp[item+1][value] = min(dp[item][value],
                                        dp[item][value-vi] + wi)
                
            else:
                dp[item+1][value] = dp[item][value]
            
        else:
            dp[item+1][value] = dp[item][value]
        

ans = 0
for value in range(SIZE):
    if dp[n][value] <= UPPER:
        ans = max(ans, value)
        
print(ans)
            

Measured memory_bytes: 120300
W,H,N = map(int,input().split())

A = []
for i in range(N):
    x,y,a = map(int,input().split())
    A.append( [x,y,a] )

glid = []
for i in range(H):
    l = [0]*(W)
    glid.append(l)

for s in range(N):
    x = A[s][0]
    y = A[s][1]
    a = A[s][2]
    
    if a==1:
        for t in range(H):
            for u in range(x):
                glid[t][u] = 1
        
    elif a==2:
        for t in range(H):
            for u in range(x,W,1):
                glid[t][u] = 1
    
    elif a==3:
        y_ = H-y
        for t in range(y_,H,1):
            for u in range(W):
                glid[t][u] = 1
    
    else:
        y_ = H-y
        for t in range(0,y_,1):
            for u in range(W):
                glid[t][u] = 1

counter = 0
for i in range(H):
    a = glid[i].count(0)
    counter += a

print(counter)

Measured memory_bytes: 3316
d,g=map(int,input().split())
g//=100
l=[]
for i in range(d):
  p,c=map(int,input().split())
  c//=100
  l.append((p,c))

mn=10000
for i in range(2**d):
  pcnt=0
  qcnt=0
  nm=None
  for j in range(d):
    if i&(2**j):
      pcnt+=(j+1)*l[j][0]+l[j][1]
      qcnt+=l[j][0]
    else:
      nm=j
  if pcnt<g:
    need=(g-pcnt-1)//(nm+1)+1
    if need<l[nm][0]:
      qcnt+=need
    else:
      qcnt+=10000
  mn=min(mn,qcnt)
print(mn)
    
    
    

Measured memory_bytes: 71236
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

class Main {
	public static void main(String args[]) throws IOException {
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		Solver solver = new Solver();
		solver.init();
		solver.readHead(in.readLine());
		solver.readS(in.readLine());
		// for (; solver.hasNext();) {
		// solver.readBody(in.readLine());
		// }
		// solver.solve();
	}
}

class Solver {
	int N;
	int cnt;

	public void init() {
		N = 0;
		cnt = 0;
	}

	public void readHead(String str) {
		String[] strArr = str.split("\\s+");
		N = Integer.parseInt(strArr[0]);
		// System.out.println(N);
	}

	public void readS(String str) {
		if (str.length() % 2 != 0) {
			System.out.println("No");
			return;
		}
		String a = str.substring(0, str.length() / 2);
		String b = str.substring(str.length() / 2);
		// System.out.println(a);
		// System.out.println(b);
		if (a.equals(b))
			System.out.println("Yes");
		else
			System.out.println("No");
	}

	public boolean hasNext() {
		return cnt < N;
	}

	public void readBody(String str) {
		// System.out.println(str);
		cnt++;
	}

	public void solve() {

	}
}


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

#define DEBUG 0

#if DEBUG
  #define DLOG(...) fprintf(stderr, __VA_ARGS__)
#else
  #define DLOG(...)
#endif

void debug(auto f) {
#if DEBUG
  f();
#endif
}

int main() {
  ll n, q;
  string s;
  cin >> n >> q >> s;
  vector<char> t(q);
  vector<char> d(q);
  for (ll i = 0; i < q; i++) {
    cin >> t.at(i) >> d.at(i);
  }
  ll c1 = 0;
  for (ll i = q-1; i >= 0; i--) {
    if ((d.at(i) == 'L') && (c1 < n) && (t.at(i) == s.at(c1))) {
      c1++;
    }else if ((d.at(i) == 'R') && (c1 > 0) && (t.at(i) == s.at(c1-1))) {
      c1--;
    }
  }
  ll c2 = n-1;
  for (ll i = q-1; i >= 0; i--) {
    if ((d.at(i) == 'R') && (c2 >= 0) && (t.at(i) == s.at(c2))) {
      c2--;
    }else if ((d.at(i) == 'L') && (c2+1 < n) && (t.at(i) == s.at(c2+1))) {
      c2++;
    }
  }
  cout << c2-c1+1 << endl;
  return 0;
}



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

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

signed main(void) { cin.tie(0); ios::sync_with_stdio(false);
    int n; cin>>n; 
    map <int,int> mp;
    rep(i,n){
        int a; cin>>a;
        mp[a]++;
    }
    cout<<mp.size()<<endl;
}


Measured memory_bytes: 9340
#include<stdio.h>
#include<string.h>
#include<math.h>

int main()
{
    long long int n = 0;
    int counter = 0;
    int tmp_counter = 0;

    scanf("%lld", &n);

    for (long long int i = 2; n != 1;)
    {
        tmp_counter = 0;

        if (i > pow(n, 0.5))
        {
            counter += 1;
            break;
        }

        while ((n%i) == 0)
        {
            n = n/i;
            tmp_counter ++;
        }

        for (int i = 1; tmp_counter >= i; i++)
        {
            counter ++;
            tmp_counter = tmp_counter - i;
        }

        if (i == 2)
        {
            i++;
        } else {
            i += 2;
        }
        
    }

    printf("%d", counter);

    return 0;
}

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

#define INF 1001001001
long long dp[105][100005];//品物がiまでで価値がjのときの最小の重さ
//dp[i+1][j]=min(dp[i][j], dp[i][j-value[i]]+weight[i])

int main(){
  int n,w;
  long long weight[101], value[101];
  cin >> n >> w;
  for(int i=0;i<n;i++)cin >> weight[i] >> value[i];
  fill(dp[0], dp[0]+105*100005+1, INF);
  for(int i=0;i<=n;i++)dp[i][0]=0;
  for(int i=0;i<n;i++){
    for(int j=0;j<=1000*n;j++){
      if(j<value[i])dp[i+1][j]=dp[i][j];
      else dp[i+1][j]=min(dp[i][j], dp[i][j-value[i]]+weight[i]);
    }
  }

  // for(int i=0;i<=n;i++){
  //   for(int j=0;j<=1000*n;j++){
  //     printf("%3d", dp[i][j]);
  //   }
  //   cout << endl;
  // }

  int mx = 0;
  for(int i=0;i<=1000*n;i++){
    if(dp[n][i]<=w)mx=max(mx, i);
  }

  cout << mx << endl;

  return 0;
}

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

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

int main() {
    long long N; cin >> N;
    auto fac = factorize(N);
    int res = 0;
    for(auto [x, n] : fac) {
        int i = 1;
        while(i * (i + 1) / 2 <= n) ++i;
        res += i - 1;
    }
    cout << res << '\n';
}

Measured memory_bytes: 3632
package main

import "fmt"

func main() {
	var n, x int
	fmt.Scan(&n, &x)

	mSlice := make([]int, n)
	for i := range mSlice {
		fmt.Scan(&mSlice[i])
	}

	count := 0
	min := 99999999
	for _, m := range mSlice {
		count++
		x -= m
		if m < min {
			min = m
		}
	}

	for x >= min {
		count++
		x -= min
	}

	fmt.Println(count)
}


Measured memory_bytes: 512
object Main {
  def main(args: Array[String]) = {
    val sc = new java.util.Scanner(System.in)
    val N = sc.nextInt()
    val S = List.fill(N)(sc.next())
    val res = List("AC", "WA", "TLE", "RE")
    for(r <- res){
      println(s"$r x ${S.count(_ == r)}")
    }
  }
}


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

using namespace std;
typedef long long ll;

int n;
ll A[310][310];
bool F[310][310];

int main() {
  cin >> n;
  for (int i = 0; i < n; i++) {
    for (int j = 0; j < n; j++) {
      cin >> A[i][j];
      F[i][j] = true;
    }
  }

  for (int k = 0; k < n; k++) {
    for (int i = 0; i < n; i++) {
      for (int j = 0; j < n; j++) {
        if (i == j || j == k || k == i) {
          continue;
        }
        if (A[i][j] > (A[i][k] + A[k][j])) {
          cout << -1 << endl;
          return 0;
        }
        if (A[i][j] == (A[i][k] + A[k][j]) ) {
          F[i][j] = false;
        }
      }
    }
  }

  ll ans = 0;
  for (int i = 0; i < n; i++) {
    for (int j = i + 1; j < n; j++) {
      if (F[i][j]) {
        ans += A[i][j];
      }
    }
  }
  cout << ans << endl;
  return 0;
}

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

namespace IssueC
{
    class Program
    {
        static void Main(string[] args)
        {
            var count = int.Parse(Console.ReadLine());
            var values = Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray();
            Console.WriteLine(values.OrderBy(x => x).Aggregate((n, elem) => (n + elem) / 2.0));
        }
    }
}

Measured memory_bytes: 13396
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<(n);i++)
using namespace std;
typedef long long ll;
int main() {
  
  int m,d;cin>>m>>d;
  
  if (d<=9) {
    cout<<0<<endl;
  }
  
  else {
    int ans=0;
    for (int i = 1; i < m+1; i++) {
      for (int j = 10; j < d+1; j++) {
        int a=j/10;
        int b=j%10;
        if (a>=2&&b>=2&&a*b==i) ans++;
      }
    }
    cout<<ans<<endl;
  }
  
}

Measured memory_bytes: 256
#ifndef _GLIBCXX_NO_ASSERT
#include <cassert>
#endif
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>

#if __cplusplus >= 201103L
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <cwchar>
#include <cwctype>
#endif

// C++
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>

#if __cplusplus >= 201103L
#include <array>
#include <atomic>
#include <chrono>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#endif
using namespace std;
typedef long long int ll;
typedef long double ld;
typedef vector<ll> vi;
typedef vector<string> vs;
typedef pair<ll,ll> P;
typedef vector<P> vp;
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define REPR(i,n) for(int i=n-1;i>=0;i--)
#define FORR(i,n,m) for(int i=n-1;i>=m;i--)
#define all(in) in.begin(),in.end()
#define ALL(in,K) in,in+K
#define INF 1e18
#define MOD 100000007
#define SIZE 10005
#define PI 	3.14159265358979323846

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    int Max=0,Sum=0;
    REP(i,n){
        int Input;
        cin >> Input;
        if(Max<Input)Max=Input;
        Sum+=Input;
    }
    cout << ((2*Max<Sum)?"Yes":"No") << endl;
    return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <cassert>
#include <cfloat>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <deque>
#include <iostream>
#include <iterator>
#include <limits>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <utility>
#include <vector>

#define FOR(i,k,n) for(int(i)=(k);(i)<(n);++(i))
#define rep(i,n) FOR(i,0,n)
#define all(v) begin(v),end(v)
#define debug(x) std::cerr<<#x<<": "<<x<<"\n"
#define debug2(x,y) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<"\n"
#define debug3(x,y,z) std::cerr<<#x<<": "<<x<<", "<<#y<<": "<<y<<", "<<#z<<": "<<z<<"\n"

using ll=long long;
using vi=std::vector<int>;
using vvi=std::vector<vi>;
using vll=std::vector<ll>;
using vvll=std::vector<vll>;
template<typename T> using vvec=std::vector<std::vector<T>>;
template<typename T>
auto make_v(size_t sz){return std::vector<T>(sz);}
template<typename T,typename... Ts>
auto make_v(size_t sz,Ts...ts){return std::vector<decltype(make_v<T>(ts...))>(sz,make_v<T>(ts...));}
template<typename T>
void fill_v(T&var,const T&x){var=x;}
template<typename V,typename T>
void fill_v(V&v,const T&x){for(auto&& w:v){fill_v(w,x);}}

template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::vector<std::vector<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<T>&v){
  int sz=v.size();s<<"\n";rep(i,sz){s<<v[i];if(i<sz-1){s<<"\t";}}s<<"\n";return s;}
template<typename T> std::ostream& operator<<(std::ostream&s,const std::deque<std::deque<T>>&v){
  for(auto&& w:v){s<<w;}return s;}
template<typename T> std::ostream& operator<<(std::ostream&s, const std::set<T>&v){
  s<<"\n";for(auto&& elm:v){s<<elm<<"\t";}s<<"\n";return s;}

inline void scan(int&a){scanf("%d",&a);}
inline void scan(ll&a){scanf("%lld",&a);}
inline void scan(char&a){scanf(" %c",&a);}
inline void scan(double&a){scanf("%lf",&a);}
template<typename T>
inline void scan(std::vector<T>&v){for(auto&& sv:v){scan(sv);}}
template<typename First,typename...Args>
inline void scan(First&f,Args&...args){scan(f);scan(args...);}
inline void scan(std::string&s){char BUF[3000000];scanf(" %s",BUF);s=std::string(BUF);}
inline void print(int a){printf("%d\n",a);}
inline void print(ll a){printf("%lld\n",a);}
inline void print(double a){printf("%.12f\n",a);}
inline void print(std::string s){std::cout<<s<<"\n";}

using namespace std;

void solve() {
  int n, m;
  scan(n, m);
  vi h(n);
  scan(h);
  vvi g(n);
  rep (i, m) {
    int a, b;
    scan(a, b);
    --a; --b;
    g[a].push_back(b);
    g[b].push_back(a);
  }
  int ans = 0;
  rep (u, n) {
    bool good = true;
    for (int v : g[u]) {
      if (h[u] <= h[v]) {
        good = false;
        break;
      }
    }
    if (good) {
      ans += 1;
    }
  }
  print(ans);
}

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


Measured memory_bytes: 8416
#include<bits/stdc++.h>
#include<atcoder/all>
using namespace std;
using namespace atcoder;
typedef long long ll;
typedef vector<int> vi;
typedef pair<int,int> pii;
#define MP make_pair
#define PB push_back
#define inf 1000000007
#define rep(i,n) for(int i = 0; i < (int)(n); ++i)
#define all(x) (x).begin(),(x).end()

template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}
 
template<class T> inline bool chmax(T &a, T b){
    if(a<b){
        a = b;
        return true;
    }
    return false;
}

template<class T> inline bool chmin(T &a, T b){
    if(a>b){
        a = b;
        return true;
    }
    return false;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,q;
    cin >> n >> q;
    fenwick_tree<ll> ft(n);
    rep(i,n){
        int a;
        cin >> a;
        ft.add(i,a);
    }
    rep(i,q){
        int t,u,v;
        cin >> t >> u >> v;
        if(t==1){
            cout << ft.sum(u,v) << "\n";
        }else{
            ft.add(u,v);
        }
    }
    return 0;
}

Measured memory_bytes: 8252
N = int(input())
S = {}
for _ in range(N):
    s = input()
    if s in S:
        S[s] += 1
    else:
        S[s] = 1

M = int(input())
T = {}
for _ in range(M):
    t = input()
    if t in T:
        T[t] += 1
    else:
        T[t] = 1

res = 0

for s in S:
    if s in T:
        if S[s] - T[s] > 0:
            res = max(res, S[s] - T[s])

    else:
        res = max(res, S[s])

print(res)



Measured memory_bytes: 9032
import math
import fractions
import bisect
import collections
import itertools
import heapq
import string
import sys
import copy
from collections import deque
sys.setrecursionlimit(10**7)
def gcd(a,b):return fractions.gcd(a,b) #最大公約数
def lcm(a,b):return (a*b) // fractions.gcd(a,b) #最小公倍数
def iin(): return int(input()) #整数読み込み
def isn(): return input().split() #文字列読み込み
def imn(): return map(int, input().split()) #整数map取得
def iln(): return list(map(int, input().split())) #整数リスト取得
def iln_s(): return sorted(iln()) # 昇順の整数リスト取得
def iln_r(): return sorted(iln(), reverse=True) # 降順の整数リスト取得
def join(l, s=''): return s.join(l) #リストを文字列に変換
def perm(l, n): return itertools.permutations(l, n) # 順列取得
def perm_count(n, r): return math.factorial(n) // math.factorial(n-r) # 順列の総数
def comb(l, n): return itertools.combinations(l, n) # 組み合わせ取得
def comb_count(n, r): return math.factorial(n) // (math.factorial(n-r) * math.factorial(r)) #組み合わせの総数
def divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i: divisors.append(n//i)
    return divisors
def is_prime(n):
    if n == 1: return False
    for i in range(2, int(n**0.5) + 1):
        if n % i == 0: return False 
    return True
def primes(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n + 1, i): is_prime[j] = False
    return [i for i in range(n+1) if is_prime[i]]
def sieve_of_e(n):
    is_prime = [True] * (n+1)
    is_prime[0] = False
    is_prime[1] = False
    for i in range(2, int(n**0.5)+1):
        if not is_prime[i]: continue
        for j in range(i * 2, n+1, i): is_prime[j] = False
    return is_prime
def run_length_encode(s):
    count = 1
    code = []
    target = s[0]
    for i in range(1, len(s)):
        if target == s[i]: count += 1
        else:
            code.append((target, count))
            target = s[i]
            count = 1
    code.append((target, count))
    return code

N,K = imn()
h = iln()
dp = [10**10] * (N)
dp[0] = 0

for i in range(N-1):
    for j in range(1,K+1):
        if i+j < N:
            dp[i+j] = min(dp[i+j], dp[i] + abs(h[i]-h[i+j])) 
print(dp[N-1])


Measured memory_bytes: 78968
N, M, K=map(int,input().split())
AB=[list(map(int,input().split()))for _ in range(M)]
CD=[list(map(int,input().split()))for _ in range(K)]
import sys;sys.setrecursionlimit(10**9)
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())
u=UnionFind(N)
for a,b in AB:u.union(a-1,b-1)
ans=[u.size(i)-1 for i in range(N)]

for a,b in AB:
  if u.same(a-1,b-1):
    ans[a-1]-=1
    ans[b-1]-=1
for c,d in CD:
  if u.same(c-1,d-1):
    ans[c-1]-=1
    ans[d-1]-=1
print(*ans)

Measured memory_bytes: 62116
S = input()
Y = [i for i in range(100)]
M = [i for i in range(1, 13)]
a = int(S[:2])
b = int(S[2:])
if a in M:
	if b in M:
		print('AMBIGUOUS')
	elif b in Y:
		print('MMYY')
elif a in Y:
	if b in M:
		print('YYMM')
	else:
		print('NA')

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

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

	string S;
	cin >> S;

	char slime[N];
	for (int i=0; i<N; i++) slime[i] = S.at(i);

	int count = 1;
	if (N!=1){
		for (int i=0; i<N-1; i++) {
			if (slime[i] != slime[i+1]) count++;
		}	
	}
	cout << count << endl;
}

Measured memory_bytes: 512
n, k = [int(i) for i in input().split()]

s = input()

if s[k-1] == "A":
    print(s[:k-1]+"a"+s[k:])

elif s[k-1] == "B":
    print(s[:k-1]+"b"+s[k:])
else:
    print(s[:k-1]+"c"+s[k:])

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair < int,int > PII;
typedef pair < ll,ll > PLL;
#define pb push_back
//#all(x) (x).begin(),(x).end()

//int const N = 1;
int const MOD = 1e9 + 7;

ll bigmod(ll a, ll b)
{
    if(b==0)
        return 1 % MOD;
    ll x = bigmod(a,b/2);
    x = (x * x) % MOD;
    if(b%2)
        x = (x * a) % MOD;
    return x;
}

int const N = 1e5 + 10;

ll n, h[N];
ll dp[N] ;



int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0);
    //memset(dp,-1,sizeof dp);
    cin >> n;

    for(int i = 0; i < n; i++)
        cin >> h[i] ;

    dp[0] = 0;

    for(int i = 1; i < n; i++)
    {
        if(i == 1)
            dp[i] = abs(h[i] - h[i-1]);
//        if(i == 2)
        else{
            dp[i] = min(dp[i-1] + abs(h[i]-h[i-1]),
                        dp[i-2] + abs(h[i] - h[i-2]));

            //dp[i] = min()
            //dp[i] =

        }
    }
    cout << dp[n-1] << '\n';
    return 0;
}




Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
int main(){
    int n;
    cin>>n;
    int w[n];
    int sum=0;
    for(int i=0;i<n;i++){
      cin>>w[i];
      sum += w[i];
    }
    int pre_sum=0;
    int ans=INFINITY;
    for(int i=0;i<n;i++){
        pre_sum += w[i];
        ans = min(ans, abs(sum-2*pre_sum));
    }
    cout << ans << endl;
    
}


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

#define null				""
#define all(dat)			dat.begin(), dat.end()
#define over(msg)			cout << msg << endl, exit(0);
#define loop(i, to)			for (int i = 0; i < to; ++i)
#define cont(i, to)			for (int i = 1; i <= to; ++i)
#define foreach(i, dat)		for (__typeof(dat.begin()) i = dat.begin(); i != dat.end(); ++i)

typedef long long			num;

using namespace std;

int n, k, h[100005], dp[100005];

int main() {
	cin >> n >> k;
	cont (i, n) {
		cin >> h[i];
		dp[i] = 2e9;
	}
	dp[1] = 0;
	cont (i, n) {
		cont (j, k) {
			if (i + j > n)  break;
			dp[i + j] = min(dp[i + j], dp[i] + abs(h[i] - h[i + j]));
		}
	}
	cout << dp[n] << endl;
}


Measured memory_bytes: 1024
N,P=map(int,input().split())
A=list(map(int,input().split()))
even=0
for i in range(N):
    if A[i]%2==0:
        even+=1

if even==N:
    if P==0:
        ans=2**N
    else:
        ans=0
else:
    ans=2**(N-1)

print(ans)

Measured memory_bytes: 9176
extern crate proconio;
use proconio::input;

fn main() {
    input! {
        n: usize,
        k: usize,
        mut p: [usize; n],
        c: [i64; n],
    }
    let p = p.iter().map(|x| x - 1).collect::<Vec<_>>();
    let mut ans = std::i64::MIN;
    for i in 0..n {
        let mut cur = i;
        let mut s = 0;
        let mut cycle = false;
        let mut len: usize = 0;
        for _ in 0..k {
            cur = p[cur];
            s += c[cur];
            ans = std::cmp::max(ans, s);
            len += 1;
            if cur == i {
                cycle = true;
                break;
            }
        }
        if cycle && s > 0 {
            let a = (k - 1) / len;
            s = s * a as i64;
            cur = i;
            let mut t = 0;
            for _ in 0..(k - a * len) {
                cur = p[cur];
                t += c[cur];
                ans = std::cmp::max(ans, s + t);
            }
        }
    }
    println!("{}", ans);
}

Measured memory_bytes: 2364
#include <iostream>
#include <cstring>
#include <cmath>
#include <vector>
#include <algorithm>
#include <stdio.h>
#include <math.h>
#include <stdlib.h>
#include <set>
#include <map>
#include <iterator>
#include <stack>
#include <string.h>
#include <cstdlib>
#include <queue>
#include <list>
#include <string>

using namespace std;

int main()
{
    int n;
    vector<long long> a;
    vector<long long> b;
    
    long long x,y;
    
    cin >> n;
    for (int i = 0;i < n;i++){
        cin >> x >> y;
        a.push_back(x);
        b.push_back(y);
    }
    
    sort(a.begin(),a.end());
    sort(b.begin(),b.end());
    
    if (n%2 == 1){
        long long sta = a[(n-1)/2];
        long long end = b[(n-1)/2];
        cout << (end-sta)+1 << endl;
    }
    else {
        long long sta = a[(n/2)-1]+a[n/2];
        long long end = b[(n/2)-1]+b[n/2];
        cout << (end-sta)+1 << endl;
    }
    
    
}


Measured memory_bytes: 6648
import java.util.Scanner;

public class Main{
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int K = N;
    int sum = 0;
    while(N > 0) {
      sum += N % 10;
      N /= 10;
    }
    if (K % sum == 0) System.out.println("Yes");
    else System.out.println("No");
  }
}


Measured memory_bytes: 21716
#include<iostream>
#include<vector>
#include<string>
#include<map>
#include<queue>
#include<algorithm>
typedef long long ll;
int main() {
	int a = 0, b = 0, c = 0, n = 0,m = 0;
	int ar[3] = {};
	int ans = 0;
	std::string str;
	std::cin >> a >> b;
	ar[0] = a + b;
	ar[1] = a - b;
	ar[2] = a * b;
	std::sort(ar,ar+3);
	std::cout << ar[2] << std::endl;
	return 0;
}

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

#define ll          long long
#define pb          push_back
#define endl        '\n'
#define mii         map<ll,ll>
#define pii         pair<ll,ll>
#define vi          vector<ll>
#define all(a)      (a).begin(),(a).end()
#define F           first
#define S           second
#define sz(x)       (ll)x.size()
#define hell        1000000007
#define INF         (1ll<<60)
#define rep(i,a,b)  for(ll i=a;i<=b;i++)
#define rrep(i,a,b)  for(ll i=a;i>=b;i--)
#define ios ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define time        cerr << "\nTime elapsed: " << 1000 * clock() / CLOCKS_PER_SEC << "ms\n";
ll gcd(ll a, ll b) { return b == 0 ? a : gcd(b, a % b); }
ll lcm(ll a, ll b) { return a * (b / gcd(a, b)); }
const int N=100005;
void solve(){
    ll n,k;
    cin>>n>>k;
    ll maxx=n/k;
    n-=maxx*k;
    cout<<min(n,abs(n-k))<<endl;
}
signed main()
{
    ios
    int TESTS=1;
    //cin>>TESTS;
    while(TESTS--){
        solve();
    }
    time
    return 0;
}

Measured memory_bytes: 256
// I SELL YOU...! 
#include<iostream>
#include<vector>
#include<algorithm>
#include<functional>
#include<queue>
#include<chrono>
using namespace std;
using ll = long long;
using P = pair<ll,ll>;
signed main(){
  ll n;
  cin >> n;
  cout << "ABC"<<n<<endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define PI 3.14159265358979323846
constexpr int INF = numeric_limits<int>::max() / 2;
constexpr long long INFL = numeric_limits<long long>::max() / 2;
constexpr int MOD = 1000000007;
using Graph = vector<vector<int>>;



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

    int x,y;
    cin >> x >> y;
    int X=abs(x);
    int Y=abs(y);
    int ans=abs(X-Y);
    if(x>0 && y>0 ){
        if(x>y) ans+=2;
    }
    else if(x<0 && y<0){
        if(x>y) ans+=2;
    }
    else if(x==0 ){
        if(y<0)ans++;
    }
    else if(y==0){
        if(x>0)ans++;
    }
    else ans++;
    cout << ans << endl;




}


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

int main()
{
	int a, b, c;

	cin >> a >> b >> c;

	if (a==b&& b==c) cout << "No";
	else if (a!=b && a!=c && b!=c) cout << "No";
	else cout << "Yes";
	return 0;
}

Measured memory_bytes: 3048
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using VI = vector<int>;
using VL = vector<ll>;
#define FOR(i,a,n) for(int (i)=(a);(i)<(n);++(i))
#define eFOR(i,a,n) for(int (i)=(a);(i)<=(n);++(i))
#define rFOR(i,a,n) for(int (i)=(n)-1;(i)>=(a);--(i))
#define erFOR(i,a,n) for(int (i)=(n);(i)>=(a);--(i))
#define SORT(i) sort((i).begin(),(i).end())
#define rSORT(i,a) sort((i).begin(),(i).end(),(a))
#define all(i) (i).begin(),(i).end()
#define out(y,x,h,w) (y) < 0 || (h) <= (y) || (x) < 0 || (w) <= (x)
constexpr ll INF = 1000000000;
constexpr ll LLINF = 1LL << 60;
constexpr ll mod = 1000000007;
constexpr ll MOD = 998244353;
const long double pi = acos(-1);
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; }
inline void init() { cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15); }
template<class T>inline istream& operator>>(istream& input, vector<T>& v) { for (auto& elemnt : v)input >> elemnt; return input; }


int main() {
    init();

    string str; cin >> str;
    int n = str.length();

    int s = 0, t = 0, ans = 0;
    FOR(i, 0, n) {
        if (str[i] == 'S')++s;
        else {
            if (s)--s;
            else ++ans;
        }
    }
    ans += s;

    cout << ans << "\n";
}


Measured memory_bytes: 720
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<cmath>
#include<algorithm>
using namespace std;
int main()
{
	int i,n,z = 0;
	char b,a[5] = {'P','W','G','Y'};
	scanf("%d",&n);
	while(n--)
	{
		scanf(" %c",&b);
		for(i = 0;i < 4; i++)
		{
			if(b == a[i])
			{
				a[i] = 'N';
				z++;
			}
		}
	}
	if(z == 3)
	printf("Three\n");
	else
		printf("Four\n");
	return 0;
}

Measured memory_bytes: 128
from collections import deque

n, q = map(int, input().split())
x = []
for i in range(0, n):
    x.append(list(input().split()))
    x[-1][1] = int(x[-1][1])

que = deque(x)
time = 0

while len(que) > 0:
    y = que.popleft()
    if y[1] <= q:
        time = time + y[1]
        print(y[0], time)
    else:
        time = time + q
        y[1] = y[1] - q
        que.append(y)



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

int main() {
  string o,e;
  cin >> o >> e;
  if(o.size()-e.size() == 1){
    for(int i = 0;i < e.size();i++){
      cout << o.at(i) << e.at(i);
    }
    cout << o.at(o.size()-1) << endl;
  }
  else{
    for(int i = 0;i < o.size();i++){
      if(i == o.size()-1){
        cout << o.at(i) << e.at(i) << endl;
      }
      else{
        cout << o.at(i) << e.at(i);
      }
    }
  }
}


Measured memory_bytes: 256
#include <stdio.h>
#include <math.h>

int main(void){
  int n;
  scanf("%d", &n);
  
  int a[n];
  int i;
  int min;
  int max;
  for(i=0; i<n; i++){
    scanf("%d", &a[i]);
    min=a[0];
    max=a[0];
  }
  
  for(i=0; i<n; i++){
    if(i==0){
      continue;
    }else{
      if(a[i] <= min){
          min = a[i];
      }
      if(max <= a[i]){
          max = a[i];
      }
    }
  }
  
  printf("%d\n", max-min);
  
  return 0;
}

Measured memory_bytes: 1732
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int n,m,i,c[100005],a,b,v,k,t[100005];
set<int> g[100005];
vector<int>first_half;
vector<int>second_half;
vector<int>total;
int par[209],group[209];
int arra[150000];
vector<int>arr;
map<char,int>cp;
map<int,int>mp;
deque<char>stp1;
deque<char>stp2;
map<int,int>pos;
map<string,int>check;
map<string,string>server;
vector<string>ans1;
vector<string>ans2;
vector<string>ans3;
string server1[1009];
string ip1[1009];
string server2[1009];
string ip2[1009];
ll cashier[109];
ll fir[109];
ll sec[100009];
vector<ll>sl1;
vector<ll>sl2;
int main()
{
  	
  ll a,b,c=0,d,e,f,g,h,i,j,k,l,n,s1=1,s2=1,m1=5,m2=15,t,m,mod=1000000007;
  //cin>>t;
  
  cin>>n>>k;
  ll sum1=0,sum2=0;
  for(i=0;i<=n;i++)
  {
     
     sum1=sum1+i;
     sum2=sum2+(n-i);
     sl1.push_back(sum1);
     sl2.push_back(sum2);   	
  }
  
  for(i=k-1;i<=n;i++)
  {
     b=(sl2[i]-sl1[i]+1)%mod;	
     c=c+b;
     c=c%mod;	
  }
  cout<<c%mod;
       
  
  
  
 
  
  
    	
  }
  
  
  
  	

Measured memory_bytes: 11388
#include <bits/stdc++.h>
#define ALL(obj) begin(obj), end(obj)
using namespace std;
template <class T>
vector<T> make_vec(size_t a) {
    return vector<T>(a);
}
template <class T, class... Ts>
auto make_vec(size_t a, Ts... ts) {
    return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));
}
template <class T>
bool chmax(T &a, const T &b) {
    if (a < b) {
        a = b;
        return 1;
    }
    return 0;
}
template <class T>
bool chmin(T &a, const T &b) {
    if (b < a) {
        a = b;
        return 1;
    }
    return 0;
}

using ll = long long;
using ull = unsigned long long;
const int INF = 2100100100;
const int MOD = 1e9 + 7;

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

struct Edge {
    int to;
    long long cost;
};
using Graph = vector<vector<Edge>>;

/* tree_diamiter : dfs を用いて重み付き木 T の直径を求める
*/
pair<long long, int> dfs(const Graph &G, int u, int par) {
    pair<long long, int> ret = make_pair(0LL, u);
    for (auto e : G[u]) {
        if (e.to == par) continue;
        auto next = dfs(G, e.to, u);
        next.first += e.cost;
        ret = max(ret, next);
    }
    return ret;
}
long long tree_diamiter(const Graph &G) {
    auto p = dfs(G, 0, -1);
    auto q = dfs(G, p.second, -1);
    return q.first;
}

int main() {
    int n;
    cin >> n;
    Graph T(n);
    for (int i = 0; i < n - 1; i++) {
        int s, t;
        cin >> s >> t;
        s--, t--;
        T[s].push_back({t, 1});
        T[t].push_back({s, 1});
    }
    long long w = tree_diamiter(T);
    if ((w + 2) % 3 == 0) {
        cout << "Second" << endl;
    } else {
        cout << "First" << endl;
    }
    return 0;
}


Measured memory_bytes: 33024
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
using namespace std;
typedef long long ll;

int main(){
    int a,b;cin>>a>>b;
    if(a%b==0)cout<<0;
    else cout<<1;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define PI 3.141592653589
#define ll long long
using namespace std;

template<typename T_char>
T_char ToUpper(T_char cX){return toupper(cX);}

int  main(){
  string s;
  cin >> s;
  ll n = s.size() + 1;

  vector<ll> a(n, 0);

  for(ll i=0; i<n-1; ++i){
    if(s[i]=='<'){
      a[i+1] = max(a[i+1], a[i]+1);
    }
  }

  for(ll i=n; i>0; --i){
    if(s[i-1]=='>'){
      a[i-1] = max(a[i-1], a[i]+1);
    }
  }

  ll sum = 0;

  for(ll i=0; i<a.size(); ++i){
    sum+= a[i];
  }

  cout << sum;
  return 0;
}

Measured memory_bytes: 4740
#include<cstdio>
#include<cstring>
#include<cmath>
#include<algorithm>
#include<vector>
#include<iostream>
#include<map>
#include<string>

#define maxn 3005

using namespace std;

inline int getint()
{
	int num=0,flag=1;char c;
	while((c=getchar())<'0'||c>'9')if(c=='-')flag=-1;
	while(c>='0'&&c<='9')num=num*10+c-48,c=getchar();
	return num*flag;
}

int MOD;
int n,m,q;
int C[maxn][maxn],S[maxn][maxn];

inline int ksm(int num,int k,int p)
{
	int ret=1;
	for(;k;k>>=1,num=1ll*num*num%p)if(k&1)ret=1ll*ret*num%p;
	return ret;
}

int main()
{
	n=getint(),MOD=getint();
	S[0][0]=C[0][0]=1;
	for(int i=1;i<=n+1;i++)
	{
		C[i][0]=1;
		for(int j=1;j<=i;j++)
		{
			S[i][j]=(S[i-1][j-1]+1ll*j*S[i-1][j])%MOD;
			C[i][j]=(C[i-1][j-1]+C[i-1][j])%MOD;
		}
	}
	int ans=0;
	for(int i=0;i<=n;i++)
	{
		int tmp=ksm(2,ksm(2,n-i,MOD-1),MOD),ret=0;
		if(i&1)tmp=MOD-tmp;
		tmp=1ll*tmp*C[n][i]%MOD;
		for(int j=0;j<=i;j++)ret=(ret+1ll*ksm(2,(n-i)*j,MOD)*S[i+1][j+1])%MOD;
		tmp=1ll*tmp*ret%MOD;
		ans=(ans+tmp)%MOD;
	}
	printf("%d\n",ans);
}

Measured memory_bytes: 58920
#include<stdio.h>

int main(){
	int N, R, ans;
	scanf("%d %d", &N, &R);
	if(N <= 10){
		ans = 100 * (10 - N) + R;
	}
	else{
		ans = R;
	}
	printf("%d", ans);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; (i) < (int)(n); ++ (i))
#define REP3(i, m, n) for (int i = (m); (i) < (int)(n); ++ (i))
#define REP_R(i, n) for (int i = (int)(n) - 1; (i) >= 0; -- (i))
#define REP3R(i, m, n) for (int i = (int)(n) - 1; (i) >= (int)(m); -- (i))
#define ALL(x) begin(x), end(x)
#define dump(x) cerr << #x " = " << x << endl
using ll = long long;
using namespace std;
template <class T> using reversed_priority_queue = priority_queue<T, vector<T>, greater<T> >;
template <class T, class U> inline void chmax(T & a, U const & b) { a = max<T>(a, b); }
template <class T, class U> inline void chmin(T & a, U const & b) { a = min<T>(a, b); }
template <typename X, typename T> auto make_vectors(X x, T a) { return vector<T>(x, a); }
template <typename X, typename Y, typename Z, typename... Zs> auto make_vectors(X x, Y y, Z z, Zs... zs) { auto cont = make_vectors(y, z, zs...); return vector<decltype(cont)>(x, cont); }
template <typename T> ostream & operator << (ostream & out, vector<T> const & xs) { REP (i, (int)xs.size() - 1) out << xs[i] << ' '; if (not xs.empty()) out << xs.back(); return out; }
template<typename Functor> struct fix_type { Functor functor; template<typename... Args> decltype(auto) operator() (Args && ... args) const & { return functor(functor, std::forward<Args>(args)...); } };
template<typename Functor> fix_type<typename std::decay<Functor>::type> fix(Functor && functor) { return { std::forward<Functor>(functor) }; }

ll solve(int n, int h, int w, const vector<int> & y, const vector<int> & x, const vector<ll> & a) {
    vector<int> row(h, -1), col(w, -1);
    unordered_set<int> used_row, used_col;
    function<bool (int, int)> go_row, go_col;
    go_row = [&](int y, int i) {
        if (used_row.count(y)) return false;
        used_row.insert(y);
        if (row[y] == -1) {
            row[y] = i;
            return true;
        } else {
            int j = row[y];
            bool p = go_col(x[j], j);
            if (p) row[y] = i;
            return p;
        }
    };
    go_col = [&](int x, int i) {
        if (used_col.count(x)) return false;
        used_col.insert(x);
        if (col[x] == -1) {
            col[x] = i;
            return true;
        } else {
            int j = col[x];
            bool p = go_row(y[j], j);
            if (p) col[x] = i;
            return p;
        }
    };

    ll answer = 0;

    vector<int> order(n);
    iota(ALL(order), 0);
    sort(ALL(order), [&](int i, int j) { return a[i] > a[j]; });
    for (int i : order) {
        if (go_row(y[i], i)) {
            row[y[i]] = i;
            answer += a[i];
            used_row.clear();
            used_col.clear();
        } else if (go_col(x[i], i)) {
            col[x[i]] = i;
            answer += a[i];
            used_row.clear();
            used_col.clear();
        }
    }
    return answer;
}

int main() {
    int n, h, w; cin >> n >> h >> w;
    vector<int> y(n), x(n);
    vector<ll> a(n);
    REP (i, n) {
        cin >> y[i] >> x[i] >> a[i];
        -- y[i];
        -- x[i];
    }
    cout << solve(n, h, w, y, x, a) << endl;
    return 0;
}


Measured memory_bytes: 10136
#include<iostream>
#include <stdlib.h>
#include <algorithm>
#include <string>
#include <math.h>
#include <vector>
#include <numeric>
typedef long long int ll;
using namespace std;

int main(){
	ll a,b;
	cin>> a >> b;
	ll c=b-a;
	ll count=0;
	ll k;
	for(int i=0; i<=c;i++){
		k=a+i;
		if(to_string(k)[0]==to_string(k)[4]&&to_string(k)[1]==to_string(k)[3]){
			count++;
		}
	}
	cout<< count << endl;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#define FOR(i,a,b) for(int i =(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<(n);i++)
#define REPm(i,n) for(int i=(n)-1;i>=0;i--)
#define REP1(i,n) for(int i=1;i<=(n);i++)
#define mp make_pair
typedef long long ll;
int main(){
    int a,b;
    cin >> a >> b;
    if(a%2 && b%2) cout << "Odd" << endl;
    else cout << "Even" << endl;
    return 0;
}


Measured memory_bytes: 256
import java.util.Scanner;

class Main {
	public static void main(String[] args) {
		Scanner scanner = new Scanner(System.in);
		int length = scanner.nextInt();
		boolean[][] list = new boolean[4][13];

		for (int i = 0; i < length; i++) {
			String pattern = scanner.next();
			int number = scanner.nextInt();

			if (pattern.equals("S"))
				list[0][number - 1] = true;
			else if (pattern.equals("H"))
				list[1][number - 1] = true;
			else if (pattern.equals("C"))
				list[2][number - 1] = true;
			else if (pattern.equals("D"))
				list[3][number - 1] = true;
		}

		for (int i = 0; i < 4; i++) {
			for (int i2 = 0; i2 < 13; i2++) {
				if (list[i][i2] != true) {
					if (i == 0)
						System.out.print("S");
					else if (i == 1)
						System.out.print("H");
					else if (i == 2)
						System.out.print("C");
					else if (i == 3)
						System.out.print("D");

					System.out.println(" " + (i2 + 1));
				}

			}
		}
	}
}

Measured memory_bytes: 26332
def main():
    n = int(input())
    tl = [[-1] * n for _ in range(n)]  # Testimonies list.
    for i in range(n):
        ts = int(input())
        for _ in range(ts):
            x, y = [int(x) for x in input().split()]
            x -= 1
            tl[i][x] = y  # i says that x is y.
    ans = set()
    for i in range(2 ** n):
        pl = [i >> d & 1 for d in range(n)]
        possible = True
        for k, p in enumerate(pl):
            if not possible:
                break
            if p != 1:
                continue
            # is honest.
            for j, t in enumerate(tl[k]):
                if t == -1:
                    continue
                if t != pl[j]:
                    possible = False
                    break
        if possible:
            ans.add(bin(i).count('1'))
    return max(ans)


if __name__ == '__main__':
    print(main())


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

int main(void)
{
    int N,M;
    cin >> N >> M;
    int A[M];
    int i;
    int total = 0;
    for(i=0;i<M;i++){
        cin >> A[i];
        total = total + A[i];
    }

    if((N-total)>=0){
        cout << N-total << endl;
    }
    else{
        cout << -1 << endl;
    }

    return 0;

}

Measured memory_bytes: 3636