akhauriyash/Code-Regression huggingface dataset:
#include <iostream>
#include <cmath>
#include <cstdlib>
#include <algorithm>

using namespace std;

int main()
{
	int n;
	int h[20];

	cin >> n;
	for (int i = 0; i < n; i++) {
		cin >> h[i];
	}

	int max_height = 0;
	int count = 0;
	for (int i = 0; i < n; i++) {
		if (max_height <= h[i]) {
			count++;
		}

		max_height = std::max(max_height, h[i]);
	}

	cout << count << endl;

	return 0;
}


Measured memory_bytes: 256
def main():

  n = int(input())
  arr = map(int, input().split())
  arr = tuple(sorted(enumerate(arr), key=lambda tpl: -tpl[1]))

  dp = [[0] * (n + 1) for _ in range(n + 1)]
  for i, (p, a) in enumerate(arr):
    for l in range(i + 1):
      dp[i + 1][l] = max(dp[i + 1][l], dp[i][l] + a * abs(p - (n - (i - l) - 1)))
      dp[i + 1][l + 1] = max(dp[i + 1][l + 1], dp[i][l] + a * abs(p - l))

  print(max(dp[n]))

main()


Measured memory_bytes: 135968
#include<bits/stdc++.h>
#define ll long long int 
#define mod 1000000007
#define se second
#define fi first
#define endl "\n"
using namespace std;
int main()
{
	ios_base::sync_with_stdio(false);
	cin.tie(0);cout.tie(0);
	ll n;
	cin>>n;
	ll x;
	ll ans=0;
	while(n>0)
	{
		x=n%10;
		if(x==7)
		{
			ans=1;
			break;
		}
		n/=10;
	}
	if(ans==1)
	cout<<"Yes";
	else
	cout<<"No";
	return 0;
}


Measured memory_bytes: 3652
import java.util.ArrayList;
import java.util.Scanner;

public class Main {
	
	public static void main(String[] args) {
		
		Scanner in = new Scanner(System.in);
		int A = in.nextInt();
		int B = in.nextInt();
		int M = in.nextInt();
		ArrayList<Integer> a = new ArrayList<Integer>();
		ArrayList<Integer> b = new ArrayList<Integer>();
//		ArrayList<ArrayList<Integer>> m = new ArrayList<ArrayList<Integer>>();
		
		int price = Integer.MAX_VALUE;
		int a_min = Integer.MAX_VALUE;
		int b_min = Integer.MAX_VALUE;
		
		for(int i=0; i<A; i++) {
			int temp = in.nextInt();
			a.add(temp);
			a_min = Math.min(a_min, temp);
		}
		for(int i=0; i<B; i++) {
			int temp = in.nextInt();
			b.add(temp);
			b_min = Math.min(b_min, temp);
		}
		for(int i=0; i<M; i++) {
//			ArrayList<Integer> c = new ArrayList<Integer>();
			int x = in.nextInt();
			int y = in.nextInt();
			int c = in.nextInt();
//			m.add(c);
			price = Math.min(price, a.get(x-1)+b.get(y-1)-c);
		}
		
		System.out.print(Math.min(price,a_min+b_min));
	}
	
}


Measured memory_bytes: 160588
# coding: utf-8
# Your code here!
N,M=map(int,input().split())
A=list(map(int,input().split()))

ans=0
wa=0
log={0:1}
for i in range(len(A)):
    wa+=A[i]
    if wa%M in log:
        ans+=log[wa%M]
        log[wa%M]+=1
    else:
        log[wa%M]=1
print(ans)



Measured memory_bytes: 14696
// Practice yahoo procon 2019 qual
// author: Leonardone @ NEETSDKASU 

fn main() {
	let mut stdin = String::new();
    std::io::Read::read_to_string(
    	&mut std::io::stdin(),
        &mut stdin).unwrap();
	let mut stdin = stdin.split_whitespace();
    let mut get = || stdin.next().unwrap();
    macro_rules! get {
    	($t:ty) => (get().parse::<$t>().unwrap());
        () => (get!(i64));
    }
    
    let n = get!(usize);
    let mut dp = vec![vec![0; 5]; n+1];
    use std::cmp::min;
    for i in 0..n {
    	let x = get!();
        
        let m = dp[i][0];
        dp[i+1][0] = m + x;
        
        let m = min(m, dp[i][1]);
        dp[i+1][1] = m + if x == 0 { 2 } else { x % 2 };
        
        let m = min(m, dp[i][2]);
		dp[i+1][2] = m + 1 - x % 2;
        
        let m = min(m, dp[i][3]);
        dp[i+1][3] = m + if x == 0 { 2 } else { x % 2 };
        
        let m = min(m, dp[i][4]);
        dp[i+1][4] = m + x;
    }
    
    let ans = dp[n].iter().min().unwrap();
    
    println!("{}", ans);
}

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




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

    int h[n+5];

    rep(i,n){
        cin >> h[i];
    }

    int a[n+5]={};

    a[1]=abs(h[1]-h[0]);

    for(int i=1;i<n-1;i++){
        a[i+1]=min(a[i-1]+abs(h[i+1]-h[i-1]),a[i]+abs(h[i+1]-h[i]));
    }


    cout << a[n-1] << endl;
    return 0;
}


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

int main(){
	char S[4];
	int ans=0;
	for(int i=0;i<4;i++){
		cin>>S[i];
		if(S[i]=='+')
			ans=ans+1;
		else
			ans=ans-1;
	}
	cout<<ans<<endl;
	return 0;
}


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

#define IOS ios::sync_with_stdio(0); cin.tie(0); cout.tie(0);
#define int long long
#define fr(i,a,b) for(int i=a;i<=b;i++)


const int N=2e5+5;


void solve()
{
	char a;
	cin>>a;
	int num=a-'a';
	if(num>=0 && num<=25)
		cout<<"a";
	else
		cout<<"A";
}

int32_t main()
{
	#ifndef ONLINE_JUDGE
	freopen("input.txt","r",stdin);
	freopen("output.txt","w",stdout);
	#endif
	
	IOS;

	int t=1;
	//cin>>t;
	while(t--)
		solve();

}

Measured memory_bytes: 3648
import bisect, collections, copy, heapq, itertools, math, string
import sys
def I(): return int(sys.stdin.readline().rstrip())
def MI(): return map(int, sys.stdin.readline().rstrip().split())
def LI(): return list(map(int, sys.stdin.readline().rstrip().split()))
def S(): return sys.stdin.readline().rstrip()
def LS(): return list(sys.stdin.readline().rstrip().split())

def main():
    from collections import deque
    N, M = MI()
    fri_list = [[] for _ in range(N)]
    for i in range(M):
        a, b = MI()
        fri_list[a - 1].append(b - 1)
        fri_list[b - 1].append(a - 1)

    #print(fri_list)
    group_list = []
    num_list = [0] * N
    for i in range(0, N):
        if num_list[i] == 0:
            num_list[i] = 1
            #print(i, 'i')
            cnt = 1
            queue = deque([i])
            while queue:
                v = queue.popleft()
                #print(v, 'v')
                for j in fri_list[v]:
                    #print(j, 'j')
                    if num_list[j] == 0:
                        num_list[j] = 1
                        queue.append(j)
                        cnt += 1
            group_list.append(cnt)

    ans = max(group_list)
    print(ans)

