akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>

using namespace std;

int n,i,j,id[100005];
char s[100005];

int solve(){
	for(int ii = 0; ii < n; ii++){
		if(id[ii] == 0)
		printf("S");
		else
		printf("W");
	}
	printf("\n");
	return 0;
}

int main(){
	scanf("%d", &n);
	scanf("%s", s);
	
	//sheep = 0, wolf = 1
	
	if(s[0] == 'o'){
		//0 is sheep
		id[0] = 0;
		//n - 1 and 1 is sheep
		id[1] = 0;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 0 && ((s[n - 1] == 'o' &&  id[n - 2] == id[0]) || (s[n - 1] == 'x' && id[n - 2] != id[0])))
		return 0 * solve();
		
		//n - 1 and 1 is wolf
		id[1] = 1;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 1 && ((s[n - 1] == 'o' &&  id[n - 2] != id[0]) || (s[n - 1] == 'x' && id[n - 2] == id[0])))
		return 0 * solve();
		
		//0 is wolf
		id[0] = 1;
		//n - 1 is wolf and 1 is sheep
		id[1] = 0;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 1 && ((s[n - 1] == 'o' &&  id[n - 2] != id[0]) || (s[n - 1] == 'x' && id[n - 2] == id[0])))
		return 0 * solve();
		//n - 1 is sheep and 1 is wolf
		id[1] = 1;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 0 && ((s[n - 1] == 'o' &&  id[n - 2] == id[0]) || (s[n - 1] == 'x' && id[n - 2] != id[0])))
		return 0 * solve();
	}
	else{
		id[0] = 0;
		//n - 1 is wolf and 1 is sheep
		id[1] = 0;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 1 && ((s[n - 1] == 'o' &&  id[n - 2] != id[0]) || (s[n - 1] == 'x' && id[n - 2] == id[0])))
		return 0 * solve();
		//n - 1 is sheep and 1 is wolf
		id[1] = 1;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 0 && ((s[n - 1] == 'o' &&  id[n - 2] == id[0]) || (s[n - 1] == 'x' && id[n - 2] != id[0])))
		return 0 * solve();
		
		id[0] = 1;
		//n - 1 and 1 is sheep
		id[1] = 0;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 0 && ((s[n - 1] == 'o' &&  id[n - 2] == id[0]) || (s[n - 1] == 'x' && id[n - 2] != id[0])))
		return 0 * solve();
		
		//n - 1 and 1 is wolf
		id[1] = 1;
		for(i = 1; i < n - 1; i++){
			if((s[i] == 'o' && id[i] == 0) || (s[i] == 'x' && id[i] == 1))
			id[i + 1] = id[i - 1];
			else
			id[i + 1] = 1 - id[i - 1];
		}
		if(id[n - 1] == 1 && ((s[n - 1] == 'o' &&  id[n - 2] != id[0]) || (s[n - 1] == 'x' && id[n - 2] == id[0])))
		return 0 * solve();
	}
	
	printf("-1\n");
}


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

int main() {
  int x;
  cin >> x;
  int a = x % 10 ;
  int b = (x / 10) % 10 ;
  int c = (x / 100) % 10;
  int d = x / 1000;
  if ((a == b && a == c) || (b == c && c == d)) {
    cout << "Yes" << endl;
  }
  else {
    cout << "No" << endl;
  }
}


Measured memory_bytes: 256
#include"bits/stdc++.h"
using namespace std;
using ll = int64_t;

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

    vector<ll> V(N), C(N);
    for (ll i = 0; i < N; i++) {
        cin >> V[i];
    }
    for (ll i = 0; i < N; i++) {
        cin >> C[i];
    }

    ll ans = 0;
    for (ll i = 0; i < N; i++) {
        ans += max(V[i] - C[i], (ll)0);
    }
    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include<vector>
#include<cmath>
#include<algorithm>
using namespace std;
int main() {
  int n1, n2, i, j;
  string palavra1, palavra2;
  cin>>palavra1>>palavra2;
  n1=palavra1.size();
  n2=palavra2.size();
  int M[n1+1][n2+1];
  for(i=0;i<=n1;i++){
    M[i][0]=0;
  }
  for(i=0;i<=n2;i++){
    M[0][i]=0;
  }

  for(i=1;i<=n1;i++){
    for(j=1;j<=n2;j++){
      if(palavra1[i-1]==palavra2[j-1]){
        M[i][j]=M[i-1][j-1]+1;
      }
      else{
        M[i][j]= max(M[i-1][j],M[i][j-1]);
      }
    }
  }
  vector<char> sub;
  i=n1;
  j=n2;
  while(i>0 && j>0){
    if(palavra1[i-1]==palavra2[j-1]){
      sub.push_back(palavra1[i-1]);
      i--;
      j--;
    }
    else if(M[i-1][j]>M[i][j-1]){
      i--;
    }
    else{
      j--;
    }
  }
  reverse(sub.begin(),sub.end());
  for(i=0;i<sub.size();i++){
    cout<<sub.at(i);
  }
  cout<<endl;
}

Measured memory_bytes: 35456
#pragma GCC optimize("O3")
#pragma GCC optimize("Ofast,no-stack-protector")
#include<bits/stdc++.h>
using namespace std;
#define INF 0x3f3f3f3f
#define LL long long int
#define vi vector<int>
#define vl vector<LL>
#define pb push_back
#define all(V) V.begin(),V.end()
#define sci(x) scanf("%d",&x)
#define scl(x) scanf("%I64d",&x)
#define pii pair<int,int>
#define cmax(a,b) ((a) = (a) > (b) ? (a) : (b))
#define cmin(a,b) ((a) = (a) < (b) ? (a) : (b))
#define debug(x)  cerr << #x << " = " << x << endl
function<void(void)> ____ = [](){ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);};
const int MOD = 1e9+7;
const int MAXN = 2e5+7;
LL fac[MAXN],inv[MAXN], rfac[MAXN];
void solve(){
    LL h, w, a, b;
    cin >> h >> w >> a >> b;
    LL ret = 0;
    fac[0] = 1;
    for(int i = 1; i < MAXN; i++) fac[i] = fac[i-1] * i % MOD;
    inv[1] = 1;
    for(int i = 2; i < MAXN; i++) inv[i] = (MOD - MOD / i) * inv[MOD%i] % MOD;
    rfac[0] = 1;
    for(int i = 1; i < MAXN; i++) rfac[i] = rfac[i-1] * inv[i] % MOD;
    auto C = [&](int n, int m){
        return fac[n] * rfac[m] % MOD * rfac[n-m] % MOD;
    };
    for(int i = 0; i < h - a; i++){
        ret = (ret + C(i+b-1,i) * C(w-b-1+h-i-1,w-b-1)) % MOD;
    }
    cout << ret << endl;
}
int main(){
    #ifndef ONLINE_JUDGE
    freopen("Local.in","r",stdin);
    freopen("ans.out","w",stdout);
    #endif
    solve();
    return 0;
}

