akhauriyash/Code-Regression huggingface dataset:
MOD = 1000000007
class ModInt:
    def __init__(self, x):
        self.x = x % MOD

    def __str__(self):
        return str(self.x)

    __repr__ = __str__

    def __add__(self, other):
        return (
            ModInt(self.x + other.x) if isinstance(other, ModInt) else
            ModInt(self.x + other)
        )

    def __sub__(self, other):
        return (
            ModInt(self.x - other.x) if isinstance(other, ModInt) else
            ModInt(self.x - other)
        )

    def __mul__(self, other):
        return (
            ModInt(self.x * other.x) if isinstance(other, ModInt) else
            ModInt(self.x * other)
        )

    def __truediv__(self, other):
        return (
            ModInt(
                self.x * pow(other.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(self.x * pow(other, MOD - 2, MOD))
        )

    def __pow__(self, other):
        return (
            ModInt(pow(self.x, other.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(self.x, other, MOD))
        )

    __radd__ = __add__

    def __rsub__(self, other):
        return (
            ModInt(other.x - self.x) if isinstance(other, ModInt) else
            ModInt(other - self.x)
        )

    __rmul__ = __mul__

    def __rtruediv__(self, other):
        return (
            ModInt(
                other.x * pow(self.x, MOD - 2, MOD)
            ) if isinstance(other, ModInt) else
            ModInt(other * pow(self.x, MOD - 2, MOD))
        )

    def __rpow__(self, other):
        return (
            ModInt(pow(other.x, self.x, MOD)) if isinstance(other, ModInt) else
            ModInt(pow(other, self.x, MOD))
        )
      
n = int(input())
a = ModInt(1)
b = ModInt(1)
w = ModInt(1)
for i in range(n):
  a *= 9
  b *= 8
  w *= 10
  
ex = a * 2 - b
ans = w - ex
print(ans)

Measured memory_bytes: 9352
#include <bits/stdc++.h>
#define INF (1<<30)
#define MOD 1000000007
#define l_ength size
using ll = long long;
using namespace std;

int main(){
	const int n = 100000;
	vector<int> v;
	for( int i = 2; i < n; ++i ){
		bool flag = false;
		int m = i;
		for( int j = 2; j*j <= i; ++j ){	
			if( m%j == 0 ){
				flag = true;
				break;
			}
		}
		if( flag ) continue;
		else v.push_back(i);
	}
	vector<int> sum(n+1, 0);
	for( int i = 1; i < n; i += 2 ){
		if( i != 1 ) sum[i] += sum[i-2];
		if(
			binary_search( v.begin(), v.end(), i )
			&&
			binary_search( v.begin(), v.end(), (i+1)/2 )
		){
			sum[i] += 1;
		}
	}
	int q; cin >> q;
	for( int i = 0; i < q; ++i ){
		int l, r; cin >> l >> r;
		int sl, sr;
		sl = ( l == 1 ) ? 0 : sum[l-2];
		sr = ( r == 1 ) ? 0 : sum[r];
		cout << sr - sl << endl;;
	}
	return 0;
}

Measured memory_bytes: 1152
#include <iostream>
#include <string>
#include <vector>
#include <climits>
#include <set>
#include <algorithm>
#include <unordered_map>
#include <queue>
#include <iomanip>
#include <map>
#include <utility>
#include <numeric>
#include <chrono>
#include <ctime>
#include <bitset>
#include <iterator>
#include <cmath>
#include <stack>

#define rep(i,n) for(int i=0; i<(int)(n); i++)
#define debug(x) cerr << #x << ": " << x << ", "
#define debugln(x) cerr << #x << ": " << x << '\n'

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; }

using namespace std;
using ll = long long;
using P = pair<ll, ll>;

typedef bitset<5200> bs;

constexpr ll mod = 1e9 + 7;
const double PI = acos(-1.0);

vector<int> graph[100005];
vector<int> graph2[100005];
vector<int> cnt(100005);
vector<int> sorted;
vector<int> rev(100005);
vector<int> used(100005);

int main() {
  ios_base::sync_with_stdio(false);
  cin.tie(nullptr);

  int n, m; cin >> n >> m;
  int p = n-1+m;
  rep(i, p) {
    int a, b; cin >> a >> b;
    graph[a].push_back(b);
    graph2[b].push_back(a);
    cnt[b]++;
  }

  stack<int> st;
  for(int i=1; i<=n; i++) {
    if (cnt[i] == 0) {
      st.push(i);
    }
  }

  while(st.size() > 0) {
    int a = st.top(); st.pop();
    sorted.push_back(a);
    used[a] = true;
    for(auto e: graph[a]) {
      if (!used[e]) {
        cnt[e]--;
        if (cnt[e] == 0) {
        st.push(e);
        }
      }
    }
  }


  for(int i=0; i<n; i++) {
    rev[sorted[i]] = i;
  }
  //debugln("piyo");
  for(int i=1; i<=n; i++) {
    int ret = 0;
    for(auto e: graph2[i]) {
      if (ret == 0) {
        ret = e;
      }
      if (rev[e] > rev[ret]) {
        ret = e;
      }
    }
    cout << ret << '\n';
  }
}

Measured memory_bytes: 13436
#include<bits/stdc++.h>
using namespace std;
string s;
int q;
char c;
int f;
int t;
string pre,suf;
bool order;
int main()
{
	//freopen("input.txt","r",stdin);
	order=true;
	cin>>s;
	cin>>q;
	while(q--)
	{
		cin>>t;
		if(t==1) order^=1; //!!
		else
		{
			cin>>f;
			if(f==1) 
			{
				cin>>c;
				if(order) pre+=c;
				else suf+=c;
			}
			else
			{
				cin>>c;
				if(order) suf+=c;
				else pre+=c;
			}
		}
	}
	if(order)
	{
		reverse(pre.begin(),pre.end());
		cout<<pre<<s<<suf<<endl;
	}
	else
	{
		reverse(suf.begin(),suf.end());
		reverse(s.begin(),s.end());
		cout<<suf<<s<<pre<<endl;
	}
	return 0;
}




Measured memory_bytes: 1088
#include<stdio.h>
int main(){
  int a,b;
  scanf("%d %d",&a,&b);
  if(a<b){
    printf("a < b\n");
  }else if(a==b){
    printf("a == b\n");
  }else{
    printf("a > b\n");
  }
  return 0;
}

Measured memory_bytes: 580
#include <iostream>
#include <algorithm>

using namespace std;
static const int MAX = 200000;

int main() {
  int R[MAX], n;
  cin >> n;
  for ( int i = 0; i < n; i++ ) cin >> R[i];
  int maxv = -2000000000;
  
  int minv = R[0];

  for ( int i = 1; i < n; i++) {
    maxv = max(maxv, R[i] - minv);
    minv = min(minv, R[i]);
  }
  cout << maxv << endl;

  return 0;
}



Measured memory_bytes: 3876
h, w = map(int, input().split())

ans = 0
if h == 1 or w == 1:
    ans = 1
else:
    if w % 2 == 0:
        ans += (w//2)*h
    else:
        if h % 2 == 0:
            ans += (h//2)*(w//2*2+1)
        else:
            ans += (h//2)*(w//2*2+1)+(w//2+1)
print(max(1, ans))


Measured memory_bytes: 3060
#include <stdio.h>
#include <string.h>
#include <iostream>

int main() {
  using namespace std;
  
  int ballCount;
  cin >> ballCount;
  
  int *ballno;
  ballno = new int[ballCount];
  for (int i=0, *p = ballno ; i<ballCount ; i++) {
    cin >> *p;
    p++;
  }
  
  int dicCount = ballCount+1;
  int *dic = new int[dicCount];
  int dicBytes = dicCount<<2;
  
  memset(dic, 0, dicBytes);
  for (int i=0 ; i<ballCount ; i++) {
    dic[ballno[i]]++;
  }

  unsigned long int sum = 0;
  for (int i=0, *p = dic; i<dicCount ; i++, p++) {
    if (*p > 1) {
      sum += ((unsigned long int)*p) * (*p - 1);
    }
  }
  sum >>= 1;
  
  for (int k=0 ; k<ballCount ; k++) {
    int m = dic[ballno[k]];
    m = ((m-1) * -2) >> 1;
    printf("%lld\r\n", sum + m);
  }
  
  delete[] ballno, dic;
}


Measured memory_bytes: 4352
#include <algorithm>
#include <bitset>
#include <cmath>
#include <functional>
#include <iomanip>
#include <iostream>
#include <limits>
#include <map>
#include <queue>
#include <set>
#include <tuple>
#include <vector>

using namespace std;

#define rep(i, n) for (int64_t i = 0; i < (int64_t)(n); i++)
#define irep(i, n) for (int64_t i = 0; i <= (int64_t)(n); i++)
#define rrep(i, n) for (int64_t i = (n)-1; i >= 0; i--)
#define rirep(i, n) for (int64_t i = n; i >= 0; i--)

template <int64_t MOD>
class Modint {
  using Self = Modint<MOD>;

  int64_t m_value;

 public:
  Modint(int64_t value) : m_value((value % MOD + MOD) % MOD) {}
  Self pow(int64_t e) const {
    if (e == 0) {
      return (Self)1;
    } else if (e % 2 == 0) {
      return ((*this) * (*this)).pow(e / 2);
    } else {
      return (*this).pow(e - 1) * (*this);
    }
  }
  Self inv() const { return pow(MOD - 2); }
  Self& operator=(const Self& rh) {
    m_value = rh.m_value;
    return *this;
  }
  Self operator-() const { return Self(-m_value); }
  Self operator+(const Self& other) const {
    return Self(m_value + other.m_value);
  }
  Self operator-(const Self& other) const {
    return Self(m_value - other.m_value);
  }
  Self operator*(const Self& other) const {
    return Self(m_value * other.m_value);
  }
  Self operator/(const Self& other) const { return (*this) * other.inv(); }
  Self& operator+=(const Self& rh) { return (*this) = (*this) + rh; }
  Self& operator-=(const Self& rh) { return (*this) = (*this) - rh; }
  Self& operator*=(const Self& rh) { return (*this) = (*this) * rh; }
  Self& operator/=(const Self& rh) { return (*this) = (*this) / rh; }
  int64_t value() const { return m_value; }
};

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

  using Mint = Modint<1'000'000'007>;

  const int N = K + s.size();
  vector<Mint> fact(N + 1, 1);
  rep(i, N) { fact[i + 1] = fact[i] * (i + 1); }

  Mint result = 0;
  Mint p = Mint(26).pow(K);
  Mint i26 = Mint(26).inv();
  irep(i, K) {
    Mint v = fact[s.size() + i - 1] / fact[i] * p;
    result += v;

    p *= Mint(25) * i26;
  }
  result /= fact[s.size() - 1];

  cout << result.value() << endl;

  return 0;
}

Measured memory_bytes: 20072
def get_i() #空白区切の入力を数値(整数)の配列で返す
  return gets.chomp.split(" ").map(&:to_i)
end
def get_f() #空白区切の入力を数値(実数)の配列で返す
  return gets.chomp.split(" ").map(&:to_f)
end
def get() #空白区切の入力を文字列の配列で返す
  return gets.chomp.split(" ")
end
def get_nsp() #入力されたものを一文字ずつに区切った文字列の配列で返す
  return gets.chomp.split("")
end
def yn_judge(bool,y="Yes",n="No") #boolに真偽を投げることで、trueならy、falseならnの値を出力する
  return bool ? y : n 
end
def array(size1,init=nil,size2=-1) #size2に二次元配列時の最初の要素数、size1に次の配列の大きさ、initに初期値を投げることでその配列を返す
  if size2==-1
    return Array.new(size1){init}
  else
    return Array.new(size2){Array.new(size1){init}}
  end
end

N=gets.to_i
ans=1
N.times do|i|
    ans=ans.lcm(gets.to_i)
end
puts ans

Measured memory_bytes: 1788
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
using namespace std;
int main(){
long long int a;
  string s;

cin >> s;
  if(atoi(s.substr(0, 4).c_str())<2019)
	cout << "Heisei";
  else if(atoi(s.substr(0, 4).c_str())==2019)
    if(atoi(s.substr(5, 2).c_str())<=4)
      cout << "Heisei";
    else
      cout << "TBD";
  else
    cout << "TBD";
return 0;
}

Measured memory_bytes: 256
n = gets.to_i
monsters = gets.split.map(&:to_i)
warriors = gets.split.map(&:to_i)
count = 0

(0..n-1).each do |i|
  count += [monsters[i], warriors[i]].min
  warriors[i] = [warriors[i] - monsters[i], 0].max
  count += [monsters[i+1], warriors[i]].min
  monsters[i+1] = [monsters[i+1] - warriors[i], 0].max
end

puts count

Measured memory_bytes: 19612
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
int main() {
    int n,m,x,ans = 1e9;
    cin >> n >> m >> x;
    int c[n],d[n][m];
    rep(i,n){
        cin >> c[i];
        rep(j,m){
            cin >> d[i][j];
        }
    }
    for(int i=0;i<(1<<n);i++){//bit全探索
        int e[12]={},f=0;
        bitset<12> a(i);
        rep(j,n){
            if(a.test(j)){
                rep(k,m) e[k] += d[j][k];
                f += c[j];
            }
        }
        int flag = 1;
        rep(k,m){
            if(e[k]<x) flag = 0;
        }
        if(flag) ans = min(ans,f);
    }
    if(ans==1e9) cout << -1 << endl;
    else cout << ans << endl;
}

Measured memory_bytes: 3644
n = int(input())
xs = [int(elem) for elem in input().split()]
 
min_ = min(xs)
max_ = max(xs)
result = []
for p in range(min_, max_+1):
  res = 0
  for x in xs:
    res += (x - p) ** 2
  result.append(res)
print(min(result))

Measured memory_bytes: 3060
import java.util.Scanner;

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

        int n, x;
        int count = 0;
        while(true){
            n = scanner.nextInt();
            x = scanner.nextInt();
            if(n == 0 && x == 0){
                break;
            }
            count = 0;
            for(int a = n; a > 0; a--){
                for(int b = n; b > 0; b--){
                    for(int c = n; c > 0; c--){
                        if(x == (a+b+c) && a != b && b != c && c != a){
                            count++;
                        }
                    }
                }
            }
            System.out.println(count/6);
        }


        scanner.close();
    }
}



Measured memory_bytes: 26640
using System;
using System.Text;
using System.Linq;
using System.Collections;
using System.Collections.Generic;
using static System.Console;
using static System.Math;

namespace AtCoder
{
    public class Program
    {
        public static void Main(string[] args)
        {
            new Program().Solve(new ConsoleInput(Console.In, ' '));

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var X = cin.ReadLong;
            var m = cin.ReadLongArray(N);

            var nokori = X - m.Sum();
            var ans = nokori / m.Min() + m.Length;

            WriteLine(ans);
        }
    }

    public static class Extensions
    {
        public static string Reverse(this string sourse)
        {
            char[] chrAry = sourse.ToCharArray();
            Array.Reverse(chrAry);
            return new string(chrAry);
        }
    }

    public class ConsoleInput
    {
        private readonly System.IO.TextReader _stream;
        private char _separator = ' ';
        private Queue<string> inputStream;
        public ConsoleInput(System.IO.TextReader stream, char separator = ' ')
        {
            this._separator = separator;
            this._stream = stream;
            inputStream = new Queue<string>();
        }
        public string Read
        {
            get
            {
                if (inputStream.Count != 0) return inputStream.Dequeue();
                string[] tmp = _stream.ReadLine().Split(_separator);
                for (int i = 0; i < tmp.Length; ++i)
                    inputStream.Enqueue(tmp[i]);
                return inputStream.Dequeue();
            }
        }
        public string ReadLine { get { return _stream.ReadLine(); } }
        public int ReadInt { get { return int.Parse(Read); } }
        public long ReadLong { get { return long.Parse(Read); } }
        public double ReadDouble { get { return double.Parse(Read); } }
        public string[] ReadStrArray(long N) { var ret = new string[N]; for (long i = 0; i < N; ++i) ret[i] = Read; return ret; }
        public int[] ReadIntArray(long N) { var ret = new int[N]; for (long i = 0; i < N; ++i) ret[i] = ReadInt; return ret; }
        public long[] ReadLongArray(long N) { var ret = new long[N]; for (long i = 0; i < N; ++i) ret[i] = ReadLong; return ret; }
    }
}


Measured memory_bytes: 13396
#include<stdio.h>
#define FOR(i,m,n) for(i=m;i<n;i++)
#define rep(i,n) FOR(i,0,n)
#define MAX 100
 
double max(double a,double b){return a>b?a:b;}
 
int main(void)
{
  int n,m,i,j,k;
  double g[MAX][MAX],dp[MAX+1][MAX],res;//mñÚ,níÞ
  for(;;){
    scanf("%d%d",&n,&m); if(!n)break;
    memset(dp,0,sizeof(dp));
    rep(i,n)dp[0][i]=1.0;
    rep(i,n)rep(j,n)scanf("%lf",g[i]+j);
    rep(i,m)rep(j,n)rep(k,n){
      dp[i+1][k]=max(dp[i+1][k],dp[i][j]*g[j][k]);
    }
    res=0;
    rep(i,n)res=max(res,dp[m-1][i]);
    printf("%.2f\n",res);
  }
  return 0;
}

Measured memory_bytes: 0
#include<stdio.h>
#include<stdlib.h>
#include<string.h>
 
struct node{
  struct node *prev;
  int number;
  struct node *next;
};
 
typedef struct node* NodePointer;
 
NodePointer N;
 
void init(void);
void insert(int);
void delete(int);
void deleteFirst(void);
void deleteLast(void);
void printList(void);
 
int main(){
  int i, n, a;
  char buf[12];
 
  scanf("%d",&n);
 
  init();
 
  for(i = 1; i <= n; i++){
    scanf("%s",buf);
 
    if(strcmp(buf, "deleteFirst") == 0) deleteFirst();
 
    else if(strcmp(buf, "deleteLast") == 0) deleteLast();
 
    else if(strcmp(buf, "insert") == 0 || strcmp(buf, "delete") == 0){
      scanf("%d",&a);
 
      if(strcmp(buf, "insert") == 0) insert(a);
 
      else delete(a);
    }
  }
 
  printList();
 
  return 0;
}
 
void init(void){
  N = malloc(sizeof(struct node));
  N->next = N;
  N->prev = N;
}
 
void insert(int a){
  NodePointer new;
  static int count = 0;
 
  new = malloc(sizeof(struct node));
 
  new->number = a;
   
  if(count == 0){
    new->next = N;
    N->next = new;
    new->prev = N;
    N->prev = new;
    count++;
  }
 
  else{
    new->next = N->next;
    N->next->prev = new;
    N->next = new;
    new->prev = N;
    count++;
  }
}
 
void delete(int a){
  int judge = 0;
  NodePointer x;
  NodePointer y; 
   
  for(y = N->next; y != N; y = y->next){
    if(y->number == a){
      judge = 1;
    }
  }
   
  if(judge == 1){
    y = N->next;
 
    while(y != N){
      if(y->number == a) break;
      y = y->next;
    }
 
    x = y->prev;
    x->next = y->next;
    x->next->prev = x;
    free(y);
  }
}
 
void deleteFirst(void){
  NodePointer x = N->next;
  N->next = x->next;
  x->next->prev = N;
}
 
void deleteLast(void){
  NodePointer x = N->prev;
  N->prev = x->prev;
  x->prev->next = N;
  free(x);
}
 
void printList(void){
  NodePointer x = N->next;
  int y = 1;
 
  while(x != N){
    if (y == 0) printf(" ");
    printf("%d", x->number);
    x = x->next;
    y = 0;
  }
 
  printf("\n");
}

Measured memory_bytes: 31852
N = int(input())
W = list(map(int,input().split()))
xmin = 10000
S1 = 0
S2 = sum(W)

for i in range(N):
    S1=S1 + W[i]
    S2=S2 - W[i] 
    x = abs(S1-S2)
    if x < xmin:
        xmin = x
print(xmin)

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
 
typedef long long ll;
#define mod 1000000007
 
int gcd(int a, int b) { return b ? gcd(b, a%b) : a; }
 
int lcm(int a, int b) { return a * b / gcd(a, b); }

int main(){
    string s;
    cin >> s;
    int batu_cnt = 0;
    for (int i = 0; i < s.size(); i++){
        if(s[i] == 'x'){
            batu_cnt++;
        }
    }
    if(batu_cnt >= 8){
        cout << "NO" << endl;
    }else{
        cout << "YES" << endl;
    }
    return 0;
}

Measured memory_bytes: 256
import java.util.ArrayList;
import java.util.Collections;
import java.util.Scanner;

public class Main {
	public static void main(String[]args) {
		try(Scanner scan = new Scanner(System.in)){
			
			
			int X = scan.nextInt();
			
			long A = 0;
			long B = 0;
			
			long x = 0;
			long y = 0;
			
			
			ArrayList<Integer>yakusu = enum_div(X);
			
			
			//System.out.println(yakusu.size());
			
			for(int i = 0;i<yakusu.size();i++) {
				A = yakusu.get(i);
				B = X/A;
				
				
				x=0;
				while(true) {
					long z = x*x*x*x*x-(x-A)*(x-A)*(x-A)*(x-A)*(x-A);
					if(z==X) {
						System.out.println(x);
						System.out.println(x-A);
						System.exit(0);
					}
					
					if(x==10000)break;
					
					x++;
				
				}
			
				}
				
				
			}
			
			
		}
		
		
	
	
	
	private static ArrayList<Integer> enum_div(int n){//数字１〜ｎまでの約数を全部Allaylistに詰め込むメソッド
		ArrayList<Integer> ret = new ArrayList<Integer>();
		for(int i = 1;i*i<=n;i++) {
			if(n%i==0) {
				ret.add(i);
				if(i*i!=n){
					ret.add(n/i);
				}
			}
		}
		
		//ただここまでだと格納した約数はソートされてない
		
		Collections.sort(ret);//int型、Sting型くらいの格納した奴ならコレクションクラスのソートが使える。
		//ソートしてからcollections.reverseつかえば降順にもできる
		return ret;
		
		
		
	}
		

}


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

#define int long long
#define endl "\n"
#define REP(i,a,n) for(int i=a;i<n;++i)
#define REPR(i,a,n) for(int i=a;i>n;--i)
#define RUP(a,b) ((a+b-1)/(b))
#define ALL(v) (v).begin(),(v).end()
#define pb push_back
#define mp make_pair
#define mt make_tuple
//#define MOD 1000000007
#define INF LLONG_MAX/2

typedef long long ll;
typedef pair<int,int> Pii;
typedef tuple<int,int,int> Tiii;
typedef vector<int> Vi;
typedef vector<Vi> VVi;
typedef vector<Pii> VPii;
typedef vector<string> Vs;

template<class T> inline bool chmax(T& a,T b){if(a<b){a=b;return 1;}return 0;}
template<class T> inline bool chmin(T& a,T b){if(a>b){a=b;return 1;}return 0;}
template<class T> void YesNo(T a) {cout<<(a?"Yes":"No")<<endl;}
template<class T> void YESNO(T a) {cout<<(a?"YES":"NO")<<endl;}
void vin(Vi &v){REP(i,0,(v).size()) cin>>v[i];}
void vin(Vi &v,Vi &v2){REP(i,0,(v).size()) cin>>v[i]>>v2[i];}
void vout(Vi &v){for(int i=0;i<(v).size();i++) cout<<v[i]<<" ";cout<<endl;}
int gcd(int a,int b){return b?gcd(b,a%b):a;}
int lcm(int a,int b){return a/gcd(a,b)*b;}
void uniq(Vi &v){sort(v.begin(),v.end()); v.erase(unique(v.begin(),v.end()),v.end());}
int ctoi(char c){if(c>='0'&&c<='9'){return c-'0';}return 0;}
void accum(Vi &v){REP(i,1,(v).size()) v[i]+=v[i-1];}
bool comp(Pii a,Pii b){
    if(a.second != b.second) return a.second<b.second;
    else return a.first<b.first;
}

int bitsc(int bits){
    int num  = 0;
    int mask = 1;
    for ( ; mask != 0 ; mask = mask << 1 ){
        if (bits & mask )
            num++;
    }
    return num;
}


// Generated by 1.1.6 https://github.com/kyuridenamida/atcoder-tools  (tips: You use the default template now. You can remove this line by using your custom template)
signed main(){
    int n;
    cin>>n;
    VVi x(n),y(n);
    REP(i,0,n){
        int ai;
        cin>>ai;
        REP(j,0,ai){
            int xi,yi;
            cin>>xi>>yi;
            xi--;
            x[i].pb(xi);
            y[i].pb(yi);
        }
    }

    int ans=0;
    REP(i,0,(1ll<<n)){
        bool check=true;
        REP(j,0,n){
            if(check==false) break;
            REP(k,0,x[j].size()){
                int bit1=0,bit2=0;
                if(i&(1ll<<j)) bit1=1;
                if(i&(1ll<<x[j][k])) bit2=1;
                if(y[j][k]==1){
                    if(bit1==1 && bit2==0) {
                        check=false;
                        break;
                    } 
                }else{
                    if(bit1==1 && bit2==1){
                        check=false;
                        break;
                    }
                }
            }
        }
        if(check==false) {
            continue;
        }
        chmax(ans,bitsc(i));
//        cout<<i<<endl;
    }
    cout<<ans<<endl;
    return 0;
}


Measured memory_bytes: 256
#include<stdio.h>
int main(void){
   int n;
   while(scanf("%d",&n)!=EOF){
      int a[16][16]={0},i,j,k,b,c,x,y;
      x=n/2+2;
      y=n/2+1;
      a[x][y]=1;

      for(i=2;i<=n*n;i++){
         x++;
         y++;

         while(1){
            int flag=0;
            if(y>n){
               y=1;
               flag=1;
            }
            if(x>n){
               x=1;
               flag=1;
            }
            if(a[x][y]!=0){
               x++;
               y--;
               flag=1;
            }
            if(y<1){
               y=n;
               flag=1;
            }
            if(flag==1)continue;
            break;
         }

         a[x][y]=i;
      }

      for(i=1;i<=n;i++){
         for(j=1;j<=n;j++)printf("%4d",a[i][j]);
         puts("");
      }
   }
   return 0;
}

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

#define DEBUG(x) cerr << #x << ": " << x << endl;
#define ll long long

int main() {
    ll n, x;
    cin >> n >> x;
    vector<ll> a(n+1);
    for (int i = 1; i <= n; i++) {
        cin >> a[i];
    }

    ll ans = 0;
    for (int i = 1; i <= n; i++) {
        if (a[i] + a[i-1] > x) {
            ans += (a[i] + a[i-1] - x);
            a[i] -= (a[i] + a[i-1] - x);
        }
    }

    cout << ans << endl;

    return 0;
}

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

//#define int long long
#define rep(i,n) for(int (i)=0;(i)<(int)(n);(i)++)
#define rept(i,n) for(int (i)=0;(i)<=(int)(n);(i)++)
#define reps(i,s,n) for(int (i)=(s);(i)<(int)(n);(i)++)
#define repst(i,s,n) for(int (i)=(s);(i)<=(int)(n);(i)++)
#define repr(i,n) for(int (i)=(n);(i)>=0;(i)--)
#define each(itr,v) for(auto (itr):(v))
#define all(c) (c).begin(),(c).end()
#define pb push_back
#define mp(x,y) make_pair((x),(y))
#define fi first
#define se second
#define chmin(x,y) x=min(x,y)
#define chmax(x,y) x=max(x,y)
#define ln '\n'
#define dbg(x) cout<<#x" = "<<(x)<<ln

typedef long long ll;
typedef vector<int> vi;
typedef vector<ll> vl;
typedef vector<vector<int> > mat;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;

const int inf = (int)1e9;
const ll linf = (ll)1e18;
const int mod = (int)(1e9+7);
const int dx[] = {0, 1, 0, -1};
const int dy[] = {1, 0, -1, 0};
const int ddx[] = {0, 1, 1, 1, 0, -1, -1, -1};
const int ddy[] = {1, 1, 0, -1, -1, -1, 0, 1};
const double eps = 1e-10;

struct oreno_initializer {
	oreno_initializer() {
		cin.tie(0);
		ios::sync_with_stdio(0);
	}
} oreno_initializer;

// ━━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…
// .｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋.｡.:( ^ω^)・ﾟ＋
// ・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・‥…━━━☆・

int n, a, b;

signed main() {
	cin >> n >> a >> b;
	if (b-a==1) cout << "Borys" << ln;
	else if ((b-a)%2==0) cout << "Alice" << ln;
	else cout << "Borys" << ln;
}

Measured memory_bytes: 892
using System;
using System.Collections.Generic;
class Program
{
	static void Main(string[] args)
	{
		string str = Console.ReadLine();
		long N = long.Parse(str);
		long ans = 0;
		for(var i=1;i<=N;i++){
			if(i%2!=0){
				long t = 0;
				for(var j=1;j<=i;j++){
					if(i%j==0){
						t += 1;
					}
				}
				if(t == 8){
					ans +=　1;
				}
			}
		}
		Console.WriteLine(ans);
	}
}

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

using namespace std;
typedef long long ll;

int main() {
  cin.tie(0);
  ios_base::sync_with_stdio(false);
  
  int a, b, c, x;
  cin >> a >> b >> c >> x;

  int ans = 0;
  for (int i = 0; i <= a; i++) {
    for (int j = 0; j <= b; j++) {
      for (int k = 0; k <= c; k++) {
        ans += (i * 500 + j * 100 + k * 50 == x);
      }
    }
  }
  cout << ans << endl;

  return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
int main()
{
	int use1[200],use2[200],count=1;
	memset(use1,0,sizeof(use1));
	memset(use2,0,sizeof(use2));
	string s1,s2;
	cin>>s1>>s2;
	for(int i=0;i<s1.length();i++)
	{
		if(use1[s1[i]]==0) {use1[s1[i]]=count;s1[i]=count;count++;}
		else s1[i]=use1[s1[i]];
	}
	count=1;
	for(int i=0;i<s2.length();i++)
	{
		if(use2[s2[i]]==0) {use2[s2[i]]=count;s2[i]=count;count++;}
		else s2[i]=use2[s2[i]];
	}
	if(s1==s2) cout<<"Yes";
	else cout<<"No";
}

Measured memory_bytes: 776
#include <bits/stdc++.h>
typedef long long int lli;
using namespace std;
#define DADAH ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
int main()
{
#ifdef _DEBUG
    freopen("input.txt", "r", stdin);
//	freopen("output.txt", "w", stdout);
#endif
    DADAH

    lli n;
cin>>n;
    if(n==1)cout<<"1";
    else if(n%2==0)cout<<n/2;
    else cout<<n/2+1;



        return 0;

}


Measured memory_bytes: 256
def reduce(x):
	return x-1
def sum(lst):
	cnt = 0
	for i in range(0, len(lst)):
		cnt += lst[i]
	return cnt
def calc(lst):
	if lst == []: return 0
	elif 0 in lst:
		lstlst = []
		newlst = []
		for i in range(0, len(lst)):
			if lst[i] == 0:
				lstlst.append(newlst)
				newlst = []
			else:
				newlst.append(lst[i])
		lstlst.append(newlst)
		return sum(map(calc, lstlst))
	else: return 1 + calc(map(reduce, lst))
	
N = int(raw_input())
h = map(int, raw_input().split())

print calc(h)

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

int main() {
    int n;
    cin >> n;
    int t[110000];
    int x[110000];
    int y[110000];
    t[0] = x[0] = y[0] = 0;
    for (int i = 0; i < n; i++) {
        cin >> t[i + 1] >> x[i + 1] >> y[i + 1];
    }
    bool can = true;
    for (int i = 0; i < n; i++) {
        int dt = t[i + 1] - t[i];
        int dist = abs(x[i + 1] - x[i]) + abs(y[i + 1] - y[i]);
        if (dt < dist) can = false;
        if (dist % 2 != dt % 2) can = false;
    }
    if (can)
        cout << "Yes" << endl;
    else
        cout << "No" << endl;

    return 0;
}


Measured memory_bytes: 4628
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
const int MOD=1e9+7;
const int INF=1e9;

int main(){
    int n,k;
    cin>>n>>k;
    vector<int> ng;
    for(int i=0;i<k;i++){
        int d;
        cin>>d;
        ng.push_back(d);
    }
    for(int i=n;;i++){
        string s=to_string(i);
        bool flag=true;
        for(char c:s){
            for(int num:ng){
                if(c-'0'==num)flag=false;
            }
        }
        if(flag){
            cout<<i<<endl;
            return 0;
        }
    }
}


Measured memory_bytes: 256
#ifndef ONPC
  #define _FORTIFY_SOURCE 0
  #pragma GCC optimize("Ofast")
  #pragma GCC optimize("no-stack-protector")
  #pragma GCC optimize("unroll-loops")
  #pragma GCC target("sse,sse2,sse3,ssse3,popcnt,abm,mmx,tune=native")
  #pragma GCC optimize("fast-math")
#endif

#include <bits/stdc++.h>

#define mp make_pair
#define eb emplace_back
#define ff first
#define ss second

using namespace std;

typedef long long ll;
typedef unsigned long long ull;

#ifdef ONPC
mt19937 rnd(228);
#else
mt19937 rnd(chrono::steady_clock::now().time_since_epoch().count());
#endif


const int MAXN = 100;
#define int long long
const int INF = 1e9;

signed main()
{
    #ifdef FILEIO
      freopen("input.txt", "r", stdin);
      freopen("output.txt", "w", stdout);
    #endif

    ios_base::sync_with_stdio(0);
    cin.tie(0);

    int n;
    cin >> n;

    if (n == 2LL){
      cout << 1LL << '\n';
      return 0;
    }

    int cnt = 2LL;

    // n-1 divs
    int nn = n-1LL;
    int sq = sqrt(nn) + 1LL;
    for (int i = 2LL; i < sq; ++i) {
      if (nn % i == 0) cnt += 2;
      if (nn % i == 0 && i == n/i) cnt--;
    }
    //cerr << cnt << '\n';

    sq = sqrt(n) + 1LL;
    for (int i = 2LL; i < sq; i++){
      if (n % i == 0){
        int c = n;
        while (c % i == 0) c /= i;
        c = c % i;
        if (c == 1) cnt++;

        c = n;
        int j = n / i;
        if (j == i) continue;
        while (c % j == 0) c /= j;
        c = c % j;
        if (c == 1) cnt++;
      }
    }

    cout << cnt << '\n';

    return 0;
}


Measured memory_bytes: 256
#include<bits/stdc++.h>
#define _GLIBCXX_DEBUG
using namespace std;
using ll= long long;
using ld= long double;
using P =pair<ll,ll>;

//これを見る初心者の方へ:mainより上のいっぱい書いてあるやつはプログラムを簡略化するためのものです。自分も最近知りました。各種コメントをつけているので参考にしてみてください(検索すればqittaとかでも色々見つかるので探してみてください)
//マクロ
//forループ関係
//引数は、(ループ内変数,動く範囲)か(ループ内変数,始めの数,終わりの数)、のどちらか
//Dがついてないものはループ変数は1ずつインクリメントされ、Dがついてるものはループ変数は1ずつデクリメントされる
#define REP(i,n) for(ll i=0;i<(ll)(n);i++)
#define REPD(i,n) for(ll i=n-1;i>=0;i--)
#define FOR(i,a,b) for(ll i=a;i<(ll)(b);i++)
#define FORD(i,a,b) for(ll i=a;i>=(ll)(b);i--)
//xにはvectorなどのコンテナ
#define ALL(x) (x).begin(),(x).end() //sortなどの引数を省略したい
#define sort(a) sort(ALL(a))//sortの省略
#define SIZE(x) ((ll)(x).size()) //sizeをsize_tからllに直しておく
#define MAX(x) *max_element(ALL(x)) //最大値を求める
#define MIN(x) *min_element(ALL(x)) //最小値を求める
//定数
#define INF 1000000000000 //10^12:極めて大きい値,∞
#define MOD 10000007 //10^9+7:合同式の法
#define MAXR 100000 //10^5:配列の最大のrange(素数列挙などで使用)
//略記
#define in(T, x) T x;cin >> x;//Tは型,xが入力値
#define vec(T,a,n,x) vector<T> a(n,x);
#define vec2(T,a,n,m) vector<vector<T>> a(n,vector<T>(m));
#define PB push_back //vectorヘの挿入
#define MP make_pair //pairのコンストラクタ
#define F first //pairの一つ目の要素
#define S second //pairの二つ目の要素
#define out(x) cout << x << endl//出力
#define bout(b) if(b){out("Yes");}else{out("No");}//真偽問題に対する出力
#define ain(T, a, n) vector<T> a(n);REP(i, n){cin >> a[i];}//配列の宣言と入力
#define a2in(T1, a, T2, b, n) vector<T1> a(n);vector<T2> b(n);REP(i, n){cin >> a[i] >> b[i];}//2つの配列を同時宣言、入力

template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return true; } return false; }//dp表とかで最大値更新するやつ
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return true; } return false; }//最小値更新