if __name__ == "__main__":
    main()

Measured memory_bytes: 102720
#include <iostream>
#include <iomanip>
#include <string>
#include <vector>
#include <algorithm>
#include <map>
#include <cmath>
#include <queue>
#include <set>
#include <cassert>

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

using namespace std;
typedef long long int ll;
const int INF = 1000000000;
const double PI = acos(-1);
const ll mod = 1000000007;

int main()
{
    int n;
    cin >> n;
    vector<int> a(n);
    rep(i, n) cin >> a[i];

    int p = 1;
    int b = 0;
    rep(i, n) {
        if (a[i] == p) p++;
        else b++;
    }
    if (b == n) cout << -1 << endl;
    else cout << b << endl;
}

Measured memory_bytes: 4028
#include <bits/stdc++.h>
#include <math.h>
using namespace std;
int main(){
  int N,M=0,M2=0,k;
  cin>>N;
  int a[N];
  for(int i=0;i<N;i++){
    cin>>a[i];
    M=max(M,a[i]);
    if(M==a[i]) k=i;
  }
  
  for(int i=0;i<N;i++){
    int cnt=0;
    if(cnt==0&&i==k){
      cnt++;
      continue;
    }else M2=max(M2,a[i]);
  }
  
  for(int i=0;i<N;i++){
    if(i==k) cout<<M2<<endl;
    else cout<<M<<endl;
  }
}


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

using namespace std;

main() {
#ifdef HOME
    freopen("input.txt", "r", stdin);
#endif // HOME
    ios_base::sync_with_stdio(0);
    cin.tie(0);
    cout.tie(0);
    string s;
    cin >> s;
    sort(s.begin(), s.end());
    if (s[0] == s[1] && s[2] == s[3] && s[1] != s[2]) cout << "Yes";
    else cout << "No" << '\n';
    return 0;
}


Measured memory_bytes: 256
import Control.Monad
import Control.Applicative
import Data.Functor
import Data.Monoid
import Data.Maybe
import Data.List
import Data.Foldable (foldMap)
import Data.List.Split
import Data.Char
import Data.Ratio
import Data.Ord
import Data.Array.IO

readInt = read :: String -> Int
getInt = readLn :: IO Int
getInts = map readInt . words <$> getLine
sjoin :: (Show a) => [a] -> String
sjoin = unwords . map show
cond :: a -> a -> Bool -> a
cond t f c = if c then t else f
-- end of templete

judge :: String -> Int -> Int -> ((Int, Int) -> [(Int, Int)]) -> [String] -> Maybe String
judge res w h gen field = res <$ (guard . getAny . foldMap Any . map (all hit) . map gen $ points)
  where
    points = [(x, y) | x <- [0..(8-w)], y <- [0..(8-h)]]
    hit (x, y) = field !! y !! x == '1'

ds :: [(Int, Int)] -> (Int, Int) -> [(Int, Int)]
ds ps (a, b) = [(x+a, y+b) | (x, y) <- ps]

functs = [judge "A" 2 2 $ ds [(0,0),(0,1),(1,0),(1,1)], 
          judge "B" 1 4 $ ds [(0,0),(0,1),(0,2),(0,3)],
          judge "C" 4 1 $ ds [(0,0),(1,0),(2,0),(3,0)],
          judge "D" 2 3 $ ds [(1,0),(0,1),(1,1),(0,2)],
          judge "E" 3 2 $ ds [(0,0),(1,0),(1,1),(2,1)],
          judge "F" 2 3 $ ds [(0,0),(0,1),(1,1),(1,2)],
          judge "G" 3 2 $ ds [(1,0),(2,0),(0,1),(1,1)]
          ]

main = do
    ls <- splitWhen null . lines <$> getContents
    forM_ ls $ \field -> do
        putStrLn $ fromJust $ mconcat $ map ($field) functs

Measured memory_bytes: 4184
#include <iostream>
#include <iomanip>
#include <sstream>
#include <algorithm>
#include <functional>
#include <iterator>
#include <string>
#include <bitset>
#include <queue>
#include <stack>
#include <set>
#include <map>
#include <list>
#include <vector>
#include <cmath>

typedef unsigned long long int ulli;
typedef   signed long long int slli;
const ulli MAX_ULLI = 0xFFFFFFFFFFFFFFFF;
const ulli MIN_ULLI = 0x0000000000000000;
const slli MAX_SLLI = 0x7FFFFFFFFFFFFFFF;
const slli MIN_SLLI = 0x8000000000000000;
const ulli MOD = 1e9 + 7;

#ifdef __USE_REAL__
typedef long double real;
const real MATH_PI =  3.141592653589793238462643383279502884197169399375105820974944;
const real MATH_E  =  2.718281828459045235360287471352662497757247093699959574966967;
const real eps = 1e-14;
#endif /* __USE_REAL__ */

#ifdef __DEBUG__
template<typename T, typename U=T>
std::string to_string(
	const std::list<T>& l, 
	std::function<U(T)> conv = [](const T& v){ return v; },
	const std::string delim = ","
)
{
	std::stringstream ss;
	auto itr = l.begin();
	while(itr != l.end())
	{
		ss << conv(*itr);
		++itr;
		if(itr != l.end()) ss << delim;
	}
	return ss.str();
}

template<typename T, typename U=T>
std::string to_string(
	const std::vector<T>& v, 
	std::function<U(T)> conv = [](const T& v){ return v; },
	const std::string delim = ","
)
{
	std::stringstream ss;
	for(ulli i=0; i<v.size(); ++i)
	{
		ss << conv(v[i]);
		if((i + 1) < v.size()) ss << delim;
	}
	return ss.str();
}
#endif

template<typename T, class InputIterator>
inline bool have(
	InputIterator first, 
	InputIterator last, 
	const T &val
)
{
	return std::find(first, last, val) != last;
}

template<class InputIterator, class UnaryPred>
inline bool have_if(
	InputIterator first, 
	InputIterator last, 
	UnaryPred pred
)
{
	return std::find_if(first, last, pred) != last;
}

std::string to_string(unsigned x)
{
	std::stringstream ss;
	ss << x;
	return ss.str();
}

bool check(unsigned P, const std::vector<unsigned> &D)
{
	//std::string S = std::to_string(P);
	std::string S = to_string(P);
	for(unsigned i=0; i<S.size(); ++i)
	{
		for(unsigned j=0; j<D.size(); ++j)
		{
			if(static_cast<unsigned>(S[i] - '0') == D[j])
			{
				return false;
			}
		}
	}
	return true;
}

int main()
{
	unsigned N, K;
	std::cin >> N >> K;
	
	std::vector<unsigned> D(K);
	for(unsigned k=0; k<K; ++k)
	{
		std::cin >> D[k];
	}
	
	for(unsigned P=N; true; ++P)
	{
		if(check(P, D))
		{
			std::cout << P << std::endl;
			break;
		}
	}
	
	return 0;
}

Measured memory_bytes: 256
#include <stdio.h>

int main(void)
{
	int h, w;
	int i, j;

	scanf("%d %d", &h, &w);

	while (h != 0 && w != 0)
	{
		for (i = 0; i < h; i++)
		{
			if (i == 0 || i == h - 1) {
				for (j = 0; j < w; j++)
				{
					printf("#");
				}
			}
			else{
				for (j = 0; j < w; j++)
				{
					if (j == 0 || j == w - 1)
						printf("#");
					else
						printf(".");
				}
			}
			printf("\n");
		}

		printf("\n");
		scanf("%d %d", &h, &w);
	}

	return 0;
}