Measured memory_bytes: 8368
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) (v).begin(),(v).end()
#define rall(v) (v).rbegin(),(v).rend()   //reverse
#define strall(v) (v).cbegin(),(v).cend() //const_itterator
using namespace std;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
template<class t,class u> void chmax(t&a,u b){if(a<b)a=b;}
template<class t,class u> void chmin(t&a,u b){if(b<a)a=b;}
const int INF = 1e8;

int main() {
  int N; cin >> N;
  vector<int> vec(N-1);
  rep(i,N-1) cin >> vec[i],vec[i]--;
  vector<ll> ans(N,0);
  
  for(int i=0;i<N-1;i++){
    ans[vec[i]]++;
  }
  rep(i,N){
    cout << ans[i] << endl;
  }
}

Measured memory_bytes: 5632
#include <bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>

#define x first
#define y second
#define ndl '\n'
#define mp make_pair
#define mt make_tuple
#define pb push_back
#define up_b upper_bound
#define low_b lower_bound
#define sz(x) (int)x.size()
#define bit __builtin_popcount
#define all(x) x.begin(), x.end()
#define rall(x) x.rbegin(), x.rend()

using namespace std;
using namespace __gnu_pbds;

template<typename T> using indexed_set = tree <T, null_type, less<T>, rb_tree_tag, tree_order_statistics_node_update>;
mt19937_64 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef long long ll;
typedef long double ld;
typedef unsigned int uint;
typedef unsigned long long ull;
typedef pair<ll, ll> pll;
typedef pair<int, int> pii;
typedef pair<int, ll> pil;
typedef pair<ll, int> pli;
typedef pair<int, ull> piu;
typedef vector<vector<int>> matrix;

const ll INF = 1e18 + 123;
const ld EPS = 1e-9;
const int inf = 1e9 + 123;
const int MOD = 1e9 + 7;
const int N = 5e5 + 123;
const int M = 1e6 + 123;
const double pi = acos(-1.0);
const int dx[] = {0, 0, 1, -1};
const int dy[] = {1, -1, 0, 0};

void solve(){
    string s;
    cin >> s;
    if (find(all(s), '7') != s.end()){
        cout << "Yes";
    }
    else cout << "No";
}

int main(){
    #ifdef KAZAKH
        freopen("input.txt", "r", stdin);
    #endif
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    int t = 1;
    //cin >> t;
    for (int i = 1; i <= t; i++){
        //cout << "case #" << i << ": ";
        solve();
    }
    return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <string>
#include <algorithm>
#include <utility>
#include <iomanip>
#include <functional>
#include <queue>
#include <stack>
#include <map>
#include <vector>
#include <cmath>
#include <cctype>
#include <cstdio>
#define ll long long
#define INF 1e+9
#define MOD 1000000007
using namespace std;


ll dp[101][100001]={};
int main(){
    ll N,W;
    cin >> N >> W;
    


    
    for(ll i=1; i<=N; i++){
        ll wi,vi;
        cin >> wi >> vi;
        for(ll w=1; w<=W; w++){
            if(w-wi>=0){
                dp[i][w] = max(dp[i-1][w], dp[i-1][w-wi] + vi );
            }else{
                dp[i][w] = dp[i-1][w];
            }
        }
    }
    
    cout << dp[N][W] << endl;
    return 0;
}


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

int main() {
  int a, b, c, d;
  cin >> a >> b >> c >> d;
  if (abs(a - c) <= d) cout << "Yes" << endl;
  else if (abs(a - b) <= d && abs(b - c) <= d) cout << "Yes" << endl;
  else cout << "No" << endl;
}

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

#define f(a, b) for(auto i = a;i < b;i++)
typedef long long int ll;

void solve()
{
	return ;
}

int main()
{
	ll n, m;
	cin >> n >> m;
	// solve();

	cout << n * (n - 1)/2 + m *(m - 1)/2 << "\n";



}


Measured memory_bytes: 256
import sys
sys.setrecursionlimit(4100000)

import math

import logging

logging.basicConfig(level=logging.DEBUG)

logger = logging.getLogger(__name__)

# from collections import defaultdict
# d = defaultdict(list)

# from itertools import combinations
# comb = combinations(range(N), 2)

# 累積和
# from itertools import accumulate
# _list = list(accumulate(a_list)

# from functools import lru_cache
# @lru_cache(maxsize=None)
# def setUp(self):
#     dp.cache_clear()


def resolve():
    # S = [x for x in sys.stdin.readline().split()][0]  # 文字列 一つ
    # N = [int(x) for x in sys.stdin.readline().split()][0]  # int 一つ
    n, m, d = [int(x) for x in sys.stdin.readline().split()]  # 複数int
    # h_list = [int(x) for x in sys.stdin.readline().split()]  # 複数int

    # grid = [list(sys.stdin.readline().split()[0]) for _ in range(N)]  # 文字列grid
    # v_list = [int(sys.stdin.readline().split()[0]) for _ in range(N)]
    # grid = [[int(x) for x in sys.stdin.readline().split()]
    #         for _ in range(N)]  # int grid

    logger.debug('{}'.format([]))

    if d == 0:
        print((m - 1) / n)

    else:
        print(((n - 2 * d) * 2 + 2 * d) * (m - 1) / n**2)


if __name__ == "__main__":
    resolve()

# AtCoder Unit Test で自動生成できる, 最後のunittest.main は消す
# python -m unittest template/template.py で実行できる
# pypy3 -m unittest template/template.py で実行できる

import sys
from io import StringIO
import unittest


class TestClass(unittest.TestCase):
    def assertIO(self, input, output):
        stdout, stdin = sys.stdout, sys.stdin
        sys.stdout, sys.stdin = StringIO(), StringIO(input)
        resolve()
        sys.stdout.seek(0)
        out = sys.stdout.read()[:-1]
        sys.stdout, sys.stdin = stdout, stdin
        self.assertEqual(out, output)

    def test_入力例_1(self):
        input = """2 3 1"""
        output = """1.0000000000"""
        self.assertIO(input, output)

    def test_入力例_2(self):
        input = """1000000000 180707 0"""
        output = """0.0001807060"""
        self.assertIO(input, output)


Measured memory_bytes: 6824
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int N, count=0;
  cin >> N;
  vector<int> p(N);
  for (int i=0; i<N; i++)
    cin >> p.at(i);
  for (int i=0; i < N-2; i++){
    if (p.at(i) > p.at(i+1) && p.at(i+1) > p.at(i+2))
      count++;
    else if (p.at(i)<p.at(i+1) && p.at(i+1)<p.at(i+2))
      count++;
    else
      continue;
  }
  cout << count << endl;
}

