akhauriyash/Code-Regression huggingface dataset:
vert,hori = gets.chomp.split(" ").map(&:to_i)
coin = Array.new(vert).map{Array.new(hori, 0)}
coin2 = Array.new(vert).map{Array.new(hori, 0)}
for i in 0..vert - 1
  coin[i] = gets.chomp.split(" ").map(&:to_i)
end
for i in 0..vert - 1
  for j in 0..hori - 1
    coin2[i][j] = coin[i][j] % 2
  end
end
ans = []
for i in 0..vert - 1
  for j in 0..hori - 1
    if coin2[i][j] == 1 || coin2[i][j] == 3
      if j != hori - 1
        coin2[i][j] -= 1
        coin2[i][j + 1] += 1
        ans.push("#{i + 1} #{j + 1} #{i + 1} #{j + 2}")
      elsif i != vert - 1
        coin2[i][j] -= 1
        coin2[i + 1][j] += 1
        ans.push("#{i + 1} #{j + 1} #{i + 2} #{j + 1}")
      end
    end
  end
end

puts ans.length
for i in 0..ans.length - 1
  puts ans[i]
end


Measured memory_bytes: 20604
n,m = map(int,input().split())

ansl = []

start = n // 2
end = n // 2 + 1
for i in range(m):
    if n % 2 == 0 and end - start + 2 * i >= n // 2:
        ansl.append((start - i-1, end + i))
    else:
        ansl.append((start-i, end+i))

for a,b in sorted(ansl):
    print(a,b)


Measured memory_bytes: 80652
//ABC136 B - Uneven Numbers
//20190905

using System;
using System.Linq;

namespace B
{
    class Program
    {
        static void Main(string[] args)
        {
            int N = int.Parse(Console.ReadLine());
            double OUTPUT = 0;

            for (int i = 1; i <= N; i++)
            {
                if (i.ToString().Length % 2 == 1)
                {
                    OUTPUT++;
                }
            }
            Console.WriteLine(OUTPUT);

            // int N = int.Parse(Console.ReadLine());
            // double OUTPUT = 0;

            // if (N < 10)
            // {
            //     OUTPUT = N;
            // }
            // else if (N < 100)
            // {
            //     OUTPUT = 9;
            // }
            // else if (N < 1000)
            // {
            //     OUTPUT = 9 + N - 99;
            // }
            // else if (N < 10000)
            // {
            //     OUTPUT = 9 + 900;
            // }
            // else if (N < 100000)
            // {
            //     OUTPUT = 9 + 900 + N - 9999;
            // }
            // else
            // {
            //     OUTPUT = 9 + 900 + 90000 ;
            // }

            // Console.WriteLine(OUTPUT);

        }
    }
}


Measured memory_bytes: 11092
import sys
read = sys.stdin.read
readline = sys.stdin.readline
readlines = sys.stdin.readlines

lst = list(map(int, read().split()))
arr=lst[:9]
tf = [False] * 10
for i in lst[10:]:
  if i in arr:
    tf[arr.index(i)] = True

t=[[0,1,2],[3,4,5],[6,7,8],[0,3,6],[1,4,7],[2,5,8],[0,4,8],[2,4,6]]
for i in t:
  a = True
  for j in i:
    if not tf[j]:
      a = False
  if a:
    print('Yes')
    quit()
else:
  print('No')

Measured memory_bytes: 3064
#include <bits/stdc++.h>
#define rep(i,n) for (int i = 0; i < (n); ++i)
using namespace std;
using ll = long long;
using P = pair<int,int>;
  
int main() {
    int n, r;
    cin >> n >> r;
    if(n < 10){
        cout << r + 100*(10-n) << endl;
    }else{
        cout << r << endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <cstring>
#include <vector>
#include <deque>
#include <queue>
#include <array>
#include <set>
#include <map>
#include <cmath>
#include <algorithm>
#include <numeric>
#include <utility>
#include <tuple>
#include <functional>
#include <bitset>
#include <cstdint>
#include <cassert>
#include <random>

using namespace std;
using i64 = int64_t;
using i32 = int32_t;
template<class T, class U> void init_n(vector<T>& v, size_t n, U x) 
{ v = vector<T>(n, x); }
template<class T> void init_n(vector<T>& v, size_t n) { init_n(v, n, T()); }
template<class T> void read_n(vector<T>& v, size_t n, size_t o = 0) 
{ v = vector<T>(n+o); for (size_t i=o; i<n+o; ++i) cin >> v[i]; }
template<class T> void read_n(T a[], size_t n, size_t o = 0)
{ for (size_t i=o; i<n+o; ++i) cin >> a[i]; }
template<class T> T iabs(const T& x) { return max(x, -x); }
// #define abs gabs

int main() {
    int k, x;
    cin >> k >> x;
    string s = "No";
    if (k * 500 >= x) s = "Yes";
    cout << s << endl;
    return 0;
}

Measured memory_bytes: 888
#include <bits/stdc++.h>
using ll = long long;
using namespace std;
#define _overload3(_1, _2, _3, name, ...) name
#define _rep(i, n) repi(i, 0, n)
#define repi(i, a, b) for(int i = int(a); i < int(b); ++i)
#define rep(...) _overload3(__VA_ARGS__, repi, _rep, )(__VA_ARGS__)
const long long INFLL = 1LL << 60;
const int INFINT = 1 << 30;
const long long MOD = 1e9 + 7;

vector<vector<int>> G(101, vector<int>(0));
vector<int> c(101, 0);
vector<int> d(101, 0);
vector<int> f(101, 0);

template <class T> void vecout(T V) {
    auto t = V.begin();
    *t++;
    while(t != V.end()) {
        cout << " " << *t++;
        // if(t != V.end()) cout << " ";
    }
    cout << endl;
};

int t = 0;
void dfs(int i) {
    if(c[i]) return;
    c[i] = 1;
    d[i] = ++t;
    for(auto e : G[i])
        dfs(e);
    f[i] = ++t;
}

int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n, a, b, c;
    cin >> n;
    rep(i, n) {
        cin >> a >> b;
        rep(j, b) {
            cin >> c;
            G[a].push_back(c);
        }
    }
    rep(i, 1, n + 1) dfs(i);

    rep(i, 1, n + 1) cout << i << " " << d[i] << " " << f[i] << "\n";
}


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

broken = set(a)
mod = 10**9 + 7

dp = [0] * (n + 1)
dp[0] = 1

for i in range(1,n +1):
    if i in broken:
        continue

    if i == 1:
        dp[1] = dp[0]
        continue

    dp[i] = dp[i-1] + dp[i-2]
    dp[i] %= mod

print(dp[n]) 

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

using namespace std;

typedef long long ll;

const int maxn=100;

const int mod=1e9+7;

int a[maxn][maxn];

int b[maxn][maxn];

int num[maxn][maxn];

int du[maxn*maxn];

bool dp[maxn*maxn][maxn*maxn];

int top=0;
int head[maxn*maxn];

void init(){
	top=0;
	memset(head,-1,sizeof(head));
}

struct Edge{
	int to,w,next;
}edge[maxn*maxn*4];

void addedge(int x,int y,int w){
	edge[top].to=y;
	edge[top].next=head[x];
	edge[top].w=w;
	head[x]=top++;
	du[y]++;
}

int main(){
	init();
	int n,m;
	scanf("%d%d",&n,&m);
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&a[i][j]);
		}
	}
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			scanf("%d",&b[i][j]);
		}
	}
	int cnt=1;
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			num[i][j]=cnt++;
		}
	}
	
	for(int i=1;i<=n;i++){
		for(int j=1;j<=m;j++){
			if(i!=n){
				addedge(num[i][j],num[i+1][j],abs(a[i+1][j]-b[i+1][j]));
			}
			if(j!=m){
				addedge(num[i][j],num[i][j+1],abs(a[i][j+1]-b[i][j+1]));
			}
		}
	}
	queue<int> q;
	q.push(1);
	dp[1][abs(a[1][1]-b[1][1])]=1;
	while(!q.empty()){
		int u=q.front();
		q.pop();
		for(int i=head[u];i!=-1;i=edge[i].next){
			int to=edge[i].to;
			int w=edge[i].w;
			du[to]--;
			if(du[to]==0){
				q.push(to);
			}
			for(int j=0;j<=6400;++j){
				if(dp[u][j]){
					dp[to][abs(j+w)]=1;
					dp[to][abs(j-w)]=1;
				}
			}
		}
	}
	for(int i=0;i<=6400;i++){
		if(dp[n*m][i]){
			printf("%d",i);break;
		}
	}
	return 0;
}

