akhauriyash/Code-Regression huggingface dataset:
#include<bits/stdc++.h>
using namespace std;
#define rep(i,a,b) for(int i=(a),i##_end=(b);i<=i##_end;++i)
#define For(i,a,b) for(int i=(a),i##_end=(b);i<i##_end;++i)
#define per(i,a,b) for(int i=(b),i##_st=(a);i>=i##_st;--i)
#define fi first
#define se second
#define pb push_back
#define mp make_pair
#define dbg(x) cerr<<#x" = "<<x<<endl
#define debug(...) fprintf(stderr, __VA_ARGS__)
#define Es(x,i) for(Edge *i=G[x];i;i=i->nxt)
typedef long long ll;
typedef pair<int,int> pii;
const int inf=~0u>>1,MOD=1e9+7;
inline int rd() {
    int x,c,f=1;while(!isdigit(c=getchar()))f=c!='-';x=c-'0';
    while(isdigit(c=getchar()))x=x*10+c-'0';return f?x:-x;
}
const int N=10000000;
int f[N];
inline int pw(int n,int m){
	int r=1;
	for(;m;m>>=1,n=(ll)n*n%MOD)
		if(m&1)r=(ll)r*n%MOD;
	return r;
}
int main(){
#ifdef flukehn
	freopen("test.txt","r",stdin);
#endif 
	For(i,1,N)f[i]=f[i/10]+1;
	For(i,1,N)f[i]+=f[i-1];
	int l=0,n=rd();
	ll ans=0;
	For(i,1,N){
		while(f[i]-f[l]>n)++l;
		ans+=(f[i]-f[l]==n);
		if(f[N-1]-f[i-1]<n){
			int t=n-f[N-1]+f[i-1];
			if(!(t&7))++ans;
		}
	}
//	cerr<<ans<<endl;
	rep(i,1,n/8){
		if(n%i==0){
			int t=n/i;
			ll tmp=pw(10,t)-pw(10,t-1);
			ans+=tmp-i+1;
		}else{
			++ans;
		}
	}
	ans=(ans%MOD+MOD)%MOD;
	cout<<ans<<endl;
}

Measured memory_bytes: 39424
# 初期入力
N,R = (int(x) for x in input().split(" "))

# 内部レーティング計算、１０回以上と以下で場合分け
if 10 <= N:
    naibu = R
else:
    naibu = R + 100*(10 - N)
print(naibu)

Measured memory_bytes: 3064
using System;
using System.Collections.Generic;
using System.Linq;
using static System.Console;
using static System.Convert;
using static System.Math;
//using static System.Globalization.CultureInfo;

class Program
{
    static void Main(string[] args)
    {
        var nmq = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
        var lr = new int[nmq[0]+1,nmq[0]+1];
        for (var i = 0; i < nmq[1]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            lr[input[0], input[1]]++;
        }
        var sumo = new int[nmq[0]+1, nmq[0]+1];
        for (var i = 0; i <= nmq[0]; i++)
            for (var j = 1; j <= nmq[0]; j++)
                sumo[i, j] += sumo[i, j - 1] + lr[i, j];
        var res = new int[nmq[2]];
        for(var i = 0; i < nmq[2]; i++)
        {
            var input = Array.ConvertAll(ReadLine().Split(' '), int.Parse);
            for (var j = input[0]; j <= input[1]; j++)
                res[i] += sumo[j, input[1]] - sumo[j, input[0] - 1];
        }
        WriteLine(string.Join("\n", res));
        
    }
    private const string ALFA = "abcdefghijklmnopqrstuvwxyz";
    private const int MOD = 1000000007;
}


Measured memory_bytes: 20236
#include <bits/stdc++.h>
using namespace std;
using ll = int64_t;
#define rep(i,n) for(int i = 0; i < ((int)(n)); i++)   // 0-indexed昇順

struct edge {ll from, to, cost;};
edge es[2000];
ll d[1000];
ll N, M;

int main() {
    cin >> N >> M;
    rep(i,M) {
        ll a, b, c; cin >> a >> b >> c;
        es[i] = {--a, --b, c};
    }

    rep(i,N) d[i] = INT64_MIN;
    d[0] = 0;
    rep(i,N) {
        rep(j, M) {
            edge e = es[j];
            if (d[e.from] != INT64_MIN && d[e.to] < d[e.from] + e.cost) {
                d[e.to] = d[e.from] + e.cost;
                if (i == N - 1 && e.to == N - 1) {
                    cout << "inf" << endl;
                    return 0;
                }
            }
        }
    }
    cout << d[N - 1] << endl;
}


Measured memory_bytes: 256
using System;

namespace ConsoleApplication2
{
    class Program
    {
        static void Main(string[] args)
        {
            
            string AB = Console.ReadLine();
            string[] ab = (AB.Split(' '));        //?????????????????§?????????????´???????
            int a = int.Parse(ab[0]);             //????????????int????????°????????????
            int b = int.Parse(ab[1]);
            int x = a * b;
            int y = (a + b) * 2;

            Console.WriteLine(x + " " + y);
        }

    }
}

Measured memory_bytes: 9104
#include <iostream>
#include <vector>
#include <algorithm>
#include <assert.h>

using namespace std;

#define LEN 200003

long long A[LEN];
long long P[LEN];
bool V[LEN];
int cycle_start = -1;
int ans = -1;

int visit(int node, int p, vector<int> &nodes, long long K, long long jumped){

  if(K == jumped) ans = node;
  
  if(V[node]){ cycle_start = node; return 1;}

  P[node] = p;
  V[node] = true;
  nodes.push_back(node);
  return 1 + visit(A[node], node, nodes, K, jumped + 1);
  
}

int main(){

  long long N, K;
  cin >> N >> K;

  for(int i = 1; i <= N; i++){
    cin >> A[i];
    V[i] = false;
    P[i] = -1;
  }

  vector<int> nodes;
  long long before_cycle = visit(1, -1, nodes, K, 0) - 1;

  for(int i = 1; i <= N; i++){
    V[i] = false;
    P[i] = -1;
  }
  nodes.clear();

  if(before_cycle <= K){
    long long cycle_length = visit(cycle_start, -1, nodes, K, 0) - 1;
    long long pos = (K - before_cycle) % (cycle_length);
    assert(nodes.size() == cycle_length);
    cout << nodes[pos] << endl;
  }
  else{
    visit(1, -1, nodes, K, 0);
    assert(ans != -1);
    cout << ans << endl;
  }
  
  
  return 0;
  
  
}


Measured memory_bytes: 16444
#include <cassert>
#include <cstdio>
#include <cmath>
#include <iostream>
#include <iomanip>
#include <sstream>
#include <vector>
#include <set>
#include <map>
#include <queue>
#include <numeric>
#include <algorithm>

using namespace std;
using lint = long long;
constexpr int MOD = 1000000007, INF = 1010101010;
constexpr lint LINF = 1LL << 60;

template <class T>
ostream &operator<<(ostream &os, const vector<T> &vec) {
	for (const auto &e : vec) os << e << (&e == &vec.back() ? "\n" : " ");
	return os;
}

