akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
#include <ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;

#define ff              first
#define ss              second
#define int             long long
#define pb              push_back
#define mp              make_pair
#define pii             pair<int,int>
#define vi              vector<int>
#define mii             map<int,int>
#define pqb             priority_queue<int>
#define pqs             priority_queue<int,vi,greater<int> >
#define setbits(x)      __builtin_popcountll(x)
#define zrobits(x)      __builtin_ctzll(x)
#define mod             1000000007
#define inf             1e18
#define ps(x,y)         fixed<<setprecision(y)<<x
#define mk(arr,n,type)  type *arr=new type[n];
#define w(x)            int x; cin>>x; while(x--)
#define pw(b,p)         pow(b,p) + 0.1
mt19937                 rng(chrono::steady_clock::now().time_since_epoch().count());

typedef tree<int, null_type, less<int>, rb_tree_tag, tree_order_statistics_node_update> pbds;


void c_p_c()
{
	ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
/*#ifndef ONLINE_JUDGE
	freopen("input.txt", "r", stdin);
	freopen("output.txt", "w", stdout);
#endif*/
}

int32_t main()
{
	c_p_c();
	int n, m; cin >> n >> m;
	set<int> cr;
	map<int, int> cnt;
	while (m--)
	{
		int p; cin >> p;
		string s; cin >> s;

		if (s == "WA" && !cr.count(p))
			cnt[p]++;
		else if (s == "AC")
			cr.insert(p);
	}

	cout << cr.size() << ' ';

	int ans = 0;
	for (auto el : cr)
		ans += cnt[el];

	cout << ans << '\n';
	return 0;
}

Measured memory_bytes: 11264
def ch_min(a, b):
    if (a > b):
        a = b
    return a


if __name__ == "__main__":
    N = int(input())
    h = list(map(int, input().split()))
    INF = 10 ** 10
    dp = [INF] * 100010
    dp[0] = 0
    for i in range(N - 1):
        dp[i + 1] = ch_min(dp[i + 1], dp[i] + abs(h[i] - h[i + 1]))
        if (i < N - 2):
            dp[i + 2] = ch_min(dp[i + 2], dp[i] + abs(h[i] - h[i + 2]))
    print(dp[N - 1])


Measured memory_bytes: 13980
#include <iostream>

using std::cin;
using std::cout;

int main() {
  int num[2], temp;
  num[0] = num[1] = 0;
  for(int i = 0; i < 3; i++) {
    cin >> temp;
    if(temp == 5) {
      num[0]++;
    } else if(temp == 7) {
      num[1]++;
    }
  }
  if(num[0]==2 && num[1 == 1]) {
    std::cout << "YES\n";
  } else {
    std::cout << "NO\n";
  }
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define me(a) memset(a,0,sizeof(a));
typedef long long ll;

int main(){
	string s,t;
    s.clear();
    t.clear();
    cin>>s>>t;
    int len1 = s.length();
    int len2 = t.length();
    int ans = 2000;
    for(int i = 0;i <= len1-len2;i++){
        int tmp = 0;
        for(int j = 0;j < len2;j++){
            if(s[i+j] != t[j])tmp++;
        }
        ans = min(ans,tmp);
    }
    printf("%d",ans);
	//system("PAUSE");
	return 0;
}

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

int main(){
   int N;
   cin >> N;
   vector<int> A(N);
   for (int i=0; i<N; i++)
      cin >> A.at(i);

   double sum=0.0;
   for (int i=0; i<N; i++)
      sum = sum + 1.0/A.at(i);

   double result;
   result = 1.0/sum;

   cout << setprecision(11) << result << endl;

}



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

const int MAXN = 100010, MODX = 1000000007;
int dp[MAXN], n, m;

int main() {
	std::ios_base::sync_with_stdio(false);
	cin.tie(NULL); cout.tie(NULL);
	memset(dp, 0, sizeof(dp));
	cin>>n>>m;
	for (int i=0, t; i<m; i++) {
		cin>>t;
		dp[t] = -1;
	}
	dp[0] = 1;
	for (int i=0; i<n; i++)
		if (dp[i] >= 0) {
			if (dp[i+1] != -1)
				dp[i+1] = (dp[i+1] + dp[i])%MODX;
			if (dp[i+2] != -1)
				dp[i+2] = (dp[i+2] + dp[i])%MODX;
		}
	cout<<dp[n]%MODX<<endl;
	return 0;
}

Measured memory_bytes: 768
#include<bits/stdc++.h>
using namespace std;
int main(){
  ios_base::sync_with_stdio(false);cin.tie(0);
  string S;
  cin>>S;
  if(S[2] == S[3] && S[4] == S[5]){
    cout<<"Yes"<<'\n';
  }else{
    cout<<"No"<<'\n';
  }
}

Measured memory_bytes: 3584
N = int(input())
T = list(map(int, input().split()))
M = int(input())
P = []
X = []
for i in range(M):
    Pi, Xi = map(int, input().split())
    P.append(Pi)
    X.append(Xi)

S = sum(T)
for i in range(M):
    print(S - (T[P[i] - 1] - X[i]))


Measured memory_bytes: 3060
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; (i) < (n); (i)++)
#define MOD 1000000007
using namespace std;

int main(){
  int n, count = 0;
  cin >> n;
  int p[n];
  REP(i,n) {
    cin >> p[i];
  }
  for (int i = 1; i < n-1; i++) {
    if ((p[i-1] < p[i] && p[i] < p[i+1]) || (p[i-1] > p[i] && p[i] > p[i+1])) {
      count++;
    }
  }
  cout << count <<  endl;
}


Measured memory_bytes: 256
from sys import stdin
import math
import fractions
from collections import deque
from collections import Counter
import itertools

INF = 10 ** 10

K = int(stdin.readline().rstrip())
A, B = [int(x) for x in stdin.readline().rstrip().split()]

for i in range(A, B+1):
    if i % K ==0:
        print("OK")
        exit()

print("NG")



Measured memory_bytes: 72808
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <string>
#include <sstream>
#include <cstring>
#include <cstdlib>

using namespace std;

#define ALL(c) c.begin(),c.end()
#define RALL(c) c.rbegin(),c.rend()
#define SORT(x) sort((x).begin(),(x).end())
#define REP(i,x,y) for(int i=(x);i<(y);++i)
#define MP(a,b) make_pair((a),(b))
#define debug(x) #x << "=" << (x)
 
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#define dump(x) std::cerr << debug(x) << " (L:" << __LINE__ << ")" << std::endl
#else
#define dump(x)
#endif

typedef long long int ll;
typedef pair<int,int> pii;
//template<typename T> using vec=std::vector<T>;

const int INF=1<<30;
const long long int INF_=1LL<<58;
const double EPS=1e-9;
const int dx[]={1,0,-1,0},dy[]={0,1,0,-1};

template <typename T> ostream &operator<<(ostream &os, const vector<T> &vec){
	os << "[";
	for (const auto &v : vec) {
		os << v << ",";
	}
	os << "]";
	return os;
}

