akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;

typedef long long ll;
string s1, s2;

string lcs(){
    int len1 = s1.size(), len2 = s2.size();
    int dp[len1+1][len2+1];
    for(int i=0; i<=len1; i++){
        for(int j=0; j<=len2; j++){
            if(i == 0 || j == 0) dp[i][j] = 0;
            else{
                if(s1[i-1] == s2[j-1]){
                    dp[i][j] = 1 + dp[i-1][j-1];
                }
                else dp[i][j] = max(dp[i-1][j], dp[i][j-1]);
            }
        }
    }
    int mx_len = dp[len1][len2];
    //cout << mx_len << endl;
    string ans = "";
    int first = len1, second = len2;
    while(len1 > 0 && len2 > 0){
        if(s1[len1-1] == s2[len2-1]){
            ans = s1[len1-1] + ans;
            --len1;
            --len2;
        }
        else if(dp[len1-1][len2] > dp[len1][len2-1]){
            --len1;
        }
        else --len2;
    }
    return ans;
}

int main(){
    cin >> s1 >> s2;
    cout << lcs() << endl;
}

Measured memory_bytes: 35456
#include <algorithm>
#include <cmath>
#include <cstdint>
#include <cstdio>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int(i) = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int(i) = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define pb push_back
#define MP(a, b) make_pair((a), (b))
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
const int INF = 1 << 30;
const ll LINF = 1LL << 60;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<int> A(N);
    rep(i, N) cin >> A[i];
    int win = 1;
    rep(i, N) if(A[i] % 2 == 1) win = 0;
    if(win) {
        cout << "second" << endl;
    } else {
        cout << "first" << endl;
    }
    return 0;
}

Measured memory_bytes: 640
import java.util.*;

/**
 * Base_version with sc.close()
 */ 

