akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;
#define mod 1000000007
#define pb push_back
#define mp make_pair
#define fi first
#define sec second
typedef long long ll;
typedef long double  ld;
#define pii pair<ll,ll> 
#define pic pair<ll,char>
#define vi vector< ll > 
#define vvi vector< vi > 
#define vpi vector< pii > 
#define vvpi vector< vpi > 
#define st  set <ll, greater <ll> >
#define mst  multiset <ll, greater <ll> >
#define fast ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define mapp  unordered_map <ll, ll>
#define ppii pair< pii, pii > 
#define test(t) ll t;cin>>t;while(t--)
#define inarr(n) ll arr[n];for(ll i=0;i<n;i++)cin>>arr[i];
#define ingra(m) vvi arr(100005);for(ll i=0;i<m;i++){ll u,v;cin>>u>>v;arr[u].pb(v);arr[v].pb(u);}
#define mem(a,b) memset(a,b,sizeof(a))
#define inn freopen("input.txt", "r", stdin)
#define outt freopen("output.txt", "w", stdout)
#define all(arr) arr.begin(),arr.end()
ll power(ll x,ll y){ll res = 1;while(y){if(y&1) res = (res*x)%mod;y=y/2,x=(x*x)%mod;}return res%mod;}
ll dp[101][100001];
ll wt[101];
ll value[101];
ll n,w;

signed main()
{
    fast;
    cin>>n>>w;
    ll i,j;
    mem(dp,-1);
    for(i=1;i<=n;i++)
        cin>>wt[i]>>value[i];
    for(i=0;i<=100;i++)
        for(j=0;j<=100000;j++)
            dp[i][j] = 1e18;
    dp[0][0] = 0;
    for(i=1;i<=n;i++)
    {
        for(j=0;j<=100000;j++)
        {
            dp[i][j] = dp[i-1][j];
            if(j==0)
                dp[i][j] = 0;
            else
            {
                if(value[i]<=j)
                    dp[i][j] = min(dp[i-1][j-value[i]]+wt[i],dp[i][j]);
            }
        }
    }
    for(i=100000;i>=0;i--)
    {
        if(dp[n][i]<=w)
        {
            cout<<i;
            return 0;
        }
    }
}

Measured memory_bytes: 79232
#include <bits/stdc++.h>
 
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
#define Rep(i,n0,n) for(int i=n0;i<n;i++)
#define Com(i,j,n) for(int i=0;i<n-1;i++)for(int j=i+1;j<n;j++)
const int INF =100100100;
const int MOD = (int)1e9+7;
const double EPS = 1e-9;
typedef long long ll;
typedef long li;
#define pb push_back 
#define mp make_pair

int max(int a, int b){
	if (a>b) return a;
	else return b;
}

signed main (){
	int NN;
	cin >> NN;
	map <int,int> mape;
	map <int,int> mapo;
	int temp;
	rep(i,NN/2){
		cin >> temp;
		mapo[temp] ++;
		cin >> temp;
		mape[temp] ++;
	}
	vector <pair<int,int>> evens;
	vector <pair<int,int>> odds;
	int onee = 0;
	int twoe = 0;
	int nume = -1;
	int oneo = 0;
	int twoo = 0;
	int numo = -2;
	evens.pb(mp(0,-1));
	odds.pb(mp(0,-2));
	for(auto itr = mape.begin(); itr != mape.end(); ++itr) {
		evens.pb(mp(itr->second,itr->first));
    }
    for(auto itr = mapo.begin(); itr != mapo.end(); ++itr) {
		odds.pb(mp(itr->second,itr->first));
    }
    sort(evens.rbegin(),evens.rend());
    sort(odds.rbegin(),odds.rend());
    onee = evens[0].first;
    oneo = odds[0].first;
    twoe = evens[1].first;
    twoo = odds[1].first;
    if(evens[0].second != odds[0].second){
    	cout << NN - onee - oneo << endl;
    }
    else {
    	cout << NN - max(onee+twoo,twoe+oneo) << endl;
    }

	return 0;
}


Measured memory_bytes: 6136
fun main(args: Array<String>) {
    val N  = nextInt()
    val A = listOfInt()
    val sum = A.reduce { acc, b -> acc xor b }
    println(if(sum == 0) "Yes" else "No")
}
fun next() = readLine()!!
fun nextInt() = Integer.parseInt(next())
fun listOfString() = next().split(" ")
fun listOfInt() = listOfString().map { Integer.parseInt(it) }

Measured memory_bytes: 51952
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

typedef long long int ll;
typedef unsigned long long int ull;
typedef long double ld;
typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> indexed_set;

#define mp make_pair
#define pb push_back
#define pf push_front
#define ss second
#define ff first
#define sz(x) (int)x.size()
#define newl "\n"
#define vi vector<int>
#define pii pair<int, int>
#define vii vector<pii>
#define vl vector<ll>
#define pll pair<ll, ll>
#define vll vector<pll>
#define coutp cout << fixed << setprecision(12)
#define mem(x, val) memset(x, val, sizeof(x))
#define fastio                        \
    ios_base::sync_with_stdio(false); \
    cin.tie(NULL);                    \
    cout.tie(NULL);
#define all(v) (v).begin(), (v).end()

const ld pi = 3.14159265359;
ll INF = 1e18 + 10;
ll MOD = 998244353;
ll mod = 1e9 + 9;

inline ll add(ll a, ll b, ll m)
{
    if ((a + b) >= m)
        return (a + b) % m;
    return a + b;
}

inline ll mul(ll a, ll b, ll m)
{
    if ((a * b) < m)
        return a * b;
    return (a * b) % m;
}

ll power(ll x, ll y, ll m)
{
    ll res = 1;
    x = x % m;
    if (x == 0)
        return 0;
    while (y > 0)
    {
        if (y & 1)
            res = (res * x) % m;
        y = y >> 1;
        x = (x * x) % m;
    }
    return res;
}

void solve()
{
    int x;
    cin>>x;
    if(x>=30) cout<<"Yes";
    else cout<<"No";
}

int main()
{
    fastio;
    int t;

    t = 1;
    //cin >> t;
    //int test=t;
    while (t-- > 0)
    {
        //cout<<"Case #"<<(test-t)<<": ";
        solve();
        cout << newl;
    }

    return 0;
}

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

int main() {
    int a, b;
    cin >> a >> b;

    if (a < b) cout << "a < b" << endl;
    else if (a > b) cout << "a > b" << endl;
    else if (a == b) cout << "a == b" << endl;

    return 0;
}


Measured memory_bytes: 3076
n = gets.to_i
p_a = gets.chomp.split
n.times do |i|
    p_a[i] = p_a[i].to_i
end

count = 0
(n-2).times do |i|
    if (p_a[i] <= p_a[i+1] && p_a[i+1] <= p_a[i+2]) || (p_a[i+2] <= p_a[i+1] && p_a[i+1] <= p_a[i])
        count += 1
    end
end

puts count

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

int main(void){
    int N;
    cin >> N;
    long long int check[N+1];

    check[0] = 2;
    check[1] = 1;

    for(int i = 2; i <= N; i++){
        check[i] = check[i-1] + check[i-2];
    }
    cout << check[N] << endl;
    return 0;
}


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