signed main(){
  ll weight[110],value[110];
  ll dp[110][100100];
  REP(i,110){
    REP(j,100100){
      dp[i][j]=INF;
    }
  }
  dp[0][0]=0;
  
  in(ll,N);
  in(ll,W);
  REP(i,N) cin>>weight[i]>>value[i];
  ll MAX_v=100100;
  
  REP(i,N){
    REP(sum_v,MAX_v){
      if(sum_v-value[i]>=0){
        chmin(dp[i+1][sum_v],dp[i][sum_v-value[i]]+weight[i]);
      }
      chmin(dp[i+1][sum_v],dp[i][sum_v]);
    }
  }
  ll ans=0;
  REP(i,MAX_v){
    if(dp[N][i]<=W) ans=i;
  }
  out(ans);
    
  
}

Measured memory_bytes: 86272
#include<cstdio>
#include<iostream>
#include<algorithm>
#include<cstring>
#include<cmath>
typedef long long ll;
using namespace std;
inline int rd(){
	int res=0,sign=1;char ch;
	while((ch=getchar())<'0'||ch>'9')if(ch=='-')sign=-1;res=res*10+ch-48;
	while((ch=getchar())>='0'&&ch<='9')res=res*10+ch-48;
	return res*sign;
}
int a,b,c,n;
int sum,ans;
int main(){
    cin>>a>>b>>c>>n;
    for(int i=0;i<=a;i++)
     for(int j=0;j<=b;j++)
      for(int k=0;k<=c;k++){
      	sum=i*500+j*100+k*50;
      	if(sum==n)
      		ans++;
      	//if(sum>n)break;
	  }
	cout<<ans<<endl;
	return 0;
}


