akhauriyash/Code-Regression huggingface dataset:
using System;
using System.Linq;
using System.Collections.Generic;

namespace program
{
    class Program
    {
        static void Main()
        {
          int[] n = Input.ScanIntArray();
          if(n[1]==1 || n[0]==n[1])
            Console.WriteLine(0);
          else
            Console.WriteLine(n[0]-n[1]);
        }
    }

    static class Input
    {
        static public int ScanInt() { return int.Parse(Console.ReadLine()); }
        static public uint ScanUint() { return uint.Parse(Console.ReadLine()); }
        static public double ScanDouble() { return double.Parse(Console.ReadLine()); }
        static public long ScanLong() { return long.Parse(Console.ReadLine()); }
        static public ulong ScanUlong() { return ulong.Parse(Console.ReadLine()); }
        static public int[] ScanIntArray() { return Console.ReadLine().Split(' ').Select(x => int.Parse(x)).ToArray(); }
        static public uint[] ScanUintArray() { return Console.ReadLine().Split(' ').Select(x => uint.Parse(x)).ToArray(); }
        static public double[] ScanDoubleArray() { return Console.ReadLine().Split(' ').Select(x => double.Parse(x)).ToArray(); }
        static public long[] ScanLongArray() { return Console.ReadLine().Split(' ').Select(x => long.Parse(x)).ToArray(); }
        static public ulong[] ScanUlongArray() { return Console.ReadLine().Split(' ').Select(x => ulong.Parse(x)).ToArray(); }

        static public string ScanStr() { return Console.ReadLine(); }
        static public string[] ScanStrArray() { return ScanStr().Split(' '); }
    }

    static class MyMath
    {
        public static int GCD(int a, int b)
        {
            Func<int, int, int> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static ulong GCD(ulong a, ulong b)
        {
            Func<ulong, ulong, ulong> gcd = null;
            gcd = (x, y) => y == 0 ? x : gcd(y, x % y);
            return a > b ? gcd(a, b) : gcd(b, a);
        }
        public static int LCM(int a, int b)
        {
            return a * b / GCD(a, b);
        }
        public static ulong LCM(ulong a, ulong b)
        {
            return a * b / GCD(a, b);
        }
    }
}


Measured memory_bytes: 11348
#include <assert.h>
#include <ctype.h>
#include <errno.h>
#include <float.h>
#include <fstream>
#include <iomanip>
#include <iostream>
#include <set>
#include <queue>
#include <limits>
#include <deque>
#include <locale>
#include <math.h>
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <time.h>
#include <wchar.h>
#include <wctype.h>
#include <algorithm>
#include <bitset>
#include <map>
#include <iomanip>
#include <ios>
#include <iostream>
#include <vector>
#include <cwchar>
#include <cwctype>
#define mp make_pair
#define fs first
#define se second
#define memset(a,t) memset(a,t,sizeof(a))
#define all(v) v.begin(),v.end()
#define MN 0LL
#define Mx 200000005
#define Mn -Mx
#define MX 20000000000000005
using namespace std;
int readint(){
	char c;
	while(c=getchar(),(c<'0'||c>'9')&&c!='-');
	bool flag=(c=='-');
	if(flag)c=getchar();
	int x=0;
	while(c>='0'&&c<='9'){
		x=x*10+c-48;
		c=getchar();
	}
	return flag?-x:x;
}
inline string tos(int x){
	string s;
	while(x) s=(char)(x%10+'0')+s,x/=10;
	return s;
}
inline int toi(string s){
	int rt=0;
	for(int i=0;i<s.size();i++) rt=rt*10+(int)(s[i]-'0');
	return rt;
}
int main(){
	int i,j;
	int a,b,ans=0;
	cin>>a>>b;
	for(i=a;i<=b;i++){
		string s=tos(i);
		string t=s;
		reverse(t.begin(),t.end());
		if(t==s) ans++;
	}
	cout<<ans<<endl;
	return 0;
}


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

using namespace std;

void scan() {
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
}

#define ll long long
#define fir first
#define sec second
int vis[10000];

int solve(int T) {
    int n, m;
    cin >> n >> m;
    if (vis[n * m]&&n>=1&&n<=9&&m>=1&&m<=9) cout << n * m << endl;
    else cout << -1 << endl;
//    if (!vis[n]) cout << "No";
//    else cout << "Yes";
    return 0;
}


int main() {
//    scan();
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);

    memset(vis, 0, sizeof(vis));
    for (int i = 1; i <= 9; i++) {
        for (int j = 1; j <= 9; j++) {
            vis[i * j]++;
        }
    }
    int T = 1;
//    cin >> T;
    for (int i = 1; i <= T; i++) solve(i);
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int f(int *n,int l,int min,int max){
  int r=1,i,j,s[10000];
  for(s[i=0]=min-1;i<l;i++){
    for(s[j=r]=max+1;s[j-1]>=n[i];j--);
    if(s[j]>n[i])s[j]=n[i];
    if(j==r)r++;
  }
  return r-1;
}
int main(){
  int n,m,a[110][2],b[110][2],c[210],i,j,ar,br;
  while(scanf("%d",&n),n){
    for(i=ar=0;i<n;i++)scanf("%d %d",&a[i][0],&a[i][1]);
    scanf("%d",&m);
    for(i=br=0;i<m;i++)scanf("%d %d",&b[i][0],&b[i][1]);
    a[n][0]=b[m][0]=10000;
    for(i=0;i<n+m;i++){
      if     (a[ar][0]<b[br][0])c[i]=a[ar++][1];
      else if(a[ar][0]>b[br][0])c[i]=b[br++][1];
      else{
	if   (a[ar][1]<b[br][1])c[i]=b[br++][1];
	else                    c[i]=a[ar++][1]; 
      }
    }
    printf("%d\n",f(c,n+m,0,1000));
  }
  return 0;
}

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



int main() {
    ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
    srand(chrono::high_resolution_clock::now().time_since_epoch().count());

 string n;
  cin>>n;
  long long int res=0;
  long long int res1=0;
cout<<fixed<<setprecision(15);
  for(int i=0;i<n.length();i++){
      res = n[i] - 48;
		res1 += res;
      
  }
  if(res1%9==0 ){
      cout<<"Yes\n";
  }
  else{
      cout<<"No\n";
  }
    return 0;
}


Measured memory_bytes: 3752
#include <bits/stdc++.h>
#define FOR(i, begin, end) for(int i=(begin);i<(end);i++)
#define REP(i, n) FOR(i,0,n)
#define IFOR(i, begin, end) for(int i=(end)-1;i>=(begin);i--)
#define IREP(i, n) IFOR(i,0,n)
#define SORT(a) sort(a.begin(), a.end())
#define REVERSE(a) reverse(a.begin(), a.end())
#define Lower_bound(v, x) distance(v.begin(), lower_bound(v.begin(), v.end(), x))
#define Upper_bound(v, x) distance(v.begin(), upper_bound(v.begin(), v.end(), x))
#define int long long
#define INF 1000000000000000000
using namespace std;

#define ANS(f) if(f) cout << "YES" << endl; else cout << "NO" << endl;

typedef vector<int> vec;
typedef vector<vec> mat;
typedef pair<int, int> Pii;

template<typename T>
void readv(vector<T> &a){ REP(i, a.size()) cin >> a[i]; }
void readi(vector<int> &a){ REP(i, a.size()){cin >> a[i]; a[i]--;} }
void debug(mat m){REP(i, m.size()){ REP(j, m[0].size()){ cout << m[i][j] << ","; } cout << endl; }}



signed main(){

    int N, X; cin >> N >> X;
    vec P(N + 1);
    P[0] = 1;
    REP(i, N) P[i + 1] = 2 * P[i] + 1;
    vec T(N + 1);
    T[0] = 1;
    REP(i, N) T[i + 1] = 2 * T[i] + 3;

    int ans = 0;
    int x = X, n = N;
    while(x > 0){
        while(T[n] > x){
            n--;
            x--;
            if(x == 0){
                cout << ans;
                return 0;
            }
        }
        x -= T[n];
        ans += P[n];
        if(x >= 1){
            ans += 1;
            x--;
        }
    }
    cout << ans;
    
    return 0;
}

Measured memory_bytes: 256
import java.io.*;
  
public class Main {
        public static void main(String[] args) {
                BufferedReader reader = new BufferedReader(new InputStreamReader(System.in));
                try {
                        String line = reader.readLine();
                        int x = Integer.parseInt(line);
                        System.out.println(x * x * x);
                } catch (Exception e) {
                        e.printStackTrace();
                }
        }
}


Measured memory_bytes: 24324
import java.util.*;

public class Main {
  
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int max = 0;
    int sum = 0;
    for (int i = 0; i < N; i++) {
      int l = sc.nextInt();
      sum += l;
      if (max < l) {
        max = l;
      }
    }
    
