akhauriyash/Code-Regression huggingface dataset:
// CODE by Kazhybay Askar

#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
#include <bits/stdc++.h>

using namespace std;
using namespace __gnu_pbds;

/*
find_by_order(k);
order_of_key(k);
ordered_set(int) s;
*/

/*
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
rng();
shuffle(permutation.begin(), permutation.end(), rng);
*/

/*
#pragma comment(linker, "/stack:200000000")
#pragma GCC    optimize("Ofast")
#pragma GCC    target("sse,sse2,sse3,ssse3,sse4,popcnt,abm,mmx,avx,tune=native")
*/

#define F      first
#define S      second
#define pb     push_back
#define pf     push_front
#define ppb    pop_back
#define ppf    pop_front
#define Speed  ios_base::sync_with_stdio(0), cin.tie(0), cout.tie(0);
#define sz     size()
#define all(x) x.begin(),x.end()
#define cont   continue
#define r0     return 0
#define nl     '\n'
#define ordered_set(T) tree<T, null_type,less<T>, rb_tree_tag,tree_order_statistics_node_update>

typedef unsigned long long ull;
typedef long long ll;
typedef long double   ld;
typedef pair<ll,ll>   pll;
typedef pair<int,int> pii;
typedef pair<char,char> pcc;

const int MAXN  = 5e5  + 7;
const int MOD   = 1e9  + 7;
const int INF   = 1e9  + 7;
const ll  MINF  = 1e18 + 7;
const int EPS   = 1e-6;
const int dx[]  = {0, 0, 1, -1, -1, -1, 1, 1};
const int dy[]  = {1, -1, 0, 0, -1, 1, -1, 1};
const double pi = acos(-1.0);

ll n,a[MAXN],p[MAXN],s[MAXN];

void solve(){
    ll k;
    cin>>n>>k;
    for(int i=1;i<=k;i++){
        cin>>a[i];
    }
    sort(a+1,a+1+k);
    a[k+1]=n;
    for(int i=1;i<=k;i++){
        p[i]=p[i-1]+a[i]-a[i-1];
   //     cout<<p[i]<<" ";
    }
 //   cout<<nl;
    for(int i=k;i>=1;i--){
        s[i]=s[i+1]+a[i+1]-a[i];
      //  cout<<s[i]<<" ";
    }
 //   cout<<nl;
    ll mn=INF;
    for(int i=1;i<=k;i++){
   //     cout<<p[i]<<" "<<s[i+1]<<nl;
        mn=min(mn,p[i-1]+s[i]);
    }
    cout<<min(mn,p[k]-a[1]);
}



int main(){
    Speed;
    ll T=1;
    //cin>>T;
    while(T--){
        solve();
    }
    r0;
}


Measured memory_bytes: 9984
#include<iostream>
#include<iomanip>
//#include<cstdio>
#include<vector>
#include<map>
#include<queue>
#include<algorithm>
#include<cmath>
#include<cassert>
using namespace std;
typedef long long ll;
int L;

struct edge {
	int s,t,w;
};

int main(){
	cin >> L;

	int r=0;
	while((1<<(r+1))<=L) r++;
	int k=1<<r;

	vector<edge> g;
	for(int i=0; i<r; i++){
		g.push_back({i, i+1, 0});
		g.push_back({i, i+1, 1<<i});
	}

	for(int i=r-1; i>=0; i--){
		if(k+(1<<i)-1 < L){
			g.push_back({i, r, k});
			k += (1<<i);
		}
	}

	cout << r+1 << " " << g.size() << endl;
	for(int i=0; i<g.size(); i++){
		cout << g[i].s+1 << " " << g[i].t+1 << " " << g[i].w << endl;
	}

	return 0;
}


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

using namespace std;

int main() {
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    int t = 1, q = 0;
    // cin >> t;
    while (t--) {
        long long x;
        cin >> x;
        long long ans = 0;
        long long curr = 100;
        while (curr < x) curr += (curr / 100), ans++;
        cout << ans;
        cout << endl;
    }
    return 0;
}

Measured memory_bytes: 3652
/*************************************************************************

       Author:            palayutm
       Created Time :     Mon 10 Oct 2016 12:13:01 PM CST

       File Name:         e.cc
       Description:       new style, new life

 ************************************************************************/
#include <bits/stdc++.h>

using namespace std;

typedef unsigned long long ull;

const ull base = 1e9+7;

const int B = 640;

int ch[400005][26], cnt = 1;
vector<int> vec[400006];
vector<string> vstr, vv;
vector<vector<ull> > key;
int cl[B+100][B+100];
int idx[100005];
bool tx[256][267];
int hh[400005];

void insert(char* s, int id) {
  int now = 0;
  for (int i = 0; s[i]; i ++) {
    int c = s[i] - 'a';
    if (!ch[now][c]) {
      ch[now][c] = cnt ++;
    }
    now = ch[now][c];
    vec[now].push_back(id);
  }
  hh[now] = id;
}

char s[400005];

int solve(int k, const string& t){
  string& s = vv[k-1];
  for (int i = 0; i < 26; i ++) {
    for (int j = i+1; j < 26; j ++) {
      tx[t[i]][t[j]] = 1;
      tx[t[j]][t[i]] = 0;
    }
  }
  int ans = 0;
  int now = 0;
  for (int i = 0; i < min(B, (int)s.size()); i ++) {
    if (hh[now] >= 0) {
      ans ++;
    }
    for (int j = 0; j < 26; j ++) {
      if (t[j] == s[i]) {
        now = ch[now][s[i]-'a'];
        break;
      }
      int c = t[j]-'a';
      int num = vec[ch[now][c]].size();
      ans += num;
    }
  }
  if (s.size() < B) {
    return ans;
  }
  sort(vec[now].begin(), vec[now].end(), [](const int xx, const int yy){
      int x = idx[xx], y = idx[yy]; 
      if (cl[x][y] == -1) {
      return vstr[x].size() < vstr[y].size();
      } else {
      int id = cl[x][y];
      return tx[ vstr[x][id] ][ vstr[y][id] ];
      }
      ;
      });
  for (auto x : vec[now]) {
    if (x != k-1) {
      ans ++;
    } else {
      break;
    }
  }
  return ans;
}

int main(int argc, const char *argv[])
{
  memset(hh, -1, sizeof(hh));
  int n;
  cin >> n;
  for (int i = 0; i < n; i ++) {
    scanf("%s", s);
    int len = strlen(s);
    insert (s, i);
    vv.push_back(string(s));
    if (len >= B) {
      idx[i] = vstr.size();
      vstr.push_back(string(s));
      key.push_back(vector<ull>());
      key.back().push_back(s[0]);
      for (int j = 1; j < len; j ++) {
        key.back().push_back(key.back().back()*base + s[j]);
      }
    }
  }
  for (int i = 0; i < (int)vstr.size(); i ++) {
    for (int j = i+1; j < (int)vstr.size(); j ++) {
      const string& x = vstr[i], y = vstr[j];
      int low = 0, high = (int)min(x.size(), y.size()) - 1;
      while (low <= high) {
        int mid = (low + high)/2;
        if (key[i][mid] != key[j][mid]) {
          high = mid -1;
        } else {
          low = mid + 1;
        }
      }
      if (low > (int)min(x.size(), y.size()) - 1) {
        cl[i][j] = cl[j][i] = -1;
      } else {
        cl[i][j] = cl[j][i] = low;
      }
    }
  }
  int q;
  cin >> q;
  while (q --) {
    int k;
    string t;
    cin >> k >> t;
    int now = 0;
    cout << solve(k, t) + 1 << endl;
  }
  return 0;
}