if 1<= n <= 9:
  e = n 
  print(e)
elif 10 <= n <= 99:
  print(9)
elif 100 <= n <= 999:
  e = 9 + n - 100 + 1
  print(e)
elif 1000 <= n <= 9999:
  e = 909 
  print(e)
elif 10000 <= n <= 99999:
  e = 909 + n - 10000 + 1
  print(e)
elif n == 100000:
  print(90909)

Measured memory_bytes: 9176
#include <iostream>
#include <vector>
#include <list>
#include <set>
#include <map>
#include <algorithm>
using namespace std;
template <typename T = int>
T in() {
    T temp; cin >> temp; return temp;
}

template <typename VType = int>
list<VType> const LR(VType start, VType end) {
    list<VType> ret; for (VType i = start; i < end; i++) ret.push_back(i); return move(ret);
}

int GoRight(int& i, int n, int* h) {
    int count = 0;
    for (; i < (n - 1); i++) {
        if (h[i + 1] > h[i]) break;
        count++;
    }
    return count;
}

int main() {
   int N;
   cin >> N;
   uint64_t sum = 0;
   for (int i = 1; i < N; i++) {
        sum += i;
   }
   cout << sum << endl;
   return 0;
}




Measured memory_bytes: 256
n,m=map(int,input().split())
a=list(map(int,input().split()))
from collections import Counter
mo=[[]for _ in range(m)]
for i in a:mo[i%m].append(i)
ans=len(mo[0])//2
if m%2==0:ans+=len(mo[m//2])//2
for i in range(1,0--m//2):
  if len(mo[i])>len(mo[m-i]):d=Counter(mo[i])
  elif len(mo[i])==len(mo[m-i]):
    ans+=len(mo[i])
    continue
  else:d=Counter(mo[m-i])
  anss=0
  for j in d:anss+=d[j]//2
  ans+=min(len(mo[i]),len(mo[m-i]))+min(abs(len(mo[i])-len(mo[m-i]))//2,anss)
print(ans)

Measured memory_bytes: 19384
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<utility>
#include<cstring>
#include<string>
#include<vector>
#include<stack>
#include<set>
#include<map>
#include<bitset>
#define inf 0x3f3f3f3f
using namespace std;
typedef long long ll;
typedef pair<int,int> pll;
const int maxn=2e5+10;
const int mod =1e9+7;
const double EPS = 1e-6;
struct node
{
    int num;
    string s;
};
node a[maxn];
map<string ,int> v;
bool cmp(node x, node y)
{
    if(x.num!=y.num)
        return x.num>y.num;
    else
        return x.s<y.s;
}
int main()
{
    ios::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);
    int n;
    cin >> n;
    string t;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin >> t;
        if(!v[t])
        {
            a[++cnt].s=t;
            v[t]++;
        }
        else
        {
            v[t]++;
        }
    }
    for(int i=1;i<=cnt;i++)
    {
        a[i].num=v[a[i].s];
    }
    sort(a+1,a+1+cnt,cmp);
    cout << a[1].s << endl;
    int maxnum=a[1].num;
    for(int i=2;i<=cnt;i++)
    {
        if(a[i].num==maxnum)
        {
            cout << a[i].s << endl;
        }
        else
            break;
    }
    return 0;
}


Measured memory_bytes: 27008
#include <stdio.h>
#include <algorithm>
#include <cmath>
#include <iostream>
#include <vector>

typedef long long ll;
using namespace std;

int main() {
  double A, B, H, M;
  cin >> A >> B >> H >> M;
  double anglem = 6.0 * M;
  double angleh = 30.0 * (H + M / 60.0);
  double diffangle = abs(anglem - angleh);
  double c = A * A + B * B - 2.0 * A * B * cos(diffangle / 180.0 * acos(-1.0));
  printf("%.15f\n", sqrt(c));
  return 0;
}

Measured memory_bytes: 4188
A = int(input())
B = int(input())
C = int(input())
X = int(input())
ans = 0


for i in range(A + 1):
    for j in range(B + 1):
        temp = X - (500 * i + 100 * j)
        if temp // 50 > C or temp < 0:
            continue
        else:
            ans += 1

print(ans)

Measured memory_bytes: 3064
from heapq import heappush, heappop
 
def main():
    n, m = map(int,input().split())
    
    jobs = []
    for i in range(n):
        day, value = map(int,input().split())
        jobs.append((day, value))

    jobs.sort()
    
    cur, res = 0, 0
    done = []
    h = []
    for i in range(1, m+1):
        while cur < n and jobs[cur][0] <= i:
            heappush(h, -jobs[cur][1])
            cur += 1
        if not h:
            continue
        res -= heappop(h)
 
    print(res)
 
if __name__ == "__main__":
    main()

Measured memory_bytes: 70616
#include <cstdio>
#include <cstring>
#include <iostream>
#include <string>
#include <cmath>
#include <bitset>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <algorithm>
#include <complex>
#include <unordered_map>
#include <unordered_set>
#include <random>
#include <cassert>
#include <fstream>
#include <utility>
#include <functional>
#include <time.h>
#include <stack>
#include <array>
#define popcount __builtin_popcount
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
struct unionfind{
    vector<int> par, sz;
    unionfind() {}
    unionfind(int n):par(n), sz(n, 1){
        for(int i=0; i<n; i++) par[i]=i;
    }
    int find(int x){
        if(par[x]==x) return x;
        return par[x]=find(par[x]);
    }
    void unite(int x, int y){
        x=find(x); y=find(y);
        if(x==y) return;
        if(sz[x]>sz[y]) swap(x, y);
        par[x]=y;
        sz[y]+=sz[x];
    }
    bool same(int x, int y){
        return find(x)==find(y);
    }
    int size(int x){
        return sz[find(x)];
    }
};
int main()
{
    int n, q;
	cin>>n>>q;
	int a[200020], b[200020];
	ll c[200020];
	using edge=pair<ll, P>;
	vector<edge> v;
	ll mn[200020];
	const ll INF=1e18;
	fill(mn, mn+n, INF);
	ll d=INF;
	for(int i=0; i<q; i++){
		cin>>a[i]>>b[i]>>c[i];
		d=min(d, c[i]+1+2*(n-a[i]));
		mn[a[i]]=min(mn[a[i]], c[i]+1);
		d=min(d, c[i]+2+2*(n-b[i]));
		mn[b[i]]=min(mn[b[i]], c[i]+2);
		v.push_back({c[i], {a[i], b[i]}});
	}
	for(int i=0; i<n; i++){
		d=min(d, mn[i]);
		v.push_back({d, {i, (i+1)%n}});
		d+=2;
	}
	sort(v.begin(), v.end());
	unionfind uf(n);
	ll ans=0;
	for(auto e:v){
		int x=e.second.first, y=e.second.second;
		if(!uf.same(x, y)){
			uf.unite(x, y);
			ans+=e.first;
		}
	}
	cout<<ans<<endl;
    return 0;
}


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

int main(){
    bool plus = false, ilast = false, newlast = false;
    string S;
    long long K;
    int cnt1 = 0, cnt2 = 0;

    cin >> S >> K;

    for(int i=0; i<S.length(); i++){
        if(i == S.length() - 1) ilast = true;
        else if(S[i] == S[i+1]){
            cnt1++;
            i++;
        }
    }
    if(ilast && S[S.length() - 1] == S[0]){
        string newString = S[0] + S;
        plus = true;

        for(int i=0; i<S.length() + 1; i++){
            if(i == S.length()) newlast = true;
            else if (newString[i] == newString[i+1]){
            cnt2++;
            i++;
            }
        }
    }

    if(newlast){
        cout << cnt1 + cnt2*(K-1);
    } else if(plus){
        if(K % 2 == 1){
            cout << cnt1*(K / 2 + 1) + cnt2*(K / 2);
        } else{
            cout << cnt1*(K / 2) + cnt2*(K / 2);
        }
    } else{
        cout << cnt1*K ;
    }
}

Measured memory_bytes: 3616
#include<stdio.h>

int main(void) {
  int i,n,a;
  int min=1000000,max=-min;
  unsigned long long sum=0;
  scanf("%d",&n);
  for(i=0;i<n;i++){
    scanf("%d",&a);
    if(min>a)  min=a;
    if(max<a)  max=a;
    sum+=a;
  }
  printf("%d %d %ld\n",min,max,sum);
  return(0);
}

Measured memory_bytes: 600
#pragma GCC optimize("Ofast")
#include<bits/stdc++.h>
using namespace std;
using ll=long long;
#define double long double
using datas=pair<ll,ll>;
using ddatas=pair<double,double>;
using tdata=pair<ll,datas>;
using vec=vector<ll>;
using mat=vector<vec>;
using pvec=vector<datas>;
using pmat=vector<pvec>;
#define For(i,a,b) for(i=a;i<(ll)b;i++)
#define bFor(i,a,b) for(i=a;i>=(ll)b;i--)
#define rep(i,N) For(i,0,N)
#define rep1(i,N) For(i,1,N)
#define brep(i,N) bFor(i,N-1,0)
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define vsort(v) sort(all(v))
#define vrsort(v) sort(allr(v))
#define endl "\n"
#define pb push_back
#define print(v) cout<<v<<endl
#define printyes cout<<"Yes"<<endl
#define printno cout<<"No"<<endl
#define printYES cout<<"YES"<<endl
#define printNO cout<<"NO"<<endl
#define output(v) do{bool f=0;for(auto outi:v){cout<<(f?" ":"")<<outi;f=1;}cout<<endl;}while(0)
const ll mod=1000000007;
const ll inf=1LL<<60;
const double PI = acos(-1);
const double eps = 1e-9;
template<class T> inline bool chmax(T& a,T b){bool x=a<b;if(x)a=b;return x;} 
template<class T> inline bool chmin(T& a,T b){bool x=a>b;if(x)a=b;return x;} 

void startupcpp(){
  cin.tie(0);
  ios::sync_with_stdio(false);
  cout<<fixed<<setprecision(15);
}

double distance(ddatas x,ddatas y){
  double a=x.first-y.first,b=x.second-y.second;
  return sqrt(a*a+b*b);
}

ll modinv(ll a) {
  ll b=mod,u=1,v=0,t;
  while(b){
    t=a/b;
    a-=t*b; swap(a,b);
    u-=t*v; swap(u,v);
  }
  return (u+mod)%mod;
}

ll moddevide(ll a,ll b){return (a*modinv(b))%mod;}

vec modncrlistp,modncrlistm;

ll modncr(ll n,ll r){
  ll i,size=modncrlistp.size();
  if(size<=n){
    modncrlistp.resize(n+1);
    modncrlistm.resize(n+1);
    if(!size){
      modncrlistp[0]=modncrlistm[0]=1;
      size++;
    }
    For(i,size,n+1){
      modncrlistp[i]=modncrlistp[i-1]*i%mod;
      modncrlistm[i]=modinv(modncrlistp[i]);
    }
  }
  return modncrlistp[n]*modncrlistm[r]%mod*modncrlistm[n-r]%mod;
}

ll modpow(ll a,ll n){
  ll res=1;
  while(n){
    if(n&1)res=res*a%mod;
    a=a*a%mod;
    n>>=1;
  }
  return res;
}

ll gcd(ll a,ll b){if(!b)return a;return (a%b==0)?b:gcd(b,a%b);}
ll lcm(ll a,ll b){return a/gcd(a,b)*b;}

ll countdigits(ll n){
  ll ans=0;
  while(n){n/=10;ans++;}
  return ans;
}

ll sumdigits(ll n){
  ll ans=0;
  while(n){ans+=n%10;n/=10;}
  return ans;
}

int main(){
  // startupcpp();
  // ll test;cin>>test;while(test--){
  ll i,j=1,N,K,ans=0;
  cin>>N;
  while(N){
    N/=2;
    ans+=j;
    j*=2;
  }
  print(ans);
  return 0;
}

Measured memory_bytes: 256
n = int(input())
s = []
t = []
for i in range(n):
    _s, _t = map(str, input().split())
    s.append(_s)
    t.append(int(_t))
x = input()

m = s.index(x)

ans = 0
for i in range(m+1, n):
    ans += t[i]

print(ans)


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

#define rep(i, n) for (int i = 0; i < int(n); i++)
#define rrep(i, n) for (int i = int(n) - 1; i >= 0; i--)
#define reps(i, n) for (int i = 1; i <= int(n); i++)
#define rreps(i, n) for (int i = int(n); i >= 1; i--)
#define repc(i, n) for (int i = 0; i <= int(n); i++)
#define rrepc(i, n) for (int i = int(n); i >= 0; i--)
#define repi(i, a, b) for (int i = int(a); i < int(b); i++)
#define repic(i, a, b) for (int i = int(a); i <= int(b); i++)
#define each(x, y) for (auto &x : y)
#define all(a) (a).begin(), (a).end()
#define bit32(x) (1 << (x))
#define bit64(x) (1ll << (x))
#define sz(v) ((int) v.size())

using namespace std;

using i64 = long long;
using f80 = long double;
using vi32 = vector<int>;
using vi64 = vector<i64>;
using vf80 = vector<f80>;
using vstr = vector<string>;

inline void yes() { cout << "Yes" << endl; exit(0); }
inline void no() { cout << "No" << endl; exit(0); }
inline i64 gcd(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); if (a % b == 0) return b; return gcd(b, a % b); }
inline i64 lcm(i64 a, i64 b) { if (min(a, b) == 0) return max(a, b); return a / gcd(a, b) * b; }
template <typename T> class pqasc : public priority_queue<T, vector<T>, greater<T>> {};
template <typename T> class pqdesc : public priority_queue<T, vector<T>, less<T>> {};
template <typename T> inline void amax(T &x, T y) { x = max(x, y); }
template <typename T> inline void amin(T &x, T y) { x = min(x, y); }
template <typename T> inline T exp(T x, i64 n, T e = 1) { T r = e; while (n > 0) { if (n & 1) r *= x; x *= x; n >>= 1; } return r; }
template <typename T> istream& operator>>(istream &is, vector<T> &v) { each(x, v) is >> x; return is; }
template <typename T> ostream& operator<<(ostream &os, vector<T> &v) { rep(i, v.size()) { if (i) os << ' '; os << v[i]; } return os; }
void solve(); int main() { ios::sync_with_stdio(0); cin.tie(0); cout << fixed << setprecision(16); solve(); return 0; }

const int INF = 1001001001;

void solve() {
  int n;
  cin >> n;
  vi32 a(n), b(n);
  i64 sum = 0;
  int mi = INF;
  rep(i, n) {
    cin >> a[i] >> b[i];
    sum += a[i];
    if (a[i] > b[i]) amin(mi, b[i]);
  }
  if (mi == INF) {
    cout << 0 << endl;
    return;
  }
  cout << sum - mi << endl;
}


Measured memory_bytes: 384
import java.util.Scanner;

class Main {
  public static void main(String[] args) {
    Scanner stdIn = new Scanner(System.in);
    int a = stdIn.nextInt();
    int b = stdIn.nextInt();

    if (b >= a) {
      System.out.println(a);
    } else {
      System.out.println(a-1);
    }
  }
}


Measured memory_bytes: 21844
#define _CRT_SECURE_NO_WARNINGS
#include"bits/stdc++.h"
#ifdef _DEBUG
#define DBG(n) n
#else
#define DBG(n)
#endif
#define INF         1e9
#define INFLL       1e18
#define EPS         1e-9
#define REP(i,n)    for(ll i=0,i##_len=(n);i<i##_len;++i)
#define REP1(i,n)   for(ll i=1,i##_len=(n);i<=i##_len;++i)
#define REPR(i,n)   for(ll i=(n)-1;i>=0;--i)
#define REPR1(i,n)  for(ll i=(n);i>0;--i)
#define REPC(i,obj) for(auto i:obj)
#define ALL(obj)    (obj).begin(),(obj).end()
#define SETP(n)     cout<<fixed<<setprecision(n)
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

signed main()
{
	for (ll n = in(); n != 0; n = in()) {
		vector<vector<ll>>masq(n, vector<ll>(n));
		ll ans = 0;
		REP(i, n) {
			REP(j, n) {
				masq[i][j] = in<char>() == '*' ? 0 : 1;
				if (i * j) ans = max(ans, masq[i][j] = masq[i][j] == 0 ? 0 : min({ masq[i - 1][j - 1],masq[i - 1][j],masq[i][j - 1] }) + 1);
			}
		}
		cout << ans << endl;
	}
}


Measured memory_bytes: 10716
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define inf 10e17
#define rep(i,n) for(long long i=0; i<n; i++)
#define repr(i,n,m) for(long long i=m; i<n; i++)
#define mod 1000000007
#define sorti(x) sort(x.begin(), x.end())
#define sortd(x) sort(x.begin(), x.end(), std::greater<long long>())
#define debug(x) std::cerr << (x) << std::endl;
#define roll(x) for (auto&& itr : x) { cerr << (itr) << " "; }

template <class T> inline void chmax(T &ans, T t) { if (t > ans) ans = t;}
template <class T> inline void chmin(T &ans, T t) { if (t < ans) ans = t;}

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

  using pi = pair<int, int>;
  map<pi, int> mp;

  auto get_digits = [](int const& value) -> pi {
    pi p = make_pair(-1, -1);
    bool flag = true;
    auto cpy = value;
    int t;
    while(cpy > 0) {
      t = cpy % 10;
      if (flag) p.first = t, flag = false;      
      cpy /= 10;
    }
    p.second = t;
    return p;
  };

  repr(i, n+1, 1) {
    auto d = get_digits(i);
    mp[d] += 1;
  }

  ll ans = 0;
  repr(i, 10, 1) repr(j, 10, 1) {
    auto p1 = make_pair(i, j);
    auto p2 = make_pair(j, i);

    auto t1 = mp[p1];
    auto t2 = mp[p2];

    ans += t1 * t2;
  } 

  cout << ans << endl;
}

