akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cstdio>
#include <string>
#include <sstream>
#include <algorithm>
#include <cmath>
#include <vector>
#include <set>
#include <map>
#include <queue>
using namespace std;

int main() {
    // 標準入力
    long long N, M;
    cin >> N >> M;
    
    long long ans=0;
    if (N>1&&M>1) {
        ans=(N-2)*(M-2);
    }
    else if (N==1&&M>1){
        ans=M-2;
    }
    else if (N>1&&M==1){
        ans=N-2;
    }
    else{
        ans=1;
    }
    
    cout << ans << endl;
}


Measured memory_bytes: 256
#include <algorithm>
#include <cmath>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; (i) < (n); (i)++)
#define FOR(i, m, n) for(int i = (m); (i) < (n); (i)++)
#define All(v) (v).begin(), (v).end()
#define MP make_pair
#define pb push_back
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1 << 30;
const ll LINF = 1LL << 61;
const int MOD = 1e9 + 7;

int main() {
    int N;
    cin >> N;
    vector<ll> A(N), B(N);
    rep(i, N) { cin >> A[i]; }
    rep(i, N) cin >> B[i];
    vector<ll> Asum(N + 1), Bsum(N + 1);
    rep(i, N) Asum[i + 1] = Asum[i] + A[i];
    rep(i, N) Bsum[i + 1] = Bsum[i] + B[i];
    ll res = 0;
    for(int i = 0; i < N; i++) {
        res = max(Asum[i + 1] + (Bsum[N] - Bsum[i]), res);
    }
    cout << res << endl;
    return 0;
}

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

typedef pair<int, int> pii;
typedef long long ll;
typedef vector<int> vi;

#define pb push_back
#define eb emplace_back
#define mp make_pair
#define fi first
#define se second
#define rep(i,n) rep2(i,0,n)
#define rep2(i,m,n) for(int i=m;i<(n);i++)
#define ALL(c) (c).begin(),(c).end()

class unionfind {
	vector<int> par, rank;

public:
	void init(int n) {
		par.resize(n);
		rank.resize(n);

		for (int i = 0; i < n; i++) {
			par[i] = i;
			rank[i] = 0;
		}
	}

	int find(int x) {
		if (par[x] == x) return x;
		else return par[x] = find(par[x]);
	}

	void unite(int x, int y) {
		x = find(x);
		y = find(y);
		if (x == y) return ;

		if (rank[x] < rank[y]) par[x] = y;
		else {
			par[y] = x;
			if (rank[x] == rank[y]) ++rank[x];
		}
	}

	bool same(int x, int y) { return (find(x) == find(y)); }
} uf;

const int MN = 200010;

int N, Q;
ll ret;
int mini[MN * 2];

int main() {
	cin >> N >> Q;
	uf.init(N);

	using Edge = pair<int, pii>;
	priority_queue<Edge, vector<Edge>, greater<Edge>> que;

	rep(i, MN * 2) {
		mini[i] = 1 << 30;
	}

	rep(i, Q) {
		int A, B, C;
		cin >> A >> B >> C;
		que.push(mp(C, mp(A, B)));

		mini[A] = min(mini[A], C+1);
		mini[B] = min(mini[B], C+2);
		mini[A+N] = min(mini[A+N], mini[A]);
		mini[B+N] = min(mini[B+N], mini[B]);		
	}

	rep(i, N * 2) {
		mini[i+1] = min(mini[i+1], mini[i] + 2);
	}

	rep(i, N) {
		que.push(mp(min(mini[i], mini[i+N]), mp(i, i+1)));
	}

	while (!que.empty()) {
		Edge e = que.top(); que.pop();
		int u = e.se.fi, v = e.se.se;

		if (!uf.same(u, v)) {
			ret += e.fi;
			uf.unite(u, v);
		}
	}

	cout << ret << endl;

	return 0;
}

Measured memory_bytes: 11504
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
const ll INF = 1e18;
const int inf = 1e9;
double pi = 3.14159265359;
#define rep(i, a, b) for (int i = a; i < b; i++)
#define per(i, b, a) for (int i = a - 1; i >= b; i--)
using Graph = vector<vector<int>>;
using pint = pair<int, int>;
int dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1};
int dxx[8] = {1, 1, 1, 0, 0, -1, -1, -1}, dyy[8] = {-1, 0, 1, -1, 1, -1, 0, 1};

int main() {
    int n;
    cin >> n;
    int a[n];
    rep (i, 0, n) cin >> a[i];
    int r = 0;
    int sum = 0;
    ll ans = 0;
    rep (l, 0, n) {
        while (r < n && (sum ^ a[r]) == (sum + a[r])) {
            sum += a[r++];
        }
        // cout << r << "\n";
        ans += (ll) (r - l);
        if (r == l) {
            r++;
            continue;
        }
        sum ^= a[l];
    }

    cout << ans << "\n";
}

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

using namespace std;

typedef long long int 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; }

typedef pair<int,int> pair;

int main(){
    int n,m;
    cin >> n >> m;
    n-=m;
    if(n==0){
        puts("Yes");
    }else{
        puts("No");
    }
}

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

int main() {
	//ios_base::sync_with_stdio(false);
    string s,g,w;
    int n;
    cin>>n;
    cin>>s>>g>>w;
    int ans=0;
    for(int i=0;i<n;i++){
        if(s[i]==g[i]&&w[i]==g[i]){
            ans+=0;
        }
        else if(s[i]==g[i]){
            ans++;
        }
        else if(w[i]==g[i]){
            ans++;
        }
        else if(s[i]==w[i]){
            ans++;
        }
        else{
            ans+=2;
        }
    }
    cout<<ans;
	return 0;
}

Measured memory_bytes: 256
K, S = input().strip().split()
K, S = int(K), int(S)

NUMS = list(range(K+1))

sums = {}

count = 0

for x in NUMS:
  for y in NUMS:
    if x+y not in sums:
      sums[x+y] = 0
    sums[x+y] += 1
for k, v in sums.items():
  z = S - k
  if z in NUMS:
    count += v
print(count)

Measured memory_bytes: 43440
using System;

namespace ABC054_C___One_Stroke_Path
{
    class Program
    {
        static void Main(string[] args)
        {
            var NM = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
            var N = NM[0];
            var M = NM[1];

            var joint = new bool[N, N];
            for (int i = 0; i < N; i++) for (int j = 0; j < N; j++) joint[i, j] = false;
            for (int i = 0; i < M; i++)
            {
                var ab = Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
                joint[ab[0] - 1, ab[1] - 1] = true;
                joint[ab[1] - 1, ab[0] - 1] = true;
            }

            var dp = new int[1 << N, N];
            for (int i = 0; i < dp.GetLength(0); i++) for (int j = 0; j < dp.GetLength(1); j++) dp[i, j] = 0;
            for (int i = 0; i < N; i++) dp[1 << i, i] = 1;

            for (int bit = 1; bit < dp.GetLength(0); bit++)
                for (int last = 0; last < dp.GetLength(1); last++)
                {
                    if ((bit & (1 << last)) == 0) continue;
                    for (int prev = 0; prev < dp.GetLength(1); prev++)
                    {
                        if (((bit - (1 << last)) & (1 << prev)) > 0)
                            if (joint[last, prev])
                                dp[bit, last] += dp[bit - (1 << last), prev];
                    }
                }

            Console.WriteLine(dp[dp.GetLength(0) - 1, 0]);


        }
    }
}