Measured memory_bytes: 65024
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static Reader;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        int n = int.Parse(Console.ReadLine());
        var a = Console.ReadLine().Split().Select(int.Parse).ToArray();

        Console.WriteLine(a.All(x => x % 2 != 0 || x % 3 == 0 || x % 5 == 0) ? "APPROVED" : "DENIED");
    }
}


static class Reader
{
    const int BUF_SIZE = 1 << 12;
    static Stream Stream = Console.OpenStandardInput();
    static byte[] Buffer = new byte[BUF_SIZE];
    static int ptr = BUF_SIZE - 1;
    static void Move() { if (++ptr >= Buffer.Length) { Stream.Read(Buffer, 0, BUF_SIZE); ptr = 0; } }

    public static int NextInt
    {
        [MethodImpl(MethodImplOptions.AggressiveInlining)]
        get
        {
            int res = 0; int sign = 1; while (Buffer[ptr] < 45) Move();
            if (Buffer[ptr] == 45) { Move(); sign = -1; }
            do { res = res * 10 + (Buffer[ptr] ^ 48); Move(); } while (48 <= Buffer[ptr]);
            return res * sign;
        }
    }
}


Measured memory_bytes: 13396
#include <bits/stdc++.h>
#define REP(i, n) for(int i = 0; i < (n); i++)
#define REP1(i, n) for(int i = 1; i <= (n); i++)
#define REPD(i,a,b) for (int i=(a);i<(b);i++)
#define ALL(v) (v).begin(), (v).end()
using namespace std;
typedef long long ll;
typedef vector<string> vs;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef set<int> si;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<int, int> pi;
typedef queue<pi> qpi;
typedef pair<ll, ll> pll;
typedef queue<pll> qpll;
typedef vector<pi> vpi;
typedef vector<pll> vpll;
const int mod = 1000000007;
const int INF = 1001001001;
// 小数点　<< fixed << setprecision(0) <<
// sort降順　sort(ALL(),greater<int>());
// 円周率　M_PI
// 文字判定　isupper islower
// 順列　do {} while(next_permutation(ALL(X)));
// 最大値　LLONG_MAX
// a内でx以上　auto iter = lower_bound(ALL(a), x);
// a内でxより大きい　auto iter = upper_bound(ALL(a), x);
int dx[4] = {1, 0, -1, 0};
int dy[4] = {0, 1, 0, -1};
struct edge {
    int from; //出発点
    int to;   //到達点
    int cost; //移動コスト
};
typedef struct edge se;
typedef vector<edge> ve;
unsigned euclidean_gcd(unsigned a, unsigned b) {
  if(a < b) return euclidean_gcd(b, a);
  unsigned r;
  while ((r=a%b)) {
    a = b;
    b = r;
  }
  return b;
}
int check(int x,int y, vvi ch) {
  int flg = 1;
  REP(i,8) {
    if(ch[x][i]==1) {
      flg=0;
      break;
    }
    if(ch[i][y]==1)  {
      flg=0;
      break;
    }
    if(x+i<8&&y+i<8) {
      if(ch[x+i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y+i<8) {
      if(ch[x-i][y+i]==1)  {
      flg=0;
      break;
    }
    }
    if(x+i<8&&y-i>=0) {
      if(ch[x+i][y-i]==1)  {
      flg=0;
      break;
    }
    }
    if(x-i>=0&&y-i>=0) {
      if(ch[x-i][y-i]==1)  {
      flg=0;
      break;
    }
    }
  }
  return flg;
}

int solution(double t,double p) {
  double f=1.0-(1/1.5)*log(2)*p*pow(2,-t/1.5);
  if(f>=0) return 1;
  else if(f<0) return 0; 
}

int main() {
  int n;
  cin >> n;
  vi a(n);
  int ans=0;
  REP(i,n) {
    cin >> a[i];
    while(a[i]%2==0) {
      ans++;
      a[i]/=2;
    }
  }
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 256
using System;
using System.Linq;
using System.Numerics;
using System.Collections.Generic;
using System.IO;
using System.Text;
using N = System.Int64;

static class Program
{
    static public void Main(string[] args)
    {
        Console.SetOut(new StreamWriter(Console.OpenStandardOutput()) { AutoFlush = false });
        var solver = new Solver();
        solver.Solve();
        Console.Out.Flush();
    }
}

public class Solver
{
    public void Solve()
    {
        N n = rn;
        N sum = 0;
        N psum = 0;
        N a = 0;
        for(int i = 0; i < n; i++)
        {
            a = rn;
            sum += a;
            sum %= mod;
            psum += a * a;
            psum %= mod;
        }
        sum *= sum;
        sum %= mod;
        sum -= psum;
        sum %= mod;
        sum *= Reverse(2);
        sum %= mod;
        while (sum < 0) { sum += mod; }
        Write(sum);
    }
    private const N mod = 1000000007;
    N Reverse(N n) { return Pow(n, mod - 2); }
    N Mul(params N[] n) { N p = n[0]; for (N i = 1; i < n.Length; i++) { p = (p * n[i]) % mod; } return p; }
    N Pow(N n, N p) { N t = n, q = 1; while (p > 0) { if (p % 2 == 1) { q = (q * t) % mod; } t = (t * t) % mod; p >>= 1; } return q; }

    N rn { get { return sc.Integer(); } }
    double rd { get { return sc.Double(); } }
    string rs { get { return sc.Scan(); } }
    public StreamScanner sc = new StreamScanner(Console.OpenStandardInput());

    void Write<T>(T t) { Console.WriteLine(t.ToString()); }
    void YN(bool t) { Console.WriteLine(t ? "YES" : "NO"); }
    void Yn(bool t) { Console.WriteLine(t ? "Yes" : "No"); }
    void yn(bool t) { Console.WriteLine(t ? "yes" : "no"); }
}



public class StreamScanner
{
    public StreamScanner(Stream stream) { str = stream; }
    private readonly Stream str;
    private readonly byte[] buf = new byte[1024];
    private int len, ptr;
    public bool isEof = false;
    public bool IsEndOfStream { get { return isEof; } }
    private byte read()
    {
        if (isEof) throw new EndOfStreamException();
        if (ptr >= len)
        {
            ptr = 0;
            if ((len = str.Read(buf, 0, 1024)) <= 0)
            {
                isEof = true;
                return 0;
            }
        }
        return buf[ptr++];
    }
    public char Char()
    {
        byte b = 0;
        do b = read();
        while (b < 33 || 126 < b);
        return (char)b;
    }
    public string Scan()
    {
        var sb = new StringBuilder();
        for (var b = Char(); b >= 33 && b <= 126; b = (char)read())
            sb.Append(b);
        return sb.ToString();
    }
    public N Integer()
    {
        N ret = 0; byte b = 0; var ng = false;
        do b = read();
        while (b != '-' && (b < '0' || '9' < b));
        if (b == '-') { ng = true; b = read(); }
        for (; true; b = read())
        {
            if (b < '0' || '9' < b)
                return ng ? -ret : ret;
            else ret = ret * 10 + b - '0';
        }
    }
    public double Double() { return double.Parse(Scan()); }
}


Measured memory_bytes: 23732
using System;
using static System.Console;
using System.Linq;

namespace AC
{
   public class shiokara
   {
      static void Main(string[] args)
      {
         int[] kazu = ReadLine().Split(' ').Select(int.Parse).ToArray();
         if(kazu[0] > kazu[1]){
             WriteLine("safe");
         }else{
             WriteLine("unsafe");
         }
      }
   }
}

Measured memory_bytes: 28300
#include <bits/stdc++.h>
int main(){
  std::string s;
  std::cin >> s;
  if(s.find("A") != std::string::npos && s.find("B") != std::string::npos){
    std::cout << "Yes" << std::endl;
  }else{
    std::cout << "No" << std::endl;
  }
}


Measured memory_bytes: 256
/*
title:

url:
*/

#include <iostream>
#include <cstdio>
#include <cstdlib>
#include <algorithm>
#include <functional>
#include <queue>
#include <limits>
#include <string>
#include <utility>
#include <cstring>
#include <map>
#include <cmath>
#include <iterator>

using namespace std;

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

typedef pair<int, int> pint;
typedef long long ll;

int main()
{
    int N, M;
    vector<int> from1;
    vector<int> toN;
    cin >> N >> M;

    rep(i, M)
    {
        int a, b;
        scanf("%d %d", &a, &b);
        if (a == 1)
        {
            from1.push_back(b);
        }
        if (b == N)
        {
            toN.push_back(a);
        }
    }

    sort(from1.begin(), from1.end());
    sort(toN.begin(), toN.end());

    bool possible = false;
    rep(i, from1.size())
    {
        if (upper_bound(toN.begin(), toN.end(), from1[i]) - lower_bound(toN.begin(), toN.end(), from1[i]) != 0)
        {
            possible = true;
            break;
        }
    }

    if (possible)
    {
        cout << "POSSIBLE" << endl;
        ;
    }
    else
    {
        cout << "IMPOSSIBLE" << endl;
    }
    return 0;
}

Measured memory_bytes: 1276
#include <bits/stdc++.h>
using ll = long long;
#define FOR(i, k, n) for(ll i = (k); i < (n); i++)
#define FORe(i, k, n) for(ll i = (k); i <= (n); i++)
#define FORr(i, k, n) for(ll i = (k)-1; i > (n); i--)
#define FORre(i, k, n) for(ll i = (k)-1; i >= (n); i--)
#define REP(i, n) FOR(i, 0, n)
#define REPr(i, n) FORre(i, n, 0)
#define ALL(x) (x).begin(), (x).end()
#define ALLr(x) (x).rbegin(), (x).rend()
#define chmin(x, y) x = min(x, y)
#define chmax(x, y) x = max(x, y)
using namespace std;

const int INF = 1001001001;

int main(void){
  ll n, d;
  cin >> n >> d;
  vector<double> x(n), y(n);
  REP(i, n) cin >> x[i] >> y[i];
  ll ans = 0;
  REP(i, n){
    double t = sqrt(x[i]*x[i]+y[i]*y[i]);
    if(t <= d) ans++;
  }
  cout << ans << endl;
  return 0;
}

Measured memory_bytes: 6464
N, K = map(int, input().split())

MOD = 10**9 + 7
n_sum = [0]

for i in range(N):
    n_sum.append(n_sum[i] + i+1)
#print(n_sum)

ans = 0
for i in range(K-1,N):
    #print(n_sum[i], n_sum[N]-n_sum[N-i-1])
    ans += (n_sum[N] - n_sum[N-i-1] - n_sum[i] + 1)
    ans %= MOD

print((ans+1)%MOD)

Measured memory_bytes: 19228
import java.util.Scanner;
import java.util.Arrays;

public class Main {
    public static void main(String args[]){
        Scanner stdIn = new Scanner(System.in);
        int k = stdIn.nextInt(); //塗られている個数
        int x = stdIn.nextInt(); //黒確座標
        
        for(int i = x - k + 1; i <= x + k - 2; i++){
            System.out.print(i + " ");
        }
        
        System.out.println(x + k - 1);
    }
}


Measured memory_bytes: 23636
#include <stdio.h>
#include <ctype.h>
#include <stdlib.h>
 
int main()
{
    int m, f, r;
    int s;
 
    while (1) {
        scanf("%d%d%d", &m, &f, &r);
        if (m == -1 && f == -1 && r == -1) break;
 
        if (m < 0 || f < 0) puts("F");
        else {
            s = m + f;
            if (s >= 80) puts("A");
            else if (s >= 65) puts("B");
            else if (s >= 50) puts("C");
            else if (s < 30) puts("F");
            else puts(r >= 50 ? "C" : "D");
        }
    }
    return 0;
}


Measured memory_bytes: 2068
#include<iostream>
#include<cstdio>
#include<cstdlib>
#include<cmath>
#include<queue>
#include<string>
#include<cstring>
#include<algorithm>
#include<set>
#include<map>
#include<iomanip>

#define REP(i,n) for(int i=0;i<(n);i++)
#define EPS (1e-7)
#define INF (2e9)
// cout << setprecision(10)

using namespace std;
typedef long long int ll;

ll X;
int main(void){
    cin >> X;
    ll A, B;
    bool b = false;
    for(ll i = -200;i<=200;i++){
        for (ll j = -200;j<=200;j++){
            if (pow(i,5) - pow(j,5) == X){
                A = i;
                B = j;
                b = true;
                break;
            }
        }
        if(b) break;
    }
    cout << A << " " << B << endl;
    return 0;
}



Measured memory_bytes: 4100
#require 'prime'
#require 'openssl'
MOD=10**9+7;  cnt=0; sum=0; prev=nil; can=true; h=Hash.new(0)
def gs() gets.chomp end
def gi() gets.chomp.to_i end
def gsmi() gets.chomp.split.map(&:to_i) end

def ar2(s1,s2,de=nil) Array.new(s1){Array.new(s2,de)} end
def ar3(s1,s2,s3,de=nil) Array.new(s1){Array.new(s2){Array.new(s3,de)}} end

def desc(ar) ar.sort!{|x,y| y<=>x} end
def min(a,b) a<=b ? a : b end
def max(a,b) a>=b ? a : b end
def sum(ar) ar.inject(:+).to_i end
def ceil(a,b) (a.to_f/b).ceil end

def C(a,b) b==0||a==b ? 1 : (b=a-b if a/2<b;(a-b+1..a).inject(:*)/(1..b).inject(:*)) end
def rui(ar) s=[0]; ar.size.times{|i| s<<s[-1]+ar[i]}; s end
def rev_rui(ar) s=[0]; ar.size.times.reverse_each{|i| s<<s[-1]+ar[i]}; s end

def puts_yesno(b) puts(b ? 'Yes' : 'No') end
def putsend(s) puts s; exit end
def pu(h) begin; require './../nemi_lib/debug.rb'; puts_val(h); rescue LoadError; end; end
########### ( ˘ω˘ )ｽﾔｧ… ###########
n,k=gsmi
a=[]
k.times{
  d=gi
  a<<gsmi
}
puts n - a.flatten.uniq.size

Measured memory_bytes: 14368
#include <math.h>
#include <stdio.h>
const double pr = 1e-6;
int main()
{
    int n;  scanf("%d", &n);
    double ans  = 0;
    double a;
    while(n--)
    {
        scanf("%lf", &a);
        ans += 1/a;
    }
    ans = 1/ans;
    printf("%0.10lf\n", ans);
}

Measured memory_bytes: 128
#include <iostream>
#include <queue>
#include <algorithm>
using namespace std;
class FC{
	public:
		int p[31];
		int n;
		bool is_over(){
			return p[1]==p[2] && p[2]==p[3] && p[3]==p[4] && p[4]==p[5] && p[5]==p[6] && p[6]==p[7] && p[7]==p[8] && p[8]==p[9]  && p[10]==p[11] && p[11]==p[12] && p[13]==p[14] && p[14]==p[15]  && p[16]==p[17] && p[17]==p[18]  && p[19]==p[20] && p[20]==p[21] && p[22]==p[23] && p[23]==p[24] && p[24]==p[25] && p[25]==p[26] && p[26]==p[27] && p[27]==p[28] && p[28]==p[29] && p[29]==p[30];
		}
		void rot1(){
			swap(p[7],p[22]); swap(p[8],p[23]); swap(p[9],p[24]); swap(p[13],p[18]); swap(p[10],p[12]);
		}
		void rot2(){
			swap(p[1],p[28]); swap(p[2],p[29]); swap(p[3],p[30]); swap(p[15],p[16]); swap(p[19],p[21]);
		}
		void rot3(){
			swap(p[3],p[22]); swap(p[6],p[25]); swap(p[9],p[28]); swap(p[15],p[13]); swap(p[12],p[19]);
		}
		void rot4(){
			swap(p[1],p[24]); swap(p[4],p[27]); swap(p[7],p[30]); swap(p[10],p[21]); swap(p[16],p[18]);
		}
};
int main(){
	int N;
	cin>>N;
	for(int i=0;i<N;i++){
		FC now;
		for(int j=1;j<=30;j++)
			cin>>now.p[j];
		now.n=0;
		queue<FC> que;
		que.push(now);
		while(!que.empty()){
			now=que.front();
			que.pop();
		
			if(now.is_over()){
				cout<<now.n<<endl;
				break;
			}
			FC nex1=now; nex1.rot1(); nex1.n++; que.push(nex1);
			FC nex2=now; nex2.rot2(); nex2.n++; que.push(nex2);
			FC nex3=now; nex3.rot3(); nex3.n++; que.push(nex3);
			FC nex4=now; nex4.rot4(); nex4.n++; que.push(nex4);
		}
	}
	return 0;
}
	
	

Measured memory_bytes: 12168
while True:
    table = input().split()

    a = int(table[0])
    b = int(table[2])
    op = table[1]
    if op == '?':
        break
    if op == '+':
        print(a+b)
    elif op == '-':
        print(a-b)
    elif op == '*':
        print(a*b)
    elif op == '/':
        print(int(a/b))


Measured memory_bytes: 5596
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
struct node{
	int w,s;
	ll v;
}a[30005];
int n; 
ll f[30005],ans;
bool cmp(node a,node b){
	return a.w+a.s<b.w+b.s;
}
int main(){
	cin>>n;
	for(int i=1;i<=n;++i){
		cin>>a[i].w>>a[i].s>>a[i].v;
	}
	sort(a+1,a+n+1,cmp);
	for(int i=1;i<=n;++i){
		for(int j=a[i].s;j>=0;--j){
			f[j+a[i].w]=max(f[j+a[i].w],f[j]+a[i].v);
		}
	}
	for(int i=0;i<30005;++i){
		ans=max(ans,f[i]);
	}
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 384
//#include <tourist>
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> p;
const int INF = 1e9;
const ll LINF = ll(1e18) + 1;
const int MOD = 1000000007;
const int dx[4] = {0, 1, 0, -1}, dy[4] = {-1, 0, 1, 0};
const int Dx[8] = {0, 1, 1, 1, 0, -1, -1, -1}, Dy[8] = {-1, -1, 0, 1, 1, 1, 0, -1};
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl
#define rep(i, n) for (int i = 0; i < n; i++)
#define ALL(v) v.begin(), v.end()
#define debug(v)          \
    cout << #v << ":";    \
    for (auto x : v)      \
    {                     \
        cout << x << ' '; \
    }                     \
    cout << endl;
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;
}
//cout<<fixed<<setprecision(15);有効数字15桁
//-std=c++14
ll gcd(ll a, ll b) { return b ? gcd(b, a % b) : a; }
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
int n, m;
vector<int> a;

int main()
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    string s;
    cin >>s;
    ll bcount=0;
    ll wcount=0;
    ll ans=0;
    rep(i,s.size()){
        if(s[i]=='W'){
            ans+=(i-wcount);
            wcount++;
        }
    }
    ll ans1=0;
    for(int i=s.size()-1;i>=0;i--){
        if(s[i]=='B'){
            ans1 += (s.size() - 1 - bcount - i);
            bcount++;
        }
    }
    cout << max(ans,ans1) << "\n";
}


Measured memory_bytes: 720
#include<bits/stdc++.h>
using namespace std;
bitset<2000020> f;
int n,s;
int main()
{
	scanf("%d",&n);
	int x;
	f[0]=1;
	for(int i=1;i<=n;i++)
	 {
	  scanf("%d",&x);
	  f|=f<<x;
	  s+=x;
	 }
	for(int i=(s+1)/2;i<=s;i++)
	 if(f[i])
	  {
	   printf("%d\n",i);
	   break;
	  }
	return 0;
}


Measured memory_bytes: 1024
'use strict';

var DateToDay = function(year, month, date) {
	if (month == 1 || month == 2) {
		month += 12;
		--year;
	}
	var j = Math.floor(year / 100);
	var k = year % 100;
	var h = (date + Math.floor(26*(month + 1)/10) + k + Math.floor(k/4) + Math.floor(j/4) + 5*j) % 7;
	var day;
	switch (h) {
		case 0:
			day = 'Saturday';
			break;
		case 1:
			day = 'Sunday';
			break;
		case 2:
			day = 'Monday';
			break;
		case 3:
			day = 'Tuesday';
			break;
		case 4:
			day = 'Wednesday';
			break;
		case 5:
			day = 'Thursday';
			break;
		case 6:
			day = 'Friday';
			break;
	}
	return day;
}

var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var dates = input.trim().split('\n');
//var dates = ['1 1', '2 29', '0 0'];
var year = 2004;
while (true) {
	var date = dates.shift().split(' ');
	if (date[0] === '0' || date[1] === '0') {
		break;
	}
	console.log(DateToDay(year, parseInt(date[0]), parseInt(date[1])));
}

Measured memory_bytes: 15412
#include<stdio.h>
int main(void){
	int R,G,B,N;
	int r,g,b;
	int i,j,k;
	int Ans =0;
	scanf("%d %d %d %d",&R,&G,&B,&N);
	
	for(i=0;i<=3000;i++){
		for(j=0;j<=3000;j++){
			if(N>=R*i+G*j && (N-R*i-G*j)%B==0){
				Ans++;
			}
		}
	}
	printf("%d",Ans);
    return 0;
}

Measured memory_bytes: 128
#include<bits/stdc++.h>
#define ll long long
using namespace std;
const int N=1e5+5;
char s[N],t[N];int a[N][30],nxt[N],pre[N][30],p;
int main()
{
	scanf("%s%s",s+1,t+1);
	int len1=strlen(s+1),len2=strlen(t+1);
	for(int i=1;i<=len1;i++)
	{
		int k=s[i]-'a'+1;
		for(int j=1;j<=26;j++)
			if(j==k)
			{
				if(pre[i-1][j]==0)a[0][j]=i;
				pre[i][j]=i;
				nxt[pre[i-1][j]]=i;
			}else pre[i][j]=pre[i-1][j];
	}
	
	nxt[0]=0;
	for(int i=1;i<=len1;i++)
		for(int j=1;j<=26;j++)
		{
			int k=nxt[pre[i][j]];
			if(k)a[i][j]=k;else a[i][j]=a[0][j];
		}
	ll ans=0;
	for(int i=1;i<=len2;i++)
	{
		int k=a[p][t[i]-'a'+1];
		if(k==0)
		{
			puts("-1");
			return 0;
		}
		int add=k<=p?k-p+len1:k-p;
		p=k;
		ans+=(ll)add;
	}
	printf("%lld\n",ans);
	return 0;
}

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

typedef long long ll;
const ll INF = 1010000000000000017LL;
const ll MOD = 1000000007LL;

#define REP(i, n) for(ll i = 0 ; i < n; i++)

//#define DEBUG(fmt, ...)
#define DEBUG(fmt, ...) fprintf(stderr, fmt "\n", ##__VA_ARGS__)

int main(){
    std::cout<<std::fixed<<std::setprecision(10);

    ll N;

    cin >> N;
    if( N%2 == 1 ){
        cout << N/2 + 1 << endl;
    }else{
        cout << N/2 << endl;
    }
}


Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <queue>
#include <tuple>
#include <cstring>

#define INF 100000000

using namespace std;

int main()
{
    int a, b;
    char c;
    cin >> a >> c >> b;
    if (c == '+')
        cout << a + b << endl;
    else
        cout << a - b << endl;
    return 0;
}


Measured memory_bytes: 256
import sys, copy
input = lambda: sys.stdin.readline().rstrip() 
sys.setrecursionlimit(10**7)
INF = 10**10
def I(): return int(input())
def F(): return float(input())
def SS(): return input()
def LI(): return [int(x) for x in input().split()]
def LI_(): return [int(x)-1 for x in input().split()]
def LF(): return [float(x) for x in input().split()]
def LSS(): return input().split()

def resolve():
    N = I()
    C_tmp = LSS()
    C = [{'suit':'', 'value':0} for _ in range(N)]
    for i in range(N):
        C[i]['suit'] = C_tmp[i][0]
        C[i]['value'] = int(C_tmp[i][1:])

    def BubbleSort(C, N):
        for i in range(N):
            for j in range(N-1, i, -1):
                if C[j]['value'] < C[j-1]['value']:
                    C[j], C[j-1] = C[j-1], C[j]
        return C

    def SelectionSort(C, N):
        for i in range(N):
            minj = i
            for j in range(i, N):
                if C[j]['value']<C[minj]['value']:
                    minj = j
            if i!=minj:
                C[i], C[minj] = C[minj], C[i]
        return C

    def isStable(C, C_s):
        isStable = True
        for i in range(1, 10):
            if [j['suit'] for j in C if j['value']==i]!=[j['suit'] for j in C_s if j['value']==i]:
                isStable = False
        ret = 'Stable' if isStable else 'Not stable'
        return ret

    C_bs = BubbleSort(copy.deepcopy(C), N)
    print(*[i['suit']+str(i['value']) for i in C_bs])
    print(isStable(C, C_bs))

    C_ss = SelectionSort(copy.deepcopy(C), N)
    print(*[i['suit']+str(i['value']) for i in C_ss])
    print(isStable(C, C_ss))

if __name__ == '__main__':
    resolve()


Measured memory_bytes: 6352
import java.util.Scanner;
public class Main{
 public static void main(String[] args) {
   Scanner kbd = new Scanner(System.in);
  int a=kbd.nextInt();
    int b=kbd.nextInt();
      int c=kbd.nextInt();
        int d=kbd.nextInt();

    while(c>0&&a>0){
    c=c-b;
    a=a-d;
  }
int n=0;
    if(c<=0){
    n=0;
  }
  if(a<=0){
    n=1;
  }
  if(c<=0&&a<=0){
    n=0;
  }
  if(n==0){
    System.out.println("Yes");
}else{
    System.out.println("No");
}
}
}

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

using namespace std;
using ll = long long;
using ld = long double;
#define rep(i,n) for(int i=0;i<(int)(n);i++)
#define reps(i,s,n) for(int i=(int)(s);i<(int)(n);i++)
const ll mod = ll(1e9) + 7;
const int INF = int(1e9);

int main() {
	cin.sync_with_stdio(false);
	int N, M;
	cin >> N;
	vector<string>s(N);
	map<string, int>mp;
	rep(i, N) {
		cin >> s[i];
		mp[s[i]]++;
	}
	cin >> M;
	vector<string>t(M);
	rep(i, M) {
		cin >> t[i];
		mp[t[i]]--;
	}
	int ans = 0;
	rep(i, N) {
		ans = max(ans, mp[s[i]]);
	}
	cout << ans << endl;

	return 0;
}


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

#define times(n, i) uptil(0, n, i)
#define upto(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i <= _##i poi  i++)
#define uptil(f, t, i) for(auto _##i = (t), i = decltype(_##i)(f) poi  i < _##i poi  i++)
#define downto(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i >= _##i poi  i--)
#define downtil(f, t, i) for(auto i = (f), _##i = decltype(i)(t) poi  i > _##i poi  i--)

#define unless(c) if(!(c))
#define until(c) while(!(c))
#define loop while(true)

#define poi ;
#define poipoi << "\n"

/*#define do {*/
#define end }

#define val const auto
#define var auto

#define fuwafuwa(n, c) dokidoki((n) + (c) - 1, c)
#define dokidoki(n, c) ((n) / (c) * (c))

template<class T> bool read(T& t){
    return cin >> t poi
}
template<class T, class...U> bool read(T& t, U&... u){
    unless(cin >> t) return false poi
    return read(u...) poi
}

int main(){
    char c[100] poi
    while(cin.getline(c, 100)){
        string s = c poi
        loop{
            if(s.substr(0, 4) == "the " || s.substr(0, 5) == "this " || s.substr(0, 5) == "that "){
                cout << s poipoi poi
                goto pyon poi
            }
            times(s.size() - 5, i)
                if(s.substr(i, 5) == " the " || s.substr(i, 4) == " this " || s.substr(i, 4) == " that "){
                    cout << s poipoi poi
                    goto pyon poi
                }
            if(s.substr(s.size() - 4) == " the" || s.substr(s.size() - 5) == " this" || s.substr(s.size() - 5) == " that"){
                cout << s poipoi poi
                goto pyon poi
            }

            for(char& c : s) if('a' <= c && c < 'z') c++poi else if(c == 'z') c = 'a' poi
        }
        pyon:;
    }
    return 0 poi
}

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

int main(void){
	const int inf = 100000000;

	int n,m;
	cin >> n >> m;

	int a[1000],b[1000],c[1000],dist[100][100];
	
	for(int i = 0; i < m; ++i){
		cin >> a[i] >> b[i] >> c[i];
		a[i]--,b[i]--;
	}

	for(int i = 0; i < n; ++i){
		for(int j = 0; j < n; ++j){
			if(i==j)
				dist[i][j]=0;
			else
				dist[i][j]=inf;
		}
	}
	
	for(int i = 0; i < m; ++i){
		dist[a[i]][b[i]]=min(dist[a[i]][b[i]],c[i]);
		dist[b[i]][a[i]]=min(dist[b[i]][a[i]],c[i]);
	}

	for(int k = 0; k < n; ++k){
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < n; ++j){
				dist[i][j]=min(dist[i][j],dist[i][k]+dist[k][j]);
			}
		}
	}
	
	int ans=m;
	for(int i = 0; i < m; ++i){
		bool shortest=false;
		for(int j = 0; j < n; ++j) if(dist[j][a[i]]+c[i]==dist[j][b[i]]) shortest=true;
		if(shortest==true){
			ans=ans-1;
		}
	}

	cout << ans << endl;
}

