akhauriyash/Code-Regression huggingface dataset:
#coding:utf-8
#1_7_B
class Node():
    def __init__(self, node_id):
        self.node_id    =   node_id
        self.parent     =   -1
        self.sibling    =   -1
        self.degree     =   0
        self.depth      =   0
        self.height     =   0
        self.typ        =   'root'
        self.children   =   []

    def set_parent(self, child):
        child.parent = self.node_id
        self.degree += 1
        self.children.append(child)

        if child.degree:
            child.typ = 'internal node'
        else:
            child.typ = 'leaf'

        if self.parent != -1:
            self.typ = 'internal node'

    def set_sibling(self, sibling):
        self.sibling = sibling

def set_depth(tree):
    for node in tree:
        if node.typ == 'root':
            root = node
            break
    queue = []
    queue.extend(root.children)
    while queue:
        node = queue.pop(0)
        node.depth = tree[node.parent].depth + 1
        queue.extend(node.children)

def set_height(tree):
    queue = []
    for node in tree:
        if node.typ == 'leaf':
            queue.append(node)

    while queue:
        leaf = queue.pop(0)
        if leaf.parent != -1 and tree[leaf.parent].height < leaf.height + 1:
            tree[leaf.parent].height = leaf.height + 1
            queue.append(tree[leaf.parent])

n = int(input())
tree = [Node(i) for i in range(n)]

for i in range(n):
    node_id, left, right = map(int, input().split())
    if left != -1:
        tree[node_id].set_parent(tree[left])
        tree[left].set_sibling(right)
    if right != -1:
        tree[node_id].set_parent(tree[right])
        tree[right].set_sibling(left)

set_depth(tree)
set_height(tree)

for node in tree:
    print("node {}: parent = {}, sibling = {}, degree = {}, depth = {}, height = {}, {}".format(node.node_id, node.parent, node.sibling, node.degree, node.depth, node.height, node.typ))

Measured memory_bytes: 7852
s=input()
ok = True

if s.count('N')*s.count('S')==0 and s.count('N')+s.count('S')!=0:
    ok=False
if s.count('W')*s.count('E')==0 and s.count('W')+s.count('E')!=0:
    ok=False
    
if ok:
    print('Yes')
else:
    print('No')

Measured memory_bytes: 9060
#include <iostream>
#include <algorithm>
#include <string>
#include <unordered_map>
#include <deque>
#include <array>
#include <cmath>

using namespace std;

int main()
{
  int a, b, c;

  cin >> a >> b >> c;

  int tmp = b;

  b = a;
  a = tmp;

  tmp = c;
  c = a;
  a = tmp;

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

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
//define
#define int long long
#define UNIQUE(v) v.erase(unique(all(v)), v.end());
#define ZIP(v) sort(all(v)),UNIQUE(v)
#define ADD(a, b) a = (a + b) % mod
#define SUB(a, b) a = (a+mod-b)%mod
#define MUL(a, b) a = (a * b) % mod
#define repi(i,m,n) for(int i = m;i < n;i++)
#define drep(i,n,m) for(int i = n;i >= m;i--)
#define rep(i,n) repi(i,0,n)
#define rrep(i,n) repi(i,1,n+1)
#define chmin(x,y) x = min(x,y)
#define chmax(x,y) x = max(x,y)
#define all(v) v.begin(),v.end()
#define rall(v) v.rbegin(), v.rend()
#define dmp(x,y) make_pair(x,y)
#define pb(x) push_back(x)
#define fi first
#define se second
// 許容する誤差ε
#define EPS (1e-10)
// 2つのスカラーが等しいかどうか
#define EQ(a,b) (abs((a)-(b)) < EPS)
// 2つのベクトルが等しいかどうか
#define EQV(a,b) ( EQ((a).real(), (b).real()) && EQ((a).imag(), (b).imag()) )
//template
template <typename T, typename U>
ostream &operator<<(ostream &os, const pair<T, U> &p){
  os << "(" << p.first << "," << p.second << ")";return os;
}
template <typename T>
ostream &operator<<(ostream &os, const vector<T> &v){
  for (auto it = v.begin();it != v.end();++it){
    if(it != v.begin())os << " ";os << *it;
      }return os;
}
template <typename T, typename U>
ostream &operator<<(ostream &os, const map<T, U> &mp){
  for(auto x: mp)os << "(" << x.first << "," << x.second << ")" << endl;
  return os;
}
template<typename T, int SIZE>
int array_length(const T (&)[SIZE]){return SIZE;}
template<typename T, int N>
void print(const T (&a)[N], int s = N, int t = -1, bool f = true){
	if(t == -1){rep(i,s){if(i)cout << " ";cout << a[i];}}
	else repi(i,s,t){if(i!=s)cout << " ";cout << a[i];}
	if(f)cout << "\n";
}
template<typename T, int N1, int N2>
void print(const T (&a)[N1][N2], int h = N1, int w = N2){
	rep(i,h){rep(j,w){cout << a[i][j] << " \n"[j==w-1];}}
}
//typedef
typedef complex<double> Point;
typedef pair<int,int> P;
typedef pair<int, P> PP;
typedef pair<P, int> Pi;
typedef vector<int> vi;
typedef deque<int> dq;
const int inf = 1e9+7;
const int INF = 1e18+7;



//公約数
int gcd(int a, int b){
  if(a == 0 || b == 0)return max(a, b);
  if(a == b)return a;
  if(a > b)a = a%b;
	else b = b%a;
  return gcd(a, b);
}

signed main(){
  int n, x;cin >> n >> x;
  int ans = -1;
  rep(i,n){
    int y;cin >> y;
    if(ans == -1)ans = llabs(x-y);
    ans = gcd(ans, llabs(y-x));
    // cout << ans << endl;
  }
  cout << ans << endl;
	return 0;
}










Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
    ll n; cin>>n;
    map<string,int> mp;
    rep(i,0,n){
        string s;
        cin>>s;
        mp[s]++;
    }
    ll ans=0;
    for(auto i:mp){
        ans++;
    }
    cout<<ans<<endl;
}

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


int main(){
  int n;
  cin >> n;
  int ans=0;
  int a;
  for(int i=0; i<n; ++i){
    cin >> a;
    if((i+1) % 2 == 1 && a % 2 == 1) ans += 1;
  }
  cout << ans << endl;
}


Measured memory_bytes: 3512
N, M = map(int, input().split())

def main():
    cnts = [0]*M
    ans = 0

    for i in range(N):
        A = list(map(int, input().split()))[1:]
        for a in A:
            cnts[a-1] += 1

    for cnt in cnts:
        if cnt == N:
            ans += 1
    return ans


if __name__ == '__main__':
    print(main())


Measured memory_bytes: 3060
n = int(input())
nums = [int(i) for i in input().split()]
box = [0] * n
for i in range(1, n + 1)[::-1]:
    c = i * 2
    ball = nums[i - 1]
    while c <= n:
        ball = ball ^ box[c - 1]
        c += i
    box[i - 1] = ball