#ifdef _DEBUG
template <class T>
void dump(const char* str, T &&h) { cerr << str << " = " << h << "\n"; };
template <class Head, class... Tail>
void dump(const char* str, Head &&h, Tail &&... t) {
	while (*str != ',') cerr << *str++; cerr << " = " << h << "\n";
	dump(str + (*(str + 1) == ' ' ? 2 : 1), t...);
}
#define DMP(...) dump(#__VA_ARGS__, __VA_ARGS__)
#else 
#define DMP(...) ((void)0)
#endif

int main() {

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

	string s;
	cin >> s;

	const int sz = (int)s.size();

	if (s.back() != '0' || s.front() != '1' || s[sz - 2] != '1') {
		cout << -1 << "\n";
		return 0;
	}

	for (int i = 0; i < sz / 2; i++) {
		if (s[i] != s[sz - i - 2]) {
			cout << -1 << "\n";
			return 0;
		}
	}

	auto star = [](int &now, const int size) {
		const int center = now++;
		for (int i = 1; i < size; i++, now++) {
			cout << center << " " << now << "\n";
		}
		return center;
	};

	int now = 1;
	int i = 1;
	for (; i < sz / 2; i++) {
		if (s[i] == '1') {
			DMP(i, now);
			const int st = star(now, i + 2 - now);
			cout << st << " " << now << "\n";
		}
	}
	star(now, sz - now + 1);

	return 0;
}

Measured memory_bytes: 1616
#include<cstdio>
#include<cstdlib>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<string>
#include<cmath>
#include<map>
using namespace std;
typedef long long LL;
int h,w;
char a[105][105];
bool vis;
int main(){
	scanf("%d%d",&h,&w);
	for(int i=1;i<=h;i++) scanf("%s",a[i]+1);
	for(int i=1;i<=h;i++){
		for(int j=1;j<=w;j++){
			if(a[i][j]=='#'){
				vis=0;
				if(i-1>=1){
					if(a[i-1][j]=='#') vis=1;
				}
				if(i+1<=h){
					if(a[i+1][j]=='#') vis=1;
				}
				if(j-1>=1){
					if(a[i][j-1]=='#') vis=1;
				}
				if(j+1<=w){
					if(a[i][j+1]=='#') vis=1;
				}
			}
			else vis=1;
			if(vis==0) break;
		}
		if(vis==0) break;
	}
	if(vis==0) printf("No\n");
	else printf("Yes\n");
}

Measured memory_bytes: 256
s = int(input())
l = [s]