Measured memory_bytes: 256
#pragma GCC optimize(3)
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
bool Finish_read;
template<class T>inline void read(T &x){Finish_read=0;x=0;int f=1;char ch=getchar();while(!isdigit(ch)){if(ch=='-')f=-1;if(ch==EOF)return;ch=getchar();}while(isdigit(ch))x=x*10+ch-'0',ch=getchar();x*=f;Finish_read=1;}
template<class T>inline void print(T x){if(x/10!=0)print(x/10);putchar(x%10+'0');}
template<class T>inline void writeln(T x){if(x<0)putchar('-');x=abs(x);print(x);putchar('\n');}
template<class T>inline void write(T x){if(x<0)putchar('-');x=abs(x);print(x);}
/*================Header Template==============*/
double a,b,v;
int main() {
	scanf("%lf%lf",&a,&b);
	v=(a+b)/2.0;
	printf("%d\n",(int)(v+0.5));
}

Measured memory_bytes: 256
object Main extends App {
  
  val sc = new java.util.Scanner(System.in) 
  val s = sc.next().toArray
  val t = sc.next().toArray
  val ans = for (i <- 0 to s.length - t.length) yield {
    (for (j <- 0 until t.length) yield if (s(i+j) == t(j)) 0 else 1).sum
  }
  println(ans.min)
}

Measured memory_bytes: 56968
#include <iostream>
#include <vector>
#include<string>
#include <algorithm>
#include <map>
#include <queue>
#include <climits>
using namespace std;

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

#define INF INT_MAX/3
#define REP(i,n) for(int i=0;i<n;i++)

int main(){
	string str;
	cin>>str;
	int N = str.size();
	int i = 0;
	int ans = 0;
	while(i < N){
		ans++;
		int k = 1;
		while((i+k < N)&&(str[i] == str[i+k]) ){
			k++;
		}
		while((i+k < N)&&(str[i] != str[i+k+1]) ){
			k++;
		}
		i += k;
	}

	if((ans == 1) && (str[0] == str[N-1])){
		cout<<0<<endl;
	}
	else{
		cout<<ans<<endl;
	}	
	return 0;
}


Measured memory_bytes: 512
#include <iostream>
#include <vector>
#include <map>
#include <algorithm>
#include <cstdlib>
#include <cmath>
#include <numeric>
#include <tuple>
#include <stack>

#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
#define print(s) cout << s << endl
typedef long long ll;
using namespace std;

int ctoi(char c) {
	if (c >= '0' && c <= '9') {
		return c - '0';
	}
	return 0;
}

int main() {
	string s; cin >> s;
	map<char, int> mp;
	rep(i,s.size()){
		mp[s[i]]++;
		if (mp[s[i]] > 1){
			cout << "no" << endl;
			return 0;
		}
	}
	cout << "yes" << endl;
}

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

#define pb push_back
#define sz size

const int N = 1e5 + 123;
int n, m, dp[N];
vector <int> g[N];

void dfs(int v) {
	int mx = 0;
	for(int i = 0; i < g[v].sz(); ++i) {
		int to = g[v][i];
		if(!dp[to]) {
			dfs(to);
		}
		mx = max(mx, dp[to]);
	}
	dp[v] = mx + 1; 
}
int main() {
	//freopen("input.txt", "r", stdin);
	cin >> n >> m;
	for(int i = 1; i <= m; ++i) {
		int x, y;
		cin >> x >> y;
		g[x].pb(y);
	}
	for(int i = 1; i <= n; ++i) {
		if(!dp[i]) {
			dfs(i);
		}
	}
	int ans = -1;
	for(int i = 1; i <= n; ++i) {
		ans = max(ans, dp[i]);
	}
	cout << ans - 1;
}

Measured memory_bytes: 8832
// C++ 14
#include <bits/stdc++.h>
using namespace std;
template <typename T>  ostream& operator<<(ostream& os, const vector<T>& v)  {  os << "[";  for (int i = 0; i < v.size(); ++i) {  os << v[i];  if (i != v.size() - 1)  os << ", ";  }  os << "]";  return os;  }
template <typename T> void print(T v, string s = "\n") { cout << v << s; }
template <typename T> void in(T& v) { cin >> v; }
#define ll long long
#define loop(__x, __start, __end) for(int __x = __start; __x < __end; __x++)

vector<string> S { "dream", "dreamer", "erase", "eraser" };

int main() {
  string t;in(t);
  int n=t.size();
  reverse(t.begin(), t.end());
  loop(i,0,4) reverse(S[i].begin(), S[i].end());
  int idx = 0;
  while (idx < n - 1) {
    bool match = false;
    for (auto &s: S) {
      int size = s.size();
      if (t.substr(idx, size) == s) idx += size,match = true;
    }
    if (!match) {
      print("NO");
      return 0;
    }
  }
  print("YES");
  return 0;
}


Measured memory_bytes: 3764
#include<iostream>
#include<vector>
#include<stack>

#define rep(i,a) for(int i=0;i<(a);i++)
using namespace std;

vector<int> in;


bool check(vector<int> r,vector<int> l){
	int lenr=r.size(),lenl=l.size();
	for(int i=1;i<lenr;i++){
		if(r[i]<=r[i-1])return false;
	}	
	for(int i=1;i<lenl;i++){
		if(l[i]<=l[i-1])return false;
	}
	return true;
}

bool dfs(vector<int> r,vector<int> l,int num){
	if(!check(r,l))return false;
	if(num==10)return true;

	r.push_back(in[num]);
	if( dfs(r,l,num+1) )return true;
	r.pop_back();

	l.push_back(in[num]);
	if( dfs(r,l,num+1) )return true;
	l.pop_back();

	return false;
}



int main(){
int N;
	cin>>N;
	rep(roop,N){
        while(in.size())in.pop_back();
		rep(i,10){
			int tmp;
			cin>>tmp;
			in.push_back(tmp);
		}
		if(dfs({},{},0))	cout<<"YES"<<endl;
		else		cout<<"NO"<<endl;	
	}
	return 0;
}
	

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

using namespace std;

#define ll long long
#define ull unsigned long long

const int inf = 2e9;

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

    int n, m;
    cin >> n >> m;
    vector<string> a(n);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }

    vector<vector<int> > dp(n, vector<int>(m, inf));
    dp[0][0] = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < m; j++) {
            if (i > 0) {
                dp[i][j] = min(dp[i][j], dp[i - 1][j] + (a[i - 1][j] != a[i][j]));
            }
            if (j > 0) {
                dp[i][j] = min(dp[i][j], dp[i][j - 1] + (a[i][j - 1] != a[i][j]));
            }
        }
    }

    int r = dp[n - 1][m - 1];
    if (a[0][0] == '#') r++;
    if (a[n - 1][m - 1] == '#') r++;
    cout << r / 2 << '\n';
}