void Solve(){
	while(true){
		int w,d,cntw[21]={},cntd[21]={};
		cin >> w >> d;
		if(w==0&&d==0) break;
		REP(i,0,w){
			int h;
			cin >> h;
			++cntw[h];
		}
		REP(i,0,d){
			int h;
			cin >> h;
			++cntd[h];
		}

		int ans=0;
		REP(i,1,21){
			ans+=i*max(cntw[i],cntd[i]);
		}

		cout << ans << endl;
	}
}

int main(){
	std::ios::sync_with_stdio(false);
	std::cin.tie(0);
	Solve();
	return 0;
}

Measured memory_bytes: 1188
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using ull = unsigned long long; 
using pii =  pair<int, int>;
using pll =  pair<long long, long long>;
#define rep(i, n) for(int i = 0; i < (n); ++i)
#define all(x) (x).begin(),(x).end()
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
//constexpr long long MOD = 998244353LL;
template<class T, class U> inline bool chmax(T &a, U b) { if (a < b) { a = b; return true;} return false; }
template<class T, class U> inline bool chmin(T &a, U b) { if (a > b) { a = b; return true;} return false; }
////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////
 
int main() {
    ios::sync_with_stdio(false); cin.tie(nullptr);
    
    int a,b; cin >> a >> b;
    int ans = 0;
    
    int p = a+b;
    int q = a-b;
    int r = a*b;
    
    ans = max({p,q,r});
    
    cout << ans << ln;
    return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define r(i,n) for(int i=0;i<n;i++)
#define INF 1e9
using namespace std;
int main(){
  int n,m,l,k,a,h,t1,t2,t3;
  while(cin>>n>>m>>l>>k>>a>>h,n){
    set<int>rei;rei.insert(a),rei.insert(h);
    int b[n][n],re,x[n][n];
    r(i,n)r(j,n)x[i][j]=b[i][j]=INF;
    r(i,l)cin>>re,rei.insert(re);
    r(i,k)cin>>t1>>t2>>t3,b[t1][t2]=b[t2][t1]=t3;
    r(o,n)r(i,n)r(j,n)b[i][j]=min(b[i][j],b[i][o]+b[o][j]);
    r(i,n)if(rei.count(i))r(j,n)if(rei.count(j))if(b[i][j]<=m)x[i][j]=b[i][j];
    r(o,n)r(i,n)r(j,n)x[i][j]=min(x[i][j],x[i][o]+x[o][j]);
    if(x[a][h]>=INF)cout<<"Help!"<<endl;
    else if(x[a][h]<m)cout<<x[a][h]<<endl;
    else cout<<x[a][h]*2-m<<endl;
  }
}

Measured memory_bytes: 3152
/*Function Template*/
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pint;
const int MAX = 510000;
const int MOD = 1000000007;
#define rep(i, n) for(ll i = 0; i < (n); i++)
#define Rep(i, n) for(ll i = 1; i < (n); i++)
#define ALL(a)  (a).begin(),(a).end()
#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll fac[MAX], finv[MAX], inv[MAX];


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;
}
// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;
    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }

}
ll Len(ll n) {
  ll s=0;
  while(n!=0) s++, n/=10;
  return s;
}


ll Sint(ll n) {
  ll m=0,s=0,a=n;
  while(a!=0) s++, a/=10;
  for(ll i=s-1;i>=0;i--) m+=n/((ll)pow(10,i))-(n/((ll)pow(10,i+1)))*10;
  return m;
}


ll Svec(vector<ll> v){
  ll n=0;
  for(ll i=0;i<v.size();i++) n+=v[i];
  return n;
}


ll GCD(ll a,ll b) {
  return b ? GCD(b,a%b) : a;
}


ll LCM(ll a,ll b){
  return a/GCD(a,b)*b;
}


ll Factorial(ll n){
  ll m=1;
  while(n>=1) m*=n,n--;
  return m;
}

void runlength(string s,vector<pair<char,ll>> &p){
  ll x=1;
  if(s.size()==1){
    p.push_back(pair<char,ll>(s[0],1));
  }
  for(ll i=0;i<s.size()-1;i++){
    if(s[i]==s[i+1]){
      x++;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[i],x));
      }
    }else{
      p.push_back(pair<char,ll>(s[i],x));
      x=1;
      if(i==s.size()-2){
        p.push_back(pair<char,ll>(s[s.size()-1],x));
      }
    }
  }
}

ll COM(ll n,ll k){
    if (n < k) return 0;
    if (n < 0 || k < 0) return 0;
    return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}


string Toupper(string s){
  string ans="";
  rep(i,s.size()){
    if('a'<=s[i] && s[i]<='z') ans+=(char)s[i]-32;
    else ans+=s[i];
  }
  return ans;
}
string Tolower(string s){
  string ans="";
  rep(i,s.size()){
    if('A'<=s[i] && s[i]<='Z') ans+=(char)s[i]+32;
    else ans+=s[i];
  }
  return ans;
}


const int MAX_N=100010;
vector<bool> sieve_of_eratosthenes(){
  vector<bool> isPrime(MAX_N+1,true);
  for(int i=2;i<=MAX_N;i++){
    if(isPrime[i]){
      for(int j=2*i;j<=MAX_N;j+=i){
        isPrime[j]=false;
      }
    }
  }
  return isPrime;
}

vector<pint> prime_factorize(ll n){
  vector<pint> ans;
  for(ll p=2;p<=sqrt(n);p++){
    if(n%p!=0) continue;
    ll cnt=0;
    while(n%p==0){
      n/=p;
      cnt++;
    }
    ans.push_back(make_pair(p,cnt));
  }
  if(n!=1) ans.push_back(make_pair(n,1));
  return ans;
}

/*bool cmp(pint a, pint b) { return a.second < b.second; }*/

/*↓↓↓↓↓↓↓↓↓↓↓↓↓↓↓*/
int main() {
  IOS;
  ll n;
  cin>>n;
  ll ans=0;
  Rep(i,n+1){
    if(i%2==0) continue;
    ll cnt=0;
    for(ll j=1;j<=i;j++){
      if(i%j==0) cnt++;
    }
    if(cnt==8) ans++;
  }
  cout<<ans<<endl;
}

Measured memory_bytes: 256
/*
  Compete against Yourself.
  Author - Aryan Choudhary (@aryanc403)
*/

#pragma GCC optimize ("Ofast")
#pragma GCC target ("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
#pragma GCC optimize ("-ffloat-store")

#include<iostream>
#include<bits/stdc++.h>
using namespace std;
#define fo(i,n)   for(i=0;i<(n);++i)
#define repA(i,j,n)   for(i=(j);i<=(n);++i)
#define repD(i,j,n)   for(i=(j);i>=(n);--i)
#define all(x) begin(x), end(x)
#define sz(x) (int)(x).size()
#define pb push_back
#define mp make_pair
#define X first
#define Y second
#define endl "\n"

