akhauriyash/Code-Regression huggingface dataset:
// g++ -std=c++11 a.cpp
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<map>
#include<set>
#include<unordered_map>
#include<utility>
#include<cmath>
#include<random>
#include<cstring>
#include<queue>
#include<stack>
#include<bitset>
#include<cstdio>
#include<sstream>
#include<iomanip>
#include<assert.h>
#include<typeinfo>
#define loop(i,a,b) for(long long i=a;i<b;i++)
#define rep(i,a) loop(i,0,a)
#define FOR(i,a) for(auto i:a)
#define pb push_back
#define all(in) in.begin(),in.end()
#define shosu(x) fixed<<setprecision(x)
#define show1d(v) {rep(_,v.size())cout<<" "<<v[_];cout<<endl;}
#define show2d(v) {rep(__,v.size())show1d(v[__]);}
using namespace std;
//kaewasuretyuui
typedef long long ll;
#define int ll
typedef int Def;
typedef pair<Def,Def> pii;
typedef vector<Def> vi;
typedef vector<vi> vvi;
typedef vector<pii> vp;
typedef vector<vp> vvp;
typedef vector<string> vs;
typedef vector<double> vd;
typedef vector<vd> vvd;
typedef pair<Def,pii> pip;
typedef vector<pip>vip;
#define mt make_tuple
typedef tuple<int,int,int,int> tp;
typedef vector<tp> vt;
template<typename A,typename B>bool cmin(A &a,const B &b){return a>b?(a=b,true):false;}
template<typename A,typename B>bool cmax(A &a,const B &b){return a<b?(a=b,true):false;}
const double PI=acos(-1);
const double EPS=1e-9;
Def inf = sizeof(Def) == sizeof(long long) ? 2e18 : 1e9+10;
int dx[]={-1,0,1,0};
int dy[]={0,1,0,-1};
#define yes cout<<"YES\n"
#define no cout<<"NO\n"

int n,m;
vs in;
void dfs(int x,int y){
	if(in[x][y]=='!'||in[x][y]=='#')return;
	in[x][y]='!';
	rep(i,4){
		int nx=x+dx[i],ny=y+dy[i];
		if(nx<0||nx>=n||ny<0||ny>=m)continue;
		dfs(nx,ny);
	}
}
signed main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	
	cin>>n>>m;
	in=vs(n);
	rep(i,n)cin>>in[i];
	string t[4]={"6314","2#2#","1364","5#5#"};
	rep(i,n)rep(j,m)if(in[i][j]-t[i%4][j%4])in[i][j]='#';
	
	dfs(0,0);
	if(in[n-1][m-1]=='!')yes;
	else no;
}








Measured memory_bytes: 3408
n = int(input())
A = list(map(int, input().split()))
q = int(input())
M = list(map(int, input().split()))
flag = [False] * 2000

for i in range(2 ** n):
    total = 0
    for j in range(n):
        if((i >> j) & 1):
            total += A[j]
    flag[total] = True
for m in M:
    print('yes' if flag[m] else 'no')


Measured memory_bytes: 5636
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <utility>
#include <tuple>
#include <algorithm>
#include <cstdio>
#include <cmath>
#define rep(i, n) for(int i = 0; i < (n); i++)
using namespace std;
using ll = long long;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }

const int INF = 1e9;

void dfs(int n, const vector<vector<int>>& graph, vector<bool>& check) {
  if(!check[n]) {
    check[n] = true;
    rep(i, graph[n].size())
      dfs(graph[n][i], graph, check);
  }
}

int main() {
  int N, M, P;
  cin >> N >> M >> P;
  vector<int> A(M), B(M), C(M);
  rep(i, M) {
    cin >> A[i] >> B[i] >> C[i];
    A[i]--;
    B[i]--;
    C[i] -= P;
  }
  vector<vector<int>> to(N), co(N), rto(N);
  rep(i, M) {
    to[A[i]].push_back(B[i]);
    co[A[i]].push_back(-C[i]);
    rto[B[i]].push_back(A[i]);
  }
  vector<bool> stog(N), gtos(N);
  dfs(0, to, stog);
  dfs(N-1, rto, gtos);
  vector<int> isTrue(N, false);
  rep(i, N) {
    if(stog[i] && gtos[i])
      isTrue[i] = true;
  }
  vector<int> node(N, INF);
  node[0] = 0;
  rep(i, N-1) {
    rep(j, N) {
      if(isTrue[j]) {
        rep(k, to[j].size()) {
          chmin(node[to[j][k]], node[j]+co[j][k]);
        }
      }
    }
  }
  vector<int> isRoop = node;
  rep(i, N) {
    if(isTrue[i]) {
      rep(j, to[i].size()) {
        chmin(isRoop[to[i][j]], isRoop[i]+co[i][j]);
      }
    }
  }
  if(node == isRoop)
    cout << max(-node[N-1], 0) << endl;
  else
    cout << -1 << endl;
  return 0;
}

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

main(){
	int n;
	int a[110];
	long long ans;
	
	ans = 0;
	cin>>n;
	cin>>a[1];
	ans += a[1];
	for(int i=2;i<n;i++){
		cin>>a[i];
		ans += min(a[i],a[i-1]);
	}
	cout<<ans+a[n-1]<<endl;
} 

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

typedef long long ll;
const ll MOD = 1e9 + 7;
const long long INF = 1LL<<60;
const double PI=3.14159265358979323846;
const int NMAX=100005;
using namespace std;


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

    string strn = to_string(n);
    int num = strn.length();
    int topn = strn[0]-'0';
    int lastn = strn[num-1]-'0';
    int middle = 0;
    for(int i = 1; i < num-1; i++){
        if(i != 1) middle *= 10;
        middle += strn[i]-'0';
    }
    ll ans = 0;

    for(ll i = 1; i <= n; i++){
        ll cnt = 0;
        ll n_digits = num;
        string str = to_string(i);
        int digits = str.length();
        bool issame = false;
        int top = str[0]-'0';
        int last = str[str.length()-1]-'0';
        if(top == last) issame = true;
        
        if(last == 0) continue;
        if(last > topn){
            n_digits -=1;
        } else if(last == topn && top > lastn && num == 2) continue;
        else if(last == topn && num > 2){
            ll tmp = middle+1;
            if(tmp > 0 && top > lastn) tmp-=1;
            cnt += tmp;
            n_digits -= 1;
        }

        switch(n_digits){
            case 6:
            cnt += 10*10*10*10;
            case 5:
            cnt += 10*10*10;
            case 4:
            cnt += 10*10;
            case 3:
            cnt += 10;
            case 2:
            cnt +=1;
            case 1:
            if(digits == 1 || issame){
                cnt += 1;
            }
            break;
        }
    //    cout << i << ":" << cnt << endl;
        ans += cnt;
    }

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

Measured memory_bytes: 3692
from collections import deque

