akhauriyash/Code-Regression huggingface dataset:
#include <stdio.h>
#include <stdlib.h>
#include <assert.h>
#include <fstream>
#include <iostream>
#include <sstream>
#include <iomanip>
#include <algorithm>
#include <bitset>
#include <array>
#include <vector>
#include <queue>
#include <set>
#include <cmath> // 変数名にy1が使えなくなるかも…。
#include <map>
#include <unordered_map>
#include <unordered_set>
#include <limits>
#include <functional>
#include <string>

typedef __int128_t int128_t;
std::istream &operator>>(std::istream& input, int128_t& value) { // int128_tの入力。入力が64bitに収まる前提。
    long long tmp; input >> tmp; value = tmp;
    return input;
}
std::ostream &operator<<(std::ostream& output, const int128_t value) { // int128_tの出力。出力が64bitに収まる前提。
    output << (long long)value;
    return output;
}

#define rep(i, begin, end) for(int64_t i = (begin); i <= (end); i++)
#define rev(i, begin, end) for(int64_t i = (begin); (end) <= i; i--)

void printvec(const std::vector<int>& vec) {
    for (int i = 0; i < vec.size(); i++) { std::cout << vec[i] << " "; } std::cout << std::endl;
}

int128_t S;
int MAX = 1e9;

int main(int argc, char **argv) {
    std::cin >> S;

    int128_t x1, x2, y1, y2;

    if (S < MAX) {
        x1 = S + 1;
        y2 = 1;
        x2 = 1;
        y1 = 1;
        //std::cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << 0 << " " << 0 << std::endl;
    } else {
        x1 = MAX;
        if (S % MAX == 0) {
            y2 = S / x1;
        } else {
            y2 = S / x1 + 1;
        }

        int128_t tmp = x1 * y2 - S;
        if (tmp == 0) {
            x2 = 0;
            y1 = 0;
        } else {
            x2 = tmp;
            y1 = 1;
        }

        /*
        if (S % MAX == 0) {
            x1 = MAX - 1;
        } else {
            x1 = MAX;
        }
        assert(S % x1 != 0);

        y2 = S / x1 + 1;

        int128_t tmp = x1 * y2 - S;
        assert(0 < tmp);
        assert(tmp <= MAX);

        x2 = tmp;
        y1 = 1;
        */
    }
    std::cout << x1 << " " << y1 << " " << x2 << " " << y2 << " " << 0 << " " << 0 << std::endl;
    

    return 0;
}

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

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

#define p_ary(ary,a,b) do { cout << "["; for (int count = (a);count < (b);++count) cout << ary[count] << ((b)-1 == count ? "" : ", "); cout << "]\n"; } while(0)
#define p_map(map,it) do {cout << "{";for (auto (it) = map.begin();;++(it)) {if ((it) == map.end()) {cout << "}\n";break;}else cout << "" << (it)->first << "=>" << (it)->second << ", ";}}while(0)

template<typename T1,typename T2>ostream& operator<<(ostream& os,const pair<T1,T2>& a) {os << "(" << a.first << ", " << a.second << ")";return os;}

const char newl = '\n';

int main() {
    int n,m,k;
    cin >> n >> m >> k;
    vector<ll> a(n),b(m),sums(m+1,0);
    for (int i = 0;i < n;++i) cin >> a[i];
    for (int i = 0;i < m;++i) cin >> b[i];
    for (int i = 0;i < m;++i) sums[i+1] = sums[i]+b[i];
    int ans = 0;
    ll sum = 0;
    for (int i = 0;i < n+1;++i) {
        int j = upper_bound(sums.begin(),sums.end(),k-sum)-sums.begin();
        ans  = max(ans,i+j-1);
        sum += a[i];
        if (sum > k) break;
    }
    cout << ans << endl;
}

Measured memory_bytes: 8004
#include <iostream>
#include <algorithm>
#include <cmath>
#include <string>
#include <vector>
#include <iomanip>
#include <queue>
#define rep(i,n) for(int i=0;i<n;i++)
#define repn(i,n) for(int i=1;i<=n;i++)
using namespace std;
typedef long long ll;

int P,Q,R;

int main(){
    cin>>P>>Q>>R;

    int ans=min(P+Q,min(Q+R,R+P));

    cout<<ans<<endl;
}

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

using namespace std;

int main() {
    int a, b;
    cin >> a >> b;
    if (a > b) swap(a, b);

    stringstream ss;
    for (int i = 0; i < b; ++i ) {
        char c = '0' + a;
        ss << c;
    }
    cout << ss.str() << endl;
    return 0;
}


Measured memory_bytes: 256
using System;
using System.Collections;
using System.Collections.Generic;
using System.Diagnostics;
using System.IO;
using System.Linq;
using System.Numerics;
using System.Text;
using System.Text.RegularExpressions;
using System.Threading.Tasks;
using static System.Math;
using MethodImplAttribute = System.Runtime.CompilerServices.MethodImplAttribute;
using MethodImplOptions = System.Runtime.CompilerServices.MethodImplOptions;

public static class P
{
    public static void Main()
    {
        var nm = Console.ReadLine().Split().Select(int.Parse).ToArray();
        var n = nm[0];
        var m = nm[1];
        bool[] paint = new bool[n];
        for (int i = 0; i < m; i++)
        {
            var al = Console.ReadLine().Split().Select(int.Parse).ToArray();
            for (int j = 0; j < al[1]; j++)
            {
                paint[(j + al[0]) % n] |= true;
            }
        }

        UnionFind uf = new UnionFind(n + 1);
        for (int i = 0; i < n; i++)
        {
            if (!paint[i])
                uf.TryUnite(i, n);
        }
        for (int i = 0; i < n - 1; i++)
        {
            if (paint[i] && paint[i + 1]) uf.TryUnite(i, i + 1);
        }
        if (paint[n - 1] && paint[0]) uf.TryUnite(n - 1, 0);

        Console.WriteLine(string.Join("\n", Enumerable.Range(0, n).GroupBy(x => uf.Find(x)).Where(x => x.Key != uf.Find(n)).GroupBy(x => x.Count()).OrderByDescending(x => x.Key).Select(x => $"{x.Key} {x.Count()}")));
    }
}


class UnionFind
{
    public int Size { get; private set; }
    public int GroupCount { get; private set; }
    public IEnumerable<int> AllRepresents => Parent.Where((x, y) => x == y);
    int[] Sizes;
    int[] Parent;
    public UnionFind(int count)
    {
        Size = count;
        GroupCount = count;
        Parent = new int[count];
        Sizes = new int[count];
        for (int i = 0; i < count; i++) Sizes[Parent[i] = i] = 1;
    }
    public bool TryUnite(int x, int y)
    {
        int xp = Find(x);
        int yp = Find(y);
        if (yp == xp) return false;
        if (Sizes[xp] < Sizes[yp]) { var tmp = xp; xp = yp; yp = tmp; }
        GroupCount--;
        Parent[yp] = xp;
        Sizes[xp] += Sizes[yp];
        return true;
    }
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int GetSize(int x) => Sizes[Find(x)];
    [MethodImpl(MethodImplOptions.AggressiveInlining)]
    public int Find(int x)
    {
        while (x != Parent[x]) x = (Parent[x] = Parent[Parent[x]]);
        return x;
    }
}