class Main { 
    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
      	int x = sc.nextInt();
      	int t = sc.nextInt();
      	sc.close();
        System.out.println(Math.max(x - t, 0));
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
#include <vector>
#include <string>
#include <stdio.h>
#include <math.h>
#include <cstdlib>
#include <iostream>
#include <cstdlib>
using namespace std;
using ll = long long;
const int INF = 1e9 + 5;

void max_self(ll& a, ll b){
    a= max(a, b);
}

int main(){
    ll N,W;
    cin>>N>>W;
    vector<ll> dp(W + 1);
    // dp[i] the maximum total value with weight exactly
    for(ll item =0; item < N; item++){
        ll weight, value;
        cin>>weight>>value;
        for(int weight_already = W - weight; weight_already >= 0; weight_already--){
            max_self(dp[weight_already + weight], dp[weight_already] + value);
        }
    }
    ll answer = 0;
    for(ll i = 0; i <= W; i++){
        max_self(answer, dp[i]);
    }
cout<<answer;

    return 0;
}



Measured memory_bytes: 1024
#include <iostream>
#include <string>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <queue>
#include <set>
#include <numeric>
#include <cmath>

using namespace std;

typedef long long int ll;

#define all(x) x.begin(),x.end()

const ll mod = 1e9+7;
const ll INF = 1e9;
const ll MAXN = 1e9;

int main()
{
	int n;
	cin >> n;
	int ans = 0;
	for(int i = 1; i <= n; i++){
		if(i%2!=0){
			int res = 0;
			for(int j = 1; j <= i; j++){
				if(i%j==0) res++;
			}
			if(res == 8) ans++;
		}
	}

	cout << ans << endl;

	return 0;
}

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

typedef long long ll;
typedef pair<int,int> pii;

long long MOD = 10000000000 + 7;
// modint
const ll mod = 1e9+7;
template< int mod >
struct ModInt {
  int x;
  ModInt() : x(0) {}
  ModInt(int64_t y) : x(y >= 0 ? y % mod : (mod - (-y) % mod) % mod) {}
  ModInt &operator+=(const ModInt &p) {
    if((x += p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator-=(const ModInt &p) {
    if((x += mod - p.x) >= mod) x -= mod;
    return *this;
  }
  ModInt &operator*=(const ModInt &p) {
    x = (int) (1LL * x * p.x % mod);
      return *this;
  }
  ModInt &operator/=(const ModInt &p) {
    *this *= p.inv();
    return *this;
  }
  ModInt operator-() const { return ModInt(-x); }
  ModInt operator+(const ModInt &p) const { return ModInt(*this) += p; }
  ModInt operator-(const ModInt &p) const { return ModInt(*this) -= p; }
  ModInt operator*(const ModInt &p) const { return ModInt(*this) *= p; }
  ModInt operator/(const ModInt &p) const { return ModInt(*this) /= p; }
  bool operator==(const ModInt &p) const { return x == p.x; }
  bool operator!=(const ModInt &p) const { return x != p.x; }
    
  ModInt inv() const {
    int a = x, b = mod, u = 1, v = 0, t;
    while(b > 0) {
      t = a / b;
      swap(a -= t * b, b);
      swap(u -= t * v, v);
    }
    return ModInt(u);
  }
  
  ModInt pow(int64_t n) const {
    ModInt ret(1), mul(x);
    while(n > 0) {
      if(n & 1) ret *= mul;
      mul *= mul;
      n >>= 1;
    }
    return ret;
  }
  
  friend ostream &operator<<(ostream &os, const ModInt &p) {
    return os << p.x;
  }
  
  friend istream &operator>>(istream &is, ModInt &a) {
    int64_t t;
    is >> t;
    a = ModInt< mod >(t);
    return (is);
  }
  
  static int get_mod() { return mod; }
};
 
using mint = ModInt<mod>;

template<typename T>
map<T, ll> prime_factorize(T x){
  map<T, ll> res;

  while(x%2==0){
    x/=2;
    res[2]++;
  }

  for(ll i=3;i*i<=x;i+=2){
    while(x%i==0){
      x/=i;
      res[i]++;
    }
  }
  if(x!=1) res[x]++;
  return res;
}


int main(){
  cout << setprecision(10);
  int N; cin >> N;
  vector<map<ll,ll>> v(N);
  vector<ll> A(N);

  map<ll,ll> x;
  for(int i = 0; i < N; i++){
    cin >> A[i];
    auto t = prime_factorize(A[i]);
    for(auto u: t){
      x[u.first] = max(x[u.first], u.second);
    }
  }

  mint val = 1;
  for(auto y: x){
    mint t = y.first;
    val *= t.pow(y.second);
  }

  mint ans = 0;
  for(auto a: A){
    mint t = a;
    ans += val * t.inv();
  }
  cout << ans << endl;

}


Measured memory_bytes: 4108
#include<bits/stdc++.h>
using namespace std;
const int N=100005;
int a[N],b[N],n,m,k,ma=1e9,mb=1e9,ans;
int main()
{
	scanf("%d%d%d",&n,&m,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&a[i]);
		ma=min(ma,a[i]);
	}
	for(int i=1;i<=m;i++)
	{
		scanf("%d",&b[i]);
		mb=min(mb,b[i]);
	}
	ans=ma+mb;
	for(int i=1;i<=k;i++)
	{
		int x,y,z;
		scanf("%d%d%d",&x,&y,&z);
		ans=min(ans,a[x]+b[y]-z);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 1024
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<queue>
#include<stack>
#include<list>

#define endl "\n"
using namespace std;
using ll = long long;
const ll MOD = 1e9+7;
const ll INF = 1e18;
#define REP(i, n) for(int i = 0; i < n; i++)
using Graph = vector<vector<int>>;

int main(){
    ll x;
    cin>>x;
    ll ans = x / 500 * 1000;
    if(x-x/500*500 >= 0){
        x -= x / 500 * 500;
        ans += x / 5 * 5;
    }
    else ans += x/5 * 5;

    cout<<ans<<endl;
}

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

cnt = 0
flg = 0

for i in range(n):
    a, b = map(int, input().split())

    if a == b:
        cnt += 1
        if cnt >= 3:
            flg = 1
    else:
        cnt = 0

if flg == 1:
    print("Yes")
else:
    print("No")


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

A = list(map(int, input().split()))
B = list(map(int, input().split()))
C = list(map(int, input().split()))

answer = sum(B)
for i in range(n - 1):
    if A[i] + 1 == A[i + 1]:
        answer += C[A[i] - 1]

print(answer)


Measured memory_bytes: 3060
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <queue>
#include <stack>
#include <cctype>
#include <cassert>
#include <climits>
#include <string>
#include <bitset>
#include <cfloat>
#include <random>
#include <iomanip>
#include <unordered_set>
using namespace std;
typedef long double ld;
typedef long long int ll;
typedef unsigned long long int ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<ll> vll;
typedef vector<pair<int,int> > vpii;
typedef vector<pair<ll,ll> > vpll;
typedef vector<vi> vvi;
typedef vector<vvi> vvvi;
typedef vector<vc> vvc;
typedef vector<vs> vvs;
typedef vector<vll> vvll;
typedef map<int,int> mii;
typedef set<int> si;
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define arep(i,v) for(auto i : v)
#define irep(it, stl) for(auto it = stl.begin(); it != stl.end(); it++)
#define drep(i,n) for(int i = (n) - 1; i >= 0; --i)
#define fin(ans) cout << (ans) << '\n'
#define STLL(s) strtoll(s.c_str(), NULL, 10)
#define mp(p,q) make_pair(p, q)
#define pb(n) push_back(n)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define Sort(a) sort(a.begin(), a.end())
#define Rort(a) sort(a.rbegin(), a.rend())
#define MATHPI acos(-1)
#define fi first
#define se second
constexpr int dx[8] = {1, 0, -1, 0, 1, -1, -1, 1};
constexpr int dy[8] = {0, 1, 0, -1, 1, 1, -1, -1};
template <class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;} return 0;}
template <class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;} return 0;}
template <class T> inline void dump(T &v){irep(i, v){cout<<*i<<((i==--v.end())?'\n':' ');}}
inline string getline(){string s; getline(cin,s); return s;}
inline void yn(const bool b){b?fin("yes"):fin("no");}
inline void Yn(const bool b){b?fin("Yes"):fin("No");}
inline void YN(const bool b){b?fin("YES"):fin("NO");}
struct io{io(){ios::sync_with_stdio(false);cin.tie(0);}};
const int INF = INT_MAX;
constexpr ll LLINF = 1LL<<60;
constexpr ll MOD = 1000000007;
constexpr double EPS = 1e-9;


int main() {
    
    
    map<string,ll> m;
    int n;
    cin>>n;
    rep(i,n){
        string s;
        cin>>s;
        Sort(s);
        m[s]++;
    }
    ll ans=0;
    irep(i,m){
        ans+=i->second*(i->second-1)/2;
    }
    fin(ans);
}








Measured memory_bytes: 11136
// Author: Jinhai Chen
#include <bits/stdc++.h>
typedef long long ll;
ll INF = 0x3f3f3f3f3f3f3f3f;
#define mst(a,x) memset(a,x,sizeof(a))
using namespace std;


int main() {
#ifdef CJHCJH
	freopen("data.in","r",stdin);
#endif
	ios::sync_with_stdio(false);
	int a,b,c;
	cin>>a>>b>>c;
	int ans = min(b/a,c);
	cout<<ans<<endl;
	return 0;
}















Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main(){
  int N,a,b,c;
  cin>>N;
  a=N/100;
  b=(N-a*100)/10;
  c=N-a*100-b*10;
  if(a==7 || b==7 || c==7){
    cout<<"Yes"<<endl;
  }
  else{
    cout<<"No"<<endl;
  }
}

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

typedef long long int ll;
typedef long double ld;
typedef pair<int,int> pi;
typedef pair<ll,ll> pll;

#define endl '\n'
#define ff first
#define ss second
#define sz(v) (int)v.size()
#define int long long
#define pb push_back
#define f(i,l,r) for(ll i=l;i<=r;i++)
#define rf(i,r,l) for(ll i=r;i>=l;i--)
#define Max 5000001
#define inf 2147483647
#define llinf 9223372036854775807
#define all(v) v.begin(),v.end()
#define bp(n) __builtin_popcountll(n)
#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)

#define d0(a) cout<<a<<' ';
#define d1(a) cout<<a<<endl;
#define d2(a,b) cout<<a<<' '<<b<<endl;
#define d3(a,b,c) cout<<a<<' '<<b<<' '<<c<<endl;
#define d4(a,b,c,d) cout<<a<<' '<<b<<' '<<c<<' '<<d<<endl;
#define d5(a,b,c,d,e) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<endl;
#define d6(a,b,c,d,e,f) cout<<a<<' '<<b<<' '<<c<<' '<<d<<' '<<e<<' '<<f<<endl;

const ll N=2e5+5,mod=1e9+7,bit=61;

ll ans[N],n,sub[N],fact,den;
vector<ll> adj[N];

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

void dfs(ll u,ll p)  // Find number of vertices in the subtree of u including it.
{
    sub[u]=1;
    for(auto v:adj[u])
    {
        if(v==p)
        {
            continue;
        }
        dfs(v,u);
        sub[u]+=sub[v];
    }
    den=(den * sub[u])%mod;
}

void solve(ll u,ll p)
{
    ans[u]=(powerm(den,mod-2)*fact)%mod;
    for(auto v:adj[u])
    {
        if(v==p)
        {
            continue;
        }
        // Go from u ---> v
        ll rem=(powerm(sub[u],mod-2)*powerm(sub[v],mod-2))%mod;
        sub[u]-=sub[v];  // Making v as a root of tree
        sub[v]+=sub[u];
        den=(den * sub[u])%mod;
        den=(den * sub[v])%mod;
        den=(den * rem)%mod;
        solve(v,u);
        rem=(powerm(sub[u],mod-2)*powerm(sub[v],mod-2))%mod;
        sub[v]-=sub[u];  // Making u again as a root of tree
        sub[u]+=sub[v];
        den=(den * sub[u])%mod;
        den=(den * sub[v])%mod;
        den=(den * rem)%mod;
    }
}

signed main()
{
    fast;

    ll t=1;
    //cin>>t;
    while(t--)
    {
        cin>>n;
        fact=den=1;
        f(i,1,n-1)
        {
            fact=(fact*i)%mod;
            ll u,v;
            cin>>u>>v;
            adj[u].pb(v);
            adj[v].pb(u);
        }
        fact=(fact * n)%mod;
        dfs(1,0); // Assuming 1 as a root
        solve(1,0);
        f(i,1,n)
        {
            cout<<ans[i]<<endl;
        }
    }
    return 0;
}


















Measured memory_bytes: 17904
#n=int(input())
#n, p,q,r = map(int, input().split())
#arr = list(map(int, input().split()))
#n=int(input())
#n,m,k = map(int, input().split())
#n, m, k = [int(x) for x in input().split()]
#for _ in range(int(input())):
#n=int(input())
#arr = list(map(int, input().split()))
h, w, m = map(int, input().split())
target_points = {tuple(map(lambda x: int(x) - 1, input().split())) for _ in range(m)}

row_points = [0] * h
col_points = [0] * w
for row, col in target_points:
    row_points[row] += 1
    col_points[col] += 1

row_max = max(row_points)
col_max = max(col_points)

row_max_indexes = [i for i in range(h) if row_points[i] == row_max]
col_max_indexes = [i for i in range(w) if col_points[i] == col_max]
crossing_filled = 0
if len(row_max_indexes) * len(col_max_indexes) <= m:
    if all([(row, col) in target_points for row in row_max_indexes for col in col_max_indexes]):
        crossing_filled=1

print(row_max + col_max - crossing_filled)


Measured memory_bytes: 83532
l=[]
while 1:
  s = input()
  if s == "0 0":
    break
  l.append(s)

for z in l:
  h,w=map(int,z.split())
  for y in range(h):
    for x in range(w):
      #改行無しprint
      print("#",end="")
    print()
  print()


Measured memory_bytes: 7004
N, W = map(int, input().split())
WEIGHTS = list(list(map(int, input().split())) for _ in range(N))
M = len(WEIGHTS)

DP = [[0 for _ in range(W + 1)] for _ in range(M + 1)]

for i, (weight, value) in enumerate(WEIGHTS):
    for w in range(W + 1):
        if w - weight >= 0:
            DP[i+1][w] = max(DP[i][w - weight] + value, DP[i][w])
        else:
            DP[i+1][w] = DP[i][w]

print(DP[M][W])

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

ll gcd(ll a, ll b){
      if(b==0){
            return a;
      }else{
            return gcd(b,a%b);
      }
}


int main(){
      ll a,b,c,d;
      while(cin >>a >>b){
            c = gcd(a,b);
            d = a*(b/c);
            cout << c <<' '<< d << endl;
      }
}


Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
#define lli long long int
#define mp(a,b) make_pair(a,b)
#define pb(a) push_back(a)
#define fr(i,n) for(i=0;i<n;i++)
#define F first
#define S second
#define fast std::ios_base::sync_with_stdio(false)
#define mod 1000000007
#define pi 3.14159265
int main() {
	fast;
	lli n,i,j,count=0;
	cin>>n;
	string s;
	cin>>s;
	lli count1=0,count2=0,count3=0;
	fr(i,s.length())
	{
		if(s[i]=='G')
			count1++;
		else if(s[i]=='R')
		    count2++;
		else
		    count3++;
	}
    fr(i,s.length())
    {
        fr(j,s.length())
        {
            if(s[i]=='R'&&s[j]=='B')
            {
                if(min(i,j)-abs(i-j)>=0&&s[min(i,j)-abs(i-j)]=='G')
                    count++;
                if(max(i,j)+abs(i-j)<s.length()&&s[max(i,j)+abs(i-j)]=='G')
                    count++;
                if((abs(i-j))%2==0&&s[min(i,j)+(abs(i-j))/2]=='G')
                    count++;
            }
        }
    }
	cout<<count1*count2*count3-count;
	
	return 0;
}

Measured memory_bytes: 3640
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
using namespace std;


signed main(){
    int n, m;
    while(1){
        cin >> n;
        if(n == 0) break;
        string s;
        cin >> m >> s;
        vector<int> d;
        bool f = false;
        int cnt = 0;
        rep(i, 0, m){
            if(f){
                if(s[i] == 'O' && s[i + 1] == 'I'){
                    cnt++; i++;
                }else{
                    d. push_back(cnt);
                    cnt = 0;
                    f = false;
                }
            }
            if(s[i] == 'I' && !f){
                f = true;
            }
        }
        int ans = 0;
        rep(i, 0, d.size()){
            ans += max((int)0, d[i] - n + 1);
        }
        cout << ans << endl;
    }
}

Measured memory_bytes: 2124
#include<bits/stdc++.h>
 
#define INF 1000010000
#define nl '\n'
#define pb push_back
#define ppb pop_back
#define mp make_pair
#define fi first
#define se second
#define pii pair<int,int>
#define pdd pair<double,double>
#define all(c) (c).begin(), (c).end()
#define SORT(c) sort(all(c))
#define sz(c) (c).size()
#define rep(i,n) for( int i = 0; i < n; ++i )
#define repi(i,n) for( int i = 1 ; i <= n; ++i )
#define repn(i,n) for( int i = n - 1 ; i >= 0 ; --i )
#define repf(j,i,n) for( int j = i ; j < n ; ++j )
#define die(s) {std::cout << s << nl;}
#define dier(s) {std::cout << s; return 0;}
#define vi vector<int>
typedef long long ll;
 
using namespace std;
 
 
int main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cout.precision(0); 
	ll n;
	cin >> n;
	ll ans = 0;
	ll t = n / 11;
	ans += t * 2;
	n -= t * 11;
	if(n == 10){
		ans += 2;
	}
	if(n == 9){
		ans += 2;
	}
	if(n == 8){
		ans += 2;
	}
	if(n == 7){
		ans += 2;
	}
	if(n < 7 && n > 0){
		ans += 1;
	}
	die(ans);
 
 
 