N, K = map(int, input().split())
A = list(map(int, input().split()))
stack = deque([])
passed = set()
town = 0
while town not in passed:
    passed.add(town)
    stack.append(town)
    town = A[town] - 1

if len(stack) > K:
    print(stack[K] + 1)
    import sys
    sys.exit()

tail = 0
while stack[0] != town:
    _ = stack.popleft()
    tail += 1

K -= tail
K += 1
tmp = K % len(stack)
if tmp == 0:
    tmp = len(stack)
print(stack[tmp - 1] + 1)

Measured memory_bytes: 113588
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
#include <map>
using namespace std;
typedef long long ll;
inline int read()
{
	int x=0,f=1;char c=getchar();
	while(!isdigit(c)){if(c=='-')f=-1;c=getchar();}
	while(isdigit(c)){x=x*10+c-'0';c=getchar();}
	return x*f;
}

const int mod = 1e9 + 7;
inline int mul(int x, int y) {return (ll)x * y % mod;}
inline int inc(int x, int y) {int t = x + y; return t >= mod ? t - mod : t;}
inline int qpow(int x, int y)
{
	int res = 1;
	for (; y; y >>= 1, x = (ll)x * x % mod)
		if (y & 1) res = (ll)res * x % mod;
	return res;
}

const int maxn = 2e5 + 10;
int n, a[maxn], p[35];
bool vis[maxn];
int main()
{
	n = read();
	for (int i = 1; i <= n; i ++)
		a[i] = read();
	sort (a + 1, a + 1 + n);
	for (int i = 0; i <= 30; i ++)
		p[i] = 1;
	int ans = 0;
	for (int i = n; i >= 1; i --)
		if (!vis[i])
		{
			vis[i] = 1;
			for (int j = 0; j <= 30; j ++)
			{
				if (p[j] >= i)
					continue;
				int now = 1 << j;
				while (p[j] < i && (vis[p[j]] || a[p[j]] < now - a[i]))
					++ p[j];
				if (p[j] >= i)
					continue;
				if (a[p[j]] == now - a[i])
				{
					vis[p[j]] = 1, ++ ans;
					break;
				}
			}
		}
	printf ("%d\n", ans);
	return 0;
}

Measured memory_bytes: 1280
def main():
    from sys import setrecursionlimit, stdin, stderr
    from os import environ
    from collections import defaultdict, deque, Counter
    from math import ceil, floor
    from itertools import accumulate, combinations, combinations_with_replacement
    setrecursionlimit(10**6)
    dbg = (lambda *something: stderr.write("\033[92m{}\033[0m".format(str(something)+'\n'))) if 'TERM_PROGRAM' in environ else lambda *x: 0
    input = lambda: stdin.readline().rstrip()
    LMIIS = lambda: list(map(int,input().split()))
    II = lambda: int(input())
    P = 10**9+7
    INF = 10**18+10

    N,X,T = LMIIS()
    print(T*ceil(N/X))

    
main()

Measured memory_bytes: 65144
#include <iostream>
#include<iomanip>
#include <deque>
using namespace std;
int main(){
    int a,b,m;
    int mem;
    int rmin=10000000,dmin=10000000;
    int reizouko[100000];
    int renji[100000];
    cin >> a >> b >> m;
    for(int i=0;i<a;i++){
        cin >> mem;
        reizouko[i]=mem;
        if(rmin>mem){
            rmin=mem;
        }
    }
    for(int i=0;i<b;i++){
        cin >> mem;
        renji[i]=mem;
        if(dmin>mem){
            dmin=mem;
        }
    }
    int minimum = dmin+rmin;
    int x,y,c,memmini;
    for(int i=0;i<m;i++){
        cin >> x >> y >> c;
        memmini = reizouko[x-1] + renji[y-1] - c;
        if(memmini<minimum){
            minimum=memmini;
        }
    }
    cout << minimum << endl;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp> 
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace __gnu_pbds;
using namespace std;
#define getbit(n, i) (((n) & (1LL << (i))) != 0) 
#define setbit0(n, i) ((n) & (~(1LL << (i)))) 
#define setbit1(n, i) ((n) | (1LL << (i))) 
#define togglebit(n, i) ((n) ^ (1LL << (i))) 
#define lastone(n) ((n) & (-(n))) 
char gap = 32;
template<typename T> 
ostream& operator<<(ostream &os, const vector<T> &v) { 
    os << '{'; 
    for (const auto &x : v) os << gap << x;
        return os << '}'; 
}
template<typename A, typename B> 
ostream& operator<<(ostream &os, const pair<A, B> &p) {
        return os << '(' << p.first << gap << p.second << ')';
}

template <class T>
void read(T &x) {
    char c;
    for (c = getchar(); c < '0' || c > '9'; c = getchar())
        ;
    for (x = 0; c <= '9' && c >= '0'; c = getchar()) x = x * 10 + (c & 15);
}
#define ll long long 
#define lll __int128_t
#define pb push_back
#define mp make_pair
typedef pair < int,int> ii;
typedef vector<ii> vii;
typedef vector<ll>vl;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef tree<
int,
null_type,
less<int>,
rb_tree_tag,
tree_order_statistics_node_update>
ordered_set;
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
ll hashPrime = 1610612741;
ll status[1000001];
void siv(){
    ll N = 1000000;
    status[1] = 1;
    for (ll i = 2;i*i<=N;i++){
        if(status[i]==0){
            for (ll j = i * i; j <= N;j+=i)
                status[j] = 1;
        }
    }
}
int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    ll i, j, k, l, n, m;
    cin >> n;
    siv();
    ll res = 0;
    for (i = 2; i*i <= n;i++){
        if(status[i]==0){
            ll cnt = 0;
            while(n%i==0){
                cnt++;
                n /= i;
            }
            ll maxres = 0;
            for (j = 0; j <= cnt;j++){
                if((j*j+j)/2<=cnt){
                    maxres = j;
                }
                else{
                    break;
                }
            }
            res += maxres;
        }
    }
    if(n>1)
        res += 1;
    cout << res << "\n";
    return 0;
}

Measured memory_bytes: 11476
// Min, Max and Sum

#include <iostream>
#include <cassert>
#include <cstdint>

int main()
{
  int n;
  std::cin >> n;
  assert(n >= 0 && n <= 10000);

  int min, max;
  int64_t sum = 0;
  for (int i = 0; i < n; ++i) {
    int input;
    std::cin >> input;

    if (i == 0) {
      min = max = input;
    }
    else {
      if (input < min) min = input;
      if (input > max) max = input;
    }

    sum += input;
  }

  std::cout << min << " " << max << " " << sum << std::endl;

  return 0;
}

Measured memory_bytes: 1164
#include <bits/stdc++.h>
#define rep(i, a, b) for(int i = a; i < (b); ++i)
#define trav(a, x) for(auto& a : x)
#define all(x) x.begin(), x.end()
#define endl "\n"
#define speed() ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);
#define sz(x) (int)(x).size()
#define _USE_MATH_DEFINES
using namespace std;
typedef long long int lli;
typedef long long ll;
typedef pair<int, int> pii;
typedef vector<int> vi;