Measured memory_bytes: 256
///cREATED bY BERNARB.01
#include<bits/stdc++.h>

using namespace std;

int main() {
    ios::sync_with_stdio(0);
	cin.tie(0);
    string s;
    cin >> s;
    if(s[0]==s[1]&&s[1]==s[2]) cout << "No";
    else cout << "Yes";
    return 0;
}


Measured memory_bytes: 764
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

const int maxN = 1e5;
const lli mod = 1e9 + 7;

lli modPow(lli x, lli y)
{
  lli ans = 1;
  while (y)
  {
    if (y & 1LL) ans = ans * x % mod;
    x = x * x % mod, y >>= 1LL;
  }
  return ans;
}
lli memo[maxN + 1];

int main()
{
  int n, k;
  while (scanf("%d %d", &n, &k) != EOF)
  {
    for (lli i = k; i >= 1; i--)
    {
      memo[i] = modPow(k / i, n);
      for (lli j = 2; i * j <= k; j++)
        memo[i] = (memo[i] - memo[i*j] + mod) % mod;
    }
    lli ans = 0;
    for (int i = 1; i <= k; i++)
      ans = (ans + memo[i]*i % mod) % mod;
    printf("%lld\n", ans);
    fflush(stdout);
  }
  return 0;
}

Measured memory_bytes: 4592
import numpy as np
A = np.array([list(map(int,input().split())) for n in range(3)])
N = int(input())
B = [int(input()) for i in range(N)]