Measured memory_bytes: 256
L = int( input())
r = 0
A = []
l = L
ANS = []
while l != 0:
    l, r = divmod(l, 2)
    A.insert(0,r)
N = len(A)
for i in range(N-1):
    ANS.append("{} {} {}".format(i+1, i+2, 0))
    ANS.append("{} {} {}".format(i+1, i+2, 2**i))
del A[0]
y = 2**(N-1)
M = 2*(N-1)
#Flag = False
for i in range(N-1):
#    if Flag == True:
#        y += A[i]*(2**(N-i-1))
    if A[i] == 1:
        ANS.append("{} {} {}".format(N-i-1, N, y))
        M += 1
        y += A[i]*(2**(N-i-2))
#        Flag = True
print("{} {}".format(N, M))
for a in ANS:
    print(a)

Measured memory_bytes: 3064
import math

N = int(input())

# 割れるだけ割る
KMAX = math.floor(math.sqrt(N)) + 1

Kn = [N]  # N の約数であるような K
Kn1 = [N-1]  # N - 1 の約数であるような K

# N の約数であるような K (Kn)を求める
for K in range(2,KMAX):
    
    if N % K == 0:
        Kn.append(K)
        tmp = N//K
        if tmp == K:
            continue
        Kn.append(N//K)
        
Knn = []

# Kn のうち、割れるだけ割った(tN)あと、tN mod Kn == 1 であるような Kn
for K in Kn:
    tN = N
    while tN % K == 0:
        tN = tN // K  # K で割れなくなるまで割る
    
    if (tN - 1) % K == 0:
        Knn.append(K)
        
# N-1 の約数であるような K を求める
for K in range(2,KMAX):

    if (N - 1) % K == 0:
        Kn1.append(K)
        tmp = (N-1) // K
        if tmp == K:
            continue
        Kn1.append(tmp)

Knn.extend(Kn1)
if 1 in Knn:
    Knn.remove(1)
print(len(Knn))

Measured memory_bytes: 3276
#include <iostream>
#include <vector>
#include <algorithm>
#include <map>
#include <cstring>
#include <math.h>
#include <bitset>
#include <queue>
#include <set>
#include <iomanip>
#include <math.h>
#include <assert.h>
// #include<bits/stdc++.h>
using namespace std;
typedef long long ll;
constexpr long long int INFLL = 1001001001001001LL;
constexpr long long int infll = 1001001001001001LL;
constexpr int INF = 1000000007;
constexpr int inf = 1000000007;
const int mod = 1000000007;

template <class T>
inline bool chmin(T &a, T b)
{
    if (a > b)
    {
        a = b;
        return true;
    }
    return false;
}
template <class T>
inline bool chmax(T &a, T b)
{
    if (a < b)
    {
        a = b;
        return true;
    }
    return false;
}

ll gcd(ll a, ll b)
{
    if (a % b == 0)
    {
        return (b);
    }
    else
    {
        return (gcd(b, a % b));
    }
}

ll lcm(ll a, ll b)
{
    return a / gcd(a, b) * b;
}

inline double nCr(const int n, int r)
{
    if (n == 0)
    {
        return 0;
    }
    if (r == 0)
    {
        return 1;
    }
    if (r == 1)
    {
        return n;
    }
    if (n == r)
    {
        return 1;
    }

    if (r > n / 2)
    {
        r = n / 2;
    }

    double result = 1;
    for (double i = 1; i <= r; i++)
    {
        result *= (n - i + 1) / i;
    }

    return (result);
}

template <typename T>
T seinomi(T a)
{
    if (a > 0)
    {
        return a;
    }
    else
    {
        return 0;
    }
}

template <typename T>
map<T, T> soinsuubunkai(T n) //連想配列[素因数f.first][個数f.second]
{
    map<T, T> ret;
    for (T i = 2; i * i <= n; i++)
    {
        while (n % i == 0)
        {
            ret[i]++;
            n /= i;
        }
    }
    if (n != 1)
        ret[n] = 1;
    return ret;
}

template <typename T>
T ketasuu(T num)
{
    return std::to_string(num).length();
}

int kaizyou(int k)
{
    int sum = 1;
    for (int i = 1; i <= k; ++i)
    {
        sum *= i;
    }
    return sum;
}

template <class ForwardIt, class T>
void iota(ForwardIt first, ForwardIt last, T value)
{
    while (first != last)
    {
        *first++ = value;
        ++value;
    }
}

//nの階乗を計算
int factorial(int n)
{
    int answer = 1;
    while (n > 1)
    {
        answer *= n;
        n--;
    }
    return answer;
}
int comb(int n, int r)
{
    return factorial(n) / (factorial(r) * factorial(n - r));
}

long long modpow(long long a, long long n, long long mod)
{
    long long res = 1;
    while (n > 0)
    {
        if (n & 1)
            res = res * a % mod;
        a = a * a % mod;
        n >>= 1;
    }
    return res;
}

//小数点以下10桁テンプレート（main関数内の最初に貼付け）
//std::cout << std::fixed << std::setprecision(10);

//----------------------------------------------------------------


int main(){
ll a,b;
cin>>a>>b;
ll ans=-infll;
chmax(ans,a+b);
chmax(ans,a-b);
chmax(ans,a*b);
cout<<ans<<endl;
}









Measured memory_bytes: 256
#include <iostream>
#include <cmath>
#include <vector>

#define MAX_N 44

using namespace std;

int fibonacci[MAX_N];

int fibo(int n){
  if(fibonacci[n]>0){
    return fibonacci[n];
  }else{
    if(n==0 || n==1){
      fibonacci[n]=1;
      return fibonacci[n];
    }else{
      fibonacci[n]=fibo(n-1)+fibo(n-2);
      return fibonacci[n];
    }
  }
}

  


int main(){
  for(int i=0;i<MAX_N;i++){
    fibonacci[i] = 0;
  }


  int n;
  cin >> n;
  cout << fibo(n) << endl;
  
}

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

P = list(input().split())
N = int(P[0])
M = int(P[1])

A = list(input().split())
A = [int(i) for i in A]
SUM_A = sum(A)

if N >= sum(A):
    ans = N - sum(A)
    print(ans)
else:
    print(-1)

Measured memory_bytes: 10120
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        Scanner input = new Scanner(System.in);
        int a = input.nextInt();
        int b = input.nextInt();
        int c = input.nextInt();
        int k = input.nextInt();
        int sum = 0;
        if(k<=a){
            sum += k;
        }else{
            sum += a;
            int k2 = k-a;
            if(k2<=b){
                sum += 0;
            }else{
                sum -= k2-b;
            }
        }

        System.out.println(sum);

    }
}