Measured memory_bytes: 572
import numpy as np
S = input()
S = np.array([int(x) for x in S])

if len(S)%2 == 0:
  P1 = np.array([1, 0]*int(len(S)/2))
  P2 = np.array([0, 1]*int(len(S)/2))
else:
  P1 = np.array([1, 0]*int(len(S)/2) + [1])
  P2 = np.array([0, 1]*int(len(S)/2) + [0])

ans1 = np.abs(S - P1).sum()
ans2 = np.abs(S - P2).sum()

if ans1 < ans2:
  print(ans1)
else:
  print(ans2)



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

void solve(int w[], int v[], int W, int n){
	long dp[n+1][W+1];
	
	for(int i=0; i<=n; i++){
		for(int j=0; j<=W; j++){
			if(i==0 || j==0)	dp[i][j] = 0;
			else if(w[i-1] <= j )	dp[i][j] = max(dp[i-1][j] ,  v[i-1] + dp[i-1][j-w[i-1]]);
			else	dp[i][j] = dp[i-1][j];
		}
	}
	//for(int i=0; i<=n; i++)
	cout <<dp[n][W];
}

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

Measured memory_bytes: 79104
L, R = map(int, input().split())
dif = R-L+1 if R-L+1<2019 else 2019

ans = 2018
for i in range(L, L+dif):
  for j in range(i+1, L+dif):
    ans = i*j%2019 if i*j%2019 < ans else ans
print(ans)

Measured memory_bytes: 3060
#include <cstdio>
#include <cmath>
#include <cstring>
#include <cstdlib>
#include <algorithm>
#include <iostream>
using namespace std;
int a[105];
int main(){
	int i,n,ans = 0,m,b;
	scanf("%d",&n);
	memset(a,0,sizeof(a));
	for(i = 1; i <= n; i++){
		b = i;
		while(b%2 == 0){
			a[i]++;
			b = b / 2;
		}
	}
	for(i = 1; i <= n; i++){
		ans = max(a[i],ans);
	}
	for(int i = 1; i <= n; i++)
		if(a[i] == ans) m = i;
	printf("%d\n",m);
}

Measured memory_bytes: 256
#include<iostream>
#include<vector>
#include<string>
#include<algorithm>
#include<cmath>
#include<bitset>
#include<deque>
#include<functional>
#include<iterator>
#include<map>
#include<set>
#include<stack>
#include<queue>
#include<utility>
using namespace std;
typedef long long ll;
typedef pair<ll,ll> P;
#define a first
#define b second
#define sz(x) (ll)((x).size())
#define pb push_back
#define mp make_pair
#define bg begin()
#define ed end()
#define all(x) (x).bg,(x).ed
#define rep(i,n) for(ll i=0;i<(n);i++)
#define rep1(i,n) for(ll i=1;i<=(n);i++)
#define rrep(i,n) for(ll i=(n)-1;i>=0;i--)
#define rrep1(i,n) for(ll i=(n);i>=1;i--)
#define FOR(i,a,b) for(ll i=(a);i<(b);i++)
const ll MOD=1000000007;
const ll INF=1000000000000000;
template<class T> inline bool chmin(T& a, T b){if(a>b){a=b;return true;}return false;}
template<class T> inline bool chmax(T& a, T b){if(a<b){a=b;return true;}return false;}
ll maxx(ll x,ll y,ll z){return max(max(x,y),z);}
ll minn(ll x,ll y,ll z){return min(min(x,y),z);}
ll gcd(ll x,ll y){if(x%y==0) return y;else return gcd(y,x%y);}
ll lcm(ll x,ll y){return x*(y/gcd(x,y));}
ll digsz(ll x){if(x==0) return 1;else{ll ans=0;while(x){x/=10;ans++;}return ans;}}
ll digsum(ll x){ll sum=0;while(x){sum+=x%10;x/=10;}return sum;}
vector<ll> pw2(62,1);vector<ll> pw10(19,1);
ll dx[8]={0,0,-1,1,-1,1,-1,1};
ll dy[8]={1,-1,0,0,1,1,-1,-1};
vector<vector<ll> > c(10,vector<ll>(10,0));

int main(){
    {rep1(i,61) pw2[i]=2*pw2[i-1];}
    {rep1(i,18) pw10[i]=10*pw10[i-1];}
    
    ll N; cin>>N;
    string s; cin>>s;
    //  0 1 2 3 4 5  .......  sz(s)-1
    // 0 1 2 3  ........ sz(s)-1     sz(s)
    
    vector<ll> L(sz(s)+1,0); //左にある黒
    vector<ll> R(sz(s)+1,0); //右にある白
    
    rep1(i,sz(s)){
        if(s[i-1]=='#') L[i]=L[i-1]+1;
        else L[i]=L[i-1];
    }
    rrep(i,sz(s)){
        if(s[i]=='.') R[i]=R[i+1]+1;
        else R[i]=R[i+1];
    }
    
    ll ans=INF;
    //境目i
    rep(i,sz(s)+1){
        chmin(ans,L[i]+R[i]);
    }
    cout<<ans<<endl;
}


Measured memory_bytes: 6796
n, m = map(int, input().split())
students = []
for _ in range(n):
  a, b = map(int, input().split())
  students.append((a, b))

checkpoints = []
for _ in range(m):
  a, b = map(int, input().split())
  checkpoints.append((a, b))

for student in students:
  ans = (-1, float('inf'))
  for i, point in enumerate(checkpoints):
    distance = abs(student[0]-point[0]) + abs(student[1]-point[1])
    if ans[1] > distance:
      ans = (i, distance)
  print(ans[0]+1)

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

using namespace std;