for b in B:
  A = np.where(A==b,0,A)

if np.any(np.all(A==0,axis=0)) or np.any(np.all(A==0,axis=1)):
  print("Yes")
  
elif A[0][0]==A[1][1]==A[2][2]==0 or A[0][2]==A[1][1]==A[2][0]==0:
  print("Yes")
  
else:
  print("No")

Measured memory_bytes: 26912
#include<iostream>
#include<string>

using namespace std;

int main()
{
    int N, AC = 0, WA = 0, TLE = 0, RE = 0;
    cin >> N;
    string S[N];
    for(int i = 0; i < N; i++){
        cin >> S[i];
    }
    for(int i = 0; i < N; i++){
        if(S[i][0] == 'A' && S[i][1] == 'C'){
            AC += 1;
        }
        else if(S[i][0] == 'W' && S[i][1] == 'A'){
            WA += 1;
        }
        else if(S[i][0] == 'T' && S[i][1] == 'L' && S[i][2] == 'E'){
            TLE += 1;
        }
        else if(S[i][0] == 'R' && S[i][1] == 'E'){
            RE += 1;
        }
    }
    cout << "AC x " << AC << endl;
    cout << "WA x " << WA << endl;
    cout << "TLE x " << TLE << endl;
    cout << "RE x " << RE << endl;
}

Measured memory_bytes: 6748
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const ll INF = 1e18;

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
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;
}
int ctoi(char c) {
  if (c >= '0' && c <= '9') {
    return c - '0';
  }
  return 0;
}
ll factorial(ll n) {
  if (n == 1) {
    return 1;
  }
  ll ans = factorial(n-1);
  return ans*n;
}
ll gcd(ll a, ll b) {
  if (a < b) {
    ll tmp = a;
    a = b;
    b = tmp;
  }
  ll r = a%b;
  while(r != 0) {
    a = b;
    b = r;
    r = a%b;
  }
  return b;
}
ll lcm(ll a, ll b) {
  return (a/gcd(a, b))*b;
}