Measured memory_bytes: 69744
#ifndef LOCAL
#pragma GCC optimize("O3")
#endif
#include "bits/stdc++.h"
#include <ext/pb_ds/assoc_container.hpp> // Common file
#include <ext/pb_ds/tree_policy.hpp> // Including tree_order_statistics_node_update
#include <ext/pb_ds/detail/standard_policies.hpp>
using namespace std;
using namespace __gnu_pbds;
#define sim template < class c
#define int long long
#define ris return * this
#define dor > debug & operator <<
#define eni(x) sim > typename \
  enable_if<sizeof dud<c>(0) x 1, debug&>::type operator<<(c i) {
sim > struct rge { c b, e; };
sim > rge<c> range(c i, c j) { return rge<c>{i, j}; }
sim > auto dud(c* x) -> decltype(cerr << *x, 0);
sim > char dud(...);
struct debug {
#ifdef LOCAL
~debug() { cerr << '\n'; }
eni(!=) cerr << boolalpha << i; ris; }
eni(==) ris << range(begin(i), end(i)); }
sim, class b dor(pair < b, c > d) {
  ris << "(" << d.first << ", " << d.second << ")";
}
sim dor(rge<c> d) {
  *this << "[";
  for (auto it = d.b; it != d.e; ++it)
    *this << ", " + 2 * (it == d.b) << *it;
  ris << "]";
}
#else
sim dor(const c&) { ris; }
#endif
};
#define imie(...) " [" << #__VA_ARGS__ ": " << (__VA_ARGS__) << "] "
#define fastio ios_base::sync_with_stdio(false);cin.tie(0);
typedef tree< pair<int,int>, null_type, less<pair<int,int> >, rb_tree_tag, tree_order_statistics_node_update> ordered_set;
typedef long long ll;
const ll MOD = 1e9 + 7 ;
const ll N = 2e5 + 10 ;
const ll INF = 1e18 + 10 ;
signed main(){
    fastio
    int x , y , a , b , c ;
    cin >> x >> y >> a >> b >> c ;
    priority_queue<int> red , green, extra, all ;

    for(int i = 0; i < a; i++){
        int t ;
        cin >> t ;
        red.push(t) ;
    }
    for(int i = 0; i < b; i++){
        int t ;
        cin >> t ;
        green.push(t) ;
    }
    for(int i = 0; i < c; i++){
        int t ;
        cin >> t ;
        extra.push(t) ;
    }
    for(int i = 0; i < x; i++){
        all.push(red.top()) ; red.pop() ;
    }
    for(int i = 0; i < y; i++){
        all.push(green.top()) ; green.pop() ;
    }
    for(int i = 0; i < c; i++){
        all.push(extra.top()) ; extra.pop() ;
    }
    int ans = 0 ;
    for(int i = 0; i < x + y; i++){
        ans += all.top() ; all.pop() ;
    }
    cout << ans << endl ;
    return 0; 
}

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

using namespace std;

#define rep(i,n) for(int i=0;i<n;i++)
#define MP make_pair

int const SIZE = 20;
int const MAX_N = 11;
int const INF = (int)1e8;
int H, W;
char grid[SIZE][SIZE];
typedef pair<int, int> Pii;

int cost[SIZE][SIZE][SIZE][SIZE];
int dist[MAX_N][MAX_N];
int dp[1<<MAX_N][MAX_N];
map<Pii, int> dmap;

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

inline bool inF(int x, int y) {
  return 0<=x && x<W && 0<=y && y<H;
}

bool bfs(int SX, int SY) {

#define COST(x, y) cost[SY][SX][y][x]
  
  fill(&COST(0, 0), &COST(0, 0)+22*22, INF);
  queue<Pii> Q;
  Q.push(Pii(SX, SY));
  COST(SX, SY) = 0;
  while(!Q.empty()) {
    Pii pii = Q.front(); Q.pop();
    int x = pii.first, y = pii.second;
    for(int i=0; i<4; i++) {
      int nx = x+dx[i], ny = y+dy[i];
      if(!inF(nx, ny)) continue;
      if(COST(nx, ny) != INF) continue;
      if(grid[ny][nx] == 'x') continue;
      COST(nx, ny) = COST(x, y) + 1;
      Q.push(Pii(nx, ny));
    }
  }
  
  bool ok = true;
  rep(i, H)rep(j, W) if(grid[i][j] == '*' && COST(j, i) == INF) ok = false;
  
  return ok;
}

int main() {
  
  while(cin >> W >> H && (W|H)) {
    
    dmap.clear();
    
    int dsx, dsy;
    int dcnt = 1;
    rep(i, H) rep(j, W){
      cin>>grid[i][j];
      if(grid[i][j] == 'o') {
        dsx = j, dsy = i;
        dmap[Pii(j, i)] = 0;
      }
      if(grid[i][j] == '*') {
        dmap[Pii(j, i)] = dcnt++;
      }
    }
    
    bool NA = false;
    rep(i, H) rep(j, W)
      if(grid[i][j] == '*' || grid[i][j] == 'o') {
        if(!bfs(j, i)) { NA = true; i = j = INF; }
      }
    if(NA) { cout << -1 << endl; continue; }
    
    rep(i, H) rep(j, W) rep(k, H) rep(l, W) {
      if(i == k && j == l) continue;
      if((grid[i][j] == '*' && grid[k][l] == '*')
         ||
         (grid[i][j] == 'o' && grid[k][l] == '*')) {
        dist[dmap[Pii(j, i)]][dmap[Pii(l, k)]] = cost[i][j][k][l];
      }
    }
   
    int V = dcnt;
    
    for(int i=0; i<(1<<V); i++) fill(dp[i], dp[i]+MAX_N, INF);
    dp[(1<<V)-1][0] = 0;
    
    for(int st = (1<<V)-2; st >= 0; st--)
      for(int v=0; v<V; v++)
        for(int u=0; u<V; u++)
          if(!((st >> u) & 1)) { dp[st][v] = min(dp[st][v], dp[st|(1<<u)][u]+dist[v][u]); }
    
    cout << dp[0][0] << endl;
  }
  
  return 0;
}

Measured memory_bytes: 1864
///
// File:  a.go
// Author: ymiyamoto
//
// Created on Sun Feb 18 21:00:18 2018
//
package main

import (
	"fmt"
)

func main() {
	var N, A int
	fmt.Scan(&N, &A)
	if N%500 <= A {
		fmt.Println("Yes")
	} else {
		fmt.Println("No")
	}
}