int main(int argc, char* argv[])
{
  int a, b, c, d; cin >> a >> b >> c >> d;

  cout << ((abs(a-c) <= d || (abs(a-b) <= d && abs(b-c) <= d)) ? "Yes" : "No") << endl;
  
  return 0;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef pair<ll, ll> P;
#define DUMP(x) cout << #x << " = " << (x) << endl;
#define FOR(i, m, n) for (ll i = m; i < n; i++)
#define IFOR(i, m, n) for (ll i = n - 1; i >= m; i--)
#define REP(i, n) FOR(i, 0, n)
#define IREP(i, n) IFOR(i, 0, n)
#define FOREACH(x, a) for (auto&(x) : (a))
#define ALL(v) (v).begin(), (v).end()
#define SZ(x) ll(x.size())

int main() {
  ll n, k;
  cin >> n >> k;
  vector<ll> a(n);
  REP(i, n) { cin >> a[i]; }
  sort(ALL(a));
  ll ans = 0;
  REP(i, n - k) { ans += a[i]; }
  cout << ans << endl;
}

Measured memory_bytes: 1792
#pragma GCC optimize("Ofast")
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<long long, long long>;
constexpr char ln =  '\n';
constexpr long long MOD = 1000000007LL;
constexpr long long INF = 1001001001LL;
#define all(x) (x).begin(),(x).end()
#define rep(i,n) for(int i=0;i<(n);i++)
#define rept(i, j, n) for(int i=(j); i<(n); i++)
template<class T> inline bool chmax(T& a, T b) { if (a < b) { a = b; return 1; } return 0; }
template<class T> inline bool chmin(T& a, T b) { if (a > b) { a = b; return 1; } return 0; }


int main(){ 
    int n; cin >> n;
    int odd = 0, even = 0;
    rep(i, n){
      int a; cin >> a;
      if(a%2==0)even++;
      else odd++;
    }
    if(odd%2==0)cout << "YES" << ln;
    else cout << "NO" << ln;
}


Measured memory_bytes: 256
#include <bits/stdc++.h>
#define REP(i, e) for(int (i) = 0; (i) < (e); ++(i))
#define FOR(i, b, e) for(int (i) = (b); (i) < (e); ++(i))
#define ALL(c) (c).begin(), (c).end()
#define PRINT(x) cout << (x) << "\n"
using namespace std;
using ll = long long; using pint = pair<int, int>; using pll = pair<ll, ll>;
template<typename T> auto compare = [](T x, T y) -> bool{return (x < y);};
const int MOD = 1000000007;

int H, W;
int num[100][100];
unordered_map<int, int> mp[100][100];
bool dp[100][100][2 * 80 * 160];

signed main(){
    cin >> H >> W;
    int B;
    REP(i, H) REP(j, W) cin >> num[i][j];
    REP(i, H){
        REP(j, W){
            cin >> B;
            num[i][j] = abs(num[i][j] - B);
        }
    }
    dp[0][0][num[0][0]] = true;
    int ans = INT32_MAX;
    REP(i, H){
        REP(j, W){
            if(i < H - 1){
                REP(k, 80 * 160 + 1){
                    dp[i + 1][j][abs(k - num[i + 1][j])] |= dp[i][j][k];
                    dp[i + 1][j][k + num[i + 1][j]] |= dp[i][j][k];
                }
            }
            if(j < W - 1){
                REP(k, 80 * 160 + 1){
                    dp[i][j + 1][abs(k - num[i][j + 1])] |= dp[i][j][k];
                    dp[i][j + 1][k + num[i][j + 1]] |= dp[i][j][k];
                }
            }
        }
    }
    REP(k, 2 * 80 * 160 + 1){
        if(dp[H - 1][W - 1][k]){
            PRINT(k);
            return 0;
        }
    }
    return 0;
}

Measured memory_bytes: 112936
import java.util.*;
public class Main {
	public static void main(String[] args){
		Scanner sc = new Scanner(System.in);
		// 整数の入力
		int n = sc.nextInt();
		int k = sc.nextInt();
		if(n%k == 0){
			System.out.println(0);
		}else{
		System.out.println(1); 
		}
	}
}

Measured memory_bytes: 23764
#include <bits/stdc++.h>
#include <iostream>
#include<map>
#include <algorithm>
#include <vector>
using namespace std;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)

int main() {
    string s;
    cin >> s;
    for (int i = 0; i < s.size(); i++)
    {
        s[i]  = 'x';
    }
  cout << s << endl;
}

Measured memory_bytes: 256
#include <bits/stdc++.h>
#define ll long long int
#define REP(i,n) for(ll i=0;i<n;i++)
#define SZ(v) (ll)v.size()
#define endl "\n"
#define ff first
#define ss second
using namespace std;
#include <ext/pb_ds/assoc_container.hpp>
#include <ext/pb_ds/tree_policy.hpp>
using namespace __gnu_pbds;
#define pbds tree<int, null_type,less<int>, rb_tree_tag,tree_order_statistics_node_update>
const ll INF=1e29;
const ll MOD=1000000007;
const ll nxm=2e7+5;
bool c(pair<ll,ll> a,pair<ll,ll> b)
{
return a.ff<b.ff;
}
void solve()
{
ll n;
cin>>n;
ll cnt=0;
while(n%2==0)
{
    n/=2;
    cnt++;
}
ll res=0;
ll prev=0;
for(ll k=1;;k++)
{
    prev+=k;
    if(prev>cnt)
        break;
    res++;
}
for(ll i=3;i<=sqrt(n);i++)
{
    cnt=0;
    while(n%i==0)
    {
        cnt++;
        n/=i;
    }

ll prev=0;

for(ll k=1;;k++)
{
    prev+=k;
    if(prev>cnt)
        break;
    res++;
}



}


if(n>2)
    res++;



cout<<res;

}
int main(){
//    freopen("input.txt", "r", stdin);
//    freopen("output.txt", "w", stdout);
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	cout.tie(0);
	ll t=1;
//	cin>>t;
	while(t--){
		solve();
	}


	return 0;
}


Measured memory_bytes: 3700
import math
N, M = tuple(map(int, input().split()))
if N == M:
    print(2 * math.factorial(N) * math.factorial(M) % (10**9 + 7))
    exit()

if abs(N - M) == 1:
    print(math.factorial(N) * math.factorial(M) % (10**9 + 7))
else:
    print(0)

Measured memory_bytes: 5192
#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;
using namespace std;

int main(){
  int N;
  cin >> N;
  int V[N], C[N];
  for(int i=0;i<N;i++) cin >> V[i];
  for(int i=0;i<N;i++) cin >> C[i];

  ll ans = 0LL;
  for(int i=0;i<N;i++){
    if(V[i] >= C[i]){
      ans += V[i] - C[i];
    }
  }

  cout << ans << endl;
  return 0;

}


Measured memory_bytes: 256
import itertools

n, k = [int(i) for i in input().split()]
v = [int(i) for i in input().split()]
v2 = list(reversed(v))

answer = 0
for i in range(k+1):
    for j in range(k-i+1):
        for l in range(k-i-j+1):
            if i + j >= n:
                持っている宝石 = v[:]
            else:
                持っている宝石 = v[:i] + v2[:j]
            持っている宝石.sort()
            価値の合計 = sum(持っている宝石)

            for o in range(l):
                if o < len(持っている宝石):
                    if 持っている宝石[o] < 0:
                        価値の合計 -= 持っている宝石[o]
            answer = max(answer, 価値の合計)

print(answer)

Measured memory_bytes: 3064
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <vector>
#include <stack>
#include <queue>
#include <deque>
#include <set>
#include <map>
#include <cstdio>
#include <cmath>
#include <tuple>
#include <iomanip>
#include <numeric>
#include <unordered_map>
#include <sstream>
#include<limits.h>
#include<float.h>
#include<list>
#include <array>
#include <complex>
#include<stdio.h>
#include<string.h>
#include <bitset>
#include<assert.h>
#include<random>
using namespace std;
#define int long long

#define I32_MAX 2147483647
#define I64_MAX 9223372036854775807LL
#define I64_MAX2 1223372036854775807LL
#define INF I64_MAX2
#define MOD 1000000007
// #define MOD 998244353 
#define MEM_SIZE 10000
#define DEBUG_OUT true
#define ALL(x) (x).begin(), (x).end()