while True:
  if l[-1] % 2 == 0: l.append(l[-1] // 2) # n is even
  else: l.append(3 * l[-1] + 1) # n is odd
  if l[-1] in l[:-1]: break
      
print(len(l))
                 
         

Measured memory_bytes: 9032
n = int(input())
AB = [list(map(int, input().split())) for _ in range(n)]
AB.sort(key=lambda x: (x[1], -x[0]))
time = 0
for a, b in AB:
    time += a
    if time > b:
        print('No')
        break
else:
    print('Yes')


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

#define REP(i,n) for(int i=0;i<(int)(n);i++)
#define ALL(a) (a).begin(),(a).end()

pair<int, int> n(const string &s, int i) {
  int nv = 0;
  if (s[i] == '0') return make_pair(0, i+1);
  if (!isdigit(s[i])) throw "invalid";
  while (i < s.size() && isdigit(s[i])) {
    nv *= 2;
    nv += s[i] - '0';
    ++i;
  }
  return make_pair(nv, i);
}

pair<int, int> e(const string &s, int i);

pair<int, int> f(const string &s, int i) {
  if (i >= s.size()) throw "invalid";
  if (s[i] == '-') {
    int fv;
    tie(fv, i) = f(s, i+1);
    return make_pair(-fv, i);
  } else if (s[i] == '(') {
    int ev;
    tie(ev, i) = e(s, i+1);
    if (i >= s.size() || s[i] != ')') throw "invalid";
    return make_pair(ev, i+1);
  }
  return n(s, i);
}

pair<int, int> t(const string &s, int i) {
  int fl;
  tie(fl, i) = f(s, i);
  while (i < s.size()-1 && s[i] == '*') {
    int fr;
    tie(fr, i) = f(s, i+1);
    fl *= fr;
  }
  return make_pair(fl, i);
}

pair<int, int> e(const string &s, int i) {
  int tl;
  tie(tl, i) = t(s, i);
  while (i < s.size()-1 && (s[i] == '+' || s[i] == '-')) {
    char op = s[i];
    int tr;
    tie(tr, i) = t(s, i+1);
    if (op == '+') {
      tl += tr;
    } else {
      tl -= tr;
    }
  }
  return make_pair(tl, i);
}

bool valid(const string &s) {
  int i = 0;
  int e1, e2;
  tie(e1, i) = e(s, i);
  if (i >= s.size() || s[i] != '=') throw "invalid";
  tie(e2, i) = e(s, i+1);
  if (i != s.size()) throw "invalid";
  return e1 == e2;
}

int frac(int i) {
  if (i == 0) return 1;
  return i * frac(i-1);
}

int main(){
  string ch = "01()+-=*";
  sort(ALL(ch));
  string s;
  cin>>s;
  int cnt=0;
  vector<char> let;
  for (char c : s) {
    if (find(ALL(ch), c) == end(ch)) {
      let.push_back(c);
    }
  }
  sort(ALL(let));
  let.erase(unique(ALL(let)), end(let));
  if (let.size() > 8) {
    cout << 0 << endl;
    return 0;
  }
  map<char, int> idx;
  REP(i,let.size()) {
    idx[let[i]] = i;
  }
  do {
    string t = s;
    for (char &c : t) {
      if (idx.count(c)) {
        c = ch[idx[c]];
      }
    }
    try {
      if (valid(t)) {
        ++cnt;
      }
    } catch(...) {
    }
  } while (next_permutation(ALL(ch)));
  cout << cnt/frac(ch.size() - let.size()) << endl;
  return 0;
}

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

#define int long long
#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()
#define pb push_back
#define mp make_pair
#define mt make_tuple

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

const int inf = 1LL<<60;
const int mod = 1e9 + 7;
const double eps = 1e-9;

/*{
}*/

template<class T>
class BinaryIndexedTree
{
public:
  int n;
  vector<T> bit;

  BinaryIndexedTree():n(-1){}

  BinaryIndexedTree(int n_, T d):n(n_),bit(n_+1,d){}

  T sum(int i)
  {
    T s = 0;
    while(i > 0){
      s += bit[i];
      i -= i&-i;
    }
    return s;
  }

  void add(int i, T x)
  {
    if(i == 0) return;
    while(i <= n){
      bit[i] += x;
      i += i&-i;
    }
  }

  T sum0(int i)
  {
    return sum(i+1);
  }

  void add0(int i, T x)
  {
    add(i+1, x);
  }

  T query(int l, int r)
  {
    return sum(r-1)-sum(l-1);
  }

  T query0(int l, int r)
  {
    return sum(r)-sum(l);
  }
};

int n, a[100000];
const int offset = 100000;

bool check(int x)
{
  BinaryIndexedTree<int> bit(200010, 0);  
  int res = 0, cnt = 0;
  bit.add0(offset, 1);
  rep(i, n){
    if(x <= a[i]) cnt++;
    else cnt--;

    res += bit.query0(0, cnt+offset+1);
    bit.add0(cnt+offset, 1);
  }

  return (n*(n-1)/2+n+1)/2 <= res;
}

signed main()
{
  cin >> n;
  rep(i, n) cin >> a[i];

  int l = 0, r = inf;
  while(r-l > 1){
    int m = (l+r)/2;
    if(check(m)) l = m;
    else r = m;
  }

  cout << l << endl;

  return 0;
}


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

namespace Algorithm
{
    class Program
    {
        static void Main(string[] args)
        {
            var N = int.Parse(Console.ReadLine());
            var L = Console.ReadLine().Split().Select(int.Parse).ToArray();

            Array.Sort(L);
            var total = 0;
            for (var i = 1; i < 2 * N; i+=2)
            {
                total += Math.Min(L[i - 1], L[i]);
            }

            Console.WriteLine(total);
        }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
int main(void){
	int i, n, j, A, B[11] = { 0 }, C[11] = { 0 }, judgeB, judgeC, pattern, cntB, cntC;
	scanf("%d", &n);
	for (i = 0; i < n; i++){
		pattern = 0;
		cntB = 1;
		cntC = 1;
		for (j = 0; j < 10; j++){
			scanf("%d", &A);
			judgeB = A - B[cntB-1];
			judgeC = A - C[cntC-1];
			//printf("%d %d\n", judgeB, judgeC);
			if (judgeB < 0 && judgeC < 0){
				pattern = 1;
			}
			else if (judgeB <= judgeC && judgeB>0){
				B[cntB] = A;
				cntB++;
			}
			else{
				C[cntC] = A;
				cntC++;
			}
		}
		if (pattern == 1){
			printf("NO\n");
		}
		else{
			printf("YES\n");
		}
	}
    return 0;
}

Measured memory_bytes: 580
n = int(input())
a = list(map(int, input().split()))
if n % 2:
    li = a[1::2][::-1] + a[::2]
    li = li[::-1]
else:
    li = a[::2][::-1] + a[1::2]
    li = li[::-1]
print(" ".join(map(str, li)))

Measured memory_bytes: 29760
'use strict'

const main = input => {
	const args = input.split('\n').map(arg => arg.split(' '))
	const a = parseInt(args[0][0], 10)
	const b = parseInt(args[0][1], 10)
	if (a + b === 15) console.log('+')
	else if (a * b === 15) console.log('*')
	else console.log('x')
}

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


Measured memory_bytes: 7496
#include <stdio.h>
int main(void){
    
    int h, w;
    int i, j;
    
    while(1) {
        scanf("%d %d", &h, &w);
        if(h==0 && w==0)
            break;
    
        for (i=0; i<h; i++) {
            for(j=0; j<w; j++) {
                printf("#");
            }
            printf("\n");
        }
        printf("\n");
    }
    return 0;
}


Measured memory_bytes: 2028
import java.util.Scanner;

public class Main {
	public static void main(String args[]) {
		Scanner sc = new Scanner(System.in);
		int N = sc.nextInt();
		int X = N%1000;
		if(X ==  0) {
			X = 1000;
		}
		System.out.println(1000-X);
		sc.close();
	}
}


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

int main() {
    
    int K;
    string S;
    cin >> K >> S;
    
    if(S.size() <= K){
        cout << S << endl;
    }else{
        cout << S.substr(0, K) + "..." << endl;
    }
    
    return 0;
}

Measured memory_bytes: 3644
#include<iostream>
#include<string>
#include<queue>
using namespace std;
priority_queue<string,vector<string>,greater<string> > q1;
int main(){
	int n,l;
	string a;
	cin>>n>>l;
	for(int i=0;i<n;i++){
		cin>>a;
		q1.push(a);
	}
	while(!q1.empty()){
		cout<<q1.top();
		q1.pop();
	}
	cout<<endl;
	return 0;
}

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

int main()
{
  string t="CODEFESTIVAL2016";
  string s;
  cin>>s;
  
  int cnt=0;
  for(int i=0;i<t.size();i++){
    if(t.at(i)!=s.at(i))
      cnt++;
  }
  
  cout<<cnt<<endl;
  
  return 0;
}

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

using namespace std;
int main(){
    int n,a;
    while(scanf("%d%d",&n,&a)!=EOF){
        if(n%500<=a){
            printf("Yes\n");
        }
        else printf("No\n");
    }
    return 0;
}

Measured memory_bytes: 256
N, X = map(int, input().split())

a, p = [1], [1]

for i in range(N):
    a.append(a[i] * 2 + 3)
    p.append(p[i] * 2 + 1)

def f(N, X):
    if N == 0:
        return 0 if X <= 0 else 1
    elif X <= 1 + a[N-1]:
        return f(N - 1, X - 1)
    else:
        return p[N - 1] + 1 + f(N - 1, X - 2 - a[N - 1])

print(f(N, X))

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

int main() {
    vector<vector<int>> a(3,vector<int>(3));
    rep(i,3){
        rep(j,3) cin>>a[i][j];
    }
     int n;
     cin>>n;
     if(n<3){ cout<<"No"<<endl;}
     else{
     vector<int> b(n);
     rep(i,n) cin>>b[i];
     rep(i,n){
         rep(j,3){
             rep(k,3){ if(b[i]==a[j][k]) a[j][k]=0;}
                 }
            }
     
     bool x=false;
     rep(i,3){
         if(a[i][0]==0&&a[i][1]==0&&a[i][2]==0) x=true;
         if(a[0][i]==0&&a[1][i]==0&&a[2][i]==0) x=true;
     }
     if(a[0][0]==0&&a[1][1]==0&&a[2][2]==0) x=true;
     if(a[0][2]==0&&a[1][1]==0&&a[2][0]==0) x=true;
     if(x) cout<<"Yes"<<endl;
     if(x==false) cout<<"No"<<endl;
     }
}

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


int N, K, S;


int main() {
    cin >> N >> K >> S;
    int x = 1e9;
    if (S == x) x--;
    vector<int> ans(N, x);
    rep(i, K) ans[i] = S;
    rep(i, N-1) cout << ans[i] << " ";
    cout << ans.back() << endl;
}


Measured memory_bytes: 1664
#!/usr/bin/python3
# -*- coding:utf-8 -*-

def main():
  h, w, a, b = map(int, input().split())
  for i in range(h):
    if i < b:
      print('0'*a+'1'*(w-a))
    else:
      print('1'*a+'0'*(w-a))
  
    

if __name__=='__main__':
  main()



Measured memory_bytes: 3956
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int 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; }

int digits(ll n){
	int res = 0;
	while(n > 0){
		n /= 10;
		res++;
	}
	return res;
}

int f(ll x, ll y){
    return max(digits(x), digits(y));
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    ll n;
    cin >> n;
    int ans = digits(n);
    for(ll a = 1; a*a <= n; ++a){
        if(n%a != 0) continue;
        ll b = n / a;
        chmin(ans, f(a, b));
    }
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3612
#include<iostream>
#include<string>
#include<iomanip>
#include<cmath>
#include<vector>
#include<algorithm>

using namespace std;

#define int long long
#define endl "\n"

const long long INF = (long long)1e18;
const long long MOD = 1'000'000'007; 

string yn(bool f){return f?"Yes":"No";}
string YN(bool f){return f?"YES":"NO";}



signed main(){
	cin.tie(0);
	ios::sync_with_stdio(false);
	cout<<fixed<<setprecision(10);
	
	int a, b, c;
	int d;
	
	cin>>a>>b>>c;
	
	d = a * 100 + b * 10 + c;
	
	if(d%4 == 0) cout<<"YES"<<endl;
	else cout<<"NO"<<endl;
	return 0;
}

Measured memory_bytes: 256
#include<stdio.h>
int main(void)
{
	int i,j,n,m,l,s[101];
	m=0;
	scanf("%d",&n);
	for(i=1;i<=n;i++){
		scanf("%d",&s[i]);
		m+=s[i];
	}
	for(i=1;i<=n;i++){
		for(j=1;j<=n;j++){
			if(s[i]<s[j]){
				l=s[i];
				s[i]=s[j];
				s[j]=l;
			}
		}
	}
	if(m%10==0){
		for(i=1;i<=n;i++){
			if(s[i]%10!=0){
				m=m-s[i];
				break;
			}
		}
	}
	if(m%10!=0) printf("%d\n",m);
	else  printf("0\n");
	return 0;
}

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

typedef long long ll;
typedef unsigned long long ull;
//typedef long double ld;

typedef map<int, int> mii;
typedef pair<int, int> pii;
typedef pair<double,double> pdd;
typedef set<int> si;
typedef set<ll> sll;
typedef vector<int> vi;
typedef vector<pair<int, int > > vii;
typedef vector<ll> vll;
typedef vector<double> vd;
typedef vector<vi> vvi;
typedef vector<vii> vvii;
typedef vector<vll> vvll;

constexpr ll MOD = 1e9+7;
constexpr int INF = 1<<30;
constexpr ll  LINF = 1LL<<60;

#define Sort(x) sort(x.begin(),x.end())
#define Reverse(x) reverse(x.begin(),x.end())
#define ABS(a,b) ((a)<(b)?(b)-(a):(a)-(b))
#define nbit(n) (1ll<<(n))

// sort(begin(x), end(x), greater<ll>());
// lower_bound(a.begin(), a.end(), val): a[i] ≥ valである最左の位置
// upper_bound(a.begin(), a.end(), val): a[i] > valである最左の位置

// Returns minimum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmin(T& a, T b) {
  if (a > b) {
    a = b;
  }
  return a;
}

// Returns maximum of a and b.
// If a is less b, a is set to b.
template<typename T>
T chmax(T& a, T b) {
  if (a < b) {
    a = b;
  }
  return a;
}

// a = (a+b)%MOD;
void addmod(ll& a, ll b) {
  a = (a+b)%MOD;
}

template <typename T>
void dumpContents(const T& v, const string& msg)
{
  cerr << "### " << msg << " ###\n";
  for (const auto& x : v) {
    cerr << x << " ";
  }
  cerr << endl;
}

struct before_main_function {
  before_main_function() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    cout<<setprecision(20)<<fixed;
    #define endl "\n"
  }
} before_main_function;

// ========== end of template ==========
constexpr int X_MAX = 1e5;
vvi all(X_MAX*2+10);

void addPoint(int x, int y) {
  assert(x>0);
  assert(y>0);

  int X = x;
  int Y = X_MAX + y;

  all[X].emplace_back(Y);
  all[Y].emplace_back(X);
}


ll count(const vii& g) {
  si sx;
  si sy;
  for (auto p : g) {
    sx.insert(p.first);
    sy.insert(p.second);
  }

  return sx.size()*sy.size() - g.size();
}

void dfs(vector<bool>& visited, vii& g, int u) {
  if (u<=X_MAX) {
    for (int v : all[u]) {
      g.emplace_back(u,v);
    }
  }

  for (int v : all[u]) {
    if (visited[v]){
      continue;
    }

    visited[v] = true;
    dfs(visited, g, v);
  }

}

int main(int argc, char** argv) {
  int N;
  cin >> N;

  for (int i=0; i<N; i++) {
    int x, y;
    cin >> x >> y;
    addPoint(x, y);
  }

  ll ret = 0;

  vector<bool> visited(X_MAX*2+10);
  // 連結成分ごとに
  for (int x=1; x<=X_MAX; x++) {
    if (visited[x]) continue;

    visited[x] = true;

    vii g;
    dfs(visited, g, x);
    ret += count(g);

    //cerr << "x " << x << ", ret " << ret << endl;
  }

  cout << ret << endl;

  return 0;
}


Measured memory_bytes: 18420
#include<bits/stdc++.h>
using namespace std;
const int N =2e5,OO=0x3f3f3f3f;
int n,l;
int arr[N];
int main()
{
    cin>>n;
    for(int i=0;i<n;i++)cin>>arr[i];
    int mn=1e9;
    for(int i=-1000;i<=1000;i++){
        int sum=0;
        for(int j=0;j<n;j++){
            sum+=(arr[j]-i)*(arr[j]-i);
        }
        mn=min(mn,sum);
    }
    cout<<mn<<endl;
}


Measured memory_bytes: 256
import java.util.*;

/**
 * Created by Seiya on 2016/10/16.
 */
public class Main {

    public static void main(String[] args) {
        Scanner scanner = new Scanner(System.in);

        int H, W;
        H = scanner.nextInt();
        W = scanner.nextInt();

        for (int i = 0; i < H; i++) {
            String s = scanner.next();
            System.out.println(s);
            System.out.println(s);
        }

    }
}




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

int main() {
  int N;
  cin >> N;
  int B[N];
  for (int i = 0; i < N-1; i++) cin >> B[i];

  int sum = B[0];
  for (int i = 0; i < N-1; i++) {
    if (i == N-2) {
      sum += B[N-2];
      continue;
    }
    sum += min(B[i], B[i+1]);
  }

  cout << sum << endl;
}


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

int main(){
    long long N, ans = 0, a;
    long long a_2, sum = 0, sum_2 = 0;
    std::cin >> N;
    for(long long i = 0; i < N; i++){
        std::cin >> a;
        a_2 = (a*a)%1000000007;
        sum = (sum + a)%1000000007;
        sum_2 = (sum_2 + a_2)%1000000007;
        //std::cout << sum << " " << sum_2 << "\n";
    }

    ans = ((sum * sum)%1000000007 - sum_2);
    ans = ans%1000000007;
    ans = (ans * 500000004)%1000000007;

    if(ans < 0){
         ans = 1000000007 + ans;
    }

    std::cout << ans;
}


Measured memory_bytes: 3596
#pragma GCC optimize(2)
#include <bits/stdc++.h>
using namespace std;

/*-------------------Define Start-------------------*/
typedef bool BL;                        // 布尔类型
typedef char SB;                        // 有符号1字节,8位
typedef unsigned char UB;                // 无符号1字节,8位
typedef short SW;                        // 有符号短整型,16位
typedef unsigned short UW;                // 无符号短整型,16位
typedef long SDW;                        // 有符号整型,32位
typedef unsigned long UDW;               // 无符号整型,32位
typedef long long SLL;                    // 有符号长整型,64位
typedef unsigned long long ULL;            // 无符号长整型,64位
typedef char CH;                        // 单个字符
typedef float R32;                        // 单精度浮点数
typedef double R64;                        // 双精度浮点数

#define Rep(i, n) for (register SDW i = 0; i < (n); ++i)
#define For(i, s, t) for (register SDW i = (s); i <= (t); ++i)
#define rFor(i, t, s) for (register SDW i = (t); i >= (s); --i)
#define foreach(i, c) for (__typeof(c.begin()) i = c.begin(); i != c.end(); ++i)
#define ms0(a) memset(a,0,sizeof(a))
#define msI(a) memset(a,0x7f,sizeof(a))
#define LOWBIT(x) ((x)&(-x))

#define MP make_pair
#define PB push_back
#define ft first
#define sd second
#define ALL(x) x.begin(),x.end()

#define pr(x) cout << #x << " = " << x << "  "
#define prln(x) cout << #x << " = " << x << endl

#define lson l , mid , rt << 1 
#define rson mid + 1 , r , rt << 1 | 1

const ULL mod = 1e9 + 7;                //常用模数(可根据题目需要修改)
const ULL inf = 0x7fffffff;                //用来表示无限大
const ULL infLL = 0x7fffffffffffffffLL;    //用来表示无限大
/*-------------------Define End-------------------*/

const UDW maxN = 1e4 + 7;
SDW N, P;
string S; 
SLL r[maxN]; // 
SLL ans;


void input(){
	cin >> N >> P >> S;
}

void solve(){
	if(P == 2 || P == 5) {
		rFor(i, N - 1, 0) {
			if((S[i] - '0') % P == 0) {
				ans += i + 1;
			}
		}
	}
	else{
		SLL base = 1;
		SLL x = 0;
		r[0] = 1;
		 
		rFor(i, N - 1, 0) {
			x = (x + (S[i] - '0') * base) % P;
			ans += r[x];
			++r[x];
			base = (base * 10) % P;
		}
	}
}

void output(){
    cout << ans << endl;
}

int main() {
    input();
    solve();
    output();
    return 0;
}


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


int main() {
  int n, k;
  cin >> n >> k;
  int ans = 0;
  if(n%k) ans = 1;
  cout << ans << endl;
  return 0;
  
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define rep(i,n) for(int i = 0; i < (n); ++i)
using namespace std;
typedef long long int ll;
typedef pair<int, vector<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; }

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int h, w, n;
    cin >> h >> w >> n;
    vector<int> a(n);
    rep(i,n) cin >> a[i];
    vector<vector<int>> ans(h, vector<int>(w));
    int p = 0;
    rep(i,h){
        if(i%2 == 0){
            rep(j,w){
                if(a[p] == 0) ++p;
                ans[i][j] = p+1;
                --a[p];
            }
        }
        else{
            for(int j = w-1; j >= 0; --j){
                if(a[p] == 0) ++p;
                ans[i][j] = p+1;
                --a[p];
            }
        }
    }
    rep(i,h){
        rep(j,w) cout << ans[i][j] << " ";
        cout << endl;
    }
    return 0;
}