Measured memory_bytes: 512
#include <vector>
#include <iostream>
#include <algorithm>
#include <functional>
using namespace std;
int main() {
	int N;
	cin >> N;
	vector<int> a(N - 1), b(N - 1);
	vector<vector<int> > G(N);
	for (int i = 0; i < N - 1; ++i) {
		cin >> a[i] >> b[i]; --a[i], --b[i];
		G[a[i]].push_back(b[i]);
		G[b[i]].push_back(a[i]);
	}
	function<int(int, int)> dist = [&](int pos, int pre) {
		int ans = 0;
		for (int i : G[pos]) {
			if (i == pre) continue;
			ans = max(ans, dist(i, pos) + 1);
		}
		return ans;
	};
	function<void(int, int, int, vector<int>&)> calc = [&](int pos, int pre, int depth, vector<int> &v) {
		int cnt = 0;
		for (int i : G[pos]) {
			if (i == pre) continue;
			calc(i, pos, depth + 1, v);
			++cnt;
		}
		v[depth] = max(v[depth], cnt);
	};
	vector<int> d(N), de(N - 1);
	for (int i = 0; i < N; ++i) {
		d[i] = dist(i, -1);
	}
	for (int i = 0; i < N - 1; ++i) {
		de[i] = max(dist(a[i], b[i]), dist(b[i], a[i]));
	}
	int md = *min_element(d.begin(), d.end());
	md = min(md, *min_element(de.begin(), de.end()));
	long long ans = 1LL << 62;
	for (int i = 0; i < N; ++i) {
		if (d[i] != md) continue;
		vector<int> v(md + 1);
		calc(i, -1, 0, v);
		long long mul = 1;
		for (int i = 0; i < md; ++i) {
			mul *= v[i];
		}
		ans = min(ans, mul);
	}
	for (int i = 0; i < N - 1; ++i) {
		if (de[i] != md) continue;
		vector<int> v(md + 1);
		calc(a[i], b[i], 0, v);
		calc(b[i], a[i], 0, v);
		long long mul = 2;
		for (int i = 0; i < md; ++i) {
			mul *= v[i];
		}
		ans = min(ans, mul);
	}
	cout << md + 1 << ' ' << ans << endl;
	return 0;
}

Measured memory_bytes: 256
N,K,Q = map(int, input().split())
everyone = [K - Q] * N

for i in range(Q):
    anspeople = int(input()) -1 # pythonのindex特性
    everyone[anspeople] += 1
    
for i in range(N):
    if everyone[i] > 0:
        print('Yes')
    else:
        print('No')

Measured memory_bytes: 6584
#include <bits/stdc++.h>
#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 srep(i, s, t) for (int i = s; i < t; ++i)
#define rng(a) a.begin(), a.end()
#define rrng(a) a.rbegin(), a.rend()
#define maxs(x, y) (x = max(x, y))
#define mins(x, y) (x = min(x, y))
#define limit(x, l, r) max(l, min(x, r))
#define lims(x, l, r) (x = max(l, min(x, r)))
#define isin(x, l, r) ((l) <= (x) && (x) < (r))
#define pb push_back
#define eb emplace_back
#define sz(x) (int)(x).size()
#define pcnt __builtin_popcountll
#define uni(x) x.erase(unique(rng(x)), x.end())
#define show(x) cout << #x << " = " << x << endl;
#define PQ(T) priority_queue<T, v(T), greater<T>>
#define bn(x) ((1 << x) - 1)
#define dup(x, y) (((x) + (y)-1) / (y))
#define newline puts("")
#define v(T) vector<T>
#define vv(T) v(v(T))
using namespace std;
typedef long long int ll;
typedef unsigned uint;
typedef unsigned long long ull;
typedef pair<int, int> P;
typedef tuple<int, int, int> T;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
typedef vector<T> vt;

int main() {
  int n;
  cin >> n;
  vector<vi> a(n, vi(n - 1));
  rep(i, n) {
    rep(j, n - 1) {
      cin >> a[i][j];
      a[i][j]--;
    }
  }
  rep(i, n) reverse(rng(a[i]));
  vp q;
  auto check = [&](int i) {
    if (a[i].size() == 0)
      return;
    int j = a[i].back();
    if (a[j].size() == 0)
      return;
    if(a[j].back()!=i)return;
    if (i > j)
      swap(i, j); // return;
    q.push_back(P(i, j));
  };

  rep(i, n) check(i);
  int day = 0;
  while (q.size()) {
    day++;
    vp prevQ;
    sort(rng(q));
    q.erase(unique(rng(q)), q.end());
    swap(q, prevQ);
    for (auto p : prevQ) {
      int i = p.fi;
      int j = p.se;
      a[i].pop_back();
      a[j].pop_back();
    }
    for (auto p : prevQ) {
      int i = p.fi;
      int j = p.se;
      check(i);
      check(j);
    }
  }
  rep(i, n) {
    if (a[i].size()) {
      cout << -1 << endl;
      return 0;
    }
  }
  cout << day << endl;
  return 0;
}

Measured memory_bytes: 7500
# ABC168D
# https://atcoder.jp/contests/abc168/tasks/abc168_d

n,m=map(int, input().split())
ab=[[]for _ in range(n)]
for i in range(m):
    a,b = list(map(int, input().split()))
    a,b = a-1, b-1
    ab[a].append(b)
    ab[b].append(a)
    '''
    まず両方を追加する考えがなかった。
    浅い部屋からも深い部屋からも参照できる。
    その代わりに visitedで考えなくて良い部屋を記録している。
    部屋１につながっているのはもっとも浅い部屋でそこから考えることがきっかけになる？
    '''
#print(ab)
ans = [0]*n
visited={0}
stack=[0]
for i in stack:
    '''
    現在考えている部屋を stack、そこにつながる部屋 ab[i]として考える。
    stack=[0]なので1の部屋から始める。なので深さ1の部屋が ab[i](ab[0])で分かる。
    i==0の始めの一周では、ab[i]は深さ１の部屋のリストであり、それぞれの部屋を jとして順番に考える。
    (このように深さ1から考えられる＋次に深さ2の部屋を求めるというのが上手くいく)
    その現在考えている部屋 i(stackの循環)とそこにつながる部屋 j(abの循環)なので、
    部屋 jはより浅い部屋 iを道しるべにすればよい。
    しかし、ab[a], ab[b]と両方を追加しているので、浅い部屋も深い部屋も abには含まれている。
    浅い部屋から順に考えているので、過去に調べた abの値は無視するために visitedを導入する。たぶん。
    '''
    for j in ab[i]:
        #print(i,j,'----------------------')
        if j in visited:
            continue
        stack.append(j)
        visited.add(j)
        ans[j]=i+1
        #print('stack', stack)
        #print('visited', visited)
        #print('ans', ans)
'''check=0
for i in ans[1:]:
    if i==0:check==1
if check:
    print('No')
else:
    print("Yes")
    print(*ans[1:])'''
print("Yes")
print(*ans[1:])

Measured memory_bytes: 43052
import java.util.*;

public class Main{
    public static void main(String[] args){
        Scanner sc=new Scanner(System.in);
        int n=sc.nextInt();
        Set<String> st=new HashSet<String>();
        String[] ans=new String[n];
        for(int i=0;i<n;i++){
            String s=sc.next();
            String t=sc.next();
            if(s.equals("insert")){
                st.add(t);
            }else{
                if(st.contains(t)){
                    System.out.println("yes");
                }else{
                    System.out.println("no");
                }
            }
        }
    }
}


Measured memory_bytes: 257232
#include <bits/stdc++.h>
#define rep(i, a, n) for(int i = a; i < n; i++)
#define repr(i, a, b) for(int i = a; i >= b; i--)
#define int long long
#define all(a) a.begin(), a.end()
using namespace std;
typedef pair<int, int> P;
const int mod = 1000000007;
const int INF = 1e18;