template<typename T> void DEBUG(T e){if(DEBUG_OUT == false)return; std::cout << e <<" ";}
template<typename T> void DEBUG(const std::vector<T>& v){if(DEBUG_OUT == false)return;for(const auto& e : v){std::cout<< e << " "; } std::cout << std::endl;}
template<typename T> void DEBUG(const std::vector<std::vector<T> >& vv){if(DEBUG_OUT == false)return;for(const auto& v : vv){ DEBUG(v); } }
template<class T,class... Ts> void DEBUG(T d, Ts... e){if(DEBUG_OUT == false)return;DEBUG(d);DEBUG(e...);}
template <class T> void corner(bool flg, T hoge) {if (flg) {cout << hoge << endl; abort();}}
template< typename T1, typename T2 > inline bool chmax(T1 &a, T2 b) { return a < b && (a = b, true); }
template< typename T1, typename T2 > inline bool chmin(T1 &a, T2 b) { return a > b && (a = b, true); }


//BELOW
//-----CODE------//

void solve(void)
{
  int K,S;
  cin>>K>>S;
  int res = 0;
  for (size_t i = 0; i < K+1; i++)
  {
    for (int j = 0; j < K + 1; j++)
    {
      int Q = S - i -j;
      if(0 <= Q && Q <= K)
      {
        res++;
      }
    }
    
  }
  cout<<res<<endl;
  

  return;
}
int32_t main(int32_t argc, const char *argv[])
{
  std::ios::sync_with_stdio(false);
  std::cin.tie(0);

  std::cout << std::fixed;
  std::cout << std::setprecision(11);
  solve();

  return 0;
}


Measured memory_bytes: 3604
#include "bits/stdc++.h"
using namespace std;
typedef long long ll;
typedef pair<int, int> pii;
typedef pair<ll, ll> pll;
const int INF = 1e9;
const ll LINF = 1e18;
template<class S,class T> ostream& operator << (ostream& out,const pair<S,T>& o){ out << "(" << o.first << "," << o.second << ")"; return out; }
template<class T> ostream& operator << (ostream& out,const vector<T> V){ for(int i = 0; i < V.size(); i++){ out << V[i]; if(i!=V.size()-1) out << " ";} return out; }
template<class T> ostream& operator << (ostream& out,const vector<vector<T> > Mat){ for(int i = 0; i < Mat.size(); i++) { if(i != 0) out << endl; out << Mat[i];} return out; }
template<class S,class T> ostream& operator << (ostream& out,const map<S,T> mp){ out << "{ "; for(auto it = mp.begin(); it != mp.end(); it++){ out << it->first << ":" << it->second; if(mp.size()-1 != distance(mp.begin(),it)) out << ", "; } out << " }"; return out; }

/*
 <url:https://beta.atcoder.jp/contests/arc098/tasks/arc098_a>
 問題文============================================================
 =================================================================
 解説=============================================================
 ================================================================
 */
ll solve(){
    ll res = LINF;
    ll N; cin >> N;
    string S; cin >> S;
    vector<vector<ll>> cusum(2,vector<ll>(S.length()+2));
    for(int i = 0; i < S.length();i++){
        cusum[0][i+1] = cusum[0][i] + (S[i]=='W');
        cusum[1][i+1] = cusum[1][i] + (S[i]=='E');
    }
    cusum[0][S.length()+1] = cusum[0][S.length()];
    cusum[1][S.length()+1] = cusum[1][S.length()];
    for(int i = 0; i < S.length();i++){
        res = min(res,cusum[0][i]+(cusum[1][S.length()+1]-cusum[1][i+1]));
    }
    return res;
}
int main(void) {
    cin.tie(0); ios_base::sync_with_stdio(false);
    cout << solve() << endl;
    return 0;
}


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

int N, C;
int cnt[100005][33] = {};
int main()
{

    cin >> N >> C;
    for ( int i = 0; i < N; i++ ) {
        int s, t, c;
        cin >> s >> t >> c; --c;
        cnt[s][c]++;
        cnt[t + 1][c]--;
    }

    int maxv = 0;
    for ( int i = 1; i <= 100000; i++ ) {
        int cn = 0;
        for ( int j = 0; j < C; j++ ) {
            cnt[i][j] += cnt[i - 1][j];
            if ( cnt[i][j] > 0 ) {
                cn++;
            }
        }
        maxv = max(maxv, cn);
    }

    cout << maxv << endl;

    return ( 0 );
}


Measured memory_bytes: 13184
#include<stdio.h>

int main(){
		int n,A,B,a=0,b=0,i,c=0;
		char s[100001];
		scanf("%d%d%d%s",&n,&A,&B,s);
		for(i=0;i<n;i++){
				if(s[i]=='c')puts("No");
				else {
						if(s[i]=='a'){
								if(a+b<A+B){
										a++;
										puts("Yes");
								}
								else puts("No");
						}
						if(s[i]=='b'){
								if(a+b<A+B&&b<B){
										puts("Yes");
										b++;
								}
								else puts("No");
						}
				}
		}
		return 0;
}


Measured memory_bytes: 640
import std.string;
import std.stdio;
import std.algorithm;
import std.conv;
import std.typecons;

void main() {
	long[Tuple!(immutable(char), size_t)] dp;
	long[char] checks;
	auto s = readln.chomp;
	auto t = readln.chomp;
	foreach(c; s) {
		checks[c] = 0;
	}
	bool check = true;
	foreach(c; t) {
		if (c !in checks) {
			check = false;
		}
	}
	if (check) {
		size_t i;
		foreach(c; t) {
			auto key = tuple(c, i%s.length);
			if (key in dp) {
				i += dp[key];
			}
			else {
				size_t j;
				for(;j < s.length; ++j) {
					auto p = (i + j) % s.length;
					if (s[p] == c) break;
				}
				i += j+1;
				dp[key] = j+1;
			}
		}
		write(i);
	}
	else {
		write(-1);
	}
}


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

template <typename InputIterator>
typename InputIterator::value_type summation(InputIterator first,
                                             InputIterator last) {
  return std::accumulate(first, last, typename InputIterator::value_type());
}
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v);
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p);
template <typename T>
std::istream &operator>>(std::istream &stream, std::vector<T> &v) {
  for (auto &i : v) {
    stream >> i;
  }
  return stream;
}
template <typename T1, typename T2>
std::istream &operator>>(std::istream &stream, std::pair<T1, T2> &p) {
  stream >> p.first >> p.second;
  return stream;
}

int main() {
  int64_t h, w;
  std::cin >> h >> w;
  std::vector<std::string> s(h);
  std::cin >> s;
  std::vector<std::vector<int64_t>> yoko(h, std::vector<int64_t>(w, 0)),
      tate(h, std::vector<int64_t>(w, 0));

  for (int64_t i = 0; i < h; i++) {
    int64_t j = 0;
    while (j != w) {
      while (j < w && s[i][j] == '#') {
        j++;
      }
      if (j == w) {
        continue;
      }
      int64_t k = j;
      while (k < w && s[i][k] == '.') {
        k++;
      }
      for (int64_t p = j; p < k; p++) {
        yoko[i][p] = k - j;
      }
      j = k;
    }
  }

  for (int64_t i = 0; i < w; i++) {
    int64_t j = 0;
    while (j != h) {
      while (j < h && s[j][i] == '#') {
        j++;
      }
      if (j == h) {
        continue;
      }
      int64_t k = j;
      while (k < h && s[k][i] == '.') {
        k++;
      }
      for (int64_t p = j; p < k; p++) {
        tate[p][i] = k - j;
      }
      j = k;
    }
  }
  int64_t ans = 1;

  for (int64_t i = 0; i < h; i++) {
    for (int64_t j = 0; j < w; j++) {
      ans = std::max(ans, yoko[i][j] + tate[i][j] - 1);
    }
  }
  std::cout << ans << std::endl;
  return 0;
}