Measured memory_bytes: 18924
#include<bits/stdc++.h>
using namespace std;
#define int long long
const int INF = 1e18L + 5;
int32_t main()
{
 int n, W;
  cin>>n>>W;
  vector<int> weight(n);
  vector<int> value(n);
  int sum_value = 0;
  for(int i=0; i<n; i++){
    	cin>>weight[i]>>value[i];
    	sum_value += value[i];
  }
  vector<int> dp(sum_value + 1, INF);
  dp[0] = 0;
  for(int item =0; item < n; item++){
    for(int j = sum_value; j>=value[item]; j--){
      dp[j] = min(dp[j], dp[j-value[item]] + weight[item]);
    }
  }
 int ans = 0;
 for(int i=0; i<=sum_value; i++){
     //cout<<dp[i]<<" ";
   if( dp[i] <=W)
     	ans = max(ans, i);
 }
   cout<<ans;
}


Measured memory_bytes: 1024
#include<stdio.h>

int main(){
char a[15],b[15],c[15];
int i,j,k;

scanf("%s %s %s",a,b,c);

for(i=0; a[i]!='\0'; i++){}
for(j=0; b[j]!='\0'; j++){}


if((a[i-1]==b[0]) && (b[j-1]==c[0]) ) printf("YES");
else printf("NO");



}


Measured memory_bytes: 1696
#include <ios>
#include <iomanip>
#include <iostream>
#include <functional>
#include <cstdio>
#include <cstdlib>
#include <cstring>
#include <algorithm>
#include <string>
#include <sstream>
#include <complex>
#include <vector>
#include <list>
#include <queue>
#include <deque>
#include <stack>
#include <map>
#include <set>
#include <climits>

using namespace std;
typedef long long int ll;
#define rep(i, n) for(int i = 0; i < (int)(n); i++)
#define all(x) (x).begin(),(x).end()
#define MOD 1000000007
#define INF (1e9)
#define PI (acos(-1))
#define print(x) cout << x << endl
#define yes cout << "Yes" << endl
#define YES cout << "YES" << endl
#define no cout << "No" << endl
#define NO cout << "NO" << endl

ll gcd(ll a, ll b) { return b ? gcd(b,a%b) : a;}
ll lcm(ll a, ll b) { return a / gcd(a, b) * b; }
typedef pair <ll,ll> P;

int main()
{
    string A, B;
    cin >> A >> B;
    if (A.size() == B.size()) {
        if (A > B) print("GREATER");
        else if (A < B) print("LESS");
        else print("EQUAL");
    } else {
        if (A.size() > B.size()) print("GREATER");
        else if (A.size() < B.size()) print("LESS");
    }
    
    return 0;
}


Measured memory_bytes: 764
#include<bits/stdc++.h>
using namespace std;
typedef long long ll;
typedef unsigned long long LL;
typedef vector<ll>VI;
typedef pair<ll,ll>P;
typedef pair<double,double>P_D;
#define VV(T) vector<vector<T>>
#define PI 3.1415926535897932384626433832795
#define rep(i, n) for (ll i = 0; i < (ll)n; i++)
#define reprev(i, n) for (ll i = (ll)n - 1; i >= 0; i--)
#define ALL(a)  (a).begin(),(a).end()
#define c_max(a, b) (((ll)a)>((ll)b)?(a):(b))
#define c_min(a,b) (((ll)a)<((ll)b)?(a):(b))
#define chmax(x,a) x=max(x,a)
#define chmin(x,a) x=min(x,a)
#define vmax(v) *max_element(ALL(v))
#define vmin(v) *min_element(ALL(v))
#define $(x) {cout<<#x<<" = " <<(x)<<endl;}
#define fi first
#define se second
#define MAX 100100//5
#define MAX2 200100
#define MAX_6 1001001//6
#define MAX_7 10010010//7
#define SENTINEL 2000000000//9
#define NIL -1
const int MOD = 1000000007;
#define INF 1<<30
#define INFTY 1LL<<61
#define MAX_INT INT_MAX
#define Endl '\n'
inline ll GCD(ll a,ll b){return b?GCD(b,a%b):a;}
inline ll lcm(ll a,ll b){return a*b/GCD(a,b);}
using Edge=pair<int,ll>;
using Graph=vector<vector<int> >;//ll or Edge
using Edge=pair<int,ll>;
const int dx[4]={1,0,-1,0},dy[4]={0,1,0,-1};
// sort_reverse...greater<ll>()
// vector型から重複を削除 list.erase(unique(ALL(list)),list.end());
// g++ -o a a.cpp -Wall -lm -std=c++17
int n,m;
int ans[MAX];
int main(){
    cin>>n>>m;
    Graph G(n);
    rep(i,m){
        int a,b;
        cin>>a>>b;
        a--;b--;
        G[a].push_back(b);
        G[b].push_back(a);
    }
    memset(ans,-1,sizeof(ans));
    queue<int>q;
    q.push(0);
    ans[0]=0;
    while(q.size()){
        int t=q.front();
        q.pop();
        for(auto v:G[t]){
            if(ans[v]!=-1)continue;
            q.push(v);
            ans[v]=t+1;
        }
    }
    for(int i=1;i<n;i++){
        if(ans[i]==-1){
            cout<<"No"<<endl;
            return 0;
        }
    }
    cout<<"Yes"<<endl;
    for(int i=1;i<n;i++){
        cout<<ans[i]<<endl;
    }
}

Measured memory_bytes: 10248
#include <bits/stdc++.h>
/*...
  ...
  author 
  @
  Aman Kothari
  .....
  .....*/
using namespace std;
#define ll long long
#define dl double

int main()
{
    ios_base::sync_with_stdio(false);
    cin.tie(NULL);
    cout.tie(NULL);
    ll n;
	string s;
	cin>>s;
	ll count=0;
	vector<ll>v;
	ll len=0;
	for(ll i=0;i<s.length();i++){
		if(s[i]=='R'){
			count++;
		}
		else{
		v.push_back(count);
			count=0;
		}
		len=i;
	}
	if(s[len]=='R'){
		v.push_back(count);
	}
	cout<<*max_element(v.begin(), v.end())<<"\n"; 
    return 0;
}

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

const ll INFF = 1e18;

ll solve(ll x) {
	ll ans = INFF;
	for (ll i = 1; i <= 1000000; ++i) {
		if (x % i != 0)
			continue;
		ll j = x / i;
		ans = min(ans, i + j - 2);
	}
	return ans;
}

int main(int argc, char const *argv[])
{
	ll n; cin >> n;
	cout << solve(n) << endl;
	return 0;
}


Measured memory_bytes: 256
#pragma GCC target ("avx2")
#pragma GCC optimization ("O3")
#pragma GCC optimization ("unroll-loops")
#include<bits/stdc++.h>
using namespace std;
 
#define all(a) a.begin(),a.end()
#define F first
#define S second
#define pb push_back
#define ll long long
#define vi vector<int>
#define pi pair<int,int>
#define mp make_pair
 
#ifdef LOCAL
#include "debug.h"
#else
#define debug(...) 42
#endif
 
const int mod=1e9+7;
 
mt19937 rng(chrono::steady_clock::now().time_since_epoch().count());
 
int mul(int a,int b){
	return ((a)*1ll*(b))%mod;
}
 
void add(int &a,int b){
	a+=b;
	if(a>=mod)a-=mod;
}
 
int sub(int a,int b){
	a-=b;
	if(a<0){
		a+=mod;
	}
	return a;
}
 
int powz(int a,int b){
	int res=1;
	while(b){
		if(b&1){
			res=mul(res,a);
		}
		b/=2;
		a=mul(a,a);
	}
	return res;
}
 