typedef long long int lli;
typedef long double mytype;
typedef pair<lli,lli> ii;
typedef vector<ii> vii;
typedef vector<lli> vi;

clock_t time_p=clock();
void aryanc403()
{
#ifdef ARYANC403
    time_p=clock()-time_p;
    cerr<<"Time Taken : "<<(float)(time_p)/CLOCKS_PER_SEC<<"\n";
#endif
}

#ifdef ARYANC403
#include "/home/aryan/codes/PastCodes/header.h"
#else
    #define dbg(args...)
#endif

const lli INF = 0xFFFFFFFFFFFFFFFL;

lli seed;
mt19937 rng(seed=chrono::steady_clock::now().time_since_epoch().count());
inline lli rnd(lli l=0,lli r=INF)
{return uniform_int_distribution<lli>(l,r)(rng);}

class CMP
{public:
bool operator()(ii a , ii b) //For min priority_queue .
{    return ! ( a.X < b.X || ( a.X==b.X && a.Y <= b.Y ));   }};

void add( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt==m.end())         m.insert({x,cnt});
    else                    jt->Y+=cnt;
}

void del( map<lli,lli> &m, lli x,lli cnt=1)
{
    auto jt=m.find(x);
    if(jt->Y<=cnt)            m.erase(jt);
    else                      jt->Y-=cnt;
}

bool cmp(const ii &a,const ii &b)
{
    return a.X<b.X||(a.X==b.X&&a.Y<b.Y);
}

const lli mod = 1000000007L;
// const lli maxN = 1000000007L;

    lli T,n,i,j,k,in,cnt,l,r,u,v,x,y;
    lli m;
    string s;
    map<lli,lli> a,b;
    //priority_queue < ii , vector < ii > , CMP > pq;// min priority_queue .

int main(void) {
    ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
    // freopen("txt.in", "r", stdin);
    // freopen("txt.out", "w", stdout);
// cout<<std::fixed<<std::setprecision(35);
// cin>>T;while(T--)
{
    lli d,c;
    cin>>n>>d>>c;
    // a.clear();a.reserve(n);
    d*=2;
    fo(i,n)
    {
        cin>>x>>in;
        in=(in+c-1)/c;
        a[x]+=in;
        b[x]=0;
        b[x+d+1]=0;
    }

    lli ans=0,cur=0;
    auto it=b.begin();
    for(auto x:a)
    {
        while(it!=b.end()&&it->X<=x.X)
        {
            cur+=it->Y;
            ++it;
        }
        x.Y-=cur;
        x.Y=max(x.Y,0LL);
        b[x.X+d+1]-=x.Y;
        cur+=x.Y;
        ans+=x.Y;
    }

    cout<<ans<<endl;

}   aryanc403();
    return 0;
}


Measured memory_bytes: 37760
n,m = map(int,input().split())
s = [0 for i in range(m)]
for i in range(n):
    t = list(map(int,input().split()))
    for i in range(1,len(t)):
        s[t[i]-1] += 1
ans = 0
for i in range(m):
    if(s[i] == n):
        ans += 1
print(ans)

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

using namespace std;

int main(){
	int n; cin >> n;
	string s;
	cin >> s;
	
	bool flag = false;

	if(n % 2 != 0){
		cout << "No" << endl;
		return 0;
	}else{
		for(int i = 0; i < n / 2; i++) {
			if(s[i] == s[n/2+i]){
				flag = true;
			}else{
				flag = false;
			}
			if(flag == false) break;
		}
	}

	if(flag) cout << "Yes" << endl;
	else cout << "No" << endl;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		String s = sc.next();
		if(s.startsWith("YAKI")) {
			System.out.println("Yes");
		} else {
			System.out.println("No");
		}
	}
}

Measured memory_bytes: 21844
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function(chunk) {
  var input = chunk.split(' ').map(Number);
  var w = input[0];
  var h = input[1];
  var x = input[2];
  var y = input[3];
  var r = input[4];

  if ((x - r) < 0 || (y - r) < 0 || w < (x + r) || h < (y + r)) {
    console.log('No');
  } else {
    console.log('Yes');
  }
});

Measured memory_bytes: 15680
#include<map>
#include<iostream>

int main(void){
  std::map<std::string,int> table;
  std::string max_freq="";
  std::string max_length="";
  std::string input;
  while(std::cin>>input){
    if(input.size()>max_length.size())
      max_length=input;
    table[input]++;
    if(table[input]>table[max_freq])
      max_freq=input;
  }
  std::cout<<max_freq<<' '<<max_length<<std::endl;
  return 0;
}


Measured memory_bytes: 3148
import java.util.*;
import java.io.*;

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

        int d[] = new int[n];
        for(int i = 0; i < n; i++){
            d[i] = Integer.parseInt(sc.next());
        }

        int num[] = new int [101];
        for(int i = 0; i < n; i++){
            num[d[i]]++;
        }

        int cnt = 0;
        for (int i = 0; i < 101; i++) {
            if(num[i] > 0){
                cnt++;
            }
        }

        System.out.println(cnt);
    }
}

Measured memory_bytes: 23380
import copy
N=int(input())
ans = [0]

if N > 1:
  ans1 = []
  a = max(ans)+1
  for i in range(a+1):
    c = copy.copy(ans)
    c.append(i)
    ans1.append(c)
    
if N > 2:
  ans2 = []
  for j in range(len(ans1)):
    a = max(ans1[j])+1
    for i in range(a+1):
      c = copy.copy(ans1[j])
      c.append(i)
      ans2.append(c)

if N > 3:
  ans3 = []
  for j in range(len(ans2)):
    a = max(ans2[j])+1
    for i in range(a+1):
      c = copy.copy(ans2[j])
      c.append(i)
      ans3.append(c)
      

if N > 4:
  ans4 = []
  for j in range(len(ans3)):
    a = max(ans3[j])+1
    for i in range(a+1):
      c = copy.copy(ans3[j])
      c.append(i)
      ans4.append(c)


if N > 5:
  ans5 = []
  for j in range(len(ans4)):
    a = max(ans4[j])+1
    for i in range(a+1):
      c = copy.copy(ans4[j])
      c.append(i)
      ans5.append(c)

      
if N > 6:
  ans6 = []
  for j in range(len(ans5)):
    a = max(ans5[j])+1
    for i in range(a+1):
      c = copy.copy(ans5[j])
      c.append(i)
      ans6.append(c)

if N > 7:
  ans7 = []
  for j in range(len(ans6)):
    a = max(ans6[j])+1
    for i in range(a+1):
      c = copy.copy(ans6[j])
      c.append(i)
      ans7.append(c)

if N > 8:
  ans8 = []
  for j in range(len(ans7)):
    a = max(ans7[j])+1
    for i in range(a+1):
      c = copy.copy(ans7[j])
      c.append(i)
      ans8.append(c)

if N > 9:
  ans9 = []
  for j in range(len(ans8)):
    a = max(ans8[j])+1
    for i in range(a+1):
      c = copy.copy(ans8[j])
      c.append(i)
      ans9.append(c)
      
