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

int n ;
vector<vector<int> > d;

void Erase () {
    for (int i = 0; i < 5; i++) {
        for (int j = n - 1; j >= 0; j--) {
            if (d[j][i] == 0) {
                int k = j;
                bool flag = true;
                while (k >= 0 && d[k][i] == 0) {
                    k--;
                    if (k < 0) {
                        flag = false;
                        break;
                    }
                }
                if (flag) {
                    d[j][i] = d[k][i];
                    d[k][i] = 0;
                }
            }
        }
    }
}

int Check () {
    int ret = 0;
    for (int i = 0; i < n; i++) {
        for (int j = 0; j < 5; j++) {
            int count = 0;
            int num = d[i][j];
            int k = j;
            while (num != 0 && d[i][k] == num) {
                count++;
                k++;
            }

            if (count >= 3) {
                ret += count * num;
                while (k > j) {
                    k--;
                    d[i][k] = 0;
                }

                break;
            }
        }
    }

    Erase();

    return ret;
}

int main ()
{
    while (cin >> n, n) {
        d.clear();
        d.resize(n, vector<int>(5));
        for (auto &i : d)
            for (auto &j : i) cin >> j;

        int num = 1;
        int res = 0;
        while (num > 0) {
            //Erase();
            num = Check();
            res += num;
        }

        cout << res << endl;
    }

    return 0;
}

Measured memory_bytes: 1212
#include<iostream>
#include<string>
#include<cstdio>
#include<cstring>
#include<vector>
#include<cmath>
#include<algorithm>
#include<functional>
#include<iomanip>
#include<queue>
#include<deque>
#include<ciso646>
#include<random>
#include<map>
#include<set>
#include<complex>
#include<bitset>
#include<stack>
#include<unordered_map>
#include<utility>
#include<cassert>
using namespace std;

typedef long long ll;
typedef unsigned long long ul;
typedef unsigned int ui;
typedef long double ld;
const int inf=1e9+7;
const ll INF=1LL<<60 ;
const ll mod=1e9+7 ;
#define rep(i,n) for(int i=0;i<n;i++)
#define per(i,n) for(int i=n-1;i>=0;i--)
#define Rep(i,sta,n) for(int i=sta;i<n;i++)
#define rep1(i,n) for(int i=1;i<=n;i++)
#define per1(i,n) for(int i=n;i>=1;i--)
#define Rep1(i,sta,n) for(int i=sta;i<=n;i++)
typedef complex<ld> Point;
const ld eps = 1e-8;
const ld pi = acos(-1.0);
typedef pair<int, int> P;
typedef pair<ld, ld> LDP;
typedef pair<ll, ll> LP;
#define fr first
#define sc second
#define all(c) c.begin(),c.end()
#define pb push_back
#define debug(x)  cout << #x << " = " << (x) << endl;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
//#define int long long

void solve() {
	string s; cin >> s;
    int n = (int)s.size();
    string t = s;
    reverse(all(t));
    int i = 0, j = 0;
    int ans = 0;
    while(i < n - 1 - j) {
        if(s[i] == t[j]) {
            ++i;
            ++j;
            continue;
        } else {
            if(s[i] == 'x') {
                ++ans;
                ++i;
            } else if(t[j] == 'x') {
                ++ans;
                ++j;
            } else {
                cout << -1 << endl;
                return;
            }
        }
    }
    cout << ans << endl;
}

signed main() {
	ios::sync_with_stdio(false);
	cin.tie(0);
	//cout << fixed << setprecision(10);
	//init();
	solve();
	//cout << "finish" << endl;
    return 0;
}

Measured memory_bytes: 512
#include<bits/stdc++.h>
using namespace std;
#define rep(i,n) for(int i=0;i<n;i++)
int main(){
    int n,tmp,flag=1;
    cin >> n;
    rep(i,n){
        cin >> tmp;
        if(tmp%2==0&&((tmp%3)*(tmp%5)!=0)){
            flag=0;
            break;
        }
    }
    cout << ((flag)?"APPROVED":"DENIED") << endl;
}


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

int main(){
    int N;
    cin >> N;
    int a[N];
    for ( int i = 0; i < N; ++i ){
        cin >> a[i];
    }
    int now = 1;
    int count = 0;
    for ( int i = 0; i < N; ++i){
        if ( a[i] == now ){
            now += 1;
            count += 1;
        }
    }
    if ( count == 0 ){
        cout << -1 << endl;
    } else {
        cout << N - count << endl;
    }
    return 0;
}


Measured memory_bytes: 1024
#include <bits/stdc++.h>
#if __has_include(<atcoder/all>)
    #include <atcoder/all>
#endif
using namespace std;
using namespace atcoder;
namespace defines{
    typedef long long ll;
    typedef pair<ll,ll> P;
    #define FOR(i,a,b) for(ll i = a ; i < b ; i++) // for i in range(a,b)
    #define REP(i,n) for(ll i = 0 ; i < n ; i++) // for i in range(b)
    #define FORD(i,a,b) for(ll i = a ; i > b ; i--) // for i in range(a,b,-1)
    #define ALL(x) x.begin(),x.end()
    template<class T> vector<T> make_vec(size_t a){return vector<T>(a);}
    template<class T, class... Ts> auto make_vec(size_t a, Ts... ts){ return vector<decltype(make_vec<T>(ts...))>(a, make_vec<T>(ts...));}

    /* for debug print */
    #define DEBUG(x) cerr << #x << ": " << x << '\n'
    #define DEBUGP(x) cerr << #x << ": (" << x.first << ", " << x.second << ")" << '\n' 
    #define DEBUGL(xl) dbgl_f(#xl,xl)
    #define DEBUGLP(xl) dbglp_f(#xl,xl)
    #define DEBUGLL(xll) dbgll_f(#xll,xll)
    #define DEBUGM(xl) dbgm_f(#xl,xl)
    template<class T> void dbgl_f(string name, vector<T> xl){cerr<<name<<": "; for(T x: xl) cerr<<x<<" "; cerr << '\n';}
    template<class T, class U> void dbgm_f(string name, map<T,U> xl){cerr<<name<<": ";for(auto x: xl)cerr<<"("<<x.first<<": "<<x.second<<") ";cerr<<'\n';}
    template<class T> void dbglp_f(string name, vector<T> xl){cerr<<name<<": ";for(T x: xl)cerr<<"("<<x.first<<", "<< x.second<<") ";cerr<<'\n';}
    template<class T> void dbgll_f(string name, vector<vector<T>> xll){
        cerr<< name << ": " << '\n'; 
        for(vector<T> xl: xll){
            for(T x : xl) cerr << x << " ";
            cerr << '\n';
        }
    }
}
using namespace defines;

const int IINF = 1'001'001'001;
const ll INF = 1'001'001'001'001'001'001ll;
const int MOD = 1'000'000'007;

using mint = modint998244353;
vector<mint> keta_to_mint10(200001);
vector<mint> keta_to_mint(200001);

// lazy_segtree<S, op, e, F, mapping, composition, id> seg(int n);

struct S{
    mint v;
    int keta;
    S() : v(1), keta(1) {}
    S(mint v, int keta) : v(v), keta(keta) {}
};