template <typename A, typename B>
istream& operator>>(istream& input,pair<A,B>& x) {
	input>>x.F>>x.S;
	return input;
}
 
template <typename A>
istream& operator>>(istream& input,vector<A>& x) {
	for(auto& i:x)
		input>>i;
	return input;
}
 
template<typename A>
ostream& operator<<(ostream& output,vector<A>& x) {
	for(auto& i:x)
		output<<i<<' ';
	return output;
}
 
const int N=100002;

vector<int>rv[200005];
 
void solve(){
	int n;
	cin>>n;
	vi a(n);
	cin>>a;
	for(int i=0;i<n;i++){
		rv[a[i]].pb(i+1);
	}
	int lst=-1;
	int ans=0;
	for(int i=1;i<=200000;i++){
		int zz=lower_bound(all(rv[i]),lst)-rv[i].begin();
		if(zz==rv[i].size()){
			break;
		}
		lst=rv[i][zz];
		ans++;
	}	
	if(!ans){
		cout<<-1;
	}
	else{
		cout<<n-ans;
	}
	
}
 
signed main(){
	ios_base::sync_with_stdio(false);
	cin.tie(0);
	int tc=1;
	//~ cin>>tc;
	for(int _=0;_<tc;_++){
		//~ cout<<"Case #"<<_+1<<": ";
		solve();
		if(_!=tc-1)
		cout<<"\n";
	}
}


Measured memory_bytes: 12032
import java.util.Scanner;

public class Main {
	public static void main(String[] args) {
		Scanner sc = new Scanner(System.in);
		int n = sc.nextInt(), m = sc.nextInt(), c = sc.nextInt(), b[] = new int[m], ans = 0;
		for (int j = 0; j < m; j++)
			b[j] = sc.nextInt();
		for (int i = 0; i < n; i++) {
			int val = 0;
			for (int j = 0; j < m; j++)
				val += sc.nextInt() * b[j];
			if (val + c > 0)
				++ans;
		}
		System.out.println(ans);
		sc.close();
	}
}


Measured memory_bytes: 36328
#include<stdio.h>

int main(void)
{

	int su[3],a,hako;

	for(a=0;a<3;a++)
	{
		scanf("%d",&su[a]);
	}

	if(su[0]>su[1])
	{
		hako=su[0];
		su[0]=su[1];
		su[1]=hako;
	}
	if(su[1]>su[2])
	{ 
		hako=su[1];
		su[1]=su[2];
		su[2]=hako;
	}
	if(su[0]>su[1])
	{
		hako=su[0];
		su[0]=su[1];
		su[1]=hako;
	}

	printf("%d %d %d\n",su[0],su[1],su[2]);


	return 0;
}

Measured memory_bytes: 596
{-# LANGUAGE BangPatterns #-}
module Main (main) where

-- import Control.Monad
-- import Control.Monad.Trans.State
import Data.ByteString (ByteString)
-- import qualified Data.ByteString.Unsafe as B
import qualified Data.ByteString.Char8 as C8
import Data.Bool
-- import Data.Bits
-- import Data.Char
-- import Data.List
import Data.Maybe

main :: IO ()
main = do
  [n] <- readInts
  [k] <- readInts
  xs  <- readInts
  print . showAnswer $ solve (n,k) xs

type Output = Int

solve :: (Int,Int) -> [Int] -> Output
solve (n,k) = sum . map (\x -> min x (abs (k-x)) * 2)

showAnswer :: Output -> Answer
showAnswer = Number

-- utils
readInts :: IO [Int]
readInts = map (fst . fromJust . C8.readInt) . C8.words <$> C8.getLine

data Answer
  = YesNo Bool
  | YESNO Bool
  | AB Bool
  | Number Int
  | String String
  | ByteString ByteString
  | Compare Ordering
  | Compare2 Ordering

instance Show Answer where
  show (YesNo b)       = bool "No" "Yes"  b
  show (YESNO b)       = bool "NO" "YES"  b
  show (AB b)          = bool "B"  "A"    b
  show (Number i)      = show i
  show (String s)      = s
  show (ByteString bs) = C8.unpack bs
  show (Compare o)     = ordering "<" "=" ">" o
  show (Compare2 o)    = ordering "Right" "Balanced" "Left" o

ordering :: a -> a -> a -> Ordering -> a
ordering lt eq gt o = case o of
  LT -> lt
  EQ -> eq
  GT -> gt

-- | k 番目の文字に関数 f を適用する
indexMapBS :: Int -> (Char -> Char) -> ByteString -> ByteString
indexMapBS k f s = C8.concat [s1, C8.singleton (f c), s3]
  where
    (s1, s2) = C8.splitAt (k-1) s
    c = C8.head s2
    s3 = C8.tail s2

Measured memory_bytes: 508
#include <stdio.h>
#include <stdlib.h>
#include <iostream>
#include <queue>
#include <string>
#include <algorithm>
#include <cstdio>
#include <stack>
#include <vector>
#include <map>
#include <ctime>
#include <cmath>
#include <string.h>
#define inf 0x7fffffff
using namespace std;
struct P
{
    int x,y,z;

    bool operator<(const P &a)const{
       // if(y!=a.y)
       // return y>a.y;
       return x>a.x;
//        return z>a.z;
    }
};
vector<int> v[20056],v1[20020];
long long a,b,c,n,m,i,k,o[110000],d,e,dy[15]={0,0,-1,1,-1,1,-1,1},dx[15]={-1,1,0,0,1,1,-1,-1};
long long l[171000];
long long x,y,z;
P u[600][55];
int j[6000100];
//queue<int> q,q1;
stack<int> s;
queue<int> q;
//long long x=0,y=0,z[99];

//deque<int> d;
//'1'==49;
//'A'==65;
//'a'==97;
map<int, int > p;
string r,r1;
//char r[5000][1111];

bool as(P a,P b)
{
     return a.x<b.x;

}



int main()
{
    scanf("%lld %lld",&a,&b);
    for(long long t=1;t<=a;t++)
    {
        //o[t]=l[t]=1000000000;
        scanf("%lld %lld",&o[t],&l[t]);
        if((o[t]|b)==b) x+=l[t];
    }

    for(long long i=1;i<30;i++)
    if(((1<<i)|b)==b)
    {
        y=0;
        for(long long t=1;t<=a;t++)
        {
            if(((((o[t]>>(i+1))<<(i+1))+(1<<i))|b)<=b&&(o[t]&(1<<i))==0)
                y+=l[t];
        }
        //printf("%d %lld\n",(1<<i),y);
        x=max(x,y);
    }
    printf("%lld",x);
}


Measured memory_bytes: 5248
#include <iostream>
#include <map>
#include <set>
#include <stack>
#include <cmath>
#include <ctime>
#include <queue>
#include <vector>
#include <sstream>
#include <iomanip>
#include <cstdlib>
#include <stdio.h>
#include <assert.h>  
#include <unordered_map>  
#include <string.h>
#include <algorithm>
 
using namespace std;
 
typedef long long ll;
 
#define y1 needtrainharder
#define f first
#define s second
#define gg exit(0)
#define sz() size()
#define pb push_back
#define mp make_pair
#define skip continue
#define all(x) x.begin(), x.end()
#define alln(x, y) x, x + y
#define boost ios_base::sync_with_stdio(0),cin.tie(NULL),cout.tie(NULL)
#define file(s) if(fopen(task".in", "r"))freopen(s".in","r",stdin),freopen(s".out","w",stdout);
#define task "sorting"    
 
const int inf = 1e9 + 5;  
const ll infll = 1e18 + 5ll;  
const long double eps = 1e-9;
const long double pi = acos(-1);
const int maxn = 3e5;
const ll maxlog = 21;
const int P = 97;
const int mod = 1e9 + 7;   
const int block = 707;
const int dx[]={0,0,1,-1};
const int dy[]={1,-1,0,0};

string s, t, ans;
int dp[3002][3002];

int main() {
  file(task); 
  cin >> s >> t;
  s = '#' + s;
  t = '#' + t;
  for (int i = 1; i < s.sz(); ++i) {
    for (int j = 1; j < t.sz(); ++j) {
      if (s[i] == t[j]) {
        dp[i][j] = dp[i - 1][j - 1] + 1;
      }
      else
        dp[i][j] = max(dp[i - 1][j], dp[i][j - 1]);
    }
  }
  int i = s.sz() - 1, j = t.sz() - 1;
  while (i >= 1 && j >= 1) {
    if (s[i] == t[j]) {
      ans = s[i] + ans;
      --i;
      --j;
    } else {
      if (dp[i - 1][j] >= dp[i][j - 1]) {
        --i;
      } else {
        --j;
      }
    }
  }
  cout << ans;
  return 0;
}
/*





*/

Measured memory_bytes: 35456
#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using P = pair<ll, ll>;
constexpr int INF = 1001001001;
constexpr int MOD = 1000000007;

int solve(int num, int x) {
  int sum = 0;
  for (int i = 1; i <= num; i++) {
    for (int j = i + 1; j <= num; j++) {
      for (int k = j + 1; k <= num; k++) {
        if (i == j || j == k || i == k) continue;

        if (i + j + k == x) {
          sum++;
        }
      }
    }
  }

  return sum;
}

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

  vector<int> n, x;
  while (1) {
    int tn, tx;
    cin >> tn >> tx;

    if (tn == 0 && tx == 0) {
      break;
    } else {
      n.emplace_back(tn);
      x.emplace_back(tx);
    }
  }

  for (int i = 0; i < n.size(); i++) {
    int ans = solve(n[i], x[i]);
    cout << ans << endl;
  }

  return 0;
}


