akhauriyash/Code-Regression huggingface dataset:
#include <bits/stdc++.h>
using namespace std;

#define IOS ios_base::sync_with_stdio(false);cin.tie(0);cout.tie(0);
#define ll long long
#define vll vector<ll>
#define vi vector<int>
#define pb push_back
#define fi first
#define se second
#define pii pair<int,int>
#define pll pair<ll,ll>
#define mii map<int,int>
#define mll map<ll,ll>
#define all(x) (x).begin(),(x).end()
#define S(x) (int)(x).size()
#define L(x) (int)(x).length()

#include<ext/pb_ds/assoc_container.hpp>
#include<ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
typedef tree<int , null_type , less<int> , rb_tree_tag , tree_order_statistics_node_update> ordered_set;

const int mod = 1e9+7;
const ll infl = 0x3f3f3f3f3f3f3f3fLL;
const int infi = 0x3f3f3f3f;

void solve()
{
	string s[10];
	int h,w,i,j,k;
	cin>>h>>w>>k;
	int cnt=0;
	for(i=0;i<h;i++) cin>>s[i];
	for(int rm=0;rm<(1<<h);rm++)
	for(int rc=0;rc<(1<<w);rc++)
	{
		int sum=0;
		for(i=0;i<h;i++)
		{
			if((1<<i)&rm)
			for(j=0;j<w;j++) sum += s[i][j]=='#' && ((1<<j)&rc);
		}
		for(j=0;j<w;j++)
		{
			if((1<<j)&rc)
			for(i=0;i<h;i++) sum += s[i][j]=='#' && ((1<<i)&rm);
		}
		for(i=0;i<h;i++)
		for(j=0;j<w;j++)
		{
			if(((1<<i)&rm) && ((1<<j)&rc))
			{
				if(s[i][j]=='#')
				sum--;
			}
		}
		if(sum==k)
		{
			//cout<<bitset<6>(rm)<<' '<<bitset<6>(rc)<<'\n';
			cnt++;
		}
	}
	cout<<cnt<<'\n';
}

int main()
{
	IOS
	int t=1;
	//cin>>t;
	while(t--)
	{
		solve();
	}
}


Measured memory_bytes: 3656
#include <iostream>
#include <vector>
#include <algorithm>
#include <cstring>
using namespace std;
vector <int> v[100005];
int dst1[100005],dst2[100005];
int dfs1(int pz)
{
    for(int i=0;i<v[pz].size();++i)
    {
        if(!dst1[v[pz][i]])
        {
            dst1[v[pz][i]]=1+dst1[pz];
            dfs1(v[pz][i]);
        }
    }
}
int dfs2(int pz)
{
    for(int i=0;i<v[pz].size();++i)
    {
        if(!dst2[v[pz][i]])
        {
            dst2[v[pz][i]]=1+dst2[pz];
            dfs2(v[pz][i]);
        }
    }
}
int main()
{
    int n,m,k,i,j,s=0,rz=0,a,b,f,mx=0;
    cin>>n>>f>>s;
    for(i=1;i<n;++i)
    {
        cin>>a>>b;
        v[a].push_back(b);
        v[b].push_back(a);
    }
    dst1[f]=dst2[s]=1;
    dfs1(f);
    dfs2(s);
    for(i=1;i<=n;++i)
    {
        if(dst1[i]<dst2[i])
        {
            int cur=dst2[i];
            mx=max(mx,cur-2);
        }
    }
    cout<<mx;
    return 0;
}


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

typedef long long ll;
typedef pair<ll, ll> P;
typedef pair<pair<int, int>, int> PP;
const ll INF = 1LL << 60;
const ll MOD = 1000000007;

int GCD(int a, int b) { return b ? GCD(b, a%b) : a; }
//------------------------------------------------------------------------------------------------------------------------------

int main(void) { 
    string S, S1, S2; S1 = S2 = "";
    cin >> S;
    int sz = S.size();;
    for(int i = 0; i < sz; i++) {
        if (i % 2) S1 += "0";
        else S1 += "1";
    }
    for(int i = 0; i < sz; i++) {
        if (i % 2) S2 += "1";
        else S2 += "0";
    }
    int cnt1, cnt2; cnt1 = cnt2 = 0;
    for(int i = 0; i < sz; i++) {
        if (S[i] != S1[i]) cnt1++;
    }
    for(int i = 0; i < sz; i++) {
        if (S[i] != S2[i]) cnt2++;
    }
    cout << min(cnt1, cnt2) << endl;
}


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

//短縮
#define rep(i,n) for(int i=0;i<(n);++i)
//sort()用
#define all(v) v.begin(), v.end()

using namespace std;

int main(){
  string N;
  cin >>N;
  int flag=0;
  rep(i,3){
    if(N.at(i)=='7')flag=1;
  }
  if(flag) cout << "Yes";
  else cout << "No";

  return 0;
}


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

int main()
{
	int a,b,c;
	int tmp;
	cin >> a >> b >>c;
	
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	
	if (b > c){
		tmp = b;
		b = c;
		c = tmp;
	}
	
	if (a > b){
		tmp = a;
		a = b;
		b = tmp;
	}
	cout << a << " " << b << " " << c <<endl;
	
	return 0;
}

Measured memory_bytes: 3068
#include<iostream>
#include<cstdio>

using namespace std;

int main() {
	int n;
	char s[10001];
	cin >> n;
	scanf("%s", &s);
	
	for (int i = 0;s[i]!='\0';i++) {
		if (s[i]+ n > 'Z') {
			printf("%c",s[i]+n-26);
		}
		else if (s[i] + n <= 'Z') {
			printf("%c", s[i] + n);
		}

	}
	printf("\n");
	
	return 0;
}

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

using namespace std;

int main() {
    ios::sync_with_stdio(0);
    cin.tie(0);
    int x;
    cin >> x;
    if (x >= 9) x -= 9;
    else {
        x += 5;
    }
    if (x % 7 == 0) {
        cout << "sat" << '\n';
    } else if (x % 7 == 1) {
        cout << "sun" << '\n';
    } else if (x % 7 == 2) {
        cout << "mon" << '\n';
    } else if (x % 7 == 3) {
        cout << "tue" << '\n';
    } else if (x % 7 == 4) {
        cout << "wed" << '\n';
    } else if (x % 7 == 5) {
        cout << "thu" << '\n';
    } else {
        cout << "fri" << '\n';
    }
    return 0;
}


Measured memory_bytes: 3192
def GCD(a, b):
    if a < b:
        a, b = b, a
    while b > 0:
        a, b = b, a%b
    return a

N, K = map(int, input().split())
A = list(map(int, input().split()))

if K > max(A):
  print("IMPOSSIBLE")
  exit(0)

G = A[0]
for i in range(1,N):
  G = GCD(G,A[i])
  #print(i,G,A[i])
  
if K % G == 0:
  print("POSSIBLE")
else:
  print("IMPOSSIBLE")