aaa = "abcdefghij"
if N == 1:
  print("a")    
    
elif N ==2:
  for i in ans1:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==3:
  for i in ans2:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==4:
  for i in ans3:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==5:
  for i in ans4:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==6:
  for i in ans5:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==7:
  for i in ans6:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==8:
  for i in ans7:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
  
elif N ==9:
  for i in ans8:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)
    
elif N ==10:
  ans9.sort()
  for i in ans9:
    S = ""
    for j in i:
      S = S + aaa[j]
    print(S)


Measured memory_bytes: 34192
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long ll;
typedef pair<ll,ll> P;
const ll mod=1000000007;
const ll LINF=1LL<<60;
const int INF=1<<30;

int main(){
	int n;cin>>n;
	string s;cin>>s;
	
	for(int i = 0; i < 2; i++) {
		for(int j = 0; j < 2; j++) {
			vector<int> a(n,0);
			a[0] = i;
			a[1] = j;
			for(int k = 1; k < n - 1; k++) {
				if(a[k] == 0){//sheep
					if (s[k] == 'o'){
						a[k + 1] = a[k - 1];
					}
					else{
						a[k + 1] = !a[k - 1];
					}
				}
				else{
					if (s[k] == 'o'){
						a[k + 1] = !a[k - 1];
					}
					else{
						a[k + 1] = a[k - 1];
					}
				}
			}
			bool flag = true;
			if (a[n - 1] == 0){
				if (s[n - 1] == 'o'){
					if(a[n - 2] != a[0]){
						flag = false;
					}
				}
				else{
					if(a[n - 2] == a[0]){
						flag = false;
					}
				}
			}
			else {
				if (s[n - 1] == 'o'){
					if(a[n - 2] == a[0]){
						flag = false;
					}
				}
				else{
					if(a[n - 2] != a[0]){
						flag = false;
					}
				}
			}

			if (a[0] == 0){
				if (s[0] == 'o'){
					if(a[n - 1] != a[1]){
						flag = false;
					}
				}
				else{
					if(a[n - 1] == a[1]){
						flag = false;
					}
				}
			}
			else {
				if (s[0] == 'o'){
					if(a[n - 1] == a[1]){
						flag = false;
					}
				}
				else{
					if(a[n - 1] != a[1]){
						flag = false;
					}
				}
			}
			if (flag){
				for(int l = 0; l < a.size(); l++) {
					if(a[l] == 0){
						cout << 'S';
					}
					else{
						cout << 'W';
					}
				}
				cout << endl;	
				return 0;
			}
		}	
	}
	cout << -1 << endl;
	return 0;
}

Measured memory_bytes: 1016
#include <cstdio>
#include <vector>
#include <stack>
#include <iostream>
#include <string>
#include <tuple>
#include <random>
#include <map>
#include <queue>
#include <set>
#include <complex>
#include <algorithm>
#include <cassert>
#include <iterator>
#include <numeric>

using namespace std;

typedef long double ld;
typedef long long ll;
typedef pair<ll, ll> P;

const ll INF = 1e15;
const double eps = 1e-6;
const ll MOD = 1000000007;

int cal(int base, int x) {
	if (base < x)
		return (x - base);
	int sa = abs(base - x);
	return (sa+1) / 2 + sa % 2;
}

