akhauriyash/Code-Regression huggingface dataset:
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

class Main
{
    static int dp[];
    public static void main(String[] args) throws IOException {
        BufferedReader br=new BufferedReader(new InputStreamReader(System.in));
        String s[]=br.readLine().split(" ");
        List<List<Integer>> list=new ArrayList<>();
        int n=Integer.parseInt(s[0]);
        for(int i=0;i<=n;i++)
            list.add(new ArrayList<>());
        int m=Integer.parseInt(s[1]);
        for(int i=0;i<m;i++)
        {
            String str[]=br.readLine().split(" ");
            int a=Integer.parseInt(str[0]);
            int b=Integer.parseInt(str[1]);
            list.get(a).add(b);
        }
        dp=new int[n+2];
        Arrays.fill(dp,-1);
        int max=0;
        for(int i=1;i<=n;i++)
        {
            max=Math.max(max,dfs(list,i));
        }
        System.out.println(max);


    }

    private static int dfs(List<List<Integer>> list, int index) {
        int max=0;
        if(dp[index]!=-1)
            return dp[index];
        for(int i=0;i<list.get(index).size();i++)
        {
            max=Math.max(max,1+dfs(list,list.get(index).get(i)));
        }
        return dp[index]= max;
    }


}

Measured memory_bytes: 58900
# coding: utf-8

import math
import re
import numpy as np
import copy

#読み込む
N = int(input())
an = list(map(int, input().split(' ')))
ans = 0

for i in range(N):
    if (i+1) % 2 == 0:
        continue
    elif an[i] % 2 != 0:
        ans += 1

print(ans)



Measured memory_bytes: 27020
#include <bits/stdc++.h>
#define DEBUG if(0)
#define lli long long int
#define ldouble long double
using namespace std;

int n, nsz;

bool can(int first, int last, int sz, int mid)
{
  int res = first * pow(10, sz) + mid * 10 + last;
  DEBUG printf("\t%d %d %d %d: %d\n", first, last, sz, mid, res);
  return first * pow(10, sz) + mid * 10 + last <= n;
}
int binarySearch(int first, int last, int sz, int lo, int hi)
{
  while (lo < hi)
  {
    int mid = (lo + hi + 1) >> 1;
    if (can(first, last, sz, mid)) lo = mid;
    else hi = mid - 1;
  }
  if (!can(first, last, sz, lo)) return 0;
  return lo + 1;
}

int cnt(int first, int last, int sz)
{
  int ans = (first==last)*(first <= n) + (first * 10 + last <= n);
  DEBUG printf("\t%d %d - %d", first, last, ans);
  for (int i = 2; i <= nsz; i ++)
    ans += binarySearch(first, last, i, 0, pow(10, i - 1) - 1);
  DEBUG printf(" - %d\n", ans);
  return ans;
}

int main()
{
  while (scanf("%d", &n) != EOF)
  {
    nsz = log10(n);
    lli ans = 0;
    for (int a = 1; a <= n; a ++)
    {
      if (a % 10 == 0) continue;
      int sz = log10(a);
      DEBUG printf("%d\n", a);
      ans += cnt(a % 10, a / pow(10, sz), sz);
    }
    printf("%lld\n", ans);
  }
  return 0;
}
/*
a = y---x
b = x---y
*/

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

long long int n, a, b, c, d;
bool f;

