akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
int main(){
	int k;
	cin>>k;
	int a,b;
	cin>>a>>b;
	int count=0;
for(int i=a;i<=b;i++)
	if(i%k==0){
		count++;
	}
	int x=count;
	if(x){
	
	cout<<"OK"<<endl;
}
else{

			cout<<"NG"<<endl;
	
}
}

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

using namespace std;

using int64 = long long;

int main() {
  string s;
  cin >> s;
  int64 ret = 0;
  int pre = 0;
  for(auto &p : s) {
    if(p == 'B') {
      pre++;
    } else {
      ret += pre;
    }
  }

  cout << ret << endl;


}

Measured memory_bytes: 1152
macro_rules !input {(source =$s :expr ,$($r :tt ) *) =>{let mut iter =$s .split_whitespace () ;let mut next =||{iter .next () .unwrap () } ;input_inner !{next ,$($r ) *} } ;($($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 :ty ) =>{$next () .parse ::<$t >() .expect ("Parse error" ) } ;}

fn main() {
   input! {
      n: usize,
      txy: [(i32, i32, i32); n]
   }
   let mut tn = 0;
   let mut xn = 0;
   let mut yn = 0;
   for i in 0..n {
      let (t, x, y) = txy[i];
      let dt = t - tn;
      let dx = (x - xn).abs();
      let dy = (y - yn).abs();
      if dt < dx + dy || (dt - dx - dy) % 2 == 1 {
         println!("No");
         return;
      }
      tn = t;
      xn = x;
      yn = y;
   }
   println!("Yes");
}


Measured memory_bytes: 4352
Nstr = input()
N = int(Nstr)

l = len(Nstr)

_sum = 0

# if odd
if l % 2 == 1:
    _sum += (N - (10**(l-1)-1))
else:
    pass

for keta in range(1,l,2):
    if keta % 2 == 0:
        continue
    _sum += (10**(keta) -1) - (10**(keta-1) -1)

print(_sum)


Measured memory_bytes: 38384
#include <bits/stdc++.h>
#define GET_REP(_1, _2, _3, NAME, ...) NAME
#define rep(...) GET_REP(__VA_ARGS__, irep, _rep)(__VA_ARGS__)
#define rep1(...) GET_REP(__VA_ARGS__, irep1, _rep1)(__VA_ARGS__)
#define _rep(i, n) irep (i, 0, n)
#define _rep1(i, n) irep1(i, 1, n)
#define irep(i, a, n) for (int i = a; i < (int)(n); ++i)
#define irep1(i, a, n) for (int i = a; i <= (int)(n); ++i)
#define rrep(i, n) for (int i = (int)(n) - 1; i >= 0; --i)
#define rrep1(i, n) for (int i = (int)(n); i >= 1; --i)
#define allrep(X, x) for (auto &&X : x)
#define all(x) begin(x), end(x)
#ifdef LOCAL
  #include "../../Lib/cout_container.hpp"
  #define debug(x) cout << #x " => " << (x) << endl
#else
  #define debug(x) 0
#endif
using lint = long long;
constexpr int    INF  = 1 << 28;
constexpr lint   INFL = 1LL << 60;
constexpr int    MOD  = (int)1e9 + 7;
constexpr double EPS  = 1e-9;
using namespace std;
namespace { struct INIT { INIT() { cin.tie(0); ios::sync_with_stdio(false); cout << fixed << setprecision(15); } } INIT; }

int main(void) {
  int n;
  cin >> n;
  vector<int> p(n);
  rep (i, n) cin >> p[i];
  sort(all(p));
  int sum = accumulate(p.begin(), --p.end(), 0);
  sum += p.back() / 2;
  cout << sum << endl;
  return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <vector>
#include <utility>
#include <tuple>
#include <algorithm>
#include <functional>

using namespace std;

typedef pair <int, int> ii;

int N, K;
vector <int> adjList[100005];
int kp[100005];
vector <ii> sortedDist;
bool fixed[100005];
int ans;

int p[20][100005], dist[100005];
void root(int u, int prevP, int prevDist)
{
    p[0][u] = prevP, dist[u] = prevDist;
    for (int v : adjList[u])
    {
        if (v == prevP) continue;
        root(v, u, prevDist + 1);
    }
}

void markFixed(int u)
{
    fixed[u] = true;
    for (int v : adjList[u])
    {
        if (v == p[0][u]) continue;
        if (!fixed[v]) markFixed(v);
    }
}

int main()
{
    scanf("%d%d", &N, &K);
    for (int i = 1; i <= N; i++)
    {
        int a; scanf("%d", &a);
        if (i == 1 && a != 1) ans++;
        else adjList[i].push_back(a), adjList[a].push_back(i);
    }
    root(1, -1, 0);
    for (int k = 1; k < 20; k++) for (int i = 1; i <= N; i++)
    {
        if (p[k-1][i] == -1) p[k][i] = -1;
        else p[k][i] = p[k-1][p[k-1][i]];
    }
    for (int i = 1; i <= N; i++)
    {
        kp[i] = i;
        int temp = K - 1;
        for (int k = 19; k >= 0; k--)
        {
            if (temp >= (1 << k))
            {
                if (kp[i] != -1) kp[i] = p[k][kp[i]];
                temp -= (1 << k);
            }
        }
    }
    for (int i = 1; i <= N; i++)
    {
        sortedDist.emplace_back(dist[i], i);
    }
    sort(sortedDist.begin(), sortedDist.end(), greater <ii>());
    for (ii temp : sortedDist)
    {
        int d, u; tie(d, u) = temp;
        if (fixed[u]) continue;
        else
        {
            int parent = kp[u];
            if (parent != -1)
            {
                markFixed(parent);
                if (p[0][parent] != 1 && parent != 1) ans++;
            }
        }
    }
    printf("%d\n", ans);
    return 0;
}


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

int main(){
    int n, s;
    int a[10] = {0,1,2,3,4,5,6,7,8,9};
    int mat[10][10001] = {};
    
    do{
        int tmp = 0;
        for(int i = 0; i < 10; i++){
            tmp += (i+1) * a[i];
            mat[i][tmp]++;
        }
    }while(next_permutation(a, a+10));

    while(cin >> n >> s){
        int ans = mat[n-1][s];
        for(int i = 1; i <= 10-n; i++)  ans /= i;
        cout << ans << endl;
    }

    return 0;
}


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

using namespace std;

int main(){
    vector<int> x(5);
    
    for(int i=0;i<5;i++)
        cin>>x[i];
    
    for(int i=0;i<5;i++){
        if(x[i]==0){
            if(i==0){
                cout<<x[i+1]-1<<endl;
                break;
            }else{
                cout<<x[i-1]+1<<endl;
                break;
            }      
        }
    }
}

Measured memory_bytes: 3572
x, n= map(int, input().split())
p = list(map(int, input().split()))
pc = 1000
ans = 1000

for i in range(102):
    if i in p:
        ans = ans
    else:
        #print(i+1)
        if abs(x - i) < pc:
            #print(abs(x - i+1))
            #print(i+1)
            pc = abs(x - i)
            #if i+1 < ans:
            ans = i
    #print(i+1)
if abs(x + 1) <= pc:
    print(-1)
else:
    print(ans)

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

#define FOR(a,b,c) for (int a=(b);a<(c);++a)
#define REP(i,n) FOR(i,0,n)
#define ll long long
#define pii pair<int,int>
#define x first
#define y second
#define pb push_back
#define lf double

using namespace std;

const int MAX = (int)1e6 + 5;
const ll INF = (ll)1e18;

int p[MAX];
ll dp[MAX][3];

ll f(int x,int y){
	if (x<0) return 0;
	return dp[x][y];
}

int main(){
	int n;
	scanf ("%d",&n);
	REP(i,n){
		scanf ("%d",p+i);
	}
	REP(i,n) REP(j,3) dp[i][j]=-INF;
	dp[0][0]=p[0];
	dp[1][1]=p[1];
	FOR(i,2,n){
		int a=p[i];
		dp[i][0]=max(dp[i][0],f(i-2,0)+a);
		dp[i][1]=max(dp[i][1],f(i-2,1)+a);
		dp[i][1]=max(dp[i][1],f(i-3,0)+a);
		dp[i][2]=max(dp[i][2],f(i-2,2)+a);
		dp[i][2]=max(dp[i][2],f(i-3,1)+a);
		dp[i][2]=max(dp[i][2],f(i-4,0)+a);
		
	}
	if (n&1){
		ll sol=dp[n-1][2];
		sol=max(sol,dp[n-2][1]);
		sol=max(sol,dp[n-3][0]);
		printf ("%lld\n",sol);
	}
	else{
		ll sol=dp[n-1][1];
		sol=max(sol,dp[n-2][0]);
		printf ("%lld\n",sol);
		
	}
	
	
	return 0;
}


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

map<int,int> X;
int N;
int query(int a,int b){
  cout << "? " << a << " "<< b << endl;
  cout.flush();
  int ret; cin >> ret;
  return ret;
}

int solve(){
  int a = query(1, 2);
  X[0] = 1;
  X[a] = 2;
  int f = 1;
  int x = a;
  for(int i=2;i<N;i++){
    int b = query( i,i+1 );
    int c = query( i-1,i+1 );
    if( a + c == b || b+c == a ) {
      f *= -1;
    }
    x = x + f*b;
    X[x] = i+1;
    a = b;
  }
  cout << "!";
  for( auto p : X) {
    cout << " " << p.second;
  }
  cout << endl;
  cout.flush();
}

int main(){
  cin >> N;
  if( N == 1 )
    cout << "! 1" << endl;
  else
    solve();

}

Measured memory_bytes: 3652
n = int(input())

def f(n):
    n = n-1
    m = 'abcdefghijklmnopqrstuvwxyz'
    ans = ''
    if n // 26 == 0:
        ans += m[(n%26)]
        return ans
    ans += m[(n%26)]
    return f(n//26) + ans

print(f(n))

Measured memory_bytes: 61712
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<string>
#include<algorithm>
using namespace std;
const int MaxN = 1e5;

int main()
{
	long long T,ans,x,y;
	while(~scanf("%lld %lld",&x,&y))
	{
		T = x*y;
		for(int i = 1;;i++)
		{
			ans = x*i;
			if(ans > T) 
			{
				ans = -1;
				break;
			}
			if(ans%y != 0) break;
			if(x % y == 0)
			{
				ans = -1;
				break;
			}
		}
		printf("%lld\n",ans);
	}
	return 0;
}

Measured memory_bytes: 128
#include <stdio.h>

int
main(int argc, char *argv[])
{
  double w, h, x, y;
  scanf("%lf %lf %lf %lf", &w, &h, &x, &y);

  printf("%lf ", w * (h / 2));
  if(x == w / 2 && y == h / 2) printf("1\n");
  else printf("0\n");

  return 0;
}


Measured memory_bytes: 128
n, m = map(int, input().split())
sc = [list(map(int, input().split())) for _ in range(m)]

if n == 1:
    t = 0
else:
    t = 10 ** (n - 1)

for i in range(t, 10 ** n):
    j = str(i)
    f = 0
    for s, c in sc:
        if j[s - 1] != str(c):
            break
        f += 1
    if f == m:
        print(i)
        exit()
print(-1)

Measured memory_bytes: 3064
#include<bits/stdc++.h>
#define ll long long
#define rep(i,a,b) for(ll i=a;i<=b;i++)
#define repn(i,n) for(ll i=0;i<n;i++)
#define all(v) v.begin(),v.end()
#define bac(i,a,b) for(ll i=a;i>=b;i--)
#define sz(v) (ll)v.size()
using namespace std;

ll MOD=1e9+7;
ll g,h,l;
const ll N=100005;

ll add(ll a,ll b); ll mul(ll a,ll b); ll binpo(ll a,ll b);

int main(){
    ios_base::sync_with_stdio(false); cin.tie(NULL);
    ll k,n;
    cin>>k>>n;
    ll arr[n];
    repn(i,n){
        cin>>arr[i];
    }
    sort(arr,arr+n);
    ll maxi=-1;
    rep(i,0,n-2){
        maxi=max(maxi,arr[i+1]-arr[i]);
    }
    maxi=max(maxi,arr[0]-arr[n-1]+k);
    cout<<k-maxi;
}

ll add(ll a,ll b)
{
    return (a%MOD+b%MOD)%MOD ;
}
ll mul(ll a,ll b)
{
    return (a* 1ll *b)%MOD ;
}
ll binpo(ll a,ll b)
{
    int ans = 1 ;
    while(b)
    {
        if( b % 2 != 0)
        {
            ans = mul(ans,a);
        }
        a = mul(a,a);
        b = b/2;
    }
    return ans;
}

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

using namespace std;

int main()
{
    int n;
    cin >> n;
    double res=0.0;
    for(int i=0;i<n;i++)
    {
        double val;
        string tp;
        cin >> val >> tp;
        if(tp=="JPY") res+=val;
        else res+=(380000.0*val);
    }
    cout << fixed << setprecision(8) << res << endl;
    return 0;
}


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

using namespace std;

void input();
int x;
void solve(){
    int lcm = (x*360)/__gcd(x,360);
    cout<<lcm/x<<"\n";
}

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

    input();
    solve();
}

void input(){
    cin>>x;
}


Measured memory_bytes: 3648
#include <iostream>
#include <vector>

using namespace std;

int n;
vector<int> vec;
int lcount, rcount, l, r;

bool dfs(int i)
{
	if(i == 10) return true;
	if(lcount < 10 && l < vec[i]){ l = vec[i]; if(dfs(i + 1)) return true; }
	if(rcount < 10 && r < vec[i]){ r= vec[i]; if(dfs(i + 1)) return true; }
	return false;
}

int main()
{
	cin >> n;
	for (int j = 0; j < n; j++)
	{
		lcount = 0; rcount = 0; l = 0; r = 0;
		vec.resize(10);

		for (int i = 0; i < 10; i++)
		{
			cin >> vec[i];
		}	
		cout << (dfs(0) ? "YES" : "NO") << endl;
	}
	return 0;
}

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

long long N=0,K=0,M=0,A=0,ans=0,p=0;
string S;
int main(){
    cin >> N >> S;
    for(int i=0;i<N-2;i++){
        if(S.substr(i,3)=="ABC") ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int isprime(int);
int main(void){
  int array[10000];
  int len;
  int i,j,count=0;
  scanf("%d",&len);
  for(i=0;i<len;i++){
    scanf("%d",&array[i]);
  }
  for(i=0;i<len;i++){
    if(isprime(array[i])==1){
      count++;
      for(j=0;j<i;j++){
	if(array[i]==array[j]){
	  count=count-1;
	  break;
	}
      }
    }
  }
  printf("%d\n",count);
 return 0;
}

int isprime(int n){
    int i;
    if(n<2)return 0; 
    else if(n==2)return 1;
    if(n%2==0)return 0;
    for(i=3;i*i<=n;i+=2){
      if(n%i==0)return 0;
    }
    return 1;
}

Measured memory_bytes: 0
#include<cstdio>
#include<cstring>
#include<algorithm>
using namespace std;
char d[7];
int main()
{
	scanf("%s",d);
	int ans=0;
	for(int i=0;i<6;i++)
		if(d[i]=='1')
			ans++;
	printf("%d\n",ans);
}

Measured memory_bytes: 128
#include <algorithm>
#include <cassert>
#include <climits>
#include <cmath>
#include <cstdio>
#include <cstring>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <string>
#include <vector>


using namespace std;
typedef unsigned int uint;
typedef long long ll;
typedef unsigned long long ull;

#define REP(i,n) for(int i = 0; i < (int)(n); ++i)
#define FOR(i,a,b) for(int i = (a); i < (int)(b); ++i)
#define ALL(c) (c).begin(), (c).end()
#define SIZE(v) ((int)v.size())

#define pb push_back
#define mp make_pair
#define mt make_tuple

class UnionFind
{
public:
    UnionFind(){};
    ~UnionFind(){};
    void init(int num_entries) {
        num_entries_ = num_entries;
        par_.resize(num_entries_);
        rank_.resize(num_entries_, 0);
        member_num_.resize(num_entries_, 1);
        REP(i, num_entries_) {
            par_[i] = i;
        }
    }
    int find(int x) {
        if (par_[x] == x) return x;
        else return par_[x] = find(par_[x]);
    }
    void unite(int x, int y) {
        x = find(x); y = find(y);
        if (x == y) return;
        if (rank_[x] < rank_[y]) {
            par_[x] = y;
            member_num_[y] += member_num_[x];
            member_num_[x] = 0;
        } else {
            par_[y] = x;
            member_num_[x] += member_num_[y];
            member_num_[y] = 0;
            if (rank_[x] == rank_[y]) rank_[x]++;
        }
    }
    bool same(int x, int y) { return find(x) == find(y); }
    int size(int x) {
        return member_num_[this->find(x)];
    }
private:
    int num_entries_;
    std::vector<int> par_;
    std::vector<int> rank_;
    std::vector<int> member_num_;
};

vector<ll> solve(ll N, ll M, vector<pair<ll, ll>> ABs) {
    REP(m, M) cin >> ABs[m].first >> ABs[m].second;
    reverse(ALL(ABs));
    UnionFind uf;
    uf.init(N);

    vector<ll> ans;
    ans.pb(N * (N - 1) / 2);

    for(auto ab: ABs) {
        auto a = ab.first - 1;
        auto b = ab.second - 1;
        ll decrease = 0;
        if (uf.find(a) != uf.find(b)) {
            ll n1 = uf.size(a);
            ll n2 = uf.size(b);
            decrease = n1 * n2;
        }
        ans.pb(ans.back() - decrease);
        uf.unite(a, b);
    }
    ans.pop_back();
    reverse(ALL(ans));
    return ans;
}

int main(void)
{
    cin.sync_with_stdio(false);
    ll N, M;
    cin >> N >> M;
    vector<pair<ll,ll>> ABs(M);
    auto ans = solve(N, M, ABs);
    for(auto a: ans) cout << a << endl;
    return 0;
}


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

int main() {
  int N, s = 0;
  cin >> N;
  vector<int> side(N);
  for (int i = 0; i < N; i++) {
    cin >> side.at(i);
  }
  sort(side.begin(), side.end());
  for(int i = 0; i < N - 1; i++) {
    s += side.at(i);
  }
  if (side.at(N - 1) < s) {
    cout << "Yes" << endl;
  } else {
    cout << "No" << endl;
  }
}

Measured memory_bytes: 256
import collections

n = input()
mylist = []
for i in range(0, int(n)):
    val = input()
    mylist.append(val)

c = collections.Counter(mylist)
ma = c.most_common()[0][1]
ans = []
for target_list in c.items():   
    if target_list[1] == ma:
        ans.append(target_list[0])

ans.sort()

for target_list in ans:
    print(target_list)


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

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

    int n = s.length();

    ll ans = 0;
    ll cou = 0;
    for(int i = 0; i < n - 1; i++){
        if(s[i] == 'A'){
            cou++;
        }else{
            if(s.substr(i, 2) == "BC"){
                ans += cou;
                i++;
            }else{
                cou = 0;
            }
        }
    }

    cout << ans << endl;
}

Measured memory_bytes: 3748
#include <bits/stdc++.h>
using namespace std;
 
    int main() {
        int N,K;
        cin >> N >> K;
        vector<int> d(K);
        vector<vector<int>>  A(K,vector<int>(N,0));
        vector<int> B(N,0);
        for(int i=0;i<K;i++){
            cin >> d.at(i);
            for(int j=0;j<d.at(i);j++){
                cin >> A.at(i).at(j);
                B.at(A.at(i).at(j)-1)++;
            }
        }
        int count=0;
        for(int i=0;i<N;i++){
            if(B.at(i)==0) count++;
        }     
        cout << count << endl;
    }

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

using namespace std;

typedef long long ll;
const ll MOD = 1e9 + 7;
const ll INF = 1e18;

int main() {
    ll n, m, i, j, k;
    cin >> n;
    vector<ll> d(n);
    for(i = 0; i < n; i++) {
        cin >> d[i];
    }
    sort(d.begin(), d.end());
    if(n >= 24 || d[0] == 0) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> cnt(12, 0),tim(24,0);
    tim[0]=1;
    for(i = 0; i < n; i++) {
        cnt[d[i]]++;
        if(cnt[d[i]] > 2) {
            cout << 0 << endl;
            return 0;
        }
    }
    if(cnt[12] > 1) {
        cout << 0 << endl;
        return 0;
    }
    vector<ll> solo;
    for(i=1;i<=12;i++){
        if(cnt[i]==2){
            tim[i] = 1;
            tim[24-i]=1;
        }else if(cnt[i]==1){
            solo.push_back(i);
        }
    }
    vector<ll> t(n, 0);
    ll ret = 0;
    for(i = 0; i < 1 << solo.size(); i++) {
        t = tim;
        for(j = 0; j < solo.size(); j++) {
            if((i >> j) & 1) {
                t[solo[j]] = 1;
            } else {
                t[24-solo[j]] = 1;
            }
        }
        ll now = INF, cur = 0;
        for(j = 1; j < 24; j++) {
            if(t[j] == 1){
                now = min(now, abs(cur - j));
                cur = j;
            }
        }
        now = min(now,min(cur,24-cur));
        ret = max(ret, now);
    }
    cout << ret << endl;
    return 0;
}

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

#define FOR(i, a, b) for (int i=a; i<b; i++)
#define For(i, a) for (int i=0; i<a; i++)
#define FORR(i,a,b) for (int i = a; i >= b; i--)
#define Forr(i,a) for (int i = a; i >= 0; i--)

#define deb(...) cerr << "[" << #__VA_ARGS__ << "] : [", DBG(__VA_ARGS__)
void DBG() { cerr << "]\n";}
template<typename T, typename ...Args> void DBG(T first, Args... args)
{cerr << first; if(sizeof...(args))cerr<<", "; DBG(args...); }

const int mod = 1e9+7;

int mul(int x,int y){
  int res = x*y;
  if(res >= mod)res%=mod;
  return res;
}

int add(int x, int y){
  int res = x+y;
  if(res >= mod)res-=mod;
  return res;
}
int sub(int x, int y){
  int res = x-y;
  if(res<0)res+=mod;
  return res;
}

int power(int x, int y){
  int res = 1;
  while(y){
    if(y&1)res = mul(res,x);
    y = y>>1;
    x = mul(x,x);
  }
  return res;
}

int dp[20000];

void solve(){
  int s; cin >> s;
  dp[0]=1,dp[1]=0,dp[2]=0,dp[3]=1,dp[4]=1,dp[5]=1;
  for(int i=6;i<=s;i++){
    for(int dig=3;dig<=s+1;dig++){
      if(i-dig>=0)dp[i]=add(dp[i],dp[i-dig]);
    }
  }
  cout << dp[s] << "\n";

}

int32_t main(){
  ios_base:: sync_with_stdio(false);
  cin.tie(0);
  int t=1;
  for(int tt=1;tt<=t;tt++){
    solve();
  }
}

Measured memory_bytes: 3644
#include<iostream>
#include<algorithm>
#include<string>
#include<vector>
using namespace std;
#define REP(i, limit) for(int i=0; i< limit; ++i)
#define LINT long long

class BIT2d
{
  public:

  int Num;
  vector<vector<int>> bit;

  //コンストラクタ、要素数N+1のvectorを値0で初期化して宣言
  //bit[0]は使わない
  BIT2d(int N):
      bit(vector<vector<int>>(N+1, vector<int>(N+1, 0))), Num(N) {}

  //BITの値を更新する O((logNum)^2)
  void add(int a, int b, int w) {
    for (int x = a; x <= Num; x += x & -x){
      for (int y = b; y <= Num; y += y & -y){
        bit[x][y] += w;
      }
    }
  }

  //要素の和を求める O((logNum)^2)
  int sum(int a, int b) {
    int ret = 0;
    for (int x = a; x > 0; x -= x & -x){
      for (int y = b; y > 0; y -= y & -y){
        ret += bit[x][y];
      }
    }
    return ret;
  }
};


int main(){
  int N, M, Q;
  cin >> N >> M >> Q;
  int L[M], R[M], p[Q], q[Q];
  REP(i, M){
    cin >> L[i] >> R[i];
  }
  REP(i, Q){
    cin >> p[i] >> q[i];
  }
  BIT2d memo(N);
  REP(i, M){
    memo.add(N-L[i]+1, R[i], 1);
  }

  REP(i, Q){
    cout << memo.sum(N-p[i]+1, q[i]) << endl;
  }


  return 0;
}


Measured memory_bytes: 4224
import java.util.Arrays;
import java.util.Scanner;
public class Main {
	public static void main(String[] args){
		Scanner in = new java.util.Scanner(System.in);
		String N = in.nextLine();
		int n = Integer.parseInt(N);
		String b = in.nextLine();
		char[] s = b.toCharArray();
		
		int[] west = new int[n];
		int[] east = new int[n];
		if(s[0] == 'W') {
			west[0] = 1;
			east[0] = 0;
		}else {
			west[0] = 0;
			east[0] = 1;
		}
		for(int i=1; i<n; i++) {
			if(s[i] == 'W') {
				west[i] = west[i-1] + 1;
				east[i] = east[i-1];
			}else {
				west[i] = west[i-1];
				east[i] = east[i-1] + 1;
			}
		}

		int min = n;
		if(east[n-1]-east[0]<min) {
			min = east[n-1]-east[0];
		}
		if(west[n-2]<min) {
			min =west[n-2];
		}
		for(int leader=1; leader<n-1; leader++) {
			int count = west[leader-1] + east[n-1]-east[leader];
			if(count < min) {
				min = count;
			}
		}
		System.out.print(min);
		in.close();
		
	}
}


Measured memory_bytes: 32540
////////////
//||||| ||// 
//   || ||//
//||||||||//
//|| ||   //
//|| |||||//
////////////
#include<bits/stdc++.h>
using namespace std;
#define   ll  long long int
#define   dl double
#define   llu unsigned long long int
#define   scll(x) scanf("%lld",&x)
#define   scld(x) scanf("%lf",&x)
#define   scull(x) scanf("%llu",&x)
#define   scch(x) scanf(" %c",&x)
#define   pb(x) push_back(x)
#define   pf(x) push_front(x)
#define   ppb() pop_back()
#define   ppf() pop_front()
#define   Pi acos(-1.0)
#define   inf 1000000000000000000
#define   mod 1000000007
#define   ff first
#define   ss second
#define   mpr make_pair
#define   debug(x) cout<<x<<'\n';
#define   MAX 1000000
#define   eps 1e-8
// Creates a min heap
//priority_queue <int, vector<int>, greater<int> > pq;
//sin((x*pi)/180.0)[x in degree]
//sin(x)[x in radian]
//asin(x)[radian]
//(asin(x)*180)/pi[degree]
//or(|)//and(&)//xor(^)//not(~)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
ll lcm(ll a, ll b) {return (a * b) / __gcd(a, b);}

int main()
{
#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
#endif
    ll a, b, c = 0, d, e, f = 0, g, h, i, j, k, m, n, o, p, s, t, v, w, x, y, z,l;
    ll cnt = 0, l1 = 0, l2, l3, c1 = 0, c2 = 0, c3 = 0, mx = 0, mn = 0;
    ll prevsum = 0, ans1 = 0, ans2 = 0, odd = 0, even = 0, hh, mm;
    string str, str1, str2, str3 = "", str4 = "";
    ll ide = 0, idx = 0, Q;
    
    scll(n);
    ll arr[n];
    for(i=0;i<n;i++)
    	scll(arr[i]);
    for(i=0;i<n;i++)
    {
    	for(j=0;j<n;j++)
    	{
                for(k=0;k<n;k++)
                {
                	if(((arr[i]+arr[j])>arr[k])&&((arr[i]+arr[k])>arr[j])&&((arr[k]+arr[j])>arr[i])&&i<j&&j<k&&arr[i]!=arr[j]&&arr[j]!=arr[k]&&arr[i]!=arr[k])
                	{
                	c++;
                	}
                }
    	}
    }

    cout<<c;
    return 0;
}

Measured memory_bytes: 3696
#include<iostream>
#include<cstdio>
//1≤A≤100
//1≤B≤100
//1≤X≤200
using namespace std;
int main()
{
	int a,b,x;
	cin>>a>>b>>x;
	if(a>x||a+b<x)cout<<"NO";
	if(a+b>=x&&a<=x)cout<<"YES";
	return 0;
}

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

using namespace std;
using namespace __gnu_pbds;

#define fi first
#define se second
#define mp make_pair
#define pb push_back
#define fbo find_by_order
#define ook order_of_key
#define INF 1e9

typedef long long ll;
typedef pair<ll,ll> ii;
typedef vector<int> vi;
typedef vector < pair<int, int> > vii;
typedef long double ld;
typedef tree<pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> pbds;
typedef set<int>::iterator sit;
typedef map<int,int>::iterator mit;
typedef vector<int>::iterator vit;

queue <int> a[301];
ll n, m, x, ans, mx, cur, cnt[301];
bool disabled[301];

int main()
{
	cin >> n >> m;
	ans=n;
	for(int i = 0; i < n; i++){
		for(int j = 0; j < m; j++){
			cin >> x;
			a[i].push(x);
		}
	}
	for(int i = 0; i < m-1; i++){
		for(int j = 0; j < n; j++){
			while(disabled[a[j].front()]){
				a[j].pop();
			}
			cnt[a[j].front()]++;
		}
		mx=-1;
		for(int j = 1; j <= m; j++){
			if(cnt[j]>mx){
				mx=cnt[j];
				cur=j;
			}
			cnt[j]=0;
		}
		ans=min(ans,mx);
		disabled[cur]=1;
	}
	cout << ans;
	return 0;
}


Measured memory_bytes: 768
#include <cstdio>
#include <algorithm>
#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <string>
#include <string.h>
#include <cstdlib>
#include <ctime>
#include <cmath>
#include <map>
#include <set>
#include <iostream>
#include <sstream>
#include <numeric>
#include <cctype>
#include <bitset>
#include <cassert>
#define fi first
#define se second
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define gep(i,g,j) for(int i = g.head[j]; i != -1; i = g.e[i].next)
#define each(it,c) for(__typeof((c).begin()) it=(c).begin();it!=(c).end();it++)
#define rng(a) a.begin(),a.end()
#define maxs(x,y) x = max(x,y)
#define mins(x,y) x = min(x,y)
#define pb push_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcount
#define uni(x) x.erase(unique(rng(x)),x.end())
#define snuke srand((unsigned)clock()+(unsigned)time(NULL));
#define df(x) int x = in()
#define dame { puts("0"); return 0;}
#define show(x) cout<<#x<<" = "<<x<<endl;
#define PQ(T) priority_queue<T,vector<T>,greater<T> >
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
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;}
inline void priv(vi a) { rep(i,sz(a)) printf("%d%c",a[i],i==sz(a)-1?'\n':' ');}
template<typename T>istream& operator>>(istream&i,vector<T>&v)
{rep(j,sz(v))i>>v[j];return i;}
template<typename T>string join(vector<T>&v)
{stringstream s;rep(i,sz(v))s<<' '<<v[i];return s.str().substr(1);}
template<typename T>ostream& operator<<(ostream&o,vector<T>&v)
{if(sz(v))o<<join(v);return o;}
template<typename T1,typename T2>istream& operator>>(istream&i,pair<T1,T2>&v)
{return i>>v.fi>>v.se;}
template<typename T1,typename T2>ostream& operator<<(ostream&o,pair<T1,T2>&v)
{return o<<v.fi<<","<<v.se;}
const int MX = 100005, INF = 1001001001;
const ll LINF = 1e18;
const double eps = 1e-10;



int main() {
  int ts;
  scanf("%d",&ts);
  rep(ti,ts) {
    int n, x;
    scanf("%d%d",&n,&x);
    int ans = 127*(n-1);
    if (n%2 == 0) x ^= 127;
    ans += x;
    printf("%d\n",ans);
  }
  return 0;
}







Measured memory_bytes: 256
#include <iostream>
#include <numeric>
#include <string> // string, to_string, stoi
#include <vector> // vector
#include <algorithm> // min, max, swap, sort, reverse, lower_bound, upper_bound
#include <utility> // pair, make_pair
#include <tuple> // tuple, make_tuple
#include <cstdint> // int64_t, int*_t
#include <cstdio> // printf
#include <map> // map
#include <queue> // queue, priority_queue
#include <set> // set
#include <stack> // stack
#include <deque> // deque
#include <unordered_map> // unordered_map
#include <unordered_set> // unordered_set
#include <bitset> // bitset
#include <cctype> // isupper, islower, isdigit, toupper, tolower
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)




int main() {
	string s;
	cin >> s;
	int N = s.size();
	int k = 0;
	rep(i, (N - 1) / 2) {
		if (s.at(i) == s.at(N - 1 - i)&& s.at(i) == s.at((N - 3)/2 - i) && s.at((N+ 1) / 2 + i) == s.at((N - 3) / 2 - i)) {

		}
		else {
			k = 1;
		}
	}
	if (k == 0) {
		cout << "Yes" << endl;
	}
	else {
		cout << "No" << endl;
	}
}

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

namespace Practice
{
    class Program
    {
        static void Main(string[] args)
        {
            SolveA();
            //SolveB();
            //SolveC();
            //SolveD();
        }
        private const long MOD = 1000000007;
        static void SolveA()
        {
            string s = Console.ReadLine();
            if( s.Length == 2)
            {
                Console.WriteLine(s);
            }
            else
            {
                StringBuilder sb = new StringBuilder();
                sb.Append(s[2]);
                sb.Append(s[1]);
                sb.Append(s[0]);
                Console.WriteLine(sb.ToString());
            }
        }

        #region よく使う便利関数
        private static bool isPrime(long x)
        {
            if( x == 2) { return true; }
            if( x < 2 || x % 2 == 0) { return false; }
            long i = 3;
            while( i * i <= x)
            {
                if( x % i == 0) { return false; }
                i = i + 2;
            }
            return true;
        }
        private static long lcm(long x, long y)
        {
            return x / gcd(x, y) * y;
        }
        private static long gcd(long x, long y)
        {
            return y > 0 ? gcd(y, x % y) : x;
        }

        private static int ReadAndParseInt()
        {
            return int.Parse(Console.ReadLine());
        }
        private static int[] ReadAndParseIntArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), int.Parse);
        }
        private static long ReadAndParseLong()
        {
            return long.Parse(Console.ReadLine());
        }
        private static long[] ReadAndParseLongArr()
        {
            return Array.ConvertAll(Console.ReadLine().Split(' '), long.Parse);
        }
        #endregion
    }
}

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