Measured memory_bytes: 69120
#include <bits/stdc++.h> 
using namespace std;
typedef long long ll;
int main(void){
    // Your code here!
    int N,Z,W;
    cin >> N >> Z >> W;
    vector<int> a(N);
    for(int i = 0; i < N; i++) cin >> a.at(i);
    
    int ans = 0;
    if(N == 1){
        ans = abs(a.at(N-1) - W);
    }else{
        ans = max(abs(a.at(N-1) - a.at(N-2)), abs(a.at(N-1)-W)); 
    }
    cout << ans << endl;
    
}


Measured memory_bytes: 256
#include <stdio.h>
char str[100];
int n,j;
char temp;
int main()
{
	scanf("%d %d",&n,&j);
	scanf("%c",&temp);
	scanf("%[^\n]",str);
	str[j-1]=str[j-1]+32;
	printf("%s",str);
	return 0;
}

Measured memory_bytes: 128
#include <bits/stdc++.h>
using namespace std;
#define ll long long 
#define endl "\n"
#define pb push_back
#define f(i,n) for(i=0;i<n;i++)
#define F(i,a,b) for(i=a;a<=b;i++)
#define arr(a,n) for( i=0;i<n;i++)cin>>a[i];
#define fi first
#define se second
#define mp make_pair
#define mod 1000000007
#define YES cout<<"YES"<<endl;
#define Yes cout<<"Yes"<<endl;
#define NO cout<<"NO"<<endl;
#define No cout<<"No"<<endl;
#define yes cout<<"yes"<<endl;
#define no cout<<"no"<<endl;
#define vi vector<ll>
#define ed end()
#define bg begin()
#define sz size()
#define ln length()
#define s() sort(a,a+n);
#define sr() sort(a,a+n,greater<ll>());
#define v()  sort(v.begin(),v.end());
#define vr() sort(v.begin(),v.end(),greater<ll>());
#define mod 1000000007
#define fast() ios_base::sync_with_stdio(0); cin.tie(0); cout.tie(0)

int main() {
    /*#ifndef ONLINE_JUDGE
      // for getting input from input.txt
      freopen("input.txt", "r", stdin);
      // for writing output to output.txt
      freopen("output.txt", "w", stdout);
  #endif*/
fast();
  ll n,c=0;
  cin>>n;
  if(n==1)
    c=1;
  for(int i=2;i<=9;i++)
  {
    if(n%i==0&&n/i<=9) 
      c=1;
  }
if(c==0)
  No
else
  Yes

return 0;
}

Measured memory_bytes: 256
N = int(input())
data = []

for _ in range(N):
	item = input().strip().split()
	data.append((item[0], int(item[1])))

X = input().strip()

i = 0
while X != data[i][0]:
	i += 1

i += 1
time = 0
while i < N:
	time += data[i][1]
	i += 1

print(time)


Measured memory_bytes: 3316
#include <stdio.h>
int main(){
	int a,b,c;
	scanf("%d ",&a);
	scanf("%d ",&b);
	scanf("%d ",&c);
	if(a==5&&b==5){
		if(c==7){
		printf("YES");
		}else {
		printf("NO");
		}
	}else if(a==5&&b==7){
		if(c==5){
		printf("YES");
		}else{
		printf("NO");
		}
	}else if(a==7&&b==5){
		if(c==5){
		printf("YES");
		}else{
		printf("NO");
		}
	}else{
		printf("NO");
	}
	
}

Measured memory_bytes: 128
# -*- coding: utf-8 -*-
import numpy as np
import sys
from collections import deque
from collections import defaultdict
import heapq
import collections
import itertools
import bisect
from scipy.special import comb
import copy
sys.setrecursionlimit(10**6)

# lis_of_lis = [[] for _ in range(N)]


def zz():
    return list(map(int, sys.stdin.readline().split()))


def z():
    return int(sys.stdin.readline())


def S():
    return sys.stdin.readline()[:-1]


def C(line):
    return [sys.stdin.readline() for _ in range(line)]


N, X, T = zz()

tmp = N//X
if (N % X == 0):
    print(tmp*T)
else:
    print((tmp+1)*T)


Measured memory_bytes: 42308
A = list(map(int, input().split()))
L = len(A)
ans = [0, 0, 0, 0]
dx = A[2] - A[0]
dy = A[3] - A[1]
if(dx>=0 and dy>=0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] - dy
    y3 = A[3] + dx
    x4 = x3 - dx
    y4 = y3 - dy
elif(dx>0 and dy<0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] + dy
    y3 = A[3] + dx
    x4 = x3 - dx
    y4 = y3 + dy
elif(dx<=0 and dy<=0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] + dy
    y3 = A[3] - dx
    x4 = x3 + dx
    y4 = y3 + dy
elif(dx<0 and dy>0):
    dx = abs(dx)
    dy = abs(dy)
    x3 = A[2] - dy
    y3 = A[3] - dx
    x4 = x3 + dx
    y4 = y3 - dy

ans[0] = str(x3)
ans[1] = str(y3)
ans[2] = str(x4)
ans[3] = str(y4)
ans = ' '.join(ans)
print(ans)

Measured memory_bytes: 3064
#pragma GCC optimize("03")
#include <bits/stdc++.h>

using namespace std;

int n, k, a[105], dp[100005];

int main()
{
	cin.tie(NULL);
	ios_base::sync_with_stdio(false);
	
	cin >> n >> k;
	for (int i = 1; i <= n; ++i)
		cin >> a[i];
		
	for (int i = 0; i <= k; ++i)
	{
		if (dp[i] == 0)
			for (int j = 1; j <= n; ++j)
				if (i + a[j] <= k)
					dp[i + a[j]] = 1; 
	}
	
	cout << (dp[k] ? "First\n" : "Second\n");
	
	return 0;
}


Measured memory_bytes: 640
import java.io.OutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.PrintWriter;
import java.util.Arrays;
import java.util.Scanner;
import java.util.ArrayList;

/**
 * Built using CHelper plug-in
 * Actual solution is at the top
 *
 * @author silviase
 */
public class Main {
    public static void main(String[] args) {
        InputStream inputStream = System.in;
        OutputStream outputStream = System.out;
        Scanner in = new Scanner(inputStream);
        PrintWriter out = new PrintWriter(outputStream);
        GLongestPath solver = new GLongestPath();
        solver.solve(1, in, out);
        out.close();
    }

    static class GLongestPath {
        Graph g = new Graph(100000);
        int[] p = new int[100000];

        public void solve(int testNumber, Scanner in, PrintWriter out) {
            int n = in.nextInt();
            int m = in.nextInt();
            for (int i = 0; i < m; i++) {
                int x = in.nextInt() - 1;
                int y = in.nextInt() - 1;
                g.addEdge(new Edge(x, y, 0));
            }
            int max = 0;
            Arrays.fill(p, -1);
            for (int i = 0; i < n; i++) {
                // out.println(f(i));
                max = Math.max(max, f(i));
            }
            out.println(max);
        }