int main() {
    speed();
    int N; cin >> N;
    int P[N];
    rep(i, 0, N) cin >> P[i];
    int m = P[0];
    int k = 1;
    rep(i, 1, N) {
        if (P[i] <= m) {
            ++k;
            m = P[i];
        }
    }
    cout << k << endl;
    return 0;
}

Measured memory_bytes: 1152
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
using namespace std;
int main()
{
    vector<string> word;
    string temp;
    int n;

    cin >> n;
    for (int i = 0; i < n; i++)
    {
        cin >> temp;
        word.push_back(temp);
    }
    for (int i = 1; i < n; i++)
    {
        if ((word[i-1][word[i-1].size()-1]) != (word[i][0]))
        {
            cout << "No" << endl;
            return 0;
        }
        else;
    }
    sort(word.begin(), word.end());
    for (int i = 1; i < n; i++)
    {
        if (word[i-1] == word[i])
        {
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string.h>
#include <stdio.h>
using namespace std;
int n, cnt = 0, a[62][3], tot = 0;
int main()
{
    scanf("%d", &n); n--;
    int ed = 1, x = 1;
    for(int i=1;i<20 && n;i++,x<<=1) {
        if(x > n) break;
        a[++cnt][0] = i; a[cnt][1] = i+1; a[cnt][2] = x;
        a[++cnt][0] = i; a[cnt][1] = i+1; a[cnt][2] = 0;
        n -= x; tot += x; ed = i+1;
    }
    if(n) {
        for(int i=ed+1; i>=1; i--) {
            while(1<<(i-1) <= n) {
                n -= (1<<(i-1));
                a[++cnt][0] = i; a[cnt][1] = ed; a[cnt][2] = tot + 1;
                tot = tot + (1<<(i-1));
            }
        }
    }
    printf("%d %d\n", ed, cnt);
    for(int i=1;i<=cnt;i++) printf("%d %d %d\n", a[i][0], a[i][1], a[i][2]);
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main()
{
  int n;
  cin >> n;
  vector<int> v(n);
  for (int i = 0 ; i < n;++i)
    cin >> v[i];
  vector<int> dp(n,0);
  dp[1] = abs(v[1]-v[0]);
  for (int i = 2; i < n; ++i)
  {
    dp[i] = min(dp[i-1]+abs(v[i]-v[i-1]), dp[i-2]+abs(v[i]-v[i-2]));
  }
  cout << dp[n-1] << endl;
  return 0;
}

Measured memory_bytes: 1024
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
using namespace std;
template<typename T> bool chmax(T &a,T b){if(a<b){a=b;return true;}return false;}
template<typename T> bool chmin(T &a,T b){if(a>b){a=b;return true;}return false;}
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define all(vec) vec.begin(),vec.end()
typedef long long ll;
typedef long double ld;
typedef pair<ll,ll> pll;
typedef pair<int,int> pii;
typedef tuple<ll,ll,ll> tlll;
typedef tuple<int,int,int> tiii;
const ll mod=1e9+7;
const int inf=1<<30;

int main(){
  int n; cin >> n;
  vector<string> s(n);
  rep(i,n) cin >> s[i];
  vector<int> a(n);
  vector<int> b(n);
  rep(i,n){
    int mx=0;
    rep(j,s[i].size()){
      if(s[i][j]==')') mx++;
      else mx--;
      chmax(a[i],mx);
    }
    mx=0;
    for(int j=s[i].size()-1;j>=0;j--){
      if(s[i][j]=='(') mx++;
      else mx--;
      chmax(b[i],mx);
    }
  }
  vector<pair<int,string> > v1(0);
  vector<pair<int,string> > v2(0);
  rep(i,n){
    if(b[i]-a[i]>=0) v1.emplace_back(a[i],s[i]);
    else v2.emplace_back(b[i],s[i]);
  }
  sort(all(v1));
  sort(all(v2));
  reverse(all(v2));
  string t;
  for(auto c:v1){
    t+=c.second;
  }
  for(auto c:v2){
    t+=c.second;
  }
  int check=0;
  rep(i,t.size()){
    if(t[i]=='(') check++;
    else check--;
    if(check<0){
      cout << "No" << endl;
      return 0;
    }
  }
  if(check!=0){
    cout << "No" << endl;
    return 0;
  }
  cout << "Yes" << endl;
}

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

#define ll long long
#define vecll vector<long long>
#define vecs vector<string>
#define vec2ll vector<vector<long long>>
#define vecbool vector<bool>
#define vecpairll vector<pair<long long,long long>>
#define forll(s,a,b) for(long long s = a;s < b;s++)
#define forllde(s,a) for(long long s = a;s > 0;s--)

int main()
{
  ll x, maxv=0;
  cin >> x;
  forllde(i, sqrt(x)){
	for(ll p=9; p>1; p--){
	  if (pow(i, p) <= x)
		maxv = max(maxv, (ll)pow(i, p));
	}
  }
  cout << maxv << endl;
}

Measured memory_bytes: 640
#include<set>
#include<map>
#include<deque>
#include<queue>
#include<stack>
#include<cmath>
#include<ctime>
#include<bitset>
#include<string>
#include<vector>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<climits>
#include<complex>
#include<iostream>
#include<algorithm>
#define ll long long
using namespace std;

const int maxn = 210000;
const ll Mod = 1e9+7;

ll inv[maxn],s[maxn];
void pre()
{
	s[0]=1ll; for(int i=1;i<maxn;i++) s[i]=s[i-1]*(ll)i%Mod;
	inv[0]=inv[1]=1;
	for(ll i=2;i<maxn;i++)
		inv[i]=(-(Mod/i)*inv[Mod%i]%Mod+Mod)%Mod;
	for(int i=1;i<maxn;i++) inv[i]=inv[i]*inv[i-1]%Mod;
}

int n,X,Y;
vector<int>V[maxn];

int main()
{
	pre();
	scanf("%d%d%d",&n,&X,&Y);
	for(int i=1;i<=n;i++)
	{
		int w,c; scanf("%d%d",&c,&w);
		V[c].push_back(w);
	}
	for(int i=1;i<=n;i++) sort(V[i].begin(),V[i].end());
	int m1=0,m2=0;
	for(int i=1;i<=n;i++) if(V[i].size())
	{
		for(int j=1;j<V[i].size();j++) if(V[i][j]+V[i][0]<=X) V[i][j]=V[i][0];
		if(!m1||V[m1][0]>V[i][0]) m2=m1,m1=i;
		else if(!m2||V[m2][0]>V[i][0]) m2=i;
	}
	if(!m2) return puts("1"),0;
	
	int ren=1; ll ans=1ll;
	for(int j=1;j<V[m1].size();j++)
		if(V[m1][j]+V[m1][0]<=X||V[m1][j]+V[m2][0]<=Y) ren++;
	ans=ans*inv[ren]%Mod;
	for(int i=1;i<=n;i++) if(i!=m1)
	{
		int now=0;
		for(int j=0;j<V[i].size();j++) if(V[m1][0]+V[i][j]<=Y) now++;
		ans=ans*inv[now]%Mod;
		ren+=now;
	}
	ans=ans*s[ren]%Mod;
	printf("%lld\n",ans);
	
	return 0;
}


Measured memory_bytes: 12800
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
using namespace std;
using ll = long long;
using P = pair<int,int>;
template <class T> void chmin(T &a, const T &b) noexcept { if (b < a) a = b; }
template <class T> void chmax(T &a, const T &b) noexcept { if (a < b) a = b; }
void debug_out() { cout << "\n"; }
template <class T, class... Args>
void debug_out(const T &x, const Args &... args) { cout << x << " "; debug_out(args...);}
#ifdef _DEBUG
  #define debug(...) debug_out(__VA_ARGS__)
#else
  #define debug(...) 
#endif

int main() {
  std::cin.tie(nullptr);
  std::ios_base::sync_with_stdio(false);
  std::cout << std::fixed << std::setprecision(15);
  int x, n;
  cin >> x >> n;
  vector<int> cnt(102,0);
  rep(i,n) {
    int p;
    cin >> p;
    cnt[p]++;
  }
  if (cnt[x] == 0) {
    cout << x << endl;
    return 0;
  }
  int itr1 = x-1, itr2 = x+1;
  while (true) {
    if (itr1 >= 0 && cnt[itr1] == 0) {
      cout << itr1 << endl;
      return 0;
    }
    if (itr2 <= 101 && cnt[itr2] == 0) {
      cout << itr2 << endl;
      return 0;
    }
    itr1--; itr2++;
  }
  return 0;
}

Measured memory_bytes: 3656
#include <bits/stdc++.h>
#define rep(i,n) for(int (i)=0;(i)<(n);++(i))
#define all(x) (x).begin(),(x).end()
#define dump(x) cout << #x << " = " << (x) << endl
#define YES(n) cout << ((n) ? "YES" : "NO") << endl
#define Yes(n) cout << ((n) ? "Yes" : "No") << endl
#define yes(n) cout << ((n) ? "yes" : "no") << endl

using namespace std;
using ll = long long;
using P = pair<int, int>;

const int INF = 1001001001;
const vector<int> di = {-1,  0, 1, 0};
const vector<int> dj = { 0, -1, 0, 1};

void chmin(int &a, int b) { if (a > b) a = b; }

ll GCD(ll a, ll b) {
    if (b == 0) return a;
    else return GCD(b, a % b);
}
ll LCM(ll a, ll b) {
    ll g = GCD(a, b);
    return a / g * b;
}


int main(){
    int p;
    cin >> p;
    int a, b, c, d;
    d = (p%10); p /= 10;
    c = (p%10); p /= 10;
    b = (p%10); p /= 10;
    a = (p%10); p /= 10;

    int res = a;
    string ans = "";
    bool ok = false;
    rep(i, 2) {
        rep(j, 2) { 
            rep(k, 2) {
                res = a;
                ans = "";
                if (i == 0) {
                    res += b;
                    ans += "+";
                } else {
                    res -= b;
                    ans += "-";
                }
                if (j == 0) {
                    res += c;
                    ans += "+";
                } else {
                    res -= c;
                    ans += "-";
                }
                if (k == 0) {
                    res += d;
                    ans += "+";
                } else {
                    res -= d;
                    ans += "-";
                }
                if (res == 7) {
                    ok = true;
                    break;
                }
            }
            if (ok) break;
        }
        if (ok) break;
    }

    cout << a;
    cout << ans[0];
    cout << b;
    cout << ans[1];
    cout << c;
    cout << ans[2];
    cout << d;
    cout << "=7" << endl;
}

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

// macros
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define MIN(a,b) (a>b?b:a)
#define MAX(a,b) (a>b?a:b)
#define INT_IN(a) int a; cin >> a
#define STR_IN(s) string s; cin >> s
#define PRINTLN(s) cout << s << endl
#define PRINTDOUBLELN(s) cout << fixed << setprecision(12) << (s) << endl;

// util functions
template<class T> inline T sqr(T x) {return x*x;}

inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

template <typename T>inline T max(vector<T> v){T max=v[0]; FOR(i, 1, v.size())max=MAX(v[i], max); return max;}
template <typename T>inline T min(vector<T> v){T min=v[0]; FOR(i, 1, v.size())min=MIN(v[i], min); return min;}
template <typename T>inline vector<T> concat(vector<T> a, vector<T> b){vector<T> ab; ab.reserve(a.size()+b.size());ab.insert(ab.end(),a.begin(),a.end());ab.insert(ab.end(),b.begin(),b.end());return ab;}

// types
typedef long long LL;

// consts
const double EPS = 1e-10;
const double PI  = acos(-1.0);

//debug
#define dump(x)  #x << " = " << (x) << endl
#define debug(x) #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl

int main(){
    INT_IN(a);
    INT_IN(b);
    PRINTLN(a / b << " " << a % b << " " << fixed << setprecision(12) << 1. * a / b);
    return 0;
}

Measured memory_bytes: 3228
import java.io.*;
import java.util.*;
class Main {
	public static void main(String[] args) throws IOException{
		BufferedReader in = new BufferedReader(new InputStreamReader(System.in));
		//BufferedReader in = new BufferedReader(new FileReader("prob.in"));
		
		PrintWriter out = new PrintWriter(new BufferedWriter(new OutputStreamWriter(System.out)));
		//PrintWriter out = new PrintWriter(new BufferedWriter(new FileWriter("prob.out")));
		
		
		StringTokenizer st = new StringTokenizer(in.readLine());
		
		int N = Integer.parseInt(st.nextToken());
		int A = Integer.parseInt(st.nextToken());
		int B = Integer.parseInt(st.nextToken());
		
		
		int totalSum = 0;
		
		for(int i = 1; i <= N; i++){
			int curr = i;
			String str= "" + curr;
			
			int tempSum = 0;
			
			while(str.length() < 4){
				str = "0" + str;
			}
			
			
			for(int j =0; j < 4; j++){
				tempSum += Integer.parseInt("" + str.charAt(j));
			}
			
			if(tempSum >= A && tempSum <= B){
				//out.println(str);
				totalSum += curr;
			}
			
			
		}
		
		out.println(totalSum);
		
		
		
		
		in.close();
		out.close();
		
	}
}


Measured memory_bytes: 29392
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc = new Scanner(System.in);

        int n = sc.nextInt();
        int m = sc.nextInt();

        long x = n * (n - 1) / 2;
        long y = m * (m - 1) / 2;

        System.out.println(x + y);

    }

}


Measured memory_bytes: 21972
#include <iostream>
#include <string>
#include <vector>
using namespace std;

int main()
{
	int n;
	cin >> n;
	vector<vector<int>> g(n, vector<int>(n, 0));
	for (int i = 0; i < n; ++i) {
		string s;
		cin >> s;
		for (int j = 0; j < n; ++j) {
			if (s[j] == '1') {
				g[i][j] = 1;
			}
		}
	}

	int ret = 0;
	bool isOk = true;
	for (int i = 0; i < n; ++i) {
		vector<int> cg(n, 0);
		int retCand = 1;
		cg[i] = 1;
		int count = 1;
		vector<int> next(n, 0);
		next[i] = 1;
		while (count != n) {
			vector<int> newNext(n, 0);
			for (int j = 0; j < n; ++j)
			{
				if (next[j] == 1) 
				{
					for (int k = 0; k < n; ++k) 
					{
						if (g[j][k] == 1) {
							if (next[k] == 1) {
								isOk = false;
							}
							if (cg[k] == 0) {
								newNext[k] = 1;
								cg[k] = 1;
								++count;
							}
						}
					}
				}
			}
			++retCand;
			if (!isOk) {
				cout << -1 << endl;
				return 0;
			}
			next.swap(newNext);
		}


		for (int j = 0; j < n; ++j)
		{
			if (next[j] == 1)
			{
				for (int k = 0; k < n; ++k)
				{
					if (g[j][k] == 1) {
						if (next[k] == 1) {
							isOk = false;
						}
					}
				}
			}
		}

		if (!isOk) {
			cout << -1 << endl;
			return 0;
		}

		if (ret < retCand) {
			ret = retCand;
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 512
fun main(args: Array<String>) {
    dwacon6thPrelimsA()
}

fun dwacon6thPrelimsA() {
    val n = readLine()!!.toInt()
    val stList = (1..n).map { readLine()!!.split(' ').let { Pair(it[0], it[1].toInt()) } }
    val x = readLine()!!

    val indexOfFirst = stList.indexOfFirst { it.first == x }

    val answer = stList.slice(indexOfFirst + 1..stList.lastIndex).map { it.second }.sum()

    println(answer)
}


Measured memory_bytes: 36332
#include <bits/stdc++.h>
#define ll long long
#define pii pair<int,int>
#define pll pair<ll,ll>
#define pli pair<ll,int>
#define pil pair<int,ll>
#define fi first
#define se second
#define inf (INT_MAX/2-1)
#define infl (1LL<<60)
#define vi vector<int>
#define vl vector<ll>
#define pb push_back
#define sz(a) (int)(a).size()
#define all(a) begin(a),end(a)
#define y0 y5656
#define y1 y7878
#define aaa system("pause");
#define dbg(x) cerr<<(#x)<<": "<<(x)<<'\n',aaa
#define dbga(x,n) cerr<<(#x)<<"[]: ";for(int _=0;_<n;_++)cerr<<x[_]<<' ';cerr<<'\n',aaa
#define dbgs(x) cerr<<(#x)<<"[stl]: ";for(auto _:x)cerr<<_<<' ';cerr<<'\n',aaa
#define dbgp(x) cerr<<(#x)<<": "<<x.fi<<' '<<x.se<<'\n',aaa
#define maxn 1000000
#define maxp 78498

using namespace std;

bool cc[maxn+5], viz[maxp+5];
int v[maxn+5];
vi prime;

void ciur () {
  int i, j;
  cc[0] = cc[1] = 1;
  for (i = 2; i*i <= maxn; i++)
    if (!cc[i])
      for (j = i*i; j <= maxn; j += i) cc[j] = 1;
  for (i = 2; i <= maxn; i++)
    if (!cc[i]) prime.pb(i);
}

int gcd (int a, int b) {
  if (b > 0) return gcd(b, a%b);
  return a;
}

int main () {
  ios::sync_with_stdio(false); cin.tie(0); cout.tie(0);
  ciur();
  int n; cin >> n;
  int i, j, z;
  for (i = 1; i <= n; i++) cin >> v[i];
  bool cop = 1, dv;
  for (i = 1; i <= n && cop; i++) {
    z = v[i];
    j = 0;
    while (z > 1 && j < sz(prime) && 1LL*prime[j]*prime[j] <= 1LL*v[i] && cop) {
      dv = 0;
      while (z > 1 && z%prime[j] == 0) {
        dv = 1;
        z /= prime[j];
      }
      if (dv) {
        cop &= (!viz[j]);
        viz[j] = 1;
      }
      j++;
    }
    if (z > 1) {
      j = lower_bound(all(prime), z) - prime.begin();
      cop &= (!viz[j]);
      viz[j] = 1;
    }
  }
  if (cop) cout << "pairwise coprime";
  else {
    int ans = 0;
    for (i = 1; i <= n; i++) ans = gcd(v[i], ans);
    if (ans == 1) cout << "setwise coprime";
    else cout << "not coprime";
  }
  return 0;
}


Measured memory_bytes: 8596
#include <stdio.h>
 
int main()
{
    for (;;) {
        int h, w, x, y;
        scanf("%d %d", &h, &w);
        if (h == 0 & w == 0) {
            return 0;
        }
        for (y = 0; y < h; y++) {
            for (x = 0; x < w; x++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
}

Measured memory_bytes: 572
import sys
sys.setrecursionlimit(10 ** 7)

class UnionFind():
	def __init__(self, size):
		self.table = [-1 for _ in range(size)]
		self.size = [1 for _ in range(size)]

	def find(self, x):
		if self.table[x] < 0:
			return x
		else:
			self.table[x] = self.find(self.table[x])
			return self.table[x]

	def union(self, x, y):
		s1 = self.find(x)
		s2 = self.find(y)
		if s1 != s2:
			if self.table[s1] > self.table[s2]:
				self.table[s2] = s1
				self.table[s1] -= 1
				self.size[s1] += self.size[s2]
				self.size[s2] = 0
			else:
				self.table[s1] = s2
				self.table[s2] -= 1
				self.size[s2] += self.size[s1]
				self.size[s1] = 0

		return

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

uf = UnionFind(n)
ans = [n*(n-1)//2]
for i in range(m-1, 0, -1):
	a, b = brs[i][0], brs[i][1]
	a, b = a-1, b-1
	s1, s2 = uf.find(a), uf.find(b)
	if s1 != s2:
		ans.append(ans[-1] - uf.size[s1]*uf.size[s2])
	else:
		ans.append(ans[-1])
	uf.union(s1, s2)
print(*list(reversed(ans)), sep="\n")

Measured memory_bytes: 62628
fn run() {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).unwrap();
    let mut it = s.trim().split_whitespace();
    let a: usize = it.next().unwrap().parse().unwrap();
    let b: usize = it.next().unwrap().parse().unwrap();
    if a == b {
        println!("Yes");
    } else {
        println!("No");
    }
}

fn main() {
    run();
}

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

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

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

const int MAX = 1e5 + 5;
const int INF = 1001001001;
const int MOD = 1e9 + 7;

int main(){
    int T1, T2;
    cin >> T1 >> T2;

    ll A1, A2, B1, B2;
    cin >> A1 >> A2 >> B1 >> B2;

    ll A = (A1 - B1) * T1, B = (A2 - B2) * T2;

    if (A < 0) {
        A = -A;
        B = -B;
    }

    if (A + B > 0) {
        puts("0");
        return 0;
    } else if (A + B == 0) {
        cout << "infinity" << endl;
        return 0;
    }

    ll ans = (-A / (A+B)) * 2 + 1;
    if (-A % (A+B) == 0) {
        ans -=1;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
N = int(input())
P = [int(input()) for i in range(N)]

D = {p:i for i,p in enumerate(P)}
pv = N
l = seq = 0
for n in range(1,N+1):
    nx = D[n]
    if pv < nx:
        seq += 1
    else:
        l = max(l,seq)
        seq = 1
    pv = nx
l = max(l, seq)

print(N - l)

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

using namespace std;

#define int long long
#define endl '\n'
#define MOD 1000000007
#define maxn 100010

int lcm(int a, int b) {
    return (a * b) / __gcd(a, b);
}

void solve() {
    int n, m;
    cin >> n >> m;

    vector<int> v(n);

    int ans = 1;
    for (int i = 0; i < n; i++) {
        cin >> v[i];
        ans = lcm(ans, v[i] / 2);
        v[i] /= 2;
    }

    bool flag = true;
    for (int i = 0; i < n; i++) {
        if ((ans / v[i]) % 2 == 0)
            flag = false;
    }
    if (!flag)
        cout << 0 << endl;
    else
        cout << (m / ans + 1) / 2 << endl;
}

int32_t main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);

    int t = 1;
//    cin >> t;

    while (t--)
        solve();
    return 0;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
int h,w,k,sum[15][1005],ans;
int choose[15];
vector < pair<int,int> > vec;
inline void Solve(){
	register int i,j;
	vec.clear();
	int l=0,cnt = 0,maxx=-1;
	for(i=1;i<h;++i)
		if(choose[i])
			vec.push_back(make_pair(l,i)),l=i,maxx = max(maxx,i-l);
	vec.push_back(make_pair(l,h));
	int len = vec.end()-vec.begin();
	if(len-1 >= ans)return ;
	l=0;
	for(i=1;i<=w;++i){
		int flag = 0;
		for(j=0;j<len;++j)
			if(sum[vec[j].second][i]-sum[vec[j].second][l]-sum[vec[j].first][i]+sum[vec[j].first][l] > k){
				flag = 1;
				break;
			}
		if(flag&&l==i-1)return ;
		if(flag)l=--i,++cnt;
	}
	ans = min(ans,len+cnt-1);
}
void dfs(int dep){
	if(dep == h)return Solve();
	choose[dep] = 0,dfs(dep+1);
	choose[dep] = 1,dfs(dep+1);
}
int main(){
	scanf("%d %d %d",&h,&w,&k);
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
			scanf("%1d",&sum[i][j]);
	for(int i=1;i<=h;++i)
		for(int j=1;j<=w;++j)
			sum[i][j] = sum[i-1][j] + sum[i][j-1] - sum[i-1][j-1] + sum[i][j];
//	for(int i=1;i<=h;++i){
//		for(int j=1;j<=w;++j)printf("%d ",sum[i][j]);
//		puts("");
//	}
	ans = 0x3f3f3f3f;
	dfs(1);
	printf("%d",ans);
	return 0;
}
//O(2^hw)

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

int main() {
  map<char, string> in;
  string a, b, c;
  cin >> a >> b >> c;
  in['a'] = a;
  in['b'] = b;
  in['c'] = c;

  char turn = 'a';
  while (1) {
    if (in[turn].size() == 0) {
      if (turn == 'a') {
        cout << 'A' << endl;
      } else if (turn == 'b') {
        cout << 'B' << endl;
      } else {
        cout << 'C' << endl;
      }
      return 0;
    }

    char tmp = in[turn][0];
    in[turn].erase(0, 1);
    turn = tmp;
  }

  return 0;
}

Measured memory_bytes: 256
/*

Author : @karngyan
Team : BlundersPride
Date : 15-03-2019
Time : 15:44:18

*/


#include<bits/stdc++.h>
//#include <ext/pb_ds/assoc_container.hpp>
//using namespace __gnu_pbds;
//typedef tree<int,null_type,less<int>,rb_tree_tag,
//tree_order_statistics_node_update> indexed_set;
using namespace std;

typedef long long ll;
typedef long double ld;
typedef std::vector<ll> vll;
typedef std::pair<ll,ll> pll;
typedef std::vector<vll> vvll;

#define fast ios_base::sync_with_stdio(false),cin.tie(NULL),cout.tie(NULL)
#define endl '\n'
#define pb push_back
#define rep(i,a,b) for(ll i=a;i<b;++i)
#define rrep(i,a,b) for(ll i=a;i>b;--i)
#define max3( a, b, c ) max( a , max(b , c))
#define cres(c,n) (c).clear(),(c).resize(n)
#define all(a) (a).begin(), (a).end()
#define rall(a) (a).rbegin(), (a).rend()
#define ff first
#define ss second
#define mk make_pair
const ll mod = 1e9 + 7;

signed main()
{
	fast;
////////////////////////////////////////////////////////////////////////////////////////////
	
	ll n;
	cin >> n;
	string s;
	cin >> s;
	unordered_map<ll,ll> m;
	for(auto it: s)
		m[it]++;
	ll ans = 1;
	for(auto it: m)
	{
		ans = (ans%mod * (it.ss + 1))%mod;
	}

	ans = (ans%mod - 1%mod + mod)%mod;
	cout<<ans<<endl;





////////////////////////////////////////////////////////////////////////////////////////////
	
	return 0;
}



Measured memory_bytes: 512
#include<stdio.h>
int main(){
  char s[8][8];
  int i,j,k;
  for(i=0;i<8;i++){
    fgets(s[i],10,stdin);
  }
  printf("90\n");
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      printf("%c",s[7-j][i]);
    }
    printf("\n");
  }
  printf("180\n");
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      printf("%c",s[7-i][7-j]);
    }
    printf("\n");
  }
  printf("270\n");
  for(i=0;i<8;i++){
    for(j=0;j<8;j++){
      printf("%c",s[j][7-i]);
    }
    printf("\n");
  }
  return 0;
}

Measured memory_bytes: 524
#include <iostream>
#include <cstdio>
#include <cstring>
#include <algorithm>
using namespace std;
string s;
int l=1,r=0;
int main(){
	cin>>s;
	int ans=0;
	s=" "+s;
	r=s.size()-1;
	while(l<=r){
		if (s[l]!=s[r]) ans++;
		l++,r--;
	}
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
typedef unsigned long long ull;
 
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define RFOR(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define REP(i,n) for(int i=0;i<(n);i++)
#define RREP(i,n) for(int i=(n)-1;i>=0;i--)
#define VSORT(v) sort(v.begin(), v.end())
#define DVSORT(v) sort(v.begin(), v.end(),greater<int>())
#define SORT(v, n) sort(v, v+n)
#define DSORT(v,n) sort(v, v+n,greater<int>())
#define vi vector<int>
#define pb push_back
#define P pair<int,int>
#define Pll pair<ll,ll>

template <class T> void chmin(T&a,const T&b) { a = min(a,b); }
template <class T> void chmax(T&a,const T&b) { a = max(a,b); }
 
void print(){cout<<endl;}
template <class Head, class... Tail>
void print(Head&& h,Tail&&... t){ 
	if(sizeof...(t)==0)
		cout<<h;
	else
		cout<<h<<' ';
	print(move(t)...);
}
 
const double EPS =1e-9;
const long INF =2147483647;//32bit 2*1e+9
const long MOD =1e+9+7;
#define PI 3.14159265258979

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

int main(void){
	int X,A,B;
	cin>>X>>A>>B;
	print((X-A)%B);
	return 0;
}


Measured memory_bytes: 256
N, C, K = map(int, input().split())
flag = True
pass_num = 0
count = 1
for t in sorted([int(input()) for _ in range(N)]):
    if flag:
        first_pass_time = t
        flag = False
    if t - first_pass_time > K or pass_num == C:
        first_pass_time = t
        pass_num = 0
        count += 1
    pass_num += 1
print(count)

Measured memory_bytes: 8288
package main

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

// const abcd = "abcdefghijklnmopqrstuvwxyz"
// const ABCD = "ABCDEFGHIJKLMNOPQRSTUVWXYZ"

// var dy = [...]int{1, 1, 0, -1, -1, -1, 0, 1}
// var dx = [...]int{0, 1, 1, 1, 0, -1, -1, -1}

// var dx = [...]int{0, 1, 0, -1}
// var dy = [...]int{1, 0, -1, 0}

var inf int = 1e14

// var mod = 1000000007

// ---------------------------------------------------------
func main() {
	log.SetFlags(log.Lshortfile)
	next := newScanner()
	n := next.Int()
	x := next.Int()
	a := make([]int, n)
	for i := 0; i < n; i++ {
		a[i] = next.Int()
	}
	v := make([]int, n)
	copy(v, a)
	ans := inf
	for k := 0; k < n; k++ {
		kans := 0
		for i := 0; i < n; i++ {
			if i-k < 0 {
				v[i] = min(v[i], a[n+i-k])
			} else {
				v[i] = min(v[i], a[i-k])
			}
			kans += v[i]
		}
		ans = min(ans, kans+k*x)
	}

	fmt.Println(ans)
}

// ---------------------------------------------------------

// Pair is liked C++ pair
type Pair struct {
	a, b int
}

// Pairs is sorted by []Pair struct
type Pairs []Pair

func (p Pairs) Len() int {
	return len(p)
}
func (p Pairs) Swap(i, j int) {
	p[i], p[j] = p[j], p[i]
}

func (p Pairs) Less(i, j int) bool {
	if p[i].a < p[j].a {
		return true
	} else if p[i].a == p[j].a {
		return p[i].b < p[j].b
	}
	return false
}

// -------------------------------
func in(c, a, z int) bool {
	return c >= a && c < z
}

func btoi(b bool) int {
	if b {
		return 1
	}
	return 0
}

func itob(a int) bool {
	if a == 0 {
		return false
	}
	return true
}

func max(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r < a[i] {
			r = a[i]
		}
	}
	return r
}

func min(a ...int) int {
	r := a[0]
	for i := 0; i < len(a); i++ {
		if r > a[i] {
			r = a[i]
		}
	}
	return r
}

func minmax(a, b int) (int, int) {
	if a > b {
		return b, a
	}
	return a, b
}

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}

func sum(a ...int) int {
	r := a[0]
	if len(a) > 1 {
		for i := 1; i < len(a); i++ {
			r += a[i]
		}
	}
	return r
}

// ---------- buffered scanner -----------------------------------------
type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) Line() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) Int() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) Int64() int64 {
	v, _ := strconv.ParseInt(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 768
#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 MOD          1000000007
#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)
#define VV(T,h,w)    move(vector<vector<T>>(h,move(vector<T>(w))))
#define VVI(T,h,w,i) move(vector<vector<T>>(h,move(vector<T>(w,i))))
using namespace std;
using ll = long long;
template<typename T = ll>inline T in() { T ret; cin >> ret; return ret; }

int main()
{
	ll x = in(), y = in();
	cout << (x + y < 10 ? to_string(x + y) : "error") << endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define GLX glx ak!!
#define ZZH zzh ak!!
#define LYH lyh ak!!
#define XRY xry ak!!
#define ZJH zjh ak!!
#define HP hp ak!!
#define WXH wxh ak!!
#define JIRY jiry good teacher
#define DYH dyh good teacher
#define ll long long
using namespace std;
int n,ans,x,f[110];
bool vis[110];
inline void dfs(int x){
    if(x>12){
        int ret=24;
        for(int i=0;i<=23;i++)
            for(int j=i+1;j<=23;j++)
                if(vis[i]&&vis[j]) ret=min(ret,min(j-i,24-j+i));
        ans=max(ans,ret);
        return ;
    }
    if(f[x]==2){
		vis[x]=vis[24-x]=1;
		dfs(x+1);
		return;
	}
	if(f[x]){
        vis[x]=1;
		dfs(x+1);
		vis[x]=0;
        if(x){
        	vis[24-x]=1;
			dfs(x+1);
			vis[24-x]=0;
    	}
		return ;
	}
    dfs(x+1);
	return;
}
int main(){
    scanf("%d",&n);
    f[0]=1;
	for(int i=1;i<=n;i++){
		scanf("%d",&x);
		f[x]++;
	}
	if(f[12]>1||f[0]>1){puts("0");return 0;}
    for(int i=1;i<=12;i++) if(f[i]>2){puts("0");return 0;}
    dfs(0);
    printf("%d",ans);
    return 0;
}


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

const long double EPS = 1e-10;
const long long INF = 1e18;
const long double PI = acos(-1.0L);

int main() {
  int n,m;
  cin >> n>>m;
  int a[m];
  REP(i, m) {
    cin>>a[i];
  }
  // sort(a,a+m);
  int sum = 0;

  REP(i, m){
    sum +=a[i];
    }

    if( n-sum >=0){
      cout<<n-sum<<"\n";
    }
    else{
      cout<<"-1\n";
    }


  
  return 0;
}


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

using namespace std;

vector <int> adjList[300000];
int explored [300000];

void explore(int x){
    explored[x] = 1;
    for(int i = 0; i < adjList[x].size(); i++){
        if(!explored[adjList[x][i]]){
            explore(adjList[x][i]);
        }
    }
}

int main(){
    int n, m, k, l;
    cin >> n >> m;
    for(int i = 0; i < n; i++){
        cin >> k;
        for(int j = 0; j < k; j++){
            cin >> l;
            adjList[i].push_back(100000 + l);
            adjList[100000 + l].push_back(i);
        }
    }
    explore(0);
    for(int i = 0; i < n; i++){
        if(!explored[i]){
            cout << "NO";
            return 0;
        }
    }
    cout << "YES";

    return 0;
}


Measured memory_bytes: 11264
#include "bits/stdc++.h"
using namespace std;
const int MAX = 700000;
const int MOD = 1000000007;

long long  fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
	fac[0] = fac[1] = 1;
	finv[0] = finv[1] = 1;
	inv[1] = 1;
	for (int i = 2; i < MAX; i++) {
		fac[i] = fac[i - 1] * i % MOD;
		inv[i] = MOD - inv[MOD % i] * (MOD / i) % MOD;
		finv[i] = finv[i - 1] * inv[i] % MOD;
	}
}

// 二項係数計算
long long COM(int n, int k) {
	if (n < k) return 0;
	if (n < 0 || k < 0) return 0;
	return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}
/*第二引数で第一引数を割ったときの切り上げの計算*/
long long int maxtime(long long int x, long long int y){
	return(x + y - 1) / y;

}
/*最大公約数*/
long long int lcm(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;

	if (number2 > number1) {
		m = number2;
		n = number1;
	}
	long long int s = -1;
	while (s != 0) {
		s = m % n;
		m = n;
		n = s;
	}
	return m;
}
/*最大公倍数*/
long long int gcd(long long int number1, long long int number2) {
	long long int m = number1;
	long long int n = number2;
	return m / lcm(m, n) * n;
}

// index が条件を満たすかどうか
int main() {
	long long int n, k, s;
	cin >> n >> k >> s;
	if (s == 1000000000) {
		for (int i = 0; i < k; i++) {
			cout << 1000000000 << " ";
		}
		for (int i = k; i < n; i++) {
			cout << 1 << " ";
		}
	}
	else {
		for (int i = 0; i < k; i++) {
			cout << s << " ";
		}
		for (int i = k; i < n; i++) {
			cout << 1000000000 << " ";
		}
	}
}

Measured memory_bytes: 1280
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
#define M 100000
bool mark;

int main()
{
    ll x,y,z,n,m,a,i,j,k,l;
    vector<int>v;
    cin>>n;
    while(n>0)
    {
        v.push_back(n%10);
        n=n/10;
    }
    if(v[0]==v[1] && v[1]==v[2])
    {
        cout<<"Yes"<<endl;
    }
    else if(v[1]==v[2] && v[2]==v[3])
    {
        cout<<"Yes"<<endl;
    }
    else if(v[0]==v[1] && v[1]==v[2] && v[2]==v[3])
    {
        cout<<"Yes"<<endl;
    }
    else
    {
        cout<<"No"<<endl;
    }



    return 0;
}



Measured memory_bytes: 256
#include <stdio.h>
#include <string.h>
char n[2000000];
int main(void){
	int i,j=0,t;
	scanf("%s",n);
	t=strlen(n);
	for(i=0;i<t;i++)
	j+=n[i]-'0';
	if(j%9==0)
	printf("Yes\n");
	else
	printf("No\n");
	return 0;
}

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

using namespace std;

#define ll long long int
#define ld long double
#define MAX 1000000000
#define MOD 1000000007

int main(){

    ll n,m;
    cin >> n >> m;

    vector<ll> a;

    ll i,a1;

    ll sum = 0;

    for(i=0;i<n;i++){
        cin >> a1;
        a.push_back(a1);
        sum = sum + a[i];
    }

    ll cnt = 0;

    for(i=0;i<n;i++){
        float tmp1 = float(sum)/float(4*m);
        float tmp2 = float(a[i]);
        if(tmp2>=tmp1){
            cnt++;
        }
    }

    if(cnt>=m){
        cout << "Yes\n";
    }
    else{
        cout << "No\n";
    }

}




















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

using namespace std;

int main(void) {
    int a, b;

    cin >> a >> b;

    if ((a * b) % 2 == 0) {
        cout << "Even" << endl;
    }
    else {
        cout << "Odd" << endl;
    }

    return 0;
}

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

#define x first
#define y second
#define pb push_back
#define mp make_pair
#define all(a) (a).begin(), (a).end()

using namespace std;
using namespace __gnu_pbds;

typedef tree< int, null_type, less< int >, rb_tree_tag, tree_order_statistics_node_update> ost;
// name.find_by_order(x) or name.order_of_key(x)
typedef long long ll;
typedef pair<int, int> ii;
typedef vector<int> vi;
typedef vector<pair<int, int>> vii;
typedef vector<vector<int>> vvi;

void yes() {printf("YES\n");}
void no() {printf("NO\n");}

int dx4[] = {-1, 1, 0, 0};
int dy4[] = {0, 0, -1, 1};
int dx8[] = {-1, -1, -1, 0, 0, 1, 1, 1};
int dy8[] = {-1, 0, 1, -1, 1, -1, 0, 1};

const int maxn = 2e5 + 5, maxv = 2e6 + 5;
const int MOD = 1e9 + 7;

int mult(ll a, ll b) {return (a * b) % MOD;}
int pot(int n, int k) {
	int ret = 1, pot = n;
	for(;k > 0;k >>= 1, pot = mult(pot, pot)) 
		ret = mult(ret, (k & 1) ? pot : 1);
	return ret;
}
int divide(int a, int b) {return mult(a, pot(b, MOD - 2));}
int add(int a, int b) {a += b;if(a >= MOD) a -= MOD;return a;}
int sub(int a, int b) {a -= b;if(a < 0) a += MOD;return a;}

vector<int> fact;
void calc_fact(int n) {
	fact = vector<int>(n + 1, 1);
	for(int i = 1;i <= n;i++) fact[i] = mult(fact[i - 1], i);
}
int choose(int n, int k) {return divide(fact[n], mult(fact[n - k], fact[k]));}

bool prime(ll a) {
	if (a == 1) return 0;
	for(ll i = 2;i * i <= a;i++) 
		if (a % i == 0) return 0;
	return 1;
}

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

ll phi(ll x) {
	double ret = x;
	for(ll i = 2;i * i <= x;i++) {
		if (x % i) continue;
		ret *= (1.0 - 1.0 / (double)i);
		while (x % i == 0) x /= i;
	}
	if (x > 1) ret *= (1.0 - 1.0 / (double)x );
	return (ll)ret;
}

void solve() {
	int n;
	scanf("%d", &n);
	calc_fact(maxn);
	int ans = 0;
	for(int i = 1;i <= n;i++) {
		int x = n - i * 3;
		if(x < 0) continue;
		ans = add(ans, choose(x + i - 1, i - 1));
	}
	printf("%d\n", ans);
}

int main() {
	int t = 1;
	//scanf("%d", &t);
	while(t--) solve();
	return 0;
}


Measured memory_bytes: 4044