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

using namespace std;

#define fo(i,a,b) for (int i=a;i<=b;i++)
#define fd(i,a,b) for (int i=a;i>=b;i--)
#define fi first
#define se second	
#define mkp make_pair

typedef long long ll;

const int N=1100000;

int n,ans,flag,s[N],t[N],pos[N],a[N],b[N];

int read()
{
	int ret=0,sig=1;
	char c;
	while (c=getchar(),(c<'0'||c>'9')&&c!='-');
	if (c=='-') sig=-1;
	else ret=c-'0';
	while (c=getchar(),c>='0'&&c<='9') ret=ret*10+c-'0';
	return ret*sig;
}

int main()
{
	n=read();
	fo(i,1,n)
	{
		char c;
		while (c=getchar(),c<'a'||c>'z');
		s[i]=c-'a'+1;
	}
	fo(i,1,n)
	{
		char c;
		while (c=getchar(),c<'a'||c>'z');
		t[i]=c-'a'+1;
		if (s[i]!=t[i]) flag=1;
	}
	if (!flag) 
	{
		printf("0\n");
		return 0;
	}
	int w=n+1;
	b[0]=1;
	fd(i,n+1,1)
		if (t[i]!=t[i-1])
		{
			b[++b[0]]=i-1;
			while (w&&(w>i||s[w]!=t[i])) w--;
			if (!w)
			{
				printf("-1\n");
				return 0;
			}
			a[++a[0]]=w;
		}
	int tail=1;
	fo(i,2,a[0])
	{
		while (tail<a[0]&&a[tail+1]-(i-tail-1)>=b[i]) tail++;
		ans=max(ans,i-tail);
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 19328
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#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 IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N; 
  cin >> N;

  vector<int> A(N);
  REP(i, N) cin >> A[i];

  vector<int> o(N);
  iota(ALL(o), 0);

  sort(ALL(o), [&](int const & l, int const & r){
      return A[l] > A[r];
      });

  multiset<int> s;
  s.insert(-1); s.insert(N);
  s.insert(-1); s.insert(N);

  int ans = 0;
  REP(i, N){
    int I = o[i];
    auto it = s.upper_bound(I);
    int r1 = *it; it++;
    int r2 = *it; it--; it--;
    int l2 = *it; it--;
    int l1 = *it;
    
    ans += ((l2-l1)*(r1-I)+(I-l2)*(r2-r1))*A[I];
    s.insert(I);
  }

  cout << ans << "\n";

  return 0;
}

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

class Dice {
public:
    Dice(int label1, int label2, int label3, int label4, int label5, int label6)
    {
        m_label[0] = label1;
        m_label[1] = label2;
        m_label[2] = label3;
        m_label[3] = label4;
        m_label[4] = label5;
        m_label[5] = label6;
    }

    void rollDice(std::string command)
    {
        if (command == "East") {
            // 1->3 3->6 6->4 4->1
            int tmpLabelV = m_label[0];
            m_label[0] = m_label[3];
            m_label[3] = m_label[5];
            m_label[5] = m_label[2];
            m_label[2] = tmpLabelV;
        }
        else if (command == "North") {
            // 1->5 5->6 6->2 2->1
            int tmpLabelV = m_label[0];
            m_label[0] = m_label[1];
            m_label[1] = m_label[5];
            m_label[5] = m_label[4];
            m_label[4] = tmpLabelV;
        }
        else if (command == "South") {
            // 1->2 2->6 6->5 5->1
            int tmpLabelV = m_label[0];
            m_label[0] = m_label[4];
            m_label[4] = m_label[5];
            m_label[5] = m_label[1];
            m_label[1] = tmpLabelV;
        }
        else if (command == "West") {
            // 1->4 4->6 6->3 3->1
            int tmpLabelV = m_label[0];
            m_label[0] = m_label[2];
            m_label[2] = m_label[5];
            m_label[5] = m_label[3];
            m_label[3] = tmpLabelV;
        }
        else if (command == "Right") {
            // 2->4 4->5 5->3 3->2
            int tmpLabelV = m_label[1];
            m_label[1] = m_label[2];
            m_label[2] = m_label[4];
            m_label[4] = m_label[3];
            m_label[3] = tmpLabelV;
        }
        else if (command == "Left") {
            // 2->3 3->5 5->4 4->2
            int tmpLabelV = m_label[1];
            m_label[1] = m_label[3];
            m_label[3] = m_label[4];
            m_label[4] = m_label[2];
            m_label[2] = tmpLabelV;
        }
        return;
    }

    int getNumberOnTop(void)
    {
        return m_label[0];
    }

private:
    int m_label[6];
};

int main()
{
    int count = 0;
    int dataSetSum[5] = {0};
    for(count=0; count<5; count++)
    {
        Dice dice1(1, 2, 3, 4, 5, 6);
        int sum=1;
        int actionNum;
        std::cin >> actionNum;
        if(actionNum == 0)
        {
            break;
        }

        std::string command;

        for (int i = 0; i < actionNum; i++) {
            std::cin >> command;
            dice1.rollDice(command);
            sum += dice1.getNumberOnTop();
        }
        dataSetSum[count] = sum;
    }
    for(int i=0; i<count; i++)
    {
        std::cout << dataSetSum[i] << std::endl;
    }
    return 0;
}

Measured memory_bytes: 3188
A = input()
S = list(map(int,list(A)))
N = len(S)
output = 0
for i in range(N):
    t = N-1-i
    M = S[t]
    if M>5:
        output += 10-M
        S[t-1]+=1
    elif M==5:
        if S[t-1]>=5:
            output += 10-M
            S[t-1]+=1
        else:
            output+=M
    else:
        output += M
if S[0]>5:
    output+=1
if A=="5":
    output = 5
print(output)

Measured memory_bytes: 145408
H, W, D = map(int, input().split())
A = [list(map(int, input().split())) for i in range(H)]

Numbers = {}
for h in range(H):
    for w in range(W):
        Numbers[A[h][w]] = (h, w)

Cost = [0] * (H * W + 1)
for i in range(D + 1, H * W + 1):
    Cost[i] = abs(Numbers[i][0] - Numbers[i - D][0]) + abs(Numbers[i][1] - Numbers[i - D][1])
for i in range(H * W + 1 - D):
    Cost[i + D] += Cost[i]

Q = int(input())
for q in range(Q):
    l, r = map(int, input().split())
    print(Cost[r] - Cost[l])


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

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

    int n;
    cin >> n;
    vector<pair<pair<string, int>, int>>v(n);
    for(int i = 0; i < n; i++){
        string str;
        int val;
        cin >> str >> val;
        v[i].first.first = str;
        v[i].first.second = val * -1;
        v[i].second = i+1;
    }
    sort(v.begin(), v.end());

    for(int i = 0; i < n; i++){
        cout << v[i].second << endl;
    }
    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main(void){
    int A,B,C;
    bool flag =false;
    cin>>A>>B>>C;
    for(int i=1;i<=A*B+C;i++){
        if(i%A==0&&i%B==C)
            flag=true;
    }
    if(flag)cout<<"YES"<<endl;
    else cout<<"NO"<<endl;
    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <climits>
#include <cmath>
#include <cstdio>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
#define REP(var, a, b) for (int var = (a); var < (b); var++)
#define rep(var, n) for (int var = 0; var < (n); ++var)
#define ALL(c) (c).begin(), (c).end()
#define rALL(c) (c).rbegin(), (c).rend()
ll MOD = 1000000007;
ll INF = 1e18;

vl z_algorithm(const string& s) {
  vl z(s.size(), 0);
  z[0] = s.size();
  ll lt = 0, rt = 0;
  for (ll k = 1; k < s.size(); k++) {
    if (k > rt) {
      ll n = 0;
      while (k + n < s.size() && s[n] == s[k + n]) {
        n++;
      }
      z[k] = n;
      if (n > 0) {
        lt = k;
        rt = k + n - 1;
      }
    } else {
      ll p = k - lt;
      ll right_len = rt - k + 1;
      if (z[p] < right_len) {
        z[k] = z[p];
      } else {
        ll i = rt + 1;
        while (i < s.size() && s[i] == s[i - k]) {
          i++;
        }
        z[k] = i - k;
        lt = k;
        rt = i - 1;
      }
    }
  }
  return z;
}

ll longest(vl& z, ll tsize, ll start, ll i, vl& data) {
  if (start == i) {
    data[i] = -1;
    return -1;
  }
  if (data[i] >= -1) {
    return data[i];
  }

  if (z[tsize + 1 + i] == tsize) {
    ll next = (i + tsize) % data.size();
    ll tmp = longest(z, tsize, start, next, data);
    if (tmp == -1) {
      data[i] = -1;
      return -1;
    } else {
      data[i] = 1 + tmp;
      return 1 + tmp;
    }
  } else {
    data[i] = 0;
    return 0;
  }
}

int main() {
  //
  string s, t;
  cin >> s;
  cin >> t;
  string ss = s;
  while (ss.size() < s.size() + t.size()) {
    ss += s;
  }
  vl z = z_algorithm(t + "#" + ss);

  ll ans = 0;
  vl data(s.size(), -2);
  rep(i, s.size()) {
    if (z[t.size() + 1 + i] == t.size()) {
      int next = (i + t.size()) % s.size();
      ll tmp = longest(z, t.size(), i, next, data);
      if (tmp == -1) {
        cout << -1 << endl;
        return 0;
      }
      data[i] = tmp + 1;
      ans = max(ans, tmp + 1);
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 38420
#include <cmath>
#include <cstdio>
#include <vector>
#include <cstring>
#include <iostream>
#include <algorithm>
using namespace std;
#define N 1005
#define M 200005
vector<int>E[N];
int n, m, beg[N], len, num[N][N];
bool can[N][N], vis[N], can1[N][N];
int vis1[N], vis2[N], frm[M], tar[M];
void Dfs(int u, int rt)
{
	vis[u] = 1;
	can[rt][u] = 1;
	int t = E[u].size() - 1;
	for (int i = 0; i <= t; i++)
	{
		int v = E[u][i];
		if (vis[v])
			continue;
		Dfs(v, rt);
	}
}
void Dfs1(int u)
{
	vis[u] = 1;
	int t = E[u].size() - 1;
	for (int i = 0; i <= t; i++)
	{
		int v = E[u][i];
		if (vis[v])
			continue;
		vis1[v] = num[u][v];
		Dfs1(v);
	}
}
void Dfs2(int u)
{
	vis[u] = 1;
	int t = E[u].size() - 1;
	for (int i = t; i >= 0; i--)
	{
		int v = E[u][i];
		if (vis[v])
			continue;
		vis2[v] = num[u][v];
		Dfs2(v);
	}
}
int main()
{
	scanf("%d%d", &n, &m);
	for (int i = 1; i <= m; i++)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		E[u].push_back(v);
		num[u][v]=++len;
		frm[len]=u;
		tar[len]=v;
	}
	for (int i = 1; i <= n; i++)
	{
		Dfs(i,i);
		memset(vis, 0, sizeof(vis));
	}
	for (int i = 1; i <= n; i++)
	{
		Dfs1(i);
		memset(vis, 0, sizeof(vis));
		Dfs2(i);
		memset(vis, 0, sizeof(vis));
		int t =E[i].size()-1;
		for (int j = 0; j <= t; j++)
		{
			int v=E[i][j];
			if(vis1[v]!=num[i][v] || vis2[v]!=num[i][v])
				can1[i][v]=1;
		}
		memset(vis1, 0, sizeof(vis1));
		memset(vis2, 0, sizeof(vis2));
	}
	for (int i = 1; i <= m; i++)
	{
		int u = frm[i], v = tar[i];
		if (can[v][u] == can1[u][v])
			puts("same");
		else
			puts("diff");
	}
}


Measured memory_bytes: 12652
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define REP(i,n) FOR(i,0,n)
#define FOR(i,a,b) for(ll i=a;i<b;i++)
#define PB push_back
typedef vector<ll> vi;
typedef vector<vector<ll>> vvi;
typedef pair<ll,ll> pii;
typedef vector<pii> vpii;
typedef pii point;
using namespace std;

int main(){
  string S; cin>>S;
  ll K; cin>>K;
  ll N=S.length();
  unordered_set<string> v;
  REP(i,N){
    ll t=min(N-i+1,6ll);
    FOR(j,1,t){
      v.insert(S.substr(i,j));
    }
  }
  vector<string> a;
  for(string s:v) a.push_back(s);
  sort(a.begin(),a.end());
  cout<<a[K-1]<<endl;
}


Measured memory_bytes: 1792
#include <bits/stdc++.h>
using namespace std;
#define MOD 1000000007
//#define MOD 998244353
#define INF 1145141919810893364
typedef pair<int,int> PP;
typedef long long ll;
#define int ll
#define setdouble setprecision
#define REP(i,n) for(int i=0;i<(n);++i)
#define OREP(i,n) for(int i=1;i<=(n);++i)
#define RREP(i,n) for(int i=(n)-1;i>=0;--i)
#define GOODBYE cout << -1 << endl;return 0
#define twin(s) s?cout << "Yay!" << endl:cout << ":(" << endl
#define Endl endl


signed main(void){
    int N;
    int x[57],y[57];
    int num=0;
    map<pair<int,int>,int> M;
    cin >> N;
    REP(i,N){
        cin >> x[i] >> y[i];
    }
    REP(i,N){
        REP(j,N){
            if(i!=j && (x[i]!=x[j] || y[i]!=y[j])){
                M[{x[i]-x[j],y[i]-y[j]}]+=1;
                //cout << x[i]-x[j] << " " << y[i]-y[j] << endl;
            }
        }
    }
    REP(i,N){
        REP(j,N){
            if(i!=j && (x[i]!=x[j] || y[i]!=y[j])){
                num=max(num,M[{x[i]-x[j],y[i]-y[j]}]);
                M[{x[i]-x[j],y[i]-y[j]}]=0;
            }
        }
    }
    cout << N-num << endl;
    return 0;
}



Measured memory_bytes: 384
import bisect
def main():
    N = int(input())
    A = [int(_) for _ in input().split()]
    B = [-a-i for i, a in enumerate(A)]
    C = sorted([a-i for i, a in enumerate(A)])
    D = [a+i for i, a in enumerate(A)]
    E = sorted([i-a for i, a in enumerate(A)])

    output = 0
    for b in B:
        x = bisect.bisect_left(C, b)
        y = bisect.bisect_right(C, b)
        output += y - x
    for d in D:
        x = bisect.bisect_left(E, d)
        y = bisect.bisect_right(E, d)
        output += y - x
    print(output//2)
    return

if __name__ == '__main__':
    main()


Measured memory_bytes: 51372
#include <iostream>
#include <algorithm>
#include <cmath>

using namespace std;

int calc(int p, int q, int mind, int ca, int a, int cn, int n){
        int s = 0; 
        if(cn <= n){
                mind = max(mind,q/p);
                int maxd = floor((double)(n-cn+1)*q/p);
                for(int i = mind;i <= maxd && pow(i,floor((double)i*p/q))*ca <= a;i++){
                        if(p*i-q==0){
                                s++;
                        }else if(p*i-q > 0){
                                int _p = p*i-q;
                                int _q = q*i;
                                s += calc(_p,_q,i,ca*i,a,cn+1,n);
                        }
                }
        }
        return s;
}

int main(){
        int p,q,a,n;
        cin >> p >> q >> a >> n;
        while(p){
                for(int i = 2; i <= min(p,q); i++){
                        while(p%i+q%i == 0){
                                p /= i;
                                q /= i;
                        }
                }
                cout << calc(p,q,1,1,a,1,n) << endl;
                cin >> p >> q >> a >> n;
        }
}

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

using ll = long long;
const long long MOD = 1000000007;

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

    vector<ll> a(N);
    vector<ll> can_change(33, 0);
    ll x = 0;
    for(int i=0;i<N;i++){
        cin >> a[i];
        x ^= a[i];
        ll diff = (a[i] - 1) ^ a[i];
        for(int bit=32;bit>=0;bit--){
            if((diff>>bit)&1){
                can_change[bit] = a[i];
                break;
            }
        }
    }

    ll ans = 0;
    for(int bit=32;bit>=0;bit--){
        if (((x >> bit)&1)==0) continue;
        if(can_change[bit] == 0){
            cout << -1 << endl;
            return 0;
        }else{
            x ^= can_change[bit];
            x ^= can_change[bit] - 1;
            ans++;
        }
    }
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
    #include<algorithm>
    #include<cmath>
    #include<climits>
    using namespace std;
    typedef long long int lli;
    typedef vector<int> vi;
    typedef vector<long long int> vlli;
    typedef pair<int,int> pii;
    typedef pair<long long int,long long int> plli;
    typedef vector< vi > vvi ;
    typedef vector< vlli > vvlli  ;
    #define fi(i,a,b) for(int i=a;i<=b;i++)
    #define flli(i,a,b) for(long long int i=a;i<=b;i++)
    #define bi(i,a,b) for(int i=a;i>=b;i--)
    #define blli(i,a,b) for(long long int i=a;i>=b;i--)
    #define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
    #define all(x) x.begin(),x.end()
    #define sz(x) x.size()
    #define pi 2*acos(0.0)
    #define pb push_back
    #define tr(v,it) for(decltype(v.begin()) it=v.begin();it!=v.end();it++)
    #define present(v,num) (v.find(num)!=v.end())
    #define cpresent(v,num) (find(v.begin(),v.end(),num)!=v.end())
    #define pq priority_queue
    #define mp make_pair
    const int inf=INT_MAX;
    const lli INF =LLONG_MAX;
    const lli mod = 1e9+7;
    int main() {
        #ifndef ONLINE_JUDGE
        freopen("input.txt", "r", stdin);
        freopen("output.txt", "w", stdout);
        #endif
        fast;
        lli n;cin>>n;
        vlli div(n+1,0);
        flli(i,1,n)
        {
        	for(lli j=i;j<=n;j+=i)
        	{
        		div[j]++;
        	}
        }
        lli ans=0;
        flli(i,1,n)
        {
        	ans+=i*div[i];
        }
        cout<<ans;
        cerr << "Time : " << 1000 * ((double)clock()) / (double)CLOCKS_PER_SEC << "ms\n";
        return 0;
    }

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

int main(){
	int n,m,i;
	cin>>n>>m;
	int a[m+1];
	
	for(i=1;i<=m;i++)
	{
		cin>>a[i];
		n-=a[i];
	}
	
	if(n>=0)
		cout<<n<<endl;
	else
		cout<<-1<<endl;
		
	return 0;
} 

Measured memory_bytes: 3672
def dfs(seq):
    ans = 0

    if len(seq) == n:
        score = 0
        for a, b, c, d in req:
            if seq[b-1] - seq[a-1] == c:
                score += d
        return score
    else:
        for i in range(seq[-1], m+1):
            next_seq = seq + (i,)
            score = dfs(next_seq)
            ans = max(ans, score)
    return ans

n, m, q = list(map(int, input().split()))
req = [list(map(int, input().split())) for _ in range(q)]

print(dfs((1,)))


Measured memory_bytes: 9140
#include <stdio.h>

int isPrime(int x){
  int i;

  if(x == 2)    return 1;
  if(x < 2 || x % 2 == 0)    return 0;

  for(i = 3; i * i <= x; i = i + 2){
    if(x % i == 0)    return 0;
  }

  return 1;
}

int main(){
  int n, x, i;
  int cnt = 0;
  scanf("%d", &n);
  for ( i = 0; i < n; i++){
    scanf("%d", &x);
    if(isPrime(x))cnt++;
  }
  printf("%d\n", cnt);

  return 0;
}

Measured memory_bytes: 596
#include<cstdio>
#include<cstring>
#include<iomanip>
#include<iostream>
#include<algorithm>
#include<cmath>
#include<ctime>
#include<map>
#include<set>
#include<vector>
#include<queue>
#include<bitset>
#include<stack>
#include<cassert>
#define F first
#define S second
#define mp make_pair
#define pii pair<int,int>
#define pb push_back
#define mem(x,y) memset(x,y,sizeof x)
#define sqr(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef double db;
const int INF=2e9;
const db eps=1e-8;
template<typename T>
inline void read(T &x)
{
	x=0; int f=1; char ch=getchar();
	while( (ch<'0' || ch>'9') && ch!='-') ch=getchar(); if(ch=='-') {f=-1; ch=getchar();}
	while(ch>='0' && ch <='9') x=x*10+ch-'0',ch=getchar();
	x*=f;
}
//==========================head template==========================
const int N=100010;
int n;
char s[20];
inline int trans(char x) {
	if(x=='V') return 2;
	if(x=='M') return 0;
	if(x=='F') return 1;
	throw;
}
inline int Ask(int u) {
	printf("%d\n",u);
	fflush(stdout);
	scanf("%s",s+1);
	return trans(s[1]);
}
inline bool judge(int pos,bool t1,bool t2) {
	return (!(pos&1)) ^ t1^t2;
}
signed main()
{
	read(n);
	int type=Ask(0); if(type==2) return 0;
	int l=0,r=n-1;
	while(l<=r) {
		int mid=l+r>>1;
		int t=Ask(mid);
		if(t==2) return 0;
		if(judge(mid,t,type)) l=mid+1;
		else r=mid-1;
	}
	return 0;
}

Measured memory_bytes: 852
//              +-- -- --++-- +-In the name of ALLAH-+ --++-- -- --+              \\

#include <bits/stdc++.h>

#define F first
#define S second
#define _sz(x) (int)x.size()

using namespace std ;
using ll = long long ;
using ld = long double ;
using pii = pair <int , int> ;

int const N = 4000 + 20 , mod = 998244353 ;

int k , n ;
int C[N][N] , p2[N] ;

inline void rel (int &a) {
	if (a >= mod) a -= mod ;
}

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

	for (int i = 0 ; i < N ; i ++) {
		p2[i] = (i ? 2 * p2[i - 1] % mod : 1) ;
		C[i][0] = C[i][i] = 1 ;
		for (int j = 1 ; j < i ; j ++) {
			C[i][j] = C[i - 1][j] + C[i - 1][j - 1] ;
			rel(C[i][j]) ;
		}
	}

	cin >> k >> n ;

	for (int sum = 2 ; sum <= 2 * k ; sum ++) {
		int l = max(1 , sum - k) , r = min(k , sum - 1) ;

		int a = max(0 , r - l + 1) , b = 0 , c = k - a ;

		int ans = 0 ;

		if (sum % 2 == 0) a -- , b ++ ;
		a /= 2 ;

		for (int i = 0 ; i <= a ; i ++) {
			for (int j = 0 ; j <= b ; j ++) {
				int m = n - j ;	
			
				ans += 1ll * C[a][i] * p2[i] % mod * C[m + c - 1][i + c - 1] % mod ;
				rel(ans) ;
			}
		}

		cout << ans << '\n' ;
	}
}


Measured memory_bytes: 61952
import java.util.Scanner;

public class Main {	
	public static void main(String[] args) {
		Scanner scan = new Scanner(System.in);
		int a = scan.nextInt();
		int b = scan.nextInt();
		if (a>8  || b>8) {
			System.out.println(":(");
		} else {
			System.out.println("Yay!");
		}
	}
}


Measured memory_bytes: 21844
//Written by Zhu Zeqi
//Come on,baby
//Hack,please
#include<cmath>
#include<math.h>
#include<ctype.h>
#include<algorithm>
#include<bitset>
#include<cassert>
#include<cctype>
#include<cerrno>
#include<cfloat>
#include<ciso646>
#include<climits>
#include<clocale>
#include<complex>
#include<csetjmp>
#include<csignal>
#include<cstdarg>
#include<cstddef>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<ctime>
#include<cwchar>
#include<cwctype>
#include<deque>
#include<exception>
#include<fstream>
#include<functional>
#include<iomanip>
#include<ios>
#include<iosfwd>
#include<iostream>
#include<istream>
#include<iterator>
#include<limits>
#include<list>
#include<locale>
#include<map>
#include<memory>
#include<new>
#include<numeric>
#include<ostream>
#include<queue>
#include<set>
#include<sstream>
#include<stack>
#include<stdexcept>
#include<streambuf>
#include<string>
#include<typeinfo>
#include<utility>
#include<valarray>
#include<vector>
#include<string.h>
#include<stdlib.h>
#include<stdio.h>
#define CLR(x) memset(x,0,sizeof x)
#define pb push_back
#define mp make_pair
#define F first
#define S second
#define pii pair<int,int>
#define vi vector<int>
#define MAX 1000000000000000000
#define MOD 1000000007
#define PI 3.141592653589793238462
#define INF 0x3f3f3f3f
typedef long long ll;
//orz yht
using namespace std;
string i_s(int x){
	if(x==0)
	return "0";
	string ret="";
	while(x){
		ret=ret+(char)(x%10+'0');
		x/=10;
	}
	reverse(ret.begin(),ret.end());
	return ret;
}
string add(string a,string b){
	if(a=="")
	a="0";
	if(b=="")
	b="0";
	if(a.length()<b.length())
	swap(a,b);
	while(b.length()<a.length()){
		b='0'+b;
	}
	for(int i=0;i<a.length();i++){
		a[i]=a[i]+(b[i]-'0');
	}
	bool big=false;
	for(int i=a.length()-1;i>=0;i--){
		if(big){
			a[i]++;
		}
		big=false;
		if(a[i]>'9'){
			a[i]=a[i]-10;
			big=true;
		}
	}
	if(big)
	a='1'+a;
	return a;
}
string mul(string a,string b){
	vector<int> va,vb;
	if(a=="0" || b=="0")
	return "0";
	string ans;
	for(int i=0;i<a.length();i++){
		va.push_back(a[i]-'0');
	}
	for(int i=0;i<b.length();i++){
		vb.push_back(b[i]-'0');
	}
	reverse(va.begin(),va.end());
	reverse(vb.begin(),vb.end());
	vector<int> res;
	res.clear();
	res.resize(1005);
	for(int i=0;i<a.length();i++){
		for(int j=0;j<b.length();j++){
			res[i+j]+=(va[i]*vb[j]);
		}
	}
	for(int i=0;i<1005;i++){
		if(res[i]>9){
			res[i+1]+=(res[i]/10);
			res[i]%=10;
		}
	}
	for(int i=0;i<1005;i++){
		ans+=(res[i]+'0');
	}
	reverse(ans.begin(),ans.end());
	int k=0;
	while(ans[k]=='0'){
		k++;
	}
	ans=ans.substr(k);
	return ans;
}
bool is_prime(int n){
	if(n<2)
    return false;
    for(int i=2;i*i<=n;i++)
    if(n%i==0)
    return false;
    return true;
}
int main(){
	//freopen("input.in","r",stdin);
	//freopen("output.out","w",stdout);
	int n;
	cin>>n;
	set<int> s;
	for(int i=0;i<n;i++){
		int x;
		cin>>x;
		if(s.count(x))
		s.erase(x);
		else
		s.insert(x);
	}
	cout<<s.size();
	//system("pause");
	return 0;
}

Measured memory_bytes: 4864
#include <iostream>
#include <climits>
#include <set>
#include <string>
#include <algorithm>
#include <vector>
#define MAX 1000000007


using namespace std;
#define ll long long
#define dbg if(0)
#define ISRANGE(val,lo,hi) ((lo<=val)&&(val<hi))


ll top(ll i){
    if(i<10)return i;
    return top(i/10);
}

int main(){
    ll ans=0,ans1=0,n;
    cin>>n;
    /* //模範解答。
    ll c[10][10];
    for(int i=0;i<10;i++){
        for(int j=0;j<10;j++){
            c[j][i]=0;
        }
    }
    for(int i=1;i<=n;i++){
        ll a=i%10;//aは0~9のみ
        ll b=top(i);//bは1~9のみ
        c[a][b]++;
    }
    for(int i=0;i<=9;i++){
        for(int j=0;j<=9;j++){
            ans1+=c[i][j]*c[j][i];
            //c[k][0]は常に0が入っているため、for文は0から回しても大丈夫だった
        }
    }
    cout<<ans1<<endl;
    */
    for( int i=1;i<=9;i++){
        for( int j=1;j<=9;j++){
        ll p=0;
        ll t=0;
        ll a=0;
        ll b=0;
            if(i==j && i<=n)p++;
            if(max(i*10+j,j*10+i)<=n)t++;
            ll by=100;
            while(i*by+j<=n){//入れ替える前のもの個数
                a+=(min(((n-(i*by+j))/10),by/10-1))%(by/10)+1;
                by*=10;
            } 
            by=100;
            while(j*by+i<=n){//入れ替えたものの個数
                b+=(min(((n-(j*by+i))/10),by/10-1))%(by/10)+1;
                by*=10;
            } 
            ans+=(p+t+a)*(p+t+b);
        }
    }


    cout <<ans<<endl;

    return 0;

}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0;i<n;i++)
#define rep2(i,a,n) for(int i=a;i<n;i++)
#define been(ix) (ix).begin(),(ix).end()
using namespace std;
typedef long long ll; 
typedef vector<int> vi;
typedef vector<long long> vl;
const ll INFL = 1e18;
const int INF = 1001001001; 
typedef pair<int,int> P;
#define foreach(ix,i) for(auto& (ix) : (i))
typedef long double ld;
const int mod =1000000007;
const double PI = acos(-1);
int main(){
    int n;cin>>n;
    vl ans(100005,0);
    rep2(i,1,101){
        rep2(j,1,101){
            rep2(k,1,101){
                ans[i*i+j*j+k*k+i*j+j*k+i*k]++;
            }
        }
    }
    rep(i,n)cout<<ans[i+1]<<endl;

}

Measured memory_bytes: 3956
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
 
#define pb push_back
#define f first
#define s second
#define lb lower_bound
#define ub upper_bound
 
typedef long long ll;
typedef vector<int> vi;
typedef unsigned long ul;
typedef vector<ll> vl;
typedef pair<int,int> pi;
typedef vector<pi> vpi;
typedef set<int> si;
typedef multiset<int> mi;
 
const ll INF = 1e18;
const int MOD = 1e9+7;
 
int main() {
	
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	string n;
	cin >> n;
	
	ll sum=0;
	
	for(int i=0; i<n.size(); ++i) sum+=int(n[i]-'0');
	
	if(sum%9==0) cout << "Yes\n";
	else cout << "No\n";
	
	return 0;
}


Measured memory_bytes: 3776
#include<cmath>
#include<cstdio>
#include<cctype>
#include<cstring>
#include<algorithm>
using namespace std;
const int N=1600005,mod=924844033;
int n,nm,t1,t2,cnt,G,Gi;
int p[N],noww[N],goal[N],siz[N];
int rev[N],fac[N],inv[N],a[N],b[N],pw[30][2];
void Read(int &x)
{
	x=0; char ch=getchar();
	while(!isdigit(ch))
		ch=getchar();
	while(isdigit(ch))
		x=(x<<3)+(x<<1)+(ch^48),ch=getchar();
}
int Addit(int x,int y)
{
	x+=y;
	if(x>=mod) x-=mod;
	return x;
}
int Qpow(int x,int k)
{
	if(k==1) return x;
	int tmp=Qpow(x,k/2);
	return k%2?1ll*tmp*tmp%mod*x%mod:1ll*tmp*tmp%mod;
}
void Link(int f,int t)
{
	noww[++cnt]=p[f];
	goal[cnt]=t,p[f]=cnt;
	noww[++cnt]=p[t];
	goal[cnt]=f,p[t]=cnt;
}
int C(int a,int b)
{
	return 1ll*fac[a]*inv[b]%mod*inv[a-b]%mod;
}
void DFS(int nde,int fth)
{
	siz[nde]=1;
	for(int i=p[nde];i;i=noww[i])
		if(goal[i]!=fth)
		{
			DFS(goal[i],nde);
			a[siz[goal[i]]]++;
			siz[nde]+=siz[goal[i]];
		}
	a[n-siz[nde]]++;
}
void Pre()
{
	fac[0]=inv[0]=1;
	for(int i=1;i<=n;i++) fac[i]=1ll*fac[i-1]*i%mod;
	inv[n]=Qpow(fac[n],mod-2);
	for(int i=n-1;i;i--) inv[i]=1ll*inv[i+1]*(i+1)%mod;
	nm=2*n,n=1; while(n<=nm) n<<=1; G=5,Gi=Qpow(G,mod-2),nm>>=1;
	for(int i=1;i<=n;i++) rev[i]=(rev[i>>1]>>1)+(i&1)*(n>>1);
	for(int i=1;i<=24;i++)
	{
		pw[i][0]=Qpow(G,(mod-1)/(1<<i));
		pw[i][1]=Qpow(Gi,(mod-1)/(1<<i));
	}
	for(int i=0;i<=nm;i++) a[i]=1ll*a[i]*fac[i]%mod,b[i]=inv[nm-i];
}
void Trans(int *arr,int len,int typ)
{
    register int i,j,k;
    for(i=0;i<len;i++)
        if(rev[i]>i) swap(arr[rev[i]],arr[i]);
    for(i=2;i<=len;i<<=1)
    {
        int lth=i>>1,ort=pw[(int)log2(i)][typ==-1];
        for(j=0;j<len;j+=i)
        {
            int ori=1,tmp;
            for(k=j;k<j+lth;k++,ori=1ll*ori*ort%mod)
            {
                tmp=1ll*ori*arr[k+lth]%mod;
                arr[k+lth]=(arr[k]-tmp+mod)%mod;
                arr[k]=(arr[k]+tmp)%mod;
            }
        }
    }
    if(typ==-1)
    {
    	int Ni=Qpow(len,mod-2);
        for(i=0;i<=len;i++)
            arr[i]=1ll*arr[i]*Ni%mod;
	}
}
int main()
{
	Read(n);
	for(int i=1;i<n;i++)
		Read(t1),Read(t2),Link(t1,t2);
	DFS(1,0),Pre();
	Trans(a,n,1),Trans(b,n,1);
	for(int i=0;i<n;i++) a[i]=1ll*a[i]*b[i]%mod;
	Trans(a,n,-1);
	for(int i=1;i<=nm;i++)
	{
		int ans=1ll*C(nm,i)*nm%mod-1ll*a[nm+i]*inv[i]%mod;
		printf("%d\n",Addit(ans,mod));
	}
	return 0;
}

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


int main() {
	int n, x, l[110];
	cin >> n >> x;
	for (int i = 0; i < n; i++) cin >> l[i];
	int point = 0, ans = 1;
	for (int i = 0; i < n; i++) {
		point += l[i];
		if (point <= x) ans++;
		else break;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 256
#include <iostream>
using namespace std;
long long a,b,c,d,n;
int main(void){
   cin>>a>>d>>n>>b>>c>>n>>n;
   n=a%2+b%2+c%2;
   if(a*b*c&&n>=2)++n%=2;
   cout<<a+b+c+d-n;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const double pi=3.141592653589793;
typedef unsigned long long ull;
typedef long double ldouble;
const ll INF=1e18;

vector<int> cost(1000000);
vector<vector<int>> data(1000000);


int main(){
    int n;
    vector<int> answers(4);
    fill(answers.begin(), answers.end(), 0);
    cin >> n;
    for(int i = 0; i < n; i++){
        string str;
        cin >> str;
        if(str == "AC") answers.at(0)++;
        else if(str == "WA") answers.at(1)++;
        else if(str == "TLE") answers.at(2)++;
        else if(str == "RE") answers.at(3)++;
    }
    cout << "AC x " << answers.at(0) <<endl;
    cout << "WA x " << answers.at(1) <<endl;
    cout << "TLE x " << answers.at(2) <<endl;
    cout << "RE x " << answers.at(3) <<endl;
}

Measured memory_bytes: 30476
/*
LANG:C++
PROB:

*/
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <functional>
#include <iostream>
#define mp make_pair
#define mt make_tuple
#define fi first
#define se second
#define pb push_back
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
#define for1(i, n) for (int i = 1; i <= (int)(n); ++i)
#define ford(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define fore(i, a, b) for (int i = (int)(a); i <= (int)(b); ++i)


using namespace __gnu_pbds;
using namespace std;


typedef tree<int, null_type, less<int>, rb_tree_tag,
            tree_order_statistics_node_update>
    ordered_set;

typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<pii> vpi;
typedef vector<vi> vvi;
typedef long long i64;
typedef vector<i64> vi64;
typedef vector<vi64> vvi64;
typedef pair<i64, i64> pi64;
typedef double ld;
typedef unsigned long long ui64;

template<class T> bool uin(T &a, T b) { return a > b ? (a = b, true) : false; }
template<class T> bool uax(T &a, T b) { return a < b ? (a = b, true) : false; }
const int mod=1000000007;
  i64 poww(i64 a, i64 b)
  {
    a%=mod;
    i64 res=1;
    while(b)
      {
if(b&1)res=res*a%mod;

      a=a*a%mod;
      b/=2;

      }
      return res;
  }
  i64 inv(i64 a)
  {
    return poww(a,mod-2);
  }


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

    // ifstream fin(".in");
    // ofstream fout(".in");

i64 n,k,s;
cin>>n>>k>>s;
i64 mx=s+1;
if(s==1e9)mx=s-100;
vi64 v(n,mx);
for(int i=0;i<k-1;i++)
v[i]=s;
if(k>0)
v[k-1]=s;

for(int i=0;i<n;i++)cout<<v[i]<<" ";
    return 0;
  }


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

using namespace std;

using ll = long long;
using P = pair<ll, ll>;
using Graph = vector<vector<ll>>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
const int dx[4] = {1, 0, -1, 0};
const int dy[4] = {0, 1, 0, -1};
const int ddx[8] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll MOD = 1000000007;
const ll INF = 1000000000000000000L;
#ifdef __DEBUG

/**
 * For DEBUG
 * https://github.com/ta7uw/cpp-pyprint
 */
#include "cpp-pyprint/pyprint.h"

#endif

void Main() {
    int N;
    cin >> N;
    vector<ll> A(N);
    rep(i, N) cin >> A[i];

    vector<vector<ll>> dp(N + 1, vector<ll>(2, 0));

    dp[0][0] = 0;
    dp[0][1] = -INF;
    rep(i, N) {
        ll a = A[i];
        dp[i + 1][0] = max(dp[i][0] + a, dp[i][1] - a);
        dp[i + 1][1] = max(dp[i][0] - a, dp[i][1] + a);
    }
    cout << dp[N][0] << '\n';
}

int main() {
    cin.tie(nullptr);
    ios::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    Main();
    return 0;
}


Measured memory_bytes: 6528
#include <bits/stdc++.h>
#define int long long
#define rep(i, a, n) for(int i = (int)(a);(i) < (int)(n);++(i))
#define repe(i, a, n) for(int i = (int)(a);(i) <= (int)(n);++(i))
#define repif(i, a, x) for(int i = (int)(a);(x);++(i))
#define repr(i, a, n) for(int i = ((int)(a)-1);(i) >= (int)(n);--(i))
#define reper(i, a, n) for(int i = (int)(a);(i) >= (int)(n);--(i))
#define SZ(x) ((int)(x).size())
#define ALL(x) begin(x), end(x)
#define RNG(x, a, n) begin(x)+(a), begin(x)+(n)
#define ADD(a, b) ((((a)%MOD+MOD)%MOD+((b)%MOD+MOD)%MOD)%MOD)
#define SUB(a, b) ((((a)%MOD+MOD)%MOD-((b)%MOD+MOD)%MOD+MOD)%MOD)
#define MUL(a, b) (((((a)%MOD+MOD)%MOD)*(((b)%MOD+MOD)%MOD))%MOD)
#define CHADD(a, b) (a = ADD(a, b))
#define CHMUL(a, b) (a = MUL(a, b))
#define CEIL(x) ((int)ceil(((double)x)))
#define POW(x, y) ((int)pow(x, y))
#define UNIQUE(x) (x).erase(unique(ALL((x))), (x).end())
#define gcd(x, y) __gcd(x, y)
#define lcm(x, y) ((x)/gcd(x,y)*(y))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define YES cout << "YES" << endl
#define NO cout << "NO" << endl
#define Yes cout << "Yes" << endl
#define No cout << "No" << endl
#define yes cout << "yes" << endl
#define no cout << "no" << endl
#define fcout cout << fixed << setprecision(10)
#define pb push_back
#define eb emplace_back
#define lb lower_bound
#define ub upper_bound
#define PI (acos(-1))
#define EPS (1e-10)
#define INF LLONG_MAX
#define MOD 1000000007LL
using namespace std;
using VI = vector<int>;
using PII = pair<int, int>;
using TIII = tuple<int, int, int>;
using VPII = vector<PII>;
using VTIII = vector<TIII>;
using Complex = complex<double>;
template<typename T, template<typename> typename C = less> using PQ = priority_queue<T, vector<T>, C<T>>;
template<typename T> bool chmax(T& a, const T& b){ if(a<b){ a=b; return true; } return false; }
template<typename T> bool chmin(T& a, const T& b){ if(a>b){ a=b; return true; } return false; }


int H, W;
int A[90][90], B[90][90];
bool dp[90][90][12730];


signed main(){
    cin >> H >> W;
    rep(i, 0, H) rep(j, 0, W) cin >> A[i][j];
    rep(i, 0, H) rep(j, 0, W) cin >> B[i][j];

    dp[0][0][abs(A[0][0]-B[0][0])] = true;
    rep(i, 0, H) rep(j, 0, W){
        rep(k, 0, 12730){
            if(!dp[i][j][k]) continue;
            if(j+1 < W){ int d = abs(A[i][j+1]-B[i][j+1]); dp[i][j+1][k+d] = dp[i][j+1][abs(k-d)] = true; }
            if(i+1 < H){ int d = abs(A[i+1][j]-B[i+1][j]); dp[i+1][j][k+d] = dp[i+1][j][abs(k-d)] = true; }
        }
    }

    int ans = -1;
    rep(i, 0, 12730) if(dp[H-1][W-1][i]){ ans = i; break; }

    cout << ans << endl;

    return 0;
}

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

using namespace std;

#define debug(n) cerr << #n << ':' << n << endl;
#define dline    cerr << __LINE__ << endl;

using ll = long long;
template<class T, class U> using P = pair<T,U>;
template<class T> using Heap = priority_queue<T>;
template<class T> using heaP = priority_queue<T,vector<T>,greater<T>>;
template<class T,class U> using umap = unordered_map<T,U>;
template<class T> using uset = unordered_set<T>;

template<class T>
bool ChangeMax(T&a,const T&b){
  if(a >= b) return false;
  a = b;    return true;
}

template<class T>
bool ChangeMin(T&a,const T&b){
  if(a <= b) return false;
  a = b;    return true;  
}

template<class T, size_t N, class U>
void Fill(T (&a)[N], const U&v){
    fill((U*)a,(U*)(a+N),v);
}

template<class T>
istream& operator >> (istream&is, vector<T>&v){
  for(auto&e:v)is >> e;
  return is;
}

int main(){
  int a,b,c; cin >> a >> b >> c;
  string s = "";
  if(a + b + c >= 22)s = "bust";
  else s = "win";
  cout << s << endl;
  return 0;
}


Measured memory_bytes: 256
# include <iostream>
# include <algorithm>
#include <array>
# include <cassert>
#include <cctype>
#include <climits>
#include <numeric>
# include <vector>
# include <string>
# include <set>
# include <map>
# include <cmath>
# include <iomanip>
# include <functional>
# include <tuple>
# include <utility>
# include <stack>
# include <queue>
# include <list>
# include <bitset>
# include <complex>
# include <chrono>
# include <random>
# include <limits.h>
# include <unordered_map>
# include <unordered_set>
# include <deque>
# include <cstdio>
# include <cstring>
#include <stdio.h>
#include<time.h>
#include <stdlib.h>
#include <cstdint>
#include <cfenv>
#include<fstream>
//#include <bits/stdc++.h>
using namespace std;
using LL = long long;
using ULL = unsigned long long;
long long MOD = 1000000000 + 7; //924844033 1000000000 + 9;
constexpr long long INF = numeric_limits<LL>::max();
const double PI = acos(-1);
#define fir first
#define sec second
#define thi third
#define debug(x) cerr<<#x<<": "<<x<<'\n'
typedef pair<LL, LL> Pll;
typedef pair<double, double> Dll;
typedef pair<LL, pair<LL, LL>> Ppll;
typedef pair<LL, pair<LL, bitset<100001>>> Pbll;
typedef pair<LL, pair<LL, vector<LL>>> Pvll;
typedef pair<LL, LL> Vec2;
struct Tll { LL first, second, third; };
struct Fll { LL first, second, third, fourth; };
typedef pair<LL, Tll> Ptll;
#define rep(i,rept) for(LL i=0;i<rept;i++)
#define Rrep(i,mf) for(LL i=mf-1;i>=0;i--)
LL h, w, n, m, k, t, s, p, q, last, first, cnt, sum[1<<20], ans, a[20][20], b[220000],dp[1<<20];
string str, ss;
bool f[220000];
char c[4000][4000];
int di[4][2] = { { 0,1 },{ 1,0 },{ 0,-1 },{ -1,0 } };
struct Edge { LL to, cost; };
struct edge {
	LL from, to, cost;
};
vector<vector<Edge>>vec,rvec;
vector<edge>ed;
vector<LL>v;
map<string, LL>ma;
set<LL>st;

void YN(bool f) {
	if (f)
		cout << "YES" << endl;
	else
		cout << "NO" << endl;
}
void yn(bool f) {
	if (f)
		cout << "Yes" << endl;
	else
		cout << "No" << endl;
}
int main() {
	cin >> n;
	rep(i, n) {
		rep(j, n) {
			cin >> a[i][j];
		}
	}
	rep(i, 1 << n) {
		rep(j, n)for(int k=j+1;k<n;k++)if (i&(1 << j) && i&(1 << k))sum[i] += a[j][k];
	}
	rep(mask, 1 << n) {
		dp[mask] = max((LL)0,sum[mask]);
		for (int mask2 = mask; mask2; mask2 = (mask2 - 1)&mask) {
			dp[mask] = max(dp[mask], dp[mask2] + dp[mask - mask2]);
		}
	}
	cout << dp[(1 << n) - 1] << endl;
	return 0;
}


Measured memory_bytes: 4352
#include <stdio.h>
#include <string.h>
 
int main(void){
    int a,b;
    char s[11],t[11],u[11];
    scanf("%s%s%d%d%s",s,t,&a,&b,u);
    if(strcmp(s,u)==0){
        a--;
    }else if(strcmp(t,u)==0){
        b--;
    }
    printf("%d %d",a,b);
}

Measured memory_bytes: 128
h,w,m=map(int,input().split())
a=[[] for i in range(m)]
g=[0 for i in range(h)]
r=[0 for i in range(w)]

for i in range(m):
    x,y=map(int,input().split())
    a[i].append(x)
    a[i].append(y)
    g[x-1]+=1
    r[y-1]+=1
G=[0 for i in range(h)]
R=[0 for i in range(w)]
d=max(g)
e=max(r)
for i in range(h):
    if g[i]==d:
        G[i]=1
for i in range(w):
    if r[i]==e:
        R[i]=1
f=0
for i in range(m):
    p=0
    q=0
    x=a[i][0]
    y=a[i][1]
    if G[x-1]==1:
        p=1
    if R[y-1]==1:
        q=1


    if p==q==1:
        f+=1
v=1
if f!=G.count(1)*R.count(1):
    v=0
ans=max(g)+max(r)
print(ans if v==0 else ans-1)


Measured memory_bytes: 68144
def solve():
    N = int(input())
    s = []
    t = []
    for i in range(N):
        tmps, tmpt = input().split()
        tmpt = int(tmpt)
        s.append(tmps)
        t.append(tmpt)
    
    X = input()

    sleepi = 0
    for i in range(N):
        if X == s[i]:
            sleepi = i
    
    ans = sum(t[sleepi+1:])


    print(ans)

if __name__ == '__main__':
    solve()


Measured memory_bytes: 38256
from collections import defaultdict, deque
import sys, heapq, bisect, math, itertools, string, queue, copy, time
from fractions import gcd
import numpy as np
sys.setrecursionlimit(10**8)
INF = float('inf')
MOD = 10**9+7
EPS = 10**-7
def inp(): return int(sys.stdin.readline())
def inpl(): return list(map(int, sys.stdin.readline().split()))
def inpl_str(): return list(sys.stdin.readline().split())

ans = 0
n = int(input())
def to_num(m):
    outp = 0
    for i in range(n):
        outp += (m>>i)&1
    return outp

ini = [[] for _ in range(n)]
for i in range(n):
    A = int(input())
    for _ in range(A):
        x, y = map(int, input().split())
        ini[i].append([x,y])
#all possible true or false 
for bit in range(1<<n):
    is_good = 1
    for i in range(n):
        if is_good != 1:
            break
        #ith person is honest
        if (bit>>i)&1:
            for j in range(len(ini[i])):
                if is_good != 1:
                    break
                if ini[i][j][1] == 1:
                    is_good = is_good & ((bit >> (ini[i][j][0]-1))&1)
                elif ini[i][j][1] == 0:
                    is_good = is_good & ~((bit >> (ini[i][j][0]-1))&1)

    if is_good:
        ans = max(ans, to_num(bit))
    
print(ans)
     



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

using namespace std;
typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;

struct edge {
    ll to, cost;
};

int n;
vector<vector<edge>> g;
vector<ll> d;

//ダイクストラ法
void dijkstra(int s) {
    for (int i = 0; i < n; ++i) {
        d[i] = LINF;
    }

    //最小値を取り出す優先度付きキュー
    priority_queue<pair<ll, ll>, vector<pair<ll, ll>>, greater<pair<ll, ll>>> que;

    d[s] = 0;
    que.push(make_pair(0, s)); //距離を最初にして、優先度付きキューで最小値を出せるようにする

    while (!que.empty()) {
        pair<int, int> p = que.top(); que.pop();
        int v = p.second;

        //記録してある最短距離よりも取り出した要素に入っている距離情報が大きい場合は打ち切り
        if (d[v] < p.first) continue;

        for (int i = 0; i < g[v].size(); ++i) {
            edge e = g[v][i];

            if (d[e.to] > d[v] + e.cost) {
                d[e.to] = d[v] + e.cost;
                que.push(make_pair(d[e.to], e.to));
            }
        }
    }
}

int main() {

    cin >> n;

    g.resize(n);
    d.resize(n);

    for (int i = 0; i < n - 1; ++i) {
        int a, b, c; cin >> a >> b >> c;
        --a; --b;

        g[a].push_back(edge({b, c}));
        g[b].push_back(edge({a, c}));
    }

    int q, k; cin >> q >> k;
    --k;

    vector<ll> ans(q, 0);
    dijkstra(k);

    for (int i = 0; i < q; ++i) {
        int x, y; cin >> x >> y;
        --x; --y;

        ll ans = 0;

        ans += d[x] + d[y];

        cout << ans << endl;
    }
}

Measured memory_bytes: 11888
#include <cstdio>
#include <algorithm>
#include <vector>
#include <iostream>
#include <numeric>
#include <cmath>
#include <set>
 
using namespace std;
 
int main(){
    int n;
    scanf("%d",&n);
    int r = 1;
    while(true){
        r = r * 2;
        if(r > n){
            printf("%d",r/2);
            break;
        }
    }
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define all(a) (a).begin(), (a).end()
typedef long long ll;
#define INF 1e9
typedef pair<int, int> P;

/* 　"assert"    assert(A：条件式)で　Aが真なら処理は続行、偽ならプログラムを終了する　*/

/*　　ラムダ式　　 auto a = [キャプチャ](パラメータ){ 処理 }  */

/* string型　メンバ関数　substr()    replace()  */

int main(){
    int a, b, c; cin >> a >> b >> c;
    if (a != b && b == c) {
        cout << "Yes" << endl;
        return 0;
    }
    if (a != b && a == c) {
        cout << "Yes" << endl;
        return 0;
    }
    if (a != c && a == b) {
        cout << "Yes" << endl;
        return 0;
    }
    cout << "No" << endl;
}


Measured memory_bytes: 256
import sys, math
def input():
    return sys.stdin.readline()[:-1]
from itertools import permutations, combinations
from collections import defaultdict, Counter
from math import factorial
from bisect import bisect_left # bisect_left(list, value)
#from fractions import gcd

sys.setrecursionlimit(10**7)
N = int(input())
A = list(map(int, input().split()))

flg = True
for a in A:
    if a%2==0:
        if a%3==0 or a%5==0:
            continue
        else:
            flg = False
            break

if flg:
    print('APPROVED')
else:
    print('DENIED')



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

int main() {
    int n, k, q;
    cin >> n >> k >> q;
    vector<int> a(q);
    for (int i = 0; i < q; i++) {
        cin >> a.at(i);
    }
    vector<int> cnt(n);
    for (int i = 0; i < q; i++) {
        cnt.at(a.at(i) - 1)++;
    }
    for (int i = 0; i < n; i++) {
        if (k > q - cnt.at(i)) {
            cout << "Yes" << endl;
        } else {
            cout << "No" << endl;
        }
    }
    return 0;
}

Measured memory_bytes: 4000
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <iomanip>
#include <vector>
#include <string.h>
#include <string>
#include <map>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <math.h>
#include <algorithm>
#include <numeric>


using namespace std;

// マクロ&定数 ============================================================
typedef unsigned int uint;
typedef long long ll;
//typedef pair<int, int> P;

typedef vector<int> vint;
typedef vector<ll> vll;
typedef vector<double> vdouble;
typedef vector<bool> vbool;
typedef vector<string> vstring;

typedef vector<pair<int, int>> vpint;
typedef vector<pair<ll, ll>> vpll;
typedef vector<pair<double, double>> vpdouble;

typedef vector<vector<int>> vvint;
typedef vector<vector<ll>> vvll;
typedef vector<vpint> vvpint;
typedef vector<vpll> vvpll;
typedef vector<vector<double>> vvdouble;
typedef vector<vector<string>> vvstring;
typedef vector<vector<bool>> vvbool;

typedef vector<vector<vector<ll>>> vvvll;

const int c_YET = -1;
const int INF = 1e9 + 1;
const ll LLINF = 1e17 + 1;
const int DX[9] = { 0,  0, 1, -1, 1,  1, -1, -1, 0 }; // 4;４近傍
const int DY[9] = { 1, -1, 0,  0, 1, -1,  1, -1, 0 }; // 8:８近傍 9:(0,0)を含む
const ll MOD = 1e9 + 7; //10^9 + 7
const ll MAX = 1e9;
const double PI = 3.14159265358979323846264338327950288;
//========================================================================


int main() {

	////==================================
	cin.tie(nullptr);
	ios_base::sync_with_stdio(false);
	cout << fixed << setprecision(30);
	////==================================


	ll K, A, B;
	cin >> K >> A >> B;

	ll ans = 1;
	if (B - A > 2 && A - 1 + 1 <= K)
	{
		ll begin = A - 1;
		ll nokori = K - begin;

		ans = A;
		ans += (B - A) * (nokori / 2);
		ans += nokori % 2;
	}
	else
	{
		ans += K;
	}


	cout << ans << endl;





}





Measured memory_bytes: 256