Measured memory_bytes: 13268
//ProblemC

#ifdef _MYPC
#include "mypc.h"
#endif // _MYPC

#include <iostream>
#include <string>
#include <vector>
#include <bitset>
#include <list>
#include <map>
#include <set>
#include <unordered_map>
#include <unordered_set>
#include <queue>
#include <stack>
#include <algorithm>
#include <numeric>
#include <functional>
#include <memory>
#include <complex>
#include <cstdio>
#include <cstring>
#include <cmath>

using namespace std;

//ProblemC

class Solve {
private:

	int calc(int a, int dst) {
		if (a == dst) return 0;
		else if (a > dst) return  a - dst;
		else {
			return (dst - a) % 2 ? (dst - a) / 2 + 2 : (dst - a) / 2;
		}
	}

	void solve() {
		int a, b, c;
		cin >> a >> b >> c;

		int minv = min({ a, b, c });
		int maxv = max({ a, b, c });

		int rst = 500;
		for (int i = minv; i <= maxv + 2; i++) {
			int t = calc(a, i) + calc(b, i) + calc(c, i);
			rst = min(t, rst);
		}
		cout << rst << endl;
	}

public:
	Solve() { solve(); }
};

int main(int argc, char* argv[]) {
	unique_ptr<Solve> solve = make_unique<Solve>();
	return 0;
}


Measured memory_bytes: 256
/// Code By t_bone_289 (Tushar Singh)
/// An Immature Programmer.... I'm still developing !!
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/trie_policy.hpp>
using namespace std;
using namespace __gnu_pbds;
#define pll pair<ll,ll>
#define fi first
#define se second
#define mp make_pair
#define pb emplace_back
#define endl '\n'
#define M 1000000007
#define error(x) cout << #x << " = " << x << endl;
#define pi 3.14159265358979323846
typedef long long ll;
typedef long double ld;
template <typename T>
void ContainerError(T &v){cout<<"{";for(auto &x:v){cout<<x<<',';}cout<<"}"<<endl;return;}
typedef tree<ll,null_type,less<ll>,rb_tree_tag,tree_order_statistics_node_update> ordered_set;
ll powmod(ll base,ll exp,ll MOD){ll res=1;while(exp>0){if(exp%2==1) res=(res*base)%MOD;base=(base*base)%MOD;exp/=2;}return (res%MOD);}
ll mpow(ll base,ll exp){ll res=1;while(exp>0){if(exp%2==1) res=(res*base);base=(base*base);exp/=2;}return (res);}
ll gcd(ll a, ll b){return b?gcd(b,a%b):a;}
ll h,w;
ll count(ll i1,ll j1,ll i2,ll j2,map<pll,bool> &m)
{
	if(i1>0 && i1<=h && i2>0 && i2<=h && j1>0 && j1<=w && j2>0 && j2<=w){
	ll cc = 0;
	for(ll i=i1;i<=i2;i++)
	{
		for(ll j=j1;j<=j2;j++)
		{
			pll p = {i,j};
			if(m.find(p)!=m.end())cc++;
		}
	}
	return cc;}
	return -1;
}
int main()
{
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
 //   ll h,w,n;
 	ll n;
    cin>>h>>w>>n;
    std::vector<pll> v(n);
    map<pll,bool> m;
    for(auto &x:v)
    {
    	cin>>x.fi>>x.se;m[x]=1;
    }
    map<pair<pll,pll>,ll> mm;
    for(ll i = 0;i < n; i++)
    {
    	ll x = v[i].fi;
    	ll y = v[i].se;
    	for(ll dx = -2;dx<=0;dx++)
    	{
    		for(ll dy=-2;dy<=0;dy++)
    		{
    			ll i1 = x+dx;
    			ll j1 = y+dy;
    			ll i2 = i1+2;
    			ll j2 = j1+2;
    			pair<pll,pll> p = {{i1,j1},{i2,j2}};
    			if(mm.find(p)!=mm.end()){continue;}
    			ll cc = count(i1,j1,i2,j2,m);
    			if(cc!=-1)mm[p]=cc;
    		}
    	}
    }
    std::vector<ll> ans(10,0);
    ans[0] = (h-2)*(w-2)-(ll)mm.size();
    for(auto p:mm)
    {
    	ans[p.se]++;
    }
    for(ll i=0;i<10;i++)
    {
    	cout<<ans[i]<<endl;
    }
    return 0;
}
/**

22200
22200
22100
00000
00000

**/

Measured memory_bytes: 78336
s=input()
sento=2000000
matubi=0

for i in range(len(s)):
  if s[i] == "A":
    sento=min(i,sento)
for i in range(len(s)):
  if s[i] == "Z" and i > sento:
    matubi=max(i,matubi)
print(matubi-sento+1)

Measured memory_bytes: 3516
def gcd(A,B):
    deka = max(A,B)
    mini = min(A,B)
    
    while not deka % mini == 0:       
        yo = deka % mini
        deka = mini
        mini = yo
    return mini


DATA = input()

N,X = DATA.split()
N = int(N)
X = int(X)

DATA = input()
x = DATA.split()

x[0] = int(x[0])
num = abs(X-x[0])

for lop in range(1,N):
    x[lop] = int(x[lop])
    sa = abs(X-x[lop])
    num = gcd(num,sa)
print(num)

Measured memory_bytes: 11484
#include <functional>
#include <algorithm>
#include <iostream>
#include <numeric>
#include <iomanip>
#include <utility>
#include <cstdlib>
#include <sstream>
#include <bitset>
#include <vector>
#include <cstdio>
#include <ctime>
#include <queue>
#include <deque>
#include <cmath>
#include <stack>
#include <list>
#include <map>
#include <set>

using namespace std;

typedef vector<int> vi;
typedef pair<int,int> pii;
typedef long long ll;

#define dump(x)  cerr << #x << " = " << (x) << endl
#define rep(i,n) for(int i=0;i<(n);i++)
#define all(a)  (a).begin(),(a).end()
#define pb push_back

int main() {
    string s;
    cin>>s;
    int k,u,p,c;
    k=u=p=c=0;
    
    rep(i,s.size()){
        if(s[i]=='K')k++;
        if(s[i]=='U')u++;
        if(s[i]=='P')p++;
        if(s[i]=='C')c++;
    }
    cout<<min(k,min(u,min(p,c)))<<endl;
    
    return 0;
}

Measured memory_bytes: 1188
import java.util.Scanner;

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

		// 入力値の取得
		int R = sc.nextInt();
		
		// 結果の出力
		System.out.println(2 * Math.PI * R);

		sc.close();
	}
}


Measured memory_bytes: 27160
/*
 Author: LargeDumpling
 Email: LargeDumpling@qq.com
 Edit History:
	2017-07-23	File created.
*/