int main(){
//	cin.tie(0);
//	ios::sync_with_stdio(false);
	cin >> n >> a >> b >> c >> d;
//	for(int i=0; n-2*i>=0; ++i)
//		if((a+c*(n-2*i)-i <= b && b <= a+d*(n-2*i))+i || (a-d*(n-2*i)-i <= b && b <= a-c*(n-2*i)+i))
//			f = true;
	for(int i=2; i<=n; ++i){
		if((n-i)%2==0)
			if((a+(i-1)*c-(n-i)*(d-c)/2 <= b && b <= a+(i-1)*d+(n-i)*(d-c)/2) || (a-(i-1)*c+(n-i)*(d-c)/2 >= b && b >= a-(i-1)*d-(n-i)*(d-c)/2))
				f = true;
	}
	cout << (f ? "YES" : "NO") << "\n";
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
using namespace std;
#define ll long long
const int inf = 1200005;
int main(){
    int n, m, x;
    cin >> n >> m >> x;
    int c[n], a[n][m];
    for(int i = 0; i < n; i++){
        cin >> c[i];
        for(int j = 0; j < m; j++)
            cin >> a[i][j];
    }
    int ans = inf;
    for(int bit = 0; bit < (1 << n); bit++){
        int s = 0;
        vector<int> al(m);
        for(int i = 0; i < n; i++){
            if(1 & (bit >> i)){
                s += c[i];
                for(int j = 0; j < m; j++){
                    al[j] += a[i][j];
                }
            }
        }
        int cnt = 0;
        for(int i = 0; i < m; i++)
            if(al[i] >= x)
                cnt ++;
        if(cnt == m)
            ans = min(ans, s);
    }
    if(ans == inf)
        ans = -1;
    cout << ans << endl;
    return 0;
}

Measured memory_bytes: 3564
from functools import reduce
from fractions import gcd

l = input().split()
N = int(l[0])
ABC =[int(x) for x in l[1:]]
L = []
for i in range(N):
    L.append(int(input()))

# print(N, ABC, L)

def calc_score(a, b, L):
    c = 0
    r = 0
    u = 0
    while b > 0:
        if b & 1 != 0:
            r += L[c]
            u += 1
        c += 1
        b >>= 1
    score = (u - 1) * 10 + abs(a - r)
    return score

ans = 10**9
max_range = 1 << len(L)
for a in range(1, max_range):
    score_a = calc_score(ABC[0], a, L)
    for b in range(1, max_range):
        if a & b != 0:
            continue
        score_b = score_a + calc_score(ABC[1], b, L)
        for c in range(1, max_range):
            if a & c != 0 or b & c != 0:
                continue
            score_c = score_b + calc_score(ABC[2], c, L)
            ans = min(ans, score_c)

print(ans)


Measured memory_bytes: 73688
s=list(input())
if len(set(s))==1 and s[0]=='x':
    print(0)
    exit()

n=len(s)

nox=[i for i in s if i!='x']
if nox!=nox[::-1]:
    print(-1)
    exit()

ans=0
i=0
j=n-1
while i<j:
    if s[i]==s[j]:
        i+=1
        j-=1
    elif s[i]=='x':
        i+=1
        ans+=1
    elif s[j]=='x':
        j-=1
        ans+=1
print(ans)

Measured memory_bytes: 49804
import java.util.*;

public class Main {
  public static void main(String[] args) {
    // ???????????????
    List<Integer> targetList = new ArrayList<Integer>();

    // ??????????????????
    createNumsList(targetList);
    int sizeOfList = targetList.size();

    // ?°????????????????????????????
    bubbleSort(targetList, sizeOfList);
    // ???????????????
    printResult(targetList, sizeOfList);
  }

  private static void createNumsList(List<Integer> targetList) {
    Scanner sc = new Scanner(System.in);
    for (int i = 0; i < 3; i++) {
      // ????????????
      targetList.add(sc.nextInt());
    }
  }

  private static void bubbleSort(List<Integer> targetList, int sizeOfList) {
    for (int i = 0; i < sizeOfList-1; i++) {
      for (int j = i+1; j < sizeOfList; j++) {
        if (targetList.get(i) > targetList.get(j)) {
          swap(targetList, i, j);
        }
      }
    }
  }

  private static void swap(List<Integer> targetList, int x, int y) {
    int temp = targetList.get(x);
    targetList.set(x, targetList.get(y));
    targetList.set(y, temp);
  }

  private static void printResult(List<Integer> targetList, int sizeOfList) {
    for (int i = 0; i < sizeOfList; i++) {
      System.out.print(targetList.get(i));
      if (i != sizeOfList-1) {
        System.out.print(" ");
      }
    }
    System.out.println();
  }
}

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

#define sz(s) (ll)(s.size())
#define all(x) (x.begin(), x.end())
#define pb push_back
#define pf push_front
#define F first
#define S second
#define nl endl
#define ort1 exit(0);
#define db double
#define TL (double)clock()/CLOCKS_PER_SEC

using namespace std;

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


const double pi = acos(-1.0);
const double eps = 1e-9;
const int mod = 1e9 + 7;
const ll INF = 1e12 + 1;
const int N = 1e5 + 9;

int n, x;
int a[N];
int ans;

int main(){

    int mn = N, cnt = 0;
    cin >> n >> x;
    for(int i = 1; i <= n; ++i){
        cin >> a[i];
        ans += a[i];
        mn = min(a[i], mn);
    }

    if(x >= ans) cnt += n;
    x -= ans;
    ans = 0;
    ans = x / mn;

    cout << ans + cnt; 

ort1
}

Measured memory_bytes: 256
import java.util.*;

public class Main{
	public static void main(String[] args){
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        
        int num = (int)Math.floor(Math.log10(n));
        
        int ans = 0;
        
        for(int i=2;i<num;i+=2){
            
            ans += 9 * Math.pow(10,i);
            
        }

        if(num%2==0 && num>0){
            ans += n - Math.pow(10,num) + 1;
        }

        if(n<10){
            ans += n;
        }else{
            ans += 9;
        }

        System.out.println(ans);

        sc.close();
    }
}

Measured memory_bytes: 21716
import java.util.Scanner;

public class Main {
    public static void main(String[] args){
        try(Scanner sc =new Scanner(System.in)){
            int w = sc.nextInt();
            int n = sc.nextInt();
            int[] values = new int[w];
            for(int i=0;i<values.length;i++){
                values[i]=i+1;
            }
            for(int i=0;i<n;i++){
                String str=sc.next();
                String[] ab=str.split(",");
                int a = Integer.parseInt(ab[0]) - 1;
                int b = Integer.parseInt(ab[1]) - 1;
                int value=values[a];
                values[a]=values[b];
                values[b]=value;
            }
            for(int i=0;i<values.length;i++){
                System.out.println(values[i]);
            }
        }
    }
}


Measured memory_bytes: 26132
package main
 
import (
	"fmt"
)

func main() {
	var a,b,c,d int
	var o int
	fmt.Scanf("%d %d", &a, &b)
	fmt.Scanf("%d %d", &c, &d)
	if a != c {
		o = 1
	}
	if d == 1 {
		o = 1
	}
	fmt.Print(o)
}

Measured memory_bytes: 512
import math
from functools import reduce
from collections import deque
import sys
sys.setrecursionlimit(10**7)

# スペース区切りの入力を読み込んで数値リストにして返します。
def get_nums_l():
    return [ int(s) for s in input().split(" ")]

# 改行区切りの入力をn行読み込んで数値リストにして返します。
def get_nums_n(n):
    return [ int(input()) for _ in range(n)]

# 改行またはスペース区切りの入力をすべて読み込んでイテレータを返します。
def get_all_int():
    return map(int, open(0).read().split())

def log(*args):
    print("DEBUG:", *args, file=sys.stderr)

n,k = get_nums_l()

n = n%k
print(min(n, k-n))


Measured memory_bytes: 38384
#include<bits/stdc++.h>
#define ll long long int
#define v vector
#define pub push_back
#define pob pop_back
#define puh push_heap
#define poh pop_heap
#define com(x) x.begin(),x.end()
#define fast(); ios::sync_with_stdio(0);cin.tie(0);
#define popcount __builtin_popcount
#define F first
#define S second
#define LB lower_bound
#define UB upper_bound 
#define MP make_pair
#define MH make_heap
#define NLmax(x) numeric_limits<x>::max()
#define NLmin(x) numeric_limits<x>::min()
#define bisearch(s) binary_search(s.begin(),s.end())
#define loop(i,a,b,x) for(ll i=a;i<b;i=i+x)
#define M 1000000007
using namespace std;
int main()
{
    fast();
    string s;
    cin>>s;
    ll len=0,ans=0;
    for(ll i=0;i<s.size();i++)
    {
        if(s[i]=='A' || s[i]=='C' || s[i]=='G' ||s[i]=='T') len++;
        else len=0;
        ans = max(ans,len);
    }
    cout<<ans;
    return 0;
}

Measured memory_bytes: 256
//I hate this town, bacause it's too filled with memories I'd rather forget.
#include <vector>
#include <list>
#include <map>
#include <set>
#include <queue>
#include <deque>
#include <stack>
#include <bitset>
#include <algorithm>
#include <functional>
#include <numeric>
#include <utility>
#include <sstream>
#include <iostream>
#include <iomanip>
#include <cstdio>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <cstring>

//kAc
const double pi = acos(-1.0), eps = 1e-9;
const int dx[8] = {1, -1, 0, 0, 1, 1, -1, -1};
const int dy[8] = {0, 0, 1, -1, 1, -1, -1, 1};
const int MO = (int)(1e9 + 7);

//Two becomes one,and it through all eternity.
#define ALL(x) x.begin(), x.end()
#define fr(x, E) for (__typeof(E.begin()) x = E.begin(); x != E.end(); x++)
#define MP make_pair
#define PB push_back
#define FR first
#define SC second
#define ERR cerr << "ERROR" << endl
#define LL long long
#define LD long double
#define PII pair<int, int>
#define PIII pair<PII, int>
#define PDI pair<double, int>
#define PID pair<int, double>
#define SZ(a) (int)((a).size())
#define VEC vector
#define STR string
#define ISS istringstream
#define OSS ostringstream
#define CLR(a, b) memset(a, b, sizeof(a))
#define gmin(a, b) { if (b < a) a = b; }
#define gmax(a, b) { if (b > a) a = b; }

using namespace std;
int can[101][101];
multimap<int, string> road[1001];
set<pair<string, int>, less<pair<string, int> > > dp;
int n, m, s, t;
int main()
{

while(true){
	cin >> n >> m >> s >> t; if (n == 0) break;
	memset(can, 0, sizeof(can));
	while(m--){
		int x, y; string s;
		cin >> x >> y >> s;
		road[x].insert(MP(y, s));
		can[x][y] = true;
	}
	for (int k = 0; k < n; k++){
		can[k][k] = 1;
		for (int i = 0; i < n; i++)
			for (int j = 0; j < n; j++)
				can[i][j] |= can[i][k] && can[k][j];
	}
	dp.insert(MP("", s));
	string ss;
	while(s != t){
		if (dp.empty()) break;
		s = dp.begin()->second;
		ss = dp.begin()->first;
		dp.erase(dp.begin());
		if (ss.size() > 6 * n) break;
		for (multimap<int, string>::iterator itr = road[s].begin(); itr != road[s].end(); itr++){
			if (!can[itr->first][t]) continue;
			dp.insert(MP(ss + itr->second, itr->first));
		}
	}
	if (s == t) cout << ss << endl;
	else cout << "NO" << endl;
	dp.clear();
	for (int i = 0; i < n; i++) road[i].clear();
}

}

Measured memory_bytes: 2108
#include<string>
#include<iostream>
#include<algorithm>
#include<set>
#include<math.h>
#include<vector>
#include<sstream>
#include<queue>
#include<functional>
#include<bitset>
#include<cstdio>
#include<iomanip>
#include<map>
#include<unordered_map>
#include<unordered_set>
#include <string.h>
using ll = long long;

#define rep(i, n) for(ll i = 0; i < (int)(n); i++)
#define reps(i,x) for(ll i=1;i<=(int)(x);i++)
#define rrep(i,x) for(ll i=((int)(x)-1);i>=0;i--)
#define rreps(i,x) for(ll i=(int)(x);i>0;i--)
#define all(x) (x).begin(),(x).end()
#define m0(x) memset(x,0,sizeof(x))
#define vll vector<ll>
#define vi vector<int>
#define mp make_pair
#define vpll vector<pair<ll,ll>>
#define vpi vector<pair<int,int>>
#define mod 1000000007 
using namespace std;
ll n, m;
ll a[1005];
ll t[1005];
ll gcd(ll a, ll b) {
	if (b == 0) return a;
	gcd(b, a % b);
}
int main() {
	cin >> n;
	rep(i, n) {
		cin >> t[i] >> a[i];
	}

	reps(i, n-1) {
		ll pt = t[i-1] / t[i] + ((t[i - 1] % t[i] ? 1 : 0));
		ll pa = a[i - 1] / a[i] + ((a[i - 1] % a[i] ? 1 : 0));
		ll mx = max(pt, pa);
		t[i] *= mx;
		a[i] *= mx;
	}
		cout << t[n - 1] + a[n - 1] << endl;
	return 0;
}

Measured memory_bytes: 256
s = gets.chomp.split('')

ans = 0
(0..s.size).to_a.combination(2) do |ar|
  m = s[ar[0]...ar[1]]
  if m.all?{|e| ['A','C','G','T'].include?(e)}
    ans = [ans,m.size].max
  end
end
p ans


Measured memory_bytes: 1788
#include<iostream>
#include<algorithm>
#include<vector>
#include<queue>
#include<map>
#include<unordered_map>

using namespace std;
typedef pair<long long int, long long int> P;

long long int INF = 1e18;
long long int MOD = 1e9 + 7;

long long int N, M;

vector<int> E[110000], memo[110000];
long long int ans[110000];

long long int func(int pos, int pre){
  long long int ret = 1;
  for(int i = 0; i < E[pos].size(); i++){
    int to = E[pos][i];
    if(to != pre){
      memo[pos][i] = func(to, pos);
      ret *= memo[pos][i];
      ret %= M;
    }
  }
  return (ret + 1) % M;
}

void func2(int pos, int pre, long long int patt){
  ans[pos] = 1;
  for(int i = 0; i < E[pos].size(); i++){
    int to = E[pos][i];
    if(to == pre){
      memo[pos][i] = patt;
    }
    ans[pos] *= memo[pos][i];
    ans[pos] %= M;
  }
  long long int L[E[pos].size() + 1], R[E[pos].size() + 1];
  L[0] = 1;
  for(int i = 0; i < E[pos].size(); i++){
    L[i + 1] = L[i] * memo[pos][i] % M;
  }
  R[E[pos].size()] = 1;
  for(int i = E[pos].size() - 1; i >= 0; i--){
    R[i] = R[i + 1] * memo[pos][i] % M;
  }
  for(int i = 0; i < E[pos].size(); i++){
    int to = E[pos][i];
    if(to != pre){
      func2(to, pos, (L[i] * R[i + 1] + 1) % M);
    }
  }
}

int main(){
  cin >> N >> M;
  for(int i = 0; i < N - 1; i++){
    int x, y;
    cin >> x >> y;
    E[x].push_back(y);
    E[y].push_back(x);
    memo[x].push_back(0);
    memo[y].push_back(0);
  }
  func(1, -1);
  func2(1, -1, 0);
  for(int i = 1; i <= N; i++){
    cout << ans[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 23552
#include <bits/stdc++.h>
using namespace std;
int par[101];
int rank[101];
void init(int n){
  for(int i=0;i<n;i++){
    par[i]=i;
    rank[i]=1;
  }
}
int find(int x){
  if(par[x]==x){
    return x;
  }else{
    return par[x]=find(par[x]);
  }
}
void unit(int x,int y){
  x=find(x);
  y=find(y);
  if(x==y)return;
  if(rank[x]<rank[y]){
    par[x]=y;
  }else{
    par[y]=x;
    if(rank[x]==rank[y])rank[x]++;
  }
}
bool same(int x,int y){
  return find(x)==find(y);
}
struct edge{int u,v,cost;};
bool comp(const edge& e1,const edge& e2){
  return e1.cost<e2.cost;
}
edge es[10001];
int V,E;
int kruskal(int p){
  init(V);
  int res=0,p1=0,p2=1e9;
  for(int i=p;i<E;i++){
    edge e=es[i];
    if(!same(e.u,e.v)){
      unit(e.u,e.v);
      p1=max(e.cost,p1);
      p2=min(e.cost,p2);
    }
  }
  for(int i=1;i<V-1;i++)
    if(!same(i,i+1))return 1e9;
  return p1-p2;
}
int main(){
  while(cin>>V>>E,V){V++;
    int ans=1e9;
    for(int i=0;i<E;i++){
      cin>>es[i].u>>es[i].v>>es[i].cost;
    }
    sort(es,es+E,comp);
    for(int i=0;i<E;i++)
      ans=min(kruskal(i),ans);
    if(ans!=1e9)cout<<ans<<endl;
    else cout<<(-1)<<endl;
  }
}

Measured memory_bytes: 3164
#include <bits/stdc++.h>
using namespace std;
int main() {
  int n;
  cin >> n;
  int b[110];
  for(int i=0; i<n-1; i++){
    cin >> b[i];
  }
  int c[110];
  c[0] = b[0];
  c[n-1] = b[n-2];
  for(int i=0; i<n-2; i++){
    c[i+1] = min(b[i],b[i+1]);
  }
  //cout << c[0] << " " << c[1] << " " << c[2] << endl;
  int ans = 0;
  for(int i=0; i<n; i++){
    ans += c[i];
  }
  cout << ans << endl;
}


Measured memory_bytes: 256
#include <stdio.h>
#include <string>
#include <iostream>
#include <map>
#include <algorithm>
using namespace std;

int main(void){
    string a,b;
    cin >> a >> b;
    int flag=0;
    if(a[0]==b[2]&&a[1]==b[1]&&a[2]==b[0])flag=1;
    cout << (flag?"YES":"NO") << endl;
    return 0;
}

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

#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define bit(n) (1LL << (n))
#define SZ(x) ((int)(x).size())
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
#define end '\n'

#define pb push_back
#define mp make_pair

typedef long long ll;
using namespace std;

int gcd(int a, int b) { return b ? gcd(b, a % b) : a; }
int dx[4] = { 1, 0, -1,  0 };
int dy[4] = { 0, 1,  0, -1 };

struct aaa {
	aaa() {
		cin.tie(0);
		ios::sync_with_stdio(0);
		cout << fixed << setprecision(20);
	};
}aaaaa;

int main() {
	int n, k;
	cin >> n >> k;
	vector <int> v(n);
	for (int i = 0; i < n; i++) {
		cin >> v[i];
	}

	//組み合わせ（合計）
	vector <ll> vec(n * (n + 1) / 2 + 1);
	for (int i = 0; i < n; i++) {
		ll curr = 0;
		for (int j = i; j < n; j++) {
			curr += v[j];
			vec.push_back(curr);
		}
	}

	//ビット演算(64bit)
	ll res = 0;
	for (int i = 63; i >= 0; i--) {
		int cnt = 0;
		for (auto x : vec) {
			if (x & (1LL << i)) cnt++; //1の数を数える
		}

		if (cnt >= k) { //k個以上1があるなら
			res += (1LL << i); //答えに入れる

			vector <ll> next;
			for (auto x : vec) {
				if (!(x & (1LL << i))) continue;
				next.push_back(x); //0のやつを入れる
			}
			vec = next; //次はその中から
		}
	}
	cout << res << end;
}

Measured memory_bytes: 10040
def main():
    width, high, x, y = map(int, input().split())
    # data = [list(map(int, input().split())) for i in range(num)]

    ans = width * high / 2

    if x == width / 2 and y == high / 2:
        print(ans, 1)
    else:
        print(ans, 0)





if __name__ == '__main__':
    main()




Measured memory_bytes: 38384
#include <bits/stdc++.h>
using namespace std;
int N, M;
vector<vector<pair<int,int>>> A;
vector<bool> visited;
vector<int> pos;
bool g(int p, int q) {
	if (visited[p]) {
		return pos[p] == q;
	} else {
		visited[p] = true;
		pos[p] = q;
		for (auto x : A[p]) {
			if (!g(x.first, q + x.second)) return false;
		}
		return true;
	}
}
bool f() {
	visited.resize(N);
	pos.resize(N);
	for (int i = 0; i < N; ++ i) if (!visited[i]) {
		if (!g(i, 0)) return false;
	}
	return true;
}
int main() {
	cin >> N >> M;
	A.resize(N);
	for (int i = 0; i < M; ++ i) {
		int Li, Ri, Di;
		cin >> Li >> Ri >> Di;
		-- Li; -- Ri;
		A[Li].push_back({Ri, Di});
		A[Ri].push_back({Li, -Di});
	}

	cout << (f() ? "Yes" : "No") << endl;
}


Measured memory_bytes: 11008
#include <iostream>
#include <cstdlib>
#include <utility>
#include <algorithm>
#include <string>
#include <vector>
#include <queue>
#include <stack>
#include <set>

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

using namespace std;

int main() {
    int N, M, C;
    cin >> N >> M >> C;
    vector <int> B(M, 0); 
    rep(i, M) cin >> B[i];
    vector < vector <int> > A(N, vector <int> (M, 0));
    rep(i, N) rep(j, M) cin >> A[i][j];
    int sum = 0;
    rep(i, N) {
        int check = 0;
        rep(j, M) {
            check += A[i][j] * B[j];
        }   
        check += C;
        if (check > 0) sum++;
    }   
    cout << sum << endl;
}

Measured memory_bytes: 256
import qualified Data.Set as Set
import qualified Data.Map.Strict as Map

main = do
  n:m:_ <- map read . words <$> getLine :: IO [Int]
  pss <- map ((\(p:s:_) -> (read p, s)) . words) <$> lines <$> getContents :: IO [(Int, String)]
  putStrLn $ unwords . map show $ count n pss

count n pss = [Set.size ac, Map.foldr' (+) 0 $ Map.filterWithKey (\k v -> Set.member k ac) wa]
    where (ac,wa) = foldl step (Set.empty, Map.fromList [ (i, 0) | i <- [1..n] ]) pss
          step (ac,wa) (p,s)
            | Set.member p ac = (ac, wa)
            | s == "WA" = (ac, Map.insert p ((wa Map.! p) + 1) wa)
            | s == "AC" = (Set.insert p ac, wa)


Measured memory_bytes: 36220
#include<iostream>
using namespace std;
int main()
{
	long long a, b, c, d, N;

	cin >> N;

	a = N / 1000;
	b = (N - 1000 * a) / 100;
	c = (N - 1000 * a - 100 * b) / 10;
	d = N - 1000 * a - 100 * b - 10 * c;

	if (a == b && b == c)
			cout << "Yes";
		else
			if (b == c && c == d)
				cout << "Yes";
			else
				cout << "No";

	return 0;
}

Measured memory_bytes: 256
n = int(input())

red = []
blue = []
ed = []
for i in range(n):
    red.append(list(map(int,input().split())))
for i in range(n):
    blue.append(list(map(int,input().split())))

inf = 10**30

node = n*2+2

for i in range(1,n+1):
    ed.append([0,i,1])
    ed.append([n+i,2*n+1,1])
    
for i in range(n):
    for j in range(n):
        if red[i][0]<blue[j][0] and red[i][1]<blue[j][1]:
            ed.append([i+1,j+n+1,1])
    


edge = len(ed)
start = 0
goal = 2*n+1

"""
limit = [[0 for i in range(node)] for j in range(node)]
for i in edge:
    limit[i[0]][i[1]] += i[2]
"""

limit = [[] for i in range(node)]
for i in ed:
    limit[i[0]].append([i[1],i[2]])
    limit[i[1]].append([i[0],0])

ans = 0
while True:
    used = [False for i in range(node)]
    used[start] = True
    stack = [start]
    pre = [False for i in range(node)] # posの前
    pcos = [inf for i in range(node)] # posまでのコスト
    flg = False
    while stack:
        # print(stack)
        pos = stack.pop()
        for e in limit[pos]:
            if e[1] != 0 and (not used[e[0]]):
                pre[e[0]]=pos
                pcos[e[0]]=e[1]
                stack.append(e[0])
                used[e[0]]=True
                if e[0]==goal:
                    stack = []
                    flg = True
    if flg==False:
        print(ans)
        break
    pos = goal
    root = []
    minicost = inf
    while pos != start:
        root.append(pos)
        minicost = min(minicost,pcos[pos])
        pos = pre[pos]
    root.append(start)
    root.reverse()
    ans += minicost
    for i in range(len(root)-1):
        for j in range(len(limit[root[i]])):
            if limit[root[i]][j][0]==root[i+1]:
                limit[root[i]][j] = [root[i+1],limit[root[i]][j][1]-minicost]
        for j in range(len(limit[root[i+1]])):
            if limit[root[i+1]][j][0] == root[i]:
                limit[root[i+1]][j] = [root[i],limit[root[i+1]][j][1]+minicost]


Measured memory_bytes: 3944
#include <iostream>
using namespace std;
int main() {
    int m, f, r;
    while (1) {
        cin >> m >> f >> r;
        if (m == -1 && f == -1 && r == -1) break;
        if (m == -1 || f == -1) {
            cout << "F" << endl;
        } else if (m+f>=80) {
            cout << "A" << endl;
        } else if (m+f<80 && m+f>=65) {
            cout << "B" << endl;
        } else if (m+f<65 && m+f>=50) {
            cout << "C" << endl;
        } else if (m+f<50 && m+f>=30) {
            if (r>=50) {
                cout << "C" << endl;
            } else {
                cout << "D" << endl;
            }
        } else {
            cout << "F" << endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3084
import math

def make_divisors(n):
    divisors = []
    for i in range(1, int(n**0.5)+1):
        if n % i == 0:
            divisors.append(i)
            if i != n // i:
                divisors.append(n//i)

    # divisors.sort()
    return divisors

#a = list(map(int, input().split()))

cake=[]


h,w,k=list(map(int, input().split()))
totaltotal=0
for i in range(h):
    temp=input()
    cakeline=[]
    for j in range(w):
        if(temp[j]=='.'):
            cakeline.append(0)
        else:
            cakeline.append(1)
    cake.append(cakeline)
    totaltotal+=sum(cakeline)

ans=[[-1 for i in range(w)]for j in range(h)]
charge=1
count=0
hcount=0
for i in range(h):
    su = sum(cake[i])
    hcount+=su
    if(hcount==totaltotal and su==0):
        for j in range(w):
            ans[i][j]=ans[i-1][j]
    elif(su==0):
        charge+=1
    else:
        count+=1
        for j in range(w):
            for k in range(charge):
                ans[i-k][j]=count
            if(cake[i][j]==1 and count<hcount):
                count+=1
        charge=1
for i in range(h):
    print(' '.join(map(str,ans[i])))


Measured memory_bytes: 48344
h, w = map(int, input().split())
s = []
for _ in range(h):
    s.append(input())
r = [[0]*w for _ in range(h)]
for i in range(h):
    flg = False
    row = s[i]
    row2 = r[i]
    for j in range(w):
        if row[j]=='.':
            if not flg:
                tmp = 0
                begin = j
                flg = True
            tmp += 1
        if flg and row[j]=='#':
            for k in range(begin, j):
                row2[k] = tmp
            flg = False
    if flg:
        for k in range(begin, w):
            row2[k] = tmp
c = [[0]*w for _ in range(h)]
for i in range(w):
    flg = False
    for j in range(h):
        if s[j][i]=='.':
            if not flg:
                tmp = 0
                begin = j
                flg = True
            tmp += 1
        if flg and s[j][i]=='#':
            for k in range(begin, j):
                c[k][i] = tmp
            flg = False
    if flg:
        for k in range(begin, h):
            c[k][i] = tmp
ans = 0
for row1, row2 in zip(r, c):
    for e1, e2 in zip(row1, row2):
        if ans<e1+e2-1:
            ans = e1+e2-1
print(ans)

Measured memory_bytes: 129752
#include <algorithm>
#include <iostream>
#include <string>

using namespace std;

using ll = long long;

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

    ll A[N], B[N];
    ll asum = 0, bsum = 0;
    for (int i = 0; i < N; ++i) {
        cin >> A[i] >> B[i];
        asum += A[i];
        bsum += B[i];
    }

    ll ans = min(asum, bsum);

    pair<ll, int> w[N * 2];
    for (int i = 0; i < N; ++i) {
        w[i] = make_pair(A[i], i);
    }
    for (int i = 0; i < N; ++i) {
        w[i + N] = make_pair(B[i], i);
    }

    sort(w, w + N * 2);

    int cnt[N];
    fill(cnt, cnt + N, 0);

    ll total = 0;
    for (int i = 0; i < N; ++i) {
        auto p = w[i];
        total += p.first;
        ++cnt[p.second];
    }

    bool judge = false;
    for (int i = 0; i < N; ++i) {
        if (cnt[i] == 2) judge = true;
    }

    if (judge) {
        ans = min(ans, total);
    } else {
        for (int i = 0; i < N; ++i) {
            // A[i]とB[i]を両方選ぶ場合
            auto p = w[N - 1];
            if (p.second == i) p = w[N - 2];
            ans = min(ans, total - p.first + max(A[i], B[i]));
        }
    }

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


Measured memory_bytes: 5376
h, w = map(int,input().split())
li = [list(input()) for i in range(h)]

if h == 1 or w == 1:
    print("No")
    exit()

for i in range(h):
    for j in range(w):
        x = 0 #縦OK
        y = 0 #横OK
        if li[i][j] == "#":
            if i == 0:
                if li[i+1][j] == "#":
                    x = 1
            elif i == h-1:
                if li[i-1][j] == "#":
                    x = 1
            else:
                if li[i+1][j] == "#" or li[i-1][j] == "#":
                    x = 1
            if j == 0:
                if li[i][j+1] == "#":
                    y = 1
            elif j == w-1:
                if li[i][j-1] == "#":
                    y = 1
            else:
                if li[i][j+1] == "#" or li[i][j-1] == "#":
                    y = 1 

            if x == 0 and y == 0:
                print("No")
                exit()

print("Yes")

Measured memory_bytes: 3064
#include <bits/stdc++.h>
using namespace std;
const int MOD=1e9+7;
//const int MOD=998244353;
const int INF=1e9;
const long long LINF=1e18;
#define int long long
//template
template <typename T>
void fin(T a){
  cout<<a<<endl;
  exit(0);
}
//main
signed main(){
  int N,M;cin>>N>>M;
  std::vector<int> v(N);
  for(int i=0;i<N;i++)cin>>v[i];
  if(M==1)fin(N/2);
  std::vector<int> w(M,0);
  for(int i=0;i<N;i++)w[v[i]%M]++;
  int ans=0;
  std::vector<int> use(M,0);
  for(int i=1;i<(M+1)/2;i++){
    int res=min(w[i],w[M-i]);
    ans+=res;use[i]+=res;use[M-i]+=res;
  }
  ans+=w[0]/2;
  if((M&1)==0)ans+=w[M/2]/2;
  map<int,int> m;
  for(int i=0;i<N;i++)m[v[i]]++;
  std::vector<int> no(M);
  for(auto p:m)if(p.second&1)no[p.first%M]++;
  for(int i=1;i<M;i++){
    if((M&1)==0&&i==M/2)continue;
    ans+=(w[i]-max(no[i],use[i]))/2;
  }
  fin(ans);
}


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

void call(){
	int n;
	cin>>n;
	int i=1;
	while(true){
		int x=i;
		bool b=false;
		if(x%3==0){
			cout<<" "<<i;
			b=true;
		}
		if(!b){
			while(true){
				if(x%10==3){
					cout<<" "<<i;
					break;
				}
				x/=10;
				if(x)continue;
				break;
			}
		}
		if(++i>n)break;
	}
	cout<<endl;
}
signed main(){
	call();
	return 0;
}


Measured memory_bytes: 3120
#include <iostream>
#include <algorithm>
#include <string>
using namespace std;
string s;
int n;
int main(){
    cin>>n>>s;
    for(int i=0;i<s.size();i++){
        s[i]+=n;
        while('Z'<s[i])s[i]-=26;
        cout<<s[i];
    }
}

Measured memory_bytes: 256
def prime(n):
    p = True
    for i in range(2, round(n**0.5)+1):
        if n % i == 0:
            p= False
            break
    return p

x = int(input())

if x == 2 or x == 3:
    print(x)
elif x == 4 or x == 5:
    print(5)
else:
    p = prime(x)
    while not p:
        x = x + 1
        p = prime(x)
    print(x)

Measured memory_bytes: 3064
S = list(input())

flag = 0

if S[0] == 'A':
    if S[2:-1].count("C") == 1:
        S.remove("A")
        S.remove("C")
        for s in S:
            if s.islower():
                continue
            else:
                flag = 1
                break
        if flag == 0:
            print("AC")
        else:
            print("WA")
    else:
        print("WA")
else:
    print("WA")

Measured memory_bytes: 38384
import java.util.*;

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

        while(true){
            int h = sc.nextInt();
            int w = sc.nextInt();

            if(h==0 && w==0){break;}
            else{
                for(int i=0;i<h;i++){
                    for(int j=0;j<w;j++){
                        if(i%2==0){
                            if(j%2==0){System.out.printf("#");}
                            else{System.out.printf(".");}
                        }else{
                            if(j%2==0){System.out.printf(".");}
                            else{System.out.printf("#");}
                        }
                    }
                    System.out.println();

                }
                System.out.println();
            }
        }
    }
}


Measured memory_bytes: 58848
using System;
public class Program{
    public static void Main(){
        string[] line = Console.ReadLine().Split(' ');
        long n = long.Parse(line[0]);
        long m = long.Parse(line[1]);
        long[] x = new long[n];
        long[] y = new long[n];
        long[] z = new long[n];
        for(long i=0; i<n; i++){
            line = Console.ReadLine().Split(' ');
            x[i]=long.Parse(line[0]);
            y[i]=long.Parse(line[1]);
            z[i]=long.Parse(line[2]);
        }
        long r=0;
        for(int p=0; p<8; p++){
            long[] s = new long[n];
            for(long i=0; i<n; i++){
                s[i]=pm(p,x[i],y[i],z[i]);
            }
            Array.Sort(s);
            long t = 0;
            for(long i=0; i<m; i++){
                t+=s[n-1-i];
            }
            r=(r>t)? r: t;
        }
        Console.WriteLine(r);
    }
    public static long pm(int p, long x, long y, long z){
        int a = p/4;
        int b = (p-4*a)/2;
        int c = p-4*a-2*b;
        return (a*x+b*y+c*z)*2-x-y-z;
    }
}

Measured memory_bytes: 11380
#include<bits/stdc++.h>
using namespace std;
#define ll long long int
int main()
{
    ll n;
    cin>>n;
    string s,s1;
    cin>>s>>s1;
    for(ll i=0;i<2*s.length();i++)
    if(i%2==0)
    cout<<s[i/2];
    else
    cout<<s1[i/2];
}

Measured memory_bytes: 256
package main

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

func main() {
	sc := newScanner()
	N := sc.nextInt()
	K := sc.nextUint64()
	masks := make([]uint64, 10000)
	masks = append(masks, K)

	var i uint
	for i = 30; i >= 0; i-- {
		if (1<<i)&K != 0 {
			mask := K &^ (1 << i)
			mask = mask | (1<<i - 1)
			masks = append(masks, mask)
		}
		if i == 0 {
			break
		}
	}
	// for _, m := range masks {
	// 	fmt.Printf("%b \n", m)
	// }
	a := make([]uint64, N)
	b := make([]uint64, N)
	for i := 0; i < N; i++ {
		a[i] = sc.nextUint64()
		b[i] = sc.nextUint64()
	}
	anss := make([]uint64, len(masks))
	for i := 0; i < N; i++ {
		// fmt.Scan(&a, &b)
		// a := sc.nextUint64()
		// b := sc.nextUint64()
		for idx, m := range masks {
			if m|a[i] == m {
				anss[idx] += b[i]
			}
		}
	}
	var ans uint64
	for _, a := range anss {
		if a > ans {
			ans = a
		}
	}
	fmt.Println(ans)
}

type scanner struct {
	r   *bufio.Reader
	buf []byte
	p   int
}

func newScanner() *scanner {
	rdr := bufio.NewReaderSize(os.Stdin, 10000)
	return &scanner{r: rdr}
}
func (s *scanner) next() string {
	s.pre()
	start := s.p
	for ; s.p < len(s.buf); s.p++ {
		if s.buf[s.p] == ' ' {
			break
		}
	}
	result := string(s.buf[start:s.p])
	s.p++
	return result
}
func (s *scanner) nextLine() string {
	s.pre()
	start := s.p
	s.p = len(s.buf)
	return string(s.buf[start:])
}
func (s *scanner) nextInt() int {
	v, _ := strconv.Atoi(s.next())
	return v
}
func (s *scanner) nextUint64() uint64 {
	v, _ := strconv.ParseUint(s.next(), 10, 64)
	return v
}
func (s *scanner) pre() {
	if s.p >= len(s.buf) {
		s.readLine()
		s.p = 0
	}
}
func (s *scanner) readLine() {
	s.buf = make([]byte, 0)
	for {
		l, p, e := s.r.ReadLine()
		if e != nil {
			panic(e)
		}
		s.buf = append(s.buf, l...)
		if !p {
			break
		}
	}
}


Measured memory_bytes: 6912
#include <stdio.h>
#include <string.h>

int main(void)
{
	int		house[4][3][10] = {0}, num, build,  floor,  issue, people, i, j, k;
	char	pattern;

	scanf("%d" , &num);
	
	for(i=0; i<num; i++){
		scanf("%d" , &build);
		scanf("%d" , &floor);
		scanf("%d" , &issue);
		scanf("%d" , &people);

		house[build-1][floor-1][issue-1] += people;
	}
	for(i=0; i<4; i++){
		for(j=0; j<3; j++){	
			for(k=0; k<10;k++){

				printf(" %d", house[i][j][k]);
			}
			printf("\r\n");
		}
		if(i == 3){
			break;
		}	
		printf("####################\r\n");		
	}
	return 0;	 
}

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

int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    string s;
    cin >> s;
    if (s == "ABC")
        cout << "ARC";
    else if (s == "ARC")
        cout << "ABC";
    cout << endl;
    return 0;
}

Measured memory_bytes: 3660
#include <iostream>
#include <vector>
int main()
{
  int n;
  std::cin >> n;
  std::vector<long> a(n+1);
  for (long i = 0; i < n+1; i++)
  {
    std::cin >> a[i];
  }
  std::vector<long> b(n);
  for (long i = 0; i < n; i++)
  {
    std::cin >> b[i];
  }
  long count = 0;
  for(long i = 0; i < n; i++)
  {
    long tmp = b[i]-a[i];
    if(tmp < 0)
    {
      count += b[i];
      a[i] -= b[i];
      b[i] = 0;
      if(b[i] - a[i+1] < 0)
      {
        count += b[i];
        a[i+1]-=b[i];
        b[i] = 0;
      }
      else
      {
        count += a[i+1];
        b[i] -= a[i+1];
        a[i+1] = 0;
      }
    }
    else
    {
      count += a[i];
      b[i] -= a[i];
      a[i] = 0;
      if(b[i] - a[i+1] < 0)
      {
        count += b[i];
        a[i+1]-=b[i];
        b[i] = 0;
      }
      else
      {
        count += a[i+1];
        b[i] -= a[i+1];
        a[i+1] = 0;
      }
    }
  }
  std::cout << count << std::endl;
  return 0;
}

Measured memory_bytes: 1792
class UnionFind:
    def __init__(self, N, l):
        self.roots = list(range(N+1))
        self.counter = [1]*(N+1)
        for a, b in l:
            self.union(a, b)
 
    def get_root(self, n):
        if self.roots[n] != n:
            self.roots[n] = self.get_root(self.roots[n])
        return self.roots[n]
 
    def union(self, a, b):
        a, b = sorted([self.get_root(a), self.get_root(b)])
        if a != b:
            self.roots[b] = a
            self.counter[a] += self.counter[b]
            self.counter[b] = 0
 
    def find(self, a, b):
        return self.get_root(a) == self.get_root(b)
 
    def count(self, x):
        return(self.counter[self.get_root(x)])
 
 
N, M, K = [int(i) for i in input().split()]
ab = [[int(i) for i in input().split()] for _ in range(M)]
cd = [[int(i) for i in input().split()] for _ in range(K)]
friend = [[] for _ in range(N+1)]
uf = UnionFind(N, ab)
 
for a, b in ab:
    friend[a].append(b)
    friend[b].append(a)
 
ans = [uf.count(i)-1-len(friend[i]) for i in range(N+1)]
 
for c, d in cd:
    if uf.find(c, d):
        ans[c] -= 1
        ans[d] -= 1
 
print(*ans[1:])

Measured memory_bytes: 125856
#include<cstdio>
#include<cstring>
#include<algorithm>
#include<iostream>
#include<string>
#include<vector>
#include<stack>
#include<bitset>
#include<cstdlib>
#include<cmath>
#include<set>
#include<list>
#include<deque>
#include<map>
#include<queue>
#define INF 0x3f3f3f3f
using namespace std;
typedef long long ll;
int main(void)
{
    int T,t,s,x,y,n,m;
    char c;
    scanf("%c",&c);
    printf("%c\n",c+1);
    return 0;
}









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

#define _CRT_SECURE_NO_WARNINGS

int main(int argc, char const *argv[])
{
	double n,k;
	double sumRate = 0.00;
	double tempRate;

	scanf("%lf %lf",&n,&k);
	for (double i = 1.00; i <= n; i += 1.00)
	{
		if(i < k)	tempRate = pow(0.50, ceil(log2(k / i))) / n;
		else tempRate = 1.00 / n;
		sumRate += tempRate;
	}
	printf("%.12f\n", sumRate);
	return 0;
}


Measured memory_bytes: 128
n,k=map(int,input().split())
if n>k:
    if n%k==0:
        print(0)
    else:
        a=n%k
        b=k/2
        if a<b:
            print(a)
        else:
            print(k-a)
else:

    print(min([n,k-n]))


Measured memory_bytes: 2940
#include <bits/stdc++.h>
using namespace std;
 
int main() {
  int K;
  string S;
  cin >> K >> S;
  if (K<S.size()){
    for (int X=0; X<K; X++){
      cout << S.at(X);
    }
    cout << "..." << endl;
  }
  else{
    cout << S << endl;
  }
}

Measured memory_bytes: 3632
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <memory.h>
#include <math.h>
#include <assert.h>
#include <stack>
#include <queue>
#include <map>
#include <set>
#include <string>
#include <algorithm>
#include <iostream>
#include <functional>
#include <unordered_set>
#include <bitset>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define Fi first
#define Se second
#define pb(x) push_back(x)
#define szz(x) (int)x.size()
#define rep(i,n) for(int i=0;i<n;i++)
#define all(x) x.begin(),x.end()
typedef tuple<int, int, int> t3;

int N, D, A[200020];
ll mn_l[200020];
vector <pair<ll, pii> > E;
int p[200020]; int Find(int x) { return p[x] == x ? x : p[x] = Find(p[x]); }

int main() {
	scanf("%d%d", &N, &D);
	for(int i=1;i<=N;i++) {
		scanf("%d", A + i);
	}
	mn_l[N + 1] = 1e18;
	for(int i=N;i;i--) {
		mn_l[i] = min(mn_l[i+1], A[i] + (ll) i * D);
	}
	vector <int> v;
	ll mn = 1e18;
	for(int i=1;i<=N;i++) {
		if(mn > A[i] - (ll)i*D) {
			mn = A[i] - (ll) i*D;
			v.pb(i);
		}
		else {
			int p = v.back();
			ll len = min(mn_l[i+1] + A[i] - (ll)i*D, A[i] + A[p] + (ll)D*(i-p));
			E.pb(make_pair(len, pii(i, v.back())));
		}
	}
	for(int i=0;i<szz(v)-1;i++) {
		int a = v[i], b = v[i+1];
		E.pb(make_pair(mn_l[b] + A[a] - (ll)a*D, pii(a, b)));
	}
	
	sort(all(E));
	for(int i=1;i<=N;i++) p[i] = i;
	ll ans = 0;
	for(auto e : E) {
		int x = Find(e.Se.Fi), y = Find(e.Se.Se);
		if(x != y) p[y] = x, ans += e.Fi;
	}
	printf("%lld\n", ans);
	return 0;
}


Measured memory_bytes: 9456
#include <bits/stdc++.h>
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
#define UNIQUE(v) v.erase( unique(v.begin(), v.end()), v.end() );
using namespace std;
using ll = long long;
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; }
const ll INF = 1e9;
const ll MOD = 1e9 + 7;


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

    int ans = 0;
    for(int i=1; i<=n; i++){
        if(i%2 == 0) continue;
        int cnt = 0;
        for(int j=1; j<=i; j++) cnt += (i%j == 0);
        if(cnt == 8) ans++;
    }

    cout << ans << endl;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <math.h>
#include <vector>
#include <algorithm>
#include <iomanip>
#define mod 1000000007
#define ten5 100000
using namespace std;



int main()
{
    int m,n,o=0,i,j,k,num[3];
    int sum=0,range=0;
    //long long int m,n,o,i,j,k=0;
    //vector <int> v;
    //float f,g,h;
    char c,d;
    //string a;
    cin>>m;
    for(i=1;i<10;i++)
    {
        if(m%i==0)
            if(m/i<10)
        {
            cout<<"Yes";
            return 0;
        }
    }
    cout<<"No";
    return 0;
}





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

int main(){
    int a,b,c;
    cin>>a>>b>>c;
    if(a>=b&&a>=c)cout<<a*10+b+c;
    else if(b>=a&&b>=c)cout<<b*10+a+c;
    else cout<<c*10+a+b;
return 0;
}


Measured memory_bytes: 3588
#include<cstdio>
#include<algorithm>

class Solution{
private :
	static const int maxn = 5e5 + 7;
	static const int maxm = 5e5;
	static const int mod = 998244353;
	
	int n, m, frac[maxn * 2], invf[maxn * 2], ans, tot, sum;
	
	void Init(int x) {
		frac[0] = 1;
		for (register int i = 1; i <= x; i++) {
			frac[i] = 1ll * frac[i - 1] * i % mod;
		}
		invf[x] = Kasumi(frac[x], mod - 2);
		for (register int i = x - 1; i >= 0; i--) {
			invf[i] = 1ll * invf[i + 1] * (i + 1) % mod;
		}
	}
	
	int Kasumi(int a, int b) {
		int res = 1, base = a;
		for (; b; b >>= 1) {
			if (b & 1) {
				res = 1ll * res * base % mod;
			}
			base = 1ll * base * base % mod;
		}
		return res;
	}
	
	int Inv(int x) {
		return Kasumi(x, mod - 2);
	}
	
	int A(int n, int m) {
		if (n == m || !m) {
			return frac[n];
		}
		return 1ll * frac[n] * invf[m] % mod;
	}
	
	int C(int n, int m) {
		if (n == m || !m) {
			return 1;
		}
		return 1ll * A(n, m) * invf[n - m] % mod;
	}
	
public :
	Solution() {
		Get();
		Solve();
	}
	
	void Get() {
		scanf("%d %d", &n, &m);
	}
	
	void Solve() {
        Init(n + m);
        if (n > m) {
            std :: swap(n, m);
        }
        for (register int i = 1; i <= n; i++) {
            tot += 1ll * C(2 * i, i) * C(n - i + m - i, n - i) % mod;
            if (tot >= mod) {
                tot -= mod;
            }
        }
        sum = C(n + m, n);
        printf("%lld\n", (1ll * tot * Inv(sum) % mod * Inv(2) + m) % mod);
	}
};
Solution sol;

int main() {}


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

#define rep(i, n) for(int i = 0; i < (n); ++i)
#define repr(i, n) for(int i = (n-1); i >= 0; --i)

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

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

const int MAX = 200005;
const int INF = 1001001001;
const int MOD = 1000000007;

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

    vector<int> p(N), q(N);
    for (auto &i : p) cin >> i;
    for (auto &i : q) cin >> i;

    vector<int> v(N);
    rep(i, N) v[i] = i+1;

    int i = 1, resP = 0, resQ = 0;
    do {
        if (v == p) resP = i;
        if (v == q) resQ = i;
        i++;
    } while (next_permutation(v.begin(), v.end()));

    cout << abs(resP - resQ) << endl;
}

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

using ll = long long;
using db = long double;
using pii = pair < int, int >;
using pll = pair < ll, ll >;
const int N = 2e5 + 10;
const ll inf = 1e15 + 42;
#define endl "\n"
db prob[3004];
int n;
db dp[3004][3004];
db go (int indx, int head) {
    if (indx == n+1) {
        if (head > n/2)
            return 1;
        else
            return 0;
    }
    if (dp[indx][head] != -1)
        return dp[indx][head];
    db &ans = dp[indx][head];
    ans = prob[indx]*go(indx+1, head+1) + (1-prob[indx])*go(indx+1, head);
    return ans;
}

void testCase() {
    //int n;
    cin >> n;
    //db prob[n+3];
    for (int i=1; i<=n; i++)
        cin >> prob[i];
    // for (int i=1; i<=n; i++) {
    //     for (int j=0; j<=n; j++)
    //         dp[i][j] = -1;
    // }
    dp[n][0] = 1 - prob[n];
    dp[n][1] = prob[n];
    for (int j=2; j<=n; j++) {
        dp[n][j] = 0;
    }
    for (int i=n-1; i>=1; i--) {
        dp[i][0] = dp[i+1][0] * (1 - prob[i]);
        for (int j=1; j<=n; j++) {
            dp[i][j] = dp[i+1][j-1]*prob[i] + dp[i+1][j]*(1-prob[i]);
        }
    }
    db ans = 0;
    for (int i=n/2+1; i<=n; i++)
        ans += dp[1][i];
    cout << fixed << setprecision(15) << ans << endl;

    // cout << "TABLE: " << endl;
    // for (int i=1; i<=n; i++) {
    //     for (int j=1; j<=n; j++)
    //         cout << dp[i][j] << " ";
    //     cout << endl;
    // }
}

int main() {
    ios_base :: sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    testCase();
    return 0;
}

Measured memory_bytes: 141056
#include<stdio.h>
#include<iostream>
 
using namespace std;
 
int main(){
 
int x,y;
int p=1;
int dx;
 
cin>>x>>y;
 
while(1){
 
dx=x;
x=y;
y=dx%y;
 
if(y==0)break;
 
 
}
 
 
cout<<x<<endl;
 
return 0;
 
}

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

#define ll long long
#define pii pair<int,int>
#define fi first
#define se second
#define pb push_back

/** Dateloper */


using namespace std;
int main()
{
    int A,B;
    cin>>A>>B;
    int ans=0;
        int tmp=1;
        while(tmp<B)
        {
            tmp+=A-1;
            ans++;
        }
        cout<<ans;
    return 0;
}



Measured memory_bytes: 256