Measured memory_bytes: 3716
#include <iostream>
#include <limits>
#include <numeric>
#include <type_traits>

int gcd(int a, int b)
{
      if (a < b) {
        a ^= b;
        b ^= a;
        a ^= b;
      }
   return b ? gcd(b, a % b) : a;
}

int main()
{
  int n, t, sum = 0;
  std::cin >> n;
  for(int i = 1; i < n+1; i++){
    for(int j = 1; j < n+1; j++){
      for (int k = 1; k < n+1; k++){
        t = gcd(i, j);
        t = gcd(t, k);
        sum += t;
      }
    }
  }
  std::cout << sum;
  return 0;
}

Measured memory_bytes: 3592
#include <bits/stdc++.h>
#define rep(i,N) for(long long  i=0;i<N;i++)
using namespace std;
long long  INF=1000000000000000000;
long long mod=1000000007;
 
using namespace std;


int main(){

int N;
cin>>N;
long long A[N];
rep(i,N)cin>>A[i];

long long ans=1;
long long c[3]={};
for(int i=0;i<N;i++){

long long cnt=0,id=-1;

if(A[i]==c[0]){cnt++,id=0;}
if(A[i]==c[1]){cnt++,id=1;}
if(A[i]==c[2]){cnt++,id=2;}

    if(id==-1){
    cout<<"0"<<endl;
    return 0;
    }
    ans*=cnt;
    if(ans>mod)ans%=mod;
    c[id]++;
}
cout<<ans<<endl;
 return 0;
}
/*

6
0 1 2 3 4 5

3

3
0 0 0

6

54
0 0 1 0 1 2 1 2 3 2 3 3 4 4 5 4 6 5 7 8 5 6 6 7 7 8 8 9 9 10 10 11 9 12 10 13 14 11 11 12 12 13 13 14 14 15 15 15 16 16 16 17 17 17

115295190

*/

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