#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<algorithm>
using namespace std;
int gcd(int m,int n)
{
	int t;
	while(n)
	{
		t=m%n;
		m=n;
		n=t;
	}
	return m;
}
int n,k,num[100050],a_gcd,a_max;
int main()
{
	//freopen("code.in","r",stdin);
	//freopen("code.out","w",stdout);
	bool flag=false;
	scanf("%d%d",&n,&k);
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&num[i]);
		if(i==1) a_gcd=a_max=num[i];
		else
		{
			a_gcd=gcd(a_gcd,num[i]);
			a_max=max(a_max,num[i]);
		}
	}
	if(a_max<k) puts("IMPOSSIBLE");
	else
	{
		for(int i=1;i<=n&&!flag;i++)
			if(k<=num[i]&&(!((num[i]-k)%a_gcd)))
				flag=true;
		if(flag) puts("POSSIBLE");
		else puts("IMPOSSIBLE");
	}
	fclose(stdin);
	fclose(stdout);
	return 0;
}


Measured memory_bytes: 640
n=int(input())
h=list(map(int,input().split()))
l=[0]
c='plus'
for i in range(n-1):
    if c=='minus' and h[i]<=h[i+1]:
        l.append(i)
    if h[i]<=h[i+1]:c='plus'
    else:c='minus'

w=0
m=0
for i in range(len(l)-1):
    w+=max(h[l[i]:l[i+1]+1])-m
    m=h[l[i+1]]
w+=max(h[l[-1]:n])-m
print(w)

Measured memory_bytes: 3064
import java.util.Scanner;

public class Main {
	public static void main(String[] args) throws Exception {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		int[] h = new int[n];
		for (int i = 0; i < n; i++) {
			h[i] = sc.nextInt();
		}
		sc.close();

		int ans = 0;
		int cnt = 0;
		for (int i = 1; i < n; i++) {
			if (h[i - 1] >= h[i]) {
				cnt++;
				ans = Math.max(ans, cnt);
			} else {
				cnt = 0;
			}
		}
		System.out.println(ans);
	}
}


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

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

int main(void)
{
    char c; cin>>c;
    string v = "aeiou";
    if(v.find(c)!=string::npos) cout<<"vowel"<<endl;
    else cout<<"consonant"<<endl;
    return 0;
} 

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long int ll;
#define mod 1000000007
#define all(v)  v.begin(),v.end()
#define pb push_back
ll power(ll a,ll x){if(x==0) return 1;ll y=power(a,x/2);ll ans=(y*y)%mod; if(x%2) ans=(ans*a)%mod;return ans;}
ll inv(ll a){return power(a,mod-2);}

#define N 100005
vector< pair<ll,ll> > adj[N];
ll color[N];
 int main(){

 ios_base:: sync_with_stdio(false); cin.tie(NULL);cout.tie(NULL);
  
 ll n;
 cin>>n;
 for(int i=1;i<n;i++){
    ll u,v,w;
    cin>>u>>v>>w;
    adj[u].pb({v,w});
    adj[v].pb({u,w});
 } 

 queue<ll> q;
 ll vis[n+1];
 for(int i=1;i<=n;i++) vis[i]=-1;
 vis[1]=0;
 color[1]=0;
 q.push(1);
 while(!q.empty()){
    ll k=q.front();
    ll u=k;
    q.pop();
    for(auto i: adj[u]){
        ll v=i.first;
        ll w=i.second;
        if(vis[v]==-1){
          vis[v]=vis[u]+w;
          if(w%2==0){color[v]=color[u];}
          else color[v]=1-color[u];
          q.push(v);
      }  
    }
 }

 for(int i=1;i<=n;i++){
 //  cout<<vis[i]<<endl;
   cout<<color[i]<<endl;
 }


}

Measured memory_bytes: 9472
#include <bits/stdc++.h>
#define MOD 1000000007LL
using namespace std;
typedef long long ll;
typedef pair<int,int> P;

int n;
int a[1005];