S op(S a, S b){
    return S{a.v*keta_to_mint10[b.keta] + b.v, a.keta+b.keta};
}

S e(){ return S{0,0}; }

using F = int;
const F ID = 0;

S mapping(F f, S x){
    if( f == ID ) {
        return x;
    } else {
        return S{keta_to_mint[x.keta]*f, x.keta};
    }
}

F composition(F f, F g){
    if( f == ID ) return g;
    else return f;
}

F id(){return ID;}

void solve(){
    int n,q; cin >> n >> q;
    keta_to_mint10[0] = 1;
    FOR(i,1,200001){
        keta_to_mint10[i] = keta_to_mint10[i-1]*10;
        keta_to_mint[i] = (keta_to_mint10[i]-1)/9;
    }
    // DEBUG(keta_to_mint10[2].val());
    // DEBUG(keta_to_mint[2].val());

    vector<S> vals(n); 
    lazy_segtree<S, op, e, F, mapping, composition, id> seg(vals);
    // cout << seg.all_prod().v.val() << endl;
    REP(i,q){
        int l,r,d; cin >> l >> r >> d;
        seg.apply(l-1,r,d);
        cout << seg.all_prod().v.val() << endl;
    }
}

int main(){
    ios::sync_with_stdio(false);
    cin.tie(nullptr);
    solve();
}

Measured memory_bytes: 11388
#include<cstdio>
#include<vector>
#include<queue>
#include<set>
#include<map>
#include<iostream>
using namespace std;

#define mp make_pair