Measured memory_bytes: 256
//#pragma comment(linker, "/STACK:102400000,102400000")
#include <fstream>
#include <iostream>
#include <functional>
#include <algorithm>
#include <sstream>
#include <cstring>
#include <vector>
#include <string>
#include <cstdio>
#include <cmath>
#include <queue>
#include <stack>
#include <deque>
#include <ctime>
#include <list>
#include <set>
#include <map>
#include <unordered_map>
#include <unordered_set>
using namespace std;

typedef long long ll;
#define eps 1e-10
#define LL_INF 0x3fffffffffffffff
#define INF 0x3f3f3f3f
#define mem(a, b) memset(a, b, sizeof(a))
#define pper(i,n,m) for(int i = n;i >= m; i--)
#define repp(i, n, m) for (int i = n; i <= m; i++)
#define rep(i, n, m) for (int i = n; i < m; i++)
#define sa(n) scanf("%d", &(n))
#define mp make_pair
#define ff first
#define ss second
#define pb push_back

const int maxn = 1e5 + 5;
const double PI = acos(-1.0);
const ll mod = 1e9 + 7;
ll po(ll a, ll b,ll mod) { ll res = 1; a %= mod; for (; b; b >>= 1) { if (b & 1)res = res*a%mod; a = a*a%mod; }return res; }
ll gcd(ll a,ll b){ if(a==0){return b;}else{ return gcd(b%a,a);}}
void YES(){puts("YES");exit(0);}
void Yes(){puts("Yes");exit(0);}
void NO(){puts("NO");exit(0);}
void No(){puts("No");exit(0);}