int main(void){
	scanf("%d",&n);
	for(int i=0;i<n;i++){
		scanf("%d",&a[i]);
	}
	bool flag=true;
	for(int i=0;i<n;i++){
		if(a[i]%2==0){
			if(a[i]%3!=0 && a[i]%5!=0){
				flag=false;
			}
		}
	}
	printf("%s\n",flag?"APPROVED":"DENIED");
	return 0;
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
long long mod=1e9+7;

int main(){
  string s;
  cin>>s;
  if((s.size()%2==1&&s[0]!=s[s.size()-1])||(s.size()%2==0&&s[0]==s[s.size()-1])){
    cout<<"First"<<endl;
  }else{
    cout<<"Second"<<endl;
  }
}


Measured memory_bytes: 512
#include<stdio.h>
int main()
{
	int a,b,c;
	scanf("%d %d %d",&a,&b,&c);
	if(a==5&&b==5&&c==7)
	printf("YES");
	else if(a==5&&b==7&&c==5)
	printf("YES");
	else if(a==7&&b==5&&c==5)
	printf("YES");
	else
	printf("NO");
	return 0;
 } 

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

#define REP(i, x, n) for (int i = x; i < (int)(n); i++)
#define rep(i, n) REP (i, 0, n)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
#define sz(x) (int)(x.size())
#define popcount(x) __builtin_popcount(x)
#define popcountll(x) __builtin_popcountll(x)
#define uniq(x) x.erase(unique(x.begin(), x.end()), x.end())
#define F first
#define S second
#define mp make_pair
#define eb emplace_back

using namespace std;

typedef long long ll;

// const int INF = 1 << 30;
// const ll INF = 1LL << 60;
const int MOD = 1000000007;

string L;
ll dp[100000 + 5][2]; // 1: ギリギリ / 0: 余裕あり

int main() {
  cin >> L;

  int n = sz(L);

  dp[0][1] = 2;
  dp[0][0] = 1;

  REP (i, 1, n) {
    if (L[i] == '1') {
      dp[i][1] = dp[i - 1][1] * 2 % MOD;
      dp[i][0] = (dp[i - 1][1] + dp[i - 1][0] * 3) % MOD;
    } else {
      dp[i][1] = dp[i - 1][1];
      dp[i][0] = dp[i - 1][0] * 3 % MOD;
    }
  }

  cout << (dp[n - 1][0] + dp[n - 1][1]) % MOD << endl;
}


Measured memory_bytes: 2048
import java.util.*;
public class Main {

	public static void main(String[] args) {
		int i1, i2;
		Scanner sc = new Scanner(System.in);
		while (true) {
			i1 = sc.nextInt();
			i2 = sc.nextInt();
			if (i1 == 0 && i2 == 0)
				break;
			for (int i = 0; i < i1; i++) {
				for (int j = 0; j < i2; j++)
					if((i == 0 || i == i1 - 1)||(j == 0 || j == i2 - 1))
						System.out.print("#");
					else
						System.out.print(".");
				System.out.println("");
			}
			System.out.println("");
		}
	}
}

Measured memory_bytes: 25772
#include <cstdio>
int sx,sy,tx,ty;
int main()
{
    scanf("%d%d%d%d",&sx,&sy,&tx,&ty);
    for (int i=0;i<tx-sx;++i)
        putchar('R');
    for (int j=0;j<ty-sy;++j)
        putchar('U');
    for (int i=0;i<tx-sx;++i)
        putchar('L');
    for (int j=0;j<ty-sy;++j)
        putchar('D');
    putchar('D');
    putchar('R');
    for (int i=0;i<tx-sx;++i)
        putchar('R');
    putchar('U');
    for (int j=0;j<ty-sy;++j)
        putchar('U');
    putchar('L');
    putchar('U');
    putchar('L');
    for (int i=0;i<tx-sx;++i)
        putchar('L');
    for (int j=0;j<ty-sy;++j)
        putchar('D');
    putchar('D');
    putchar('R');
    return 0;
}


Measured memory_bytes: 128
#include<bits/stdc++.h>
#include<iostream>
#include<cstdio>
#include<vector>
#include<string>
#include<algorithm>
#define rep(i,x) for(int i = 0; i < x; i++)
typedef long long ll;
using namespace std;

int main(){
    int n,m; cin >> n >> m;
    int card[n] = {0};
    vector<int> lr[m];
    int mm[2] = {0};
    rep(i,m){
        int t1,t2;
        scanf("%d%d",&t1,&t2);
        lr[i].push_back(t1-1);
        lr[i].push_back(t2-1);
        // cout << lr[i][0] << lr[i][1] << endl;
    }
    // rep(i,m){
    //     for(int j =lr[i].at(0);j < lr[i].at(1)+1;j++){
    //         card[j]++;
    //         // cout << j;
    //     }
    // }
    mm[1] = n;
    rep(i,m){
        if(mm[0] < lr[i][0]) mm[0] = lr[i][0];
        if(mm[1] > lr[i][1]) mm[1] = lr[i][1]; 
        // cout << mm[0] << mm[1] << endl;
    }
    int ans = 0;
    // rep(i,n){
    //     if(card[i] == m) {
    //         ans++;
    //         // cout << i+1 << endl;
    //     }
    // }
    ans = mm[1]-mm[0]+1;
    if(ans < 0) ans = 0;
    cout << ans << endl;
}

Measured memory_bytes: 6144
macro_rules! input {
  (source = $s:expr, $($r:tt)*) => {
    let mut iter = $s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
  ($($r:tt)*) => {
    let mut s = {
      use std::io::Read;
      let mut s = String::new();
      std::io::stdin().read_to_string(&mut s).unwrap();
      s
    };
    let mut iter = s.split_whitespace();
    input_inner!{iter, $($r)*}
  };
}

macro_rules! input_inner {
  ($iter:expr) => {};
  ($iter:expr, ) => {};

  ($iter:expr, $var:ident : $t:tt $($r:tt)*) => {
    let $var = read_value!($iter, $t);
    input_inner!{$iter $($r)*}
  };
}

macro_rules! read_value {
  ($iter:expr, ( $($t:tt),* )) => {
    ( $(read_value!($iter, $t)),* )
  };

  ($iter:expr, [ $t:tt ; $len:expr ]) => {
    (0..$len).map(|_| read_value!($iter, $t)).collect::<Vec<_>>()
  };

  ($iter:expr, chars) => {
    read_value!($iter, String).chars().collect::<Vec<char>>()
  };

  ($iter:expr, usize1) => {
    read_value!($iter, usize) - 1
  };

  ($iter:expr, $t:ty) => {
    $iter.next().unwrap().parse::<$t>().expect("Parse error")
  };
}

fn main() {
  input! {
    n: i16,
    r: i16,
  }
  
  println!("{}",
    if n < 10 { r + 100 * (10 - n) }
    else { r }
  )
}

Measured memory_bytes: 4352
public class Main {
  public static void main(String[] args) {
    int k = new java.util.Scanner(System.in).nextInt();
    if (k % 2 == 0) {
      System.out.println((k / 2)*(k / 2));
    } else {
      System.out.println((k / 2 + 1) * (k / 2));
    }
  }
}


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

#define _overload(_1,_2,_3,name,...) name
#define _rep(i,n) _range(i,0,n)
#define _range(i,a,b) for(int i=int(a);i<int(b);++i)
#define rep(...) _overload(__VA_ARGS__,_range,_rep,)(__VA_ARGS__)

#define _rrep(i,n) _rrange(i,n,0)
#define _rrange(i,a,b) for(int i=int(a)-1;i>=int(b);--i)
#define rrep(...) _overload(__VA_ARGS__,_rrange,_rrep,)(__VA_ARGS__)

#define _all(arg) begin(arg),end(arg)
#define uniq(arg) sort(_all(arg)),(arg).erase(unique(_all(arg)),end(arg))
#define getidx(ary,key) lower_bound(_all(ary),key)-begin(ary)
#define clr(a,b) memset((a),(b),sizeof(a))
#define bit(n) (1LL<<(n))
#define popcount(n) (__builtin_popcountll(n))

using namespace std;

template<class T>bool chmax(T &a, const T &b) { return (a < b) ? (a = b, 1) : 0;}
template<class T>bool chmin(T &a, const T &b) { return (b < a) ? (a = b, 1) : 0;}

using ll = long long;
using R = long double;
const R EPS = 1e-9L; // [-1000,1000]->EPS=1e-8 [-10000,10000]->EPS=1e-7
inline int sgn(const R& r) {return (r > EPS) - (r < -EPS);}
inline R sq(R x) {return sqrt(max(x, 0.0L));}

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

// Problem Specific Parameter:
int h, w;
map<vector<int>, int> dp[2][13];
string board[12];

auto normalize(const auto &c) {
	vector<int> ary;
	rep(i, w) if (c[i] >= 0) ary.push_back(c[i]);
	sort(begin(ary), end(ary));
	ary.erase(unique(begin(ary), end(ary)), end(ary));

	vector<int> ret = c;
	rep(i, w) if (ret[i] >= 0) ret[i] = lower_bound(begin(ary), end(ary), ret[i]) - begin(ary);
	return ret;
}

int white(vector<int> &c, int pos, int comp) {
	if (c[pos] == -1) return -1;
	if (pos > 0 and c[pos - 1] == -1) return -1;
	c[pos] = -1;
	c = normalize(c);
	return comp;
}

int black(vector<int> &c, int pos, int comp) {
	if (pos > 0 and c[pos] >= 0 and c[pos - 1] >= 0) {
		if (c[pos] == c[pos - 1]) return -1;
		int a = c[pos - 1], b = c[pos];
		if (a > b) swap(a, b);
		rep(i, w) if (c[i] == b) c[i] = a;
		c = normalize(c);
		return comp - 1;
	} else {
		int nxt = -1;
		if (c[pos] >= 0) nxt = c[pos];
		if (pos > 0 and c[pos - 1] >= 0) nxt = c[pos - 1];

		if (nxt == -1) {
			nxt = 0, comp++;
			rep(i, w) chmax(nxt, c[i] + 1);
		}
		c[pos] = nxt;
		c = normalize(c);
		return comp;
	}
}

int main(void) {
	cin >> h >> w;
	rep(i, h) cin >> board[i];

	if (h == 1 and w == 1 and board[0][0] == '.') {
		puts("0");
		return 0;
	}

	vector<int> init(w, -2);
	dp[0][0][init] = 0;

	rep(i, h)rep(j, w) {
		const int cidx = (w * i + j) % 2;
		const int nidx = cidx ^ 1;
		rep(ncomp, 7) dp[nidx][ncomp].clear();

		rep(comp, 7) {
			for (auto &cur : dp[cidx][comp]) {
				if (board[i][j] != '#') {
					vector<int> nxt = cur.first;
					int ncomp = white(nxt, j, comp);
					if (ncomp >= 0) chmax(dp[nidx][ncomp][nxt], cur.second);
				}

				if (board[i][j] != '.') {
					vector<int> nxt = cur.first;
					int ncomp = black(nxt, j, comp);
					if (ncomp >= 0) chmax(dp[nidx][ncomp][nxt], cur.second + 1);
				}
			}
		}
	}

	const int aidx = (w * h) % 2;
	int ans = -1;
	for (auto &elem : dp[aidx][1]) chmax(ans, elem.second);
	cout << ans << endl;

	return 0;
}

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

using namespace std;

int main()
{
    int n,i,j,k,res=0;
    scanf("%d",&n);
    vector<int> l(n);
    for(i=0;i<n;i++)
        scanf("%d",&l[i]);
    if(n<3)
    {
        printf("0\n");
        return 0;
    }
    for(i=0;i<n-2;i++)
        for(j=i+1;j<n-1;j++)
            for(k=j+1;k<n;k++)
                if(l[i]==l[j]||l[i]==l[k]||l[j]==l[k])
                    continue;
                else
                {
                    if(l[i]+l[j]>l[k] && l[i]+l[k]>l[j] && l[j]+l[k]>l[i])
                    {
                        //printf("%d,%d,%d: %d,%d,%d\n",i+1,j+1,k+1,l[i],l[j],l[k]);
                        res++;
                    }
                }
    printf("%d\n",res);

    return 0;
}


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

#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)   FOR(i,0,n)
#define ALL(a)     (a).begin(),(a).end()
#define MOD 1000000007

typedef long long int ll;

const ll INF=(ll)1e19;
//const int INF=(1<<30);


int main(){
  int a,b;
  cin >> a >> b;
  int n=b;
  
  if(b>=100)n+=a*1000;
  else if(b>=10)n+=a*100;
  else n += a*10;

  for(int i = 1; i*i<=n; i++){
    if(i*i==n){
      cout << "Yes" << endl;
      exit(0);
    }
  }
  cout << "No" << endl;
}



Measured memory_bytes: 256
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll = long long;
using vec = vector<ll>;
using vect = vector<double>;
using Graph = vector<vector<ll>>;
#define loop(i, n) for (ll i = 0; i < n; i++)
#define Loop(i, m, n) for (ll i = m; i < n; i++)
#define pool(i, n) for (ll i = n; i >= 0; i--)
#define Pool(i, m, n) for (ll i = n; i >= m; i--)
#define mod 1000000007ll
#define flagcount __builtin_popcount
#define flag(x) (1 << x)
#define flagadd(bit, x) bit |= flag(x)
#define flagpop(bit, x) bit &= ~flag(x)
#define flagon(bit, i) bit &flag(i)
#define flagoff(bit, i) !(bit & (1 << i))
#define all(v) v.begin(), v.end()
#define low2way(v, x) lower_bound(all(v), x)
#define high2way(v, x) upper_bound(all(v), x)
#define idx_lower(v, x) (distance(v.begin(), low2way(v, x)))  //配列vでx未満の要素数を返す
#define idx_upper(v, x) (distance(v.begin(), high2way(v, x))) //配列vでx以下の要素数を返す
#define idx_lower2(v, x) (v.size() - idx_lower(v, x))         //配列vでx以上の要素数を返す
#define idx_upper2(v, x) (v.size() - idx_upper(v, x))         //配列vでxより大きい要素の数を返す
#define putout(a) cout << a << endl
#define Gput(a, b) G[a].push_back(b)
#define Sum(v) accumulate(all(v), 0ll)
#define gcd(x, y) __gcd(x, y)
ll ctoi(char c)
{
    if (c >= '0' && c <= '9')
    {
        return c - '0';
    }
    return 0;
}
template <typename T>
T lcm(T x, T y)
{
    T z = gcd(x, y);
    return x * y / z;
}
template <typename T>
bool primejudge(T n)
{
    if (n < 2)
        return false;
    else if (n == 2)
        return true;
    else if (n % 2 == 0)
        return false;
    double sqrtn = sqrt(n);
    for (T i = 3; i < sqrtn + 1; i++)
    {
        if (n % i == 0)
        {
            return false;
        }
        i++;
    }
    return true;
}
//場合によって使い分ける
//const ll dx[4]={1,0,-1,0};
//const ll dy[4]={0,1,0,-1};
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//2次元配列の宣言
//vector<vector<ll>> field(h, vector<ll>(w));
//dp[i][j][k]:座標(i,j)で偏りがkになることがあるか？
ll dp[85][85][80 * 80 * 3];
int main()
{
    cout << fixed << setprecision(30);
    ll H, W;
    cin >> H >> W;
    vector<vector<ll>> fieldA(H, vector<ll>(W));
    vector<vector<ll>> fieldB(H, vector<ll>(W));
    loop(i, H) loop(j, W) cin >> fieldA[i][j];
    loop(i, H) loop(j, W) cin >> fieldB[i][j];
    dp[0][0][abs(fieldA[0][0] - fieldB[0][0])] = true;
    loop(i, H)
    {
        loop(j, W)
        {
            loop(k, 80 * 80 * 2)
            {
                if (i - 1 >= 0 && dp[i - 1][j][k])
                {
                    dp[i][j][k + abs(fieldA[i][j] - fieldB[i][j])] = true;
                    dp[i][j][abs(k - abs(fieldA[i][j] - fieldB[i][j]))] = true;
                }
                if (j - 1 >= 0 && dp[i][j - 1][k])
                {
                    dp[i][j][k + abs(fieldA[i][j] - fieldB[i][j])] = true;
                    dp[i][j][abs(k - abs(fieldA[i][j] - fieldB[i][j]))] = true;
                }
            }
        }
    }
    loop(i, 80 * 80 * 3) if (dp[H - 1][W - 1][i])
    {
        putout(i);
        return 0;
    }
    return 0;
}


Measured memory_bytes: 346512
#include <iostream>
#include <cstdio>
#include <string>
#include <algorithm>
#include <utility>
#include <cmath>
#include <vector>
#include <queue>
#include <set>
#include <map>
#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;
 
int main() {
    ll S;
    cin >> S;
    
    const ll m = 1e9;

    if(S <= m) {
        cout << 0 << " " << 0 << " " << 1 << " " << 0 << " " << 0 << " " << S << endl;
        re0;
    }

    if(S == 1e18) {
        ll x3 = 0, y3 = m;
        cout << 0 << " " << 0 << " " << m << " " << 0 << " " << 0 << " " << m << endl;
        re0;
    }
    
    cout << 0 << " " << 0 << " " << m << " " << 1 << " " << m - S%m << " " << S/m + 1 << endl;
    re0;
}

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

using ll = long long int;

const int MAX = (int)(1e5 + 5);
const ll INF = (ll)(1e10 + 5);

const int MAX_N = (int)(1e5 + 5);

int n;

vector<int> minus_vec;
vector<int> plus_vec;

vector<pair<int, int>> ans_pair;

int ans;

int main(void) {
  // Here your code !
  scanf("%d", &n);

  for (int i = 0; i < n; ++i) {
    int a;
    scanf("%d", &a);

    if (a < 0) {
      minus_vec.push_back(a);
    }
    else {
      plus_vec.push_back(a);
    }
  }

  sort(plus_vec.begin(), plus_vec.end());
  sort(minus_vec.begin(), minus_vec.end(), greater<int>());

  if (plus_vec.size() == 0 && minus_vec.size() > 0) {
    if (minus_vec.size() == 2) {
      printf("%d\n", minus_vec[0] - minus_vec[1]);
      printf("%d %d\n", minus_vec[0], minus_vec[1]);

      return 0;
    }

    int cur_plus = minus_vec[0] - minus_vec[1];
    ans_pair.push_back(make_pair(minus_vec[0], minus_vec[1]));

    for (int i = 2; i < minus_vec.size(); ++i) {
      ans_pair.push_back(make_pair(cur_plus, minus_vec[i]));
      cur_plus = cur_plus - minus_vec[i];
    }

    ans = cur_plus;
  }
  else if (plus_vec.size() > 0 && minus_vec.size() == 0) {
    if (plus_vec.size() == 2) {
      printf("%d\n", plus_vec[1] - plus_vec[0]);
      printf("%d %d\n", plus_vec[1], plus_vec[0]);

      return 0;
    }

    int cur_minus = plus_vec[0] - plus_vec[1];
    ans_pair.push_back(make_pair(plus_vec[0], plus_vec[1]));

    for (int i = 2; i < plus_vec.size() - 1; ++i) {
      ans_pair.push_back(make_pair(cur_minus, plus_vec[i]));
      cur_minus = cur_minus - plus_vec[i];
    }

    ans = plus_vec.back() - cur_minus;
    ans_pair.push_back(make_pair(plus_vec.back(), cur_minus));
  }
  else {
    if (minus_vec.size() == 1 && plus_vec.size() == 1) {
      printf("%d\n", plus_vec[0] - minus_vec[0]);
      printf("%d %d\n", plus_vec[0], minus_vec[0]);

      return 0;
    }

    for (int i = 0; i < plus_vec.size() - 1; ++i) {
      ans_pair.push_back(make_pair(minus_vec[0], plus_vec[i]));
      minus_vec[0] = minus_vec[0] - plus_vec[i];

      // printf("- ");
      // for (auto e: minus_vec) {
      //   printf("%d ", e);
      // }
      // printf("\n");
    }

    int cur_plus = plus_vec.back();

    for (int i = 0; i < minus_vec.size(); ++i) {
      ans_pair.push_back(make_pair(cur_plus, minus_vec[i]));
      cur_plus = cur_plus - minus_vec[i];
    }

    ans = cur_plus;
  }

  printf("%d\n", ans);

  for (auto &e: ans_pair) {
    printf("%d %d\n", e.first, e.second);
  }

  return 0;
}


Measured memory_bytes: 3444
package main

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

var sc, wr = bufio.NewScanner(os.Stdin), bufio.NewWriter(os.Stdout)

func scanString() string   { sc.Scan(); return sc.Text() }
func scanRunes() []rune    { return []rune(scanString()) }
func scanInt() int         { a, _ := strconv.Atoi(scanString()); return a }
func scanInt64() int64     { a, _ := strconv.ParseInt(scanString(), 10, 64); return a }
func scanFloat64() float64 { a, _ := strconv.ParseFloat(scanString(), 64); return a }

func scanInts(n int) []int {
	res := make([]int, n)
	for i := 0; i < n; i++ {
		res[i] = scanInt()
	}
	return res
}

func debug(a ...interface{}) { fmt.Fprintln(os.Stderr, a...) }

func abs(a int) int {
	if a < 0 {
		return -a
	}
	return a
}
func min(a, b int) int {
	if a < b {
		return a
	}
	return b
}
func max(a, b int) int {
	if a > b {
		return a
	}
	return b
}

//•*¨*•.¸¸♪main•*¨*•.¸¸♪(　-ω-)ノ　(　・ω・)
func main() {
	defer wr.Flush()
	sc.Split(bufio.ScanWords)
	sc.Buffer(make([]byte, 10000), 1001001)

	n, k := scanInt(), scanInt()
	h := scanInts(n)

	if n == k {
		fmt.Fprintln(wr, 0)
		return
	}

	inf := 1 << 60
	dp := make([][]int, n+1)
	for i := 0; i < n+1; i++ {
		dp[i] = make([]int, n+1)
		for j := 0; j < n+1; j++ {
			dp[i][j] = inf
		}
	}

	for i := 0; i < n; i++ {
		dp[i+1][1] = h[i]
		for j := 1; j <= i+1; j++ {
			for k := 1; k < n-i; k++ {
				dp[i+k+1][j+1] = min(dp[i+k+1][j+1], dp[i+1][j]+max(0, h[i+k]-h[i]))
			}
		}
	}

	ans := inf
	for i := 0; i < n; i++ {
		ans = min(ans, dp[i+1][n-k])
	}

	fmt.Fprintln(wr, ans)
}


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

int main()
{
    int n, m, k;
    cin >> n >> m >> k;
    vector<ll> a(n + 1, 0), b(m + 1, 0);
    for (int i = 1; i <= n; i++)
    {
        int t;
        cin >> t;
        a[i] = a[i - 1] + t;
    }
    for (int i = 1; i <= m; i++)
    {
        int t;
        cin >> t;
        b[i] = b[i - 1] + t;
    }
    int ans = 0;
    int j = m;
    for (int i = 0; i <= n; i++)
    {
        if (a[i] > k)
            break;
        while (a[i] + b[j] > k)
            j--;
        ans = max(ans, i + j);
    }
    cout << ans << endl;
}


Measured memory_bytes: 6416
#include<iostream>
//#include<algorithm>
//#include<cmath>
//#include<string>
//#include<cctype>
#include <vector>
using namespace std;
int main() {
	int n;
	while (cin >> n) {
		if (n == 0)break;
		int c = 0;
		while (n != 1)
			n = n % 2 ? n * 3 + 1 : n / 2, c++;
		cout << c << endl;
	}
	return 0;
}

Measured memory_bytes: 3024
#include <algorithm>
#include <cmath>
#include <iostream>
#include <map>
#include <vector>

using namespace std;

int main() {
  string str;
  vector<int> stations(3, 0);

  cin >> str;

  for (int i = 0; i < str.length(); i++) {
    if (str[i] == 'A') {
      stations[0]++;
    } else {
      stations[1]++;
    }
  }

  if (stations[0] > 0 && stations[1] > 0) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }

  return 0;
}

Measured memory_bytes: 256
use proconio::{fastout, input};
use std::io::*;
use std::str::FromStr;

use std::cmp::{max, min};
use std::collections::HashSet;

struct UnionFind {
    parent: Vec<usize>,
    size: Vec<usize>,
}

impl UnionFind {
    fn new(n: usize) -> UnionFind {
        // initialize
        let mut v: Vec<usize> = vec![];
        for i in 0..n + 1 {
            v.push(i)
        }
        let mut s: Vec<usize> = vec![1; n + 1];

        UnionFind { parent: v, size: s }
    }

    fn root(&self, x: usize) -> usize {
        if self.parent[x] == x {
            return x;
        } else {
            return self.root(self.parent[x]);
        }
    }

    fn size(&self, a: usize) -> usize {
        let ra = self.root(a);
        self.size[ra]
    }

    fn unite(&mut self, a: usize, b: usize) {
        let mut ra = self.root(a);
        let mut rb = self.root(b);
        if ra == rb {
            return;
        }
        if self.size[ra] < self.size[rb] {
            std::mem::swap(&mut ra, &mut rb)
        };
        self.size[ra] += self.size[rb];
        self.parent[rb] = ra;
    }

    fn same(&self, a: usize, b: usize) -> bool {
        let ra = self.root(a);
        let rb = self.root(b);
        ra == rb
    }
}

// this is code for abc177
fn main() {
    input! {
        n: usize,
        m: usize,
        ab: [(usize, usize); m],
    }

    let mut uf = UnionFind::new(n);

    for i in 0..ab.len() {
        uf.unite(ab[i].0, ab[i].1);
    }

    let mut maxv = 0;
    for i in 0..n + 1 {
        maxv = max(maxv, uf.size(i));
    }
    println!("{}", maxv);
}


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

#define ll long long

int main(){

    int i,j,k;
    ll int N,H,W,D;
    int a,b,c;
    int count = 0;

    cin >> D >> N;

    if(D == 0){
        if(N != 100)cout << N << endl;
        else cout << "101" << endl;
    }

    else if(D == 1){
        if (N !=100)cout << N*100 << endl;
        else cout << "10100" << endl;
    }

    else if(D == 2){
        if( N != 100)cout << N*10000 << endl;
        else cout << "1010000" << endl;

    }

    return 0;

}

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

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

    priority_queue<int> pq_intact_plus;
    long sum_minus = 0, sum_used_plus = 0;

    for (int i = 0; i < n; i++) {
        int x = a[i] - b[i];
        if (x >= 0)
            pq_intact_plus.push(x);
        else
            sum_minus += (long) x;
    }

    if (sum_minus >= 0) {
        cout << 0 << endl;
        return 0;
    }
    while (true) {
        if (sum_used_plus > 0) {
            long sum = sum_used_plus + sum_minus;
            if (sum >= 0) {
                cout << n - pq_intact_plus.size() << endl;
                return 0;
            }
            sum_minus = sum;
            sum_used_plus = 0;
        }
        if (pq_intact_plus.empty()) {
            cout << -1 << endl;
            return 0;
        }
        sum_used_plus = pq_intact_plus.top();
        pq_intact_plus.pop();
    }
    return 0;
}