ans = box.count(1)
print(ans)
ball = []
for i in range(n):
    if box[i] == 1:
        ball.append(i + 1)
print(*ball)


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

#define rep(i, N) for (ll i = 0; i < N; i++)
#define rep1(i, N) for (ll i = 1; i <= N; 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 INF (int)1e9+7

using ll = long long;
using namespace std;

typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<P> vpi;
typedef pair<ll,ll> Pl;
typedef vector<ll> vl;
typedef vector<Pl> vpl;

ll gcd(ll a, ll b){
    if(a < b) swap(a, b);
    if(b <= 0) return -1;
    ll r = a % b;
    while(r != 0){
        a = b;
        b = r;
        r = a % b;
    }
    return b;
}

ll lcm(ll a, ll b){
    return (a/gcd(a,b)*b);
}

int main() {
    ll N, B, ans = 0;
    cin >> N;
    for (ll A = (ll)pow(N, 0.5); A > 0; A--) {
        if(N%A == 0) {
            B = N/A;
            break;
        }
    }

    while(B != 0) {
        B /= 10;
        ans++;
    }
    
    //string ans = ( flag ? "Yes" : "No" );
    //printf("%.8lf\n", ans);
    cout << ans << "\n";
    return 0;
}


Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
 
int main() {
int n;
  cin>>n;
  double sum=0;
for (int i = 0; i < n; i++) {
  double x;
  string u;
  cin>>x>>u;
 if(u=="JPY"){
   sum+=x;
 }  
  else{
    sum +=380000*x;
  }
   
}
cout<<sum<<endl;
 
}

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

#define INF 1e9
using namespace std;
typedef long long ll;