int main() {
	ll A, B, C;
	cin >> A >> B >> C;
	ll ans = INF;
	for (int i = 0;i <= 50;i++) {
		ans = min(ans, (ll)cal(i, A) + cal(i, B) + cal(i, C));
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 888
#include<iostream>
#include<math.h>
using namespace std;
#define MAX 100000
typedef long long llong;

int n, k;
llong T[MAX];

int check(llong P) {
	int i = 0;
	for (int j = 0; j < k; j++) {
		llong s = 0;
		while (s + T[i] <= P) {
			s += T[i];
			i++;
			if (i == n)
				return n;
		}
	}
	return i;
}


int solve() {
	llong left = 0;
	llong right = 100000 * 10000;
	llong mid;
	while (right - left > 1) {
		mid = (left + right) / 2;
		int v = check(mid);
		if (v >= n)
			right = mid;
		else
			left = mid;
	}
	return right;
}


int main(void) {
	cin >> n >> k;
	for (int i = 0; i < n; i++) cin >> T[i];
	llong ans = solve();
	cout << ans << endl;




}


Measured memory_bytes: 3904
#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;
using ll = long long;
using P = pair<int,int>;
using Graph = vector<vector<int>>;
//const long long INF = 1LL << 60;

const int mod = 1e9 + 7;
const int INF = 100000;
int h,w;
int main() {
  int a,b,c,d;
  bool ok = false;
  cin >> a >> b >> c >> d;
  if(abs(a-c) <= d) ok = true;
  else if(abs(a-b) <= d && abs(b-c) <=d) ok = true;
  cout << (ok ? "Yes" : "No") << "\n";
}


Measured memory_bytes: 256
#include "bits/stdc++.h"
using namespace std;
#ifdef _DEBUG
#include "dump.hpp"
#else
#define dump(...)
#endif

#define int long long
#define rep(i,a,b) for(int i=(a);i<(b);i++)
#define rrep(i,a,b) for(int i=(b)-1;i>=(a);i--)
#define all(c) begin(c),end(c)
const int INF = sizeof(int) == sizeof(long long) ? 0x3f3f3f3f3f3f3f3fLL : 0x3f3f3f3f;
const int MOD = 1000000007;
template<class T> bool chmax(T &a, const T &b) { if (a < b) { a = b; return true; } return false; }
template<class T> bool chmin(T &a, const T &b) { if (b < a) { a = b; return true; } return false; }

template<typename T>
vector<T> gen_v(size_t a) { return vector<T>(a); }
template<typename T, typename ...Ts>
auto gen_v(size_t a, Ts... ts) { return vector<decltype(gen_v<T>(ts...))>(a, gen_v<T>(ts...)); }
template<typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type
fill_v(T &t, const V &v) { t = v; }
template<typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type
fill_v(T &t, const V &v) { for (auto &e : t) fill_v(e, v); }

signed main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N; cin >> N;
	vector<int> X(N), Y(N), H(N); rep(i, 0, N) {
		cin >> X[i] >> Y[i] >> H[i];
	}

	rep(x, 0, 101)rep(y, 0, 101) {
		int h = -1;
		bool ok = true;
		rep(i, 0, N) {
			if (H[i] == 0)continue;
			int hh = H[i] + abs(x - X[i]) + abs(y - Y[i]);
			if (h != -1 && h != hh) {
				ok = false;
				break;
			}
			h = hh;
		}
		rep(i, 0, N) {
			if (max(h - abs(x - X[i]) - abs(y - Y[i]), 0LL) != H[i])
				ok = false;
		}
		if (ok) {
			cout << x << " " << y << " " << h << endl;
			return 0;
		}
	}

	return 0;
}

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

int main() {
  int H, W;
  cin >> H >> W;
  vector<string> C(H);
  
  for(int i = 0; i < H; i++) {
    cin >> C[i];
    cout << C[i] << endl;
    cout << C[i] << endl;
  }
  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
///Welcome to Nasif's Code
#define bug printf("bug\n");
#define bug2(var) cout<<#var<<" "<<var<<endl;
#define co(q) cout<<q<<endl;
typedef long long int ll;
typedef unsigned long long int ull;
const int MOD = (int)1e9+7;
const int MAX = 1e6;
#define pi acos(-1)
#define inf 1000000000000000LL
#define FastRead    ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
bool prime[MAX];
int prime_numbers[9999999],pos;
void sieve()
{
    prime[0]=1;
    prime[1]=1;
    for(int i=4; i<=MAX; i+=2)
        prime[i]=1;
    int root = sqrt(MAX);
    for(int i=3; i<=root; i+=2)
    {
        if(prime[i]==0)
        {
            for(int j=i*i; j<=MAX; j+=i)
            {
                prime[j]=1;
            }
        }
    }
    prime_numbers[pos++]=2;
    for(int i=3; i<MAX; i+=2)
        if(prime[i]==0)
            prime_numbers[pos++]=i;
}
int cs[MAX];
int main()
{
    FastRead
    //freopen("output.txt", "w", stdout);
    sieve();
    for(int i=1; i<=MAX; i++)
    {
        cs[i]=cs[i-1];
        int x=i;
        int y=(i+1)/2;
        if(!prime[x] && !prime[y])
            cs[i]++;
    }
    int q;
    cin>>q;
    while(q--){
        int l,r;
        cin>>l>>r;
        cout<<cs[r]-cs[l-1]<<endl;
    }


    return 0;
}


Measured memory_bytes: 8808
#include <iostream>
#include <stdio.h>
#include <fstream>
#include <algorithm>
#include <string>
#include <map>
#include <set>
#include <queue>
#include <stack>
#include <vector>
#include <limits.h>
#include <math.h>
#include <functional>

#define repeat(i,n) for (long long i = 0; (i) < (n); ++ (i))
#define debug(x) cerr << #x << ": " << x << '\n'
#define debugArray(x,n) for(long long i = 0; (i) < (n); ++ (i)) cerr << #x << "[" << i << "]: " << x[i] << '\n'

using namespace std;

typedef long long ll;
typedef pair<int,int> Pii;
typedef vector<int> vint;
typedef vector<ll> vll;
const ll INF = INT_MAX;
const ll MOD = 1e9+7;

int X[6000],Y[6000];

bool dfs(vector<vint>& g,int v){
  for(auto u:g[v]){
    if(!dfs(g,u)) return false;
  }

  vector<vint> dp(g[v].size()+1,vint(X[v]+1,INF));
  repeat(j,X[v]+1){
    dp[0][j] = 0;
  }
  repeat(i,g[v].size()){
    repeat(j,X[v]+1){
      if(j-X[g[v][i]]>=0 && dp[i][j-X[g[v][i]]] != INF){
        dp[i+1][j] = min(dp[i+1][j],dp[i][j-X[g[v][i]]]+Y[g[v][i]]);
      }
      if(j-Y[g[v][i]]>=0 && dp[i][j-Y[g[v][i]]] != INF){
        dp[i+1][j] = min(dp[i+1][j],dp[i][j-Y[g[v][i]]]+X[g[v][i]]);
      }
    }
  }

  Y[v] = dp[g[v].size()][X[v]];
  if(Y[v] == INF){
    return false;
  }

  return true;
}

int main() {
  int N;cin >> N;
  vector<vint> g(N);
  repeat(i,N-1){
    int P;cin >> P;P--;
    g[P].push_back(i+1);
  }
  repeat(i,N) cin >> X[i];
  cout << (dfs(g,0)? "POSSIBLE":"IMPOSSIBLE") << endl;
  debugArray(Y,N);
  //debugArray(g[0],g[0].size());
  return 0;
}


Measured memory_bytes: 1264
#include<bits/stdc++.h>
#define rep(i,a) for(int i=(int)0;i<(int)a;++i)
#define rrep(i,a) for(int i=(int)a-1;i>=0;--i)
#define REP(i,a,b) for(int i=(int)a;i<(int)b;++i)
#define RREP(i,a,b) for(int i=(int)a-1;i>=b;--i)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(),x.end()
#define rall(x) x.rbegin(),x.rend()
typedef std::vector<int> vi;
typedef std::vector<std::vector<int>> vvi;
typedef std::vector<long long> vl;
typedef std::vector<std::vector<long long>> vvl;
#define out(x) cout<<x<<"\n";
using ll=long long;
constexpr ll mod = 1e9 + 7;
constexpr ll INF = 1LL << 60;

ll gcd(ll n, ll m) {
    ll tmp;
    while (m!=0) {
        tmp = n % m;
        n = m;
        m = tmp;
    }
    return n;
}

ll lcm(ll n, ll m) {
    return abs(n) / gcd(n, m)*abs(m);//gl=xy
}
 
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;
}
 
using namespace std;

#define int64_t ll

vector< int64_t > divisor(int64_t n) {
  vector< int64_t > ret;
  for(int64_t i = 1; i * i <= n; i++) {
    if(n % i == 0) {
      ret.push_back(i);
      if(i * i != n) ret.push_back(n / i);
    }
  }
  sort(begin(ret), end(ret));
  return (ret);
}


void solve(){
  ll n;
  cin>>n;
  ll ans=1;
  //if(sqrt(n)<n-1)++ans;
  set<ll>st;
  st.emplace(n);
  for(ll i=2;i*i<=n;++i){
    ll nn=n;
    //cerr<<i<<endl;
    while((nn>=i)){
      if(nn%i==0)nn/=i;
      else nn=nn%i;
    }
    if(nn==1)++ans,st.emplace(i);
  }
  for(ll i=1;i*i<=n;++i){
    if((n-1)%i==0){
      if((!st.count((n-1)/i))&&((n-1)/i>1))++ans;
      st.emplace((n-1)/i);
    }
  }
  cout<<ans;
}


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


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

using namespace std;

int main()
{
    int n,l[11],sum=0;
    cin>>n;
    for(int i=0;i<n;i++){
        cin>>l[i];
    }
    sort(l,l+n);
    for(int i=0;i<n-1;i++){
        sum+=l[i];
    }
    if(sum>l[n-1]){
        cout<<"Yes";
    }
    else cout<<"No";
    return 0;
}


Measured memory_bytes: 3584
#include<iostream>
#include<stdio.h>
#include<string.h>
#include<bits/stdc++.h>
using namespace std;
const int maxn=1e5+10;
int vis[maxn];
vector<int>s[maxn];
void dfs(int x)
{
     for(int i=0;i<s[x].size();i++)
     {
         if(vis[s[x][i]]==0)
         {
             vis[s[x][i]]=1;
             dfs(s[x][i]);
         }
     }
}
int main()
{
      int n,m,x,y,z;
      cin>>n>>m;
      for(int i=0;i<m;i++)
      {  cin>>x>>y>>z;
          s[x].push_back(y);
          s[y].push_back(x);
      }
      int couts=0;
      for(int i=1;i<=n;i++)
      {
        if(vis[i]==0)
        {
            vis[i]=1;
            dfs(i);
            couts++;
        }
      }
      printf("%d\n",couts);
          return 0;
    }


Measured memory_bytes: 9216
using System;

public class AtCoder{
	public static void Main(){
		
		int n;
		n = int.Parse(Console.ReadLine().Trim());
		int[] a = new int[n];
		
		for (int i=0; i<n; i++){
			a[i] = int.Parse(Console.ReadLine().Trim());
		}
		
		long s1 = 0;
		long s2 = 0;
		
		Array.Sort(a);
		
		if(n%2==1){
			for(int i=0; i<n; i++){
				if(i<=(n-2)/2){
					s1 -= a[i]*2;
				}else if(i<=2+(n-2)/2){
					s1 += a[i];
				}else{
					s1 += a[i]*2;
				}
			}
			for(int i=0; i<n; i++){
				if(i<=-1+(n-2)/2){
					s2 -= a[i]*2;
				}else if(i<=1+(n-2)/2){
					s2 -= a[i];
				}else{
					s2 += a[i]*2;
				}
			}
			if(s1<s2){
				Console.WriteLine(s2);
			}else{
				Console.WriteLine(s1);
			}
		}else{
			for(int i=0; i<n; i++){
				if(i<=-1+(n-2)/2){
					s1 -= a[i]*2;
				}else if(i<=(n-2)/2){
					s1 -= a[i];
				}else if(i<=1+(n-2)/2){
					s1 += a[i];
				}else{
					s1 += a[i]*2;
				}
			}
				Console.WriteLine(s1);
		}
	}
}

Measured memory_bytes: 15580
#include <stdio.h>

int main( void ) {
	int a, b;

	while ( scanf( "%d %d", &a, &b ) != EOF ) {
		int i, min, gcd = 1, lcm = 1, start = 2;

		while( 1 ) {
			min = ( a > b ? b : a );
			for ( i = start; i <= min / 2; i++ )
				if ( a % i + b % i == 0 ) {
					a /= i;
					b /= i;
					gcd = lcm *= i;
					start = i;
					break;
				}
			if ( i > min / 2 )
				break;
		}
		if ( a % min + b % min == 0 ) {
			a /= min;
			b /= min;
			gcd = lcm *= min;
		}
		lcm *= a * b;

		printf( "%d %d\n", gcd, lcm );
	}

	return 0;
}

Measured memory_bytes: 596
#import numpy as np
def cin():
    return map(int, input().split())


n = int(input())

cnt = 0
if n % 2 == 1:
    print(0)
    exit(0)

div = 1
n //= 2

for i in range(33):
    div *= 5
    cnt += n // div

print(cnt)


Measured memory_bytes: 2940
#include <iostream>
#include <algorithm>
#include <cstdio>
#include <vector>
#include <cmath>
#include <iomanip>
#include <bitset>
#include <string>
#include <cstring>
#include <stdlib.h>
using namespace std;
//cout <<  << endl;
typedef long long int ll;
typedef long double ld;

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

#define MAX_N 2010

const long long INF = 1LL << 60;

//境界値に注意！！！

int main() {
    ll a,b;
    string s;
    cin >> a >> b >> s;
    for (ll i=0;i<=a+b;i++){
        if (i==a && s[i]!='-'){
            cout << "No" << endl;
            return 0;
        }
        if (i!=a && s[i]=='-'){
            cout << "No" << endl;
            return 0;
        }
    }
    cout << "Yes" << endl;
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define ll long long int
int main(void){
    int count=0;
    string s;
    cin>>s;
    for(int i=0;i<s.size();i++){
        if(s[i]=='g')count++;
        else count--;
    }
    cout<<count/2<<endl;
}

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

int main()
{
  int R;
  cin >> R;
  
  string ans;
  if (R < 1200) ans = "ABC";
  else if (R < 2800) ans = "ARC";
  else ans = "AGC";
  
  cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <string>
#include <math.h>

using namespace std;
#define ll long long
#define FOR(i, n, m) for(int i=n; i<m; ++i)

int main(){
  ll N;
  cin >> N;
  string W[110];
  FOR(i, 0, N) cin >> W[i];
  
  int seflag = 1;
  int doflag = 1;
  
  FOR(i, 0, N-1){
    if(W[i+1][0]!=W[i][W[i].length()-1]) {
      seflag = 0;
    }
  }
  
  FOR(i, 0, N){
    FOR(j, i+1, N){
      if(W[i]==W[j]) doflag = 0;
    }
  }
  
  if(seflag==1 && doflag==1) cout << "Yes" << endl;
  else cout << "No" << endl;

      
}

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

using namespace std;

typedef long long LL;
typedef pair<int,int> pi;
typedef vector<int> vi;
#define ST first
#define ND second
#define PB push_back
#define DET(a,b,c) (LL(b.x-a.x)*LL((c.y-a.y))-LL((c.x-a.x))*LL((b.y-a.y)))

const int MAXN = 301;
double pro[MAXN][MAXN][MAXN];
double ev[MAXN][MAXN][MAXN];
int n;
int cnt[4];


int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cin>>n;
    for(int a,i=0; i<n;i++) {
        cin>>a;
        cnt[a]++;
    }
    pro[cnt[1]][cnt[2]][cnt[3]] = 1;
    for(int c = n; c>=0; c--) {
        for(int b=n; b>=0;b--) {
            for(int a=n; a>=0;a--) {
                if(a+b+c>n) continue;
                if(a+b+c==0) continue;
                double pro0 = (double)(n-a-b-c)/n;
                double e0 = (double)pro0/(1-pro0)+1;
                ev[a][b][c] += e0 * pro[a][b][c];
                //1
                if(a>0) {
                    pro[a-1][b][c]+=pro[a][b][c]*((double)a/(a+b+c));
                    ev[a-1][b][c]+=ev[a][b][c]*((double)a/(a+b+c));
                }
                //2
                if(b>0) {
                    pro[a+1][b-1][c]+=pro[a][b][c]*((double)b/(a+b+c));
                    ev[a+1][b-1][c]+=ev[a][b][c]*((double)b/(a+b+c));
                }
                //3
                if(c>0) {
                    pro[a][b+1][c-1]+=pro[a][b][c]*((double)c/(a+b+c));
                    ev[a][b+1][c-1]+=ev[a][b][c]*((double)c/(a+b+c));
                }
            }
        }
    }
    cout<<setprecision(10)<<ev[0][0][0];
}


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

int main() {
  ios::sync_with_stdio(0);
  cin.tie(0);
  int N;
  cin >> N;
  bool has7 = false;
  while (N && !has7) {
      int d = N % 10;
      if (d == 7) {
          has7 = true;
      }
      N /= 10;
  }
  cout << (has7 ? "Yes" : "No") << endl;
  return 0;
}

Measured memory_bytes: 3636
m, k = map(int, input().split())
if m == 0:
    if k == 0:
        print(0, 0)
    else:
        print(-1)
elif m == 1:
    if k == 0:
        print(0, 1, 1, 0)
    else:
        print(-1)
else:
    a = 2 ** m - 1
    if k > a:
        print(-1)
    else:
        for num in range(a + 1):
            if num == k:
                continue
            print(num, end = " ")
        print(k, end = " ")
        for num in range(a, -1, -1):
            if num == k:
                continue
            print(num, end = " ")
        print(k)

Measured memory_bytes: 9228
#include<iostream>
#include<algorithm>
#include<iomanip>
#include<utility>
#include<cmath>
#include<string>

using namespace std;

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

cout << a[0]+a[1] << endl;

  return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

int main(){
  int n, m;
  cin >> n >> m;
  string s;
  cin >> s;
  int pos = n;
  vector<int> ans;
  while(1){
    bool f = false;
    rep(i, m){
      int nx = pos - m + i;
      if(nx < 0) continue;
      if(s.at(nx) == '0'){
        f = true;
        pos = nx;
        ans.push_back(m-i);
        break;
      }
    }
    if(f == false){
      cout << -1 << endl;
      return 0;
    }
    if(pos == 0){
      rrep(i, ans.size()){
        if(i != ans.size() - 1) cout << " ";
        cout << ans.at(i);
      }
      cout << endl;
      return 0;
    }
  }
  return 0;
}

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

int main() {
	int n, s = 0; cin >> n;
	vector<int> A(n);
	for(int i = 0; i < n; i++) cin >> A[i];
	sort(A.begin(), A.end());
//	for(int x : A) cout << x << " "; cout << "\n";
	for(int i = 0; i < n; i++)
		for(int j = i + 1; j < n; j++)
			for(int k = j + 1; k < n; k++)
				s += (A[i] != A[j] && A[j] != A[k] && A[k] < A[i] + A[j]);
//				if(A[i] != A[j] && A[j] != A[k] && A[k] < A[i] + A[j]) {
//					cout << A[i] << " " << A[j] << " " << A[k] << "\n";
//				}
	cout << s;
}


Measured memory_bytes: 3632
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(v,n) for(int i=0;i<n;i++){cin >> v.at(i);} //配列vにn個の要素を入力する

int main(){
    int k,s;
    cin >> k >> s;
    int ans = 0;
    for(int x = 0;x <= k;x++){
        for(int y = 0;y <= k;y++){
            int z = s - x - y;
            if(0 <= z && z <= k){ans++;}
        }
    }
    cout << ans;
}

Measured memory_bytes: 256
import java.util.Scanner;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int[] dp = new int[1000000 + 1];
    int[] dp2 = new int[1000000 + 1];
    for (int i = 1; i < dp.length; i++) {
      dp[i] = i;
      dp2[i] = i;
    }
    for (int i = 1; ; i++) {
      int k = (i * (i + 1) * (i + 2)) / 6;
      if (k >= 1000000) {
        break;
      }
      for (int j = 0; j + k < 1000000; j++) {
        dp[j + k] = Math.min(dp[j + k], dp[j] + 1);
      }
      if (k % 2 == 1) {
        for (int j = 0; j + k < 1000000; j++) {
          dp2[j + k] = Math.min(dp2[j + k], dp2[j] + 1);
        }
      }
    }

    while (true) {
      int n = sc.nextInt();
      if (n == 0) {
        break;
      }
      System.out.println(dp[n] + " " + dp2[n]);
    }
  }
}