int n;
int a[maxn],b[maxn];
ll sum;

void solve()
{
	sa(n);
	sum = 0;
	repp(i,1,n)
	{
		sa(a[i]);
		sum+=a[i];
	}
	ll all  = 1LL*n*(n+1)/2;
	if(sum%all)
	{
		NO();
	}
	repp(i,1,n-1)
	{
		b[i+1] = a[i+1] - a[i];
	}
	b[1]=a[1]-a[n];
	ll k = sum/all;

	repp(i,1,n)
	{
		b[i]-=k;
		if(b[i]%n||b[i]>0)
		{
			NO();
		}
	}
	YES();
}

int main()
{

	solve();    
    return 0;
}


Measured memory_bytes: 1024
#include<bits/stdc++.h>
using namespace std;
int main()
{
int n;
cin>>n;
int a[n+1]={0};
int i,j,k,sum;
for(i=1;i*i<=n;i++)
{
for(j=1;j*j<=n;j++)
{
for(k=1;k*k<=n;k++)
{
sum=i*i+j*j+k*k+i*j+j*k+k*i;
if(sum<=n)
a[sum]++;
}
}
}
for(i=1;i<=n;i++)
{
cout<<a[i]<<endl;

}
}


Measured memory_bytes: 3552
package main

import (
	"bufio"
	"fmt"
	"os"
)