Measured memory_bytes: 14224
#include <iostream>
#include <climits>
#include <cmath>
#include <vector>
#include <map>
#include <set>
#include <algorithm>
 
using namespace std;
typedef long long int ll;
typedef unsigned long long int ull;

#define MOD 1000000007LL

int main()
{
  int n;
  int ac=0, wa=0, tle=0, re=0;
  string s;

  cin >> n;

  for (int i=0; i<n; i++) {
    cin >> s;
    if (s=="AC") {
      ac++;
    } else if (s=="WA") {
      wa++;
    } else if (s=="TLE") {
      tle++;
    } else if (s=="RE") {
      re++;
    }
  }

  printf("AC x %d\n", ac);
  printf("WA x %d\n", wa);
  printf("TLE x %d\n", tle);
  printf("RE x %d\n", re);

  return 0;
}


Measured memory_bytes: 3720
#include <iostream>
#include <vector>
#include <string>
#include <algorithm>
#include <numeric>
#include <cmath>
#include <unordered_map>
#define For(i, n) for(int i = 0; i < (n); i ++)
#define Range(c) c.begin(), c.end()
#define RevRange(c) c.rbegin(), c.rend()
#define Contains(c, x) find(Range(c), x) != c.end()
#define Sort(a) sort(Range(a))
#define DeSort(a) sort(RevRange(a))
#define Vec2(T, n, m, xs) vector<vector<T>> xs(n, vector<T>(m))
#define Sum(a) accumulate(Range(a), 0)
#define Cusum(T, n, xs, sxs) vector<T> sxs(n+1); For(i, n) sxs[i+1] = sxs[i] + xs[i]
#define Cin(T, x) T x; cin >> x
#define Cins(T, n, xs) vector<T> xs(n); For(i, n) cin >> xs[i]
#define Cins2(T, n, xs, ys) vector<T> xs(n), ys(n); For(i, n) cin >> xs[i] >> ys[i]
#define Cins3(T, n, xs, ys, zs) vector<T> xs(n), ys(n), zs(n); For(i, n) cin >> xs[i] >> ys[i] >> zs[i]
#define Cinss(T, n, m, xs) Vec2(T, n, m, xs); For(i, n) For(j, m) cin >> xs[i][j]
#define Cinm(T, n, map) unordered_map<T, int> map; For(i, n){ Cin(T, x); map[x] ++; }
#define Cout(x) cout << (x) << "\n"
#define Couts(xs) for(const auto &e : xs) cout << e << " "; cout << "\n"

using namespace std;
using ll = long long;

int main(void){
    Cin(int, n);
    Cin(int, k);
    Cinm(int, n, a);
    
    vector<int> v;
    for(auto &e : a) v.push_back(e.second);
    Sort(v);
    Cout(v.size() <= k ? 0 : accumulate(v.begin(), v.end() - k, 0));
}


Measured memory_bytes: 10312
#include <bits/stdc++.h>
using namespace std;
#define rep(i, n) for (int i = 0; i < (n); i++)
#define rep2(i, x, n) for (int i = x; i < (n); i++)
#define all(n) begin(n), end(n)
struct cww
{
    cww()
    {
        ios::sync_with_stdio(false);
        cin.tie(0);
    }
} star;
const long long INF = numeric_limits<long long>::max();
typedef long long ll;
typedef vector<int> vint;
typedef vector<char> vchar;
typedef vector<vector<int>> vvint;
typedef vector<ll> vll;
typedef vector<vector<ll>> vvll;
typedef unsigned long long ull;
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;
}
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);
}
struct UnionFind
{
    vector<int> data;

    UnionFind(int sz)
    {
        data.assign(sz, -1);
    }

    bool unite(int x, int y)
    {
        x = find(x), y = find(y);
        if (x == y)
            return (false);
        if (data[x] > data[y])
            swap(x, y);
        data[x] += data[y];
        data[y] = x;
        return (true);
    }

    int find(int k)
    {
        if (data[k] < 0)
            return (k);
        return (data[k] = find(data[k]));
    }

    int size(int k)
    {
        return (-data[find(k)]);
    }
    bool same(int x, int y)
    {
        return find(x) == find(y);
    }
};

int main()
{
    int N, M;
    cin >> N >> M;
    UnionFind uf(N);
    vvint L(N);
    vvint m(M); // m[i] = 言語iを話す人の配列
    for (size_t i = 0; i < N; i++)
    {
        int k;
        cin >> k;
        L[i].resize(k);
        for (size_t j = 0; j < k; j++)
        {
            cin >> L[i][j];
            L[i][j]--;
            m[L[i][j]].push_back(i);
        }
    }
    for (size_t i = 0; i < M; i++)
    {
        for (auto &&j : m[i])
        {
            uf.unite(m[i][0], j);
        }
    }
    cout << ((uf.size(0) == N) ? "YES" : "NO");
    return 0;
}

Measured memory_bytes: 8824
import java.util.Scanner;

class Main{
	static final long MOD = 1000000007;

	static int H, W, K;
	static long[][] dp = new long[110][10];
	static int ans = 0;
	static long n = 0;





	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);			//文字の入力
		long n = sc.nextLong();
		long m = sc.nextLong();
		for(long i = m/n;i >= 1;i--){
			if(m%i == 0 && i*n<=m){
				System.out.println(i);
				return;

			}
		}

	}
}







	class Pair implements Comparable{
		int from;		//p
		int end;		//y
		int num;
		int bango;
		@Override
		public int compareTo(Object other) {
			Pair otherpair = (Pair)other;

			return end - otherpair.end;
		}
	}



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

int main() {
    int64_t x;
    cin >> x;
    
    int64_t min, sum, max;
    sum = 0;
    for (int i = 0; i < x; i++) {
        int num;
        cin >> num;
        sum += num;
        if (!(i)) {
            min = num;
            max = num;
        } else {
            if (num < min) min = num;
            if (num > max) max = num;
        }
    }
    
    cout << min << ' ' << max << ' ' << sum << endl;
}


Measured memory_bytes: 3072
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int>P;
const double eps = 1e-8;
const int NINF = 0xc0c0c0c0;
const int INF  = 0x3f3f3f3f;
const ll  mod  = 1e9 + 7;
const ll  maxn = 1e6 + 5;
const double pi = acos(-1.0);

int main(){
	ios::sync_with_stdio(false);
	cin.tie(0);
	cout.precision(20);
	int a,b,c,d;cin>>a>>b>>c>>d;
	double x=(c*60+d)%(60*12)/(60.0*12)*2*pi;
	double y=d%60/60.0*2*pi;
	double k=fabs(x-y);
	double ans=sqrt(a*a+b*b-2*a*b*cos(k));
	cout<<ans<<'\n';
	return 0;
}