int main(){
	int N,C[510],S[510],F[510];
	cin>>N;
	for(int i=0;i<N-1;i++){
		cin>>C[i]>>S[i]>>F[i];
	}
	int ans;
	for(int s=0;s<N-1;s++){
		ans=0;
		for(int i=s;i<N-1;i++){
			for(int j=0;;j++)
				if(ans<=S[i]+j*F[i]){
					ans=max(ans+C[i],S[i]+j*F[i]+C[i]);
					break;
				}
		}
		cout<<ans<<endl;
	}
	cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 256
H,W = map(int,input().split())
dp = [list(input())for i in range(H)]
mod = 10**9+7
'''
dp = [[0]*(W) for i in range(H)]

dp[0][0] = 1
dp[1][0] = 1 if maze[1][0] != '#' else float('inf')
dp[0][1] = 1 if maze[1][0] != '#' else float('inf')

for i in range(H):
    for j in range(W):
        if 0 <= i+1 < H and 0 <= j+1 < W and maze[i+1][j] != '#':
            dp[i+1][j+1] += dp[i+1][j] % mod
        if 0 <= j+1 < W and 0 <= i+1 < H and maze[i][j+1] != '#':
            dp[i+1][j+1] += dp[i][j+1] % mod
print(dp[H-1][W-1] % mod) if dp[H-1][W-1] != float('inf') else 0
'''
dp[0][0] = 1
'''
dp[0][1] = 1 if dp[0][1] != '#' else '#'
dp[1][0] = 1 if dp[1][0] != '#' else '#'
'''
for i in range(H):
    for j in range(W):
        if dp[i][j] != '#' and j > 0 and isinstance(dp[i][j-1], int):
            if isinstance(dp[i][j], int):
                dp[i][j] += dp[i][j-1] % mod
            else:
                dp[i][j] = dp[i][j-1] % mod
        if dp[i][j] != '#' and i > 0 and isinstance(dp[i-1][j], int):
            if isinstance(dp[i][j],int):
                dp[i][j] += dp[i-1][j] % mod
            else:
                dp[i][j] = dp[i-1][j] % mod
'''
print(dp)
'''
print(dp[H-1][W-1] % mod) if dp[H-1][W-1] != '.' else print(0)

        


Measured memory_bytes: 43548
#r, d, x = map(int,input().split())
#n = int(input())
#h = list(map(int,input().split()))
ls = [int(input()) for i in range(5)]
#s = input()
one = [(i-1)%100 %10 for i in ls]
one.index(min(one))
ten = [ls[i] + (10 - one[i] - 1) if i != one.index(min(one)) else ls[i] for i in range(len(ls))]
print(sum(ten))


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

long long n;
vector<long long> b, a;

long long solve();

int main() {
  cin >> n;
  b.resize(n);
  for(int i = 0; i < n - 1; ++i) cin >> b[i];

  cout << solve() << endl;
  return 0;
}

long long solve() {
  long long ans = 0;
  ans = b[0] + b[n - 2];
  for(int i = 1; i < n - 1; ++i) ans += min(b[i], b[i - 1]);
  return ans;
}

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

int main()
{
  int N;
  cin >> N;
  
  vector<int> d(N);
  for(int i = 0; i < N; ++i)
  {
    cin >> d.at(i);
  }
  
  sort(d.rbegin(), d.rend());
  
  int ans = 1;
  for(int i = 1; i < N; ++i)
  {
    if(d.at(i) < d.at(i - 1))
    {
      ++ans;
    }
  }
  
  cout << ans << endl;
  return 0;
}    

Measured memory_bytes: 256
def rle(s):
    tmp, count = s[0], 1
    ans = []
    for i in range(1,len(s)):
        if tmp == s[i]:
            count += 1
        else:
            ans.append((tmp,count))
            tmp = s[i]
            count = 1
    ans.append((tmp,count))
    return ans


S = input()
R = rle(S)
A = [0]*len(S)
key = -1
for (c, count) in R:
    plus = (count-1)//2+1
    if c == 'R':
        key += count
        A[key] += plus
        A[key+1] += count-plus
        
    else:
        A[key+1] += plus
        A[key] += count-plus
        key += count

print(*A)

Measured memory_bytes: 57376
#include <algorithm>
#include <bitset>
#include <cmath>
#include <cstdio>
#include <cstdlib>
#include <ctime>
#include <deque>
#include <functional>
#include <iomanip>
#include <iostream>
#include <list>
#include <map>
#include <numeric>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <utility>
#include <vector>
#include <tuple>

#define DEBUG(x) cout<<#x<<": "<<x<<endl
#define co(x) cout << (x) << "\n"
#define ll long long
#define pb push_back
#define Never
#define To

using namespace std;

int main(){

	cin.tie(0);
	ios::sync_with_stdio(false);

	int N;
	ll X;

	cin >> N >> X;

	ll ok = 0;
	ll ng = 1;
	ll pt = 1;
	for(int i = 1; i <= N; i++){
		ng = ng * 2 + 3;
		pt = pt * 2 + 1;
	}

	ll ans = 0;
	while(ng - ok > 0){

		ll mid = (ng + ok) / 2 + 1;
		pt = (pt-1)/2 + 1;

		if(mid <= X) {
			ok = mid;
			ans += pt;
			//if(ok == X) ans++;
			ng--;
		} else {
			ng = mid -1;
			ok++;
		}

	}
	cout << ans << endl;

	Never To return 0;
}


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

#define rep(i,s,n) for(ll i = (s); i < (n); i++)
#define rep0(i,n) rep(i,0,n)
#define rep1(i,n) rep(i,1,n+1)
#define repR(i,s,n) for(ll i = (n-1); i >= (s); i--)
#define repR0(i,n) repR(i,0,n)
#define repR1(i,n) repR(i,1,n+1)

#define BR "\n"
#define SP " "
#define SHOW(x) for(int i = 0; i < x.size(); i++) { cout << x[i] << SP; } cout << BR;
#define SHOW2(x) for(int j = 0; j < x.size(); j++) { SHOW(x[j]); } cout << BR;
#define fcout cout << fixed << setprecision(18)

int main() {
  int H, W, K;
  cin >> H >> W >> K;

  vector<vector<ll>> cells(H, vector<ll>(W, 0));
  vector<vector<ll>> ans(H, vector<ll>(W, 0));
  vector<ll> C(H, 0);

  ll c = 0;
  rep0(i, H) {
    string s;
    cin >> s;
    rep0(j, W) {
      if (s[j] == '#') {
        c++;
        cells[i][j] = c;
      }
    }
    C[i] = c;
  }

  ll sc = 0, sh = 0;
  rep0(i, H) {
    if (sc < C[i]) {
      rep(j, 0, W - 1) {
        if (cells[i][j] > 0 && cells[i][j + 1] == 0) {
          cells[i][j + 1] = cells[i][j];
        }
      }
      repR(j, 1, W) {
        if (cells[i][j] > 0 && cells[i][j - 1] == 0) {
          cells[i][j - 1] = cells[i][j];
        }
      }
      repR(k, sh, i) {
        rep0(j, W) cells[k][j] = cells[k + 1][j];
      }
    }
    sc = C[i];
    sh = i + 1;
  }

  ll start0 = -1;
  rep0(i, H) {
    if (cells[i][0] == 0 && start0 == -1) {
      start0 = i;
    }
    if (cells[i][0] > 0 && start0 >= 0) {
      rep(k, start0, i) {
        rep0(j, W) {
          cells[k][j] = cells[i][j];
        }
      }
      start0 = -1;
    }
  }

  repR0(i, H) {
    if (cells[i][0] > 0) {
      rep(k, i + 1, H) {
        rep0(j, W) {
          cells[k][j] = cells[i][j];
        }
      }
      break;
    }
  }


  rep0(i, H) {
    cout << cells[i][0];
    rep(j, 1, W) {
      cout << SP << cells[i][j];
    }
    cout << BR;
  }

  return 0;
}

Measured memory_bytes: 2176
def main():
    N = int(input())
    A = [int(x) for x in input().split()]
    from collections import defaultdict
    count = defaultdict(int)
    ans = 0
    for i, a in enumerate(A):
        if i - a in count:
            ans += count[i-a]
        count[i+a] += 1
    print(ans)


if __name__ == '__main__':
    main()


Measured memory_bytes: 40752
#include <bits/stdc++.h>
const int INF=1e9;
const int MOD=1e9+7;
//const int MOD=998244353;
const long long LINF=1e18;
using namespace std;
#define int long long
#define fin {cout<<"First"<<endl;return 0;}
//template

//main
signed main(){
  int N;cin>>N;
  std::vector<int> edge[N];
  for(int i=0;i<N-1;i++){
    int a,b;cin>>a>>b;a--;b--;
    edge[a].push_back(b);
    edge[b].push_back(a);
  }
  std::vector<int> v(N);
  for(int i=0;i<N;i++)v[i]=edge[i].size();
  queue<int> que;
  for(int i=0;i<N;i++)if(v[i]==1)que.push(edge[i][0]);
  int turn=0;
  std::vector<int> used(N,0);
  while(que.size()){
    int p=que.front();que.pop();
    turn++;
    if(used[p])continue;used[p]++;
    //cout<<p<<endl;
    for(int q:edge[p]){
      v[q]--;
      if(v[q]==0)turn--;
      if(v[q]==1){
        for(int i:edge[q])if(used[i]==0)que.push(i);
      }
    }
    if(turn<0)fin;
  }
  cout<<"Second"<<endl;
}


Measured memory_bytes: 8320
import Data.List

toInt :: (String -> Int)
toInt x = read x ::Int

main :: IO ()
main = do
    n <- readLn
    di <- getLine
    let
        d = (map $ toInt) $ words di
        sd = sort d

    print $ (sd !! (n `div` 2)) - sd !! (n `div` 2 - 1)


Measured memory_bytes: 34428
#include <iostream>
#include <unordered_map>

using namespace std;

int abs(int x) {
    return x > 0 ? x : -x;
}

int main() {
    int X, N;
    cin >> X >> N;

    unordered_map<int, bool> m;

    for (int i = 0; i < N; ++i) {
        int pi;
        cin >> pi;
        m[pi] = true;
    }

    int d = 0;

    while (true) {
        if (!m[X - d]) {
            cout << X - d << endl;
            break;
        }

        if (!m[X + d]) {
            cout << X + d << endl;
            break;
        }

        d++;
    }

    return 0;
}

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


int main() {
  int n, m;
  cin >> n >> m;
  vector<int> cnt(m);
  rep(i,n){
    int k;
    cin >> k;
    rep(j,k){
      int a;
      cin >> a;
      a--;
      cnt[a]++;
    }
  }
  int ans = 0;
  rep(i,m){
    if(cnt[i] == n)ans++;
  }
  cout << ans << endl;
  return 0;
}

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


int main(){
  string N;
  cin>>N;
  int keta = N.size();
  
  int dp[keta+1][2];
  dp[0][0] = 0;
  dp[0][1] = 1;

  for(int i=1; i<=keta; i++){
    N[i-1] -= '0';
    //charからintに変換

    dp[i][0] = min(
      dp[i-1][0] + N[i-1],
      dp[i-1][1] + (10 - N[i-1])
    );

    dp[i][1] = min(
      dp[i-1][0] + (N[i-1]+1),
      dp[i-1][1] + (10 - (N[i-1]+1))
    );
  }

  cout<<dp[keta][0]<<endl;
  
}

Measured memory_bytes: 9220
#include <stdio.h>
#include <stdlib.h>
#include <math.h>

int main(void)
{
  int k,a,b,i;
  scanf("%d",&k);
  scanf("%d %d",&a,&b);

  for(i=a;i<=b;i++)
  {
    if(i%k==0)
    {
      printf("OK\n");
      break;
    }
    if(i==b) printf("NG\n");
  }

  return 0;
}

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

using namespace std;

#define MAX_N 100000

int n;
int cnt[MAX_N];

void cntAC(string &s)
{
    int slen = s.length(), ans = 0;
    for (int i = 0; i < slen - 1; i++)
    {
        if (s[i] == 'A' && s[i + 1] == 'C')
        {
            cnt[i + 1] = cnt[i] + 1;
        }
        else
            cnt[i + 1] = cnt[i];
    }
}

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

    string s;
    cin >> s;
    cntAC(s);

    for (int i = 0; i < q; i++)
    {
        int l, r;
        scanf("%d %d", &l, &r);
        int ans = cnt[r - 1] - cnt[l - 1];
        printf("%d\n", ans);
    }

    return 0;
}


Measured memory_bytes: 1408
#include<bits/stdc++.h>
#define LEN 100005
using namespace std;

typedef struct{
    char name[100];
    int time;
}P;

int head, tail;
P Q[LEN];

/*
void init(){
    head = tail = 0;
}

int isfull(){
    return head == (tail+1)%LEN;
}

int isempty(){
    return head == tail;
}
*/

