akhauriyash/Code-Regression huggingface dataset:
#define N 2000
int solve(int , int);
int A[N], M[N];
  int i, j, n, q, m;
int main()
{
 
  scanf("%d",&n);
 
  for(i = 0 ; i < n ; i++)
    {
      scanf("%d",&A[i]);
    }
 
  scanf("%d",&q);
  for(i = 0 ; i < q ; i++)
    {
      scanf("%d",&M[i]);
    }
 
  for(i = 0 ; i < q ; i++)
    {
      j = 0;
      if(solve(j, M[i])==1)
    {
      printf("yes\n");
    }else if(solve(j, M[i])==0){
    printf("no\n");
    }
    }
  
 
  return 0;
}
 
 
int solve(int i, int m)
{
  int res;
  if(m==0) return 1;
 
  if(i>=n) return 0;
  res = solve(i + 1, m) || solve(i + 1, m - A[i]);
 
   
}

Measured memory_bytes: 588
#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);
	int x;
	cin>>x;
	if(x>=30)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


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

int main(int argc, char const *argv[]) {
    int W, H, x, y, r;
    cin >> W >> H >> x >> y >> r;

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



Measured memory_bytes: 3100
#define _GLIBCXX_DEBUG//実行時、何も出なかったらこれを使う
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<cmath>
#include<queue>
#include<stack>
#include<map>
#include<numeric>
#include<climits>
#include<limits>//
#include <stdio.h>//
#include<cmath>
#include<iomanip>

using namespace std;

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

typedef long long ll;

template <class A, class B> inline bool chmax(A &a, const B &b) { return b > a && (a = b, true); }
template <class A, class B> inline bool chmin(A &a, const B &b) { return b < a && (a = b, true); }

int dy[] = {1,0}; //次に行くところ
int dx[] = {0,1}; //s上に同じ

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

  //l1,q9,0o,b6
  
  int ans = INT_MAX,n,m;
  string s,t;
  cin >> s >> t;
  n = s.size();
  m = t.size();

  for (int i = 0; i < n; i++){
    int cnt = 0;
    for (int j = 0; j < m; j++){
      if (n - i < m){
        cnt = INT_MAX;
        break;
      }

      if (s[i+j] != t[j]){
        cnt++;
      }
    }
    chmin(ans,cnt);
  }
  
  cout << ans << '\n';
                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                    
  return 0;
}

Measured memory_bytes: 3664
#pragma GCC optimize ("O3")
#include <bits/stdc++.h>
#define abdelrahman001 ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define F first
#define S second
#define inFile(t) freopen((t),"r",stdin)
#define outFile(t) freopen((t),"w",stdout)
#define pb push_back
#define pf push_front
#define Pb pop_back
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define Pf pop_front
#define sz size
#define MP make_pair
#define Pc __builtin_popcount
#define pi 2*acos(0)
#define BiEdge(v,a,b) (v)[(a)].pb(b),(v)[(b)].pb(a)
#define mod 1000000007
#define point complex<ld>
#define X real()
#define Y imag()
#define pll pair<ll,ll>
#define pii pair<int,int>
#define cross(a,b)(conj(a)*(b)).imag()
#define dot(a,b) (conj(a)*(b)).real()
#define rectangle pair<coordinate,coordinate>
#define line tuple<ll,ll,ll>
#define EPS 1e-7
#define polygon vector<point>
typedef long long ll;
typedef unsigned long long ull;
typedef long double ld;
int const N = 2*1e5+5,M = 3005;
using namespace std;
ll n;
ld arr[M],memo[M][M];
ld solve(ll ind,ll heads)
{
    if(ind == n)
    {
        if(heads*2>n)
            return 1;
        return 0;
    }
    ld &ans = memo[ind][heads];
    if(ans!=-1)
        return ans;
    ans = 0;
    ans += solve(ind+1,heads+1)*arr[ind] + solve(ind+1,heads)* (1-arr[ind]);
    return ans;
}
int main()
{
    abdelrahman001
    cin >> n;
    for(int i = 0;i<n;i++)
        for(int j = 0;j<n;j++)
            memo[i][j] = -1;
    for(int i = 0;i<n;i++)
        cin >> arr[i];
    cout << fixed << setprecision(9) << solve(0,0);
    return 0;
}



Measured memory_bytes: 141440
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  char x;
  cin>> x;
  if ((x== 'a')||(x== 'e')||(x== 'i')||(x== 'o')||(x== 'u'))
    cout<< "vowel"<<endl;
  else
    cout<<"consonant"<<endl;
}

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

using namespace std;

int main(){
    string b,bondPair;
    cin>>b;
    if(b=="A")bondPair="T";
    if(b=="T")bondPair="A";
    if(b=="C")bondPair="G";
    if(b=="G")bondPair="C";
    cout<<bondPair;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
typedef long long ll;
typedef long double ld;
const int INF=1e9,MOD=1e9+7,ohara=1e6;
const ll LINF=1e18;
using namespace std;

#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rrep(i,a,b) for(int i=(a);i<(b);i++)
#define rrrep(i,a,b) for(int i=(a);i>=(b);i--)
#define all(v) (v).begin(), (v).end()
#define Size(n) (n).size()
#define Cout(x) cout<<(x)<<endl

ll n,cnt,ans,a,b,c,d,tmp,tmpp,m,h,w,x,y,sum,pos,k;
ld doua;
int dy[]={1,0,-1,0};
int dx[]={0,1,0,-1};
//int dy[]={-1,0,1,-1,1,-1,0,1};
//int dx[]={-1,-1,-1,0,0,1,1,1};
string alph("abcdefghijklmnopqrstuvwxyz"),s;
bool fl;
struct edge{int to,cost;};

//-------------------------↓↓↓↓↓↓------------------------

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

    cin>>s;
    ans=Size(s)/2;
    set<char> st;
    if(Size(s)%2==1){
        ans++;
        st.insert(s[Size(s)/2]);
        rep(i,Size(s)/2){
            st.insert(s[Size(s)/2+i+1]);
            st.insert(s[Size(s)/2-i-1]);
            if(Size(st)==2)break;
            ans++;
        }
    }
    else{
        rep(i,Size(s)/2){
            st.insert(s[Size(s)/2+i]);
            st.insert(s[Size(s)/2-i-1]);
            if(Size(st)==2)break;
            ans++;
        }
    }
    Cout(ans);
    return 0;
}


Measured memory_bytes: 512
c = [list(map(int, input().split())) for _ in range(3)]
b = c[0]
a = 0, c[1][0] - b[0], c[2][0] - b[0]
for i in range(3):
    for j in range(3):
        if c[i][j] != a[i] + b[j]:
            print('No')
            exit()
