akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <math.h>
#include <string>
#include <sstream>
using namespace std;

//template <class T>
void swap(int &a, int &b){
	int temp;
	temp = a;
	a = b;
	b = temp;
}

void swap2(string& a, string& b)
{
	string temp;
	temp = a;
	a = b;
	b = temp;
}

void select_sort(int n, string*array, int*num){
	int min;
	for(int i=0;i<n;i++)
	{
		min = i;
		for(int j=i;j<n;j++)
		{
			if(num[j]<num[min])
			{
				min = j;
			}			
		}
		if(num[i] != num[min])
		{
			swap(num[i], num[min]);
			swap2(array[i], array[min]);
		}
	}	
}


void bubble_sort(int n, string*array1, int*num1){
	for(int i = n-1; i>=0; i--)
	{
		for(int j = 0; j<=i-1; j++)
		{
			if(num1[j]>num1[j+1]) 
			{
				swap(num1[j], num1[j+1]);
				swap2(array1[j], array1[j+1]);
			}
		}
	}
}

void Ifstable(int n, string*pre, int*num, string*array)
{
	for(int i = 0; i<n; i++){
		for(int j = i+1; j<n; j++){
			if(num[i] == num[j]){
				if(pre[num[j]] == "") pre[num[j]].push_back(array[i][0]);
				pre[num[j]].push_back(array[j][0]);
			}
		}
	}
}

template <class T>
int Toint(T input){
	stringstream ss;
	ss<<input;
	int num;
	ss>>num;
	return num;
}

void printout(int n, string* input, string *pre, string *post)
{
	for(int i=0; i<n; i++)
	{
		if(i!=0) cout<<" ";
		cout<<input[i];
	}
	cout<<endl;
	int a;
	for(a=1; a<=9; a++)
	{
		if(pre[a].compare(post[a]) != 0)
		break;
	}
	if(a==10) cout<<"Stable"<<endl;
	else cout<<"Not stable"<<endl;
//	cout<<post[a]<<' ';
//	}
//	cout<<endl;
}

int main(){
	int n;
	cin>>n;
	string pre[10], post[10], post1[10];
	string *array = new string[n];
	string *array1 = new string[n];
	int *num = new int[n];
	int *num1 = new int[n];
	for(int i=0;i<n;i++) 
	{
		string input;
		cin>>input;
		array1[i] = array[i] = input;
		num1[i] = num[i] = Toint(array[i][1]);
	}	
	Ifstable(n, pre, num, array);	
//-------------------------------------------
	bubble_sort(n, array1, num1);
	Ifstable(n, post, num1, array1);			
	printout(n, array1, pre, post);
//-------------------------------------------	
	select_sort(n, array, num);	
	Ifstable(n, post1, num, array);	
	printout(n, array, pre, post1);



//	delete []array;
	return 0;
}

Measured memory_bytes: 1240
#include <iostream>
#include <string>
#include <vector>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
int main()
{
	int k, n;
	cin >> k >> n;
	vector<int> vec(n);
	int m = 0;
	m = 0;
	rep(i, n) {
		cin >> vec[i];
		if (i == 0)	continue;
		else if (i < n) {
			if (m < vec[i] - vec[i - 1])	m = vec[i] - vec[i - 1];
		}
	}
	if (m < k + vec[0] - vec[n - 1])	m = k + vec[0] - vec[n - 1];
	cout << k - m << endl;
	return 0;
}

Measured memory_bytes: 1024
s=input()
n=len(s)
ans=1
for i in range(n):
    if s[i]!=s[n-1-i]:
        ans=0
harf=int((n-1)/2)
for i in range(harf):
    if s[i]!=s[harf-1-i]:
        ans=0
for i in range(harf+1,n):
    if s[i]!=s[n-1-(i-harf-1)]:
        ans=0
if ans==1:
    print("Yes")
else:
    print("No")

Measured memory_bytes: 3064
#include<algorithm>
#include<iostream>
#include<string>
using namespace std;

int main(){
  string S;cin>>S;
  long long K;cin>>K;
  int c,t=1;
  for(int i=0;i<min((long long)S.size(),K);i++){
    if(S[i]>'1'){
      t=0;c=i;break;
    }
  }
  if(t!=1)cout<<S[c];
  else cout<<'1'<<endl;
}


Measured memory_bytes: 256
x, y, a, b, c = list(map(int, input().split()))
ppp = list(map(int, input().split()))
qqq = list(map(int, input().split()))
rrr = list(map(int, input().split()))
ppp.sort(reverse=True)
qqq.sort(reverse=True)
rrr.sort(reverse=True)
ppqq = ppp[:x] + qqq[:y]
ppqq.sort(reverse=True)
ppqq.insert(0, 0)
rrr.insert(0, 0)

i = x + y
j = 1
while i > 0 and j <= c and ppqq[i] < rrr[j]:
    i -= 1
    j += 1
print(sum(ppqq[:i + 1]) + sum(rrr[:j]))


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

int main(){
    string s;
    cin >> s;
    string t = s.substr(0);
    reverse(t.begin(), t.end());
    string ss = s.substr(0, s.size() / 2);
    string tt = ss.substr(0);
    reverse(tt.begin(), tt.end());
    string sss = t.substr(0, t.size() / 2);
    string ttt = sss.substr(0);
    reverse(ttt.begin(), ttt.end());
    
    if(s == t && ss == tt && sss == ttt) cout << "Yes" << endl;
    else cout << "No" << endl;
    return 0;
}

Measured memory_bytes: 256
import java.util.*;

public class Main {
    public static void main(String[] args) throws Exception {
        // Your code here!
        Scanner sc = new Scanner(System.in);
        int N = sc.nextInt();
        int N1 = N/100;
        int N2 = (N - N1 * 100 ) /10;
        int N3 = (N - N1*100 - N2*10);
        if(N1==7||N2==7||N3==7) System.out.println("Yes");
        else System.out.println("No");
    }
}


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

using namespace std;

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

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

#endif

void Main() {
    ll N, M; cin >> N >> M;
    set<ll> a;
    rep(i, M){int tmp; cin >> tmp; a.insert(tmp);}
    vector<ll> dp(N+1, 0);
    dp.at(0) = 1;
    rep2(i, 1, N+1){
        if ((i - 2 >= 0) && (a.find(i-2) == a.end())){dp.at(i) += dp.at(i-2); dp.at(i) = dp.at(i) % MOD;}
        if ((i - 1 >= 0) && (a.find(i-1) == a.end())){dp.at(i) += dp.at(i-1); dp.at(i) = dp.at(i) % MOD;}
    }
    cout << dp.at(N) << endl;
}

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


Measured memory_bytes: 5760
#include <iostream>
#include <cstdio>
#include <map>
#include <algorithm>
#include <vector>
#include <string>
#include <utility>
#include <queue>
#define INF 1e16
#define rep(i,n) for(int i=0;i<n;i++)
#define NO cout<<"NO"<<endl;
#define YES cout << "YES"<<endl;
#define No cout << "No"<<endl;
#define Yes cout << "Yes"<<endl;
#define all(a) a.begin(),a.end()
#define P pair<ll,ll>
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