int main() {
  ll n, m;
  cin >> n >> m;
  if (n >= 10) {
    cout << m << endl;
  } else {
    cout << m + (10-n)*100 << endl;
  }
}

Measured memory_bytes: 256
n = int(input())
ans = 'Yes'
w = []
for i in range(n):
    w.append(input())
for i in range(0,n-1):
    if w.count(w[i]) > 1:
        ans = 'No'
        break
    elif w[i][-1] != w[i+1][0]:
        ans = 'No'
        break
print(ans)

Measured memory_bytes: 3060
#include <stdio.h>
#include <stdlib.h>

int main(void){
    int x;
    char s[100];
    int stack[100];
    int c = 0;
    
    while(scanf("%s", s) != EOF){
        if ( s[0] == '+' ){
            stack[c-2] = stack[c-2] + stack[c-1];
            c--;
        } else if ( s[0] == '-' ){
            stack[c-2] = stack[c-2] - stack[c-1];
            c--;
        } else if ( s[0] == '*' ){
            stack[c-2] = stack[c-2] * stack[c-1];
            c--;
        } else {
            x = atoi(s);
            stack[c] = x;
            c++;
        }
    }
    printf("%d\n", stack[0]);
    
    return 0;
}



Measured memory_bytes: 2116
L = gets.to_i
s, t = 2.times.map{gets.chomp}.sort_by{|str| str.size}

pt = 0
pt += s.size while s == t[pt, s.size]
t2 = t[pt..-1] + t
s, t = t, s if s > t2

N = s.size
M = t.size
(L/N).downto(0) do |i|
    next if (L - i*N) % M > 0
    j = (L - i*N) / M
    puts (s*i + t*j)
    exit
end

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

long long max(long long a,long long b){
    return a<b ? b : a;
}

int main(){
    int x,y,a,b,c,p[100010],q[100010],r[100010],s[200010][3],i;
    long long ans;

    cin >> x >> y >> a >> b >> c;
    for(i=0;i<a;i++)scanf("%d",p+i);
    for(i=0;i<b;i++)scanf("%d",q+i);
    for(i=0;i<c;i++)scanf("%d",r+i);
    sort(p,p+a,greater<int>());
    sort(q,q+b,greater<int>());
    sort(r,r+c,greater<int>());
    
    r[c]=0;
    int e=0,f=0,g=0,l,n,m;
    for(i=0;i<x+y;i++){
      l = p[e];
      n = q[f];
      m = r[g];
      if(e==x)l=0;
      if(f==y)n=0;
      if(g==c)m=0;
      if(l>=n&&l>=m){
        ans += p[e];
        e++;
      }else if(n>=l&&n>=m){
        ans += q[f];
        f++;
      }else{
        ans += r[g];
        g++;
      }
    }
        
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 1408
X = gets.to_i
case
  when 400 <= X && X <= 599
  puts 8
  when 600 <= X && X <= 799
  puts 7
  when 800 <= X && X <= 999
  puts 6
  when 1000 <= X && X <= 1199
  puts 5
  when 1200 <= X && X <= 1399
  puts 4
  when 1400 <= X && X <= 1599
  puts 3
  when 1600 <= X && X <= 1799
  puts 2
  when 1800 <= X && X <= 1999
  puts 1
end

Measured memory_bytes: 14280
import java.util.Scanner;
 
public class Main {
 
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int a = sc.nextInt();
		int b = sc.nextInt();
		int i;
      
      for(i = 0; a > 0; i++)
        a-=b;

      System.out.println(i);

    }
}

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

int main(){
  int a,b,c;
  int n = 0;
  cin >> a >> b >> c;
  
  for ( int i = a; i <= b; ++i) {
    int x = c % i;
    
    if (x == 0) {
      ++n;
    }
  }
  
  cout << n << endl;
  
  return 0;
}


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

//#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__, __VA_ARGS__)
template <typename Arg1>
void __f(const char* name, Arg1&& arg1){
    cerr << name << " : " << arg1 << std::endl;
}
template <typename Arg1, typename... Args>
void __f(const char* names, Arg1&& arg1, Args&&... args){
    const char* comma = strchr(names + 1, ',');cerr.write(names, comma - names) << " : " << arg1<<" | ";__f(comma+1, args...);
}
#else
#define trace(...)
#endif

#define LL long long

map<int, int> mp;


int main() {
	vector<int> rat {599, 799, 999, 1199, 1399, 1599, 1799, 1999};

	int x;
	cin >> x;

	for(int i=0;i<rat.size();i++) {
		if(x <= rat[i]) {
			cout << 8 - i << endl;
			break;
		}
	}

	return 0;
}


Measured memory_bytes: 3624
#include <stdio.h>

int main(){

  int r,c,n,hyo[101][101],rsum,csum,sum,i,j;
  scanf("%d%d",&r,&c);
  sum=0;
  for(i=0;i<r;i++){
    csum=0;
    for(j=0;j<c;j++){
      scanf("%d",&n);
      hyo[i][j]=n;
      csum += hyo[i][j];
      printf("%d ",hyo[i][j]);
     sum += hyo[i][j];
    }
    printf("%d\n",csum);
  }
  for(i=0;i<c;i++){
    rsum=0;
    for(j=0;j<r;j++){
      rsum += hyo[j][i];
    }
    printf("%d ",rsum);
  }
  printf("%d\n",sum);
  return 0;
}

Measured memory_bytes: 636
#include<stdio.h>
int main ( )
{
  int A,B,C,D;
scanf("%d%d%d%d",&A,&B,&C,&D);
if((A+B)>(C+D))
{
  printf("Left\n");
}
else if((A+B)<(C+D))
{
  printf("Right\n");
}

else
{
  printf("Balanced\n");
}

return 0;
}

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

int main(){
  
  int N, M;
  cin >> N >> M;
  vector<set<int>> V(N+1);
  
  for(int i = 0; i<M; i++){
    int A, B;
    cin >> A >> B;
    V[A].insert(B);
    V[B].insert(A);
  }
  
  
  vector<bool> visited(N+1, false);
  queue<int> que;
  
  int ans = 0;
  
  for(int i = 1; i<N+1; i++){
    if(!visited[i]){
      
      int sum = 1;
      
      visited[i] = true;
      que.push(i);
      
      while(!que.empty()){
        int v = que.front();
        que.pop();
        
        for(int nv : V[v]){
          if(visited[nv]) continue;
          
          sum++;
          visited[nv] = true;
          que.push(nv);
        }
      }
      
      ans = max(ans, sum);
    }
  }
  
  cout << ans << endl;       
}





Measured memory_bytes: 31556
MOD=10**9+7
N=int(input())
A=list(map(int,input().split()))

cnt=A[-1]
sumA=[cnt]
for i in range(N-2,0,-1):
  sumA.append(sumA[-1]+A[i])

ans=0
for i in range(N-1):
  ans+=(A[i]*sumA[-i-1])
print(ans%MOD)

Measured memory_bytes: 31380
#include <bits/stdc++.h>
#define ll long long
#define ld long double
#define ull unsigned ll
#define ioi exit(0);
 
#define f first
#define s second
 
#define inf (ll)1e18 + 7
 