Measured memory_bytes: 27052
import sys
s=input()
k=int(input())

s_2=s*2
pre=""
ans=0

if s.count(s[0])==len(s):
  print((len(s)*k)//2)
  sys.exit()

for i in range(len(s)):
  if pre==s[i]:
    ans+=1
    pre=""
  else:
    pre=s[i]

pre=""
ans1=0
for i in range(len(s_2)):
  if pre==s_2[i]:
    ans1+=1
    pre=""
  else:
    pre=s_2[i]

if 2*ans<ans1:
  print(ans+(k-1)*(ans1-ans))
else:
  print(ans*k)


Measured memory_bytes: 9128
import numpy as np
w,h,n=map(int,input().split())
li=[list(map(int,input().split())) for i in range(n)]
#[[x1,y1,a1],[x2,y2,a2]]
a=np.zeros((h,w))

for i in range(n):
    lis=li[i]
    if lis[2]==1:
        a[:,:lis[0]]=1
    elif lis[2]==2:
        a[:,lis[0]:]=1
    elif lis[2]==3:
        a[:lis[1],:]=1
    elif lis[2]==4:
        a[lis[1]:,:]=1

print(np.count_nonzero(a==0))

Measured memory_bytes: 12484
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int N = sc.nextInt();
    int N3 = N / 100;
    int N1 = N % 10;
    if (N1 == N3) {
      System.out.println("Yes");
    } else {
      System.out.println("No");
    }
  }
}

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