Measured memory_bytes: 3144
#pragma GCC optimize("Ofast")
#include <cmath>
#include <cctype>
#include <cstdio>
#include <vector>
#include <cstdlib>
#include <climits>
using namespace std;

void read_un() {};
template<typename T, typename... Args> void read_un(T& x, Args&&... args) {
  x = 0; int ch = 0;
  while (!isdigit(ch = getchar())); x = ch ^ '0';
  while (isdigit(ch = getchar())) x = (x << 3) + (x << 1) + (ch ^ '0');
  read_un(args...);
};

const int& minx(const int &a, const int &b) {
  return a < b ? a : b;
}

int main() {
  unsigned n, k; read_un(n, k);
  vector<int> h(n);
  for (auto &x : h) read_un(x);
  vector<int> f(n, INT_MAX);
  f.at(0) = 0;
  for (unsigned i = 1; i < n; ++i)
    for (int j = i - 1, l = 0; ~j && l < k; --j, ++l)
      f.at(i) = minx(f.at(i), f.at(j) + abs(h.at(i) - h.at(j)));
  printf("%d", f.back());
  return 0;
}


Measured memory_bytes: 1024
n = int(input())
al = list(map(int, input().split()))

ans = 0
while True:
    for i in range(n):
        if al[i] % 2 == 0:
            al[i] = al[i]//2
        else:
            break
    else:
        ans += 1
        continue
    break

print(ans)


Measured memory_bytes: 2940
from fractions import gcd

n, x = [int(i) for i in input().split()]
x_list = [int(i) for i in input().split()]

temp_list = [abs(num - x) for num in x_list]

ans = temp_list[0]
for i in range(1, n):
    ans = gcd(ans, temp_list[i])
    if ans == 1:
        break
print(ans)

Measured memory_bytes: 16276
#include<stdio.h>

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

int equal(int a[], int b[]){
        return a[0]==b[0] && a[1]==b[1] && a[2]==b[2];
}

int main(void){
        int n;
        scanf("%d", &n);

        int i, j, size = 0, prgn[n][3];

        for(i=0; i<n; i++){
                int a, b, c;
                scanf("%d %d %d", &a, &b, &c);
                if(a>b) swap(&a, &b);
                if(b>c) swap(&b, &c);
                if(a>b) swap(&a, &b);
                int tp[] = {a, b, c};

                int new = 1;
                for(j=0; j<size; j++){
                        if(equal(tp, prgn[j])) new = 0;
                }
                if(new){
                        prgn[size][0] = a;
                        prgn[size][1] = b;
                        prgn[size][2] = c;
                        size++;
                }
        }

        printf("%d\n", n-size);
        return 0;
}


Measured memory_bytes: 2144
#include<stdio.h>
#include<iostream>
#include<iomanip>
#include<string>
#include<vector>
#include<queue>
#include<stack>
#include<map>
#include<set>
#include<algorithm>
#include<string>
#include<math.h>
#include<numeric>
#include<complex>
#include<ctype.h>

using namespace std;
typedef long long ll;

#define REP(i,n) for(int i=0;i<n;++i)
#define FOR(i,a,b) for(int i=(a);i<(b);++i)
#define ALL(v) (v).begin(), (v).end()
#define p(s) cout<<(s)<<endl
#define p2(s, t) cout << (s) << " " << (t) << endl
#define pn(s) cout << (#s) << " " << (s) << endl

const ll mod = 1e9 + 7;
const ll inf = 1e18;

void pV(vector<ll> A){
    cout << "[vector]" << endl;
    for(int i=0; i<A.size(); i++){
        cout << A[i] << " ";
    }
    cout << endl;
}

const int N_MAX = 100000;
ll a[N_MAX+10] = {};
int N;

int sign(ll v){
    if(v > 0){
        return 1;
    }else if(v == 0){
        return 0;
    }else{
        return -1;
    }
}

ll calc(ll count, ll sum){
    FOR(i, 1, N){
        ll nextSum = sum + a[i];
        if(nextSum == 0){
            if(sign(sum) > 0){
                nextSum = -1;
            }else{
                nextSum = 1;
            }
            count += 1;
        }
        else if(sum * nextSum < 0){
            // do nothing
        }else{
            ll diff;
            if(sign(sum) > 0){
                diff = -1 - nextSum;
                nextSum += diff;
            }else{
                diff = 1 - nextSum;
                nextSum += diff;
            }
            count += abs(diff);
        }
        sum = nextSum;
    }
    return count;
}

int main(){
    cin.tie(0);
    ios::sync_with_stdio(false);
    
    // input
    cin >> N;

    FOR(i, 0, N){
        cin >> a[i];
    }

    // プラマイ
    ll count = 0;
    ll sum = a[0];
    if(sum <= 0){
        sum = 1;
        count += (1-a[0]);
    }
    ll count0 = calc(count, sum);

    // マイプラ
    count = 0;
    sum = a[0];
    if(sum >= 0){
        sum = -1;
        count += (a[0]+1);
    }
    ll count1 = calc(count, sum);

    p(min(count0, count1));
    
    return 0;
}

Measured memory_bytes: 1024
<?php

fscanf(STDIN, "%d %d", $switch, $lamp);


for ($i = 0; $i < $lamp; ++$i) {
 $str_lamp = trim(fgets(STDIN));
 $lamp_map[$i] = explode(" ", $str_lamp);
}