Measured memory_bytes: 4240
import java.util.*;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		
		int A = sc.nextInt();
		int B = sc.nextInt();
		int C = sc.nextInt();
		int D = sc.nextInt();
		
	    int time = 0;
		
	    if( A<=C && C<=B ) {
	    	if( B<=D ) {
	    		time = B-C;
	    	}else {
	    		time = D-C;
	    	}
	    }else if( C<A && A<=D ){
	    	if( D<=B ) {
	    		time = D-A;
	    	}else {
	    		time = B-A;
	    	}
	    }
	    
		System.out.println(time);
	}
}


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

int main()
{
    int n;
    char buf[10];
    fgets(buf, sizeof(buf), stdin);

    n = atoi(buf);
    
    int num[4] = {0,0,0,0};

    for(int i=0; i<n; i++){
        fgets(buf, sizeof(buf), stdin);

        if( strstr(buf, "AC") != NULL ){
            num[0] += 1;
            //printf("AC\n");
        }
        else if( strstr(buf, "WA") != NULL ){
            num[1] += 1;
            //printf("WA\n");
        }
        else if( strstr(buf, "TLE") != NULL ){
            num[2] += 1;
            //printf("TLE\n");
        }
        else if( strstr(buf, "RE") != NULL ){
            num[3] += 1;
            //printf("RE\n");
        }
    }

    printf("AC x %d\n", num[0]);
    printf("WA x %d\n", num[1]);
    printf("TLE x %d\n", num[2]);
    printf("RE x %d\n", num[3]);

    return 0;
}


Measured memory_bytes: 1704
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long ull;
typedef pair<ll, ll> P;

int main(){
  string s;
  cin >> s;
  if (s.at(0) == s.at(1) && s.at(0) == s.at(2) && s.at(1) == s.at(2)) cout << "No" << endl;
  else cout << "Yes" << endl;
  return 0;
}


Measured memory_bytes: 256
import java.util.*;

public class Main {
	
	public static void main(String[] args) {

		// argumentの取得
		Scanner s = new Scanner(System.in);

		String str = s.next();
                // String型
	        // String x = s.next();
      
        char []alphabet = new char[26];
        char c = 'a';
        for (int i = 0; i < 26; i++){
          alphabet[i] = c++;
          long count = Main.split(str , alphabet[i]);
          if (count % 2 != 0){
            System.out.println("No");
            return;
          }
        }
      
        // 最後まで走ったらYes
        System.out.println("Yes");
	
	} 
    
    public static int split(String str, char target){
        int count = 0;
      
        for (int i=0; i < str.length(); i++){
          if (str.charAt(i) == target)
              count ++;
        }
      
        return count;
    }
  
}

Measured memory_bytes: 21588
import numpy as np

N = int(input())

AC = 0
WA = 0
TLE = 0
RE = 0

for i in range(N):
    
    S = input()

    if S == "AC":
        AC += 1
    elif S == "WA":
        WA += 1
    elif S == "TLE":
        TLE += 1
    elif S == "RE":
        RE += 1

print("AC x {0}".format(AC))
print("WA x {0}".format(WA))
print("TLE x {0}".format(TLE))
print("RE x {0}".format(RE))


Measured memory_bytes: 27176
var input = require('fs').readFileSync('/dev/stdin', 'utf8');
var Arr=(input.trim()).split("\n");
var a=[0,0];
var b=[0,0];
var c=[0,0];
var d=[0,0];
for(var i=0;i<Arr.length;i++){
   var arr=Arr[i].split(" ").map(Number);
   for(var j=0;j<2;j++){
      if(arr[j]>=1.1)a[j]++;
      else if(arr[j]>=0.6)b[j]++;
      else if(arr[j]>=0.2)c[j]++;
      else d[j]++;
   }
}
console.log(a[0]+" "+a[1]);
console.log(b[0]+" "+b[1]);
console.log(c[0]+" "+c[1]);
console.log(d[0]+" "+d[1]);

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

int main(void){
	int m, f, r;
	while(cin >> m >> f >> r && !(m == -1 && f == -1 && r == -1)){
		int total_mf;
		if( m == -1 || f == -1 ) cout << "F" << endl;
		else{
			total_mf = m + f;
			if( total_mf >= 80 ) cout << "A" << endl;
			if( 65 <= total_mf && total_mf < 80 ) cout << "B" << endl;
			if( 50 <= total_mf && total_mf < 65 ) cout << "C" << endl;
			if( 30 <= total_mf && total_mf < 50 ){
				if( r >= 50 ) cout << "C" << endl;
				else cout << "D" << endl;
			}
			if( total_mf < 30 ) cout << "F" << endl;
		}
	}

	return 0;
}

Measured memory_bytes: 1156
#include<iostream>
using namespace std;
int main(){
    int H,W;
    while(true){
        cin>>H>>W;
        if(H==0 && W==0) break;
        else{
            for(int i=0;i<H;i++){
                for(int j=0;j<W;j++){
                    if(i==0 || i==H-1 || j==0 || j==W-1){
                        cout<<'#';
                    }else{
                        cout<<'.';
                    }
                }cout<<endl;
            }cout<<endl;
        }
    }
    return 0;
}


Measured memory_bytes: 3060
#include<bits/stdc++.h>
#define rep(i, n) for (int i = 0; i < (n); ++i) 
#define PI acos(-1)

using namespace std;
typedef long long ll;
typedef pair<int, int> P;
typedef pair<ll, ll> LP;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<vl> vvl;

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

ll INF = 1001001001;
ll LINF = 1001001001001001001ll;

ll n;
vl as;
vvl size;
vvl dp;

ll dfs(ll l, ll r) {
    if (l + 1 == r) return dp[l][r] = 0;
    if (dp[l][r] >= 0) return dp[l][r];

    ll res = LINF;
    for (int i = l + 1; i < r; ++i) chmin(res, dfs(l, i) + size[l][i] + dfs(i, r) + size[i][r]);
    return dp[l][r] = res;
}

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

    cin>>n;
    as = vl(n);
    rep(i, n) cin>>as[i];

    size = vvl(n + 1, vl(n + 1));
    rep(i, n) for (int j = i; j < n; ++j) {
        size[i][j + 1] = size[i][j] + as[j];
    }
    dp = vvl(n + 1, vl(n + 1, -1));
    ll ans = dfs(0, n);
    cout<<ans<<endl;
}

Measured memory_bytes: 2816
package main

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

func main() {
	scanner := makeWordScanner()
	n := eGetInt(scanner)
	k := eGetInt(scanner)
	count := 0
	for i := 0; i < n; i++ {
		h := eGetInt(scanner)
		if h >= k {
			count++
		}
	}
	fmt.Println(count)
}