#define MAX_N 100005

long long int prime[MAX_N]; // i番目の素数
bool is_prime[MAX_N + 1];   // is_prime[i]がtrueならばiは素数
bool is_like_2017[MAX_N + 1];
long long int acc[MAX_N + 1]={0};

// n以下の素数の数を返す
long long int sieve(long long int n) {
    long long int p = 0;
    for (long long int i = 0; i <= n; i++)
        is_prime[i] = true;
    is_prime[0] = false;
    is_prime[1] = false;
    for (long long int i = 2; i <= n; i++) {
        if (is_prime[i]) {
            prime[p++] = i;
            for (long long int j = 2 * i; j <= n; j += i)
                is_prime[j] = false;
        }
    }
    return p;
}

int main(){
    sieve(100000);
    int q;
    cin >> q;
    for(int i=0;i<=100000;++i)is_like_2017[i] = (is_prime[i] && is_prime[(i+1)/2]);
    for(int i=1;i<=100000;++i)acc[i] = acc[i-1] + (is_like_2017[i] ? 1 : 0);
    for(int i=0;i<q;++i){
        int l, r;
        cin >> l >> r;
        cout << acc[r] - acc[l-1] << endl;
    }

    return 0;
}


Measured memory_bytes: 1664
#include <bits/stdc++.h>
#define GET_MACRO(_1,_2,_3,_4,_5,_6,_7,_8,NAME,...) NAME
#define pr(...) cerr<< GET_MACRO(__VA_ARGS__,pr8,pr7,pr6,pr5,pr4,pr3,pr2,pr1)(__VA_ARGS__) <<endl
#define pr1(a) (#a)<<"="<<(a)<<" "
#define pr2(a,b) pr1(a)<<pr1(b)
#define pr3(a,b,c) pr1(a)<<pr2(b,c)
#define pr4(a,b,c,d) pr1(a)<<pr3(b,c,d)
#define pr5(a,b,c,d,e) pr1(a)<<pr4(b,c,d,e)
#define pr6(a,b,c,d,e,f) pr1(a)<<pr5(b,c,d,e,f)
#define pr7(a,b,c,d,e,f,g) pr1(a)<<pr6(b,c,d,e,f,g)
#define pr8(a,b,c,d,e,f,g,h) pr1(a)<<pr7(b,c,d,e,f,g,h)
#define prArr(a) {cerr<<(#a)<<"={";int i=0;for(auto t:(a))cerr<<(i++?", ":"")<<t;cerr<<"}"<<endl;}
using namespace std;
using Int = long long;
using _int = int;
using ll = long long;
using Double = long double;
const Int INF = (1LL<<60)+1e9; // ~ 1.15 * 1e18
const Int mod = (1e9)+7;
const Double EPS = 1e-8;
const Double PI = 6.0 * asin((Double)0.5);
using P = pair<Int,Int>;
template<class T> T Max(T &a,T b){return a=max(a,b);}
template<class T> T Min(T &a,T b){return a=min(a,b);}
template<class T1, class T2> ostream& operator<<(ostream& o,pair<T1,T2> p){return o<<"("<<p.first<<","<<p.second<<")";}
template<class T1, class T2, class T3> ostream& operator<<(ostream& o,tuple<T1,T2,T3> t){
  return o<<"("<<get<0>(t)<<","<<get<1>(t)<<","<<get<2>(t)<<")";}