#define NFS ios_base :: sync_with_stdio(0), cin.tie(0), cout.tie(0);
 
#define mp(x,y) make_pair(x,y)
 
#define lb(x) lower_bound(x)
#define ub(x) upper_bound(x)
 
#define pb push_back
#define ppb pop_back
 
#define bitcoin __builtin_popcount
 
#define endl "\n"
 
#define in(x) insert(x)
 
#define sz(x) (int)x.size()
 
#define all(x) x.begin(),x.end()
 
#define pw2(x) (1ll<<x) //2^x
 
#define forit(it,v) for (typeof(v.begin()) it = v.begin(); it != v.end(); ++it)
 
#define sqr(x) ((x) * 1ll * (x))
 
#define UpdateRandom srand (time(NULL));
 
using namespace std;
 
const int N = (int)5e5 + 7, MOD = (int)1e9 + 7;

ll n,W;
ll w[N],v[N],dp[N];

int main(){
		
	NFS

	cin >> n >> W;
	
	for(int i=1;i<=n;i++){
		cin >> w[i] >> v[i];
	}
	
	for(int i=1;i<=W;i++)dp[i]=-inf;
	
	for(int i=1;i<=n;i++){
		for(int j=W;j>=w[i];j--){
			dp[j]=max(dp[j],dp[j-w[i]]+v[i]);
			//cout << dp[j] << ' ' << j << ' ' << i << endl;
		}
	}
	
	ll ans=0;
	
	for(int i=1;i<=W;i++)ans=max(ans,dp[i]);
	
	cout << ans << endl;
	
	//cout << dp[W] << endl;
	
	ioi
}

Measured memory_bytes: 5120
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;



/**
 * Lesson8B 与えられた数の各桁の和を計算するプログラム
 *
 * @author Internship
 *
 */
public class Main{

	/**
	 * プログラムのエントリポイント
	 *
	 * @param args
	 */
	public static void main(String[] args) {

		//答えの格納場所
		ArrayList<Integer> intAry = new ArrayList<Integer>();

		//答えでカウント式
		int intAnswer = 0;

		//各行読み込む
		try {
			BufferedReader insBR = new BufferedReader(new InputStreamReader(System.in));

			while(true) {
				String strLine = insBR.readLine();

				//終了条件
				if(strLine.equals("0")) {
					break;
				}

				//char型に分解
				char[] chaAryLine = strLine.toCharArray();


				//int型にキャスト
				for(int i = 0; i < chaAryLine.length; i++) {
					int intNum = Integer.parseInt("" + chaAryLine[i]);

					//答えをカウント
					intAnswer += intNum;
				}
				intAry.add(intAnswer);

				//答え初期化
				intAnswer = 0;

			}
			int intSize = intAry.size();

		    //出力
			for(int i = 0; i < intSize; i++) {
				System.out.println(intAry.get(i));
			}

		} catch (IOException e) {
			System.out.println(e);
		}

	}
}

Measured memory_bytes: 17200
# import sys
# sys.setrecursionlimit(10 ** 6)
# import bisect
# from collections import deque
# from decorator import stop_watch
#
#
# @stop_watch
def solve(H, W, K, Cxx):
    ans = 0
    for i in range(2 ** H):
        for j in range(2 ** W):
            cnt = 0
            for h in range(H):
                if i >> h & 1 == 1:
                    continue
                for w in range(W):
                    if j >> w & 1 == 1:
                        continue
                    if Cxx[h][w] == '#':
                        cnt += 1
            if cnt == K:
                ans += 1
    print(ans)



if __name__ == '__main__':
    # S = input()
    # N = int(input())
    H, W, K = map(int, input().split())
    Cxx = [input() for _ in range(H)]
    # As = [int(i) for i in input().split()]
    # Bs = [int(i) for i in input().split()]
    solve(H, W, K, Cxx)


Measured memory_bytes: 9016
package main

import (
	"fmt"
	"sort"
)

func main() {
	var N, K, h int
	fmt.Scan(&N, &K)
	A := []int{}
	for n := 0; n < N; n++ {
		fmt.Scanf("%d", &h)
		A = append(A, h)
	}
	sort.Sort(sort.Reverse(sort.IntSlice(A)))
	// fmt.Println(A)
	sum := 0
	for n := 0; n < N; n++ {
		if K-1 >= n {
			continue
		} else {
			sum += A[n]
		}
	}
	fmt.Println(sum)
}


Measured memory_bytes: 8704
#include "bits/stdc++.h"
using namespace std;
#define sim template < class c
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << endl; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
*this << "[";
for (auto it = d.b; it != d.e; ++it)
*this << ", " + 2 * (it == d.b) << *it;
ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define cool ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define int  long long int
#define pb push_back
#define fe first
#define lb lower_bound 
#define ub upper_bound
#define pii pair<pair<int,int>,pair<int,int> >
#define se second
#define endl "\n"
#define pi pair<int, int>
#define mi          map<int,int>
#define mii         map<pi,int>
#define vi vector<int> 
#define vvi vector<vi>
#define bs   binary_search
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rep1(i,a,b) for(int i=a;i<=b;i++)	
#define all(c) (c).begin(),(c).end()
#define sz(x)       (int)x.size() 
#define PI 3.14159265358979323846

 const int N=2e5+5;

 int mod= 1e9+7;
 int dx[4]={0,0,+1,-1};
 int dy[4]={+1,-1,0,0};  
 
 
int po(int a, int b) {
	a %= mod;
	int res = 1;
	while (b > 0) {
		if (b & 1)
			res = (res * a) % mod;
		a =(a*a) % mod;
		b >>= 1;
	}
	 return res;	
   }
  

   vi vf[N],vb[N],v;
   int vis[N],ct=1;
   
   void dfs(int u) {
	       v.pb(u);
	       vis[u]=ct;
	       for(auto to:vf[u]) {
			      if(!vis[to])
			         dfs(to);
			   }       
	   }
   
   
   
   
     void solve() {
	    int  n,m,k;
	    cin>>n>>m>>k;
        rep(i,0,m) {
			   int x,y;
			   cin>>x>>y;
			  --x;--y;
			   vf[x].pb(y);
			   vf[y].pb(x);
			}
		
		rep(i,0,k) {
			   int x,y;
			   cin>>x>>y;
			  --x;--y;
			   vb[x].pb(y);
			   vb[y].pb(x);
			}
	
	
	  vi ans(n,0);
	  
	    rep(i,0,n) {			  
			  if(!vis[i]) {
				     v.clear();
				     dfs(i);
				     int vs1=sz(v);
				     for(auto to:v) {
						   ans[to]=vs1-sz(vf[to])-1;
						   for(auto nax:vb[to]) {
							       if(vis[nax]==ct) ans[to]--;
							   }					   
						}
						ct++;						 
				  }		  
			}
			
			
			for(auto to:ans)
			 cout<<to<<" ";
			 cout<<endl;		 	        
	         					  		   		   
	 }

    
int32_t main() {
	cool;
	int t=1;
	//cin>>t;
	while(t--)
	solve();


return 0;	   
}