    if (max < sum - max) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <string>
#include <numeric>
#include <iostream>
#include <cmath>
#include <algorithm>
#include <iomanip>
#include <queue>
#include <tuple>

#define rep(i,n) for(ll i=0;i<n;i++)
#define dup(x,y) (((x)+(y)-1)/(y)) // dup * y >= x なる最小のdup.
using namespace std;
typedef long long ll;
using Graph = vector<vector<ll>>;
//	std::cout<<std::fixed<<std::setprecision(10);

int main() {
	string S;
	cin >> S;
	int ans = 0;
	rep(i, S.size()/2) {
		if(S[i]!=S[S.size()-1-i]) ans++;
	}
	
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 256
unittest
{
	assert( [ "2 4" ].solve == 5 );
	assert( [ "123 456" ].solve == 435 );
	assert( [ "123456789012 123456789012" ].solve == 123456789012 );
	
	assert( [ "0 1000000000000" ].solve == 1000000000000 );		// 追加ケース
	assert( [ "2 1000000000000" ].solve == 1000000000001 );		// 追加ケース
}



import std.conv;
import std.format;
import std.range;
import std.stdio;

void main()
{
	stdin.byLineCopy.solve.writeln;
}

auto solve( Range )( Range input )
if( isInputRange!Range && is( ElementType!Range == string ) )
{
	auto a = 0L;
	auto b = 0L;
	input.front.formattedRead!"%s %s"( a, b );
	
	// 範囲[i..j](i<jかつi%4==3かつj%4==3）の累積xorは必ず0になるので、途中の計算を省略できる
	auto ans = 0L;
	foreach( i; a .. ( a + 3 ) / 4 * 4 )
	{
		ans ^= i;
	}
	foreach( i; b / 4 * 4 .. b + 1 )
	{
		ans ^= i;
	}
	return ans;
}


Measured memory_bytes: 2920
def mkou(A,B):
    x = A%B
    if  x== 0:
        return B
    else:
        return mkou(B,x)
        
def prime_F(k):
    a =[1,]
    end = int(pow(k,0.5))
    if k % 2 == 0:
        while k %2 == 0:
            k /=2
        a.append(2)
    k =int(k)

    for x in range(3,end,1):
        if k % x == 0:
            while k %x == 0:
                k/=x
            a.append(x)
            if k == 1:
                break
    if k != 1:
        a.append(k)
    return a
            
A,B = map(int,input().split())
divA_array = []
divB_array = []
if A<B:
    A,B =B,A

kouyaku = mkou(A,B)
soinsu =prime_F(kouyaku)
print(len(soinsu))


Measured memory_bytes: 3188
//65 - A 90 - Z 97 - a 122 - z
#include <bits/stdc++.h>
using namespace std;

typedef long long LL;

string s;
LL licz[1000];
LL cnt = 0;

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

    cin >> s;
    int n = s.size();
    for(int i = 0; i < n; i++)
    {
        cnt += (i - licz[s[i] - 'a']);
        licz[s[i] - 'a'] ++;
    }
    cnt ++;
    cout << cnt;
    return 0;
}


Measured memory_bytes: 720
//      https://youtu.be/X_hMZYDMps4

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

typedef long long ll;
typedef long double ld;
typedef long long unsigned llu;
typedef pair<long long, long long> pll;
const long long inf = 2000000000000000000LL;    // 2e18
#define pi                  acos(-1.0)
#define fast                ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0)
#define nl                  "\n"
#define ff                  first
#define ss                  second
#define pb                  push_back
#define pf                  push_front
#define all(x)              x.begin(),x.end()
#define debug(x)            cout<<"debug "<<x<<"\n"

int main()
{
    fast;
    ll t,i,j,k,l,m,n,o,p,q,temp,ans=0,flag=0,mod=1000000007,odd=0,even=0,a,b;
    string s;
    cin>>s;
    for(i=0,temp=0;i<s.size();i++){
        if(s[i]=='B') temp++;
        if(s[i]=='W') ans+=temp;
    }
    cout<<ans;
}


Measured memory_bytes: 3788
#include <bits/stdc++.h>
using intl = long long;
using ld = long double;
using namespace std;
#define rep(i, n) for(intl i = 0; i < (intl)(n); i++)
#define repd(i, n) for(intl i = (intl)(n); i >= 0; i--)
#define repi(i, a, b) for(intl i = (intl)(a); i < (intl)(b); i++)
#define repid(i, a, b) for(intl i = (intl)(a); i >= (intl)(b); i--)
#define max(a, b) ((a) > (b) ? (a) : (b))
#define min(a, b) ((a) < (b) ? (a) : (b))
#define all(x) (x).begin,(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define m1(x) memset(x,1,sizeof(x))
#define fill(x,y) memset(x,y,sizeof(x))
#define alength(a) (sizeof(a) / sizeof(a[0]))
#define cin(i, a) rep(i, alength(a))cin >> a[i]
#define ccin(i, j, a) rep(i, alength(a))rep(j, alength(a[i]))cin >> a[i][j]
#define debug(x) cout << #x << ":" << x << endl
#define rdebug(i,x) rep(i, alength(x))cout << #x << "[" << i << "]:" << x[i] << endl
#define sqrt sqrtl
#define int intl
#define itn intl
#define double ld
#define pb push_back
#define mp make_pair
const intl INF = 1e9;
const intl MOD = 1e9+7;
const ld eps = 1.0e-14;//-9
void fp(bool flag){
    if(flag)cout << "Yes" << endl;
    else cout << "No" << endl;
}
void fp(bool flag, string s, string t){
    if(flag)cout << s << endl;
    else cout << t << endl;
}
intl kai(intl k){
    intl a = 1;
    for(int i = 2; i <= k; i++){
        a *= i;
    }
    return a;
}
intl gcd(intl a, intl b){
    if(!b)return a;
    return gcd(b, a % b);
}
intl digit10(intl a){
    if(!a)return 1;
    intl b = 0;
    while(a){
        a /= 10;
        b++;
    }
    return b;
}
signed main(){
    cout << fixed << setprecision(10);
    intl a,b;
    cin >> a >> b;
    if((a == 1)||(b == 1)){
        if(a == b)cout << "Draw" << endl;
        else if(a < b)cout << "Alice" << endl;
        else if(a > b)cout << "Bob" << endl;
    }
    else if(a > b)cout << "Alice" << endl;
    else if(a < b)cout << "Bob" << endl;
    else cout << "Draw" << endl;
    return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
#include <cctype>
#include<math.h>
#include <iomanip>  
using namespace std;
int main() {
	int n, a[200000], cnt = 1, ans = 0;
	cin >> n;
	for (int i = 0; i < n; ++i)cin >> a[i];
	for (int i = 0; i < n; ++i) {
		if (a[i] == cnt) cnt = cnt + 1;
		else ans = ans + 1;
	}
	if (cnt == 1)ans = -1;
	cout << ans << endl;
	//cin >> n;
}

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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define debug(a) cerr << #a << ": " << a << endl
#define endl '\n'
#define int long long

const int N = 101;


int n, W;
int w[N], v[N];
int cache[101][100001];

int dp(int idx, int curr)
{
      if(curr<0) return -1e15;
      if(idx==n+1 || curr==0) return 0;

      int &res = cache[idx][curr];
      if(res != -1) return res;

      res = dp(idx+1, curr - w[idx]) + v[idx];
      res = max(res , dp(idx+1, curr));

      return  res;

}

int32_t main()
{
      IOS;

     cin>>n>>W;
     for(int i=1; i<=n; i++) cin>>w[i]>>v[i];

      memset(cache, -1, sizeof cache);
     int ans = dp(1, W);

     cout<<ans<<endl;


      return 0;
}


Measured memory_bytes: 79232
using Atcoder;
using System;
using System.Collections.Generic;
using System.ComponentModel.Design;
using System.Linq;
using System.Net;
using System.Text;
using System.Threading.Tasks;

namespace Atcoder
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var inputs = Console.ReadLine().Split(' ').Select(double.Parse).OrderBy(x => x).ToArray();
            double ret = inputs[0];
            for (int i = 1; i < N; i++)
            {
                ret = (ret + inputs[i]) / 2;
            }
            Console.WriteLine(ret);
        }
        //static void Main(string[] args)
        //{
        //    var temp = new Atcoder.ABC130.D();
        //    temp.Run();
        //}

    }
}