print('Yes')

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i,i1,n) for(int i=(int)(i1);i<(int)(n);i++)
#define ll long long
#define vi vector<int>
#define vll vector<long long>
using graph = vector<vector<int>>;

int main() {
  string s;
  cin>>s;
  if(s.at(s.size()-1)=='s'){
    cout<<s<<"es";
  }else{
    cout<<s<<"s";
  }
}

Measured memory_bytes: 3628
object Main extends App{
  var list = List[Int]()
  for(i <- 0 until 10){
    val m = io.StdIn.readLine().toInt
    list = m :: list
  }
  list = list.sorted(Ordering[Int].reverse)

  for(i <- 0 to 2){
    println(list(i))
  }
}

Measured memory_bytes: 43632
N = int(input())
a = [int(i) for i in input().split()]
b = sum(a)//N
if sum(a)%N*2 >=  N:
    p = 1
else:
    p = 0
b =b+p
ans = 0
for i in range(N):
    ans += (a[i]-b)**2
print(ans)

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

using namespace std;

using ll = long long;
using ull = unsigned long long;

ll mod = 1000000007;

int main(int argc, char const *argv[]) {
	int n,m;
	std::cin >> n >> m;
	// 階段の穴を入力
	std::vector<int> a;
	for (size_t i = 0; i < m; i++) {
		int tmp;
		std::cin >> tmp;
		//格納
		a.push_back(tmp);
	}

	// 階段のn段目にくるには、n-1段から1段登るか、n-2段から2段登るかのどちらかでしかこれない
	// dp[n] = dp[n-1] + dp[n-2]
	std::vector<ll> dp(n+10,-1);
	dp[0] = 1;
	dp[1] = 1;
	for (size_t i = 0; i < a.size(); i++) {
		dp[a[i]] = 0;
	}
	for (ll i = 2; i < dp.size(); i++) {
		if (dp[i] == -1) {
			dp[i] = (dp[i-1] + dp[i-2]) % mod;
		}
	}

	std::cout << dp[n] << '\n';


	return 0;
}


Measured memory_bytes: 1528
#include<iostream>
#include<algorithm>
#include<vector>
using namespace std;


int main() {
    int x,y;
    while (cin >> x >> y) {
        if (x==0 && y==0) break;
        if (x>y) {
            cout << y << " " << x << endl;
        }else{
            cout << x << " " << y << endl;
        }
    }
    
    return 0;
}


Measured memory_bytes: 3028
#include<bits/stdc++.h> 
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
using namespace std;
using namespace __gnu_pbds;
struct custom_hash {
    static uint64_t splitmix64(uint64_t x) {
        // http://xorshift.di.unimi.it/splitmix64.c
        x += 0x9e3779b97f4a7c15;
        x = (x ^ (x >> 30)) * 0xbf58476d1ce4e5b9;
        x = (x ^ (x >> 27)) * 0x94d049bb133111eb;
        return x ^ (x >> 31);
    }

    size_t operator()(uint64_t x) const {
        static const uint64_t FIXED_RANDOM = chrono::steady_clock::now().time_since_epoch().count();
        return splitmix64(x + FIXED_RANDOM);
    }
};
void err(istream_iterator<string> it) {}
template<typename T, typename... Args>
void err(istream_iterator<string> it, T a, Args... args) {
    cerr << *it << " = " << a << endl;
    err(++it, args...);
}
#define ll                 long long    
#define vi                 vector<ll >
// -------------------Standard Traversal Moves---------------------
// vi fx = {1 ,-1 ,0, 0}, fy = {0, 0, -1, 1};
// vi fx = {2, -2, 2, -2,  1, -1, 1, -1}, fy = {1, 1, -1, -1, 2, 2, -2, -2};
// vi fx = {1, 1, 1, -1, -1 , -1, 0, 0}, fy = {1, -1, 0, 1, -1, 0, 1, -1};
// ----------------------------------------------------------------

#define int                long long                        
#define pb                 push_back                                                     
#define mii                map<ll ,ll >
#define rep(i, a, b)       for(ll  i=a;i<b;i++)
#ifdef LOCAL
#define dbg(args...)       { string _s = #args; replace(_s.begin(), _s.end(), ',', ' '); stringstream _ss(_s); istream_iterator<string> _it(_ss); err(_it, args); }
#else
#define dbg(args...)
#endif
#define pii                pair<ll ,ll >
#define ppb                pop_back
#define vii                vector<pair<ll , ll >>
#define si                 set <ll>
#define hell               1000000007
// #define hell               (ll)998244353
#define all(a)             (a).begin(),(a).end()
#define sz(x)              (ll )x.size()
#define mp                 make_pair
#define yes                cout << "YES" << endl
#define no                 cout << "NO" << endl
#define inf                3223372036854775807
#define endl               '\n' 
#define PI                  3.14159265
#define N                  200005
ll n, m, k, a[N];


