akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <vector>
#include <utility>
#include<algorithm>
#include<stack>
#include<queue>
#include<list>
using namespace std;
int main() {
	int n;
	cin >> n;
	vector<int>v(n);
	for (int i = 0; i < n; i++) {
		cin >> v.at(i);
	}                              
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (v.at(i) < 0) {
			v.at(i) *= -1;
			count++;
		}
	}
	int64_t sum = 0;
	for (int i = 0; i < n; i++) {
			sum += v.at(i);
	}
	int a = v.at(0);
	for (int i = 0; i < n; i++) {
		a = min(v.at(i), a);
	}
    if ((count) % 2 == 0) {
			cout << sum << endl;
	}
	else {
			cout << sum - (2*a) << endl;
	}
		return 0;
}

Measured memory_bytes: 640
#include<bits/stdc++.h>
using namespace std;
int main()
{
    long long a,b,g;
    cin>>a>>b;
    g=__gcd(a,b);
    set<int>s;
    if(g%2==0)
    {
        s.insert(2);
        while(g%2==0)
            g/=2;
    }
    for(long long i=3;i*i<=g;i+=2)
        if(g%i==0)
    {
        s.insert(i);
        while(g%i==0)
            g/=i;
    }
    if(g>2)
        s.insert(g);
    cout<<s.size()+1<<endl;
}


Measured memory_bytes: 256
n = int(input())
a = [int(input()) for _ in range(n)]
a_sort = sorted(a,reverse=True)
m1 = a_sort[0]
m2 = a_sort[1]
for i in range(n):
  if a[i] == m1:
    print(m2)
  else:
    print(m1)

Measured memory_bytes: 18976
while True:
    try:
        l = map(int, raw_input().split(","))
        v1 = l.pop(10)
        v2 = l.pop(10)
        p = v1*float(sum(l))/(v1+v2)
        for i in range(10):
            p -= l[i]
            if p <= 0:
                print i+1
                break
    except:
        break


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

using ll = long long;

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

    int n,a,b;cin>>n>>a>>b;

    ll ans=0;

    if(n==1)
    {
        if(a==b)ans=1;
        else ans=0;
    }
    else
    {
        n-=2;
        ll nmax=a+b;
        ll nmin=a+b;
        for(int i=0;i<n;i++)
        {
            nmax+=b;
            nmin+=a;
        }
        ans=max(nmax-nmin+1,0LL);
    }
    
    cout<<ans<<"\n";

    return 0;
}


Measured memory_bytes: 3584
N, K = map(int, input().split())
X = [list(map(int, input().split())) for _ in range(N)]

x = sorted(v for v, _ in X)
y = sorted(v for _, v in X)
ans = 10 ** 20
for i in range(N - 1):
    for j in range(i + 1, N):
        for k in range(N - 1):
            for l in range(k + 1, N):
                x1 = x[i]
                x2 = x[j]
                y1 = y[k]
                y2 = y[l]
                num = 0
                for n in range(N):
                    if x1 <= X[n][0] <= x2 and y1 <= X[n][1] <= y2:
                        num += 1
                if num >= K:
                    ans = min(ans, (x2 - x1) * (y2 - y1))

print(ans)


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

using ll = long long;
using ull = unsigned long long;
using st = string;
using db = double;
using vll = vector<long long>;
using vvll = vector<vll>;
using vchar = vector<char>;
#define rep(i, m, n) for (int i = (int)(m); i < (int)(n); i++)
#define vrep(i, vec) for(auto& i : vec)
#define vin(vec) for(auto& i : vec) cin >> i
#define all(v) v.begin(), v.end()
ll mod = 1000000007;