template<class T1, class T2> istream& operator>>(istream& i,pair<T1,T2> &p){return i>>p.first>>p.second;}
template<class T> ostream& operator<<(ostream& o,vector<T> a){Int i=0;for(T t:a)o<<(i++?" ":"")<<t;return o;}
template<class T> istream& operator>>(istream& i,vector<T> &a){for(T &t:a)i>>t;return i;}



signed main(){
  srand((unsigned)time(NULL));
  cin.tie(0);
  ios_base::sync_with_stdio(0);
  cout << fixed << setprecision(12);

  while(1){
  int n, m;
  cin>>n>>m;
  if(n == 0 && m == 0) break;
  
  map<int,int> num;
  for(int i=0;i<n;i++){
    int d, v;
    cin>>d>>v;
    Max(num[d], v);
  }
  int ans = 0;
  for(auto &p:num) ans += p.second;
  cout<<ans<<endl;
  }

  return 0;
}



Measured memory_bytes: 3164
#include <iostream>
#include <cstdio>
#include <cstring>
#include <cstdlib>
#include <cassert>
#include <climits>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <fstream>

using namespace std;
#define SZ(x) (int)(x).size()
#define REP(i,n) for(int i=0;i<(n);i++)
#define FOR(i,a,b) for(int i=(a);i<(b);i++)
#define REPR(i,n) for(int i=(n)-1;i>=0;i--)
#define ALL(s) (s).begin(), (s).end()
#define so(V) sort(ALL(V))
#define rev(V) reverse(ALL(V))
#define uni(v) v.erase( unique(ALL(v)) , v.end());

typedef long long unsigned int llu;
typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vll;
typedef vector<bool> vb;
const double EPS = 1e-9;
const int MOD = 1e9 + 7;
const int INF = (1 << 29);
const ll LINF = 1e18;
const double PI = acos(-1);

template<typename T>vector<T> make_v(size_t a) { return vector<T>(a); }
template<typename T, typename... Ts>auto make_v(size_t a, Ts... ts) { return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...)); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value != 0>::type
fill_v(U& u, const V... v) { u = U(v...); }
template<typename T, typename U, typename... V>
typename enable_if<is_same<T, U>::value == 0>::type
fill_v(U& u, const V... v) { for (auto& e : u) fill_v<T>(e, v...); }
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; }

int main() {
	cin.tie(0);
	ios::sync_with_stdio(false);
	int N;
	cin >> N;
	vi A(N);
	REP(i, N)cin >> A[i];
	vi Ans;
	vi V(N + 1);
	REPR(i, N) {
		ll cur = i + 1;
		int sum = 0;
		ll m = 1;
		while (cur * m <= N) {
			sum += V[cur * m];
			m++;
		}
		if ((sum + A[i]) % 2 == 1) {
			Ans.push_back(cur);
			V[cur]++;
		}
	}
	cout << SZ(Ans) << endl;
	REP(i, SZ(Ans)) {
		if (i != 0) {
			cout << " ";
		}
		cout << Ans[i];
	}
	cout << endl;
	return 0;
}


Measured memory_bytes: 3192
import java.util.*;
public class Main{
	public static void main(String args[]) {
		Scanner sc=new Scanner(System.in);
		int N=sc.nextInt();
		int M=sc.nextInt();
		int C=sc.nextInt();
		int A[][]=new int[N][M];
		int B[]=new int[M];
		int sum=0;
		int count=0;
		for(int i=0;i<M;i++) {
			B[i]=sc.nextInt();
		}
		for(int j=0;j<N;j++) {
			for(int k=0;k<M;k++) {
				A[j][k]=sc.nextInt();
			}
		}
		for(int l=0;l<N;l++) {
			for(int m=0;m<M;m++) {
				sum+=A[l][m]*B[m];
			}
			sum+=C;
			if(sum>0) {
				count++;
			}
			sum=0;
		}
		System.out.println(count);
	}
}

Measured memory_bytes: 24020
#include<functional>
#include<algorithm>
#include<iostream>
#include<utility>
#include<string>
#include<vector>
#include<cmath>
#include<stack>
#include<queue>
#include<deque>
#include<map>
#define rep(i,n) for(int i=0;i<n;i++)
#define loop(i,x,n) for(int i=x;i<n;i++)
#define all(v) (v).begin(),(v).end()
#define pf push_front
#define pb push_back
#define int long long
using namespace std;
const int INF=1000000007;
int dx[4]={1,0,-1,0};
int dy[4]={0,1,0,-1};


signed main(){
  int a,b;
  cin>>a>>b;
  if(a<b)cout<<"a < b"<<endl;
  else if(a>b)cout<<"a > b"<<endl;
  else cout<<"a == b"<<endl;


  return 0;
}

Measured memory_bytes: 3064
//Radhe Radhe
#include<bits/stdc++.h>//14 JUL 2020
#define ll long long
#define fixed cout.setf(ios::fixed);
#define rep1    for( i=0; i<n; i++)
#define Precise cout.precision(7);
using namespace std;

int main()
{
    ll n,i,j,m,ans=0;
    cin>>n>>m;
    ans=(n*(n-1))/2;
    ans+=(m*(m-1))/2;

    cout<<ans<<endl;
    return 0;
}





Measured memory_bytes: 3636
import sys