        int f(int index) {
            if (p[index] != -1) {
                return p[index];
            }
            p[index] = 0;
            ArrayList<Edge> adj = g.getAdj()[index];

            for (Edge e : adj) {
                int to = e.to;
                p[index] = Math.max(p[index], f(to));
            }

            if (adj.size() != 0) {
                p[index] += 1;
            }
            return p[index];
        }

    }

    static class Edge {
        public int from;
        public int to;
        public long cost;

        public Edge(int to) {
            this.to = to;
        }

        public Edge(int to, long cost) {
            this.to = to;
            this.cost = cost;
        }

        public Edge(int from, int to, long cost) {
            this.from = from;
            this.to = to;
            this.cost = cost;
        }

        public String toString() {
            return "Edge{" +
                    "from=" + from +
                    ", to=" + to +
                    ", cost=" + cost +
                    '}';
        }

    }

    static class Graph {
        int n;
        ArrayList<Edge>[] adj;
        int[] inDeg;
        long[] vertexCost;

        public Graph(int size) {
            n = size;
            adj = new ArrayList[n];
            inDeg = new int[n];
            for (int i = 0; i < n; i++) {
                adj[i] = new ArrayList<>();
            }
            vertexCost = new long[n];
        }

        public void addEdge(Edge e) {
            adj[e.from].add(e);
            inDeg[e.to]++;
        }

        public ArrayList<Edge>[] getAdj() {
            return adj;
        }

    }
}



Measured memory_bytes: 113088
#include "bits/stdc++.h"
using namespace std;

#define FOR(i, a, b) for (int i = (a); i < (b); ++i)
#define REP0(i, n) for (int i = 0, i##_len = (n); i < i##_len; ++i)
#define REP1(i, n) for (int i = 1, i##_len = (n); i <= i##_len; ++i)

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

const int INTINF = 1e9;
const LL LLINF   = 1e18;
#define TENS(n) int(1e##n + n)

// [i, j) における最適値
LL dp[402][402];
LL cum[402];
bool flg[402][402];

LL rec(int l, int r)
{
    if (abs(l - r) == 1 or flg[l][r])
        return dp[l][r];

    flg[l][r] = true;

    LL ans = LLINF;
    for (int i = l + 1; i < r; i++)
    {
        ans = min(ans, rec(l, i) + rec(i, r));
    }
    ans += cum[r - 1] - cum[l - 1];
    return dp[l][r] = ans;
}

void solve()
{
    int N;
    cin >> N;
    REP0 (i, N)
    {
        cin >> cum[i];
        if (i)
            cum[i] += cum[i - 1];
    }

    cout << rec(0, N) << endl;
}

int main(int argc, char const *argv[])
{
    cin.tie(0);
    ios::sync_with_stdio(false);
    std::cout << std::fixed << std::setprecision(10);
    solve();
    return 0;
}

Measured memory_bytes: 1664
import java.util.Scanner;

public class Main {

	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt();
		sc.nextLine();
		int[] a = new int[n];
		int oddOfSum = 0;
		for (int i=0;i<n;i++){
			a[i] = sc.nextInt();
			if (a[i]%2==1){
				oddOfSum++;
			}
		}
		if (oddOfSum%2==1){
			System.out.println("NO");
		}
		else{
			System.out.println("YES");
		}
		
	}
}


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

using namespace std;

int c[15][1010];

int main() {
  int h, w, k;
  cin >> h >> w >> k;
  
 string s[15];
  bool booling1 = true;
  bool booling2 = true;
  
for(int i=0;i<h;i++){
  cin >> s[i];
}
  int ans = 10000000;
  
  for(int bit=0;bit<(1<<(h-1));bit++) {
  bool booling1 = true;
  bool booling2 = true;
    int res = 0;
    int a[15];
    for(int i=0;i<h;i++) {
      a[i] = res;
    if (bit&(1<<i)) res++;
    }
    res;
    
    for(int i=0;i<=res;i++){
      for(int j=0;j<w;j++){
        c[i][j] = 0;
      }
    }
    
    for(int i=0;i<h;i++){
      for(int j=0;j<w;j++){
       if(s[i][j] == '1') c[a[i]][j]++;
      }
    }
    
    int now[15];
    
    for(int i=0;i<=res;i++){
      now[i] = 0;
    }
    
    int temp = res;
    for(int j=0;j<w;j++){
      for(int i=0;i<=res;i++){
        
        now[i] += c[i][j];
        
        if(now[i] > k){
          booling2 = false;
        }
      }
      
        if(!(booling2)){
          temp++;
          
          for(int i=0;i<=res;i++){
          now[i]=0;
          }
          
          for(int i=0;i<=res;i++){
            
          if(c[i][j] > k){
            booling1 = false;
            break;
          }
          }
          booling2 = true;
         j--;
        }
      if(!booling1){
        break;
      }
    }
    
      if(!booling1){
        ans = 100000000;
        continue;
      }
     
    
    ans = min(ans, temp);
  }
  
  cout << ans << endl;
}


Measured memory_bytes: 256
n = gets.to_i
p = gets.split(" ").map(&:to_i)

loop_count = n - 2
count = 0

(1..loop_count).each do |i|
    if p[i] >= p[i-1] and p[i+1] > p[i]
        count = count + 1
    elsif p[i] >= p[i+1] and p[i-1] > p[i]
        count = count + 1
    end
end

puts count


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

// syntax sugar: `for (int i = 0; i < N; ++i)`
#define rep(i, N) for (int i = 0; i < (int)(N); ++i)
// syntax sugar: `for (int i = 0; i < N; ++i)`
#define REP(type, name, beginValue, endCondValue) \
  for (type name = beginValue; name < endCondValue; ++name)
// syntax sugar: 多次元vector
#define VECTOR_DIM3(T, name, d1, d2, d3, initValue) \
    std::vector<std::vector<std::vector<T>>> name(d1, std::vector<std::vector<T>>(d2, std::vector<int>(d3, initValue)));
#define VECTOR_DIM2(T, name, d1, d2, initValue) \
    std::vector<std::vector<T>> name(d1, std::vector<T>(d2, initValue));
#define VECTOR_DIM1(T, name, d1, initValue) \
    std::vector<T> name(d1, initValue);
#define ll long long
#define ld long double


// ABC073C - Write and Erase
int main(){
  int N, a; // 1 <= N <= 1e5
  cin >> N;
  map<int, int> anum;
  rep(i, N) {
    cin >> a;
    anum[a]++;
  }
  int num = 0;
  for (const auto& pair : anum) {
    if (pair.second % 2 == 1) {
      ++num;
    }
  }

  cout << num << endl;
  return 0;
}



Measured memory_bytes: 4864
p,M,f=pow,1000003,[1]
for i in range(1,M):f.append(f[i-1]*i%M)
for _ in'_'*input():x,d,n=map(int,raw_input().split());t=x*p(d,M-2,M)%M;print[p(x,n,M),M/(t+n)*t and f[t+n-1]*p(f[t-1],M-2,M)*p(d,n,M)%M][d>0]

Measured memory_bytes: 108908
using System;