int32_t main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    #ifdef LOCAL
    // for getting input from input.txt
    freopen("input.txt", "r", stdin);
    // for writing output to output.txt
    freopen("output.txt", "w", stdout);
    #endif
    ll tests = 1;
    // cin >> tests;
    rep(test, 1, tests+1)
    {
    	int h1 ,m1, h2, m2;
    	cin >> h1 >> m1 >> h2 >> m2;
    	cin >> n;
    	int len = 0;
    	if(m1 - m2 > 0)
    	{
    		len += 60 - m1 + m2;
    		h2--;
    	}
    	else len += m2 - m1;
    	len += (h2 - h1) * (60);
    	cout << len - n << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <cmath>
#include <ios>
#include <ctype.h>
#include <stack>
#include <istream>
#include <stdio.h>
#include <map>
#include <set>
#include <queue>
#include <unordered_map>
#include <functional>
#include <bitset>
#include <list>
#include <deque>
#include <time.h>
#include <random>
#include <iomanip>
#include <fstream>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define REP(i,a,b) for (int i = a; i < (b); ++i)
#define all(x) (x).begin(),(x).end()
#define pint pair<int,int>
const int INF = 1000000007;
const long double EPS = 1e-15;
const long double PI = acos(-1);
typedef long long ll;
using namespace std;
using Graph = vector<vector<int>>;
using Graph_weighted = vector<vector<pair<int,int>>>;
ll gcd(ll a, ll b) { return b ? gcd(b, a%b) : a; }
ll lcm(ll a, ll b) { return (a * b) / gcd(a,b); }
ll ceil(const ll a, const ll b) { return (a + b - 1) / b; }
int main(){
  ll n;
  cin >> n;
  ll tmp = 0,j = 0;
  while(tmp < n)tmp += (++j);
  ll d = tmp - n;
  REP(i,1,j + 1)if(i != d)cout << i << endl;
  return 0;
}


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

// macro
#define rep(i,n) for(i=0;i<n;i++)
#define ll long long
#define all(v) v.begin(), v.end()
#define PI acos(-1)

// code starts
int main()
{
  int l,r,d;
  cin >> l >> r >> d;
  int i;
  int ans = 0;
  for(i=l;i<=r;i++)
  {
    if(i%d==0) ans++;
  }
  cout << ans << "\n";
}


Measured memory_bytes: 3588
#include<bits/stdc++.h>
using namespace std;
long long ans(string s)
{
	if(s.size()<=1)
		return 0;
	if(s[0]==s[1])
		return 1+ans(s.substr(2));
	return ans(s.substr(1));
}
long long slove(long long k,string s)
{
	string t;
	for(int i=0;i<k;i++)
		t+=s;
	return ans(t);
}
int main()
{
	string s;
	long long k;
	cin>>s>>k;
	int n;
//	cout<<"v应当加几\n";
	//cin>>n;
	long long v=(k%2)+2;
	long long diff=slove(v+2,s)-slove(v,s);
	cout<<slove(v,s)+diff*((k-v)/2)<<endl;
	return 0;
} 

Measured memory_bytes: 384
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cctype>
using namespace std;

string str[10]={"","\',.!?","abc","def","ghi","jkl","mno","pqrs","tuv","wxyz"};
int main(){
	string s;
	while(cin>>s){
		if(s[s.size()-1]!='0')s+='0';
		int prev=0;
		int b=s[0]-'0',c=-1;
		for(int j=0;j<s.size();j++){
			if(s[j]=='0'){
				if(prev==0){
					cout<<' ';
				}else{
					char ch=str[b][c%str[b].size()];
					if(c/str[b].size()%2==1)ch=toupper(ch);
					cout<<ch;			
				}
				b=0;
			}else{
				if(prev==0){
					b=s[j]-'0';
					c=0;
				}else if(s[j]-'0'==b){
					c++;
				}else{
					char ch=str[b][c%str[b].size()];
					if(c/str[b].size()%2==1)ch=toupper(ch);
					cout<<ch;			
					b=s[j]-'0';
					c=0;
				}
			}
			prev=s[j]-'0';
		}
		cout<<endl;
	}
	return 0;
}

Measured memory_bytes: 1192
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair < ll, ll > PLL;
#define rep(i,n) for (int i = 0; i < (n); ++i)
ll MOD = 1e4+7;

ll func_comb_calc ( ll a, ll b ) {
    ll ans = 1;
    ll mult_num = a;
    ll div_num = 1;
    ll lim_num = ( b > a / 2 ) ? a - b : b;
    rep(i, lim_num) {
        ans *= mult_num;
        ans /= div_num;
        --mult_num;
        ++div_num;
    }
    return ans;
};

int main() {
    ll n, p;
    cin >> n >> p;
    ll odd_num = 0;
    ll even_num = 0;
    rep(i, n) {
        int tmp_a;
        cin >> tmp_a;
        if ( tmp_a & 1 ) ++odd_num;
        else             ++even_num;
    }
    ll ans = 0;
    ll even_cnum = 0;
    ll odd_cnum = 0;
    if ( p ) {
        for ( ll i = 0; i <= even_num; ++i ) {
            even_cnum += func_comb_calc(even_num, i);
        }
        for ( ll i = 1; i <= odd_num; i += 2 ) {
            odd_cnum += func_comb_calc(odd_num, i);
        }
    }
    else {
        for ( ll i = 0; i <= even_num; ++i ) {
            even_cnum += func_comb_calc(even_num, i);
        }
        for ( ll i = 0; i <= odd_num; i += 2 ) {
            odd_cnum += func_comb_calc(odd_num, i);
        }
    }
    ans = even_cnum * odd_cnum;
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n ; i++)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define whole(f, x, ...) ([&](decltype((x)) whole) { return (f)(begin(whole), end(whole), ## __VA_ARGS__); })(x) // decltypeで型取得、引数があればva_argsのところに入れる
using namespace std;
typedef long long ll; // long longをllでかけるようにした
const int INF = 1e9;

int to_int(string a, int b){
    int ans = 0;
    REP(i, b){
        ans += a[i] * pow(10, b - i - 1);
    }
    return ans;
}

int main(void){
    while(true){
        int aInt, b; cin >> aInt >> b;
        if(aInt == 0 and b == 0) return 0;
        else{
            vector<int> Num(0);
            Num.push_back(aInt);
            string a = to_string(aInt);
            bool find = false;
            if(a.size() < b) while(a.size() != b) a.push_back('0');
            while (true){
                if(a.size() < b) while(a.size() != b) a.push_back('0');
                whole(sort, a);
                string aMinStr = a;
                int aMin = to_int(aMinStr, b);
                whole(sort, a, greater<>());
                string aMaxStr = a;
                int aMax = to_int(aMaxStr, b);
                int ans = aMax - aMin;
                int findNum;
                for(int i = 0; i <= Num.size() - 1; i++){
                    if(ans == Num[i]){
                        find = true;
                        findNum = i;
                    }
                }
                if(find){
                    cout << findNum << " " << Num[findNum] << " " <<  Num.size() - findNum << endl;
                    break;
                }
                else{
                    Num.push_back(ans);
                    a = to_string(ans);
                }
            

            }
            
        }
    }
}


Measured memory_bytes: 3412
//Zory-2019
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
// typedef __int128 ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
#define FR first
#define SE second
#define MP make_pair
#define PB push_back
#define vc vector
#define all(x) (x).begin(),(x).end()
#define sz(x) ((int)(x).size())
#define bin(x) (1ll<<(x))
#define fo(i,l,r) for(int i=(l),I=(r);i<=I;i++)
#define fd(i,r,l) for(int i=(r),I=(l);i>=I;i--)
#define Debug printf("Passing [%s] in LINE %d\n",__FUNCTION__,__LINE__)
#define debug(x) cerr<<#x<<'='<<x<<endl
#define mem(x,val) memset(x,val,sizeof x)
namespace mine
{
    ll qread()
    {
        ll ans=0,f=1;char c=getchar();
        while(c<'0' or c>'9') {if(c=='-')f=-1;c=getchar();}
        while('0'<=c and c<='9') ans=ans*10+c-'0',c=getchar();
        return ans*f;
    }
    void write(ll num){if(num<0) putchar('-'),num=-num;if(num>=10) write(num/10);putchar('0'+num%10);}
    void write1(ll num){write(num);putchar(' ');}
    void write2(ll num){write(num);putchar('\n');}
    template<typename T> void chmax(T &x,const T y) {x=(x>y?x:y);}
    template<typename T> void chmin(T &x,const T y) {x=(x<y?x:y);}
    ll gcd(ll x,ll y){return y?gcd(y,x%y):x;}
    bool IN(ll x,ll l,ll r){return l<=x and x<=r;}

    const int INF=0x3f3f3f3f;
    const int MOD=1e9;
    int mm(const int x){return x>=MOD?x-MOD:x;}
    template<typename T> void add(T &x,const int &y){x=(x+y>=MOD?x+y-MOD:x+y);}
    ll qpower(ll x,ll e,int mod=MOD){ll ans=1;while(e){if(e&1)ans=ans*x%mod;x=x*x%mod;e>>=1;}return ans;}
    ll invm(ll x){return qpower(x,MOD-2);}
    const int N=1e3+10;

    bool done[N][N];queue<pii> q;char str[N];int dis[N][N];
    const int tx[4]={0,0,-1,1};const int ty[4]={-1,1,0,0};
    void main()
	{
        int n=qread(),m=qread();fo(i,1,n){scanf("%s",str+1);fo(j,1,m) if(str[j]=='#') done[i][j]=1,q.push({i,j});}
        int ans=0;
        while(sz(q))
        {
            int x=q.front().FR,y=q.front().SE;q.pop();
            chmax(ans,dis[x][y]);
            fo(t,0,3)
            {
                int x1=x+tx[t],y1=y+ty[t];
                if(1<=x1 and x1<=n and 1<=y1 and y1<=m and !done[x1][y1]) done[x1][y1]=1,dis[x1][y1]=dis[x][y]+1,q.push({x1,y1});
            }
        }
        write(ans);
	}
};//(ans+MOD)%MOD
signed main()
{
    srand(time(0));
    mine::main();
}


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

int w, h;
char data[99][99]; //y, x
int dx[] = {0,0,1,-1};
int dy[] = {1,-1,0,0};

int solve(int x, int y){

  if(x < 0 || y < 0 || x == w || y == h) return 0;
  if(data[y][x] == '#') return 0;

  data[y][x] = '#';

  int ret = 0;
  for(int i=0;i<4;i++) ret += solve(x+dx[i], y+dy[i])+1;

  return ret;
}

int main(){

  while(true){
    cin >> w >> h;
    if(!w && !h) break;

    int sx, sy;
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
	cin >> data[i][j];
	if(data[i][j] == '@') sx = j, sy = i;
      }
    }

    cout << solve(sx, sy)/4 << endl; //for()で４回+1しているため

  }
}

Measured memory_bytes: 1172
using System;
using System.IO;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using System.Text;
using System.Numerics;
using System.Threading.Tasks;
using System.Text.RegularExpressions;
using Debug = System.Diagnostics.Debug;
using System.Runtime.CompilerServices;
using static System.Math;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;

static class P
{
    static void Main()
    {
        long n = long.Parse(Console.ReadLine());
        int sqrt = (int)Ceiling(Sqrt(n));
        long res = 0;
        for (int i = 1; i <= sqrt; i++)
        {
            if (n % i != 0) continue;
            long div = n / i;
            if (div - 1 <= i) continue;
            res += (div - 1);
        }
        Console.WriteLine(res);
    }
}


Measured memory_bytes: 11220
import java.util.*;
public class Main{
    public static void main(String args[]){
        Scanner scanner = new Scanner(System.in);
        String x = scanner.nextLine();
        int r = 3;
        int s = 0;

        for(int i = 0;i < r;i++){
            if(x.charAt(i) == '1'){
                s++;
            }
        }
        System.out.println(s);
    }
}

Measured memory_bytes: 21844
#include<stdio.h>
int main (){
  int a,b,c,max,min,mid;
  scanf("%d%d%d", &a, &b, &c);
  if( a > b){
    max = a;
    min = b;
  }
  else{
    max = b;
    min = a;
  }
  if( c > max){
    mid = max;
    max = c;
  }
  else if( c < min){
    mid = min;
    min = c;
  }
  else
    mid = c;

  printf("%d %d %d\n", min, mid, max);

  return 0;
}




Measured memory_bytes: 2104
//Area of Polygon
#include<bits/stdc++.h>
using namespace std;
typedef complex<double> P;

double helon(P a, P b, P c){
  double d1=abs(a-b), d2=abs(b-c), d3=abs(c-a);
  double z=(d1+d2+d3)/2.0;
  return sqrt(z*(z-d1)*(z-d2)*(z-d3));
}

int main(){
  vector<P> pol;
  P tmp;
  double sum=0.0;
  while(scanf("%lf,%lf", &tmp.real(), &tmp.imag())!=EOF) pol.push_back(tmp);
  for(int i=0; i<pol.size()-2; i++)
    sum+=helon(pol[0], pol[i+1], pol[i+2]);
  printf("%.8f\n", sum);
  return 0;
}

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

int main() {
  int N = 0; cin >> N;
  if(N % 2 == 0){
    cout << "0.5000000000";
  }
  else{
    long double M = N;
    N += 1;
    N /= 2;
    cout << fixed << setprecision(10) << N/M;
  }
}

Measured memory_bytes: 3732
#include<iostream>
#include<vector>
#include<algorithm>
#include<cmath>

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

	if(k<=(n/2+ n%2))
		std::cout<<"YES"<<std::endl;
	else
		std::cout<<"NO"<<std::endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n,l,s=0,d=210; cin>>n>>l;
  s=(l+l+n-1)*n/2;
  for(int i=l;i<l+n;i++) d=min(d,abs(i));
  cout<<(s<0?s+d:s-d);
}

Measured memory_bytes: 3552
#include <bits/stdc++.h>
using namespace std;
int main() {
#define int long long
int X,Y,A,B,C,D,N,A5,rA,rB;
bool found = true;
A = 0;
B = 0;
vector<int>pl(121);
for(int i=0;i<121;i++){
	pl[i] = i*i*i*i*i;
}
cin >> X;
for(int i=0;i<121 && found;i++){
    B = i;
    A5 = X + pl[i];
    for(int j=0;j<121;j++){
      if(pl[j] == abs(A5)){
        if(A5 >=0){
          A = j;
          found = false;
          rA = A;
          rB = B;
          break;
        }else{
          A = -1*j;
          found = false;
          rA = A;
          rB = B;
          break;
        }
      }
    }
    B = -1*i;
    A5 = X - pl[i];
    for(int j=0;j<121;j++){
      if(pl[j] == abs(A5)){
        if(A5 >=0){
          A = j;
          found = false;
          rA = A;
          rB = B;
          break;
        }else{
          A = -1*j;
          found = false;
          rA = A;
          rB = B;
          break;
        }
      }
    }
}
  
  cout << rA <<' ' << rB << endl;
}









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

int main(){
    int N;
    cin >> N;
    
    int B[N-1];
    for(int i=0; i<N-1; i++) cin >> B[i];

    int ANS = 0;
    for(int i=0; i<N; i++){
        if(i == 0){
            ANS += B[i];
            continue;
        }
        if(i == N-1){
            ANS += B[N-2];
            continue;
        }

        ANS += min(B[i-1], B[i]);
    }

    cout << ANS << endl;
}

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

int main() {
    int n;
    cin >> n;
    int a[n];
    for(int i = 0; i < n; i++) {
        cin >> a[i];
    }
    cout << a[n-1];
    for(int j = n-2; j >= 0; j--) {
        cout << " " << a[j];
    }
    cout << endl;
    
    return 0;
}


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


Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>
#include <map>
#include <stack>
#include <queue>
#include <set>
#include <algorithm>
#include <iomanip>
#include <string.h>

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define ALL(a)  (a).begin(),(a).end()

typedef long long lint;

using namespace std;
lint p=1e9+7;

int main(){
  int N;
  cin>>N;
  lint C[N];
  REP(i,N)cin>>C[i];
  sort(C,C+N);
  lint ans=0;
  REP(i,N){
    ans+=C[i]*(lint)(1+N-i);
    ans%=p;
  }
  REP(i,2*N-2){
    ans*=2;
    ans%=p;
  }
  cout<<ans<<endl;
  return 0;
}


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

using namespace std;
typedef long long ll;
#define rep(i, n) for (ll i = 0; i < (ll)(n); ++i)
#define erep(i, n) for (ll i = 0; i <= (ll)(n); ++i)
#define FOR(i,a,b) for (ll i = (a); i < (ll)(b); ++i)
#define EFOR(i,a,b) for (ll i = (a); i <= (ll)(b); ++i)
template<class T>bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } }
template<class T>bool chmin(T &a, const T &b) { if (b<a) { a=b; return 1; } }