Measured memory_bytes: 1660
#include<iostream>
#include<vector>
#include<algorithm>
using namespace std;

struct node {
	int mingci;
	int renshu;
	
	node(int m,int r) {
		mingci=m;
		renshu=r;
		
	}
	bool operator < (const node &a) {
		return renshu<a.renshu;
	}
}; 

int N;
vector<node> vec;
int main() {
	cin>>N;
	for(int i=1;i<=N;i++) {
		int temp;
		cin>>temp;
		vec.push_back(node(i,temp));
	}
	sort(vec.begin(),vec.end());
	
	for(int i=0;i<N;i++) {
		cout<<vec[i].mingci<<' ';
	}
	
	
}

Measured memory_bytes: 1780
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <cstdio>
#include <string>
#include <cmath>
#include <queue>
#include <tuple>
#include <bitset>
#include <cassert>
#include <chrono>
#include <cstring>
#include <iomanip>
#include <iostream>
#include <random>
#include <set>
#include <stack>
#include <time.h>

//#include <bits/stdc++.h>
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#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,i0,n) for(int (i)=(i0);(i)<(n);(i)++)
#define FORR(i,i0,n) for(int (i)=(n)-1; (i)>=(i0);(i)--)
#define SORT(x) sort(x.begin(),x.end())
#define SORTR(x) sort(x.begin(),x.end(),greater<vector<int>>())