$str_binary = trim(fgets(STDIN));
$binary = explode(" ", $str_binary);
$ans = [];
for ($i = 0; $i < $lamp; ++$i) {
 $checker = [];
 for ($k = 1; $k <= $lamp_map[$i][0]; $k++) {
  $checker[$lamp_map[$i][$k]] = 1;
 }
 for ($j = 0; $j < (pow(2, $switch)); ++$j) {
  $hoge = 0;
  foreach ($checker as $number => $one) {

   if ($j & ((pow(2, $number - 1)))) {
    $hoge++;
   }
  }
  if ($hoge % 2 == $binary[$i]) {
   @$ans[$j]++;
  }
 }
}
$count = 0;
foreach ($ans as $value) {
 if ($value == $lamp) {
  $count++;
 }
}
echo $count;


Measured memory_bytes: 4604
#include <bits/stdc++.h>
using namespace std;
string arr;
long long getsum(int ind,int sum,int flag,vector<vector<vector<long long> > >&dp){
	if(ind==arr.size()) return sum;
	if(dp[ind][sum][flag]!=-1) return dp[ind][sum][flag];
	int limit=9;
	if(!flag) limit=arr[ind]-'0';
	long long res=0;
	for(int i=0;i<=limit;i++){
		if(flag||i<limit){
			res=max(res,getsum(ind+1,sum+i,1,dp));
		}
		else res=max(res,getsum(ind+1,sum+i,0,dp));
	}
	dp[ind][sum][flag]=res;
	return res;
	
	
}
int main() {
	
		long long a;
		cin>>a;
	
	
		arr=to_string(a);
		
		
			vector<vector<vector<long long> > >dp(arr.size()+1,vector<vector<long long> >(200,vector<long long>(2,-1)));
		long long u=getsum(0,0,0,dp);
		
		
		cout<<u<<endl;
		
		
	
	
	return 0;
}

Measured memory_bytes: 3916
#include<iostream>
#include<string>
#include<algorithm>
#include<cmath>
#include<iomanip>
#include<cstring>
#include<map>
#include<vector>
#include<queue>
#include<stack>
#include<climits>
#include<set>
#include<utility>
#include<typeinfo>
using namespace std;
typedef long long int ll;
typedef pair<int, int> P;
typedef set<int> S;
#define rep(i, n) for(int i=0; i<n; i++)
const ll MOD=1e9+7;

int main(){

	int N, H, W, A, B, ans = 0;
	cin >> N >> H >> W;
	for(int i = 0; i < N; i++){
		cin >> A >> B;
		if(H <= A && W <= B){
			ans++;
		}
	}
	cout << ans << endl;

	return 0;
}

Measured memory_bytes: 256
# import bisect
# import copy
# import fractions
# import math
# import numpy as np
# from collections import Counter, deque
# from itertools import accumulate,permutations, combinations,combinations_with_replacement,product

