akhauriyash/Code-Regression huggingface dataset:
#include <cstdio>
#include <iostream>
#include <set>
#include <map>
#include <vector>
#include <algorithm>
#include <utility>
#include <string>
#include <cmath>
#include <iomanip>
typedef long long ll;
#define rep(i,n) for(int i=0;i<n;i++)

using namespace std;
ll intpow(ll N, ll P){
    if(P==0) return 1;
    if(P%2==0){
        ll t = intpow(N, P/2);
        return t*t;
    }
    return N * intpow(N, P-1);
}
ll gcd(ll n,ll m){
    n = max(n,m);
    m = min(n,m);
    if(n%m == 0)return m;
    return gcd(m,n%m);
}
ll lcm(ll n,ll m){
    return n*m/gcd(n,m);
}
int main(){
    ll n;cin >> n;
    ll a[5];
    rep(i,5)cin >> a[i];
    sort(a,a+5);
    if(n%a[0] != 0)cout << n/a[0]+5 <<endl;
    else cout << n/a[0]+4 <<endl;
}

Measured memory_bytes: 256
// ######      ###      #######    #######    ##     #     #####        ###     ##### //
// #     #    #   #          #        #       # #    #    #     #      #   #     ###  //
// #     #   #     #        #         #       #  #   #   #       #    #     #    ###  //
// ######   #########      #          #       #   #  #   #           #########    #   //
// #     #  #       #     #           #       #    # #   #    ####   #       #    #   //
// #     #  #       #    #            #       #     ##   #    #  #   #       #        //
// ######   #       #   #######    #######    #      #    #####  #   #       #    #   //

// #pragma GCC optimize(2)
// #pragma GCC optimize(3)
// #pragma GCC optimize("Ofast,no-stack-protector,unroll-loops,fast-math,O3")
// #pragma GCC target("avx,avx2,fma")
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef long double lld;
#define DEBUG(x) cout << '>' << #x << ':' << x << endl;
#define loop(i,n) for(ll i=0;i<(n);++i)
#define FOR(i,a,b) for(ll i=(a);i<=(b);++i)
#define FORD(i,a,b) for(ll i=(a);i>=(b);--i)
#define cases ll T=0;cin>>T;while(T--)
#define ff first
#define ss second
#define all(v) v.begin(),v.end()
#define END "\n"
#define pb push_back
#define go(c,itr) for(auto itr=(c).begin(); itr!=(c).end(); ++itr)
#define back(c,itr) for(auto itr=(c).rbegin(); itr!=(c).rend(); ++itr)
#define PI 3.14159265359
#define inf 9e18
#define MOD 1000000007
#define MODU 998244353
#define fast ios_base::sync_with_stdio(false); cin.tie(NULL); cout.tie(NULL);
#define MAXN 100005
const string alpha = "abcdefghijklmnopqrstuvwxyz";
const ll N = 1e9;
ll binexp(ll a, ll b, ll m) {
	a %= m;
	ll res = 1;
	while (b > 0) {
		if (b & 1)
			res = res * a % m;
		a = a * a % m;
		b >>= 1;
	}
	return res;
}
void task(bool flag)
{
	if (flag)
		cout << "YES\n";
	else
		cout << "NO\n";
}
ll lcm(ll a, ll b)
{
	return ((1LL * a * b) / (__gcd(a, b)));
}
vector<vector<ll>> adj(MAXN);
vector<ll> vis(MAXN), indeg(MAXN), dist(MAXN, 0);
void addedge()
{
	ll a, b;
	cin >> a >> b;
	adj[a].pb(b);
	++indeg[b];
	// adj[b].pb(a);
}
vector<ll> ans;
void dfs(ll node)
{
	vis[node] = 1;
	for (auto child : adj[node])
	{
		dist[child] = max(dist[node] + 1, dist[child]);
		--indeg[child];
		if (indeg[child] == 0)
			dfs(child);
	}
}
signed main() {
// #ifndef ONLINE_JUDGE
// 	freopen("input.txt", "r", stdin);
// 	freopen("output.txt", "w", stdout);
// #endif
	fast
	ll n, m;
	cin >> n >> m;
	loop(i, m)	addedge();
	FOR(i, 1, n)
	{
		if (vis[i] == 0 && indeg[i] == 0)
		{
			dfs(i);
		}
	}
	cout << *max_element(all(dist)) << END;



// #ifndef ONLINE_JUDGE
// 	cout << "\nTime Elapsed: " << 1.0 * clock() / CLOCKS_PER_SEC << " sec\n";
// #endif
	return 0;
}


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

int main(void) {
    double N,K;cin>>N>>K;
    double ex = 0.0;
    for (int i = 1; i <= N; i++) {
        int score = i;
        int cnt = 0;
        if (score >= K) {
            ex += 1 / N;
            continue;
        }
        while (1 <= score && score <= K - 1) {
            cnt++;
            score *= 2;
        }
        ex += (1 / N) * pow((1 / 2.0), cnt);
        
    }
    printf("%.10f\n", ex);
    return 0;
}

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

#define ll long long int 

const ll N = 2e5+7 ;

ll dp[4][N] ;

const ll N1 = 2e5+7  ;
ll max_cost ( ll a[][N1] , ll n , ll k) {

	if(dp[k][n] != -1) return dp[k][n] ;

	if( n == 0) {
		dp[k][n] = 0 ;
		return dp[k][n] ;
	}
	if( n == 1) {
		dp[k][1] = a[k][1] ;
		return dp[k][1] ;
	}

	if( k == 1) {
		dp[k][n] = max ( max_cost( a , n-1 , 2 ) ,  max_cost( a , n-1 , 3 ) ) + a[k][n] ;
		return dp[k][n] ;
	}
	if( k == 2 ){
		dp[k][n] = max ( max_cost( a , n-1 , 1 ) ,  max_cost( a , n-1 , 3 ) ) + a[k][n] ;
		return dp[k][n] ;
	}
	if( k == 3 ){
		dp[k][n] = max ( max_cost( a , n-1 , 1 ) ,  max_cost( a , n-1 , 2 ) ) + a[k][n] ;
		return dp[k][n] ;
	}

}
void solve(ll n ) {
	ll a[4][N1];
	for(int i = 1; i <= n ; i++ ){
		for(int j = 1 ; j <= 3 ; j++ ) {
			cin >> a[j][i] ;
		}
	} 
	memset( dp , -1 , sizeof(dp) ) ;
	cout <<  max(max_cost(a,n,1) , max( max_cost(a,n,2) ,max_cost(a,n,3) ) ) ;
}


int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    ll n ; cin >> n ;
    solve(n) ;
    return 0;
}

Measured memory_bytes: 16128
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vb=vector<bool>;
using vvb=vector<vb>;
using vd=vector<double>;
using vvd=vector<vd>;
using vi=vector<int>;
using vvi=vector<vi>;
using vl=vector<ll>;
using vvl=vector<vl>;
using pll=pair<ll,ll>;
using tll=tuple<ll,ll>;
using tlll=tuple<ll,ll,ll>;
using vs=vector<string>;
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define rep(i,n) range(i,0,n)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define range(i,a,n) for(ll i=(a);i<(n);i++)
#define LINF ((ll)1ll<<60)
#define INF ((int)1<<30)
#define EPS (1e-9)
#define MOD (1000000007ll)
#define fcout(a) cout<<setprecision(a)<<fixed
#define fs first
#define sc second
#define PI (3.1415926535897932384)