int main() {

    int n; cin >> n;

    ll m = 0;
    ll a = 0;
    ll r = 0;
    ll c = 0;
    ll h = 0;

    for (int i = 0; i < n; ++i) {
        string s; cin >> s;

        if (s[0] == 'M') {
            ++m;
        }

        if (s[0] == 'A') {
            ++a;
        }

        if (s[0] == 'R') {
            ++r;
        }

        if (s[0] == 'C') {
            ++c;
        }

        if (s[0] == 'H') {
            ++h;
        }
    }

    ll ans = 0;

    ans = m * a * r
            + m * a * c
            + m * a * h
            + m * r * c
            + m * r * h
            + m * c * h
            + a * r * c
            + a * r * h
            + a * c * h
            + r * c * h;

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/irange.hpp>
using namespace std;
using namespace boost;
main() {
  // total_layer[n] = pow(2, n+2) - 3
  // paty[n] = pow(2, n+1) - 1
  int64_t n, x;
  cin >> n >> x;
  
  int64_t ans = 0;
  for (; n>=0; --n) {
    auto t = pow(2L, n+2-1) - 3;
    if (x > 1 + t) {
      ans += pow(2L, n+1-1);
      x -= 1 + t;
    }
    if (x == 2 + t) --x;
    --x;
  }
  cout << ans << endl;
}
  

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

using namespace std;
typedef long long ll;
#define rep(i, s, e) for (int(i) = (s); (i) <= (e); ++(i))
#define all(x) x.begin(),x.end()


int main()
{
	int n, m, Q; cin >> n >> m >> Q;
	vector<vector<int>> a(n, vector<int>(n, 0));
	rep(i, 1, m)
	{
		int l, r; cin >> l >> r;
		--l, --r;
		++a[l][r];
	}
	vector<vector<int>> s(n + 1, vector<int>(n + 1));
	s[0][0] = 0;
	rep(i, 0, n - 1)rep(j, 0, n - 1)
	{
		s[i + 1][j + 1] = s[i + 1][j] + s[i][j + 1] - s[i][j] + a[i][j];
	}
	rep(i, 1, Q)
	{
		int p, q; cin >> p >> q;
		int ans = s[q][q] - s[p - 1][q] - s[q][p - 1] + s[p - 1][p - 1];
		cout << ans << endl;
	}
}


Measured memory_bytes: 2944
#include <bits/stdc++.h>
using namespace std;
#define min(a,b) ((a)<(b)?(a):(b))
#define max(a,b) ((a)>(b)?(a):(b))
#define REP(i,n) for(ll i=0;i<n;i++)
#define FOR(i,n1,n2) for(int i=n1;i<n2;i++)
#define bFOR(i,n1,n2) for(int i=n1;i>=n2;i--)
#define speed_up    ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);

typedef long long int ll;
typedef pair<ll,ll> Pi;
const int INF=(ll)(1LL<<30)-1;
const double INFd=100000000000.0;
const ll INFl=(ll)9223372036854775807;
const int MAX=10000;
const ll MOD=(ll)1e9+7;
ll gcd(ll a,ll b){return b?gcd(b,a%b):a;}
ll lcm(ll a,ll b){return a/gcd(a, b)*b;}
int dx[4]={0,-1,0,1},dy[4]={-1,0,1,0};
int mdx[4]={0,1,0,-1},mdy[4]={-1,0,1,0};


template<typename A, size_t N, typename T>
void Fill(A (&array)[N], const T &val){
    std::fill( (T*)array, (T*)(array+N), val );
}

int n;
ll a[200100];
ll ans=0;
int cou[22]={};
bool check(){
	int flag=1;
	for(int i=0;i<22;i++){
		if(cou[i]!=0&&cou[i]!=1){
			flag=0;
		}
	}
	return flag;
}
int main(){
	cin>>n;
	REP(i,n)cin>>a[i];
	int l=0;
	ll t=0;
	for(int i=1;i<=n;i++){
		for(int j=0;j<22;j++){
			if((a[i-1]>>j)&1)cou[j]++;
		}
		while(!check()){
			for(int j=0;j<22;j++){
				if((a[l]>>j)&1)cou[j]--;
			}
			l++;
		}
		ans+=(i-l);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 1792
/****************************************************
*   Template for coding contests                    *
*   Author    :    Sanjeev Sharma                   *
*   Email     :    thedevelopersanjeev@gmail.com    *
*****************************************************/
#pragma GCC optimize ("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize ("unroll-loops")
#pragma GCC optimize("no-stack-protector")
#pragma GCC optimize("fast-math")
#pragma GCC target ("sse4")
#pragma comment(linker, "/stack:200000000")

#include <bits/stdc++.h>
#include <ext/pb_ds/tree_policy.hpp>
#include <ext/pb_ds/assoc_container.hpp>

using namespace __gnu_pbds;
using namespace std;

#define deb(x) cout << #x << " is " << x << "\n";
#define int long long
#define mod 1000000007

const double PI = 2 * acos(0.0);
const long long INF = 1e18L + 5;
template <typename T>
using ordered_set = tree<T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;

void solve() {
	int x, y;
	cin >> x >> y;
	bool flag = false;
	for(int a = 0; a <= x; a++) {
		int b = x - a;
		if(((2 * a) + (4 * b)) == y) {
			flag = true;
			break;
		}
	}
	cout << (flag ? "Yes" : "No");
}

int32_t main() {
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	solve();
	return 0;
}


Measured memory_bytes: 3660
#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 a,b,c;cin>>a>>b>>c;
	int ans =b;
	ans+=min(c,a+b+1);
	cout<<ans<<endl;
}

Measured memory_bytes: 256
#include <cstdio>
#include <cstdlib>
#include <cmath>
#include <climits>
#include <cfloat>
#include <map>
#include <utility>
#include <set>
#include <iostream>
#include <memory>
#include <string>
#include <vector>
#include <algorithm>
#include <functional>
#include <sstream>
#include <complex>
#include <stack>
#include <queue>
#include <numeric>
#include <iomanip>

#define REP(i,n) for(i=0; i < (n); i++)
#define REPONE(i, n) for(i=1; i <= (n); i++)
#define LOOP(n) for(int loopCount=1; loopCount <= (n); loopCount++)
#define ITER(c) __typeof((c).begin())
#define EACH(c,it) for(ITER(c) it =(c).begin(); it!=(c).end(); it++)
#define SZ(c) ((int) (c).size())
#define ALL(c) c.begin(), c.end()
#define SUM(c) accumulate(ALL(c), 0)
#define EXIST(c,v) (find(ALL(c), (v)) != (c).end())
#define PB push_back
#define MP make_pair

using namespace std;
static const double EPS = 1e-9;
static const double PI = 3.141592653589793238462643383279;
typedef long long ll;

vector<pair<int,int> > rot(vector<pair<int,int> > ps){
    int i, s=SZ(ps);
    REP(i,s){
        swap(ps[i].first, ps[i].second);
        ps[i].first *= -1;
    }
    REP(i,s){
        ps[s-1-i].first  -= ps[0].first;
        ps[s-1-i].second -= ps[0].second;
    }
    return ps;
}

int main(){
    int n, m, i, j, k, x, y;

    while(scanf("%d",&n)){
        if(!n) break;
        scanf("%d",&m);
        vector< pair<int,int> > origin;
        vector<int> ans;
        vector< vector< vector<pair<int, int> > > > polys(n);
        REP(i,m){
            scanf("%d%d",&x,&y);
            origin.PB(MP(x,y));
        }
        REP(i,m){
            origin[m-1-i].first  -= origin[0].first;
            origin[m-1-i].second -= origin[0].second;
        }

        REP(i,n){
            scanf("%d",&m);
            polys[i].PB(vector< pair<int, int> >());
            REP(j,m){
                scanf("%d%d",&x,&y);
                polys[i][0].PB(MP(x,y));
            }
            REP(j,3) polys[i].PB(rot(polys[i].back()));
            polys[i].PB(polys[i][0]);
            reverse(polys[i].back().begin(), polys[i].back().end());
            REP(j,m){
                polys[i].back()[m-1-j].first -= polys[i].back()[0].first;
                polys[i].back()[m-1-j].second-= polys[i].back()[0].second;
            }
            REP(j,3) polys[i].PB(rot(polys[i].back()));
        }

        REP(i,n){
            REP(k,4){
                origin = rot(origin);
                REP(j,8)if(polys[i][j] == origin) goto end;
            }
end:;
            if(j<8) ans.PB(i);
        }
        REP(i,SZ(ans)){
            printf("%d\n",ans[i]+1);
        }
        printf("+++++\n");
    }

    return 0;
}

Measured memory_bytes: 0
from numpy import cumsum

n = int(input())
a = list(map(int, input().split()))

ans = 1000000000000000000
ruiseki = cumsum(a)
sum = ruiseki[len(ruiseki)-1]
for i in range(len(ruiseki)-1):
    x = ruiseki[i]
    y = sum - ruiseki[i]
    ans = min(ans, abs(x-y))

print(ans)


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

int64_t N, M;

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

    int64_t ans = 0;
    if( N <= M / 2 ){
        ans += N;
        M -= N * 2;
        ans += M / 4;
    } else {
        ans += M / 2;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < n; ++i)
#define REPP(i, n) for(int i = 1; i <= n; ++i)
#define REPR(i, n) for(int i = n-1; i >= 0; --i)
#define FOR(i, m, n) for(int i = m; i < n; ++i)
#define ALL(v) v.begin(), v.end()
#define UNIQUE(v) v.erase(unique(v.begin(), v.end()), v.end());
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
const ll MOD = 1000000007;
const ll INF = 1000000000;

int main() {
    ll n; cin >> n;
    vector<ll> a(n);
    REP(i,n) cin >> a[i];
    sort(ALL(a));
    ll ans = 0;
    ll right = n-1, left = 0;
    ll x,y;
    vector<P> xy;
    while (right>=0 && a[right-1]>0) {
        x = a[0];
        y = a[right];
        ans = (x-y);
        xy.push_back({x,y});
        a[0] -= a[right];
        right --;
    }
    while (left<right && a[left]<=a[right]) {
        x = a[right];
        y = a[left];
        ans = (x-y);
        xy.push_back({x,y});
        a[right] -= a[left];
        left ++;
    }
    cout << ans << endl;
    ll l = xy.size();
    REP(i,l) {
        cout << xy[i].first << ' ' << xy[i].second << endl;
    }
    return 0;
}

Measured memory_bytes: 4336
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef double D;
typedef pair<ll,ll> P;
#define M 1000000007
#define F first
#define S second
#define PB push_back
#define INF 100000000000000000
ll n,a[3005],dp[3005][3005][2];
int main(void){
    scanf("%lld",&n);
    for(int i=1;i<=n;i++)scanf("%lld",a+i);
    for(int k=0;k<n;k++){
        for(int i=1;i+k<=n;i++){
            int l=i,r=i+k;
            dp[l][r][0]=max(dp[l+1][r][1]+a[l],dp[l][r-1][1]+a[r]);
            dp[l][r][1]=min(dp[l+1][r][0]-a[l],dp[l][r-1][0]-a[r]);
        }
    }
    printf("%lld\n",dp[1][n][0]);
}


Measured memory_bytes: 139648
import java.util.*;

public class Main {
    public static void main(String[] args) {
        Scanner scan = new Scanner(System.in);
        int rows = scan.nextInt();
        int cols = scan.nextInt();
        int[][] board = new int[rows][cols]; 
        scan.nextLine(); // read the new line char.

        for(int i = 0 ; i < rows ; i++){
            String s = scan.nextLine();
            for(int j = 0 ; j < cols ; j++) {
                board[i][j] = (s.charAt(j) == '#') ? -1 : 0;
            }
        }

        board[0][0] = 1;
        for(int i = 0 ; i < rows ; i++){
            for(int j = 0 ; j < cols ; j++) {
                if(board[i][j] == -1 || j == cols || i == rows) {
                    continue;
                }
                board[i][j] = board[i][j] % 1000000007;
                if(i < rows - 1 && board[i+1][j] != -1) {
                    board[i+1][j] += board[i][j];
                }
                if(j < cols -1 && board[i][j+1] != -1) {
                    board[i][j+1] += board[i][j];
                }
            }
        }
        

        //Now board is ready. lets do the 2 way dfs.
        //System.out.println(dfs(board, 0, 0));//board[rows-1][cols-1]);
        System.out.println(board[rows-1][cols-1]);
    }

    private static int dfs(int[][] board, int row, int col) {
        if(row >= board.length || row < 0 || col >= board[row].length || col < 0 || board[row][col] == -1) {
            return 0;
        }
        if(board[row][col] > 0) {
            return board[row][col];
        }
        if(row == board.length-1 && col == board[row].length-1) {
            return 1;
        }
        board[row][col] = (dfs(board, row+1, col) + dfs(board, row, col+1))%1000000007;
        return board[row][col];
    }
}


Measured memory_bytes: 39160
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <math.h>
#include <iomanip>
#include <cmath>
#include <queue>
#include <stack>
#include <cstdlib>
#include <map>
using namespace std;
#define int long long
#define rep(i,n) for(int i=0;i<n;i++)
#define pie 3.141592653589793238462643383279
#define mod 1000000007
#define inf 10000000000000007
#define all(vec) vec.begin(),vec.end()
#define ggr getchar(); getchar();return 0;
int gcd(int x, int y) {
	if (y == 0)return x;
	return gcd(y, x % y);
}
int lcm(int x, int y) {
	return x / gcd(x, y) * y;
}
bool prime(int x) {
	for (int i = 2; i <= sqrt(x); i++) {
		if (x % i == 0)return false;
	}
	return true;
}

int n, a[100010];
int ta;
int ans = 1;

signed main() {
	cin >> n;
	rep(i, n) {
		cin >> a[i];
		ta += a[i];
	}
	sort(a, a + n);
	ta -= a[n - 1];
	for (int i = n - 2; i >= 0; i--) {
		if (ta * 2 >= a[i + 1]) {
			ans++;
			ta -= a[i];
		}
		else break;
	}
	cout << ans << endl;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
 int a,b;
 cin>>a>>b;
 long long ans=4*a-b;
 if((ans>=0)&&(ans%2==0)&&((ans/2)<=a))
 cout<<"Yes";
 else
 cout<<"No";
   return 0;
}
 

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

int main()
{
  int K, S;
  cin >> K >> S;

  int ans = 0;
  for (int x = 0; x <= K; ++x)
  {
    for (int y = 0; y <= K; ++y)
    {
      if (x + y > S) break;
      if (S - (x + y) > K) continue;
      ++ans;
    }
  }

  cout << ans << endl;

  return 0;
}


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

typedef long long ll;

const int size = 100005;

std::vector<int> g[size];

bool visited[size][3];

int dfs(int s, int e)
{
	// Vertex, mod
	std::queue<std::pair<int, int>> q;
	q.push({ s, 0 });
	while (!q.empty())
	{
		int vert = q.front().first;
		int ken = q.front().second;
		q.pop();
		if (vert == e && ken % 3 == 0)
		{
			return ken / 3;
		}
		if (visited[vert][ken % 3])
		{
			continue;
		}
		visited[vert][ken % 3] = true;
		for (int nV : g[vert])
		{
			q.push({ nV, ken + 1 });
		}
	}
	return -1;
}

int main()
{
	int n, m;
	scanf("%d%d", &n, &m);
	for (int i = 0; i < m; ++i)
	{
		int u, v;
		scanf("%d%d", &u, &v);
		g[u].push_back(v);
	}
	int s, e;
	scanf("%d%d", &s, &e);
	printf("%d\n", dfs(s, e));
	return 0;
}

Measured memory_bytes: 9508
#include <stdio.h>

int main() {

  int count[5][4][11]={};
  int i, j, k, n, b, f, r, v;

  scanf("%d", &n);
  
  for (i = 0; i < n; i++){
    scanf("%d %d %d %d", &b, &f, &r, &v);
    count[b][f][r] += v;
  }
  for (i = 1; i <= 4; i++){
    for (j = 1; j <= 3; j++){
      for (k = 1; k <= 10; k++){
	printf(" %d", count[i][j][k]);
      }
      printf("\n");
    }
    if (i < 4)
      printf("####################\n");
  }

  return 0;

}

Measured memory_bytes: 612
#include<algorithm>/*{{{*/
#include<cctype>
#include<cassert>
#include<cmath>
#include<cstdio>
#include<cstring>
#include<cstdlib>
#include<ctime>
#include<iostream>
#include<map>
#include<queue>
#include<set>
#include<vector>
using namespace std;
typedef long long lld;
typedef long double lf;
typedef unsigned long long uld;
typedef pair<int,int> pii;
#define fi first
#define se second
#define pb push_back
#define mk make_pair
#define FOR(i,a,b) for(int i=(a);i<=(b);++i)
#define ROF(i,a,b) for(int i=(a);i>=(b);--i)
namespace RA{
    int r(int p){return 1ll*rand()*rand()%p;}
    int r(int L,int R){return r(R-L+1)+L;}
}
namespace IO{
    char nc(){ static char bf[100000],*p1=bf,*p2=bf; return p1==p2&&(p2=(p1=bf)+ fread(bf,1,100000,stdin),p1==p2)?EOF:*p1++; }
    int rd(){ int res=0; char c=getchar(); while(!isdigit(c))c=getchar(); while(isdigit(c))res=res*10+c-'0',c=getchar(); return res; }
}/*}}}*/
/******************heading******************/
const int N=2e5+50;

int n,h,w;

struct edge{
    int u,v,w;
    bool operator<(edge e){ return w<e.w; }
}e[N];

int f[N],g[N];
void init(int k){FOR(i,0,k)f[i]=i,g[i]=0;}
int get(int u){return f[u]==u?u:f[u]=get(f[u]);}
void merge(int u,int v){f[get(u)]=get(v);}
bool find(int u,int v){return get(u)==get(v);}
bool has_circle(int u){return g[get(u)];}
void set_circle(int u){g[get(u)]=1;}

lld ans;

int main(){
    scanf("%d%d%d",&n,&h,&w);
    init(h+w);
    FOR(i,1,n){
        int x,y,z;
        scanf("%d%d%d",&x,&y,&z);
        e[i]=(edge){x,y+h,z};
    }
    sort(e+1,e+n+1);
    ROF(i,n,1){
        int u=e[i].u,v=e[i].v,w=e[i].w;
        if(find(u,v)){
            if(!has_circle(u)) ans+=w, set_circle(u);
        }else{
            if(has_circle(u)&&has_circle(v));
            else if(has_circle(u)) ans+=w, merge(v,u);
            else ans+=w, merge(u,v);
        }
    }
    printf("%lld",ans);
    return 0;
}


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

using ul=unsigned long long;
int s[500],t[500],tmp[500][500],S[500],T[500],n,bit=-1,IN;
ul ans[500][500],u[500],v[500];

void ng(){
  cout<<-1;
  exit(0);
}

struct P{int va,idx,ve,ne,al;};
bool operator <(const P &a,const P &b){return a.va<b.va;};
priority_queue<P> que;

#define REP(i) for(int i=0;i<n;i++)
#define U ((u[i]>>bit)&1)
#define V ((v[j]>>bit)&1)
#define F(va) {\
  if(!~tmp[i][j]){\
    ans[i][j]+=((ul)1<<bit)*(tmp[i][j]=va);\
    S[i]++,T[j]++;\
    if(IN){\
      if(S[i]<n)que.push({S[i],i,'S',s[i]});\
      if(T[j]<n)que.push({T[j],j,'T',t[j]});\
    }\
  }\
}
void AL(){
  int KO=1;
  while(KO--){
    REP(i)
      if(s[i]==U){
        bool f=0;
        REP(j)f|=tmp[i][j]==s[i];
        if(f)REP(j){KO|=tmp[i][j]<0;F(s[i]^1);}
      }
    REP(j)
      if(t[j]==V){
        bool f=0;
        REP(i)f|=tmp[i][j]==t[j];
        if(f)REP(i){KO|=tmp[i][j]<0;F(t[j]^1);}
      }
  }
}
bool same(int a,int b,int c,int d){return a==b&&b==c&&c==d;}

int main(){
  cin>>n;
  REP(i)cin>>s[i];
  REP(i)cin>>t[i];
  REP(i)cin>>u[i];
  REP(i)cin>>v[i];
  while(++bit<64){
    memset(tmp,-1,sizeof(tmp));
    memset(S,0,sizeof(S));
    memset(T,0,sizeof(T));
    IN=0;
    REP(i)if(s[i]^U)REP(j)F(s[i]^1);
    REP(j)if(t[j]^V)REP(i)F(t[j]^1);
    REP(i)REP(j)if(same(s[i],(u[i]>>bit)&1,t[j],(v[j]>>bit)&1))F(s[i]);
    AL();
    IN=1;
    REP(i)if(S[i]<n)que.push({S[i],i,'S',s[i],1});
    REP(j)if(T[j]<n)que.push({T[j],j,'T',t[j],1});
    while(que.size()){
      P p=que.top();que.pop();
      if(p.ve=='S'){
        int i=p.idx;
        if(p.va<S[i])continue;
        REP(j)
          if(!~tmp[i][j]){
            F(p.ne);
            p.ne^=p.al;p.al=0;
          }
        AL();
      }
      else{
        int j=p.idx;
        if(p.va<T[j])continue;
        REP(i)
          if(!~tmp[i][j]){
            F(p.ne);
            p.ne^=p.al;p.al=0;
          }
        AL();
      }
    }
  }

  REP(i){
    ul A=ans[i][0];
    REP(j)
      if(s[i])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=u[i])ng();
  }
  REP(j){
    ul A=ans[0][j];
    REP(i)
      if(t[j])A|=ans[i][j];
      else A&=ans[i][j];
    if(A!=v[j])ng();
  }

  REP(i){
    REP(j)cout<<ans[i][j]<<" ";cout<<endl;
  }
}