////////////////////////////////////////////////////////////////////////////////
// ライブラリ
////////////////////////////////////////////////////////////////////////////////
func makeScanner(maxByte int) *bufio.Scanner {
	scanner := bufio.NewScanner(os.Stdin)
	scanner.Buffer(make([]uint8, 0, 8192), maxByte)
	return scanner
}
func makeWordScanner() *bufio.Scanner {
	scanner := makeScanner(8192)
	scanner.Split(bufio.ScanWords)
	return scanner
}
func eGetLine(r *bufio.Scanner) string {
	if r.Scan() {
		return r.Text()
	}
	err := r.Err()
	if err != nil {
		log.Fatal(err)
	}
	// EOF
	return ""
}
func eGetInt(r *bufio.Scanner) int {
	line := eGetLine(r)
	return eAtoi(line)
}
func eGetInt64(r *bufio.Scanner) int64 {
	line := eGetLine(r)
	return eAtoInt64(line)
}
func eGetFields(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Fields(line)
}
func eGetInts(r *bufio.Scanner) []int {
	fields := eGetFields(r)
	ints := make([]int, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoi(fields[i])
	}
	return ints
}
func eGetInt64s(r *bufio.Scanner) []int64 {
	fields := eGetFields(r)
	ints := make([]int64, len(fields))
	for i := 0; i < len(ints); i++ {
		ints[i] = eAtoInt64(fields[i])
	}
	return ints
}
func eGetChars(r *bufio.Scanner) []string {
	line := eGetLine(r)
	return strings.Split(line, "")
}
func eAtoi(s string) int {
	n, err := strconv.Atoi(s)
	if err != nil {
		log.Fatal(err)
	}
	return n
}
func eAtoInt64(s string) int64 {
	n, err := strconv.ParseInt(s, 10, 64)
	if err != nil {
		log.Fatal(err)
	}
	return n
}


Measured memory_bytes: 896
#include<cstdio>
#include<algorithm>
using namespace std;
int main(void){
	int a,b,c,d,T,A;
	scanf("%d %d %d %d",&a,&b,&c,&d);
	T=c/b;
	A=a/d;
	if(c%b!=0){
		T++;
	}
	if(a%d!=0){
		A++;
	}
	if(T<=A){
		printf("Yes\n");
	}
	else{
		printf("No\n");
	}
	return 0;
}

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

int main() {
  int s, s2, s1, s0;
  cin >> s;
  s2 = s/100; // 100の位
  s1 = (s-s2*100)/10; // 10の位
  s0 = s-s1*10-s2*100; // 1の位
  cout << s2 + s1 + s0 << endl;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define rep(i,n) for(int i=0; i < (n);++i)
using namespace std;
using ll = long long; 
using P = pair<int,int>;
using vv = vector<vector<ll> >;
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;}

const int INF = 2147483647;
const int max_N = 1000000000;
const long long inf = 1ll << 60;
const long long mod = 1000000007;

int dx[4] = {1,0,-1,0};
int dy[4] = {0,-1,0,1};
int main(){
    ll n,d;cin >> n >> d;
    vector<ll> x(n),y(n);
    int ans = 0;
    for(int i=0;i<n;i++){
        cin >> x[i] >> y[i];
        if(x[i]*x[i]+y[i]*y[i] <= d*d) ans++;
    }
    cout << ans << endl;
    return 0;
}


Measured memory_bytes: 6424
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (n); ++i)
#define rrep(i,n) for(int i = 1; i <= (n); ++i)
#define drep(i,n) for(int i = (n)-1; i >= 0; --i)
#define srep(i,s,t) for (int i = s; i < t; ++i)
using namespace std;
typedef long long int ll;
typedef pair<int,int> P;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef vector<ll> vl;
typedef vector<P> vp;
#define dame { puts("-1"); return 0;}
#define yn {puts("Yes");}else{puts("No");}
struct edge{ int to, num; };
const int INF = 1001001001;
const int MAX_V = 200005;
int V,E;
vector<edge> G[MAX_V];
int d[MAX_V];
set<int> se[MAX_V];
int f[MAX_V];

void dijkstra(int s){
    // greater<P>を指定することでfirstが小さい順に取り出せるようにする
    priority_queue<P, vector<P>, greater<P> > que;
    fill(d, d+V, INF);
    d[s] = 0;
    que.push(P(0, s));

    while(!que.empty()){
        P p = que.top();
        que.pop();
        int v = p.second;
        if(d[v] >= d[V-1])continue;
        if(f[v] == 1)continue;
        f[v] = 1;
        for(int i=0; i<G[v].size(); i++){
            edge e = G[v][i];
            if(d[e.to] >= d[v]){
                auto it = se[v].find(e.num);
                if(it != se[v].end()){
                    if(d[e.to] == d[v]){
                        auto it2 = se[e.to].find(e.num);
                        if(it2 == se[e.to].end()){
                            se[e.to].insert(e.num);
                            f[e.to] = 0;
                            que.push(P(d[e.to], e.to));
                        }
                    }else{
                        se[e.to].clear();
                        se[e.to].insert(e.num);
                        d[e.to] = d[v];
                        f[e.to] = 0;
                        que.push(P(d[e.to], e.to));
                    }
                }else if(d[e.to] > d[v]){
                    if(d[e.to] == d[v] + 1){
                        auto it2 = se[e.to].find(e.num);
                        if(it2 == se[e.to].end()){
                            se[e.to].insert(e.num);
                            f[e.to] = 0;
                            que.push(P(d[e.to], e.to));
                        }
                    }else{
                        se[e.to].clear();
                        se[e.to].insert(e.num);
                        d[e.to] = d[v] + 1;
                        f[e.to] = 0;
                        que.push(P(d[e.to], e.to));
                    }
                }
            }
        }
    }
}

int main() {
    cin >> V >> E;
    rep(i,E){
        int from,to,num;
        cin >> from >> to >> num;
        from--; to--;
        edge e1, e2;
        e1.to = to; e1.num = num;
        e2.to = from; e2.num = num;
        G[from].push_back(e1);
        G[to].push_back(e2);
    }

    dijkstra(0);

    if(d[V-1] == INF)d[V-1] = -1;
    cout << d[V-1] << endl;
    return 0;
}


Measured memory_bytes: 29044
#include <iostream>
#include <string>
#include <vector>
#include <algorithm>
#include <cmath>
using namespace std;

string data[] = {"Man", "Oku", "Cho", "Kei", "Gai", "Jo", "Jou", "Ko", "Kan", "Sei", "Sai", "Gok", "Ggs", "Asg", "Nyt", "Fks", "Mts"};