#define 	pi				3.1415926536
#define 	mod 			1000000007
#define 	ll  			long long int
#define 	rep(i, a, b) 	for(int i = a ; i < b ; i++)
#define     repn(i, a, b)   for(int i = a ; i > b ; i--)
#define 	mod1 			1000003
#define     mod2            998244353
#define 	hi   			"hello"
#define 	nl 				"\n"
#define 	ws 				" "
#define     sz              size()
#define 	F 				first
#define 	S 				second
#define 	PB 				push_back
#define 	MP				make_pair
#define 	B 				begin()
#define 	E 				end()
#define 	all(v) 			v.begin(), v.end()
#define 	reset(a, val) 	memset(a, val, sizeof(a))
#define 	vi 				vector<int>
#define     vll             vector<long long int>
#define     pii             pair<int, int>
#define 	vs 				vector<string>
#define     vc              vector<char>
#define 	print1(a) 		for(auto i : a)cout<<i<<" ";cout<<"\n"
#define 	print2(a) 		for(auto i : a)cout<<i;cout<<"\n"
#define 	io   			ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL)

using namespace std;

//fixed<<setprecision(9);
//max_element(mp.begin(), mp.end(), compare)
// __gcd(a, b);

bool sortbysec(const pair<int, int> &a, const pair<int, int> &b) { return (a.second < b.second); }