Measured memory_bytes: 13396
#include <cstdio>
#include <cstring>

using namespace std;

int a[50][50];
char s[20];

int main() {
    int n, i, j, k, l;
    long long ans = 0;
    
    scanf("%d", &n);
    
    for (i = 0; i < n; i++) {
        int m, c = -1, p = 0, q = 0;
        long long x = 0;
        
        scanf("%s", s);
        
        m = strlen(s);
        
        for (j = 0; j < m; j++) {
            if (s[j] == '.') {
                c = 0;
            } else {
                x *= 10;
                x += s[j] - '0';
                if (c >= 0) c++;
            }
        }
        
        if (c == -1) c = 0;
        
        while (c < 9) {
            x *= 10;
            c++;
        }
        
        while (x % 2 == 0) {
            x /= 2;
            p++;
        }
        
        while (x % 5 == 0) {
            x /= 5;
            q++;
        }
        
        a[p][q]++;
    }
    
    for (i = 0; i < 50; i++) {
        for (j = 0; j < 50; j++) {
            for (k = i; k < 50; k++) {
                for (l = 0; l < 50; l++) {
                    if (i == k && j > l) continue;
                    if (i + k >= 18 && j + l >= 18) {
                        if (i == k && j == l) {
                            ans += (long long)a[i][j] * (a[i][j] - 1) / 2;
                        } else {
                            ans += (long long)a[i][j] * a[k][l];
                        }
                    }
                }
            }
        }
    }
    
    printf("%lld\n", ans);
    
    return 0;
}


Measured memory_bytes: 1728
#include<iostream>
#include<cstdio>
#include<cmath>
#include<cstring>
#include<string>
#include<stack>
#include<queue>
#include<vector>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<set>
#include<unordered_set>
typedef long long int ll;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) for(int i=0;i<signed(n);i++)
#define EREP(i,n) for(int i=1;i<=signed(n);i++)
#define ALL(a) (a).begin(),(a).end()
using std::cout;
using std::vector;
using std::endl;
using std::cin;
using std::string;
using std::min;
using std::max;
//#define EVEL 1
#ifdef EVEL
#define DEB(X) cout << /*#X <<":" <<*/X<<" " ;
#define TF(f) f ? cout<<"true  " : cout<<"false ";
#define END cout<<"\n";
#else
#define DEB(X) {}
#define TF(f) {}
#define END {}
#endif
const ll MOD = 1000000007;
const ll INF = 9e9;
// typedef std::pair<int,int> P;
struct edge {int to,cost;};
#define VMAX 100000

ll N,K,ans=0;
ll A[2*100010],X[21];


