akhauriyash/Code-Regression huggingface dataset:
'''
ベルマンフォード法。
始点を固定した時にすべての頂点に対する最短経路を計算する。
負の辺が使われている場合に使う。
負のループがどこかにあればそれだけで検出する。

O(|E||V|)
'''
class BellmanFord():
    def __init__(self, N):
        '''
        Parameters
        ----------
        N:int
            the number of nodes
        '''
        self.N = N
        self.edges = []
    
    def add(self, u, v, d, directed=False):
        '''
        Parameters
        ----------
        u:int
            from node (not 0-index)
        v:int
            to node (not 0-index)
        d:int
            cost
        directed:bool
            there is direction
        '''
        if directed is False:
            self.edges.append([u, v, d])
            self.edges.append([v, u, d])
        else:
            self.edges.append([u, v, d])

    def calc(self, s):
        '''
        Parameters
        ----------
        s:int
            start index (not 0-index)
        
        Returns
        ----------
        list or bool
            d[i] is shortest distances from node[s] to node[i]
            if there is negative loop, return False
        '''
        dist = [float('inf') for i in range(self.N)]
        dist[s-1] = 0
        #辺の緩和
        for i in range(self.N):
            for edge in self.edges:
                frm, to, cost = edge[0] - 1, edge[1] - 1, edge[2]
                # dist[frm]!=inf ->sから到達可能を意味する
                if dist[frm] != float('inf') and dist[to] > dist[frm] + cost:
                    dist[to] = dist[frm] + cost
                    # どこに負のループがあっても検出する
                    # if i == self.N - 1: return False
                    # 頂点Nに行く際に負のループがあるときだけ検出する
                    if i == self.N - 1 and to==self.N-1: return False
        return dist[-1]

'''
ABC061-D
N頂点M辺の重み付き有向グラフがあり、
頂点a_iから頂点b_iを重みc_iで結んでいる。
その辺を移動したときスコアc_iが加算される。
頂点1から始まり、頂点Nに駒があるときゲームを終了できる。
頂点1からNまで移動できることは保証されている。
ゲーム終了時のスコアを最大にするような行動をとった時の最大スコアを出力せよ。
スコアが無限に大きくなる場合はinfを出力せよ。

term:
2<=N<=1000
1<=M<=min(N(N-1),2000)
1<=a_i,b_i<=N
-10**9<=c_i<=10**9

input:
3 3
1 2 4
2 3 3
1 3 5

output:
    7
'''

from collections import defaultdict,deque
import sys, bisect, math, itertools, heapq
from operator import itemgetter
# a.sort(key=itemgetter(i)) # i番目要素でsort
from functools import lru_cache
# @lru_cache(maxsize=None)
sys.setrecursionlimit(10**8)
input = sys.stdin.readline
INF = float('inf')
mod = 10**9+7
eps = 10**-7
def inpl():
    '''
    一行に複数の整数
    '''
    return list(map(int, input().split()))

n, m = inpl()
graph=BellmanFord(n)
for _ in range(m):
    a, b, c = inpl()
    graph.add(a, b, -c, directed=True)  #\sum c_iを最大化する
result = graph.calc(1)
if result:
    print(-result)
else:
    print("inf")

'''
負になる閉路に頂点Nが入っていなければその閉路を経由して頂点Nにたどりつけない。
'''

Measured memory_bytes: 42332
import sys
import itertools
# import numpy as np
import time
import math
import heapq
from collections import defaultdict
from collections import Counter
sys.setrecursionlimit(10 ** 7)
 
INF = 10 ** 18
MOD = 10 ** 9 + 7
read = sys.stdin.buffer.read
readline = sys.stdin.buffer.readline
readlines = sys.stdin.buffer.readlines

# map(int, input().split())

M, D = map(int, input().split())

ans = 0
for i in range(1, M + 1):
    for j in range(1, D + 1):
        d1 = j // 10
        d2 = j % 10
        if d1 < 2 or d2 < 2:
            continue
        if d1 * d2 == i:
            ans += 1
print(ans)


Measured memory_bytes: 9376
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define SIZE 16 //1000 + " " + 1000 + " " + 1000 + \n + \0

int cmp(const void *a, const void *b) {
    return *(int *)a - *(int *)b;
}
int main() {
    char line[SIZE];
    int n_lines;
    scanf("%d", &n_lines);
    int num[3];
    for (int i = 0; i < n_lines; i++) {
        scanf("%d %d %d", &num[0], &num[1], &num[2]);

        qsort(num, 3, sizeof(int), cmp);

        if (num[2] * num[2] == num[0] * num[0] + num[1] * num[1]) {
            printf("YES\n");
        } else {
            printf("NO\n");
        }
    }
}



Measured memory_bytes: 2036
N, M = map(int, input().split())
s = []
for _ in range(M):
    ss = list(map(int, input().split()))
    s.append(ss[1:])
p = list(map(int, input().split()))

ans = 0
for i in range(2 ** N):
    check = True
    for k in range(M):
        count = 0
        for ss in s[k]:
            if (i >> (ss - 1)) & 1 == 1:
                count += 1
        if count % 2 != p[k]:
            check = False
    if check:
        ans += 1

print(ans)


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

using namespace std;

char a[60][60];

int main(){
    memset(a,'.',sizeof(a));
    int h,w;
    cin>>h>>w;
    for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
            cin>>a[i][j];
    }
    int flag=true;
      for(int i=1;i<=h;++i)
    {
        for(int j=1;j<=w;++j)
            {
                if(a[i][j]=='.')
                    continue;
                else
                {
                    if(a[i-1][j]=='.'&&a[i][j-1]=='.'&&a[i+1][j]=='.'&&a[i][j+1]=='.')
                    {
                        flag=false;
                        break;
                    }
                }
            }
    }
    if(flag)
        cout<<"Yes";
    else
        cout<<"No";
    return 0;
}



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

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

    bool flag = false; int counter = 0;
    for ( int i = 0; i < s.length(); i++ ){
        if ( i >= 2 && i < s.length() - 1 && s[i] == 'C' ){
            flag = true;
        }
        if ( islower( s[i] ) ){
            counter++;
        }
    }

    if ( s[0] == 'A' && flag == true && counter == s.length() - 2 ){
        cout << "AC";
    }
    else{
        cout << "WA";
    }
    return 0;
}

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

int main(){
    int n,i;
    while(cin>>n,n){
        map<int,long long>m;
        vector<int>vec;
        long long p,q,s=0;
        while(n--){
            cin>>i>>p>>q;
            if(!m[i])vec.push_back(i);
            m[i]+=p*q;
        }
//        for (map<int,long long>::iterator it=m.begin(); it!=m.end(); ++it){
//            cout<<it->first<<endl;
//            if(it->second>=1000000){
//                s=1;
//                cout<<it->first<<endl;
//            }
//        }
        for (int i=0;i<vec.size();i++){
            if(m.find(vec[i])->second>=1000000){
                s=1;
                cout<<m.find(vec[i])->first<<endl;
            }
        }
        if(!s)cout<<"NA"<<endl;
    }
}