#define fi first
#define se second
#define pb push_back
#define eb emplace_back
#define mp make_pair
#define mt make_tuple

using namespace std;
using ll = long long;
typedef std::pair<int, int> pii;
typedef std::pair<int, double> pid;
typedef std::vector<int> vi;
typedef std::vector<pii> vii;

#define PI 3.14159265358979323846264338327950L
const int mod = 1e9+7;




map<int,ll> dp;
int helper(int n){
    //cout << n << " ";
    if (n<3) return 0;
    if (n<=5) return 1;
    if (dp[n]) return dp[n];
    ll ret = 1;
    for(int i = 3; i <= n-3; i++){
        ret += helper(n-i);
        ret %= mod;
    }
    return dp[n] = ret;
}





void solve(){
    int s;
    cin >> s;
    cout << helper(s);
    
}

// void solveV(){

//     int n;
//     cin >> n;
//     ll dp[n+1][4];
//     memset(dp,0,sizeof dp);
    
//     for(int i = 1; i <= n; i++){
//         for(int t = 0; t < 4; t++){
//             // none, 0, 9, {0,9}
//             if (t==0){
//                 dp[i][0] = dp[i-1][0]*7;
//                 dp[i][1] += dp[i-1][0];
//                 dp[i][2] += dp[i-1][0];
//             }
//             if (t==1){
//                 dp[i][1] += dp[i-1][0]*10;
//                 dp[i][]
//             }
//         }
//     }
    