int block[20];

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

	int m, n;
	while(cin >> m >> n && (m || n)){
		fill(block, block + 20, 0);
		block[0] = 1;
		for(int i = 0; i < n; ++i){
			for(int j = 0; j < 18; ++j){
				block[j] *= m;
			}
			for(int j = 0; j < 18; ++j){
				int up = block[j] / 10000;
				block[j + 1] += up;
				block[j] -= up * 10000;
			}
		}

		for(int i = 17; i >= 0; --i){
			if(block[i]){
				cout << block[i];
				if(i != 0)
					cout << data[i - 1];
			}
		}
		cout << endl;
	}

	return 0;
}
/*
int main(){
	cin.tie(0);
	ios::sync_with_stdio(false);

	int m, n;
	while(cin >> m >> n && (m || n)){

		long double f = n * (long double)log10(m);

		//cout << f << endl;

		//cout << pow(10, f) << endl;

		long double d = f - (int)(f);

		//cout << d << endl;

		long double d2 = pow(10, d);

		cout << fixed << setprecision(20) << d2 << endl;

		for(int i = 17; i >= 0; --i){
			if(i * 4 <= f){
				d2 *= pow(10, min((int)f - i * 4, 4));
				cout << d2 << endl;
				if((int)d2 == 0) continue;
				cout << (int)d2;
				d2 -= (int)d2;
				//cout << d2 << endl;
				if(i != 0){
					cout << data[i - 1] << endl;;
				}
			}
		}
		cout << endl;
	}

	return 0;
}
*/

Measured memory_bytes: 1208
#include <bits/stdc++.h>
#define rep(i,n) for(int i = 0; i < (int)(n); i++)
#define rrep(ri,n) for(int ri = (int)(n-1); ri >= 0; ri--)
#define rep2(i,x,n) for(int i = (int)(x); i < (int)(n); i++)
#define rrep2(ri,x,n) for(int ri = (int)(n-1); ri >= (int)(x); ri--)
#define repit(itr,x) for(auto itr = x.begin(); itr != x.end(); itr++)
#define rrepit(ritr,x) for(auto ritr = x.rbegin(); ritr != x.rend(); ritr++)
#define ALL(x) x.begin(), x.end()
using ll = long long;
using namespace std;

const int INF = 1001001001;
int main(){
  int n, m, k;
  cin >> n >> m >> k;
  vector<ll> suma(n+1, 0), sumb(m+1, 0);
  rep(i, n){
    int in;
    cin >> in;
    suma.at(i+1) = in + suma.at(i);
  }
  rep(i, m){
    int in;
    cin >> in;
    sumb.at(i+1) = in + sumb.at(i);
  }
  int ans = 0;
  rep(i, n+1){
    int add = i;
    int kk = k - suma.at(i);
    if(kk < 0) break;
    int it = upper_bound(sumb.begin(), sumb.end(), kk) - sumb.begin();
    add += it-1;
    ans = max(ans, add);
  }
  cout << ans << endl;
  return 0;
}

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

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

            return;
        }

        public void Solve(ConsoleInput cin)
        {

            var N = cin.ReadInt;
            var X = cin.ReadInt;
            var x = cin.ReadIntArray(N);

            for (int i = 0; i < N; i++)
            {
                x[i] = Abs(x[i] - X);
            }
            var ans = x[0];
            for (int i = 1; i < N; i++)
            {
                ans = Gcd(ans, x[i]);
            }

            Console.WriteLine(ans);
        }
        public int Gcd(int a, int b)
        {
            if(a == 0) return b;
            if(b == 0) return a;
            if (a < b) {
                return Gcd(b, a);
            }
            while (b != 0) {
                int remainder = a % b;
                a = b;
                b = remainder;
            }
            return a;
        }
    }

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

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


Measured memory_bytes: 20448
import java.util.*;
public class Main {
  public static void main(String[] args){
    Scanner sc = new Scanner(System.in);
	int n = sc.nextInt();
    HashMap<String,Integer> map = new HashMap<String,Integer>();
    LinkedList<String> array = new LinkedList<String>();
    int max = 1;
    for(int i = 0; i < n; i++){
      String s = sc.next();
      int tmp = 1;
      if(map.containsKey(s)){
        tmp = map.get(s)+1;
      }
      map.put(s, tmp);
      
      if(tmp == max){
        array.add(s);
      } 
      else if(tmp > max){
        max = tmp;
        array.clear();
        array.add(s);
      }
    }
    
    array.sort(Comparator.naturalOrder());
    for(String value : array)
	{
      System.out.println(value);
	}
  }
}

Measured memory_bytes: 95312
S = input()
T = input()

L = len(T)
ans = 0

for i in range(len(S)-L+1):
    cnt = 0
    for j in range(L):
        
        if S[i+j] == T[j]:
            cnt += 1
        ans = max(ans,cnt)
        
print(L-ans)

Measured memory_bytes: 9120
/** 
 * THIS IS MOOONI'S CODE !
 * HACK IT IF YOU CAN !
**/
#include <bits/stdc++.h>

using namespace std;

int main() {
  ios::sync_with_stdio(false);
  cin.tie(0);
  auto Pal = [&](string s) {
    string t = s;
    reverse(t.begin(), t.end());
    return t == s;
  };
  string s;
  cin >> s;
  int n = (int) s.size();
  if (Pal(s) && Pal(s.substr(0, n / 2)) && Pal(s.substr(n / 2 + 1, n / 2))) {
    cout << "Yes" << '\n';
    return 0;
  }
  cout << "No" << '\n';
  return 0;
}

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

int main() {
  int N, i; 
  int judge = 0;
  string S;
  
  cin >> N;
  
  for(i = 0; i < N; i++)
  {
    cin >> S;
    
    if(S == "Y")
      judge = 1;
  }

  if(judge == 1)
    cout << "Four" << endl;
  else
    cout << "Three" << endl;
}


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

int main(){
	int n,k;
	int last=0,num=-1,ans=0;
	set <int> val;

	cin >>n >>k;
	int *array=new int[n];
	for(int i=0;i<n;i++){
		cin >>array[i];
		val.insert(array[i]);
	}
	int *count=new int[(int)val.size()];
	if((int)val.size()>k){
		sort(array,array+n);
		for(int i=0;i<n;i++){
			if(last!=array[i]){
				num++;
				count[num]=1;
			}
			else count[num]++;
			last=array[i];
		}
		sort(count,count+(int)val.size());
		for(int i=0;i<(int)val.size()-k;i++)ans+=count[i];
		cout<<ans<<endl;
	}
	else cout<<0<<endl;
	return 0;
}


Measured memory_bytes: 11136
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
int main(){
int N,K; cin >> N >> K; ll sum = 0;
  for(int b = 1; b <= N; b++){
    int p = N/b; int r = N%b;
    sum  += max(b-K,0)*p + max(r-K+1,0); if( K == 0){ sum--;}}
  
  cout << sum << endl; return 0;}
  
  

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

int main() {
  long long N,M,x,y,z;
  z=0;
  cin >>N;
  vector<long long>a(N),b(N),c(M),d(M),e(N);
  for(int i=0;i<N;i++){
    cin>>a[i];
  }
  sort(a.begin(),a.end());
    for(int i=0;i<N-1;i++){
    if(a[i]==a[i+1]){
      b[i]=a[i];
      i++;
    }
  }
  sort(b.begin(),b.end());
  reverse(b.begin(),b.end());
  cout<<b[0]*b[1]<<endl;
}


Measured memory_bytes: 2560
#include<stdio.h>

void swap(int *a, int *b){
	int c;
	c = *a;
	*a = *b;
	*b = c;
}