Measured memory_bytes: 384
# -*- coding: utf-8 -*-


class FactMod():
    '''
    modの値が素数の時のfactと組み合わせを求める
    フェルマーの小定理を用いているため、modが素数以外の時は使えない
    '''

    def __init__(self, n, mod):
        '''
        コンストラクタ
        f:nまでの i!の値を　配列に入れる
        inv: (i!)^-1　の値を配列に入れる
        '''
        self.mod = mod
        self.f = [1]*(n+1)
        for i in range(1, n+1):
            self.f[i] = self.f[i-1]*i % mod

        self.inv = [pow(self.f[-1], mod-2, mod)]
        for i in range(1, n+1)[::-1]:
            self.inv.append(self.inv[-1]*i % mod)
        self.inv.reverse()

    def fact(self, n):
        '''
        n!の値を返す
        '''
        return self.f[n]

    def comb(self, n, r):
        '''
        nCrの値を返す
        '''
        ret = self.f[n] * self.inv[n-r]*self.inv[r]
        ret %= self.mod
        return ret

    def perm(self, n, r):
        """
        nPrの値を返す
        """
        ret = self.f[n] * self.inv[n-r]
        ret %= self.mod
        return ret

S=int(input())

MOD=10**9+7
F=FactMod(S,MOD)

ans=0
for i in range(1,S):
    #i個に分割する通り数
    r=S-3*i
    if r<0:
        continue

    ans+=F.comb(r+i-1,i-1)
    ans%=MOD

print(ans%MOD)


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

int main() {
	int N;
  	cin >> N;
  
  	long power = 1;
  	for(int i = 1; i <= N; i++) {
    	power = (power * i) % 1000000007;
    }
  
  	cout << power << endl;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,b) for(ll i=0;i<b;i++)
#define ll long long
using namespace std;
/*--Input//////////////////////////////////////////////////*/
inline void IN(void){return;}
template <typename First, typename... Rest>
void IN(First& first, Rest&... rest){
    cin >> first;
    IN(rest...);
    return;
}
#define SS(T, ...)      T __VA_ARGS__; IN(__VA_ARGS__);
#define SV(type,c,n) vector<type> c(n);for(auto& i:c)cin >> i;
/*--Output/////////////////////////////////////////////////*/
#define Yes(n) cout << ((n) ? "Yes" : "No"  ) << endl
#define YES(n) cout << ((n) ? "YES" : "NO"  ) << endl
inline int p(void){cout << endl; return 0;}
template<class Head> int p(Head&& head){cout << head;p();return 0;} template<class Head,class... Tail> int p(Head&& head,Tail&&... tail){cout<<head<<" ";p(forward<Tail>(tail)...);return 0;}
struct ProconInit {
    static constexpr int IOS_PREC = 15;
    static constexpr bool AUTOFLUSH = false;

    ProconInit() {
        cin.tie(nullptr);
        ios::sync_with_stdio(false);
        cout << fixed << setprecision(IOS_PREC);
        if(AUTOFLUSH)
            cout << unitbuf;
    }
} PROCON_INIT;


#define vl vector<ll>
#define vvl vector<vector<ll>>
#define vvvl vector<vector<vector<ll>>>
#define debug(x) cerr<<#x<<" "<<x<<'\n';
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL<<(n))
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; }
bool cmp(pair<ll,ll> a, pair<ll,ll> b) { return a.second < b.second; }

const int MOD = 1000000007;

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

int main(){
    int N;
    double ans = 0.0, A;
    cin >> N;
    for(int i = 1; i <= N; ++i){
        cin >> A;
        ans += 1.0 / A;
        }
    ans = 1.0 / ans;
    cout << ans << endl;
    }

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

// types
typedef long long ll;
typedef long double ld;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef pair<ld,ld> pdd;
typedef vector<ll> vll;

// macros
#define ALL(a) a.begin(),a.end()
#define SZ(a) ((int)a.size())
#define FI first
#define SE second
#define REP(i,n) for(int i=0;i<((int)n);i++)
#define REP1(i,n) for(int i=1;i<((int)n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define PB push_back
#define EB emplace_back
#define MP(a,b) make_pair(a,b)
#define SORT_UNIQUE(c) (sort(c.begin(),c.end()), c.resize(distance(c.begin(),unique(c.begin(),c.end()))))
#define GET_POS(c,x) (lower_bound(c.begin(),c.end(),x)-c.begin())
#define Decimal fixed<<setprecision(20)
#define INF 1000000000
#define LLINF 1000000000000000000LL

// constants
const int inf = 1e9;
const ll linf = 1LL << 50;
const double eps = 1e-10;
const int MOD = 1e9 + 7;
const int dx[4] = {-1, 0, 1, 0};
const int dy[4] = {0, -1, 0, 1};


int main(){
  ios_base::sync_with_stdio(false);
  cin.tie(NULL);


  ll a;
  string s;
  cin >> a >> s;

  if(a >= 3200)
    cout << s << endl;
  else
    cout << "red" << endl;
  
}


Measured memory_bytes: 256
import std.stdio, std.conv, std.string, std.array, std.math, std.regex, std.range, std.ascii, std.numeric, std.random;
import std.typecons, std.functional, std.traits,std.concurrency;
import std.algorithm, std.container;
import core.bitop, core.time, core.memory;
import std.bitmanip;
import std.regex;

enum INF = long.max/3;
enum MOD = 10L^^9+7;

//辞書順順列はiota(1,N),nextPermituionを使う


void end(T)(T v)
if(isIntegral!T||isSomeString!T||isSomeChar!T)
{
    import core.stdc.stdlib;
    writeln(v);
    exit(0);
}

T[] scanArray(T = long)()
{
    static char[] scanBuf;
    readln(scanBuf);
    return scanBuf.split.to!(T[]);
}

dchar scanChar()
{
    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    return cast(dchar)c;
}

T scanElem(T = long)()
{
    import core.stdc.stdlib;
    static auto scanBuf = appender!(char[])([]);

    scanBuf.clear;

    int c = ' ';
    while (isWhite(c) && c != -1)
    {
        c = getchar;
    }
    while (!isWhite(c) && c != -1)
    {
        scanBuf ~= cast(char) c;
        c = getchar;
    }
    return scanBuf.data.to!T;
}

dchar[] scanString(){
    return scanElem!(dchar[]);
}


void main()
{
  auto s = scanString;
  if(s[0]==s[2])end("Yes");end("No");
}


Measured memory_bytes: 256
#include<stdio.h>
#include<iostream>
#include<algorithm>
using namespace std;
const int maxn=2000+10;
const int base=1000000000+7;

int n,k;
int c[maxn][maxn];
long long kq;