vector<int> ans(10e5+5, -1);
using Graph = vector<vector<int>>;
Graph g(10e5+5);
int dfs(int node ) {
    if(ans[node] > -1) return ans[node];

    ans[node] = 0;
    for(auto i : g[node]) {
        if(ans[i] != -1) chmax(ans[node], ans[i]+1);
        else chmax(ans[node], dfs(i) + 1);
    }
    return ans[node];
}

int main() {

    int n,m; cin >> n >> m;
    for (int i = 0; i < m; ++i) {
        int from, to;
        cin >> from >> to;
        g[from].push_back(to);
    }

//    int ret = 0;
//    for(int i=1; i <= n; i++) {
//        if(ans[i] == -1) ret = max(ret, dfs(i));
//    }

    int ret = 0;
    for(int i=1; i <= n; i++) {
        chmax(ret, dfs(i));
    }

    cout << ret << endl;

    return 0;
}


Measured memory_bytes: 32768
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace std;
using namespace __gnu_pbds;
#define MOD  1000000007
#define inf  1e18
#define ll long long
#define multiply(x) x*x*(x-=1)

#define ar array
#define wt(x) int x;cin>>x;while(x--)
typedef tree<pair<int,int>,null_type,less<pair<int,int>>,rb_tree_tag,tree_order_statistics_node_update> pbds;
 void  c_p_c(){
  ios_base::sync_with_stdio(0);
  cin.tie(0);
  cout.tie(0);
 
#ifndef ONLINE_JUDGE
  freopen("input1.txt","r",stdin);
  freopen("output1.txt","w",stdout);
#endif
 
 
}


            




    
  



 
int32_t main() {
   c_p_c();
  
       
       string s;
       int k;
       cin>>k>>s;
       if(s.size()<=k){
        cout<<s;
       }
       else{
        string p=s.substr(0,k);
        p.push_back('.');
        p.push_back('.');
        p.push_back('.');
        cout<<p;
       }
        
        
    
    return 0;
 }