bool compare(const pair<string, int>&a, const pair<string, int>&b){ return a.second<b.second; }

void solve()
{
    ll n, tmp; cin>>n;
    vll a(n, 0);
    rep(i, 0, n-1){
        cin>>tmp;
        a[tmp-1]++;
    }
    print1(a);
}

int main()
{
    //io;
    int t = 1, k = 1;
    // cin>>t; 
    while(t--){
        // cout<<"Case #"<<k<<": ";
        solve();
        k++;
    }
}


Measured memory_bytes: 4840
'use strict'
// inputに入力データ全体が入る
function Main(input) {
	// 1行目がinput[0], 2行目がinput[1], …に入る
	input = input.split("\n");
  let line1 = input[0].split(" ");
  let n = line1[0];

  let A = input[1].split(" ");

  let isOK = true;

  for(let i=0; i<A.length; i++) {
    if(A[i]%2 === 0) {
      if(A[i]%3 !== 0 && A[i]%5 !== 0) {
        isOK = false;
      }
    }
  }

  if(isOK) console.log("APPROVED");
  else console.log("DENIED");

}

Main(require("fs").readFileSync("/dev/stdin", "utf8"));

Measured memory_bytes: 7372
#include <iostream>
#include<bits/stdc++.h>
using namespace std;
const int N=1e5+5;