int main(){
	int x, y, z;
	scanf("%d %d %d", &x, &y, &z);
	swap(&x, &y);
	swap(&x, &z);
	printf("%d %d %d\n", x, y, z);
	return 0;
}

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

ans = 0
current_move = 0
current_hight = 0
for h in H:
    if h > current_hight:
        current_move = 0
        current_hight = h
    else:
        current_move += 1
        current_hight = h
        ans = max(current_move, ans)
print(ans)


Measured memory_bytes: 14224
import java.util.*;
class Main
{
    public static void main (String[] args)
    {
        Scanner sc = new Scanner(System.in);
        int n = sc.nextInt();
        int a = sc.nextInt();
        int b = sc.nextInt();
        int ans = 0;
        for(int i = 1; i <= n; i++)
            if(judge(i, a, b)) ans += i;
        System.out.println(ans);
    }
    static boolean judge(int i, int a, int b){
        int k = 0;
        while(i > 0){
            k += i - i / 10 * 10;
            i /= 10;
        }
        if(a <= k && k <= b) return true;
        else return false;
    }
}

Measured memory_bytes: 23888
#include <iostream>
#include <algorithm>
#include <utility>
#include <vector>
#include <string>

using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
#define REP(i, n) for (int i = 0; i < (n); i++)
#define RREP(i, n) for (int i = (n) - 1; i >= 0; i--)
#define FOR(i, a, b) for (int i = (a); i < (b); i++)
#define RFOR(i, a, b) for (int i = (a); i > (b); i--)
#define ALL(a) (a).begin(), (a).end()

vector<int> prime;

bool check(int num) {
    vector<int> vi;
    for (int p : prime) {
        int count = 0;
        while (num % p == 0) {
            count++;
            num /= p;
        }
        vi.push_back(count + 1);
    }
    int ret = 1;
    for (int i : vi) ret *= i;
    return ret == 8;
}

int main() {
    prime.push_back(2);
    FOR(i, 3, 201) {
        bool ok = true;
        for (int p : prime) {
            ok &= i % p != 0;
        }
        if (ok) prime.push_back(i);
    }

    int N;
    cin >> N;
    int ans = 0;
    for (int i = 1; i <= N; i += 2) {
        if (check(i)) ans++;
    }
    cout << ans << endl;
    return 0;
}

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

int main(){
  int n, R[200000];
  cin >> n;
  for(int i=0; i<n; ++i) cin >> R[i];
  
  int maxv = -2000000000;
  int minv = R[0];
  for(int j=1; j<n; ++j){
    maxv = max(maxv, R[j]-minv);
    minv = min(minv, R[j]);
  }
  cout << maxv << endl;
  return 0;
}




Measured memory_bytes: 3904
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<int,int> pp;
typedef pair<ll,ll> pll;
void read(int& x){ scanf("%d",&x); }
void read(ll& x){ scanf("%lld",&x); }
template<typename T,typename... Args>
void read(T& a,Args&... b){ read(a); read(b...); }
#define all(x) (x).begin(),(x).end()
#define pb push_back
#define x first
#define y second

int n, v;

int x[200010];

int hn;
int gl[20][200010];
int gr[20][200010];

void in(){
	read(n, v);
	for(int i=1; i<=n; ++i) read(x[i]);
}

void build(){
	for(;;++hn, v/=2){
		for(int i=1; i<=n;){
			int j;
			for(j=i+1; j<=n && x[j]-x[j-1] <= v; ++j);
 			for(int k=i; k<j; ++k){
				gl[hn][k]=i;
				gr[hn][k]=j-1;
			}
			i=j;
		}
		if(v == 0) break;
	}
}

int dpL[524288];
int dpR[524288];

void do_dp(){
	int M = (1<<hn);
	for(int i=0; i<M; ++i){
		dpL[i] = 0;
		dpR[i] = n+1;
		for(int j=1; j<=hn; ++j){
			int key = (1 << (j-1));
			if(i & key){
				int bl=dpL[i^key], br=dpR[i^key];
				dpL[i] = max(dpL[i], bl == n ? n : gr[j][bl+1]);
				dpR[i] = min(dpR[i], br == 1 ? 1 : gl[j][br-1]);
			}
		}
	}
}

bool all_yes;
bool yes[200010];
void apply_gugan(int a, int b){
	if(a > b){
		all_yes = true;
	} else {
		if(gl[0][a] == gl[0][b]){
			yes[gl[0][a]]=1;
		}
	}
}

void Fill(){
	int M = (1<<hn);
	for(int i=1; i<M; ++i){
		dpL[i] = max(dpL[i], dpL[i&(i-1)]);
		dpR[i] = min(dpR[i], dpR[i&(i-1)]);
	}
	for(int i=0; i<M; ++i){
		int l=dpL[i]+1;
		int r=dpR[(M-1)^i]-1;
		apply_gugan(l, r);
	}
}

int main()
{
	in(); build(); do_dp(); Fill();
	for(int i=1; i<=n; ++i){
		puts((all_yes || yes[gl[0][i]])?"Possible":"Impossible");
	}
    return 0;
}


Measured memory_bytes: 36992
#include "bits/stdc++.h"
using namespace std;
#define int long long
#define FOR(i, a, b) for(int i=(a);i<(b);i++)
#define RFOR(i, a, b) for(int i=(b-1);i>=(a);i--)
#define REP(i, n) for(int i=0; i<(n); i++)
#define RREP(i, n) for(int i=(n-1); i>=0; i--)
#define REP1(i, n) for(int i=1; i<=(n); i++)
#define RREP1(i, n) for(int i=(n); i>=1; i--)
#define ALL(a) (a).begin(),(a).end()
#define UNIQUE_SORT(l) sort(ALL(l)); l.erase(unique(ALL(l)), l.end());
#define CONTAIN(a, b) find(ALL(a), (b)) != (a).end()
#define out(...) printf(__VA_ARGS__)
#if DEBUG
#define debug(...) printf(__VA_ARGS__)
#else
#define debug(...) /* ... */
#endif
template<class T>bool chmax(T &a,const T &b){if(a<b){a=b;return true;}return false;}
template<class T>bool chmin(T &a,const T &b){if(b<a){a=b;return true;}return false;}

void solve();
signed main()
{
#if DEBUG
    std::ifstream in("input.txt");
    std::cin.rdbuf(in.rdbuf());
#endif
    cin.tie(0);
    ios::sync_with_stdio(false);
    solve();
    return 0;
}

/*================================*/
#if DEBUG
#define SIZE 100
#else
#define SIZE 223450
#endif

int N,Q,K;
int A[SIZE];

void solve() {
    cin>>N;
    
    cout << (N+N*N+N*N*N) << endl;
}


Measured memory_bytes: 3640
a = int(input())
b = int(input())
c = int(input())
d = int(input())
e = int(input())
k = int(input())
if a<b<c<d<e :
  if e - a <= k :
    if d - a <= k:
      if c - a <= k:
        if b - a <= k:
          print('Yay!')
  else:
    print(":(")