def resolve():
    x,y,z=map(int,input().split())
    x=x-z
    print(x//(y+z))

resolve()

Measured memory_bytes: 38384
N,*A = map(int,open(0).read().split())
A.sort()
B = [[] for i in range(100)]
B[0]= A
#print(B)
for i in range(99):
  B[i+1].append(B[i][0])
  for j in range(1,len(B[i])):
    x = B[i][j]%B[i][0]
    if x!=0:
      B[i+1].append(x)
  B[i+1]=sorted(B[i+1])
  if len(B[i])<=1:
    break
print(B[i][0])

Measured memory_bytes: 87312
#include<iostream>
#include<string>
#include<algorithm>
#include<vector>
#include<queue>
#include<random>
#include<set>
#include<map>
#include<functional>
using namespace std;
#define int long long
#define inf 1145141919
#define rep(i,n) for(int i=0;i<n;i++)
typedef pair<int, int>P;
struct edge { int u, v, cost; };
int par[114514], rnk[114514];
edge es[114514];
bool comp(const edge&e1, const edge&e2) {
	return e1.cost<e2.cost;
}
void init(int n) {
	for (int i = 0; i<n; i++) {
		par[i] = i;
		rnk[i] = 0;
	}
}
int find(int x) {
	if (par[x] == x)return x;
	return par[x] = find(par[x]);
}
void unite(int x, int y) {
	x = find(x);
	y = find(y);
	if (x == y)return;
	if (rnk[x]<rnk[y])par[x] = y;
	else {
		par[y] = x;
		if (rnk[x] == rnk[y])rnk[x]++;
	}

}

int a[114514];

int dt(int n) {
	int res = 0;
	while (!(n & 1)) {
		n /= 2; res++;
	}
	return res;
}

signed main() {
	int n; cin >> n; rep(i, n)cin >> a[i];
	int cnt = 0;
	rep(i, n) {
		cnt += dt(a[i]);
	}
	cout << cnt << endl;
}


Measured memory_bytes: 384
#include <cstdio>
#include <vector>
#include <set>
#include <stack>
#include <algorithm>

#define REP(i,n) for(int i=0;i<(int)n;++i)
#define FOR(i,c) for(__typeof((c).begin())i=(c).begin();i!=(c).end();++i)
#define ALL(c) (c).begin(), (c).end()
#define INF 9999999
using namespace std;

typedef int Weight;
struct Edge {
  int src, dst;
  Weight weight;
  Edge(int src, int dst, Weight weight) :
    src(src), dst(dst), weight(weight) { }
};
bool operator < (const Edge &e, const Edge &f) {
  return e.weight != f.weight ? e.weight > f.weight : // !!INVERSE!!
    e.src != f.src ? e.src < f.src : e.dst < f.dst;
}
typedef vector<Edge> Edges;
typedef vector<Edges> Graph;
typedef vector<Weight> Array;
typedef vector<Array> Matrix;

const int M = 20;
Weight best[1<<M][M];
int    prev[1<<M][M];
void buildPath(int S, int i, vector<int> &path) {
  if (!S) return;
  buildPath(S^(1<<i), prev[S][i], path);
  path.push_back(i);
}
Weight shortestHamiltonCycle(Matrix w, vector<int> &path) {
  int n=w.size();
  int N = 1 << n;
  REP(S,N) REP(i,n) best[S][i] = INF;
  best[0][0] = 0;
  REP(S,N) REP(i,n) REP(j,n) if (!(S&(1<<j)))
    if (best[S|(1<<j)][j] > best[S][i] + w[i][j])
      best[S|(1<<j)][j] = best[S][i] + w[i][j],
      prev[S|(1<<j)][j] = i;
  //int t = min_element(best[N-1], best[N-1]+n) - best[N-1];
  //path.clear(); buildPath(N-1, t, path);
  return best[N-1][0]==INF ? -1 : best[N-1][0];
}

int main(){
	int V,E,s,t,d;
	scanf("%d%d",&V,&E);
	Matrix m(V,Array(V));
	for(s=0;s<V;s++)for(t=0;t<V;t++)if(s!=t)m[s][t]=INF;
	vector<int>path;
	for(;E--;)scanf("%d%d%d",&s,&t,&d),m[s][t]=d;
	printf("%d\n",shortestHamiltonCycle(m,path));
}

Measured memory_bytes: 9240
using System;

namespace ITP1_4_B_Circle
{
    class Program
    {
        static void Main(string[] args)
        {
            var r = double.Parse( Console.ReadLine() );
            Console.WriteLine( "{0:f6} {1:f6}", r * r * Math.PI, 2 * r * Math.PI );
        }
    }
}

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

using namespace std;

typedef long long ll;

#define MAX 1024
#define INF LLONG_MAX/4

ll N, W;
ll memo[MAX][MAX];
vector<ll> a;

ll solve(int line, int n)
{
    if (n == N) return 0;
    ll &res = memo[line][n];
    if (res != -1) return res;
    res = INF;
    ll sum = 0;
    for (int i = n; i < N; i++) {
        sum += a[i];
        res = min(res, solve(line + 1, i+1) + abs(sum - W));
    }
    res = min(res, solve(line + 1, N) + max(0LL, sum - W));
    return res;
}

int main()
{
    int T = 1;
    while (cin >> N >> W, N) {
        a.resize(N);
        for (int i = 0; i < N; i++) {
            cin >> a[i];
        }
        memset(memo, -1, sizeof(memo));
        cout << "Case " << T++ << ": " << solve(0, 0) << endl;
    }    
    return 0;
}

Measured memory_bytes: 11428
#include <bits/stdc++.h>
using namespace std;
using ll=long long;
using vi=vector<int>;
using vvi=vector<vi>;
using pii=pair<int,int>;
#define rep(i,n) for(int i=0;i<n;i++)
#define range(i,a,n) for(int i=a;i<n;i++)
#define all(a) a.begin(),a.end()
#define rall(a) a.rbegin(),a.rend()
#define INF 1e9
#define EPS 1e-9
#define MOD (1e9+7)
void put(string d){}template<class H,class...T>void put(string d,H&h,T&...t){cout<<h;if(sizeof...(t))cout<<d;put(d,t...);}
template<class T>void puti(T&a,string d=" "){bool f=1;for(auto&_:a)cout<<(exchange(f,0)?"":d)<<_;cout<<endl;}
template<class T>void putii(T&a,string d=" "){for(auto&_:a)puti(_,d);}

int main(){
    ll k; cin>>k;
    vector<ll> ans;
    rep(i,51) if(i!=50-k%50) ans.push_back(k/50+i);
    cout<<50<<endl;
    puti(ans);
	return 0;
}


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

using namespace std;

int main()
{
  long long int a,b,sum,num;
  scanf("%lld %lld",&a,&b);
  sum=(a+b);
  num=sum/2;
  if(num*2 == sum)
  {
    printf("%lld\n",num);
  }
  else printf("IMPOSSIBLE\n");
}

Measured memory_bytes: 256
from sys import stdin, stdout
a, b, c ,d = map(int, stdin.readline().strip().split())

i = 0
while a>0 and c>0:
    if i%2 == 0:
        c -= b
    else:
        a -= d
    i+=1

if a <= 0:
    print('No')
else:
    print('Yes')

Measured memory_bytes: 61688
// Believe in yourself
#include<bits/stdc++.h>

using namespace std;

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

#define PB push_back
#define MP make_pair
#define F first
#define S second
#define Pair vector<pair<ll,ll>>
#define vec vector <ll> 
#define all(a) a.begin(),a.end()
#define mo 1000000007
#define decimal(i,n) fixed << setprecision(i) << n
#define show(a) for(auto xyz:a)cout<<xyz<<" ";cout<<endl;
#define show_nl(a) for(auto xyz:a)cout<<xyz<<endl;


void eea(ll a,ll b,ll &x,ll &y)
{
    if (a == 1)
    {
        x = 1; y = 0;
        return;
    }
    ll x1, y1;
    eea(b%a,a,x1,y1);
    x=y1-(b/a)*x1;
    y=x1;
}
ll mi(ll a,ll m)
{
    ll x,y;
    eea(a,m,x,y);
    x= (x%m+m)%m;
    return x;
}

/*
Enter the test case


Some helpful points
1.) Calm yourself
2.) check for semicolon or data type mismatch
*/

int main()
{
    ios::sync_with_stdio(0);
    cin.tie(0); cout.tie(0);    
    ll t=1;
    // cin>>t;
    while(t--)
    {
       ll n;
       cin>>n;
       ll re=0;
       ll te=0;
       ll a=7,i;
       for(i=1;i<1000000;i++)
       {
           if(a%n!=0)
           {
               re=a%n;
               a=(7+re*10)%n;
           }
           else
           break;
       }
       if(i==1000000)
       cout<<-1<<"\n";
       else
       cout<<i<<"\n";
    }
}



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

const int N = 100005;

template <class T>
void read (T &x) {
	int sgn = 1;
	char ch;
	x = 0;
	for (ch = getchar(); (ch < '0' || ch > '9') && ch != '-'; ch = getchar()) ;
	if (ch == '-') ch = getchar(), sgn = -1;
	for (; '0' <= ch && ch <= '9'; ch = getchar()) x = x * 10 + ch - '0';
	x *= sgn;
}
template <class T>
void write (T x) {
	if (x < 0) putchar('-'), write(-x);
	else if (x < 10) putchar(x + '0');
	else write(x / 10), putchar(x % 10 + '0');
}

char str[N];
int main () {
	scanf("%s", str);
	bool chk = true;
	for (int i = 0; str[i]; i++) {
		if (i & 1) {
			if (str[i] != 'i') chk = false;
		}
		else if (str[i] != 'h') chk = false;
	}
	if (strlen(str) & 1) chk = false;
	if (chk) puts("Yes");
	else puts("No");
	return 0;
}

Measured memory_bytes: 256
#include <cstdio>
#include <algorithm>
#include <vector>
#include <string>
#include <iostream>
#include <climits>
#include <cmath>
#include <functional>
#include <map>
// #include <bits/stdc++.h>
using namespace std;

#define size_t int
typedef long long ll;
#define int long long
typedef vector<int> VI;
#define FOR(i, a, b) for(int i = (a); i < (b); i++)
#define REP(i, n) FOR(i, 0, n)
#define SORT(v, n) sort(v, v + n);
#define VSORT(v) sort(v.begin(), v.end());
#define debug(x) cerr << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug1(i, x) cerr << "(" << (i) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
#define debug2(i, j, x) cerr << "(" << (i) << ", " << (j) <<  ") " << #x << " = " << (x) << " (line " << __LINE__ << ")" << endl;
template <typename T> class vec2d : public vector<vector<T>> {
public:
    vec2d(int H, int W): vector<vector<T>> (H, vector<T>(W)) {
    }
};
template <typename T> istream& operator >> (istream& is, vector<T>& vec){
  for(T& x: vec) is >> x;
  //for(int i=0; i<vec.size(); i++) is >> x[i]; とかでもいいです。
  return is;
}
template <typename T> ostream& operator << (ostream& os, vector<T>& vec){
  REP(i, vec.size()) {
    os << vec[i] << ( i+1 == vec.size() ? "" : " " );
  }
  return os;
}
struct aaa{
    aaa(){
        cin.tie(0); ios::sync_with_stdio(0);
        // cout<<fixed<<setprecision(20);
    };
}aaaaaaa;

int N, M;

struct UnionFind {
  vector<int> data;
  UnionFind(int size) : data(size, -1) { }
  bool unionSet(int x, int y) {
    x = root(x); y = root(y);
    if (x != y) {
      if (data[y] < data[x]) swap(x, y);
      data[x] += data[y]; data[y] = x;
    }
    return x != y;
  }
  bool findSet(int x, int y) {
    return root(x) == root(y);
  }
  int root(int x) {
    return data[x] < 0 ? x : data[x] = root(data[x]);
  }
  int size(int x) {
    return -data[root(x)];
  }
};


signed main(signed argc, char **argv) {
  cin >> N >> M;
  vector<vector<int>> e(M, vector<int>(2));
  for (size_t i = 0; i < M; i++) {
    int a,b;
    cin >> a >> b;
    e[i][0] = a - 1;
    e[i][1] = b - 1;
  }
  UnionFind uf(N);
  int ans = N * (N-1) / 2;
  VI anss(M);
  for (size_t i = M - 1; i >= 0; i--) {
    anss[i] = ans;
    debug(ans);
    debug(M - i - 1);
    bool con = uf.findSet(e[i][0], e[i][1]);
    if (!con) {
      ans = ans - uf.size(e[i][0]) * uf.size(e[i][1]);
    }
    uf.unionSet(e[i][0], e[i][1]);
    debug(uf.size(e[i][0]));
    debug(uf.size(e[i][1]));
  }
  for (size_t i = 0; i < M; i++) {
    cout << anss[i] << endl;
  }
  return 0;
}


Measured memory_bytes: 8320
n = int(input())
ans = []

if n == 0:
    print('0')

else:
    while n != 0:
        if n % -2 == -1:
            n = n // -2 + 1
            ans.append('1')
        else:
            n = n // -2
            ans.append('0')
    
    ans.reverse()

    print(''.join(ans))

Measured memory_bytes: 3060
#include <bits/stdc++.h>
using namespace std;
#define rep(i, s, n) for (int i = (s); i < (n); i++)
#define rrep(i, s, n) for (int i = (s); i > (n); i--)
#define all(v) v.begin(), v.end()
#define out(s) cout << (s) << endl
#define ll long long

void solve(){
  int n;
  cin>>n;
  vector<int> a(n);
  rep(i,0,n){cin>>a[i];}

  int ans = 0;
  rep(i,0,n){
    rrep(j,n-1,i){
      if(a[j-1]>a[j]){
        swap(a[j-1],a[j]);
        ans++;
      }
    }
  }

  rep(i,0,n){
    cout<<a[i];
    if(i!=n-1)
    {
        cout<<" ";
    }
  }
  cout<<endl;
  out(ans);
}

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



Measured memory_bytes: 3176
/********************************************
 *Author*        :ZZZZone
 *Created Time*  : 六  4/21 20:16:41 2018
 * Ended  Time*  : 六  4/21 20:39:09 2018
*********************************************/

#include <cstdio>
#include <cstring>
#include <iostream>
#include <algorithm>
#include <vector>
#include <queue>
#include <set>
#include <map>
#include <string>
#include <cmath>
#include <cstdlib>
#include <ctime>
#include <stack>
using namespace std;
#define debug(x) std::cerr << #x << " = " << (x) << std::endl
typedef pair<int, int> PII;
typedef long long LL;
typedef unsigned long long ULL;
const int MAXN = 1e5;

LL x[MAXN+5], v[MAXN+5];
int n;
LL C;


struct Node{
	int pos;
	LL sum;
}fl, fr;
LL qr[MAXN+5], ql[MAXN+5];

void Init(){
	scanf("%d %lld", &n, &C);
	for(int i = 1; i <= n; i++){
		scanf("%lld %lld", &x[i], &v[i]);
	}
}

void Solve(){
	LL sum = 0;
	for(int i = 1; i <= n; i++){
		sum += v[i];
		ql[i] = max(ql[i-1], sum - x[i]);
	}
	sum = 0LL;
	for(int i = n; i >= 1; i--){
		sum += v[i];
		qr[i] = max(qr[i+1], sum - (C-x[i]));
	}
	sum = 0LL;
	LL ans = 0LL;
	for(int i = 0; i <= n; i++){
		LL tmp = max(ql[i] - x[i] + qr[i+1], ql[i]);
		ans = max(ans, tmp);
	}
	sum = 0LL;
	for(int i = n+1; i >= 1; i--){
		LL tmp = max(qr[i] - (C-x[i]) + ql[i-1], qr[i]);
		ans = max(ans, tmp);
	}
	printf("%lld\n", ans);
}

int main()
{
	Init();
	Solve();
    return 0;
}


Measured memory_bytes: 3328
import fractions
t = int(input())
al = []
for i in range(t):
    a,b,c,d = map(int,input().split())
    if b > d:
        al.append("No")
    else:
        if b > a:
            al.append("No")
        else:
            if b-1 <= c:
                al.append("Yes")
            else:
                if a % b > c:
                    al.append("No")
                else:
                    yo = d%b
                    now = a%b 
                    if yo == 0:
                        al.append("Yes")
                    else:
                        g = fractions.gcd(b,yo)
                        #print(g)
                        if c >= b-g+a%g:
                            al.append("Yes")
                        else:
                            al.append("No")
for i in al:
    print(i)

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

using namespace std;
using ll = long long;
using ull = unsigned long long;

typedef pair<ll, ll> P;
typedef pair<ll, P> PP;
typedef pair<P, P> PPP;

const ll MOD = 1e9 + 7;
const ll INF = 9e18;
const double DINF = 5e14;
const double eps = 1e-10;
const int dx[4] = { 1,0,-1,0 }, dy[4] = { 0,1,0,-1 };

#define ALL(x) (x).begin(),(x).end()
#define ALLR(x) (x).rbegin(),(x).rend()
#define pb push_back
#define eb emplace_back
#define fr first
#define sc second

int h, r;

int main() {
	cin >> h >> r;
	if (h + r > 0) cout << 1 << endl;
	else if (h + r == 0)cout << 0 << endl;
	else cout << -1 << endl;
	return 0;
}


Measured memory_bytes: 3088
#include <algorithm>
#include <iomanip>
#include <iostream>
#include <vector>

#define REP(i,s,n) for(int i=(int)(s);i<(int)(n);i++)

using namespace std;
typedef long long int ll;
typedef vector<int> VI;
typedef vector<ll> VL;
typedef pair<int, int> PI;
const int N = 123456;

VI edges[N];
int depth[N];

void dfs(int v) {
  int mi = 1e8;
  REP(i, 0, edges[v].size()) {
    int w = edges[v][i];
    dfs(w);
    mi = min(mi, depth[w]);
  }
  if (mi == (int) 1e8) {
    depth[v] = 0;
  } else {
    depth[v] = mi + 1;
  }
}

int main(void) {
  ios::sync_with_stdio(false);
  cin.tie(0);
  int n, k;
  cin >> n >> k;
  VI a(n);
  REP(i, 0, n) {
    cin >> a[i];
    a[i]--;
    if (a[i] >= 0) {
      edges[a[i]].push_back(i);
    }
  }
  fill_n(depth, N, -1);
  REP(i, 0, n) {
    if (depth[i] == -1) {
      dfs(i);
    }
  }
  int tot = 0;
  REP(i, 0, n) {
    tot += depth[i] < k || a[i] == -1 ? 1 : 0;
  }
  cout << tot << "\n";
}

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

using namespace std;

typedef long long ll;
typedef unsigned long long ull;
using P = pair<ll, ll>;
using V = vector<ll>;
#define rep(i, n) for(ll i=0;i<(ll)(n);i++)
#define rep1(i, n) for(ll i=1;i<=(ll)(n);i++)
#define rep2(i, m, n) for(ll i=m;i<(ll)(n);i++)
#define rrep(i, n, m) for(ll i=n;i>=(ll)(m);i--)
#define ALL(obj) (obj).begin(), (obj).end()
#define MOD 1000000007
#define INF 1000000000

void solve_abc_c() {
	ll n;
	ll ans = -INF;

	cin >> n;

	ll f[101][6][3];
	rep(i, n) {
		rep(j, 5) {
			cin >> f[i][j][0] >> f[i][j][1];
		}
	}

	ll p[101][11];
	rep(i, n) {
		rep(j, 11) {
			cin >> p[i][j];
		}
	}

	ll y, g;
	ll v;
	V c(n, 0);
	rep(i, 1 << 10) { // 店の開き方
		if (i == 0) {
			continue;
		}

		rep(k, n) {
			c[k] = 0;
		}
		rep(j, 10) { // 曜日と時間帯
			if (((i >> j) & 1) == 1) {
				y = j / 2;
				g = j % 2;
				rep(k, n) { // 各店
					if (f[k][y][g] == 1) {
						c[k]++;
					}
				}
			}
		}
		v = 0;
		rep(k, n) {
			v += p[k][c[k]];
		}
		ans = max(ans, v);
	}

	cout << ans << "\n";
}

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

	solve_abc_c();

	return 0;
}