long long C(int n,int k){
  if (k==0){
    if (n==0) return 1;
    else return 0;
  }
  if (k>n) return 0;
  return c[n-1][k-1];
}

int main(){
  cin>>n>>k;
  for(int i=0;i<=n;i++) c[i][0]=1;
  for(int i=0;i<=n;i++) c[i][i]=1;
  for(int i=1;i<=n;i++)
    for(int j=1;j<=n;j++)
      c[i][j]=(c[i-1][j]+c[i-1][j-1])%base;
  for(int i=1;i<=k;i++){
    kq=C(k,i)*(2*C(n-k,i)+C(n-k,i+1)+C(n-k,i-1))%base;
    cout<<kq<<endl;
  }
}


Measured memory_bytes: 16000
(let ((n (read))
    (a (read))
    (b (read))
    (shitumon1 0)
    (shitumon2 0)
    (shitumon3 0))
    (dotimes (i n)
        (let ((p (read)))
            (if (<= p a)
            (incf shitumon1))
            (if (and (> p a) (<= p b))
            (incf shitumon2))
            (if (> p b)
            (incf shitumon3))
        )
    )
    (princ (min shitumon1 shitumon2 shitumon3))
)

Measured memory_bytes: 24404
N = int(input())
a = list(map(int, input().split()))
dp = [[0] * N for i in range(N)]
for i in range(N):
    dp[i][i] = a[i]
for i in range(N-1)[::-1]:
    for j in range(i+1, N):
        dp[i][j] = max(a[i]-dp[i+1][j], a[j]-dp[i][j-1])
print(dp[0][N-1])


Measured memory_bytes: 113116
#[allow(unused_imports)]
use std::cmp::*;
#[allow(unused_imports)]
use std::collections::*;
use std::io::{Write, BufWriter};
// https://qiita.com/tanakh/items/0ba42c7ca36cd29d0ac8
macro_rules! input {
    ($($r:tt)*) => {
        let stdin = std::io::stdin();
        let mut bytes = std::io::Read::bytes(std::io::BufReader::new(stdin.lock()));
        let mut next = move || -> String{
            bytes
                .by_ref()
                .map(|r|r.unwrap() as char)
                .skip_while(|c|c.is_whitespace())
                .take_while(|c|!c.is_whitespace())
                .collect()
        };
        input_inner!{next, $($r)*}
    };
}

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

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

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

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

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

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

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

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

fn solve() {
    let out = std::io::stdout();
    let mut out = BufWriter::new(out.lock());
    macro_rules! puts {
        ($($format:tt)*) => (write!(out,$($format)*).unwrap());
    }
    input!(n: usize, k: usize);
    let mut tot = 0.0;
    for i in 1..n + 1 {
        let mut v = i;
        let mut p = 1.0;
        while v < k {
            v *= 2;
            p /= 2.0;
        }
        tot += p;
    }
    tot /= n as f64;
    puts!("{}\n", tot);
}

fn main() {
    // In order to avoid potential stack overflow, spawn a new thread.
    let stack_size = 104_857_600; // 100 MB
    let thd = std::thread::Builder::new().stack_size(stack_size);
    thd.spawn(|| solve()).unwrap().join().unwrap();
}


Measured memory_bytes: 8572
#include<iostream>
using namespace std;
int main(){
  unsigned long long int s,book,books;
  while(cin>>s){
    if(s==0) break;
    books = 0;
    for(int i=0;i<9;i++){
      cin >> book;
      books += book;
    }
    cout << s - books << endl;
  }
  return 0;
}

Measured memory_bytes: 1148
#include <stdio.h>
#define rep(i, n) for (int i = 0; i < (int)(n); i++)

int main() {
    rep (i, 9) rep (j, 9) {
        printf("%dx%d=%d\n", i+1, j+1, (i+1)*(j+1));
    }
    return 0;
}

Measured memory_bytes: 0
import sys
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines
read = sys.stdin.buffer.read
sys.setrecursionlimit(10 ** 7)
INF = float('inf')

H1, M1, H2, M2, K = map(int, readline().split())

ans = (H2 * 60 + M2 - K) - (H1 * 60 + M1)
print(ans)

Measured memory_bytes: 9236
#include<iostream>
#include<iomanip>
#include<cmath>
#include<string>
#include<cstring>
#include<vector>
#include<list>
#include<algorithm>
#include<map>
#include<set>
#include<queue>
#include<stack>
using namespace std;
typedef long long ll;
#define fi first
#define se second
#define mp make_pair
#define rep(i, n) for(int i=0;i<n;++i)
#define rrep(i, n) for(int i=n;i>=0;--i)
const int inf=1e9+7;
const ll mod=1e9+7;
const ll big=1e18;
const double PI=2*asin(1);

ll comb1[100005];
ll comb2[100005];
ll frac[100005];

void prepare1(ll a) {
  ll ue, shita1, shita2;
  ll tmpshita1, tmpshita2;
  ll h, two;
  for(ll i=0;i<100005;++i) {
    if(a<i) {
      comb1[i] = 0;
      continue;
    }
    if(a==i) {
      comb1[i] = 1;
      continue;
    }
    h = mod - 2;
    ue = frac[a];
    shita1 = 1;
    shita2 = 1;
    while(h>0) {
      two = 1;
      tmpshita1 = frac[i];
      tmpshita2 = frac[a-i];
      while(2*two<h) {
        two *= 2;
        tmpshita1 *= tmpshita1;
        tmpshita2 *= tmpshita2;
        tmpshita1 %= mod;
        tmpshita2 %= mod;
      }
      h -= two;
      shita1 *= tmpshita1;
      shita2 *= tmpshita2;
      shita1 %= mod;
      shita2 %= mod;
    }
    comb1[i] = ue*shita1%mod*shita2%mod;
  }
}

void prepare2(ll a) {
  ll ue, shita1, shita2;
  ll tmpshita1, tmpshita2;
  ll h, two;
  for(ll i=0;i<100005;++i) {
    if(a<i) {
      comb2[i] = 0;
      continue;
    }
    if(a==i) {
      comb2[i] = 1;
      continue;
    }
    h = mod - 2;
    ue = frac[a];
    shita1 = 1;
    shita2 = 1;
    while(h>0) {
      two = 1;
      tmpshita1 = frac[i];
      tmpshita2 = frac[a-i];
      while(2*two<h) {
        two *= 2;
        tmpshita1 *= tmpshita1;
        tmpshita2 *= tmpshita2;
        tmpshita1 %= mod;
        tmpshita2 %= mod;
      }
      h -= two;
      shita1 *= tmpshita1;
      shita2 *= tmpshita2;
      shita1 %= mod;
      shita2 %= mod;
    }
    comb2[i] = ue*shita1%mod*shita2%mod;
  }
}