Measured memory_bytes: 20600
n,_,*a=map(int,open(0).read().split())
ref={1:2,2:5,3:5,4:4,5:5,6:6,7:3,8:7,9:6}
dp=[0]+[-float('inf')]*(n+9)
for i in range(n+1):
	for x in a:
		if dp[i]<dp[i-ref[x]]*10+x:
			dp[i]=dp[i-ref[x]]*10+x
print(dp[n])

Measured memory_bytes: 14508
#include <iostream>

using namespace std;

void prt(int a[], int n);
int main(){

  int n;
  cin >> n;

  int a[n];

  for(int i = 0; i < n; i++){
    cin >> a[i];
  }
  prt(a, n);

  for(int i = 1; i < n; i++){
    int v = a[i];
    int j = i-1;
    while(j >= 0 && a[j] > v){
      a[j+1] = a[j];
      j--;
    } 
    a[j+1] = v;
    prt(a, n);
  }

  return 0;
}
void prt(int a[], int n){

  for(int i = 0; i < n-1; i++){
    cout << a[i] << ' ';
  }

  cout << a[n-1] << '\n';
}
    



Measured memory_bytes: 3084
N = int(input())
ANS = 10**10 + 2
i = 1
while i * i <= N:
    if (N % i == 0):
        # print(i,' : ', int(N / i))
        max_len = max(len(str(i)),len(str(int(N / i))))
        ANS = min(ANS, max_len)

    i += 1

print(ANS)


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

int main() {
  int N;
  int j = 0;
  string s;
  
  cin >> N;
  
  rep(i, N){
 	cin >> s;
  	if (s == "Y") j++;
  }
  
  if (j > 0) {
    cout << "Four" << endl;
  } else {
    cout << "Three" << endl;
  }
}

Measured memory_bytes: 3592
#define _CRT_SECURE_NO_WARNINGS
#include <iostream>
#include <sstream>
#include <iomanip>
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <cctype>
#include <cstring>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <algorithm>
#include <iterator>
#include <bitset>
#include <ctime>
#include<complex>
using namespace std;

#define FOR(i,a,b) for (int i = (a); i < (b); i++)
#define RFOR(i,b,a) for (int i = (b)-1; i >= (a); i--)
#define ITER(it,a) for (__typeof(a.begin()) it = a.begin(); it != a.end(); it++)
#define FILL(a,value) memset(a, value, sizeof(a))

#define SZ(a) (int)a.size()
#define ALL(a) a.begin(), a.end()
#define PB push_back
#define MP make_pair

typedef long long LL;
typedef vector<int> VI;
typedef pair<int, int> PII;

const double PI = acos(-1.0);
const int INF = 1000 * 1000 * 1000 + 7;
const LL LINF = INF * (LL)INF;

const int L = 16;
const int MAX = 1 << L;
const int MOD = 1000 * 1000 * 1000 + 7;

int G[MAX];
LL dp[MAX];
int n;
int CNT[MAX];

bool isOk(int maskTo, int subMask)
{
	int b1 = (subMask & 1) ? 1 : 0;
	int b2 = (subMask & 2) ? 1 : 0;
	if (b1 != b2) return false;
	FOR(i, 0, n)
	{
		if (maskTo & (1 << i))
		{
			if ((G[i] & subMask) == 0) return false;
		}
	}

	return true;
}

LL f(int maskTo, int subMask)
{
	LL ans = 1;
	FOR(i, 0, n)
	{
		if (((1 << i) & maskTo) != 0)
		{
			int cnt = CNT[G[i] & subMask];
			ans = (ans * ((1 << cnt) - 1) + MOD) % MOD;
		}

		if (((1 << i) & subMask) != 0)
		{
			int cnt = CNT[G[i] & maskTo];
			ans = (ans * (1 << cnt)) % MOD;
		}
	}

	return ans;
}

LL calc(int mask)
{
	if (dp[mask] != -1) return dp[mask];

	dp[mask] = 0;
	for (int subMask = mask; subMask > 0; subMask = (subMask - 1) & mask)
	{
		int maskTo = mask ^ subMask;
		if (!isOk(maskTo, subMask)) continue;
		LL mult = f(maskTo, subMask);
		//cout << "??" << subMask << " " << mult << endl;
		
		dp[mask] = (dp[mask] + mult * calc(maskTo)) % MOD;
	}

	return dp[mask];
}

int main()
{
	//freopen("in.txt", "r", stdin);
	//freopen("out.txt", "w", stdout);
	ios::sync_with_stdio(false); cin.tie(0);
	int m;
	cin >> n >> m;

	FOR(mask, 0, 1 << n)
	{
		FOR(k, 0, n)
		{
			if (mask & (1 << k)) CNT[mask]++;
		}
	}

	FILL(dp, -1);
	dp[0] = 1;

	FOR(i, 0, m)
	{
		int x, y;
		cin >> x >> y;
		x--;
		y--;
		G[x] |= 1 << y;
	}

	LL ans = 1;
	FOR(i, 0, m)
	{
		ans = (ans + ans) % MOD;
	}

	LL t = calc((1 << n) - 1);
	ans = (ans - t + MOD) % MOD;
	cout << ans << endl;
}

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

int main() {
  ll N = 0,ans = 1000;
  cin >> N;
  vector<ll>A(N);
  rep(i,N){
    cin >> A[i];
  }
  rep(i,N-1){
    ll tmp = 0;
    if(A[i] < A[i+1]){
      tmp = ans/A[i];
      ans -= tmp*A[i];
      ans += tmp*A[i+1];
    }
  }
  cout << ans;
}

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

const ll INF = 1LL << 60;
const ll MOD = 1e9 + 7;

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

    string s;
    cin >> s;

    ll n = s.size();

    if (s[n-1] == 's'){
        cout << s << "es" << endl;
    }
    else{
        cout << s << "s" << endl;
    }
}

Measured memory_bytes: 3652
package main

import (
	"bufio"
	"fmt"
	"os"
	"strconv"
	"strings"
)

// Swapping two number
func main() {
	sc := bufio.NewScanner(os.Stdin)
	s := ""
	for i := 0; i < 3000; i++ {
		sc.Scan()
		ary := strings.Split(strings.TrimSpace(sc.Text()), " ")
		x, _ := strconv.Atoi(ary[0])
		y, _ := strconv.Atoi(ary[1])
		if x == 0 && y == 0 {
			break
		} else if x < y {
			s += strconv.Itoa(x) + " " + strconv.Itoa(y) + "\n"
		} else {
			s += strconv.Itoa(y) + " " + strconv.Itoa(x) + "\n"
		}
	}
	fmt.Print(s)
}



Measured memory_bytes: 6060
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<ctime>
#include<cctype>
#include<climits>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<memory>
#include<functional>

#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 llong long long
#define pb(a) push_back(a)
#define INF 999999999
using namespace std;

typedef vector<int> vi;
typedef vector<long long> vl;
typedef vector<double> vd;
typedef pair<int, int> pii;
typedef pair<long, long> pll;
typedef long long ll;

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

double Round(double x){
	x *= 1000;

	if (x > 0.0) {
		x = floor(x + 0.5);
	}
	else {
		x = -1.0 * floor(fabs(x) + 0.5);
	}

	x /= 1000;

	if (-0.0005 < x && x < 0.0005)
		x = 0.0000;

	return x;
}

