akhauriyash/Code-Regression huggingface dataset:
/*

	??????????£???§??????????????´?????????????????????
	???????????±???????±???????????????????????????¢

	??????????????§break ??§???????????????
	 <-------- ????????¢

	 TIME LIMITED
*/

#include <iostream>
using namespace std;
#include<queue>
#include<cstring>

int flg[51][51][51][51];

struct Twins
{
	int tax, tay;
	int kax, kay;
	int cnt;
};

queue <Twins> que;

bool check(int y1, int x1, int y2, int x2){ //?????§????????£?????¢?´¢??????


	if (flg[y1][x1][y2][x2] == 0) return true;
	return false;
}

int main(void){

	int x, y;
	int tx, ty;
	int kx, ky;
	Twins twins;

	int y_temp[4] = { -1, +1, 0, 0 };//????????????
	int x_temp[4] = { 0, 0, -1, +1 };//????????????

	while (cin >> x >> y && x != 0 && y != 0){

		memset(flg, 0, sizeof(flg));

		while (!que.empty())
			que.pop();
		int map[52][52];
		memset(map, 1, sizeof(map));

		cin >> tx >> ty >> kx >> ky;

		twins.cnt = 0, twins.tax = tx, twins.tay = ty, twins.kax = kx, twins.kay = ky;

		for (int i = 1; i < y + 1; i++){
			for (int j = 1; j < x + 1; j++)
					cin >> map[i][j];
		}

		que.push(twins);
		flg[que.front().tay][que.front().tax][que.front().kay][que.front().kax] = 1;

		while (1){

			if (que.front().cnt >= 100){
				break;
			}
			if (que.front().kax == que.front().tax && que.front().kay == que.front().tay){
				break;
			}

			for (int i = 0; i < 4; i++){
				if (map[que.front().tay + y_temp[i]][que.front().tax + x_temp[i]] == 0){ //T???????????????????£???????
					if (map[que.front().kay - y_temp[i]][que.front().kax - x_temp[i]] == 0){ //K???????????????????£???????
						if (check(que.front().tay + y_temp[i], que.front().tax + x_temp[i], que.front().kay - y_temp[i], que.front().kax - x_temp[i])){
							twins.tay = que.front().tay + y_temp[i], twins.tax = que.front().tax + x_temp[i], twins.kay = que.front().kay -y_temp[i], twins.kax = que.front().kax - x_temp[i];
							twins.cnt = que.front().cnt + 1;
							que.push(twins);
							flg[twins.tay][twins.tax][twins.kay][twins.kax] = 1;
						}
					}
					else if (check(que.front().tay + y_temp[i], que.front().tax + x_temp[i], que.front().kay, que.front().kax)){
						twins.tay = que.front().tay + y_temp[i], twins.tax = que.front().tax + x_temp[i], twins.kay = que.front().kay, twins.kax = que.front().kax;
						twins.cnt = que.front().cnt + 1;
						que.push(twins);
						flg[twins.tay][twins.tax][twins.kay][twins.kax] = 1;
					}
				}
				else if (map[que.front().kay - y_temp[i]][que.front().kax - x_temp[i]] == 0){ //K???????????????????£???????
					if (check(que.front().tay, que.front().tax, que.front().kay - y_temp[i], que.front().kax - x_temp[i])){
						twins.tay = que.front().tay, twins.tax = que.front().tax, twins.kay = que.front().kay - y_temp[i], twins.kax = que.front().kax - x_temp[i];
						twins.cnt = que.front().cnt + 1;
						que.push(twins);
						flg[twins.tay][twins.tax][twins.kay][twins.kax] = 1;
					}
				}
			}

			que.pop();
			if (que.empty())
				break;
		}

		if (que.empty() || que.front().cnt >= 100)
			cout << "NA" << endl;
		else
			cout << que.front().cnt << endl;

	}
}

Measured memory_bytes: 27980
n,y=[int(i) for i in input().split()]
re=False
for i in range(n+1):
    for j in range(n-i+1):
        if i*10000+j*5000+(n-(i+j))*1000==y:
            if i+j+(n-(i+j))==n:
                print("{} {} {}".format(i,j,(n-(i+j))))
                re=True
        if re:
            break
    if re:
        break
else:
    print("-1 -1 -1")

Measured memory_bytes: 3064
def s()
    gets().chomp
  end
  def i()
    gets.to_i
  end
  def li()
    gets.split.map(&:to_i)
  end
  def ls()
    gets.split
  end
  def ili()
    n = gets.to_i
    as = gets.split.map(&:to_i)
    [n, as]
  end
  def inli()
    n = gets.to_i
    as = []
    n.times {
      as << gets.split.map(&:to_i)
    }
    [n, as]
  end
  class Array
    def sum
      total = 0
      self.each do |item|
        total += item
      end
      total
    end
  end
  
  def eratosthenes(size)
    prime_list = []
    is_prime = Array.new(size, true)
    is_prime[0] = false
    is_prime[1] = false
  
    2.upto(size-1){|i|
      if is_prime[i]
        prime_list << i
        (2).upto((size.to_f/i).ceil-1){|j|
          is_prime[j*i] = false
        }
      end
    }
    [prime_list, is_prime]
  end
  
  def dijkstra(s, e, cost)
    size = cost.length
    if s==e
      return 0
    end
    dp = {}
    dp[s] = 0
    undefined_node = {}
    size.times{|i|
      if i != s
        undefined_node[i] = cost[s][i]
      end
    }
    while undefined_node.length != 0
      min = undefined_node.min_by{|_, v| v}
      stock = {}
      temp = undefined_node.clone
      temp.each{|k, v|
        if min[1] == v
          undefined_node.delete(k)
          if k == e
            return v
          end
          dp[k] = v
          stock[k] = v
        end
      }
  
      stock.each{|k, v|
        undefined_node.each{|k2, v2|
          undefined_node[k2] = v + cost[k][k2] < v2 ?  v + cost[k][k2] : v2
        }
      }
    end
  end
  
  def get_bits(len)
    res =  []
    (2**len).times{|i|
      res << i.to_s(2).rjust(len, '0')
    }
    res
  end
  
  def get_GCD(m, n)
    tmp = [n, m].max
    n = [n, m].min
    m = tmp
    while n != 0
      tmp = m % n
      m = n
      n = tmp
    end
    m
  end
  def fact(n, m=0)
    (m+1..n).inject(1,:*)
  end
  def perm(n, r)
    fact(n, n-r)
  end
  def comb(n, m)
    fact(n, n-m)/fact(m)
  end
  def matrix(n, m=n, init=0)
    Array.new(n).map{Array.new(m,init)}
  end


def solve(s, n, p)
    res = 0
    if p == 2 || p == 5 
        s.each_char.with_index{|c, i|
          if c.to_i % p == 0
            res += i+1
          end
        }
        return res
    end
    s = s.reverse
    mods = get_mods(s, p)
    res = mods.count(0)
    hash = {}
    mods.each{|m|
        if hash.has_key?(m)
            hash[m] += 1
        else
            hash[m] = 1
        end
    }
    hash.each{|k, v|
      if v >= 2
        res += comb(v, 2)
      end
    }
    return res