int main(){
  st s;
  cin >> s;
  set<char> sset;
  vrep(i, s) sset.insert(i);
  for(char i = 'a'; i <= 'z'; i++){
    if(!sset.count(i)) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "None" << endl;
}

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

ans=1
b = [-1,-1,-1]
for i in a:
    flag = True
    count=0
    for j in range(3):
        if b[j] == i - 1:
            if flag:
                b[j] += 1
                flag=False
            count +=1
    ans = ans * count % 1000000007
print(ans)

Measured memory_bytes: 13932
#include <bits/stdc++.h>
using namespace std;
const long long INF = 123456789;
const long long MOD = 1000000007;
const long double PI = 3.1415926;
#define FOR(i, r, n) for (ll i = (ll)(r); i < (ll)(n); i++)
#define RFOR(i, r, n) for (ll i = (ll)(n - 1); i >= r; i--)
#define REP(i, n) FOR(i, 0, n)
#define RREP(i, n) RFOR(i, 0, n)
#define ALL(x) x.begin(), x.end()
#define RALL(x) x.rbegin(), x.rend()
typedef long long int ll;
typedef vector<ll> vi;
typedef vector<pair<ll, ll>> vp;
typedef vector<string> vs;
typedef vector<char> vc;
typedef list<ll> lst;
typedef pair<ll, ll> P;

ll n, m, k, ans = 0, sum = 0, cnt = 0;
string s;
char c;

#define Endl endl

/*--------------------template--------------------*/

set<ll> lx, ly;

int main()
{
    ll x, y;
    cin >> s >> x >> y;
    ll nx = 0;
    ll ny = 0;
    s.push_back('T');
    while (1) {
        if (s[cnt] == 'T') {
            break;
        } else {
            nx++;
            cnt++;
        }
    }
    vi vx, vy;
    int xx = 1;
    FOR(i, cnt, s.size())
    {
        if (s[i] == 'T') {
            if (sum != 0) {
                if (xx == 1) {
                    vx.push_back(sum);
                } else {
                    vy.push_back(sum);
                }
            }
            xx *= -1;
            sum = 0;
        } else {
            sum++;
        }
    }
    lx.insert(nx);
    ly.insert(ny);
    REP(i, vx.size())
    {
        vi xxx;
        for (auto q : lx) {
            ll a = q + vx[i];
            ll b = q - vx[i];
            xxx.push_back(a);
            xxx.push_back(b);
        }
        lx.clear();
        REP(j, xxx.size()) {
            lx.insert(xxx[j]);
        }
    }
    bool px = false;
    for (auto p : lx) {
        if (p == x) {
            px = true;
        }
    }
    REP(i, vy.size())
    {
        vi yyy;
        for (auto q : ly) {
            ll a = q + vy[i];
            ll b = q - vy[i];
            yyy.push_back(a);
            yyy.push_back(b);
        }
        ly.clear();
        REP(j, yyy.size())
        {
            ly.insert(yyy[j]);
        }
    }
    bool py = false;
    for (auto p : ly) {
        if (p == y) {
            py = true;
        }
    }
    cout << (px && py ? "Yes" : "No") << endl;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  int a, b, c;
  cin >> a >> b >> c;
  int ans = 0;
  chmax(ans, max(a*10+b+c, max(b*10+c+a, c*10+a+b)));
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std; using P=pair<int,int>; using ll=long long;

int main() {
  ll n; cin>>n;
  ll b[n+1]; fill(b,b+n+1,0);
    for(ll j=1;j<=n;j++) {
      ll j2=j;
      for(ll k=2;k<=j2;k++) {
        if (j2%k==0) j2/=k, b[k]++, k--;
      }
    }
  /*
  for(int i=0;i<=n;i++) {
    cout<<b[i]<<" ";
  } cout<<endl;*/

  ll an=0;
  for(int i=2;i<=n;i++) {
    for(int j=2;j<=n-1;j++){
      for(int k=j+1;k<=n;k++) {
        if (i==j || j==k || i==k) continue;
        if (b[i]>=2 && b[j]>=4 && b[k]>=4) an++;
      }
    }
  }

  for(int i=2;i<=n;i++) {
    for(int j=2;j<=n;j++) {
      if (i==j) continue;
      if (b[i]>=2 && b[j]>=24) an++;
      if (b[i]>=4 && b[j]>=14) an++;
    }
  }
  for(int i=2;i<=n;i++) {
    if (b[i]>=74) an++;
  }
  cout<<an<<endl;
}

Measured memory_bytes: 256
while 1:
  n = input()
  if n == 0:  break
  d = range(1, 7)
  ans = 1
  for i in range(n):
    c = raw_input()[0]
    if c == 'N': S = [1,5,2,3,0,4]
    elif c == "S": S = [4,0,2,3,5,1]
    elif c == "E": S = [3,1,0,5,4,2]
    elif c == "W": S = [2,1,5,0,4,3]
    elif c == "R": S = [0,2,4,1,3,5]
    elif c == "L": S = [0,3,1,4,2,5]
    d = [d[s] for s in S]
    ans += d[0]
  print ans

Measured memory_bytes: 6468
#include<iostream>
using namespace std;
int main()
{
int a,b,c;
cin>>a>>b>>c;
if(a==b and b==c)
cout<<"0";

if(a>b and b>c)
cout<<b-c+a-b;
if(a>c and c>b)
cout<<c-b+a-c;
if(b>a and a>c)
cout<<a-c+b-a;
if(b>c and c>a)
cout<<c-a+b-c;
if(c>a and a>b)
cout<<a-b+c-a;
if(c>b and b>a)
cout<<b-a+c-b;

if(a>b and b==c)
cout<<a-b;
if(b>a and a==c)
cout<<b-a;
if(c>a and a==b)
cout<<c-a;

if(a==b and b>c)
cout<<b-c;
if(a==c and c>b)
cout<<c-b;
if(b==c and c>a)
cout<<c-a;

return 0;
} 

Measured memory_bytes: 256
#include <cstdint>
#include <cstdio>
typedef int64_t i64;

static const auto M = 1000000007;

static int F[500001];

// 1 <= x < m <= 3037000500
i64 inv(i64 x, i64 m) {return x == 1 ? 1 : ((x - inv(m % x, x)) * m + 1) / x;}

static inline int C(int n, int m) {
	return F[n] * inv((i64)F[m] * F[n - m] % M, M) % M;
}

static void build() {
	F[0] = 1;
	for(auto i = 1; i < sizeof(F) / sizeof(*F); i++) {
		F[i] = F[i - 1] * (i64)i % M;
	}
}

int main() {
	build();
	int H, W, h, w;
	scanf("%d%d%d%d", &H, &W, &h, &w);
	auto ans = 0;
	for(auto hh = 0; hh < H - h; hh++) {
		ans = (ans + (i64)C(hh + w - 1, w - 1) * C(H - 1 - hh + W - w - 1, W - w - 1)) % M;
	}
	printf("%d\n", ans);
	return 0;
}

Measured memory_bytes: 2176
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define rep(i, s, e) for (ll (i) = (s); (i) < (e); ++(i))
#define per(i, s, e) for (ll (i) = (s); (i) >= (e); --(i))
#define all(x) x.begin(),x.end()
 
int main(void) {
  string s, t;
  cin >> s >> t;
  int a, b;
  cin >> a >> b;
  string u;
  cin >> u;

  if (u == s) a--;
  else if (u == t) b--;

  cout << a << " " << b << endl;

}


Measured memory_bytes: 256
#include<iostream>
#include<string>
using namespace std;
string S, T = "AKIHABARA"; int cx = 0, a[4] = { 0,4,6,8 }; bool used[10];
int main() {
	cin >> S;
	for (int i = 0; i < 16; i++) {
		string U = "";
		for (int j = 0; j < 9; j++)used[j] = false;
		for (int j = 0; j < 4; j++) { if ((i / (1 << j)) % 2 == 1)used[a[j]] = true; }
		for (int j = 0; j < 9; j++) {
			if (used[j] == false)U += T[j];
		}
		if (S == U) { cout << "YES" << endl; return 0; }
	}
	cout << "NO" << endl;
	return 0;
}

Measured memory_bytes: 256
import sys
input = lambda: sys.stdin.readline().rstrip()

def main():
    n = list(input().split())
    if len(n[0]) == 1 and len(n[1]) == 1:
        print(int(n[0])*int(n[1]))
    else:
        print(-1)
    
if __name__ == '__main__':
    main()

Measured memory_bytes: 3060
/*------U Have To DO It------*/
/* BY-> RicoProg */
/*        ___ 
           __|__|
          |  |___       */
#include <bits/stdc++.h>
using namespace std;
 
 
//---------------------------------------------------MACROS----------------------------------------------------------
#define ll long long
#define beg(i ,n) for(int i=0;i<n;i++)
#define beg1(i ,n) for(int i=1;i<n;i++)
#define fast ios_base::sync_with_stdio(0);cin.tie(NULL);cout.tie(NULL)
#define pb push_back 
#define mp make_pair
#define nl "\n" 
#define vec(v , n) vector<ll> v(n)
#define all(x) x.begin() , x.end()
#define pii pair<int , int>
#define pll pair<ll , ll>
#define mii map<int , int>
#define mll map<ll , ll>
#define msi map<string , int>
#define mci map<char , int>
#define f1 first
#define f2 second
 
//---------------------------------------------------GLOBAL----------------------------------------------------------
const ll MOD = 1e9 + 7 ;
const ll MAX = 1e5 + 7 ;
//---------------------------------------------------FUNCTIONS-------------------------------------------------------

ll dp[1001][1001] ;

void solve(){
	memset(dp , 0 , sizeof(dp)) ;
	ll n, m ;
	cin >> n >> m ;
	string ar[n+1] , a ;
	beg1(i , n+1) cin >> a , ar[i] = " " + a ;
	dp[1][1] = 1 ;
	beg1(i , n+1){
		beg1(j  , m+1){
			if(ar[i][j]=='.'){
				if(i==1 && j==1){
					continue ;
				}
				dp[i][j] = (dp[i-1][j] + dp[i][j-1])%MOD ;
				//cout << i << " " << j <<  " " << dp[i][j] << nl ;
			}
		}
	}
	cout << dp[n][m] ;
}
 
//---------------------------------------------------DRIVER----------------------------------------------------------
int main()
{
    fast ;
    int t=1 ;
    //cin >> t ;
    while(t--){
        solve() ;
    }
    return 0;
}	

Measured memory_bytes: 9088
#include<iostream>
#include<stdio.h>
#include<algorithm>
#include<string>
#include<cmath>
#include<vector>
#include<functional>
#include<stack>
#include<utility>
#include<map>
#include<queue>

using namespace std;

int main() {
	int n, m, a[50], b[50], c[50], d[50];
	cin >> n >> m;
	for (int i = 0; i < n; i++)cin >> a[i] >> b[i];
	for (int i = 0; i < m; i++)cin >> c[i] >> d[i];
	for (int i = 0; i < n; i++) {
		int min = 1000000000, k;
		for (int j = 0; j < m; j++) {
			int l = abs(c[j] - a[i]) + abs(d[j] - b[i]);
				if (l < min) {
					min = l;
					k = j + 1;
				}
		}
		cout << k << endl;
	}
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <map>
#include <stack>
#include <queue>
#include <iomanip>
#include <set>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;

int main()
{
    int n;
    string s;
    cin >> n >> s;
    int ans = 0;
    for (int i = 0; i < 10; ++i)
    {
        for (int j = 0; j < 10; ++j)
        {
            for (int k = 0; k < 10; ++k)
            {
                string v;
                v.push_back(i + '0'), v.push_back(j + '0'), v.push_back(k + '0');
                int p0 = -1, p1 = -1, p2 = -1;
                for (int idx = 0; idx < s.size(); ++idx)
                {
                    if (s[idx] == v[0] && p0 == -1)
                    {
                        p0 = idx;
                        continue;
                    }
                    else if (s[idx] == v[1] && p0 >= 0 && p1 == -1)
                    {
                        p1 = idx;
                        continue;
                    }
                    else if (s[idx] == v[2] && p1 >= 0)
                    {
                        p2 = idx;
                        continue;
                    }
                }
                if (p0 >= 0 && p1 > p0 && p2 > p1)
                {
                    //cout << s[p0] << s[p1] << s[p2] << endl;
                    ++ans;
                }
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 3676
#include<bits/stdc++.h>
#include<stdio.h>
#include<string.h>
#define MAXN 100005
#define mod 1000000007
typedef long long ll; 
using namespace std;
//vector<ll> arr;
ll arr[MAXN];
ll book[MAXN];
ll dp[MAXN];
int main(){
    memset(dp,0,sizeof(dp));
    memset(book,0,sizeof(book));
    ll n;
    char x;
    ll y;
    cin >> n;
    //arr.resize(n);
    for(ll i=1;i<=n;i++){
        cin >> x;
        y=x-'a'+1;
        arr[i]=y;
    }   
    sort(arr+1,arr+n+1);
    for(ll i=1;i<=n;i++){
        if(!book[arr[i]]){
            dp[i]=(2*dp[i-1]+1)%mod;
        }
        else{
            int t=book[arr[i]];
            dp[i]=(dp[i-1]*2%mod+mod-dp[t-1]%mod)%mod;
        }
         book[arr[i]]=i;
    }   
    printf("%lld\n",dp[n]%mod);
return 0;
}


Measured memory_bytes: 2560
#include <bits/stdc++.h>
using namespace std;
const long long int MOD = 1e9 + 7;

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

    vector<long long int> alphabet(26);
    for(int i=0; i<n; i++){
        alphabet[s[i] - 'a'] += 1;
    }

    long long int ans = 1;
    for(int i=0; i<26; i++){
        ans *= (alphabet[i] + 1);
        ans %= MOD;
    }
    ans -= 1;
    ans = (ans % MOD + MOD) % MOD;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3752
#pragma comment (linker, "/STACK:256000000")
#define  _CRT_SECURE_NO_WARNINGS
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <math.h>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <math.h>
#include <iostream>
#include <random>
#include<map>
#include <iomanip>
#include <time.h>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include<fstream>
#include <unordered_map>
#include <unordered_set>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>

using namespace std;
typedef string::const_iterator State;
const long double Ma_PI = 3.1415926535897932384626433832795028841971L;
#define eps 1e-7
#define LONG_INF 2000000000000000000LL
#define GOLD 1.61803398874989484820458
#define MAX_MOD 1000000007LL
#define GYAKU 500000004LL

#define MOD 998244353LL
#define seg_size 262144*2
#define pb push_back
#define mp make_pair
typedef long long ll;
#define REP(a,b) for(long long a = 0;a < b;++a)
#define ALL(x) (x).begin(),(x).end()
void init() {
    iostream::sync_with_stdio(false);
    cout << fixed << setprecision(20);
}
unsigned long xor128() {
    static unsigned long x = 123456789, y = 362436069, z = 521288629, w = 88675123;
    unsigned long t = (x ^ (x << 11));
    x = y; y = z; z = w;
    return (w = (w ^ (w >> 19)) ^ (t ^ (t >> 8)));
}
typedef struct BigInt{
    string s = "0";
    BigInt operator +(BigInt obj) {
        string c;
        while (max(obj.s.length(), this->s.length()) + 1 > c.length()) {
            c.pb('0');
        }
        for (int q = 0; q < obj.s.length(); ++q) {
            c[c.length() - 1 - q] = obj.s[obj.s.length() - q - 1];
        }
        for (int q = 0; q < this->s.length(); ++q) {
            c[c.length() - 1 - q] += this->s[this->s.length() - 1 - q] - '0';
            if (c[c.length() - 1 - q] > '9') {
                c[c.length() - 2 - q]++;
                c[c.length() - 1 - q] -= 10;
            }
        }
        if (c.front() == '0') {
            c.erase(c.begin());
        }
        return BigInt{ c };
    }
    BigInt operator *(BigInt obj) {
        BigInt ans;
        for (int i = this->s.length() - 1; i >= 0; --i) {
            REP(q, this -> s[i] - '0') {
                ans = ans + obj;
            }
            obj.s.pb('0');
        }
        return ans;
    }
}BigInt;

int cnt[200000] = {};
int ok[200000] = {};
void solve() {
    int n, m;
    cin >> n >> m;
    int ans[2] = {};
    REP(i, m) {
        int a;
        cin >> a;
        string s;
        cin >> s;
        if (s == "AC") {
            if (ok[a] == 0) {
                ok[a] = 1;
                ans[0]++;
                ans[1] += cnt[a];
            }
        }
        else {
            cnt[a]++;
        }
    }
    cout << ans[0] << " " << ans[1] << endl;
}

int main() {
    init();
    solve();
}

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

int main() {
	int box[3][8] = {
		{ 1,3,5,7,8,10,12 },
		{ 4,6,9,11 },
		{ 2 }
	};
	int TF;
	int x, y;
	int n;
	cin >> x >> y;
	for (int i = 0; i < 3; i++) {
		TF = 0;
		for (int j = 0; j < 8; j++) {
			if (x == box[i][j] || y == box[i][j]) {
				TF++;
			}
		}
		if (TF == 2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N;
  cin >> N;
  vector<string> W(N);
  cin >> W[0];
  bool res = true;
  for (int i = 1; i < N; i++){
    cin >> W[i];
    for (int j = 0; j < i; j++) if (W[j] == W[i]) res = false;
    if (W[i][0] != W[i - 1][W[i - 1].size() - 1]) res = false;
  }
  cout << (res ? "Yes" : "No");
}

Measured memory_bytes: 256
#include <cmath>
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <set>
#include <map>
#include <list>
#include <time.h>
#include <math.h>
#include <random>
#include <deque>
#include <queue>
#include <cassert>
#include <unordered_map>
#include <unordered_set>
#include <iomanip>
#include <bitset>
#include <sstream>

using namespace std;

typedef long long ll;

mt19937 rnd(228);

const int M = 1791791791;
const int M1 = 1e9 + 7;
const int M2 = 1e9 + 9;
const int B = 239;
const int B1 = 228;
const int B2 = 337;

inline int add(ll a, ll b, int M)
{
    a += b;
    if (a >= M) a -= M;
    if (a < 0) a += M;
    return a;
}

inline int mul(int a, int b, int M)
{
    return (a * (ll) b) % M;
}

inline int bin(int a, int n, int M)
{
    int res = 1;
    while (n)
    {
        if (n % 2 == 0)
        {
            a = mul(a, a, M);
            n /= 2;
        }
        else
        {
            res = mul(res, a, M);
            n--;
        }
    }
    return res;
}

const int rev_B = bin(B, M - 2, M);
const int rev_B1 = bin(B1, M1 - 2, M1);
const int rev_B2 = bin(B2, M2 - 2, M2);

string s;
int n;

int main()
{
#ifdef ONPC
    freopen("a.in", "r", stdin);
#endif
    ios::sync_with_stdio(0);
    cin.tie(0);
    cin >> n;
    cin >> s;
    int cur = 1;
    int hsh = 0;
    vector <int> p(n + 1);
    vector <int> p1(n + 1);
    vector <int> p2(n + 1);
    vector <int> h(n + 1);
    vector <int> h1(n + 1);
    vector <int> h2(n + 1);
    p[0] = 1;
    p1[0] = 1;
    p2[0] = 1;
    h[0] = 0;
    h1[0] = 0;
    h2[0] = 0;
    int cur_1 = 1;
    int hsh_1 = 0;
    int cur_2 = 1;
    int hsh_2 = 0;
    for (int i = 0; i < n; i++)
    {
        if (s[i] == '>')
        {
            cur = mul(cur, B, M);
            cur_1 = mul(cur_1, B1, M1);
            cur_2 = mul(cur_2, B2, M2);
        }
        else if (s[i] == '<')
        {
            cur = mul(cur, rev_B, M);
            cur_1 = mul(cur_1, rev_B1, M1);
            cur_2 = mul(cur_2, rev_B2, M2);
        }
        else if (s[i] == '+')
        {
            hsh = add(hsh, cur, M);
            hsh_1 = add(hsh_1, cur_1, M1);
            hsh_2 = add(hsh_2, cur_2, M2);
        }
        else
        {
            hsh = add(hsh, -cur, M);
            hsh_1 = add(hsh_1, -cur_1, M1);
            hsh_2 = add(hsh_2, -cur_2, M2);
        }
        p[i + 1] = cur;
        h[i + 1] = hsh;
        p1[i + 1] = cur_1;
        h1[i + 1] = hsh_1;
        p2[i + 1] = cur_2;
        h2[i + 1] = hsh_2;
    }
    ll ans = 0;
    map <pair <int, pair <int, int> > , int> ret;
    for (int i = n; i >= 0; i--)
    {
        int need = add(mul(hsh, p[i], M), h[i], M);
        int need_1 = add(mul(hsh_1, p1[i], M1), h1[i], M1);
        int need_2 = add(mul(hsh_2, p2[i], M2), h2[i], M2);
        ans += ret[{need, {need_1, need_2}}];
        ret[{h[i], {h1[i], h2[i]}}]++;
    }
    cout << ans << '\n';
}


Measured memory_bytes: 37652
#include <iostream>
#include <string>
#include <vector>
using namespace std;
#define D

#ifdef A
int main(void)
{
	const int thousand = 1000;
	string hello = "Hello World\n";
	for (size_t i = 0; i < thousand; i++)
	{
		cout << hello;

	}
	return 0;
}


#endif // A

#ifdef B
#define _MAX 10000
int main(void)
{
	vector<int> arr(_MAX);
	int in = -1;
	for (size_t i = 0; i < _MAX && in != 0; i++)
	{
		cin >> in;
		arr[i] = in;

	}

	for (size_t i = 0; i < _MAX; i++)
	{
		if (arr[i] == 0)break;
		cout << "Case " << i + 1 << ": " << arr[i] << endl;
	}

	return 0;
}
#endif // B


#ifdef C
#define _MAX 10000
int main(void)
{
	int x, y;
	vector<pair<int, int> > arr(_MAX);
	pair<int, int> dis;
	dis.first = -1;
	for (size_t i = 0; i < _MAX && (dis.first != 0 || dis.second != 0); ++i)
	{
		cin >> dis.first >> dis.second;
		if (dis.first > dis.second)
			swap(dis.first, dis.second);
		arr[i] = dis;
	}
	for (size_t i = 0; i < _MAX && (arr[i].first != 0 || arr[i].second != 0); ++i)
	{
		cout << arr[i].first << " " << arr[i].second << endl;

	}


	return 0;
}
#endif // C

#ifdef D
#define _MAX 10000
int main(void)
{
	int a, b, c;
	int ans = 0;
	cin >> a >> b >> c;
	b++;
	for (size_t i = a; i < b; i++)
	{
		if (c % i == 0) ans++;
	}

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

#endif // D

Measured memory_bytes: 3076
c = [list(map(int, input().split())) for _ in range(3)]

for i in range(2):
    for j in range(2):
        d = c[i][j] - c[i+1][j]
        e = c[i][j+1] - c[i+1][j+1]
        if d != e:
            print("No")
            exit(0)

for i in range(2):
    for j in range(2):
        d = c[i][j] - c[i][j+1]
        e = c[i+1][j] - c[i+1][j+1]
        if d != e:
            print("No")
            exit(0)

print("Yes")


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

#define rep(i, m, n) for(int i=int(m);i<int(n);i++)
#define EACH(i, c) for (auto &(i): c)
#define all(c) begin(c),end(c)
#define EXIST(s, e) ((s).find(e)!=(s).end())
#define SORT(c) sort(begin(c),end(c))
#define pb emplace_back
#define MP make_pair
#define SZ(a) int((a).size())

//#define LOCAL 0
//#ifdef LOCAL
//#define DEBUG(s) cout << (s) << endl
//#define dump(x)  cerr << #x << " = " << (x) << endl
//#define BR cout << endl;
//#else
//#define DEBUG(s) do{}while(0)
//#define dump(x) do{}while(0)
//#define BR
//#endif


//改造
typedef long long int ll;
using namespace std;
#define INF (1 << 30)
#define INFl (ll)5e15
#define DEBUG 0 //デバッグする時1にしてね
#define dump(x)  cerr << #x << " = " << (x) << endl
#define MOD 1000000007
//ここから編集する


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

    int A,B,N;
    cin >> N >> A >> B;
    if((B-A) % 2 == 0){
        cout << "Alice" << endl;
    }else{
        cout << "Borys" << endl;
    }


    return 0;
}


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

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

Measured memory_bytes: 640
#include<bits/stdc++.h>
#include<math.h>
using namespace std;
typedef long long ll;
const int INF = 1<<30;

int main(){
  int a, b, c, x;cin>>a>>b>>c>>x;
  x/=50;// a: 10 b: 2 c: 1
  int ans=0;
  for(int i=0;i<=a;i++){
    for(int j=0;j<=b;j++){
      int rest = x-i*10-j*2;
      ans += int(0<=rest && rest<=c);
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define va first
#define vb second
using namespace std;
typedef long long ll;
typedef pair<int,int> pii;
const int MN = 1e5+5;

void impos()
{
    cout << "No";
    exit(0);
}

int main()
{
    ios_base::sync_with_stdio(0),cin.tie(0);
    string S;
    int N;
    cin >>S;
    N = S.size();
    for(int i=0; i<N; i++){
        if(S[i]!=S[N-1-i]) impos();
    }
    for(int i=0; i<(N-1)/2; i++){
        if(S[i]!=S[(N-1)/2-1-i]) impos();
    }
    for(int i=(N+3)/2-1; i<N; i++){
        if(S[i]!=S[N+(N+3)/2-2-i]) impos();
    }
    cout << "Yes";
}


Measured memory_bytes: 256
import collections
N = int(input())
A = list(map(int, input().split()))
c = collections.Counter(A)
def main():
    if c[0] >0:
        print(0)
        return

    ans = 1
    for a in A:
        ans *= a
        if ans > 1e18:
            ans = -1
            break
    if ans > 1e18:
        ans = -1
    print(ans)
main()

Measured memory_bytes: 96300
#include<bits/stdc++.h>
#define pb push_back
#define fast ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0)
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define f first
#define s second
#define int long long
#define sz(x) (ll)(x.size())
using namespace std;


const int mod = 1e9+7;

int expo_pow(int x,int y){
 if(y == 0) return 1;
  y=y%(mod-1);
  x%=mod;
  if(y==0) y=mod-1;
  int res=1;
  while(y){
    if(y&1) res=(res*x)%mod;
    x=(x*x)%mod;
    y>>=1; 
  }
  return res;
}

ll add()
{
    return 0;
}

template <typename T, typename... Types>
T add(T var1, Types... var2){
    return (((((ll)(var1)) % mod + (ll)(add(var2...))) % mod) + mod) % mod;
}

ll mul(){
    return 1;
}

template <typename T, typename... Types>
T mul(T var1, Types... var2){
    return (((ll)(var1)) % mod * (ll)(mul(var2...))) % mod;
}
const int inf = 9223372036854775807;
vector<int> val,perm;
int n,k;

int get(vector<int>& a) {
  int n = a.size();
  
  int total =  0;
  for (int i = 0; i < n; ++i) total += a[i];

  int ans = -inf;
  for(int i = 0;i < n; ++i) {
    int tot = 0;
    for(int j = 0;j < n; ++j) {
      tot += a[(i + j)%n];
      if(j+1 > k) break;
      int muli = (k - j -1)/n;
      ans = max(tot + max(total*muli,0LL),ans);
    }
  }
  return ans;
}

void solve(){
  cin >> n >> k;
  val.resize(n+1);
  perm.resize(n+1);
  int visited[n+1] = {0};

  for (int i = 1; i <= n; ++i) {
    cin >> perm[i];
  }
  
  for (int i = 1; i <= n; ++i) {
    cin >> val[i];
  }
  
  int ans = -inf;
  for (int i = 1; i <= n; ++i) {
    if (visited[i] != 1) {
      vector<int> tmp;
      int cur = perm[i];
      while(cur!=i) {
        visited[cur] = 1;
        tmp.pb(val[cur]);
        cur = perm[cur];
      }
      visited[i] = 1;
      tmp.pb(val[i]);
      ans = max(ans,get(tmp));
    }
  }
  cout << ans << "\n";
}


signed main(){
//  fast;
  int test = 1;
  int i=1;
  while(test--){
    solve();
  }
}





Measured memory_bytes: 3840
use std::io;

fn main() {
    let mut s = String::new();
    io::stdin().read_line(&mut s).unwrap();
    s = s.trim().to_string();

    let mut t: Vec<String> = vec![];

    loop {
        let mut s = String::new();
        io::stdin().read_line(&mut s).unwrap();
        if s.find("END_OF_TEXT") != None {
            break;
        }

        for term in s.to_lowercase().trim().split_whitespace() {
            t.push(term.to_string())
        }
    }

    let mut ans = 0;

    for term in t {
        if term == s {
            ans += 1;
        }
    }

    println!("{}", ans);
}



Measured memory_bytes: 5052
#![allow(unused_imports)]
#![allow(unused_macros)]
use std::cmp::{max, min};
use std::collections::*;
use std::io::{stdin, Read};

trait ChMinMax {
    fn chmin(&mut self, other: Self);
    fn chmax(&mut self, other: Self);
}
impl<T> ChMinMax for T
where
    T: PartialOrd,
{
    fn chmin(&mut self, other: Self) {
        if *self > other {
            *self = other
        }
    }
    fn chmax(&mut self, other: Self) {
        if *self < other {
            *self = other
        }
    }
}

#[allow(unused_macros)]
macro_rules! parse {
    ($it: ident ) => {};
    ($it: ident, ) => {};
    ($it: ident, $var:ident : $t:tt $($r:tt)*) => {
        let $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, mut $var:ident : $t:tt $($r:tt)*) => {
        let mut $var = parse_val!($it, $t);
        parse!($it $($r)*);
    };
    ($it: ident, $var:ident $($r:tt)*) => {
        let $var = parse_val!($it, usize);
        parse!($it $($r)*);
    };
}

#[allow(unused_macros)]
macro_rules! parse_val {
    ($it: ident, [$t:tt; $len:expr]) => {
        (0..$len).map(|_| parse_val!($it, $t)).collect::<Vec<_>>();
    };
    ($it: ident, ($($t: tt),*)) => {
        ($(parse_val!($it, $t)),*)
    };
    ($it: ident, u1) => {
        $it.next().unwrap().parse::<usize>().unwrap() -1
    };
    ($it: ident, $t: ty) => {
        $it.next().unwrap().parse::<$t>().unwrap()
    };
}

#[cfg(debug_assertions)]
macro_rules! debug {
    ($( $args:expr ),*) => { eprintln!( $( $args ),* ); }
}

#[cfg(not(debug_assertions))]
macro_rules! debug {
    ($( $args:expr ),*) => {
        ()
    };
}

fn solve(s: &str) {
    let mut it = s.split_whitespace();
    parse!(it, r: usize, c: usize, k: usize);
    let mut board = vec![vec![0; c]; r];
    let ns = 4;
    for _ in 0..k {
        parse!(it, r: u1, c: u1, v: usize);
        board[r][c] = v;
    }
    let mut dp = vec![vec![0; ns]; c];
    for i in 0..r {
        for j in 0..c {
            dp[j][0] = *dp[j].iter().max().unwrap();
            let v = board[i][j];
            if v > 0 {
                let tmp = dp[j][0] + v;
                dp[j][1].chmax(tmp);
            }
            for k in 0..ns {
                if j > 0 {
                    let tmp = dp[j - 1][k];
                    dp[j][k].chmax(tmp);
                    if k > 0 && v > 0 {
                        let tmp = dp[j - 1][k - 1] + v;
                        dp[j][k].chmax(tmp)
                    }
                }
            }
        }
    }
    println!("{}", dp[c - 1].iter().max().unwrap());
}

fn main() {
    let mut s = String::new();
    stdin().read_to_string(&mut s).unwrap();
    solve(&s);
}

#[cfg(test)]
mod tests {
    use super::*;
    #[test]
    fn test_input() {
        let s = "
        ";
        solve(s);
    }
}


Measured memory_bytes: 76372
/// In The Name Of God
/// I wish, that I could leave it all behind me / Go to my own world where no one can find me
#include<bits/stdc++.h>

using namespace std;

#define F first
#define S second
#define mp make_pair
#define pb push_back
#define int long long
#define ll long long
#define pii pair <int , int>
#define ld long double
#define for2(a,b,c) for(int (a) = (b); (a) < (c); (a)++)
#define setp cout << fixed << setprecision(15)
#define endl "\n"
#define minit(a,b) a = min(a,b)
#define maxit(a,b) a = max(a,b)
#define PII pair<int,int>
#define Vec vector<int>
#define error(x) cerr << #x << " = " << (x) << endl;
#define all(x) (x).begin() , (x).end()

const int maxn = 718;
bool a[maxn][maxn];
int seen[maxn];
vector<PII> w;
PII sz;
int tmp[maxn];
int dp[maxn];
int n;

void dfs(int root,bool h = 0){
    seen[root] = h+1;
    if(h) sz.F ++;
    else sz.S++;
    for2(i,0,n) if(!a[root][i] && !seen[i]) dfs(i,!h);
                else if(!a[root][i] && seen[i] == seen[root] && root != i){
                    cout << -1 << endl;
                    exit(0);
                }
}

int32_t main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    int m; cin >> n >> m;
    for2(i,0,m){
        int v,u; cin >> v >> u; v-- ,u--;
        a[v][u] = a[u][v] = 1;
    }
    for2(i,0,n) if(!seen[i]){
        sz = {0,0};
        dfs(i);
        w.pb(sz);
    }
    dp[0] = 1;
    for(auto x : w){
        for2(i,0,maxn){
            if(i >= x.F) tmp[i] |= dp[i-x.F];
            if(i >= x.S) tmp[i] |= dp[i-x.S];
        }
        for2(i,0,maxn) dp[i] = tmp[i],tmp[i]=0;
    }
    int ans = n*n;
    for2(i,0,n+1) if(dp[i]) ans = min(ans,(i*(i-1)/2) + (n-i)*(n-i-1)/2 );
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 768
#include<iostream>

using namespace std;

int main(){
 int n;
   cin >> n;
  int res=n;
  
  for(int i=0;i<=n;i++){
    int cnt=0;
    int t=i;
     while(t>0) {
       cnt+=(t%6); 
       t/=6;
     }
       t=n-i;
     while(t>0) {
       cnt+=(t%9); 
       t/=9;
     }
   res=min(res,cnt);
  }
  
  cout << res << endl;
}

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

using namespace std;

const int maxn=105;

char s[maxn];
int h, w;
int cnt[maxn];

int main()
{
    while(~scanf("%d %d", &h, &w)){
        memset(cnt, 0, sizeof(cnt));
        for(int i=0;i<h;i++){
            scanf("%s", &s);
            int len=strlen(s);
            for(int i=0;i<len;i++){
                cnt[s[i]-'a']++;
                cnt[s[i]-'a']%=4;
            }
        }
        int one=0, two=0;
        for(int i=0;i<26;i++){
            if(cnt[i]==1)one++;
            if(cnt[i]==2)two++;
            if(cnt[i]==3){
                one++;
                two++;
            }
        }
        //cout<<one<<"  "<<two<<endl;
        if(h%2&&w%2){   //奇*奇
            int max2=h/2+w/2;
            if(one==1&&two<=max2){
                printf("Yes\n");
            }
            else printf("No\n");
        }
        else if(h%2==0&&w%2==0){    //偶*偶
            if(one==0&&two==0){
                printf("Yes\n");
            }
            else printf("No\n");
        }
        else{
            int max2;
            if(h%2==1)max2=w/2;
            else max2=h/2;
            if(one==0&&two<=max2){
                printf("Yes\n");
            }
            else printf("No\n");
        }
    }
    return 0;
}


Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#include <iomanip>
#include <string>
#include <queue>
#include <stack>
#include <vector>
#include <set>
#include <map>
#include <unordered_map>
#include <algorithm>
#include <utility>
#include <cmath>
#include <climits>

#define ll long long int
#define pb push_back
#define mk make_pair
#define pq priority_queue

using namespace std;
typedef pair<int, int> P;
typedef pair<ll, int> Pl;
typedef pair<ll, ll> Pll;
const int inf = 1e9;
const ll linf = 1LL << 50;
const double EPS = 1e-10;
const int mod = 1e9 + 7;

int main(int argc, char const* argv[])
{
  int n;
  cin >> n;
  string s[2];
  cin >> s[0];
  cin >> s[1];
  vector<int> vec;
  int i = 0;
  while(i < n){
    if(s[0][i] == s[1][i]){
      vec.pb(0);
      i++;
    }else{
      vec.pb(1);
      i += 2;
    }
  }
  ll res = 1;
  if(vec[0] == 0)res = 3;
  else res = 6;
  for(int j = 1; j < vec.size(); j++){
    if(vec[j - 1] == 0 && vec[j] == 0)res = res * 2 % mod;
    else if(vec[j - 1] == 0 && vec[j] == 1)res = res * 2 % mod;
    else if(vec[j - 1] == 1 && vec[j] == 0)res = res % mod;
    else if(vec[j - 1] == 1 && vec[j] == 1)res = res * 3 % mod;
  }
  cout << res << endl;
	return 0;
}


Measured memory_bytes: 384
//uvwzyx
//uvwyzx
#include<bits/stdc++.h>
using namespace std;
int main(){
string s;cin>>s;
//if atleast is not there, then it is easy
  vector<int >nos(26,-1);
  for(int i=0;i<s.size();i++){
  	nos[s[i]-'a']=i;
  }
  //if anything is -1
  int repl=-1;
  for(int i=0;i<26;i++)if(nos[i]==-1){repl=i;break;}
  if(repl!=-1){cout<<s;cout<<(char)('a'+repl);}
  else{
  	for(int i=s.size()-1;i>0;i--){
    	if(s[i]>s[i-1]){
        	//swapping has to work
          	
            	//something special
              for(int j=0;j<i-1;j++)cout<<s[j];
              repl=-1;
              for(int j=0;j<26;j++){
              	if(('a'+j > s[i-1] ) && nos[j]>=i){repl=j;break;}
              }
              if(repl==-1)break;
              cout<<(char)('a'+repl);
              return 0;
            }
          
    }
    cout<<-1;
  }
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define fastIO ios::sync_with_stdio(0), cin.tie(0)
#define endl '\n'
typedef long long ll;

int main() {
    #ifndef LOCAL
        fastIO;
    #endif
    int n,x;
    cin >> n >> x;
    int l[n+1];
    vector<int> d;
    d.push_back(0);
    for(int i=1;i<n+1;i++){
        cin >> l[i];
    }
    for(int i=1;i<n+1;i++){
        if(l[i]+d[i-1]>x) break;
        else{
            d.push_back(l[i]+d[i-1]);
        }
    }
    cout << (int)d.size() << endl;
    return 0;
}


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

using namespace std;

using ll = long long;

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

    ll N, W;
    cin >> N >> W;

    ll w0 = 0;
    vector<vector<ll>> v(4);
    for (int i = 0; i < N; ++i) {
        ll tw, tv;
        cin >> tw >> tv;
        if (i == 0) w0 = tw;
        v[tw - w0].push_back(tv);
    }

    for (int i = 0; i < 4; ++i)
        sort(v[i].begin(), v[i].end(), greater<ll>());

    array<int, 4> size;
    for (int i = 0; i < 4; ++i) size[i] = v[i].size();
    for (int i = 0; i < 4; ++i)
        for (int j = 1; j < size[i]; ++j)
            v[i][j] += v[i][j - 1];

    ll max_v = 0;
    for (int i1 = 0; i1 <= size[0]; ++i1) {
        for (int i2 = 0; i2 <= size[1]; ++i2) {
            for (int i3 = 0; i3 <= size[2]; ++i3) {
                for (int i4 = 0; i4 <= size[3]; ++i4) {
                    ll sum_w = w0 * (i1 + i2 + i3 + i4) + i2 + 2 * i3 + 3 * i4;

                    if (W < sum_w) continue;
                    ll sum_v = 0;
                    if (0 < i1) sum_v += v[0][i1 - 1];
                    if (0 < i2) sum_v += v[1][i2 - 1];
                    if (0 < i3) sum_v += v[2][i3 - 1];
                    if (0 < i4) sum_v += v[3][i4 - 1];
                    max_v = max(max_v, sum_v);
                }
            }
        }
    }

    cout << max_v << endl;

    return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:> 
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */

const ll MOD = 1e9+7;

/* 素因数分解 */
vector<ll> PrimeFact(ll n){
    vector<ll> res;
    while(n!=1){
        if(n == 2 || n == 3){
            res.emplace_back(n); n/=n;
            continue;
        }
        bool prime_flag = false;
        for(int i = 2;i*i <= n;i++){
            if(n%i==0){
                res.emplace_back(i); n/=i;
                prime_flag = true;
                break;
            }
        }
        if(!prime_flag){res.emplace_back(n); n/= n;}
    }
    return res;
}

int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    ll N; cin >> N;
    ll ans = 1;
    map<ll,ll> mp;
    for(int i = 1; i <= N;i++){
        auto pf = PrimeFact(i);
        for(auto  v:pf) mp[v]++;
    }
    for(auto v:mp){
        (ans *= (v.second+1))%=MOD;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<iostream>
#include<algorithm>
#include<cmath>
using namespace std;
int main() {
	int h, w; cin >> h >> w;
	int ar[30][30];
	for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)cin >> ar[i][j];
	int ans = 1600000;
	for (int a = 0; a < h; a++)for (int b = 0; b < w; b++) {
		int cnt = 0;
		for (int i = 0; i < h; i++)for (int j = 0; j < w; j++)cnt += min(abs(a - i), abs(b - j))*ar[i][j];
		ans = min(ans, cnt);
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 3092
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define rep(i,n) for(int i=0, i##_len=(int)(n); i<i##_len; i++)
#define reps(i,n) for(int i=1 , i##_len=(int)(n);i<=i##_len;i++)
#define rrep(i,n) for(int i=((int)(n)-1);i>=0;i--)
#define rreps(i,n) for(int i=((int)(n));i>0;i--)
#define all(x) (x).begin(), (x).end()
#define F first
#define S second
#define mp make_pair
#define pb push_back
#define solve(a) ((a)?"Yes":"No")
typedef vector<long long> V;
typedef vector<V> VV;
typedef pair<long long , long long> P;
typedef vector<P> VP;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1;} return 0;}
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1;} return 0;}
const long long INFLL = 1LL<<62;
const int INF = 1<<30;
const double PI=acos(-1);
int func(int l,int r,vector<vector<int>>&dp,vector<int>&w){
	//clog << l << " " << r<<endl; 
	if (dp[l][r] == -1)
	{
		chmax(dp[l][r],0);
		if(r!=l+1){
			for(int med=l;med<r;med++){
				if (func(l+1, r-1, dp, w) ==r-l-1){
					if(abs(w[l]-w[r])<=1){
						dp[l][r]=r-l+1;
					}
				}
					chmax(dp[l][r], func(l, med, dp, w) + func(med + 1, r, dp, w));
			}
		}else if(l!=r){
			if(abs(w[l]-w[r])<=1){
				dp[l][r]=2;
			}
		}
	}
//	clog << l << " " << r << " ->  " << dp[l][r] << endl;
	return dp[l][r];
}
int main(){
	int n=1;
	vector<vector<int>>dp(310,vector<int>(310,-1));
	vector<int>w(310,-2);
	while(1){
	rep(i,n){
		rep(j,n){
			dp[i][j]=-1;
		}
		w[i]=-2;
	}
	cin >>n;
	if(n==0){
		break;
	}
	rep(i,n){
		cin>>w[i];
	}

	cout<<func(0,n-1,dp,w)<<endl;
	}
}


Measured memory_bytes: 3352
#include <stdio.h>
#include <math.h>
double sqr(double a)
{
    return a * a;
}
int main(void)
{
    double x1, y1, x2, y2;

    scanf("%lf %lf %lf %lf", &x1, &y1, &x2, &y2);


    printf("%lf\n", sqrt(sqr(x1 - x2) + sqr(y1 - y2)));

    return 0;
}


Measured memory_bytes: 2696
// 2011/06/23 Tazoe

#include <iostream>
using namespace std;

int main()
{
	while(true){
		int a[4];
		cin >> a[0];
		if(cin.eof())
			break;
		for(int i=1; i<4; i++)
			cin >> a[i];
		int b[4];
		for(int i=0; i<4; i++)
			cin >> b[i];

		int hit = 0;
		int blw = 0;
		for(int i=0; i<4; i++)
			for(int j=0; j<4; j++)
				if(a[i]==b[j])
					if(i==j)
						hit++;
					else
						blw++;

		cout << hit << ' ' << blw << endl;
	}

	return 0;
}

Measured memory_bytes: 0
//Totka hai dosto
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
#define int ll
const int mod=1e9+7;
const int N=1e5+6;
vector<int> adj[N];
int fact[N];
int ans;
int n,k;
void dfs(int node, int par)
{
	int color=k-1;
	if(par!=0)color--;
	for(auto u:adj[node])
	{
		if(u==par)continue;
		if(color<=0)
		{
			ans=0;return;
		}
		ans=(ans*color)%mod;
		color--;
		dfs(u,node);
	}
}
int32_t main()
{
	int u,v;
	cin>>n>>k;
	ans=k;
	
	for(int i=1;i<n;i++)
	{
		cin>>u>>v;
		adj[u].push_back(v);
		adj[v].push_back(u);
	}
	
	dfs(1,0);
	cout<<ans;
	
	
}

Measured memory_bytes: 10368
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
#include <bitset>
typedef long long ll;
using namespace std;
typedef pair<int, int> P;
#define fs first
#define sc second

class Tree {
    struct edge {
        int to, id;
        edge(int to, int id) : to(to), id(id) {}
    };

public:
    int N, M;
    vector<P> uv;
    vector<ll> edges; //条件iが通るパス上の辺集合をbitで管理
    vector<vector<edge>> G;

    Tree(int N, int M) : N(N), M(M) {
        edges.resize(M);
        G.resize(N);
    }

    void add_edge(int s, int t, int id){
        G[s].push_back(edge(t, id));
        G[t].push_back(edge(s, id));
    }

    void add_rest(int u, int v){
        uv.push_back(P(u, v));
    }

    //sからtへのパス上の辺を求める(始点，終点，親，何番目の条件か)
    bool dfs(int n, int t, int par, int j){
        if(n == t){

            return true;
        }

        for(int i = 0; i < (int)G[n].size(); i++){
            edge e = G[n][i];
            int nx = e.to;
            if(nx == par) continue;

            if(dfs(nx, t, n, j)){
                edges[j] |= (1LL << e.id);
                return true;
            }
        }

        return false;
    }

    ll solve(){
        for(int i = 0; i < M; i++){
            dfs(uv[i].first, uv[i].second, -1, i);
        }

        /*for(int i = 0; i < M; i++){
            cout << bitset<30>(edges[i]) << endl;
        }*/

        ll ans = 0;
        for(int bit = 1; bit < (1 << M); bit++){
            ll e = 0; //bitで表される条件で白く塗られる辺の情報
            int cnt = 0;
            for(int i = 0; i < M; i++){
                if(bit & (1 << i)){
                    cnt++;
                    e |= edges[i];
                }
            }

            int p = 0; //白く塗る辺の数
            while(e > 0){
                if(e % 2 == 1) p++;
                e /= 2;
            }

            ll tmp = (1LL << (N - 1 - p));
            //cout << tmp << endl;
            if(cnt % 2 == 0){
                ans -= tmp;
            } else {
                ans += tmp;
            }
        }

        ans = (1LL << (N - 1)) - ans;
        return ans;
    }
};

int main(){
    int N;
    cin >> N;
    int a[N - 1], b[N - 1];
    for(int i = 0; i < N - 1; i++) cin >> a[i] >> b[i];
    int M;
    cin >> M;
    int u[M], v[M];
    for(int i = 0; i < M; i++) cin >> u[i] >> v[i];

    Tree tr = Tree(N, M);

    for(int i = 0; i < N - 1; i++){
        tr.add_edge(a[i] - 1, b[i] - 1, i);
    }

    for(int i = 0; i < M; i++){
        tr.add_rest(u[i] - 1, v[i] - 1);
    }

    cout << tr.solve() << endl;
    return 0;
}


Measured memory_bytes: 256