int main(){
	ios::sync_with_stdio(false);

	int a, b, c, d, e, f;
	double x, y;
	int r;

	while (cin >> a >> b >> c >> d >> e >> f){
		r = b*d - a*e;
		x = Round(1.0*(b*f - c*e) / r);
		y = Round(1.0*(c*d - a*f) / r);
		
		printf("%.3lf %.3lf\n", x, y);
	}
}

Measured memory_bytes: 1244
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define ld long double
#define INF (ll)1e18+4
#define md (ll)1e9+7
#define mx 10000000
#define mk make_pair
#define __builtin_popcountll(x) one(x)
#define pi pair<int,int>
#define ss second
#define ff first
#define pb emplace_back 
#define all(s) s.begin(),s.end()
#define rall(x) (x).rbegin(), (x).rend()
#define trav(x, a) for (auto& x: a)
#define fr(i,a,b) for(int i=a;i<=b;i++)
#define rep(i,a,b) for(int i=a;i<b;i++)
#define per(i,a,b) for(int i=a;i>b;i--)
#define rf(i,a,b) for(int i=a;i>=b;i--)
#define sz(x) ((long long)x.size())
#define mez(s) memset(s,0,sizeof s)
#define mex(s) memset(s,-1,sizeof s)
#define metr(s) memset(s,true, sizeof s)
typedef vector<int> vi; 
typedef vector<ll>vl;
typedef map<int,int> mp;
typedef queue<int> que;
typedef vector<pi> vp;
const int mxn=100010;
int n,k;int a[mxn];
ll dp[mxn];
ll dfs(int r){
	if(r<=0){
		return 0;
	}
  if(dp[r]!=-1)return dp[r];
	ll ans=INF;
	fr(i,1,k){
		if(r-i>=0)
		ans=min(ans,abs(a[r]-a[r-i])+dfs(r-i));
	}
	return dp[r]=ans;
}
void solve(){
	cin>>n>>k;mex(dp);
	rep(i,0,n){
		cin>>a[i];
	}
	ll ans=dfs(n-1);
	cout<<ans<<"\n";
}
int main(){
  ios::sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  //cin>>t;
  while(t--){
  	solve();
  }
  return 0;
}

Measured memory_bytes: 12632
#include <bits/stdc++.h>
using namespace std;
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
#define ALL(v) (v).begin(),(v).end()
#define fi first
#define se second
template<typename A, typename B> inline bool chmax(A &a, B b) { if (a<b) { a=b; return 1; } return 0; }
template<typename A, typename B> inline bool chmin(A &a, B b) { if (a>b) { a=b; return 1; } return 0; }
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<int, pii> pip;
typedef pair<pll, pll> P;
const ll INF = 1ll<<29;
const ll MOD = 1000000007;
const double EPS = 1e-9;
const bool debug = 0;
//---------------------------------//

template<typename T>
struct LazySegTree {
	vector<T> node, lazy;
	vector<bool> done;
	int n;
	T init_val;
	
	LazySegTree(int _n, T init_val) : init_val(init_val) {
		n = 1;
		while (n < _n) n *= 2;
		node.resize(n * 2 - 1, init_val);
		lazy.resize(n * 2 - 1);
		done.resize(n * 2 - 1, true);
	}
	
	void eval(int k, int l, int r) {
		if (done[k]) return;
		node[k] = lazy[k];
		
		if (r - l > 1) {
			lazy[k * 2 + 1] = lazy[k]; done[k * 2 + 1] = false;
			lazy[k * 2 + 2] = lazy[k]; done[k * 2 + 2] = false;
		}
		done[k] = true;
	}
	
	void update(int a, int b, T x, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return;
		if (a <= l && r <= b) {
			lazy[k] = x;
			done[k] = false;
			eval(k, l, r);
		}
		else {
			update(a, b, x, k * 2 + 1, l, (l + r) / 2);
			update(a, b, x, k * 2 + 2, (l + r) / 2, r);
			node[k] = min(node[k * 2 + 1], node[k * 2 + 2]);
		}
	}
	
	T query(int a, int b, int k = 0, int l = 0, int r = -1) {
		if (r < 0) r = n;
		eval(k, l, r);
		
		if (a >= r || b <= l) return init_val;
		if (a <= l && r <= b) return node[k];
		
		ll vl = query(a, b, k * 2 + 1, l, (l + r) / 2);
		ll vr = query(a, b, k * 2 + 2, (l + r) / 2, r);
		return min(vl, vr);
	}
};

int main() {
	int n, q;
	cin >> n >> q;
	
	LazySegTree<ll> st(n, (1ll<<31) - 1);
	
	while (q--) {
		int a, b, c, d;
		cin >> a >> b;
		if (a == 0) {
			cin >> c >> d;
			st.update(b, c + 1, d);
		}
		else {
			cout << st.query(b, b + 1) << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 7032
#include<iostream>
#include<cstdio>
#include<vector>
#include<map>
#include<tuple>
#include<string>
#include<sstream>
#include<cmath>
#include<climits>
#include<algorithm>
#include<bitset>
#include<set>
#include<stack>
#include<queue>
#include<iomanip>
#include<memory.h>
using namespace std;  
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
#define rep(i,n) for(ll i=0;i<(n);i++)  
#define tii tuple<int,int>
#define tiii tuple<int,int,int>
#define mt make_tuple
#define pb push_back  
#define ALL(a) (a).begin(),(a).end()
#define FST first
#define SEC second  
const int INF = (INT_MAX/2);
const ll LLINF = (LLONG_MAX/2);
const double eps = 1e-5;
const double PI = M_PI;  
#define DEB cerr<<"!"<<endl
#define SHOW(a,b) cerr<<(a)<<" "<<(b)<<endl
#define SHOWARRAY(ar,i,j) REP(a,i)REP(b,j)cerr<<ar[a][b]<<((b==j-1)?((a==i-1)?("\n\n"):("\n")):(" "))
#define DIV 1000007
inline ll pow(ll x,ll n,ll m){ll r=1;while(n>0){if((n&1)==1)r=r*x%m;x=x*x%m;n>>=1;}return r%m;}

int main(){
  int a,b,c; cin >> a >> b >> c;
  if(a == b)
      cout << c << endl;
  else if(b == c)
      cout << a << endl;
  else
    cout << b << endl;
}

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

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  int K;
  cin >> K;
  if(K % 2 == 0) {
    cout << (K / 2) * (K / 2) << endl;
  } else {
    K -= 1;
    cout << (K / 2) * (K / 2 + 1) << endl;
  }
  return 0;
}

Measured memory_bytes: 256
// AtCode.cpp : このファイルには 'main' 関数が含まれています。プログラム実行の開始と終了がそこで行われます。

#include <iostream>
#include <string>
#include <vector>
#include <math.h>
#include <algorithm>
#include <stdint.h>
#include <queue>
#include <bitset>

using namespace std;


int main() {

    int N;
    cin >> N;
    string S;
    cin >> S;

    int count = 0;
    for (int i = 0; i <= S.size()-3; i++) {
        if (S[i] == 'A' && S[i + 1] == 'B' && S[i + 2] == 'C') count++;
    }

    cout << count << endl;

    return 0;
}



Measured memory_bytes: 256