Measured memory_bytes: 3060
#include <iostream>
#include <string>
#include <algorithm>
#include <vector>
#include <iomanip>
#include <cmath>
#include <stdio.h>
#include <queue>
#include <deque>
#include <cstdio>
#include <set>
#include <map>
#include <bitset>
#include <stack>
using namespace std;
long long a[100010], b[100010];
int main() {
	int n;
	long long h;
	cin >> n >> h;
	for (int i = 0; i < n; i++) {
		cin >> a[i] >> b[i];
	}
	sort(a, a + n);
	sort(b, b + n);
	long long s = a[n - 1];
	int co = 0;
	for (int i = n - 1; i >= 0; i--) {
		if (s > b[i]) {
			break;
		}
		h -= b[i];
		co++;
		if (h <= 0) {
			cout << co << endl;
			return 0;
		}
	}
	cout << co + (h + s - 1) / s << endl;
	return 0;
}


Measured memory_bytes: 1792
#include "bits/stdc++.h"
#include <regex>
#define _USE_MATH_DEFINES
#include <math.h>

using namespace std;

#ifndef _DEBUG
#define main_ main
#endif
#define FOR(i,s,e) for (int i = int(s); i != int(e); i++)
#define INF (INT_MAX/2)
#define EPS (1.0e-8)
#define LINF (LONG_MAX/2)

typedef long long ll;
typedef vector<int> vi;
typedef vector<vi> vvi;
typedef pair<int, int> pii;

template <typename T>
using keyVal = pair<string, T>;
template<typename T>
bool val_greater(const keyVal<T>& left, const keyVal<T>& right) {
	return left.second > right.second;
}

void init_global() {}