Measured memory_bytes: 35300
n = int(input())
a = list(map(int,input().split()))
c = [0]*9
for i in a:
    b = i//400
    if b >= 8:
        c[8] += 1
    else:
        c[b] =1

print(sum(c[:8])+(1 if c[8] and sum(c[:8])==0 else 0),sum(c[:8])+c[8])

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
int main()
{
	std::ios_base::sync_with_stdio(false); cin.tie(0); cout.tie(0);
    long test=1;
// 	cin>>test;	
	while(test--)
	{
	long a,b=0,c,k,i,n,temp;
	string s;
		cin>>s;
		string ans="";
		for(i=0;i<s.length();i++)
		{
		    if(s[i]=='B' && ans.length()!=0)
		    ans=ans.substr(0,ans.length()-1);
		    else if(s[i]=='1')
		    ans+='1';
		    else if(s[i]=='0') ans+='0';
		}
		
		cout<<ans;
    }
    
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
using namespace std;
#define NMAX 110000
#define rep(i,a,b) for(int i=a;i<b;i++)
#define rrep(i,a,b) for(int i=a;i>=b;i--)
typedef unsigned long long int ll;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;

int main()
{	
    ll p,q,r;
    cin >> p >> q >> r;

    ll sum = p+q+r;
    ll maxi(p);
    if(q>maxi) maxi = q;
    if(r>maxi) maxi = r;

    cout << sum-maxi << endl;
    return 0;
}

Measured memory_bytes: 256
#include<iostream>
#include<cstdlib>

using namespace std;

int main() {
	int a, b, c, d;
	cin >> a >> b >> c >> d;

	int x = abs(b - a);
	int y = abs(c - b);
	int z = abs(c - a);

	if (x <= d && y <= d || z <= d) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}

	return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define rep(i,n) for(int i=0;i<(int)n;i++)
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define dbg(...) do{cerr<<__LINE__<<": ";dbgprint(#__VA_ARGS__, __VA_ARGS__);}while(0);

using namespace std;

namespace std{template<class S,class T>struct hash<pair<S,T>>{size_t operator()(const pair<S,T>&p)const{return ((size_t)1e9+7)*hash<S>()(p.first)+hash<T>()(p.second);}};template<class T>struct hash<vector<T>>{size_t operator()(const vector<T> &v)const{size_t h=0;for(auto i : v)h=h*((size_t)1e9+7)+hash<T>()(i)+1;return h;}};}
template<class T>ostream& operator<<(ostream &os, const vector<T> &v){os<<"[ ";rep(i,v.size())os<<v[i]<<(i==v.size()-1?" ]":", ");return os;}template<class T>ostream& operator<<(ostream &os,const set<T> &v){os<<"{ "; for(const auto &i:v)os<<i<<", ";return os<<"}";}
template<class T,class U>ostream& operator<<(ostream &os,const map<T,U> &v){os<<"{";for(const auto &i:v)os<<" "<<i.first<<": "<<i.second<<",";return os<<"}";}template<class T,class U>ostream& operator<<(ostream &os,const pair<T,U> &p){return os<<"("<<p.first<<", "<<p.second<<")";}
void dbgprint(const string &fmt){cerr<<endl;}template<class H,class... T>void dbgprint(const string &fmt,const H &h,const T&... r){cerr<<fmt.substr(0,fmt.find(","))<<"= "<<h<<" ";dbgprint(fmt.substr(fmt.find(",")+1),r...);}
typedef long long ll;typedef vector<int> vi;typedef pair<int,int> pi;const int inf = (int)1e9;const double INF = 1e12, EPS = 1e-9;

struct BIT{
	int N;
	vi bit;
	BIT(int N):N(N){
		bit.resize(N + 1);
	}
	void add(int i, int x){
		for(i++; i <= N; i += i & -i) bit[i] += x;
	}
	int sum(int i){
		int res = 0;
		for(i++; i; i -= i & -i) res += bit[i];
		return res;
	}
};

int main(){
	cin.tie(0); cin.sync_with_stdio(0);
	
	int n, q;
	string s; cin >> n >> s >> q;
	
	vector<BIT> bits;
	rep(i, 26){
		bits.emplace_back(n);
		rep(j, n) if(s[j] - 'a' == i) bits[i].add(j, 1);
	}
	
	rep(it, q){
		int t; cin >> t;
		if(t == 1){
			int p; char c; cin >> p >> c; p--;
			int f = s[p] - 'a', t = c - 'a';
			bits[f].add(p, -1);
			bits[t].add(p, 1);
			s[p] = c;
		}
		else{
			int l, r, res = 0; cin >> l >> r;
			rep(i, 26) res += bits[i].sum(r - 1) - bits[i].sum(l - 2) > 0;
			cout << res << endl;
		}
	}
	return 0;
}

Measured memory_bytes: 51868
import std.stdio, std.string, std.conv, std.range;
import std.algorithm, std.array, std.typecons, std.container;
import std.math, std.numeric, std.random, core.bitop;

enum inf = 1_001_001_001;
enum infl = 1_001_001_001_001_001_001L;

void main() {
    int a, b, c, d;
    scan(a, b, c, d);

    foreach (i; 0 .. 1000) {
        if (a <= 0 || c <= 0) break;
        if (i % 2 == 0) {
            c -= b;
        }
        else {
            a -= d;
        }
    }

    yes(c <= 0);
}

void scan(T...)(ref T args) {
    auto line = readln.split; // @suppress(dscanner.suspicious.unmodified)
    foreach (ref arg; args) {
        arg = line.front.to!(typeof(arg));
        line.popFront;
    }
    assert(line.empty);
}

void fillAll(R, T)(ref R arr, T value) {
    static if (is(typeof(arr[] = value))) {
        arr[] = value;
    }
    else {
        foreach (ref e; arr) {
            fillAll(e, value);
        }
    }
}

bool chmin(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x > arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

bool chmax(T, U...)(ref T x, U args) {
    bool isChanged;
    foreach (arg; args)
        if (x < arg) {
            x = arg;
            isChanged = true;
        }
    return isChanged;
}

void yes(bool ok, string y = "Yes", string n = "No") {
    return writeln(ok ? y : n);
}


Measured memory_bytes: 2692
#include <bits/stdc++.h>
#include <algorithm>
#include <math.h>
#define rep(i, n) for (long long i = 0; i < (long long)(n); i++)
#define INF 999999999
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );

using llong = long long;
using namespace std;

int main(){
    llong n,x,d[103],l[103];
    d[0] = 0;
    cin >> n >> x;
    rep(i,n){
        cin >> l[i];
        d[i+1] = d[i] + l[i];
    }
    rep(i,n+1) if(d[i] > x){
        cout << i << endl;
        return 0;
    }
    cout << n+1 << endl;
}

Measured memory_bytes: 256
N,M=map(int, input().split())
H=list(map(int, input().split()))
flag=[1]*N
for i in range(M):
    A,B=map(int, input().split())
    if H[A-1]>H[B-1]:
        flag[B-1]=0 
    elif H[A-1]<H[B-1]:
        flag[A-1]=0
    else:
        flag[A-1]=0
        flag[B-1]=0
print(sum(flag))

Measured memory_bytes: 19972
n=int(input())
p=list(map(int,input().split()))
a = [0]*n
b = [0]*n
for i in range(n):
  a[p[i] - 1] += i
  a[i] += n * (i + 1)
  b[i] = n * (n - i)
print(' '.join(map(str,a)))
print(' '.join(map(str,b)))

Measured memory_bytes: 7232
/************************************
/ AUTHOR : YATHARTH GOSWAMI         /  
/ ALIAS : hacker_yg                 /
/ INSTITUTE : IIT Kanpur            /
************************************/
//          TEMPLATE                //

#include <bits/stdc++.h>

#define ll long long
#define MOD 1000000007
#define pb push_back
#define mp make_pair
#define F first
#define S second

using namespace std;

int main(){
    int n;
    cin >> n;
    cout << (n/2) + n%2;
    return 0;
}



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

using namespace std;
using ll =long long;
typedef pair<int,int> P;
#define SORT(a) sort((a).begin(),(a).end())
#define rSORT(a) reverse((a).begin(),(a).end())
#define For(i, a, b)    for(int i = (a) ; i < (b) ; ++i)
#define rep(i, n)       For(i, 0, n)
#define debug(x)  cerr << #x << " = " << (x) << endl;
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; }
//Write From this Line

int main()
{
	int n;
	cin >> n;
	vector<int> a(n);
	rep(i, n)cin>>a[i];
	ll sum = 0;
	rep(i,n) sum += a[i];

	ll M = 1e9;
	int ans = -1;
	rep(i,n){
		ll diff = abs(sum - n * a[i]);
		if(M > diff){
			M = diff;
			ans = i;
		}
	}
	cout << ans << endl;
}


Measured memory_bytes: 3636
import java.util.*;

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

        long rt = (long) Math.sqrt(n);
        while (n % rt != 0) {
            rt--;
        }
        long result = rt + n / rt - 2;

        System.out.println(result);
    }
}


Measured memory_bytes: 23764
#include<bits/stdc++.h>
using namespace std;
int n;
const int maxn=2e5+100;
int a[maxn],sum[maxn];
int mod=2019;
string st;
int kasumi(int x,int p){
	int s=1;
	while(p){
//		cout << "x,p=" << x << ' ' << p << ' ' << s << endl;
		if (p&1) s=(s*x)%mod;
		x=(x*x)%mod,p/=2;
	}
	return s;
}
int main(){
//	cout << kasumi(3,mod-2);
	string st;cin>>st;
	n=st.length();
//	for (int i=1;i<=n;i++) cout << kasumi(i,mod-2) << ' ';cout << endl;
	for (int i=1;i<=n;i++) a[i]=(a[i-1]*10+(st[i-1]-'0'))%mod;
//	for(int i=1;i<=n;i++) cout << a[i] << ' ';cout << endl;
	for (int i=1;i<=n;i++) a[i]=(a[i]*kasumi(10,n-i))%mod;
//	for(int i=1;i<=n;i++) cout << a[i] << ' ';cout << endl;
	int ans=0;
	for (int i=0;i<=n;i++){
		ans+=sum[a[i]];
		sum[a[i]]++;
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 4524