end

def get_mods(s, p)
    mods = []
    mod10s = []
    n = s.size
    tmp = 1
    n.times{|i| 
      mod10s << tmp 
      tmp = (tmp*10) % p 
    }
    tmp = 0
    n.times{|i|
      tmp = ((s[i].to_i * mod10s[i]) + tmp)%p
      mods << tmp
    }
    mods
end

n, p = li()
S = s()
puts solve(S, n, p)



Measured memory_bytes: 6140
#include <bits/stdc++.h>
using namespace std;
 
int main () {
  int64_t A, B;
  cin >> A >> B;
  int64_t G = gcd(A, B);
  int64_t M = G;
  int ans = 1;
  for (int i = 2; i <= sqrt(M); i++) {
    if (G % i == 0) {
      ans++;
      while (G % i == 0) {
        G /= i;
      }
    }
  }
  if (G != 1) {
    ans++;
  }
  cout << ans << endl;
}

Measured memory_bytes: 3548
#include<bits/stdc++.h>
using namespace std;
using Int = long long;
//INSERT ABOVE HERE
signed main(){
  Int n;
  cin>>n;
  deque<Int> d(n);
  for(Int i=0;i<n;i++) cin>>d[i];
  vector<Int> as;
  auto a=d;
  Int ans=0;
  if(*max_element(d.begin(),d.end())<=0){
    Int k=max_element(d.begin(),d.end())-d.begin()+1;
    ans=d[k-1];
    for(Int i=n;i>k;i--) as.emplace_back(i);
    for(Int i=1;i<k;i++) as.emplace_back(1);
  }else{
    Int a=0,b=0;
    for(Int i=0;i<n;i++){
      if(i&1) b+=max(d[i],Int(0));
      else a+=max(d[i],Int(0));
    }
    auto calc=[&](Int x){
      as.emplace_back(x);
      if(x==1) d.pop_front();
      else if(x==(Int)d.size()) d.pop_back();
      else{
	d[x-1]=d[x-2]+d[x];
	d.erase(d.begin()+x);
	d.erase(d.begin()+x-2);
      }
    };
    if(a<b) calc(1);
    while(d.size()>2u){
      if(d[0]<0){
	calc(1);
	calc(1);
      }else if(d[2]<0){
	calc(3);
      }else{
	calc(2);
      }
    }
    if(d.size()==2u) calc(2);
    ans=d[0];
  }
  cout<<ans<<endl;
  cout<<as.size()<<endl;
  for(Int x:as) cout<<x<<endl;
  for(Int x:as){
    if(x==1) a.pop_front();
    else if(x==(Int)a.size()) a.pop_back();
    else{
      a[x-1]=a[x-2]+a[x];
      a.erase(a.begin()+x);
      a.erase(a.begin()+x-2);
    }
  }
  assert(a.size()==1u);
  assert(a[0]==ans);
  return 0;
}


Measured memory_bytes: 384
#include<stdio.h>
#include<stdlib.h>

struct node{
  struct node *right;
  struct node *left;
  struct node *parent;
  int key;
};
typedef struct node * Node;

#define NIL NULL

Node root;

Node treeMinimum(Node x){
  while(x->left!=NIL)x=x->left;
  return x;
}

Node treeMaximum(Node x){
  while(x->right!=NIL)x=x->right;
  return x;
}

Node treeSearch(Node u, int k){
  if(u==NIL||k==u->key)return u;
  if(k<u->key)
    return treeSearch(u->left,k);
  else
    return treeSearch(u->right,k);

}

Node treeSuccessor(Node x){
  Node y=x->parent;
  if(x->right!=NIL)
    return treeMinimum(x->right);
  while(y!= NIL&&x==y->right){
    x=y;
    y=y->parent;
  }
  return y;

}

void treeDelete(Node z){
  Node y; // node to be deleted
  Node x; // child of y

  if(z->left==NIL || z->right==NIL)y=z;
  else y=treeSuccessor(z);
  
  if(y->left!=NIL)x=y->left;
  else x=y->right;

  if(x!=NIL)x->parent=y->parent;
  
  if(y->parent==NIL)root=x;
  else if(y==y->parent->left)y->parent->left=x;
  else y->parent->right=x;

  if(y!=z)z->key=y->key;
  
}

void insert(int k){
  Node y = NIL;
  Node x = root;
  Node z;

  z = malloc(sizeof(struct node));
  z->key = k;
  z->left = NIL;
  z->right = NIL;
  
  while(x!=NIL){
    y=x;
    if(z->key<x->key)x=x->left;
    else x=x->right;
  }
  z->parent=y;
  if(y==NIL)root=z;
  else if(z->key<y->key)y->left=z;
  else y->right=z;
  
}

void inorder(Node u){
  if(u==NIL)return;
  inorder(u->left);
  printf(" %d",u->key);
  inorder(u->right);
}
void preorder(Node u){
  if(u==NIL)return;
  printf(" %d",u->key);
  preorder(u->left);
  preorder(u->right);
}


int main(){
  int n, i, x;
  char com[20];
  scanf("%d", &n);

  for ( i = 0; i < n; i++ ){
    scanf("%s", com);
    if ( com[0] == 'f' ){
      scanf("%d", &x);
      Node t = treeSearch(root, x);
      if ( t != NIL ) printf("yes\n");
      else printf("no\n");
    } else if ( com[0] == 'i' ){
      scanf("%d", &x);
      insert(x);
    } else if ( com[0] == 'p' ){
      inorder(root);
      printf("\n");
      preorder(root);
      printf("\n");
    } else if ( com[0] == 'd' ){
      scanf("%d", &x);
      treeDelete(treeSearch(root, x));
    }
  }

  return 0;
}



Measured memory_bytes: 20488
K, A, B = list(map(int, input().split()))

if A >= B -1: # 差が１以下ならば、そのまま割って行くほうがコスト的に良い
    re = K + 1
else:
    ite = (K - (A - 1) ) // 2
    re = B * ite - A *(ite - 1) 
    if (K - (A - 1)) % 2 == 1:
        re += 1
print(re)

Measured memory_bytes: 3060
use std::io::*;
use std::str::FromStr;

fn read<T: FromStr>() -> T {
    let stdin = stdin();
    let stdin = stdin.lock();
    let token: String = stdin
        .bytes()
        .map(|c| c.expect("failed to read char") as char) 
        .skip_while(|c| c.is_whitespace())
        .take_while(|c| !c.is_whitespace())
        .collect();
    token.parse().ok().expect("failed to parse token")
}

fn main() {
    let a: u32 = read();
    let b: u32 = read();

    let ans = (a..b+1).filter(|x| {
        let rev = x.to_string().chars().rev().collect::<String>();
        x.to_string() == rev
    }).count();

    println!("{}", ans);
}


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

ll a, b, c;

inline ll read(){
	ll s = 0, w = 1;
	char ch = getchar();
	for (; ch < '0' || ch > '9'; ch = getchar()) w *= ch == '-' ? -1 : 1;
	for (; ch >= '0' && ch <= '9'; ch = getchar()) s = s * 10 + ch - '0';
	return s * w;
}