int main_() {
	string S;
	cin >> S;

	int i = 0;
	while (S[i] != 'A') i++;
	int j = S.size() - 1;
	while (S[j] != 'Z') j--;

	int ans = j - i + 1;
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 640
#include <iostream>

#include <stack>
#include <queue>
#include <deque>
#include <vector>
#include <set>
#include <map>
#include <unordered_set>
#include <unordered_map>

#include <cmath>
#include <algorithm>

#include <fstream>

using namespace std;

#define M_PI 3.14159265358979323846264338327950288


int main()
{
  srand(179179);

  cin.tie(nullptr);
  ios_base::sync_with_stdio(false);

  cout.setf(ios_base::fixed);
  cout.precision(28);

  int n;
  cin >> n;
  vector<int> v(n);
  for (auto& x : v) {
    cin >> x;
  }

  long long ans = 0;
  for (int i = 0; i < n; ++i) {
    ans += v[i] / 2;
    if (v[i] % 2 == 1 && i < n - 1 && v[i + 1] > 0) {
      --v[i + 1];
      ++ans;
    }
  }
  cout << ans;
  return 0;
}

Measured memory_bytes: 640
import java.util.*;
import java.io.*;

//多項式を利用した考察による解法
public class Main {
	static final int mod = 998244353;
	static final int DX[] = { -1, 0, 1, 0 }, DY[] = { 0, -1, 0, 1 };
	static final int[] DX8 = { -1, -1, -1, 0, 0, 1, 1, 1 }, DY8 = { -1, 0, 1, -1, 1, -1, 0, 1 };
	static final int INF = Integer.MAX_VALUE / 3;
	static final long LINF = Long.MAX_VALUE / 3;
	static final String nextLine = "\n";

	public static void main(String[] args) {
		FastScanner fs = new FastScanner(System.in);
		int n = fs.nextInt(), s = fs.nextInt();
		int a[] = fs.nextIntArray(n);
		
		int F[] = new int[s+1];
		long ans = 0;
		for(int i=0;i<n;i++) {
			F[0] += 1;
			int F2[] = new int[s+1];
			for(int j=0;j<s+1;j++) {//このループがF3=f3(F2+1)のf3をかける事に値する
				F2[j] += F[j];
				F2[j] %= mod;
				if(j+a[i]<s+1) {
					F2[j+a[i]] += F[j];
					F2[j+a[i]] %= mod;
				}
			}
			F = F2;
			ans += F[s];
			ans %= mod;
		}
		System.out.println(ans);
	}

	//MOD culculations
	static long plus(long x, long y) {
		long res = (x + y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long sub(long x, long y) {
		long res = (x - y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long mul(long x, long y) {
		long res = (x * y) % mod;
		return res < 0 ? res + mod : res;
	}

	static long div(long x, long y) {
		long res = x * pow(y, mod - 2) % mod;
		return res < 0 ? res + mod : res;
	}

	static long pow(long x, long y) {
		if (y < 0)
			return 0;
		if (y == 0)
			return 1;
		if (y % 2 == 1)
			return (x * pow(x, y - 1)) % mod;
		long root = pow(x, y / 2);
		return root * root % mod;
	}
}

//高速なScanner
class FastScanner {
	private BufferedReader reader = null;
	private StringTokenizer tokenizer = null;

	public FastScanner(InputStream in) {
		reader = new BufferedReader(new InputStreamReader(in));
		tokenizer = null;
	}

	public String next() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				tokenizer = new StringTokenizer(reader.readLine());
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken();
	}

	public String nextLine() {
		if (tokenizer == null || !tokenizer.hasMoreTokens()) {
			try {
				return reader.readLine();
			} catch (IOException e) {
				throw new RuntimeException(e);
			}
		}
		return tokenizer.nextToken("\n");
	}

	public long nextLong() {
		return Long.parseLong(next());
	}

	public int nextInt() {
		return Integer.parseInt(next());
	}

	public double nextDouble() {
		return Double.parseDouble(next());
	}

	public int[] nextIntArray(int n) {
		int[] a = new int[n];
		for (int i = 0; i < n; i++)
			a[i] = nextInt();
		return a;
	}

	public long[] nextLongArray(int n) {
		long[] a = new long[n];
		for (int i = 0; i < n; i++)
			a[i] = nextLong();
		return a;
	}
}

Measured memory_bytes: 43732
// OBツ嘉ッツ嘉債宿2011 Day3 C : On or Off

#include <iostream>
#include <string>
#include <queue>
#include <cstring>

using namespace std;

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

int main(){
	int R, C, M;
	int pow[50][50], on[50][50], off[50][50];
	long long cost[2][50][50], time[50][50];
	int prev[50*50];
	string mp[50];
	while(cin >> R >> C >> M){
		memset(cost, 0, sizeof(cost));
		memset(time, 0, sizeof(time));
		for(int i=0;i<R;i++) cin >> mp[i];
		for(int i=0;i<R;i++)
			for(int j=0;j<C;j++) cin >> pow[i][j];
		for(int i=0;i<R;i++)
			for(int j=0;j<C;j++) cin >> on[i][j], cost[0][i][j] = on[i][j];
		for(int i=0;i<R;i++)
			for(int j=0;j<C;j++) cin >> off[i][j], time[i][j] = -1000000007;
		int px, py, cx, cy; cin >> cx >> cy;
		int t = 0;
		for(int i=1;i<M;i++){
			px = cx, py = cy;
			cin >> cx >> cy;
			if(px==cx && py==cy) continue;
			queue< pair<int,int> > qu; qu.push(make_pair(cx, cy));
			memset(prev, -1, sizeof(prev));
			prev[cx*C+cy] = -2;
			while(!qu.empty()){
				pair<int,int> pr = qu.front(); qu.pop();
				for(int j=0;j<4;j++){
					int x = pr.first+dx[j], y = pr.second+dy[j];
					if(x<0||R<=x||y<0||C<=y||mp[x][y]=='#') continue;
					if(prev[x*C+y]==-1){
						prev[x*C+y] = pr.first*C+pr.second;
						qu.push(make_pair(x,y));
					}
				}
			}
			for(int cur=px*C+py;prev[cur]!=-2;cur=prev[cur]){
				int x = cur/C, y = cur%C;
				cost[0][x][y] = min(cost[0][x][y]+(t-time[x][y])*pow[x][y], cost[1][x][y]+on[x][y]);
				cost[1][x][y] = cost[0][x][y]+off[x][y];
				time[x][y] = t++;
			}
		}
		cost[0][cx][cy] = min(cost[0][cx][cy]+(t-time[cx][cy])*pow[cx][cy], cost[1][cx][cy]+on[cx][cy]);
		cost[1][cx][cy] = cost[0][cx][cy]+off[cx][cy];
		time[cx][cy] = t;

		int res = 0;
		for(int i=0;i<R;i++)
			for(int j=0;j<C;j++) res += cost[1][i][j];
		cout << res << endl;
	}
}

Measured memory_bytes: 996
import kotlin.math.max

fun readString() = readLine()!!
fun readInt() = readLine()!!.toInt()
fun readLong() = readLine()!!.toLong()
fun readIntList() = readLine()!!.split(" ").map(String::toInt)
fun readLongList() = readLine()!!.split(" ").map(String::toLong)
fun <T> Array<Array<T>>.print() {
    this.forEach {
        println(it.joinToString(" "))
    }
}

fun List<Long>.upperBound(element: Long, fromIndex: Int = 0, toIndex: Int = size): Int {
    return binarySearch(element, Comparator { x, y ->
        if (x > y) {
            1
        } else {
            -1
        }
    }, fromIndex, toIndex).inv()
}

@ExperimentalStdlibApi
fun main() {
    val (_, _, k) = readLongList()
    val a = readLongList()
    val b = readLongList()

    val ar = listOf(0L) + a.scanReduce { acc, l -> acc + l }
    val br = listOf(0L) + b.scanReduce { acc, l -> acc + l }

    var res = 0
    for (aCount in ar.indices) {
        val remain = k - ar[aCount]
        if (remain < 0) continue
        val bCount = br.upperBound(remain) - 1
        res = max(res, aCount + bCount)
    }

    print(res)
}

Measured memory_bytes: 94412
#include<iostream>
using namespace std;
int main(){
	while(true){
	int n=32,a,b[25]={0},c=0;
	cin>>a;
	if(a==0)break;
	for(int i=0;i<a;i++){
		cin>>b[i];
	}
	while(true){
		for(int i=0;i<a;i++){
			n=n-(n-1)%5;
			cout<<n<<endl;
			n=n-b[i];
				if(n<1){
				c=1;
				n=0;
				cout<<n<<endl;
				break;
			}
			cout<<n<<endl;
		}
		if(c==1)break;
	}
	}
}

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

using namespace std;

typedef long long LL;
typedef pair<int , int> P2;
typedef pair<pair<int , int> , int> P3;
typedef pair<pair<int , int> , pair<int , int> > P4;
#define PB(a) push_back(a)
#define MP(a , b) make_pair((a) , (b))
#define M3P(a , b , c) make_pair(make_pair((a) , (b)) , (c))
#define M4P(a , b , c , d) make_pair(make_pair((a) , (b)) , make_pair((c) , (d)))
#define repp(i,a,b) for(int i = (int)(a) ; i < (int)(b) ; ++i)
#define repm(i,a,b) for(int i = (int)(a) ; i > (int)(b) ; --i)

const int MC = 2010;
const LL mod = 1e9 + 7;
LL fct[MC*2];
LL inv[MC*2];
int A,B;
LL comb[MC][MC];
LL s[MC][MC];
LL s2[MC][MC];

void build(){
	int z = MC*2;
	fct[0] = 1;
	repp(i,1,z) fct[i] = fct[i-1] * i % mod;
	inv[z-1] = 1;
	LL x = fct[z-1];
	for(int i = mod - 2 ; i > 0 ; i >>= 1 , x = x * x % mod){
		if(i%2) (inv[z-1] *= x) %= mod;
	}
	repm(i,z-1,0) inv[i-1] = inv[i] * i % mod;
	repp(i,0,MC) repp(j,0,MC) comb[i][j] = inv[i] * inv[j] % mod * fct[i+j] % mod;
	repp(i,0,MC){
		s[i][0] = comb[0][i];
		repp(j,1,MC){
			if(j > i) break;
			s[i][j] = (s[i][j-1] + comb[j][i-j]) % mod;
		}
	}
	repp(i,0,MC){
		s2[i][0] = s[i][0];
		repp(j,1,MC){
			if(j > i) break;
			s2[i][j] = (s2[i][j-1] + s[i][j]) % mod;
		}
	}
}

int main(){
	build();
	cin >> A >> B;
	LL ans = 0;
	repp(i,0,A+1){
		repp(j,0,B){
			if(i+j > A) break;
			(ans += comb[j][B-j-1] * (j?(i>j-1?(s2[j-1][j-1]+s[j-1][j-1]*(i-j+1))%mod:s2[j-1][i]):1)) %= mod;
		//	cout << i << ' ' << j << ' ' << ans << endl;
		}
	}
	cout << ans << endl;
	return 0;
}


Measured memory_bytes: 93568
using System;
class Program
{
	static void Main(string[] args)
	{
		// スペース区切りの整数の入力
		string[] input = Console.ReadLine().Split(' ');
		int n = int.Parse(input[0]);
		int m = int.Parse(input[1]);
      	int ans = n * (n-1) / 2 + m * (m-1) / 2;
		//出力
		Console.WriteLine(ans);
	}
}



Measured memory_bytes: 11092
use proconio::{input,fastout};

#[fastout]
fn main() {
    input! {
        n: usize,
        p: [usize; n],
    }
    let mut cnt = 0;
    for i in 1..n-1 {
        if p[i-1] < p[i] && p[i] < p[i+1] {cnt += 1;}
        if p[i-1] > p[i] && p[i] > p[i+1] {cnt += 1;}
    }
    println!("{}",cnt);
}


Measured memory_bytes: 2144