using namespace std;
using ll = long long;

#define FOR(i,a,n) for(int i=(a); i<(n); i++)
#define REP(i,n) FOR(i, 0, n)
#define FORD(i,a,n) for(int i=(a); i>=(n); i--)
#define REPD(i,n) FOR(i, n, 0)

#define ALL(o) (o).begin(), (o).end()

template<class T> using V = vector<T>;
template<class T, class U> using P = pair<T, U>;
template<class T> using PQ = priority_queue<T>;
template<class T> using PQR = priority_queue<T, vector<T>, greater<T> >;

const ll MOD = 1000000007;

int main() {
	int a,b,c;
	cin >> a >> b >> c;
	V<int> v(10);

	v[a] += 1;
	v[b] += 1;
	v[c] += 1;

	REP(i,10) {
		if(v[i] == 2) {
			cout << "Yes" << endl;
			return 0;
		}
	}
	cout << "No" << endl;
	return 0;

}




Measured memory_bytes: 256
#include <stdio.h>

int main(void){
  int n;
  int x;
  
  scanf("%d", &n);
  x=n%10;
  
  if(x==3){
    printf("bon");
  }else if(x==0||x==1||x==6||x==8){
    printf("pon");
  }else{
    printf("hon");
  }
  
  return 0;
}

Measured memory_bytes: 1732
'''
Created on 2020/08/23

@author: harurun
'''
def f(n):
  arr=[]
  temp=n
  for c in range(2,int(-(-n**0.5//1))+1):
    if temp%c==0:
      cnt=0
      while temp%c==0:
        cnt+=1
        temp//=c
      arr.append([c,cnt])
  if temp!=1:
    arr.append([temp,1])
  return arr

def main():
  import math
  import sys
  pin=sys.stdin.readline
  pout=sys.stdout.write
  perr=sys.stderr.write

  N=int(pin())
  r=f(N)
  ans=0
  for i in r:
    ans+=int((math.sqrt(1+8*i[1])-1)/2)
  print(ans)
  return 
main()

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

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

    int sum=0;

    for (int i=1; i <= N; i++){
        int Nsum;
        Nsum=i%10 + (i/10)%10 + (i/100)%10 + (i/1000)%10 + i/10000;

        if ( A <= Nsum && Nsum <= B ) sum+=i;
         
    }

    cout << sum << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <map>
#include <algorithm>

using namespace std;

int main() {
    int n;
    cin >> n;
    map<int, int> mp;
    int max_n = INT_MIN;
    int min_n = INT_MAX;
    for (int i=0; i<n; i++) {
        int a;
        cin >> a;
        mp[a]++;
        max_n = max(max_n, a);
        min_n = min(min_n, a);
    }

    long long ans = 0, sum = 0;
    for (int i=min_n; i<min(min_n+3, max_n+1); i++) {
        ans += mp[i];
        sum += mp[i];
    }
    for (int i=min_n+3; i<=max_n; i++) {
        sum += mp[i];
        sum -= mp[i-3];
        ans = max(ans, sum);
    }

    cout << ans << endl;
}


Measured memory_bytes: 4992
#include <cstdio>
#include <cstring>
#include <iostream>
#include <vector>
#include <algorithm>
using namespace std;

long long increment(long long a) {
    char s[30];
    bool overflow[30] = {};

    sprintf(s, "%lld", a);
    int len = strlen(s);
    reverse(s, s+len);

    s[0]++;
    for (int i = 0; i < len; ++i) {
        bool o = false;
        if (s[i] > '9') { o = true; }
        if (i != len-1 && abs(s[i] - s[i+1]) > 1) { o = true; }
        if (o) {
            // 繰り上がる
            overflow[i] = true;
            s[i+1]++;
        }
    }

    if (overflow[len-1]) {
        s[len] = '1';
        s[len+1] = '\0';
        overflow[len] = false;
        len++;
    }
    reverse(s, s+len);
    reverse(overflow, overflow+len);

    for (int i = 1; i < len; ++i) {
        if (overflow[i]) {
            s[i] = max(s[i-1]-1, (int)'0');
        }
    }

    sscanf(s, "%lld", &a);
    return a;
}

// 1,2,3,4,5,6,7,8,9,10,11,12,21,22,23,32,33,34,43,44,45,54,55,56,
// 65,66,67,76,77,78,87,88,89,98,99,100,101,110,111,112,121,122,123,132
int main() {
    int K; cin >> K;

    long long a = 1;
    for (int i = 1; i < K; ++i) {
        a = increment(a);
    }
    cout << a << endl;
}


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

int main(){
  
  int H,W;
  cin>>H>>W;
  vector<vector<char>>date(H,vector<char>(W));
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      cin>>date[i][j];
    }
  }
  
  for(int i=0;i<H;i++){
    for(int j=0;j<W;j++){
      if(j!=W-1){
      cout<<date[i][j];
      }
      else{
        cout<<date[i][j]<<endl;
      }
    }
    
       for(int j=0;j<W;j++){
      if(j!=W-1){
      cout<<date[i][j];
      }
      else{
        cout<<date[i][j]<<endl;
      }
    }
    
  }
}
    
    
  
  

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

int main(){
  int i,j,cnt=0;
  string s;
  cin>>s;
  while(1){
    j=s.size();
    if(j<5)break;
    if(s.substr(j-5)=="dream")s=s.substr(0,j-5);
    else if(s.substr(j-5)=="erase")s=s.substr(0,j-5);
    else if(s.substr(max(0,j-6))=="eraser")s=s.substr(0,j-6);
    else if(s.substr(max(0,j-7))=="dreamer")s=s.substr(0,j-7);
    else break;
  }
  if(s=="")cout<<"YES"<<endl;
  else cout<<"NO"<<endl;
}

Measured memory_bytes: 512
#include <bits/stdc++.h>
using namespace std;
int main() {
  int N, M, O = 0, P = 0;
  cin >> N >> M;
  for (int i = 1; i < N; i++) {O += i;}
  for (int i = 1; i < M; i++) {P += i;}
  if (N == 1) {O = 0;}
  else if (M == 1) {P = 0;}
  cout << O + P << endl;
}

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

signed main() {
  int N, M; cin >> N >> M;
  vector<int> vec(N);

  int ans = 0;
  
  if(N+M>=10) cout << "error" << endl;
  else cout << N+M << endl;

}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<queue>
#include<string>
#include<algorithm>
#include<map>
#include<cmath>
#include<cstring>
using namespace std;

typedef long long ll;
typedef pair<int,int> P;
#define INF = 1000000100;

int main(){
    int N;
    cin >> N;
    vector<vector<int >> G(N);
    vector<pair<int, int>> vp;
    for(int i=1;i<N;i++){
        int a, b;
        cin >> a >> b;
        a--;b--;
        G[a].emplace_back(b);
        G[b].emplace_back(a);
        vp.emplace_back(a,b);        
    }
    int K=0;
    map<pair<int ,int>, int> I;
    vector<int> cs(N, 0);

    vector<bool> used(N, false);
    queue<int > que;
    used[0]=true;
    que.emplace(0);
    while(!que.empty()){
        int v=que.front(); que.pop();
        if(K<(int) G[v].size()) K=(int) G[v].size();
        int cur = 1;
        for(int u : G[v]){
            if(used[u]) continue;
            if(cur==cs[v]) cur++;
            cs[u] = I[make_pair(u,v)]=I[make_pair(v,u)] = cur++;
            que.emplace(u);
            used[u]=true;
        }
    }

    cout << K << endl;
    for(auto p: vp){
        cout << I[p] << endl;
    }
    return 0;

}

Measured memory_bytes: 19700
#include <iostream>

using namespace std;

int main(){
    int n;
    cin >> n;
	n = n % 10;
    if(n == 2 || n == 4 || n == 5 || n == 7 ||  n == 9)
        cout << "hon" << endl;
    else if (n == 0 || n == 1 || n == 6 || n ==8)
        cout << "pon" << endl;
    else cout << "bon" << endl;
}

Measured memory_bytes: 3592
#include <stdio.h>

int main()
{
	int n,i,p,t,m,j;
	int a[5001];
	
	while(1){
		scanf("%d",&n);
		if(n==0) break;
		for(i=0;i<n;i++){
			scanf("%d",a+i);
		}
		p=a[0];
		for(i=0;i<n;i++){
			t=m=a[i];
			for(j=i+1;j<n;j++){
				t+=a[j];
				if(t>m) m=t;
			}
			if(m>p) p=m;
		}
		printf("%d\n",p);
	}
	return 0;
}

Measured memory_bytes: 620
#include <bits/stdc++.h>
using namespace std;
int n;
int k;
int frog(int v[],int i,int a[])
{


    if(a[i]!=-1)
    {

        return a[i];
    }
    else
    {
        a[i]=frog(v,i+1,a)+abs(v[i]-v[i+1]);
        for(int p=1;p<=k;p++)
        {

            if(i+p<n-1)
            {
                a[i]=min(frog(v,i+p,a)+abs(v[i]-v[i+p]),a[i]);

            }
            else
            {
                break;
            }
        }
        return a[i];
    }


}
int main()
{




    cin>>n>>k;

    int v[n];
    int a[n];

    for(int i=0;i<n;i++)
    {

        cin>>v[i];
        a[i]=-1;
    }
    for(int i=n-1;i>=n-1-k;i--)
    {
        a[i]=abs(v[n-1]-v[i]);
    }

    int res=frog(v,0,a);
    cout<<res;

}


Measured memory_bytes: 8832
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#define ll long long
using namespace std;

int max(int a,int b,int c){
  if(a >= b and a >= c){
    return a;
  }else if(b >= a and b >= c){
    return b;
  }else{
    return c;
  }
}

int main(void){
  int a,b,c,ma;
  cin >> a >> b >> c;
  ma = max(a,b,c);
  a = a-ma;
  b = b-ma;
  c = c-ma;
  if(-(a+b+c) % 2 == 0){
    cout <<  -(a+b+c)/2 << endl;
    return 0;
  }else{
    cout << -(a+b+c-3)/2 << endl;
    return 0;
  }
}

Measured memory_bytes: 3564
def abc048():
    d=[]
    a=input()
    b=a.split()
    c=[i for i in b]
    k=''.join(c)
    for i in k:
        d.append(i)

    print(d[0],end='')
    print(d[len(c[0])],end='')
    print('C',end='')
    


abc048()


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


int main(){
	int n; cin >> n;
	vector<int> w(n);
	int min=200000;
	for(int i=0;i<n;++i) cin >> w[i];
	for(int i=1;i<=100;++i){
		int sum_l=0;
		int sum_h=0;
		for(int j=0;j<=i;++j){
			sum_l+=w[j];
		}
		for(int j=n-1;j>i;--j){
			sum_h+=w[j];
		}
		if(min > abs(sum_h-sum_l)) min=abs(sum_h-sum_l);
		//cout << "min:" << min << endl;
	}
	cout << min << endl;
}	

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

import sys
from collections import deque

def input(): return sys.stdin.readline().strip()
def list2d(a, b, c): return [[c] * b for i in range(a)]
def list3d(a, b, c, d): return [[[d] * c for j in range(b)] for i in range(a)]
def ceil(x, y=1): return int(-(-x // y))
def INT(): return int(input())
def MAP(): return map(int, input().split())
def LIST(): return list(map(int, input().split()))
def Yes(): print('Yes')
def No(): print('No')
def YES(): print('YES')
def NO(): print('NO')
sys.setrecursionlimit(10 ** 9)
INF = float('inf')
MOD = 10 ** 9 + 7

H,W=MAP()
grid=[None]*H
for i in range(H):
    grid[i]=LIST()

# その行を底辺として、高さをどこまで伸ばせるか記録しておく
acc=list2d(H, W, 0)
for j in range(W):
    if grid[0][j]!=1:
        acc[0][j]=1
for j in range(W):
    for i in range(1, H):
        if grid[i][j]!=1:
            acc[i][j]=acc[i-1][j]+1
# 最後にスタックに残ってる分を確認するために番兵的に足す
for i in range(H):
    acc[i].append(0)

mx=0
# 各行を高さのヒストグラムとみなす
for i, hist in enumerate(acc):
    stack=deque()
    for j, h in enumerate(hist):
        if not len(stack):
            stack.append((j, h))
        else:
            if stack[-1][1]<h:
                stack.append((j, h))
            elif stack[-1][1]>h:
                # 次のhがスタックより低かったら、そこより手前の最大を確定する
                while len(stack) and stack[-1][1]>h:
                    prev=stack.pop()
                    w2=j-prev[0]
                    h2=prev[1]
                    mx=max(mx, h2*w2)
                stack.append((prev[0], h))
print(mx)



Measured memory_bytes: 65284
while data =gets
	if data == nil
		break
	end
x=1
y=1
z=1
gcd=[]
gcda=[]
gcdb=[]

lcma=[]
lcmb=[]

	a,b=data.split(" ").map{|num| num.to_i}
	i=2
	while i <= a || i <= b
		if a%i==0 && b%i==0
#		p "a=#{a} b=#{b} i=#{i}  ab??????"
			gcd << i
			a = a/i
			b = b/i
			redo
		elsif a%i==0
#		p "a=#{a} b=#{b} i=#{i}  a??????"
			gcda << i
			a = a/i
			redo
		elsif b%i==0
#		p "a=#{a} b=#{b} i=#{i}  b??????"
			gcdb << i
			b = b/i
			redo
		end
		i+=1
#		p "#{a} #{b}"
	end

	gcda.each do |i|
		x=x*i 
	end

	gcdb.each do |i|
		y=y*i 
	end

	gcd.each do |i|
		z=z*i 
	end

	#puts "#{gcd} #{x} #{y} #{z} #{x*y*z}"
	puts "#{z} #{x*y*z}"

end

Measured memory_bytes: 8512
<?php
// Your code here!
fscanf(STDIN, "%d %d", $n, $k);
$list = explode(" ", trim(fgets(STDIN)));

$count = 0;
for($i = 0; $i < $n; $i++) {
    if($list[$i] >= $k){
        $count++;
    }
}
echo $count.PHP_EOL;

Measured memory_bytes: 12792
class UnionFind():
    def __init__(self, n):
        self.n = n
        self.parents = [-1] * n

    def find(self, x):
        if self.parents[x] < 0:
            return x
        else:
            self.parents[x] = self.find(self.parents[x])
            return self.parents[x]

    def union(self, x, y):
        x = self.find(x)
        y = self.find(y)

        if x == y:
            return

        if self.parents[x] > self.parents[y]:
            x, y = y, x

        self.parents[x] += self.parents[y]
        self.parents[y] = x

    def size(self, x):
        return -self.parents[self.find(x)]

    def same(self, x, y):
        return self.find(x) == self.find(y)

    def members(self, x):
        root = self.find(x)
        return [i for i in range(self.n) if self.find(i) == root]

    def roots(self):
        return [i for i, x in enumerate(self.parents) if x < 0]

    def group_count(self):
        return len(self.roots())

    def all_group_members(self):
        return {r: self.members(r) for r in self.roots()}

    def __str__(self):
        return '\n'.join('{}: {}'.format(r, self.members(r)) for r in self.roots())


N, M = map(int, input().split())
uf = UnionFind(N)
for _ in range(M):
    A, B = map(int, input().split())
    uf.union(A-1, B-1)

ans = -1
for i in range(N):
    ans = max(ans, uf.size(i))

print(ans)

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

#define rep(i, n) for (int i = 0; i < (n); i++)
#define REP(i, init, n) for(int i = init; i < (n); i++)

using namespace std;
using ll = long long int;
using P = pair<int, int>;
using T = tuple<int, int, int>;
using edge = struct
{
    int to, cost;
};

const int MOD = 1e9 + 7;
const int iINF = 1e9;
const long long int llINF = 1e18;
const double PI = acos(-1.0);

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

int main()
{
    string S;
    cin >> S;
    int cnt = 0;
    rep(i, 3) if(S[i] == 'o') cnt++;

    cout << 700 + 100 * cnt << endl;
    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
 
int main() {
	int n, ans = 0;
	cin >> n;

	vector<int> p(n);
	for(int i=0;i<n;i++) cin >> p.at(i);

	sort(p.begin(), p.end());
	for(int i=0;i<n-1;i++){
		ans += p.at(i);
	}
	ans += p.at(n-1) / 2;
	cout << ans << endl;
}

Measured memory_bytes: 256
import sys
input = sys.stdin.readline
import copy
from collections import deque

H,W=map(int,input().split())
A=[[0]*W for i in range(H)]
for i in range(H):
    S=input()
    for j in range(W):
        A[i][j]=S[j]
C=copy.deepcopy(A)
for h in range(W):
    C[0][h]='#'
for j in range(W):
    if j%2==1:
        for i in range(H-1):
            C[i][j]='#'
D=copy.deepcopy(A)
for h in range(W):
    D[-1][h]='#'
for j in range(W):
    if j%2==0:
        for i in range(1,H):
            D[i][j]='#'
for i in range(H):
    print(''.join(C[i]))
print()
for i in range(H):
    print(''.join(D[i]))

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

#define rep(i, n) REP(i, 0, n)
#define REP(i, x, n) for (int i = x; i < n; i++)
#define REP2(i, x, n) for (int i = x; i <= n; i++)
#define OP(x) cout << x << endl;
typedef long long ll;

int main() {
    int n; cin >> n;
    vector<int> vec(n);

    rep(i, n){
        cin >> vec[i];
    }

    for(int i = n - 1; i > 0; i--){
        if(vec[i] >= vec[i - 1]) continue;
        else if(vec[i - 1] - 1 == vec[i]) vec[i - 1] -= 1;
        else {
            OP("No");
            return 0;
        }
    }
    OP("Yes");
}


Measured memory_bytes: 640
/*#include<algorithm>
#include<iostream>
#include<cstdio>
#include<cmath>
using namespace std;
int x,y,H,N,cnt=0;
int main(void){
	cin>>H;
	int a[H][4];
	cin>>N;
	for(int i=0;i<H;i++){
		for(int j=0;j<4;j++){
			a[i][j]=0;
		}
		//cout<<endl;
	}
	for(int i=0;i<N;i++){
		cin>>x>>y;
		a[x][y]=1;
	}
	for(int i=0;i<H-1;i++){
		for(int j=0;j<4-1;j++){
			if(1>a[i][j]+a[i+1][j]+a[i][j+1]+a[i+1][j+1])
			{
				cnt++;
				//cout<<i<<" "<<j<<endl;
				a[i][j]=a[i][j+1]=a[i+1][j]=a[i+1][j+1]=1;
			}
		}
	}
	cout<<cnt<<endl;
	return 0;
}*/
#include<bits/stdc++.h>
using namespace std;
int H,N;
int t[100005][4];
int dp[100005][1<<4];

int main(){
	cin>>H>>N;
	for(int i=0;i<N;i++){
		int x,y;
		cin>>x>>y;
		t[y][x]=1;
	}
	
	for(int i=0;i<H;i++)
		for(int j=0;j<(1<<4);j++)
			dp[i][j]=-100000000;
	dp[0][0]=0;
	int ans=0;
	
	for(int i=0;i<H;i++){
		for(int b=0;b<(1<<4);b++){
			
			ans=max(ans,dp[i][b]);
			if(i==H-1)continue;
			
			int tmp[2][4]={};
			
			for(int j=0;j<4;j++){
				tmp[0][j]=t[i][j];
				tmp[1][j]=t[i+1][j];
				tmp[0][j]|=(b>>j&1);
			}
			dp[i+1][0]=max(dp[i+1][0],dp[i][b]);
			
			if(!tmp[0][0]&&!tmp[0][1]&&!tmp[1][0]&&!tmp[1][1]){
				dp[i+1][3]=max(dp[i+1][3],dp[i][b]+1);
			}
			if(!tmp[0][1]&&!tmp[0][2]&&!tmp[1][1]&&!tmp[1][2]){
				dp[i+1][6]=max(dp[i+1][6],dp[i][b]+1);
			}
			if(!tmp[0][2]&&!tmp[0][3]&&!tmp[1][2]&&!tmp[1][3]){
				dp[i+1][12]=max(dp[i+1][12],dp[i][b]+1);
			}
			if(!tmp[0][0]&&!tmp[0][1]&&!tmp[1][0]&&!tmp[1][1]){
				if(!tmp[0][2]&&!tmp[0][3]&&!tmp[1][2]&&!tmp[1][3]){
					dp[i+1][15]=max(dp[i+1][15],dp[i][b]+2);
				}
			}
			
		}
		
	}
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 3880
#include<stdio.h>
int main()
{
	int w,h,x,y,r;
	scanf("%d %d %d %d %d",&w,&h,&x,&y,&r);
	if(x>w || y>h || x<0 || y<0 || x==w || y==h || r>x || r>y)
	{
		printf("No\n");
	}
	else
	{
		printf("Yes\n");
	}
	
	
	return 0;
}


Measured memory_bytes: 1992