Measured memory_bytes: 3656
#ABC091 B - Two Colors Card Game
si = lambda: input()
ni = lambda: int(input())
nm = lambda: map(int, input().split())
nl = lambda: list(map(int, input().split()))

N = ni()
S = [input() for i in range(N)]
M = ni()
T = [input() for i in range(M)]

ST_map = set(S)|set(T)
b = 0
r = 0

ans = -1000
for st_m in ST_map:
    b = 0
    r = 0
    for s in S:
        if st_m == s:
            b+=1
    for t in T:
        if st_m == t:
            r+=1
    ans = max(ans,b-r)

if ans<0:
    ans = 0
print(ans)

Measured memory_bytes: 3188
import java.util.*;
import java.lang.*;
import java.io.*;

public class Main{
public static void main (String[] args){
	Scanner sc = new Scanner(System.in);
	int a = Integer.parseInt(sc.next());
	int b = Integer.parseInt(sc.next());
	int t = Integer.parseInt(sc.next());
	System.out.println((t/a)*b);
	
}
}


Measured memory_bytes: 22868
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.util.StringTokenizer;

public class Main {
    public static void main(final String[] args) {
        final FastScanner scanner = new FastScanner(System.in);
        final int t = scanner.nextInt();
        for (int i = 0; i < t; i++) {
            final long n = scanner.nextInt();
            final long m = scanner.nextInt();
            final long a = scanner.nextInt();
            final long b = scanner.nextInt();
            System.out.println(floorSum(n, m, a, b));
        }
    }

    private static long floorSum(final long n, final long m, long a, long b) {
        long answer = 0;
        if (a >= m) {
            answer += (n - 1) * n * (a / m) / 2;
            a %= m;
        }
        if (b >= m) {
            answer += n * (b / m);
            b %= m;
        }

        final long yMax = (a * n + b) / m;
        final long xMax = yMax * m - b;
        if (yMax == 0) {
            return answer;
        }
        answer += (n - (xMax + a - 1) / a) * yMax;
        answer += floorSum(yMax, a, m, (a - xMax % a) % a);
        return answer;
    }