	return 0;
}

Measured memory_bytes: 256
//#define _GLIBCXX_DEBUG
#include<bits/stdc++.h>
#define PI 3.14159265359
using namespace std;
#define rep(i, n) for (ll i = 0; i < (ll)(n); i++)
#define bit(n,k) (((ll)n>>(ll)k)&1) /*nのk bit目*/
const long long INF= 1e+18+1;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll> >vvl;
typedef pair<ll,ll> P;
typedef tuple<ll,ll,ll> T;
const ll MOD=1000000007LL;
string abc="abcdefghijklmnopqrstuvwxyz";
string ABC="ABCDEFGHIJKLMNOPQRSTUVWXYZ";
vl dx={-1,-1,-1,0,0,1,1,1};
vl dy={1,-1,0,1,-1,1,0,-1};
bool dp[80][80][26000];//13000が中心
int main(){
    ll h,w;cin>>h>>w;
    vvl a(h,vl(w));
    vvl b(h,vl(w));
    
    rep(i,h){
        rep(j,w)cin>>a[i][j];
    }
    rep(i,h){
        rep(j,w){
            cin>>b[i][j];
            a[i][j]-=b[i][j];
        }
    }
    dp[0][0][13000-a[0][0]]=true;
    dp[0][0][13000+a[0][0]]=true;
    rep(i,h){
        rep(j,w){
            rep(k,26000){
                if((i>=1&&k>=a[i][j]&&k-a[i][j]<=25999&&dp[i-1][j][k-a[i][j]])||(j>=1&&k>=a[i][j]&&k-a[i][j]<=25999&&dp[i][j-1][k-a[i][j]]))dp[i][j][k]=true;
                if((i>=1&&k+a[i][j]>=0&&k+a[i][j]<=25999&&dp[i-1][j][k+a[i][j]])||(j>=1&&k+a[i][j]>=0&&k+a[i][j]<=25999&&dp[i][j-1][k+a[i][j]]))dp[i][j][k]=true;

            }
        }
    }
    ll ans=INF;
    rep(i,26000){
        if(dp[h-1][w-1][i]){
          ll d=abs(13000-i);
          ans=min(ans,d);
        }
    }
    cout<<ans<<endl;
    /*rep(i,h){
        rep(j,w){
            cout<<i<<" "<<j<<endl;
            rep(k,26000){
                if(dp[i][j][k])cout<<k<<" ";
            }
            cout<<endl;
        }
        cout<<endl;
        cout<<endl;
    }*/
}

    