class Node:
    def __init__(self, val):
        self.val = val
        self.parent = None
        self.left = None
        self.right = None
        self.depth = 0
    
    def get_depth(self):
        if not self.parent:
            return 0
        else:
            return self.parent.get_depth()+1
    
    def get_sibling(self):
        if not self.parent:
            return - 1
        else:
            if self.parent.right and self.parent.right.val == self.val:
                if self.parent.left:
                    return self.parent.left.val
                else:
                    return - 1
            elif self.parent.left and self.parent.left.val == self.val:
                if self.parent.right:
                    return self.parent.right.val
                else:
                    return - 1
    
    def get_parent(self):
        if not self.parent:
            return -1
        return self.parent.val
    
    def get_degree(self):
        degree = 0
        if self.left:
            degree += 1
        if self.right:
            degree += 1
        return degree
    
    def get_type(self):
        if not self.parent:
            return "root"
        elif self.left or self.right:
            return "internal node"
        else:
            return "leaf"
    
    def get_height(self):
        if not self.left and not self.right:
            return 0
        l,r = 0,0
        if self.left:
            l = self.left.get_height()
        if self.right:
            r = self.right.get_height()
        return max(l + 1, r + 1)

def main():
    n = int(input().strip())
    nodes = [Node(i) for i in range(n)]

    ## get order
    preorder = [int(i)-1 for i in input().strip().split()] ## convert to 0-based index
    inorder = [int(i)-1 for i in input().strip().split()] ## convert to 0-based index

    def make_tree(preorder, inorder):
        if not preorder or not inorder:
            return None

        ## get root of tree
        root = nodes[preorder[0]]
        ## find divide point in inorder table
        idx = inorder.index(root.val)

        left_inorder = inorder[:idx]
        left_preorder = preorder[1:len(left_inorder)+1]
        right_inorder = inorder[idx + 1:]
        right_preorder = preorder[len(left_inorder) + 1:]

        ## create left and right tree
        root.left = make_tree(left_preorder,left_inorder)
        root.right = make_tree(right_preorder,right_inorder)

        return root

    make_tree(preorder, inorder)
    
    postorder = []

    def postorder_walk(node):
        if node.left:
            postorder_walk(node.left)
        if node.right:
            postorder_walk(node.right)
        postorder.append(str(node.val+1)) ## fix to 1-based index
    root = nodes[preorder[0]]
    postorder_walk(root)
    print(" ".join(postorder))


if __name__ == "__main__":
    main()


Measured memory_bytes: 5664
n, c, k = map(int, input().split())
t = [int(input()) for i in range(n)]
t.sort()

bus = 0
i = 0
while i < n:
  base = i
  bus += 1
  passenger = 0
  while i < n and t[i] <= t[base] + k and passenger + 1 <= c:
    passenger += 1
    i += 1
print(bus)

Measured memory_bytes: 7384
//#include <bits/stdc++.h>
#include<iostream>
#include<stdio.h>
#include<bitset>
#include<algorithm>
#include<vector>
#include<list>
#include<queue>
#include<stack>
#include<string>
#include<string.h>
#include<cmath>
#include<utility>
#include<functional>
#include<map>
#include<set>
 
 
#define FOR(i, a, b) for( int i=(a);i<=(b);i++)
#define RFOR(i, a, b) for( int i=(a);i>=(b);i--)
#define LFOR(i, a, b) for( long long int i=(a);i<=(b);i++)
#define LRFOR(i, a, b) for(long long int i=(a);i>=(b);i--)
#define MOD 1000000007
#define INF 1000000000 //2000000000
#define LLINF 1000000000000000000 //9000000000000000000
#define PI 3.14159265358979
#define MAXI 7500000
 
using namespace std;
typedef long long int ll;
typedef pair< long long int, long long  int> P;
 
 
int main(void) {
	
	long long int a, b, c, k;
 
	cin >> a >> b >> c >> k;
 
	if (k % 2 == 1) {
		if (abs(a - b) >= 1000000000000000000) {
			cout << "Unfair" << endl;
		}
		else {
			cout << -(a - b) << endl;
		}
	}
	else {
		if (abs(a - b) >= 1000000000000000000) {
			cout << "Unfair" << endl;
		}
		else {
			cout << (a - b) << endl;
		}
	}
 
	return 0;
}

Measured memory_bytes: 256
#include "bits/stdc++.h"
#define Rep(i,n) for(int i=0;i<(int)(n);i++)
#define For(i,n1,n2) for(int i=(int)(n1);i<(int)(n2);i++)
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define RREP(i,n) for(ll i=((ll)(n)-1);i>=0;i--)
#define FOR(i,n1,n2) for(ll i=(ll)(n1);i<(ll)(n2);i++)
#define RFOR(i,n1,n2) for(ll i=((ll)(n1)-1);i>=(ll)(n2);i--)
#define all(a)  (a).begin(),(a).end()
#define IOS std::cin.tie(0),std::ios::sync_with_stdio(false)

namespace idaten {

	using namespace std;
	using ll = int_fast64_t;
	using ull = uint_fast64_t;
	using P = std::pair<int64_t, int64_t>;
	template<typename T1, typename T2> inline bool chmin(T1& a, T2 b) { if (a > b) { a = b; return 1; }return 0; }
	template<typename T1, typename T2> inline bool chmax(T1& a, T2 b) { if (a < b) { a = b; return 1; }return 0; }
	template<class Type>struct is_vector : std::false_type {};
	template<class ValueType, class Alloc>struct is_vector<std::vector<ValueType, Alloc>> : std::true_type {};
	template <typename T> inline std::ostream& operator << (std::ostream& out, const std::vector<T>& v) {
		if (v.empty())return out;
		constexpr bool is_vector_v = is_vector<T>::value;
		if (is_vector_v)for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? "\n" : "");
		else for (auto itr = v.begin(); itr != v.end();)out << (*itr), out << ((++itr != v.end()) ? " " : "");
		return out;
	}
	inline void put() {}
	template<class T> inline void put(const T& first) { std::cout << first << "\n"; }
	template<class T, class... N> inline void put(const T& first, const N& ... rest) { std::cout << first << " "; put(rest...); }
	inline void putn() {}
	template<class T, class... N> inline void putn(const T& first, const N& ... rest) { std::cout << first << "\n"; putn(rest...); }

	void dfs(int now, vector<vector<int>>& path, vector<int>& visit, int& time) {
		visit[now] = time;
		REP(i, path[now].size()) {
			int t = path[now][i];
			if (visit[t] < 0) {
				dfs(t, path, visit, time);
			}
		}
	}

	void solve() {
		IOS;
		int h, w;
		cin >> w >> h;
		while (h + w > 0) {
			vector<vector<int>> c(h, vector<int>(w));
			vector<vector<int>> path(h * w);
			REP(i, h) {
				REP(j, w) {
					cin >> c[i][j];
				}
			}
			int dy[] = { 0,1,1,1,0,-1,-1,-1 };
			int dx[] = { 1,1,0,-1,-1,-1,0,1 };
			REP(i, h) {
				REP(j, w) {
					if (c[i][j] == 1) {
						REP(k, 8) {
							int ny = i + dy[k];
							int nx = j + dx[k];
							if (0 <= ny && ny < h && 0 <= nx && nx < w) {
								if (c[ny][nx] == 1) {
									int next = ny * w + nx;
									int now = i * w + j;
									path[next].push_back(now);
									path[now].push_back(next);
								}
							}
						}
					}
				}
			}
			vector<int> visit(h * w, -1);
			int cnt = 0;
			REP(i, h) {
				REP(j, w) {
					int t = i * w + j;
					if (c[i][j]==1&&visit[t] < 0) {
						dfs(t, path, visit, cnt);
						cnt++;
					}
				}
			}
			put(cnt);
			cin >> w >> h;
		}
	}
} // namespace idaten