void enqueue(P x){
    /*if(isfull){
        printf("Error : Over flow.\n");
        exit(0);
    }*/
    Q[tail] = x;
    tail = (tail+1)%LEN;
}

P dequeue(){
    P x;
    /*if(isempty){
        printf("Error : Under flow\n");
        exit(0);
    }*/
    x = Q[head];
    head = (head+1)%LEN;
    return x;
}

int main(){
    int n, q, c, elaps=0;
    cin >> n >> q;
    for(int i=1; i<=n; i++) scanf("%s %d", Q[i].name, &Q[i].time);

    head = 1; tail=n+1;
    P a;
    while(head!=tail){
        a = dequeue();
        /*printf("%s %d\n", a.name, elaps);*/
        if(a.time>q){
            elaps += q;
            a.time -= q;
            enqueue(a);
        }
        else{
            elaps += a.time;
            printf("%s %d\n", a.name, elaps);
        }
    }
    return 0;
}


Measured memory_bytes: 13360
#include <iostream>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <istream>
#include <sstream>
#include <cctype>
#define rep(i,N) for(int i=0;i<(int)N;++i)
typedef long long ll;
using namespace std;
int main()
{
	string A,B,C,ANS;
	cin>>A>>B>>C;
	reverse(A.begin(),A.end());
	reverse(B.begin(),B.end());
	reverse(C.begin(),C.end());
	char a;
	a=*(A.end()-1);
	A.pop_back();
	for(int i=0;;i++){
		//cout<<A<<":"<<B<<":"<<C<<":"<<endl;
		if(A.size()==0&&a=='a'){
			ANS="A";
			break;
		}
		if(B.size()==0&&a=='b'){
			ANS="B";
			break;
		}
		if(C.size()==0&&a=='c'){
			ANS="C";
			break;
		}
		if(a=='a'&&A.size()!=0){
			a=*(A.end()-1);
			A.pop_back();
		}
		else if(a=='b'&&B.size()!=0){
			a=*(B.end()-1);
			B.pop_back();
		}
		else if(a=='c'&&C.size()!=0){
			a=*(C.end()-1);
			C.pop_back();
		}
	}
	cout<<ANS<<endl;
}

Measured memory_bytes: 888
#include<cstdio>
#include<cstring>
#include<vector>
#include<queue>
#include<stack>
#include<algorithm>
#include<cmath>
#include<climits>
#include<string>
#include<set>
#include<numeric>
#include<map>
#include<iostream>
using namespace std;
#define rep(i,n) for(int i = 0;i<((int)(n));i++)
#define reg(i,a,b) for(int i = ((int)(a));i<=((int)(b));i++)
#define irep(i,n) for(int i = ((int)(n)-1);i>=0;i--)
#define ireg(i,a,b) for(int i = ((int)(b));i>=((int)(a));i--)
typedef long long ll;
typedef pair<ll, ll> mp;
ll MOD = 1e9+7;
//LLONG_MIN

int main(void){
	int dx[9]={-1,0,1,-1,0,1,-1,0,1};
	int dy[9]={-1,-1,-1,0,0,0,1,1,1};
	ll H,W,N,a,b,d[10]={},sum=0;
	map<ll,int> M;
	scanf("%lld%lld%lld",&H,&W,&N);
	rep(i,N){
		scanf("%lld%lld",&a,&b);
		rep(j,9){
			int x = b+dx[j];
			int y = a+dy[j];
			if(y>1 && y<H && x>1 && x<W)M[y*(W+1)+x]++;
		}
	}
	for(auto itr = M.begin(); itr != M.end(); ++itr) {
		// printf("(%lld,%lld): %lld\n",itr->first/(W+1),itr->first%(W+1),itr->second);
		d[itr->second]++;
		sum++;
    }
    printf("%lld\n",(W-2)*(H-2)-sum);
    reg(i,1,9)printf("%d\n",d[i]);
	return 0;
}

Measured memory_bytes: 56448
#include <iostream>
#include <algorithm>
#include <bitset>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <utility>
#include <vector>
#include <complex>
#include <deque>
#include <valarray>
#include <unordered_map>
#include <unordered_set>
#include <array>
#include <cassert>
#include <cmath>
#include <functional>
#include <iomanip>
#include <chrono>
#include <random>
#include <numeric>
using namespace std;
using ll = long long;
using ld = long double;
using str = string;
typedef vector<string> vs;
typedef vector<bool> vb;
typedef vector<char> vc;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef vector<vs> vvs;
typedef vector<vc> vvc;
typedef vector<vb> vvb;
using P = pair<ll,ll>;
#define REP(i, n) for (ll i = 0; i < (int)(n); i++)
#define RREP(i, n) for (ll i = (int)(n)-1; i > -1 ; i--)
#define IN(T, x) T x;cin >> x;
#define AIN(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}
#define A2IN(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}
#define ALL(a) (a).begin(),(a).end()
#define SORT(a) sort(ALL(a))
#define RSORT(a) SORT(a);reverse(ALL(a))
#define pb push_back
#define mp make_pair
#define PF first
#define PS second
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 A, size_t N, typename T>void Fill(A (&array)[N], const T &val){fill( (T*)array, (T*)(array+N), val );}
#define OUT(x) cout << x << endl;
#define OUTD(x) cout << fixed << x << endl;
#define BOUT(b) if(b){OUT("Yes");}else{OUT("No");}
const ll MOD = 1000000007;
const ll INF = 10e9;
#define PI 3.14159265369;
ll dx[4] = {1,-1,0,0};
ll dy[4] = {0,0,1,-1};
ll ddx[8] = {1,1,1,-1,-1,-1,0,0};
ll ddy[8] = {0,1,-1,0,1,-1,1,-1};

int main() {
  cin.tie(0);
  ios::sync_with_stdio(false);
  
  IN(ll,N);
  AIN(ll,A,N);
  SORT(A);
  vector<P> ans(0);
  
  if(A.at(0) >= 0){
    for(ll i = 1;i<N-1;i++){
      P ans0;
      ans0.first = A.at(0);
      ans0.second = A.at(i);
      ans.push_back(ans0);
      A.at(0) -= A.at(i);
    }
    OUT(A.at(N-1) - A.at(0));
    ans.push_back({A.at(N-1),A.at(0)});
  }else if(A.at(N-1) <= 0){
    for(ll i = 0;i<N-1;i++){
      P ans3;
      ans3.first = A.at(N-1);
      ans3.second = A.at(i);
      ans.push_back(ans3);
      A.at(N-1) -= A.at(i);
    }
    OUT(A.at(N-1));
  }else{
    auto num = lower_bound(ALL(A),0) - A.begin();
    for(ll i = num; i < N-1; i++){
        P ans1;
        ans1.first = A.at(0);
        ans1.second = A.at(i);
        ans.push_back(ans1);
        A.at(0) -= A.at(i); 
    }
    for(ll i = 0; i < num; i++){
        P ans2;
        ans2.first = A.at(N-1);
        ans2.second = A.at(i);
        ans.push_back(ans2);
        A.at(N-1) -= A.at(i);
    }
    OUT(A.at(N-1));
  }
  for(ll i = 0; i < ans.size(); i++){
      cout << ans.at(i).first << " " << ans.at(i).second << endl;
  }
}