Measured memory_bytes: 161664
from itertools import permutations

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

A = [[0]*N for i in range(N)]

for i in range(M) :
    u,v = map(int,input().split())
    u -= 1
    v -= 1
    
    A[u][v] = 1
    A[v][u] = 1

ran = list(range(1,N))

P = list(permutations(ran))

ans = 0

for perm in P :
    perm = list(perm)
    
    for u,v in zip([0]+perm, perm) :
        if not A[u][v] :
            break
        
    else :
        ans += 1

print(ans)


Measured memory_bytes: 3572
#include <map>
#include <set>
#include <list>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdio>
#include <string>
#include <vector>
#include <complex>
#include <cstdlib>
#include <cstring>
#include <numeric>
#include <sstream>
#include <iostream>
#include <algorithm>
#include <functional>

#define mp       make_pair
#define pb       push_back
#define all(x)   (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define repi(i,a,b) for(int i = (a); i < (b); i++)

using namespace std;

typedef    long long          ll;
typedef    unsigned long long ull;
typedef    vector<bool>       vb;
typedef    vector<int>        vi;
typedef    vector<vb>         vvb;
typedef    vector<vi>         vvi;
typedef    pair<int,int>      pii;

const int INF=1<<29;
const double EPS=1e-9;

const int dx[]={1,0,-1,0},dy[]={0,-1,0,1};
const int MAX_N =10000;

struct edge
{
	int to,cost;
	edge(int _to,int _cost){
		to =_to;
		cost =_cost;
	}
};

int V;
vector<edge> cost[MAX_N];
int d[MAX_N];
bool visit[MAX_N];
void dijkstra(int s){
	d[s]=0;
	priority_queue<pii, vector<pii> ,greater<pii> > que;
	que.push(mp(0,s));
	while(!que.empty()){
		pii p =que.top();
		que.pop();
		int v =p.second;
		if(d[v] < p.first)continue;
		for(int i =0;i <cost[v].size();i++){
			edge e =cost[v][i];
			if(d[e.to] >d[v]+e.cost){
				d[e.to] =d[v] +e.cost;
				que.push(mp(d[e.to],e.to));
			}
		}
	}
}

int main(){
	cin>>V;
	for(int i =0;i <V;i++){
		d[i]=INF;
		int u,k;
		cin>>u>>k;
		for(int j =0;j <k;j++){
			int to,c;
			cin>>to>>c;
			cost[u].push_back(edge(to,c));
		}
	}
	
	dijkstra(0);
	for(int i =0;i <V;i++){
		cout <<i<<" "<<d[i]<<endl;
	}
	return 0;
}

Measured memory_bytes: 6296
#include<iostream>
#include<string>
#include<vector>
using namespace std;
#define ll long long
const ll MOD=1e9+7;

int main(){
    int n,k;cin>>n>>k;
    ll smin=0,smax=0;
    for(int i=0;i<k;i++){
        smin+=i;
        smax+=(n-i);
    }
    ll ans=0;
    for(int i=k;i<=n;i++){
        ans+=(smax-smin+1);
        ans%=MOD;
        smin+=i;
        smax+=(n-i);
    }
    cout<<ans+1<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include<string.h>
#include<algorithm>
#include<math.h>
#include<stdio.h>
#include<string>
using namespace std;

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

	int c=0;
	int x = 0;
	for (int a= 0; a <= n; ++a) {
		for (int b = 0; b <= n; ++b) {
			c = n - (a + b);
			x = 10000 * a + 5000 * b+1000*c;
			if (x==y && c>=0) {
				cout << a << " " << b << " " << c << endl;
				return 0;
			}
			
		}
	}

	cout << "-1 -1 -1" << endl;
	return 0;
}

Measured memory_bytes: 256
#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <cinttypes>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iostream>
#include <limits>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <tuple>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;