int main() {
	idaten::solve();
	return 0;
}



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

int main() {
	int n;
	cin >> n;

	int num;
	int ans;
	for (int i = 1; i < 10; i++) {
		num = i*100 + i*10 + i;
		if (n <= num) {
			ans = num;
			break;
		}
	}
	cout << ans << endl;
	return 0;
}


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

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

using ll = long long int;
const ll MOD = 1e9 + 7;

int main() {
  int N;
  std::cin >> N;
  std::vector<int> cnt(N);
  for(int i = 1; i < N; ++i) {
    int A;
    std::cin >> A;
    --A;
    ++cnt[A];
  }

  rep(i, N) {
    std::cout << cnt[i] << '\n';
  }
}


Measured memory_bytes: 4052
#include <iostream>
#include <queue>
#include <assert.h>   
#include <vector>
#include <algorithm>
#include <time.h>
#include <numeric>
#include <string>
#include <cstring>
#include <stack>
#include <unordered_set>
#include <unordered_map>
#include <set>
#include <map>
#include <numeric>
#include <deque>
#include <iomanip>
#include <cstdlib>
#include <climits>
#include <cmath>
#include <cstdio>
using namespace std;


//#define double long double
//#define int long long
//#define int unsigned long long

#define ll long long
#define ld long double 
#define pi pair<int, int> 
#define pl pair<ll,ll>  
#define pd pair<ld,ld> 
#define str string  
#define mp make_pair
#define vi vector<int> 
#define vl vector<ll> 
#define vd vector<ld> 
#define vs vector<str> 
#define vpi vector<pi> 
#define vpl vector<pl> 
#define vpd vector<pd> 
#define si set<int> 
#define FF(i,j,n) for(signed i=j;i<=n;i++)  
#define DD(i,j,n) for(signed i=j;i>=n;i--) 
#define F(i,j,n) for(signed i=j;i<n;i++)   
#define D(i,j,n) for(signed i=j;i>n;i--) 
#define mem(a,b) memset(a,b,sizeof(a))
#define ndl cout << endl
#define ull unsigned long long 

const int inf = 0x3f3f3f3f;
const ll INF = 0x3f3f3f3f3f3f3f3fLL;


#define sz(x) (signed)x.size()
#define all(x) begin(x), end(x)
#define rall(x) (x).rbegin(), (x).rend() 
#define rsz resize
#define ins insert 
#define ft front() 
#define bk back() 
#define fi first
#define se second
#define pf push_front 
#define pb push_back
#define eb emplace_back 
#define lb lower_bound 
#define ub upper_bound 
#define IOS ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);

//math


const int mod = 1e9 + 7;

ll powmod(ll a,ll b) {ll res=1;a%=mod; assert(b>=0); for(;b;b>>=1){if(b&1)res=res*a%mod;a=a*a%mod;}return res;}
ll gcd(ll a,ll b) { return b?gcd(b,a%b):a;}
int pct(int x) { return __builtin_popcount(x); } 
int bit(int x) { return 31-__builtin_clz(x); } // floor(log2(x)) 
int cdiv(int a, int b) { return a/b+!(a<0||a%b == 0); } // division of a by b rounded up, assumes b > 0 


//DEBUG, compile with -DLOCAL
void DBG() { cerr << "]" << endl; }
template<class H, class... T> void DBG(H h, T... t) {
  cerr << to_string(h); if (sizeof...(t)) cerr << ", ";
  DBG(t...); }
#ifdef LOCAL 
#define dbg(...) cerr << "[" << #__VA_ARGS__ << "]: [", DBG(__VA_ARGS__)
#define HERE cout << "===GOTHERE===" << endl
#else
#define dbg(...) 42
#define HERE 42
#endif


 /* ============== END OF HEADER ============== */





const int maxn = 1e5*3+20;

int n,_,q,k;
int t;

void solve(){
	cin >> n;
	si st;
	FF(i,1,n){
		cin >> t;
		st.ins(t);
	}
	if(st.size() == n){
		cout << "YES" << endl;
	}else{
		cout << "NO" << endl;
	}
}

signed main(){
  //clock_t t1 = clock();  
	IOS
	solve();
  
  //cout << "THE ALGORITHM TOOK: " << (clock() - t1) * 1.0 / CLOCKS_PER_SEC * 1000 << "ms"<< endl;
	return 0;
}

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


int main() {
  int n,k,d,num;
  cin>>n>>k;
  vector<int> sunu(n,0);
  
  rep(i,k){
    cin>>d;
    rep(j,d){
      cin>>num;
      sunu[num-1]=1;
    }
  }
  int cnt=0;
  rep(i,n){
    if(sunu[i]==0) cnt++;
  }
  cout<<cnt<<endl;
    
  
  
      
    
  
  
}

Measured memory_bytes: 3620
#include<bits/stdc++.h>
using namespace std;
#define ll long long
#define elif else if
#define ffast ios::sync_with_stdio(0);cin.tie(0);cout.tie(0);



int main()
{
    ffast;
    //freopen("0in.txt","r",stdin);
    //freopen("0out.txt","w",stdout);


    string s;
    cin>>s;
    if(s[2]==s[3] && s[4]==s[5])
        cout<<"Yes\n";
    else
        cout<<"No\n";

    return 0;
}





Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int n,mx,c,x,ls=0;
int main()
{
	cin>>n;
	for(int i=1;i<=n;i++)
	{
		scanf("%d",&x);
		if(x<=ls)c++;
		else c=1;
		ls=x;
		mx=max(mx,c);
	}
	cout<<mx-1;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <set>
#include <algorithm>
#include <fstream>
#include <string>
#include <math.h>
#include <cstdlib>
#include <cstdint>
#include <istream>
#include <sstream>
#include <cctype>
#include <functional>
#include <iomanip>
#define rep(i,N) for(ll i=0;i<N;i++)
#define disp(a) cout << a << endl;
#define PI 3.1415926535897932384626433
//cout << fixed << setprecision(20) << ** << endl;
typedef long long ll;
using namespace std;

double deg2rad(double degree)
{
    return degree * PI / 180.0000000000;
}
int main()
{
	double H,W,N;
	cin>>H>>W>>N;
	cout<<ceil(N/max(H,W))<<endl;

}

Measured memory_bytes: 256
N = int(input())
#S = str(input())
#L, R, d = map(int, input().split())
#A = list(map(int, input().split()))
ans = [0] * (N + 1)

for i in range(1,101):
  for j in range(1,101):
    for k in range(1,101):
      now = i ** 2 + i * (j + k) + j ** 2 + k ** 2 + j * k
      if now <= N:
        ans[now] += 1
  
for i in range(1, N + 1):
  print(ans[i])
  
  

Measured memory_bytes: 9240