Measured memory_bytes: 4336
#include<bits/stdc++.h>
#define rep(i,N) for(ll (i)=0;(i)<(N);(i)++)
#define chmax(x,y) x=max(x,y)
#define chmin(x,y) x=min(x,y)
using namespace std;
typedef long long ll;
typedef pair<int,int> P;
const int mod = 1000000007;

int main() {
  int n;
  cin >> n;
  string s;
  cin >> s;
  vector<int> a(n);
  vector<ll> cnt(3);
  rep(i, n) {
    if(s[i] == 'R') cnt[0]++;
    if(s[i] == 'G') cnt[1]++;
    if(s[i] == 'B') cnt[2]++;
  }

  ll ans = cnt[0] * cnt[1] * cnt[2];
  
  rep(i, n) {
    rep(j, n) {
      if(i >= j) continue;
      int d = j - i;
      int k = j + d;
      if(k >= n) continue;
      if(s[i] == s[j]) continue;
      if(s[j] == s[k]) continue;
      if(s[k] == s[i]) continue;
      ans--;
    }
  }
  cout << ans << endl;
}

Measured memory_bytes: 3656
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
#define max2(a,b) (a>b?a:b)
int f(int r[][99],int m[][99],int x,int y,int d,int sum){
  int g,max=0;
  if(y==d)
    return sum;
  else if(r[x][y]==-1)
    return 0;
  else if(m[x][y]>=sum)
    return 0;
  else{
    m[x][y]=sum;
    if(y<d/2){
      g=f(r,m,x,y+1,d,sum+r[x][y]);
      max=max2(max,g);
      g=f(r,m,x+1,y+1,d,sum+r[x][y]);
      max=max2(max,g);
    }else{
      g=f(r,m,x-1,y+1,d,sum+r[x][y]);
      max=max2(max,g);
      g=f(r,m,x,y+1,d,sum+r[x][y]);
      max=max2(max,g);
    }
    return max;
  }
}
int main(){
  int i,j;
  int r[51][99],m[51][99];
  char s[256],*t;
  memset(r,-1,sizeof(r));
  memset(m,-1,sizeof(m));
  for(i=0;fgets(s,256,stdin)!=0;i++){
    j=0+1;
    r[j][i]=atoi(strtok(s,","));
    for(j++;(t=strtok(NULL,","))!=NULL;j++)
      r[j][i]=atoi(t);
  }
  printf("%d\n",f(r,m,0+1,0,i,0));
  return 0;
}

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

#include <ext/pb_ds/assoc_container.hpp> 
#include <ext/pb_ds/tree_policy.hpp> 
using namespace __gnu_pbds; 

mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());

int getRand(int l, int r)
{
    uniform_int_distribution<int> uid(l, r);
    return uid(rng);
}
  
#define int long long 
#define pb push_back
#define S second
#define F first
#define f(i,n) for(int i=0;i<n;i++)
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)
#define vi vector<int>
#define pii pair<int,int>
#define ordered_set tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update> 
#define precise(x) fixed << setprecision(x) 

const int MOD = 1e9+7;

int mod_pow(int a,int b,int M = MOD)
{
    int res = 1;
    
    while(b)
    {
        if(b&1) res=(res*a)%M;
        a=(a*a)%M;
        b>>=1;
    }
    
    return res;
}


void solve()
{
   int n;
    cin >> n;
    
    pii a[n];
    f(i,n) cin >> a[i].F >> a[i].S;
    
    for(int i=2;i<n;i++)
    {
        if(a[i].F == a[i].S && a[i-1].F == a[i-1].S && a[i-2].F == a[i-2].S)
        {
            cout <<"Yes";
            return;
        }
    }
    
    cout <<"No";
    
}

signed main()
{
    fast;
    
    int t = 1;
    
//    cin >> t;
    
    while(t--)
        
    solve();
}

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

int main() {
  int n;
  int ac = 0, wa = 0, tle = 0, re = 0;
  cin >> n;

  rep(i, n) {
    string s;
    cin >> s;

    if (s == "AC") ac++;
    else if (s == "WA") wa++;
    else if (s == "TLE") tle++;
    else if (s == "RE") re++;
  }

  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);

  return 0;
}


Measured memory_bytes: 3728
"use strict"

const main = (input) => {
  const lines = input.split("\n")
  if (lines[0].length === 1) {
    console.log(lines[0])
    return
  }
  const len9 = lines[0].length - 1
  const all9 = ((line) => {
    for (let i=1; i<line.length; i++) {
      if (line[i] != '9') {
        return false
      }
    }
    return true
  })(lines[0])
  const head = parseInt(lines[0][0]) - 1
  if (all9) {
    console.log(head + 1 + len9 * 9);
    return
  }
  console.log(head + len9 * 9)
}

main (require('fs').readFileSync('/dev/stdin', 'utf8'))

Measured memory_bytes: 7372
#include<bits/stdc++.h>
#include<ext/pb_ds/assoc_container.hpp>
using namespace __gnu_pbds;
using namespace std;
#define ll long long
//increase stack size
#pragma comment(linker, "/STACK:16777216")

ll mxm() {return LLONG_MIN;}
template<typename... Args>
ll mxm(ll a, Args... args) { return max(a,mxm(args...)); }

ll mnm() {return LLONG_MAX;}
template<typename... Args>
ll mnm(ll a, Args... args) { return min(a,mnm(args...)); }

template<class T> ostream& operator<<(ostream& os,vector<T> V){
	os<<"[ ";for(auto v:V)os<<v<<" ";return os<<"]";
}
template<class L,class R> ostream& operator<<(ostream& os,pair<L,R> P){
	return os<<"("<<P.first<<","<<P.second<<")";
}

#define TRACE
#ifdef TRACE
#define trace(...) __f(#__VA_ARGS__,__VA_ARGS__)
template<typename Arg1>
void __f(const char* name,Arg1&& arg1){
	cout<<name<<" : "<<arg1<<endl;
}
template <typename Arg1,typename... Args>
void __f(const char* names,Arg1&& arg1,Args&&... args){
	const char* comma=strchr(names+1,',');cout.write(names,comma-names)<<" : "<<arg1<<" | ";__f(comma+1,args...);
}
#else
#define trace(...) 1
#endif

#define ld long double
#define pll pair<ll,ll>
#define ii pair<int,int>
#define vll vector<ll>
#define vii vector<ii>
#define vi vector<int>
#define vpll vector<pll>
#define vld vector<ld>
#define vvld vector<vld>
#define vvi vector<vi>
#define vvll vector<vll>
#define vvpll vector<vpll>
#define vvii vector<vii>
#define I insert
#define F first
#define S second
#define pb push_back
#define endl "\n"
#define all(x)	x.begin(),x.end()

const int mod=1e9+7;
// 128 bit: __int128
inline int add(int a,int b){a+=b;if(a>=mod)a-=mod;return a;}
inline int sub(int a,int b){a-=b;if(a<0)a+=mod;return a;}
inline int mul(int a,int b){return (a*1ll*b)%mod;}
inline int power(int a,int b){int rt=1;while(b>0){if(b&1)rt=mul(rt,a);a=mul(a,a);b>>=1;}return rt;}
inline int inv(int a){return power(a,mod-2);}