Measured memory_bytes: 256
import Control.Applicative
import Data.List(tails, intersperse)

type Sorted    = [Int]
type NotSorted = [Int]

insert :: Int -> Sorted -> Sorted
insert x [] = [x]
insert x (y:ys) | x < y     = x : y : ys
                | otherwise = y : (insert x ys)

step :: ([String], Sorted) -> NotSorted -> ([String], Sorted)
step pair []         = pair
step (ss, ys) (x:xs) = let ns = insert x ys
                        in ((cat (toS ns) (toS xs)) : ss, ns)

toS :: Sorted -> String
toS = concat . intersperse " " . map show

cat :: String -> String -> String
cat left [] = left
cat left right = left ++ " " ++ right

main = do
    getLine
    qs <- map read . words <$> getLine
    let st = fst (foldl step ([], []) (tails qs))
    mapM_ putStrLn (reverse st)


Measured memory_bytes: 4688
#include <bits/stdc++.h>
#define cinf(n,x) for(int i=0;i<(n);i++)cin>>x[i];
#define ft first
#define sc second
#define pb push_back
#define lb lower_bound
#define ub upper_bound
#define all(v) (v).begin(),(v).end()
#define LB(a,x) lb(all(a),x)-a.begin()
#define UB(a,x) ub(all(a),x)-a.begin()
#define mod 1000000007
#define FS fixed<<setprecision(15)
using namespace std;
typedef long long ll;
#define rep(i,n) for(ll i=0;i<n;i++)
const double pi=3.141592653589793;
template<class T> using V=vector<T>;
using Graph = vector<vector<int>>;
using P=pair<ll,ll>;
typedef unsigned long long ull;
typedef long double ldouble;
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; }