    private static class FastScanner {
        private final BufferedReader reader;
        private StringTokenizer tokenizer;

        FastScanner(final InputStream in) {
            reader = new BufferedReader(new InputStreamReader(in));
        }

        String next() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    tokenizer = new StringTokenizer(reader.readLine());
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }
            return tokenizer.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            if (tokenizer == null || !tokenizer.hasMoreTokens()) {
                try {
                    return reader.readLine();
                } catch (final IOException e) {
                    throw new RuntimeException(e);
                }
            }

            return tokenizer.nextToken("\n");
        }
    }
}


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

const int N = (int)2e5 + 500;
typedef long long ll;
const ll INF = (ll)1e18;

int n;
int num[N];
ll psum[N];

ll getsum(int l, int i, int r){
    return (psum[i-1] - psum[l-1]) - (psum[r] - psum[i-1]);
}


ll get(int pi){
    ll sma, lar;
    int l = 2, r = pi-1, mid;
    while(l + 1 < r){
        mid = (l+r) / 2;
        if(getsum(1, mid, pi-1) < 0) l = mid;
        else r = mid;
    }
    if(abs(getsum(1, r, pi-1)) > abs(getsum(1, l, pi-1))){
        sma = min(psum[l-1], psum[pi-1] - psum[l-1]);
        lar = max(psum[l-1], psum[pi-1] - psum[l-1]);
    }
    else{
        sma = min(psum[r-1], psum[pi-1] - psum[r-1]);
        lar = max(psum[r-1], psum[pi-1] - psum[r-1]);
    }
    l = pi + 1, r = n;
    while(l + 1 < r){
        mid = (l + r) / 2;
        if(getsum(pi, mid, n) < 0) l = mid;
        else r = mid;
    }

    if(abs(getsum(pi, r, n)) > abs(getsum(pi, l, n))){
        sma = min(sma, min(psum[l-1] - psum[pi-1], psum[n] - psum[l-1]));
        lar = max(lar, max(psum[l-1] - psum[pi-1], psum[n] - psum[l-1]));
    }
    else{
        sma = min(sma, min(psum[r-1] - psum[pi-1], psum[n] - psum[r-1]));
        lar = max(lar, max(psum[r-1] - psum[pi-1], psum[n] - psum[r-1]));
    }
    return lar - sma;
}

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

    cin >> n;
    for(int i = 1; i <= n; i++) cin >> num[i], psum[i] = psum[i-1] + num[i];

    ll res = INF;
    for(int pi = 3; pi <= n-1; pi++){
        res = min(res, get(pi));
    }
    cout << res;
}

Measured memory_bytes: 2560
N,X,M = map(int,input().split())

ans = X
A = X
TF = True
srt = 1000000
retu = [X]
d = dict()
d[X] = 0
loop = X
flag = False
for i in range(N-1):
    if TF:
        A = A**2 % M
        if d.get(A) != None:
          srt = d[A]
          goal = i
          TF = False
          
        if TF:
          retu.append(A)
          d[A] = i + 1
          loop += A
    else:
      flag = True
      break
      
if flag:
    n = (N-srt)//(goal-srt+1)
    saisyo = sum(retu[:srt])
    loop -= saisyo
    print(saisyo + loop*n + sum(retu[srt:N-n*(goal-srt+1)]))
    
else:
    print(sum(retu[:N]))


Measured memory_bytes: 15828
h,w=map(int,input().split())
a=[list(map(int,input().split()))for i in range(h)]
l=[]
for i in range(h):
 for j in range(w):
  if a[i][j]%2:
   if i+1<h:a[i][j]-=1;a[i+1][j]+=1;l.append((i+1,j+1,i+2,j+1))
   elif j+1<w:a[i][j]-=1;a[i][j+1]+=1;l.append((i+1,j+1,i+1,j+2))
print(len(l))
for i in l:print(*i)

Measured memory_bytes: 30228
N, K = map(int, input().split())
L, R = [], []
for _ in range(K):
    tmpl, tmpr = map(int, input().split())
    L.append(tmpl)
    R.append(tmpr)
MOD = 998244353

dp = [0] * (N + 1)
dp[1] = 1
dp[2] = -1
for i in range(1, N + 1):
    dp[i] = dp[i - 1] + dp[i]
    for l, r in zip(L, R):
        if i + l < N + 1:
            dp[i + l] += dp[i]
            dp[i + l] %= MOD
        if i + r + 1 < N + 1:
            dp[i + r + 1] -= dp[i]
            dp[i + r + 1] %= MOD
print(dp[N] % MOD)


Measured memory_bytes: 75084
import math
def order(N,P):
  value=0
  N_ls=list(range(1,N+1))
  score=0
  for i in P:
    score+=N_ls.index(i)*math.factorial(len(N_ls)-1)
    N_ls.remove(i)
  return score

N=int(input())
P=[int(x) for x in input().split()]
Q=[int(x) for x in input().split()]
print(abs(order(N,P)-order(N,Q)))

Measured memory_bytes: 9176
// ※※※ 解答不能 ※※※
// SovietPower氏.
// https://atcoder.jp/contests/yahoo-procon2019-qual/submissions/4241327
#include <bits/stdc++.h>
using namespace std;
using LL = long long;
#define rep(i, n) for(int i = 0; i < n; i++)
#define repx(i, a, b) for(int i = a; i < b; i++)
LL f[5];

int main(){
    int L, ai;
    scanf("%d", &L);
    repx(i, 1, L + 1){
        scanf("%d", &ai);
        LL mn = f[0];
        f[0] += ai;
        mn = min(mn, f[1]), f[1] = mn + (ai ? ai & 1 : 2);
        mn = min(mn, f[2]), f[2] = mn + (ai ? (ai + 1) & 1 : 1);
        mn = min(mn, f[3]), f[3] = mn + (ai ? ai & 1 : 2);
        mn = min(mn, f[4]), f[4] = mn + ai;
    }
    printf("%lld\n", min(f[2], min(f[3], f[4])));
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(){
	int ans=0,N,X,m[1005]={0};
	cin>>N>>X;
	ans=N;
	for(int i=0;i<N;i++){
		cin>>m[i];
		X=X-m[i];
	}
	sort(m,m+N);
	ans=ans+X/m[0];
	cout<<ans;
	return 0;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int count =0;
		String str = sc.next();
		char[] c = str.toCharArray();
		if(c[0]=='1') count++;
		if(c[1]=='1')count++;
		if(c[2]=='1')count++;
		System.out.printf("%d\n",count);
	}
}