struct compare{
	bool operator() (const int &a,const int &b) const{
		return a>b;
	}
};

int main()
{
	ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);cout<<setprecision(25);
	ll x, y, a, b, c;
	cin >> x >> y >> a >> b >> c;
	vll v1(a), v2(b), v3(c);
	for(int i = 0; i < a; i++)
		cin >> v1[i];
	for(int i = 0; i < b; i++)
		cin >> v2[i];
	for(int i = 0; i < c; i++)
		cin >> v3[i];
	sort(all(v1));sort(all(v2));sort(all(v3));
	reverse(all(v1));reverse(all(v2));reverse(all(v3));
	ll ans = 0;
	multiset<ll> m1, m2;
	for(int i = 0; i < x; i++)
		ans += v1[i], m1.I(v1[i]);
	for(int i = 0; i < y; i++)
		ans += v2[i], m1.I(v2[i]);
	for(int i = 0; i < c; i++){
		if(m1.empty())
			break;
		if(*m1.begin() >= v3[i])
			break;
		ans -= *m1.begin();
		m1.erase(m1.begin());
		ans += v3[i];
	}
	cout << ans << endl;
}

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

using namespace std;

typedef long long ll;

double getTime() {
  return clock() / (double) CLOCKS_PER_SEC;
}

void read() {};

template<typename T, typename... Args>
void read(T& a, Args&... args) {
  cin >> a;
  read(args...);
}

void print() {};

template <typename T, typename... Args>
void print(T a, Args... args) {
  cout << a << " \n"[sizeof...(args) == 0];
  print(args...);
}