int h, w;
int dp[1010][1010];
string s[1010];

signed main(){
    cin >> h >> w;
    rep(i, 0, h){
        cin >> s[i];
    }
    dp[0][0] = 1;
    rep(i, 0, h){
        rep(j, 0, w){
            if(i != h - 1 && s[i + 1][j] != '#'){
                dp[i + 1][j] += dp[i][j];
                dp[i + 1][j] %= mod;
            }
            if(j != w - 1 && s[i][j + 1] != '#'){
                dp[i][j + 1] += dp[i][j];
                dp[i][j + 1] %= mod;
            }
        }
    }
    cout << dp[h - 1][w - 1] << endl;
}


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


int main() {
    vector<int> vec(5);
    for (int i = 0; i < 5; i++) {
        cin >> vec.at(i);
        if (vec.at(i) == 0) cout << i + 1 << endl;
    }

}

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

using namespace std;
#define ALL(x)              (x).begin(),(x).end()
#define REP(i, n)           for (ll (i) = 0 ; (i) < (ll)(n) ; ++(i))
#define REPN(i, m, n)       for (ll (i) = m ; (i) < (ll)(n) ; ++(i))
#define INF                 (ll)2e9
#define MOD                 (1000 * 1000 * 1000 + 7)
#define Ceil(x, n)          (((((x))+((n)-1))/n))
#define CeilN(x, n)         (((((x))+((n)-1))/n)*n)
#define FloorN(x, n)        ((x)-(x)%(n))
#define IsOdd(x)            (((x)&0x01UL) == 0x01UL)
#define IsEven(x)           (!IsOdd((x)))
#define M_PI                3.14159265358979323846
typedef long long           ll;
typedef pair<ll, ll>	    P;

/*-----------------------------------------------------------------------------
　処理
 -----------------------------------------------------------------------------*/
/* 最大公約数 */
ll gcd(ll a, ll b)
{
	if (b == 0) return a;
	return gcd(b, a % b);
}

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

	ll rNum = 0;
	ll gNum = 0;
	ll bNum = 0;
	REP(i, N) {
		if (S[i] == 'R') rNum++;
		if (S[i] == 'G') gNum++;
		if (S[i] == 'B') bNum++;
	}
	ll ans = rNum * gNum * bNum;

	ll renzoku = 0;
	REP(i, N) {
//		ll lim = N /3 + 1;
		REPN(j, 1, N) {
			if (N <= i + j) continue;
			if (N <= i + j * 2) continue;
			char a = S[i];
			char b = S[i + j];
			char c = S[i + j * 2];
			if (a != b && b != c && c != a) {
				renzoku++;
			}
		}
	}

	ans -= renzoku;
	cout << ans << endl;
	return 0;
}


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

typedef unsigned long long ull;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
typedef pair<double, double> pdd;
//const ull mod = 1e9 + 7;
const ll mod = 1e9 + 7;
#define REP(i,n) for(int i=0;i<(int)n;++i)

// debug
#define dump(x)  cerr << #x << " = " << (x) << endl;
#define debug(x) cerr << #x << " = " << (x) << " (L" << __LINE__ << ")" << " " << __FILE__ << endl;

template<class S, class T> ostream& operator << (ostream& os, const pair<S, T> v){
  os << "(" << v.first << ", " << v.second << ")"; return os;
}
template<class T> ostream& operator << (ostream& os, const vector<T> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << " ";} os << v[i];} return os;
}
template<class T> ostream& operator << (ostream& os, const vector<vector<T>> v){
  for(int i = 0; i < (int)v.size(); i++){if(i > 0){os << endl;} os << v[i];} return os;
}
template<class T> bool chmax(T &a, const T &b) { if (a<b) { a=b; return 1; } return 0; }
template<class T> bool chmin(T &a, const T &b) { if (a>b) { a=b; return 1; } return 0; }

// conversion number to bit
string num2bit(ll num, ll len){
  string bit = "";
  REP(i, len){
    bit += char('0'+(num>>i & 1));
  }
  return bit;
}

string N;
ll K;

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

    cin >> N >> K;
    ll M = N.size();
    ll dp[105][2][5] = {};
    dp[0][1][0] = 1;
    REP(i, M){
    	REP(k, 4){
    		REP(j, 10){
    			ll nk = k + (j!=0 ? 1 : 0);
	    		dp[i+1][0][nk] += dp[i][0][k];
	    		if(j<N[i]-'0')dp[i+1][0][nk] += dp[i][1][k];
	    		if(j==N[i]-'0')dp[i+1][1][nk] += dp[i][1][k];
	    	}
    	}
    }

    cout << dp[M][0][K] + dp[M][1][K] << endl;

    /*
    cout << dp[M][0][K] << endl;
    cout << dp[M][1][K] << endl;

    REP(j, 2){
	    REP(i, 10){
	    	REP(k, 5){
	    		cout << dp[i][j][k] << " ";
	    	}
	    	cout << endl;
	    }
	    cout << endl;
	}
	*/
    return 0;
}

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


int main(){
  int n,i;
  cin >> n;
  vector<int> a(n),b(n);
  int med=(n/2);
  vector<pair<int,int>> ab(n);
  for(i=0;i<n;++i){
    cin >> a[i];
    ab[i]=make_pair(a[i],i);
  }
  sort(ab.begin(),ab.end());
  for(i=0;i<n;++i){
    if(i+1<=med){
      b[ab[i].second]=ab[med].first;
    }else{
      b[ab[i].second]=ab[med-1].first;
    }
  }
  for(i=0;i<n;++i){
    cout << b[i] << endl;
  }
  return 0;
}


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

const int INF=1e9+5;

int main(){
   int n;
  cin>>n;
  int dp[n+5];
  int a[n];
  for(int i=0;i<n;i++)
    cin>>a[i];
 
           for(int i=0;i<n;i++)
            dp[i]=INF;
            dp[0]=0;
           for(int i=0;i<n;i++){
             if(i+1<n)
               dp[i+1]=min(dp[i+1],dp[i]+abs(a[i]-a[i+1]));
             if(i+2<n)
               dp[i+2]=min(dp[i+2],dp[i]+abs(a[i]-a[i+2]));
           }
           
           printf("%d\n",dp[n-1]);
           return 0;
           }
             