int dx[]={1,0,-1,0,1,-1,-1,1},dy[]={0,1,0,-1,1,1,-1,-1};
template<class T>bool chmax(T&a,T b){if(a<b){a=b; return true;}return false;}
template<class T>bool chmin(T&a,T b){if(a>b){a=b; return true;}return false;}
template<class S>S sum(vector<S>&a){return accumulate(all(a),S());}
template<class S>S max(vector<S>&a){return *max_element(all(a));}
template<class S>S min(vector<S>&a){return *min_element(all(a));}
ll max(int a,ll b){return max((ll)a,b);} ll max(ll a,int b){return max(a,(ll)b);}
int sgn(const double&r){return (r>EPS)-(r<-EPS);} // a>0  : sgn(a)>0
int sgn(const double&a,const double&b){return sgn(a-b);} // b<=c : sgn(b,c)<=0

template<class T>void puta(T&&t){cout<<t<<"\n";}
template<class H,class...T>void puta(H&&h,T&&...t){cout<<h<<' ';puta(t...);}
template<class S,class T>void tf(bool b,S t,T f){if(b)puta(t);else puta(f);}
void YN(bool b){tf(b,"YES","NO");}
void Yn(bool b){tf(b,"Yes","No");}
void yn(bool b){tf(b,"yes","no");}
template<class S,class T>ostream&operator<<(ostream&os,pair<S,T>p){os<<"["<<p.first<<", "<<p.second<<"]";return os;};
template<class S>auto&operator<<(ostream&os,vector<S>t){bool a=1;for(auto s:t){os<<(a?"":" ")<<s;a=0;}return os;}
template<class S>auto&operator>>(istream&is,vector<S>&t){for(S&a:t)cin>>a;return is;}

/*他のライブラリを入れる場所*/


int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	ll n;
	cin>>n;
	ll ans=LINF;
	range(i,1,(ll)ceil(sqrt(n))+1){
		if(n%i!=0)continue;
		chmin(ans,i-1 + n/i-1);
	}
	puta(ans);
	return 0;
}

Measured memory_bytes: 256
import itertools

n = int(input())
p = input().split(" ")
q = input().split(" ")

pi = itertools.permutations(sorted(p))
a = 0
for pi_p in pi:
    a += 1
    if tuple(p) == pi_p:
        break

qi = itertools.permutations(sorted(q))
b = 0
for qi_q in qi:
    b += 1
    if tuple(q) == qi_q:
        break

print(abs(a - b))

Measured memory_bytes: 41564
#include<stdio.h>
int main (void)
{
	int a,b,c,d;
	scanf("%d %d %d",&a,&b,&c);
	
	d = c - (a - b);
	
	if(d <= 0){
		d = 0;
	}
	printf("%d",d);
	
	return 0;
}

Measured memory_bytes: 128
#include<iostream>
#include<algorithm>
#include<cstdint>

int64_t const MOD = 1e9+7;
int const MAXN = 1e5;
int N, K;
int64_t A[MAXN];

template<int64_t Prime>
struct mod_int {
  int64_t v_;
  mod_int(int64_t x=0) : v_(x) { normalize(); }
  void normalize() { ((v_ %= Prime) += Prime) %= Prime; }
  mod_int operator+=(mod_int const& r){ (v_ += r.v_) %= Prime; return *this; }
  mod_int operator-=(mod_int const& r){ (v_ += Prime - r.v_) %= Prime; return *this; }
  mod_int operator*=(mod_int const& r){ (v_ *= r.v_) %= Prime; return *this; }
  mod_int operator+(mod_int const& r) { mod_int res(*this); return res += r; }
  mod_int operator-(mod_int const& r) { mod_int res(*this); return res -= r; }
  mod_int operator*(mod_int const& r) { mod_int res(*this); return res *= r; }
  mod_int pow(int x) const {
    int64_t res = 1, v = v_;
    while(x > 0) {
      if(x&1) (res *= v) %= Prime;
      x/=2; (v *= v) %= Prime;
    }
    return mod_int(res);
  }
  mod_int inv() const { return pow(Prime-2); }
};
typedef mod_int<MOD> mint;

mint fact[MAXN+1], ifact[MAXN+1];
void init() {
  fact[0] = fact[1] = mint(1);
  for(int i = 2; i <= N; ++i) fact[i] = fact[i-1]*i;
  ifact[N] = fact[N].inv();
  for(int i = N-1; i >= 0; --i) ifact[i] = ifact[i+1]*(i+1);
}
mint comb(int n, int k) { return fact[n]*ifact[k]*ifact[n-k]; }

int main() {
  std::cin >> N >> K;
  init();
  for(int i = 0; i < N; ++i) std::cin >> A[i];
  std::sort(A, A+N);
  mint vm, vM;
  for(int i = 0; i < N; ++i) {
    if(i+K<=N) vm += comb(N-i-1, K-1)*A[i];
    if(i>=K-1) vM += comb(i, K-1)*A[i];
  }
  std::cout << (vM - vm).v_ << std::endl;
  /*mint ans;
  for(int i = 0; i+K <= N; ++i) {
    mint diff = 
    ans += (mint(A[N-1-i]) - mint(A[i]))*comb(N-i-1, K-1);
  }
  std::cout << ans.v_ << std::endl;*/
  return 0;
}


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