Measured memory_bytes: 1288
import math,itertools,fractions,heapq,collections,bisect,sys,queue,copy

sys.setrecursionlimit(10**7)
inf=10**20
mod=10**9+7
dd=[(-1,0),(0,1),(1,0),(0,-1)]
ddn=[(-1,0),(-1,1),(0,1),(1,1),(1,0),(1,-1),(0,-1),(-1,-1)]

def LI(): return [int(x) for x in sys.stdin.readline().split()]
def I(): return int(sys.stdin.readline())
def LS(): return sys.stdin.readline().split()
def S(): return input()

def main():
  s=S()
  i_f=0
  i_b=len(s)-1

  ans=0
  while True:
    if i_f>=i_b:
      return ans

    # print(i_f,i_b)
    if s[i_f]==s[i_b]:
      i_f+=1
      i_b-=1
    else:
      if s[i_f]=='x':
        i_f+=1
        ans+=1
      elif s[i_b]=='x':
        i_b-=1
        ans+=1
      else:
        return -1

# main()
print(main())


Measured memory_bytes: 5332
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <utility>
using namespace std;
typedef long long ll;
#define rep(i,n) for (int i=0;i < (int)(n);i++)

int main(){
  int n,m;
  string s;
  cin >> n >> m;
  vector<pair<int,int>> v(n);
  vector<pair<int,int>> u(m);
  rep(i,n){
     int x,y;
     cin >> x >> y;
     pair<int,int> p=make_pair(x,y);
     v[i]=p;
  }
  rep(i,m){
     int x,y;
     cin >> x >> y;
     pair<int,int> p=make_pair(x,y);
     u[i]=p;
  }
  int id=0;
  rep(i,n){
     int ans= 1 << 30;
     rep(j,m){
        if (ans > abs(v[i].first-u[j].first)+abs(v[i].second-u[j].second)){
         ans=min(ans,abs(v[i].first-u[j].first)+abs(v[i].second-u[j].second));
         id=j;
        }
     }
     cout << id+1 << endl;
  }

   return 0;
}



Measured memory_bytes: 256
#include <iostream>
#include <math.h>
#include <cmath>
using namespace std;
 
int main() {
  int h, w;
  cin >> h >> w;
  int roads[h][w];
  for (int h1 = 0; h1 < h; h1 ++ ) {
    for (int w1 = 0; w1 < w; w1 ++ ) {
      cin >> roads[h1][w1]; 
    }
  }
  int min = 100000000;
  int count = 0;
  for (int h1 = 0; h1 < h; h1 ++ ) {
    for (int w1 = 0; w1 < w; w1 ++ ) {
      for (int h2 = 0; h2 < h; h2 ++) {
        for (int w2 = 0; w2 < w; w2 ++ ) {
          if (abs(w1-w2) <= abs(h1-h2)) {
            count += abs(w1-w2)*roads[h2][w2];
          }
          else {
            count += abs(h1-h2)*roads[h2][w2];
          }
        }
      }
      if (count < min) {
      min = count;
      count = 0;
    }
    count = 0;
    }
    
  }
   cout << min << endl;
}


Measured memory_bytes: 3088
#include<iostream>
using namespace std;
 
 int main(){
  char n, N[10000];
  
  for ( int i = 0; i < 4; i++ ) cin >> N[i];
    
 
 if ((N[0] == N[1]) && (N[2] == N[3]) && (N[1] == N[2])) {
  cout << "Yes" << endl;
  }
 
  else if((N[0] == N[1]) && (N[1] == N[2])) {
  cout << "Yes" << endl;
  }
 
  else if((N[1] == N[2]) && (N[2] == N[3])) {
  cout << "Yes" << endl;
  }
 
  else cout << "No" << endl;
 
 return 0;
}

Measured memory_bytes: 256
import sys


def resolve(in_):
    n = int(in_.readline())
    a = tuple(map(int, in_.readline().split()))
    return sum(1 for i, v in enumerate(a, 1) if i % 2 and v % 2)


def main():
    answer = resolve(sys.stdin.buffer)
    print(answer)


if __name__ == '__main__':
    main()

Measured memory_bytes: 9140
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <math.h>
#include <iomanip>
#include <map>
using namespace std;

#define INF 1e9
#define LLINF 1e18
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
typedef long long ll;

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


int main() {
    ll x;
    cin >> x;
    ll ans = (x / 11) * 2;
    x %= 11;
    if (x > 6) ans += 2;
    else if (x == 0);
    else ans ++;
    cout << ans << endl;
}

Measured memory_bytes: 256
fun main(args: Array<String>) {
    val (a , b) = readLine()!!.split(' ').map { it.toInt() }
    val astr = StringBuffer("")
    repeat(a) {
        astr.append(b)
    }
    val bstr = StringBuffer("")
    repeat(b) {
        bstr.append(a)
    }
    println(listOf(astr.toString(),bstr.toString()).sorted()[0])
}


Measured memory_bytes: 38240
#include <stdio.h>
#include <algorithm>
#include <utility>
#include <functional>
#include <cstring>
#include <queue>
#include <stack>
#include <cmath>
#include <iterator>
#include <vector>
#include <string>
#include <set>
#include <iostream>
#include <random>
#include <map>
#include <iomanip>
#include <stdlib.h>
#include <list>
#include <typeinfo>
#include <list>
#include <set>
#include <cassert>
#include <fstream>
#include <unordered_map>
#include <cstdlib>
#include <complex>
#include <cctype>
#include <bitset>
using namespace std;

using ll = long long;
using vll = vector<long long>;
using pll = pair<long long, long long>;
#define rep(i,n) for(long long i(0);(i)<(n);(i)++)


void solve(long long N, long long H, long long W, std::vector<long long> A, std::vector<long long> B){
    ll cnt = 0;
    rep(i, N){
        if(A[i]>= H && B[i]>= W)
            cnt ++;
    }
    cout << cnt << endl;
}