inline void work(){
	a = read(), b = read(), c = read();
	if (c >= b) c = b - 1;
	printf("%lld\n", a * c / b);
}

int main(){
	work();
	return 0;
}

Measured memory_bytes: 3696
a=int(input())
b=int(input())
c=int(input())
d=int(input())
e=int(input())

if a<40:
    a=40
else:
    pass
if b<40:
    b=40
else:
    pass
if c<40:
    c=40
else:
    pass
if d<40:
    d=40
else:
    pass
if e<40:
    e=40
else:
    pass

print((a+b+c+d+e)//5)



Measured memory_bytes: 5588
#include<iostream>
#include<algorithm>
#include<vector>
#include<string>
#include<map>
using namespace std;
vector<int>vec[100005];
int h[100005];
int main()
{
	int n, m;
	cin >> n >> m;
	for (int i = 1; i <= n; i++)
	{
		scanf("%d", &h[i]);
	}
	while (m--)
	{
		int l, r;
		scanf("%d%d", &l, &r);
		vec[l].push_back(r);
		vec[r].push_back(l);
	}
	int ans = 0;
	for (int i = 1; i <= n; i++)
	{
		bool wa = false;
		for (auto it : vec[i])
		{
			if (h[it] >= h[i])
			{
				wa = true;
				break;
			}
		}
		if (!wa)ans++;
	}
	cout << ans << endl;
	return 0;
}

Measured memory_bytes: 9272
#include <iostream>
#include <algorithm>
#include <utility>
#include <string>
#include <vector>
#include <set>
#include <stack>
#include <queue>
#include <map>
#include <math.h>
#include <string.h>
#include <iomanip>
#include <numeric>
#include <cstdlib>
#include <cstdint>
#include <cmath>
#include <functional>

using namespace std;

using ll = long long;
using pll = pair<ll, ll>;
using vl = vector<ll>;
using vll = vector<vl>;
using vpll = vector<pll>;

#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 Rep(i, n) for (long long i = 0; i< (long long)(n); i++)
#define RRep(i,n) for (long long i = ((long long)(n)-1); i>=0; i--)
#define all(v) (v).begin(),(v).end()

struct Edge{
    int to;
    int weight;
    Edge(int t, int w) : to(t), weight(w){ }
};

using Graph = vector<vector<Edge>>;
using graph = vector<vector<int>>;

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

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

template <class T>
T gcd(T a, T b){
    if( b==0 ) return a;
    return gcd(b, a%b);
}

template <class T>
T lcm(T a, T b){
    return (a*b)/gcd(a,b);
}

int INF = 1e9+7;

vector<int> dx = {-1,0,1,0};
vector<int> dy = {0,-1,0,1};

struct LazySegmentTree{
private:
    int n;
    vector<ll> node,lazy;
    
public:
    LazySegmentTree(vector<ll> v){
        int sz = (int)v.size();
        n = 1;
        while(n<sz) n*=2;
        node.resize(2*n-1);
        lazy.resize(2*n-1,0);

        for(int i = 0; i<sz; i++) node[i+n-1] = v[i];
        for(int i =n-2; i>=0; i--) node[i] = node[i*2+1] + node[i*2+2];
    }

    void eval(int k, int l, int r){
        if(lazy[k] != 0){
            node[k] += lazy[k];
            if(r-l>1){
                lazy[2*k+1] += lazy[k]/2;
                lazy[2*k+2] += lazy[k]/2;
            }
        }

        lazy[k] = 0;
    }

    void add(int a, int b, ll x, int k = 0, int l = 0, int r = -1){
        if(r<0) r = n;
        eval(k,l,r);
        if(b<=l || r<= a) return;
        if(a<=l && r<=b){
            lazy[k] += (r-l)*x;
            eval(k,l,r);
        }
        else{
            add(a,b,x,2*k+1,l,(l+r)/2);
            add(a,b,x,2*k+2,(l+r)/2,r);
            node[k] = node[2*k+1]+node[2*k+2];
        }
    }

    ll getsum(int a,int b, int k= 0,int l = 0, int r = -1){
        if(r<0) r = n;
        if(b<=l || r<=a) return 0;

        eval(k,l,r);
        if(a<=l && r<= b) return node[k];
        ll vl = getsum(a,b,2*k+1,l,(l+r)/2);            
        ll vr = getsum(a,b,2*k+2,(l+r)/2,r);
        return vl+vr;
    }
};

int main(){
    int n,q;
    cin >> n >> q;
    LazySegmentTree seg(vector<ll>(n,0));
    rep(i,q){
        int query;
        cin >> query;
        if(query==0){
            int s,t;
            ll x;
            cin >> s >> t >> x;
            seg.add(s-1,t,x);
        }
        else{
            int a,b;
            cin >> a >> b;
            cout << seg.getsum(a-1,b) << endl;
        }
    }
}


Measured memory_bytes: 7580
/*

    author : s@if

*/

#include<bits/stdc++.h>
using namespace std;

#define 		NIL 			-1
#define		 	fi	 		    first
#define 		sec 			second
#define 		MAX 			INT_MAX
#define			INF 			99999999
#define 		ll 			    long long
#define 		PI 			    acos(-1.0)
#define			MOD 			1000000007
#define 		PLL 			pair<ll,ll>
#define 		PII			    pair<int,int>
#define 		ull 			unsigned long long
#define 		For(i,a,b) 		for(int i=a;i<=(int)b;i++)


inline int in() {int x; scanf("%d", &x); return x; }
bool Check(int N , int pos)	{	return (bool) (N & (1<<pos));}
int Set(int N, int pos) {	return N = N | (1<<pos);}

int fx[]={+0,+0,+1,-1,-1,+1,-1,+1};
int fy[]={-1,+1,+0,+0,+1,+1,-1,-1};
int hr[]={-2,-2,-1,+1,+2,+2,-1,+1};
int hc[]={+1,-1,+2,+2,-1,+1,-2,-2};
int dx[]={+1,-1,+0,+0};
int dy[]={+0,+0,+1,-1};

const int MAXN = (int)1e5+9;

int main()
{
/*	freopen("input.txt","r",stdin);
    freopen("output.txt","w",stdout);
    ios_base::sync_with_stdio(false);
    cin.tie(0);
    cout.tie(0);  */

    int i,j,k,l,m,n,p,q,x,y,u,v,r,tc,t;

    cin>>p>>q>>r;

    m = p-q;

    n = r-m;

    if(n<0)
        n = 0;

    cout<<n<<endl;

    return 0;
}

// read the question correctly (is y a vowel? what are the exact constraints?)
// look out for SPECIAL CASES (n=1?) and overflow (ll vs int?)


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
const int inf = (1 << 30) - 1;

int H, W, ans, cost[1111][1111], dx[4] = {1, 0, -1, 0}, dy[4] = {0, 1, 0, -1}, ny, nx, x, y, cnt;
char grid[1111][1111];

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

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            cin >> grid[i][j];
            cost[i][j] = inf;
        }
    }

    queue<pair<int, pair<int, int>>> que;
    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            if (grid[i][j] == '#')
            {
                que.emplace(0, make_pair(i, j));
            }
        }
    }

    while (!que.empty())
    {
        auto p = que.front();
        que.pop();
        y = p.second.first, x = p.second.second, cnt = p.first;
        if (cost[y][x] != inf)
            continue;
        cost[y][x] = cnt, grid[y][x] = '#', cnt++;
        for (int i = 0; i < 4; i++)
        {
            ny = y + dy[i], nx = x + dx[i];
            if ((ny < 0 || ny >= H) || (nx < 0 || nx >= W) || (grid[ny][nx] == '#'))
                continue;
            que.emplace(cnt, make_pair(ny, nx));
        }
    }

    for (int i = 0; i < H; i++)
    {
        for (int j = 0; j < W; j++)
        {
            ans = max(cost[i][j], ans);
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 17808
N, K = map(int, input().split())
R, S, P = map(int, input().split())
T = input()

hands = [None] * N
d1 = {'r': 'p', 's': 'r', 'p': 's'}
d2 = {'r': P, 's': R, 'p': S}
result = 0
for i in range(len(T)):
    if i >= K and d1[T[i]] == hands[i - K]:
        if i + K < N:
            hands[i] = set('rps') - set(T[i + K]) - set(T[i])
        else:
            hands[i] = T[i]
    else:
        hands[i] = d1[T[i]]
        result += d2[T[i]]
print(result)


Measured memory_bytes: 14924
n, k = [int(i) for i in input().split()]
h = [int(i) for i in input().split()]
if k >= n:
    print(0)
elif k == 0:
    print(sum(h))
else:
    h.sort()
    ans = 0
    for i in h[: - k]:
        ans += i
    print(ans)

Measured memory_bytes: 26360
#include <iostream>
#include <vector>
#include <algorithm>

using namespace std;

int main()
{
    int n, m, k, ans = 0;
    cin >> n >> m;

    vector< vector<int> > a(n);

    for (int i = 0; i < n; ++i) {
        cin >> k;
        a[i].resize(k);
        for (int j = 0; j < k; ++j) {
            cin >> a[i][j];
        }
    }

    for (int i = 1; i <= m; ++i) {
        int cnt = 0;
        for (int j = 0; j < n; ++j) {
            auto it = find(a[j].begin(), a[j].end(), i);
            if (it != a[j].end()) ++cnt;
        }
        if (cnt == n) ++ans;
    }

    cout << ans << endl;

    return 0;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#include <iostream>
#include <queue>
#include <stack>
#include <vector>
#include <string>
#include <set>
#include <map>
#include <random>
#define rep(i,n) for (int i = 0; i < (n); ++i)
#define repp(i,n,m) for (int i = m; i < (n); ++i)
#define repl(i,n) for (long long i = 0; i < (n); ++i)
#define reppl(i,n,m) for (long long i = m; i < (n); ++i)
using namespace std;
using ll = long long;
using ld = long double;
using P = pair<int, int>;
using PL = pair<long long, long long>;
using Pxy = pair<double, double>;
using T = tuple<int, int, bool>;
const int INF = 1001001007;
const int mod = 1000000007;
const int MOD = 998244353;
const ll inf = 1e18;
template <typename AT>
void printvec(vector<AT> &ar){
    rep(i,ar.size()-1) cout << ar[i] << " ";
    cout << ar[ar.size()-1] << endl;
}
template <typename Q>
void printvvec(vector<vector<Q>> &ar){
    rep(i,ar.size()){
        rep(j,ar[0].size()-1) cout << ar[i][j] << " ";
        cout << ar[i][ar[0].size()-1] << endl;
    }
}
template <typename S>
bool range(S a, S b, S x){
    return (a <= x && x < b);
}

int main() {
    ll n; cin >> n;
    string s = "";
    vector<int> ar;
    while (true){
        int a = n % 26;
        n -= a;
        if (a == 0){
            n -= 26;
            s += 'z';
        }
        else {
            char c = 'a';
            rep(i,a-1) c++;
            s += c;
        }
        n /= 26;
        if (n == 0) break;
    }
    string ans = "";
    int m = s.size();
    rep(i,m) ans += s[m-1-i];
    cout << ans << endl;
}

Measured memory_bytes: 3552
#include <iostream>
#include <algorithm>
#include <complex>
#include <utility>
#include <vector>
#include <string>
#include <queue>
#include <tuple>
#include <cmath>
#include <bitset>
#include <cctype>
#include <set>
#include <map>
#include <numeric>
#include <functional>
#define _overload3(_1,_2,_3,name,...) name
#define _rep(i,n) repi(i,0,n)
#define repi(i,a,b) for(ll i=ll(a);i<ll(b);++i)
#define rep(...) _overload3(__VA_ARGS__,repi,_rep,)(__VA_ARGS__)
#define all(x) (x).begin(),(x).end()
#define PRINT(V) cout << V << "\n"
#define SORT(V) sort((V).begin(),(V).end())
#define RSORT(V) sort((V).rbegin(), (V).rend())
using namespace std;
using ll = long long;
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; }
inline void Yes(bool condition){ if(condition) PRINT("Yes"); else PRINT("No"); }
template<class itr> void cins(itr first,itr last){
    for (auto i = first;i != last;i++){
        cin >> (*i);
    }
}
template<class itr> void array_output(itr start,itr goal){
    string ans = "",k = " ";
    for (auto i = start;i != goal;i++) ans += to_string(*i)+k;
    if (!ans.empty()) ans.pop_back();
    PRINT(ans);
}
ll gcd(ll a, ll b) {
    return a ? gcd(b%a,a) : b;
}
const ll INF = 1e18;
const ll MOD = 1000000007;
typedef pair<ll,ll> P;
const ll MAX = 20000;
constexpr ll nx[8] = {1,0,-1,0,-1,-1,1,1};
constexpr ll ny[8] = {0,1,0,-1,-1,1,-1,1};
int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n,a;
    cin >> n >> a;
    PRINT(n*n-a);
}


Measured memory_bytes: 256
n = int(input())
abc = []
ans = 0

for i in range(5) :
    abc.append(int(input()))

minabc = min(abc)
ans += n//minabc
if n % minabc != 0:
    ans += 1

if minabc >= n :
    print(5)
else :
    print(4 + ans)

Measured memory_bytes: 3064
/*
 * Author:  heyuhhh
 * Created Time:  2020/6/22 14:05:49
 */
#include <iostream>
#include <algorithm>
#include <cstring>
#include <cstdio>
#include <vector>
#include <cmath>
#include <set>
#include <map>
#include <queue>
#include <iomanip>
#include <assert.h>
#include <functional>
#include <numeric>
#define MP make_pair
#define fi first
#define se second
#define pb push_back
#define sz(x) (int)(x).size()
#define all(x) (x).begin(), (x).end()
#define INF 0x3f3f3f3f
#define Local
#ifdef Local
  #define dbg(args...) do { cout << #args << " -> "; err(args); } while (0)
  void err() { std::cout << std::endl; }
  template<typename T, typename...Args>
  void err(T a, Args...args) { std::cout << a << ' '; err(args...); }
  template <template<typename...> class T, typename t, typename... A> 
  void err(const T <t> &arg, const A&... args) {
  for (auto &v : arg) std::cout << v << ' '; err(args...); }
#else
  #define dbg(...)
#endif
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
//head
const int N = 1e5 + 5;

int n, m, k;
struct node {
    int x, y;
    int cost;
    int r;
    int dir;
    bool operator < (const node& A) const {
        if (cost + (r + k - 1) / k == A.cost + (A.r + k - 1) / k) return r > A.r;
        return cost + (r + k - 1) / k > A.cost + (A.r + k - 1) / k;
    }
};

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

void run() {
    cin >> n >> m >> k;
    int sx, sy, ex, ey;
    cin >> sx >> sy >> ex >> ey;
    --sx, --sy;
    --ex, --ey;
    vector <string> s(n);
    for (int i = 0; i < n; i++) {
        cin >> s[i];
    }
    priority_queue <node> q;
    vector <vector <vector <int>>> dis(n, vector <vector <int>>(m, vector <int>(4, INF)));
    vector <vector <vector <bool>>> vis(n, vector <vector <bool>>(m, vector <bool>(4, false)));
    dis[sx][sy][0] = 0;
    q.push(node{sx, sy, 0, 0, 0});
    while (!q.empty()) {
        node now = q.top(); q.pop();
        int x = now.x, y = now.y;
        int cost = now.cost, r = now.r;
        int dir = now.dir;
        if (vis[x][y][dir]) continue;
        vis[x][y][dir] = true;
        dis[x][y][dir] = cost + (r + k - 1) / k;
        for (int d = 0; d < 4; d++) {
            int nx = x + dx[d], ny = y + dy[d];
            if (nx >= 0 && nx < n && ny >= 0 && ny < m && s[nx][ny] != '@') {
                if (d == dir) {
                    q.push(node{nx, ny, cost, r + 1, d});
                } else {
                    q.push(node{nx, ny, dis[x][y][dir], 1, d});
                }
            }
        }
    }
    int ans = INF;
    for (int i = 0; i < 4; i++) {
        ans = min(ans, dis[ex][ey][i]);
    }
    if (ans == INF) ans = -1;
    cout << ans << '\n';
}

int main() {
    ios::sync_with_stdio(false);
    cin.tie(0); cout.tie(0);
    cout << fixed << setprecision(20);
    run();
    return 0;
}

Measured memory_bytes: 199572
#include <bits/stdc++.h>
#define rep(i,s,n) for(int i=s;i<n;i++)
#define pb push_back
#define all(x) (x).begin(),(x).end()
#define int long long
using namespace std;
using P=pair<int,int>;
using Graph=vector<vector<int>>;
using ll=long long;


ll gcd(ll A, ll B){
    if(B == 0)return A;
    return gcd(B, A % B);
}
ll lcm(ll A, ll B){
    return A * B / gcd(A, B);
}
bool root(string s){
    int n=s.length();
    if(n==2){
        if(s[0]==s[1]){
            return true;
        }
        else return false;
    }
    if(n==3){
        if(s[0]==s[2]){
            return true;
        }
        else return false;
    }
 
    return false;
}
 
 
//深さ優先
vector<int> seen;
vector<ll> h;
 
//普通の深さ優先探索seenを返す感じ
void dfs(const Graph &G,int v){
    seen[v] = 0; //v探索済み
 
    P good=make_pair(v,h[v]);
    for(auto next_v :G[v]){
        if(seen[next_v]!=-1) continue;//もう探索していた
        if(h[next_v]>good.second){
            good=make_pair(next_v,h[next_v]);
        }
        dfs(G,next_v);
    }
 
    if(!(h[v]==good.second && v==good.first)){
        seen[good.first]=1;
    }
}
 
signed main(){
    int n; 
    cin>>n;
    int a[n];
    vector<vector<pair<int,int>>> xy(n);
    rep(i,0,n){
        int ai; cin>>ai;
        a[i]=ai;
        rep(j,0,ai){
            int xi,yi;
            cin>>xi>>yi;
            xy[i].pb(make_pair(xi,yi));
        }
    }

    //cout<<1<<endl;

    int ans=0;
    for(int tmp=0;tmp<(1<<n);tmp++){
        bool able=true;
        bitset<16> bi=(tmp);
        for(int i=0;i<n;i++){
            if(bi.test(i)){
            for(int ai=0;ai<a[i];ai++){
                int k=xy[i][ai].first-1;
                int boo=xy[i][ai].second;
                if(bi.test(k)!=boo){
                    able=false;
                    break;
                }
            }
        }
        }

        if(able){
            ans=max(ans,(long long) __builtin_popcount(bi.to_ullong()));
        }
    }

    cout<<ans<<endl;
}   

Measured memory_bytes: 256
import java.io.*;
import java.math.*;
import java.util.*;
public class Main {

	public static void main(String[] args) {
		Scanner input = new Scanner(System.in);
		long A = input.nextLong();
		long B = input.nextLong();
		long limit = Math.min(A,B);
		long ans = 0;
		for (long i = 2; i <= Math.sqrt(limit); i++) {
			if (A%i==0&&B%i==0) ans++;
			while (A%i==0&&B%i==0) {
				A/=i;
				B/=i;
			}
		}
		if (GCD(A,B)>1) ans++; //Breaking case: 111 74
		ans++; //Including 1
		System.out.println(ans);
	}
	public static long GCD(long A, long B) {
		if (A==0||B==0) return Math.max(A, B);
		return GCD(Math.max(A, B)%Math.min(A, B),Math.min(A, B));
	}
}

Measured memory_bytes: 23764
const input = require('fs').readFileSync('/dev/stdin', 'utf8');

const r = Number(input);

const output = () => {
  if (r < 1200) {
    console.log('ABC');
  } else if (r < 2800) {
    console.log('ARC');
  } else {
    console.log('AGC');
  }
}

output();


Measured memory_bytes: 7372
#include<algorithm>
#include<iostream>
#include<cstring>
#include<cmath>
#include<vector>
using namespace std;

int main()
{
	long long int i, j, k, l, m, n,A,B, sum, flag, cc, cnt;
	sum = 0;
	flag = 1;
	cin >> A >> B;
	if (A % 2 == 1 &&B % 2 == 1) {
		cout << "Yes" << endl;
	}
	else
		cout << "No" <<endl;

    return 0;
}



Measured memory_bytes: 256
uses
  SysUtils,
  Classes;

 function JudgeFunc(const Value : Integer) : string;
	const
		cake = 4;
		donut = 7;
	var
		i : Integer;
		remaining : Integer;
	begin
	Result := 'No';
	for i := 0 to Value div donut do
		begin
		remaining := Value - (i * donut);
		if (remaining = 0) or ((remaining mod cake) = 0) then
			Result := 'Yes';
		end;
	end;
  
 procedure MainProc;
	var
		input : Integer;
		output : string;
	begin
	ReadLn(input);
	output := JudgeFunc(input);
	WriteLn(output);
	end;
  
begin
MainProc;
end.


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

int main(){
    int N, x[100], y[100], h[100];

    cin >> N;
    for(int i = 0; i < N; i++)
        cin >> x[i] >> y[i] >> h[i];
    
    int cx, cy, height;

    for(cy = 0; cy < 101; cy++){
        for(cx = 0; cx < 101; cx++){
            int flag = 0;
            for(int j = 0; j < N; j++){
                if(h[j] != 0){
                    if(flag == 0){
                        height = h[j] + abs(x[j] - cx) + abs(y[j] - cy);
                        flag = 1;
                    }
                    else{
                        if(height != h[j] + abs(x[j] - cx) + abs(y[j] - cy)){
                            flag = -1;
                            break;
                        }
                    }
                }
            }
            if(flag != -1){
                for(int k = 0; k < N; k++){
                    if(h[k] == 0){
                        if (height > abs(x[k] - cx) + abs(y[k] - cy)){
                            flag = -1;
                            break;
                        }
                    }
                }
            }
            if(flag != -1){
                cout << cx << " " << cy << " " << height << endl;
                return 0;
            }
        }
    }
}

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

const double pi = acos(-1); 

int main(){
  double r;
  cin >> r;
  double ans = 2*pi*r;
  cout << fixed << setprecision(10);
  cout << ans << endl;
  return 0;
}


Measured memory_bytes: 3788
#include<iostream>
using namespace std;
int main(){
	int a[32]={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};
    int k;
    cin>>k;
    cout<<a[k-1];
   }


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

int dgt[10];

int main()
{
    int N;
    cin >> N;
    for(int i = 0; N > 0; ++i) {
        dgt[i] = N%10; N /= 10;
    }
    for(int i = 0; i < 2; ++i) {
        if(dgt[i] == dgt[i+1] && dgt[i+1] == dgt[i+2]) {
            cout << "Yes" << endl; return 0;
        }
    }
    cout << "No" << endl;
    return 0;
}

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

int main(){
string t ;
cin >> t;
int n = (int)t[0];
if(n<95) {
 cout << "A" <<endl;
 return 0;
}else{
cout << "a" <<endl;
 return 0;
}
}

Measured memory_bytes: 3596
#include<bits/stdc++.h>
using namespace std;
int f(int x){
  int keta=0;
  while(x!=0){
    x/=10;
    keta++;
  }
    return keta;
}
int main(){
  int N;
  cin>>N;
  int ans=0;
  for(int i=1;i<=N;i++){
    if(f(i)%2==1){
      ans++;
    }
  }
  cout<<ans<<endl;
}


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

int main() {
	int N;
	cin >> N;
	vector<vector<int>> cnt(20, vector<int>(20, 0));
	vector<string> A(N);
	for (int i=0;i<N;i++) {
		cin >> A[i];
		string tmp_num = "000000000";
		string int_num = "";
		int dot_index = -1;
		for (int j=0;j<A[i].length();j++) {
			if (dot_index == -1 && A[i][j] != '.') int_num += A[i][j];
			if (dot_index != -1) tmp_num[j-1-dot_index] = A[i][j];
			if (A[i][j] == '.') {
				dot_index = j;
			}
		}

		long long num = stoll(int_num+tmp_num);
		// cout << num << endl;
		int two = 0;
		while (num!=0 && num%2 == 0) {
			num /= 2;
			two++;
		}
		int five = 0;
		while (num!=0 && num%5 == 0) {
			num /= 5;
			five++;
		}
		if (two >= 20) two = 19;
		if (five >= 20) five = 19;
		cnt[two][five]++;
	}

	long long ans = 0LL;
	for (int i=0;i<20;i++) {
		for (int j=0;j<20;j++) {
			long long tmp = 0LL;
			if (cnt[i][j] == 0) continue;
			for (int k=max(0, 18-i);k<20;k++) {
				for (int l=max(0, 18-j);l<20;l++) {
					if (i == k && j == l) {
						tmp += (long long)(cnt[i][j]-1)*cnt[k][l];
					} else {
						tmp += (long long)cnt[i][j]*cnt[k][l];
					}
				}
			}
			ans += tmp;
		}
	}
	cout << ans/2 << endl;
	// for (int i=0;i<20;i++) {
	// 	for (int j=0;j<20;j++) {
	// 		cout << cnt[i][j] << " ";
	// 	}
	// 	cout << endl;
	// }
}

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

int main() {
    int a, b, d, r;
    double f;
    cin >> a >> b;
    d = a/b;
    r = a%b;
    f = (double)a/b;
    cout << d << " " << r << " " << fixed << setprecision(6) << f << endl;
}


Measured memory_bytes: 3276
//#define _GLIBCXX_DEBUG
#include <bits/stdc++.h>
typedef int64_t int64;
typedef uint32_t uint;
typedef uint64_t uint64;
using namespace std;

//---

template <typename T>
inline void print(const T& rhs){ std::cout<<" = "<<rhs<<std::endl; }
template <typename T>
inline void print(const std::vector<T>& rhs){
    std::cout<<" = [ ";
    for(uint i=0; i<rhs.size(); ++i){ std::cout<<rhs[i]<<' '; }
    std::cout<<"]"<<std::endl;
}
template <typename T>
inline void print(const std::vector<std::vector<T>>& rhs){
    std::cout<<" = "<<std::endl;
    std::cout<<"[[ ";
    for(uint p=0; p<rhs.size(); ++p){
        if(p!=0){ std::cout<<" [ "; }
        for(uint q=0; q<rhs[p].size(); ++q){
            std::cout<<rhs[p][q]<<' ';
        }
        if(p!=rhs.size()-1){ std::cout<<"]"<<std::endl; }
    }
    std::cout<<"]]"<<std::endl;
}
template <typename TL, typename TR>
inline void print(const std::vector<std::pair<TR,TL>>& rhs){
    std::cout<<" = [";
    uint i=0;
    for(; i<rhs.size()-1; ++i){ std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"], "; }
    std::cout<<"[f: "<<rhs[i].first<<", s: "<<rhs[i].second<<"]]" << endl;
}
#define printn(var) {printf("%s", #var);print(var);}
#define printn_all(var) {printf("%s(%d): ", __func__, __LINE__);printf("%s", #var);print(var);}

//---

int main(){
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    
    int N; cin >> N;
    cout << (N/3) << endl;
    
    return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int n,S[50];

int main(){
  int num2,M,i;
  
  scanf("%d",&n);
  for(i=0; i<n; i++)
    scanf("%d",&S[i]);
  
  scanf("%d",&num2);
  
  for(i=0; i<num2; i++){
    scanf("%d",&M);
    
    if(solve(0,M)==1) printf("yes\n");
    else printf("no\n");
  }
  
  return 0;
}

int solve(int i,int m){
  
  if( m == 0 ) return 1;
  if( i >= n ) return 0;
  int res = solve( i + 1 , m ) || solve( i + 1 , m - S[i] );
  return res;

}

Measured memory_bytes: 580
#include <iostream>
#include <cstdio>
#include <vector>
#include <algorithm>
#include <map>
#include <numeric>
#include <string>
#include <cmath>
#include <iomanip>
#include <queue>
#include <list>
#include <stack>
#include <set>
#include <cctype>
#include <cmath>

using namespace std;

/* typedef */

typedef long long ll;

/* constant */

const int INF = 1 << 30;
const int MAX = 10000;
const int mod = 1000000007;
const double pi = 3.141592653589;
/* global variables */

/* function */
void printAns(bool can);

/* main */
int main(){

    int n, q, k;
    bool can;
    cin >> n;
    vector<int> a(n);
    for (int i = 0; i < n; i++) cin >> a[i];
    cin >> q;
    for (int i = 0; i < q; i++) {
        cin >> k;
        auto it = lower_bound(a.begin(), a.end(), k);
        int dist = it - a.begin();
        cout << dist << '\n';
    }

    //printAns(can);
}

void printAns(bool can) {
    if (can)
        cout << 1 << '\n';
    else 
        cout << 0 << '\n';
}



Measured memory_bytes: 3100
#include <bits/stdc++.h>
using namespace std;
int main() {
	int n, k, d, tmp, cnt = 0;
	cin >> n >> k;
	vector<int> ns(n, 0);

	for (int i = 0; i < k; i++) {
		cin >> d;
		for (int j = 0; j < d; j++) {
			cin >> tmp;
			ns.at(tmp - 1)++;
		}
	}
	for (int i = 0; i < n; i++) {
		if (ns.at(i) == 0) {
			cnt++;
		}
	}
	cout << cnt << endl;
}

Measured memory_bytes: 3632
import java.util.*;

public class Main {
	public static void main(String[] args) throws Exception{
		Scanner scn = new Scanner(System.in);
		int n = scn.nextInt();
      	int m = scn.nextInt();
		int[][] a = new int[n][2];
		for(int i=0; i<n; i++){
          for(int j=0; j<2; j++){
			a[i][j] = scn.nextInt();
          }
		}
      	int[][] c = new int[m][2];
		for(int i=0; i<m; i++){
          for(int j=0; j<2; j++){
			c[i][j] = scn.nextInt();
          }
		}
      	for(int i=0; i<n; i++) {
    		int min = (int)Math.pow(10, 9);
    		int min2 = 0;
    		for(int j=0; j<m; j++) {
      			int x =  Math.abs(a[i][0]-c[j][0])+Math.abs(a[i][1]-c[j][1]);
      			if(x<min) {
        			min = x;
        			min2 = j;
      			}
    		}
    		System.out.println(min2 + 1);
        }
	}
}


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

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

    int n;
    cin>>n;

    priority_queue<double,vector<double>, greater<int> > q;

    double x;

    while(n--)
    {
        cin>>x;
        q.push(x);
    }

    while(!q.empty())
    {
        x=q.top();
        q.pop();
        if(!q.empty())
        {
            double y=q.top();
            q.pop();
            y+=x;
            y/=2.0;
            q.push(y);
        }
        else cout<<x;
    }
}


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

int main() {
    char b; cin >> b;
    if (b == 'A') {
        cout << "T" << endl;
    }
    else if (b == 'T') {
        cout << "A" << endl;
    }
    else if (b == 'G') {
        cout << "C" << endl;
    }
    else {
        cout << "G" << endl;
    }
}

Measured memory_bytes: 256
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
#define SIZE 300005
#define MOD 1000000007LL
#define EPS 1e-10
#define INF 2147483647
#define LLINF 9223372036854775807
#define REP(i,n) for(int i=0;i<n;i++)
#define FOR(i,a,b) for(int i=a;i<=b;i++)
#define DOWN(i,b,a) for(int i=b;i>=a;i--)
#define SET(a,c) memset(a,c,sizeof a)
#define BIT(i,j) ((i)>>(j))&1
#define ALL(o) (o).begin(), (o).end()
#define ERASE(o) (o).erase(unique((o).begin(),(o).end()), (o).end())
#define SQ(x) ((x)*(x))
using namespace std;
typedef long long ll;
typedef pair<ll,ll> Pll;
typedef pair<int, int> Pii;
typedef pair<double, double> Pdd;
typedef complex<double> dcomplex;
template<typename T> inline void priv(vector<T>a){REP(i,a.size()){cerr<<a[i]<<((i==a.size()-1)?"\n":" ");}}
inline void fastio(){cin.tie(nullptr); cout.tie(nullptr); ios::sync_with_stdio(false); cout << fixed << setprecision(15);}
ll gcd(ll a,ll b){int c=max(a,b);int d=min(a,b);return c==0||d==0?c:gcd(c%d,d);}
ll lcm(ll a,ll b){return a==0||b==0?0:a*b/gcd(a,b);}
ll modfact(ll a){ll b=1;FOR(i,2,a)b=b*i%MOD;return b;}
ll modpow(ll a, ll n){ll b=1;while (n>0){if(n&1)b=b*a%MOD;a=a*a%MOD;n>>=1;}return b;}
ll modcomb(ll n, ll k){ll b=1;k=min(n-k,k);DOWN(i,n,n-k+1)b=b*i%MOD;return b*modpow(modfact(k),MOD-2)%MOD;}

int N, M;
int A[1000], B[1000], C[1000];
int dist[100][100];

int main() {
    fastio();
    int N, M;
    int inf = 100000000;
    cin >> N >> M;
    REP(i, N) REP(j, N) dist[i][j] = i == j ? 0 : inf;
    REP(i, M) {
        cin >> A[i] >> B[i] >> C[i];
        A[i]--; B[i]--;
        dist[A[i]][B[i]] = min(dist[A[i]][B[i]], C[i]);
        dist[B[i]][A[i]] = min(dist[B[i]][A[i]], C[i]);
    }
    REP(i, N) REP(j, N) REP(k, N)
        dist[j][k] = min(dist[j][k], dist[j][i] + dist[i][k]);
    int ans = M;
    REP(i, M) {
        REP(s, N) {
            if(dist[s][A[i]] + C[i] == dist[s][B[i]]) {
                ans--; break;
            }
        }
    }
    cout << ans << "\n";
	return 0;
}

Measured memory_bytes: 256
import sys
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines


def main():
    N = int(readline())
    ans = 0
    for i in  range(1, N):
        ans += (N-1)//i
    print(ans)
if __name__ == '__main__':
    main()


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

//repetition
#define FOR(i,a,b) for(ll i=(a);i<(b);++i)
#define rep(i, n) for(ll i = 0; i < (ll)(n); i++)

//container util
#define all(x) (x).begin(),(x).end()

//typedef
typedef long long ll;
typedef vector<int> VI;
typedef vector<VI> VVI;
typedef vector<ll> VLL;
typedef vector<VLL> VVLL;
typedef vector<string> VS;
typedef pair<int, int> PII;
typedef pair<ll, ll> PLL;

//const value
//const ll MOD = 1e9 + 7;
//const int dx[] = {0,1,0,-1};//{0,0,1,1,1,-1,-1,-1};
//const int dy[] = {1,0,-1,0};//{1,-1,0,1,-1,0,1,-1};

//conversion
inline int toInt(string s) {int v; istringstream sin(s);sin>>v;return v;}
inline ll toLL(string s) {ll v; istringstream sin(s);sin>>v;return v;}
template<class T> inline string toString(T x) {ostringstream sout;sout<<x;return sout.str();}

#define MAX_N 1010
const int MAX = 510000;
const int MOD = 1000000007;

long long fac[MAX], finv[MAX], inv[MAX];

// テーブルを作る前処理
void COMinit() {
    fac[0] = fac[1] = 1;
    finv[0] = finv[1] = 1;
    inv[1] = 1;

    for (ll i = 2; i < MAX; i++){
        fac[i] = fac[i - 1] * i % MOD;
        inv[i] = MOD - inv[MOD%i] * (MOD / i) % MOD;
        finv[i] = finv[i - 1] * inv[i] % MOD;
    }
}

// 二項係数計算
long long COM(ll n, ll k){
  if (n < k) return 0;
  if (n < 0 || k < 0) return 0;
  return fac[n] * (finv[k] * finv[n - k] % MOD) % MOD;
}

ll perm(ll a, ll b){
    if(a < b) return 0;
    ll tmp = finv[a-b] % MOD;
    return tmp * fac[a] % MOD;
}


long long modPow(long long x, long long n){
  if(n == 0) return 1;
  if(n % 2 == 0) {
    long long sqrtX = modPow(x,n/2);
    return sqrtX * sqrtX % MOD ;
  }else{
    return x * modPow(x,n-1) % MOD;
  }
}

ll dp[MAX_N][MAX_N];
int main(){
  COMinit();
  ios::sync_with_stdio(false);
  cin.tie(0);
  ll n,a,b,c,d;
  cin >> n >> a >> b >> c >> d;
  dp[0][0] = 1;

  FOR(i,1,n+1){
    rep(j,n+1){
      (dp[i][j] += dp[i-1][j]) %= MOD;
      if(a > i || i > b){
        continue;
      }
      // i人グループをk組み作る
      ll tmp = 1;
      ll tmp2 = finv[0];
      FOR(k,1,d+1){
        if(j + k*i > n) break;

        (tmp *= COM((n-j)-i*(k-1),i)) %= MOD;
        (tmp2 *= inv[k]) %= MOD;

        if(k < c) continue;
        dp[i][j+i*k] += ((dp[i-1][j] * tmp) % MOD) * tmp2;
        dp[i][j+i*k] %= MOD;
      }

    }
  }
  // rep(i,n+1){
  //   rep(j,n+1){
  //     cout << dp[i][j] << " ";
  //   }
  //   cout << endl;
  // }
  cout << dp[n][n] << endl;
  return 0;
}


Measured memory_bytes: 20224
import numpy as np
m,d = map(int,input().split())
ans = 0
for i in range(1,m+1):
    for j in range(10,d+1):
        temp = str(j)
        l = int(temp[0])
        r = int(temp[1])
        if l >= 2 and r >= 2 and l*r == i:
            ans += 1

print(ans)



Measured memory_bytes: 12612
#include <bits/stdc++.h>
using namespace std;
#pragma GCC optimize("Ofast")
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int (i)=0;i<(n);i++)
#define REP(i,m,n) for(int (i)=(m);(i)<(n);(i)++)
#define INF LLONG_MAX - 100
#define MOD 1000000007
#define fcout cout << fixed << setprecision(15)
#define int long long
#define yorn(f) puts((f)?"Yes":"No")
#define YORN(f) puts((f)?"YES":"NO")
#define lower_bound lowb
#define upper_bound upb
typedef long long ll;
typedef pair<int, int> P;
typedef priority_queue<int> pque;
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 mod(int a,int b){return (a+b-1)/b;};
int month[12] = {31,28,31,30,31,30,31,31,30,31,30,31};
template<typename A, size_t N, typename T>
void Fill(A(&array)[N],const T &val){std::fill((T*)array,(T*)(array+N),val);}
template<class T>inline bool chmax(T& a,T b){if(a<b){a=b;return true;}return false;};
template<class T>inline bool chmin(T& a,T b){if(a>b){a=b;return true;}return false;};



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

	int n;
	cin >> n;
	stack<int> s;
	bool b[110] = {};

	rep(i, n) {
		int p; cin >> p;
		if (p > 0) {
			if (b[p]) {
				cout << i + 1 << endl;
				return 0;
			}
			s.push(p);
			b[p] = 1;
		}
		else if (s.size() == 0 || s.top() != -p || !b[-p]) {
			cout << i + 1 << endl;
			return 0;
		}
		else {
			b[-p] = 0;
			s.pop();
		}
	}
	puts("OK");
	return 0;
}