int main() {
  frac[0] = 1;
  for(ll i=1;i<100005;++i) {
    frac[i] = frac[i-1]*i%mod;
  }
  int N;
  cin>>N;
  int A[N+1];
  map<int, int> amap;
  for(int i=0;i<=N;++i) {
    cin>>A[i];
    amap[A[i]]++;
  }
  int num;
  for(int i=1;i<=N;++i) {
    if(amap[i]==2) num = i;
  }
  ll a=0, b=0, c=0;
  bool aa=true, bb=false;
  for(int i=0;i<=N;++i) {
    if(aa) {
      if(A[i]!=num) a++;
      else {
        aa = false;
        bb = true;
      }
    }
    else if(bb) {
      if(A[i]!=num) b++;
      else {
        bb = false;
      }
    }
    else c++;
  }
  prepare1(N+1);
  prepare2(a+c);
  for(int i=1;i<=N+1;++i) {
    cout<<(comb1[i]-comb2[i-1]+mod)%mod<<endl;
  }
}



Measured memory_bytes: 10932
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define all(v) v.begin(), v.end()
using namespace std;
typedef long long ll;

int main() {
	
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n) cin >> a[i], a[i]--;
	int cnt = 0;
	rep(i, n){
		if(a[i] == cnt){
			cnt++;
		}
	}
	printf("%d\n", (cnt == 0) ? -1 : n-cnt);
	return 0;
}

Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll,string>;
using Map = map<string,ll>;
using vl = vector<ll>;
using vvl = vector<vector<ll>>;

ll INF=99999999999999999;

int main(){
    ll ans=-INF;
    ll N;
    cin >> N;
    ll M;
    cin >> M;
    vector<ll> A(N+1,0);
    vector<ll> B(N+1,0);
    vector<ll> C(N+1,0);
    for(ll i=1;i<=N;i++){
        cin>>A[i]>>B[i]>>C[i]
    ;}
    for(ll bit=0;bit<(1<<3);bit++){
        vector<ll> f(3,1);
        for(ll j=0;j<3;j++){
            if(bit&(1<<j))f[j]=-1
        ;}
        vector<ll> val(N,0);
        for(ll j=0;j<N;j++){
            val[j]=A[j+1]*f[0]+B[j+1]*f[1]+C[j+1]*f[2]
        ;}
        sort(val.begin(), val.end());
        reverse(val.begin(), val.end());
        ll sum=0;
        for(ll j=0;j<M;j++){
            sum+=val[j]
        ;}
        ans=max(ans,sum);
    ;}



  
  cout<<ans<<endl;

  
return 0;
}


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