func main() {
	r := bufio.NewReader(os.Stdin)
	var s string
	fmt.Fscan(r, &s)

	c := s[0]
	ans := 0
	for i := 1; i < len(s); i++ {
		if c != s[i] {
			ans++
		}
		c = s[i]
	}

	fmt.Println(ans)
}


Measured memory_bytes: 1280
fn main() {
    match read::<u32>() {
        3 | 5 | 7 => println!("YES"),
        _         => println!("NO"),
    }
}

#[allow(dead_code)]
fn read<T: std::str::FromStr>() -> T {
    let mut s = String::new();
    std::io::stdin().read_line(&mut s).ok();
    s.trim().parse().ok().unwrap()
}

Measured memory_bytes: 4352
#include <stdio.h>

int main(){
	int input1,input2,i;
	i=1;
	while (1){
		scanf("%d %d",&input1,&input2);
		//scanf("%d",&input2);
		if(input1 ==0 &&input2==0)break;
		else{
			if(input1>input2) printf("%d %d\n",input2,input1);
			else printf("%d %d\n",input1,input2);
		}
		i++;
	}
}


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

int main()
{
    string s,t,temp;
    int i,j,k;
    cin>>s>>t;
    set<int> sett[2];
    for(i=0;i<s.size();i++)
    {
        sett[0].insert(s[i]);
        sett[1].insert(t[i]);
    }
    if(sett[1].size() != sett[0].size())
    {
        printf("No\n");
        return 0;
    }
    temp = s;
    int len = s.size();i=0;
    char ch ;
    while(temp != t && i<len)
    {
        ch = temp[len-1];
        temp = temp.substr(0,len-1);
        temp=ch+temp;
       // cout<<temp<<endl;
        i++;
    }
    if(i<len)
    {
        printf("Yes\n");
    }
    else {
        printf("No");
    }
    return 0;
}


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