int main(){
    long long N;
    scanf("%lld",&N);
    long long H;
    scanf("%lld",&H);
    long long W;
    scanf("%lld",&W);
    std::vector<long long> A(N);
    std::vector<long long> B(N);
    for(int i = 0 ; i < N ; i++){
        scanf("%lld",&A[i]);
        scanf("%lld",&B[i]);
    }
    solve(N, H, W, std::move(A), std::move(B));
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <queue>
#include <set>
#include <map>
#include <vector>
#include <stack>
#include <cmath>
#include <algorithm>
#include <cstdio>
#include <cctype>
#include <functional>
#include <string>
#include <cstring>
#include <sstream>
#include <deque>
#define fir first
#define sec second
using namespace std;

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

const int inf1=2e9+9;
const ll inf2=8e18+9;
const ll mol=1e4;//1e9+7;
const int maxn=1e5+9;
const ll maxx=1e12+9;

int n,num;

int main()
{
    cin>>n;
    int cnt=0;
    for(int i=1;i<=n;i++)
    {
        cin>>num;
        if((num&1)&&(i&1)) cnt++;
    }
    cout<<cnt<<endl;
}


Measured memory_bytes: 3620
import collections
import itertools
import numpy as np
import sys
def IL(): return list(map(int,input().split()))
def SL(): return input().split()
def I(): return int(sys.stdin.readline())
def S(): return input()

N = I()
a = IL()
l = [0,a[0]]
for i in range(1,N):
    l.append(l[i]+a[i])

ll = collections.Counter(l)
a = list(ll.values())

ans = 0
for i in a:
  ans += i*(i-1)//2

print(ans)

Measured memory_bytes: 50368
### SNIPPET
  # n = gets.split.map(&:to_i)
  # array = n.times.map { gets.split.map(&:to_i) }
  # [].all?(&:even?)
  # a = [*1..m].repeated_combination(n).to_a
  # [1,2,3,4,5].select { |num| num.even? }  # => [2, 4]
  # ["a","a","b"].group_by(&:itself).map{|k,v| [k, v.count]}.to_h #=> {"a"=>2, "b"=>1}
  # 切り捨て: .floor(2).to_f ,切り上げ： .ceil(2).to_f,四捨五入: round(2)
  # 3.upto(6) do |i|, 6.downto(3) do |i|
  # 公約数125.gcd(100)、公倍数125.lcm(100)
  # PI = Math::PI
  # 高さ = a * Math.sin(w / 180.0 * Math::PI), 底辺 = a * Math.cos(w / 180.0 * Math::PI)
  # def chmax(a, b) a > b ? a : b end
  # INF = Float::INFINITY
  # def chmin(a, b) a < b ? a : b end

n = gets.chomp.split("").map(&:to_i)


if n.join("").to_i == 10000
  puts 0
  exit
elsif n.join("").to_i % 1000 == 0
  puts 0
  exit
elsif n.length < 4
  puts 1000 - n.join("").to_i
  exit
end
k = n[0]

puts (k.to_i+1) * 1000 - n.join("").to_i

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

int main(){
    string s;
    cin >> s;
    int flag = 0;
    if(s.at(2) == s.at(3) && s.at(4) == s.at(5)){
        flag = 1;
    }

    if(flag == 1){
        cout << "Yes" << endl;
    }else{
        cout << "No" << endl;
    }
}

Measured memory_bytes: 256
#include<cstdio>
#include<cstdlib>
#include<ctime>
#include<cmath>
#include<cstring>
#include<cctype>
#include<complex>
#include<iostream>
#include<sstream>
#include<algorithm>
#include<functional>
#include<vector>
#include<string>
#include<stack>
#include<queue>
#include<map>
#include<set>
#include<bitset>
using namespace std;
const int dx[] = {1,0,-1,0},dy[] = {0,1,0,-1};
#define INF 1e+8
#define EPS 1e-8
#define rep(i,j) for(int i = 0; i < (j); i++)
#define reps(i,j,k) for(int i = (j); i < (k); i++)
typedef long long ll;
typedef pair < int , int > Pii;
int main(){
	int ans;
	while(scanf("%d",&ans),ans){
		rep(i,9){
			int tmp;
			scanf("%d",&tmp);
			ans -= tmp;
		}
		printf("%d\n",ans);
	}
	return 0;
}

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

int		main(void)
{
	int n, ans = 0;

	cin >> n;
	for (int i = 1; i <= n; i += 2)
	{
		int cnt = 0;

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



Measured memory_bytes: 256
object Main {
    import scala.annotation.tailrec

    def main(args: Array[String]) = {
        val sc = new java.util.Scanner(System.in)

        output(sc)
    }

    @tailrec
    def output(scanner: java.util.Scanner): Unit = {
        val a = scanner.nextInt
        val op = scanner.next
        val b = scanner.nextInt

        if( op != "?" ) {
            op match {
                case "+" => println(a+b)
                case "-" => println(a-b)
                case "*" => println(a*b)
                case "/" => println(a/b)
            }

            output(scanner)
        }
    }

}



Measured memory_bytes: 44824
#include <iostream>
#include <vector>
#include <string>
#define rep(i, n)   for(int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;

int main(){
    int x,y,z;  cin >> x >> y >> z;
    printf("%d %d %d\n", z, x, y);
}


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

typedef long long ll;

#define SIZE_OF_ARRAY(array) (sizeof(array) / sizeof(array[0]))
#define rep(i, n) for (int i = 0; i < (n); ++i)
#define AA(i) cout << i << endl;
#define AS(i) cout << i << " ";

const int INF = 1001001001;
const double PI = 3.14159;

using namespace std;


int main() {

    int n;
    cin >> n;

   

    for (int i = 1; i <= n; i++) {

        int ans = 0;

        int MM = (int)sqrt(i);

        for (int j = 1; j < MM; j++) {
            for (int k = j; k < MM; k++) {
                for (int l = k; l < MM; l++) {

                    if ( pow(j + k + l, 2) - j*k - j*l - k*l == i) {
                        
                        if (j == k && j == l && k == l)
                            ans++;
                        else if (j == k || j == l || k == l)
                            ans += 3;
                        else 
                            ans += 6;
                    }
                        
                }
            }
        }

        AA(ans);
    }
}

Measured memory_bytes: 3676
#include<stdio.h>

int main(void){
  
  int N,K;
  char s[1000];
  
  scanf("%d %d",&N,&K);
  scanf("%s",s);
  
  if(s[K-1]=='A'){
    s[K-1]='a';
  }
  else if(s[K-1]=='B'){
    s[K-1]='b';
  }
  else if(s[K-1]=='C'){
    s[K-1]='c';
  }
  
  printf("%s\n",s);
  
  return 0;
}

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

using ll = long long;
using ull = unsigned long long;

const double PI = acos(-1);
const int inf = 2e9;
const ll INF = 2e18;
const ll MOD = 1e9+7;

#define sz(s) (s).size()
#define pb push_back
#define fi first
#define se second
#define REP(i,n) for (int i = 0; i<n; i++)
#define ALL(a) begin(a), end(a)

int main (void) {
    int N;
    cin>>N;
    int nowx = 0;
    int nowy = 0;
    int nowt = 0;
    bool ans = true;
    REP(i,N) {
        int t,x,y;
        cin>>t>>x>>y;
        int movet = t - nowt;
        int movex = abs(nowx - x), movey = abs(nowy - y);
        if (movet < movex + movey) {
            ans = false;
        }
        else if ((movet - movex - movey) % 2 == 1) {
            ans = false;
        }
        nowx = x;
        nowy = y;
        nowt = t;
    }
    if (ans) {
        cout<<"Yes"<<endl;
    }
    else {
        cout<<"No"<<endl;
    }
    return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <string>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <unordered_set>
#include <map>
#include <unordered_map>
#include <cmath>
#include <limits>
#include <climits>
#include <utility>
#include <algorithm>
#include <numeric>

using namespace std;

using ll = long long;
using ull = unsigned long long;

static const ull MOD = 1e+9 + 7;

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

    ull ans = 1;

    for (ull i = 1; i <= N; ++i) {
        ans = (ans * i) % MOD;
    }

    std::cout << ans << std::endl;

    return 0;
}


Measured memory_bytes: 256
#include <algorithm>
#include <iostream>
#include <iomanip>
#include <cstring>
#include <string>
#include <vector>
#include <queue>
#include <cmath>
#include <stack>
#include <set>
#include <map>
typedef long long ll;
typedef unsigned int uint;
using namespace std;

int main(){
  int H,W;
  cin >> H >> W;
  char s[H+2][W+2];
  for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      if(i==0 || i==H+1 || j==0 || j==W+1){
        s[i][j] = '.';
      }else{
        cin >> s[i][j];
      }
    }
  }

  /*for(int i=0;i<H+2;i++){
    for(int j=0;j<W+2;j++){
      cout << s[i][j];
    }
    cout << endl;
  }*/

  for(int i=1;i<=H;i++){
    for(int j=1;j<=W;j++){
      if(s[i][j]=='#'){
        if(s[i-1][j]=='.' && s[i+1][j]=='.' && s[i][j-1]=='.' && s[i][j+1]=='.'){
          cout << "No" << endl;
          return 0;
        }
      }
    }
  }

  cout << "Yes" << endl;
  return 0;
}

Measured memory_bytes: 256
#include <iostream>
#include <set>

int main()
{
    int a;
    std::set<int> st;
    for (int i = 0; i < 3; i++) {
        std::cin >> a;
        st.insert(a);
    }
    std::cout << st.size() << std::endl;
    return 0;
}


Measured memory_bytes: 256
#include <iostream>
#include <cstdio>
#include <complex>
#include <cmath>
using namespace std;
 
int main(int argc, char** argv) {
    double x, y;
    char c;
    cin >> x >> c >> y;
    complex<double> o(x, y);
    cin >> x >> c >> y;
    complex<double> a(x, y);
    a -= o;
    double s = 0.0;
    while(cin >> x >> c >> y) {
        complex<double> b(x, y);
        b -= o;
        s += 0.5*abs(a)*abs(b)*sin(abs(arg(a)-arg(b)));
        a = b;
    }
    printf("%.6f\n", s);
    return 0;
}


Measured memory_bytes: 3412
#include <bits/stdc++.h>
#define all(vec) vec.begin(), vec.end()
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr ll INF = (1LL << 30) - 1LL;
constexpr ll LINF = (1LL << 60) - 1LL;
constexpr double eps = 1e-9;
constexpr ll MOD = 1000000007LL;
template <typename T> bool chmin(T &a, T b) {
    if (a > b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> bool chmax(T &a, T b) {
    if (a < b) {
        a = b;
        return true;
    }
    return false;
};
template <typename T> ostream &operator<<(ostream &os, vector<T> v) {
    for (int i = 0; i < v.size(); i++) {
        os << v[i] << (i + 1 == v.size() ? "\n" : " ");
    }
    return os;
}
template <typename T> vector<T> make_v(size_t a) { return vector<T>(a); }
template <typename T, typename... Ts> auto make_v(size_t a, Ts... ts) {
    return vector<decltype(make_v<T>(ts...))>(a, make_v<T>(ts...));
}
template <typename T, typename V>
typename enable_if<is_class<T>::value == 0>::type fill_v(T &t, const V &v) {
    t = v;
}
template <typename T, typename V>
typename enable_if<is_class<T>::value != 0>::type fill_v(T &t, const V &v) {
    for (auto &e : t) {
        fill_v(e, v);
    }
};
int main() {
    cin.tie(0);
    ios::sync_with_stdio(false);
    int n;
    cin >> n;
    vector<int> a(n), ma(n + 1);
    for (int i = 0; i < n; i++) {
        cin >> a[i];
    }
    for (int i = n - 1; i >= 1; i--) {
        ma[i] = max(ma[i + 1], a[i]);
    }
    int m2 = 0;
    for (int i = 0; i < n; i++) {
        cout << max(ma[i + 1], m2) << endl;
        chmax(m2, a[i]);
    }
}


Measured memory_bytes: 3200
import java.io.*;
import java.io.IOException;
import java.util.*;

@SuppressWarnings({"rawtypes", "unchecked"})
class Main {
    final static int INF = 1 << 28;
    final static long LNF = 1L << 60;
    final static double EPS = 1e-9;
    final static double GOLDEN_RATIO = (1.0 + Math.sqrt(5)) / 2.0;

    static final long MOD = 1_000_000_007;

    public static void main(String[] args) throws Exception {
        final MyScanner sc = new MyScanner();
        long K;
        K = sc.nextLong();
        solve(K);
    }

    static void solve(long K){
        long[] arr = {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};
        System.out.println(arr[(int)K-1]);
    }


    static class MyScanner {
 
        BufferedReader br;
        StringTokenizer st;
 
        MyScanner(FileReader fileReader) {
            br = new BufferedReader(fileReader);
        }
 
        MyScanner() {
            br = new BufferedReader(new InputStreamReader(System.in));
        }
 
        String nn() {
            while (st == null || !st.hasMoreElements()) {
                try {
                    st = new StringTokenizer(br.readLine());
                } catch (IOException e) {
                    e.printStackTrace();
                }
            }
            return st.nextToken();
        }
 
        String next() {
            return nn();
        }

        String nextLine() {
            String ans = "";
            try {
                ans = br.readLine();
            } catch (IOException ex) {
                ex.printStackTrace();
            }
            return ans;
        }
 
        char nextChar() {
            return nn().charAt(0);
        }
 
        int nextInt() {
            return Integer.parseInt(nn());
        }
 
        long nextLong() {
            return Long.parseLong(nn());
        }
 
        double nextDouble() {
            return Double.parseDouble(nn());
        }
 
        Integer[] niArr0(int n) {
            Integer[] ar = new Integer[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Integer[] niArr1(int n) {
            Integer[] ar = new Integer[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextInt();
            }
            return ar;
        }
 
        Long[] nlArr0(int n) {
            Long[] ar = new Long[n];
            for (int i = 0; i < n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
 
        Long[] nlArr1(int n) {
            Long[] ar = new Long[n + 1];
            for (int i = 1; i <= n; i++) {
                ar[i] = nextLong();
            }
            return ar;
        }
    }

}


Measured memory_bytes: 22612
x1, y1, x2, y2=map(int, input().split())
s=x2 -x1
t=y2 -y1
d=s**2 +t**2

if s>=0 and t>=0:
    k=-t
    l=s
elif s<=0 and t<=0:
    k=-t
    l=s
elif s>=0 and t<=0:
    k=-t
    l=s
elif s<=0 and t>=0:
    k=-t
    l=s

x3=x2+k
y3=y2+l
x4=x3-s
y4=y3-t
print(x3, y3, x4, y4)

Measured memory_bytes: 3064
#define _GLIBCXX_DEBUG
#define rep(i, n) for (int i = 0; i < (int)(n); i++)
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
int main()
{
    string s;
    cin >> s;
    ll ans = 0;
    rep(i, 1 << s.size())
    {
        bitset<10> b(i);
        string ns;
        rep(j, s.size())
        {
            ns += s[j];
            if (b.test(j))
            {
                ns += '+';
            }
        }
        //cout << ns << endl;
        string nns;
        if (ns[ns.size() - 1] != '+')
        {
            rep(j, ns.size())
            {
                if (ns[j] == '+')
                {
                    ans += stoll(nns);
                    nns = "";
                }
                else
                    nns += ns[j];
            }
            ans += stoll(nns);
            //cout << ans << endl;
        }
    }
    cout << ans << endl;
}


Measured memory_bytes: 3612
#include<stdio.h>
#include<string.h>
int main()
{
    int i,j;
    long long int s;
    char n[1011];
    for(j=1;;j++)
    {
        fgets(n, 1011, stdin);
        s=0;
        if(n[0]=='0')
        {
            break;
        }
        else
        {
            for(i=0;i<strlen(n);i++)
            {
                if(n[i]>='0'&&n[i]<='9')
                {
                    s=s+n[i]-'0';
                }
            }
            printf("%lld\n",s);
        }
    }
    return 0;
}



Measured memory_bytes: 2072
import sys
input = sys.stdin.readline

# https://qiita.com/derodero24/items/91b6468e66923a87f39f#既存ツールを用いた手法３評価-
def cmb(n, r, mod):
    if ( r<0 or r>n ):
        return 0
    r = min(r, n-r)
    return g1[n] * g2[r] * g2[n-r] % mod

mod = 10**9+7 #出力の制限
N = 10**6
g1 = [1, 1] # 元テーブル
g2 = [1, 1] #逆元テーブル
inverse = [0, 1] #逆元テーブル計算用テーブル


for i in range( 2, N + 1 ):
    g1.append( ( g1[-1] * i ) % mod )
    inverse.append( ( -inverse[mod % i] * (mod//i) ) % mod )
    g2.append( (g2[-1] * inverse[-1]) % mod )

# a = cmb(n,r,mod)


###
X, Y = map(int, input().split())
MOD = 1000000007

dP = dict()
vQ = []

if (X+Y)%3 != 0:
    print(0)
    exit(0)

N = (X+Y)//3
K = X - N
nCk = cmb(N,K,MOD)

print(nCk)


Measured memory_bytes: 122068
using System;
using System.Linq;

namespace ConsoleApp1111
{
    class Program
    {
        static void Main(string[] args)
        {
            var aa = Console.ReadLine().Trim().Split(' ').Select(int.Parse).ToArray();
            var n = aa[0];
            var k = aa[1];
            var p = Console.ReadLine().Trim().Split(' ').Select(double.Parse).ToArray();

            var m = 0.0;
            for (int i = 0; i < k; i++)
            {
                m = m + NewMethod(p[i]);
            }

            var s = m;
            for (int i = k; i < n; i++)
            {
                s = s - NewMethod(p[i - k]) + NewMethod(p[i]);
                if (m < s)
                {
                    m = s;
                }
            }

            Console.WriteLine(m);


        }

        private static double NewMethod(double p)
        {
            var s = (p + 1) / 2;
            return s;
        }
    }
}

Measured memory_bytes: 34780
#include<bits/stdc++.h>
using namespace std;
#define all(v) ((v).begin()),((v).end())
#define ll long long
#define fastIO cout << fixed << setprecision(9), ios::sync_with_stdio(false), cin.tie(nullptr), cout.tie(nullptr)
double const EPS = 1e-9, PI = acos(-1);
const int N = 1e5 + 9, M = 5e2 + 9, OO = 1e9 + 7, MOD = 1e9 + 9;
const ll inf = 1e18;

ll dp[N][3], happ[N][3];

int main() {
  fastIO;
#ifdef LOCAL
  freopen("input.in", "rt", stdin);
#endif

  int n;
  cin >> n;
  for (int i = 0; i < n; ++i)
    for (int j = 0; j < 3; ++j)
      cin >> happ[i][j];

  for (int i = 0; i < 3; ++i)
    dp[0][i] = happ[0][i];

  for (int i = 1; i < n; ++i) {
    for (int prv = 0; prv < 3; ++prv) {
      for (int k = 0; k < 3; ++k) {
        if(k == prv) continue;
        dp[i][k] = max(dp[i][k], dp[i-1][prv] + happ[i][k]);
      }
    }
  }

  cout << max(dp[n-1][0], max(dp[n-1][1], dp[n-1][2]));
  return 0;
}


Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0;i<n;i++)
#define int long long
#define ll long long
#define INF LLONG_MAX/3
#define eps LDBL_EPSILON
#define moder 1000000007
#define pie 3.141592653589793238462643383279
#define P std::pair<int,int>
#define prique priority_queue<int,vector<int>,greater<int>>
using namespace std;
int n,a[100010][3];
int dp[100010][3];
signed main(){
	cin>>n;
	rep(i,n)cin>>a[i][0]>>a[i][1]>>a[i][2];
	dp[0][0]=a[0][0];
	dp[0][1]=a[0][1];
	dp[0][2]=a[0][2];
	for(int i=1;i<n;i++){
		rep(j,3){
			rep(k,3){
				if(j!=k)dp[i][j]=max(dp[i][j],dp[i-1][k]+a[i][j]);
			}
		}
	}
	cout<<max({dp[n-1][0],dp[n-1][1],dp[n-1][2]})<<endl;
    return 0;
}

Measured memory_bytes: 4992
#include <bits/stdc++.h>
#define REP(i, n) for (int i = 0; i < n; i++)
#define FOR(i, m, n) for (int i = m; i < n; i++)
#define ll long long int
const int INF = 2147483647;

using namespace std;

int dp[100][10001] = {};
int main()
{
  int n, w;
  cin >> n >> w;
  pair<int, int> vw[100];
  REP(i, n)
  {
    int v, w;
    cin >> v >> w;
    vw[i] = make_pair(v, w);
  }

  dp[0][vw[0].second] = vw[0].first;
  FOR(i, 1, n)
  {
    REP(j, w + 1)
    {
      dp[i][j] = dp[i - 1][j];
      if (j - vw[i].second >= 0)
      {
        dp[i][j] = max(dp[i][j], dp[i - 1][j - vw[i].second] + vw[i].first);
      }
    }
  }

  int ans = 0;
  REP(i, w + 1)
  {
    ans = max(ans, dp[n - 1][i]);
  }
  cout << ans << endl;
}



Measured memory_bytes: 6952
#ifdef DEBUG
#define _GLIBCXX_DEBUG
#endif
//#pragma GCC optimize("O3")
#include <bits/stdc++.h>
using namespace std;
typedef long double ld;
typedef long long ll;
int n;
const int maxN = 2 * (int)1e5 + 10;
int a[maxN], b[maxN];
int T;
bool cmp(int i, int j) {
    return (1LL * (b[i] + 1) * (a[j] + 1) + (b[j] + 1)) < (1LL * (b[j] + 1) * (a[i] + 1) + b[i] + 1);
}
const int maxP = 50;
ll dp[50];
const ll INF = 1e18;
int main() {
    ios_base::sync_with_stdio(false);
    cin.tie(nullptr);
    //freopen("input.txt", "r", stdin);
    cin >> n >> T;
    vector < int > ord;
    for (int i = 1; i <= n; i++) {
        cin >> a[i] >> b[i];
        ord.push_back(i);
    }
    sort(ord.begin(), ord.end(), cmp);
    T++;
    int where = -1;
    for (int i = 0; i < maxP; i++) {
        dp[i] = INF;
    }
    dp[0] = 1;
    for (int i = 0; i < ord.size(); i++) {
        if (a[ord[i]] == 0) {
            where = i;
            break;
        }
        int v = ord[i];
        for (int j = maxP - 2; j >= 0; j--) {
            if (dp[j] <= T) {
                dp[j + 1] = min(dp[j + 1], dp[j] * (a[v] + 1) + (b[v] + 1));
            }
        }
    }
    if (where == -1) {
        int best = 0;
        for (int j = 0; j < maxP; j++) {
            if (dp[j] <= T) best = j;
        }
        cout << best;
        return 0;
    }
    vector < int > all;
    for (int j = where; j < ord.size(); j++) {
        all.emplace_back(b[ord[j]]);
    }
    sort(all.begin(), all.end());
    int ans = 0;
    for (int j = 0; j < maxP; j++) {
        if (dp[j] > T) continue;
        int best = all.size();
        for (int p = 0; p < all.size(); p++) {
            if (dp[j] + all[p] + 1 > T) {
                best = p;
                break;
            }
            dp[j] += all[p] + 1;
        }
        ans = max(ans, best + j);
    }
    cout << ans;
    return 0;
}

Measured memory_bytes: 4084
#include <stdio.h>
#include <iostream>
#include <algorithm>
#include <cmath>
#include <numeric>
#include <vector>
#include <set>
#include <map>
#include <cstring>
#include <unordered_map>
#define lld long long int
#define DBG1(vari1) cerr<<#vari1<<" = "<<(vari1)<<endl;
#define DBG2(vari1,vari2) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<endl;
#define DBG3(vari1,vari2,vari3) cerr<<#vari1<<" = "<<(vari1)<<" "<<#vari2<<" = "<<(vari2)<<" "<<#vari3<<" = "<<(vari3)<<endl;
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(NULL);
	// freopen("input.txt", "r", stdin);  
	string s;
	cin >> s;
	for(int i=0;i<s.size()-1;i++)
	{
		if(s[i]==s[i+1])
		{
			cout << i+1 << " " << i+2;
			return 0;
		}
		else if(s[i]==s[i+2])
		{
			cout << i+1 << " " << i+3;
			return 0;
		}
	}
	cout << "-1 -1";
}

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

const int MAX_N=1e5;

int n,m,ans;
int f[MAX_N+1];
bool is_f[MAX_N+1];

int Find(int x)
{
   return f[x]?f[x]=Find(f[x]):x;
}

void merge(int x,int y)
{
	int fx=Find(x);
	int fy=Find(y);
	if (fx!=fy)
		f[fx]=fy;
}

int main()
{
    cin>>n>>m;
	for(int i=1;i<=m;i++)
	{
		int x,y,z;
		cin>>x>>y>>z;
		merge(x,y);
	}
	
	for(int i=1;i<=n;i++)
	  is_f[Find(i)]=true;
	
	for(int i=1;i<=n;i++)
		ans+=is_f[i];
	
	cout<<ans<<endl;
	return 0;
}

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

typedef long long ll;

const int MAXN = 1e5 + 10;
const int MOD = 1e9 + 7;

vector<int> grafo[MAXN];
ll dp[MAXN][2];
int N;

ll solve(int v,int c,int p)
{
	if(dp[v][c] != -1) return dp[v][c];
	ll tot = 1;
	for(int u : grafo[v]){
		if(u == p) continue;
		if(c == 0) tot = (tot * (solve(u,0,v) + solve(u,1,v))) % MOD;
		else tot = (tot * solve(u,0,v)) % MOD;
	}
	return dp[v][c] = tot;
}

int main()
{
	memset(dp,-1,sizeof(dp));
	scanf("%d",&N);
	for(int i = 1;i<N;i++){
		int u,v;
		scanf("%d %d",&u,&v);
		grafo[u].push_back(v);
		grafo[v].push_back(u);
	}
	printf("%lld\n", (solve(1,0,-1) + solve(1,1,-1)) % MOD );
}

Measured memory_bytes: 17828
#include <cstdio>

const int MAXN = 100 + 5;

int main() {
        int n;
        int nums[MAXN];
        int sum = 0;

        scanf("%d", &n);
        for (int i = 0; i < n; i++) {
                scanf("%d", nums + i);
                sum += nums[i];
        }

        int p = sum/n;
        int p2 = sum/n + 1;
        int res = 0, res2 = 0;

        for (int i = 0; i < n; i++) {
                res += (nums[i] - p)*(nums[i] - p);
                res2 += (nums[i] - p2) * (nums[i] - p2);
        }

        printf("%d", res < res2 ? res : res2);

        return 0;
}


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

int main() {
  ll n; cin>>n;
  vector<ll> v(n);
  rep(i,n){
    cin>>v[i];
  }
  sort(v.begin(),v.end());
  cout<<v[n-1]<<" ";
  vector<ll> v_(n);
  v_=v;
  rep(i,n){
    v_[i]=min(v_[i],v[n-1]-v_[i]);
  }
  sort(v_.begin(),v_.end());
  if(count(v.begin(),v.end(),v_[n-1]) )cout<<v_[n-1];
  else{cout<<v[n-1]-v_[n-1];}
}



Measured memory_bytes: 4844
import java.util.*;
        public class Main {
          public static void main(String[] args) {
            Scanner s = new Scanner(System.in);
            int n = s.nextInt();
            int[] h = new int[n];
            for (int i = 0; i < n  ; i++ ) {
              h[i] = s.nextInt();
            }
            System.out.println(calc(h));
          }
          public static int calc(int[] h) {
            int[] dp = new int[h.length];
            dp[0] = 0;
            dp[1] = Math.abs(h[1] - h[0]);
            for(int  i = 2; i < h.length; i++ ) {
              dp[i] = Math.min ( dp[i-1] + Math.abs(h[i] - h[i-1]),
                               dp[i-2] + Math.abs(h[i] - h[i-2]) );
            }
            return dp[h.length - 1];
          }
        }

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

int H, W;
vector<string> S;

void input() {
    cin >> H >> W;
    S = vector<string>(H);
    rep(i, H) cin >> S[i];
}

int main() {
    input();
    vector<int> x{0};
    matrix w, h;
    w = h = matrix(H, vector<int>(W));
    rep(i, H) {
        int c = 0;
        rep(j, W) {
            if (S[i][j] == '.') {
                c++;
                w[i][j] = x.size();
            }
            else {
                x.push_back(c);
                w[i][j] = 0;
                c = 0;
            }
        }
        x.push_back(c);
    }
    rep(j, W) {
        int c = 0;
        rep(i, H) {
            if (S[i][j] == '.') {
                c++;
                h[i][j] = x.size();
            }
            else {
                x.push_back(c);
                h[i][j] = 0;
                c = 0;
            }
        }
        x.push_back(c);
    }
    int ans = 0;
    rep(i, H) {
        rep(j, W) {
            ans = max(ans, x[w[i][j]] + x[h[i][j]]);
        }
    }
    cout << ans - 1 << endl;
}


Measured memory_bytes: 70128
#!/usr/bin/env python


def main():
    while True:
        h, w = [int(x) for x in raw_input().split(" ")]
        if h == 0 and w == 0:
            break

        for x in range(1, h+1):
            if x == 1 or x == h:
                print "#" * w
            else:
                if w >= 3:
                    print "#" + "." * (w-2) + "#"
                else:
                    print "#" * w
        print

if __name__ == '__main__':
    main()

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

int main(){
  int n;
  cin >> n;
  vector<int> vec(n);
  for(int i=0; i<n; i++){
    int num;
    cin >> num;
    vec[i] = num;
  }
  int checkingNum = 1;
  int cnt = 0;
  for(int i=0; i<n; i++){
    if(vec[i] == checkingNum){
      checkingNum++;
    }else{
      cnt++;
    }
  }
  if(checkingNum == 1){
    cout << -1 << endl;
  }else{
    cout << cnt << endl;
  }
  return 0;
}
    
    
    
    
  

Measured memory_bytes: 1152
#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
#include <numeric>
#include <map>
#include <iomanip>

using namespace std;    
typedef long long ll;
typedef pair<ll, ll> pll;
#define all(x) (x).begin(),(x).end()
#define rall(x) (x).rbegin(),(x).rend()
const bool DEBAG = false;

int main(){


    char c;
    cin >> c;
    cout << char(c + 1) << endl;



}

Measured memory_bytes: 764
#include<cstdio>
#include<cstring>
#include<iostream>
#include<stdlib.h>
#include<ctime>
#include<string>
#include<cmath>
#include<algorithm>
#include<complex>
#include<vector>
#include<set>
#include<map>
#include<queue>
#define pb push_back
#define mp make_pair
#define fi first
#define se second
#define LL long long
#define FOR(i,a,b) for (int i=a;i<=b;++i)
#define FORD(i,a,b) for (int i=a;i>=b;--i)
using namespace std;
void getint(int &v){
    char ch,fu=0;
    for(ch='*'; (ch<'0'||ch>'9')&&ch!='-'; ch=getchar());
    if(ch=='-') fu=1, ch=getchar();
    for(v=0; ch>='0'&&ch<='9'; ch=getchar()) v=v*10+ch-'0';
    if(fu) v=-v;
}
const LL INF=1e18;
LL s[500010],ans;
int A,B,C,D,a[500010],l,r,n;
LL que(int l,int r){
	return s[r]-s[l-1];
}
void ck(int A,int B,int C){
	if (B<=A || C<=B) return ;
	if (A<1 || C>=n) return ;
	LL X=que(1,A);
	LL Y=que(A+1,B);
	LL Z=que(B+1,C);
	LL W=que(C+1,n);
	LL G=max(max(X,Y),max(Z,W));
	LL H=min(min(X,Y),min(Z,W));
	ans=min(ans,G-H);
}
int main(){
	cin>>n;
	ans=INF;
	FOR(i,1,n) getint(a[i]),s[i]=s[i-1]+a[i];
	FOR(i,2,n-2){
		int l=1,r=i-1;
		while (l<r){
			int o=(l+r>>1)+1;
			if (que(1,o)<=que(o+1,i)) l=o;
			else r=o-1;
		}
		A=r,B=r+1;
		l=i+1,r=n-1;
		while (l<r){
			int o=(l+r>>1)+1;
			if (que(i+1,o)<=que(o+1,n)) l=o;
			else r=o-1;
		}
		C=r,D=r+1;
		ck(A,i,C);
		ck(A,i,D);
		ck(B,i,C);
		ck(B,i,D);
	}
	cout<<ans<<endl;
	return 0;
}

Measured memory_bytes: 3200
#include<bits/stdc++.h>
using namespace std;
#define fast ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0);
typedef long long ll;
ll strtoint(string str);
int main(){
	fast;
	ll h,n,s=0; cin>>h>>n;
	for(auto i=0;i<n;++i){
		ll x; cin>>x;
		s+=x;
	}
	if(s>=h)cout<<"Yes\n";
	else
		cout<<"No\n";
	return 0;
}
ll strtoint(string str){
	ll x=0;
	stringstream ss;
	ss<<str;
	ss>>x;
	return x;
}

Measured memory_bytes: 256
n=int(input())
w=list(map(int,input().split()))
ans=1000000
for i in range(n):
  s1=sum(w[0:i+1])
  s2=sum(w[i+1:n+1])
  ab=abs(s1-s2)
  if ab<=ans:
    ans=ab
print(ans)

Measured memory_bytes: 3060
// parameter "input" gets all data

function nbrDividor(n){
	var nbr=0;
	for (var i = 1; i <=n; i++) {
		if(n%i==0)
			nbr++;
	}
	return nbr;

}
function Main(input) {

	var a = parseInt(input, 10);
	var ans = 0;
	for (var i = 1; i <=a; i++) {
		if(nbrDividor(i)==8 && i%2==1){
			ans++;
		}
	}
	//output
	console.log('%d',ans);
}
// Don't edit this line!


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

Measured memory_bytes: 21064
using System;
public class Hello{
    public static void Main(){
        int N = int.Parse(Console.ReadLine());
        int curT = 0;
        int curX = 0;
        int curY = 0;
        
        for(int i = 0;i < N;i++){
            string[] input = Console.ReadLine().Split(' ');
            int nexT = int.Parse(input[0]);
            int nexX = int.Parse(input[1]);
            int nexY = int.Parse(input[2]);
            
            int t = nexT - curT;
            int x = Math.Abs(nexX - curX);
            int y = Math.Abs(nexY - curY);
            int d = x + y;
            if(t >= d && (t % 2 == d % 2)){
                
            }else{
                Console.WriteLine("No");
                return;
            }
            curT = nexT;
            curX = nexX;
            curY = nexY;
        }
        Console.WriteLine("Yes");
    }
}


Measured memory_bytes: 15184
#include <cstdio>
#include <algorithm>
#include <utility>

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

#define pow CHANGETHENAMESTUPID

using namespace std;

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

void load() {

}

void solve() {
	int n; scanf("%d", &n);
	printf("%d\n", (n-1)/2);
}

int main() {
	load();
	solve();
	return 0;
}


Measured memory_bytes: 128
import java.util.*;

public class Main {
  public static void main(String[] args) {
    Scanner sc = new Scanner(System.in);
    int A = sc.nextInt();
    int B = sc.nextInt();
    int count = 0;
    for (int i = A; i <= B; i++) {
      String s = Integer.toString(i);
      if (s.charAt(0) == s.charAt(4) && s.charAt(1) == s.charAt(3)) {
        count++;
      }
    }
    System.out.println(count);
  }
}

Measured memory_bytes: 26324
#include <bits/stdc++.h>
using namespace std;
int main()
{
    int a,b,c,x,y,ans;
    cin>>a>>b>>c>>x>>y;
    ans=a*x+b*y;
    for(int i=0;i<=2*max(x,y);i++){
    int m;
    m=max(0,a*(x-i))+max(0,b*(y-i))+2*c*i;
    if(ans>m)ans=m;
    }
    cout<<ans<<endl;
      
    return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (int)(n); i++)
#define all(v) v.begin(), v.end()
using ll = long long;
const ll MOD = 1e9+7; ll LLINF = 1LL << 60; int INF = INT_MAX;

//

int main(){
      ll s; cin>>s;
      set<ll> st;
      ll now=s;
      ll ans=1;
      while(true){

            if(st.count(now)==false) st.insert(now);
            else{
                  cout<<ans<<endl;
                  return 0;
            }

            if(now%2==0) now/=2;
            else now=3*now+1;

            ans++;
      }
}

Measured memory_bytes: 256
#include <algorithm>
    #include <bits/stdc++.h>
    #include <cctype>
    #include <cmath>
    #include <cstdio>
    #include <iomanip>
    #include <iostream>
    #include <list>

    #include <stack>
    #include <string>
    #include <vector>
    #include <bits/stdc++.h>
    #define INFINI (1000 * 1000 * 1000)

    using namespace std;
    //#define s(T) scanf("%d", &T)
    #define sl(T) scanf("%lld", &T)
    #define fill(a, val) memset(a, val, sizeof(a))
    #define mp make_pair
    #define pb push_back
    #define all(x) x.begin(), x.end()
    #define DREP(x) sort(all(x)); x.erase(unique(all(x)), x.end())
    #define INDEX(a, val) (lower_bound(all(a), val) - a.begin())
    #define mod ll(1e9+7)
    typedef long long ll;


    bool compare_first(pair<ll,ll >a,pair<ll,ll >b)
    {
        return a.first<b.first;
    }

     bool compare_second(pair<int,pair<int , int> > a,pair<int,pair<int , int> > b)
    {
        return a.second.first<b.second.first;
    }


    ll min(ll a,ll b)
    {
        if(a>b)return b;
        return a;
    }

int arr[10];
    int main() {
      ios::sync_with_stdio(false);

int n;
cin>>n;

cout<<(n*(n+1))/2<<endl;


return 0;
    }


/*

 }
 */


Measured memory_bytes: 256
#include<bits/stdc++.h>
#include<unordered_set>
#include<unordered_map>
using namespace std;
#define REP(i,m,n) for(int i=(m);i<(n);i++)
#define rep(i,n) REP(i,0,n)
#define pb push_back
#define all(a) a.begin(),a.end()
#define rall(c) (c).rbegin(),(c).rend()
#define mp make_pair
typedef long long ll;
typedef pair<int,int> pii;
typedef pair<ll,ll> pll;
typedef long double ld;
const ll inf=1e9+7;
const ll mod=998244353;
int main(){
    ll n,a;cin>>n>>a;
    vector<ll>x(n);
    rep(i,n)cin>>x[i];
    vector<vector<vector<ll> > >dp(n+1,vector<vector<ll> >(n+1,vector<ll>(3000)));
    dp[0][0][0]=1;
    rep(i,n){
        rep(j,n+1){
            rep(k,3000){
                if(dp[i][j][k]==0)continue;
                if(k+x[i]<3000)dp[i+1][j+1][k+x[i]]+=dp[i][j][k];
                dp[i+1][j][k]+=dp[i][j][k];
            }
        }
    }
    ll ans=0;
    REP(i,1,n+1){
        rep(j,3000){
            if(i*a==j)ans+=dp[n][i][j];
        }
    }
    cout<<ans<<endl;
}

Measured memory_bytes: 62592
#include <iostream>
#include <string>
#include <algorithm>
#include <stdlib.h>
#include <iomanip>
#include <vector>
#include <cmath>
#include <bits/stdc++.h>
using namespace std;
//typedef long long unsigned int ll;
typedef long long ll;
//typedef pair<ll, ll> edge;
//typedef tuple<ll, ll, ll> tp;
const ll INF = 1e18;
const ll mod = 1e9+7;

ll exc(ll num){
  if(num%4 == 0) return num;
  if(num%4 == 1) return 1;
  if(num%4 == 2) return num+1;
  if(num%4 == 3) return 0;
}

int main() {
  ll a,b;
  cin >> a >> b;
  ll a2 = exc(a-1);
  ll b2 = exc(b);
  //cout << a2 << b2 << endl;
  
  ll ans = a2 ^ b2;
  
  cout << ans << endl;
}

Measured memory_bytes: 256
from itertools import permutations

dishes = [int(input()) for _ in range(5)]
ans = 10**9
for order in permutations(dishes):
    temp = 0
    for i in range(5):
        temp += order[i]
        if i != 4:
            temp += (10 - (order[i] % 10)) % 10
    if temp < ans:
        ans = temp
print(ans)

Measured memory_bytes: 3060
#include<stdio.h>
int main(void){
	int a,b,c;
	scanf("%d%d%d",&a,&b,&c);
	if(a<b){
		if(b<c){
			printf("%d",(10*c)+a+b);
		}else{
			printf("%d",(10*b)+a+c);
		}
	}else{
		if(a<c){
			printf("%d",(10*c)+a+b);
		}else{
			printf("%d",(10*a)+b+c);
		}
	}
return 0;
}

Measured memory_bytes: 128
#include <stdio.h>
#include <vector>
#include <iostream>
#include <string>
using namespace std;

int main() {
  int sum,biggap;
  sum = 0;
  biggap = 0;
  for (int i = 0; i < 5; i++) {
    int time; cin>>time;
    int gap; gap = time%10;
    if (gap != 0)  {
      biggap = max(10-gap,biggap);
      sum += time + 10 - gap;
    } else sum += time;
  }
  cout<<sum-biggap<<endl;
  return 0;
}

Measured memory_bytes: 256