Measured memory_bytes: 1024
#include <bits/stdc++.h>
#define f(i,j,k) for(int i=j;i<k;i++)
#define f2(i,j,k) for(int i=j;i>k;i--)
using namespace std;
int main(){
    long long n,a,b;
    cin>>n>>a>>b;
    if(a>b){
        cout<<0<<endl;
    }
    else{
        if(n==1){
            if(a==b){
                cout<<1<<endl;
            }
            else{
                cout<<0<<endl;
            }
        }
        else{
            cout<<(b-a)*(n-2)+1<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3648
from collections import deque

H, W = map(int, input().split())
N = int(input())

tmp = 0
rlt = []
h = deque([])

As = list(map(int, input().split()))

for k,i in enumerate(As):
  for _ in range(i):
    tmp += 1
    if ((tmp - 1) // W) % 2 == 0:
      h.append(k+1)
    else:
      h.appendleft(k+1)
    if tmp % W == 0:
      rlt.append(h)
      h = deque([])

for q in rlt:
  print(" ".join(map(str, q)))

Measured memory_bytes: 74128
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <stack>
#include <queue>
#include <cmath>
#include <tuple>
#include <cstdio>
#include <bitset>
#include <sstream>
#include <iterator>
#include <numeric>
#include <map>
#include <cstring>
#include <set>
#include <functional>
#include <iomanip>

using namespace std;

#define DEBUG_ //!!提出時にコメントアウト!!
#ifdef DEBUG_
	#define dump(x)  cerr << #x << " = " << (x) << endl;
#else
	#define dump(x)  ;
#endif

#define equals(a,b) (fabs((a)-(b)) < EPS)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define REP(i,n)  FOR(i,0,n)
#define SZ(x) ((int)(x).size())
#define pb push_back
#define eb emplace_back

//#define int long long

typedef long long LL;
typedef vector<int> VI;
typedef vector<LL> VL;
typedef vector<VI> VVI;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<LL, LL> PLL;

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

template <typename T>
std::string printVector(const std::vector<T> &data)
{
    std::stringstream ss;
    std::ostream_iterator<T> out_it(ss, ", ");
    ss << "[";
    std::copy(data.begin(), data.end() - 1, out_it);
    ss << data.back() << "]";
    return ss.str();
}

template <typename T>
void print_array(const T &ary, int size){
    REP(i,size){
        cout << ary[i] << " ";
    }
    cout << endl;
}

const int MOD = 1e9+7;
const LL LINF = 1001002003004005006ll;
const int INF = 1001001001;
const double EPS = (1e-10);

signed main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout << setprecision(12);
    int N; cin >> N;
    LL ans = 0;
    FOR(i,1,N+1){
        if(i%3 != 0 && i%5 != 0) ans += i;
    }
    cout << ans << endl;

}


Measured memory_bytes: 3640
import fractions
n, X = map(int, input().split())
x = list(map(int, input().split()))
x.append(X)
x.sort()
d = []
for i in range(n):
    d.append(x[i+1]-x[i])
ans = d[0]
for j in range(1, len(d)):
    ans = fractions.gcd(ans, d[j])
print(ans)

Measured memory_bytes: 16296
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <algorithm>
#include <cctype>
#include <cmath>
#include <queue>
#include <map>
#include <numeric>
#include <unordered_map>
#include <iomanip>
#include <functional>
#include <bitset>
#include <complex>

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

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

typedef long long ll;

using namespace std;


int main()
{
  ios::sync_with_stdio(false);
  cin.tie(0);
  string s;
  cin>>s;
  int l=s.length();
  ll res=0;
  rep(i,l)
  {
    ll d=s[i]-'0';
    res+=((9*pow(10,l-1-i)-pow(2,l-1-i))/8)*pow(2,i)*d;
  }
  cout<<res<<endl;

  return 0;

}


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


int main(){
  // 標準入力高速化のおまじない
  // scanfとの同期を切る。以降紛らわしいのでscanf使用不可。
  ios::sync_with_stdio(false);
  // // cin前の自動flashをやめる
  cin.tie(nullptr);

  int N;
  cin >> N;
  vector<int> A(N),B(N);
  for(int i=0; i<N; i++){
    cin >> A[i] >> B[i];
  }
  sort(A.begin(), A.end());
  sort(B.begin(), B.end());

  ll result = 0;
  if(N % 2 == 1){
    ll mi = A[N/2], ma = B[N/2];
    result = ma - mi+1;
  }
  else{
    ll mi = A[N/2-1] + A[N/2];
    ll ma = B[N/2-1] + B[N/2];
    result = ma - mi +1;
  }
  cout << result << endl;
  return 0;
}


Measured memory_bytes: 4760
def main():
    n = int(input())
    s = input()
    
    a = [0] * (n)
    b = [0] * (n)
    for i in range(1, n):
        if s[i - 1] == 'W':
            a[i] = a[i - 1] + 1
        else:
            a[i] = a[i - 1]
        if s[n- i] == 'E':
            b[n - i - 1] = b[n - i ] + 1
        else:
            b[n- i - 1] = b[n - i ]
    ans = 10**9
    for aa, bb in zip(a, b):
        ans = min(ans, aa++bb)
    print(ans) 
        
if __name__ == '__main__':
    main()

Measured memory_bytes: 19448
#include<bits/stdc++.h>
using namespace std;
int main(){
    long long n,x;
    cin >> n >> x;
    long long a[100050];
    for(long long i = 0;i < n;i++)cin >> a[i];
    long long ans = 0;
    if(a[0] >= x){
        long long y = a[0] - x;
        ans += y;
        a[0] = x;
    }
    for(long long i = 1;i < n;i++){
        if(a[i-1] + a[i] >= x){
            long long y = (a[i-1] + a[i]) - x;
            ans += y;
            a[i] -= y;
        }
    }
    cout << ans << endl;
}

Measured memory_bytes: 1024
#include <bits/stdc++.h>
using namespace std;
# define PI  3.14159265358979323846264338327950L

int main(){
int a,b,h,m;
cin>> a>>b>> h>> m;
long double rad = 2*PI*((long double)h/12+((long double )m/60)/12 - (long double)m/60);

long double ans = (long double)(a*a+b*b) - (long double)(2*a*b*cosl(rad));
cout<<fixed<< setprecision(20)<< sqrtl(ans) << endl;
}

Measured memory_bytes: 4120
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;

class hoge{
    public:
    ll sum, a, b, c;
    hoge(ll _sum, ll _a, ll _b, ll _c){
        sum = _sum;
        a = _a;
        b = _b;
        c = _c;
    }
    bool operator < (const hoge &h)const{
        return sum < h.sum;
    }
    ll hash(){
        return a + 10000LL * b + 100000000LL * c;
    }
};

int main(){

    ll X, Y, Z, K;
    cin >> X >> Y >> Z >> K;
    vector<ll>A(X), B(Y), C(Z);
    for(int i = 0; i < X; i++)cin >> A[i];
    for(int i = 0; i < Y; i++)cin >> B[i];
    for(int i = 0; i < Z; i++)cin >> C[i];
    sort(A.begin(), A.end(), greater<ll>());
    sort(B.begin(), B.end(), greater<ll>());
    sort(C.begin(), C.end(), greater<ll>());
    
    priority_queue<hoge>Q;
    map<ll, ll>flg;
    Q.push(hoge(A[0] + B[0] + C[0], 0, 0, 0));
    flg[0] = 1;
    for(ll i = 0; i < K; i++){
        hoge h = Q.top();
        Q.pop();
        cout << h.sum << endl;
        if(h.a + 1 < X){
            h.a++;
            if(flg[h.hash()] == 0){
                flg[h.hash()] = 1;
                Q.push(hoge(A[h.a] + B[h.b] + C[h.c], h.a, h.b, h.c));
            }
            h.a--;
        }
        if(h.b + 1 < Y){
            h.b++;
            if(flg[h.hash()] == 0){
                flg[h.hash()] = 1;
                Q.push(hoge(A[h.a] + B[h.b] + C[h.c], h.a, h.b, h.c));
            }
            h.b--;
        }
        if(h.c + 1 < Z){
            h.c++;
            if(flg[h.hash()] == 0){
                flg[h.hash()] = 1;
                Q.push(hoge(A[h.a] + B[h.b] + C[h.c], h.a, h.b, h.c));
            }
            h.c--;
        }
    }

    return 0;
}

Measured memory_bytes: 896
#include<cstdio>
#include<cstdlib>
#include<cstring>
#include<cmath>
#include<iostream>
#include<string>
#include<vector>
#include<map>
#include<set>
#include<list>
#include<queue>
#include<deque>
#include<algorithm>
#include<numeric>
#include<utility>
#include<complex>
#include<functional>
 
using namespace std;

/* constant */

const int MAX_N = 1000;

const double DELTA = 1e-4;
const double DELTA2 = 1e-8;
const double PI = acos(-1);
const double PI2 = PI * 2;

/* typedef */

template <typename T>
struct Pt {
  T x, y;

  Pt() {}
  Pt(T _x, T _y) : x(_x), y(_y) {}
  Pt(const Pt& pt) : x(pt.x), y(pt.y) {}

  bool operator==(const Pt pt) const { return x == pt.x && y == pt.y; }
  Pt<T> operator+(const Pt pt) const { return Pt<T>(x + pt.x, y + pt.y); }
  Pt<T> operator-() const { return Pt<T>(-x, -y); }
  Pt<T> operator-(const Pt pt) const { return Pt<T>(x - pt.x, y - pt.y); }
  Pt<T> operator*(T t) const { return Pt<T>(x * t, y * t); }
  Pt<T> operator/(T t) const { return Pt<T>(x / t, y / t); }
  T dot(Pt v) const { return x * v.x + y * v.y; }
  T cross(Pt v) const { return x * v.y - y * v.x; }
  Pt<T> mid(const Pt pt) { return Pt<T>((x + pt.x) / 2, (y + pt.y) / 2); }
  T d2() { return x * x + y * y; }
  double d() { return sqrt(d2()); }

  Pt<T> rot(double th) {
    double c = cos(th), s = sin(th);
    return Pt<T>(c * x - s * y, s * x + c * y);
  }

  bool operator<(const Pt& pt) const {
    return x < pt.x || (x == pt.x && y < pt.y);
  }

  void print(string format) {
    printf(("(" + format + ", " + format + ")\n").c_str(), x, y);
  }
  void print() { print("%.6lf"); }
};

typedef Pt<double> pt;

/* global variables */

int n;
pt pts[2][MAX_N], rpts[MAX_N];

/* subroutines */

bool pt_comp(const pt& pt0, const pt& pt1) {
  double dx = pt0.x - pt1.x, dy = pt0.y - pt1.y;
  return (dx <= -DELTA) || (dx < DELTA && dy <= -DELTA);
}

/* main */

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

    for (int j = 0; j < 2; j++) {
      pt ctr(0.0, 0.0);
      for (int i = 0; i < n; i++) {
	cin >> pts[j][i].x >> pts[j][i].y;
	ctr = ctr + pts[j][i];
      }
      ctr = ctr / n;
      //ctr.print();

      for (int i = 0; i < n; i++)
	pts[j][i] = pts[j][i] - ctr;
    }

    pt *pts0 = pts[0], *pts1 = pts[1];
    double min_th = 10;

    pt& pto = pts0[0];
    double tho = atan2(pto.y, pto.x);
    double d2o = pto.d2();

    for (int i = 0; i < n; i++) {
      pt& pti = pts1[i];
      double d2i = pti.d2();
      if (abs(d2i - d2o) < DELTA2) {
	double thi = atan2(pti.y, pti.x);
	double dth = thi - tho;
	if (dth > PI) dth -= PI2;
	else if (dth < -PI) dth += PI2;

	double adth = abs(dth);
	if (min_th <= adth) continue;
	//cout << dth << endl;

	double cdth = cos(dth), sdth = sin(dth);
	for (int j = 0; j < n; j++) {
	  rpts[j].x = cdth * pts0[j].x - sdth * pts0[j].y;
	  rpts[j].y = sdth * pts0[j].x + cdth * pts0[j].y;
	}
	sort(rpts, rpts + n, pt_comp);

	bool found = true;
	for (int j = 0; j < n; j++)
	  if (! binary_search(rpts, rpts + n, pts1[j], pt_comp)) {
	    found = false;
	    break;
	  }

	if (found) min_th = adth;
      }
    }

    printf("%.10lf\n", min_th);
  }

  return 0;
}

Measured memory_bytes: 1372
def main():
    n = int(input())

    min_s = 100001
    for i in range(1, n//2+2):
        b = n - i

        a_s, b_s = i % 10, b % 10
        while i // 10 != 0:
            i //= 10
            a_s += i % 10

        while b // 10 != 0:
            b //= 10
            b_s += b % 10

        if a_s + b_s < min_s:
            min_s = a_s + b_s

    print(min_s)


if __name__ == '__main__':
    main()


Measured memory_bytes: 3060
#include <bits/stdc++.h>
#define rep(i, a, n) for (int i = (int)(a); i <= (int)(n); ++i)
#define rrep(i, a, n) for (int i = (int)(a); i >= (int)(n); --i)
#define debug(x) cerr << #x << " = " << x << "\n"
#define debugv(x) \
  rep(f, 0, (x.size() - 1)) cerr << x[f] << (f == (x.size() - 1) ? "\n" : " ")
#define all(x) x.begin(), x.end()
#define int long long
using namespace std;
typedef pair<int, int> pii;
typedef vector<int> vi;
const int MX = 1e5 + 5, INF = 5 << 28, MOD = 1e9 + 7;

int N, M, K;

void input() {
  int x, y, z;
  cin >> N >> M;
  ;
}
void solve() {
  int A = N, B = M;
  int s = A + B;
  if (((s % 3) == 0) or (A % 3 == 0) or (B % 3 == 0))
    cout << "Possible";
  else
    cout << "Impossible";

  ;
  ;
}
signed main() {
  input();
  solve();
  return 0;
}

Measured memory_bytes: 256
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.StringTokenizer;

public class Main {
	
	static final long MOD = 998244353;
	static int[] zeroes;
	
	public static void main(String[] args) throws IOException {
		MyScanner sc = new MyScanner();
		PrintWriter out = new PrintWriter(System.out);
		char[] vals = sc.next().toCharArray();
		int K = sc.nextInt();
		int tot = 0, z = 0;
		zeroes = new int[vals.length];
		for (int i = 0; i < vals.length; i++) {
			if (vals[i] == '1') {
				zeroes[tot++] = z;
			} else {
				z++;
			}
		}
		zeroes = Arrays.copyOf(zeroes, tot);
		if (K > zeroes.length) {
			K = zeroes.length;
		}
		int[] got = new int[z + 1];
		for (int zero : zeroes) {
			got[zero]++;
		}
		long[][][] table = new long[tot + 1][z + 2][K + 1];
		for (int i = 0; i <= z + 1; i++) {
			for (int j = 0; j <= K ; j++) {
				table[tot][i][j] = 1;
			}
		}
		for (int pos = tot - 1; pos >= 0; pos--) {
			for (int from = z; from >= 0 ; from--) {
				for (int rem = K; rem >= 0; rem--) {
					table[pos][from][rem] = table[pos][from + 1][rem];
					if (from <= zeroes[pos]) {
						for (int cant = 1; pos + cant <= tot && cant - got[from] <= rem; cant++) {
							int nRem = rem - Math.max(cant - got[from], 0);
							if (nRem >= 0) {
								table[pos][from][rem] += table[pos + cant][from + 1][nRem];
							}
						}
						table[pos][from][rem] %= MOD;
					}
				}
			}
		}
		
		out.println(table[0][0][K]);
		
		out.flush();
	}
	
	static class MyScanner {
		private BufferedReader br;
		private StringTokenizer tokenizer;
		
		public MyScanner() {
			br = new BufferedReader(new InputStreamReader(System.in));
		}
		
		public String next() {
			while (tokenizer == null || !tokenizer.hasMoreTokens()) {
				try {
					tokenizer = new StringTokenizer(br.readLine());
				} catch (IOException e) {
					throw new RuntimeException(e);
				}
			}
			return tokenizer.nextToken();
		}
		
		public int nextInt() {
			return Integer.parseInt(next());
		}
		
		public long nextLong() {
			return Long.parseLong(next());
		}
	}
}


Measured memory_bytes: 65776
#include<bits/stdc++.h>
using namespace std;//qwq
int main(){
    string a;
    bool v[2]={0};//hhh
    cin>>a;//readin
    for(int i=0;i<a.length();i++){//see all
        if(a[i]=='C') v[0]=1;//discover c
        if(a[i]=='F'&&v[0])  v[1]=1;//discover f
    }
    if(v[1]) cout<<"Yes";//yes,you can
    else cout<<"No";//no,you can't 
    return 0;
}

Measured memory_bytes: 256
N, K = map(int, input().split())
p = list(map(int,input().split()))
ans = 0
cum = [0]

for i in range(len(p)):
    ex = (1 + p[i])/2
    p[i] = ex
    
for i in  range(len(p)):
    cum.append(p[i] + cum[i])
    
for i in range(K, N+1):
    ans  = max(ans, cum[i] - cum[i-K])

print(ans)

Measured memory_bytes: 25060
//
// Created by Zain on 11/15/2019.
//
#include <bits/stdc++.h>
#define mk make_pair
#define fs first
#define sc second
using namespace std;
typedef long long ll;
typedef long double ld;
int a[3333], b[3333];
ll dp[3333], mod=1e9+7, pr[200010], ipr[200010];
ll pwr(ll x, ll e){
    if(e==0)
        return 1;
    ll tmp=pwr(x, e/2);
    tmp*=tmp;
    tmp%=mod;
    if(e%2){
        tmp*=x;
        tmp%=mod;
    }
    return tmp;
}
ll cmb(ll x, ll y){
    ll ans=pr[x]*ipr[x-y];
    ans%=mod;
    ans*=ipr[y];
    ans%=mod;
    return ans;
}
int main(){
    int n, h, w;
    pr[0]=1;
    ipr[0]=1;
    for(ll i=1; i<200010; ++i){
        pr[i]=pr[i-1]*i;
        pr[i]%=mod;
        ipr[i]=pwr(pr[i], mod-2);
    }
    while(cin>>h>>w>>n){
        ll ans=0;
        vector<pair<int, int> > v;
        for(int i=0; i<n; ++i){
            scanf("%d%d",a+i, b+i);
            v.push_back(mk(a[i], b[i]));
        }
        v.push_back(mk(h, w));
        sort(v.begin(), v.end());
        for(int i=0; i<v.size(); ++i){
            dp[i]=cmb(v[i].sc+v[i].fs-2, v[i].sc-1);
            for(int j=0; j<i; ++j){
                if(v[i].sc >= v[j].sc) {
                    dp[i] -= dp[j] * cmb(v[i].fs - v[j].fs + v[i].sc - v[j].sc, v[i].fs - v[j].fs);
                    dp[i] %= mod;
                }
            }
        }
        ans=dp[(int)(v.size())-1];
        if(ans<0)
            ans+=mod;
        printf("%lld\n",ans);
    }
    return 0;
}





Measured memory_bytes: 3456
process.stdin.resume();
process.stdin.setEncoding('utf8');
process.stdin.on('data', function (arrayStrig)
{
    arrayStrig = arrayStrig.split(' ');
    const a = Number(arrayStrig[0]);
    const b = Number(arrayStrig[1]);
    const area = a * b;
    const length =( a + b ) * 2;
    console.log(area + ' ' + length);
});


Measured memory_bytes: 15528
#include <bits/stdc++.h>
using namespace std;
using vi = vector<int>;
using vb = vector<bool>;
using vc = vector<char>;
using vs = vector<string>;
using vvi = vector<vector<int>>;
using vvc = vector<vector<char>>;
using pii = pair<int, int>;
#define fix10 cout << fixed << setprecision(10);
#define rep(i,n) for(int i=0; i<(int)(n);i++)

int main(){
  long n;
  cin >> n;
  vector<long> h(n);
  rep(i,n){
    cin >> h.at(i);
  }
  long count = 0;
  long maxi = 0;
  for(int i=1;i<n;i++){
    if(h.at(i-1) >= h.at(i)){
      count++;
    }else{
      maxi = max(maxi,count);
      count = 0;
    }
  }
  maxi = max(maxi,count);
  cout << maxi << endl;
}

Measured memory_bytes: 1152
using System;
using System.Collections.Generic;
using System.Linq;

namespace abc151c
{
    class Program
    {
        static void Main(string[] args)
        {
            List<int> input = Console.ReadLine().Split(' ').Select(int.Parse).ToList();

            Dictionary<int, List<string>> dic = new Dictionary<int, List<string>>();
            //List<Obj> aaaaaaa = new List<Obj>();

            for (int index = 0; index < input[1]; index++)
            {
                string[] answer = Console.ReadLine().Split(' ');
                int quest = int.Parse(answer[0]);

                if (dic.ContainsKey(quest))
                {
                    dic[quest].Add(answer[1]);
                }
                else
                {
                    List<string> list = new List<string>();
                    list.Add(answer[1]);

                    dic.Add(quest, list);
                    //Obj a = new Obj();
                    //a.key = quest;
                    //if (answer[1] == "AC")
                    //{
                    //    a.isConplete = true;
                    //}
                    //a.list.Add(answer[1]);

                    //aaaaaaa.Add(a);
                }

            }

            int ok = dic.Where(x => x.Value.Contains("AC")).Count();
            int ng = 0;
            foreach (var aaa in dic)
            {
                int sss = aaa.Value.IndexOf("AC");

                if (sss == -1)
                {

                    //ng += aaa.Value.Count();
                }
                else
                {
                    ng += sss;
                }


            }



            string output = ok + " " + ng;

            Console.WriteLine(output);
        }

    }

    //class Obj
    //{
    //    public int key;
    //    public bool isConplete = false;
    //    public List<string> list = new List<string>();

    //}

}


Measured memory_bytes: 34552
import sys
from collections import deque


input = lambda: sys.stdin.readline().rstrip()


if __name__ == "__main__":
    H, W = map(int, input().split())
    ch, cw = map(lambda x: int(x)-1, input().split())
    dh, dw = map(lambda x: int(x)-1, input().split())
    maze = [list(input()) for _ in range(H)]
    INF = 10**8
    mc = [[INF]*W for _ in range(H)]
    mc[ch][cw] = 0
    walk = [(1, 0), (0, 1), (-1, 0), (0, -1)]
    warp = [(y, x) for x in range(-2, 3) for y in range(-2, 3) if abs(y) + abs(x) > 1]
    que = deque()
    que.append((ch, cw, 0))
    while que:
        y, x, w = que.popleft()
        for dy, dx in walk:
            ny = y + dy
            nx = x + dx
            if H > ny >= 0 and W > nx >= 0 and mc[ny][nx] > w and maze[ny][nx] == ".":
                mc[ny][nx] = w
                que.appendleft((ny, nx, w))
        for dy, dx in warp:
            ny = y + dy
            nx = x + dx
            if H > ny >= 0 and W > nx >= 0 and mc[ny][nx] > w+1 and maze[ny][nx] == ".":
                mc[ny][nx] = w + 1
                que.append((ny, nx, w+1))
    if mc[dh][dw] == INF:
        print(-1)
    else:
        print(mc[dh][dw])


Measured memory_bytes: 132588
#include<bits/stdc++.h>
using namespace std;
int dx[9]={-1,-1,-1,0,0,0,1,1,1};
int dy[9]={-1,0,1,-1,0,1,-1,0,1};
	map<pair<int,int>,int> cnt;
	long long H,W,N,a,b,p,q;
	long long ditmedevc[11];
int main (){

	cin>>H>>W>>N;
	ditmedevc[0]=(H-2)*(W-2);
  while(N--){
  	cin>>a>>b;
      for(int i=0;i<9;i++){
      	p=a+dx[i];
      	q=b+dy[i];
      	if(p>1&&p<=H-1&&q>1&&q<=W-1){
      		cnt[{p,q}]++;
      		ditmedevc[cnt[{p,q}]-1]--;
      		ditmedevc[cnt[{p,q}]]++;
		  }
	  } 
  }
   for(int i=0;i<10;i++){
	  	cout<<ditmedevc[i]<<endl;
	  }
}

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

int main(){
  int k,s;
  cin>>k>>s;
  k++;
  int ans = 0;
  for(int i = 0;i<k;i++){
    for(int j = 0;j<k;j++){
      int h = s-i-j;
          if(h<k&&h>=0){
            ans++;
          }
    }
  }
  cout<<ans<<endl;
  return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <set>
#include <queue>
#include <stack>
#include <map>
#include <algorithm>
#include <math.h>
#include <cassert>
#define rep(i,n) for(int i = 0; i < n; ++i )
using namespace std;
using ll = long long;
using P = pair<int,int>;

int main() {
  int n,h;
  cin >> n >> h;
  int a=1; priority_queue<int> b;
  rep(i,n){
    int x,y;
    cin >> x >> y;
    a = max(a,x);
    b.emplace(y);
  }
  int ans = 0;
  while(!b.empty()){
    int d = b.top(); b.pop();
    if(d<=a) break;
    h -= d;
    ++ans;
    if(h<=0) break;
  }
  if(h>0) ans += (h+a-1)/a;
  cout << ans << endl;
}

Measured memory_bytes: 892
#include<iostream>
#include<math.h>
#include<vector>
#include<set>
#include<algorithm>
#include<ctype.h>
#include<unordered_set>
#include<string>
#include<iomanip>
#include<queue>
#include<limits>

using namespace std;
int gcd(int a, int b) {
	if (b == 0)
		return a;
	return gcd(b, a % b);
}
#define MOD 1000000007
#define INF 99999999999 
#define pb push_back
#define mt make_tuple
#define ll long long
ll ncr(ll n, ll r)
{
	ll i, ans = 1, k = 0;
	if (r == 0)
		return 1;
	else if (n < r)
		return 0;
	for (i = n; i >= n - r + 1; i--)
	{
		ans *= i;
		ans /= n - i + 1;
	}


	return ans;

}
bool visited[6] = { false };
int n = 6;
vector<int> adj[6];


void max_heapify(int a[100], int i)
{
	int l, r, largest = i;
	l = 2 * i + 1;
	r = 2 * i + 2;
	if (l<n && a[l]>a[i])
		largest = l;
	if (r<n && a[r]>a[l])
		largest = r;
	if (largest != i)
	{
		int k;
		k = a[i];
		a[i] = a[largest];
		a[largest] = k;
		max_heapify(a, largest);
	}

}
int power(ll x, ll y, ll p)
{
	int res = 1;
	x = x % p;

	while (y > 0)
	{

		if (y & 1)
			res = (res * x) % p;


		y = y >> 1;
		x = (x * x) % p;
	}
	return res;
}

bool square(ll n)
{
	double x;
	x = sqrt(n);
	if (x == floor(x))
		return true;
	else return false;
}


bool prime(ll n)
{
	ll i;
	for (i = 2; i * i <= n; i++)
	{
		if (n % i == 0)
			return false;
	}
	return true;
}
ll arr[1000];
void dfs(ll a, vector<ll>adj[100099], bool visited[100001],ll& count, vector<ll> in, ll n,ll ans[])
{
	visited[a] = true;
	if (a <= n)
	{
		count++;
		arr[count - 1] = a;
	}
	for (auto u : adj[a])
	{
		if (!visited[u])
		{
			visited[u] = true;
			dfs(u, adj, visited, count , in, n, ans);
		}
	}
	for (ll i = 0; i < count;i++) {
		ans[arr[i]] = count;
	}
	
}
ll modi(ll a, ll m)
{
	return power(a, m - 2, m);
	
}
ll calhash(string& s) {
	ll i, hash = 0, p=1, pow = 3;
	for (i = 0; s[i] != '\0'; i++) {
		hash = (hash + p * (s[i] - 'a' + 1)) % MOD;
		p *= pow;
	}
	return hash;
}

int main() {
	int n, mat[3][3], i , j;
	
	for (i = 0; i < 3; i++) {
		for (j = 0; j < 3; j++) {
			cin >> mat[i][j];
		}
	}
	int a, k;
	cin >> n;
	for (k = 0; k < n; k++) {
		cin >> a;
		for (i = 0; i < 3; i++) {
			
			for (j = 0; j < 3; j++) {
				if (mat[i][j] == a) {
					
					if (mat[i][j] > 0) {
						mat[i][j] *= -1;
					}
				}
			}
		}
	}
	
	bool ans = false;
	for (i = 0; i < 3; i++) {
		if (mat[i][0] < 0 && mat[i][1] < 0 && mat[i][2] < 0) {
			ans = true;
			
		}
	}
	for (i = 0; i < 3; i++) {
		if (mat[0][i] < 0 && mat[1][i] < 0 && mat[2][i] < 0) {
			ans = true;
			
		}
	}
	if (mat[0][0] < 0 && mat[1][1] < 0 && mat[2][2] < 0) {
		ans = true;
		
	}
	if (mat[2][0] < 0 && mat[1][1] < 0 && mat[0][2] < 0) {
		ans = true;
		
	}
	if (ans)
	{
		cout << "Yes";
	}
	else
		cout << "No";
	return 0;
}

Measured memory_bytes: 256
#import <stdio.h>
#define M 1000000007
typedef long long INT;
INT fa(INT n, INT val){
    return (n==1)? (val%M) : fa(n-1,((n%M)*(val%M)%M));
}
INT fact(INT n){
    return fa(n,1);
}

int main(){
    INT n,m;
    scanf("%lld %lld",&n,&m);
    if (n==m) {
        printf("%lld",2*fact(n)*fact(n)%M);
    } else if (n-m==1||n-m==-1) {
        printf("%lld",fact(n)*fact(m)%M);
    } else {
        puts("0");
    }
}


Measured memory_bytes: 7120