int main() {
//  freopen("../Console/1.txt", "rb", stdin);
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  string A, B;
  cin >> A >> B;

  string S;
  for (int i = 0; i < A.size() + B.size(); ++i) {
    if (i % 2 == 0) {
      S.push_back(A[i / 2]);
    } else {
      S.push_back(B[i / 2]);
    }
  }

  cout << S << '\n';

  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Collections.Generic;

namespace ConsoleApp2
{
    public class Program
    {
        public static void Main(string[] args)
        {
            long N;
            long[] listA;
            
            N = Read(Console.ReadLine())[0];
            int[] ansCollection = new int[N];
            listA = Read(Console.ReadLine());

            //find negative number
            long[] data = Negative_Min(listA);
            long negNum = data[0];
            long min = data[1];

            long ans = 0;

            if (negNum % 2 == 0)
            {
                foreach (long item in listA) ans += Math.Abs(item);
            }
            else
            {
                foreach (var item in listA) ans += Math.Abs(item);
                ans -= 2 * min;
            }
            Console.WriteLine(ans);

        }


        public static long[] Negative_Min(long[] array)
        {
            int neg = 0;
            long min = Math.Abs(array[0]);

            foreach (var num in array) 
            {
                if (num < 0) neg++;
                long ab = Math.Abs(num);
                if (min > ab) min = ab;
            }
            long[] ans = new long[2] { neg, min };
            return ans;
        }

        private static long[] Read(string input)
        {
            string[] inputs = input.Split(' ');
            long num = inputs.Length;
            long[] ints = new long[num];
            for (int i = 0; i < num; i++)
            {
                ints[i] = long.Parse(inputs[i]);
            }
            
            return ints;
        }


    }
}


Measured memory_bytes: 29660
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n, a[100002] = {0}, sum = 0;
  cin >> n;
  for (int i = 1; i <= n; i++) {
    cin >> a[i];
    sum += fabs(a[i - 1] - a[i]);
    if (i == n) sum += fabs(a[i] - a[i + 1]);
  }
  for (int i = 1; i <= n; i++) {
    int b = 0;

    b = (fabs(a[i - 1] - a[i]) + fabs(a[i] - a[i + 1])) - fabs(a[i - 1] - a[i + 1]);
    cout << sum - b << endl;
  }
}

Measured memory_bytes: 1664
#include <iostream>
#include <utility>
#include <vector>
#include <queue>
#include <stack>
#include <array>
#include <algorithm>
#include <numeric>
#include <limits>
#include <string>
#include <regex>
#include <cstdio>
#include <cstring>
#include <cmath>
using namespace std;