// }




int main() {
    int T;
    //if (0==0) cin >> T;  
    //else T = 1;
    T = 1;
    while (T--) {
        solve();
        cout << endl;
    }
}




Measured memory_bytes: 3704
# coding: utf-8

n_mou = int(input())
l_mou = list(map(int, input().split()))
l_mou_ind = [[l_mou[i], i] for i in range(n_mou)]
l_mou_ind.sort()

l_ans = [0 for i in range(n_mou)]

l_ans[0] = l_mou_ind[0][0] * n_mou
min_index = l_mou_ind[-1][1]
for i in range(n_mou - 1, 0, -1):
    min_index = min(min_index, l_mou_ind[i][1])
    if l_mou_ind[i - 1][0] != l_mou_ind[i][0]:
        l_ans[min_index] += (l_mou_ind[i][0] - l_mou_ind[i - 1][0]) * (n_mou - i)

for i in range(n_mou):
    print(l_ans[i])

Measured memory_bytes: 25664
while True:
	n = int(input())
	if n == 0:
		break
	list = [int(s) for s in input().split()]
	m=sum(list)/n
	x = 0
	for i in range(n):
		x +=(list[i]-m)**2
	a = (x/n)**0.5
	print(a)


Measured memory_bytes: 5680
#include<bits/stdc++.h>
#define rep(i, n) for(i = 0; i < (n); ++i)
using namespace std;
typedef long long ll;
typedef pair<int, int> P;
#define MOD 1000000007
#define PI 3.14159265359

int main(){
  double A, B, H, M, time, ans, theta;
  cin >> A >> B >> H >> M;
  time = H+M/60;
  
  theta = fabs((2*PI*time) - time*PI/6);
  
  ans = sqrt(A*A + B*B - 2*A*B*cos(theta));
  
  printf("%.13f\n", ans);
  
  return 0;
}

Measured memory_bytes: 4228
#include<iostream>