Measured memory_bytes: 18332
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int (i)=0;(i)<(n);(i)++)
#define repp(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define repm(i,n) for(int (i)=(n-1);(i)>=0;(i)--)
#define INF (1ll<<60)
#define all(x) (x).begin(),(x).end()
typedef long long lint;
const lint MOD =1000000007;
const lint MAX = 10000000;
using Graph =vector<vector<lint>>;
typedef pair<lint,lint> P;

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

void COMinit() 
{
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (lint 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(lint n, lint k)
{
    if (n < k)
        return 0;
    if (n < 0 || k < 0)
        return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

lint primary(lint num)
{
    if (num < 2) return 0;
    else if (num == 2) return 1;
    else if (num % 2 == 0) return 0;

    double sqrtNum = sqrt(num);
    for (int i = 3; i <= sqrtNum; i += 2)
    {
        if (num % i == 0)
        {
            return 0;
        }
    }

    return 1;
}
   long long modpow(long long a, long long n, long long mod) {
    long long res = 1;
    while (n > 0) {
        if (n & 1) res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}
    lint lcm(lint a,lint b){
        return a/__gcd(a,b)*b;
    }
    
    
  int main(){
    string s;
    lint N,Q;
    cin>>N;
    N=(N+1)/2;
    cout<<N;
  }
     
  


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <boost/range/algorithm.hpp>
#include <boost/range/numeric.hpp>
#include <boost/integer/common_factor.hpp>
#include <boost/integer/common_factor_rt.hpp>
#include <boost/multiprecision/cpp_dec_float.hpp>

using std::string;
using std::vector;
using std::set;
using std::map;
using std::unordered_map;
using std::pair;
using std::cin;
using std::cout;

typedef uintmax_t    ull;
typedef intmax_t     ll;
typedef uint64_t     ul;
typedef uint32_t     ui;
typedef uint8_t      uc;

typedef boost::multiprecision::number<boost::multiprecision::cpp_dec_float<1000>> cpp_dec_float_1000;

constexpr char CRLF = '\n';
constexpr char SPACE = ' ';
constexpr char VECTOR_COUT_SEPARATOR = SPACE;
constexpr ll INF = 1000'000'007;

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; }
template<class T> std::ostream& operator<< (std::ostream& os, const std::vector<T>& vc) { for(auto it = vc.begin(); it != vc.end(); ++it) { if (std::next(it) == vc.end()) os << *it; else os << *it << VECTOR_COUT_SEPARATOR; } return os; }
template<class T1, class T2> inline std::ostream & operator<< (std::ostream & os, const std::pair<T1, T2> & p) { return os << p.first << ' ' << p.second; }

void solve(void)
{
  int D{}; cin >> D;
  
  cout << "Christmas";
  while(25 - D++) cout << " Eve";
  cout << CRLF;

  return;
}

int main(void)
{
  std::ios_base::sync_with_stdio(false);
  std::cin.tie(0);

  solve();

  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <algorithm>
#include <cmath>
#include <cstring>
typedef long long ll;


using namespace std;


int a[105];

int main() {
	int n;
	cin >> n;
	int i;
	int s = 0;
	for (i = 1; i <= n; i++) {
		scanf("%d", &a[i]);
	}
	
	for (i = 2; i <= n; i++) {
		if (a[i - 1] == a[i]) {
			s++;
			a[i] = -1;
		}
	}
	cout << s << endl;
}

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

using namespace std;
#define ll long long
#define all(x) x.begin(), x.end()
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<ll> vll;
const int N = 1e5 + 10;


int main() {
    int a, b;
    cin >> a >> b;
    if (a > 8 || b > 8)
        cout << ":(" << endl;
    else cout << "Yay!" << endl;
}

Measured memory_bytes: 3496
#include <iostream>
#include <algorithm>
#include <limits>
#include <vector>
#include <map>
#include <cmath>
#include <limits>
#include <iomanip>
#include <queue>
#include <string.h>
#include <bitset>

#define ll long long int
#define ld long double
#define rep(i,n) for(int i = 0;i < n;i++)
#define rep1(i,n) for(int i = 1;i < n;i++)
#define co(x) cout << x << endl
#define cosp(x) cout << x << " "
#define all(x) x.begin(),x.end()
#define allr(x) x.begin(),x.end(),greater<int>()
#define P pair<ll,ll>
#define pb push_back
#define mp make_pair
#define MOD 1000000007
#define INF 1ll << 60
#define PI 3.14159265359

using namespace std;

int main(){

	string s;
	cin >> s;

	if(s[0] == s[1] && s[1] == s[2]) cout << "No" << endl;
	else cout << "Yes" << endl;

	return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
// 287644PV
#define FIXED_FLOAT(x) std::fixed <<std::setprecision(6)<<(x)
const int mod = 1000000007;

void addSelf(int&x, int y)
{
    x+= y;
    if(x >= mod)
        x-=mod;
}
void subSelf(int&x, int y)
{
    x -= y;
    if(x < 0)
        x += mod;
}

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

int64_t power(int base, int expo)
{
    int64_t sol = 1;
    for (int i = 0; i <expo ; ++i) {
        sol *= base;
    }
    return sol;
}

bool compare1(pair<int,int> i,pair<int,int> j) // 1 < i < n
{
    return i.second < j.second;
}

bool compare2(pair<int,int> i, pair<int,int> j) //n > n-i > 1
{
    return i.first > j.first;
}
int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    int n,d;
    cin >> n >> d;
    set<int> squares;
    for (int i = 0; i <= 1000; ++i) {
        squares.insert(i*i);
    }
    vector<vector<int>> matrix(n,vector<int>(d));
    for (int j = 0; j < n; ++j) {
        for (int i = 0; i < d; ++i) {
            cin >> matrix[j][i];
        }
    }
    int pairs = 0;
    for (int i = 0; i < n; ++i) {
        for (int j = i+1; j < n; ++j) {
            int dist = 0;
            if(i == j)
                continue;
            for (int k = 0; k < d; ++k) {
                dist = dist + (matrix[i][k]-matrix[j][k]) * (matrix[i][k]-matrix[j][k]);
            }
            pairs += squares.count(dist);
        }
    }

    cout << pairs;


return 0;
}

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

int n, a;
double t;

double dif(double tmp){
    return abs(tmp-a);
}

int main(){
    cin >> n >> t >> a;
    double h[n];
    for(int i=0; i<n; ++i){
        cin >> h[i];
    }
    double min_dif = dif(t-h[0]*0.006), min_index = 0;
    for(int i = 1; i<n; ++i){
        if( dif(t-h[i]*0.006) < min_dif ) { min_dif = dif(t-h[i]*0.006); min_index = i;}
    }
    cout << min_index + 1 << endl; return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define REP(i, n) rep(i, 0, n)
#define repb(i, a, b) for(int i = a; i >= b; i--)
#define all(a) a.begin(), a.end()
#define int long long
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e12;

signed main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    string s;
    cin >> s;
    cout << s.substr(0, s.size() - 8) << endl;    
}

Measured memory_bytes: 256
#include<stdio.h>
#include<algorithm>
#define MAXN 100000
using namespace std;
int T[MAXN];
int main(){
	int n,c,k;
	scanf("%d%d%d",&n,&c,&k);
	for(int i=0;i<n;i++)scanf("%d",T+i);
	sort(T,T+n);
	int s=0,cnt=0,ans=1;
	for(int i=0;i<n;i++){
		if(T[i]-T[s]>k||cnt>=c){
			s=i;
			cnt=1;
			ans++;
		}
		else cnt++;
	}
	printf("%d",ans);
	return 0;
}


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

int main(){
  int n,i,x,saisho,kotae=1;
  cin>>n;
  cin>>saisho;
  for(i=1;i<n;i++){
    cin>>x;
    if(saisho>x){
      saisho=x;
      kotae++;
    }
  }
  cout<<kotae;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
using namespace std;
using ll = long long;
using P = pair<int, int>;
template<class T> inline bool chmax(T &a, T b) { if (a<b) {a=b; return 1;} return 0;}
template<class T> inline bool chmin(T &a, T b) { if (b<a) {a=b; return 1;} return 0;}
const string YES = "Yes";
const string NO = "No";

int main(){
    string s;
    cin >> s;
    if (s[2]==s[3] && s[4] == s[5]) cout << YES << endl;
    else cout << NO << endl;
}

Measured memory_bytes: 256
#include <cstring>
#include <cstdio>
#define rg register
#define file(x) freopen(x".in", "r", stdin), freopen(x".out", "w", stdout)
template < class T > inline void read(T& s) {
	s = 0; int f = 0; char c = getchar();
	while ('0' > c || c > '9') f |= c == '-', c = getchar();
	while ('0' <= c && c <= '9') s = s * 10 + c - 48, c = getchar();
	s = f ? -s : s;
}

const int _ = 5010, p = 1e9 + 7;

int tot, head[_], nxt[_ << 1], ver[_ << 1];
inline void Add_edge(int u, int v)
{ nxt[++tot] = head[u], head[u] = tot, ver[tot] = v; }

int n, g[_], siz[_], dp[_][2][_], tmp[2][_];

inline void dfs(int u, int f) {
	siz[u] = 1, dp[u][0][1] = 1;
	for (rg int i = head[u]; i; i = nxt[i]) {
		int v = ver[i]; if (v == f) continue ;
		dfs(v, u), memset(tmp, 0, sizeof tmp);
		for (rg int j = 1; j <= siz[u]; ++j)
			for (rg int k = 1; k <= siz[v]; ++k) {
				int t1 = (1ll * dp[u][0][j] * dp[v][0][k] % p
						  + 1ll * dp[u][1][j] * dp[v][1][k] % p) % p;
				int t2 = (1ll * dp[u][0][j] * dp[v][1][k] % p
						  + 1ll * dp[u][1][j] * dp[v][0][k] % p) % p;
				tmp[0][j + k] = (tmp[0][j + k] + t1) % p;
				tmp[1][j + k] = (tmp[1][j + k] + t2) % p;
				tmp[0][j] = (tmp[0][j] + 1ll * g[k] * t2 % p) % p;
				tmp[1][j] = (tmp[1][j] + 1ll * g[k] * t1 % p) % p;
			}
		siz[u] += siz[v];
		memcpy(dp[u], tmp, sizeof tmp);
	}
}

int main() {
	read(n);
	for (rg int u, v, i = 1; i < n; ++i)
		read(u), read(v), Add_edge(u, v), Add_edge(v, u);
	g[0] = 1;
	for (rg int i = 2; i <= n; i += 2) g[i] = 1ll * (i - 1) * g[i - 2] % p;
	dfs(1, 0);
	int ans = 0;
	for (rg int i = 2; i <= n; i += 2)
		ans = (ans + 1ll * g[i] * (dp[1][0][i] - dp[1][1][i]) % p) % p;
	printf("%d\n", (ans + p) % p);
	return 0;
}


Measured memory_bytes: 196224
#include <bits/stdc++.h>
using namespace std;
typedef long long int lint;

int main(){
    int n, k;
    cin >> n >> k;
    
        int cntr = 1;
        int sonuc = 0;
        while(cntr<k){
            cntr = cntr+n-1;
            sonuc++;
        }
        cout << sonuc;
    
    
    return 0;
}

Measured memory_bytes: 256
#include<cstdio>
int const NMAX=200001;
char s[NMAX],t[NMAX],d[NMAX];
int n,q;
int lastposition(int i){
    int c=i;
    for(int qi=0;qi<q;qi++){
        if(s[c]==t[qi]){
            if(d[qi]=='L'){
                c--;
                if(c<0)return -1;
            }else{
                c++;
                if(c>=n)return n;
            }
        }
    }
    return c;
}

int main(){
    scanf("%d%d%s",&n,&q,s);
    for(int i=0;i<q;i++){
        char tmp0[2],tmp1[2];
        scanf("%s%s",tmp0,tmp1);
        t[i]=tmp0[0];
        d[i]=tmp1[0];
    }
    //for(int i=0;i<n;i++)printf("%d->%d\n",i,lastposition(i));
    //端にあるゴーレムが反対側の端に落ちるならすべて消滅する
    if(lastposition(n-1)==-1||lastposition(0)==n){
        printf("0\n");
        return 0;
    }
    //l,l+1,...,rにいたゴーレムが生き残るとする
    //l-1は-1に消える
    int lmin=0,lmax=n-1,l;
    while(lmin+1<lmax){
        int lmid=(lmin+lmax)/2;
        if(lastposition(lmid)>=0)lmax=lmid;
        else lmin=lmid;
    }
    if(lastposition(lmin)==-1)l=lmax;
    else l=lmin;
    //r+1はnに消える
    int rmin=0,rmax=n-1,r;
    while(rmin+1<rmax){
        int rmid=(rmin+rmax)/2;
        if(lastposition(rmid)<n)rmin=rmid;
        else rmax=rmid;
    }
    if(lastposition(rmax)==n)r=rmin;
    else r=rmax;
    printf("%d\n",r-l+1);
    return 0;
}

Measured memory_bytes: 768
#include <bits/stdc++.h>
#include <iostream>
#include <vector>
#include <sstream>
#include <algorithm>

#define REP(i,n) for(int i = 0; i < (int)(n); i++)
#define ALL(x) (x).begin(),(x).end()

using namespace std;
using ll = long long;

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

    //write here
    ll N,P;
    cin >> N >> P;
    ll count = 2;
    ll res = 1;
    if (N == 1) {
        cout << P << endl;
        return 0;
    }

    while(1){
        bool is_down = false;
        ll tmp = 1;
        for(int i = 0; i < N;i = i + 1) {
            tmp *= count;
            if(tmp > P) {
                is_down = true;
                break;
            }
        }
        if (tmp > P || is_down)
            break;
        //  if(P % count == 0)
        //     P /= count;
        if (P % tmp == 0) {
            res = count;

        }

        count += 1;
    }

    cout << res<< endl;
    return 0;
}

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

readline = sys.stdin.buffer.readline
def readstr():return readline().rstrip().decode()
def readstrs():return list(readline().decode().split())
def readint():return int(readline())
def readints():return list(map(int,readline().split()))
def printrows(x):print('\n'.join(map(str,x)))
def printline(x):print(' '.join(map(str,x)))

class Twelveways:
    def __init__(self,n,m=10**9+7):
        self.num = n
        self.mod = m
        self.f = self.factorials()
        self.g = self.inverse()

    def factorials(self):
        # 0~n!のリスト
        f = [1, 1]
        for i in range(2, self.num + 1):
            f.append(f[-1] * i % self.mod)
        return f

    def inverse(self):
        # 0~n!の逆元のリスト
        g = [1]
        for i in range(self.num):
            g.append(pow(self.f[i + 1], self.mod - 2, self.mod))
        return g

    def combination(self, n, k):
        # nCk mod mを求める
        nCk = self.f[n] * self.g[n - k] * self.g[k]
        nCk %= self.mod
        return nCk


s = readint()
mod = 10**9+7

a = Twelveways(s)

ans = 0
for i in range(1,s//3+1):
    ans += a.combination(s-3*i+i-1,i-1)

print(ans%mod)






Measured memory_bytes: 64940
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.io.PrintWriter;
import java.util.StringTokenizer;

public class Main {

	public static void main(String[] args) {
		InputStream inputStream = System.in;
		OutputStream outputStream = System.out;
		InputReader in = new InputReader(inputStream);
		PrintWriter out = new PrintWriter(outputStream);
		Task solver = new Task();
		solver.solve(1, in, out);
		out.close();

	}
	static class Task{
		int M = (int) (1e9 + 3);
		public void solve(int testNumber, InputReader in, PrintWriter out) {
			
				char[] s = in.next().toCharArray();
				for(int i = -1; ++i < 3;) if(s[i] == s[i+1]) {
					out.print("Bad");return;
				}
			
				out.print("Good");
	
		}//Solve
		

			
	}//task

	static class InputReader{
		public BufferedReader reader;
		public StringTokenizer tokenizer;
		public InputReader(InputStream stream) {
			reader = new BufferedReader(new InputStreamReader(stream), 32768);
			tokenizer = null;
		}
		public String next() {
			while(tokenizer == null || ! tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(reader.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		public int nextInt() {
			return Integer.parseInt(next());
		}
		public int[] nextIntArray(int n) {
			int[] arr = new int[n];
			for(int i = -1; ++i < n;) arr[i] = Integer.parseInt(next());
			return arr;
		}
		public long nextLong() {
			return Long.parseLong(next());
		}
		
	}
}

Measured memory_bytes: 21460
#include <iostream>
#include <vector>
#include <cstdio>
using namespace std;

int main() {
	int r,c,n,rsum;
	vector<int> csum;
	cin >> r >> c;
	csum.resize(c+1);
	for(int i=0;i<c+1;++i) {
		csum[i]=0;
	}
	for(int i=0;i<r;++i) {
		rsum=0;
		for(int j=0;j<c;++j) {
			scanf("%d",&n);
			printf("%d ",n);
			csum[j]+=n;
			rsum+=n;
		}
		printf("%d\n",rsum);
		csum[c]+=rsum;
	}
	for(int j=0;j<c;++j) {
		printf("%d ",csum[j]);
	}
	printf("%d\n",csum[c]);
	return 0;
}

Measured memory_bytes: 3220
#include <iostream>

using namespace std;

int main()
{
    int N;

    cin >> N;

    int M = N;
    int S = 0;

    while (M)
    {
        S = S + (M % 10);
        M = M / 10;
    }

    if (N % S)
        cout << "No";
    else
        cout << "Yes";

    cout << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ff { ios_base::sync_with_stdio(false);cin.tie(NULL);}
using namespace std;

typedef long long ll;
 ll  pp=1e9+7; 
double pi=3.141592653589793238;
  
 int main() {
        ff;
        int n;
        cin>>n;
        long long int a[n];
        for(int i=0;i<n;i++){
            cin>>a[i];
        }
        int c=0;
        for(int i=0;i<n;i++){
            for(int j=i+1;j<n;j++){
                for(int k=j+1;k<n;k++){
                    if(a[i]!=a[j] && a[j]!=a[k] && a[i]!=a[k]&& a[i]+a[j]>a[k] && a[j]+a[k]>a[i] && a[i]+a[k]>a[j]){
                        c++;
                    }
                }
            }
        }
        cout<<c<<endl;
		
    return 0;
}

            
		
        
           
  

Measured memory_bytes: 3544
from collections import deque
import sys
input = sys.stdin.readline

N = int(input())
A = list(map(int, input().split()))
B = list(map(int, input().split()))
cntA = [0] * (N + 1)
cntB = [0] * (N + 1)
for i in range(N):
    cntA[A[i]] += 1
    cntB[B[i]] += 1
nums = [(cntA[i], cntB[i], i) for i in range(1, N+1)]
nums.sort(key=lambda p: p[0] + p[1], reverse=True)
a = deque()
b = deque()
c = deque(list(range(N)))
ansa = [0] * N
ansb = [0] * N
for x, y, n in nums:
    if x == y == 0:
        break
    if x + y > len(a) + len(b) + len(c):
        print('No')
        exit()
    ra = x - len(a)
    rb = y - len(b)
    for i in range(ra):
        ansa[c[0]] = n
        b.append(c[0])
        c.popleft()
        x -= 1
    for i in range(rb):
        ansb[c[0]] = n
        a.append(c[0])
        c.popleft()
        y -= 1
    while c and (x or y):
        if x:
            ansa[c[0]] = n
            b.append(c[0])
            x -= 1
        else:
            ansb[c[0]] = n
            a.append(c[0])
            y -= 1
        c.popleft()
    for i in range(x):
        ansa[a[0]] = n
        a.popleft()
    for i in range(y):
        ansb[b[0]] = n
        b.popleft()
ans = []
for i in range(N):
    ans.append((ansa[i], ansb[i]))
ans.sort()
print('Yes')
print(*[p[1] for p in ans])

Measured memory_bytes: 170688
A = []
B = []
n, m = map(int, input().split())

for i in range(n):
    A.append(list(map(int, input().split())))

for i in range(m):
    B.append(int(input()))

for i in range(n):
    ans = 0
    for a, b in zip(A[i], B):
        ans += (a * b)
    print(ans)


Measured memory_bytes: 6012
#include<cstdio>
#include<iostream>
#include<string>
#include<algorithm>

using namespace std;

int main(void) {

	int a[3], tmp = 3;

	cin >> a[0] >> a[1] >> a[2];

	if (a[0] == a[1]) {
		tmp--;
	}

	if (a[1] == a[2]) {
		tmp--;
	}else if (a[2]== a[0]) {
		tmp--;
	}
	
	cout << tmp << "\n";

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define endl "\n"
using namespace std;
#define ll long long
#define ld long double
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define repo(i,n) for(int i = 1; i < (int)(n); i++)
#define pb push_back
#define mp make_pair
#define np next_permutation
#define fi first
#define se second
#define all(x) (x).begin(),(x).end()
#define uniq(v) v.erase(unique(v.begin(),v.end()),v.end())
#define lb(v,x) (lower_bound(v.begin(),v.end(),x)-v.begin())
#define ub(v,x) (upper_bound(v.begin(),v.end(),x)-v.begin())
using Pair = pair<ll,pair<int,int>>;
#define pq priority_queue<Pair, vector<Pair>, greater<Pair>> 
const ll mod=1000000007;
//const ll mod=998244353;
const ld pi=acos(-1.0);
const ll INF = 1LL<<61;
template<class T>bool chmax(T &a, const T &b) { 
  if (a<b) { a=b; return 1; } return 0; }
template<class T>bool chmin(T &a, const T &b) {
  if (b<a) { a=b; return 1; } return 0; }
ll gcd(ll x, ll y) { return y ? gcd(y, x % y) : x; }
ll lcm(ll x, ll y) { return x / gcd(x, y) * y; }
//intの最大値2147483647 ≒ 2×10^9
//long longの最大値9223372036854775807 ≒ 9×10^18
//'大文字'+=32;    で小文字に
//  cout << fixed << setprecision (20);   小数点以下2０桁まで
//実行時間制約2秒では２×10^8回くらいまで計算できる


//—————————————UnionFind木   UF uf(n);——————————————————————

struct UF {
    vector <ll> par; // 各元の親を表す配列
    vector <ll> siz; // 素集合のサイズを表す配列(1 で初期化)

    UF(ll sz_): par(sz_), siz(sz_, 1LL) {
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }
    void reset(ll sz_) {
        par.resize(sz_);
        siz.assign(sz_, 1LL);
        for (ll i = 0; i < sz_; ++i) par[i] = i; // 初期では親は自分自身
    }

    ll root(ll x) { // 根の検索
        while (par[x] != x) {
            x = par[x] = par[par[x]]; // x の親の親を x の親とする
        }
        return x;
    }

    bool unite(ll x, ll y) {
        x = root(x);
        y = root(y);
        if (x == y) return false;
        // merge technique（データ構造をマージするテク．小を大にくっつける）
        if (siz[x] < siz[y]) swap(x, y);
        siz[x] += siz[y];
        par[y] = x;
        return true;
    }

    bool same(ll x, ll y) { // 連結判定
        return root(x) == root(y);
    }

    ll size(ll x) { // 素集合のサイズ
        return siz[root(x)];
    }
};

//—————————————————————————————————————————————————


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

  int n,q;
  cin>>n>>q;

  UF uf(n);

  rep(i,q){
    int t,u,v;
    cin>>t>>u>>v;
    if(t==0) uf.unite(u,v);
    if(t==1) cout << uf.same(u,v) << endl;
  }




}


Measured memory_bytes: 6176