Measured memory_bytes: 3220
#include <bits/stdc++.h>
using namespace std;
int m,n,i,j,a[200][200],dp[200][200];
int main()
{
  //  freopen("A.in","r",stdin);
    //freopen("A.out","w",stdout);
    scanf("%d",&m);
    n=2;
    for(i=1;i<=n;i++)
    {
        for(j=1;j<=m;j++)
        {
            scanf("%d",&a[i][j]);
        }
    }
    for(j=1;j<=m;j++)
    {
        dp[1][j]=dp[1][j-1]+a[1][j];
    }
    for(i=1;i<=n;i++)
    {
        dp[i][1]=dp[i-1][1]+a[i][1];
    }
    for(i=2;i<=n;i++)
    {
        for(j=2;j<=m;j++)
        {
            dp[i][j]=max(dp[i-1][j], dp[i][j-1])+a[i][j];
        }
    }
    printf("%d",dp[n][m]);
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <iomanip>
#include <vector>
#include <set>
#include <string>
#include <queue>
#include <algorithm>
#include <map>
#include <cmath>
#include <numeric>
#include <list>
#include <stack>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <tuple>
#include <deque>

using namespace std;

/*
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;
typedef vector<pii> vpii;
*/

typedef long long ll;
typedef vector<ll> vll;
typedef vector<vll> vvll;
typedef pair<long long, long long> pll;
typedef vector<pll> vpll;

typedef long double ld;
typedef vector<ld> vld;

typedef vector<bool> vb;

#define rep(i, n) for (ll i = 0; i < (n); i++)
#define reps(i, n) for (ll i = 1; i <= (n); i++)
#define rrep(i, n) for (ll i = (n) - 1; i >= 0; i--)
#define rreps(i, n) for (ll i = (n); i >= 1; i--)
#define all(v) (v).begin(), (v).end()

template <class T> void chmin(T& a, T b) { a = min(a, b);}
template <class T> void chmax(T& a, T b) { a = max(a, b);}

constexpr int INF = 1 << 30;
constexpr ll INFL = 1LL << 60;
constexpr ll MOD = 1000000007;
constexpr ld EPS = 1e-12;
constexpr ld PI = 3.14159265358979323846;

void solve() {
    ll a, b, c, k;
    cin >> a >> b >> c >> k;
    ll ans;
    if(a >= k) ans = k;
    else if(a+b >= k) ans = a;
    else ans = a - (k - a - b);
    cout << ans << endl;
    return;
}

int main() {
    std::cin.tie(nullptr);
    std::ios_base::sync_with_stdio(false);
    cout << fixed << setprecision(15);
    solve();
}

Measured memory_bytes: 3648