using namespace std;

int main() {
	//最初のK泊までは、1泊あたりX円
	//K+1泊目以降は、1泊あたりY円
	//N泊連続宿泊
	
	int N;//連続宿泊N日
	int K;//最初のK泊
	int X;//最初のK泊までは、1泊あたりX円
	int Y;//K+1泊目以降は、1泊あたりY円
	int AccommodationFees;//宿泊費

	//入力
	cin >> N;
	cin >> K;
	cin >> X;
	cin >> Y;

	//宿泊費の合計金額を求める
	if (N<K) {
		AccommodationFees = N * X;
	}
	else {
		AccommodationFees = K * X + (N - K) * Y;
	}

	cout << AccommodationFees << endl;

}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
long long int x, y, a, b, c, ans;
long long int p[100000], q[100000], r[100000], p2[300000], q2[100000], r2[100000];
int main(){
	cin >> x >> y >> a >> b >> c;
	for(long long int i = 0;i < a;i++){
		cin >> p[i];
	}
	for(long long int i = 0;i < b;i++){
		cin >> q[i];
	}
	for(long long int i = 0;i < c;i++){
		cin >> r[i];
	}
	sort(p, p + a, greater<long long int>());
	sort(q, q + b, greater<long long int>());
	sort(r, r + c, greater<long long int>());
	for(long long int i = 0;i < x;i++){
		p2[i] = p[i];
 	}
 	for(long long int i = x;i < x + y;i++){
 		p2[i] = q[i - x];
 	}
 	for(long long int i = x + y;i < x + y + c;i++){
 		p2[i] = r[i - x - y];
 	}
 	sort(p2, p2 + x + y + c, greater<long long int>());
 	ans = p2[0];
 	for(long long int i = 1;i < x + y;i++){
		ans += p2[i];
	}
	/*p2[0] = p[0];
	q2[0] = q[0];
	r2[0] = r[0];
	long long int ans = 0;
	long long int zero = 0;
	for(long long int i = 0;i < a;i++){
		p2[i] = p2[i - 1] + p[i];
	}
	for(long long int i = 0;i < b;i++){
		q2[i] = q2[i - 1] + q[i];
	}
	for(long long int i = 0;i < c;i++){
		r2[i] = r2[i - 1] + r[i];
	}
	for(long long int i = max(zero, x - c);i <= x;i++){
		for(long long int j = max(zero, y - (c + i - x));j <= y;j++){
			ans2 = 0;
			if(i){
				ans2 += p2[i - 1];
			}
			if(j){
				ans2 += q2[i - 1];
			}
			if(c - i - j){
				ans2 += r2[c - i - j - 1];
			}
			ans = max(ans, ans2);
		}
	}
	*/
	cout << ans << endl;
}

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

int main(){
    int N;
    string res="No";
    cin >> N;

    for (int i=0;i<N/4+1;++i){
        if ((N-4*i)%7==0){
            res = "Yes";
            break;
        }
    }
    cout << res << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
int N;
string S;
int k = 700;
int A[26][800];
void upd(int i, char c) {
    int j = i/k;
    A[S[i]-'a'][j]--;
    S[i] = c;
    A[S[i]-'a'][j]++;
}
int opt(int l, int r) {
    int res = 0;
    for (int i = 0; i < 26; i++) {
        bool f = 0;
        for (int j = (l/k)+1; j < (r/k); j++) {
            if (A[i][j]) {
                res++;
                f = 1;
                break;
            }
        }
        if (f) continue;
        for (int j = l; j < (l/k+1)*k && j <= r; j++) {
            if (S[j]-'a' == i) {
                res++;
                f = 1;
                break;
            }
        }
        if (f) continue;
        if (r/k == l/k) continue;
        for (int j = (r/k)*k; j <= r; j++) {
            if (S[j]-'a' == i) {
                res++;
                f = 1;
                break;
            }
        }
        if (f) continue;
    }
    return res;
}
int main () {
    int Q;
    cin >> N >> S >> Q;
    for (int i = 0; i < N; i++) {
        A[S[i]-'a'][i/k]++;
    }
    for (; Q; Q--) {
        int a;
        scanf("%d", &a);
        if (a == 1) {
            int i;
            char c;
            scanf("%d %c", &i, &c);
            i--;
            upd(i, c);
        }
        else {
            int l, r;
            scanf("%d %d", &l, &r);
            l--, r--;
            printf("%d\n", opt(l, r));
        }
    }
}

Measured memory_bytes: 1028
n = int(input())
xy = [[] for _ in range(n)]
for i in range(n):
    a = int(input())
    for _ in range(a):
        x, y = map(int, input().split())
        xy[i].append((x - 1, y))

result = 0
for i in range(2**n):
  flg = True
  for j in range(n):
    if (i>>j) & 1 == 0:
      continue
    for x,y in (xy[j]):
      if (i>>x) & 1 != y:
        flg = False
        break
    if not flg:
      break
  if flg:
    num_honest = bin(i)[2:].count('1')
    if result < num_honest:
      result = num_honest
print(result)


Measured memory_bytes: 3064
use std::collections::{BinaryHeap, HashSet};

pub fn main() {
    use std::io::Read;
    let mut buf = String::new();
    std::io::stdin().read_to_string(&mut buf).unwrap();
    let mut iter = buf.split_whitespace();

    let x: usize = iter.next().unwrap().parse().unwrap();
    let y: usize = iter.next().unwrap().parse().unwrap();
    let z: usize = iter.next().unwrap().parse().unwrap();
    let k: usize = iter.next().unwrap().parse().unwrap();

    let mut a: Vec<u64> = vec![0;x];
    for i in 0..x {
        a[i] = iter.next().unwrap().parse().unwrap();
    }
    let mut b: Vec<u64> = vec![0;y];
    for i in 0..y {
        b[i] = iter.next().unwrap().parse().unwrap();
    }
    let mut c: Vec<u64> = vec![0;z];
    for i in 0..z {
        c[i] = iter.next().unwrap().parse().unwrap();
    }
    a.sort();
    a.reverse();
    b.sort();
    b.reverse();
    c.sort();
    c.reverse();

    let mut heap: BinaryHeap<(u64, usize, usize, usize)> = BinaryHeap::new();
    heap.push((a[0] + b[0] + c[0], 0,0,0));
    let mut hset: HashSet<(usize,usize,usize)> = HashSet::new();
    hset.insert((0,0,0));
    for _ in 0..k {
        let max_item = heap.pop();
        match max_item {
            None => (),
            Some((sum, p,q,r)) => {
                println!("{}", sum);
                if p<x-1 && !hset.contains(&(p+1,q,r)) {
                    heap.push((a[p+1]+b[q]+c[r],p+1,q,r));
                    hset.insert((p+1,q,r));
                };
                if q<y-1 && !hset.contains(&(p,q+1,r)) {
                    heap.push((a[p]+b[q+1]+c[r],p,q+1,r));
                    hset.insert((p,q+1,r));
                };
                if r<z-1 && !hset.contains(&(p,q,r+1)) {
                    heap.push((a[p]+b[q]+c[r+1],p,q,r+1));
                    hset.insert((p,q,r+1));
                };
            }
        }
    }

}

Measured memory_bytes: 4352