int main()
{
    int N;
    int sumA,sumB;
    
    cin >> N;
    vector<int> a(N);
    for (int i=0;i<N;i++) {
        cin >> a.at(i);
        //cout << a.at(i);
    }
    
    sumA = 0;
    sumB = 0;
    sort(a.begin(),a.end(),greater<int>());
    for (int i=0;i<N;i++) {
        if (i%2==0) sumA += a.at(i);
        else        sumB += a.at(i);
        //cout << a.at(i) << endl;
    }
    //cout << "A :" << sumA << endl;
    //cout << "B :" << sumB << endl;
    cout << sumA - sumB << endl;
    
    return 0;
}


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

using namespace std;

#define pb push_back
#define mp make_pair
#define forn(i, n) for (int i = 0; i < (int)(n); ++i)
typedef long long LL;
typedef pair<int, int> PII;

int n, h, w;
int a[100005], r[100005], c[100005];
int d[200005], ord[100005];

inline bool cmp(const int &lhs, const int &rhs) {
    return a[lhs] > a[rhs];
}

int main() {
    scanf("%d%d%d", &n, &h, &w);
    forn(i, n) {
        scanf("%d%d%d", r + i, c + i, a + i);
        --r[i], --c[i];
        c[i] += h;
        ord[i] = i;
    }
    memset(d, -1, sizeof d);
    sort(ord, ord + n, cmp);
    LL ans = 0;
    forn(ii, n) {
        int i = ord[ii];
        int cur = r[i];
        vector<int> toDo;
        while (d[cur] >= 0) {
            int ncur = d[cur];
            toDo.pb(cur);
            d[cur] = -2;
            cur = ncur;
        }
        if (d[cur] == -1) {
            ans += a[i];
            d[cur] = c[i];
            for (int x : toDo) {
                d[x] = c[i];
            }
            continue;
        }

        toDo.clear();
        cur = c[i];
        while (d[cur] >= 0) {
            int ncur = d[cur];
            toDo.pb(cur);
            d[cur] = -2;
            cur = ncur;
        }
        if (d[cur] == -1) {
            ans += a[i];
            for (int x : toDo) {
                d[x] = r[i];
            }
            d[cur] = r[i];
        }
    }
    cout << ans << endl;
    return 0;
}


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