int main() {
  int n; read(n);
  for(int i = 0; i < n; i++) {
    int x; read(x);
    if(x % 2 == 0) {
      if(!(x % 3 == 0 or x % 5 == 0)) {
        print("DENIED");
        return 0;
      }
    }
  }
  print("APPROVED");
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
int main() {
  string A,B,C; cin>>A>>B>>C;
  char t='a';
  while(1){
    if(t=='a'){
      if(A.empty()){cout<<"A";return 0;}
      t=A[0];
      A.erase(A.begin());
    }
    else if(t=='b'){
      if(B.empty()){cout<<"B";return 0;}
      t=B[0];
      B.erase(B.begin());
    }
    else{
      if(C.empty()){cout<<"C";return 0;}
      t=C[0];
      C.erase(C.begin());
    }
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>

using namespace std;

using lint = long long;
using ldouble = long double;

const int INF = 1 << 25;

bool solve() {
    int N, M, s, g1, g2;
    cin >> N >> M >> s >> g1 >> g2;
    if (N == 0) return false;

    --s, --g1, --g2;

    vector<vector<int>> dist(N, vector<int>(N, INF));
    for (int v = 0; v < N; ++v) dist[v][v] = 0;
    for (int i = 0; i < M; ++i) {
        int u, v;
        cin >> u >> v;
        cin >> dist[--u][--v];
    }

    for (int j = 0; j < N; ++j) {
        for (int i = 0; i < N; ++i) {
            for (int k = 0; k < N; ++k) {
                dist[i][k] = min(dist[i][k], dist[i][j] + dist[j][k]);
            }
        }
    }

    int ans = INF;
    for (int v = 0; v < N; ++v) {
        ans = min(ans, dist[s][v] + dist[v][g1] + dist[v][g2]);
    }
    cout << ans << endl;
    return true;
}

int main() {
    while (solve()) {}
    return 0;
}



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

int main() {
	int n, m; cin >> n >> m;
	vector<int> a(m), b(m); rep(i, 0, m) cin >> a[i] >> b[i];

	map<int, int> mp;
	rep(i, 0, m) {
		mp[a[i]]++;
		mp[b[i]]++;
	}

	rep(i, 1, n + 1) cout << mp[i] << endl;

	return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#ifdef HIRO
#define d(f_, ...) printf((f_), ##__VA_ARGS__)
#else
#define d(f_, ...)
#endif

using namespace std;
typedef long long ll;
typedef long double ld;
typedef pair<int, int> pii;
typedef vector<int> vi;
typedef vector<long long> vll;
typedef queue<int> qi;
typedef queue< pair<int, int> > qp;
#define mp make_pair
#define pi 3.14159265358979323846
#define MAX max_element
#define MIN min_element
#define all(v) v.begin(), v.end()
#define gt(T) greater<T>()
#define sum(v) accumulate(v.begin(), v.end(), 0)
#define uni(v) do{ \
  sort(v.begin(), v.end()); \
  decltype(v)::iterator result = unique(v.begin(), v.end()); \
  v.erase(result, v.end()); \
}while(0)
#define fi(init, n) for(int i = init; i < n; ++i)
#define fj(init, n) for(int j = init; j < n; ++j)
#define fk(init, n) for(int k = init; k < n; ++k)
#define zero(x) memset(x, 0, sizeof(x))
#define negative(x) memset(x, ~0, sizeof(x))
const ll MOD = 1e9 + 7;
const int INF = 1e9;
const int di[] = { 0, 1, 0, -1 };
const int dj[] = { 1, 0, -1, 0 };

template<typename T>
T gcd(T a, T b) {
	return b ? gcd(b, a % b) : a;
}
template<typename T>
T lcm(T a, T b) {
	return a * b / gcd(a, b);
}
template<typename T>
int finder(vector<T> vec, T number) {
	auto itr = find(vec.begin(), vec.end(), number);
	size_t index = distance(vec.begin(), itr);
	if (index != vec.size()) return 1;
	else return 0;
}
ll frac(ll n){
	if (n == 0) return 1;
	return (n * frac(n - 1)) % MOD;
}

int main(int argc, char** argv) {
#ifdef HIRO
  string quiz(argv[1]);
  string id(argv[2]);
  string filename("input/" + quiz + "/" + id + ".txt");
  ifstream fin(filename);
  if (fin.peek() == ifstream::traits_type::eof()) {
    cout << "No input.";
    return 0;
  }
  ifstream cin(filename);
  std::cin.rdbuf(cin.rdbuf());
#endif
  ll ans = 0;
  // ll n;
  // cin >> n;
  ll n, m;
  cin >> n >> m;
  // ll n, m, k;
  // cin >> n >> m >> k;
  fi(0,2000){
    if(i*8/100 == n && i/10 == m) {
      cout << i << endl;
      return 0;
    }
  }
  cout << "-1\n";
  // cout << ans << endl;
  return 0;
}



Measured memory_bytes: 256
#include <cstdio>
#include <iostream>
#define NMAX 102

using namespace std;

int A[NMAX],B[9] = {},N,W,ans = 0;
void solve(){
	for (int i = 0; i < N; ++i)
	{
		W = A[i]/400;
		if(W <= 7){
			B[W]++;
		}else{
			B[8]++;
		}
	}
	for (int i = 0; i < 8; ++i)
	{
		if(B[i] > 0){
			ans++;
		}
	}
}

void answer(){
	if(!ans)
		cout << 1 << " ";
	else	
		cout << ans << " ";
	cout << ans+B[8] << "\n";
}

int main(){
	cin >> N;
	for (int i = 0; i < N; ++i)
	{
		cin >> A[i];
	}
	solve();
	answer();

	return 0;
}

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

public class Main {
	public static void main(String[] args)throws IOException{
		BufferedReader br = new BufferedReader(new InputStreamReader(System.in));
		String str = br.readLine();
		String[] s = str.split(" ");

		int a = Integer.parseInt(s[0]);
		int b = Integer.parseInt(s[1]);
		int c = Integer.parseInt(s[2]);

		if((0 <= a)&&(0 <= b)&&(0 <= c)){
			if((100 >= a)&&(100 >= b)&&(100 >= c)){
				if(a < b){
					if(b < c){
						System.out.println("Yes");
					}else{
						System.out.println("No");
					}
				}else{
					System.out.println("No");
				}
			}
		}
	}
}

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



int main(){
    long long n;
    cin>>n;
    long long a[88]={};
    a[0]=2;
    a[1]=1;
    for(int i=2;i<88;i++){
        a[i]=a[i-1]+a[i-2];
    }
    cout<<a[n]<<endl;
    return 0;
}


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

struct dat {
  int d;
  vector<int> c;
  vector<vector<int>> s;
};

int calc(const dat &a, const vector<int> &last, int day, int t) {
  int v = 0;
  v += a.s.at(day - 1).at(t);
  for (int i = 0; i < 26; i++) {
    if (i == t) continue;
    v -= a.c.at(i) * (day - last.at(i));
  }
  return v;
}

int main() {
  int d;
  cin >> d;
  vector<int> c(26);
  vector<vector<int>> s(d, vector<int>(26));
  for (int i = 0; i < 26; i++) {
    cin >> c.at(i);
  }
  for (int i = 0; i < d; i++) {
    for (int j = 0; j < 26; j++) {
      cin >> s.at(i).at(j);
    }
  }
  dat a = {d, c, s};
  
  int w = 200;
  vector<vector<int>> last(w, vector<int>(26)), ans(w);
  vector<int> score(w);
  for (int i = 0; i < d; i++) {
    vector<tuple<int, int, int>> idx;
    for (int j = 0; j < w; j++) {
      vector<int> best(w, -4e4), best_t(w, 25);
      for (int t = 0; t < 26; t++) {
        int v = calc(a, last.at(j), i + 1, t);
        if (v > best.at(w - 1)) {
          best.at(w - 1) = v;
          best_t.at(w - 1) = t;
        }
        for (int k = w - 1; k > 0; k--) {
          if (best.at(k - 1) < best.at(k)) {
            swap(best.at(k - 1), best.at(k));
            swap(best_t.at(k - 1), best_t.at(k));
          }
        }
      }
      for (int k = 0; k < w; k++) {
        idx.emplace_back(score.at(j) + best.at(k), j, best_t.at(k));
      }
    }
    sort(idx.rbegin(), idx.rend());
    vector<vector<int>> newlast(w, vector<int>(26)), newans(w);
    for (int j = 0; j < w; j++) {
      int k = get<1>(idx.at(j)), t = get<2>(idx.at(j));
      score.at(j) = get<0>(idx.at(j));
      newans.at(j) = ans.at(k);
      newlast.at(j) = last.at(k);
      newans.at(j).push_back(t);
      newlast.at(j).at(t) = i + 1;
    }
    ans = newans;
    last = newlast;
  }
  for (int i = 0; i < d; i++) {
    cout << ans.at(0).at(i) + 1 << endl;
  }
}


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

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

    int cnt = 0;
    for (int i = 0; i < s.size(); ++i)
    {
        if (s[i] == 'o')
        {
            ++cnt;
        }
    }

    string ans;
    if (((15 - s.size()) + cnt) >= 8)
    {
        ans = "YES";
    }
    else
    {
        ans = "NO";
    }
    
    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for(int i = 0; i < n; i++)
#define rep2(i, x, n) for(ll i = x; i <= n; i++)
#define rep3(i, x, n) for(int i = x; i >= n; i--)
#define elif else if
#define sp(x) fixed << setprecision(x)
#define pb push_back
#define eb emplace_back
#define all(x) x.begin(), x.end()
#define sz(x) (int)x.size()
using ll = long long;
using ld = long double;
using pii = pair<int, int>;
using pil = pair<int, ll>;
using pli = pair<ll, int>;
using pll = pair<ll, ll>;
const ll MOD = 1e9+7;
//const ll MOD = 998244353;
const int inf = (1<<30)-1;
const ll INF = (1LL<<60)-1;
const ld EPS = 1e-10;
template<typename T> bool chmax(T &x, const T &y) {return (x < y)? (x = y, true) : false;};
template<typename T> bool chmin(T &x, const T &y) {return (x > y)? (x = y, true) : false;};

int main(){
    ll N;
    cin >> N;
    ll ans = 0;
    rep2(i, 1, N){
        ll x = N/i;
        ans += (x+1)*i*x/2;
    }
    cout << ans << endl;
}

Measured memory_bytes: 3632
#include<bits/stdc++.h>
using namespace std;
typedef long long int ll;
typedef pair<ll,ll> pii;
#define fi first
#define se second
#define ios ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define mod 1000000007
int main()
{
	ios;
	ll k,x;
	cin>>k>>x;
	if(k*500>=x)
		cout<<"Yes"<<endl;
	else
		cout<<"No"<<endl;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define fs first
#define sc second
#define pb push_back
#define mp make_pair
#define eb emplace_back
#define ALL(A) A.begin(),A.end()
#define RALL(A) A.rbegin(),A.rend()
typedef long long LL;
typedef pair<LL,LL> P;
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }
template<typename T> T gcd(T a,T b){return b?gcd(b,a%b):a;}
const LL mod=1000000007;
const LL LINF=1LL<<62;
const int INF=1<<30;
int dx[]={1,0,-1,0,1,-1,1,-1};
int dy[]={0,1,0,-1,1,-1,-1,1};




int main(){
    LL n,d;cin >> n >> d;
    int a = 0;
    for (int i = 0; i < n; i++) {
        LL x,y;cin >> x >> y;
        if(x * x + y * y <= d * d) a++;
    }
    cout << a << endl;
    return 0;
}


Measured memory_bytes: 3628
#include<iostream>
#include<string>
using namespace std;
int main() {
    string s;
    getline(cin, s);
    for (int i = 0; i < s.length(); i++) {
        if (s[i] >= 'A' && s[i] <= 'z') {
            if (s[i] >= 'a' && s[i] <= 'z') s[i] = toupper(s[i]);
            else s[i] = tolower(s[i]);
        }
    }
    cout << s << endl;
    return 0;
}


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

#define REP(i,n) for(ll i=0;i<n;++i)
#define RREP(i,n) for(ll i=n-1;i>=0;--i)
#define FOR(i,m,n) for(ll i=m;i<n;++i)
#define RFOR(i,m,n) for(ll i=n-1;i>=m;--i)
#define ALL(v) (v).begin(),(v).end()
#define PB(a) push_back(a)
#define UNIQUE(v) v.erase(unique(ALL(v)),v.end());
#define DUMP(v) REP(i, (v).size()) { cout << v[i]; if (i != v.size() - 1)cout << " "; else cout << endl; }
#define INF 1000000001ll
#define MOD 1000000007ll
#define EPS 1e-9

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


using namespace std;
typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vi> vvi;
typedef vector<vl> vvl;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
ll max(ll a, int b) { return max(a, ll(b)); }
ll max(int a, ll b) { return max(ll(a), b); }
///(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)(テつエテ」ツδサテ渉嘉」ツδサ`)///
int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int n;
	cin >> n;
	REP(j,n) {
		int out = 0, score = 0;
		vi v(3, 0);
		while (out <3) {
			string s;
			cin >> s;
			if (s == "HIT") {
				RREP(i, 3) {
					if (v[i] == 1) {
						if (i == 2)score++;
						else v[i + 1]++;
						v[i]--;

					}
				}
				v[0]++;
			}
			else if (s[0] == 'O') {
				out++;
			}
			else {
				REP(i, 3) {
					if (v[i] == 1) {
						score++;
						v[i] = 0;
					}
				}
				score++;
			}
		}
		cout << score << endl;
	}
	return 0;
}

Measured memory_bytes: 3016
s=input()
s1="ATGC"
l=[]
count=0
for i in range(len(s)):
  if s[i] not in s1:
    l.append(count)
    count=0
  else:
    count=count+1
  if i==len(s)-1 and s[i] in s1:
    l.append(count)
    
print(max(l))

Measured memory_bytes: 3060
N, K, S = gets.split.map(&:to_i)
ans = []
if K == 0
  a = S == 1 ? S + 1 : S - 1
  puts ([a] * N).join(' ')
  exit 0
end
ans = ([S] * K)
ans = ans + ([(S == 1 ? S + 1 : S - 1)] * (N - K)) if N - K > 0
puts ans.join(' ')

Measured memory_bytes: 5500
#include <stdio.h>

int main(void){
    char num[3 + 1];

    scanf("%s", num);

    for(int i = 0; num[i] != '\0'; i++){
        num[i] = (num[i] == '1')? '9' : '1';
    }

    printf("%s\n", num);
    return 0;
}

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

int main() {
    int n, k;
    string s;
    cin >> n >> s >> k;

    for (int i = 0; i < n; i++) {
        if (s[i] != s[k-1]) {
            s[i] = '*';
        }
        cout << s[i];
    }
}

Measured memory_bytes: 256
X = list(map(int, input().split()))
A = []
B=[]
C=[]
for _ in range(X[2]):
    A.append(int(input()))
for _ in range(X[0]):
    B.append(X[1]-X[2])
for i in range(0,X[2]):
    B[A[i]-1]=B[A[i]-1]+1
for j in range(0,X[0]):
    if B[j]>0:
        C.append("Yes")
    else:
        C.append("No")
[print(i) for i in C]

# 難しかった

Measured memory_bytes: 18324
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using vi = vector<int>;
using vvi = vector<vi>;
using vvvi = vector<vvi>;
using vll = vector<ll>;
using vvll = vector<vll>;
using vvvll = vector<vvll>;
using vs = vector<string>;
using pll = pair<ll, ll>;
using vp = vector<pll>;
#define rep(i, n) for (ll i = 0; i < (n); i++)
#define repr(i, a, b) for (ll i = (a); i < (b); i++)
#define ALL(a) (a).begin(), (a).end()
#define SZ(x) ((int)(x).size())
#define PRINT(V) for (auto v:(V)) {cerr << v << " ";} cerr << endl
#define dump(x) cerr << #x << " : " << (x) << endl
#define dump2(x, y) cerr << "(" << #x << ", " << #y << ") = (" << x << ", " << y << ")" << endl
inline ll GCD(ll a, ll b){return b ? GCD(b, a % b) : a;}
const ll MOD = 1000000007;
const ll INF = 100000000000000000LL;
/* END OF TEMPLATE */

int main(){
    cin.tie(0); ios::sync_with_stdio(false);
    ll n, k;
    cin >> n >> k;
    if(k > (n-1)*(n-2)/2){
        cout << -1 << endl;
        return 0;
    }
    ll cnt = (n-1)*(n-2)/2;
    ll m = cnt - k + n-1;
    cout << m << endl;
    repr(i, 2, n+1){
        cout << "1 " << i << "\n";
    }
    if(cnt == k){
        return 0;
    }
    repr(i, 2, n){
        repr(j, i+1, n+1){
            cout << i << " " << j << "\n";
            cnt--;
            if(cnt == k){
                return 0;
            }
        }
    }
    return 0;
}

Measured memory_bytes: 256
#define	_USE_MATH_DEFINES
#include <iostream>
#include <iomanip>
#include <cctype>
#include <algorithm>
#include <functional>
#include <vector>
#include <cstdio>
#include <cstring>
#include <cmath>
#include <cfloat>
#include <map>
#include <queue>
#include <stack>
#include <list>
#include <string>
#include <set>
#include <complex>
#include <utility>
#include <numeric>
#include <bitset>
using namespace std;
const int INF=1<<30;

typedef pair<int,int> P;
int dice[6]={1,5,3,2,4,6};

int rot(string s){
	
	int a[6]={0};
	if(s=="North"){
		a[0]=dice[3];
		a[1]=dice[0];
		a[2]=dice[2];
		a[3]=dice[5];
		a[4]=dice[4];
		a[5]=dice[1];
	}
	else if(s=="East"){
		a[0]=dice[4];
		a[1]=dice[1];
		a[2]=dice[0];
		a[3]=dice[3];
		a[4]=dice[5];
		a[5]=dice[2];
	}
	else if(s=="West"){
		a[0]=dice[2];
		a[1]=dice[1];
		a[2]=dice[5];
		a[3]=dice[3];
		a[4]=dice[0];
		a[5]=dice[4];
	}
	else if(s=="South"){
		a[0]=dice[1];
		a[1]=dice[5];
		a[2]=dice[2];
		a[3]=dice[0];
		a[4]=dice[4];
		a[5]=dice[3];
	}
	else if(s=="Right"){
		a[0]=dice[0];
		a[1]=dice[4];
		a[2]=dice[1];
		a[3]=dice[2];
		a[4]=dice[3];
		a[5]=dice[5];
	}
	else{
		a[0]=dice[0];
		a[1]=dice[2];
		a[2]=dice[3];
		a[3]=dice[4];
		a[4]=dice[1];
		a[5]=dice[5];
	}
	
	for(int i=0;i<6;i++)
		dice[i]=a[i];
	return dice[0];
}

int main(){
	
	int n;
	string s;
	
	while(cin>>n&&n){
		long long ans=1;
		for(int i=0;i<n;i++){
			cin>>s;
			ans+=rot(s);
		}
		cout<<ans<<endl;
		dice[0]=1;
		dice[1]=5;
		dice[2]=3;
		dice[3]=2;
		dice[4]=4;
		dice[5]=6;
	}

}

Measured memory_bytes: 3004
#include<bits/stdc++.h>
using namespace std;
signed main(){
  int a,b,c,count=0,count2=0;
  cin>>a>>b>>c;
  if(a==5)
    count++;
  if(a==7)
    count2++;
  if(b==5)
    count++;
  if(b==7)
    count2++;
  if(c==5)
    count++;
  if(c==7)
    count2++;
  if(count==2 && count2==1)
    cout<<"YES"<<'\n';
  else
    cout<<"NO"<<'\n';
  return(0);
}
  


Measured memory_bytes: 256