namespace _0368
{
    class Program
    {
        static void Main(string[] args)
        {
            string[] s = Console.ReadLine().Split();
            int tate = int.Parse(s[1]); int yoko = int.Parse(s[0]);
            Console.Write("+"); for (int i = 1; i < yoko - 1; i++) Console.Write("-"); Console.WriteLine("+");
            for (int i = 1; i < tate - 1; i++)
            {
                Console.Write("|");
                for (int j = 1; j < yoko - 1; j++)
                {
                    Console.Write(i * 2 + 1 == tate && j * 2 + 1 == yoko ? s[2] : ".");
                }
                Console.WriteLine("|");
            }
            Console.Write("+"); for (int i = 1; i < yoko - 1; i++) Console.Write("-"); Console.WriteLine("+");
        }
    }
}


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

int main(){
  ll x,k,d;
  std::cin >> x>>k>>d;

  x=abs(x);

  ll cnt=0;
  cnt=x/d;

  ll ans=0;

  if(cnt<=k){
    // std::cout << "a" << '\n';
    ll rest=k-cnt;
    if(rest%2==0)ans=x-cnt*d;
    else ans=abs(x-cnt*d-d);
  }else{
    // std::cout << "b" << '\n';
    x-=k*d;
    ans=x;
  }

  std::cout << abs(ans) << '\n';



  return 0;
}


Measured memory_bytes: 3576
#include <bits/stdc++.h>
using namespace std;
typedef long long ll;
#define rep(i, srt, end) for (long long i = (srt); i < (long long)(end); i++)

int main(){
    ll a, b, n;
    cin >> a >> b >> n;
    
    if(n < b-1){
        ll l = (a * n) / b;
        ll r = a * (ll)(n / b);
        //cerr << l << " " << r << endl; 
        cout << l - r << endl;
    }else{
        ll l = (a * (b-1)) / b;
        ll r = a * (ll)((b-1) / b);
        //cerr << l << " " << r << endl; 
        cout << l - r << endl;
    }
    return 0;
}

Measured memory_bytes: 3636
x,k,d  = map(int,input().split())

passSinaiCount = abs(x)//d

if passSinaiCount >= k:
    print(abs(x) - k*d)
    exit()

passSinaiDistance = abs(x) - passSinaiCount * d
passSuruDistance = d - passSinaiDistance

nokoriCount = k - passSinaiCount
if nokoriCount % 2 == 0:
    print(passSinaiDistance)
else:
    print(passSuruDistance)

Measured memory_bytes: 9204
#include <vector>
#include <iostream>
#include <string>
#include <algorithm>
#include <functional>
#include <cmath>

#define rep(i, n) for (int i = 0; i < (n); i++)
using namespace std;
typedef long long ll;
const int INF = 1e9;

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

	vector<vector<int> > vec(M);

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

	vector<int> p(M);
	for (int i = 0; i < M; ++i) cin >> p[i];

	int ans = 0;
	for (int i = 0; i < (1 << N); ++i) {
		bool ok = true;
		for (int j = 0; j < M; ++j) {
			int c = 0;
			for (int id : vec[j]) {
				if ((i >> id) & 1) {
					++c;
				}
			}
			c %= 2;
			if (c != p[j]) {
				ok = false;
			}
		}
		if (ok) {
			++ans;
		}
	}

	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
#include<bits/stdc++.h>
#define endl '\n'
using namespace std;

int main(){
    ios::sync_with_stdio(false);
    cin.tie(0);
    long long n,m,count=0;
    cin>>n>>m;
    double a[n],temp=0;
    for(int i=0; i<n; i++){
        cin>>a[i];
        temp+=a[i];
    }
    double aa=(temp/(4*m));
    for(int i=0; i<n; i++){
        if(a[i] >=(double)aa) count++;
    }
    if(count >= m) cout<<"Yes";
    else cout<<"No";
}


Measured memory_bytes: 256
#include<iostream>

using namespace std;

int main(void){
	
	int yama[50],temp[50],cut,n,p,c;

	while(cin>>n>>cut,n){
		for(int i=0;i<50;i++){
			yama[i]=0;
			temp[i]=0;
		}
		for(int j=0;j<n;j++){
			yama[j]=n-j;
		}
		for(int i=0;i<cut;i++){
			
			cin>>p>>c;
			
			for(int i=0;i<p-1;i++){
				temp[i]=yama[i];
			}
			for(int i=0;i<c;i++){
				yama[i]=yama[(p-1)+i];
			}
			for(int i=0;i<p-1;i++){
				yama[c+i]=temp[i];
			}
		}
		cout<<yama[0]<<endl;
	}
}

Measured memory_bytes: 0
#include <bits/stdc++.h>
#define mset(a, b) memset(a, b, sizeof(a))
#define mpcy(a, b) memcpy(a, b, sizeof(a))
#define rg register
using namespace std;
typedef long long LL;
const int MAXN = 100005;

template <typename T> inline void read(T &AKNOI) {
    T x = 0, flag = 1;
    char ch = getchar();
    while (!isdigit(ch)) {
        if (ch == '-') flag = -1;
        ch = getchar();
    }
    while (isdigit(ch)) {
        x = x * 10 + ch - '0';
        ch = getchar();
    }
    AKNOI = flag * x;
}

template <typename T> inline void cmin(T &x, T y) {
    if (x > y) x = y;
}

template <typename T> inline void cmax(T &x, T y) {
    if (x < y) x = y;
}

int n, a[MAXN];

void output(int win) {
	puts(win? "First" : "Second");
	exit(0);
}

int gcd(int x, int y) {
	return (y == 0)? x : gcd(y, x % y);
}

void play(int player) {
	int even = 0;
	for (int i=1;i<=n;++i) {
		even += !(a[i] & 1);
	}
	if (even & 1) output(1 ^ player);
	if (n - even > 1) output(0 ^ player);
	int d = 0;
	for (int i=1;i<=n;++i) {
		if (a[i] == 1) output(0 ^ player);
		d = gcd(d, a[i] - (a[i] & 1));
	}
	for (int i=1;i<=n;++i) {
		a[i] /= d;
	}
	play(player ^ 1);
}

void solve() {
	read(n);
	for (int i=1;i<=n;++i) {
		read(a[i]);
	}
	play(0);
}

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


Measured memory_bytes: 640
N, M, C = list(map(int, input().split()))
B = list(map(int, input().split()))
A = [list(map(int, input().split())) for _ in range(N)]
kai = 0
for i in range(N):
  ans = 0
  for j in range(M):
    ans += A[i][j]*B[j]
  ans += C
  if ans > 0:
    kai += 1
print(kai)
    

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

iiart = lambda x,y,z: "YES" if (z**2 == x**2+y**2) else "NO"

if __name__ == "__main__":
    for i in range(int(raw_input())):
        print "%s" % (iiart(*sorted([int(x) for x in raw_input().split()])))

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

using namespace std;

int ten(int n){
    int ret=1;
    for (int i = 0; i < n; ++i) {
        ret*=10;
    }
    return ret;
}

int main(){
    string n;
    cin>>n;
    if(n.size()==1){
        cout<<n[0]-'0'<<endl;
        return 0;
    }
    int ans=0;
    int m=n.size();
    if(n.size()%2==1){
        ans+=stoi(n);
        string t(m-1,'9');
        ans-=stoi(t);
        --m;
    }

    while(m>0){
        if(m%2==1)ans+=9*ten(m-1);
        --m;
    }
    cout<<ans<<endl;
    return 0;
}

Measured memory_bytes: 256