#define li long long int
#define rep(i, to) for (li i = 0; i < ((li)(to)); i++)
typedef pair<li, li> PI;

string s[111];

int main(void)
{
	li n, l;
	cin >> n >> l;

	rep(i, n) {
		cin >> s[i];
	}
	sort(s, s + n);
	rep(i, n) {
		cout << s[i];
	}
	cout << endl;

	return 0;
}

Measured memory_bytes: 256
#include <cassert>
#include <cctype>
#include <cerrno>
#include <cfloat>
#include <ciso646>
#include <climits>
#include <clocale>
#include <cmath>
#include <csetjmp>
#include <csignal>
#include <cstdarg>
#include <cstddef>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <ctime>
#include <cwchar>
#include <cwctype>
#include <ccomplex>
#include <cfenv>
#include <cinttypes>
#include <cstdbool>
#include <cstdint>
#include <ctgmath>
#include <algorithm>
#include <bitset>
#include <complex>
#include <deque>
#include <exception>
#include <fstream>
#include <functional>
#include <iomanip>
#include <ios>
#include <iosfwd>
#include <iostream>
#include <istream>
#include <iterator>
#include <limits>
#include <list>
#include <locale>
#include <map>
#include <memory>
#include <new>
#include <numeric>
#include <ostream>
#include <queue>
#include <set>
#include <sstream>
#include <stack>
#include <stdexcept>
#include <streambuf>
#include <string>
#include <typeinfo>
#include <utility>
#include <valarray>
#include <vector>
#include <array>
#include <atomic>
#include <chrono>
#include <codecvt>
#include <condition_variable>
#include <forward_list>
#include <future>
#include <initializer_list>
#include <mutex>
#include <random>
#include <ratio>
#include <regex>
#include <scoped_allocator>
#include <system_error>
#include <thread>
#include <tuple>
#include <typeindex>
#include <type_traits>
#include <unordered_map>
#include <unordered_set>
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)
#define all(x) (x).begin(),(x).end()
// #pragma GCC optimize("Ofast")
using namespace std;
typedef int64_t ll;
typedef long double ld;
const ll INF=(1LL<<60);
const ld pi=acosl((ld)1);
const ll mod = 1000000007;
const int dx[4]={0,1,0,-1};
const int dy[4]={1,0,-1,0};
const int ddx[8]={1,0,-1,-1,-1,0,1,1};
const int ddy[8]={1,1,1,0,-1,-1,-1,0};
#define endn "\n"