//(int)'a'は97 (int)'A'は65 (int)'1'は49
//おまじない
//UnionFind

const int maxn=100000;

int main(){
    int a,b;
    
    cin >> a>>b;
    
    if(a>=13){
        cout << b<<endl;
    }else if(6<=a&&a<=12){
        cout << b/2<<endl;
    }else{
        cout << 0<<endl;
    }
    
    return 0;
}


Measured memory_bytes: 256
/*
    CP Submission
*/

#include<bits/stdc++.h>

using namespace std;

/* Shortcuts */
#define mp make_pair
#define pb push_back
#define all(x) x.begin(), x.end()
#define val(x) cout << #x << ": " << (x) << endl;
#define log(x) cout << (x) << endl;
#define sz(x) (int)(x.size())

/* typedefs */
typedef long long ll;
typedef pair<int,int> ii;
typedef pair<string,int> si;
typedef pair<int,ii> iii;
typedef vector <si> vsi;
typedef vector <ii> vii;
typedef vector <int> vi;
typedef vector <char> vc;
typedef vector <string> vs;
typedef map <string,vs> msvs;
typedef map <string,int> msi;
typedef map <string,string> mss;

int main(){

    ios_base::sync_with_stdio(false);
    cin.tie(NULL);

    ll x;
    cin>>x;

    if(x % 2 == 0){
        cout << x << endl;
    } else {
        cout << x * 2 << endl;
    }

    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define xrep(i, a, b) for (int i = int(a); i < int(b); ++i)
using ll = long long;
int main() {
    ll A, B, C, K;
    cin >> A >> B >> C >> K;

    ll ans = 0;

    rep(i, K) {
        if(A!=0) {
            ans += 1;
            A--;
        }
        else if(B!=0) {
            B--;
        }
        else if(C!=0) {
            ans += -1*(K-i);
            break;
        }
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 3636
#include <bits/stdc++.h>
typedef long long ll;
#define rep(i,n) for(ll i=0;i<(n);i++)
#define repr(i,n) for(ll i=(n-1);i>=0;i--)
#define pb push_back
#define mp make_pair
#define all(x) x.begin(),x.end()
#define br cout << "\n";
using namespace std;
const int INF = 1e9;
const int MOD = 1e9+7;
using Graph = vector<vector<ll>>;
template<class T> inline bool chmin(T &a, T b) { if(a > b){ a = b; return true;} return false;}
template<class T> inline bool chmax(T &a, T b) { if(a < b){ a = b; return true;} return false;}

// 0 false, 1 true 
// string to int : -48
// ceil(a)  1.2->2.0
// c++17	g++ -std=c++17 a.cpp

int main() {
    std::cout << std::fixed << std::setprecision(15);
    ll n, k;
    cin >> n >> k;

    ll tmp = n / k;
    n -= tmp * k;
    cout << min(n, abs(n-k)) << endl;
    /*

    ll ans = 0;
    while(n >= 0){
        n = n-k;
    }

    n = n * (-1);
    ll tmp = abs(n - k);

    cout << min(n, tmp) << endl;
    */

}

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

#define pb push_back
#define ll unsigned long long
#define maxn 100005
#define fr(i,j,k) for(int i=j;i<k;i++)
#define f(n) fr(i,0,n)
#define f1(n) fr(i,1,n+1)
#define ms(i) memset(i,0,sizeof(i));
#define F first
#define S second
const ll mod = 998244353;
    
int main(){
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int n;
    cin >> n;
    ll ans = 0;
    ll sum = 0;
    f (n) {
        ll x;
        cin >> x;
        sum += x;
        ans -= x * x;
    }
    ans += sum * sum;
    ans /= 2;
    cout << ans << '\n';
}

Measured memory_bytes: 384
#include <bits/stdc++.h>
using namespace std;
typedef long long LL;
const LL INF=1LL<<60;
LL A[4000];
LL dp[4000][4000];
int N;
LL solve(int l,int r) {
    if(l==r) return 0;
    LL &res=dp[l][r];
    if(res!=INF) return res;
    if((r-l)%2==N%2) {
        return res=max(solve(l+1,r)+A[l],solve(l,r-1)+A[r-1]);
    }else {
        if(A[l]>=A[r-1]) return res=solve(l+1,r); else return res=solve(l,r-1);
    }
}
int main() {
    scanf("%d",&N);
    for(int i=0;i<N;i++) {
        scanf("%lld",&A[i]);
        A[i+N]=A[i];
    }
    fill((LL*)dp,(LL*)(dp+4000),INF);
    LL ans=0;
    for(int i=0;i<N;i++) {
        ans=max(ans,solve(i,i+N));
    }
    printf("%lld\n",ans);
}

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

const int maxN = 1e6 + 10;

int n;
int cnt[3], p[3];
int b[maxN + 1], a[maxN + 1];
bool flag[maxN + 1];
char s[maxN + 1];

inline bool comp(int a, int b) { return cnt[a] < cnt[b]; }

inline void build()
{
	int t = n; n = 0;
	for(int i = 1; i <= t; i++)
		if(!flag[i]) a[++ n] = a[i];
	for(int i = 1; i <= n; i++) flag[i] = false;
}

inline void delc()
{
	if(cnt[ p[1] ] == cnt[ p[2] ]) return;
	int l = 1, r;
	while(l <= n)
	{
		if(a[l] == p[0]) l ++;
		if(l > n) break;
		r = l + 1;
		while(a[r] != p[0] && r <= n) r ++;
		r --;
		if(l != r || l == 1 || r == n)
		{
			if(a[l] == p[2] && !flag[l])
			{
				flag[l] = true;
				cnt[ p[2] ] --;
				if(cnt[ p[1] ] == cnt[ p[2] ]) break;
			}
			if(a[r] == p[2] && !flag[r])
			{
				flag[r] = true;
				cnt[ p[2] ] --;
				if(cnt[ p[1] ] == cnt[ p[2] ]) break;
			}
		}
		l = r + 1;
	}
	build();
	if(cnt[ p[1] ] == cnt[ p[2] ]) return;
	for(int i = 1; i < n; i++)
	{
		if(flag[i]) continue;
		if(a[i] == p[0] && a[i + 1] == p[2])
		{
			flag[i] = flag[i + 1] = true;
			cnt[ p[0] ] --; cnt[ p[2] ] --;
			if(cnt[ p[1] ] == cnt[ p[2] ]) break;
		}
	}
	build();
}

inline void get()
{
	if(cnt[ p[0] ] == cnt[ p[1] ]) return;
	int l = 1, r;
	while(l <= n)
	{
		if(a[l] == p[0]) l ++;
		if(l > n) break;
		r = l + 1;
		while(a[r] != p[0] && r <= n) r ++;
		r --;
		int len = r - l + 1, fk = 0;
		for(int i = l; i < r; i++)
			if(a[i] == p[1] && a[i + 1] == p[2])
			{
				if(l > 1 && r < n && len <= 2) continue;
				flag[i] = flag[i + 1] = true;
				cnt[ p[1] ] --; cnt[ p[2] ] --;
				len -= 2;
				if(cnt[ p[0] ] == cnt[ p[1] ]) { fk = 1; break; }
			}
		if(fk) break;
		l = r + 1;
	}
	build();
}

int main()
{
	scanf("%s", s + 1);
	
	n = strlen(s + 1);
	a[0] = -1;
	for(int i = 1; i <= n; i++)
	{
		a[i] = s[i] - 'A';
		if(a[i] == a[i - 1]) flag[i] = true;
	}
	build();

	for(int i = 1; i <= n; i++) cnt[ a[i] ] ++;
	for(int i = 0; i < 3; i++) p[i] = i;
	sort(p, p + 3, comp);

	delc();
	get();

	for(int i = 1; i <= n; i++) putchar(a[i] + 'A');
	puts("");
	return 0;
}


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

using namespace std;

int main(){
    long long N, A, B;
    cin >> N >> A >> B;

    if(A > B) printf("0\n");
    else if(N == 1) {
        if(A == B) printf("1\n");
        else printf("0\n");
    }
    else printf("%lld\n", (B-A)*(N-2) + 1);

    return 0;
}

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

int main()
{
    long long n, k;
    cin >> n >> k;

    long long count = 0;
    for(long long i = k; i <= n+1; i++)
    {
        long long min = i * (i - 1) / 2;
        long long max = n * i - min;
        count += (max - min + 1);
    }

    long long d = 1000000000 + 7;
    cout << count % d;

    return 0;
}


Measured memory_bytes: 3632
import Data.List                                                                                                           
                                                                                                                           
main :: IO ()                                                                                                              
main = do                                                                                                                  
  n <- read <$> getLine :: IO Int                                                                                          
  as <- map read . words <$> getLine :: IO [Int]                                                                           
                                                                                                                           
  let avg = sum as                                                                                                         
  print . snd . head . sort . mapfst (abs . subtract avg . (*n)) $ zip as [0..]                                            
                                                                                                                           
mapfst :: (a -> b) -> [(a,c)] -> [(b,c)]                                                                                   
mapfst _ [] = []                                                                                                           
mapfst f ((x,y):xys) = (f x,y):mapfst f xys

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

typedef long long ll;
const int INF = 1e9;
const int MOD = 1e9 + 7;
const ll LINF = 1e18;
#define y0 y3487465
#define y1 y8687969
#define j0 j1347829
#define j1 j234892
#define next asdnext
#define prev asdprev
#define dump(x)  cout << #x << " = " << (x) << endl;	//debug
#define SZ(x) ((int)(x).size())
#define REP(i, n) for(ll i = 0; i < (n); i++)
#define REPR(i, n) for (ll i = (n); i >= 0; i--)
#define FOR(i, a, b) for (ll i = (a); i <= (b); i++)
#define ps(s) cout << #s << endl;
#define pv(v) cout << (v) << endl;
#define ALL(a)  (a).begin(),(a).end()

int main() {
	int n;
	string s, t;
	cin >> n >> s >> t;
	string res;
	FOR(i, 0, n-1) {
		res.push_back(s[i]);
		res.push_back(t[i]);
	}
	pv(res)
	return(0);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define modulo 1000000007
#define mod(mod_x) ((((long long)mod_x+modulo))%modulo)
#define Inf 1000000000

template <typename T>
struct BIT{
	vector<T> v;
	int n;
	
	const T init_value = 0;
	
	BIT(int sz){
		n=sz+1;
		v.resize(n,init_value);
	}
	
	BIT(vector<T> &x){
		n=x.size()+1;
		v.resize(n,init_value);
		
		for(int i=0;i<x.size();i++){
			add(i,x[i]);
		}
		
	}

	void add(int x,T val){
		x++;
		while(x < n){
			v[x] = func(v[x],val);
			x += x & (-x);
		}
	}
	
	//区間[0,r)におけるクエリ処理
	T query(int r){
		T ret = init_value;
		
		while(r>0){
			ret = func(v[r],ret);
			r -= r & (-r);
		}
		
		return ret;
	}
	
	T query(int l,int r){
		return query(r) - query(l);
	}
	
	T func(T a,T b){
		return a+b;
	}
	
};

vector<pair<int,int>> calc(vector<int> &Bind,vector<int> &Wind,int c){
	BIT<int> B(2*Bind.size());
	for(int i=0;i<2*Bind.size();i++)B.add(i,1);
	for(int i=0;i<c;i++){
		B.add(Bind[i],-1);
	}
	
	vector<pair<int,int>> ret;
	for(int i=0;i<=Wind.size();i++){
		pair<int,int> t(-1,-1);
		if(c!=Bind.size()){
			t.first = B.query(0,Bind[c]);
		}
		if(i!=Wind.size()){
			t.second = B.query(0,Wind[i]);
		}
		ret.push_back(t);
		if(i!=Wind.size()){
			B.add(Wind[i],-1);
		}
	}
	return ret;
}


int main(){
	int N;
	cin>>N;
	
	vector<int> Bind(N),Wind(N);
	
	for(int i=0;i<2*N;i++){
		char c;
		int x;
		cin>>c>>x;
		x--;
		if(c=='B')Bind[x] = i;
		else Wind[x] = i;
	}
	
	vector<vector<pair<int,int>>> add(N+1);
	
	for(int i=0;i<=N;i++){
		add[i] = calc(Bind,Wind,i);
	}
	
	vector<vector<int>> dp(N+1,vector<int>(N+1,Inf));
	dp[0][0] = 0;
	
	for(int i=0;i<=N;i++){
		for(int j=0;j<=N;j++){
			if(i!=N){
				dp[i+1][j] = min(dp[i+1][j],dp[i][j]+add[i][j].first);
			}
			if(j!=N){
				dp[i][j+1] = min(dp[i][j+1],dp[i][j]+add[i][j].second);
			}
		}
	}
	
	cout<<dp.back().back()<<endl;
	
	return 0;
}

Measured memory_bytes: 48128
n,y=map(int,input().split())
    
n10max=y//10000
n5max=y//5000

iskip=0
for n10 in range(n10max,-1,-1):
    if n10*10000>y:
        continue
    for n5 in range(min(n-n10,n5max)+1):
        n1=n-n10-n5
        if n10*10000+n5*5000+n1*1000==y and n1>=0:
            print(n10,n5,n-n10-n5)
            iskip=1
            break
        else:
            continue
    if iskip==1:
        break
    else:
        continue
        
if iskip==0:
    print(-1,-1,-1)



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

#include <iostream>
#include <iomanip>
#include <vector>
#include <cmath>
// #include <map>
// #include <string>
// #include <algorithm>
// #include <numeric>
// #include <limits>

using namespace std;

int main() {
	double r;
	double pi = M_PI;
	cin >> r;
	cout << fixed << setprecision(6);
	cout << pi * r * r << " " << 2 * pi * r << endl;
	return 0;
}



Measured memory_bytes: 3252
#include <iostream>
#include <cstring>

using namespace std;

int main()
{
    string str;
    cin>>str;
    int len=str.size();
    cout<<str;
    if(str[len-1]=='s'){
        cout<<"es"<<endl;
    }else{
        cout<<"s"<<endl;
    }
    return 0;
}


Measured memory_bytes: 3132
N = int(input())
Bs = list(map(int, input().split()))
 
As = [ None for _ in range(N) ]

As[0] = Bs[0]
for i in range(1, N-1):  
  As[i] = min(Bs[i-1], Bs[i])

As[-1] = Bs[-1]

print(sum(As))

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
#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++)
#define Clear(a) a = decltype(a)();
typedef long long ll;
typedef vector<vector<ll>> vvl;
typedef vector<ll> vl;
typedef vector<vector<char>> vvc;
typedef vector<char> vc;
typedef pair<ll,ll> pll;
typedef priority_queue<string> priquestring;
typedef priority_queue<int> priqueint;
typedef priority_queue<ll> priquell;
typedef priority_queue<char> priquechar;
typedef priority_queue<string,vector<string>,greater<string>> rpriquestring;
typedef priority_queue<int,vector<int>,greater<int>> rpriqueint;
typedef priority_queue<ll,vector<ll>,greater<ll>> rpriquell;
typedef priority_queue<char,vector<char>,greater<char>> rpriquechar;
ll max(ll x,ll y){
if(x>y)return x;
else return y;
}
ll min(ll x,ll y){
  return x+y-max(x,y);
}

const ll big=1000000007;
int exp(int x,int y){
    if(y==0)return 1;//0^0=1
    if(x==1||x==0)return x;
    if(y%2==1)return (exp(x,y-1)*x)%big;
    int t=exp(x,y/2);
    return (t*t)%big;
}
void chmin(ll a,ll b){
    if(a>b)a=b;
    return;
}

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

void next(vector<int> &use){
    bool ans=true;
    int cnt=0;
    while(ans){
        use[cnt]++;
        if(use[cnt]<=2)ans=false;
        else use[cnt]=0;
        cnt++;
    }
}

int main(){
    ios::sync_with_stdio(false);
    std::cin.tie(nullptr);
    cout << fixed << setprecision(10);
    /*--------------------------------*/
    
  ll a; cin >> a;
  string b;cin >> b;
  int k=0;
  k+=(b[0]-'0')*100;
  k+=(b[2]-'0')*10;
  k+=(b[3]-'0');
  a*=k;
  cout << a/100 << endl;
}

Measured memory_bytes: 3660
#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-1); i >= 0; --i)

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

typedef long long ll;
typedef complex<double> P;

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

const double PI = 3.14159265358979323;

int main(){
    int A, B, H, M;
    cin >> A >> B >> H >> M;

    int m = 60 * H + M;
    double angle1 = 0.5 * m, angle2 = 6 * m;
    while (360 < angle1) angle1 -= 360;
    while (360 < angle2) angle2 -= 360;

    P x, y;
    if (angle1 < 90) {
        double rad = angle1 * (PI/180);
        x = P(cos(rad) * A, -sin(rad) * A);
    } else if (angle1 < 180) {
        double rad = (180 - angle1) * (PI/180);
        x = P(-cos(rad) * A, -sin(rad) * A);
    } else if (angle1 < 270) {
        double rad = (angle1 - 180) * (PI/180);
        x = P(-cos(rad) * A, sin(rad) * A);
    } else {
        double rad = (360 - angle1) * (PI/180);
        x = P(cos(rad) * A, sin(rad) * A);
    }

    if (angle2 < 90) {
        double rad = angle2 * (PI/180);
        y = P(cos(rad) * B, -sin(rad) * B);
    } else if (angle2 < 180) {
        double rad = (180 - angle2) * (PI/180);
        y = P(-cos(rad) * B, -sin(rad) * B);
    } else if (angle2 < 270) {
        double rad = (angle2 - 180) * (PI/180);
        y = P(-cos(rad) * B, sin(rad) * B);
    } else {
        double rad = (360 - angle2) * (PI/180);
        y = P(cos(rad) * B, sin(rad) * B);
    }
    
    printf("%.10f\n", abs(x - y));
}

Measured memory_bytes: 3968
#include <cstdio>

int n, m, k;

int main() {
  scanf("%d%d%d", &n, &m, &k);
  for (int i = 0; i <= n; ++i)
    for (int j = 0; j <= m; ++j)
      if (i * m + j * n - 2 * i * j == k) return puts("Yes"), 0;
  puts("No");
  return 0;
}


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

#define int long long



typedef long long ll;
typedef long double ld;








signed main(){
	ios::sync_with_stdio(0);
    cin.tie(0);cout.tie(0);
    int N,K;
    cin>>N>>K;
    vector<int> num(N+1,0);
    int ans = N;
    for(int i = 0;i < K;i++){
    	int x;
    	cin>>x;
    	while(x--){
    		int t;
    		cin>>t;
    		if(num[t]) continue;
    		else{
    			ans--;
    			num[t] = 1;
			}
		}
	}
	cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 3656
#include <bits/stdc++.h>
using namespace std;
#define rep(i, j) for(int i=0; i < (int)(j); i++)
#define repeat(i, j, k) for(int i = (j); i < (int)(k); i++)
#define all(v) v.begin(),v.end()
template<class T> istream& operator >> (istream &is , vector<T> &v) { for(T &a : v) is >> a; return is; }
int main() {
    int K, T; cin >> K >> T;
    vector<int> A(T); cin >> A;
    sort(all(A));
    reverse(all(A));

    list<int> l;
    rep(i, A[0]) l.push_back(0);
    auto pos = l.begin();
    repeat(i, 1, T) {
        rep(j, A[i]) {
            pos++;
            l.insert(pos, i);
            if(pos == l.end()) pos = l.begin();
        }
    }

    int ans = 0;
    int pre = -1;
    for(auto i : l) {
        ans += pre == i;
        pre = i;
    }    
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 512
//https://atcoder.jp/contests/keyence2019/tasks/keyence2019_e 
#include <bits/stdc++.h>
using namespace std;
//#pragma GCC optimize("Ofast")
typedef long long ll;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef unsigned long long ull;
#define fst first
#define sed second
#define pb push_back
#define mp make_pair
#define rt register int
#define all(it) it.begin(), it.end()
#define rep(it, f, e) for (rt it = f; it <= e; ++it)
#define per(it, f, e) for (rt it = f; it >= e; --it)
const int MAXN = 2e5 + 10;
struct Dsu {
	int par[MAXN];
	Dsu() {
		rep (i, 1, MAXN - 1) {
			par[i] = i;
		}
	}
	inline int find(int x) {
		return x == par[x] ? x : par[x] = find(par[x]);
	}
	inline void mry(int a, int b) {
		par[find(a)] = find(b);
	}
	inline bool tog(int a, int b) {
		return find(a) == find(b);
	}
}	dsu;
ll A[MAXN], n, d;
vector<pair<ll,pii> > edge;
inline void solve(int l, int r) {
	if (l == r) return;
	int m = (l + r) >> 1;
	ll ml = 1e18, li = 0;
	rep (i, l, m) {
		if (ml > A[i] - i * d) {
			ml = A[i] - i * d;
			li = i;
		}
	}
	ll mr = 1e18, ri = 0;
	rep (i, m + 1, r) {
		if (mr > A[i] + i * d) {
			mr = A[i] + i * d;
			ri = i;
		}
	}
	rep (i, l, m) {
		edge.pb(mp(A[i] - i * d + mr,mp(i, ri)));
	}
	rep (i, m + 1, r) {
		edge.pb(mp(A[i] + i * d + ml,mp(i, li)));
	}
	solve(l, m);
	solve(m + 1, r);
}
int main() {
	cin >> n >> d;
	rep (i, 1, n) {
		cin >> A[i];
	}
	solve(1, n);
	sort(all(edge));
	ll ans = 0;
	for (auto e : edge) {
	//	cerr << e.sed.fst << ' ' << e.sed.sed <<endl;
		if (!dsu.tog(e.sed.fst, e.sed.sed)) {
			ans += e.fst;
			dsu.mry(e.sed.fst, e.sed.sed);
		}
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 70240
#include <cstdio>
#include <algorithm>

int main() {
  int X;
  scanf("%d", &X);

  int res = 1;
  for (int i = 2; i <= 32; ++i)
    for (int j = i*i; j <= X; j *= i)
      res = std::max(res, j);

  printf("%d\n", res);
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define REP(i,a) for(int i = 0; i < (a); i++)
#define ALL(a) (a).begin(),(a).end()
typedef long long ll;
typedef pair<int, int> P;
const int INF = 1e9;
const int MOD = 1e9 + 7;

signed main(){
    int n;
    cin >> n;
    int l[2 * n];
    REP(i,2 * n){
        cin >> l[i];
    }
    sort(l,l + 2 * n);
    reverse(l,l + 2 * n);
    int ans = 0;
    REP(i,n){
        ans += l[2 * i + 1];
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ABC142
{
    class A
    {
        static void Main(string[] args)
        {
            double N = double.Parse(Console.ReadLine());
            Console.WriteLine(((int)N / 2 + (int)N % 2) / N);
        }
    }
}


Measured memory_bytes: 13140
#include<stdio.h>
#define M 2000

int main(){

  int i,j,n,q,num,hai[M+1]={0};
  scanf("%d",&n);


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

      for(j=M-num;0<j;j--){
        if(hai[j]){
          hai[j+num]= 1;
        }
      }

    hai[num]=1;
  }

  scanf("%d",&q);


  for(i=0;i<q;i++){
    scanf("%d",&num);

    if(hai[num]){
      printf("yes\n");
    }
    else printf("no\n");
  }

  
  return 0;
}



Measured memory_bytes: 2044
#include<bits/stdc++.h>
#define rep(i,n)for(int i=0;i<n;i++)
using namespace std;

int g[100][100];
int main(){
	int n;cin>>n;
	rep(i,n){
		int u,k;cin>>u>>k;u--;
		rep(j,k){
			int v;cin>>v;v--;
			g[u][v]=1;
		}
	}
	rep(i,n){
		rep(j,n){
			if(j)cout<<" ";
			cout<<g[i][j];
		}
		cout<<endl;
	}
}

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

#define io ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0)
#define int long long
#define endl '\n'
#define eps  1e-9
const double pi=acos(-1);
const int mod=1e9+7;
//____________________

int toleft(vector<int> &v,int x)
{
  auto it=lower_bound(v.begin(), v.end(),x);
  --it;
  return *it;
}

int toright(vector<int> &v,int x)
{
  auto it=lower_bound(v.begin(), v.end(),x);
  return *it;
}

int32_t main()
{ 
  io;
 
  
  int a,b,q,x;
  cin>>a>>b>>q;

  vector<int> s,t,qry(q),ans(q);
 
  s.push_back(-1e12);
  s.push_back(-1e11);
  for(int i=0;i<a;i++)
  {
    cin>>x;
    s.push_back(x);
  }
  s.push_back(1e11);
  s.push_back(1e12);
  

  t.push_back(-1e12);
  t.push_back(-1e11);
  for(int i=0;i<b;i++)
  {
    cin>>x;
    t.push_back(x);
  }
  t.push_back(1e11);
  t.push_back(1e12);

  for(int run=0;run<q;run++)
  {
    cin>>qry[run];
    x=qry[run];
    int dis=1e18;

    int rs=toright(s,x),ls,rt,lt;
    
    lt=toleft(t,rs);
    if(lt>=x and lt<=rs)
        dis=min(dis,rs-x);
    else
        dis=min(dis,(rs-x)+(rs-lt));
    
    rt=toright(t,rs);
    dis=min(dis,rt-x);

    ls=toleft(s,x);

    rt=toright(t,ls);

    if(rt>=ls and rt<=x)
      dis=min(dis,x-ls);
    else
      dis=min(dis,(x-ls)+(rt-ls));

    lt=toleft(t,ls);
    dis=min(dis,x-lt);
    
    ans[run]=dis;
  }

  for(int run=0;run<q;run++)
  {
    int dis=1e18;
    x=qry[run];
    int rs,ls,rt,lt;

    rt=toright(t,x);
    ls=toleft(s,rt);

    if(ls>=x and ls<=rt)
      dis=min(dis,rt-x);
    else
      dis=min(dis,(rt-x)+(rt-ls));

    rs=toright(s,rt);
    dis=min(dis,rs-x);

    lt=toleft(t,x);
    rs=toright(s,lt);
    if(rs>=lt and rs<=x)
      dis=min(dis,x-lt);
    else
      dis=min(dis,(x-lt)+(rs-lt));

    ls=toleft(s,lt);
    dis=min(dis,x-ls);

    ans[run]=min(ans[run],dis);
    
  }

  for(int i=0;i<q;i++)
    cout<<ans[i]<<endl;

 return 0;
}

Measured memory_bytes: 4596
#include <iostream>
#include <algorithm>
#include <iomanip>
#include <string>
#include <vector>
#include <math.h>
#include <queue>
#include <map>
#define ll long long
const int MOD = 1e9+7;
using namespace std;


int main(){
	int n, r;
	cin >> n >> r;
	if (n >= 10) cout << r << endl;
	else cout << r + 100*(10-n) << endl;
	return 0;
}




Measured memory_bytes: 256
#pragma GCC optimize("O3")
#pragma comment(linker, "/stack:200000000")
#pragma GCC optimize("Ofast")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define ld  double
#define pii pair<int,int>
#define pip pair<int,pii>
#define ppi pair<pii,int> 
#define ppp pair<pii,pii>
#define pb push_back
#define N 10003
#define inf (ll)1e9+11
#define warmup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);
int mod=1e9+7;
int cnt[N];

signed main()
{
    warmup
    
    int n,p;
    cin>>n>>p;
    string s;
    cin>>s;
    int i,j=1,sum=0;
    ll ans=0;
    if(p==2 or p==5)
    {
        for(i=0;i<n;++i)
            if((s[i]-'0')%p==0)
                ans+=i+1;
    }   
    else
    {
        cnt[0]=1;
        for(i=n-1;~i;--i)
        {
            sum=(sum+(s[i]-'0')*j)%p;
            ans+=cnt[sum]++;
            j*=10, j%=p;
        }   
    }   
    cout<<ans;
    
    return 0;
}


Measured memory_bytes: 720
str = input()

d = {}
for c in str:
    if c in d: d[c] += 1
    else: d[c] = 1

l = []
for v in d.items():
    l.append(v)

if l[0][1] == 2 and l[0][1] == l[1][1]: print("Yes")
else: print("No")

Measured memory_bytes: 3060
#include<bits/stdc++.h>
using namespace std;
int main()
{
  int n,sum=0;
  cin>>n;
  int l[n],r[n];
  for(int i=0;i<n;i++){
    cin>>l[i]>>r[i];
    sum = sum+abs(l[i]-r[i])+1;
  }
  cout<<sum<<endl;
} 

Measured memory_bytes: 3596
#include <iostream>
#include <vector>
#include <algorithm>
#include <string>
#include <iomanip>
#include <map>
#include <set>
#include <ctype.h>
#include <numeric>
using namespace std;

typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> Pll;
const ll MOD = 1e9 + 7;
const int INF = 1e9;

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

int main() {
  int h, w; cin >> h >> w;
  vector<string> ss;
  string str;
  for (int i = 0; i < h; ++i) {
    cin >> str; ss.push_back(str);
  }
  for (int i = 0; i < w + 2; ++i) cout << "#";
  cout << endl;
  for (int i = 0; i < h; ++i) {
    cout << "#" << ss[i] << "#" << endl;
  }
  for (int i = 0; i < w + 2; ++i) cout << "#";
  cout << endl;
  return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define df 0
#define MAX 100010
#define MOD 1000000007
#define min(a,b) ((a)<(b)?a:b)
#define max(a,b) ((a)>(b)?a:b)

#define MAX 100010


int h[2][MAX];
int a[2][MAX];


int main(){
  int i,j,n;
  scanf("%d",&n);
  for(j=0;j<2;j++){
    for(i=0;i<n;i++){
      scanf("%d",&(a[j][i]));
    }
  }
  long int s=1;

  int m=0;
  for(i=0;i<n;i++){
    if(m<a[0][i]){
      m=a[0][i];
      h[0][i]=m;
      h[1][i]=m;
    }else{
      h[0][i]=1;
      h[1][i]=m;
    }
    if(df) printf("%d ",m);
  }
    if(df) printf("h\n");
  if(df){
    for(j=0;j<2;j++){
      for(i=0;i<n;i++){
	printf("%d ",h[j][i]);
      }
      printf("\n");
    }
    printf("\n");
  }
  m=0;
  for(i=n-1;i>=0;i--){
    if(m<a[1][i]){
      m=a[1][i];
      h[0][i]=max(m,h[0][i]);
      h[1][i]=min(m,h[1][i]);
    }else{
      h[1][i]=min(m,h[1][i]);
    }
  }

  if(df){
    for(j=0;j<2;j++){
      for(i=0;i<n;i++){
	printf("%d ",h[j][i]);
      }
      printf("\n");
    }
    printf("\n");
  }
  
  for(i=0;i<n;i++){
    long int k=h[1][i]-h[0][i]+1;
    if(k>0){
      s*=k;
      s%=MOD;
    }else{
      s=0;
      break;
    }
  }

  printf("%d",s);
  return 0;
}


/// confirm df==0 ///


Measured memory_bytes: 1664
#define _USE_MATH_DEFINES
#include <bits/stdc++.h>

using namespace std;

#define FOR(i,a,b) for(int i = (a); i < (b); ++i)
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()

inline int toInt(string s) {int v; istringstream sin(s);sin>>v; return v;}

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector< vector<int> > Mat;
typedef tuple<int, int, int, int> T;

const int MOD = (int)1e9+7;
const int INF = (int)1e9;
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};

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

    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];
    vector< vector<int> > ans(h, vector<int>(w));
    
    int k = 0, l = 0;
    rep(i, n){
        rep(j, a[i]){
            ans[k][l] = i+1;
            l++;
            if(l == w){
                k++;
                l = 0;
            }
        }
    }

    for(int i = 1; i < h; i+=2){
        reverse(all(ans[i]));
    }
    
    rep(i, h){
        rep(j, w){
            cout << ans[i][j] << (j != w-1 ? " " : "");
        }
        cout << endl;
    }

    return 0;
}

Measured memory_bytes: 384
#include <cstdio>
#include <algorithm>
#include <iostream>
#include <vector>
#include <map>
#include <unordered_map>
#include <cmath>

using namespace std;
typedef long long ll;
#define INF int(1e9)
#define REP(i, n) for(int i = 0; i < (int)(n); i++)
#define REPR(i, n) for(int i = n - 1; i >= 0; i--)
#define REPONE(i, n) for(int i = 1; i <= (int)(n); i++)
#define EACH(i, mp) for(auto i:mp)
#define FOR(i, m, n) for(int i = m;i < n;i++)

const int MAX_N = 100;
int N, A[MAX_N];

void solve() {
}

int main() {
    cin >> N;
    int a = 0, b = INF, temp;
    REP(i, N) {
        cin >> temp;
        a = max(temp, a);
        b = min(temp, b);
    }
    cout << a - b << endl;
    solve();
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <vector>
using namespace std;
#define MAX 101
#define NIL -1

int pre[MAX],in[MAX];
vector<int> post;
int n,pos;
void rec(int l,int r){
    if(l>=r)
        return ;
    int c = pre[pos++];
    int m;
    for(int i=0;i<n;i++){
        if(in[i]== c)
            m = i;
    }
    rec(l,m);
    rec(m+1,r);
    post.push_back(c);
}
void solve(){
    pos = 0;
    rec(0,n);
    for(int i=0;i<n;i++){
        if(i) cout<<" ";
        cout<<post[i];
    }
    cout<<endl;
}
int main()
{
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>pre[i];
    }
    for(int i=0;i<n;i++){
        cin>>in[i];
    }
    solve();
    return 0;
}



Measured memory_bytes: 3152
#include<stdio.h>
#include<math.h>
typedef struct{
	double x;
	double y;
}pt;
void koch(int,pt,pt);
int main(){
  pt pt1 = {0.0, 0.0}, pt2 = {100.0, 0.0};
  int n;
  scanf("%d", &n);
  printf("%f\t%f\n", pt1.x, pt1.y);
  koch(n, pt1, pt2);
  printf("%f\t%f\n", pt2.x, pt2.y);
  return 0;
}
void koch(int n,pt pt1,pt pt2){
  pt a,b,c;
  if(n == 0) return;
  a.x = (2.0*pt1.x+1.0*pt2.x)/3.0;
  a.y = (2.0*pt1.y+1.0*pt2.y)/3.0;
  b.x = (1.0*pt1.x+2.0*pt2.x)/3.0;
  b.y = (1.0*pt1.y+2.0*pt2.y)/3.0;
  c.x = (b.x-a.x)*cos(M_PI/3)-(b.y-a.y)*sin(M_PI/3)+a.x;
  c.y = (b.x-a.x)*sin(M_PI/3)+(b.y-a.y)*cos(M_PI/3)+a.y;

  koch(n-1,pt1,a);
  printf("%f\t%f\n",a.x,a.y);
  koch(n-1,a,c);
  printf("%f\t%f\n",c.x,c.y);
  koch(n-1,c,b);
  printf("%f\t%f\n",b.x,b.y);
  koch(n-1,b,pt2);
}


Measured memory_bytes: 2060
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;

public class Main {

    public static void main(String[] args) {
        BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
        try {
            String str = br.readLine();
            String input[] = str.split(" ");
            int L = Integer.valueOf(input[0]);
            int R = Integer.valueOf(input[1]);
            
            int result = 2018;

          if(R-L >2019){
            R = L+2019;
          }
          if(L > 2019 && L/2019 == R/2019){
            L %= 2019;
            R %= 2019;
          }

            for(int i = L; i<R; i++) {
				if(i%2019 == 0 || result == 0){
                  result = 0;
                  break;
                }
              for(int j = i+1; j<=R; j++) {
                  int N = i* j;
                    if( N % 2019 < result && N % 2019 > 0 ) {
                        result = N % 2019;
                    } else if(N%2019 == 0){
                      result = N % 2019;
                      break;
                    }
                }
            }
            System.out.println(result);
            
            
        }catch(IOException e) {
            
        }
    }

}

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


int main(void) {
	string s;
	cin >> s;
	int sum = 0;
	for (int i = 0; i < 3; i++) {
		if (s[i] == '1') {
			sum++;
		}
	}
	cout << sum;
	
	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define int long long
#define ll long long
#define FOR(i,a,b) for(int i=(a); i<=(b); i++)
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define chmin(a,b) if((a)>(b)) (a)=(b);
#define chmax(a,b) if((a)<(b)) (a)=(b);
#define vi vector<int>
#define pii pair<int,int>
#define all(v) (v).begin(),(v).end()
#define allr(v) (v).rbegin(),(v).rend()
#define pb push_back
#define pf push_front
int gcd(int a,int b){/*a>=0,b>=0,￢(a=b=0)*/
  while(min(a,b)>0){if(a<b)swap(a,b);a%=b;}return max(a,b);
}
int dx[]={1,0,-1,0,1,-1,-1,1};
int dy[]={0,1,0,-1,1,1,-1,-1};
const int MOD = 1e9+7;
const long long INF = 1e18+10;

/*--------------------------------------------------------------------*/
int modpow(int x,int n){
	int res=1;
	while(n>0){
		if(n&1) res=(res*x)%MOD;
		 x=(x*x)%MOD;
		 n>>=1;
	 }
	 return res;
}
int ncr(int n,int r){
	int res=1,fact=1;
	FOR(i,1,r) fact=(fact*i)%MOD;
	rep(i,r) res=(res*(n-i))%MOD;
	res=(res*modpow(fact,MOD-2))%MOD;
	return res;
}
signed main(){
	int s;
	cin>>s;
	int ans=0;
	for(int i=1;3*i<=s;i++){
		//i項の数列
		int rest=s-3*i;
		ans+=ncr(rest+i-1,rest);
		ans%=MOD;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3620
#include <stdio.h>
int isPrime(int n){
    if(n==1)return 0;
    for(int i=2;i*i<=n;i++){
        if(n%i==0)return 0;
    }
    return 1;
}
int main(void){
    int sosu[100001];
    sosu[0]=0;
    for(int i=1;i<100001;i++){
        if(i%2==0)sosu[i]=0;
        else sosu[i]=isPrime(i)&&isPrime((i+1)/2);
    }
    for(int i=1;i<100001;i++)sosu[i]+=sosu[i-1];
    int Q;
    scanf("%d",&Q);
    for(int i=0;i<Q;i++){
        int l,r;
        scanf("%d %d",&l,&r);
        printf("%d\n",sosu[r]-sosu[l-1]);
    }
    return 0;
}


Measured memory_bytes: 896
/*
                Author: Ankit Kaul
**********************Code Belongs to Respective Author Only************************************
*/
/*#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast")
#pragma GCC optimize("unroll-loops")
#pragma GCC target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")*/
#include <bits/stdc++.h>
#define endl       '\n'
#define PI          3.141592653589
#define jaldi       ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
#define M           1000000007
#define int         long long int
#define inf         INT_MAX
#define pb          emplace_back
#define pf          emplace_front
#define pii         pair<int,int>
#define vi          vector<int>
#define vii         vector<pii>
#define mi          map<int,int>
#define mii         map<pii,int>
#define all(a)      (a).begin(),(a).end()
#define rall(a)     (a).rbegin(),(a).rend()
using namespace std;
int gcd(int a,int b) { return b == 0 ? a : gcd(b, a % b); }
int power(int x,int n){
    int result=1;
    while(n>0)
    {   if(n % 2 ==1)
        result=(result * x) % M;
        x=(x*x)% M;
        n=n/2;
    }
return result % M;
}      
bool isPrime(int n) 
{ 
if (n <= 1) 
    return false; 
if (n <= 3) 
    return true; 
if (n % 2 == 0 || n % 3 == 0) 
    return false; 
for (int i = 5; i * i <= n; i = i + 6) 
    if (n % i == 0 || n % (i + 2) == 0) 
        return false; 
return true; 
} 
signed main()
{   jaldi
    int n;
    cin>>n;
    int a[n],i;
    for(i=0;i<n;i++)
    cin>>a[i];
    sort(a,a+n);
    bool w=true;
    for(i=0;i<n-1;i++)
    {   if(a[i]==a[i+1])
        w=false;
    }
    if(w)
    cout<<"YES";
    else
    cout<<"NO";    
}

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

const int WIDTH_LIMIT = 1500000;

int main()
{
	int m, n;
	while( cin >> m >> n && ( m || n ) ){
		int memo[ 100 ][ 100 ] = {0};
		set< int > width;
		for( int i = 0; i < n; ++i ){
			cin >> memo[ i ][ i ];
			width.insert( memo[ i ][ i ] );
		}
		for( int i = 0; i < n - 1; ++i ){
			for( int j = i + 1; j < n; ++j ){
				memo[ i ][ j ] = memo[ i ][ j - 1 ] + memo[ j ][ j ];
				width.insert( memo[ i ][ j ] );
			}
		}
		set< int >::iterator itr = width.begin();
		while( itr != width.end() ){
			int w = *itr;
			int b = 0;
			int s = 0;
			while( b < n && s < m ){
				int p = b;
				while( p < n && memo[ b ][ p ] <= w ){
					++p;
				}
				--p;
				if( b > p ){
					break;
				}
				++s;
				b = p + 1;
			}
			if( b == n ){
				cout << w << endl;
				break;
			}
			++itr;
		}
	}

	return 0;
}

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

//#define int long long
#define all(v) (v).begin(), (v).end()
#define rall(v) (v).rbegin(), (v).rend()
#define rep(i,n) for(int i=0;i<n;++i)
#define rep1(i,n) for(int i=1;i<n;++i)
#define exrep(i, a, b) for(ll i = a; i < b; i++)
#define out(x) cout << x << endl
#define EPS (1e-7)
#define gearup ios_base::sync_with_stdio(0);cin.tie(0);cout.tie(0);

typedef long long ll;
typedef long double ld;
typedef unsigned long long ull;
typedef vector<int> vi;
typedef vector<char> vc;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef vector<string> vs;
typedef vector<pair<int,int> > vpii;
typedef vector<vector<int> > vvi;
typedef vector<vector<char> > vvc;
typedef vector<vector<bool> > vvb;
typedef vector<vector<double> > vvd;
typedef vector<vector<string> > vvs;
typedef vector<ll> vl;
typedef vector<vector<ll> > vvl;
typedef vector<vector<vector<ll> > > vvvl;
ll MOD = 1000000007;
const long long L_0 = 1LL << 60;
const int INF = 2147483647; // 2^31-1
const double PI = acos(-1);
//cout<<fixed<<setprecision(10);

template<class T> inline bool chmin(T& a, T b) {if (a > b) {a = b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b) {if (a < b) {a = b;return true;}return false;}
template<class T> void debug(T v){rep(i,v.size()) cout<<v[i]<<" ";cout<<endl;}
const ll dx[8] = {1, 1, 0, -1, -1, -1, 0, 1};
const ll dy[8] = {0, 1, 1, 1, 0, -1, -1, -1};
//以降 cin の入力元が 'input.txt' になる
//std::ifstream in("input.txt");
//std::cin.rdbuf(in.rdbuf());

signed main()
{   
    gearup;
    string s,t; cin >> s >> t;
    map<char,vi> mp;
    rep(i,s.size())mp[s[i]].push_back(i);
    rep(j,t.size()){
        if(mp[t[j]].size() == 0){
            out(-1);
            return 0;
        }
    }
    ll res = 0;
    int i_idx = 0;
    rep(j,t.size()){
        char c = t[j];
        auto itr = lower_bound(all(mp[c]),i_idx);
        if(itr == mp[c].end()){
            res += s.size() - i_idx;
            res += mp[c][0] + 1;
            i_idx = mp[c][0] + 1;
        }
        else{
            res += *itr - i_idx + 1;
            i_idx = *itr + 1;
        }
    }
    out(res);
}


Measured memory_bytes: 4164
N = str(input())
if N=='SSS':
    print(0)
if N=='SSR':
    print(1)
if N=='SRS':
    print(1)
if N=='SRR':
    print(2)
if N=='RSS':
    print(1)    
if N=='RSR':
    print(1)
if N=='RRS':
    print(2)    
if N=='RRR':
    print(3)


Measured memory_bytes: 61612
#include "bits/stdc++.h"
using namespace std;

using ll = long long;
using ld = long double;
using P = pair<int, int>;
using vi = vector<int>;
using vl = vector<ll>;
ld EPS = 1e-12;
int INF = numeric_limits<int>::max() / 2;
ll LINF = numeric_limits<ll>::max() / 2;
int MOD = 1e9 + 7;
#define rep(i,n) for(int i = 0; i < n; i++)
#define all(obj) (obj).begin(), (obj).end()
#define debug(x) cerr << #x << ": " << x << '\n'

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
	int a,b,k;
	cin >> a >> b >> k;
	rep(i,k){
		if(i % 2 == 0){
			if(a % 2 == 1){
				a--;
			}
			a /= 2;
			b += a;
		}else{
			if(b%2 == 1){
				b--;
			}
			b /= 2;
			a += b;
		}
	}
	cout << a << " " << b << endl;
}

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

#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#define MOD 1000000000 + 7
#define PI 3.14159265359

const long long INF = 100000;
typedef pair<int,int> P;
typedef long long ll;

using Graph = vector<vector<ll>>;


int main() {
	int N;
	cin >> N;
	vector<int> A(N + 1);
	for (int i = 1; i <= N; i++) {
		cin >> A[i];
	}
	map<int, int> ma;
	ll ans = 0;

	for (int i = 1; i <= N; i++) {
		ans += ma[i - A[i]];
		ma[i + A[i]]++;
	}
	cout << ans << endl;
}

Measured memory_bytes: 21116
#include <bits/stdc++.h>
using namespace std;
int main(){
    int a,b;
    cin >> a >> b;
    int sum = 1;
    int ans = 0;
    while(sum<b){
        if(sum==1){
            sum=a;
        }else{
            sum--;
            sum+=a;
        }
        ans++;
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3636
#include <iostream>
#include <string>
#include <vector>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <cmath>
#include <iomanip>
#include <algorithm>
using namespace std;
using ll = long long;

int main(){
    int n, m;
    cin >> n >> m;
    vector<int> city[n+1];
    for(int i = 0; i < m; i++){
        int a, b;
        cin >> a >> b;
        city[a].push_back(b);
        city[b].push_back(a);
    }
    for(int i = 1; i <= n; i++){
        cout << city[i].size() << endl;
    }
    return 0;
}


Measured memory_bytes: 256
# 約数全探索
# https://atcoder.jp/contests/abc106/tasks/abc106_b

N = int(input())


def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

ans = 0
for i in range(1, N+1, 2):
    if len(make_divisors(i)) == 8:
        ans += 1
print(ans)

Measured memory_bytes: 38384
#include <stdio.h>
#define NUMBER 200000
int main () {
   int n, i, j, a, x[NUMBER];
   long minv, maxv;

   scanf("%d\n", &n);

   for (i = 0; i < n; i++) {
     scanf("%d\n", &x[i]);
   }

   minv = x[0];
   maxv = x[1] - x[0];

   for (j = 1; j < n; j++) {
     a = x[j] - minv;

     if (maxv < a) {
       maxv = a;
     }

     if (minv > x[j]) {
       minv = x[j];
     }

   }

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

   return 0;

}

Measured memory_bytes: 1380