int main()
{
    long long l, r;
    cin >> l >> r;
    int lm = l % 2019;
    int rm = r % 2019;
    int ans = 2018;

    // 0 mod 2019 となるケース
    if ((r / 2019) - (l / 2019) > 0) ans = 0;

    // otherwise
    else {
        for (int i = lm; i <= rm; i++) {
            for (int j = i + 1; j <= rm; j++) {
                ans = min(ans, (i * j) % 2019);
            }
        }
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define all(vecto) vecto.begin(),vecto.end()
typedef long long ll;

int main(){
    string s;
    int n;
    cin >> n >> s;
    rep(i,s.size()){
        s.at(i) = s.at(i) + n;
        if(s.at(i)>'Z'){
            s.at(i) -= 26;
        }
    }
    cout << s << endl;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<math.h>
#include<iomanip>
#include<set>
#include<numeric>
#include<cstring>
#include<cstdio>
#include<functional>
#include<bitset>
#include<limits.h>
#include<cassert>
#include <fstream>
#include <time.h>
#include <iterator>


#define REP(i, n) for(int i = 0;i < n;i++)
#define REPR(i, n) for(int i = n;i >= 0;i--)
#define FOR(i, m, n) for(int i = m;i < n;i++)
#define FORR(i, m, n) for(int i = m;i >= n;i--)
#define SORT(v, n) sort(v, v+n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v,n) reverse(v,v+n);
#define VREVERSE(v) reverse(v.begin(), v.end());
#define ll long long
#define pb(a) push_back(a)
#define m0(x) memset(x,0,sizeof(x))
#define print(x) cout<<x<<endl;
#define pe(x) cout<<x<<" ";
#define lb(v,n) lower_bound(v.begin(), v.end(), n);
#define ub(v,n) upper_bound(v.begin(), v.end(), n);
#define int long long
#define all(x) (x).begin(), (x).end()

using namespace std;

const int MOD = (ll)1000000000 + 7;
const ll INF = 1e17;
const double pi = acos(-1);
const double EPS = 1e-10;
typedef pair<int, int>P;

struct edge {
	int to,  cost;
};
vector<edge> G[100010];
int color[100010];

bool visited[100010];
void dfs(int n, int c) {
	for (auto x : G[n]) {
		if (!visited[x.to]) {
			visited[x.to] = true;
			if (x.cost % 2 == 0) {
				color[x.to] = c;
				dfs(x.to, c);
			}
			else {
				color[x.to] = (c + 1) % 2;
				dfs(x.to, (c + 1) % 2);
			}
		}
	}
}

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	m0(visited);
	REP(i, N - 1) {
		int u, v, c;
		cin >> u >> v >> c;
		u--, v--, c;
		G[u].push_back({ v,c });
		G[v].push_back({ u,c });
	}
	visited[0] = true;
	color[0] = 0;
	dfs(0, 0);
	REP(i, N) {
		print(color[i]);
	}
}

Measured memory_bytes: 10240
/*
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
ACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACAC
CACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACACA
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <cmath>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <array>
#include <tuple>
#include <random>

#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)

#define all(x) (x).begin(), (x).end()

using namespace std;
typedef long long int ll;

int main(){
    ll n, m, ans;
    cin >> n >> m;
    ans = (1900 * m + 100 * (n - m)) * (int)pow(2, m);
    cout << ans << endl;
}

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

#define rep(i, first, to) for(int i = first; i < to; ++i)
#define REP(i, first, to) for(int i = first; i <= to; ++i)
#define MyDebug

#ifdef MyDebug
	#define debug(x) cout << #x << " : " << x << endl
	#define debugP(x) cout << x << endl
#else
	#define debug(x)
	#define debugP(x)
#endif

using namespace std;
typedef long long ll;

string s;
int n;
void solve() {
	cin >> s;
	int n = s.size();
	int max = 0;
	rep(i, 1, n / 2) {
		string tmp1, tmp2;
		tmp1 = s.substr(0, i);
		tmp2 = s.substr(i, i);
		if (tmp1 == tmp2) {
			max = i * 2;
		}
	}
	cout << max << endl;
}

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


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int,int> P;
typedef pair<ll,ll> l_l;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define pb push_back
#define sz(x) (int)(x).size()
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
const int INF=1001001000;
const int mINF=-1001001000;
const ll LINF=1010010010010010000;
template<class T> inline bool chmin(T& a, T b) {
if (a > b) {
a = b;
return true;
}
return false;
}
template<class T> inline bool chmax(T& a, T b) {
if (a < b) {
a = b;
return true;
}
return false;
}
//グリッド：（典型）dp,dfs,bfs,最短経路,その他
int main(){
    ll a,b,c,d;cin>>a>>b>>c>>d;
    ll tcnt=(a+d-1)/d;
    ll acnt=(c+b-1)/b;
    if(tcnt<acnt)cout<<"No"<<endl;
    else cout<<"Yes"<<endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <vector>
#include <algorithm>
#include <cmath>
#include <queue>
#include <string>
#include <map>
#include <set>
#include <stack>
#include <tuple>
#include <deque>
#include <numeric>
#include <bitset>
#include <iomanip>
#include <cassert>
#include <chrono>
#include <random>
#include <limits>
#include <iterator>
#include <functional>
#include <sstream>
#include <complex>
using namespace std;

typedef long long ll;
typedef uint64_t ull;
typedef pair<int, int> P;
constexpr double EPS = 1e-9;
constexpr int INF = 1001001001;
constexpr int mod = 1000000007;
// constexpr int mod = 998244353;

#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)

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

    ll a, b;
    cin >> a >> b;
    ll g = __gcd(a, b);
    map<int, int> mp;
    for(int i = 2; (ll)i * i <= g; ++i){
        while(g % i == 0){
            ++mp[i];
            g /= i;
        }
    }
    if(g != 1)  ++mp[g];
    int ans = mp.size() + 1;
    cout << ans << endl;
}

Measured memory_bytes: 256
class UnionFind:
    from typing import List, Set

    def __init__(self, n):
        self.n = n
        self.parent = [-1] * n

    def merge(self, x, y) -> int:
        x = self.leader(x)
        y = self.leader(y)

        if x == y:
            return 0

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

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

        return self.parent[x]

    def same(self, x, y) -> bool:
        return self.leader(x) == self.leader(y)

    def leader(self, x) -> int:
        if self.parent[x] < 0:
            return x
        else:
            self.parent[x] = self.leader(self.parent[x])
            return self.parent[x]

    def size(self, x) -> int:
        return -self.parent[self.leader(x)]

    def groups(self) -> List[Set[int]]:
        groups = dict()

        for i in range(self.n):
            p = self.leader(i)
            if not groups.get(p):
                groups[p] = set()
            groups[p].add(i)

        return list(groups.values())


def main():
    N, M = map(int, input().split())

    uf = UnionFind(N)

    for _ in range(M):
        # UnionFindを0スタートで実装しているので、入力から1引きます
        A, B = map(lambda x: int(x) - 1, input().split())  
        uf.merge(A, B)  # AとBをmergeします。union, uniteとも呼ばれます。

    print(len(uf.groups()) - 1)


if __name__ == '__main__':
    main()

Measured memory_bytes: 35516
#ifndef AC_ABC_LIB_HPP
#define AC_ABC_LIB_HPP

#include <iostream>
#include <string>
#include <vector>

std::vector<std::string> sys_args(int argc, char **argv) {
    std::vector<std::string> args;

    for (int i = 1; i < argc; ++i)
        args.emplace_back(argv[i]);

    return args;
}

template<typename T>
void print(const T& vs) {
    std::cout << "[ ";

    for (auto&& v : vs)
        std::cout << v << " ";

    std::cout << "]" << std::endl;
}

std::vector<int> get_n_vector(void) {
    size_t n;
    std::cin >> n;

    std::vector<int> hs;
    hs.reserve(n);

    for (size_t i = 0; i < n; ++i) {
        int h;
        std::cin >> h;
        hs.emplace_back(h);
    }

    return hs;
}

#endif  // AC_ABC_LIB_HPP
using namespace std;

int main(int argc, char **argv) {
    auto hs = get_n_vector();
    int hotels = 0, maxh = 0;

    vector<int> maxlist;
    for (auto&& h : hs) {
        if (maxh < h)
            maxh = h;
        maxlist.emplace_back(maxh);
    }

    for (size_t i = 0; i < maxlist.size(); ++i) {
        if (maxlist[i] <= hs[i])
            hotels++;
    }

    cout << hotels << endl;

    return 0;
}

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

using namespace std;

using LL = long long;
using vi = vector<int>;
using pii = pair<int, int>;
using vpii = vector<pair<int, int>>;
using vll = vector<LL>;
using LD = long double;

#define ALL(v) v.begin(), v.end()
#define endl '\n'
#define SYNC ios_base::sync_with_stdio(false); cin.tie(NULL); cerr.tie(NULL);
#define REP(i , n) for(int i =0 ; i < n ;i++)
#define REPN(i , n) for(int i = 1; i <= n ; i++)
#define cot(x) cerr << #x << " " << x << " ";
#define cotd(x) cerr << #x << " " << x << endl;
#define her 	cerr << " here \n"; 
#define pp push_back
#define fi first 
#define se second
#define un(x) x.erase(unique(ALL(x)), x.end())

template<typename T > void check(T & a, const T & b) { if (a >= b) { a %= b; } }
template<typename T>T gcd(T u, T v) { if (u == v)return u; if (u == 0)return v; if (v == 0)return u; if (~u & 1) { if (v & 1) return gcd(u >> 1, v); else return gcd(u >> 1, v >> 1) << 1; }if (~v & 1)return gcd(u, v >> 1); if (u > v)return gcd((u - v) >> 1, v); return gcd((v - u) >> 1, u); }
LL mulmod(LL a, LL b, const LL & m) { LL q = (LL)(((LD)a*(LD)b) / (LD)m); LL r = a*b - q*m; if (r>m)r %= m; if (r<0)r += m; return r; }
template <typename T, typename S>T expo(T e, S n) { T x = 1, p = e; while (n) { if (n & 1)x = x*p; p = p*p; n >>= 1; }return x; }
template <typename T>T powerL(T e, T n, const T & m) { T x = 1, p = e; while (n) { if (n & 1)x = mulmod(x, p, m); p = mulmod(p, p, m); n >>= 1; }return x; }

#define rank ____rank

const int N = (int)2e5 + 10;
const LL MOD = (int)1e9 + 7;   
int n, x, y, T, rank[N], par[N], c[N], w[N], m[N]; 
int sz[N]; 
LL fact[N], inv[N]; 
vector<vi> col;
map<int,int> M[N];

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

void uni(int x, int y){
	int a = find(x), b = find(y); 
	if(a == b) return; 
	if(rank[a] >= rank[b]){
		par[b] = a; 
		if(rank[a] == rank[b])rank[a]++;
	}
	else par[a] = b;
}

void pre(){
	fact[0] = fact[1] = inv[0] = inv[1] = 1; 
	for(int i = 2; i < N; i++){
		fact[i] = (fact[i-1]*i) % MOD; 
		inv[i] = powerL(fact[i], MOD - 2, MOD); 
	}
}

int main(){
	SYNC; 
	pre(); 
	cin >> n >> x >> y;
	memset(rank, 0, sizeof rank); 

	REPN(i, n){
		par[i] = i; 
		cin >> c[i] >> w[i]; 
		m[c[i]] = i; 
	}

	REPN(i, n){
		if(w[i] < w[m[c[i]]]){
			m[c[i]] = i; 
		}
	}

	REPN(i, n){
		if(i != m[c[i]] && w[i] + w[m[c[i]]] <= x){
			uni(i, m[c[i]]); 	
		}
	}
	int mn1 = 0, mn2 = 0;
	REPN(i, n){
		if(!m[i]) continue;
		if(!mn1){
			mn1 = m[i]; 
		}
		else if(w[m[i]] < w[mn1]){
			mn2 = mn1;
			mn1 = m[i]; 
		}
		else if(!mn2 || w[m[i]] < w[mn2]){
			mn2 = m[i]; 
		}
	}

	REPN(i, n){
		if(c[i] != c[mn1] && w[i] + w[mn1] <= y){
			uni(i, mn1); 
		}
		if(mn2 && c[i] != c[mn2] && w[i] + w[mn2] <= y){ 
			uni(i, mn2); 
		}
	}

	REPN(i, n){
		int a = find(i);
		M[a][c[i]]++;
		sz[a]++; 
	}

	int ans = 1; 

	REPN(i, n){
		if(sz[i]){
			ans = (ans * 1LL * fact[sz[i]]) % MOD; 
			for(auto & j : M[i]){
				ans = (ans * 1LL * inv[j.se]) % MOD; 
			}
		}
	}

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

Measured memory_bytes: 26752
n=int(input())
a=[0]+list(map(int,input().split()))
b=list(map(int,input().split()))+[0]

m=[a[i] for i in range(1,n+1)]
l=[1 for _ in range(n)]

for i in range(n):
	if a[i]<a[i+1]:
		l[i]=a[i+1]
		
ans=1
for i in range(n-1,-1,-1):
	if b[i+1]<b[i]:
		if l[i]>b[i]:
			ans=0
		else:
			l[i]=b[i]
	m[i]=min(m[i],b[i])
	
for i in range(n):
	ans=(ans*(m[i]-l[i]+1))%(10**9+7)
	if m[i]<l[i]:
		ans=0
print(ans)

Measured memory_bytes: 18480
#include <iostream>
#define rep(i, n) for (int i = 0; i < (n); ++i)
using namespace std;

int main(void) {
  ios::sync_with_stdio(false);
  string S;
  cin >> S;
  int N = S.size();

  const string A = "AKIHABARA";
  int nA = A.size();
  if (nA < N) {
    cout << "NO" << endl;
    return 0;
  }

  int iS = 0;
  rep(iA, nA) {
    // cout << iA << ": " << A[iA] << endl;
    if (S[iS] == A[iA]) {
      iS++;
      if (iS == N) {
        if (iA < nA - 2) {
          cout << "NO" << endl;
          return 0;
        }
        break;
      }
    } else if (A[iA] != 'A') {
      cout << "NO" << endl;
      return 0;
    }
  }
  if (iS == N)
    cout << "YES" << endl;
  else
    cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 3628
#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define str to_string
#define endl "\n"
#define PI 3.141592653589
using namespace std;
using lint = long long;
template <class T>ostream &operator<<(ostream &o,const vector<T>&v)
{o<<"{";for(int i=0;i<(int)v.size();i++)o<<(i>0?", ":"")<<v[i];o<<"}";return o;}

//AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC(*'ω'*)AC
int main(){
    int x;
    vector<int> vec(10);
    for(int i=0;i<4;i++){
        cin>>x;
        vec[x]++;
    }
    if(vec[1]==1&&vec[4]==1&&vec[7]==1&&vec[9]==1)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
}


Measured memory_bytes: 3608
#include<cstdio>
#include<algorithm>
#include<cstring>
#include<iostream>
#include<vector>
#include<queue>
#include<cmath>
#include<map>
#include<set>
#define ll long long
#define F(i,a,b) for(int i=(a);i<=(b);i++)
#define mst(a,b) memset((a),(b),sizeof(a))
#define PII pair<int,int>
using namespace std;
template<class T>inline void read(T &x) {
    x=0; int ch=getchar(),f=0;
    while(ch<'0'||ch>'9'){if (ch=='-') f=1;ch=getchar();}
    while (ch>='0'&&ch<='9'){x=(x<<1)+(x<<3)+(ch^48);ch=getchar();}
    if(f)x=-x;
}
const int inf=0x3f3f3f3f;
const int maxn=15;
int n,a[maxn],b[maxn],fac[maxn];
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++) cin>>a[i];
	for(int i=1;i<=n;i++) cin>>b[i];
	fac[0]=1;
	for(int i=1;i<=8;i++) fac[i]=fac[i-1]*i;
	int ans1=0,ans2=0;
	for(int i=1;i<=n-1;i++)
	{
		int cnt=0;
		for(int j=i+1;j<=n;j++)
		{
			if(a[j]<a[i]) cnt++;
		}
		ans1+=cnt*fac[n-i];
	}
	
	for(int i=1;i<=n-1;i++)
	{
		int cnt=0;
		for(int j=i+1;j<=n;j++)
		{
			if(b[j]<b[i]) cnt++;
		}
		ans2+=cnt*fac[n-i];
	}
	//cout<<ans1<<"  "<<ans2<<endl;
	cout<<abs(ans1-ans2)<<endl;
	return 0;
}


Measured memory_bytes: 256
N = int(input())
dp = [[0, 0, 0] for _ in range(N)]
for i in range(N):
  if i == 0:
    dp[0] = list(map(int, input().split()))
  else:
    v = list(map(int, input().split()))
    dp[i][0] = max(dp[i-1][1] + v[0], dp[i-1][2] + v[0])
    dp[i][1] = max(dp[i-1][2] + v[1], dp[i-1][0] + v[1])
    dp[i][2] = max(dp[i-1][0] + v[2], dp[i-1][1] + v[2])
print(max(dp[N-1]))

Measured memory_bytes: 22860
#include <bits/stdc++.h>
#define rep(i,N) for (int i = 0; i < (N); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using P = pair<int, int>;
int main(void){
  int N;
  cin >> N;
  vector <int> A(N);
  rep(i,N) cin >> A[i];

  double ans = 0.0;  //答えの分母
  rep(i,N){
    ans += 1.0 / A[i];
  }
  ans = 1.0 / ans;
  cout << setprecision(10) << ans << endl;
}


Measured memory_bytes: 3808
import java.util.Scanner;

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

		for (int i = 0; i < length; i++) {
			list[scanner.nextInt() - 1][scanner.nextInt() - 1][scanner.nextInt() - 1] += scanner.nextInt();
		}

		for (int i = 0; i < 4; i++) {
			for (int i2 = 0; i2 < 3; i2++) {
				for (int i3 = 0; i3 < 10; i3++) {
					System.out.print(" " + list[i][i2][i3]);
				}

				System.out.println();
			}

			if (i != 3)
				System.out.println("####################");
		}
	}
}

Measured memory_bytes: 29884
#include <algorithm>
#include <cassert>
#include <cmath>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <vector>
#define repeat(i, n) for (int i = 0; (i) < (n); ++(i))
#define repeat_from(i, m, n) for (int i = (m); (i) < (n); ++(i))
using namespace std;
template <class T>
void setmax(T &a, T const &b) {
    if (a < b) a = b;
}

template <class T>
void setmin(T &a, T const &b) {
    if (a > b) a = b;
}

template <typename T, typename X>
auto vectors(T a, X x) { return vector<T>(x, a); }

template <typename T, typename X, typename Y, typename... Zs>
auto vectors(T a, X x, Y y, Zs... zs) {
    auto cont = vectors(a, y, zs...);
    return vector<decltype(cont)>(x, cont);
}

int main() {
    int N;
    cin >> N;
    vector<long long> x(N), y(N);
    repeat(i, N) {
        cin >> x[i] >> y[i];
    }
    vector<long long> fx(N), fy(N);
    repeat(i, N) {
        fx[i] = x[i] - y[i];
        fy[i] = x[i] + y[i];
    }
    long long res = -1;
    long long maxf = INT64_MIN, minf = INT64_MAX;
    for (int i = 0; i < N; ++i) {
        setmax(maxf, fx[i]);
        setmin(minf, fx[i]);
    }
    setmax(res, maxf - minf);
    maxf = INT64_MIN, minf = INT64_MAX;
    for (int i = 0; i < N; ++i) {
        setmax(maxf, fy[i]);
        setmin(minf, fy[i]);
    }
    setmax(res, maxf - minf);
    cout << res << endl;
    return 0;
}

Measured memory_bytes: 9524
#define _USE_MATH_DEFINES
#include <iostream>
#include <string>
#include <list>
#include <vector>
#include <queue>
#include <algorithm>
#include <climits>
#include <cstring>
#include <cmath>
#include <stack>
#include <iomanip>
#include <tuple>
#include <functional>
#include <cfloat>
#include <map>
#include <set>
#include <array>
#include <stdio.h>
#include <string.h>
using ll = long long;
using ull = unsigned long long;
using namespace std;
#define int long long
#define CONTAINS_VEC(v,n) (find((v).begin(), (v).end(), (n)) != (v).end())
#define SORT(v) sort((v).begin(), (v).end())
#define RSORT(v) sort((v).rbegin(), (v).rend())
#define ARY_SORT(a, size) sort((a), (a)+(size))
#define REMOVE(v,a) (v.erase(remove((v).begin(), (v).end(), (a)), (v).end()))
#define REVERSE(v) (reverse((v).begin(), (v).end()))
#define ARY_REVERSE(v,a) (reverse((v), (v)+(a)))
#define REP(i, n) for (int (i)=0; (i) < (n); (i)++)
#define CONTAINS_MAP(m, a) (m).find((a)) != m.end()
#define CONTAINS_SET(m, a) (m).find((a)) != m.end()
void YesNo(bool b) { cout << (b ? "Yes" : "No") << endl; }
void YESNO(bool b) { cout << (b ? "YES" : "NO") << endl; }

set<string> se;

signed main()
{
	bool valid = true;

	int N;
	cin >> N;
	string prev;
	cin >> prev;
	se.insert(prev);
	REP(i, N - 1)
	{
		string s;
		cin >> s;

		if (CONTAINS_SET(se, s)) valid = false;
		se.insert(s);
		if (prev.back() != s.front()) valid = false;

		prev = s;
	}

	YesNo(valid);
}



Measured memory_bytes: 3140
#include <bits/stdc++.h>
#define rep(i,n)for(long long i=0;i<(long long)(n);i++)
#define all(a) a.begin(), a.end()
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }
 
const ll MOD=1e9+7;
const ll INF=1e18;
const int MAX=510000;
const double pi=acos(-1);
int dx[8] = {1,0,-1,0,1,1,-1,-1};
int dy[8] = {0,1,0,-1,-1,1,1,-1};
// int d[13]={0,31,28,31,30,31,30,31,31,30,31,30,31};


int main(){
  cin.tie(0);
  ios::sync_with_stdio(false); 
  
  int a,b,c;
  cin >> a >> b >> c;

  if(a*b*c == 5*5*7) cout << "YES" << endl;
  else cout << "NO" << endl;
  return 0;
}


Measured memory_bytes: 256
d = int(10**9 + 7)
H, W = map(int, input().split())

maze = [list(input()) for _ in range(H)]

dp = [[0] * W for _ in range(H)]
dp[0][0] = 1

for i in range(H):
    for j in range(W):
        if maze[i][j] != '#':
            if i != 0:
                dp[i][j] = (dp[i][j] + dp[i-1][j] % d) % d
            if j != 0:
                dp[i][j] = (dp[i][j] + dp[i][j-1] % d) % d

print(dp[H-1][W-1])


Measured memory_bytes: 89072
#include<stdio.h>

int main(){
  int D,N;
  int i,j,k;
  
  scanf("%d %d",&D,&N);
  
  if(D==0){
    
    if(N==100)
      printf("101\n");
    else
      printf("%d\n",N);
  }
  else if(D==1){
    
    if(N==100)
      printf("10100\n");
    else
      printf("%d\n",100*N);
  }
  
  else if(D==2){
    
    if(N==100)
      printf("1010000\n");
    else
      printf("%d\n",10000*N);
  }
  
  return 0;
}


Measured memory_bytes: 128