int main()
{

long long n;
cin>>n;
if(n%2!=0){cout<<0;
    return 0;}
else{

    long long int s=10*5;
    long long res=n/10;
  while(s<=n)
  {

      res+=(n/s);
      s*=5;

  }


cout<<res;



}

    return 0;
}

Measured memory_bytes: 256
N=int(input())
li=list(map(int,input().split()))
if N%2==0:
    ans_normal=li[::2]
    ans_rev=li[1::2]
else:
    ans_rev=li[::2]
    ans_normal=li[1::2]  
ans_rev.reverse()
ans=ans_rev+ans_normal
for n in range(N):
    ans[n]=str(ans[n])
print(' '.join(ans))

Measured memory_bytes: 121972
//e4 - e5 - f4
//#include <boost/multiprecision/cpp_int.hpp> 
#include "bits/stdc++.h"
#include "ext/pb_ds/assoc_container.hpp"
#include "ext/pb_ds/tree_policy.hpp"
typedef long long int ll;
typedef double db;
// __int128 s128;
// __uint128_t u128;
typedef unsigned long long u64;
#define int long long int
#define P 1000000007
#define Q 1000000006
#define sz(a) (ll)a.size()
#define lt(a) (ll)a.length()
#define pll pair<ll,ll>
#define f(i,a,b) for(ll i=(ll)a;i<(ll)b;i++)
#define bac(i,a,b) for(ll i=(ll)a;i>=(ll)b;i--)
#define mll map<ll,ll>
#define umll unordered_map<ll,ll>
#define vl vector<ll>
#define vvl vector<vector<ll>>
#define mt make_tuple
#define eb emplace_back
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define teevra_gati ios_base::sync_with_stdio(false);cin.tie(NULL);cout.tie(NULL);
#define N 100005
#define PI 3.14159265359
#define inf LLONG_MAX
//using namespace boost::multiprecision; 
using namespace __gnu_pbds;
using namespace std;