int main()
{
  string s;
  cin >> s;
  if(s.at(0) != s.at(1) && s.at(0) != s.at(2) && s.at(1) != s.at(2))
  {
    cout << "Yes" << endl;
  }
  else
  {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
#include<iostream>
#include<fstream>
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
#define fast ios_base::sync_with_stdio(false),cin.tie(nullptr)
int main()
{
        char ch;
        cin>>ch;
        if(ch>='A' && ch<='Z')
                cout<<"A"<<endl;
        else
                cout<<"a"<<endl;
}

Measured memory_bytes: 3612
#include <bits/stdc++.h>
using namespace std;
#define REP(i,n) for(int i=0;i<n;i++)
#define REPR(i,n) for(int i=n;i>=0;i--)
#define FOR(i,m,n) for(int i=m;i<n;i++)
#define ALL(a) a.begin(),a.end()
typedef long long ll;
#define INF 1<<30

int main()
{
    int N;
    cin >> N;
    vector<int> A(N);
    REP(i,N)cin >> A[i];
    bool approve = true;
    REP(i,N){
        if(A[i]%2==0){
            if(A[i]%3!=0&&A[i]%5!=0)approve = false;
        }
        else continue;
    }
    if(approve)cout << "APPROVED" << endl;
    else cout << "DENIED" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;
class P
{
	int x;
	int y;
	P(int x, int y)
	{
		this.x = x;
		this.y = y;
	}
}
public class Main 
{
	public static void main(String[] args) 
	{
		Scanner stdIn = new Scanner(System.in);
		int n = stdIn.nextInt();
		int count = 1;
		while(n-- != 0)
		{
			StringBuffer[] field = new StringBuffer[8];
			
			for(int i = 0; i < 8; ++i)
			{
				String temp = stdIn.next();
				field[i] = new StringBuffer(temp);
			}
			int x = stdIn.nextInt();
			int y = stdIn.nextInt();
			field[y - 1].setCharAt(x - 1, '0');
			Queue<P> que = new ArrayDeque<P>();
			que.add(new P(x - 1, y - 1));
			while(!que.isEmpty())
			{
				P p = que.poll();
				for(int i = -3; i <= 3; ++i)
				{
					if(p.x + i < 0 || p.x + i >= 8)
					{
						continue;
					}
					if(field[p.y].charAt(p.x + i) == '1')
					{
						field[p.y].setCharAt(p.x + i, '0');
						que.add(new P(p.x + i, p.y));
					}
				}
				for(int i = -3; i <= 3; ++i)
				{
					if(p.y + i < 0 || p.y + i >= 8)
					{
						continue;
					}
					if(field[p.y + i].charAt(p.x) == '1')
					{
						field[p.y + i].setCharAt(p.x, '0');
						que.add(new P(p.x, p.y + i));
					}
				}
			}
			System.out.println("Data " + count + ":");
			for(int i = 0; i < 8; ++i)
			{
				System.out.println(field[i]);
			}
			++count;
		}
	}
}

Measured memory_bytes: 12000
#include <iostream>

using namespace std;

int main(){
  int x,sum = 0,p = 1;
  for(int i = 0 ; i < 3 ; i++){
    cin >> x;
    sum += x*p; p *= 2;
  }
  if(sum == 3 || sum == 4){
    cout << "Open" << endl;
  }else{
    cout << "Close" << endl;
  }
  return 0;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define REP(i, n) for (int i = 1; i <= (int)(n); i++)
#define all(v) v.begin(), v.end()
using namespace std;
using ll = long long;
using pi = pair<int, int>;
const ll INF = 1LL << 60;

int main() {
    int n;
    ll maxim = 0;
    cin >> n;
    bool ans = true;
    vector<ll>arr(n);
    rep(i, n)cin >> arr[i];
    for (int i = n - 1; i > 0; i--) {
        if (arr[i] < arr[i - 1]) {
            if (arr[i] == (arr[i - 1] - 1))arr[i - 1]--;
            else { ans = false; break; }
        }
    }
    if (ans) {
        cout << "Yes" << endl;
    }
    else {
        cout << "No" << endl;
    }
    return 0;
}

Measured memory_bytes: 1024
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <iostream>
#include <map>
#include <queue>
#include <unordered_map>
#include <utility>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>
#include <cstdio>

using namespace std;

#define REP(i,n,m) for( long long i = (n); i < (m); i++ )
#define ll long long
#define ALL(a) (a).begin(), (a).end()
#define SORT(v) sort( v.begin(), v.end() );
#define LAST(v) v[sz(v)-1]
#define ZERO(a) memset(a,0,sizeof(a))
#define MINUS(a) memset(a,-1,sizeof(a))
#define pi pair<int, int>
#define MP make_pair
#define PB push_back
#define IIN(a) int a; cin >> a;
#define LIN(a) long long a; cin >> a;
#define SIN(a) string a; cin >> a;
#define EPS (1e-10)

int MOD=1000000007;
int dx[4] = {0, 0, -1, 1};
int dy[4] = {1, -1, 0, 0};
//Im ASCII code: '0' = 48; 'A' = 65; 'a' = 97


signed main(){
  LIN( n );
  ll num_odd = 0;
  REP( i, 0, n ){
    LIN( a );
    if( a % 2 == 1 ) num_odd++;
  }

  cout << ( ( num_odd % 2 == 0 ) ? "YES" : "NO" ) << endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
using namespace std;
int main(void)
{
	int S,h,m,s;
	cin >> S;
	h=S/3600;
	S=S%3600;
	m=S/60;
	S=S%60;
	s=S;
	cout << h << ":" << m << ":" << s << endl;
	
	return 0;
}

Measured memory_bytes: 3092
#include<iostream>
#include<string>
#include<cctype>

using namespace std;

string shuffle(string str, int h ){
  string head = str.substr(0, h);
  string tail = str.substr(h, str.size() - h);
  return tail + head;
}

int main(){
  string cards;
  int m, h;

  while(1){
    cin >> cards;
    if (cards == "-" ) break;

    cin >> m;
    for ( int i = 0; i < m; i++){
      cin >> h;
      cards = shuffle(cards, h);
    }
    cout << cards << endl;
  }

  return 0;

}

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

int main(){
    int a, b;
    cin >> a >> b;
    if(a%3==0 || b%3==0 || (a+b)%3==0){
        cout << "Possible" << endl;
    }else{
        cout << "Impossible" << endl;
    }

    return 0;
}

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

using namespace std;

inline int read(){
	char ch=getchar();int x=0,f=1;
    while(ch<'0' || ch>'9') {
       if(ch=='-') f=-1;
	  	  ch=getchar();
	}
    while(ch<='9' && ch>='0') {
	   x=x*10+ch-'0';
	   ch=getchar();
	}
    return x*f;
}

int main(){
	long long int x=read(),y=read(),z=read(),k=read();
	if(x<y) swap(x,y);
	if(x<z) swap(x,z);
	for(int i=1;i<=k;i++) 
	x*=1ll*2;
	cout<<x+y+z<<endl;
	return 0;
}


Measured memory_bytes: 384
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.Arrays;
import java.util.HashMap;
import java.util.Scanner;
import java.util.StringTokenizer;

public class Main {
    public static void main(String[] args) {
        Scanner s = new Scanner(System.in);
        int k= 1;
        HashMap<String,Integer> hashMap = new HashMap<>();
        hashMap.put("SUN",7);
        hashMap.put("MON",6);
        hashMap.put("TUE",5);
        hashMap.put("WED",4);
        hashMap.put("THU",3);
        hashMap.put("FRI",2);
        hashMap.put("SAT",1);
        String s1;
        String s2;
        int a,b,c;
        double n;
        while(k-->0){
            a=s.nextInt();
            b=s.nextInt();
            c=a+b;
            if(c%2==0)
                System.out.println(c/2);
            else
                System.out.println("IMPOSSIBLE");
        }
    }

    private static int binary_search(
            int arr[], int l,
            int h, int x)
    {
        while (l <= h) {
            int mid = (l + h) / 2;
            if (arr[mid] <= x)
                l = mid + 1;
            else
                h = mid - 1;
        }
        return h;
    }
    static int gcd(int a, int b)
    {
        if(b==0) {
            return a;
        }
        return gcd(b,a%b);
    }
    private static boolean isPrime(int n) {
        if (n == 2)
            return true;
        else if ((n % 2 == 0 && n > 2) || n < 2)
            return false;
        else {
            for (int i = 3; i <= (int) Math.sqrt(n); i += 2) {
                if (n % i == 0)
                    return false;
            }
            return true;
        }


    }

    static class FastReader {
        BufferedReader br;
        StringTokenizer st;

        public FastReader() {
            br = new BufferedReader(new
                    InputStreamReader(System.in));
        }

        String next() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }

        int nextInt() {
            return Integer.parseInt(next());
        }

        long nextLong() {
            return Long.parseLong(next());
        }

        double nextDouble() {
            return Double.parseDouble(next());
        }

        String nextLine() {
            String str = "";
            try {
                str = br.readLine();
            } catch (IOException e) {
                e.printStackTrace();
            }
            return str;
        }
    }

}

Measured memory_bytes: 26996
#include <stdio.h>
#include <stdlib.h>
#include <math.h>
#include <string.h>

int main()
{
	int N;
	int H[100000];
	int ans=0, count = 0;

	scanf("%d", &N);

	for (int i = 0; i < N; i++)
		scanf("%d", &H[i]);

	for (int i = 0; i < N; i++)
	{
		count = 0;
		for (int j = i; j < N -1; j++)
		{
			if (H[j] < H[j + 1])
				break;
			count++;
		}
		if(count>0)
			i += count-1;
		if (count > ans)
			ans = count;
	}

	printf("%d", ans);
}


Measured memory_bytes: 512
import java.util.Scanner;
public class Main{
    
    public static void main (String[ ]args){
        
        Main main = new Main ();
        main.solve();
    }
    
    private void solve (){
        Scanner sc = new Scanner (System.in);

        String s = sc.next();
        
        char [] list = new char [s.length()];
        
        for (int index=0; index<s.length(); index++){
            list[index]=s.charAt(index);
        }
        
        boolean odd = true;
        int count1 = 0;
        for (int index=0; index<s.length();index++){
            if (odd){
                if (list[index]=='0'){
                    count1++;
                }
                odd=false;
            } else {
                if (list[index]=='1'){
                    count1++;
                }
                odd=true;
            }
        }
        odd=false;
        int count2=0;
        for (int index=0; index<s.length();index++){
            if (odd){
                if (list[index]=='0'){
                    count2++;
                }
                odd=false;
            } else {
                if (list[index]=='1'){
                    count2++;
                }
                odd=true;
            }
        }
        
        if (count1>count2){
            System.out.println(count2);
        } else {
            System.out.println(count1);
        }
    }
}

Measured memory_bytes: 27988
#include <bits/stdc++.h>
using namespace std;
const int MOD = 1e9+7;
const double EPS = 1e-11;
const double PI = 2 * acos(0.0);
using ll = long long;
using ull =  unsigned long long;

#define input freopen("input.txt", "r", stdin)
#define output freopen("output.txt", "w", stdout)
#define fast_io ios_base::sync_with_stdio(0);cin.tie(nullptr);cout.tie(nullptr);
#define pf printf
#define si(x) scanf("%d",&x)
#define sl(x) scanf("%lld",&x)
#define sii(x,y) scanf("%d %d",&x,&y)
#define sll(x,y) scanf("%lld %lld",&x,&y)

#define pii pair<int,int>
#define nl '\n'
#define mp make_pair
#define x first
#define y second
#define pb push_back
#define ALL(v) v.begin(),v.end()
#define uniq(a) a.erase(unique(a.begin(), a.end()), a.end())
#define out(x) cout <<"#x = "<<x<<endl
#define outt(x,y) cout <<"# "<<x<<" "<<y<<endl
#define mem(array,value) memset(array,value,sizeof(array))
#define MX 10005

int a[100007];
int b[100007];
int c[100007];
int n;
int dp[100007][4];
int solve(int pos,int prev)
{
	if(pos==n)return 0;

	if(dp[pos][prev]!=-1)return dp[pos][prev];
	int val=0;
	if(pos==0){
		val=max(a[pos]+solve(pos+1,1),max(b[pos]+solve(pos+1,2),c[pos]+solve(pos+1,3)));
	}
	
	if(prev==1){
		val=max(val,max(b[pos]+solve(pos+1,2),c[pos]+solve(pos+1,3)));
	}
	else if(prev==2){
		val=max(val,max(a[pos]+solve(pos+1,1),c[pos]+solve(pos+1,3)));
	}
	else if(prev==3){
		val=max(val,max(a[pos]+solve(pos+1,1),b[pos]+solve(pos+1,2)));
	}
	return dp[pos][prev]=val;
}
int main()
{
	mem(dp,-1);
	cin >>n;
	for(int i=0;i<n;i++){
		cin >>a[i]>>b[i]>>c[i];
	}
	cout <<solve(0,0)<<endl;
	return 0;
}

Measured memory_bytes: 9216
#include<iostream>
#include<cstdio>
#include<algorithm>
#include<cmath>
#include<vector>
#include<map>
#include<set>
#include<string>
#include<queue>
#include<stack>
using namespace std;
#define MOD 1000000007
#define INF (1<<29)
#define LINF (1LL<<60)
#define EPS (1e-10)
typedef long long Int;
typedef pair<Int, Int> P;

vector<int> edge[216000];
Int cnt[216000][20];
Int val[216000];
Int n, u, v;
void solve(Int x, Int last = -1){
  for(Int to:edge[x]){
    if(to == last)continue;
    solve(to, x);
    for(Int i = 0;i < 20;i++){
      cnt[x][i] += cnt[to][i];
    }
  }
  val[x] = 19;
  while(val[x] > 0 && cnt[x][val[x]] <= 1)val[x]--;
  while(cnt[x][val[x]] > 0)val[x]++;
  for(int i = 0;i < 20;i++){
    cnt[x][i] = !!cnt[x][i];
    if(i < val[x])cnt[x][i] = 0;
  }
  cnt[x][val[x]] = 1;
}

int main(){
  cin >> n;
  for(int i = 0;i < n-1;i++){
    cin >> u >> v;u--,v--;
    edge[u].push_back(v);
    edge[v].push_back(u);		   
  }
  solve(0);
  cout << *max_element(val, val + n) << endl;
  return 0;
}

Measured memory_bytes: 32256
#include<iostream>
#include<algorithm>
#define int long long
#define rep(s,i,n) for(int i=s;i<n;i++)
using namespace std;
bool p(int n){
	int sum=0;
	for(int i=2;i<n;i++){
		if(n%i==0){
			sum++;
		}
	}
	if(sum==0){
		return true;
	}
	else{
		return false;
	}
}			
int pr[168];
signed main(){
	int n;
	cin>>n;
	int sum=0;
	int ans=1;
	int n1=n;
	rep(2,i,1000){
		if(p(i)==1){
			pr[sum]=i;
			sum++;	
		}
	}		
	rep(0,i,168){
		sum=1;
	 	n=n1;
		rep(0,j,10){
			sum+=n/pr[i];
			n=n/pr[i];
		}
		ans*=sum;
		ans=ans%1000000007;
	}
	cout<<ans<<endl;
}		


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (int)(n); ++i)
#define rep2(i, s, n) for (int i = (s); i < (int)(n); i++)
using namespace std;
int main() {
  string s;
  cin>>s;
  int n=s.size();
  vector<char>q;
  vector<int>p(n+1);
  int j=0;
  rep(i,s.size()){
    if(s.at(i)!='x'){
      q.push_back(s.at(i));
      j++;
    }
    else{
      p[j]++;
    }
  }
  bool ex=true;
  rep(i,q.size()/2){
    if(q.at(i)!=q.at(q.size()-i-1)){
      ex=false;
    }
  }
  int ans=0;
  if(ex){
    rep(i,(q.size()-1)/2+1){
      ans+=abs(p[i]-p[q.size()-i]);
    }
  }
  if(ex){
    cout<<ans<<endl;
  }
  else{
    cout<<-1<<endl;
  }
}




Measured memory_bytes: 1024
n, k = list(map(int, input().split()))
ans = 0
# while True:
#     n = n // k
#     ans += 1
#     if n == 0:
#         break
# print(ans)


if k == 10:
    ans = len(str(n))
else:
    l = []
    while True:
        n = n // k
        ans += 1
        if n == 0:
            break
print(ans)

Measured memory_bytes: 2940
#include<bits/stdc++.h>
using namespace std;
#define int long long
int n,p[12],a[11]={0,1,2,4,7,12,20,29,38,52,73};
int g[12][12];
signed main(){
	int n;
	cin>>n;
	cout<<180*(n-2);
	return 0;
}

Measured memory_bytes: 3468
while 1 :
	n, m = map(int,raw_input().split(" "))
	if (n, m) == (0,0):
		break
	Lon = [0 for i in range(1000 * n + 1)]
	Lat = [0 for i in range(1000 * m + 1)]
	Lon_sum = [0]
	Lat_sum = [0]
	for i in range(0,n):
		tmp_Lon_sum = [0]
		h = int(raw_input())
		for j in Lon_sum:
			Lon[j+h] += 1
			tmp_Lon_sum.append(j+h) 
		Lon_sum = tmp_Lon_sum
	else :
		Lon_max = Lon_sum[-1]
	for i in range(0,m):
		tmp_Lat_sum = [0]
		w = int(raw_input())
		for j in Lat_sum:
			Lat[j+w] += 1
			tmp_Lat_sum.append(j+w) 
		Lat_sum = tmp_Lat_sum
	else :
		Lat_max = Lat_sum[-1]
	max_width = min(Lon_max,Lat_max)
	print sum([Lon[i]*Lat[i] for i in range(1,max_width+1)])

Measured memory_bytes: 99216
/// Bismillahir Rahmanir Rahim
/* Mohammad Morsalin 
   Dept of ICE, NSTU
*/
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define ll long long
#define pb push_back
#define mp make_pair
#define endl "\n"
#define int long long
#define f0(n) for(int i=0;i<n;i++)
#define ms(x) memset(x,0,sizeof(x))
#define ms2d(x,m,n) memset(x, 0, sizeof(x[0][0]) * m * n)
#define uniq(vec) vec.resize(distance(vec.begin(),unique(vec.begin(),vec.end())))
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
#define pi pair<int,int>
#define tc(t) int t;cin>>t;while(t--)
#define bits(n) __builtin_popcount(n)
#define maxpq priority_queue<int>
#define minpq priority_queue<int, vector<int>, greater<int> >
#define ins insert
#define ALL(v) v.begin(),v.end()
#define highest(x) numeric_limits<x>::max()
#define lowest(x) numeric_limits<x>::min()
#define Inf INFINITY
#define minv(v) *min_element(v.begin(),v.end())
#define maxv(v) *max_element(v.begin(),v.end())
#define fi first
#define se second
#define PI acos(-1)
#define sz(a) (int)a.size();
#define IOS ios::sync_with_stdio(false);
using namespace std;
int gcd(int a, int b) { if (a == 0) return b; return gcd(b % a, a);}
typedef tree<pair<int, int>,null_type,less<pair<int, int>>,rb_tree_tag,tree_order_statistics_node_update> ordered_multiset;
int dx8[] = {0, 0, 1, 1, 1, -1, -1, -1};
int dy8[] = {1,-1, 1, -1, 0, 0, -1, 1};
int dx4[] = {0, 0, 1, -1};
int dy4[] = {1, -1, 0, 0};
const long long MOD = 1000000007;
double sq(double x) {return x*x;}
template<typename T>inline T Bigmod(T base, T power, T MOD){
    T ret=1;
    while(power)
    {
        if(power & 1)ret=(ret*base)%MOD;
        base=(base*base)%MOD;
        power>>=1;
    }
    return ret;
}

bool sortinrev(const pair<int,int> &a,  
               const pair<int,int> &b) 
{ 
       return (a.first > b.first); 
}
signed main()
{
    IOS
    int x;
    cin>>x;
    if(x>=30)cout << "Yes\n";
    else cout << "No\n";
    return 0;
}
///Alhamdulillah


Measured memory_bytes: 3644
#include <stdio.h>

int parent(int);
int left(int);
int right(int);

main(void){
  int a,i,A[260];
    scanf("%d",&a);
    for(i=1;i<=a;i++) {
        scanf("%d",&A[i]);
    }
 
    for(i=1;i<=a;i++) {
        printf("node %d: key = %d, ",i,A[i]);
        if(parent(i)!=0){
	  printf("parent key = %d, ",A[parent(i)]);
	}
        if(left(i)<=a){
	  printf("left key = %d, ",A[left(i)]);
	}
        if(right(i)<=a){
	  printf("right key = %d, ",A[right(i)]);
	}
        printf("\n");
    }
    return 0;
}
 
int parent(int i)
{
  return i/2;
}
int left(int i)
{
  return 2*i;
}
int right(int i)
{
  return 2*i+1;
}

Measured memory_bytes: 604
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

int main() {
  int n;
  cin >> n;
  vector<int> h(n);
  for (int i = 0; i < n; i++) {
    cin >> h[i];
  }

  int max_h = -1;
  int ans = 0;
  for (int i = 0; i < n; i++) {
    if (h[i] >= max_h) {
      max_h = h[i];
      ans++;
    }
  }
  cout << ans << endl;

  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
# define M_PI           3.1415926535
int main()
{
	ios_base::sync_with_stdio(0);
	cin.tie(0);
	cout.tie(0);
	int n;
	cin>>n;
	double x=2*M_PI*n;
	cout<<x;
	return 0;
}

Measured memory_bytes: 3816
#include <algorithm>
#include <iostream>
#include <vector>

using namespace std;

typedef long long ll;

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;
}

ll calc_lcd(ll x, ll y) {
    if (x == 0) {
        return y;
    }
    return calc_lcd(y % x, x);
}

// excluding 1
vector<ll> calc_divs(const ll x) {
    vector<ll> res;
    for (ll i = 1; i * i <= x; i++) {
        if (x % i == 0) {
            res.push_back(i);
            if (i * i != x) {
                res.push_back(x / i);
            }
        }
    }

    sort(res.begin(), res.end());
    return res;
}

int main(void) {
    ll A, B;
    cin >> A >> B;

    ll lcd;
    if (A < B) {
        lcd = calc_lcd(A, B);
    } else {
        lcd = calc_lcd(B, A);
    }

    // cout << "lcd: " << lcd << endl;

    vector<ll> divs = calc_divs(lcd);
    // for (int i = 0; i < (int) divs.size(); i++) {
    //     cout << divs[i] << " ";
    // }
    // cout << endl;

    int count = 1; // for 1
    vector<bool> flag((int) divs.size(), true);
    for (int i = 1; i < (int) flag.size(); i++) {
        if (flag[i]) {
            count++;
        }
        for (int j = i + 1; j < (int) flag.size(); j++) {
            if (divs[j] % divs[i] == 0) {
                flag[j] = false;
            }
        }
    }

    cout << count << endl;

    return 0;
}


Measured memory_bytes: 384
#include <stdio.h>

int main()
{
  int n, a, b;
  int min;
  
  scanf("%d %d %d",&n,&a,&b);
  
  min=n*a;
  
  if(min>b)
    min=b;
  
  printf("%d\n",min);
  
  return 0;
}

Measured memory_bytes: 1736
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    N=int(input())
    K=int(input())

    X=list(map(int,input().split()))

    cnt=0
    for i in X:
        cnt+=min(2*i,2*abs(K-i))

    print(cnt)

resolve()

Measured memory_bytes: 38384
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx")
#pragma GCC optimize("unroll-loops")
//#pragma warning(disable : 4996)

#define ATCODER
#ifdef ATCODER
#include<atcoder/all>
using namespace atcoder;
#endif

#include <algorithm>
#include <utility>
#include <vector>

#ifdef _MSC_VER
#include <intrin.h>
#define __builtin_popcount __popcnt
#define __builtin_popcountll __popcnt64

#endif

#include <limits.h>
#include <math.h>
#include <time.h>

#include <algorithm>
#include <array>
#include <bitset>
#include <cassert>
#include <complex>
#include <cstdio>
#include <cstring>
#include <functional>
#include <iomanip>
#include <iostream>
#include <iterator>
#include <map>
#include <numeric>
#include <queue>
#include <random>
#include <set>
#include <stack>
#include <string>
#include <unordered_map>
#include <unordered_set>
#include <vector>

using namespace std;

#define REP(i, n) for (int i = 0; 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 FORR(i, m, n) for (int i = m - 1; i >= n; --i)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define REVERSE(v, n) reverse(v, v + n);
#define VREVERSE(v) reverse(v.begin(), v.end())
#define ll long long
#define print(x) cout << (x) << '\n'
#define pe(x) cout << (x) << " "
#define DEBUG(x) cout << #x << ": " << x << endl
#define lb(v, n) lower_bound(v.begin(), v.end(), (n))
#define ub(v, n) upper_bound(v.begin(), v.end(), (n))
#define int long long
//#define double long double
#define all(x) (x).begin(), (x).end()
#define print_space(v) REP(i, v.size()) cout << v[i] << " \n"[i==(int)v.size()-1]
template <typename T1, typename T2> inline void chmin(T1 & a, T2 b) { if (a > b) a = b; }
template <typename T1, typename T2> inline void chmax(T1& a, T2 b) { if (a < b) a = b; }
typedef pair<int, int> pii;
typedef pair<long long, long long> pll;
std::random_device rd;
std::mt19937 mt(rd());
constexpr ll MOD = 998244353;
constexpr int MAX = 4400000;
const double pi = acos(-1);
constexpr double EPS = 1e-8;
constexpr ll LINF = 1e17 + 1;
constexpr int INF = 1e9 + 1;
using S = long long;
using F = long long;

//const S INF = 8e18;
const F ID = 8e18;

S op(S a, S b) { return std::max(a, b); }
S e() { return -INF; }
S mapping(F f, S x) { return max(f, x); }
F composition(F f, F g) { return max(f,g); }
F id() { return -INF; }


int MX = 300000;
void solve() {
	int N, K; cin >> N >> K;
	vector<S>v(300060, 0);
	vector<int>A(N);
	REP(i, N)cin >> A[i];
	//REP(i, N)cin >> A[i];
	atcoder::lazy_segtree<S, op, e, F, mapping, composition, id> seg(v);
	REP(i, N) {
		seg.apply(A[i], 0);
		int r = min(MX + 1, A[i] + K + 1);
		int l = max(0LL, A[i] - K);
		seg.apply(l, r, seg.get(A[i]) + 1);

	}
	print(seg.all_prod());
}



signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	//int q;
	//cin >> q;
	//while (q--)
	solve();

}


Measured memory_bytes: 20428
import java.util.Scanner;

public class Main {

    private static Scanner scan = new Scanner(System.in);

    public static void main(String[] args) {
	int N = Integer.parseInt(scan.next());
	long A = Long.parseLong(scan.next());
	long B = Long.parseLong(scan.next());

	long[] X = new long[N];
	for (int i = 0; i < N; i++) {
	    X[i] = Long.parseLong(scan.next());
	}

	int rest = N-1;
	long cost = 0;
	for (int i = 1; i < N; i++) {
	    long tmp = (X[i]-X[i-1]) * A;
	    if(tmp < B) {
		rest--;
		cost += tmp;
	    }
	}
	cost = cost + rest * B;

	System.out.println(cost);
	scan.close();
    }
}


Measured memory_bytes: 47428
S = int(input())

X1 = 0
Y1 = 0

tmp = int(S**0.5)
if tmp**2 >= S:
    X2 = Y3 = tmp
else:
    X2 = Y3 = tmp+1

rest = X2**2 - S

if rest == 0:
    X3 = Y2 = 0
else:
    if rest < 10**9:
        X3 = 1
        Y2 = rest
    else:
        for i in range(2, int(rest**0.5)+2):
            if rest % i == 0:
                X3 = i
                Y2 = rest // i

print(X1, Y1, X2, Y2, X3, Y3)

Measured memory_bytes: 3064
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <tuple>
#include <numeric>
#include <functional>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vector<ll>> vvl;
typedef pair<ll, ll> P;
#define rep(i, n) for(ll i = 0; i < n; i++)
#define exrep(i, a, b) for(ll i = a; i <= b; i++)
#define out(x) cout << x << endl
#define exout(x) printf("%.10f\n", x)
#define chmax(x, y) x = max(x, y)
#define chmin(x, y) x = min(x, y)
#define all(a) a.begin(), a.end()
#define rall(a) a.rbegin(), a.rend()
#define pb push_back
#define re0 return 0
const ll mod = 1000000007;
const ll INF = 1e16;
const ll MAX_N = 100010;
 
ll gcd(ll x, ll y) {
    if(y == 0) {
        return x;
    }
    return gcd(y, x%y);
}
 
int main() {
    ll n;
    cin >> n;
 
    vl a(n);
    rep(i, n) {
        cin >> a[i];
    }
    
    vl L(n-1);  // L[i] : a[0]からa[i]までのGCD
    L[0] = a[0];
    exrep(i, 1, n-2) {
        L[i] = gcd(L[i-1], a[i]);
    }
 
    vl R(n-1);  // R[i] : a[n-1]からa[(n-1) - i]までのGCD
    R[0] = a[n-1];
    exrep(i, 1, n-2) {
        R[i] = gcd(R[i-1], a[(n-1) - i]);
    }
 
    ll ans = max(L[n-2], R[n-2]);
    exrep(i, 1, n-2) {
        chmax(ans, gcd(L[i-1], R[(n-2) - i]));
    }
 
    out(ans);
    re0;
}

Measured memory_bytes: 2560
import itertools
import bisect
N, M, K = map(int,input().split())
al = list(map(int,input().split()))
bl = list(map(int,input().split()))

als = list(itertools.accumulate(al))
als.insert(0,0)
bls = list(itertools.accumulate(bl))
bls.insert(0,0)
# print(als)
# print(bls)

ans = 0
for i in range(N+1):
    nokori = K - als[i]
    if nokori >= 0:
        index = bisect.bisect_right(bls,nokori)
        if index > 0:
            index -= 1
        tmp = i + index
        #print(i,index)
        if tmp > ans:
            ans = tmp
print(ans)



Measured memory_bytes: 47572
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
signed main(){
  ll a,n;
  cin >> n;
  for(int i=1;i<=9;i++){
    if(n%i==0){
      a = n/i;
      if(a<10){
        cout <<"Yes\n";
        return 0;
      }
    }
  }
  cout <<"No\n";
}


Measured memory_bytes: 256
# -*- coding: utf-8 -*-
"""
http://judge.u-aizu.ac.jp/onlinejudge/description.jsp?id=0174

"""
import sys
from sys import stdin
input = stdin.readline


def main(args):

    while True:
        data = input().strip()
        if data[0] == '0':
            break

        data = data[1:]
        score_A = data.count('A')
        score_B = data.count('B')

        if score_A > score_B:
            score_A += 1
        else:
            score_B += 1
        print('{} {}'.format(score_A, score_B))



if __name__ == '__main__':
    main(sys.argv[1:])
    

Measured memory_bytes: 7436
from collections import deque
def resolve():
    N, M = map(int, input().split())
    G = [[] for _ in range(N)]
    for _ in range(M):
        x, y = map(lambda x:int(x)-1, input().split())
        G[x].append(y)
        G[y].append(x)

    dist = [-1]*N
    ans = [0]*N
    q = deque()
    q.append(0)
    while q:
        fm = q.popleft()
        for to in G[fm]:
            if dist[to] != -1:
                continue
            dist[to] += 1
            ans[to] = fm
            q.append(to)

    print("Yes")
    for i in range(1, N):
        print(ans[i] + 1)
        
if __name__ == "__main__":
    resolve()

Measured memory_bytes: 34728
#include <bits/stdc++.h>
#define bug1(x) cout<<#x<<" = "<<x<<endl
#define bug2(x,y) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<endl
#define bug3(x,y,z) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<endl
#define bug4(x,y,z,m) cout<<#x<<" = "<<x<<" "<<#y<<" = "<<y<<" "<<#z<<" = "<<z<<" "<<#m<<" = "<<m<<endl

using namespace std;

template<class T> 
ostream& operator<<(ostream &os, vector<T> input) {
    os << "[ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "]";
}

template<class T> 
ostream& operator<<(ostream &os, set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_set<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class T> 
ostream& operator<<(ostream &os, unordered_multiset<T> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << elem << " ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

template<class L, class R> 
ostream& operator<<(ostream &os, unordered_map<L,R> input) {
    os << "{ ";
    for(auto elem : input) { 
		os << "(" << elem.first << "," << elem.second << ") ";
	}
	return os << "}";
}

#define ll long long
const int MAXN = 500005;
const int INF = 1e9;
const int MOD = 1e9 + 7;

class TaskD {
private:
	vector<vector<int>> memo;
	int rec(int len, int sum) {
		if(sum < 0) {
			return 0;
		}
		if(len == 0) {
			return sum == 0;
		}
		int &ans = memo[len][sum];
		if(ans != -1) {
			return ans;
		}
		ans = rec(len, sum-1);
		ans += rec(len-1, sum);
		ans %= MOD;
		return ans;
	}

public:
	void solveOne(int it){
		int sum;
		cin >> sum;
		int ans = 0;
		memo.assign(sum+1, vector<int>(sum+1, -1));
		for(int len = 1; 3*len <= sum; len++) {
			ans += rec(len, sum - 3*len);
			ans %= MOD;
		}
		cout << ans << endl;
	}

	void solve(){
		int tc = 1;
		for(int it = 1; it <= tc; it++){
			solveOne(it);
		}
	}
};


int main(){
	ios_base::sync_with_stdio(false);
	TaskD solver;
	solver.solve();
	return 0;
}


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

int main(){ 
    int n;
    cin >> n;
    int w[n];
    int t = 0;
    int s1 = 0;
    int s2 = 0;
    int ans = 100000000;
    for(int i=0;i<n;i++){
        cin >> w[i];
    }
    while(t!=n){
        for(int i=0;i<n;i++){
            if(i<=t){
                s1 += w[i];
            }
            else{
                s2 += w[i];
            }
        }
        if(ans > abs(s1-s2)){
            ans = abs(s1-s2);
        }
        t++;
        s1 = 0;
        s2 = 0;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 256
import math

a, b, x = list(map(int, input().split()))

x /= a

if a * b / 2 < x:
	# tetragon
	k = 2 * x / a - b
	print(math.degrees(math.atan((b - k) / a)))

else:
	# triangle
	tan_a = b ** 2 / (2 * x)
	print(math.degrees(math.atan(tan_a)))

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

using namespace std;

const int N = 1e5 + 100;

void enter()
{
    freopen("solve.inp","r",stdin);
    freopen("solve.out","w",stdout);
}
const long long oo = 1e18;
long long IT[N * 4];
long long lazy[N * 4];

void cn(int i, int L, int R) {
    if (lazy[i] == 0) return;
    IT[i] = 1LL * (R - L + 1) * lazy[i];
    if (L != R) {
        lazy[i << 1] = lazy[i];
        lazy[i << 1 | 1] = lazy[i];
    }
    lazy[i] = 0;
}
void update(int i, int L, int R, int u, int v, long long val) { ///a[u -> v] = val
    cn(i, L, R);
    if (L > v || R < u) return;
    if (L >= u && R <= v) {
        lazy[i] = val;
        cn(i, L, R);
        return;
    }
    int mid = (L + R) >> 1;
    update(i << 1, L, mid, u, v, val);
    update(i << 1 | 1, mid + 1, R, u, v, val);
    IT[i] = IT[i << 1] + IT[i << 1 | 1];
}
long long Get(int i, int L, int R, int u, int v) {
    cn(i, L, R);
    if (L > v || R < u) return 0;
    if (L >= u && R <= v) return IT[i];
    int mid = (L + R) >> 1;
    long long Left = Get(i << 1, L, mid, u, v);
    long long Right = Get(i << 1 | 1, mid + 1, R, u, v);
    return Left + Right;
}
void solve()
{
    int n, Q;
    cin >> n >> Q;
    while (Q--) {
        int r;
      	long long Pi;
        cin >> r >> Pi;
        int L = 1;
        int R = r;
        int H = r;
        while (L <= R) {
            int mid = (L + R) >> 1;
            long long KC = Get(1, 1, n, mid, r);
            long long Cao = Get(1, 1, n, mid, mid);
            if ((Cao * (r - mid + 1) - KC) <= Pi) {
                R = mid - 1;
                H = mid;
            }
            else L = mid + 1;
        }
        long long Cao = Get(1, 1, n, H, H);
        long long SL = Get(1, 1, n, H, r);
        Pi -= Cao * (r - H + 1) - SL;
        long long newH = Cao + (Pi / (r - H + 1));
        long long Thua = Pi % (r - H + 1);
        update(1, 1, n, H, r, newH);
        update(1, 1, n, H, H + Thua - 1, newH + 1);
        //cout << Get(1, 1, n, 2, 2).sum << '\n';
//        for (int i = 1; i <= n; i++) cout << Get(1, 1, n, i, i).sum << ' ';
//        cout << '\n';
    }
    for (int i = 1; i <= n; i++) cout << Get(1, 1, n, i, i) << '\n';
}
int main()
{
    ios_base::sync_with_stdio(0); cin.tie(nullptr); cout.tie(nullptr);
    //enter();
    solve();
}


Measured memory_bytes: 7808
n,k=map(int,input().split())
A=[int(i) for i in input().split()]


def f(i):
    if i<=0: return False
    if i>= 10**9: return True
    x = sum([(a-1)//i for a in A])
    if x<=k:
        return True
    else:
        return False
l=-1
r=10**9
while r-l>1:
    m = (l+r)//2
    if f(m):
        r=m
    else:
        l=m
    #print(l,m,r)
print(r)

Measured memory_bytes: 167980
#include<bits/stdc++.h>
#define INF (1e9)
#define N 105
using namespace std;
typedef pair<int,int> P;
typedef pair<int,P> P1;
int n,m,C,f,t,c;
vector<P> G[N];

int dijkstra(){
  int d[N][N];
  for(int i=0;i<n;i++)
    for(int j=0;j<n;j++)
      d[i][j]=INF;
  priority_queue<P1,vector<P1>,greater<P1> > q;
  d[0][0]=0;
  q.push(P1(0,P(0,0)));
  while(!q.empty()){
    P1 a=q.top(); q.pop();
    int cost=a.first;
    int cnt=a.second.first;
    int node=a.second.second;
    if(d[cnt][node]<cost)continue;
    for(int i=0;i<G[node].size();i++){
      int nnode=G[node][i].first;
      int ncost=cost+G[node][i].second;
      if(d[cnt][nnode]>ncost){
	d[cnt][nnode]=ncost;
	q.push(P1(ncost,P(cnt,nnode)));
      }
      if(cnt<n&&d[cnt+1][nnode]>cost){
	d[cnt+1][nnode]=cost;
	q.push(P1(cost,P(cnt+1,nnode)));
      }
    }
  }
  for(int i=0;i<=n;i++)
    if(C>=d[i][n-1])return i;
}

int main(){
  while(1){
    cin>>n>>m>>C;
    if(!n&&!m&&!C)break;
    for(int i=0;i<m;i++){
      cin>>f>>t>>c;
      f--,t--;
      G[f].push_back(P(t,c));
    }
    cout<<dijkstra()<<endl;
    for(int i=0;i<n;i++)G[i].clear();
  }
  return 0;
}

Measured memory_bytes: 3068
#include <bits/stdc++.h>
#include <vector>
#include <iostream>
#include<algorithm>
#include<string>
#include <map>
#include <queue>
#include <stack>
#include<set>

#define DIV 1000000007

using namespace std;
using ll = long long;
using ldb = long double;

int main() {
    vector<int> cnt(1e5 + 1);
    for (int i = 3; i <= 1e5; i++) {
        cnt[i] = cnt[i - 1];
        if (i % 2 == 0) continue;
        bool flag = true;
        int temp = i;
        for (int j = 2; j <= sqrt(temp); j++) {
            if (temp % j == 0) {
                flag = false;
                break;
            }
        }
        temp = (i + 1) / 2;
        for (int j = 2; j <= sqrt(temp); j++) {
            if (temp % j == 0) {
                flag = false;
                break;
            }
        }
        if (flag) cnt[i]++;
    }
    /*
    for (int i = 1; i <= 100; i++) {
        printf("cnt[%d]=%d\n", i, cnt[i]);
    }
    */
    int Q; cin >> Q;
    for (int i = 0; i < Q; i++) {
        int l, r; cin >> l >> r;
        cout << cnt[r] - cnt[l - 1] << endl;
        
    }

}


Measured memory_bytes: 1024
#include<iostream>
#include<set>
using namespace std;
int main(){
  int n;
  cin>>n;
  set<int> a;
  int g;
  for(int i=0;i<n;i++){
    cin>>g;
    a.insert(g);
  }
  cout<<a.size()<<endl;
  return 0;
}

Measured memory_bytes: 256
import java.util.*;
class Main
{
  public static void main(String[] args) {
    
    Scanner scan =new Scanner(System.in);
    int n = scan.nextInt();
   	String[] str = new String[n];
       int count = 0 ;
    ArrayList<String> st = new ArrayList<String>();
      for(int i = 0 ; i<n ; i++){
      str[i] = scan.next();
        if(st.contains(str[i])){
        count++;
        break;
      }else{
        st.add(str[i]);
      }
    }
    
 	if(count==0){
      for(int i = 0 ; i<n-1 ; i++){

        if(str[i].charAt(str[i].length()-1) != str[i+1].charAt(0)){
          count++;
          break;
        } 
      }
    }
    if(count!=0){
      System.out.println("No");
    }else{
      
      System.out.println("Yes");
    }
  }
}


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

int main()
{
  int n, k, q;
  cin >> n >> k >> q;
  vector<int> h(n, k - q), a(q);

  for (int i = 0; i < q; i++) {
    int t;
    cin >> t;
    t--;
    h[t]++;
  }

  for (auto&& e : h) {
    cout << (e > 0 ? "Yes" : "No") << endl;
  }
}


Measured memory_bytes: 1408
#include <bits/stdc++.h>
using namespace std;
#define pi 3.14159265359
#define int long long
#define pii pair<int,int>
#define ld long double
const int mod=1e9 + 7;
 
int dx[]={-1, 0, 1, 0};
int dy[]={0, -1, 0, 1};
 
 
 
 
int32_t main()
{
ios::sync_with_stdio(false);
cin.tie(0);
cout.tie(0);
 


    int a,b;
    cin>>a>>b;

    cout<<6-a-b<<"\n";
}

Measured memory_bytes: 256