Measured memory_bytes: 22740
n,m,q=map(int,input().split())
abcd=[list(map(int,input().split())) for i in range(q)]
ans=0

def calc(arr):
  score=0
  for a,b,c,d in abcd:
    if arr[b-1]-arr[a-1]==c:
      score+=d
  return score

def dfs(arr, i):
  global ans
  if len(arr)==n:
    ans=max(ans,calc(arr))
    return
  for j in range(i,m+1):
    arr.append(j)
    dfs(arr, j)
    arr.pop()
dfs([], 1)
print(ans)

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

typedef long long ll;
#define REP(i,n) for(int i=0,_n=(int)(n);i<_n;++i)
#define ALL(v) (v).begin(),(v).end()
#define CLR(t,v) memset(t,(v),sizeof(t))
template<class T1,class T2>ostream& operator<<(ostream& os,const pair<T1,T2>&a){return os<<"("<<a.first<<","<<a.second<< ")";}
template<class T>void pv(T a,T b){for(T i=a;i!=b;++i)cout<<(*i)<<" ";cout<<endl;}
template<class T>void chmin(T&a,const T&b){if(a>b)a=b;}
template<class T>void chmax(T&a,const T&b){if(a<b)a=b;}


int nextInt() { int x; scanf("%d", &x); return x;}

int main2() {
  int N = nextInt();
  vector<int> p(N);
  REP(i, N) p[i] = nextInt();

  int ans = 0;
  for (int i = 0; i + 2 < N; i++) {
    vector<int> v({ p[i],  p[i+1], p[i+2] });
    sort(ALL(v));
    if (p[i+1] == v[1]) ans++;
  }
  cout << ans << endl;
  return 0;
}

int main() {

#ifdef LOCAL
  for (;!cin.eof();cin>>ws)
#endif
    main2();
  return 0;
}


Measured memory_bytes: 256
N, A, B = map(int, input().split())
 
diff = B - A
 
if diff % 2 == 0:
    x = diff//2
else:
    diff_small = A - 1
    diff_big = N - B
 
    x = (diff - 1)//2 + min(diff_small, diff_big) + 1
 
 
print(int(x))
 

Measured memory_bytes: 2940
#include <iostream>
using namespace std;
int main() {
  char *str = new char[1001];
  long sum;
  int i;
  while(cin >> str) {
	sum = 0;
	i = 0;
	if(str[0] == '0') {break;}
	while(str[i] != '\0') {
	  sum += str[i++] - '0';
	}
	cout << sum << endl;
  }
  return 0;
}

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