int main(){
    string ins;
    cin >> ins;

    if(ins=="Sunny"){
        cout << "Cloudy";
    }else if(ins=="Cloudy"){
        cout << "Rainy";
    }else if(ins=="Rainy"){
        cout << "Sunny";
    }

    cout << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int a,b,x;
double e;
double r = 45.0/atan(1.0);
double ans;
int main()
{
    cin>>a>>b>>x;
    e=a*a*b/2;
    ans=0;
    if(x>=e)
    {
        double c = 2.0*b-((2.0*x)/(a*a));
        ans=atan(a/c);
        ans*=r*1.0;
        printf("%.10lf\n",90.0000000000-ans);
    }
    else
    {
        double c= ((2.0*x)/(a*b));
        ans=atan(c/b);
        ans*=r*1.0;
        printf("%.10lf\n",90.0000000000-ans);
    }
}

Measured memory_bytes: 256
import math
import bisect
N, M = map(int, input().split())

divisor_array = []
divisor_max = math.floor(math.sqrt(M))

for i in range(1, divisor_max + 1):
    if M % i == 0:
        divisor_array.append(i)
        divisor_array.append(M // i)

divisor_array.sort()

# print(divisor_array)
insert_index = bisect.bisect_left(divisor_array, N)

print(M // divisor_array[insert_index])


Measured memory_bytes: 38640
#include <iostream>
#include <string>
#include <cstdlib>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <queue>
#include <stack>
#include <functional>
#include <bitset>
#include <assert.h>
using namespace std;
typedef long long ll;
typedef vector<ll> vl;
typedef vector<vl> vvl;
typedef vector<char> vc;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<double> vd;
typedef pair<ll,ll> P;
typedef vector<P> vpl;
typedef tuple<ll,ll,ll> tapu;
#define rep(i,n) for(ll i=0; i<(n); i++)
#define REP(i,a,b) for(int i=(a); i<(b); i++)
#define all(x) (x).begin(), (x).end()
#define rall(x) (x).rbegin(), (x).rend()
const int inf = 1<<30;
const ll linf = 1LL<<62;
const int MAX = 510000;
ll dy[8] = {0,1,0,-1,1,-1,1,-1};
ll dx[8] = {1,0,-1,0,1,-1,-1,1};
const double pi = acos(-1);
const double eps = 1e-7;
template<typename T1,typename T2> inline bool chmin(T1 &a,T2 b){
	if(a>b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline bool chmax(T1 &a,T2 b){
	if(a<b){
		a = b; return true;
	}
	else return false;
}
template<typename T1,typename T2> inline void print2(T1 a, T2 b){cout << a << " " << b << "\n";}
template<typename T1,typename T2,typename T3> inline void print3(T1 a, T2 b, T3 c){
	cout << a << " " << b << " " << c << "\n";
}
//const int mod = 1e9 + 7;
const int mod = 998244353;

int main(){
    ll n; cin >> n;
    vpl plus, minus;
    rep(i,n){
        string s; cin >> s;
        ll cnt = 0, cnt2 = 0;
        ll mn = inf, mx = -inf;
        rep(j,s.size()){
            if(s[j]=='(') cnt++;
            else cnt--;
            chmin(mn,cnt);
        }
        for(ll j=s.size()-1; j>=0; j--){
            if(s[j]=='(') cnt2++;
            else cnt2--;
            chmax(mx,cnt2);
        }
        if(cnt >= 0) plus.emplace_back(mn,cnt);
        else minus.emplace_back(mx,cnt2);
    }
    sort(rall(plus));
    sort(all(minus));
    ll cnt = 0;
    rep(i,plus.size()){
        if(-plus[i].first > cnt){
            puts("No");
            return 0;
        }
        cnt += plus[i].second;
    }
    ll cnt2 = 0;
    rep(i,minus.size()){
        if(-minus[i].first < cnt2){
            puts("No");
            return 0;
        }
        cnt2 += minus[i].second;
    }
    if(cnt != -cnt2){
        puts("No");
    }else{
        puts("Yes");
    }
}

Measured memory_bytes: 18956
#include<cstdio>
#include<algorithm>
#include<iostream>
#include<cstring>
#include<vector>
using namespace std;
typedef long long LL;
const int N=200005;
const int MOD=1e9+7;
int add (int x,int y)   {x=x+y;return x>=MOD?x-MOD:x;}
int mul (int x,int y)   {return (LL)x*y%MOD;}
int dec (int x,int y)   {x=x-y;return x<0?x+MOD:x;}
int Pow (int x,int y)
{
	if (y==0) return 1;
	if (y==1) return x;
	int lalal=Pow(x,y>>1);
	lalal=mul(lalal,lalal);
	if (y&1) lalal=mul(lalal,x);
	return lalal;
}
int n,a,b,c;
int g[N],h[N];
int JC[N],Inv[N];
void Init (int n)
{
	JC[0]=1;for (int u=1;u<=n;u++) JC[u]=mul(JC[u-1],u);
	Inv[n]=Pow(JC[n],MOD-2);
	for (int u=n-1;u>=0;u--) Inv[u]=mul(Inv[u+1],u+1);
}
int C (int x,int y)	{return mul(mul(JC[x],Inv[y]),Inv[x-y]);}
int f1[N],f2[N];
int main()
{
	Init(200000);
	scanf("%d%d%d%d",&n,&a,&b,&c);
	int t=Pow(a+b,MOD-2);
	a=mul(a,t);b=mul(b,t);
	t=Pow(100,MOD-2);
	c=dec(1,mul(c,t));
	c=Pow(c,MOD-2);
	g[0]=1;for (int u=1;u<=2*n;u++) g[u]=mul(g[u-1],a);
	h[0]=1;for (int u=1;u<=2*n;u++) h[u]=mul(h[u-1],b);
	for (int u=0;u<=n;u++)
	{
		if (u!=0) f1[u]=f1[u-1],f2[u]=f2[u-1];
		f1[u]=add(f1[u],mul(g[u],C(n+u,u)));
		f2[u]=add(f2[u],mul(h[u],C(n+u,u)));
	}
	int sum=0,ans=0;
	for (int u=n;u<=2*n-1;u++)//有效局数多少局解决
	{
		/*int now=1;
		for (int i=0;i<=u;i++)//a多少局 
		{
			int j=u-i;
			if (i>=n||j>=n) continue;
			now=dec(now,mul(mul(C(u,i),g[i]),h[j]));
		}*/
		int now=0,ff;
		/*for (int i=0;i<u;i++)//A赢了多少局 
		{
			int j=u-i;
			if (j<n) break;
			now=add(now,mul(mul(C(u,i),g[i]),h[j]));
			now=add(now,mul(mul(C(u,i),h[i]),g[j]));
		}*/
		int t=u-n;
		ff=add(mul(f1[t-1],b),mul(g[t],C(n+t,t)));
		now=add(now,mul(ff,h[n]));
		//now=add(mul(f1[t],h[n]),mul(f2[t],g[n]));
		ff=add(mul(f2[t-1],a),mul(h[t],C(n+t,t)));
		now=add(now,mul(ff,g[n]));
		int o=dec(now,sum);sum=now;
		ans=add(ans,mul(o,mul(c,u)));
	}
	printf("%d\n",ans);
	return 0;
}

Measured memory_bytes: 4096
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <list>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <bitset>
#include <numeric>
#include <climits>
#include <cfloat>
using namespace std;

int main()
{
    for(;;){
        int n;
        cin >> n;
        if(n == 0)
            return 0;

        vector<int> num(n+3, 0);
        num[0] = 1;
        for(int i=0; i<n; ++i){
            num[i+1] += num[i];
            num[i+2] += num[i];
            num[i+3] += num[i];
        }

        int ret = num[n];
        cout << ((num[n]+3649) / 3650) << endl;
    }
}

Measured memory_bytes: 0
#include<stdio.h>
int main(){
    int n;
    scanf("%d", &n);
    int w[100];
    for(int i=0;i<n;i++){
        scanf("%d", &w[i]);
    }
    int min = 100;
    for(int t=0;t<n;t++){
        int sa = 0;
        int sb = 0;
        for(int i=0;i<n;i++){
            if(i<=t)sa+=w[i];
            else sb+=w[i];
        }
        if(abs(sa-sb)<min)min=abs(sa-sb);
    }
    printf("%d\n",min);
    return 0;
}

Measured memory_bytes: 128
#include<stdio.h>
#include<string.h>
int main(void){
     char s[101],p[101];
     char a[1000];
     scanf("%s",s);
     scanf("%s",p);
     strcpy(a,s);
     strcat(a,s);
     if(strstr(a,p)!=NULL)
         puts("Yes");
     else
         puts("No");
     return 0;
 }


Measured memory_bytes: 2760
#include <iostream>

using namespace std;

int main()
{
    string s; cin >> s;
    int size = s.size();
    int h, ans = 0;
    h = size / 2;
    
    for (int i = 0, j = size-1; i < h; ++i, --j)
        if (s[i] != s[j]) ++ans;

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <algorithm>
using namespace std;
string a, b;

int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	cin >> a >> b;
	int i;
	int ra = a.size();
	for (i = 0; i <= a.size() - b.size(); i++)
	{
		int j;
		int ans = 0;
		for (j = i; j < i + b.size();j++)
		{
			ans += b[j - i] != a[j];
		}
		ra = min(ra, ans);
	}
	cout << ra;
}

Measured memory_bytes: 3656
#include<bits/stdc++.h>
#define mod 1000000007
using namespace std;
typedef long long ll;
int main(){
    cin.tie(0);
    ios::sync_with_stdio(0);
    ll n,a[300000];
    cin>>n;
    for(int i=0;i<n;i++){
		cin>>a[i];
    }
    ll ans=0;
    for(int i=0;i<60;i++){
        int x=0,y=0;
        for(int j=0;j<n;j++){
            if(a[j]&(1LL<<i)) x++;
            else y++;
        }
        ll p=(1LL<<i)%mod;
        p=p*x%mod;
        p=p*y%mod;
        ans=(ans+p)%mod;
    }
    cout<<ans<<"\n";
}


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

int main() {
    int N, M, L;
    cin >> N >> M >> L;
    vector<double> P(N), T(N), V(N);
    for (int i = 0; i < N; i++)
        cin >> P[i] >> T[i] >> V[i];
    for (int i = 0; i < N; i++)
        P[i] = P[i] / 100.;

    vector<vector<double> > times(N, vector<double>(M + 1)), prob(N, vector<double>(M + 1));
    for (int i = 0; i < N; i++)
        times[i][0] = (double)L / V[i];

    vector<vector<long long int> > comb(M + 1, vector<long long int>(M + 1));
    for (auto& i : comb) i[0] = 1LL;
    for (int i = 1; i <= M; i++)
        for (int j = 1; j <= M; j++) {
            long long int up = comb[i-1][j];
            long long int left = comb[i-1][j-1];
            comb[i][j] = up + left;
        }

    for (int i = 0; i < N; i++) {
        for (int j = 0; j <= M; j++) {
            if (j > 0) times[i][j] = times[i][j-1] + T[i];
            prob[i][j] = pow(P[i], j) * pow(1.000 - P[i], M - j) * comb[M][j];
        }
    }

    for (int i = 0; i < N; i++) {
        double ans = 0.0000;
        for (int j = 0; j <= M; j++) {
            double tmp = 1.0000;
            for (int k = 0; k < N; k++) {
                if (k == i) continue;
                double sum = 0.0000;
                for (int l = 0; l <= M; l++) {
                    if (times[i][j] < times[k][l]) sum += prob[k][l];
                }
                tmp *= sum;
            }
            ans += prob[i][j] * tmp;
        }
        printf("%.10f\n", ans);
    }


    return 0;
}

Measured memory_bytes: 3612
from collections import defaultdict, deque, Counter
from heapq import heappush, heappop
from itertools import permutations, accumulate, combinations, combinations_with_replacement
from math import sqrt, ceil, floor, factorial
from bisect import bisect_left, bisect_right
from copy import deepcopy
from operator import itemgetter
from functools import reduce
#from fractions import gcd
#from math import gcd
import sys
def I(): return int(input())
def Is(): return map(int, input().split())
def LI(): return list(map(int, input().split()))
def TI(): return tuple(map(int, input().split()))
def IR(n): return [I() for _ in range(n)]
def LIR(n): return [LI() for _ in range(n)]
def TIR(n): return [TI() for _ in range(n)]
def S(): return input()
def Ss(): return input().split()
def LS(): return list(input())
def SR(n): return [S() for _ in range(n)]
def SsR(n): return [Ss() for _ in range(n)]
def LSR(n): return [LS() for _ in range(n)]
sys.setrecursionlimit(10**6)
MOD = 10**9+7
INF = float('inf')


n = I()
tmp = 0
for i in range(1, n+1):
    if i % 2 == 1:
        tmp += 1
print(tmp/n)

Measured memory_bytes: 38384
n,m = gets.split.map(&:to_i)
a = gets.split.map(&:to_i).sort

list = []
m.times do
  list << gets.split.map(&:to_i)
end
list.sort_by!{|t| t[1]}.reverse!
idx = 0
list.each do |b,c|
  break if a[idx] >= c
  b.times do
    if a[idx] < c
      a[idx] = c
      idx += 1
    end
    break if idx > n-1
  end
  break if idx > n-1
end
p a.reduce(:+)


Measured memory_bytes: 21776
import java.util.*;
 
public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
     
      List<Integer> a = new ArrayList<>();
      
      for(int i=0; i<N; i++){
      a.add(sc.nextInt());
      }
      
      int sum = 0;
      for(int i=0; i<N; i++){
      for(int j=i+1; j<N; j++){
      sum +=a.get(i)*a.get(j);
      }
      }
      System.out.println(sum);
    }
}

Measured memory_bytes: 35432
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(n);++i)
#define ALL(A) A.begin(), A.end()

using namespace std;

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

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

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

	bool ok = (b - a == c - b || a - b == b - c);

	cout << (ok ? "YES" : "NO") << endl;

	return 0;
}

Measured memory_bytes: 256
//#include <bits/stdc++.h>
#include<iostream>
#include<iomanip>
#include<numeric>
#include<cstdio>
#include<cmath>
#include<string>
#include<algorithm>
#include<vector>
#include<map>
#include<stack>
#include<queue>
#include<ctype.h>
#include <fstream>
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REP(i,n) FOR(i,0,n)
using namespace std;
typedef long long ll;//int64
typedef unsigned long long ull;
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a*b/gcd(a,b);}
int dy[4]={0,1,0,-1};
//----------program from here----------