bool solve(){
  ll a[]={1, 1, 1, 2, 1, 2, 1, 5, 2, 2, 1, 5, 1, 2, 1, 14, 1, 5, 1, 5, 2, 2, 1, 15, 2, 2, 5, 4, 1, 4, 1, 51};
  ll k;cin>>k;
  cout<<a[k-1]<<endl;
  // if(sum%2)cout<<"Yes"<<endl;
  // else cout<<"No"<<endl;
  return false;
}

signed main(){
	ios::sync_with_stdio(false);
	cin.tie(nullptr);
	cout<<fixed;
	cout<<setprecision(30);
  // ll Q;cin>>Q;
	// while(Q--)solve();
  solve();
}


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

int main() {
  string s;
  cin >> s;
  int sum = 0;
  vector<int> v(s.size());
  for(int i=0; i<s.size(); i++) {
    v[i] = s[i]-'0';
    sum += v[i];
  }
  if(stoi(s)%sum==0) cout << "Yes" << endl;
  else cout << "No" << endl;
  return 0;
}

Measured memory_bytes: 3628
#include<iostream>
#include<cstring>
#include<algorithm>
#include<cstdio>
#include<cstdlib>
#include<stack>
#include<queue>
#include<string>
#include<vector>
#include<list>
#include<cmath>
//#include <bits/stdc++.h>
using namespace std;
vector<int>S;
int main(){
    long long int n;cin>>n;
    long int count=1;
    while(n>1){
        n=n/2;
        count+=1;
    }
    long long int a[count+1];
    for(int i=0;i<count;i++){
        if(i==0){
            a[i]=1;
            continue;
        }
        a[i]=pow(2,i)+a[i-1];
    }
    cout<<a[count-1]<<endl;
}


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

ans = 0
m = H[0]
k = 0
for i, h in enumerate(H[1:]):
    if m < h:
        ans = max(ans, k)
        k = 0
    else:
        k += 1
    m = H[i+1]
ans = max(ans, k)

print(ans)

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

int main() {
  string s;
  cin>>s;
  bool a=false, b=false;
  if ((s[0]=='0'&&s[1]!='0')||(s[0]=='1'&&s[1]-'0'<3)) {
    a=true;
  }
  if ((s[2]=='0'&&s[3]!='0')||(s[2]=='1'&&s[3]-'0'<3)) {
    b=true;
  }
  if (a&&b) {
    cout<<"AMBIGUOUS";
  }else if (a) {
    cout<<"MMYY";
  }else if (b) {
    cout<<"YYMM";
  }else{
    cout<<"NA";
  }
}

Measured memory_bytes: 256
#include <iostream>
#include <algorithm>
#include <map>
#include <queue>
#include <set>
#include <stack>
#include <string>
#include <string.h>
#include <vector>
#include <queue>
#include <cmath>
#include <bitset>
#include <complex>
#include <functional>
#include <numeric>
#include <iomanip>

// output
#define SPBR(w, n) std::cout<<(w + 1 == n ? '\n' : ' ');
#define YES cout << "YES" << endl
#define Yes cout << "Yes" << endl
#define NO cout << "NO" << endl
#define No cout << "No" << endl
// utility
#define ALL(i) (i).begin(), (i).end()
#define FOR(i, a, n) for(int i=(a);i<(n);++i)
#define RFOR(i, a, n) for(int i=(n)-1;i>=(a);--i)
#define REP(i, n) for(int i=0;i<int(n);++i)
#define RREP(i, n) for(int i=int(n)-1;i>=0;--i)
#define IN(a, x, b) (a<=x && x<b)
#define OUT(a, x, b) (x<a || b<=x)
template<class T> inline T chmax(T & a, const T b) { return a = (a < b) ? b : a; }
template<class T> inline T chmin(T& a, const T b) { return a = (a > b) ? b : a; }

// type/const
#define int ll
using ll = long long;
using ull = unsigned long long;
using ld = long double;
const int MOD = 1000000007;
/* const int MOD = 998244353; */
const int INF = 1e18;
const double PI = acos(-1);

using namespace std;
struct INIT { INIT(){
  cin.tie(0); ios::sync_with_stdio(false);
  cout << fixed << setprecision(10);
}}INIT;


signed main() {
  int N, K;
  cin >> N >> K;

  string s; 
  cin >> s;

  if(s.back() == 'L') s += 'R';
  else s += 'L';

  vector<int> v;

  int cnt = 1;
  REP(i, N){
    if(s[i] != s[i+1]){
      v.emplace_back(cnt);
      cnt = 1;
    }else{
      cnt++;
    }
  }

  cout << min(N-1, N-(int)v.size()+2*K) << "\n";

  return 0;
}

Measured memory_bytes: 1480
#include <bits/stdc++.h>
using namespace std;
int main()
{
int x,a,b,c;
cin>>a>>b>>c>>x;
int ans=0;
for(int i=0;i<=c;i++)
{
    for(int j=0;j<=b;j++)
    {
       for(int k=0;k<=a;k++)
       {
           if(k*500+j*100+i*50==x)
           ans++;
       }
    }
}
cout<<ans;
return 0;
}
 


Measured memory_bytes: 256
prime = Array.new(10 ** 6,true)
for i in 2..10 ** 3
  if prime[i]
    for j in 2..10 ** 6 / i
      prime[i * j] = false
    end
  end
end
while n = gets
  puts prime[2..n.to_i].select{|i|i}.size
end

Measured memory_bytes: 20608
import java.util.*;

public class Main {

    public static void main(String[] args) {
        Scanner sc = new Scanner(System.in);
        int a = sc.nextInt();
        int b = sc.nextInt();
        int c = sc.nextInt();
        int min = 0;
        int max = 0;
        if(a<b){
            min = a;
            max = b;
        }else{
            min = b;
            max = a;
        }
        if(min<c&&max>c){
            System.out.println("Yes");
        }else {
            System.out.println("No");
        }
    }
}


Measured memory_bytes: 23124
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
#define int ll
#define rep(i, n) for (int i = 0; i < (int)(n); ++i)
#define all(c) begin(c), end(c)
#define dump(x) cerr << __LINE__ << ":\t" #x " = " << (x) << endl

template <typename T>
bool chmax(T &x, T y) {
    if (x < y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

template <typename T>
bool chmin(T &x, T y) {
    if (x > y) {
        x = y;
        return true;
    } else {
        return false;
    }
}

int dp[100010];

int N, W;
int w[100010], v[100010];


signed main() {
    while (cin >> N) {
        cin >> W;
        rep(i, N) cin >> w[i] >> v[i];
        rep(i, W+1) dp[i] = 0;
        rep(i, N) {
            for (int j = W; j >= 0; --j) {
                if (j - w[i] >= 0) {
                    chmax(dp[j], dp[j-w[i]] + v[i]);
                }
            }
        }
        cout << dp[W] << endl;
    }
}


Measured memory_bytes: 1024