void solve(){
    ll n;
    cin>>n;
    mll m;
    f(i,0,n){
        ll x;
        cin>>x;
        m[x]++;
    }
    ll ans = n;
    if(m[1]>0){
        if(m[1]==1) cout<<1;
        else cout<<0;
        return;
    }
    for(auto u:m){
        ll i = u.F, f = u.S;
        if(u.S > 1) ans -= f;
        else{
            for(ll j=2; j*j<=i; j++){
                if(i%j==0 && (m.count(j)>0 || m.count(i/j)>0)){
                    ans -= f;
                    break;
                }
            }
        }
    }
    cout<<ans;
}

signed main() {
    teevra_gati
        
    solve();

    return 0;
}

Measured memory_bytes: 16052
# 配るDP

N=int(input())

dp = [100000] * 200005;

g = [1]
a = 6
while a <= 100000:
  g.append(a)
  a *= 6
a = 9
while a <= 100000:
  g.append(a)
  a *= 9
g.sort(reverse=True)

dp[0] = 0
for i in range(N):
  for j in g:
    dp[i+j] = min( dp[i+j], dp[i]+1 )

print(dp[N])



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

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

    int x,y,z;
    vector<int> box;
    cin>>x>>y>>z;

    if(x<1 || y<1 || z<1)
    {
        return 0;
    }

    if(x>100 || y>100 || z>100)
    {
        return 0;
    }

    /*box.push_back(x);
    box.push_back(y);
    box.push_back(z);*/

    int a1,a2, a3;

    a1 = x;
    a2 = y;
    a3 = z;

    box.push_back(y);
    box.push_back(x);
    box.push_back(z);

    box.at(0) = z;
    box.at(2) = y;

    for(int i=0; i<3; i++)
    {
        cout<<box.at(i)<<" ";
    }

    cout<<endl;

    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <vector>
#include <string>
#include <cmath>
#include <set>
#include <algorithm>
#include <array>
#include <complex>
#include <string>
#include <utility>
#include <map>
#include <queue>
#include <list>
#include <functional>
#include <numeric>
#include <stack>
#include <tuple>

using namespace std;
int dx[4] = { -1,0,1,0 };
int dy[4] = { 0,1,0,-1 };
const int INF = 100000000;
const long long LINF = 1000000000000000000;
const int MOD = (int)1e9 + 7;
const double EPS = 1e-6;
using pii = std::pair<int, int>;
using ll = long long;
using pLL = std::pair<ll, ll>;
#define SORT(v) std::sort(v.begin(), v.end())
using Matrix = vector<vector<int>>;
Matrix d;
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    d = Matrix(n, vector<int>(n, 0));
    for (int i = 0; i < n; ++i) {
        int u,k;
        cin >> u >> k;
        u--;
        for (int j = 0; j < k; ++j) {
            int v;
            cin >> v;
            d[u][v-1] = 1;
        }
    }
    for (int i = 0; i < n; ++i) {
        for (int j = 0; j < n; ++j) {
            if(j!=n-1)cout << d[i][j] << " ";
            else cout << d[i][j] << endl;
        }

    }
    return 0;
}



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

using namespace std;

void solve(){
	int n,l,r; cin>>l>>r>>n;
	int c = 0;
	for(int i = l; i <= r; i++){
		if(i%n==0){
			c++;
		}
	}
	cout << c << "\n";
}

int main(){
	#ifndef ONLINE_JUDGE
    freopen("input.txt", "r", stdin);
    freopen("output.txt", "w", stdout);
	#endif
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	long long int t = 1;
	while(t--){
		solve();
	}
	return 0;
}


Measured memory_bytes: 3616
#include <iostream>
#include <algorithm>
#include <set>

using namespace std;

int main()
{
    int N, M;
    cin >> N;
    set<int> Set;
    
    for(int i = 0; i < N; ++i)
    {
        int Num; cin >> Num;
        Set.insert(Num);
    }
    
    cin >> M;
    
    for(int i = 0; i < M; ++i)
    {
        int Num;
        cin >> Num;
        if(Set.find(Num) == Set.end())
        {
            cout << 0 << endl;
            return 0;
        }
        
    }
    
    cout << 1 << endl;
    
    return 0;
    
}


Measured memory_bytes: 12472
#include<bits/stdc++.h>
using namespace std;
#define int long long int
#define until(x) while(!(x))
#define unless(x) if(!(x))
#define all(x) (x).begin(),(x).end()
#define F first
#define S second
#define pc __builtin_popcount

int32_t main(){
	int n,a,b;
	cin>>n>>a>>b;
	cout<<a*(n/(a+b))+min(a,n%(a+b));
}


Measured memory_bytes: 256
#include <iostream>

int main() {
  int K;
  std::cin >> K;
  int A, B;
  std::cin >> A >> B;

  for (int i = A; i <= B; ++i) {
    if (i % K == 0) {
      std::cout << "OK" << std::endl;
      return 0;
    }
  }

  std::cout << "NG" << std::endl;

  return 0;
}


Measured memory_bytes: 3636