int check(int n)
{
	int t = 1;
	while(n / 10 != 0){
		t ++ ;
		n /= 10;
	}
	return t;
}
int main()
{
	int n;
	cin >> n;
	int cnt = 0;
	for(int i=1;i<=n;i++)
		{
			if(check(i) % 2 == 1)
				cnt ++ ;
		}
	cout << cnt << endl;
	return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<functional>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<tuple>
#include<stack>
#include<queue>
#include<deque>
#include<sstream>
#include<stdio.h>
#include<math.h>
#include<stdlib.h>
#include<bitset>
#include<time.h>
#include<cstdlib>
#include<cassert>
#define ll long long
#define fi first
#define se second
using namespace std;

int n,m;
string s;
                   
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  cout.precision(10);
  cout<<fixed;
#ifdef LOCAL_DEFINE
    freopen("in", "r", stdin); 
    freopen("out","w",stdout);
#endif
  cin>>n;
  int k;
  cin>>k;
  cout<<n*n-k<<endl;
#ifdef LOCAL_DEFINE
    cerr << "Time elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " s.\n";
#endif
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
 
using namespace std;
 
int main(void){
    double r;
    cin >> r;
    double s = r * r * 1.0 * 3.141592653589;
    double l = r * 2.0 * 3.141592653589;
    cout << setprecision(6);
    cout << fixed << s << " " << l << endl;
}

Measured memory_bytes: 1288
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
ll a,b,t,cnt=1;
ll gcd(ll a, ll b) {
    return b==0? a: gcd(b, a%b);
}
int main() {
    cin>>a>>b;
    t=gcd(a,b);
    for(ll i=2;i*i<=t;i++) {
        if(t%i==0) {
            cnt++;
            while(t%i==0) t/=i;
        }
    }
    if(t>1) cnt++;
    cout<<cnt<<endl;
    return 0;
}


Measured memory_bytes: 256
{-# LANGUAGE BangPatterns      #-} --引数に!

import Data.Bits
import Data.Foldable (foldlM,foldrM)
import Data.Maybe (fromJust)
import Data.List
import qualified Data.Vector.Unboxed.Mutable as V
import Control.Monad
import qualified Data.ByteString.Lazy.Char8 as BS

main :: IO ()
main = do
  [a,p] <- map read.words <$> getLine :: IO [Int]
  print $ (3*a+p) `div` 2


Measured memory_bytes: 508
//#pragma comment(linker, "/stack:200000000")
//#pragma GCC optimize("Ofast")
//#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include <bits/stdc++.h>

using namespace std;
typedef long long ll;

#define loopinc(i, a, b, inc) for(int i = a; i < (b); i += inc)
#define loop(i, a, b) for(int i = a; i < (b); i++)
#define rep(i, n) loop(i, 0, n)
#define rrep(i, n) for (int i = n-1; i >= 0; i--)
#define endl "\n"
#define all(c) (c).begin(),(c).end()
#define lloopinc(i, a, b, inc) for(ll i = a; i < (b); i += inc)
#define lloop(i, a, b) for(ll i = a; i < (b); i++)
#define lrep(i, n) lloop(i, 0, n)
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vll;
typedef tuple<int, int, int> tiii;
void __print(int x) {cerr << x;}
void __print(long x) {cerr << x;}
void __print(long long x) {cerr << x;}
void __print(unsigned x) {cerr << x;}
void __print(unsigned long x) {cerr << x;}
void __print(unsigned long long x) {cerr << x;}
void __print(float x) {cerr << x;}
void __print(double x) {cerr << x;}
void __print(long double x) {cerr << x;}
void __print(char x) {cerr << '\'' << x << '\'';}
void __print(const char *x) {cerr << '\"' << x << '\"';}
void __print(const string &x) {cerr << '\"' << x << '\"';}
void __print(bool x) {cerr << (x ? "true" : "false");}

template<typename T, typename V>
void __print(const pair<T, V> &x) {cerr << '{'; __print(x.first); cerr << ','; __print(x.second); cerr << '}';}
template<typename T>
void __print(const T &x) {int f = 0; cerr << '{'; for (auto &i: x) cerr << (f++ ? "," : ""), __print(i); cerr << "}";}
void _print() {cerr << "]\n";}
template <typename T, typename... V>
void _print(T t, V... v) {__print(t); if (sizeof...(v)) cerr << ", "; _print(v...);}
#ifndef ONLINE_JUDGE
#define debug(x...) cerr << "[" << #x << "] = ["; _print(x)
#else
#define debug(x...)
#endif

template <typename T>
T modpow(T base, T exp, T modulus) {
  base %= modulus;
  T result = 1;
  while (exp > 0) {
    if (exp & 1) result = (result * base) % modulus;
    base = (base * base) % modulus;
    exp >>= 1;
  }
  return result;
}

constexpr int maxn = 500001;
constexpr ll mod = 1000000007;
ll fac[maxn];
void calcfac() {
	fac[0] = 1;
	loop(i, 1, maxn) {
		fac[i] = fac[i-1]*i % mod;
	}
}

ll mdiv(ll a, ll b) {
	return a*modpow(b, mod-2, mod)%mod;
}

ll ncr(ll n, ll r) {
	return mdiv(fac[n], fac[r]*fac[n-r] % mod);
}

signed main() {
	// freopen("input.txt", "r", stdin); freopen("output.txt", "w", stdout);
	std::ios::sync_with_stdio(false);
	cin.tie(0);
	memset(fac, 0, sizeof(fac));
	calcfac();

	int n, m;
	cin >> n >> m;
	
	ll acc = 0;
	rep(i, n+1) {
		//debug(fac[m-i], fac[m-n], ncr(n, i), (i%2 == 0 ? 1 : -1));
		acc += (((mdiv(fac[m-i], fac[m-n]) * ncr(n, i) % mod) * (i%2 == 0 ? 1 : -1)) + mod) % mod;
		acc %= mod;
	}
	acc *= mdiv(fac[m], fac[m-n]);
	acc %= mod;
	//acc = mdiv(acc, 2);
	cout << acc << endl;
}


Measured memory_bytes: 7468
N, M = map(int, input().split())
#a = [int(input()) for _ in range(M)]
issafe = [True] * (N + 1)
for i in range(M):
    issafe[int(input())] = False

dp = [0] * (N + 1)
dp[0] = 1
if issafe[1]:
    dp[1] = 1

for i in range(2, N + 1):
    if issafe[i - 1]:
        dp[i] += dp[i - 1]
    if issafe[i - 2]:
        dp[i] += dp[i - 2]

mod = 1000000007
print(dp[N] % mod)

Measured memory_bytes: 463476
#include <bits/stdc++.h>
#define rep(i, n) for(ll i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
const double PI=acos(-1);

int main(){
    ll n;
    cin >> n;
    ll a = n%10;
    if(a == 2 || a == 4 || a == 5 || a == 7 || a == 9) cout << "hon" << endl;
    else if(a == 0 || a == 1 || a == 6 || a == 8) cout << "pon" << endl;
    else cout << "bon" << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <stdlib.h>
#include <cmath>
#include <cstdio>
#include <cstdint>
#include <string>
#include <iostream>
#include <vector>
#include <utility>
#include <algorithm>
#include <map>
using namespace std;
using ll = long long;

int main(){
  int N;
  cin >> N;
  vector<int> A(N+1);
  vector<int> B(N);
  for(int i=0;i<N+1;++i) cin >> A.at(i);
  for(int i=0;i<N;++i) cin >> B.at(i);

  ll ans=0;
  for(int i=0;i<N;++i){
    if(A.at(i)<B.at(i)){
      ans+=A.at(i);
      B.at(i)-=A.at(i);
      A.at(i)=0;
      if(A.at(i+1)<B.at(i)){
	ans+=A.at(i+1);
	B.at(i)-=A.at(i+1);
	A.at(i+1)=0;
      }
      else{
	ans+=B.at(i);
	A.at(i+1)-=B.at(i);
	B.at(i)=0;
      }
    }
    else{
      ans+=B.at(i);
      A.at(i)-=B.at(i);
      B.at(i)=0;
    }
  }

  cout << ans << endl;

  return 0;
}


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

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

    return 0;
}

Measured memory_bytes: 3588
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

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

    for(int i=1; i<=n; ++i){
        int a;
        cin >> a;

        cout << "Case " << i << ':' << endl;
        for(int j=0; j<10; ++j){
            a *= a;
            a /= 100;
            a %= 10000;
            cout << a << endl;
        }
    }
}

Measured memory_bytes: 0
#pragma GCC optimize("Ofast", "unroll-loops")

#include <bits/stdc++.h>

using namespace std;

#define ll long long
#define ld long double

const ll mod = 1000000007LL;

ll modpow(ll a, ll b) {
	if (b == 0) return 1;
	ll t = modpow(a, b / 2);
	if (b & 1)
		return t * t % mod * a % mod;
	return t * t % mod;
}

signed main() {
	ll n; cin >> n;
	vector<ll> c(n);
	for (int i = 0; i < n; ++i) cin >> c[i];
	sort(c.begin(), c.end());

	ll ans = 0;
	for (int i = 0; i < n; ++i) {
		ll t = c[i] * (-i + n + 1) % mod;
		ans += t; ans %= mod;
	}
	ans *= modpow(2, 2 * n - 2LL);
	ans %= mod;
	cout << ans << endl;
	
	return 0;
}

Measured memory_bytes: 1792
w=int(input())
n=int(input())
a=[]
for i in range(w):
    a.append(i+1)
for i in range(n):
    m, n= map(int,input().split(','))
    temp=a[m-1]
    a[m-1]=a[n-1]
    a[n-1]=temp
for i in range(w):
    print(a[i])

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

o_list = [0]*n

for x in range(1,101):
  for y in range(1,101):
    for z in range(1,101):
      if n < x**2+y**2+z**2+x*y+y*z+z*x:
        break
      o_list[x**2+y**2+z**2+x*y+y*z+z*x-1] += 1

for o in o_list:
  print(o)

Measured memory_bytes: 69236
from itertools import chain
op_list = ["+", "-"]
s = input()
for i in range(8):
	op1 = op_list[i % 2]
	op2 = op_list[i // 2 % 2]
	op3 = op_list[i // 4]
	expr = "".join(chain.from_iterable(zip(s, [op1, op2, op3, ""])))
	if eval(expr) == 7:
		print(expr + "=7")
		quit()


Measured memory_bytes: 3060