const ll INF=1e18;

int main(){
    cin.tie(0);ios::sync_with_stdio(false);
    int h,w;
    cin>>h>>w;
    char s[h][w];
    V<V<int>> ro(h),co(w);
    rep(i,h)ro[i].push_back(-1);
    rep(i,w)co[i].push_back(-1);
    rep(i,h){
        rep(j,w){
            cin>>s[i][j];
            if(s[i][j]=='#'){
                ro[i].push_back(j);
                co[j].push_back(i);
            }
        }
    }
    rep(i,h)ro[i].push_back(w);
    rep(i,w)co[i].push_back(h);
    int ans=0;
    rep(i,h){
        rep(j,w){
            if(s[i][j]=='.'){
                int x=lb(all(ro[i]),j)-ro[i].begin();
                int y=lb(all(co[j]),i)-co[j].begin();
                int cnt=ro[i][x]-ro[i][x-1]+co[j][y]-co[j][y-1]-3;
                chmax(ans,cnt);
            }
        }
    }
    cout<<ans<<endl;
}
//ペナルティ出しても焦らない　ACできると信じろ！！！
//どうしてもわからないときはサンプルで実験　何か見えてくるかも
//頭で考えてダメなら紙におこせ！！
/*
V,P(大文字)使用不可
乗算などの際にオーバーフローに注意せよ！
(適切にmodをとれ　にぶたんで途中で切り上げろ)
制約をよく読め！
{
    ・全探索できるなら全探索しろ
    ・異常な制約ならそこに注目
}
stringの計算量(扱い)注意
コーナー注意！(特に数値が小さいものについては要検証)
N行出力のときは'¥n'
グリッド上では行先が範囲内におさまるかif文で確認(RE注意)
if文ではちゃんと比較演算子==を使え('='でもエラー出ない)
配列(vector)の大きさが0か1以上かで場合分けせよ(RE注意)
(vector<int> a(m)でm==0というものはできない)
modはなるべく最後に取れ！
doubleを扱うときには(abs)ではなく'fabs'!!!
*/

Measured memory_bytes: 41424
//! ----------------------------------------------
//! Framework <https://github.com/vain0x/procon>
//!
//! See the bottom of file for solution.
//! ----------------------------------------------

#![allow(unused_imports)]
#![allow(non_snake_case)]

use std::cell::RefCell;
use std::cmp::{max, min, Ordering};
use std::collections::*;
use std::fmt::{Debug, Display, Formatter, Write as FmtWrite};
use std::io::{stderr, stdin, BufRead, Write};
use std::mem::{replace, swap};
use std::ops::*;
use std::rc::Rc;

/// Print values to standard error if debug mode.
#[allow(unused_macros)]
macro_rules! debug {
    ($($e:expr),*) => {
        #[cfg(debug_assertions)]
        $({
            let (e, mut err) = (stringify!($e), stderr());
            writeln!(err, "\x1B[33m{}\x1B[0m = {:?}", e, $e).unwrap()
        })*
    };
}

/// Read from standard input and parse each word.
/// - `read!(T, U, ..)` parses a line as a tuple of words.
/// - `read![[T]]` parses a line as an array of words.
/// - `read![..; N]` parses `N` lines, using `read!(..)` repeatedly.
#[allow(unused_macros)]
macro_rules! read {
    ([$t:ty] ; $n:expr) =>
        ((0..$n).map(|_| read!([$t])).collect::<Vec<_>>());
    ($($t:ty),+ ; $n:expr) =>
        ((0..$n).map(|_| read!($($t),+)).collect::<Vec<_>>());
    ([$t:ty]) =>
        (rl().split_whitespace().map(|w| w.parse().unwrap()).collect::<Vec<$t>>());
    ($($t:ty),*) => {{
        let buf = rl();
        let mut w = buf.split_whitespace();
        ($(w.next().unwrap().parse::<$t>().unwrap()),*)
    }};
}

/// Read a line from standard input.
#[allow(dead_code)]
fn rl() -> String {
    let mut buf = String::new();
    stdin().read_line(&mut buf).unwrap();

    #[allow(deprecated)]
    buf.trim_right().to_owned()
}

// -----------------------------------------------
// Solution
// -----------------------------------------------

fn main() {
    read!(usize);
    let A = read![[i64]];

    let ok = A.iter().all(|&a| a % 2 != 0 || (a % 3 == 0 || a % 5 == 0));

    println!("{}", if ok { "APPROVED" } else { "DENIED" })
}


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

int main() {
  int A, B, C;
  cin >> A >> B >> C;

  long ans{};
  if (B + 1 >= C) {
    ans = B + C;
  } else {
    ans = B * 2;
    C -= B;
    if (A + 1 >= C) {
      ans += C;
    } else {
      ans += A + 1;
    }
  }

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


Measured memory_bytes: 256