int main(){
    std::ios_base::sync_with_stdio(false);
    cin>>N;
    REP(i,N)
        cin>>A[i];
    bool ch=true;
    int l=0,r=0;
    REP(i,20){
        if(A[0]&(1<<i))X[i]++;
    }
    while(ch){
        bool f=true;
        ch=false;
        REP(i,20)
            if(X[i]>1)f=false;
        if(!f){
            REP(i,20)
                if(A[l]&(1<<i))X[i]--;
            if(l!=N-1){
                if(l==r)r++;
                l++,ch=true;
            }
        }else{
            ans+=1+r-l;
            if(r!=N-1){
                r++;ch=true;
                REP(i,20)
                    if(A[r]&(1<<i))X[i]++;
            }
        }
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
    ios_base:: sync_with_stdio(false);
    cin.tie(NULL); cout.tie(NULL);
    string s;cin>>s;
    if(s[0]==s[1] && s[1]==s[2])return cout<<"Yes" ,0 ;
    if(s[1]==s[2] && s[2]==s[3])return cout<<"Yes" , 0;
    cout<<"No";
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int a, b, n;
  int ans = 0;
  int v[5];
  cin >> a >> b;
  n = a;

  while (a <= b) {
    for (int i = 0; i < 5; i++){
      v[i] = n % 10;
      n /= 10;
    }
    if (v[0] == v[4] && v[1] == v[3]) {
      ans++;
    }   
    a++;
    n = a;
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
/* it was worth becoming a chemist */
#include <bits/stdc++.h>

using namespace std;

typedef long long ll;
typedef double db;
typedef long double ld;
typedef unsigned int uni;
typedef unsigned long long unll;
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
typedef pair<long long, int> pli;
typedef pair<int, long long> pil;
typedef vector<int> vi;
typedef vector<long long> vll;

#define mp make_pair
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define sz(x) (int)x.size()
#define NAME "puts"
#define F first
#define S second

const ll INF = 1e18;
const int inf = 1e9;
const int mod = 1e9 + 7;
const db EPS = (db) 1e-9;
const db pi = acos(-1.0);
const int MAXN = 1e6 + 5;                  

int n, m;
int ct[MAXN];
bool r[MAXN];   


int main() {
    
    cin >> n >> m;
    r[1] = 1;
    for (int i = 1; i <= n; i++) {
    	ct[i] = 1;
    }
    for (int i = 1; i <= m; i++) {
    	int x, y;
    	cin >> x >> y;
    	if (r[x]) {
    		ct[x]--;
    		r[y] = 1;
    	    ct[y]++;
    		if (ct[x] == 0) r[x] = 0;
    	}
    	else {
    		ct[x]--;
    		ct[y]++;
    	}
    }
    int res = 0;
	for (int i = 1; i <= n; i++) {
		if (r[i]) res++;
	}
	cout << res;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
#define PB push_back
#define MP make_pair
#define F first
#define S second
#define MOD	1000000007
#define int	long long
#define pii pair<int,int> 
#define vi vector<int>
using namespace std;

int modpow(int a, int b, int mod){
	int res = 1;
	a %= mod;
	while(b > 0){
		if(b&1)
			res = (res*a)%mod;
		a = (a*a)%mod;
		b >>= 1;
	}
	return res;
}

int modinv(int a){
	return modpow(a,MOD-2,MOD);
}

int32_t main(){
	int n, a, b;
	cin >> n >> a >> b;
	
	int p = (modpow(2,n,MOD) - 1 + MOD) % MOD;
	
	a = max(a,n-a);
	b = max(b,n-b);
	
	int q = 1;
	for(int i = n; i >= a+1; i--){
		q = (q*i) % MOD;
	}
	int temp = 1;
	for(int i = 1; i <= n - a; i++)
		temp = (temp * i) % MOD;
		
	q = q * modinv(temp);
	
	int r = 1;
	for(int i = n; i >= b+1; i--){
		r = (r*i) % MOD;
	}
	temp = 1;
	for(int i = 1; i <= n - b; i++)
		temp = (temp * i) % MOD;
		
	r = r * modinv(temp);
	
	
	
	int ans = (p - q - r) % MOD;
	if(ans < 0)
		ans += MOD;
		
	cout << ans << endl;
	
	
	return 0;
}



Measured memory_bytes: 256
const lines = require('fs')
  .readFileSync('/dev/stdin', 'utf8')
  .trim()
  .split('\n')

const monsters = lines[1].split(' ').map(n => Number.parseInt(n))
const bravers = lines[2].split(' ').map(n => Number.parseInt(n))

const killed = bravers.reduce((prev, x, i) => {
  const n = Math.min(x, monsters[i])
  x -= n
  monsters[i] -= n

  const m = Math.min(x, monsters[i + 1])
  monsters[i + 1] -= m
  return prev + n + m
}, 0)

console.log(killed)


Measured memory_bytes: 32812
#include <bits/stdc++.h>
using namespace std;
#define endl '\n'
#define pi pair<int,int>
#define ff firs
#define ss second
#define boost ios::sync_with_stdio(false);cin.tie(nullptr)
#include "string"
#define int long long

int32_t main() { 
	boost;
   int a;
   double b;
   cin>>a>>b;
   int c = round(b*100);
   int ans = a*c;
   ans /= 100;
   cout<<ans<<endl;
}

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

typedef long long ll;
#define Max 200020
ll V[Max];
int main(){
	ll ans=0;
	int N; cin>>N;
	map<ll,ll> M;
	M[0]=1;
	for(int i=1;i<=N;i++){
		cin>>V[i];
		V[i]=V[i]+V[i-1];
		ans=ans+M[V[i]];
		M[V[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 14336
#include<iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<set>
#include<map>
#include<queue>
#include<cmath>
#define REP(i,a) for (int i = 0;i < (a);++i)
#define FOR(i,a,b) for (int i = (a);i < (b); ++i)
#define FORR(i,a,b) for (int i = (a);i >= (b); --i)
#define ALL(obj) (obj).begin(),(obj).end()
#define SORT(list) sort(ALL((list)));
#define MOD 1000000007
using namespace std;
using ll = long long;
int main(){
    int n,d;
    cin >> n >> d;
    int answer = 0;
    answer = n/(2*d+1);
    if(n%(2*d+1))answer++;
    cout << answer << endl;
    
    return 0;
}

Measured memory_bytes: 3616
#include <bits/stdc++.h> 
using namespace std;
 
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}
 
 
//typedef
//------------------------------------------
typedef pair<int, int> PII;
typedef long long LL;
typedef pair<long, long> PLL;
 
//container util
//------------------------------------------
#define PB emplace_back
#define MP make_pair 
#define SZ(a) int((a).size())
//repetition
//------------------------------------------
#define FOR(i,a,b) for(LL i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SORT(c) sort((c).begin(),(c).end())
#define ALL(a)  (a).begin(),(a).end()
//constant
//--------------------------------------------
//clear memory
#define CLR(a) memset((a), 0 ,sizeof(a))

const LL MOD=1e9+7;


struct UnionFind
{
    vector<int> par;
    vector<int> sizes;
    vector<int> rnk;
    UnionFind(){}
    UnionFind(int n){
        par.resize(n);rnk.resize(n,0);
        sizes.resize(n, 1);
        REP(i,n) par[i] = i;
    }

    int find(int x) {
        if (x == par[x]) return x;
        return par[x] = find(par[x]);
    }

    void unite(int x, int y) {
        x = find(x);
        y = find(y);
        if(x==y)return;
        if(rnk[x]<rnk[y]){
            par[x]=y;
            sizes[y]+=sizes[x];
        }else{
            par[y]=x;
            sizes[x]+=sizes[y];
            if(rnk[x]==rnk[y])rnk[x]++;
        }
    }

    bool same(int x, int y) {
        return find(x) == find(y);
    }
    int size(int x) {
        return sizes[find(x)];
    }
};

int main(){
    int N,M;
    cin>>N>>M;
    UnionFind uf(N);
    REP(i,M){
        int X,Y,Z;
        cin>>X>>Y>>Z;
        X--;Y--;uf.unite(X,Y);
    }
    set<int> st;
    REP(i,N)st.insert(uf.find(i));
    cout<<SZ(st)<<endl;
    return 0;
}

Measured memory_bytes: 6144
#include <stdio.h>
#include <string.h>

int main(void) {
  int n, pt = 0, ph = 0;
  char s[101], t[101];

  scanf("%d", &n);

  while (n --> 0) {
    scanf("%s %s", s, t);

    if (strcmp(s, t) > 0) {
      pt += 3;
    } else if (strcmp(s, t) < 0) {
      ph += 3;
    } else {
      pt++;
      ph++;
    }
  }

  printf("%d %d\n", pt, ph);

  return 0;
}

Measured memory_bytes: 604
#include <stdio.h>

int main(){
  int W,H,x,y,r;
  scanf("%d %d %d %d %d",&W,&H,&x,&y,&r);
  if(x<=0||y<=0){
    printf("No\n");
    return 0;
  }
  if(x+r>W||y+r>H){
    printf("No\n");
    return 0;
  }else{
    printf("Yes\n");
    return 0;
  }
}



Measured memory_bytes: 2680
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
long long a[2000], n, cnt, mod = 1000000007;
int main() {
	cin >> n; cnt = 1;
	for (int i = 1; i <= n; i++) {
		int p = i;
		for (int j = 2; j <= n; j++) {
			while (p%j == 0) { p /= j; a[j]++; }
		}
	}
	for (int i = 1; i <= n; i++) { cnt *= (a[i] + 1); cnt %= mod; }
	cout << cnt << endl;
	return 0;
}


Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<algorithm>
#include<cmath>
#include<cstring>
#include<string>
#include<iostream>
#include<map>
using namespace std;
int a[15];
int main(){
	int ans,n,k;
	bool vis;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=k;i++) scanf("%d",&a[i]);
	for(int i=n;;i++){
		vis=0;
		ans=0;
		for(int x=1;x<=k;x++){
			vis=0;
			if(i/10==0){
				if(i%10!=a[x]){
					vis=1;
					ans++;
				}
				else break;
			}
			else if(i/100==0){
				if(i%10!=a[x]&&i/10%10!=a[x]){
					vis=1;
					ans++;
				}
				else break;
			}
			else if(i/1000==0){
				if(i%10!=a[x]&&i/10%10!=a[x]&&i/100%10!=a[x]){
					vis=1;
					ans++;
				}
				else break;
			}
			else if(i/10000==0){
				if(i%10!=a[x]&&i/10%10!=a[x]&&i/100%10!=a[x]&&i/1000%10!=a[x]){
					vis=1;
					ans++;
				}
				else break;
			}
			else if(i/100000==0){
				if(i%10!=a[x]&&i/10%10!=a[x]&&i/100%10!=a[x]&&i/1000%10!=a[x]&&i/10000%10!=a[x]){
					vis=1;
					ans++;
				}
				else break;
			}
		}
		if(ans==k){
			printf("%d\n",i);
			break;
		}
	}
}

Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <algorithm>
#include <bitset>
#include <iomanip>
#include <cstdio>
#include <new>
#include <vector>
#include <cstdlib>
#include <string>
#include <set>
#include <tuple>
#include<map>

using namespace std;
int main() {
	int x;
	cin >> x;

	if (x < 1200) cout << "ABC" << endl;
	else cout << "ARC" << endl;
	
}

Measured memory_bytes: 3596
#include <bits/stdc++.h>
using namespace std;
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; }
using ll = long long;
using P = pair<ll, ll>;
const long double PI = acos(-1.0L);
ll GCD(ll a, ll b) { return b?GCD(b, a%b):a; }
ll LCM(ll a, ll b) { return a/GCD(a, b)*b; }

int t;
struct numdata {
    int no; ll value;
};

ll f(vector<numdata> &xvec) {
    int xlen = xvec.size();
    for(int i = 0; i < xlen; ++i) {
        xvec.at(i).no = min(xvec.at(i).no, xlen);
    }
    vector< vector<ll> > smap(xlen+1);
    for(int i = 0; i < xlen; ++i) {
        smap.at(xvec.at(i).no).emplace_back(xvec.at(i).value);
    }

    ll ret = 0;
    priority_queue<ll> pque;
    for(int i = xlen; i >= 1; --i) {
        for(auto x : smap[i]) pque.push(x);
        if(!pque.empty()) {
            ret += pque.top();
            pque.pop();
        }
    }
    return ret;
}

int main() {
    cin >> t;
    while(t--) {
        int n; cin >> n;
        ll ans = 0;
        vector<numdata> lvec;
        vector<numdata> rvec;
        for(int i = 0; i < n; ++i) {
            int k; ll l, r;
            cin >> k >> l >> r;
            ll m = min(l, r);
            ans += m;
            l -= m; r -= m;
            if(l > 0) lvec.emplace_back(numdata{k, l});
            else rvec.emplace_back(numdata{n-k, r});
        }
        ans += f(lvec);
        ans += f(rvec);
        cout << ans << endl;
    }
}

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

int main() {
 
  vector<char> num(4);
  //int sum = 0;
  for(int i = 0; i < 4; i++) {
    cin >> num.at(i);
    //sum += num.at(i);
    //cout << num.at(i) << endl;
  }
  //cout << sum-192 << endl;
  
  if(num.at(0) + num.at(1) + num.at(2) + num.at(3) - 192 == 7)
    cout << num.at(0) << '+' << num.at(1) << '+' << num.at(2) << '+' << num.at(3) << "=7" << endl;
  
  else if(num.at(0) + num.at(1) + num.at(2) - num.at(3) - 96 == 7)
    cout << num.at(0) << '+' << num.at(1) << '+' << num.at(2) << '-' << num.at(3) << "=7" << endl;
  
  else if(num.at(0) + num.at(1) - num.at(2) + num.at(3) - 96 == 7)
    cout << num.at(0) << '+' << num.at(1) << '-' << num.at(2) << '+' << num.at(3) << "=7" << endl;
  
  else if(num.at(0) - num.at(1) + num.at(2) + num.at(3) - 96 == 7)
    cout << num.at(0) << '-' << num.at(1) << '+' << num.at(2) << '+' << num.at(3) << "=7" << endl;

  else if(num.at(0) + num.at(1) - num.at(2) - num.at(3) == 7)
    cout << num.at(0) << '+' << num.at(1) << '-' << num.at(2) << '-' << num.at(3) << "=7" << endl;
  
  else if(num.at(0) - num.at(1) + num.at(2) - num.at(3) == 7)
    cout << num.at(0) << '-' << num.at(1) << '+' << num.at(2) << '-' << num.at(3) << "=7" << endl;

  else if(num.at(0) - num.at(1) - num.at(2) + num.at(3) == 7)
    cout << num.at(0) << '-' << num.at(1) << '-' << num.at(2) << '+' << num.at(3) << "=7" << endl;

  else if(num.at(0) - num.at(1) - num.at(2) - num.at(3) + 48 == 7)
    cout << num.at(0) << '-' << num.at(1) << '-' << num.at(2) << '-' << num.at(3) << "=7" << endl;
}

Measured memory_bytes: 256
#include <stdio.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
//1232
int a,b,c,n,m,l[100000110],o[100010],k,i,d,dx[10]={0,1,-1,0,0,-1,-1,1,1},dy[10]={0,0,0,-1,1,1,-1,1,-1};
long long x,y,z[100010];
stack<int> s;
struct P
{
    int x;
    int y;
    bool operator<(const P &a)const
    {
        return y>a.y;
    }
};
 //map<int, int> p;
queue<P> q;
priority_queue<int> q1;
string r;
vector<int> v[200010];

bool sdf(P a,P b){return a.y<b.y;}



int main()
{
    scanf("%d",&a);
    for(int t=1;t<=a;t++)
    {
        scanf("%d",&b);
        k=max(k,b);
        if(!o[b]) o[b]=1,c++;
        else o[b]++;
    }
    for(int t=1;t<=k;t++)
        if(o[t]%2==0&&o[t]) i++;

    printf("%d",c-(i%2));
    return 0;
}

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

int main(void) {
    int k, s, ans = 0;
    cin >> k >> s;
    for (int i = 0; i <= k; i++) {
        for (int j = 0; j <= k; j++) {
            if (i + j <= s && s - i - j <= k) {
                ++ans;
            }
        }
    }
    cout << ans << "\n";
}


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

#define whole(f,x,...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x)
#define REP(i, n) for(int i = 0;i < n;++i)
#define REPR(i, n) for(int i = n;i >= 0;--i)
#define FOR(i, a, b) for(int i = a;i < b;++i)
#define ALL(x) (x).begin(),(x).end()
#define INF 999999999
using namespace std;
#define lint long long

int main()
{
  lint N,A,B;
  lint out =0;
  cin >> N >> A >> B;;
  //string S;
  //cin >> S;
  //vector<int> a(N);
  lint AB = A+B;
  lint NAB = N/AB;
  lint NAB2 = N%AB;
  out = A*NAB;
  if(NAB2 > A){
    out += A;
  }else{
   out += NAB2; 
  }
  cout << out;
  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define exrep(i, a, b) for(long long i = a; i <= b; i++)
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
using namespace std;
typedef unsigned long long ull;
typedef long long ll;
typedef long double ld;
typedef pair<ll, ll> P;
typedef vector<ll> vl;
typedef vector<string> vs;
typedef vector<P> vp;
typedef vector<vector<ll> > vvl;
typedef vector<vector<P> > vvp;
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; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};

int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  ll x;
  cin >> x;
  exrep(a,-300,300){
    exrep(b,-300,300){
      if(pow(a,5)-pow(b,5)==x){
        cout << a << " " << b << endl;
        return 0;
      }
    }
  }
  return 0;     
}


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

int cost[100][100];
int mincost[100];
bool used[100];

int main() {
	int n, m;
	while (scanf("%d%d", &n, &m), n) {
		memset(cost, 0x3f, sizeof(cost));
		rep(i, m) {
			int a, b, c; scanf("%d%d%d", &a, &b, &c);
			cost[a][b] = c; cost[b][a] = c;
		}
		memset(mincost, 0x3f, sizeof(mincost));
		memset(used, 0, sizeof(used));
		mincost[0] = 0;
		int ans = 0;
		while (true) {
			int v = -1;
			rep(i, n) {
				if (!used[i] && (v == -1 || mincost[i] < mincost[v]))
					v = i;
			}
			if (v == -1)break;
			used[v] = true;
			ans += mincost[v];
			rep(i, n)mincost[i] = min(mincost[i], cost[v][i]);
		}
		printf("%d\n", ans);
	}
}

Measured memory_bytes: 3164
/*
How to lambda
  ex) sort(ALL(cont),[](dat a,dat b){return a.l<b.l;});
lower_bound/upper_bound
  1 2 2 2 3 3 
    ^lb   ^ub */
#include <algorithm>
#include <cstdio>
#include <cstdlib>
#define BR "\n"
#define REP(i,n) for(int (i)=0;(i)<(n);++(i))
#define ALL(cont) begin(cont),end(cont)
#define AS_MOD(a,b) ((((a) % (b) ) + (b)) % (b))
#define FEACH(it,cont) for(auto (it) = begin(cont); it!=end(cont);++it)
#define FEACHR(it,cont) for(auto (it) = rbegin(cont); it!=rend(cont);++it)
#define pb push_back
#define pob pop_back
#define fi first
#define se second
#define getll() ([](){ll s;scanf("%lld", &s);return s;})()
#define getld() ([](){ld s;scanf("%Lf", &s);return s;})()
#define prl(P) printf("%lld", P)
#define prd(P) printf("%.10Lf", P)
#define pr(P) printf(P)
#define assign_if_greater(V, T) V=max(V,T)
using namespace std;
typedef long long ll;
typedef long double ld;
int A,B,Q;
ll As[100000];
ll Bs[100000];
ll INF=(ll)1000*1000*1000*1000;
int main() {

  scanf("%d%d%d", &A, &B, &Q);
  REP(i,A)
    As[i]=getll();
  REP(i,B)
    Bs[i]=getll();
  REP(i,Q) {
    ll x;
    scanf("%lld", &x);
    ll* ita=lower_bound(As, As+A, x);
    ll* itb=lower_bound(Bs, Bs+B, x);
    ll ans=INF;
    ll alis[2],blis[2];
    alis[0]=ita!=As+A?*ita:INF;
    blis[0]=itb!=Bs+B?*itb:INF;
    alis[1]=ita!=As?ita[-1]:-INF;
    blis[1]=itb!=Bs?itb[-1]:-INF;
    for(ll a:alis)
      for(ll b:blis) {
        ans = min(ans,abs(a-x)+abs(b-a));
        ans = min(ans,abs(b-x)+abs(b-a));
      }
    printf("%lld\n",ans);
  }


  return 0;
}


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

namespace _2001
{
    public class pairint
    {
        public int a;
        public int b;
    }
    class Program
    {
        static void Main(string[] args)
        {
            while (true)
            {
                int[] x = Console.ReadLine().Split().Select(int.Parse).ToArray();
                if (x.Max() == 0) break;
                int[] high = new int[x[1]]; pairint[] line = new pairint[x[1]];
                for (int i = 0; i < x[1]; i++)
                {
                    int[] a = Console.ReadLine().Split().Select(int.Parse).ToArray();
                    high[i] = 1000 - a[0];
                    line[i] = new pairint
                    {
                        a = a[1],
                        b = a[2],
                    };
                }
                Array.Sort(high,line);
                int ret = x[2];
                for (int i = 0; i < x[1]; i++)
                {
                    if (line[i].a == ret) ret = line[i].b;
                    else if (line[i].b == ret) ret = line[i].a;
                }
                Console.WriteLine(ret);
            }
        }
    }
}


Measured memory_bytes: 9940
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <cmath>

#define rep(i,n) for (int i=0; i < (n); ++i)
using namespace std;
using ll = long long ;
const int INF = 1001001001;
using namespace std;

int main() {

    string s ;
    cin >> s ;

    int ans = 0 ;
    rep(i,3){
        if(s[i]=='R'){
            ans+=1 ;
    }
    }

    if(ans==2){
        if(s[1]!='R'){
            ans = 1 ;
        }
    }

    cout << ans << endl ;



    return 0 ;
}

Measured memory_bytes: 3588
#include <bits/stdc++.h>
using namespace std;
#define REP(i, n) for (int i = 0; i < (int)(n); i++)
#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
typedef long long ll;
typedef pair<int, int> P;
const int INF = 100100100;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-9;
int main() {
  ll H, W;
  cin >> H >> W;
  ll mn = INF * 1e+2;
  for (int i = 1; i <= H / 2; i++) {
    vector<ll> A(3);
    A[0] = i * W;
    A[1] = (H -i)/ 2;
    A[2] = (H - i - A[1]);
    if (A[2] == 0) A[2] = INF;
    A[2] *= W;
    A[1] *= W;
    sort(A.begin(), A.end());
    if (0 < A[0]) {
      mn = min(mn, A[2] - A[0]);
    }
    A[0] = i * W;
    A[1] = W / 2;
    A[2] = (W - A[1]);
    if (A[2] == 0) A[2] = INF;
    A[2]*=(H-i);
    A[1] *=(H-i);
    sort(A.begin(), A.end());
    if (0 <= A[0]) {
      mn = min(mn, A[2] - A[0]);
    }
  }
  for (int i = 1; i <= W / 2; i++) {
    vector<ll> A(3);
    A[0] = i * H;
    A[1] = H / 2;
    A[2] = H - A[1];
    if (A[2] == 0) A[2] = INF;
    A[1] *= (W - i);
    A[2] *= (W - i);
    sort(A.begin(), A.end());
    if (0 <= A[0]) {
      mn = min(mn, A[2] - A[0]);
    }
    A[0] = i * H;
    A[1] = (W - i) / 2;
    A[2] = W- i - A[1];
    if (A[2] == 0) A[2] = INF;
    A[1] *= H;
    A[2] *= H;
    sort(A.begin(), A.end());
    if (0 <= A[0]) {
      mn = min(mn, A[2] - A[0]);
    }
  }
  cout << mn << endl;
}

Measured memory_bytes: 256
N,K=map(x->parse(Int,x),split(readline()))
if N==1
	if K==0
		println("1 1 0 0")
	else
		println(-1)
	end
elseif K>=1<<N
	println(-1)
else
	for i=0:(1<<N)-1
		if i!=K
			println(i)
		end
	end
	println(K)
	for i=(1<<N)-1:-1:0
		if i!=K
			println(i)
		end
	end
	println(K)
end


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

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

int main()
{
    int N, M;
    cin >> N >> M;
    vector<int> start(N), goal(N);
    rep(i, M){
        int a, b;
        cin >> a >> b;
        if(a == 1){
            start.at(b)++;
        }else if(b == N){
            goal.at(a)++;
        }
    }

    rep(i, N){
        if(start.at(i) > 0){
            if(goal.at(i) > 0){
                cout << "POSSIBLE" << endl;
                return 0;
            }
        }
    }

    cout << "IMPOSSIBLE" << endl;
}



Measured memory_bytes: 1792
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <cmath>
#include <vector>
#include <queue>
#include <functional>
#include <cassert>
#include <cctype>
#include <string>
#include <sstream>
#include <bitset>
using namespace std;
typedef long long int LL;
const int MAXN = 200 + 24;
int cost[10][10], num[MAXN][MAXN], dist[10], dis[10];
bool vis[10];
void dij(int st) {
	memset(vis, false, sizeof(vis));
	memset(dis, 0x3f3f3f3f, sizeof(dis));
	dis[st] = 0;
	for (int i = 0; i < 10; i++) {
		int u, mindis = 0x3f3f3f3f;
		for (int j = 0; j < 10; j++) {
			if (dis[j] < mindis && vis[j]==false) {
				mindis = dis[j]; u = j;
			}
		}
		vis[u] = true;
		for (int j = 0; j < 10; j++) {
			if (dis[j] > dis[u] + cost[u][j]) {
				dis[j] = dis[u] + cost[u][j];
			}
		}
	}
	dist[st] = dis[1];
}
int main() {
#ifdef kirito
	freopen("in.txt", "r", stdin);
	freopen("out.txt", "w", stdout);
#endif // kirito
	int n,m;
	while (~scanf("%d%d", &n,&m)) {
		for (int i = 0; i < 10; i++) {
			for (int j = 0; j < 10; j++) {
				scanf("%d", &cost[i][j]);
			}
		}
		for (int i = 0; i < 10; i++) {
			dij(i);
		}
		LL res = 0;
		for (int i = 0; i < n; i++) {
			for (int j = 0; j < m; j++) {
				scanf("%d", &num[i][j]);
				if (num[i][j] != -1) {
					res += dist[num[i][j]];
				}
			}
		}
		cout << res << endl;
		
	}
	return 0;
}

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<functional>
#include<algorithm>
#include<string>
#include<map>
#include<queue>

using namespace std;

int main(void){

    int a, b, c, d;
    cin >> a >> b >> c >> d;

    if((abs(c - b) <= d && abs(b - a) <= d) || abs(a - c) <= d) cout << "Yes" << endl;
    else cout << "No" << endl;

    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
  int k,t;
  cin >> k >> t;
  int a;
  vector<pair<int,int> >p(t);
  int i;
  for(i=0;i<t;i++){
    cin >> a;
    p[i] = make_pair(a,i);
  }
  sort(p.begin(),p.end(),greater<pair<int,int> >());
  int tmp = -1;
  if(t==1)cout << k-1 << endl;
  else{
    while(k>0){
      if(p[0].second != tmp){
        tmp = p[0].second;
        p[0].first--;
        k--;
      }else if(p[1].first>0){
        tmp = p[1].second;
        p[1].first--;
        k--;
      }else break;
      sort(p.begin(),p.end(),greater<pair<int,int> >());
    }
    cout << k << endl;;
  }
}


Measured memory_bytes: 256
/******************************************
* NICK : nikhilsinghh59 *
******************************************/
#include<bits/stdc++.h>
using namespace std;
#define ll long long int 
#define watch(x) cout << (#x) << " is " << (x) << endl
#define endl "\n"

#define PB push_back
#define F first
#define S second
#define all(c) (c).begin(),(c).end()
const int M = (1e9+7);

int main()
{   
    #ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
    #endif

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

    ll mn_sum[n+1] = {0} , mx_sum[n+1]={0};
    mn_sum[0]=0;
    mx_sum[0]=n;
    for(ll i=1 ; i<n ; i++) {
        mn_sum[i] = (i + mn_sum[i-1]);
        mx_sum[i] = (n-i + mx_sum[i-1]);
    }

    ll ans = (mx_sum[k-1] - mn_sum[k-1] + 1)%M;
    //cout << ans << endl;

    for(ll i=k ; i<=n;i++){
        ll add = (mx_sum[i] - mn_sum[i] + 1);
        ll sub=0;
        if(i) {
            if(mx_sum[i-1] > mn_sum[i]) {
                sub = mx_sum[i-1] - mn_sum[i] + 1;
            }
        }
        ans+=(add)%M;
        ans%=M;
        //ans += (mx_sum[i] - mn_sum[i] + 1 - (i ? ((mx_sum[i-1] - mn_sum[i])>0 ? (mx_sum[i-1]-mn_sum[i]) : 0) : 0))%M;
        //ans -= (mx_sum[i-1] - mn_sum)
    }

    cout << ans << endl;
    
    return 0;
}

Measured memory_bytes: 6664
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
    int A, B, C;
    cin >> A >> B >> C;
    if (A + B + C >= 22) {
        cout << "bust"
             << "\n";
    } else {
        cout << "win"
             << "\n";
    }
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <cmath>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

int dx4[4] = { 0, -1, 1, 0 };
int dy4[4] = { -1, 0, 0, 1 };
int dx8[8] = { 0, -1, 1, 0, -1, 1, -1, 1 };
int dy8[8] = { -1, 0, 0, 1, -1, -1, 1, 1 };

int main() {
  int x;
  cin >> x;
  if (x == 7 || x == 5 || x == 3) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<algorithm>
#include<string>
#include<cmath>
#include<set>

using namespace std;

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

	if (S.substr(0, 4) == "YAKI") {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

}






Measured memory_bytes: 3536
#include <stdio.h>

double qidaizhi(int a){
    double sum=0;
    for(int i=1;i<=a;i++){
        sum+=i;
    }
    return sum/a;
}

int main()
{
    int N,K;
    double max,sum=0;
    scanf("%d%d",&N,&K);
    int p[N];
    for(int i=0;i<N;i++){
        scanf("%d",&p[i]);
    }

    int head=K-1,tail=0;
    for(int i=0;i<K;i++){
        sum+=qidaizhi(p[i]);
    }
    max=sum;

    while(head!=N-1){
        head++;
        sum=sum+qidaizhi(p[head])-qidaizhi(p[tail]);
        tail++;
        if(sum>max) max=sum;
    }

    printf("%f",max);

    return 0;
}

Measured memory_bytes: 896
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vll;
typedef pair<ll, ll> pll;
typedef vector<pll> vpll;
typedef string str;
static const long long INF = INT64_MAX;
static const long long MOD = (ll)1e9+7;

#define endl "\n"
#define fast_io ios_base::sync_with_stdio(false);cin.tie(NULL)
#define REP(i, n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)((v).size())
#define WHOLE(v) (v).begin(), (v).end()
#define ASC(v) sort((v).begin(), (v).end())
#define DESC(v) sort((v).rbegin(), (v).rend())
#define INV(v) reverse((v).begin(), (v).end())
#define FOLDL(src, dst, lambda) partial_sum((src).begin(), (src).end(), (dst).begin(), lambda)
#define FOLDR(src, dst, lambda) INV(src);partial_sum((src).begin(), (src).end(), (dst).begin(), lambda);INV(dst)
#define CUMSUML(src, dst) FOLDL(src, dst, [](auto a, auto b) {return a+b;})
#define CUMSUMR(src, dst) FOLDR(src, dst, [](auto a, auto b) {return a+b;})
#define ACCUM(v, d0, lambda) accumulate((v).begin(), (v).end(), d0, lambda)
#define SUM(v, d0) ACCUM(v, d0, [](auto a, auto b) {return a+b;})
#define ERASE(v, i) v.erase(v.begin() + i)
#define UNIQ(v) ASC(v);v.erase(unique(v.begin(), v.end()), v.end())

template <typename T>void debug(T t) {cerr << t << endl;}
template <typename T, typename ...Args>void debug(T t, Args ...args) {cerr << t << " ";debug(args...);}
template <typename T>void out(T t) {cout << t << endl;}
template <typename T, typename ...Args>void out(T t, Args ...args) {cout << t << " ";out(args...);}

// size-base union-find
class UF {
public:
    ll node_size;
    vll siz;
    vll par;
    UF(ll sz) : par(sz), siz(sz, 1LL) {
        REP(i, sz) par[i] = i;
        node_size = sz;
    }
    // 再初期化
    void initialize(ll sz) {
        par.resize(sz);
        siz.assign(sz, 1LL);
        REP(i, sz) par[i] = i;
        node_size = sz;
    }
    ll root(ll x) {
        while(par[x] != x) {
            x = par[x] = par[par[x]];
        }
        return x;
    }
    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if(x == y) return false;
        if(siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }
    bool find(ll x, ll y) {
        return root(x) == root(y);
    }
    ll size(ll x) {
        return siz[root(x)];
    }
    map<ll, ll> islands() {
        set<ll> st;
        REP(i, node_size) {
            st.insert(root(i));
        }
        map<ll, ll> ret;
        for(auto &s:st) {
            ret[s] = size(s);
        }
        return ret;
    }
};

void solve() {
    ll N, M;
    cin >> N >> M;
    UF uf(N);
    REP(i, M) {
        ll x, y, z;
        cin >> x >> y >> z;
        uf.unite(x - 1, y - 1);
    }
    out(uf.islands().size());
}

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


Measured memory_bytes: 12800