int main(){
  int N=0;
  cin >> N;
  cout << (N<1000?"ABC":"ABD") << endl;

  return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<string>
#include<vector>
#include<algorithm>
#include<utility>
using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef pair<ll, ll> P;
int main() {
	int n;
	cin >> n;
	vi l(2*n);
	for (int i = 0; i < 2*n; i++) {
		cin >> l[i];
	}
	sort(l.begin(), l.end());
	int ans = 0;
	for (int i = 0; i < n; i++) {
		ans += l[i * 2];
	}
	cout << ans << endl;
	return 0;
}

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

long long MOD = 1000000007;

long long Calc(long long A, long long B) {
	if (B == 0) return 1;
	if (B % 2 == 0) {
		long long C = Calc(A, B / 2);
		return (C * C) % MOD;
	}
	return (A * Calc(A, B - 1)) % MOD;
}

int main() {
	long long X, Y;
	cin >> X >> Y;
	if ((X + Y) % 3 != 0) {
		cout << 0 << endl;
		return 0;
	}
	long long Z = (X + Y) / 3;
	if (X < Z || Y < Z) {
		cout << 0 << endl;
		return 0;
	}
	X -= Z, Y -= Z;
	long long A = 1, B = 1, C = 1;
	for (long long i = 2; i <= Z; i++) A = (A * i) % MOD;
	for (long long i = 2; i <= Z - X; i++) B = (B * i) % MOD;
	for (long long i = 2; i <= X; i++) C = (C * i) % MOD;
	cout << ((A * Calc(B, MOD - 2)) % MOD * Calc(C, MOD - 2)) % MOD << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0; i<(n); i++)
#define all(n) begin(n),end(n)
using ll = long long;
using P = pair<int,int>;

int main() {
    string s, t;
    cin >> s >> t;
    int ans = 1e9;
    for(int i = 0; i < s.size()-t.size()+1; ++i){
        int cnt = 0;
        rep(j,t.size()){
            if(s[i+j]!=t[j]) cnt++;
        }
        ans = min(ans, cnt);
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3604
#include <bits/stdc++.h>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) (x = max(x,y))
#define mins(x,y) (x = min(x,y))
#define limit(x,l,r) max(l,min(x,r))
#define lims(x,l,r) (x = max(l,min(x,r)))
#define isin(x,l,r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)),x.end())
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,v(T),greater<T> >
#define bn(x) ((1<<x)-1)
#define dup(x,y) (((x)+(y)-1)/(y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int,int> P;
typedef set<int> S;
typedef queue<int> Q;
typedef queue<P> QP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
inline int in() { int x; scanf("%d",&x); return x;}
const ll LINF = 1001002003004005006ll;
const int INF = 1001001001;
const int MOD = 1000000007;
#define dame { puts("-1"); return 0;}
#define yn {puts("YES");}else{puts("NO");}
  
int main() {
  int A,B;
  cin >> A >> B;
  cout << max(max(A+B,A-B),A * B) << endl;
  return 0;
}

Measured memory_bytes: 256